[v4,04/16] net/ark: switch Rx timestamp to dynamic mbuf field
Checks
Commit Message
The mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field.
The related dynamic mbuf flag is set, although was missing previously.
The timestamp is set if configured for at least one device.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: David Marchand <david.marchand@redhat.com>
---
drivers/net/ark/ark_ethdev.c | 16 ++++++++++++++++
drivers/net/ark/ark_ethdev_rx.c | 7 ++++++-
drivers/net/ark/ark_ethdev_rx.h | 2 ++
3 files changed, 24 insertions(+), 1 deletion(-)
Comments
On 11/3/20 3:21 PM, Thomas Monjalon wrote:
> The mbuf timestamp is moved to a dynamic field
> in order to allow removal of the deprecated static field.
> The related dynamic mbuf flag is set, although was missing previously.
>
> The timestamp is set if configured for at least one device.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: David Marchand <david.marchand@redhat.com>
Just one minor comment below
> ---
> drivers/net/ark/ark_ethdev.c | 16 ++++++++++++++++
> drivers/net/ark/ark_ethdev_rx.c | 7 ++++++-
> drivers/net/ark/ark_ethdev_rx.h | 2 ++
> 3 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
> index fa343999a1..a34dcc5291 100644
> --- a/drivers/net/ark/ark_ethdev.c
> +++ b/drivers/net/ark/ark_ethdev.c
> @@ -79,6 +79,8 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
> #define ARK_TX_MAX_QUEUE (4096 * 4)
> #define ARK_TX_MIN_QUEUE (256)
>
> +uint64_t ark_timestamp_rx_dynflag;
> +int ark_timestamp_dynfield_offset = -1;
> int rte_pmd_ark_rx_userdata_dynfield_offset = -1;
> int rte_pmd_ark_tx_userdata_dynfield_offset = -1;
It is a bit confusing that naming above differs so much and
put in the same block without empty lines in between.
I guess the reason is export/no-export. May be it would
be useful to highlight it in a comment.
03/11/2020 13:37, Andrew Rybchenko:
> On 11/3/20 3:21 PM, Thomas Monjalon wrote:
> > --- a/drivers/net/ark/ark_ethdev.c
> > +++ b/drivers/net/ark/ark_ethdev.c
> > +uint64_t ark_timestamp_rx_dynflag;
> > +int ark_timestamp_dynfield_offset = -1;
> > int rte_pmd_ark_rx_userdata_dynfield_offset = -1;
> > int rte_pmd_ark_tx_userdata_dynfield_offset = -1;
>
> It is a bit confusing that naming above differs so much and
> put in the same block without empty lines in between.
> I guess the reason is export/no-export. May be it would
> be useful to highlight it in a comment.
I can add a blank line.
Not sure it is worth an out of scope comment to explain
that "rte_pmd_" prefixed variables are for the PMD-specific API.
@@ -79,6 +79,8 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
#define ARK_TX_MAX_QUEUE (4096 * 4)
#define ARK_TX_MIN_QUEUE (256)
+uint64_t ark_timestamp_rx_dynflag;
+int ark_timestamp_dynfield_offset = -1;
int rte_pmd_ark_rx_userdata_dynfield_offset = -1;
int rte_pmd_ark_tx_userdata_dynfield_offset = -1;
@@ -552,6 +554,18 @@ static int
eth_ark_dev_configure(struct rte_eth_dev *dev)
{
struct ark_adapter *ark = dev->data->dev_private;
+ int ret;
+
+ if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_TIMESTAMP) {
+ ret = rte_mbuf_dyn_rx_timestamp_register(
+ &ark_timestamp_dynfield_offset,
+ &ark_timestamp_rx_dynflag);
+ if (ret != 0) {
+ ARK_PMD_LOG(ERR,
+ "Failed to register Rx timestamp field/flag\n");
+ return -rte_errno;
+ }
+ }
eth_ark_dev_set_link_up(dev);
if (ark->user_ext.dev_configure)
@@ -782,6 +796,8 @@ eth_ark_dev_info_get(struct rte_eth_dev *dev,
ETH_LINK_SPEED_50G |
ETH_LINK_SPEED_100G);
+ dev_info->rx_offload_capa = DEV_RX_OFFLOAD_TIMESTAMP;
+
return 0;
}
@@ -272,7 +272,12 @@ eth_ark_recv_pkts(void *rx_queue,
mbuf->port = meta->port;
mbuf->pkt_len = meta->pkt_len;
mbuf->data_len = meta->pkt_len;
- mbuf->timestamp = meta->timestamp;
+ /* set timestamp if enabled at least on one device */
+ if (ark_timestamp_rx_dynflag > 0) {
+ *RTE_MBUF_DYNFIELD(mbuf, ark_timestamp_dynfield_offset,
+ rte_mbuf_timestamp_t *) = meta->timestamp;
+ mbuf->ol_flags |= ark_timestamp_rx_dynflag;
+ }
rte_pmd_ark_mbuf_rx_userdata_set(mbuf, meta->user_data);
if (ARK_DEBUG_CORE) { /* debug sanity checks */
@@ -11,6 +11,8 @@
#include <rte_mempool.h>
#include <rte_ethdev_driver.h>
+extern uint64_t ark_timestamp_rx_dynflag;
+extern int ark_timestamp_dynfield_offset;
int eth_ark_dev_rx_queue_setup(struct rte_eth_dev *dev,
uint16_t queue_idx,