From: Ivan Malov Date: Thu, 18 Jan 2018 09:44:27 +0000 (+0000) Subject: ethdev: add function to look up Tx offload names X-Git-Tag: spdx-start~67 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=748298441981f0a6eb6c8c2ed425cc6d028dab70;p=dpdk.git ethdev: add function to look up Tx offload names 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 Acked-by: Thomas Monjalon --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 542dcb823f..8a365393d4 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -117,6 +117,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. * @@ -789,6 +818,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 f37a5b84f5..8f26f50b13 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; /** @@ -1940,6 +1945,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 diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 0971a40137..399e78297c 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -209,6 +209,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;