]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/sfxge/common/efx.h
sfxge(4): get actions MARK and FLAG support
[FreeBSD/FreeBSD.git] / sys / dev / sfxge / common / efx.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2006-2016 Solarflare Communications Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  *    this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  *    this list of conditions and the following disclaimer in the documentation
14  *    and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * The views and conclusions contained in the software and documentation are
29  * those of the authors and should not be interpreted as representing official
30  * policies, either expressed or implied, of the FreeBSD Project.
31  *
32  * $FreeBSD$
33  */
34
35 #ifndef _SYS_EFX_H
36 #define _SYS_EFX_H
37
38 #include "efsys.h"
39 #include "efx_check.h"
40 #include "efx_phy_ids.h"
41
42 #ifdef  __cplusplus
43 extern "C" {
44 #endif
45
46 #define EFX_STATIC_ASSERT(_cond)                \
47         ((void)sizeof (char[(_cond) ? 1 : -1]))
48
49 #define EFX_ARRAY_SIZE(_array)                  \
50         (sizeof (_array) / sizeof ((_array)[0]))
51
52 #define EFX_FIELD_OFFSET(_type, _field)         \
53         ((size_t)&(((_type *)0)->_field))
54
55 /* The macro expands divider twice */
56 #define EFX_DIV_ROUND_UP(_n, _d)                (((_n) + (_d) - 1) / (_d))
57
58 /* Return codes */
59
60 typedef __success(return == 0) int efx_rc_t;
61
62
63 /* Chip families */
64
65 typedef enum efx_family_e {
66         EFX_FAMILY_INVALID,
67         EFX_FAMILY_FALCON,      /* Obsolete and not supported */
68         EFX_FAMILY_SIENA,
69         EFX_FAMILY_HUNTINGTON,
70         EFX_FAMILY_MEDFORD,
71         EFX_FAMILY_MEDFORD2,
72         EFX_FAMILY_NTYPES
73 } efx_family_t;
74
75 extern  __checkReturn   efx_rc_t
76 efx_family(
77         __in            uint16_t venid,
78         __in            uint16_t devid,
79         __out           efx_family_t *efp,
80         __out           unsigned int *membarp);
81
82
83 #define EFX_PCI_VENID_SFC                       0x1924
84
85 #define EFX_PCI_DEVID_FALCON                    0x0710  /* SFC4000 */
86
87 #define EFX_PCI_DEVID_BETHPAGE                  0x0803  /* SFC9020 */
88 #define EFX_PCI_DEVID_SIENA                     0x0813  /* SFL9021 */
89 #define EFX_PCI_DEVID_SIENA_F1_UNINIT           0x0810
90
91 #define EFX_PCI_DEVID_HUNTINGTON_PF_UNINIT      0x0901
92 #define EFX_PCI_DEVID_FARMINGDALE               0x0903  /* SFC9120 PF */
93 #define EFX_PCI_DEVID_GREENPORT                 0x0923  /* SFC9140 PF */
94
95 #define EFX_PCI_DEVID_FARMINGDALE_VF            0x1903  /* SFC9120 VF */
96 #define EFX_PCI_DEVID_GREENPORT_VF              0x1923  /* SFC9140 VF */
97
98 #define EFX_PCI_DEVID_MEDFORD_PF_UNINIT         0x0913
99 #define EFX_PCI_DEVID_MEDFORD                   0x0A03  /* SFC9240 PF */
100 #define EFX_PCI_DEVID_MEDFORD_VF                0x1A03  /* SFC9240 VF */
101
102 #define EFX_PCI_DEVID_MEDFORD2_PF_UNINIT        0x0B13
103 #define EFX_PCI_DEVID_MEDFORD2                  0x0B03  /* SFC9250 PF */
104 #define EFX_PCI_DEVID_MEDFORD2_VF               0x1B03  /* SFC9250 VF */
105
106
107 #define EFX_MEM_BAR_SIENA                       2
108
109 #define EFX_MEM_BAR_HUNTINGTON_PF               2
110 #define EFX_MEM_BAR_HUNTINGTON_VF               0
111
112 #define EFX_MEM_BAR_MEDFORD_PF                  2
113 #define EFX_MEM_BAR_MEDFORD_VF                  0
114
115 #define EFX_MEM_BAR_MEDFORD2                    0
116
117
118 /* Error codes */
119
120 enum {
121         EFX_ERR_INVALID,
122         EFX_ERR_SRAM_OOB,
123         EFX_ERR_BUFID_DC_OOB,
124         EFX_ERR_MEM_PERR,
125         EFX_ERR_RBUF_OWN,
126         EFX_ERR_TBUF_OWN,
127         EFX_ERR_RDESQ_OWN,
128         EFX_ERR_TDESQ_OWN,
129         EFX_ERR_EVQ_OWN,
130         EFX_ERR_EVFF_OFLO,
131         EFX_ERR_ILL_ADDR,
132         EFX_ERR_SRAM_PERR,
133         EFX_ERR_NCODES
134 };
135
136 /* Calculate the IEEE 802.3 CRC32 of a MAC addr */
137 extern  __checkReturn           uint32_t
138 efx_crc32_calculate(
139         __in                    uint32_t crc_init,
140         __in_ecount(length)     uint8_t const *input,
141         __in                    int length);
142
143
144 /* Type prototypes */
145
146 typedef struct efx_rxq_s        efx_rxq_t;
147
148 /* NIC */
149
150 typedef struct efx_nic_s        efx_nic_t;
151
152 extern  __checkReturn   efx_rc_t
153 efx_nic_create(
154         __in            efx_family_t family,
155         __in            efsys_identifier_t *esip,
156         __in            efsys_bar_t *esbp,
157         __in            efsys_lock_t *eslp,
158         __deref_out     efx_nic_t **enpp);
159
160 /* EFX_FW_VARIANT codes map one to one on MC_CMD_FW codes */
161 typedef enum efx_fw_variant_e {
162         EFX_FW_VARIANT_FULL_FEATURED,
163         EFX_FW_VARIANT_LOW_LATENCY,
164         EFX_FW_VARIANT_PACKED_STREAM,
165         EFX_FW_VARIANT_HIGH_TX_RATE,
166         EFX_FW_VARIANT_PACKED_STREAM_HASH_MODE_1,
167         EFX_FW_VARIANT_RULES_ENGINE,
168         EFX_FW_VARIANT_DPDK,
169         EFX_FW_VARIANT_DONT_CARE = 0xffffffff
170 } efx_fw_variant_t;
171
172 extern  __checkReturn   efx_rc_t
173 efx_nic_probe(
174         __in            efx_nic_t *enp,
175         __in            efx_fw_variant_t efv);
176
177 extern  __checkReturn   efx_rc_t
178 efx_nic_init(
179         __in            efx_nic_t *enp);
180
181 extern  __checkReturn   efx_rc_t
182 efx_nic_reset(
183         __in            efx_nic_t *enp);
184
185 #if EFSYS_OPT_DIAG
186
187 extern  __checkReturn   efx_rc_t
188 efx_nic_register_test(
189         __in            efx_nic_t *enp);
190
191 #endif  /* EFSYS_OPT_DIAG */
192
193 extern          void
194 efx_nic_fini(
195         __in            efx_nic_t *enp);
196
197 extern          void
198 efx_nic_unprobe(
199         __in            efx_nic_t *enp);
200
201 extern          void
202 efx_nic_destroy(
203         __in    efx_nic_t *enp);
204
205 #define EFX_PCIE_LINK_SPEED_GEN1                1
206 #define EFX_PCIE_LINK_SPEED_GEN2                2
207 #define EFX_PCIE_LINK_SPEED_GEN3                3
208
209 typedef enum efx_pcie_link_performance_e {
210         EFX_PCIE_LINK_PERFORMANCE_UNKNOWN_BANDWIDTH,
211         EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_BANDWIDTH,
212         EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_LATENCY,
213         EFX_PCIE_LINK_PERFORMANCE_OPTIMAL
214 } efx_pcie_link_performance_t;
215
216 extern  __checkReturn   efx_rc_t
217 efx_nic_calculate_pcie_link_bandwidth(
218         __in            uint32_t pcie_link_width,
219         __in            uint32_t pcie_link_gen,
220         __out           uint32_t *bandwidth_mbpsp);
221
222 extern  __checkReturn   efx_rc_t
223 efx_nic_check_pcie_link_speed(
224         __in            efx_nic_t *enp,
225         __in            uint32_t pcie_link_width,
226         __in            uint32_t pcie_link_gen,
227         __out           efx_pcie_link_performance_t *resultp);
228
229 #if EFSYS_OPT_MCDI
230
231 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
232 /* Huntington and Medford require MCDIv2 commands */
233 #define WITH_MCDI_V2 1
234 #endif
235
236 typedef struct efx_mcdi_req_s efx_mcdi_req_t;
237
238 typedef enum efx_mcdi_exception_e {
239         EFX_MCDI_EXCEPTION_MC_REBOOT,
240         EFX_MCDI_EXCEPTION_MC_BADASSERT,
241 } efx_mcdi_exception_t;
242
243 #if EFSYS_OPT_MCDI_LOGGING
244 typedef enum efx_log_msg_e {
245         EFX_LOG_INVALID,
246         EFX_LOG_MCDI_REQUEST,
247         EFX_LOG_MCDI_RESPONSE,
248 } efx_log_msg_t;
249 #endif /* EFSYS_OPT_MCDI_LOGGING */
250
251 typedef struct efx_mcdi_transport_s {
252         void            *emt_context;
253         efsys_mem_t     *emt_dma_mem;
254         void            (*emt_execute)(void *, efx_mcdi_req_t *);
255         void            (*emt_ev_cpl)(void *);
256         void            (*emt_exception)(void *, efx_mcdi_exception_t);
257 #if EFSYS_OPT_MCDI_LOGGING
258         void            (*emt_logger)(void *, efx_log_msg_t,
259                                         void *, size_t, void *, size_t);
260 #endif /* EFSYS_OPT_MCDI_LOGGING */
261 #if EFSYS_OPT_MCDI_PROXY_AUTH
262         void            (*emt_ev_proxy_response)(void *, uint32_t, efx_rc_t);
263 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
264 } efx_mcdi_transport_t;
265
266 extern  __checkReturn   efx_rc_t
267 efx_mcdi_init(
268         __in            efx_nic_t *enp,
269         __in            const efx_mcdi_transport_t *mtp);
270
271 extern  __checkReturn   efx_rc_t
272 efx_mcdi_reboot(
273         __in            efx_nic_t *enp);
274
275                         void
276 efx_mcdi_new_epoch(
277         __in            efx_nic_t *enp);
278
279 extern                  void
280 efx_mcdi_get_timeout(
281         __in            efx_nic_t *enp,
282         __in            efx_mcdi_req_t *emrp,
283         __out           uint32_t *usec_timeoutp);
284
285 extern                  void
286 efx_mcdi_request_start(
287         __in            efx_nic_t *enp,
288         __in            efx_mcdi_req_t *emrp,
289         __in            boolean_t ev_cpl);
290
291 extern  __checkReturn   boolean_t
292 efx_mcdi_request_poll(
293         __in            efx_nic_t *enp);
294
295 extern  __checkReturn   boolean_t
296 efx_mcdi_request_abort(
297         __in            efx_nic_t *enp);
298
299 extern                  void
300 efx_mcdi_fini(
301         __in            efx_nic_t *enp);
302
303 #endif  /* EFSYS_OPT_MCDI */
304
305 /* INTR */
306
307 #define EFX_NINTR_SIENA 1024
308
309 typedef enum efx_intr_type_e {
310         EFX_INTR_INVALID = 0,
311         EFX_INTR_LINE,
312         EFX_INTR_MESSAGE,
313         EFX_INTR_NTYPES
314 } efx_intr_type_t;
315
316 #define EFX_INTR_SIZE   (sizeof (efx_oword_t))
317
318 extern  __checkReturn   efx_rc_t
319 efx_intr_init(
320         __in            efx_nic_t *enp,
321         __in            efx_intr_type_t type,
322         __in            efsys_mem_t *esmp);
323
324 extern                  void
325 efx_intr_enable(
326         __in            efx_nic_t *enp);
327
328 extern                  void
329 efx_intr_disable(
330         __in            efx_nic_t *enp);
331
332 extern                  void
333 efx_intr_disable_unlocked(
334         __in            efx_nic_t *enp);
335
336 #define EFX_INTR_NEVQS  32
337
338 extern  __checkReturn   efx_rc_t
339 efx_intr_trigger(
340         __in            efx_nic_t *enp,
341         __in            unsigned int level);
342
343 extern                  void
344 efx_intr_status_line(
345         __in            efx_nic_t *enp,
346         __out           boolean_t *fatalp,
347         __out           uint32_t *maskp);
348
349 extern                  void
350 efx_intr_status_message(
351         __in            efx_nic_t *enp,
352         __in            unsigned int message,
353         __out           boolean_t *fatalp);
354
355 extern                  void
356 efx_intr_fatal(
357         __in            efx_nic_t *enp);
358
359 extern                  void
360 efx_intr_fini(
361         __in            efx_nic_t *enp);
362
363 /* MAC */
364
365 #if EFSYS_OPT_MAC_STATS
366
367 /* START MKCONFIG GENERATED EfxHeaderMacBlock 7d59c0d68431a5d1 */
368 typedef enum efx_mac_stat_e {
369         EFX_MAC_RX_OCTETS,
370         EFX_MAC_RX_PKTS,
371         EFX_MAC_RX_UNICST_PKTS,
372         EFX_MAC_RX_MULTICST_PKTS,
373         EFX_MAC_RX_BRDCST_PKTS,
374         EFX_MAC_RX_PAUSE_PKTS,
375         EFX_MAC_RX_LE_64_PKTS,
376         EFX_MAC_RX_65_TO_127_PKTS,
377         EFX_MAC_RX_128_TO_255_PKTS,
378         EFX_MAC_RX_256_TO_511_PKTS,
379         EFX_MAC_RX_512_TO_1023_PKTS,
380         EFX_MAC_RX_1024_TO_15XX_PKTS,
381         EFX_MAC_RX_GE_15XX_PKTS,
382         EFX_MAC_RX_ERRORS,
383         EFX_MAC_RX_FCS_ERRORS,
384         EFX_MAC_RX_DROP_EVENTS,
385         EFX_MAC_RX_FALSE_CARRIER_ERRORS,
386         EFX_MAC_RX_SYMBOL_ERRORS,
387         EFX_MAC_RX_ALIGN_ERRORS,
388         EFX_MAC_RX_INTERNAL_ERRORS,
389         EFX_MAC_RX_JABBER_PKTS,
390         EFX_MAC_RX_LANE0_CHAR_ERR,
391         EFX_MAC_RX_LANE1_CHAR_ERR,
392         EFX_MAC_RX_LANE2_CHAR_ERR,
393         EFX_MAC_RX_LANE3_CHAR_ERR,
394         EFX_MAC_RX_LANE0_DISP_ERR,
395         EFX_MAC_RX_LANE1_DISP_ERR,
396         EFX_MAC_RX_LANE2_DISP_ERR,
397         EFX_MAC_RX_LANE3_DISP_ERR,
398         EFX_MAC_RX_MATCH_FAULT,
399         EFX_MAC_RX_NODESC_DROP_CNT,
400         EFX_MAC_TX_OCTETS,
401         EFX_MAC_TX_PKTS,
402         EFX_MAC_TX_UNICST_PKTS,
403         EFX_MAC_TX_MULTICST_PKTS,
404         EFX_MAC_TX_BRDCST_PKTS,
405         EFX_MAC_TX_PAUSE_PKTS,
406         EFX_MAC_TX_LE_64_PKTS,
407         EFX_MAC_TX_65_TO_127_PKTS,
408         EFX_MAC_TX_128_TO_255_PKTS,
409         EFX_MAC_TX_256_TO_511_PKTS,
410         EFX_MAC_TX_512_TO_1023_PKTS,
411         EFX_MAC_TX_1024_TO_15XX_PKTS,
412         EFX_MAC_TX_GE_15XX_PKTS,
413         EFX_MAC_TX_ERRORS,
414         EFX_MAC_TX_SGL_COL_PKTS,
415         EFX_MAC_TX_MULT_COL_PKTS,
416         EFX_MAC_TX_EX_COL_PKTS,
417         EFX_MAC_TX_LATE_COL_PKTS,
418         EFX_MAC_TX_DEF_PKTS,
419         EFX_MAC_TX_EX_DEF_PKTS,
420         EFX_MAC_PM_TRUNC_BB_OVERFLOW,
421         EFX_MAC_PM_DISCARD_BB_OVERFLOW,
422         EFX_MAC_PM_TRUNC_VFIFO_FULL,
423         EFX_MAC_PM_DISCARD_VFIFO_FULL,
424         EFX_MAC_PM_TRUNC_QBB,
425         EFX_MAC_PM_DISCARD_QBB,
426         EFX_MAC_PM_DISCARD_MAPPING,
427         EFX_MAC_RXDP_Q_DISABLED_PKTS,
428         EFX_MAC_RXDP_DI_DROPPED_PKTS,
429         EFX_MAC_RXDP_STREAMING_PKTS,
430         EFX_MAC_RXDP_HLB_FETCH,
431         EFX_MAC_RXDP_HLB_WAIT,
432         EFX_MAC_VADAPTER_RX_UNICAST_PACKETS,
433         EFX_MAC_VADAPTER_RX_UNICAST_BYTES,
434         EFX_MAC_VADAPTER_RX_MULTICAST_PACKETS,
435         EFX_MAC_VADAPTER_RX_MULTICAST_BYTES,
436         EFX_MAC_VADAPTER_RX_BROADCAST_PACKETS,
437         EFX_MAC_VADAPTER_RX_BROADCAST_BYTES,
438         EFX_MAC_VADAPTER_RX_BAD_PACKETS,
439         EFX_MAC_VADAPTER_RX_BAD_BYTES,
440         EFX_MAC_VADAPTER_RX_OVERFLOW,
441         EFX_MAC_VADAPTER_TX_UNICAST_PACKETS,
442         EFX_MAC_VADAPTER_TX_UNICAST_BYTES,
443         EFX_MAC_VADAPTER_TX_MULTICAST_PACKETS,
444         EFX_MAC_VADAPTER_TX_MULTICAST_BYTES,
445         EFX_MAC_VADAPTER_TX_BROADCAST_PACKETS,
446         EFX_MAC_VADAPTER_TX_BROADCAST_BYTES,
447         EFX_MAC_VADAPTER_TX_BAD_PACKETS,
448         EFX_MAC_VADAPTER_TX_BAD_BYTES,
449         EFX_MAC_VADAPTER_TX_OVERFLOW,
450         EFX_MAC_FEC_UNCORRECTED_ERRORS,
451         EFX_MAC_FEC_CORRECTED_ERRORS,
452         EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE0,
453         EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE1,
454         EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE2,
455         EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE3,
456         EFX_MAC_CTPIO_VI_BUSY_FALLBACK,
457         EFX_MAC_CTPIO_LONG_WRITE_SUCCESS,
458         EFX_MAC_CTPIO_MISSING_DBELL_FAIL,
459         EFX_MAC_CTPIO_OVERFLOW_FAIL,
460         EFX_MAC_CTPIO_UNDERFLOW_FAIL,
461         EFX_MAC_CTPIO_TIMEOUT_FAIL,
462         EFX_MAC_CTPIO_NONCONTIG_WR_FAIL,
463         EFX_MAC_CTPIO_FRM_CLOBBER_FAIL,
464         EFX_MAC_CTPIO_INVALID_WR_FAIL,
465         EFX_MAC_CTPIO_VI_CLOBBER_FALLBACK,
466         EFX_MAC_CTPIO_UNQUALIFIED_FALLBACK,
467         EFX_MAC_CTPIO_RUNT_FALLBACK,
468         EFX_MAC_CTPIO_SUCCESS,
469         EFX_MAC_CTPIO_FALLBACK,
470         EFX_MAC_CTPIO_POISON,
471         EFX_MAC_CTPIO_ERASE,
472         EFX_MAC_NSTATS
473 } efx_mac_stat_t;
474
475 /* END MKCONFIG GENERATED EfxHeaderMacBlock */
476
477 #endif  /* EFSYS_OPT_MAC_STATS */
478
479 typedef enum efx_link_mode_e {
480         EFX_LINK_UNKNOWN = 0,
481         EFX_LINK_DOWN,
482         EFX_LINK_10HDX,
483         EFX_LINK_10FDX,
484         EFX_LINK_100HDX,
485         EFX_LINK_100FDX,
486         EFX_LINK_1000HDX,
487         EFX_LINK_1000FDX,
488         EFX_LINK_10000FDX,
489         EFX_LINK_40000FDX,
490         EFX_LINK_25000FDX,
491         EFX_LINK_50000FDX,
492         EFX_LINK_100000FDX,
493         EFX_LINK_NMODES
494 } efx_link_mode_t;
495
496 #define EFX_MAC_ADDR_LEN 6
497
498 #define EFX_VNI_OR_VSID_LEN 3
499
500 #define EFX_MAC_ADDR_IS_MULTICAST(_address) (((uint8_t *)_address)[0] & 0x01)
501
502 #define EFX_MAC_MULTICAST_LIST_MAX      256
503
504 #define EFX_MAC_SDU_MAX 9202
505
506 #define EFX_MAC_PDU_ADJUSTMENT                                  \
507         (/* EtherII */ 14                                       \
508             + /* VLAN */ 4                                      \
509             + /* CRC */ 4                                       \
510             + /* bug16011 */ 16)                                \
511
512 #define EFX_MAC_PDU(_sdu)                                       \
513         P2ROUNDUP((_sdu) + EFX_MAC_PDU_ADJUSTMENT, 8)
514
515 /*
516  * Due to the P2ROUNDUP in EFX_MAC_PDU(), EFX_MAC_SDU_FROM_PDU() may give
517  * the SDU rounded up slightly.
518  */
519 #define EFX_MAC_SDU_FROM_PDU(_pdu)      ((_pdu) - EFX_MAC_PDU_ADJUSTMENT)
520
521 #define EFX_MAC_PDU_MIN 60
522 #define EFX_MAC_PDU_MAX EFX_MAC_PDU(EFX_MAC_SDU_MAX)
523
524 extern  __checkReturn   efx_rc_t
525 efx_mac_pdu_get(
526         __in            efx_nic_t *enp,
527         __out           size_t *pdu);
528
529 extern  __checkReturn   efx_rc_t
530 efx_mac_pdu_set(
531         __in            efx_nic_t *enp,
532         __in            size_t pdu);
533
534 extern  __checkReturn   efx_rc_t
535 efx_mac_addr_set(
536         __in            efx_nic_t *enp,
537         __in            uint8_t *addr);
538
539 extern  __checkReturn                   efx_rc_t
540 efx_mac_filter_set(
541         __in                            efx_nic_t *enp,
542         __in                            boolean_t all_unicst,
543         __in                            boolean_t mulcst,
544         __in                            boolean_t all_mulcst,
545         __in                            boolean_t brdcst);
546
547 extern  __checkReturn   efx_rc_t
548 efx_mac_multicast_list_set(
549         __in                            efx_nic_t *enp,
550         __in_ecount(6*count)            uint8_t const *addrs,
551         __in                            int count);
552
553 extern  __checkReturn   efx_rc_t
554 efx_mac_filter_default_rxq_set(
555         __in            efx_nic_t *enp,
556         __in            efx_rxq_t *erp,
557         __in            boolean_t using_rss);
558
559 extern                  void
560 efx_mac_filter_default_rxq_clear(
561         __in            efx_nic_t *enp);
562
563 extern  __checkReturn   efx_rc_t
564 efx_mac_drain(
565         __in            efx_nic_t *enp,
566         __in            boolean_t enabled);
567
568 extern  __checkReturn   efx_rc_t
569 efx_mac_up(
570         __in            efx_nic_t *enp,
571         __out           boolean_t *mac_upp);
572
573 #define EFX_FCNTL_RESPOND       0x00000001
574 #define EFX_FCNTL_GENERATE      0x00000002
575
576 extern  __checkReturn   efx_rc_t
577 efx_mac_fcntl_set(
578         __in            efx_nic_t *enp,
579         __in            unsigned int fcntl,
580         __in            boolean_t autoneg);
581
582 extern                  void
583 efx_mac_fcntl_get(
584         __in            efx_nic_t *enp,
585         __out           unsigned int *fcntl_wantedp,
586         __out           unsigned int *fcntl_linkp);
587
588
589 #if EFSYS_OPT_MAC_STATS
590
591 #if EFSYS_OPT_NAMES
592
593 extern  __checkReturn                   const char *
594 efx_mac_stat_name(
595         __in                            efx_nic_t *enp,
596         __in                            unsigned int id);
597
598 #endif  /* EFSYS_OPT_NAMES */
599
600 #define EFX_MAC_STATS_MASK_BITS_PER_PAGE        (8 * sizeof (uint32_t))
601
602 #define EFX_MAC_STATS_MASK_NPAGES       \
603         (P2ROUNDUP(EFX_MAC_NSTATS, EFX_MAC_STATS_MASK_BITS_PER_PAGE) / \
604             EFX_MAC_STATS_MASK_BITS_PER_PAGE)
605
606 /*
607  * Get mask of MAC statistics supported by the hardware.
608  *
609  * If mask_size is insufficient to return the mask, EINVAL error is
610  * returned. EFX_MAC_STATS_MASK_NPAGES multiplied by size of the page
611  * (which is sizeof (uint32_t)) is sufficient.
612  */
613 extern  __checkReturn                   efx_rc_t
614 efx_mac_stats_get_mask(
615         __in                            efx_nic_t *enp,
616         __out_bcount(mask_size)         uint32_t *maskp,
617         __in                            size_t mask_size);
618
619 #define EFX_MAC_STAT_SUPPORTED(_mask, _stat)    \
620         ((_mask)[(_stat) / EFX_MAC_STATS_MASK_BITS_PER_PAGE] &  \
621             (1ULL << ((_stat) & (EFX_MAC_STATS_MASK_BITS_PER_PAGE - 1))))
622
623
624 extern  __checkReturn                   efx_rc_t
625 efx_mac_stats_clear(
626         __in                            efx_nic_t *enp);
627
628 /*
629  * Upload mac statistics supported by the hardware into the given buffer.
630  *
631  * The DMA buffer must be 4Kbyte aligned and sized to hold at least
632  * efx_nic_cfg_t::enc_mac_stats_nstats 64bit counters.
633  *
634  * The hardware will only DMA statistics that it understands (of course).
635  * Drivers should not make any assumptions about which statistics are
636  * supported, especially when the statistics are generated by firmware.
637  *
638  * Thus, drivers should zero this buffer before use, so that not-understood
639  * statistics read back as zero.
640  */
641 extern  __checkReturn                   efx_rc_t
642 efx_mac_stats_upload(
643         __in                            efx_nic_t *enp,
644         __in                            efsys_mem_t *esmp);
645
646 extern  __checkReturn                   efx_rc_t
647 efx_mac_stats_periodic(
648         __in                            efx_nic_t *enp,
649         __in                            efsys_mem_t *esmp,
650         __in                            uint16_t period_ms,
651         __in                            boolean_t events);
652
653 extern  __checkReturn                   efx_rc_t
654 efx_mac_stats_update(
655         __in                            efx_nic_t *enp,
656         __in                            efsys_mem_t *esmp,
657         __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
658         __inout_opt                     uint32_t *generationp);
659
660 #endif  /* EFSYS_OPT_MAC_STATS */
661
662 /* MON */
663
664 typedef enum efx_mon_type_e {
665         EFX_MON_INVALID = 0,
666         EFX_MON_SFC90X0,
667         EFX_MON_SFC91X0,
668         EFX_MON_SFC92X0,
669         EFX_MON_NTYPES
670 } efx_mon_type_t;
671
672 #if EFSYS_OPT_NAMES
673
674 extern          const char *
675 efx_mon_name(
676         __in    efx_nic_t *enp);
677
678 #endif  /* EFSYS_OPT_NAMES */
679
680 extern  __checkReturn   efx_rc_t
681 efx_mon_init(
682         __in            efx_nic_t *enp);
683
684 #if EFSYS_OPT_MON_STATS
685
686 #define EFX_MON_STATS_PAGE_SIZE 0x100
687 #define EFX_MON_MASK_ELEMENT_SIZE 32
688
689 /* START MKCONFIG GENERATED MonitorHeaderStatsBlock 400fdb0517af1fca */
690 typedef enum efx_mon_stat_e {
691         EFX_MON_STAT_2_5V,
692         EFX_MON_STAT_VCCP1,
693         EFX_MON_STAT_VCC,
694         EFX_MON_STAT_5V,
695         EFX_MON_STAT_12V,
696         EFX_MON_STAT_VCCP2,
697         EFX_MON_STAT_EXT_TEMP,
698         EFX_MON_STAT_INT_TEMP,
699         EFX_MON_STAT_AIN1,
700         EFX_MON_STAT_AIN2,
701         EFX_MON_STAT_INT_COOLING,
702         EFX_MON_STAT_EXT_COOLING,
703         EFX_MON_STAT_1V,
704         EFX_MON_STAT_1_2V,
705         EFX_MON_STAT_1_8V,
706         EFX_MON_STAT_3_3V,
707         EFX_MON_STAT_1_2VA,
708         EFX_MON_STAT_VREF,
709         EFX_MON_STAT_VAOE,
710         EFX_MON_STAT_AOE_TEMP,
711         EFX_MON_STAT_PSU_AOE_TEMP,
712         EFX_MON_STAT_PSU_TEMP,
713         EFX_MON_STAT_FAN0,
714         EFX_MON_STAT_FAN1,
715         EFX_MON_STAT_FAN2,
716         EFX_MON_STAT_FAN3,
717         EFX_MON_STAT_FAN4,
718         EFX_MON_STAT_VAOE_IN,
719         EFX_MON_STAT_IAOE,
720         EFX_MON_STAT_IAOE_IN,
721         EFX_MON_STAT_NIC_POWER,
722         EFX_MON_STAT_0_9V,
723         EFX_MON_STAT_I0_9V,
724         EFX_MON_STAT_I1_2V,
725         EFX_MON_STAT_0_9V_ADC,
726         EFX_MON_STAT_INT_TEMP2,
727         EFX_MON_STAT_VREG_TEMP,
728         EFX_MON_STAT_VREG_0_9V_TEMP,
729         EFX_MON_STAT_VREG_1_2V_TEMP,
730         EFX_MON_STAT_INT_VPTAT,
731         EFX_MON_STAT_INT_ADC_TEMP,
732         EFX_MON_STAT_EXT_VPTAT,
733         EFX_MON_STAT_EXT_ADC_TEMP,
734         EFX_MON_STAT_AMBIENT_TEMP,
735         EFX_MON_STAT_AIRFLOW,
736         EFX_MON_STAT_VDD08D_VSS08D_CSR,
737         EFX_MON_STAT_VDD08D_VSS08D_CSR_EXTADC,
738         EFX_MON_STAT_HOTPOINT_TEMP,
739         EFX_MON_STAT_PHY_POWER_SWITCH_PORT0,
740         EFX_MON_STAT_PHY_POWER_SWITCH_PORT1,
741         EFX_MON_STAT_MUM_VCC,
742         EFX_MON_STAT_0V9_A,
743         EFX_MON_STAT_I0V9_A,
744         EFX_MON_STAT_0V9_A_TEMP,
745         EFX_MON_STAT_0V9_B,
746         EFX_MON_STAT_I0V9_B,
747         EFX_MON_STAT_0V9_B_TEMP,
748         EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY,
749         EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY_EXT_ADC,
750         EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY,
751         EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY_EXT_ADC,
752         EFX_MON_STAT_CONTROLLER_MASTER_VPTAT,
753         EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP,
754         EFX_MON_STAT_CONTROLLER_MASTER_VPTAT_EXT_ADC,
755         EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP_EXT_ADC,
756         EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT,
757         EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP,
758         EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT_EXT_ADC,
759         EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP_EXT_ADC,
760         EFX_MON_STAT_SODIMM_VOUT,
761         EFX_MON_STAT_SODIMM_0_TEMP,
762         EFX_MON_STAT_SODIMM_1_TEMP,
763         EFX_MON_STAT_PHY0_VCC,
764         EFX_MON_STAT_PHY1_VCC,
765         EFX_MON_STAT_CONTROLLER_TDIODE_TEMP,
766         EFX_MON_STAT_BOARD_FRONT_TEMP,
767         EFX_MON_STAT_BOARD_BACK_TEMP,
768         EFX_MON_STAT_I1V8,
769         EFX_MON_STAT_I2V5,
770         EFX_MON_STAT_I3V3,
771         EFX_MON_STAT_I12V0,
772         EFX_MON_STAT_1_3V,
773         EFX_MON_STAT_I1V3,
774         EFX_MON_NSTATS
775 } efx_mon_stat_t;
776
777 /* END MKCONFIG GENERATED MonitorHeaderStatsBlock */
778
779 typedef enum efx_mon_stat_state_e {
780         EFX_MON_STAT_STATE_OK = 0,
781         EFX_MON_STAT_STATE_WARNING = 1,
782         EFX_MON_STAT_STATE_FATAL = 2,
783         EFX_MON_STAT_STATE_BROKEN = 3,
784         EFX_MON_STAT_STATE_NO_READING = 4,
785 } efx_mon_stat_state_t;
786
787 typedef struct efx_mon_stat_value_s {
788         uint16_t        emsv_value;
789         uint16_t        emsv_state;
790 } efx_mon_stat_value_t;
791
792 #if EFSYS_OPT_NAMES
793
794 extern                                  const char *
795 efx_mon_stat_name(
796         __in                            efx_nic_t *enp,
797         __in                            efx_mon_stat_t id);
798
799 #endif  /* EFSYS_OPT_NAMES */
800
801 extern  __checkReturn                   efx_rc_t
802 efx_mon_stats_update(
803         __in                            efx_nic_t *enp,
804         __in                            efsys_mem_t *esmp,
805         __inout_ecount(EFX_MON_NSTATS)  efx_mon_stat_value_t *values);
806
807 #endif  /* EFSYS_OPT_MON_STATS */
808
809 extern          void
810 efx_mon_fini(
811         __in    efx_nic_t *enp);
812
813 /* PHY */
814
815 extern  __checkReturn   efx_rc_t
816 efx_phy_verify(
817         __in            efx_nic_t *enp);
818
819 #if EFSYS_OPT_PHY_LED_CONTROL
820
821 typedef enum efx_phy_led_mode_e {
822         EFX_PHY_LED_DEFAULT = 0,
823         EFX_PHY_LED_OFF,
824         EFX_PHY_LED_ON,
825         EFX_PHY_LED_FLASH,
826         EFX_PHY_LED_NMODES
827 } efx_phy_led_mode_t;
828
829 extern  __checkReturn   efx_rc_t
830 efx_phy_led_set(
831         __in    efx_nic_t *enp,
832         __in    efx_phy_led_mode_t mode);
833
834 #endif  /* EFSYS_OPT_PHY_LED_CONTROL */
835
836 extern  __checkReturn   efx_rc_t
837 efx_port_init(
838         __in            efx_nic_t *enp);
839
840 #if EFSYS_OPT_LOOPBACK
841
842 typedef enum efx_loopback_type_e {
843         EFX_LOOPBACK_OFF = 0,
844         EFX_LOOPBACK_DATA = 1,
845         EFX_LOOPBACK_GMAC = 2,
846         EFX_LOOPBACK_XGMII = 3,
847         EFX_LOOPBACK_XGXS = 4,
848         EFX_LOOPBACK_XAUI = 5,
849         EFX_LOOPBACK_GMII = 6,
850         EFX_LOOPBACK_SGMII = 7,
851         EFX_LOOPBACK_XGBR = 8,
852         EFX_LOOPBACK_XFI = 9,
853         EFX_LOOPBACK_XAUI_FAR = 10,
854         EFX_LOOPBACK_GMII_FAR = 11,
855         EFX_LOOPBACK_SGMII_FAR = 12,
856         EFX_LOOPBACK_XFI_FAR = 13,
857         EFX_LOOPBACK_GPHY = 14,
858         EFX_LOOPBACK_PHY_XS = 15,
859         EFX_LOOPBACK_PCS = 16,
860         EFX_LOOPBACK_PMA_PMD = 17,
861         EFX_LOOPBACK_XPORT = 18,
862         EFX_LOOPBACK_XGMII_WS = 19,
863         EFX_LOOPBACK_XAUI_WS = 20,
864         EFX_LOOPBACK_XAUI_WS_FAR = 21,
865         EFX_LOOPBACK_XAUI_WS_NEAR = 22,
866         EFX_LOOPBACK_GMII_WS = 23,
867         EFX_LOOPBACK_XFI_WS = 24,
868         EFX_LOOPBACK_XFI_WS_FAR = 25,
869         EFX_LOOPBACK_PHYXS_WS = 26,
870         EFX_LOOPBACK_PMA_INT = 27,
871         EFX_LOOPBACK_SD_NEAR = 28,
872         EFX_LOOPBACK_SD_FAR = 29,
873         EFX_LOOPBACK_PMA_INT_WS = 30,
874         EFX_LOOPBACK_SD_FEP2_WS = 31,
875         EFX_LOOPBACK_SD_FEP1_5_WS = 32,
876         EFX_LOOPBACK_SD_FEP_WS = 33,
877         EFX_LOOPBACK_SD_FES_WS = 34,
878         EFX_LOOPBACK_AOE_INT_NEAR = 35,
879         EFX_LOOPBACK_DATA_WS = 36,
880         EFX_LOOPBACK_FORCE_EXT_LINK = 37,
881         EFX_LOOPBACK_NTYPES
882 } efx_loopback_type_t;
883
884 typedef enum efx_loopback_kind_e {
885         EFX_LOOPBACK_KIND_OFF = 0,
886         EFX_LOOPBACK_KIND_ALL,
887         EFX_LOOPBACK_KIND_MAC,
888         EFX_LOOPBACK_KIND_PHY,
889         EFX_LOOPBACK_NKINDS
890 } efx_loopback_kind_t;
891
892 extern                  void
893 efx_loopback_mask(
894         __in    efx_loopback_kind_t loopback_kind,
895         __out   efx_qword_t *maskp);
896
897 extern  __checkReturn   efx_rc_t
898 efx_port_loopback_set(
899         __in    efx_nic_t *enp,
900         __in    efx_link_mode_t link_mode,
901         __in    efx_loopback_type_t type);
902
903 #if EFSYS_OPT_NAMES
904
905 extern  __checkReturn   const char *
906 efx_loopback_type_name(
907         __in            efx_nic_t *enp,
908         __in            efx_loopback_type_t type);
909
910 #endif  /* EFSYS_OPT_NAMES */
911
912 #endif  /* EFSYS_OPT_LOOPBACK */
913
914 extern  __checkReturn   efx_rc_t
915 efx_port_poll(
916         __in            efx_nic_t *enp,
917         __out_opt       efx_link_mode_t *link_modep);
918
919 extern          void
920 efx_port_fini(
921         __in    efx_nic_t *enp);
922
923 typedef enum efx_phy_cap_type_e {
924         EFX_PHY_CAP_INVALID = 0,
925         EFX_PHY_CAP_10HDX,
926         EFX_PHY_CAP_10FDX,
927         EFX_PHY_CAP_100HDX,
928         EFX_PHY_CAP_100FDX,
929         EFX_PHY_CAP_1000HDX,
930         EFX_PHY_CAP_1000FDX,
931         EFX_PHY_CAP_10000FDX,
932         EFX_PHY_CAP_PAUSE,
933         EFX_PHY_CAP_ASYM,
934         EFX_PHY_CAP_AN,
935         EFX_PHY_CAP_40000FDX,
936         EFX_PHY_CAP_DDM,
937         EFX_PHY_CAP_100000FDX,
938         EFX_PHY_CAP_25000FDX,
939         EFX_PHY_CAP_50000FDX,
940         EFX_PHY_CAP_BASER_FEC,
941         EFX_PHY_CAP_BASER_FEC_REQUESTED,
942         EFX_PHY_CAP_RS_FEC,
943         EFX_PHY_CAP_RS_FEC_REQUESTED,
944         EFX_PHY_CAP_25G_BASER_FEC,
945         EFX_PHY_CAP_25G_BASER_FEC_REQUESTED,
946         EFX_PHY_CAP_NTYPES
947 } efx_phy_cap_type_t;
948
949
950 #define EFX_PHY_CAP_CURRENT     0x00000000
951 #define EFX_PHY_CAP_DEFAULT     0x00000001
952 #define EFX_PHY_CAP_PERM        0x00000002
953
954 extern          void
955 efx_phy_adv_cap_get(
956         __in            efx_nic_t *enp,
957         __in            uint32_t flag,
958         __out           uint32_t *maskp);
959
960 extern  __checkReturn   efx_rc_t
961 efx_phy_adv_cap_set(
962         __in            efx_nic_t *enp,
963         __in            uint32_t mask);
964
965 extern                  void
966 efx_phy_lp_cap_get(
967         __in            efx_nic_t *enp,
968         __out           uint32_t *maskp);
969
970 extern  __checkReturn   efx_rc_t
971 efx_phy_oui_get(
972         __in            efx_nic_t *enp,
973         __out           uint32_t *ouip);
974
975 typedef enum efx_phy_media_type_e {
976         EFX_PHY_MEDIA_INVALID = 0,
977         EFX_PHY_MEDIA_XAUI,
978         EFX_PHY_MEDIA_CX4,
979         EFX_PHY_MEDIA_KX4,
980         EFX_PHY_MEDIA_XFP,
981         EFX_PHY_MEDIA_SFP_PLUS,
982         EFX_PHY_MEDIA_BASE_T,
983         EFX_PHY_MEDIA_QSFP_PLUS,
984         EFX_PHY_MEDIA_NTYPES
985 } efx_phy_media_type_t;
986
987 /*
988  * Get the type of medium currently used.  If the board has ports for
989  * modules, a module is present, and we recognise the media type of
990  * the module, then this will be the media type of the module.
991  * Otherwise it will be the media type of the port.
992  */
993 extern                  void
994 efx_phy_media_type_get(
995         __in            efx_nic_t *enp,
996         __out           efx_phy_media_type_t *typep);
997
998 extern  __checkReturn           efx_rc_t
999 efx_phy_module_get_info(
1000         __in                    efx_nic_t *enp,
1001         __in                    uint8_t dev_addr,
1002         __in                    uint8_t offset,
1003         __in                    uint8_t len,
1004         __out_bcount(len)       uint8_t *data);
1005
1006 #if EFSYS_OPT_PHY_STATS
1007
1008 /* START MKCONFIG GENERATED PhyHeaderStatsBlock 30ed56ad501f8e36 */
1009 typedef enum efx_phy_stat_e {
1010         EFX_PHY_STAT_OUI,
1011         EFX_PHY_STAT_PMA_PMD_LINK_UP,
1012         EFX_PHY_STAT_PMA_PMD_RX_FAULT,
1013         EFX_PHY_STAT_PMA_PMD_TX_FAULT,
1014         EFX_PHY_STAT_PMA_PMD_REV_A,
1015         EFX_PHY_STAT_PMA_PMD_REV_B,
1016         EFX_PHY_STAT_PMA_PMD_REV_C,
1017         EFX_PHY_STAT_PMA_PMD_REV_D,
1018         EFX_PHY_STAT_PCS_LINK_UP,
1019         EFX_PHY_STAT_PCS_RX_FAULT,
1020         EFX_PHY_STAT_PCS_TX_FAULT,
1021         EFX_PHY_STAT_PCS_BER,
1022         EFX_PHY_STAT_PCS_BLOCK_ERRORS,
1023         EFX_PHY_STAT_PHY_XS_LINK_UP,
1024         EFX_PHY_STAT_PHY_XS_RX_FAULT,
1025         EFX_PHY_STAT_PHY_XS_TX_FAULT,
1026         EFX_PHY_STAT_PHY_XS_ALIGN,
1027         EFX_PHY_STAT_PHY_XS_SYNC_A,
1028         EFX_PHY_STAT_PHY_XS_SYNC_B,
1029         EFX_PHY_STAT_PHY_XS_SYNC_C,
1030         EFX_PHY_STAT_PHY_XS_SYNC_D,
1031         EFX_PHY_STAT_AN_LINK_UP,
1032         EFX_PHY_STAT_AN_MASTER,
1033         EFX_PHY_STAT_AN_LOCAL_RX_OK,
1034         EFX_PHY_STAT_AN_REMOTE_RX_OK,
1035         EFX_PHY_STAT_CL22EXT_LINK_UP,
1036         EFX_PHY_STAT_SNR_A,
1037         EFX_PHY_STAT_SNR_B,
1038         EFX_PHY_STAT_SNR_C,
1039         EFX_PHY_STAT_SNR_D,
1040         EFX_PHY_STAT_PMA_PMD_SIGNAL_A,
1041         EFX_PHY_STAT_PMA_PMD_SIGNAL_B,
1042         EFX_PHY_STAT_PMA_PMD_SIGNAL_C,
1043         EFX_PHY_STAT_PMA_PMD_SIGNAL_D,
1044         EFX_PHY_STAT_AN_COMPLETE,
1045         EFX_PHY_STAT_PMA_PMD_REV_MAJOR,
1046         EFX_PHY_STAT_PMA_PMD_REV_MINOR,
1047         EFX_PHY_STAT_PMA_PMD_REV_MICRO,
1048         EFX_PHY_STAT_PCS_FW_VERSION_0,
1049         EFX_PHY_STAT_PCS_FW_VERSION_1,
1050         EFX_PHY_STAT_PCS_FW_VERSION_2,
1051         EFX_PHY_STAT_PCS_FW_VERSION_3,
1052         EFX_PHY_STAT_PCS_FW_BUILD_YY,
1053         EFX_PHY_STAT_PCS_FW_BUILD_MM,
1054         EFX_PHY_STAT_PCS_FW_BUILD_DD,
1055         EFX_PHY_STAT_PCS_OP_MODE,
1056         EFX_PHY_NSTATS
1057 } efx_phy_stat_t;
1058
1059 /* END MKCONFIG GENERATED PhyHeaderStatsBlock */
1060
1061 #if EFSYS_OPT_NAMES
1062
1063 extern                                  const char *
1064 efx_phy_stat_name(
1065         __in                            efx_nic_t *enp,
1066         __in                            efx_phy_stat_t stat);
1067
1068 #endif  /* EFSYS_OPT_NAMES */
1069
1070 #define EFX_PHY_STATS_SIZE 0x100
1071
1072 extern  __checkReturn                   efx_rc_t
1073 efx_phy_stats_update(
1074         __in                            efx_nic_t *enp,
1075         __in                            efsys_mem_t *esmp,
1076         __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
1077
1078 #endif  /* EFSYS_OPT_PHY_STATS */
1079
1080
1081 #if EFSYS_OPT_BIST
1082
1083 typedef enum efx_bist_type_e {
1084         EFX_BIST_TYPE_UNKNOWN,
1085         EFX_BIST_TYPE_PHY_NORMAL,
1086         EFX_BIST_TYPE_PHY_CABLE_SHORT,
1087         EFX_BIST_TYPE_PHY_CABLE_LONG,
1088         EFX_BIST_TYPE_MC_MEM,   /* Test the MC DMEM and IMEM */
1089         EFX_BIST_TYPE_SAT_MEM,  /* Test the DMEM and IMEM of satellite cpus */
1090         EFX_BIST_TYPE_REG,      /* Test the register memories */
1091         EFX_BIST_TYPE_NTYPES,
1092 } efx_bist_type_t;
1093
1094 typedef enum efx_bist_result_e {
1095         EFX_BIST_RESULT_UNKNOWN,
1096         EFX_BIST_RESULT_RUNNING,
1097         EFX_BIST_RESULT_PASSED,
1098         EFX_BIST_RESULT_FAILED,
1099 } efx_bist_result_t;
1100
1101 typedef enum efx_phy_cable_status_e {
1102         EFX_PHY_CABLE_STATUS_OK,
1103         EFX_PHY_CABLE_STATUS_INVALID,
1104         EFX_PHY_CABLE_STATUS_OPEN,
1105         EFX_PHY_CABLE_STATUS_INTRAPAIRSHORT,
1106         EFX_PHY_CABLE_STATUS_INTERPAIRSHORT,
1107         EFX_PHY_CABLE_STATUS_BUSY,
1108 } efx_phy_cable_status_t;
1109
1110 typedef enum efx_bist_value_e {
1111         EFX_BIST_PHY_CABLE_LENGTH_A,
1112         EFX_BIST_PHY_CABLE_LENGTH_B,
1113         EFX_BIST_PHY_CABLE_LENGTH_C,
1114         EFX_BIST_PHY_CABLE_LENGTH_D,
1115         EFX_BIST_PHY_CABLE_STATUS_A,
1116         EFX_BIST_PHY_CABLE_STATUS_B,
1117         EFX_BIST_PHY_CABLE_STATUS_C,
1118         EFX_BIST_PHY_CABLE_STATUS_D,
1119         EFX_BIST_FAULT_CODE,
1120         /*
1121          * Memory BIST specific values. These match to the MC_CMD_BIST_POLL
1122          * response.
1123          */
1124         EFX_BIST_MEM_TEST,
1125         EFX_BIST_MEM_ADDR,
1126         EFX_BIST_MEM_BUS,
1127         EFX_BIST_MEM_EXPECT,
1128         EFX_BIST_MEM_ACTUAL,
1129         EFX_BIST_MEM_ECC,
1130         EFX_BIST_MEM_ECC_PARITY,
1131         EFX_BIST_MEM_ECC_FATAL,
1132         EFX_BIST_NVALUES,
1133 } efx_bist_value_t;
1134
1135 extern  __checkReturn           efx_rc_t
1136 efx_bist_enable_offline(
1137         __in                    efx_nic_t *enp);
1138
1139 extern  __checkReturn           efx_rc_t
1140 efx_bist_start(
1141         __in                    efx_nic_t *enp,
1142         __in                    efx_bist_type_t type);
1143
1144 extern  __checkReturn           efx_rc_t
1145 efx_bist_poll(
1146         __in                    efx_nic_t *enp,
1147         __in                    efx_bist_type_t type,
1148         __out                   efx_bist_result_t *resultp,
1149         __out_opt               uint32_t *value_maskp,
1150         __out_ecount_opt(count) unsigned long *valuesp,
1151         __in                    size_t count);
1152
1153 extern                          void
1154 efx_bist_stop(
1155         __in                    efx_nic_t *enp,
1156         __in                    efx_bist_type_t type);
1157
1158 #endif  /* EFSYS_OPT_BIST */
1159
1160 #define EFX_FEATURE_IPV6                0x00000001
1161 #define EFX_FEATURE_LFSR_HASH_INSERT    0x00000002
1162 #define EFX_FEATURE_LINK_EVENTS         0x00000004
1163 #define EFX_FEATURE_PERIODIC_MAC_STATS  0x00000008
1164 #define EFX_FEATURE_MCDI                0x00000020
1165 #define EFX_FEATURE_LOOKAHEAD_SPLIT     0x00000040
1166 #define EFX_FEATURE_MAC_HEADER_FILTERS  0x00000080
1167 #define EFX_FEATURE_TURBO               0x00000100
1168 #define EFX_FEATURE_MCDI_DMA            0x00000200
1169 #define EFX_FEATURE_TX_SRC_FILTERS      0x00000400
1170 #define EFX_FEATURE_PIO_BUFFERS         0x00000800
1171 #define EFX_FEATURE_FW_ASSISTED_TSO     0x00001000
1172 #define EFX_FEATURE_FW_ASSISTED_TSO_V2  0x00002000
1173 #define EFX_FEATURE_PACKED_STREAM       0x00004000
1174
1175 typedef enum efx_tunnel_protocol_e {
1176         EFX_TUNNEL_PROTOCOL_NONE = 0,
1177         EFX_TUNNEL_PROTOCOL_VXLAN,
1178         EFX_TUNNEL_PROTOCOL_GENEVE,
1179         EFX_TUNNEL_PROTOCOL_NVGRE,
1180         EFX_TUNNEL_NPROTOS
1181 } efx_tunnel_protocol_t;
1182
1183 typedef enum efx_vi_window_shift_e {
1184         EFX_VI_WINDOW_SHIFT_INVALID = 0,
1185         EFX_VI_WINDOW_SHIFT_8K = 13,
1186         EFX_VI_WINDOW_SHIFT_16K = 14,
1187         EFX_VI_WINDOW_SHIFT_64K = 16,
1188 } efx_vi_window_shift_t;
1189
1190 typedef struct efx_nic_cfg_s {
1191         uint32_t                enc_board_type;
1192         uint32_t                enc_phy_type;
1193 #if EFSYS_OPT_NAMES
1194         char                    enc_phy_name[21];
1195 #endif
1196         char                    enc_phy_revision[21];
1197         efx_mon_type_t          enc_mon_type;
1198 #if EFSYS_OPT_MON_STATS
1199         uint32_t                enc_mon_stat_dma_buf_size;
1200         uint32_t                enc_mon_stat_mask[(EFX_MON_NSTATS + 31) / 32];
1201 #endif
1202         unsigned int            enc_features;
1203         efx_vi_window_shift_t   enc_vi_window_shift;
1204         uint8_t                 enc_mac_addr[6];
1205         uint8_t                 enc_port;       /* PHY port number */
1206         uint32_t                enc_intr_vec_base;
1207         uint32_t                enc_intr_limit;
1208         uint32_t                enc_evq_limit;
1209         uint32_t                enc_txq_limit;
1210         uint32_t                enc_rxq_limit;
1211         uint32_t                enc_txq_max_ndescs;
1212         uint32_t                enc_buftbl_limit;
1213         uint32_t                enc_piobuf_limit;
1214         uint32_t                enc_piobuf_size;
1215         uint32_t                enc_piobuf_min_alloc_size;
1216         uint32_t                enc_evq_timer_quantum_ns;
1217         uint32_t                enc_evq_timer_max_us;
1218         uint32_t                enc_clk_mult;
1219         uint32_t                enc_rx_prefix_size;
1220         uint32_t                enc_rx_buf_align_start;
1221         uint32_t                enc_rx_buf_align_end;
1222         uint32_t                enc_rx_scale_max_exclusive_contexts;
1223         /*
1224          * Mask of supported hash algorithms.
1225          * Hash algorithm types are used as the bit indices.
1226          */
1227         uint32_t                enc_rx_scale_hash_alg_mask;
1228         /*
1229          * Indicates whether port numbers can be included to the
1230          * input data for hash computation.
1231          */
1232         boolean_t               enc_rx_scale_l4_hash_supported;
1233         boolean_t               enc_rx_scale_additional_modes_supported;
1234 #if EFSYS_OPT_LOOPBACK
1235         efx_qword_t             enc_loopback_types[EFX_LINK_NMODES];
1236 #endif  /* EFSYS_OPT_LOOPBACK */
1237 #if EFSYS_OPT_PHY_FLAGS
1238         uint32_t                enc_phy_flags_mask;
1239 #endif  /* EFSYS_OPT_PHY_FLAGS */
1240 #if EFSYS_OPT_PHY_LED_CONTROL
1241         uint32_t                enc_led_mask;
1242 #endif  /* EFSYS_OPT_PHY_LED_CONTROL */
1243 #if EFSYS_OPT_PHY_STATS
1244         uint64_t                enc_phy_stat_mask;
1245 #endif  /* EFSYS_OPT_PHY_STATS */
1246 #if EFSYS_OPT_MCDI
1247         uint8_t                 enc_mcdi_mdio_channel;
1248 #if EFSYS_OPT_PHY_STATS
1249         uint32_t                enc_mcdi_phy_stat_mask;
1250 #endif  /* EFSYS_OPT_PHY_STATS */
1251 #if EFSYS_OPT_MON_STATS
1252         uint32_t                *enc_mcdi_sensor_maskp;
1253         uint32_t                enc_mcdi_sensor_mask_size;
1254 #endif  /* EFSYS_OPT_MON_STATS */
1255 #endif  /* EFSYS_OPT_MCDI */
1256 #if EFSYS_OPT_BIST
1257         uint32_t                enc_bist_mask;
1258 #endif  /* EFSYS_OPT_BIST */
1259 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
1260         uint32_t                enc_pf;
1261         uint32_t                enc_vf;
1262         uint32_t                enc_privilege_mask;
1263 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
1264         boolean_t               enc_bug26807_workaround;
1265         boolean_t               enc_bug35388_workaround;
1266         boolean_t               enc_bug41750_workaround;
1267         boolean_t               enc_bug61265_workaround;
1268         boolean_t               enc_rx_batching_enabled;
1269         /* Maximum number of descriptors completed in an rx event. */
1270         uint32_t                enc_rx_batch_max;
1271         /* Number of rx descriptors the hardware requires for a push. */
1272         uint32_t                enc_rx_push_align;
1273         /* Maximum amount of data in DMA descriptor */
1274         uint32_t                enc_tx_dma_desc_size_max;
1275         /*
1276          * Boundary which DMA descriptor data must not cross or 0 if no
1277          * limitation.
1278          */
1279         uint32_t                enc_tx_dma_desc_boundary;
1280         /*
1281          * Maximum number of bytes into the packet the TCP header can start for
1282          * the hardware to apply TSO packet edits.
1283          */
1284         uint32_t                enc_tx_tso_tcp_header_offset_limit;
1285         boolean_t               enc_fw_assisted_tso_enabled;
1286         boolean_t               enc_fw_assisted_tso_v2_enabled;
1287         boolean_t               enc_fw_assisted_tso_v2_encap_enabled;
1288         /* Number of TSO contexts on the NIC (FATSOv2) */
1289         uint32_t                enc_fw_assisted_tso_v2_n_contexts;
1290         boolean_t               enc_hw_tx_insert_vlan_enabled;
1291         /* Number of PFs on the NIC */
1292         uint32_t                enc_hw_pf_count;
1293         /* Datapath firmware vadapter/vport/vswitch support */
1294         boolean_t               enc_datapath_cap_evb;
1295         boolean_t               enc_rx_disable_scatter_supported;
1296         boolean_t               enc_allow_set_mac_with_installed_filters;
1297         boolean_t               enc_enhanced_set_mac_supported;
1298         boolean_t               enc_init_evq_v2_supported;
1299         boolean_t               enc_rx_packed_stream_supported;
1300         boolean_t               enc_rx_var_packed_stream_supported;
1301         boolean_t               enc_rx_es_super_buffer_supported;
1302         boolean_t               enc_fw_subvariant_no_tx_csum_supported;
1303         boolean_t               enc_pm_and_rxdp_counters;
1304         boolean_t               enc_mac_stats_40g_tx_size_bins;
1305         uint32_t                enc_tunnel_encapsulations_supported;
1306         /*
1307          * NIC global maximum for unique UDP tunnel ports shared by all
1308          * functions.
1309          */
1310         uint32_t                enc_tunnel_config_udp_entries_max;
1311         /* External port identifier */
1312         uint8_t                 enc_external_port;
1313         uint32_t                enc_mcdi_max_payload_length;
1314         /* VPD may be per-PF or global */
1315         boolean_t               enc_vpd_is_global;
1316         /* Minimum unidirectional bandwidth in Mb/s to max out all ports */
1317         uint32_t                enc_required_pcie_bandwidth_mbps;
1318         uint32_t                enc_max_pcie_link_gen;
1319         /* Firmware verifies integrity of NVRAM updates */
1320         uint32_t                enc_nvram_update_verify_result_supported;
1321         /* Firmware support for extended MAC_STATS buffer */
1322         uint32_t                enc_mac_stats_nstats;
1323         boolean_t               enc_fec_counters;
1324         /* Firmware support for "FLAG" and "MARK" filter actions */
1325         boolean_t               enc_filter_action_flag_supported;
1326         boolean_t               enc_filter_action_mark_supported;
1327 } efx_nic_cfg_t;
1328
1329 #define EFX_PCI_FUNCTION_IS_PF(_encp)   ((_encp)->enc_vf == 0xffff)
1330 #define EFX_PCI_FUNCTION_IS_VF(_encp)   ((_encp)->enc_vf != 0xffff)
1331
1332 #define EFX_PCI_FUNCTION(_encp) \
1333         (EFX_PCI_FUNCTION_IS_PF(_encp) ? (_encp)->enc_pf : (_encp)->enc_vf)
1334
1335 #define EFX_PCI_VF_PARENT(_encp)        ((_encp)->enc_pf)
1336
1337 extern                  const efx_nic_cfg_t *
1338 efx_nic_cfg_get(
1339         __in            efx_nic_t *enp);
1340
1341 /* RxDPCPU firmware id values by which FW variant can be identified */
1342 #define EFX_RXDP_FULL_FEATURED_FW_ID    0x0
1343 #define EFX_RXDP_LOW_LATENCY_FW_ID      0x1
1344 #define EFX_RXDP_PACKED_STREAM_FW_ID    0x2
1345 #define EFX_RXDP_RULES_ENGINE_FW_ID     0x5
1346 #define EFX_RXDP_DPDK_FW_ID             0x6
1347
1348 typedef struct efx_nic_fw_info_s {
1349         /* Basic FW version information */
1350         uint16_t        enfi_mc_fw_version[4];
1351         /*
1352          * If datapath capabilities can be detected,
1353          * additional FW information is to be shown
1354          */
1355         boolean_t       enfi_dpcpu_fw_ids_valid;
1356         /* Rx and Tx datapath CPU FW IDs */
1357         uint16_t        enfi_rx_dpcpu_fw_id;
1358         uint16_t        enfi_tx_dpcpu_fw_id;
1359 } efx_nic_fw_info_t;
1360
1361 extern  __checkReturn           efx_rc_t
1362 efx_nic_get_fw_version(
1363         __in                    efx_nic_t *enp,
1364         __out                   efx_nic_fw_info_t *enfip);
1365
1366 /* Driver resource limits (minimum required/maximum usable). */
1367 typedef struct efx_drv_limits_s {
1368         uint32_t        edl_min_evq_count;
1369         uint32_t        edl_max_evq_count;
1370
1371         uint32_t        edl_min_rxq_count;
1372         uint32_t        edl_max_rxq_count;
1373
1374         uint32_t        edl_min_txq_count;
1375         uint32_t        edl_max_txq_count;
1376
1377         /* PIO blocks (sub-allocated from piobuf) */
1378         uint32_t        edl_min_pio_alloc_size;
1379         uint32_t        edl_max_pio_alloc_count;
1380 } efx_drv_limits_t;
1381
1382 extern  __checkReturn   efx_rc_t
1383 efx_nic_set_drv_limits(
1384         __inout         efx_nic_t *enp,
1385         __in            efx_drv_limits_t *edlp);
1386
1387 typedef enum efx_nic_region_e {
1388         EFX_REGION_VI,                  /* Memory BAR UC mapping */
1389         EFX_REGION_PIO_WRITE_VI,        /* Memory BAR WC mapping */
1390 } efx_nic_region_t;
1391
1392 extern  __checkReturn   efx_rc_t
1393 efx_nic_get_bar_region(
1394         __in            efx_nic_t *enp,
1395         __in            efx_nic_region_t region,
1396         __out           uint32_t *offsetp,
1397         __out           size_t *sizep);
1398
1399 extern  __checkReturn   efx_rc_t
1400 efx_nic_get_vi_pool(
1401         __in            efx_nic_t *enp,
1402         __out           uint32_t *evq_countp,
1403         __out           uint32_t *rxq_countp,
1404         __out           uint32_t *txq_countp);
1405
1406
1407 #if EFSYS_OPT_VPD
1408
1409 typedef enum efx_vpd_tag_e {
1410         EFX_VPD_ID = 0x02,
1411         EFX_VPD_END = 0x0f,
1412         EFX_VPD_RO = 0x10,
1413         EFX_VPD_RW = 0x11,
1414 } efx_vpd_tag_t;
1415
1416 typedef uint16_t efx_vpd_keyword_t;
1417
1418 typedef struct efx_vpd_value_s {
1419         efx_vpd_tag_t           evv_tag;
1420         efx_vpd_keyword_t       evv_keyword;
1421         uint8_t                 evv_length;
1422         uint8_t                 evv_value[0x100];
1423 } efx_vpd_value_t;
1424
1425
1426 #define EFX_VPD_KEYWORD(x, y) ((x) | ((y) << 8))
1427
1428 extern  __checkReturn           efx_rc_t
1429 efx_vpd_init(
1430         __in                    efx_nic_t *enp);
1431
1432 extern  __checkReturn           efx_rc_t
1433 efx_vpd_size(
1434         __in                    efx_nic_t *enp,
1435         __out                   size_t *sizep);
1436
1437 extern  __checkReturn           efx_rc_t
1438 efx_vpd_read(
1439         __in                    efx_nic_t *enp,
1440         __out_bcount(size)      caddr_t data,
1441         __in                    size_t size);
1442
1443 extern  __checkReturn           efx_rc_t
1444 efx_vpd_verify(
1445         __in                    efx_nic_t *enp,
1446         __in_bcount(size)       caddr_t data,
1447         __in                    size_t size);
1448
1449 extern  __checkReturn           efx_rc_t
1450 efx_vpd_reinit(
1451         __in                    efx_nic_t *enp,
1452         __in_bcount(size)       caddr_t data,
1453         __in                    size_t size);
1454
1455 extern  __checkReturn           efx_rc_t
1456 efx_vpd_get(
1457         __in                    efx_nic_t *enp,
1458         __in_bcount(size)       caddr_t data,
1459         __in                    size_t size,
1460         __inout                 efx_vpd_value_t *evvp);
1461
1462 extern  __checkReturn           efx_rc_t
1463 efx_vpd_set(
1464         __in                    efx_nic_t *enp,
1465         __inout_bcount(size)    caddr_t data,
1466         __in                    size_t size,
1467         __in                    efx_vpd_value_t *evvp);
1468
1469 extern  __checkReturn           efx_rc_t
1470 efx_vpd_next(
1471         __in                    efx_nic_t *enp,
1472         __inout_bcount(size)    caddr_t data,
1473         __in                    size_t size,
1474         __out                   efx_vpd_value_t *evvp,
1475         __inout                 unsigned int *contp);
1476
1477 extern  __checkReturn           efx_rc_t
1478 efx_vpd_write(
1479         __in                    efx_nic_t *enp,
1480         __in_bcount(size)       caddr_t data,
1481         __in                    size_t size);
1482
1483 extern                          void
1484 efx_vpd_fini(
1485         __in                    efx_nic_t *enp);
1486
1487 #endif  /* EFSYS_OPT_VPD */
1488
1489 /* NVRAM */
1490
1491 #if EFSYS_OPT_NVRAM
1492
1493 typedef enum efx_nvram_type_e {
1494         EFX_NVRAM_INVALID = 0,
1495         EFX_NVRAM_BOOTROM,
1496         EFX_NVRAM_BOOTROM_CFG,
1497         EFX_NVRAM_MC_FIRMWARE,
1498         EFX_NVRAM_MC_GOLDEN,
1499         EFX_NVRAM_PHY,
1500         EFX_NVRAM_NULLPHY,
1501         EFX_NVRAM_FPGA,
1502         EFX_NVRAM_FCFW,
1503         EFX_NVRAM_CPLD,
1504         EFX_NVRAM_FPGA_BACKUP,
1505         EFX_NVRAM_DYNAMIC_CFG,
1506         EFX_NVRAM_LICENSE,
1507         EFX_NVRAM_UEFIROM,
1508         EFX_NVRAM_MUM_FIRMWARE,
1509         EFX_NVRAM_NTYPES,
1510 } efx_nvram_type_t;
1511
1512 extern  __checkReturn           efx_rc_t
1513 efx_nvram_init(
1514         __in                    efx_nic_t *enp);
1515
1516 #if EFSYS_OPT_DIAG
1517
1518 extern  __checkReturn           efx_rc_t
1519 efx_nvram_test(
1520         __in                    efx_nic_t *enp);
1521
1522 #endif  /* EFSYS_OPT_DIAG */
1523
1524 extern  __checkReturn           efx_rc_t
1525 efx_nvram_size(
1526         __in                    efx_nic_t *enp,
1527         __in                    efx_nvram_type_t type,
1528         __out                   size_t *sizep);
1529
1530 extern  __checkReturn           efx_rc_t
1531 efx_nvram_rw_start(
1532         __in                    efx_nic_t *enp,
1533         __in                    efx_nvram_type_t type,
1534         __out_opt               size_t *pref_chunkp);
1535
1536 extern  __checkReturn           efx_rc_t
1537 efx_nvram_rw_finish(
1538         __in                    efx_nic_t *enp,
1539         __in                    efx_nvram_type_t type,
1540         __out_opt               uint32_t *verify_resultp);
1541
1542 extern  __checkReturn           efx_rc_t
1543 efx_nvram_get_version(
1544         __in                    efx_nic_t *enp,
1545         __in                    efx_nvram_type_t type,
1546         __out                   uint32_t *subtypep,
1547         __out_ecount(4)         uint16_t version[4]);
1548
1549 extern  __checkReturn           efx_rc_t
1550 efx_nvram_read_chunk(
1551         __in                    efx_nic_t *enp,
1552         __in                    efx_nvram_type_t type,
1553         __in                    unsigned int offset,
1554         __out_bcount(size)      caddr_t data,
1555         __in                    size_t size);
1556
1557 extern  __checkReturn           efx_rc_t
1558 efx_nvram_read_backup(
1559         __in                    efx_nic_t *enp,
1560         __in                    efx_nvram_type_t type,
1561         __in                    unsigned int offset,
1562         __out_bcount(size)      caddr_t data,
1563         __in                    size_t size);
1564
1565 extern  __checkReturn           efx_rc_t
1566 efx_nvram_set_version(
1567         __in                    efx_nic_t *enp,
1568         __in                    efx_nvram_type_t type,
1569         __in_ecount(4)          uint16_t version[4]);
1570
1571 extern  __checkReturn           efx_rc_t
1572 efx_nvram_validate(
1573         __in                    efx_nic_t *enp,
1574         __in                    efx_nvram_type_t type,
1575         __in_bcount(partn_size) caddr_t partn_data,
1576         __in                    size_t partn_size);
1577
1578 extern   __checkReturn          efx_rc_t
1579 efx_nvram_erase(
1580         __in                    efx_nic_t *enp,
1581         __in                    efx_nvram_type_t type);
1582
1583 extern  __checkReturn           efx_rc_t
1584 efx_nvram_write_chunk(
1585         __in                    efx_nic_t *enp,
1586         __in                    efx_nvram_type_t type,
1587         __in                    unsigned int offset,
1588         __in_bcount(size)       caddr_t data,
1589         __in                    size_t size);
1590
1591 extern                          void
1592 efx_nvram_fini(
1593         __in                    efx_nic_t *enp);
1594
1595 #endif  /* EFSYS_OPT_NVRAM */
1596
1597 #if EFSYS_OPT_BOOTCFG
1598
1599 /* Report size and offset of bootcfg sector in NVRAM partition. */
1600 extern  __checkReturn           efx_rc_t
1601 efx_bootcfg_sector_info(
1602         __in                    efx_nic_t *enp,
1603         __in                    uint32_t pf,
1604         __out_opt               uint32_t *sector_countp,
1605         __out                   size_t *offsetp,
1606         __out                   size_t *max_sizep);
1607
1608 /*
1609  * Copy bootcfg sector data to a target buffer which may differ in size.
1610  * Optionally corrects format errors in source buffer.
1611  */
1612 extern                          efx_rc_t
1613 efx_bootcfg_copy_sector(
1614         __in                    efx_nic_t *enp,
1615         __inout_bcount(sector_length)
1616                                 uint8_t *sector,
1617         __in                    size_t sector_length,
1618         __out_bcount(data_size) uint8_t *data,
1619         __in                    size_t data_size,
1620         __in                    boolean_t handle_format_errors);
1621
1622 extern                          efx_rc_t
1623 efx_bootcfg_read(
1624         __in                    efx_nic_t *enp,
1625         __out_bcount(size)      uint8_t *data,
1626         __in                    size_t size);
1627
1628 extern                          efx_rc_t
1629 efx_bootcfg_write(
1630         __in                    efx_nic_t *enp,
1631         __in_bcount(size)       uint8_t *data,
1632         __in                    size_t size);
1633
1634 #endif  /* EFSYS_OPT_BOOTCFG */
1635
1636 #if EFSYS_OPT_IMAGE_LAYOUT
1637
1638 #include "ef10_signed_image_layout.h"
1639
1640 /*
1641  * Image header used in unsigned and signed image layouts (see SF-102785-PS).
1642  *
1643  * NOTE:
1644  * The image header format is extensible. However, older drivers require an
1645  * exact match of image header version and header length when validating and
1646  * writing firmware images.
1647  *
1648  * To avoid breaking backward compatibility, we use the upper bits of the
1649  * controller version fields to contain an extra version number used for
1650  * combined bootROM and UEFI ROM images on EF10 and later (to hold the UEFI ROM
1651  * version). See bug39254 and SF-102785-PS for details.
1652  */
1653 typedef struct efx_image_header_s {
1654         uint32_t        eih_magic;
1655         uint32_t        eih_version;
1656         uint32_t        eih_type;
1657         uint32_t        eih_subtype;
1658         uint32_t        eih_code_size;
1659         uint32_t        eih_size;
1660         union {
1661                 uint32_t        eih_controller_version_min;
1662                 struct {
1663                         uint16_t        eih_controller_version_min_short;
1664                         uint8_t         eih_extra_version_a;
1665                         uint8_t         eih_extra_version_b;
1666                 };
1667         };
1668         union {
1669                 uint32_t        eih_controller_version_max;
1670                 struct {
1671                         uint16_t        eih_controller_version_max_short;
1672                         uint8_t         eih_extra_version_c;
1673                         uint8_t         eih_extra_version_d;
1674                 };
1675         };
1676         uint16_t        eih_code_version_a;
1677         uint16_t        eih_code_version_b;
1678         uint16_t        eih_code_version_c;
1679         uint16_t        eih_code_version_d;
1680 } efx_image_header_t;
1681
1682 #define EFX_IMAGE_HEADER_SIZE           (40)
1683 #define EFX_IMAGE_HEADER_VERSION        (4)
1684 #define EFX_IMAGE_HEADER_MAGIC          (0x106F1A5)
1685
1686
1687 typedef struct efx_image_trailer_s {
1688         uint32_t        eit_crc;
1689 } efx_image_trailer_t;
1690
1691 #define EFX_IMAGE_TRAILER_SIZE          (4)
1692
1693 typedef enum efx_image_format_e {
1694         EFX_IMAGE_FORMAT_NO_IMAGE,
1695         EFX_IMAGE_FORMAT_INVALID,
1696         EFX_IMAGE_FORMAT_UNSIGNED,
1697         EFX_IMAGE_FORMAT_SIGNED,
1698 } efx_image_format_t;
1699
1700 typedef struct efx_image_info_s {
1701         efx_image_format_t      eii_format;
1702         uint8_t *               eii_imagep;
1703         size_t                  eii_image_size;
1704         efx_image_header_t *    eii_headerp;
1705 } efx_image_info_t;
1706
1707 extern  __checkReturn   efx_rc_t
1708 efx_check_reflash_image(
1709         __in            void                    *bufferp,
1710         __in            uint32_t                buffer_size,
1711         __out           efx_image_info_t        *infop);
1712
1713 extern  __checkReturn   efx_rc_t
1714 efx_build_signed_image_write_buffer(
1715         __out_bcount(buffer_size)
1716                         uint8_t                 *bufferp,
1717         __in            uint32_t                buffer_size,
1718         __in            efx_image_info_t        *infop,
1719         __out           efx_image_header_t      **headerpp);
1720
1721 #endif  /* EFSYS_OPT_IMAGE_LAYOUT */
1722
1723 #if EFSYS_OPT_DIAG
1724
1725 typedef enum efx_pattern_type_t {
1726         EFX_PATTERN_BYTE_INCREMENT = 0,
1727         EFX_PATTERN_ALL_THE_SAME,
1728         EFX_PATTERN_BIT_ALTERNATE,
1729         EFX_PATTERN_BYTE_ALTERNATE,
1730         EFX_PATTERN_BYTE_CHANGING,
1731         EFX_PATTERN_BIT_SWEEP,
1732         EFX_PATTERN_NTYPES
1733 } efx_pattern_type_t;
1734
1735 typedef                 void
1736 (*efx_sram_pattern_fn_t)(
1737         __in            size_t row,
1738         __in            boolean_t negate,
1739         __out           efx_qword_t *eqp);
1740
1741 extern  __checkReturn   efx_rc_t
1742 efx_sram_test(
1743         __in            efx_nic_t *enp,
1744         __in            efx_pattern_type_t type);
1745
1746 #endif  /* EFSYS_OPT_DIAG */
1747
1748 extern  __checkReturn   efx_rc_t
1749 efx_sram_buf_tbl_set(
1750         __in            efx_nic_t *enp,
1751         __in            uint32_t id,
1752         __in            efsys_mem_t *esmp,
1753         __in            size_t n);
1754
1755 extern          void
1756 efx_sram_buf_tbl_clear(
1757         __in    efx_nic_t *enp,
1758         __in    uint32_t id,
1759         __in    size_t n);
1760
1761 #define EFX_BUF_TBL_SIZE        0x20000
1762
1763 #define EFX_BUF_SIZE            4096
1764
1765 /* EV */
1766
1767 typedef struct efx_evq_s        efx_evq_t;
1768
1769 #if EFSYS_OPT_QSTATS
1770
1771 /* START MKCONFIG GENERATED EfxHeaderEventQueueBlock 6f3843f5fe7cc843 */
1772 typedef enum efx_ev_qstat_e {
1773         EV_ALL,
1774         EV_RX,
1775         EV_RX_OK,
1776         EV_RX_FRM_TRUNC,
1777         EV_RX_TOBE_DISC,
1778         EV_RX_PAUSE_FRM_ERR,
1779         EV_RX_BUF_OWNER_ID_ERR,
1780         EV_RX_IPV4_HDR_CHKSUM_ERR,
1781         EV_RX_TCP_UDP_CHKSUM_ERR,
1782         EV_RX_ETH_CRC_ERR,
1783         EV_RX_IP_FRAG_ERR,
1784         EV_RX_MCAST_PKT,
1785         EV_RX_MCAST_HASH_MATCH,
1786         EV_RX_TCP_IPV4,
1787         EV_RX_TCP_IPV6,
1788         EV_RX_UDP_IPV4,
1789         EV_RX_UDP_IPV6,
1790         EV_RX_OTHER_IPV4,
1791         EV_RX_OTHER_IPV6,
1792         EV_RX_NON_IP,
1793         EV_RX_BATCH,
1794         EV_TX,
1795         EV_TX_WQ_FF_FULL,
1796         EV_TX_PKT_ERR,
1797         EV_TX_PKT_TOO_BIG,
1798         EV_TX_UNEXPECTED,
1799         EV_GLOBAL,
1800         EV_GLOBAL_MNT,
1801         EV_DRIVER,
1802         EV_DRIVER_SRM_UPD_DONE,
1803         EV_DRIVER_TX_DESCQ_FLS_DONE,
1804         EV_DRIVER_RX_DESCQ_FLS_DONE,
1805         EV_DRIVER_RX_DESCQ_FLS_FAILED,
1806         EV_DRIVER_RX_DSC_ERROR,
1807         EV_DRIVER_TX_DSC_ERROR,
1808         EV_DRV_GEN,
1809         EV_MCDI_RESPONSE,
1810         EV_NQSTATS
1811 } efx_ev_qstat_t;
1812
1813 /* END MKCONFIG GENERATED EfxHeaderEventQueueBlock */
1814
1815 #endif  /* EFSYS_OPT_QSTATS */
1816
1817 extern  __checkReturn   efx_rc_t
1818 efx_ev_init(
1819         __in            efx_nic_t *enp);
1820
1821 extern          void
1822 efx_ev_fini(
1823         __in            efx_nic_t *enp);
1824
1825 #define EFX_EVQ_MAXNEVS         32768
1826 #define EFX_EVQ_MINNEVS         512
1827
1828 #define EFX_EVQ_SIZE(_nevs)     ((_nevs) * sizeof (efx_qword_t))
1829 #define EFX_EVQ_NBUFS(_nevs)    (EFX_EVQ_SIZE(_nevs) / EFX_BUF_SIZE)
1830
1831 #define EFX_EVQ_FLAGS_TYPE_MASK         (0x3)
1832 #define EFX_EVQ_FLAGS_TYPE_AUTO         (0x0)
1833 #define EFX_EVQ_FLAGS_TYPE_THROUGHPUT   (0x1)
1834 #define EFX_EVQ_FLAGS_TYPE_LOW_LATENCY  (0x2)
1835
1836 #define EFX_EVQ_FLAGS_NOTIFY_MASK       (0xC)
1837 #define EFX_EVQ_FLAGS_NOTIFY_INTERRUPT  (0x0)   /* Interrupting (default) */
1838 #define EFX_EVQ_FLAGS_NOTIFY_DISABLED   (0x4)   /* Non-interrupting */
1839
1840 extern  __checkReturn   efx_rc_t
1841 efx_ev_qcreate(
1842         __in            efx_nic_t *enp,
1843         __in            unsigned int index,
1844         __in            efsys_mem_t *esmp,
1845         __in            size_t ndescs,
1846         __in            uint32_t id,
1847         __in            uint32_t us,
1848         __in            uint32_t flags,
1849         __deref_out     efx_evq_t **eepp);
1850
1851 extern          void
1852 efx_ev_qpost(
1853         __in            efx_evq_t *eep,
1854         __in            uint16_t data);
1855
1856 typedef __checkReturn   boolean_t
1857 (*efx_initialized_ev_t)(
1858         __in_opt        void *arg);
1859
1860 #define EFX_PKT_UNICAST         0x0004
1861 #define EFX_PKT_START           0x0008
1862
1863 #define EFX_PKT_VLAN_TAGGED     0x0010
1864 #define EFX_CKSUM_TCPUDP        0x0020
1865 #define EFX_CKSUM_IPV4          0x0040
1866 #define EFX_PKT_CONT            0x0080
1867
1868 #define EFX_CHECK_VLAN          0x0100
1869 #define EFX_PKT_TCP             0x0200
1870 #define EFX_PKT_UDP             0x0400
1871 #define EFX_PKT_IPV4            0x0800
1872
1873 #define EFX_PKT_IPV6            0x1000
1874 #define EFX_PKT_PREFIX_LEN      0x2000
1875 #define EFX_ADDR_MISMATCH       0x4000
1876 #define EFX_DISCARD             0x8000
1877
1878 /*
1879  * The following flags are used only for packed stream
1880  * mode. The values for the flags are reused to fit into 16 bit,
1881  * since EFX_PKT_START and EFX_PKT_CONT are never used in
1882  * packed stream mode
1883  */
1884 #define EFX_PKT_PACKED_STREAM_NEW_BUFFER        EFX_PKT_START
1885 #define EFX_PKT_PACKED_STREAM_PARSE_INCOMPLETE  EFX_PKT_CONT
1886
1887
1888 #define EFX_EV_RX_NLABELS       32
1889 #define EFX_EV_TX_NLABELS       32
1890
1891 typedef __checkReturn   boolean_t
1892 (*efx_rx_ev_t)(
1893         __in_opt        void *arg,
1894         __in            uint32_t label,
1895         __in            uint32_t id,
1896         __in            uint32_t size,
1897         __in            uint16_t flags);
1898
1899 #if EFSYS_OPT_RX_PACKED_STREAM || EFSYS_OPT_RX_ES_SUPER_BUFFER
1900
1901 /*
1902  * Packed stream mode is documented in SF-112241-TC.
1903  * The general idea is that, instead of putting each incoming
1904  * packet into a separate buffer which is specified in a RX
1905  * descriptor, a large buffer is provided to the hardware and
1906  * packets are put there in a continuous stream.
1907  * The main advantage of such an approach is that RX queue refilling
1908  * happens much less frequently.
1909  *
1910  * Equal stride packed stream mode is documented in SF-119419-TC.
1911  * The general idea is to utilize advantages of the packed stream,
1912  * but avoid indirection in packets representation.
1913  * The main advantage of such an approach is that RX queue refilling
1914  * happens much less frequently and packets buffers are independent
1915  * from upper layers point of view.
1916  */
1917
1918 typedef __checkReturn   boolean_t
1919 (*efx_rx_ps_ev_t)(
1920         __in_opt        void *arg,
1921         __in            uint32_t label,
1922         __in            uint32_t id,
1923         __in            uint32_t pkt_count,
1924         __in            uint16_t flags);
1925
1926 #endif
1927
1928 typedef __checkReturn   boolean_t
1929 (*efx_tx_ev_t)(
1930         __in_opt        void *arg,
1931         __in            uint32_t label,
1932         __in            uint32_t id);
1933
1934 #define EFX_EXCEPTION_RX_RECOVERY       0x00000001
1935 #define EFX_EXCEPTION_RX_DSC_ERROR      0x00000002
1936 #define EFX_EXCEPTION_TX_DSC_ERROR      0x00000003
1937 #define EFX_EXCEPTION_UNKNOWN_SENSOREVT 0x00000004
1938 #define EFX_EXCEPTION_FWALERT_SRAM      0x00000005
1939 #define EFX_EXCEPTION_UNKNOWN_FWALERT   0x00000006
1940 #define EFX_EXCEPTION_RX_ERROR          0x00000007
1941 #define EFX_EXCEPTION_TX_ERROR          0x00000008
1942 #define EFX_EXCEPTION_EV_ERROR          0x00000009
1943
1944 typedef __checkReturn   boolean_t
1945 (*efx_exception_ev_t)(
1946         __in_opt        void *arg,
1947         __in            uint32_t label,
1948         __in            uint32_t data);
1949
1950 typedef __checkReturn   boolean_t
1951 (*efx_rxq_flush_done_ev_t)(
1952         __in_opt        void *arg,
1953         __in            uint32_t rxq_index);
1954
1955 typedef __checkReturn   boolean_t
1956 (*efx_rxq_flush_failed_ev_t)(
1957         __in_opt        void *arg,
1958         __in            uint32_t rxq_index);
1959
1960 typedef __checkReturn   boolean_t
1961 (*efx_txq_flush_done_ev_t)(
1962         __in_opt        void *arg,
1963         __in            uint32_t txq_index);
1964
1965 typedef __checkReturn   boolean_t
1966 (*efx_software_ev_t)(
1967         __in_opt        void *arg,
1968         __in            uint16_t magic);
1969
1970 typedef __checkReturn   boolean_t
1971 (*efx_sram_ev_t)(
1972         __in_opt        void *arg,
1973         __in            uint32_t code);
1974
1975 #define EFX_SRAM_CLEAR          0
1976 #define EFX_SRAM_UPDATE         1
1977 #define EFX_SRAM_ILLEGAL_CLEAR  2
1978
1979 typedef __checkReturn   boolean_t
1980 (*efx_wake_up_ev_t)(
1981         __in_opt        void *arg,
1982         __in            uint32_t label);
1983
1984 typedef __checkReturn   boolean_t
1985 (*efx_timer_ev_t)(
1986         __in_opt        void *arg,
1987         __in            uint32_t label);
1988
1989 typedef __checkReturn   boolean_t
1990 (*efx_link_change_ev_t)(
1991         __in_opt        void *arg,
1992         __in            efx_link_mode_t link_mode);
1993
1994 #if EFSYS_OPT_MON_STATS
1995
1996 typedef __checkReturn   boolean_t
1997 (*efx_monitor_ev_t)(
1998         __in_opt        void *arg,
1999         __in            efx_mon_stat_t id,
2000         __in            efx_mon_stat_value_t value);
2001
2002 #endif  /* EFSYS_OPT_MON_STATS */
2003
2004 #if EFSYS_OPT_MAC_STATS
2005
2006 typedef __checkReturn   boolean_t
2007 (*efx_mac_stats_ev_t)(
2008         __in_opt        void *arg,
2009         __in            uint32_t generation);
2010
2011 #endif  /* EFSYS_OPT_MAC_STATS */
2012
2013 typedef struct efx_ev_callbacks_s {
2014         efx_initialized_ev_t            eec_initialized;
2015         efx_rx_ev_t                     eec_rx;
2016 #if EFSYS_OPT_RX_PACKED_STREAM || EFSYS_OPT_RX_ES_SUPER_BUFFER
2017         efx_rx_ps_ev_t                  eec_rx_ps;
2018 #endif
2019         efx_tx_ev_t                     eec_tx;
2020         efx_exception_ev_t              eec_exception;
2021         efx_rxq_flush_done_ev_t         eec_rxq_flush_done;
2022         efx_rxq_flush_failed_ev_t       eec_rxq_flush_failed;
2023         efx_txq_flush_done_ev_t         eec_txq_flush_done;
2024         efx_software_ev_t               eec_software;
2025         efx_sram_ev_t                   eec_sram;
2026         efx_wake_up_ev_t                eec_wake_up;
2027         efx_timer_ev_t                  eec_timer;
2028         efx_link_change_ev_t            eec_link_change;
2029 #if EFSYS_OPT_MON_STATS
2030         efx_monitor_ev_t                eec_monitor;
2031 #endif  /* EFSYS_OPT_MON_STATS */
2032 #if EFSYS_OPT_MAC_STATS
2033         efx_mac_stats_ev_t              eec_mac_stats;
2034 #endif  /* EFSYS_OPT_MAC_STATS */
2035 } efx_ev_callbacks_t;
2036
2037 extern  __checkReturn   boolean_t
2038 efx_ev_qpending(
2039         __in            efx_evq_t *eep,
2040         __in            unsigned int count);
2041
2042 #if EFSYS_OPT_EV_PREFETCH
2043
2044 extern                  void
2045 efx_ev_qprefetch(
2046         __in            efx_evq_t *eep,
2047         __in            unsigned int count);
2048
2049 #endif  /* EFSYS_OPT_EV_PREFETCH */
2050
2051 extern                  void
2052 efx_ev_qpoll(
2053         __in            efx_evq_t *eep,
2054         __inout         unsigned int *countp,
2055         __in            const efx_ev_callbacks_t *eecp,
2056         __in_opt        void *arg);
2057
2058 extern  __checkReturn   efx_rc_t
2059 efx_ev_usecs_to_ticks(
2060         __in            efx_nic_t *enp,
2061         __in            unsigned int usecs,
2062         __out           unsigned int *ticksp);
2063
2064 extern  __checkReturn   efx_rc_t
2065 efx_ev_qmoderate(
2066         __in            efx_evq_t *eep,
2067         __in            unsigned int us);
2068
2069 extern  __checkReturn   efx_rc_t
2070 efx_ev_qprime(
2071         __in            efx_evq_t *eep,
2072         __in            unsigned int count);
2073
2074 #if EFSYS_OPT_QSTATS
2075
2076 #if EFSYS_OPT_NAMES
2077
2078 extern          const char *
2079 efx_ev_qstat_name(
2080         __in    efx_nic_t *enp,
2081         __in    unsigned int id);
2082
2083 #endif  /* EFSYS_OPT_NAMES */
2084
2085 extern                                  void
2086 efx_ev_qstats_update(
2087         __in                            efx_evq_t *eep,
2088         __inout_ecount(EV_NQSTATS)      efsys_stat_t *stat);
2089
2090 #endif  /* EFSYS_OPT_QSTATS */
2091
2092 extern          void
2093 efx_ev_qdestroy(
2094         __in    efx_evq_t *eep);
2095
2096 /* RX */
2097
2098 extern  __checkReturn   efx_rc_t
2099 efx_rx_init(
2100         __inout         efx_nic_t *enp);
2101
2102 extern          void
2103 efx_rx_fini(
2104         __in            efx_nic_t *enp);
2105
2106 #if EFSYS_OPT_RX_SCATTER
2107         __checkReturn   efx_rc_t
2108 efx_rx_scatter_enable(
2109         __in            efx_nic_t *enp,
2110         __in            unsigned int buf_size);
2111 #endif  /* EFSYS_OPT_RX_SCATTER */
2112
2113 /* Handle to represent use of the default RSS context. */
2114 #define EFX_RSS_CONTEXT_DEFAULT 0xffffffff
2115
2116 #if EFSYS_OPT_RX_SCALE
2117
2118 typedef enum efx_rx_hash_alg_e {
2119         EFX_RX_HASHALG_LFSR = 0,
2120         EFX_RX_HASHALG_TOEPLITZ,
2121         EFX_RX_HASHALG_PACKED_STREAM,
2122         EFX_RX_NHASHALGS
2123 } efx_rx_hash_alg_t;
2124
2125 /*
2126  * Legacy hash type flags.
2127  *
2128  * They represent standard tuples for distinct traffic classes.
2129  */
2130 #define EFX_RX_HASH_IPV4        (1U << 0)
2131 #define EFX_RX_HASH_TCPIPV4     (1U << 1)
2132 #define EFX_RX_HASH_IPV6        (1U << 2)
2133 #define EFX_RX_HASH_TCPIPV6     (1U << 3)
2134
2135 #define EFX_RX_HASH_LEGACY_MASK         \
2136         (EFX_RX_HASH_IPV4       |       \
2137         EFX_RX_HASH_TCPIPV4     |       \
2138         EFX_RX_HASH_IPV6        |       \
2139         EFX_RX_HASH_TCPIPV6)
2140
2141 /*
2142  * The type of the argument used by efx_rx_scale_mode_set() to
2143  * provide a means for the client drivers to configure hashing.
2144  *
2145  * A properly constructed value can either be:
2146  *  - a combination of legacy flags
2147  *  - a combination of EFX_RX_HASH() flags
2148  */
2149 typedef unsigned int efx_rx_hash_type_t;
2150
2151 typedef enum efx_rx_hash_support_e {
2152         EFX_RX_HASH_UNAVAILABLE = 0,    /* Hardware hash not inserted */
2153         EFX_RX_HASH_AVAILABLE           /* Insert hash with/without RSS */
2154 } efx_rx_hash_support_t;
2155
2156 #define EFX_RSS_KEY_SIZE        40      /* RSS key size (bytes) */
2157 #define EFX_RSS_TBL_SIZE        128     /* Rows in RX indirection table */
2158 #define EFX_MAXRSS              64      /* RX indirection entry range */
2159 #define EFX_MAXRSS_LEGACY       16      /* See bug16611 and bug17213 */
2160
2161 typedef enum efx_rx_scale_context_type_e {
2162         EFX_RX_SCALE_UNAVAILABLE = 0,   /* No RX scale context */
2163         EFX_RX_SCALE_EXCLUSIVE,         /* Writable key/indirection table */
2164         EFX_RX_SCALE_SHARED             /* Read-only key/indirection table */
2165 } efx_rx_scale_context_type_t;
2166
2167 /*
2168  * Traffic classes eligible for hash computation.
2169  *
2170  * Select packet headers used in computing the receive hash.
2171  * This uses the same encoding as the RSS_MODES field of
2172  * MC_CMD_RSS_CONTEXT_SET_FLAGS.
2173  */
2174 #define EFX_RX_CLASS_IPV4_TCP_LBN       8
2175 #define EFX_RX_CLASS_IPV4_TCP_WIDTH     4
2176 #define EFX_RX_CLASS_IPV4_UDP_LBN       12
2177 #define EFX_RX_CLASS_IPV4_UDP_WIDTH     4
2178 #define EFX_RX_CLASS_IPV4_LBN           16
2179 #define EFX_RX_CLASS_IPV4_WIDTH         4
2180 #define EFX_RX_CLASS_IPV6_TCP_LBN       20
2181 #define EFX_RX_CLASS_IPV6_TCP_WIDTH     4
2182 #define EFX_RX_CLASS_IPV6_UDP_LBN       24
2183 #define EFX_RX_CLASS_IPV6_UDP_WIDTH     4
2184 #define EFX_RX_CLASS_IPV6_LBN           28
2185 #define EFX_RX_CLASS_IPV6_WIDTH         4
2186
2187 #define EFX_RX_NCLASSES                 6
2188
2189 /*
2190  * Ancillary flags used to construct generic hash tuples.
2191  * This uses the same encoding as RSS_MODE_HASH_SELECTOR.
2192  */
2193 #define EFX_RX_CLASS_HASH_SRC_ADDR      (1U << 0)
2194 #define EFX_RX_CLASS_HASH_DST_ADDR      (1U << 1)
2195 #define EFX_RX_CLASS_HASH_SRC_PORT      (1U << 2)
2196 #define EFX_RX_CLASS_HASH_DST_PORT      (1U << 3)
2197
2198 /*
2199  * Generic hash tuples.
2200  *
2201  * They express combinations of packet fields
2202  * which can contribute to the hash value for
2203  * a particular traffic class.
2204  */
2205 #define EFX_RX_CLASS_HASH_DISABLE       0
2206
2207 #define EFX_RX_CLASS_HASH_1TUPLE_SRC    EFX_RX_CLASS_HASH_SRC_ADDR
2208 #define EFX_RX_CLASS_HASH_1TUPLE_DST    EFX_RX_CLASS_HASH_DST_ADDR
2209
2210 #define EFX_RX_CLASS_HASH_2TUPLE                \
2211         (EFX_RX_CLASS_HASH_SRC_ADDR     |       \
2212         EFX_RX_CLASS_HASH_DST_ADDR)
2213
2214 #define EFX_RX_CLASS_HASH_2TUPLE_SRC            \
2215         (EFX_RX_CLASS_HASH_SRC_ADDR     |       \
2216         EFX_RX_CLASS_HASH_SRC_PORT)
2217
2218 #define EFX_RX_CLASS_HASH_2TUPLE_DST            \
2219         (EFX_RX_CLASS_HASH_DST_ADDR     |       \
2220         EFX_RX_CLASS_HASH_DST_PORT)
2221
2222 #define EFX_RX_CLASS_HASH_4TUPLE                \
2223         (EFX_RX_CLASS_HASH_SRC_ADDR     |       \
2224         EFX_RX_CLASS_HASH_DST_ADDR      |       \
2225         EFX_RX_CLASS_HASH_SRC_PORT      |       \
2226         EFX_RX_CLASS_HASH_DST_PORT)
2227
2228 #define EFX_RX_CLASS_HASH_NTUPLES       7
2229
2230 /*
2231  * Hash flag constructor.
2232  *
2233  * Resulting flags encode hash tuples for specific traffic classes.
2234  * The client drivers are encouraged to use these flags to form
2235  * a hash type value.
2236  */
2237 #define EFX_RX_HASH(_class, _tuple)                             \
2238         EFX_INSERT_FIELD_NATIVE32(0, 31,                        \
2239         EFX_RX_CLASS_##_class, EFX_RX_CLASS_HASH_##_tuple)
2240
2241 /*
2242  * The maximum number of EFX_RX_HASH() flags.
2243  */
2244 #define EFX_RX_HASH_NFLAGS      (EFX_RX_NCLASSES * EFX_RX_CLASS_HASH_NTUPLES)
2245
2246 extern  __checkReturn                           efx_rc_t
2247 efx_rx_scale_hash_flags_get(
2248         __in                                    efx_nic_t *enp,
2249         __in                                    efx_rx_hash_alg_t hash_alg,
2250         __inout_ecount(EFX_RX_HASH_NFLAGS)      unsigned int *flagsp,
2251         __out                                   unsigned int *nflagsp);
2252
2253 extern  __checkReturn   efx_rc_t
2254 efx_rx_hash_default_support_get(
2255         __in            efx_nic_t *enp,
2256         __out           efx_rx_hash_support_t *supportp);
2257
2258
2259 extern  __checkReturn   efx_rc_t
2260 efx_rx_scale_default_support_get(
2261         __in            efx_nic_t *enp,
2262         __out           efx_rx_scale_context_type_t *typep);
2263
2264 extern  __checkReturn   efx_rc_t
2265 efx_rx_scale_context_alloc(
2266         __in            efx_nic_t *enp,
2267         __in            efx_rx_scale_context_type_t type,
2268         __in            uint32_t num_queues,
2269         __out           uint32_t *rss_contextp);
2270
2271 extern  __checkReturn   efx_rc_t
2272 efx_rx_scale_context_free(
2273         __in            efx_nic_t *enp,
2274         __in            uint32_t rss_context);
2275
2276 extern  __checkReturn   efx_rc_t
2277 efx_rx_scale_mode_set(
2278         __in    efx_nic_t *enp,
2279         __in    uint32_t rss_context,
2280         __in    efx_rx_hash_alg_t alg,
2281         __in    efx_rx_hash_type_t type,
2282         __in    boolean_t insert);
2283
2284 extern  __checkReturn   efx_rc_t
2285 efx_rx_scale_tbl_set(
2286         __in            efx_nic_t *enp,
2287         __in            uint32_t rss_context,
2288         __in_ecount(n)  unsigned int *table,
2289         __in            size_t n);
2290
2291 extern  __checkReturn   efx_rc_t
2292 efx_rx_scale_key_set(
2293         __in            efx_nic_t *enp,
2294         __in            uint32_t rss_context,
2295         __in_ecount(n)  uint8_t *key,
2296         __in            size_t n);
2297
2298 extern  __checkReturn   uint32_t
2299 efx_pseudo_hdr_hash_get(
2300         __in            efx_rxq_t *erp,
2301         __in            efx_rx_hash_alg_t func,
2302         __in            uint8_t *buffer);
2303
2304 #endif  /* EFSYS_OPT_RX_SCALE */
2305
2306 extern  __checkReturn   efx_rc_t
2307 efx_pseudo_hdr_pkt_length_get(
2308         __in            efx_rxq_t *erp,
2309         __in            uint8_t *buffer,
2310         __out           uint16_t *pkt_lengthp);
2311
2312 #define EFX_RXQ_MAXNDESCS               4096
2313 #define EFX_RXQ_MINNDESCS               512
2314
2315 #define EFX_RXQ_SIZE(_ndescs)           ((_ndescs) * sizeof (efx_qword_t))
2316 #define EFX_RXQ_NBUFS(_ndescs)          (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
2317 #define EFX_RXQ_LIMIT(_ndescs)          ((_ndescs) - 16)
2318 #define EFX_RXQ_DC_NDESCS(_dcsize)      (8 << _dcsize)
2319
2320 typedef enum efx_rxq_type_e {
2321         EFX_RXQ_TYPE_DEFAULT,
2322         EFX_RXQ_TYPE_PACKED_STREAM,
2323         EFX_RXQ_TYPE_ES_SUPER_BUFFER,
2324         EFX_RXQ_NTYPES
2325 } efx_rxq_type_t;
2326
2327 /*
2328  * Dummy flag to be used instead of 0 to make it clear that the argument
2329  * is receive queue flags.
2330  */
2331 #define EFX_RXQ_FLAG_NONE               0x0
2332 #define EFX_RXQ_FLAG_SCATTER            0x1
2333 /*
2334  * If tunnels are supported and Rx event can provide information about
2335  * either outer or inner packet classes (e.g. SFN8xxx adapters with
2336  * full-feature firmware variant running), outer classes are requested by
2337  * default. However, if the driver supports tunnels, the flag allows to
2338  * request inner classes which are required to be able to interpret inner
2339  * Rx checksum offload results.
2340  */
2341 #define EFX_RXQ_FLAG_INNER_CLASSES      0x2
2342
2343 extern  __checkReturn   efx_rc_t
2344 efx_rx_qcreate(
2345         __in            efx_nic_t *enp,
2346         __in            unsigned int index,
2347         __in            unsigned int label,
2348         __in            efx_rxq_type_t type,
2349         __in            efsys_mem_t *esmp,
2350         __in            size_t ndescs,
2351         __in            uint32_t id,
2352         __in            unsigned int flags,
2353         __in            efx_evq_t *eep,
2354         __deref_out     efx_rxq_t **erpp);
2355
2356 #if EFSYS_OPT_RX_PACKED_STREAM
2357
2358 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_1M       (1U * 1024 * 1024)
2359 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_512K     (512U * 1024)
2360 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_256K     (256U * 1024)
2361 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_128K     (128U * 1024)
2362 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_64K      (64U * 1024)
2363
2364 extern  __checkReturn   efx_rc_t
2365 efx_rx_qcreate_packed_stream(
2366         __in            efx_nic_t *enp,
2367         __in            unsigned int index,
2368         __in            unsigned int label,
2369         __in            uint32_t ps_buf_size,
2370         __in            efsys_mem_t *esmp,
2371         __in            size_t ndescs,
2372         __in            efx_evq_t *eep,
2373         __deref_out     efx_rxq_t **erpp);
2374
2375 #endif
2376
2377 #if EFSYS_OPT_RX_ES_SUPER_BUFFER
2378
2379 /* Maximum head-of-line block timeout in nanoseconds */
2380 #define EFX_RXQ_ES_SUPER_BUFFER_HOL_BLOCK_MAX   (400U * 1000 * 1000)
2381
2382 extern  __checkReturn   efx_rc_t
2383 efx_rx_qcreate_es_super_buffer(
2384         __in            efx_nic_t *enp,
2385         __in            unsigned int index,
2386         __in            unsigned int label,
2387         __in            uint32_t n_bufs_per_desc,
2388         __in            uint32_t max_dma_len,
2389         __in            uint32_t buf_stride,
2390         __in            uint32_t hol_block_timeout,
2391         __in            efsys_mem_t *esmp,
2392         __in            size_t ndescs,
2393         __in            unsigned int flags,
2394         __in            efx_evq_t *eep,
2395         __deref_out     efx_rxq_t **erpp);
2396
2397 #endif
2398
2399 typedef struct efx_buffer_s {
2400         efsys_dma_addr_t        eb_addr;
2401         size_t                  eb_size;
2402         boolean_t               eb_eop;
2403 } efx_buffer_t;
2404
2405 typedef struct efx_desc_s {
2406         efx_qword_t ed_eq;
2407 } efx_desc_t;
2408
2409 extern                          void
2410 efx_rx_qpost(
2411         __in                    efx_rxq_t *erp,
2412         __in_ecount(ndescs)     efsys_dma_addr_t *addrp,
2413         __in                    size_t size,
2414         __in                    unsigned int ndescs,
2415         __in                    unsigned int completed,
2416         __in                    unsigned int added);
2417
2418 extern          void
2419 efx_rx_qpush(
2420         __in    efx_rxq_t *erp,
2421         __in    unsigned int added,
2422         __inout unsigned int *pushedp);
2423
2424 #if EFSYS_OPT_RX_PACKED_STREAM
2425
2426 extern                  void
2427 efx_rx_qpush_ps_credits(
2428         __in            efx_rxq_t *erp);
2429
2430 extern  __checkReturn   uint8_t *
2431 efx_rx_qps_packet_info(
2432         __in            efx_rxq_t *erp,
2433         __in            uint8_t *buffer,
2434         __in            uint32_t buffer_length,
2435         __in            uint32_t current_offset,
2436         __out           uint16_t *lengthp,
2437         __out           uint32_t *next_offsetp,
2438         __out           uint32_t *timestamp);
2439 #endif
2440
2441 extern  __checkReturn   efx_rc_t
2442 efx_rx_qflush(
2443         __in    efx_rxq_t *erp);
2444
2445 extern          void
2446 efx_rx_qenable(
2447         __in    efx_rxq_t *erp);
2448
2449 extern          void
2450 efx_rx_qdestroy(
2451         __in    efx_rxq_t *erp);
2452
2453 /* TX */
2454
2455 typedef struct efx_txq_s        efx_txq_t;
2456
2457 #if EFSYS_OPT_QSTATS
2458
2459 /* START MKCONFIG GENERATED EfxHeaderTransmitQueueBlock 12dff8778598b2db */
2460 typedef enum efx_tx_qstat_e {
2461         TX_POST,
2462         TX_POST_PIO,
2463         TX_NQSTATS
2464 } efx_tx_qstat_t;
2465
2466 /* END MKCONFIG GENERATED EfxHeaderTransmitQueueBlock */
2467
2468 #endif  /* EFSYS_OPT_QSTATS */
2469
2470 extern  __checkReturn   efx_rc_t
2471 efx_tx_init(
2472         __in            efx_nic_t *enp);
2473
2474 extern          void
2475 efx_tx_fini(
2476         __in    efx_nic_t *enp);
2477
2478 #define EFX_TXQ_MINNDESCS               512
2479
2480 #define EFX_TXQ_SIZE(_ndescs)           ((_ndescs) * sizeof (efx_qword_t))
2481 #define EFX_TXQ_NBUFS(_ndescs)          (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
2482 #define EFX_TXQ_LIMIT(_ndescs)          ((_ndescs) - 16)
2483
2484 #define EFX_TXQ_MAX_BUFS 8 /* Maximum independent of EFX_BUG35388_WORKAROUND. */
2485
2486 #define EFX_TXQ_CKSUM_IPV4              0x0001
2487 #define EFX_TXQ_CKSUM_TCPUDP            0x0002
2488 #define EFX_TXQ_FATSOV2                 0x0004
2489 #define EFX_TXQ_CKSUM_INNER_IPV4        0x0008
2490 #define EFX_TXQ_CKSUM_INNER_TCPUDP      0x0010
2491
2492 extern  __checkReturn   efx_rc_t
2493 efx_tx_qcreate(
2494         __in            efx_nic_t *enp,
2495         __in            unsigned int index,
2496         __in            unsigned int label,
2497         __in            efsys_mem_t *esmp,
2498         __in            size_t n,
2499         __in            uint32_t id,
2500         __in            uint16_t flags,
2501         __in            efx_evq_t *eep,
2502         __deref_out     efx_txq_t **etpp,
2503         __out           unsigned int *addedp);
2504
2505 extern  __checkReturn           efx_rc_t
2506 efx_tx_qpost(
2507         __in                    efx_txq_t *etp,
2508         __in_ecount(ndescs)     efx_buffer_t *eb,
2509         __in                    unsigned int ndescs,
2510         __in                    unsigned int completed,
2511         __inout                 unsigned int *addedp);
2512
2513 extern  __checkReturn   efx_rc_t
2514 efx_tx_qpace(
2515         __in            efx_txq_t *etp,
2516         __in            unsigned int ns);
2517
2518 extern                  void
2519 efx_tx_qpush(
2520         __in            efx_txq_t *etp,
2521         __in            unsigned int added,
2522         __in            unsigned int pushed);
2523
2524 extern  __checkReturn   efx_rc_t
2525 efx_tx_qflush(
2526         __in            efx_txq_t *etp);
2527
2528 extern                  void
2529 efx_tx_qenable(
2530         __in            efx_txq_t *etp);
2531
2532 extern  __checkReturn   efx_rc_t
2533 efx_tx_qpio_enable(
2534         __in            efx_txq_t *etp);
2535
2536 extern                  void
2537 efx_tx_qpio_disable(
2538         __in            efx_txq_t *etp);
2539
2540 extern  __checkReturn   efx_rc_t
2541 efx_tx_qpio_write(
2542         __in                    efx_txq_t *etp,
2543         __in_ecount(buf_length) uint8_t *buffer,
2544         __in                    size_t buf_length,
2545         __in                    size_t pio_buf_offset);
2546
2547 extern  __checkReturn   efx_rc_t
2548 efx_tx_qpio_post(
2549         __in                    efx_txq_t *etp,
2550         __in                    size_t pkt_length,
2551         __in                    unsigned int completed,
2552         __inout                 unsigned int *addedp);
2553
2554 extern  __checkReturn   efx_rc_t
2555 efx_tx_qdesc_post(
2556         __in            efx_txq_t *etp,
2557         __in_ecount(n)  efx_desc_t *ed,
2558         __in            unsigned int n,
2559         __in            unsigned int completed,
2560         __inout         unsigned int *addedp);
2561
2562 extern  void
2563 efx_tx_qdesc_dma_create(
2564         __in    efx_txq_t *etp,
2565         __in    efsys_dma_addr_t addr,
2566         __in    size_t size,
2567         __in    boolean_t eop,
2568         __out   efx_desc_t *edp);
2569
2570 extern  void
2571 efx_tx_qdesc_tso_create(
2572         __in    efx_txq_t *etp,
2573         __in    uint16_t ipv4_id,
2574         __in    uint32_t tcp_seq,
2575         __in    uint8_t  tcp_flags,
2576         __out   efx_desc_t *edp);
2577
2578 /* Number of FATSOv2 option descriptors */
2579 #define EFX_TX_FATSOV2_OPT_NDESCS               2
2580
2581 /* Maximum number of DMA segments per TSO packet (not superframe) */
2582 #define EFX_TX_FATSOV2_DMA_SEGS_PER_PKT_MAX     24
2583
2584 extern  void
2585 efx_tx_qdesc_tso2_create(
2586         __in                    efx_txq_t *etp,
2587         __in                    uint16_t ipv4_id,
2588         __in                    uint16_t outer_ipv4_id,
2589         __in                    uint32_t tcp_seq,
2590         __in                    uint16_t tcp_mss,
2591         __out_ecount(count)     efx_desc_t *edp,
2592         __in                    int count);
2593
2594 extern  void
2595 efx_tx_qdesc_vlantci_create(
2596         __in    efx_txq_t *etp,
2597         __in    uint16_t tci,
2598         __out   efx_desc_t *edp);
2599
2600 extern  void
2601 efx_tx_qdesc_checksum_create(
2602         __in    efx_txq_t *etp,
2603         __in    uint16_t flags,
2604         __out   efx_desc_t *edp);
2605
2606 #if EFSYS_OPT_QSTATS
2607
2608 #if EFSYS_OPT_NAMES
2609
2610 extern          const char *
2611 efx_tx_qstat_name(
2612         __in    efx_nic_t *etp,
2613         __in    unsigned int id);
2614
2615 #endif  /* EFSYS_OPT_NAMES */
2616
2617 extern                                  void
2618 efx_tx_qstats_update(
2619         __in                            efx_txq_t *etp,
2620         __inout_ecount(TX_NQSTATS)      efsys_stat_t *stat);
2621
2622 #endif  /* EFSYS_OPT_QSTATS */
2623
2624 extern          void
2625 efx_tx_qdestroy(
2626         __in    efx_txq_t *etp);
2627
2628
2629 /* FILTER */
2630
2631 #if EFSYS_OPT_FILTER
2632
2633 #define EFX_ETHER_TYPE_IPV4 0x0800
2634 #define EFX_ETHER_TYPE_IPV6 0x86DD
2635
2636 #define EFX_IPPROTO_TCP 6
2637 #define EFX_IPPROTO_UDP 17
2638 #define EFX_IPPROTO_GRE 47
2639
2640 /* Use RSS to spread across multiple queues */
2641 #define EFX_FILTER_FLAG_RX_RSS          0x01
2642 /* Enable RX scatter */
2643 #define EFX_FILTER_FLAG_RX_SCATTER      0x02
2644 /*
2645  * Override an automatic filter (priority EFX_FILTER_PRI_AUTO).
2646  * May only be set by the filter implementation for each type.
2647  * A removal request will restore the automatic filter in its place.
2648  */
2649 #define EFX_FILTER_FLAG_RX_OVER_AUTO    0x04
2650 /* Filter is for RX */
2651 #define EFX_FILTER_FLAG_RX              0x08
2652 /* Filter is for TX */
2653 #define EFX_FILTER_FLAG_TX              0x10
2654
2655 typedef uint8_t efx_filter_flags_t;
2656
2657 /*
2658  * Flags which specify the fields to match on. The values are the same as in the
2659  * MC_CMD_FILTER_OP/MC_CMD_FILTER_OP_EXT commands.
2660  */
2661
2662 /* Match by remote IP host address */
2663 #define EFX_FILTER_MATCH_REM_HOST               0x00000001
2664 /* Match by local IP host address */
2665 #define EFX_FILTER_MATCH_LOC_HOST               0x00000002
2666 /* Match by remote MAC address */
2667 #define EFX_FILTER_MATCH_REM_MAC                0x00000004
2668 /* Match by remote TCP/UDP port */
2669 #define EFX_FILTER_MATCH_REM_PORT               0x00000008
2670 /* Match by remote TCP/UDP port */
2671 #define EFX_FILTER_MATCH_LOC_MAC                0x00000010
2672 /* Match by local TCP/UDP port */
2673 #define EFX_FILTER_MATCH_LOC_PORT               0x00000020
2674 /* Match by Ether-type */
2675 #define EFX_FILTER_MATCH_ETHER_TYPE             0x00000040
2676 /* Match by inner VLAN ID */
2677 #define EFX_FILTER_MATCH_INNER_VID              0x00000080
2678 /* Match by outer VLAN ID */
2679 #define EFX_FILTER_MATCH_OUTER_VID              0x00000100
2680 /* Match by IP transport protocol */
2681 #define EFX_FILTER_MATCH_IP_PROTO               0x00000200
2682 /* Match by VNI or VSID */
2683 #define EFX_FILTER_MATCH_VNI_OR_VSID            0x00000800
2684 /* For encapsulated packets, match by inner frame local MAC address */
2685 #define EFX_FILTER_MATCH_IFRM_LOC_MAC           0x00010000
2686 /* For encapsulated packets, match all multicast inner frames */
2687 #define EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST 0x01000000
2688 /* For encapsulated packets, match all unicast inner frames */
2689 #define EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST 0x02000000
2690 /*
2691  * Match by encap type, this flag does not correspond to
2692  * the MCDI match flags and any unoccupied value may be used
2693  */
2694 #define EFX_FILTER_MATCH_ENCAP_TYPE             0x20000000
2695 /* Match otherwise-unmatched multicast and broadcast packets */
2696 #define EFX_FILTER_MATCH_UNKNOWN_MCAST_DST      0x40000000
2697 /* Match otherwise-unmatched unicast packets */
2698 #define EFX_FILTER_MATCH_UNKNOWN_UCAST_DST      0x80000000
2699
2700 typedef uint32_t efx_filter_match_flags_t;
2701
2702 typedef enum efx_filter_priority_s {
2703         EFX_FILTER_PRI_HINT = 0,        /* Performance hint */
2704         EFX_FILTER_PRI_AUTO,            /* Automatic filter based on device
2705                                          * address list or hardware
2706                                          * requirements. This may only be used
2707                                          * by the filter implementation for
2708                                          * each NIC type. */
2709         EFX_FILTER_PRI_MANUAL,          /* Manually configured filter */
2710         EFX_FILTER_PRI_REQUIRED,        /* Required for correct behaviour of the
2711                                          * client (e.g. SR-IOV, HyperV VMQ etc.)
2712                                          */
2713 } efx_filter_priority_t;
2714
2715 /*
2716  * FIXME: All these fields are assumed to be in little-endian byte order.
2717  * It may be better for some to be big-endian. See bug42804.
2718  */
2719
2720 typedef struct efx_filter_spec_s {
2721         efx_filter_match_flags_t        efs_match_flags;
2722         uint8_t                         efs_priority;
2723         efx_filter_flags_t              efs_flags;
2724         uint16_t                        efs_dmaq_id;
2725         uint32_t                        efs_rss_context;
2726         uint16_t                        efs_outer_vid;
2727         uint16_t                        efs_inner_vid;
2728         uint8_t                         efs_loc_mac[EFX_MAC_ADDR_LEN];
2729         uint8_t                         efs_rem_mac[EFX_MAC_ADDR_LEN];
2730         uint16_t                        efs_ether_type;
2731         uint8_t                         efs_ip_proto;
2732         efx_tunnel_protocol_t           efs_encap_type;
2733         uint16_t                        efs_loc_port;
2734         uint16_t                        efs_rem_port;
2735         efx_oword_t                     efs_rem_host;
2736         efx_oword_t                     efs_loc_host;
2737         uint8_t                         efs_vni_or_vsid[EFX_VNI_OR_VSID_LEN];
2738         uint8_t                         efs_ifrm_loc_mac[EFX_MAC_ADDR_LEN];
2739 } efx_filter_spec_t;
2740
2741
2742 /* Default values for use in filter specifications */
2743 #define EFX_FILTER_SPEC_RX_DMAQ_ID_DROP         0xfff
2744 #define EFX_FILTER_SPEC_VID_UNSPEC              0xffff
2745
2746 extern  __checkReturn   efx_rc_t
2747 efx_filter_init(
2748         __in            efx_nic_t *enp);
2749
2750 extern                  void
2751 efx_filter_fini(
2752         __in            efx_nic_t *enp);
2753
2754 extern  __checkReturn   efx_rc_t
2755 efx_filter_insert(
2756         __in            efx_nic_t *enp,
2757         __inout         efx_filter_spec_t *spec);
2758
2759 extern  __checkReturn   efx_rc_t
2760 efx_filter_remove(
2761         __in            efx_nic_t *enp,
2762         __inout         efx_filter_spec_t *spec);
2763
2764 extern  __checkReturn   efx_rc_t
2765 efx_filter_restore(
2766         __in            efx_nic_t *enp);
2767
2768 extern  __checkReturn   efx_rc_t
2769 efx_filter_supported_filters(
2770         __in                            efx_nic_t *enp,
2771         __out_ecount(buffer_length)     uint32_t *buffer,
2772         __in                            size_t buffer_length,
2773         __out                           size_t *list_lengthp);
2774
2775 extern                  void
2776 efx_filter_spec_init_rx(
2777         __out           efx_filter_spec_t *spec,
2778         __in            efx_filter_priority_t priority,
2779         __in            efx_filter_flags_t flags,
2780         __in            efx_rxq_t *erp);
2781
2782 extern                  void
2783 efx_filter_spec_init_tx(
2784         __out           efx_filter_spec_t *spec,
2785         __in            efx_txq_t *etp);
2786
2787 extern  __checkReturn   efx_rc_t
2788 efx_filter_spec_set_ipv4_local(
2789         __inout         efx_filter_spec_t *spec,
2790         __in            uint8_t proto,
2791         __in            uint32_t host,
2792         __in            uint16_t port);
2793
2794 extern  __checkReturn   efx_rc_t
2795 efx_filter_spec_set_ipv4_full(
2796         __inout         efx_filter_spec_t *spec,
2797         __in            uint8_t proto,
2798         __in            uint32_t lhost,
2799         __in            uint16_t lport,
2800         __in            uint32_t rhost,
2801         __in            uint16_t rport);
2802
2803 extern  __checkReturn   efx_rc_t
2804 efx_filter_spec_set_eth_local(
2805         __inout         efx_filter_spec_t *spec,
2806         __in            uint16_t vid,
2807         __in            const uint8_t *addr);
2808
2809 extern                  void
2810 efx_filter_spec_set_ether_type(
2811         __inout         efx_filter_spec_t *spec,
2812         __in            uint16_t ether_type);
2813
2814 extern  __checkReturn   efx_rc_t
2815 efx_filter_spec_set_uc_def(
2816         __inout         efx_filter_spec_t *spec);
2817
2818 extern  __checkReturn   efx_rc_t
2819 efx_filter_spec_set_mc_def(
2820         __inout         efx_filter_spec_t *spec);
2821
2822 typedef enum efx_filter_inner_frame_match_e {
2823         EFX_FILTER_INNER_FRAME_MATCH_OTHER = 0,
2824         EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_MCAST_DST,
2825         EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_UCAST_DST
2826 } efx_filter_inner_frame_match_t;
2827
2828 extern  __checkReturn   efx_rc_t
2829 efx_filter_spec_set_encap_type(
2830         __inout         efx_filter_spec_t *spec,
2831         __in            efx_tunnel_protocol_t encap_type,
2832         __in            efx_filter_inner_frame_match_t inner_frame_match);
2833
2834 extern  __checkReturn   efx_rc_t
2835 efx_filter_spec_set_vxlan_full(
2836         __inout         efx_filter_spec_t *spec,
2837         __in            const uint8_t *vxlan_id,
2838         __in            const uint8_t *inner_addr,
2839         __in            const uint8_t *outer_addr);
2840
2841 #if EFSYS_OPT_RX_SCALE
2842 extern  __checkReturn   efx_rc_t
2843 efx_filter_spec_set_rss_context(
2844         __inout         efx_filter_spec_t *spec,
2845         __in            uint32_t rss_context);
2846 #endif
2847 #endif  /* EFSYS_OPT_FILTER */
2848
2849 /* HASH */
2850
2851 extern  __checkReturn           uint32_t
2852 efx_hash_dwords(
2853         __in_ecount(count)      uint32_t const *input,
2854         __in                    size_t count,
2855         __in                    uint32_t init);
2856
2857 extern  __checkReturn           uint32_t
2858 efx_hash_bytes(
2859         __in_ecount(length)     uint8_t const *input,
2860         __in                    size_t length,
2861         __in                    uint32_t init);
2862
2863 #if EFSYS_OPT_LICENSING
2864
2865 /* LICENSING */
2866
2867 typedef struct efx_key_stats_s {
2868         uint32_t        eks_valid;
2869         uint32_t        eks_invalid;
2870         uint32_t        eks_blacklisted;
2871         uint32_t        eks_unverifiable;
2872         uint32_t        eks_wrong_node;
2873         uint32_t        eks_licensed_apps_lo;
2874         uint32_t        eks_licensed_apps_hi;
2875         uint32_t        eks_licensed_features_lo;
2876         uint32_t        eks_licensed_features_hi;
2877 } efx_key_stats_t;
2878
2879 extern  __checkReturn           efx_rc_t
2880 efx_lic_init(
2881         __in                    efx_nic_t *enp);
2882
2883 extern                          void
2884 efx_lic_fini(
2885         __in                    efx_nic_t *enp);
2886
2887 extern  __checkReturn   boolean_t
2888 efx_lic_check_support(
2889         __in                    efx_nic_t *enp);
2890
2891 extern  __checkReturn   efx_rc_t
2892 efx_lic_update_licenses(
2893         __in            efx_nic_t *enp);
2894
2895 extern  __checkReturn   efx_rc_t
2896 efx_lic_get_key_stats(
2897         __in            efx_nic_t *enp,
2898         __out           efx_key_stats_t *ksp);
2899
2900 extern  __checkReturn   efx_rc_t
2901 efx_lic_app_state(
2902         __in            efx_nic_t *enp,
2903         __in            uint64_t app_id,
2904         __out           boolean_t *licensedp);
2905
2906 extern  __checkReturn   efx_rc_t
2907 efx_lic_get_id(
2908         __in            efx_nic_t *enp,
2909         __in            size_t buffer_size,
2910         __out           uint32_t *typep,
2911         __out           size_t *lengthp,
2912         __out_opt       uint8_t *bufferp);
2913
2914
2915 extern  __checkReturn           efx_rc_t
2916 efx_lic_find_start(
2917         __in                    efx_nic_t *enp,
2918         __in_bcount(buffer_size)
2919                                 caddr_t bufferp,
2920         __in                    size_t buffer_size,
2921         __out                   uint32_t *startp);
2922
2923 extern  __checkReturn           efx_rc_t
2924 efx_lic_find_end(
2925         __in                    efx_nic_t *enp,
2926         __in_bcount(buffer_size)
2927                                 caddr_t bufferp,
2928         __in                    size_t buffer_size,
2929         __in                    uint32_t offset,
2930         __out                   uint32_t *endp);
2931
2932 extern  __checkReturn   __success(return != B_FALSE)    boolean_t
2933 efx_lic_find_key(
2934         __in                    efx_nic_t *enp,
2935         __in_bcount(buffer_size)
2936                                 caddr_t bufferp,
2937         __in                    size_t buffer_size,
2938         __in                    uint32_t offset,
2939         __out                   uint32_t *startp,
2940         __out                   uint32_t *lengthp);
2941
2942 extern  __checkReturn   __success(return != B_FALSE)    boolean_t
2943 efx_lic_validate_key(
2944         __in                    efx_nic_t *enp,
2945         __in_bcount(length)     caddr_t keyp,
2946         __in                    uint32_t length);
2947
2948 extern  __checkReturn           efx_rc_t
2949 efx_lic_read_key(
2950         __in                    efx_nic_t *enp,
2951         __in_bcount(buffer_size)
2952                                 caddr_t bufferp,
2953         __in                    size_t buffer_size,
2954         __in                    uint32_t offset,
2955         __in                    uint32_t length,
2956         __out_bcount_part(key_max_size, *lengthp)
2957                                 caddr_t keyp,
2958         __in                    size_t key_max_size,
2959         __out                   uint32_t *lengthp);
2960
2961 extern  __checkReturn           efx_rc_t
2962 efx_lic_write_key(
2963         __in                    efx_nic_t *enp,
2964         __in_bcount(buffer_size)
2965                                 caddr_t bufferp,
2966         __in                    size_t buffer_size,
2967         __in                    uint32_t offset,
2968         __in_bcount(length)     caddr_t keyp,
2969         __in                    uint32_t length,
2970         __out                   uint32_t *lengthp);
2971
2972         __checkReturn           efx_rc_t
2973 efx_lic_delete_key(
2974         __in                    efx_nic_t *enp,
2975         __in_bcount(buffer_size)
2976                                 caddr_t bufferp,
2977         __in                    size_t buffer_size,
2978         __in                    uint32_t offset,
2979         __in                    uint32_t length,
2980         __in                    uint32_t end,
2981         __out                   uint32_t *deltap);
2982
2983 extern  __checkReturn           efx_rc_t
2984 efx_lic_create_partition(
2985         __in                    efx_nic_t *enp,
2986         __in_bcount(buffer_size)
2987                                 caddr_t bufferp,
2988         __in                    size_t buffer_size);
2989
2990 extern  __checkReturn           efx_rc_t
2991 efx_lic_finish_partition(
2992         __in                    efx_nic_t *enp,
2993         __in_bcount(buffer_size)
2994                                 caddr_t bufferp,
2995         __in                    size_t buffer_size);
2996
2997 #endif  /* EFSYS_OPT_LICENSING */
2998
2999 /* TUNNEL */
3000
3001 #if EFSYS_OPT_TUNNEL
3002
3003 extern  __checkReturn   efx_rc_t
3004 efx_tunnel_init(
3005         __in            efx_nic_t *enp);
3006
3007 extern                  void
3008 efx_tunnel_fini(
3009         __in            efx_nic_t *enp);
3010
3011 /*
3012  * For overlay network encapsulation using UDP, the firmware needs to know
3013  * the configured UDP port for the overlay so it can decode encapsulated
3014  * frames correctly.
3015  * The UDP port/protocol list is global.
3016  */
3017
3018 extern  __checkReturn   efx_rc_t
3019 efx_tunnel_config_udp_add(
3020         __in            efx_nic_t *enp,
3021         __in            uint16_t port /* host/cpu-endian */,
3022         __in            efx_tunnel_protocol_t protocol);
3023
3024 extern  __checkReturn   efx_rc_t
3025 efx_tunnel_config_udp_remove(
3026         __in            efx_nic_t *enp,
3027         __in            uint16_t port /* host/cpu-endian */,
3028         __in            efx_tunnel_protocol_t protocol);
3029
3030 extern                  void
3031 efx_tunnel_config_clear(
3032         __in            efx_nic_t *enp);
3033
3034 /**
3035  * Apply tunnel UDP ports configuration to hardware.
3036  *
3037  * EAGAIN is returned if hardware will be reset (datapath and management CPU
3038  * reboot).
3039  */
3040 extern  __checkReturn   efx_rc_t
3041 efx_tunnel_reconfigure(
3042         __in            efx_nic_t *enp);
3043
3044 #endif /* EFSYS_OPT_TUNNEL */
3045
3046 #if EFSYS_OPT_FW_SUBVARIANT_AWARE
3047
3048 /**
3049  * Firmware subvariant choice options.
3050  *
3051  * It may be switched to no Tx checksum if attached drivers are either
3052  * preboot or firmware subvariant aware and no VIS are allocated.
3053  * If may be always switched to default explicitly using set request or
3054  * implicitly if unaware driver is attaching. If switching is done when
3055  * a driver is attached, it gets MC_REBOOT event and should recreate its
3056  * datapath.
3057  *
3058  * See SF-119419-TC DPDK Firmware Driver Interface and
3059  * SF-109306-TC EF10 for Driver Writers for details.
3060  */
3061 typedef enum efx_nic_fw_subvariant_e {
3062         EFX_NIC_FW_SUBVARIANT_DEFAULT = 0,
3063         EFX_NIC_FW_SUBVARIANT_NO_TX_CSUM = 1,
3064         EFX_NIC_FW_SUBVARIANT_NTYPES
3065 } efx_nic_fw_subvariant_t;
3066
3067 extern  __checkReturn   efx_rc_t
3068 efx_nic_get_fw_subvariant(
3069         __in            efx_nic_t *enp,
3070         __out           efx_nic_fw_subvariant_t *subvariantp);
3071
3072 extern  __checkReturn   efx_rc_t
3073 efx_nic_set_fw_subvariant(
3074         __in            efx_nic_t *enp,
3075         __in            efx_nic_fw_subvariant_t subvariant);
3076
3077 #endif  /* EFSYS_OPT_FW_SUBVARIANT_AWARE */
3078
3079 #ifdef  __cplusplus
3080 }
3081 #endif
3082
3083 #endif  /* _SYS_EFX_H */