Skip to content

Commit e207b7e

Browse files
Huy Nguyendavem330
authored andcommitted
net/mlx5e: ConnectX-4 firmware support for DCBX
DBCX by default is controlled by firmware where dcbx capability bit is set. In this mode, firmware is responsible for reading/sending the TLV packets from/to the remote partner. This patch sets up the infrastructure to move between HOST/FW DCBX control mode. Signed-off-by: Huy Nguyen <huyn@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 341c5ee commit e207b7e

File tree

3 files changed

+94
-28
lines changed

3 files changed

+94
-28
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ enum {
234234
};
235235

236236
struct mlx5e_dcbx {
237+
enum mlx5_dcbx_oper_mode mode;
237238
struct mlx5e_cee_config cee_cfg; /* pending configuration */
238239

239240
/* The only setting that cannot be read from FW */
@@ -843,6 +844,7 @@ extern const struct ethtool_ops mlx5e_ethtool_ops;
843844
#ifdef CONFIG_MLX5_CORE_EN_DCB
844845
extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops;
845846
int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets);
847+
void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv);
846848
#endif
847849

848850
#ifndef CONFIG_RFS_ACCEL

drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,45 @@
4141
#define MLX5E_CEE_STATE_UP 1
4242
#define MLX5E_CEE_STATE_DOWN 0
4343

44+
/* If dcbx mode is non-host set the dcbx mode to host.
45+
*/
46+
static int mlx5e_dcbnl_set_dcbx_mode(struct mlx5e_priv *priv,
47+
enum mlx5_dcbx_oper_mode mode)
48+
{
49+
struct mlx5_core_dev *mdev = priv->mdev;
50+
u32 param[MLX5_ST_SZ_DW(dcbx_param)];
51+
int err;
52+
53+
err = mlx5_query_port_dcbx_param(mdev, param);
54+
if (err)
55+
return err;
56+
57+
MLX5_SET(dcbx_param, param, version_admin, mode);
58+
if (mode != MLX5E_DCBX_PARAM_VER_OPER_HOST)
59+
MLX5_SET(dcbx_param, param, willing_admin, 1);
60+
61+
return mlx5_set_port_dcbx_param(mdev, param);
62+
}
63+
64+
static int mlx5e_dcbnl_switch_to_host_mode(struct mlx5e_priv *priv)
65+
{
66+
struct mlx5e_dcbx *dcbx = &priv->dcbx;
67+
int err;
68+
69+
if (!MLX5_CAP_GEN(priv->mdev, dcbx))
70+
return 0;
71+
72+
if (dcbx->mode == MLX5E_DCBX_PARAM_VER_OPER_HOST)
73+
return 0;
74+
75+
err = mlx5e_dcbnl_set_dcbx_mode(priv, MLX5E_DCBX_PARAM_VER_OPER_HOST);
76+
if (err)
77+
return err;
78+
79+
dcbx->mode = MLX5E_DCBX_PARAM_VER_OPER_HOST;
80+
return 0;
81+
}
82+
4483
static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev,
4584
struct ieee_ets *ets)
4685
{
@@ -255,6 +294,9 @@ static u8 mlx5e_dcbnl_getdcbx(struct net_device *dev)
255294

256295
static u8 mlx5e_dcbnl_setdcbx(struct net_device *dev, u8 mode)
257296
{
297+
if (mlx5e_dcbnl_switch_to_host_mode(netdev_priv(dev)))
298+
return 1;
299+
258300
if ((mode & DCB_CAP_DCBX_LLD_MANAGED) ||
259301
!(mode & DCB_CAP_DCBX_VER_CEE) ||
260302
!(mode & DCB_CAP_DCBX_VER_IEEE) ||
@@ -637,3 +679,52 @@ const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops = {
637679
.getpfcstate = mlx5e_dcbnl_getpfcstate,
638680
.setpfcstate = mlx5e_dcbnl_setpfcstate,
639681
};
682+
683+
static void mlx5e_dcbnl_query_dcbx_mode(struct mlx5e_priv *priv,
684+
enum mlx5_dcbx_oper_mode *mode)
685+
{
686+
u32 out[MLX5_ST_SZ_DW(dcbx_param)];
687+
688+
*mode = MLX5E_DCBX_PARAM_VER_OPER_HOST;
689+
690+
if (!mlx5_query_port_dcbx_param(priv->mdev, out))
691+
*mode = MLX5_GET(dcbx_param, out, version_oper);
692+
693+
/* From driver's point of view, we only care if the mode
694+
* is host (HOST) or non-host (AUTO)
695+
*/
696+
if (*mode != MLX5E_DCBX_PARAM_VER_OPER_HOST)
697+
*mode = MLX5E_DCBX_PARAM_VER_OPER_AUTO;
698+
}
699+
700+
static void mlx5e_ets_init(struct mlx5e_priv *priv)
701+
{
702+
int i;
703+
struct ieee_ets ets;
704+
705+
memset(&ets, 0, sizeof(ets));
706+
ets.ets_cap = mlx5_max_tc(priv->mdev) + 1;
707+
for (i = 0; i < ets.ets_cap; i++) {
708+
ets.tc_tx_bw[i] = MLX5E_MAX_BW_ALLOC;
709+
ets.tc_tsa[i] = IEEE_8021QAZ_TSA_VENDOR;
710+
ets.prio_tc[i] = i;
711+
}
712+
713+
memcpy(priv->dcbx.tc_tsa, ets.tc_tsa, sizeof(ets.tc_tsa));
714+
715+
/* tclass[prio=0]=1, tclass[prio=1]=0, tclass[prio=i]=i (for i>1) */
716+
ets.prio_tc[0] = 1;
717+
ets.prio_tc[1] = 0;
718+
719+
mlx5e_dcbnl_ieee_setets_core(priv, &ets);
720+
}
721+
722+
void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv)
723+
{
724+
struct mlx5e_dcbx *dcbx = &priv->dcbx;
725+
726+
if (MLX5_CAP_GEN(priv->mdev, dcbx))
727+
mlx5e_dcbnl_query_dcbx_mode(priv, &dcbx->mode);
728+
729+
mlx5e_ets_init(priv);
730+
}

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,33 +3325,6 @@ u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev)
33253325
2 /*sizeof(mlx5e_tx_wqe.inline_hdr_start)*/;
33263326
}
33273327

3328-
#ifdef CONFIG_MLX5_CORE_EN_DCB
3329-
static void mlx5e_ets_init(struct mlx5e_priv *priv)
3330-
{
3331-
struct ieee_ets ets;
3332-
int i;
3333-
3334-
if (!MLX5_CAP_GEN(priv->mdev, ets))
3335-
return;
3336-
3337-
memset(&ets, 0, sizeof(ets));
3338-
ets.ets_cap = mlx5_max_tc(priv->mdev) + 1;
3339-
for (i = 0; i < ets.ets_cap; i++) {
3340-
ets.tc_tx_bw[i] = MLX5E_MAX_BW_ALLOC;
3341-
ets.tc_tsa[i] = IEEE_8021QAZ_TSA_VENDOR;
3342-
ets.prio_tc[i] = i;
3343-
}
3344-
3345-
memcpy(priv->dcbx.tc_tsa, ets.tc_tsa, sizeof(ets.tc_tsa));
3346-
3347-
/* tclass[prio=0]=1, tclass[prio=1]=0, tclass[prio=i]=i (for i>1) */
3348-
ets.prio_tc[0] = 1;
3349-
ets.prio_tc[1] = 0;
3350-
3351-
mlx5e_dcbnl_ieee_setets_core(priv, &ets);
3352-
}
3353-
#endif
3354-
33553328
void mlx5e_build_default_indir_rqt(struct mlx5_core_dev *mdev,
33563329
u32 *indirection_rqt, int len,
33573330
int num_channels)
@@ -3794,7 +3767,7 @@ static int mlx5e_init_nic_tx(struct mlx5e_priv *priv)
37943767
}
37953768

37963769
#ifdef CONFIG_MLX5_CORE_EN_DCB
3797-
mlx5e_ets_init(priv);
3770+
mlx5e_dcbnl_initialize(priv);
37983771
#endif
37993772
return 0;
38003773
}

0 commit comments

Comments
 (0)