aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYunsheng Lin <linyunsheng@huawei.com>2018-05-15 14:20:11 -0400
committerDavid S. Miller <davem@davemloft.net>2018-05-16 11:33:08 -0400
commit67bf2541f4b9a091e928d75eca544bca4c5db142 (patch)
tree861a2cfde48002d574b9988949deead227a8d39c
parent0c698257c7befa8d1ec1b8d767758c3d73a2686a (diff)
net: hns3: Fixes the back pressure setting when sriov is enabled
When sriov is enabled, the Qset and tc mapping is not longer one to one relation. This patch fixes it by mapping all pf and vf's Qset to tc. Fixes: 848440544b41 ("net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver") Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com> Signed-off-by: Peng Li <lipeng321@huawei.com> Signed-off-by: Salil Mehta <salil.mehta@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c45
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h5
2 files changed, 45 insertions, 5 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
index c69ecab460f9..262c125f8137 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
@@ -500,7 +500,8 @@ static int hclge_tm_qs_schd_mode_cfg(struct hclge_dev *hdev, u16 qs_id, u8 mode)
500 return hclge_cmd_send(&hdev->hw, &desc, 1); 500 return hclge_cmd_send(&hdev->hw, &desc, 1);
501} 501}
502 502
503static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc) 503static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc, u8 grp_id,
504 u32 bit_map)
504{ 505{
505 struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd; 506 struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd;
506 struct hclge_desc desc; 507 struct hclge_desc desc;
@@ -511,9 +512,8 @@ static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc)
511 bp_to_qs_map_cmd = (struct hclge_bp_to_qs_map_cmd *)desc.data; 512 bp_to_qs_map_cmd = (struct hclge_bp_to_qs_map_cmd *)desc.data;
512 513
513 bp_to_qs_map_cmd->tc_id = tc; 514 bp_to_qs_map_cmd->tc_id = tc;
514 515 bp_to_qs_map_cmd->qs_group_id = grp_id;
515 /* Qset and tc is one by one mapping */ 516 bp_to_qs_map_cmd->qs_bit_map = cpu_to_le32(bit_map);
516 bp_to_qs_map_cmd->qs_bit_map = cpu_to_le32(1 << tc);
517 517
518 return hclge_cmd_send(&hdev->hw, &desc, 1); 518 return hclge_cmd_send(&hdev->hw, &desc, 1);
519} 519}
@@ -1167,6 +1167,41 @@ static int hclge_pfc_setup_hw(struct hclge_dev *hdev)
1167 hdev->tm_info.hw_pfc_map); 1167 hdev->tm_info.hw_pfc_map);
1168} 1168}
1169 1169
1170/* Each Tc has a 1024 queue sets to backpress, it divides to
1171 * 32 group, each group contains 32 queue sets, which can be
1172 * represented by u32 bitmap.
1173 */
1174static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc)
1175{
1176 struct hclge_vport *vport = hdev->vport;
1177 u32 i, k, qs_bitmap;
1178 int ret;
1179
1180 for (i = 0; i < HCLGE_BP_GRP_NUM; i++) {
1181 qs_bitmap = 0;
1182
1183 for (k = 0; k < hdev->num_alloc_vport; k++) {
1184 u16 qs_id = vport->qs_offset + tc;
1185 u8 grp, sub_grp;
1186
1187 grp = hnae_get_field(qs_id, HCLGE_BP_GRP_ID_M,
1188 HCLGE_BP_GRP_ID_S);
1189 sub_grp = hnae_get_field(qs_id, HCLGE_BP_SUB_GRP_ID_M,
1190 HCLGE_BP_SUB_GRP_ID_S);
1191 if (i == grp)
1192 qs_bitmap |= (1 << sub_grp);
1193
1194 vport++;
1195 }
1196
1197 ret = hclge_tm_qs_bp_cfg(hdev, tc, i, qs_bitmap);
1198 if (ret)
1199 return ret;
1200 }
1201
1202 return 0;
1203}
1204
1170static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev) 1205static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
1171{ 1206{
1172 bool tx_en, rx_en; 1207 bool tx_en, rx_en;
@@ -1218,7 +1253,7 @@ int hclge_pause_setup_hw(struct hclge_dev *hdev)
1218 dev_warn(&hdev->pdev->dev, "set pfc pause failed:%d\n", ret); 1253 dev_warn(&hdev->pdev->dev, "set pfc pause failed:%d\n", ret);
1219 1254
1220 for (i = 0; i < hdev->tm_info.num_tc; i++) { 1255 for (i = 0; i < hdev->tm_info.num_tc; i++) {
1221 ret = hclge_tm_qs_bp_cfg(hdev, i); 1256 ret = hclge_bp_setup_hw(hdev, i);
1222 if (ret) 1257 if (ret)
1223 return ret; 1258 return ret;
1224 } 1259 }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
index 2dbe177581e9..c2b6e8a6700f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
@@ -89,6 +89,11 @@ struct hclge_pg_shapping_cmd {
89 __le32 pg_shapping_para; 89 __le32 pg_shapping_para;
90}; 90};
91 91
92#define HCLGE_BP_GRP_NUM 32
93#define HCLGE_BP_SUB_GRP_ID_S 0
94#define HCLGE_BP_SUB_GRP_ID_M GENMASK(4, 0)
95#define HCLGE_BP_GRP_ID_S 5
96#define HCLGE_BP_GRP_ID_M GENMASK(9, 5)
92struct hclge_bp_to_qs_map_cmd { 97struct hclge_bp_to_qs_map_cmd {
93 u8 tc_id; 98 u8 tc_id;
94 u8 rsvd[2]; 99 u8 rsvd[2];