mlx5en: Implement SIOCGIFDOWNREASON.

Sponsored by:	Mellanox Technologies - Nvidia
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2020-08-31 16:27:03 +00:00
parent 62daa4b6e8
commit 2ea114b34e
3 changed files with 39 additions and 0 deletions

View File

@ -127,6 +127,9 @@ void mlx5_core_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force);
void mlx5_disable_device(struct mlx5_core_dev *dev);
void mlx5_recover_device(struct mlx5_core_dev *dev);
int mlx5_query_pddr_troubleshooting_info(struct mlx5_core_dev *mdev,
u16 *monitor_opcode,
u8 *status_message, size_t sm_len);
int mlx5_register_device(struct mlx5_core_dev *dev);
void mlx5_unregister_device(struct mlx5_core_dev *dev);

View File

@ -1221,6 +1221,31 @@ int mlx5_query_pddr_range_info(struct mlx5_core_dev *mdev, u8 local_port, u8 *is
}
EXPORT_SYMBOL_GPL(mlx5_query_pddr_range_info);
int mlx5_query_pddr_troubleshooting_info(struct mlx5_core_dev *mdev,
u16 *monitor_opcode, u8 *status_message, size_t sm_len)
{
int outlen = MLX5_ST_SZ_BYTES(pddr_reg);
u32 out[MLX5_ST_SZ_DW(pddr_reg)] = {0};
int err;
err = mlx5_query_pddr(mdev, MLX5_PDDR_TROUBLESHOOTING_INFO_PAGE, 1,
out, outlen);
if (err != 0)
return err;
if (monitor_opcode != NULL) {
*monitor_opcode = MLX5_GET(pddr_reg, out,
page_data.troubleshooting_info_page.status_opcode.
monitor_opcodes);
}
if (status_message != NULL) {
strlcpy(status_message,
MLX5_ADDR_OF(pddr_reg, out,
page_data.troubleshooting_info_page.status_message),
sm_len);
}
return (0);
}
int
mlx5_query_mfrl_reg(struct mlx5_core_dev *mdev, u8 *reset_level)
{

View File

@ -3233,6 +3233,7 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
{
struct mlx5e_priv *priv;
struct ifreq *ifr;
struct ifdownreason *ifdr;
struct ifi2creq i2c;
int error = 0;
int mask = 0;
@ -3501,6 +3502,16 @@ out:
err_i2c:
PRIV_UNLOCK(priv);
break;
case SIOCGIFDOWNREASON:
ifdr = (struct ifdownreason *)data;
bzero(ifdr->ifdr_msg, sizeof(ifdr->ifdr_msg));
PRIV_LOCK(priv);
error = -mlx5_query_pddr_troubleshooting_info(priv->mdev, NULL,
ifdr->ifdr_msg, sizeof(ifdr->ifdr_msg));
PRIV_UNLOCK(priv);
if (error == 0)
ifdr->ifdr_reason = IFDR_REASON_MSG;
break;
default:
error = ether_ioctl(ifp, command, data);