1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #ifndef _QED_L2_H
33 #define _QED_L2_H
34 #include <linux/types.h>
35 #include <linux/io.h>
36 #include <linux/kernel.h>
37 #include <linux/slab.h>
38 #include <linux/qed/qed_eth_if.h>
39 #include "qed.h"
40 #include "qed_hw.h"
41 #include "qed_sp.h"
42 struct qed_rss_params {
43 u8 update_rss_config;
44 u8 rss_enable;
45 u8 rss_eng_id;
46 u8 update_rss_capabilities;
47 u8 update_rss_ind_table;
48 u8 update_rss_key;
49 u8 rss_caps;
50 u8 rss_table_size_log;
51
52
53 void *rss_ind_table[QED_RSS_IND_TABLE_SIZE];
54 u32 rss_key[QED_RSS_KEY_SIZE];
55 };
56
57 struct qed_sge_tpa_params {
58 u8 max_buffers_per_cqe;
59
60 u8 update_tpa_en_flg;
61 u8 tpa_ipv4_en_flg;
62 u8 tpa_ipv6_en_flg;
63 u8 tpa_ipv4_tunn_en_flg;
64 u8 tpa_ipv6_tunn_en_flg;
65
66 u8 update_tpa_param_flg;
67 u8 tpa_pkt_split_flg;
68 u8 tpa_hdr_data_split_flg;
69 u8 tpa_gro_consistent_flg;
70 u8 tpa_max_aggs_num;
71 u16 tpa_max_size;
72 u16 tpa_min_size_to_start;
73 u16 tpa_min_size_to_cont;
74 };
75
76 enum qed_filter_opcode {
77 QED_FILTER_ADD,
78 QED_FILTER_REMOVE,
79 QED_FILTER_MOVE,
80 QED_FILTER_REPLACE,
81 QED_FILTER_FLUSH,
82 };
83
84 enum qed_filter_ucast_type {
85 QED_FILTER_MAC,
86 QED_FILTER_VLAN,
87 QED_FILTER_MAC_VLAN,
88 QED_FILTER_INNER_MAC,
89 QED_FILTER_INNER_VLAN,
90 QED_FILTER_INNER_PAIR,
91 QED_FILTER_INNER_MAC_VNI_PAIR,
92 QED_FILTER_MAC_VNI_PAIR,
93 QED_FILTER_VNI,
94 };
95
96 struct qed_filter_ucast {
97 enum qed_filter_opcode opcode;
98 enum qed_filter_ucast_type type;
99 u8 is_rx_filter;
100 u8 is_tx_filter;
101 u8 vport_to_add_to;
102 u8 vport_to_remove_from;
103 unsigned char mac[ETH_ALEN];
104 u8 assert_on_error;
105 u16 vlan;
106 u32 vni;
107 };
108
109 struct qed_filter_mcast {
110
111 enum qed_filter_opcode opcode;
112 u8 vport_to_add_to;
113 u8 vport_to_remove_from;
114 u8 num_mc_addrs;
115 #define QED_MAX_MC_ADDRS 64
116 unsigned char mac[QED_MAX_MC_ADDRS][ETH_ALEN];
117 };
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133 int
134 qed_eth_rx_queue_stop(struct qed_hwfn *p_hwfn,
135 void *p_rxq,
136 bool eq_completion_only, bool cqe_completion);
137
138
139
140
141
142
143
144
145
146 int qed_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, void *p_txq);
147
148 enum qed_tpa_mode {
149 QED_TPA_MODE_NONE,
150 QED_TPA_MODE_UNUSED,
151 QED_TPA_MODE_GRO,
152 QED_TPA_MODE_MAX
153 };
154
155 struct qed_sp_vport_start_params {
156 enum qed_tpa_mode tpa_mode;
157 bool remove_inner_vlan;
158 bool tx_switching;
159 bool handle_ptp_pkts;
160 bool only_untagged;
161 bool drop_ttl0;
162 u8 max_buffers_per_cqe;
163 u32 concrete_fid;
164 u16 opaque_fid;
165 u8 vport_id;
166 u16 mtu;
167 bool check_mac;
168 bool check_ethtype;
169 };
170
171 int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
172 struct qed_sp_vport_start_params *p_params);
173
174
175 struct qed_filter_accept_flags {
176 u8 update_rx_mode_config;
177 u8 update_tx_mode_config;
178 u8 rx_accept_filter;
179 u8 tx_accept_filter;
180 #define QED_ACCEPT_NONE 0x01
181 #define QED_ACCEPT_UCAST_MATCHED 0x02
182 #define QED_ACCEPT_UCAST_UNMATCHED 0x04
183 #define QED_ACCEPT_MCAST_MATCHED 0x08
184 #define QED_ACCEPT_MCAST_UNMATCHED 0x10
185 #define QED_ACCEPT_BCAST 0x20
186 #define QED_ACCEPT_ANY_VNI 0x40
187 };
188
189 struct qed_arfs_config_params {
190 bool tcp;
191 bool udp;
192 bool ipv4;
193 bool ipv6;
194 enum qed_filter_config_mode mode;
195 };
196
197 struct qed_sp_vport_update_params {
198 u16 opaque_fid;
199 u8 vport_id;
200 u8 update_vport_active_rx_flg;
201 u8 vport_active_rx_flg;
202 u8 update_vport_active_tx_flg;
203 u8 vport_active_tx_flg;
204 u8 update_inner_vlan_removal_flg;
205 u8 inner_vlan_removal_flg;
206 u8 silent_vlan_removal_flg;
207 u8 update_default_vlan_enable_flg;
208 u8 default_vlan_enable_flg;
209 u8 update_default_vlan_flg;
210 u16 default_vlan;
211 u8 update_tx_switching_flg;
212 u8 tx_switching_flg;
213 u8 update_approx_mcast_flg;
214 u8 update_anti_spoofing_en_flg;
215 u8 anti_spoofing_en;
216 u8 update_accept_any_vlan_flg;
217 u8 accept_any_vlan;
218 u32 bins[8];
219 struct qed_rss_params *rss_params;
220 struct qed_filter_accept_flags accept_flags;
221 struct qed_sge_tpa_params *sge_tpa_params;
222 u8 update_ctl_frame_check;
223 u8 mac_chk_en;
224 u8 ethtype_chk_en;
225 };
226
227 int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
228 struct qed_sp_vport_update_params *p_params,
229 enum spq_mode comp_mode,
230 struct qed_spq_comp_cb *p_comp_data);
231
232
233
234
235
236
237
238
239
240
241
242
243
244 int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id);
245
246 int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
247 u16 opaque_fid,
248 struct qed_filter_ucast *p_filter_cmd,
249 enum spq_mode comp_mode,
250 struct qed_spq_comp_cb *p_comp_data);
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271 int
272 qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
273 void **pp_rxq_handlers,
274 u8 num_rxqs,
275 u8 complete_cqe_flg,
276 u8 complete_event_flg,
277 enum spq_mode comp_mode,
278 struct qed_spq_comp_cb *p_comp_data);
279
280 void qed_get_vport_stats(struct qed_dev *cdev, struct qed_eth_stats *stats);
281
282 void qed_reset_vport_stats(struct qed_dev *cdev);
283
284
285
286
287
288
289
290
291
292
293
294
295 void qed_arfs_mode_configure(struct qed_hwfn *p_hwfn,
296 struct qed_ptt *p_ptt,
297 struct qed_arfs_config_params *p_cfg_params);
298
299
300
301
302
303
304
305
306
307
308
309
310 int
311 qed_configure_rfs_ntuple_filter(struct qed_hwfn *p_hwfn,
312 struct qed_spq_comp_cb *p_cb,
313 struct qed_ntuple_filter_params *p_params);
314
315 #define MAX_QUEUES_PER_QZONE (sizeof(unsigned long) * 8)
316 #define QED_QUEUE_CID_SELF (0xff)
317
318
319
320
321 struct qed_queue_cid_params {
322 u8 vport_id;
323 u16 queue_id;
324 u8 stats_id;
325 };
326
327
328
329
330 struct qed_queue_cid_vf_params {
331
332 u8 vfid;
333
334
335
336
337 u8 vf_qid;
338
339
340
341
342
343 u8 vf_legacy;
344
345 u8 qid_usage_idx;
346 };
347
348 struct qed_queue_cid {
349
350 struct qed_queue_cid_params rel;
351 struct qed_queue_cid_params abs;
352
353
354 u16 sb_igu_id;
355 u8 sb_idx;
356
357 u32 cid;
358 u16 opaque_fid;
359
360 bool b_is_rx;
361
362
363
364
365
366
367 u8 vfid;
368 u8 vf_qid;
369
370
371
372
373
374 u8 qid_usage_idx;
375
376 u8 vf_legacy;
377 #define QED_QCID_LEGACY_VF_RX_PROD (BIT(0))
378 #define QED_QCID_LEGACY_VF_CID (BIT(1))
379
380 struct qed_hwfn *p_owner;
381 };
382
383 int qed_l2_alloc(struct qed_hwfn *p_hwfn);
384 void qed_l2_setup(struct qed_hwfn *p_hwfn);
385 void qed_l2_free(struct qed_hwfn *p_hwfn);
386
387 void qed_eth_queue_cid_release(struct qed_hwfn *p_hwfn,
388 struct qed_queue_cid *p_cid);
389
390 struct qed_queue_cid *
391 qed_eth_queue_to_cid(struct qed_hwfn *p_hwfn,
392 u16 opaque_fid,
393 struct qed_queue_start_common_params *p_params,
394 bool b_is_rx,
395 struct qed_queue_cid_vf_params *p_vf_params);
396
397 int
398 qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
399 struct qed_sp_vport_start_params *p_params);
400
401
402
403
404
405
406
407
408
409
410
411
412
413 int
414 qed_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
415 struct qed_queue_cid *p_cid,
416 u16 bd_max_bytes,
417 dma_addr_t bd_chain_phys_addr,
418 dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size);
419
420
421
422
423
424
425
426
427
428
429
430
431 int
432 qed_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn,
433 struct qed_queue_cid *p_cid,
434 dma_addr_t pbl_addr, u16 pbl_size, u16 pq_id);
435
436 u8 qed_mcast_bin_from_mac(u8 *mac);
437
438 int qed_set_rxq_coalesce(struct qed_hwfn *p_hwfn,
439 struct qed_ptt *p_ptt,
440 u16 coalesce, struct qed_queue_cid *p_cid);
441
442 int qed_set_txq_coalesce(struct qed_hwfn *p_hwfn,
443 struct qed_ptt *p_ptt,
444 u16 coalesce, struct qed_queue_cid *p_cid);
445
446 int qed_get_rxq_coalesce(struct qed_hwfn *p_hwfn,
447 struct qed_ptt *p_ptt,
448 struct qed_queue_cid *p_cid, u16 *p_hw_coal);
449
450 int qed_get_txq_coalesce(struct qed_hwfn *p_hwfn,
451 struct qed_ptt *p_ptt,
452 struct qed_queue_cid *p_cid, u16 *p_hw_coal);
453
454 #endif