nic.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /****************************************************************************
  2. * Driver for Solarflare Solarstorm network controllers and boards
  3. * Copyright 2005-2006 Fen Systems Ltd.
  4. * Copyright 2006-2011 Solarflare Communications Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation, incorporated herein by reference.
  9. */
  10. #ifndef EFX_NIC_H
  11. #define EFX_NIC_H
  12. #include <linux/net_tstamp.h>
  13. #include <linux/i2c-algo-bit.h>
  14. #include "net_driver.h"
  15. #include "efx.h"
  16. #include "mcdi.h"
  17. /*
  18. * Falcon hardware control
  19. */
  20. enum {
  21. EFX_REV_FALCON_A0 = 0,
  22. EFX_REV_FALCON_A1 = 1,
  23. EFX_REV_FALCON_B0 = 2,
  24. EFX_REV_SIENA_A0 = 3,
  25. };
  26. static inline int efx_nic_rev(struct efx_nic *efx)
  27. {
  28. return efx->type->revision;
  29. }
  30. extern u32 efx_farch_fpga_ver(struct efx_nic *efx);
  31. /* NIC has two interlinked PCI functions for the same port. */
  32. static inline bool efx_nic_is_dual_func(struct efx_nic *efx)
  33. {
  34. return efx_nic_rev(efx) < EFX_REV_FALCON_B0;
  35. }
  36. /* Read the current event from the event queue */
  37. static inline efx_qword_t *efx_event(struct efx_channel *channel,
  38. unsigned int index)
  39. {
  40. return ((efx_qword_t *) (channel->eventq.buf.addr)) +
  41. (index & channel->eventq_mask);
  42. }
  43. /* See if an event is present
  44. *
  45. * We check both the high and low dword of the event for all ones. We
  46. * wrote all ones when we cleared the event, and no valid event can
  47. * have all ones in either its high or low dwords. This approach is
  48. * robust against reordering.
  49. *
  50. * Note that using a single 64-bit comparison is incorrect; even
  51. * though the CPU read will be atomic, the DMA write may not be.
  52. */
  53. static inline int efx_event_present(efx_qword_t *event)
  54. {
  55. return !(EFX_DWORD_IS_ALL_ONES(event->dword[0]) |
  56. EFX_DWORD_IS_ALL_ONES(event->dword[1]));
  57. }
  58. /* Returns a pointer to the specified transmit descriptor in the TX
  59. * descriptor queue belonging to the specified channel.
  60. */
  61. static inline efx_qword_t *
  62. efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index)
  63. {
  64. return ((efx_qword_t *) (tx_queue->txd.buf.addr)) + index;
  65. }
  66. /* Decide whether to push a TX descriptor to the NIC vs merely writing
  67. * the doorbell. This can reduce latency when we are adding a single
  68. * descriptor to an empty queue, but is otherwise pointless. Further,
  69. * Falcon and Siena have hardware bugs (SF bug 33851) that may be
  70. * triggered if we don't check this.
  71. */
  72. static inline bool efx_nic_may_push_tx_desc(struct efx_tx_queue *tx_queue,
  73. unsigned int write_count)
  74. {
  75. unsigned empty_read_count = ACCESS_ONCE(tx_queue->empty_read_count);
  76. if (empty_read_count == 0)
  77. return false;
  78. tx_queue->empty_read_count = 0;
  79. return ((empty_read_count ^ write_count) & ~EFX_EMPTY_COUNT_VALID) == 0
  80. && tx_queue->write_count - write_count == 1;
  81. }
  82. /* Returns a pointer to the specified descriptor in the RX descriptor queue */
  83. static inline efx_qword_t *
  84. efx_rx_desc(struct efx_rx_queue *rx_queue, unsigned int index)
  85. {
  86. return ((efx_qword_t *) (rx_queue->rxd.buf.addr)) + index;
  87. }
  88. enum {
  89. PHY_TYPE_NONE = 0,
  90. PHY_TYPE_TXC43128 = 1,
  91. PHY_TYPE_88E1111 = 2,
  92. PHY_TYPE_SFX7101 = 3,
  93. PHY_TYPE_QT2022C2 = 4,
  94. PHY_TYPE_PM8358 = 6,
  95. PHY_TYPE_SFT9001A = 8,
  96. PHY_TYPE_QT2025C = 9,
  97. PHY_TYPE_SFT9001B = 10,
  98. };
  99. #define FALCON_XMAC_LOOPBACKS \
  100. ((1 << LOOPBACK_XGMII) | \
  101. (1 << LOOPBACK_XGXS) | \
  102. (1 << LOOPBACK_XAUI))
  103. #define FALCON_GMAC_LOOPBACKS \
  104. (1 << LOOPBACK_GMAC)
  105. /* Alignment of PCIe DMA boundaries (4KB) */
  106. #define EFX_PAGE_SIZE 4096
  107. /* Size and alignment of buffer table entries (same) */
  108. #define EFX_BUF_SIZE EFX_PAGE_SIZE
  109. /**
  110. * struct falcon_board_type - board operations and type information
  111. * @id: Board type id, as found in NVRAM
  112. * @init: Allocate resources and initialise peripheral hardware
  113. * @init_phy: Do board-specific PHY initialisation
  114. * @fini: Shut down hardware and free resources
  115. * @set_id_led: Set state of identifying LED or revert to automatic function
  116. * @monitor: Board-specific health check function
  117. */
  118. struct falcon_board_type {
  119. u8 id;
  120. int (*init) (struct efx_nic *nic);
  121. void (*init_phy) (struct efx_nic *efx);
  122. void (*fini) (struct efx_nic *nic);
  123. void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
  124. int (*monitor) (struct efx_nic *nic);
  125. };
  126. /**
  127. * struct falcon_board - board information
  128. * @type: Type of board
  129. * @major: Major rev. ('A', 'B' ...)
  130. * @minor: Minor rev. (0, 1, ...)
  131. * @i2c_adap: I2C adapter for on-board peripherals
  132. * @i2c_data: Data for bit-banging algorithm
  133. * @hwmon_client: I2C client for hardware monitor
  134. * @ioexp_client: I2C client for power/port control
  135. */
  136. struct falcon_board {
  137. const struct falcon_board_type *type;
  138. int major;
  139. int minor;
  140. struct i2c_adapter i2c_adap;
  141. struct i2c_algo_bit_data i2c_data;
  142. struct i2c_client *hwmon_client, *ioexp_client;
  143. };
  144. /**
  145. * struct falcon_spi_device - a Falcon SPI (Serial Peripheral Interface) device
  146. * @device_id: Controller's id for the device
  147. * @size: Size (in bytes)
  148. * @addr_len: Number of address bytes in read/write commands
  149. * @munge_address: Flag whether addresses should be munged.
  150. * Some devices with 9-bit addresses (e.g. AT25040A EEPROM)
  151. * use bit 3 of the command byte as address bit A8, rather
  152. * than having a two-byte address. If this flag is set, then
  153. * commands should be munged in this way.
  154. * @erase_command: Erase command (or 0 if sector erase not needed).
  155. * @erase_size: Erase sector size (in bytes)
  156. * Erase commands affect sectors with this size and alignment.
  157. * This must be a power of two.
  158. * @block_size: Write block size (in bytes).
  159. * Write commands are limited to blocks with this size and alignment.
  160. */
  161. struct falcon_spi_device {
  162. int device_id;
  163. unsigned int size;
  164. unsigned int addr_len;
  165. unsigned int munge_address:1;
  166. u8 erase_command;
  167. unsigned int erase_size;
  168. unsigned int block_size;
  169. };
  170. static inline bool falcon_spi_present(const struct falcon_spi_device *spi)
  171. {
  172. return spi->size != 0;
  173. }
  174. /**
  175. * struct falcon_nic_data - Falcon NIC state
  176. * @pci_dev2: Secondary function of Falcon A
  177. * @board: Board state and functions
  178. * @stats_disable_count: Nest count for disabling statistics fetches
  179. * @stats_pending: Is there a pending DMA of MAC statistics.
  180. * @stats_timer: A timer for regularly fetching MAC statistics.
  181. * @stats_dma_done: Pointer to the flag which indicates DMA completion.
  182. * @spi_flash: SPI flash device
  183. * @spi_eeprom: SPI EEPROM device
  184. * @spi_lock: SPI bus lock
  185. * @mdio_lock: MDIO bus lock
  186. * @xmac_poll_required: XMAC link state needs polling
  187. */
  188. struct falcon_nic_data {
  189. struct pci_dev *pci_dev2;
  190. struct falcon_board board;
  191. unsigned int stats_disable_count;
  192. bool stats_pending;
  193. struct timer_list stats_timer;
  194. u32 *stats_dma_done;
  195. struct falcon_spi_device spi_flash;
  196. struct falcon_spi_device spi_eeprom;
  197. struct mutex spi_lock;
  198. struct mutex mdio_lock;
  199. bool xmac_poll_required;
  200. };
  201. static inline struct falcon_board *falcon_board(struct efx_nic *efx)
  202. {
  203. struct falcon_nic_data *data = efx->nic_data;
  204. return &data->board;
  205. }
  206. /**
  207. * struct siena_nic_data - Siena NIC state
  208. * @wol_filter_id: Wake-on-LAN packet filter id
  209. */
  210. struct siena_nic_data {
  211. int wol_filter_id;
  212. };
  213. /*
  214. * On the SFC9000 family each port is associated with 1 PCI physical
  215. * function (PF) handled by sfc and a configurable number of virtual
  216. * functions (VFs) that may be handled by some other driver, often in
  217. * a VM guest. The queue pointer registers are mapped in both PF and
  218. * VF BARs such that an 8K region provides access to a single RX, TX
  219. * and event queue (collectively a Virtual Interface, VI or VNIC).
  220. *
  221. * The PF has access to all 1024 VIs while VFs are mapped to VIs
  222. * according to VI_BASE and VI_SCALE: VF i has access to VIs numbered
  223. * in range [VI_BASE + i << VI_SCALE, VI_BASE + i + 1 << VI_SCALE).
  224. * The number of VIs and the VI_SCALE value are configurable but must
  225. * be established at boot time by firmware.
  226. */
  227. /* Maximum VI_SCALE parameter supported by Siena */
  228. #define EFX_VI_SCALE_MAX 6
  229. /* Base VI to use for SR-IOV. Must be aligned to (1 << EFX_VI_SCALE_MAX),
  230. * so this is the smallest allowed value. */
  231. #define EFX_VI_BASE 128U
  232. /* Maximum number of VFs allowed */
  233. #define EFX_VF_COUNT_MAX 127
  234. /* Limit EVQs on VFs to be only 8k to reduce buffer table reservation */
  235. #define EFX_MAX_VF_EVQ_SIZE 8192UL
  236. /* The number of buffer table entries reserved for each VI on a VF */
  237. #define EFX_VF_BUFTBL_PER_VI \
  238. ((EFX_MAX_VF_EVQ_SIZE + 2 * EFX_MAX_DMAQ_SIZE) * \
  239. sizeof(efx_qword_t) / EFX_BUF_SIZE)
  240. #ifdef CONFIG_SFC_SRIOV
  241. static inline bool efx_sriov_wanted(struct efx_nic *efx)
  242. {
  243. return efx->vf_count != 0;
  244. }
  245. static inline bool efx_sriov_enabled(struct efx_nic *efx)
  246. {
  247. return efx->vf_init_count != 0;
  248. }
  249. static inline unsigned int efx_vf_size(struct efx_nic *efx)
  250. {
  251. return 1 << efx->vi_scale;
  252. }
  253. extern int efx_init_sriov(void);
  254. extern void efx_sriov_probe(struct efx_nic *efx);
  255. extern int efx_sriov_init(struct efx_nic *efx);
  256. extern void efx_sriov_mac_address_changed(struct efx_nic *efx);
  257. extern void efx_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event);
  258. extern void efx_sriov_rx_flush_done(struct efx_nic *efx, efx_qword_t *event);
  259. extern void efx_sriov_event(struct efx_channel *channel, efx_qword_t *event);
  260. extern void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq);
  261. extern void efx_sriov_flr(struct efx_nic *efx, unsigned flr);
  262. extern void efx_sriov_reset(struct efx_nic *efx);
  263. extern void efx_sriov_fini(struct efx_nic *efx);
  264. extern void efx_fini_sriov(void);
  265. #else
  266. static inline bool efx_sriov_wanted(struct efx_nic *efx) { return false; }
  267. static inline bool efx_sriov_enabled(struct efx_nic *efx) { return false; }
  268. static inline unsigned int efx_vf_size(struct efx_nic *efx) { return 0; }
  269. static inline int efx_init_sriov(void) { return 0; }
  270. static inline void efx_sriov_probe(struct efx_nic *efx) {}
  271. static inline int efx_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; }
  272. static inline void efx_sriov_mac_address_changed(struct efx_nic *efx) {}
  273. static inline void efx_sriov_tx_flush_done(struct efx_nic *efx,
  274. efx_qword_t *event) {}
  275. static inline void efx_sriov_rx_flush_done(struct efx_nic *efx,
  276. efx_qword_t *event) {}
  277. static inline void efx_sriov_event(struct efx_channel *channel,
  278. efx_qword_t *event) {}
  279. static inline void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq) {}
  280. static inline void efx_sriov_flr(struct efx_nic *efx, unsigned flr) {}
  281. static inline void efx_sriov_reset(struct efx_nic *efx) {}
  282. static inline void efx_sriov_fini(struct efx_nic *efx) {}
  283. static inline void efx_fini_sriov(void) {}
  284. #endif
  285. extern int efx_sriov_set_vf_mac(struct net_device *dev, int vf, u8 *mac);
  286. extern int efx_sriov_set_vf_vlan(struct net_device *dev, int vf,
  287. u16 vlan, u8 qos);
  288. extern int efx_sriov_get_vf_config(struct net_device *dev, int vf,
  289. struct ifla_vf_info *ivf);
  290. extern int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf,
  291. bool spoofchk);
  292. struct ethtool_ts_info;
  293. extern void efx_ptp_probe(struct efx_nic *efx);
  294. extern int efx_ptp_ioctl(struct efx_nic *efx, struct ifreq *ifr, int cmd);
  295. extern void efx_ptp_get_ts_info(struct efx_nic *efx,
  296. struct ethtool_ts_info *ts_info);
  297. extern bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
  298. extern int efx_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
  299. extern void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev);
  300. extern const struct efx_nic_type falcon_a1_nic_type;
  301. extern const struct efx_nic_type falcon_b0_nic_type;
  302. extern const struct efx_nic_type siena_a0_nic_type;
  303. /**************************************************************************
  304. *
  305. * Externs
  306. *
  307. **************************************************************************
  308. */
  309. extern int falcon_probe_board(struct efx_nic *efx, u16 revision_info);
  310. /* TX data path */
  311. static inline int efx_nic_probe_tx(struct efx_tx_queue *tx_queue)
  312. {
  313. return tx_queue->efx->type->tx_probe(tx_queue);
  314. }
  315. static inline void efx_nic_init_tx(struct efx_tx_queue *tx_queue)
  316. {
  317. tx_queue->efx->type->tx_init(tx_queue);
  318. }
  319. static inline void efx_nic_remove_tx(struct efx_tx_queue *tx_queue)
  320. {
  321. tx_queue->efx->type->tx_remove(tx_queue);
  322. }
  323. static inline void efx_nic_push_buffers(struct efx_tx_queue *tx_queue)
  324. {
  325. tx_queue->efx->type->tx_write(tx_queue);
  326. }
  327. /* RX data path */
  328. static inline int efx_nic_probe_rx(struct efx_rx_queue *rx_queue)
  329. {
  330. return rx_queue->efx->type->rx_probe(rx_queue);
  331. }
  332. static inline void efx_nic_init_rx(struct efx_rx_queue *rx_queue)
  333. {
  334. rx_queue->efx->type->rx_init(rx_queue);
  335. }
  336. static inline void efx_nic_remove_rx(struct efx_rx_queue *rx_queue)
  337. {
  338. rx_queue->efx->type->rx_remove(rx_queue);
  339. }
  340. static inline void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue)
  341. {
  342. rx_queue->efx->type->rx_write(rx_queue);
  343. }
  344. static inline void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue)
  345. {
  346. rx_queue->efx->type->rx_defer_refill(rx_queue);
  347. }
  348. /* Event data path */
  349. static inline int efx_nic_probe_eventq(struct efx_channel *channel)
  350. {
  351. return channel->efx->type->ev_probe(channel);
  352. }
  353. static inline void efx_nic_init_eventq(struct efx_channel *channel)
  354. {
  355. channel->efx->type->ev_init(channel);
  356. }
  357. static inline void efx_nic_fini_eventq(struct efx_channel *channel)
  358. {
  359. channel->efx->type->ev_fini(channel);
  360. }
  361. static inline void efx_nic_remove_eventq(struct efx_channel *channel)
  362. {
  363. channel->efx->type->ev_remove(channel);
  364. }
  365. static inline int
  366. efx_nic_process_eventq(struct efx_channel *channel, int quota)
  367. {
  368. return channel->efx->type->ev_process(channel, quota);
  369. }
  370. static inline void efx_nic_eventq_read_ack(struct efx_channel *channel)
  371. {
  372. channel->efx->type->ev_read_ack(channel);
  373. }
  374. extern void efx_nic_event_test_start(struct efx_channel *channel);
  375. /* Falcon/Siena queue operations */
  376. extern int efx_farch_tx_probe(struct efx_tx_queue *tx_queue);
  377. extern void efx_farch_tx_init(struct efx_tx_queue *tx_queue);
  378. extern void efx_farch_tx_fini(struct efx_tx_queue *tx_queue);
  379. extern void efx_farch_tx_remove(struct efx_tx_queue *tx_queue);
  380. extern void efx_farch_tx_write(struct efx_tx_queue *tx_queue);
  381. extern int efx_farch_rx_probe(struct efx_rx_queue *rx_queue);
  382. extern void efx_farch_rx_init(struct efx_rx_queue *rx_queue);
  383. extern void efx_farch_rx_fini(struct efx_rx_queue *rx_queue);
  384. extern void efx_farch_rx_remove(struct efx_rx_queue *rx_queue);
  385. extern void efx_farch_rx_write(struct efx_rx_queue *rx_queue);
  386. extern void efx_farch_rx_defer_refill(struct efx_rx_queue *rx_queue);
  387. extern int efx_farch_ev_probe(struct efx_channel *channel);
  388. extern void efx_farch_ev_init(struct efx_channel *channel);
  389. extern void efx_farch_ev_fini(struct efx_channel *channel);
  390. extern void efx_farch_ev_remove(struct efx_channel *channel);
  391. extern int efx_farch_ev_process(struct efx_channel *channel, int quota);
  392. extern void efx_farch_ev_read_ack(struct efx_channel *channel);
  393. extern void efx_farch_ev_test_generate(struct efx_channel *channel);
  394. /* Falcon/Siena filter operations */
  395. extern int efx_farch_filter_table_probe(struct efx_nic *efx);
  396. extern void efx_farch_filter_table_restore(struct efx_nic *efx);
  397. extern void efx_farch_filter_table_remove(struct efx_nic *efx);
  398. extern void efx_farch_filter_update_rx_scatter(struct efx_nic *efx);
  399. extern s32 efx_farch_filter_insert(struct efx_nic *efx,
  400. struct efx_filter_spec *spec, bool replace);
  401. extern int efx_farch_filter_remove_safe(struct efx_nic *efx,
  402. enum efx_filter_priority priority,
  403. u32 filter_id);
  404. extern int efx_farch_filter_get_safe(struct efx_nic *efx,
  405. enum efx_filter_priority priority,
  406. u32 filter_id, struct efx_filter_spec *);
  407. extern void efx_farch_filter_clear_rx(struct efx_nic *efx,
  408. enum efx_filter_priority priority);
  409. extern u32 efx_farch_filter_count_rx_used(struct efx_nic *efx,
  410. enum efx_filter_priority priority);
  411. extern u32 efx_farch_filter_get_rx_id_limit(struct efx_nic *efx);
  412. extern s32 efx_farch_filter_get_rx_ids(struct efx_nic *efx,
  413. enum efx_filter_priority priority,
  414. u32 *buf, u32 size);
  415. #ifdef CONFIG_RFS_ACCEL
  416. extern s32 efx_farch_filter_rfs_insert(struct efx_nic *efx,
  417. struct efx_filter_spec *spec);
  418. extern bool efx_farch_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id,
  419. unsigned int index);
  420. #endif
  421. extern void efx_farch_filter_sync_rx_mode(struct efx_nic *efx);
  422. extern bool efx_nic_event_present(struct efx_channel *channel);
  423. /* Some statistics are computed as A - B where A and B each increase
  424. * linearly with some hardware counter(s) and the counters are read
  425. * asynchronously. If the counters contributing to B are always read
  426. * after those contributing to A, the computed value may be lower than
  427. * the true value by some variable amount, and may decrease between
  428. * subsequent computations.
  429. *
  430. * We should never allow statistics to decrease or to exceed the true
  431. * value. Since the computed value will never be greater than the
  432. * true value, we can achieve this by only storing the computed value
  433. * when it increases.
  434. */
  435. static inline void efx_update_diff_stat(u64 *stat, u64 diff)
  436. {
  437. if ((s64)(diff - *stat) > 0)
  438. *stat = diff;
  439. }
  440. /* Interrupts */
  441. extern int efx_nic_init_interrupt(struct efx_nic *efx);
  442. extern void efx_nic_irq_test_start(struct efx_nic *efx);
  443. extern void efx_nic_fini_interrupt(struct efx_nic *efx);
  444. /* Falcon/Siena interrupts */
  445. extern void efx_farch_irq_enable_master(struct efx_nic *efx);
  446. extern void efx_farch_irq_test_generate(struct efx_nic *efx);
  447. extern void efx_farch_irq_disable_master(struct efx_nic *efx);
  448. extern irqreturn_t efx_farch_msi_interrupt(int irq, void *dev_id);
  449. extern irqreturn_t efx_farch_legacy_interrupt(int irq, void *dev_id);
  450. extern irqreturn_t efx_farch_fatal_interrupt(struct efx_nic *efx);
  451. static inline int efx_nic_event_test_irq_cpu(struct efx_channel *channel)
  452. {
  453. return ACCESS_ONCE(channel->event_test_cpu);
  454. }
  455. static inline int efx_nic_irq_test_irq_cpu(struct efx_nic *efx)
  456. {
  457. return ACCESS_ONCE(efx->last_irq_cpu);
  458. }
  459. /* Global Resources */
  460. extern int efx_nic_flush_queues(struct efx_nic *efx);
  461. extern void siena_prepare_flush(struct efx_nic *efx);
  462. extern int efx_farch_fini_dmaq(struct efx_nic *efx);
  463. extern void siena_finish_flush(struct efx_nic *efx);
  464. extern void falcon_start_nic_stats(struct efx_nic *efx);
  465. extern void falcon_stop_nic_stats(struct efx_nic *efx);
  466. extern int falcon_reset_xaui(struct efx_nic *efx);
  467. extern void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw);
  468. extern void efx_farch_init_common(struct efx_nic *efx);
  469. static inline void efx_nic_push_rx_indir_table(struct efx_nic *efx)
  470. {
  471. efx->type->rx_push_indir_table(efx);
  472. }
  473. extern void efx_farch_rx_push_indir_table(struct efx_nic *efx);
  474. int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
  475. unsigned int len, gfp_t gfp_flags);
  476. void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer);
  477. /* Tests */
  478. struct efx_farch_register_test {
  479. unsigned address;
  480. efx_oword_t mask;
  481. };
  482. extern int efx_farch_test_registers(struct efx_nic *efx,
  483. const struct efx_farch_register_test *regs,
  484. size_t n_regs);
  485. extern size_t efx_nic_get_regs_len(struct efx_nic *efx);
  486. extern void efx_nic_get_regs(struct efx_nic *efx, void *buf);
  487. #define EFX_MAX_FLUSH_TIME 5000
  488. extern void efx_farch_generate_event(struct efx_nic *efx, unsigned int evq,
  489. efx_qword_t *event);
  490. #endif /* EFX_NIC_H */