From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id C744F37B7 for ; Wed, 21 Jun 2017 09:26:16 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 21 Jun 2017 00:26:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,368,1493708400"; d="scan'208";a="101899266" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by orsmga002.jf.intel.com with ESMTP; 21 Jun 2017 00:26:15 -0700 From: Pablo de Lara To: thomas@monjalon.net, declan.doherty@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Wed, 21 Jun 2017 00:25:53 +0100 Message-Id: <20170620232555.82244-4-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170620232555.82244-1-pablo.de.lara.guarch@intel.com> References: <20170620232555.82244-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH 3/5] crypto/scheduler: check if socket id has memory X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 07:26:17 -0000 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 --- drivers/crypto/scheduler/scheduler_pmd.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c index 0b63c20..e2b0aa7 100644 --- a/drivers/crypto/scheduler/scheduler_pmd.c +++ b/drivers/crypto/scheduler/scheduler_pmd.c @@ -219,22 +219,6 @@ cryptodev_scheduler_remove(struct rte_vdev_device *vdev) return 0; } -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, @@ -391,9 +375,10 @@ scheduler_parse_init_params(struct scheduler_init_params *params, if (ret < 0) goto free_kvlist; - if (params->def_p.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->def_p.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