aboutsummaryrefslogtreecommitdiff
path: root/lib/packets.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-10-08 16:26:21 -0700
committerBen Pfaff <blp@nicira.com>2010-10-11 13:31:43 -0700
commit26233bb4615608fd45d89a5abe2e62f4b3d776f7 (patch)
tree932157370b68fec5b6b775d70ccaa005c5b82362 /lib/packets.h
parentae412e7dd89489911a32c6723d4109c6d1de3a38 (diff)
datapath: Combine dl_vlan and dl_vlan_pcp.
This allows eliminating padding from odp_flow_key, although actually doing that is postponed until the next commit. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'lib/packets.h')
-rw-r--r--lib/packets.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/packets.h b/lib/packets.h
index fb044071..af028ebf 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -18,6 +18,8 @@
#define PACKETS_H 1
#include <inttypes.h>
+#include <sys/types.h>
+#include <netinet/in.h>
#include <stdint.h>
#include <string.h>
#include "compiler.h"
@@ -198,6 +200,24 @@ BUILD_ASSERT_DECL(LLC_SNAP_HEADER_LEN == sizeof(struct llc_snap_header));
#define VLAN_PCP_MASK 0xe000
#define VLAN_PCP_SHIFT 13
+#define VLAN_CFI 0x1000
+
+/* Given the vlan_tci field from an 802.1Q header, in network byte order,
+ * returns the VLAN ID in host byte order. */
+static inline uint16_t
+vlan_tci_to_vid(uint16_t vlan_tci)
+{
+ return (ntohs(vlan_tci) & VLAN_VID_MASK) >> VLAN_VID_SHIFT;
+}
+
+/* Given the vlan_tci field from an 802.1Q header, in network byte order,
+ * returns the priority code point (PCP) in host byte order. */
+static inline int
+vlan_tci_to_pcp(uint16_t vlan_tci)
+{
+ return (ntohs(vlan_tci) & VLAN_PCP_MASK) >> VLAN_PCP_SHIFT;
+}
+
#define VLAN_HEADER_LEN 4
struct vlan_header {
uint16_t vlan_tci; /* Lowest 12 bits are VLAN ID. */