From: Shunfeng Yang yangshunfeng2@huawei.com
mainline inclusion from mainline-v5.13 commit 847d19a45146 category: bugfix bugzilla: NA CVE: NA
Implement the ops named get_dev_fw_str to support ib_get_device_fw_str().
Signed-off-by: Shunfeng Yang yangshunfeng2@huawei.com Signed-off-by: Yangyang Li liyangyang20@huawei.com Reviewed-by: chunzhi hu huchunzhi@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 9ed050f790a40..a604e6d931544 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -701,6 +701,19 @@ static void hns_roce_disassociate_ucontext(struct ib_ucontext *ibcontext) mutex_unlock(&context->vma_list_mutex); }
+static void hns_roce_get_fw_ver(struct ib_device *device, char *str) +{ + u64 fw_ver = to_hr_dev(device)->caps.fw_ver; + unsigned int major, minor, sub_minor; + + major = upper_32_bits(fw_ver); + minor = high_16_bits(lower_32_bits(fw_ver)); + sub_minor = low_16_bits(fw_ver); + + snprintf(str, IB_FW_VERSION_NAME_MAX, "%u.%u.%04u", major, minor, + sub_minor); +} + static const char * const hns_roce_hw_stats_name[] = { "pd_alloc", "pd_dealloc", @@ -923,6 +936,9 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) ib_dev->dealloc_ucontext = hns_roce_dealloc_ucontext; ib_dev->mmap = hns_roce_mmap;
+ /* FW */ + ib_dev->get_dev_fw_str = hns_roce_get_fw_ver; + /* PD */ ib_dev->alloc_pd = hns_roce_alloc_pd; ib_dev->dealloc_pd = hns_roce_dealloc_pd;