From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f68.google.com (mail-oi0-f68.google.com [209.85.218.68]) by dpdk.org (Postfix) with ESMTP id 7C6FB376F for ; Fri, 7 Apr 2017 12:27:10 +0200 (CEST) Received: by mail-oi0-f68.google.com with SMTP id b187so11364733oif.3 for ; Fri, 07 Apr 2017 03:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9w7U0OUWGuTBlniUqr5+oPEXA3aaxIJIplNhifZjlS8=; b=Qer4SB6X4Cp58wFzpGXaBEZM+MGi575a/D+n2dF2mQ89AJ5W51jDwxu2gfbU4xDJIZ /l6HuS1oyH+N1jQtUvv3JYbgXhs7pen76P1TB73QSXtvqZGkg+ksIzcN0soyrXitOUn1 9XCEc3HU56vkvppayftbDzZFgXUcL+xx8bx9sXLbWrQA5dFjREIIDyVsU5s8JoXRFXYl o9MHHUA3HbN3k2SokdcFw3Z+HtajcwUbxpSayeT0DrZH9zCE+DPqDRVZAUDL/amheH2y etWultJGbN0vYlAhR+BNO/4YSfS9DEHOGSwu/mcoe/13b8A7CH0QMiHb4W9htoc5XS6L m8yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9w7U0OUWGuTBlniUqr5+oPEXA3aaxIJIplNhifZjlS8=; b=uBbM/YMYUuRE9hk5y8d0XG/NjK2xH1VrtTxbXNpg5t/eKOxho170qUgwmaXTIe497/ Mez2y8Bk/ASs5mfWJtQK4o5g6+79rZgdzFjWdPTdjZgdKQgnIxMyQzZwTMpvTAnD6w9e kmmAHkF8mNroRnz5sW8TKU1DGajVH1+TxsUm0y1ZgoOwiO9jLfSCnA7dHrRE/H7CUupt SXXWeN/l9N29ttUJNHQRFhtPP59LD9uhEI0KitYS+r5eno4NXbSj/wLleCWDpkGGCz5I jcGHwI0BSkmwzGPdpvMoMdL06fKo/lWCfQ7xp+JZt3bJ+81DiEzz2xfiADfQttOyou5N TNXA== X-Gm-Message-State: AFeK/H1J0+UE66NtchsUcHwba1PznPRZHhcByeTNY6wGsWU6UALPp5Im7XnQWBe9qMGDiA== X-Received: by 10.202.85.213 with SMTP id j204mr20850949oib.11.1491560829721; Fri, 07 Apr 2017 03:27:09 -0700 (PDT) Received: from host-1.skytap.example ([184.170.234.51]) by smtp.gmail.com with ESMTPSA id h189sm1799021oic.37.2017.04.07.03.27.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Apr 2017 03:27:08 -0700 (PDT) From: Ray Zhang X-Google-Original-From: Ray Zhang To: dev@dpdk.org Cc: Ray Zhang Date: Fri, 7 Apr 2017 03:26:57 -0700 Message-Id: <1491560817-3558-1-git-send-email-skytap@host-1.skytap.example> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491559197-3307-1-git-send-email-skytap@host-1.skytap.example> References: <1491559197-3307-1-git-send-email-skytap@host-1.skytap.example> Subject: [dpdk-dev] [PATCH v1] 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 10:27:10 -0000 From: Ray Zhang Add a new RTE_PTYPE_L2_ETHER_PPPOE and its support in rte_net_get_ptype() Signed-off-by: Ray Zhang --- Resend the patch 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 ff6de9d..7dd03de 100644 --- a/lib/librte_mbuf/rte_mbuf_ptype.h +++ b/lib/librte_mbuf/rte_mbuf_ptype.h @@ -150,6 +150,13 @@ */ #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 ff3d065..d76edb3 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 a8c7aff..439c2f6 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: -- 1.9.1