[dpdk-dev] [PATCH 2/5] cryptodev: check if socket id has memory
Pablo de Lara
pablo.de.lara.guarch at intel.com
Wed Jun 21 01:25:52 CEST 2017
Use new function to check if socket id has reserved memory,
instead of implementing a local function that checks
total number of sockets, to verify if selected socket id
is beyond the range of sockets.
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch at intel.com>
---
lib/librte_cryptodev/rte_cryptodev.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index b65cd9c..20dcaf2 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -233,22 +233,6 @@ rte_crypto_auth_operation_strings[] = {
[RTE_CRYPTO_AUTH_OP_GENERATE] = "generate"
};
-static uint8_t
-number_of_sockets(void)
-{
- int sockets = 0;
- int i;
- const struct rte_memseg *ms = rte_eal_get_physmem_layout();
-
- for (i = 0; ((i < RTE_MAX_MEMSEG) && (ms[i].addr != NULL)); i++) {
- if (sockets < ms[i].socket_id)
- sockets = ms[i].socket_id;
- }
-
- /* Number of sockets = maximum socket_id + 1 */
- return ++sockets;
-}
-
/** Parse integer from integer argument */
static int
parse_integer_arg(const char *key __rte_unused,
@@ -326,9 +310,10 @@ rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
if (ret < 0)
goto free_kvlist;
- if (params->socket_id >= number_of_sockets()) {
- CDEV_LOG_ERR("Invalid socket id specified to create "
- "the virtual crypto device on");
+ if (!rte_eal_has_memory_socket(params->socket_id)) {
+ CDEV_LOG_ERR("Socket ID specified to create the "
+ "the virtual crypto device on does not have "
+ "available memory");
goto free_kvlist;
}
}
--
2.9.4
More information about the dev
mailing list