1
2
3
4
5
6
7
8
9
10#ifndef __HCLGE_CMD_H
11#define __HCLGE_CMD_H
12#include <linux/types.h>
13#include <linux/io.h>
14
15#define HCLGE_CMDQ_TX_TIMEOUT 30000
16
17struct hclge_dev;
18struct hclge_desc {
19 __le16 opcode;
20
21#define HCLGE_CMDQ_RX_INVLD_B 0
22#define HCLGE_CMDQ_RX_OUTVLD_B 1
23
24 __le16 flag;
25 __le16 retval;
26 __le16 rsv;
27 __le32 data[6];
28};
29
30struct hclge_desc_cb {
31 dma_addr_t dma;
32 void *va;
33 u32 length;
34};
35
36struct hclge_cmq_ring {
37 dma_addr_t desc_dma_addr;
38 struct hclge_desc *desc;
39 struct hclge_desc_cb *desc_cb;
40 struct hclge_dev *dev;
41 u32 head;
42 u32 tail;
43
44 u16 buf_size;
45 u16 desc_num;
46 int next_to_use;
47 int next_to_clean;
48 u8 flag;
49 spinlock_t lock;
50};
51
52enum hclge_cmd_return_status {
53 HCLGE_CMD_EXEC_SUCCESS = 0,
54 HCLGE_CMD_NO_AUTH = 1,
55 HCLGE_CMD_NOT_EXEC = 2,
56 HCLGE_CMD_QUEUE_FULL = 3,
57};
58
59enum hclge_cmd_status {
60 HCLGE_STATUS_SUCCESS = 0,
61 HCLGE_ERR_CSQ_FULL = -1,
62 HCLGE_ERR_CSQ_TIMEOUT = -2,
63 HCLGE_ERR_CSQ_ERROR = -3,
64};
65
66struct hclge_misc_vector {
67 u8 __iomem *addr;
68 int vector_irq;
69};
70
71struct hclge_cmq {
72 struct hclge_cmq_ring csq;
73 struct hclge_cmq_ring crq;
74 u16 tx_timeout;
75 enum hclge_cmd_status last_status;
76};
77
78#define HCLGE_CMD_FLAG_IN BIT(0)
79#define HCLGE_CMD_FLAG_OUT BIT(1)
80#define HCLGE_CMD_FLAG_NEXT BIT(2)
81#define HCLGE_CMD_FLAG_WR BIT(3)
82#define HCLGE_CMD_FLAG_NO_INTR BIT(4)
83#define HCLGE_CMD_FLAG_ERR_INTR BIT(5)
84
85enum hclge_opcode_type {
86
87 HCLGE_OPC_QUERY_FW_VER = 0x0001,
88 HCLGE_OPC_CFG_RST_TRIGGER = 0x0020,
89 HCLGE_OPC_GBL_RST_STATUS = 0x0021,
90 HCLGE_OPC_QUERY_FUNC_STATUS = 0x0022,
91 HCLGE_OPC_QUERY_PF_RSRC = 0x0023,
92 HCLGE_OPC_QUERY_VF_RSRC = 0x0024,
93 HCLGE_OPC_GET_CFG_PARAM = 0x0025,
94
95 HCLGE_OPC_STATS_64_BIT = 0x0030,
96 HCLGE_OPC_STATS_32_BIT = 0x0031,
97 HCLGE_OPC_STATS_MAC = 0x0032,
98
99 HCLGE_OPC_QUERY_REG_NUM = 0x0040,
100 HCLGE_OPC_QUERY_32_BIT_REG = 0x0041,
101 HCLGE_OPC_QUERY_64_BIT_REG = 0x0042,
102
103
104
105 HCLGE_OPC_CONFIG_MAC_MODE = 0x0301,
106 HCLGE_OPC_CONFIG_AN_MODE = 0x0304,
107 HCLGE_OPC_QUERY_AN_RESULT = 0x0306,
108 HCLGE_OPC_QUERY_LINK_STATUS = 0x0307,
109 HCLGE_OPC_CONFIG_MAX_FRM_SIZE = 0x0308,
110 HCLGE_OPC_CONFIG_SPEED_DUP = 0x0309,
111 HCLGE_OPC_SERDES_LOOPBACK = 0x0315,
112
113
114
115 HCLGE_OPC_CFG_MAC_PAUSE_EN = 0x0701,
116 HCLGE_OPC_CFG_PFC_PAUSE_EN = 0x0702,
117 HCLGE_OPC_CFG_MAC_PARA = 0x0703,
118 HCLGE_OPC_CFG_PFC_PARA = 0x0704,
119 HCLGE_OPC_QUERY_MAC_TX_PKT_CNT = 0x0705,
120 HCLGE_OPC_QUERY_MAC_RX_PKT_CNT = 0x0706,
121 HCLGE_OPC_QUERY_PFC_TX_PKT_CNT = 0x0707,
122 HCLGE_OPC_QUERY_PFC_RX_PKT_CNT = 0x0708,
123 HCLGE_OPC_PRI_TO_TC_MAPPING = 0x0709,
124 HCLGE_OPC_QOS_MAP = 0x070A,
125
126
127 HCLGE_OPC_TM_PG_TO_PRI_LINK = 0x0804,
128 HCLGE_OPC_TM_QS_TO_PRI_LINK = 0x0805,
129 HCLGE_OPC_TM_NQ_TO_QS_LINK = 0x0806,
130 HCLGE_OPC_TM_RQ_TO_QS_LINK = 0x0807,
131 HCLGE_OPC_TM_PORT_WEIGHT = 0x0808,
132 HCLGE_OPC_TM_PG_WEIGHT = 0x0809,
133 HCLGE_OPC_TM_QS_WEIGHT = 0x080A,
134 HCLGE_OPC_TM_PRI_WEIGHT = 0x080B,
135 HCLGE_OPC_TM_PRI_C_SHAPPING = 0x080C,
136 HCLGE_OPC_TM_PRI_P_SHAPPING = 0x080D,
137 HCLGE_OPC_TM_PG_C_SHAPPING = 0x080E,
138 HCLGE_OPC_TM_PG_P_SHAPPING = 0x080F,
139 HCLGE_OPC_TM_PORT_SHAPPING = 0x0810,
140 HCLGE_OPC_TM_PG_SCH_MODE_CFG = 0x0812,
141 HCLGE_OPC_TM_PRI_SCH_MODE_CFG = 0x0813,
142 HCLGE_OPC_TM_QS_SCH_MODE_CFG = 0x0814,
143 HCLGE_OPC_TM_BP_TO_QSET_MAPPING = 0x0815,
144
145
146 HCLGE_OPC_TX_BUFF_ALLOC = 0x0901,
147 HCLGE_OPC_RX_PRIV_BUFF_ALLOC = 0x0902,
148 HCLGE_OPC_RX_PRIV_WL_ALLOC = 0x0903,
149 HCLGE_OPC_RX_COM_THRD_ALLOC = 0x0904,
150 HCLGE_OPC_RX_COM_WL_ALLOC = 0x0905,
151 HCLGE_OPC_RX_GBL_PKT_CNT = 0x0906,
152
153
154
155 HCLGE_OPC_SET_TQP_MAP = 0x0A01,
156
157
158 HCLGE_OPC_CFG_TX_QUEUE = 0x0B01,
159 HCLGE_OPC_QUERY_TX_POINTER = 0x0B02,
160 HCLGE_OPC_QUERY_TX_STATUS = 0x0B03,
161 HCLGE_OPC_CFG_RX_QUEUE = 0x0B11,
162 HCLGE_OPC_QUERY_RX_POINTER = 0x0B12,
163 HCLGE_OPC_QUERY_RX_STATUS = 0x0B13,
164 HCLGE_OPC_STASH_RX_QUEUE_LRO = 0x0B16,
165 HCLGE_OPC_CFG_RX_QUEUE_LRO = 0x0B17,
166 HCLGE_OPC_CFG_COM_TQP_QUEUE = 0x0B20,
167 HCLGE_OPC_RESET_TQP_QUEUE = 0x0B22,
168
169
170 HCLGE_OPC_TSO_GENERIC_CONFIG = 0x0C01,
171
172
173 HCLGE_OPC_RSS_GENERIC_CONFIG = 0x0D01,
174 HCLGE_OPC_RSS_INDIR_TABLE = 0x0D07,
175 HCLGE_OPC_RSS_TC_MODE = 0x0D08,
176 HCLGE_OPC_RSS_INPUT_TUPLE = 0x0D02,
177
178
179 HCLGE_OPC_CFG_PROMISC_MODE = 0x0E01,
180
181
182 HCLGE_OPC_VLAN_PORT_TX_CFG = 0x0F01,
183 HCLGE_OPC_VLAN_PORT_RX_CFG = 0x0F02,
184
185
186 HCLGE_OPC_ADD_RING_TO_VECTOR = 0x1503,
187 HCLGE_OPC_DEL_RING_TO_VECTOR = 0x1504,
188
189
190 HCLGE_OPC_MAC_VLAN_ADD = 0x1000,
191 HCLGE_OPC_MAC_VLAN_REMOVE = 0x1001,
192 HCLGE_OPC_MAC_VLAN_TYPE_ID = 0x1002,
193 HCLGE_OPC_MAC_VLAN_INSERT = 0x1003,
194 HCLGE_OPC_MAC_VLAN_ALLOCATE = 0x1004,
195 HCLGE_OPC_MAC_ETHTYPE_ADD = 0x1010,
196 HCLGE_OPC_MAC_ETHTYPE_REMOVE = 0x1011,
197 HCLGE_OPC_MAC_VLAN_MASK_SET = 0x1012,
198
199
200 HCLGE_OPC_MTA_MAC_MODE_CFG = 0x1020,
201 HCLGE_OPC_MTA_MAC_FUNC_CFG = 0x1021,
202 HCLGE_OPC_MTA_TBL_ITEM_CFG = 0x1022,
203 HCLGE_OPC_MTA_TBL_ITEM_QUERY = 0x1023,
204
205
206 HCLGE_OPC_VLAN_FILTER_CTRL = 0x1100,
207 HCLGE_OPC_VLAN_FILTER_PF_CFG = 0x1101,
208 HCLGE_OPC_VLAN_FILTER_VF_CFG = 0x1102,
209
210
211 HCLGE_OPC_MDIO_CONFIG = 0x1900,
212
213
214 HCLGE_OPC_QCN_MOD_CFG = 0x1A01,
215 HCLGE_OPC_QCN_GRP_TMPLT_CFG = 0x1A02,
216 HCLGE_OPC_QCN_SHAPPING_IR_CFG = 0x1A03,
217 HCLGE_OPC_QCN_SHAPPING_BS_CFG = 0x1A04,
218 HCLGE_OPC_QCN_QSET_LINK_CFG = 0x1A05,
219 HCLGE_OPC_QCN_RP_STATUS_GET = 0x1A06,
220 HCLGE_OPC_QCN_AJUST_INIT = 0x1A07,
221 HCLGE_OPC_QCN_DFX_CNT_STATUS = 0x1A08,
222
223
224 HCLGEVF_OPC_MBX_PF_TO_VF = 0x2000,
225
226
227 HCLGE_OPC_LED_STATUS_CFG = 0xB000,
228};
229
230#define HCLGE_TQP_REG_OFFSET 0x80000
231#define HCLGE_TQP_REG_SIZE 0x200
232
233#define HCLGE_RCB_INIT_QUERY_TIMEOUT 10
234#define HCLGE_RCB_INIT_FLAG_EN_B 0
235#define HCLGE_RCB_INIT_FLAG_FINI_B 8
236struct hclge_config_rcb_init_cmd {
237 __le16 rcb_init_flag;
238 u8 rsv[22];
239};
240
241struct hclge_tqp_map_cmd {
242 __le16 tqp_id;
243 u8 tqp_vf;
244#define HCLGE_TQP_MAP_TYPE_PF 0
245#define HCLGE_TQP_MAP_TYPE_VF 1
246#define HCLGE_TQP_MAP_TYPE_B 0
247#define HCLGE_TQP_MAP_EN_B 1
248 u8 tqp_flag;
249 __le16 tqp_vid;
250 u8 rsv[18];
251};
252
253#define HCLGE_VECTOR_ELEMENTS_PER_CMD 10
254
255enum hclge_int_type {
256 HCLGE_INT_TX,
257 HCLGE_INT_RX,
258 HCLGE_INT_EVENT,
259};
260
261struct hclge_ctrl_vector_chain_cmd {
262 u8 int_vector_id;
263 u8 int_cause_num;
264#define HCLGE_INT_TYPE_S 0
265#define HCLGE_INT_TYPE_M GENMASK(1, 0)
266#define HCLGE_TQP_ID_S 2
267#define HCLGE_TQP_ID_M GENMASK(12, 2)
268#define HCLGE_INT_GL_IDX_S 13
269#define HCLGE_INT_GL_IDX_M GENMASK(14, 13)
270 __le16 tqp_type_and_id[HCLGE_VECTOR_ELEMENTS_PER_CMD];
271 u8 vfid;
272 u8 rsv;
273};
274
275#define HCLGE_TC_NUM 8
276#define HCLGE_TC0_PRI_BUF_EN_B 15
277#define HCLGE_BUF_UNIT_S 7
278struct hclge_tx_buff_alloc_cmd {
279 __le16 tx_pkt_buff[HCLGE_TC_NUM];
280 u8 tx_buff_rsv[8];
281};
282
283struct hclge_rx_priv_buff_cmd {
284 __le16 buf_num[HCLGE_TC_NUM];
285 __le16 shared_buf;
286 u8 rsv[6];
287};
288
289struct hclge_query_version_cmd {
290 __le32 firmware;
291 __le32 firmware_rsv[5];
292};
293
294#define HCLGE_RX_PRIV_EN_B 15
295#define HCLGE_TC_NUM_ONE_DESC 4
296struct hclge_priv_wl {
297 __le16 high;
298 __le16 low;
299};
300
301struct hclge_rx_priv_wl_buf {
302 struct hclge_priv_wl tc_wl[HCLGE_TC_NUM_ONE_DESC];
303};
304
305struct hclge_rx_com_thrd {
306 struct hclge_priv_wl com_thrd[HCLGE_TC_NUM_ONE_DESC];
307};
308
309struct hclge_rx_com_wl {
310 struct hclge_priv_wl com_wl;
311};
312
313struct hclge_waterline {
314 u32 low;
315 u32 high;
316};
317
318struct hclge_tc_thrd {
319 u32 low;
320 u32 high;
321};
322
323struct hclge_priv_buf {
324 struct hclge_waterline wl;
325 u32 buf_size;
326 u32 tx_buf_size;
327 u32 enable;
328};
329
330#define HCLGE_MAX_TC_NUM 8
331struct hclge_shared_buf {
332 struct hclge_waterline self;
333 struct hclge_tc_thrd tc_thrd[HCLGE_MAX_TC_NUM];
334 u32 buf_size;
335};
336
337struct hclge_pkt_buf_alloc {
338 struct hclge_priv_buf priv_buf[HCLGE_MAX_TC_NUM];
339 struct hclge_shared_buf s_buf;
340};
341
342#define HCLGE_RX_COM_WL_EN_B 15
343struct hclge_rx_com_wl_buf_cmd {
344 __le16 high_wl;
345 __le16 low_wl;
346 u8 rsv[20];
347};
348
349#define HCLGE_RX_PKT_EN_B 15
350struct hclge_rx_pkt_buf_cmd {
351 __le16 high_pkt;
352 __le16 low_pkt;
353 u8 rsv[20];
354};
355
356#define HCLGE_PF_STATE_DONE_B 0
357#define HCLGE_PF_STATE_MAIN_B 1
358#define HCLGE_PF_STATE_BOND_B 2
359#define HCLGE_PF_STATE_MAC_N_B 6
360#define HCLGE_PF_MAC_NUM_MASK 0x3
361#define HCLGE_PF_STATE_MAIN BIT(HCLGE_PF_STATE_MAIN_B)
362#define HCLGE_PF_STATE_DONE BIT(HCLGE_PF_STATE_DONE_B)
363struct hclge_func_status_cmd {
364 __le32 vf_rst_state[4];
365 u8 pf_state;
366 u8 mac_id;
367 u8 rsv1;
368 u8 pf_cnt_in_mac;
369 u8 pf_num;
370 u8 vf_num;
371 u8 rsv[2];
372};
373
374struct hclge_pf_res_cmd {
375 __le16 tqp_num;
376 __le16 buf_size;
377 __le16 msixcap_localid_ba_nic;
378 __le16 msixcap_localid_ba_rocee;
379#define HCLGE_MSIX_OFT_ROCEE_S 0
380#define HCLGE_MSIX_OFT_ROCEE_M GENMASK(15, 0)
381#define HCLGE_PF_VEC_NUM_S 0
382#define HCLGE_PF_VEC_NUM_M GENMASK(7, 0)
383 __le16 pf_intr_vector_number;
384 __le16 pf_own_fun_number;
385 __le16 tx_buf_size;
386 __le16 dv_buf_size;
387 __le32 rsv[2];
388};
389
390#define HCLGE_CFG_OFFSET_S 0
391#define HCLGE_CFG_OFFSET_M GENMASK(19, 0)
392#define HCLGE_CFG_RD_LEN_S 24
393#define HCLGE_CFG_RD_LEN_M GENMASK(27, 24)
394#define HCLGE_CFG_RD_LEN_BYTES 16
395#define HCLGE_CFG_RD_LEN_UNIT 4
396
397#define HCLGE_CFG_VMDQ_S 0
398#define HCLGE_CFG_VMDQ_M GENMASK(7, 0)
399#define HCLGE_CFG_TC_NUM_S 8
400#define HCLGE_CFG_TC_NUM_M GENMASK(15, 8)
401#define HCLGE_CFG_TQP_DESC_N_S 16
402#define HCLGE_CFG_TQP_DESC_N_M GENMASK(31, 16)
403#define HCLGE_CFG_PHY_ADDR_S 0
404#define HCLGE_CFG_PHY_ADDR_M GENMASK(7, 0)
405#define HCLGE_CFG_MEDIA_TP_S 8
406#define HCLGE_CFG_MEDIA_TP_M GENMASK(15, 8)
407#define HCLGE_CFG_RX_BUF_LEN_S 16
408#define HCLGE_CFG_RX_BUF_LEN_M GENMASK(31, 16)
409#define HCLGE_CFG_MAC_ADDR_H_S 0
410#define HCLGE_CFG_MAC_ADDR_H_M GENMASK(15, 0)
411#define HCLGE_CFG_DEFAULT_SPEED_S 16
412#define HCLGE_CFG_DEFAULT_SPEED_M GENMASK(23, 16)
413#define HCLGE_CFG_RSS_SIZE_S 24
414#define HCLGE_CFG_RSS_SIZE_M GENMASK(31, 24)
415#define HCLGE_CFG_SPEED_ABILITY_S 0
416#define HCLGE_CFG_SPEED_ABILITY_M GENMASK(7, 0)
417#define HCLGE_CFG_UMV_TBL_SPACE_S 16
418#define HCLGE_CFG_UMV_TBL_SPACE_M GENMASK(31, 16)
419
420struct hclge_cfg_param_cmd {
421 __le32 offset;
422 __le32 rsv;
423 __le32 param[4];
424};
425
426#define HCLGE_MAC_MODE 0x0
427#define HCLGE_DESC_NUM 0x40
428
429#define HCLGE_ALLOC_VALID_B 0
430struct hclge_vf_num_cmd {
431 u8 alloc_valid;
432 u8 rsv[23];
433};
434
435#define HCLGE_RSS_DEFAULT_OUTPORT_B 4
436#define HCLGE_RSS_HASH_KEY_OFFSET_B 4
437#define HCLGE_RSS_HASH_KEY_NUM 16
438struct hclge_rss_config_cmd {
439 u8 hash_config;
440 u8 rsv[7];
441 u8 hash_key[HCLGE_RSS_HASH_KEY_NUM];
442};
443
444struct hclge_rss_input_tuple_cmd {
445 u8 ipv4_tcp_en;
446 u8 ipv4_udp_en;
447 u8 ipv4_sctp_en;
448 u8 ipv4_fragment_en;
449 u8 ipv6_tcp_en;
450 u8 ipv6_udp_en;
451 u8 ipv6_sctp_en;
452 u8 ipv6_fragment_en;
453 u8 rsv[16];
454};
455
456#define HCLGE_RSS_CFG_TBL_SIZE 16
457
458struct hclge_rss_indirection_table_cmd {
459 __le16 start_table_index;
460 __le16 rss_set_bitmap;
461 u8 rsv[4];
462 u8 rss_result[HCLGE_RSS_CFG_TBL_SIZE];
463};
464
465#define HCLGE_RSS_TC_OFFSET_S 0
466#define HCLGE_RSS_TC_OFFSET_M GENMASK(9, 0)
467#define HCLGE_RSS_TC_SIZE_S 12
468#define HCLGE_RSS_TC_SIZE_M GENMASK(14, 12)
469#define HCLGE_RSS_TC_VALID_B 15
470struct hclge_rss_tc_mode_cmd {
471 __le16 rss_tc_mode[HCLGE_MAX_TC_NUM];
472 u8 rsv[8];
473};
474
475#define HCLGE_LINK_STATUS_UP_B 0
476#define HCLGE_LINK_STATUS_UP_M BIT(HCLGE_LINK_STATUS_UP_B)
477struct hclge_link_status_cmd {
478 u8 status;
479 u8 rsv[23];
480};
481
482struct hclge_promisc_param {
483 u8 vf_id;
484 u8 enable;
485};
486
487#define HCLGE_PROMISC_TX_EN_B BIT(4)
488#define HCLGE_PROMISC_RX_EN_B BIT(5)
489#define HCLGE_PROMISC_EN_B 1
490#define HCLGE_PROMISC_EN_ALL 0x7
491#define HCLGE_PROMISC_EN_UC 0x1
492#define HCLGE_PROMISC_EN_MC 0x2
493#define HCLGE_PROMISC_EN_BC 0x4
494struct hclge_promisc_cfg_cmd {
495 u8 flag;
496 u8 vf_id;
497 __le16 rsv0;
498 u8 rsv1[20];
499};
500
501enum hclge_promisc_type {
502 HCLGE_UNICAST = 1,
503 HCLGE_MULTICAST = 2,
504 HCLGE_BROADCAST = 3,
505};
506
507#define HCLGE_MAC_TX_EN_B 6
508#define HCLGE_MAC_RX_EN_B 7
509#define HCLGE_MAC_PAD_TX_B 11
510#define HCLGE_MAC_PAD_RX_B 12
511#define HCLGE_MAC_1588_TX_B 13
512#define HCLGE_MAC_1588_RX_B 14
513#define HCLGE_MAC_APP_LP_B 15
514#define HCLGE_MAC_LINE_LP_B 16
515#define HCLGE_MAC_FCS_TX_B 17
516#define HCLGE_MAC_RX_OVERSIZE_TRUNCATE_B 18
517#define HCLGE_MAC_RX_FCS_STRIP_B 19
518#define HCLGE_MAC_RX_FCS_B 20
519#define HCLGE_MAC_TX_UNDER_MIN_ERR_B 21
520#define HCLGE_MAC_TX_OVERSIZE_TRUNCATE_B 22
521
522struct hclge_config_mac_mode_cmd {
523 __le32 txrx_pad_fcs_loop_en;
524 u8 rsv[20];
525};
526
527#define HCLGE_CFG_SPEED_S 0
528#define HCLGE_CFG_SPEED_M GENMASK(5, 0)
529
530#define HCLGE_CFG_DUPLEX_B 7
531#define HCLGE_CFG_DUPLEX_M BIT(HCLGE_CFG_DUPLEX_B)
532
533struct hclge_config_mac_speed_dup_cmd {
534 u8 speed_dup;
535
536#define HCLGE_CFG_MAC_SPEED_CHANGE_EN_B 0
537 u8 mac_change_fec_en;
538 u8 rsv[22];
539};
540
541#define HCLGE_QUERY_SPEED_S 3
542#define HCLGE_QUERY_AN_B 0
543#define HCLGE_QUERY_DUPLEX_B 2
544
545#define HCLGE_QUERY_SPEED_M GENMASK(4, 0)
546#define HCLGE_QUERY_AN_M BIT(HCLGE_QUERY_AN_B)
547#define HCLGE_QUERY_DUPLEX_M BIT(HCLGE_QUERY_DUPLEX_B)
548
549struct hclge_query_an_speed_dup_cmd {
550 u8 an_syn_dup_speed;
551 u8 pause;
552 u8 rsv[23];
553};
554
555#define HCLGE_RING_ID_MASK GENMASK(9, 0)
556#define HCLGE_TQP_ENABLE_B 0
557
558#define HCLGE_MAC_CFG_AN_EN_B 0
559#define HCLGE_MAC_CFG_AN_INT_EN_B 1
560#define HCLGE_MAC_CFG_AN_INT_MSK_B 2
561#define HCLGE_MAC_CFG_AN_INT_CLR_B 3
562#define HCLGE_MAC_CFG_AN_RST_B 4
563
564#define HCLGE_MAC_CFG_AN_EN BIT(HCLGE_MAC_CFG_AN_EN_B)
565
566struct hclge_config_auto_neg_cmd {
567 __le32 cfg_an_cmd_flag;
568 u8 rsv[20];
569};
570
571#define HCLGE_MAC_UPLINK_PORT 0x100
572
573struct hclge_config_max_frm_size_cmd {
574 __le16 max_frm_size;
575 u8 min_frm_size;
576 u8 rsv[21];
577};
578
579enum hclge_mac_vlan_tbl_opcode {
580 HCLGE_MAC_VLAN_ADD,
581 HCLGE_MAC_VLAN_UPDATE,
582 HCLGE_MAC_VLAN_REMOVE,
583 HCLGE_MAC_VLAN_LKUP,
584};
585
586#define HCLGE_MAC_VLAN_BIT0_EN_B 0x0
587#define HCLGE_MAC_VLAN_BIT1_EN_B 0x1
588#define HCLGE_MAC_EPORT_SW_EN_B 0xc
589#define HCLGE_MAC_EPORT_TYPE_B 0xb
590#define HCLGE_MAC_EPORT_VFID_S 0x3
591#define HCLGE_MAC_EPORT_VFID_M GENMASK(10, 3)
592#define HCLGE_MAC_EPORT_PFID_S 0x0
593#define HCLGE_MAC_EPORT_PFID_M GENMASK(2, 0)
594struct hclge_mac_vlan_tbl_entry_cmd {
595 u8 flags;
596 u8 resp_code;
597 __le16 vlan_tag;
598 __le32 mac_addr_hi32;
599 __le16 mac_addr_lo16;
600 __le16 rsv1;
601 u8 entry_type;
602 u8 mc_mac_en;
603 __le16 egress_port;
604 __le16 egress_queue;
605 u8 rsv2[6];
606};
607
608#define HCLGE_VLAN_MASK_EN_B 0x0
609struct hclge_mac_vlan_mask_entry_cmd {
610 u8 rsv0[2];
611 u8 vlan_mask;
612 u8 rsv1;
613 u8 mac_mask[6];
614 u8 rsv2[14];
615};
616
617#define HCLGE_UMV_SPC_ALC_B 0
618struct hclge_umv_spc_alc_cmd {
619 u8 allocate;
620 u8 rsv1[3];
621 __le32 space_size;
622 u8 rsv2[16];
623};
624
625#define HCLGE_MAC_MGR_MASK_VLAN_B BIT(0)
626#define HCLGE_MAC_MGR_MASK_MAC_B BIT(1)
627#define HCLGE_MAC_MGR_MASK_ETHERTYPE_B BIT(2)
628#define HCLGE_MAC_ETHERTYPE_LLDP 0x88cc
629
630struct hclge_mac_mgr_tbl_entry_cmd {
631 u8 flags;
632 u8 resp_code;
633 __le16 vlan_tag;
634 __le32 mac_addr_hi32;
635 __le16 mac_addr_lo16;
636 __le16 rsv1;
637 __le16 ethter_type;
638 __le16 egress_port;
639 __le16 egress_queue;
640 u8 sw_port_id_aware;
641 u8 rsv2;
642 u8 i_port_bitmap;
643 u8 i_port_direction;
644 u8 rsv3[2];
645};
646
647#define HCLGE_CFG_MTA_MAC_SEL_S 0x0
648#define HCLGE_CFG_MTA_MAC_SEL_M GENMASK(1, 0)
649#define HCLGE_CFG_MTA_MAC_EN_B 0x7
650struct hclge_mta_filter_mode_cmd {
651 u8 dmac_sel_en;
652 u8 rsv[23];
653};
654
655#define HCLGE_CFG_FUNC_MTA_ACCEPT_B 0x0
656struct hclge_cfg_func_mta_filter_cmd {
657 u8 accept;
658 u8 function_id;
659 u8 rsv[22];
660};
661
662#define HCLGE_CFG_MTA_ITEM_ACCEPT_B 0x0
663#define HCLGE_CFG_MTA_ITEM_IDX_S 0x0
664#define HCLGE_CFG_MTA_ITEM_IDX_M GENMASK(11, 0)
665struct hclge_cfg_func_mta_item_cmd {
666 __le16 item_idx;
667 u8 accept;
668 u8 rsv[21];
669};
670
671struct hclge_mac_vlan_add_cmd {
672 __le16 flags;
673 __le16 mac_addr_hi16;
674 __le32 mac_addr_lo32;
675 __le32 mac_addr_msk_hi32;
676 __le16 mac_addr_msk_lo16;
677 __le16 vlan_tag;
678 __le16 ingress_port;
679 __le16 egress_port;
680 u8 rsv[4];
681};
682
683#define HNS3_MAC_VLAN_CFG_FLAG_BIT 0
684struct hclge_mac_vlan_remove_cmd {
685 __le16 flags;
686 __le16 mac_addr_hi16;
687 __le32 mac_addr_lo32;
688 __le32 mac_addr_msk_hi32;
689 __le16 mac_addr_msk_lo16;
690 __le16 vlan_tag;
691 __le16 ingress_port;
692 __le16 egress_port;
693 u8 rsv[4];
694};
695
696struct hclge_vlan_filter_ctrl_cmd {
697 u8 vlan_type;
698 u8 vlan_fe;
699 u8 rsv[22];
700};
701
702struct hclge_vlan_filter_pf_cfg_cmd {
703 u8 vlan_offset;
704 u8 vlan_cfg;
705 u8 rsv[2];
706 u8 vlan_offset_bitmap[20];
707};
708
709struct hclge_vlan_filter_vf_cfg_cmd {
710 __le16 vlan_id;
711 u8 resp_code;
712 u8 rsv;
713 u8 vlan_cfg;
714 u8 rsv1[3];
715 u8 vf_bitmap[16];
716};
717
718#define HCLGE_ACCEPT_TAG1_B 0
719#define HCLGE_ACCEPT_UNTAG1_B 1
720#define HCLGE_PORT_INS_TAG1_EN_B 2
721#define HCLGE_PORT_INS_TAG2_EN_B 3
722#define HCLGE_CFG_NIC_ROCE_SEL_B 4
723#define HCLGE_ACCEPT_TAG2_B 5
724#define HCLGE_ACCEPT_UNTAG2_B 6
725
726struct hclge_vport_vtag_tx_cfg_cmd {
727 u8 vport_vlan_cfg;
728 u8 vf_offset;
729 u8 rsv1[2];
730 __le16 def_vlan_tag1;
731 __le16 def_vlan_tag2;
732 u8 vf_bitmap[8];
733 u8 rsv2[8];
734};
735
736#define HCLGE_REM_TAG1_EN_B 0
737#define HCLGE_REM_TAG2_EN_B 1
738#define HCLGE_SHOW_TAG1_EN_B 2
739#define HCLGE_SHOW_TAG2_EN_B 3
740struct hclge_vport_vtag_rx_cfg_cmd {
741 u8 vport_vlan_cfg;
742 u8 vf_offset;
743 u8 rsv1[6];
744 u8 vf_bitmap[8];
745 u8 rsv2[8];
746};
747
748struct hclge_tx_vlan_type_cfg_cmd {
749 __le16 ot_vlan_type;
750 __le16 in_vlan_type;
751 u8 rsv[20];
752};
753
754struct hclge_rx_vlan_type_cfg_cmd {
755 __le16 ot_fst_vlan_type;
756 __le16 ot_sec_vlan_type;
757 __le16 in_fst_vlan_type;
758 __le16 in_sec_vlan_type;
759 u8 rsv[16];
760};
761
762struct hclge_cfg_com_tqp_queue_cmd {
763 __le16 tqp_id;
764 __le16 stream_id;
765 u8 enable;
766 u8 rsv[19];
767};
768
769struct hclge_cfg_tx_queue_pointer_cmd {
770 __le16 tqp_id;
771 __le16 tx_tail;
772 __le16 tx_head;
773 __le16 fbd_num;
774 __le16 ring_offset;
775 u8 rsv[14];
776};
777
778#define HCLGE_TSO_MSS_MIN_S 0
779#define HCLGE_TSO_MSS_MIN_M GENMASK(13, 0)
780
781#define HCLGE_TSO_MSS_MAX_S 16
782#define HCLGE_TSO_MSS_MAX_M GENMASK(29, 16)
783
784struct hclge_cfg_tso_status_cmd {
785 __le16 tso_mss_min;
786 __le16 tso_mss_max;
787 u8 rsv[20];
788};
789
790#define HCLGE_TSO_MSS_MIN 256
791#define HCLGE_TSO_MSS_MAX 9668
792
793#define HCLGE_TQP_RESET_B 0
794struct hclge_reset_tqp_queue_cmd {
795 __le16 tqp_id;
796 u8 reset_req;
797 u8 ready_to_reset;
798 u8 rsv[20];
799};
800
801#define HCLGE_CFG_RESET_MAC_B 3
802#define HCLGE_CFG_RESET_FUNC_B 7
803struct hclge_reset_cmd {
804 u8 mac_func_reset;
805 u8 fun_reset_vfid;
806 u8 rsv[22];
807};
808
809#define HCLGE_CMD_SERDES_SERIAL_INNER_LOOP_B BIT(0)
810#define HCLGE_CMD_SERDES_DONE_B BIT(0)
811#define HCLGE_CMD_SERDES_SUCCESS_B BIT(1)
812struct hclge_serdes_lb_cmd {
813 u8 mask;
814 u8 enable;
815 u8 result;
816 u8 rsv[21];
817};
818
819#define HCLGE_DEFAULT_TX_BUF 0x4000
820#define HCLGE_TOTAL_PKT_BUF 0x108000
821#define HCLGE_DEFAULT_DV 0xA000
822#define HCLGE_DEFAULT_NON_DCB_DV 0x7800
823#define HCLGE_NON_DCB_ADDITIONAL_BUF 0x200
824
825#define HCLGE_TYPE_CRQ 0
826#define HCLGE_TYPE_CSQ 1
827#define HCLGE_NIC_CSQ_BASEADDR_L_REG 0x27000
828#define HCLGE_NIC_CSQ_BASEADDR_H_REG 0x27004
829#define HCLGE_NIC_CSQ_DEPTH_REG 0x27008
830#define HCLGE_NIC_CSQ_TAIL_REG 0x27010
831#define HCLGE_NIC_CSQ_HEAD_REG 0x27014
832#define HCLGE_NIC_CRQ_BASEADDR_L_REG 0x27018
833#define HCLGE_NIC_CRQ_BASEADDR_H_REG 0x2701c
834#define HCLGE_NIC_CRQ_DEPTH_REG 0x27020
835#define HCLGE_NIC_CRQ_TAIL_REG 0x27024
836#define HCLGE_NIC_CRQ_HEAD_REG 0x27028
837#define HCLGE_NIC_CMQ_EN_B 16
838#define HCLGE_NIC_CMQ_ENABLE BIT(HCLGE_NIC_CMQ_EN_B)
839#define HCLGE_NIC_CMQ_DESC_NUM 1024
840#define HCLGE_NIC_CMQ_DESC_NUM_S 3
841
842#define HCLGE_LED_LOCATE_STATE_S 0
843#define HCLGE_LED_LOCATE_STATE_M GENMASK(1, 0)
844
845struct hclge_set_led_state_cmd {
846 u8 rsv1[3];
847 u8 locate_led_config;
848 u8 rsv2[20];
849};
850
851int hclge_cmd_init(struct hclge_dev *hdev);
852static inline void hclge_write_reg(void __iomem *base, u32 reg, u32 value)
853{
854 writel(value, base + reg);
855}
856
857#define hclge_write_dev(a, reg, value) \
858 hclge_write_reg((a)->io_base, (reg), (value))
859#define hclge_read_dev(a, reg) \
860 hclge_read_reg((a)->io_base, (reg))
861
862static inline u32 hclge_read_reg(u8 __iomem *base, u32 reg)
863{
864 u8 __iomem *reg_addr = READ_ONCE(base);
865
866 return readl(reg_addr + reg);
867}
868
869#define HCLGE_SEND_SYNC(flag) \
870 ((flag) & HCLGE_CMD_FLAG_NO_INTR)
871
872struct hclge_hw;
873int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num);
874void hclge_cmd_setup_basic_desc(struct hclge_desc *desc,
875 enum hclge_opcode_type opcode, bool is_read);
876void hclge_cmd_reuse_desc(struct hclge_desc *desc, bool is_read);
877
878int hclge_cmd_set_promisc_mode(struct hclge_dev *hdev,
879 struct hclge_promisc_param *param);
880
881enum hclge_cmd_status hclge_cmd_mdio_write(struct hclge_hw *hw,
882 struct hclge_desc *desc);
883enum hclge_cmd_status hclge_cmd_mdio_read(struct hclge_hw *hw,
884 struct hclge_desc *desc);
885
886void hclge_destroy_cmd_queue(struct hclge_hw *hw);
887int hclge_cmd_queue_init(struct hclge_dev *hdev);
888#endif
889