1874aeea5SJeff Kirsher /**************************************************************************** 2f7a6d2c4SBen Hutchings * Driver for Solarflare network controllers and boards 3874aeea5SJeff Kirsher * Copyright 2005-2006 Fen Systems Ltd. 4f7a6d2c4SBen Hutchings * Copyright 2006-2013 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 147c236c43SStuart Hodgson #include <linux/net_tstamp.h> 15874aeea5SJeff Kirsher #include <linux/i2c-algo-bit.h> 16874aeea5SJeff Kirsher #include "net_driver.h" 17874aeea5SJeff Kirsher #include "efx.h" 18874aeea5SJeff Kirsher #include "mcdi.h" 19874aeea5SJeff Kirsher 20874aeea5SJeff Kirsher enum { 2142e6cae1SBert Kenward /* Revisions 0-2 were Falcon A0, A1 and B0 respectively. 2242e6cae1SBert Kenward * They are not supported by this driver but these revision numbers 2342e6cae1SBert Kenward * form part of the ethtool API for register dumping. 2442e6cae1SBert Kenward */ 2542e6cae1SBert Kenward EFX_REV_SIENA_A0 = 3, 2642e6cae1SBert Kenward EFX_REV_HUNT_A0 = 4, 27874aeea5SJeff Kirsher }; 28874aeea5SJeff Kirsher 29874aeea5SJeff Kirsher static inline int efx_nic_rev(struct efx_nic *efx) 30874aeea5SJeff Kirsher { 31874aeea5SJeff Kirsher return efx->type->revision; 32874aeea5SJeff Kirsher } 33874aeea5SJeff Kirsher 3400aef986SJoe Perches u32 efx_farch_fpga_ver(struct efx_nic *efx); 35874aeea5SJeff Kirsher 3686094f7fSBen Hutchings /* Read the current event from the event queue */ 3786094f7fSBen Hutchings static inline efx_qword_t *efx_event(struct efx_channel *channel, 3886094f7fSBen Hutchings unsigned int index) 3986094f7fSBen Hutchings { 4086094f7fSBen Hutchings return ((efx_qword_t *) (channel->eventq.buf.addr)) + 4186094f7fSBen Hutchings (index & channel->eventq_mask); 4286094f7fSBen Hutchings } 4386094f7fSBen Hutchings 4486094f7fSBen Hutchings /* See if an event is present 4586094f7fSBen Hutchings * 4686094f7fSBen Hutchings * We check both the high and low dword of the event for all ones. We 4786094f7fSBen Hutchings * wrote all ones when we cleared the event, and no valid event can 4886094f7fSBen Hutchings * have all ones in either its high or low dwords. This approach is 4986094f7fSBen Hutchings * robust against reordering. 5086094f7fSBen Hutchings * 5186094f7fSBen Hutchings * Note that using a single 64-bit comparison is incorrect; even 5286094f7fSBen Hutchings * though the CPU read will be atomic, the DMA write may not be. 5386094f7fSBen Hutchings */ 5486094f7fSBen Hutchings static inline int efx_event_present(efx_qword_t *event) 5586094f7fSBen Hutchings { 5686094f7fSBen Hutchings return !(EFX_DWORD_IS_ALL_ONES(event->dword[0]) | 5786094f7fSBen Hutchings EFX_DWORD_IS_ALL_ONES(event->dword[1])); 5886094f7fSBen Hutchings } 5986094f7fSBen Hutchings 6086094f7fSBen Hutchings /* Returns a pointer to the specified transmit descriptor in the TX 6186094f7fSBen Hutchings * descriptor queue belonging to the specified channel. 6286094f7fSBen Hutchings */ 6386094f7fSBen Hutchings static inline efx_qword_t * 6486094f7fSBen Hutchings efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index) 6586094f7fSBen Hutchings { 6686094f7fSBen Hutchings return ((efx_qword_t *) (tx_queue->txd.buf.addr)) + index; 6786094f7fSBen Hutchings } 6886094f7fSBen Hutchings 6970b33fb0SEdward Cree /* Get partner of a TX queue, seen as part of the same net core queue */ 7070b33fb0SEdward Cree static struct efx_tx_queue *efx_tx_queue_partner(struct efx_tx_queue *tx_queue) 7170b33fb0SEdward Cree { 7270b33fb0SEdward Cree if (tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD) 7370b33fb0SEdward Cree return tx_queue - EFX_TXQ_TYPE_OFFLOAD; 7470b33fb0SEdward Cree else 7570b33fb0SEdward Cree return tx_queue + EFX_TXQ_TYPE_OFFLOAD; 7670b33fb0SEdward Cree } 7770b33fb0SEdward Cree 7870b33fb0SEdward Cree /* Report whether this TX queue would be empty for the given write_count. 7970b33fb0SEdward Cree * May return false negative. 80306a2782SBen Hutchings */ 81306a2782SBen Hutchings static inline bool __efx_nic_tx_is_empty(struct efx_tx_queue *tx_queue, 82306a2782SBen Hutchings unsigned int write_count) 83306a2782SBen Hutchings { 846aa7de05SMark Rutland unsigned int empty_read_count = READ_ONCE(tx_queue->empty_read_count); 85306a2782SBen Hutchings 86306a2782SBen Hutchings if (empty_read_count == 0) 87306a2782SBen Hutchings return false; 88306a2782SBen Hutchings 89306a2782SBen Hutchings return ((empty_read_count ^ write_count) & ~EFX_EMPTY_COUNT_VALID) == 0; 90306a2782SBen Hutchings } 91306a2782SBen Hutchings 92de1deff9SEdward Cree /* Report whether the NIC considers this TX queue empty, using 93de1deff9SEdward Cree * packet_write_count (the write count recorded for the last completable 94de1deff9SEdward Cree * doorbell push). May return false negative. EF10 only, which is OK 95de1deff9SEdward Cree * because only EF10 supports PIO. 96de1deff9SEdward Cree */ 97de1deff9SEdward Cree static inline bool efx_nic_tx_is_empty(struct efx_tx_queue *tx_queue) 98de1deff9SEdward Cree { 99de1deff9SEdward Cree EFX_WARN_ON_ONCE_PARANOID(!tx_queue->efx->type->option_descriptors); 100de1deff9SEdward Cree return __efx_nic_tx_is_empty(tx_queue, tx_queue->packet_write_count); 101de1deff9SEdward Cree } 102de1deff9SEdward Cree 10370b33fb0SEdward Cree /* Decide whether we can use TX PIO, ie. write packet data directly into 10470b33fb0SEdward Cree * a buffer on the device. This can reduce latency at the expense of 10570b33fb0SEdward Cree * throughput, so we only do this if both hardware and software TX rings 10670b33fb0SEdward Cree * are empty. This also ensures that only one packet at a time can be 10770b33fb0SEdward Cree * using the PIO buffer. 10870b33fb0SEdward Cree */ 10970b33fb0SEdward Cree static inline bool efx_nic_may_tx_pio(struct efx_tx_queue *tx_queue) 110306a2782SBen Hutchings { 11170b33fb0SEdward Cree struct efx_tx_queue *partner = efx_tx_queue_partner(tx_queue); 112de1deff9SEdward Cree 113de1deff9SEdward Cree return tx_queue->piobuf && efx_nic_tx_is_empty(tx_queue) && 114de1deff9SEdward Cree efx_nic_tx_is_empty(partner); 115306a2782SBen Hutchings } 116306a2782SBen Hutchings 11786094f7fSBen Hutchings /* Decide whether to push a TX descriptor to the NIC vs merely writing 11886094f7fSBen Hutchings * the doorbell. This can reduce latency when we are adding a single 11986094f7fSBen Hutchings * descriptor to an empty queue, but is otherwise pointless. Further, 12086094f7fSBen Hutchings * Falcon and Siena have hardware bugs (SF bug 33851) that may be 12186094f7fSBen Hutchings * triggered if we don't check this. 12270b33fb0SEdward Cree * We use the write_count used for the last doorbell push, to get the 12370b33fb0SEdward Cree * NIC's view of the tx queue. 12486094f7fSBen Hutchings */ 12586094f7fSBen Hutchings static inline bool efx_nic_may_push_tx_desc(struct efx_tx_queue *tx_queue, 12686094f7fSBen Hutchings unsigned int write_count) 12786094f7fSBen Hutchings { 128306a2782SBen Hutchings bool was_empty = __efx_nic_tx_is_empty(tx_queue, write_count); 12986094f7fSBen Hutchings 13086094f7fSBen Hutchings tx_queue->empty_read_count = 0; 131306a2782SBen Hutchings return was_empty && tx_queue->write_count - write_count == 1; 13286094f7fSBen Hutchings } 13386094f7fSBen Hutchings 13486094f7fSBen Hutchings /* Returns a pointer to the specified descriptor in the RX descriptor queue */ 13586094f7fSBen Hutchings static inline efx_qword_t * 13686094f7fSBen Hutchings efx_rx_desc(struct efx_rx_queue *rx_queue, unsigned int index) 13786094f7fSBen Hutchings { 13886094f7fSBen Hutchings return ((efx_qword_t *) (rx_queue->rxd.buf.addr)) + index; 13986094f7fSBen Hutchings } 14086094f7fSBen Hutchings 141874aeea5SJeff Kirsher enum { 142874aeea5SJeff Kirsher PHY_TYPE_NONE = 0, 143874aeea5SJeff Kirsher PHY_TYPE_TXC43128 = 1, 144874aeea5SJeff Kirsher PHY_TYPE_88E1111 = 2, 145874aeea5SJeff Kirsher PHY_TYPE_SFX7101 = 3, 146874aeea5SJeff Kirsher PHY_TYPE_QT2022C2 = 4, 147874aeea5SJeff Kirsher PHY_TYPE_PM8358 = 6, 148874aeea5SJeff Kirsher PHY_TYPE_SFT9001A = 8, 149874aeea5SJeff Kirsher PHY_TYPE_QT2025C = 9, 150874aeea5SJeff Kirsher PHY_TYPE_SFT9001B = 10, 151874aeea5SJeff Kirsher }; 152874aeea5SJeff Kirsher 1535b6262d0SBen Hutchings /* Alignment of PCIe DMA boundaries (4KB) */ 1545b6262d0SBen Hutchings #define EFX_PAGE_SIZE 4096 1555b6262d0SBen Hutchings /* Size and alignment of buffer table entries (same) */ 1565b6262d0SBen Hutchings #define EFX_BUF_SIZE EFX_PAGE_SIZE 1575b6262d0SBen Hutchings 158e4d112e4SEdward Cree /* NIC-generic software stats */ 159e4d112e4SEdward Cree enum { 160e4d112e4SEdward Cree GENERIC_STAT_rx_noskb_drops, 161e4d112e4SEdward Cree GENERIC_STAT_rx_nodesc_trunc, 162e4d112e4SEdward Cree GENERIC_STAT_COUNT 163e4d112e4SEdward Cree }; 164e4d112e4SEdward Cree 165cd0ecc9aSBen Hutchings enum { 166e4d112e4SEdward Cree SIENA_STAT_tx_bytes = GENERIC_STAT_COUNT, 167cd0ecc9aSBen Hutchings SIENA_STAT_tx_good_bytes, 168cd0ecc9aSBen Hutchings SIENA_STAT_tx_bad_bytes, 169cd0ecc9aSBen Hutchings SIENA_STAT_tx_packets, 170cd0ecc9aSBen Hutchings SIENA_STAT_tx_bad, 171cd0ecc9aSBen Hutchings SIENA_STAT_tx_pause, 172cd0ecc9aSBen Hutchings SIENA_STAT_tx_control, 173cd0ecc9aSBen Hutchings SIENA_STAT_tx_unicast, 174cd0ecc9aSBen Hutchings SIENA_STAT_tx_multicast, 175cd0ecc9aSBen Hutchings SIENA_STAT_tx_broadcast, 176cd0ecc9aSBen Hutchings SIENA_STAT_tx_lt64, 177cd0ecc9aSBen Hutchings SIENA_STAT_tx_64, 178cd0ecc9aSBen Hutchings SIENA_STAT_tx_65_to_127, 179cd0ecc9aSBen Hutchings SIENA_STAT_tx_128_to_255, 180cd0ecc9aSBen Hutchings SIENA_STAT_tx_256_to_511, 181cd0ecc9aSBen Hutchings SIENA_STAT_tx_512_to_1023, 182cd0ecc9aSBen Hutchings SIENA_STAT_tx_1024_to_15xx, 183cd0ecc9aSBen Hutchings SIENA_STAT_tx_15xx_to_jumbo, 184cd0ecc9aSBen Hutchings SIENA_STAT_tx_gtjumbo, 185cd0ecc9aSBen Hutchings SIENA_STAT_tx_collision, 186cd0ecc9aSBen Hutchings SIENA_STAT_tx_single_collision, 187cd0ecc9aSBen Hutchings SIENA_STAT_tx_multiple_collision, 188cd0ecc9aSBen Hutchings SIENA_STAT_tx_excessive_collision, 189cd0ecc9aSBen Hutchings SIENA_STAT_tx_deferred, 190cd0ecc9aSBen Hutchings SIENA_STAT_tx_late_collision, 191cd0ecc9aSBen Hutchings SIENA_STAT_tx_excessive_deferred, 192cd0ecc9aSBen Hutchings SIENA_STAT_tx_non_tcpudp, 193cd0ecc9aSBen Hutchings SIENA_STAT_tx_mac_src_error, 194cd0ecc9aSBen Hutchings SIENA_STAT_tx_ip_src_error, 195cd0ecc9aSBen Hutchings SIENA_STAT_rx_bytes, 196cd0ecc9aSBen Hutchings SIENA_STAT_rx_good_bytes, 197cd0ecc9aSBen Hutchings SIENA_STAT_rx_bad_bytes, 198cd0ecc9aSBen Hutchings SIENA_STAT_rx_packets, 199cd0ecc9aSBen Hutchings SIENA_STAT_rx_good, 200cd0ecc9aSBen Hutchings SIENA_STAT_rx_bad, 201cd0ecc9aSBen Hutchings SIENA_STAT_rx_pause, 202cd0ecc9aSBen Hutchings SIENA_STAT_rx_control, 203cd0ecc9aSBen Hutchings SIENA_STAT_rx_unicast, 204cd0ecc9aSBen Hutchings SIENA_STAT_rx_multicast, 205cd0ecc9aSBen Hutchings SIENA_STAT_rx_broadcast, 206cd0ecc9aSBen Hutchings SIENA_STAT_rx_lt64, 207cd0ecc9aSBen Hutchings SIENA_STAT_rx_64, 208cd0ecc9aSBen Hutchings SIENA_STAT_rx_65_to_127, 209cd0ecc9aSBen Hutchings SIENA_STAT_rx_128_to_255, 210cd0ecc9aSBen Hutchings SIENA_STAT_rx_256_to_511, 211cd0ecc9aSBen Hutchings SIENA_STAT_rx_512_to_1023, 212cd0ecc9aSBen Hutchings SIENA_STAT_rx_1024_to_15xx, 213cd0ecc9aSBen Hutchings SIENA_STAT_rx_15xx_to_jumbo, 214cd0ecc9aSBen Hutchings SIENA_STAT_rx_gtjumbo, 215cd0ecc9aSBen Hutchings SIENA_STAT_rx_bad_gtjumbo, 216cd0ecc9aSBen Hutchings SIENA_STAT_rx_overflow, 217cd0ecc9aSBen Hutchings SIENA_STAT_rx_false_carrier, 218cd0ecc9aSBen Hutchings SIENA_STAT_rx_symbol_error, 219cd0ecc9aSBen Hutchings SIENA_STAT_rx_align_error, 220cd0ecc9aSBen Hutchings SIENA_STAT_rx_length_error, 221cd0ecc9aSBen Hutchings SIENA_STAT_rx_internal_error, 222cd0ecc9aSBen Hutchings SIENA_STAT_rx_nodesc_drop_cnt, 223cd0ecc9aSBen Hutchings SIENA_STAT_COUNT 224cd0ecc9aSBen Hutchings }; 225cd0ecc9aSBen Hutchings 226874aeea5SJeff Kirsher /** 227874aeea5SJeff Kirsher * struct siena_nic_data - Siena NIC state 2282dc313ecSShradha Shah * @efx: Pointer back to main interface structure 229874aeea5SJeff Kirsher * @wol_filter_id: Wake-on-LAN packet filter id 230cd0ecc9aSBen Hutchings * @stats: Hardware statistics 231bf3d0156SDaniel Pieczko * @vf: Array of &struct siena_vf objects 2322dc313ecSShradha Shah * @vf_buftbl_base: The zeroth buffer table index used to back VF queues. 2332dc313ecSShradha Shah * @vfdi_status: Common VFDI status page to be dmad to VF address space. 2342dc313ecSShradha Shah * @local_addr_list: List of local addresses. Protected by %local_lock. 2352dc313ecSShradha Shah * @local_page_list: List of DMA addressable pages used to broadcast 2362dc313ecSShradha Shah * %local_addr_list. Protected by %local_lock. 2372dc313ecSShradha Shah * @local_lock: Mutex protecting %local_addr_list and %local_page_list. 2382dc313ecSShradha Shah * @peer_work: Work item to broadcast peer addresses to VMs. 239874aeea5SJeff Kirsher */ 240874aeea5SJeff Kirsher struct siena_nic_data { 2412dc313ecSShradha Shah struct efx_nic *efx; 242874aeea5SJeff Kirsher int wol_filter_id; 243cd0ecc9aSBen Hutchings u64 stats[SIENA_STAT_COUNT]; 2442dc313ecSShradha Shah #ifdef CONFIG_SFC_SRIOV 245bf3d0156SDaniel Pieczko struct siena_vf *vf; 2462dc313ecSShradha Shah struct efx_channel *vfdi_channel; 2472dc313ecSShradha Shah unsigned vf_buftbl_base; 2482dc313ecSShradha Shah struct efx_buffer vfdi_status; 2492dc313ecSShradha Shah struct list_head local_addr_list; 2502dc313ecSShradha Shah struct list_head local_page_list; 2512dc313ecSShradha Shah struct mutex local_lock; 2522dc313ecSShradha Shah struct work_struct peer_work; 2532dc313ecSShradha Shah #endif 254874aeea5SJeff Kirsher }; 255874aeea5SJeff Kirsher 2568127d661SBen Hutchings enum { 257e80ca013SDaniel Pieczko EF10_STAT_port_tx_bytes = GENERIC_STAT_COUNT, 258e80ca013SDaniel Pieczko EF10_STAT_port_tx_packets, 259e80ca013SDaniel Pieczko EF10_STAT_port_tx_pause, 260e80ca013SDaniel Pieczko EF10_STAT_port_tx_control, 261e80ca013SDaniel Pieczko EF10_STAT_port_tx_unicast, 262e80ca013SDaniel Pieczko EF10_STAT_port_tx_multicast, 263e80ca013SDaniel Pieczko EF10_STAT_port_tx_broadcast, 264e80ca013SDaniel Pieczko EF10_STAT_port_tx_lt64, 265e80ca013SDaniel Pieczko EF10_STAT_port_tx_64, 266e80ca013SDaniel Pieczko EF10_STAT_port_tx_65_to_127, 267e80ca013SDaniel Pieczko EF10_STAT_port_tx_128_to_255, 268e80ca013SDaniel Pieczko EF10_STAT_port_tx_256_to_511, 269e80ca013SDaniel Pieczko EF10_STAT_port_tx_512_to_1023, 270e80ca013SDaniel Pieczko EF10_STAT_port_tx_1024_to_15xx, 271e80ca013SDaniel Pieczko EF10_STAT_port_tx_15xx_to_jumbo, 272e80ca013SDaniel Pieczko EF10_STAT_port_rx_bytes, 273e80ca013SDaniel Pieczko EF10_STAT_port_rx_bytes_minus_good_bytes, 274e80ca013SDaniel Pieczko EF10_STAT_port_rx_good_bytes, 275e80ca013SDaniel Pieczko EF10_STAT_port_rx_bad_bytes, 276e80ca013SDaniel Pieczko EF10_STAT_port_rx_packets, 277e80ca013SDaniel Pieczko EF10_STAT_port_rx_good, 278e80ca013SDaniel Pieczko EF10_STAT_port_rx_bad, 279e80ca013SDaniel Pieczko EF10_STAT_port_rx_pause, 280e80ca013SDaniel Pieczko EF10_STAT_port_rx_control, 281e80ca013SDaniel Pieczko EF10_STAT_port_rx_unicast, 282e80ca013SDaniel Pieczko EF10_STAT_port_rx_multicast, 283e80ca013SDaniel Pieczko EF10_STAT_port_rx_broadcast, 284e80ca013SDaniel Pieczko EF10_STAT_port_rx_lt64, 285e80ca013SDaniel Pieczko EF10_STAT_port_rx_64, 286e80ca013SDaniel Pieczko EF10_STAT_port_rx_65_to_127, 287e80ca013SDaniel Pieczko EF10_STAT_port_rx_128_to_255, 288e80ca013SDaniel Pieczko EF10_STAT_port_rx_256_to_511, 289e80ca013SDaniel Pieczko EF10_STAT_port_rx_512_to_1023, 290e80ca013SDaniel Pieczko EF10_STAT_port_rx_1024_to_15xx, 291e80ca013SDaniel Pieczko EF10_STAT_port_rx_15xx_to_jumbo, 292e80ca013SDaniel Pieczko EF10_STAT_port_rx_gtjumbo, 293e80ca013SDaniel Pieczko EF10_STAT_port_rx_bad_gtjumbo, 294e80ca013SDaniel Pieczko EF10_STAT_port_rx_overflow, 295e80ca013SDaniel Pieczko EF10_STAT_port_rx_align_error, 296e80ca013SDaniel Pieczko EF10_STAT_port_rx_length_error, 297e80ca013SDaniel Pieczko EF10_STAT_port_rx_nodesc_drops, 298e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_trunc_bb_overflow, 299e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_discard_bb_overflow, 300e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_trunc_vfifo_full, 301e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_discard_vfifo_full, 302e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_trunc_qbb, 303e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_discard_qbb, 304e80ca013SDaniel Pieczko EF10_STAT_port_rx_pm_discard_mapping, 305e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_q_disabled_packets, 306e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_di_dropped_packets, 307e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_streaming_packets, 308e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_hlb_fetch, 309e80ca013SDaniel Pieczko EF10_STAT_port_rx_dp_hlb_wait, 3103c36a2adSDaniel Pieczko EF10_STAT_rx_unicast, 3113c36a2adSDaniel Pieczko EF10_STAT_rx_unicast_bytes, 3123c36a2adSDaniel Pieczko EF10_STAT_rx_multicast, 3133c36a2adSDaniel Pieczko EF10_STAT_rx_multicast_bytes, 3143c36a2adSDaniel Pieczko EF10_STAT_rx_broadcast, 3153c36a2adSDaniel Pieczko EF10_STAT_rx_broadcast_bytes, 3163c36a2adSDaniel Pieczko EF10_STAT_rx_bad, 3173c36a2adSDaniel Pieczko EF10_STAT_rx_bad_bytes, 3183c36a2adSDaniel Pieczko EF10_STAT_rx_overflow, 3193c36a2adSDaniel Pieczko EF10_STAT_tx_unicast, 3203c36a2adSDaniel Pieczko EF10_STAT_tx_unicast_bytes, 3213c36a2adSDaniel Pieczko EF10_STAT_tx_multicast, 3223c36a2adSDaniel Pieczko EF10_STAT_tx_multicast_bytes, 3233c36a2adSDaniel Pieczko EF10_STAT_tx_broadcast, 3243c36a2adSDaniel Pieczko EF10_STAT_tx_broadcast_bytes, 3253c36a2adSDaniel Pieczko EF10_STAT_tx_bad, 3263c36a2adSDaniel Pieczko EF10_STAT_tx_bad_bytes, 3273c36a2adSDaniel Pieczko EF10_STAT_tx_overflow, 328f411b54dSEdward Cree EF10_STAT_V1_COUNT, 329f411b54dSEdward Cree EF10_STAT_fec_uncorrected_errors = EF10_STAT_V1_COUNT, 330f411b54dSEdward Cree EF10_STAT_fec_corrected_errors, 331f411b54dSEdward Cree EF10_STAT_fec_corrected_symbols_lane0, 332f411b54dSEdward Cree EF10_STAT_fec_corrected_symbols_lane1, 333f411b54dSEdward Cree EF10_STAT_fec_corrected_symbols_lane2, 334f411b54dSEdward Cree EF10_STAT_fec_corrected_symbols_lane3, 3352c0b6ee8SBert Kenward EF10_STAT_ctpio_dmabuf_start, 3362c0b6ee8SBert Kenward EF10_STAT_ctpio_vi_busy_fallback, 3372c0b6ee8SBert Kenward EF10_STAT_ctpio_long_write_success, 3382c0b6ee8SBert Kenward EF10_STAT_ctpio_missing_dbell_fail, 3392c0b6ee8SBert Kenward EF10_STAT_ctpio_overflow_fail, 3402c0b6ee8SBert Kenward EF10_STAT_ctpio_underflow_fail, 3412c0b6ee8SBert Kenward EF10_STAT_ctpio_timeout_fail, 3422c0b6ee8SBert Kenward EF10_STAT_ctpio_noncontig_wr_fail, 3432c0b6ee8SBert Kenward EF10_STAT_ctpio_frm_clobber_fail, 3442c0b6ee8SBert Kenward EF10_STAT_ctpio_invalid_wr_fail, 3452c0b6ee8SBert Kenward EF10_STAT_ctpio_vi_clobber_fallback, 3462c0b6ee8SBert Kenward EF10_STAT_ctpio_unqualified_fallback, 3472c0b6ee8SBert Kenward EF10_STAT_ctpio_runt_fallback, 3482c0b6ee8SBert Kenward EF10_STAT_ctpio_success, 3492c0b6ee8SBert Kenward EF10_STAT_ctpio_fallback, 3502c0b6ee8SBert Kenward EF10_STAT_ctpio_poison, 3512c0b6ee8SBert Kenward EF10_STAT_ctpio_erase, 3528127d661SBen Hutchings EF10_STAT_COUNT 3538127d661SBen Hutchings }; 3548127d661SBen Hutchings 355183233beSBen Hutchings /* Maximum number of TX PIO buffers we may allocate to a function. 356183233beSBen Hutchings * This matches the total number of buffers on each SFC9100-family 357183233beSBen Hutchings * controller. 358183233beSBen Hutchings */ 359183233beSBen Hutchings #define EF10_TX_PIOBUF_COUNT 16 360183233beSBen Hutchings 3618127d661SBen Hutchings /** 3628127d661SBen Hutchings * struct efx_ef10_nic_data - EF10 architecture NIC state 3638127d661SBen Hutchings * @mcdi_buf: DMA buffer for MCDI 3648127d661SBen Hutchings * @warm_boot_count: Last seen MC warm boot count 3658127d661SBen Hutchings * @vi_base: Absolute index of first VI in this function 3668127d661SBen Hutchings * @n_allocated_vis: Number of VIs allocated to this function 3678127d661SBen Hutchings * @must_realloc_vis: Flag: VIs have yet to be reallocated after MC reboot 3688127d661SBen Hutchings * @must_restore_filters: Flag: filters have yet to be restored after MC reboot 369183233beSBen Hutchings * @n_piobufs: Number of PIO buffers allocated to this function 370183233beSBen Hutchings * @wc_membase: Base address of write-combining mapping of the memory BAR 371183233beSBen Hutchings * @pio_write_base: Base address for writing PIO buffers 372183233beSBen Hutchings * @pio_write_vi_base: Relative VI number for @pio_write_base 373183233beSBen Hutchings * @piobuf_handle: Handle of each PIO buffer allocated 374c634700fSEdward Cree * @piobuf_size: size of a single PIO buffer 375183233beSBen Hutchings * @must_restore_piobufs: Flag: PIO buffers have yet to be restored after MC 376183233beSBen Hutchings * reboot 3778127d661SBen Hutchings * @rx_rss_context: Firmware handle for our RSS context 378267c0157SJon Cooper * @rx_rss_context_exclusive: Whether our RSS context is exclusive or shared 3798127d661SBen Hutchings * @stats: Hardware statistics 3808127d661SBen Hutchings * @workaround_35388: Flag: firmware supports workaround for bug 35388 38146e612b0SDaniel Pieczko * @workaround_26807: Flag: firmware supports workaround for bug 26807 382539de7c5SBert Kenward * @workaround_61265: Flag: firmware supports workaround for bug 61265 383a915ccc9SBen Hutchings * @must_check_datapath_caps: Flag: @datapath_caps needs to be revalidated 384a915ccc9SBen Hutchings * after MC reboot 3858127d661SBen Hutchings * @datapath_caps: Capabilities of datapath firmware (FLAGS1 field of 3868127d661SBen Hutchings * %MC_CMD_GET_CAPABILITIES response) 387ca889a05SBert Kenward * @datapath_caps2: Further Capabilities of datapath firmware (FLAGS2 field of 388ca889a05SBert Kenward * %MC_CMD_GET_CAPABILITIES response) 3898d9f9dd4SDaniel Pieczko * @rx_dpcpu_fw_id: Firmware ID of the RxDPCPU 3908d9f9dd4SDaniel Pieczko * @tx_dpcpu_fw_id: Firmware ID of the TxDPCPU 39145b2449eSDaniel Pieczko * @vport_id: The function's vport ID, only relevant for PFs 3926d8aaaf6SDaniel Pieczko * @must_probe_vswitching: Flag: vswitching has yet to be setup after MC reboot 3931cd9ecbbSDaniel Pieczko * @pf_index: The number for this PF, or the parent PF if this is a VF 3943c5eb876SShradha Shah #ifdef CONFIG_SFC_SRIOV 3953c5eb876SShradha Shah * @vf: Pointer to VF data structure 3963c5eb876SShradha Shah #endif 39734813fe2SAndrew Rybchenko * @vport_mac: The MAC address on the vport, only for PFs; VFs will be zero 39834813fe2SAndrew Rybchenko * @vlan_list: List of VLANs added over the interface. Serialised by vlan_lock. 39934813fe2SAndrew Rybchenko * @vlan_lock: Lock to serialize access to vlan_list. 400e5fbd977SJon Cooper * @udp_tunnels: UDP tunnel port numbers and types. 401e5fbd977SJon Cooper * @udp_tunnels_dirty: flag indicating a reboot occurred while pushing 402e5fbd977SJon Cooper * @udp_tunnels to hardware and thus the push must be re-done. 403e5fbd977SJon Cooper * @udp_tunnels_lock: Serialises writes to @udp_tunnels and @udp_tunnels_dirty. 4048127d661SBen Hutchings */ 4058127d661SBen Hutchings struct efx_ef10_nic_data { 4068127d661SBen Hutchings struct efx_buffer mcdi_buf; 4078127d661SBen Hutchings u16 warm_boot_count; 4088127d661SBen Hutchings unsigned int vi_base; 4098127d661SBen Hutchings unsigned int n_allocated_vis; 4108127d661SBen Hutchings bool must_realloc_vis; 4118127d661SBen Hutchings bool must_restore_filters; 412183233beSBen Hutchings unsigned int n_piobufs; 413183233beSBen Hutchings void __iomem *wc_membase, *pio_write_base; 414183233beSBen Hutchings unsigned int pio_write_vi_base; 415183233beSBen Hutchings unsigned int piobuf_handle[EF10_TX_PIOBUF_COUNT]; 416c634700fSEdward Cree u16 piobuf_size; 417183233beSBen Hutchings bool must_restore_piobufs; 4188127d661SBen Hutchings u32 rx_rss_context; 419267c0157SJon Cooper bool rx_rss_context_exclusive; 4208127d661SBen Hutchings u64 stats[EF10_STAT_COUNT]; 4218127d661SBen Hutchings bool workaround_35388; 42246e612b0SDaniel Pieczko bool workaround_26807; 423539de7c5SBert Kenward bool workaround_61265; 424a915ccc9SBen Hutchings bool must_check_datapath_caps; 4258127d661SBen Hutchings u32 datapath_caps; 426ca889a05SBert Kenward u32 datapath_caps2; 4278d9f9dd4SDaniel Pieczko unsigned int rx_dpcpu_fw_id; 4288d9f9dd4SDaniel Pieczko unsigned int tx_dpcpu_fw_id; 42945b2449eSDaniel Pieczko unsigned int vport_id; 4306d8aaaf6SDaniel Pieczko bool must_probe_vswitching; 4311cd9ecbbSDaniel Pieczko unsigned int pf_index; 4321d051e00SShradha Shah u8 port_id[ETH_ALEN]; 4333c5eb876SShradha Shah #ifdef CONFIG_SFC_SRIOV 43488a37de6SShradha Shah unsigned int vf_index; 4353c5eb876SShradha Shah struct ef10_vf *vf; 4363c5eb876SShradha Shah #endif 4373c5eb876SShradha Shah u8 vport_mac[ETH_ALEN]; 43834813fe2SAndrew Rybchenko struct list_head vlan_list; 43934813fe2SAndrew Rybchenko struct mutex vlan_lock; 440e5fbd977SJon Cooper struct efx_udp_tunnel udp_tunnels[16]; 441e5fbd977SJon Cooper bool udp_tunnels_dirty; 442e5fbd977SJon Cooper struct mutex udp_tunnels_lock; 44350663fe1SMartin Habets u64 licensed_features; 4448127d661SBen Hutchings }; 4458127d661SBen Hutchings 44600aef986SJoe Perches int efx_init_sriov(void); 44700aef986SJoe Perches void efx_fini_sriov(void); 448cd2d5b52SBen Hutchings 4497c236c43SStuart Hodgson struct ethtool_ts_info; 450ac36baf8SBen Hutchings int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel); 451ac36baf8SBen Hutchings void efx_ptp_defer_probe_with_channel(struct efx_nic *efx); 452ac36baf8SBen Hutchings void efx_ptp_remove(struct efx_nic *efx); 453433dc9b3SBen Hutchings int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr); 454433dc9b3SBen Hutchings int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr); 45500aef986SJoe Perches void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info); 45600aef986SJoe Perches bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb); 4579ec06595SDaniel Pieczko int efx_ptp_get_mode(struct efx_nic *efx); 4589ec06595SDaniel Pieczko int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted, 4599ec06595SDaniel Pieczko unsigned int new_mode); 46000aef986SJoe Perches int efx_ptp_tx(struct efx_nic *efx, struct sk_buff *skb); 46100aef986SJoe Perches void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev); 46299691c4aSBen Hutchings size_t efx_ptp_describe_stats(struct efx_nic *efx, u8 *strings); 46399691c4aSBen Hutchings size_t efx_ptp_update_stats(struct efx_nic *efx, u64 *stats); 464bd9a265dSJon Cooper void efx_time_sync_event(struct efx_channel *channel, efx_qword_t *ev); 465bd9a265dSJon Cooper void __efx_rx_skb_attach_timestamp(struct efx_channel *channel, 466bd9a265dSJon Cooper struct sk_buff *skb); 467bd9a265dSJon Cooper static inline void efx_rx_skb_attach_timestamp(struct efx_channel *channel, 468bd9a265dSJon Cooper struct sk_buff *skb) 469bd9a265dSJon Cooper { 470bd9a265dSJon Cooper if (channel->sync_events_state == SYNC_EVENTS_VALID) 471bd9a265dSJon Cooper __efx_rx_skb_attach_timestamp(channel, skb); 472bd9a265dSJon Cooper } 4732ea4dc28SAlexandre Rames void efx_ptp_start_datapath(struct efx_nic *efx); 4742ea4dc28SAlexandre Rames void efx_ptp_stop_datapath(struct efx_nic *efx); 4759c3afb33SMartin Habets bool efx_ptp_use_mac_tx_timestamps(struct efx_nic *efx); 476b9b603d4SMartin Habets ktime_t efx_ptp_nic_to_kernel_time(struct efx_tx_queue *tx_queue); 4777c236c43SStuart Hodgson 478874aeea5SJeff Kirsher extern const struct efx_nic_type falcon_a1_nic_type; 479874aeea5SJeff Kirsher extern const struct efx_nic_type falcon_b0_nic_type; 480874aeea5SJeff Kirsher extern const struct efx_nic_type siena_a0_nic_type; 4818127d661SBen Hutchings extern const struct efx_nic_type efx_hunt_a0_nic_type; 48202246a7fSShradha Shah extern const struct efx_nic_type efx_hunt_a0_vf_nic_type; 483874aeea5SJeff Kirsher 484874aeea5SJeff Kirsher /************************************************************************** 485874aeea5SJeff Kirsher * 486874aeea5SJeff Kirsher * Externs 487874aeea5SJeff Kirsher * 488874aeea5SJeff Kirsher ************************************************************************** 489874aeea5SJeff Kirsher */ 490874aeea5SJeff Kirsher 49100aef986SJoe Perches int falcon_probe_board(struct efx_nic *efx, u16 revision_info); 492874aeea5SJeff Kirsher 493874aeea5SJeff Kirsher /* TX data path */ 49486094f7fSBen Hutchings static inline int efx_nic_probe_tx(struct efx_tx_queue *tx_queue) 49586094f7fSBen Hutchings { 49686094f7fSBen Hutchings return tx_queue->efx->type->tx_probe(tx_queue); 49786094f7fSBen Hutchings } 49886094f7fSBen Hutchings static inline void efx_nic_init_tx(struct efx_tx_queue *tx_queue) 49986094f7fSBen Hutchings { 50086094f7fSBen Hutchings tx_queue->efx->type->tx_init(tx_queue); 50186094f7fSBen Hutchings } 50286094f7fSBen Hutchings static inline void efx_nic_remove_tx(struct efx_tx_queue *tx_queue) 50386094f7fSBen Hutchings { 50486094f7fSBen Hutchings tx_queue->efx->type->tx_remove(tx_queue); 50586094f7fSBen Hutchings } 50686094f7fSBen Hutchings static inline void efx_nic_push_buffers(struct efx_tx_queue *tx_queue) 50786094f7fSBen Hutchings { 50886094f7fSBen Hutchings tx_queue->efx->type->tx_write(tx_queue); 50986094f7fSBen Hutchings } 510874aeea5SJeff Kirsher 511874aeea5SJeff Kirsher /* RX data path */ 51286094f7fSBen Hutchings static inline int efx_nic_probe_rx(struct efx_rx_queue *rx_queue) 51386094f7fSBen Hutchings { 51486094f7fSBen Hutchings return rx_queue->efx->type->rx_probe(rx_queue); 51586094f7fSBen Hutchings } 51686094f7fSBen Hutchings static inline void efx_nic_init_rx(struct efx_rx_queue *rx_queue) 51786094f7fSBen Hutchings { 51886094f7fSBen Hutchings rx_queue->efx->type->rx_init(rx_queue); 51986094f7fSBen Hutchings } 52086094f7fSBen Hutchings static inline void efx_nic_remove_rx(struct efx_rx_queue *rx_queue) 52186094f7fSBen Hutchings { 52286094f7fSBen Hutchings rx_queue->efx->type->rx_remove(rx_queue); 52386094f7fSBen Hutchings } 52486094f7fSBen Hutchings static inline void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue) 52586094f7fSBen Hutchings { 52686094f7fSBen Hutchings rx_queue->efx->type->rx_write(rx_queue); 52786094f7fSBen Hutchings } 52886094f7fSBen Hutchings static inline void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue) 52986094f7fSBen Hutchings { 53086094f7fSBen Hutchings rx_queue->efx->type->rx_defer_refill(rx_queue); 53186094f7fSBen Hutchings } 532874aeea5SJeff Kirsher 533874aeea5SJeff Kirsher /* Event data path */ 53486094f7fSBen Hutchings static inline int efx_nic_probe_eventq(struct efx_channel *channel) 53586094f7fSBen Hutchings { 53686094f7fSBen Hutchings return channel->efx->type->ev_probe(channel); 53786094f7fSBen Hutchings } 538261e4d96SJon Cooper static inline int efx_nic_init_eventq(struct efx_channel *channel) 53986094f7fSBen Hutchings { 540261e4d96SJon Cooper return channel->efx->type->ev_init(channel); 54186094f7fSBen Hutchings } 54286094f7fSBen Hutchings static inline void efx_nic_fini_eventq(struct efx_channel *channel) 54386094f7fSBen Hutchings { 54486094f7fSBen Hutchings channel->efx->type->ev_fini(channel); 54586094f7fSBen Hutchings } 54686094f7fSBen Hutchings static inline void efx_nic_remove_eventq(struct efx_channel *channel) 54786094f7fSBen Hutchings { 54886094f7fSBen Hutchings channel->efx->type->ev_remove(channel); 54986094f7fSBen Hutchings } 55086094f7fSBen Hutchings static inline int 55186094f7fSBen Hutchings efx_nic_process_eventq(struct efx_channel *channel, int quota) 55286094f7fSBen Hutchings { 55386094f7fSBen Hutchings return channel->efx->type->ev_process(channel, quota); 55486094f7fSBen Hutchings } 55586094f7fSBen Hutchings static inline void efx_nic_eventq_read_ack(struct efx_channel *channel) 55686094f7fSBen Hutchings { 55786094f7fSBen Hutchings channel->efx->type->ev_read_ack(channel); 55886094f7fSBen Hutchings } 55900aef986SJoe Perches void efx_nic_event_test_start(struct efx_channel *channel); 56086094f7fSBen Hutchings 56186094f7fSBen Hutchings /* Falcon/Siena queue operations */ 56200aef986SJoe Perches int efx_farch_tx_probe(struct efx_tx_queue *tx_queue); 56300aef986SJoe Perches void efx_farch_tx_init(struct efx_tx_queue *tx_queue); 56400aef986SJoe Perches void efx_farch_tx_fini(struct efx_tx_queue *tx_queue); 56500aef986SJoe Perches void efx_farch_tx_remove(struct efx_tx_queue *tx_queue); 56600aef986SJoe Perches void efx_farch_tx_write(struct efx_tx_queue *tx_queue); 567e9117e50SBert Kenward unsigned int efx_farch_tx_limit_len(struct efx_tx_queue *tx_queue, 568e9117e50SBert Kenward dma_addr_t dma_addr, unsigned int len); 56900aef986SJoe Perches int efx_farch_rx_probe(struct efx_rx_queue *rx_queue); 57000aef986SJoe Perches void efx_farch_rx_init(struct efx_rx_queue *rx_queue); 57100aef986SJoe Perches void efx_farch_rx_fini(struct efx_rx_queue *rx_queue); 57200aef986SJoe Perches void efx_farch_rx_remove(struct efx_rx_queue *rx_queue); 57300aef986SJoe Perches void efx_farch_rx_write(struct efx_rx_queue *rx_queue); 57400aef986SJoe Perches void efx_farch_rx_defer_refill(struct efx_rx_queue *rx_queue); 57500aef986SJoe Perches int efx_farch_ev_probe(struct efx_channel *channel); 57600aef986SJoe Perches int efx_farch_ev_init(struct efx_channel *channel); 57700aef986SJoe Perches void efx_farch_ev_fini(struct efx_channel *channel); 57800aef986SJoe Perches void efx_farch_ev_remove(struct efx_channel *channel); 57900aef986SJoe Perches int efx_farch_ev_process(struct efx_channel *channel, int quota); 58000aef986SJoe Perches void efx_farch_ev_read_ack(struct efx_channel *channel); 58100aef986SJoe Perches void efx_farch_ev_test_generate(struct efx_channel *channel); 58286094f7fSBen Hutchings 583add72477SBen Hutchings /* Falcon/Siena filter operations */ 58400aef986SJoe Perches int efx_farch_filter_table_probe(struct efx_nic *efx); 58500aef986SJoe Perches void efx_farch_filter_table_restore(struct efx_nic *efx); 58600aef986SJoe Perches void efx_farch_filter_table_remove(struct efx_nic *efx); 58700aef986SJoe Perches void efx_farch_filter_update_rx_scatter(struct efx_nic *efx); 58800aef986SJoe Perches s32 efx_farch_filter_insert(struct efx_nic *efx, struct efx_filter_spec *spec, 58900aef986SJoe Perches bool replace); 59000aef986SJoe Perches int efx_farch_filter_remove_safe(struct efx_nic *efx, 591add72477SBen Hutchings enum efx_filter_priority priority, 592add72477SBen Hutchings u32 filter_id); 59300aef986SJoe Perches int efx_farch_filter_get_safe(struct efx_nic *efx, 59400aef986SJoe Perches enum efx_filter_priority priority, u32 filter_id, 59500aef986SJoe Perches struct efx_filter_spec *); 596fbd79120SBen Hutchings int efx_farch_filter_clear_rx(struct efx_nic *efx, 597add72477SBen Hutchings enum efx_filter_priority priority); 59800aef986SJoe Perches u32 efx_farch_filter_count_rx_used(struct efx_nic *efx, 599add72477SBen Hutchings enum efx_filter_priority priority); 60000aef986SJoe Perches u32 efx_farch_filter_get_rx_id_limit(struct efx_nic *efx); 60100aef986SJoe Perches s32 efx_farch_filter_get_rx_ids(struct efx_nic *efx, 60200aef986SJoe Perches enum efx_filter_priority priority, u32 *buf, 60300aef986SJoe Perches u32 size); 604add72477SBen Hutchings #ifdef CONFIG_RFS_ACCEL 60500aef986SJoe Perches s32 efx_farch_filter_rfs_insert(struct efx_nic *efx, 606add72477SBen Hutchings struct efx_filter_spec *spec); 60700aef986SJoe Perches bool efx_farch_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id, 608add72477SBen Hutchings unsigned int index); 609add72477SBen Hutchings #endif 61000aef986SJoe Perches void efx_farch_filter_sync_rx_mode(struct efx_nic *efx); 611add72477SBen Hutchings 61200aef986SJoe Perches bool efx_nic_event_present(struct efx_channel *channel); 613874aeea5SJeff Kirsher 614b7f514afSBen Hutchings /* Some statistics are computed as A - B where A and B each increase 615b7f514afSBen Hutchings * linearly with some hardware counter(s) and the counters are read 616b7f514afSBen Hutchings * asynchronously. If the counters contributing to B are always read 617b7f514afSBen Hutchings * after those contributing to A, the computed value may be lower than 618b7f514afSBen Hutchings * the true value by some variable amount, and may decrease between 619b7f514afSBen Hutchings * subsequent computations. 620b7f514afSBen Hutchings * 621b7f514afSBen Hutchings * We should never allow statistics to decrease or to exceed the true 622b7f514afSBen Hutchings * value. Since the computed value will never be greater than the 623b7f514afSBen Hutchings * true value, we can achieve this by only storing the computed value 624b7f514afSBen Hutchings * when it increases. 625b7f514afSBen Hutchings */ 626b7f514afSBen Hutchings static inline void efx_update_diff_stat(u64 *stat, u64 diff) 627b7f514afSBen Hutchings { 628b7f514afSBen Hutchings if ((s64)(diff - *stat) > 0) 629b7f514afSBen Hutchings *stat = diff; 630b7f514afSBen Hutchings } 631b7f514afSBen Hutchings 63286094f7fSBen Hutchings /* Interrupts */ 63300aef986SJoe Perches int efx_nic_init_interrupt(struct efx_nic *efx); 634942e298eSJon Cooper int efx_nic_irq_test_start(struct efx_nic *efx); 63500aef986SJoe Perches void efx_nic_fini_interrupt(struct efx_nic *efx); 63686094f7fSBen Hutchings 63786094f7fSBen Hutchings /* Falcon/Siena interrupts */ 63800aef986SJoe Perches void efx_farch_irq_enable_master(struct efx_nic *efx); 639942e298eSJon Cooper int efx_farch_irq_test_generate(struct efx_nic *efx); 64000aef986SJoe Perches void efx_farch_irq_disable_master(struct efx_nic *efx); 64100aef986SJoe Perches irqreturn_t efx_farch_msi_interrupt(int irq, void *dev_id); 64200aef986SJoe Perches irqreturn_t efx_farch_legacy_interrupt(int irq, void *dev_id); 64300aef986SJoe Perches irqreturn_t efx_farch_fatal_interrupt(struct efx_nic *efx); 644874aeea5SJeff Kirsher 645eee6f6a9SBen Hutchings static inline int efx_nic_event_test_irq_cpu(struct efx_channel *channel) 646eee6f6a9SBen Hutchings { 6476aa7de05SMark Rutland return READ_ONCE(channel->event_test_cpu); 648eee6f6a9SBen Hutchings } 649eee6f6a9SBen Hutchings static inline int efx_nic_irq_test_irq_cpu(struct efx_nic *efx) 650eee6f6a9SBen Hutchings { 6516aa7de05SMark Rutland return READ_ONCE(efx->last_irq_cpu); 652eee6f6a9SBen Hutchings } 653eee6f6a9SBen Hutchings 654874aeea5SJeff Kirsher /* Global Resources */ 65500aef986SJoe Perches int efx_nic_flush_queues(struct efx_nic *efx); 65600aef986SJoe Perches void siena_prepare_flush(struct efx_nic *efx); 65700aef986SJoe Perches int efx_farch_fini_dmaq(struct efx_nic *efx); 658e283546cSEdward Cree void efx_farch_finish_flr(struct efx_nic *efx); 65900aef986SJoe Perches void siena_finish_flush(struct efx_nic *efx); 66000aef986SJoe Perches void falcon_start_nic_stats(struct efx_nic *efx); 66100aef986SJoe Perches void falcon_stop_nic_stats(struct efx_nic *efx); 66200aef986SJoe Perches int falcon_reset_xaui(struct efx_nic *efx); 66300aef986SJoe Perches void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw); 66400aef986SJoe Perches void efx_farch_init_common(struct efx_nic *efx); 66500aef986SJoe Perches void efx_ef10_handle_drain_event(struct efx_nic *efx); 66600aef986SJoe Perches void efx_farch_rx_push_indir_table(struct efx_nic *efx); 667a707d188SEdward Cree void efx_farch_rx_pull_indir_table(struct efx_nic *efx); 668874aeea5SJeff Kirsher 669874aeea5SJeff Kirsher int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer, 6700d19a540SBen Hutchings unsigned int len, gfp_t gfp_flags); 671874aeea5SJeff Kirsher void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer); 672874aeea5SJeff Kirsher 673874aeea5SJeff Kirsher /* Tests */ 67486094f7fSBen Hutchings struct efx_farch_register_test { 675874aeea5SJeff Kirsher unsigned address; 676874aeea5SJeff Kirsher efx_oword_t mask; 677874aeea5SJeff Kirsher }; 67800aef986SJoe Perches int efx_farch_test_registers(struct efx_nic *efx, 67986094f7fSBen Hutchings const struct efx_farch_register_test *regs, 680874aeea5SJeff Kirsher size_t n_regs); 681874aeea5SJeff Kirsher 68200aef986SJoe Perches size_t efx_nic_get_regs_len(struct efx_nic *efx); 68300aef986SJoe Perches void efx_nic_get_regs(struct efx_nic *efx, void *buf); 684874aeea5SJeff Kirsher 68500aef986SJoe Perches size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count, 686cd0ecc9aSBen Hutchings const unsigned long *mask, u8 *names); 68700aef986SJoe Perches void efx_nic_update_stats(const struct efx_hw_stat_desc *desc, size_t count, 68800aef986SJoe Perches const unsigned long *mask, u64 *stats, 68900aef986SJoe Perches const void *dma_buf, bool accumulate); 690f8f3b5aeSJon Cooper void efx_nic_fix_nodesc_drop_stat(struct efx_nic *efx, u64 *stat); 691cd0ecc9aSBen Hutchings 692ab0115fcSBen Hutchings #define EFX_MAX_FLUSH_TIME 5000 693874aeea5SJeff Kirsher 69400aef986SJoe Perches void efx_farch_generate_event(struct efx_nic *efx, unsigned int evq, 695874aeea5SJeff Kirsher efx_qword_t *event); 696874aeea5SJeff Kirsher 697874aeea5SJeff Kirsher #endif /* EFX_NIC_H */ 698