falcon.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /****************************************************************************
  2. * Driver for Solarflare Solarstorm network controllers and boards
  3. * Copyright 2005-2006 Fen Systems Ltd.
  4. * Copyright 2006-2008 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_FALCON_H
  11. #define EFX_FALCON_H
  12. #include <linux/i2c-algo-bit.h>
  13. #include "net_driver.h"
  14. #include "efx.h"
  15. /*
  16. * Falcon hardware control
  17. */
  18. enum falcon_revision {
  19. FALCON_REV_A0 = 0,
  20. FALCON_REV_A1 = 1,
  21. FALCON_REV_B0 = 2,
  22. };
  23. static inline int falcon_rev(struct efx_nic *efx)
  24. {
  25. return efx->pci_dev->revision;
  26. }
  27. /**
  28. * struct falcon_board - board information
  29. * @type: Board model type
  30. * @major: Major rev. ('A', 'B' ...)
  31. * @minor: Minor rev. (0, 1, ...)
  32. * @init: Allocate resources and initialise peripheral hardware
  33. * @init_phy: Do board-specific PHY initialisation
  34. * @set_id_led: Set state of identifying LED or revert to automatic function
  35. * @monitor: Board-specific health check function
  36. * @fini: Shut down hardware and free resources
  37. * @i2c_adap: I2C adapter for on-board peripherals
  38. * @i2c_data: Data for bit-banging algorithm
  39. * @hwmon_client: I2C client for hardware monitor
  40. * @ioexp_client: I2C client for power/port control
  41. */
  42. struct falcon_board {
  43. int type;
  44. int major;
  45. int minor;
  46. int (*init) (struct efx_nic *nic);
  47. void (*init_phy) (struct efx_nic *efx);
  48. void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
  49. int (*monitor) (struct efx_nic *nic);
  50. void (*fini) (struct efx_nic *nic);
  51. struct i2c_adapter i2c_adap;
  52. struct i2c_algo_bit_data i2c_data;
  53. struct i2c_client *hwmon_client, *ioexp_client;
  54. };
  55. /**
  56. * struct falcon_nic_data - Falcon NIC state
  57. * @pci_dev2: The secondary PCI device if present
  58. * @board: Board state and functions
  59. */
  60. struct falcon_nic_data {
  61. struct pci_dev *pci_dev2;
  62. struct falcon_board board;
  63. };
  64. static inline struct falcon_board *falcon_board(struct efx_nic *efx)
  65. {
  66. struct falcon_nic_data *data = efx->nic_data;
  67. return &data->board;
  68. }
  69. extern struct efx_nic_type falcon_a_nic_type;
  70. extern struct efx_nic_type falcon_b_nic_type;
  71. /**************************************************************************
  72. *
  73. * Externs
  74. *
  75. **************************************************************************
  76. */
  77. extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info);
  78. /* TX data path */
  79. extern int falcon_probe_tx(struct efx_tx_queue *tx_queue);
  80. extern void falcon_init_tx(struct efx_tx_queue *tx_queue);
  81. extern void falcon_fini_tx(struct efx_tx_queue *tx_queue);
  82. extern void falcon_remove_tx(struct efx_tx_queue *tx_queue);
  83. extern void falcon_push_buffers(struct efx_tx_queue *tx_queue);
  84. /* RX data path */
  85. extern int falcon_probe_rx(struct efx_rx_queue *rx_queue);
  86. extern void falcon_init_rx(struct efx_rx_queue *rx_queue);
  87. extern void falcon_fini_rx(struct efx_rx_queue *rx_queue);
  88. extern void falcon_remove_rx(struct efx_rx_queue *rx_queue);
  89. extern void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue);
  90. /* Event data path */
  91. extern int falcon_probe_eventq(struct efx_channel *channel);
  92. extern void falcon_init_eventq(struct efx_channel *channel);
  93. extern void falcon_fini_eventq(struct efx_channel *channel);
  94. extern void falcon_remove_eventq(struct efx_channel *channel);
  95. extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota);
  96. extern void falcon_eventq_read_ack(struct efx_channel *channel);
  97. /* Ports */
  98. extern int falcon_probe_port(struct efx_nic *efx);
  99. extern void falcon_remove_port(struct efx_nic *efx);
  100. /* MAC/PHY */
  101. extern int falcon_switch_mac(struct efx_nic *efx);
  102. extern bool falcon_xaui_link_ok(struct efx_nic *efx);
  103. extern int falcon_dma_stats(struct efx_nic *efx,
  104. unsigned int done_offset);
  105. extern void falcon_drain_tx_fifo(struct efx_nic *efx);
  106. extern void falcon_deconfigure_mac_wrapper(struct efx_nic *efx);
  107. extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
  108. /* Interrupts and test events */
  109. extern int falcon_init_interrupt(struct efx_nic *efx);
  110. extern void falcon_enable_interrupts(struct efx_nic *efx);
  111. extern void falcon_generate_test_event(struct efx_channel *channel,
  112. unsigned int magic);
  113. extern void falcon_sim_phy_event(struct efx_nic *efx);
  114. extern void falcon_generate_interrupt(struct efx_nic *efx);
  115. extern void falcon_set_int_moderation(struct efx_channel *channel);
  116. extern void falcon_disable_interrupts(struct efx_nic *efx);
  117. extern void falcon_fini_interrupt(struct efx_nic *efx);
  118. #define FALCON_IRQ_MOD_RESOLUTION 5
  119. /* Global Resources */
  120. extern int falcon_probe_nic(struct efx_nic *efx);
  121. extern int falcon_init_nic(struct efx_nic *efx);
  122. extern int falcon_flush_queues(struct efx_nic *efx);
  123. extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);
  124. extern void falcon_remove_nic(struct efx_nic *efx);
  125. extern void falcon_update_nic_stats(struct efx_nic *efx);
  126. extern void falcon_set_multicast_hash(struct efx_nic *efx);
  127. extern int falcon_reset_xaui(struct efx_nic *efx);
  128. /* Tests */
  129. struct falcon_nvconfig;
  130. extern int falcon_read_nvram(struct efx_nic *efx,
  131. struct falcon_nvconfig *nvconfig);
  132. extern int falcon_test_registers(struct efx_nic *efx);
  133. /**************************************************************************
  134. *
  135. * Falcon MAC stats
  136. *
  137. **************************************************************************
  138. */
  139. #define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
  140. #define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
  141. /* Retrieve statistic from statistics block */
  142. #define FALCON_STAT(efx, falcon_stat, efx_stat) do { \
  143. if (FALCON_STAT_WIDTH(falcon_stat) == 16) \
  144. (efx)->mac_stats.efx_stat += le16_to_cpu( \
  145. *((__force __le16 *) \
  146. (efx->stats_buffer.addr + \
  147. FALCON_STAT_OFFSET(falcon_stat)))); \
  148. else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \
  149. (efx)->mac_stats.efx_stat += le32_to_cpu( \
  150. *((__force __le32 *) \
  151. (efx->stats_buffer.addr + \
  152. FALCON_STAT_OFFSET(falcon_stat)))); \
  153. else \
  154. (efx)->mac_stats.efx_stat += le64_to_cpu( \
  155. *((__force __le64 *) \
  156. (efx->stats_buffer.addr + \
  157. FALCON_STAT_OFFSET(falcon_stat)))); \
  158. } while (0)
  159. #define FALCON_MAC_STATS_SIZE 0x100
  160. #define MAC_DATA_LBN 0
  161. #define MAC_DATA_WIDTH 32
  162. extern void falcon_generate_event(struct efx_channel *channel,
  163. efx_qword_t *event);
  164. #endif /* EFX_FALCON_H */