[v7,05/14] examples/l3fwd: fix lcore ID restriction

Message ID 20240326125554.138840-6-sivaprasad.tummala@amd.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series fix lcore ID restriction |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Sivaprasad Tummala March 26, 2024, 12:55 p.m. UTC
  Currently the config option allows lcore IDs up to 255,
irrespective of RTE_MAX_LCORES and needs to be fixed.

The patch fixes these constraints by allowing all
lcore IDs up to RTE_MAX_LCORES.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
 examples/l3fwd/main.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
  

Patch

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 039207b06c..47baf464e2 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -99,7 +99,7 @@  struct parm_cfg parm_config;
 struct lcore_params {
 	uint16_t port_id;
 	uint16_t queue_id;
-	uint8_t lcore_id;
+	uint32_t lcore_id;
 } __rte_cache_aligned;
 
 static struct lcore_params lcore_params_array[MAX_LCORE_PARAMS];
@@ -293,7 +293,7 @@  static int
 check_lcore_params(void)
 {
 	uint16_t queue, i;
-	uint8_t lcore;
+	uint32_t lcore;
 	int socketid;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
@@ -304,12 +304,12 @@  check_lcore_params(void)
 		}
 		lcore = lcore_params[i].lcore_id;
 		if (!rte_lcore_is_enabled(lcore)) {
-			printf("error: lcore %hhu is not enabled in lcore mask\n", lcore);
+			printf("error: lcore %u is not enabled in lcore mask\n", lcore);
 			return -1;
 		}
 		if ((socketid = rte_lcore_to_socket_id(lcore) != 0) &&
 			(numa_on == 0)) {
-			printf("warning: lcore %hhu is on socket %d with numa off \n",
+			printf("warning: lcore %u is on socket %d with numa off\n",
 				lcore, socketid);
 		}
 	}
@@ -359,14 +359,14 @@  static int
 init_lcore_rx_queues(void)
 {
 	uint16_t i, nb_rx_queue;
-	uint8_t lcore;
+	uint32_t lcore;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
 		lcore = lcore_params[i].lcore_id;
 		nb_rx_queue = lcore_conf[lcore].n_rx_queue;
 		if (nb_rx_queue >= MAX_RX_QUEUE_PER_LCORE) {
 			printf("error: too many queues (%u) for lcore: %u\n",
-				(unsigned)nb_rx_queue + 1, (unsigned)lcore);
+				(unsigned int)nb_rx_queue + 1, lcore);
 			return -1;
 		} else {
 			lcore_conf[lcore].rx_queue_list[nb_rx_queue].port_id =
@@ -500,7 +500,11 @@  parse_config(const char *q_arg)
 	char *str_fld[_NUM_FLD];
 	int i;
 	unsigned size;
-	uint16_t max_fld[_NUM_FLD] = {255, RTE_MAX_QUEUES_PER_PORT, 255};
+	uint16_t max_fld[_NUM_FLD] = {
+		255,
+		RTE_MAX_QUEUES_PER_PORT,
+		RTE_MAX_LCORE
+	};
 
 	nb_lcore_params = 0;
 
@@ -532,7 +536,7 @@  parse_config(const char *q_arg)
 		lcore_params_array[nb_lcore_params].queue_id =
 			(uint16_t)int_fld[FLD_QUEUE];
 		lcore_params_array[nb_lcore_params].lcore_id =
-			(uint8_t)int_fld[FLD_LCORE];
+			(uint32_t)int_fld[FLD_LCORE];
 		++nb_lcore_params;
 	}
 	lcore_params = lcore_params_array;