]>
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> |
1ae1df3a | 47 | #include <linux/mlx5/fs.h> |
e8f887ac | 48 | #include <linux/rhashtable.h> |
cb67b832 | 49 | #include <net/switchdev.h> |
0ddf5432 | 50 | #include <net/xdp.h> |
4c4dbb4a | 51 | #include <linux/net_dim.h> |
f62b8bb8 | 52 | #include "wq.h" |
f62b8bb8 | 53 | #include "mlx5_core.h" |
9218b44d | 54 | #include "en_stats.h" |
f62b8bb8 | 55 | |
60bbf7ee JDB |
56 | struct page_pool; |
57 | ||
bb909416 IL |
58 | #define MLX5E_METADATA_ETHER_TYPE (0x8CE4) |
59 | #define MLX5E_METADATA_ETHER_LEN 8 | |
60 | ||
1cabe6b0 MG |
61 | #define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v) |
62 | ||
c139dbfd ES |
63 | #define MLX5E_ETH_HARD_MTU (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN) |
64 | ||
472a1e44 TT |
65 | #define MLX5E_HW2SW_MTU(params, hwmtu) ((hwmtu) - ((params)->hard_mtu)) |
66 | #define MLX5E_SW2HW_MTU(params, swmtu) ((swmtu) + ((params)->hard_mtu)) | |
d8bec2b2 | 67 | |
0696d608 | 68 | #define MLX5E_MAX_PRIORITY 8 |
2a5e7a13 | 69 | #define MLX5E_MAX_DSCP 64 |
f62b8bb8 AV |
70 | #define MLX5E_MAX_NUM_TC 8 |
71 | ||
1bfecfca | 72 | #define MLX5_RX_HEADROOM NET_SKB_PAD |
78aedd32 TT |
73 | #define MLX5_SKB_FRAG_SZ(len) (SKB_DATA_ALIGN(len) + \ |
74 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) | |
1bfecfca | 75 | |
f32f5bd2 DJ |
76 | #define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev) \ |
77 | (6 + MLX5_CAP_GEN(mdev, cache_line_128byte)) /* HW restriction */ | |
78 | #define MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, req) \ | |
79 | max_t(u32, MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev), req) | |
80 | #define MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 6) | |
81 | #define MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 8) | |
696a97cf EE |
82 | #define MLX5E_MPWQE_STRIDE_SZ(mdev, cqe_cmprs) \ |
83 | (cqe_cmprs ? MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(mdev) : \ | |
84 | MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev)) | |
f32f5bd2 | 85 | |
7e426671 | 86 | #define MLX5_MPWRQ_LOG_WQE_SZ 18 |
461017cb TT |
87 | #define MLX5_MPWRQ_WQE_PAGE_ORDER (MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT > 0 ? \ |
88 | MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0) | |
89 | #define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER) | |
fe4c988b SM |
90 | |
91 | #define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2) | |
73281b78 | 92 | #define MLX5E_REQUIRED_WQE_MTTS (ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8)) |
b8a98a4c | 93 | #define MLX5E_LOG_ALIGNED_MPWQE_PPW (ilog2(MLX5E_REQUIRED_WQE_MTTS)) |
73281b78 TT |
94 | #define MLX5E_REQUIRED_MTTS(wqes) (wqes * MLX5E_REQUIRED_WQE_MTTS) |
95 | #define MLX5E_MAX_RQ_NUM_MTTS \ | |
96 | ((1 << 16) * 2) /* So that MLX5_MTT_OCTW(num_mtts) fits into u16 */ | |
97 | #define MLX5E_ORDER2_MAX_PACKET_MTU (order_base_2(10 * 1024)) | |
98 | #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW \ | |
99 | (ilog2(MLX5E_MAX_RQ_NUM_MTTS / MLX5E_REQUIRED_WQE_MTTS)) | |
100 | #define MLX5E_LOG_MAX_RQ_NUM_PACKETS_MPW \ | |
101 | (MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW + \ | |
102 | (MLX5_MPWRQ_LOG_WQE_SZ - MLX5E_ORDER2_MAX_PACKET_MTU)) | |
103 | ||
104 | #define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE 0x6 | |
105 | #define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE 0xa | |
106 | #define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE 0xd | |
107 | ||
108 | #define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE 0x1 | |
109 | #define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE 0xa | |
110 | #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE min_t(u8, 0xd, \ | |
111 | MLX5E_LOG_MAX_RQ_NUM_PACKETS_MPW) | |
112 | ||
113 | #define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW 0x2 | |
fe4c988b | 114 | |
cbad8cdd | 115 | #define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (256) |
461017cb | 116 | |
d9a40271 | 117 | #define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024) |
2b029556 SM |
118 | #define MLX5E_DEFAULT_LRO_TIMEOUT 32 |
119 | #define MLX5E_LRO_TIMEOUT_ARR_SIZE 4 | |
120 | ||
f62b8bb8 | 121 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10 |
9908aa29 | 122 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE 0x3 |
f62b8bb8 AV |
123 | #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20 |
124 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC 0x10 | |
0088cbbc | 125 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC_FROM_CQE 0x10 |
f62b8bb8 AV |
126 | #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS 0x20 |
127 | #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES 0x80 | |
461017cb | 128 | #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW 0x2 |
f62b8bb8 | 129 | |
936896e9 AS |
130 | #define MLX5E_LOG_INDIR_RQT_SIZE 0x7 |
131 | #define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE) | |
b4e029da | 132 | #define MLX5E_MIN_NUM_CHANNELS 0x1 |
936896e9 | 133 | #define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1) |
507f0c81 | 134 | #define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC) |
f62b8bb8 AV |
135 | #define MLX5E_TX_CQ_POLL_BUDGET 128 |
136 | #define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */ | |
db75373c | 137 | #define MLX5E_SQ_RECOVER_MIN_INTERVAL 500 /* msecs */ |
f62b8bb8 | 138 | |
ea3886ca TT |
139 | #define MLX5E_UMR_WQE_INLINE_SZ \ |
140 | (sizeof(struct mlx5e_umr_wqe) + \ | |
141 | ALIGN(MLX5_MPWRQ_PAGES_PER_WQE * sizeof(struct mlx5_mtt), \ | |
142 | MLX5_UMR_MTT_ALIGNMENT)) | |
143 | #define MLX5E_UMR_WQEBBS \ | |
144 | (DIV_ROUND_UP(MLX5E_UMR_WQE_INLINE_SZ, MLX5_SEND_WQE_BB)) | |
145 | #define MLX5E_ICOSQ_MAX_WQEBBS MLX5E_UMR_WQEBBS | |
f10b7cc7 | 146 | |
b5503b99 | 147 | #define MLX5E_XDP_MIN_INLINE (ETH_HLEN + VLAN_HLEN) |
b5503b99 | 148 | #define MLX5E_XDP_TX_DS_COUNT \ |
b70149dd | 149 | ((sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS) + 1 /* SG DS */) |
b5503b99 | 150 | |
86d722ad | 151 | #define MLX5E_NUM_MAIN_GROUPS 9 |
2f48af12 | 152 | |
79c48764 GP |
153 | #define MLX5E_MSG_LEVEL NETIF_MSG_LINK |
154 | ||
155 | #define mlx5e_dbg(mlevel, priv, format, ...) \ | |
156 | do { \ | |
157 | if (NETIF_MSG_##mlevel & (priv)->msglevel) \ | |
158 | netdev_warn(priv->netdev, format, \ | |
159 | ##__VA_ARGS__); \ | |
160 | } while (0) | |
161 | ||
162 | ||
461017cb TT |
163 | static inline u16 mlx5_min_rx_wqes(int wq_type, u32 wq_size) |
164 | { | |
165 | switch (wq_type) { | |
166 | case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: | |
167 | return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW, | |
168 | wq_size / 2); | |
169 | default: | |
170 | return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES, | |
171 | wq_size / 2); | |
172 | } | |
173 | } | |
174 | ||
48935bbb SM |
175 | static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev) |
176 | { | |
177 | return is_kdump_kernel() ? | |
178 | MLX5E_MIN_NUM_CHANNELS : | |
179 | min_t(int, mdev->priv.eq_table.num_comp_vectors, | |
180 | MLX5E_MAX_NUM_CHANNELS); | |
181 | } | |
182 | ||
2f48af12 TT |
183 | struct mlx5e_tx_wqe { |
184 | struct mlx5_wqe_ctrl_seg ctrl; | |
185 | struct mlx5_wqe_eth_seg eth; | |
186 | }; | |
187 | ||
188 | struct mlx5e_rx_wqe { | |
189 | struct mlx5_wqe_srq_next_seg next; | |
190 | struct mlx5_wqe_data_seg data; | |
191 | }; | |
86d722ad | 192 | |
bc77b240 TT |
193 | struct mlx5e_umr_wqe { |
194 | struct mlx5_wqe_ctrl_seg ctrl; | |
195 | struct mlx5_wqe_umr_ctrl_seg uctrl; | |
196 | struct mlx5_mkey_seg mkc; | |
ea3886ca | 197 | struct mlx5_mtt inline_mtts[0]; |
bc77b240 TT |
198 | }; |
199 | ||
d605d668 KH |
200 | extern const char mlx5e_self_tests[][ETH_GSTRING_LEN]; |
201 | ||
4e59e288 | 202 | static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = { |
9908aa29 | 203 | "rx_cqe_moder", |
0088cbbc | 204 | "tx_cqe_moder", |
9bcc8606 | 205 | "rx_cqe_compress", |
2ccb0a79 | 206 | "rx_striding_rq", |
4e59e288 GP |
207 | }; |
208 | ||
209 | enum mlx5e_priv_flag { | |
9908aa29 | 210 | MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0), |
0088cbbc TG |
211 | MLX5E_PFLAG_TX_CQE_BASED_MODER = (1 << 1), |
212 | MLX5E_PFLAG_RX_CQE_COMPRESS = (1 << 2), | |
2ccb0a79 | 213 | MLX5E_PFLAG_RX_STRIDING_RQ = (1 << 3), |
4e59e288 GP |
214 | }; |
215 | ||
6a9764ef | 216 | #define MLX5E_SET_PFLAG(params, pflag, enable) \ |
59ece1c9 SD |
217 | do { \ |
218 | if (enable) \ | |
6a9764ef | 219 | (params)->pflags |= (pflag); \ |
59ece1c9 | 220 | else \ |
6a9764ef | 221 | (params)->pflags &= ~(pflag); \ |
4e59e288 GP |
222 | } while (0) |
223 | ||
6a9764ef | 224 | #define MLX5E_GET_PFLAG(params, pflag) (!!((params)->pflags & (pflag))) |
59ece1c9 | 225 | |
08fb1dac SM |
226 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
227 | #define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */ | |
08fb1dac SM |
228 | #endif |
229 | ||
f62b8bb8 AV |
230 | struct mlx5e_params { |
231 | u8 log_sq_size; | |
461017cb | 232 | u8 rq_wq_type; |
73281b78 | 233 | u8 log_rq_mtu_frames; |
f62b8bb8 | 234 | u16 num_channels; |
f62b8bb8 | 235 | u8 num_tc; |
9bcc8606 | 236 | bool rx_cqe_compress_def; |
9a317425 AG |
237 | struct net_dim_cq_moder rx_cq_moderation; |
238 | struct net_dim_cq_moder tx_cq_moderation; | |
f62b8bb8 AV |
239 | bool lro_en; |
240 | u32 lro_wqe_sz; | |
cff92d7c | 241 | u8 tx_min_inline_mode; |
2d75b2bc AS |
242 | u8 rss_hfunc; |
243 | u8 toeplitz_hash_key[40]; | |
244 | u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE]; | |
36350114 | 245 | bool vlan_strip_disable; |
102722fc | 246 | bool scatter_fcs_en; |
9a317425 | 247 | bool rx_dim_enabled; |
cbce4f44 | 248 | bool tx_dim_enabled; |
2b029556 | 249 | u32 lro_timeout; |
59ece1c9 | 250 | u32 pflags; |
6a9764ef | 251 | struct bpf_prog *xdp_prog; |
472a1e44 TT |
252 | unsigned int sw_mtu; |
253 | int hard_mtu; | |
f62b8bb8 AV |
254 | }; |
255 | ||
3a6a931d HN |
256 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
257 | struct mlx5e_cee_config { | |
258 | /* bw pct for priority group */ | |
259 | u8 pg_bw_pct[CEE_DCBX_MAX_PGS]; | |
260 | u8 prio_to_pg_map[CEE_DCBX_MAX_PRIO]; | |
261 | bool pfc_setting[CEE_DCBX_MAX_PRIO]; | |
262 | bool pfc_enable; | |
263 | }; | |
264 | ||
265 | enum { | |
266 | MLX5_DCB_CHG_RESET, | |
267 | MLX5_DCB_NO_CHG, | |
268 | MLX5_DCB_CHG_NO_RESET, | |
269 | }; | |
270 | ||
271 | struct mlx5e_dcbx { | |
e207b7e9 | 272 | enum mlx5_dcbx_oper_mode mode; |
3a6a931d | 273 | struct mlx5e_cee_config cee_cfg; /* pending configuration */ |
2a5e7a13 | 274 | u8 dscp_app_cnt; |
820c2c5e HN |
275 | |
276 | /* The only setting that cannot be read from FW */ | |
277 | u8 tc_tsa[IEEE_8021QAZ_MAX_TCS]; | |
9e10bf1d | 278 | u8 cap; |
0696d608 HN |
279 | |
280 | /* Buffer configuration */ | |
281 | u32 cable_len; | |
282 | u32 xoff; | |
3a6a931d | 283 | }; |
2a5e7a13 HN |
284 | |
285 | struct mlx5e_dcbx_dp { | |
286 | u8 dscp2prio[MLX5E_MAX_DSCP]; | |
287 | u8 trust_state; | |
288 | }; | |
3a6a931d HN |
289 | #endif |
290 | ||
f62b8bb8 | 291 | enum { |
c0f1147d | 292 | MLX5E_RQ_STATE_ENABLED, |
cb3c7fd4 | 293 | MLX5E_RQ_STATE_AM, |
f62b8bb8 AV |
294 | }; |
295 | ||
f62b8bb8 AV |
296 | struct mlx5e_cq { |
297 | /* data path - accessed per cqe */ | |
298 | struct mlx5_cqwq wq; | |
f62b8bb8 AV |
299 | |
300 | /* data path - accessed per napi poll */ | |
cb3c7fd4 | 301 | u16 event_ctr; |
f62b8bb8 AV |
302 | struct napi_struct *napi; |
303 | struct mlx5_core_cq mcq; | |
304 | struct mlx5e_channel *channel; | |
305 | ||
7219ab34 TT |
306 | /* cqe decompression */ |
307 | struct mlx5_cqe64 title; | |
308 | struct mlx5_mini_cqe8 mini_arr[MLX5_MINI_CQE_ARRAY_SIZE]; | |
309 | u8 mini_arr_idx; | |
310 | u16 decmprs_left; | |
311 | u16 decmprs_wqe_counter; | |
312 | ||
f62b8bb8 | 313 | /* control */ |
a43b25da | 314 | struct mlx5_core_dev *mdev; |
1c1b5228 | 315 | struct mlx5_frag_wq_ctrl wq_ctrl; |
f62b8bb8 AV |
316 | } ____cacheline_aligned_in_smp; |
317 | ||
eba2db2b | 318 | struct mlx5e_tx_wqe_info { |
77bdf895 | 319 | struct sk_buff *skb; |
eba2db2b SM |
320 | u32 num_bytes; |
321 | u8 num_wqebbs; | |
322 | u8 num_dma; | |
323 | }; | |
324 | ||
325 | enum mlx5e_dma_map_type { | |
326 | MLX5E_DMA_MAP_SINGLE, | |
327 | MLX5E_DMA_MAP_PAGE | |
328 | }; | |
329 | ||
330 | struct mlx5e_sq_dma { | |
331 | dma_addr_t addr; | |
332 | u32 size; | |
333 | enum mlx5e_dma_map_type type; | |
334 | }; | |
335 | ||
336 | enum { | |
337 | MLX5E_SQ_STATE_ENABLED, | |
db75373c | 338 | MLX5E_SQ_STATE_RECOVERING, |
2ac9cfe7 | 339 | MLX5E_SQ_STATE_IPSEC, |
cbce4f44 | 340 | MLX5E_SQ_STATE_AM, |
bf239741 | 341 | MLX5E_SQ_STATE_TLS, |
eba2db2b SM |
342 | }; |
343 | ||
344 | struct mlx5e_sq_wqe_info { | |
345 | u8 opcode; | |
eba2db2b | 346 | }; |
2f48af12 | 347 | |
31391048 | 348 | struct mlx5e_txqsq { |
eba2db2b SM |
349 | /* data path */ |
350 | ||
351 | /* dirtied @completion */ | |
352 | u16 cc; | |
353 | u32 dma_fifo_cc; | |
cbce4f44 | 354 | struct net_dim dim; /* Adaptive Moderation */ |
eba2db2b SM |
355 | |
356 | /* dirtied @xmit */ | |
357 | u16 pc ____cacheline_aligned_in_smp; | |
358 | u32 dma_fifo_pc; | |
359 | struct mlx5e_sq_stats stats; | |
360 | ||
361 | struct mlx5e_cq cq; | |
362 | ||
31391048 SM |
363 | /* write@xmit, read@completion */ |
364 | struct { | |
31391048 SM |
365 | struct mlx5e_sq_dma *dma_fifo; |
366 | struct mlx5e_tx_wqe_info *wqe_info; | |
eba2db2b SM |
367 | } db; |
368 | ||
369 | /* read only */ | |
370 | struct mlx5_wq_cyc wq; | |
371 | u32 dma_fifo_mask; | |
372 | void __iomem *uar_map; | |
373 | struct netdev_queue *txq; | |
374 | u32 sqn; | |
eba2db2b SM |
375 | u8 min_inline_mode; |
376 | u16 edge; | |
377 | struct device *pdev; | |
eba2db2b SM |
378 | __be32 mkey_be; |
379 | unsigned long state; | |
7c39afb3 FD |
380 | struct hwtstamp_config *tstamp; |
381 | struct mlx5_clock *clock; | |
eba2db2b SM |
382 | |
383 | /* control path */ | |
384 | struct mlx5_wq_ctrl wq_ctrl; | |
385 | struct mlx5e_channel *channel; | |
acc6c595 | 386 | int txq_ix; |
eba2db2b | 387 | u32 rate_limit; |
db75373c EBE |
388 | struct mlx5e_txqsq_recover { |
389 | struct work_struct recover_work; | |
390 | u64 last_recover; | |
391 | } recover; | |
31391048 SM |
392 | } ____cacheline_aligned_in_smp; |
393 | ||
394 | struct mlx5e_xdpsq { | |
395 | /* data path */ | |
396 | ||
397 | /* dirtied @rx completion */ | |
398 | u16 cc; | |
399 | u16 pc; | |
400 | ||
401 | struct mlx5e_cq cq; | |
402 | ||
403 | /* write@xmit, read@completion */ | |
404 | struct { | |
405 | struct mlx5e_dma_info *di; | |
406 | bool doorbell; | |
5168d732 | 407 | bool redirect_flush; |
31391048 SM |
408 | } db; |
409 | ||
410 | /* read only */ | |
411 | struct mlx5_wq_cyc wq; | |
412 | void __iomem *uar_map; | |
413 | u32 sqn; | |
414 | struct device *pdev; | |
415 | __be32 mkey_be; | |
416 | u8 min_inline_mode; | |
417 | unsigned long state; | |
418 | ||
419 | /* control path */ | |
420 | struct mlx5_wq_ctrl wq_ctrl; | |
421 | struct mlx5e_channel *channel; | |
422 | } ____cacheline_aligned_in_smp; | |
423 | ||
424 | struct mlx5e_icosq { | |
425 | /* data path */ | |
426 | ||
31391048 SM |
427 | /* dirtied @xmit */ |
428 | u16 pc ____cacheline_aligned_in_smp; | |
31391048 SM |
429 | |
430 | struct mlx5e_cq cq; | |
431 | ||
432 | /* write@xmit, read@completion */ | |
433 | struct { | |
434 | struct mlx5e_sq_wqe_info *ico_wqe; | |
435 | } db; | |
436 | ||
437 | /* read only */ | |
438 | struct mlx5_wq_cyc wq; | |
439 | void __iomem *uar_map; | |
440 | u32 sqn; | |
441 | u16 edge; | |
31391048 SM |
442 | unsigned long state; |
443 | ||
444 | /* control path */ | |
445 | struct mlx5_wq_ctrl wq_ctrl; | |
446 | struct mlx5e_channel *channel; | |
eba2db2b SM |
447 | } ____cacheline_aligned_in_smp; |
448 | ||
864b2d71 SM |
449 | static inline bool |
450 | mlx5e_wqc_has_room_for(struct mlx5_wq_cyc *wq, u16 cc, u16 pc, u16 n) | |
eba2db2b | 451 | { |
864b2d71 | 452 | return (((wq->sz_m1 & (cc - pc)) >= n) || (cc == pc)); |
eba2db2b | 453 | } |
6cd392a0 | 454 | |
461017cb TT |
455 | struct mlx5e_dma_info { |
456 | struct page *page; | |
457 | dma_addr_t addr; | |
458 | }; | |
459 | ||
accd5883 TT |
460 | struct mlx5e_wqe_frag_info { |
461 | struct mlx5e_dma_info di; | |
462 | u32 offset; | |
463 | }; | |
464 | ||
eba2db2b | 465 | struct mlx5e_umr_dma_info { |
eba2db2b | 466 | struct mlx5e_dma_info dma_info[MLX5_MPWRQ_PAGES_PER_WQE]; |
eba2db2b SM |
467 | }; |
468 | ||
469 | struct mlx5e_mpw_info { | |
470 | struct mlx5e_umr_dma_info umr; | |
471 | u16 consumed_strides; | |
22f45398 | 472 | DECLARE_BITMAP(xdp_xmit_bitmap, MLX5_MPWRQ_PAGES_PER_WQE); |
eba2db2b SM |
473 | }; |
474 | ||
4415a031 TT |
475 | /* a single cache unit is capable to serve one napi call (for non-striding rq) |
476 | * or a MPWQE (for striding rq). | |
477 | */ | |
478 | #define MLX5E_CACHE_UNIT (MLX5_MPWRQ_PAGES_PER_WQE > NAPI_POLL_WEIGHT ? \ | |
479 | MLX5_MPWRQ_PAGES_PER_WQE : NAPI_POLL_WEIGHT) | |
29c2849e | 480 | #define MLX5E_CACHE_SIZE (4 * roundup_pow_of_two(MLX5E_CACHE_UNIT)) |
4415a031 TT |
481 | struct mlx5e_page_cache { |
482 | u32 head; | |
483 | u32 tail; | |
484 | struct mlx5e_dma_info page_cache[MLX5E_CACHE_SIZE]; | |
485 | }; | |
486 | ||
eba2db2b SM |
487 | struct mlx5e_rq; |
488 | typedef void (*mlx5e_fp_handle_rx_cqe)(struct mlx5e_rq*, struct mlx5_cqe64*); | |
619a8f2a TT |
489 | typedef struct sk_buff * |
490 | (*mlx5e_fp_skb_from_cqe_mpwrq)(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi, | |
491 | u16 cqe_bcnt, u32 head_offset, u32 page_idx); | |
7cc6d77b | 492 | typedef bool (*mlx5e_fp_post_rx_wqes)(struct mlx5e_rq *rq); |
eba2db2b SM |
493 | typedef void (*mlx5e_fp_dealloc_wqe)(struct mlx5e_rq*, u16); |
494 | ||
121e8927 TT |
495 | enum mlx5e_rq_flag { |
496 | MLX5E_RQ_FLAG_XDP_XMIT = BIT(0), | |
497 | }; | |
498 | ||
f62b8bb8 AV |
499 | struct mlx5e_rq { |
500 | /* data path */ | |
501 | struct mlx5_wq_ll wq; | |
1bfecfca | 502 | |
21c59685 | 503 | union { |
accd5883 TT |
504 | struct { |
505 | struct mlx5e_wqe_frag_info *frag_info; | |
506 | u32 frag_sz; /* max possible skb frag_sz */ | |
b45d8b50 TT |
507 | union { |
508 | bool page_reuse; | |
b45d8b50 | 509 | }; |
accd5883 | 510 | } wqe; |
21c59685 | 511 | struct { |
b8a98a4c | 512 | struct mlx5e_umr_wqe umr_wqe; |
21c59685 | 513 | struct mlx5e_mpw_info *info; |
619a8f2a | 514 | mlx5e_fp_skb_from_cqe_mpwrq skb_from_cqe_mpwrq; |
b45d8b50 | 515 | u16 num_strides; |
89e89f7a | 516 | u8 log_stride_sz; |
a071cb9f | 517 | bool umr_in_progress; |
21c59685 SM |
518 | } mpwqe; |
519 | }; | |
1bfecfca | 520 | struct { |
b45d8b50 | 521 | u16 headroom; |
1bfecfca | 522 | u8 page_order; |
b5503b99 | 523 | u8 map_dir; /* dma map direction */ |
1bfecfca | 524 | } buff; |
f62b8bb8 | 525 | |
7cc6d77b | 526 | struct mlx5e_channel *channel; |
f62b8bb8 AV |
527 | struct device *pdev; |
528 | struct net_device *netdev; | |
529 | struct mlx5e_rq_stats stats; | |
530 | struct mlx5e_cq cq; | |
4415a031 | 531 | struct mlx5e_page_cache page_cache; |
7c39afb3 FD |
532 | struct hwtstamp_config *tstamp; |
533 | struct mlx5_clock *clock; | |
4415a031 | 534 | |
2f48af12 | 535 | mlx5e_fp_handle_rx_cqe handle_rx_cqe; |
7cc6d77b | 536 | mlx5e_fp_post_rx_wqes post_wqes; |
6cd392a0 | 537 | mlx5e_fp_dealloc_wqe dealloc_wqe; |
f62b8bb8 AV |
538 | |
539 | unsigned long state; | |
540 | int ix; | |
541 | ||
9a317425 | 542 | struct net_dim dim; /* Dynamic Interrupt Moderation */ |
31871f87 SM |
543 | |
544 | /* XDP */ | |
86994156 | 545 | struct bpf_prog *xdp_prog; |
472a1e44 | 546 | unsigned int hw_mtu; |
31391048 | 547 | struct mlx5e_xdpsq xdpsq; |
121e8927 | 548 | DECLARE_BITMAP(flags, 8); |
60bbf7ee | 549 | struct page_pool *page_pool; |
cb3c7fd4 | 550 | |
f62b8bb8 AV |
551 | /* control */ |
552 | struct mlx5_wq_ctrl wq_ctrl; | |
b45d8b50 | 553 | __be32 mkey_be; |
461017cb | 554 | u8 wq_type; |
f62b8bb8 | 555 | u32 rqn; |
a43b25da | 556 | struct mlx5_core_dev *mdev; |
ec8b9981 | 557 | struct mlx5_core_mkey umr_mkey; |
0ddf5432 JDB |
558 | |
559 | /* XDP read-mostly */ | |
560 | struct xdp_rxq_info xdp_rxq; | |
f62b8bb8 AV |
561 | } ____cacheline_aligned_in_smp; |
562 | ||
f62b8bb8 AV |
563 | struct mlx5e_channel { |
564 | /* data path */ | |
565 | struct mlx5e_rq rq; | |
31391048 SM |
566 | struct mlx5e_txqsq sq[MLX5E_MAX_NUM_TC]; |
567 | struct mlx5e_icosq icosq; /* internal control operations */ | |
b5503b99 | 568 | bool xdp; |
f62b8bb8 AV |
569 | struct napi_struct napi; |
570 | struct device *pdev; | |
571 | struct net_device *netdev; | |
572 | __be32 mkey_be; | |
573 | u8 num_tc; | |
f62b8bb8 | 574 | |
a8c2eb15 TT |
575 | /* data path - accessed per napi poll */ |
576 | struct irq_desc *irq_desc; | |
57d689a8 | 577 | struct mlx5e_ch_stats stats; |
f62b8bb8 AV |
578 | |
579 | /* control */ | |
580 | struct mlx5e_priv *priv; | |
a43b25da | 581 | struct mlx5_core_dev *mdev; |
7c39afb3 | 582 | struct hwtstamp_config *tstamp; |
f62b8bb8 | 583 | int ix; |
231243c8 | 584 | int cpu; |
f62b8bb8 AV |
585 | }; |
586 | ||
ff9c852f SM |
587 | struct mlx5e_channels { |
588 | struct mlx5e_channel **c; | |
589 | unsigned int num; | |
6a9764ef | 590 | struct mlx5e_params params; |
ff9c852f SM |
591 | }; |
592 | ||
f62b8bb8 | 593 | enum mlx5e_traffic_types { |
5a6f8aef AS |
594 | MLX5E_TT_IPV4_TCP, |
595 | MLX5E_TT_IPV6_TCP, | |
596 | MLX5E_TT_IPV4_UDP, | |
597 | MLX5E_TT_IPV6_UDP, | |
a741749f AS |
598 | MLX5E_TT_IPV4_IPSEC_AH, |
599 | MLX5E_TT_IPV6_IPSEC_AH, | |
600 | MLX5E_TT_IPV4_IPSEC_ESP, | |
601 | MLX5E_TT_IPV6_IPSEC_ESP, | |
5a6f8aef AS |
602 | MLX5E_TT_IPV4, |
603 | MLX5E_TT_IPV6, | |
604 | MLX5E_TT_ANY, | |
605 | MLX5E_NUM_TT, | |
1da36696 | 606 | MLX5E_NUM_INDIR_TIRS = MLX5E_TT_ANY, |
f62b8bb8 AV |
607 | }; |
608 | ||
7b3722fa GP |
609 | enum mlx5e_tunnel_types { |
610 | MLX5E_TT_IPV4_GRE, | |
611 | MLX5E_TT_IPV6_GRE, | |
612 | MLX5E_NUM_TUNNEL_TT, | |
613 | }; | |
614 | ||
acff797c | 615 | enum { |
e0f46eb9 | 616 | MLX5E_STATE_ASYNC_EVENTS_ENABLED, |
acff797c MG |
617 | MLX5E_STATE_OPENED, |
618 | MLX5E_STATE_DESTROYING, | |
619 | }; | |
620 | ||
621 | struct mlx5e_vxlan_db { | |
622 | spinlock_t lock; /* protect vxlan table */ | |
623 | struct radix_tree_root tree; | |
624 | }; | |
625 | ||
33cfaaa8 | 626 | struct mlx5e_l2_rule { |
f62b8bb8 | 627 | u8 addr[ETH_ALEN + 2]; |
74491de9 | 628 | struct mlx5_flow_handle *rule; |
f62b8bb8 AV |
629 | }; |
630 | ||
acff797c MG |
631 | struct mlx5e_flow_table { |
632 | int num_groups; | |
633 | struct mlx5_flow_table *t; | |
634 | struct mlx5_flow_group **g; | |
635 | }; | |
636 | ||
33cfaaa8 | 637 | #define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE) |
f62b8bb8 | 638 | |
acff797c MG |
639 | struct mlx5e_tc_table { |
640 | struct mlx5_flow_table *t; | |
641 | ||
acff797c | 642 | struct rhashtable ht; |
11c9c548 OG |
643 | |
644 | DECLARE_HASHTABLE(mod_hdr_tbl, 8); | |
5c65c564 | 645 | DECLARE_HASHTABLE(hairpin_tbl, 8); |
f62b8bb8 AV |
646 | }; |
647 | ||
acff797c MG |
648 | struct mlx5e_vlan_table { |
649 | struct mlx5e_flow_table ft; | |
03eda954 | 650 | DECLARE_BITMAP(active_cvlans, VLAN_N_VID); |
7d92d580 | 651 | DECLARE_BITMAP(active_svlans, VLAN_N_VID); |
2b52a283 | 652 | struct mlx5_flow_handle *active_cvlans_rule[VLAN_N_VID]; |
7d92d580 | 653 | struct mlx5_flow_handle *active_svlans_rule[VLAN_N_VID]; |
74491de9 | 654 | struct mlx5_flow_handle *untagged_rule; |
8a271746 MHY |
655 | struct mlx5_flow_handle *any_cvlan_rule; |
656 | struct mlx5_flow_handle *any_svlan_rule; | |
2b52a283 | 657 | bool cvlan_filter_disabled; |
f62b8bb8 AV |
658 | }; |
659 | ||
33cfaaa8 MG |
660 | struct mlx5e_l2_table { |
661 | struct mlx5e_flow_table ft; | |
662 | struct hlist_head netdev_uc[MLX5E_L2_ADDR_HASH_SIZE]; | |
663 | struct hlist_head netdev_mc[MLX5E_L2_ADDR_HASH_SIZE]; | |
664 | struct mlx5e_l2_rule broadcast; | |
665 | struct mlx5e_l2_rule allmulti; | |
666 | struct mlx5e_l2_rule promisc; | |
667 | bool broadcast_enabled; | |
668 | bool allmulti_enabled; | |
669 | bool promisc_enabled; | |
670 | }; | |
671 | ||
672 | /* L3/L4 traffic type classifier */ | |
673 | struct mlx5e_ttc_table { | |
674 | struct mlx5e_flow_table ft; | |
74491de9 | 675 | struct mlx5_flow_handle *rules[MLX5E_NUM_TT]; |
7b3722fa | 676 | struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT]; |
33cfaaa8 MG |
677 | }; |
678 | ||
18c908e4 MG |
679 | #define ARFS_HASH_SHIFT BITS_PER_BYTE |
680 | #define ARFS_HASH_SIZE BIT(BITS_PER_BYTE) | |
1cabe6b0 MG |
681 | struct arfs_table { |
682 | struct mlx5e_flow_table ft; | |
74491de9 | 683 | struct mlx5_flow_handle *default_rule; |
18c908e4 | 684 | struct hlist_head rules_hash[ARFS_HASH_SIZE]; |
1cabe6b0 MG |
685 | }; |
686 | ||
687 | enum arfs_type { | |
688 | ARFS_IPV4_TCP, | |
689 | ARFS_IPV6_TCP, | |
690 | ARFS_IPV4_UDP, | |
691 | ARFS_IPV6_UDP, | |
692 | ARFS_NUM_TYPES, | |
693 | }; | |
694 | ||
695 | struct mlx5e_arfs_tables { | |
696 | struct arfs_table arfs_tables[ARFS_NUM_TYPES]; | |
18c908e4 MG |
697 | /* Protect aRFS rules list */ |
698 | spinlock_t arfs_lock; | |
699 | struct list_head rules; | |
700 | int last_filter_id; | |
701 | struct workqueue_struct *wq; | |
1cabe6b0 MG |
702 | }; |
703 | ||
704 | /* NIC prio FTS */ | |
705 | enum { | |
706 | MLX5E_VLAN_FT_LEVEL = 0, | |
707 | MLX5E_L2_FT_LEVEL, | |
708 | MLX5E_TTC_FT_LEVEL, | |
7b3722fa | 709 | MLX5E_INNER_TTC_FT_LEVEL, |
1cabe6b0 MG |
710 | MLX5E_ARFS_FT_LEVEL |
711 | }; | |
712 | ||
3f6d08d1 OG |
713 | enum { |
714 | MLX5E_TC_FT_LEVEL = 0, | |
715 | MLX5E_TC_TTC_FT_LEVEL, | |
716 | }; | |
717 | ||
6dc6071c MG |
718 | struct mlx5e_ethtool_table { |
719 | struct mlx5_flow_table *ft; | |
720 | int num_rules; | |
721 | }; | |
722 | ||
1174fce8 | 723 | #define ETHTOOL_NUM_L3_L4_FTS 7 |
6dc6071c MG |
724 | #define ETHTOOL_NUM_L2_FTS 4 |
725 | ||
726 | struct mlx5e_ethtool_steering { | |
1174fce8 | 727 | struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS]; |
6dc6071c MG |
728 | struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS]; |
729 | struct list_head rules; | |
730 | int tot_num_rules; | |
731 | }; | |
732 | ||
acff797c MG |
733 | struct mlx5e_flow_steering { |
734 | struct mlx5_flow_namespace *ns; | |
6dc6071c | 735 | struct mlx5e_ethtool_steering ethtool; |
acff797c MG |
736 | struct mlx5e_tc_table tc; |
737 | struct mlx5e_vlan_table vlan; | |
33cfaaa8 MG |
738 | struct mlx5e_l2_table l2; |
739 | struct mlx5e_ttc_table ttc; | |
7b3722fa | 740 | struct mlx5e_ttc_table inner_ttc; |
1cabe6b0 | 741 | struct mlx5e_arfs_tables arfs; |
f62b8bb8 AV |
742 | }; |
743 | ||
398f3351 | 744 | struct mlx5e_rqt { |
1da36696 | 745 | u32 rqtn; |
398f3351 HHZ |
746 | bool enabled; |
747 | }; | |
748 | ||
749 | struct mlx5e_tir { | |
750 | u32 tirn; | |
751 | struct mlx5e_rqt rqt; | |
752 | struct list_head list; | |
1da36696 TT |
753 | }; |
754 | ||
acff797c MG |
755 | enum { |
756 | MLX5E_TC_PRIO = 0, | |
757 | MLX5E_NIC_PRIO | |
758 | }; | |
759 | ||
f62b8bb8 AV |
760 | struct mlx5e_priv { |
761 | /* priv data path fields - start */ | |
acc6c595 SM |
762 | struct mlx5e_txqsq *txq2sq[MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC]; |
763 | int channel_tc2txq[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC]; | |
2a5e7a13 HN |
764 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
765 | struct mlx5e_dcbx_dp dcbx_dp; | |
766 | #endif | |
f62b8bb8 AV |
767 | /* priv data path fields - end */ |
768 | ||
79c48764 | 769 | u32 msglevel; |
f62b8bb8 AV |
770 | unsigned long state; |
771 | struct mutex state_lock; /* Protects Interface state */ | |
50cfa25a | 772 | struct mlx5e_rq drop_rq; |
f62b8bb8 | 773 | |
ff9c852f | 774 | struct mlx5e_channels channels; |
f62b8bb8 | 775 | u32 tisn[MLX5E_MAX_NUM_TC]; |
398f3351 | 776 | struct mlx5e_rqt indir_rqt; |
724b2aa1 | 777 | struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS]; |
7b3722fa | 778 | struct mlx5e_tir inner_indir_tir[MLX5E_NUM_INDIR_TIRS]; |
724b2aa1 | 779 | struct mlx5e_tir direct_tir[MLX5E_MAX_NUM_CHANNELS]; |
507f0c81 | 780 | u32 tx_rates[MLX5E_MAX_NUM_SQS]; |
f62b8bb8 | 781 | |
acff797c | 782 | struct mlx5e_flow_steering fs; |
b3f63c3d | 783 | struct mlx5e_vxlan_db vxlan; |
f62b8bb8 | 784 | |
7bb29755 | 785 | struct workqueue_struct *wq; |
f62b8bb8 AV |
786 | struct work_struct update_carrier_work; |
787 | struct work_struct set_rx_mode_work; | |
3947ca18 | 788 | struct work_struct tx_timeout_work; |
f62b8bb8 AV |
789 | struct delayed_work update_stats_work; |
790 | ||
791 | struct mlx5_core_dev *mdev; | |
792 | struct net_device *netdev; | |
793 | struct mlx5e_stats stats; | |
7c39afb3 | 794 | struct hwtstamp_config tstamp; |
7cbaf9a3 MS |
795 | u16 q_counter; |
796 | u16 drop_rq_q_counter; | |
3a6a931d HN |
797 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
798 | struct mlx5e_dcbx dcbx; | |
799 | #endif | |
800 | ||
6bfd390b | 801 | const struct mlx5e_profile *profile; |
127ea380 | 802 | void *ppriv; |
547eede0 IT |
803 | #ifdef CONFIG_MLX5_EN_IPSEC |
804 | struct mlx5e_ipsec *ipsec; | |
805 | #endif | |
43585a41 IL |
806 | #ifdef CONFIG_MLX5_EN_TLS |
807 | struct mlx5e_tls *tls; | |
808 | #endif | |
f62b8bb8 AV |
809 | }; |
810 | ||
a43b25da SM |
811 | struct mlx5e_profile { |
812 | void (*init)(struct mlx5_core_dev *mdev, | |
813 | struct net_device *netdev, | |
814 | const struct mlx5e_profile *profile, void *ppriv); | |
815 | void (*cleanup)(struct mlx5e_priv *priv); | |
816 | int (*init_rx)(struct mlx5e_priv *priv); | |
817 | void (*cleanup_rx)(struct mlx5e_priv *priv); | |
818 | int (*init_tx)(struct mlx5e_priv *priv); | |
819 | void (*cleanup_tx)(struct mlx5e_priv *priv); | |
820 | void (*enable)(struct mlx5e_priv *priv); | |
821 | void (*disable)(struct mlx5e_priv *priv); | |
822 | void (*update_stats)(struct mlx5e_priv *priv); | |
7ca42c80 | 823 | void (*update_carrier)(struct mlx5e_priv *priv); |
a43b25da | 824 | int (*max_nch)(struct mlx5_core_dev *mdev); |
20fd0c19 SM |
825 | struct { |
826 | mlx5e_fp_handle_rx_cqe handle_rx_cqe; | |
827 | mlx5e_fp_handle_rx_cqe handle_rx_cqe_mpwqe; | |
828 | } rx_handlers; | |
2a5e7a13 HN |
829 | void (*netdev_registered_init)(struct mlx5e_priv *priv); |
830 | void (*netdev_registered_remove)(struct mlx5e_priv *priv); | |
a43b25da SM |
831 | int max_tc; |
832 | }; | |
833 | ||
665bc539 GP |
834 | void mlx5e_build_ptys2ethtool_map(void); |
835 | ||
f62b8bb8 AV |
836 | u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb, |
837 | void *accel_priv, select_queue_fallback_t fallback); | |
838 | netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev); | |
bf239741 IL |
839 | netdev_tx_t mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, |
840 | struct mlx5e_tx_wqe *wqe, u16 pi); | |
f62b8bb8 AV |
841 | |
842 | void mlx5e_completion_event(struct mlx5_core_cq *mcq); | |
843 | void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event); | |
844 | int mlx5e_napi_poll(struct napi_struct *napi, int budget); | |
8ec736e5 | 845 | bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget); |
44fb6fbb | 846 | int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); |
1c4bf940 | 847 | bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq); |
31391048 SM |
848 | void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq); |
849 | void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq); | |
461017cb | 850 | |
2ccb0a79 TT |
851 | bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev); |
852 | bool mlx5e_striding_rq_possible(struct mlx5_core_dev *mdev, | |
853 | struct mlx5e_params *params); | |
854 | ||
4415a031 TT |
855 | void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info, |
856 | bool recycle); | |
2f48af12 | 857 | void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); |
461017cb | 858 | void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); |
f62b8bb8 | 859 | bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq); |
7cc6d77b | 860 | bool mlx5e_post_rx_mpwqes(struct mlx5e_rq *rq); |
6cd392a0 DJ |
861 | void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix); |
862 | void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix); | |
7e426671 | 863 | void mlx5e_free_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi); |
619a8f2a TT |
864 | struct sk_buff * |
865 | mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi, | |
866 | u16 cqe_bcnt, u32 head_offset, u32 page_idx); | |
867 | struct sk_buff * | |
868 | mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi, | |
869 | u16 cqe_bcnt, u32 head_offset, u32 page_idx); | |
f62b8bb8 | 870 | |
19386177 | 871 | void mlx5e_update_stats(struct mlx5e_priv *priv); |
f62b8bb8 | 872 | |
acff797c MG |
873 | int mlx5e_create_flow_steering(struct mlx5e_priv *priv); |
874 | void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv); | |
33cfaaa8 | 875 | void mlx5e_init_l2_addr(struct mlx5e_priv *priv); |
1cabe6b0 | 876 | void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft); |
d605d668 KH |
877 | int mlx5e_self_test_num(struct mlx5e_priv *priv); |
878 | void mlx5e_self_test(struct net_device *ndev, struct ethtool_test *etest, | |
879 | u64 *buf); | |
f913a72a MG |
880 | int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info, |
881 | int location); | |
882 | int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv, | |
883 | struct ethtool_rxnfc *info, u32 *rule_locs); | |
6dc6071c MG |
884 | int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv, |
885 | struct ethtool_rx_flow_spec *fs); | |
886 | int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv, | |
887 | int location); | |
888 | void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv); | |
889 | void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv); | |
f62b8bb8 AV |
890 | void mlx5e_set_rx_mode_work(struct work_struct *work); |
891 | ||
1170fbd8 FD |
892 | int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr); |
893 | int mlx5e_hwstamp_get(struct mlx5e_priv *priv, struct ifreq *ifr); | |
be7e87f9 | 894 | int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val); |
ef9814de | 895 | |
f62b8bb8 AV |
896 | int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto, |
897 | u16 vid); | |
898 | int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto, | |
899 | u16 vid); | |
2b52a283 GP |
900 | void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv); |
901 | void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv); | |
237f258c | 902 | void mlx5e_timestamp_init(struct mlx5e_priv *priv); |
f62b8bb8 | 903 | |
a5f97fee SM |
904 | struct mlx5e_redirect_rqt_param { |
905 | bool is_rss; | |
906 | union { | |
907 | u32 rqn; /* Direct RQN (Non-RSS) */ | |
908 | struct { | |
909 | u8 hfunc; | |
910 | struct mlx5e_channels *channels; | |
911 | } rss; /* RSS data */ | |
912 | }; | |
913 | }; | |
914 | ||
915 | int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz, | |
916 | struct mlx5e_redirect_rqt_param rrp); | |
6a9764ef SM |
917 | void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_params *params, |
918 | enum mlx5e_traffic_types tt, | |
7b3722fa | 919 | void *tirc, bool inner); |
2d75b2bc | 920 | |
f62b8bb8 AV |
921 | int mlx5e_open_locked(struct net_device *netdev); |
922 | int mlx5e_close_locked(struct net_device *netdev); | |
55c2503d SM |
923 | |
924 | int mlx5e_open_channels(struct mlx5e_priv *priv, | |
925 | struct mlx5e_channels *chs); | |
926 | void mlx5e_close_channels(struct mlx5e_channels *chs); | |
2e20a151 SM |
927 | |
928 | /* Function pointer to be used to modify WH settings while | |
929 | * switching channels | |
930 | */ | |
931 | typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv); | |
55c2503d | 932 | void mlx5e_switch_priv_channels(struct mlx5e_priv *priv, |
2e20a151 SM |
933 | struct mlx5e_channels *new_chs, |
934 | mlx5e_fp_hw_modify hw_modify); | |
603f4a45 SM |
935 | void mlx5e_activate_priv_channels(struct mlx5e_priv *priv); |
936 | void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv); | |
55c2503d | 937 | |
d4b6c488 | 938 | void mlx5e_build_default_indir_rqt(u32 *indirection_rqt, int len, |
85082dba | 939 | int num_channels); |
0088cbbc TG |
940 | void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, |
941 | u8 cq_period_mode); | |
9908aa29 TT |
942 | void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, |
943 | u8 cq_period_mode); | |
2ccb0a79 | 944 | void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params); |
696a97cf | 945 | void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev, |
2a0f561b | 946 | struct mlx5e_params *params); |
9908aa29 | 947 | |
7b3722fa GP |
948 | static inline bool mlx5e_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev) |
949 | { | |
950 | return (MLX5_CAP_ETH(mdev, tunnel_stateless_gre) && | |
951 | MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ft_field_support.inner_ip_version)); | |
952 | } | |
953 | ||
bf239741 IL |
954 | static inline void mlx5e_sq_fetch_wqe(struct mlx5e_txqsq *sq, |
955 | struct mlx5e_tx_wqe **wqe, | |
956 | u16 *pi) | |
957 | { | |
958 | struct mlx5_wq_cyc *wq; | |
959 | ||
960 | wq = &sq->wq; | |
961 | *pi = sq->pc & wq->sz_m1; | |
962 | *wqe = mlx5_wq_cyc_get_wqe(wq, *pi); | |
963 | memset(*wqe, 0, sizeof(**wqe)); | |
964 | } | |
965 | ||
864b2d71 SM |
966 | static inline |
967 | struct mlx5e_tx_wqe *mlx5e_post_nop(struct mlx5_wq_cyc *wq, u32 sqn, u16 *pc) | |
f62b8bb8 | 968 | { |
864b2d71 SM |
969 | u16 pi = *pc & wq->sz_m1; |
970 | struct mlx5e_tx_wqe *wqe = mlx5_wq_cyc_get_wqe(wq, pi); | |
971 | struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl; | |
972 | ||
973 | memset(cseg, 0, sizeof(*cseg)); | |
974 | ||
975 | cseg->opmod_idx_opcode = cpu_to_be32((*pc << 8) | MLX5_OPCODE_NOP); | |
976 | cseg->qpn_ds = cpu_to_be32((sqn << 8) | 0x01); | |
977 | ||
978 | (*pc)++; | |
979 | ||
980 | return wqe; | |
981 | } | |
982 | ||
983 | static inline | |
984 | void mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, | |
985 | void __iomem *uar_map, | |
986 | struct mlx5_wqe_ctrl_seg *ctrl) | |
987 | { | |
988 | ctrl->fm_ce_se = MLX5_WQE_CTRL_CQ_UPDATE; | |
f62b8bb8 AV |
989 | /* ensure wqe is visible to device before updating doorbell record */ |
990 | dma_wmb(); | |
991 | ||
864b2d71 | 992 | *wq->db = cpu_to_be32(pc); |
f62b8bb8 AV |
993 | |
994 | /* ensure doorbell record is visible to device before ringing the | |
995 | * doorbell | |
996 | */ | |
997 | wmb(); | |
f62b8bb8 | 998 | |
864b2d71 | 999 | mlx5_write64((__be32 *)ctrl, uar_map, NULL); |
f62b8bb8 AV |
1000 | } |
1001 | ||
1002 | static inline void mlx5e_cq_arm(struct mlx5e_cq *cq) | |
1003 | { | |
1004 | struct mlx5_core_cq *mcq; | |
1005 | ||
1006 | mcq = &cq->mcq; | |
5fe9dec0 | 1007 | mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, cq->wq.cc); |
f62b8bb8 AV |
1008 | } |
1009 | ||
1010 | extern const struct ethtool_ops mlx5e_ethtool_ops; | |
08fb1dac SM |
1011 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
1012 | extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops; | |
1013 | int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets); | |
e207b7e9 | 1014 | void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv); |
2a5e7a13 HN |
1015 | void mlx5e_dcbnl_init_app(struct mlx5e_priv *priv); |
1016 | void mlx5e_dcbnl_delete_app(struct mlx5e_priv *priv); | |
08fb1dac SM |
1017 | #endif |
1018 | ||
1cabe6b0 MG |
1019 | #ifndef CONFIG_RFS_ACCEL |
1020 | static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv) | |
1021 | { | |
1022 | return 0; | |
1023 | } | |
1024 | ||
1025 | static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {} | |
45bf454a MG |
1026 | |
1027 | static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) | |
1028 | { | |
9eb78923 | 1029 | return -EOPNOTSUPP; |
45bf454a MG |
1030 | } |
1031 | ||
1032 | static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) | |
1033 | { | |
9eb78923 | 1034 | return -EOPNOTSUPP; |
45bf454a | 1035 | } |
1cabe6b0 MG |
1036 | #else |
1037 | int mlx5e_arfs_create_tables(struct mlx5e_priv *priv); | |
1038 | void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv); | |
45bf454a MG |
1039 | int mlx5e_arfs_enable(struct mlx5e_priv *priv); |
1040 | int mlx5e_arfs_disable(struct mlx5e_priv *priv); | |
18c908e4 MG |
1041 | int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, |
1042 | u16 rxq_index, u32 flow_id); | |
1cabe6b0 MG |
1043 | #endif |
1044 | ||
724b2aa1 HHZ |
1045 | int mlx5e_create_tir(struct mlx5_core_dev *mdev, |
1046 | struct mlx5e_tir *tir, u32 *in, int inlen); | |
1047 | void mlx5e_destroy_tir(struct mlx5_core_dev *mdev, | |
1048 | struct mlx5e_tir *tir); | |
b50d292b HHZ |
1049 | int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev); |
1050 | void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev); | |
b676f653 | 1051 | int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb); |
1afff42c | 1052 | |
bc81b9d3 | 1053 | /* common netdev helpers */ |
8f493ffd SM |
1054 | int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv); |
1055 | ||
1056 | int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv); | |
1057 | void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv); | |
1058 | ||
cb67b832 | 1059 | int mlx5e_create_direct_rqts(struct mlx5e_priv *priv); |
8f493ffd | 1060 | void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv); |
cb67b832 HHZ |
1061 | int mlx5e_create_direct_tirs(struct mlx5e_priv *priv); |
1062 | void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv); | |
8f493ffd SM |
1063 | void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt); |
1064 | ||
1ae1df3a OG |
1065 | struct ttc_params { |
1066 | struct mlx5_flow_table_attr ft_attr; | |
1067 | u32 any_tt_tirn; | |
1068 | u32 indir_tirn[MLX5E_NUM_INDIR_TIRS]; | |
1069 | struct mlx5e_ttc_table *inner_ttc; | |
1070 | }; | |
1071 | ||
1072 | void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, struct ttc_params *ttc_params); | |
1073 | void mlx5e_set_ttc_ft_params(struct ttc_params *ttc_params); | |
1074 | void mlx5e_set_inner_ttc_ft_params(struct ttc_params *ttc_params); | |
1075 | ||
1076 | int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params, | |
1077 | struct mlx5e_ttc_table *ttc); | |
1078 | void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv, | |
1079 | struct mlx5e_ttc_table *ttc); | |
bc81b9d3 | 1080 | |
1ae1df3a OG |
1081 | int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params, |
1082 | struct mlx5e_ttc_table *ttc); | |
1083 | void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv, | |
1084 | struct mlx5e_ttc_table *ttc); | |
458821c7 | 1085 | |
5426a0b2 SM |
1086 | int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc, |
1087 | u32 underlay_qpn, u32 *tisn); | |
1088 | void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn); | |
1089 | ||
cb67b832 HHZ |
1090 | int mlx5e_create_tises(struct mlx5e_priv *priv); |
1091 | void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv); | |
1092 | int mlx5e_close(struct net_device *netdev); | |
1093 | int mlx5e_open(struct net_device *netdev); | |
1094 | void mlx5e_update_stats_work(struct work_struct *work); | |
cb67b832 | 1095 | |
3f6d08d1 OG |
1096 | int mlx5e_bits_invert(unsigned long a, int size); |
1097 | ||
076b0936 ES |
1098 | /* ethtool helpers */ |
1099 | void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv, | |
1100 | struct ethtool_drvinfo *drvinfo); | |
1101 | void mlx5e_ethtool_get_strings(struct mlx5e_priv *priv, | |
1102 | uint32_t stringset, uint8_t *data); | |
1103 | int mlx5e_ethtool_get_sset_count(struct mlx5e_priv *priv, int sset); | |
1104 | void mlx5e_ethtool_get_ethtool_stats(struct mlx5e_priv *priv, | |
1105 | struct ethtool_stats *stats, u64 *data); | |
1106 | void mlx5e_ethtool_get_ringparam(struct mlx5e_priv *priv, | |
1107 | struct ethtool_ringparam *param); | |
1108 | int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv, | |
1109 | struct ethtool_ringparam *param); | |
1110 | void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv, | |
1111 | struct ethtool_channels *ch); | |
1112 | int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, | |
1113 | struct ethtool_channels *ch); | |
1114 | int mlx5e_ethtool_get_coalesce(struct mlx5e_priv *priv, | |
1115 | struct ethtool_coalesce *coal); | |
1116 | int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv, | |
1117 | struct ethtool_coalesce *coal); | |
3844b07e FD |
1118 | int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv, |
1119 | struct ethtool_ts_info *info); | |
3ffaabec OG |
1120 | int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv, |
1121 | struct ethtool_flash *flash); | |
076b0936 | 1122 | |
2c3b5bee SM |
1123 | /* mlx5e generic netdev management API */ |
1124 | struct net_device* | |
1125 | mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile, | |
1126 | void *ppriv); | |
1127 | int mlx5e_attach_netdev(struct mlx5e_priv *priv); | |
1128 | void mlx5e_detach_netdev(struct mlx5e_priv *priv); | |
1129 | void mlx5e_destroy_netdev(struct mlx5e_priv *priv); | |
8f493ffd SM |
1130 | void mlx5e_build_nic_params(struct mlx5_core_dev *mdev, |
1131 | struct mlx5e_params *params, | |
472a1e44 | 1132 | u16 max_channels, u16 mtu); |
fbcb127e | 1133 | u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev); |
9a317425 | 1134 | void mlx5e_rx_dim_work(struct work_struct *work); |
cbce4f44 | 1135 | void mlx5e_tx_dim_work(struct work_struct *work); |
1afff42c | 1136 | #endif /* __MLX5_EN_H__ */ |