1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * VLAN An implementation of 802.1Q VLAN tagging.
5 * Authors: Ben Greear <greearb@candelatech.com>
7 #ifndef _LINUX_IF_VLAN_H_
8 #define _LINUX_IF_VLAN_H_
10 #include <linux/netdevice.h>
11 #include <linux/etherdevice.h>
12 #include <linux/rtnetlink.h>
13 #include <linux/bug.h>
14 #include <uapi/linux/if_vlan.h>
16 #define VLAN_HLEN 4 /* The additional bytes required by VLAN
17 * (in addition to the Ethernet header)
19 #define VLAN_ETH_HLEN 18 /* Total octets in header. */
20 #define VLAN_ETH_ZLEN 64 /* Min. octets in frame sans FCS */
23 * According to 802.3ac, the packet can be 4 bytes longer. --Klika Jan
25 #define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */
26 #define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */
28 #define VLAN_MAX_DEPTH 8 /* Max. number of nested VLAN tags parsed */
31 * struct vlan_hdr - vlan header
32 * @h_vlan_TCI: priority and VLAN ID
33 * @h_vlan_encapsulated_proto: packet type ID or len
37 __be16 h_vlan_encapsulated_proto
;
41 * struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr)
42 * @h_dest: destination ethernet address
43 * @h_source: source ethernet address
44 * @h_vlan_proto: ethernet protocol
45 * @h_vlan_TCI: priority and VLAN ID
46 * @h_vlan_encapsulated_proto: packet type ID or len
50 unsigned char h_dest
[ETH_ALEN
];
51 unsigned char h_source
[ETH_ALEN
];
55 __be16 h_vlan_encapsulated_proto
;
58 #include <linux/skbuff.h>
60 static inline struct vlan_ethhdr
*vlan_eth_hdr(const struct sk_buff
*skb
)
62 return (struct vlan_ethhdr
*)skb_mac_header(skb
);
65 /* Prefer this version in TX path, instead of
66 * skb_reset_mac_header() + vlan_eth_hdr()
68 static inline struct vlan_ethhdr
*skb_vlan_eth_hdr(const struct sk_buff
*skb
)
70 return (struct vlan_ethhdr
*)skb
->data
;
73 #define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */
74 #define VLAN_PRIO_SHIFT 13
75 #define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator / Drop Eligible Indicator */
76 #define VLAN_VID_MASK 0x0fff /* VLAN Identifier */
77 #define VLAN_N_VID 4096
79 /* found in socket.c */
80 extern void vlan_ioctl_set(int (*hook
)(struct net
*, void __user
*));
82 static inline bool is_vlan_dev(const struct net_device
*dev
)
84 return dev
->priv_flags
& IFF_802_1Q_VLAN
;
87 #define skb_vlan_tag_present(__skb) (!!(__skb)->vlan_all)
88 #define skb_vlan_tag_get(__skb) ((__skb)->vlan_tci)
89 #define skb_vlan_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK)
90 #define skb_vlan_tag_get_cfi(__skb) (!!((__skb)->vlan_tci & VLAN_CFI_MASK))
91 #define skb_vlan_tag_get_prio(__skb) (((__skb)->vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT)
93 static inline int vlan_get_rx_ctag_filter_info(struct net_device
*dev
)
96 return notifier_to_errno(call_netdevice_notifiers(NETDEV_CVLAN_FILTER_PUSH_INFO
, dev
));
99 static inline void vlan_drop_rx_ctag_filter_info(struct net_device
*dev
)
102 call_netdevice_notifiers(NETDEV_CVLAN_FILTER_DROP_INFO
, dev
);
105 static inline int vlan_get_rx_stag_filter_info(struct net_device
*dev
)
108 return notifier_to_errno(call_netdevice_notifiers(NETDEV_SVLAN_FILTER_PUSH_INFO
, dev
));
111 static inline void vlan_drop_rx_stag_filter_info(struct net_device
*dev
)
114 call_netdevice_notifiers(NETDEV_SVLAN_FILTER_DROP_INFO
, dev
);
118 * struct vlan_pcpu_stats - VLAN percpu rx/tx stats
119 * @rx_packets: number of received packets
120 * @rx_bytes: number of received bytes
121 * @rx_multicast: number of received multicast packets
122 * @tx_packets: number of transmitted packets
123 * @tx_bytes: number of transmitted bytes
124 * @syncp: synchronization point for 64bit counters
125 * @rx_errors: number of rx errors
126 * @tx_dropped: number of tx drops
128 struct vlan_pcpu_stats
{
129 u64_stats_t rx_packets
;
130 u64_stats_t rx_bytes
;
131 u64_stats_t rx_multicast
;
132 u64_stats_t tx_packets
;
133 u64_stats_t tx_bytes
;
134 struct u64_stats_sync syncp
;
139 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
141 extern struct net_device
*__vlan_find_dev_deep_rcu(struct net_device
*real_dev
,
142 __be16 vlan_proto
, u16 vlan_id
);
143 extern int vlan_for_each(struct net_device
*dev
,
144 int (*action
)(struct net_device
*dev
, int vid
,
145 void *arg
), void *arg
);
146 extern struct net_device
*vlan_dev_real_dev(const struct net_device
*dev
);
147 extern u16
vlan_dev_vlan_id(const struct net_device
*dev
);
148 extern __be16
vlan_dev_vlan_proto(const struct net_device
*dev
);
151 * struct vlan_priority_tci_mapping - vlan egress priority mappings
152 * @priority: skb priority
153 * @vlan_qos: vlan priority: (skb->priority << 13) & 0xE000
154 * @next: pointer to next struct
156 struct vlan_priority_tci_mapping
{
159 struct vlan_priority_tci_mapping
*next
;
162 struct proc_dir_entry
;
166 * struct vlan_dev_priv - VLAN private device data
167 * @nr_ingress_mappings: number of ingress priority mappings
168 * @ingress_priority_map: ingress priority mappings
169 * @nr_egress_mappings: number of egress priority mappings
170 * @egress_priority_map: hash of egress priority mappings
171 * @vlan_proto: VLAN encapsulation protocol
172 * @vlan_id: VLAN identifier
173 * @flags: device flags
174 * @real_dev: underlying netdevice
175 * @dev_tracker: refcount tracker for @real_dev reference
176 * @real_dev_addr: address of underlying netdevice
177 * @dent: proc dir entry
178 * @vlan_pcpu_stats: ptr to percpu rx stats
180 struct vlan_dev_priv
{
181 unsigned int nr_ingress_mappings
;
182 u32 ingress_priority_map
[8];
183 unsigned int nr_egress_mappings
;
184 struct vlan_priority_tci_mapping
*egress_priority_map
[16];
190 struct net_device
*real_dev
;
191 netdevice_tracker dev_tracker
;
193 unsigned char real_dev_addr
[ETH_ALEN
];
195 struct proc_dir_entry
*dent
;
196 struct vlan_pcpu_stats __percpu
*vlan_pcpu_stats
;
197 #ifdef CONFIG_NET_POLL_CONTROLLER
198 struct netpoll
*netpoll
;
202 static inline struct vlan_dev_priv
*vlan_dev_priv(const struct net_device
*dev
)
204 return netdev_priv(dev
);
208 vlan_dev_get_egress_qos_mask(struct net_device
*dev
, u32 skprio
)
210 struct vlan_priority_tci_mapping
*mp
;
212 smp_rmb(); /* coupled with smp_wmb() in vlan_dev_set_egress_priority() */
214 mp
= vlan_dev_priv(dev
)->egress_priority_map
[(skprio
& 0xF)];
216 if (mp
->priority
== skprio
) {
217 return mp
->vlan_qos
; /* This should already be shifted
218 * to mask correctly with the
226 extern bool vlan_do_receive(struct sk_buff
**skb
);
228 extern int vlan_vid_add(struct net_device
*dev
, __be16 proto
, u16 vid
);
229 extern void vlan_vid_del(struct net_device
*dev
, __be16 proto
, u16 vid
);
231 extern int vlan_vids_add_by_dev(struct net_device
*dev
,
232 const struct net_device
*by_dev
);
233 extern void vlan_vids_del_by_dev(struct net_device
*dev
,
234 const struct net_device
*by_dev
);
236 extern bool vlan_uses_dev(const struct net_device
*dev
);
239 static inline struct net_device
*
240 __vlan_find_dev_deep_rcu(struct net_device
*real_dev
,
241 __be16 vlan_proto
, u16 vlan_id
)
247 vlan_for_each(struct net_device
*dev
,
248 int (*action
)(struct net_device
*dev
, int vid
, void *arg
),
254 static inline struct net_device
*vlan_dev_real_dev(const struct net_device
*dev
)
260 static inline u16
vlan_dev_vlan_id(const struct net_device
*dev
)
266 static inline __be16
vlan_dev_vlan_proto(const struct net_device
*dev
)
272 static inline u16
vlan_dev_get_egress_qos_mask(struct net_device
*dev
,
278 static inline bool vlan_do_receive(struct sk_buff
**skb
)
283 static inline int vlan_vid_add(struct net_device
*dev
, __be16 proto
, u16 vid
)
288 static inline void vlan_vid_del(struct net_device
*dev
, __be16 proto
, u16 vid
)
292 static inline int vlan_vids_add_by_dev(struct net_device
*dev
,
293 const struct net_device
*by_dev
)
298 static inline void vlan_vids_del_by_dev(struct net_device
*dev
,
299 const struct net_device
*by_dev
)
303 static inline bool vlan_uses_dev(const struct net_device
*dev
)
310 * eth_type_vlan - check for valid vlan ether type.
311 * @ethertype: ether type to check
313 * Returns true if the ether type is a vlan ether type.
315 static inline bool eth_type_vlan(__be16 ethertype
)
318 case htons(ETH_P_8021Q
):
319 case htons(ETH_P_8021AD
):
326 static inline bool vlan_hw_offload_capable(netdev_features_t features
,
329 if (proto
== htons(ETH_P_8021Q
) && features
& NETIF_F_HW_VLAN_CTAG_TX
)
331 if (proto
== htons(ETH_P_8021AD
) && features
& NETIF_F_HW_VLAN_STAG_TX
)
337 * __vlan_insert_inner_tag - inner VLAN tag inserting
338 * @skb: skbuff to tag
339 * @vlan_proto: VLAN encapsulation protocol
340 * @vlan_tci: VLAN TCI to insert
341 * @mac_len: MAC header length including outer vlan headers
343 * Inserts the VLAN tag into @skb as part of the payload at offset mac_len
344 * Returns error if skb_cow_head fails.
346 * Does not change skb->protocol so this function can be used during receive.
348 static inline int __vlan_insert_inner_tag(struct sk_buff
*skb
,
349 __be16 vlan_proto
, u16 vlan_tci
,
350 unsigned int mac_len
)
352 struct vlan_ethhdr
*veth
;
354 if (skb_cow_head(skb
, VLAN_HLEN
) < 0)
357 skb_push(skb
, VLAN_HLEN
);
359 /* Move the mac header sans proto to the beginning of the new header. */
360 if (likely(mac_len
> ETH_TLEN
))
361 memmove(skb
->data
, skb
->data
+ VLAN_HLEN
, mac_len
- ETH_TLEN
);
362 if (skb_mac_header_was_set(skb
))
363 skb
->mac_header
-= VLAN_HLEN
;
365 veth
= (struct vlan_ethhdr
*)(skb
->data
+ mac_len
- ETH_HLEN
);
367 /* first, the ethernet type */
368 if (likely(mac_len
>= ETH_TLEN
)) {
369 /* h_vlan_encapsulated_proto should already be populated, and
370 * skb->data has space for h_vlan_proto
372 veth
->h_vlan_proto
= vlan_proto
;
374 /* h_vlan_encapsulated_proto should not be populated, and
375 * skb->data has no space for h_vlan_proto
377 veth
->h_vlan_encapsulated_proto
= skb
->protocol
;
381 veth
->h_vlan_TCI
= htons(vlan_tci
);
387 * __vlan_insert_tag - regular VLAN tag inserting
388 * @skb: skbuff to tag
389 * @vlan_proto: VLAN encapsulation protocol
390 * @vlan_tci: VLAN TCI to insert
392 * Inserts the VLAN tag into @skb as part of the payload
393 * Returns error if skb_cow_head fails.
395 * Does not change skb->protocol so this function can be used during receive.
397 static inline int __vlan_insert_tag(struct sk_buff
*skb
,
398 __be16 vlan_proto
, u16 vlan_tci
)
400 return __vlan_insert_inner_tag(skb
, vlan_proto
, vlan_tci
, ETH_HLEN
);
404 * vlan_insert_inner_tag - inner VLAN tag inserting
405 * @skb: skbuff to tag
406 * @vlan_proto: VLAN encapsulation protocol
407 * @vlan_tci: VLAN TCI to insert
408 * @mac_len: MAC header length including outer vlan headers
410 * Inserts the VLAN tag into @skb as part of the payload at offset mac_len
411 * Returns a VLAN tagged skb. This might change skb->head.
413 * Following the skb_unshare() example, in case of error, the calling function
414 * doesn't have to worry about freeing the original skb.
416 * Does not change skb->protocol so this function can be used during receive.
418 static inline struct sk_buff
*vlan_insert_inner_tag(struct sk_buff
*skb
,
421 unsigned int mac_len
)
425 err
= __vlan_insert_inner_tag(skb
, vlan_proto
, vlan_tci
, mac_len
);
427 dev_kfree_skb_any(skb
);
434 * vlan_insert_tag - regular VLAN tag inserting
435 * @skb: skbuff to tag
436 * @vlan_proto: VLAN encapsulation protocol
437 * @vlan_tci: VLAN TCI to insert
439 * Inserts the VLAN tag into @skb as part of the payload
440 * Returns a VLAN tagged skb. This might change skb->head.
442 * Following the skb_unshare() example, in case of error, the calling function
443 * doesn't have to worry about freeing the original skb.
445 * Does not change skb->protocol so this function can be used during receive.
447 static inline struct sk_buff
*vlan_insert_tag(struct sk_buff
*skb
,
448 __be16 vlan_proto
, u16 vlan_tci
)
450 return vlan_insert_inner_tag(skb
, vlan_proto
, vlan_tci
, ETH_HLEN
);
454 * vlan_insert_tag_set_proto - regular VLAN tag inserting
455 * @skb: skbuff to tag
456 * @vlan_proto: VLAN encapsulation protocol
457 * @vlan_tci: VLAN TCI to insert
459 * Inserts the VLAN tag into @skb as part of the payload
460 * Returns a VLAN tagged skb. This might change skb->head.
462 * Following the skb_unshare() example, in case of error, the calling function
463 * doesn't have to worry about freeing the original skb.
465 static inline struct sk_buff
*vlan_insert_tag_set_proto(struct sk_buff
*skb
,
469 skb
= vlan_insert_tag(skb
, vlan_proto
, vlan_tci
);
471 skb
->protocol
= vlan_proto
;
476 * __vlan_hwaccel_clear_tag - clear hardware accelerated VLAN info
477 * @skb: skbuff to clear
479 * Clears the VLAN information from @skb
481 static inline void __vlan_hwaccel_clear_tag(struct sk_buff
*skb
)
487 * __vlan_hwaccel_copy_tag - copy hardware accelerated VLAN info from another skb
488 * @dst: skbuff to copy to
489 * @src: skbuff to copy from
491 * Copies VLAN information from @src to @dst (for branchless code)
493 static inline void __vlan_hwaccel_copy_tag(struct sk_buff
*dst
, const struct sk_buff
*src
)
495 dst
->vlan_all
= src
->vlan_all
;
499 * __vlan_hwaccel_push_inside - pushes vlan tag to the payload
500 * @skb: skbuff to tag
502 * Pushes the VLAN tag from @skb->vlan_tci inside to the payload.
504 * Following the skb_unshare() example, in case of error, the calling function
505 * doesn't have to worry about freeing the original skb.
507 static inline struct sk_buff
*__vlan_hwaccel_push_inside(struct sk_buff
*skb
)
509 skb
= vlan_insert_tag_set_proto(skb
, skb
->vlan_proto
,
510 skb_vlan_tag_get(skb
));
512 __vlan_hwaccel_clear_tag(skb
);
517 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
518 * @skb: skbuff to tag
519 * @vlan_proto: VLAN encapsulation protocol
520 * @vlan_tci: VLAN TCI to insert
522 * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest
524 static inline void __vlan_hwaccel_put_tag(struct sk_buff
*skb
,
525 __be16 vlan_proto
, u16 vlan_tci
)
527 skb
->vlan_proto
= vlan_proto
;
528 skb
->vlan_tci
= vlan_tci
;
532 * __vlan_get_tag - get the VLAN ID that is part of the payload
533 * @skb: skbuff to query
534 * @vlan_tci: buffer to store value
536 * Returns error if the skb is not of VLAN type
538 static inline int __vlan_get_tag(const struct sk_buff
*skb
, u16
*vlan_tci
)
540 struct vlan_ethhdr
*veth
= skb_vlan_eth_hdr(skb
);
542 if (!eth_type_vlan(veth
->h_vlan_proto
))
545 *vlan_tci
= ntohs(veth
->h_vlan_TCI
);
550 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
551 * @skb: skbuff to query
552 * @vlan_tci: buffer to store value
554 * Returns error if @skb->vlan_tci is not set correctly
556 static inline int __vlan_hwaccel_get_tag(const struct sk_buff
*skb
,
559 if (skb_vlan_tag_present(skb
)) {
560 *vlan_tci
= skb_vlan_tag_get(skb
);
569 * vlan_get_tag - get the VLAN ID from the skb
570 * @skb: skbuff to query
571 * @vlan_tci: buffer to store value
573 * Returns error if the skb is not VLAN tagged
575 static inline int vlan_get_tag(const struct sk_buff
*skb
, u16
*vlan_tci
)
577 if (skb
->dev
->features
& NETIF_F_HW_VLAN_CTAG_TX
) {
578 return __vlan_hwaccel_get_tag(skb
, vlan_tci
);
580 return __vlan_get_tag(skb
, vlan_tci
);
585 * vlan_get_protocol - get protocol EtherType.
586 * @skb: skbuff to query
587 * @type: first vlan protocol
588 * @depth: buffer to store length of eth and vlan tags in bytes
590 * Returns the EtherType of the packet, regardless of whether it is
591 * vlan encapsulated (normal or hardware accelerated) or not.
593 static inline __be16
__vlan_get_protocol(const struct sk_buff
*skb
, __be16 type
,
596 unsigned int vlan_depth
= skb
->mac_len
, parse_depth
= VLAN_MAX_DEPTH
;
598 /* if type is 802.1Q/AD then the header should already be
599 * present at mac_len - VLAN_HLEN (if mac_len > 0), or at
602 if (eth_type_vlan(type
)) {
604 if (WARN_ON(vlan_depth
< VLAN_HLEN
))
606 vlan_depth
-= VLAN_HLEN
;
608 vlan_depth
= ETH_HLEN
;
611 struct vlan_hdr vhdr
, *vh
;
613 vh
= skb_header_pointer(skb
, vlan_depth
, sizeof(vhdr
), &vhdr
);
614 if (unlikely(!vh
|| !--parse_depth
))
617 type
= vh
->h_vlan_encapsulated_proto
;
618 vlan_depth
+= VLAN_HLEN
;
619 } while (eth_type_vlan(type
));
629 * vlan_get_protocol - get protocol EtherType.
630 * @skb: skbuff to query
632 * Returns the EtherType of the packet, regardless of whether it is
633 * vlan encapsulated (normal or hardware accelerated) or not.
635 static inline __be16
vlan_get_protocol(const struct sk_buff
*skb
)
637 return __vlan_get_protocol(skb
, skb
->protocol
, NULL
);
640 /* This version of __vlan_get_protocol() also pulls mac header in skb->head */
641 static inline __be16
vlan_get_protocol_and_depth(struct sk_buff
*skb
,
642 __be16 type
, int *depth
)
646 type
= __vlan_get_protocol(skb
, type
, &maclen
);
649 if (!pskb_may_pull(skb
, maclen
))
657 /* A getter for the SKB protocol field which will handle VLAN tags consistently
658 * whether VLAN acceleration is enabled or not.
660 static inline __be16
skb_protocol(const struct sk_buff
*skb
, bool skip_vlan
)
663 /* VLAN acceleration strips the VLAN header from the skb and
664 * moves it to skb->vlan_proto
666 return skb_vlan_tag_present(skb
) ? skb
->vlan_proto
: skb
->protocol
;
668 return vlan_get_protocol(skb
);
671 static inline void vlan_set_encap_proto(struct sk_buff
*skb
,
672 struct vlan_hdr
*vhdr
)
675 unsigned short *rawp
;
678 * Was a VLAN packet, grab the encapsulated protocol, which the layer
679 * three protocols care about.
682 proto
= vhdr
->h_vlan_encapsulated_proto
;
683 if (eth_proto_is_802_3(proto
)) {
684 skb
->protocol
= proto
;
688 rawp
= (unsigned short *)(vhdr
+ 1);
691 * This is a magic hack to spot IPX packets. Older Novell
692 * breaks the protocol design and runs IPX over 802.3 without
693 * an 802.2 LLC layer. We look for FFFF which isn't a used
694 * 802.2 SSAP/DSAP. This won't work for fault tolerant netware
695 * but does for the rest.
697 skb
->protocol
= htons(ETH_P_802_3
);
702 skb
->protocol
= htons(ETH_P_802_2
);
706 * vlan_remove_tag - remove outer VLAN tag from payload
707 * @skb: skbuff to remove tag from
708 * @vlan_tci: buffer to store value
710 * Expects the skb to contain a VLAN tag in the payload, and to have skb->data
711 * pointing at the MAC header.
713 * Returns a new pointer to skb->data, or NULL on failure to pull.
715 static inline void *vlan_remove_tag(struct sk_buff
*skb
, u16
*vlan_tci
)
717 struct vlan_hdr
*vhdr
= (struct vlan_hdr
*)(skb
->data
+ ETH_HLEN
);
719 *vlan_tci
= ntohs(vhdr
->h_vlan_TCI
);
721 memmove(skb
->data
+ VLAN_HLEN
, skb
->data
, 2 * ETH_ALEN
);
722 vlan_set_encap_proto(skb
, vhdr
);
723 return __skb_pull(skb
, VLAN_HLEN
);
727 * skb_vlan_tagged - check if skb is vlan tagged.
728 * @skb: skbuff to query
730 * Returns true if the skb is tagged, regardless of whether it is hardware
731 * accelerated or not.
733 static inline bool skb_vlan_tagged(const struct sk_buff
*skb
)
735 if (!skb_vlan_tag_present(skb
) &&
736 likely(!eth_type_vlan(skb
->protocol
)))
743 * skb_vlan_tagged_multi - check if skb is vlan tagged with multiple headers.
744 * @skb: skbuff to query
746 * Returns true if the skb is tagged with multiple vlan headers, regardless
747 * of whether it is hardware accelerated or not.
749 static inline bool skb_vlan_tagged_multi(struct sk_buff
*skb
)
751 __be16 protocol
= skb
->protocol
;
753 if (!skb_vlan_tag_present(skb
)) {
754 struct vlan_ethhdr
*veh
;
756 if (likely(!eth_type_vlan(protocol
)))
759 if (unlikely(!pskb_may_pull(skb
, VLAN_ETH_HLEN
)))
762 veh
= skb_vlan_eth_hdr(skb
);
763 protocol
= veh
->h_vlan_encapsulated_proto
;
766 if (!eth_type_vlan(protocol
))
773 * vlan_features_check - drop unsafe features for skb with multiple tags.
774 * @skb: skbuff to query
775 * @features: features to be checked
777 * Returns features without unsafe ones if the skb has multiple tags.
779 static inline netdev_features_t
vlan_features_check(struct sk_buff
*skb
,
780 netdev_features_t features
)
782 if (skb_vlan_tagged_multi(skb
)) {
783 /* In the case of multi-tagged packets, use a direct mask
784 * instead of using netdev_interesect_features(), to make
785 * sure that only devices supporting NETIF_F_HW_CSUM will
786 * have checksum offloading support.
788 features
&= NETIF_F_SG
| NETIF_F_HIGHDMA
| NETIF_F_HW_CSUM
|
789 NETIF_F_FRAGLIST
| NETIF_F_HW_VLAN_CTAG_TX
|
790 NETIF_F_HW_VLAN_STAG_TX
;
797 * compare_vlan_header - Compare two vlan headers
798 * @h1: Pointer to vlan header
799 * @h2: Pointer to vlan header
801 * Compare two vlan headers, returns 0 if equal.
803 * Please note that alignment of h1 & h2 are only guaranteed to be 16 bits.
805 static inline unsigned long compare_vlan_header(const struct vlan_hdr
*h1
,
806 const struct vlan_hdr
*h2
)
808 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
809 return *(u32
*)h1
^ *(u32
*)h2
;
811 return ((__force u32
)h1
->h_vlan_TCI
^ (__force u32
)h2
->h_vlan_TCI
) |
812 ((__force u32
)h1
->h_vlan_encapsulated_proto
^
813 (__force u32
)h2
->h_vlan_encapsulated_proto
);
816 #endif /* !(_LINUX_IF_VLAN_H_) */