From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 341172BD1 for ; Mon, 29 Aug 2016 16:35:53 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id F389D24E34; Mon, 29 Aug 2016 16:35:52 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Cc: cunming.liang@intel.com, john.mcnamara@intel.com, andrey.chilikin@intel.com, konstantin.ananyev@intel.com Date: Mon, 29 Aug 2016 16:35:26 +0200 Message-Id: <1472481335-21226-8-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1472481335-21226-1-git-send-email-olivier.matz@6wind.com> References: <1467733310-20875-1-git-send-email-olivier.matz@6wind.com> <1472481335-21226-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v2 07/16] net: support QinQ in software packet type parser X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2016 14:35:53 -0000 Add a new RTE_PTYPE_L2_ETHER_QINQ packet type, and its support in rte_net_get_ptype(). Signed-off-by: Didier Pallard Signed-off-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf_ptype.h | 7 +++++++ lib/librte_net/rte_ether.h | 1 + lib/librte_net/rte_net.c | 16 ++++++++++++++++ lib/librte_net/rte_net.h | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/librte_mbuf/rte_mbuf_ptype.h b/lib/librte_mbuf/rte_mbuf_ptype.h index 101e7fa..7084259 100644 --- a/lib/librte_mbuf/rte_mbuf_ptype.h +++ b/lib/librte_mbuf/rte_mbuf_ptype.h @@ -143,6 +143,13 @@ extern "C" { */ #define RTE_PTYPE_L2_ETHER_VLAN 0x00000006 /** + * QinQ packet type. + * + * Packet format: + * <'ether type'=[0x88A8]> + */ +#define RTE_PTYPE_L2_ETHER_QINQ 0x00000007 +/** * Mask of layer 2 packet types. * It is used for outer packet for tunneling cases. */ diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 647e6c9..ff3d065 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -329,6 +329,7 @@ struct vxlan_hdr { #define ETHER_TYPE_ARP 0x0806 /**< Arp Protocol. */ #define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */ #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ +#define ETHER_TYPE_QINQ 0x88A8 /**< IEEE 802.1ad QinQ tagging. */ #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */ #define ETHER_TYPE_SLOW 0x8809 /**< Slow protocols (LACP and Marker). */ #define ETHER_TYPE_TEB 0x6558 /**< Transparent Ethernet Bridging. */ diff --git a/lib/librte_net/rte_net.c b/lib/librte_net/rte_net.c index 7d34532..d20cc65 100644 --- a/lib/librte_net/rte_net.c +++ b/lib/librte_net/rte_net.c @@ -167,6 +167,9 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, off = sizeof(*eh); hdr_lens->l2_len = off; + if (proto == rte_cpu_to_be_16(ETHER_TYPE_IPv4)) + goto l3; /* fast path if packet is IPv4 */ + if (proto == rte_cpu_to_be_16(ETHER_TYPE_VLAN)) { const struct vlan_hdr *vh; struct vlan_hdr vh_copy; @@ -178,8 +181,21 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, off += sizeof(*vh); hdr_lens->l2_len += sizeof(*vh); proto = vh->eth_proto; + } else if (proto == rte_cpu_to_be_16(ETHER_TYPE_QINQ)) { + const struct vlan_hdr *vh; + struct vlan_hdr vh_copy; + + pkt_type = RTE_PTYPE_L2_ETHER_QINQ; + vh = rte_pktmbuf_read(m, off + sizeof(*vh), sizeof(*vh), + &vh_copy); + if (unlikely(vh == NULL)) + return pkt_type; + off += 2 * sizeof(*vh); + hdr_lens->l2_len += 2 * sizeof(*vh); + proto = vh->eth_proto; } + l3: if (proto == rte_cpu_to_be_16(ETHER_TYPE_IPv4)) { const struct ipv4_hdr *ip4h; struct ipv4_hdr ip4h_copy; diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h index 81979f1..1224b0e 100644 --- a/lib/librte_net/rte_net.h +++ b/lib/librte_net/rte_net.h @@ -65,7 +65,7 @@ struct rte_net_hdr_lens { * (retval & RTE_PTYPE_L2_MASK) != RTE_PTYPE_UNKNOWN. * * Supported packet types are: - * L2: Ether + * L2: Ether, Vlan, QinQ * L3: IPv4, IPv6 * L4: TCP, UDP, SCTP * -- 2.8.1