DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/failsafe: fix PCI devices init
@ 2017-10-19  9:11 Raslan Darawsheh
  2017-10-19 10:22 ` Gaëtan Rivet
  0 siblings, 1 reply; 2+ messages in thread
From: Raslan Darawsheh @ 2017-10-19  9:11 UTC (permalink / raw)
  To: gaetan.rivet; +Cc: dev, thomas

When trying to attach a port as a sub-device, the ethdev port
was compared with devargs.
In the case of a PCI device, the name in devargs is the PCI address.
And since DPDK 17.08, the devargs name of the underlying device was
used to match an ethdev port:
        a1e7c17555e8 ("ethdev: use device name from device structure")

But the recent commit 72e3efb149cc has reverted this wrong matching
to use the ethdev port name as identifier of the port.
It impacts functions like rte_eth_dev_allocated() used in failsafe
for matching ports with given devargs.
The fix is to search for matching devargs in underlying device of
all ethdev ports.
If many ports match the same PCI device, only the first one is matched.

This limitation was already present in previous implementation of
rte_eth_dev_allocated(), and must be adressed later with a better
devargs syntax.

Fixes: 72e3efb149cc ("ethdev: revert use port name from device structure")

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 drivers/net/failsafe/failsafe_eal.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c
index aeb87a0..734b25c 100644
--- a/drivers/net/failsafe/failsafe_eal.c
+++ b/drivers/net/failsafe/failsafe_eal.c
@@ -41,6 +41,7 @@ fs_bus_init(struct rte_eth_dev *dev)
 	struct sub_device *sdev;
 	struct rte_devargs *da;
 	uint8_t i;
+	uint16_t j;
 	int ret;
 
 	FOREACH_SUBDEV(sdev, i, dev) {
@@ -57,7 +58,13 @@ fs_bus_init(struct rte_eth_dev *dev)
 			      rte_errno ? ")" : "");
 			continue;
 		}
-		ETH(sdev) = rte_eth_dev_allocated(da->name);
+		RTE_ETH_FOREACH_DEV(j) {
+			if (!strcmp(rte_eth_devices[j].device->name,
+				    da->name)) {
+				ETH(sdev) = &rte_eth_devices[j];
+				break;
+			}
+		}
 		if (ETH(sdev) == NULL) {
 			ERROR("sub_device %d init went wrong", i);
 			return -ENODEV;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/failsafe: fix PCI devices init
  2017-10-19  9:11 [dpdk-dev] [PATCH] net/failsafe: fix PCI devices init Raslan Darawsheh
@ 2017-10-19 10:22 ` Gaëtan Rivet
  0 siblings, 0 replies; 2+ messages in thread
From: Gaëtan Rivet @ 2017-10-19 10:22 UTC (permalink / raw)
  To: Raslan Darawsheh; +Cc: dev, thomas

Hello Raslan,

Thanks for spotting the issue and fixing it.
Small nit below.

On Thu, Oct 19, 2017 at 12:11:52PM +0300, Raslan Darawsheh wrote:
> When trying to attach a port as a sub-device, the ethdev port
> was compared with devargs.
> In the case of a PCI device, the name in devargs is the PCI address.
> And since DPDK 17.08, the devargs name of the underlying device was
> used to match an ethdev port:
>         a1e7c17555e8 ("ethdev: use device name from device structure")
> 
> But the recent commit 72e3efb149cc has reverted this wrong matching
> to use the ethdev port name as identifier of the port.
> It impacts functions like rte_eth_dev_allocated() used in failsafe
> for matching ports with given devargs.
> The fix is to search for matching devargs in underlying device of
> all ethdev ports.
> If many ports match the same PCI device, only the first one is matched.
> 
> This limitation was already present in previous implementation of
> rte_eth_dev_allocated(), and must be adressed later with a better
> devargs syntax.
> 
> Fixes: 72e3efb149cc ("ethdev: revert use port name from device structure")
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

With the nit below fixed:
Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>

> ---
>  drivers/net/failsafe/failsafe_eal.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c
> index aeb87a0..734b25c 100644
> --- a/drivers/net/failsafe/failsafe_eal.c
> +++ b/drivers/net/failsafe/failsafe_eal.c
> @@ -41,6 +41,7 @@ fs_bus_init(struct rte_eth_dev *dev)
>  	struct sub_device *sdev;
>  	struct rte_devargs *da;
>  	uint8_t i;
> +	uint16_t j;
>  	int ret;
>  
>  	FOREACH_SUBDEV(sdev, i, dev) {
> @@ -57,7 +58,13 @@ fs_bus_init(struct rte_eth_dev *dev)
>  			      rte_errno ? ")" : "");
>  			continue;
>  		}
> -		ETH(sdev) = rte_eth_dev_allocated(da->name);
> +		RTE_ETH_FOREACH_DEV(j) {
> +			if (!strcmp(rte_eth_devices[j].device->name,
> +				    da->name)) {

The explicit comparison to 0 should be preferred, as done in
failsafe_args.c.

> +				ETH(sdev) = &rte_eth_devices[j];
> +				break;
> +			}
> +		}
>  		if (ETH(sdev) == NULL) {
>  			ERROR("sub_device %d init went wrong", i);
>  			return -ENODEV;
> -- 
> 2.7.4
> 

-- 
Gaëtan Rivet
6WIND

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-19 10:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-19  9:11 [dpdk-dev] [PATCH] net/failsafe: fix PCI devices init Raslan Darawsheh
2017-10-19 10:22 ` Gaëtan Rivet

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).