From: Xueming Li Date: Thu, 21 Oct 2021 10:41:37 +0000 (+0800) Subject: ethdev: get device capability name as string X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=93e441c9a0c13cade820916979337a4269f67f7c ethdev: get device capability name as string This patch adds API to return name of device capability. Signed-off-by: Xueming Li Reviewed-by: Andrew Rybchenko Acked-by: Ajit Khaparde Acked-by: Thomas Monjalon --- diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 3939c344e8..4ea5a657e0 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -167,6 +167,15 @@ static const struct { #undef RTE_TX_OFFLOAD_BIT2STR +static const struct { + uint64_t offload; + const char *name; +} rte_eth_dev_capa_names[] = { + {RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP, "RUNTIME_RX_QUEUE_SETUP"}, + {RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP, "RUNTIME_TX_QUEUE_SETUP"}, + {RTE_ETH_DEV_CAPA_RXQ_SHARE, "RXQ_SHARE"}, +}; + /** * The user application callback description. * @@ -1236,6 +1245,22 @@ rte_eth_dev_tx_offload_name(uint64_t offload) return name; } +const char * +rte_eth_dev_capability_name(uint64_t capability) +{ + const char *name = "UNKNOWN"; + unsigned int i; + + for (i = 0; i < RTE_DIM(rte_eth_dev_capa_names); ++i) { + if (capability == rte_eth_dev_capa_names[i].offload) { + name = rte_eth_dev_capa_names[i].name; + break; + } + } + + return name; +} + static inline int eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size, uint32_t max_rx_pkt_len, uint32_t dev_info_size) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 8c1b5e01d2..21f5708329 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -2112,6 +2112,20 @@ const char *rte_eth_dev_rx_offload_name(uint64_t offload); */ const char *rte_eth_dev_tx_offload_name(uint64_t offload); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get RTE_ETH_DEV_CAPA_* flag name. + * + * @param capability + * Capability flag. + * @return + * Capability name or 'UNKNOWN' if the flag cannot be recognized. + */ +__rte_experimental +const char *rte_eth_dev_capability_name(uint64_t capability); + /** * Configure an Ethernet device. * This function must be invoked first before any other function in the diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index d552c955c9..e1abe99729 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -249,6 +249,7 @@ EXPERIMENTAL { rte_mtr_meter_policy_validate; # added in 21.11 + rte_eth_dev_capability_name; rte_eth_dev_conf_get; rte_eth_macaddrs_get; rte_eth_rx_metadata_negotiate;