net/sfc/base: import SFN7xxx family support
[dpdk.git] / drivers / net / sfc / base / efx.h
1 /*
2  * Copyright (c) 2006-2016 Solarflare Communications Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  *    this list of conditions and the following disclaimer in the documentation
12  *    and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * The views and conclusions contained in the software and documentation are
27  * those of the authors and should not be interpreted as representing official
28  * policies, either expressed or implied, of the FreeBSD Project.
29  */
30
31 #ifndef _SYS_EFX_H
32 #define _SYS_EFX_H
33
34 #include "efsys.h"
35 #include "efx_check.h"
36 #include "efx_phy_ids.h"
37
38 #ifdef  __cplusplus
39 extern "C" {
40 #endif
41
42 #define EFX_STATIC_ASSERT(_cond)                \
43         ((void)sizeof(char[(_cond) ? 1 : -1]))
44
45 #define EFX_ARRAY_SIZE(_array)                  \
46         (sizeof(_array) / sizeof((_array)[0]))
47
48 #define EFX_FIELD_OFFSET(_type, _field)         \
49         ((size_t) &(((_type *)0)->_field))
50
51 /* Return codes */
52
53 typedef __success(return == 0) int efx_rc_t;
54
55
56 /* Chip families */
57
58 typedef enum efx_family_e {
59         EFX_FAMILY_INVALID,
60         EFX_FAMILY_FALCON,      /* Obsolete and not supported */
61         EFX_FAMILY_SIENA,
62         EFX_FAMILY_HUNTINGTON,
63         EFX_FAMILY_MEDFORD,
64         EFX_FAMILY_NTYPES
65 } efx_family_t;
66
67 extern  __checkReturn   efx_rc_t
68 efx_family(
69         __in            uint16_t venid,
70         __in            uint16_t devid,
71         __out           efx_family_t *efp);
72
73
74 #define EFX_PCI_VENID_SFC                       0x1924
75
76 #define EFX_PCI_DEVID_FALCON                    0x0710  /* SFC4000 */
77
78 #define EFX_PCI_DEVID_BETHPAGE                  0x0803  /* SFC9020 */
79 #define EFX_PCI_DEVID_SIENA                     0x0813  /* SFL9021 */
80 #define EFX_PCI_DEVID_SIENA_F1_UNINIT           0x0810
81
82 #define EFX_PCI_DEVID_HUNTINGTON_PF_UNINIT      0x0901
83 #define EFX_PCI_DEVID_FARMINGDALE               0x0903  /* SFC9120 PF */
84 #define EFX_PCI_DEVID_GREENPORT                 0x0923  /* SFC9140 PF */
85
86 #define EFX_PCI_DEVID_FARMINGDALE_VF            0x1903  /* SFC9120 VF */
87 #define EFX_PCI_DEVID_GREENPORT_VF              0x1923  /* SFC9140 VF */
88
89 #define EFX_PCI_DEVID_MEDFORD_PF_UNINIT         0x0913
90 #define EFX_PCI_DEVID_MEDFORD                   0x0A03  /* SFC9240 PF */
91 #define EFX_PCI_DEVID_MEDFORD_VF                0x1A03  /* SFC9240 VF */
92
93 #define EFX_MEM_BAR     2
94
95 /* Error codes */
96
97 enum {
98         EFX_ERR_INVALID,
99         EFX_ERR_SRAM_OOB,
100         EFX_ERR_BUFID_DC_OOB,
101         EFX_ERR_MEM_PERR,
102         EFX_ERR_RBUF_OWN,
103         EFX_ERR_TBUF_OWN,
104         EFX_ERR_RDESQ_OWN,
105         EFX_ERR_TDESQ_OWN,
106         EFX_ERR_EVQ_OWN,
107         EFX_ERR_EVFF_OFLO,
108         EFX_ERR_ILL_ADDR,
109         EFX_ERR_SRAM_PERR,
110         EFX_ERR_NCODES
111 };
112
113 /* Calculate the IEEE 802.3 CRC32 of a MAC addr */
114 extern  __checkReturn           uint32_t
115 efx_crc32_calculate(
116         __in                    uint32_t crc_init,
117         __in_ecount(length)     uint8_t const *input,
118         __in                    int length);
119
120
121 /* Type prototypes */
122
123 typedef struct efx_rxq_s        efx_rxq_t;
124
125 /* NIC */
126
127 typedef struct efx_nic_s        efx_nic_t;
128
129 extern  __checkReturn   efx_rc_t
130 efx_nic_create(
131         __in            efx_family_t family,
132         __in            efsys_identifier_t *esip,
133         __in            efsys_bar_t *esbp,
134         __in            efsys_lock_t *eslp,
135         __deref_out     efx_nic_t **enpp);
136
137 extern  __checkReturn   efx_rc_t
138 efx_nic_probe(
139         __in            efx_nic_t *enp);
140
141 extern  __checkReturn   efx_rc_t
142 efx_nic_init(
143         __in            efx_nic_t *enp);
144
145 extern  __checkReturn   efx_rc_t
146 efx_nic_reset(
147         __in            efx_nic_t *enp);
148
149 extern          void
150 efx_nic_fini(
151         __in            efx_nic_t *enp);
152
153 extern          void
154 efx_nic_unprobe(
155         __in            efx_nic_t *enp);
156
157 extern          void
158 efx_nic_destroy(
159         __in    efx_nic_t *enp);
160
161 #define EFX_PCIE_LINK_SPEED_GEN1                1
162 #define EFX_PCIE_LINK_SPEED_GEN2                2
163 #define EFX_PCIE_LINK_SPEED_GEN3                3
164
165 typedef enum efx_pcie_link_performance_e {
166         EFX_PCIE_LINK_PERFORMANCE_UNKNOWN_BANDWIDTH,
167         EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_BANDWIDTH,
168         EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_LATENCY,
169         EFX_PCIE_LINK_PERFORMANCE_OPTIMAL
170 } efx_pcie_link_performance_t;
171
172 extern  __checkReturn   efx_rc_t
173 efx_nic_calculate_pcie_link_bandwidth(
174         __in            uint32_t pcie_link_width,
175         __in            uint32_t pcie_link_gen,
176         __out           uint32_t *bandwidth_mbpsp);
177
178 extern  __checkReturn   efx_rc_t
179 efx_nic_check_pcie_link_speed(
180         __in            efx_nic_t *enp,
181         __in            uint32_t pcie_link_width,
182         __in            uint32_t pcie_link_gen,
183         __out           efx_pcie_link_performance_t *resultp);
184
185 #if EFSYS_OPT_MCDI
186
187 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
188 /* Huntington and Medford require MCDIv2 commands */
189 #define WITH_MCDI_V2 1
190 #endif
191
192 typedef struct efx_mcdi_req_s efx_mcdi_req_t;
193
194 typedef enum efx_mcdi_exception_e {
195         EFX_MCDI_EXCEPTION_MC_REBOOT,
196         EFX_MCDI_EXCEPTION_MC_BADASSERT,
197 } efx_mcdi_exception_t;
198
199 #if EFSYS_OPT_MCDI_LOGGING
200 typedef enum efx_log_msg_e {
201         EFX_LOG_INVALID,
202         EFX_LOG_MCDI_REQUEST,
203         EFX_LOG_MCDI_RESPONSE,
204 } efx_log_msg_t;
205 #endif /* EFSYS_OPT_MCDI_LOGGING */
206
207 typedef struct efx_mcdi_transport_s {
208         void            *emt_context;
209         efsys_mem_t     *emt_dma_mem;
210         void            (*emt_execute)(void *, efx_mcdi_req_t *);
211         void            (*emt_ev_cpl)(void *);
212         void            (*emt_exception)(void *, efx_mcdi_exception_t);
213 #if EFSYS_OPT_MCDI_LOGGING
214         void            (*emt_logger)(void *, efx_log_msg_t,
215                                         void *, size_t, void *, size_t);
216 #endif /* EFSYS_OPT_MCDI_LOGGING */
217 #if EFSYS_OPT_MCDI_PROXY_AUTH
218         void            (*emt_ev_proxy_response)(void *, uint32_t, efx_rc_t);
219 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
220 } efx_mcdi_transport_t;
221
222 extern  __checkReturn   efx_rc_t
223 efx_mcdi_init(
224         __in            efx_nic_t *enp,
225         __in            const efx_mcdi_transport_t *mtp);
226
227 extern  __checkReturn   efx_rc_t
228 efx_mcdi_reboot(
229         __in            efx_nic_t *enp);
230
231                         void
232 efx_mcdi_new_epoch(
233         __in            efx_nic_t *enp);
234
235 extern                  void
236 efx_mcdi_get_timeout(
237         __in            efx_nic_t *enp,
238         __in            efx_mcdi_req_t *emrp,
239         __out           uint32_t *usec_timeoutp);
240
241 extern                  void
242 efx_mcdi_request_start(
243         __in            efx_nic_t *enp,
244         __in            efx_mcdi_req_t *emrp,
245         __in            boolean_t ev_cpl);
246
247 extern  __checkReturn   boolean_t
248 efx_mcdi_request_poll(
249         __in            efx_nic_t *enp);
250
251 extern  __checkReturn   boolean_t
252 efx_mcdi_request_abort(
253         __in            efx_nic_t *enp);
254
255 extern                  void
256 efx_mcdi_fini(
257         __in            efx_nic_t *enp);
258
259 #endif  /* EFSYS_OPT_MCDI */
260
261 /* INTR */
262
263 #define EFX_NINTR_SIENA 1024
264
265 typedef enum efx_intr_type_e {
266         EFX_INTR_INVALID = 0,
267         EFX_INTR_LINE,
268         EFX_INTR_MESSAGE,
269         EFX_INTR_NTYPES
270 } efx_intr_type_t;
271
272 #define EFX_INTR_SIZE   (sizeof (efx_oword_t))
273
274 extern  __checkReturn   efx_rc_t
275 efx_intr_init(
276         __in            efx_nic_t *enp,
277         __in            efx_intr_type_t type,
278         __in            efsys_mem_t *esmp);
279
280 extern                  void
281 efx_intr_enable(
282         __in            efx_nic_t *enp);
283
284 extern                  void
285 efx_intr_disable(
286         __in            efx_nic_t *enp);
287
288 extern                  void
289 efx_intr_disable_unlocked(
290         __in            efx_nic_t *enp);
291
292 #define EFX_INTR_NEVQS  32
293
294 extern  __checkReturn   efx_rc_t
295 efx_intr_trigger(
296         __in            efx_nic_t *enp,
297         __in            unsigned int level);
298
299 extern                  void
300 efx_intr_status_line(
301         __in            efx_nic_t *enp,
302         __out           boolean_t *fatalp,
303         __out           uint32_t *maskp);
304
305 extern                  void
306 efx_intr_status_message(
307         __in            efx_nic_t *enp,
308         __in            unsigned int message,
309         __out           boolean_t *fatalp);
310
311 extern                  void
312 efx_intr_fatal(
313         __in            efx_nic_t *enp);
314
315 extern                  void
316 efx_intr_fini(
317         __in            efx_nic_t *enp);
318
319 /* MAC */
320
321 typedef enum efx_link_mode_e {
322         EFX_LINK_UNKNOWN = 0,
323         EFX_LINK_DOWN,
324         EFX_LINK_10HDX,
325         EFX_LINK_10FDX,
326         EFX_LINK_100HDX,
327         EFX_LINK_100FDX,
328         EFX_LINK_1000HDX,
329         EFX_LINK_1000FDX,
330         EFX_LINK_10000FDX,
331         EFX_LINK_40000FDX,
332         EFX_LINK_NMODES
333 } efx_link_mode_t;
334
335 #define EFX_MAC_ADDR_LEN 6
336
337 #define EFX_MAC_ADDR_IS_MULTICAST(_address) (((uint8_t *)_address)[0] & 0x01)
338
339 #define EFX_MAC_MULTICAST_LIST_MAX      256
340
341 #define EFX_MAC_SDU_MAX 9202
342
343 #define EFX_MAC_PDU_ADJUSTMENT                                  \
344         (/* EtherII */ 14                                       \
345             + /* VLAN */ 4                                      \
346             + /* CRC */ 4                                       \
347             + /* bug16011 */ 16)                                \
348
349 #define EFX_MAC_PDU(_sdu)                                       \
350         P2ROUNDUP((_sdu) + EFX_MAC_PDU_ADJUSTMENT, 8)
351
352 /*
353  * Due to the P2ROUNDUP in EFX_MAC_PDU(), EFX_MAC_SDU_FROM_PDU() may give
354  * the SDU rounded up slightly.
355  */
356 #define EFX_MAC_SDU_FROM_PDU(_pdu)      ((_pdu) - EFX_MAC_PDU_ADJUSTMENT)
357
358 #define EFX_MAC_PDU_MIN 60
359 #define EFX_MAC_PDU_MAX EFX_MAC_PDU(EFX_MAC_SDU_MAX)
360
361 extern  __checkReturn   efx_rc_t
362 efx_mac_pdu_get(
363         __in            efx_nic_t *enp,
364         __out           size_t *pdu);
365
366 extern  __checkReturn   efx_rc_t
367 efx_mac_pdu_set(
368         __in            efx_nic_t *enp,
369         __in            size_t pdu);
370
371 extern  __checkReturn   efx_rc_t
372 efx_mac_addr_set(
373         __in            efx_nic_t *enp,
374         __in            uint8_t *addr);
375
376 extern  __checkReturn                   efx_rc_t
377 efx_mac_filter_set(
378         __in                            efx_nic_t *enp,
379         __in                            boolean_t all_unicst,
380         __in                            boolean_t mulcst,
381         __in                            boolean_t all_mulcst,
382         __in                            boolean_t brdcst);
383
384 extern  __checkReturn   efx_rc_t
385 efx_mac_multicast_list_set(
386         __in                            efx_nic_t *enp,
387         __in_ecount(6*count)            uint8_t const *addrs,
388         __in                            int count);
389
390 extern  __checkReturn   efx_rc_t
391 efx_mac_filter_default_rxq_set(
392         __in            efx_nic_t *enp,
393         __in            efx_rxq_t *erp,
394         __in            boolean_t using_rss);
395
396 extern                  void
397 efx_mac_filter_default_rxq_clear(
398         __in            efx_nic_t *enp);
399
400 extern  __checkReturn   efx_rc_t
401 efx_mac_drain(
402         __in            efx_nic_t *enp,
403         __in            boolean_t enabled);
404
405 extern  __checkReturn   efx_rc_t
406 efx_mac_up(
407         __in            efx_nic_t *enp,
408         __out           boolean_t *mac_upp);
409
410 #define EFX_FCNTL_RESPOND       0x00000001
411 #define EFX_FCNTL_GENERATE      0x00000002
412
413 extern  __checkReturn   efx_rc_t
414 efx_mac_fcntl_set(
415         __in            efx_nic_t *enp,
416         __in            unsigned int fcntl,
417         __in            boolean_t autoneg);
418
419 extern                  void
420 efx_mac_fcntl_get(
421         __in            efx_nic_t *enp,
422         __out           unsigned int *fcntl_wantedp,
423         __out           unsigned int *fcntl_linkp);
424
425
426 /* MON */
427
428 typedef enum efx_mon_type_e {
429         EFX_MON_INVALID = 0,
430         EFX_MON_SFC90X0,
431         EFX_MON_SFC91X0,
432         EFX_MON_SFC92X0,
433         EFX_MON_NTYPES
434 } efx_mon_type_t;
435
436 #if EFSYS_OPT_NAMES
437
438 extern          const char *
439 efx_mon_name(
440         __in    efx_nic_t *enp);
441
442 #endif  /* EFSYS_OPT_NAMES */
443
444 extern  __checkReturn   efx_rc_t
445 efx_mon_init(
446         __in            efx_nic_t *enp);
447
448 extern          void
449 efx_mon_fini(
450         __in    efx_nic_t *enp);
451
452 /* PHY */
453
454 extern  __checkReturn   efx_rc_t
455 efx_phy_verify(
456         __in            efx_nic_t *enp);
457
458 extern  __checkReturn   efx_rc_t
459 efx_port_init(
460         __in            efx_nic_t *enp);
461
462 extern  __checkReturn   efx_rc_t
463 efx_port_poll(
464         __in            efx_nic_t *enp,
465         __out_opt       efx_link_mode_t *link_modep);
466
467 extern          void
468 efx_port_fini(
469         __in    efx_nic_t *enp);
470
471 typedef enum efx_phy_cap_type_e {
472         EFX_PHY_CAP_INVALID = 0,
473         EFX_PHY_CAP_10HDX,
474         EFX_PHY_CAP_10FDX,
475         EFX_PHY_CAP_100HDX,
476         EFX_PHY_CAP_100FDX,
477         EFX_PHY_CAP_1000HDX,
478         EFX_PHY_CAP_1000FDX,
479         EFX_PHY_CAP_10000FDX,
480         EFX_PHY_CAP_PAUSE,
481         EFX_PHY_CAP_ASYM,
482         EFX_PHY_CAP_AN,
483         EFX_PHY_CAP_40000FDX,
484         EFX_PHY_CAP_NTYPES
485 } efx_phy_cap_type_t;
486
487
488 #define EFX_PHY_CAP_CURRENT     0x00000000
489 #define EFX_PHY_CAP_DEFAULT     0x00000001
490 #define EFX_PHY_CAP_PERM        0x00000002
491
492 extern          void
493 efx_phy_adv_cap_get(
494         __in            efx_nic_t *enp,
495         __in            uint32_t flag,
496         __out           uint32_t *maskp);
497
498 extern  __checkReturn   efx_rc_t
499 efx_phy_adv_cap_set(
500         __in            efx_nic_t *enp,
501         __in            uint32_t mask);
502
503 extern                  void
504 efx_phy_lp_cap_get(
505         __in            efx_nic_t *enp,
506         __out           uint32_t *maskp);
507
508 extern  __checkReturn   efx_rc_t
509 efx_phy_oui_get(
510         __in            efx_nic_t *enp,
511         __out           uint32_t *ouip);
512
513 typedef enum efx_phy_media_type_e {
514         EFX_PHY_MEDIA_INVALID = 0,
515         EFX_PHY_MEDIA_XAUI,
516         EFX_PHY_MEDIA_CX4,
517         EFX_PHY_MEDIA_KX4,
518         EFX_PHY_MEDIA_XFP,
519         EFX_PHY_MEDIA_SFP_PLUS,
520         EFX_PHY_MEDIA_BASE_T,
521         EFX_PHY_MEDIA_QSFP_PLUS,
522         EFX_PHY_MEDIA_NTYPES
523 } efx_phy_media_type_t;
524
525 /* Get the type of medium currently used.  If the board has ports for
526  * modules, a module is present, and we recognise the media type of
527  * the module, then this will be the media type of the module.
528  * Otherwise it will be the media type of the port.
529  */
530 extern                  void
531 efx_phy_media_type_get(
532         __in            efx_nic_t *enp,
533         __out           efx_phy_media_type_t *typep);
534
535 extern                                  efx_rc_t
536 efx_phy_module_get_info(
537         __in                            efx_nic_t *enp,
538         __in                            uint8_t dev_addr,
539         __in                            uint8_t offset,
540         __in                            uint8_t len,
541         __out_bcount(len)               uint8_t *data);
542
543
544 #define EFX_FEATURE_IPV6                0x00000001
545 #define EFX_FEATURE_LFSR_HASH_INSERT    0x00000002
546 #define EFX_FEATURE_LINK_EVENTS         0x00000004
547 #define EFX_FEATURE_PERIODIC_MAC_STATS  0x00000008
548 #define EFX_FEATURE_MCDI                0x00000020
549 #define EFX_FEATURE_LOOKAHEAD_SPLIT     0x00000040
550 #define EFX_FEATURE_MAC_HEADER_FILTERS  0x00000080
551 #define EFX_FEATURE_TURBO               0x00000100
552 #define EFX_FEATURE_MCDI_DMA            0x00000200
553 #define EFX_FEATURE_TX_SRC_FILTERS      0x00000400
554 #define EFX_FEATURE_PIO_BUFFERS         0x00000800
555 #define EFX_FEATURE_FW_ASSISTED_TSO     0x00001000
556 #define EFX_FEATURE_FW_ASSISTED_TSO_V2  0x00002000
557 #define EFX_FEATURE_PACKED_STREAM       0x00004000
558
559 typedef struct efx_nic_cfg_s {
560         uint32_t                enc_board_type;
561         uint32_t                enc_phy_type;
562 #if EFSYS_OPT_NAMES
563         char                    enc_phy_name[21];
564 #endif
565         char                    enc_phy_revision[21];
566         efx_mon_type_t          enc_mon_type;
567         unsigned int            enc_features;
568         uint8_t                 enc_mac_addr[6];
569         uint8_t                 enc_port;       /* PHY port number */
570         uint32_t                enc_intr_vec_base;
571         uint32_t                enc_intr_limit;
572         uint32_t                enc_evq_limit;
573         uint32_t                enc_txq_limit;
574         uint32_t                enc_rxq_limit;
575         uint32_t                enc_txq_max_ndescs;
576         uint32_t                enc_buftbl_limit;
577         uint32_t                enc_piobuf_limit;
578         uint32_t                enc_piobuf_size;
579         uint32_t                enc_piobuf_min_alloc_size;
580         uint32_t                enc_evq_timer_quantum_ns;
581         uint32_t                enc_evq_timer_max_us;
582         uint32_t                enc_clk_mult;
583         uint32_t                enc_rx_prefix_size;
584         uint32_t                enc_rx_buf_align_start;
585         uint32_t                enc_rx_buf_align_end;
586 #if EFSYS_OPT_MCDI
587         uint8_t                 enc_mcdi_mdio_channel;
588 #endif  /* EFSYS_OPT_MCDI */
589 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
590         uint32_t                enc_pf;
591         uint32_t                enc_vf;
592         uint32_t                enc_privilege_mask;
593 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
594         boolean_t               enc_bug26807_workaround;
595         boolean_t               enc_bug35388_workaround;
596         boolean_t               enc_bug41750_workaround;
597         boolean_t               enc_bug61265_workaround;
598         boolean_t               enc_rx_batching_enabled;
599         /* Maximum number of descriptors completed in an rx event. */
600         uint32_t                enc_rx_batch_max;
601         /* Number of rx descriptors the hardware requires for a push. */
602         uint32_t                enc_rx_push_align;
603         /*
604          * Maximum number of bytes into the packet the TCP header can start for
605          * the hardware to apply TSO packet edits.
606          */
607         uint32_t                enc_tx_tso_tcp_header_offset_limit;
608         boolean_t               enc_fw_assisted_tso_enabled;
609         boolean_t               enc_fw_assisted_tso_v2_enabled;
610         /* Number of TSO contexts on the NIC (FATSOv2) */
611         uint32_t                enc_fw_assisted_tso_v2_n_contexts;
612         boolean_t               enc_hw_tx_insert_vlan_enabled;
613         /* Number of PFs on the NIC */
614         uint32_t                enc_hw_pf_count;
615         /* Datapath firmware vadapter/vport/vswitch support */
616         boolean_t               enc_datapath_cap_evb;
617         boolean_t               enc_rx_disable_scatter_supported;
618         boolean_t               enc_allow_set_mac_with_installed_filters;
619         boolean_t               enc_enhanced_set_mac_supported;
620         boolean_t               enc_init_evq_v2_supported;
621         boolean_t               enc_rx_packed_stream_supported;
622         boolean_t               enc_rx_var_packed_stream_supported;
623         boolean_t               enc_pm_and_rxdp_counters;
624         boolean_t               enc_mac_stats_40g_tx_size_bins;
625         /* External port identifier */
626         uint8_t                 enc_external_port;
627         uint32_t                enc_mcdi_max_payload_length;
628         /* VPD may be per-PF or global */
629         boolean_t               enc_vpd_is_global;
630         /* Minimum unidirectional bandwidth in Mb/s to max out all ports */
631         uint32_t                enc_required_pcie_bandwidth_mbps;
632         uint32_t                enc_max_pcie_link_gen;
633         /* Firmware verifies integrity of NVRAM updates */
634         uint32_t                enc_fw_verified_nvram_update_required;
635 } efx_nic_cfg_t;
636
637 #define EFX_PCI_FUNCTION_IS_PF(_encp)   ((_encp)->enc_vf == 0xffff)
638 #define EFX_PCI_FUNCTION_IS_VF(_encp)   ((_encp)->enc_vf != 0xffff)
639
640 #define EFX_PCI_FUNCTION(_encp) \
641         (EFX_PCI_FUNCTION_IS_PF(_encp) ? (_encp)->enc_pf : (_encp)->enc_vf)
642
643 #define EFX_PCI_VF_PARENT(_encp)        ((_encp)->enc_pf)
644
645 extern                  const efx_nic_cfg_t *
646 efx_nic_cfg_get(
647         __in            efx_nic_t *enp);
648
649 /* Driver resource limits (minimum required/maximum usable). */
650 typedef struct efx_drv_limits_s {
651         uint32_t        edl_min_evq_count;
652         uint32_t        edl_max_evq_count;
653
654         uint32_t        edl_min_rxq_count;
655         uint32_t        edl_max_rxq_count;
656
657         uint32_t        edl_min_txq_count;
658         uint32_t        edl_max_txq_count;
659
660         /* PIO blocks (sub-allocated from piobuf) */
661         uint32_t        edl_min_pio_alloc_size;
662         uint32_t        edl_max_pio_alloc_count;
663 } efx_drv_limits_t;
664
665 extern  __checkReturn   efx_rc_t
666 efx_nic_set_drv_limits(
667         __inout         efx_nic_t *enp,
668         __in            efx_drv_limits_t *edlp);
669
670 typedef enum efx_nic_region_e {
671         EFX_REGION_VI,                  /* Memory BAR UC mapping */
672         EFX_REGION_PIO_WRITE_VI,        /* Memory BAR WC mapping */
673 } efx_nic_region_t;
674
675 extern  __checkReturn   efx_rc_t
676 efx_nic_get_bar_region(
677         __in            efx_nic_t *enp,
678         __in            efx_nic_region_t region,
679         __out           uint32_t *offsetp,
680         __out           size_t *sizep);
681
682 extern  __checkReturn   efx_rc_t
683 efx_nic_get_vi_pool(
684         __in            efx_nic_t *enp,
685         __out           uint32_t *evq_countp,
686         __out           uint32_t *rxq_countp,
687         __out           uint32_t *txq_countp);
688
689
690 /* NVRAM */
691
692 extern  __checkReturn   efx_rc_t
693 efx_sram_buf_tbl_set(
694         __in            efx_nic_t *enp,
695         __in            uint32_t id,
696         __in            efsys_mem_t *esmp,
697         __in            size_t n);
698
699 extern          void
700 efx_sram_buf_tbl_clear(
701         __in    efx_nic_t *enp,
702         __in    uint32_t id,
703         __in    size_t n);
704
705 #define EFX_BUF_TBL_SIZE        0x20000
706
707 #define EFX_BUF_SIZE            4096
708
709 /* EV */
710
711 typedef struct efx_evq_s        efx_evq_t;
712
713 extern  __checkReturn   efx_rc_t
714 efx_ev_init(
715         __in            efx_nic_t *enp);
716
717 extern          void
718 efx_ev_fini(
719         __in            efx_nic_t *enp);
720
721 #define EFX_EVQ_MAXNEVS         32768
722 #define EFX_EVQ_MINNEVS         512
723
724 #define EFX_EVQ_SIZE(_nevs)     ((_nevs) * sizeof (efx_qword_t))
725 #define EFX_EVQ_NBUFS(_nevs)    (EFX_EVQ_SIZE(_nevs) / EFX_BUF_SIZE)
726
727 #define EFX_EVQ_FLAGS_TYPE_MASK         (0x3)
728 #define EFX_EVQ_FLAGS_TYPE_AUTO         (0x0)
729 #define EFX_EVQ_FLAGS_TYPE_THROUGHPUT   (0x1)
730 #define EFX_EVQ_FLAGS_TYPE_LOW_LATENCY  (0x2)
731
732 #define EFX_EVQ_FLAGS_NOTIFY_MASK       (0xC)
733 #define EFX_EVQ_FLAGS_NOTIFY_INTERRUPT  (0x0)   /* Interrupting (default) */
734 #define EFX_EVQ_FLAGS_NOTIFY_DISABLED   (0x4)   /* Non-interrupting */
735
736 extern  __checkReturn   efx_rc_t
737 efx_ev_qcreate(
738         __in            efx_nic_t *enp,
739         __in            unsigned int index,
740         __in            efsys_mem_t *esmp,
741         __in            size_t n,
742         __in            uint32_t id,
743         __in            uint32_t us,
744         __in            uint32_t flags,
745         __deref_out     efx_evq_t **eepp);
746
747 extern          void
748 efx_ev_qpost(
749         __in            efx_evq_t *eep,
750         __in            uint16_t data);
751
752 typedef __checkReturn   boolean_t
753 (*efx_initialized_ev_t)(
754         __in_opt        void *arg);
755
756 #define EFX_PKT_UNICAST         0x0004
757 #define EFX_PKT_START           0x0008
758
759 #define EFX_PKT_VLAN_TAGGED     0x0010
760 #define EFX_CKSUM_TCPUDP        0x0020
761 #define EFX_CKSUM_IPV4          0x0040
762 #define EFX_PKT_CONT            0x0080
763
764 #define EFX_CHECK_VLAN          0x0100
765 #define EFX_PKT_TCP             0x0200
766 #define EFX_PKT_UDP             0x0400
767 #define EFX_PKT_IPV4            0x0800
768
769 #define EFX_PKT_IPV6            0x1000
770 #define EFX_PKT_PREFIX_LEN      0x2000
771 #define EFX_ADDR_MISMATCH       0x4000
772 #define EFX_DISCARD             0x8000
773
774 /*
775  * The following flags are used only for packed stream
776  * mode. The values for the flags are reused to fit into 16 bit,
777  * since EFX_PKT_START and EFX_PKT_CONT are never used in
778  * packed stream mode
779  */
780 #define EFX_PKT_PACKED_STREAM_NEW_BUFFER        EFX_PKT_START
781 #define EFX_PKT_PACKED_STREAM_PARSE_INCOMPLETE  EFX_PKT_CONT
782
783
784 #define EFX_EV_RX_NLABELS       32
785 #define EFX_EV_TX_NLABELS       32
786
787 typedef __checkReturn   boolean_t
788 (*efx_rx_ev_t)(
789         __in_opt        void *arg,
790         __in            uint32_t label,
791         __in            uint32_t id,
792         __in            uint32_t size,
793         __in            uint16_t flags);
794
795 typedef __checkReturn   boolean_t
796 (*efx_tx_ev_t)(
797         __in_opt        void *arg,
798         __in            uint32_t label,
799         __in            uint32_t id);
800
801 #define EFX_EXCEPTION_RX_RECOVERY       0x00000001
802 #define EFX_EXCEPTION_RX_DSC_ERROR      0x00000002
803 #define EFX_EXCEPTION_TX_DSC_ERROR      0x00000003
804 #define EFX_EXCEPTION_UNKNOWN_SENSOREVT 0x00000004
805 #define EFX_EXCEPTION_FWALERT_SRAM      0x00000005
806 #define EFX_EXCEPTION_UNKNOWN_FWALERT   0x00000006
807 #define EFX_EXCEPTION_RX_ERROR          0x00000007
808 #define EFX_EXCEPTION_TX_ERROR          0x00000008
809 #define EFX_EXCEPTION_EV_ERROR          0x00000009
810
811 typedef __checkReturn   boolean_t
812 (*efx_exception_ev_t)(
813         __in_opt        void *arg,
814         __in            uint32_t label,
815         __in            uint32_t data);
816
817 typedef __checkReturn   boolean_t
818 (*efx_rxq_flush_done_ev_t)(
819         __in_opt        void *arg,
820         __in            uint32_t rxq_index);
821
822 typedef __checkReturn   boolean_t
823 (*efx_rxq_flush_failed_ev_t)(
824         __in_opt        void *arg,
825         __in            uint32_t rxq_index);
826
827 typedef __checkReturn   boolean_t
828 (*efx_txq_flush_done_ev_t)(
829         __in_opt        void *arg,
830         __in            uint32_t txq_index);
831
832 typedef __checkReturn   boolean_t
833 (*efx_software_ev_t)(
834         __in_opt        void *arg,
835         __in            uint16_t magic);
836
837 typedef __checkReturn   boolean_t
838 (*efx_sram_ev_t)(
839         __in_opt        void *arg,
840         __in            uint32_t code);
841
842 #define EFX_SRAM_CLEAR          0
843 #define EFX_SRAM_UPDATE         1
844 #define EFX_SRAM_ILLEGAL_CLEAR  2
845
846 typedef __checkReturn   boolean_t
847 (*efx_wake_up_ev_t)(
848         __in_opt        void *arg,
849         __in            uint32_t label);
850
851 typedef __checkReturn   boolean_t
852 (*efx_timer_ev_t)(
853         __in_opt        void *arg,
854         __in            uint32_t label);
855
856 typedef __checkReturn   boolean_t
857 (*efx_link_change_ev_t)(
858         __in_opt        void *arg,
859         __in            efx_link_mode_t link_mode);
860
861 typedef struct efx_ev_callbacks_s {
862         efx_initialized_ev_t            eec_initialized;
863         efx_rx_ev_t                     eec_rx;
864         efx_tx_ev_t                     eec_tx;
865         efx_exception_ev_t              eec_exception;
866         efx_rxq_flush_done_ev_t         eec_rxq_flush_done;
867         efx_rxq_flush_failed_ev_t       eec_rxq_flush_failed;
868         efx_txq_flush_done_ev_t         eec_txq_flush_done;
869         efx_software_ev_t               eec_software;
870         efx_sram_ev_t                   eec_sram;
871         efx_wake_up_ev_t                eec_wake_up;
872         efx_timer_ev_t                  eec_timer;
873         efx_link_change_ev_t            eec_link_change;
874 } efx_ev_callbacks_t;
875
876 extern  __checkReturn   boolean_t
877 efx_ev_qpending(
878         __in            efx_evq_t *eep,
879         __in            unsigned int count);
880
881 extern                  void
882 efx_ev_qpoll(
883         __in            efx_evq_t *eep,
884         __inout         unsigned int *countp,
885         __in            const efx_ev_callbacks_t *eecp,
886         __in_opt        void *arg);
887
888 extern  __checkReturn   efx_rc_t
889 efx_ev_usecs_to_ticks(
890         __in            efx_nic_t *enp,
891         __in            unsigned int usecs,
892         __out           unsigned int *ticksp);
893
894 extern  __checkReturn   efx_rc_t
895 efx_ev_qmoderate(
896         __in            efx_evq_t *eep,
897         __in            unsigned int us);
898
899 extern  __checkReturn   efx_rc_t
900 efx_ev_qprime(
901         __in            efx_evq_t *eep,
902         __in            unsigned int count);
903
904 extern          void
905 efx_ev_qdestroy(
906         __in    efx_evq_t *eep);
907
908 /* RX */
909
910 extern  __checkReturn   efx_rc_t
911 efx_rx_init(
912         __inout         efx_nic_t *enp);
913
914 extern          void
915 efx_rx_fini(
916         __in            efx_nic_t *enp);
917
918 extern  __checkReturn   efx_rc_t
919 efx_pseudo_hdr_pkt_length_get(
920         __in            efx_rxq_t *erp,
921         __in            uint8_t *buffer,
922         __out           uint16_t *pkt_lengthp);
923
924 #define EFX_RXQ_MAXNDESCS               4096
925 #define EFX_RXQ_MINNDESCS               512
926
927 #define EFX_RXQ_SIZE(_ndescs)           ((_ndescs) * sizeof (efx_qword_t))
928 #define EFX_RXQ_NBUFS(_ndescs)          (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
929 #define EFX_RXQ_LIMIT(_ndescs)          ((_ndescs) - 16)
930 #define EFX_RXQ_DC_NDESCS(_dcsize)      (8 << _dcsize)
931
932 typedef enum efx_rxq_type_e {
933         EFX_RXQ_TYPE_DEFAULT,
934         EFX_RXQ_TYPE_SCATTER,
935         EFX_RXQ_TYPE_PACKED_STREAM_1M,
936         EFX_RXQ_TYPE_PACKED_STREAM_512K,
937         EFX_RXQ_TYPE_PACKED_STREAM_256K,
938         EFX_RXQ_TYPE_PACKED_STREAM_128K,
939         EFX_RXQ_TYPE_PACKED_STREAM_64K,
940         EFX_RXQ_NTYPES
941 } efx_rxq_type_t;
942
943 extern  __checkReturn   efx_rc_t
944 efx_rx_qcreate(
945         __in            efx_nic_t *enp,
946         __in            unsigned int index,
947         __in            unsigned int label,
948         __in            efx_rxq_type_t type,
949         __in            efsys_mem_t *esmp,
950         __in            size_t n,
951         __in            uint32_t id,
952         __in            efx_evq_t *eep,
953         __deref_out     efx_rxq_t **erpp);
954
955 typedef struct efx_buffer_s {
956         efsys_dma_addr_t        eb_addr;
957         size_t                  eb_size;
958         boolean_t               eb_eop;
959 } efx_buffer_t;
960
961 typedef struct efx_desc_s {
962         efx_qword_t ed_eq;
963 } efx_desc_t;
964
965 extern                  void
966 efx_rx_qpost(
967         __in            efx_rxq_t *erp,
968         __in_ecount(n)  efsys_dma_addr_t *addrp,
969         __in            size_t size,
970         __in            unsigned int n,
971         __in            unsigned int completed,
972         __in            unsigned int added);
973
974 extern          void
975 efx_rx_qpush(
976         __in    efx_rxq_t *erp,
977         __in    unsigned int added,
978         __inout unsigned int *pushedp);
979
980 extern  __checkReturn   efx_rc_t
981 efx_rx_qflush(
982         __in    efx_rxq_t *erp);
983
984 extern          void
985 efx_rx_qenable(
986         __in    efx_rxq_t *erp);
987
988 extern          void
989 efx_rx_qdestroy(
990         __in    efx_rxq_t *erp);
991
992 /* TX */
993
994 typedef struct efx_txq_s        efx_txq_t;
995
996 extern  __checkReturn   efx_rc_t
997 efx_tx_init(
998         __in            efx_nic_t *enp);
999
1000 extern          void
1001 efx_tx_fini(
1002         __in    efx_nic_t *enp);
1003
1004 #define EFX_TXQ_MINNDESCS               512
1005
1006 #define EFX_TXQ_SIZE(_ndescs)           ((_ndescs) * sizeof (efx_qword_t))
1007 #define EFX_TXQ_NBUFS(_ndescs)          (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
1008 #define EFX_TXQ_LIMIT(_ndescs)          ((_ndescs) - 16)
1009 #define EFX_TXQ_DC_NDESCS(_dcsize)      (8 << _dcsize)
1010
1011 #define EFX_TXQ_MAX_BUFS 8 /* Maximum independent of EFX_BUG35388_WORKAROUND. */
1012
1013 #define EFX_TXQ_CKSUM_IPV4      0x0001
1014 #define EFX_TXQ_CKSUM_TCPUDP    0x0002
1015 #define EFX_TXQ_FATSOV2         0x0004
1016
1017 extern  __checkReturn   efx_rc_t
1018 efx_tx_qcreate(
1019         __in            efx_nic_t *enp,
1020         __in            unsigned int index,
1021         __in            unsigned int label,
1022         __in            efsys_mem_t *esmp,
1023         __in            size_t n,
1024         __in            uint32_t id,
1025         __in            uint16_t flags,
1026         __in            efx_evq_t *eep,
1027         __deref_out     efx_txq_t **etpp,
1028         __out           unsigned int *addedp);
1029
1030 extern  __checkReturn   efx_rc_t
1031 efx_tx_qpost(
1032         __in            efx_txq_t *etp,
1033         __in_ecount(n)  efx_buffer_t *eb,
1034         __in            unsigned int n,
1035         __in            unsigned int completed,
1036         __inout         unsigned int *addedp);
1037
1038 extern  __checkReturn   efx_rc_t
1039 efx_tx_qpace(
1040         __in            efx_txq_t *etp,
1041         __in            unsigned int ns);
1042
1043 extern                  void
1044 efx_tx_qpush(
1045         __in            efx_txq_t *etp,
1046         __in            unsigned int added,
1047         __in            unsigned int pushed);
1048
1049 extern  __checkReturn   efx_rc_t
1050 efx_tx_qflush(
1051         __in            efx_txq_t *etp);
1052
1053 extern                  void
1054 efx_tx_qenable(
1055         __in            efx_txq_t *etp);
1056
1057 extern  __checkReturn   efx_rc_t
1058 efx_tx_qpio_enable(
1059         __in            efx_txq_t *etp);
1060
1061 extern                  void
1062 efx_tx_qpio_disable(
1063         __in            efx_txq_t *etp);
1064
1065 extern  __checkReturn   efx_rc_t
1066 efx_tx_qpio_write(
1067         __in                    efx_txq_t *etp,
1068         __in_ecount(buf_length) uint8_t *buffer,
1069         __in                    size_t buf_length,
1070         __in                    size_t pio_buf_offset);
1071
1072 extern  __checkReturn   efx_rc_t
1073 efx_tx_qpio_post(
1074         __in                    efx_txq_t *etp,
1075         __in                    size_t pkt_length,
1076         __in                    unsigned int completed,
1077         __inout                 unsigned int *addedp);
1078
1079 extern  __checkReturn   efx_rc_t
1080 efx_tx_qdesc_post(
1081         __in            efx_txq_t *etp,
1082         __in_ecount(n)  efx_desc_t *ed,
1083         __in            unsigned int n,
1084         __in            unsigned int completed,
1085         __inout         unsigned int *addedp);
1086
1087 extern  void
1088 efx_tx_qdesc_dma_create(
1089         __in    efx_txq_t *etp,
1090         __in    efsys_dma_addr_t addr,
1091         __in    size_t size,
1092         __in    boolean_t eop,
1093         __out   efx_desc_t *edp);
1094
1095 extern  void
1096 efx_tx_qdesc_tso_create(
1097         __in    efx_txq_t *etp,
1098         __in    uint16_t ipv4_id,
1099         __in    uint32_t tcp_seq,
1100         __in    uint8_t  tcp_flags,
1101         __out   efx_desc_t *edp);
1102
1103 /* Number of FATSOv2 option descriptors */
1104 #define EFX_TX_FATSOV2_OPT_NDESCS               2
1105
1106 /* Maximum number of DMA segments per TSO packet (not superframe) */
1107 #define EFX_TX_FATSOV2_DMA_SEGS_PER_PKT_MAX     24
1108
1109 extern  void
1110 efx_tx_qdesc_tso2_create(
1111         __in                    efx_txq_t *etp,
1112         __in                    uint16_t ipv4_id,
1113         __in                    uint32_t tcp_seq,
1114         __in                    uint16_t tcp_mss,
1115         __out_ecount(count)     efx_desc_t *edp,
1116         __in                    int count);
1117
1118 extern  void
1119 efx_tx_qdesc_vlantci_create(
1120         __in    efx_txq_t *etp,
1121         __in    uint16_t tci,
1122         __out   efx_desc_t *edp);
1123
1124 extern          void
1125 efx_tx_qdestroy(
1126         __in    efx_txq_t *etp);
1127
1128
1129 /* FILTER */
1130
1131 #if EFSYS_OPT_FILTER
1132
1133 #define EFX_ETHER_TYPE_IPV4 0x0800
1134 #define EFX_ETHER_TYPE_IPV6 0x86DD
1135
1136 #define EFX_IPPROTO_TCP 6
1137 #define EFX_IPPROTO_UDP 17
1138
1139 /* Use RSS to spread across multiple queues */
1140 #define EFX_FILTER_FLAG_RX_RSS          0x01
1141 /* Enable RX scatter */
1142 #define EFX_FILTER_FLAG_RX_SCATTER      0x02
1143 /*
1144  * Override an automatic filter (priority EFX_FILTER_PRI_AUTO).
1145  * May only be set by the filter implementation for each type.
1146  * A removal request will restore the automatic filter in its place.
1147  */
1148 #define EFX_FILTER_FLAG_RX_OVER_AUTO    0x04
1149 /* Filter is for RX */
1150 #define EFX_FILTER_FLAG_RX              0x08
1151 /* Filter is for TX */
1152 #define EFX_FILTER_FLAG_TX              0x10
1153
1154 typedef unsigned int efx_filter_flags_t;
1155
1156 typedef enum efx_filter_match_flags_e {
1157         EFX_FILTER_MATCH_REM_HOST = 0x0001,     /* Match by remote IP host
1158                                                  * address */
1159         EFX_FILTER_MATCH_LOC_HOST = 0x0002,     /* Match by local IP host
1160                                                  * address */
1161         EFX_FILTER_MATCH_REM_MAC = 0x0004,      /* Match by remote MAC address */
1162         EFX_FILTER_MATCH_REM_PORT = 0x0008,     /* Match by remote TCP/UDP port */
1163         EFX_FILTER_MATCH_LOC_MAC = 0x0010,      /* Match by remote TCP/UDP port */
1164         EFX_FILTER_MATCH_LOC_PORT = 0x0020,     /* Match by local TCP/UDP port */
1165         EFX_FILTER_MATCH_ETHER_TYPE = 0x0040,   /* Match by Ether-type */
1166         EFX_FILTER_MATCH_INNER_VID = 0x0080,    /* Match by inner VLAN ID */
1167         EFX_FILTER_MATCH_OUTER_VID = 0x0100,    /* Match by outer VLAN ID */
1168         EFX_FILTER_MATCH_IP_PROTO = 0x0200,     /* Match by IP transport
1169                                                  * protocol */
1170         EFX_FILTER_MATCH_LOC_MAC_IG = 0x0400,   /* Match by local MAC address
1171                                                  * I/G bit. Used for RX default
1172                                                  * unicast and multicast/
1173                                                  * broadcast filters. */
1174 } efx_filter_match_flags_t;
1175
1176 typedef enum efx_filter_priority_s {
1177         EFX_FILTER_PRI_HINT = 0,        /* Performance hint */
1178         EFX_FILTER_PRI_AUTO,            /* Automatic filter based on device
1179                                          * address list or hardware
1180                                          * requirements. This may only be used
1181                                          * by the filter implementation for
1182                                          * each NIC type. */
1183         EFX_FILTER_PRI_MANUAL,          /* Manually configured filter */
1184         EFX_FILTER_PRI_REQUIRED,        /* Required for correct behaviour of the
1185                                          * client (e.g. SR-IOV, HyperV VMQ etc.)
1186                                          */
1187 } efx_filter_priority_t;
1188
1189 /*
1190  * FIXME: All these fields are assumed to be in little-endian byte order.
1191  * It may be better for some to be big-endian. See bug42804.
1192  */
1193
1194 typedef struct efx_filter_spec_s {
1195         uint32_t        efs_match_flags:12;
1196         uint32_t        efs_priority:2;
1197         uint32_t        efs_flags:6;
1198         uint32_t        efs_dmaq_id:12;
1199         uint32_t        efs_rss_context;
1200         uint16_t        efs_outer_vid;
1201         uint16_t        efs_inner_vid;
1202         uint8_t         efs_loc_mac[EFX_MAC_ADDR_LEN];
1203         uint8_t         efs_rem_mac[EFX_MAC_ADDR_LEN];
1204         uint16_t        efs_ether_type;
1205         uint8_t         efs_ip_proto;
1206         uint16_t        efs_loc_port;
1207         uint16_t        efs_rem_port;
1208         efx_oword_t     efs_rem_host;
1209         efx_oword_t     efs_loc_host;
1210 } efx_filter_spec_t;
1211
1212
1213 /* Default values for use in filter specifications */
1214 #define EFX_FILTER_SPEC_RSS_CONTEXT_DEFAULT     0xffffffff
1215 #define EFX_FILTER_SPEC_RX_DMAQ_ID_DROP         0xfff
1216 #define EFX_FILTER_SPEC_VID_UNSPEC              0xffff
1217
1218 extern  __checkReturn   efx_rc_t
1219 efx_filter_init(
1220         __in            efx_nic_t *enp);
1221
1222 extern                  void
1223 efx_filter_fini(
1224         __in            efx_nic_t *enp);
1225
1226 extern  __checkReturn   efx_rc_t
1227 efx_filter_insert(
1228         __in            efx_nic_t *enp,
1229         __inout         efx_filter_spec_t *spec);
1230
1231 extern  __checkReturn   efx_rc_t
1232 efx_filter_remove(
1233         __in            efx_nic_t *enp,
1234         __inout         efx_filter_spec_t *spec);
1235
1236 extern  __checkReturn   efx_rc_t
1237 efx_filter_restore(
1238         __in            efx_nic_t *enp);
1239
1240 extern  __checkReturn   efx_rc_t
1241 efx_filter_supported_filters(
1242         __in            efx_nic_t *enp,
1243         __out           uint32_t *list,
1244         __out           size_t *length);
1245
1246 extern                  void
1247 efx_filter_spec_init_rx(
1248         __out           efx_filter_spec_t *spec,
1249         __in            efx_filter_priority_t priority,
1250         __in            efx_filter_flags_t flags,
1251         __in            efx_rxq_t *erp);
1252
1253 extern                  void
1254 efx_filter_spec_init_tx(
1255         __out           efx_filter_spec_t *spec,
1256         __in            efx_txq_t *etp);
1257
1258 extern  __checkReturn   efx_rc_t
1259 efx_filter_spec_set_ipv4_local(
1260         __inout         efx_filter_spec_t *spec,
1261         __in            uint8_t proto,
1262         __in            uint32_t host,
1263         __in            uint16_t port);
1264
1265 extern  __checkReturn   efx_rc_t
1266 efx_filter_spec_set_ipv4_full(
1267         __inout         efx_filter_spec_t *spec,
1268         __in            uint8_t proto,
1269         __in            uint32_t lhost,
1270         __in            uint16_t lport,
1271         __in            uint32_t rhost,
1272         __in            uint16_t rport);
1273
1274 extern  __checkReturn   efx_rc_t
1275 efx_filter_spec_set_eth_local(
1276         __inout         efx_filter_spec_t *spec,
1277         __in            uint16_t vid,
1278         __in            const uint8_t *addr);
1279
1280 extern  __checkReturn   efx_rc_t
1281 efx_filter_spec_set_uc_def(
1282         __inout         efx_filter_spec_t *spec);
1283
1284 extern  __checkReturn   efx_rc_t
1285 efx_filter_spec_set_mc_def(
1286         __inout         efx_filter_spec_t *spec);
1287
1288 #endif  /* EFSYS_OPT_FILTER */
1289
1290 /* HASH */
1291
1292 extern  __checkReturn           uint32_t
1293 efx_hash_dwords(
1294         __in_ecount(count)      uint32_t const *input,
1295         __in                    size_t count,
1296         __in                    uint32_t init);
1297
1298 extern  __checkReturn           uint32_t
1299 efx_hash_bytes(
1300         __in_ecount(length)     uint8_t const *input,
1301         __in                    size_t length,
1302         __in                    uint32_t init);
1303
1304
1305
1306 #ifdef  __cplusplus
1307 }
1308 #endif
1309
1310 #endif  /* _SYS_EFX_H */