1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2021 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
68 #define EFX_MOD_VIRTIO 0x00020000
70 #define EFX_RESET_PHY 0x00000001
71 #define EFX_RESET_RXQ_ERR 0x00000002
72 #define EFX_RESET_TXQ_ERR 0x00000004
73 #define EFX_RESET_HW_UNAVAIL 0x00000008
75 typedef enum efx_mac_type_e {
85 typedef struct efx_ev_ops_s {
86 efx_rc_t (*eevo_init)(efx_nic_t *);
87 void (*eevo_fini)(efx_nic_t *);
88 efx_rc_t (*eevo_qcreate)(efx_nic_t *, unsigned int,
89 efsys_mem_t *, size_t, uint32_t,
90 uint32_t, uint32_t, efx_evq_t *);
91 void (*eevo_qdestroy)(efx_evq_t *);
92 efx_rc_t (*eevo_qprime)(efx_evq_t *, unsigned int);
93 void (*eevo_qpost)(efx_evq_t *, uint16_t);
94 void (*eevo_qpoll)(efx_evq_t *, unsigned int *,
95 const efx_ev_callbacks_t *, void *);
96 efx_rc_t (*eevo_qmoderate)(efx_evq_t *, unsigned int);
98 void (*eevo_qstats_update)(efx_evq_t *, efsys_stat_t *);
102 typedef struct efx_tx_ops_s {
103 efx_rc_t (*etxo_init)(efx_nic_t *);
104 void (*etxo_fini)(efx_nic_t *);
105 efx_rc_t (*etxo_qcreate)(efx_nic_t *,
106 unsigned int, unsigned int,
107 efsys_mem_t *, size_t,
109 efx_evq_t *, efx_txq_t *,
111 void (*etxo_qdestroy)(efx_txq_t *);
112 efx_rc_t (*etxo_qpost)(efx_txq_t *, efx_buffer_t *,
113 unsigned int, unsigned int,
115 void (*etxo_qpush)(efx_txq_t *, unsigned int, unsigned int);
116 efx_rc_t (*etxo_qpace)(efx_txq_t *, unsigned int);
117 efx_rc_t (*etxo_qflush)(efx_txq_t *);
118 void (*etxo_qenable)(efx_txq_t *);
119 efx_rc_t (*etxo_qpio_enable)(efx_txq_t *);
120 void (*etxo_qpio_disable)(efx_txq_t *);
121 efx_rc_t (*etxo_qpio_write)(efx_txq_t *, uint8_t *, size_t,
123 efx_rc_t (*etxo_qpio_post)(efx_txq_t *, size_t, unsigned int,
125 efx_rc_t (*etxo_qdesc_post)(efx_txq_t *, efx_desc_t *,
126 unsigned int, unsigned int,
128 void (*etxo_qdesc_dma_create)(efx_txq_t *, efsys_dma_addr_t,
131 void (*etxo_qdesc_tso_create)(efx_txq_t *, uint16_t,
134 void (*etxo_qdesc_tso2_create)(efx_txq_t *, uint16_t,
135 uint16_t, uint32_t, uint16_t,
137 void (*etxo_qdesc_vlantci_create)(efx_txq_t *, uint16_t,
139 void (*etxo_qdesc_checksum_create)(efx_txq_t *, uint16_t,
142 void (*etxo_qstats_update)(efx_txq_t *,
147 typedef union efx_rxq_type_data_u {
151 #if EFSYS_OPT_RX_PACKED_STREAM
153 uint32_t eps_buf_size;
154 } ertd_packed_stream;
156 #if EFSYS_OPT_RX_ES_SUPER_BUFFER
158 uint32_t eessb_bufs_per_desc;
159 uint32_t eessb_max_dma_len;
160 uint32_t eessb_buf_stride;
161 uint32_t eessb_hol_block_timeout;
162 } ertd_es_super_buffer;
164 } efx_rxq_type_data_t;
166 typedef struct efx_rx_ops_s {
167 efx_rc_t (*erxo_init)(efx_nic_t *);
168 void (*erxo_fini)(efx_nic_t *);
169 #if EFSYS_OPT_RX_SCATTER
170 efx_rc_t (*erxo_scatter_enable)(efx_nic_t *, unsigned int);
172 #if EFSYS_OPT_RX_SCALE
173 efx_rc_t (*erxo_scale_context_alloc)(efx_nic_t *,
174 efx_rx_scale_context_type_t,
175 uint32_t, uint32_t *);
176 efx_rc_t (*erxo_scale_context_free)(efx_nic_t *, uint32_t);
177 efx_rc_t (*erxo_scale_mode_set)(efx_nic_t *, uint32_t,
179 efx_rx_hash_type_t, boolean_t);
180 efx_rc_t (*erxo_scale_key_set)(efx_nic_t *, uint32_t,
182 efx_rc_t (*erxo_scale_tbl_set)(efx_nic_t *, uint32_t,
183 unsigned int *, size_t);
184 uint32_t (*erxo_prefix_hash)(efx_nic_t *, efx_rx_hash_alg_t,
186 #endif /* EFSYS_OPT_RX_SCALE */
187 efx_rc_t (*erxo_prefix_pktlen)(efx_nic_t *, uint8_t *,
189 void (*erxo_qpost)(efx_rxq_t *, efsys_dma_addr_t *, size_t,
190 unsigned int, unsigned int,
192 void (*erxo_qpush)(efx_rxq_t *, unsigned int, unsigned int *);
193 #if EFSYS_OPT_RX_PACKED_STREAM
194 void (*erxo_qpush_ps_credits)(efx_rxq_t *);
195 uint8_t * (*erxo_qps_packet_info)(efx_rxq_t *, uint8_t *,
197 uint16_t *, uint32_t *, uint32_t *);
199 efx_rc_t (*erxo_qflush)(efx_rxq_t *);
200 void (*erxo_qenable)(efx_rxq_t *);
201 efx_rc_t (*erxo_qcreate)(efx_nic_t *enp, unsigned int,
202 unsigned int, efx_rxq_type_t,
203 const efx_rxq_type_data_t *,
204 efsys_mem_t *, size_t, uint32_t,
206 efx_evq_t *, efx_rxq_t *);
207 void (*erxo_qdestroy)(efx_rxq_t *);
210 typedef struct efx_mac_ops_s {
211 efx_rc_t (*emo_poll)(efx_nic_t *, efx_link_mode_t *);
212 efx_rc_t (*emo_up)(efx_nic_t *, boolean_t *);
213 efx_rc_t (*emo_addr_set)(efx_nic_t *);
214 efx_rc_t (*emo_pdu_set)(efx_nic_t *);
215 efx_rc_t (*emo_pdu_get)(efx_nic_t *, size_t *);
216 efx_rc_t (*emo_reconfigure)(efx_nic_t *);
217 efx_rc_t (*emo_multicast_list_set)(efx_nic_t *);
218 efx_rc_t (*emo_filter_default_rxq_set)(efx_nic_t *,
219 efx_rxq_t *, boolean_t);
220 void (*emo_filter_default_rxq_clear)(efx_nic_t *);
221 #if EFSYS_OPT_LOOPBACK
222 efx_rc_t (*emo_loopback_set)(efx_nic_t *, efx_link_mode_t,
223 efx_loopback_type_t);
224 #endif /* EFSYS_OPT_LOOPBACK */
225 #if EFSYS_OPT_MAC_STATS
226 efx_rc_t (*emo_stats_get_mask)(efx_nic_t *, uint32_t *, size_t);
227 efx_rc_t (*emo_stats_clear)(efx_nic_t *);
228 efx_rc_t (*emo_stats_upload)(efx_nic_t *, efsys_mem_t *);
229 efx_rc_t (*emo_stats_periodic)(efx_nic_t *, efsys_mem_t *,
230 uint16_t, boolean_t);
231 efx_rc_t (*emo_stats_update)(efx_nic_t *, efsys_mem_t *,
232 efsys_stat_t *, uint32_t *);
233 #endif /* EFSYS_OPT_MAC_STATS */
236 typedef struct efx_phy_ops_s {
237 efx_rc_t (*epo_power)(efx_nic_t *, boolean_t); /* optional */
238 efx_rc_t (*epo_reset)(efx_nic_t *);
239 efx_rc_t (*epo_reconfigure)(efx_nic_t *);
240 efx_rc_t (*epo_verify)(efx_nic_t *);
241 efx_rc_t (*epo_oui_get)(efx_nic_t *, uint32_t *);
242 efx_rc_t (*epo_link_state_get)(efx_nic_t *, efx_phy_link_state_t *);
243 #if EFSYS_OPT_PHY_STATS
244 efx_rc_t (*epo_stats_update)(efx_nic_t *, efsys_mem_t *,
246 #endif /* EFSYS_OPT_PHY_STATS */
248 efx_rc_t (*epo_bist_enable_offline)(efx_nic_t *);
249 efx_rc_t (*epo_bist_start)(efx_nic_t *, efx_bist_type_t);
250 efx_rc_t (*epo_bist_poll)(efx_nic_t *, efx_bist_type_t,
251 efx_bist_result_t *, uint32_t *,
252 unsigned long *, size_t);
253 void (*epo_bist_stop)(efx_nic_t *, efx_bist_type_t);
254 #endif /* EFSYS_OPT_BIST */
260 * Policy for replacing existing filter when inserting a new one.
261 * Note that all policies allow for storing the new lower priority
262 * filters as overridden by existing higher priority ones. It is needed
263 * to restore the lower priority filters on higher priority ones removal.
265 typedef enum efx_filter_replacement_policy_e {
266 /* Cannot replace existing filter */
267 EFX_FILTER_REPLACEMENT_NEVER,
268 /* Higher priority filters can replace lower priotiry ones */
269 EFX_FILTER_REPLACEMENT_HIGHER_PRIORITY,
271 * Higher priority filters can replace lower priority ones and
272 * equal priority filters can replace each other.
274 EFX_FILTER_REPLACEMENT_HIGHER_OR_EQUAL_PRIORITY,
275 } efx_filter_replacement_policy_t;
277 typedef struct efx_filter_ops_s {
278 efx_rc_t (*efo_init)(efx_nic_t *);
279 void (*efo_fini)(efx_nic_t *);
280 efx_rc_t (*efo_restore)(efx_nic_t *);
281 efx_rc_t (*efo_add)(efx_nic_t *, efx_filter_spec_t *,
282 efx_filter_replacement_policy_t policy);
283 efx_rc_t (*efo_delete)(efx_nic_t *, efx_filter_spec_t *);
284 efx_rc_t (*efo_supported_filters)(efx_nic_t *, uint32_t *,
286 efx_rc_t (*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
287 boolean_t, boolean_t, boolean_t,
288 uint8_t const *, uint32_t);
292 extern __checkReturn efx_rc_t
293 efx_filter_reconfigure(
295 __in_ecount(6) uint8_t const *mac_addr,
296 __in boolean_t all_unicst,
297 __in boolean_t mulcst,
298 __in boolean_t all_mulcst,
299 __in boolean_t brdcst,
300 __in_ecount(6*count) uint8_t const *addrs,
301 __in uint32_t count);
303 #endif /* EFSYS_OPT_FILTER */
306 typedef struct efx_tunnel_ops_s {
307 efx_rc_t (*eto_reconfigure)(efx_nic_t *);
308 void (*eto_fini)(efx_nic_t *);
310 #endif /* EFSYS_OPT_TUNNEL */
313 typedef struct efx_virtio_ops_s {
314 efx_rc_t (*evo_virtio_qstart)(efx_virtio_vq_t *,
315 efx_virtio_vq_cfg_t *,
316 efx_virtio_vq_dyncfg_t *);
317 efx_rc_t (*evo_virtio_qstop)(efx_virtio_vq_t *,
318 efx_virtio_vq_dyncfg_t *);
320 #endif /* EFSYS_OPT_VIRTIO */
322 typedef struct efx_port_s {
323 efx_mac_type_t ep_mac_type;
324 uint32_t ep_phy_type;
327 uint8_t ep_mac_addr[6];
328 efx_link_mode_t ep_link_mode;
329 boolean_t ep_all_unicst;
330 boolean_t ep_all_unicst_inserted;
332 boolean_t ep_all_mulcst;
333 boolean_t ep_all_mulcst_inserted;
335 unsigned int ep_fcntl;
336 boolean_t ep_fcntl_autoneg;
337 efx_oword_t ep_multicst_hash[2];
338 uint8_t ep_mulcst_addr_list[EFX_MAC_ADDR_LEN *
339 EFX_MAC_MULTICAST_LIST_MAX];
340 uint32_t ep_mulcst_addr_count;
341 #if EFSYS_OPT_LOOPBACK
342 efx_loopback_type_t ep_loopback_type;
343 efx_link_mode_t ep_loopback_link_mode;
344 #endif /* EFSYS_OPT_LOOPBACK */
345 #if EFSYS_OPT_PHY_FLAGS
346 uint32_t ep_phy_flags;
347 #endif /* EFSYS_OPT_PHY_FLAGS */
348 #if EFSYS_OPT_PHY_LED_CONTROL
349 efx_phy_led_mode_t ep_phy_led_mode;
350 #endif /* EFSYS_OPT_PHY_LED_CONTROL */
351 efx_phy_media_type_t ep_fixed_port_type;
352 efx_phy_media_type_t ep_module_type;
353 uint32_t ep_adv_cap_mask;
354 uint32_t ep_lp_cap_mask;
355 uint32_t ep_default_adv_cap_mask;
356 uint32_t ep_phy_cap_mask;
357 boolean_t ep_mac_drain;
359 efx_bist_type_t ep_current_bist;
361 const efx_mac_ops_t *ep_emop;
362 const efx_phy_ops_t *ep_epop;
365 typedef struct efx_mon_ops_s {
366 #if EFSYS_OPT_MON_STATS
367 efx_rc_t (*emo_stats_update)(efx_nic_t *, efsys_mem_t *,
368 efx_mon_stat_value_t *);
369 efx_rc_t (*emo_limits_update)(efx_nic_t *,
370 efx_mon_stat_limits_t *);
371 #endif /* EFSYS_OPT_MON_STATS */
374 typedef struct efx_mon_s {
375 efx_mon_type_t em_type;
376 const efx_mon_ops_t *em_emop;
379 typedef struct efx_intr_ops_s {
380 efx_rc_t (*eio_init)(efx_nic_t *, efx_intr_type_t, efsys_mem_t *);
381 void (*eio_enable)(efx_nic_t *);
382 void (*eio_disable)(efx_nic_t *);
383 void (*eio_disable_unlocked)(efx_nic_t *);
384 efx_rc_t (*eio_trigger)(efx_nic_t *, unsigned int);
385 void (*eio_status_line)(efx_nic_t *, boolean_t *, uint32_t *);
386 void (*eio_status_message)(efx_nic_t *, unsigned int,
388 void (*eio_fatal)(efx_nic_t *);
389 void (*eio_fini)(efx_nic_t *);
392 typedef struct efx_intr_s {
393 const efx_intr_ops_t *ei_eiop;
394 efsys_mem_t *ei_esmp;
395 efx_intr_type_t ei_type;
396 unsigned int ei_level;
399 typedef struct efx_nic_ops_s {
400 efx_rc_t (*eno_probe)(efx_nic_t *);
401 efx_rc_t (*eno_board_cfg)(efx_nic_t *);
402 efx_rc_t (*eno_set_drv_limits)(efx_nic_t *, efx_drv_limits_t*);
403 efx_rc_t (*eno_reset)(efx_nic_t *);
404 efx_rc_t (*eno_init)(efx_nic_t *);
405 efx_rc_t (*eno_get_vi_pool)(efx_nic_t *, uint32_t *);
406 efx_rc_t (*eno_get_bar_region)(efx_nic_t *, efx_nic_region_t,
407 uint32_t *, size_t *);
408 boolean_t (*eno_hw_unavailable)(efx_nic_t *);
409 void (*eno_set_hw_unavailable)(efx_nic_t *);
411 efx_rc_t (*eno_register_test)(efx_nic_t *);
412 #endif /* EFSYS_OPT_DIAG */
413 void (*eno_fini)(efx_nic_t *);
414 void (*eno_unprobe)(efx_nic_t *);
417 #ifndef EFX_TXQ_LIMIT_TARGET
418 #define EFX_TXQ_LIMIT_TARGET 259
420 #ifndef EFX_RXQ_LIMIT_TARGET
421 #define EFX_RXQ_LIMIT_TARGET 512
429 typedef struct siena_filter_spec_s {
432 uint32_t sfs_dmaq_id;
433 uint32_t sfs_dword[3];
434 } siena_filter_spec_t;
436 typedef enum siena_filter_type_e {
437 EFX_SIENA_FILTER_RX_TCP_FULL, /* TCP/IPv4 {dIP,dTCP,sIP,sTCP} */
438 EFX_SIENA_FILTER_RX_TCP_WILD, /* TCP/IPv4 {dIP,dTCP, -, -} */
439 EFX_SIENA_FILTER_RX_UDP_FULL, /* UDP/IPv4 {dIP,dUDP,sIP,sUDP} */
440 EFX_SIENA_FILTER_RX_UDP_WILD, /* UDP/IPv4 {dIP,dUDP, -, -} */
441 EFX_SIENA_FILTER_RX_MAC_FULL, /* Ethernet {dMAC,VLAN} */
442 EFX_SIENA_FILTER_RX_MAC_WILD, /* Ethernet {dMAC, -} */
444 EFX_SIENA_FILTER_TX_TCP_FULL, /* TCP/IPv4 {dIP,dTCP,sIP,sTCP} */
445 EFX_SIENA_FILTER_TX_TCP_WILD, /* TCP/IPv4 { -, -,sIP,sTCP} */
446 EFX_SIENA_FILTER_TX_UDP_FULL, /* UDP/IPv4 {dIP,dTCP,sIP,sTCP} */
447 EFX_SIENA_FILTER_TX_UDP_WILD, /* UDP/IPv4 { -, -,sIP,sUDP} */
448 EFX_SIENA_FILTER_TX_MAC_FULL, /* Ethernet {sMAC,VLAN} */
449 EFX_SIENA_FILTER_TX_MAC_WILD, /* Ethernet {sMAC, -} */
451 EFX_SIENA_FILTER_NTYPES
452 } siena_filter_type_t;
454 typedef enum siena_filter_tbl_id_e {
455 EFX_SIENA_FILTER_TBL_RX_IP = 0,
456 EFX_SIENA_FILTER_TBL_RX_MAC,
457 EFX_SIENA_FILTER_TBL_TX_IP,
458 EFX_SIENA_FILTER_TBL_TX_MAC,
459 EFX_SIENA_FILTER_NTBLS
460 } siena_filter_tbl_id_t;
462 typedef struct siena_filter_tbl_s {
463 int sft_size; /* number of entries */
464 int sft_used; /* active count */
465 uint32_t *sft_bitmap; /* active bitmap */
466 siena_filter_spec_t *sft_spec; /* array of saved specs */
467 } siena_filter_tbl_t;
469 typedef struct siena_filter_s {
470 siena_filter_tbl_t sf_tbl[EFX_SIENA_FILTER_NTBLS];
471 unsigned int sf_depth[EFX_SIENA_FILTER_NTYPES];
474 #endif /* EFSYS_OPT_SIENA */
476 typedef struct efx_filter_s {
478 siena_filter_t *ef_siena_filter;
479 #endif /* EFSYS_OPT_SIENA */
480 #if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
481 ef10_filter_table_t *ef_ef10_filter_table;
482 #endif /* EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10() */
489 siena_filter_tbl_clear(
491 __in siena_filter_tbl_id_t tbl);
493 #endif /* EFSYS_OPT_SIENA */
495 #endif /* EFSYS_OPT_FILTER */
499 #define EFX_TUNNEL_MAXNENTRIES (16)
503 /* State of a UDP tunnel table entry */
504 typedef enum efx_tunnel_udp_entry_state_e {
505 EFX_TUNNEL_UDP_ENTRY_ADDED, /* Tunnel addition is requested */
506 EFX_TUNNEL_UDP_ENTRY_REMOVED, /* Tunnel removal is requested */
507 EFX_TUNNEL_UDP_ENTRY_APPLIED, /* Tunnel is applied by HW */
508 } efx_tunnel_udp_entry_state_t;
510 #if EFSYS_OPT_RIVERHEAD
511 typedef uint32_t efx_vnic_encap_rule_handle_t;
512 #endif /* EFSYS_OPT_RIVERHEAD */
514 typedef struct efx_tunnel_udp_entry_s {
515 uint16_t etue_port; /* host/cpu-endian */
516 uint16_t etue_protocol;
518 efx_tunnel_udp_entry_state_t etue_state;
519 #if EFSYS_OPT_RIVERHEAD
520 efx_vnic_encap_rule_handle_t etue_handle;
521 #endif /* EFSYS_OPT_RIVERHEAD */
522 } efx_tunnel_udp_entry_t;
524 typedef struct efx_tunnel_cfg_s {
525 efx_tunnel_udp_entry_t etc_udp_entries[EFX_TUNNEL_MAXNENTRIES];
526 unsigned int etc_udp_entries_num;
529 #endif /* EFSYS_OPT_TUNNEL */
531 typedef struct efx_mcdi_ops_s {
532 efx_rc_t (*emco_init)(efx_nic_t *, const efx_mcdi_transport_t *);
533 void (*emco_send_request)(efx_nic_t *, void *, size_t,
535 efx_rc_t (*emco_poll_reboot)(efx_nic_t *);
536 boolean_t (*emco_poll_response)(efx_nic_t *);
537 void (*emco_read_response)(efx_nic_t *, void *, size_t, size_t);
538 void (*emco_fini)(efx_nic_t *);
539 efx_rc_t (*emco_feature_supported)(efx_nic_t *,
540 efx_mcdi_feature_id_t, boolean_t *);
541 void (*emco_get_timeout)(efx_nic_t *, efx_mcdi_req_t *,
545 typedef struct efx_mcdi_s {
546 const efx_mcdi_ops_t *em_emcop;
547 const efx_mcdi_transport_t *em_emtp;
548 efx_mcdi_iface_t em_emip;
551 #endif /* EFSYS_OPT_MCDI */
555 /* Invalid partition ID for en_nvram_partn_locked field of efx_nc_t */
556 #define EFX_NVRAM_PARTN_INVALID (0xffffffffu)
558 typedef struct efx_nvram_ops_s {
560 efx_rc_t (*envo_test)(efx_nic_t *);
561 #endif /* EFSYS_OPT_DIAG */
562 efx_rc_t (*envo_type_to_partn)(efx_nic_t *, efx_nvram_type_t,
564 efx_rc_t (*envo_partn_info)(efx_nic_t *, uint32_t,
566 efx_rc_t (*envo_partn_rw_start)(efx_nic_t *, uint32_t, size_t *);
567 efx_rc_t (*envo_partn_read)(efx_nic_t *, uint32_t,
568 unsigned int, caddr_t, size_t);
569 efx_rc_t (*envo_partn_read_backup)(efx_nic_t *, uint32_t,
570 unsigned int, caddr_t, size_t);
571 efx_rc_t (*envo_partn_erase)(efx_nic_t *, uint32_t,
572 unsigned int, size_t);
573 efx_rc_t (*envo_partn_write)(efx_nic_t *, uint32_t,
574 unsigned int, caddr_t, size_t);
575 efx_rc_t (*envo_partn_rw_finish)(efx_nic_t *, uint32_t,
577 efx_rc_t (*envo_partn_get_version)(efx_nic_t *, uint32_t,
578 uint32_t *, uint16_t *);
579 efx_rc_t (*envo_partn_set_version)(efx_nic_t *, uint32_t,
581 efx_rc_t (*envo_buffer_validate)(uint32_t,
584 #endif /* EFSYS_OPT_NVRAM */
587 typedef struct efx_vpd_ops_s {
588 efx_rc_t (*evpdo_init)(efx_nic_t *);
589 efx_rc_t (*evpdo_size)(efx_nic_t *, size_t *);
590 efx_rc_t (*evpdo_read)(efx_nic_t *, caddr_t, size_t);
591 efx_rc_t (*evpdo_verify)(efx_nic_t *, caddr_t, size_t);
592 efx_rc_t (*evpdo_reinit)(efx_nic_t *, caddr_t, size_t);
593 efx_rc_t (*evpdo_get)(efx_nic_t *, caddr_t, size_t,
595 efx_rc_t (*evpdo_set)(efx_nic_t *, caddr_t, size_t,
597 efx_rc_t (*evpdo_next)(efx_nic_t *, caddr_t, size_t,
598 efx_vpd_value_t *, unsigned int *);
599 efx_rc_t (*evpdo_write)(efx_nic_t *, caddr_t, size_t);
600 void (*evpdo_fini)(efx_nic_t *);
602 #endif /* EFSYS_OPT_VPD */
604 #if EFSYS_OPT_VPD || EFSYS_OPT_NVRAM
607 extern __checkReturn efx_rc_t
608 efx_mcdi_nvram_partitions(
610 __out_bcount(size) caddr_t data,
612 __out unsigned int *npartnp);
615 extern __checkReturn efx_rc_t
616 efx_mcdi_nvram_metadata(
619 __out uint32_t *subtypep,
620 __out_ecount(4) uint16_t version[4],
621 __out_bcount_opt(size) char *descp,
625 extern __checkReturn efx_rc_t
629 __out efx_nvram_info_t *eni);
632 extern __checkReturn efx_rc_t
633 efx_mcdi_nvram_update_start(
635 __in uint32_t partn);
638 extern __checkReturn efx_rc_t
642 __in uint32_t offset,
643 __out_bcount(size) caddr_t data,
648 extern __checkReturn efx_rc_t
649 efx_mcdi_nvram_erase(
652 __in uint32_t offset,
656 extern __checkReturn efx_rc_t
657 efx_mcdi_nvram_write(
660 __in uint32_t offset,
661 __in_bcount(size) caddr_t data,
664 #define EFX_NVRAM_UPDATE_FLAGS_BACKGROUND 0x00000001
665 #define EFX_NVRAM_UPDATE_FLAGS_POLL 0x00000002
668 extern __checkReturn efx_rc_t
669 efx_mcdi_nvram_update_finish(
672 __in boolean_t reboot,
674 __out_opt uint32_t *verify_resultp);
679 extern __checkReturn efx_rc_t
682 __in uint32_t partn);
684 #endif /* EFSYS_OPT_DIAG */
686 #endif /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
688 #if EFSYS_OPT_LICENSING
690 typedef struct efx_lic_ops_s {
691 efx_rc_t (*elo_update_licenses)(efx_nic_t *);
692 efx_rc_t (*elo_get_key_stats)(efx_nic_t *, efx_key_stats_t *);
693 efx_rc_t (*elo_app_state)(efx_nic_t *, uint64_t, boolean_t *);
694 efx_rc_t (*elo_get_id)(efx_nic_t *, size_t, uint32_t *,
695 size_t *, uint8_t *);
696 efx_rc_t (*elo_find_start)
697 (efx_nic_t *, caddr_t, size_t, uint32_t *);
698 efx_rc_t (*elo_find_end)(efx_nic_t *, caddr_t, size_t,
699 uint32_t, uint32_t *);
700 boolean_t (*elo_find_key)(efx_nic_t *, caddr_t, size_t,
701 uint32_t, uint32_t *, uint32_t *);
702 boolean_t (*elo_validate_key)(efx_nic_t *,
704 efx_rc_t (*elo_read_key)(efx_nic_t *,
705 caddr_t, size_t, uint32_t, uint32_t,
706 caddr_t, size_t, uint32_t *);
707 efx_rc_t (*elo_write_key)(efx_nic_t *,
708 caddr_t, size_t, uint32_t,
709 caddr_t, uint32_t, uint32_t *);
710 efx_rc_t (*elo_delete_key)(efx_nic_t *,
711 caddr_t, size_t, uint32_t,
712 uint32_t, uint32_t, uint32_t *);
713 efx_rc_t (*elo_create_partition)(efx_nic_t *,
715 efx_rc_t (*elo_finish_partition)(efx_nic_t *,
723 struct efx_vswitch_s {
725 efx_vswitch_id_t ev_vswitch_id;
726 uint32_t ev_num_vports;
728 * Vport configuration array: index 0 to store PF configuration
729 * and next ev_num_vports-1 entries hold VFs configuration.
731 efx_vport_config_t *ev_evcp;
734 typedef struct efx_evb_ops_s {
735 efx_rc_t (*eeo_init)(efx_nic_t *);
736 void (*eeo_fini)(efx_nic_t *);
737 efx_rc_t (*eeo_vswitch_alloc)(efx_nic_t *, efx_vswitch_id_t *);
738 efx_rc_t (*eeo_vswitch_free)(efx_nic_t *, efx_vswitch_id_t);
739 efx_rc_t (*eeo_vport_alloc)(efx_nic_t *, efx_vswitch_id_t,
740 efx_vport_type_t, uint16_t,
741 boolean_t, efx_vport_id_t *);
742 efx_rc_t (*eeo_vport_free)(efx_nic_t *, efx_vswitch_id_t,
744 efx_rc_t (*eeo_vport_mac_addr_add)(efx_nic_t *, efx_vswitch_id_t,
745 efx_vport_id_t, uint8_t *);
746 efx_rc_t (*eeo_vport_mac_addr_del)(efx_nic_t *, efx_vswitch_id_t,
747 efx_vport_id_t, uint8_t *);
748 efx_rc_t (*eeo_vadaptor_alloc)(efx_nic_t *, efx_vswitch_id_t,
750 efx_rc_t (*eeo_vadaptor_free)(efx_nic_t *, efx_vswitch_id_t,
752 efx_rc_t (*eeo_vport_assign)(efx_nic_t *, efx_vswitch_id_t,
753 efx_vport_id_t, uint32_t);
754 efx_rc_t (*eeo_vport_reconfigure)(efx_nic_t *, efx_vswitch_id_t,
756 uint16_t *, uint8_t *,
758 efx_rc_t (*eeo_vport_stats)(efx_nic_t *, efx_vswitch_id_t,
759 efx_vport_id_t, efsys_mem_t *);
763 extern __checkReturn boolean_t
764 efx_is_zero_eth_addr(
765 __in_bcount(EFX_MAC_ADDR_LEN) const uint8_t *addrp);
767 #endif /* EFSYS_OPT_EVB */
769 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
771 #define EFX_PROXY_CONFIGURE_MAGIC 0xAB2015EF
774 typedef struct efx_proxy_ops_s {
775 efx_rc_t (*epo_init)(efx_nic_t *);
776 void (*epo_fini)(efx_nic_t *);
777 efx_rc_t (*epo_mc_config)(efx_nic_t *, efsys_mem_t *,
778 efsys_mem_t *, efsys_mem_t *,
779 uint32_t, uint32_t *, size_t);
780 efx_rc_t (*epo_disable)(efx_nic_t *);
781 efx_rc_t (*epo_privilege_modify)(efx_nic_t *, uint32_t, uint32_t,
782 uint32_t, uint32_t, uint32_t);
783 efx_rc_t (*epo_set_privilege_mask)(efx_nic_t *, uint32_t,
785 efx_rc_t (*epo_complete_request)(efx_nic_t *, uint32_t,
787 efx_rc_t (*epo_exec_cmd)(efx_nic_t *, efx_proxy_cmd_params_t *);
788 efx_rc_t (*epo_get_privilege_mask)(efx_nic_t *, uint32_t,
789 uint32_t, uint32_t *);
792 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
796 typedef struct efx_mae_field_cap_s {
797 uint32_t emfc_support;
798 boolean_t emfc_mask_affects_class;
799 boolean_t emfc_match_affects_class;
800 } efx_mae_field_cap_t;
802 typedef struct efx_mae_s {
803 uint32_t em_max_n_action_prios;
805 * The number of MAE field IDs recognised by the FW implementation.
806 * Any field ID greater than or equal to this value is unsupported.
808 uint32_t em_max_nfields;
809 /** Action rule match field capabilities. */
810 efx_mae_field_cap_t *em_action_rule_field_caps;
811 size_t em_action_rule_field_caps_size;
812 uint32_t em_max_n_outer_prios;
813 uint32_t em_encap_types_supported;
814 /** Outer rule match field capabilities. */
815 efx_mae_field_cap_t *em_outer_rule_field_caps;
816 size_t em_outer_rule_field_caps_size;
819 #endif /* EFSYS_OPT_MAE */
821 #define EFX_DRV_VER_MAX 20
823 typedef struct efx_drv_cfg_s {
824 uint32_t edc_min_vi_count;
825 uint32_t edc_max_vi_count;
827 uint32_t edc_max_piobuf_count;
828 uint32_t edc_pio_alloc_size;
833 efx_family_t en_family;
834 uint32_t en_features;
835 efsys_identifier_t *en_esip;
836 efsys_lock_t *en_eslp;
837 efsys_bar_t *en_esbp;
838 unsigned int en_mod_flags;
839 unsigned int en_reset_flags;
840 efx_nic_cfg_t en_nic_cfg;
841 efx_drv_cfg_t en_drv_cfg;
845 uint32_t en_ev_qcount;
846 uint32_t en_rx_qcount;
847 uint32_t en_tx_qcount;
848 const efx_nic_ops_t *en_enop;
849 const efx_ev_ops_t *en_eevop;
850 const efx_tx_ops_t *en_etxop;
851 const efx_rx_ops_t *en_erxop;
852 efx_fw_variant_t efv;
853 char en_drv_version[EFX_DRV_VER_MAX];
855 efx_filter_t en_filter;
856 const efx_filter_ops_t *en_efop;
857 #endif /* EFSYS_OPT_FILTER */
859 efx_tunnel_cfg_t en_tunnel_cfg;
860 const efx_tunnel_ops_t *en_etop;
861 #endif /* EFSYS_OPT_TUNNEL */
864 #endif /* EFSYS_OPT_MCDI */
866 uint32_t en_nvram_partn_locked;
867 const efx_nvram_ops_t *en_envop;
868 #endif /* EFSYS_OPT_NVRAM */
870 const efx_vpd_ops_t *en_evpdop;
871 #endif /* EFSYS_OPT_VPD */
873 const efx_virtio_ops_t *en_evop;
874 #endif /* EFSYS_OPT_VPD */
875 #if EFSYS_OPT_RX_SCALE
876 efx_rx_hash_support_t en_hash_support;
877 efx_rx_scale_context_type_t en_rss_context_type;
878 uint32_t en_rss_context;
879 #endif /* EFSYS_OPT_RX_SCALE */
880 uint32_t en_vport_id;
881 #if EFSYS_OPT_LICENSING
882 const efx_lic_ops_t *en_elop;
883 boolean_t en_licensing_supported;
888 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
889 unsigned int enu_partn_mask;
890 #endif /* EFSYS_OPT_NVRAM || EFSYS_OPT_VPD */
893 size_t enu_svpd_length;
894 #endif /* EFSYS_OPT_VPD */
897 #endif /* EFSYS_OPT_SIENA */
900 #if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
906 uint32_t ena_fcw_base;
909 size_t ena_svpd_length;
910 #endif /* EFSYS_OPT_VPD */
911 efx_piobuf_handle_t ena_piobuf_handle[EF10_MAX_PIOBUF_NBUFS];
912 uint32_t ena_piobuf_count;
913 uint32_t ena_pio_alloc_map[EF10_MAX_PIOBUF_NBUFS];
914 uint32_t ena_pio_write_vi_base;
915 /* Memory BAR mapping regions */
916 uint32_t ena_uc_mem_map_offset;
917 size_t ena_uc_mem_map_size;
918 uint32_t ena_wc_mem_map_offset;
919 size_t ena_wc_mem_map_size;
922 #endif /* EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10() */
924 const efx_evb_ops_t *en_eeop;
925 struct efx_vswitch_s *en_vswitchp;
926 #endif /* EFSYS_OPT_EVB */
927 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
928 const efx_proxy_ops_t *en_epop;
929 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
932 #endif /* EFSYS_OPT_MAE */
935 #define EFX_FAMILY_IS_EF10(_enp) \
936 ((_enp)->en_family == EFX_FAMILY_MEDFORD2 || \
937 (_enp)->en_family == EFX_FAMILY_MEDFORD || \
938 (_enp)->en_family == EFX_FAMILY_HUNTINGTON)
940 #define EFX_FAMILY_IS_EF100(_enp) \
941 ((_enp)->en_family == EFX_FAMILY_RIVERHEAD)
944 #define EFX_NIC_MAGIC 0x02121996
946 typedef boolean_t (*efx_ev_handler_t)(efx_evq_t *, efx_qword_t *,
947 const efx_ev_callbacks_t *, void *);
949 #if EFSYS_OPT_EV_EXTENDED_WIDTH
950 typedef boolean_t (*efx_ev_ew_handler_t)(efx_evq_t *, efx_xword_t *,
951 const efx_ev_callbacks_t *, void *);
952 #endif /* EFSYS_OPT_EV_EXTENDED_WIDTH */
954 typedef struct efx_evq_rxq_state_s {
955 unsigned int eers_rx_read_ptr;
956 unsigned int eers_rx_mask;
957 #if EFSYS_OPT_RX_PACKED_STREAM || EFSYS_OPT_RX_ES_SUPER_BUFFER
958 unsigned int eers_rx_stream_npackets;
959 boolean_t eers_rx_packed_stream;
961 #if EFSYS_OPT_RX_PACKED_STREAM
962 unsigned int eers_rx_packed_stream_credits;
964 } efx_evq_rxq_state_t;
970 unsigned int ee_index;
971 unsigned int ee_mask;
972 efsys_mem_t *ee_esmp;
974 uint32_t ee_stat[EV_NQSTATS];
975 #endif /* EFSYS_OPT_QSTATS */
977 efx_ev_handler_t ee_rx;
978 efx_ev_handler_t ee_tx;
979 efx_ev_handler_t ee_driver;
980 efx_ev_handler_t ee_global;
981 efx_ev_handler_t ee_drv_gen;
983 efx_ev_handler_t ee_mcdi;
984 #endif /* EFSYS_OPT_MCDI */
986 #if EFSYS_OPT_DESC_PROXY
987 efx_ev_ew_handler_t ee_ew_txq_desc;
988 efx_ev_ew_handler_t ee_ew_virtq_desc;
989 #endif /* EFSYS_OPT_DESC_PROXY */
991 efx_evq_rxq_state_t ee_rxq_state[EFX_EV_RX_NLABELS];
994 #define EFX_EVQ_MAGIC 0x08081997
996 #define EFX_EVQ_SIENA_TIMER_QUANTUM_NS 6144 /* 768 cycles */
999 #define EFX_EV_QSTAT_INCR(_eep, _stat) \
1001 (_eep)->ee_stat[_stat]++; \
1002 _NOTE(CONSTANTCONDITION) \
1005 #define EFX_EV_QSTAT_INCR(_eep, _stat)
1012 unsigned int er_index;
1013 unsigned int er_label;
1014 unsigned int er_mask;
1016 efsys_mem_t *er_esmp;
1017 efx_evq_rxq_state_t *er_ev_qstate;
1018 efx_rx_prefix_layout_t er_prefix_layout;
1021 #define EFX_RXQ_MAGIC 0x15022005
1026 unsigned int et_index;
1027 unsigned int et_mask;
1028 efsys_mem_t *et_esmp;
1029 #if EFSYS_OPT_HUNTINGTON
1030 uint32_t et_pio_bufnum;
1031 uint32_t et_pio_blknum;
1032 uint32_t et_pio_write_offset;
1033 uint32_t et_pio_offset;
1036 #if EFSYS_OPT_QSTATS
1037 uint32_t et_stat[TX_NQSTATS];
1038 #endif /* EFSYS_OPT_QSTATS */
1041 #define EFX_TXQ_MAGIC 0x05092005
1043 #define EFX_MAC_ADDR_COPY(_dst, _src) \
1045 (_dst)[0] = (_src)[0]; \
1046 (_dst)[1] = (_src)[1]; \
1047 (_dst)[2] = (_src)[2]; \
1048 (_dst)[3] = (_src)[3]; \
1049 (_dst)[4] = (_src)[4]; \
1050 (_dst)[5] = (_src)[5]; \
1051 _NOTE(CONSTANTCONDITION) \
1054 #define EFX_MAC_BROADCAST_ADDR_SET(_dst) \
1056 uint16_t *_d = (uint16_t *)(_dst); \
1060 _NOTE(CONSTANTCONDITION) \
1063 #if EFSYS_OPT_CHECK_REG
1064 #define EFX_CHECK_REG(_enp, _reg) \
1066 const char *name = #_reg; \
1067 char min = name[4]; \
1068 char max = name[5]; \
1071 switch ((_enp)->en_family) { \
1072 case EFX_FAMILY_SIENA: \
1076 case EFX_FAMILY_HUNTINGTON: \
1080 case EFX_FAMILY_MEDFORD: \
1084 case EFX_FAMILY_MEDFORD2: \
1088 case EFX_FAMILY_RIVERHEAD: \
1097 EFSYS_ASSERT3S(rev, >=, min); \
1098 EFSYS_ASSERT3S(rev, <=, max); \
1100 _NOTE(CONSTANTCONDITION) \
1103 #define EFX_CHECK_REG(_enp, _reg) do { \
1104 _NOTE(CONSTANTCONDITION) \
1108 #define EFX_BAR_READD(_enp, _reg, _edp, _lock) \
1110 EFX_CHECK_REG((_enp), (_reg)); \
1111 EFSYS_BAR_READD((_enp)->en_esbp, _reg ## _OFST, \
1113 EFSYS_PROBE3(efx_bar_readd, const char *, #_reg, \
1114 uint32_t, _reg ## _OFST, \
1115 uint32_t, (_edp)->ed_u32[0]); \
1116 _NOTE(CONSTANTCONDITION) \
1119 #define EFX_BAR_WRITED(_enp, _reg, _edp, _lock) \
1121 EFX_CHECK_REG((_enp), (_reg)); \
1122 EFSYS_PROBE3(efx_bar_writed, const char *, #_reg, \
1123 uint32_t, _reg ## _OFST, \
1124 uint32_t, (_edp)->ed_u32[0]); \
1125 EFSYS_BAR_WRITED((_enp)->en_esbp, _reg ## _OFST, \
1127 _NOTE(CONSTANTCONDITION) \
1130 #define EFX_BAR_READQ(_enp, _reg, _eqp) \
1132 EFX_CHECK_REG((_enp), (_reg)); \
1133 EFSYS_BAR_READQ((_enp)->en_esbp, _reg ## _OFST, \
1135 EFSYS_PROBE4(efx_bar_readq, const char *, #_reg, \
1136 uint32_t, _reg ## _OFST, \
1137 uint32_t, (_eqp)->eq_u32[1], \
1138 uint32_t, (_eqp)->eq_u32[0]); \
1139 _NOTE(CONSTANTCONDITION) \
1142 #define EFX_BAR_WRITEQ(_enp, _reg, _eqp) \
1144 EFX_CHECK_REG((_enp), (_reg)); \
1145 EFSYS_PROBE4(efx_bar_writeq, const char *, #_reg, \
1146 uint32_t, _reg ## _OFST, \
1147 uint32_t, (_eqp)->eq_u32[1], \
1148 uint32_t, (_eqp)->eq_u32[0]); \
1149 EFSYS_BAR_WRITEQ((_enp)->en_esbp, _reg ## _OFST, \
1151 _NOTE(CONSTANTCONDITION) \
1154 #define EFX_BAR_READO(_enp, _reg, _eop) \
1156 EFX_CHECK_REG((_enp), (_reg)); \
1157 EFSYS_BAR_READO((_enp)->en_esbp, _reg ## _OFST, \
1159 EFSYS_PROBE6(efx_bar_reado, const char *, #_reg, \
1160 uint32_t, _reg ## _OFST, \
1161 uint32_t, (_eop)->eo_u32[3], \
1162 uint32_t, (_eop)->eo_u32[2], \
1163 uint32_t, (_eop)->eo_u32[1], \
1164 uint32_t, (_eop)->eo_u32[0]); \
1165 _NOTE(CONSTANTCONDITION) \
1168 #define EFX_BAR_WRITEO(_enp, _reg, _eop) \
1170 EFX_CHECK_REG((_enp), (_reg)); \
1171 EFSYS_PROBE6(efx_bar_writeo, const char *, #_reg, \
1172 uint32_t, _reg ## _OFST, \
1173 uint32_t, (_eop)->eo_u32[3], \
1174 uint32_t, (_eop)->eo_u32[2], \
1175 uint32_t, (_eop)->eo_u32[1], \
1176 uint32_t, (_eop)->eo_u32[0]); \
1177 EFSYS_BAR_WRITEO((_enp)->en_esbp, _reg ## _OFST, \
1179 _NOTE(CONSTANTCONDITION) \
1183 * Accessors for memory BAR non-VI tables.
1185 * Code used on EF10 *must* use EFX_BAR_VI_*() macros for per-VI registers,
1186 * to ensure the correct runtime VI window size is used on Medford2.
1188 * Code used on EF100 *must* use EFX_BAR_FCW_* macros for function control
1189 * window registers, to ensure the correct starting offset is used.
1191 * Siena-only code may continue using EFX_BAR_TBL_*() macros for VI registers.
1194 #define EFX_BAR_TBL_READD(_enp, _reg, _index, _edp, _lock) \
1196 EFX_CHECK_REG((_enp), (_reg)); \
1197 EFSYS_BAR_READD((_enp)->en_esbp, \
1198 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1200 EFSYS_PROBE4(efx_bar_tbl_readd, const char *, #_reg, \
1201 uint32_t, (_index), \
1202 uint32_t, _reg ## _OFST, \
1203 uint32_t, (_edp)->ed_u32[0]); \
1204 _NOTE(CONSTANTCONDITION) \
1207 #define EFX_BAR_TBL_WRITED(_enp, _reg, _index, _edp, _lock) \
1209 EFX_CHECK_REG((_enp), (_reg)); \
1210 EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg, \
1211 uint32_t, (_index), \
1212 uint32_t, _reg ## _OFST, \
1213 uint32_t, (_edp)->ed_u32[0]); \
1214 EFSYS_BAR_WRITED((_enp)->en_esbp, \
1215 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1217 _NOTE(CONSTANTCONDITION) \
1220 #define EFX_BAR_TBL_WRITED3(_enp, _reg, _index, _edp, _lock) \
1222 EFX_CHECK_REG((_enp), (_reg)); \
1223 EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg, \
1224 uint32_t, (_index), \
1225 uint32_t, _reg ## _OFST, \
1226 uint32_t, (_edp)->ed_u32[0]); \
1227 EFSYS_BAR_WRITED((_enp)->en_esbp, \
1229 (3 * sizeof (efx_dword_t)) + \
1230 ((_index) * _reg ## _STEP)), \
1232 _NOTE(CONSTANTCONDITION) \
1235 #define EFX_BAR_TBL_READQ(_enp, _reg, _index, _eqp) \
1237 EFX_CHECK_REG((_enp), (_reg)); \
1238 EFSYS_BAR_READQ((_enp)->en_esbp, \
1239 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1241 EFSYS_PROBE5(efx_bar_tbl_readq, const char *, #_reg, \
1242 uint32_t, (_index), \
1243 uint32_t, _reg ## _OFST, \
1244 uint32_t, (_eqp)->eq_u32[1], \
1245 uint32_t, (_eqp)->eq_u32[0]); \
1246 _NOTE(CONSTANTCONDITION) \
1249 #define EFX_BAR_TBL_WRITEQ(_enp, _reg, _index, _eqp) \
1251 EFX_CHECK_REG((_enp), (_reg)); \
1252 EFSYS_PROBE5(efx_bar_tbl_writeq, const char *, #_reg, \
1253 uint32_t, (_index), \
1254 uint32_t, _reg ## _OFST, \
1255 uint32_t, (_eqp)->eq_u32[1], \
1256 uint32_t, (_eqp)->eq_u32[0]); \
1257 EFSYS_BAR_WRITEQ((_enp)->en_esbp, \
1258 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1260 _NOTE(CONSTANTCONDITION) \
1263 #define EFX_BAR_TBL_READO(_enp, _reg, _index, _eop, _lock) \
1265 EFX_CHECK_REG((_enp), (_reg)); \
1266 EFSYS_BAR_READO((_enp)->en_esbp, \
1267 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1269 EFSYS_PROBE7(efx_bar_tbl_reado, const char *, #_reg, \
1270 uint32_t, (_index), \
1271 uint32_t, _reg ## _OFST, \
1272 uint32_t, (_eop)->eo_u32[3], \
1273 uint32_t, (_eop)->eo_u32[2], \
1274 uint32_t, (_eop)->eo_u32[1], \
1275 uint32_t, (_eop)->eo_u32[0]); \
1276 _NOTE(CONSTANTCONDITION) \
1279 #define EFX_BAR_TBL_WRITEO(_enp, _reg, _index, _eop, _lock) \
1281 EFX_CHECK_REG((_enp), (_reg)); \
1282 EFSYS_PROBE7(efx_bar_tbl_writeo, const char *, #_reg, \
1283 uint32_t, (_index), \
1284 uint32_t, _reg ## _OFST, \
1285 uint32_t, (_eop)->eo_u32[3], \
1286 uint32_t, (_eop)->eo_u32[2], \
1287 uint32_t, (_eop)->eo_u32[1], \
1288 uint32_t, (_eop)->eo_u32[0]); \
1289 EFSYS_BAR_WRITEO((_enp)->en_esbp, \
1290 (_reg ## _OFST + ((_index) * _reg ## _STEP)), \
1292 _NOTE(CONSTANTCONDITION) \
1296 * Accessors for memory BAR function control window registers.
1298 * The function control window is located at an offset which can be
1299 * non-zero in case of Riverhead.
1302 #if EFSYS_OPT_RIVERHEAD
1304 #define EFX_BAR_FCW_READD(_enp, _reg, _edp) \
1306 EFX_CHECK_REG((_enp), (_reg)); \
1307 EFSYS_BAR_READD((_enp)->en_esbp, _reg ## _OFST + \
1308 (_enp)->en_arch.ef10.ena_fcw_base, \
1310 EFSYS_PROBE3(efx_bar_fcw_readd, const char *, #_reg, \
1311 uint32_t, _reg ## _OFST, \
1312 uint32_t, (_edp)->ed_u32[0]); \
1313 _NOTE(CONSTANTCONDITION) \
1316 #define EFX_BAR_FCW_WRITED(_enp, _reg, _edp) \
1318 EFX_CHECK_REG((_enp), (_reg)); \
1319 EFSYS_PROBE3(efx_bar_fcw_writed, const char *, #_reg, \
1320 uint32_t, _reg ## _OFST, \
1321 uint32_t, (_edp)->ed_u32[0]); \
1322 EFSYS_BAR_WRITED((_enp)->en_esbp, _reg ## _OFST + \
1323 (_enp)->en_arch.ef10.ena_fcw_base, \
1325 _NOTE(CONSTANTCONDITION) \
1328 #endif /* EFSYS_OPT_RIVERHEAD */
1331 * Accessors for memory BAR per-VI registers.
1333 * The VI window size is 8KB for Medford and all earlier controllers.
1334 * For Medford2, the VI window size can be 8KB, 16KB or 64KB.
1337 #define EFX_BAR_VI_READD(_enp, _reg, _index, _edp, _lock) \
1339 EFX_CHECK_REG((_enp), (_reg)); \
1340 EFSYS_BAR_READD((_enp)->en_esbp, \
1341 ((_reg ## _OFST) + \
1342 ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1344 EFSYS_PROBE4(efx_bar_vi_readd, const char *, #_reg, \
1345 uint32_t, (_index), \
1346 uint32_t, _reg ## _OFST, \
1347 uint32_t, (_edp)->ed_u32[0]); \
1348 _NOTE(CONSTANTCONDITION) \
1351 #define EFX_BAR_VI_WRITED(_enp, _reg, _index, _edp, _lock) \
1353 EFX_CHECK_REG((_enp), (_reg)); \
1354 EFSYS_PROBE4(efx_bar_vi_writed, const char *, #_reg, \
1355 uint32_t, (_index), \
1356 uint32_t, _reg ## _OFST, \
1357 uint32_t, (_edp)->ed_u32[0]); \
1358 EFSYS_BAR_WRITED((_enp)->en_esbp, \
1359 ((_reg ## _OFST) + \
1360 ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1362 _NOTE(CONSTANTCONDITION) \
1365 #define EFX_BAR_VI_WRITED2(_enp, _reg, _index, _edp, _lock) \
1367 EFX_CHECK_REG((_enp), (_reg)); \
1368 EFSYS_PROBE4(efx_bar_vi_writed, const char *, #_reg, \
1369 uint32_t, (_index), \
1370 uint32_t, _reg ## _OFST, \
1371 uint32_t, (_edp)->ed_u32[0]); \
1372 EFSYS_BAR_WRITED((_enp)->en_esbp, \
1373 ((_reg ## _OFST) + \
1374 (2 * sizeof (efx_dword_t)) + \
1375 ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1377 _NOTE(CONSTANTCONDITION) \
1381 * Allow drivers to perform optimised 128-bit VI doorbell writes.
1382 * The DMA descriptor pointers (RX_DESC_UPD and TX_DESC_UPD) are
1383 * special-cased in the BIU on the Falcon/Siena and EF10 architectures to avoid
1384 * the need for locking in the host, and are the only ones known to be safe to
1385 * use 128-bites write with.
1387 #define EFX_BAR_VI_DOORBELL_WRITEO(_enp, _reg, _index, _eop) \
1389 EFX_CHECK_REG((_enp), (_reg)); \
1390 EFSYS_PROBE7(efx_bar_vi_doorbell_writeo, \
1391 const char *, #_reg, \
1392 uint32_t, (_index), \
1393 uint32_t, _reg ## _OFST, \
1394 uint32_t, (_eop)->eo_u32[3], \
1395 uint32_t, (_eop)->eo_u32[2], \
1396 uint32_t, (_eop)->eo_u32[1], \
1397 uint32_t, (_eop)->eo_u32[0]); \
1398 EFSYS_BAR_DOORBELL_WRITEO((_enp)->en_esbp, \
1400 ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1402 _NOTE(CONSTANTCONDITION) \
1405 #define EFX_DMA_SYNC_QUEUE_FOR_DEVICE(_esmp, _entries, _desc_size, \
1408 unsigned int _new = (_wptr); \
1409 unsigned int _old = (_owptr); \
1411 if ((_new) >= (_old)) \
1412 EFSYS_DMA_SYNC_FOR_DEVICE((_esmp), \
1413 (_old) * (_desc_size), \
1414 ((_new) - (_old)) * (_desc_size)); \
1417 * It is cheaper to sync entire map than sync \
1418 * two parts especially when offset/size are \
1419 * ignored and entire map is synced in any case.\
1421 EFSYS_DMA_SYNC_FOR_DEVICE((_esmp), \
1423 (_entries) * (_desc_size)); \
1424 _NOTE(CONSTANTCONDITION) \
1428 extern __checkReturn efx_rc_t
1430 __in efx_nic_t *enp);
1434 efx_mac_multicast_hash_compute(
1435 __in_ecount(6*count) uint8_t const *addrs,
1437 __out efx_oword_t *hash_low,
1438 __out efx_oword_t *hash_high);
1441 extern __checkReturn efx_rc_t
1443 __in efx_nic_t *enp);
1448 __in efx_nic_t *enp);
1452 /* VPD utility functions */
1455 extern __checkReturn efx_rc_t
1456 efx_vpd_hunk_length(
1457 __in_bcount(size) caddr_t data,
1459 __out size_t *lengthp);
1462 extern __checkReturn efx_rc_t
1463 efx_vpd_hunk_verify(
1464 __in_bcount(size) caddr_t data,
1466 __out_opt boolean_t *cksummedp);
1469 extern __checkReturn efx_rc_t
1470 efx_vpd_hunk_reinit(
1471 __in_bcount(size) caddr_t data,
1473 __in boolean_t wantpid);
1476 extern __checkReturn efx_rc_t
1478 __in_bcount(size) caddr_t data,
1480 __in efx_vpd_tag_t tag,
1481 __in efx_vpd_keyword_t keyword,
1482 __out unsigned int *payloadp,
1483 __out uint8_t *paylenp);
1486 extern __checkReturn efx_rc_t
1488 __in_bcount(size) caddr_t data,
1490 __out efx_vpd_tag_t *tagp,
1491 __out efx_vpd_keyword_t *keyword,
1492 __out_opt unsigned int *payloadp,
1493 __out_opt uint8_t *paylenp,
1494 __inout unsigned int *contp);
1497 extern __checkReturn efx_rc_t
1499 __in_bcount(size) caddr_t data,
1501 __in efx_vpd_value_t *evvp);
1503 #endif /* EFSYS_OPT_VPD */
1508 extern __checkReturn efx_rc_t
1509 efx_mcdi_set_workaround(
1510 __in efx_nic_t *enp,
1512 __in boolean_t enabled,
1513 __out_opt uint32_t *flagsp);
1516 extern __checkReturn efx_rc_t
1517 efx_mcdi_get_workarounds(
1518 __in efx_nic_t *enp,
1519 __out_opt uint32_t *implementedp,
1520 __out_opt uint32_t *enabledp);
1522 #if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
1525 extern __checkReturn efx_rc_t
1527 __in efx_nic_t *enp,
1528 __in unsigned int instance,
1529 __in efsys_mem_t *esmp,
1533 __in uint32_t flags,
1534 __in boolean_t low_latency);
1537 extern __checkReturn efx_rc_t
1539 __in efx_nic_t *enp,
1540 __in uint32_t instance);
1542 typedef struct efx_mcdi_init_rxq_params_s {
1543 boolean_t disable_scatter;
1544 boolean_t want_inner_classes;
1546 uint32_t ps_buf_size;
1547 uint32_t es_bufs_per_desc;
1548 uint32_t es_max_dma_len;
1549 uint32_t es_buf_stride;
1550 uint32_t hol_block_timeout;
1552 } efx_mcdi_init_rxq_params_t;
1555 extern __checkReturn efx_rc_t
1557 __in efx_nic_t *enp,
1558 __in uint32_t ndescs,
1559 __in efx_evq_t *eep,
1560 __in uint32_t label,
1561 __in uint32_t instance,
1562 __in efsys_mem_t *esmp,
1563 __in const efx_mcdi_init_rxq_params_t *params);
1566 extern __checkReturn efx_rc_t
1568 __in efx_nic_t *enp,
1569 __in uint32_t instance);
1572 extern __checkReturn efx_rc_t
1574 __in efx_nic_t *enp,
1575 __in uint32_t ndescs,
1576 __in uint32_t target_evq,
1577 __in uint32_t label,
1578 __in uint32_t instance,
1579 __in uint16_t flags,
1580 __in efsys_mem_t *esmp);
1583 extern __checkReturn efx_rc_t
1585 __in efx_nic_t *enp,
1586 __in uint32_t instance);
1588 #endif /* EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10() */
1590 #endif /* EFSYS_OPT_MCDI */
1592 #if EFSYS_OPT_MAC_STATS
1595 * Closed range of stats (i.e. the first and the last are included).
1596 * The last must be greater or equal (if the range is one item only) to
1599 struct efx_mac_stats_range {
1600 efx_mac_stat_t first;
1601 efx_mac_stat_t last;
1604 typedef enum efx_stats_action_e {
1607 EFX_STATS_ENABLE_NOEVENTS,
1608 EFX_STATS_ENABLE_EVENTS,
1610 } efx_stats_action_t;
1614 efx_mac_stats_mask_add_ranges(
1615 __inout_bcount(mask_size) uint32_t *maskp,
1616 __in size_t mask_size,
1617 __in_ecount(rng_count) const struct efx_mac_stats_range *rngp,
1618 __in unsigned int rng_count);
1621 extern __checkReturn efx_rc_t
1623 __in efx_nic_t *enp,
1624 __in uint32_t vport_id,
1625 __in_opt efsys_mem_t *esmp,
1626 __in efx_stats_action_t action,
1627 __in uint16_t period_ms);
1629 #endif /* EFSYS_OPT_MAC_STATS */
1634 * Find the next extended capability in a PCI device's config space
1635 * with specified capability id.
1636 * Passing 0 offset makes the function search from the start.
1637 * If search succeeds, found capability is in modified offset.
1639 * Returns ENOENT if a capability is not found.
1642 extern __checkReturn efx_rc_t
1643 efx_pci_config_find_next_ext_cap(
1644 __in efsys_pci_config_t *espcp,
1645 __in const efx_pci_ops_t *epop,
1646 __in uint16_t cap_id,
1647 __inout size_t *offsetp);
1650 * Get the next extended capability in a PCI device's config space.
1651 * Passing 0 offset makes the function get the first capability.
1652 * If search succeeds, the capability is in modified offset.
1654 * Returns ENOENT if there is no next capability.
1657 extern __checkReturn efx_rc_t
1658 efx_pci_config_next_ext_cap(
1659 __in efsys_pci_config_t *espcp,
1660 __in const efx_pci_ops_t *epop,
1661 __inout size_t *offsetp);
1664 * Find the next Xilinx capabilities table location by searching
1665 * PCI extended capabilities.
1667 * Returns ENOENT if a table location is not found.
1670 extern __checkReturn efx_rc_t
1671 efx_pci_find_next_xilinx_cap_table(
1672 __in efsys_pci_config_t *espcp,
1673 __in const efx_pci_ops_t *epop,
1674 __inout size_t *pci_cap_offsetp,
1675 __out unsigned int *xilinx_tbl_barp,
1676 __out efsys_dma_addr_t *xilinx_tbl_offsetp);
1679 * Read a Xilinx extended PCI capability that gives the location
1680 * of a Xilinx capabilities table.
1682 * Returns ENOENT if the extended PCI capability does not contain
1683 * Xilinx capabilities table locator.
1686 extern __checkReturn efx_rc_t
1687 efx_pci_read_ext_cap_xilinx_table(
1688 __in efsys_pci_config_t *espcp,
1689 __in const efx_pci_ops_t *epop,
1690 __in size_t cap_offset,
1691 __out unsigned int *barp,
1692 __out efsys_dma_addr_t *offsetp);
1695 * Find a capability with specified format_id in a Xilinx capabilities table.
1696 * Searching is started from provided offset, taking skip_first into account.
1697 * If search succeeds, found capability is in modified offset.
1699 * Returns ENOENT if an entry with specified format id is not found.
1702 extern __checkReturn efx_rc_t
1703 efx_pci_xilinx_cap_tbl_find(
1704 __in efsys_bar_t *esbp,
1705 __in uint32_t format_id,
1706 __in boolean_t skip_first,
1707 __inout efsys_dma_addr_t *entry_offsetp);
1709 #endif /* EFSYS_OPT_PCI */
1713 struct efx_mae_match_spec_s {
1714 efx_mae_rule_type_t emms_type;
1716 union emms_mask_value_pairs {
1717 uint8_t action[MAE_FIELD_MASK_VALUE_PAIRS_LEN];
1718 uint8_t outer[MAE_ENC_FIELD_PAIRS_LEN];
1719 } emms_mask_value_pairs;
1722 typedef enum efx_mae_action_e {
1723 /* These actions are strictly ordered. */
1724 EFX_MAE_ACTION_VLAN_POP,
1725 EFX_MAE_ACTION_VLAN_PUSH,
1728 * These actions are not strictly ordered and can
1729 * be passed by a client in any order (before DELIVER).
1730 * However, these enumerants must be kept compactly
1731 * in the end of the enumeration (before DELIVER).
1733 EFX_MAE_ACTION_FLAG,
1734 EFX_MAE_ACTION_MARK,
1736 /* DELIVER is always the last action. */
1737 EFX_MAE_ACTION_DELIVER,
1742 /* MAE VLAN_POP action can handle 1 or 2 tags. */
1743 #define EFX_MAE_VLAN_POP_MAX_NTAGS (2)
1745 /* MAE VLAN_PUSH action can handle 1 or 2 tags. */
1746 #define EFX_MAE_VLAN_PUSH_MAX_NTAGS (2)
1748 typedef struct efx_mae_action_vlan_push_s {
1749 uint16_t emavp_tpid_be;
1750 uint16_t emavp_tci_be;
1751 } efx_mae_action_vlan_push_t;
1753 struct efx_mae_actions_s {
1754 /* Bitmap of actions in spec, indexed by action type */
1755 uint32_t ema_actions;
1757 unsigned int ema_n_vlan_tags_to_pop;
1758 unsigned int ema_n_vlan_tags_to_push;
1759 efx_mae_action_vlan_push_t ema_vlan_push_descs[
1760 EFX_MAE_VLAN_PUSH_MAX_NTAGS];
1761 uint32_t ema_mark_value;
1762 efx_mport_sel_t ema_deliver_mport;
1765 #endif /* EFSYS_OPT_MAE */
1767 #if EFSYS_OPT_VIRTIO
1769 #define EFX_VQ_MAGIC 0x026011950
1771 typedef enum efx_virtio_vq_state_e {
1772 EFX_VIRTIO_VQ_STATE_UNKNOWN = 0,
1773 EFX_VIRTIO_VQ_STATE_INITIALIZED,
1774 EFX_VIRTIO_VQ_STATE_STARTED,
1775 EFX_VIRTIO_VQ_NSTATES
1776 } efx_virtio_vq_state_t;
1778 struct efx_virtio_vq_s {
1781 efx_virtio_vq_state_t evv_state;
1782 uint32_t evv_vi_index;
1783 efx_virtio_vq_type_t evv_type;
1784 uint16_t evv_target_vf;
1787 #endif /* EFSYS_OPT_VIRTIO */
1793 #endif /* _SYS_EFX_IMPL_H */