From bd6324190fb4784a51ae70ecd0b1e0c606213702 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 4 Aug 2010 00:43:40 +0000 Subject: 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 --- target/linux/generic/files/include/linux/switch.h | 53 ++++++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'target/linux/generic/files/include') 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 { -- cgit v1.2.3