diff options
Diffstat (limited to 'include/linux/if_team.h')
-rw-r--r-- | include/linux/if_team.h | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/include/linux/if_team.h b/include/linux/if_team.h index 58404b0c5010..8185f57a9c7f 100644 --- a/include/linux/if_team.h +++ b/include/linux/if_team.h | |||
@@ -28,10 +28,28 @@ struct team; | |||
28 | 28 | ||
29 | struct team_port { | 29 | struct team_port { |
30 | struct net_device *dev; | 30 | struct net_device *dev; |
31 | struct hlist_node hlist; /* node in hash list */ | 31 | struct hlist_node hlist; /* node in enabled ports hash list */ |
32 | struct list_head list; /* node in ordinary list */ | 32 | struct list_head list; /* node in ordinary list */ |
33 | struct team *team; | 33 | struct team *team; |
34 | int index; | 34 | int index; /* index of enabled port. If disabled, it's set to -1 */ |
35 | |||
36 | bool linkup; /* either state.linkup or user.linkup */ | ||
37 | |||
38 | struct { | ||
39 | bool linkup; | ||
40 | u32 speed; | ||
41 | u8 duplex; | ||
42 | } state; | ||
43 | |||
44 | /* Values set by userspace */ | ||
45 | struct { | ||
46 | bool linkup; | ||
47 | bool linkup_enabled; | ||
48 | } user; | ||
49 | |||
50 | /* Custom gennetlink interface related flags */ | ||
51 | bool changed; | ||
52 | bool removed; | ||
35 | 53 | ||
36 | /* | 54 | /* |
37 | * A place for storing original values of the device before it | 55 | * A place for storing original values of the device before it |
@@ -42,14 +60,6 @@ struct team_port { | |||
42 | unsigned int mtu; | 60 | unsigned int mtu; |
43 | } orig; | 61 | } orig; |
44 | 62 | ||
45 | bool linkup; | ||
46 | u32 speed; | ||
47 | u8 duplex; | ||
48 | |||
49 | /* Custom gennetlink interface related flags */ | ||
50 | bool changed; | ||
51 | bool removed; | ||
52 | |||
53 | struct rcu_head rcu; | 63 | struct rcu_head rcu; |
54 | }; | 64 | }; |
55 | 65 | ||
@@ -68,18 +78,30 @@ struct team_mode_ops { | |||
68 | enum team_option_type { | 78 | enum team_option_type { |
69 | TEAM_OPTION_TYPE_U32, | 79 | TEAM_OPTION_TYPE_U32, |
70 | TEAM_OPTION_TYPE_STRING, | 80 | TEAM_OPTION_TYPE_STRING, |
81 | TEAM_OPTION_TYPE_BINARY, | ||
82 | TEAM_OPTION_TYPE_BOOL, | ||
83 | }; | ||
84 | |||
85 | struct team_gsetter_ctx { | ||
86 | union { | ||
87 | u32 u32_val; | ||
88 | const char *str_val; | ||
89 | struct { | ||
90 | const void *ptr; | ||
91 | u32 len; | ||
92 | } bin_val; | ||
93 | bool bool_val; | ||
94 | } data; | ||
95 | struct team_port *port; | ||
71 | }; | 96 | }; |
72 | 97 | ||
73 | struct team_option { | 98 | struct team_option { |
74 | struct list_head list; | 99 | struct list_head list; |
75 | const char *name; | 100 | const char *name; |
101 | bool per_port; | ||
76 | enum team_option_type type; | 102 | enum team_option_type type; |
77 | int (*getter)(struct team *team, void *arg); | 103 | int (*getter)(struct team *team, struct team_gsetter_ctx *ctx); |
78 | int (*setter)(struct team *team, void *arg); | 104 | int (*setter)(struct team *team, struct team_gsetter_ctx *ctx); |
79 | |||
80 | /* Custom gennetlink interface related flags */ | ||
81 | bool changed; | ||
82 | bool removed; | ||
83 | }; | 105 | }; |
84 | 106 | ||
85 | struct team_mode { | 107 | struct team_mode { |
@@ -103,13 +125,15 @@ struct team { | |||
103 | struct mutex lock; /* used for overall locking, e.g. port lists write */ | 125 | struct mutex lock; /* used for overall locking, e.g. port lists write */ |
104 | 126 | ||
105 | /* | 127 | /* |
106 | * port lists with port count | 128 | * List of enabled ports and their count |
107 | */ | 129 | */ |
108 | int port_count; | 130 | int en_port_count; |
109 | struct hlist_head port_hlist[TEAM_PORT_HASHENTRIES]; | 131 | struct hlist_head en_port_hlist[TEAM_PORT_HASHENTRIES]; |
110 | struct list_head port_list; | 132 | |
133 | struct list_head port_list; /* list of all ports */ | ||
111 | 134 | ||
112 | struct list_head option_list; | 135 | struct list_head option_list; |
136 | struct list_head option_inst_list; /* list of option instances */ | ||
113 | 137 | ||
114 | const struct team_mode *mode; | 138 | const struct team_mode *mode; |
115 | struct team_mode_ops ops; | 139 | struct team_mode_ops ops; |
@@ -119,7 +143,7 @@ struct team { | |||
119 | static inline struct hlist_head *team_port_index_hash(struct team *team, | 143 | static inline struct hlist_head *team_port_index_hash(struct team *team, |
120 | int port_index) | 144 | int port_index) |
121 | { | 145 | { |
122 | return &team->port_hlist[port_index & (TEAM_PORT_HASHENTRIES - 1)]; | 146 | return &team->en_port_hlist[port_index & (TEAM_PORT_HASHENTRIES - 1)]; |
123 | } | 147 | } |
124 | 148 | ||
125 | static inline struct team_port *team_get_port_by_index(struct team *team, | 149 | static inline struct team_port *team_get_port_by_index(struct team *team, |
@@ -216,6 +240,7 @@ enum { | |||
216 | TEAM_ATTR_OPTION_TYPE, /* u8 */ | 240 | TEAM_ATTR_OPTION_TYPE, /* u8 */ |
217 | TEAM_ATTR_OPTION_DATA, /* dynamic */ | 241 | TEAM_ATTR_OPTION_DATA, /* dynamic */ |
218 | TEAM_ATTR_OPTION_REMOVED, /* flag */ | 242 | TEAM_ATTR_OPTION_REMOVED, /* flag */ |
243 | TEAM_ATTR_OPTION_PORT_IFINDEX, /* u32 */ /* for per-port options */ | ||
219 | 244 | ||
220 | __TEAM_ATTR_OPTION_MAX, | 245 | __TEAM_ATTR_OPTION_MAX, |
221 | TEAM_ATTR_OPTION_MAX = __TEAM_ATTR_OPTION_MAX - 1, | 246 | TEAM_ATTR_OPTION_MAX = __TEAM_ATTR_OPTION_MAX - 1, |