Skip to content

Commit 50b4a3c

Browse files
Huy NguyenSaeed Mahameed
authored andcommitted
net/mlx5: PPTB and PBMC register firmware command support
Add firmware command interface to read and write PPTB and PBMC registers. PPTB register enables mappings priority to a specific receive buffer. PBMC registers enables changing the receive buffer's configuration such as buffer size, xon/xoff thresholds, buffer's lossy property and buffer's shared property. Signed-off-by: Huy Nguyen <huyn@mellanox.com> Reviewed-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent df5f136 commit 50b4a3c

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

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

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,111 @@ u32 mlx5e_port_speed2linkmodes(u32 speed)
127127

128128
return link_modes;
129129
}
130+
131+
int mlx5e_port_query_pbmc(struct mlx5_core_dev *mdev, void *out)
132+
{
133+
int sz = MLX5_ST_SZ_BYTES(pbmc_reg);
134+
void *in;
135+
int err;
136+
137+
in = kzalloc(sz, GFP_KERNEL);
138+
if (!in)
139+
return -ENOMEM;
140+
141+
MLX5_SET(pbmc_reg, in, local_port, 1);
142+
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PBMC, 0, 0);
143+
144+
kfree(in);
145+
return err;
146+
}
147+
148+
int mlx5e_port_set_pbmc(struct mlx5_core_dev *mdev, void *in)
149+
{
150+
int sz = MLX5_ST_SZ_BYTES(pbmc_reg);
151+
void *out;
152+
int err;
153+
154+
out = kzalloc(sz, GFP_KERNEL);
155+
if (!out)
156+
return -ENOMEM;
157+
158+
MLX5_SET(pbmc_reg, in, local_port, 1);
159+
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PBMC, 0, 1);
160+
161+
kfree(out);
162+
return err;
163+
}
164+
165+
/* buffer[i]: buffer that priority i mapped to */
166+
int mlx5e_port_query_priority2buffer(struct mlx5_core_dev *mdev, u8 *buffer)
167+
{
168+
int sz = MLX5_ST_SZ_BYTES(pptb_reg);
169+
u32 prio_x_buff;
170+
void *out;
171+
void *in;
172+
int prio;
173+
int err;
174+
175+
in = kzalloc(sz, GFP_KERNEL);
176+
out = kzalloc(sz, GFP_KERNEL);
177+
if (!in || !out) {
178+
err = -ENOMEM;
179+
goto out;
180+
}
181+
182+
MLX5_SET(pptb_reg, in, local_port, 1);
183+
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPTB, 0, 0);
184+
if (err)
185+
goto out;
186+
187+
prio_x_buff = MLX5_GET(pptb_reg, out, prio_x_buff);
188+
for (prio = 0; prio < 8; prio++) {
189+
buffer[prio] = (u8)(prio_x_buff >> (4 * prio)) & 0xF;
190+
mlx5_core_dbg(mdev, "prio %d, buffer %d\n", prio, buffer[prio]);
191+
}
192+
out:
193+
kfree(in);
194+
kfree(out);
195+
return err;
196+
}
197+
198+
int mlx5e_port_set_priority2buffer(struct mlx5_core_dev *mdev, u8 *buffer)
199+
{
200+
int sz = MLX5_ST_SZ_BYTES(pptb_reg);
201+
u32 prio_x_buff;
202+
void *out;
203+
void *in;
204+
int prio;
205+
int err;
206+
207+
in = kzalloc(sz, GFP_KERNEL);
208+
out = kzalloc(sz, GFP_KERNEL);
209+
if (!in || !out) {
210+
err = -ENOMEM;
211+
goto out;
212+
}
213+
214+
/* First query the pptb register */
215+
MLX5_SET(pptb_reg, in, local_port, 1);
216+
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPTB, 0, 0);
217+
if (err)
218+
goto out;
219+
220+
memcpy(in, out, sz);
221+
MLX5_SET(pptb_reg, in, local_port, 1);
222+
223+
/* Update the pm and prio_x_buff */
224+
MLX5_SET(pptb_reg, in, pm, 0xFF);
225+
226+
prio_x_buff = 0;
227+
for (prio = 0; prio < 8; prio++)
228+
prio_x_buff |= (buffer[prio] << (4 * prio));
229+
MLX5_SET(pptb_reg, in, prio_x_buff, prio_x_buff);
230+
231+
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPTB, 0, 1);
232+
233+
out:
234+
kfree(in);
235+
kfree(out);
236+
return err;
237+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ u32 mlx5e_port_ptys2speed(u32 eth_proto_oper);
4040
int mlx5e_port_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);
4141
int mlx5e_port_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);
4242
u32 mlx5e_port_speed2linkmodes(u32 speed);
43+
44+
int mlx5e_port_query_pbmc(struct mlx5_core_dev *mdev, void *out);
45+
int mlx5e_port_set_pbmc(struct mlx5_core_dev *mdev, void *in);
46+
int mlx5e_port_query_priority2buffer(struct mlx5_core_dev *mdev, u8 *buffer);
47+
int mlx5e_port_set_priority2buffer(struct mlx5_core_dev *mdev, u8 *buffer);
4348
#endif

include/linux/mlx5/driver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ enum {
124124
MLX5_REG_PAOS = 0x5006,
125125
MLX5_REG_PFCC = 0x5007,
126126
MLX5_REG_PPCNT = 0x5008,
127+
MLX5_REG_PPTB = 0x500b,
128+
MLX5_REG_PBMC = 0x500c,
127129
MLX5_REG_PMAOS = 0x5012,
128130
MLX5_REG_PUDE = 0x5009,
129131
MLX5_REG_PMPE = 0x5010,

include/linux/mlx5/mlx5_ifc.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8788,6 +8788,41 @@ struct mlx5_ifc_qpts_reg_bits {
87888788
u8 trust_state[0x3];
87898789
};
87908790

8791+
struct mlx5_ifc_pptb_reg_bits {
8792+
u8 reserved_at_0[0x2];
8793+
u8 mm[0x2];
8794+
u8 reserved_at_4[0x4];
8795+
u8 local_port[0x8];
8796+
u8 reserved_at_10[0x6];
8797+
u8 cm[0x1];
8798+
u8 um[0x1];
8799+
u8 pm[0x8];
8800+
8801+
u8 prio_x_buff[0x20];
8802+
8803+
u8 pm_msb[0x8];
8804+
u8 reserved_at_48[0x10];
8805+
u8 ctrl_buff[0x4];
8806+
u8 untagged_buff[0x4];
8807+
};
8808+
8809+
struct mlx5_ifc_pbmc_reg_bits {
8810+
u8 reserved_at_0[0x8];
8811+
u8 local_port[0x8];
8812+
u8 reserved_at_10[0x10];
8813+
8814+
u8 xoff_timer_value[0x10];
8815+
u8 xoff_refresh[0x10];
8816+
8817+
u8 reserved_at_40[0x9];
8818+
u8 fullness_threshold[0x7];
8819+
u8 port_buffer_size[0x10];
8820+
8821+
struct mlx5_ifc_bufferx_reg_bits buffer[10];
8822+
8823+
u8 reserved_at_2e0[0x40];
8824+
};
8825+
87918826
struct mlx5_ifc_qtct_reg_bits {
87928827
u8 reserved_at_0[0x8];
87938828
u8 port_number[0x8];

0 commit comments

Comments
 (0)