2 * switch.h: Switch configuration API
4 * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #ifndef __LINUX_SWITCH_H
18 #define __LINUX_SWITCH_H
20 #include <linux/types.h>
21 #include <linux/netdevice.h>
22 #include <linux/netlink.h>
23 #include <linux/genetlink.h>
25 #include <netlink/netlink.h>
26 #include <netlink/genl/genl.h>
27 #include <netlink/genl/ctrl.h>
29 #include <net/genetlink.h>
49 SWITCH_ATTR_OP_VALUE_INT
,
50 SWITCH_ATTR_OP_VALUE_STR
,
51 SWITCH_ATTR_OP_VALUE_PORTS
,
52 SWITCH_ATTR_OP_DESCRIPTION
,
61 SWITCH_CMD_GET_SWITCH
,
63 SWITCH_CMD_LIST_GLOBAL
,
64 SWITCH_CMD_GET_GLOBAL
,
65 SWITCH_CMD_SET_GLOBAL
,
75 enum switch_val_type
{
83 /* port nested attributes */
87 SWITCH_PORT_FLAG_TAGGED
,
91 #define SWITCH_ATTR_DEFAULTS_OFFSET 0x1000
99 struct switch_attrlist
;
101 int register_switch(struct switch_dev
*dev
, struct net_device
*netdev
);
102 void unregister_switch(struct switch_dev
*dev
);
104 struct switch_attrlist
{
105 /* filled in by the driver */
107 const struct switch_attr
*attr
;
116 /* NB: either devname or netdev must be set */
118 struct net_device
*netdev
;
123 struct switch_attrlist attr_global
, attr_port
, attr_vlan
;
126 struct switch_port
*portbuf
;
127 struct list_head dev_list
;
128 unsigned long def_global
, def_port
, def_vlan
;
130 int (*get_vlan_ports
)(struct switch_dev
*dev
, struct switch_val
*val
);
131 int (*set_vlan_ports
)(struct switch_dev
*dev
, struct switch_val
*val
);
132 int (*get_port_pvid
)(struct switch_dev
*dev
, int port
, int *val
);
133 int (*set_port_pvid
)(struct switch_dev
*dev
, int port
, int val
);
134 int (*apply_config
)(struct switch_dev
*dev
);
143 const struct switch_attr
*attr
;
149 struct switch_port
*ports
;
157 const char *description
;
159 int (*set
)(struct switch_dev
*dev
, const struct switch_attr
*attr
, struct switch_val
*val
);
160 int (*get
)(struct switch_dev
*dev
, const struct switch_attr
*attr
, struct switch_val
*val
);
162 /* for driver internal use */