From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 4F6C81B2A3 for ; Thu, 18 Jan 2018 10:44:46 +0100 (CET) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 5C0BEB0005C; Thu, 18 Jan 2018 09:44:45 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Thu, 18 Jan 2018 01:44:39 -0800 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Thu, 18 Jan 2018 01:44:39 -0800 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id w0I9iekk023641; Thu, 18 Jan 2018 09:44:40 GMT Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id w0I9ieqC029942; Thu, 18 Jan 2018 09:44:40 GMT From: Andrew Rybchenko To: CC: Ivan Malov , Thomas Monjalon , Ferruh Yigit , Shahaf Shuler Date: Thu, 18 Jan 2018 09:44:27 +0000 Message-ID: <1516268671-29894-3-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1516268671-29894-1-git-send-email-arybchenko@solarflare.com> References: <1515658359-1041-1-git-send-email-arybchenko@solarflare.com> <1516268671-29894-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-MDID: 1516268685-qgsSsjhUTDdS Subject: [dpdk-dev] [PATCH v4 2/6] ethdev: add a function to look up Tx offload names 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: Thu, 18 Jan 2018 09:44:46 -0000 From: Ivan Malov Commonly, drivers converted to the new offload API may need to log unsupported offloads as a response to wrong settings. From this perspective, it would be convenient to have generic functions to look up offload names. The patch adds such a helper for Tx. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Ferruh Yigit Cc: Thomas Monjalon Cc: Ferruh Yigit Cc: Shahaf Shuler --- lib/librte_ether/rte_ethdev.c | 45 +++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 18 +++++++++++++ lib/librte_ether/rte_ethdev_version.map | 1 + 3 files changed, 64 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 9e9ef83..cd4a3ed 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -116,6 +116,35 @@ static const struct { #undef RTE_RX_OFFLOAD_BIT2STR +#define RTE_TX_OFFLOAD_BIT2STR(_name) \ + { DEV_TX_OFFLOAD_##_name, #_name } + +static const struct { + uint64_t offload; + const char *name; +} rte_tx_offload_names[] = { + RTE_TX_OFFLOAD_BIT2STR(VLAN_INSERT), + RTE_TX_OFFLOAD_BIT2STR(IPV4_CKSUM), + RTE_TX_OFFLOAD_BIT2STR(UDP_CKSUM), + RTE_TX_OFFLOAD_BIT2STR(TCP_CKSUM), + RTE_TX_OFFLOAD_BIT2STR(SCTP_CKSUM), + RTE_TX_OFFLOAD_BIT2STR(TCP_TSO), + RTE_TX_OFFLOAD_BIT2STR(UDP_TSO), + RTE_TX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM), + RTE_TX_OFFLOAD_BIT2STR(QINQ_INSERT), + RTE_TX_OFFLOAD_BIT2STR(VXLAN_TNL_TSO), + RTE_TX_OFFLOAD_BIT2STR(GRE_TNL_TSO), + RTE_TX_OFFLOAD_BIT2STR(IPIP_TNL_TSO), + RTE_TX_OFFLOAD_BIT2STR(GENEVE_TNL_TSO), + RTE_TX_OFFLOAD_BIT2STR(MACSEC_INSERT), + RTE_TX_OFFLOAD_BIT2STR(MT_LOCKFREE), + RTE_TX_OFFLOAD_BIT2STR(MULTI_SEGS), + RTE_TX_OFFLOAD_BIT2STR(MBUF_FAST_FREE), + RTE_TX_OFFLOAD_BIT2STR(SECURITY), +}; + +#undef RTE_TX_OFFLOAD_BIT2STR + /** * The user application callback description. * @@ -788,6 +817,22 @@ rte_eth_dev_rx_offload_name(uint64_t offload) return name; } +const char * +rte_eth_dev_tx_offload_name(uint64_t offload) +{ + const char *name = "UNKNOWN"; + unsigned int i; + + for (i = 0; i < RTE_DIM(rte_tx_offload_names); ++i) { + if (offload == rte_tx_offload_names[i].offload) { + name = rte_tx_offload_names[i].name; + break; + } + } + + return name; +} + int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, const struct rte_eth_conf *dev_conf) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index f37a5b8..8f26f50 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -981,6 +981,11 @@ struct rte_eth_conf { */ #define DEV_TX_OFFLOAD_SECURITY 0x00020000 +/* + * If new Tx offload capabilities are defined, they also must be + * mentioned in rte_tx_offload_names in rte_ethdev.c file. + */ + struct rte_pci_device; /** @@ -1941,6 +1946,19 @@ uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex); const char *rte_eth_dev_rx_offload_name(uint64_t offload); /** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get DEV_TX_OFFLOAD_* flag name. + * + * @param offload + * Offload flag. + * @return + * Offload name or 'UNKNOWN' if the flag cannot be recognised. + */ +const char *rte_eth_dev_tx_offload_name(uint64_t offload); + +/** * Configure an Ethernet device. * This function must be invoked first before any other function in the * Ethernet API. This function can also be re-invoked when a device is in the diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 83a9926..4e166a7 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -202,6 +202,7 @@ EXPERIMENTAL { global: rte_eth_dev_rx_offload_name; + rte_eth_dev_tx_offload_name; rte_mtr_capabilities_get; rte_mtr_create; rte_mtr_destroy; -- 2.7.4