From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 227617EB0 for ; Tue, 18 Nov 2014 08:27:20 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 17 Nov 2014 23:37:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,408,1413270000"; d="scan'208";a="609605567" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 17 Nov 2014 23:37:39 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id sAI7bbXb006147; Tue, 18 Nov 2014 15:37:37 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id sAI7bZbo007577; Tue, 18 Nov 2014 15:37:37 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sAI7bZ1I007573; Tue, 18 Nov 2014 15:37:35 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Tue, 18 Nov 2014 15:37:28 +0800 Message-Id: <1416296251-7534-2-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1416296251-7534-1-git-send-email-jijiang.liu@intel.com> References: <1416296251-7534-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH 1/4] rte_mbuf:add packet types 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, 18 Nov 2014 07:27:22 -0000 This patch abstracts packet types of L2 packet, Non Tunneled IPv4/6, IP in IP, IP in GRE, MAC in GRE and MAC in UDP, and add 4 MACROS to check packet IP header. Signed-off-by: Jijiang Liu --- lib/librte_mbuf/rte_mbuf.h | 223 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 223 insertions(+), 0 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index f5f8658..678db0d 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -125,6 +125,229 @@ extern "C" { */ #define PKT_TX_OFFLOAD_MASK (PKT_TX_VLAN_PKT | PKT_TX_IP_CKSUM | PKT_TX_L4_MASK) +/** + * Ethernet packet type + */ +enum rte_eth_packet_type { + + /* undefined packet type, means HW can't recognise it */ + RTE_PTYPE_UNDEF = 0, + + /* L2 Packet types */ + RTE_PTYPE_PAY2, + RTE_PTYPE_TimeSync_PAY2, /**< IEEE1588 and 802.1AS */ + RTE_PTYPE_FIP_PAY2, /**< FCoE Initiation Protocol */ + RTE_PTYPE_LLDP_PAY2, /**< Link Layer Discovery Protocol */ + RTE_PTYPE_ECP_PAY2, /**< Edge Control Protocol */ + RTE_PTYPE_EAPOL_PAY2, + /**< IEEE 802.1X Extensible Authentication Protocol over LAN */ + RTE_PTYPE_ARP, + RTE_PTYPE_FCOE_PAY3, + RTE_PTYPE_FCOE_FCDATA, + RTE_PTYPE_FCOE_FCRDY, + RTE_PTYPE_FCOE_FCRSP, + RTE_PTYPE_FCOE_FCOTHER, + RTE_PTYPE_FCOE_VFT, + RTE_PTYPE_FCOE_VFT_FCDATA, + RTE_PTYPE_FCOE_VFT_FCRDY, + RTE_PTYPE_FCOE_VFT_FCRSP, + RTE_PTYPE_FCOE_VFT_FCOTHER, + + /* Non Tunneled IPv4 */ + RTE_PTYPE_IPv4FRAG, + RTE_PTYPE_IPv4, + RTE_PTYPE_IPv4_UDP, + RTE_PTYPE_IPv4_TCP, + RTE_PTYPE_IPv4_SCTP, + RTE_PTYPE_IPv4_ICMP, + + /* IP in IP Tunneling (IPv4 --> IPv4) */ + RTE_PTYPE_IPv4_IPv4FRAG, + RTE_PTYPE_IPv4_IPv4, + RTE_PTYPE_IPv4_IPv4_UDP, + RTE_PTYPE_IPv4_IPv4_TCP, + RTE_PTYPE_IPv4_IPv4_SCTP, + RTE_PTYPE_IPv4_IPv4_ICMP, + + /* IP in IP Tunneling (IPv4 --> IPv6) */ + RTE_PTYPE_IPv4_IPv6FRAG, + RTE_PTYPE_IPv4_IPv6, + RTE_PTYPE_IPv4_IPv6_UDP, + RTE_PTYPE_IPv4_IPv6_TCP, + RTE_PTYPE_IPv4_IPv6_SCTP, + RTE_PTYPE_IPv4_IPv6_ICMP, + + /* IPv4 --> GRE/Teredo/VXLAN */ + RTE_PTYPE_IPv4_GRENAT_PAY3, + + /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */ + RTE_PTYPE_IPv4_GRENAT_IPv4FRAG, + RTE_PTYPE_IPv4_GRENAT_IPv4, + RTE_PTYPE_IPv4_GRENAT_IPv4_UDP, + RTE_PTYPE_IPv4_GRENAT_IPv4_TCP, + RTE_PTYPE_IPv4_GRENAT_IPv4_SCTP, + RTE_PTYPE_IPv4_GRENAT_IPv4_ICMP, + + /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */ + RTE_PTYPE_IPv4_GRENAT_IPv6FRAG, + RTE_PTYPE_IPv4_GRENAT_IPv6, + RTE_PTYPE_IPv4_GRENAT_IPv6_UDP, + RTE_PTYPE_IPv4_GRENAT_IPv6_TCP, + RTE_PTYPE_IPv4_GRENAT_IPv6_SCTP, + RTE_PTYPE_IPv4_GRENAT_IPv6_ICMP, + + /* IPv4 --> GRE/Teredo/VXLAN --> MAC */ + RTE_PTYPE_IPv4_GRENAT_MAC_PAY3, + + /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */ + RTE_PTYPE_IPv4_GRENAT_MAC_IPv4FRAG, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv4, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv4_UDP, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv4_TCP, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv4_SCTP, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv4_ICMP, + + /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */ + RTE_PTYPE_IPv4_GRENAT_MAC_IPv6FRAG, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv6, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv6_UDP, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv6_TCP, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv6_SCTP, + RTE_PTYPE_IPv4_GRENAT_MAC_IPv6_ICMP, + + /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN */ + RTE_PTYPE_IPv4_GRENAT_MACVLAN_PAY3, + + /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv4 */ + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4FRAG, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4_UDP, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4_TCP, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4_SCTP, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4_ICMP, + + /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv6 */ + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6FRAG, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_UDP, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_TCP, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_SCTP, + RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_ICMP, + + /* Non Tunneled IPv6 */ + RTE_PTYPE_IPv6FRAG, + RTE_PTYPE_IPv6, + RTE_PTYPE_IPv6_UDP, + RTE_PTYPE_IPv6_TCP, + RTE_PTYPE_IPv6_SCTP, + RTE_PTYPE_IPv6_ICMP, + + /* IP in IP Tunneling (IPv6 --> IPv4) */ + RTE_PTYPE_IPv6_IPv4FRAG, + RTE_PTYPE_IPv6_IPv4, + RTE_PTYPE_IPv6_IPv4_UDP, + RTE_PTYPE_IPv6_IPv4_TCP, + RTE_PTYPE_IPv6_IPv4_SCTP, + RTE_PTYPE_IPv6_IPv4_ICMP, + + /* IP in IP Tunneling (IPv6 --> IPv6) */ + RTE_PTYPE_IPv6_IPv6FRAG, + RTE_PTYPE_IPv6_IPv6, + RTE_PTYPE_IPv6_IPv6_UDP, + RTE_PTYPE_IPv6_IPv6_TCP, + RTE_PTYPE_IPv6_IPv6_SCTP, + RTE_PTYPE_IPv6_IPv6_ICMP, + + /* IPv6 --> GRE/Teredo/VXLAN */ + RTE_PTYPE_IPv6_GRENAT_PAY3, + + /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */ + RTE_PTYPE_IPv6_GRENAT_IPv4FRAG, + RTE_PTYPE_IPv6_GRENAT_IPv4, + RTE_PTYPE_IPv6_GRENAT_IPv4_UDP, + RTE_PTYPE_IPv6_GRENAT_IPv4_TCP, + RTE_PTYPE_IPv6_GRENAT_IPv4_SCTP, + RTE_PTYPE_IPv6_GRENAT_IPv4_ICMP, + + /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */ + RTE_PTYPE_IPv6_GRENAT_IPv6FRAG, + RTE_PTYPE_IPv6_GRENAT_IPv6, + RTE_PTYPE_IPv6_GRENAT_IPv6_UDP, + RTE_PTYPE_IPv6_GRENAT_IPv6_TCP, + RTE_PTYPE_IPv6_GRENAT_IPv6_SCTP, + RTE_PTYPE_IPv6_GRENAT_IPv6_ICMP, + + /* IPv6 --> GRE/Teredo/VXLAN --> MAC */ + RTE_PTYPE_IPv6_GRENAT_MAC_PAY3, + + /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */ + RTE_PTYPE_IPv6_GRENAT_MAC_IPv4FRAG, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv4, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv4_UDP, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv4_TCP, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv4_SCTP, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv4_ICMP, + + /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */ + RTE_PTYPE_IPv6_GRENAT_MAC_IPv6FRAG, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv6, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv6_UDP, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv6_TCP, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv6_SCTP, + RTE_PTYPE_IPv6_GRENAT_MAC_IPv6_ICMP, + + /* IPv6 --> GRE/Teredo/VXLAN --> MAC/VLAN */ + RTE_PTYPE_IPv6_GRENAT_MACVLAN_PAY3, + + /* IPv6 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv4 */ + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv4FRAG, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv4, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv4_UDP, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv4_TCP, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv4_SCTP, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv4_ICMP, + + /* IPv6 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv6 */ + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv6FRAG, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv6, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv6_UDP, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv6_TCP, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv6_SCTP, + RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv6_ICMP, +}; + +/** + * Given the packet type returns if it is a packet with IPv4 header, + * which includes IPv4 tunneling. + */ +#define RTE_ETH_IS_IPV4_HDR(ptype) \ + ((ptype >= RTE_PTYPE_IPv4FRAG) && \ + (ptype <= RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_ICMP)) + +/** + * Given the packet type returns if it is a tunneling packet + * with IPv4 header. + */ +#define RTE_ETH_IS_TUNNEL_IPV4_HDR(ptype) \ + ((ptype >= RTE_PTYPE_IPv4FRAG) && \ + (ptype <= RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_ICMP)) + +/** + * Given the packet type returns if it is a packet with IPv6 header, + * which includes IPv6 tunneling. + */ +#define RTE_ETH_IS_IPV6_HDR(ptype) \ + ((ptype >= RTE_PTYPE_IPv6FRAG) && \ + (ptype <= RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv6_ICMP)) + +/** + * Given the packet type returns if it is a tunneling packet with + * IPv6 header + */ +#define RTE_ETH_IS_TUNNEL_IPV6_HDR(ptype) \ + ((ptype >= RTE_PTYPE_IPv6_IPv4FRAG) && \ + (ptype <= RTE_PTYPE_IPv6_GRENAT_MACVLAN_IPv6_ICMP)) + /* define a set of marker types that can be used to refer to set points in the * mbuf */ typedef void *MARKER[0]; /**< generic marker for a point in a structure */ -- 1.7.7.6