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