Commit | Line | Data |
---|---|---|
46a3df9f S |
1 | /* |
2 | * Copyright (c) 2016~2017 Hisilicon Limited. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | */ | |
9 | ||
10 | #ifndef __HCLGE_MAIN_H | |
11 | #define __HCLGE_MAIN_H | |
12 | #include <linux/fs.h> | |
13 | #include <linux/types.h> | |
14 | #include <linux/phy.h> | |
15 | #include "hclge_cmd.h" | |
16 | #include "hnae3.h" | |
17 | ||
18 | #define HCLGE_MOD_VERSION "v1.0" | |
19 | #define HCLGE_DRIVER_NAME "hclge" | |
20 | ||
21 | #define HCLGE_INVALID_VPORT 0xffff | |
22 | ||
23 | #define HCLGE_ROCE_VECTOR_OFFSET 96 | |
24 | ||
25 | #define HCLGE_PF_CFG_BLOCK_SIZE 32 | |
26 | #define HCLGE_PF_CFG_DESC_NUM \ | |
27 | (HCLGE_PF_CFG_BLOCK_SIZE / HCLGE_CFG_RD_LEN_BYTES) | |
28 | ||
29 | #define HCLGE_VECTOR_REG_BASE 0x20000 | |
466b0c00 | 30 | #define HCLGE_MISC_VECTOR_REG_BASE 0x20400 |
46a3df9f S |
31 | |
32 | #define HCLGE_VECTOR_REG_OFFSET 0x4 | |
33 | #define HCLGE_VECTOR_VF_OFFSET 0x100000 | |
34 | ||
35 | #define HCLGE_RSS_IND_TBL_SIZE 512 | |
5392902d | 36 | #define HCLGE_RSS_SET_BITMAP_MSK GENMASK(15, 0) |
46a3df9f S |
37 | #define HCLGE_RSS_KEY_SIZE 40 |
38 | #define HCLGE_RSS_HASH_ALGO_TOEPLITZ 0 | |
39 | #define HCLGE_RSS_HASH_ALGO_SIMPLE 1 | |
40 | #define HCLGE_RSS_HASH_ALGO_SYMMETRIC 2 | |
41 | #define HCLGE_RSS_HASH_ALGO_MASK 0xf | |
42 | #define HCLGE_RSS_CFG_TBL_NUM \ | |
43 | (HCLGE_RSS_IND_TBL_SIZE / HCLGE_RSS_CFG_TBL_SIZE) | |
44 | ||
f7db940a L |
45 | #define HCLGE_RSS_INPUT_TUPLE_OTHER GENMASK(3, 0) |
46 | #define HCLGE_RSS_INPUT_TUPLE_SCTP GENMASK(4, 0) | |
47 | #define HCLGE_D_PORT_BIT BIT(0) | |
48 | #define HCLGE_S_PORT_BIT BIT(1) | |
49 | #define HCLGE_D_IP_BIT BIT(2) | |
50 | #define HCLGE_S_IP_BIT BIT(3) | |
51 | #define HCLGE_V_TAG_BIT BIT(4) | |
52 | ||
46a3df9f S |
53 | #define HCLGE_RSS_TC_SIZE_0 1 |
54 | #define HCLGE_RSS_TC_SIZE_1 2 | |
55 | #define HCLGE_RSS_TC_SIZE_2 4 | |
56 | #define HCLGE_RSS_TC_SIZE_3 8 | |
57 | #define HCLGE_RSS_TC_SIZE_4 16 | |
58 | #define HCLGE_RSS_TC_SIZE_5 32 | |
59 | #define HCLGE_RSS_TC_SIZE_6 64 | |
60 | #define HCLGE_RSS_TC_SIZE_7 128 | |
61 | ||
62 | #define HCLGE_TQP_RESET_TRY_TIMES 10 | |
63 | ||
64 | #define HCLGE_PHY_PAGE_MDIX 0 | |
65 | #define HCLGE_PHY_PAGE_COPPER 0 | |
66 | ||
67 | /* Page Selection Reg. */ | |
68 | #define HCLGE_PHY_PAGE_REG 22 | |
69 | ||
70 | /* Copper Specific Control Register */ | |
71 | #define HCLGE_PHY_CSC_REG 16 | |
72 | ||
73 | /* Copper Specific Status Register */ | |
74 | #define HCLGE_PHY_CSS_REG 17 | |
75 | ||
76 | #define HCLGE_PHY_MDIX_CTRL_S (5) | |
5392902d | 77 | #define HCLGE_PHY_MDIX_CTRL_M GENMASK(6, 5) |
46a3df9f S |
78 | |
79 | #define HCLGE_PHY_MDIX_STATUS_B (6) | |
80 | #define HCLGE_PHY_SPEED_DUP_RESOLVE_B (11) | |
81 | ||
4ed340ab L |
82 | /* Reset related Registers */ |
83 | #define HCLGE_MISC_RESET_STS_REG 0x20700 | |
84 | #define HCLGE_GLOBAL_RESET_REG 0x20A00 | |
85 | #define HCLGE_GLOBAL_RESET_BIT 0x0 | |
86 | #define HCLGE_CORE_RESET_BIT 0x1 | |
87 | #define HCLGE_FUN_RST_ING 0x20C00 | |
88 | #define HCLGE_FUN_RST_ING_B 0 | |
89 | ||
90 | /* Vector0 register bits define */ | |
91 | #define HCLGE_VECTOR0_GLOBALRESET_INT_B 5 | |
92 | #define HCLGE_VECTOR0_CORERESET_INT_B 6 | |
93 | #define HCLGE_VECTOR0_IMPRESET_INT_B 7 | |
94 | ||
c1a81619 SM |
95 | /* Vector0 interrupt CMDQ event source register(RW) */ |
96 | #define HCLGE_VECTOR0_CMDQ_SRC_REG 0x27100 | |
97 | /* CMDQ register bits for RX event(=MBX event) */ | |
98 | #define HCLGE_VECTOR0_RX_CMDQ_INT_B 1 | |
99 | ||
46a3df9f S |
100 | enum HCLGE_DEV_STATE { |
101 | HCLGE_STATE_REINITING, | |
102 | HCLGE_STATE_DOWN, | |
103 | HCLGE_STATE_DISABLED, | |
104 | HCLGE_STATE_REMOVING, | |
105 | HCLGE_STATE_SERVICE_INITED, | |
106 | HCLGE_STATE_SERVICE_SCHED, | |
cb1b9f77 SM |
107 | HCLGE_STATE_RST_SERVICE_SCHED, |
108 | HCLGE_STATE_RST_HANDLING, | |
c1a81619 | 109 | HCLGE_STATE_MBX_SERVICE_SCHED, |
46a3df9f | 110 | HCLGE_STATE_MBX_HANDLING, |
46a3df9f S |
111 | HCLGE_STATE_MAX |
112 | }; | |
113 | ||
ca1d7669 SM |
114 | enum hclge_evt_cause { |
115 | HCLGE_VECTOR0_EVENT_RST, | |
116 | HCLGE_VECTOR0_EVENT_MBX, | |
117 | HCLGE_VECTOR0_EVENT_OTHER, | |
118 | }; | |
119 | ||
46a3df9f S |
120 | #define HCLGE_MPF_ENBALE 1 |
121 | struct hclge_caps { | |
122 | u16 num_tqp; | |
123 | u16 num_buffer_cell; | |
124 | u32 flag; | |
125 | u16 vmdq; | |
126 | }; | |
127 | ||
128 | enum HCLGE_MAC_SPEED { | |
129 | HCLGE_MAC_SPEED_10M = 10, /* 10 Mbps */ | |
130 | HCLGE_MAC_SPEED_100M = 100, /* 100 Mbps */ | |
131 | HCLGE_MAC_SPEED_1G = 1000, /* 1000 Mbps = 1 Gbps */ | |
132 | HCLGE_MAC_SPEED_10G = 10000, /* 10000 Mbps = 10 Gbps */ | |
133 | HCLGE_MAC_SPEED_25G = 25000, /* 25000 Mbps = 25 Gbps */ | |
134 | HCLGE_MAC_SPEED_40G = 40000, /* 40000 Mbps = 40 Gbps */ | |
135 | HCLGE_MAC_SPEED_50G = 50000, /* 50000 Mbps = 50 Gbps */ | |
136 | HCLGE_MAC_SPEED_100G = 100000 /* 100000 Mbps = 100 Gbps */ | |
137 | }; | |
138 | ||
139 | enum HCLGE_MAC_DUPLEX { | |
140 | HCLGE_MAC_HALF, | |
141 | HCLGE_MAC_FULL | |
142 | }; | |
143 | ||
144 | enum hclge_mta_dmac_sel_type { | |
145 | HCLGE_MAC_ADDR_47_36, | |
146 | HCLGE_MAC_ADDR_46_35, | |
147 | HCLGE_MAC_ADDR_45_34, | |
148 | HCLGE_MAC_ADDR_44_33, | |
149 | }; | |
150 | ||
151 | struct hclge_mac { | |
152 | u8 phy_addr; | |
153 | u8 flag; | |
154 | u8 media_type; | |
155 | u8 mac_addr[ETH_ALEN]; | |
156 | u8 autoneg; | |
157 | u8 duplex; | |
158 | u32 speed; | |
159 | int link; /* store the link status of mac & phy (if phy exit)*/ | |
160 | struct phy_device *phydev; | |
161 | struct mii_bus *mdio_bus; | |
162 | phy_interface_t phy_if; | |
163 | }; | |
164 | ||
165 | struct hclge_hw { | |
166 | void __iomem *io_base; | |
167 | struct hclge_mac mac; | |
168 | int num_vec; | |
169 | struct hclge_cmq cmq; | |
170 | struct hclge_caps caps; | |
171 | void *back; | |
172 | }; | |
173 | ||
174 | /* TQP stats */ | |
175 | struct hlcge_tqp_stats { | |
176 | /* query_tqp_tx_queue_statistics ,opcode id: 0x0B03 */ | |
177 | u64 rcb_tx_ring_pktnum_rcd; /* 32bit */ | |
178 | /* query_tqp_rx_queue_statistics ,opcode id: 0x0B13 */ | |
179 | u64 rcb_rx_ring_pktnum_rcd; /* 32bit */ | |
180 | }; | |
181 | ||
182 | struct hclge_tqp { | |
183 | struct device *dev; /* Device for DMA mapping */ | |
184 | struct hnae3_queue q; | |
185 | struct hlcge_tqp_stats tqp_stats; | |
186 | u16 index; /* Global index in a NIC controller */ | |
187 | ||
188 | bool alloced; | |
189 | }; | |
190 | ||
191 | enum hclge_fc_mode { | |
192 | HCLGE_FC_NONE, | |
193 | HCLGE_FC_RX_PAUSE, | |
194 | HCLGE_FC_TX_PAUSE, | |
195 | HCLGE_FC_FULL, | |
196 | HCLGE_FC_PFC, | |
197 | HCLGE_FC_DEFAULT | |
198 | }; | |
199 | ||
200 | #define HCLGE_PG_NUM 4 | |
201 | #define HCLGE_SCH_MODE_SP 0 | |
202 | #define HCLGE_SCH_MODE_DWRR 1 | |
203 | struct hclge_pg_info { | |
204 | u8 pg_id; | |
205 | u8 pg_sch_mode; /* 0: sp; 1: dwrr */ | |
206 | u8 tc_bit_map; | |
207 | u32 bw_limit; | |
208 | u8 tc_dwrr[HNAE3_MAX_TC]; | |
209 | }; | |
210 | ||
211 | struct hclge_tc_info { | |
212 | u8 tc_id; | |
213 | u8 tc_sch_mode; /* 0: sp; 1: dwrr */ | |
46a3df9f S |
214 | u8 pgid; |
215 | u32 bw_limit; | |
216 | }; | |
217 | ||
218 | struct hclge_cfg { | |
219 | u8 vmdq_vport_num; | |
220 | u8 tc_num; | |
221 | u16 tqp_desc_num; | |
222 | u16 rx_buf_len; | |
0e7a40cd | 223 | u16 rss_size_max; |
46a3df9f S |
224 | u8 phy_addr; |
225 | u8 media_type; | |
226 | u8 mac_addr[ETH_ALEN]; | |
227 | u8 default_speed; | |
228 | u32 numa_node_map; | |
229 | }; | |
230 | ||
231 | struct hclge_tm_info { | |
232 | u8 num_tc; | |
233 | u8 num_pg; /* It must be 1 if vNET-Base schd */ | |
234 | u8 pg_dwrr[HCLGE_PG_NUM]; | |
c5795c53 | 235 | u8 prio_tc[HNAE3_MAX_USER_PRIO]; |
46a3df9f S |
236 | struct hclge_pg_info pg_info[HCLGE_PG_NUM]; |
237 | struct hclge_tc_info tc_info[HNAE3_MAX_TC]; | |
238 | enum hclge_fc_mode fc_mode; | |
239 | u8 hw_pfc_map; /* Allow for packet drop or not on this TC */ | |
240 | }; | |
241 | ||
242 | struct hclge_comm_stats_str { | |
243 | char desc[ETH_GSTRING_LEN]; | |
244 | unsigned long offset; | |
245 | }; | |
246 | ||
247 | /* all 64bit stats, opcode id: 0x0030 */ | |
248 | struct hclge_64_bit_stats { | |
249 | /* query_igu_stat */ | |
250 | u64 igu_rx_oversize_pkt; | |
251 | u64 igu_rx_undersize_pkt; | |
252 | u64 igu_rx_out_all_pkt; | |
253 | u64 igu_rx_uni_pkt; | |
254 | u64 igu_rx_multi_pkt; | |
255 | u64 igu_rx_broad_pkt; | |
256 | u64 rsv0; | |
257 | ||
258 | /* query_egu_stat */ | |
259 | u64 egu_tx_out_all_pkt; | |
260 | u64 egu_tx_uni_pkt; | |
261 | u64 egu_tx_multi_pkt; | |
262 | u64 egu_tx_broad_pkt; | |
263 | ||
264 | /* ssu_ppp packet stats */ | |
265 | u64 ssu_ppp_mac_key_num; | |
266 | u64 ssu_ppp_host_key_num; | |
267 | u64 ppp_ssu_mac_rlt_num; | |
268 | u64 ppp_ssu_host_rlt_num; | |
269 | ||
270 | /* ssu_tx_in_out_dfx_stats */ | |
271 | u64 ssu_tx_in_num; | |
272 | u64 ssu_tx_out_num; | |
273 | /* ssu_rx_in_out_dfx_stats */ | |
274 | u64 ssu_rx_in_num; | |
275 | u64 ssu_rx_out_num; | |
276 | }; | |
277 | ||
278 | /* all 32bit stats, opcode id: 0x0031 */ | |
279 | struct hclge_32_bit_stats { | |
280 | u64 igu_rx_err_pkt; | |
281 | u64 igu_rx_no_eof_pkt; | |
282 | u64 igu_rx_no_sof_pkt; | |
283 | u64 egu_tx_1588_pkt; | |
284 | u64 egu_tx_err_pkt; | |
285 | u64 ssu_full_drop_num; | |
286 | u64 ssu_part_drop_num; | |
287 | u64 ppp_key_drop_num; | |
288 | u64 ppp_rlt_drop_num; | |
289 | u64 ssu_key_drop_num; | |
290 | u64 pkt_curr_buf_cnt; | |
291 | u64 qcn_fb_rcv_cnt; | |
292 | u64 qcn_fb_drop_cnt; | |
293 | u64 qcn_fb_invaild_cnt; | |
294 | u64 rsv0; | |
295 | u64 rx_packet_tc0_in_cnt; | |
296 | u64 rx_packet_tc1_in_cnt; | |
297 | u64 rx_packet_tc2_in_cnt; | |
298 | u64 rx_packet_tc3_in_cnt; | |
299 | u64 rx_packet_tc4_in_cnt; | |
300 | u64 rx_packet_tc5_in_cnt; | |
301 | u64 rx_packet_tc6_in_cnt; | |
302 | u64 rx_packet_tc7_in_cnt; | |
303 | u64 rx_packet_tc0_out_cnt; | |
304 | u64 rx_packet_tc1_out_cnt; | |
305 | u64 rx_packet_tc2_out_cnt; | |
306 | u64 rx_packet_tc3_out_cnt; | |
307 | u64 rx_packet_tc4_out_cnt; | |
308 | u64 rx_packet_tc5_out_cnt; | |
309 | u64 rx_packet_tc6_out_cnt; | |
310 | u64 rx_packet_tc7_out_cnt; | |
311 | ||
312 | /* Tx packet level statistics */ | |
313 | u64 tx_packet_tc0_in_cnt; | |
314 | u64 tx_packet_tc1_in_cnt; | |
315 | u64 tx_packet_tc2_in_cnt; | |
316 | u64 tx_packet_tc3_in_cnt; | |
317 | u64 tx_packet_tc4_in_cnt; | |
318 | u64 tx_packet_tc5_in_cnt; | |
319 | u64 tx_packet_tc6_in_cnt; | |
320 | u64 tx_packet_tc7_in_cnt; | |
321 | u64 tx_packet_tc0_out_cnt; | |
322 | u64 tx_packet_tc1_out_cnt; | |
323 | u64 tx_packet_tc2_out_cnt; | |
324 | u64 tx_packet_tc3_out_cnt; | |
325 | u64 tx_packet_tc4_out_cnt; | |
326 | u64 tx_packet_tc5_out_cnt; | |
327 | u64 tx_packet_tc6_out_cnt; | |
328 | u64 tx_packet_tc7_out_cnt; | |
329 | ||
330 | /* packet buffer statistics */ | |
331 | u64 pkt_curr_buf_tc0_cnt; | |
332 | u64 pkt_curr_buf_tc1_cnt; | |
333 | u64 pkt_curr_buf_tc2_cnt; | |
334 | u64 pkt_curr_buf_tc3_cnt; | |
335 | u64 pkt_curr_buf_tc4_cnt; | |
336 | u64 pkt_curr_buf_tc5_cnt; | |
337 | u64 pkt_curr_buf_tc6_cnt; | |
338 | u64 pkt_curr_buf_tc7_cnt; | |
339 | ||
340 | u64 mb_uncopy_num; | |
341 | u64 lo_pri_unicast_rlt_drop_num; | |
342 | u64 hi_pri_multicast_rlt_drop_num; | |
343 | u64 lo_pri_multicast_rlt_drop_num; | |
344 | u64 rx_oq_drop_pkt_cnt; | |
345 | u64 tx_oq_drop_pkt_cnt; | |
346 | u64 nic_l2_err_drop_pkt_cnt; | |
347 | u64 roc_l2_err_drop_pkt_cnt; | |
348 | }; | |
349 | ||
350 | /* mac stats ,opcode id: 0x0032 */ | |
351 | struct hclge_mac_stats { | |
352 | u64 mac_tx_mac_pause_num; | |
353 | u64 mac_rx_mac_pause_num; | |
354 | u64 mac_tx_pfc_pri0_pkt_num; | |
355 | u64 mac_tx_pfc_pri1_pkt_num; | |
356 | u64 mac_tx_pfc_pri2_pkt_num; | |
357 | u64 mac_tx_pfc_pri3_pkt_num; | |
358 | u64 mac_tx_pfc_pri4_pkt_num; | |
359 | u64 mac_tx_pfc_pri5_pkt_num; | |
360 | u64 mac_tx_pfc_pri6_pkt_num; | |
361 | u64 mac_tx_pfc_pri7_pkt_num; | |
362 | u64 mac_rx_pfc_pri0_pkt_num; | |
363 | u64 mac_rx_pfc_pri1_pkt_num; | |
364 | u64 mac_rx_pfc_pri2_pkt_num; | |
365 | u64 mac_rx_pfc_pri3_pkt_num; | |
366 | u64 mac_rx_pfc_pri4_pkt_num; | |
367 | u64 mac_rx_pfc_pri5_pkt_num; | |
368 | u64 mac_rx_pfc_pri6_pkt_num; | |
369 | u64 mac_rx_pfc_pri7_pkt_num; | |
370 | u64 mac_tx_total_pkt_num; | |
371 | u64 mac_tx_total_oct_num; | |
372 | u64 mac_tx_good_pkt_num; | |
373 | u64 mac_tx_bad_pkt_num; | |
374 | u64 mac_tx_good_oct_num; | |
375 | u64 mac_tx_bad_oct_num; | |
376 | u64 mac_tx_uni_pkt_num; | |
377 | u64 mac_tx_multi_pkt_num; | |
378 | u64 mac_tx_broad_pkt_num; | |
379 | u64 mac_tx_undersize_pkt_num; | |
380 | u64 mac_tx_overrsize_pkt_num; | |
381 | u64 mac_tx_64_oct_pkt_num; | |
382 | u64 mac_tx_65_127_oct_pkt_num; | |
383 | u64 mac_tx_128_255_oct_pkt_num; | |
384 | u64 mac_tx_256_511_oct_pkt_num; | |
385 | u64 mac_tx_512_1023_oct_pkt_num; | |
386 | u64 mac_tx_1024_1518_oct_pkt_num; | |
387 | u64 mac_tx_1519_max_oct_pkt_num; | |
388 | u64 mac_rx_total_pkt_num; | |
389 | u64 mac_rx_total_oct_num; | |
390 | u64 mac_rx_good_pkt_num; | |
391 | u64 mac_rx_bad_pkt_num; | |
392 | u64 mac_rx_good_oct_num; | |
393 | u64 mac_rx_bad_oct_num; | |
394 | u64 mac_rx_uni_pkt_num; | |
395 | u64 mac_rx_multi_pkt_num; | |
396 | u64 mac_rx_broad_pkt_num; | |
397 | u64 mac_rx_undersize_pkt_num; | |
398 | u64 mac_rx_overrsize_pkt_num; | |
399 | u64 mac_rx_64_oct_pkt_num; | |
400 | u64 mac_rx_65_127_oct_pkt_num; | |
401 | u64 mac_rx_128_255_oct_pkt_num; | |
402 | u64 mac_rx_256_511_oct_pkt_num; | |
403 | u64 mac_rx_512_1023_oct_pkt_num; | |
404 | u64 mac_rx_1024_1518_oct_pkt_num; | |
405 | u64 mac_rx_1519_max_oct_pkt_num; | |
406 | ||
407 | u64 mac_trans_fragment_pkt_num; | |
408 | u64 mac_trans_undermin_pkt_num; | |
409 | u64 mac_trans_jabber_pkt_num; | |
410 | u64 mac_trans_err_all_pkt_num; | |
411 | u64 mac_trans_from_app_good_pkt_num; | |
412 | u64 mac_trans_from_app_bad_pkt_num; | |
413 | u64 mac_rcv_fragment_pkt_num; | |
414 | u64 mac_rcv_undermin_pkt_num; | |
415 | u64 mac_rcv_jabber_pkt_num; | |
416 | u64 mac_rcv_fcs_err_pkt_num; | |
417 | u64 mac_rcv_send_app_good_pkt_num; | |
418 | u64 mac_rcv_send_app_bad_pkt_num; | |
419 | }; | |
420 | ||
421 | struct hclge_hw_stats { | |
422 | struct hclge_mac_stats mac_stats; | |
423 | struct hclge_64_bit_stats all_64_bit_stats; | |
424 | struct hclge_32_bit_stats all_32_bit_stats; | |
425 | }; | |
426 | ||
427 | struct hclge_dev { | |
428 | struct pci_dev *pdev; | |
429 | struct hnae3_ae_dev *ae_dev; | |
430 | struct hclge_hw hw; | |
466b0c00 | 431 | struct hclge_misc_vector misc_vector; |
46a3df9f S |
432 | struct hclge_hw_stats hw_stats; |
433 | unsigned long state; | |
434 | ||
4ed340ab | 435 | enum hnae3_reset_type reset_type; |
cb1b9f77 | 436 | unsigned long reset_request; /* reset has been requested */ |
ca1d7669 | 437 | unsigned long reset_pending; /* client rst is pending to be served */ |
46a3df9f S |
438 | u32 fw_version; |
439 | u16 num_vmdq_vport; /* Num vmdq vport this PF has set up */ | |
440 | u16 num_tqps; /* Num task queue pairs of this PF */ | |
441 | u16 num_req_vfs; /* Num VFs requested for this PF */ | |
442 | ||
46a3df9f S |
443 | /* Base task tqp physical id of this PF */ |
444 | u16 base_tqp_pid; | |
445 | u16 alloc_rss_size; /* Allocated RSS task queue */ | |
446 | u16 rss_size_max; /* HW defined max RSS task queue */ | |
447 | ||
448 | /* Num of guaranteed filters for this PF */ | |
449 | u16 fdir_pf_filter_count; | |
450 | u16 num_alloc_vport; /* Num vports this driver supports */ | |
451 | u32 numa_node_mask; | |
452 | u16 rx_buf_len; | |
453 | u16 num_desc; | |
454 | u8 hw_tc_map; | |
455 | u8 tc_num_last_time; | |
456 | enum hclge_fc_mode fc_mode_last_time; | |
457 | ||
458 | #define HCLGE_FLAG_TC_BASE_SCH_MODE 1 | |
459 | #define HCLGE_FLAG_VNET_BASE_SCH_MODE 2 | |
460 | u8 tx_sch_mode; | |
cacde272 YL |
461 | u8 tc_max; |
462 | u8 pfc_max; | |
46a3df9f S |
463 | |
464 | u8 default_up; | |
cacde272 | 465 | u8 dcbx_cap; |
46a3df9f S |
466 | struct hclge_tm_info tm_info; |
467 | ||
468 | u16 num_msi; | |
469 | u16 num_msi_left; | |
470 | u16 num_msi_used; | |
471 | u32 base_msi_vector; | |
46a3df9f | 472 | u16 *vector_status; |
887c3820 SM |
473 | int *vector_irq; |
474 | u16 num_roce_msi; /* Num of roce vectors for this PF */ | |
475 | int roce_base_vector; | |
46a3df9f S |
476 | |
477 | u16 pending_udp_bitmap; | |
478 | ||
479 | u16 rx_itr_default; | |
480 | u16 tx_itr_default; | |
481 | ||
482 | u16 adminq_work_limit; /* Num of admin receive queue desc to process */ | |
483 | unsigned long service_timer_period; | |
484 | unsigned long service_timer_previous; | |
485 | struct timer_list service_timer; | |
486 | struct work_struct service_task; | |
cb1b9f77 | 487 | struct work_struct rst_service_task; |
c1a81619 | 488 | struct work_struct mbx_service_task; |
46a3df9f S |
489 | |
490 | bool cur_promisc; | |
491 | int num_alloc_vfs; /* Actual number of VFs allocated */ | |
492 | ||
493 | struct hclge_tqp *htqp; | |
494 | struct hclge_vport *vport; | |
495 | ||
496 | struct dentry *hclge_dbgfs; | |
497 | ||
498 | struct hnae3_client *nic_client; | |
499 | struct hnae3_client *roce_client; | |
500 | ||
887c3820 SM |
501 | #define HCLGE_FLAG_MAIN BIT(0) |
502 | #define HCLGE_FLAG_DCB_CAPABLE BIT(1) | |
503 | #define HCLGE_FLAG_DCB_ENABLE BIT(2) | |
504 | #define HCLGE_FLAG_MQPRIO_ENABLE BIT(3) | |
46a3df9f S |
505 | u32 flag; |
506 | ||
507 | u32 pkt_buf_size; /* Total pf buf size for tx/rx */ | |
508 | u32 mps; /* Max packet size */ | |
46a3df9f S |
509 | |
510 | enum hclge_mta_dmac_sel_type mta_mac_sel_type; | |
511 | bool enable_mta; /* Mutilcast filter enable */ | |
512 | bool accept_mta_mc; /* Whether accept mta filter multicast */ | |
513 | }; | |
514 | ||
515 | struct hclge_vport { | |
516 | u16 alloc_tqps; /* Allocated Tx/Rx queues */ | |
517 | ||
518 | u8 rss_hash_key[HCLGE_RSS_KEY_SIZE]; /* User configured hash keys */ | |
519 | /* User configured lookup table entries */ | |
520 | u8 rss_indirection_tbl[HCLGE_RSS_IND_TBL_SIZE]; | |
68ece54e | 521 | u16 alloc_rss_size; |
46a3df9f S |
522 | |
523 | u16 qs_offset; | |
524 | u16 bw_limit; /* VSI BW Limit (0 = disabled) */ | |
525 | u8 dwrr; | |
526 | ||
527 | int vport_id; | |
528 | struct hclge_dev *back; /* Back reference to associated dev */ | |
529 | struct hnae3_handle nic; | |
530 | struct hnae3_handle roce; | |
531 | }; | |
532 | ||
533 | void hclge_promisc_param_init(struct hclge_promisc_param *param, bool en_uc, | |
534 | bool en_mc, bool en_bc, int vport_id); | |
535 | ||
536 | int hclge_add_uc_addr_common(struct hclge_vport *vport, | |
537 | const unsigned char *addr); | |
538 | int hclge_rm_uc_addr_common(struct hclge_vport *vport, | |
539 | const unsigned char *addr); | |
540 | int hclge_add_mc_addr_common(struct hclge_vport *vport, | |
541 | const unsigned char *addr); | |
542 | int hclge_rm_mc_addr_common(struct hclge_vport *vport, | |
543 | const unsigned char *addr); | |
544 | ||
545 | int hclge_cfg_func_mta_filter(struct hclge_dev *hdev, | |
546 | u8 func_id, | |
547 | bool enable); | |
548 | struct hclge_vport *hclge_get_vport(struct hnae3_handle *handle); | |
84e095d6 SM |
549 | int hclge_bind_ring_with_vector(struct hclge_vport *vport, |
550 | int vector_id, bool en, | |
551 | struct hnae3_ring_chain_node *ring_chain); | |
552 | ||
46a3df9f S |
553 | static inline int hclge_get_queue_id(struct hnae3_queue *queue) |
554 | { | |
555 | struct hclge_tqp *tqp = container_of(queue, struct hclge_tqp, q); | |
556 | ||
557 | return tqp->index; | |
558 | } | |
559 | ||
560 | int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex); | |
561 | int hclge_set_vf_vlan_common(struct hclge_dev *vport, int vfid, | |
562 | bool is_kill, u16 vlan, u8 qos, __be16 proto); | |
77f255c1 YL |
563 | |
564 | int hclge_buffer_alloc(struct hclge_dev *hdev); | |
565 | int hclge_rss_init_hw(struct hclge_dev *hdev); | |
dde1a86e SM |
566 | |
567 | void hclge_mbx_handler(struct hclge_dev *hdev); | |
84e095d6 | 568 | void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id); |
46a3df9f | 569 | #endif |