fd02af1b09ea1c9ecb495e189447d62dfa2876c7
[dpdk.git] / drivers / net / sfc / base / efx.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright (c) 2006-2018 Solarflare Communications Inc.
4  * All rights reserved.
5  */
6
7 #ifndef _SYS_EFX_H
8 #define _SYS_EFX_H
9
10 #include "efsys.h"
11 #include "efx_check.h"
12 #include "efx_phy_ids.h"
13
14 #ifdef  __cplusplus
15 extern "C" {
16 #endif
17
18 #define EFX_STATIC_ASSERT(_cond)                \
19         ((void)sizeof (char[(_cond) ? 1 : -1]))
20
21 #define EFX_ARRAY_SIZE(_array)                  \
22         (sizeof (_array) / sizeof ((_array)[0]))
23
24 #define EFX_FIELD_OFFSET(_type, _field)         \
25         ((size_t)&(((_type *)0)->_field))
26
27 /* The macro expands divider twice */
28 #define EFX_DIV_ROUND_UP(_n, _d)                (((_n) + (_d) - 1) / (_d))
29
30 /* Return codes */
31
32 typedef __success(return == 0) int efx_rc_t;
33
34
35 /* Chip families */
36
37 typedef enum efx_family_e {
38         EFX_FAMILY_INVALID,
39         EFX_FAMILY_FALCON,      /* Obsolete and not supported */
40         EFX_FAMILY_SIENA,
41         EFX_FAMILY_HUNTINGTON,
42         EFX_FAMILY_MEDFORD,
43         EFX_FAMILY_MEDFORD2,
44         EFX_FAMILY_NTYPES
45 } efx_family_t;
46
47 extern  __checkReturn   efx_rc_t
48 efx_family(
49         __in            uint16_t venid,
50         __in            uint16_t devid,
51         __out           efx_family_t *efp,
52         __out           unsigned int *membarp);
53
54
55 #define EFX_PCI_VENID_SFC                       0x1924
56
57 #define EFX_PCI_DEVID_FALCON                    0x0710  /* SFC4000 */
58
59 #define EFX_PCI_DEVID_BETHPAGE                  0x0803  /* SFC9020 */
60 #define EFX_PCI_DEVID_SIENA                     0x0813  /* SFL9021 */
61 #define EFX_PCI_DEVID_SIENA_F1_UNINIT           0x0810
62
63 #define EFX_PCI_DEVID_HUNTINGTON_PF_UNINIT      0x0901
64 #define EFX_PCI_DEVID_FARMINGDALE               0x0903  /* SFC9120 PF */
65 #define EFX_PCI_DEVID_GREENPORT                 0x0923  /* SFC9140 PF */
66
67 #define EFX_PCI_DEVID_FARMINGDALE_VF            0x1903  /* SFC9120 VF */
68 #define EFX_PCI_DEVID_GREENPORT_VF              0x1923  /* SFC9140 VF */
69
70 #define EFX_PCI_DEVID_MEDFORD_PF_UNINIT         0x0913
71 #define EFX_PCI_DEVID_MEDFORD                   0x0A03  /* SFC9240 PF */
72 #define EFX_PCI_DEVID_MEDFORD_VF                0x1A03  /* SFC9240 VF */
73
74 #define EFX_PCI_DEVID_MEDFORD2_PF_UNINIT        0x0B13
75 #define EFX_PCI_DEVID_MEDFORD2                  0x0B03  /* SFC9250 PF */
76 #define EFX_PCI_DEVID_MEDFORD2_VF               0x1B03  /* SFC9250 VF */
77
78
79 #define EFX_MEM_BAR_SIENA                       2
80
81 #define EFX_MEM_BAR_HUNTINGTON_PF               2
82 #define EFX_MEM_BAR_HUNTINGTON_VF               0
83
84 #define EFX_MEM_BAR_MEDFORD_PF                  2
85 #define EFX_MEM_BAR_MEDFORD_VF                  0
86
87 #define EFX_MEM_BAR_MEDFORD2                    0
88
89
90 /* Error codes */
91
92 enum {
93         EFX_ERR_INVALID,
94         EFX_ERR_SRAM_OOB,
95         EFX_ERR_BUFID_DC_OOB,
96         EFX_ERR_MEM_PERR,
97         EFX_ERR_RBUF_OWN,
98         EFX_ERR_TBUF_OWN,
99         EFX_ERR_RDESQ_OWN,
100         EFX_ERR_TDESQ_OWN,
101         EFX_ERR_EVQ_OWN,
102         EFX_ERR_EVFF_OFLO,
103         EFX_ERR_ILL_ADDR,
104         EFX_ERR_SRAM_PERR,
105         EFX_ERR_NCODES
106 };
107
108 /* Calculate the IEEE 802.3 CRC32 of a MAC addr */
109 extern  __checkReturn           uint32_t
110 efx_crc32_calculate(
111         __in                    uint32_t crc_init,
112         __in_ecount(length)     uint8_t const *input,
113         __in                    int length);
114
115
116 /* Type prototypes */
117
118 typedef struct efx_rxq_s        efx_rxq_t;
119
120 /* NIC */
121
122 typedef struct efx_nic_s        efx_nic_t;
123
124 extern  __checkReturn   efx_rc_t
125 efx_nic_create(
126         __in            efx_family_t family,
127         __in            efsys_identifier_t *esip,
128         __in            efsys_bar_t *esbp,
129         __in            efsys_lock_t *eslp,
130         __deref_out     efx_nic_t **enpp);
131
132 extern  __checkReturn   efx_rc_t
133 efx_nic_probe(
134         __in            efx_nic_t *enp);
135
136 extern  __checkReturn   efx_rc_t
137 efx_nic_init(
138         __in            efx_nic_t *enp);
139
140 extern  __checkReturn   efx_rc_t
141 efx_nic_reset(
142         __in            efx_nic_t *enp);
143
144 #if EFSYS_OPT_DIAG
145
146 extern  __checkReturn   efx_rc_t
147 efx_nic_register_test(
148         __in            efx_nic_t *enp);
149
150 #endif  /* EFSYS_OPT_DIAG */
151
152 extern          void
153 efx_nic_fini(
154         __in            efx_nic_t *enp);
155
156 extern          void
157 efx_nic_unprobe(
158         __in            efx_nic_t *enp);
159
160 extern          void
161 efx_nic_destroy(
162         __in    efx_nic_t *enp);
163
164 #define EFX_PCIE_LINK_SPEED_GEN1                1
165 #define EFX_PCIE_LINK_SPEED_GEN2                2
166 #define EFX_PCIE_LINK_SPEED_GEN3                3
167
168 typedef enum efx_pcie_link_performance_e {
169         EFX_PCIE_LINK_PERFORMANCE_UNKNOWN_BANDWIDTH,
170         EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_BANDWIDTH,
171         EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_LATENCY,
172         EFX_PCIE_LINK_PERFORMANCE_OPTIMAL
173 } efx_pcie_link_performance_t;
174
175 extern  __checkReturn   efx_rc_t
176 efx_nic_calculate_pcie_link_bandwidth(
177         __in            uint32_t pcie_link_width,
178         __in            uint32_t pcie_link_gen,
179         __out           uint32_t *bandwidth_mbpsp);
180
181 extern  __checkReturn   efx_rc_t
182 efx_nic_check_pcie_link_speed(
183         __in            efx_nic_t *enp,
184         __in            uint32_t pcie_link_width,
185         __in            uint32_t pcie_link_gen,
186         __out           efx_pcie_link_performance_t *resultp);
187
188 #if EFSYS_OPT_MCDI
189
190 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
191 /* Huntington and Medford require MCDIv2 commands */
192 #define WITH_MCDI_V2 1
193 #endif
194
195 typedef struct efx_mcdi_req_s efx_mcdi_req_t;
196
197 typedef enum efx_mcdi_exception_e {
198         EFX_MCDI_EXCEPTION_MC_REBOOT,
199         EFX_MCDI_EXCEPTION_MC_BADASSERT,
200 } efx_mcdi_exception_t;
201
202 #if EFSYS_OPT_MCDI_LOGGING
203 typedef enum efx_log_msg_e {
204         EFX_LOG_INVALID,
205         EFX_LOG_MCDI_REQUEST,
206         EFX_LOG_MCDI_RESPONSE,
207 } efx_log_msg_t;
208 #endif /* EFSYS_OPT_MCDI_LOGGING */
209
210 typedef struct efx_mcdi_transport_s {
211         void            *emt_context;
212         efsys_mem_t     *emt_dma_mem;
213         void            (*emt_execute)(void *, efx_mcdi_req_t *);
214         void            (*emt_ev_cpl)(void *);
215         void            (*emt_exception)(void *, efx_mcdi_exception_t);
216 #if EFSYS_OPT_MCDI_LOGGING
217         void            (*emt_logger)(void *, efx_log_msg_t,
218                                         void *, size_t, void *, size_t);
219 #endif /* EFSYS_OPT_MCDI_LOGGING */
220 #if EFSYS_OPT_MCDI_PROXY_AUTH
221         void            (*emt_ev_proxy_response)(void *, uint32_t, efx_rc_t);
222 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
223 } efx_mcdi_transport_t;
224
225 extern  __checkReturn   efx_rc_t
226 efx_mcdi_init(
227         __in            efx_nic_t *enp,
228         __in            const efx_mcdi_transport_t *mtp);
229
230 extern  __checkReturn   efx_rc_t
231 efx_mcdi_reboot(
232         __in            efx_nic_t *enp);
233
234                         void
235 efx_mcdi_new_epoch(
236         __in            efx_nic_t *enp);
237
238 extern                  void
239 efx_mcdi_get_timeout(
240         __in            efx_nic_t *enp,
241         __in            efx_mcdi_req_t *emrp,
242         __out           uint32_t *usec_timeoutp);
243
244 extern                  void
245 efx_mcdi_request_start(
246         __in            efx_nic_t *enp,
247         __in            efx_mcdi_req_t *emrp,
248         __in            boolean_t ev_cpl);
249
250 extern  __checkReturn   boolean_t
251 efx_mcdi_request_poll(
252         __in            efx_nic_t *enp);
253
254 extern  __checkReturn   boolean_t
255 efx_mcdi_request_abort(
256         __in            efx_nic_t *enp);
257
258 extern                  void
259 efx_mcdi_fini(
260         __in            efx_nic_t *enp);
261
262 #endif  /* EFSYS_OPT_MCDI */
263
264 /* INTR */
265
266 #define EFX_NINTR_SIENA 1024
267
268 typedef enum efx_intr_type_e {
269         EFX_INTR_INVALID = 0,
270         EFX_INTR_LINE,
271         EFX_INTR_MESSAGE,
272         EFX_INTR_NTYPES
273 } efx_intr_type_t;
274
275 #define EFX_INTR_SIZE   (sizeof (efx_oword_t))
276
277 extern  __checkReturn   efx_rc_t
278 efx_intr_init(
279         __in            efx_nic_t *enp,
280         __in            efx_intr_type_t type,
281         __in            efsys_mem_t *esmp);
282
283 extern                  void
284 efx_intr_enable(
285         __in            efx_nic_t *enp);
286
287 extern                  void
288 efx_intr_disable(
289         __in            efx_nic_t *enp);
290
291 extern                  void
292 efx_intr_disable_unlocked(
293         __in            efx_nic_t *enp);
294
295 #define EFX_INTR_NEVQS  32
296
297 extern  __checkReturn   efx_rc_t
298 efx_intr_trigger(
299         __in            efx_nic_t *enp,
300         __in            unsigned int level);
301
302 extern                  void
303 efx_intr_status_line(
304         __in            efx_nic_t *enp,
305         __out           boolean_t *fatalp,
306         __out           uint32_t *maskp);
307
308 extern                  void
309 efx_intr_status_message(
310         __in            efx_nic_t *enp,
311         __in            unsigned int message,
312         __out           boolean_t *fatalp);
313
314 extern                  void
315 efx_intr_fatal(
316         __in            efx_nic_t *enp);
317
318 extern                  void
319 efx_intr_fini(
320         __in            efx_nic_t *enp);
321
322 /* MAC */
323
324 #if EFSYS_OPT_MAC_STATS
325
326 /* START MKCONFIG GENERATED EfxHeaderMacBlock e323546097fd7c65 */
327 typedef enum efx_mac_stat_e {
328         EFX_MAC_RX_OCTETS,
329         EFX_MAC_RX_PKTS,
330         EFX_MAC_RX_UNICST_PKTS,
331         EFX_MAC_RX_MULTICST_PKTS,
332         EFX_MAC_RX_BRDCST_PKTS,
333         EFX_MAC_RX_PAUSE_PKTS,
334         EFX_MAC_RX_LE_64_PKTS,
335         EFX_MAC_RX_65_TO_127_PKTS,
336         EFX_MAC_RX_128_TO_255_PKTS,
337         EFX_MAC_RX_256_TO_511_PKTS,
338         EFX_MAC_RX_512_TO_1023_PKTS,
339         EFX_MAC_RX_1024_TO_15XX_PKTS,
340         EFX_MAC_RX_GE_15XX_PKTS,
341         EFX_MAC_RX_ERRORS,
342         EFX_MAC_RX_FCS_ERRORS,
343         EFX_MAC_RX_DROP_EVENTS,
344         EFX_MAC_RX_FALSE_CARRIER_ERRORS,
345         EFX_MAC_RX_SYMBOL_ERRORS,
346         EFX_MAC_RX_ALIGN_ERRORS,
347         EFX_MAC_RX_INTERNAL_ERRORS,
348         EFX_MAC_RX_JABBER_PKTS,
349         EFX_MAC_RX_LANE0_CHAR_ERR,
350         EFX_MAC_RX_LANE1_CHAR_ERR,
351         EFX_MAC_RX_LANE2_CHAR_ERR,
352         EFX_MAC_RX_LANE3_CHAR_ERR,
353         EFX_MAC_RX_LANE0_DISP_ERR,
354         EFX_MAC_RX_LANE1_DISP_ERR,
355         EFX_MAC_RX_LANE2_DISP_ERR,
356         EFX_MAC_RX_LANE3_DISP_ERR,
357         EFX_MAC_RX_MATCH_FAULT,
358         EFX_MAC_RX_NODESC_DROP_CNT,
359         EFX_MAC_TX_OCTETS,
360         EFX_MAC_TX_PKTS,
361         EFX_MAC_TX_UNICST_PKTS,
362         EFX_MAC_TX_MULTICST_PKTS,
363         EFX_MAC_TX_BRDCST_PKTS,
364         EFX_MAC_TX_PAUSE_PKTS,
365         EFX_MAC_TX_LE_64_PKTS,
366         EFX_MAC_TX_65_TO_127_PKTS,
367         EFX_MAC_TX_128_TO_255_PKTS,
368         EFX_MAC_TX_256_TO_511_PKTS,
369         EFX_MAC_TX_512_TO_1023_PKTS,
370         EFX_MAC_TX_1024_TO_15XX_PKTS,
371         EFX_MAC_TX_GE_15XX_PKTS,
372         EFX_MAC_TX_ERRORS,
373         EFX_MAC_TX_SGL_COL_PKTS,
374         EFX_MAC_TX_MULT_COL_PKTS,
375         EFX_MAC_TX_EX_COL_PKTS,
376         EFX_MAC_TX_LATE_COL_PKTS,
377         EFX_MAC_TX_DEF_PKTS,
378         EFX_MAC_TX_EX_DEF_PKTS,
379         EFX_MAC_PM_TRUNC_BB_OVERFLOW,
380         EFX_MAC_PM_DISCARD_BB_OVERFLOW,
381         EFX_MAC_PM_TRUNC_VFIFO_FULL,
382         EFX_MAC_PM_DISCARD_VFIFO_FULL,
383         EFX_MAC_PM_TRUNC_QBB,
384         EFX_MAC_PM_DISCARD_QBB,
385         EFX_MAC_PM_DISCARD_MAPPING,
386         EFX_MAC_RXDP_Q_DISABLED_PKTS,
387         EFX_MAC_RXDP_DI_DROPPED_PKTS,
388         EFX_MAC_RXDP_STREAMING_PKTS,
389         EFX_MAC_RXDP_HLB_FETCH,
390         EFX_MAC_RXDP_HLB_WAIT,
391         EFX_MAC_VADAPTER_RX_UNICAST_PACKETS,
392         EFX_MAC_VADAPTER_RX_UNICAST_BYTES,
393         EFX_MAC_VADAPTER_RX_MULTICAST_PACKETS,
394         EFX_MAC_VADAPTER_RX_MULTICAST_BYTES,
395         EFX_MAC_VADAPTER_RX_BROADCAST_PACKETS,
396         EFX_MAC_VADAPTER_RX_BROADCAST_BYTES,
397         EFX_MAC_VADAPTER_RX_BAD_PACKETS,
398         EFX_MAC_VADAPTER_RX_BAD_BYTES,
399         EFX_MAC_VADAPTER_RX_OVERFLOW,
400         EFX_MAC_VADAPTER_TX_UNICAST_PACKETS,
401         EFX_MAC_VADAPTER_TX_UNICAST_BYTES,
402         EFX_MAC_VADAPTER_TX_MULTICAST_PACKETS,
403         EFX_MAC_VADAPTER_TX_MULTICAST_BYTES,
404         EFX_MAC_VADAPTER_TX_BROADCAST_PACKETS,
405         EFX_MAC_VADAPTER_TX_BROADCAST_BYTES,
406         EFX_MAC_VADAPTER_TX_BAD_PACKETS,
407         EFX_MAC_VADAPTER_TX_BAD_BYTES,
408         EFX_MAC_VADAPTER_TX_OVERFLOW,
409         EFX_MAC_NSTATS
410 } efx_mac_stat_t;
411
412 /* END MKCONFIG GENERATED EfxHeaderMacBlock */
413
414 #endif  /* EFSYS_OPT_MAC_STATS */
415
416 typedef enum efx_link_mode_e {
417         EFX_LINK_UNKNOWN = 0,
418         EFX_LINK_DOWN,
419         EFX_LINK_10HDX,
420         EFX_LINK_10FDX,
421         EFX_LINK_100HDX,
422         EFX_LINK_100FDX,
423         EFX_LINK_1000HDX,
424         EFX_LINK_1000FDX,
425         EFX_LINK_10000FDX,
426         EFX_LINK_40000FDX,
427         EFX_LINK_25000FDX,
428         EFX_LINK_50000FDX,
429         EFX_LINK_100000FDX,
430         EFX_LINK_NMODES
431 } efx_link_mode_t;
432
433 #define EFX_MAC_ADDR_LEN 6
434
435 #define EFX_MAC_ADDR_IS_MULTICAST(_address) (((uint8_t *)_address)[0] & 0x01)
436
437 #define EFX_MAC_MULTICAST_LIST_MAX      256
438
439 #define EFX_MAC_SDU_MAX 9202
440
441 #define EFX_MAC_PDU_ADJUSTMENT                                  \
442         (/* EtherII */ 14                                       \
443             + /* VLAN */ 4                                      \
444             + /* CRC */ 4                                       \
445             + /* bug16011 */ 16)                                \
446
447 #define EFX_MAC_PDU(_sdu)                                       \
448         P2ROUNDUP((_sdu) + EFX_MAC_PDU_ADJUSTMENT, 8)
449
450 /*
451  * Due to the P2ROUNDUP in EFX_MAC_PDU(), EFX_MAC_SDU_FROM_PDU() may give
452  * the SDU rounded up slightly.
453  */
454 #define EFX_MAC_SDU_FROM_PDU(_pdu)      ((_pdu) - EFX_MAC_PDU_ADJUSTMENT)
455
456 #define EFX_MAC_PDU_MIN 60
457 #define EFX_MAC_PDU_MAX EFX_MAC_PDU(EFX_MAC_SDU_MAX)
458
459 extern  __checkReturn   efx_rc_t
460 efx_mac_pdu_get(
461         __in            efx_nic_t *enp,
462         __out           size_t *pdu);
463
464 extern  __checkReturn   efx_rc_t
465 efx_mac_pdu_set(
466         __in            efx_nic_t *enp,
467         __in            size_t pdu);
468
469 extern  __checkReturn   efx_rc_t
470 efx_mac_addr_set(
471         __in            efx_nic_t *enp,
472         __in            uint8_t *addr);
473
474 extern  __checkReturn                   efx_rc_t
475 efx_mac_filter_set(
476         __in                            efx_nic_t *enp,
477         __in                            boolean_t all_unicst,
478         __in                            boolean_t mulcst,
479         __in                            boolean_t all_mulcst,
480         __in                            boolean_t brdcst);
481
482 extern  __checkReturn   efx_rc_t
483 efx_mac_multicast_list_set(
484         __in                            efx_nic_t *enp,
485         __in_ecount(6*count)            uint8_t const *addrs,
486         __in                            int count);
487
488 extern  __checkReturn   efx_rc_t
489 efx_mac_filter_default_rxq_set(
490         __in            efx_nic_t *enp,
491         __in            efx_rxq_t *erp,
492         __in            boolean_t using_rss);
493
494 extern                  void
495 efx_mac_filter_default_rxq_clear(
496         __in            efx_nic_t *enp);
497
498 extern  __checkReturn   efx_rc_t
499 efx_mac_drain(
500         __in            efx_nic_t *enp,
501         __in            boolean_t enabled);
502
503 extern  __checkReturn   efx_rc_t
504 efx_mac_up(
505         __in            efx_nic_t *enp,
506         __out           boolean_t *mac_upp);
507
508 #define EFX_FCNTL_RESPOND       0x00000001
509 #define EFX_FCNTL_GENERATE      0x00000002
510
511 extern  __checkReturn   efx_rc_t
512 efx_mac_fcntl_set(
513         __in            efx_nic_t *enp,
514         __in            unsigned int fcntl,
515         __in            boolean_t autoneg);
516
517 extern                  void
518 efx_mac_fcntl_get(
519         __in            efx_nic_t *enp,
520         __out           unsigned int *fcntl_wantedp,
521         __out           unsigned int *fcntl_linkp);
522
523
524 #if EFSYS_OPT_MAC_STATS
525
526 #if EFSYS_OPT_NAMES
527
528 extern  __checkReturn                   const char *
529 efx_mac_stat_name(
530         __in                            efx_nic_t *enp,
531         __in                            unsigned int id);
532
533 #endif  /* EFSYS_OPT_NAMES */
534
535 #define EFX_MAC_STATS_MASK_BITS_PER_PAGE        (8 * sizeof (uint32_t))
536
537 #define EFX_MAC_STATS_MASK_NPAGES       \
538         (P2ROUNDUP(EFX_MAC_NSTATS, EFX_MAC_STATS_MASK_BITS_PER_PAGE) / \
539             EFX_MAC_STATS_MASK_BITS_PER_PAGE)
540
541 /*
542  * Get mask of MAC statistics supported by the hardware.
543  *
544  * If mask_size is insufficient to return the mask, EINVAL error is
545  * returned. EFX_MAC_STATS_MASK_NPAGES multiplied by size of the page
546  * (which is sizeof (uint32_t)) is sufficient.
547  */
548 extern  __checkReturn                   efx_rc_t
549 efx_mac_stats_get_mask(
550         __in                            efx_nic_t *enp,
551         __out_bcount(mask_size)         uint32_t *maskp,
552         __in                            size_t mask_size);
553
554 #define EFX_MAC_STAT_SUPPORTED(_mask, _stat)    \
555         ((_mask)[(_stat) / EFX_MAC_STATS_MASK_BITS_PER_PAGE] &  \
556             (1ULL << ((_stat) & (EFX_MAC_STATS_MASK_BITS_PER_PAGE - 1))))
557
558 #define EFX_MAC_STATS_SIZE 0x400
559
560 extern  __checkReturn                   efx_rc_t
561 efx_mac_stats_clear(
562         __in                            efx_nic_t *enp);
563
564 /*
565  * Upload mac statistics supported by the hardware into the given buffer.
566  *
567  * The reference buffer must be at least %EFX_MAC_STATS_SIZE bytes,
568  * and page aligned.
569  *
570  * The hardware will only DMA statistics that it understands (of course).
571  * Drivers should not make any assumptions about which statistics are
572  * supported, especially when the statistics are generated by firmware.
573  *
574  * Thus, drivers should zero this buffer before use, so that not-understood
575  * statistics read back as zero.
576  */
577 extern  __checkReturn                   efx_rc_t
578 efx_mac_stats_upload(
579         __in                            efx_nic_t *enp,
580         __in                            efsys_mem_t *esmp);
581
582 extern  __checkReturn                   efx_rc_t
583 efx_mac_stats_periodic(
584         __in                            efx_nic_t *enp,
585         __in                            efsys_mem_t *esmp,
586         __in                            uint16_t period_ms,
587         __in                            boolean_t events);
588
589 extern  __checkReturn                   efx_rc_t
590 efx_mac_stats_update(
591         __in                            efx_nic_t *enp,
592         __in                            efsys_mem_t *esmp,
593         __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
594         __inout_opt                     uint32_t *generationp);
595
596 #endif  /* EFSYS_OPT_MAC_STATS */
597
598 /* MON */
599
600 typedef enum efx_mon_type_e {
601         EFX_MON_INVALID = 0,
602         EFX_MON_SFC90X0,
603         EFX_MON_SFC91X0,
604         EFX_MON_SFC92X0,
605         EFX_MON_NTYPES
606 } efx_mon_type_t;
607
608 #if EFSYS_OPT_NAMES
609
610 extern          const char *
611 efx_mon_name(
612         __in    efx_nic_t *enp);
613
614 #endif  /* EFSYS_OPT_NAMES */
615
616 extern  __checkReturn   efx_rc_t
617 efx_mon_init(
618         __in            efx_nic_t *enp);
619
620 #if EFSYS_OPT_MON_STATS
621
622 #define EFX_MON_STATS_PAGE_SIZE 0x100
623 #define EFX_MON_MASK_ELEMENT_SIZE 32
624
625 /* START MKCONFIG GENERATED MonitorHeaderStatsBlock fcc1b6748432e1ac */
626 typedef enum efx_mon_stat_e {
627         EFX_MON_STAT_2_5V,
628         EFX_MON_STAT_VCCP1,
629         EFX_MON_STAT_VCC,
630         EFX_MON_STAT_5V,
631         EFX_MON_STAT_12V,
632         EFX_MON_STAT_VCCP2,
633         EFX_MON_STAT_EXT_TEMP,
634         EFX_MON_STAT_INT_TEMP,
635         EFX_MON_STAT_AIN1,
636         EFX_MON_STAT_AIN2,
637         EFX_MON_STAT_INT_COOLING,
638         EFX_MON_STAT_EXT_COOLING,
639         EFX_MON_STAT_1V,
640         EFX_MON_STAT_1_2V,
641         EFX_MON_STAT_1_8V,
642         EFX_MON_STAT_3_3V,
643         EFX_MON_STAT_1_2VA,
644         EFX_MON_STAT_VREF,
645         EFX_MON_STAT_VAOE,
646         EFX_MON_STAT_AOE_TEMP,
647         EFX_MON_STAT_PSU_AOE_TEMP,
648         EFX_MON_STAT_PSU_TEMP,
649         EFX_MON_STAT_FAN0,
650         EFX_MON_STAT_FAN1,
651         EFX_MON_STAT_FAN2,
652         EFX_MON_STAT_FAN3,
653         EFX_MON_STAT_FAN4,
654         EFX_MON_STAT_VAOE_IN,
655         EFX_MON_STAT_IAOE,
656         EFX_MON_STAT_IAOE_IN,
657         EFX_MON_STAT_NIC_POWER,
658         EFX_MON_STAT_0_9V,
659         EFX_MON_STAT_I0_9V,
660         EFX_MON_STAT_I1_2V,
661         EFX_MON_STAT_0_9V_ADC,
662         EFX_MON_STAT_INT_TEMP2,
663         EFX_MON_STAT_VREG_TEMP,
664         EFX_MON_STAT_VREG_0_9V_TEMP,
665         EFX_MON_STAT_VREG_1_2V_TEMP,
666         EFX_MON_STAT_INT_VPTAT,
667         EFX_MON_STAT_INT_ADC_TEMP,
668         EFX_MON_STAT_EXT_VPTAT,
669         EFX_MON_STAT_EXT_ADC_TEMP,
670         EFX_MON_STAT_AMBIENT_TEMP,
671         EFX_MON_STAT_AIRFLOW,
672         EFX_MON_STAT_VDD08D_VSS08D_CSR,
673         EFX_MON_STAT_VDD08D_VSS08D_CSR_EXTADC,
674         EFX_MON_STAT_HOTPOINT_TEMP,
675         EFX_MON_STAT_PHY_POWER_SWITCH_PORT0,
676         EFX_MON_STAT_PHY_POWER_SWITCH_PORT1,
677         EFX_MON_STAT_MUM_VCC,
678         EFX_MON_STAT_0V9_A,
679         EFX_MON_STAT_I0V9_A,
680         EFX_MON_STAT_0V9_A_TEMP,
681         EFX_MON_STAT_0V9_B,
682         EFX_MON_STAT_I0V9_B,
683         EFX_MON_STAT_0V9_B_TEMP,
684         EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY,
685         EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY_EXT_ADC,
686         EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY,
687         EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY_EXT_ADC,
688         EFX_MON_STAT_CONTROLLER_MASTER_VPTAT,
689         EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP,
690         EFX_MON_STAT_CONTROLLER_MASTER_VPTAT_EXT_ADC,
691         EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP_EXT_ADC,
692         EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT,
693         EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP,
694         EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT_EXT_ADC,
695         EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP_EXT_ADC,
696         EFX_MON_STAT_SODIMM_VOUT,
697         EFX_MON_STAT_SODIMM_0_TEMP,
698         EFX_MON_STAT_SODIMM_1_TEMP,
699         EFX_MON_STAT_PHY0_VCC,
700         EFX_MON_STAT_PHY1_VCC,
701         EFX_MON_STAT_CONTROLLER_TDIODE_TEMP,
702         EFX_MON_STAT_BOARD_FRONT_TEMP,
703         EFX_MON_STAT_BOARD_BACK_TEMP,
704         EFX_MON_STAT_I1V8,
705         EFX_MON_STAT_I2V5,
706         EFX_MON_STAT_I3V3,
707         EFX_MON_STAT_I12V0,
708         EFX_MON_NSTATS
709 } efx_mon_stat_t;
710
711 /* END MKCONFIG GENERATED MonitorHeaderStatsBlock */
712
713 typedef enum efx_mon_stat_state_e {
714         EFX_MON_STAT_STATE_OK = 0,
715         EFX_MON_STAT_STATE_WARNING = 1,
716         EFX_MON_STAT_STATE_FATAL = 2,
717         EFX_MON_STAT_STATE_BROKEN = 3,
718         EFX_MON_STAT_STATE_NO_READING = 4,
719 } efx_mon_stat_state_t;
720
721 typedef struct efx_mon_stat_value_s {
722         uint16_t        emsv_value;
723         uint16_t        emsv_state;
724 } efx_mon_stat_value_t;
725
726 #if EFSYS_OPT_NAMES
727
728 extern                                  const char *
729 efx_mon_stat_name(
730         __in                            efx_nic_t *enp,
731         __in                            efx_mon_stat_t id);
732
733 #endif  /* EFSYS_OPT_NAMES */
734
735 extern  __checkReturn                   efx_rc_t
736 efx_mon_stats_update(
737         __in                            efx_nic_t *enp,
738         __in                            efsys_mem_t *esmp,
739         __inout_ecount(EFX_MON_NSTATS)  efx_mon_stat_value_t *values);
740
741 #endif  /* EFSYS_OPT_MON_STATS */
742
743 extern          void
744 efx_mon_fini(
745         __in    efx_nic_t *enp);
746
747 /* PHY */
748
749 extern  __checkReturn   efx_rc_t
750 efx_phy_verify(
751         __in            efx_nic_t *enp);
752
753 #if EFSYS_OPT_PHY_LED_CONTROL
754
755 typedef enum efx_phy_led_mode_e {
756         EFX_PHY_LED_DEFAULT = 0,
757         EFX_PHY_LED_OFF,
758         EFX_PHY_LED_ON,
759         EFX_PHY_LED_FLASH,
760         EFX_PHY_LED_NMODES
761 } efx_phy_led_mode_t;
762
763 extern  __checkReturn   efx_rc_t
764 efx_phy_led_set(
765         __in    efx_nic_t *enp,
766         __in    efx_phy_led_mode_t mode);
767
768 #endif  /* EFSYS_OPT_PHY_LED_CONTROL */
769
770 extern  __checkReturn   efx_rc_t
771 efx_port_init(
772         __in            efx_nic_t *enp);
773
774 #if EFSYS_OPT_LOOPBACK
775
776 typedef enum efx_loopback_type_e {
777         EFX_LOOPBACK_OFF = 0,
778         EFX_LOOPBACK_DATA = 1,
779         EFX_LOOPBACK_GMAC = 2,
780         EFX_LOOPBACK_XGMII = 3,
781         EFX_LOOPBACK_XGXS = 4,
782         EFX_LOOPBACK_XAUI = 5,
783         EFX_LOOPBACK_GMII = 6,
784         EFX_LOOPBACK_SGMII = 7,
785         EFX_LOOPBACK_XGBR = 8,
786         EFX_LOOPBACK_XFI = 9,
787         EFX_LOOPBACK_XAUI_FAR = 10,
788         EFX_LOOPBACK_GMII_FAR = 11,
789         EFX_LOOPBACK_SGMII_FAR = 12,
790         EFX_LOOPBACK_XFI_FAR = 13,
791         EFX_LOOPBACK_GPHY = 14,
792         EFX_LOOPBACK_PHY_XS = 15,
793         EFX_LOOPBACK_PCS = 16,
794         EFX_LOOPBACK_PMA_PMD = 17,
795         EFX_LOOPBACK_XPORT = 18,
796         EFX_LOOPBACK_XGMII_WS = 19,
797         EFX_LOOPBACK_XAUI_WS = 20,
798         EFX_LOOPBACK_XAUI_WS_FAR = 21,
799         EFX_LOOPBACK_XAUI_WS_NEAR = 22,
800         EFX_LOOPBACK_GMII_WS = 23,
801         EFX_LOOPBACK_XFI_WS = 24,
802         EFX_LOOPBACK_XFI_WS_FAR = 25,
803         EFX_LOOPBACK_PHYXS_WS = 26,
804         EFX_LOOPBACK_PMA_INT = 27,
805         EFX_LOOPBACK_SD_NEAR = 28,
806         EFX_LOOPBACK_SD_FAR = 29,
807         EFX_LOOPBACK_PMA_INT_WS = 30,
808         EFX_LOOPBACK_SD_FEP2_WS = 31,
809         EFX_LOOPBACK_SD_FEP1_5_WS = 32,
810         EFX_LOOPBACK_SD_FEP_WS = 33,
811         EFX_LOOPBACK_SD_FES_WS = 34,
812         EFX_LOOPBACK_AOE_INT_NEAR = 35,
813         EFX_LOOPBACK_DATA_WS = 36,
814         EFX_LOOPBACK_FORCE_EXT_LINK = 37,
815         EFX_LOOPBACK_NTYPES
816 } efx_loopback_type_t;
817
818 typedef enum efx_loopback_kind_e {
819         EFX_LOOPBACK_KIND_OFF = 0,
820         EFX_LOOPBACK_KIND_ALL,
821         EFX_LOOPBACK_KIND_MAC,
822         EFX_LOOPBACK_KIND_PHY,
823         EFX_LOOPBACK_NKINDS
824 } efx_loopback_kind_t;
825
826 extern                  void
827 efx_loopback_mask(
828         __in    efx_loopback_kind_t loopback_kind,
829         __out   efx_qword_t *maskp);
830
831 extern  __checkReturn   efx_rc_t
832 efx_port_loopback_set(
833         __in    efx_nic_t *enp,
834         __in    efx_link_mode_t link_mode,
835         __in    efx_loopback_type_t type);
836
837 #if EFSYS_OPT_NAMES
838
839 extern  __checkReturn   const char *
840 efx_loopback_type_name(
841         __in            efx_nic_t *enp,
842         __in            efx_loopback_type_t type);
843
844 #endif  /* EFSYS_OPT_NAMES */
845
846 #endif  /* EFSYS_OPT_LOOPBACK */
847
848 extern  __checkReturn   efx_rc_t
849 efx_port_poll(
850         __in            efx_nic_t *enp,
851         __out_opt       efx_link_mode_t *link_modep);
852
853 extern          void
854 efx_port_fini(
855         __in    efx_nic_t *enp);
856
857 typedef enum efx_phy_cap_type_e {
858         EFX_PHY_CAP_INVALID = 0,
859         EFX_PHY_CAP_10HDX,
860         EFX_PHY_CAP_10FDX,
861         EFX_PHY_CAP_100HDX,
862         EFX_PHY_CAP_100FDX,
863         EFX_PHY_CAP_1000HDX,
864         EFX_PHY_CAP_1000FDX,
865         EFX_PHY_CAP_10000FDX,
866         EFX_PHY_CAP_PAUSE,
867         EFX_PHY_CAP_ASYM,
868         EFX_PHY_CAP_AN,
869         EFX_PHY_CAP_40000FDX,
870         EFX_PHY_CAP_DDM,
871         EFX_PHY_CAP_100000FDX,
872         EFX_PHY_CAP_25000FDX,
873         EFX_PHY_CAP_50000FDX,
874         EFX_PHY_CAP_NTYPES
875 } efx_phy_cap_type_t;
876
877
878 #define EFX_PHY_CAP_CURRENT     0x00000000
879 #define EFX_PHY_CAP_DEFAULT     0x00000001
880 #define EFX_PHY_CAP_PERM        0x00000002
881
882 extern          void
883 efx_phy_adv_cap_get(
884         __in            efx_nic_t *enp,
885         __in            uint32_t flag,
886         __out           uint32_t *maskp);
887
888 extern  __checkReturn   efx_rc_t
889 efx_phy_adv_cap_set(
890         __in            efx_nic_t *enp,
891         __in            uint32_t mask);
892
893 extern                  void
894 efx_phy_lp_cap_get(
895         __in            efx_nic_t *enp,
896         __out           uint32_t *maskp);
897
898 extern  __checkReturn   efx_rc_t
899 efx_phy_oui_get(
900         __in            efx_nic_t *enp,
901         __out           uint32_t *ouip);
902
903 typedef enum efx_phy_media_type_e {
904         EFX_PHY_MEDIA_INVALID = 0,
905         EFX_PHY_MEDIA_XAUI,
906         EFX_PHY_MEDIA_CX4,
907         EFX_PHY_MEDIA_KX4,
908         EFX_PHY_MEDIA_XFP,
909         EFX_PHY_MEDIA_SFP_PLUS,
910         EFX_PHY_MEDIA_BASE_T,
911         EFX_PHY_MEDIA_QSFP_PLUS,
912         EFX_PHY_MEDIA_NTYPES
913 } efx_phy_media_type_t;
914
915 /*
916  * Get the type of medium currently used.  If the board has ports for
917  * modules, a module is present, and we recognise the media type of
918  * the module, then this will be the media type of the module.
919  * Otherwise it will be the media type of the port.
920  */
921 extern                  void
922 efx_phy_media_type_get(
923         __in            efx_nic_t *enp,
924         __out           efx_phy_media_type_t *typep);
925
926 extern  __checkReturn           efx_rc_t
927 efx_phy_module_get_info(
928         __in                    efx_nic_t *enp,
929         __in                    uint8_t dev_addr,
930         __in                    uint8_t offset,
931         __in                    uint8_t len,
932         __out_bcount(len)       uint8_t *data);
933
934 #if EFSYS_OPT_PHY_STATS
935
936 /* START MKCONFIG GENERATED PhyHeaderStatsBlock 30ed56ad501f8e36 */
937 typedef enum efx_phy_stat_e {
938         EFX_PHY_STAT_OUI,
939         EFX_PHY_STAT_PMA_PMD_LINK_UP,
940         EFX_PHY_STAT_PMA_PMD_RX_FAULT,
941         EFX_PHY_STAT_PMA_PMD_TX_FAULT,
942         EFX_PHY_STAT_PMA_PMD_REV_A,
943         EFX_PHY_STAT_PMA_PMD_REV_B,
944         EFX_PHY_STAT_PMA_PMD_REV_C,
945         EFX_PHY_STAT_PMA_PMD_REV_D,
946         EFX_PHY_STAT_PCS_LINK_UP,
947         EFX_PHY_STAT_PCS_RX_FAULT,
948         EFX_PHY_STAT_PCS_TX_FAULT,
949         EFX_PHY_STAT_PCS_BER,
950         EFX_PHY_STAT_PCS_BLOCK_ERRORS,
951         EFX_PHY_STAT_PHY_XS_LINK_UP,
952         EFX_PHY_STAT_PHY_XS_RX_FAULT,
953         EFX_PHY_STAT_PHY_XS_TX_FAULT,
954         EFX_PHY_STAT_PHY_XS_ALIGN,
955         EFX_PHY_STAT_PHY_XS_SYNC_A,
956         EFX_PHY_STAT_PHY_XS_SYNC_B,
957         EFX_PHY_STAT_PHY_XS_SYNC_C,
958         EFX_PHY_STAT_PHY_XS_SYNC_D,
959         EFX_PHY_STAT_AN_LINK_UP,
960         EFX_PHY_STAT_AN_MASTER,
961         EFX_PHY_STAT_AN_LOCAL_RX_OK,
962         EFX_PHY_STAT_AN_REMOTE_RX_OK,
963         EFX_PHY_STAT_CL22EXT_LINK_UP,
964         EFX_PHY_STAT_SNR_A,
965         EFX_PHY_STAT_SNR_B,
966         EFX_PHY_STAT_SNR_C,
967         EFX_PHY_STAT_SNR_D,
968         EFX_PHY_STAT_PMA_PMD_SIGNAL_A,
969         EFX_PHY_STAT_PMA_PMD_SIGNAL_B,
970         EFX_PHY_STAT_PMA_PMD_SIGNAL_C,
971         EFX_PHY_STAT_PMA_PMD_SIGNAL_D,
972         EFX_PHY_STAT_AN_COMPLETE,
973         EFX_PHY_STAT_PMA_PMD_REV_MAJOR,
974         EFX_PHY_STAT_PMA_PMD_REV_MINOR,
975         EFX_PHY_STAT_PMA_PMD_REV_MICRO,
976         EFX_PHY_STAT_PCS_FW_VERSION_0,
977         EFX_PHY_STAT_PCS_FW_VERSION_1,
978         EFX_PHY_STAT_PCS_FW_VERSION_2,
979         EFX_PHY_STAT_PCS_FW_VERSION_3,
980         EFX_PHY_STAT_PCS_FW_BUILD_YY,
981         EFX_PHY_STAT_PCS_FW_BUILD_MM,
982         EFX_PHY_STAT_PCS_FW_BUILD_DD,
983         EFX_PHY_STAT_PCS_OP_MODE,
984         EFX_PHY_NSTATS
985 } efx_phy_stat_t;
986
987 /* END MKCONFIG GENERATED PhyHeaderStatsBlock */
988
989 #if EFSYS_OPT_NAMES
990
991 extern                                  const char *
992 efx_phy_stat_name(
993         __in                            efx_nic_t *enp,
994         __in                            efx_phy_stat_t stat);
995
996 #endif  /* EFSYS_OPT_NAMES */
997
998 #define EFX_PHY_STATS_SIZE 0x100
999
1000 extern  __checkReturn                   efx_rc_t
1001 efx_phy_stats_update(
1002         __in                            efx_nic_t *enp,
1003         __in                            efsys_mem_t *esmp,
1004         __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
1005
1006 #endif  /* EFSYS_OPT_PHY_STATS */
1007
1008
1009 #if EFSYS_OPT_BIST
1010
1011 typedef enum efx_bist_type_e {
1012         EFX_BIST_TYPE_UNKNOWN,
1013         EFX_BIST_TYPE_PHY_NORMAL,
1014         EFX_BIST_TYPE_PHY_CABLE_SHORT,
1015         EFX_BIST_TYPE_PHY_CABLE_LONG,
1016         EFX_BIST_TYPE_MC_MEM,   /* Test the MC DMEM and IMEM */
1017         EFX_BIST_TYPE_SAT_MEM,  /* Test the DMEM and IMEM of satellite cpus */
1018         EFX_BIST_TYPE_REG,      /* Test the register memories */
1019         EFX_BIST_TYPE_NTYPES,
1020 } efx_bist_type_t;
1021
1022 typedef enum efx_bist_result_e {
1023         EFX_BIST_RESULT_UNKNOWN,
1024         EFX_BIST_RESULT_RUNNING,
1025         EFX_BIST_RESULT_PASSED,
1026         EFX_BIST_RESULT_FAILED,
1027 } efx_bist_result_t;
1028
1029 typedef enum efx_phy_cable_status_e {
1030         EFX_PHY_CABLE_STATUS_OK,
1031         EFX_PHY_CABLE_STATUS_INVALID,
1032         EFX_PHY_CABLE_STATUS_OPEN,
1033         EFX_PHY_CABLE_STATUS_INTRAPAIRSHORT,
1034         EFX_PHY_CABLE_STATUS_INTERPAIRSHORT,
1035         EFX_PHY_CABLE_STATUS_BUSY,
1036 } efx_phy_cable_status_t;
1037
1038 typedef enum efx_bist_value_e {
1039         EFX_BIST_PHY_CABLE_LENGTH_A,
1040         EFX_BIST_PHY_CABLE_LENGTH_B,
1041         EFX_BIST_PHY_CABLE_LENGTH_C,
1042         EFX_BIST_PHY_CABLE_LENGTH_D,
1043         EFX_BIST_PHY_CABLE_STATUS_A,
1044         EFX_BIST_PHY_CABLE_STATUS_B,
1045         EFX_BIST_PHY_CABLE_STATUS_C,
1046         EFX_BIST_PHY_CABLE_STATUS_D,
1047         EFX_BIST_FAULT_CODE,
1048         /*
1049          * Memory BIST specific values. These match to the MC_CMD_BIST_POLL
1050          * response.
1051          */
1052         EFX_BIST_MEM_TEST,
1053         EFX_BIST_MEM_ADDR,
1054         EFX_BIST_MEM_BUS,
1055         EFX_BIST_MEM_EXPECT,
1056         EFX_BIST_MEM_ACTUAL,
1057         EFX_BIST_MEM_ECC,
1058         EFX_BIST_MEM_ECC_PARITY,
1059         EFX_BIST_MEM_ECC_FATAL,
1060         EFX_BIST_NVALUES,
1061 } efx_bist_value_t;
1062
1063 extern  __checkReturn           efx_rc_t
1064 efx_bist_enable_offline(
1065         __in                    efx_nic_t *enp);
1066
1067 extern  __checkReturn           efx_rc_t
1068 efx_bist_start(
1069         __in                    efx_nic_t *enp,
1070         __in                    efx_bist_type_t type);
1071
1072 extern  __checkReturn           efx_rc_t
1073 efx_bist_poll(
1074         __in                    efx_nic_t *enp,
1075         __in                    efx_bist_type_t type,
1076         __out                   efx_bist_result_t *resultp,
1077         __out_opt               uint32_t *value_maskp,
1078         __out_ecount_opt(count) unsigned long *valuesp,
1079         __in                    size_t count);
1080
1081 extern                          void
1082 efx_bist_stop(
1083         __in                    efx_nic_t *enp,
1084         __in                    efx_bist_type_t type);
1085
1086 #endif  /* EFSYS_OPT_BIST */
1087
1088 #define EFX_FEATURE_IPV6                0x00000001
1089 #define EFX_FEATURE_LFSR_HASH_INSERT    0x00000002
1090 #define EFX_FEATURE_LINK_EVENTS         0x00000004
1091 #define EFX_FEATURE_PERIODIC_MAC_STATS  0x00000008
1092 #define EFX_FEATURE_MCDI                0x00000020
1093 #define EFX_FEATURE_LOOKAHEAD_SPLIT     0x00000040
1094 #define EFX_FEATURE_MAC_HEADER_FILTERS  0x00000080
1095 #define EFX_FEATURE_TURBO               0x00000100
1096 #define EFX_FEATURE_MCDI_DMA            0x00000200
1097 #define EFX_FEATURE_TX_SRC_FILTERS      0x00000400
1098 #define EFX_FEATURE_PIO_BUFFERS         0x00000800
1099 #define EFX_FEATURE_FW_ASSISTED_TSO     0x00001000
1100 #define EFX_FEATURE_FW_ASSISTED_TSO_V2  0x00002000
1101 #define EFX_FEATURE_PACKED_STREAM       0x00004000
1102
1103 typedef enum efx_tunnel_protocol_e {
1104         EFX_TUNNEL_PROTOCOL_NONE = 0,
1105         EFX_TUNNEL_PROTOCOL_VXLAN,
1106         EFX_TUNNEL_PROTOCOL_GENEVE,
1107         EFX_TUNNEL_PROTOCOL_NVGRE,
1108         EFX_TUNNEL_NPROTOS
1109 } efx_tunnel_protocol_t;
1110
1111 typedef enum efx_vi_window_shift_e {
1112         EFX_VI_WINDOW_SHIFT_INVALID = 0,
1113         EFX_VI_WINDOW_SHIFT_8K = 13,
1114         EFX_VI_WINDOW_SHIFT_16K = 14,
1115         EFX_VI_WINDOW_SHIFT_64K = 16,
1116 } efx_vi_window_shift_t;
1117
1118 typedef struct efx_nic_cfg_s {
1119         uint32_t                enc_board_type;
1120         uint32_t                enc_phy_type;
1121 #if EFSYS_OPT_NAMES
1122         char                    enc_phy_name[21];
1123 #endif
1124         char                    enc_phy_revision[21];
1125         efx_mon_type_t          enc_mon_type;
1126 #if EFSYS_OPT_MON_STATS
1127         uint32_t                enc_mon_stat_dma_buf_size;
1128         uint32_t                enc_mon_stat_mask[(EFX_MON_NSTATS + 31) / 32];
1129 #endif
1130         unsigned int            enc_features;
1131         efx_vi_window_shift_t   enc_vi_window_shift;
1132         uint8_t                 enc_mac_addr[6];
1133         uint8_t                 enc_port;       /* PHY port number */
1134         uint32_t                enc_intr_vec_base;
1135         uint32_t                enc_intr_limit;
1136         uint32_t                enc_evq_limit;
1137         uint32_t                enc_txq_limit;
1138         uint32_t                enc_rxq_limit;
1139         uint32_t                enc_txq_max_ndescs;
1140         uint32_t                enc_buftbl_limit;
1141         uint32_t                enc_piobuf_limit;
1142         uint32_t                enc_piobuf_size;
1143         uint32_t                enc_piobuf_min_alloc_size;
1144         uint32_t                enc_evq_timer_quantum_ns;
1145         uint32_t                enc_evq_timer_max_us;
1146         uint32_t                enc_clk_mult;
1147         uint32_t                enc_rx_prefix_size;
1148         uint32_t                enc_rx_buf_align_start;
1149         uint32_t                enc_rx_buf_align_end;
1150         uint32_t                enc_rx_scale_max_exclusive_contexts;
1151 #if EFSYS_OPT_LOOPBACK
1152         efx_qword_t             enc_loopback_types[EFX_LINK_NMODES];
1153 #endif  /* EFSYS_OPT_LOOPBACK */
1154 #if EFSYS_OPT_PHY_FLAGS
1155         uint32_t                enc_phy_flags_mask;
1156 #endif  /* EFSYS_OPT_PHY_FLAGS */
1157 #if EFSYS_OPT_PHY_LED_CONTROL
1158         uint32_t                enc_led_mask;
1159 #endif  /* EFSYS_OPT_PHY_LED_CONTROL */
1160 #if EFSYS_OPT_PHY_STATS
1161         uint64_t                enc_phy_stat_mask;
1162 #endif  /* EFSYS_OPT_PHY_STATS */
1163 #if EFSYS_OPT_MCDI
1164         uint8_t                 enc_mcdi_mdio_channel;
1165 #if EFSYS_OPT_PHY_STATS
1166         uint32_t                enc_mcdi_phy_stat_mask;
1167 #endif  /* EFSYS_OPT_PHY_STATS */
1168 #if EFSYS_OPT_MON_STATS
1169         uint32_t                *enc_mcdi_sensor_maskp;
1170         uint32_t                enc_mcdi_sensor_mask_size;
1171 #endif  /* EFSYS_OPT_MON_STATS */
1172 #endif  /* EFSYS_OPT_MCDI */
1173 #if EFSYS_OPT_BIST
1174         uint32_t                enc_bist_mask;
1175 #endif  /* EFSYS_OPT_BIST */
1176 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
1177         uint32_t                enc_pf;
1178         uint32_t                enc_vf;
1179         uint32_t                enc_privilege_mask;
1180 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
1181         boolean_t               enc_bug26807_workaround;
1182         boolean_t               enc_bug35388_workaround;
1183         boolean_t               enc_bug41750_workaround;
1184         boolean_t               enc_bug61265_workaround;
1185         boolean_t               enc_rx_batching_enabled;
1186         /* Maximum number of descriptors completed in an rx event. */
1187         uint32_t                enc_rx_batch_max;
1188         /* Number of rx descriptors the hardware requires for a push. */
1189         uint32_t                enc_rx_push_align;
1190         /* Maximum amount of data in DMA descriptor */
1191         uint32_t                enc_tx_dma_desc_size_max;
1192         /*
1193          * Boundary which DMA descriptor data must not cross or 0 if no
1194          * limitation.
1195          */
1196         uint32_t                enc_tx_dma_desc_boundary;
1197         /*
1198          * Maximum number of bytes into the packet the TCP header can start for
1199          * the hardware to apply TSO packet edits.
1200          */
1201         uint32_t                enc_tx_tso_tcp_header_offset_limit;
1202         boolean_t               enc_fw_assisted_tso_enabled;
1203         boolean_t               enc_fw_assisted_tso_v2_enabled;
1204         /* Number of TSO contexts on the NIC (FATSOv2) */
1205         uint32_t                enc_fw_assisted_tso_v2_n_contexts;
1206         boolean_t               enc_hw_tx_insert_vlan_enabled;
1207         /* Number of PFs on the NIC */
1208         uint32_t                enc_hw_pf_count;
1209         /* Datapath firmware vadapter/vport/vswitch support */
1210         boolean_t               enc_datapath_cap_evb;
1211         boolean_t               enc_rx_disable_scatter_supported;
1212         boolean_t               enc_allow_set_mac_with_installed_filters;
1213         boolean_t               enc_enhanced_set_mac_supported;
1214         boolean_t               enc_init_evq_v2_supported;
1215         boolean_t               enc_rx_packed_stream_supported;
1216         boolean_t               enc_rx_var_packed_stream_supported;
1217         boolean_t               enc_pm_and_rxdp_counters;
1218         boolean_t               enc_mac_stats_40g_tx_size_bins;
1219         uint32_t                enc_tunnel_encapsulations_supported;
1220         /*
1221          * NIC global maximum for unique UDP tunnel ports shared by all
1222          * functions.
1223          */
1224         uint32_t                enc_tunnel_config_udp_entries_max;
1225         /* External port identifier */
1226         uint8_t                 enc_external_port;
1227         uint32_t                enc_mcdi_max_payload_length;
1228         /* VPD may be per-PF or global */
1229         boolean_t               enc_vpd_is_global;
1230         /* Minimum unidirectional bandwidth in Mb/s to max out all ports */
1231         uint32_t                enc_required_pcie_bandwidth_mbps;
1232         uint32_t                enc_max_pcie_link_gen;
1233         /* Firmware verifies integrity of NVRAM updates */
1234         uint32_t                enc_nvram_update_verify_result_supported;
1235         /* Firmware support for extended MAC_STATS buffer */
1236         uint32_t                enc_mac_stats_nstats;
1237 } efx_nic_cfg_t;
1238
1239 #define EFX_PCI_FUNCTION_IS_PF(_encp)   ((_encp)->enc_vf == 0xffff)
1240 #define EFX_PCI_FUNCTION_IS_VF(_encp)   ((_encp)->enc_vf != 0xffff)
1241
1242 #define EFX_PCI_FUNCTION(_encp) \
1243         (EFX_PCI_FUNCTION_IS_PF(_encp) ? (_encp)->enc_pf : (_encp)->enc_vf)
1244
1245 #define EFX_PCI_VF_PARENT(_encp)        ((_encp)->enc_pf)
1246
1247 extern                  const efx_nic_cfg_t *
1248 efx_nic_cfg_get(
1249         __in            efx_nic_t *enp);
1250
1251 typedef struct efx_nic_fw_info_s {
1252         /* Basic FW version information */
1253         uint16_t        enfi_mc_fw_version[4];
1254         /*
1255          * If datapath capabilities can be detected,
1256          * additional FW information is to be shown
1257          */
1258         boolean_t       enfi_dpcpu_fw_ids_valid;
1259         /* Rx and Tx datapath CPU FW IDs */
1260         uint16_t        enfi_rx_dpcpu_fw_id;
1261         uint16_t        enfi_tx_dpcpu_fw_id;
1262 } efx_nic_fw_info_t;
1263
1264 extern  __checkReturn           efx_rc_t
1265 efx_nic_get_fw_version(
1266         __in                    efx_nic_t *enp,
1267         __out                   efx_nic_fw_info_t *enfip);
1268
1269 /* Driver resource limits (minimum required/maximum usable). */
1270 typedef struct efx_drv_limits_s {
1271         uint32_t        edl_min_evq_count;
1272         uint32_t        edl_max_evq_count;
1273
1274         uint32_t        edl_min_rxq_count;
1275         uint32_t        edl_max_rxq_count;
1276
1277         uint32_t        edl_min_txq_count;
1278         uint32_t        edl_max_txq_count;
1279
1280         /* PIO blocks (sub-allocated from piobuf) */
1281         uint32_t        edl_min_pio_alloc_size;
1282         uint32_t        edl_max_pio_alloc_count;
1283 } efx_drv_limits_t;
1284
1285 extern  __checkReturn   efx_rc_t
1286 efx_nic_set_drv_limits(
1287         __inout         efx_nic_t *enp,
1288         __in            efx_drv_limits_t *edlp);
1289
1290 typedef enum efx_nic_region_e {
1291         EFX_REGION_VI,                  /* Memory BAR UC mapping */
1292         EFX_REGION_PIO_WRITE_VI,        /* Memory BAR WC mapping */
1293 } efx_nic_region_t;
1294
1295 extern  __checkReturn   efx_rc_t
1296 efx_nic_get_bar_region(
1297         __in            efx_nic_t *enp,
1298         __in            efx_nic_region_t region,
1299         __out           uint32_t *offsetp,
1300         __out           size_t *sizep);
1301
1302 extern  __checkReturn   efx_rc_t
1303 efx_nic_get_vi_pool(
1304         __in            efx_nic_t *enp,
1305         __out           uint32_t *evq_countp,
1306         __out           uint32_t *rxq_countp,
1307         __out           uint32_t *txq_countp);
1308
1309
1310 #if EFSYS_OPT_VPD
1311
1312 typedef enum efx_vpd_tag_e {
1313         EFX_VPD_ID = 0x02,
1314         EFX_VPD_END = 0x0f,
1315         EFX_VPD_RO = 0x10,
1316         EFX_VPD_RW = 0x11,
1317 } efx_vpd_tag_t;
1318
1319 typedef uint16_t efx_vpd_keyword_t;
1320
1321 typedef struct efx_vpd_value_s {
1322         efx_vpd_tag_t           evv_tag;
1323         efx_vpd_keyword_t       evv_keyword;
1324         uint8_t                 evv_length;
1325         uint8_t                 evv_value[0x100];
1326 } efx_vpd_value_t;
1327
1328
1329 #define EFX_VPD_KEYWORD(x, y) ((x) | ((y) << 8))
1330
1331 extern  __checkReturn           efx_rc_t
1332 efx_vpd_init(
1333         __in                    efx_nic_t *enp);
1334
1335 extern  __checkReturn           efx_rc_t
1336 efx_vpd_size(
1337         __in                    efx_nic_t *enp,
1338         __out                   size_t *sizep);
1339
1340 extern  __checkReturn           efx_rc_t
1341 efx_vpd_read(
1342         __in                    efx_nic_t *enp,
1343         __out_bcount(size)      caddr_t data,
1344         __in                    size_t size);
1345
1346 extern  __checkReturn           efx_rc_t
1347 efx_vpd_verify(
1348         __in                    efx_nic_t *enp,
1349         __in_bcount(size)       caddr_t data,
1350         __in                    size_t size);
1351
1352 extern  __checkReturn           efx_rc_t
1353 efx_vpd_reinit(
1354         __in                    efx_nic_t *enp,
1355         __in_bcount(size)       caddr_t data,
1356         __in                    size_t size);
1357
1358 extern  __checkReturn           efx_rc_t
1359 efx_vpd_get(
1360         __in                    efx_nic_t *enp,
1361         __in_bcount(size)       caddr_t data,
1362         __in                    size_t size,
1363         __inout                 efx_vpd_value_t *evvp);
1364
1365 extern  __checkReturn           efx_rc_t
1366 efx_vpd_set(
1367         __in                    efx_nic_t *enp,
1368         __inout_bcount(size)    caddr_t data,
1369         __in                    size_t size,
1370         __in                    efx_vpd_value_t *evvp);
1371
1372 extern  __checkReturn           efx_rc_t
1373 efx_vpd_next(
1374         __in                    efx_nic_t *enp,
1375         __inout_bcount(size)    caddr_t data,
1376         __in                    size_t size,
1377         __out                   efx_vpd_value_t *evvp,
1378         __inout                 unsigned int *contp);
1379
1380 extern  __checkReturn           efx_rc_t
1381 efx_vpd_write(
1382         __in                    efx_nic_t *enp,
1383         __in_bcount(size)       caddr_t data,
1384         __in                    size_t size);
1385
1386 extern                          void
1387 efx_vpd_fini(
1388         __in                    efx_nic_t *enp);
1389
1390 #endif  /* EFSYS_OPT_VPD */
1391
1392 /* NVRAM */
1393
1394 #if EFSYS_OPT_NVRAM
1395
1396 typedef enum efx_nvram_type_e {
1397         EFX_NVRAM_INVALID = 0,
1398         EFX_NVRAM_BOOTROM,
1399         EFX_NVRAM_BOOTROM_CFG,
1400         EFX_NVRAM_MC_FIRMWARE,
1401         EFX_NVRAM_MC_GOLDEN,
1402         EFX_NVRAM_PHY,
1403         EFX_NVRAM_NULLPHY,
1404         EFX_NVRAM_FPGA,
1405         EFX_NVRAM_FCFW,
1406         EFX_NVRAM_CPLD,
1407         EFX_NVRAM_FPGA_BACKUP,
1408         EFX_NVRAM_DYNAMIC_CFG,
1409         EFX_NVRAM_LICENSE,
1410         EFX_NVRAM_UEFIROM,
1411         EFX_NVRAM_MUM_FIRMWARE,
1412         EFX_NVRAM_NTYPES,
1413 } efx_nvram_type_t;
1414
1415 extern  __checkReturn           efx_rc_t
1416 efx_nvram_init(
1417         __in                    efx_nic_t *enp);
1418
1419 #if EFSYS_OPT_DIAG
1420
1421 extern  __checkReturn           efx_rc_t
1422 efx_nvram_test(
1423         __in                    efx_nic_t *enp);
1424
1425 #endif  /* EFSYS_OPT_DIAG */
1426
1427 extern  __checkReturn           efx_rc_t
1428 efx_nvram_size(
1429         __in                    efx_nic_t *enp,
1430         __in                    efx_nvram_type_t type,
1431         __out                   size_t *sizep);
1432
1433 extern  __checkReturn           efx_rc_t
1434 efx_nvram_rw_start(
1435         __in                    efx_nic_t *enp,
1436         __in                    efx_nvram_type_t type,
1437         __out_opt               size_t *pref_chunkp);
1438
1439 extern  __checkReturn           efx_rc_t
1440 efx_nvram_rw_finish(
1441         __in                    efx_nic_t *enp,
1442         __in                    efx_nvram_type_t type,
1443         __out_opt               uint32_t *verify_resultp);
1444
1445 extern  __checkReturn           efx_rc_t
1446 efx_nvram_get_version(
1447         __in                    efx_nic_t *enp,
1448         __in                    efx_nvram_type_t type,
1449         __out                   uint32_t *subtypep,
1450         __out_ecount(4)         uint16_t version[4]);
1451
1452 extern  __checkReturn           efx_rc_t
1453 efx_nvram_read_chunk(
1454         __in                    efx_nic_t *enp,
1455         __in                    efx_nvram_type_t type,
1456         __in                    unsigned int offset,
1457         __out_bcount(size)      caddr_t data,
1458         __in                    size_t size);
1459
1460 extern  __checkReturn           efx_rc_t
1461 efx_nvram_read_backup(
1462         __in                    efx_nic_t *enp,
1463         __in                    efx_nvram_type_t type,
1464         __in                    unsigned int offset,
1465         __out_bcount(size)      caddr_t data,
1466         __in                    size_t size);
1467
1468 extern  __checkReturn           efx_rc_t
1469 efx_nvram_set_version(
1470         __in                    efx_nic_t *enp,
1471         __in                    efx_nvram_type_t type,
1472         __in_ecount(4)          uint16_t version[4]);
1473
1474 extern  __checkReturn           efx_rc_t
1475 efx_nvram_validate(
1476         __in                    efx_nic_t *enp,
1477         __in                    efx_nvram_type_t type,
1478         __in_bcount(partn_size) caddr_t partn_data,
1479         __in                    size_t partn_size);
1480
1481 extern   __checkReturn          efx_rc_t
1482 efx_nvram_erase(
1483         __in                    efx_nic_t *enp,
1484         __in                    efx_nvram_type_t type);
1485
1486 extern  __checkReturn           efx_rc_t
1487 efx_nvram_write_chunk(
1488         __in                    efx_nic_t *enp,
1489         __in                    efx_nvram_type_t type,
1490         __in                    unsigned int offset,
1491         __in_bcount(size)       caddr_t data,
1492         __in                    size_t size);
1493
1494 extern                          void
1495 efx_nvram_fini(
1496         __in                    efx_nic_t *enp);
1497
1498 #endif  /* EFSYS_OPT_NVRAM */
1499
1500 #if EFSYS_OPT_BOOTCFG
1501
1502 /* Report size and offset of bootcfg sector in NVRAM partition. */
1503 extern  __checkReturn           efx_rc_t
1504 efx_bootcfg_sector_info(
1505         __in                    efx_nic_t *enp,
1506         __in                    uint32_t pf,
1507         __out_opt               uint32_t *sector_countp,
1508         __out                   size_t *offsetp,
1509         __out                   size_t *max_sizep);
1510
1511 /*
1512  * Copy bootcfg sector data to a target buffer which may differ in size.
1513  * Optionally corrects format errors in source buffer.
1514  */
1515 extern                          efx_rc_t
1516 efx_bootcfg_copy_sector(
1517         __in                    efx_nic_t *enp,
1518         __inout_bcount(sector_length)
1519                                 uint8_t *sector,
1520         __in                    size_t sector_length,
1521         __out_bcount(data_size) uint8_t *data,
1522         __in                    size_t data_size,
1523         __in                    boolean_t handle_format_errors);
1524
1525 extern                          efx_rc_t
1526 efx_bootcfg_read(
1527         __in                    efx_nic_t *enp,
1528         __out_bcount(size)      uint8_t *data,
1529         __in                    size_t size);
1530
1531 extern                          efx_rc_t
1532 efx_bootcfg_write(
1533         __in                    efx_nic_t *enp,
1534         __in_bcount(size)       uint8_t *data,
1535         __in                    size_t size);
1536
1537 #endif  /* EFSYS_OPT_BOOTCFG */
1538
1539 #if EFSYS_OPT_DIAG
1540
1541 typedef enum efx_pattern_type_t {
1542         EFX_PATTERN_BYTE_INCREMENT = 0,
1543         EFX_PATTERN_ALL_THE_SAME,
1544         EFX_PATTERN_BIT_ALTERNATE,
1545         EFX_PATTERN_BYTE_ALTERNATE,
1546         EFX_PATTERN_BYTE_CHANGING,
1547         EFX_PATTERN_BIT_SWEEP,
1548         EFX_PATTERN_NTYPES
1549 } efx_pattern_type_t;
1550
1551 typedef                 void
1552 (*efx_sram_pattern_fn_t)(
1553         __in            size_t row,
1554         __in            boolean_t negate,
1555         __out           efx_qword_t *eqp);
1556
1557 extern  __checkReturn   efx_rc_t
1558 efx_sram_test(
1559         __in            efx_nic_t *enp,
1560         __in            efx_pattern_type_t type);
1561
1562 #endif  /* EFSYS_OPT_DIAG */
1563
1564 extern  __checkReturn   efx_rc_t
1565 efx_sram_buf_tbl_set(
1566         __in            efx_nic_t *enp,
1567         __in            uint32_t id,
1568         __in            efsys_mem_t *esmp,
1569         __in            size_t n);
1570
1571 extern          void
1572 efx_sram_buf_tbl_clear(
1573         __in    efx_nic_t *enp,
1574         __in    uint32_t id,
1575         __in    size_t n);
1576
1577 #define EFX_BUF_TBL_SIZE        0x20000
1578
1579 #define EFX_BUF_SIZE            4096
1580
1581 /* EV */
1582
1583 typedef struct efx_evq_s        efx_evq_t;
1584
1585 #if EFSYS_OPT_QSTATS
1586
1587 /* START MKCONFIG GENERATED EfxHeaderEventQueueBlock 6f3843f5fe7cc843 */
1588 typedef enum efx_ev_qstat_e {
1589         EV_ALL,
1590         EV_RX,
1591         EV_RX_OK,
1592         EV_RX_FRM_TRUNC,
1593         EV_RX_TOBE_DISC,
1594         EV_RX_PAUSE_FRM_ERR,
1595         EV_RX_BUF_OWNER_ID_ERR,
1596         EV_RX_IPV4_HDR_CHKSUM_ERR,
1597         EV_RX_TCP_UDP_CHKSUM_ERR,
1598         EV_RX_ETH_CRC_ERR,
1599         EV_RX_IP_FRAG_ERR,
1600         EV_RX_MCAST_PKT,
1601         EV_RX_MCAST_HASH_MATCH,
1602         EV_RX_TCP_IPV4,
1603         EV_RX_TCP_IPV6,
1604         EV_RX_UDP_IPV4,
1605         EV_RX_UDP_IPV6,
1606         EV_RX_OTHER_IPV4,
1607         EV_RX_OTHER_IPV6,
1608         EV_RX_NON_IP,
1609         EV_RX_BATCH,
1610         EV_TX,
1611         EV_TX_WQ_FF_FULL,
1612         EV_TX_PKT_ERR,
1613         EV_TX_PKT_TOO_BIG,
1614         EV_TX_UNEXPECTED,
1615         EV_GLOBAL,
1616         EV_GLOBAL_MNT,
1617         EV_DRIVER,
1618         EV_DRIVER_SRM_UPD_DONE,
1619         EV_DRIVER_TX_DESCQ_FLS_DONE,
1620         EV_DRIVER_RX_DESCQ_FLS_DONE,
1621         EV_DRIVER_RX_DESCQ_FLS_FAILED,
1622         EV_DRIVER_RX_DSC_ERROR,
1623         EV_DRIVER_TX_DSC_ERROR,
1624         EV_DRV_GEN,
1625         EV_MCDI_RESPONSE,
1626         EV_NQSTATS
1627 } efx_ev_qstat_t;
1628
1629 /* END MKCONFIG GENERATED EfxHeaderEventQueueBlock */
1630
1631 #endif  /* EFSYS_OPT_QSTATS */
1632
1633 extern  __checkReturn   efx_rc_t
1634 efx_ev_init(
1635         __in            efx_nic_t *enp);
1636
1637 extern          void
1638 efx_ev_fini(
1639         __in            efx_nic_t *enp);
1640
1641 #define EFX_EVQ_MAXNEVS         32768
1642 #define EFX_EVQ_MINNEVS         512
1643
1644 #define EFX_EVQ_SIZE(_nevs)     ((_nevs) * sizeof (efx_qword_t))
1645 #define EFX_EVQ_NBUFS(_nevs)    (EFX_EVQ_SIZE(_nevs) / EFX_BUF_SIZE)
1646
1647 #define EFX_EVQ_FLAGS_TYPE_MASK         (0x3)
1648 #define EFX_EVQ_FLAGS_TYPE_AUTO         (0x0)
1649 #define EFX_EVQ_FLAGS_TYPE_THROUGHPUT   (0x1)
1650 #define EFX_EVQ_FLAGS_TYPE_LOW_LATENCY  (0x2)
1651
1652 #define EFX_EVQ_FLAGS_NOTIFY_MASK       (0xC)
1653 #define EFX_EVQ_FLAGS_NOTIFY_INTERRUPT  (0x0)   /* Interrupting (default) */
1654 #define EFX_EVQ_FLAGS_NOTIFY_DISABLED   (0x4)   /* Non-interrupting */
1655
1656 extern  __checkReturn   efx_rc_t
1657 efx_ev_qcreate(
1658         __in            efx_nic_t *enp,
1659         __in            unsigned int index,
1660         __in            efsys_mem_t *esmp,
1661         __in            size_t ndescs,
1662         __in            uint32_t id,
1663         __in            uint32_t us,
1664         __in            uint32_t flags,
1665         __deref_out     efx_evq_t **eepp);
1666
1667 extern          void
1668 efx_ev_qpost(
1669         __in            efx_evq_t *eep,
1670         __in            uint16_t data);
1671
1672 typedef __checkReturn   boolean_t
1673 (*efx_initialized_ev_t)(
1674         __in_opt        void *arg);
1675
1676 #define EFX_PKT_UNICAST         0x0004
1677 #define EFX_PKT_START           0x0008
1678
1679 #define EFX_PKT_VLAN_TAGGED     0x0010
1680 #define EFX_CKSUM_TCPUDP        0x0020
1681 #define EFX_CKSUM_IPV4          0x0040
1682 #define EFX_PKT_CONT            0x0080
1683
1684 #define EFX_CHECK_VLAN          0x0100
1685 #define EFX_PKT_TCP             0x0200
1686 #define EFX_PKT_UDP             0x0400
1687 #define EFX_PKT_IPV4            0x0800
1688
1689 #define EFX_PKT_IPV6            0x1000
1690 #define EFX_PKT_PREFIX_LEN      0x2000
1691 #define EFX_ADDR_MISMATCH       0x4000
1692 #define EFX_DISCARD             0x8000
1693
1694 /*
1695  * The following flags are used only for packed stream
1696  * mode. The values for the flags are reused to fit into 16 bit,
1697  * since EFX_PKT_START and EFX_PKT_CONT are never used in
1698  * packed stream mode
1699  */
1700 #define EFX_PKT_PACKED_STREAM_NEW_BUFFER        EFX_PKT_START
1701 #define EFX_PKT_PACKED_STREAM_PARSE_INCOMPLETE  EFX_PKT_CONT
1702
1703
1704 #define EFX_EV_RX_NLABELS       32
1705 #define EFX_EV_TX_NLABELS       32
1706
1707 typedef __checkReturn   boolean_t
1708 (*efx_rx_ev_t)(
1709         __in_opt        void *arg,
1710         __in            uint32_t label,
1711         __in            uint32_t id,
1712         __in            uint32_t size,
1713         __in            uint16_t flags);
1714
1715 #if EFSYS_OPT_RX_PACKED_STREAM
1716
1717 /*
1718  * Packed stream mode is documented in SF-112241-TC.
1719  * The general idea is that, instead of putting each incoming
1720  * packet into a separate buffer which is specified in a RX
1721  * descriptor, a large buffer is provided to the hardware and
1722  * packets are put there in a continuous stream.
1723  * The main advantage of such an approach is that RX queue refilling
1724  * happens much less frequently.
1725  */
1726
1727 typedef __checkReturn   boolean_t
1728 (*efx_rx_ps_ev_t)(
1729         __in_opt        void *arg,
1730         __in            uint32_t label,
1731         __in            uint32_t id,
1732         __in            uint32_t pkt_count,
1733         __in            uint16_t flags);
1734
1735 #endif
1736
1737 typedef __checkReturn   boolean_t
1738 (*efx_tx_ev_t)(
1739         __in_opt        void *arg,
1740         __in            uint32_t label,
1741         __in            uint32_t id);
1742
1743 #define EFX_EXCEPTION_RX_RECOVERY       0x00000001
1744 #define EFX_EXCEPTION_RX_DSC_ERROR      0x00000002
1745 #define EFX_EXCEPTION_TX_DSC_ERROR      0x00000003
1746 #define EFX_EXCEPTION_UNKNOWN_SENSOREVT 0x00000004
1747 #define EFX_EXCEPTION_FWALERT_SRAM      0x00000005
1748 #define EFX_EXCEPTION_UNKNOWN_FWALERT   0x00000006
1749 #define EFX_EXCEPTION_RX_ERROR          0x00000007
1750 #define EFX_EXCEPTION_TX_ERROR          0x00000008
1751 #define EFX_EXCEPTION_EV_ERROR          0x00000009
1752
1753 typedef __checkReturn   boolean_t
1754 (*efx_exception_ev_t)(
1755         __in_opt        void *arg,
1756         __in            uint32_t label,
1757         __in            uint32_t data);
1758
1759 typedef __checkReturn   boolean_t
1760 (*efx_rxq_flush_done_ev_t)(
1761         __in_opt        void *arg,
1762         __in            uint32_t rxq_index);
1763
1764 typedef __checkReturn   boolean_t
1765 (*efx_rxq_flush_failed_ev_t)(
1766         __in_opt        void *arg,
1767         __in            uint32_t rxq_index);
1768
1769 typedef __checkReturn   boolean_t
1770 (*efx_txq_flush_done_ev_t)(
1771         __in_opt        void *arg,
1772         __in            uint32_t txq_index);
1773
1774 typedef __checkReturn   boolean_t
1775 (*efx_software_ev_t)(
1776         __in_opt        void *arg,
1777         __in            uint16_t magic);
1778
1779 typedef __checkReturn   boolean_t
1780 (*efx_sram_ev_t)(
1781         __in_opt        void *arg,
1782         __in            uint32_t code);
1783
1784 #define EFX_SRAM_CLEAR          0
1785 #define EFX_SRAM_UPDATE         1
1786 #define EFX_SRAM_ILLEGAL_CLEAR  2
1787
1788 typedef __checkReturn   boolean_t
1789 (*efx_wake_up_ev_t)(
1790         __in_opt        void *arg,
1791         __in            uint32_t label);
1792
1793 typedef __checkReturn   boolean_t
1794 (*efx_timer_ev_t)(
1795         __in_opt        void *arg,
1796         __in            uint32_t label);
1797
1798 typedef __checkReturn   boolean_t
1799 (*efx_link_change_ev_t)(
1800         __in_opt        void *arg,
1801         __in            efx_link_mode_t link_mode);
1802
1803 #if EFSYS_OPT_MON_STATS
1804
1805 typedef __checkReturn   boolean_t
1806 (*efx_monitor_ev_t)(
1807         __in_opt        void *arg,
1808         __in            efx_mon_stat_t id,
1809         __in            efx_mon_stat_value_t value);
1810
1811 #endif  /* EFSYS_OPT_MON_STATS */
1812
1813 #if EFSYS_OPT_MAC_STATS
1814
1815 typedef __checkReturn   boolean_t
1816 (*efx_mac_stats_ev_t)(
1817         __in_opt        void *arg,
1818         __in            uint32_t generation);
1819
1820 #endif  /* EFSYS_OPT_MAC_STATS */
1821
1822 typedef struct efx_ev_callbacks_s {
1823         efx_initialized_ev_t            eec_initialized;
1824         efx_rx_ev_t                     eec_rx;
1825 #if EFSYS_OPT_RX_PACKED_STREAM
1826         efx_rx_ps_ev_t                  eec_rx_ps;
1827 #endif
1828         efx_tx_ev_t                     eec_tx;
1829         efx_exception_ev_t              eec_exception;
1830         efx_rxq_flush_done_ev_t         eec_rxq_flush_done;
1831         efx_rxq_flush_failed_ev_t       eec_rxq_flush_failed;
1832         efx_txq_flush_done_ev_t         eec_txq_flush_done;
1833         efx_software_ev_t               eec_software;
1834         efx_sram_ev_t                   eec_sram;
1835         efx_wake_up_ev_t                eec_wake_up;
1836         efx_timer_ev_t                  eec_timer;
1837         efx_link_change_ev_t            eec_link_change;
1838 #if EFSYS_OPT_MON_STATS
1839         efx_monitor_ev_t                eec_monitor;
1840 #endif  /* EFSYS_OPT_MON_STATS */
1841 #if EFSYS_OPT_MAC_STATS
1842         efx_mac_stats_ev_t              eec_mac_stats;
1843 #endif  /* EFSYS_OPT_MAC_STATS */
1844 } efx_ev_callbacks_t;
1845
1846 extern  __checkReturn   boolean_t
1847 efx_ev_qpending(
1848         __in            efx_evq_t *eep,
1849         __in            unsigned int count);
1850
1851 #if EFSYS_OPT_EV_PREFETCH
1852
1853 extern                  void
1854 efx_ev_qprefetch(
1855         __in            efx_evq_t *eep,
1856         __in            unsigned int count);
1857
1858 #endif  /* EFSYS_OPT_EV_PREFETCH */
1859
1860 extern                  void
1861 efx_ev_qpoll(
1862         __in            efx_evq_t *eep,
1863         __inout         unsigned int *countp,
1864         __in            const efx_ev_callbacks_t *eecp,
1865         __in_opt        void *arg);
1866
1867 extern  __checkReturn   efx_rc_t
1868 efx_ev_usecs_to_ticks(
1869         __in            efx_nic_t *enp,
1870         __in            unsigned int usecs,
1871         __out           unsigned int *ticksp);
1872
1873 extern  __checkReturn   efx_rc_t
1874 efx_ev_qmoderate(
1875         __in            efx_evq_t *eep,
1876         __in            unsigned int us);
1877
1878 extern  __checkReturn   efx_rc_t
1879 efx_ev_qprime(
1880         __in            efx_evq_t *eep,
1881         __in            unsigned int count);
1882
1883 #if EFSYS_OPT_QSTATS
1884
1885 #if EFSYS_OPT_NAMES
1886
1887 extern          const char *
1888 efx_ev_qstat_name(
1889         __in    efx_nic_t *enp,
1890         __in    unsigned int id);
1891
1892 #endif  /* EFSYS_OPT_NAMES */
1893
1894 extern                                  void
1895 efx_ev_qstats_update(
1896         __in                            efx_evq_t *eep,
1897         __inout_ecount(EV_NQSTATS)      efsys_stat_t *stat);
1898
1899 #endif  /* EFSYS_OPT_QSTATS */
1900
1901 extern          void
1902 efx_ev_qdestroy(
1903         __in    efx_evq_t *eep);
1904
1905 /* RX */
1906
1907 extern  __checkReturn   efx_rc_t
1908 efx_rx_init(
1909         __inout         efx_nic_t *enp);
1910
1911 extern          void
1912 efx_rx_fini(
1913         __in            efx_nic_t *enp);
1914
1915 #if EFSYS_OPT_RX_SCATTER
1916         __checkReturn   efx_rc_t
1917 efx_rx_scatter_enable(
1918         __in            efx_nic_t *enp,
1919         __in            unsigned int buf_size);
1920 #endif  /* EFSYS_OPT_RX_SCATTER */
1921
1922 /* Handle to represent use of the default RSS context. */
1923 #define EFX_RSS_CONTEXT_DEFAULT 0xffffffff
1924
1925 #if EFSYS_OPT_RX_SCALE
1926
1927 typedef enum efx_rx_hash_alg_e {
1928         EFX_RX_HASHALG_LFSR = 0,
1929         EFX_RX_HASHALG_TOEPLITZ
1930 } efx_rx_hash_alg_t;
1931
1932 #define EFX_RX_HASH_IPV4        (1U << 0)
1933 #define EFX_RX_HASH_TCPIPV4     (1U << 1)
1934 #define EFX_RX_HASH_IPV6        (1U << 2)
1935 #define EFX_RX_HASH_TCPIPV6     (1U << 3)
1936
1937 typedef unsigned int efx_rx_hash_type_t;
1938
1939 typedef enum efx_rx_hash_support_e {
1940         EFX_RX_HASH_UNAVAILABLE = 0,    /* Hardware hash not inserted */
1941         EFX_RX_HASH_AVAILABLE           /* Insert hash with/without RSS */
1942 } efx_rx_hash_support_t;
1943
1944 #define EFX_RSS_KEY_SIZE        40      /* RSS key size (bytes) */
1945 #define EFX_RSS_TBL_SIZE        128     /* Rows in RX indirection table */
1946 #define EFX_MAXRSS              64      /* RX indirection entry range */
1947 #define EFX_MAXRSS_LEGACY       16      /* See bug16611 and bug17213 */
1948
1949 typedef enum efx_rx_scale_context_type_e {
1950         EFX_RX_SCALE_UNAVAILABLE = 0,   /* No RX scale context */
1951         EFX_RX_SCALE_EXCLUSIVE,         /* Writable key/indirection table */
1952         EFX_RX_SCALE_SHARED             /* Read-only key/indirection table */
1953 } efx_rx_scale_context_type_t;
1954
1955 extern  __checkReturn   efx_rc_t
1956 efx_rx_hash_default_support_get(
1957         __in            efx_nic_t *enp,
1958         __out           efx_rx_hash_support_t *supportp);
1959
1960
1961 extern  __checkReturn   efx_rc_t
1962 efx_rx_scale_default_support_get(
1963         __in            efx_nic_t *enp,
1964         __out           efx_rx_scale_context_type_t *typep);
1965
1966 extern  __checkReturn   efx_rc_t
1967 efx_rx_scale_context_alloc(
1968         __in            efx_nic_t *enp,
1969         __in            efx_rx_scale_context_type_t type,
1970         __in            uint32_t num_queues,
1971         __out           uint32_t *rss_contextp);
1972
1973 extern  __checkReturn   efx_rc_t
1974 efx_rx_scale_context_free(
1975         __in            efx_nic_t *enp,
1976         __in            uint32_t rss_context);
1977
1978 extern  __checkReturn   efx_rc_t
1979 efx_rx_scale_mode_set(
1980         __in    efx_nic_t *enp,
1981         __in    uint32_t rss_context,
1982         __in    efx_rx_hash_alg_t alg,
1983         __in    efx_rx_hash_type_t type,
1984         __in    boolean_t insert);
1985
1986 extern  __checkReturn   efx_rc_t
1987 efx_rx_scale_tbl_set(
1988         __in            efx_nic_t *enp,
1989         __in            uint32_t rss_context,
1990         __in_ecount(n)  unsigned int *table,
1991         __in            size_t n);
1992
1993 extern  __checkReturn   efx_rc_t
1994 efx_rx_scale_key_set(
1995         __in            efx_nic_t *enp,
1996         __in            uint32_t rss_context,
1997         __in_ecount(n)  uint8_t *key,
1998         __in            size_t n);
1999
2000 extern  __checkReturn   uint32_t
2001 efx_pseudo_hdr_hash_get(
2002         __in            efx_rxq_t *erp,
2003         __in            efx_rx_hash_alg_t func,
2004         __in            uint8_t *buffer);
2005
2006 #endif  /* EFSYS_OPT_RX_SCALE */
2007
2008 extern  __checkReturn   efx_rc_t
2009 efx_pseudo_hdr_pkt_length_get(
2010         __in            efx_rxq_t *erp,
2011         __in            uint8_t *buffer,
2012         __out           uint16_t *pkt_lengthp);
2013
2014 #define EFX_RXQ_MAXNDESCS               4096
2015 #define EFX_RXQ_MINNDESCS               512
2016
2017 #define EFX_RXQ_SIZE(_ndescs)           ((_ndescs) * sizeof (efx_qword_t))
2018 #define EFX_RXQ_NBUFS(_ndescs)          (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
2019 #define EFX_RXQ_LIMIT(_ndescs)          ((_ndescs) - 16)
2020 #define EFX_RXQ_DC_NDESCS(_dcsize)      (8 << _dcsize)
2021
2022 typedef enum efx_rxq_type_e {
2023         EFX_RXQ_TYPE_DEFAULT,
2024         EFX_RXQ_TYPE_PACKED_STREAM,
2025         EFX_RXQ_NTYPES
2026 } efx_rxq_type_t;
2027
2028 /*
2029  * Dummy flag to be used instead of 0 to make it clear that the argument
2030  * is receive queue flags.
2031  */
2032 #define EFX_RXQ_FLAG_NONE               0x0
2033 #define EFX_RXQ_FLAG_SCATTER            0x1
2034 /*
2035  * If tunnels are supported and Rx event can provide information about
2036  * either outer or inner packet classes (e.g. SFN8xxx adapters with
2037  * full-feature firmware variant running), outer classes are requested by
2038  * default. However, if the driver supports tunnels, the flag allows to
2039  * request inner classes which are required to be able to interpret inner
2040  * Rx checksum offload results.
2041  */
2042 #define EFX_RXQ_FLAG_INNER_CLASSES      0x2
2043
2044 extern  __checkReturn   efx_rc_t
2045 efx_rx_qcreate(
2046         __in            efx_nic_t *enp,
2047         __in            unsigned int index,
2048         __in            unsigned int label,
2049         __in            efx_rxq_type_t type,
2050         __in            efsys_mem_t *esmp,
2051         __in            size_t ndescs,
2052         __in            uint32_t id,
2053         __in            unsigned int flags,
2054         __in            efx_evq_t *eep,
2055         __deref_out     efx_rxq_t **erpp);
2056
2057 #if EFSYS_OPT_RX_PACKED_STREAM
2058
2059 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_1M       (1U * 1024 * 1024)
2060 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_512K     (512U * 1024)
2061 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_256K     (256U * 1024)
2062 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_128K     (128U * 1024)
2063 #define EFX_RXQ_PACKED_STREAM_BUF_SIZE_64K      (64U * 1024)
2064
2065 extern  __checkReturn   efx_rc_t
2066 efx_rx_qcreate_packed_stream(
2067         __in            efx_nic_t *enp,
2068         __in            unsigned int index,
2069         __in            unsigned int label,
2070         __in            uint32_t ps_buf_size,
2071         __in            efsys_mem_t *esmp,
2072         __in            size_t ndescs,
2073         __in            efx_evq_t *eep,
2074         __deref_out     efx_rxq_t **erpp);
2075
2076 #endif
2077
2078 typedef struct efx_buffer_s {
2079         efsys_dma_addr_t        eb_addr;
2080         size_t                  eb_size;
2081         boolean_t               eb_eop;
2082 } efx_buffer_t;
2083
2084 typedef struct efx_desc_s {
2085         efx_qword_t ed_eq;
2086 } efx_desc_t;
2087
2088 extern                          void
2089 efx_rx_qpost(
2090         __in                    efx_rxq_t *erp,
2091         __in_ecount(ndescs)     efsys_dma_addr_t *addrp,
2092         __in                    size_t size,
2093         __in                    unsigned int ndescs,
2094         __in                    unsigned int completed,
2095         __in                    unsigned int added);
2096
2097 extern          void
2098 efx_rx_qpush(
2099         __in    efx_rxq_t *erp,
2100         __in    unsigned int added,
2101         __inout unsigned int *pushedp);
2102
2103 #if EFSYS_OPT_RX_PACKED_STREAM
2104
2105 extern                  void
2106 efx_rx_qpush_ps_credits(
2107         __in            efx_rxq_t *erp);
2108
2109 extern  __checkReturn   uint8_t *
2110 efx_rx_qps_packet_info(
2111         __in            efx_rxq_t *erp,
2112         __in            uint8_t *buffer,
2113         __in            uint32_t buffer_length,
2114         __in            uint32_t current_offset,
2115         __out           uint16_t *lengthp,
2116         __out           uint32_t *next_offsetp,
2117         __out           uint32_t *timestamp);
2118 #endif
2119
2120 extern  __checkReturn   efx_rc_t
2121 efx_rx_qflush(
2122         __in    efx_rxq_t *erp);
2123
2124 extern          void
2125 efx_rx_qenable(
2126         __in    efx_rxq_t *erp);
2127
2128 extern          void
2129 efx_rx_qdestroy(
2130         __in    efx_rxq_t *erp);
2131
2132 /* TX */
2133
2134 typedef struct efx_txq_s        efx_txq_t;
2135
2136 #if EFSYS_OPT_QSTATS
2137
2138 /* START MKCONFIG GENERATED EfxHeaderTransmitQueueBlock 12dff8778598b2db */
2139 typedef enum efx_tx_qstat_e {
2140         TX_POST,
2141         TX_POST_PIO,
2142         TX_NQSTATS
2143 } efx_tx_qstat_t;
2144
2145 /* END MKCONFIG GENERATED EfxHeaderTransmitQueueBlock */
2146
2147 #endif  /* EFSYS_OPT_QSTATS */
2148
2149 extern  __checkReturn   efx_rc_t
2150 efx_tx_init(
2151         __in            efx_nic_t *enp);
2152
2153 extern          void
2154 efx_tx_fini(
2155         __in    efx_nic_t *enp);
2156
2157 #define EFX_TXQ_MINNDESCS               512
2158
2159 #define EFX_TXQ_SIZE(_ndescs)           ((_ndescs) * sizeof (efx_qword_t))
2160 #define EFX_TXQ_NBUFS(_ndescs)          (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
2161 #define EFX_TXQ_LIMIT(_ndescs)          ((_ndescs) - 16)
2162
2163 #define EFX_TXQ_MAX_BUFS 8 /* Maximum independent of EFX_BUG35388_WORKAROUND. */
2164
2165 #define EFX_TXQ_CKSUM_IPV4              0x0001
2166 #define EFX_TXQ_CKSUM_TCPUDP            0x0002
2167 #define EFX_TXQ_FATSOV2                 0x0004
2168 #define EFX_TXQ_CKSUM_INNER_IPV4        0x0008
2169 #define EFX_TXQ_CKSUM_INNER_TCPUDP      0x0010
2170
2171 extern  __checkReturn   efx_rc_t
2172 efx_tx_qcreate(
2173         __in            efx_nic_t *enp,
2174         __in            unsigned int index,
2175         __in            unsigned int label,
2176         __in            efsys_mem_t *esmp,
2177         __in            size_t n,
2178         __in            uint32_t id,
2179         __in            uint16_t flags,
2180         __in            efx_evq_t *eep,
2181         __deref_out     efx_txq_t **etpp,
2182         __out           unsigned int *addedp);
2183
2184 extern  __checkReturn           efx_rc_t
2185 efx_tx_qpost(
2186         __in                    efx_txq_t *etp,
2187         __in_ecount(ndescs)     efx_buffer_t *eb,
2188         __in                    unsigned int ndescs,
2189         __in                    unsigned int completed,
2190         __inout                 unsigned int *addedp);
2191
2192 extern  __checkReturn   efx_rc_t
2193 efx_tx_qpace(
2194         __in            efx_txq_t *etp,
2195         __in            unsigned int ns);
2196
2197 extern                  void
2198 efx_tx_qpush(
2199         __in            efx_txq_t *etp,
2200         __in            unsigned int added,
2201         __in            unsigned int pushed);
2202
2203 extern  __checkReturn   efx_rc_t
2204 efx_tx_qflush(
2205         __in            efx_txq_t *etp);
2206
2207 extern                  void
2208 efx_tx_qenable(
2209         __in            efx_txq_t *etp);
2210
2211 extern  __checkReturn   efx_rc_t
2212 efx_tx_qpio_enable(
2213         __in            efx_txq_t *etp);
2214
2215 extern                  void
2216 efx_tx_qpio_disable(
2217         __in            efx_txq_t *etp);
2218
2219 extern  __checkReturn   efx_rc_t
2220 efx_tx_qpio_write(
2221         __in                    efx_txq_t *etp,
2222         __in_ecount(buf_length) uint8_t *buffer,
2223         __in                    size_t buf_length,
2224         __in                    size_t pio_buf_offset);
2225
2226 extern  __checkReturn   efx_rc_t
2227 efx_tx_qpio_post(
2228         __in                    efx_txq_t *etp,
2229         __in                    size_t pkt_length,
2230         __in                    unsigned int completed,
2231         __inout                 unsigned int *addedp);
2232
2233 extern  __checkReturn   efx_rc_t
2234 efx_tx_qdesc_post(
2235         __in            efx_txq_t *etp,
2236         __in_ecount(n)  efx_desc_t *ed,
2237         __in            unsigned int n,
2238         __in            unsigned int completed,
2239         __inout         unsigned int *addedp);
2240
2241 extern  void
2242 efx_tx_qdesc_dma_create(
2243         __in    efx_txq_t *etp,
2244         __in    efsys_dma_addr_t addr,
2245         __in    size_t size,
2246         __in    boolean_t eop,
2247         __out   efx_desc_t *edp);
2248
2249 extern  void
2250 efx_tx_qdesc_tso_create(
2251         __in    efx_txq_t *etp,
2252         __in    uint16_t ipv4_id,
2253         __in    uint32_t tcp_seq,
2254         __in    uint8_t  tcp_flags,
2255         __out   efx_desc_t *edp);
2256
2257 /* Number of FATSOv2 option descriptors */
2258 #define EFX_TX_FATSOV2_OPT_NDESCS               2
2259
2260 /* Maximum number of DMA segments per TSO packet (not superframe) */
2261 #define EFX_TX_FATSOV2_DMA_SEGS_PER_PKT_MAX     24
2262
2263 extern  void
2264 efx_tx_qdesc_tso2_create(
2265         __in                    efx_txq_t *etp,
2266         __in                    uint16_t ipv4_id,
2267         __in                    uint32_t tcp_seq,
2268         __in                    uint16_t tcp_mss,
2269         __out_ecount(count)     efx_desc_t *edp,
2270         __in                    int count);
2271
2272 extern  void
2273 efx_tx_qdesc_vlantci_create(
2274         __in    efx_txq_t *etp,
2275         __in    uint16_t tci,
2276         __out   efx_desc_t *edp);
2277
2278 extern  void
2279 efx_tx_qdesc_checksum_create(
2280         __in    efx_txq_t *etp,
2281         __in    uint16_t flags,
2282         __out   efx_desc_t *edp);
2283
2284 #if EFSYS_OPT_QSTATS
2285
2286 #if EFSYS_OPT_NAMES
2287
2288 extern          const char *
2289 efx_tx_qstat_name(
2290         __in    efx_nic_t *etp,
2291         __in    unsigned int id);
2292
2293 #endif  /* EFSYS_OPT_NAMES */
2294
2295 extern                                  void
2296 efx_tx_qstats_update(
2297         __in                            efx_txq_t *etp,
2298         __inout_ecount(TX_NQSTATS)      efsys_stat_t *stat);
2299
2300 #endif  /* EFSYS_OPT_QSTATS */
2301
2302 extern          void
2303 efx_tx_qdestroy(
2304         __in    efx_txq_t *etp);
2305
2306
2307 /* FILTER */
2308
2309 #if EFSYS_OPT_FILTER
2310
2311 #define EFX_ETHER_TYPE_IPV4 0x0800
2312 #define EFX_ETHER_TYPE_IPV6 0x86DD
2313
2314 #define EFX_IPPROTO_TCP 6
2315 #define EFX_IPPROTO_UDP 17
2316 #define EFX_IPPROTO_GRE 47
2317
2318 /* Use RSS to spread across multiple queues */
2319 #define EFX_FILTER_FLAG_RX_RSS          0x01
2320 /* Enable RX scatter */
2321 #define EFX_FILTER_FLAG_RX_SCATTER      0x02
2322 /*
2323  * Override an automatic filter (priority EFX_FILTER_PRI_AUTO).
2324  * May only be set by the filter implementation for each type.
2325  * A removal request will restore the automatic filter in its place.
2326  */
2327 #define EFX_FILTER_FLAG_RX_OVER_AUTO    0x04
2328 /* Filter is for RX */
2329 #define EFX_FILTER_FLAG_RX              0x08
2330 /* Filter is for TX */
2331 #define EFX_FILTER_FLAG_TX              0x10
2332
2333 typedef uint8_t efx_filter_flags_t;
2334
2335 /*
2336  * Flags which specify the fields to match on. The values are the same as in the
2337  * MC_CMD_FILTER_OP/MC_CMD_FILTER_OP_EXT commands.
2338  */
2339
2340 /* Match by remote IP host address */
2341 #define EFX_FILTER_MATCH_REM_HOST               0x00000001
2342 /* Match by local IP host address */
2343 #define EFX_FILTER_MATCH_LOC_HOST               0x00000002
2344 /* Match by remote MAC address */
2345 #define EFX_FILTER_MATCH_REM_MAC                0x00000004
2346 /* Match by remote TCP/UDP port */
2347 #define EFX_FILTER_MATCH_REM_PORT               0x00000008
2348 /* Match by remote TCP/UDP port */
2349 #define EFX_FILTER_MATCH_LOC_MAC                0x00000010
2350 /* Match by local TCP/UDP port */
2351 #define EFX_FILTER_MATCH_LOC_PORT               0x00000020
2352 /* Match by Ether-type */
2353 #define EFX_FILTER_MATCH_ETHER_TYPE             0x00000040
2354 /* Match by inner VLAN ID */
2355 #define EFX_FILTER_MATCH_INNER_VID              0x00000080
2356 /* Match by outer VLAN ID */
2357 #define EFX_FILTER_MATCH_OUTER_VID              0x00000100
2358 /* Match by IP transport protocol */
2359 #define EFX_FILTER_MATCH_IP_PROTO               0x00000200
2360 /* For encapsulated packets, match all multicast inner frames */
2361 #define EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST 0x01000000
2362 /* For encapsulated packets, match all unicast inner frames */
2363 #define EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST 0x02000000
2364 /* Match otherwise-unmatched multicast and broadcast packets */
2365 #define EFX_FILTER_MATCH_UNKNOWN_MCAST_DST      0x40000000
2366 /* Match otherwise-unmatched unicast packets */
2367 #define EFX_FILTER_MATCH_UNKNOWN_UCAST_DST      0x80000000
2368
2369 typedef uint32_t efx_filter_match_flags_t;
2370
2371 typedef enum efx_filter_priority_s {
2372         EFX_FILTER_PRI_HINT = 0,        /* Performance hint */
2373         EFX_FILTER_PRI_AUTO,            /* Automatic filter based on device
2374                                          * address list or hardware
2375                                          * requirements. This may only be used
2376                                          * by the filter implementation for
2377                                          * each NIC type. */
2378         EFX_FILTER_PRI_MANUAL,          /* Manually configured filter */
2379         EFX_FILTER_PRI_REQUIRED,        /* Required for correct behaviour of the
2380                                          * client (e.g. SR-IOV, HyperV VMQ etc.)
2381                                          */
2382 } efx_filter_priority_t;
2383
2384 /*
2385  * FIXME: All these fields are assumed to be in little-endian byte order.
2386  * It may be better for some to be big-endian. See bug42804.
2387  */
2388
2389 typedef struct efx_filter_spec_s {
2390         efx_filter_match_flags_t        efs_match_flags;
2391         uint8_t                         efs_priority;
2392         efx_filter_flags_t              efs_flags;
2393         uint16_t                        efs_dmaq_id;
2394         uint32_t                        efs_rss_context;
2395         uint16_t                        efs_outer_vid;
2396         uint16_t                        efs_inner_vid;
2397         uint8_t                         efs_loc_mac[EFX_MAC_ADDR_LEN];
2398         uint8_t                         efs_rem_mac[EFX_MAC_ADDR_LEN];
2399         uint16_t                        efs_ether_type;
2400         uint8_t                         efs_ip_proto;
2401         efx_tunnel_protocol_t           efs_encap_type;
2402         uint16_t                        efs_loc_port;
2403         uint16_t                        efs_rem_port;
2404         efx_oword_t                     efs_rem_host;
2405         efx_oword_t                     efs_loc_host;
2406 } efx_filter_spec_t;
2407
2408
2409 /* Default values for use in filter specifications */
2410 #define EFX_FILTER_SPEC_RX_DMAQ_ID_DROP         0xfff
2411 #define EFX_FILTER_SPEC_VID_UNSPEC              0xffff
2412
2413 extern  __checkReturn   efx_rc_t
2414 efx_filter_init(
2415         __in            efx_nic_t *enp);
2416
2417 extern                  void
2418 efx_filter_fini(
2419         __in            efx_nic_t *enp);
2420
2421 extern  __checkReturn   efx_rc_t
2422 efx_filter_insert(
2423         __in            efx_nic_t *enp,
2424         __inout         efx_filter_spec_t *spec);
2425
2426 extern  __checkReturn   efx_rc_t
2427 efx_filter_remove(
2428         __in            efx_nic_t *enp,
2429         __inout         efx_filter_spec_t *spec);
2430
2431 extern  __checkReturn   efx_rc_t
2432 efx_filter_restore(
2433         __in            efx_nic_t *enp);
2434
2435 extern  __checkReturn   efx_rc_t
2436 efx_filter_supported_filters(
2437         __in                            efx_nic_t *enp,
2438         __out_ecount(buffer_length)     uint32_t *buffer,
2439         __in                            size_t buffer_length,
2440         __out                           size_t *list_lengthp);
2441
2442 extern                  void
2443 efx_filter_spec_init_rx(
2444         __out           efx_filter_spec_t *spec,
2445         __in            efx_filter_priority_t priority,
2446         __in            efx_filter_flags_t flags,
2447         __in            efx_rxq_t *erp);
2448
2449 extern                  void
2450 efx_filter_spec_init_tx(
2451         __out           efx_filter_spec_t *spec,
2452         __in            efx_txq_t *etp);
2453
2454 extern  __checkReturn   efx_rc_t
2455 efx_filter_spec_set_ipv4_local(
2456         __inout         efx_filter_spec_t *spec,
2457         __in            uint8_t proto,
2458         __in            uint32_t host,
2459         __in            uint16_t port);
2460
2461 extern  __checkReturn   efx_rc_t
2462 efx_filter_spec_set_ipv4_full(
2463         __inout         efx_filter_spec_t *spec,
2464         __in            uint8_t proto,
2465         __in            uint32_t lhost,
2466         __in            uint16_t lport,
2467         __in            uint32_t rhost,
2468         __in            uint16_t rport);
2469
2470 extern  __checkReturn   efx_rc_t
2471 efx_filter_spec_set_eth_local(
2472         __inout         efx_filter_spec_t *spec,
2473         __in            uint16_t vid,
2474         __in            const uint8_t *addr);
2475
2476 extern                  void
2477 efx_filter_spec_set_ether_type(
2478         __inout         efx_filter_spec_t *spec,
2479         __in            uint16_t ether_type);
2480
2481 extern  __checkReturn   efx_rc_t
2482 efx_filter_spec_set_uc_def(
2483         __inout         efx_filter_spec_t *spec);
2484
2485 extern  __checkReturn   efx_rc_t
2486 efx_filter_spec_set_mc_def(
2487         __inout         efx_filter_spec_t *spec);
2488
2489 typedef enum efx_filter_inner_frame_match_e {
2490         EFX_FILTER_INNER_FRAME_MATCH_OTHER = 0,
2491         EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_MCAST_DST,
2492         EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_UCAST_DST
2493 } efx_filter_inner_frame_match_t;
2494
2495 extern  __checkReturn   efx_rc_t
2496 efx_filter_spec_set_encap_type(
2497         __inout         efx_filter_spec_t *spec,
2498         __in            efx_tunnel_protocol_t encap_type,
2499         __in            efx_filter_inner_frame_match_t inner_frame_match);
2500
2501 #if EFSYS_OPT_RX_SCALE
2502 extern  __checkReturn   efx_rc_t
2503 efx_filter_spec_set_rss_context(
2504         __inout         efx_filter_spec_t *spec,
2505         __in            uint32_t rss_context);
2506 #endif
2507 #endif  /* EFSYS_OPT_FILTER */
2508
2509 /* HASH */
2510
2511 extern  __checkReturn           uint32_t
2512 efx_hash_dwords(
2513         __in_ecount(count)      uint32_t const *input,
2514         __in                    size_t count,
2515         __in                    uint32_t init);
2516
2517 extern  __checkReturn           uint32_t
2518 efx_hash_bytes(
2519         __in_ecount(length)     uint8_t const *input,
2520         __in                    size_t length,
2521         __in                    uint32_t init);
2522
2523 #if EFSYS_OPT_LICENSING
2524
2525 /* LICENSING */
2526
2527 typedef struct efx_key_stats_s {
2528         uint32_t        eks_valid;
2529         uint32_t        eks_invalid;
2530         uint32_t        eks_blacklisted;
2531         uint32_t        eks_unverifiable;
2532         uint32_t        eks_wrong_node;
2533         uint32_t        eks_licensed_apps_lo;
2534         uint32_t        eks_licensed_apps_hi;
2535         uint32_t        eks_licensed_features_lo;
2536         uint32_t        eks_licensed_features_hi;
2537 } efx_key_stats_t;
2538
2539 extern  __checkReturn           efx_rc_t
2540 efx_lic_init(
2541         __in                    efx_nic_t *enp);
2542
2543 extern                          void
2544 efx_lic_fini(
2545         __in                    efx_nic_t *enp);
2546
2547 extern  __checkReturn   boolean_t
2548 efx_lic_check_support(
2549         __in                    efx_nic_t *enp);
2550
2551 extern  __checkReturn   efx_rc_t
2552 efx_lic_update_licenses(
2553         __in            efx_nic_t *enp);
2554
2555 extern  __checkReturn   efx_rc_t
2556 efx_lic_get_key_stats(
2557         __in            efx_nic_t *enp,
2558         __out           efx_key_stats_t *ksp);
2559
2560 extern  __checkReturn   efx_rc_t
2561 efx_lic_app_state(
2562         __in            efx_nic_t *enp,
2563         __in            uint64_t app_id,
2564         __out           boolean_t *licensedp);
2565
2566 extern  __checkReturn   efx_rc_t
2567 efx_lic_get_id(
2568         __in            efx_nic_t *enp,
2569         __in            size_t buffer_size,
2570         __out           uint32_t *typep,
2571         __out           size_t *lengthp,
2572         __out_opt       uint8_t *bufferp);
2573
2574
2575 extern  __checkReturn           efx_rc_t
2576 efx_lic_find_start(
2577         __in                    efx_nic_t *enp,
2578         __in_bcount(buffer_size)
2579                                 caddr_t bufferp,
2580         __in                    size_t buffer_size,
2581         __out                   uint32_t *startp);
2582
2583 extern  __checkReturn           efx_rc_t
2584 efx_lic_find_end(
2585         __in                    efx_nic_t *enp,
2586         __in_bcount(buffer_size)
2587                                 caddr_t bufferp,
2588         __in                    size_t buffer_size,
2589         __in                    uint32_t offset,
2590         __out                   uint32_t *endp);
2591
2592 extern  __checkReturn   __success(return != B_FALSE)    boolean_t
2593 efx_lic_find_key(
2594         __in                    efx_nic_t *enp,
2595         __in_bcount(buffer_size)
2596                                 caddr_t bufferp,
2597         __in                    size_t buffer_size,
2598         __in                    uint32_t offset,
2599         __out                   uint32_t *startp,
2600         __out                   uint32_t *lengthp);
2601
2602 extern  __checkReturn   __success(return != B_FALSE)    boolean_t
2603 efx_lic_validate_key(
2604         __in                    efx_nic_t *enp,
2605         __in_bcount(length)     caddr_t keyp,
2606         __in                    uint32_t length);
2607
2608 extern  __checkReturn           efx_rc_t
2609 efx_lic_read_key(
2610         __in                    efx_nic_t *enp,
2611         __in_bcount(buffer_size)
2612                                 caddr_t bufferp,
2613         __in                    size_t buffer_size,
2614         __in                    uint32_t offset,
2615         __in                    uint32_t length,
2616         __out_bcount_part(key_max_size, *lengthp)
2617                                 caddr_t keyp,
2618         __in                    size_t key_max_size,
2619         __out                   uint32_t *lengthp);
2620
2621 extern  __checkReturn           efx_rc_t
2622 efx_lic_write_key(
2623         __in                    efx_nic_t *enp,
2624         __in_bcount(buffer_size)
2625                                 caddr_t bufferp,
2626         __in                    size_t buffer_size,
2627         __in                    uint32_t offset,
2628         __in_bcount(length)     caddr_t keyp,
2629         __in                    uint32_t length,
2630         __out                   uint32_t *lengthp);
2631
2632         __checkReturn           efx_rc_t
2633 efx_lic_delete_key(
2634         __in                    efx_nic_t *enp,
2635         __in_bcount(buffer_size)
2636                                 caddr_t bufferp,
2637         __in                    size_t buffer_size,
2638         __in                    uint32_t offset,
2639         __in                    uint32_t length,
2640         __in                    uint32_t end,
2641         __out                   uint32_t *deltap);
2642
2643 extern  __checkReturn           efx_rc_t
2644 efx_lic_create_partition(
2645         __in                    efx_nic_t *enp,
2646         __in_bcount(buffer_size)
2647                                 caddr_t bufferp,
2648         __in                    size_t buffer_size);
2649
2650 extern  __checkReturn           efx_rc_t
2651 efx_lic_finish_partition(
2652         __in                    efx_nic_t *enp,
2653         __in_bcount(buffer_size)
2654                                 caddr_t bufferp,
2655         __in                    size_t buffer_size);
2656
2657 #endif  /* EFSYS_OPT_LICENSING */
2658
2659 /* TUNNEL */
2660
2661 #if EFSYS_OPT_TUNNEL
2662
2663 extern  __checkReturn   efx_rc_t
2664 efx_tunnel_init(
2665         __in            efx_nic_t *enp);
2666
2667 extern                  void
2668 efx_tunnel_fini(
2669         __in            efx_nic_t *enp);
2670
2671 /*
2672  * For overlay network encapsulation using UDP, the firmware needs to know
2673  * the configured UDP port for the overlay so it can decode encapsulated
2674  * frames correctly.
2675  * The UDP port/protocol list is global.
2676  */
2677
2678 extern  __checkReturn   efx_rc_t
2679 efx_tunnel_config_udp_add(
2680         __in            efx_nic_t *enp,
2681         __in            uint16_t port /* host/cpu-endian */,
2682         __in            efx_tunnel_protocol_t protocol);
2683
2684 extern  __checkReturn   efx_rc_t
2685 efx_tunnel_config_udp_remove(
2686         __in            efx_nic_t *enp,
2687         __in            uint16_t port /* host/cpu-endian */,
2688         __in            efx_tunnel_protocol_t protocol);
2689
2690 extern                  void
2691 efx_tunnel_config_clear(
2692         __in            efx_nic_t *enp);
2693
2694 /**
2695  * Apply tunnel UDP ports configuration to hardware.
2696  *
2697  * EAGAIN is returned if hardware will be reset (datapath and managment CPU
2698  * reboot).
2699  */
2700 extern  __checkReturn   efx_rc_t
2701 efx_tunnel_reconfigure(
2702         __in            efx_nic_t *enp);
2703
2704 #endif /* EFSYS_OPT_TUNNEL */
2705
2706
2707 #ifdef  __cplusplus
2708 }
2709 #endif
2710
2711 #endif  /* _SYS_EFX_H */