falcon.h 6.7 KB

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