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> | |
35 | #include <linux/mlx5/driver.h> | |
36 | #include <linux/mlx5/qp.h> | |
37 | #include <linux/mlx5/cq.h> | |
d18a9470 | 38 | #include <linux/mlx5/vport.h> |
f62b8bb8 AV |
39 | #include "wq.h" |
40 | #include "transobj.h" | |
41 | #include "mlx5_core.h" | |
42 | ||
43 | #define MLX5E_MAX_NUM_TC 8 | |
44 | ||
45 | #define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE 0x7 | |
46 | #define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE 0xa | |
47 | #define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE 0xd | |
48 | ||
49 | #define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE 0x7 | |
50 | #define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE 0xa | |
51 | #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE 0xd | |
52 | ||
53 | #define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (16 * 1024) | |
54 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10 | |
55 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20 | |
56 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC 0x10 | |
57 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS 0x20 | |
58 | #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES 0x80 | |
f62b8bb8 | 59 | |
936896e9 AS |
60 | #define MLX5E_LOG_INDIR_RQT_SIZE 0x7 |
61 | #define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE) | |
62 | #define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1) | |
f62b8bb8 AV |
63 | #define MLX5E_TX_CQ_POLL_BUDGET 128 |
64 | #define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */ | |
88a85f99 | 65 | #define MLX5E_SQ_BF_BUDGET 16 |
f62b8bb8 AV |
66 | |
67 | static const char vport_strings[][ETH_GSTRING_LEN] = { | |
68 | /* vport statistics */ | |
69 | "rx_packets", | |
70 | "rx_bytes", | |
71 | "tx_packets", | |
72 | "tx_bytes", | |
73 | "rx_error_packets", | |
74 | "rx_error_bytes", | |
75 | "tx_error_packets", | |
76 | "tx_error_bytes", | |
77 | "rx_unicast_packets", | |
78 | "rx_unicast_bytes", | |
79 | "tx_unicast_packets", | |
80 | "tx_unicast_bytes", | |
81 | "rx_multicast_packets", | |
82 | "rx_multicast_bytes", | |
83 | "tx_multicast_packets", | |
84 | "tx_multicast_bytes", | |
85 | "rx_broadcast_packets", | |
86 | "rx_broadcast_bytes", | |
87 | "tx_broadcast_packets", | |
88 | "tx_broadcast_bytes", | |
89 | ||
90 | /* SW counters */ | |
91 | "tso_packets", | |
92 | "tso_bytes", | |
93 | "lro_packets", | |
94 | "lro_bytes", | |
95 | "rx_csum_good", | |
96 | "rx_csum_none", | |
97 | "tx_csum_offload", | |
98 | "tx_queue_stopped", | |
99 | "tx_queue_wake", | |
100 | "tx_queue_dropped", | |
101 | "rx_wqe_err", | |
102 | }; | |
103 | ||
104 | struct mlx5e_vport_stats { | |
105 | /* HW counters */ | |
106 | u64 rx_packets; | |
107 | u64 rx_bytes; | |
108 | u64 tx_packets; | |
109 | u64 tx_bytes; | |
110 | u64 rx_error_packets; | |
111 | u64 rx_error_bytes; | |
112 | u64 tx_error_packets; | |
113 | u64 tx_error_bytes; | |
114 | u64 rx_unicast_packets; | |
115 | u64 rx_unicast_bytes; | |
116 | u64 tx_unicast_packets; | |
117 | u64 tx_unicast_bytes; | |
118 | u64 rx_multicast_packets; | |
119 | u64 rx_multicast_bytes; | |
120 | u64 tx_multicast_packets; | |
121 | u64 tx_multicast_bytes; | |
122 | u64 rx_broadcast_packets; | |
123 | u64 rx_broadcast_bytes; | |
124 | u64 tx_broadcast_packets; | |
125 | u64 tx_broadcast_bytes; | |
126 | ||
127 | /* SW counters */ | |
128 | u64 tso_packets; | |
129 | u64 tso_bytes; | |
130 | u64 lro_packets; | |
131 | u64 lro_bytes; | |
132 | u64 rx_csum_good; | |
133 | u64 rx_csum_none; | |
134 | u64 tx_csum_offload; | |
135 | u64 tx_queue_stopped; | |
136 | u64 tx_queue_wake; | |
137 | u64 tx_queue_dropped; | |
138 | u64 rx_wqe_err; | |
139 | ||
140 | #define NUM_VPORT_COUNTERS 31 | |
141 | }; | |
142 | ||
efea389d GP |
143 | static const char pport_strings[][ETH_GSTRING_LEN] = { |
144 | /* IEEE802.3 counters */ | |
145 | "frames_tx", | |
146 | "frames_rx", | |
147 | "check_seq_err", | |
148 | "alignment_err", | |
149 | "octets_tx", | |
150 | "octets_received", | |
151 | "multicast_xmitted", | |
152 | "broadcast_xmitted", | |
153 | "multicast_rx", | |
154 | "broadcast_rx", | |
155 | "in_range_len_errors", | |
156 | "out_of_range_len", | |
157 | "too_long_errors", | |
158 | "symbol_err", | |
159 | "mac_control_tx", | |
160 | "mac_control_rx", | |
161 | "unsupported_op_rx", | |
162 | "pause_ctrl_rx", | |
163 | "pause_ctrl_tx", | |
164 | ||
165 | /* RFC2863 counters */ | |
166 | "in_octets", | |
167 | "in_ucast_pkts", | |
168 | "in_discards", | |
169 | "in_errors", | |
170 | "in_unknown_protos", | |
171 | "out_octets", | |
172 | "out_ucast_pkts", | |
173 | "out_discards", | |
174 | "out_errors", | |
175 | "in_multicast_pkts", | |
176 | "in_broadcast_pkts", | |
177 | "out_multicast_pkts", | |
178 | "out_broadcast_pkts", | |
179 | ||
180 | /* RFC2819 counters */ | |
181 | "drop_events", | |
182 | "octets", | |
183 | "pkts", | |
184 | "broadcast_pkts", | |
185 | "multicast_pkts", | |
186 | "crc_align_errors", | |
187 | "undersize_pkts", | |
188 | "oversize_pkts", | |
189 | "fragments", | |
190 | "jabbers", | |
191 | "collisions", | |
192 | "p64octets", | |
193 | "p65to127octets", | |
194 | "p128to255octets", | |
195 | "p256to511octets", | |
196 | "p512to1023octets", | |
197 | "p1024to1518octets", | |
198 | "p1519to2047octets", | |
199 | "p2048to4095octets", | |
200 | "p4096to8191octets", | |
201 | "p8192to10239octets", | |
202 | }; | |
203 | ||
204 | #define NUM_IEEE_802_3_COUNTERS 19 | |
205 | #define NUM_RFC_2863_COUNTERS 13 | |
206 | #define NUM_RFC_2819_COUNTERS 21 | |
207 | #define NUM_PPORT_COUNTERS (NUM_IEEE_802_3_COUNTERS + \ | |
208 | NUM_RFC_2863_COUNTERS + \ | |
209 | NUM_RFC_2819_COUNTERS) | |
210 | ||
211 | struct mlx5e_pport_stats { | |
212 | __be64 IEEE_802_3_counters[NUM_IEEE_802_3_COUNTERS]; | |
213 | __be64 RFC_2863_counters[NUM_RFC_2863_COUNTERS]; | |
214 | __be64 RFC_2819_counters[NUM_RFC_2819_COUNTERS]; | |
215 | }; | |
216 | ||
f62b8bb8 AV |
217 | static const char rq_stats_strings[][ETH_GSTRING_LEN] = { |
218 | "packets", | |
219 | "csum_none", | |
220 | "lro_packets", | |
221 | "lro_bytes", | |
222 | "wqe_err" | |
223 | }; | |
224 | ||
225 | struct mlx5e_rq_stats { | |
226 | u64 packets; | |
227 | u64 csum_none; | |
228 | u64 lro_packets; | |
229 | u64 lro_bytes; | |
230 | u64 wqe_err; | |
231 | #define NUM_RQ_STATS 5 | |
232 | }; | |
233 | ||
234 | static const char sq_stats_strings[][ETH_GSTRING_LEN] = { | |
235 | "packets", | |
236 | "tso_packets", | |
237 | "tso_bytes", | |
238 | "csum_offload_none", | |
239 | "stopped", | |
240 | "wake", | |
241 | "dropped", | |
242 | "nop" | |
243 | }; | |
244 | ||
245 | struct mlx5e_sq_stats { | |
246 | u64 packets; | |
247 | u64 tso_packets; | |
248 | u64 tso_bytes; | |
249 | u64 csum_offload_none; | |
250 | u64 stopped; | |
251 | u64 wake; | |
252 | u64 dropped; | |
253 | u64 nop; | |
254 | #define NUM_SQ_STATS 8 | |
255 | }; | |
256 | ||
257 | struct mlx5e_stats { | |
258 | struct mlx5e_vport_stats vport; | |
efea389d | 259 | struct mlx5e_pport_stats pport; |
f62b8bb8 AV |
260 | }; |
261 | ||
262 | struct mlx5e_params { | |
263 | u8 log_sq_size; | |
264 | u8 log_rq_size; | |
265 | u16 num_channels; | |
266 | u8 default_vlan_prio; | |
267 | u8 num_tc; | |
268 | u16 rx_cq_moderation_usec; | |
269 | u16 rx_cq_moderation_pkts; | |
270 | u16 tx_cq_moderation_usec; | |
271 | u16 tx_cq_moderation_pkts; | |
272 | u16 min_rx_wqes; | |
f62b8bb8 AV |
273 | bool lro_en; |
274 | u32 lro_wqe_sz; | |
2be6967c | 275 | u8 rss_hfunc; |
58d52291 | 276 | u16 tx_max_inline; |
57afead5 | 277 | u8 toeplitz_hash_key[40]; |
f62b8bb8 AV |
278 | }; |
279 | ||
280 | enum { | |
281 | MLX5E_RQ_STATE_POST_WQES_ENABLE, | |
282 | }; | |
283 | ||
284 | enum cq_flags { | |
285 | MLX5E_CQ_HAS_CQES = 1, | |
286 | }; | |
287 | ||
288 | struct mlx5e_cq { | |
289 | /* data path - accessed per cqe */ | |
290 | struct mlx5_cqwq wq; | |
f62b8bb8 AV |
291 | unsigned long flags; |
292 | ||
293 | /* data path - accessed per napi poll */ | |
294 | struct napi_struct *napi; | |
295 | struct mlx5_core_cq mcq; | |
296 | struct mlx5e_channel *channel; | |
50cfa25a | 297 | struct mlx5e_priv *priv; |
f62b8bb8 AV |
298 | |
299 | /* control */ | |
300 | struct mlx5_wq_ctrl wq_ctrl; | |
301 | } ____cacheline_aligned_in_smp; | |
302 | ||
303 | struct mlx5e_rq { | |
304 | /* data path */ | |
305 | struct mlx5_wq_ll wq; | |
306 | u32 wqe_sz; | |
307 | struct sk_buff **skb; | |
308 | ||
309 | struct device *pdev; | |
310 | struct net_device *netdev; | |
311 | struct mlx5e_rq_stats stats; | |
312 | struct mlx5e_cq cq; | |
313 | ||
314 | unsigned long state; | |
315 | int ix; | |
316 | ||
317 | /* control */ | |
318 | struct mlx5_wq_ctrl wq_ctrl; | |
319 | u32 rqn; | |
320 | struct mlx5e_channel *channel; | |
50cfa25a | 321 | struct mlx5e_priv *priv; |
f62b8bb8 AV |
322 | } ____cacheline_aligned_in_smp; |
323 | ||
324 | struct mlx5e_tx_skb_cb { | |
325 | u32 num_bytes; | |
326 | u8 num_wqebbs; | |
327 | u8 num_dma; | |
328 | }; | |
329 | ||
330 | #define MLX5E_TX_SKB_CB(__skb) ((struct mlx5e_tx_skb_cb *)__skb->cb) | |
331 | ||
332 | struct mlx5e_sq_dma { | |
333 | dma_addr_t addr; | |
334 | u32 size; | |
335 | }; | |
336 | ||
337 | enum { | |
338 | MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, | |
339 | }; | |
340 | ||
341 | struct mlx5e_sq { | |
342 | /* data path */ | |
343 | ||
344 | /* dirtied @completion */ | |
345 | u16 cc; | |
346 | u32 dma_fifo_cc; | |
347 | ||
348 | /* dirtied @xmit */ | |
349 | u16 pc ____cacheline_aligned_in_smp; | |
350 | u32 dma_fifo_pc; | |
88a85f99 AS |
351 | u16 bf_offset; |
352 | u16 prev_cc; | |
353 | u8 bf_budget; | |
f62b8bb8 AV |
354 | struct mlx5e_sq_stats stats; |
355 | ||
356 | struct mlx5e_cq cq; | |
357 | ||
358 | /* pointers to per packet info: write@xmit, read@completion */ | |
359 | struct sk_buff **skb; | |
360 | struct mlx5e_sq_dma *dma_fifo; | |
361 | ||
362 | /* read only */ | |
363 | struct mlx5_wq_cyc wq; | |
364 | u32 dma_fifo_mask; | |
365 | void __iomem *uar_map; | |
88a85f99 | 366 | void __iomem *uar_bf_map; |
f62b8bb8 AV |
367 | struct netdev_queue *txq; |
368 | u32 sqn; | |
88a85f99 | 369 | u16 bf_buf_size; |
12be4b21 SM |
370 | u16 max_inline; |
371 | u16 edge; | |
f62b8bb8 AV |
372 | struct device *pdev; |
373 | __be32 mkey_be; | |
374 | unsigned long state; | |
375 | ||
376 | /* control path */ | |
377 | struct mlx5_wq_ctrl wq_ctrl; | |
378 | struct mlx5_uar uar; | |
379 | struct mlx5e_channel *channel; | |
380 | int tc; | |
381 | } ____cacheline_aligned_in_smp; | |
382 | ||
383 | static inline bool mlx5e_sq_has_room_for(struct mlx5e_sq *sq, u16 n) | |
384 | { | |
385 | return (((sq->wq.sz_m1 & (sq->cc - sq->pc)) >= n) || | |
386 | (sq->cc == sq->pc)); | |
387 | } | |
388 | ||
389 | enum channel_flags { | |
390 | MLX5E_CHANNEL_NAPI_SCHED = 1, | |
391 | }; | |
392 | ||
393 | struct mlx5e_channel { | |
394 | /* data path */ | |
395 | struct mlx5e_rq rq; | |
396 | struct mlx5e_sq sq[MLX5E_MAX_NUM_TC]; | |
397 | struct napi_struct napi; | |
398 | struct device *pdev; | |
399 | struct net_device *netdev; | |
400 | __be32 mkey_be; | |
401 | u8 num_tc; | |
402 | unsigned long flags; | |
03289b88 | 403 | int tc_to_txq_map[MLX5E_MAX_NUM_TC]; |
f62b8bb8 AV |
404 | |
405 | /* control */ | |
406 | struct mlx5e_priv *priv; | |
407 | int ix; | |
408 | int cpu; | |
409 | }; | |
410 | ||
411 | enum mlx5e_traffic_types { | |
5a6f8aef AS |
412 | MLX5E_TT_IPV4_TCP, |
413 | MLX5E_TT_IPV6_TCP, | |
414 | MLX5E_TT_IPV4_UDP, | |
415 | MLX5E_TT_IPV6_UDP, | |
a741749f AS |
416 | MLX5E_TT_IPV4_IPSEC_AH, |
417 | MLX5E_TT_IPV6_IPSEC_AH, | |
418 | MLX5E_TT_IPV4_IPSEC_ESP, | |
419 | MLX5E_TT_IPV6_IPSEC_ESP, | |
5a6f8aef AS |
420 | MLX5E_TT_IPV4, |
421 | MLX5E_TT_IPV6, | |
422 | MLX5E_TT_ANY, | |
423 | MLX5E_NUM_TT, | |
f62b8bb8 AV |
424 | }; |
425 | ||
4cbeaff5 AS |
426 | enum mlx5e_rqt_ix { |
427 | MLX5E_INDIRECTION_RQT, | |
428 | MLX5E_SINGLE_RQ_RQT, | |
429 | MLX5E_NUM_RQT, | |
f62b8bb8 AV |
430 | }; |
431 | ||
432 | struct mlx5e_eth_addr_info { | |
433 | u8 addr[ETH_ALEN + 2]; | |
434 | u32 tt_vec; | |
435 | u32 ft_ix[MLX5E_NUM_TT]; /* flow table index per traffic type */ | |
436 | }; | |
437 | ||
438 | #define MLX5E_ETH_ADDR_HASH_SIZE (1 << BITS_PER_BYTE) | |
439 | ||
440 | struct mlx5e_eth_addr_db { | |
441 | struct hlist_head netdev_uc[MLX5E_ETH_ADDR_HASH_SIZE]; | |
442 | struct hlist_head netdev_mc[MLX5E_ETH_ADDR_HASH_SIZE]; | |
443 | struct mlx5e_eth_addr_info broadcast; | |
444 | struct mlx5e_eth_addr_info allmulti; | |
445 | struct mlx5e_eth_addr_info promisc; | |
446 | bool broadcast_enabled; | |
447 | bool allmulti_enabled; | |
448 | bool promisc_enabled; | |
449 | }; | |
450 | ||
451 | enum { | |
452 | MLX5E_STATE_ASYNC_EVENTS_ENABLE, | |
453 | MLX5E_STATE_OPENED, | |
9b37b07f | 454 | MLX5E_STATE_DESTROYING, |
f62b8bb8 AV |
455 | }; |
456 | ||
457 | struct mlx5e_vlan_db { | |
f62b8bb8 AV |
458 | u32 active_vlans_ft_ix[VLAN_N_VID]; |
459 | u32 untagged_rule_ft_ix; | |
460 | u32 any_vlan_rule_ft_ix; | |
461 | bool filter_disabled; | |
462 | }; | |
463 | ||
464 | struct mlx5e_flow_table { | |
465 | void *vlan; | |
466 | void *main; | |
467 | }; | |
468 | ||
469 | struct mlx5e_priv { | |
470 | /* priv data path fields - start */ | |
f62b8bb8 | 471 | int default_vlan_prio; |
03289b88 | 472 | struct mlx5e_sq **txq_to_sq_map; |
f62b8bb8 AV |
473 | /* priv data path fields - end */ |
474 | ||
475 | unsigned long state; | |
476 | struct mutex state_lock; /* Protects Interface state */ | |
477 | struct mlx5_uar cq_uar; | |
478 | u32 pdn; | |
3191e05f | 479 | u32 tdn; |
f62b8bb8 | 480 | struct mlx5_core_mr mr; |
50cfa25a | 481 | struct mlx5e_rq drop_rq; |
f62b8bb8 AV |
482 | |
483 | struct mlx5e_channel **channel; | |
484 | u32 tisn[MLX5E_MAX_NUM_TC]; | |
4cbeaff5 | 485 | u32 rqtn[MLX5E_NUM_RQT]; |
f62b8bb8 AV |
486 | u32 tirn[MLX5E_NUM_TT]; |
487 | ||
488 | struct mlx5e_flow_table ft; | |
489 | struct mlx5e_eth_addr_db eth_addr; | |
490 | struct mlx5e_vlan_db vlan; | |
491 | ||
492 | struct mlx5e_params params; | |
493 | spinlock_t async_events_spinlock; /* sync hw events */ | |
494 | struct work_struct update_carrier_work; | |
495 | struct work_struct set_rx_mode_work; | |
496 | struct delayed_work update_stats_work; | |
497 | ||
498 | struct mlx5_core_dev *mdev; | |
499 | struct net_device *netdev; | |
500 | struct mlx5e_stats stats; | |
501 | }; | |
502 | ||
503 | #define MLX5E_NET_IP_ALIGN 2 | |
504 | ||
505 | struct mlx5e_tx_wqe { | |
506 | struct mlx5_wqe_ctrl_seg ctrl; | |
507 | struct mlx5_wqe_eth_seg eth; | |
508 | }; | |
509 | ||
510 | struct mlx5e_rx_wqe { | |
511 | struct mlx5_wqe_srq_next_seg next; | |
512 | struct mlx5_wqe_data_seg data; | |
513 | }; | |
514 | ||
515 | enum mlx5e_link_mode { | |
516 | MLX5E_1000BASE_CX_SGMII = 0, | |
517 | MLX5E_1000BASE_KX = 1, | |
518 | MLX5E_10GBASE_CX4 = 2, | |
519 | MLX5E_10GBASE_KX4 = 3, | |
520 | MLX5E_10GBASE_KR = 4, | |
521 | MLX5E_20GBASE_KR2 = 5, | |
522 | MLX5E_40GBASE_CR4 = 6, | |
523 | MLX5E_40GBASE_KR4 = 7, | |
524 | MLX5E_56GBASE_R4 = 8, | |
525 | MLX5E_10GBASE_CR = 12, | |
526 | MLX5E_10GBASE_SR = 13, | |
527 | MLX5E_10GBASE_ER = 14, | |
528 | MLX5E_40GBASE_SR4 = 15, | |
529 | MLX5E_40GBASE_LR4 = 16, | |
530 | MLX5E_100GBASE_CR4 = 20, | |
531 | MLX5E_100GBASE_SR4 = 21, | |
532 | MLX5E_100GBASE_KR4 = 22, | |
533 | MLX5E_100GBASE_LR4 = 23, | |
534 | MLX5E_100BASE_TX = 24, | |
535 | MLX5E_100BASE_T = 25, | |
536 | MLX5E_10GBASE_T = 26, | |
537 | MLX5E_25GBASE_CR = 27, | |
538 | MLX5E_25GBASE_KR = 28, | |
539 | MLX5E_25GBASE_SR = 29, | |
540 | MLX5E_50GBASE_CR2 = 30, | |
541 | MLX5E_50GBASE_KR2 = 31, | |
542 | MLX5E_LINK_MODES_NUMBER, | |
543 | }; | |
544 | ||
545 | #define MLX5E_PROT_MASK(link_mode) (1 << link_mode) | |
546 | ||
12be4b21 | 547 | void mlx5e_send_nop(struct mlx5e_sq *sq, bool notify_hw); |
f62b8bb8 AV |
548 | u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb, |
549 | void *accel_priv, select_queue_fallback_t fallback); | |
550 | netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev); | |
f62b8bb8 AV |
551 | |
552 | void mlx5e_completion_event(struct mlx5_core_cq *mcq); | |
553 | void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event); | |
554 | int mlx5e_napi_poll(struct napi_struct *napi, int budget); | |
555 | bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq); | |
556 | bool mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); | |
557 | bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq); | |
558 | struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq); | |
559 | ||
560 | void mlx5e_update_stats(struct mlx5e_priv *priv); | |
561 | ||
40ab6a6e AS |
562 | int mlx5e_create_flow_tables(struct mlx5e_priv *priv); |
563 | void mlx5e_destroy_flow_tables(struct mlx5e_priv *priv); | |
f62b8bb8 | 564 | void mlx5e_init_eth_addr(struct mlx5e_priv *priv); |
f62b8bb8 AV |
565 | void mlx5e_set_rx_mode_work(struct work_struct *work); |
566 | ||
567 | int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto, | |
568 | u16 vid); | |
569 | int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto, | |
570 | u16 vid); | |
571 | void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv); | |
572 | void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv); | |
f62b8bb8 AV |
573 | |
574 | int mlx5e_open_locked(struct net_device *netdev); | |
575 | int mlx5e_close_locked(struct net_device *netdev); | |
f62b8bb8 AV |
576 | |
577 | static inline void mlx5e_tx_notify_hw(struct mlx5e_sq *sq, | |
88a85f99 | 578 | struct mlx5e_tx_wqe *wqe, int bf_sz) |
f62b8bb8 | 579 | { |
88a85f99 AS |
580 | u16 ofst = MLX5_BF_OFFSET + sq->bf_offset; |
581 | ||
f62b8bb8 AV |
582 | /* ensure wqe is visible to device before updating doorbell record */ |
583 | dma_wmb(); | |
584 | ||
585 | *sq->wq.db = cpu_to_be32(sq->pc); | |
586 | ||
587 | /* ensure doorbell record is visible to device before ringing the | |
588 | * doorbell | |
589 | */ | |
590 | wmb(); | |
591 | ||
88a85f99 AS |
592 | if (bf_sz) { |
593 | __iowrite64_copy(sq->uar_bf_map + ofst, &wqe->ctrl, bf_sz); | |
594 | ||
595 | /* flush the write-combining mapped buffer */ | |
596 | wmb(); | |
597 | ||
598 | } else { | |
599 | mlx5_write64((__be32 *)&wqe->ctrl, sq->uar_map + ofst, NULL); | |
600 | } | |
f62b8bb8 AV |
601 | |
602 | sq->bf_offset ^= sq->bf_buf_size; | |
603 | } | |
604 | ||
605 | static inline void mlx5e_cq_arm(struct mlx5e_cq *cq) | |
606 | { | |
607 | struct mlx5_core_cq *mcq; | |
608 | ||
609 | mcq = &cq->mcq; | |
610 | mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, NULL, cq->wq.cc); | |
611 | } | |
612 | ||
613 | extern const struct ethtool_ops mlx5e_ethtool_ops; | |
58d52291 | 614 | u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev); |