[v10,2/7] ethdev: new API to resolve device capability name
Checks
Commit Message
This patch adds API to return name of device capability.
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
lib/ethdev/rte_ethdev.c | 30 ++++++++++++++++++++++++++++++
lib/ethdev/rte_ethdev.h | 14 ++++++++++++++
lib/ethdev/version.map | 3 +++
3 files changed, 47 insertions(+)
Comments
On 10/19/21 6:28 PM, Xueming Li wrote:
> This patch adds API to return name of device capability.
>
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
[snip]
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index bc55f899f72..97217529449 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -165,6 +165,20 @@ static const struct {
>
> #undef RTE_TX_OFFLOAD_BIT2STR
>
> +#define RTE_ETH_DEV_CAPA_BIT2STR(_name) \
> + { RTE_ETH_DEV_CAPA_##_name, #_name }
In fact, such macros make more harm than add value.
It complicates grep by capability name. So, it is better
to drop the macro and just duplicate few symbols below.
> +
> +static const struct {
> + uint64_t offload;
> + const char *name;
> +} rte_eth_dev_capa_names[] = {
> + RTE_ETH_DEV_CAPA_BIT2STR(RUNTIME_RX_QUEUE_SETUP),
> + RTE_ETH_DEV_CAPA_BIT2STR(RUNTIME_TX_QUEUE_SETUP),
> + RTE_ETH_DEV_CAPA_BIT2STR(RXQ_SHARE),
> +};
> +
> +#undef RTE_ETH_DEV_CAPA_BIT2STR
> +
> /**
> * The user application callback description.
> *
On Tue, 2021-10-19 at 20:57 +0300, Andrew Rybchenko wrote:
> On 10/19/21 6:28 PM, Xueming Li wrote:
> > This patch adds API to return name of device capability.
> >
> > Signed-off-by: Xueming Li <xuemingl@nvidia.com>
>
> [snip]
>
> > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> > index bc55f899f72..97217529449 100644
> > --- a/lib/ethdev/rte_ethdev.c
> > +++ b/lib/ethdev/rte_ethdev.c
> > @@ -165,6 +165,20 @@ static const struct {
> >
> > #undef RTE_TX_OFFLOAD_BIT2STR
> >
> > +#define RTE_ETH_DEV_CAPA_BIT2STR(_name) \
> > + { RTE_ETH_DEV_CAPA_##_name, #_name }
>
> In fact, such macros make more harm than add value.
> It complicates grep by capability name. So, it is better
> to drop the macro and just duplicate few symbols below.
Will update in next version. Eclipse resolves macros and search into
expanded macros.
BTW, do you plan to review other patches today? If so I will hold new
version a little bit to avoid explode maillist.
>
> > +
> > +static const struct {
> > + uint64_t offload;
> > + const char *name;
> > +} rte_eth_dev_capa_names[] = {
> > + RTE_ETH_DEV_CAPA_BIT2STR(RUNTIME_RX_QUEUE_SETUP),
> > + RTE_ETH_DEV_CAPA_BIT2STR(RUNTIME_TX_QUEUE_SETUP),
> > + RTE_ETH_DEV_CAPA_BIT2STR(RXQ_SHARE),
> > +};
> > +
> > +#undef RTE_ETH_DEV_CAPA_BIT2STR
> > +
> > /**
> > * The user application callback description.
> > *
On 10/20/21 10:47 AM, Xueming(Steven) Li wrote:
> On Tue, 2021-10-19 at 20:57 +0300, Andrew Rybchenko wrote:
>> On 10/19/21 6:28 PM, Xueming Li wrote:
>>> This patch adds API to return name of device capability.
>>>
>>> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
>>
>> [snip]
>>
>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>>> index bc55f899f72..97217529449 100644
>>> --- a/lib/ethdev/rte_ethdev.c
>>> +++ b/lib/ethdev/rte_ethdev.c
>>> @@ -165,6 +165,20 @@ static const struct {
>>>
>>> #undef RTE_TX_OFFLOAD_BIT2STR
>>>
>>> +#define RTE_ETH_DEV_CAPA_BIT2STR(_name) \
>>> + { RTE_ETH_DEV_CAPA_##_name, #_name }
>>
>> In fact, such macros make more harm than add value.
>> It complicates grep by capability name. So, it is better
>> to drop the macro and just duplicate few symbols below.
>
> Will update in next version. Eclipse resolves macros and search into
> expanded macros.
>
> BTW, do you plan to review other patches today? If so I will hold new
> version a little bit to avoid explode maillist.
Sorry, I have no time to review testpmd patches today.
ethdev part LGTM.
@@ -165,6 +165,20 @@ static const struct {
#undef RTE_TX_OFFLOAD_BIT2STR
+#define RTE_ETH_DEV_CAPA_BIT2STR(_name) \
+ { RTE_ETH_DEV_CAPA_##_name, #_name }
+
+static const struct {
+ uint64_t offload;
+ const char *name;
+} rte_eth_dev_capa_names[] = {
+ RTE_ETH_DEV_CAPA_BIT2STR(RUNTIME_RX_QUEUE_SETUP),
+ RTE_ETH_DEV_CAPA_BIT2STR(RUNTIME_TX_QUEUE_SETUP),
+ RTE_ETH_DEV_CAPA_BIT2STR(RXQ_SHARE),
+};
+
+#undef RTE_ETH_DEV_CAPA_BIT2STR
+
/**
* The user application callback description.
*
@@ -1260,6 +1274,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)
@@ -2109,6 +2109,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
@@ -245,6 +245,9 @@ EXPERIMENTAL {
rte_mtr_meter_policy_delete;
rte_mtr_meter_policy_update;
rte_mtr_meter_policy_validate;
+
+ # added in 21.11
+ rte_eth_dev_capability_name;
};
INTERNAL {