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