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 1F0A95A30 for ; Tue, 5 Jul 2016 17:42:01 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 0F78327ACB for ; Tue, 5 Jul 2016 17:42:01 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Date: Tue, 5 Jul 2016 17:41:39 +0200 Message-Id: <1467733310-20875-8-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1467733310-20875-1-git-send-email-olivier.matz@6wind.com> References: <1467733310-20875-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 07/18] mbuf: 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: Tue, 05 Jul 2016 15:42:01 -0000 Add a new RTE_PTYPE_L2_ETHER_QINQ packet type, and its support in rte_pktmbuf_get_ptype(). Signed-off-by: Didier Pallard Signed-off-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf_ptype.c | 12 ++++++++++++ lib/librte_mbuf/rte_mbuf_ptype.h | 9 ++++++++- lib/librte_net/rte_ether.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/librte_mbuf/rte_mbuf_ptype.c b/lib/librte_mbuf/rte_mbuf_ptype.c index 6bbb255..5d46608 100644 --- a/lib/librte_mbuf/rte_mbuf_ptype.c +++ b/lib/librte_mbuf/rte_mbuf_ptype.c @@ -177,6 +177,18 @@ uint32_t rte_pktmbuf_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; } if (proto == rte_cpu_to_be_16(ETHER_TYPE_IPv4)) { diff --git a/lib/librte_mbuf/rte_mbuf_ptype.h b/lib/librte_mbuf/rte_mbuf_ptype.h index 5f1325c..e2e92d0 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. */ @@ -580,7 +587,7 @@ struct rte_mbuf_hdr_lens { * (retval & RTE_PTYPE_L2_MASK) != RTE_PTYPE_UNKNOWN. * * Supported packet types are: - * L2: Ether, Vlan + * L2: Ether, Vlan, QinQ * L3: IPv4, IPv6 * L4: TCP, UDP, SCTP * 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. */ -- 2.8.1