* [PATCH v2 1/4] net/af_xdp: fix port ID not set in Rx mbuf
2024-05-14 8:41 [PATCH v2 0/4] AF_XDP PMD Bugfixes Ciara Loftus
@ 2024-05-14 8:41 ` Ciara Loftus
2024-05-14 8:41 ` [PATCH v2 2/4] net/af_xdp: fix mbuf alloc failed statistic Ciara Loftus
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Ciara Loftus @ 2024-05-14 8:41 UTC (permalink / raw)
To: dev; +Cc: Ciara Loftus, stable, Stephen Hemminger, Maryam Tahhan
Record the port id in the af_xdp rx queue structure and use it
to set the port id of the mbuf of a received packed.
Bugzilla ID: 1428
Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
cc: stable@dpdk.org
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Acked-by: Maryam Tahhan <mtahhan@redhat.com>
---
v2:
* Fixed typo in commit message
drivers/net/af_xdp/rte_eth_af_xdp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 268a130c49..fee0d5d5f3 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -131,6 +131,7 @@ struct pkt_rx_queue {
struct xsk_umem_info *umem;
struct xsk_socket *xsk;
struct rte_mempool *mb_pool;
+ uint16_t port;
struct rx_stats stats;
@@ -360,6 +361,7 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
bufs[i]->data_off = offset - sizeof(struct rte_mbuf) -
rte_pktmbuf_priv_size(umem->mb_pool) -
umem->mb_pool->header_size;
+ bufs[i]->port = rxq->port;
rte_pktmbuf_pkt_len(bufs[i]) = len;
rte_pktmbuf_data_len(bufs[i]) = len;
@@ -426,6 +428,7 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
rte_pktmbuf_data_len(mbufs[i]) = len;
rx_bytes += len;
bufs[i] = mbufs[i];
+ bufs[i]->port = rxq->port;
}
xsk_ring_cons__release(rx, nb_pkts);
@@ -1779,6 +1782,8 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,
process_private->rxq_xsk_fds[rx_queue_id] = rxq->fds[0].fd;
+ rxq->port = dev->data->port_id;
+
dev->data->rx_queues[rx_queue_id] = rxq;
return 0;
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/4] net/af_xdp: fix mbuf alloc failed statistic
2024-05-14 8:41 [PATCH v2 0/4] AF_XDP PMD Bugfixes Ciara Loftus
2024-05-14 8:41 ` [PATCH v2 1/4] net/af_xdp: fix port ID not set in Rx mbuf Ciara Loftus
@ 2024-05-14 8:41 ` Ciara Loftus
2024-05-14 8:41 ` [PATCH v2 3/4] net/af_xdp: fix stats reset Ciara Loftus
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Ciara Loftus @ 2024-05-14 8:41 UTC (permalink / raw)
To: dev; +Cc: Ciara Loftus, stable, Stephen Hemminger
Failures to allocate mbufs in the receive path were not being
accounted for in the ethdev statistics. Fix this.
Bugzilla ID: 1429
Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
cc: stable@dpdk.org
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
v2:
* Fixed typo in commit message
* Remove unnecessary local stat for alloc_failed
drivers/net/af_xdp/rte_eth_af_xdp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index fee0d5d5f3..9bcf971ae5 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -312,6 +312,7 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
unsigned long rx_bytes = 0;
int i;
struct rte_mbuf *fq_bufs[ETH_AF_XDP_RX_BATCH_SIZE];
+ struct rte_eth_dev *dev = &rte_eth_devices[rxq->port];
nb_pkts = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx);
@@ -339,6 +340,8 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
* xsk_ring_cons__peek
*/
rx->cached_cons -= nb_pkts;
+ dev->data->rx_mbuf_alloc_failed += nb_pkts;
+
return 0;
}
@@ -390,6 +393,7 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
int i;
uint32_t free_thresh = fq->size >> 1;
struct rte_mbuf *mbufs[ETH_AF_XDP_RX_BATCH_SIZE];
+ struct rte_eth_dev *dev = &rte_eth_devices[rxq->port];
if (xsk_prod_nb_free(fq, free_thresh) >= free_thresh)
(void)reserve_fill_queue(umem, nb_pkts, NULL, fq);
@@ -408,6 +412,7 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
* xsk_ring_cons__peek
*/
rx->cached_cons -= nb_pkts;
+ dev->data->rx_mbuf_alloc_failed += nb_pkts;
return 0;
}
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/4] net/af_xdp: fix stats reset
2024-05-14 8:41 [PATCH v2 0/4] AF_XDP PMD Bugfixes Ciara Loftus
2024-05-14 8:41 ` [PATCH v2 1/4] net/af_xdp: fix port ID not set in Rx mbuf Ciara Loftus
2024-05-14 8:41 ` [PATCH v2 2/4] net/af_xdp: fix mbuf alloc failed statistic Ciara Loftus
@ 2024-05-14 8:41 ` Ciara Loftus
2024-05-20 23:27 ` Ferruh Yigit
2024-05-14 8:41 ` [PATCH v2 4/4] net/af_xdp: remove unused local statistic Ciara Loftus
` (2 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Ciara Loftus @ 2024-05-14 8:41 UTC (permalink / raw)
To: dev; +Cc: Ciara Loftus, stable, Stephen Hemminger, Maryam Tahhan
The imissed statistic was not properly reset because it was
read directly from the kernel statistics. To fix this, take note
of the kernel statistic when the stats are reset and deduct this
value from the kernel statistic read during statistics get.
Bugzilla ID: 1430
Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
cc: stable@dpdk.org
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Acked-by: Maryam Tahhan <mtahhan@redhat.com>
---
v2:
* Removed whitespace in rx_stats struct
* Fixed typo in commit message
drivers/net/af_xdp/rte_eth_af_xdp.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 9bcf971ae5..193e3576bc 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -124,6 +124,7 @@ struct rx_stats {
uint64_t rx_pkts;
uint64_t rx_bytes;
uint64_t rx_dropped;
+ uint64_t imissed_offset;
};
struct pkt_rx_queue {
@@ -884,7 +885,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
AF_XDP_LOG(ERR, "getsockopt() failed for XDP_STATISTICS.\n");
return -1;
}
- stats->imissed += xdp_stats.rx_dropped;
+ stats->imissed +=
+ (xdp_stats.rx_dropped - internals->rx_queues[i].stats.imissed_offset);
stats->opackets += stats->q_opackets[i];
stats->obytes += stats->q_obytes[i];
@@ -897,13 +899,25 @@ static int
eth_stats_reset(struct rte_eth_dev *dev)
{
struct pmd_internals *internals = dev->data->dev_private;
- int i;
+ struct pmd_process_private *process_private = dev->process_private;
+ struct xdp_statistics xdp_stats;
+ socklen_t optlen;
+ int i, ret, fd;
for (i = 0; i < internals->queue_cnt; i++) {
memset(&internals->rx_queues[i].stats, 0,
sizeof(struct rx_stats));
memset(&internals->tx_queues[i].stats, 0,
sizeof(struct tx_stats));
+ fd = process_private->rxq_xsk_fds[i];
+ optlen = sizeof(struct xdp_statistics);
+ ret = fd >= 0 ? getsockopt(fd, SOL_XDP, XDP_STATISTICS,
+ &xdp_stats, &optlen) : -1;
+ if (ret != 0) {
+ AF_XDP_LOG(ERR, "getsockopt() failed for XDP_STATISTICS.\n");
+ return -1;
+ }
+ internals->rx_queues[i].stats.imissed_offset = xdp_stats.rx_dropped;
}
return 0;
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/4] net/af_xdp: fix stats reset
2024-05-14 8:41 ` [PATCH v2 3/4] net/af_xdp: fix stats reset Ciara Loftus
@ 2024-05-20 23:27 ` Ferruh Yigit
0 siblings, 0 replies; 9+ messages in thread
From: Ferruh Yigit @ 2024-05-20 23:27 UTC (permalink / raw)
To: Ciara Loftus, dev; +Cc: stable, Stephen Hemminger, Maryam Tahhan
On 5/14/2024 9:41 AM, Ciara Loftus wrote:
> The imissed statistic was not properly reset because it was
> read directly from the kernel statistics. To fix this, take note
> of the kernel statistic when the stats are reset and deduct this
> value from the kernel statistic read during statistics get.
>
> Bugzilla ID: 1430
> Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
> cc: stable@dpdk.org
>
> Reported-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> Acked-by: Maryam Tahhan <mtahhan@redhat.com>
> ---
> v2:
> * Removed whitespace in rx_stats struct
> * Fixed typo in commit message
>
> drivers/net/af_xdp/rte_eth_af_xdp.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 9bcf971ae5..193e3576bc 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -124,6 +124,7 @@ struct rx_stats {
> uint64_t rx_pkts;
> uint64_t rx_bytes;
> uint64_t rx_dropped;
> + uint64_t imissed_offset;
> };
>
> struct pkt_rx_queue {
> @@ -884,7 +885,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
> AF_XDP_LOG(ERR, "getsockopt() failed for XDP_STATISTICS.\n");
> return -1;
> }
> - stats->imissed += xdp_stats.rx_dropped;
> + stats->imissed +=
> + (xdp_stats.rx_dropped - internals->rx_queues[i].stats.imissed_offset);
>
why not use 'rxq', like "rxq->stats.imissed_offset"?
I can update while merging if you are OK.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 4/4] net/af_xdp: remove unused local statistic
2024-05-14 8:41 [PATCH v2 0/4] AF_XDP PMD Bugfixes Ciara Loftus
` (2 preceding siblings ...)
2024-05-14 8:41 ` [PATCH v2 3/4] net/af_xdp: fix stats reset Ciara Loftus
@ 2024-05-14 8:41 ` Ciara Loftus
2024-05-14 15:34 ` [PATCH v2 0/4] AF_XDP PMD Bugfixes Stephen Hemminger
2024-05-20 22:25 ` Ferruh Yigit
5 siblings, 0 replies; 9+ messages in thread
From: Ciara Loftus @ 2024-05-14 8:41 UTC (permalink / raw)
To: dev; +Cc: Ciara Loftus, stable, Stephen Hemminger
The rx_dropped statistic is never incremented so its existence
is pointless. Remove it.
Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
cc: stable@dpdk.org
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
drivers/net/af_xdp/rte_eth_af_xdp.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 193e3576bc..16b92ae775 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -123,7 +123,6 @@ struct xsk_umem_info {
struct rx_stats {
uint64_t rx_pkts;
uint64_t rx_bytes;
- uint64_t rx_dropped;
uint64_t imissed_offset;
};
@@ -876,7 +875,6 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
stats->ipackets += stats->q_ipackets[i];
stats->ibytes += stats->q_ibytes[i];
- stats->imissed += rxq->stats.rx_dropped;
stats->oerrors += txq->stats.tx_dropped;
fd = process_private->rxq_xsk_fds[i];
ret = fd >= 0 ? getsockopt(fd, SOL_XDP, XDP_STATISTICS,
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/4] AF_XDP PMD Bugfixes
2024-05-14 8:41 [PATCH v2 0/4] AF_XDP PMD Bugfixes Ciara Loftus
` (3 preceding siblings ...)
2024-05-14 8:41 ` [PATCH v2 4/4] net/af_xdp: remove unused local statistic Ciara Loftus
@ 2024-05-14 15:34 ` Stephen Hemminger
2024-05-21 11:12 ` Ferruh Yigit
2024-05-20 22:25 ` Ferruh Yigit
5 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2024-05-14 15:34 UTC (permalink / raw)
To: Ciara Loftus; +Cc: dev
On Tue, 14 May 2024 08:41:51 +0000
Ciara Loftus <ciara.loftus@intel.com> wrote:
> Series of fixes for the AF_XDP PMD.
>
> Ciara Loftus (4):
> net/af_xdp: fix port ID not set in Rx mbuf
> net/af_xdp: fix mbuf alloc failed statistic
> net/af_xdp: fix stats reset
> net/af_xdp: remove unused local statistic
>
> drivers/net/af_xdp/rte_eth_af_xdp.c | 30 +++++++++++++++++++++++++----
> 1 file changed, 26 insertions(+), 4 deletions(-)
>
Series-Acked-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/4] AF_XDP PMD Bugfixes
2024-05-14 15:34 ` [PATCH v2 0/4] AF_XDP PMD Bugfixes Stephen Hemminger
@ 2024-05-21 11:12 ` Ferruh Yigit
0 siblings, 0 replies; 9+ messages in thread
From: Ferruh Yigit @ 2024-05-21 11:12 UTC (permalink / raw)
To: Stephen Hemminger, Ciara Loftus; +Cc: dev
On 5/14/2024 4:34 PM, Stephen Hemminger wrote:
> On Tue, 14 May 2024 08:41:51 +0000
> Ciara Loftus <ciara.loftus@intel.com> wrote:
>
>> Series of fixes for the AF_XDP PMD.
>>
>> Ciara Loftus (4):
>> net/af_xdp: fix port ID not set in Rx mbuf
>> net/af_xdp: fix mbuf alloc failed statistic
>> net/af_xdp: fix stats reset
>> net/af_xdp: remove unused local statistic
>>
>> drivers/net/af_xdp/rte_eth_af_xdp.c | 30 +++++++++++++++++++++++++----
>> 1 file changed, 26 insertions(+), 4 deletions(-)
>>
>
>
> Series-Acked-by: Stephen Hemminger <stephen@networkplumber.org>
>
Series applied to dpdk-next-net/main, thanks.
(3/4 updated slightly as commented to that patch)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/4] AF_XDP PMD Bugfixes
2024-05-14 8:41 [PATCH v2 0/4] AF_XDP PMD Bugfixes Ciara Loftus
` (4 preceding siblings ...)
2024-05-14 15:34 ` [PATCH v2 0/4] AF_XDP PMD Bugfixes Stephen Hemminger
@ 2024-05-20 22:25 ` Ferruh Yigit
5 siblings, 0 replies; 9+ messages in thread
From: Ferruh Yigit @ 2024-05-20 22:25 UTC (permalink / raw)
To: Ciara Loftus, dev
On 5/14/2024 9:41 AM, Ciara Loftus wrote:
> Series of fixes for the AF_XDP PMD.
>
> Ciara Loftus (4):
> net/af_xdp: fix port ID not set in Rx mbuf
> net/af_xdp: fix mbuf alloc failed statistic
> net/af_xdp: fix stats reset
> net/af_xdp: remove unused local statistic
>
> drivers/net/af_xdp/rte_eth_af_xdp.c | 30 +++++++++++++++++++++++++----
> 1 file changed, 26 insertions(+), 4 deletions(-)
>
Recheck-request: iol-unit-amd64-testing
^ permalink raw reply [flat|nested] 9+ messages in thread