Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Dec 2018 11:43:49 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r341904 - in stable/11/sys/dev/mlx4: . mlx4_core
Message-ID:  <201812121143.wBCBhnYm057485@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Wed Dec 12 11:43:49 2018
New Revision: 341904
URL: https://svnweb.freebsd.org/changeset/base/341904

Log:
  MFC r341545:
  mlx4: Add board identifier and firmware version to sysctl
  
  In last mlx4 update (r325841) we lost the sysctl to show the
  firmware version for mlx4 devices.
  Add both board identifier and firmware version under:
  sys.device.mlx4_core0.hw sysctl node.
  
  Sponsored by:   Mellanox Technologies

Modified:
  stable/11/sys/dev/mlx4/device.h
  stable/11/sys/dev/mlx4/mlx4_core/mlx4_main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/mlx4/device.h
==============================================================================
--- stable/11/sys/dev/mlx4/device.h	Wed Dec 12 11:42:38 2018	(r341903)
+++ stable/11/sys/dev/mlx4/device.h	Wed Dec 12 11:43:49 2018	(r341904)
@@ -877,6 +877,8 @@ struct mlx4_dev {
 	u64			regid_allmulti_array[MLX4_MAX_PORTS + 1];
 	struct mlx4_vf_dev     *dev_vfs;
 	u8  uar_page_shift;
+	struct sysctl_ctx_list	hw_ctx;
+	char			fw_str[64];
 };
 
 struct mlx4_clock_params {

Modified: stable/11/sys/dev/mlx4/mlx4_core/mlx4_main.c
==============================================================================
--- stable/11/sys/dev/mlx4/mlx4_core/mlx4_main.c	Wed Dec 12 11:42:38 2018	(r341903)
+++ stable/11/sys/dev/mlx4/mlx4_core/mlx4_main.c	Wed Dec 12 11:43:49 2018	(r341904)
@@ -1893,6 +1893,7 @@ static void unmap_internal_clock(struct mlx4_dev *dev)
 
 static void mlx4_close_hca(struct mlx4_dev *dev)
 {
+	sysctl_ctx_free(&dev->hw_ctx);
 	unmap_internal_clock(dev);
 	unmap_bf_area(dev);
 	if (mlx4_is_slave(dev))
@@ -3745,10 +3746,14 @@ err_disable_pdev:
 
 static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-	struct mlx4_priv *priv;
-	struct mlx4_dev *dev;
-	int ret;
 
+	struct sysctl_ctx_list	*ctx;
+	struct sysctl_oid	*node;
+	struct sysctl_oid_list	*node_list;
+	struct mlx4_priv	*priv;
+	struct mlx4_dev		*dev;
+	int			ret;
+
 	printk_once(KERN_INFO "%s", mlx4_version);
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -3773,8 +3778,28 @@ static int mlx4_init_one(struct pci_dev *pdev, const s
 	if (ret) {
 		kfree(dev->persist);
 		kfree(priv);
+		return ret;
 	} else {
 		pci_save_state(pdev->dev.bsddev);
+	}
+
+	snprintf(dev->fw_str, sizeof(dev->fw_str), "%d.%d.%d",
+		 (int) (dev->caps.fw_ver >> 32),
+		 (int) (dev->caps.fw_ver >> 16) & 0xffff,
+		 (int) (dev->caps.fw_ver & 0xffff));
+
+	ctx = &dev->hw_ctx;
+	sysctl_ctx_init(ctx);
+	node = SYSCTL_ADD_NODE(ctx,SYSCTL_CHILDREN(pdev->dev.kobj.oidp),
+	    OID_AUTO, "hw" , CTLFLAG_RD, 0, "mlx4 dev hw information");
+	if (node != NULL) {
+		node_list = SYSCTL_CHILDREN(node);
+		SYSCTL_ADD_STRING(ctx, node_list, OID_AUTO,
+		    "fw_version", CTLFLAG_RD, dev->fw_str, 0,
+		    "Device firmware version");
+		SYSCTL_ADD_STRING(ctx, node_list, OID_AUTO,
+		    "board_id", CTLFLAG_RD, dev->board_id, 0,
+		    "Device board identifier");
 	}
 
 	return ret;



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