[PATCH v2 4/6] examples/ipsec-secgw: fix lcore ID restriction

Sivaprasad Tummala sivaprasad.tummala at amd.com
Tue Dec 19 03:56:05 CET 2023


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: d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application")
Cc: sergio.gonzalez.monroy at intel.com
Cc: stable at dpdk.org

Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala at amd.com>
---
 examples/ipsec-secgw/event_helper.h |  2 +-
 examples/ipsec-secgw/ipsec-secgw.c  | 16 +++++++++-------
 examples/ipsec-secgw/ipsec.c        |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/examples/ipsec-secgw/event_helper.h b/examples/ipsec-secgw/event_helper.h
index dfb81bfcf1..9923700f03 100644
--- a/examples/ipsec-secgw/event_helper.h
+++ b/examples/ipsec-secgw/event_helper.h
@@ -102,7 +102,7 @@ struct eh_event_link_info {
 		/**< Event port ID */
 	uint8_t eventq_id;
 		/**< Event queue to be linked to the port */
-	uint8_t lcore_id;
+	uint16_t lcore_id;
 		/**< Lcore to be polling on this port */
 };
 
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index bf98d2618b..6f550db05c 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -221,7 +221,7 @@ static const char *cfgfile;
 struct lcore_params {
 	uint16_t port_id;
 	uint8_t queue_id;
-	uint8_t lcore_id;
+	uint16_t lcore_id;
 } __rte_cache_aligned;
 
 static struct lcore_params lcore_params_array[MAX_LCORE_PARAMS];
@@ -810,7 +810,7 @@ check_flow_params(uint16_t fdir_portid, uint8_t fdir_qid)
 static int32_t
 check_poll_mode_params(struct eh_conf *eh_conf)
 {
-	uint8_t lcore;
+	uint16_t lcore;
 	uint16_t portid;
 	uint16_t i;
 	int32_t socket_id;
@@ -829,13 +829,13 @@ check_poll_mode_params(struct eh_conf *eh_conf)
 	for (i = 0; i < nb_lcore_params; ++i) {
 		lcore = lcore_params[i].lcore_id;
 		if (!rte_lcore_is_enabled(lcore)) {
-			printf("error: lcore %hhu is not enabled in "
+			printf("error: lcore %hu is not enabled in "
 				"lcore mask\n", lcore);
 			return -1;
 		}
 		socket_id = rte_lcore_to_socket_id(lcore);
 		if (socket_id != 0 && numa_on == 0) {
-			printf("warning: lcore %hhu is on socket %d "
+			printf("warning: lcore %hu is on socket %d "
 				"with numa off\n",
 				lcore, socket_id);
 		}
@@ -870,7 +870,7 @@ static int32_t
 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;
@@ -1051,6 +1051,8 @@ parse_config(const char *q_arg)
 	char *str_fld[_NUM_FLD];
 	int32_t i;
 	uint32_t size;
+	unsigned int max_fld[_NUM_FLD] = {RTE_MAX_ETHPORTS,
+					255, RTE_MAX_LCORE};
 
 	nb_lcore_params = 0;
 
@@ -1071,7 +1073,7 @@ parse_config(const char *q_arg)
 		for (i = 0; i < _NUM_FLD; i++) {
 			errno = 0;
 			int_fld[i] = strtoul(str_fld[i], &end, 0);
-			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
+			if (errno != 0 || end == str_fld[i] || int_fld[i] > max_fld[i])
 				return -1;
 		}
 		if (nb_lcore_params >= MAX_LCORE_PARAMS) {
@@ -1084,7 +1086,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/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index f5cec4a928..5ebb71bb9a 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -259,7 +259,7 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[],
 			continue;
 
 		/* Looking for cryptodev, which can handle this SA */
-		key.lcore_id = (uint8_t)lcore_id;
+		key.lcore_id = (uint16_t)lcore_id;
 		key.cipher_algo = (uint8_t)sa->cipher_algo;
 		key.auth_algo = (uint8_t)sa->auth_algo;
 		key.aead_algo = (uint8_t)sa->aead_algo;
-- 
2.25.1



More information about the stable mailing list