mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-10 07:10:27 +00:00
net/mlxe5: Separate between FEC and current speed
FEC mode is per link type, not necessary per speed. This patch access FEC register by link modes instead of speeds. This patch will allow further enhacment of link modes supporting FEC with the same speed (different lane type). Signed-off-by: Aya Levin <ayal@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
parent
2132b71f78
commit
3c19208ea9
@ -343,64 +343,45 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static u32 fec_supported_speeds[] = {
|
||||
10000,
|
||||
40000,
|
||||
25000,
|
||||
50000,
|
||||
56000,
|
||||
100000
|
||||
enum mlx5e_fec_supported_link_mode {
|
||||
MLX5E_FEC_SUPPORTED_LINK_MODES_10G_40G,
|
||||
MLX5E_FEC_SUPPORTED_LINK_MODES_25G,
|
||||
MLX5E_FEC_SUPPORTED_LINK_MODES_50G,
|
||||
MLX5E_FEC_SUPPORTED_LINK_MODES_56G,
|
||||
MLX5E_FEC_SUPPORTED_LINK_MODES_100G,
|
||||
MLX5E_MAX_FEC_SUPPORTED_LINK_MODE,
|
||||
};
|
||||
|
||||
#define MLX5E_FEC_SUPPORTED_SPEEDS ARRAY_SIZE(fec_supported_speeds)
|
||||
#define MLX5E_FEC_OVERRIDE_ADMIN_POLICY(buf, policy, write, link) \
|
||||
do { \
|
||||
u8 *_policy = &(policy); \
|
||||
u32 *_buf = buf; \
|
||||
\
|
||||
if (write) \
|
||||
MLX5_SET(pplm_reg, _buf, fec_override_admin_##link, *_policy); \
|
||||
else \
|
||||
*_policy = MLX5_GET(pplm_reg, _buf, fec_override_admin_##link); \
|
||||
} while (0)
|
||||
|
||||
/* get/set FEC admin field for a given speed */
|
||||
static int mlx5e_fec_admin_field(u32 *pplm,
|
||||
u8 *fec_policy,
|
||||
bool write,
|
||||
u32 speed)
|
||||
static int mlx5e_fec_admin_field(u32 *pplm, u8 *fec_policy, bool write,
|
||||
enum mlx5e_fec_supported_link_mode link_mode)
|
||||
{
|
||||
switch (speed) {
|
||||
case 10000:
|
||||
case 40000:
|
||||
if (!write)
|
||||
*fec_policy = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_admin_10g_40g);
|
||||
else
|
||||
MLX5_SET(pplm_reg, pplm,
|
||||
fec_override_admin_10g_40g, *fec_policy);
|
||||
switch (link_mode) {
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_10G_40G:
|
||||
MLX5E_FEC_OVERRIDE_ADMIN_POLICY(pplm, *fec_policy, write, 10g_40g);
|
||||
break;
|
||||
case 25000:
|
||||
if (!write)
|
||||
*fec_policy = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_admin_25g);
|
||||
else
|
||||
MLX5_SET(pplm_reg, pplm,
|
||||
fec_override_admin_25g, *fec_policy);
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_25G:
|
||||
MLX5E_FEC_OVERRIDE_ADMIN_POLICY(pplm, *fec_policy, write, 25g);
|
||||
break;
|
||||
case 50000:
|
||||
if (!write)
|
||||
*fec_policy = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_admin_50g);
|
||||
else
|
||||
MLX5_SET(pplm_reg, pplm,
|
||||
fec_override_admin_50g, *fec_policy);
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_50G:
|
||||
MLX5E_FEC_OVERRIDE_ADMIN_POLICY(pplm, *fec_policy, write, 50g);
|
||||
break;
|
||||
case 56000:
|
||||
if (!write)
|
||||
*fec_policy = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_admin_56g);
|
||||
else
|
||||
MLX5_SET(pplm_reg, pplm,
|
||||
fec_override_admin_56g, *fec_policy);
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_56G:
|
||||
MLX5E_FEC_OVERRIDE_ADMIN_POLICY(pplm, *fec_policy, write, 56g);
|
||||
break;
|
||||
case 100000:
|
||||
if (!write)
|
||||
*fec_policy = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_admin_100g);
|
||||
else
|
||||
MLX5_SET(pplm_reg, pplm,
|
||||
fec_override_admin_100g, *fec_policy);
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_100G:
|
||||
MLX5E_FEC_OVERRIDE_ADMIN_POLICY(pplm, *fec_policy, write, 100g);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@ -408,32 +389,28 @@ static int mlx5e_fec_admin_field(u32 *pplm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define MLX5E_GET_FEC_OVERRIDE_CAP(buf, link) \
|
||||
MLX5_GET(pplm_reg, buf, fec_override_cap_##link)
|
||||
|
||||
/* returns FEC capabilities for a given speed */
|
||||
static int mlx5e_get_fec_cap_field(u32 *pplm,
|
||||
u8 *fec_cap,
|
||||
u32 speed)
|
||||
static int mlx5e_get_fec_cap_field(u32 *pplm, u8 *fec_cap,
|
||||
enum mlx5e_fec_supported_link_mode link_mode)
|
||||
{
|
||||
switch (speed) {
|
||||
case 10000:
|
||||
case 40000:
|
||||
*fec_cap = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_cap_10g_40g);
|
||||
switch (link_mode) {
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_10G_40G:
|
||||
*fec_cap = MLX5E_GET_FEC_OVERRIDE_CAP(pplm, 10g_40g);
|
||||
break;
|
||||
case 25000:
|
||||
*fec_cap = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_cap_25g);
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_25G:
|
||||
*fec_cap = MLX5E_GET_FEC_OVERRIDE_CAP(pplm, 25g);
|
||||
break;
|
||||
case 50000:
|
||||
*fec_cap = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_cap_50g);
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_50G:
|
||||
*fec_cap = MLX5E_GET_FEC_OVERRIDE_CAP(pplm, 50g);
|
||||
break;
|
||||
case 56000:
|
||||
*fec_cap = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_cap_56g);
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_56G:
|
||||
*fec_cap = MLX5E_GET_FEC_OVERRIDE_CAP(pplm, 56g);
|
||||
break;
|
||||
case 100000:
|
||||
*fec_cap = MLX5_GET(pplm_reg, pplm,
|
||||
fec_override_cap_100g);
|
||||
case MLX5E_FEC_SUPPORTED_LINK_MODES_100G:
|
||||
*fec_cap = MLX5E_GET_FEC_OVERRIDE_CAP(pplm, 100g);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@ -460,10 +437,10 @@ bool mlx5e_fec_in_caps(struct mlx5_core_dev *dev, int fec_policy)
|
||||
if (err)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < MLX5E_FEC_SUPPORTED_SPEEDS; i++) {
|
||||
for (i = 0; i < MLX5E_MAX_FEC_SUPPORTED_LINK_MODE; i++) {
|
||||
u8 fec_caps;
|
||||
|
||||
mlx5e_get_fec_cap_field(out, &fec_caps, fec_supported_speeds[i]);
|
||||
mlx5e_get_fec_cap_field(out, &fec_caps, i);
|
||||
if (fec_caps & fec_policy)
|
||||
return true;
|
||||
}
|
||||
@ -476,8 +453,8 @@ int mlx5e_get_fec_mode(struct mlx5_core_dev *dev, u32 *fec_mode_active,
|
||||
u32 out[MLX5_ST_SZ_DW(pplm_reg)] = {};
|
||||
u32 in[MLX5_ST_SZ_DW(pplm_reg)] = {};
|
||||
int sz = MLX5_ST_SZ_BYTES(pplm_reg);
|
||||
u32 link_speed;
|
||||
int err;
|
||||
int i;
|
||||
|
||||
if (!MLX5_CAP_GEN(dev, pcam_reg))
|
||||
return -EOPNOTSUPP;
|
||||
@ -493,13 +470,16 @@ int mlx5e_get_fec_mode(struct mlx5_core_dev *dev, u32 *fec_mode_active,
|
||||
*fec_mode_active = MLX5_GET(pplm_reg, out, fec_mode_active);
|
||||
|
||||
if (!fec_configured_mode)
|
||||
return 0;
|
||||
goto out;
|
||||
|
||||
err = mlx5e_port_linkspeed(dev, &link_speed);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return mlx5e_fec_admin_field(out, fec_configured_mode, 0, link_speed);
|
||||
*fec_configured_mode = 0;
|
||||
for (i = 0; i < MLX5E_MAX_FEC_SUPPORTED_LINK_MODE; i++) {
|
||||
mlx5e_fec_admin_field(out, fec_configured_mode, 0, i);
|
||||
if (*fec_configured_mode != 0)
|
||||
goto out;
|
||||
}
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u8 fec_policy)
|
||||
@ -525,16 +505,14 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u8 fec_policy)
|
||||
|
||||
MLX5_SET(pplm_reg, out, local_port, 1);
|
||||
|
||||
for (i = 0; i < MLX5E_FEC_SUPPORTED_SPEEDS; i++) {
|
||||
mlx5e_get_fec_cap_field(out, &fec_caps, fec_supported_speeds[i]);
|
||||
for (i = 0; i < MLX5E_MAX_FEC_SUPPORTED_LINK_MODE; i++) {
|
||||
mlx5e_get_fec_cap_field(out, &fec_caps, i);
|
||||
/* policy supported for link speed */
|
||||
if (fec_caps & fec_policy)
|
||||
mlx5e_fec_admin_field(out, &fec_policy, 1,
|
||||
fec_supported_speeds[i]);
|
||||
mlx5e_fec_admin_field(out, &fec_policy, 1, i);
|
||||
else
|
||||
/* set FEC to auto*/
|
||||
mlx5e_fec_admin_field(out, &fec_policy_auto, 1,
|
||||
fec_supported_speeds[i]);
|
||||
mlx5e_fec_admin_field(out, &fec_policy_auto, 1, i);
|
||||
}
|
||||
|
||||
return mlx5_core_access_reg(dev, out, sz, out, sz, MLX5_REG_PPLM, 0, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user