diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-08-04 00:43:40 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2010-08-04 00:43:40 +0000 |
commit | bd6324190fb4784a51ae70ecd0b1e0c606213702 (patch) | |
tree | fb07f597da35c8b342abb43998198b47d8f3f34d /target/linux/generic/files/include | |
parent | 86b209211e125479e547b18163b01dc99cfc400d (diff) | |
download | upstream-bd6324190fb4784a51ae70ecd0b1e0c606213702.tar.gz upstream-bd6324190fb4784a51ae70ecd0b1e0c606213702.tar.bz2 upstream-bd6324190fb4784a51ae70ecd0b1e0c606213702.zip |
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
SVN-Revision: 22476
Diffstat (limited to 'target/linux/generic/files/include')
-rw-r--r-- | target/linux/generic/files/include/linux/switch.h | 53 |
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 { |