All of lore.kernel.org
 help / color / mirror / Atom feed
From: Slava Ovsiienko <viacheslavo@mellanox.com>
To: Shahaf Shuler <shahafs@mellanox.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [PATCH 2/4] net/mlx5: add reference counter for DV/DR structures
Date: Wed, 3 Apr 2019 13:27:50 +0000	[thread overview]
Message-ID: <AM4PR05MB3265C590528DD8D48C9F94E0D2570@AM4PR05MB3265.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <AM0PR0502MB3795DA8D8D3222682BCDA140C3560@AM0PR0502MB3795.eurprd05.prod.outlook.com>

> -----Original Message-----
> From: Shahaf Shuler
> Sent: Tuesday, April 2, 2019 22:10
> To: Slava Ovsiienko <viacheslavo@mellanox.com>; dev@dpdk.org
> Subject: RE: [PATCH 2/4] net/mlx5: add reference counter for DV/DR
> structures
> 
> Tuesday, April 2, 2019 9:23 AM, Viacheslav Ovsiienko:
> > Subject: [PATCH 2/4] net/mlx5: add reference counter for DV/DR
> > structures
> 
> Same comment about the title.
> 
> >
> > This patch introduces the reference counter for DV/DR flow engine
> > structure, which we are going to share between master and representors
> > in E-Switch configurations over multiport Infiniband device.
> >
> > Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
> > ---
> >  drivers/net/mlx5/mlx5.c | 26 ++++++++++++++++++++++++--
> > drivers/net/mlx5/mlx5.h |  4 ++++
> >  2 files changed, 28 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index
> > 9de122d..79e0c17 100644
> > --- a/drivers/net/mlx5/mlx5.c
> > +++ b/drivers/net/mlx5/mlx5.c
> > @@ -299,7 +299,8 @@ struct mlx5_dev_spawn_data {  #ifdef
> > HAVE_MLX5DV_DR
> >  /**
> >   * Initialize DV/DR related data within private structure.
> > - * This is preparation step for the data sharing.
> > + * Routine checks the reference counter and does actual
> > + * resources creation/iniialization only if counter is zero.
> >   *
> >   * @param[in] priv
> >   *   Pointer to the private device data structure.
> > @@ -314,6 +315,14 @@ struct mlx5_dev_spawn_data {
> >  	int err = 0;
> >  	void *ns;
> >
> > +	assert(sh);
> > +	if (sh->dv_refcnt) {
> > +		/* Shared DV/DR structures is already initialized. */
> > +		sh->dv_refcnt++;
> > +		priv->dv_shared = 1;
> > +		return 0;
> > +	}
> > +	/* Reference counter is zero, we should initialize structures. */
> >  	ns = mlx5dv_dr_create_ns(sh->ctx,
> > MLX5DV_DR_NS_DOMAIN_INGRESS_BYPASS);
> >  	if (!ns) {
> >  		DRV_LOG(ERR, "ingress mlx5dv_dr_create_ns failed"); @@ -
> > 328,6 +337,8 @@ struct mlx5_dev_spawn_data {
> >  		goto error;
> >  	}
> >  	priv->tx_ns = ns;
> > +	sh->dv_refcnt++;
> > +	priv->dv_shared = 1;
> >  	return 0;
> >
> >  error:
> > @@ -352,6 +363,16 @@ struct mlx5_dev_spawn_data {  static void
> > mlx5_free_shared_dv(struct mlx5_priv *priv)  {
> > +	struct mlx5_ibv_shared *sh;
> > +
> > +	if (!priv->dv_shared)
> > +		return;
> > +	priv->dv_shared = 0;
> > +	sh = priv->sh;
> > +	assert(sh);
> > +	assert(sh->dv_refcnt);
> > +	if (sh->dv_refcnt && --sh->dv_refcnt)
> > +		return;
> >  	if (priv->rx_ns) {
> >  		mlx5dv_dr_destroy_ns(priv->rx_ns);
> >  		priv->rx_ns = NULL;
> > @@ -1491,7 +1512,8 @@ struct mlx5_dev_spawn_data {
> >  error:
> >  	if (priv) {
> >  #ifdef HAVE_MLX5DV_DR
> > -		mlx5_free_shared_dv(priv);
> > +		if (priv->sh)
> > +			mlx5_free_shared_dv(priv);
> >  #endif
> >  		if (priv->nl_socket_route >= 0)
> >  			close(priv->nl_socket_route);
> > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> > a3d5f8e..56a2c61 100644
> > --- a/drivers/net/mlx5/mlx5.h
> > +++ b/drivers/net/mlx5/mlx5.h
> > @@ -213,6 +213,9 @@ struct mlx5_ibv_shared {
> >  	char ibdev_name[IBV_SYSFS_NAME_MAX]; /* IB device name. */
> >  	char ibdev_path[IBV_SYSFS_PATH_MAX]; /* IB device path for
> secondary
> > */
> >  	struct ibv_device_attr_ex device_attr; /* Device properties. */
> > +	/* Shared DV/DR flow data section. */
> > +	uint32_t dv_refcnt; /* DV/DR data reference counter. */
> > +	/* Shared interrupt handler section. */
> >  	pthread_mutex_t intr_mutex; /* Interrupt config mutex. */
> >  	uint32_t intr_cnt; /* Interrupt handler reference counter. */
> >  	struct rte_intr_handle intr_handle; /* Interrupt handler for device.
> > */ @@ -244,6 +247,7 @@ struct mlx5_priv {
> >  	unsigned int isolated:1; /* Whether isolated mode is enabled. */
> >  	unsigned int representor:1; /* Device is a port representor. */
> >  	unsigned int master:1; /* Device is a E-Switch master. */
> > +	unsigned int dv_shared:1; /* DV/DR data is shared. */
> 
> Why this flags is needed? Aren't we always going to share?

I think we can get rid of this flag, because it is used for correct cleanup
in device spawning routines If something goes wrong (on error exit)

> 
> 
> >  	uint16_t domain_id; /* Switch domain identifier. */
> >  	uint16_t vport_id; /* Associated VF vport index (if any). */
> >  	int32_t representor_id; /* Port representor identifier. */
> > --
> > 1.8.3.1

  reply	other threads:[~2019-04-03 13:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02  6:22 [PATCH 0/4] support DR/DV flows over shared IB context Viacheslav Ovsiienko
2019-04-02  6:22 ` [PATCH 1/4] net/mlx5: add DV/DR flow data alloc/free routines Viacheslav Ovsiienko
2019-04-02 19:09   ` Shahaf Shuler
2019-04-02  6:22 ` [PATCH 2/4] net/mlx5: add reference counter for DV/DR structures Viacheslav Ovsiienko
2019-04-02 19:09   ` Shahaf Shuler
2019-04-03 13:27     ` Slava Ovsiienko [this message]
2019-04-02  6:22 ` [PATCH 3/4] net/mlx5: share DV/DR flow related structures Viacheslav Ovsiienko
2019-04-02 19:09   ` Shahaf Shuler
2019-04-02  6:22 ` [PATCH 4/4] net/mlx5: add mutex for shared DV/DR structures Viacheslav Ovsiienko
2019-04-02 19:09   ` Shahaf Shuler
2019-04-04 13:04 ` [PATCH v2 0/2] support Direct Rules flows over shared IB context Viacheslav Ovsiienko
2019-04-04 13:04   ` [PATCH v2 1/2] net/mlx5: add Direct Rules flow data alloc/free routines Viacheslav Ovsiienko
2019-04-04 13:04   ` [PATCH v2 2/2] net/mlx5: share Direct Rules/Verbs flow related structures Viacheslav Ovsiienko
2019-04-04 18:57   ` [PATCH v2 0/2] support Direct Rules flows over shared IB context Shahaf Shuler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM4PR05MB3265C590528DD8D48C9F94E0D2570@AM4PR05MB3265.eurprd05.prod.outlook.com \
    --to=viacheslavo@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.