Skip to content

Commit 4c916a7

Browse files
Rana Shahoutdavem330
authored andcommitted
net/mlx5_core: Implement get/set port status
Implemet get/set port status low level functions to be exposed by the netdev. Signed-off-by: Rana Shahout <ranas@mellanox.com> 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>
1 parent adb0c95 commit 4c916a7

File tree

2 files changed

+40
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core
  • include/linux/mlx5

2 files changed

+40
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,35 @@ int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
179179
return err;
180180
}
181181
EXPORT_SYMBOL_GPL(mlx5_set_port_proto);
182+
183+
int mlx5_set_port_status(struct mlx5_core_dev *dev,
184+
enum mlx5_port_status status)
185+
{
186+
u32 in[MLX5_ST_SZ_DW(paos_reg)];
187+
u32 out[MLX5_ST_SZ_DW(paos_reg)];
188+
189+
memset(in, 0, sizeof(in));
190+
191+
MLX5_SET(paos_reg, in, admin_status, status);
192+
MLX5_SET(paos_reg, in, ase, 1);
193+
194+
return mlx5_core_access_reg(dev, in, sizeof(in), out,
195+
sizeof(out), MLX5_REG_PAOS, 0, 1);
196+
}
197+
198+
int mlx5_query_port_status(struct mlx5_core_dev *dev, u8 *status)
199+
{
200+
u32 in[MLX5_ST_SZ_DW(paos_reg)];
201+
u32 out[MLX5_ST_SZ_DW(paos_reg)];
202+
int err;
203+
204+
memset(in, 0, sizeof(in));
205+
206+
err = mlx5_core_access_reg(dev, in, sizeof(in), out,
207+
sizeof(out), MLX5_REG_PAOS, 0, 0);
208+
if (err)
209+
return err;
210+
211+
*status = MLX5_GET(paos_reg, out, oper_status);
212+
return err;
213+
}

include/linux/mlx5/driver.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ enum mlx5_dev_event {
149149
MLX5_DEV_EVENT_CLIENT_REREG,
150150
};
151151

152+
enum mlx5_port_status {
153+
MLX5_PORT_UP = 1 << 1,
154+
MLX5_PORT_DOWN = 1 << 2,
155+
};
156+
152157
struct mlx5_uuar_info {
153158
struct mlx5_uar *uars;
154159
int num_uars;
@@ -701,6 +706,9 @@ int mlx5_query_port_proto_admin(struct mlx5_core_dev *dev,
701706
u32 *proto_admin, int proto_mask);
702707
int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
703708
int proto_mask);
709+
int mlx5_set_port_status(struct mlx5_core_dev *dev,
710+
enum mlx5_port_status status);
711+
int mlx5_query_port_status(struct mlx5_core_dev *dev, u8 *status);
704712

705713
int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
706714
void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq);

0 commit comments

Comments
 (0)