From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: [PATCH v3 06/16] net: support Vlan in software packet type parser Date: Mon, 3 Oct 2016 10:38:47 +0200 Message-ID: <1475483937-21696-7-git-send-email-olivier.matz@6wind.com> References: <1472481335-21226-1-git-send-email-olivier.matz@6wind.com> <1475483937-21696-1-git-send-email-olivier.matz@6wind.com> Cc: cunming.liang@intel.com, john.mcnamara@intel.com, andrey.chilikin@intel.com, konstantin.ananyev@intel.com, Didier Pallard To: dev@dpdk.org 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 58F85298F for ; Mon, 3 Oct 2016 10:39:04 +0200 (CEST) In-Reply-To: <1475483937-21696-1-git-send-email-olivier.matz@6wind.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add a new RTE_PTYPE_L2_ETHER_VLAN 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_net.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf_ptype.h b/lib/librte_mbuf/rte_mbuf_ptype.h index 65e9ced..a955c5a 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. */ diff --git a/lib/librte_net/rte_net.c b/lib/librte_net/rte_net.c index 93e9df0..a75b509 100644 --- a/lib/librte_net/rte_net.c +++ b/lib/librte_net/rte_net.c @@ -167,6 +167,19 @@ 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_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; -- 2.8.1