1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2874aeea5SJeff Kirsher /**************************************************************************** 3f7a6d2c4SBen Hutchings * Driver for Solarflare network controllers and boards 4874aeea5SJeff Kirsher * Copyright 2005-2006 Fen Systems Ltd. 5f7a6d2c4SBen Hutchings * Copyright 2006-2013 Solarflare Communications Inc. 6874aeea5SJeff Kirsher */ 7874aeea5SJeff Kirsher 8874aeea5SJeff Kirsher #ifndef EFX_NIC_H 9874aeea5SJeff Kirsher #define EFX_NIC_H 10874aeea5SJeff Kirsher 117c236c43SStuart Hodgson #include <linux/net_tstamp.h> 12874aeea5SJeff Kirsher #include "net_driver.h" 13874aeea5SJeff Kirsher #include "efx.h" 14e1253f39SAlex Maftei (amaftei) #include "efx_common.h" 15874aeea5SJeff Kirsher #include "mcdi.h" 16874aeea5SJeff Kirsher 17874aeea5SJeff Kirsher enum { 1842e6cae1SBert Kenward /* Revisions 0-2 were Falcon A0, A1 and B0 respectively. 1942e6cae1SBert Kenward * They are not supported by this driver but these revision numbers 2042e6cae1SBert Kenward * form part of the ethtool API for register dumping. 2142e6cae1SBert Kenward */ 2242e6cae1SBert Kenward EFX_REV_SIENA_A0 = 3, 2342e6cae1SBert Kenward EFX_REV_HUNT_A0 = 4, 24874aeea5SJeff Kirsher }; 25874aeea5SJeff Kirsher 26874aeea5SJeff Kirsher static inline int efx_nic_rev(struct efx_nic *efx) 27874aeea5SJeff Kirsher { 28874aeea5SJeff Kirsher return efx->type->revision; 29874aeea5SJeff Kirsher } 30874aeea5SJeff Kirsher 3100aef986SJoe Perches u32 efx_farch_fpga_ver(struct efx_nic *efx); 32874aeea5SJeff Kirsher 3386094f7fSBen Hutchings /* Read the current event from the event queue */ 3486094f7fSBen Hutchings static inline efx_qword_t *efx_event(struct efx_channel *channel, 3586094f7fSBen Hutchings unsigned int index) 3686094f7fSBen Hutchings { 3786094f7fSBen Hutchings return ((efx_qword_t *) (channel->eventq.buf.addr)) + 3886094f7fSBen Hutchings (index & channel->eventq_mask); 3986094f7fSBen Hutchings } 4086094f7fSBen Hutchings 4186094f7fSBen Hutchings /* See if an event is present 4286094f7fSBen Hutchings * 4386094f7fSBen Hutchings * We check both the high and low dword of the event for all ones. We 4486094f7fSBen Hutchings * wrote all ones when we cleared the event, and no valid event can 4586094f7fSBen Hutchings * have all ones in either its high or low dwords. This approach is 4686094f7fSBen Hutchings * robust against reordering. 4786094f7fSBen Hutchings * 4886094f7fSBen Hutchings * Note that using a single 64-bit comparison is incorrect; even 4986094f7fSBen Hutchings * though the CPU read will be atomic, the DMA write may not be. 5086094f7fSBen Hutchings */ 5186094f7fSBen Hutchings static inline int efx_event_present(efx_qword_t *event) 5286094f7fSBen Hutchings { 5386094f7fSBen Hutchings return !(EFX_DWORD_IS_ALL_ONES(event->dword[0]) | 5486094f7fSBen Hutchings EFX_DWORD_IS_ALL_ONES(event->dword[1])); 5586094f7fSBen Hutchings } 5686094f7fSBen Hutchings 5786094f7fSBen Hutchings /* Returns a pointer to the specified transmit descriptor in the TX 5886094f7fSBen Hutchings * descriptor queue belonging to the specified channel. 5986094f7fSBen Hutchings */ 6086094f7fSBen Hutchings static inline efx_qword_t * 6186094f7fSBen Hutchings efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index) 6286094f7fSBen Hutchings { 6386094f7fSBen Hutchings return ((efx_qword_t *) (tx_queue->txd.buf.addr)) + index; 6486094f7fSBen Hutchings } 6586094f7fSBen Hutchings 6670b33fb0SEdward Cree /* Get partner of a TX queue, seen as part of the same net core queue */ 6770b33fb0SEdward Cree static struct efx_tx_queue *efx_tx_queue_partner(struct efx_tx_queue *tx_queue) 6870b33fb0SEdward Cree { 6970b33fb0SEdward Cree if (tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD) 7070b33fb0SEdward Cree return tx_queue - EFX_TXQ_TYPE_OFFLOAD; 7170b33fb0SEdward Cree else 7270b33fb0SEdward Cree return tx_queue + EFX_TXQ_TYPE_OFFLOAD; 7370b33fb0SEdward Cree } 7470b33fb0SEdward Cree 7570b33fb0SEdward Cree /* Report whether this TX queue would be empty for the given write_count. 7670b33fb0SEdward Cree * May return false negative. 77306a2782SBen Hutchings */ 78306a2782SBen Hutchings static inline bool __efx_nic_tx_is_empty(struct efx_tx_queue *tx_queue, 79306a2782SBen Hutchings unsigned int write_count) 80306a2782SBen Hutchings { 816aa7de05SMark Rutland unsigned int empty_read_count = READ_ONCE(tx_queue->empty_read_count); 82306a2782SBen Hutchings 83306a2782SBen Hutchings if (empty_read_count == 0) 84306a2782SBen Hutchings return false; 85306a2782SBen Hutchings 86306a2782SBen Hutchings return ((empty_read_count ^ write_count) & ~EFX_EMPTY_COUNT_VALID) == 0; 87306a2782SBen Hutchings } 88306a2782SBen Hutchings 89de1deff9SEdward Cree /* Report whether the NIC considers this TX queue empty, using 90de1deff9SEdward Cree * packet_write_count (the write count recorded for the last completable 91de1deff9SEdward Cree * doorbell push). May return false negative. EF10 only, which is OK 92de1deff9SEdward Cree * because only EF10 supports PIO. 93de1deff9SEdward Cree */ 94de1deff9SEdward Cree static inline bool efx_nic_tx_is_empty(struct efx_tx_queue *tx_queue) 95de1deff9SEdward Cree { 96de1deff9SEdward Cree EFX_WARN_ON_ONCE_PARANOID(!tx_queue->efx->type->option_descriptors); 97de1deff9SEdward Cree return __efx_nic_tx_is_empty(tx_queue, tx_queue->packet_write_count); 98de1deff9SEdward Cree } 99de1deff9SEdward Cree 10070b33fb0SEdward Cree /* Decide whether we can use TX PIO, ie. write packet data directly into 10170b33fb0SEdward Cree * a buffer on the device. This can reduce latency at the expense of 10270b33fb0SEdward Cree * throughput, so we only do this if both hardware and software TX rings 10370b33fb0SEdward Cree * are empty. This also ensures that only one packet at a time can be 10470b33fb0SEdward Cree * using the PIO buffer. 10570b33fb0SEdward Cree */ 10670b33fb0SEdward Cree static inline bool efx_nic_may_tx_pio(struct efx_tx_queue *tx_queue) 107306a2782SBen Hutchings { 10870b33fb0SEdward Cree struct efx_tx_queue *partner = efx_tx_queue_partner(tx_queue); 109de1deff9SEdward Cree 110de1deff9SEdward Cree return tx_queue->piobuf && efx_nic_tx_is_empty(tx_queue) && 111de1deff9SEdward Cree efx_nic_tx_is_empty(partner); 112306a2782SBen Hutchings } 113306a2782SBen Hutchings 11486094f7fSBen Hutchings /* Decide whether to push a TX descriptor to the NIC vs merely writing 11586094f7fSBen Hutchings * the doorbell. This can reduce latency when we are adding a single 11686094f7fSBen Hutchings * descriptor to an empty queue, but is otherwise pointless. Further, 11786094f7fSBen Hutchings * Falcon and Siena have hardware bugs (SF bug 33851) that may be 11886094f7fSBen Hutchings * triggered if we don't check this. 11970b33fb0SEdward Cree * We use the write_count used for the last doorbell push, to get the 12070b33fb0SEdward Cree * NIC's view of the tx queue. 12186094f7fSBen Hutchings */ 12286094f7fSBen Hutchings static inline bool efx_nic_may_push_tx_desc(struct efx_tx_queue *tx_queue, 12386094f7fSBen Hutchings unsigned int write_count) 12486094f7fSBen Hutchings { 125306a2782SBen Hutchings bool was_empty = __efx_nic_tx_is_empty(tx_queue, write_count); 12686094f7fSBen Hutchings 12786094f7fSBen Hutchings tx_queue->empty_read_count = 0; 128306a2782SBen Hutchings return was_empty && tx_queue->write_count - write_count == 1; 12986094f7fSBen Hutchings } 13086094f7fSBen Hutchings 13186094f7fSBen Hutchings /* Returns a pointer to the specified descriptor in the RX descriptor queue */ 13286094f7fSBen Hutchings static inline efx_qword_t * 13386094f7fSBen Hutchings efx_rx_desc(struct efx_rx_queue *rx_queue, unsigned int index) 13486094f7fSBen Hutchings { 13586094f7fSBen Hutchings return ((efx_qword_t *) (rx_queue->rxd.buf.addr)) + index; 13686094f7fSBen Hutchings } 13786094f7fSBen Hutchings 138874aeea5SJeff Kirsher enum { 139874aeea5SJeff Kirsher PHY_TYPE_NONE = 0, 140874aeea5SJeff Kirsher PHY_TYPE_TXC43128 = 1, 141874aeea5SJeff Kirsher PHY_TYPE_88E1111 = 2, 142874aeea5SJeff Kirsher PHY_TYPE_SFX7101 = 3, 143874aeea5SJeff Kirsher PHY_TYPE_QT2022C2 = 4, 144874aeea5SJeff Kirsher PHY_TYPE_PM8358 = 6, 145874aeea5SJeff Kirsher PHY_TYPE_SFT9001A = 8, 146874aeea5SJeff Kirsher PHY_TYPE_QT2025C = 9, 147874aeea5SJeff Kirsher PHY_TYPE_SFT9001B = 10, 148874aeea5SJeff Kirsher }; 149874aeea5SJeff Kirsher 1505b6262d0SBen Hutchings /* Alignment of PCIe DMA boundaries (4KB) */ 1515b6262d0SBen Hutchings #define EFX_PAGE_SIZE 4096 1525b6262d0SBen Hutchings /* Size and alignment of buffer table entries (same) */ 1535b6262d0SBen Hutchings #define EFX_BUF_SIZE EFX_PAGE_SIZE 1545b6262d0SBen Hutchings 155e4d112e4SEdward Cree /* NIC-generic software stats */ 156e4d112e4SEdward Cree enum { 157e4d112e4SEdward Cree GENERIC_STAT_rx_noskb_drops, 158e4d112e4SEdward Cree GENERIC_STAT_rx_nodesc_trunc, 159e4d112e4SEdward Cree GENERIC_STAT_COUNT 160e4d112e4SEdward Cree }; 161e4d112e4SEdward Cree 162cd0ecc9aSBen Hutchings enum { 163e4d112e4SEdward Cree SIENA_STAT_tx_bytes = GENERIC_STAT_COUNT, 164cd0ecc9aSBen Hutchings SIENA_STAT_tx_good_bytes, 165cd0ecc9aSBen Hutchings SIENA_STAT_tx_bad_bytes, 166cd0ecc9aSBen Hutchings SIENA_STAT_tx_packets, 167cd0ecc9aSBen Hutchings SIENA_STAT_tx_bad, 168cd0ecc9aSBen Hutchings SIENA_STAT_tx_pause, 169cd0ecc9aSBen Hutchings SIENA_STAT_tx_control, 170cd0ecc9aSBen Hutchings SIENA_STAT_tx_unicast, 171cd0ecc9aSBen Hutchings SIENA_STAT_tx_multicast, 172cd0ecc9aSBen Hutchings SIENA_STAT_tx_broadcast, 173cd0ecc9aSBen Hutchings SIENA_STAT_tx_lt64, 174cd0ecc9aSBen Hutchings SIENA_STAT_tx_64, 175cd0ecc9aSBen Hutchings SIENA_STAT_tx_65_to_127, 176cd0ecc9aSBen Hutchings SIENA_STAT_tx_128_to_255, 177cd0ecc9aSBen Hutchings SIENA_STAT_tx_256_to_511, 178cd0ecc9aSBen Hutchings SIENA_STAT_tx_512_to_1023, 179cd0ecc9aSBen Hutchings SIENA_STAT_tx_1024_to_15xx, 180cd0ecc9aSBen Hutchings SIENA_STAT_tx_15xx_to_jumbo, 181cd0ecc9aSBen Hutchings SIENA_STAT_tx_gtjumbo, 182cd0ecc9aSBen Hutchings SIENA_STAT_tx_collision, 183cd0ecc9aSBen Hutchings SIENA_STAT_tx_single_collision, 184cd0ecc9aSBen Hutchings SIENA_STAT_tx_multiple_collision, 185cd0ecc9aSBen Hutchings SIENA_STAT_tx_excessive_collision, 186cd0ecc9aSBen Hutchings SIENA_STAT_tx_deferred, 187cd0ecc9aSBen Hutchings SIENA_STAT_tx_late_collision, 188cd0ecc9aSBen Hutchings SIENA_STAT_tx_excessive_deferred, 189cd0ecc9aSBen Hutchings SIENA_STAT_tx_non_tcpudp, 190cd0ecc9aSBen Hutchings SIENA_STAT_tx_mac_src_error, 191cd0ecc9aSBen Hutchings SIENA_STAT_tx_ip_src_error, 192cd0ecc9aSBen Hutchings SIENA_STAT_rx_bytes, 193cd0ecc9aSBen Hutchings SIENA_STAT_rx_good_bytes, 194cd0ecc9aSBen Hutchings SIENA_STAT_rx_bad_bytes, 195cd0ecc9aSBen Hutchings SIENA_STAT_rx_packets, 196cd0ecc9aSBen Hutchings SIENA_STAT_rx_good, 197cd0ecc9aSBen Hutchings SIENA_STAT_rx_bad, 198cd0ecc9aSBen Hutchings SIENA_STAT_rx_pause, 199cd0ecc9aSBen Hutchings SIENA_STAT_rx_control, 200cd0ecc9aSBen Hutchings SIENA_STAT_rx_unicast, 201cd0ecc9aSBen Hutchings SIENA_STAT_rx_multicast, 202cd0ecc9aSBen Hutchings SIENA_STAT_rx_broadcast, 203cd0ecc9aSBen Hutchings SIENA_STAT_rx_lt64, 204cd0ecc9aSBen Hutchings SIENA_STAT_rx_64, 205cd0ecc9aSBen Hutchings SIENA_STAT_rx_65_to_127, 206cd0ecc9aSBen Hutchings SIENA_STAT_rx_128_to_255, 207cd0ecc9aSBen Hutchings SIENA_STAT_rx_256_to_511, 208cd0ecc9aSBen Hutchings SIENA_STAT_rx_512_to_1023, 209cd0ecc9aSBen Hutchings SIENA_STAT_rx_1024_to_15xx, 210cd0ecc9aSBen Hutchings SIENA_STAT_rx_15xx_to_jumbo, 211cd0ecc9aSBen Hutchings SIENA_STAT_rx_gtjumbo, 212cd0ecc9aSBen Hutchings SIENA_STAT_rx_bad_gtjumbo, 213cd0ecc9aSBen Hutchings SIENA_STAT_rx_overflow, 214cd0ecc9aSBen Hutchings SIENA_STAT_rx_false_carrier, 215cd0ecc9aSBen Hutchings SIENA_STAT_rx_symbol_error, 216cd0ecc9aSBen Hutchings SIENA_STAT_rx_align_error, 217cd0ecc9aSBen Hutchings SIENA_STAT_rx_length_error, 218cd0ecc9aSBen Hutchings SIENA_STAT_rx_internal_error, 219cd0ecc9aSBen Hutchings SIENA_STAT_rx_nodesc_drop_cnt, 220cd0ecc9aSBen Hutchings SIENA_STAT_COUNT 221cd0ecc9aSBen Hutchings }; 222cd0ecc9aSBen Hutchings 223874aeea5SJeff Kirsher /** 224874aeea5SJeff Kirsher * struct siena_nic_data - Siena NIC state 2252dc313ecSShradha Shah * @efx: Pointer back to main interface structure 226874aeea5SJeff Kirsher * @wol_filter_id: Wake-on-LAN packet filter id 227cd0ecc9aSBen Hutchings * @stats: Hardware statistics 228bf3d0156SDaniel Pieczko * @vf: Array of &struct siena_vf objects 2292dc313ecSShradha Shah * @vf_buftbl_base: The zeroth buffer table index used to back VF queues. 2302dc313ecSShradha Shah * @vfdi_status: Common VFDI status page to be dmad to VF address space. 2312dc313ecSShradha Shah * @local_addr_list: List of local addresses. Protected by %local_lock. 2322dc313ecSShradha Shah * @local_page_list: List of DMA addressable pages used to broadcast 2332dc313ecSShradha Shah * %local_addr_list. Protected by %local_lock. 2342dc313ecSShradha Shah * @local_lock: Mutex protecting %local_addr_list and %local_page_list. 2352dc313ecSShradha Shah * @peer_work: Work item to broadcast peer addresses to VMs. 236874aeea5SJeff Kirsher */ 237874aeea5SJeff Kirsher struct siena_nic_data { 2382dc313ecSShradha Shah struct efx_nic *efx; 239874aeea5SJeff Kirsher int wol_filter_id; 240cd0ecc9aSBen Hutchings u64 stats[SIENA_STAT_COUNT]; 2412dc313ecSShradha Shah #ifdef CONFIG_SFC_SRIOV 242bf3d0156SDaniel Pieczko struct siena_vf *vf; 2432dc313ecSShradha Shah struct efx_channel *vfdi_channel; 2442dc313ecSShradha Shah unsigned vf_buftbl_base; 2452dc313ecSShradha Shah struct efx_buffer vfdi_status; 2462dc313ecSShradha Shah struct list_head local_addr_list; 2472dc313ecSShradha Shah struct list_head local_page_list; 2482dc313ecSShradha Shah struct mutex local_lock; 2492dc313ecSShradha Shah struct work_struct peer_work; 2502dc313ecSShradha Shah #endif 251874aeea5SJeff Kirsher }; 252874aeea5SJeff Kirsher 2538127d661SBen Hutchings enum { 254e80ca013SDaniel Pieczko EF10_STAT_port_tx_bytes = GENERIC_STAT_COUNT, 255e80ca013SDaniel Pieczko EF10_STAT_port_tx_packets, 256e80ca013SDaniel Pieczko EF10_STAT_port_tx_pause, 257e80ca013SDaniel Pieczko EF10_STAT_port_tx_control, 258e80ca013SDaniel Pieczko EF10_STAT_port_tx_unicast, 259e80ca013SDaniel Pieczko EF10_STAT_port_tx_multicast, 260e80ca013SDaniel Pieczko EF10_STAT_port_tx_broadcast, 261e80ca013SDaniel Pieczko EF10_STAT_port_tx_lt64, 262e80ca013SDaniel Pieczko EF10_STAT_port_tx_64, 263e80ca013SDaniel Pieczko EF10_STAT_port_tx_65_to_127, 264e80ca013SDaniel Pieczko EF10_STAT_port_tx_128_to_255, 265e80ca013SDaniel Pieczko EF10_STAT_port_tx_256_to_511, 266e80ca013SDaniel Pieczko EF10_STAT_port_tx_512_to_1023, 267e80ca013SDaniel Pieczko EF10_STAT_port_tx_1024_to_15xx, 268e80ca013SDaniel Pieczko EF10_STAT_port_tx_15xx_to_jumbo, 269e80ca013SDaniel Pieczko EF10_STAT_port_rx_bytes, 270e80ca013SDaniel Pieczko EF10_STAT_port_rx_bytes_minus_good_bytes, 271e80ca013SDaniel Pieczko EF10_STAT_port_rx_good_bytes, 272e80ca013SDaniel Pieczko EF10_STAT_port_rx_bad_bytes, 273e80ca013SDaniel Pieczko EF10_STAT_port_rx_packets, 274e80ca013SDaniel Pieczko EF10_STAT_port_rx_good, 275e80ca013SDaniel Pieczko EF10_STAT_port_rx_bad, 276e80ca013SDaniel Pieczko EF10_STAT_port_rx_pause, 277e80ca013SDaniel Pieczko EF10_STAT_port_rx_control, 278e80ca013SDaniel Pieczko EF10_STAT_port_rx_unicast, 279e80ca013SDaniel Pieczko EF10_STAT_port_rx_multicast, 280e80ca013SDaniel Pieczko EF10_STAT_port_rx_broadcast, 281e80ca013SDaniel Pieczko EF10_STAT_port_rx_lt64, 282e80ca013SDaniel Pieczko EF10_STAT_port_rx_64, 283e80ca013SDaniel Pieczko EF10_STAT_port_rx_65_to_127, 284e80ca013SDaniel Pieczko EF10_STAT_port_rx_128_to_255, 285e80ca013SDaniel Pieczko EF10_STAT_port_rx_256_to_511, 286e80ca013SDaniel Pieczko EF10_STAT_port_rx_512_to_1023, 287e80ca013SDaniel Pieczko EF10_STAT_port_rx_1024_to_15xx, 288e80ca013SDaniel Pieczko EF10_STAT_port_rx_15xx_to_jumbo, 289e80ca013SDaniel Pieczko EF10_STAT_port_rx_gtjumbo, 290e80ca013SDaniel Pieczko EF10_STAT_port_rx_bad_gtjumbo, 291e80ca013SDaniel Pieczko EF10_STAT_port_rx_overflow, 292e80ca013SDaniel Pieczko EF10_STAT_port_rx_align_error, 293e80ca013SDaniel Pieczko EF10_STAT_port_rx_length_error, 294e80ca013SDaniel Pieczko EF10_STAT_port_rx_nodesc_drops, 295e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_trunc_bb_overflow, 296e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_discard_bb_overflow, 297e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_trunc_vfifo_full, 298e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_discard_vfifo_full, 299e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_trunc_qbb, 300e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_discard_qbb, 301e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_discard_mapping, 302e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_q_disabled_packets, 303e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_di_dropped_packets, 304e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_streaming_packets, 305e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_hlb_fetch, 306e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_hlb_wait, 3073c36a2adSDaniel Pieczko EF10_STAT_rx_unicast, 3083c36a2adSDaniel Pieczko EF10_STAT_rx_unicast_bytes, 3093c36a2adSDaniel Pieczko EF10_STAT_rx_multicast, 3103c36a2adSDaniel Pieczko EF10_STAT_rx_multicast_bytes, 3113c36a2adSDaniel Pieczko EF10_STAT_rx_broadcast, 3123c36a2adSDaniel Pieczko EF10_STAT_rx_broadcast_bytes, 3133c36a2adSDaniel Pieczko EF10_STAT_rx_bad, 3143c36a2adSDaniel Pieczko EF10_STAT_rx_bad_bytes, 3153c36a2adSDaniel Pieczko EF10_STAT_rx_overflow, 3163c36a2adSDaniel Pieczko EF10_STAT_tx_unicast, 3173c36a2adSDaniel Pieczko EF10_STAT_tx_unicast_bytes, 3183c36a2adSDaniel Pieczko EF10_STAT_tx_multicast, 3193c36a2adSDaniel Pieczko EF10_STAT_tx_multicast_bytes, 3203c36a2adSDaniel Pieczko EF10_STAT_tx_broadcast, 3213c36a2adSDaniel Pieczko EF10_STAT_tx_broadcast_bytes, 3223c36a2adSDaniel Pieczko EF10_STAT_tx_bad, 3233c36a2adSDaniel Pieczko EF10_STAT_tx_bad_bytes, 3243c36a2adSDaniel Pieczko EF10_STAT_tx_overflow, 325f411b54dSEdward Cree EF10_STAT_V1_COUNT, 326f411b54dSEdward Cree EF10_STAT_fec_uncorrected_errors = EF10_STAT_V1_COUNT, 327f411b54dSEdward Cree EF10_STAT_fec_corrected_errors, 328f411b54dSEdward Cree EF10_STAT_fec_corrected_symbols_lane0, 329f411b54dSEdward Cree EF10_STAT_fec_corrected_symbols_lane1, 330f411b54dSEdward Cree EF10_STAT_fec_corrected_symbols_lane2, 331f411b54dSEdward Cree EF10_STAT_fec_corrected_symbols_lane3, 3322c0b6ee8SBert Kenward EF10_STAT_ctpio_vi_busy_fallback, 3332c0b6ee8SBert Kenward EF10_STAT_ctpio_long_write_success, 3342c0b6ee8SBert Kenward EF10_STAT_ctpio_missing_dbell_fail, 3352c0b6ee8SBert Kenward EF10_STAT_ctpio_overflow_fail, 3362c0b6ee8SBert Kenward EF10_STAT_ctpio_underflow_fail, 3372c0b6ee8SBert Kenward EF10_STAT_ctpio_timeout_fail, 3382c0b6ee8SBert Kenward EF10_STAT_ctpio_noncontig_wr_fail, 3392c0b6ee8SBert Kenward EF10_STAT_ctpio_frm_clobber_fail, 3402c0b6ee8SBert Kenward EF10_STAT_ctpio_invalid_wr_fail, 3412c0b6ee8SBert Kenward EF10_STAT_ctpio_vi_clobber_fallback, 3422c0b6ee8SBert Kenward EF10_STAT_ctpio_unqualified_fallback, 3432c0b6ee8SBert Kenward EF10_STAT_ctpio_runt_fallback, 3442c0b6ee8SBert Kenward EF10_STAT_ctpio_success, 3452c0b6ee8SBert Kenward EF10_STAT_ctpio_fallback, 3462c0b6ee8SBert Kenward EF10_STAT_ctpio_poison, 3472c0b6ee8SBert Kenward EF10_STAT_ctpio_erase, 3488127d661SBen Hutchings EF10_STAT_COUNT 3498127d661SBen Hutchings }; 3508127d661SBen Hutchings 351183233beSBen Hutchings /* Maximum number of TX PIO buffers we may allocate to a function. 352183233beSBen Hutchings * This matches the total number of buffers on each SFC9100-family 353183233beSBen Hutchings * controller. 354183233beSBen Hutchings */ 355183233beSBen Hutchings #define EF10_TX_PIOBUF_COUNT 16 356183233beSBen Hutchings 3578127d661SBen Hutchings /** 3588127d661SBen Hutchings * struct efx_ef10_nic_data - EF10 architecture NIC state 3598127d661SBen Hutchings * @mcdi_buf: DMA buffer for MCDI 3608127d661SBen Hutchings * @warm_boot_count: Last seen MC warm boot count 3618127d661SBen Hutchings * @vi_base: Absolute index of first VI in this function 3628127d661SBen Hutchings * @n_allocated_vis: Number of VIs allocated to this function 363183233beSBen Hutchings * @n_piobufs: Number of PIO buffers allocated to this function 364183233beSBen Hutchings * @wc_membase: Base address of write-combining mapping of the memory BAR 365183233beSBen Hutchings * @pio_write_base: Base address for writing PIO buffers 366183233beSBen Hutchings * @pio_write_vi_base: Relative VI number for @pio_write_base 367183233beSBen Hutchings * @piobuf_handle: Handle of each PIO buffer allocated 368c634700fSEdward Cree * @piobuf_size: size of a single PIO buffer 369183233beSBen Hutchings * @must_restore_piobufs: Flag: PIO buffers have yet to be restored after MC 370183233beSBen Hutchings * reboot 371d3142c19SEdward Cree * @mc_stats: Scratch buffer for converting statistics to the kernel's format 3728127d661SBen Hutchings * @stats: Hardware statistics 3738127d661SBen Hutchings * @workaround_35388: Flag: firmware supports workaround for bug 35388 37446e612b0SDaniel Pieczko * @workaround_26807: Flag: firmware supports workaround for bug 26807 375539de7c5SBert Kenward * @workaround_61265: Flag: firmware supports workaround for bug 61265 376a915ccc9SBen Hutchings * @must_check_datapath_caps: Flag: @datapath_caps needs to be revalidated 377a915ccc9SBen Hutchings * after MC reboot 3788127d661SBen Hutchings * @datapath_caps: Capabilities of datapath firmware (FLAGS1 field of 3798127d661SBen Hutchings * %MC_CMD_GET_CAPABILITIES response) 380ca889a05SBert Kenward * @datapath_caps2: Further Capabilities of datapath firmware (FLAGS2 field of 381ca889a05SBert Kenward * %MC_CMD_GET_CAPABILITIES response) 3828d9f9dd4SDaniel Pieczko * @rx_dpcpu_fw_id: Firmware ID of the RxDPCPU 3838d9f9dd4SDaniel Pieczko * @tx_dpcpu_fw_id: Firmware ID of the TxDPCPU 3846d8aaaf6SDaniel Pieczko * @must_probe_vswitching: Flag: vswitching has yet to be setup after MC reboot 3851cd9ecbbSDaniel Pieczko * @pf_index: The number for this PF, or the parent PF if this is a VF 3863c5eb876SShradha Shah #ifdef CONFIG_SFC_SRIOV 3873c5eb876SShradha Shah * @vf: Pointer to VF data structure 3883c5eb876SShradha Shah #endif 38934813fe2SAndrew Rybchenko * @vport_mac: The MAC address on the vport, only for PFs; VFs will be zero 39034813fe2SAndrew Rybchenko * @vlan_list: List of VLANs added over the interface. Serialised by vlan_lock. 39134813fe2SAndrew Rybchenko * @vlan_lock: Lock to serialize access to vlan_list. 392e5fbd977SJon Cooper * @udp_tunnels: UDP tunnel port numbers and types. 393e5fbd977SJon Cooper * @udp_tunnels_dirty: flag indicating a reboot occurred while pushing 394e5fbd977SJon Cooper * @udp_tunnels to hardware and thus the push must be re-done. 395e5fbd977SJon Cooper * @udp_tunnels_lock: Serialises writes to @udp_tunnels and @udp_tunnels_dirty. 3968127d661SBen Hutchings */ 3978127d661SBen Hutchings struct efx_ef10_nic_data { 3988127d661SBen Hutchings struct efx_buffer mcdi_buf; 3998127d661SBen Hutchings u16 warm_boot_count; 4008127d661SBen Hutchings unsigned int vi_base; 4018127d661SBen Hutchings unsigned int n_allocated_vis; 402183233beSBen Hutchings unsigned int n_piobufs; 403183233beSBen Hutchings void __iomem *wc_membase, *pio_write_base; 404183233beSBen Hutchings unsigned int pio_write_vi_base; 405183233beSBen Hutchings unsigned int piobuf_handle[EF10_TX_PIOBUF_COUNT]; 406c634700fSEdward Cree u16 piobuf_size; 407183233beSBen Hutchings bool must_restore_piobufs; 408d3142c19SEdward Cree __le64 *mc_stats; 4098127d661SBen Hutchings u64 stats[EF10_STAT_COUNT]; 4108127d661SBen Hutchings bool workaround_35388; 41146e612b0SDaniel Pieczko bool workaround_26807; 412539de7c5SBert Kenward bool workaround_61265; 413a915ccc9SBen Hutchings bool must_check_datapath_caps; 4148127d661SBen Hutchings u32 datapath_caps; 415ca889a05SBert Kenward u32 datapath_caps2; 4168d9f9dd4SDaniel Pieczko unsigned int rx_dpcpu_fw_id; 4178d9f9dd4SDaniel Pieczko unsigned int tx_dpcpu_fw_id; 4186d8aaaf6SDaniel Pieczko bool must_probe_vswitching; 4191cd9ecbbSDaniel Pieczko unsigned int pf_index; 4201d051e00SShradha Shah u8 port_id[ETH_ALEN]; 4213c5eb876SShradha Shah #ifdef CONFIG_SFC_SRIOV 42288a37de6SShradha Shah unsigned int vf_index; 4233c5eb876SShradha Shah struct ef10_vf *vf; 4243c5eb876SShradha Shah #endif 4253c5eb876SShradha Shah u8 vport_mac[ETH_ALEN]; 42634813fe2SAndrew Rybchenko struct list_head vlan_list; 42734813fe2SAndrew Rybchenko struct mutex vlan_lock; 428e5fbd977SJon Cooper struct efx_udp_tunnel udp_tunnels[16]; 429e5fbd977SJon Cooper bool udp_tunnels_dirty; 430e5fbd977SJon Cooper struct mutex udp_tunnels_lock; 43150663fe1SMartin Habets u64 licensed_features; 4328127d661SBen Hutchings }; 4338127d661SBen Hutchings 43400aef986SJoe Perches int efx_init_sriov(void); 43500aef986SJoe Perches void efx_fini_sriov(void); 436cd2d5b52SBen Hutchings 4377c236c43SStuart Hodgson struct ethtool_ts_info; 438ac36baf8SBen Hutchings int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel); 439ac36baf8SBen Hutchings void efx_ptp_defer_probe_with_channel(struct efx_nic *efx); 440c1d0d339SMartin Habets struct efx_channel *efx_ptp_channel(struct efx_nic *efx); 441ac36baf8SBen Hutchings void efx_ptp_remove(struct efx_nic *efx); 442433dc9b3SBen Hutchings int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr); 443433dc9b3SBen Hutchings int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr); 44400aef986SJoe Perches void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info); 44500aef986SJoe Perches bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb); 4469ec06595SDaniel Pieczko int efx_ptp_get_mode(struct efx_nic *efx); 4479ec06595SDaniel Pieczko int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted, 4489ec06595SDaniel Pieczko unsigned int new_mode); 44900aef986SJoe Perches int efx_ptp_tx(struct efx_nic *efx, struct sk_buff *skb); 45000aef986SJoe Perches void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev); 45199691c4aSBen Hutchings size_t efx_ptp_describe_stats(struct efx_nic *efx, u8 *strings); 45299691c4aSBen Hutchings size_t efx_ptp_update_stats(struct efx_nic *efx, u64 *stats); 453bd9a265dSJon Cooper void efx_time_sync_event(struct efx_channel *channel, efx_qword_t *ev); 454bd9a265dSJon Cooper void __efx_rx_skb_attach_timestamp(struct efx_channel *channel, 455bd9a265dSJon Cooper struct sk_buff *skb); 456bd9a265dSJon Cooper static inline void efx_rx_skb_attach_timestamp(struct efx_channel *channel, 457bd9a265dSJon Cooper struct sk_buff *skb) 458bd9a265dSJon Cooper { 459bd9a265dSJon Cooper if (channel->sync_events_state == SYNC_EVENTS_VALID) 460bd9a265dSJon Cooper __efx_rx_skb_attach_timestamp(channel, skb); 461bd9a265dSJon Cooper } 4622ea4dc28SAlexandre Rames void efx_ptp_start_datapath(struct efx_nic *efx); 4632ea4dc28SAlexandre Rames void efx_ptp_stop_datapath(struct efx_nic *efx); 4649c3afb33SMartin Habets bool efx_ptp_use_mac_tx_timestamps(struct efx_nic *efx); 465b9b603d4SMartin Habets ktime_t efx_ptp_nic_to_kernel_time(struct efx_tx_queue *tx_queue); 4667c236c43SStuart Hodgson 467874aeea5SJeff Kirsher extern const struct efx_nic_type falcon_a1_nic_type; 468874aeea5SJeff Kirsher extern const struct efx_nic_type falcon_b0_nic_type; 469874aeea5SJeff Kirsher extern const struct efx_nic_type siena_a0_nic_type; 4708127d661SBen Hutchings extern const struct efx_nic_type efx_hunt_a0_nic_type; 47102246a7fSShradha Shah extern const struct efx_nic_type efx_hunt_a0_vf_nic_type; 472874aeea5SJeff Kirsher 473874aeea5SJeff Kirsher /************************************************************************** 474874aeea5SJeff Kirsher * 475874aeea5SJeff Kirsher * Externs 476874aeea5SJeff Kirsher * 477874aeea5SJeff Kirsher ************************************************************************** 478874aeea5SJeff Kirsher */ 479874aeea5SJeff Kirsher 48000aef986SJoe Perches int falcon_probe_board(struct efx_nic *efx, u16 revision_info); 481874aeea5SJeff Kirsher 482874aeea5SJeff Kirsher /* TX data path */ 48386094f7fSBen Hutchings static inline int efx_nic_probe_tx(struct efx_tx_queue *tx_queue) 48486094f7fSBen Hutchings { 48586094f7fSBen Hutchings return tx_queue->efx->type->tx_probe(tx_queue); 48686094f7fSBen Hutchings } 48786094f7fSBen Hutchings static inline void efx_nic_init_tx(struct efx_tx_queue *tx_queue) 48886094f7fSBen Hutchings { 48986094f7fSBen Hutchings tx_queue->efx->type->tx_init(tx_queue); 49086094f7fSBen Hutchings } 49186094f7fSBen Hutchings static inline void efx_nic_remove_tx(struct efx_tx_queue *tx_queue) 49286094f7fSBen Hutchings { 49386094f7fSBen Hutchings tx_queue->efx->type->tx_remove(tx_queue); 49486094f7fSBen Hutchings } 49586094f7fSBen Hutchings static inline void efx_nic_push_buffers(struct efx_tx_queue *tx_queue) 49686094f7fSBen Hutchings { 49786094f7fSBen Hutchings tx_queue->efx->type->tx_write(tx_queue); 49886094f7fSBen Hutchings } 499874aeea5SJeff Kirsher 500e1253f39SAlex Maftei (amaftei) int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue, struct sk_buff *skb, 501e1253f39SAlex Maftei (amaftei) bool *data_mapped); 502e1253f39SAlex Maftei (amaftei) 503874aeea5SJeff Kirsher /* RX data path */ 50486094f7fSBen Hutchings static inline int efx_nic_probe_rx(struct efx_rx_queue *rx_queue) 50586094f7fSBen Hutchings { 50686094f7fSBen Hutchings return rx_queue->efx->type->rx_probe(rx_queue); 50786094f7fSBen Hutchings } 50886094f7fSBen Hutchings static inline void efx_nic_init_rx(struct efx_rx_queue *rx_queue) 50986094f7fSBen Hutchings { 51086094f7fSBen Hutchings rx_queue->efx->type->rx_init(rx_queue); 51186094f7fSBen Hutchings } 51286094f7fSBen Hutchings static inline void efx_nic_remove_rx(struct efx_rx_queue *rx_queue) 51386094f7fSBen Hutchings { 51486094f7fSBen Hutchings rx_queue->efx->type->rx_remove(rx_queue); 51586094f7fSBen Hutchings } 51686094f7fSBen Hutchings static inline void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue) 51786094f7fSBen Hutchings { 51886094f7fSBen Hutchings rx_queue->efx->type->rx_write(rx_queue); 51986094f7fSBen Hutchings } 52086094f7fSBen Hutchings static inline void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue) 52186094f7fSBen Hutchings { 52286094f7fSBen Hutchings rx_queue->efx->type->rx_defer_refill(rx_queue); 52386094f7fSBen Hutchings } 524874aeea5SJeff Kirsher 525874aeea5SJeff Kirsher /* Event data path */ 52686094f7fSBen Hutchings static inline int efx_nic_probe_eventq(struct efx_channel *channel) 52786094f7fSBen Hutchings { 52886094f7fSBen Hutchings return channel->efx->type->ev_probe(channel); 52986094f7fSBen Hutchings } 530261e4d96SJon Cooper static inline int efx_nic_init_eventq(struct efx_channel *channel) 53186094f7fSBen Hutchings { 532261e4d96SJon Cooper return channel->efx->type->ev_init(channel); 53386094f7fSBen Hutchings } 53486094f7fSBen Hutchings static inline void efx_nic_fini_eventq(struct efx_channel *channel) 53586094f7fSBen Hutchings { 53686094f7fSBen Hutchings channel->efx->type->ev_fini(channel); 53786094f7fSBen Hutchings } 53886094f7fSBen Hutchings static inline void efx_nic_remove_eventq(struct efx_channel *channel) 53986094f7fSBen Hutchings { 54086094f7fSBen Hutchings channel->efx->type->ev_remove(channel); 54186094f7fSBen Hutchings } 54286094f7fSBen Hutchings static inline int 54386094f7fSBen Hutchings efx_nic_process_eventq(struct efx_channel *channel, int quota) 54486094f7fSBen Hutchings { 54586094f7fSBen Hutchings return channel->efx->type->ev_process(channel, quota); 54686094f7fSBen Hutchings } 54786094f7fSBen Hutchings static inline void efx_nic_eventq_read_ack(struct efx_channel *channel) 54886094f7fSBen Hutchings { 54986094f7fSBen Hutchings channel->efx->type->ev_read_ack(channel); 55086094f7fSBen Hutchings } 551e1253f39SAlex Maftei (amaftei) 55200aef986SJoe Perches void efx_nic_event_test_start(struct efx_channel *channel); 55386094f7fSBen Hutchings 55486094f7fSBen Hutchings /* Falcon/Siena queue operations */ 55500aef986SJoe Perches int efx_farch_tx_probe(struct efx_tx_queue *tx_queue); 55600aef986SJoe Perches void efx_farch_tx_init(struct efx_tx_queue *tx_queue); 55700aef986SJoe Perches void efx_farch_tx_fini(struct efx_tx_queue *tx_queue); 55800aef986SJoe Perches void efx_farch_tx_remove(struct efx_tx_queue *tx_queue); 55900aef986SJoe Perches void efx_farch_tx_write(struct efx_tx_queue *tx_queue); 560e9117e50SBert Kenward unsigned int efx_farch_tx_limit_len(struct efx_tx_queue *tx_queue, 561e9117e50SBert Kenward dma_addr_t dma_addr, unsigned int len); 56200aef986SJoe Perches int efx_farch_rx_probe(struct efx_rx_queue *rx_queue); 56300aef986SJoe Perches void efx_farch_rx_init(struct efx_rx_queue *rx_queue); 56400aef986SJoe Perches void efx_farch_rx_fini(struct efx_rx_queue *rx_queue); 56500aef986SJoe Perches void efx_farch_rx_remove(struct efx_rx_queue *rx_queue); 56600aef986SJoe Perches void efx_farch_rx_write(struct efx_rx_queue *rx_queue); 56700aef986SJoe Perches void efx_farch_rx_defer_refill(struct efx_rx_queue *rx_queue); 56800aef986SJoe Perches int efx_farch_ev_probe(struct efx_channel *channel); 56900aef986SJoe Perches int efx_farch_ev_init(struct efx_channel *channel); 57000aef986SJoe Perches void efx_farch_ev_fini(struct efx_channel *channel); 57100aef986SJoe Perches void efx_farch_ev_remove(struct efx_channel *channel); 57200aef986SJoe Perches int efx_farch_ev_process(struct efx_channel *channel, int quota); 57300aef986SJoe Perches void efx_farch_ev_read_ack(struct efx_channel *channel); 57400aef986SJoe Perches void efx_farch_ev_test_generate(struct efx_channel *channel); 57586094f7fSBen Hutchings 576add72477SBen Hutchings /* Falcon/Siena filter operations */ 57700aef986SJoe Perches int efx_farch_filter_table_probe(struct efx_nic *efx); 57800aef986SJoe Perches void efx_farch_filter_table_restore(struct efx_nic *efx); 57900aef986SJoe Perches void efx_farch_filter_table_remove(struct efx_nic *efx); 58000aef986SJoe Perches void efx_farch_filter_update_rx_scatter(struct efx_nic *efx); 58100aef986SJoe Perches s32 efx_farch_filter_insert(struct efx_nic *efx, struct efx_filter_spec *spec, 58200aef986SJoe Perches bool replace); 58300aef986SJoe Perches int efx_farch_filter_remove_safe(struct efx_nic *efx, 584add72477SBen Hutchings enum efx_filter_priority priority, 585add72477SBen Hutchings u32 filter_id); 58600aef986SJoe Perches int efx_farch_filter_get_safe(struct efx_nic *efx, 58700aef986SJoe Perches enum efx_filter_priority priority, u32 filter_id, 58800aef986SJoe Perches struct efx_filter_spec *); 589fbd79120SBen Hutchings int efx_farch_filter_clear_rx(struct efx_nic *efx, 590add72477SBen Hutchings enum efx_filter_priority priority); 59100aef986SJoe Perches u32 efx_farch_filter_count_rx_used(struct efx_nic *efx, 592add72477SBen Hutchings enum efx_filter_priority priority); 59300aef986SJoe Perches u32 efx_farch_filter_get_rx_id_limit(struct efx_nic *efx); 59400aef986SJoe Perches s32 efx_farch_filter_get_rx_ids(struct efx_nic *efx, 59500aef986SJoe Perches enum efx_filter_priority priority, u32 *buf, 59600aef986SJoe Perches u32 size); 597add72477SBen Hutchings #ifdef CONFIG_RFS_ACCEL 59800aef986SJoe Perches bool efx_farch_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id, 599add72477SBen Hutchings unsigned int index); 600add72477SBen Hutchings #endif 60100aef986SJoe Perches void efx_farch_filter_sync_rx_mode(struct efx_nic *efx); 602add72477SBen Hutchings 60300aef986SJoe Perches bool efx_nic_event_present(struct efx_channel *channel); 604874aeea5SJeff Kirsher 605b7f514afSBen Hutchings /* Some statistics are computed as A - B where A and B each increase 606b7f514afSBen Hutchings * linearly with some hardware counter(s) and the counters are read 607b7f514afSBen Hutchings * asynchronously. If the counters contributing to B are always read 608b7f514afSBen Hutchings * after those contributing to A, the computed value may be lower than 609b7f514afSBen Hutchings * the true value by some variable amount, and may decrease between 610b7f514afSBen Hutchings * subsequent computations. 611b7f514afSBen Hutchings * 612b7f514afSBen Hutchings * We should never allow statistics to decrease or to exceed the true 613b7f514afSBen Hutchings * value. Since the computed value will never be greater than the 614b7f514afSBen Hutchings * true value, we can achieve this by only storing the computed value 615b7f514afSBen Hutchings * when it increases. 616b7f514afSBen Hutchings */ 617b7f514afSBen Hutchings static inline void efx_update_diff_stat(u64 *stat, u64 diff) 618b7f514afSBen Hutchings { 619b7f514afSBen Hutchings if ((s64)(diff - *stat) > 0) 620b7f514afSBen Hutchings *stat = diff; 621b7f514afSBen Hutchings } 622b7f514afSBen Hutchings 62386094f7fSBen Hutchings /* Interrupts */ 62400aef986SJoe Perches int efx_nic_init_interrupt(struct efx_nic *efx); 625942e298eSJon Cooper int efx_nic_irq_test_start(struct efx_nic *efx); 62600aef986SJoe Perches void efx_nic_fini_interrupt(struct efx_nic *efx); 62786094f7fSBen Hutchings 62886094f7fSBen Hutchings /* Falcon/Siena interrupts */ 62900aef986SJoe Perches void efx_farch_irq_enable_master(struct efx_nic *efx); 630942e298eSJon Cooper int efx_farch_irq_test_generate(struct efx_nic *efx); 63100aef986SJoe Perches void efx_farch_irq_disable_master(struct efx_nic *efx); 63200aef986SJoe Perches irqreturn_t efx_farch_msi_interrupt(int irq, void *dev_id); 63300aef986SJoe Perches irqreturn_t efx_farch_legacy_interrupt(int irq, void *dev_id); 63400aef986SJoe Perches irqreturn_t efx_farch_fatal_interrupt(struct efx_nic *efx); 635874aeea5SJeff Kirsher 636eee6f6a9SBen Hutchings static inline int efx_nic_event_test_irq_cpu(struct efx_channel *channel) 637eee6f6a9SBen Hutchings { 6386aa7de05SMark Rutland return READ_ONCE(channel->event_test_cpu); 639eee6f6a9SBen Hutchings } 640eee6f6a9SBen Hutchings static inline int efx_nic_irq_test_irq_cpu(struct efx_nic *efx) 641eee6f6a9SBen Hutchings { 6426aa7de05SMark Rutland return READ_ONCE(efx->last_irq_cpu); 643eee6f6a9SBen Hutchings } 644eee6f6a9SBen Hutchings 645874aeea5SJeff Kirsher /* Global Resources */ 64600aef986SJoe Perches int efx_nic_flush_queues(struct efx_nic *efx); 64700aef986SJoe Perches void siena_prepare_flush(struct efx_nic *efx); 64800aef986SJoe Perches int efx_farch_fini_dmaq(struct efx_nic *efx); 649e283546cSEdward Cree void efx_farch_finish_flr(struct efx_nic *efx); 65000aef986SJoe Perches void siena_finish_flush(struct efx_nic *efx); 65100aef986SJoe Perches void falcon_start_nic_stats(struct efx_nic *efx); 65200aef986SJoe Perches void falcon_stop_nic_stats(struct efx_nic *efx); 65300aef986SJoe Perches int falcon_reset_xaui(struct efx_nic *efx); 65400aef986SJoe Perches void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw); 65500aef986SJoe Perches void efx_farch_init_common(struct efx_nic *efx); 65600aef986SJoe Perches void efx_ef10_handle_drain_event(struct efx_nic *efx); 65700aef986SJoe Perches void efx_farch_rx_push_indir_table(struct efx_nic *efx); 658a707d188SEdward Cree void efx_farch_rx_pull_indir_table(struct efx_nic *efx); 659874aeea5SJeff Kirsher 660874aeea5SJeff Kirsher int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer, 6610d19a540SBen Hutchings unsigned int len, gfp_t gfp_flags); 662874aeea5SJeff Kirsher void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer); 663874aeea5SJeff Kirsher 664874aeea5SJeff Kirsher /* Tests */ 66586094f7fSBen Hutchings struct efx_farch_register_test { 666874aeea5SJeff Kirsher unsigned address; 667874aeea5SJeff Kirsher efx_oword_t mask; 668874aeea5SJeff Kirsher }; 669e1253f39SAlex Maftei (amaftei) 67000aef986SJoe Perches int efx_farch_test_registers(struct efx_nic *efx, 67186094f7fSBen Hutchings const struct efx_farch_register_test *regs, 672874aeea5SJeff Kirsher size_t n_regs); 673874aeea5SJeff Kirsher 67400aef986SJoe Perches size_t efx_nic_get_regs_len(struct efx_nic *efx); 67500aef986SJoe Perches void efx_nic_get_regs(struct efx_nic *efx, void *buf); 676874aeea5SJeff Kirsher 67700aef986SJoe Perches size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count, 678cd0ecc9aSBen Hutchings const unsigned long *mask, u8 *names); 679d3142c19SEdward Cree int efx_nic_copy_stats(struct efx_nic *efx, __le64 *dest); 68000aef986SJoe Perches void efx_nic_update_stats(const struct efx_hw_stat_desc *desc, size_t count, 68100aef986SJoe Perches const unsigned long *mask, u64 *stats, 68200aef986SJoe Perches const void *dma_buf, bool accumulate); 683f8f3b5aeSJon Cooper void efx_nic_fix_nodesc_drop_stat(struct efx_nic *efx, u64 *stat); 684cd0ecc9aSBen Hutchings 685ab0115fcSBen Hutchings #define EFX_MAX_FLUSH_TIME 5000 686874aeea5SJeff Kirsher 68700aef986SJoe Perches void efx_farch_generate_event(struct efx_nic *efx, unsigned int evq, 688874aeea5SJeff Kirsher efx_qword_t *event); 689874aeea5SJeff Kirsher 690874aeea5SJeff Kirsher #endif /* EFX_NIC_H */ 691