1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2019 Hisilicon Limited.
8 #define HNS3_ETHER_MAX_RATE 100000
11 #define HNS3_TX_MAC_PAUSE_EN_MSK BIT(0)
12 #define HNS3_RX_MAC_PAUSE_EN_MSK BIT(1)
14 #define HNS3_DEFAULT_PAUSE_TRANS_GAP 0x18
15 #define HNS3_DEFAULT_PAUSE_TRANS_TIME 0xFFFF
18 #define HNS3_DCB_TX_SCHD_DWRR_MSK BIT(0)
19 #define HNS3_DCB_TX_SCHD_SP_MSK (0xFE)
21 enum hns3_shap_bucket {
22 HNS3_DCB_SHAP_C_BUCKET = 0,
23 HNS3_DCB_SHAP_P_BUCKET,
26 struct hns3_priority_weight_cmd {
32 struct hns3_qs_weight_cmd {
38 struct hns3_pg_weight_cmd {
44 struct hns3_ets_tc_weight_cmd {
45 uint8_t tc_weight[HNS3_MAX_TC_NUM];
46 uint8_t weight_offset;
50 struct hns3_qs_to_pri_link_cmd {
54 #define HNS3_DCB_QS_PRI_LINK_VLD_MSK BIT(0)
59 struct hns3_nq_to_qs_link_cmd {
62 #define HNS3_DCB_Q_QS_LINK_VLD_MSK BIT(10)
67 #define HNS3_DCB_SHAP_IR_B_MSK GENMASK(7, 0)
68 #define HNS3_DCB_SHAP_IR_B_LSH 0
69 #define HNS3_DCB_SHAP_IR_U_MSK GENMASK(11, 8)
70 #define HNS3_DCB_SHAP_IR_U_LSH 8
71 #define HNS3_DCB_SHAP_IR_S_MSK GENMASK(15, 12)
72 #define HNS3_DCB_SHAP_IR_S_LSH 12
73 #define HNS3_DCB_SHAP_BS_B_MSK GENMASK(20, 16)
74 #define HNS3_DCB_SHAP_BS_B_LSH 16
75 #define HNS3_DCB_SHAP_BS_S_MSK GENMASK(25, 21)
76 #define HNS3_DCB_SHAP_BS_S_LSH 21
78 struct hns3_pri_shapping_cmd {
81 uint32_t pri_shapping_para;
85 struct hns3_pg_shapping_cmd {
88 uint32_t pg_shapping_para;
92 #define HNS3_BP_GRP_NUM 32
93 #define HNS3_BP_SUB_GRP_ID_S 0
94 #define HNS3_BP_SUB_GRP_ID_M GENMASK(4, 0)
95 #define HNS3_BP_GRP_ID_S 5
96 #define HNS3_BP_GRP_ID_M GENMASK(9, 5)
97 struct hns3_bp_to_qs_map_cmd {
105 struct hns3_pfc_en_cmd {
106 uint8_t tx_rx_en_bitmap;
107 uint8_t pri_en_bitmap;
111 struct hns3_port_shapping_cmd {
112 uint32_t port_shapping_para;
116 struct hns3_cfg_pause_param_cmd {
117 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
118 uint8_t pause_trans_gap;
120 uint16_t pause_trans_time;
122 /* extra mac address to do double check for pause frame */
123 uint8_t mac_addr_extra[RTE_ETHER_ADDR_LEN];
127 struct hns3_pg_to_pri_link_cmd {
134 enum hns3_shaper_level {
135 HNS3_SHAPER_LVL_PRI = 0,
136 HNS3_SHAPER_LVL_PG = 1,
137 HNS3_SHAPER_LVL_PORT = 2,
138 HNS3_SHAPER_LVL_QSET = 3,
139 HNS3_SHAPER_LVL_CNT = 4,
140 HNS3_SHAPER_LVL_VF = 0,
141 HNS3_SHAPER_LVL_PF = 1,
144 struct hns3_shaper_parameter {
145 uint32_t ir_b; /* IR_B parameter of IR shaper */
146 uint32_t ir_u; /* IR_U parameter of IR shaper */
147 uint32_t ir_s; /* IR_S parameter of IR shaper */
150 #define hns3_dcb_set_field(dest, string, val) \
151 hns3_set_field((dest), \
152 (HNS3_DCB_SHAP_##string##_MSK), \
153 (HNS3_DCB_SHAP_##string##_LSH), val)
154 #define hns3_dcb_get_field(src, string) \
155 hns3_get_field((src), (HNS3_DCB_SHAP_##string##_MSK), \
156 (HNS3_DCB_SHAP_##string##_LSH))
158 int hns3_pause_addr_cfg(struct hns3_hw *hw, const uint8_t *mac_addr);
160 int hns3_dcb_configure(struct hns3_adapter *hns);
162 int hns3_dcb_init(struct hns3_hw *hw);
164 int hns3_dcb_init_hw(struct hns3_hw *hw);
166 int hns3_dcb_info_init(struct hns3_hw *hw);
169 hns3_fc_enable(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf);
172 hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf);
174 void hns3_set_rss_size(struct hns3_hw *hw, uint16_t nb_rx_q);
176 void hns3_tc_queue_mapping_cfg(struct hns3_hw *hw, uint16_t nb_queue);
178 int hns3_dcb_cfg_update(struct hns3_adapter *hns);
180 #endif /* _HNS3_DCB_H_ */