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 13F9D5A1D 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 0503627ACC for ; Tue, 5 Jul 2016 17:42:01 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Date: Tue, 5 Jul 2016 17:41:38 +0200 Message-Id: <1467733310-20875-7-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 06/18] mbuf: support Vlan 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_VLAN 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 | 13 +++++++++++++ lib/librte_mbuf/rte_mbuf_ptype.h | 9 ++++++++- 2 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 73284ae..6bbb255 100644 --- a/lib/librte_mbuf/rte_mbuf_ptype.c +++ b/lib/librte_mbuf/rte_mbuf_ptype.c @@ -166,6 +166,19 @@ uint32_t rte_pktmbuf_get_ptype(const struct rte_mbuf *m, off = sizeof(*eh); hdr_lens->l2_len = off; + if (proto == rte_cpu_to_be_16(ETHER_TYPE_VLAN)) { + const struct vlan_hdr *vh; + struct vlan_hdr vh_copy; + + pkt_type = RTE_PTYPE_L2_ETHER_VLAN; + vh = rte_pktmbuf_read(m, off, sizeof(*vh), &vh_copy); + if (unlikely(vh == NULL)) + return pkt_type; + off += sizeof(*vh); + hdr_lens->l2_len += sizeof(*vh); + proto = vh->eth_proto; + } + 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_mbuf/rte_mbuf_ptype.h b/lib/librte_mbuf/rte_mbuf_ptype.h index f468520..5f1325c 100644 --- a/lib/librte_mbuf/rte_mbuf_ptype.h +++ b/lib/librte_mbuf/rte_mbuf_ptype.h @@ -136,6 +136,13 @@ extern "C" { */ #define RTE_PTYPE_L2_ETHER_NSH 0x00000005 /** + * VLAN packet type. + * + * Packet format: + * <'ether type'=[0x8100]> + */ +#define RTE_PTYPE_L2_ETHER_VLAN 0x00000006 +/** * Mask of layer 2 packet types. * It is used for outer packet for tunneling cases. */ @@ -573,7 +580,7 @@ struct rte_mbuf_hdr_lens { * (retval & RTE_PTYPE_L2_MASK) != RTE_PTYPE_UNKNOWN. * * Supported packet types are: - * L2: Ether + * L2: Ether, Vlan * L3: IPv4, IPv6 * L4: TCP, UDP, SCTP * -- 2.8.1