All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Huy Nguyen <huyn@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [PATCH net-next 5/6] net/mlx5e: Add DCBX control interface
Date: Tue, 30 Aug 2016 14:29:54 +0300	[thread overview]
Message-ID: <1472556595-9286-6-git-send-email-saeedm@mellanox.com> (raw)
In-Reply-To: <1472556595-9286-1-git-send-email-saeedm@mellanox.com>

From: Huy Nguyen <huyn@mellanox.com>

1. Use setdcbx interface to set the DCBX mode to firmware or os.
   If setdcbx is called with mode value of zero, the DCBX mode
   is set to firmware.

2. Add private ethtool flag "qos_with_dcbx_by_fw". When this
   flag is "On", the DCBX is forced to firmware mode.

Signed-off-by: Huy Nguyen <huyn@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h       |  2 ++
 drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 24 ++++++++++++++++++++-
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c   | 25 ++++++++++++++++++++++
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 806f5e8..501b1e4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -158,10 +158,12 @@ struct mlx5e_umr_wqe {
 
 static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
 	"rx_cqe_moder",
+	"qos_with_dcbx_by_fw",
 };
 
 enum mlx5e_priv_flag {
 	MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0),
+	MLX5E_PFLAG_QOS_WITH_DCBX_BY_FW = (1 << 1),
 };
 
 #define MLX5E_SET_PRIV_FLAG(priv, pflag, enable)    \
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index 5d1b402..6c739c1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -54,6 +54,9 @@ static inline bool mlx5e_dcbnl_is_allowed(struct mlx5e_priv *priv)
 	if (dcbx->mode == MLX5E_DCBX_PARAM_VER_OPER_HOST)
 		return true;
 
+	if (priv->pflags & MLX5E_PFLAG_QOS_WITH_DCBX_BY_FW)
+		return true;
+
 	if (mlx5e_dcbnl_set_dcbx_mode(priv, MLX5E_DCBX_PARAM_VER_OPER_HOST))
 		return false;
 
@@ -283,13 +286,32 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
 
 static u8 mlx5e_dcbnl_getdcbx(struct net_device *dev)
 {
-	return DCB_CAP_DCBX_HOST |
+	struct mlx5e_priv *priv = netdev_priv(dev);
+	struct mlx5e_dcbx *dcbx = &priv->dcbx;
+	u8 mode = 0;
+
+	if (dcbx->mode == MLX5E_DCBX_PARAM_VER_OPER_HOST)
+		mode = DCB_CAP_DCBX_HOST;
+
+	return mode |
 	       DCB_CAP_DCBX_VER_IEEE |
 	       DCB_CAP_DCBX_VER_CEE;
 }
 
 static u8 mlx5e_dcbnl_setdcbx(struct net_device *dev, u8 mode)
 {
+	struct mlx5e_priv *priv = netdev_priv(dev);
+	struct mlx5e_dcbx *dcbx = &priv->dcbx;
+
+	if ((!mode) && MLX5_CAP_GEN(priv->mdev, dcbx)) {
+		/* set dcbx to fw controlled */
+		if (dcbx->mode == MLX5E_DCBX_PARAM_VER_OPER_HOST)
+			if (!mlx5e_dcbnl_set_dcbx_mode(priv, MLX5E_DCBX_PARAM_VER_OPER_AUTO))
+				dcbx->mode = MLX5E_DCBX_PARAM_VER_OPER_AUTO;
+
+		return 0;
+	}
+
 	if (!mlx5e_dcbnl_is_allowed(netdev_priv(dev)))
 		return 1;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index d1cd156..9bc26cd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1460,6 +1460,25 @@ static int mlx5e_handle_pflag(struct net_device *netdev,
 	return 0;
 }
 
+#ifdef CONFIG_MLX5_CORE_EN_DCB
+static int qos_with_dcbx_by_fw_handler(struct net_device *netdev, bool enable)
+{
+	struct mlx5e_priv *priv = netdev_priv(netdev);
+
+	if (!MLX5_CAP_GEN(priv->mdev, dcbx))
+		return -EPERM;
+
+	if (!enable)
+		return 0;
+
+	/* Not allow to turn on the flag if the dcbx mode is host */
+	if (priv->dcbx.mode == MLX5E_DCBX_PARAM_VER_OPER_HOST)
+		return -EPERM;
+
+	return 0;
+}
+#endif
+
 static int mlx5e_set_priv_flags(struct net_device *netdev, u32 pflags)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -1471,6 +1490,12 @@ static int mlx5e_set_priv_flags(struct net_device *netdev, u32 pflags)
 				 MLX5E_PFLAG_RX_CQE_BASED_MODER,
 				 set_pflag_rx_cqe_based_moder);
 
+#ifdef CONFIG_MLX5_CORE_EN_DCB
+	err  = mlx5e_handle_pflag(netdev, pflags,
+				  MLX5E_PFLAG_QOS_WITH_DCBX_BY_FW,
+				  qos_with_dcbx_by_fw_handler);
+#endif
+
 	mutex_unlock(&priv->state_lock);
 	return err ? -EINVAL : 0;
 }
-- 
2.7.4

  parent reply	other threads:[~2016-08-30 11:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30 11:29 [PATCH net-next 0/6] Mellanox 100G mlx5 DCBX CEE and firmware support Saeed Mahameed
2016-08-30 11:29 ` [PATCH net-next 1/6] net/mlx5e: Support DCBX CEE API Saeed Mahameed
2016-08-30 20:33   ` Or Gerlitz
2016-08-30 11:29 ` [PATCH net-next 2/6] net/mlx5e: Read ETS settings directly from firmware Saeed Mahameed
2016-08-30 20:34   ` Or Gerlitz
2016-08-30 11:29 ` [PATCH net-next 3/6] net/mlx5: Add DCBX firmware commands support Saeed Mahameed
2016-08-31 11:24   ` zhuyj
2016-08-31 14:49     ` Huy Nguyen
2016-08-31 16:08     ` Saeed Mahameed
2016-08-30 11:29 ` [PATCH net-next 4/6] net/mlx5e: ConnectX-4 firmware support for DCBX Saeed Mahameed
2016-08-30 11:29 ` Saeed Mahameed [this message]
2016-08-30 11:29 ` [PATCH net-next 6/6] net/mlx5: Add handling for port module event Saeed Mahameed
2016-08-30 20:24   ` Or Gerlitz
2016-08-31 11:05     ` Saeed Mahameed

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=1472556595-9286-6-git-send-email-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=huyn@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /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.