From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 369F97CFD for ; Mon, 5 Mar 2018 15:52:12 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 5 Mar 2018 16:52:37 +0200 Received: from dev-r630-06.mtbc.labs.mlnx (dev-r630-06.mtbc.labs.mlnx [10.12.205.180]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w25Eq9bA022949; Mon, 5 Mar 2018 16:52:10 +0200 Received: from dev-r630-06.mtbc.labs.mlnx (localhost [127.0.0.1]) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id w25Eq9SL071932; Mon, 5 Mar 2018 22:52:09 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id w25Eq955071931; Mon, 5 Mar 2018 22:52:09 +0800 From: Xueming Li To: Wenzhuo Lu , Jingjing Wu , Thomas Monjalon , Yongseok Koh , Olivier MATZ , Shahaf Shuler Cc: Xueming Li , Ferruh Yigit , dev@dpdk.org Date: Mon, 5 Mar 2018 22:51:15 +0800 Message-Id: <20180305145121.71866-2-xuemingl@mellanox.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20180305145121.71866-1-xuemingl@mellanox.com> References: <20180305145121.71866-1-xuemingl@mellanox.com> In-Reply-To: <20180109141110.146250-2-xuemingl@mellanox.com> References: <20180109141110.146250-2-xuemingl@mellanox.com> Subject: [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload 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: Mon, 05 Mar 2018 14:52:12 -0000 This patch introduce new TX offload flags for device that supports tunnel agnostic L3/L4 checksum and TSO offload. The support from the device is for inner and outer checksums on IPV4/TCP/UDP and TSO for *any packet with the following format*: < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / / [optional inner IPv4/IPv6] / [optional TCP/UDP] For example the following packets can use this feature: 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE / MPLS / ipv4 / udp Signed-off-by: Xueming Li --- lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf.c | 5 +++++ lib/librte_mbuf/rte_mbuf.h | 18 ++++++++++++++++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 036153306..66d12d3e0 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -980,6 +980,30 @@ struct rte_eth_conf { * the same mempool and has refcnt = 1. */ #define DEV_TX_OFFLOAD_SECURITY 0x00020000 +/**< Generic tunnel L3/L4 checksum offload. To enable this offload feature + * for a packet to be transmitted on hardware supporting generic tunnel L3/L4 + * checksum offload: + * - fill outer_l2_len and outer_l3_len in mbuf + * - fill l2_len and l3_len in mbuf + * - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if undefined) + * - set the flags PKT_TX_OUTER_IP_CKSUM + * - set the flags PKT_TX_IP_CKSUM + * - set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or PKT_TX_UDP_CKSUM + */ +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM 0x00040000 +/**< Generic tunnel segmentation offload. To enable it, the user needs to: + * - fill outer_l2_len and outer_l3_len in mbuf + * - fill l2_len and l3_len in mbuf + * - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if undefined) + * - set the flags PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6 + * - if it's UDP tunnel, set the flags PKT_TX_OUTER_UDP + * - set the flags PKT_TX_IPV4 or PKT_TX_IPV6 + * - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies + * PKT_TX_OUTER_IP_CKSUM, PKT_TX_IP_CKSUM and PKT_TX_TCP_CKSUM) + * Hardware that supports generic tunnel TSO offload only update outer/inner + * L3/L4 fields, tunnel fields are not touched. + */ +#define DEV_TX_OFFLOAD_GENERIC_TNL_TSO 0x00080000 /* * If new Tx offload capabilities are defined, they also must be diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 091d388d3..c139d5b30 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -400,11 +400,13 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask) case PKT_TX_OUTER_IP_CKSUM: return "PKT_TX_OUTER_IP_CKSUM"; case PKT_TX_OUTER_IPV4: return "PKT_TX_OUTER_IPV4"; case PKT_TX_OUTER_IPV6: return "PKT_TX_OUTER_IPV6"; + case PKT_TX_OUTER_UDP: return "PKT_TX_OUTER_UDP"; case PKT_TX_TUNNEL_VXLAN: return "PKT_TX_TUNNEL_VXLAN"; case PKT_TX_TUNNEL_GRE: return "PKT_TX_TUNNEL_GRE"; case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP"; case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE"; case PKT_TX_TUNNEL_MPLSINUDP: return "PKT_TX_TUNNEL_MPLSINUDP"; + case PKT_TX_TUNNEL_UNKNOWN: return "PKT_TX_TUNNEL_UNKNOWN"; case PKT_TX_MACSEC: return "PKT_TX_MACSEC"; case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD"; default: return NULL; @@ -429,6 +431,7 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) { PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM, NULL }, { PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4, NULL }, { PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6, NULL }, + { PKT_TX_OUTER_UDP, PKT_TX_OUTER_UDP, NULL }, { PKT_TX_TUNNEL_VXLAN, PKT_TX_TUNNEL_MASK, "PKT_TX_TUNNEL_NONE" }, { PKT_TX_TUNNEL_GRE, PKT_TX_TUNNEL_MASK, @@ -439,6 +442,8 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) "PKT_TX_TUNNEL_NONE" }, { PKT_TX_TUNNEL_MPLSINUDP, PKT_TX_TUNNEL_MASK, "PKT_TX_TUNNEL_NONE" }, + { PKT_TX_TUNNEL_UNKNOWN, PKT_TX_TUNNEL_MASK, + "PKT_TX_TUNNEL_NONE" }, { PKT_TX_MACSEC, PKT_TX_MACSEC, NULL }, { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL }, }; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 62740254d..53cc1b713 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -210,6 +210,13 @@ extern "C" { #define PKT_TX_TUNNEL_GENEVE (0x4ULL << 45) /**< TX packet with MPLS-in-UDP RFC 7510 header. */ #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45) +/** + * Used by generic tunnel checksum and TSO. Please refer to document of below + * fields to enable this feature on hardware support Generic tunnel offload: + * - DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM + * - DEV_TX_OFFLOAD_GENERIC_TNL_TSO + */ +#define PKT_TX_TUNNEL_UNKNOWN (0xFULL << 45) /* add new TX TUNNEL type here */ #define PKT_TX_TUNNEL_MASK (0xFULL << 45) @@ -232,6 +239,8 @@ extern "C" { * - calculate the pseudo header checksum without taking ip_len in account, * and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and * rte_ipv6_phdr_cksum() that can be used as helpers. + * PLease refer to DEV_TX_OFFLOAD_GENERIC_TNL_TSO to enable Generic tunnel + * TSO. */ #define PKT_TX_TCP_SEG (1ULL << 50) @@ -311,6 +320,13 @@ extern "C" { #define PKT_TX_OUTER_IPV6 (1ULL << 60) /** + * Packet outer header is UDP. Set when using generic tunnel TSO offload + * (DEV_TX_OFFLOAD_GENERIC_TNL_TSO) to tell the NIC that the outer L4 + * header is UDP. + */ +#define PKT_TX_OUTER_UDP (1ULL << 61) /**< Outer L4 header is UDP. */ + +/** * Bitmask of all supported packet Tx offload features flags, * which can be set for packet. */ @@ -326,8 +342,6 @@ extern "C" { PKT_TX_MACSEC | \ PKT_TX_SEC_OFFLOAD) -#define __RESERVED (1ULL << 61) /**< reserved for future mbuf use */ - #define IND_ATTACHED_MBUF (1ULL << 62) /**< Indirect attached mbuf */ /* Use final bit of flags to indicate a control mbuf */ -- 2.13.3