hinic3: Add PF/VF capability parsing and parameter validation

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>
This commit is contained in:
Fan Gong 2026-03-10 09:04:56 +08:00 committed by Paolo Abeni
parent 33cf53672b
commit 330adcedd0
2 changed files with 52 additions and 3 deletions

View 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)

View 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;
};