Skip to content

Commit 415a64a

Browse files
Huy NguyenSaeed Mahameed
authored andcommitted
net/mlx5: QPTS and QPDPM register firmware command support
The QPTS register allows changing the priority trust state between pcp and dscp. Add support to get/set trust state from device. When the port is in pcp/dscp trust state, packet is routed by hardware to matching priority based on its pcp/dscp value respectively. The QPDPM register allow channing the dscp to priority mapping. Add support to get/set dscp to priority mapping from device. Note that to change a dscp mapping, the "e" bit of this dscp structure must be set in the QPDPM firmware command. Signed-off-by: Huy Nguyen <huyn@mellanox.com> Reviewed-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 71c70eb commit 415a64a

4 files changed

Lines changed: 131 additions & 0 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx5/core/port.c‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,3 +971,102 @@ int mlx5_set_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 arm, u8 mode)
971971
return mlx5_core_access_reg(mdev, in, sizeof(in), out,
972972
sizeof(out), MLX5_REG_MTPPSE, 0, 1);
973973
}
974+
975+
int mlx5_set_trust_state(struct mlx5_core_dev *mdev, u8 trust_state)
976+
{
977+
u32 out[MLX5_ST_SZ_DW(qpts_reg)] = {};
978+
u32 in[MLX5_ST_SZ_DW(qpts_reg)] = {};
979+
int err;
980+
981+
MLX5_SET(qpts_reg, in, local_port, 1);
982+
MLX5_SET(qpts_reg, in, trust_state, trust_state);
983+
984+
err = mlx5_core_access_reg(mdev, in, sizeof(in), out,
985+
sizeof(out), MLX5_REG_QPTS, 0, 1);
986+
return err;
987+
}
988+
989+
int mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state)
990+
{
991+
u32 out[MLX5_ST_SZ_DW(qpts_reg)] = {};
992+
u32 in[MLX5_ST_SZ_DW(qpts_reg)] = {};
993+
int err;
994+
995+
MLX5_SET(qpts_reg, in, local_port, 1);
996+
997+
err = mlx5_core_access_reg(mdev, in, sizeof(in), out,
998+
sizeof(out), MLX5_REG_QPTS, 0, 0);
999+
if (!err)
1000+
*trust_state = MLX5_GET(qpts_reg, out, trust_state);
1001+
1002+
return err;
1003+
}
1004+
1005+
int mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio)
1006+
{
1007+
int sz = MLX5_ST_SZ_BYTES(qpdpm_reg);
1008+
void *qpdpm_dscp;
1009+
void *out;
1010+
void *in;
1011+
int err;
1012+
1013+
in = kzalloc(sz, GFP_KERNEL);
1014+
out = kzalloc(sz, GFP_KERNEL);
1015+
if (!in || !out) {
1016+
err = -ENOMEM;
1017+
goto out;
1018+
}
1019+
1020+
MLX5_SET(qpdpm_reg, in, local_port, 1);
1021+
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_QPDPM, 0, 0);
1022+
if (err)
1023+
goto out;
1024+
1025+
memcpy(in, out, sz);
1026+
MLX5_SET(qpdpm_reg, in, local_port, 1);
1027+
1028+
/* Update the corresponding dscp entry */
1029+
qpdpm_dscp = MLX5_ADDR_OF(qpdpm_reg, in, dscp[dscp]);
1030+
MLX5_SET16(qpdpm_dscp_reg, qpdpm_dscp, prio, prio);
1031+
MLX5_SET16(qpdpm_dscp_reg, qpdpm_dscp, e, 1);
1032+
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_QPDPM, 0, 1);
1033+
1034+
out:
1035+
kfree(in);
1036+
kfree(out);
1037+
return err;
1038+
}
1039+
1040+
/* dscp2prio[i]: priority that dscp i mapped to */
1041+
#define MLX5E_SUPPORTED_DSCP 64
1042+
int mlx5_query_dscp2prio(struct mlx5_core_dev *mdev, u8 *dscp2prio)
1043+
{
1044+
int sz = MLX5_ST_SZ_BYTES(qpdpm_reg);
1045+
void *qpdpm_dscp;
1046+
void *out;
1047+
void *in;
1048+
int err;
1049+
int i;
1050+
1051+
in = kzalloc(sz, GFP_KERNEL);
1052+
out = kzalloc(sz, GFP_KERNEL);
1053+
if (!in || !out) {
1054+
err = -ENOMEM;
1055+
goto out;
1056+
}
1057+
1058+
MLX5_SET(qpdpm_reg, in, local_port, 1);
1059+
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_QPDPM, 0, 0);
1060+
if (err)
1061+
goto out;
1062+
1063+
for (i = 0; i < (MLX5E_SUPPORTED_DSCP); i++) {
1064+
qpdpm_dscp = MLX5_ADDR_OF(qpdpm_reg, out, dscp[i]);
1065+
dscp2prio[i] = MLX5_GET16(qpdpm_dscp_reg, qpdpm_dscp, prio);
1066+
}
1067+
1068+
out:
1069+
kfree(in);
1070+
kfree(out);
1071+
return err;
1072+
}

‎include/linux/mlx5/driver.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ enum {
107107
};
108108

109109
enum {
110+
MLX5_REG_QPTS = 0x4002,
110111
MLX5_REG_QETCR = 0x4005,
111112
MLX5_REG_QTCT = 0x400a,
113+
MLX5_REG_QPDPM = 0x4013,
112114
MLX5_REG_QCAM = 0x4019,
113115
MLX5_REG_DCBX_PARAM = 0x4020,
114116
MLX5_REG_DCBX_APP = 0x4021,
@@ -142,6 +144,11 @@ enum {
142144
MLX5_REG_MCAM = 0x907f,
143145
};
144146

147+
enum mlx5_qpts_trust_state {
148+
MLX5_QPTS_TRUST_PCP = 1,
149+
MLX5_QPTS_TRUST_DSCP = 2,
150+
};
151+
145152
enum mlx5_dcbx_oper_mode {
146153
MLX5E_DCBX_PARAM_VER_OPER_HOST = 0x0,
147154
MLX5E_DCBX_PARAM_VER_OPER_AUTO = 0x3,

‎include/linux/mlx5/mlx5_ifc.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8578,6 +8578,26 @@ struct mlx5_ifc_qetc_reg_bits {
85788578
struct mlx5_ifc_ets_global_config_reg_bits global_configuration;
85798579
};
85808580

8581+
struct mlx5_ifc_qpdpm_dscp_reg_bits {
8582+
u8 e[0x1];
8583+
u8 reserved_at_01[0x0b];
8584+
u8 prio[0x04];
8585+
};
8586+
8587+
struct mlx5_ifc_qpdpm_reg_bits {
8588+
u8 reserved_at_0[0x8];
8589+
u8 local_port[0x8];
8590+
u8 reserved_at_10[0x10];
8591+
struct mlx5_ifc_qpdpm_dscp_reg_bits dscp[64];
8592+
};
8593+
8594+
struct mlx5_ifc_qpts_reg_bits {
8595+
u8 reserved_at_0[0x8];
8596+
u8 local_port[0x8];
8597+
u8 reserved_at_10[0x2d];
8598+
u8 trust_state[0x3];
8599+
};
8600+
85818601
struct mlx5_ifc_qtct_reg_bits {
85828602
u8 reserved_at_0[0x8];
85838603
u8 port_number[0x8];

‎include/linux/mlx5/port.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,9 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
179179

180180
int mlx5_query_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *out);
181181
int mlx5_set_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *in);
182+
183+
int mlx5_set_trust_state(struct mlx5_core_dev *mdev, u8 trust_state);
184+
int mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state);
185+
int mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio);
186+
int mlx5_query_dscp2prio(struct mlx5_core_dev *mdev, u8 *dscp2prio);
182187
#endif /* __MLX5_PORT_H__ */

0 commit comments

Comments
 (0)