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