From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: thomas@monjalon.net, declan.doherty@intel.com
Cc: dev@dpdk.org, Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: [dpdk-dev] [PATCH 4/5] net/bonding: check if socket id has memory
Date: Wed, 21 Jun 2017 00:25:54 +0100 [thread overview]
Message-ID: <20170620232555.82244-5-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <20170620232555.82244-1-pablo.de.lara.guarch@intel.com>
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@intel.com>
---
drivers/net/bonding/rte_eth_bond_api.c | 16 ----------------
drivers/net/bonding/rte_eth_bond_args.c | 2 +-
drivers/net/bonding/rte_eth_bond_pmd.c | 7 ++++---
drivers/net/bonding/rte_eth_bond_private.h | 3 ---
4 files changed, 5 insertions(+), 23 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..66c3795 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -205,7 +205,7 @@ bond_ethdev_parse_socket_id_kvarg(const char *key __rte_unused,
return -1;
/* validate mode value */
- if (socket_id >= 0 && socket_id < number_of_sockets()) {
+ if (socket_id >= 0 && rte_eal_has_memory_socket(socket_id)) {
*(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..500e59b 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2272,9 +2272,10 @@ 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.");
+ if (!rte_eal_has_memory_socket(socket_id)) {
+ RTE_BOND_LOG(ERR, "Socket ID specified to create the "
+ "the bonded device on does not have "
+ "available memory");
goto err;
}
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
next prev parent reply other threads:[~2017-06-21 7:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 23:25 [dpdk-dev] [PATCH 0/5] eal: check socket memory Pablo de Lara
2017-06-20 23:25 ` [dpdk-dev] [PATCH 1/5] eal: check if socket has memory reserved Pablo de Lara
2017-06-20 23:25 ` [dpdk-dev] [PATCH 2/5] cryptodev: check if socket id has memory Pablo de Lara
2017-06-20 23:25 ` [dpdk-dev] [PATCH 3/5] crypto/scheduler: " Pablo de Lara
2017-06-20 23:25 ` Pablo de Lara [this message]
2017-06-20 23:25 ` [dpdk-dev] [PATCH 5/5] test/bonding: " Pablo de Lara
2017-06-21 5:07 ` [dpdk-dev] [PATCH v2 0/4] Socket ID check removal Pablo de Lara
2017-06-21 5:07 ` [dpdk-dev] [PATCH v2 1/4] cryptodev: remove socket id check Pablo de Lara
2017-06-22 11:27 ` Declan Doherty
2017-06-21 5:07 ` [dpdk-dev] [PATCH v2 2/4] crypto/scheduler: " Pablo de Lara
2017-06-22 11:38 ` Declan Doherty
2017-06-21 5:07 ` [dpdk-dev] [PATCH v2 3/4] net/bonding: " Pablo de Lara
2017-06-22 11:47 ` Declan Doherty
2017-06-21 5:07 ` [dpdk-dev] [PATCH v2 4/4] test/bonding: " Pablo de Lara
2017-06-22 11:48 ` Declan Doherty
2017-06-22 15:47 ` [dpdk-dev] [PATCH v2 0/4] Socket ID check removal Thomas Monjalon
2017-06-21 11:33 ` [dpdk-dev] [PATCH 0/5] eal: check socket memory De Lara Guarch, Pablo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170620232555.82244-5-pablo.de.lara.guarch@intel.com \
--to=pablo.de.lara.guarch@intel.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).