From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id EBDC93256 for ; Wed, 21 Jun 2017 15:07:31 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2017 06:07:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,369,1493708400"; d="scan'208";a="870269127" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by FMSMGA003.fm.intel.com with ESMTP; 21 Jun 2017 06:07:24 -0700 From: Pablo de Lara To: declan.doherty@intel.com, thomas@monjalon.net Cc: dev@dpdk.org, Pablo de Lara Date: Wed, 21 Jun 2017 06:07:32 +0100 Message-Id: <20170621050733.88850-4-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170621050733.88850-1-pablo.de.lara.guarch@intel.com> References: <20170620232555.82244-1-pablo.de.lara.guarch@intel.com> <20170621050733.88850-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 3/4] net/bonding: remove socket id check 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 13:07:32 -0000 Socket id parsed from the user was checked if it was in the range of available sockets. This check is unnecessary, as the socket specified might not have memory anyway, so it will fail at memory allocation. Therefore, the best solution is to remove this check. Signed-off-by: Pablo de Lara --- drivers/net/bonding/rte_eth_bond_api.c | 16 ---------------- drivers/net/bonding/rte_eth_bond_args.c | 4 ++-- drivers/net/bonding/rte_eth_bond_pmd.c | 6 ------ drivers/net/bonding/rte_eth_bond_private.h | 3 --- 4 files changed, 2 insertions(+), 27 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index 36ec65d..6c7dbae 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -143,22 +143,6 @@ deactivate_slave(struct rte_eth_dev *eth_dev, uint8_t port_id) } } -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; -} - int rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) { diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c index e3bdad9..baaab35 100644 --- a/drivers/net/bonding/rte_eth_bond_args.c +++ b/drivers/net/bonding/rte_eth_bond_args.c @@ -204,8 +204,8 @@ bond_ethdev_parse_socket_id_kvarg(const char *key __rte_unused, if (*endptr != 0 || errno != 0) return -1; - /* validate mode value */ - if (socket_id >= 0 && socket_id < number_of_sockets()) { + /* validate socket id value */ + if (socket_id >= 0) { *(uint8_t *)extra_args = (uint8_t)socket_id; return 0; } diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 82959ab..c5efd06 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2272,12 +2272,6 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode) * and internal (private) data */ - if (socket_id >= number_of_sockets()) { - RTE_BOND_LOG(ERR, - "Invalid socket id specified to create bonded device on."); - goto err; - } - /* reserve an ethdev entry */ eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internals)); if (eth_dev == NULL) { diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h index c8db090..e37d463 100644 --- a/drivers/net/bonding/rte_eth_bond_private.h +++ b/drivers/net/bonding/rte_eth_bond_private.h @@ -232,9 +232,6 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct ether_addr *dst_mac_addr); int mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev); -uint8_t -number_of_sockets(void); - int bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int mode); -- 2.9.4