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