Commit 53916a67 authored by Igor Russkikh's avatar Igor Russkikh Committed by David S. Miller

qed: implement devlink info request

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: default avatarIgor Russkikh <irusskikh@marvell.com>
Signed-off-by: default avatarAlexander Lobakin <alobakin@marvell.com>
Signed-off-by: default avatarMichal Kalderon <michal.kalderon@marvell.com>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b75d05b2
......@@ -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;
......
......@@ -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);
}
......
......@@ -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)
{
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment