Skip to content

Commit 0a5677d

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: Add support for port shaper setting in TM module
This patch add a tm_port_shaper cmd and set port shaper to HCLGE_ETHER_MAX_RATE on TM initialization process. Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9dc2145 commit 0a5677d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,34 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev,
301301
return hclge_cmd_send(&hdev->hw, &desc, 1);
302302
}
303303

304+
static int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev)
305+
{
306+
struct hclge_port_shapping_cmd *shap_cfg_cmd;
307+
struct hclge_desc desc;
308+
u32 shapping_para = 0;
309+
u8 ir_u, ir_b, ir_s;
310+
int ret;
311+
312+
ret = hclge_shaper_para_calc(HCLGE_ETHER_MAX_RATE,
313+
HCLGE_SHAPER_LVL_PORT,
314+
&ir_b, &ir_u, &ir_s);
315+
if (ret)
316+
return ret;
317+
318+
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_TM_PORT_SHAPPING, false);
319+
shap_cfg_cmd = (struct hclge_port_shapping_cmd *)desc.data;
320+
321+
hclge_tm_set_field(shapping_para, IR_B, ir_b);
322+
hclge_tm_set_field(shapping_para, IR_U, ir_u);
323+
hclge_tm_set_field(shapping_para, IR_S, ir_s);
324+
hclge_tm_set_field(shapping_para, BS_B, HCLGE_SHAPER_BS_U_DEF);
325+
hclge_tm_set_field(shapping_para, BS_S, HCLGE_SHAPER_BS_S_DEF);
326+
327+
shap_cfg_cmd->port_shapping_para = cpu_to_le32(shapping_para);
328+
329+
return hclge_cmd_send(&hdev->hw, &desc, 1);
330+
}
331+
304332
static int hclge_tm_pri_shapping_cfg(struct hclge_dev *hdev,
305333
enum hclge_shap_bucket bucket, u8 pri_id,
306334
u8 ir_b, u8 ir_u, u8 ir_s,
@@ -864,6 +892,10 @@ static int hclge_tm_shaper_cfg(struct hclge_dev *hdev)
864892
{
865893
int ret;
866894

895+
ret = hclge_tm_port_shaper_cfg(hdev);
896+
if (ret)
897+
return ret;
898+
867899
ret = hclge_tm_pg_shaper_cfg(hdev);
868900
if (ret)
869901
return ret;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ struct hclge_pfc_en_cmd {
9999
u8 pri_en_bitmap;
100100
};
101101

102+
struct hclge_port_shapping_cmd {
103+
__le32 port_shapping_para;
104+
};
105+
102106
#define hclge_tm_set_field(dest, string, val) \
103107
hnae_set_field((dest), (HCLGE_TM_SHAP_##string##_MSK), \
104108
(HCLGE_TM_SHAP_##string##_LSH), val)

0 commit comments

Comments
 (0)