diff options
author | Saeed Mahameed <saeedm@mellanox.com> | 2015-05-28 15:28:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-30 21:24:08 -0400 |
commit | e725440e75da8c4d617a31c4e38216acc55c24e3 (patch) | |
tree | c148d3e27db3c3adbb7a33237440711cf0fec377 /drivers/net | |
parent | 90b3e38d048f09b22fb50bcd460cea65fd00b2d7 (diff) |
net/mlx5_core: Set/Query port MTU commands
Introduce set/Query low level functions to access MTU in hardware. To be
used by the netdev.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/port.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c index 742a6fb8debe..7d3d0f9f328d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/port.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c | |||
@@ -211,3 +211,56 @@ int mlx5_query_port_status(struct mlx5_core_dev *dev, u8 *status) | |||
211 | *status = MLX5_GET(paos_reg, out, oper_status); | 211 | *status = MLX5_GET(paos_reg, out, oper_status); |
212 | return err; | 212 | return err; |
213 | } | 213 | } |
214 | |||
215 | static int mlx5_query_port_mtu(struct mlx5_core_dev *dev, | ||
216 | int *admin_mtu, int *max_mtu, int *oper_mtu) | ||
217 | { | ||
218 | u32 in[MLX5_ST_SZ_DW(pmtu_reg)]; | ||
219 | u32 out[MLX5_ST_SZ_DW(pmtu_reg)]; | ||
220 | int err; | ||
221 | |||
222 | memset(in, 0, sizeof(in)); | ||
223 | |||
224 | MLX5_SET(pmtu_reg, in, local_port, 1); | ||
225 | |||
226 | err = mlx5_core_access_reg(dev, in, sizeof(in), out, | ||
227 | sizeof(out), MLX5_REG_PMTU, 0, 0); | ||
228 | if (err) | ||
229 | return err; | ||
230 | |||
231 | if (max_mtu) | ||
232 | *max_mtu = MLX5_GET(pmtu_reg, out, max_mtu); | ||
233 | if (oper_mtu) | ||
234 | *oper_mtu = MLX5_GET(pmtu_reg, out, oper_mtu); | ||
235 | if (admin_mtu) | ||
236 | *admin_mtu = MLX5_GET(pmtu_reg, out, admin_mtu); | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | int mlx5_set_port_mtu(struct mlx5_core_dev *dev, int mtu) | ||
242 | { | ||
243 | u32 in[MLX5_ST_SZ_DW(pmtu_reg)]; | ||
244 | u32 out[MLX5_ST_SZ_DW(pmtu_reg)]; | ||
245 | |||
246 | memset(in, 0, sizeof(in)); | ||
247 | |||
248 | MLX5_SET(pmtu_reg, in, admin_mtu, mtu); | ||
249 | MLX5_SET(pmtu_reg, in, local_port, 1); | ||
250 | |||
251 | return mlx5_core_access_reg(dev, in, sizeof(in), out, sizeof(out), | ||
252 | MLX5_REG_PMTU, 0, 1); | ||
253 | } | ||
254 | EXPORT_SYMBOL_GPL(mlx5_set_port_mtu); | ||
255 | |||
256 | int mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, int *max_mtu) | ||
257 | { | ||
258 | return mlx5_query_port_mtu(dev, NULL, max_mtu, NULL); | ||
259 | } | ||
260 | EXPORT_SYMBOL_GPL(mlx5_query_port_max_mtu); | ||
261 | |||
262 | int mlx5_query_port_oper_mtu(struct mlx5_core_dev *dev, int *oper_mtu) | ||
263 | { | ||
264 | return mlx5_query_port_mtu(dev, NULL, NULL, oper_mtu); | ||
265 | } | ||
266 | EXPORT_SYMBOL_GPL(mlx5_query_port_oper_mtu); | ||