lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1584458082-29207-6-git-send-email-vasundhara-v.volam@broadcom.com>
Date:   Tue, 17 Mar 2020 20:44:42 +0530
From:   Vasundhara Volam <vasundhara-v.volam@...adcom.com>
To:     davem@...emloft.net
Cc:     netdev@...r.kernel.org,
        Vasundhara Volam <vasundhara-v.volam@...adcom.com>,
        Michael Chan <michael.chan@...adcom.com>
Subject: [PATCH net-next 05/11] bnxt_en: Add hw addr and multihost base hw addr to devlink info_get cb.

In most of the scenarios, device serial number is not supported. So
MAC address is used for proper asset tracking by cloud customers. In
case of multihost NICs, base MAC address is unique for entire NIC and
this can be used for asset tracking. Add the multihost base MAC address
and interface MAC address information to info_get command.

Also update bnxt.rst documentation file.

Example display:

$ devlink dev info pci/0000:3b:00.1
pci/0000:3b:00.1:
  driver bnxt_en
  serial_number B0-26-28-FF-FE-C8-85-20
  versions:
      fixed:
        asic.id 1750
        asic.rev 1
      running:
        drv.spec 1.10.1.12
        hw.addr b0:26:28:c8:85:21
        hw.mh_base_addr b0:26:28:c8:85:20
        fw 216.0.286.0
        fw.psid 0.0.6
        fw.app 216.0.251.0

Signed-off-by: Vasundhara Volam <vasundhara-v.volam@...adcom.com>
Signed-off-by: Michael Chan <michael.chan@...adcom.com>
---
 Documentation/networking/devlink/bnxt.rst         |  7 ++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 40 +++++++++++++++++++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h |  2 ++
 3 files changed, 49 insertions(+)

diff --git a/Documentation/networking/devlink/bnxt.rst b/Documentation/networking/devlink/bnxt.rst
index 2709161..f850a18 100644
--- a/Documentation/networking/devlink/bnxt.rst
+++ b/Documentation/networking/devlink/bnxt.rst
@@ -60,6 +60,13 @@ The ``bnxt_en`` driver reports the following versions
    * - ``drv.spec``
      - running
      - HWRM specification version supported by driver HWRM implementation
+   * - ``hw.addr``
+     - stored, running
+     - Hardware address of the interface
+   * - ``hw.mh_base_addr``
+     - stored, running
+     - Base hardware address of the multihost NIC. Displayed only on multihost
+       system
    * - ``fw.psid``
      - stored, running
      - Firmware parameter set version of the board
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
index f08db49..607e27a 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
@@ -396,6 +396,32 @@ static int bnxt_get_nvm_cfg_ver(struct bnxt *bp,
 	return rc;
 }
 
+static int bnxt_get_mh_base_addr(struct bnxt *bp, u8 *base_addr)
+{
+	dma_addr_t data_dma_addr;
+	__le32 *data;
+	int rc;
+
+	data = dma_alloc_coherent(&bp->pdev->dev, 2 * sizeof(*data),
+				  &data_dma_addr, GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	rc = bnxt_hwrm_nvm_get_var(bp, data_dma_addr, NVM_OFF_MAC_ADDR,
+				   BNXT_NVM_MAC_ADDR_BITS);
+	if (!rc) {
+		u32 mac_hi = le32_to_cpu(data[0]);
+		u32 mac_lo = le32_to_cpu(data[1]);
+
+		sprintf(base_addr, "%02x:%02x:%02x:%02x:%02x:%02x",
+			(u8)(mac_hi >> 8), (u8)(mac_hi), (u8)(mac_lo >> 24),
+			(u8)(mac_lo >> 16), (u8)(mac_lo >> 8), (u8)(mac_lo));
+	}
+	dma_free_coherent(&bp->pdev->dev, 2 * sizeof(*data), data,
+			  data_dma_addr);
+	return rc;
+}
+
 static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
 			    struct netlink_ext_ack *extack)
 {
@@ -405,6 +431,7 @@ static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
 	char mgmt_ver[FW_VER_STR_LEN];
 	char roce_ver[FW_VER_STR_LEN];
 	char fw_ver[FW_VER_STR_LEN];
+	u8 mh_base_addr[ETH_ALEN];
 	char buf[32];
 	int rc;
 
@@ -439,6 +466,19 @@ static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
 	if (rc)
 		return rc;
 
+	sprintf(buf, "%pM", bp->dev->dev_addr);
+	rc = devlink_info_version_running_put(req,
+				DEVLINK_INFO_VERSION_GENERIC_HW_ADDR, buf);
+	if (rc)
+		return rc;
+
+	if (BNXT_MH(bp) && !bnxt_get_mh_base_addr(bp, &mh_base_addr[0])) {
+		rc = devlink_info_version_running_put(req, "hw.mh_base_addr",
+						      mh_base_addr);
+		if (rc)
+			return rc;
+	}
+
 	if (strlen(ver_resp->active_pkg_name)) {
 		rc =
 		    devlink_info_version_running_put(req,
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
index 95f893f..e720b1d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
@@ -33,6 +33,7 @@ static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl)
 	}
 }
 
+#define NVM_OFF_MAC_ADDR		1
 #define NVM_OFF_MSIX_VEC_PER_PF_MAX	108
 #define NVM_OFF_MSIX_VEC_PER_PF_MIN	114
 #define NVM_OFF_IGNORE_ARI		164
@@ -40,6 +41,7 @@ static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl)
 #define NVM_OFF_ENABLE_SRIOV		401
 #define NVM_OFF_NVM_CFG_VER		602
 
+#define BNXT_NVM_MAC_ADDR_BITS		64
 #define BNXT_NVM_CFG_VER_BITS		24
 #define BNXT_NVM_CFG_VER_BYTES		4
 
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ