aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/if_vlan.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:08:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:08:52 -0400
commit73287a43cc79ca06629a88d1a199cd283f42456a (patch)
treeacf4456e260115bea77ee31a29f10ce17f0db45c /include/linux/if_vlan.h
parent251df49db3327c64bf917bfdba94491fde2b4ee0 (diff)
parent20074f357da4a637430aec2879c9d864c5d2c23c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: "Highlights (1721 non-merge commits, this has to be a record of some sort): 1) Add 'random' mode to team driver, from Jiri Pirko and Eric Dumazet. 2) Make it so that any driver that supports configuration of multiple MAC addresses can provide the forwarding database add and del calls by providing a default implementation and hooking that up if the driver doesn't have an explicit set of handlers. From Vlad Yasevich. 3) Support GSO segmentation over tunnels and other encapsulating devices such as VXLAN, from Pravin B Shelar. 4) Support L2 GRE tunnels in the flow dissector, from Michael Dalton. 5) Implement Tail Loss Probe (TLP) detection in TCP, from Nandita Dukkipati. 6) In the PHY layer, allow supporting wake-on-lan in situations where the PHY registers have to be written for it to be configured. Use it to support wake-on-lan in mv643xx_eth. From Michael Stapelberg. 7) Significantly improve firewire IPV6 support, from YOSHIFUJI Hideaki. 8) Allow multiple packets to be sent in a single transmission using network coding in batman-adv, from Martin Hundebøll. 9) Add support for T5 cxgb4 chips, from Santosh Rastapur. 10) Generalize the VXLAN forwarding tables so that there is more flexibility in configurating various aspects of the endpoints. From David Stevens. 11) Support RSS and TSO in hardware over GRE tunnels in bxn2x driver, from Dmitry Kravkov. 12) Zero copy support in nfnelink_queue, from Eric Dumazet and Pablo Neira Ayuso. 13) Start adding networking selftests. 14) In situations of overload on the same AF_PACKET fanout socket, or per-cpu packet receive queue, minimize drop by distributing the load to other cpus/fanouts. From Willem de Bruijn and Eric Dumazet. 15) Add support for new payload offset BPF instruction, from Daniel Borkmann. 16) Convert several drivers over to mdoule_platform_driver(), from Sachin Kamat. 17) Provide a minimal BPF JIT image disassembler userspace tool, from Daniel Borkmann. 18) Rewrite F-RTO implementation in TCP to match the final specification of it in RFC4138 and RFC5682. From Yuchung Cheng. 19) Provide netlink socket diag of netlink sockets ("Yo dawg, I hear you like netlink, so I implemented netlink dumping of netlink sockets.") From Andrey Vagin. 20) Remove ugly passing of rtnetlink attributes into rtnl_doit functions, from Thomas Graf. 21) Allow userspace to be able to see if a configuration change occurs in the middle of an address or device list dump, from Nicolas Dichtel. 22) Support RFC3168 ECN protection for ipv6 fragments, from Hannes Frederic Sowa. 23) Increase accuracy of packet length used by packet scheduler, from Jason Wang. 24) Beginning set of changes to make ipv4/ipv6 fragment handling more scalable and less susceptible to overload and locking contention, from Jesper Dangaard Brouer. 25) Get rid of using non-type-safe NLMSG_* macros and use nlmsg_*() instead. From Hong Zhiguo. 26) Optimize route usage in IPVS by avoiding reference counting where possible, from Julian Anastasov. 27) Convert IPVS schedulers to RCU, also from Julian Anastasov. 28) Support cpu fanouts in xt_NFQUEUE netfilter target, from Holger Eitzenberger. 29) Network namespace support for nf_log, ebt_log, xt_LOG, ipt_ULOG, nfnetlink_log, and nfnetlink_queue. From Gao feng. 30) Implement RFC3168 ECN protection, from Hannes Frederic Sowa. 31) Support several new r8169 chips, from Hayes Wang. 32) Support tokenized interface identifiers in ipv6, from Daniel Borkmann. 33) Use usbnet_link_change() helper in USB net driver, from Ming Lei. 34) Add 802.1ad vlan offload support, from Patrick McHardy. 35) Support mmap() based netlink communication, also from Patrick McHardy. 36) Support HW timestamping in mlx4 driver, from Amir Vadai. 37) Rationalize AF_PACKET packet timestamping when transmitting, from Willem de Bruijn and Daniel Borkmann. 38) Bring parity to what's provided by /proc/net/packet socket dumping and the info provided by netlink socket dumping of AF_PACKET sockets. From Nicolas Dichtel. 39) Fix peeking beyond zero sized SKBs in AF_UNIX, from Benjamin Poirier" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1722 commits) filter: fix va_list build error af_unix: fix a fatal race with bit fields bnx2x: Prevent memory leak when cnic is absent bnx2x: correct reading of speed capabilities net: sctp: attribute printl with __printf for gcc fmt checks netlink: kconfig: move mmap i/o into netlink kconfig netpoll: convert mutex into a semaphore netlink: Fix skb ref counting. net_sched: act_ipt forward compat with xtables mlx4_en: fix a build error on 32bit arches Revert "bnx2x: allow nvram test to run when device is down" bridge: avoid OOPS if root port not found drivers: net: cpsw: fix kernel warn on cpsw irq enable sh_eth: use random MAC address if no valid one supplied 3c509.c: call SET_NETDEV_DEV for all device types (ISA/ISAPnP/EISA) tg3: fix to append hardware time stamping flags unix/stream: fix peeking with an offset larger than data in queue unix/dgram: fix peeking with an offset larger than data in queue unix/dgram: peek beyond 0-sized skbs openvswitch: Remove unneeded ovs_netdev_get_ifindex() ...
Diffstat (limited to 'include/linux/if_vlan.h')
-rw-r--r--include/linux/if_vlan.h56
1 files changed, 37 insertions, 19 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 218a3b686d90..52bd03b38962 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -86,15 +86,15 @@ static inline int is_vlan_dev(struct net_device *dev)
86#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 86#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
87 87
88extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev, 88extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
89 u16 vlan_id); 89 __be16 vlan_proto, u16 vlan_id);
90extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); 90extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
91extern u16 vlan_dev_vlan_id(const struct net_device *dev); 91extern u16 vlan_dev_vlan_id(const struct net_device *dev);
92 92
93extern bool vlan_do_receive(struct sk_buff **skb); 93extern bool vlan_do_receive(struct sk_buff **skb);
94extern struct sk_buff *vlan_untag(struct sk_buff *skb); 94extern struct sk_buff *vlan_untag(struct sk_buff *skb);
95 95
96extern int vlan_vid_add(struct net_device *dev, unsigned short vid); 96extern int vlan_vid_add(struct net_device *dev, __be16 proto, u16 vid);
97extern void vlan_vid_del(struct net_device *dev, unsigned short vid); 97extern void vlan_vid_del(struct net_device *dev, __be16 proto, u16 vid);
98 98
99extern int vlan_vids_add_by_dev(struct net_device *dev, 99extern int vlan_vids_add_by_dev(struct net_device *dev,
100 const struct net_device *by_dev); 100 const struct net_device *by_dev);
@@ -104,7 +104,8 @@ extern void vlan_vids_del_by_dev(struct net_device *dev,
104extern bool vlan_uses_dev(const struct net_device *dev); 104extern bool vlan_uses_dev(const struct net_device *dev);
105#else 105#else
106static inline struct net_device * 106static inline struct net_device *
107__vlan_find_dev_deep(struct net_device *real_dev, u16 vlan_id) 107__vlan_find_dev_deep(struct net_device *real_dev,
108 __be16 vlan_proto, u16 vlan_id)
108{ 109{
109 return NULL; 110 return NULL;
110} 111}
@@ -131,12 +132,12 @@ static inline struct sk_buff *vlan_untag(struct sk_buff *skb)
131 return skb; 132 return skb;
132} 133}
133 134
134static inline int vlan_vid_add(struct net_device *dev, unsigned short vid) 135static inline int vlan_vid_add(struct net_device *dev, __be16 proto, u16 vid)
135{ 136{
136 return 0; 137 return 0;
137} 138}
138 139
139static inline void vlan_vid_del(struct net_device *dev, unsigned short vid) 140static inline void vlan_vid_del(struct net_device *dev, __be16 proto, u16 vid)
140{ 141{
141} 142}
142 143
@@ -157,9 +158,20 @@ static inline bool vlan_uses_dev(const struct net_device *dev)
157} 158}
158#endif 159#endif
159 160
161static inline bool vlan_hw_offload_capable(netdev_features_t features,
162 __be16 proto)
163{
164 if (proto == htons(ETH_P_8021Q) && features & NETIF_F_HW_VLAN_CTAG_TX)
165 return true;
166 if (proto == htons(ETH_P_8021AD) && features & NETIF_F_HW_VLAN_STAG_TX)
167 return true;
168 return false;
169}
170
160/** 171/**
161 * vlan_insert_tag - regular VLAN tag inserting 172 * vlan_insert_tag - regular VLAN tag inserting
162 * @skb: skbuff to tag 173 * @skb: skbuff to tag
174 * @vlan_proto: VLAN encapsulation protocol
163 * @vlan_tci: VLAN TCI to insert 175 * @vlan_tci: VLAN TCI to insert
164 * 176 *
165 * Inserts the VLAN tag into @skb as part of the payload 177 * Inserts the VLAN tag into @skb as part of the payload
@@ -170,7 +182,8 @@ static inline bool vlan_uses_dev(const struct net_device *dev)
170 * 182 *
171 * Does not change skb->protocol so this function can be used during receive. 183 * Does not change skb->protocol so this function can be used during receive.
172 */ 184 */
173static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci) 185static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb,
186 __be16 vlan_proto, u16 vlan_tci)
174{ 187{
175 struct vlan_ethhdr *veth; 188 struct vlan_ethhdr *veth;
176 189
@@ -185,7 +198,7 @@ static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci)
185 skb->mac_header -= VLAN_HLEN; 198 skb->mac_header -= VLAN_HLEN;
186 199
187 /* first, the ethernet type */ 200 /* first, the ethernet type */
188 veth->h_vlan_proto = htons(ETH_P_8021Q); 201 veth->h_vlan_proto = vlan_proto;
189 202
190 /* now, the TCI */ 203 /* now, the TCI */
191 veth->h_vlan_TCI = htons(vlan_tci); 204 veth->h_vlan_TCI = htons(vlan_tci);
@@ -204,24 +217,28 @@ static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci)
204 * Following the skb_unshare() example, in case of error, the calling function 217 * Following the skb_unshare() example, in case of error, the calling function
205 * doesn't have to worry about freeing the original skb. 218 * doesn't have to worry about freeing the original skb.
206 */ 219 */
207static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) 220static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb,
221 __be16 vlan_proto, u16 vlan_tci)
208{ 222{
209 skb = vlan_insert_tag(skb, vlan_tci); 223 skb = vlan_insert_tag(skb, vlan_proto, vlan_tci);
210 if (skb) 224 if (skb)
211 skb->protocol = htons(ETH_P_8021Q); 225 skb->protocol = vlan_proto;
212 return skb; 226 return skb;
213} 227}
214 228
215/** 229/**
216 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting 230 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
217 * @skb: skbuff to tag 231 * @skb: skbuff to tag
232 * @vlan_proto: VLAN encapsulation protocol
218 * @vlan_tci: VLAN TCI to insert 233 * @vlan_tci: VLAN TCI to insert
219 * 234 *
220 * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest 235 * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest
221 */ 236 */
222static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, 237static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
238 __be16 vlan_proto,
223 u16 vlan_tci) 239 u16 vlan_tci)
224{ 240{
241 skb->vlan_proto = vlan_proto;
225 skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci; 242 skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci;
226 return skb; 243 return skb;
227} 244}
@@ -236,12 +253,13 @@ static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
236 * Assumes skb->dev is the target that will xmit this frame. 253 * Assumes skb->dev is the target that will xmit this frame.
237 * Returns a VLAN tagged skb. 254 * Returns a VLAN tagged skb.
238 */ 255 */
239static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) 256static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb,
257 __be16 vlan_proto, u16 vlan_tci)
240{ 258{
241 if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 259 if (vlan_hw_offload_capable(skb->dev->features, vlan_proto)) {
242 return __vlan_hwaccel_put_tag(skb, vlan_tci); 260 return __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
243 } else { 261 } else {
244 return __vlan_put_tag(skb, vlan_tci); 262 return __vlan_put_tag(skb, vlan_proto, vlan_tci);
245 } 263 }
246} 264}
247 265
@@ -256,9 +274,9 @@ static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
256{ 274{
257 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; 275 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
258 276
259 if (veth->h_vlan_proto != htons(ETH_P_8021Q)) { 277 if (veth->h_vlan_proto != htons(ETH_P_8021Q) &&
278 veth->h_vlan_proto != htons(ETH_P_8021AD))
260 return -EINVAL; 279 return -EINVAL;
261 }
262 280
263 *vlan_tci = ntohs(veth->h_vlan_TCI); 281 *vlan_tci = ntohs(veth->h_vlan_TCI);
264 return 0; 282 return 0;
@@ -294,7 +312,7 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
294 */ 312 */
295static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) 313static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
296{ 314{
297 if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 315 if (skb->dev->features & NETIF_F_HW_VLAN_CTAG_TX) {
298 return __vlan_hwaccel_get_tag(skb, vlan_tci); 316 return __vlan_hwaccel_get_tag(skb, vlan_tci);
299 } else { 317 } else {
300 return __vlan_get_tag(skb, vlan_tci); 318 return __vlan_get_tag(skb, vlan_tci);
@@ -339,7 +357,7 @@ static inline void vlan_set_encap_proto(struct sk_buff *skb,
339 */ 357 */
340 358
341 proto = vhdr->h_vlan_encapsulated_proto; 359 proto = vhdr->h_vlan_encapsulated_proto;
342 if (ntohs(proto) >= 1536) { 360 if (ntohs(proto) >= ETH_P_802_3_MIN) {
343 skb->protocol = proto; 361 skb->protocol = proto;
344 return; 362 return;
345 } 363 }