diff mbox series

[net-next,05/11] bnxt_en: Add hw addr and multihost base hw addr to devlink info_get cb.

Message ID 1584458082-29207-6-git-send-email-vasundhara-v.volam@broadcom.com
State Changes Requested
Delegated to: David Miller
Headers show
Series bnxt_en updates to devlink cmd | expand

Commit Message

Vasundhara Volam March 17, 2020, 3:14 p.m. UTC
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@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.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(+)

Comments

Jakub Kicinski March 17, 2020, 5:47 p.m. UTC | #1
On Tue, 17 Mar 2020 20:44:42 +0530 Vasundhara Volam wrote:
> 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@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>

Nack. 

Make a proper serial number for the device, the point of common
Linux interfaces is to abstract differences between vendors. You
basically say "Broadcom is special, we will use our own identifier".

Also how is this a running version if it's supposed to be used for
asset management.
Vasundhara Volam March 18, 2020, 4:16 a.m. UTC | #2
On Tue, Mar 17, 2020 at 11:17 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 17 Mar 2020 20:44:42 +0530 Vasundhara Volam wrote:
> > 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@broadcom.com>
> > Signed-off-by: Michael Chan <michael.chan@broadcom.com>
>
> Nack.
>
> Make a proper serial number for the device, the point of common
> Linux interfaces is to abstract differences between vendors. You
> basically say "Broadcom is special, we will use our own identifier".
I thought only couple of vendors support multi-host NICs, so made this
macro as vendor specific. If it will be widely used, I will make it a generic
macro.

>
> Also how is this a running version if it's supposed to be used for
> asset management.
My mistake, will fix it to fixed version.

Thanks,
Vasundhara
Jakub Kicinski March 18, 2020, 8:10 p.m. UTC | #3
On Wed, 18 Mar 2020 09:46:46 +0530 Vasundhara Volam wrote:
> On Tue, Mar 17, 2020 at 11:17 PM Jakub Kicinski <kuba@kernel.org> wrote:
> > On Tue, 17 Mar 2020 20:44:42 +0530 Vasundhara Volam wrote:  
> > > 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@broadcom.com>
> > > Signed-off-by: Michael Chan <michael.chan@broadcom.com>  
> >
> > Nack.
> >
> > Make a proper serial number for the device, the point of common
> > Linux interfaces is to abstract differences between vendors. You
> > basically say "Broadcom is special, we will use our own identifier".  
> I thought only couple of vendors support multi-host NICs, so made this
> macro as vendor specific. If it will be widely used, I will make it a generic
> macro.

There is no use for the "base address" other than to identify the
device. Which is what serial numbers are for. If the "base address"
is unique, just put it in the serial number field.

Or. You actually don't have to do that because if I look at your commit
message - it's already the exact same value. Sigh.

> > Also how is this a running version if it's supposed to be used for
> > asset management.  
> My mistake, will fix it to fixed version.
diff mbox series

Patch

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