diff options
author | Patrick McHardy <kaber@trash.net> | 2008-07-08 06:24:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-08 06:24:44 -0400 |
commit | 9bb8582efb555521c7eec595ebd34e835ddc34b8 (patch) | |
tree | 8eb6aae062bbd359e820a35d51fb16a32e7b828f /include | |
parent | df6b6a0cf62afeacdeb4c1a35b8fba21fda54399 (diff) |
vlan: TCI related type and naming cleanups
The VLAN code contains multiple spots that use tag, id and tci as
identifiers for arguments and variables incorrectly and they actually
contain or are expected to contain something different. Additionally
types are used inconsistently (unsigned short vs u16) and identifiers
are sometimes capitalized.
- consistently use u16 for storing TCI, ID or QoS values
- consistently use vlan_id and vlan_tci for storing the respective values
- remove capitalization
- add kdoc comment to netif_hwaccel_{rx,receive_skb}
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/if_vlan.h | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 8e68b05b13df..d36515dae62f 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h | |||
@@ -87,7 +87,7 @@ struct vlan_group { | |||
87 | }; | 87 | }; |
88 | 88 | ||
89 | static inline struct net_device *vlan_group_get_device(struct vlan_group *vg, | 89 | static inline struct net_device *vlan_group_get_device(struct vlan_group *vg, |
90 | unsigned int vlan_id) | 90 | u16 vlan_id) |
91 | { | 91 | { |
92 | struct net_device **array; | 92 | struct net_device **array; |
93 | array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN]; | 93 | array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN]; |
@@ -95,7 +95,7 @@ static inline struct net_device *vlan_group_get_device(struct vlan_group *vg, | |||
95 | } | 95 | } |
96 | 96 | ||
97 | static inline void vlan_group_set_device(struct vlan_group *vg, | 97 | static inline void vlan_group_set_device(struct vlan_group *vg, |
98 | unsigned int vlan_id, | 98 | u16 vlan_id, |
99 | struct net_device *dev) | 99 | struct net_device *dev) |
100 | { | 100 | { |
101 | struct net_device **array; | 101 | struct net_device **array; |
@@ -122,7 +122,7 @@ extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); | |||
122 | extern u16 vlan_dev_vlan_id(const struct net_device *dev); | 122 | extern u16 vlan_dev_vlan_id(const struct net_device *dev); |
123 | 123 | ||
124 | extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, | 124 | extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, |
125 | unsigned short vlan_tag, int polling); | 125 | u16 vlan_tci, int polling); |
126 | #else | 126 | #else |
127 | static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev) | 127 | static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev) |
128 | { | 128 | { |
@@ -137,39 +137,51 @@ static inline u16 vlan_dev_vlan_id(const struct net_device *dev) | |||
137 | } | 137 | } |
138 | 138 | ||
139 | static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, | 139 | static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, |
140 | unsigned short vlan_tag, int polling) | 140 | u16 vlan_tci, int polling) |
141 | { | 141 | { |
142 | BUG(); | 142 | BUG(); |
143 | return NET_XMIT_SUCCESS; | 143 | return NET_XMIT_SUCCESS; |
144 | } | 144 | } |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | /** | ||
148 | * vlan_hwaccel_rx - netif_rx wrapper for VLAN RX acceleration | ||
149 | * @skb: buffer | ||
150 | * @grp: vlan group | ||
151 | * @vlan_tci: VLAN TCI as received from the card | ||
152 | */ | ||
147 | static inline int vlan_hwaccel_rx(struct sk_buff *skb, | 153 | static inline int vlan_hwaccel_rx(struct sk_buff *skb, |
148 | struct vlan_group *grp, | 154 | struct vlan_group *grp, |
149 | unsigned short vlan_tag) | 155 | u16 vlan_tci) |
150 | { | 156 | { |
151 | return __vlan_hwaccel_rx(skb, grp, vlan_tag, 0); | 157 | return __vlan_hwaccel_rx(skb, grp, vlan_tci, 0); |
152 | } | 158 | } |
153 | 159 | ||
160 | /** | ||
161 | * vlan_hwaccel_receive_skb - netif_receive_skb wrapper for VLAN RX acceleration | ||
162 | * @skb: buffer | ||
163 | * @grp: vlan group | ||
164 | * @vlan_tci: VLAN TCI as received from the card | ||
165 | */ | ||
154 | static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb, | 166 | static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb, |
155 | struct vlan_group *grp, | 167 | struct vlan_group *grp, |
156 | unsigned short vlan_tag) | 168 | u16 vlan_tci) |
157 | { | 169 | { |
158 | return __vlan_hwaccel_rx(skb, grp, vlan_tag, 1); | 170 | return __vlan_hwaccel_rx(skb, grp, vlan_tci, 1); |
159 | } | 171 | } |
160 | 172 | ||
161 | /** | 173 | /** |
162 | * __vlan_put_tag - regular VLAN tag inserting | 174 | * __vlan_put_tag - regular VLAN tag inserting |
163 | * @skb: skbuff to tag | 175 | * @skb: skbuff to tag |
164 | * @tag: VLAN tag to insert | 176 | * @vlan_tci: VLAN TCI to insert |
165 | * | 177 | * |
166 | * Inserts the VLAN tag into @skb as part of the payload | 178 | * Inserts the VLAN tag into @skb as part of the payload |
167 | * Returns a VLAN tagged skb. If a new skb is created, @skb is freed. | 179 | * Returns a VLAN tagged skb. If a new skb is created, @skb is freed. |
168 | * | 180 | * |
169 | * Following the skb_unshare() example, in case of error, the calling function | 181 | * Following the skb_unshare() example, in case of error, the calling function |
170 | * doesn't have to worry about freeing the original skb. | 182 | * doesn't have to worry about freeing the original skb. |
171 | */ | 183 | */ |
172 | static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag) | 184 | static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) |
173 | { | 185 | { |
174 | struct vlan_ethhdr *veth; | 186 | struct vlan_ethhdr *veth; |
175 | 187 | ||
@@ -197,8 +209,8 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short | |||
197 | /* first, the ethernet type */ | 209 | /* first, the ethernet type */ |
198 | veth->h_vlan_proto = htons(ETH_P_8021Q); | 210 | veth->h_vlan_proto = htons(ETH_P_8021Q); |
199 | 211 | ||
200 | /* now, the tag */ | 212 | /* now, the TCI */ |
201 | veth->h_vlan_TCI = htons(tag); | 213 | veth->h_vlan_TCI = htons(vlan_tci); |
202 | 214 | ||
203 | skb->protocol = htons(ETH_P_8021Q); | 215 | skb->protocol = htons(ETH_P_8021Q); |
204 | 216 | ||
@@ -208,17 +220,18 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short | |||
208 | /** | 220 | /** |
209 | * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting | 221 | * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting |
210 | * @skb: skbuff to tag | 222 | * @skb: skbuff to tag |
211 | * @tag: VLAN tag to insert | 223 | * @vlan_tci: VLAN TCI to insert |
212 | * | 224 | * |
213 | * Puts the VLAN tag in @skb->cb[] and lets the device do the rest | 225 | * Puts the VLAN TCI in @skb->cb[] and lets the device do the rest |
214 | */ | 226 | */ |
215 | static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsigned short tag) | 227 | static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, |
228 | u16 vlan_tci) | ||
216 | { | 229 | { |
217 | struct vlan_skb_tx_cookie *cookie; | 230 | struct vlan_skb_tx_cookie *cookie; |
218 | 231 | ||
219 | cookie = VLAN_TX_SKB_CB(skb); | 232 | cookie = VLAN_TX_SKB_CB(skb); |
220 | cookie->magic = VLAN_TX_COOKIE_MAGIC; | 233 | cookie->magic = VLAN_TX_COOKIE_MAGIC; |
221 | cookie->vlan_tag = tag; | 234 | cookie->vlan_tag = vlan_tci; |
222 | 235 | ||
223 | return skb; | 236 | return skb; |
224 | } | 237 | } |
@@ -228,28 +241,28 @@ static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsign | |||
228 | /** | 241 | /** |
229 | * vlan_put_tag - inserts VLAN tag according to device features | 242 | * vlan_put_tag - inserts VLAN tag according to device features |
230 | * @skb: skbuff to tag | 243 | * @skb: skbuff to tag |
231 | * @tag: VLAN tag to insert | 244 | * @vlan_tci: VLAN TCI to insert |
232 | * | 245 | * |
233 | * Assumes skb->dev is the target that will xmit this frame. | 246 | * Assumes skb->dev is the target that will xmit this frame. |
234 | * Returns a VLAN tagged skb. | 247 | * Returns a VLAN tagged skb. |
235 | */ | 248 | */ |
236 | static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, unsigned short tag) | 249 | static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) |
237 | { | 250 | { |
238 | if (skb->dev->features & NETIF_F_HW_VLAN_TX) { | 251 | if (skb->dev->features & NETIF_F_HW_VLAN_TX) { |
239 | return __vlan_hwaccel_put_tag(skb, tag); | 252 | return __vlan_hwaccel_put_tag(skb, vlan_tci); |
240 | } else { | 253 | } else { |
241 | return __vlan_put_tag(skb, tag); | 254 | return __vlan_put_tag(skb, vlan_tci); |
242 | } | 255 | } |
243 | } | 256 | } |
244 | 257 | ||
245 | /** | 258 | /** |
246 | * __vlan_get_tag - get the VLAN ID that is part of the payload | 259 | * __vlan_get_tag - get the VLAN ID that is part of the payload |
247 | * @skb: skbuff to query | 260 | * @skb: skbuff to query |
248 | * @tag: buffer to store vlaue | 261 | * @vlan_tci: buffer to store vlaue |
249 | * | 262 | * |
250 | * Returns error if the skb is not of VLAN type | 263 | * Returns error if the skb is not of VLAN type |
251 | */ | 264 | */ |
252 | static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag) | 265 | static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) |
253 | { | 266 | { |
254 | struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; | 267 | struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; |
255 | 268 | ||
@@ -257,29 +270,28 @@ static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag) | |||
257 | return -EINVAL; | 270 | return -EINVAL; |
258 | } | 271 | } |
259 | 272 | ||
260 | *tag = ntohs(veth->h_vlan_TCI); | 273 | *vlan_tci = ntohs(veth->h_vlan_TCI); |
261 | |||
262 | return 0; | 274 | return 0; |
263 | } | 275 | } |
264 | 276 | ||
265 | /** | 277 | /** |
266 | * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[] | 278 | * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[] |
267 | * @skb: skbuff to query | 279 | * @skb: skbuff to query |
268 | * @tag: buffer to store vlaue | 280 | * @vlan_tci: buffer to store vlaue |
269 | * | 281 | * |
270 | * Returns error if @skb->cb[] is not set correctly | 282 | * Returns error if @skb->cb[] is not set correctly |
271 | */ | 283 | */ |
272 | static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, | 284 | static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, |
273 | unsigned short *tag) | 285 | u16 *vlan_tci) |
274 | { | 286 | { |
275 | struct vlan_skb_tx_cookie *cookie; | 287 | struct vlan_skb_tx_cookie *cookie; |
276 | 288 | ||
277 | cookie = VLAN_TX_SKB_CB(skb); | 289 | cookie = VLAN_TX_SKB_CB(skb); |
278 | if (cookie->magic == VLAN_TX_COOKIE_MAGIC) { | 290 | if (cookie->magic == VLAN_TX_COOKIE_MAGIC) { |
279 | *tag = cookie->vlan_tag; | 291 | *vlan_tci = cookie->vlan_tag; |
280 | return 0; | 292 | return 0; |
281 | } else { | 293 | } else { |
282 | *tag = 0; | 294 | *vlan_tci = 0; |
283 | return -EINVAL; | 295 | return -EINVAL; |
284 | } | 296 | } |
285 | } | 297 | } |
@@ -289,16 +301,16 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, | |||
289 | /** | 301 | /** |
290 | * vlan_get_tag - get the VLAN ID from the skb | 302 | * vlan_get_tag - get the VLAN ID from the skb |
291 | * @skb: skbuff to query | 303 | * @skb: skbuff to query |
292 | * @tag: buffer to store vlaue | 304 | * @vlan_tci: buffer to store vlaue |
293 | * | 305 | * |
294 | * Returns error if the skb is not VLAN tagged | 306 | * Returns error if the skb is not VLAN tagged |
295 | */ | 307 | */ |
296 | static inline int vlan_get_tag(const struct sk_buff *skb, unsigned short *tag) | 308 | static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) |
297 | { | 309 | { |
298 | if (skb->dev->features & NETIF_F_HW_VLAN_TX) { | 310 | if (skb->dev->features & NETIF_F_HW_VLAN_TX) { |
299 | return __vlan_hwaccel_get_tag(skb, tag); | 311 | return __vlan_hwaccel_get_tag(skb, vlan_tci); |
300 | } else { | 312 | } else { |
301 | return __vlan_get_tag(skb, tag); | 313 | return __vlan_get_tag(skb, vlan_tci); |
302 | } | 314 | } |
303 | } | 315 | } |
304 | 316 | ||