Commit | Line | Data |
---|---|---|
f62b8bb8 AV |
1 | /* |
2 | * Copyright (c) 2015, Mellanox Technologies. All rights reserved. | |
3 | * | |
4 | * This software is available to you under a choice of one of two | |
5 | * licenses. You may choose to be licensed under the terms of the GNU | |
6 | * General Public License (GPL) Version 2, available from the file | |
7 | * COPYING in the main directory of this source tree, or the | |
8 | * OpenIB.org BSD license below: | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or | |
11 | * without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistributions of source code must retain the above | |
15 | * copyright notice, this list of conditions and the following | |
16 | * disclaimer. | |
17 | * | |
18 | * - Redistributions in binary form must reproduce the above | |
19 | * copyright notice, this list of conditions and the following | |
20 | * disclaimer in the documentation and/or other materials | |
21 | * provided with the distribution. | |
22 | * | |
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
30 | * SOFTWARE. | |
31 | */ | |
32 | ||
33 | #include <linux/if_vlan.h> | |
34 | #include <linux/etherdevice.h> | |
ef9814de EBE |
35 | #include <linux/timecounter.h> |
36 | #include <linux/net_tstamp.h> | |
3d8c38af | 37 | #include <linux/ptp_clock_kernel.h> |
f62b8bb8 AV |
38 | #include <linux/mlx5/driver.h> |
39 | #include <linux/mlx5/qp.h> | |
40 | #include <linux/mlx5/cq.h> | |
ada68c31 | 41 | #include <linux/mlx5/port.h> |
d18a9470 | 42 | #include <linux/mlx5/vport.h> |
8d7f9ecb | 43 | #include <linux/mlx5/transobj.h> |
f62b8bb8 | 44 | #include "wq.h" |
f62b8bb8 AV |
45 | #include "mlx5_core.h" |
46 | ||
47 | #define MLX5E_MAX_NUM_TC 8 | |
48 | ||
e842b100 | 49 | #define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE 0x6 |
f62b8bb8 AV |
50 | #define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE 0xa |
51 | #define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE 0xd | |
52 | ||
e842b100 | 53 | #define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE 0x1 |
f62b8bb8 AV |
54 | #define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE 0xa |
55 | #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE 0xd | |
56 | ||
d9a40271 | 57 | #define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024) |
f62b8bb8 AV |
58 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10 |
59 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20 | |
60 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC 0x10 | |
61 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS 0x20 | |
62 | #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES 0x80 | |
f62b8bb8 | 63 | |
936896e9 AS |
64 | #define MLX5E_LOG_INDIR_RQT_SIZE 0x7 |
65 | #define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE) | |
66 | #define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1) | |
f62b8bb8 AV |
67 | #define MLX5E_TX_CQ_POLL_BUDGET 128 |
68 | #define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */ | |
88a85f99 | 69 | #define MLX5E_SQ_BF_BUDGET 16 |
f62b8bb8 | 70 | |
86d722ad MG |
71 | #define MLX5E_NUM_MAIN_GROUPS 9 |
72 | ||
f62b8bb8 AV |
73 | static const char vport_strings[][ETH_GSTRING_LEN] = { |
74 | /* vport statistics */ | |
75 | "rx_packets", | |
76 | "rx_bytes", | |
77 | "tx_packets", | |
78 | "tx_bytes", | |
79 | "rx_error_packets", | |
80 | "rx_error_bytes", | |
81 | "tx_error_packets", | |
82 | "tx_error_bytes", | |
83 | "rx_unicast_packets", | |
84 | "rx_unicast_bytes", | |
85 | "tx_unicast_packets", | |
86 | "tx_unicast_bytes", | |
87 | "rx_multicast_packets", | |
88 | "rx_multicast_bytes", | |
89 | "tx_multicast_packets", | |
90 | "tx_multicast_bytes", | |
91 | "rx_broadcast_packets", | |
92 | "rx_broadcast_bytes", | |
93 | "tx_broadcast_packets", | |
94 | "tx_broadcast_bytes", | |
95 | ||
96 | /* SW counters */ | |
97 | "tso_packets", | |
98 | "tso_bytes", | |
99 | "lro_packets", | |
100 | "lro_bytes", | |
101 | "rx_csum_good", | |
102 | "rx_csum_none", | |
bbceefce | 103 | "rx_csum_sw", |
f62b8bb8 AV |
104 | "tx_csum_offload", |
105 | "tx_queue_stopped", | |
106 | "tx_queue_wake", | |
107 | "tx_queue_dropped", | |
108 | "rx_wqe_err", | |
109 | }; | |
110 | ||
111 | struct mlx5e_vport_stats { | |
112 | /* HW counters */ | |
113 | u64 rx_packets; | |
114 | u64 rx_bytes; | |
115 | u64 tx_packets; | |
116 | u64 tx_bytes; | |
117 | u64 rx_error_packets; | |
118 | u64 rx_error_bytes; | |
119 | u64 tx_error_packets; | |
120 | u64 tx_error_bytes; | |
121 | u64 rx_unicast_packets; | |
122 | u64 rx_unicast_bytes; | |
123 | u64 tx_unicast_packets; | |
124 | u64 tx_unicast_bytes; | |
125 | u64 rx_multicast_packets; | |
126 | u64 rx_multicast_bytes; | |
127 | u64 tx_multicast_packets; | |
128 | u64 tx_multicast_bytes; | |
129 | u64 rx_broadcast_packets; | |
130 | u64 rx_broadcast_bytes; | |
131 | u64 tx_broadcast_packets; | |
132 | u64 tx_broadcast_bytes; | |
133 | ||
134 | /* SW counters */ | |
135 | u64 tso_packets; | |
136 | u64 tso_bytes; | |
137 | u64 lro_packets; | |
138 | u64 lro_bytes; | |
139 | u64 rx_csum_good; | |
140 | u64 rx_csum_none; | |
bbceefce | 141 | u64 rx_csum_sw; |
f62b8bb8 AV |
142 | u64 tx_csum_offload; |
143 | u64 tx_queue_stopped; | |
144 | u64 tx_queue_wake; | |
145 | u64 tx_queue_dropped; | |
146 | u64 rx_wqe_err; | |
147 | ||
bbceefce | 148 | #define NUM_VPORT_COUNTERS 32 |
f62b8bb8 AV |
149 | }; |
150 | ||
efea389d GP |
151 | static const char pport_strings[][ETH_GSTRING_LEN] = { |
152 | /* IEEE802.3 counters */ | |
153 | "frames_tx", | |
154 | "frames_rx", | |
155 | "check_seq_err", | |
156 | "alignment_err", | |
157 | "octets_tx", | |
158 | "octets_received", | |
159 | "multicast_xmitted", | |
160 | "broadcast_xmitted", | |
161 | "multicast_rx", | |
162 | "broadcast_rx", | |
163 | "in_range_len_errors", | |
164 | "out_of_range_len", | |
165 | "too_long_errors", | |
166 | "symbol_err", | |
167 | "mac_control_tx", | |
168 | "mac_control_rx", | |
169 | "unsupported_op_rx", | |
170 | "pause_ctrl_rx", | |
171 | "pause_ctrl_tx", | |
172 | ||
173 | /* RFC2863 counters */ | |
174 | "in_octets", | |
175 | "in_ucast_pkts", | |
176 | "in_discards", | |
177 | "in_errors", | |
178 | "in_unknown_protos", | |
179 | "out_octets", | |
180 | "out_ucast_pkts", | |
181 | "out_discards", | |
182 | "out_errors", | |
183 | "in_multicast_pkts", | |
184 | "in_broadcast_pkts", | |
185 | "out_multicast_pkts", | |
186 | "out_broadcast_pkts", | |
187 | ||
188 | /* RFC2819 counters */ | |
189 | "drop_events", | |
190 | "octets", | |
191 | "pkts", | |
192 | "broadcast_pkts", | |
193 | "multicast_pkts", | |
194 | "crc_align_errors", | |
195 | "undersize_pkts", | |
196 | "oversize_pkts", | |
197 | "fragments", | |
198 | "jabbers", | |
199 | "collisions", | |
200 | "p64octets", | |
201 | "p65to127octets", | |
202 | "p128to255octets", | |
203 | "p256to511octets", | |
204 | "p512to1023octets", | |
205 | "p1024to1518octets", | |
206 | "p1519to2047octets", | |
207 | "p2048to4095octets", | |
208 | "p4096to8191octets", | |
209 | "p8192to10239octets", | |
210 | }; | |
211 | ||
212 | #define NUM_IEEE_802_3_COUNTERS 19 | |
213 | #define NUM_RFC_2863_COUNTERS 13 | |
214 | #define NUM_RFC_2819_COUNTERS 21 | |
215 | #define NUM_PPORT_COUNTERS (NUM_IEEE_802_3_COUNTERS + \ | |
216 | NUM_RFC_2863_COUNTERS + \ | |
217 | NUM_RFC_2819_COUNTERS) | |
218 | ||
219 | struct mlx5e_pport_stats { | |
220 | __be64 IEEE_802_3_counters[NUM_IEEE_802_3_COUNTERS]; | |
221 | __be64 RFC_2863_counters[NUM_RFC_2863_COUNTERS]; | |
222 | __be64 RFC_2819_counters[NUM_RFC_2819_COUNTERS]; | |
223 | }; | |
224 | ||
f62b8bb8 AV |
225 | static const char rq_stats_strings[][ETH_GSTRING_LEN] = { |
226 | "packets", | |
227 | "csum_none", | |
bbceefce | 228 | "csum_sw", |
f62b8bb8 AV |
229 | "lro_packets", |
230 | "lro_bytes", | |
231 | "wqe_err" | |
232 | }; | |
233 | ||
234 | struct mlx5e_rq_stats { | |
235 | u64 packets; | |
236 | u64 csum_none; | |
bbceefce | 237 | u64 csum_sw; |
f62b8bb8 AV |
238 | u64 lro_packets; |
239 | u64 lro_bytes; | |
240 | u64 wqe_err; | |
bbceefce | 241 | #define NUM_RQ_STATS 6 |
f62b8bb8 AV |
242 | }; |
243 | ||
244 | static const char sq_stats_strings[][ETH_GSTRING_LEN] = { | |
245 | "packets", | |
246 | "tso_packets", | |
247 | "tso_bytes", | |
248 | "csum_offload_none", | |
249 | "stopped", | |
250 | "wake", | |
251 | "dropped", | |
252 | "nop" | |
253 | }; | |
254 | ||
255 | struct mlx5e_sq_stats { | |
256 | u64 packets; | |
257 | u64 tso_packets; | |
258 | u64 tso_bytes; | |
259 | u64 csum_offload_none; | |
260 | u64 stopped; | |
261 | u64 wake; | |
262 | u64 dropped; | |
263 | u64 nop; | |
264 | #define NUM_SQ_STATS 8 | |
265 | }; | |
266 | ||
267 | struct mlx5e_stats { | |
268 | struct mlx5e_vport_stats vport; | |
efea389d | 269 | struct mlx5e_pport_stats pport; |
f62b8bb8 AV |
270 | }; |
271 | ||
272 | struct mlx5e_params { | |
273 | u8 log_sq_size; | |
274 | u8 log_rq_size; | |
275 | u16 num_channels; | |
276 | u8 default_vlan_prio; | |
277 | u8 num_tc; | |
278 | u16 rx_cq_moderation_usec; | |
279 | u16 rx_cq_moderation_pkts; | |
280 | u16 tx_cq_moderation_usec; | |
281 | u16 tx_cq_moderation_pkts; | |
282 | u16 min_rx_wqes; | |
f62b8bb8 AV |
283 | bool lro_en; |
284 | u32 lro_wqe_sz; | |
58d52291 | 285 | u16 tx_max_inline; |
2d75b2bc AS |
286 | u8 rss_hfunc; |
287 | u8 toeplitz_hash_key[40]; | |
288 | u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE]; | |
f62b8bb8 AV |
289 | }; |
290 | ||
ef9814de EBE |
291 | struct mlx5e_tstamp { |
292 | rwlock_t lock; | |
293 | struct cyclecounter cycles; | |
294 | struct timecounter clock; | |
295 | struct hwtstamp_config hwtstamp_config; | |
296 | u32 nominal_c_mult; | |
297 | unsigned long overflow_period; | |
298 | struct delayed_work overflow_work; | |
299 | struct mlx5_core_dev *mdev; | |
3d8c38af EBE |
300 | struct ptp_clock *ptp; |
301 | struct ptp_clock_info ptp_info; | |
ef9814de EBE |
302 | }; |
303 | ||
f62b8bb8 AV |
304 | enum { |
305 | MLX5E_RQ_STATE_POST_WQES_ENABLE, | |
306 | }; | |
307 | ||
308 | enum cq_flags { | |
309 | MLX5E_CQ_HAS_CQES = 1, | |
310 | }; | |
311 | ||
312 | struct mlx5e_cq { | |
313 | /* data path - accessed per cqe */ | |
314 | struct mlx5_cqwq wq; | |
f62b8bb8 AV |
315 | unsigned long flags; |
316 | ||
317 | /* data path - accessed per napi poll */ | |
318 | struct napi_struct *napi; | |
319 | struct mlx5_core_cq mcq; | |
320 | struct mlx5e_channel *channel; | |
50cfa25a | 321 | struct mlx5e_priv *priv; |
f62b8bb8 AV |
322 | |
323 | /* control */ | |
324 | struct mlx5_wq_ctrl wq_ctrl; | |
325 | } ____cacheline_aligned_in_smp; | |
326 | ||
327 | struct mlx5e_rq { | |
328 | /* data path */ | |
329 | struct mlx5_wq_ll wq; | |
330 | u32 wqe_sz; | |
331 | struct sk_buff **skb; | |
332 | ||
333 | struct device *pdev; | |
334 | struct net_device *netdev; | |
ef9814de | 335 | struct mlx5e_tstamp *tstamp; |
f62b8bb8 AV |
336 | struct mlx5e_rq_stats stats; |
337 | struct mlx5e_cq cq; | |
338 | ||
339 | unsigned long state; | |
340 | int ix; | |
341 | ||
342 | /* control */ | |
343 | struct mlx5_wq_ctrl wq_ctrl; | |
344 | u32 rqn; | |
345 | struct mlx5e_channel *channel; | |
50cfa25a | 346 | struct mlx5e_priv *priv; |
f62b8bb8 AV |
347 | } ____cacheline_aligned_in_smp; |
348 | ||
34802a42 | 349 | struct mlx5e_tx_wqe_info { |
f62b8bb8 AV |
350 | u32 num_bytes; |
351 | u8 num_wqebbs; | |
352 | u8 num_dma; | |
353 | }; | |
354 | ||
d4e28cbd AS |
355 | enum mlx5e_dma_map_type { |
356 | MLX5E_DMA_MAP_SINGLE, | |
357 | MLX5E_DMA_MAP_PAGE | |
358 | }; | |
359 | ||
f62b8bb8 | 360 | struct mlx5e_sq_dma { |
d4e28cbd AS |
361 | dma_addr_t addr; |
362 | u32 size; | |
363 | enum mlx5e_dma_map_type type; | |
f62b8bb8 AV |
364 | }; |
365 | ||
366 | enum { | |
367 | MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, | |
368 | }; | |
369 | ||
370 | struct mlx5e_sq { | |
371 | /* data path */ | |
372 | ||
373 | /* dirtied @completion */ | |
374 | u16 cc; | |
375 | u32 dma_fifo_cc; | |
376 | ||
377 | /* dirtied @xmit */ | |
378 | u16 pc ____cacheline_aligned_in_smp; | |
379 | u32 dma_fifo_pc; | |
88a85f99 AS |
380 | u16 bf_offset; |
381 | u16 prev_cc; | |
382 | u8 bf_budget; | |
f62b8bb8 AV |
383 | struct mlx5e_sq_stats stats; |
384 | ||
385 | struct mlx5e_cq cq; | |
386 | ||
387 | /* pointers to per packet info: write@xmit, read@completion */ | |
388 | struct sk_buff **skb; | |
389 | struct mlx5e_sq_dma *dma_fifo; | |
34802a42 | 390 | struct mlx5e_tx_wqe_info *wqe_info; |
f62b8bb8 AV |
391 | |
392 | /* read only */ | |
393 | struct mlx5_wq_cyc wq; | |
394 | u32 dma_fifo_mask; | |
395 | void __iomem *uar_map; | |
88a85f99 | 396 | void __iomem *uar_bf_map; |
f62b8bb8 AV |
397 | struct netdev_queue *txq; |
398 | u32 sqn; | |
88a85f99 | 399 | u16 bf_buf_size; |
12be4b21 SM |
400 | u16 max_inline; |
401 | u16 edge; | |
f62b8bb8 | 402 | struct device *pdev; |
ef9814de | 403 | struct mlx5e_tstamp *tstamp; |
f62b8bb8 AV |
404 | __be32 mkey_be; |
405 | unsigned long state; | |
406 | ||
407 | /* control path */ | |
408 | struct mlx5_wq_ctrl wq_ctrl; | |
409 | struct mlx5_uar uar; | |
410 | struct mlx5e_channel *channel; | |
411 | int tc; | |
412 | } ____cacheline_aligned_in_smp; | |
413 | ||
414 | static inline bool mlx5e_sq_has_room_for(struct mlx5e_sq *sq, u16 n) | |
415 | { | |
416 | return (((sq->wq.sz_m1 & (sq->cc - sq->pc)) >= n) || | |
417 | (sq->cc == sq->pc)); | |
418 | } | |
419 | ||
420 | enum channel_flags { | |
421 | MLX5E_CHANNEL_NAPI_SCHED = 1, | |
422 | }; | |
423 | ||
424 | struct mlx5e_channel { | |
425 | /* data path */ | |
426 | struct mlx5e_rq rq; | |
427 | struct mlx5e_sq sq[MLX5E_MAX_NUM_TC]; | |
428 | struct napi_struct napi; | |
429 | struct device *pdev; | |
430 | struct net_device *netdev; | |
431 | __be32 mkey_be; | |
432 | u8 num_tc; | |
433 | unsigned long flags; | |
434 | ||
435 | /* control */ | |
436 | struct mlx5e_priv *priv; | |
437 | int ix; | |
438 | int cpu; | |
439 | }; | |
440 | ||
441 | enum mlx5e_traffic_types { | |
5a6f8aef AS |
442 | MLX5E_TT_IPV4_TCP, |
443 | MLX5E_TT_IPV6_TCP, | |
444 | MLX5E_TT_IPV4_UDP, | |
445 | MLX5E_TT_IPV6_UDP, | |
a741749f AS |
446 | MLX5E_TT_IPV4_IPSEC_AH, |
447 | MLX5E_TT_IPV6_IPSEC_AH, | |
448 | MLX5E_TT_IPV4_IPSEC_ESP, | |
449 | MLX5E_TT_IPV6_IPSEC_ESP, | |
5a6f8aef AS |
450 | MLX5E_TT_IPV4, |
451 | MLX5E_TT_IPV6, | |
452 | MLX5E_TT_ANY, | |
453 | MLX5E_NUM_TT, | |
f62b8bb8 AV |
454 | }; |
455 | ||
4cbeaff5 AS |
456 | enum mlx5e_rqt_ix { |
457 | MLX5E_INDIRECTION_RQT, | |
458 | MLX5E_SINGLE_RQ_RQT, | |
459 | MLX5E_NUM_RQT, | |
f62b8bb8 AV |
460 | }; |
461 | ||
462 | struct mlx5e_eth_addr_info { | |
463 | u8 addr[ETH_ALEN + 2]; | |
464 | u32 tt_vec; | |
86d722ad | 465 | struct mlx5_flow_rule *ft_rule[MLX5E_NUM_TT]; |
f62b8bb8 AV |
466 | }; |
467 | ||
468 | #define MLX5E_ETH_ADDR_HASH_SIZE (1 << BITS_PER_BYTE) | |
469 | ||
470 | struct mlx5e_eth_addr_db { | |
471 | struct hlist_head netdev_uc[MLX5E_ETH_ADDR_HASH_SIZE]; | |
472 | struct hlist_head netdev_mc[MLX5E_ETH_ADDR_HASH_SIZE]; | |
473 | struct mlx5e_eth_addr_info broadcast; | |
474 | struct mlx5e_eth_addr_info allmulti; | |
475 | struct mlx5e_eth_addr_info promisc; | |
476 | bool broadcast_enabled; | |
477 | bool allmulti_enabled; | |
478 | bool promisc_enabled; | |
479 | }; | |
480 | ||
481 | enum { | |
482 | MLX5E_STATE_ASYNC_EVENTS_ENABLE, | |
483 | MLX5E_STATE_OPENED, | |
9b37b07f | 484 | MLX5E_STATE_DESTROYING, |
f62b8bb8 AV |
485 | }; |
486 | ||
487 | struct mlx5e_vlan_db { | |
aad9e6e4 | 488 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
86d722ad MG |
489 | struct mlx5_flow_rule *active_vlans_rule[VLAN_N_VID]; |
490 | struct mlx5_flow_rule *untagged_rule; | |
491 | struct mlx5_flow_rule *any_vlan_rule; | |
f62b8bb8 AV |
492 | bool filter_disabled; |
493 | }; | |
494 | ||
495 | struct mlx5e_flow_table { | |
86d722ad MG |
496 | int num_groups; |
497 | struct mlx5_flow_table *t; | |
498 | struct mlx5_flow_group **g; | |
499 | }; | |
500 | ||
501 | struct mlx5e_flow_tables { | |
502 | struct mlx5_flow_namespace *ns; | |
503 | struct mlx5e_flow_table vlan; | |
504 | struct mlx5e_flow_table main; | |
f62b8bb8 AV |
505 | }; |
506 | ||
507 | struct mlx5e_priv { | |
508 | /* priv data path fields - start */ | |
f62b8bb8 | 509 | int default_vlan_prio; |
03289b88 | 510 | struct mlx5e_sq **txq_to_sq_map; |
5283af89 | 511 | int channeltc_to_txq_map[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC]; |
f62b8bb8 AV |
512 | /* priv data path fields - end */ |
513 | ||
514 | unsigned long state; | |
515 | struct mutex state_lock; /* Protects Interface state */ | |
516 | struct mlx5_uar cq_uar; | |
517 | u32 pdn; | |
3191e05f | 518 | u32 tdn; |
f62b8bb8 | 519 | struct mlx5_core_mr mr; |
50cfa25a | 520 | struct mlx5e_rq drop_rq; |
f62b8bb8 AV |
521 | |
522 | struct mlx5e_channel **channel; | |
523 | u32 tisn[MLX5E_MAX_NUM_TC]; | |
4cbeaff5 | 524 | u32 rqtn[MLX5E_NUM_RQT]; |
f62b8bb8 AV |
525 | u32 tirn[MLX5E_NUM_TT]; |
526 | ||
86d722ad | 527 | struct mlx5e_flow_tables fts; |
f62b8bb8 AV |
528 | struct mlx5e_eth_addr_db eth_addr; |
529 | struct mlx5e_vlan_db vlan; | |
530 | ||
531 | struct mlx5e_params params; | |
532 | spinlock_t async_events_spinlock; /* sync hw events */ | |
533 | struct work_struct update_carrier_work; | |
534 | struct work_struct set_rx_mode_work; | |
535 | struct delayed_work update_stats_work; | |
536 | ||
537 | struct mlx5_core_dev *mdev; | |
538 | struct net_device *netdev; | |
539 | struct mlx5e_stats stats; | |
ef9814de | 540 | struct mlx5e_tstamp tstamp; |
f62b8bb8 AV |
541 | }; |
542 | ||
543 | #define MLX5E_NET_IP_ALIGN 2 | |
544 | ||
545 | struct mlx5e_tx_wqe { | |
546 | struct mlx5_wqe_ctrl_seg ctrl; | |
547 | struct mlx5_wqe_eth_seg eth; | |
548 | }; | |
549 | ||
550 | struct mlx5e_rx_wqe { | |
551 | struct mlx5_wqe_srq_next_seg next; | |
552 | struct mlx5_wqe_data_seg data; | |
553 | }; | |
554 | ||
555 | enum mlx5e_link_mode { | |
556 | MLX5E_1000BASE_CX_SGMII = 0, | |
557 | MLX5E_1000BASE_KX = 1, | |
558 | MLX5E_10GBASE_CX4 = 2, | |
559 | MLX5E_10GBASE_KX4 = 3, | |
560 | MLX5E_10GBASE_KR = 4, | |
561 | MLX5E_20GBASE_KR2 = 5, | |
562 | MLX5E_40GBASE_CR4 = 6, | |
563 | MLX5E_40GBASE_KR4 = 7, | |
564 | MLX5E_56GBASE_R4 = 8, | |
565 | MLX5E_10GBASE_CR = 12, | |
566 | MLX5E_10GBASE_SR = 13, | |
567 | MLX5E_10GBASE_ER = 14, | |
568 | MLX5E_40GBASE_SR4 = 15, | |
569 | MLX5E_40GBASE_LR4 = 16, | |
570 | MLX5E_100GBASE_CR4 = 20, | |
571 | MLX5E_100GBASE_SR4 = 21, | |
572 | MLX5E_100GBASE_KR4 = 22, | |
573 | MLX5E_100GBASE_LR4 = 23, | |
574 | MLX5E_100BASE_TX = 24, | |
575 | MLX5E_100BASE_T = 25, | |
576 | MLX5E_10GBASE_T = 26, | |
577 | MLX5E_25GBASE_CR = 27, | |
578 | MLX5E_25GBASE_KR = 28, | |
579 | MLX5E_25GBASE_SR = 29, | |
580 | MLX5E_50GBASE_CR2 = 30, | |
581 | MLX5E_50GBASE_KR2 = 31, | |
582 | MLX5E_LINK_MODES_NUMBER, | |
583 | }; | |
584 | ||
585 | #define MLX5E_PROT_MASK(link_mode) (1 << link_mode) | |
586 | ||
12be4b21 | 587 | void mlx5e_send_nop(struct mlx5e_sq *sq, bool notify_hw); |
f62b8bb8 AV |
588 | u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb, |
589 | void *accel_priv, select_queue_fallback_t fallback); | |
590 | netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev); | |
f62b8bb8 AV |
591 | |
592 | void mlx5e_completion_event(struct mlx5_core_cq *mcq); | |
593 | void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event); | |
594 | int mlx5e_napi_poll(struct napi_struct *napi, int budget); | |
595 | bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq); | |
44fb6fbb | 596 | int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); |
f62b8bb8 AV |
597 | bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq); |
598 | struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq); | |
599 | ||
600 | void mlx5e_update_stats(struct mlx5e_priv *priv); | |
601 | ||
40ab6a6e AS |
602 | int mlx5e_create_flow_tables(struct mlx5e_priv *priv); |
603 | void mlx5e_destroy_flow_tables(struct mlx5e_priv *priv); | |
f62b8bb8 | 604 | void mlx5e_init_eth_addr(struct mlx5e_priv *priv); |
f62b8bb8 AV |
605 | void mlx5e_set_rx_mode_work(struct work_struct *work); |
606 | ||
ef9814de EBE |
607 | void mlx5e_fill_hwstamp(struct mlx5e_tstamp *clock, u64 timestamp, |
608 | struct skb_shared_hwtstamps *hwts); | |
609 | void mlx5e_timestamp_init(struct mlx5e_priv *priv); | |
610 | void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv); | |
611 | int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr); | |
612 | int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr); | |
613 | ||
f62b8bb8 AV |
614 | int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto, |
615 | u16 vid); | |
616 | int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto, | |
617 | u16 vid); | |
618 | void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv); | |
619 | void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv); | |
f62b8bb8 | 620 | |
2d75b2bc AS |
621 | int mlx5e_redirect_rqt(struct mlx5e_priv *priv, enum mlx5e_rqt_ix rqt_ix); |
622 | ||
f62b8bb8 AV |
623 | int mlx5e_open_locked(struct net_device *netdev); |
624 | int mlx5e_close_locked(struct net_device *netdev); | |
f62b8bb8 AV |
625 | |
626 | static inline void mlx5e_tx_notify_hw(struct mlx5e_sq *sq, | |
88a85f99 | 627 | struct mlx5e_tx_wqe *wqe, int bf_sz) |
f62b8bb8 | 628 | { |
88a85f99 AS |
629 | u16 ofst = MLX5_BF_OFFSET + sq->bf_offset; |
630 | ||
f62b8bb8 AV |
631 | /* ensure wqe is visible to device before updating doorbell record */ |
632 | dma_wmb(); | |
633 | ||
634 | *sq->wq.db = cpu_to_be32(sq->pc); | |
635 | ||
636 | /* ensure doorbell record is visible to device before ringing the | |
637 | * doorbell | |
638 | */ | |
639 | wmb(); | |
640 | ||
88a85f99 AS |
641 | if (bf_sz) { |
642 | __iowrite64_copy(sq->uar_bf_map + ofst, &wqe->ctrl, bf_sz); | |
643 | ||
644 | /* flush the write-combining mapped buffer */ | |
645 | wmb(); | |
646 | ||
647 | } else { | |
648 | mlx5_write64((__be32 *)&wqe->ctrl, sq->uar_map + ofst, NULL); | |
649 | } | |
f62b8bb8 AV |
650 | |
651 | sq->bf_offset ^= sq->bf_buf_size; | |
652 | } | |
653 | ||
654 | static inline void mlx5e_cq_arm(struct mlx5e_cq *cq) | |
655 | { | |
656 | struct mlx5_core_cq *mcq; | |
657 | ||
658 | mcq = &cq->mcq; | |
659 | mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, NULL, cq->wq.cc); | |
660 | } | |
661 | ||
3435ab59 AS |
662 | static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev) |
663 | { | |
664 | return min_t(int, mdev->priv.eq_table.num_comp_vectors, | |
665 | MLX5E_MAX_NUM_CHANNELS); | |
666 | } | |
667 | ||
f62b8bb8 | 668 | extern const struct ethtool_ops mlx5e_ethtool_ops; |
58d52291 | 669 | u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev); |