DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>, Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>
Subject: [PATCH] net/ring: Set mbuf->port for received packets
Date: Tue, 18 Jun 2024 15:47:00 +0200	[thread overview]
Message-ID: <20240618134700.3709388-1-sriram.yagnaraman@ericsson.com> (raw)

When using ring based ethdev, mbuf->port is not set on received packets.

For applications that use the mbuf->port to identify the incoming port,
especially when eventdev RX adapter pulls the packet on a different core
and the application running on a worker core has no clue on the incoming
port. This change adds some cycles at receive, to set the port of course.

Please advise if this change is something that can be upstreamed.

Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>
---
 drivers/net/ring/rte_eth_ring.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index b16f5d55f2..1346a0dba3 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -44,6 +44,7 @@ enum dev_action {
 
 struct ring_queue {
 	struct rte_ring *rng;
+	uint16_t in_port;
 	RTE_ATOMIC(uint64_t) rx_pkts;
 	RTE_ATOMIC(uint64_t) tx_pkts;
 };
@@ -75,10 +76,13 @@ RTE_LOG_REGISTER_DEFAULT(eth_ring_logtype, NOTICE);
 static uint16_t
 eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
+	unsigned int i;
 	void **ptrs = (void *)&bufs[0];
 	struct ring_queue *r = q;
 	const uint16_t nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng,
 			ptrs, nb_bufs, NULL);
+	for (i = 0; i < nb_rx; i++)
+		bufs[i]->port = r->in_port;
 	if (r->rng->flags & RING_F_SC_DEQ)
 		r->rx_pkts += nb_rx;
 	else
@@ -155,7 +159,7 @@ eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 				    struct rte_mempool *mb_pool __rte_unused)
 {
 	struct pmd_internals *internals = dev->data->dev_private;
-
+	internals->rx_ring_queues[rx_queue_id].in_port = dev->data->port_id;
 	dev->data->rx_queues[rx_queue_id] = &internals->rx_ring_queues[rx_queue_id];
 	return 0;
 }
@@ -414,10 +418,12 @@ do_eth_dev_ring_create(const char *name,
 	internals->max_tx_queues = nb_tx_queues;
 	for (i = 0; i < nb_rx_queues; i++) {
 		internals->rx_ring_queues[i].rng = rx_queues[i];
+		internals->rx_ring_queues[i].in_port = -1;
 		data->rx_queues[i] = &internals->rx_ring_queues[i];
 	}
 	for (i = 0; i < nb_tx_queues; i++) {
 		internals->tx_ring_queues[i].rng = tx_queues[i];
+		internals->tx_ring_queues[i].in_port = -1;
 		data->tx_queues[i] = &internals->tx_ring_queues[i];
 	}
 
-- 
2.31.1


             reply	other threads:[~2024-06-18 14:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18 13:47 Sriram Yagnaraman [this message]
2024-06-18 16:00 ` Morten Brørup
2024-06-18 19:14   ` Sriram Yagnaraman
2024-06-19  6:48     ` Morten Brørup
2024-07-06  3:40       ` Ferruh Yigit
2024-07-06  3:40     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240618134700.3709388-1-sriram.yagnaraman@ericsson.com \
    --to=sriram.yagnaraman@ericsson.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).