1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2020 Xilinx, Inc.
4 * Copyright(c) 2007-2019 Solarflare Communications Inc.
7 #ifndef _SYS_EFX_IMPL_H
8 #define _SYS_EFX_IMPL_H
12 #include "efx_regs_ef10.h"
13 #include "efx_regs_ef100.h"
16 #endif /* EFSYS_OPT_MCDI */
18 /* FIXME: Add definition for driver generated software events */
19 #ifndef ESE_DZ_EV_CODE_DRV_GEN_EV
20 #define ESE_DZ_EV_CODE_DRV_GEN_EV FSE_AZ_EV_CODE_DRV_GEN_EV
25 #include "siena_impl.h"
26 #endif /* EFSYS_OPT_SIENA */
28 #if EFSYS_OPT_HUNTINGTON
29 #include "hunt_impl.h"
30 #endif /* EFSYS_OPT_HUNTINGTON */
33 #include "medford_impl.h"
34 #endif /* EFSYS_OPT_MEDFORD */
36 #if EFSYS_OPT_MEDFORD2
37 #include "medford2_impl.h"
38 #endif /* EFSYS_OPT_MEDFORD2 */
40 #if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
41 #include "ef10_impl.h"
42 #endif /* EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10() */
44 #if EFSYS_OPT_RIVERHEAD
45 #include "rhead_impl.h"
46 #endif /* EFSYS_OPT_RIVERHEAD */
52 #define EFX_MOD_MCDI 0x00000001
53 #define EFX_MOD_PROBE 0x00000002
54 #define EFX_MOD_NVRAM 0x00000004
55 #define EFX_MOD_VPD 0x00000008
56 #define EFX_MOD_NIC 0x00000010
57 #define EFX_MOD_INTR 0x00000020
58 #define EFX_MOD_EV 0x00000040
59 #define EFX_MOD_RX 0x00000080
60 #define EFX_MOD_TX 0x00000100
61 #define EFX_MOD_PORT 0x00000200
62 #define EFX_MOD_MON 0x00000400
63 #define EFX_MOD_FILTER 0x00001000
64 #define EFX_MOD_LIC 0x00002000
65 #define EFX_MOD_TUNNEL 0x00004000
66 #define EFX_MOD_EVB 0x00008000
67 #define EFX_MOD_PROXY 0x00010000
69 #define EFX_RESET_PHY 0x00000001
70 #define EFX_RESET_RXQ_ERR 0x00000002
71 #define EFX_RESET_TXQ_ERR 0x00000004
72 #define EFX_RESET_HW_UNAVAIL 0x00000008
74 typedef enum efx_mac_type_e {
83 typedef struct efx_ev_ops_s {
84 efx_rc_t (*eevo_init)(efx_nic_t *);
85 void (*eevo_fini)(efx_nic_t *);
86 efx_rc_t (*eevo_qcreate)(efx_nic_t *, unsigned int,
87 efsys_mem_t *, size_t, uint32_t,
88 uint32_t, uint32_t, efx_evq_t *);
89 void (*eevo_qdestroy)(efx_evq_t *);
90 efx_rc_t (*eevo_qprime)(efx_evq_t *, unsigned int);
91 void (*eevo_qpost)(efx_evq_t *, uint16_t);
92 void (*eevo_qpoll)(efx_evq_t *, unsigned int *,
93 const efx_ev_callbacks_t *, void *);
94 efx_rc_t (*eevo_qmoderate)(efx_evq_t *, unsigned int);
96 void (*eevo_qstats_update)(efx_evq_t *, efsys_stat_t *);
100 typedef struct efx_tx_ops_s {
101 efx_rc_t (*etxo_init)(efx_nic_t *);
102 void (*etxo_fini)(efx_nic_t *);
103 efx_rc_t (*etxo_qcreate)(efx_nic_t *,
104 unsigned int, unsigned int,
105 efsys_mem_t *, size_t,
107 efx_evq_t *, efx_txq_t *,
109 void (*etxo_qdestroy)(efx_txq_t *);
110 efx_rc_t (*etxo_qpost)(efx_txq_t *, efx_buffer_t *,
111 unsigned int, unsigned int,
113 void (*etxo_qpush)(efx_txq_t *, unsigned int, unsigned int);
114 efx_rc_t (*etxo_qpace)(efx_txq_t *, unsigned int);
115 efx_rc_t (*etxo_qflush)(efx_txq_t *);
116 void (*etxo_qenable)(efx_txq_t *);
117 efx_rc_t (*etxo_qpio_enable)(efx_txq_t *);
118 void (*etxo_qpio_disable)(efx_txq_t *);
119 efx_rc_t (*etxo_qpio_write)(efx_txq_t *, uint8_t *, size_t,
121 efx_rc_t (*etxo_qpio_post)(efx_txq_t *, size_t, unsigned int,
123 efx_rc_t (*etxo_qdesc_post)(efx_txq_t *, efx_desc_t *,
124 unsigned int, unsigned int,
126 void (*etxo_qdesc_dma_create)(efx_txq_t *, efsys_dma_addr_t,
129 void (*etxo_qdesc_tso_create)(efx_txq_t *, uint16_t,
132 void (*etxo_qdesc_tso2_create)(efx_txq_t *, uint16_t,
133 uint16_t, uint32_t, uint16_t,
135 void (*etxo_qdesc_vlantci_create)(efx_txq_t *, uint16_t,
137 void (*etxo_qdesc_checksum_create)(efx_txq_t *, uint16_t,
140 void (*etxo_qstats_update)(efx_txq_t *,
145 typedef union efx_rxq_type_data_u {
149 #if EFSYS_OPT_RX_PACKED_STREAM
151 uint32_t eps_buf_size;
152 } ertd_packed_stream;
154 #if EFSYS_OPT_RX_ES_SUPER_BUFFER
156 uint32_t eessb_bufs_per_desc;
157 uint32_t eessb_max_dma_len;
158 uint32_t eessb_buf_stride;
159 uint32_t eessb_hol_block_timeout;
160 } ertd_es_super_buffer;
162 } efx_rxq_type_data_t;
164 typedef struct efx_rx_ops_s {
165 efx_rc_t (*erxo_init)(efx_nic_t *);
166 void (*erxo_fini)(efx_nic_t *);
167 #if EFSYS_OPT_RX_SCATTER
168 efx_rc_t (*erxo_scatter_enable)(efx_nic_t *, unsigned int);
170 #if EFSYS_OPT_RX_SCALE
171 efx_rc_t (*erxo_scale_context_alloc)(efx_nic_t *,
172 efx_rx_scale_context_type_t,
173 uint32_t, uint32_t *);
174 efx_rc_t (*erxo_scale_context_free)(efx_nic_t *, uint32_t);
175 efx_rc_t (*erxo_scale_mode_set)(efx_nic_t *, uint32_t,
177 efx_rx_hash_type_t, boolean_t);
178 efx_rc_t (*erxo_scale_key_set)(efx_nic_t *, uint32_t,
180 efx_rc_t (*erxo_scale_tbl_set)(efx_nic_t *, uint32_t,
181 unsigned int *, size_t);
182 uint32_t (*erxo_prefix_hash)(efx_nic_t *, efx_rx_hash_alg_t,
184 #endif /* EFSYS_OPT_RX_SCALE */
185 efx_rc_t (*erxo_prefix_pktlen)(efx_nic_t *, uint8_t *,
187 void (*erxo_qpost)(efx_rxq_t *, efsys_dma_addr_t *, size_t,
188 unsigned int, unsigned int,
190 void (*erxo_qpush)(efx_rxq_t *, unsigned int, unsigned int *);
191 #if EFSYS_OPT_RX_PACKED_STREAM
192 void (*erxo_qpush_ps_credits)(efx_rxq_t *);
193 uint8_t * (*erxo_qps_packet_info)(efx_rxq_t *, uint8_t *,
195 uint16_t *, uint32_t *, uint32_t *);
197 efx_rc_t (*erxo_qflush)(efx_rxq_t *);
198 void (*erxo_qenable)(efx_rxq_t *);
199 efx_rc_t (*erxo_qcreate)(efx_nic_t *enp, unsigned int,
200 unsigned int, efx_rxq_type_t,
201 const efx_rxq_type_data_t *,
202 efsys_mem_t *, size_t, uint32_t,
204 efx_evq_t *, efx_rxq_t *);
205 void (*erxo_qdestroy)(efx_rxq_t *);
208 typedef struct efx_mac_ops_s {
209 efx_rc_t (*emo_poll)(efx_nic_t *, efx_link_mode_t *);
210 efx_rc_t (*emo_up)(efx_nic_t *, boolean_t *);
211 efx_rc_t (*emo_addr_set)(efx_nic_t *);
212 efx_rc_t (*emo_pdu_set)(efx_nic_t *);
213 efx_rc_t (*emo_pdu_get)(efx_nic_t *, size_t *);
214 efx_rc_t (*emo_reconfigure)(efx_nic_t *);
215 efx_rc_t (*emo_multicast_list_set)(efx_nic_t *);
216 efx_rc_t (*emo_filter_default_rxq_set)(efx_nic_t *,
217 efx_rxq_t *, boolean_t);
218 void (*emo_filter_default_rxq_clear)(efx_nic_t *);
219 #if EFSYS_OPT_LOOPBACK
220 efx_rc_t (*emo_loopback_set)(efx_nic_t *, efx_link_mode_t,
221 efx_loopback_type_t);
222 #endif /* EFSYS_OPT_LOOPBACK */
223 #if EFSYS_OPT_MAC_STATS
224 efx_rc_t (*emo_stats_get_mask)(efx_nic_t *, uint32_t *, size_t);
225 efx_rc_t (*emo_stats_clear)(efx_nic_t *);
226 efx_rc_t (*emo_stats_upload)(efx_nic_t *, efsys_mem_t *);
227 efx_rc_t (*emo_stats_periodic)(efx_nic_t *, efsys_mem_t *,
228 uint16_t, boolean_t);
229 efx_rc_t (*emo_stats_update)(efx_nic_t *, efsys_mem_t *,
230 efsys_stat_t *, uint32_t *);
231 #endif /* EFSYS_OPT_MAC_STATS */
234 typedef struct efx_phy_ops_s {
235 efx_rc_t (*epo_power)(efx_nic_t *, boolean_t); /* optional */
236 efx_rc_t (*epo_reset)(efx_nic_t *);
237 efx_rc_t (*epo_reconfigure)(efx_nic_t *);
238 efx_rc_t (*epo_verify)(efx_nic_t *);
239 efx_rc_t (*epo_oui_get)(efx_nic_t *, uint32_t *);
240 efx_rc_t (*epo_link_state_get)(efx_nic_t *, efx_phy_link_state_t *);
241 #if EFSYS_OPT_PHY_STATS
242 efx_rc_t (*epo_stats_update)(efx_nic_t *, efsys_mem_t *,
244 #endif /* EFSYS_OPT_PHY_STATS */
246 efx_rc_t (*epo_bist_enable_offline)(efx_nic_t *);
247 efx_rc_t (*epo_bist_start)(efx_nic_t *, efx_bist_type_t);
248 efx_rc_t (*epo_bist_poll)(efx_nic_t *, efx_bist_type_t,
249 efx_bist_result_t *, uint32_t *,
250 unsigned long *, size_t);
251 void (*epo_bist_stop)(efx_nic_t *, efx_bist_type_t);
252 #endif /* EFSYS_OPT_BIST */
258 * Policy for replacing existing filter when inserting a new one.
259 * Note that all policies allow for storing the new lower priority
260 * filters as overridden by existing higher priority ones. It is needed
261 * to restore the lower priority filters on higher priority ones removal.
263 typedef enum efx_filter_replacement_policy_e {
264 /* Cannot replace existing filter */
265 EFX_FILTER_REPLACEMENT_NEVER,
266 /* Higher priority filters can replace lower priotiry ones */
267 EFX_FILTER_REPLACEMENT_HIGHER_PRIORITY,
269 * Higher priority filters can replace lower priority ones and
270 * equal priority filters can replace each other.
272 EFX_FILTER_REPLACEMENT_HIGHER_OR_EQUAL_PRIORITY,
273 } efx_filter_replacement_policy_t;
275 typedef struct efx_filter_ops_s {
276 efx_rc_t (*efo_init)(efx_nic_t *);
277 void (*efo_fini)(efx_nic_t *);
278 efx_rc_t (*efo_restore)(efx_nic_t *);
279 efx_rc_t (*efo_add)(efx_nic_t *, efx_filter_spec_t *,
280 efx_filter_replacement_policy_t policy);
281 efx_rc_t (*efo_delete)(efx_nic_t *, efx_filter_spec_t *);
282 efx_rc_t (*efo_supported_filters)(efx_nic_t *, uint32_t *,
284 efx_rc_t (*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
285 boolean_t, boolean_t, boolean_t,
286 uint8_t const *, uint32_t);
290 extern __checkReturn efx_rc_t
291 efx_filter_reconfigure(
293 __in_ecount(6) uint8_t const *mac_addr,
294 __in boolean_t all_unicst,
295 __in boolean_t mulcst,
296 __in boolean_t all_mulcst,
297 __in boolean_t brdcst,
298 __in_ecount(6*count) uint8_t const *addrs,
299 __in uint32_t count);
301 #endif /* EFSYS_OPT_FILTER */
304 typedef struct efx_tunnel_ops_s {
305 boolean_t (*eto_udp_encap_supported)(efx_nic_t *);
306 efx_rc_t (*eto_reconfigure)(efx_nic_t *);
308 #endif /* EFSYS_OPT_TUNNEL */
310 typedef struct efx_port_s {
311 efx_mac_type_t ep_mac_type;
312 uint32_t ep_phy_type;
315 uint8_t ep_mac_addr[6];
316 efx_link_mode_t ep_link_mode;
317 boolean_t ep_all_unicst;
318 boolean_t ep_all_unicst_inserted;
320 boolean_t ep_all_mulcst;
321 boolean_t ep_all_mulcst_inserted;
323 unsigned int ep_fcntl;
324 boolean_t ep_fcntl_autoneg;
325 efx_oword_t ep_multicst_hash[2];
326 uint8_t ep_mulcst_addr_list[EFX_MAC_ADDR_LEN *
327 EFX_MAC_MULTICAST_LIST_MAX];
328 uint32_t ep_mulcst_addr_count;
329 #if EFSYS_OPT_LOOPBACK
330 efx_loopback_type_t ep_loopback_type;
331 efx_link_mode_t ep_loopback_link_mode;
332 #endif /* EFSYS_OPT_LOOPBACK */
333 #if EFSYS_OPT_PHY_FLAGS
334 uint32_t ep_phy_flags;
335 #endif /* EFSYS_OPT_PHY_FLAGS */
336 #if EFSYS_OPT_PHY_LED_CONTROL
337 efx_phy_led_mode_t ep_phy_led_mode;
338 #endif /* EFSYS_OPT_PHY_LED_CONTROL */
339 efx_phy_media_type_t ep_fixed_port_type;
340 efx_phy_media_type_t ep_module_type;
341 uint32_t ep_adv_cap_mask;
342 uint32_t ep_lp_cap_mask;
343 uint32_t ep_default_adv_cap_mask;
344 uint32_t ep_phy_cap_mask;
345 boolean_t ep_mac_drain;
347 efx_bist_type_t ep_current_bist;
349 const efx_mac_ops_t *ep_emop;
350 const efx_phy_ops_t *ep_epop;
353 typedef struct efx_mon_ops_s {
354 #if EFSYS_OPT_MON_STATS
355 efx_rc_t (*emo_stats_update)(efx_nic_t *, efsys_mem_t *,
356 efx_mon_stat_value_t *);
357 efx_rc_t (*emo_limits_update)(efx_nic_t *,
358 efx_mon_stat_limits_t *);
359 #endif /* EFSYS_OPT_MON_STATS */
362 typedef struct efx_mon_s {
363 efx_mon_type_t em_type;
364 const efx_mon_ops_t *em_emop;
367 typedef struct efx_intr_ops_s {
368 efx_rc_t (*eio_init)(efx_nic_t *, efx_intr_type_t, efsys_mem_t *);
369 void (*eio_enable)(efx_nic_t *);
370 void (*eio_disable)(efx_nic_t *);
371 void (*eio_disable_unlocked)(efx_nic_t *);
372 efx_rc_t (*eio_trigger)(efx_nic_t *, unsigned int);
373 void (*eio_status_line)(efx_nic_t *, boolean_t *, uint32_t *);
374 void (*eio_status_message)(efx_nic_t *, unsigned int,
376 void (*eio_fatal)(efx_nic_t *);
377 void (*eio_fini)(efx_nic_t *);
380 typedef struct efx_intr_s {
381 const efx_intr_ops_t *ei_eiop;
382 efsys_mem_t *ei_esmp;
383 efx_intr_type_t ei_type;
384 unsigned int ei_level;
387 typedef struct efx_nic_ops_s {
388 efx_rc_t (*eno_probe)(efx_nic_t *);
389 efx_rc_t (*eno_board_cfg)(efx_nic_t *);
390 efx_rc_t (*eno_set_drv_limits)(efx_nic_t *, efx_drv_limits_t*);
391 efx_rc_t (*eno_reset)(efx_nic_t *);
392 efx_rc_t (*eno_init)(efx_nic_t *);
393 efx_rc_t (*eno_get_vi_pool)(efx_nic_t *, uint32_t *);
394 efx_rc_t (*eno_get_bar_region)(efx_nic_t *, efx_nic_region_t,
395 uint32_t *, size_t *);
396 boolean_t (*eno_hw_unavailable)(efx_nic_t *);
397 void (*eno_set_hw_unavailable)(efx_nic_t *);
399 efx_rc_t (*eno_register_test)(efx_nic_t *);
400 #endif /* EFSYS_OPT_DIAG */
401 void (*eno_fini)(efx_nic_t *);
402 void (*eno_unprobe)(efx_nic_t *);
405 #ifndef EFX_TXQ_LIMIT_TARGET
406 #define EFX_TXQ_LIMIT_TARGET 259
408 #ifndef EFX_RXQ_LIMIT_TARGET
409 #define EFX_RXQ_LIMIT_TARGET 512
417 typedef struct siena_filter_spec_s {
420 uint32_t sfs_dmaq_id;
421 uint32_t sfs_dword[3];
422 } siena_filter_spec_t;
424 typedef enum siena_filter_type_e {
425 EFX_SIENA_FILTER_RX_TCP_FULL, /* TCP/IPv4 {dIP,dTCP,sIP,sTCP} */
426 EFX_SIENA_FILTER_RX_TCP_WILD, /* TCP/IPv4 {dIP,dTCP, -, -} */
427 EFX_SIENA_FILTER_RX_UDP_FULL, /* UDP/IPv4 {dIP,dUDP,sIP,sUDP} */
428 EFX_SIENA_FILTER_RX_UDP_WILD, /* UDP/IPv4 {dIP,dUDP, -, -} */
429 EFX_SIENA_FILTER_RX_MAC_FULL, /* Ethernet {dMAC,VLAN} */
430 EFX_SIENA_FILTER_RX_MAC_WILD, /* Ethernet {dMAC, -} */
432 EFX_SIENA_FILTER_TX_TCP_FULL, /* TCP/IPv4 {dIP,dTCP,sIP,sTCP} */
433 EFX_SIENA_FILTER_TX_TCP_WILD, /* TCP/IPv4 { -, -,sIP,sTCP} */
434 EFX_SIENA_FILTER_TX_UDP_FULL, /* UDP/IPv4 {dIP,dTCP,sIP,sTCP} */
435 EFX_SIENA_FILTER_TX_UDP_WILD, /* UDP/IPv4 { -, -,sIP,sUDP} */
436 EFX_SIENA_FILTER_TX_MAC_FULL, /* Ethernet {sMAC,VLAN} */
437 EFX_SIENA_FILTER_TX_MAC_WILD, /* Ethernet {sMAC, -} */
439 EFX_SIENA_FILTER_NTYPES
440 } siena_filter_type_t;
442 typedef enum siena_filter_tbl_id_e {
443 EFX_SIENA_FILTER_TBL_RX_IP = 0,
444 EFX_SIENA_FILTER_TBL_RX_MAC,
445 EFX_SIENA_FILTER_TBL_TX_IP,
446 EFX_SIENA_FILTER_TBL_TX_MAC,
447 EFX_SIENA_FILTER_NTBLS
448 } siena_filter_tbl_id_t;
450 typedef struct siena_filter_tbl_s {
451 int sft_size; /* number of entries */
452 int sft_used; /* active count */
453 uint32_t *sft_bitmap; /* active bitmap */
454 siena_filter_spec_t *sft_spec; /* array of saved specs */
455 } siena_filter_tbl_t;
457 typedef struct siena_filter_s {
458 siena_filter_tbl_t sf_tbl[EFX_SIENA_FILTER_NTBLS];
459 unsigned int sf_depth[EFX_SIENA_FILTER_NTYPES];
462 #endif /* EFSYS_OPT_SIENA */
464 typedef struct efx_filter_s {
466 siena_filter_t *ef_siena_filter;
467 #endif /* EFSYS_OPT_SIENA */
468 #if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
469 ef10_filter_table_t *ef_ef10_filter_table;
470 #endif /* EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10() */
477 siena_filter_tbl_clear(
479 __in siena_filter_tbl_id_t tbl);
481 #endif /* EFSYS_OPT_SIENA */
483 #endif /* EFSYS_OPT_FILTER */
487 #define EFX_TUNNEL_MAXNENTRIES (16)
491 typedef struct efx_tunnel_udp_entry_s {
492 uint16_t etue_port; /* host/cpu-endian */
493 uint16_t etue_protocol;
494 } efx_tunnel_udp_entry_t;
496 typedef struct efx_tunnel_cfg_s {
497 efx_tunnel_udp_entry_t etc_udp_entries[EFX_TUNNEL_MAXNENTRIES];
498 unsigned int etc_udp_entries_num;
501 #endif /* EFSYS_OPT_TUNNEL */
503 typedef struct efx_mcdi_ops_s {
504 efx_rc_t (*emco_init)(efx_nic_t *, const efx_mcdi_transport_t *);
505 void (*emco_send_request)(efx_nic_t *, void *, size_t,
507 efx_rc_t (*emco_poll_reboot)(efx_nic_t *);
508 boolean_t (*emco_poll_response)(efx_nic_t *);
509 void (*emco_read_response)(efx_nic_t *, void *, size_t, size_t);
510 void (*emco_fini)(efx_nic_t *);
511 efx_rc_t (*emco_feature_supported)(efx_nic_t *,
512 efx_mcdi_feature_id_t, boolean_t *);
513 void (*emco_get_timeout)(efx_nic_t *, efx_mcdi_req_t *,
517 typedef struct efx_mcdi_s {
518 const efx_mcdi_ops_t *em_emcop;
519 const efx_mcdi_transport_t *em_emtp;
520 efx_mcdi_iface_t em_emip;
523 #endif /* EFSYS_OPT_MCDI */
527 /* Invalid partition ID for en_nvram_partn_locked field of efx_nc_t */
528 #define EFX_NVRAM_PARTN_INVALID (0xffffffffu)
530 typedef struct efx_nvram_ops_s {
532 efx_rc_t (*envo_test)(efx_nic_t *);
533 #endif /* EFSYS_OPT_DIAG */
534 efx_rc_t (*envo_type_to_partn)(efx_nic_t *, efx_nvram_type_t,
536 efx_rc_t (*envo_partn_info)(efx_nic_t *, uint32_t,
538 efx_rc_t (*envo_partn_rw_start)(efx_nic_t *, uint32_t, size_t *);
539 efx_rc_t (*envo_partn_read)(efx_nic_t *, uint32_t,
540 unsigned int, caddr_t, size_t);
541 efx_rc_t (*envo_partn_read_backup)(efx_nic_t *, uint32_t,
542 unsigned int, caddr_t, size_t);
543 efx_rc_t (*envo_partn_erase)(efx_nic_t *, uint32_t,
544 unsigned int, size_t);
545 efx_rc_t (*envo_partn_write)(efx_nic_t *, uint32_t,
546 unsigned int, caddr_t, size_t);
547 efx_rc_t (*envo_partn_rw_finish)(efx_nic_t *, uint32_t,
549 efx_rc_t (*envo_partn_get_version)(efx_nic_t *, uint32_t,
550 uint32_t *, uint16_t *);
551 efx_rc_t (*envo_partn_set_version)(efx_nic_t *, uint32_t,
553 efx_rc_t (*envo_buffer_validate)(uint32_t,
556 #endif /* EFSYS_OPT_NVRAM */
559 typedef struct efx_vpd_ops_s {
560 efx_rc_t (*evpdo_init)(efx_nic_t *);
561 efx_rc_t (*evpdo_size)(efx_nic_t *, size_t *);
562 efx_rc_t (*evpdo_read)(efx_nic_t *, caddr_t, size_t);
563 efx_rc_t (*evpdo_verify)(efx_nic_t *, caddr_t, size_t);
564 efx_rc_t (*evpdo_reinit)(efx_nic_t *, caddr_t, size_t);
565 efx_rc_t (*evpdo_get)(efx_nic_t *, caddr_t, size_t,
567 efx_rc_t (*evpdo_set)(efx_nic_t *, caddr_t, size_t,
569 efx_rc_t (*evpdo_next)(efx_nic_t *, caddr_t, size_t,
570 efx_vpd_value_t *, unsigned int *);
571 efx_rc_t (*evpdo_write)(efx_nic_t *, caddr_t, size_t);
572 void (*evpdo_fini)(efx_nic_t *);
574 #endif /* EFSYS_OPT_VPD */
576 #if EFSYS_OPT_VPD || EFSYS_OPT_NVRAM
579 extern __checkReturn efx_rc_t
580 efx_mcdi_nvram_partitions(
582 __out_bcount(size) caddr_t data,
584 __out unsigned int *npartnp);
587 extern __checkReturn efx_rc_t
588 efx_mcdi_nvram_metadata(
591 __out uint32_t *subtypep,
592 __out_ecount(4) uint16_t version[4],
593 __out_bcount_opt(size) char *descp,
597 extern __checkReturn efx_rc_t
601 __out efx_nvram_info_t *eni);
604 extern __checkReturn efx_rc_t
605 efx_mcdi_nvram_update_start(
607 __in uint32_t partn);
610 extern __checkReturn efx_rc_t
614 __in uint32_t offset,
615 __out_bcount(size) caddr_t data,
620 extern __checkReturn efx_rc_t
621 efx_mcdi_nvram_erase(
624 __in uint32_t offset,
628 extern __checkReturn efx_rc_t
629 efx_mcdi_nvram_write(
632 __in uint32_t offset,
633 __in_bcount(size) caddr_t data,
636 #define EFX_NVRAM_UPDATE_FLAGS_BACKGROUND 0x00000001
637 #define EFX_NVRAM_UPDATE_FLAGS_POLL 0x00000002
640 extern __checkReturn efx_rc_t
641 efx_mcdi_nvram_update_finish(
644 __in boolean_t reboot,
646 __out_opt uint32_t *verify_resultp);
651 extern __checkReturn efx_rc_t
654 __in uint32_t partn);
656 #endif /* EFSYS_OPT_DIAG */
658 #endif /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
660 #if EFSYS_OPT_LICENSING
662 typedef struct efx_lic_ops_s {
663 efx_rc_t (*elo_update_licenses)(efx_nic_t *);
664 efx_rc_t (*elo_get_key_stats)(efx_nic_t *, efx_key_stats_t *);
665 efx_rc_t (*elo_app_state)(efx_nic_t *, uint64_t, boolean_t *);
666 efx_rc_t (*elo_get_id)(efx_nic_t *, size_t, uint32_t *,
667 size_t *, uint8_t *);
668 efx_rc_t (*elo_find_start)
669 (efx_nic_t *, caddr_t, size_t, uint32_t *);
670 efx_rc_t (*elo_find_end)(efx_nic_t *, caddr_t, size_t,
671 uint32_t, uint32_t *);
672 boolean_t (*elo_find_key)(efx_nic_t *, caddr_t, size_t,
673 uint32_t, uint32_t *, uint32_t *);
674 boolean_t (*elo_validate_key)(efx_nic_t *,
676 efx_rc_t (*elo_read_key)(efx_nic_t *,
677 caddr_t, size_t, uint32_t, uint32_t,
678 caddr_t, size_t, uint32_t *);
679 efx_rc_t (*elo_write_key)(efx_nic_t *,
680 caddr_t, size_t, uint32_t,
681 caddr_t, uint32_t, uint32_t *);
682 efx_rc_t (*elo_delete_key)(efx_nic_t *,
683 caddr_t, size_t, uint32_t,
684 uint32_t, uint32_t, uint32_t *);
685 efx_rc_t (*elo_create_partition)(efx_nic_t *,
687 efx_rc_t (*elo_finish_partition)(efx_nic_t *,
695 struct efx_vswitch_s {
697 efx_vswitch_id_t ev_vswitch_id;
698 uint32_t ev_num_vports;
700 * Vport configuration array: index 0 to store PF configuration
701 * and next ev_num_vports-1 entries hold VFs configuration.
703 efx_vport_config_t *ev_evcp;
706 typedef struct efx_evb_ops_s {
707 efx_rc_t (*eeo_init)(efx_nic_t *);
708 void (*eeo_fini)(efx_nic_t *);
709 efx_rc_t (*eeo_vswitch_alloc)(efx_nic_t *, efx_vswitch_id_t *);
710 efx_rc_t (*eeo_vswitch_free)(efx_nic_t *, efx_vswitch_id_t);
711 efx_rc_t (*eeo_vport_alloc)(efx_nic_t *, efx_vswitch_id_t,
712 efx_vport_type_t, uint16_t,
713 boolean_t, efx_vport_id_t *);
714 efx_rc_t (*eeo_vport_free)(efx_nic_t *, efx_vswitch_id_t,
716 efx_rc_t (*eeo_vport_mac_addr_add)(efx_nic_t *, efx_vswitch_id_t,
717 efx_vport_id_t, uint8_t *);
718 efx_rc_t (*eeo_vport_mac_addr_del)(efx_nic_t *, efx_vswitch_id_t,
719 efx_vport_id_t, uint8_t *);
720 efx_rc_t (*eeo_vadaptor_alloc)(efx_nic_t *, efx_vswitch_id_t,
722 efx_rc_t (*eeo_vadaptor_free)(efx_nic_t *, efx_vswitch_id_t,
724 efx_rc_t (*eeo_vport_assign)(efx_nic_t *, efx_vswitch_id_t,
725 efx_vport_id_t, uint32_t);
726 efx_rc_t (*eeo_vport_reconfigure)(efx_nic_t *, efx_vswitch_id_t,
728 uint16_t *, uint8_t *,
730 efx_rc_t (*eeo_vport_stats)(efx_nic_t *, efx_vswitch_id_t,
731 efx_vport_id_t, efsys_mem_t *);
735 extern __checkReturn boolean_t
736 efx_is_zero_eth_addr(
737 __in_bcount(EFX_MAC_ADDR_LEN) const uint8_t *addrp);
739 #endif /* EFSYS_OPT_EVB */
741 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
743 #define EFX_PROXY_CONFIGURE_MAGIC 0xAB2015EF
746 typedef struct efx_proxy_ops_s {
747 efx_rc_t (*epo_init)(efx_nic_t *);
748 void (*epo_fini)(efx_nic_t *);
749 efx_rc_t (*epo_mc_config)(efx_nic_t *, efsys_mem_t *,
750 efsys_mem_t *, efsys_mem_t *,
751 uint32_t, uint32_t *, size_t);
752 efx_rc_t (*epo_disable)(efx_nic_t *);
753 efx_rc_t (*epo_privilege_modify)(efx_nic_t *, uint32_t, uint32_t,
754 uint32_t, uint32_t, uint32_t);
755 efx_rc_t (*epo_set_privilege_mask)(efx_nic_t *, uint32_t,
757 efx_rc_t (*epo_complete_request)(efx_nic_t *, uint32_t,
759 efx_rc_t (*epo_exec_cmd)(efx_nic_t *, efx_proxy_cmd_params_t *);
760 efx_rc_t (*epo_get_privilege_mask)(efx_nic_t *, uint32_t,
761 uint32_t, uint32_t *);
764 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
766 #define EFX_DRV_VER_MAX 20
768 typedef struct efx_drv_cfg_s {
769 uint32_t edc_min_vi_count;
770 uint32_t edc_max_vi_count;
772 uint32_t edc_max_piobuf_count;
773 uint32_t edc_pio_alloc_size;
778 efx_family_t en_family;
779 uint32_t en_features;
780 efsys_identifier_t *en_esip;
781 efsys_lock_t *en_eslp;
782 efsys_bar_t *en_esbp;
783 unsigned int en_mod_flags;
784 unsigned int en_reset_flags;
785 efx_nic_cfg_t en_nic_cfg;
786 efx_drv_cfg_t en_drv_cfg;
790 uint32_t en_ev_qcount;
791 uint32_t en_rx_qcount;
792 uint32_t en_tx_qcount;
793 const efx_nic_ops_t *en_enop;
794 const efx_ev_ops_t *en_eevop;
795 const efx_tx_ops_t *en_etxop;
796 const efx_rx_ops_t *en_erxop;
797 efx_fw_variant_t efv;
798 char en_drv_version[EFX_DRV_VER_MAX];
800 efx_filter_t en_filter;
801 const efx_filter_ops_t *en_efop;
802 #endif /* EFSYS_OPT_FILTER */
804 efx_tunnel_cfg_t en_tunnel_cfg;
805 const efx_tunnel_ops_t *en_etop;
806 #endif /* EFSYS_OPT_TUNNEL */
809 #endif /* EFSYS_OPT_MCDI */
811 uint32_t en_nvram_partn_locked;
812 const efx_nvram_ops_t *en_envop;
813 #endif /* EFSYS_OPT_NVRAM */
815 const efx_vpd_ops_t *en_evpdop;
816 #endif /* EFSYS_OPT_VPD */
817 #if EFSYS_OPT_RX_SCALE
818 efx_rx_hash_support_t en_hash_support;
819 efx_rx_scale_context_type_t en_rss_context_type;
820 uint32_t en_rss_context;
821 #endif /* EFSYS_OPT_RX_SCALE */
822 uint32_t en_vport_id;
823 #if EFSYS_OPT_LICENSING
824 const efx_lic_ops_t *en_elop;
825 boolean_t en_licensing_supported;
830 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
831 unsigned int enu_partn_mask;
832 #endif /* EFSYS_OPT_NVRAM || EFSYS_OPT_VPD */
835 size_t enu_svpd_length;
836 #endif /* EFSYS_OPT_VPD */
839 #endif /* EFSYS_OPT_SIENA */
842 #if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
850 size_t ena_svpd_length;
851 #endif /* EFSYS_OPT_VPD */
852 efx_piobuf_handle_t ena_piobuf_handle[EF10_MAX_PIOBUF_NBUFS];
853 uint32_t ena_piobuf_count;
854 uint32_t ena_pio_alloc_map[EF10_MAX_PIOBUF_NBUFS];
855 uint32_t ena_pio_write_vi_base;
856 /* Memory BAR mapping regions */
857 uint32_t ena_uc_mem_map_offset;
858 size_t ena_uc_mem_map_size;
859 uint32_t ena_wc_mem_map_offset;
860 size_t ena_wc_mem_map_size;
863 #endif /* EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10() */
865 const efx_evb_ops_t *en_eeop;
866 struct efx_vswitch_s *en_vswitchp;
867 #endif /* EFSYS_OPT_EVB */
868 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
869 const efx_proxy_ops_t *en_epop;
870 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
873 #define EFX_FAMILY_IS_EF10(_enp) \
874 ((_enp)->en_family == EFX_FAMILY_MEDFORD2 || \
875 (_enp)->en_family == EFX_FAMILY_MEDFORD || \
876 (_enp)->en_family == EFX_FAMILY_HUNTINGTON)
878 #define EFX_FAMILY_IS_EF100(_enp) \
879 ((_enp)->en_family == EFX_FAMILY_RIVERHEAD)
882 #define EFX_NIC_MAGIC 0x02121996
884 typedef boolean_t (*efx_ev_handler_t)(efx_evq_t *, efx_qword_t *,
885 const efx_ev_callbacks_t *, void *);
887 typedef struct efx_evq_rxq_state_s {
888 unsigned int eers_rx_read_ptr;
889 unsigned int eers_rx_mask;
890 #if EFSYS_OPT_RX_PACKED_STREAM || EFSYS_OPT_RX_ES_SUPER_BUFFER
891 unsigned int eers_rx_stream_npackets;
892 boolean_t eers_rx_packed_stream;
894 #if EFSYS_OPT_RX_PACKED_STREAM
895 unsigned int eers_rx_packed_stream_credits;
897 } efx_evq_rxq_state_t;
903 unsigned int ee_index;
904 unsigned int ee_mask;
905 efsys_mem_t *ee_esmp;
907 uint32_t ee_stat[EV_NQSTATS];
908 #endif /* EFSYS_OPT_QSTATS */
910 efx_ev_handler_t ee_rx;
911 efx_ev_handler_t ee_tx;
912 efx_ev_handler_t ee_driver;
913 efx_ev_handler_t ee_global;
914 efx_ev_handler_t ee_drv_gen;
916 efx_ev_handler_t ee_mcdi;
917 #endif /* EFSYS_OPT_MCDI */
919 efx_evq_rxq_state_t ee_rxq_state[EFX_EV_RX_NLABELS];
922 #define EFX_EVQ_MAGIC 0x08081997
924 #define EFX_EVQ_SIENA_TIMER_QUANTUM_NS 6144 /* 768 cycles */
927 #define EFX_EV_QSTAT_INCR(_eep, _stat) \
929 (_eep)->ee_stat[_stat]++; \
930 _NOTE(CONSTANTCONDITION) \
933 #define EFX_EV_QSTAT_INCR(_eep, _stat)
940 unsigned int er_index;
941 unsigned int er_label;
942 unsigned int er_mask;
944 efsys_mem_t *er_esmp;
945 efx_evq_rxq_state_t *er_ev_qstate;
948 #define EFX_RXQ_MAGIC 0x15022005
953 unsigned int et_index;
954 unsigned int et_mask;
955 efsys_mem_t *et_esmp;
956 #if EFSYS_OPT_HUNTINGTON
957 uint32_t et_pio_bufnum;
958 uint32_t et_pio_blknum;
959 uint32_t et_pio_write_offset;
960 uint32_t et_pio_offset;
964 uint32_t et_stat[TX_NQSTATS];
965 #endif /* EFSYS_OPT_QSTATS */
968 #define EFX_TXQ_MAGIC 0x05092005
970 #define EFX_MAC_ADDR_COPY(_dst, _src) \
972 (_dst)[0] = (_src)[0]; \
973 (_dst)[1] = (_src)[1]; \
974 (_dst)[2] = (_src)[2]; \
975 (_dst)[3] = (_src)[3]; \
976 (_dst)[4] = (_src)[4]; \
977 (_dst)[5] = (_src)[5]; \
978 _NOTE(CONSTANTCONDITION) \
981 #define EFX_MAC_BROADCAST_ADDR_SET(_dst) \
983 uint16_t *_d = (uint16_t *)(_dst); \
987 _NOTE(CONSTANTCONDITION) \
990 #if EFSYS_OPT_CHECK_REG
991 #define EFX_CHECK_REG(_enp, _reg) \
993 const char *name = #_reg; \
994 char min = name[4]; \
995 char max = name[5]; \
998 switch ((_enp)->en_family) { \
999 case EFX_FAMILY_SIENA: \
1003 case EFX_FAMILY_HUNTINGTON: \
1007 case EFX_FAMILY_MEDFORD: \
1011 case EFX_FAMILY_MEDFORD2: \
1015 case EFX_FAMILY_RIVERHEAD: \
1024 EFSYS_ASSERT3S(rev, >=, min); \
1025 EFSYS_ASSERT3S(rev, <=, max); \
1027 _NOTE(CONSTANTCONDITION) \
1030 #define EFX_CHECK_REG(_enp, _reg) do { \
1031 _NOTE(CONSTANTCONDITION) \
1035 #define EFX_BAR_READD(_enp, _reg, _edp, _lock) \
1037 EFX_CHECK_REG((_enp), (_reg)); \
1038 EFSYS_BAR_READD((_enp)->en_esbp, _reg ## _OFST, \
1040 EFSYS_PROBE3(efx_bar_readd, const char *, #_reg, \
1041 uint32_t, _reg ## _OFST, \
1042 uint32_t, (_edp)->ed_u32[0]); \
1043 _NOTE(CONSTANTCONDITION) \
1046 #define EFX_BAR_WRITED(_enp, _reg, _edp, _lock) \
1048 EFX_CHECK_REG((_enp), (_reg)); \
1049 EFSYS_PROBE3(efx_bar_writed, const char *, #_reg, \
1050 uint32_t, _reg ## _OFST, \
1051 uint32_t, (_edp)->ed_u32[0]); \
1052 EFSYS_BAR_WRITED((_enp)->en_esbp, _reg ## _OFST, \
1054 _NOTE(CONSTANTCONDITION) \
1057 #define EFX_BAR_READQ(_enp, _reg, _eqp) \
1059 EFX_CHECK_REG((_enp), (_reg)); \
1060 EFSYS_BAR_READQ((_enp)->en_esbp, _reg ## _OFST, \
1062 EFSYS_PROBE4(efx_bar_readq, const char *, #_reg, \
1063 uint32_t, _reg ## _OFST, \
1064 uint32_t, (_eqp)->eq_u32[1], \
1065 uint32_t, (_eqp)->eq_u32[0]); \
1066 _NOTE(CONSTANTCONDITION) \
1069 #define EFX_BAR_WRITEQ(_enp, _reg, _eqp) \
1071 EFX_CHECK_REG((_enp), (_reg)); \
1072 EFSYS_PROBE4(efx_bar_writeq, const char *, #_reg, \
1073 uint32_t, _reg ## _OFST, \
1074 uint32_t, (_eqp)->eq_u32[1], \
1075 uint32_t, (_eqp)->eq_u32[0]); \
1076 EFSYS_BAR_WRITEQ((_enp)->en_esbp, _reg ## _OFST, \
1078 _NOTE(CONSTANTCONDITION) \
1081 #define EFX_BAR_READO(_enp, _reg, _eop) \
1083 EFX_CHECK_REG((_enp), (_reg)); \
1084 EFSYS_BAR_READO((_enp)->en_esbp, _reg ## _OFST, \
1086 EFSYS_PROBE6(efx_bar_reado, const char *, #_reg, \
1087 uint32_t, _reg ## _OFST, \
1088 uint32_t, (_eop)->eo_u32[3], \
1089 uint32_t, (_eop)->eo_u32[2], \
1090 uint32_t, (_eop)->eo_u32[1], \
1091 uint32_t, (_eop)->eo_u32[0]); \
1092 _NOTE(CONSTANTCONDITION) \
1095 #define EFX_BAR_WRITEO(_enp, _reg, _eop) \
1097 EFX_CHECK_REG((_enp), (_reg)); \
1098 EFSYS_PROBE6(efx_bar_writeo, const char *, #_reg, \
1099 uint32_t, _reg ## _OFST, \
1100 uint32_t, (_eop)->eo_u32[3], \
1101 uint32_t, (_eop)->eo_u32[2], \
1102 uint32_t, (_eop)->eo_u32[1], \
1103 uint32_t, (_eop)->eo_u32[0]); \
1104 EFSYS_BAR_WRITEO((_enp)->en_esbp, _reg ## _OFST, \
1106 _NOTE(CONSTANTCONDITION) \
1110 * Accessors for memory BAR non-VI tables.
1112 * Code used on EF10 *must* use EFX_BAR_VI_*() macros for per-VI registers,
1113 * to ensure the correct runtime VI window size is used on Medford2.
1115 * Siena-only code may continue using EFX_BAR_TBL_*() macros for VI registers.
1118 #define EFX_BAR_TBL_READD(_enp, _reg, _index, _edp, _lock) \
1120 EFX_CHECK_REG((_enp), (_reg)); \
1121 EFSYS_BAR_READD((_enp)->en_esbp, \
1122 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1124 EFSYS_PROBE4(efx_bar_tbl_readd, const char *, #_reg, \
1125 uint32_t, (_index), \
1126 uint32_t, _reg ## _OFST, \
1127 uint32_t, (_edp)->ed_u32[0]); \
1128 _NOTE(CONSTANTCONDITION) \
1131 #define EFX_BAR_TBL_WRITED(_enp, _reg, _index, _edp, _lock) \
1133 EFX_CHECK_REG((_enp), (_reg)); \
1134 EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg, \
1135 uint32_t, (_index), \
1136 uint32_t, _reg ## _OFST, \
1137 uint32_t, (_edp)->ed_u32[0]); \
1138 EFSYS_BAR_WRITED((_enp)->en_esbp, \
1139 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1141 _NOTE(CONSTANTCONDITION) \
1144 #define EFX_BAR_TBL_WRITED3(_enp, _reg, _index, _edp, _lock) \
1146 EFX_CHECK_REG((_enp), (_reg)); \
1147 EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg, \
1148 uint32_t, (_index), \
1149 uint32_t, _reg ## _OFST, \
1150 uint32_t, (_edp)->ed_u32[0]); \
1151 EFSYS_BAR_WRITED((_enp)->en_esbp, \
1153 (3 * sizeof (efx_dword_t)) + \
1154 ((_index) * _reg ## _STEP)), \
1156 _NOTE(CONSTANTCONDITION) \
1159 #define EFX_BAR_TBL_READQ(_enp, _reg, _index, _eqp) \
1161 EFX_CHECK_REG((_enp), (_reg)); \
1162 EFSYS_BAR_READQ((_enp)->en_esbp, \
1163 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1165 EFSYS_PROBE5(efx_bar_tbl_readq, const char *, #_reg, \
1166 uint32_t, (_index), \
1167 uint32_t, _reg ## _OFST, \
1168 uint32_t, (_eqp)->eq_u32[1], \
1169 uint32_t, (_eqp)->eq_u32[0]); \
1170 _NOTE(CONSTANTCONDITION) \
1173 #define EFX_BAR_TBL_WRITEQ(_enp, _reg, _index, _eqp) \
1175 EFX_CHECK_REG((_enp), (_reg)); \
1176 EFSYS_PROBE5(efx_bar_tbl_writeq, const char *, #_reg, \
1177 uint32_t, (_index), \
1178 uint32_t, _reg ## _OFST, \
1179 uint32_t, (_eqp)->eq_u32[1], \
1180 uint32_t, (_eqp)->eq_u32[0]); \
1181 EFSYS_BAR_WRITEQ((_enp)->en_esbp, \
1182 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1184 _NOTE(CONSTANTCONDITION) \
1187 #define EFX_BAR_TBL_READO(_enp, _reg, _index, _eop, _lock) \
1189 EFX_CHECK_REG((_enp), (_reg)); \
1190 EFSYS_BAR_READO((_enp)->en_esbp, \
1191 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1193 EFSYS_PROBE7(efx_bar_tbl_reado, const char *, #_reg, \
1194 uint32_t, (_index), \
1195 uint32_t, _reg ## _OFST, \
1196 uint32_t, (_eop)->eo_u32[3], \
1197 uint32_t, (_eop)->eo_u32[2], \
1198 uint32_t, (_eop)->eo_u32[1], \
1199 uint32_t, (_eop)->eo_u32[0]); \
1200 _NOTE(CONSTANTCONDITION) \
1203 #define EFX_BAR_TBL_WRITEO(_enp, _reg, _index, _eop, _lock) \
1205 EFX_CHECK_REG((_enp), (_reg)); \
1206 EFSYS_PROBE7(efx_bar_tbl_writeo, const char *, #_reg, \
1207 uint32_t, (_index), \
1208 uint32_t, _reg ## _OFST, \
1209 uint32_t, (_eop)->eo_u32[3], \
1210 uint32_t, (_eop)->eo_u32[2], \
1211 uint32_t, (_eop)->eo_u32[1], \
1212 uint32_t, (_eop)->eo_u32[0]); \
1213 EFSYS_BAR_WRITEO((_enp)->en_esbp, \
1214 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1216 _NOTE(CONSTANTCONDITION) \
1220 * Accessors for memory BAR per-VI registers.
1222 * The VI window size is 8KB for Medford and all earlier controllers.
1223 * For Medford2, the VI window size can be 8KB, 16KB or 64KB.
1226 #define EFX_BAR_VI_READD(_enp, _reg, _index, _edp, _lock) \
1228 EFX_CHECK_REG((_enp), (_reg)); \
1229 EFSYS_BAR_READD((_enp)->en_esbp, \
1230 ((_reg ## _OFST) + \
1231 ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1233 EFSYS_PROBE4(efx_bar_vi_readd, const char *, #_reg, \
1234 uint32_t, (_index), \
1235 uint32_t, _reg ## _OFST, \
1236 uint32_t, (_edp)->ed_u32[0]); \
1237 _NOTE(CONSTANTCONDITION) \
1240 #define EFX_BAR_VI_WRITED(_enp, _reg, _index, _edp, _lock) \
1242 EFX_CHECK_REG((_enp), (_reg)); \
1243 EFSYS_PROBE4(efx_bar_vi_writed, const char *, #_reg, \
1244 uint32_t, (_index), \
1245 uint32_t, _reg ## _OFST, \
1246 uint32_t, (_edp)->ed_u32[0]); \
1247 EFSYS_BAR_WRITED((_enp)->en_esbp, \
1248 ((_reg ## _OFST) + \
1249 ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1251 _NOTE(CONSTANTCONDITION) \
1254 #define EFX_BAR_VI_WRITED2(_enp, _reg, _index, _edp, _lock) \
1256 EFX_CHECK_REG((_enp), (_reg)); \
1257 EFSYS_PROBE4(efx_bar_vi_writed, const char *, #_reg, \
1258 uint32_t, (_index), \
1259 uint32_t, _reg ## _OFST, \
1260 uint32_t, (_edp)->ed_u32[0]); \
1261 EFSYS_BAR_WRITED((_enp)->en_esbp, \
1262 ((_reg ## _OFST) + \
1263 (2 * sizeof (efx_dword_t)) + \
1264 ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1266 _NOTE(CONSTANTCONDITION) \
1270 * Allow drivers to perform optimised 128-bit VI doorbell writes.
1271 * The DMA descriptor pointers (RX_DESC_UPD and TX_DESC_UPD) are
1272 * special-cased in the BIU on the Falcon/Siena and EF10 architectures to avoid
1273 * the need for locking in the host, and are the only ones known to be safe to
1274 * use 128-bites write with.
1276 #define EFX_BAR_VI_DOORBELL_WRITEO(_enp, _reg, _index, _eop) \
1278 EFX_CHECK_REG((_enp), (_reg)); \
1279 EFSYS_PROBE7(efx_bar_vi_doorbell_writeo, \
1280 const char *, #_reg, \
1281 uint32_t, (_index), \
1282 uint32_t, _reg ## _OFST, \
1283 uint32_t, (_eop)->eo_u32[3], \
1284 uint32_t, (_eop)->eo_u32[2], \
1285 uint32_t, (_eop)->eo_u32[1], \
1286 uint32_t, (_eop)->eo_u32[0]); \
1287 EFSYS_BAR_DOORBELL_WRITEO((_enp)->en_esbp, \
1289 ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1291 _NOTE(CONSTANTCONDITION) \
1294 #define EFX_DMA_SYNC_QUEUE_FOR_DEVICE(_esmp, _entries, _wptr, _owptr) \
1296 unsigned int _new = (_wptr); \
1297 unsigned int _old = (_owptr); \
1299 if ((_new) >= (_old)) \
1300 EFSYS_DMA_SYNC_FOR_DEVICE((_esmp), \
1301 (_old) * sizeof (efx_desc_t), \
1302 ((_new) - (_old)) * sizeof (efx_desc_t)); \
1305 * It is cheaper to sync entire map than sync \
1306 * two parts especially when offset/size are \
1307 * ignored and entire map is synced in any case.\
1309 EFSYS_DMA_SYNC_FOR_DEVICE((_esmp), \
1311 (_entries) * sizeof (efx_desc_t)); \
1312 _NOTE(CONSTANTCONDITION) \
1316 extern __checkReturn efx_rc_t
1318 __in efx_nic_t *enp);
1322 efx_mac_multicast_hash_compute(
1323 __in_ecount(6*count) uint8_t const *addrs,
1325 __out efx_oword_t *hash_low,
1326 __out efx_oword_t *hash_high);
1329 extern __checkReturn efx_rc_t
1331 __in efx_nic_t *enp);
1336 __in efx_nic_t *enp);
1340 /* VPD utility functions */
1343 extern __checkReturn efx_rc_t
1344 efx_vpd_hunk_length(
1345 __in_bcount(size) caddr_t data,
1347 __out size_t *lengthp);
1350 extern __checkReturn efx_rc_t
1351 efx_vpd_hunk_verify(
1352 __in_bcount(size) caddr_t data,
1354 __out_opt boolean_t *cksummedp);
1357 extern __checkReturn efx_rc_t
1358 efx_vpd_hunk_reinit(
1359 __in_bcount(size) caddr_t data,
1361 __in boolean_t wantpid);
1364 extern __checkReturn efx_rc_t
1366 __in_bcount(size) caddr_t data,
1368 __in efx_vpd_tag_t tag,
1369 __in efx_vpd_keyword_t keyword,
1370 __out unsigned int *payloadp,
1371 __out uint8_t *paylenp);
1374 extern __checkReturn efx_rc_t
1376 __in_bcount(size) caddr_t data,
1378 __out efx_vpd_tag_t *tagp,
1379 __out efx_vpd_keyword_t *keyword,
1380 __out_opt unsigned int *payloadp,
1381 __out_opt uint8_t *paylenp,
1382 __inout unsigned int *contp);
1385 extern __checkReturn efx_rc_t
1387 __in_bcount(size) caddr_t data,
1389 __in efx_vpd_value_t *evvp);
1391 #endif /* EFSYS_OPT_VPD */
1396 extern __checkReturn efx_rc_t
1397 efx_mcdi_set_workaround(
1398 __in efx_nic_t *enp,
1400 __in boolean_t enabled,
1401 __out_opt uint32_t *flagsp);
1404 extern __checkReturn efx_rc_t
1405 efx_mcdi_get_workarounds(
1406 __in efx_nic_t *enp,
1407 __out_opt uint32_t *implementedp,
1408 __out_opt uint32_t *enabledp);
1410 #endif /* EFSYS_OPT_MCDI */
1412 #if EFSYS_OPT_MAC_STATS
1415 * Closed range of stats (i.e. the first and the last are included).
1416 * The last must be greater or equal (if the range is one item only) to
1419 struct efx_mac_stats_range {
1420 efx_mac_stat_t first;
1421 efx_mac_stat_t last;
1424 typedef enum efx_stats_action_e {
1427 EFX_STATS_ENABLE_NOEVENTS,
1428 EFX_STATS_ENABLE_EVENTS,
1430 } efx_stats_action_t;
1434 efx_mac_stats_mask_add_ranges(
1435 __inout_bcount(mask_size) uint32_t *maskp,
1436 __in size_t mask_size,
1437 __in_ecount(rng_count) const struct efx_mac_stats_range *rngp,
1438 __in unsigned int rng_count);
1441 extern __checkReturn efx_rc_t
1443 __in efx_nic_t *enp,
1444 __in uint32_t vport_id,
1445 __in_opt efsys_mem_t *esmp,
1446 __in efx_stats_action_t action,
1447 __in uint16_t period_ms);
1449 #endif /* EFSYS_OPT_MAC_STATS */
1455 #endif /* _SYS_EFX_IMPL_H */