DPDK patches and discussions
 help / color / mirror / Atom feed
From: Declan Doherty <declan.doherty@intel.com>
To: Gowrishankar <gowrishankar.m@linux.vnet.ibm.com>
Cc: dev@dpdk.org, Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@intel.com>
Subject: Re: [dpdk-dev] [PATCH v2] net/bonding: support bifurcated driver in eal cli using --vdev
Date: Fri, 7 Jul 2017 16:38:56 +0100	[thread overview]
Message-ID: <2115e096-6c7f-08a1-bec2-1860b5ff11ae@intel.com> (raw)
In-Reply-To: <266cd54d289bfd6e9535a173c9607f0234f8b1b7.1499167396.git.gowrishankar.m@linux.vnet.ibm.com>

On 04/07/2017 12:57 PM, Gowrishankar wrote:
> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
>
> At present, creating bonding devices using --vdev is broken for PMD like
> mlx5 as it is neither UIO nor VFIO based and hence PMD driver is unknown
> to find_port_id_by_pci_addr(), as below.
>
> testpmd <EAL args> --vdev 'net_bonding0,mode=1,slave=<PCI>,socket_id=0'
>
> PMD: bond_ethdev_parse_slave_port_kvarg(150) - Invalid slave port value
>  (<PCI ID>) specified
> EAL: Failed to parse slave ports for bonded device net_bonding0
>
> This patch fixes parsing PCI ID from bonding device params by verifying
> it in RTE PCI bus, rather than checking dev->kdrv.
>
> Changes:
>   v2 - revisit fix by iterating rte_pci_bus
>
> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> ---
...
>

Hey Gowrishankar,

I was having a look at this patch and there is the following checkpatch 
error.

_coding style issues_


WARNING:AVOID_EXTERNS: externs should be avoided in .c files
#48: FILE: drivers/net/bonding/rte_eth_bond_args.c:43:
+extern struct rte_pci_bus rte_pci_bus;


Looking at bit closer at the issue I think there is a simpler solution, 
the bonding driver really shouldn't be parsing the PCI bus directly, and 
since PCI devices use the PCI DBF as their name we can simply replace 
the all the scanning code with a simple call to 
rte_eth_dev_get_port_by_name API.

Can you try the following changes which removes any dependency on 
parsing the PCI bus tree directly, which works fine for me with UIO 
devices. If this works I'll send this fix to the list.

Thanks
Declan


---
  drivers/net/bonding/rte_eth_bond_args.c | 109 
++++----------------------------
  1 file changed, 14 insertions(+), 95 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_args.c 
b/drivers/net/bonding/rte_eth_bond_args.c
index ffab6e0..9fb98c6 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -40,7 +40,6 @@
  #include "rte_eth_bond.h"
  #include "rte_eth_bond_private.h"

-extern struct rte_pci_bus rte_pci_bus;

  const char *pmd_bond_init_valid_arguments[] = {
  	PMD_BOND_SLAVE_PORT_KVARG,
@@ -53,104 +52,22 @@ const char *pmd_bond_init_valid_arguments[] = {
  	NULL
  };

-static inline int
-find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)
-{
-	struct rte_pci_device *pci_dev;
-	struct rte_pci_addr *eth_pci_addr;
-	unsigned i;
-
-	for (i = 0; i < rte_eth_dev_count(); i++) {
-		pci_dev = RTE_ETH_DEV_TO_PCI(&rte_eth_devices[i]);
-		eth_pci_addr = &pci_dev->addr;
-
-		if (pci_addr->bus == eth_pci_addr->bus &&
-			pci_addr->devid == eth_pci_addr->devid &&
-			pci_addr->domain == eth_pci_addr->domain &&
-			pci_addr->function == eth_pci_addr->function)
-			return i;
-	}
-	return -1;
-}
-
-static inline int
-find_port_id_by_dev_name(const char *name)
-{
-	unsigned i;
-
-	for (i = 0; i < rte_eth_dev_count(); i++) {
-		if (rte_eth_devices[i].data == NULL)
-			continue;
-
-		if (strcmp(rte_eth_devices[i].device->name, name) == 0)
-			return i;
-	}
-	return -1;
-}
-
-/**
- * Parses a port identifier string to a port id by pci address, then by 
name,
- * and finally port id.
- */
-static inline int
-parse_port_id(const char *port_str)
-{
-	struct rte_pci_device *dev;
-	struct rte_pci_addr dev_addr;
-	int port_id = -1;
-
-	/* try parsing as pci address, physical devices */
-	if (eal_parse_pci_DomBDF(port_str, &dev_addr) == 0) {
-		FOREACH_DEVICE_ON_PCIBUS(dev) {
-			if (rte_eal_compare_pci_addr(&dev->addr, &dev_addr))
-				continue;
-
-			port_id = find_port_id_by_pci_addr(&dev_addr);
-		}
-		if (port_id < 0)
-			return -1;
-	} else {
-		/* try parsing as device name, virtual devices */
-		port_id = find_port_id_by_dev_name(port_str);
-		if (port_id < 0) {
-			char *end;
-			errno = 0;
-
-			/* try parsing as port id */
-			port_id = strtol(port_str, &end, 10);
-			if (*end != 0 || errno != 0)
-				return -1;
-		}
-	}
-
-	if (port_id < 0 || port_id > RTE_MAX_ETHPORTS) {
-		RTE_BOND_LOG(ERR, "Slave port specified (%s) outside expected range",
-				port_str);
-		return -1;
-	}
-	return port_id;
-}
-
  int
-bond_ethdev_parse_slave_port_kvarg(const char *key,
+bond_ethdev_parse_slave_port_kvarg(const char *key __rte_unused,
  		const char *value, void *extra_args)
  {
-	struct bond_ethdev_slave_ports *slave_ports;
+	struct bond_ethdev_slave_ports *slaves;
+	uint8_t pid;

  	if (value == NULL || extra_args == NULL)
  		return -1;

-	slave_ports = extra_args;
+	if (rte_eth_dev_get_port_by_name(value, &pid) < 0)
+		return -1;
+
+	slaves = extra_args;
+	slaves->slaves[slaves->slave_count++] = pid;

-	if (strcmp(key, PMD_BOND_SLAVE_PORT_KVARG) == 0) {
-		int port_id = parse_port_id(value);
-		if (port_id < 0) {
-			RTE_BOND_LOG(ERR, "Invalid slave port value (%s) specified", value);
-			return -1;
-		} else
-			slave_ports->slaves[slave_ports->slave_count++] =
-					(uint8_t)port_id;
-	}
  	return 0;
  }

@@ -214,20 +131,22 @@ int
  bond_ethdev_parse_primary_slave_port_id_kvarg(const char *key 
__rte_unused,
  		const char *value, void *extra_args)
  {
-	int primary_slave_port_id;
+	uint8_t pid, *primary_pid;

  	if (value == NULL || extra_args == NULL)
  		return -1;

-	primary_slave_port_id = parse_port_id(value);
-	if (primary_slave_port_id < 0)
+	if (rte_eth_dev_get_port_by_name(value, &pid) < 0)
  		return -1;

-	*(uint8_t *)extra_args = (uint8_t)primary_slave_port_id;
+	primary_pid = (uint8_t *)extra_args;
+	*primary_pid = pid;

  	return 0;
  }

+
+
  int
  bond_ethdev_parse_balance_xmit_policy_kvarg(const char *key __rte_unused,
  		const char *value, void *extra_args)
-- 
2.9.4

  reply	other threads:[~2017-07-07 15:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 10:49 [dpdk-dev] [PATCH] " Gowrishankar
2017-06-15 13:54 ` Ferruh Yigit
2017-06-16 14:34 ` Thomas Monjalon
2017-07-04 11:57 ` [dpdk-dev] [PATCH v2] " Gowrishankar
2017-07-07 15:38   ` Declan Doherty [this message]
2017-07-10  6:32     ` gowrishankar muthukrishnan
2017-07-31 14:34       ` Gaëtan Rivet
2017-09-05  9:13         ` Thomas Monjalon
2017-09-06  8:59           ` gowrishankar muthukrishnan
2017-10-02  8:41             ` [dpdk-dev] [Suspected-Phishing]Re: " Raslan Darawsheh
2017-10-02  8:44               ` gowrishankar muthukrishnan
2017-10-03  8:38                 ` [dpdk-dev] [Suspected-Phishing]Re: " Raslan Darawsheh
2017-09-20 18:04   ` [dpdk-dev] [PATCH v3] " Gowrishankar
2017-10-02 11:06     ` Doherty, Declan
2017-10-02 23:32       ` Ferruh Yigit
2017-10-02 12:09     ` Gaëtan Rivet

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=2115e096-6c7f-08a1-bec2-1860b5ff11ae@intel.com \
    --to=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=gowrishankar.m@linux.vnet.ibm.com \
    --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).