Skip to content

Commit adb0c95

Browse files
Saeed Mahameeddavem330
authored andcommitted
net/mlx5_core: Implement access functions of ptys register fields
Those registers will be used by the ethtool to set/get settings. 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 938fe83 commit adb0c95

File tree

2 files changed

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

2 files changed

+91
-0
lines changed

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,80 @@ int mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps)
102102
return err;
103103
}
104104
EXPORT_SYMBOL_GPL(mlx5_set_port_caps);
105+
106+
int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
107+
int ptys_size, int proto_mask)
108+
{
109+
u32 in[MLX5_ST_SZ_DW(ptys_reg)];
110+
int err;
111+
112+
memset(in, 0, sizeof(in));
113+
MLX5_SET(ptys_reg, in, local_port, 1);
114+
MLX5_SET(ptys_reg, in, proto_mask, proto_mask);
115+
116+
err = mlx5_core_access_reg(dev, in, sizeof(in), ptys,
117+
ptys_size, MLX5_REG_PTYS, 0, 0);
118+
119+
return err;
120+
}
121+
EXPORT_SYMBOL_GPL(mlx5_query_port_ptys);
122+
123+
int mlx5_query_port_proto_cap(struct mlx5_core_dev *dev,
124+
u32 *proto_cap, int proto_mask)
125+
{
126+
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
127+
int err;
128+
129+
err = mlx5_query_port_ptys(dev, out, sizeof(out), proto_mask);
130+
if (err)
131+
return err;
132+
133+
if (proto_mask == MLX5_PTYS_EN)
134+
*proto_cap = MLX5_GET(ptys_reg, out, eth_proto_capability);
135+
else
136+
*proto_cap = MLX5_GET(ptys_reg, out, ib_proto_capability);
137+
138+
return 0;
139+
}
140+
EXPORT_SYMBOL_GPL(mlx5_query_port_proto_cap);
141+
142+
int mlx5_query_port_proto_admin(struct mlx5_core_dev *dev,
143+
u32 *proto_admin, int proto_mask)
144+
{
145+
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
146+
int err;
147+
148+
err = mlx5_query_port_ptys(dev, out, sizeof(out), proto_mask);
149+
if (err)
150+
return err;
151+
152+
if (proto_mask == MLX5_PTYS_EN)
153+
*proto_admin = MLX5_GET(ptys_reg, out, eth_proto_admin);
154+
else
155+
*proto_admin = MLX5_GET(ptys_reg, out, ib_proto_admin);
156+
157+
return 0;
158+
}
159+
EXPORT_SYMBOL_GPL(mlx5_query_port_proto_admin);
160+
161+
int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
162+
int proto_mask)
163+
{
164+
u32 in[MLX5_ST_SZ_DW(ptys_reg)];
165+
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
166+
int err;
167+
168+
memset(in, 0, sizeof(in));
169+
170+
MLX5_SET(ptys_reg, in, local_port, 1);
171+
MLX5_SET(ptys_reg, in, proto_mask, proto_mask);
172+
if (proto_mask == MLX5_PTYS_EN)
173+
MLX5_SET(ptys_reg, in, eth_proto_admin, proto_admin);
174+
else
175+
MLX5_SET(ptys_reg, in, ib_proto_admin, proto_admin);
176+
177+
err = mlx5_core_access_reg(dev, in, sizeof(in), out,
178+
sizeof(out), MLX5_REG_PTYS, 0, 1);
179+
return err;
180+
}
181+
EXPORT_SYMBOL_GPL(mlx5_set_port_proto);

include/linux/mlx5/driver.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,11 @@ enum {
504504
MLX5_COMP_EQ_SIZE = 1024,
505505
};
506506

507+
enum {
508+
MLX5_PTYS_IB = 1 << 0,
509+
MLX5_PTYS_EN = 1 << 2,
510+
};
511+
507512
struct mlx5_db_pgdir {
508513
struct list_head list;
509514
DECLARE_BITMAP(bitmap, MLX5_DB_PER_PAGE);
@@ -686,7 +691,16 @@ void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev);
686691
int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in,
687692
int size_in, void *data_out, int size_out,
688693
u16 reg_num, int arg, int write);
694+
689695
int mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps);
696+
int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
697+
int ptys_size, int proto_mask);
698+
int mlx5_query_port_proto_cap(struct mlx5_core_dev *dev,
699+
u32 *proto_cap, int proto_mask);
700+
int mlx5_query_port_proto_admin(struct mlx5_core_dev *dev,
701+
u32 *proto_admin, int proto_mask);
702+
int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
703+
int proto_mask);
690704

691705
int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
692706
void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq);

0 commit comments

Comments
 (0)