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