net/sfc/base: support choosing firmware variant
[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_pm_and_rxdp_counters;
1263         boolean_t               enc_mac_stats_40g_tx_size_bins;
1264         uint32_t                enc_tunnel_encapsulations_supported;
1265         /*
1266          * NIC global maximum for unique UDP tunnel ports shared by all
1267          * functions.
1268          */
1269         uint32_t                enc_tunnel_config_udp_entries_max;
1270         /* External port identifier */
1271         uint8_t                 enc_external_port;
1272         uint32_t                enc_mcdi_max_payload_length;
1273         /* VPD may be per-PF or global */
1274         boolean_t               enc_vpd_is_global;
1275         /* Minimum unidirectional bandwidth in Mb/s to max out all ports */
1276         uint32_t                enc_required_pcie_bandwidth_mbps;
1277         uint32_t                enc_max_pcie_link_gen;
1278         /* Firmware verifies integrity of NVRAM updates */
1279         uint32_t                enc_nvram_update_verify_result_supported;
1280         /* Firmware support for extended MAC_STATS buffer */
1281         uint32_t                enc_mac_stats_nstats;
1282         boolean_t               enc_fec_counters;
1283 } efx_nic_cfg_t;
1284
1285 #define EFX_PCI_FUNCTION_IS_PF(_encp)   ((_encp)->enc_vf == 0xffff)
1286 #define EFX_PCI_FUNCTION_IS_VF(_encp)   ((_encp)->enc_vf != 0xffff)
1287
1288 #define EFX_PCI_FUNCTION(_encp) \
1289         (EFX_PCI_FUNCTION_IS_PF(_encp) ? (_encp)->enc_pf : (_encp)->enc_vf)
1290
1291 #define EFX_PCI_VF_PARENT(_encp)        ((_encp)->enc_pf)
1292
1293 extern                  const efx_nic_cfg_t *
1294 efx_nic_cfg_get(
1295         __in            efx_nic_t *enp);
1296
1297 typedef struct efx_nic_fw_info_s {
1298         /* Basic FW version information */
1299         uint16_t        enfi_mc_fw_version[4];
1300         /*
1301          * If datapath capabilities can be detected,
1302          * additional FW information is to be shown
1303          */
1304         boolean_t       enfi_dpcpu_fw_ids_valid;
1305         /* Rx and Tx datapath CPU FW IDs */
1306         uint16_t        enfi_rx_dpcpu_fw_id;
1307         uint16_t        enfi_tx_dpcpu_fw_id;
1308 } efx_nic_fw_info_t;
1309
1310 extern  __checkReturn           efx_rc_t
1311 efx_nic_get_fw_version(
1312         __in                    efx_nic_t *enp,
1313         __out                   efx_nic_fw_info_t *enfip);
1314
1315 /* Driver resource limits (minimum required/maximum usable). */
1316 typedef struct efx_drv_limits_s {
1317         uint32_t        edl_min_evq_count;
1318         uint32_t        edl_max_evq_count;
1319
1320         uint32_t        edl_min_rxq_count;
1321         uint32_t        edl_max_rxq_count;
1322
1323         uint32_t        edl_min_txq_count;
1324         uint32_t        edl_max_txq_count;
1325
1326         /* PIO blocks (sub-allocated from piobuf) */
1327         uint32_t        edl_min_pio_alloc_size;
1328         uint32_t        edl_max_pio_alloc_count;
1329 } efx_drv_limits_t;
1330
1331 extern  __checkReturn   efx_rc_t
1332 efx_nic_set_drv_limits(
1333         __inout         efx_nic_t *enp,
1334         __in            efx_drv_limits_t *edlp);
1335
1336 typedef enum efx_nic_region_e {
1337         EFX_REGION_VI,                  /* Memory BAR UC mapping */
1338         EFX_REGION_PIO_WRITE_VI,        /* Memory BAR WC mapping */
1339 } efx_nic_region_t;
1340
1341 extern  __checkReturn   efx_rc_t
1342 efx_nic_get_bar_region(
1343         __in            efx_nic_t *enp,
1344         __in            efx_nic_region_t region,
1345         __out           uint32_t *offsetp,
1346         __out           size_t *sizep);
1347
1348 extern  __checkReturn   efx_rc_t
1349 efx_nic_get_vi_pool(
1350         __in            efx_nic_t *enp,
1351         __out           uint32_t *evq_countp,
1352         __out           uint32_t *rxq_countp,
1353         __out           uint32_t *txq_countp);
1354
1355
1356 #if EFSYS_OPT_VPD
1357
1358 typedef enum efx_vpd_tag_e {
1359         EFX_VPD_ID = 0x02,
1360         EFX_VPD_END = 0x0f,
1361         EFX_VPD_RO = 0x10,
1362         EFX_VPD_RW = 0x11,
1363 } efx_vpd_tag_t;
1364
1365 typedef uint16_t efx_vpd_keyword_t;
1366
1367 typedef struct efx_vpd_value_s {
1368         efx_vpd_tag_t           evv_tag;
1369         efx_vpd_keyword_t       evv_keyword;
1370         uint8_t                 evv_length;
1371         uint8_t                 evv_value[0x100];
1372 } efx_vpd_value_t;
1373
1374
1375 #define EFX_VPD_KEYWORD(x, y) ((x) | ((y) << 8))
1376
1377 extern  __checkReturn           efx_rc_t
1378 efx_vpd_init(
1379         __in                    efx_nic_t *enp);
1380
1381 extern  __checkReturn           efx_rc_t
1382 efx_vpd_size(
1383         __in                    efx_nic_t *enp,
1384         __out                   size_t *sizep);
1385
1386 extern  __checkReturn           efx_rc_t
1387 efx_vpd_read(
1388         __in                    efx_nic_t *enp,
1389         __out_bcount(size)      caddr_t data,
1390         __in                    size_t size);
1391
1392 extern  __checkReturn           efx_rc_t
1393 efx_vpd_verify(
1394         __in                    efx_nic_t *enp,
1395         __in_bcount(size)       caddr_t data,
1396         __in                    size_t size);
1397
1398 extern  __checkReturn           efx_rc_t
1399 efx_vpd_reinit(
1400         __in                    efx_nic_t *enp,
1401         __in_bcount(size)       caddr_t data,
1402         __in                    size_t size);
1403
1404 extern  __checkReturn           efx_rc_t
1405 efx_vpd_get(
1406         __in                    efx_nic_t *enp,
1407         __in_bcount(size)       caddr_t data,
1408         __in                    size_t size,
1409         __inout                 efx_vpd_value_t *evvp);
1410
1411 extern  __checkReturn           efx_rc_t
1412 efx_vpd_set(
1413         __in                    efx_nic_t *enp,
1414         __inout_bcount(size)    caddr_t data,
1415         __in                    size_t size,
1416         __in                    efx_vpd_value_t *evvp);
1417
1418 extern  __checkReturn           efx_rc_t
1419 efx_vpd_next(
1420         __in                    efx_nic_t *enp,
1421         __inout_bcount(size)    caddr_t data,
1422         __in                    size_t size,
1423         __out                   efx_vpd_value_t *evvp,
1424         __inout                 unsigned int *contp);
1425
1426 extern  __checkReturn           efx_rc_t
1427 efx_vpd_write(
1428         __in                    efx_nic_t *enp,
1429         __in_bcount(size)       caddr_t data,
1430         __in                    size_t size);
1431
1432 extern                          void
1433 efx_vpd_fini(
1434         __in                    efx_nic_t *enp);
1435
1436 #endif  /* EFSYS_OPT_VPD */
1437
1438 /* NVRAM */
1439
1440 #if EFSYS_OPT_NVRAM
1441
1442 typedef enum efx_nvram_type_e {
1443         EFX_NVRAM_INVALID = 0,
1444         EFX_NVRAM_BOOTROM,
1445         EFX_NVRAM_BOOTROM_CFG,
1446         EFX_NVRAM_MC_FIRMWARE,
1447         EFX_NVRAM_MC_GOLDEN,
1448         EFX_NVRAM_PHY,
1449         EFX_NVRAM_NULLPHY,
1450         EFX_NVRAM_FPGA,
1451         EFX_NVRAM_FCFW,
1452         EFX_NVRAM_CPLD,
1453         EFX_NVRAM_FPGA_BACKUP,
1454         EFX_NVRAM_DYNAMIC_CFG,
1455         EFX_NVRAM_LICENSE,
1456         EFX_NVRAM_UEFIROM,
1457         EFX_NVRAM_MUM_FIRMWARE,
1458         EFX_NVRAM_NTYPES,
1459 } efx_nvram_type_t;
1460
1461 extern  __checkReturn           efx_rc_t
1462 efx_nvram_init(
1463         __in                    efx_nic_t *enp);
1464
1465 #if EFSYS_OPT_DIAG
1466
1467 extern  __checkReturn           efx_rc_t
1468 efx_nvram_test(
1469         __in                    efx_nic_t *enp);
1470
1471 #endif  /* EFSYS_OPT_DIAG */
1472
1473 extern  __checkReturn           efx_rc_t
1474 efx_nvram_size(
1475         __in                    efx_nic_t *enp,
1476         __in                    efx_nvram_type_t type,
1477         __out                   size_t *sizep);
1478
1479 extern  __checkReturn           efx_rc_t
1480 efx_nvram_rw_start(
1481         __in                    efx_nic_t *enp,
1482         __in                    efx_nvram_type_t type,
1483         __out_opt               size_t *pref_chunkp);
1484
1485 extern  __checkReturn           efx_rc_t
1486 efx_nvram_rw_finish(
1487         __in                    efx_nic_t *enp,
1488         __in                    efx_nvram_type_t type,
1489         __out_opt               uint32_t *verify_resultp);
1490
1491 extern  __checkReturn           efx_rc_t
1492 efx_nvram_get_version(
1493         __in                    efx_nic_t *enp,
1494         __in                    efx_nvram_type_t type,
1495         __out                   uint32_t *subtypep,
1496         __out_ecount(4)         uint16_t version[4]);
1497
1498 extern  __checkReturn           efx_rc_t
1499 efx_nvram_read_chunk(
1500         __in                    efx_nic_t *enp,
1501         __in                    efx_nvram_type_t type,
1502         __in                    unsigned int offset,
1503         __out_bcount(size)      caddr_t data,
1504         __in                    size_t size);
1505
1506 extern  __checkReturn           efx_rc_t
1507 efx_nvram_read_backup(
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_set_version(
1516         __in                    efx_nic_t *enp,
1517         __in                    efx_nvram_type_t type,
1518         __in_ecount(4)          uint16_t version[4]);
1519
1520 extern  __checkReturn           efx_rc_t
1521 efx_nvram_validate(
1522         __in                    efx_nic_t *enp,
1523         __in                    efx_nvram_type_t type,
1524         __in_bcount(partn_size) caddr_t partn_data,
1525         __in                    size_t partn_size);
1526
1527 extern   __checkReturn          efx_rc_t
1528 efx_nvram_erase(
1529         __in                    efx_nic_t *enp,
1530         __in                    efx_nvram_type_t type);
1531
1532 extern  __checkReturn           efx_rc_t
1533 efx_nvram_write_chunk(
1534         __in                    efx_nic_t *enp,
1535         __in                    efx_nvram_type_t type,
1536         __in                    unsigned int offset,
1537         __in_bcount(size)       caddr_t data,
1538         __in                    size_t size);
1539
1540 extern                          void
1541 efx_nvram_fini(
1542         __in                    efx_nic_t *enp);
1543
1544 #endif  /* EFSYS_OPT_NVRAM */
1545
1546 #if EFSYS_OPT_BOOTCFG
1547
1548 /* Report size and offset of bootcfg sector in NVRAM partition. */
1549 extern  __checkReturn           efx_rc_t
1550 efx_bootcfg_sector_info(
1551         __in                    efx_nic_t *enp,
1552         __in                    uint32_t pf,
1553         __out_opt               uint32_t *sector_countp,
1554         __out                   size_t *offsetp,
1555         __out                   size_t *max_sizep);
1556
1557 /*
1558  * Copy bootcfg sector data to a target buffer which may differ in size.
1559  * Optionally corrects format errors in source buffer.
1560  */
1561 extern                          efx_rc_t
1562 efx_bootcfg_copy_sector(
1563         __in                    efx_nic_t *enp,
1564         __inout_bcount(sector_length)
1565                                 uint8_t *sector,
1566         __in                    size_t sector_length,
1567         __out_bcount(data_size) uint8_t *data,
1568         __in                    size_t data_size,
1569         __in                    boolean_t handle_format_errors);
1570
1571 extern                          efx_rc_t
1572 efx_bootcfg_read(
1573         __in                    efx_nic_t *enp,
1574         __out_bcount(size)      uint8_t *data,
1575         __in                    size_t size);
1576
1577 extern                          efx_rc_t
1578 efx_bootcfg_write(
1579         __in                    efx_nic_t *enp,
1580         __in_bcount(size)       uint8_t *data,
1581         __in                    size_t size);
1582
1583 #endif  /* EFSYS_OPT_BOOTCFG */
1584
1585 #if EFSYS_OPT_IMAGE_LAYOUT
1586
1587 #include "ef10_signed_image_layout.h"
1588
1589 /*
1590  * Image header used in unsigned and signed image layouts (see SF-102785-PS).
1591  *
1592  * NOTE:
1593  * The image header format is extensible. However, older drivers require an
1594  * exact match of image header version and header length when validating and
1595  * writing firmware images.
1596  *
1597  * To avoid breaking backward compatibility, we use the upper bits of the
1598  * controller version fields to contain an extra version number used for
1599  * combined bootROM and UEFI ROM images on EF10 and later (to hold the UEFI ROM
1600  * version). See bug39254 and SF-102785-PS for details.
1601  */
1602 typedef struct efx_image_header_s {
1603         uint32_t        eih_magic;
1604         uint32_t        eih_version;
1605         uint32_t        eih_type;
1606         uint32_t        eih_subtype;
1607         uint32_t        eih_code_size;
1608         uint32_t        eih_size;
1609         union {
1610                 uint32_t        eih_controller_version_min;
1611                 struct {
1612                         uint16_t        eih_controller_version_min_short;
1613                         uint8_t         eih_extra_version_a;
1614                         uint8_t         eih_extra_version_b;
1615                 };
1616         };
1617         union {
1618                 uint32_t        eih_controller_version_max;
1619                 struct {
1620                         uint16_t        eih_controller_version_max_short;
1621                         uint8_t         eih_extra_version_c;
1622                         uint8_t         eih_extra_version_d;
1623                 };
1624         };
1625         uint16_t        eih_code_version_a;
1626         uint16_t        eih_code_version_b;
1627         uint16_t        eih_code_version_c;
1628         uint16_t        eih_code_version_d;
1629 } efx_image_header_t;
1630
1631 #define EFX_IMAGE_HEADER_SIZE           (40)
1632 #define EFX_IMAGE_HEADER_VERSION        (4)
1633 #define EFX_IMAGE_HEADER_MAGIC          (0x106F1A5)
1634
1635
1636 typedef struct efx_image_trailer_s {
1637         uint32_t        eit_crc;
1638 } efx_image_trailer_t;
1639
1640 #define EFX_IMAGE_TRAILER_SIZE          (4)
1641
1642 typedef enum efx_image_format_e {
1643         EFX_IMAGE_FORMAT_NO_IMAGE,
1644         EFX_IMAGE_FORMAT_INVALID,
1645         EFX_IMAGE_FORMAT_UNSIGNED,
1646         EFX_IMAGE_FORMAT_SIGNED,
1647 } efx_image_format_t;
1648
1649 typedef struct efx_image_info_s {
1650         efx_image_format_t      eii_format;
1651         uint8_t *               eii_imagep;
1652         size_t                  eii_image_size;
1653         efx_image_header_t *    eii_headerp;
1654 } efx_image_info_t;
1655
1656 extern  __checkReturn   efx_rc_t
1657 efx_check_reflash_image(
1658         __in            void                    *bufferp,
1659         __in            uint32_t                buffer_size,
1660         __out           efx_image_info_t        *infop);
1661
1662 extern  __checkReturn   efx_rc_t
1663 efx_build_signed_image_write_buffer(
1664         __out           uint8_t                 *bufferp,
1665         __in            uint32_t                buffer_size,
1666         __in            efx_image_info_t        *infop,
1667         __out           efx_image_header_t      **headerpp);
1668
1669 #endif  /* EFSYS_OPT_IMAGE_LAYOUT */
1670
1671 #if EFSYS_OPT_DIAG
1672
1673 typedef enum efx_pattern_type_t {
1674         EFX_PATTERN_BYTE_INCREMENT = 0,
1675         EFX_PATTERN_ALL_THE_SAME,
1676         EFX_PATTERN_BIT_ALTERNATE,
1677         EFX_PATTERN_BYTE_ALTERNATE,
1678         EFX_PATTERN_BYTE_CHANGING,
1679         EFX_PATTERN_BIT_SWEEP,
1680         EFX_PATTERN_NTYPES
1681 } efx_pattern_type_t;
1682
1683 typedef                 void
1684 (*efx_sram_pattern_fn_t)(
1685         __in            size_t row,
1686         __in            boolean_t negate,
1687         __out           efx_qword_t *eqp);
1688
1689 extern  __checkReturn   efx_rc_t
1690 efx_sram_test(
1691         __in            efx_nic_t *enp,
1692         __in            efx_pattern_type_t type);
1693
1694 #endif  /* EFSYS_OPT_DIAG */
1695
1696 extern  __checkReturn   efx_rc_t
1697 efx_sram_buf_tbl_set(
1698         __in            efx_nic_t *enp,
1699         __in            uint32_t id,
1700         __in            efsys_mem_t *esmp,
1701         __in            size_t n);
1702
1703 extern          void
1704 efx_sram_buf_tbl_clear(
1705         __in    efx_nic_t *enp,
1706         __in    uint32_t id,
1707         __in    size_t n);
1708
1709 #define EFX_BUF_TBL_SIZE        0x20000
1710
1711 #define EFX_BUF_SIZE            4096
1712
1713 /* EV */
1714
1715 typedef struct efx_evq_s        efx_evq_t;
1716
1717 #if EFSYS_OPT_QSTATS
1718
1719 /* START MKCONFIG GENERATED EfxHeaderEventQueueBlock 6f3843f5fe7cc843 */
1720 typedef enum efx_ev_qstat_e {
1721         EV_ALL,
1722         EV_RX,
1723         EV_RX_OK,
1724         EV_RX_FRM_TRUNC,
1725         EV_RX_TOBE_DISC,
1726         EV_RX_PAUSE_FRM_ERR,
1727         EV_RX_BUF_OWNER_ID_ERR,
1728         EV_RX_IPV4_HDR_CHKSUM_ERR,
1729         EV_RX_TCP_UDP_CHKSUM_ERR,
1730         EV_RX_ETH_CRC_ERR,
1731         EV_RX_IP_FRAG_ERR,
1732         EV_RX_MCAST_PKT,
1733         EV_RX_MCAST_HASH_MATCH,
1734         EV_RX_TCP_IPV4,
1735         EV_RX_TCP_IPV6,
1736         EV_RX_UDP_IPV4,
1737         EV_RX_UDP_IPV6,
1738         EV_RX_OTHER_IPV4,
1739         EV_RX_OTHER_IPV6,
1740         EV_RX_NON_IP,
1741         EV_RX_BATCH,
1742         EV_TX,
1743         EV_TX_WQ_FF_FULL,
1744         EV_TX_PKT_ERR,
1745         EV_TX_PKT_TOO_BIG,
1746         EV_TX_UNEXPECTED,
1747         EV_GLOBAL,
1748         EV_GLOBAL_MNT,
1749         EV_DRIVER,
1750         EV_DRIVER_SRM_UPD_DONE,
1751         EV_DRIVER_TX_DESCQ_FLS_DONE,
1752         EV_DRIVER_RX_DESCQ_FLS_DONE,
1753         EV_DRIVER_RX_DESCQ_FLS_FAILED,
1754         EV_DRIVER_RX_DSC_ERROR,
1755         EV_DRIVER_TX_DSC_ERROR,
1756         EV_DRV_GEN,
1757         EV_MCDI_RESPONSE,
1758         EV_NQSTATS
1759 } efx_ev_qstat_t;
1760
1761 /* END MKCONFIG GENERATED EfxHeaderEventQueueBlock */
1762
1763 #endif  /* EFSYS_OPT_QSTATS */
1764
1765 extern  __checkReturn   efx_rc_t
1766 efx_ev_init(
1767         __in            efx_nic_t *enp);
1768
1769 extern          void
1770 efx_ev_fini(
1771         __in            efx_nic_t *enp);
1772
1773 #define EFX_EVQ_MAXNEVS         32768
1774 #define EFX_EVQ_MINNEVS         512
1775
1776 #define EFX_EVQ_SIZE(_nevs)     ((_nevs) * sizeof (efx_qword_t))
1777 #define EFX_EVQ_NBUFS(_nevs)    (EFX_EVQ_SIZE(_nevs) / EFX_BUF_SIZE)
1778
1779 #define EFX_EVQ_FLAGS_TYPE_MASK         (0x3)
1780 #define EFX_EVQ_FLAGS_TYPE_AUTO         (0x0)
1781 #define EFX_EVQ_FLAGS_TYPE_THROUGHPUT   (0x1)
1782 #define EFX_EVQ_FLAGS_TYPE_LOW_LATENCY  (0x2)
1783
1784 #define EFX_EVQ_FLAGS_NOTIFY_MASK       (0xC)
1785 #define EFX_EVQ_FLAGS_NOTIFY_INTERRUPT  (0x0)   /* Interrupting (default) */
1786 #define EFX_EVQ_FLAGS_NOTIFY_DISABLED   (0x4)   /* Non-interrupting */
1787
1788 extern  __checkReturn   efx_rc_t
1789 efx_ev_qcreate(
1790         __in            efx_nic_t *enp,
1791         __in            unsigned int index,
1792         __in            efsys_mem_t *esmp,
1793         __in            size_t ndescs,
1794         __in            uint32_t id,
1795         __in            uint32_t us,
1796         __in            uint32_t flags,
1797         __deref_out     efx_evq_t **eepp);
1798
1799 extern          void
1800 efx_ev_qpost(
1801         __in            efx_evq_t *eep,
1802         __in            uint16_t data);
1803
1804 typedef __checkReturn   boolean_t
1805 (*efx_initialized_ev_t)(
1806         __in_opt        void *arg);
1807
1808 #define EFX_PKT_UNICAST         0x0004
1809 #define EFX_PKT_START           0x0008
1810
1811 #define EFX_PKT_VLAN_TAGGED     0x0010
1812 #define EFX_CKSUM_TCPUDP        0x0020
1813 #define EFX_CKSUM_IPV4          0x0040
1814 #define EFX_PKT_CONT            0x0080
1815
1816 #define EFX_CHECK_VLAN          0x0100
1817 #define EFX_PKT_TCP             0x0200
1818 #define EFX_PKT_UDP             0x0400
1819 #define EFX_PKT_IPV4            0x0800
1820
1821 #define EFX_PKT_IPV6            0x1000
1822 #define EFX_PKT_PREFIX_LEN      0x2000
1823 #define EFX_ADDR_MISMATCH       0x4000
1824 #define EFX_DISCARD             0x8000
1825
1826 /*
1827  * The following flags are used only for packed stream
1828  * mode. The values for the flags are reused to fit into 16 bit,
1829  * since EFX_PKT_START and EFX_PKT_CONT are never used in
1830  * packed stream mode
1831  */
1832 #define EFX_PKT_PACKED_STREAM_NEW_BUFFER        EFX_PKT_START
1833 #define EFX_PKT_PACKED_STREAM_PARSE_INCOMPLETE  EFX_PKT_CONT
1834
1835
1836 #define EFX_EV_RX_NLABELS       32
1837 #define EFX_EV_TX_NLABELS       32
1838
1839 typedef __checkReturn   boolean_t
1840 (*efx_rx_ev_t)(
1841         __in_opt        void *arg,
1842         __in            uint32_t label,
1843         __in            uint32_t id,
1844         __in            uint32_t size,
1845         __in            uint16_t flags);
1846
1847 #if EFSYS_OPT_RX_PACKED_STREAM
1848
1849 /*
1850  * Packed stream mode is documented in SF-112241-TC.
1851  * The general idea is that, instead of putting each incoming
1852  * packet into a separate buffer which is specified in a RX
1853  * descriptor, a large buffer is provided to the hardware and
1854  * packets are put there in a continuous stream.
1855  * The main advantage of such an approach is that RX queue refilling
1856  * happens much less frequently.
1857  */
1858
1859 typedef __checkReturn   boolean_t
1860 (*efx_rx_ps_ev_t)(
1861         __in_opt        void *arg,
1862         __in            uint32_t label,
1863         __in            uint32_t id,
1864         __in            uint32_t pkt_count,
1865         __in            uint16_t flags);
1866
1867 #endif
1868
1869 typedef __checkReturn   boolean_t
1870 (*efx_tx_ev_t)(
1871         __in_opt        void *arg,
1872         __in            uint32_t label,
1873         __in            uint32_t id);
1874
1875 #define EFX_EXCEPTION_RX_RECOVERY       0x00000001
1876 #define EFX_EXCEPTION_RX_DSC_ERROR      0x00000002
1877 #define EFX_EXCEPTION_TX_DSC_ERROR      0x00000003
1878 #define EFX_EXCEPTION_UNKNOWN_SENSOREVT 0x00000004
1879 #define EFX_EXCEPTION_FWALERT_SRAM      0x00000005
1880 #define EFX_EXCEPTION_UNKNOWN_FWALERT   0x00000006
1881 #define EFX_EXCEPTION_RX_ERROR          0x00000007
1882 #define EFX_EXCEPTION_TX_ERROR          0x00000008
1883 #define EFX_EXCEPTION_EV_ERROR          0x00000009
1884
1885 typedef __checkReturn   boolean_t
1886 (*efx_exception_ev_t)(
1887         __in_opt        void *arg,
1888         __in            uint32_t label,
1889         __in            uint32_t data);
1890
1891 typedef __checkReturn   boolean_t
1892 (*efx_rxq_flush_done_ev_t)(
1893         __in_opt        void *arg,
1894         __in            uint32_t rxq_index);
1895
1896 typedef __checkReturn   boolean_t
1897 (*efx_rxq_flush_failed_ev_t)(
1898         __in_opt        void *arg,
1899         __in            uint32_t rxq_index);
1900
1901 typedef __checkReturn   boolean_t
1902 (*efx_txq_flush_done_ev_t)(
1903         __in_opt        void *arg,
1904         __in            uint32_t txq_index);
1905
1906 typedef __checkReturn   boolean_t
1907 (*efx_software_ev_t)(
1908         __in_opt        void *arg,
1909         __in            uint16_t magic);
1910
1911 typedef __checkReturn   boolean_t
1912 (*efx_sram_ev_t)(
1913         __in_opt        void *arg,
1914         __in            uint32_t code);
1915
1916 #define EFX_SRAM_CLEAR          0
1917 #define EFX_SRAM_UPDATE         1
1918 #define EFX_SRAM_ILLEGAL_CLEAR  2
1919
1920 typedef __checkReturn   boolean_t
1921 (*efx_wake_up_ev_t)(
1922         __in_opt        void *arg,
1923         __in            uint32_t label);
1924
1925 typedef __checkReturn   boolean_t
1926 (*efx_timer_ev_t)(
1927         __in_opt        void *arg,
1928         __in            uint32_t label);
1929
1930 typedef __checkReturn   boolean_t
1931 (*efx_link_change_ev_t)(
1932         __in_opt        void *arg,
1933         __in            efx_link_mode_t link_mode);
1934
1935 #if EFSYS_OPT_MON_STATS
1936
1937 typedef __checkReturn   boolean_t
1938 (*efx_monitor_ev_t)(
1939         __in_opt        void *arg,
1940         __in            efx_mon_stat_t id,
1941         __in            efx_mon_stat_value_t value);
1942
1943 #endif  /* EFSYS_OPT_MON_STATS */
1944
1945 #if EFSYS_OPT_MAC_STATS
1946
1947 typedef __checkReturn   boolean_t
1948 (*efx_mac_stats_ev_t)(
1949         __in_opt        void *arg,
1950         __in            uint32_t generation);
1951
1952 #endif  /* EFSYS_OPT_MAC_STATS */
1953
1954 typedef struct efx_ev_callbacks_s {
1955         efx_initialized_ev_t            eec_initialized;
1956         efx_rx_ev_t                     eec_rx;
1957 #if EFSYS_OPT_RX_PACKED_STREAM
1958         efx_rx_ps_ev_t                  eec_rx_ps;
1959 #endif
1960         efx_tx_ev_t                     eec_tx;
1961         efx_exception_ev_t              eec_exception;
1962         efx_rxq_flush_done_ev_t         eec_rxq_flush_done;
1963         efx_rxq_flush_failed_ev_t       eec_rxq_flush_failed;
1964         efx_txq_flush_done_ev_t         eec_txq_flush_done;
1965         efx_software_ev_t               eec_software;
1966         efx_sram_ev_t                   eec_sram;
1967         efx_wake_up_ev_t                eec_wake_up;
1968         efx_timer_ev_t                  eec_timer;
1969         efx_link_change_ev_t            eec_link_change;
1970 #if EFSYS_OPT_MON_STATS
1971         efx_monitor_ev_t                eec_monitor;
1972 #endif  /* EFSYS_OPT_MON_STATS */
1973 #if EFSYS_OPT_MAC_STATS
1974         efx_mac_stats_ev_t              eec_mac_stats;
1975 #endif  /* EFSYS_OPT_MAC_STATS */
1976 } efx_ev_callbacks_t;
1977
1978 extern  __checkReturn   boolean_t
1979 efx_ev_qpending(
1980         __in            efx_evq_t *eep,
1981         __in            unsigned int count);
1982
1983 #if EFSYS_OPT_EV_PREFETCH
1984
1985 extern                  void
1986 efx_ev_qprefetch(
1987         __in            efx_evq_t *eep,
1988         __in            unsigned int count);
1989
1990 #endif  /* EFSYS_OPT_EV_PREFETCH */
1991
1992 extern                  void
1993 efx_ev_qpoll(
1994         __in            efx_evq_t *eep,
1995         __inout         unsigned int *countp,
1996         __in            const efx_ev_callbacks_t *eecp,
1997         __in_opt        void *arg);
1998
1999 extern  __checkReturn   efx_rc_t
2000 efx_ev_usecs_to_ticks(
2001         __in            efx_nic_t *enp,
2002         __in            unsigned int usecs,
2003         __out           unsigned int *ticksp);
2004
2005 extern  __checkReturn   efx_rc_t
2006 efx_ev_qmoderate(
2007         __in            efx_evq_t *eep,
2008         __in            unsigned int us);
2009
2010 extern  __checkReturn   efx_rc_t
2011 efx_ev_qprime(
2012         __in            efx_evq_t *eep,
2013         __in            unsigned int count);
2014
2015 #if EFSYS_OPT_QSTATS
2016
2017 #if EFSYS_OPT_NAMES
2018
2019 extern          const char *
2020 efx_ev_qstat_name(
2021         __in    efx_nic_t *enp,
2022         __in    unsigned int id);
2023
2024 #endif  /* EFSYS_OPT_NAMES */
2025
2026 extern                                  void
2027 efx_ev_qstats_update(
2028         __in                            efx_evq_t *eep,
2029         __inout_ecount(EV_NQSTATS)      efsys_stat_t *stat);
2030
2031 #endif  /* EFSYS_OPT_QSTATS */
2032
2033 extern          void
2034 efx_ev_qdestroy(
2035         __in    efx_evq_t *eep);
2036
2037 /* RX */
2038
2039 extern  __checkReturn   efx_rc_t
2040 efx_rx_init(
2041         __inout         efx_nic_t *enp);
2042
2043 extern          void
2044 efx_rx_fini(
2045         __in            efx_nic_t *enp);
2046
2047 #if EFSYS_OPT_RX_SCATTER
2048         __checkReturn   efx_rc_t
2049 efx_rx_scatter_enable(
2050         __in            efx_nic_t *enp,
2051         __in            unsigned int buf_size);
2052 #endif  /* EFSYS_OPT_RX_SCATTER */
2053
2054 /* Handle to represent use of the default RSS context. */
2055 #define EFX_RSS_CONTEXT_DEFAULT 0xffffffff
2056
2057 #if EFSYS_OPT_RX_SCALE
2058
2059 typedef enum efx_rx_hash_alg_e {
2060         EFX_RX_HASHALG_LFSR = 0,
2061         EFX_RX_HASHALG_TOEPLITZ
2062 } efx_rx_hash_alg_t;
2063
2064 #define EFX_RX_HASH_IPV4        (1U << 0)
2065 #define EFX_RX_HASH_TCPIPV4     (1U << 1)
2066 #define EFX_RX_HASH_IPV6        (1U << 2)
2067 #define EFX_RX_HASH_TCPIPV6     (1U << 3)
2068
2069 typedef unsigned int efx_rx_hash_type_t;
2070
2071 typedef enum efx_rx_hash_support_e {
2072         EFX_RX_HASH_UNAVAILABLE = 0,    /* Hardware hash not inserted */
2073         EFX_RX_HASH_AVAILABLE           /* Insert hash with/without RSS */
2074 } efx_rx_hash_support_t;
2075
2076 #define EFX_RSS_KEY_SIZE        40      /* RSS key size (bytes) */
2077 #define EFX_RSS_TBL_SIZE        128     /* Rows in RX indirection table */
2078 #define EFX_MAXRSS              64      /* RX indirection entry range */
2079 #define EFX_MAXRSS_LEGACY       16      /* See bug16611 and bug17213 */
2080
2081 typedef enum efx_rx_scale_context_type_e {
2082         EFX_RX_SCALE_UNAVAILABLE = 0,   /* No RX scale context */
2083         EFX_RX_SCALE_EXCLUSIVE,         /* Writable key/indirection table */
2084         EFX_RX_SCALE_SHARED             /* Read-only key/indirection table */
2085 } efx_rx_scale_context_type_t;
2086
2087 extern  __checkReturn   efx_rc_t
2088 efx_rx_hash_default_support_get(
2089         __in            efx_nic_t *enp,
2090         __out           efx_rx_hash_support_t *supportp);
2091
2092
2093 extern  __checkReturn   efx_rc_t
2094 efx_rx_scale_default_support_get(
2095         __in            efx_nic_t *enp,
2096         __out           efx_rx_scale_context_type_t *typep);
2097
2098 extern  __checkReturn   efx_rc_t
2099 efx_rx_scale_context_alloc(
2100         __in            efx_nic_t *enp,
2101         __in            efx_rx_scale_context_type_t type,
2102         __in            uint32_t num_queues,
2103         __out           uint32_t *rss_contextp);
2104
2105 extern  __checkReturn   efx_rc_t
2106 efx_rx_scale_context_free(
2107         __in            efx_nic_t *enp,
2108         __in            uint32_t rss_context);
2109
2110 extern  __checkReturn   efx_rc_t
2111 efx_rx_scale_mode_set(
2112         __in    efx_nic_t *enp,
2113         __in    uint32_t rss_context,
2114         __in    efx_rx_hash_alg_t alg,
2115         __in    efx_rx_hash_type_t type,
2116         __in    boolean_t insert);
2117
2118 extern  __checkReturn   efx_rc_t
2119 efx_rx_scale_tbl_set(
2120         __in            efx_nic_t *enp,
2121         __in            uint32_t rss_context,
2122         __in_ecount(n)  unsigned int *table,
2123         __in            size_t n);
2124
2125 extern  __checkReturn   efx_rc_t
2126 efx_rx_scale_key_set(
2127         __in            efx_nic_t *enp,
2128         __in            uint32_t rss_context,
2129         __in_ecount(n)  uint8_t *key,
2130         __in            size_t n);
2131
2132 extern  __checkReturn   uint32_t
2133 efx_pseudo_hdr_hash_get(
2134         __in            efx_rxq_t *erp,
2135         __in            efx_rx_hash_alg_t func,
2136         __in            uint8_t *buffer);
2137
2138 #endif  /* EFSYS_OPT_RX_SCALE */
2139
2140 extern  __checkReturn   efx_rc_t
2141 efx_pseudo_hdr_pkt_length_get(
2142         __in            efx_rxq_t *erp,
2143         __in            uint8_t *buffer,
2144         __out           uint16_t *pkt_lengthp);
2145
2146 #define EFX_RXQ_MAXNDESCS               4096
2147 #define EFX_RXQ_MINNDESCS               512
2148
2149 #define EFX_RXQ_SIZE(_ndescs)           ((_ndescs) * sizeof (efx_qword_t))
2150 #define EFX_RXQ_NBUFS(_ndescs)          (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
2151 #define EFX_RXQ_LIMIT(_ndescs)          ((_ndescs) - 16)
2152 #define EFX_RXQ_DC_NDESCS(_dcsize)      (8 << _dcsize)
2153
2154 typedef enum efx_rxq_type_e {
2155         EFX_RXQ_TYPE_DEFAULT,
2156         EFX_RXQ_TYPE_PACKED_STREAM,
2157         EFX_RXQ_NTYPES
2158 } efx_rxq_type_t;
2159
2160 /*
2161  * Dummy flag to be used instead of 0 to make it clear that the argument
2162  * is receive queue flags.
2163  */
2164 #define EFX_RXQ_FLAG_NONE               0x0
2165 #define EFX_RXQ_FLAG_SCATTER            0x1
2166 /*
2167  * If tunnels are supported and Rx event can provide information about
2168  * either outer or inner packet classes (e.g. SFN8xxx adapters with
2169  * full-feature firmware variant running), outer classes are requested by
2170  * default. However, if the driver supports tunnels, the flag allows to
2171  * request inner classes which are required to be able to interpret inner
2172  * Rx checksum offload results.
2173  */
2174 #define EFX_RXQ_FLAG_INNER_CLASSES      0x2
2175
2176 extern  __checkReturn   efx_rc_t
2177 efx_rx_qcreate(
2178         __in            efx_nic_t *enp,
2179         __in            unsigned int index,
2180         __in            unsigned int label,
2181         __in            efx_rxq_type_t type,
2182         __in            efsys_mem_t *esmp,
2183         __in            size_t ndescs,
2184         __in            uint32_t id,
2185         __in            unsigned int flags,
2186         __in            efx_evq_t *eep,
2187         __deref_out     efx_rxq_t **erpp);
2188
2189 #if EFSYS_OPT_RX_PACKED_STREAM
2190
2191 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_1M       (1U * 1024 * 1024)
2192 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_512K     (512U * 1024)
2193 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_256K     (256U * 1024)
2194 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_128K     (128U * 1024)
2195 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_64K      (64U * 1024)
2196
2197 extern  __checkReturn   efx_rc_t
2198 efx_rx_qcreate_packed_stream(
2199         __in            efx_nic_t *enp,
2200         __in            unsigned int index,
2201         __in            unsigned int label,
2202         __in            uint32_t ps_buf_size,
2203         __in            efsys_mem_t *esmp,
2204         __in            size_t ndescs,
2205         __in            efx_evq_t *eep,
2206         __deref_out     efx_rxq_t **erpp);
2207
2208 #endif
2209
2210 typedef struct efx_buffer_s {
2211         efsys_dma_addr_t        eb_addr;
2212         size_t                  eb_size;
2213         boolean_t               eb_eop;
2214 } efx_buffer_t;
2215
2216 typedef struct efx_desc_s {
2217         efx_qword_t ed_eq;
2218 } efx_desc_t;
2219
2220 extern                          void
2221 efx_rx_qpost(
2222         __in                    efx_rxq_t *erp,
2223         __in_ecount(ndescs)     efsys_dma_addr_t *addrp,
2224         __in                    size_t size,
2225         __in                    unsigned int ndescs,
2226         __in                    unsigned int completed,
2227         __in                    unsigned int added);
2228
2229 extern          void
2230 efx_rx_qpush(
2231         __in    efx_rxq_t *erp,
2232         __in    unsigned int added,
2233         __inout unsigned int *pushedp);
2234
2235 #if EFSYS_OPT_RX_PACKED_STREAM
2236
2237 extern                  void
2238 efx_rx_qpush_ps_credits(
2239         __in            efx_rxq_t *erp);
2240
2241 extern  __checkReturn   uint8_t *
2242 efx_rx_qps_packet_info(
2243         __in            efx_rxq_t *erp,
2244         __in            uint8_t *buffer,
2245         __in            uint32_t buffer_length,
2246         __in            uint32_t current_offset,
2247         __out           uint16_t *lengthp,
2248         __out           uint32_t *next_offsetp,
2249         __out           uint32_t *timestamp);
2250 #endif
2251
2252 extern  __checkReturn   efx_rc_t
2253 efx_rx_qflush(
2254         __in    efx_rxq_t *erp);
2255
2256 extern          void
2257 efx_rx_qenable(
2258         __in    efx_rxq_t *erp);
2259
2260 extern          void
2261 efx_rx_qdestroy(
2262         __in    efx_rxq_t *erp);
2263
2264 /* TX */
2265
2266 typedef struct efx_txq_s        efx_txq_t;
2267
2268 #if EFSYS_OPT_QSTATS
2269
2270 /* START MKCONFIG GENERATED EfxHeaderTransmitQueueBlock 12dff8778598b2db */
2271 typedef enum efx_tx_qstat_e {
2272         TX_POST,
2273         TX_POST_PIO,
2274         TX_NQSTATS
2275 } efx_tx_qstat_t;
2276
2277 /* END MKCONFIG GENERATED EfxHeaderTransmitQueueBlock */
2278
2279 #endif  /* EFSYS_OPT_QSTATS */
2280
2281 extern  __checkReturn   efx_rc_t
2282 efx_tx_init(
2283         __in            efx_nic_t *enp);
2284
2285 extern          void
2286 efx_tx_fini(
2287         __in    efx_nic_t *enp);
2288
2289 #define EFX_TXQ_MINNDESCS               512
2290
2291 #define EFX_TXQ_SIZE(_ndescs)           ((_ndescs) * sizeof (efx_qword_t))
2292 #define EFX_TXQ_NBUFS(_ndescs)          (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
2293 #define EFX_TXQ_LIMIT(_ndescs)          ((_ndescs) - 16)
2294
2295 #define EFX_TXQ_MAX_BUFS 8 /* Maximum independent of EFX_BUG35388_WORKAROUND. */
2296
2297 #define EFX_TXQ_CKSUM_IPV4              0x0001
2298 #define EFX_TXQ_CKSUM_TCPUDP            0x0002
2299 #define EFX_TXQ_FATSOV2                 0x0004
2300 #define EFX_TXQ_CKSUM_INNER_IPV4        0x0008
2301 #define EFX_TXQ_CKSUM_INNER_TCPUDP      0x0010
2302
2303 extern  __checkReturn   efx_rc_t
2304 efx_tx_qcreate(
2305         __in            efx_nic_t *enp,
2306         __in            unsigned int index,
2307         __in            unsigned int label,
2308         __in            efsys_mem_t *esmp,
2309         __in            size_t n,
2310         __in            uint32_t id,
2311         __in            uint16_t flags,
2312         __in            efx_evq_t *eep,
2313         __deref_out     efx_txq_t **etpp,
2314         __out           unsigned int *addedp);
2315
2316 extern  __checkReturn           efx_rc_t
2317 efx_tx_qpost(
2318         __in                    efx_txq_t *etp,
2319         __in_ecount(ndescs)     efx_buffer_t *eb,
2320         __in                    unsigned int ndescs,
2321         __in                    unsigned int completed,
2322         __inout                 unsigned int *addedp);
2323
2324 extern  __checkReturn   efx_rc_t
2325 efx_tx_qpace(
2326         __in            efx_txq_t *etp,
2327         __in            unsigned int ns);
2328
2329 extern                  void
2330 efx_tx_qpush(
2331         __in            efx_txq_t *etp,
2332         __in            unsigned int added,
2333         __in            unsigned int pushed);
2334
2335 extern  __checkReturn   efx_rc_t
2336 efx_tx_qflush(
2337         __in            efx_txq_t *etp);
2338
2339 extern                  void
2340 efx_tx_qenable(
2341         __in            efx_txq_t *etp);
2342
2343 extern  __checkReturn   efx_rc_t
2344 efx_tx_qpio_enable(
2345         __in            efx_txq_t *etp);
2346
2347 extern                  void
2348 efx_tx_qpio_disable(
2349         __in            efx_txq_t *etp);
2350
2351 extern  __checkReturn   efx_rc_t
2352 efx_tx_qpio_write(
2353         __in                    efx_txq_t *etp,
2354         __in_ecount(buf_length) uint8_t *buffer,
2355         __in                    size_t buf_length,
2356         __in                    size_t pio_buf_offset);
2357
2358 extern  __checkReturn   efx_rc_t
2359 efx_tx_qpio_post(
2360         __in                    efx_txq_t *etp,
2361         __in                    size_t pkt_length,
2362         __in                    unsigned int completed,
2363         __inout                 unsigned int *addedp);
2364
2365 extern  __checkReturn   efx_rc_t
2366 efx_tx_qdesc_post(
2367         __in            efx_txq_t *etp,
2368         __in_ecount(n)  efx_desc_t *ed,
2369         __in            unsigned int n,
2370         __in            unsigned int completed,
2371         __inout         unsigned int *addedp);
2372
2373 extern  void
2374 efx_tx_qdesc_dma_create(
2375         __in    efx_txq_t *etp,
2376         __in    efsys_dma_addr_t addr,
2377         __in    size_t size,
2378         __in    boolean_t eop,
2379         __out   efx_desc_t *edp);
2380
2381 extern  void
2382 efx_tx_qdesc_tso_create(
2383         __in    efx_txq_t *etp,
2384         __in    uint16_t ipv4_id,
2385         __in    uint32_t tcp_seq,
2386         __in    uint8_t  tcp_flags,
2387         __out   efx_desc_t *edp);
2388
2389 /* Number of FATSOv2 option descriptors */
2390 #define EFX_TX_FATSOV2_OPT_NDESCS               2
2391
2392 /* Maximum number of DMA segments per TSO packet (not superframe) */
2393 #define EFX_TX_FATSOV2_DMA_SEGS_PER_PKT_MAX     24
2394
2395 extern  void
2396 efx_tx_qdesc_tso2_create(
2397         __in                    efx_txq_t *etp,
2398         __in                    uint16_t ipv4_id,
2399         __in                    uint16_t outer_ipv4_id,
2400         __in                    uint32_t tcp_seq,
2401         __in                    uint16_t tcp_mss,
2402         __out_ecount(count)     efx_desc_t *edp,
2403         __in                    int count);
2404
2405 extern  void
2406 efx_tx_qdesc_vlantci_create(
2407         __in    efx_txq_t *etp,
2408         __in    uint16_t tci,
2409         __out   efx_desc_t *edp);
2410
2411 extern  void
2412 efx_tx_qdesc_checksum_create(
2413         __in    efx_txq_t *etp,
2414         __in    uint16_t flags,
2415         __out   efx_desc_t *edp);
2416
2417 #if EFSYS_OPT_QSTATS
2418
2419 #if EFSYS_OPT_NAMES
2420
2421 extern          const char *
2422 efx_tx_qstat_name(
2423         __in    efx_nic_t *etp,
2424         __in    unsigned int id);
2425
2426 #endif  /* EFSYS_OPT_NAMES */
2427
2428 extern                                  void
2429 efx_tx_qstats_update(
2430         __in                            efx_txq_t *etp,
2431         __inout_ecount(TX_NQSTATS)      efsys_stat_t *stat);
2432
2433 #endif  /* EFSYS_OPT_QSTATS */
2434
2435 extern          void
2436 efx_tx_qdestroy(
2437         __in    efx_txq_t *etp);
2438
2439
2440 /* FILTER */
2441
2442 #if EFSYS_OPT_FILTER
2443
2444 #define EFX_ETHER_TYPE_IPV4 0x0800
2445 #define EFX_ETHER_TYPE_IPV6 0x86DD
2446
2447 #define EFX_IPPROTO_TCP 6
2448 #define EFX_IPPROTO_UDP 17
2449 #define EFX_IPPROTO_GRE 47
2450
2451 /* Use RSS to spread across multiple queues */
2452 #define EFX_FILTER_FLAG_RX_RSS          0x01
2453 /* Enable RX scatter */
2454 #define EFX_FILTER_FLAG_RX_SCATTER      0x02
2455 /*
2456  * Override an automatic filter (priority EFX_FILTER_PRI_AUTO).
2457  * May only be set by the filter implementation for each type.
2458  * A removal request will restore the automatic filter in its place.
2459  */
2460 #define EFX_FILTER_FLAG_RX_OVER_AUTO    0x04
2461 /* Filter is for RX */
2462 #define EFX_FILTER_FLAG_RX              0x08
2463 /* Filter is for TX */
2464 #define EFX_FILTER_FLAG_TX              0x10
2465
2466 typedef uint8_t efx_filter_flags_t;
2467
2468 /*
2469  * Flags which specify the fields to match on. The values are the same as in the
2470  * MC_CMD_FILTER_OP/MC_CMD_FILTER_OP_EXT commands.
2471  */
2472
2473 /* Match by remote IP host address */
2474 #define EFX_FILTER_MATCH_REM_HOST               0x00000001
2475 /* Match by local IP host address */
2476 #define EFX_FILTER_MATCH_LOC_HOST               0x00000002
2477 /* Match by remote MAC address */
2478 #define EFX_FILTER_MATCH_REM_MAC                0x00000004
2479 /* Match by remote TCP/UDP port */
2480 #define EFX_FILTER_MATCH_REM_PORT               0x00000008
2481 /* Match by remote TCP/UDP port */
2482 #define EFX_FILTER_MATCH_LOC_MAC                0x00000010
2483 /* Match by local TCP/UDP port */
2484 #define EFX_FILTER_MATCH_LOC_PORT               0x00000020
2485 /* Match by Ether-type */
2486 #define EFX_FILTER_MATCH_ETHER_TYPE             0x00000040
2487 /* Match by inner VLAN ID */
2488 #define EFX_FILTER_MATCH_INNER_VID              0x00000080
2489 /* Match by outer VLAN ID */
2490 #define EFX_FILTER_MATCH_OUTER_VID              0x00000100
2491 /* Match by IP transport protocol */
2492 #define EFX_FILTER_MATCH_IP_PROTO               0x00000200
2493 /* Match by VNI or VSID */
2494 #define EFX_FILTER_MATCH_VNI_OR_VSID            0x00000800
2495 /* For encapsulated packets, match by inner frame local MAC address */
2496 #define EFX_FILTER_MATCH_IFRM_LOC_MAC           0x00010000
2497 /* For encapsulated packets, match all multicast inner frames */
2498 #define EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST 0x01000000
2499 /* For encapsulated packets, match all unicast inner frames */
2500 #define EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST 0x02000000
2501 /*
2502  * Match by encap type, this flag does not correspond to
2503  * the MCDI match flags and any unoccupied value may be used
2504  */
2505 #define EFX_FILTER_MATCH_ENCAP_TYPE             0x20000000
2506 /* Match otherwise-unmatched multicast and broadcast packets */
2507 #define EFX_FILTER_MATCH_UNKNOWN_MCAST_DST      0x40000000
2508 /* Match otherwise-unmatched unicast packets */
2509 #define EFX_FILTER_MATCH_UNKNOWN_UCAST_DST      0x80000000
2510
2511 typedef uint32_t efx_filter_match_flags_t;
2512
2513 typedef enum efx_filter_priority_s {
2514         EFX_FILTER_PRI_HINT = 0,        /* Performance hint */
2515         EFX_FILTER_PRI_AUTO,            /* Automatic filter based on device
2516                                          * address list or hardware
2517                                          * requirements. This may only be used
2518                                          * by the filter implementation for
2519                                          * each NIC type. */
2520         EFX_FILTER_PRI_MANUAL,          /* Manually configured filter */
2521         EFX_FILTER_PRI_REQUIRED,        /* Required for correct behaviour of the
2522                                          * client (e.g. SR-IOV, HyperV VMQ etc.)
2523                                          */
2524 } efx_filter_priority_t;
2525
2526 /*
2527  * FIXME: All these fields are assumed to be in little-endian byte order.
2528  * It may be better for some to be big-endian. See bug42804.
2529  */
2530
2531 typedef struct efx_filter_spec_s {
2532         efx_filter_match_flags_t        efs_match_flags;
2533         uint8_t                         efs_priority;
2534         efx_filter_flags_t              efs_flags;
2535         uint16_t                        efs_dmaq_id;
2536         uint32_t                        efs_rss_context;
2537         uint16_t                        efs_outer_vid;
2538         uint16_t                        efs_inner_vid;
2539         uint8_t                         efs_loc_mac[EFX_MAC_ADDR_LEN];
2540         uint8_t                         efs_rem_mac[EFX_MAC_ADDR_LEN];
2541         uint16_t                        efs_ether_type;
2542         uint8_t                         efs_ip_proto;
2543         efx_tunnel_protocol_t           efs_encap_type;
2544         uint16_t                        efs_loc_port;
2545         uint16_t                        efs_rem_port;
2546         efx_oword_t                     efs_rem_host;
2547         efx_oword_t                     efs_loc_host;
2548         uint8_t                         efs_vni_or_vsid[EFX_VNI_OR_VSID_LEN];
2549         uint8_t                         efs_ifrm_loc_mac[EFX_MAC_ADDR_LEN];
2550 } efx_filter_spec_t;
2551
2552
2553 /* Default values for use in filter specifications */
2554 #define EFX_FILTER_SPEC_RX_DMAQ_ID_DROP         0xfff
2555 #define EFX_FILTER_SPEC_VID_UNSPEC              0xffff
2556
2557 extern  __checkReturn   efx_rc_t
2558 efx_filter_init(
2559         __in            efx_nic_t *enp);
2560
2561 extern                  void
2562 efx_filter_fini(
2563         __in            efx_nic_t *enp);
2564
2565 extern  __checkReturn   efx_rc_t
2566 efx_filter_insert(
2567         __in            efx_nic_t *enp,
2568         __inout         efx_filter_spec_t *spec);
2569
2570 extern  __checkReturn   efx_rc_t
2571 efx_filter_remove(
2572         __in            efx_nic_t *enp,
2573         __inout         efx_filter_spec_t *spec);
2574
2575 extern  __checkReturn   efx_rc_t
2576 efx_filter_restore(
2577         __in            efx_nic_t *enp);
2578
2579 extern  __checkReturn   efx_rc_t
2580 efx_filter_supported_filters(
2581         __in                            efx_nic_t *enp,
2582         __out_ecount(buffer_length)     uint32_t *buffer,
2583         __in                            size_t buffer_length,
2584         __out                           size_t *list_lengthp);
2585
2586 extern                  void
2587 efx_filter_spec_init_rx(
2588         __out           efx_filter_spec_t *spec,
2589         __in            efx_filter_priority_t priority,
2590         __in            efx_filter_flags_t flags,
2591         __in            efx_rxq_t *erp);
2592
2593 extern                  void
2594 efx_filter_spec_init_tx(
2595         __out           efx_filter_spec_t *spec,
2596         __in            efx_txq_t *etp);
2597
2598 extern  __checkReturn   efx_rc_t
2599 efx_filter_spec_set_ipv4_local(
2600         __inout         efx_filter_spec_t *spec,
2601         __in            uint8_t proto,
2602         __in            uint32_t host,
2603         __in            uint16_t port);
2604
2605 extern  __checkReturn   efx_rc_t
2606 efx_filter_spec_set_ipv4_full(
2607         __inout         efx_filter_spec_t *spec,
2608         __in            uint8_t proto,
2609         __in            uint32_t lhost,
2610         __in            uint16_t lport,
2611         __in            uint32_t rhost,
2612         __in            uint16_t rport);
2613
2614 extern  __checkReturn   efx_rc_t
2615 efx_filter_spec_set_eth_local(
2616         __inout         efx_filter_spec_t *spec,
2617         __in            uint16_t vid,
2618         __in            const uint8_t *addr);
2619
2620 extern                  void
2621 efx_filter_spec_set_ether_type(
2622         __inout         efx_filter_spec_t *spec,
2623         __in            uint16_t ether_type);
2624
2625 extern  __checkReturn   efx_rc_t
2626 efx_filter_spec_set_uc_def(
2627         __inout         efx_filter_spec_t *spec);
2628
2629 extern  __checkReturn   efx_rc_t
2630 efx_filter_spec_set_mc_def(
2631         __inout         efx_filter_spec_t *spec);
2632
2633 typedef enum efx_filter_inner_frame_match_e {
2634         EFX_FILTER_INNER_FRAME_MATCH_OTHER = 0,
2635         EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_MCAST_DST,
2636         EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_UCAST_DST
2637 } efx_filter_inner_frame_match_t;
2638
2639 extern  __checkReturn   efx_rc_t
2640 efx_filter_spec_set_encap_type(
2641         __inout         efx_filter_spec_t *spec,
2642         __in            efx_tunnel_protocol_t encap_type,
2643         __in            efx_filter_inner_frame_match_t inner_frame_match);
2644
2645 extern  __checkReturn   efx_rc_t
2646 efx_filter_spec_set_vxlan_full(
2647         __inout         efx_filter_spec_t *spec,
2648         __in            const uint8_t *vxlan_id,
2649         __in            const uint8_t *inner_addr,
2650         __in            const uint8_t *outer_addr);
2651
2652 #if EFSYS_OPT_RX_SCALE
2653 extern  __checkReturn   efx_rc_t
2654 efx_filter_spec_set_rss_context(
2655         __inout         efx_filter_spec_t *spec,
2656         __in            uint32_t rss_context);
2657 #endif
2658 #endif  /* EFSYS_OPT_FILTER */
2659
2660 /* HASH */
2661
2662 extern  __checkReturn           uint32_t
2663 efx_hash_dwords(
2664         __in_ecount(count)      uint32_t const *input,
2665         __in                    size_t count,
2666         __in                    uint32_t init);
2667
2668 extern  __checkReturn           uint32_t
2669 efx_hash_bytes(
2670         __in_ecount(length)     uint8_t const *input,
2671         __in                    size_t length,
2672         __in                    uint32_t init);
2673
2674 #if EFSYS_OPT_LICENSING
2675
2676 /* LICENSING */
2677
2678 typedef struct efx_key_stats_s {
2679         uint32_t        eks_valid;
2680         uint32_t        eks_invalid;
2681         uint32_t        eks_blacklisted;
2682         uint32_t        eks_unverifiable;
2683         uint32_t        eks_wrong_node;
2684         uint32_t        eks_licensed_apps_lo;
2685         uint32_t        eks_licensed_apps_hi;
2686         uint32_t        eks_licensed_features_lo;
2687         uint32_t        eks_licensed_features_hi;
2688 } efx_key_stats_t;
2689
2690 extern  __checkReturn           efx_rc_t
2691 efx_lic_init(
2692         __in                    efx_nic_t *enp);
2693
2694 extern                          void
2695 efx_lic_fini(
2696         __in                    efx_nic_t *enp);
2697
2698 extern  __checkReturn   boolean_t
2699 efx_lic_check_support(
2700         __in                    efx_nic_t *enp);
2701
2702 extern  __checkReturn   efx_rc_t
2703 efx_lic_update_licenses(
2704         __in            efx_nic_t *enp);
2705
2706 extern  __checkReturn   efx_rc_t
2707 efx_lic_get_key_stats(
2708         __in            efx_nic_t *enp,
2709         __out           efx_key_stats_t *ksp);
2710
2711 extern  __checkReturn   efx_rc_t
2712 efx_lic_app_state(
2713         __in            efx_nic_t *enp,
2714         __in            uint64_t app_id,
2715         __out           boolean_t *licensedp);
2716
2717 extern  __checkReturn   efx_rc_t
2718 efx_lic_get_id(
2719         __in            efx_nic_t *enp,
2720         __in            size_t buffer_size,
2721         __out           uint32_t *typep,
2722         __out           size_t *lengthp,
2723         __out_opt       uint8_t *bufferp);
2724
2725
2726 extern  __checkReturn           efx_rc_t
2727 efx_lic_find_start(
2728         __in                    efx_nic_t *enp,
2729         __in_bcount(buffer_size)
2730                                 caddr_t bufferp,
2731         __in                    size_t buffer_size,
2732         __out                   uint32_t *startp);
2733
2734 extern  __checkReturn           efx_rc_t
2735 efx_lic_find_end(
2736         __in                    efx_nic_t *enp,
2737         __in_bcount(buffer_size)
2738                                 caddr_t bufferp,
2739         __in                    size_t buffer_size,
2740         __in                    uint32_t offset,
2741         __out                   uint32_t *endp);
2742
2743 extern  __checkReturn   __success(return != B_FALSE)    boolean_t
2744 efx_lic_find_key(
2745         __in                    efx_nic_t *enp,
2746         __in_bcount(buffer_size)
2747                                 caddr_t bufferp,
2748         __in                    size_t buffer_size,
2749         __in                    uint32_t offset,
2750         __out                   uint32_t *startp,
2751         __out                   uint32_t *lengthp);
2752
2753 extern  __checkReturn   __success(return != B_FALSE)    boolean_t
2754 efx_lic_validate_key(
2755         __in                    efx_nic_t *enp,
2756         __in_bcount(length)     caddr_t keyp,
2757         __in                    uint32_t length);
2758
2759 extern  __checkReturn           efx_rc_t
2760 efx_lic_read_key(
2761         __in                    efx_nic_t *enp,
2762         __in_bcount(buffer_size)
2763                                 caddr_t bufferp,
2764         __in                    size_t buffer_size,
2765         __in                    uint32_t offset,
2766         __in                    uint32_t length,
2767         __out_bcount_part(key_max_size, *lengthp)
2768                                 caddr_t keyp,
2769         __in                    size_t key_max_size,
2770         __out                   uint32_t *lengthp);
2771
2772 extern  __checkReturn           efx_rc_t
2773 efx_lic_write_key(
2774         __in                    efx_nic_t *enp,
2775         __in_bcount(buffer_size)
2776                                 caddr_t bufferp,
2777         __in                    size_t buffer_size,
2778         __in                    uint32_t offset,
2779         __in_bcount(length)     caddr_t keyp,
2780         __in                    uint32_t length,
2781         __out                   uint32_t *lengthp);
2782
2783         __checkReturn           efx_rc_t
2784 efx_lic_delete_key(
2785         __in                    efx_nic_t *enp,
2786         __in_bcount(buffer_size)
2787                                 caddr_t bufferp,
2788         __in                    size_t buffer_size,
2789         __in                    uint32_t offset,
2790         __in                    uint32_t length,
2791         __in                    uint32_t end,
2792         __out                   uint32_t *deltap);
2793
2794 extern  __checkReturn           efx_rc_t
2795 efx_lic_create_partition(
2796         __in                    efx_nic_t *enp,
2797         __in_bcount(buffer_size)
2798                                 caddr_t bufferp,
2799         __in                    size_t buffer_size);
2800
2801 extern  __checkReturn           efx_rc_t
2802 efx_lic_finish_partition(
2803         __in                    efx_nic_t *enp,
2804         __in_bcount(buffer_size)
2805                                 caddr_t bufferp,
2806         __in                    size_t buffer_size);
2807
2808 #endif  /* EFSYS_OPT_LICENSING */
2809
2810 /* TUNNEL */
2811
2812 #if EFSYS_OPT_TUNNEL
2813
2814 extern  __checkReturn   efx_rc_t
2815 efx_tunnel_init(
2816         __in            efx_nic_t *enp);
2817
2818 extern                  void
2819 efx_tunnel_fini(
2820         __in            efx_nic_t *enp);
2821
2822 /*
2823  * For overlay network encapsulation using UDP, the firmware needs to know
2824  * the configured UDP port for the overlay so it can decode encapsulated
2825  * frames correctly.
2826  * The UDP port/protocol list is global.
2827  */
2828
2829 extern  __checkReturn   efx_rc_t
2830 efx_tunnel_config_udp_add(
2831         __in            efx_nic_t *enp,
2832         __in            uint16_t port /* host/cpu-endian */,
2833         __in            efx_tunnel_protocol_t protocol);
2834
2835 extern  __checkReturn   efx_rc_t
2836 efx_tunnel_config_udp_remove(
2837         __in            efx_nic_t *enp,
2838         __in            uint16_t port /* host/cpu-endian */,
2839         __in            efx_tunnel_protocol_t protocol);
2840
2841 extern                  void
2842 efx_tunnel_config_clear(
2843         __in            efx_nic_t *enp);
2844
2845 /**
2846  * Apply tunnel UDP ports configuration to hardware.
2847  *
2848  * EAGAIN is returned if hardware will be reset (datapath and managment CPU
2849  * reboot).
2850  */
2851 extern  __checkReturn   efx_rc_t
2852 efx_tunnel_reconfigure(
2853         __in            efx_nic_t *enp);
2854
2855 #endif /* EFSYS_OPT_TUNNEL */
2856
2857
2858 #ifdef  __cplusplus
2859 }
2860 #endif
2861
2862 #endif  /* _SYS_EFX_H */