[v2,2/6] examples/l3fwd-power: fix lcore ID restriction

Message ID 20231219032826.4814-3-sivaprasad.tummala@amd.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series fix lcore ID restriction |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Sivaprasad Tummala Dec. 19, 2023, 3:28 a.m. UTC
  Currently the config option allows lcore IDs up to 255,
irrespective of RTE_MAX_LCORES and needs to be fixed.

The patch allows config options based on DPDK config.

Fixes: f88e7c175a68 ("examples/l3fwd-power: add high/regular perf cores options")
Cc: radu.nicolau@intel.com
Cc: stable@dpdk.org

Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
---
 examples/l3fwd-power/main.c | 16 +++++++++-------
 examples/l3fwd-power/main.h |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)
  

Patch

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index f4adcf41b5..bb9da36455 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -1399,8 +1399,8 @@  main_legacy_loop(__rte_unused void *dummy)
 static int
 check_lcore_params(void)
 {
-	uint8_t queue, lcore;
-	uint16_t i;
+	uint8_t queue;
+	uint16_t lcore, i;
 	int socketid;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
@@ -1411,13 +1411,13 @@  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 "
+			printf("error: lcore %hu 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 "
+			printf("warning: lcore %hu is on socket %d with numa "
 						"off\n", lcore, socketid);
 		}
 		if (app_mode == APP_MODE_TELEMETRY && lcore == rte_lcore_id()) {
@@ -1469,7 +1469,7 @@  static int
 init_lcore_rx_queues(void)
 {
 	uint16_t i, nb_rx_queue;
-	uint8_t lcore;
+	uint16_t lcore;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
 		lcore = lcore_params[i].lcore_id;
@@ -1661,6 +1661,8 @@  parse_config(const char *q_arg)
 	char *str_fld[_NUM_FLD];
 	int i;
 	unsigned size;
+	unsigned int max_fld[_NUM_FLD] = {RTE_MAX_ETHPORTS,
+					255, RTE_MAX_LCORE};
 
 	nb_lcore_params = 0;
 
@@ -1681,7 +1683,7 @@  parse_config(const char *q_arg)
 			errno = 0;
 			int_fld[i] = strtoul(str_fld[i], &end, 0);
 			if (errno != 0 || end == str_fld[i] || int_fld[i] >
-									255)
+									max_fld[i])
 				return -1;
 		}
 		if (nb_lcore_params >= MAX_LCORE_PARAMS) {
@@ -1694,7 +1696,7 @@  parse_config(const char *q_arg)
 		lcore_params_array[nb_lcore_params].queue_id =
 				(uint8_t)int_fld[FLD_QUEUE];
 		lcore_params_array[nb_lcore_params].lcore_id =
-				(uint8_t)int_fld[FLD_LCORE];
+				(uint16_t)int_fld[FLD_LCORE];
 		++nb_lcore_params;
 	}
 	lcore_params = lcore_params_array;
diff --git a/examples/l3fwd-power/main.h b/examples/l3fwd-power/main.h
index 258de98f5b..4e5fd3b6d6 100644
--- a/examples/l3fwd-power/main.h
+++ b/examples/l3fwd-power/main.h
@@ -10,7 +10,7 @@ 
 struct lcore_params {
 	uint16_t port_id;
 	uint8_t queue_id;
-	uint8_t lcore_id;
+	uint16_t lcore_id;
 } __rte_cache_aligned;
 
 extern struct lcore_params *lcore_params;