* [dpdk-stable] [PATCH v2 1/6] ethdev: fix port data reset timing
[not found] ` <1515318351-4756-1-git-send-email-matan@mellanox.com>
@ 2018-01-07 9:45 ` Matan Azrad
[not found] ` <1516293317-30748-1-git-send-email-matan@mellanox.com>
1 sibling, 0 replies; 25+ messages in thread
From: Matan Azrad @ 2018-01-07 9:45 UTC (permalink / raw)
To: Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
rte_eth_dev_data structure is allocated per ethdev port and can be
used to get a data of the port internally.
rte_eth_dev_attach_secondary tries to find the port identifier using
rte_eth_dev_data name field comparison and may get an identifier of
invalid port in case of this port was released by the primary process
because the port release API doesn't reset the port data.
So, it will be better to reset the port data in release time instead of
allocation time.
Move the port data reset to the port release API.
Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
lib/librte_ether/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index d1385df..684e3e8 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -233,7 +233,6 @@ struct rte_eth_dev *
return NULL;
}
- memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
eth_dev = eth_dev_get(port_id);
snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = port_id;
@@ -279,6 +278,7 @@ struct rte_eth_dev *
if (eth_dev == NULL)
return -EINVAL;
+ memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
eth_dev->state = RTE_ETH_DEV_UNUSED;
return 0;
}
--
1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
[not found] ` <1516293317-30748-1-git-send-email-matan@mellanox.com>
@ 2018-01-18 16:35 ` Matan Azrad
2018-01-18 17:00 ` Thomas Monjalon
` (2 more replies)
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation Matan Azrad
[not found] ` <1516483468-9048-1-git-send-email-matan@mellanox.com>
2 siblings, 3 replies; 25+ messages in thread
From: Matan Azrad @ 2018-01-18 16:35 UTC (permalink / raw)
To: Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
rte_eth_dev_data structure is allocated per ethdev port and can be
used to get a data of the port internally.
rte_eth_dev_attach_secondary tries to find the port identifier using
rte_eth_dev_data name field comparison and may get an identifier of
invalid port in case of this port was released by the primary process
because the port release API doesn't reset the port data.
So, it will be better to reset the port data in release time instead of
allocation time.
Move the port data reset to the port release API.
Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
lib/librte_ether/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7044159..156231c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -204,7 +204,6 @@ struct rte_eth_dev *
return NULL;
}
- memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
eth_dev = eth_dev_get(port_id);
snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = port_id;
@@ -252,6 +251,7 @@ struct rte_eth_dev *
if (eth_dev == NULL)
return -EINVAL;
+ memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
eth_dev->state = RTE_ETH_DEV_UNUSED;
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
--
1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation
[not found] ` <1516293317-30748-1-git-send-email-matan@mellanox.com>
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 1/7] " Matan Azrad
@ 2018-01-18 16:35 ` Matan Azrad
2018-01-18 17:00 ` Thomas Monjalon
2018-01-19 12:40 ` Ananyev, Konstantin
[not found] ` <1516483468-9048-1-git-send-email-matan@mellanox.com>
2 siblings, 2 replies; 25+ messages in thread
From: Matan Azrad @ 2018-01-18 16:35 UTC (permalink / raw)
To: Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
rte_eth_dev_find_free_port() found a free port by state checking.
The state field are in local process memory, so other DPDK processes
may get the same port ID because their local states may be different.
Replace the state checking by the ethdev port name checking,
so, if the name is an empty string the port ID will be detected as
unused.
Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
Cc: stable@dpdk.org
Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
lib/librte_ether/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 156231c..5d87f72 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -164,7 +164,7 @@ struct rte_eth_dev *
unsigned i;
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
- if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED)
+ if (rte_eth_dev_share_data->data[i].name[0] == '\0')
return i;
}
return RTE_MAX_ETHPORTS;
--
1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 1/7] " Matan Azrad
@ 2018-01-18 17:00 ` Thomas Monjalon
2018-01-19 12:38 ` Ananyev, Konstantin
2018-03-05 11:24 ` Ferruh Yigit
2 siblings, 0 replies; 25+ messages in thread
From: Thomas Monjalon @ 2018-01-18 17:00 UTC (permalink / raw)
To: Matan Azrad
Cc: Gaetan Rivet, Jingjing Wu, dev, Neil Horman, Bruce Richardson,
Konstantin Ananyev, stable
18/01/2018 17:35, Matan Azrad:
> rte_eth_dev_data structure is allocated per ethdev port and can be
> used to get a data of the port internally.
>
> rte_eth_dev_attach_secondary tries to find the port identifier using
> rte_eth_dev_data name field comparison and may get an identifier of
> invalid port in case of this port was released by the primary process
> because the port release API doesn't reset the port data.
>
> So, it will be better to reset the port data in release time instead of
> allocation time.
>
> Move the port data reset to the port release API.
>
> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
> Cc: stable@dpdk.org
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation Matan Azrad
@ 2018-01-18 17:00 ` Thomas Monjalon
2018-01-19 12:40 ` Ananyev, Konstantin
1 sibling, 0 replies; 25+ messages in thread
From: Thomas Monjalon @ 2018-01-18 17:00 UTC (permalink / raw)
To: Matan Azrad
Cc: Gaetan Rivet, Jingjing Wu, dev, Neil Horman, Bruce Richardson,
Konstantin Ananyev, stable
18/01/2018 17:35, Matan Azrad:
> rte_eth_dev_find_free_port() found a free port by state checking.
> The state field are in local process memory, so other DPDK processes
> may get the same port ID because their local states may be different.
>
> Replace the state checking by the ethdev port name checking,
> so, if the name is an empty string the port ID will be detected as
> unused.
>
> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
> Cc: stable@dpdk.org
>
> Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 1/7] " Matan Azrad
2018-01-18 17:00 ` Thomas Monjalon
@ 2018-01-19 12:38 ` Ananyev, Konstantin
2018-03-05 11:24 ` Ferruh Yigit
2 siblings, 0 replies; 25+ messages in thread
From: Ananyev, Konstantin @ 2018-01-19 12:38 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Wu, Jingjing
Cc: dev, Neil Horman, Richardson, Bruce, stable
> -----Original Message-----
> From: Matan Azrad [mailto:matan@mellanox.com]
> Sent: Thursday, January 18, 2018 4:35 PM
> To: Thomas Monjalon <thomas@monjalon.net>; Gaetan Rivet <gaetan.rivet@6wind.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Neil Horman <nhorman@tuxdriver.com>; Richardson, Bruce <bruce.richardson@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; stable@dpdk.org
> Subject: [PATCH v3 1/7] ethdev: fix port data reset timing
>
> rte_eth_dev_data structure is allocated per ethdev port and can be
> used to get a data of the port internally.
>
> rte_eth_dev_attach_secondary tries to find the port identifier using
> rte_eth_dev_data name field comparison and may get an identifier of
> invalid port in case of this port was released by the primary process
> because the port release API doesn't reset the port data.
>
> So, it will be better to reset the port data in release time instead of
> allocation time.
>
> Move the port data reset to the port release API.
>
> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
> Cc: stable@dpdk.org
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
> lib/librte_ether/rte_ethdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 7044159..156231c 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -204,7 +204,6 @@ struct rte_eth_dev *
> return NULL;
> }
>
> - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
> eth_dev = eth_dev_get(port_id);
> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
> eth_dev->data->port_id = port_id;
> @@ -252,6 +251,7 @@ struct rte_eth_dev *
> if (eth_dev == NULL)
> return -EINVAL;
>
> + memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
> eth_dev->state = RTE_ETH_DEV_UNUSED;
>
> _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
> --
> 1.8.3.1
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation Matan Azrad
2018-01-18 17:00 ` Thomas Monjalon
@ 2018-01-19 12:40 ` Ananyev, Konstantin
2018-01-20 16:48 ` Matan Azrad
1 sibling, 1 reply; 25+ messages in thread
From: Ananyev, Konstantin @ 2018-01-19 12:40 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Wu, Jingjing
Cc: dev, Neil Horman, Richardson, Bruce, stable
> -----Original Message-----
> From: Matan Azrad [mailto:matan@mellanox.com]
> Sent: Thursday, January 18, 2018 4:35 PM
> To: Thomas Monjalon <thomas@monjalon.net>; Gaetan Rivet <gaetan.rivet@6wind.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Neil Horman <nhorman@tuxdriver.com>; Richardson, Bruce <bruce.richardson@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; stable@dpdk.org
> Subject: [PATCH v3 2/7] ethdev: fix used portid allocation
>
> rte_eth_dev_find_free_port() found a free port by state checking.
> The state field are in local process memory, so other DPDK processes
> may get the same port ID because their local states may be different.
>
> Replace the state checking by the ethdev port name checking,
> so, if the name is an empty string the port ID will be detected as
> unused.
>
> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
> Cc: stable@dpdk.org
>
> Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
> lib/librte_ether/rte_ethdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 156231c..5d87f72 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -164,7 +164,7 @@ struct rte_eth_dev *
> unsigned i;
>
> for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
> - if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED)
> + if (rte_eth_dev_share_data->data[i].name[0] == '\0')
I know it is not really necessary, but I'd keep both (just in case):
if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED) && rte_eth_dev_share_data->data[i].name[0] == '\0')
Aprart from that: Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> return i;
> }
> return RTE_MAX_ETHPORTS;
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation
2018-01-19 12:40 ` Ananyev, Konstantin
@ 2018-01-20 16:48 ` Matan Azrad
2018-01-20 17:26 ` Ananyev, Konstantin
0 siblings, 1 reply; 25+ messages in thread
From: Matan Azrad @ 2018-01-20 16:48 UTC (permalink / raw)
To: Ananyev, Konstantin, Thomas Monjalon, Gaetan Rivet, Wu, Jingjing
Cc: dev, Neil Horman, Richardson, Bruce, stable
Hi Konstantin
From: Ananyev, Konstantin, Friday, January 19, 2018 2:40 PM
> > -----Original Message-----
> > From: Matan Azrad [mailto:matan@mellanox.com]
> > Sent: Thursday, January 18, 2018 4:35 PM
> > To: Thomas Monjalon <thomas@monjalon.net>; Gaetan Rivet
> > <gaetan.rivet@6wind.com>; Wu, Jingjing <jingjing.wu@intel.com>
> > Cc: dev@dpdk.org; Neil Horman <nhorman@tuxdriver.com>; Richardson,
> > Bruce <bruce.richardson@intel.com>; Ananyev, Konstantin
> > <konstantin.ananyev@intel.com>; stable@dpdk.org
> > Subject: [PATCH v3 2/7] ethdev: fix used portid allocation
> >
> > rte_eth_dev_find_free_port() found a free port by state checking.
> > The state field are in local process memory, so other DPDK processes
> > may get the same port ID because their local states may be different.
> >
> > Replace the state checking by the ethdev port name checking, so, if
> > the name is an empty string the port ID will be detected as unused.
> >
> > Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
> > process model")
> > Cc: stable@dpdk.org
> >
> > Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> > Signed-off-by: Matan Azrad <matan@mellanox.com>
> > ---
> > lib/librte_ether/rte_ethdev.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.c
> > b/lib/librte_ether/rte_ethdev.c index 156231c..5d87f72 100644
> > --- a/lib/librte_ether/rte_ethdev.c
> > +++ b/lib/librte_ether/rte_ethdev.c
> > @@ -164,7 +164,7 @@ struct rte_eth_dev *
> > unsigned i;
> >
> > for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
> > - if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED)
> > + if (rte_eth_dev_share_data->data[i].name[0] == '\0')
>
> I know it is not really necessary, but I'd keep both (just in case):
> if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED) &&
> rte_eth_dev_share_data->data[i].name[0] == '\0')
>
Since, as you, I don't think it is necessary, searched again and didn't find reason to that,
What's about
RTE_ASSERT(rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED);
Instead?
> Aprart from that: Acked-by: Konstantin Ananyev
> <konstantin.ananyev@intel.com>
>
> > return i;
> > }
> > return RTE_MAX_ETHPORTS;
> > --
> > 1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation
2018-01-20 16:48 ` Matan Azrad
@ 2018-01-20 17:26 ` Ananyev, Konstantin
0 siblings, 0 replies; 25+ messages in thread
From: Ananyev, Konstantin @ 2018-01-20 17:26 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Wu, Jingjing
Cc: dev, Neil Horman, Richardson, Bruce, stable
Hi Matan,
>
> Hi Konstantin
>
> From: Ananyev, Konstantin, Friday, January 19, 2018 2:40 PM
> > > -----Original Message-----
> > > From: Matan Azrad [mailto:matan@mellanox.com]
> > > Sent: Thursday, January 18, 2018 4:35 PM
> > > To: Thomas Monjalon <thomas@monjalon.net>; Gaetan Rivet
> > > <gaetan.rivet@6wind.com>; Wu, Jingjing <jingjing.wu@intel.com>
> > > Cc: dev@dpdk.org; Neil Horman <nhorman@tuxdriver.com>; Richardson,
> > > Bruce <bruce.richardson@intel.com>; Ananyev, Konstantin
> > > <konstantin.ananyev@intel.com>; stable@dpdk.org
> > > Subject: [PATCH v3 2/7] ethdev: fix used portid allocation
> > >
> > > rte_eth_dev_find_free_port() found a free port by state checking.
> > > The state field are in local process memory, so other DPDK processes
> > > may get the same port ID because their local states may be different.
> > >
> > > Replace the state checking by the ethdev port name checking, so, if
> > > the name is an empty string the port ID will be detected as unused.
> > >
> > > Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
> > > process model")
> > > Cc: stable@dpdk.org
> > >
> > > Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> > > Signed-off-by: Matan Azrad <matan@mellanox.com>
> > > ---
> > > lib/librte_ether/rte_ethdev.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/lib/librte_ether/rte_ethdev.c
> > > b/lib/librte_ether/rte_ethdev.c index 156231c..5d87f72 100644
> > > --- a/lib/librte_ether/rte_ethdev.c
> > > +++ b/lib/librte_ether/rte_ethdev.c
> > > @@ -164,7 +164,7 @@ struct rte_eth_dev *
> > > unsigned i;
> > >
> > > for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
> > > - if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED)
> > > + if (rte_eth_dev_share_data->data[i].name[0] == '\0')
> >
> > I know it is not really necessary, but I'd keep both (just in case):
> > if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED) &&
> > rte_eth_dev_share_data->data[i].name[0] == '\0')
> >
> Since, as you, I don't think it is necessary, searched again and didn't find reason to that,
> What's about
> RTE_ASSERT(rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED);
> Instead?
Sounds ok to me.
Konstantin
>
> > Aprart from that: Acked-by: Konstantin Ananyev
> > <konstantin.ananyev@intel.com>
> >
> > > return i;
> > > }
> > > return RTE_MAX_ETHPORTS;
> > > --
> > > 1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-stable] [PATCH v4 1/7] ethdev: fix port data reset timing
[not found] ` <1516483468-9048-1-git-send-email-matan@mellanox.com>
@ 2018-01-20 21:24 ` Matan Azrad
2018-01-20 21:24 ` [dpdk-stable] [PATCH v4 2/7] ethdev: fix used portid allocation Matan Azrad
[not found] ` <1516639103-27166-1-git-send-email-matan@mellanox.com>
2 siblings, 0 replies; 25+ messages in thread
From: Matan Azrad @ 2018-01-20 21:24 UTC (permalink / raw)
To: Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
rte_eth_dev_data structure is allocated per ethdev port and can be
used to get a data of the port internally.
rte_eth_dev_attach_secondary tries to find the port identifier using
rte_eth_dev_data name field comparison and may get an identifier of
invalid port in case of this port was released by the primary process
because the port release API doesn't reset the port data.
So, it will be better to reset the port data in release time instead of
allocation time.
Move the port data reset to the port release API.
Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
lib/librte_ether/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index c4ff1b0..23b7442 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -204,7 +204,6 @@ struct rte_eth_dev *
return NULL;
}
- memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
eth_dev = eth_dev_get(port_id);
snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = port_id;
@@ -252,6 +251,7 @@ struct rte_eth_dev *
if (eth_dev == NULL)
return -EINVAL;
+ memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
eth_dev->state = RTE_ETH_DEV_UNUSED;
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
--
1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-stable] [PATCH v4 2/7] ethdev: fix used portid allocation
[not found] ` <1516483468-9048-1-git-send-email-matan@mellanox.com>
2018-01-20 21:24 ` [dpdk-stable] [PATCH v4 1/7] ethdev: fix port data reset timing Matan Azrad
@ 2018-01-20 21:24 ` Matan Azrad
[not found] ` <1516639103-27166-1-git-send-email-matan@mellanox.com>
2 siblings, 0 replies; 25+ messages in thread
From: Matan Azrad @ 2018-01-20 21:24 UTC (permalink / raw)
To: Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
rte_eth_dev_find_free_port() found a free port by state checking.
The state field are in local process memory, so other DPDK processes
may get the same port ID because their local states may be different.
Replace the state checking by the ethdev port name checking,
so, if the name is an empty string the port ID will be detected as
unused.
Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
Cc: stable@dpdk.org
Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
lib/librte_ether/rte_ethdev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 23b7442..3a25a64 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -164,8 +164,12 @@ struct rte_eth_dev *
unsigned i;
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
- if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED)
+ /* Using shared name field to find a free port. */
+ if (rte_eth_dev_data[i].name[0] == '\0') {
+ RTE_ASSERT(rte_eth_devices[i].state ==
+ RTE_ETH_DEV_UNUSED);
return i;
+ }
}
return RTE_MAX_ETHPORTS;
}
--
1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-stable] [PATCH v5 1/7] ethdev: fix port data reset timing
[not found] ` <1516639103-27166-1-git-send-email-matan@mellanox.com>
@ 2018-01-22 16:38 ` Matan Azrad
2018-01-22 16:38 ` [dpdk-stable] [PATCH v5 2/7] ethdev: fix used portid allocation Matan Azrad
1 sibling, 0 replies; 25+ messages in thread
From: Matan Azrad @ 2018-01-22 16:38 UTC (permalink / raw)
To: Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
rte_eth_dev_data structure is allocated per ethdev port and can be
used to get a data of the port internally.
rte_eth_dev_attach_secondary tries to find the port identifier using
rte_eth_dev_data name field comparison and may get an identifier of
invalid port in case of this port was released by the primary process
because the port release API doesn't reset the port data.
So, it will be better to reset the port data in release time instead of
allocation time.
Move the port data reset to the port release API.
Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
lib/librte_ether/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f285ba2..c469bd4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -261,7 +261,6 @@ struct rte_eth_dev *
return NULL;
}
- memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
eth_dev = eth_dev_get(port_id);
snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = port_id;
@@ -309,6 +308,7 @@ struct rte_eth_dev *
if (eth_dev == NULL)
return -EINVAL;
+ memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
eth_dev->state = RTE_ETH_DEV_UNUSED;
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
--
1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [dpdk-stable] [PATCH v5 2/7] ethdev: fix used portid allocation
[not found] ` <1516639103-27166-1-git-send-email-matan@mellanox.com>
2018-01-22 16:38 ` [dpdk-stable] [PATCH v5 1/7] ethdev: fix port data reset timing Matan Azrad
@ 2018-01-22 16:38 ` Matan Azrad
1 sibling, 0 replies; 25+ messages in thread
From: Matan Azrad @ 2018-01-22 16:38 UTC (permalink / raw)
To: Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
rte_eth_dev_find_free_port() found a free port by state checking.
The state field are in local process memory, so other DPDK processes
may get the same port ID because their local states may be different.
Replace the state checking by the ethdev port name checking,
so, if the name is an empty string the port ID will be detected as
unused.
Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
Cc: stable@dpdk.org
Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
lib/librte_ether/rte_ethdev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index c469bd4..e348b63 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -221,8 +221,12 @@ struct rte_eth_dev *
unsigned i;
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
- if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED)
+ /* Using shared name field to find a free port. */
+ if (rte_eth_dev_data[i].name[0] == '\0') {
+ RTE_ASSERT(rte_eth_devices[i].state ==
+ RTE_ETH_DEV_UNUSED);
return i;
+ }
}
return RTE_MAX_ETHPORTS;
}
--
1.8.3.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 1/7] " Matan Azrad
2018-01-18 17:00 ` Thomas Monjalon
2018-01-19 12:38 ` Ananyev, Konstantin
@ 2018-03-05 11:24 ` Ferruh Yigit
2018-03-05 14:52 ` Matan Azrad
2 siblings, 1 reply; 25+ messages in thread
From: Ferruh Yigit @ 2018-03-05 11:24 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
On 1/18/2018 4:35 PM, Matan Azrad wrote:
> rte_eth_dev_data structure is allocated per ethdev port and can be
> used to get a data of the port internally.
>
> rte_eth_dev_attach_secondary tries to find the port identifier using
> rte_eth_dev_data name field comparison and may get an identifier of
> invalid port in case of this port was released by the primary process
> because the port release API doesn't reset the port data.
>
> So, it will be better to reset the port data in release time instead of
> allocation time.
>
> Move the port data reset to the port release API.
>
> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
> Cc: stable@dpdk.org
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
> lib/librte_ether/rte_ethdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 7044159..156231c 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -204,7 +204,6 @@ struct rte_eth_dev *
> return NULL;
> }
>
> - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
> eth_dev = eth_dev_get(port_id);
> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
> eth_dev->data->port_id = port_id;
> @@ -252,6 +251,7 @@ struct rte_eth_dev *
> if (eth_dev == NULL)
> return -EINVAL;
>
> + memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
Hi Matan,
What most of the vdev release path does is:
eth_dev = rte_eth_dev_allocated(...)
rte_free(eth_dev->data->dev_private);
rte_free(eth_dev->data);
rte_eth_dev_release_port(eth_dev);
Since eth_dev->data freed, memset() it in rte_eth_dev_release_port() will be
problem.
We don't run remove path that is why we didn't hit the issue but this seems
problem for all virtual PMDs.
Also rte_eth_dev_pci_release() looks problematic now.
Can you please check the issue?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-03-05 11:24 ` Ferruh Yigit
@ 2018-03-05 14:52 ` Matan Azrad
2018-03-05 15:06 ` Ferruh Yigit
0 siblings, 1 reply; 25+ messages in thread
From: Matan Azrad @ 2018-03-05 14:52 UTC (permalink / raw)
To: Ferruh Yigit, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
HI
From: Ferruh Yigit, Sent: Monday, March 5, 2018 1:24 PM
> On 1/18/2018 4:35 PM, Matan Azrad wrote:
> > rte_eth_dev_data structure is allocated per ethdev port and can be
> > used to get a data of the port internally.
> >
> > rte_eth_dev_attach_secondary tries to find the port identifier using
> > rte_eth_dev_data name field comparison and may get an identifier of
> > invalid port in case of this port was released by the primary process
> > because the port release API doesn't reset the port data.
> >
> > So, it will be better to reset the port data in release time instead
> > of allocation time.
> >
> > Move the port data reset to the port release API.
> >
> > Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
> > process model")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Matan Azrad <matan@mellanox.com>
> > ---
> > lib/librte_ether/rte_ethdev.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.c
> > b/lib/librte_ether/rte_ethdev.c index 7044159..156231c 100644
> > --- a/lib/librte_ether/rte_ethdev.c
> > +++ b/lib/librte_ether/rte_ethdev.c
> > @@ -204,7 +204,6 @@ struct rte_eth_dev *
> > return NULL;
> > }
> >
> > - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct
> rte_eth_dev_data));
> > eth_dev = eth_dev_get(port_id);
> > snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
> "%s", name);
> > eth_dev->data->port_id = port_id;
> > @@ -252,6 +251,7 @@ struct rte_eth_dev *
> > if (eth_dev == NULL)
> > return -EINVAL;
> >
> > + memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
>
> Hi Matan,
>
> What most of the vdev release path does is:
>
> eth_dev = rte_eth_dev_allocated(...)
> rte_free(eth_dev->data->dev_private);
> rte_free(eth_dev->data);
> rte_eth_dev_release_port(eth_dev);
>
> Since eth_dev->data freed, memset() it in rte_eth_dev_release_port() will
> be problem.
>
> We don't run remove path that is why we didn't hit the issue but this seems
> problem for all virtual PMDs.
Yes, it is a problem and should be fixed:
For vdevs which use private rte_eth_dev_data the remove order can be:
private_data = eth_dev->data;
rte_free(eth_dev->data->dev_private);
rte_eth_dev_release_port(eth_dev); /* The last operation working on ethdev structure. */
rte_free(private_data);
> Also rte_eth_dev_pci_release() looks problematic now.
Yes, again, the last operation working on ethdev structure should be rte_eth_dev_release_port().
So need to fix all vdevs and the rte_eth_dev_pci_release() function.
Any comments?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-03-05 14:52 ` Matan Azrad
@ 2018-03-05 15:06 ` Ferruh Yigit
2018-03-05 15:12 ` Matan Azrad
0 siblings, 1 reply; 25+ messages in thread
From: Ferruh Yigit @ 2018-03-05 15:06 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
On 3/5/2018 2:52 PM, Matan Azrad wrote:
> HI
>
> From: Ferruh Yigit, Sent: Monday, March 5, 2018 1:24 PM
>> On 1/18/2018 4:35 PM, Matan Azrad wrote:
>>> rte_eth_dev_data structure is allocated per ethdev port and can be
>>> used to get a data of the port internally.
>>>
>>> rte_eth_dev_attach_secondary tries to find the port identifier using
>>> rte_eth_dev_data name field comparison and may get an identifier of
>>> invalid port in case of this port was released by the primary process
>>> because the port release API doesn't reset the port data.
>>>
>>> So, it will be better to reset the port data in release time instead
>>> of allocation time.
>>>
>>> Move the port data reset to the port release API.
>>>
>>> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
>>> process model")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Matan Azrad <matan@mellanox.com>
>>> ---
>>> lib/librte_ether/rte_ethdev.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/lib/librte_ether/rte_ethdev.c
>>> b/lib/librte_ether/rte_ethdev.c index 7044159..156231c 100644
>>> --- a/lib/librte_ether/rte_ethdev.c
>>> +++ b/lib/librte_ether/rte_ethdev.c
>>> @@ -204,7 +204,6 @@ struct rte_eth_dev *
>>> return NULL;
>>> }
>>>
>>> - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct
>> rte_eth_dev_data));
>>> eth_dev = eth_dev_get(port_id);
>>> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
>> "%s", name);
>>> eth_dev->data->port_id = port_id;
>>> @@ -252,6 +251,7 @@ struct rte_eth_dev *
>>> if (eth_dev == NULL)
>>> return -EINVAL;
>>>
>>> + memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
>>
>> Hi Matan,
>>
>> What most of the vdev release path does is:
>>
>> eth_dev = rte_eth_dev_allocated(...)
>> rte_free(eth_dev->data->dev_private);
>> rte_free(eth_dev->data);
>> rte_eth_dev_release_port(eth_dev);
>>
>> Since eth_dev->data freed, memset() it in rte_eth_dev_release_port() will
>> be problem.
>>
>> We don't run remove path that is why we didn't hit the issue but this seems
>> problem for all virtual PMDs.
>
> Yes, it is a problem and should be fixed:
> For vdevs which use private rte_eth_dev_data the remove order can be:
> private_data = eth_dev->data;
> rte_free(eth_dev->data->dev_private);
> rte_eth_dev_release_port(eth_dev); /* The last operation working on ethdev structure. */
> rte_free(private_data);
Do we need to save "private_data"?
>
>
>> Also rte_eth_dev_pci_release() looks problematic now.
>
> Yes, again, the last operation working on ethdev structure should be rte_eth_dev_release_port().
>
> So need to fix all vdevs and the rte_eth_dev_pci_release() function.
>
> Any comments?
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-03-05 15:06 ` Ferruh Yigit
@ 2018-03-05 15:12 ` Matan Azrad
2018-03-27 22:37 ` Ferruh Yigit
0 siblings, 1 reply; 25+ messages in thread
From: Matan Azrad @ 2018-03-05 15:12 UTC (permalink / raw)
To: Ferruh Yigit, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
Hi Ferruh
From: Ferruh Yigit, Sent: Monday, March 5, 2018 5:07 PM
> On 3/5/2018 2:52 PM, Matan Azrad wrote:
> > HI
> >
> > From: Ferruh Yigit, Sent: Monday, March 5, 2018 1:24 PM
> >> On 1/18/2018 4:35 PM, Matan Azrad wrote:
> >>> rte_eth_dev_data structure is allocated per ethdev port and can be
> >>> used to get a data of the port internally.
> >>>
> >>> rte_eth_dev_attach_secondary tries to find the port identifier using
> >>> rte_eth_dev_data name field comparison and may get an identifier of
> >>> invalid port in case of this port was released by the primary
> >>> process because the port release API doesn't reset the port data.
> >>>
> >>> So, it will be better to reset the port data in release time instead
> >>> of allocation time.
> >>>
> >>> Move the port data reset to the port release API.
> >>>
> >>> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
> >>> process model")
> >>> Cc: stable@dpdk.org
> >>>
> >>> Signed-off-by: Matan Azrad <matan@mellanox.com>
> >>> ---
> >>> lib/librte_ether/rte_ethdev.c | 2 +-
> >>> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/lib/librte_ether/rte_ethdev.c
> >>> b/lib/librte_ether/rte_ethdev.c index 7044159..156231c 100644
> >>> --- a/lib/librte_ether/rte_ethdev.c
> >>> +++ b/lib/librte_ether/rte_ethdev.c
> >>> @@ -204,7 +204,6 @@ struct rte_eth_dev *
> >>> return NULL;
> >>> }
> >>>
> >>> - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct
> >> rte_eth_dev_data));
> >>> eth_dev = eth_dev_get(port_id);
> >>> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
> >> "%s", name);
> >>> eth_dev->data->port_id = port_id;
> >>> @@ -252,6 +251,7 @@ struct rte_eth_dev *
> >>> if (eth_dev == NULL)
> >>> return -EINVAL;
> >>>
> >>> + memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
> >>
> >> Hi Matan,
> >>
> >> What most of the vdev release path does is:
> >>
> >> eth_dev = rte_eth_dev_allocated(...)
> >> rte_free(eth_dev->data->dev_private);
> >> rte_free(eth_dev->data);
> >> rte_eth_dev_release_port(eth_dev);
> >>
> >> Since eth_dev->data freed, memset() it in rte_eth_dev_release_port()
> >> will be problem.
> >>
> >> We don't run remove path that is why we didn't hit the issue but this
> >> seems problem for all virtual PMDs.
> >
> > Yes, it is a problem and should be fixed:
> > For vdevs which use private rte_eth_dev_data the remove order can be:
> > private_data = eth_dev->data;
> > rte_free(eth_dev->data->dev_private);
> > rte_eth_dev_release_port(eth_dev); /* The last operation working
> on ethdev structure. */
> > rte_free(private_data);
>
> Do we need to save "private_data"?
Just to emphasis that eth_dev structure should not more be available after rte_eth_dev_release_port().
Maybe in the future rte_eth_dev_release_port() will zero eth_dev structure too :)
> >
> >
> >> Also rte_eth_dev_pci_release() looks problematic now.
> >
> > Yes, again, the last operation working on ethdev structure should be
> rte_eth_dev_release_port().
> >
> > So need to fix all vdevs and the rte_eth_dev_pci_release() function.
> >
> > Any comments?
> >
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-03-05 15:12 ` Matan Azrad
@ 2018-03-27 22:37 ` Ferruh Yigit
2018-03-28 12:07 ` Matan Azrad
0 siblings, 1 reply; 25+ messages in thread
From: Ferruh Yigit @ 2018-03-27 22:37 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
On 3/5/2018 3:12 PM, Matan Azrad wrote:
> Hi Ferruh
>
> From: Ferruh Yigit, Sent: Monday, March 5, 2018 5:07 PM
>> On 3/5/2018 2:52 PM, Matan Azrad wrote:
>>> HI
>>>
>>> From: Ferruh Yigit, Sent: Monday, March 5, 2018 1:24 PM
>>>> On 1/18/2018 4:35 PM, Matan Azrad wrote:
>>>>> rte_eth_dev_data structure is allocated per ethdev port and can be
>>>>> used to get a data of the port internally.
>>>>>
>>>>> rte_eth_dev_attach_secondary tries to find the port identifier using
>>>>> rte_eth_dev_data name field comparison and may get an identifier of
>>>>> invalid port in case of this port was released by the primary
>>>>> process because the port release API doesn't reset the port data.
>>>>>
>>>>> So, it will be better to reset the port data in release time instead
>>>>> of allocation time.
>>>>>
>>>>> Move the port data reset to the port release API.
>>>>>
>>>>> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
>>>>> process model")
>>>>> Cc: stable@dpdk.org
>>>>>
>>>>> Signed-off-by: Matan Azrad <matan@mellanox.com>
>>>>> ---
>>>>> lib/librte_ether/rte_ethdev.c | 2 +-
>>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/lib/librte_ether/rte_ethdev.c
>>>>> b/lib/librte_ether/rte_ethdev.c index 7044159..156231c 100644
>>>>> --- a/lib/librte_ether/rte_ethdev.c
>>>>> +++ b/lib/librte_ether/rte_ethdev.c
>>>>> @@ -204,7 +204,6 @@ struct rte_eth_dev *
>>>>> return NULL;
>>>>> }
>>>>>
>>>>> - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct
>>>> rte_eth_dev_data));
>>>>> eth_dev = eth_dev_get(port_id);
>>>>> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
>>>> "%s", name);
>>>>> eth_dev->data->port_id = port_id;
>>>>> @@ -252,6 +251,7 @@ struct rte_eth_dev *
>>>>> if (eth_dev == NULL)
>>>>> return -EINVAL;
>>>>>
>>>>> + memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
>>>>
>>>> Hi Matan,
>>>>
>>>> What most of the vdev release path does is:
>>>>
>>>> eth_dev = rte_eth_dev_allocated(...)
>>>> rte_free(eth_dev->data->dev_private);
>>>> rte_free(eth_dev->data);
>>>> rte_eth_dev_release_port(eth_dev);
>>>>
>>>> Since eth_dev->data freed, memset() it in rte_eth_dev_release_port()
>>>> will be problem.
>>>>
>>>> We don't run remove path that is why we didn't hit the issue but this
>>>> seems problem for all virtual PMDs.
>>>
>>> Yes, it is a problem and should be fixed:
>>> For vdevs which use private rte_eth_dev_data the remove order can be:
>>> private_data = eth_dev->data;
>>> rte_free(eth_dev->data->dev_private);
>>> rte_eth_dev_release_port(eth_dev); /* The last operation working
>> on ethdev structure. */
>>> rte_free(private_data);
>>
>> Do we need to save "private_data"?
>
> Just to emphasis that eth_dev structure should not more be available after rte_eth_dev_release_port().
> Maybe in the future rte_eth_dev_release_port() will zero eth_dev structure too :)
Hi Matan,
Reminder of this issue, it would be nice to fix in this release.
>
>>>
>>>
>>>> Also rte_eth_dev_pci_release() looks problematic now.
>>>
>>> Yes, again, the last operation working on ethdev structure should be
>> rte_eth_dev_release_port().
>>>
>>> So need to fix all vdevs and the rte_eth_dev_pci_release() function.
>>>
>>> Any comments?
>>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-03-27 22:37 ` Ferruh Yigit
@ 2018-03-28 12:07 ` Matan Azrad
2018-03-30 10:39 ` Ferruh Yigit
0 siblings, 1 reply; 25+ messages in thread
From: Matan Azrad @ 2018-03-28 12:07 UTC (permalink / raw)
To: Ferruh Yigit, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
Hi Ferruh
> From: Ferruh Yigit, Wednesday, March 28, 2018 1:38 AM
> On 3/5/2018 3:12 PM, Matan Azrad wrote:
> > Hi Ferruh
> >
> > From: Ferruh Yigit, Sent: Monday, March 5, 2018 5:07 PM
> >> On 3/5/2018 2:52 PM, Matan Azrad wrote:
> >>> HI
> >>>
> >>> From: Ferruh Yigit, Sent: Monday, March 5, 2018 1:24 PM
> >>>> On 1/18/2018 4:35 PM, Matan Azrad wrote:
> >>>>> rte_eth_dev_data structure is allocated per ethdev port and can be
> >>>>> used to get a data of the port internally.
> >>>>>
> >>>>> rte_eth_dev_attach_secondary tries to find the port identifier
> >>>>> using rte_eth_dev_data name field comparison and may get an
> >>>>> identifier of invalid port in case of this port was released by
> >>>>> the primary process because the port release API doesn't reset the
> port data.
> >>>>>
> >>>>> So, it will be better to reset the port data in release time
> >>>>> instead of allocation time.
> >>>>>
> >>>>> Move the port data reset to the port release API.
> >>>>>
> >>>>> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
> >>>>> process model")
> >>>>> Cc: stable@dpdk.org
> >>>>>
> >>>>> Signed-off-by: Matan Azrad <matan@mellanox.com>
> >>>>> ---
> >>>>> lib/librte_ether/rte_ethdev.c | 2 +-
> >>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>>
> >>>>> diff --git a/lib/librte_ether/rte_ethdev.c
> >>>>> b/lib/librte_ether/rte_ethdev.c index 7044159..156231c 100644
> >>>>> --- a/lib/librte_ether/rte_ethdev.c
> >>>>> +++ b/lib/librte_ether/rte_ethdev.c
> >>>>> @@ -204,7 +204,6 @@ struct rte_eth_dev *
> >>>>> return NULL;
> >>>>> }
> >>>>>
> >>>>> - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct
> >>>> rte_eth_dev_data));
> >>>>> eth_dev = eth_dev_get(port_id);
> >>>>> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
> >>>> "%s", name);
> >>>>> eth_dev->data->port_id = port_id; @@ -252,6 +251,7 @@ struct
> >>>>> rte_eth_dev *
> >>>>> if (eth_dev == NULL)
> >>>>> return -EINVAL;
> >>>>>
> >>>>> + memset(eth_dev->data, 0, sizeof(struct
> rte_eth_dev_data));
> >>>>
> >>>> Hi Matan,
> >>>>
> >>>> What most of the vdev release path does is:
> >>>>
> >>>> eth_dev = rte_eth_dev_allocated(...)
> >>>> rte_free(eth_dev->data->dev_private);
> >>>> rte_free(eth_dev->data);
> >>>> rte_eth_dev_release_port(eth_dev);
> >>>>
> >>>> Since eth_dev->data freed, memset() it in
> >>>> rte_eth_dev_release_port() will be problem.
> >>>>
> >>>> We don't run remove path that is why we didn't hit the issue but
> >>>> this seems problem for all virtual PMDs.
> >>>
> >>> Yes, it is a problem and should be fixed:
> >>> For vdevs which use private rte_eth_dev_data the remove order can
> be:
> >>> private_data = eth_dev->data;
> >>> rte_free(eth_dev->data->dev_private);
> >>> rte_eth_dev_release_port(eth_dev); /* The last operation working
> >> on ethdev structure. */
> >>> rte_free(private_data);
> >>
> >> Do we need to save "private_data"?
> >
> > Just to emphasis that eth_dev structure should not more be available after
> rte_eth_dev_release_port().
> > Maybe in the future rte_eth_dev_release_port() will zero eth_dev
> > structure too :)
>
> Hi Matan,
>
> Reminder of this issue, it would be nice to fix in this release.
>
Regarding the private rte_eth_dev_data, it should be fixed in the next thread:
https://dpdk.org/dev/patchwork/patch/35632/
Regarding the rte_eth_dev_pci_release() function: I'm going to send a fix.
> >
> >>>
> >>>
> >>>> Also rte_eth_dev_pci_release() looks problematic now.
> >>>
> >>> Yes, again, the last operation working on ethdev structure should be
> >> rte_eth_dev_release_port().
> >>>
> >>> So need to fix all vdevs and the rte_eth_dev_pci_release() function.
> >>>
> >>> Any comments?
> >>>
> >
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-03-28 12:07 ` Matan Azrad
@ 2018-03-30 10:39 ` Ferruh Yigit
2018-04-19 11:07 ` Ferruh Yigit
0 siblings, 1 reply; 25+ messages in thread
From: Ferruh Yigit @ 2018-03-30 10:39 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable
On 3/28/2018 1:07 PM, Matan Azrad wrote:
> Hi Ferruh
>
>> From: Ferruh Yigit, Wednesday, March 28, 2018 1:38 AM
>> On 3/5/2018 3:12 PM, Matan Azrad wrote:
>>> Hi Ferruh
>>>
>>> From: Ferruh Yigit, Sent: Monday, March 5, 2018 5:07 PM
>>>> On 3/5/2018 2:52 PM, Matan Azrad wrote:
>>>>> HI
>>>>>
>>>>> From: Ferruh Yigit, Sent: Monday, March 5, 2018 1:24 PM
>>>>>> On 1/18/2018 4:35 PM, Matan Azrad wrote:
>>>>>>> rte_eth_dev_data structure is allocated per ethdev port and can be
>>>>>>> used to get a data of the port internally.
>>>>>>>
>>>>>>> rte_eth_dev_attach_secondary tries to find the port identifier
>>>>>>> using rte_eth_dev_data name field comparison and may get an
>>>>>>> identifier of invalid port in case of this port was released by
>>>>>>> the primary process because the port release API doesn't reset the
>> port data.
>>>>>>>
>>>>>>> So, it will be better to reset the port data in release time
>>>>>>> instead of allocation time.
>>>>>>>
>>>>>>> Move the port data reset to the port release API.
>>>>>>>
>>>>>>> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
>>>>>>> process model")
>>>>>>> Cc: stable@dpdk.org
>>>>>>>
>>>>>>> Signed-off-by: Matan Azrad <matan@mellanox.com>
>>>>>>> ---
>>>>>>> lib/librte_ether/rte_ethdev.c | 2 +-
>>>>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>>
>>>>>>> diff --git a/lib/librte_ether/rte_ethdev.c
>>>>>>> b/lib/librte_ether/rte_ethdev.c index 7044159..156231c 100644
>>>>>>> --- a/lib/librte_ether/rte_ethdev.c
>>>>>>> +++ b/lib/librte_ether/rte_ethdev.c
>>>>>>> @@ -204,7 +204,6 @@ struct rte_eth_dev *
>>>>>>> return NULL;
>>>>>>> }
>>>>>>>
>>>>>>> - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct
>>>>>> rte_eth_dev_data));
>>>>>>> eth_dev = eth_dev_get(port_id);
>>>>>>> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
>>>>>> "%s", name);
>>>>>>> eth_dev->data->port_id = port_id; @@ -252,6 +251,7 @@ struct
>>>>>>> rte_eth_dev *
>>>>>>> if (eth_dev == NULL)
>>>>>>> return -EINVAL;
>>>>>>>
>>>>>>> + memset(eth_dev->data, 0, sizeof(struct
>> rte_eth_dev_data));
>>>>>>
>>>>>> Hi Matan,
>>>>>>
>>>>>> What most of the vdev release path does is:
>>>>>>
>>>>>> eth_dev = rte_eth_dev_allocated(...)
>>>>>> rte_free(eth_dev->data->dev_private);
>>>>>> rte_free(eth_dev->data);
>>>>>> rte_eth_dev_release_port(eth_dev);
>>>>>>
>>>>>> Since eth_dev->data freed, memset() it in
>>>>>> rte_eth_dev_release_port() will be problem.
>>>>>>
>>>>>> We don't run remove path that is why we didn't hit the issue but
>>>>>> this seems problem for all virtual PMDs.
>>>>>
>>>>> Yes, it is a problem and should be fixed:
>>>>> For vdevs which use private rte_eth_dev_data the remove order can
>> be:
>>>>> private_data = eth_dev->data;
>>>>> rte_free(eth_dev->data->dev_private);
>>>>> rte_eth_dev_release_port(eth_dev); /* The last operation working
>>>> on ethdev structure. */
>>>>> rte_free(private_data);
>>>>
>>>> Do we need to save "private_data"?
>>>
>>> Just to emphasis that eth_dev structure should not more be available after
>> rte_eth_dev_release_port().
>>> Maybe in the future rte_eth_dev_release_port() will zero eth_dev
>>> structure too :)
>>
>> Hi Matan,
>>
>> Reminder of this issue, it would be nice to fix in this release.
>>
>
> Regarding the private rte_eth_dev_data, it should be fixed in the next thread:
> https://dpdk.org/dev/patchwork/patch/35632/
>
> Regarding the rte_eth_dev_pci_release() function: I'm going to send a fix.
Thanks Matan for the patch,
But rte_eth_dev_release_port() is still broken because of this change, please
check _rte_eth_dev_callback_process() which uses dev->data->port_id.
>
>>>
>>>>>
>>>>>
>>>>>> Also rte_eth_dev_pci_release() looks problematic now.
>>>>>
>>>>> Yes, again, the last operation working on ethdev structure should be
>>>> rte_eth_dev_release_port().
>>>>>
>>>>> So need to fix all vdevs and the rte_eth_dev_pci_release() function.
>>>>>
>>>>> Any comments?
>>>>>
>>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-03-30 10:39 ` Ferruh Yigit
@ 2018-04-19 11:07 ` Ferruh Yigit
2018-04-25 12:16 ` Matan Azrad
0 siblings, 1 reply; 25+ messages in thread
From: Ferruh Yigit @ 2018-04-19 11:07 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable,
Olga Shern
On 3/30/2018 11:39 AM, Ferruh Yigit wrote:
> On 3/28/2018 1:07 PM, Matan Azrad wrote:
>> Hi Ferruh
>>
>>> From: Ferruh Yigit, Wednesday, March 28, 2018 1:38 AM
>>> On 3/5/2018 3:12 PM, Matan Azrad wrote:
>>>> Hi Ferruh
>>>>
>>>> From: Ferruh Yigit, Sent: Monday, March 5, 2018 5:07 PM
>>>>> On 3/5/2018 2:52 PM, Matan Azrad wrote:
>>>>>> HI
>>>>>>
>>>>>> From: Ferruh Yigit, Sent: Monday, March 5, 2018 1:24 PM
>>>>>>> On 1/18/2018 4:35 PM, Matan Azrad wrote:
>>>>>>>> rte_eth_dev_data structure is allocated per ethdev port and can be
>>>>>>>> used to get a data of the port internally.
>>>>>>>>
>>>>>>>> rte_eth_dev_attach_secondary tries to find the port identifier
>>>>>>>> using rte_eth_dev_data name field comparison and may get an
>>>>>>>> identifier of invalid port in case of this port was released by
>>>>>>>> the primary process because the port release API doesn't reset the
>>> port data.
>>>>>>>>
>>>>>>>> So, it will be better to reset the port data in release time
>>>>>>>> instead of allocation time.
>>>>>>>>
>>>>>>>> Move the port data reset to the port release API.
>>>>>>>>
>>>>>>>> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple
>>>>>>>> process model")
>>>>>>>> Cc: stable@dpdk.org
>>>>>>>>
>>>>>>>> Signed-off-by: Matan Azrad <matan@mellanox.com>
>>>>>>>> ---
>>>>>>>> lib/librte_ether/rte_ethdev.c | 2 +-
>>>>>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/lib/librte_ether/rte_ethdev.c
>>>>>>>> b/lib/librte_ether/rte_ethdev.c index 7044159..156231c 100644
>>>>>>>> --- a/lib/librte_ether/rte_ethdev.c
>>>>>>>> +++ b/lib/librte_ether/rte_ethdev.c
>>>>>>>> @@ -204,7 +204,6 @@ struct rte_eth_dev *
>>>>>>>> return NULL;
>>>>>>>> }
>>>>>>>>
>>>>>>>> - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct
>>>>>>> rte_eth_dev_data));
>>>>>>>> eth_dev = eth_dev_get(port_id);
>>>>>>>> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
>>>>>>> "%s", name);
>>>>>>>> eth_dev->data->port_id = port_id; @@ -252,6 +251,7 @@ struct
>>>>>>>> rte_eth_dev *
>>>>>>>> if (eth_dev == NULL)
>>>>>>>> return -EINVAL;
>>>>>>>>
>>>>>>>> + memset(eth_dev->data, 0, sizeof(struct
>>> rte_eth_dev_data));
>>>>>>>
>>>>>>> Hi Matan,
>>>>>>>
>>>>>>> What most of the vdev release path does is:
>>>>>>>
>>>>>>> eth_dev = rte_eth_dev_allocated(...)
>>>>>>> rte_free(eth_dev->data->dev_private);
>>>>>>> rte_free(eth_dev->data);
>>>>>>> rte_eth_dev_release_port(eth_dev);
>>>>>>>
>>>>>>> Since eth_dev->data freed, memset() it in
>>>>>>> rte_eth_dev_release_port() will be problem.
>>>>>>>
>>>>>>> We don't run remove path that is why we didn't hit the issue but
>>>>>>> this seems problem for all virtual PMDs.
>>>>>>
>>>>>> Yes, it is a problem and should be fixed:
>>>>>> For vdevs which use private rte_eth_dev_data the remove order can
>>> be:
>>>>>> private_data = eth_dev->data;
>>>>>> rte_free(eth_dev->data->dev_private);
>>>>>> rte_eth_dev_release_port(eth_dev); /* The last operation working
>>>>> on ethdev structure. */
>>>>>> rte_free(private_data);
>>>>>
>>>>> Do we need to save "private_data"?
>>>>
>>>> Just to emphasis that eth_dev structure should not more be available after
>>> rte_eth_dev_release_port().
>>>> Maybe in the future rte_eth_dev_release_port() will zero eth_dev
>>>> structure too :)
>>>
>>> Hi Matan,
>>>
>>> Reminder of this issue, it would be nice to fix in this release.
>>>
>>
>> Regarding the private rte_eth_dev_data, it should be fixed in the next thread:
>> https://dpdk.org/dev/patchwork/patch/35632/
>>
>> Regarding the rte_eth_dev_pci_release() function: I'm going to send a fix.
>
> Thanks Matan for the patch,
>
> But rte_eth_dev_release_port() is still broken because of this change, please
> check _rte_eth_dev_callback_process() which uses dev->data->port_id.
Hi Matan,
Any update on this?
As mentioned above rte_eth_dev_release_port() is still broken.
Thanks,
ferruh
>
>>
>>>>
>>>>>>
>>>>>>
>>>>>>> Also rte_eth_dev_pci_release() looks problematic now.
>>>>>>
>>>>>> Yes, again, the last operation working on ethdev structure should be
>>>>> rte_eth_dev_release_port().
>>>>>>
>>>>>> So need to fix all vdevs and the rte_eth_dev_pci_release() function.
>>>>>>
>>>>>> Any comments?
>>>>>>
>>>>
>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-04-19 11:07 ` Ferruh Yigit
@ 2018-04-25 12:16 ` Matan Azrad
2018-04-25 12:30 ` [dpdk-stable] [dpdk-dev] " Ori Kam
2018-04-25 12:54 ` [dpdk-stable] " Ferruh Yigit
0 siblings, 2 replies; 25+ messages in thread
From: Matan Azrad @ 2018-04-25 12:16 UTC (permalink / raw)
To: Ferruh Yigit, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable,
Olga Shern
Hi all
From: Ferruh Yigit, Thursday, April 19, 2018 2:08 PM
> > But rte_eth_dev_release_port() is still broken because of this change,
> > please check _rte_eth_dev_callback_process() which uses dev->data-
> >port_id.
The issue is that a DESTROY callback gets port_id=0 all the time, regardless the destroyed port id.
Let's discuss about the fix:
There are 2 options for the DESTROY event meaning:
1. The device is going to be destroyed in the future (a bit after the callbacks calling).
The user may think that there is a valid data in the device structure in the callback time,
Thus, he may use it.
The fix here is to move the callback to the start of the function,
In this time the data field is still valid.
2. The device was already destroyed in the past (a bit before the callbacks calling).
The user should think that there is no any valid data in the device structure in the callback time,
Thus, he doesn't use it.
The issue here:
_rte_eth_dev_callback_process() assumes there is a valid data in the data field all the time,
But in this case the data field is not valid because the device was already destroyed.
Optional fixes:
1. Always keep the data->port_id valid.
2. keep the data->port_id valid only for the _rte_eth_dev_callback_process() call.
2. Change _rte_eth_dev_callback_process() arg from "struct rte_eth_dev *dev" to "uint16_t port_id"
a. Need to change all the calls for this internal API.
I vote to 2.1.
What do you think?
Matan.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-04-25 12:16 ` Matan Azrad
@ 2018-04-25 12:30 ` Ori Kam
2018-04-25 12:54 ` [dpdk-stable] " Ferruh Yigit
1 sibling, 0 replies; 25+ messages in thread
From: Ori Kam @ 2018-04-25 12:30 UTC (permalink / raw)
To: Matan Azrad, Ferruh Yigit, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable,
Olga Shern
Hi
I vote for 2.3.
Ori
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Matan Azrad
> Sent: Wednesday, April 25, 2018 3:16 PM
> To: Ferruh Yigit <ferruh.yigit@intel.com>; Thomas Monjalon
> <thomas@monjalon.net>; Gaetan Rivet <gaetan.rivet@6wind.com>; Jingjing
> Wu <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Neil Horman <nhorman@tuxdriver.com>; Bruce
> Richardson <bruce.richardson@intel.com>; Konstantin Ananyev
> <konstantin.ananyev@intel.com>; stable@dpdk.org; Olga Shern
> <olgas@mellanox.com>
> Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data
> reset timing
>
> Hi all
>
> From: Ferruh Yigit, Thursday, April 19, 2018 2:08 PM
> > > But rte_eth_dev_release_port() is still broken because of this
> > >change, please check _rte_eth_dev_callback_process() which uses
> > >dev->data- port_id.
>
> The issue is that a DESTROY callback gets port_id=0 all the time, regardless
> the destroyed port id.
>
> Let's discuss about the fix:
>
> There are 2 options for the DESTROY event meaning:
>
> 1. The device is going to be destroyed in the future (a bit after the callbacks
> calling).
> The user may think that there is a valid data in the device structure in
> the callback time,
> Thus, he may use it.
> The fix here is to move the callback to the start of the function,
> In this time the data field is still valid.
>
> 2. The device was already destroyed in the past (a bit before the callbacks
> calling).
> The user should think that there is no any valid data in the device
> structure in the callback time,
> Thus, he doesn't use it.
> The issue here:
> _rte_eth_dev_callback_process() assumes there is a valid data in the
> data field all the time,
> But in this case the data field is not valid because the device was
> already destroyed.
> Optional fixes:
> 1. Always keep the data->port_id valid.
> 2. keep the data->port_id valid only for the
> _rte_eth_dev_callback_process() call.
> 3. Change _rte_eth_dev_callback_process() arg from "struct
> rte_eth_dev *dev" to "uint16_t port_id"
> a. Need to change all the calls for this internal API.
>
> I vote to 2.1.
>
>
> What do you think?
>
> Matan.
>
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-04-25 12:16 ` Matan Azrad
2018-04-25 12:30 ` [dpdk-stable] [dpdk-dev] " Ori Kam
@ 2018-04-25 12:54 ` Ferruh Yigit
2018-04-25 14:01 ` Matan Azrad
1 sibling, 1 reply; 25+ messages in thread
From: Ferruh Yigit @ 2018-04-25 12:54 UTC (permalink / raw)
To: Matan Azrad, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable,
Olga Shern
On 4/25/2018 1:16 PM, Matan Azrad wrote:
> Hi all
>
> From: Ferruh Yigit, Thursday, April 19, 2018 2:08 PM
>>> But rte_eth_dev_release_port() is still broken because of this change,
>>> please check _rte_eth_dev_callback_process() which uses dev->data-
>>> port_id.
>
> The issue is that a DESTROY callback gets port_id=0 all the time, regardless the destroyed port id.
>
> Let's discuss about the fix:
>
> There are 2 options for the DESTROY event meaning:
>
> 1. The device is going to be destroyed in the future (a bit after the callbacks calling).
> The user may think that there is a valid data in the device structure in the callback time,
> Thus, he may use it.
> The fix here is to move the callback to the start of the function,
> In this time the data field is still valid.
>
> 2. The device was already destroyed in the past (a bit before the callbacks calling).
> The user should think that there is no any valid data in the device structure in the callback time,
> Thus, he doesn't use it.
> The issue here:
> _rte_eth_dev_callback_process() assumes there is a valid data in the data field all the time,
> But in this case the data field is not valid because the device was already destroyed.
> Optional fixes:
> 1. Always keep the data->port_id valid.
> 2. keep the data->port_id valid only for the _rte_eth_dev_callback_process() call.
> 2. Change _rte_eth_dev_callback_process() arg from "struct rte_eth_dev *dev" to "uint16_t port_id"
> a. Need to change all the calls for this internal API.
>
> I vote to 2.1.
>
>
> What do you think?
What is the concern with 1? It is easy to implement.
And it may be better because if callback called after device destroyed, there is
no guarantee/locking that same port won't be re-used, in the middle of the
callback function rte_eth_dev_data can be updated, no?
>
> Matan.
>
>
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [dpdk-stable] [PATCH v3 1/7] ethdev: fix port data reset timing
2018-04-25 12:54 ` [dpdk-stable] " Ferruh Yigit
@ 2018-04-25 14:01 ` Matan Azrad
0 siblings, 0 replies; 25+ messages in thread
From: Matan Azrad @ 2018-04-25 14:01 UTC (permalink / raw)
To: Ferruh Yigit, Thomas Monjalon, Gaetan Rivet, Jingjing Wu
Cc: dev, Neil Horman, Bruce Richardson, Konstantin Ananyev, stable,
Olga Shern
Hi Ferruh
From: Ferruh Yigit, Wednesday, April 25, 2018 3:54 PM
> On 4/25/2018 1:16 PM, Matan Azrad wrote:
> > Hi all
> >
> > From: Ferruh Yigit, Thursday, April 19, 2018 2:08 PM
> >>> But rte_eth_dev_release_port() is still broken because of this
> >>> change, please check _rte_eth_dev_callback_process() which uses
> >>> dev->data- port_id.
> >
> > The issue is that a DESTROY callback gets port_id=0 all the time, regardless
> the destroyed port id.
> >
> > Let's discuss about the fix:
> >
> > There are 2 options for the DESTROY event meaning:
> >
> > 1. The device is going to be destroyed in the future (a bit after the callbacks
> calling).
> > The user may think that there is a valid data in the device structure in
> the callback time,
> > Thus, he may use it.
> > The fix here is to move the callback to the start of the function,
> > In this time the data field is still valid.
> >
> > 2. The device was already destroyed in the past (a bit before the callbacks
> calling).
> > The user should think that there is no any valid data in the device
> structure in the callback time,
> > Thus, he doesn't use it.
> > The issue here:
> > _rte_eth_dev_callback_process() assumes there is a valid data in the
> data field all the time,
> > But in this case the data field is not valid because the device was
> already destroyed.
> > Optional fixes:
> > 1. Always keep the data->port_id valid.
> > 2. keep the data->port_id valid only for the
> _rte_eth_dev_callback_process() call.
> > 3. Change _rte_eth_dev_callback_process() arg from "struct
> rte_eth_dev *dev" to "uint16_t port_id"
> > a. Need to change all the calls for this internal API.
> >
> > I vote to 2.1.
> >
> >
> > What do you think?
>
> What is the concern with 1? It is easy to implement.
>
Yes, also 2.1 and 2.2 are easy.
> And it may be better because if callback called after device destroyed, there
> is no guarantee/locking that same port won't be re-used, in the middle of the
> callback function rte_eth_dev_data can be updated, no?
>
Good point!
I think we must guarantee no port allocation for the same port id in the callback time.
I also prefer to not call the callbacks in the critical section.
So maybe call it before the locking is better.
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2018-04-25 14:01 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1511870281-15282-1-git-send-email-matan@mellanox.com>
[not found] ` <1515318351-4756-1-git-send-email-matan@mellanox.com>
2018-01-07 9:45 ` [dpdk-stable] [PATCH v2 1/6] ethdev: fix port data reset timing Matan Azrad
[not found] ` <1516293317-30748-1-git-send-email-matan@mellanox.com>
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 1/7] " Matan Azrad
2018-01-18 17:00 ` Thomas Monjalon
2018-01-19 12:38 ` Ananyev, Konstantin
2018-03-05 11:24 ` Ferruh Yigit
2018-03-05 14:52 ` Matan Azrad
2018-03-05 15:06 ` Ferruh Yigit
2018-03-05 15:12 ` Matan Azrad
2018-03-27 22:37 ` Ferruh Yigit
2018-03-28 12:07 ` Matan Azrad
2018-03-30 10:39 ` Ferruh Yigit
2018-04-19 11:07 ` Ferruh Yigit
2018-04-25 12:16 ` Matan Azrad
2018-04-25 12:30 ` [dpdk-stable] [dpdk-dev] " Ori Kam
2018-04-25 12:54 ` [dpdk-stable] " Ferruh Yigit
2018-04-25 14:01 ` Matan Azrad
2018-01-18 16:35 ` [dpdk-stable] [PATCH v3 2/7] ethdev: fix used portid allocation Matan Azrad
2018-01-18 17:00 ` Thomas Monjalon
2018-01-19 12:40 ` Ananyev, Konstantin
2018-01-20 16:48 ` Matan Azrad
2018-01-20 17:26 ` Ananyev, Konstantin
[not found] ` <1516483468-9048-1-git-send-email-matan@mellanox.com>
2018-01-20 21:24 ` [dpdk-stable] [PATCH v4 1/7] ethdev: fix port data reset timing Matan Azrad
2018-01-20 21:24 ` [dpdk-stable] [PATCH v4 2/7] ethdev: fix used portid allocation Matan Azrad
[not found] ` <1516639103-27166-1-git-send-email-matan@mellanox.com>
2018-01-22 16:38 ` [dpdk-stable] [PATCH v5 1/7] ethdev: fix port data reset timing Matan Azrad
2018-01-22 16:38 ` [dpdk-stable] [PATCH v5 2/7] ethdev: fix used portid allocation Matan Azrad
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).