summaryrefslogtreecommitdiff
path: root/target/linux/generic/files/include
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-08-04 00:43:40 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-08-04 00:43:40 +0000
commitf093fbf8a31d704c1a92f5ca1db8b01eda292e8b (patch)
treea9432c86caea410933545f281cf2bba534c5e3f4 /target/linux/generic/files/include
parentfa5411e7e4ae9c4c99a897069ac7757d8748d5df (diff)
swconfig: cleanup of kernel drivers and interface
- add some comments to a few data structures - add a switch_dev_ops data structure for attributes and callback to replace the stupid template memcpy - get rid of the switch_dev.priv pointer - using container_of() is better git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22476 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/include')
-rw-r--r--target/linux/generic/files/include/linux/switch.h53
1 files changed, 41 insertions, 12 deletions
diff --git a/target/linux/generic/files/include/linux/switch.h b/target/linux/generic/files/include/linux/switch.h
index 25aedb83b0..ef2dc3ad9f 100644
--- a/target/linux/generic/files/include/linux/switch.h
+++ b/target/linux/generic/files/include/linux/switch.h
@@ -102,16 +102,50 @@ struct switch_attrlist;
int register_switch(struct switch_dev *dev, struct net_device *netdev);
void unregister_switch(struct switch_dev *dev);
+/**
+ * struct switch_attrlist - attribute list
+ *
+ * @n_attr: number of attributes
+ * @attr: pointer to the attributes array
+ */
struct switch_attrlist {
- /* filled in by the driver */
int n_attr;
const struct switch_attr *attr;
};
+/**
+ * struct switch_dev_ops - switch driver operations
+ *
+ * @attr_global: global switch attribute list
+ * @attr_port: port attribute list
+ * @attr_vlan: vlan attribute list
+ *
+ * Callbacks:
+ *
+ * @get_vlan_ports: read the port list of a VLAN
+ * @set_vlan_ports: set the port list of a VLAN
+ *
+ * @get_port_pvid: get the primary VLAN ID of a port
+ * @set_port_pvid: set the primary VLAN ID of a port
+ *
+ * @apply_config: apply all changed settings to the switch
+ * @reset_switch: resetting the switch
+ */
+struct switch_dev_ops {
+ struct switch_attrlist attr_global, attr_port, attr_vlan;
+
+ int (*get_vlan_ports)(struct switch_dev *dev, struct switch_val *val);
+ int (*set_vlan_ports)(struct switch_dev *dev, struct switch_val *val);
+
+ int (*get_port_pvid)(struct switch_dev *dev, int port, int *val);
+ int (*set_port_pvid)(struct switch_dev *dev, int port, int val);
+
+ int (*apply_config)(struct switch_dev *dev);
+ int (*reset_switch)(struct switch_dev *dev);
+};
struct switch_dev {
- int id;
- void *priv;
+ const struct switch_dev_ops *ops;
const char *name;
/* NB: either devname or netdev must be set */
@@ -121,19 +155,14 @@ struct switch_dev {
int ports;
int vlans;
int cpu_port;
- struct switch_attrlist attr_global, attr_port, attr_vlan;
- spinlock_t lock;
- struct switch_port *portbuf;
+ /* the following fields are internal for swconfig */
+ int id;
struct list_head dev_list;
unsigned long def_global, def_port, def_vlan;
- int (*get_vlan_ports)(struct switch_dev *dev, struct switch_val *val);
- int (*set_vlan_ports)(struct switch_dev *dev, struct switch_val *val);
- int (*get_port_pvid)(struct switch_dev *dev, int port, int *val);
- int (*set_port_pvid)(struct switch_dev *dev, int port, int val);
- int (*apply_config)(struct switch_dev *dev);
- int (*reset_switch)(struct switch_dev *dev);
+ spinlock_t lock;
+ struct switch_port *portbuf;
};
struct switch_port {