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