[v3,1/4] ethdev: add the API for getting burst mode information
Checks
Commit Message
Some PMDs have more than one RX/TX burst paths, add the ethdev API
that allows an application to retrieve the mode information about
Rx/Tx packet burst such as Scalar or Vector, and Vector technology
like AVX2.
Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
---
doc/guides/nics/features.rst | 11 ++++
doc/guides/nics/features/default.ini | 1 +
doc/guides/rel_notes/release_19_11.rst | 9 +++
lib/librte_ethdev/rte_ethdev.c | 71 ++++++++++++++++++++
lib/librte_ethdev/rte_ethdev.h | 82 ++++++++++++++++++++++++
lib/librte_ethdev/rte_ethdev_core.h | 5 ++
lib/librte_ethdev/rte_ethdev_version.map | 5 ++
7 files changed, 184 insertions(+)
Comments
On 10/14/2019 4:35 PM, Haiyue Wang wrote:
> Some PMDs have more than one RX/TX burst paths, add the ethdev API
> that allows an application to retrieve the mode information about
> Rx/Tx packet burst such as Scalar or Vector, and Vector technology
> like AVX2.
>
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
As far as I can see Bernard has ack only on testpmd patch, 4/4, not for reset of
the patchset, can you please confirm this offline?
> Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
<...>
> +const char *
> +rte_eth_burst_mode_option_name(uint64_t option)
> +{
> + switch (option) {
> + case RTE_ETH_BURST_SCALAR: return "Scalar";
> + case RTE_ETH_BURST_VECTOR: return "Vector";
> +
> + case RTE_ETH_BURST_ALTIVEC: return "AltiVec";
> + case RTE_ETH_BURST_NEON: return "Neon";
> + case RTE_ETH_BURST_SSE: return "SSE";
> + case RTE_ETH_BURST_AVX2: return "AVX2";
> + case RTE_ETH_BURST_AVX512: return "AVX512";
> +
> + case RTE_ETH_BURST_SCATTERED: return "Scattered";
> + case RTE_ETH_BURST_BULK_ALLOC: return "Bulk Alloc";
> + case RTE_ETH_BURST_SIMPLE: return "Simple";
> +
> + case RTE_ETH_BURST_PER_QUEUE: return "Per Queue";
> + }
> +
> + return "";
> +}
Hi Haiyue,
The string representation of a vector mode is a data, and I think better to keep
it separately as an array instead of keeping this information in the function
and make the function use that data.
So that when new type are added it won't require to update the function itself.
'rte_rx_offload_names' and 'rte_eth_dev_rx_offload_name()' is the good sample of
what I mentioned above.
Thanks,
ferruh
Hi,
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Tuesday, October 15, 2019 00:39
> To: Wang, Haiyue <haiyue.wang@intel.com>; dev@dpdk.org; Ye, Xiaolong <xiaolong.ye@intel.com>
> Cc: Kinsella, Ray <ray.kinsella@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>; Sun,
> Chenmin <chenmin.sun@intel.com>
> Subject: Re: [PATCH v3 1/4] ethdev: add the API for getting burst mode information
>
> On 10/14/2019 4:35 PM, Haiyue Wang wrote:
> > Some PMDs have more than one RX/TX burst paths, add the ethdev API
> > that allows an application to retrieve the mode information about
> > Rx/Tx packet burst such as Scalar or Vector, and Vector technology
> > like AVX2.
> >
> > Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
>
> As far as I can see Bernard has ack only on testpmd patch, 4/4, not for reset of
> the patchset, can you please confirm this offline?
>
I checked it, yes, will remove other three ACKs, sorry for not so strict.
> > Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
>
> <...>
>
> > +const char *
> > +rte_eth_burst_mode_option_name(uint64_t option)
> > +{
> > + switch (option) {
> > + case RTE_ETH_BURST_SCALAR: return "Scalar";
> > + case RTE_ETH_BURST_VECTOR: return "Vector";
> > +
> > + case RTE_ETH_BURST_ALTIVEC: return "AltiVec";
> > + case RTE_ETH_BURST_NEON: return "Neon";
> > + case RTE_ETH_BURST_SSE: return "SSE";
> > + case RTE_ETH_BURST_AVX2: return "AVX2";
> > + case RTE_ETH_BURST_AVX512: return "AVX512";
> > +
> > + case RTE_ETH_BURST_SCATTERED: return "Scattered";
> > + case RTE_ETH_BURST_BULK_ALLOC: return "Bulk Alloc";
> > + case RTE_ETH_BURST_SIMPLE: return "Simple";
> > +
> > + case RTE_ETH_BURST_PER_QUEUE: return "Per Queue";
> > + }
> > +
> > + return "";
> > +}
>
> Hi Haiyue,
>
> The string representation of a vector mode is a data, and I think better to keep
> it separately as an array instead of keeping this information in the function
> and make the function use that data.
> So that when new type are added it won't require to update the function itself.
>
> 'rte_rx_offload_names' and 'rte_eth_dev_rx_offload_name()' is the good sample of
> what I mentioned above.
>
+1, will update it.
> Thanks,
> ferruh
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Tuesday, October 15, 2019 00:39
> To: Wang, Haiyue <haiyue.wang@intel.com>; dev@dpdk.org; Ye, Xiaolong <xiaolong.ye@intel.com>
> Cc: Kinsella, Ray <ray.kinsella@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>; Sun,
> Chenmin <chenmin.sun@intel.com>
> Subject: Re: [PATCH v3 1/4] ethdev: add the API for getting burst mode information
>
> On 10/14/2019 4:35 PM, Haiyue Wang wrote:
> > Some PMDs have more than one RX/TX burst paths, add the ethdev API
> > that allows an application to retrieve the mode information about
> > Rx/Tx packet burst such as Scalar or Vector, and Vector technology
> > like AVX2.
> >
> > Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
>
> As far as I can see Bernard has ack only on testpmd patch, 4/4, not for reset of
> the patchset, can you please confirm this offline?
>
> > Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
>
> <...>
>
> > +const char *
> > +rte_eth_burst_mode_option_name(uint64_t option)
> > +{
> > + switch (option) {
> > + case RTE_ETH_BURST_SCALAR: return "Scalar";
> > + case RTE_ETH_BURST_VECTOR: return "Vector";
> > +
> > + case RTE_ETH_BURST_ALTIVEC: return "AltiVec";
> > + case RTE_ETH_BURST_NEON: return "Neon";
> > + case RTE_ETH_BURST_SSE: return "SSE";
> > + case RTE_ETH_BURST_AVX2: return "AVX2";
> > + case RTE_ETH_BURST_AVX512: return "AVX512";
> > +
> > + case RTE_ETH_BURST_SCATTERED: return "Scattered";
> > + case RTE_ETH_BURST_BULK_ALLOC: return "Bulk Alloc";
> > + case RTE_ETH_BURST_SIMPLE: return "Simple";
> > +
> > + case RTE_ETH_BURST_PER_QUEUE: return "Per Queue";
> > + }
> > +
> > + return "";
> > +}
>
> Hi Haiyue,
>
> The string representation of a vector mode is a data, and I think better to keep
> it separately as an array instead of keeping this information in the function
> and make the function use that data.
> So that when new type are added it won't require to update the function itself.
>
Hi Ferruh,
Even the vector mode is a data, it still is a bit field option, if we treated them
differently, that will make 'rte_eth_burst_mode_option_name' ugly like:
switch (option) {
case RTE_ETH_BURST_SCALAR: return "Scalar";
case RTE_ETH_BURST_VECTOR: return "Vector";
case RTE_ETH_BURST_SCATTERED: return "Scattered";
case RTE_ETH_BURST_BULK_ALLOC: return "Bulk Alloc";
case RTE_ETH_BURST_SIMPLE: return "Simple";
case RTE_ETH_BURST_PER_QUEUE: return "Per Queue";
}
static const struct {
uint64_t vector;
const char *name;
} rte_burst_vector_names[] = {
{ RTE_ETH_BURST_ALTIVEC, "AltiVec" },
{ RTE_ETH_BURST_NEON, "Neon" },
{ RTE_ETH_BURST_SSE, "SSE" },
{ RTE_ETH_BURST_AVX2, "AVX2" },
{ RTE_ETH_BURST_AVX512, "AVX512" },
};
for (i = 0; i < RTE_DIM(rte_burst_vector_names); ++i) {
if (option == rte_burst_ vector _names[i].option)
return rte_burst_option_names[i].name;
}
Why just put them together ?
static const struct {
uint64_t option;
const char *name;
} rte_burst_option_names[] = {
{ RTE_ETH_BURST_SCALAR, "Scalar" },
{ RTE_ETH_BURST_VECTOR, "Vector" },
{ RTE_ETH_BURST_ALTIVEC, "AltiVec" },
{ RTE_ETH_BURST_NEON, "Neon" },
{ RTE_ETH_BURST_SSE, "SSE" },
{ RTE_ETH_BURST_AVX2, "AVX2" },
{ RTE_ETH_BURST_AVX512, "AVX512" },
{ RTE_ETH_BURST_SCATTERED, "Scattered" },
{ RTE_ETH_BURST_BULK_ALLOC, "Bulk Alloc" },
{ RTE_ETH_BURST_SIMPLE, "Simple" },
{ RTE_ETH_BURST_PER_QUEUE, "Per Queue" },
};
const char *
rte_eth_burst_mode_option_name(uint64_t option)
{
const char *name = "";
unsigned int i;
for (i = 0; i < RTE_DIM(rte_burst_option_names); ++i) {
if (option == rte_burst_option_names[i].option) {
name = rte_burst_option_names[i].name;
break;
}
}
return name;
}
> 'rte_rx_offload_names' and 'rte_eth_dev_rx_offload_name()' is the good sample of
> what I mentioned above.
>
> Thanks,
> ferruh
On 10/15/2019 2:39 AM, Wang, Haiyue wrote:
>> -----Original Message-----
>> From: Yigit, Ferruh
>> Sent: Tuesday, October 15, 2019 00:39
>> To: Wang, Haiyue <haiyue.wang@intel.com>; dev@dpdk.org; Ye, Xiaolong <xiaolong.ye@intel.com>
>> Cc: Kinsella, Ray <ray.kinsella@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>; Sun,
>> Chenmin <chenmin.sun@intel.com>
>> Subject: Re: [PATCH v3 1/4] ethdev: add the API for getting burst mode information
>>
>> On 10/14/2019 4:35 PM, Haiyue Wang wrote:
>>> Some PMDs have more than one RX/TX burst paths, add the ethdev API
>>> that allows an application to retrieve the mode information about
>>> Rx/Tx packet burst such as Scalar or Vector, and Vector technology
>>> like AVX2.
>>>
>>> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
>>> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
>>
>> As far as I can see Bernard has ack only on testpmd patch, 4/4, not for reset of
>> the patchset, can you please confirm this offline?
>>
>>> Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
>>
>> <...>
>>
>>> +const char *
>>> +rte_eth_burst_mode_option_name(uint64_t option)
>>> +{
>>> + switch (option) {
>>> + case RTE_ETH_BURST_SCALAR: return "Scalar";
>>> + case RTE_ETH_BURST_VECTOR: return "Vector";
>>> +
>>> + case RTE_ETH_BURST_ALTIVEC: return "AltiVec";
>>> + case RTE_ETH_BURST_NEON: return "Neon";
>>> + case RTE_ETH_BURST_SSE: return "SSE";
>>> + case RTE_ETH_BURST_AVX2: return "AVX2";
>>> + case RTE_ETH_BURST_AVX512: return "AVX512";
>>> +
>>> + case RTE_ETH_BURST_SCATTERED: return "Scattered";
>>> + case RTE_ETH_BURST_BULK_ALLOC: return "Bulk Alloc";
>>> + case RTE_ETH_BURST_SIMPLE: return "Simple";
>>> +
>>> + case RTE_ETH_BURST_PER_QUEUE: return "Per Queue";
>>> + }
>>> +
>>> + return "";
>>> +}
>>
>> Hi Haiyue,
>>
>> The string representation of a vector mode is a data, and I think better to keep
>> it separately as an array instead of keeping this information in the function
>> and make the function use that data.
>> So that when new type are added it won't require to update the function itself.
>>
<...>
> Why just put them together ?
>
> static const struct {
> uint64_t option;
> const char *name;
> } rte_burst_option_names[] = {
> { RTE_ETH_BURST_SCALAR, "Scalar" },
> { RTE_ETH_BURST_VECTOR, "Vector" },
>
> { RTE_ETH_BURST_ALTIVEC, "AltiVec" },
> { RTE_ETH_BURST_NEON, "Neon" },
> { RTE_ETH_BURST_SSE, "SSE" },
> { RTE_ETH_BURST_AVX2, "AVX2" },
> { RTE_ETH_BURST_AVX512, "AVX512" },
>
> { RTE_ETH_BURST_SCATTERED, "Scattered" },
> { RTE_ETH_BURST_BULK_ALLOC, "Bulk Alloc" },
> { RTE_ETH_BURST_SIMPLE, "Simple" },
> { RTE_ETH_BURST_PER_QUEUE, "Per Queue" },
> };
>
> const char *
> rte_eth_burst_mode_option_name(uint64_t option)
> {
> const char *name = "";
> unsigned int i;
>
> for (i = 0; i < RTE_DIM(rte_burst_option_names); ++i) {
> if (option == rte_burst_option_names[i].option) {
> name = rte_burst_option_names[i].name;
> break;
> }
> }
>
> return name;
> }
+1, this my intention, thanks.
@@ -871,6 +871,17 @@ Supports Tx queue setup after device started.
* **[provides] rte_eth_dev_info**: ``dev_capa:RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP``.
* **[related] API**: ``rte_eth_dev_info_get()``.
+.. _nic_features_burst_mode_info:
+
+Burst mode info
+---------------
+
+Supports to get Rx/Tx packet burst mode information.
+
+* **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
+* **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``,
+ ``rte_eth_burst_mode_option_name()``.
+
.. _nic_features_other:
Other dev ops not represented by a Feature
@@ -19,6 +19,7 @@ Free Tx mbuf on demand =
Queue start/stop =
Runtime Rx queue setup =
Runtime Tx queue setup =
+Burst mode info =
MTU update =
Jumbo frame =
Scattered Rx =
@@ -83,6 +83,15 @@ New Features
Added support for the ``RTE_ETH_DEV_CLOSE_REMOVE`` flag.
+* **Added RX/TX packet burst mode get API.**
+
+ Added two new functions ``rte_eth_rx_burst_mode_get`` and
+ ``rte_eth_tx_burst_mode_get`` that allow an application
+ to retrieve the mode information about RX/TX packet burst
+ such as Scalar or Vector, and Vector technology like AVX2.
+ Another new function ``rte_eth_burst_mode_option_name`` is
+ provided for burst mode options stringification.
+
* **Updated the Intel ice driver.**
Updated the Intel ice driver with new features and improvements, including:
@@ -4210,6 +4210,77 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
return 0;
}
+int
+rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
+ struct rte_eth_burst_mode *mode)
+{
+ struct rte_eth_dev *dev;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+ if (mode == NULL)
+ return -EINVAL;
+
+ dev = &rte_eth_devices[port_id];
+
+ if (queue_id >= dev->data->nb_rx_queues) {
+ RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
+ return -EINVAL;
+ }
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_burst_mode_get, -ENOTSUP);
+ memset(mode, 0, sizeof(*mode));
+ return eth_err(port_id,
+ dev->dev_ops->rx_burst_mode_get(dev, queue_id, mode));
+}
+
+int
+rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
+ struct rte_eth_burst_mode *mode)
+{
+ struct rte_eth_dev *dev;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+ if (mode == NULL)
+ return -EINVAL;
+
+ dev = &rte_eth_devices[port_id];
+
+ if (queue_id >= dev->data->nb_tx_queues) {
+ RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
+ return -EINVAL;
+ }
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_burst_mode_get, -ENOTSUP);
+ memset(mode, 0, sizeof(*mode));
+ return eth_err(port_id,
+ dev->dev_ops->tx_burst_mode_get(dev, queue_id, mode));
+}
+
+const char *
+rte_eth_burst_mode_option_name(uint64_t option)
+{
+ switch (option) {
+ case RTE_ETH_BURST_SCALAR: return "Scalar";
+ case RTE_ETH_BURST_VECTOR: return "Vector";
+
+ case RTE_ETH_BURST_ALTIVEC: return "AltiVec";
+ case RTE_ETH_BURST_NEON: return "Neon";
+ case RTE_ETH_BURST_SSE: return "SSE";
+ case RTE_ETH_BURST_AVX2: return "AVX2";
+ case RTE_ETH_BURST_AVX512: return "AVX512";
+
+ case RTE_ETH_BURST_SCATTERED: return "Scattered";
+ case RTE_ETH_BURST_BULK_ALLOC: return "Bulk Alloc";
+ case RTE_ETH_BURST_SIMPLE: return "Simple";
+
+ case RTE_ETH_BURST_PER_QUEUE: return "Per Queue";
+ }
+
+ return "";
+}
+
int
rte_eth_dev_set_mc_addr_list(uint16_t port_id,
struct rte_ether_addr *mc_addr_set,
@@ -1214,6 +1214,32 @@ struct rte_eth_txq_info {
uint16_t nb_desc; /**< configured number of TXDs. */
} __rte_cache_min_aligned;
+enum rte_eth_burst_mode_option {
+ RTE_ETH_BURST_SCALAR = (1 << 0),
+ RTE_ETH_BURST_VECTOR = (1 << 1),
+
+ /**< bits[15:2] are reserved for each vector type */
+ RTE_ETH_BURST_ALTIVEC = (1 << 2),
+ RTE_ETH_BURST_NEON = (1 << 3),
+ RTE_ETH_BURST_SSE = (1 << 4),
+ RTE_ETH_BURST_AVX2 = (1 << 5),
+ RTE_ETH_BURST_AVX512 = (1 << 6),
+
+ RTE_ETH_BURST_SCATTERED = (1 << 16), /**< Support scattered packets */
+ RTE_ETH_BURST_BULK_ALLOC = (1 << 17), /**< Support mbuf bulk alloc */
+ RTE_ETH_BURST_SIMPLE = (1 << 18),
+
+ RTE_ETH_BURST_PER_QUEUE = (1 << 19), /**< Support per queue burst */
+};
+
+/**
+ * Ethernet device RX/TX queue packet burst mode information structure.
+ * Used to retrieve information about packet burst mode setting.
+ */
+struct rte_eth_burst_mode {
+ uint64_t options;
+};
+
/** Maximum name length for extended statistics counters */
#define RTE_ETH_XSTATS_NAME_SIZE 64
@@ -3602,6 +3628,62 @@ int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
struct rte_eth_txq_info *qinfo);
+/**
+ * Retrieve information about the Rx packet burst mode.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param queue_id
+ * The Rx queue on the Ethernet device for which information
+ * will be retrieved.
+ * @param mode
+ * A pointer to a structure of type *rte_eth_burst_mode* to be filled
+ * with the information of the packet burst mode.
+ *
+ * @return
+ * - 0: Success
+ * - -ENOTSUP: routine is not supported by the device PMD.
+ * - -EINVAL: The port_id or the queue_id is out of range.
+ */
+__rte_experimental
+int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
+ struct rte_eth_burst_mode *mode);
+
+/**
+ * Retrieve information about the Tx packet burst mode.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param queue_id
+ * The Tx queue on the Ethernet device for which information
+ * will be retrieved.
+ * @param mode
+ * A pointer to a structure of type *rte_eth_burst_mode* to be filled
+ * with the information of the packet burst mode.
+ *
+ * @return
+ * - 0: Success
+ * - -ENOTSUP: routine is not supported by the device PMD.
+ * - -EINVAL: The port_id or the queue_id is out of range.
+ */
+__rte_experimental
+int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
+ struct rte_eth_burst_mode *mode);
+
+/**
+ * Retrieve name about burst mode option.
+ *
+ * @param mode
+ * The burst mode option of type *rte_eth_burst_mode_option*.
+ *
+ * @return
+ * - "": Not found
+ * - "xxx": name of the mode option.
+ */
+__rte_experimental
+const char *
+rte_eth_burst_mode_option_name(uint64_t option);
+
/**
* Retrieve device registers and register attributes (number of registers and
* register size)
@@ -294,6 +294,9 @@ typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
+typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
+ uint16_t queue_id, struct rte_eth_burst_mode *mode);
+
typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
/**< @internal Set MTU. */
@@ -542,6 +545,8 @@ struct eth_dev_ops {
eth_dev_infos_get_t dev_infos_get; /**< Get device info. */
eth_rxq_info_get_t rxq_info_get; /**< retrieve RX queue information. */
eth_txq_info_get_t txq_info_get; /**< retrieve TX queue information. */
+ eth_burst_mode_get_t rx_burst_mode_get; /**< Get RX burst mode */
+ eth_burst_mode_get_t tx_burst_mode_get; /**< Get TX burst mode */
eth_fw_version_get_t fw_version_get; /**< Get firmware version. */
eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
/**< Get packet types supported and identified by device. */
@@ -283,4 +283,9 @@ EXPERIMENTAL {
# added in 19.08
rte_eth_read_clock;
+
+ # added in 19.11
+ rte_eth_rx_burst_mode_get;
+ rte_eth_tx_burst_mode_get;
+ rte_eth_burst_mode_option_name;
};