falcon.h 4.9 KB

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