net: hns3: PF support get unicast MAC address space assigned by firmware
authorGuangbin Huang <huangguangbin2@huawei.com>
Tue, 14 Sep 2021 12:11:16 +0000 (20:11 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 May 2024 09:50:58 +0000 (11:50 +0200)
[ Upstream commit e435a6b5315a05a4e4e9f77679a57fd0d679e384 ]

Currently, there are two ways for PF to set the unicast MAC address space
size: specified by config parameters in firmware or set to default value.

That's mean if the config parameters in firmware is zero, driver will
divide the whole unicast MAC address space equally to 8 PFs. However, in
this case, the unicast MAC address space will be wasted a lot when the
hardware actually has less then 8 PFs. And in the other hand, if one PF has
much more VFs than other PFs, then each function of this PF will has much
less address space than other PFs.

In order to ameliorate the above two situations, introduce the third way
of unicast MAC address space assignment: firmware divides the whole unicast
MAC address space equally to functions of all PFs, and calculates the space
size of each PF according to its function number. PF queries the space size
by the querying device specification command when in initialization
process.

The third way assignment is lower priority than specified by config
parameters, only if the config parameters is zero can be used, and if
firmware does not support the third way assignment, then driver still
divides the whole unicast MAC address space equally to 8 PFs.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 05eb60e9648c ("net: hns3: using user configure after hardware reset")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index b51afb83d023e5f99843e10263e1c11d2ef2d4b7..8dfa372df8e77422c8142620f0d21becf8f03743 100644 (file)
@@ -341,6 +341,7 @@ struct hnae3_dev_specs {
        u8 max_non_tso_bd_num; /* max BD number of one non-TSO packet */
        u16 max_frm_size;
        u16 max_qset_num;
+       u16 umv_size;
 };
 
 struct hnae3_client_ops {
index 45f245b1d331cdbe8a319d25d464839e63d8c8ce..bd801e35d51eae4239df16cf3e98d4f9d7158cd9 100644 (file)
@@ -924,6 +924,8 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos)
                          dev_specs->max_tm_rate);
        *pos += scnprintf(buf + *pos, len - *pos, "MAX QSET number: %u\n",
                          dev_specs->max_qset_num);
+       *pos += scnprintf(buf + *pos, len - *pos, "umv size: %u\n",
+                         dev_specs->umv_size);
 }
 
 static int hns3_dbg_dev_info(struct hnae3_handle *h, char *buf, int len)
index 33244472e0d0e7e820e96a49e0cef8a81b2d0db8..cfbb7c51b0cb3a9b11872338f2dba521e508c2cc 100644 (file)
@@ -1188,7 +1188,9 @@ struct hclge_dev_specs_1_cmd {
        __le16 max_frm_size;
        __le16 max_qset_num;
        __le16 max_int_gl;
-       u8 rsv1[18];
+       u8 rsv0[2];
+       __le16 umv_size;
+       u8 rsv1[14];
 };
 
 /* mac speed type defined in firmware command */
index 598da1be22ebe9f6a1b202689be4d65fe9be4388..3423b8e278e3a1e4edba88d6541bc22c6aba2fb2 100644 (file)
@@ -1343,8 +1343,6 @@ static void hclge_parse_cfg(struct hclge_cfg *cfg, struct hclge_desc *desc)
        cfg->umv_space = hnae3_get_field(__le32_to_cpu(req->param[1]),
                                         HCLGE_CFG_UMV_TBL_SPACE_M,
                                         HCLGE_CFG_UMV_TBL_SPACE_S);
-       if (!cfg->umv_space)
-               cfg->umv_space = HCLGE_DEFAULT_UMV_SPACE_PER_PF;
 
        cfg->pf_rss_size_max = hnae3_get_field(__le32_to_cpu(req->param[2]),
                                               HCLGE_CFG_PF_RSS_SIZE_M,
@@ -1420,6 +1418,7 @@ static void hclge_set_default_dev_specs(struct hclge_dev *hdev)
        ae_dev->dev_specs.max_int_gl = HCLGE_DEF_MAX_INT_GL;
        ae_dev->dev_specs.max_frm_size = HCLGE_MAC_MAX_FRAME;
        ae_dev->dev_specs.max_qset_num = HCLGE_MAX_QSET_NUM;
+       ae_dev->dev_specs.umv_size = HCLGE_DEFAULT_UMV_SPACE_PER_PF;
 }
 
 static void hclge_parse_dev_specs(struct hclge_dev *hdev,
@@ -1441,6 +1440,7 @@ static void hclge_parse_dev_specs(struct hclge_dev *hdev,
        ae_dev->dev_specs.max_qset_num = le16_to_cpu(req1->max_qset_num);
        ae_dev->dev_specs.max_int_gl = le16_to_cpu(req1->max_int_gl);
        ae_dev->dev_specs.max_frm_size = le16_to_cpu(req1->max_frm_size);
+       ae_dev->dev_specs.umv_size = le16_to_cpu(req1->umv_size);
 }
 
 static void hclge_check_dev_specs(struct hclge_dev *hdev)
@@ -1461,6 +1461,8 @@ static void hclge_check_dev_specs(struct hclge_dev *hdev)
                dev_specs->max_int_gl = HCLGE_DEF_MAX_INT_GL;
        if (!dev_specs->max_frm_size)
                dev_specs->max_frm_size = HCLGE_MAC_MAX_FRAME;
+       if (!dev_specs->umv_size)
+               dev_specs->umv_size = HCLGE_DEFAULT_UMV_SPACE_PER_PF;
 }
 
 static int hclge_query_dev_specs(struct hclge_dev *hdev)
@@ -1550,7 +1552,10 @@ static int hclge_configure(struct hclge_dev *hdev)
        hdev->tm_info.num_pg = 1;
        hdev->tc_max = cfg.tc_num;
        hdev->tm_info.hw_pfc_map = 0;
-       hdev->wanted_umv_size = cfg.umv_space;
+       if (cfg.umv_space)
+               hdev->wanted_umv_size = cfg.umv_space;
+       else
+               hdev->wanted_umv_size = hdev->ae_dev->dev_specs.umv_size;
        hdev->tx_spare_buf_size = cfg.tx_spare_buf_size;
        hdev->gro_en = true;
        if (cfg.vlan_fliter_cap == HCLGE_VLAN_FLTR_CAN_MDF)