Skip to content

Commit da54d24

Browse files
Gal Pressmandavem330
authored andcommitted
net/mlx5e: Add ethtool support for interface identify (LED blinking)
Add the needed hardware command and mlx5_ifc structs for managing LED control. Add set_phys_id ethtool callback to support ethtool -p flag. Signed-off-by: Gal Pressman <[email protected]> Signed-off-by: Eugenia Emantayev <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 94cb1eb commit da54d24

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,30 @@ static int mlx5e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
11351135
return mlx5_set_port_wol(mdev, mlx5_wol_mode);
11361136
}
11371137

1138+
static int mlx5e_set_phys_id(struct net_device *dev,
1139+
enum ethtool_phys_id_state state)
1140+
{
1141+
struct mlx5e_priv *priv = netdev_priv(dev);
1142+
struct mlx5_core_dev *mdev = priv->mdev;
1143+
u16 beacon_duration;
1144+
1145+
if (!MLX5_CAP_GEN(mdev, beacon_led))
1146+
return -EOPNOTSUPP;
1147+
1148+
switch (state) {
1149+
case ETHTOOL_ID_ACTIVE:
1150+
beacon_duration = MLX5_BEACON_DURATION_INF;
1151+
break;
1152+
case ETHTOOL_ID_INACTIVE:
1153+
beacon_duration = MLX5_BEACON_DURATION_OFF;
1154+
break;
1155+
default:
1156+
return -EOPNOTSUPP;
1157+
}
1158+
1159+
return mlx5_set_port_beacon(mdev, beacon_duration);
1160+
}
1161+
11381162
const struct ethtool_ops mlx5e_ethtool_ops = {
11391163
.get_drvinfo = mlx5e_get_drvinfo,
11401164
.get_link = ethtool_op_get_link,
@@ -1159,6 +1183,7 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
11591183
.get_pauseparam = mlx5e_get_pauseparam,
11601184
.set_pauseparam = mlx5e_set_pauseparam,
11611185
.get_ts_info = mlx5e_get_ts_info,
1186+
.set_phys_id = mlx5e_set_phys_id,
11621187
.get_wol = mlx5e_get_wol,
11631188
.set_wol = mlx5e_set_wol,
11641189
};

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@ int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
115115
}
116116
EXPORT_SYMBOL_GPL(mlx5_query_port_ptys);
117117

118+
int mlx5_set_port_beacon(struct mlx5_core_dev *dev, u16 beacon_duration)
119+
{
120+
u32 out[MLX5_ST_SZ_DW(mlcr_reg)];
121+
u32 in[MLX5_ST_SZ_DW(mlcr_reg)];
122+
123+
memset(in, 0, sizeof(in));
124+
MLX5_SET(mlcr_reg, in, local_port, 1);
125+
MLX5_SET(mlcr_reg, in, beacon_duration, beacon_duration);
126+
127+
return mlx5_core_access_reg(dev, in, sizeof(in), out,
128+
sizeof(out), MLX5_REG_MLCR, 0, 1);
129+
}
130+
118131
int mlx5_query_port_proto_cap(struct mlx5_core_dev *dev,
119132
u32 *proto_cap, int proto_mask)
120133
{

include/linux/mlx5/driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ enum {
116116
MLX5_REG_PMLP = 0, /* TBD */
117117
MLX5_REG_NODE_DESC = 0x6001,
118118
MLX5_REG_HOST_ENDIANNESS = 0x7004,
119+
MLX5_REG_MLCR = 0x902b,
119120
};
120121

121122
enum {

include/linux/mlx5/port.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535

3636
#include <linux/mlx5/driver.h>
3737

38+
enum mlx5_beacon_duration {
39+
MLX5_BEACON_DURATION_OFF = 0x0,
40+
MLX5_BEACON_DURATION_INF = 0xffff,
41+
};
42+
3843
int mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps);
3944
int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
4045
int ptys_size, int proto_mask, u8 local_port);
@@ -53,6 +58,7 @@ int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
5358
enum mlx5_port_status status);
5459
int mlx5_query_port_admin_status(struct mlx5_core_dev *dev,
5560
enum mlx5_port_status *status);
61+
int mlx5_set_port_beacon(struct mlx5_core_dev *dev, u16 beacon_duration);
5662

5763
int mlx5_set_port_mtu(struct mlx5_core_dev *dev, int mtu, u8 port);
5864
void mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, int *max_mtu, u8 port);

0 commit comments

Comments
 (0)