RDMA/hns: Query the number of functions supported by the PF
authorWei Xu <xuwei5@hisilicon.com>
Tue, 6 Apr 2021 13:25:10 +0000 (21:25 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 13 Apr 2021 23:01:27 +0000 (20:01 -0300)
Query how many functions are supported by the PF from the FW and store it
in the hns_roce_dev structure which will be used to support the
configuration of virtual functions.

Link: https://lore.kernel.org/r/1617715514-29039-3-git-send-email-liweihang@huawei.com
Signed-off-by: Wei Xu <xuwei5@hisilicon.com>
Signed-off-by: Shengming Shu <shushengming1@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/hns/hns_roce_device.h
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.h

index 59c78185440253db79be87dba22387353fb8680c..c9fb5835a5904f55ee6a05027ffe40398911babc 100644 (file)
@@ -986,6 +986,7 @@ struct hns_roce_dev {
        void                    *priv;
        struct workqueue_struct *irq_workq;
        const struct hns_roce_dfx_hw *dfx;
+       u32 func_num;
        u32 cong_algo_tmpl_id;
 };
 
index 21169c099549ef197906c0e23c094aa95a98080d..a01e4dfbc81ad8a3af114104ef24207495c2a8d6 100644 (file)
@@ -1612,15 +1612,20 @@ static int hns_roce_query_func_info(struct hns_roce_dev *hr_dev)
        struct hns_roce_cmq_desc desc;
        int ret;
 
-       if (hr_dev->pci_dev->revision < PCI_REVISION_ID_HIP09)
+       if (hr_dev->pci_dev->revision < PCI_REVISION_ID_HIP09) {
+               hr_dev->func_num = 1;
                return 0;
+       }
 
        hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_QUERY_FUNC_INFO,
                                      true);
        ret = hns_roce_cmq_send(hr_dev, &desc, 1);
-       if (ret)
+       if (ret) {
+               hr_dev->func_num = 1;
                return ret;
+       }
 
+       hr_dev->func_num = le32_to_cpu(desc.func_info.own_func_num);
        hr_dev->cong_algo_tmpl_id = le32_to_cpu(desc.func_info.own_mac_id);
 
        return 0;
index e535f945e9398e19dd4bec66c050f731bc01c823..340acbc7e338d22b1c65d09f4e8c475107d29c48 100644 (file)
@@ -1710,9 +1710,9 @@ struct hns_roce_cmq_desc {
        union {
                __le32 data[6];
                struct {
-                       __le32 rsv1;
+                       __le32 own_func_num;
                        __le32 own_mac_id;
-                       __le32 rsv2[4];
+                       __le32 rsv[4];
                } func_info;
        };