From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id 51B93C660 for ; Fri, 24 Jun 2016 17:47:29 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id f126so27343846wma.1 for ; Fri, 24 Jun 2016 08:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Knh26hu8RA/BZXb0IVEXXilZj8AvlA1MxCSHnQUkEDI=; b=bvpO48rRRNHxl80Hp/LWABZXo1+OYrSKh8vNbXiuiKLEFgqhzAdlIlrPOGJil+xwhq T1emWp7m1BQ6ogD2AXD+ZXVmmYEZbm71BS5QljXAKgG9n+MSXESfDsjfpk4aT+ODYx3/ AAL8lEHUqcKqg0BAoS94ME0sPrPpkLSfrx+g9rD+S3phFaR+MmZcaFH9G2n0uaZiBK2Z T8eJJ59NYXUngK5G8+A1ubsdcc0zPlBLHQm+9Om2owhWkVGt4Nj1sLN53pGUvQllvkl5 Qzvq2/IRvOqiTAlnFz8XBEFahkGRInN9QRWNovaNw2eZM+39zK04WFy4KDQohMlrBmxf bK5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Knh26hu8RA/BZXb0IVEXXilZj8AvlA1MxCSHnQUkEDI=; b=mS696nEFrZYiQaTEuC6Q2t1uqDI+Aaa6FsyHU6m1mZZQXs2xlA7E5tAtgJSsGayTVa CkIiiKi+FKIIsDkq6NKX3LVBiIjMQ+4cGwZJOkSk946Eg8hyH0CKXijDCJPYV1CaAO23 vum8MbA4VTO/wMH9DFApealQQkPa0k7vlFBJYMGBQ+x38Uay2mq2NStnflK57oAhVk2w vMr/g8F9OSEP3wu0cI+hCiVfamirD8PGpWg0hyNaixmkQDpWYuoI+ITN7nkzkt7UWd+Z azbyCtevKz+hfxG9gJjWbJZ/HBZJ3LKwYTOAfPcFNz1cU0vX8kmKG2WUBILIB1lb3NQG LoUg== X-Gm-Message-State: ALyK8tIh8IE1GsxkH6NlqpLo9vTAeXodvdUYDB4XmEuB3g10TKwmfzX6gz9kT2wBAfWTzFXC X-Received: by 10.194.162.168 with SMTP id yb8mr5007447wjb.32.1466783249039; Fri, 24 Jun 2016 08:47:29 -0700 (PDT) Received: from XPS13.localdomain (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id t188sm3705761wma.8.2016.06.24.08.47.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Jun 2016 08:47:28 -0700 (PDT) From: Thomas Monjalon To: declan.doherty@intel.com, pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org Date: Fri, 24 Jun 2016 17:47:24 +0200 Message-Id: <1466783244-4484-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 Subject: [dpdk-dev] [PATCH] cryptodev: uninline parameter parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2016 15:47:29 -0000 There is no need to have this parsing inlined in the header. It brings kvargs dependency to every crypto drivers. The functions are moved into rte_cryptodev.c. Signed-off-by: Thomas Monjalon --- lib/librte_cryptodev/rte_cryptodev.c | 91 ++++++++++++++++++++++++++++++++++ lib/librte_cryptodev/rte_cryptodev.h | 95 ++---------------------------------- 2 files changed, 95 insertions(+), 91 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index 960e2d5..20e5beb 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -102,6 +102,97 @@ struct rte_cryptodev_callback { uint32_t active; /**< Callback is executing */ }; +#define RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG ("max_nb_queue_pairs") +#define RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG ("max_nb_sessions") +#define RTE_CRYPTODEV_VDEV_SOCKET_ID ("socket_id") + +static const char *cryptodev_vdev_valid_params[] = { + RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG, + RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG, + RTE_CRYPTODEV_VDEV_SOCKET_ID +}; + +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, + const char *value, void *extra_args) +{ + int *i = (int *) extra_args; + + *i = atoi(value); + if (*i < 0) { + CDEV_LOG_ERR("Argument has to be positive."); + return -1; + } + + return 0; +} + +int +rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params, + const char *input_args) +{ + struct rte_kvargs *kvlist; + int ret; + + if (params == NULL) + return -EINVAL; + + if (input_args) { + kvlist = rte_kvargs_parse(input_args, + cryptodev_vdev_valid_params); + if (kvlist == NULL) + return -1; + + ret = rte_kvargs_process(kvlist, + RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG, + &parse_integer_arg, + ¶ms->max_nb_queue_pairs); + if (ret < 0) + goto free_kvlist; + + ret = rte_kvargs_process(kvlist, + RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG, + &parse_integer_arg, + ¶ms->max_nb_sessions); + if (ret < 0) + goto free_kvlist; + + ret = rte_kvargs_process(kvlist, RTE_CRYPTODEV_VDEV_SOCKET_ID, + &parse_integer_arg, + ¶ms->socket_id); + 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"); + goto free_kvlist; + } + } + + return 0; + +free_kvlist: + rte_kvargs_free(kvlist); + return ret; +} const char * rte_cryptodev_get_feature_name(uint64_t flag) diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index 27cf8ef..7768f0a 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -300,48 +300,6 @@ struct rte_crypto_vdev_init_params { uint8_t socket_id; }; -#define RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG ("max_nb_queue_pairs") -#define RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG ("max_nb_sessions") -#define RTE_CRYPTODEV_VDEV_SOCKET_ID ("socket_id") - -static const char *cryptodev_vdev_valid_params[] = { - RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG, - RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG, - RTE_CRYPTODEV_VDEV_SOCKET_ID -}; - -static inline 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 inline int -__rte_cryptodev_parse_integer_arg(const char *key __rte_unused, - const char *value, void *extra_args) -{ - int *i = (int *) extra_args; - - *i = atoi(value); - if (*i < 0) { - CDEV_LOG_ERR("Argument has to be positive."); - return -1; - } - - return 0; -} - /** * Parse virtual device initialisation parameters input arguments * @internal @@ -353,55 +311,10 @@ __rte_cryptodev_parse_integer_arg(const char *key __rte_unused, * 0 on successful parse * <0 on failure to parse */ -static inline int -rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params, - const char *input_args) -{ - struct rte_kvargs *kvlist; - int ret; - - if (params == NULL) - return -EINVAL; - - if (input_args) { - kvlist = rte_kvargs_parse(input_args, - cryptodev_vdev_valid_params); - if (kvlist == NULL) - return -1; - - ret = rte_kvargs_process(kvlist, - RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG, - &__rte_cryptodev_parse_integer_arg, - ¶ms->max_nb_queue_pairs); - if (ret < 0) - goto free_kvlist; - - ret = rte_kvargs_process(kvlist, - RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG, - &__rte_cryptodev_parse_integer_arg, - ¶ms->max_nb_sessions); - if (ret < 0) - goto free_kvlist; - - ret = rte_kvargs_process(kvlist, RTE_CRYPTODEV_VDEV_SOCKET_ID, - &__rte_cryptodev_parse_integer_arg, - ¶ms->socket_id); - 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"); - goto free_kvlist; - } - } - - return 0; - -free_kvlist: - rte_kvargs_free(kvlist); - return ret; -} +int +rte_cryptodev_parse_vdev_init_params( + struct rte_crypto_vdev_init_params *params, + const char *input_args); /** * Create a virtual crypto device -- 2.7.0