Skip to content

Commit c5795c5

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: Fix for pri to tc mapping in TM
Current mapping between pri and tc is one to one, so user can't map multi priorities to the same tc. This patch changes the mapping to many to one. Fixes: 8484405 ("net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver") Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 68ece54 commit c5795c5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,19 +376,20 @@ struct hnae3_ae_algo {
376376
struct hnae3_tc_info {
377377
u16 tqp_offset; /* TQP offset from base TQP */
378378
u16 tqp_count; /* Total TQPs */
379-
u8 up; /* user priority */
380379
u8 tc; /* TC index */
381380
bool enable; /* If this TC is enable or not */
382381
};
383382

384383
#define HNAE3_MAX_TC 8
384+
#define HNAE3_MAX_USER_PRIO 8
385385
struct hnae3_knic_private_info {
386386
struct net_device *netdev; /* Set by KNIC client when init instance */
387387
u16 rss_size; /* Allocated RSS queues */
388388
u16 rx_buf_len;
389389
u16 num_desc;
390390

391391
u8 num_tc; /* Total number of enabled TCs */
392+
u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */
392393
struct hnae3_tc_info tc_info[HNAE3_MAX_TC]; /* Idx of array is HW TC */
393394

394395
u16 num_tqps; /* total number of TQPs in this handle */

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ struct hclge_pg_info {
176176
struct hclge_tc_info {
177177
u8 tc_id;
178178
u8 tc_sch_mode; /* 0: sp; 1: dwrr */
179-
u8 up;
180179
u8 pgid;
181180
u32 bw_limit;
182181
};
@@ -197,6 +196,7 @@ struct hclge_tm_info {
197196
u8 num_tc;
198197
u8 num_pg; /* It must be 1 if vNET-Base schd */
199198
u8 pg_dwrr[HCLGE_PG_NUM];
199+
u8 prio_tc[HNAE3_MAX_USER_PRIO];
200200
struct hclge_pg_info pg_info[HCLGE_PG_NUM];
201201
struct hclge_tc_info tc_info[HNAE3_MAX_TC];
202202
enum hclge_fc_mode fc_mode;

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ static int hclge_fill_pri_array(struct hclge_dev *hdev, u8 *pri, u8 pri_id)
128128
{
129129
u8 tc;
130130

131-
for (tc = 0; tc < hdev->tm_info.num_tc; tc++)
132-
if (hdev->tm_info.tc_info[tc].up == pri_id)
133-
break;
131+
tc = hdev->tm_info.prio_tc[pri_id];
134132

135133
if (tc >= hdev->tm_info.num_tc)
136134
return -EINVAL;
@@ -158,7 +156,7 @@ static int hclge_up_to_tc_map(struct hclge_dev *hdev)
158156

159157
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_PRI_TO_TC_MAPPING, false);
160158

161-
for (pri_id = 0; pri_id < hdev->tm_info.num_tc; pri_id++) {
159+
for (pri_id = 0; pri_id < HNAE3_MAX_USER_PRIO; pri_id++) {
162160
ret = hclge_fill_pri_array(hdev, pri, pri_id);
163161
if (ret)
164162
return ret;
@@ -405,16 +403,17 @@ static void hclge_tm_vport_tc_info_update(struct hclge_vport *vport)
405403
kinfo->tc_info[i].tqp_offset = i * kinfo->rss_size;
406404
kinfo->tc_info[i].tqp_count = kinfo->rss_size;
407405
kinfo->tc_info[i].tc = i;
408-
kinfo->tc_info[i].up = hdev->tm_info.tc_info[i].up;
409406
} else {
410407
/* Set to default queue if TC is disable */
411408
kinfo->tc_info[i].enable = false;
412409
kinfo->tc_info[i].tqp_offset = 0;
413410
kinfo->tc_info[i].tqp_count = 1;
414411
kinfo->tc_info[i].tc = 0;
415-
kinfo->tc_info[i].up = 0;
416412
}
417413
}
414+
415+
memcpy(kinfo->prio_tc, hdev->tm_info.prio_tc,
416+
FIELD_SIZEOF(struct hnae3_knic_private_info, prio_tc));
418417
}
419418

420419
static void hclge_tm_vport_info_update(struct hclge_dev *hdev)
@@ -436,12 +435,15 @@ static void hclge_tm_tc_info_init(struct hclge_dev *hdev)
436435
for (i = 0; i < hdev->tm_info.num_tc; i++) {
437436
hdev->tm_info.tc_info[i].tc_id = i;
438437
hdev->tm_info.tc_info[i].tc_sch_mode = HCLGE_SCH_MODE_DWRR;
439-
hdev->tm_info.tc_info[i].up = i;
440438
hdev->tm_info.tc_info[i].pgid = 0;
441439
hdev->tm_info.tc_info[i].bw_limit =
442440
hdev->tm_info.pg_info[0].bw_limit;
443441
}
444442

443+
for (i = 0; i < HNAE3_MAX_USER_PRIO; i++)
444+
hdev->tm_info.prio_tc[i] =
445+
(i >= hdev->tm_info.num_tc) ? 0 : i;
446+
445447
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
446448
}
447449

0 commit comments

Comments
 (0)