xref: /linux/include/linux/if_vlan.h (revision a3f671b3152919e72af261333402c0f1272bdf59)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * VLAN		An implementation of 802.1Q VLAN tagging.
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Authors:	Ben Greear <greearb@candelatech.com>
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *		This program is free software; you can redistribute it and/or
71da177e4SLinus Torvalds  *		modify it under the terms of the GNU General Public License
81da177e4SLinus Torvalds  *		as published by the Free Software Foundation; either version
91da177e4SLinus Torvalds  *		2 of the License, or (at your option) any later version.
101da177e4SLinus Torvalds  *
111da177e4SLinus Torvalds  */
121da177e4SLinus Torvalds 
131da177e4SLinus Torvalds #ifndef _LINUX_IF_VLAN_H_
141da177e4SLinus Torvalds #define _LINUX_IF_VLAN_H_
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds #ifdef __KERNEL__
171da177e4SLinus Torvalds #include <linux/netdevice.h>
180610d11bSStephen Hemminger #include <linux/etherdevice.h>
1965ac6a5fSJesse Gross #include <linux/rtnetlink.h>
201da177e4SLinus Torvalds 
21*a3f671b3SJoe Perches #define VLAN_HLEN	4		/* The additional bytes required by VLAN
22*a3f671b3SJoe Perches 					 * (in addition to the Ethernet header)
231da177e4SLinus Torvalds 					 */
241da177e4SLinus Torvalds #define VLAN_ETH_HLEN	18		/* Total octets in header.	 */
251da177e4SLinus Torvalds #define VLAN_ETH_ZLEN	64		/* Min. octets in frame sans FCS */
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds /*
281da177e4SLinus Torvalds  * According to 802.3ac, the packet can be 4 bytes longer. --Klika Jan
291da177e4SLinus Torvalds  */
301da177e4SLinus Torvalds #define VLAN_ETH_DATA_LEN	1500	/* Max. octets in payload	 */
311da177e4SLinus Torvalds #define VLAN_ETH_FRAME_LEN	1518	/* Max. octets in frame sans FCS */
321da177e4SLinus Torvalds 
33740c15d0SPatrick McHardy /*
34740c15d0SPatrick McHardy  * 	struct vlan_hdr - vlan header
35740c15d0SPatrick McHardy  * 	@h_vlan_TCI: priority and VLAN ID
36740c15d0SPatrick McHardy  *	@h_vlan_encapsulated_proto: packet type ID or len
37740c15d0SPatrick McHardy  */
38740c15d0SPatrick McHardy struct vlan_hdr {
39740c15d0SPatrick McHardy 	__be16	h_vlan_TCI;
40740c15d0SPatrick McHardy 	__be16	h_vlan_encapsulated_proto;
41740c15d0SPatrick McHardy };
42740c15d0SPatrick McHardy 
43740c15d0SPatrick McHardy /**
44740c15d0SPatrick McHardy  *	struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr)
45740c15d0SPatrick McHardy  *	@h_dest: destination ethernet address
46740c15d0SPatrick McHardy  *	@h_source: source ethernet address
47740c15d0SPatrick McHardy  *	@h_vlan_proto: ethernet protocol (always 0x8100)
48740c15d0SPatrick McHardy  *	@h_vlan_TCI: priority and VLAN ID
49740c15d0SPatrick McHardy  *	@h_vlan_encapsulated_proto: packet type ID or len
50740c15d0SPatrick McHardy  */
511da177e4SLinus Torvalds struct vlan_ethhdr {
52740c15d0SPatrick McHardy 	unsigned char	h_dest[ETH_ALEN];
53740c15d0SPatrick McHardy 	unsigned char	h_source[ETH_ALEN];
54740c15d0SPatrick McHardy 	__be16		h_vlan_proto;
55740c15d0SPatrick McHardy 	__be16		h_vlan_TCI;
56740c15d0SPatrick McHardy 	__be16		h_vlan_encapsulated_proto;
571da177e4SLinus Torvalds };
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds #include <linux/skbuff.h>
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
621da177e4SLinus Torvalds {
6398e399f8SArnaldo Carvalho de Melo 	return (struct vlan_ethhdr *)skb_mac_header(skb);
641da177e4SLinus Torvalds }
651da177e4SLinus Torvalds 
6605423b24SEric Dumazet #define VLAN_PRIO_MASK		0xe000 /* Priority Code Point */
6705423b24SEric Dumazet #define VLAN_PRIO_SHIFT		13
6805423b24SEric Dumazet #define VLAN_CFI_MASK		0x1000 /* Canonical Format Indicator */
6905423b24SEric Dumazet #define VLAN_TAG_PRESENT	VLAN_CFI_MASK
7005423b24SEric Dumazet #define VLAN_VID_MASK		0x0fff /* VLAN Identifier */
71b738127dSJesse Gross #define VLAN_N_VID		4096
721da177e4SLinus Torvalds 
731da177e4SLinus Torvalds /* found in socket.c */
74881d966bSEric W. Biederman extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
751da177e4SLinus Torvalds 
765b9ea6e0SJiri Pirko struct vlan_info;
771da177e4SLinus Torvalds 
786dcbbe25SNeil Horman static inline int is_vlan_dev(struct net_device *dev)
796dcbbe25SNeil Horman {
806dcbbe25SNeil Horman         return dev->priv_flags & IFF_802_1Q_VLAN;
816dcbbe25SNeil Horman }
826dcbbe25SNeil Horman 
8305423b24SEric Dumazet #define vlan_tx_tag_present(__skb)	((__skb)->vlan_tci & VLAN_TAG_PRESENT)
8405423b24SEric Dumazet #define vlan_tx_tag_get(__skb)		((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
851da177e4SLinus Torvalds 
867750f403SPatrick McHardy #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
8765ac6a5fSJesse Gross 
88cec9c133SJiri Pirko extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
89cec9c133SJiri Pirko 					       u16 vlan_id);
9022d1ba74SPatrick McHardy extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
9122d1ba74SPatrick McHardy extern u16 vlan_dev_vlan_id(const struct net_device *dev);
9222d1ba74SPatrick McHardy 
936a32e4f9SEric Dumazet extern bool vlan_do_receive(struct sk_buff **skb, bool last_handler);
94bcc6d479SJiri Pirko extern struct sk_buff *vlan_untag(struct sk_buff *skb);
959b22ea56SPatrick McHardy 
9687002b03SJiri Pirko extern int vlan_vid_add(struct net_device *dev, unsigned short vid);
9787002b03SJiri Pirko extern void vlan_vid_del(struct net_device *dev, unsigned short vid);
9887002b03SJiri Pirko 
99348a1443SJiri Pirko extern int vlan_vids_add_by_dev(struct net_device *dev,
100348a1443SJiri Pirko 				const struct net_device *by_dev);
101348a1443SJiri Pirko extern void vlan_vids_del_by_dev(struct net_device *dev,
102348a1443SJiri Pirko 				 const struct net_device *by_dev);
1037750f403SPatrick McHardy #else
104cec9c133SJiri Pirko static inline struct net_device *
105cec9c133SJiri Pirko __vlan_find_dev_deep(struct net_device *real_dev, u16 vlan_id)
106cec9c133SJiri Pirko {
107cec9c133SJiri Pirko 	return NULL;
108cec9c133SJiri Pirko }
109cec9c133SJiri Pirko 
11022d1ba74SPatrick McHardy static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
11122d1ba74SPatrick McHardy {
11222d1ba74SPatrick McHardy 	BUG();
11322d1ba74SPatrick McHardy 	return NULL;
11422d1ba74SPatrick McHardy }
11522d1ba74SPatrick McHardy 
11622d1ba74SPatrick McHardy static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
11722d1ba74SPatrick McHardy {
11822d1ba74SPatrick McHardy 	BUG();
11922d1ba74SPatrick McHardy 	return 0;
12022d1ba74SPatrick McHardy }
12122d1ba74SPatrick McHardy 
1226a32e4f9SEric Dumazet static inline bool vlan_do_receive(struct sk_buff **skb, bool last_handler)
1239b22ea56SPatrick McHardy {
1246a32e4f9SEric Dumazet 	if (((*skb)->vlan_tci & VLAN_VID_MASK) && last_handler)
1250988c4c7SJesse Gross 		(*skb)->pkt_type = PACKET_OTHERHOST;
1263701e513SJesse Gross 	return false;
1279b22ea56SPatrick McHardy }
128e1c096e2SHerbert Xu 
1296139e75fSDavid S. Miller static inline struct sk_buff *vlan_untag(struct sk_buff *skb)
130bcc6d479SJiri Pirko {
131bcc6d479SJiri Pirko 	return skb;
132bcc6d479SJiri Pirko }
13387002b03SJiri Pirko 
13487002b03SJiri Pirko static inline int vlan_vid_add(struct net_device *dev, unsigned short vid)
13587002b03SJiri Pirko {
13687002b03SJiri Pirko 	return 0;
13787002b03SJiri Pirko }
13887002b03SJiri Pirko 
13987002b03SJiri Pirko static inline void vlan_vid_del(struct net_device *dev, unsigned short vid)
14087002b03SJiri Pirko {
14187002b03SJiri Pirko }
142348a1443SJiri Pirko 
143348a1443SJiri Pirko static inline int vlan_vids_add_by_dev(struct net_device *dev,
144348a1443SJiri Pirko 				       const struct net_device *by_dev)
145348a1443SJiri Pirko {
146348a1443SJiri Pirko 	return 0;
147348a1443SJiri Pirko }
148348a1443SJiri Pirko 
149348a1443SJiri Pirko static inline void vlan_vids_del_by_dev(struct net_device *dev,
150348a1443SJiri Pirko 					const struct net_device *by_dev)
151348a1443SJiri Pirko {
152348a1443SJiri Pirko }
1537750f403SPatrick McHardy #endif
1541da177e4SLinus Torvalds 
1559bb8582eSPatrick McHardy /**
1560b5c9db1SJiri Pirko  * vlan_insert_tag - regular VLAN tag inserting
1571da177e4SLinus Torvalds  * @skb: skbuff to tag
1589bb8582eSPatrick McHardy  * @vlan_tci: VLAN TCI to insert
1591da177e4SLinus Torvalds  *
1601da177e4SLinus Torvalds  * Inserts the VLAN tag into @skb as part of the payload
1611da177e4SLinus Torvalds  * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
1621da177e4SLinus Torvalds  *
1631da177e4SLinus Torvalds  * Following the skb_unshare() example, in case of error, the calling function
1641da177e4SLinus Torvalds  * doesn't have to worry about freeing the original skb.
1650b5c9db1SJiri Pirko  *
1660b5c9db1SJiri Pirko  * Does not change skb->protocol so this function can be used during receive.
1671da177e4SLinus Torvalds  */
1680b5c9db1SJiri Pirko static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci)
1691da177e4SLinus Torvalds {
1701da177e4SLinus Torvalds 	struct vlan_ethhdr *veth;
1711da177e4SLinus Torvalds 
17211a100f8SPatrick McHardy 	if (skb_cow_head(skb, VLAN_HLEN) < 0) {
17311a100f8SPatrick McHardy 		kfree_skb(skb);
1741da177e4SLinus Torvalds 		return NULL;
1751da177e4SLinus Torvalds 	}
1761da177e4SLinus Torvalds 	veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
1771da177e4SLinus Torvalds 
1781da177e4SLinus Torvalds 	/* Move the mac addresses to the beginning of the new header. */
179*a3f671b3SJoe Perches 	memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN);
180e4dd6188SJarek Poplawski 	skb->mac_header -= VLAN_HLEN;
1811da177e4SLinus Torvalds 
1821da177e4SLinus Torvalds 	/* first, the ethernet type */
18357d3ae84SPatrick McHardy 	veth->h_vlan_proto = htons(ETH_P_8021Q);
1841da177e4SLinus Torvalds 
1859bb8582eSPatrick McHardy 	/* now, the TCI */
1869bb8582eSPatrick McHardy 	veth->h_vlan_TCI = htons(vlan_tci);
1871da177e4SLinus Torvalds 
1880b5c9db1SJiri Pirko 	return skb;
1890b5c9db1SJiri Pirko }
1901da177e4SLinus Torvalds 
1910b5c9db1SJiri Pirko /**
1920b5c9db1SJiri Pirko  * __vlan_put_tag - regular VLAN tag inserting
1930b5c9db1SJiri Pirko  * @skb: skbuff to tag
1940b5c9db1SJiri Pirko  * @vlan_tci: VLAN TCI to insert
1950b5c9db1SJiri Pirko  *
1960b5c9db1SJiri Pirko  * Inserts the VLAN tag into @skb as part of the payload
1970b5c9db1SJiri Pirko  * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
1980b5c9db1SJiri Pirko  *
1990b5c9db1SJiri Pirko  * Following the skb_unshare() example, in case of error, the calling function
2000b5c9db1SJiri Pirko  * doesn't have to worry about freeing the original skb.
2010b5c9db1SJiri Pirko  */
2020b5c9db1SJiri Pirko static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
2030b5c9db1SJiri Pirko {
2040b5c9db1SJiri Pirko 	skb = vlan_insert_tag(skb, vlan_tci);
2050b5c9db1SJiri Pirko 	if (skb)
2060b5c9db1SJiri Pirko 		skb->protocol = htons(ETH_P_8021Q);
2071da177e4SLinus Torvalds 	return skb;
2081da177e4SLinus Torvalds }
2091da177e4SLinus Torvalds 
2101da177e4SLinus Torvalds /**
2111da177e4SLinus Torvalds  * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
2121da177e4SLinus Torvalds  * @skb: skbuff to tag
2139bb8582eSPatrick McHardy  * @vlan_tci: VLAN TCI to insert
2141da177e4SLinus Torvalds  *
2156aa895b0SPatrick McHardy  * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest
2161da177e4SLinus Torvalds  */
2179bb8582eSPatrick McHardy static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
2189bb8582eSPatrick McHardy 						     u16 vlan_tci)
2191da177e4SLinus Torvalds {
22005423b24SEric Dumazet 	skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci;
2211da177e4SLinus Torvalds 	return skb;
2221da177e4SLinus Torvalds }
2231da177e4SLinus Torvalds 
2241da177e4SLinus Torvalds #define HAVE_VLAN_PUT_TAG
2251da177e4SLinus Torvalds 
2261da177e4SLinus Torvalds /**
2271da177e4SLinus Torvalds  * vlan_put_tag - inserts VLAN tag according to device features
2281da177e4SLinus Torvalds  * @skb: skbuff to tag
2299bb8582eSPatrick McHardy  * @vlan_tci: VLAN TCI to insert
2301da177e4SLinus Torvalds  *
2311da177e4SLinus Torvalds  * Assumes skb->dev is the target that will xmit this frame.
2321da177e4SLinus Torvalds  * Returns a VLAN tagged skb.
2331da177e4SLinus Torvalds  */
2349bb8582eSPatrick McHardy static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
2351da177e4SLinus Torvalds {
2361da177e4SLinus Torvalds 	if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
2379bb8582eSPatrick McHardy 		return __vlan_hwaccel_put_tag(skb, vlan_tci);
2381da177e4SLinus Torvalds 	} else {
2399bb8582eSPatrick McHardy 		return __vlan_put_tag(skb, vlan_tci);
2401da177e4SLinus Torvalds 	}
2411da177e4SLinus Torvalds }
2421da177e4SLinus Torvalds 
2431da177e4SLinus Torvalds /**
2441da177e4SLinus Torvalds  * __vlan_get_tag - get the VLAN ID that is part of the payload
2451da177e4SLinus Torvalds  * @skb: skbuff to query
2469bb8582eSPatrick McHardy  * @vlan_tci: buffer to store vlaue
2471da177e4SLinus Torvalds  *
2481da177e4SLinus Torvalds  * Returns error if the skb is not of VLAN type
2491da177e4SLinus Torvalds  */
2509bb8582eSPatrick McHardy static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
2511da177e4SLinus Torvalds {
2521da177e4SLinus Torvalds 	struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
2531da177e4SLinus Torvalds 
25457d3ae84SPatrick McHardy 	if (veth->h_vlan_proto != htons(ETH_P_8021Q)) {
2551da177e4SLinus Torvalds 		return -EINVAL;
2561da177e4SLinus Torvalds 	}
2571da177e4SLinus Torvalds 
2589bb8582eSPatrick McHardy 	*vlan_tci = ntohs(veth->h_vlan_TCI);
2591da177e4SLinus Torvalds 	return 0;
2601da177e4SLinus Torvalds }
2611da177e4SLinus Torvalds 
2621da177e4SLinus Torvalds /**
2631da177e4SLinus Torvalds  * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
2641da177e4SLinus Torvalds  * @skb: skbuff to query
2659bb8582eSPatrick McHardy  * @vlan_tci: buffer to store vlaue
2661da177e4SLinus Torvalds  *
2676aa895b0SPatrick McHardy  * Returns error if @skb->vlan_tci is not set correctly
2681da177e4SLinus Torvalds  */
26918149935SPatrick McHardy static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
2709bb8582eSPatrick McHardy 					 u16 *vlan_tci)
2711da177e4SLinus Torvalds {
2726aa895b0SPatrick McHardy 	if (vlan_tx_tag_present(skb)) {
27305423b24SEric Dumazet 		*vlan_tci = vlan_tx_tag_get(skb);
2741da177e4SLinus Torvalds 		return 0;
2751da177e4SLinus Torvalds 	} else {
2769bb8582eSPatrick McHardy 		*vlan_tci = 0;
2771da177e4SLinus Torvalds 		return -EINVAL;
2781da177e4SLinus Torvalds 	}
2791da177e4SLinus Torvalds }
2801da177e4SLinus Torvalds 
2811da177e4SLinus Torvalds #define HAVE_VLAN_GET_TAG
2821da177e4SLinus Torvalds 
2831da177e4SLinus Torvalds /**
2841da177e4SLinus Torvalds  * vlan_get_tag - get the VLAN ID from the skb
2851da177e4SLinus Torvalds  * @skb: skbuff to query
2869bb8582eSPatrick McHardy  * @vlan_tci: buffer to store vlaue
2871da177e4SLinus Torvalds  *
2881da177e4SLinus Torvalds  * Returns error if the skb is not VLAN tagged
2891da177e4SLinus Torvalds  */
2909bb8582eSPatrick McHardy static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
2911da177e4SLinus Torvalds {
2921da177e4SLinus Torvalds 	if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
2939bb8582eSPatrick McHardy 		return __vlan_hwaccel_get_tag(skb, vlan_tci);
2941da177e4SLinus Torvalds 	} else {
2959bb8582eSPatrick McHardy 		return __vlan_get_tag(skb, vlan_tci);
2961da177e4SLinus Torvalds 	}
2971da177e4SLinus Torvalds }
2981da177e4SLinus Torvalds 
2990a85df00SHao Zheng /**
3000a85df00SHao Zheng  * vlan_get_protocol - get protocol EtherType.
3010a85df00SHao Zheng  * @skb: skbuff to query
3020a85df00SHao Zheng  *
3030a85df00SHao Zheng  * Returns the EtherType of the packet, regardless of whether it is
3040a85df00SHao Zheng  * vlan encapsulated (normal or hardware accelerated) or not.
3050a85df00SHao Zheng  */
3060a85df00SHao Zheng static inline __be16 vlan_get_protocol(const struct sk_buff *skb)
3070a85df00SHao Zheng {
3080a85df00SHao Zheng 	__be16 protocol = 0;
3090a85df00SHao Zheng 
3100a85df00SHao Zheng 	if (vlan_tx_tag_present(skb) ||
3110a85df00SHao Zheng 	     skb->protocol != cpu_to_be16(ETH_P_8021Q))
3120a85df00SHao Zheng 		protocol = skb->protocol;
3130a85df00SHao Zheng 	else {
3140a85df00SHao Zheng 		__be16 proto, *protop;
3150a85df00SHao Zheng 		protop = skb_header_pointer(skb, offsetof(struct vlan_ethhdr,
3160a85df00SHao Zheng 						h_vlan_encapsulated_proto),
3170a85df00SHao Zheng 						sizeof(proto), &proto);
3180a85df00SHao Zheng 		if (likely(protop))
3190a85df00SHao Zheng 			protocol = *protop;
3200a85df00SHao Zheng 	}
3210a85df00SHao Zheng 
3220a85df00SHao Zheng 	return protocol;
3230a85df00SHao Zheng }
324396cf943SPravin B Shelar 
325396cf943SPravin B Shelar static inline void vlan_set_encap_proto(struct sk_buff *skb,
326396cf943SPravin B Shelar 					struct vlan_hdr *vhdr)
327396cf943SPravin B Shelar {
328396cf943SPravin B Shelar 	__be16 proto;
329396cf943SPravin B Shelar 	unsigned char *rawp;
330396cf943SPravin B Shelar 
331396cf943SPravin B Shelar 	/*
332396cf943SPravin B Shelar 	 * Was a VLAN packet, grab the encapsulated protocol, which the layer
333396cf943SPravin B Shelar 	 * three protocols care about.
334396cf943SPravin B Shelar 	 */
335396cf943SPravin B Shelar 
336396cf943SPravin B Shelar 	proto = vhdr->h_vlan_encapsulated_proto;
337396cf943SPravin B Shelar 	if (ntohs(proto) >= 1536) {
338396cf943SPravin B Shelar 		skb->protocol = proto;
339396cf943SPravin B Shelar 		return;
340396cf943SPravin B Shelar 	}
341396cf943SPravin B Shelar 
342396cf943SPravin B Shelar 	rawp = skb->data;
343396cf943SPravin B Shelar 	if (*(unsigned short *) rawp == 0xFFFF)
344396cf943SPravin B Shelar 		/*
345396cf943SPravin B Shelar 		 * This is a magic hack to spot IPX packets. Older Novell
346396cf943SPravin B Shelar 		 * breaks the protocol design and runs IPX over 802.3 without
347396cf943SPravin B Shelar 		 * an 802.2 LLC layer. We look for FFFF which isn't a used
348396cf943SPravin B Shelar 		 * 802.2 SSAP/DSAP. This won't work for fault tolerant netware
349396cf943SPravin B Shelar 		 * but does for the rest.
350396cf943SPravin B Shelar 		 */
351396cf943SPravin B Shelar 		skb->protocol = htons(ETH_P_802_3);
352396cf943SPravin B Shelar 	else
353396cf943SPravin B Shelar 		/*
354396cf943SPravin B Shelar 		 * Real 802.2 LLC
355396cf943SPravin B Shelar 		 */
356396cf943SPravin B Shelar 		skb->protocol = htons(ETH_P_802_2);
357396cf943SPravin B Shelar }
3581da177e4SLinus Torvalds #endif /* __KERNEL__ */
3591da177e4SLinus Torvalds 
3601da177e4SLinus Torvalds /* VLAN IOCTLs are found in sockios.h */
3611da177e4SLinus Torvalds 
3621da177e4SLinus Torvalds /* Passed in vlan_ioctl_args structure to determine behaviour. */
3631da177e4SLinus Torvalds enum vlan_ioctl_cmds {
3641da177e4SLinus Torvalds 	ADD_VLAN_CMD,
3651da177e4SLinus Torvalds 	DEL_VLAN_CMD,
3661da177e4SLinus Torvalds 	SET_VLAN_INGRESS_PRIORITY_CMD,
3671da177e4SLinus Torvalds 	SET_VLAN_EGRESS_PRIORITY_CMD,
3681da177e4SLinus Torvalds 	GET_VLAN_INGRESS_PRIORITY_CMD,
3691da177e4SLinus Torvalds 	GET_VLAN_EGRESS_PRIORITY_CMD,
3701da177e4SLinus Torvalds 	SET_VLAN_NAME_TYPE_CMD,
3711da177e4SLinus Torvalds 	SET_VLAN_FLAG_CMD,
3721da177e4SLinus Torvalds 	GET_VLAN_REALDEV_NAME_CMD, /* If this works, you know it's a VLAN device, btw */
3731da177e4SLinus Torvalds 	GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */
3741da177e4SLinus Torvalds };
3751da177e4SLinus Torvalds 
376a4bf3af4SPatrick McHardy enum vlan_flags {
377a4bf3af4SPatrick McHardy 	VLAN_FLAG_REORDER_HDR	= 0x1,
37870c03b49SPatrick McHardy 	VLAN_FLAG_GVRP		= 0x2,
3795e756593SPatrick McHardy 	VLAN_FLAG_LOOSE_BINDING	= 0x4,
380a4bf3af4SPatrick McHardy };
381a4bf3af4SPatrick McHardy 
3821da177e4SLinus Torvalds enum vlan_name_types {
3831da177e4SLinus Torvalds 	VLAN_NAME_TYPE_PLUS_VID, /* Name will look like:  vlan0005 */
3841da177e4SLinus Torvalds 	VLAN_NAME_TYPE_RAW_PLUS_VID, /* name will look like:  eth1.0005 */
3851da177e4SLinus Torvalds 	VLAN_NAME_TYPE_PLUS_VID_NO_PAD, /* Name will look like:  vlan5 */
3861da177e4SLinus Torvalds 	VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, /* Name will look like:  eth0.5 */
3871da177e4SLinus Torvalds 	VLAN_NAME_TYPE_HIGHEST
3881da177e4SLinus Torvalds };
3891da177e4SLinus Torvalds 
3901da177e4SLinus Torvalds struct vlan_ioctl_args {
3911da177e4SLinus Torvalds 	int cmd; /* Should be one of the vlan_ioctl_cmds enum above. */
3921da177e4SLinus Torvalds 	char device1[24];
3931da177e4SLinus Torvalds 
3941da177e4SLinus Torvalds         union {
3951da177e4SLinus Torvalds 		char device2[24];
3961da177e4SLinus Torvalds 		int VID;
3971da177e4SLinus Torvalds 		unsigned int skb_priority;
3981da177e4SLinus Torvalds 		unsigned int name_type;
3991da177e4SLinus Torvalds 		unsigned int bind_type;
4007da82c06SJiri Pirko 		unsigned int flag; /* Matches vlan_dev_priv flags */
4011da177e4SLinus Torvalds         } u;
4021da177e4SLinus Torvalds 
4031da177e4SLinus Torvalds 	short vlan_qos;
4041da177e4SLinus Torvalds };
4051da177e4SLinus Torvalds 
4061da177e4SLinus Torvalds #endif /* !(_LINUX_IF_VLAN_H_) */
407