Lines Matching +full:layer +full:- +full:depth

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
23 * According to 802.3ac, the packet can be 4 bytes longer. --Klika Jan
31 * struct vlan_hdr - vlan header
41 * struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr)
70 return (struct vlan_ethhdr *)skb->data; in skb_vlan_eth_hdr()
84 return dev->priv_flags & IFF_802_1Q_VLAN; in is_vlan_dev()
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)
118 * struct vlan_pcpu_stats - VLAN percpu rx/tx stats
151 * struct vlan_priority_tci_mapping - vlan egress priority mappings
153 * @vlan_qos: vlan priority: (skb->priority << 13) & 0xE000
166 * struct vlan_dev_priv - VLAN private device data
215 mp = vlan_dev_priv(dev)->egress_priority_map[(skprio & 0xF)]; in vlan_dev_get_egress_qos_mask()
217 if (mp->priority == skprio) { in vlan_dev_get_egress_qos_mask()
218 return mp->vlan_qos; /* This should already be shifted in vlan_dev_get_egress_qos_mask()
222 mp = mp->next; in vlan_dev_get_egress_qos_mask()
311 * eth_type_vlan - check for valid vlan ether type.
338 * __vlan_insert_inner_tag - inner VLAN tag inserting
345 * Does not change skb->protocol so this function can be used during receive.
356 return -ENOMEM; in __vlan_insert_inner_tag()
362 memmove(skb->data, skb->data + VLAN_HLEN, mac_len - ETH_TLEN); in __vlan_insert_inner_tag()
364 skb->mac_header -= VLAN_HLEN; in __vlan_insert_inner_tag()
366 veth = (struct vlan_ethhdr *)(skb->data + mac_len - ETH_HLEN); in __vlan_insert_inner_tag()
371 * skb->data has space for h_vlan_proto in __vlan_insert_inner_tag()
373 veth->h_vlan_proto = vlan_proto; in __vlan_insert_inner_tag()
376 * skb->data has no space for h_vlan_proto in __vlan_insert_inner_tag()
378 veth->h_vlan_encapsulated_proto = skb->protocol; in __vlan_insert_inner_tag()
382 veth->h_vlan_TCI = htons(vlan_tci); in __vlan_insert_inner_tag()
388 * __vlan_insert_tag - regular VLAN tag inserting
394 * Does not change skb->protocol so this function can be used during receive.
405 * vlan_insert_inner_tag - inner VLAN tag inserting
412 * Returns a VLAN tagged skb. This might change skb->head.
417 * Does not change skb->protocol so this function can be used during receive.
437 * vlan_insert_tag - regular VLAN tag inserting
443 * Returns a VLAN tagged skb. This might change skb->head.
448 * Does not change skb->protocol so this function can be used during receive.
459 * vlan_insert_tag_set_proto - regular VLAN tag inserting
465 * Returns a VLAN tagged skb. This might change skb->head.
478 skb->protocol = vlan_proto; in vlan_insert_tag_set_proto()
483 * __vlan_hwaccel_clear_tag - clear hardware accelerated VLAN info
490 skb->vlan_all = 0; in __vlan_hwaccel_clear_tag()
494 * __vlan_hwaccel_copy_tag - copy hardware accelerated VLAN info from another skb
502 dst->vlan_all = src->vlan_all; in __vlan_hwaccel_copy_tag()
506 * __vlan_hwaccel_push_inside - pushes vlan tag to the payload
509 * Pushes the VLAN tag from @skb->vlan_tci inside to the payload.
516 skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto, in __vlan_hwaccel_push_inside()
524 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
529 * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest
534 skb->vlan_proto = vlan_proto; in __vlan_hwaccel_put_tag()
535 skb->vlan_tci = vlan_tci; in __vlan_hwaccel_put_tag()
539 * __vlan_get_tag - get the VLAN ID that is part of the payload
549 if (!eth_type_vlan(veth->h_vlan_proto)) in __vlan_get_tag()
550 return -ENODATA; in __vlan_get_tag()
552 *vlan_tci = ntohs(veth->h_vlan_TCI); in __vlan_get_tag()
557 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
561 * Returns: error if @skb->vlan_tci is not set correctly
571 return -ENODATA; in __vlan_hwaccel_get_tag()
576 * vlan_get_tag - get the VLAN ID from the skb
584 if (skb->dev->features & NETIF_F_HW_VLAN_CTAG_TX) { in vlan_get_tag()
592 * __vlan_get_protocol_offset() - get protocol EtherType.
596 * @depth: buffer to store length of eth and vlan tags in bytes
604 int *depth) in __vlan_get_protocol_offset() argument
606 unsigned int vlan_depth = skb->mac_len, parse_depth = VLAN_MAX_DEPTH; in __vlan_get_protocol_offset()
609 * present at mac_len - VLAN_HLEN (if mac_len > 0), or at in __vlan_get_protocol_offset()
616 vlan_depth -= VLAN_HLEN; in __vlan_get_protocol_offset()
625 if (unlikely(!vh || !--parse_depth)) in __vlan_get_protocol_offset()
628 type = vh->h_vlan_encapsulated_proto; in __vlan_get_protocol_offset()
633 if (depth) in __vlan_get_protocol_offset()
634 *depth = vlan_depth; in __vlan_get_protocol_offset()
640 int *depth) in __vlan_get_protocol() argument
642 return __vlan_get_protocol_offset(skb, type, 0, depth); in __vlan_get_protocol()
646 * vlan_get_protocol - get protocol EtherType.
654 return __vlan_get_protocol(skb, skb->protocol, NULL); in vlan_get_protocol()
657 /* This version of __vlan_get_protocol() also pulls mac header in skb->head */
659 __be16 type, int *depth) in vlan_get_protocol_and_depth() argument
668 else if (depth) in vlan_get_protocol_and_depth()
669 *depth = maclen; in vlan_get_protocol_and_depth()
681 * moves it to skb->vlan_proto in skb_protocol()
683 return skb_vlan_tag_present(skb) ? skb->vlan_proto : skb->protocol; in skb_protocol()
695 * Was a VLAN packet, grab the encapsulated protocol, which the layer in vlan_set_encap_proto()
699 proto = vhdr->h_vlan_encapsulated_proto; in vlan_set_encap_proto()
701 skb->protocol = proto; in vlan_set_encap_proto()
710 * an 802.2 LLC layer. We look for FFFF which isn't a used in vlan_set_encap_proto()
714 skb->protocol = htons(ETH_P_802_3); in vlan_set_encap_proto()
719 skb->protocol = htons(ETH_P_802_2); in vlan_set_encap_proto()
723 * vlan_remove_tag - remove outer VLAN tag from payload
727 * Expects the skb to contain a VLAN tag in the payload, and to have skb->data
730 * Returns: a new pointer to skb->data, or NULL on failure to pull.
734 struct vlan_hdr *vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN); in vlan_remove_tag()
736 *vlan_tci = ntohs(vhdr->h_vlan_TCI); in vlan_remove_tag()
738 memmove(skb->data + VLAN_HLEN, skb->data, 2 * ETH_ALEN); in vlan_remove_tag()
744 * skb_vlan_tagged - check if skb is vlan tagged.
753 likely(!eth_type_vlan(skb->protocol))) in skb_vlan_tagged()
760 * skb_vlan_tagged_multi - check if skb is vlan tagged with multiple headers.
768 __be16 protocol = skb->protocol; in skb_vlan_tagged_multi()
780 protocol = veh->h_vlan_encapsulated_proto; in skb_vlan_tagged_multi()
790 * vlan_features_check - drop unsafe features for skb with multiple tags.
800 /* In the case of multi-tagged packets, use a direct mask in vlan_features_check()
814 * compare_vlan_header - Compare two vlan headers
822 * Return: 0 if equal, arbitrary non-zero value if not equal.
830 return ((__force u32)h1->h_vlan_TCI ^ (__force u32)h2->h_vlan_TCI) | in compare_vlan_header()
831 ((__force u32)h1->h_vlan_encapsulated_proto ^ in compare_vlan_header()
832 (__force u32)h2->h_vlan_encapsulated_proto); in compare_vlan_header()