Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Sep 2020 10:36:07 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r365407 - in stable/12/sys/dev/mlx5: mlx5_core mlx5_en
Message-ID:  <202009071036.087Aa7rl086587@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Sep  7 10:36:07 2020
New Revision: 365407
URL: https://svnweb.freebsd.org/changeset/base/365407

Log:
  MFC r365001:
  mlx5en: Implement SIOCGIFDOWNREASON.

Modified:
  stable/12/sys/dev/mlx5/mlx5_core/mlx5_core.h
  stable/12/sys/dev/mlx5/mlx5_core/mlx5_port.c
  stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/mlx5/mlx5_core/mlx5_core.h
==============================================================================
--- stable/12/sys/dev/mlx5/mlx5_core/mlx5_core.h	Mon Sep  7 10:35:22 2020	(r365406)
+++ stable/12/sys/dev/mlx5/mlx5_core/mlx5_core.h	Mon Sep  7 10:36:07 2020	(r365407)
@@ -127,6 +127,9 @@ void mlx5_core_event(struct mlx5_core_dev *dev, enum m
 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);

Modified: stable/12/sys/dev/mlx5/mlx5_core/mlx5_port.c
==============================================================================
--- stable/12/sys/dev/mlx5/mlx5_core/mlx5_port.c	Mon Sep  7 10:35:22 2020	(r365406)
+++ stable/12/sys/dev/mlx5/mlx5_core/mlx5_port.c	Mon Sep  7 10:36:07 2020	(r365407)
@@ -1221,6 +1221,31 @@ int mlx5_query_pddr_range_info(struct mlx5_core_dev *m
 }
 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)
 {

Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Mon Sep  7 10:35:22 2020	(r365406)
+++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Mon Sep  7 10:36:07 2020	(r365407)
@@ -3195,6 +3195,7 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t
 {
 	struct mlx5e_priv *priv;
 	struct ifreq *ifr;
+	struct ifdownreason *ifdr;
 	struct ifi2creq i2c;
 	int error = 0;
 	int mask = 0;
@@ -3456,6 +3457,16 @@ out:
 		error = copyout(&i2c, ifr_data_get_ptr(ifr), sizeof(i2c));
 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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009071036.087Aa7rl086587>