falcon.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 "net_driver.h"
  13. #include "efx.h"
  14. /*
  15. * Falcon hardware control
  16. */
  17. enum falcon_revision {
  18. FALCON_REV_A0 = 0,
  19. FALCON_REV_A1 = 1,
  20. FALCON_REV_B0 = 2,
  21. };
  22. static inline int falcon_rev(struct efx_nic *efx)
  23. {
  24. return efx->pci_dev->revision;
  25. }
  26. extern struct efx_nic_type falcon_a_nic_type;
  27. extern struct efx_nic_type falcon_b_nic_type;
  28. /**************************************************************************
  29. *
  30. * Externs
  31. *
  32. **************************************************************************
  33. */
  34. /* TX data path */
  35. extern int falcon_probe_tx(struct efx_tx_queue *tx_queue);
  36. extern void falcon_init_tx(struct efx_tx_queue *tx_queue);
  37. extern void falcon_fini_tx(struct efx_tx_queue *tx_queue);
  38. extern void falcon_remove_tx(struct efx_tx_queue *tx_queue);
  39. extern void falcon_push_buffers(struct efx_tx_queue *tx_queue);
  40. /* RX data path */
  41. extern int falcon_probe_rx(struct efx_rx_queue *rx_queue);
  42. extern void falcon_init_rx(struct efx_rx_queue *rx_queue);
  43. extern void falcon_fini_rx(struct efx_rx_queue *rx_queue);
  44. extern void falcon_remove_rx(struct efx_rx_queue *rx_queue);
  45. extern void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue);
  46. /* Event data path */
  47. extern int falcon_probe_eventq(struct efx_channel *channel);
  48. extern void falcon_init_eventq(struct efx_channel *channel);
  49. extern void falcon_fini_eventq(struct efx_channel *channel);
  50. extern void falcon_remove_eventq(struct efx_channel *channel);
  51. extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota);
  52. extern void falcon_eventq_read_ack(struct efx_channel *channel);
  53. /* Ports */
  54. extern int falcon_probe_port(struct efx_nic *efx);
  55. extern void falcon_remove_port(struct efx_nic *efx);
  56. /* MAC/PHY */
  57. extern int falcon_switch_mac(struct efx_nic *efx);
  58. extern bool falcon_xaui_link_ok(struct efx_nic *efx);
  59. extern int falcon_dma_stats(struct efx_nic *efx,
  60. unsigned int done_offset);
  61. extern void falcon_drain_tx_fifo(struct efx_nic *efx);
  62. extern void falcon_deconfigure_mac_wrapper(struct efx_nic *efx);
  63. extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
  64. /* Interrupts and test events */
  65. extern int falcon_init_interrupt(struct efx_nic *efx);
  66. extern void falcon_enable_interrupts(struct efx_nic *efx);
  67. extern void falcon_generate_test_event(struct efx_channel *channel,
  68. unsigned int magic);
  69. extern void falcon_sim_phy_event(struct efx_nic *efx);
  70. extern void falcon_generate_interrupt(struct efx_nic *efx);
  71. extern void falcon_set_int_moderation(struct efx_channel *channel);
  72. extern void falcon_disable_interrupts(struct efx_nic *efx);
  73. extern void falcon_fini_interrupt(struct efx_nic *efx);
  74. #define FALCON_IRQ_MOD_RESOLUTION 5
  75. /* Global Resources */
  76. extern int falcon_probe_nic(struct efx_nic *efx);
  77. extern int falcon_probe_resources(struct efx_nic *efx);
  78. extern int falcon_init_nic(struct efx_nic *efx);
  79. extern int falcon_flush_queues(struct efx_nic *efx);
  80. extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);
  81. extern void falcon_remove_resources(struct efx_nic *efx);
  82. extern void falcon_remove_nic(struct efx_nic *efx);
  83. extern void falcon_update_nic_stats(struct efx_nic *efx);
  84. extern void falcon_set_multicast_hash(struct efx_nic *efx);
  85. extern int falcon_reset_xaui(struct efx_nic *efx);
  86. /* Tests */
  87. struct falcon_nvconfig;
  88. extern int falcon_read_nvram(struct efx_nic *efx,
  89. struct falcon_nvconfig *nvconfig);
  90. extern int falcon_test_registers(struct efx_nic *efx);
  91. /**************************************************************************
  92. *
  93. * Falcon MAC stats
  94. *
  95. **************************************************************************
  96. */
  97. #define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
  98. #define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
  99. /* Retrieve statistic from statistics block */
  100. #define FALCON_STAT(efx, falcon_stat, efx_stat) do { \
  101. if (FALCON_STAT_WIDTH(falcon_stat) == 16) \
  102. (efx)->mac_stats.efx_stat += le16_to_cpu( \
  103. *((__force __le16 *) \
  104. (efx->stats_buffer.addr + \
  105. FALCON_STAT_OFFSET(falcon_stat)))); \
  106. else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \
  107. (efx)->mac_stats.efx_stat += le32_to_cpu( \
  108. *((__force __le32 *) \
  109. (efx->stats_buffer.addr + \
  110. FALCON_STAT_OFFSET(falcon_stat)))); \
  111. else \
  112. (efx)->mac_stats.efx_stat += le64_to_cpu( \
  113. *((__force __le64 *) \
  114. (efx->stats_buffer.addr + \
  115. FALCON_STAT_OFFSET(falcon_stat)))); \
  116. } while (0)
  117. #define FALCON_MAC_STATS_SIZE 0x100
  118. #define MAC_DATA_LBN 0
  119. #define MAC_DATA_WIDTH 32
  120. extern void falcon_generate_event(struct efx_channel *channel,
  121. efx_qword_t *event);
  122. #endif /* EFX_FALCON_H */