Skip to content

Commit 2fc6854

Browse files
selvintxavierdledford
authored andcommitted
RDMA/bnxt_re: Add support for query firmware version
The device now reports firmware version thus, removing the hard coded values of the FW version string and redundant fw_rev hook from sysfs. Adding code to query firmware version from underlying device and report it through the kernel verb to get firmware version string. Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Devesh Sharma <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent ccd9d0d commit 2fc6854

File tree

6 files changed

+39
-15
lines changed

6 files changed

+39
-15
lines changed

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ int bnxt_re_query_device(struct ib_device *ibdev,
141141
struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
142142

143143
memset(ib_attr, 0, sizeof(*ib_attr));
144-
145-
ib_attr->fw_ver = (u64)(unsigned long)(dev_attr->fw_ver);
144+
memcpy(&ib_attr->fw_ver, dev_attr->fw_ver,
145+
min(sizeof(dev_attr->fw_ver),
146+
sizeof(ib_attr->fw_ver)));
146147
bnxt_qplib_get_guid(rdev->netdev->dev_addr,
147148
(u8 *)&ib_attr->sys_image_guid);
148149
ib_attr->max_mr_size = BNXT_RE_MAX_MR_SIZE;
@@ -281,6 +282,15 @@ int bnxt_re_get_port_immutable(struct ib_device *ibdev, u8 port_num,
281282
return 0;
282283
}
283284

285+
void bnxt_re_query_fw_str(struct ib_device *ibdev, char *str)
286+
{
287+
struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
288+
289+
snprintf(str, IB_FW_VERSION_NAME_MAX, "%d.%d.%d.%d",
290+
rdev->dev_attr.fw_ver[0], rdev->dev_attr.fw_ver[1],
291+
rdev->dev_attr.fw_ver[2], rdev->dev_attr.fw_ver[3]);
292+
}
293+
284294
int bnxt_re_query_pkey(struct ib_device *ibdev, u8 port_num,
285295
u16 index, u16 *pkey)
286296
{

drivers/infiniband/hw/bnxt_re/ib_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ int bnxt_re_query_port(struct ib_device *ibdev, u8 port_num,
143143
struct ib_port_attr *port_attr);
144144
int bnxt_re_get_port_immutable(struct ib_device *ibdev, u8 port_num,
145145
struct ib_port_immutable *immutable);
146+
void bnxt_re_query_fw_str(struct ib_device *ibdev, char *str);
146147
int bnxt_re_query_pkey(struct ib_device *ibdev, u8 port_num,
147148
u16 index, u16 *pkey);
148149
int bnxt_re_del_gid(struct ib_device *ibdev, u8 port_num,

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
572572

573573
ibdev->query_port = bnxt_re_query_port;
574574
ibdev->get_port_immutable = bnxt_re_get_port_immutable;
575+
ibdev->get_dev_fw_str = bnxt_re_query_fw_str;
575576
ibdev->query_pkey = bnxt_re_query_pkey;
576577
ibdev->query_gid = bnxt_re_query_gid;
577578
ibdev->get_netdev = bnxt_re_get_netdev;
@@ -623,14 +624,6 @@ static ssize_t show_rev(struct device *device, struct device_attribute *attr,
623624
return scnprintf(buf, PAGE_SIZE, "0x%x\n", rdev->en_dev->pdev->vendor);
624625
}
625626

626-
static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
627-
char *buf)
628-
{
629-
struct bnxt_re_dev *rdev = to_bnxt_re_dev(device, ibdev.dev);
630-
631-
return scnprintf(buf, PAGE_SIZE, "%s\n", rdev->dev_attr.fw_ver);
632-
}
633-
634627
static ssize_t show_hca(struct device *device, struct device_attribute *attr,
635628
char *buf)
636629
{
@@ -640,12 +633,10 @@ static ssize_t show_hca(struct device *device, struct device_attribute *attr,
640633
}
641634

642635
static DEVICE_ATTR(hw_rev, 0444, show_rev, NULL);
643-
static DEVICE_ATTR(fw_rev, 0444, show_fw_ver, NULL);
644636
static DEVICE_ATTR(hca_type, 0444, show_hca, NULL);
645637

646638
static struct device_attribute *bnxt_re_attributes[] = {
647639
&dev_attr_hw_rev,
648-
&dev_attr_fw_rev,
649640
&dev_attr_hca_type
650641
};
651642

drivers/infiniband/hw/bnxt_re/qplib_rcfw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw, struct cmdq_base *req,
9393
opcode = req->opcode;
9494
if (!test_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags) &&
9595
(opcode != CMDQ_BASE_OPCODE_QUERY_FUNC &&
96-
opcode != CMDQ_BASE_OPCODE_INITIALIZE_FW)) {
96+
opcode != CMDQ_BASE_OPCODE_INITIALIZE_FW &&
97+
opcode != CMDQ_BASE_OPCODE_QUERY_VERSION)) {
9798
dev_err(&rcfw->pdev->dev,
9899
"QPLIB: RCFW not initialized, reject opcode 0x%x",
99100
opcode);

drivers/infiniband/hw/bnxt_re/qplib_sp.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ static bool bnxt_qplib_is_atomic_cap(struct bnxt_qplib_rcfw *rcfw)
6464
return !!(pcie_ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ);
6565
}
6666

67+
static void bnxt_qplib_query_version(struct bnxt_qplib_rcfw *rcfw,
68+
char *fw_ver)
69+
{
70+
struct cmdq_query_version req;
71+
struct creq_query_version_resp resp;
72+
u16 cmd_flags = 0;
73+
int rc = 0;
74+
75+
RCFW_CMD_PREP(req, QUERY_VERSION, cmd_flags);
76+
77+
rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req,
78+
(void *)&resp, NULL, 0);
79+
if (rc)
80+
return;
81+
fw_ver[0] = resp.fw_maj;
82+
fw_ver[1] = resp.fw_minor;
83+
fw_ver[2] = resp.fw_bld;
84+
fw_ver[3] = resp.fw_rsvd;
85+
}
86+
6787
int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
6888
struct bnxt_qplib_dev_attr *attr, bool vf)
6989
{
@@ -134,7 +154,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
134154
attr->l2_db_size = (sb->l2_db_space_size + 1) * PAGE_SIZE;
135155
attr->max_sgid = le32_to_cpu(sb->max_gid);
136156

137-
strlcpy(attr->fw_ver, "20.6.28.0", sizeof(attr->fw_ver));
157+
bnxt_qplib_query_version(rcfw, attr->fw_ver);
138158

139159
for (i = 0; i < MAX_TQM_ALLOC_REQ / 4; i++) {
140160
temp = le32_to_cpu(sb->tqm_alloc_reqs[i]);

drivers/infiniband/hw/bnxt_re/qplib_sp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
#define PCI_EXP_DEVCTL2_ATOMIC_REQ 0x0040
4646

4747
struct bnxt_qplib_dev_attr {
48-
char fw_ver[32];
48+
#define FW_VER_ARR_LEN 4
49+
u8 fw_ver[FW_VER_ARR_LEN];
4950
u16 max_sgid;
5051
u16 max_mrw;
5152
u32 max_qp;

0 commit comments

Comments
 (0)