[dpdk-dev,v1,1/2] net/mlx5: change eth device reference for secondary process

Message ID 20170824140341.95471-1-xuemingl@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/Intel-compilation fail apply patch file failure
ci/checkpatch success coding style OK

Commit Message

Xueming Li Aug. 24, 2017, 2:03 p.m. UTC
  rte_eth_dev created by primary process were not available in secondary
process, it was not possible to use the primary process local memory
object from a secondary process.

This patch modify the reference of primary rte_eth_dev object, use
local rte_eth_dev secondary process instead.

Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5.h         |  6 ++---
 drivers/net/mlx5/mlx5_ethdev.c  | 52 ++++++++++++++++++++++-------------------
 drivers/net/mlx5/mlx5_fdir.c    |  3 +++
 drivers/net/mlx5/mlx5_rss.c     |  3 +++
 drivers/net/mlx5/mlx5_rxq.c     |  2 ++
 drivers/net/mlx5/mlx5_trigger.c |  4 ++--
 6 files changed, 41 insertions(+), 29 deletions(-)
  

Comments

Nélio Laranjeiro Aug. 25, 2017, 6:52 a.m. UTC | #1
Hi Xueming,

Please see some comments below,

On Thu, Aug 24, 2017 at 10:03:40PM +0800, Xueming Li wrote:
> rte_eth_dev created by primary process were not available in secondary
> process, it was not possible to use the primary process local memory
> object from a secondary process.
> 
> This patch modify the reference of primary rte_eth_dev object, use
> local rte_eth_dev secondary process instead.
> 
> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5.h         |  6 ++---
>  drivers/net/mlx5/mlx5_ethdev.c  | 52 ++++++++++++++++++++++-------------------
>  drivers/net/mlx5/mlx5_fdir.c    |  3 +++
>  drivers/net/mlx5/mlx5_rss.c     |  3 +++
>  drivers/net/mlx5/mlx5_rxq.c     |  2 ++
>  drivers/net/mlx5/mlx5_trigger.c |  4 ++--
>  6 files changed, 41 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
> index f5167e0..fce7dd5 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -1356,17 +1356,17 @@ struct priv *
>   *   0 on success, errno value on failure.
>   */
>  static int
> -priv_set_link(struct priv *priv, int up)
> +mlx5_dev_set_link(struct rte_eth_dev *dev, int up)
>  {
> -	struct rte_eth_dev *dev = priv->dev;
> +	struct priv *priv = dev->data->dev_private;
>  	int err;
>  

This function should lock/unclock priv.

>  	if (up) {
>  		err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
>  		if (err)
>  			return err;
> -		priv_select_tx_function(priv);
> -		priv_select_rx_function(priv);
> +		mlx5_dev_select_tx_function(dev);
> +		mlx5_dev_select_rx_function(dev);

This also induce that those function mlx5_dev_select_rx/tx_function() should
be renamed to:
 priv_dev_select_rx/tx_function(struct *priv, struct rte_eth_dev *dev, ...)

this will avoid the multiple lock/unlocks inside the functions.

> diff --git a/drivers/net/mlx5/mlx5_fdir.c b/drivers/net/mlx5/mlx5_fdir.c
> index 6acc053..0f3b70a 100644
> --- a/drivers/net/mlx5/mlx5_fdir.c
> +++ b/drivers/net/mlx5/mlx5_fdir.c
> @@ -1075,6 +1075,9 @@ struct mlx5_fdir_filter {
>  	int ret = EINVAL;
>  	struct priv *priv = dev->data->dev_private;
>  
> +	if (mlx5_is_secondary())
> +		return -E_RTE_SECONDARY;
> +

Extra empty line also in the following copy/past of this if statement.
>[...]

Thanks,
  
Xueming Li Aug. 25, 2017, 7:15 a.m. UTC | #2
Nelio, thanks, comments inline.

> -----Original Message-----
> From: Nélio Laranjeiro [mailto:nelio.laranjeiro@6wind.com]
> Sent: Friday, August 25, 2017 2:52 PM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: dev@dpdk.org
> Subject: Re: [PATCH v1 1/2] net/mlx5: change eth device reference for
> secondary process
> 
> Hi Xueming,
> 
> Please see some comments below,
> 
> On Thu, Aug 24, 2017 at 10:03:40PM +0800, Xueming Li wrote:
> > rte_eth_dev created by primary process were not available in secondary
> > process, it was not possible to use the primary process local memory
> > object from a secondary process.
> >
> > This patch modify the reference of primary rte_eth_dev object, use
> > local rte_eth_dev secondary process instead.
> >
> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > ---
> >  drivers/net/mlx5/mlx5.h         |  6 ++---
> >  drivers/net/mlx5/mlx5_ethdev.c  | 52 ++++++++++++++++++++++-----------
> --------
> >  drivers/net/mlx5/mlx5_fdir.c    |  3 +++
> >  drivers/net/mlx5/mlx5_rss.c     |  3 +++
> >  drivers/net/mlx5/mlx5_rxq.c     |  2 ++
> >  drivers/net/mlx5/mlx5_trigger.c |  4 ++--
> >  6 files changed, 41 insertions(+), 29 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> > b/drivers/net/mlx5/mlx5_ethdev.c index f5167e0..fce7dd5 100644
> > --- a/drivers/net/mlx5/mlx5_ethdev.c
> > +++ b/drivers/net/mlx5/mlx5_ethdev.c
> > @@ -1356,17 +1356,17 @@ struct priv *
> >   *   0 on success, errno value on failure.
> >   */
> >  static int
> > -priv_set_link(struct priv *priv, int up)
> > +mlx5_dev_set_link(struct rte_eth_dev *dev, int up)
> >  {
> > -	struct rte_eth_dev *dev = priv->dev;
> > +	struct priv *priv = dev->data->dev_private;
> >  	int err;
> >
> 
> This function should lock/unclock priv.
This is a static function, caller function do the lock/unlock. 
Is there naming convention here? Mlx5_* is outpost interfaces that normally require lock/unlock priv?

> 
> >  	if (up) {
> >  		err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
> >  		if (err)
> >  			return err;
> > -		priv_select_tx_function(priv);
> > -		priv_select_rx_function(priv);
> > +		mlx5_dev_select_tx_function(dev);
> > +		mlx5_dev_select_rx_function(dev);
> 
> This also induce that those function mlx5_dev_select_rx/tx_function() should
> be renamed to:
>  priv_dev_select_rx/tx_function(struct *priv, struct rte_eth_dev *dev, ...)
> 
> this will avoid the multiple lock/unlocks inside the functions.
So priv_* are lock-free functions?

> 
> > diff --git a/drivers/net/mlx5/mlx5_fdir.c
> > b/drivers/net/mlx5/mlx5_fdir.c index 6acc053..0f3b70a 100644
> > --- a/drivers/net/mlx5/mlx5_fdir.c
> > +++ b/drivers/net/mlx5/mlx5_fdir.c
> > @@ -1075,6 +1075,9 @@ struct mlx5_fdir_filter {
> >  	int ret = EINVAL;
> >  	struct priv *priv = dev->data->dev_private;
> >
> > +	if (mlx5_is_secondary())
> > +		return -E_RTE_SECONDARY;
> > +
> 
> Extra empty line also in the following copy/past of this if statement.
> >[...]
> 
> Thanks,
> 
> --
> Nélio Laranjeiro
> 6WIND
  
Nélio Laranjeiro Aug. 25, 2017, 7:32 a.m. UTC | #3
On Fri, Aug 25, 2017 at 07:15:50AM +0000, Xueming(Steven) Li wrote:
> Nelio, thanks, comments inline.
>[...]
> > >  static int
> > > -priv_set_link(struct priv *priv, int up)
> > > +mlx5_dev_set_link(struct rte_eth_dev *dev, int up)
> > >  {
> > > -	struct rte_eth_dev *dev = priv->dev;
> > > +	struct priv *priv = dev->data->dev_private;
> > >  	int err;
> > >
> > 
> > This function should lock/unclock priv.
> This is a static function, caller function do the lock/unlock. 
> Is there naming convention here? Mlx5_* is outpost interfaces that normally
> require lock/unlock priv?

Yes there is a naming convention following the patterns:
 - priv_...(struct *priv priv, ...): no locks inside.
 - priv_dev_...(struct *priv priv, struct rte_eth_dev *dev, ...): no locks
   inside.
 - mlx5_...(struct rte_eth_dev *dev, ...): should lock any access to struct priv
   and to priv_*().

> > >  	if (up) {
> > >  		err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
> > >  		if (err)
> > >  			return err;
> > > -		priv_select_tx_function(priv);
> > > -		priv_select_rx_function(priv);
> > > +		mlx5_dev_select_tx_function(dev);
> > > +		mlx5_dev_select_rx_function(dev);
> > 
> > This also induce that those function mlx5_dev_select_rx/tx_function() should
> > be renamed to:
> >  priv_dev_select_rx/tx_function(struct *priv, struct rte_eth_dev *dev, ...)
> > 
> > this will avoid the multiple lock/unlocks inside the functions.
> So priv_* are lock-free functions?

priv_*() assume the lock have been done by the caller.

Hope it helps.

Thanks,
  
Xueming Li Sept. 18, 2017, 2:36 p.m. UTC | #4
This patchset enhances Mellanox multi-process by supporting all multi-process
examples, also support reading ethdev (x)stats in secondary process.

Start from V2, this patchset depends on upstream rdma-core enhancement
and l2fork example bug fix:
http://www.dpdk.org/ml/archives/dev/2017-August/073405.html
http://www.dpdk.org/ml/archives/dev/2017-September/075568.html

V3:
* add cover letter
* add dependency notes

V2:
* split into multiple patches
* support forked secondary process
* add secondary process ethdev operations
* rebase on latest rdma-core upstream api


Xueming Li (6):
  net/mlx5: change eth device reference for secondary process
  net/mlx5: install a socket to exchange a file descriptor
  net/mlx5: allocate verbs object into shared memory
  net/mlx5: remove verbs fork check
  net/mlx5: add operations for secondary process
  net/mlx5: multi-process document update

 doc/guides/nics/features/mlx5.ini |   1 +
 doc/guides/nics/mlx5.rst          |   3 +-
 drivers/net/mlx5/Makefile         |   1 +
 drivers/net/mlx5/mlx5.c           | 112 +++++++++++++--
 drivers/net/mlx5/mlx5.h           |  16 ++-
 drivers/net/mlx5/mlx5_ethdev.c    | 108 +++++++++-----
 drivers/net/mlx5/mlx5_fdir.c      |   2 +
 drivers/net/mlx5/mlx5_rss.c       |   1 +
 drivers/net/mlx5/mlx5_rxq.c       |   1 +
 drivers/net/mlx5/mlx5_rxtx.h      |   2 +
 drivers/net/mlx5/mlx5_socket.c    | 294 ++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_trigger.c   |   4 +-
 drivers/net/mlx5/mlx5_txq.c       |  66 +++++++++
 13 files changed, 561 insertions(+), 50 deletions(-)
 create mode 100644 drivers/net/mlx5/mlx5_socket.c
  
Xueming Li Sept. 19, 2017, 2:31 p.m. UTC | #5
This patchset enhances Mellanox multi-process by supporting all multi-process
examples, also support reading ethdev (x)stats in secondary process.

Start from V2, this patchset depends on upstream rdma-core enhancement
and l2fork example bug fix:
http://www.dpdk.org/ml/archives/dev/2017-August/073405.html
http://www.dpdk.org/ml/archives/dev/2017-September/075568.html

V4:
* remove forked secondary mode

V3:
* add cover letter
* add dependency notes

V2:
* split into multiple patches
* support forked secondary process
* add secondary process ethdev operations
* rebase on latest rdma-core upstream api


Xueming Li (5):
  net/mlx5: change eth device reference for secondary process
  net/mlx5: install a socket to exchange a file descriptor
  net/mlx5: allocate verbs object into shared memory
  net/mlx5: add operations for secondary process
  net/mlx5: multi-process document update

 doc/guides/nics/features/mlx5.ini |   1 +
 doc/guides/nics/mlx5.rst          |   4 +-
 drivers/net/mlx5/Makefile         |   1 +
 drivers/net/mlx5/mlx5.c           | 104 ++++++++++++++
 drivers/net/mlx5/mlx5.h           |  16 ++-
 drivers/net/mlx5/mlx5_ethdev.c    | 108 +++++++++-----
 drivers/net/mlx5/mlx5_fdir.c      |   2 +
 drivers/net/mlx5/mlx5_rss.c       |   1 +
 drivers/net/mlx5/mlx5_rxq.c       |   1 +
 drivers/net/mlx5/mlx5_rxtx.h      |   2 +
 drivers/net/mlx5/mlx5_socket.c    | 294 ++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_trigger.c   |   4 +-
 drivers/net/mlx5/mlx5_txq.c       |  66 +++++++++
 13 files changed, 562 insertions(+), 42 deletions(-)
 create mode 100644 drivers/net/mlx5/mlx5_socket.c
  
Nélio Laranjeiro Sept. 19, 2017, 2:41 p.m. UTC | #6
On Tue, Sep 19, 2017 at 10:31:47PM +0800, Xueming Li wrote:
> This patchset enhances Mellanox multi-process by supporting all multi-process
> examples, also support reading ethdev (x)stats in secondary process.
> 
> Start from V2, this patchset depends on upstream rdma-core enhancement
> and l2fork example bug fix:
> http://www.dpdk.org/ml/archives/dev/2017-August/073405.html
> http://www.dpdk.org/ml/archives/dev/2017-September/075568.html
> 
> V4:
> * remove forked secondary mode

You should not push commits with the ACK of someone who did not review
the modification.
  
Ferruh Yigit Sept. 19, 2017, 2:48 p.m. UTC | #7
On 9/19/2017 3:31 PM, Xueming Li wrote:
> This patchset enhances Mellanox multi-process by supporting all multi-process
> examples, also support reading ethdev (x)stats in secondary process.
> 
> Start from V2, this patchset depends on upstream rdma-core enhancement
> and l2fork example bug fix:
> http://www.dpdk.org/ml/archives/dev/2017-August/073405.html
> http://www.dpdk.org/ml/archives/dev/2017-September/075568.html

Out of curiosity, why this driver patch depends on example app bug fix?

> V4:
> * remove forked secondary mode
> 
> V3:
> * add cover letter
> * add dependency notes
> 
> V2:
> * split into multiple patches
> * support forked secondary process
> * add secondary process ethdev operations
> * rebase on latest rdma-core upstream api
> 
> 
> Xueming Li (5):
>   net/mlx5: change eth device reference for secondary process
>   net/mlx5: install a socket to exchange a file descriptor
>   net/mlx5: allocate verbs object into shared memory
>   net/mlx5: add operations for secondary process
>   net/mlx5: multi-process document update
> 
>  doc/guides/nics/features/mlx5.ini |   1 +
>  doc/guides/nics/mlx5.rst          |   4 +-
>  drivers/net/mlx5/Makefile         |   1 +
>  drivers/net/mlx5/mlx5.c           | 104 ++++++++++++++
>  drivers/net/mlx5/mlx5.h           |  16 ++-
>  drivers/net/mlx5/mlx5_ethdev.c    | 108 +++++++++-----
>  drivers/net/mlx5/mlx5_fdir.c      |   2 +
>  drivers/net/mlx5/mlx5_rss.c       |   1 +
>  drivers/net/mlx5/mlx5_rxq.c       |   1 +
>  drivers/net/mlx5/mlx5_rxtx.h      |   2 +
>  drivers/net/mlx5/mlx5_socket.c    | 294 ++++++++++++++++++++++++++++++++++++++
>  drivers/net/mlx5/mlx5_trigger.c   |   4 +-
>  drivers/net/mlx5/mlx5_txq.c       |  66 +++++++++
>  13 files changed, 562 insertions(+), 42 deletions(-)
>  create mode 100644 drivers/net/mlx5/mlx5_socket.c
>
  
Xueming Li Sept. 19, 2017, 3:02 p.m. UTC | #8
The only example to verify forked mode secondary process - should be 
deleted now as fork support removed in v4

> -----Original Message-----

> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]

> Sent: Tuesday, September 19, 2017 10:48 PM

> To: Xueming(Steven) Li <xuemingl@mellanox.com>; Nélio Laranjeiro

> <nelio.laranjeiro@6wind.com>; Adrien Mazarguil

> <adrien.mazarguil@6wind.com>

> Cc: dev@dpdk.org

> Subject: Re: [dpdk-dev] [PATCH v4 0/5] net/mlx5 multi-process support

> 

> On 9/19/2017 3:31 PM, Xueming Li wrote:

> > This patchset enhances Mellanox multi-process by supporting all

> > multi-process examples, also support reading ethdev (x)stats in

> secondary process.

> >

> > Start from V2, this patchset depends on upstream rdma-core enhancement

> > and l2fork example bug fix:

> > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.

> > dpdk.org%2Fml%2Farchives%2Fdev%2F2017-August%2F073405.html&data=02%7C0

> > 1%7Cxuemingl%40mellanox.com%7Ce4100a14196745c17db308d4ff6d7221%7Ca6529

> > 71c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636414292914587251&sdata=i7zsa3A

> > uSSwREjp25fOd9NHbpOiqrHQ%2B9Os1v6wc%2BiA%3D&reserved=0

> > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.

> > dpdk.org%2Fml%2Farchives%2Fdev%2F2017-September%2F075568.html&data=02%

> > 7C01%7Cxuemingl%40mellanox.com%7Ce4100a14196745c17db308d4ff6d7221%7Ca6

> > 52971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636414292914587251&sdata=tXcz

> > DtwMbPjGcRTbC0O8a7DCVtR5zKIz7%2B3RA5CC0YA%3D&reserved=0

> 

> Out of curiosity, why this driver patch depends on example app bug fix?

> 

> > V4:

> > * remove forked secondary mode

> >

> > V3:

> > * add cover letter

> > * add dependency notes

> >

> > V2:

> > * split into multiple patches

> > * support forked secondary process

> > * add secondary process ethdev operations

> > * rebase on latest rdma-core upstream api

> >

> >

> > Xueming Li (5):

> >   net/mlx5: change eth device reference for secondary process

> >   net/mlx5: install a socket to exchange a file descriptor

> >   net/mlx5: allocate verbs object into shared memory

> >   net/mlx5: add operations for secondary process

> >   net/mlx5: multi-process document update

> >

> >  doc/guides/nics/features/mlx5.ini |   1 +

> >  doc/guides/nics/mlx5.rst          |   4 +-

> >  drivers/net/mlx5/Makefile         |   1 +

> >  drivers/net/mlx5/mlx5.c           | 104 ++++++++++++++

> >  drivers/net/mlx5/mlx5.h           |  16 ++-

> >  drivers/net/mlx5/mlx5_ethdev.c    | 108 +++++++++-----

> >  drivers/net/mlx5/mlx5_fdir.c      |   2 +

> >  drivers/net/mlx5/mlx5_rss.c       |   1 +

> >  drivers/net/mlx5/mlx5_rxq.c       |   1 +

> >  drivers/net/mlx5/mlx5_rxtx.h      |   2 +

> >  drivers/net/mlx5/mlx5_socket.c    | 294

> ++++++++++++++++++++++++++++++++++++++

> >  drivers/net/mlx5/mlx5_trigger.c   |   4 +-

> >  drivers/net/mlx5/mlx5_txq.c       |  66 +++++++++

> >  13 files changed, 562 insertions(+), 42 deletions(-)  create mode

> > 100644 drivers/net/mlx5/mlx5_socket.c

> >
  
Nélio Laranjeiro Sept. 20, 2017, 8:07 a.m. UTC | #9
On Tue, Sep 19, 2017 at 10:31:47PM +0800, Xueming Li wrote:
> This patchset enhances Mellanox multi-process by supporting all multi-process
> examples, also support reading ethdev (x)stats in secondary process.
> 
> Start from V2, this patchset depends on upstream rdma-core enhancement
> and l2fork example bug fix:
> http://www.dpdk.org/ml/archives/dev/2017-August/073405.html
> http://www.dpdk.org/ml/archives/dev/2017-September/075568.html
> 
> V4:
> * remove forked secondary mode

For the V4 series
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
  
Ferruh Yigit Oct. 5, 2017, 12:17 a.m. UTC | #10
On 9/19/2017 3:31 PM, Xueming Li wrote:
> This patchset enhances Mellanox multi-process by supporting all multi-process
> examples, also support reading ethdev (x)stats in secondary process.
> 
> Start from V2, this patchset depends on upstream rdma-core enhancement
> and l2fork example bug fix:
> http://www.dpdk.org/ml/archives/dev/2017-August/073405.html
> http://www.dpdk.org/ml/archives/dev/2017-September/075568.html
> 
> V4:
> * remove forked secondary mode
> 
> V3:
> * add cover letter
> * add dependency notes
> 
> V2:
> * split into multiple patches
> * support forked secondary process
> * add secondary process ethdev operations
> * rebase on latest rdma-core upstream api
> 
> 
> Xueming Li (5):
>   net/mlx5: change eth device reference for secondary process
>   net/mlx5: install a socket to exchange a file descriptor
>   net/mlx5: allocate verbs object into shared memory
>   net/mlx5: add operations for secondary process
>   net/mlx5: multi-process document update

Hi Xueming,

I guess all dependent patches merged into next-net for this patchset, so
can get this one.

But this is causing merge conflicts on latest next-net, can you please
re-base patchset and sent a new version?

Thanks,
ferruh
  
Xueming Li Oct. 6, 2017, 3:45 p.m. UTC | #11
This patchset enhances Mellanox multi-process by supporting all multi-process
examples, also support reading ethdev (x)stats in secondary process.

V5:
* rebase on latest upstream code, patch 2/5 mlx5_ethdev.c updated.

V4:
* remove forked secondary mode

V3:
* add cover letter
* add dependency notes

V2:
* split into multiple patches
* support forked secondary process
* add secondary process ethdev operations
* rebase on latest rdma-core upstream api

Xueming Li (5):
  net/mlx5: change eth device reference for secondary process
  net/mlx5: install a socket to exchange a file descriptor
  net/mlx5: allocate verbs object into shared memory
  net/mlx5: add operations for secondary process
  net/mlx5: multi-process document update

 doc/guides/nics/features/mlx5.ini |   1 +
 doc/guides/nics/mlx5.rst          |   4 +-
 drivers/net/mlx5/Makefile         |   1 +
 drivers/net/mlx5/mlx5.c           | 104 ++++++++++++++
 drivers/net/mlx5/mlx5.h           |  16 ++-
 drivers/net/mlx5/mlx5_ethdev.c    | 112 ++++++++++-----
 drivers/net/mlx5/mlx5_fdir.c      |   2 +
 drivers/net/mlx5/mlx5_rss.c       |   1 +
 drivers/net/mlx5/mlx5_rxq.c       |   1 +
 drivers/net/mlx5/mlx5_rxtx.h      |   2 +
 drivers/net/mlx5/mlx5_socket.c    | 294 ++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_trigger.c   |   4 +-
 drivers/net/mlx5/mlx5_txq.c       |  66 +++++++++
 13 files changed, 564 insertions(+), 44 deletions(-)
 create mode 100644 drivers/net/mlx5/mlx5_socket.c
  
Xueming Li Oct. 6, 2017, 3:52 p.m. UTC | #12
> -----Original Message-----

> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]

> Sent: Thursday, October 5, 2017 8:18 AM

> To: Xueming(Steven) Li <xuemingl@mellanox.com>; Nélio Laranjeiro

> <nelio.laranjeiro@6wind.com>; Adrien Mazarguil

> <adrien.mazarguil@6wind.com>

> Cc: dev@dpdk.org

> Subject: Re: [dpdk-dev] [PATCH v4 0/5] net/mlx5 multi-process support

> 

> On 9/19/2017 3:31 PM, Xueming Li wrote:

> > This patchset enhances Mellanox multi-process by supporting all

> > multi-process examples, also support reading ethdev (x)stats in

> secondary process.

> >

> > Start from V2, this patchset depends on upstream rdma-core enhancement

> > and l2fork example bug fix:

> > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.

> > dpdk.org%2Fml%2Farchives%2Fdev%2F2017-August%2F073405.html&data=02%7C0

> > 1%7Cxuemingl%40mellanox.com%7C298eed4fbcb74aef3d6a08d50b868a08%7Ca6529

> > 71c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636427594843039082&sdata=Rv4%2Bd

> > WocHEGMrPQIbcx0kXiXH40cORcTlCULPohDnRU%3D&reserved=0

> > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.

> > dpdk.org%2Fml%2Farchives%2Fdev%2F2017-September%2F075568.html&data=02%

> > 7C01%7Cxuemingl%40mellanox.com%7C298eed4fbcb74aef3d6a08d50b868a08%7Ca6

> > 52971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636427594843039082&sdata=2Qq%

> > 2FptWHbOt5jWEAemcU0kkbCOQ168RuagK5Mlpv8So%3D&reserved=0

> >

> > V4:

> > * remove forked secondary mode

> >

> > V3:

> > * add cover letter

> > * add dependency notes

> >

> > V2:

> > * split into multiple patches

> > * support forked secondary process

> > * add secondary process ethdev operations

> > * rebase on latest rdma-core upstream api

> >

> >

> > Xueming Li (5):

> >   net/mlx5: change eth device reference for secondary process

> >   net/mlx5: install a socket to exchange a file descriptor

> >   net/mlx5: allocate verbs object into shared memory

> >   net/mlx5: add operations for secondary process

> >   net/mlx5: multi-process document update

> 

> Hi Xueming,

> 

> I guess all dependent patches merged into next-net for this patchset, so

> can get this one.

> 

> But this is causing merge conflicts on latest next-net, can you please

> re-base patchset and sent a new version?

> 

> Thanks,

> Ferruh


Hi Ferruh,

Rebased and v5 uploaded, thanks very much.

Best Regards,
Xueming
  
Ferruh Yigit Oct. 6, 2017, 6:21 p.m. UTC | #13
On 10/6/2017 4:45 PM, Xueming Li wrote:
> 
> This patchset enhances Mellanox multi-process by supporting all multi-process
> examples, also support reading ethdev (x)stats in secondary process.
> 
> V5:
> * rebase on latest upstream code, patch 2/5 mlx5_ethdev.c updated.
> 
> V4:
> * remove forked secondary mode
> 
> V3:
> * add cover letter
> * add dependency notes
> 
> V2:
> * split into multiple patches
> * support forked secondary process
> * add secondary process ethdev operations
> * rebase on latest rdma-core upstream api
> 
> Xueming Li (5):
>   net/mlx5: change eth device reference for secondary process
>   net/mlx5: install a socket to exchange a file descriptor
>   net/mlx5: allocate verbs object into shared memory
>   net/mlx5: add operations for secondary process
>   net/mlx5: multi-process document update

Series applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 684a603..2dee07c 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -95,7 +95,7 @@  struct mlx5_xstats_ctrl {
 };
 
 struct priv {
-	struct rte_eth_dev *dev; /* Ethernet device. */
+	struct rte_eth_dev *dev; /* Ethernet device of master process. */
 	struct ibv_context *ctx; /* Verbs context. */
 	struct ibv_device_attr_ex device_attr; /* Device properties. */
 	struct ibv_pd *pd; /* Protection Domain. */
@@ -223,8 +223,8 @@  int mlx5_ibv_device_to_pci_addr(const struct ibv_device *,
 int mlx5_set_link_down(struct rte_eth_dev *dev);
 int mlx5_set_link_up(struct rte_eth_dev *dev);
 struct priv *mlx5_secondary_data_setup(struct priv *priv);
-void priv_select_tx_function(struct priv *);
-void priv_select_rx_function(struct priv *);
+void mlx5_dev_select_tx_function(struct rte_eth_dev *dev);
+void mlx5_dev_select_rx_function(struct rte_eth_dev *dev);
 
 /* mlx5_mac.c */
 
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index f5167e0..fce7dd5 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1038,7 +1038,7 @@  struct priv *
 	 * burst function again.
 	 */
 	if (!ret)
-		priv_select_rx_function(priv);
+		mlx5_dev_select_rx_function(dev);
 out:
 	priv_unlock(priv);
 	assert(ret >= 0);
@@ -1347,7 +1347,7 @@  struct priv *
 /**
  * Change the link state (UP / DOWN).
  *
- * @param priv
+ * @param dev
  *   Pointer to Ethernet device structure.
  * @param up
  *   Nonzero for link up, otherwise link down.
@@ -1356,17 +1356,17 @@  struct priv *
  *   0 on success, errno value on failure.
  */
 static int
-priv_set_link(struct priv *priv, int up)
+mlx5_dev_set_link(struct rte_eth_dev *dev, int up)
 {
-	struct rte_eth_dev *dev = priv->dev;
+	struct priv *priv = dev->data->dev_private;
 	int err;
 
 	if (up) {
 		err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
 		if (err)
 			return err;
-		priv_select_tx_function(priv);
-		priv_select_rx_function(priv);
+		mlx5_dev_select_tx_function(dev);
+		mlx5_dev_select_rx_function(dev);
 	} else {
 		err = priv_set_flags(priv, ~IFF_UP, ~IFF_UP);
 		if (err)
@@ -1393,7 +1393,7 @@  struct priv *
 	int err;
 
 	priv_lock(priv);
-	err = priv_set_link(priv, 0);
+	err = mlx5_dev_set_link(dev, 0);
 	priv_unlock(priv);
 	return err;
 }
@@ -1414,7 +1414,7 @@  struct priv *
 	int err;
 
 	priv_lock(priv);
-	err = priv_set_link(priv, 1);
+	err = mlx5_dev_set_link(dev, 1);
 	priv_unlock(priv);
 	return err;
 }
@@ -1560,8 +1560,8 @@  struct priv *
 	rte_mb();
 	priv->dev->data = &sd->data;
 	rte_mb();
-	priv_select_tx_function(priv);
-	priv_select_rx_function(priv);
+	mlx5_dev_select_tx_function(priv->dev);
+	mlx5_dev_select_rx_function(priv->dev);
 	priv_unlock(priv);
 end:
 	/* More sanity checks. */
@@ -1579,30 +1579,32 @@  struct priv *
 /**
  * Configure the TX function to use.
  *
- * @param priv
- *   Pointer to private structure.
+ * @param dev
+ *   Pointer to device structure.
  */
 void
-priv_select_tx_function(struct priv *priv)
+mlx5_dev_select_tx_function(struct rte_eth_dev *dev)
 {
-	priv->dev->tx_pkt_burst = mlx5_tx_burst;
+	struct priv *priv = dev->data->dev_private;
+
+	dev->tx_pkt_burst = mlx5_tx_burst;
 	/* Select appropriate TX function. */
 	if (priv->mps == MLX5_MPW_ENHANCED) {
 		if (priv_check_vec_tx_support(priv) > 0) {
 			if (priv_check_raw_vec_tx_support(priv) > 0)
-				priv->dev->tx_pkt_burst = mlx5_tx_burst_raw_vec;
+				dev->tx_pkt_burst = mlx5_tx_burst_raw_vec;
 			else
-				priv->dev->tx_pkt_burst = mlx5_tx_burst_vec;
+				dev->tx_pkt_burst = mlx5_tx_burst_vec;
 			DEBUG("selected Enhanced MPW TX vectorized function");
 		} else {
-			priv->dev->tx_pkt_burst = mlx5_tx_burst_empw;
+			dev->tx_pkt_burst = mlx5_tx_burst_empw;
 			DEBUG("selected Enhanced MPW TX function");
 		}
 	} else if (priv->mps && priv->txq_inline) {
-		priv->dev->tx_pkt_burst = mlx5_tx_burst_mpw_inline;
+		dev->tx_pkt_burst = mlx5_tx_burst_mpw_inline;
 		DEBUG("selected MPW inline TX function");
 	} else if (priv->mps) {
-		priv->dev->tx_pkt_burst = mlx5_tx_burst_mpw;
+		dev->tx_pkt_burst = mlx5_tx_burst_mpw;
 		DEBUG("selected MPW TX function");
 	}
 }
@@ -1610,17 +1612,19 @@  struct priv *
 /**
  * Configure the RX function to use.
  *
- * @param priv
- *   Pointer to private structure.
+ * @param dev
+ *   Pointer to device structure.
  */
 void
-priv_select_rx_function(struct priv *priv)
+mlx5_dev_select_rx_function(struct rte_eth_dev *dev)
 {
+	struct priv *priv = dev->data->dev_private;
+
 	if (priv_check_vec_rx_support(priv) > 0) {
 		priv_prep_vec_rx_function(priv);
-		priv->dev->rx_pkt_burst = mlx5_rx_burst_vec;
+		dev->rx_pkt_burst = mlx5_rx_burst_vec;
 		DEBUG("selected RX vectorized function");
 	} else {
-		priv->dev->rx_pkt_burst = mlx5_rx_burst;
+		dev->rx_pkt_burst = mlx5_rx_burst;
 	}
 }
diff --git a/drivers/net/mlx5/mlx5_fdir.c b/drivers/net/mlx5/mlx5_fdir.c
index 6acc053..0f3b70a 100644
--- a/drivers/net/mlx5/mlx5_fdir.c
+++ b/drivers/net/mlx5/mlx5_fdir.c
@@ -1075,6 +1075,9 @@  struct mlx5_fdir_filter {
 	int ret = EINVAL;
 	struct priv *priv = dev->data->dev_private;
 
+	if (mlx5_is_secondary())
+		return -E_RTE_SECONDARY;
+
 	switch (filter_type) {
 	case RTE_ETH_FILTER_GENERIC:
 		if (filter_op != RTE_ETH_FILTER_GET)
diff --git a/drivers/net/mlx5/mlx5_rss.c b/drivers/net/mlx5/mlx5_rss.c
index a2dd7d1..7fd1ac1 100644
--- a/drivers/net/mlx5/mlx5_rss.c
+++ b/drivers/net/mlx5/mlx5_rss.c
@@ -357,6 +357,9 @@ 
 	int ret;
 	struct priv *priv = dev->data->dev_private;
 
+	if (mlx5_is_secondary())
+		return -E_RTE_SECONDARY;
+
 	mlx5_dev_stop(dev);
 	priv_lock(priv);
 	ret = priv_dev_rss_reta_update(priv, reta_conf, reta_size);
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index da9f2f7..18e711e 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1376,6 +1376,8 @@ 
 	unsigned int count = 0;
 	struct rte_intr_handle *intr_handle = priv->dev->intr_handle;
 
+	assert(!mlx5_is_secondary());
+
 	if (!priv->dev->data->dev_conf.intr_conf.rxq)
 		return 0;
 	priv_rx_intr_vec_disable(priv);
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index 595a9e0..5e7f979 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -73,8 +73,8 @@ 
 		return 0;
 	}
 	/* Update Rx/Tx callback. */
-	priv_select_tx_function(priv);
-	priv_select_rx_function(priv);
+	mlx5_dev_select_tx_function(dev);
+	mlx5_dev_select_rx_function(dev);
 	DEBUG("%p: allocating and configuring hash RX queues", (void *)dev);
 	err = priv_create_hash_rxqs(priv);
 	if (!err)