]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hinic3: Add PF/VF capability parsing and parameter validation
authorFan Gong <gongfan1@huawei.com>
Tue, 10 Mar 2026 01:04:56 +0000 (09:04 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 12 Mar 2026 11:13:48 +0000 (12:13 +0100)
Add the ability to parse PF and VF capabilities and validate
related parameters(SQ & RQ).

Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
Link: https://patch.msgid.link/ac4733f2c0409bb778b4624ed1632dcb2ded6632.1773062356.git.zhuyikai1@h-partners.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h

index ca60cf4b6282a23118ede96e677f85d6f42b09e1..2dfa4fb396274fec3c752ecb5158bc7e06f95704 100644 (file)
@@ -17,6 +17,17 @@ static void hinic3_parse_pub_res_cap(struct hinic3_hwdev *hwdev,
 {
        cap->port_id = dev_cap->port_id;
        cap->supp_svcs_bitmap = dev_cap->svc_cap_en;
+
+       cap->cos_valid_bitmap = dev_cap->valid_cos_bitmap;
+       cap->port_cos_valid_bitmap = dev_cap->port_cos_valid_bitmap;
+
+       if (type != HINIC3_FUNC_TYPE_VF)
+               cap->max_vf = dev_cap->max_vf;
+       else
+               cap->max_vf = 0;
+
+       dev_dbg(hwdev->dev, "Port_id: 0x%x, cos_bitmap: 0x%x, Max_vf: 0x%x\n",
+               cap->port_id, cap->cos_valid_bitmap, cap->max_vf);
 }
 
 static void hinic3_parse_l2nic_res_cap(struct hinic3_hwdev *hwdev,
@@ -28,6 +39,13 @@ static void hinic3_parse_l2nic_res_cap(struct hinic3_hwdev *hwdev,
 
        nic_svc_cap->max_sqs = min(dev_cap->nic_max_sq_id + 1,
                                   HINIC3_CFG_MAX_QP);
+
+       nic_svc_cap->max_rqs = min(dev_cap->nic_max_rq_id + 1,
+                                  HINIC3_CFG_MAX_QP);
+       nic_svc_cap->default_num_queues = dev_cap->nic_default_num_queues;
+
+       dev_dbg(hwdev->dev, "L2nic resource capbility, max_sqs: 0x%x, max_rqs: 0x%x\n",
+               nic_svc_cap->max_sqs, nic_svc_cap->max_rqs);
 }
 
 static void hinic3_parse_dev_cap(struct hinic3_hwdev *hwdev,
@@ -44,8 +62,8 @@ static void hinic3_parse_dev_cap(struct hinic3_hwdev *hwdev,
                hinic3_parse_l2nic_res_cap(hwdev, cap, dev_cap, type);
 }
 
-static int get_cap_from_fw(struct hinic3_hwdev *hwdev,
-                          enum hinic3_func_type type)
+static int hinic3_get_cap_from_fw(struct hinic3_hwdev *hwdev,
+                                 enum hinic3_func_type type)
 {
        struct mgmt_msg_params msg_params = {};
        struct cfg_cmd_dev_cap dev_cap = {};
@@ -69,6 +87,29 @@ static int get_cap_from_fw(struct hinic3_hwdev *hwdev,
        return 0;
 }
 
+static int hinic3_get_dev_cap(struct hinic3_hwdev *hwdev)
+{
+       enum hinic3_func_type type = HINIC3_FUNC_TYPE(hwdev);
+       int err;
+
+       switch (type) {
+       case HINIC3_FUNC_TYPE_PF:
+       case HINIC3_FUNC_TYPE_VF:
+               err = hinic3_get_cap_from_fw(hwdev, type);
+               if (err) {
+                       dev_err(hwdev->dev, "Failed to get FW capability\n");
+                       return err;
+               }
+               break;
+       default:
+               dev_err(hwdev->dev, "Unsupported PCI Function type: %d\n",
+                       type);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int hinic3_init_irq_info(struct hinic3_hwdev *hwdev)
 {
        struct hinic3_cfg_mgmt_info *cfg_mgmt = hwdev->cfg_mgmt;
@@ -215,7 +256,7 @@ void hinic3_free_irq(struct hinic3_hwdev *hwdev, u32 irq_id)
 
 int hinic3_init_capability(struct hinic3_hwdev *hwdev)
 {
-       return get_cap_from_fw(hwdev, HINIC3_FUNC_TYPE_VF);
+       return hinic3_get_dev_cap(hwdev);
 }
 
 bool hinic3_support_nic(struct hinic3_hwdev *hwdev)
index 58806199bf5471448f322b3d584ada69e1be94aa..361c0b6a70f092ef173f9257676057ffc294db02 100644 (file)
@@ -26,6 +26,8 @@ struct hinic3_irq_info {
 
 struct hinic3_nic_service_cap {
        u16 max_sqs;
+       u16 max_rqs;
+       u16 default_num_queues;
 };
 
 /* Device capabilities */
@@ -34,6 +36,12 @@ struct hinic3_dev_cap {
        u16                           supp_svcs_bitmap;
        /* Physical port */
        u8                            port_id;
+
+       u8                            cos_valid_bitmap;
+       u8                            port_cos_valid_bitmap;
+       /* max number of VFs that PF supports */
+       u16                           max_vf;
+
        struct hinic3_nic_service_cap nic_svc_cap;
 };