Skip to content

Commit

Permalink
net: add macros for VLAN metadata parsing
Browse files Browse the repository at this point in the history
[ upstream commit b74087f15e16c42fe4ff9c4d603cc7a51a1aa1dc ]

Add common macros for extracting parts of VLAN tag.

Fixes: 4e9c73e ("net/netvsc: add Hyper-V network device")

Signed-off-by: Alan Elder <alan.elder@microsoft.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
Alan Elder authored and bluca committed Mar 7, 2024
1 parent 8603dea commit 6ccc096
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Akshay Dorwat <akshay.dorwat@amd.com>
Alain Leon <xerebz@gmail.com>
Alan Carew <alan.carew@intel.com>
Alan Dewar <alan.dewar@att.com> <adewar@brocade.com>
Alan Elder <alan.elder@microsoft.com>
Alan Liu <zaoxingliu@gmail.com>
Alan Winkowski <walan@marvell.com>
Alejandro Lucero <alejandro.lucero@netronome.com>
Expand Down
14 changes: 14 additions & 0 deletions lib/net/rte_ether.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ extern "C" {

#define RTE_ETHER_MIN_MTU 68 /**< Minimum MTU for IPv4 packets, see RFC 791. */

/* VLAN header fields */
#define RTE_VLAN_DEI_SHIFT 12
#define RTE_VLAN_PRI_SHIFT 13
#define RTE_VLAN_PRI_MASK 0xe000 /* Priority Code Point */
#define RTE_VLAN_DEI_MASK 0x1000 /* Drop Eligible Indicator */
#define RTE_VLAN_ID_MASK 0x0fff /* VLAN Identifier */

#define RTE_VLAN_TCI_ID(vlan_tci) ((vlan_tci) & RTE_VLAN_ID_MASK)
#define RTE_VLAN_TCI_PRI(vlan_tci) (((vlan_tci) & RTE_VLAN_PRI_MASK) >> RTE_VLAN_PRI_SHIFT)
#define RTE_VLAN_TCI_DEI(vlan_tci) (((vlan_tci) & RTE_VLAN_DEI_MASK) >> RTE_VLAN_DEI_SHIFT)
#define RTE_VLAN_TCI_MAKE(id, pri, dei) ((id) | \
((pri) << RTE_VLAN_PRI_SHIFT) | \
((dei) << RTE_VLAN_DEI_SHIFT))

/**
* Ethernet address:
* A universally administered address is uniquely assigned to a device by its
Expand Down

0 comments on commit 6ccc096

Please sign in to comment.