xref: /freebsd/sys/dev/sfxge/common/efx_impl.h (revision b2053d80255fccf7a4be3a1184f6832af2b7f199)
1e948693eSPhilip Paeps /*-
2718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3718cf2ccSPedro F. Giffuni  *
4929c7febSAndrew Rybchenko  * Copyright (c) 2007-2016 Solarflare Communications Inc.
53c838a9fSAndrew Rybchenko  * All rights reserved.
6e948693eSPhilip Paeps  *
7e948693eSPhilip Paeps  * Redistribution and use in source and binary forms, with or without
83c838a9fSAndrew Rybchenko  * modification, are permitted provided that the following conditions are met:
9e948693eSPhilip Paeps  *
103c838a9fSAndrew Rybchenko  * 1. Redistributions of source code must retain the above copyright notice,
113c838a9fSAndrew Rybchenko  *    this list of conditions and the following disclaimer.
123c838a9fSAndrew Rybchenko  * 2. Redistributions in binary form must reproduce the above copyright notice,
133c838a9fSAndrew Rybchenko  *    this list of conditions and the following disclaimer in the documentation
143c838a9fSAndrew Rybchenko  *    and/or other materials provided with the distribution.
153c838a9fSAndrew Rybchenko  *
163c838a9fSAndrew Rybchenko  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
173c838a9fSAndrew Rybchenko  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
183c838a9fSAndrew Rybchenko  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
193c838a9fSAndrew Rybchenko  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
203c838a9fSAndrew Rybchenko  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
213c838a9fSAndrew Rybchenko  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
223c838a9fSAndrew Rybchenko  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
233c838a9fSAndrew Rybchenko  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
243c838a9fSAndrew Rybchenko  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
253c838a9fSAndrew Rybchenko  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
263c838a9fSAndrew Rybchenko  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273c838a9fSAndrew Rybchenko  *
283c838a9fSAndrew Rybchenko  * The views and conclusions contained in the software and documentation are
293c838a9fSAndrew Rybchenko  * those of the authors and should not be interpreted as representing official
303c838a9fSAndrew Rybchenko  * policies, either expressed or implied, of the FreeBSD Project.
315dee87d7SPhilip Paeps  *
325dee87d7SPhilip Paeps  * $FreeBSD$
33e948693eSPhilip Paeps  */
34e948693eSPhilip Paeps 
35e948693eSPhilip Paeps #ifndef	_SYS_EFX_IMPL_H
36e948693eSPhilip Paeps #define	_SYS_EFX_IMPL_H
37e948693eSPhilip Paeps 
38e948693eSPhilip Paeps #include "efx.h"
39e948693eSPhilip Paeps #include "efx_regs.h"
403c838a9fSAndrew Rybchenko #include "efx_regs_ef10.h"
413c838a9fSAndrew Rybchenko 
423c838a9fSAndrew Rybchenko /* FIXME: Add definition for driver generated software events */
433c838a9fSAndrew Rybchenko #ifndef	ESE_DZ_EV_CODE_DRV_GEN_EV
443c838a9fSAndrew Rybchenko #define	ESE_DZ_EV_CODE_DRV_GEN_EV FSE_AZ_EV_CODE_DRV_GEN_EV
453c838a9fSAndrew Rybchenko #endif
463c838a9fSAndrew Rybchenko 
47e948693eSPhilip Paeps 
48e948693eSPhilip Paeps #if EFSYS_OPT_SIENA
49e948693eSPhilip Paeps #include "siena_impl.h"
50e948693eSPhilip Paeps #endif	/* EFSYS_OPT_SIENA */
51e948693eSPhilip Paeps 
523c838a9fSAndrew Rybchenko #if EFSYS_OPT_HUNTINGTON
533c838a9fSAndrew Rybchenko #include "hunt_impl.h"
543c838a9fSAndrew Rybchenko #endif	/* EFSYS_OPT_HUNTINGTON */
553c838a9fSAndrew Rybchenko 
565f5c71ccSAndrew Rybchenko #if EFSYS_OPT_MEDFORD
575f5c71ccSAndrew Rybchenko #include "medford_impl.h"
585f5c71ccSAndrew Rybchenko #endif	/* EFSYS_OPT_MEDFORD */
595f5c71ccSAndrew Rybchenko 
60ae64ac93SAndrew Rybchenko #if EFSYS_OPT_MEDFORD2
61ae64ac93SAndrew Rybchenko #include "medford2_impl.h"
62ae64ac93SAndrew Rybchenko #endif	/* EFSYS_OPT_MEDFORD2 */
63ae64ac93SAndrew Rybchenko 
64ae64ac93SAndrew Rybchenko #if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
655f5c71ccSAndrew Rybchenko #include "ef10_impl.h"
66ae64ac93SAndrew Rybchenko #endif	/* (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2) */
675f5c71ccSAndrew Rybchenko 
68e948693eSPhilip Paeps #ifdef	__cplusplus
69e948693eSPhilip Paeps extern "C" {
70e948693eSPhilip Paeps #endif
71e948693eSPhilip Paeps 
72e948693eSPhilip Paeps #define	EFX_MOD_MCDI		0x00000001
73e948693eSPhilip Paeps #define	EFX_MOD_PROBE		0x00000002
74e948693eSPhilip Paeps #define	EFX_MOD_NVRAM		0x00000004
75e948693eSPhilip Paeps #define	EFX_MOD_VPD		0x00000008
76e948693eSPhilip Paeps #define	EFX_MOD_NIC		0x00000010
77e948693eSPhilip Paeps #define	EFX_MOD_INTR		0x00000020
78e948693eSPhilip Paeps #define	EFX_MOD_EV		0x00000040
79e948693eSPhilip Paeps #define	EFX_MOD_RX		0x00000080
80e948693eSPhilip Paeps #define	EFX_MOD_TX		0x00000100
81e948693eSPhilip Paeps #define	EFX_MOD_PORT		0x00000200
82e948693eSPhilip Paeps #define	EFX_MOD_MON		0x00000400
83e948693eSPhilip Paeps #define	EFX_MOD_FILTER		0x00001000
84908ecfc6SAndrew Rybchenko #define	EFX_MOD_LIC		0x00002000
85fdbe38cfSAndrew Rybchenko #define	EFX_MOD_TUNNEL		0x00004000
86e948693eSPhilip Paeps 
870c909247SAndrew Rybchenko #define	EFX_RESET_PHY		0x00000001
880c909247SAndrew Rybchenko #define	EFX_RESET_RXQ_ERR	0x00000002
890c909247SAndrew Rybchenko #define	EFX_RESET_TXQ_ERR	0x00000004
90c6d5e85dSAndrew Rybchenko #define	EFX_RESET_HW_UNAVAIL	0x00000008
91e948693eSPhilip Paeps 
92e948693eSPhilip Paeps typedef enum efx_mac_type_e {
93e948693eSPhilip Paeps 	EFX_MAC_INVALID = 0,
94e948693eSPhilip Paeps 	EFX_MAC_SIENA,
953c838a9fSAndrew Rybchenko 	EFX_MAC_HUNTINGTON,
96c15d6d21SAndrew Rybchenko 	EFX_MAC_MEDFORD,
97cbc3f94fSAndrew Rybchenko 	EFX_MAC_MEDFORD2,
98e948693eSPhilip Paeps 	EFX_MAC_NTYPES
99e948693eSPhilip Paeps } efx_mac_type_t;
100e948693eSPhilip Paeps 
1013c838a9fSAndrew Rybchenko typedef struct efx_ev_ops_s {
102460cb568SAndrew Rybchenko 	efx_rc_t	(*eevo_init)(efx_nic_t *);
1033c838a9fSAndrew Rybchenko 	void		(*eevo_fini)(efx_nic_t *);
104460cb568SAndrew Rybchenko 	efx_rc_t	(*eevo_qcreate)(efx_nic_t *, unsigned int,
1053c838a9fSAndrew Rybchenko 					  efsys_mem_t *, size_t, uint32_t,
106a3fe009aSAndrew Rybchenko 					  uint32_t, uint32_t, efx_evq_t *);
1073c838a9fSAndrew Rybchenko 	void		(*eevo_qdestroy)(efx_evq_t *);
108460cb568SAndrew Rybchenko 	efx_rc_t	(*eevo_qprime)(efx_evq_t *, unsigned int);
1093c838a9fSAndrew Rybchenko 	void		(*eevo_qpost)(efx_evq_t *, uint16_t);
110460cb568SAndrew Rybchenko 	efx_rc_t	(*eevo_qmoderate)(efx_evq_t *, unsigned int);
1113c838a9fSAndrew Rybchenko #if EFSYS_OPT_QSTATS
1123c838a9fSAndrew Rybchenko 	void		(*eevo_qstats_update)(efx_evq_t *, efsys_stat_t *);
1133c838a9fSAndrew Rybchenko #endif
1143c838a9fSAndrew Rybchenko } efx_ev_ops_t;
1153c838a9fSAndrew Rybchenko 
1163c838a9fSAndrew Rybchenko typedef struct efx_tx_ops_s {
117460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_init)(efx_nic_t *);
1183c838a9fSAndrew Rybchenko 	void		(*etxo_fini)(efx_nic_t *);
119460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_qcreate)(efx_nic_t *,
1203c838a9fSAndrew Rybchenko 					unsigned int, unsigned int,
1213c838a9fSAndrew Rybchenko 					efsys_mem_t *, size_t,
1223c838a9fSAndrew Rybchenko 					uint32_t, uint16_t,
1233c838a9fSAndrew Rybchenko 					efx_evq_t *, efx_txq_t *,
1243c838a9fSAndrew Rybchenko 					unsigned int *);
1253c838a9fSAndrew Rybchenko 	void		(*etxo_qdestroy)(efx_txq_t *);
126460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_qpost)(efx_txq_t *, efx_buffer_t *,
1273c838a9fSAndrew Rybchenko 				      unsigned int, unsigned int,
1283c838a9fSAndrew Rybchenko 				      unsigned int *);
1293c838a9fSAndrew Rybchenko 	void		(*etxo_qpush)(efx_txq_t *, unsigned int, unsigned int);
130460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_qpace)(efx_txq_t *, unsigned int);
131460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_qflush)(efx_txq_t *);
1323c838a9fSAndrew Rybchenko 	void		(*etxo_qenable)(efx_txq_t *);
133460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_qpio_enable)(efx_txq_t *);
1343c838a9fSAndrew Rybchenko 	void		(*etxo_qpio_disable)(efx_txq_t *);
135460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_qpio_write)(efx_txq_t *, uint8_t *, size_t,
1363c838a9fSAndrew Rybchenko 					   size_t);
137460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_qpio_post)(efx_txq_t *, size_t, unsigned int,
1383c838a9fSAndrew Rybchenko 					   unsigned int *);
139460cb568SAndrew Rybchenko 	efx_rc_t	(*etxo_qdesc_post)(efx_txq_t *, efx_desc_t *,
1403c838a9fSAndrew Rybchenko 				      unsigned int, unsigned int,
1413c838a9fSAndrew Rybchenko 				      unsigned int *);
1423c838a9fSAndrew Rybchenko 	void		(*etxo_qdesc_dma_create)(efx_txq_t *, efsys_dma_addr_t,
1433c838a9fSAndrew Rybchenko 						size_t, boolean_t,
1443c838a9fSAndrew Rybchenko 						efx_desc_t *);
1453c838a9fSAndrew Rybchenko 	void		(*etxo_qdesc_tso_create)(efx_txq_t *, uint16_t,
1463c838a9fSAndrew Rybchenko 						uint32_t, uint8_t,
1473c838a9fSAndrew Rybchenko 						efx_desc_t *);
1484ab49369SAndrew Rybchenko 	void		(*etxo_qdesc_tso2_create)(efx_txq_t *, uint16_t,
1494142e8cfSAndrew Rybchenko 						uint16_t, uint32_t, uint16_t,
1504ab49369SAndrew Rybchenko 						efx_desc_t *, int);
1513c838a9fSAndrew Rybchenko 	void		(*etxo_qdesc_vlantci_create)(efx_txq_t *, uint16_t,
1523c838a9fSAndrew Rybchenko 						efx_desc_t *);
1534effeb9eSAndrew Rybchenko 	void		(*etxo_qdesc_checksum_create)(efx_txq_t *, uint16_t,
1544effeb9eSAndrew Rybchenko 						efx_desc_t *);
1553c838a9fSAndrew Rybchenko #if EFSYS_OPT_QSTATS
1563c838a9fSAndrew Rybchenko 	void		(*etxo_qstats_update)(efx_txq_t *,
1573c838a9fSAndrew Rybchenko 					      efsys_stat_t *);
1583c838a9fSAndrew Rybchenko #endif
1593c838a9fSAndrew Rybchenko } efx_tx_ops_t;
1603c838a9fSAndrew Rybchenko 
1612a726a7fSAndrew Rybchenko typedef union efx_rxq_type_data_u {
1622a726a7fSAndrew Rybchenko 	/* Dummy member to have non-empty union if no options are enabled */
1632a726a7fSAndrew Rybchenko 	uint32_t	ertd_dummy;
1642a726a7fSAndrew Rybchenko #if EFSYS_OPT_RX_PACKED_STREAM
1652a726a7fSAndrew Rybchenko 	struct {
1662a726a7fSAndrew Rybchenko 		uint32_t	eps_buf_size;
1672a726a7fSAndrew Rybchenko 	} ertd_packed_stream;
1682a726a7fSAndrew Rybchenko #endif
16904381b5eSAndrew Rybchenko #if EFSYS_OPT_RX_ES_SUPER_BUFFER
17004381b5eSAndrew Rybchenko 	struct {
17104381b5eSAndrew Rybchenko 		uint32_t	eessb_bufs_per_desc;
17204381b5eSAndrew Rybchenko 		uint32_t	eessb_max_dma_len;
17304381b5eSAndrew Rybchenko 		uint32_t	eessb_buf_stride;
17404381b5eSAndrew Rybchenko 		uint32_t	eessb_hol_block_timeout;
17504381b5eSAndrew Rybchenko 	} ertd_es_super_buffer;
17604381b5eSAndrew Rybchenko #endif
1772a726a7fSAndrew Rybchenko } efx_rxq_type_data_t;
1782a726a7fSAndrew Rybchenko 
1793c838a9fSAndrew Rybchenko typedef struct efx_rx_ops_s {
180460cb568SAndrew Rybchenko 	efx_rc_t	(*erxo_init)(efx_nic_t *);
1813c838a9fSAndrew Rybchenko 	void		(*erxo_fini)(efx_nic_t *);
1823c838a9fSAndrew Rybchenko #if EFSYS_OPT_RX_SCATTER
183460cb568SAndrew Rybchenko 	efx_rc_t	(*erxo_scatter_enable)(efx_nic_t *, unsigned int);
1843c838a9fSAndrew Rybchenko #endif
1853c838a9fSAndrew Rybchenko #if EFSYS_OPT_RX_SCALE
186e6d55a0bSAndrew Rybchenko 	efx_rc_t	(*erxo_scale_context_alloc)(efx_nic_t *,
187e6d55a0bSAndrew Rybchenko 						    efx_rx_scale_context_type_t,
188e6d55a0bSAndrew Rybchenko 						    uint32_t, uint32_t *);
189e6d55a0bSAndrew Rybchenko 	efx_rc_t	(*erxo_scale_context_free)(efx_nic_t *, uint32_t);
19082af879cSAndrew Rybchenko 	efx_rc_t	(*erxo_scale_mode_set)(efx_nic_t *, uint32_t,
19182af879cSAndrew Rybchenko 					       efx_rx_hash_alg_t,
1923c838a9fSAndrew Rybchenko 					       efx_rx_hash_type_t, boolean_t);
19382af879cSAndrew Rybchenko 	efx_rc_t	(*erxo_scale_key_set)(efx_nic_t *, uint32_t,
19482af879cSAndrew Rybchenko 					      uint8_t *, size_t);
19582af879cSAndrew Rybchenko 	efx_rc_t	(*erxo_scale_tbl_set)(efx_nic_t *, uint32_t,
19682af879cSAndrew Rybchenko 					      unsigned int *, size_t);
1970badfd72SAndrew Rybchenko 	uint32_t	(*erxo_prefix_hash)(efx_nic_t *, efx_rx_hash_alg_t,
1980badfd72SAndrew Rybchenko 					    uint8_t *);
1990badfd72SAndrew Rybchenko #endif /* EFSYS_OPT_RX_SCALE */
2000badfd72SAndrew Rybchenko 	efx_rc_t	(*erxo_prefix_pktlen)(efx_nic_t *, uint8_t *,
2010badfd72SAndrew Rybchenko 					      uint16_t *);
2023c838a9fSAndrew Rybchenko 	void		(*erxo_qpost)(efx_rxq_t *, efsys_dma_addr_t *, size_t,
2033c838a9fSAndrew Rybchenko 				      unsigned int, unsigned int,
2043c838a9fSAndrew Rybchenko 				      unsigned int);
2053c838a9fSAndrew Rybchenko 	void		(*erxo_qpush)(efx_rxq_t *, unsigned int, unsigned int *);
2068e0c4827SAndrew Rybchenko #if EFSYS_OPT_RX_PACKED_STREAM
2078e0c4827SAndrew Rybchenko 	void		(*erxo_qpush_ps_credits)(efx_rxq_t *);
2088e0c4827SAndrew Rybchenko 	uint8_t *	(*erxo_qps_packet_info)(efx_rxq_t *, uint8_t *,
2098e0c4827SAndrew Rybchenko 						uint32_t, uint32_t,
2108e0c4827SAndrew Rybchenko 						uint16_t *, uint32_t *, uint32_t *);
2118e0c4827SAndrew Rybchenko #endif
212460cb568SAndrew Rybchenko 	efx_rc_t	(*erxo_qflush)(efx_rxq_t *);
2133c838a9fSAndrew Rybchenko 	void		(*erxo_qenable)(efx_rxq_t *);
214460cb568SAndrew Rybchenko 	efx_rc_t	(*erxo_qcreate)(efx_nic_t *enp, unsigned int,
2152a726a7fSAndrew Rybchenko 					unsigned int, efx_rxq_type_t,
2162a726a7fSAndrew Rybchenko 					const efx_rxq_type_data_t *,
2173c838a9fSAndrew Rybchenko 					efsys_mem_t *, size_t, uint32_t,
2189445d1c5SAndrew Rybchenko 					unsigned int,
2193c838a9fSAndrew Rybchenko 					efx_evq_t *, efx_rxq_t *);
2203c838a9fSAndrew Rybchenko 	void		(*erxo_qdestroy)(efx_rxq_t *);
2213c838a9fSAndrew Rybchenko } efx_rx_ops_t;
2223c838a9fSAndrew Rybchenko 
223e948693eSPhilip Paeps typedef struct efx_mac_ops_s {
224460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_poll)(efx_nic_t *, efx_link_mode_t *);
225460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_up)(efx_nic_t *, boolean_t *);
226460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_addr_set)(efx_nic_t *);
22708c5af79SAndrew Rybchenko 	efx_rc_t	(*emo_pdu_set)(efx_nic_t *);
228d8484af2SAndrew Rybchenko 	efx_rc_t	(*emo_pdu_get)(efx_nic_t *, size_t *);
229460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_reconfigure)(efx_nic_t *);
230460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_multicast_list_set)(efx_nic_t *);
231460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_filter_default_rxq_set)(efx_nic_t *,
2323c838a9fSAndrew Rybchenko 						      efx_rxq_t *, boolean_t);
2333c838a9fSAndrew Rybchenko 	void		(*emo_filter_default_rxq_clear)(efx_nic_t *);
234e948693eSPhilip Paeps #if EFSYS_OPT_LOOPBACK
235460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_loopback_set)(efx_nic_t *, efx_link_mode_t,
236e948693eSPhilip Paeps 					    efx_loopback_type_t);
237e948693eSPhilip Paeps #endif	/* EFSYS_OPT_LOOPBACK */
238e948693eSPhilip Paeps #if EFSYS_OPT_MAC_STATS
23958a72cb2SAndrew Rybchenko 	efx_rc_t	(*emo_stats_get_mask)(efx_nic_t *, uint32_t *, size_t);
24031e518b4SAndrew Rybchenko 	efx_rc_t	(*emo_stats_clear)(efx_nic_t *);
241460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_stats_upload)(efx_nic_t *, efsys_mem_t *);
242460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_stats_periodic)(efx_nic_t *, efsys_mem_t *,
243e948693eSPhilip Paeps 					      uint16_t, boolean_t);
244460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_stats_update)(efx_nic_t *, efsys_mem_t *,
245e948693eSPhilip Paeps 					    efsys_stat_t *, uint32_t *);
246e948693eSPhilip Paeps #endif	/* EFSYS_OPT_MAC_STATS */
247e948693eSPhilip Paeps } efx_mac_ops_t;
248e948693eSPhilip Paeps 
249e948693eSPhilip Paeps typedef struct efx_phy_ops_s {
250460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_power)(efx_nic_t *, boolean_t); /* optional */
251460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_reset)(efx_nic_t *);
252460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_reconfigure)(efx_nic_t *);
253460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_verify)(efx_nic_t *);
254460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_oui_get)(efx_nic_t *, uint32_t *);
255e948693eSPhilip Paeps #if EFSYS_OPT_PHY_STATS
256460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_stats_update)(efx_nic_t *, efsys_mem_t *,
257e948693eSPhilip Paeps 					    uint32_t *);
258e948693eSPhilip Paeps #endif	/* EFSYS_OPT_PHY_STATS */
2593c838a9fSAndrew Rybchenko #if EFSYS_OPT_BIST
260460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_bist_enable_offline)(efx_nic_t *);
261460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_bist_start)(efx_nic_t *, efx_bist_type_t);
262460cb568SAndrew Rybchenko 	efx_rc_t	(*epo_bist_poll)(efx_nic_t *, efx_bist_type_t,
2633c838a9fSAndrew Rybchenko 					 efx_bist_result_t *, uint32_t *,
264e948693eSPhilip Paeps 					 unsigned long *, size_t);
2653c838a9fSAndrew Rybchenko 	void		(*epo_bist_stop)(efx_nic_t *, efx_bist_type_t);
2663c838a9fSAndrew Rybchenko #endif	/* EFSYS_OPT_BIST */
267e948693eSPhilip Paeps } efx_phy_ops_t;
268e948693eSPhilip Paeps 
2693c838a9fSAndrew Rybchenko #if EFSYS_OPT_FILTER
2703c838a9fSAndrew Rybchenko typedef struct efx_filter_ops_s {
271460cb568SAndrew Rybchenko 	efx_rc_t	(*efo_init)(efx_nic_t *);
2723c838a9fSAndrew Rybchenko 	void		(*efo_fini)(efx_nic_t *);
273460cb568SAndrew Rybchenko 	efx_rc_t	(*efo_restore)(efx_nic_t *);
274460cb568SAndrew Rybchenko 	efx_rc_t	(*efo_add)(efx_nic_t *, efx_filter_spec_t *,
2753c838a9fSAndrew Rybchenko 				   boolean_t may_replace);
276460cb568SAndrew Rybchenko 	efx_rc_t	(*efo_delete)(efx_nic_t *, efx_filter_spec_t *);
27763492ab8SAndrew Rybchenko 	efx_rc_t	(*efo_supported_filters)(efx_nic_t *, uint32_t *,
27863492ab8SAndrew Rybchenko 				   size_t, size_t *);
279460cb568SAndrew Rybchenko 	efx_rc_t	(*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
2803c838a9fSAndrew Rybchenko 				   boolean_t, boolean_t, boolean_t,
28147cb5106SAndrew Rybchenko 				   uint8_t const *, uint32_t);
2823c838a9fSAndrew Rybchenko } efx_filter_ops_t;
2833c838a9fSAndrew Rybchenko 
284460cb568SAndrew Rybchenko extern	__checkReturn	efx_rc_t
2853c838a9fSAndrew Rybchenko efx_filter_reconfigure(
2863c838a9fSAndrew Rybchenko 	__in				efx_nic_t *enp,
2873c838a9fSAndrew Rybchenko 	__in_ecount(6)			uint8_t const *mac_addr,
2883c838a9fSAndrew Rybchenko 	__in				boolean_t all_unicst,
2893c838a9fSAndrew Rybchenko 	__in				boolean_t mulcst,
2903c838a9fSAndrew Rybchenko 	__in				boolean_t all_mulcst,
2913c838a9fSAndrew Rybchenko 	__in				boolean_t brdcst,
2923c838a9fSAndrew Rybchenko 	__in_ecount(6*count)		uint8_t const *addrs,
29347cb5106SAndrew Rybchenko 	__in				uint32_t count);
2943c838a9fSAndrew Rybchenko 
2953c838a9fSAndrew Rybchenko #endif /* EFSYS_OPT_FILTER */
2963c838a9fSAndrew Rybchenko 
297fdbe38cfSAndrew Rybchenko #if EFSYS_OPT_TUNNEL
298fdbe38cfSAndrew Rybchenko typedef struct efx_tunnel_ops_s {
299fdbe38cfSAndrew Rybchenko 	boolean_t	(*eto_udp_encap_supported)(efx_nic_t *);
300fdbe38cfSAndrew Rybchenko 	efx_rc_t	(*eto_reconfigure)(efx_nic_t *);
301fdbe38cfSAndrew Rybchenko } efx_tunnel_ops_t;
302fdbe38cfSAndrew Rybchenko #endif /* EFSYS_OPT_TUNNEL */
3033c838a9fSAndrew Rybchenko 
304e948693eSPhilip Paeps typedef struct efx_port_s {
305e948693eSPhilip Paeps 	efx_mac_type_t		ep_mac_type;
306e948693eSPhilip Paeps 	uint32_t		ep_phy_type;
307e948693eSPhilip Paeps 	uint8_t			ep_port;
308e948693eSPhilip Paeps 	uint32_t		ep_mac_pdu;
309e948693eSPhilip Paeps 	uint8_t			ep_mac_addr[6];
310e948693eSPhilip Paeps 	efx_link_mode_t		ep_link_mode;
3113c838a9fSAndrew Rybchenko 	boolean_t		ep_all_unicst;
3123c838a9fSAndrew Rybchenko 	boolean_t		ep_mulcst;
3133c838a9fSAndrew Rybchenko 	boolean_t		ep_all_mulcst;
314e948693eSPhilip Paeps 	boolean_t		ep_brdcst;
315e948693eSPhilip Paeps 	unsigned int		ep_fcntl;
316e948693eSPhilip Paeps 	boolean_t		ep_fcntl_autoneg;
317e948693eSPhilip Paeps 	efx_oword_t		ep_multicst_hash[2];
3183c838a9fSAndrew Rybchenko 	uint8_t			ep_mulcst_addr_list[EFX_MAC_ADDR_LEN *
3193c838a9fSAndrew Rybchenko 						    EFX_MAC_MULTICAST_LIST_MAX];
3203c838a9fSAndrew Rybchenko 	uint32_t		ep_mulcst_addr_count;
321e948693eSPhilip Paeps #if EFSYS_OPT_LOOPBACK
322e948693eSPhilip Paeps 	efx_loopback_type_t	ep_loopback_type;
323e948693eSPhilip Paeps 	efx_link_mode_t		ep_loopback_link_mode;
324e948693eSPhilip Paeps #endif	/* EFSYS_OPT_LOOPBACK */
325e948693eSPhilip Paeps #if EFSYS_OPT_PHY_FLAGS
326e948693eSPhilip Paeps 	uint32_t		ep_phy_flags;
327e948693eSPhilip Paeps #endif	/* EFSYS_OPT_PHY_FLAGS */
328e948693eSPhilip Paeps #if EFSYS_OPT_PHY_LED_CONTROL
329e948693eSPhilip Paeps 	efx_phy_led_mode_t	ep_phy_led_mode;
330e948693eSPhilip Paeps #endif	/* EFSYS_OPT_PHY_LED_CONTROL */
331e948693eSPhilip Paeps 	efx_phy_media_type_t	ep_fixed_port_type;
332e948693eSPhilip Paeps 	efx_phy_media_type_t	ep_module_type;
333e948693eSPhilip Paeps 	uint32_t		ep_adv_cap_mask;
334e948693eSPhilip Paeps 	uint32_t		ep_lp_cap_mask;
335e948693eSPhilip Paeps 	uint32_t		ep_default_adv_cap_mask;
336e948693eSPhilip Paeps 	uint32_t		ep_phy_cap_mask;
337e948693eSPhilip Paeps 	boolean_t		ep_mac_drain;
3383c838a9fSAndrew Rybchenko #if EFSYS_OPT_BIST
3393c838a9fSAndrew Rybchenko 	efx_bist_type_t		ep_current_bist;
340e948693eSPhilip Paeps #endif
341ec831f7fSAndrew Rybchenko 	const efx_mac_ops_t	*ep_emop;
342ec831f7fSAndrew Rybchenko 	const efx_phy_ops_t	*ep_epop;
343e948693eSPhilip Paeps } efx_port_t;
344e948693eSPhilip Paeps 
345e948693eSPhilip Paeps typedef struct efx_mon_ops_s {
346e948693eSPhilip Paeps #if EFSYS_OPT_MON_STATS
347460cb568SAndrew Rybchenko 	efx_rc_t	(*emo_stats_update)(efx_nic_t *, efsys_mem_t *,
348e948693eSPhilip Paeps 					    efx_mon_stat_value_t *);
349b4d3f02eSAndrew Rybchenko 	efx_rc_t	(*emo_limits_update)(efx_nic_t *,
350b4d3f02eSAndrew Rybchenko 					     efx_mon_stat_limits_t *);
351e948693eSPhilip Paeps #endif	/* EFSYS_OPT_MON_STATS */
352e948693eSPhilip Paeps } efx_mon_ops_t;
353e948693eSPhilip Paeps 
354e948693eSPhilip Paeps typedef struct efx_mon_s {
355e948693eSPhilip Paeps 	efx_mon_type_t		em_type;
356ec831f7fSAndrew Rybchenko 	const efx_mon_ops_t	*em_emop;
357e948693eSPhilip Paeps } efx_mon_t;
358e948693eSPhilip Paeps 
3593c838a9fSAndrew Rybchenko typedef struct efx_intr_ops_s {
360460cb568SAndrew Rybchenko 	efx_rc_t	(*eio_init)(efx_nic_t *, efx_intr_type_t, efsys_mem_t *);
3613c838a9fSAndrew Rybchenko 	void		(*eio_enable)(efx_nic_t *);
3623c838a9fSAndrew Rybchenko 	void		(*eio_disable)(efx_nic_t *);
3633c838a9fSAndrew Rybchenko 	void		(*eio_disable_unlocked)(efx_nic_t *);
364460cb568SAndrew Rybchenko 	efx_rc_t	(*eio_trigger)(efx_nic_t *, unsigned int);
3650c24a07eSAndrew Rybchenko 	void		(*eio_status_line)(efx_nic_t *, boolean_t *, uint32_t *);
3660c24a07eSAndrew Rybchenko 	void		(*eio_status_message)(efx_nic_t *, unsigned int,
3670c24a07eSAndrew Rybchenko 				 boolean_t *);
3680c24a07eSAndrew Rybchenko 	void		(*eio_fatal)(efx_nic_t *);
3693c838a9fSAndrew Rybchenko 	void		(*eio_fini)(efx_nic_t *);
3703c838a9fSAndrew Rybchenko } efx_intr_ops_t;
3713c838a9fSAndrew Rybchenko 
372e948693eSPhilip Paeps typedef struct efx_intr_s {
373ec831f7fSAndrew Rybchenko 	const efx_intr_ops_t	*ei_eiop;
374e948693eSPhilip Paeps 	efsys_mem_t		*ei_esmp;
3753c838a9fSAndrew Rybchenko 	efx_intr_type_t		ei_type;
376e948693eSPhilip Paeps 	unsigned int		ei_level;
377e948693eSPhilip Paeps } efx_intr_t;
378e948693eSPhilip Paeps 
379e948693eSPhilip Paeps typedef struct efx_nic_ops_s {
380460cb568SAndrew Rybchenko 	efx_rc_t	(*eno_probe)(efx_nic_t *);
381cfa023ebSAndrew Rybchenko 	efx_rc_t	(*eno_board_cfg)(efx_nic_t *);
382460cb568SAndrew Rybchenko 	efx_rc_t	(*eno_set_drv_limits)(efx_nic_t *, efx_drv_limits_t*);
383460cb568SAndrew Rybchenko 	efx_rc_t	(*eno_reset)(efx_nic_t *);
384460cb568SAndrew Rybchenko 	efx_rc_t	(*eno_init)(efx_nic_t *);
385460cb568SAndrew Rybchenko 	efx_rc_t	(*eno_get_vi_pool)(efx_nic_t *, uint32_t *);
386460cb568SAndrew Rybchenko 	efx_rc_t	(*eno_get_bar_region)(efx_nic_t *, efx_nic_region_t,
3873c838a9fSAndrew Rybchenko 					uint32_t *, size_t *);
388c6d5e85dSAndrew Rybchenko 	boolean_t	(*eno_hw_unavailable)(efx_nic_t *);
389*b2053d80SAndrew Rybchenko 	void		(*eno_set_hw_unavailable)(efx_nic_t *);
390e948693eSPhilip Paeps #if EFSYS_OPT_DIAG
391460cb568SAndrew Rybchenko 	efx_rc_t	(*eno_register_test)(efx_nic_t *);
392e948693eSPhilip Paeps #endif	/* EFSYS_OPT_DIAG */
393e948693eSPhilip Paeps 	void		(*eno_fini)(efx_nic_t *);
394e948693eSPhilip Paeps 	void		(*eno_unprobe)(efx_nic_t *);
395e948693eSPhilip Paeps } efx_nic_ops_t;
396e948693eSPhilip Paeps 
3979ab060a7SAndrew Rybchenko #ifndef EFX_TXQ_LIMIT_TARGET
398e948693eSPhilip Paeps #define	EFX_TXQ_LIMIT_TARGET 259
3999ab060a7SAndrew Rybchenko #endif
4009ab060a7SAndrew Rybchenko #ifndef EFX_RXQ_LIMIT_TARGET
40175ba9e1eSAndrew Rybchenko #define	EFX_RXQ_LIMIT_TARGET 512
4029ab060a7SAndrew Rybchenko #endif
4032d99dff8SAndrew Rybchenko 
404e948693eSPhilip Paeps 
405e948693eSPhilip Paeps #if EFSYS_OPT_FILTER
406e948693eSPhilip Paeps 
407553455eaSAndrew Rybchenko #if EFSYS_OPT_SIENA
408553455eaSAndrew Rybchenko 
409f7aa4b3dSAndrew Rybchenko typedef struct siena_filter_spec_s {
410f7aa4b3dSAndrew Rybchenko 	uint8_t		sfs_type;
411f7aa4b3dSAndrew Rybchenko 	uint32_t	sfs_flags;
412f7aa4b3dSAndrew Rybchenko 	uint32_t	sfs_dmaq_id;
413f7aa4b3dSAndrew Rybchenko 	uint32_t	sfs_dword[3];
414f7aa4b3dSAndrew Rybchenko } siena_filter_spec_t;
4153c838a9fSAndrew Rybchenko 
416f7aa4b3dSAndrew Rybchenko typedef enum siena_filter_type_e {
417f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_RX_TCP_FULL,	/* TCP/IPv4 {dIP,dTCP,sIP,sTCP} */
418f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_RX_TCP_WILD,	/* TCP/IPv4 {dIP,dTCP,  -,   -} */
419f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_RX_UDP_FULL,	/* UDP/IPv4 {dIP,dUDP,sIP,sUDP} */
420f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_RX_UDP_WILD,	/* UDP/IPv4 {dIP,dUDP,  -,   -} */
421f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_RX_MAC_FULL,	/* Ethernet {dMAC,VLAN} */
422f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_RX_MAC_WILD,	/* Ethernet {dMAC,   -} */
423e948693eSPhilip Paeps 
424f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TX_TCP_FULL,	/* TCP/IPv4 {dIP,dTCP,sIP,sTCP} */
425f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TX_TCP_WILD,	/* TCP/IPv4 {  -,   -,sIP,sTCP} */
426f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TX_UDP_FULL,	/* UDP/IPv4 {dIP,dTCP,sIP,sTCP} */
427f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TX_UDP_WILD,	/* UDP/IPv4 {  -,   -,sIP,sUDP} */
428f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TX_MAC_FULL,	/* Ethernet {sMAC,VLAN} */
429f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TX_MAC_WILD,	/* Ethernet {sMAC,   -} */
430e948693eSPhilip Paeps 
431f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_NTYPES
432f7aa4b3dSAndrew Rybchenko } siena_filter_type_t;
433e948693eSPhilip Paeps 
434f7aa4b3dSAndrew Rybchenko typedef enum siena_filter_tbl_id_e {
435f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TBL_RX_IP = 0,
436f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TBL_RX_MAC,
437f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TBL_TX_IP,
438f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_TBL_TX_MAC,
439f7aa4b3dSAndrew Rybchenko 	EFX_SIENA_FILTER_NTBLS
440f7aa4b3dSAndrew Rybchenko } siena_filter_tbl_id_t;
441e948693eSPhilip Paeps 
442f7aa4b3dSAndrew Rybchenko typedef struct siena_filter_tbl_s {
443f7aa4b3dSAndrew Rybchenko 	int			sft_size;	/* number of entries */
444f7aa4b3dSAndrew Rybchenko 	int			sft_used;	/* active count */
445f7aa4b3dSAndrew Rybchenko 	uint32_t		*sft_bitmap;	/* active bitmap */
446f7aa4b3dSAndrew Rybchenko 	siena_filter_spec_t	*sft_spec;	/* array of saved specs */
447f7aa4b3dSAndrew Rybchenko } siena_filter_tbl_t;
448e948693eSPhilip Paeps 
449f7aa4b3dSAndrew Rybchenko typedef struct siena_filter_s {
450f7aa4b3dSAndrew Rybchenko 	siena_filter_tbl_t	sf_tbl[EFX_SIENA_FILTER_NTBLS];
451f7aa4b3dSAndrew Rybchenko 	unsigned int		sf_depth[EFX_SIENA_FILTER_NTYPES];
452f7aa4b3dSAndrew Rybchenko } siena_filter_t;
453e948693eSPhilip Paeps 
454553455eaSAndrew Rybchenko #endif	/* EFSYS_OPT_SIENA */
455553455eaSAndrew Rybchenko 
456e948693eSPhilip Paeps typedef struct efx_filter_s {
457e75412c9SAndrew Rybchenko #if EFSYS_OPT_SIENA
458f7aa4b3dSAndrew Rybchenko 	siena_filter_t		*ef_siena_filter;
459e75412c9SAndrew Rybchenko #endif /* EFSYS_OPT_SIENA */
460ae64ac93SAndrew Rybchenko #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
4611289fe72SAndrew Rybchenko 	ef10_filter_table_t	*ef_ef10_filter_table;
462ae64ac93SAndrew Rybchenko #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
463e948693eSPhilip Paeps } efx_filter_t;
464e948693eSPhilip Paeps 
465553455eaSAndrew Rybchenko #if EFSYS_OPT_SIENA
466553455eaSAndrew Rybchenko 
467e948693eSPhilip Paeps extern			void
4681c159dbfSAndrew Rybchenko siena_filter_tbl_clear(
469e948693eSPhilip Paeps 	__in		efx_nic_t *enp,
470f7aa4b3dSAndrew Rybchenko 	__in		siena_filter_tbl_id_t tbl);
471e948693eSPhilip Paeps 
472553455eaSAndrew Rybchenko #endif	/* EFSYS_OPT_SIENA */
473553455eaSAndrew Rybchenko 
474e948693eSPhilip Paeps #endif	/* EFSYS_OPT_FILTER */
475e948693eSPhilip Paeps 
4763c838a9fSAndrew Rybchenko #if EFSYS_OPT_MCDI
4773c838a9fSAndrew Rybchenko 
478fdbe38cfSAndrew Rybchenko #define	EFX_TUNNEL_MAXNENTRIES	(16)
479fdbe38cfSAndrew Rybchenko 
480fdbe38cfSAndrew Rybchenko #if EFSYS_OPT_TUNNEL
481fdbe38cfSAndrew Rybchenko 
482fdbe38cfSAndrew Rybchenko typedef struct efx_tunnel_udp_entry_s {
483fdbe38cfSAndrew Rybchenko 	uint16_t			etue_port; /* host/cpu-endian */
484fdbe38cfSAndrew Rybchenko 	uint16_t			etue_protocol;
485fdbe38cfSAndrew Rybchenko } efx_tunnel_udp_entry_t;
486fdbe38cfSAndrew Rybchenko 
487fdbe38cfSAndrew Rybchenko typedef struct efx_tunnel_cfg_s {
488fdbe38cfSAndrew Rybchenko 	efx_tunnel_udp_entry_t	etc_udp_entries[EFX_TUNNEL_MAXNENTRIES];
489fdbe38cfSAndrew Rybchenko 	unsigned int		etc_udp_entries_num;
490fdbe38cfSAndrew Rybchenko } efx_tunnel_cfg_t;
491fdbe38cfSAndrew Rybchenko 
492fdbe38cfSAndrew Rybchenko #endif /* EFSYS_OPT_TUNNEL */
493fdbe38cfSAndrew Rybchenko 
4943c838a9fSAndrew Rybchenko typedef struct efx_mcdi_ops_s {
495460cb568SAndrew Rybchenko 	efx_rc_t	(*emco_init)(efx_nic_t *, const efx_mcdi_transport_t *);
496fd7501bfSAndrew Rybchenko 	void		(*emco_send_request)(efx_nic_t *, void *, size_t,
497fd7501bfSAndrew Rybchenko 					void *, size_t);
498460cb568SAndrew Rybchenko 	efx_rc_t	(*emco_poll_reboot)(efx_nic_t *);
499548ebee5SAndrew Rybchenko 	boolean_t	(*emco_poll_response)(efx_nic_t *);
500548ebee5SAndrew Rybchenko 	void		(*emco_read_response)(efx_nic_t *, void *, size_t, size_t);
5013c838a9fSAndrew Rybchenko 	void		(*emco_fini)(efx_nic_t *);
5028a4fcbd4SAndrew Rybchenko 	efx_rc_t	(*emco_feature_supported)(efx_nic_t *,
5038a4fcbd4SAndrew Rybchenko 					    efx_mcdi_feature_id_t, boolean_t *);
5048a4fcbd4SAndrew Rybchenko 	void		(*emco_get_timeout)(efx_nic_t *, efx_mcdi_req_t *,
5058a4fcbd4SAndrew Rybchenko 					    uint32_t *);
5063c838a9fSAndrew Rybchenko } efx_mcdi_ops_t;
5073c838a9fSAndrew Rybchenko 
5083c838a9fSAndrew Rybchenko typedef struct efx_mcdi_s {
509ec831f7fSAndrew Rybchenko 	const efx_mcdi_ops_t		*em_emcop;
5103c838a9fSAndrew Rybchenko 	const efx_mcdi_transport_t	*em_emtp;
5113c838a9fSAndrew Rybchenko 	efx_mcdi_iface_t		em_emip;
5123c838a9fSAndrew Rybchenko } efx_mcdi_t;
5133c838a9fSAndrew Rybchenko 
5143c838a9fSAndrew Rybchenko #endif /* EFSYS_OPT_MCDI */
5153c838a9fSAndrew Rybchenko 
516e948693eSPhilip Paeps #if EFSYS_OPT_NVRAM
5173d670ff5SAndrew Rybchenko 
5183d670ff5SAndrew Rybchenko /* Invalid partition ID for en_nvram_partn_locked field of efx_nc_t */
5193d670ff5SAndrew Rybchenko #define	EFX_NVRAM_PARTN_INVALID		(0xffffffffu)
5203d670ff5SAndrew Rybchenko 
521e948693eSPhilip Paeps typedef struct efx_nvram_ops_s {
522e948693eSPhilip Paeps #if EFSYS_OPT_DIAG
523460cb568SAndrew Rybchenko 	efx_rc_t	(*envo_test)(efx_nic_t *);
524e948693eSPhilip Paeps #endif	/* EFSYS_OPT_DIAG */
525bce88e31SAndrew Rybchenko 	efx_rc_t	(*envo_type_to_partn)(efx_nic_t *, efx_nvram_type_t,
526bce88e31SAndrew Rybchenko 					    uint32_t *);
52756bd83b0SAndrew Rybchenko 	efx_rc_t	(*envo_partn_size)(efx_nic_t *, uint32_t, size_t *);
5285d846e87SAndrew Rybchenko 	efx_rc_t	(*envo_partn_rw_start)(efx_nic_t *, uint32_t, size_t *);
5290afdf29cSAndrew Rybchenko 	efx_rc_t	(*envo_partn_read)(efx_nic_t *, uint32_t,
5300afdf29cSAndrew Rybchenko 					    unsigned int, caddr_t, size_t);
531ede1a3edSAndrew Rybchenko 	efx_rc_t	(*envo_partn_read_backup)(efx_nic_t *, uint32_t,
532ede1a3edSAndrew Rybchenko 					    unsigned int, caddr_t, size_t);
533b60ff840SAndrew Rybchenko 	efx_rc_t	(*envo_partn_erase)(efx_nic_t *, uint32_t,
534b60ff840SAndrew Rybchenko 					    unsigned int, size_t);
535134c4c4aSAndrew Rybchenko 	efx_rc_t	(*envo_partn_write)(efx_nic_t *, uint32_t,
536134c4c4aSAndrew Rybchenko 					    unsigned int, caddr_t, size_t);
537a21b2f20SAndrew Rybchenko 	efx_rc_t	(*envo_partn_rw_finish)(efx_nic_t *, uint32_t,
538a21b2f20SAndrew Rybchenko 					    uint32_t *);
53992187119SAndrew Rybchenko 	efx_rc_t	(*envo_partn_get_version)(efx_nic_t *, uint32_t,
54092187119SAndrew Rybchenko 					    uint32_t *, uint16_t *);
5416d0b856cSAndrew Rybchenko 	efx_rc_t	(*envo_partn_set_version)(efx_nic_t *, uint32_t,
5426d0b856cSAndrew Rybchenko 					    uint16_t *);
543e919b7ecSAndrew Rybchenko 	efx_rc_t	(*envo_buffer_validate)(uint32_t,
5445abce2b9SAndrew Rybchenko 					    caddr_t, size_t);
545e948693eSPhilip Paeps } efx_nvram_ops_t;
546e948693eSPhilip Paeps #endif /* EFSYS_OPT_NVRAM */
547e948693eSPhilip Paeps 
548e948693eSPhilip Paeps #if EFSYS_OPT_VPD
549e948693eSPhilip Paeps typedef struct efx_vpd_ops_s {
550460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_init)(efx_nic_t *);
551460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_size)(efx_nic_t *, size_t *);
552460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_read)(efx_nic_t *, caddr_t, size_t);
553460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_verify)(efx_nic_t *, caddr_t, size_t);
554460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_reinit)(efx_nic_t *, caddr_t, size_t);
555460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_get)(efx_nic_t *, caddr_t, size_t,
556460cb568SAndrew Rybchenko 					efx_vpd_value_t *);
557460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_set)(efx_nic_t *, caddr_t, size_t,
558460cb568SAndrew Rybchenko 					efx_vpd_value_t *);
559460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_next)(efx_nic_t *, caddr_t, size_t,
560460cb568SAndrew Rybchenko 					efx_vpd_value_t *, unsigned int *);
561460cb568SAndrew Rybchenko 	efx_rc_t	(*evpdo_write)(efx_nic_t *, caddr_t, size_t);
562e948693eSPhilip Paeps 	void		(*evpdo_fini)(efx_nic_t *);
563e948693eSPhilip Paeps } efx_vpd_ops_t;
564e948693eSPhilip Paeps #endif	/* EFSYS_OPT_VPD */
565e948693eSPhilip Paeps 
5663c838a9fSAndrew Rybchenko #if EFSYS_OPT_VPD || EFSYS_OPT_NVRAM
5673c838a9fSAndrew Rybchenko 
568460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
5693c838a9fSAndrew Rybchenko efx_mcdi_nvram_partitions(
5703c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
5713c838a9fSAndrew Rybchenko 	__out_bcount(size)	caddr_t data,
5723c838a9fSAndrew Rybchenko 	__in			size_t size,
5733c838a9fSAndrew Rybchenko 	__out			unsigned int *npartnp);
5743c838a9fSAndrew Rybchenko 
575460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
5763c838a9fSAndrew Rybchenko efx_mcdi_nvram_metadata(
5773c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
5783c838a9fSAndrew Rybchenko 	__in			uint32_t partn,
5793c838a9fSAndrew Rybchenko 	__out			uint32_t *subtypep,
5803c838a9fSAndrew Rybchenko 	__out_ecount(4)		uint16_t version[4],
5813c838a9fSAndrew Rybchenko 	__out_bcount_opt(size)	char *descp,
5823c838a9fSAndrew Rybchenko 	__in			size_t size);
5833c838a9fSAndrew Rybchenko 
584460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
5853c838a9fSAndrew Rybchenko efx_mcdi_nvram_info(
5863c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
5873c838a9fSAndrew Rybchenko 	__in			uint32_t partn,
5883c838a9fSAndrew Rybchenko 	__out_opt		size_t *sizep,
5893c838a9fSAndrew Rybchenko 	__out_opt		uint32_t *addressp,
5909cb71b16SAndrew Rybchenko 	__out_opt		uint32_t *erase_sizep,
5919cb71b16SAndrew Rybchenko 	__out_opt		uint32_t *write_sizep);
5923c838a9fSAndrew Rybchenko 
593460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
5943c838a9fSAndrew Rybchenko efx_mcdi_nvram_update_start(
5953c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
5963c838a9fSAndrew Rybchenko 	__in			uint32_t partn);
5973c838a9fSAndrew Rybchenko 
598460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
5993c838a9fSAndrew Rybchenko efx_mcdi_nvram_read(
6003c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
6013c838a9fSAndrew Rybchenko 	__in			uint32_t partn,
6023c838a9fSAndrew Rybchenko 	__in			uint32_t offset,
6033c838a9fSAndrew Rybchenko 	__out_bcount(size)	caddr_t data,
6049ad7e03fSAndrew Rybchenko 	__in			size_t size,
6059ad7e03fSAndrew Rybchenko 	__in			uint32_t mode);
6063c838a9fSAndrew Rybchenko 
607460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
6083c838a9fSAndrew Rybchenko efx_mcdi_nvram_erase(
6093c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
6103c838a9fSAndrew Rybchenko 	__in			uint32_t partn,
6113c838a9fSAndrew Rybchenko 	__in			uint32_t offset,
6123c838a9fSAndrew Rybchenko 	__in			size_t size);
6133c838a9fSAndrew Rybchenko 
614460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
6153c838a9fSAndrew Rybchenko efx_mcdi_nvram_write(
6163c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
6173c838a9fSAndrew Rybchenko 	__in			uint32_t partn,
6183c838a9fSAndrew Rybchenko 	__in			uint32_t offset,
619dbcc3c8fSAndrew Rybchenko 	__in_bcount(size)	caddr_t data,
6203c838a9fSAndrew Rybchenko 	__in			size_t size);
6213c838a9fSAndrew Rybchenko 
622460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
6233c838a9fSAndrew Rybchenko efx_mcdi_nvram_update_finish(
6243c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
6253c838a9fSAndrew Rybchenko 	__in			uint32_t partn,
626e9c123a5SAndrew Rybchenko 	__in			boolean_t reboot,
627a21b2f20SAndrew Rybchenko 	__out_opt		uint32_t *verify_resultp);
6283c838a9fSAndrew Rybchenko 
6293c838a9fSAndrew Rybchenko #if EFSYS_OPT_DIAG
6303c838a9fSAndrew Rybchenko 
631460cb568SAndrew Rybchenko 	__checkReturn		efx_rc_t
6323c838a9fSAndrew Rybchenko efx_mcdi_nvram_test(
6333c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
6343c838a9fSAndrew Rybchenko 	__in			uint32_t partn);
6353c838a9fSAndrew Rybchenko 
6363c838a9fSAndrew Rybchenko #endif	/* EFSYS_OPT_DIAG */
6373c838a9fSAndrew Rybchenko 
6383c838a9fSAndrew Rybchenko #endif /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
6393c838a9fSAndrew Rybchenko 
6400c848230SAndrew Rybchenko #if EFSYS_OPT_LICENSING
6410c848230SAndrew Rybchenko 
6420c848230SAndrew Rybchenko typedef struct efx_lic_ops_s {
6430c848230SAndrew Rybchenko 	efx_rc_t	(*elo_update_licenses)(efx_nic_t *);
6440c848230SAndrew Rybchenko 	efx_rc_t	(*elo_get_key_stats)(efx_nic_t *, efx_key_stats_t *);
6450c848230SAndrew Rybchenko 	efx_rc_t	(*elo_app_state)(efx_nic_t *, uint64_t, boolean_t *);
6460c848230SAndrew Rybchenko 	efx_rc_t	(*elo_get_id)(efx_nic_t *, size_t, uint32_t *,
6470c848230SAndrew Rybchenko 				      size_t *, uint8_t *);
648fc3a62cfSAndrew Rybchenko 	efx_rc_t	(*elo_find_start)
649fc3a62cfSAndrew Rybchenko 				(efx_nic_t *, caddr_t, size_t, uint32_t *);
650fc3a62cfSAndrew Rybchenko 	efx_rc_t	(*elo_find_end)(efx_nic_t *, caddr_t, size_t,
651fc3a62cfSAndrew Rybchenko 				uint32_t, uint32_t *);
652fc3a62cfSAndrew Rybchenko 	boolean_t	(*elo_find_key)(efx_nic_t *, caddr_t, size_t,
653fc3a62cfSAndrew Rybchenko 				uint32_t, uint32_t *, uint32_t *);
654fc3a62cfSAndrew Rybchenko 	boolean_t	(*elo_validate_key)(efx_nic_t *,
655fc3a62cfSAndrew Rybchenko 				caddr_t, uint32_t);
656fc3a62cfSAndrew Rybchenko 	efx_rc_t	(*elo_read_key)(efx_nic_t *,
657fc3a62cfSAndrew Rybchenko 				caddr_t, size_t, uint32_t, uint32_t,
658fc3a62cfSAndrew Rybchenko 				caddr_t, size_t, uint32_t *);
659fc3a62cfSAndrew Rybchenko 	efx_rc_t	(*elo_write_key)(efx_nic_t *,
660fc3a62cfSAndrew Rybchenko 				caddr_t, size_t, uint32_t,
661fc3a62cfSAndrew Rybchenko 				caddr_t, uint32_t, uint32_t *);
662fc3a62cfSAndrew Rybchenko 	efx_rc_t	(*elo_delete_key)(efx_nic_t *,
663fc3a62cfSAndrew Rybchenko 				caddr_t, size_t, uint32_t,
664fc3a62cfSAndrew Rybchenko 				uint32_t, uint32_t, uint32_t *);
665fc3a62cfSAndrew Rybchenko 	efx_rc_t	(*elo_create_partition)(efx_nic_t *,
666fc3a62cfSAndrew Rybchenko 				caddr_t, size_t);
667fc3a62cfSAndrew Rybchenko 	efx_rc_t	(*elo_finish_partition)(efx_nic_t *,
668fc3a62cfSAndrew Rybchenko 				caddr_t, size_t);
6690c848230SAndrew Rybchenko } efx_lic_ops_t;
6700c848230SAndrew Rybchenko 
6710c848230SAndrew Rybchenko #endif
6720c848230SAndrew Rybchenko 
6733c838a9fSAndrew Rybchenko typedef struct efx_drv_cfg_s {
6743c838a9fSAndrew Rybchenko 	uint32_t		edc_min_vi_count;
6753c838a9fSAndrew Rybchenko 	uint32_t		edc_max_vi_count;
6763c838a9fSAndrew Rybchenko 
6773c838a9fSAndrew Rybchenko 	uint32_t		edc_max_piobuf_count;
6783c838a9fSAndrew Rybchenko 	uint32_t		edc_pio_alloc_size;
6793c838a9fSAndrew Rybchenko } efx_drv_cfg_t;
6803c838a9fSAndrew Rybchenko 
681e948693eSPhilip Paeps struct efx_nic_s {
682e948693eSPhilip Paeps 	uint32_t		en_magic;
683e948693eSPhilip Paeps 	efx_family_t		en_family;
684e948693eSPhilip Paeps 	uint32_t		en_features;
685e948693eSPhilip Paeps 	efsys_identifier_t	*en_esip;
686e948693eSPhilip Paeps 	efsys_lock_t		*en_eslp;
687e948693eSPhilip Paeps 	efsys_bar_t		*en_esbp;
688e948693eSPhilip Paeps 	unsigned int		en_mod_flags;
689e948693eSPhilip Paeps 	unsigned int		en_reset_flags;
690e948693eSPhilip Paeps 	efx_nic_cfg_t		en_nic_cfg;
6913c838a9fSAndrew Rybchenko 	efx_drv_cfg_t		en_drv_cfg;
692e948693eSPhilip Paeps 	efx_port_t		en_port;
693e948693eSPhilip Paeps 	efx_mon_t		en_mon;
694e948693eSPhilip Paeps 	efx_intr_t		en_intr;
695e948693eSPhilip Paeps 	uint32_t		en_ev_qcount;
696e948693eSPhilip Paeps 	uint32_t		en_rx_qcount;
697e948693eSPhilip Paeps 	uint32_t		en_tx_qcount;
698ec831f7fSAndrew Rybchenko 	const efx_nic_ops_t	*en_enop;
699ec831f7fSAndrew Rybchenko 	const efx_ev_ops_t	*en_eevop;
700ec831f7fSAndrew Rybchenko 	const efx_tx_ops_t	*en_etxop;
701ec831f7fSAndrew Rybchenko 	const efx_rx_ops_t	*en_erxop;
70287a67e18SAndrew Rybchenko 	efx_fw_variant_t	efv;
703e948693eSPhilip Paeps #if EFSYS_OPT_FILTER
704e948693eSPhilip Paeps 	efx_filter_t		en_filter;
705ec831f7fSAndrew Rybchenko 	const efx_filter_ops_t	*en_efop;
706e948693eSPhilip Paeps #endif	/* EFSYS_OPT_FILTER */
707fdbe38cfSAndrew Rybchenko #if EFSYS_OPT_TUNNEL
708fdbe38cfSAndrew Rybchenko 	efx_tunnel_cfg_t	en_tunnel_cfg;
709fdbe38cfSAndrew Rybchenko 	const efx_tunnel_ops_t	*en_etop;
710fdbe38cfSAndrew Rybchenko #endif /* EFSYS_OPT_TUNNEL */
7113c838a9fSAndrew Rybchenko #if EFSYS_OPT_MCDI
7123c838a9fSAndrew Rybchenko 	efx_mcdi_t		en_mcdi;
7133c838a9fSAndrew Rybchenko #endif	/* EFSYS_OPT_MCDI */
714e948693eSPhilip Paeps #if EFSYS_OPT_NVRAM
7153d670ff5SAndrew Rybchenko 	uint32_t		en_nvram_partn_locked;
716ec831f7fSAndrew Rybchenko 	const efx_nvram_ops_t	*en_envop;
717e948693eSPhilip Paeps #endif	/* EFSYS_OPT_NVRAM */
718e948693eSPhilip Paeps #if EFSYS_OPT_VPD
719ec831f7fSAndrew Rybchenko 	const efx_vpd_ops_t	*en_evpdop;
720e948693eSPhilip Paeps #endif	/* EFSYS_OPT_VPD */
7213c838a9fSAndrew Rybchenko #if EFSYS_OPT_RX_SCALE
7223c838a9fSAndrew Rybchenko 	efx_rx_hash_support_t		en_hash_support;
72339023729SAndrew Rybchenko 	efx_rx_scale_context_type_t	en_rss_context_type;
7243c838a9fSAndrew Rybchenko 	uint32_t			en_rss_context;
7253c838a9fSAndrew Rybchenko #endif	/* EFSYS_OPT_RX_SCALE */
7263c838a9fSAndrew Rybchenko 	uint32_t		en_vport_id;
7270c848230SAndrew Rybchenko #if EFSYS_OPT_LICENSING
728ec831f7fSAndrew Rybchenko 	const efx_lic_ops_t	*en_elop;
7295df3232cSAndrew Rybchenko 	boolean_t		en_licensing_supported;
7300c848230SAndrew Rybchenko #endif
731e948693eSPhilip Paeps 	union {
732e948693eSPhilip Paeps #if EFSYS_OPT_SIENA
733e948693eSPhilip Paeps 		struct {
734e948693eSPhilip Paeps #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
735e948693eSPhilip Paeps 			unsigned int		enu_partn_mask;
736e948693eSPhilip Paeps #endif	/* EFSYS_OPT_NVRAM || EFSYS_OPT_VPD */
737e948693eSPhilip Paeps #if EFSYS_OPT_VPD
738e948693eSPhilip Paeps 			caddr_t			enu_svpd;
739e948693eSPhilip Paeps 			size_t			enu_svpd_length;
740e948693eSPhilip Paeps #endif	/* EFSYS_OPT_VPD */
7413c838a9fSAndrew Rybchenko 			int			enu_unused;
742e948693eSPhilip Paeps 		} siena;
743e948693eSPhilip Paeps #endif	/* EFSYS_OPT_SIENA */
744e7119ad9SAndrew Rybchenko 		int	enu_unused;
745e948693eSPhilip Paeps 	} en_u;
746ae64ac93SAndrew Rybchenko #if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
747e7119ad9SAndrew Rybchenko 	union en_arch {
748e7119ad9SAndrew Rybchenko 		struct {
749e7119ad9SAndrew Rybchenko 			int			ena_vi_base;
750e7119ad9SAndrew Rybchenko 			int			ena_vi_count;
751426f453bSAndrew Rybchenko 			int			ena_vi_shift;
752e7119ad9SAndrew Rybchenko #if EFSYS_OPT_VPD
753e7119ad9SAndrew Rybchenko 			caddr_t			ena_svpd;
754e7119ad9SAndrew Rybchenko 			size_t			ena_svpd_length;
755e7119ad9SAndrew Rybchenko #endif	/* EFSYS_OPT_VPD */
756e7119ad9SAndrew Rybchenko 			efx_piobuf_handle_t	ena_piobuf_handle[EF10_MAX_PIOBUF_NBUFS];
757e7119ad9SAndrew Rybchenko 			uint32_t		ena_piobuf_count;
758e7119ad9SAndrew Rybchenko 			uint32_t		ena_pio_alloc_map[EF10_MAX_PIOBUF_NBUFS];
759e7119ad9SAndrew Rybchenko 			uint32_t		ena_pio_write_vi_base;
760e7119ad9SAndrew Rybchenko 			/* Memory BAR mapping regions */
761e7119ad9SAndrew Rybchenko 			uint32_t		ena_uc_mem_map_offset;
762e7119ad9SAndrew Rybchenko 			size_t			ena_uc_mem_map_size;
763e7119ad9SAndrew Rybchenko 			uint32_t		ena_wc_mem_map_offset;
764e7119ad9SAndrew Rybchenko 			size_t			ena_wc_mem_map_size;
765e7119ad9SAndrew Rybchenko 		} ef10;
766e7119ad9SAndrew Rybchenko 	} en_arch;
767ae64ac93SAndrew Rybchenko #endif	/* (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2) */
768e948693eSPhilip Paeps };
769e948693eSPhilip Paeps 
770e948693eSPhilip Paeps 
771e948693eSPhilip Paeps #define	EFX_NIC_MAGIC	0x02121996
772e948693eSPhilip Paeps 
773e948693eSPhilip Paeps typedef	boolean_t (*efx_ev_handler_t)(efx_evq_t *, efx_qword_t *,
774e948693eSPhilip Paeps     const efx_ev_callbacks_t *, void *);
775e948693eSPhilip Paeps 
7763c838a9fSAndrew Rybchenko typedef struct efx_evq_rxq_state_s {
7773c838a9fSAndrew Rybchenko 	unsigned int			eers_rx_read_ptr;
7783c838a9fSAndrew Rybchenko 	unsigned int			eers_rx_mask;
77904381b5eSAndrew Rybchenko #if EFSYS_OPT_RX_PACKED_STREAM || EFSYS_OPT_RX_ES_SUPER_BUFFER
7808e0c4827SAndrew Rybchenko 	unsigned int			eers_rx_stream_npackets;
7818e0c4827SAndrew Rybchenko 	boolean_t			eers_rx_packed_stream;
78204381b5eSAndrew Rybchenko #endif
78304381b5eSAndrew Rybchenko #if EFSYS_OPT_RX_PACKED_STREAM
7848e0c4827SAndrew Rybchenko 	unsigned int			eers_rx_packed_stream_credits;
7858e0c4827SAndrew Rybchenko #endif
7863c838a9fSAndrew Rybchenko } efx_evq_rxq_state_t;
7873c838a9fSAndrew Rybchenko 
788e948693eSPhilip Paeps struct efx_evq_s {
789e948693eSPhilip Paeps 	uint32_t			ee_magic;
790e948693eSPhilip Paeps 	efx_nic_t			*ee_enp;
791e948693eSPhilip Paeps 	unsigned int			ee_index;
792e948693eSPhilip Paeps 	unsigned int			ee_mask;
793e948693eSPhilip Paeps 	efsys_mem_t			*ee_esmp;
794e948693eSPhilip Paeps #if EFSYS_OPT_QSTATS
795e948693eSPhilip Paeps 	uint32_t			ee_stat[EV_NQSTATS];
796e948693eSPhilip Paeps #endif	/* EFSYS_OPT_QSTATS */
7973c838a9fSAndrew Rybchenko 
7983c838a9fSAndrew Rybchenko 	efx_ev_handler_t		ee_rx;
7993c838a9fSAndrew Rybchenko 	efx_ev_handler_t		ee_tx;
8003c838a9fSAndrew Rybchenko 	efx_ev_handler_t		ee_driver;
8013c838a9fSAndrew Rybchenko 	efx_ev_handler_t		ee_global;
8023c838a9fSAndrew Rybchenko 	efx_ev_handler_t		ee_drv_gen;
8033c838a9fSAndrew Rybchenko #if EFSYS_OPT_MCDI
8043c838a9fSAndrew Rybchenko 	efx_ev_handler_t		ee_mcdi;
8053c838a9fSAndrew Rybchenko #endif	/* EFSYS_OPT_MCDI */
8063c838a9fSAndrew Rybchenko 
8073c838a9fSAndrew Rybchenko 	efx_evq_rxq_state_t		ee_rxq_state[EFX_EV_RX_NLABELS];
80882d2a148SAndrew Rybchenko 
80982d2a148SAndrew Rybchenko 	uint32_t			ee_flags;
810e948693eSPhilip Paeps };
811e948693eSPhilip Paeps 
812e948693eSPhilip Paeps #define	EFX_EVQ_MAGIC	0x08081997
813e948693eSPhilip Paeps 
814af9078c3SAndrew Rybchenko #define	EFX_EVQ_SIENA_TIMER_QUANTUM_NS	6144 /* 768 cycles */
815e948693eSPhilip Paeps 
816e948693eSPhilip Paeps struct efx_rxq_s {
817e948693eSPhilip Paeps 	uint32_t			er_magic;
818e948693eSPhilip Paeps 	efx_nic_t			*er_enp;
8193c838a9fSAndrew Rybchenko 	efx_evq_t			*er_eep;
820e948693eSPhilip Paeps 	unsigned int			er_index;
8213c838a9fSAndrew Rybchenko 	unsigned int			er_label;
822e948693eSPhilip Paeps 	unsigned int			er_mask;
823e948693eSPhilip Paeps 	efsys_mem_t			*er_esmp;
8245fb80fd4SAndrew Rybchenko 	efx_evq_rxq_state_t		*er_ev_qstate;
825e948693eSPhilip Paeps };
826e948693eSPhilip Paeps 
827e948693eSPhilip Paeps #define	EFX_RXQ_MAGIC	0x15022005
828e948693eSPhilip Paeps 
829e948693eSPhilip Paeps struct efx_txq_s {
830e948693eSPhilip Paeps 	uint32_t			et_magic;
831e948693eSPhilip Paeps 	efx_nic_t			*et_enp;
832e948693eSPhilip Paeps 	unsigned int			et_index;
833e948693eSPhilip Paeps 	unsigned int			et_mask;
834e948693eSPhilip Paeps 	efsys_mem_t			*et_esmp;
8353c838a9fSAndrew Rybchenko #if EFSYS_OPT_HUNTINGTON
8363c838a9fSAndrew Rybchenko 	uint32_t			et_pio_bufnum;
8373c838a9fSAndrew Rybchenko 	uint32_t			et_pio_blknum;
8383c838a9fSAndrew Rybchenko 	uint32_t			et_pio_write_offset;
8393c838a9fSAndrew Rybchenko 	uint32_t			et_pio_offset;
8403c838a9fSAndrew Rybchenko 	size_t				et_pio_size;
8413c838a9fSAndrew Rybchenko #endif
842e948693eSPhilip Paeps #if EFSYS_OPT_QSTATS
843e948693eSPhilip Paeps 	uint32_t			et_stat[TX_NQSTATS];
844e948693eSPhilip Paeps #endif	/* EFSYS_OPT_QSTATS */
845e948693eSPhilip Paeps };
846e948693eSPhilip Paeps 
847e948693eSPhilip Paeps #define	EFX_TXQ_MAGIC	0x05092005
848e948693eSPhilip Paeps 
849e948693eSPhilip Paeps #define	EFX_MAC_ADDR_COPY(_dst, _src)					\
850e948693eSPhilip Paeps 	do {								\
851e948693eSPhilip Paeps 		(_dst)[0] = (_src)[0];					\
852e948693eSPhilip Paeps 		(_dst)[1] = (_src)[1];					\
853e948693eSPhilip Paeps 		(_dst)[2] = (_src)[2];					\
854e948693eSPhilip Paeps 		(_dst)[3] = (_src)[3];					\
855e948693eSPhilip Paeps 		(_dst)[4] = (_src)[4];					\
856e948693eSPhilip Paeps 		(_dst)[5] = (_src)[5];					\
857e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
858e948693eSPhilip Paeps 	} while (B_FALSE)
859e948693eSPhilip Paeps 
8603c838a9fSAndrew Rybchenko #define	EFX_MAC_BROADCAST_ADDR_SET(_dst)				\
8613c838a9fSAndrew Rybchenko 	do {								\
8623c838a9fSAndrew Rybchenko 		uint16_t *_d = (uint16_t *)(_dst);			\
8633c838a9fSAndrew Rybchenko 		_d[0] = 0xffff;						\
8643c838a9fSAndrew Rybchenko 		_d[1] = 0xffff;						\
8653c838a9fSAndrew Rybchenko 		_d[2] = 0xffff;						\
8663c838a9fSAndrew Rybchenko 	_NOTE(CONSTANTCONDITION)					\
8673c838a9fSAndrew Rybchenko 	} while (B_FALSE)
8683c838a9fSAndrew Rybchenko 
869e948693eSPhilip Paeps #if EFSYS_OPT_CHECK_REG
870e948693eSPhilip Paeps #define	EFX_CHECK_REG(_enp, _reg)					\
871e948693eSPhilip Paeps 	do {								\
8723c838a9fSAndrew Rybchenko 		const char *name = #_reg;				\
873e948693eSPhilip Paeps 		char min = name[4];					\
874e948693eSPhilip Paeps 		char max = name[5];					\
875e948693eSPhilip Paeps 		char rev;						\
876e948693eSPhilip Paeps 									\
877e948693eSPhilip Paeps 		switch ((_enp)->en_family) {				\
878e948693eSPhilip Paeps 		case EFX_FAMILY_SIENA:					\
879e948693eSPhilip Paeps 			rev = 'C';					\
880e948693eSPhilip Paeps 			break;						\
881e948693eSPhilip Paeps 									\
8823c838a9fSAndrew Rybchenko 		case EFX_FAMILY_HUNTINGTON:				\
8833c838a9fSAndrew Rybchenko 			rev = 'D';					\
8843c838a9fSAndrew Rybchenko 			break;						\
8853c838a9fSAndrew Rybchenko 									\
88634f6ea29SAndrew Rybchenko 		case EFX_FAMILY_MEDFORD:				\
88734f6ea29SAndrew Rybchenko 			rev = 'E';					\
88834f6ea29SAndrew Rybchenko 			break;						\
88934f6ea29SAndrew Rybchenko 									\
890ae64ac93SAndrew Rybchenko 		case EFX_FAMILY_MEDFORD2:				\
891ae64ac93SAndrew Rybchenko 			rev = 'F';					\
892ae64ac93SAndrew Rybchenko 			break;						\
893ae64ac93SAndrew Rybchenko 									\
894e948693eSPhilip Paeps 		default:						\
895e948693eSPhilip Paeps 			rev = '?';					\
896e948693eSPhilip Paeps 			break;						\
897e948693eSPhilip Paeps 		}							\
898e948693eSPhilip Paeps 									\
899e948693eSPhilip Paeps 		EFSYS_ASSERT3S(rev, >=, min);				\
900e948693eSPhilip Paeps 		EFSYS_ASSERT3S(rev, <=, max);				\
901e948693eSPhilip Paeps 									\
902e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
903e948693eSPhilip Paeps 	} while (B_FALSE)
904e948693eSPhilip Paeps #else
905e948693eSPhilip Paeps #define	EFX_CHECK_REG(_enp, _reg) do {					\
906e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
907e948693eSPhilip Paeps 	} while (B_FALSE)
908e948693eSPhilip Paeps #endif
909e948693eSPhilip Paeps 
910e948693eSPhilip Paeps #define	EFX_BAR_READD(_enp, _reg, _edp, _lock)				\
911e948693eSPhilip Paeps 	do {								\
912e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
913e948693eSPhilip Paeps 		EFSYS_BAR_READD((_enp)->en_esbp, _reg ## _OFST,		\
914e948693eSPhilip Paeps 		    (_edp), (_lock));					\
915e948693eSPhilip Paeps 		EFSYS_PROBE3(efx_bar_readd, const char *, #_reg,	\
916e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
917e948693eSPhilip Paeps 		    uint32_t, (_edp)->ed_u32[0]);			\
918e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
919e948693eSPhilip Paeps 	} while (B_FALSE)
920e948693eSPhilip Paeps 
921e948693eSPhilip Paeps #define	EFX_BAR_WRITED(_enp, _reg, _edp, _lock)				\
922e948693eSPhilip Paeps 	do {								\
923e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
924e948693eSPhilip Paeps 		EFSYS_PROBE3(efx_bar_writed, const char *, #_reg,	\
925e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
926e948693eSPhilip Paeps 		    uint32_t, (_edp)->ed_u32[0]);			\
927e948693eSPhilip Paeps 		EFSYS_BAR_WRITED((_enp)->en_esbp, _reg ## _OFST,	\
928e948693eSPhilip Paeps 		    (_edp), (_lock));					\
929e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
930e948693eSPhilip Paeps 	} while (B_FALSE)
931e948693eSPhilip Paeps 
932e948693eSPhilip Paeps #define	EFX_BAR_READQ(_enp, _reg, _eqp)					\
933e948693eSPhilip Paeps 	do {								\
934e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
935e948693eSPhilip Paeps 		EFSYS_BAR_READQ((_enp)->en_esbp, _reg ## _OFST,		\
936e948693eSPhilip Paeps 		    (_eqp));						\
937e948693eSPhilip Paeps 		EFSYS_PROBE4(efx_bar_readq, const char *, #_reg,	\
938e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
939e948693eSPhilip Paeps 		    uint32_t, (_eqp)->eq_u32[1],			\
940e948693eSPhilip Paeps 		    uint32_t, (_eqp)->eq_u32[0]);			\
941e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
942e948693eSPhilip Paeps 	} while (B_FALSE)
943e948693eSPhilip Paeps 
944e948693eSPhilip Paeps #define	EFX_BAR_WRITEQ(_enp, _reg, _eqp)				\
945e948693eSPhilip Paeps 	do {								\
946e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
947e948693eSPhilip Paeps 		EFSYS_PROBE4(efx_bar_writeq, const char *, #_reg,	\
948e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
949e948693eSPhilip Paeps 		    uint32_t, (_eqp)->eq_u32[1],			\
950e948693eSPhilip Paeps 		    uint32_t, (_eqp)->eq_u32[0]);			\
951e948693eSPhilip Paeps 		EFSYS_BAR_WRITEQ((_enp)->en_esbp, _reg ## _OFST,	\
952e948693eSPhilip Paeps 		    (_eqp));						\
953e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
954e948693eSPhilip Paeps 	} while (B_FALSE)
955e948693eSPhilip Paeps 
956e948693eSPhilip Paeps #define	EFX_BAR_READO(_enp, _reg, _eop)					\
957e948693eSPhilip Paeps 	do {								\
958e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
959e948693eSPhilip Paeps 		EFSYS_BAR_READO((_enp)->en_esbp, _reg ## _OFST,		\
960e948693eSPhilip Paeps 		    (_eop), B_TRUE);					\
961e948693eSPhilip Paeps 		EFSYS_PROBE6(efx_bar_reado, const char *, #_reg,	\
962e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
963e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[3],			\
964e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[2],			\
965e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[1],			\
966e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[0]);			\
967e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
968e948693eSPhilip Paeps 	} while (B_FALSE)
969e948693eSPhilip Paeps 
970e948693eSPhilip Paeps #define	EFX_BAR_WRITEO(_enp, _reg, _eop)				\
971e948693eSPhilip Paeps 	do {								\
972e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
973e948693eSPhilip Paeps 		EFSYS_PROBE6(efx_bar_writeo, const char *, #_reg,	\
974e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
975e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[3],			\
976e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[2],			\
977e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[1],			\
978e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[0]);			\
979e948693eSPhilip Paeps 		EFSYS_BAR_WRITEO((_enp)->en_esbp, _reg ## _OFST,	\
980e948693eSPhilip Paeps 		    (_eop), B_TRUE);					\
981e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
982e948693eSPhilip Paeps 	} while (B_FALSE)
983e948693eSPhilip Paeps 
984c63c8369SAndrew Rybchenko /*
985c63c8369SAndrew Rybchenko  * Accessors for memory BAR non-VI tables.
986c63c8369SAndrew Rybchenko  *
987c63c8369SAndrew Rybchenko  * Code used on EF10 *must* use EFX_BAR_VI_*() macros for per-VI registers,
988c63c8369SAndrew Rybchenko  * to ensure the correct runtime VI window size is used on Medford2.
989c63c8369SAndrew Rybchenko  *
990c63c8369SAndrew Rybchenko  * Siena-only code may continue using EFX_BAR_TBL_*() macros for VI registers.
991c63c8369SAndrew Rybchenko  */
992c63c8369SAndrew Rybchenko 
993e948693eSPhilip Paeps #define	EFX_BAR_TBL_READD(_enp, _reg, _index, _edp, _lock)		\
994e948693eSPhilip Paeps 	do {								\
995e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
996e948693eSPhilip Paeps 		EFSYS_BAR_READD((_enp)->en_esbp,			\
997e948693eSPhilip Paeps 		    (_reg ## _OFST + ((_index) * _reg ## _STEP)),	\
998e948693eSPhilip Paeps 		    (_edp), (_lock));					\
999e948693eSPhilip Paeps 		EFSYS_PROBE4(efx_bar_tbl_readd, const char *, #_reg,	\
1000e948693eSPhilip Paeps 		    uint32_t, (_index),					\
1001e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
1002e948693eSPhilip Paeps 		    uint32_t, (_edp)->ed_u32[0]);			\
1003e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
1004e948693eSPhilip Paeps 	} while (B_FALSE)
1005e948693eSPhilip Paeps 
1006e948693eSPhilip Paeps #define	EFX_BAR_TBL_WRITED(_enp, _reg, _index, _edp, _lock)		\
1007e948693eSPhilip Paeps 	do {								\
1008e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
1009e948693eSPhilip Paeps 		EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg,	\
1010e948693eSPhilip Paeps 		    uint32_t, (_index),					\
1011e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
1012e948693eSPhilip Paeps 		    uint32_t, (_edp)->ed_u32[0]);			\
1013e948693eSPhilip Paeps 		EFSYS_BAR_WRITED((_enp)->en_esbp,			\
1014e948693eSPhilip Paeps 		    (_reg ## _OFST + ((_index) * _reg ## _STEP)),	\
1015e948693eSPhilip Paeps 		    (_edp), (_lock));					\
1016e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
1017e948693eSPhilip Paeps 	} while (B_FALSE)
1018e948693eSPhilip Paeps 
1019e948693eSPhilip Paeps #define	EFX_BAR_TBL_WRITED3(_enp, _reg, _index, _edp, _lock)		\
1020e948693eSPhilip Paeps 	do {								\
1021e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
1022e948693eSPhilip Paeps 		EFSYS_PROBE4(efx_bar_tbl_writed, const char *, #_reg,	\
1023e948693eSPhilip Paeps 		    uint32_t, (_index),					\
1024e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
1025e948693eSPhilip Paeps 		    uint32_t, (_edp)->ed_u32[0]);			\
1026e948693eSPhilip Paeps 		EFSYS_BAR_WRITED((_enp)->en_esbp,			\
1027e948693eSPhilip Paeps 		    (_reg ## _OFST +					\
1028e948693eSPhilip Paeps 		    (3 * sizeof (efx_dword_t)) +			\
1029e948693eSPhilip Paeps 		    ((_index) * _reg ## _STEP)),			\
1030e948693eSPhilip Paeps 		    (_edp), (_lock));					\
1031e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
1032e948693eSPhilip Paeps 	} while (B_FALSE)
1033e948693eSPhilip Paeps 
1034e948693eSPhilip Paeps #define	EFX_BAR_TBL_READQ(_enp, _reg, _index, _eqp)			\
1035e948693eSPhilip Paeps 	do {								\
1036e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
1037e948693eSPhilip Paeps 		EFSYS_BAR_READQ((_enp)->en_esbp,			\
1038e948693eSPhilip Paeps 		    (_reg ## _OFST + ((_index) * _reg ## _STEP)),	\
1039e948693eSPhilip Paeps 		    (_eqp));						\
1040e948693eSPhilip Paeps 		EFSYS_PROBE5(efx_bar_tbl_readq, const char *, #_reg,	\
1041e948693eSPhilip Paeps 		    uint32_t, (_index),					\
1042e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
1043e948693eSPhilip Paeps 		    uint32_t, (_eqp)->eq_u32[1],			\
1044e948693eSPhilip Paeps 		    uint32_t, (_eqp)->eq_u32[0]);			\
1045e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
1046e948693eSPhilip Paeps 	} while (B_FALSE)
1047e948693eSPhilip Paeps 
1048e948693eSPhilip Paeps #define	EFX_BAR_TBL_WRITEQ(_enp, _reg, _index, _eqp)			\
1049e948693eSPhilip Paeps 	do {								\
1050e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
1051e948693eSPhilip Paeps 		EFSYS_PROBE5(efx_bar_tbl_writeq, const char *, #_reg,	\
1052e948693eSPhilip Paeps 		    uint32_t, (_index),					\
1053e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
1054e948693eSPhilip Paeps 		    uint32_t, (_eqp)->eq_u32[1],			\
1055e948693eSPhilip Paeps 		    uint32_t, (_eqp)->eq_u32[0]);			\
1056e948693eSPhilip Paeps 		EFSYS_BAR_WRITEQ((_enp)->en_esbp,			\
1057e948693eSPhilip Paeps 		    (_reg ## _OFST + ((_index) * _reg ## _STEP)),	\
1058e948693eSPhilip Paeps 		    (_eqp));						\
1059e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
1060e948693eSPhilip Paeps 	} while (B_FALSE)
1061e948693eSPhilip Paeps 
10623c838a9fSAndrew Rybchenko #define	EFX_BAR_TBL_READO(_enp, _reg, _index, _eop, _lock)		\
1063e948693eSPhilip Paeps 	do {								\
1064e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
1065e948693eSPhilip Paeps 		EFSYS_BAR_READO((_enp)->en_esbp,			\
1066e948693eSPhilip Paeps 		    (_reg ## _OFST + ((_index) * _reg ## _STEP)),	\
10673c838a9fSAndrew Rybchenko 		    (_eop), (_lock));					\
1068e948693eSPhilip Paeps 		EFSYS_PROBE7(efx_bar_tbl_reado, const char *, #_reg,	\
1069e948693eSPhilip Paeps 		    uint32_t, (_index),					\
1070e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
1071e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[3],			\
1072e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[2],			\
1073e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[1],			\
1074e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[0]);			\
1075e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
1076e948693eSPhilip Paeps 	} while (B_FALSE)
1077e948693eSPhilip Paeps 
10783c838a9fSAndrew Rybchenko #define	EFX_BAR_TBL_WRITEO(_enp, _reg, _index, _eop, _lock)		\
1079e948693eSPhilip Paeps 	do {								\
1080e948693eSPhilip Paeps 		EFX_CHECK_REG((_enp), (_reg));				\
1081e948693eSPhilip Paeps 		EFSYS_PROBE7(efx_bar_tbl_writeo, const char *, #_reg,	\
1082e948693eSPhilip Paeps 		    uint32_t, (_index),					\
1083e948693eSPhilip Paeps 		    uint32_t, _reg ## _OFST,				\
1084e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[3],			\
1085e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[2],			\
1086e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[1],			\
1087e948693eSPhilip Paeps 		    uint32_t, (_eop)->eo_u32[0]);			\
1088e948693eSPhilip Paeps 		EFSYS_BAR_WRITEO((_enp)->en_esbp,			\
1089e948693eSPhilip Paeps 		    (_reg ## _OFST + ((_index) * _reg ## _STEP)),	\
10903c838a9fSAndrew Rybchenko 		    (_eop), (_lock));					\
10913c838a9fSAndrew Rybchenko 	_NOTE(CONSTANTCONDITION)					\
10923c838a9fSAndrew Rybchenko 	} while (B_FALSE)
10933c838a9fSAndrew Rybchenko 
10943c838a9fSAndrew Rybchenko /*
1095c63c8369SAndrew Rybchenko  * Accessors for memory BAR per-VI registers.
1096c63c8369SAndrew Rybchenko  *
1097c63c8369SAndrew Rybchenko  * The VI window size is 8KB for Medford and all earlier controllers.
1098c63c8369SAndrew Rybchenko  * For Medford2, the VI window size can be 8KB, 16KB or 64KB.
1099c63c8369SAndrew Rybchenko  */
1100c63c8369SAndrew Rybchenko 
1101c63c8369SAndrew Rybchenko #define	EFX_BAR_VI_READD(_enp, _reg, _index, _edp, _lock)		\
1102c63c8369SAndrew Rybchenko 	do {								\
1103c63c8369SAndrew Rybchenko 		EFX_CHECK_REG((_enp), (_reg));				\
1104c63c8369SAndrew Rybchenko 		EFSYS_BAR_READD((_enp)->en_esbp,			\
1105c63c8369SAndrew Rybchenko 		    ((_reg ## _OFST) +					\
1106c63c8369SAndrew Rybchenko 		    ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1107c63c8369SAndrew Rybchenko 		    (_edp), (_lock));					\
1108c63c8369SAndrew Rybchenko 		EFSYS_PROBE4(efx_bar_vi_readd, const char *, #_reg,	\
1109c63c8369SAndrew Rybchenko 		    uint32_t, (_index),					\
1110c63c8369SAndrew Rybchenko 		    uint32_t, _reg ## _OFST,				\
1111c63c8369SAndrew Rybchenko 		    uint32_t, (_edp)->ed_u32[0]);			\
1112c63c8369SAndrew Rybchenko 	_NOTE(CONSTANTCONDITION)					\
1113c63c8369SAndrew Rybchenko 	} while (B_FALSE)
1114c63c8369SAndrew Rybchenko 
1115c63c8369SAndrew Rybchenko #define	EFX_BAR_VI_WRITED(_enp, _reg, _index, _edp, _lock)		\
1116c63c8369SAndrew Rybchenko 	do {								\
1117c63c8369SAndrew Rybchenko 		EFX_CHECK_REG((_enp), (_reg));				\
1118c63c8369SAndrew Rybchenko 		EFSYS_PROBE4(efx_bar_vi_writed, const char *, #_reg,	\
1119c63c8369SAndrew Rybchenko 		    uint32_t, (_index),					\
1120c63c8369SAndrew Rybchenko 		    uint32_t, _reg ## _OFST,				\
1121c63c8369SAndrew Rybchenko 		    uint32_t, (_edp)->ed_u32[0]);			\
1122c63c8369SAndrew Rybchenko 		EFSYS_BAR_WRITED((_enp)->en_esbp,			\
1123c63c8369SAndrew Rybchenko 		    ((_reg ## _OFST) +					\
1124c63c8369SAndrew Rybchenko 		    ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1125c63c8369SAndrew Rybchenko 		    (_edp), (_lock));					\
1126c63c8369SAndrew Rybchenko 	_NOTE(CONSTANTCONDITION)					\
1127c63c8369SAndrew Rybchenko 	} while (B_FALSE)
1128c63c8369SAndrew Rybchenko 
1129c63c8369SAndrew Rybchenko #define	EFX_BAR_VI_WRITED2(_enp, _reg, _index, _edp, _lock)		\
1130c63c8369SAndrew Rybchenko 	do {								\
1131c63c8369SAndrew Rybchenko 		EFX_CHECK_REG((_enp), (_reg));				\
1132c63c8369SAndrew Rybchenko 		EFSYS_PROBE4(efx_bar_vi_writed, const char *, #_reg,	\
1133c63c8369SAndrew Rybchenko 		    uint32_t, (_index),					\
1134c63c8369SAndrew Rybchenko 		    uint32_t, _reg ## _OFST,				\
1135c63c8369SAndrew Rybchenko 		    uint32_t, (_edp)->ed_u32[0]);			\
1136c63c8369SAndrew Rybchenko 		EFSYS_BAR_WRITED((_enp)->en_esbp,			\
1137c63c8369SAndrew Rybchenko 		    ((_reg ## _OFST) +					\
1138c63c8369SAndrew Rybchenko 		    (2 * sizeof (efx_dword_t)) +			\
1139c63c8369SAndrew Rybchenko 		    ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
1140c63c8369SAndrew Rybchenko 		    (_edp), (_lock));					\
1141c63c8369SAndrew Rybchenko 	_NOTE(CONSTANTCONDITION)					\
1142c63c8369SAndrew Rybchenko 	} while (B_FALSE)
1143c63c8369SAndrew Rybchenko 
1144c63c8369SAndrew Rybchenko /*
1145c63c8369SAndrew Rybchenko  * Allow drivers to perform optimised 128-bit VI doorbell writes.
11463c838a9fSAndrew Rybchenko  * The DMA descriptor pointers (RX_DESC_UPD and TX_DESC_UPD) are
11473c838a9fSAndrew Rybchenko  * special-cased in the BIU on the Falcon/Siena and EF10 architectures to avoid
11483c838a9fSAndrew Rybchenko  * the need for locking in the host, and are the only ones known to be safe to
11493c838a9fSAndrew Rybchenko  * use 128-bites write with.
11503c838a9fSAndrew Rybchenko  */
1151c63c8369SAndrew Rybchenko #define	EFX_BAR_VI_DOORBELL_WRITEO(_enp, _reg, _index, _eop)		\
11523c838a9fSAndrew Rybchenko 	do {								\
11533c838a9fSAndrew Rybchenko 		EFX_CHECK_REG((_enp), (_reg));				\
1154c63c8369SAndrew Rybchenko 		EFSYS_PROBE7(efx_bar_vi_doorbell_writeo,		\
115595c45bd0SAndrew Rybchenko 		    const char *, #_reg,				\
11563c838a9fSAndrew Rybchenko 		    uint32_t, (_index),					\
11573c838a9fSAndrew Rybchenko 		    uint32_t, _reg ## _OFST,				\
11583c838a9fSAndrew Rybchenko 		    uint32_t, (_eop)->eo_u32[3],			\
11593c838a9fSAndrew Rybchenko 		    uint32_t, (_eop)->eo_u32[2],			\
11603c838a9fSAndrew Rybchenko 		    uint32_t, (_eop)->eo_u32[1],			\
11613c838a9fSAndrew Rybchenko 		    uint32_t, (_eop)->eo_u32[0]);			\
11623c838a9fSAndrew Rybchenko 		EFSYS_BAR_DOORBELL_WRITEO((_enp)->en_esbp,		\
1163c63c8369SAndrew Rybchenko 		    (_reg ## _OFST +					\
1164c63c8369SAndrew Rybchenko 		    ((_index) << (_enp)->en_nic_cfg.enc_vi_window_shift)), \
11653c838a9fSAndrew Rybchenko 		    (_eop));						\
11663c838a9fSAndrew Rybchenko 	_NOTE(CONSTANTCONDITION)					\
11673c838a9fSAndrew Rybchenko 	} while (B_FALSE)
11683c838a9fSAndrew Rybchenko 
11693c838a9fSAndrew Rybchenko #define	EFX_DMA_SYNC_QUEUE_FOR_DEVICE(_esmp, _entries, _wptr, _owptr)	\
11703c838a9fSAndrew Rybchenko 	do {								\
11713c838a9fSAndrew Rybchenko 		unsigned int _new = (_wptr);				\
11723c838a9fSAndrew Rybchenko 		unsigned int _old = (_owptr);				\
11733c838a9fSAndrew Rybchenko 									\
11743c838a9fSAndrew Rybchenko 		if ((_new) >= (_old))					\
11753c838a9fSAndrew Rybchenko 			EFSYS_DMA_SYNC_FOR_DEVICE((_esmp),		\
11763c838a9fSAndrew Rybchenko 			    (_old) * sizeof (efx_desc_t),		\
11773c838a9fSAndrew Rybchenko 			    ((_new) - (_old)) * sizeof (efx_desc_t));	\
11783c838a9fSAndrew Rybchenko 		else							\
11793c838a9fSAndrew Rybchenko 			/*						\
11803c838a9fSAndrew Rybchenko 			 * It is cheaper to sync entire map than sync	\
11813c838a9fSAndrew Rybchenko 			 * two parts especially when offset/size are	\
11823c838a9fSAndrew Rybchenko 			 * ignored and entire map is synced in any case.\
11833c838a9fSAndrew Rybchenko 			 */						\
11843c838a9fSAndrew Rybchenko 			EFSYS_DMA_SYNC_FOR_DEVICE((_esmp),		\
11853c838a9fSAndrew Rybchenko 			    0,						\
11863c838a9fSAndrew Rybchenko 			    (_entries) * sizeof (efx_desc_t));		\
1187e948693eSPhilip Paeps 	_NOTE(CONSTANTCONDITION)					\
1188e948693eSPhilip Paeps 	} while (B_FALSE)
1189e948693eSPhilip Paeps 
1190460cb568SAndrew Rybchenko extern	__checkReturn	efx_rc_t
1191e948693eSPhilip Paeps efx_mac_select(
1192e948693eSPhilip Paeps 	__in		efx_nic_t *enp);
1193e948693eSPhilip Paeps 
11943c838a9fSAndrew Rybchenko extern	void
11953c838a9fSAndrew Rybchenko efx_mac_multicast_hash_compute(
11963c838a9fSAndrew Rybchenko 	__in_ecount(6*count)		uint8_t const *addrs,
11973c838a9fSAndrew Rybchenko 	__in				int count,
11983c838a9fSAndrew Rybchenko 	__out				efx_oword_t *hash_low,
11993c838a9fSAndrew Rybchenko 	__out				efx_oword_t *hash_high);
12003c838a9fSAndrew Rybchenko 
1201460cb568SAndrew Rybchenko extern	__checkReturn	efx_rc_t
1202e948693eSPhilip Paeps efx_phy_probe(
1203e948693eSPhilip Paeps 	__in		efx_nic_t *enp);
1204e948693eSPhilip Paeps 
1205e948693eSPhilip Paeps extern			void
1206e948693eSPhilip Paeps efx_phy_unprobe(
1207e948693eSPhilip Paeps 	__in		efx_nic_t *enp);
1208e948693eSPhilip Paeps 
1209e948693eSPhilip Paeps #if EFSYS_OPT_VPD
1210e948693eSPhilip Paeps 
1211e948693eSPhilip Paeps /* VPD utility functions */
1212e948693eSPhilip Paeps 
1213460cb568SAndrew Rybchenko extern	__checkReturn		efx_rc_t
1214e948693eSPhilip Paeps efx_vpd_hunk_length(
1215e948693eSPhilip Paeps 	__in_bcount(size)	caddr_t data,
1216e948693eSPhilip Paeps 	__in			size_t size,
1217e948693eSPhilip Paeps 	__out			size_t *lengthp);
1218e948693eSPhilip Paeps 
1219460cb568SAndrew Rybchenko extern	__checkReturn		efx_rc_t
1220e948693eSPhilip Paeps efx_vpd_hunk_verify(
1221e948693eSPhilip Paeps 	__in_bcount(size)	caddr_t data,
1222e948693eSPhilip Paeps 	__in			size_t size,
1223e948693eSPhilip Paeps 	__out_opt		boolean_t *cksummedp);
1224e948693eSPhilip Paeps 
1225460cb568SAndrew Rybchenko extern	__checkReturn		efx_rc_t
1226e948693eSPhilip Paeps efx_vpd_hunk_reinit(
12273c838a9fSAndrew Rybchenko 	__in_bcount(size)	caddr_t data,
1228e948693eSPhilip Paeps 	__in			size_t size,
1229e948693eSPhilip Paeps 	__in			boolean_t wantpid);
1230e948693eSPhilip Paeps 
1231460cb568SAndrew Rybchenko extern	__checkReturn		efx_rc_t
1232e948693eSPhilip Paeps efx_vpd_hunk_get(
1233e948693eSPhilip Paeps 	__in_bcount(size)	caddr_t data,
1234e948693eSPhilip Paeps 	__in			size_t size,
1235e948693eSPhilip Paeps 	__in			efx_vpd_tag_t tag,
1236e948693eSPhilip Paeps 	__in			efx_vpd_keyword_t keyword,
1237e948693eSPhilip Paeps 	__out			unsigned int *payloadp,
1238e948693eSPhilip Paeps 	__out			uint8_t *paylenp);
1239e948693eSPhilip Paeps 
1240460cb568SAndrew Rybchenko extern	__checkReturn			efx_rc_t
1241e948693eSPhilip Paeps efx_vpd_hunk_next(
1242e948693eSPhilip Paeps 	__in_bcount(size)		caddr_t data,
1243e948693eSPhilip Paeps 	__in				size_t size,
1244e948693eSPhilip Paeps 	__out				efx_vpd_tag_t *tagp,
1245e948693eSPhilip Paeps 	__out				efx_vpd_keyword_t *keyword,
124686ec4b85SAndrew Rybchenko 	__out_opt			unsigned int *payloadp,
1247e948693eSPhilip Paeps 	__out_opt			uint8_t *paylenp,
1248e948693eSPhilip Paeps 	__inout				unsigned int *contp);
1249e948693eSPhilip Paeps 
1250460cb568SAndrew Rybchenko extern	__checkReturn		efx_rc_t
1251e948693eSPhilip Paeps efx_vpd_hunk_set(
1252e948693eSPhilip Paeps 	__in_bcount(size)	caddr_t data,
1253e948693eSPhilip Paeps 	__in			size_t size,
1254e948693eSPhilip Paeps 	__in			efx_vpd_value_t *evvp);
1255e948693eSPhilip Paeps 
1256e948693eSPhilip Paeps #endif	/* EFSYS_OPT_VPD */
1257e948693eSPhilip Paeps 
12583c838a9fSAndrew Rybchenko #if EFSYS_OPT_MCDI
12593c838a9fSAndrew Rybchenko 
1260460cb568SAndrew Rybchenko extern	__checkReturn		efx_rc_t
12613c838a9fSAndrew Rybchenko efx_mcdi_set_workaround(
12623c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
12633c838a9fSAndrew Rybchenko 	__in			uint32_t type,
12643c838a9fSAndrew Rybchenko 	__in			boolean_t enabled,
12653c838a9fSAndrew Rybchenko 	__out_opt		uint32_t *flagsp);
12663c838a9fSAndrew Rybchenko 
1267460cb568SAndrew Rybchenko extern	__checkReturn		efx_rc_t
12683c838a9fSAndrew Rybchenko efx_mcdi_get_workarounds(
12693c838a9fSAndrew Rybchenko 	__in			efx_nic_t *enp,
12703c838a9fSAndrew Rybchenko 	__out_opt		uint32_t *implementedp,
12713c838a9fSAndrew Rybchenko 	__out_opt		uint32_t *enabledp);
12723c838a9fSAndrew Rybchenko 
12733c838a9fSAndrew Rybchenko #endif /* EFSYS_OPT_MCDI */
12743c838a9fSAndrew Rybchenko 
127558a72cb2SAndrew Rybchenko #if EFSYS_OPT_MAC_STATS
127658a72cb2SAndrew Rybchenko 
127758a72cb2SAndrew Rybchenko /*
127858a72cb2SAndrew Rybchenko  * Closed range of stats (i.e. the first and the last are included).
127958a72cb2SAndrew Rybchenko  * The last must be greater or equal (if the range is one item only) to
128058a72cb2SAndrew Rybchenko  * the first.
128158a72cb2SAndrew Rybchenko  */
128258a72cb2SAndrew Rybchenko struct efx_mac_stats_range {
128358a72cb2SAndrew Rybchenko 	efx_mac_stat_t		first;
128458a72cb2SAndrew Rybchenko 	efx_mac_stat_t		last;
128558a72cb2SAndrew Rybchenko };
128658a72cb2SAndrew Rybchenko 
128758a72cb2SAndrew Rybchenko extern					efx_rc_t
128858a72cb2SAndrew Rybchenko efx_mac_stats_mask_add_ranges(
128958a72cb2SAndrew Rybchenko 	__inout_bcount(mask_size)	uint32_t *maskp,
129058a72cb2SAndrew Rybchenko 	__in				size_t mask_size,
129158a72cb2SAndrew Rybchenko 	__in_ecount(rng_count)		const struct efx_mac_stats_range *rngp,
129258a72cb2SAndrew Rybchenko 	__in				unsigned int rng_count);
129358a72cb2SAndrew Rybchenko 
129458a72cb2SAndrew Rybchenko #endif	/* EFSYS_OPT_MAC_STATS */
129558a72cb2SAndrew Rybchenko 
1296e948693eSPhilip Paeps #ifdef	__cplusplus
1297e948693eSPhilip Paeps }
1298e948693eSPhilip Paeps #endif
1299e948693eSPhilip Paeps 
1300e948693eSPhilip Paeps #endif	/* _SYS_EFX_IMPL_H */
1301