From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id 849BD5A6B for ; Wed, 6 Jul 2016 10:00:10 +0200 (CEST) Received: by mail-wm0-f45.google.com with SMTP id z126so101586844wme.0 for ; Wed, 06 Jul 2016 01:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=or75iwhgkstYRmUFbLa9XfNgWz+PGXm5HUAfO7yAP04=; b=Un/sZfGJ6/JbsVSEJqCf3tXNm6eR+ULlFT4V75TCX7Ekgvnl+lXK1J+x+oG0J6yXFG 7WiG3iMgLFuQK5H+597JeVW31i5ebe1I9McwYiFJyHlTPbAf2n3QJsCKLDJMOyTXTsrG 7KbKNatTY73X3IrX/ENlPCA7pBXiBGes5O8J2PbeuokXfzgh5DsWMSUDZz8lYaiFGctW fbfj2R8rRit/bdUGb0jKSN/kxjSTXvXr6Rny5NvCYx6wv67vVV5ZV/BzO8bVh79BePjx rmIIJYoShbTrc7PTY1w9XvH9WSVbYUoNZlWQW9/kMHQs+LodZykTpUgmRNA2I7n3/xAe BbMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=or75iwhgkstYRmUFbLa9XfNgWz+PGXm5HUAfO7yAP04=; b=IJjlh9ugIckm4AKADtsF/ftxsTNUZmEqCNgEc5eDKCAJCeuAKkHZD8pyqjP9mXV4P6 EV+X4FMFdLM6AxzQ9dqxLAKUWi4zKeIVw5FrPqTOuVlrc/Pvey8UafbmW+z026/2QhFe Ns9rBkTBFgKuSyXh6HZjo5pkhnF8oxLJV8NsAGbLPC2nQfGlzaphu+szF0PptIcVatWt 6y16FgaY+VLdG4w7UtCG5ewDJmopwvaI8LkR/eopGU/Qc0cFbj7b5r6uoyi0VmaJ0yEO 7rCStv+ng77Lr8m41QzVRWJKLhRtB7qqpZ9KiLYbyhSMhgEPnFe3ahCl995ay7yMqzDD yfLw== X-Gm-Message-State: ALyK8tK0llmkESx0yNPeMkMtJQ29bgKWi/ttP2wBIeHw5Q+IsCm2vcCSPuSJCl4XO/72CDkj X-Received: by 10.194.78.148 with SMTP id b20mr888610wjx.5.1467792010207; Wed, 06 Jul 2016 01:00:10 -0700 (PDT) Received: from [192.168.1.15] (LFbn-1-8274-170.w81-254.abo.wanadoo.fr. [81.254.171.170]) by smtp.gmail.com with ESMTPSA id j2sm1111910wjz.15.2016.07.06.01.00.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2016 01:00:09 -0700 (PDT) To: "Liang, Cunming" , dev@dpdk.org References: <1467733310-20875-1-git-send-email-olivier.matz@6wind.com> <1467733310-20875-10-git-send-email-olivier.matz@6wind.com> <577CAE66.6050606@intel.com> From: Olivier MATZ Message-ID: <299f6d61-0ec4-dae4-d79d-fb746dc201b7@6wind.com> Date: Wed, 6 Jul 2016 10:00:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: <577CAE66.6050606@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 09/18] mbuf: support Mpls 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: Wed, 06 Jul 2016 08:00:10 -0000 Hi Cunming, On 07/06/2016 09:08 AM, Liang, Cunming wrote: > Hi Olivier, > > On 7/5/2016 11:41 PM, Olivier Matz wrote: >> Add a new RTE_PTYPE_L2_ETHER_MPLS 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 | 25 +++++++++++++++++++++++++ >> lib/librte_mbuf/rte_mbuf_ptype.h | 9 ++++++++- >> lib/librte_net/Makefile | 4 +++- >> lib/librte_net/rte_ether.h | 2 ++ >> 4 files changed, 38 insertions(+), 2 deletions(-) >> >> diff --git a/lib/librte_mbuf/rte_mbuf_ptype.c >> b/lib/librte_mbuf/rte_mbuf_ptype.c >> index 5d46608..0dea600 100644 >> --- a/lib/librte_mbuf/rte_mbuf_ptype.c >> +++ b/lib/librte_mbuf/rte_mbuf_ptype.c >> @@ -41,6 +41,7 @@ >> #include >> #include >> #include >> +#include >> /* get l3 packet type from ip6 next protocol */ >> static uint32_t >> @@ -166,6 +167,9 @@ 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_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; >> @@ -189,8 +193,29 @@ uint32_t rte_pktmbuf_get_ptype(const struct >> rte_mbuf *m, >> off += 2 * sizeof(*vh); >> hdr_lens->l2_len += 2 * sizeof(*vh); >> proto = vh->eth_proto; >> + } else if ((proto == rte_cpu_to_be_16(ETHER_TYPE_MPLS)) || >> + (proto == rte_cpu_to_be_16(ETHER_TYPE_MPLSM))) { >> + unsigned int i; >> + const struct mpls_hdr *mh; >> + struct mpls_hdr mh_copy; >> + >> +#define MAX_MPLS_HDR 5 >> + for (i = 0; i < MAX_MPLS_HDR; i++) { >> + mh = rte_pktmbuf_read(m, off + (i * sizeof(*mh)), >> + sizeof(*mh), &mh_copy); >> + if (unlikely(mh == NULL)) >> + return pkt_type; >> + if (mh->bs) >> + break; >> + } >> + if (i == MAX_MPLS_HDR) >> + return pkt_type; >> + pkt_type = RTE_PTYPE_L2_ETHER_MPLS; >> + hdr_lens->l2_len += (sizeof(*mh) * (i + 1)); > [LC] l2_len includes Eth, Vlan(opt.), MPLS(opt.). For VLAN and MPLS, it > may include #n times overlay. > These layer recognition knowledge are lost after the detection logic. > Once the APP takes the ptype, for the layer(L2, L3, L4) which has more > shim-layer, the xxx_len can't help to avoid the re-parse cost. This is linked with the definition of packet type. Each layer has a type, and here we associate it to a length (by the way the length is something we may consider integrate inside the packet type in the future). The packet_type model allows to describe many packets kinds. Some will be difficult to represent (ex: a packet with several different L2 or L3). But I think this is a good compromise that could help the application to get some information without looking inside the packet. Changing the packet type structure to something more flexible/complex would probably imply to loose time filling it in drivers and parse it in the application. And we already have a structure that contains all the information needed by the application: the packet data ;) In any case, this is not really the topic of the patchset, which just provide a helper to parse a packet by software and get a packet_type (as it is defined today). Regards, Olivier