From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by dpdk.org (Postfix) with ESMTP id D24E59E3 for ; Fri, 7 Apr 2017 10:54:43 +0200 (CEST) Received: by mail-pg0-f66.google.com with SMTP id 79so14148508pgf.0 for ; Fri, 07 Apr 2017 01:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=7ERg/evWrcLoq/zySduQUYWXuziVx7mBQmYDuPvvveI=; b=JIH5pKslPTU8BRJ6CoXKKT4aBMkaJcocdtmn1r56Cnx4OYmO/kW9A+muGM+AcZaNLm OtLS0WSGH3nzzHdMSFLOyA/hMXS5pU4oj2NjS5ouTloN6O+fSMje/ceSNzucq0pcmBGQ NVszXgdZfT5ZVaCX9t8bjn9gRX3tla5c55D2rLqTISdh2W7zjD5bVQo5LSZlSePUNTUu TQHU/7Fbzvyb6nVTpQQR5U5PFc8R00K3yR1PtDoO8VTA2Kkl871TV2D3DHt+T58DwHzM YgW9cig2f4aCU7o6H0e+VftzT3kQ9VC1ol/ftSmOTw335t8fgrePe6BgVhVIN+rghMMM 7Kug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=7ERg/evWrcLoq/zySduQUYWXuziVx7mBQmYDuPvvveI=; b=CORG7YHxG92+3l4qr7K3MAdfLelKXfcbL2pJ18hD5M6jtlhHboZMwq1sj+6Ok4U3MY 849ft7ivCqG/tOKYKA/+fbLrhyr/+ffyvt7IxtuS12n/eTNmfqoENqhDjL51mYiN4qFT Anc0pj1MuZ0dGsBXn0B8WMMwYSqJbCgoErdOmOisR42IGwEONBrL88/z4WkoEi0/ojF4 1I1hNc+KHMQZfIR3x0UIinYqepY7IiJcn17LNks65vezK5gvENayfNedEnegJPsAEQRj OIUHG8Nle2AjPUNKvclH/IZ6TADW28awLN/uucH1yBXQ4yrUCk+rYItf1Uo3htII6Hlq iQ+g== X-Gm-Message-State: AFeK/H2IYzUla5pRXfytDy4VlJiZoBXNu+ed14i1+wVKxdOPMrBOLQINlWt9HgX6fpZI66tO4KHpe0zyYMR11A== X-Received: by 10.99.240.83 with SMTP id s19mr40509594pgj.45.1491555282592; Fri, 07 Apr 2017 01:54:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.169.198 with HTTP; Fri, 7 Apr 2017 01:54:42 -0700 (PDT) From: Zhang Lei Date: Fri, 7 Apr 2017 16:54:42 +0800 Message-ID: To: dev@dpdk.org Content-Type: text/plain; charset=UTF-8 Subject: [dpdk-dev] [PATCH] net: support PPPOE in software packet type parser X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Apr 2017 08:54:44 -0000 Add a new RTE_PTYPE_L2_ETHER_PPPOE and its support in rte_net_get_ptype() Signed-off-by: Ray Zhang --- lib/librte_mbuf/rte_mbuf_ptype.h | 7 +++++++ lib/librte_net/rte_ether.h | 12 ++++++++++++ lib/librte_net/rte_net.c | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf_ptype.h b/lib/librte_mbuf/rte_mbuf_ptype.h index ff6de9d17..7dd03de9e 100644 --- a/lib/librte_mbuf/rte_mbuf_ptype.h +++ b/lib/librte_mbuf/rte_mbuf_ptype.h @@ -150,6 +150,13 @@ extern "C" { */ #define RTE_PTYPE_L2_ETHER_QINQ 0x00000007 /** + * PPPOE packet type. + * + * Packet format: + * <'ether type'=[0x8864]> + */ +#define RTE_PTYPE_L2_ETHER_PPPOE 0x00000008 +/** * 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 ff3d06540..d76edb368 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -323,12 +323,24 @@ struct vxlan_hdr { uint32_t vx_vni; /**< VNI (24) + Reserved (8). */ } __attribute__((__packed__)); +/** + * PPPOE protocol header + */ +struct pppoe_hdr { + uint8_t type_ver; + uint8_t code; + uint16_t sid; + uint16_t length; + uint16_t proto; +} __attribute__((packed)); + /* Ethernet frame types */ #define ETHER_TYPE_IPv4 0x0800 /**< IPv4 Protocol. */ #define ETHER_TYPE_IPv6 0x86DD /**< IPv6 Protocol. */ #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_PPPOE 0x8864 /**< PPPoE Protocol */ #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). */ diff --git a/lib/librte_net/rte_net.c b/lib/librte_net/rte_net.c index a8c7aff9c..439c2f6e6 100644 --- a/lib/librte_net/rte_net.c +++ b/lib/librte_net/rte_net.c @@ -302,6 +302,25 @@ uint32_t rte_net_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_PPPOE)) { + const struct pppoe_hdr *ph; + struct pppoe_hdr ph_copy; + + pkt_type = RTE_PTYPE_L2_ETHER_PPPOE; + ph = rte_pktmbuf_read(m, off, sizeof(*ph), &ph_copy); + if (unlikely(ph == NULL)) + return pkt_type; + + off += sizeof(*ph); + hdr_lens->l2_len += sizeof(*ph); + if (ph->code != 0) /* Not Seesion Data */ + return pkt_type; + if (ph->proto == rte_cpu_to_be_16(0x21)) + proto = rte_cpu_to_be_16(ETHER_TYPE_IPv4); + else if (ph->proto == rte_cpu_to_be_16(0x57)) + proto = rte_cpu_to_be_16(ETHER_TYPE_IPv6); + else + return pkt_type; } l3: -- 2.12.0.189.g3bc53220c