diff options
author | Patrick McHardy <kaber@trash.net> | 2008-07-15 01:49:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-15 01:49:06 -0400 |
commit | 6aa895b047720f71ec4eb11452f7c3ce8426941f (patch) | |
tree | ba52827c2e90de0678043ecf9d43208057d05da7 /include/linux | |
parent | 968edbe1c82f1a50d80225ed7e410aba419e55bf (diff) |
vlan: Don't store VLAN tag in cb
Use a real skb member to store the skb to avoid clashes with qdiscs,
which are allowed to use the cb area themselves. As currently only real
devices that consume the skb set the NETIF_F_HW_VLAN_TX flag, no explicit
invalidation is neccessary.
The new member fills a hole on 64 bit, the skb layout changes from:
__u32 mark; /* 172 4 */
sk_buff_data_t transport_header; /* 176 4 */
sk_buff_data_t network_header; /* 180 4 */
sk_buff_data_t mac_header; /* 184 4 */
sk_buff_data_t tail; /* 188 4 */
/* --- cacheline 3 boundary (192 bytes) --- */
sk_buff_data_t end; /* 192 4 */
/* XXX 4 bytes hole, try to pack */
to
__u32 mark; /* 172 4 */
__u16 vlan_tci; /* 176 2 */
/* XXX 2 bytes hole, try to pack */
sk_buff_data_t transport_header; /* 180 4 */
sk_buff_data_t network_header; /* 184 4 */
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/if_vlan.h | 31 | ||||
-rw-r--r-- | include/linux/skbuff.h | 3 |
2 files changed, 10 insertions, 24 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 93f5d9b0e9f9..9e7b49b8062d 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h | |||
@@ -105,17 +105,8 @@ static inline void vlan_group_set_device(struct vlan_group *vg, | |||
105 | array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev; | 105 | array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev; |
106 | } | 106 | } |
107 | 107 | ||
108 | /* VLAN tx hw acceleration helpers. */ | 108 | #define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci) |
109 | struct vlan_skb_tx_cookie { | 109 | #define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci) |
110 | u32 magic; | ||
111 | u32 vlan_tag; | ||
112 | }; | ||
113 | |||
114 | #define VLAN_TX_COOKIE_MAGIC 0x564c414e /* "VLAN" in ascii. */ | ||
115 | #define VLAN_TX_SKB_CB(__skb) ((struct vlan_skb_tx_cookie *)&((__skb)->cb[0])) | ||
116 | #define vlan_tx_tag_present(__skb) \ | ||
117 | (VLAN_TX_SKB_CB(__skb)->magic == VLAN_TX_COOKIE_MAGIC) | ||
118 | #define vlan_tx_tag_get(__skb) (VLAN_TX_SKB_CB(__skb)->vlan_tag) | ||
119 | 110 | ||
120 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | 111 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) |
121 | extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); | 112 | extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); |
@@ -210,17 +201,12 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) | |||
210 | * @skb: skbuff to tag | 201 | * @skb: skbuff to tag |
211 | * @vlan_tci: VLAN TCI to insert | 202 | * @vlan_tci: VLAN TCI to insert |
212 | * | 203 | * |
213 | * Puts the VLAN TCI in @skb->cb[] and lets the device do the rest | 204 | * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest |
214 | */ | 205 | */ |
215 | static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, | 206 | static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, |
216 | u16 vlan_tci) | 207 | u16 vlan_tci) |
217 | { | 208 | { |
218 | struct vlan_skb_tx_cookie *cookie; | 209 | skb->vlan_tci = vlan_tci; |
219 | |||
220 | cookie = VLAN_TX_SKB_CB(skb); | ||
221 | cookie->magic = VLAN_TX_COOKIE_MAGIC; | ||
222 | cookie->vlan_tag = vlan_tci; | ||
223 | |||
224 | return skb; | 210 | return skb; |
225 | } | 211 | } |
226 | 212 | ||
@@ -267,16 +253,13 @@ static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) | |||
267 | * @skb: skbuff to query | 253 | * @skb: skbuff to query |
268 | * @vlan_tci: buffer to store vlaue | 254 | * @vlan_tci: buffer to store vlaue |
269 | * | 255 | * |
270 | * Returns error if @skb->cb[] is not set correctly | 256 | * Returns error if @skb->vlan_tci is not set correctly |
271 | */ | 257 | */ |
272 | static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, | 258 | static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, |
273 | u16 *vlan_tci) | 259 | u16 *vlan_tci) |
274 | { | 260 | { |
275 | struct vlan_skb_tx_cookie *cookie; | 261 | if (vlan_tx_tag_present(skb)) { |
276 | 262 | *vlan_tci = skb->vlan_tci; | |
277 | cookie = VLAN_TX_SKB_CB(skb); | ||
278 | if (cookie->magic == VLAN_TX_COOKIE_MAGIC) { | ||
279 | *vlan_tci = cookie->vlan_tag; | ||
280 | return 0; | 263 | return 0; |
281 | } else { | 264 | } else { |
282 | *vlan_tci = 0; | 265 | *vlan_tci = 0; |
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 8f10e3d08fd9..7ea44f6621f2 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -246,6 +246,7 @@ typedef unsigned char *sk_buff_data_t; | |||
246 | * @dma_cookie: a cookie to one of several possible DMA operations | 246 | * @dma_cookie: a cookie to one of several possible DMA operations |
247 | * done by skb DMA functions | 247 | * done by skb DMA functions |
248 | * @secmark: security marking | 248 | * @secmark: security marking |
249 | * @vlan_tci: vlan tag control information | ||
249 | */ | 250 | */ |
250 | 251 | ||
251 | struct sk_buff { | 252 | struct sk_buff { |
@@ -326,6 +327,8 @@ struct sk_buff { | |||
326 | 327 | ||
327 | __u32 mark; | 328 | __u32 mark; |
328 | 329 | ||
330 | __u16 vlan_tci; | ||
331 | |||
329 | sk_buff_data_t transport_header; | 332 | sk_buff_data_t transport_header; |
330 | sk_buff_data_t network_header; | 333 | sk_buff_data_t network_header; |
331 | sk_buff_data_t mac_header; | 334 | sk_buff_data_t mac_header; |