2 * Copyright (c) 2007-2015 Solarflare Communications Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * The views and conclusions contained in the software and documentation are
27 * those of the authors and should not be interpreted as representing official
28 * policies, either expressed or implied, of the FreeBSD Project.
33 #ifndef _SYS_EFX_IMPL_H
34 #define _SYS_EFX_IMPL_H
37 #include "efx_check.h"
40 #include "efx_regs_ef10.h"
42 /* FIXME: Add definition for driver generated software events */
43 #ifndef ESE_DZ_EV_CODE_DRV_GEN_EV
44 #define ESE_DZ_EV_CODE_DRV_GEN_EV FSE_AZ_EV_CODE_DRV_GEN_EV
49 #include "falcon_impl.h"
50 #endif /* EFSYS_OPT_FALCON */
53 #include "siena_impl.h"
54 #endif /* EFSYS_OPT_SIENA */
56 #if EFSYS_OPT_HUNTINGTON
57 #include "hunt_impl.h"
58 #endif /* EFSYS_OPT_HUNTINGTON */
61 #include "medford_impl.h"
62 #endif /* EFSYS_OPT_MEDFORD */
64 #if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
65 #include "ef10_impl.h"
66 #endif /* (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) */
72 #define EFX_MOD_MCDI 0x00000001
73 #define EFX_MOD_PROBE 0x00000002
74 #define EFX_MOD_NVRAM 0x00000004
75 #define EFX_MOD_VPD 0x00000008
76 #define EFX_MOD_NIC 0x00000010
77 #define EFX_MOD_INTR 0x00000020
78 #define EFX_MOD_EV 0x00000040
79 #define EFX_MOD_RX 0x00000080
80 #define EFX_MOD_TX 0x00000100
81 #define EFX_MOD_PORT 0x00000200
82 #define EFX_MOD_MON 0x00000400
83 #define EFX_MOD_WOL 0x00000800
84 #define EFX_MOD_FILTER 0x00001000
85 #define EFX_MOD_PKTFILTER 0x00002000
86 #define EFX_MOD_LIC 0x00004000
88 #define EFX_RESET_MAC 0x00000001
89 #define EFX_RESET_PHY 0x00000002
90 #define EFX_RESET_RXQ_ERR 0x00000004
91 #define EFX_RESET_TXQ_ERR 0x00000008
93 typedef enum efx_mac_type_e {
103 typedef struct efx_ev_ops_s {
104 efx_rc_t (*eevo_init)(efx_nic_t *);
105 void (*eevo_fini)(efx_nic_t *);
106 efx_rc_t (*eevo_qcreate)(efx_nic_t *, unsigned int,
107 efsys_mem_t *, size_t, uint32_t,
109 void (*eevo_qdestroy)(efx_evq_t *);
110 efx_rc_t (*eevo_qprime)(efx_evq_t *, unsigned int);
111 void (*eevo_qpost)(efx_evq_t *, uint16_t);
112 efx_rc_t (*eevo_qmoderate)(efx_evq_t *, unsigned int);
114 void (*eevo_qstats_update)(efx_evq_t *, efsys_stat_t *);
118 typedef struct efx_tx_ops_s {
119 efx_rc_t (*etxo_init)(efx_nic_t *);
120 void (*etxo_fini)(efx_nic_t *);
121 efx_rc_t (*etxo_qcreate)(efx_nic_t *,
122 unsigned int, unsigned int,
123 efsys_mem_t *, size_t,
125 efx_evq_t *, efx_txq_t *,
127 void (*etxo_qdestroy)(efx_txq_t *);
128 efx_rc_t (*etxo_qpost)(efx_txq_t *, efx_buffer_t *,
129 unsigned int, unsigned int,
131 void (*etxo_qpush)(efx_txq_t *, unsigned int, unsigned int);
132 efx_rc_t (*etxo_qpace)(efx_txq_t *, unsigned int);
133 efx_rc_t (*etxo_qflush)(efx_txq_t *);
134 void (*etxo_qenable)(efx_txq_t *);
135 efx_rc_t (*etxo_qpio_enable)(efx_txq_t *);
136 void (*etxo_qpio_disable)(efx_txq_t *);
137 efx_rc_t (*etxo_qpio_write)(efx_txq_t *,uint8_t *, size_t,
139 efx_rc_t (*etxo_qpio_post)(efx_txq_t *, size_t, unsigned int,
141 efx_rc_t (*etxo_qdesc_post)(efx_txq_t *, efx_desc_t *,
142 unsigned int, unsigned int,
144 void (*etxo_qdesc_dma_create)(efx_txq_t *, efsys_dma_addr_t,
147 void (*etxo_qdesc_tso_create)(efx_txq_t *, uint16_t,
150 void (*etxo_qdesc_tso2_create)(efx_txq_t *, uint16_t,
153 void (*etxo_qdesc_vlantci_create)(efx_txq_t *, uint16_t,
156 void (*etxo_qstats_update)(efx_txq_t *,
161 typedef struct efx_rx_ops_s {
162 efx_rc_t (*erxo_init)(efx_nic_t *);
163 void (*erxo_fini)(efx_nic_t *);
164 #if EFSYS_OPT_RX_SCATTER
165 efx_rc_t (*erxo_scatter_enable)(efx_nic_t *, unsigned int);
167 #if EFSYS_OPT_RX_SCALE
168 efx_rc_t (*erxo_scale_mode_set)(efx_nic_t *, efx_rx_hash_alg_t,
169 efx_rx_hash_type_t, boolean_t);
170 efx_rc_t (*erxo_scale_key_set)(efx_nic_t *, uint8_t *, size_t);
171 efx_rc_t (*erxo_scale_tbl_set)(efx_nic_t *, unsigned int *,
173 uint32_t (*erxo_prefix_hash)(efx_nic_t *, efx_rx_hash_alg_t,
175 #endif /* EFSYS_OPT_RX_SCALE */
176 efx_rc_t (*erxo_prefix_pktlen)(efx_nic_t *, uint8_t *,
178 void (*erxo_qpost)(efx_rxq_t *, efsys_dma_addr_t *, size_t,
179 unsigned int, unsigned int,
181 void (*erxo_qpush)(efx_rxq_t *, unsigned int, unsigned int *);
182 efx_rc_t (*erxo_qflush)(efx_rxq_t *);
183 void (*erxo_qenable)(efx_rxq_t *);
184 efx_rc_t (*erxo_qcreate)(efx_nic_t *enp, unsigned int,
185 unsigned int, efx_rxq_type_t,
186 efsys_mem_t *, size_t, uint32_t,
187 efx_evq_t *, efx_rxq_t *);
188 void (*erxo_qdestroy)(efx_rxq_t *);
191 typedef struct efx_mac_ops_s {
192 efx_rc_t (*emo_reset)(efx_nic_t *); /* optional */
193 efx_rc_t (*emo_poll)(efx_nic_t *, efx_link_mode_t *);
194 efx_rc_t (*emo_up)(efx_nic_t *, boolean_t *);
195 efx_rc_t (*emo_addr_set)(efx_nic_t *);
196 efx_rc_t (*emo_pdu_set)(efx_nic_t *);
197 efx_rc_t (*emo_reconfigure)(efx_nic_t *);
198 efx_rc_t (*emo_multicast_list_set)(efx_nic_t *);
199 efx_rc_t (*emo_filter_default_rxq_set)(efx_nic_t *,
200 efx_rxq_t *, boolean_t);
201 void (*emo_filter_default_rxq_clear)(efx_nic_t *);
202 #if EFSYS_OPT_LOOPBACK
203 efx_rc_t (*emo_loopback_set)(efx_nic_t *, efx_link_mode_t,
204 efx_loopback_type_t);
205 #endif /* EFSYS_OPT_LOOPBACK */
206 #if EFSYS_OPT_MAC_STATS
207 efx_rc_t (*emo_stats_upload)(efx_nic_t *, efsys_mem_t *);
208 efx_rc_t (*emo_stats_periodic)(efx_nic_t *, efsys_mem_t *,
209 uint16_t, boolean_t);
210 efx_rc_t (*emo_stats_update)(efx_nic_t *, efsys_mem_t *,
211 efsys_stat_t *, uint32_t *);
212 #endif /* EFSYS_OPT_MAC_STATS */
215 typedef struct efx_phy_ops_s {
216 efx_rc_t (*epo_power)(efx_nic_t *, boolean_t); /* optional */
217 efx_rc_t (*epo_reset)(efx_nic_t *);
218 efx_rc_t (*epo_reconfigure)(efx_nic_t *);
219 efx_rc_t (*epo_verify)(efx_nic_t *);
220 efx_rc_t (*epo_uplink_check)(efx_nic_t *,
221 boolean_t *); /* optional */
222 efx_rc_t (*epo_downlink_check)(efx_nic_t *, efx_link_mode_t *,
223 unsigned int *, uint32_t *);
224 efx_rc_t (*epo_oui_get)(efx_nic_t *, uint32_t *);
225 #if EFSYS_OPT_PHY_STATS
226 efx_rc_t (*epo_stats_update)(efx_nic_t *, efsys_mem_t *,
228 #endif /* EFSYS_OPT_PHY_STATS */
229 #if EFSYS_OPT_PHY_PROPS
231 const char *(*epo_prop_name)(efx_nic_t *, unsigned int);
232 #endif /* EFSYS_OPT_PHY_PROPS */
233 efx_rc_t (*epo_prop_get)(efx_nic_t *, unsigned int, uint32_t,
235 efx_rc_t (*epo_prop_set)(efx_nic_t *, unsigned int, uint32_t);
236 #endif /* EFSYS_OPT_PHY_PROPS */
238 efx_rc_t (*epo_bist_enable_offline)(efx_nic_t *);
239 efx_rc_t (*epo_bist_start)(efx_nic_t *, efx_bist_type_t);
240 efx_rc_t (*epo_bist_poll)(efx_nic_t *, efx_bist_type_t,
241 efx_bist_result_t *, uint32_t *,
242 unsigned long *, size_t);
243 void (*epo_bist_stop)(efx_nic_t *, efx_bist_type_t);
244 #endif /* EFSYS_OPT_BIST */
248 typedef struct efx_filter_ops_s {
249 efx_rc_t (*efo_init)(efx_nic_t *);
250 void (*efo_fini)(efx_nic_t *);
251 efx_rc_t (*efo_restore)(efx_nic_t *);
252 efx_rc_t (*efo_add)(efx_nic_t *, efx_filter_spec_t *,
253 boolean_t may_replace);
254 efx_rc_t (*efo_delete)(efx_nic_t *, efx_filter_spec_t *);
255 efx_rc_t (*efo_supported_filters)(efx_nic_t *, uint32_t *, size_t *);
256 efx_rc_t (*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
257 boolean_t, boolean_t, boolean_t,
258 uint8_t const *, int);
261 extern __checkReturn efx_rc_t
262 efx_filter_reconfigure(
264 __in_ecount(6) uint8_t const *mac_addr,
265 __in boolean_t all_unicst,
266 __in boolean_t mulcst,
267 __in boolean_t all_mulcst,
268 __in boolean_t brdcst,
269 __in_ecount(6*count) uint8_t const *addrs,
272 #endif /* EFSYS_OPT_FILTER */
275 typedef struct efx_port_s {
276 efx_mac_type_t ep_mac_type;
277 uint32_t ep_phy_type;
280 uint8_t ep_mac_addr[6];
281 efx_link_mode_t ep_link_mode;
282 boolean_t ep_all_unicst;
284 boolean_t ep_all_mulcst;
286 unsigned int ep_fcntl;
287 boolean_t ep_fcntl_autoneg;
288 efx_oword_t ep_multicst_hash[2];
289 uint8_t ep_mulcst_addr_list[EFX_MAC_ADDR_LEN *
290 EFX_MAC_MULTICAST_LIST_MAX];
291 uint32_t ep_mulcst_addr_count;
292 #if EFSYS_OPT_LOOPBACK
293 efx_loopback_type_t ep_loopback_type;
294 efx_link_mode_t ep_loopback_link_mode;
295 #endif /* EFSYS_OPT_LOOPBACK */
296 #if EFSYS_OPT_PHY_FLAGS
297 uint32_t ep_phy_flags;
298 #endif /* EFSYS_OPT_PHY_FLAGS */
299 #if EFSYS_OPT_PHY_LED_CONTROL
300 efx_phy_led_mode_t ep_phy_led_mode;
301 #endif /* EFSYS_OPT_PHY_LED_CONTROL */
302 efx_phy_media_type_t ep_fixed_port_type;
303 efx_phy_media_type_t ep_module_type;
304 uint32_t ep_adv_cap_mask;
305 uint32_t ep_lp_cap_mask;
306 uint32_t ep_default_adv_cap_mask;
307 uint32_t ep_phy_cap_mask;
308 #if EFSYS_OPT_PHY_TXC43128 || EFSYS_OPT_PHY_QT2025C
311 unsigned int bug10934_count;
314 unsigned int bug17190_count;
318 boolean_t ep_mac_poll_needed; /* falcon only */
319 boolean_t ep_mac_up; /* falcon only */
320 uint32_t ep_fwver; /* falcon only */
321 boolean_t ep_mac_drain;
322 boolean_t ep_mac_stats_pending;
324 efx_bist_type_t ep_current_bist;
326 efx_mac_ops_t *ep_emop;
327 efx_phy_ops_t *ep_epop;
330 typedef struct efx_mon_ops_s {
331 efx_rc_t (*emo_reset)(efx_nic_t *);
332 efx_rc_t (*emo_reconfigure)(efx_nic_t *);
333 #if EFSYS_OPT_MON_STATS
334 efx_rc_t (*emo_stats_update)(efx_nic_t *, efsys_mem_t *,
335 efx_mon_stat_value_t *);
336 #endif /* EFSYS_OPT_MON_STATS */
339 typedef struct efx_mon_s {
340 efx_mon_type_t em_type;
341 efx_mon_ops_t *em_emop;
344 typedef struct efx_intr_ops_s {
345 efx_rc_t (*eio_init)(efx_nic_t *, efx_intr_type_t, efsys_mem_t *);
346 void (*eio_enable)(efx_nic_t *);
347 void (*eio_disable)(efx_nic_t *);
348 void (*eio_disable_unlocked)(efx_nic_t *);
349 efx_rc_t (*eio_trigger)(efx_nic_t *, unsigned int);
350 void (*eio_status_line)(efx_nic_t *, boolean_t *, uint32_t *);
351 void (*eio_status_message)(efx_nic_t *, unsigned int,
353 void (*eio_fatal)(efx_nic_t *);
354 void (*eio_fini)(efx_nic_t *);
357 typedef struct efx_intr_s {
358 efx_intr_ops_t *ei_eiop;
359 efsys_mem_t *ei_esmp;
360 efx_intr_type_t ei_type;
361 unsigned int ei_level;
364 typedef struct efx_nic_ops_s {
365 efx_rc_t (*eno_probe)(efx_nic_t *);
366 efx_rc_t (*eno_board_cfg)(efx_nic_t *);
367 efx_rc_t (*eno_set_drv_limits)(efx_nic_t *, efx_drv_limits_t*);
368 efx_rc_t (*eno_reset)(efx_nic_t *);
369 efx_rc_t (*eno_init)(efx_nic_t *);
370 efx_rc_t (*eno_get_vi_pool)(efx_nic_t *, uint32_t *);
371 efx_rc_t (*eno_get_bar_region)(efx_nic_t *, efx_nic_region_t,
372 uint32_t *, size_t *);
374 efx_rc_t (*eno_sram_test)(efx_nic_t *, efx_sram_pattern_fn_t);
375 efx_rc_t (*eno_register_test)(efx_nic_t *);
376 #endif /* EFSYS_OPT_DIAG */
377 void (*eno_fini)(efx_nic_t *);
378 void (*eno_unprobe)(efx_nic_t *);
381 #ifndef EFX_TXQ_LIMIT_TARGET
382 #define EFX_TXQ_LIMIT_TARGET 259
384 #ifndef EFX_RXQ_LIMIT_TARGET
385 #define EFX_RXQ_LIMIT_TARGET 512
387 #ifndef EFX_TXQ_DC_SIZE
388 #define EFX_TXQ_DC_SIZE 1 /* 16 descriptors */
390 #ifndef EFX_RXQ_DC_SIZE
391 #define EFX_RXQ_DC_SIZE 3 /* 64 descriptors */
396 typedef struct falconsiena_filter_spec_s {
399 uint32_t fsfs_dmaq_id;
400 uint32_t fsfs_dword[3];
401 } falconsiena_filter_spec_t;
403 typedef enum falconsiena_filter_type_e {
404 EFX_FS_FILTER_RX_TCP_FULL, /* TCP/IPv4 4-tuple {dIP,dTCP,sIP,sTCP} */
405 EFX_FS_FILTER_RX_TCP_WILD, /* TCP/IPv4 dest {dIP,dTCP, -, -} */
406 EFX_FS_FILTER_RX_UDP_FULL, /* UDP/IPv4 4-tuple {dIP,dUDP,sIP,sUDP} */
407 EFX_FS_FILTER_RX_UDP_WILD, /* UDP/IPv4 dest {dIP,dUDP, -, -} */
410 EFX_FS_FILTER_RX_MAC_FULL, /* Ethernet {dMAC,VLAN} */
411 EFX_FS_FILTER_RX_MAC_WILD, /* Ethernet {dMAC, -} */
413 EFX_FS_FILTER_TX_TCP_FULL, /* TCP/IPv4 {dIP,dTCP,sIP,sTCP} */
414 EFX_FS_FILTER_TX_TCP_WILD, /* TCP/IPv4 { -, -,sIP,sTCP} */
415 EFX_FS_FILTER_TX_UDP_FULL, /* UDP/IPv4 {dIP,dTCP,sIP,sTCP} */
416 EFX_FS_FILTER_TX_UDP_WILD, /* UDP/IPv4 source (host, port) */
418 EFX_FS_FILTER_TX_MAC_FULL, /* Ethernet source (MAC address, VLAN ID) */
419 EFX_FS_FILTER_TX_MAC_WILD, /* Ethernet source (MAC address) */
420 #endif /* EFSYS_OPT_SIENA */
423 } falconsiena_filter_type_t;
425 typedef enum falconsiena_filter_tbl_id_e {
426 EFX_FS_FILTER_TBL_RX_IP = 0,
427 EFX_FS_FILTER_TBL_RX_MAC,
428 EFX_FS_FILTER_TBL_TX_IP,
429 EFX_FS_FILTER_TBL_TX_MAC,
431 } falconsiena_filter_tbl_id_t;
433 typedef struct falconsiena_filter_tbl_s {
434 int fsft_size; /* number of entries */
435 int fsft_used; /* active count */
436 uint32_t *fsft_bitmap; /* active bitmap */
437 falconsiena_filter_spec_t *fsft_spec; /* array of saved specs */
438 } falconsiena_filter_tbl_t;
440 typedef struct falconsiena_filter_s {
441 falconsiena_filter_tbl_t fsf_tbl[EFX_FS_FILTER_NTBLS];
442 unsigned int fsf_depth[EFX_FS_FILTER_NTYPES];
443 } falconsiena_filter_t;
445 typedef struct efx_filter_s {
446 #if EFSYS_OPT_FALCON || EFSYS_OPT_SIENA
447 falconsiena_filter_t *ef_falconsiena_filter;
448 #endif /* EFSYS_OPT_FALCON || EFSYS_OPT_SIENA */
449 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
450 ef10_filter_table_t *ef_ef10_filter_table;
451 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
455 falconsiena_filter_tbl_clear(
457 __in falconsiena_filter_tbl_id_t tbl);
459 #endif /* EFSYS_OPT_FILTER */
463 typedef struct efx_mcdi_ops_s {
464 efx_rc_t (*emco_init)(efx_nic_t *, const efx_mcdi_transport_t *);
465 void (*emco_send_request)(efx_nic_t *, void *, size_t,
467 efx_rc_t (*emco_poll_reboot)(efx_nic_t *);
468 boolean_t (*emco_poll_response)(efx_nic_t *);
469 void (*emco_read_response)(efx_nic_t *, void *, size_t, size_t);
470 void (*emco_fini)(efx_nic_t *);
471 efx_rc_t (*emco_feature_supported)(efx_nic_t *, efx_mcdi_feature_id_t, boolean_t *);
474 typedef struct efx_mcdi_s {
475 efx_mcdi_ops_t *em_emcop;
476 const efx_mcdi_transport_t *em_emtp;
477 efx_mcdi_iface_t em_emip;
480 #endif /* EFSYS_OPT_MCDI */
483 typedef struct efx_nvram_ops_s {
485 efx_rc_t (*envo_test)(efx_nic_t *);
486 #endif /* EFSYS_OPT_DIAG */
487 efx_rc_t (*envo_type_to_partn)(efx_nic_t *, efx_nvram_type_t,
489 efx_rc_t (*envo_partn_size)(efx_nic_t *, uint32_t, size_t *);
490 efx_rc_t (*envo_partn_rw_start)(efx_nic_t *, uint32_t, size_t *);
491 efx_rc_t (*envo_partn_read)(efx_nic_t *, uint32_t,
492 unsigned int, caddr_t, size_t);
493 efx_rc_t (*envo_partn_erase)(efx_nic_t *, uint32_t,
494 unsigned int, size_t);
495 efx_rc_t (*envo_partn_write)(efx_nic_t *, uint32_t,
496 unsigned int, caddr_t, size_t);
497 void (*envo_partn_rw_finish)(efx_nic_t *, uint32_t);
498 efx_rc_t (*envo_partn_get_version)(efx_nic_t *, uint32_t,
499 uint32_t *, uint16_t *);
500 efx_rc_t (*envo_partn_set_version)(efx_nic_t *, uint32_t,
502 efx_rc_t (*envo_buffer_validate)(efx_nic_t *, uint32_t,
505 #endif /* EFSYS_OPT_NVRAM */
507 extern __checkReturn efx_rc_t
508 efx_nvram_tlv_validate(
511 __in_bcount(partn_size) caddr_t partn_data,
512 __in size_t partn_size);
516 typedef struct efx_vpd_ops_s {
517 efx_rc_t (*evpdo_init)(efx_nic_t *);
518 efx_rc_t (*evpdo_size)(efx_nic_t *, size_t *);
519 efx_rc_t (*evpdo_read)(efx_nic_t *, caddr_t, size_t);
520 efx_rc_t (*evpdo_verify)(efx_nic_t *, caddr_t, size_t);
521 efx_rc_t (*evpdo_reinit)(efx_nic_t *, caddr_t, size_t);
522 efx_rc_t (*evpdo_get)(efx_nic_t *, caddr_t, size_t,
524 efx_rc_t (*evpdo_set)(efx_nic_t *, caddr_t, size_t,
526 efx_rc_t (*evpdo_next)(efx_nic_t *, caddr_t, size_t,
527 efx_vpd_value_t *, unsigned int *);
528 efx_rc_t (*evpdo_write)(efx_nic_t *, caddr_t, size_t);
529 void (*evpdo_fini)(efx_nic_t *);
531 #endif /* EFSYS_OPT_VPD */
533 #if EFSYS_OPT_VPD || EFSYS_OPT_NVRAM
535 __checkReturn efx_rc_t
536 efx_mcdi_nvram_partitions(
538 __out_bcount(size) caddr_t data,
540 __out unsigned int *npartnp);
542 __checkReturn efx_rc_t
543 efx_mcdi_nvram_metadata(
546 __out uint32_t *subtypep,
547 __out_ecount(4) uint16_t version[4],
548 __out_bcount_opt(size) char *descp,
551 __checkReturn efx_rc_t
555 __out_opt size_t *sizep,
556 __out_opt uint32_t *addressp,
557 __out_opt uint32_t *erase_sizep,
558 __out_opt uint32_t *write_sizep);
560 __checkReturn efx_rc_t
561 efx_mcdi_nvram_update_start(
563 __in uint32_t partn);
565 __checkReturn efx_rc_t
569 __in uint32_t offset,
570 __out_bcount(size) caddr_t data,
574 __checkReturn efx_rc_t
575 efx_mcdi_nvram_erase(
578 __in uint32_t offset,
581 __checkReturn efx_rc_t
582 efx_mcdi_nvram_write(
585 __in uint32_t offset,
586 __out_bcount(size) caddr_t data,
589 __checkReturn efx_rc_t
590 efx_mcdi_nvram_update_finish(
593 __in boolean_t reboot);
597 __checkReturn efx_rc_t
600 __in uint32_t partn);
602 #endif /* EFSYS_OPT_DIAG */
604 #endif /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
606 #if EFSYS_OPT_LICENSING
608 typedef struct efx_lic_ops_s {
609 efx_rc_t (*elo_update_licenses)(efx_nic_t *);
610 efx_rc_t (*elo_get_key_stats)(efx_nic_t *, efx_key_stats_t *);
611 efx_rc_t (*elo_app_state)(efx_nic_t *, uint64_t, boolean_t *);
612 efx_rc_t (*elo_get_id)(efx_nic_t *, size_t, uint32_t *,
613 size_t *, uint8_t *);
618 typedef struct efx_drv_cfg_s {
619 uint32_t edc_min_vi_count;
620 uint32_t edc_max_vi_count;
622 uint32_t edc_max_piobuf_count;
623 uint32_t edc_pio_alloc_size;
628 efx_family_t en_family;
629 uint32_t en_features;
630 efsys_identifier_t *en_esip;
631 efsys_lock_t *en_eslp;
632 efsys_bar_t *en_esbp;
633 unsigned int en_mod_flags;
634 unsigned int en_reset_flags;
635 efx_nic_cfg_t en_nic_cfg;
636 efx_drv_cfg_t en_drv_cfg;
640 uint32_t en_ev_qcount;
641 uint32_t en_rx_qcount;
642 uint32_t en_tx_qcount;
643 efx_nic_ops_t *en_enop;
644 efx_ev_ops_t *en_eevop;
645 efx_tx_ops_t *en_etxop;
646 efx_rx_ops_t *en_erxop;
648 efx_filter_t en_filter;
649 efx_filter_ops_t *en_efop;
650 #endif /* EFSYS_OPT_FILTER */
653 #endif /* EFSYS_OPT_MCDI */
655 efx_nvram_type_t en_nvram_locked;
656 efx_nvram_ops_t *en_envop;
657 #endif /* EFSYS_OPT_NVRAM */
659 efx_vpd_ops_t *en_evpdop;
660 #endif /* EFSYS_OPT_VPD */
661 #if EFSYS_OPT_RX_SCALE
662 efx_rx_hash_support_t en_hash_support;
663 efx_rx_scale_support_t en_rss_support;
664 uint32_t en_rss_context;
665 #endif /* EFSYS_OPT_RX_SCALE */
666 uint32_t en_vport_id;
667 #if EFSYS_OPT_LICENSING
668 efx_lic_ops_t *en_elop;
673 falcon_spi_dev_t enu_fsd[FALCON_SPI_NTYPES];
674 falcon_i2c_t enu_fip;
675 boolean_t enu_i2c_locked;
676 #if EFSYS_OPT_FALCON_NIC_CFG_OVERRIDE
677 const uint8_t *enu_forced_cfg;
678 #endif /* EFSYS_OPT_FALCON_NIC_CFG_OVERRIDE */
679 uint8_t enu_mon_devid;
680 uint16_t enu_board_rev;
681 boolean_t enu_internal_sram;
682 uint8_t enu_sram_num_bank;
683 uint8_t enu_sram_bank_size;
685 #endif /* EFSYS_OPT_FALCON */
688 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
689 unsigned int enu_partn_mask;
690 #endif /* EFSYS_OPT_NVRAM || EFSYS_OPT_VPD */
693 size_t enu_svpd_length;
694 #endif /* EFSYS_OPT_VPD */
697 #endif /* EFSYS_OPT_SIENA */
700 #if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
708 size_t ena_svpd_length;
709 #endif /* EFSYS_OPT_VPD */
710 efx_piobuf_handle_t ena_piobuf_handle[EF10_MAX_PIOBUF_NBUFS];
711 uint32_t ena_piobuf_count;
712 uint32_t ena_pio_alloc_map[EF10_MAX_PIOBUF_NBUFS];
713 uint32_t ena_pio_write_vi_base;
714 /* Memory BAR mapping regions */
715 uint32_t ena_uc_mem_map_offset;
716 size_t ena_uc_mem_map_size;
717 uint32_t ena_wc_mem_map_offset;
718 size_t ena_wc_mem_map_size;
721 #endif /* (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) */
725 #define EFX_NIC_MAGIC 0x02121996
727 typedef boolean_t (*efx_ev_handler_t)(efx_evq_t *, efx_qword_t *,
728 const efx_ev_callbacks_t *, void *);
730 typedef struct efx_evq_rxq_state_s {
731 unsigned int eers_rx_read_ptr;
732 unsigned int eers_rx_mask;
733 } efx_evq_rxq_state_t;
738 unsigned int ee_index;
739 unsigned int ee_mask;
740 efsys_mem_t *ee_esmp;
742 uint32_t ee_stat[EV_NQSTATS];
743 #endif /* EFSYS_OPT_QSTATS */
745 efx_ev_handler_t ee_rx;
746 efx_ev_handler_t ee_tx;
747 efx_ev_handler_t ee_driver;
748 efx_ev_handler_t ee_global;
749 efx_ev_handler_t ee_drv_gen;
751 efx_ev_handler_t ee_mcdi;
752 #endif /* EFSYS_OPT_MCDI */
754 efx_evq_rxq_state_t ee_rxq_state[EFX_EV_RX_NLABELS];
757 #define EFX_EVQ_MAGIC 0x08081997
759 #define EFX_EVQ_FALCON_TIMER_QUANTUM_NS 4968 /* 621 cycles */
760 #define EFX_EVQ_SIENA_TIMER_QUANTUM_NS 6144 /* 768 cycles */
766 unsigned int er_index;
767 unsigned int er_label;
768 unsigned int er_mask;
769 efsys_mem_t *er_esmp;
772 #define EFX_RXQ_MAGIC 0x15022005
777 unsigned int et_index;
778 unsigned int et_mask;
779 efsys_mem_t *et_esmp;
780 #if EFSYS_OPT_HUNTINGTON
781 uint32_t et_pio_bufnum;
782 uint32_t et_pio_blknum;
783 uint32_t et_pio_write_offset;
784 uint32_t et_pio_offset;
788 uint32_t et_stat[TX_NQSTATS];
789 #endif /* EFSYS_OPT_QSTATS */
792 #define EFX_TXQ_MAGIC 0x05092005
794 #define EFX_MAC_ADDR_COPY(_dst, _src) \
796 (_dst)[0] = (_src)[0]; \
797 (_dst)[1] = (_src)[1]; \
798 (_dst)[2] = (_src)[2]; \
799 (_dst)[3] = (_src)[3]; \
800 (_dst)[4] = (_src)[4]; \
801 (_dst)[5] = (_src)[5]; \
802 _NOTE(CONSTANTCONDITION) \
805 #define EFX_MAC_BROADCAST_ADDR_SET(_dst) \
807 uint16_t *_d = (uint16_t *)(_dst); \
811 _NOTE(CONSTANTCONDITION) \
814 #if EFSYS_OPT_CHECK_REG
815 #define EFX_CHECK_REG(_enp, _reg) \
817 const char *name = #_reg; \
818 char min = name[4]; \
819 char max = name[5]; \
822 switch ((_enp)->en_family) { \
823 case EFX_FAMILY_FALCON: \
827 case EFX_FAMILY_SIENA: \
831 case EFX_FAMILY_HUNTINGTON: \
835 case EFX_FAMILY_MEDFORD: \
844 EFSYS_ASSERT3S(rev, >=, min); \
845 EFSYS_ASSERT3S(rev, <=, max); \
847 _NOTE(CONSTANTCONDITION) \
850 #define EFX_CHECK_REG(_enp, _reg) do { \
851 _NOTE(CONSTANTCONDITION) \
855 #define EFX_BAR_READD(_enp, _reg, _edp, _lock) \
857 EFX_CHECK_REG((_enp), (_reg)); \
858 EFSYS_BAR_READD((_enp)->en_esbp, _reg ## _OFST, \
860 EFSYS_PROBE3(efx_bar_readd, const char *, #_reg, \
861 uint32_t, _reg ## _OFST, \
862 uint32_t, (_edp)->ed_u32[0]); \
863 _NOTE(CONSTANTCONDITION) \
866 #define EFX_BAR_WRITED(_enp, _reg, _edp, _lock) \
868 EFX_CHECK_REG((_enp), (_reg)); \
869 EFSYS_PROBE3(efx_bar_writed, const char *, #_reg, \
870 uint32_t, _reg ## _OFST, \
871 uint32_t, (_edp)->ed_u32[0]); \
872 EFSYS_BAR_WRITED((_enp)->en_esbp, _reg ## _OFST, \
874 _NOTE(CONSTANTCONDITION) \
877 #define EFX_BAR_READQ(_enp, _reg, _eqp) \
879 EFX_CHECK_REG((_enp), (_reg)); \
880 EFSYS_BAR_READQ((_enp)->en_esbp, _reg ## _OFST, \
882 EFSYS_PROBE4(efx_bar_readq, const char *, #_reg, \
883 uint32_t, _reg ## _OFST, \
884 uint32_t, (_eqp)->eq_u32[1], \
885 uint32_t, (_eqp)->eq_u32[0]); \
886 _NOTE(CONSTANTCONDITION) \
889 #define EFX_BAR_WRITEQ(_enp, _reg, _eqp) \
891 EFX_CHECK_REG((_enp), (_reg)); \
892 EFSYS_PROBE4(efx_bar_writeq, const char *, #_reg, \
893 uint32_t, _reg ## _OFST, \
894 uint32_t, (_eqp)->eq_u32[1], \
895 uint32_t, (_eqp)->eq_u32[0]); \
896 EFSYS_BAR_WRITEQ((_enp)->en_esbp, _reg ## _OFST, \
898 _NOTE(CONSTANTCONDITION) \
901 #define EFX_BAR_READO(_enp, _reg, _eop) \
903 EFX_CHECK_REG((_enp), (_reg)); \
904 EFSYS_BAR_READO((_enp)->en_esbp, _reg ## _OFST, \
906 EFSYS_PROBE6(efx_bar_reado, const char *, #_reg, \
907 uint32_t, _reg ## _OFST, \
908 uint32_t, (_eop)->eo_u32[3], \
909 uint32_t, (_eop)->eo_u32[2], \
910 uint32_t, (_eop)->eo_u32[1], \
911 uint32_t, (_eop)->eo_u32[0]); \
912 _NOTE(CONSTANTCONDITION) \
915 #define EFX_BAR_WRITEO(_enp, _reg, _eop) \
917 EFX_CHECK_REG((_enp), (_reg)); \
918 EFSYS_PROBE6(efx_bar_writeo, const char *, #_reg, \
919 uint32_t, _reg ## _OFST, \
920 uint32_t, (_eop)->eo_u32[3], \
921 uint32_t, (_eop)->eo_u32[2], \
922 uint32_t, (_eop)->eo_u32[1], \
923 uint32_t, (_eop)->eo_u32[0]); \
924 EFSYS_BAR_WRITEO((_enp)->en_esbp, _reg ## _OFST, \
926 _NOTE(CONSTANTCONDITION) \
929 #define EFX_BAR_TBL_READD(_enp, _reg, _index, _edp, _lock) \
931 EFX_CHECK_REG((_enp), (_reg)); \
932 EFSYS_BAR_READD((_enp)->en_esbp, \
933 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
935 EFSYS_PROBE4(efx_bar_tbl_readd, const char *, #_reg, \
936 uint32_t, (_index), \
937 uint32_t, _reg ## _OFST, \
938 uint32_t, (_edp)->ed_u32[0]); \
939 _NOTE(CONSTANTCONDITION) \
942 #define EFX_BAR_TBL_WRITED(_enp, _reg, _index, _edp, _lock) \
944 EFX_CHECK_REG((_enp), (_reg)); \
945 EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg, \
946 uint32_t, (_index), \
947 uint32_t, _reg ## _OFST, \
948 uint32_t, (_edp)->ed_u32[0]); \
949 EFSYS_BAR_WRITED((_enp)->en_esbp, \
950 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
952 _NOTE(CONSTANTCONDITION) \
955 #define EFX_BAR_TBL_WRITED2(_enp, _reg, _index, _edp, _lock) \
957 EFX_CHECK_REG((_enp), (_reg)); \
958 EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg, \
959 uint32_t, (_index), \
960 uint32_t, _reg ## _OFST, \
961 uint32_t, (_edp)->ed_u32[0]); \
962 EFSYS_BAR_WRITED((_enp)->en_esbp, \
964 (2 * sizeof (efx_dword_t)) + \
965 ((_index) * _reg ## _STEP)), \
967 _NOTE(CONSTANTCONDITION) \
970 #define EFX_BAR_TBL_WRITED3(_enp, _reg, _index, _edp, _lock) \
972 EFX_CHECK_REG((_enp), (_reg)); \
973 EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg, \
974 uint32_t, (_index), \
975 uint32_t, _reg ## _OFST, \
976 uint32_t, (_edp)->ed_u32[0]); \
977 EFSYS_BAR_WRITED((_enp)->en_esbp, \
979 (3 * sizeof (efx_dword_t)) + \
980 ((_index) * _reg ## _STEP)), \
982 _NOTE(CONSTANTCONDITION) \
985 #define EFX_BAR_TBL_READQ(_enp, _reg, _index, _eqp) \
987 EFX_CHECK_REG((_enp), (_reg)); \
988 EFSYS_BAR_READQ((_enp)->en_esbp, \
989 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
991 EFSYS_PROBE5(efx_bar_tbl_readq, const char *, #_reg, \
992 uint32_t, (_index), \
993 uint32_t, _reg ## _OFST, \
994 uint32_t, (_eqp)->eq_u32[1], \
995 uint32_t, (_eqp)->eq_u32[0]); \
996 _NOTE(CONSTANTCONDITION) \
999 #define EFX_BAR_TBL_WRITEQ(_enp, _reg, _index, _eqp) \
1001 EFX_CHECK_REG((_enp), (_reg)); \
1002 EFSYS_PROBE5(efx_bar_tbl_writeq, const char *, #_reg, \
1003 uint32_t, (_index), \
1004 uint32_t, _reg ## _OFST, \
1005 uint32_t, (_eqp)->eq_u32[1], \
1006 uint32_t, (_eqp)->eq_u32[0]); \
1007 EFSYS_BAR_WRITEQ((_enp)->en_esbp, \
1008 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1010 _NOTE(CONSTANTCONDITION) \
1013 #define EFX_BAR_TBL_READO(_enp, _reg, _index, _eop, _lock) \
1015 EFX_CHECK_REG((_enp), (_reg)); \
1016 EFSYS_BAR_READO((_enp)->en_esbp, \
1017 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1019 EFSYS_PROBE7(efx_bar_tbl_reado, const char *, #_reg, \
1020 uint32_t, (_index), \
1021 uint32_t, _reg ## _OFST, \
1022 uint32_t, (_eop)->eo_u32[3], \
1023 uint32_t, (_eop)->eo_u32[2], \
1024 uint32_t, (_eop)->eo_u32[1], \
1025 uint32_t, (_eop)->eo_u32[0]); \
1026 _NOTE(CONSTANTCONDITION) \
1029 #define EFX_BAR_TBL_WRITEO(_enp, _reg, _index, _eop, _lock) \
1031 EFX_CHECK_REG((_enp), (_reg)); \
1032 EFSYS_PROBE7(efx_bar_tbl_writeo, const char *, #_reg, \
1033 uint32_t, (_index), \
1034 uint32_t, _reg ## _OFST, \
1035 uint32_t, (_eop)->eo_u32[3], \
1036 uint32_t, (_eop)->eo_u32[2], \
1037 uint32_t, (_eop)->eo_u32[1], \
1038 uint32_t, (_eop)->eo_u32[0]); \
1039 EFSYS_BAR_WRITEO((_enp)->en_esbp, \
1040 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1042 _NOTE(CONSTANTCONDITION) \
1046 * Allow drivers to perform optimised 128-bit doorbell writes.
1047 * The DMA descriptor pointers (RX_DESC_UPD and TX_DESC_UPD) are
1048 * special-cased in the BIU on the Falcon/Siena and EF10 architectures to avoid
1049 * the need for locking in the host, and are the only ones known to be safe to
1050 * use 128-bites write with.
1052 #define EFX_BAR_TBL_DOORBELL_WRITEO(_enp, _reg, _index, _eop) \
1054 EFX_CHECK_REG((_enp), (_reg)); \
1055 EFSYS_PROBE7(efx_bar_tbl_doorbell_writeo, \
1058 uint32_t, (_index), \
1059 uint32_t, _reg ## _OFST, \
1060 uint32_t, (_eop)->eo_u32[3], \
1061 uint32_t, (_eop)->eo_u32[2], \
1062 uint32_t, (_eop)->eo_u32[1], \
1063 uint32_t, (_eop)->eo_u32[0]); \
1064 EFSYS_BAR_DOORBELL_WRITEO((_enp)->en_esbp, \
1065 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1067 _NOTE(CONSTANTCONDITION) \
1070 #define EFX_DMA_SYNC_QUEUE_FOR_DEVICE(_esmp, _entries, _wptr, _owptr) \
1072 unsigned int _new = (_wptr); \
1073 unsigned int _old = (_owptr); \
1075 if ((_new) >= (_old)) \
1076 EFSYS_DMA_SYNC_FOR_DEVICE((_esmp), \
1077 (_old) * sizeof (efx_desc_t), \
1078 ((_new) - (_old)) * sizeof (efx_desc_t)); \
1081 * It is cheaper to sync entire map than sync \
1082 * two parts especially when offset/size are \
1083 * ignored and entire map is synced in any case.\
1085 EFSYS_DMA_SYNC_FOR_DEVICE((_esmp), \
1087 (_entries) * sizeof (efx_desc_t)); \
1088 _NOTE(CONSTANTCONDITION) \
1091 extern __checkReturn efx_rc_t
1093 __in efx_nic_t *enp);
1095 extern __checkReturn efx_rc_t
1097 __in efx_nic_t *enp);
1100 efx_mac_multicast_hash_compute(
1101 __in_ecount(6*count) uint8_t const *addrs,
1103 __out efx_oword_t *hash_low,
1104 __out efx_oword_t *hash_high);
1106 extern __checkReturn efx_rc_t
1108 __in efx_nic_t *enp);
1112 __in efx_nic_t *enp);
1116 /* VPD utility functions */
1118 extern __checkReturn efx_rc_t
1119 efx_vpd_hunk_length(
1120 __in_bcount(size) caddr_t data,
1122 __out size_t *lengthp);
1124 extern __checkReturn efx_rc_t
1125 efx_vpd_hunk_verify(
1126 __in_bcount(size) caddr_t data,
1128 __out_opt boolean_t *cksummedp);
1130 extern __checkReturn efx_rc_t
1131 efx_vpd_hunk_reinit(
1132 __in_bcount(size) caddr_t data,
1134 __in boolean_t wantpid);
1136 extern __checkReturn efx_rc_t
1138 __in_bcount(size) caddr_t data,
1140 __in efx_vpd_tag_t tag,
1141 __in efx_vpd_keyword_t keyword,
1142 __out unsigned int *payloadp,
1143 __out uint8_t *paylenp);
1145 extern __checkReturn efx_rc_t
1147 __in_bcount(size) caddr_t data,
1149 __out efx_vpd_tag_t *tagp,
1150 __out efx_vpd_keyword_t *keyword,
1151 __out_opt unsigned int *payloadp,
1152 __out_opt uint8_t *paylenp,
1153 __inout unsigned int *contp);
1155 extern __checkReturn efx_rc_t
1157 __in_bcount(size) caddr_t data,
1159 __in efx_vpd_value_t *evvp);
1161 #endif /* EFSYS_OPT_VPD */
1165 extern efx_sram_pattern_fn_t __efx_sram_pattern_fns[];
1167 typedef struct efx_register_set_s {
1168 unsigned int address;
1172 } efx_register_set_t;
1174 extern __checkReturn efx_rc_t
1175 efx_nic_test_registers(
1176 __in efx_nic_t *enp,
1177 __in efx_register_set_t *rsp,
1180 extern __checkReturn efx_rc_t
1181 efx_nic_test_tables(
1182 __in efx_nic_t *enp,
1183 __in efx_register_set_t *rsp,
1184 __in efx_pattern_type_t pattern,
1187 #endif /* EFSYS_OPT_DIAG */
1191 extern __checkReturn efx_rc_t
1192 efx_mcdi_set_workaround(
1193 __in efx_nic_t *enp,
1195 __in boolean_t enabled,
1196 __out_opt uint32_t *flagsp);
1198 extern __checkReturn efx_rc_t
1199 efx_mcdi_get_workarounds(
1200 __in efx_nic_t *enp,
1201 __out_opt uint32_t *implementedp,
1202 __out_opt uint32_t *enabledp);
1204 #endif /* EFSYS_OPT_MCDI */
1210 #endif /* _SYS_EFX_IMPL_H */