DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Andrew Rybchenko <arybchenko@solarflare.com>,
	Slava Ovsiienko <viacheslavo@mellanox.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 04/13] ethdev: change promiscuous callbacks to return status
Date: Tue, 10 Sep 2019 07:53:48 +0000	[thread overview]
Message-ID: <AM0PR0502MB4019BFF272C9B1184F4B419CD2B60@AM0PR0502MB4019.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <1568030331-16526-5-git-send-email-arybchenko@solarflare.com>

Hi

Review for mlx5 part:

Added not very important comment below.
You can stay it as is if no new version will be created.

Acked-by: Matan Azrad <matan@mellanox.com>

Thanks.

From: Andrew Rybchenko
> Enabling/disabling of promiscuous mode is not always successful and
> it should be taken into account to be able to handle it properly.
> 
> When correct return status is unclear from driver code, -EAGAIN is used.
> 
>  drivers/net/mlx4/mlx4.h                   |  4 +-
>  drivers/net/mlx4/mlx4_ethdev.c            | 24 ++++++++---
>  drivers/net/mlx5/mlx5.h                   |  4 +-
>  drivers/net/mlx5/mlx5_rxmode.c            | 40 ++++++++++++++---
> 
>  static void
> diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h
> index 7730b530af..21517d70a2 100644
> --- a/drivers/net/mlx4/mlx4.h
> +++ b/drivers/net/mlx4/mlx4.h
> @@ -205,8 +205,8 @@ int mlx4_mtu_get(struct mlx4_priv *priv, uint16_t
> *mtu);
>  int mlx4_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
>  int mlx4_dev_set_link_down(struct rte_eth_dev *dev);
>  int mlx4_dev_set_link_up(struct rte_eth_dev *dev);
> -void mlx4_promiscuous_enable(struct rte_eth_dev *dev);
> -void mlx4_promiscuous_disable(struct rte_eth_dev *dev);
> +int mlx4_promiscuous_enable(struct rte_eth_dev *dev);
> +int mlx4_promiscuous_disable(struct rte_eth_dev *dev);
>  void mlx4_allmulticast_enable(struct rte_eth_dev *dev);
>  void mlx4_allmulticast_disable(struct rte_eth_dev *dev);
>  void mlx4_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
> diff --git a/drivers/net/mlx4/mlx4_ethdev.c
> b/drivers/net/mlx4/mlx4_ethdev.c
> index 623ebd88cb..c8a73bc1f4 100644
> --- a/drivers/net/mlx4/mlx4_ethdev.c
> +++ b/drivers/net/mlx4/mlx4_ethdev.c
> @@ -341,13 +341,17 @@ enum rxmode_toggle {
>   *   Pointer to Ethernet device structure.
>   * @param toggle
>   *   Toggle to set.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
>   */
> -static void
> +static int
>  mlx4_rxmode_toggle(struct rte_eth_dev *dev, enum rxmode_toggle
> toggle)
>  {
>  	struct mlx4_priv *priv = dev->data->dev_private;
>  	const char *mode;
>  	struct rte_flow_error error;
> +	int ret;
> 
>  	switch (toggle) {
>  	case RXMODE_TOGGLE_PROMISC_OFF:
> @@ -363,12 +367,16 @@ mlx4_rxmode_toggle(struct rte_eth_dev *dev,
> enum rxmode_toggle toggle)
>  	default:
>  		mode = "undefined";
>  	}
> -	if (!mlx4_flow_sync(priv, &error))
> -		return;
> +
> +	ret = mlx4_flow_sync(priv, &error);
> +	if (!ret)
> +		return 0;
> +
>  	ERROR("cannot toggle %s mode (code %d, \"%s\"),"
>  	      " flow error type %d, cause %p, message: %s",
>  	      mode, rte_errno, strerror(rte_errno), error.type, error.cause,
>  	      error.message ? error.message : "(unspecified)");
> +	return ret;
>  }
> 
>  /**
> @@ -376,8 +384,11 @@ mlx4_rxmode_toggle(struct rte_eth_dev *dev,
> enum rxmode_toggle toggle)
>   *
>   * @param dev
>   *   Pointer to Ethernet device structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
>   */
> -void
> +int
>  mlx4_promiscuous_enable(struct rte_eth_dev *dev)
>  {
>  	mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_PROMISC_ON);
> @@ -388,8 +399,11 @@ mlx4_promiscuous_enable(struct rte_eth_dev
> *dev)
>   *
>   * @param dev
>   *   Pointer to Ethernet device structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
>   */
> -void
> +int
>  mlx4_promiscuous_disable(struct rte_eth_dev *dev)
>  {
>  	mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_PROMISC_OFF);
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
> index 8ddbb7a17c..11d540c3a5 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -752,8 +752,8 @@ int mlx5_dev_rss_reta_update(struct rte_eth_dev
> *dev,
> 
>  /* mlx5_rxmode.c */
> 
> -void mlx5_promiscuous_enable(struct rte_eth_dev *dev);
> -void mlx5_promiscuous_disable(struct rte_eth_dev *dev);
> +int mlx5_promiscuous_enable(struct rte_eth_dev *dev);
> +int mlx5_promiscuous_disable(struct rte_eth_dev *dev);
>  void mlx5_allmulticast_enable(struct rte_eth_dev *dev);
>  void mlx5_allmulticast_disable(struct rte_eth_dev *dev);
> 
> diff --git a/drivers/net/mlx5/mlx5_rxmode.c
> b/drivers/net/mlx5/mlx5_rxmode.c
> index d5077db0db..c862fc9520 100644
> --- a/drivers/net/mlx5/mlx5_rxmode.c
> +++ b/drivers/net/mlx5/mlx5_rxmode.c
> @@ -28,8 +28,11 @@
>   *
>   * @param dev
>   *   Pointer to Ethernet device structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
>   */
> -void
> +int
>  mlx5_promiscuous_enable(struct rte_eth_dev *dev)
>  {
>  	struct mlx5_priv *priv = dev->data->dev_private;
> @@ -41,14 +44,24 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev)
>  			"port %u cannot enable promiscuous mode"
>  			" in flow isolation mode",
>  			dev->data->port_id);
> -		return;
> +		return 0;
> +	}
> +	if (priv->config.vf) {
> +		ret = mlx5_nl_promisc(dev, 1);
> +		if (ret)
> +			goto error;

No need the jump, just return ret here and below.

>  	}
> -	if (priv->config.vf)
> -		mlx5_nl_promisc(dev, 1);
>  	ret = mlx5_traffic_restart(dev);
>  	if (ret)
>  		DRV_LOG(ERR, "port %u cannot enable promiscuous mode:
> %s",
>  			dev->data->port_id, strerror(rte_errno));
> +
> +error:
> +	/*
> +	 * rte_eth_dev_promiscuous_enable() rollback
> +	 * dev->data->promiscuous in the case of failure.
> +	 */
> +	return ret;
>  }
> 
>  /**
> @@ -56,20 +69,33 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev)
>   *
>   * @param dev
>   *   Pointer to Ethernet device structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
>   */
> -void
> +int
>  mlx5_promiscuous_disable(struct rte_eth_dev *dev)
>  {
>  	struct mlx5_priv *priv = dev->data->dev_private;
>  	int ret;
> 
>  	dev->data->promiscuous = 0;
> -	if (priv->config.vf)
> -		mlx5_nl_promisc(dev, 0);
> +	if (priv->config.vf) {
> +		ret = mlx5_nl_promisc(dev, 0);
> +		if (ret)
> +			goto error;

Same here.

> +	}
>  	ret = mlx5_traffic_restart(dev);
>  	if (ret)
>  		DRV_LOG(ERR, "port %u cannot disable promiscuous mode:
> %s",
>  			dev->data->port_id, strerror(rte_errno));
> +
> +error:
> +	/*
> +	 * rte_eth_dev_promiscuous_disable() rollback
> +	 * dev->data->promiscuous in the case of failure.
> +	 */
> +	return ret;
>  }
> 
>  /**

  reply	other threads:[~2019-09-10  7:53 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 16:10 [dpdk-dev] [PATCH 00/13] ethdev: change promiscuous mode functions " Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 01/13] ethdev: change promiscuous mode controllers to return errors Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 02/13] net/failsafe: check code of promiscuous mode switch Andrew Rybchenko
2019-09-05 16:25   ` Gaëtan Rivet
2019-09-05 16:32     ` Andrew Rybchenko
2019-09-05 16:36   ` Stephen Hemminger
2019-09-05 16:38     ` Andrew Rybchenko
2019-09-06  9:24       ` Gaëtan Rivet
2019-09-06 10:08         ` Andrew Rybchenko
2019-09-05 16:40   ` Stephen Hemminger
2019-09-05 16:49     ` Andrew Rybchenko
2019-09-05 17:13       ` Stephen Hemminger
2019-09-05 16:10 ` [dpdk-dev] [PATCH 03/13] net/bonding: " Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 04/13] ethdev: change promiscuous callbacks to return status Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 05/13] ethdev: do nothing if promiscuous mode is applied again Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 06/13] app/pipeline: check code of promiscuous mode switch Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 07/13] app/testpmd: " Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 08/13] app/eventdev: " Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 09/13] app/pdump: " Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 10/13] app/test: " Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 11/13] kni: " Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 12/13] test/bonding: " Andrew Rybchenko
2019-09-05 16:10 ` [dpdk-dev] [PATCH 13/13] examples: take promiscuous mode switch result into account Andrew Rybchenko
2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 00/13] ethdev: change promiscuous mode functions to return status Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 01/13] ethdev: change promiscuous mode controllers to return errors Andrew Rybchenko
2019-09-13 15:35     ` Ferruh Yigit
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 02/13] net/failsafe: check code of promiscuous mode switch Andrew Rybchenko
2019-09-09 12:48     ` Gaëtan Rivet
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 03/13] net/bonding: " Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 04/13] ethdev: change promiscuous callbacks to return status Andrew Rybchenko
2019-09-10  7:53     ` Matan Azrad [this message]
2019-09-13 21:05       ` Andrew Rybchenko
2019-09-11  8:46     ` Hyong Youb Kim (hyonkim)
2019-09-13 21:06       ` Andrew Rybchenko
2019-09-16  6:48         ` Hyong Youb Kim (hyonkim)
2019-09-13 15:34     ` Ferruh Yigit
2019-09-13 15:54       ` Andrew Rybchenko
2019-09-13 16:33         ` Ferruh Yigit
2019-09-13 15:39     ` Ferruh Yigit
2019-09-13 16:05       ` Andrew Rybchenko
2019-09-13 16:34         ` Ferruh Yigit
2019-09-13 19:57           ` Andrew Rybchenko
2019-09-16 13:22             ` Ferruh Yigit
2019-09-16 15:45               ` Andrew Rybchenko
2019-09-16 15:58                 ` Ferruh Yigit
2019-09-13 16:43     ` Ferruh Yigit
2019-09-13 20:33       ` Andrew Rybchenko
2019-09-13 16:56     ` Ferruh Yigit
2019-09-13 20:38       ` Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 05/13] ethdev: do nothing if promiscuous mode is applied again Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 06/13] app/pipeline: check code of promiscuous mode switch Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 07/13] app/testpmd: " Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 08/13] app/eventdev: " Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 09/13] app/pdump: " Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 10/13] app/test: " Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 11/13] kni: " Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 12/13] test/bonding: " Andrew Rybchenko
2019-09-09 11:58   ` [dpdk-dev] [PATCH v2 13/13] examples: take promiscuous mode switch result into account Andrew Rybchenko
2019-09-13 16:40     ` Ferruh Yigit
2019-09-13 18:30       ` Andrew Rybchenko
2019-09-13 16:37   ` [dpdk-dev] [PATCH v2 00/13] ethdev: change promiscuous mode functions to return status Ferruh Yigit
2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 " Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 01/13] ethdev: change promiscuous mode controllers to return errors Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 02/13] net/failsafe: check code of promiscuous mode switch Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 03/13] net/bonding: " Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 04/13] ethdev: change promiscuous callbacks to return status Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 05/13] ethdev: do nothing if promiscuous mode is applied again Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 06/13] app/pipeline: check code of promiscuous mode switch Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 07/13] app/testpmd: " Andrew Rybchenko
2019-09-16 13:18     ` Iremonger, Bernard
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 08/13] app/eventdev: " Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 09/13] app/pdump: " Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 10/13] app/test: " Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 11/13] kni: " Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 12/13] test/bonding: " Andrew Rybchenko
2019-09-14 11:37   ` [dpdk-dev] [PATCH v3 13/13] examples: take promiscuous mode switch result into account Andrew Rybchenko
2019-09-24  7:31   ` [dpdk-dev] [PATCH v3 00/13] ethdev: change promiscuous mode functions to return status Ferruh Yigit

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=AM0PR0502MB4019BFF272C9B1184F4B419CD2B60@AM0PR0502MB4019.eurprd05.prod.outlook.com \
    --to=matan@mellanox.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=viacheslavo@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 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).