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