]>
Commit | Line | Data |
---|---|---|
f62b8bb8 | 1 | /* |
1afff42c | 2 | * Copyright (c) 2015-2016, Mellanox Technologies. All rights reserved. |
f62b8bb8 AV |
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 | */ | |
1afff42c MF |
32 | #ifndef __MLX5_EN_H__ |
33 | #define __MLX5_EN_H__ | |
f62b8bb8 AV |
34 | |
35 | #include <linux/if_vlan.h> | |
36 | #include <linux/etherdevice.h> | |
ef9814de EBE |
37 | #include <linux/timecounter.h> |
38 | #include <linux/net_tstamp.h> | |
3d8c38af | 39 | #include <linux/ptp_clock_kernel.h> |
48935bbb | 40 | #include <linux/crash_dump.h> |
f62b8bb8 AV |
41 | #include <linux/mlx5/driver.h> |
42 | #include <linux/mlx5/qp.h> | |
43 | #include <linux/mlx5/cq.h> | |
ada68c31 | 44 | #include <linux/mlx5/port.h> |
d18a9470 | 45 | #include <linux/mlx5/vport.h> |
8d7f9ecb | 46 | #include <linux/mlx5/transobj.h> |
e8f887ac | 47 | #include <linux/rhashtable.h> |
cb67b832 | 48 | #include <net/switchdev.h> |
f62b8bb8 | 49 | #include "wq.h" |
f62b8bb8 | 50 | #include "mlx5_core.h" |
9218b44d | 51 | #include "en_stats.h" |
f62b8bb8 | 52 | |
1cabe6b0 MG |
53 | #define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v) |
54 | ||
d8bec2b2 MKL |
55 | #define MLX5E_HW2SW_MTU(hwmtu) ((hwmtu) - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN)) |
56 | #define MLX5E_SW2HW_MTU(swmtu) ((swmtu) + (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN)) | |
57 | ||
f62b8bb8 AV |
58 | #define MLX5E_MAX_NUM_TC 8 |
59 | ||
e842b100 | 60 | #define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE 0x6 |
f62b8bb8 AV |
61 | #define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE 0xa |
62 | #define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE 0xd | |
63 | ||
e842b100 | 64 | #define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE 0x1 |
f62b8bb8 AV |
65 | #define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE 0xa |
66 | #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE 0xd | |
67 | ||
461017cb | 68 | #define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW 0x1 |
7e426671 | 69 | #define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW 0x3 |
461017cb TT |
70 | #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW 0x6 |
71 | ||
1bfecfca SM |
72 | #define MLX5_RX_HEADROOM NET_SKB_PAD |
73 | ||
f32f5bd2 DJ |
74 | #define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev) \ |
75 | (6 + MLX5_CAP_GEN(mdev, cache_line_128byte)) /* HW restriction */ | |
76 | #define MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, req) \ | |
77 | max_t(u32, MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev), req) | |
78 | #define MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 6) | |
79 | #define MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 8) | |
80 | ||
7e426671 | 81 | #define MLX5_MPWRQ_LOG_WQE_SZ 18 |
461017cb TT |
82 | #define MLX5_MPWRQ_WQE_PAGE_ORDER (MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT > 0 ? \ |
83 | MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0) | |
84 | #define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER) | |
85 | #define MLX5_MPWRQ_STRIDES_PER_PAGE (MLX5_MPWRQ_NUM_STRIDES >> \ | |
86 | MLX5_MPWRQ_WQE_PAGE_ORDER) | |
fe4c988b SM |
87 | |
88 | #define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2) | |
ec8b9981 TT |
89 | #define MLX5E_REQUIRED_MTTS(wqes) \ |
90 | (wqes * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8)) | |
91 | #define MLX5E_VALID_NUM_MTTS(num_mtts) (MLX5_MTT_OCTW(num_mtts) - 1 <= U16_MAX) | |
fe4c988b | 92 | |
bc77b240 | 93 | #define MLX5_UMR_ALIGN (2048) |
461017cb TT |
94 | #define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128) |
95 | ||
d9a40271 | 96 | #define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024) |
2b029556 SM |
97 | #define MLX5E_DEFAULT_LRO_TIMEOUT 32 |
98 | #define MLX5E_LRO_TIMEOUT_ARR_SIZE 4 | |
99 | ||
f62b8bb8 | 100 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10 |
9908aa29 | 101 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE 0x3 |
f62b8bb8 AV |
102 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20 |
103 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC 0x10 | |
104 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS 0x20 | |
105 | #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES 0x80 | |
461017cb | 106 | #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW 0x2 |
f62b8bb8 | 107 | |
936896e9 AS |
108 | #define MLX5E_LOG_INDIR_RQT_SIZE 0x7 |
109 | #define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE) | |
b4e029da | 110 | #define MLX5E_MIN_NUM_CHANNELS 0x1 |
936896e9 | 111 | #define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1) |
507f0c81 | 112 | #define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC) |
f62b8bb8 AV |
113 | #define MLX5E_TX_CQ_POLL_BUDGET 128 |
114 | #define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */ | |
115 | ||
f10b7cc7 SM |
116 | #define MLX5E_ICOSQ_MAX_WQEBBS \ |
117 | (DIV_ROUND_UP(sizeof(struct mlx5e_umr_wqe), MLX5_SEND_WQE_BB)) | |
118 | ||
b5503b99 | 119 | #define MLX5E_XDP_MIN_INLINE (ETH_HLEN + VLAN_HLEN) |
b5503b99 | 120 | #define MLX5E_XDP_TX_DS_COUNT \ |
b70149dd | 121 | ((sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS) + 1 /* SG DS */) |
b5503b99 | 122 | |
86d722ad | 123 | #define MLX5E_NUM_MAIN_GROUPS 9 |
2f48af12 | 124 | |
461017cb TT |
125 | static inline u16 mlx5_min_rx_wqes(int wq_type, u32 wq_size) |
126 | { | |
127 | switch (wq_type) { | |
128 | case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: | |
129 | return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW, | |
130 | wq_size / 2); | |
131 | default: | |
132 | return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES, | |
133 | wq_size / 2); | |
134 | } | |
135 | } | |
136 | ||
137 | static inline int mlx5_min_log_rq_size(int wq_type) | |
138 | { | |
139 | switch (wq_type) { | |
140 | case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: | |
141 | return MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW; | |
142 | default: | |
143 | return MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE; | |
144 | } | |
145 | } | |
146 | ||
147 | static inline int mlx5_max_log_rq_size(int wq_type) | |
148 | { | |
149 | switch (wq_type) { | |
150 | case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: | |
151 | return MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW; | |
152 | default: | |
153 | return MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE; | |
154 | } | |
155 | } | |
156 | ||
48935bbb SM |
157 | static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev) |
158 | { | |
159 | return is_kdump_kernel() ? | |
160 | MLX5E_MIN_NUM_CHANNELS : | |
161 | min_t(int, mdev->priv.eq_table.num_comp_vectors, | |
162 | MLX5E_MAX_NUM_CHANNELS); | |
163 | } | |
164 | ||
2f48af12 TT |
165 | struct mlx5e_tx_wqe { |
166 | struct mlx5_wqe_ctrl_seg ctrl; | |
167 | struct mlx5_wqe_eth_seg eth; | |
168 | }; | |
169 | ||
170 | struct mlx5e_rx_wqe { | |
171 | struct mlx5_wqe_srq_next_seg next; | |
172 | struct mlx5_wqe_data_seg data; | |
173 | }; | |
86d722ad | 174 | |
bc77b240 TT |
175 | struct mlx5e_umr_wqe { |
176 | struct mlx5_wqe_ctrl_seg ctrl; | |
177 | struct mlx5_wqe_umr_ctrl_seg uctrl; | |
178 | struct mlx5_mkey_seg mkc; | |
179 | struct mlx5_wqe_data_seg data; | |
180 | }; | |
181 | ||
d605d668 KH |
182 | extern const char mlx5e_self_tests[][ETH_GSTRING_LEN]; |
183 | ||
4e59e288 | 184 | static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = { |
9908aa29 | 185 | "rx_cqe_moder", |
9bcc8606 | 186 | "rx_cqe_compress", |
4e59e288 GP |
187 | }; |
188 | ||
189 | enum mlx5e_priv_flag { | |
9908aa29 | 190 | MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0), |
9bcc8606 | 191 | MLX5E_PFLAG_RX_CQE_COMPRESS = (1 << 1), |
4e59e288 GP |
192 | }; |
193 | ||
6a9764ef | 194 | #define MLX5E_SET_PFLAG(params, pflag, enable) \ |
59ece1c9 SD |
195 | do { \ |
196 | if (enable) \ | |
6a9764ef | 197 | (params)->pflags |= (pflag); \ |
59ece1c9 | 198 | else \ |
6a9764ef | 199 | (params)->pflags &= ~(pflag); \ |
4e59e288 GP |
200 | } while (0) |
201 | ||
6a9764ef | 202 | #define MLX5E_GET_PFLAG(params, pflag) (!!((params)->pflags & (pflag))) |
59ece1c9 | 203 | |
08fb1dac SM |
204 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
205 | #define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */ | |
08fb1dac SM |
206 | #endif |
207 | ||
9908aa29 TT |
208 | struct mlx5e_cq_moder { |
209 | u16 usec; | |
210 | u16 pkts; | |
211 | }; | |
212 | ||
f62b8bb8 AV |
213 | struct mlx5e_params { |
214 | u8 log_sq_size; | |
461017cb | 215 | u8 rq_wq_type; |
d9d9f156 TT |
216 | u8 mpwqe_log_stride_sz; |
217 | u8 mpwqe_log_num_strides; | |
f62b8bb8 AV |
218 | u8 log_rq_size; |
219 | u16 num_channels; | |
f62b8bb8 | 220 | u8 num_tc; |
9908aa29 | 221 | u8 rx_cq_period_mode; |
9bcc8606 | 222 | bool rx_cqe_compress_def; |
9908aa29 TT |
223 | struct mlx5e_cq_moder rx_cq_moderation; |
224 | struct mlx5e_cq_moder tx_cq_moderation; | |
f62b8bb8 AV |
225 | bool lro_en; |
226 | u32 lro_wqe_sz; | |
58d52291 | 227 | u16 tx_max_inline; |
cff92d7c | 228 | u8 tx_min_inline_mode; |
2d75b2bc AS |
229 | u8 rss_hfunc; |
230 | u8 toeplitz_hash_key[40]; | |
231 | u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE]; | |
36350114 | 232 | bool vlan_strip_disable; |
102722fc | 233 | bool scatter_fcs_en; |
cb3c7fd4 | 234 | bool rx_am_enabled; |
2b029556 | 235 | u32 lro_timeout; |
59ece1c9 | 236 | u32 pflags; |
6a9764ef | 237 | struct bpf_prog *xdp_prog; |
f62b8bb8 AV |
238 | }; |
239 | ||
3a6a931d HN |
240 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
241 | struct mlx5e_cee_config { | |
242 | /* bw pct for priority group */ | |
243 | u8 pg_bw_pct[CEE_DCBX_MAX_PGS]; | |
244 | u8 prio_to_pg_map[CEE_DCBX_MAX_PRIO]; | |
245 | bool pfc_setting[CEE_DCBX_MAX_PRIO]; | |
246 | bool pfc_enable; | |
247 | }; | |
248 | ||
249 | enum { | |
250 | MLX5_DCB_CHG_RESET, | |
251 | MLX5_DCB_NO_CHG, | |
252 | MLX5_DCB_CHG_NO_RESET, | |
253 | }; | |
254 | ||
255 | struct mlx5e_dcbx { | |
e207b7e9 | 256 | enum mlx5_dcbx_oper_mode mode; |
3a6a931d | 257 | struct mlx5e_cee_config cee_cfg; /* pending configuration */ |
820c2c5e HN |
258 | |
259 | /* The only setting that cannot be read from FW */ | |
260 | u8 tc_tsa[IEEE_8021QAZ_MAX_TCS]; | |
3a6a931d HN |
261 | }; |
262 | #endif | |
263 | ||
ef9814de EBE |
264 | struct mlx5e_tstamp { |
265 | rwlock_t lock; | |
266 | struct cyclecounter cycles; | |
267 | struct timecounter clock; | |
268 | struct hwtstamp_config hwtstamp_config; | |
269 | u32 nominal_c_mult; | |
270 | unsigned long overflow_period; | |
271 | struct delayed_work overflow_work; | |
272 | struct mlx5_core_dev *mdev; | |
3d8c38af EBE |
273 | struct ptp_clock *ptp; |
274 | struct ptp_clock_info ptp_info; | |
ee7f1220 | 275 | u8 *pps_pin_caps; |
ef9814de EBE |
276 | }; |
277 | ||
f62b8bb8 | 278 | enum { |
c0f1147d | 279 | MLX5E_RQ_STATE_ENABLED, |
bc77b240 | 280 | MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, |
cb3c7fd4 | 281 | MLX5E_RQ_STATE_AM, |
f62b8bb8 AV |
282 | }; |
283 | ||
f62b8bb8 AV |
284 | struct mlx5e_cq { |
285 | /* data path - accessed per cqe */ | |
286 | struct mlx5_cqwq wq; | |
f62b8bb8 AV |
287 | |
288 | /* data path - accessed per napi poll */ | |
cb3c7fd4 | 289 | u16 event_ctr; |
f62b8bb8 AV |
290 | struct napi_struct *napi; |
291 | struct mlx5_core_cq mcq; | |
292 | struct mlx5e_channel *channel; | |
293 | ||
7219ab34 TT |
294 | /* cqe decompression */ |
295 | struct mlx5_cqe64 title; | |
296 | struct mlx5_mini_cqe8 mini_arr[MLX5_MINI_CQE_ARRAY_SIZE]; | |
297 | u8 mini_arr_idx; | |
298 | u16 decmprs_left; | |
299 | u16 decmprs_wqe_counter; | |
300 | ||
f62b8bb8 | 301 | /* control */ |
a43b25da | 302 | struct mlx5_core_dev *mdev; |
1c1b5228 | 303 | struct mlx5_frag_wq_ctrl wq_ctrl; |
f62b8bb8 AV |
304 | } ____cacheline_aligned_in_smp; |
305 | ||
eba2db2b SM |
306 | struct mlx5e_tx_wqe_info { |
307 | u32 num_bytes; | |
308 | u8 num_wqebbs; | |
309 | u8 num_dma; | |
310 | }; | |
311 | ||
312 | enum mlx5e_dma_map_type { | |
313 | MLX5E_DMA_MAP_SINGLE, | |
314 | MLX5E_DMA_MAP_PAGE | |
315 | }; | |
316 | ||
317 | struct mlx5e_sq_dma { | |
318 | dma_addr_t addr; | |
319 | u32 size; | |
320 | enum mlx5e_dma_map_type type; | |
321 | }; | |
322 | ||
323 | enum { | |
324 | MLX5E_SQ_STATE_ENABLED, | |
325 | }; | |
326 | ||
327 | struct mlx5e_sq_wqe_info { | |
328 | u8 opcode; | |
329 | u8 num_wqebbs; | |
330 | }; | |
2f48af12 | 331 | |
31391048 | 332 | struct mlx5e_txqsq { |
eba2db2b SM |
333 | /* data path */ |
334 | ||
335 | /* dirtied @completion */ | |
336 | u16 cc; | |
337 | u32 dma_fifo_cc; | |
338 | ||
339 | /* dirtied @xmit */ | |
340 | u16 pc ____cacheline_aligned_in_smp; | |
341 | u32 dma_fifo_pc; | |
342 | struct mlx5e_sq_stats stats; | |
343 | ||
344 | struct mlx5e_cq cq; | |
345 | ||
31391048 SM |
346 | /* write@xmit, read@completion */ |
347 | struct { | |
348 | struct sk_buff **skb; | |
349 | struct mlx5e_sq_dma *dma_fifo; | |
350 | struct mlx5e_tx_wqe_info *wqe_info; | |
eba2db2b SM |
351 | } db; |
352 | ||
353 | /* read only */ | |
354 | struct mlx5_wq_cyc wq; | |
355 | u32 dma_fifo_mask; | |
356 | void __iomem *uar_map; | |
357 | struct netdev_queue *txq; | |
358 | u32 sqn; | |
359 | u16 max_inline; | |
360 | u8 min_inline_mode; | |
361 | u16 edge; | |
362 | struct device *pdev; | |
363 | struct mlx5e_tstamp *tstamp; | |
364 | __be32 mkey_be; | |
365 | unsigned long state; | |
366 | ||
367 | /* control path */ | |
368 | struct mlx5_wq_ctrl wq_ctrl; | |
369 | struct mlx5e_channel *channel; | |
acc6c595 | 370 | int txq_ix; |
eba2db2b | 371 | u32 rate_limit; |
31391048 SM |
372 | } ____cacheline_aligned_in_smp; |
373 | ||
374 | struct mlx5e_xdpsq { | |
375 | /* data path */ | |
376 | ||
377 | /* dirtied @rx completion */ | |
378 | u16 cc; | |
379 | u16 pc; | |
380 | ||
381 | struct mlx5e_cq cq; | |
382 | ||
383 | /* write@xmit, read@completion */ | |
384 | struct { | |
385 | struct mlx5e_dma_info *di; | |
386 | bool doorbell; | |
387 | } db; | |
388 | ||
389 | /* read only */ | |
390 | struct mlx5_wq_cyc wq; | |
391 | void __iomem *uar_map; | |
392 | u32 sqn; | |
393 | struct device *pdev; | |
394 | __be32 mkey_be; | |
395 | u8 min_inline_mode; | |
396 | unsigned long state; | |
397 | ||
398 | /* control path */ | |
399 | struct mlx5_wq_ctrl wq_ctrl; | |
400 | struct mlx5e_channel *channel; | |
401 | } ____cacheline_aligned_in_smp; | |
402 | ||
403 | struct mlx5e_icosq { | |
404 | /* data path */ | |
405 | ||
406 | /* dirtied @completion */ | |
407 | u16 cc; | |
408 | ||
409 | /* dirtied @xmit */ | |
410 | u16 pc ____cacheline_aligned_in_smp; | |
411 | u32 dma_fifo_pc; | |
412 | u16 prev_cc; | |
413 | ||
414 | struct mlx5e_cq cq; | |
415 | ||
416 | /* write@xmit, read@completion */ | |
417 | struct { | |
418 | struct mlx5e_sq_wqe_info *ico_wqe; | |
419 | } db; | |
420 | ||
421 | /* read only */ | |
422 | struct mlx5_wq_cyc wq; | |
423 | void __iomem *uar_map; | |
424 | u32 sqn; | |
425 | u16 edge; | |
426 | struct device *pdev; | |
427 | __be32 mkey_be; | |
428 | unsigned long state; | |
429 | ||
430 | /* control path */ | |
431 | struct mlx5_wq_ctrl wq_ctrl; | |
432 | struct mlx5e_channel *channel; | |
eba2db2b SM |
433 | } ____cacheline_aligned_in_smp; |
434 | ||
864b2d71 SM |
435 | static inline bool |
436 | mlx5e_wqc_has_room_for(struct mlx5_wq_cyc *wq, u16 cc, u16 pc, u16 n) | |
eba2db2b | 437 | { |
864b2d71 | 438 | return (((wq->sz_m1 & (cc - pc)) >= n) || (cc == pc)); |
eba2db2b | 439 | } |
6cd392a0 | 440 | |
461017cb TT |
441 | struct mlx5e_dma_info { |
442 | struct page *page; | |
443 | dma_addr_t addr; | |
444 | }; | |
445 | ||
eba2db2b SM |
446 | struct mlx5e_umr_dma_info { |
447 | __be64 *mtt; | |
448 | dma_addr_t mtt_addr; | |
449 | struct mlx5e_dma_info dma_info[MLX5_MPWRQ_PAGES_PER_WQE]; | |
450 | struct mlx5e_umr_wqe wqe; | |
451 | }; | |
452 | ||
453 | struct mlx5e_mpw_info { | |
454 | struct mlx5e_umr_dma_info umr; | |
455 | u16 consumed_strides; | |
456 | u16 skbs_frags[MLX5_MPWRQ_PAGES_PER_WQE]; | |
457 | }; | |
458 | ||
cb3c7fd4 GR |
459 | struct mlx5e_rx_am_stats { |
460 | int ppms; /* packets per msec */ | |
461 | int epms; /* events per msec */ | |
462 | }; | |
463 | ||
464 | struct mlx5e_rx_am_sample { | |
465 | ktime_t time; | |
466 | unsigned int pkt_ctr; | |
467 | u16 event_ctr; | |
468 | }; | |
469 | ||
470 | struct mlx5e_rx_am { /* Adaptive Moderation */ | |
471 | u8 state; | |
472 | struct mlx5e_rx_am_stats prev_stats; | |
473 | struct mlx5e_rx_am_sample start_sample; | |
474 | struct work_struct work; | |
475 | u8 profile_ix; | |
476 | u8 mode; | |
477 | u8 tune_state; | |
478 | u8 steps_right; | |
479 | u8 steps_left; | |
480 | u8 tired; | |
481 | }; | |
482 | ||
4415a031 TT |
483 | /* a single cache unit is capable to serve one napi call (for non-striding rq) |
484 | * or a MPWQE (for striding rq). | |
485 | */ | |
486 | #define MLX5E_CACHE_UNIT (MLX5_MPWRQ_PAGES_PER_WQE > NAPI_POLL_WEIGHT ? \ | |
487 | MLX5_MPWRQ_PAGES_PER_WQE : NAPI_POLL_WEIGHT) | |
488 | #define MLX5E_CACHE_SIZE (2 * roundup_pow_of_two(MLX5E_CACHE_UNIT)) | |
489 | struct mlx5e_page_cache { | |
490 | u32 head; | |
491 | u32 tail; | |
492 | struct mlx5e_dma_info page_cache[MLX5E_CACHE_SIZE]; | |
493 | }; | |
494 | ||
eba2db2b SM |
495 | struct mlx5e_rq; |
496 | typedef void (*mlx5e_fp_handle_rx_cqe)(struct mlx5e_rq*, struct mlx5_cqe64*); | |
497 | typedef int (*mlx5e_fp_alloc_wqe)(struct mlx5e_rq*, struct mlx5e_rx_wqe*, u16); | |
498 | typedef void (*mlx5e_fp_dealloc_wqe)(struct mlx5e_rq*, u16); | |
499 | ||
f62b8bb8 AV |
500 | struct mlx5e_rq { |
501 | /* data path */ | |
502 | struct mlx5_wq_ll wq; | |
1bfecfca | 503 | |
21c59685 SM |
504 | union { |
505 | struct mlx5e_dma_info *dma_info; | |
506 | struct { | |
507 | struct mlx5e_mpw_info *info; | |
508 | void *mtt_no_align; | |
21c59685 SM |
509 | } mpwqe; |
510 | }; | |
1bfecfca SM |
511 | struct { |
512 | u8 page_order; | |
513 | u32 wqe_sz; /* wqe data buffer size */ | |
b5503b99 | 514 | u8 map_dir; /* dma map direction */ |
1bfecfca | 515 | } buff; |
bc77b240 | 516 | __be32 mkey_be; |
f62b8bb8 AV |
517 | |
518 | struct device *pdev; | |
519 | struct net_device *netdev; | |
ef9814de | 520 | struct mlx5e_tstamp *tstamp; |
f62b8bb8 AV |
521 | struct mlx5e_rq_stats stats; |
522 | struct mlx5e_cq cq; | |
4415a031 TT |
523 | struct mlx5e_page_cache page_cache; |
524 | ||
2f48af12 TT |
525 | mlx5e_fp_handle_rx_cqe handle_rx_cqe; |
526 | mlx5e_fp_alloc_wqe alloc_wqe; | |
6cd392a0 | 527 | mlx5e_fp_dealloc_wqe dealloc_wqe; |
f62b8bb8 AV |
528 | |
529 | unsigned long state; | |
530 | int ix; | |
d8bec2b2 | 531 | u16 rx_headroom; |
f62b8bb8 | 532 | |
cb3c7fd4 | 533 | struct mlx5e_rx_am am; /* Adaptive Moderation */ |
31871f87 SM |
534 | |
535 | /* XDP */ | |
86994156 | 536 | struct bpf_prog *xdp_prog; |
31391048 | 537 | struct mlx5e_xdpsq xdpsq; |
cb3c7fd4 | 538 | |
f62b8bb8 AV |
539 | /* control */ |
540 | struct mlx5_wq_ctrl wq_ctrl; | |
461017cb | 541 | u8 wq_type; |
d9d9f156 TT |
542 | u32 mpwqe_stride_sz; |
543 | u32 mpwqe_num_strides; | |
f62b8bb8 AV |
544 | u32 rqn; |
545 | struct mlx5e_channel *channel; | |
a43b25da | 546 | struct mlx5_core_dev *mdev; |
ec8b9981 | 547 | struct mlx5_core_mkey umr_mkey; |
f62b8bb8 AV |
548 | } ____cacheline_aligned_in_smp; |
549 | ||
f62b8bb8 AV |
550 | enum channel_flags { |
551 | MLX5E_CHANNEL_NAPI_SCHED = 1, | |
552 | }; | |
553 | ||
554 | struct mlx5e_channel { | |
555 | /* data path */ | |
556 | struct mlx5e_rq rq; | |
31391048 SM |
557 | struct mlx5e_txqsq sq[MLX5E_MAX_NUM_TC]; |
558 | struct mlx5e_icosq icosq; /* internal control operations */ | |
b5503b99 | 559 | bool xdp; |
f62b8bb8 AV |
560 | struct napi_struct napi; |
561 | struct device *pdev; | |
562 | struct net_device *netdev; | |
563 | __be32 mkey_be; | |
564 | u8 num_tc; | |
565 | unsigned long flags; | |
566 | ||
567 | /* control */ | |
568 | struct mlx5e_priv *priv; | |
a43b25da SM |
569 | struct mlx5_core_dev *mdev; |
570 | struct mlx5e_tstamp *tstamp; | |
f62b8bb8 AV |
571 | int ix; |
572 | int cpu; | |
573 | }; | |
574 | ||
ff9c852f SM |
575 | struct mlx5e_channels { |
576 | struct mlx5e_channel **c; | |
577 | unsigned int num; | |
6a9764ef | 578 | struct mlx5e_params params; |
ff9c852f SM |
579 | }; |
580 | ||
f62b8bb8 | 581 | enum mlx5e_traffic_types { |
5a6f8aef AS |
582 | MLX5E_TT_IPV4_TCP, |
583 | MLX5E_TT_IPV6_TCP, | |
584 | MLX5E_TT_IPV4_UDP, | |
585 | MLX5E_TT_IPV6_UDP, | |
a741749f AS |
586 | MLX5E_TT_IPV4_IPSEC_AH, |
587 | MLX5E_TT_IPV6_IPSEC_AH, | |
588 | MLX5E_TT_IPV4_IPSEC_ESP, | |
589 | MLX5E_TT_IPV6_IPSEC_ESP, | |
5a6f8aef AS |
590 | MLX5E_TT_IPV4, |
591 | MLX5E_TT_IPV6, | |
592 | MLX5E_TT_ANY, | |
593 | MLX5E_NUM_TT, | |
1da36696 | 594 | MLX5E_NUM_INDIR_TIRS = MLX5E_TT_ANY, |
f62b8bb8 AV |
595 | }; |
596 | ||
acff797c | 597 | enum { |
e0f46eb9 | 598 | MLX5E_STATE_ASYNC_EVENTS_ENABLED, |
acff797c MG |
599 | MLX5E_STATE_OPENED, |
600 | MLX5E_STATE_DESTROYING, | |
601 | }; | |
602 | ||
603 | struct mlx5e_vxlan_db { | |
604 | spinlock_t lock; /* protect vxlan table */ | |
605 | struct radix_tree_root tree; | |
606 | }; | |
607 | ||
33cfaaa8 | 608 | struct mlx5e_l2_rule { |
f62b8bb8 | 609 | u8 addr[ETH_ALEN + 2]; |
74491de9 | 610 | struct mlx5_flow_handle *rule; |
f62b8bb8 AV |
611 | }; |
612 | ||
acff797c MG |
613 | struct mlx5e_flow_table { |
614 | int num_groups; | |
615 | struct mlx5_flow_table *t; | |
616 | struct mlx5_flow_group **g; | |
617 | }; | |
618 | ||
33cfaaa8 | 619 | #define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE) |
f62b8bb8 | 620 | |
acff797c MG |
621 | struct mlx5e_tc_table { |
622 | struct mlx5_flow_table *t; | |
623 | ||
624 | struct rhashtable_params ht_params; | |
625 | struct rhashtable ht; | |
f62b8bb8 AV |
626 | }; |
627 | ||
acff797c MG |
628 | struct mlx5e_vlan_table { |
629 | struct mlx5e_flow_table ft; | |
aad9e6e4 | 630 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
74491de9 MB |
631 | struct mlx5_flow_handle *active_vlans_rule[VLAN_N_VID]; |
632 | struct mlx5_flow_handle *untagged_rule; | |
8a271746 MHY |
633 | struct mlx5_flow_handle *any_cvlan_rule; |
634 | struct mlx5_flow_handle *any_svlan_rule; | |
635 | bool filter_disabled; | |
f62b8bb8 AV |
636 | }; |
637 | ||
33cfaaa8 MG |
638 | struct mlx5e_l2_table { |
639 | struct mlx5e_flow_table ft; | |
640 | struct hlist_head netdev_uc[MLX5E_L2_ADDR_HASH_SIZE]; | |
641 | struct hlist_head netdev_mc[MLX5E_L2_ADDR_HASH_SIZE]; | |
642 | struct mlx5e_l2_rule broadcast; | |
643 | struct mlx5e_l2_rule allmulti; | |
644 | struct mlx5e_l2_rule promisc; | |
645 | bool broadcast_enabled; | |
646 | bool allmulti_enabled; | |
647 | bool promisc_enabled; | |
648 | }; | |
649 | ||
650 | /* L3/L4 traffic type classifier */ | |
651 | struct mlx5e_ttc_table { | |
652 | struct mlx5e_flow_table ft; | |
74491de9 | 653 | struct mlx5_flow_handle *rules[MLX5E_NUM_TT]; |
33cfaaa8 MG |
654 | }; |
655 | ||
18c908e4 MG |
656 | #define ARFS_HASH_SHIFT BITS_PER_BYTE |
657 | #define ARFS_HASH_SIZE BIT(BITS_PER_BYTE) | |
1cabe6b0 MG |
658 | struct arfs_table { |
659 | struct mlx5e_flow_table ft; | |
74491de9 | 660 | struct mlx5_flow_handle *default_rule; |
18c908e4 | 661 | struct hlist_head rules_hash[ARFS_HASH_SIZE]; |
1cabe6b0 MG |
662 | }; |
663 | ||
664 | enum arfs_type { | |
665 | ARFS_IPV4_TCP, | |
666 | ARFS_IPV6_TCP, | |
667 | ARFS_IPV4_UDP, | |
668 | ARFS_IPV6_UDP, | |
669 | ARFS_NUM_TYPES, | |
670 | }; | |
671 | ||
672 | struct mlx5e_arfs_tables { | |
673 | struct arfs_table arfs_tables[ARFS_NUM_TYPES]; | |
18c908e4 MG |
674 | /* Protect aRFS rules list */ |
675 | spinlock_t arfs_lock; | |
676 | struct list_head rules; | |
677 | int last_filter_id; | |
678 | struct workqueue_struct *wq; | |
1cabe6b0 MG |
679 | }; |
680 | ||
681 | /* NIC prio FTS */ | |
682 | enum { | |
683 | MLX5E_VLAN_FT_LEVEL = 0, | |
684 | MLX5E_L2_FT_LEVEL, | |
685 | MLX5E_TTC_FT_LEVEL, | |
686 | MLX5E_ARFS_FT_LEVEL | |
687 | }; | |
688 | ||
6dc6071c MG |
689 | struct mlx5e_ethtool_table { |
690 | struct mlx5_flow_table *ft; | |
691 | int num_rules; | |
692 | }; | |
693 | ||
1174fce8 | 694 | #define ETHTOOL_NUM_L3_L4_FTS 7 |
6dc6071c MG |
695 | #define ETHTOOL_NUM_L2_FTS 4 |
696 | ||
697 | struct mlx5e_ethtool_steering { | |
1174fce8 | 698 | struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS]; |
6dc6071c MG |
699 | struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS]; |
700 | struct list_head rules; | |
701 | int tot_num_rules; | |
702 | }; | |
703 | ||
acff797c MG |
704 | struct mlx5e_flow_steering { |
705 | struct mlx5_flow_namespace *ns; | |
6dc6071c | 706 | struct mlx5e_ethtool_steering ethtool; |
acff797c MG |
707 | struct mlx5e_tc_table tc; |
708 | struct mlx5e_vlan_table vlan; | |
33cfaaa8 MG |
709 | struct mlx5e_l2_table l2; |
710 | struct mlx5e_ttc_table ttc; | |
1cabe6b0 | 711 | struct mlx5e_arfs_tables arfs; |
f62b8bb8 AV |
712 | }; |
713 | ||
398f3351 | 714 | struct mlx5e_rqt { |
1da36696 | 715 | u32 rqtn; |
398f3351 HHZ |
716 | bool enabled; |
717 | }; | |
718 | ||
719 | struct mlx5e_tir { | |
720 | u32 tirn; | |
721 | struct mlx5e_rqt rqt; | |
722 | struct list_head list; | |
1da36696 TT |
723 | }; |
724 | ||
acff797c MG |
725 | enum { |
726 | MLX5E_TC_PRIO = 0, | |
727 | MLX5E_NIC_PRIO | |
728 | }; | |
729 | ||
f62b8bb8 AV |
730 | struct mlx5e_priv { |
731 | /* priv data path fields - start */ | |
acc6c595 SM |
732 | struct mlx5e_txqsq *txq2sq[MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC]; |
733 | int channel_tc2txq[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC]; | |
f62b8bb8 AV |
734 | /* priv data path fields - end */ |
735 | ||
736 | unsigned long state; | |
737 | struct mutex state_lock; /* Protects Interface state */ | |
50cfa25a | 738 | struct mlx5e_rq drop_rq; |
f62b8bb8 | 739 | |
ff9c852f | 740 | struct mlx5e_channels channels; |
f62b8bb8 | 741 | u32 tisn[MLX5E_MAX_NUM_TC]; |
398f3351 | 742 | struct mlx5e_rqt indir_rqt; |
724b2aa1 HHZ |
743 | struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS]; |
744 | struct mlx5e_tir direct_tir[MLX5E_MAX_NUM_CHANNELS]; | |
507f0c81 | 745 | u32 tx_rates[MLX5E_MAX_NUM_SQS]; |
f62b8bb8 | 746 | |
acff797c | 747 | struct mlx5e_flow_steering fs; |
b3f63c3d | 748 | struct mlx5e_vxlan_db vxlan; |
f62b8bb8 | 749 | |
7bb29755 | 750 | struct workqueue_struct *wq; |
f62b8bb8 AV |
751 | struct work_struct update_carrier_work; |
752 | struct work_struct set_rx_mode_work; | |
3947ca18 | 753 | struct work_struct tx_timeout_work; |
f62b8bb8 AV |
754 | struct delayed_work update_stats_work; |
755 | ||
756 | struct mlx5_core_dev *mdev; | |
757 | struct net_device *netdev; | |
758 | struct mlx5e_stats stats; | |
ef9814de | 759 | struct mlx5e_tstamp tstamp; |
593cf338 | 760 | u16 q_counter; |
3a6a931d HN |
761 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
762 | struct mlx5e_dcbx dcbx; | |
763 | #endif | |
764 | ||
6bfd390b | 765 | const struct mlx5e_profile *profile; |
127ea380 | 766 | void *ppriv; |
f62b8bb8 AV |
767 | }; |
768 | ||
a43b25da SM |
769 | struct mlx5e_profile { |
770 | void (*init)(struct mlx5_core_dev *mdev, | |
771 | struct net_device *netdev, | |
772 | const struct mlx5e_profile *profile, void *ppriv); | |
773 | void (*cleanup)(struct mlx5e_priv *priv); | |
774 | int (*init_rx)(struct mlx5e_priv *priv); | |
775 | void (*cleanup_rx)(struct mlx5e_priv *priv); | |
776 | int (*init_tx)(struct mlx5e_priv *priv); | |
777 | void (*cleanup_tx)(struct mlx5e_priv *priv); | |
778 | void (*enable)(struct mlx5e_priv *priv); | |
779 | void (*disable)(struct mlx5e_priv *priv); | |
780 | void (*update_stats)(struct mlx5e_priv *priv); | |
781 | int (*max_nch)(struct mlx5_core_dev *mdev); | |
782 | int max_tc; | |
783 | }; | |
784 | ||
665bc539 GP |
785 | void mlx5e_build_ptys2ethtool_map(void); |
786 | ||
f62b8bb8 AV |
787 | u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb, |
788 | void *accel_priv, select_queue_fallback_t fallback); | |
789 | netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev); | |
f62b8bb8 AV |
790 | |
791 | void mlx5e_completion_event(struct mlx5_core_cq *mcq); | |
792 | void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event); | |
793 | int mlx5e_napi_poll(struct napi_struct *napi, int budget); | |
8ec736e5 | 794 | bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget); |
44fb6fbb | 795 | int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); |
1c4bf940 | 796 | bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq); |
31391048 SM |
797 | void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq); |
798 | void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq); | |
461017cb | 799 | |
4415a031 TT |
800 | void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info, |
801 | bool recycle); | |
2f48af12 | 802 | void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); |
461017cb | 803 | void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); |
f62b8bb8 | 804 | bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq); |
2f48af12 | 805 | int mlx5e_alloc_rx_wqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix); |
7e426671 | 806 | int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix); |
6cd392a0 DJ |
807 | void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix); |
808 | void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix); | |
7e426671 TT |
809 | void mlx5e_post_rx_mpwqe(struct mlx5e_rq *rq); |
810 | void mlx5e_free_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi); | |
f62b8bb8 AV |
811 | struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq); |
812 | ||
cb3c7fd4 GR |
813 | void mlx5e_rx_am(struct mlx5e_rq *rq); |
814 | void mlx5e_rx_am_work(struct work_struct *work); | |
815 | struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode); | |
816 | ||
f62b8bb8 AV |
817 | void mlx5e_update_stats(struct mlx5e_priv *priv); |
818 | ||
acff797c MG |
819 | int mlx5e_create_flow_steering(struct mlx5e_priv *priv); |
820 | void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv); | |
33cfaaa8 | 821 | void mlx5e_init_l2_addr(struct mlx5e_priv *priv); |
1cabe6b0 | 822 | void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft); |
d605d668 KH |
823 | int mlx5e_self_test_num(struct mlx5e_priv *priv); |
824 | void mlx5e_self_test(struct net_device *ndev, struct ethtool_test *etest, | |
825 | u64 *buf); | |
f913a72a MG |
826 | int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info, |
827 | int location); | |
828 | int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv, | |
829 | struct ethtool_rxnfc *info, u32 *rule_locs); | |
6dc6071c MG |
830 | int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv, |
831 | struct ethtool_rx_flow_spec *fs); | |
832 | int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv, | |
833 | int location); | |
834 | void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv); | |
835 | void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv); | |
f62b8bb8 AV |
836 | void mlx5e_set_rx_mode_work(struct work_struct *work); |
837 | ||
ef9814de EBE |
838 | void mlx5e_fill_hwstamp(struct mlx5e_tstamp *clock, u64 timestamp, |
839 | struct skb_shared_hwtstamps *hwts); | |
840 | void mlx5e_timestamp_init(struct mlx5e_priv *priv); | |
841 | void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv); | |
ee7f1220 EE |
842 | void mlx5e_pps_event_handler(struct mlx5e_priv *priv, |
843 | struct ptp_clock_event *event); | |
ef9814de EBE |
844 | int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr); |
845 | int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr); | |
be7e87f9 | 846 | int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val); |
ef9814de | 847 | |
f62b8bb8 AV |
848 | int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto, |
849 | u16 vid); | |
850 | int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto, | |
851 | u16 vid); | |
852 | void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv); | |
853 | void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv); | |
f62b8bb8 | 854 | |
a5f97fee SM |
855 | struct mlx5e_redirect_rqt_param { |
856 | bool is_rss; | |
857 | union { | |
858 | u32 rqn; /* Direct RQN (Non-RSS) */ | |
859 | struct { | |
860 | u8 hfunc; | |
861 | struct mlx5e_channels *channels; | |
862 | } rss; /* RSS data */ | |
863 | }; | |
864 | }; | |
865 | ||
866 | int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz, | |
867 | struct mlx5e_redirect_rqt_param rrp); | |
6a9764ef SM |
868 | void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_params *params, |
869 | enum mlx5e_traffic_types tt, | |
870 | void *tirc); | |
2d75b2bc | 871 | |
f62b8bb8 AV |
872 | int mlx5e_open_locked(struct net_device *netdev); |
873 | int mlx5e_close_locked(struct net_device *netdev); | |
55c2503d SM |
874 | |
875 | int mlx5e_open_channels(struct mlx5e_priv *priv, | |
876 | struct mlx5e_channels *chs); | |
877 | void mlx5e_close_channels(struct mlx5e_channels *chs); | |
2e20a151 SM |
878 | |
879 | /* Function pointer to be used to modify WH settings while | |
880 | * switching channels | |
881 | */ | |
882 | typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv); | |
55c2503d | 883 | void mlx5e_switch_priv_channels(struct mlx5e_priv *priv, |
2e20a151 SM |
884 | struct mlx5e_channels *new_chs, |
885 | mlx5e_fp_hw_modify hw_modify); | |
55c2503d | 886 | |
d8c9660d TT |
887 | void mlx5e_build_default_indir_rqt(struct mlx5_core_dev *mdev, |
888 | u32 *indirection_rqt, int len, | |
85082dba | 889 | int num_channels); |
b797a684 | 890 | int mlx5e_get_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed); |
f62b8bb8 | 891 | |
9908aa29 TT |
892 | void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, |
893 | u8 cq_period_mode); | |
6a9764ef SM |
894 | void mlx5e_set_rq_type_params(struct mlx5_core_dev *mdev, |
895 | struct mlx5e_params *params, u8 rq_type); | |
9908aa29 | 896 | |
864b2d71 SM |
897 | static inline |
898 | struct mlx5e_tx_wqe *mlx5e_post_nop(struct mlx5_wq_cyc *wq, u32 sqn, u16 *pc) | |
f62b8bb8 | 899 | { |
864b2d71 SM |
900 | u16 pi = *pc & wq->sz_m1; |
901 | struct mlx5e_tx_wqe *wqe = mlx5_wq_cyc_get_wqe(wq, pi); | |
902 | struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl; | |
903 | ||
904 | memset(cseg, 0, sizeof(*cseg)); | |
905 | ||
906 | cseg->opmod_idx_opcode = cpu_to_be32((*pc << 8) | MLX5_OPCODE_NOP); | |
907 | cseg->qpn_ds = cpu_to_be32((sqn << 8) | 0x01); | |
908 | ||
909 | (*pc)++; | |
910 | ||
911 | return wqe; | |
912 | } | |
913 | ||
914 | static inline | |
915 | void mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, | |
916 | void __iomem *uar_map, | |
917 | struct mlx5_wqe_ctrl_seg *ctrl) | |
918 | { | |
919 | ctrl->fm_ce_se = MLX5_WQE_CTRL_CQ_UPDATE; | |
f62b8bb8 AV |
920 | /* ensure wqe is visible to device before updating doorbell record */ |
921 | dma_wmb(); | |
922 | ||
864b2d71 | 923 | *wq->db = cpu_to_be32(pc); |
f62b8bb8 AV |
924 | |
925 | /* ensure doorbell record is visible to device before ringing the | |
926 | * doorbell | |
927 | */ | |
928 | wmb(); | |
f62b8bb8 | 929 | |
864b2d71 | 930 | mlx5_write64((__be32 *)ctrl, uar_map, NULL); |
f62b8bb8 AV |
931 | } |
932 | ||
933 | static inline void mlx5e_cq_arm(struct mlx5e_cq *cq) | |
934 | { | |
935 | struct mlx5_core_cq *mcq; | |
936 | ||
937 | mcq = &cq->mcq; | |
5fe9dec0 | 938 | mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, cq->wq.cc); |
f62b8bb8 AV |
939 | } |
940 | ||
7e426671 TT |
941 | static inline u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix) |
942 | { | |
ec8b9981 | 943 | return wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8); |
7e426671 TT |
944 | } |
945 | ||
f62b8bb8 | 946 | extern const struct ethtool_ops mlx5e_ethtool_ops; |
08fb1dac SM |
947 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
948 | extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops; | |
949 | int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets); | |
e207b7e9 | 950 | void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv); |
08fb1dac SM |
951 | #endif |
952 | ||
1cabe6b0 MG |
953 | #ifndef CONFIG_RFS_ACCEL |
954 | static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv) | |
955 | { | |
956 | return 0; | |
957 | } | |
958 | ||
959 | static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {} | |
45bf454a MG |
960 | |
961 | static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) | |
962 | { | |
9eb78923 | 963 | return -EOPNOTSUPP; |
45bf454a MG |
964 | } |
965 | ||
966 | static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) | |
967 | { | |
9eb78923 | 968 | return -EOPNOTSUPP; |
45bf454a | 969 | } |
1cabe6b0 MG |
970 | #else |
971 | int mlx5e_arfs_create_tables(struct mlx5e_priv *priv); | |
972 | void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv); | |
45bf454a MG |
973 | int mlx5e_arfs_enable(struct mlx5e_priv *priv); |
974 | int mlx5e_arfs_disable(struct mlx5e_priv *priv); | |
18c908e4 MG |
975 | int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, |
976 | u16 rxq_index, u32 flow_id); | |
1cabe6b0 MG |
977 | #endif |
978 | ||
58d52291 | 979 | u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev); |
724b2aa1 HHZ |
980 | int mlx5e_create_tir(struct mlx5_core_dev *mdev, |
981 | struct mlx5e_tir *tir, u32 *in, int inlen); | |
982 | void mlx5e_destroy_tir(struct mlx5_core_dev *mdev, | |
983 | struct mlx5e_tir *tir); | |
b50d292b HHZ |
984 | int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev); |
985 | void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev); | |
b676f653 | 986 | int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb); |
1afff42c | 987 | |
cb67b832 HHZ |
988 | struct mlx5_eswitch_rep; |
989 | int mlx5e_vport_rep_load(struct mlx5_eswitch *esw, | |
990 | struct mlx5_eswitch_rep *rep); | |
991 | void mlx5e_vport_rep_unload(struct mlx5_eswitch *esw, | |
992 | struct mlx5_eswitch_rep *rep); | |
993 | int mlx5e_nic_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep); | |
994 | void mlx5e_nic_rep_unload(struct mlx5_eswitch *esw, | |
995 | struct mlx5_eswitch_rep *rep); | |
996 | int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv); | |
997 | void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv); | |
998 | int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr); | |
f5f82476 | 999 | void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); |
370bad0f | 1000 | void mlx5e_update_hw_rep_counters(struct mlx5e_priv *priv); |
cb67b832 | 1001 | |
bc81b9d3 | 1002 | /* common netdev helpers */ |
8f493ffd SM |
1003 | int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv); |
1004 | ||
1005 | int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv); | |
1006 | void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv); | |
1007 | ||
cb67b832 | 1008 | int mlx5e_create_direct_rqts(struct mlx5e_priv *priv); |
8f493ffd | 1009 | void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv); |
cb67b832 HHZ |
1010 | int mlx5e_create_direct_tirs(struct mlx5e_priv *priv); |
1011 | void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv); | |
8f493ffd SM |
1012 | void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt); |
1013 | ||
bc81b9d3 SM |
1014 | int mlx5e_create_ttc_table(struct mlx5e_priv *priv, u32 underlay_qpn); |
1015 | void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv); | |
1016 | ||
5426a0b2 SM |
1017 | int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc, |
1018 | u32 underlay_qpn, u32 *tisn); | |
1019 | void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn); | |
1020 | ||
cb67b832 HHZ |
1021 | int mlx5e_create_tises(struct mlx5e_priv *priv); |
1022 | void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv); | |
1023 | int mlx5e_close(struct net_device *netdev); | |
1024 | int mlx5e_open(struct net_device *netdev); | |
1025 | void mlx5e_update_stats_work(struct work_struct *work); | |
2b029556 | 1026 | u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout); |
cb67b832 | 1027 | |
370bad0f OG |
1028 | int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev, |
1029 | void *sp); | |
1030 | bool mlx5e_has_offload_stats(const struct net_device *dev, int attr_id); | |
1031 | ||
1032 | bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv); | |
1033 | bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv); | |
2c3b5bee SM |
1034 | |
1035 | /* mlx5e generic netdev management API */ | |
1036 | struct net_device* | |
1037 | mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile, | |
1038 | void *ppriv); | |
1039 | int mlx5e_attach_netdev(struct mlx5e_priv *priv); | |
1040 | void mlx5e_detach_netdev(struct mlx5e_priv *priv); | |
1041 | void mlx5e_destroy_netdev(struct mlx5e_priv *priv); | |
8f493ffd SM |
1042 | void mlx5e_build_nic_params(struct mlx5_core_dev *mdev, |
1043 | struct mlx5e_params *params, | |
1044 | u16 max_channels); | |
2c3b5bee | 1045 | |
1afff42c | 1046 | #endif /* __MLX5_EN_H__ */ |