]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
qed: implement devlink info request
authorIgor Russkikh <irusskikh@marvell.com>
Sun, 23 Aug 2020 11:19:28 +0000 (14:19 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Aug 2020 01:01:32 +0000 (18:01 -0700)
Here we return existing fw & mfw versions, we also fetch device's
serial number:

~$ sudo ~/iproute2/devlink/devlink  dev info
pci/0000:01:00.1:
  driver qed
  board.serial_number REE1915E44552
  versions:
      running:
        fw.app 8.42.2.0
      stored:
        fw.mgmt 8.52.10.0

MFW and FW are different firmwares on device.
Management is a firmware responsible for link configuration and
various control plane features. Its permanent and resides in NVM.

Running FW (or fastpath FW) is an embedded microprogram implementing
all the packet processing, offloads, etc. This FW is being loaded
on each start by the driver from FW binary blob.

The base device specific structure (qed_dev_info) was not directly
available to the base driver before. Thus, here we create and store
a private copy of this structure in qed_dev root object to
access the data.

Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: Alexander Lobakin <alobakin@marvell.com>
Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed.h
drivers/net/ethernet/qlogic/qed/qed_dev.c
drivers/net/ethernet/qlogic/qed/qed_devlink.c
drivers/net/ethernet/qlogic/qed/qed_main.c

index b6ce1488abcc61595ad0b8d4e124cf7323683123..ccd789eeda3eaefaa22e2860a84d62062e662e36 100644 (file)
@@ -807,6 +807,7 @@ struct qed_dev {
        struct qed_llh_info *p_llh_info;
 
        /* Linux specific here */
+       struct qed_dev_info             common_dev_info;
        struct  qede_dev                *edev;
        struct  pci_dev                 *pdev;
        u32 flags;
index b3c9ebaf228077e618f7af9ad49f07307d97e63c..00f2d7f13de632c8fd421b19199ed036bba47dbd 100644 (file)
@@ -3973,6 +3973,7 @@ static int qed_hw_get_nvm_info(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
        struct qed_mcp_link_speed_params *ext_speed;
        struct qed_mcp_link_capabilities *p_caps;
        struct qed_mcp_link_params *link;
+       int i;
 
        /* Read global nvm_cfg address */
        nvm_cfg_addr = qed_rd(p_hwfn, p_ptt, MISC_REG_GEN_PURP_CR0);
@@ -4290,6 +4291,14 @@ static int qed_hw_get_nvm_info(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
                __set_bit(QED_DEV_CAP_ROCE,
                          &p_hwfn->hw_info.device_capabilities);
 
+       /* Read device serial number information from shmem */
+       addr = MCP_REG_SCRATCH + nvm_cfg1_offset +
+               offsetof(struct nvm_cfg1, glob) +
+               offsetof(struct nvm_cfg1_glob, serial_number);
+
+       for (i = 0; i < 4; i++)
+               p_hwfn->hw_info.part_num[i] = qed_rd(p_hwfn, p_ptt, addr + i * 4);
+
        return qed_mcp_fill_shmem_func_info(p_hwfn, p_ptt);
 }
 
index a62c47c61edf5b056a60eb8dbd4696f4d8c87d6f..47d54a96cbb9e01d437e41c0ab25ca30b5f86547 100644 (file)
@@ -45,7 +45,55 @@ static const struct devlink_param qed_devlink_params[] = {
                             qed_dl_param_get, qed_dl_param_set, NULL),
 };
 
-static const struct devlink_ops qed_dl_ops;
+static int qed_devlink_info_get(struct devlink *devlink,
+                               struct devlink_info_req *req,
+                               struct netlink_ext_ack *extack)
+{
+       struct qed_devlink *qed_dl = devlink_priv(devlink);
+       struct qed_dev *cdev = qed_dl->cdev;
+       struct qed_dev_info *dev_info;
+       char buf[100];
+       int err;
+
+       dev_info = &cdev->common_dev_info;
+
+       err = devlink_info_driver_name_put(req, KBUILD_MODNAME);
+       if (err)
+               return err;
+
+       memcpy(buf, cdev->hwfns[0].hw_info.part_num, sizeof(cdev->hwfns[0].hw_info.part_num));
+       buf[sizeof(cdev->hwfns[0].hw_info.part_num)] = 0;
+
+       if (buf[0]) {
+               err = devlink_info_board_serial_number_put(req, buf);
+               if (err)
+                       return err;
+       }
+
+       snprintf(buf, sizeof(buf), "%d.%d.%d.%d",
+                GET_MFW_FIELD(dev_info->mfw_rev, QED_MFW_VERSION_3),
+                GET_MFW_FIELD(dev_info->mfw_rev, QED_MFW_VERSION_2),
+                GET_MFW_FIELD(dev_info->mfw_rev, QED_MFW_VERSION_1),
+                GET_MFW_FIELD(dev_info->mfw_rev, QED_MFW_VERSION_0));
+
+       err = devlink_info_version_stored_put(req,
+                                             DEVLINK_INFO_VERSION_GENERIC_FW_MGMT, buf);
+       if (err)
+               return err;
+
+       snprintf(buf, sizeof(buf), "%d.%d.%d.%d",
+                dev_info->fw_major,
+                dev_info->fw_minor,
+                dev_info->fw_rev,
+                dev_info->fw_eng);
+
+       return devlink_info_version_running_put(req,
+                                               DEVLINK_INFO_VERSION_GENERIC_FW_APP, buf);
+}
+
+static const struct devlink_ops qed_dl_ops = {
+       .info_get = qed_devlink_info_get,
+};
 
 struct devlink *qed_devlink_register(struct qed_dev *cdev)
 {
index d6f76421379b260b91f4904a3303cc22f138fdbe..d1a559ccf5167b285db77b1a0231d473ce500d44 100644 (file)
@@ -479,6 +479,7 @@ int qed_fill_dev_info(struct qed_dev *cdev,
        }
 
        dev_info->mtu = hw_info->mtu;
+       cdev->common_dev_info = *dev_info;
 
        return 0;
 }