[PATCH v3 01/65] net/ring: make numa node signed

Stephen Hemminger stephen at networkplumber.org
Thu Oct 1 00:40:19 CEST 2026


rte_eth_from_rings() takes a numa node (socket) but used unsigned
where int should have been used to allow for SOCKET_ID_ANY.
The only usage is in call rte_malloc routines with socket
and those functions expect int.

Change the parameter to int socket_id and carry that through the two
internal create functions. The devargs path keeps working as before:
"nodeaction=name:-1:CREATE" was already accepted, since strtol()
returned -1 into an unsigned int which became SOCKET_ID_ANY again at
the allocation.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 doc/guides/rel_notes/release_26_11.rst |  6 ++++
 drivers/net/ring/rte_eth_ring.c        | 38 +++++++++++++-------------
 drivers/net/ring/rte_eth_ring.h        | 11 ++++----
 3 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index e027c7a27f..58b0e588ce 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -206,6 +206,12 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* net/ring: The last parameter of ``rte_eth_from_rings`` changed from
+  ``const unsigned numa_node`` to ``int socket_id``, so that
+  ``SOCKET_ID_ANY`` can be passed as it can everywhere else a socket is
+  given. The value was already used as a signed socket id by the memory
+  and ring allocations underneath.
+
 * ethdev: Updated VMDq related API.
 
   * At port configuration time, the number of VMDq pools advertised by a driver
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 4cbdbe3085..533a4c1b6b 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -32,7 +32,7 @@ struct ring_internal_args {
 	const unsigned int nb_rx_queues;
 	struct rte_ring * const *tx_queues;
 	const unsigned int nb_tx_queues;
-	const unsigned int numa_node;
+	int socket_id;
 };
 
 /* rte_eth_from_rings() stashes a pointer to its on-stack args here */
@@ -361,7 +361,7 @@ do_eth_dev_ring_create(const char *name,
 		const unsigned int nb_rx_queues,
 		struct rte_ring *const tx_queues[],
 		const unsigned int nb_tx_queues,
-		const unsigned int numa_node, enum dev_action action,
+		int socket_id, enum dev_action action,
 		struct rte_eth_dev **eth_dev_p)
 {
 	struct rte_eth_dev_data *data = NULL;
@@ -371,24 +371,24 @@ do_eth_dev_ring_create(const char *name,
 	void **tx_queues_local = NULL;
 	unsigned int i;
 
-	PMD_LOG(INFO, "Creating rings-backed ethdev on numa socket %u",
-			numa_node);
+	PMD_LOG(INFO, "Creating rings-backed ethdev on numa socket %d",
+			socket_id);
 
 	rx_queues_local = rte_calloc_socket(name, nb_rx_queues,
-					    sizeof(void *), 0, numa_node);
+					    sizeof(void *), 0, socket_id);
 	if (rx_queues_local == NULL) {
 		rte_errno = ENOMEM;
 		goto error;
 	}
 
 	tx_queues_local = rte_calloc_socket(name, nb_tx_queues,
-					    sizeof(void *), 0, numa_node);
+					    sizeof(void *), 0, socket_id);
 	if (tx_queues_local == NULL) {
 		rte_errno = ENOMEM;
 		goto error;
 	}
 
-	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
+	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
 		rte_errno = ENOMEM;
 		goto error;
@@ -404,7 +404,7 @@ do_eth_dev_ring_create(const char *name,
 	/* now put it all together
 	 * - store EAL device in eth_dev,
 	 * - store queue data in internals,
-	 * - store numa_node info in eth_dev_data
+	 * - store socket id info in eth_dev_data
 	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
@@ -439,7 +439,7 @@ do_eth_dev_ring_create(const char *name,
 	data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
 	eth_dev->dev_ops = &ops;
-	data->numa_node = numa_node;
+	data->numa_node = socket_id;
 
 	/* finally assign rx and tx ops */
 	eth_dev->rx_pkt_burst = eth_ring_rx;
@@ -464,14 +464,14 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned int nb_rx_queues,
 		struct rte_ring *const tx_queues[],
 		const unsigned int nb_tx_queues,
-		const unsigned int numa_node)
+		int socket_id)
 {
 	struct ring_internal_args args = {
 		.rx_queues = rx_queues,
 		.nb_rx_queues = nb_rx_queues,
 		.tx_queues = tx_queues,
 		.nb_tx_queues = nb_tx_queues,
-		.numa_node = numa_node,
+		.socket_id = socket_id,
 	};
 	char ring_name[RTE_RING_NAMESIZE];
 	uint16_t port_id = RTE_MAX_ETHPORTS;
@@ -526,7 +526,7 @@ rte_eth_from_ring(struct rte_ring *r)
 static int
 eth_dev_ring_create(const char *name,
 		struct rte_vdev_device *vdev,
-		const unsigned int numa_node,
+		int socket_id,
 		enum dev_action action, struct rte_eth_dev **eth_dev)
 {
 	/* rx and tx are so-called from point of view of first port.
@@ -549,7 +549,7 @@ eth_dev_ring_create(const char *name,
 		}
 
 		rxtx[i] = (action == DEV_CREATE) ?
-				rte_ring_create(rng_name, 1024, numa_node,
+				rte_ring_create(rng_name, 1024, socket_id,
 						RING_F_SP_ENQ|RING_F_SC_DEQ) :
 				rte_ring_lookup(rng_name);
 		if (rxtx[i] == NULL)
@@ -557,7 +557,7 @@ eth_dev_ring_create(const char *name,
 	}
 
 	if (do_eth_dev_ring_create(name, vdev, rxtx, num_rings, rxtx, num_rings,
-		numa_node, action, eth_dev) < 0)
+		socket_id, action, eth_dev) < 0)
 		return -1;
 
 	return 0;
@@ -565,7 +565,7 @@ eth_dev_ring_create(const char *name,
 
 struct node_action_pair {
 	char name[ETH_RING_ACTION_MAX_LEN];
-	unsigned int node;
+	int socket_id;
 	enum dev_action action;
 };
 
@@ -626,7 +626,7 @@ static int parse_kvlist(const char *key __rte_unused,
 		goto out;
 
 	errno = 0;
-	info->list[info->count].node = strtol(node, &end, 10);
+	info->list[info->count].socket_id = strtol(node, &end, 10);
 
 	if ((errno != 0) || (*end != '\0')) {
 		PMD_LOG(WARNING,
@@ -686,7 +686,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			internal_args->nb_rx_queues,
 			internal_args->tx_queues,
 			internal_args->nb_tx_queues,
-			internal_args->numa_node,
+			internal_args->socket_id,
 			DEV_ATTACH,
 			&eth_dev);
 		return ret >= 0 ? 0 : ret;
@@ -740,7 +740,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 		for (info->count = 0; info->count < info->total; info->count++) {
 			ret = eth_dev_ring_create(info->list[info->count].name,
 						  dev,
-						  info->list[info->count].node,
+						  info->list[info->count].socket_id,
 						  info->list[info->count].action,
 						  &eth_dev);
 			if (ret == -1 && info->list[info->count].action == DEV_CREATE) {
@@ -748,7 +748,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 					"Attach to pmd_ring for %s",
 					name);
 				ret = eth_dev_ring_create(name, dev,
-						info->list[info->count].node,
+						info->list[info->count].socket_id,
 						DEV_ATTACH,
 						&eth_dev);
 			}
diff --git a/drivers/net/ring/rte_eth_ring.h b/drivers/net/ring/rte_eth_ring.h
index 98292c7b33..dfbfce9f2f 100644
--- a/drivers/net/ring/rte_eth_ring.h
+++ b/drivers/net/ring/rte_eth_ring.h
@@ -24,17 +24,18 @@ extern "C" {
  *    pointer to array of rte_rings to be used as TX queues
  * @param nb_tx_queues
  *    number of elements in the tx_queues array
- * @param numa_node
- *    the numa node on which the memory for this port is to be allocated
+ * @param socket_id
+ *    the NUMA socket on which the memory for this port is to be allocated,
+ *    or SOCKET_ID_ANY
  * @return
  *    the port number of the newly created the ethdev or -1 on error.
  */
 int rte_eth_from_rings(const char *name,
 		struct rte_ring * const rx_queues[],
-		const unsigned nb_rx_queues,
+		const unsigned int nb_rx_queues,
 		struct rte_ring *const tx_queues[],
-		const unsigned nb_tx_queues,
-		const unsigned numa_node);
+		const unsigned int nb_tx_queues,
+		int socket_id);
 
 /**
  * Create a new ethdev port from a ring
-- 
2.53.0



More information about the dev mailing list