xref: /openbmc/linux/drivers/net/ethernet/sfc/nic.h (revision cd2d5b52)
1874aeea5SJeff Kirsher /****************************************************************************
2874aeea5SJeff Kirsher  * Driver for Solarflare Solarstorm network controllers and boards
3874aeea5SJeff Kirsher  * Copyright 2005-2006 Fen Systems Ltd.
4874aeea5SJeff Kirsher  * Copyright 2006-2011 Solarflare Communications Inc.
5874aeea5SJeff Kirsher  *
6874aeea5SJeff Kirsher  * This program is free software; you can redistribute it and/or modify it
7874aeea5SJeff Kirsher  * under the terms of the GNU General Public License version 2 as published
8874aeea5SJeff Kirsher  * by the Free Software Foundation, incorporated herein by reference.
9874aeea5SJeff Kirsher  */
10874aeea5SJeff Kirsher 
11874aeea5SJeff Kirsher #ifndef EFX_NIC_H
12874aeea5SJeff Kirsher #define EFX_NIC_H
13874aeea5SJeff Kirsher 
14874aeea5SJeff Kirsher #include <linux/i2c-algo-bit.h>
15874aeea5SJeff Kirsher #include "net_driver.h"
16874aeea5SJeff Kirsher #include "efx.h"
17874aeea5SJeff Kirsher #include "mcdi.h"
18874aeea5SJeff Kirsher #include "spi.h"
19874aeea5SJeff Kirsher 
20874aeea5SJeff Kirsher /*
21874aeea5SJeff Kirsher  * Falcon hardware control
22874aeea5SJeff Kirsher  */
23874aeea5SJeff Kirsher 
24874aeea5SJeff Kirsher enum {
25874aeea5SJeff Kirsher 	EFX_REV_FALCON_A0 = 0,
26874aeea5SJeff Kirsher 	EFX_REV_FALCON_A1 = 1,
27874aeea5SJeff Kirsher 	EFX_REV_FALCON_B0 = 2,
28874aeea5SJeff Kirsher 	EFX_REV_SIENA_A0 = 3,
29874aeea5SJeff Kirsher };
30874aeea5SJeff Kirsher 
31874aeea5SJeff Kirsher static inline int efx_nic_rev(struct efx_nic *efx)
32874aeea5SJeff Kirsher {
33874aeea5SJeff Kirsher 	return efx->type->revision;
34874aeea5SJeff Kirsher }
35874aeea5SJeff Kirsher 
36874aeea5SJeff Kirsher extern u32 efx_nic_fpga_ver(struct efx_nic *efx);
37874aeea5SJeff Kirsher 
38874aeea5SJeff Kirsher static inline bool efx_nic_has_mc(struct efx_nic *efx)
39874aeea5SJeff Kirsher {
40874aeea5SJeff Kirsher 	return efx_nic_rev(efx) >= EFX_REV_SIENA_A0;
41874aeea5SJeff Kirsher }
42874aeea5SJeff Kirsher /* NIC has two interlinked PCI functions for the same port. */
43874aeea5SJeff Kirsher static inline bool efx_nic_is_dual_func(struct efx_nic *efx)
44874aeea5SJeff Kirsher {
45874aeea5SJeff Kirsher 	return efx_nic_rev(efx) < EFX_REV_FALCON_B0;
46874aeea5SJeff Kirsher }
47874aeea5SJeff Kirsher 
48874aeea5SJeff Kirsher enum {
49874aeea5SJeff Kirsher 	PHY_TYPE_NONE = 0,
50874aeea5SJeff Kirsher 	PHY_TYPE_TXC43128 = 1,
51874aeea5SJeff Kirsher 	PHY_TYPE_88E1111 = 2,
52874aeea5SJeff Kirsher 	PHY_TYPE_SFX7101 = 3,
53874aeea5SJeff Kirsher 	PHY_TYPE_QT2022C2 = 4,
54874aeea5SJeff Kirsher 	PHY_TYPE_PM8358 = 6,
55874aeea5SJeff Kirsher 	PHY_TYPE_SFT9001A = 8,
56874aeea5SJeff Kirsher 	PHY_TYPE_QT2025C = 9,
57874aeea5SJeff Kirsher 	PHY_TYPE_SFT9001B = 10,
58874aeea5SJeff Kirsher };
59874aeea5SJeff Kirsher 
60874aeea5SJeff Kirsher #define FALCON_XMAC_LOOPBACKS			\
61874aeea5SJeff Kirsher 	((1 << LOOPBACK_XGMII) |		\
62874aeea5SJeff Kirsher 	 (1 << LOOPBACK_XGXS) |			\
63874aeea5SJeff Kirsher 	 (1 << LOOPBACK_XAUI))
64874aeea5SJeff Kirsher 
65874aeea5SJeff Kirsher #define FALCON_GMAC_LOOPBACKS			\
66874aeea5SJeff Kirsher 	(1 << LOOPBACK_GMAC)
67874aeea5SJeff Kirsher 
685b6262d0SBen Hutchings /* Alignment of PCIe DMA boundaries (4KB) */
695b6262d0SBen Hutchings #define EFX_PAGE_SIZE	4096
705b6262d0SBen Hutchings /* Size and alignment of buffer table entries (same) */
715b6262d0SBen Hutchings #define EFX_BUF_SIZE	EFX_PAGE_SIZE
725b6262d0SBen Hutchings 
73874aeea5SJeff Kirsher /**
74874aeea5SJeff Kirsher  * struct falcon_board_type - board operations and type information
75874aeea5SJeff Kirsher  * @id: Board type id, as found in NVRAM
76874aeea5SJeff Kirsher  * @ref_model: Model number of Solarflare reference design
77874aeea5SJeff Kirsher  * @gen_type: Generic board type description
78874aeea5SJeff Kirsher  * @init: Allocate resources and initialise peripheral hardware
79874aeea5SJeff Kirsher  * @init_phy: Do board-specific PHY initialisation
80874aeea5SJeff Kirsher  * @fini: Shut down hardware and free resources
81874aeea5SJeff Kirsher  * @set_id_led: Set state of identifying LED or revert to automatic function
82874aeea5SJeff Kirsher  * @monitor: Board-specific health check function
83874aeea5SJeff Kirsher  */
84874aeea5SJeff Kirsher struct falcon_board_type {
85874aeea5SJeff Kirsher 	u8 id;
86874aeea5SJeff Kirsher 	const char *ref_model;
87874aeea5SJeff Kirsher 	const char *gen_type;
88874aeea5SJeff Kirsher 	int (*init) (struct efx_nic *nic);
89874aeea5SJeff Kirsher 	void (*init_phy) (struct efx_nic *efx);
90874aeea5SJeff Kirsher 	void (*fini) (struct efx_nic *nic);
91874aeea5SJeff Kirsher 	void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
92874aeea5SJeff Kirsher 	int (*monitor) (struct efx_nic *nic);
93874aeea5SJeff Kirsher };
94874aeea5SJeff Kirsher 
95874aeea5SJeff Kirsher /**
96874aeea5SJeff Kirsher  * struct falcon_board - board information
97874aeea5SJeff Kirsher  * @type: Type of board
98874aeea5SJeff Kirsher  * @major: Major rev. ('A', 'B' ...)
99874aeea5SJeff Kirsher  * @minor: Minor rev. (0, 1, ...)
100874aeea5SJeff Kirsher  * @i2c_adap: I2C adapter for on-board peripherals
101874aeea5SJeff Kirsher  * @i2c_data: Data for bit-banging algorithm
102874aeea5SJeff Kirsher  * @hwmon_client: I2C client for hardware monitor
103874aeea5SJeff Kirsher  * @ioexp_client: I2C client for power/port control
104874aeea5SJeff Kirsher  */
105874aeea5SJeff Kirsher struct falcon_board {
106874aeea5SJeff Kirsher 	const struct falcon_board_type *type;
107874aeea5SJeff Kirsher 	int major;
108874aeea5SJeff Kirsher 	int minor;
109874aeea5SJeff Kirsher 	struct i2c_adapter i2c_adap;
110874aeea5SJeff Kirsher 	struct i2c_algo_bit_data i2c_data;
111874aeea5SJeff Kirsher 	struct i2c_client *hwmon_client, *ioexp_client;
112874aeea5SJeff Kirsher };
113874aeea5SJeff Kirsher 
114874aeea5SJeff Kirsher /**
115874aeea5SJeff Kirsher  * struct falcon_nic_data - Falcon NIC state
116874aeea5SJeff Kirsher  * @pci_dev2: Secondary function of Falcon A
117874aeea5SJeff Kirsher  * @board: Board state and functions
118874aeea5SJeff Kirsher  * @stats_disable_count: Nest count for disabling statistics fetches
119874aeea5SJeff Kirsher  * @stats_pending: Is there a pending DMA of MAC statistics.
120874aeea5SJeff Kirsher  * @stats_timer: A timer for regularly fetching MAC statistics.
121874aeea5SJeff Kirsher  * @stats_dma_done: Pointer to the flag which indicates DMA completion.
122874aeea5SJeff Kirsher  * @spi_flash: SPI flash device
123874aeea5SJeff Kirsher  * @spi_eeprom: SPI EEPROM device
124874aeea5SJeff Kirsher  * @spi_lock: SPI bus lock
125874aeea5SJeff Kirsher  * @mdio_lock: MDIO bus lock
126874aeea5SJeff Kirsher  * @xmac_poll_required: XMAC link state needs polling
127874aeea5SJeff Kirsher  */
128874aeea5SJeff Kirsher struct falcon_nic_data {
129874aeea5SJeff Kirsher 	struct pci_dev *pci_dev2;
130874aeea5SJeff Kirsher 	struct falcon_board board;
131874aeea5SJeff Kirsher 	unsigned int stats_disable_count;
132874aeea5SJeff Kirsher 	bool stats_pending;
133874aeea5SJeff Kirsher 	struct timer_list stats_timer;
134874aeea5SJeff Kirsher 	u32 *stats_dma_done;
135874aeea5SJeff Kirsher 	struct efx_spi_device spi_flash;
136874aeea5SJeff Kirsher 	struct efx_spi_device spi_eeprom;
137874aeea5SJeff Kirsher 	struct mutex spi_lock;
138874aeea5SJeff Kirsher 	struct mutex mdio_lock;
139874aeea5SJeff Kirsher 	bool xmac_poll_required;
140874aeea5SJeff Kirsher };
141874aeea5SJeff Kirsher 
142874aeea5SJeff Kirsher static inline struct falcon_board *falcon_board(struct efx_nic *efx)
143874aeea5SJeff Kirsher {
144874aeea5SJeff Kirsher 	struct falcon_nic_data *data = efx->nic_data;
145874aeea5SJeff Kirsher 	return &data->board;
146874aeea5SJeff Kirsher }
147874aeea5SJeff Kirsher 
148874aeea5SJeff Kirsher /**
149874aeea5SJeff Kirsher  * struct siena_nic_data - Siena NIC state
150874aeea5SJeff Kirsher  * @mcdi: Management-Controller-to-Driver Interface
151874aeea5SJeff Kirsher  * @wol_filter_id: Wake-on-LAN packet filter id
15255c5e0f8SBen Hutchings  * @hwmon: Hardware monitor state
153874aeea5SJeff Kirsher  */
154874aeea5SJeff Kirsher struct siena_nic_data {
155874aeea5SJeff Kirsher 	struct efx_mcdi_iface mcdi;
156874aeea5SJeff Kirsher 	int wol_filter_id;
15755c5e0f8SBen Hutchings #ifdef CONFIG_SFC_MCDI_MON
15855c5e0f8SBen Hutchings 	struct efx_mcdi_mon hwmon;
15955c5e0f8SBen Hutchings #endif
160874aeea5SJeff Kirsher };
161874aeea5SJeff Kirsher 
16255c5e0f8SBen Hutchings #ifdef CONFIG_SFC_MCDI_MON
16355c5e0f8SBen Hutchings static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx)
16455c5e0f8SBen Hutchings {
16555c5e0f8SBen Hutchings 	struct siena_nic_data *nic_data;
16655c5e0f8SBen Hutchings 	EFX_BUG_ON_PARANOID(efx_nic_rev(efx) < EFX_REV_SIENA_A0);
16755c5e0f8SBen Hutchings 	nic_data = efx->nic_data;
16855c5e0f8SBen Hutchings 	return &nic_data->hwmon;
16955c5e0f8SBen Hutchings }
17055c5e0f8SBen Hutchings #endif
17155c5e0f8SBen Hutchings 
172cd2d5b52SBen Hutchings /*
173cd2d5b52SBen Hutchings  * On the SFC9000 family each port is associated with 1 PCI physical
174cd2d5b52SBen Hutchings  * function (PF) handled by sfc and a configurable number of virtual
175cd2d5b52SBen Hutchings  * functions (VFs) that may be handled by some other driver, often in
176cd2d5b52SBen Hutchings  * a VM guest.  The queue pointer registers are mapped in both PF and
177cd2d5b52SBen Hutchings  * VF BARs such that an 8K region provides access to a single RX, TX
178cd2d5b52SBen Hutchings  * and event queue (collectively a Virtual Interface, VI or VNIC).
179cd2d5b52SBen Hutchings  *
180cd2d5b52SBen Hutchings  * The PF has access to all 1024 VIs while VFs are mapped to VIs
181cd2d5b52SBen Hutchings  * according to VI_BASE and VI_SCALE: VF i has access to VIs numbered
182cd2d5b52SBen Hutchings  * in range [VI_BASE + i << VI_SCALE, VI_BASE + i + 1 << VI_SCALE).
183cd2d5b52SBen Hutchings  * The number of VIs and the VI_SCALE value are configurable but must
184cd2d5b52SBen Hutchings  * be established at boot time by firmware.
185cd2d5b52SBen Hutchings  */
186cd2d5b52SBen Hutchings 
187cd2d5b52SBen Hutchings /* Maximum VI_SCALE parameter supported by Siena */
188cd2d5b52SBen Hutchings #define EFX_VI_SCALE_MAX 6
189cd2d5b52SBen Hutchings /* Base VI to use for SR-IOV. Must be aligned to (1 << EFX_VI_SCALE_MAX),
190cd2d5b52SBen Hutchings  * so this is the smallest allowed value. */
191cd2d5b52SBen Hutchings #define EFX_VI_BASE 128U
192cd2d5b52SBen Hutchings /* Maximum number of VFs allowed */
193cd2d5b52SBen Hutchings #define EFX_VF_COUNT_MAX 127
194cd2d5b52SBen Hutchings /* Limit EVQs on VFs to be only 8k to reduce buffer table reservation */
195cd2d5b52SBen Hutchings #define EFX_MAX_VF_EVQ_SIZE 8192UL
196cd2d5b52SBen Hutchings /* The number of buffer table entries reserved for each VI on a VF */
197cd2d5b52SBen Hutchings #define EFX_VF_BUFTBL_PER_VI					\
198cd2d5b52SBen Hutchings 	((EFX_MAX_VF_EVQ_SIZE + 2 * EFX_MAX_DMAQ_SIZE) *	\
199cd2d5b52SBen Hutchings 	 sizeof(efx_qword_t) / EFX_BUF_SIZE)
200cd2d5b52SBen Hutchings 
201cd2d5b52SBen Hutchings #ifdef CONFIG_SFC_SRIOV
202cd2d5b52SBen Hutchings 
203cd2d5b52SBen Hutchings static inline bool efx_sriov_wanted(struct efx_nic *efx)
204cd2d5b52SBen Hutchings {
205cd2d5b52SBen Hutchings 	return efx->vf_count != 0;
206cd2d5b52SBen Hutchings }
207cd2d5b52SBen Hutchings static inline bool efx_sriov_enabled(struct efx_nic *efx)
208cd2d5b52SBen Hutchings {
209cd2d5b52SBen Hutchings 	return efx->vf_init_count != 0;
210cd2d5b52SBen Hutchings }
211cd2d5b52SBen Hutchings static inline unsigned int efx_vf_size(struct efx_nic *efx)
212cd2d5b52SBen Hutchings {
213cd2d5b52SBen Hutchings 	return 1 << efx->vi_scale;
214cd2d5b52SBen Hutchings }
215cd2d5b52SBen Hutchings 
216cd2d5b52SBen Hutchings extern int efx_init_sriov(void);
217cd2d5b52SBen Hutchings extern void efx_sriov_probe(struct efx_nic *efx);
218cd2d5b52SBen Hutchings extern int efx_sriov_init(struct efx_nic *efx);
219cd2d5b52SBen Hutchings extern void efx_sriov_mac_address_changed(struct efx_nic *efx);
220cd2d5b52SBen Hutchings extern void efx_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event);
221cd2d5b52SBen Hutchings extern void efx_sriov_rx_flush_done(struct efx_nic *efx, efx_qword_t *event);
222cd2d5b52SBen Hutchings extern void efx_sriov_event(struct efx_channel *channel, efx_qword_t *event);
223cd2d5b52SBen Hutchings extern void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq);
224cd2d5b52SBen Hutchings extern void efx_sriov_flr(struct efx_nic *efx, unsigned flr);
225cd2d5b52SBen Hutchings extern void efx_sriov_reset(struct efx_nic *efx);
226cd2d5b52SBen Hutchings extern void efx_sriov_fini(struct efx_nic *efx);
227cd2d5b52SBen Hutchings extern void efx_fini_sriov(void);
228cd2d5b52SBen Hutchings 
229cd2d5b52SBen Hutchings #else
230cd2d5b52SBen Hutchings 
231cd2d5b52SBen Hutchings static inline bool efx_sriov_wanted(struct efx_nic *efx) { return false; }
232cd2d5b52SBen Hutchings static inline bool efx_sriov_enabled(struct efx_nic *efx) { return false; }
233cd2d5b52SBen Hutchings static inline unsigned int efx_vf_size(struct efx_nic *efx) { return 0; }
234cd2d5b52SBen Hutchings 
235cd2d5b52SBen Hutchings static inline int efx_init_sriov(void) { return 0; }
236cd2d5b52SBen Hutchings static inline void efx_sriov_probe(struct efx_nic *efx) {}
237cd2d5b52SBen Hutchings static inline int efx_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; }
238cd2d5b52SBen Hutchings static inline void efx_sriov_mac_address_changed(struct efx_nic *efx) {}
239cd2d5b52SBen Hutchings static inline void efx_sriov_tx_flush_done(struct efx_nic *efx,
240cd2d5b52SBen Hutchings 					   efx_qword_t *event) {}
241cd2d5b52SBen Hutchings static inline void efx_sriov_rx_flush_done(struct efx_nic *efx,
242cd2d5b52SBen Hutchings 					   efx_qword_t *event) {}
243cd2d5b52SBen Hutchings static inline void efx_sriov_event(struct efx_channel *channel,
244cd2d5b52SBen Hutchings 				   efx_qword_t *event) {}
245cd2d5b52SBen Hutchings static inline void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq) {}
246cd2d5b52SBen Hutchings static inline void efx_sriov_flr(struct efx_nic *efx, unsigned flr) {}
247cd2d5b52SBen Hutchings static inline void efx_sriov_reset(struct efx_nic *efx) {}
248cd2d5b52SBen Hutchings static inline void efx_sriov_fini(struct efx_nic *efx) {}
249cd2d5b52SBen Hutchings static inline void efx_fini_sriov(void) {}
250cd2d5b52SBen Hutchings 
251cd2d5b52SBen Hutchings #endif
252cd2d5b52SBen Hutchings 
253cd2d5b52SBen Hutchings extern int efx_sriov_set_vf_mac(struct net_device *dev, int vf, u8 *mac);
254cd2d5b52SBen Hutchings extern int efx_sriov_set_vf_vlan(struct net_device *dev, int vf,
255cd2d5b52SBen Hutchings 				 u16 vlan, u8 qos);
256cd2d5b52SBen Hutchings extern int efx_sriov_get_vf_config(struct net_device *dev, int vf,
257cd2d5b52SBen Hutchings 				   struct ifla_vf_info *ivf);
258cd2d5b52SBen Hutchings extern int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf,
259cd2d5b52SBen Hutchings 				     bool spoofchk);
260cd2d5b52SBen Hutchings 
261874aeea5SJeff Kirsher extern const struct efx_nic_type falcon_a1_nic_type;
262874aeea5SJeff Kirsher extern const struct efx_nic_type falcon_b0_nic_type;
263874aeea5SJeff Kirsher extern const struct efx_nic_type siena_a0_nic_type;
264874aeea5SJeff Kirsher 
265874aeea5SJeff Kirsher /**************************************************************************
266874aeea5SJeff Kirsher  *
267874aeea5SJeff Kirsher  * Externs
268874aeea5SJeff Kirsher  *
269874aeea5SJeff Kirsher  **************************************************************************
270874aeea5SJeff Kirsher  */
271874aeea5SJeff Kirsher 
272874aeea5SJeff Kirsher extern int falcon_probe_board(struct efx_nic *efx, u16 revision_info);
273874aeea5SJeff Kirsher 
274874aeea5SJeff Kirsher /* TX data path */
275874aeea5SJeff Kirsher extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue);
276874aeea5SJeff Kirsher extern void efx_nic_init_tx(struct efx_tx_queue *tx_queue);
277874aeea5SJeff Kirsher extern void efx_nic_fini_tx(struct efx_tx_queue *tx_queue);
278874aeea5SJeff Kirsher extern void efx_nic_remove_tx(struct efx_tx_queue *tx_queue);
279874aeea5SJeff Kirsher extern void efx_nic_push_buffers(struct efx_tx_queue *tx_queue);
280874aeea5SJeff Kirsher 
281874aeea5SJeff Kirsher /* RX data path */
282874aeea5SJeff Kirsher extern int efx_nic_probe_rx(struct efx_rx_queue *rx_queue);
283874aeea5SJeff Kirsher extern void efx_nic_init_rx(struct efx_rx_queue *rx_queue);
284874aeea5SJeff Kirsher extern void efx_nic_fini_rx(struct efx_rx_queue *rx_queue);
285874aeea5SJeff Kirsher extern void efx_nic_remove_rx(struct efx_rx_queue *rx_queue);
286874aeea5SJeff Kirsher extern void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue);
2872ae75dacSBen Hutchings extern void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue);
288874aeea5SJeff Kirsher 
289874aeea5SJeff Kirsher /* Event data path */
290874aeea5SJeff Kirsher extern int efx_nic_probe_eventq(struct efx_channel *channel);
291874aeea5SJeff Kirsher extern void efx_nic_init_eventq(struct efx_channel *channel);
292874aeea5SJeff Kirsher extern void efx_nic_fini_eventq(struct efx_channel *channel);
293874aeea5SJeff Kirsher extern void efx_nic_remove_eventq(struct efx_channel *channel);
294874aeea5SJeff Kirsher extern int efx_nic_process_eventq(struct efx_channel *channel, int rx_quota);
295874aeea5SJeff Kirsher extern void efx_nic_eventq_read_ack(struct efx_channel *channel);
296874aeea5SJeff Kirsher extern bool efx_nic_event_present(struct efx_channel *channel);
297874aeea5SJeff Kirsher 
298874aeea5SJeff Kirsher /* MAC/PHY */
299874aeea5SJeff Kirsher extern void falcon_drain_tx_fifo(struct efx_nic *efx);
300874aeea5SJeff Kirsher extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
301710b208dSBen Hutchings extern bool falcon_xmac_check_fault(struct efx_nic *efx);
302710b208dSBen Hutchings extern int falcon_reconfigure_xmac(struct efx_nic *efx);
303710b208dSBen Hutchings extern void falcon_update_stats_xmac(struct efx_nic *efx);
304874aeea5SJeff Kirsher 
305874aeea5SJeff Kirsher /* Interrupts and test events */
306874aeea5SJeff Kirsher extern int efx_nic_init_interrupt(struct efx_nic *efx);
307874aeea5SJeff Kirsher extern void efx_nic_enable_interrupts(struct efx_nic *efx);
308874aeea5SJeff Kirsher extern void efx_nic_generate_test_event(struct efx_channel *channel);
309874aeea5SJeff Kirsher extern void efx_nic_generate_interrupt(struct efx_nic *efx);
310874aeea5SJeff Kirsher extern void efx_nic_disable_interrupts(struct efx_nic *efx);
311874aeea5SJeff Kirsher extern void efx_nic_fini_interrupt(struct efx_nic *efx);
312874aeea5SJeff Kirsher extern irqreturn_t efx_nic_fatal_interrupt(struct efx_nic *efx);
313874aeea5SJeff Kirsher extern irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id);
314874aeea5SJeff Kirsher extern void falcon_irq_ack_a1(struct efx_nic *efx);
315874aeea5SJeff Kirsher 
316874aeea5SJeff Kirsher /* Global Resources */
317874aeea5SJeff Kirsher extern int efx_nic_flush_queues(struct efx_nic *efx);
318874aeea5SJeff Kirsher extern void falcon_start_nic_stats(struct efx_nic *efx);
319874aeea5SJeff Kirsher extern void falcon_stop_nic_stats(struct efx_nic *efx);
320874aeea5SJeff Kirsher extern void falcon_setup_xaui(struct efx_nic *efx);
321874aeea5SJeff Kirsher extern int falcon_reset_xaui(struct efx_nic *efx);
32228e47c49SBen Hutchings extern void
32328e47c49SBen Hutchings efx_nic_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw);
324874aeea5SJeff Kirsher extern void efx_nic_init_common(struct efx_nic *efx);
325874aeea5SJeff Kirsher extern void efx_nic_push_rx_indir_table(struct efx_nic *efx);
326874aeea5SJeff Kirsher 
327874aeea5SJeff Kirsher int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
328874aeea5SJeff Kirsher 			 unsigned int len);
329874aeea5SJeff Kirsher void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer);
330874aeea5SJeff Kirsher 
331874aeea5SJeff Kirsher /* Tests */
332874aeea5SJeff Kirsher struct efx_nic_register_test {
333874aeea5SJeff Kirsher 	unsigned address;
334874aeea5SJeff Kirsher 	efx_oword_t mask;
335874aeea5SJeff Kirsher };
336874aeea5SJeff Kirsher extern int efx_nic_test_registers(struct efx_nic *efx,
337874aeea5SJeff Kirsher 				  const struct efx_nic_register_test *regs,
338874aeea5SJeff Kirsher 				  size_t n_regs);
339874aeea5SJeff Kirsher 
340874aeea5SJeff Kirsher extern size_t efx_nic_get_regs_len(struct efx_nic *efx);
341874aeea5SJeff Kirsher extern void efx_nic_get_regs(struct efx_nic *efx, void *buf);
342874aeea5SJeff Kirsher 
343874aeea5SJeff Kirsher /**************************************************************************
344874aeea5SJeff Kirsher  *
345874aeea5SJeff Kirsher  * Falcon MAC stats
346874aeea5SJeff Kirsher  *
347874aeea5SJeff Kirsher  **************************************************************************
348874aeea5SJeff Kirsher  */
349874aeea5SJeff Kirsher 
350874aeea5SJeff Kirsher #define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
351874aeea5SJeff Kirsher #define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
352874aeea5SJeff Kirsher 
353874aeea5SJeff Kirsher /* Retrieve statistic from statistics block */
354874aeea5SJeff Kirsher #define FALCON_STAT(efx, falcon_stat, efx_stat) do {		\
355874aeea5SJeff Kirsher 	if (FALCON_STAT_WIDTH(falcon_stat) == 16)		\
356874aeea5SJeff Kirsher 		(efx)->mac_stats.efx_stat += le16_to_cpu(	\
357874aeea5SJeff Kirsher 			*((__force __le16 *)				\
358874aeea5SJeff Kirsher 			  (efx->stats_buffer.addr +		\
359874aeea5SJeff Kirsher 			   FALCON_STAT_OFFSET(falcon_stat))));	\
360874aeea5SJeff Kirsher 	else if (FALCON_STAT_WIDTH(falcon_stat) == 32)		\
361874aeea5SJeff Kirsher 		(efx)->mac_stats.efx_stat += le32_to_cpu(	\
362874aeea5SJeff Kirsher 			*((__force __le32 *)				\
363874aeea5SJeff Kirsher 			  (efx->stats_buffer.addr +		\
364874aeea5SJeff Kirsher 			   FALCON_STAT_OFFSET(falcon_stat))));	\
365874aeea5SJeff Kirsher 	else							\
366874aeea5SJeff Kirsher 		(efx)->mac_stats.efx_stat += le64_to_cpu(	\
367874aeea5SJeff Kirsher 			*((__force __le64 *)				\
368874aeea5SJeff Kirsher 			  (efx->stats_buffer.addr +		\
369874aeea5SJeff Kirsher 			   FALCON_STAT_OFFSET(falcon_stat))));	\
370874aeea5SJeff Kirsher 	} while (0)
371874aeea5SJeff Kirsher 
372874aeea5SJeff Kirsher #define FALCON_MAC_STATS_SIZE 0x100
373874aeea5SJeff Kirsher 
374874aeea5SJeff Kirsher #define MAC_DATA_LBN 0
375874aeea5SJeff Kirsher #define MAC_DATA_WIDTH 32
376874aeea5SJeff Kirsher 
37790893000SBen Hutchings extern void efx_generate_event(struct efx_nic *efx, unsigned int evq,
378874aeea5SJeff Kirsher 			       efx_qword_t *event);
379874aeea5SJeff Kirsher 
380874aeea5SJeff Kirsher extern void falcon_poll_xmac(struct efx_nic *efx);
381874aeea5SJeff Kirsher 
382874aeea5SJeff Kirsher #endif /* EFX_NIC_H */
383