falcon.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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_nic_data - Falcon NIC state
  29. * @pci_dev2: The secondary PCI device if present
  30. * @i2c_data: Operations and state for I2C bit-bashing algorithm
  31. */
  32. struct falcon_nic_data {
  33. struct pci_dev *pci_dev2;
  34. struct i2c_algo_bit_data i2c_data;
  35. };
  36. static inline struct falcon_board *falcon_board(struct efx_nic *efx)
  37. {
  38. return &efx->board_info;
  39. }
  40. extern struct efx_nic_type falcon_a_nic_type;
  41. extern struct efx_nic_type falcon_b_nic_type;
  42. /**************************************************************************
  43. *
  44. * Externs
  45. *
  46. **************************************************************************
  47. */
  48. extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info);
  49. /* TX data path */
  50. extern int falcon_probe_tx(struct efx_tx_queue *tx_queue);
  51. extern void falcon_init_tx(struct efx_tx_queue *tx_queue);
  52. extern void falcon_fini_tx(struct efx_tx_queue *tx_queue);
  53. extern void falcon_remove_tx(struct efx_tx_queue *tx_queue);
  54. extern void falcon_push_buffers(struct efx_tx_queue *tx_queue);
  55. /* RX data path */
  56. extern int falcon_probe_rx(struct efx_rx_queue *rx_queue);
  57. extern void falcon_init_rx(struct efx_rx_queue *rx_queue);
  58. extern void falcon_fini_rx(struct efx_rx_queue *rx_queue);
  59. extern void falcon_remove_rx(struct efx_rx_queue *rx_queue);
  60. extern void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue);
  61. /* Event data path */
  62. extern int falcon_probe_eventq(struct efx_channel *channel);
  63. extern void falcon_init_eventq(struct efx_channel *channel);
  64. extern void falcon_fini_eventq(struct efx_channel *channel);
  65. extern void falcon_remove_eventq(struct efx_channel *channel);
  66. extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota);
  67. extern void falcon_eventq_read_ack(struct efx_channel *channel);
  68. /* Ports */
  69. extern int falcon_probe_port(struct efx_nic *efx);
  70. extern void falcon_remove_port(struct efx_nic *efx);
  71. /* MAC/PHY */
  72. extern int falcon_switch_mac(struct efx_nic *efx);
  73. extern bool falcon_xaui_link_ok(struct efx_nic *efx);
  74. extern int falcon_dma_stats(struct efx_nic *efx,
  75. unsigned int done_offset);
  76. extern void falcon_drain_tx_fifo(struct efx_nic *efx);
  77. extern void falcon_deconfigure_mac_wrapper(struct efx_nic *efx);
  78. extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
  79. /* Interrupts and test events */
  80. extern int falcon_init_interrupt(struct efx_nic *efx);
  81. extern void falcon_enable_interrupts(struct efx_nic *efx);
  82. extern void falcon_generate_test_event(struct efx_channel *channel,
  83. unsigned int magic);
  84. extern void falcon_sim_phy_event(struct efx_nic *efx);
  85. extern void falcon_generate_interrupt(struct efx_nic *efx);
  86. extern void falcon_set_int_moderation(struct efx_channel *channel);
  87. extern void falcon_disable_interrupts(struct efx_nic *efx);
  88. extern void falcon_fini_interrupt(struct efx_nic *efx);
  89. #define FALCON_IRQ_MOD_RESOLUTION 5
  90. /* Global Resources */
  91. extern int falcon_probe_nic(struct efx_nic *efx);
  92. extern int falcon_init_nic(struct efx_nic *efx);
  93. extern int falcon_flush_queues(struct efx_nic *efx);
  94. extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);
  95. extern void falcon_remove_nic(struct efx_nic *efx);
  96. extern void falcon_update_nic_stats(struct efx_nic *efx);
  97. extern void falcon_set_multicast_hash(struct efx_nic *efx);
  98. extern int falcon_reset_xaui(struct efx_nic *efx);
  99. /* Tests */
  100. struct falcon_nvconfig;
  101. extern int falcon_read_nvram(struct efx_nic *efx,
  102. struct falcon_nvconfig *nvconfig);
  103. extern int falcon_test_registers(struct efx_nic *efx);
  104. /**************************************************************************
  105. *
  106. * Falcon MAC stats
  107. *
  108. **************************************************************************
  109. */
  110. #define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
  111. #define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
  112. /* Retrieve statistic from statistics block */
  113. #define FALCON_STAT(efx, falcon_stat, efx_stat) do { \
  114. if (FALCON_STAT_WIDTH(falcon_stat) == 16) \
  115. (efx)->mac_stats.efx_stat += le16_to_cpu( \
  116. *((__force __le16 *) \
  117. (efx->stats_buffer.addr + \
  118. FALCON_STAT_OFFSET(falcon_stat)))); \
  119. else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \
  120. (efx)->mac_stats.efx_stat += le32_to_cpu( \
  121. *((__force __le32 *) \
  122. (efx->stats_buffer.addr + \
  123. FALCON_STAT_OFFSET(falcon_stat)))); \
  124. else \
  125. (efx)->mac_stats.efx_stat += le64_to_cpu( \
  126. *((__force __le64 *) \
  127. (efx->stats_buffer.addr + \
  128. FALCON_STAT_OFFSET(falcon_stat)))); \
  129. } while (0)
  130. #define FALCON_MAC_STATS_SIZE 0x100
  131. #define MAC_DATA_LBN 0
  132. #define MAC_DATA_WIDTH 32
  133. extern void falcon_generate_event(struct efx_channel *channel,
  134. efx_qword_t *event);
  135. #endif /* EFX_FALCON_H */