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 /* NIC has two interlinked PCI functions for the same port. */ 39874aeea5SJeff Kirsher static inline bool efx_nic_is_dual_func(struct efx_nic *efx) 40874aeea5SJeff Kirsher { 41874aeea5SJeff Kirsher return efx_nic_rev(efx) < EFX_REV_FALCON_B0; 42874aeea5SJeff Kirsher } 43874aeea5SJeff Kirsher 44874aeea5SJeff Kirsher enum { 45874aeea5SJeff Kirsher PHY_TYPE_NONE = 0, 46874aeea5SJeff Kirsher PHY_TYPE_TXC43128 = 1, 47874aeea5SJeff Kirsher PHY_TYPE_88E1111 = 2, 48874aeea5SJeff Kirsher PHY_TYPE_SFX7101 = 3, 49874aeea5SJeff Kirsher PHY_TYPE_QT2022C2 = 4, 50874aeea5SJeff Kirsher PHY_TYPE_PM8358 = 6, 51874aeea5SJeff Kirsher PHY_TYPE_SFT9001A = 8, 52874aeea5SJeff Kirsher PHY_TYPE_QT2025C = 9, 53874aeea5SJeff Kirsher PHY_TYPE_SFT9001B = 10, 54874aeea5SJeff Kirsher }; 55874aeea5SJeff Kirsher 56874aeea5SJeff Kirsher #define FALCON_XMAC_LOOPBACKS \ 57874aeea5SJeff Kirsher ((1 << LOOPBACK_XGMII) | \ 58874aeea5SJeff Kirsher (1 << LOOPBACK_XGXS) | \ 59874aeea5SJeff Kirsher (1 << LOOPBACK_XAUI)) 60874aeea5SJeff Kirsher 61874aeea5SJeff Kirsher #define FALCON_GMAC_LOOPBACKS \ 62874aeea5SJeff Kirsher (1 << LOOPBACK_GMAC) 63874aeea5SJeff Kirsher 645b6262d0SBen Hutchings /* Alignment of PCIe DMA boundaries (4KB) */ 655b6262d0SBen Hutchings #define EFX_PAGE_SIZE 4096 665b6262d0SBen Hutchings /* Size and alignment of buffer table entries (same) */ 675b6262d0SBen Hutchings #define EFX_BUF_SIZE EFX_PAGE_SIZE 685b6262d0SBen Hutchings 69874aeea5SJeff Kirsher /** 70874aeea5SJeff Kirsher * struct falcon_board_type - board operations and type information 71874aeea5SJeff Kirsher * @id: Board type id, as found in NVRAM 72874aeea5SJeff Kirsher * @ref_model: Model number of Solarflare reference design 73874aeea5SJeff Kirsher * @gen_type: Generic board type description 74874aeea5SJeff Kirsher * @init: Allocate resources and initialise peripheral hardware 75874aeea5SJeff Kirsher * @init_phy: Do board-specific PHY initialisation 76874aeea5SJeff Kirsher * @fini: Shut down hardware and free resources 77874aeea5SJeff Kirsher * @set_id_led: Set state of identifying LED or revert to automatic function 78874aeea5SJeff Kirsher * @monitor: Board-specific health check function 79874aeea5SJeff Kirsher */ 80874aeea5SJeff Kirsher struct falcon_board_type { 81874aeea5SJeff Kirsher u8 id; 82874aeea5SJeff Kirsher const char *ref_model; 83874aeea5SJeff Kirsher const char *gen_type; 84874aeea5SJeff Kirsher int (*init) (struct efx_nic *nic); 85874aeea5SJeff Kirsher void (*init_phy) (struct efx_nic *efx); 86874aeea5SJeff Kirsher void (*fini) (struct efx_nic *nic); 87874aeea5SJeff Kirsher void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode); 88874aeea5SJeff Kirsher int (*monitor) (struct efx_nic *nic); 89874aeea5SJeff Kirsher }; 90874aeea5SJeff Kirsher 91874aeea5SJeff Kirsher /** 92874aeea5SJeff Kirsher * struct falcon_board - board information 93874aeea5SJeff Kirsher * @type: Type of board 94874aeea5SJeff Kirsher * @major: Major rev. ('A', 'B' ...) 95874aeea5SJeff Kirsher * @minor: Minor rev. (0, 1, ...) 96874aeea5SJeff Kirsher * @i2c_adap: I2C adapter for on-board peripherals 97874aeea5SJeff Kirsher * @i2c_data: Data for bit-banging algorithm 98874aeea5SJeff Kirsher * @hwmon_client: I2C client for hardware monitor 99874aeea5SJeff Kirsher * @ioexp_client: I2C client for power/port control 100874aeea5SJeff Kirsher */ 101874aeea5SJeff Kirsher struct falcon_board { 102874aeea5SJeff Kirsher const struct falcon_board_type *type; 103874aeea5SJeff Kirsher int major; 104874aeea5SJeff Kirsher int minor; 105874aeea5SJeff Kirsher struct i2c_adapter i2c_adap; 106874aeea5SJeff Kirsher struct i2c_algo_bit_data i2c_data; 107874aeea5SJeff Kirsher struct i2c_client *hwmon_client, *ioexp_client; 108874aeea5SJeff Kirsher }; 109874aeea5SJeff Kirsher 110874aeea5SJeff Kirsher /** 111874aeea5SJeff Kirsher * struct falcon_nic_data - Falcon NIC state 112874aeea5SJeff Kirsher * @pci_dev2: Secondary function of Falcon A 113874aeea5SJeff Kirsher * @board: Board state and functions 114874aeea5SJeff Kirsher * @stats_disable_count: Nest count for disabling statistics fetches 115874aeea5SJeff Kirsher * @stats_pending: Is there a pending DMA of MAC statistics. 116874aeea5SJeff Kirsher * @stats_timer: A timer for regularly fetching MAC statistics. 117874aeea5SJeff Kirsher * @stats_dma_done: Pointer to the flag which indicates DMA completion. 118874aeea5SJeff Kirsher * @spi_flash: SPI flash device 119874aeea5SJeff Kirsher * @spi_eeprom: SPI EEPROM device 120874aeea5SJeff Kirsher * @spi_lock: SPI bus lock 121874aeea5SJeff Kirsher * @mdio_lock: MDIO bus lock 122874aeea5SJeff Kirsher * @xmac_poll_required: XMAC link state needs polling 123874aeea5SJeff Kirsher */ 124874aeea5SJeff Kirsher struct falcon_nic_data { 125874aeea5SJeff Kirsher struct pci_dev *pci_dev2; 126874aeea5SJeff Kirsher struct falcon_board board; 127874aeea5SJeff Kirsher unsigned int stats_disable_count; 128874aeea5SJeff Kirsher bool stats_pending; 129874aeea5SJeff Kirsher struct timer_list stats_timer; 130874aeea5SJeff Kirsher u32 *stats_dma_done; 131874aeea5SJeff Kirsher struct efx_spi_device spi_flash; 132874aeea5SJeff Kirsher struct efx_spi_device spi_eeprom; 133874aeea5SJeff Kirsher struct mutex spi_lock; 134874aeea5SJeff Kirsher struct mutex mdio_lock; 135874aeea5SJeff Kirsher bool xmac_poll_required; 136874aeea5SJeff Kirsher }; 137874aeea5SJeff Kirsher 138874aeea5SJeff Kirsher static inline struct falcon_board *falcon_board(struct efx_nic *efx) 139874aeea5SJeff Kirsher { 140874aeea5SJeff Kirsher struct falcon_nic_data *data = efx->nic_data; 141874aeea5SJeff Kirsher return &data->board; 142874aeea5SJeff Kirsher } 143874aeea5SJeff Kirsher 144874aeea5SJeff Kirsher /** 145874aeea5SJeff Kirsher * struct siena_nic_data - Siena NIC state 146874aeea5SJeff Kirsher * @mcdi: Management-Controller-to-Driver Interface 147874aeea5SJeff Kirsher * @wol_filter_id: Wake-on-LAN packet filter id 14855c5e0f8SBen Hutchings * @hwmon: Hardware monitor state 149874aeea5SJeff Kirsher */ 150874aeea5SJeff Kirsher struct siena_nic_data { 151874aeea5SJeff Kirsher struct efx_mcdi_iface mcdi; 152874aeea5SJeff Kirsher int wol_filter_id; 15355c5e0f8SBen Hutchings #ifdef CONFIG_SFC_MCDI_MON 15455c5e0f8SBen Hutchings struct efx_mcdi_mon hwmon; 15555c5e0f8SBen Hutchings #endif 156874aeea5SJeff Kirsher }; 157874aeea5SJeff Kirsher 15855c5e0f8SBen Hutchings #ifdef CONFIG_SFC_MCDI_MON 15955c5e0f8SBen Hutchings static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx) 16055c5e0f8SBen Hutchings { 16155c5e0f8SBen Hutchings struct siena_nic_data *nic_data; 16255c5e0f8SBen Hutchings EFX_BUG_ON_PARANOID(efx_nic_rev(efx) < EFX_REV_SIENA_A0); 16355c5e0f8SBen Hutchings nic_data = efx->nic_data; 16455c5e0f8SBen Hutchings return &nic_data->hwmon; 16555c5e0f8SBen Hutchings } 16655c5e0f8SBen Hutchings #endif 16755c5e0f8SBen Hutchings 168cd2d5b52SBen Hutchings /* 169cd2d5b52SBen Hutchings * On the SFC9000 family each port is associated with 1 PCI physical 170cd2d5b52SBen Hutchings * function (PF) handled by sfc and a configurable number of virtual 171cd2d5b52SBen Hutchings * functions (VFs) that may be handled by some other driver, often in 172cd2d5b52SBen Hutchings * a VM guest. The queue pointer registers are mapped in both PF and 173cd2d5b52SBen Hutchings * VF BARs such that an 8K region provides access to a single RX, TX 174cd2d5b52SBen Hutchings * and event queue (collectively a Virtual Interface, VI or VNIC). 175cd2d5b52SBen Hutchings * 176cd2d5b52SBen Hutchings * The PF has access to all 1024 VIs while VFs are mapped to VIs 177cd2d5b52SBen Hutchings * according to VI_BASE and VI_SCALE: VF i has access to VIs numbered 178cd2d5b52SBen Hutchings * in range [VI_BASE + i << VI_SCALE, VI_BASE + i + 1 << VI_SCALE). 179cd2d5b52SBen Hutchings * The number of VIs and the VI_SCALE value are configurable but must 180cd2d5b52SBen Hutchings * be established at boot time by firmware. 181cd2d5b52SBen Hutchings */ 182cd2d5b52SBen Hutchings 183cd2d5b52SBen Hutchings /* Maximum VI_SCALE parameter supported by Siena */ 184cd2d5b52SBen Hutchings #define EFX_VI_SCALE_MAX 6 185cd2d5b52SBen Hutchings /* Base VI to use for SR-IOV. Must be aligned to (1 << EFX_VI_SCALE_MAX), 186cd2d5b52SBen Hutchings * so this is the smallest allowed value. */ 187cd2d5b52SBen Hutchings #define EFX_VI_BASE 128U 188cd2d5b52SBen Hutchings /* Maximum number of VFs allowed */ 189cd2d5b52SBen Hutchings #define EFX_VF_COUNT_MAX 127 190cd2d5b52SBen Hutchings /* Limit EVQs on VFs to be only 8k to reduce buffer table reservation */ 191cd2d5b52SBen Hutchings #define EFX_MAX_VF_EVQ_SIZE 8192UL 192cd2d5b52SBen Hutchings /* The number of buffer table entries reserved for each VI on a VF */ 193cd2d5b52SBen Hutchings #define EFX_VF_BUFTBL_PER_VI \ 194cd2d5b52SBen Hutchings ((EFX_MAX_VF_EVQ_SIZE + 2 * EFX_MAX_DMAQ_SIZE) * \ 195cd2d5b52SBen Hutchings sizeof(efx_qword_t) / EFX_BUF_SIZE) 196cd2d5b52SBen Hutchings 197cd2d5b52SBen Hutchings #ifdef CONFIG_SFC_SRIOV 198cd2d5b52SBen Hutchings 199cd2d5b52SBen Hutchings static inline bool efx_sriov_wanted(struct efx_nic *efx) 200cd2d5b52SBen Hutchings { 201cd2d5b52SBen Hutchings return efx->vf_count != 0; 202cd2d5b52SBen Hutchings } 203cd2d5b52SBen Hutchings static inline bool efx_sriov_enabled(struct efx_nic *efx) 204cd2d5b52SBen Hutchings { 205cd2d5b52SBen Hutchings return efx->vf_init_count != 0; 206cd2d5b52SBen Hutchings } 207cd2d5b52SBen Hutchings static inline unsigned int efx_vf_size(struct efx_nic *efx) 208cd2d5b52SBen Hutchings { 209cd2d5b52SBen Hutchings return 1 << efx->vi_scale; 210cd2d5b52SBen Hutchings } 211cd2d5b52SBen Hutchings 212cd2d5b52SBen Hutchings extern int efx_init_sriov(void); 213cd2d5b52SBen Hutchings extern void efx_sriov_probe(struct efx_nic *efx); 214cd2d5b52SBen Hutchings extern int efx_sriov_init(struct efx_nic *efx); 215cd2d5b52SBen Hutchings extern void efx_sriov_mac_address_changed(struct efx_nic *efx); 216cd2d5b52SBen Hutchings extern void efx_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event); 217cd2d5b52SBen Hutchings extern void efx_sriov_rx_flush_done(struct efx_nic *efx, efx_qword_t *event); 218cd2d5b52SBen Hutchings extern void efx_sriov_event(struct efx_channel *channel, efx_qword_t *event); 219cd2d5b52SBen Hutchings extern void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq); 220cd2d5b52SBen Hutchings extern void efx_sriov_flr(struct efx_nic *efx, unsigned flr); 221cd2d5b52SBen Hutchings extern void efx_sriov_reset(struct efx_nic *efx); 222cd2d5b52SBen Hutchings extern void efx_sriov_fini(struct efx_nic *efx); 223cd2d5b52SBen Hutchings extern void efx_fini_sriov(void); 224cd2d5b52SBen Hutchings 225cd2d5b52SBen Hutchings #else 226cd2d5b52SBen Hutchings 227cd2d5b52SBen Hutchings static inline bool efx_sriov_wanted(struct efx_nic *efx) { return false; } 228cd2d5b52SBen Hutchings static inline bool efx_sriov_enabled(struct efx_nic *efx) { return false; } 229cd2d5b52SBen Hutchings static inline unsigned int efx_vf_size(struct efx_nic *efx) { return 0; } 230cd2d5b52SBen Hutchings 231cd2d5b52SBen Hutchings static inline int efx_init_sriov(void) { return 0; } 232cd2d5b52SBen Hutchings static inline void efx_sriov_probe(struct efx_nic *efx) {} 233cd2d5b52SBen Hutchings static inline int efx_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; } 234cd2d5b52SBen Hutchings static inline void efx_sriov_mac_address_changed(struct efx_nic *efx) {} 235cd2d5b52SBen Hutchings static inline void efx_sriov_tx_flush_done(struct efx_nic *efx, 236cd2d5b52SBen Hutchings efx_qword_t *event) {} 237cd2d5b52SBen Hutchings static inline void efx_sriov_rx_flush_done(struct efx_nic *efx, 238cd2d5b52SBen Hutchings efx_qword_t *event) {} 239cd2d5b52SBen Hutchings static inline void efx_sriov_event(struct efx_channel *channel, 240cd2d5b52SBen Hutchings efx_qword_t *event) {} 241cd2d5b52SBen Hutchings static inline void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq) {} 242cd2d5b52SBen Hutchings static inline void efx_sriov_flr(struct efx_nic *efx, unsigned flr) {} 243cd2d5b52SBen Hutchings static inline void efx_sriov_reset(struct efx_nic *efx) {} 244cd2d5b52SBen Hutchings static inline void efx_sriov_fini(struct efx_nic *efx) {} 245cd2d5b52SBen Hutchings static inline void efx_fini_sriov(void) {} 246cd2d5b52SBen Hutchings 247cd2d5b52SBen Hutchings #endif 248cd2d5b52SBen Hutchings 249cd2d5b52SBen Hutchings extern int efx_sriov_set_vf_mac(struct net_device *dev, int vf, u8 *mac); 250cd2d5b52SBen Hutchings extern int efx_sriov_set_vf_vlan(struct net_device *dev, int vf, 251cd2d5b52SBen Hutchings u16 vlan, u8 qos); 252cd2d5b52SBen Hutchings extern int efx_sriov_get_vf_config(struct net_device *dev, int vf, 253cd2d5b52SBen Hutchings struct ifla_vf_info *ivf); 254cd2d5b52SBen Hutchings extern int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf, 255cd2d5b52SBen Hutchings bool spoofchk); 256cd2d5b52SBen Hutchings 257874aeea5SJeff Kirsher extern const struct efx_nic_type falcon_a1_nic_type; 258874aeea5SJeff Kirsher extern const struct efx_nic_type falcon_b0_nic_type; 259874aeea5SJeff Kirsher extern const struct efx_nic_type siena_a0_nic_type; 260874aeea5SJeff Kirsher 261874aeea5SJeff Kirsher /************************************************************************** 262874aeea5SJeff Kirsher * 263874aeea5SJeff Kirsher * Externs 264874aeea5SJeff Kirsher * 265874aeea5SJeff Kirsher ************************************************************************** 266874aeea5SJeff Kirsher */ 267874aeea5SJeff Kirsher 268874aeea5SJeff Kirsher extern int falcon_probe_board(struct efx_nic *efx, u16 revision_info); 269874aeea5SJeff Kirsher 270874aeea5SJeff Kirsher /* TX data path */ 271874aeea5SJeff Kirsher extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue); 272874aeea5SJeff Kirsher extern void efx_nic_init_tx(struct efx_tx_queue *tx_queue); 273874aeea5SJeff Kirsher extern void efx_nic_fini_tx(struct efx_tx_queue *tx_queue); 274874aeea5SJeff Kirsher extern void efx_nic_remove_tx(struct efx_tx_queue *tx_queue); 275874aeea5SJeff Kirsher extern void efx_nic_push_buffers(struct efx_tx_queue *tx_queue); 276874aeea5SJeff Kirsher 277874aeea5SJeff Kirsher /* RX data path */ 278874aeea5SJeff Kirsher extern int efx_nic_probe_rx(struct efx_rx_queue *rx_queue); 279874aeea5SJeff Kirsher extern void efx_nic_init_rx(struct efx_rx_queue *rx_queue); 280874aeea5SJeff Kirsher extern void efx_nic_fini_rx(struct efx_rx_queue *rx_queue); 281874aeea5SJeff Kirsher extern void efx_nic_remove_rx(struct efx_rx_queue *rx_queue); 282874aeea5SJeff Kirsher extern void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue); 2832ae75dacSBen Hutchings extern void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue); 284874aeea5SJeff Kirsher 285874aeea5SJeff Kirsher /* Event data path */ 286874aeea5SJeff Kirsher extern int efx_nic_probe_eventq(struct efx_channel *channel); 287874aeea5SJeff Kirsher extern void efx_nic_init_eventq(struct efx_channel *channel); 288874aeea5SJeff Kirsher extern void efx_nic_fini_eventq(struct efx_channel *channel); 289874aeea5SJeff Kirsher extern void efx_nic_remove_eventq(struct efx_channel *channel); 290874aeea5SJeff Kirsher extern int efx_nic_process_eventq(struct efx_channel *channel, int rx_quota); 291874aeea5SJeff Kirsher extern void efx_nic_eventq_read_ack(struct efx_channel *channel); 292874aeea5SJeff Kirsher extern bool efx_nic_event_present(struct efx_channel *channel); 293874aeea5SJeff Kirsher 294874aeea5SJeff Kirsher /* MAC/PHY */ 295874aeea5SJeff Kirsher extern void falcon_drain_tx_fifo(struct efx_nic *efx); 296874aeea5SJeff Kirsher extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx); 297710b208dSBen Hutchings extern bool falcon_xmac_check_fault(struct efx_nic *efx); 298710b208dSBen Hutchings extern int falcon_reconfigure_xmac(struct efx_nic *efx); 299710b208dSBen Hutchings extern void falcon_update_stats_xmac(struct efx_nic *efx); 300874aeea5SJeff Kirsher 301874aeea5SJeff Kirsher /* Interrupts and test events */ 302874aeea5SJeff Kirsher extern int efx_nic_init_interrupt(struct efx_nic *efx); 303874aeea5SJeff Kirsher extern void efx_nic_enable_interrupts(struct efx_nic *efx); 304eee6f6a9SBen Hutchings extern void efx_nic_event_test_start(struct efx_channel *channel); 305eee6f6a9SBen Hutchings extern void efx_nic_irq_test_start(struct efx_nic *efx); 306874aeea5SJeff Kirsher extern void efx_nic_disable_interrupts(struct efx_nic *efx); 307874aeea5SJeff Kirsher extern void efx_nic_fini_interrupt(struct efx_nic *efx); 308874aeea5SJeff Kirsher extern irqreturn_t efx_nic_fatal_interrupt(struct efx_nic *efx); 309874aeea5SJeff Kirsher extern irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id); 310874aeea5SJeff Kirsher extern void falcon_irq_ack_a1(struct efx_nic *efx); 311874aeea5SJeff Kirsher 312eee6f6a9SBen Hutchings static inline int efx_nic_event_test_irq_cpu(struct efx_channel *channel) 313eee6f6a9SBen Hutchings { 314dd40781eSBen Hutchings return ACCESS_ONCE(channel->event_test_cpu); 315eee6f6a9SBen Hutchings } 316eee6f6a9SBen Hutchings static inline int efx_nic_irq_test_irq_cpu(struct efx_nic *efx) 317eee6f6a9SBen Hutchings { 318eee6f6a9SBen Hutchings return ACCESS_ONCE(efx->last_irq_cpu); 319eee6f6a9SBen Hutchings } 320eee6f6a9SBen Hutchings 321874aeea5SJeff Kirsher /* Global Resources */ 322874aeea5SJeff Kirsher extern int efx_nic_flush_queues(struct efx_nic *efx); 323874aeea5SJeff Kirsher extern void falcon_start_nic_stats(struct efx_nic *efx); 324874aeea5SJeff Kirsher extern void falcon_stop_nic_stats(struct efx_nic *efx); 325874aeea5SJeff Kirsher extern void falcon_setup_xaui(struct efx_nic *efx); 326874aeea5SJeff Kirsher extern int falcon_reset_xaui(struct efx_nic *efx); 32728e47c49SBen Hutchings extern void 32828e47c49SBen Hutchings efx_nic_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw); 329874aeea5SJeff Kirsher extern void efx_nic_init_common(struct efx_nic *efx); 330874aeea5SJeff Kirsher extern void efx_nic_push_rx_indir_table(struct efx_nic *efx); 331874aeea5SJeff Kirsher 332874aeea5SJeff Kirsher int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer, 333874aeea5SJeff Kirsher unsigned int len); 334874aeea5SJeff Kirsher void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer); 335874aeea5SJeff Kirsher 336874aeea5SJeff Kirsher /* Tests */ 337874aeea5SJeff Kirsher struct efx_nic_register_test { 338874aeea5SJeff Kirsher unsigned address; 339874aeea5SJeff Kirsher efx_oword_t mask; 340874aeea5SJeff Kirsher }; 341874aeea5SJeff Kirsher extern int efx_nic_test_registers(struct efx_nic *efx, 342874aeea5SJeff Kirsher const struct efx_nic_register_test *regs, 343874aeea5SJeff Kirsher size_t n_regs); 344874aeea5SJeff Kirsher 345874aeea5SJeff Kirsher extern size_t efx_nic_get_regs_len(struct efx_nic *efx); 346874aeea5SJeff Kirsher extern void efx_nic_get_regs(struct efx_nic *efx, void *buf); 347874aeea5SJeff Kirsher 348874aeea5SJeff Kirsher /************************************************************************** 349874aeea5SJeff Kirsher * 350874aeea5SJeff Kirsher * Falcon MAC stats 351874aeea5SJeff Kirsher * 352874aeea5SJeff Kirsher ************************************************************************** 353874aeea5SJeff Kirsher */ 354874aeea5SJeff Kirsher 355874aeea5SJeff Kirsher #define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset) 356874aeea5SJeff Kirsher #define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH) 357874aeea5SJeff Kirsher 358874aeea5SJeff Kirsher /* Retrieve statistic from statistics block */ 359874aeea5SJeff Kirsher #define FALCON_STAT(efx, falcon_stat, efx_stat) do { \ 360874aeea5SJeff Kirsher if (FALCON_STAT_WIDTH(falcon_stat) == 16) \ 361874aeea5SJeff Kirsher (efx)->mac_stats.efx_stat += le16_to_cpu( \ 362874aeea5SJeff Kirsher *((__force __le16 *) \ 363874aeea5SJeff Kirsher (efx->stats_buffer.addr + \ 364874aeea5SJeff Kirsher FALCON_STAT_OFFSET(falcon_stat)))); \ 365874aeea5SJeff Kirsher else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \ 366874aeea5SJeff Kirsher (efx)->mac_stats.efx_stat += le32_to_cpu( \ 367874aeea5SJeff Kirsher *((__force __le32 *) \ 368874aeea5SJeff Kirsher (efx->stats_buffer.addr + \ 369874aeea5SJeff Kirsher FALCON_STAT_OFFSET(falcon_stat)))); \ 370874aeea5SJeff Kirsher else \ 371874aeea5SJeff Kirsher (efx)->mac_stats.efx_stat += le64_to_cpu( \ 372874aeea5SJeff Kirsher *((__force __le64 *) \ 373874aeea5SJeff Kirsher (efx->stats_buffer.addr + \ 374874aeea5SJeff Kirsher FALCON_STAT_OFFSET(falcon_stat)))); \ 375874aeea5SJeff Kirsher } while (0) 376874aeea5SJeff Kirsher 377874aeea5SJeff Kirsher #define FALCON_MAC_STATS_SIZE 0x100 378874aeea5SJeff Kirsher 379874aeea5SJeff Kirsher #define MAC_DATA_LBN 0 380874aeea5SJeff Kirsher #define MAC_DATA_WIDTH 32 381874aeea5SJeff Kirsher 38290893000SBen Hutchings extern void efx_generate_event(struct efx_nic *efx, unsigned int evq, 383874aeea5SJeff Kirsher efx_qword_t *event); 384874aeea5SJeff Kirsher 385874aeea5SJeff Kirsher extern void falcon_poll_xmac(struct efx_nic *efx); 386874aeea5SJeff Kirsher 387874aeea5SJeff Kirsher #endif /* EFX_NIC_H */ 388