[v7,08/14] examples/ipsec-secgw: fix lcore ID restriction

Message ID 20240326125554.138840-9-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. Also the queue
IDs are increased to support up to 65535.

Fixes: d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application")
Cc: sergio.gonzalez.monroy@intel.com
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/ipsec-secgw/event_helper.h |  2 +-
 examples/ipsec-secgw/ipsec-secgw.c  | 21 +++++++++++++--------
 examples/ipsec-secgw/ipsec.c        |  2 +-
 examples/ipsec-secgw/ipsec.h        |  4 ++--
 4 files changed, 17 insertions(+), 12 deletions(-)
  

Patch

diff --git a/examples/ipsec-secgw/event_helper.h b/examples/ipsec-secgw/event_helper.h
index dfb81bfcf1..be635685b4 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;
+	uint32_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 782535f4b5..2d004d82fd 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;
 	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];
@@ -807,7 +807,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;
+	uint32_t lcore;
 	uint16_t portid;
 	uint16_t i;
 	int32_t socket_id;
@@ -826,13 +826,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 %u 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 %u is on socket %d "
 				"with numa off\n",
 				lcore, socket_id);
 		}
@@ -867,7 +867,7 @@  static int32_t
 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;
@@ -1048,7 +1048,11 @@  parse_config(const char *q_arg)
 	char *str_fld[_NUM_FLD];
 	int32_t i;
 	uint32_t size;
-	uint32_t max_fld[_NUM_FLD] = {255, RTE_MAX_QUEUES_PER_PORT, 255};
+	uint32_t max_fld[_NUM_FLD] = {
+		255,
+		RTE_MAX_QUEUES_PER_PORT,
+		RTE_MAX_LCORE
+	};
 
 	nb_lcore_params = 0;
 
@@ -1082,7 +1086,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;
@@ -1918,7 +1922,8 @@  port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads,
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_txconf *txconf;
 	uint16_t nb_tx_queue, nb_rx_queue;
-	uint16_t tx_queueid, rx_queueid, queue, lcore_id;
+	uint16_t tx_queueid, rx_queueid, queue;
+	uint32_t lcore_id;
 	int32_t ret, socket_id;
 	struct lcore_conf *qconf;
 	struct rte_ether_addr ethaddr;
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index c321108119..b52b0ffc3d 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 = 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;
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index 29b9b283f0..6526a80d81 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -256,11 +256,11 @@  extern struct offloads tx_offloads;
  * (hash key calculation reads 8 bytes if this struct is size 5 bytes).
  */
 struct cdev_key {
-	uint16_t lcore_id;
+	uint32_t lcore_id;
 	uint8_t cipher_algo;
 	uint8_t auth_algo;
 	uint8_t aead_algo;
-	uint8_t padding[3]; /* padding to 8-byte size should be zeroed */
+	uint8_t padding; /* padding to 8-byte size should be zeroed */
 };
 
 struct socket_ctx {