nic.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /****************************************************************************
  3. * Driver for Solarflare network controllers and boards
  4. * Copyright 2005-2006 Fen Systems Ltd.
  5. * Copyright 2006-2013 Solarflare Communications Inc.
  6. */
  7. #ifndef EFX_NIC_H
  8. #define EFX_NIC_H
  9. #include "nic_common.h"
  10. #include "efx.h"
  11. u32 efx_farch_fpga_ver(struct efx_nic *efx);
  12. enum {
  13. PHY_TYPE_NONE = 0,
  14. PHY_TYPE_TXC43128 = 1,
  15. PHY_TYPE_88E1111 = 2,
  16. PHY_TYPE_SFX7101 = 3,
  17. PHY_TYPE_QT2022C2 = 4,
  18. PHY_TYPE_PM8358 = 6,
  19. PHY_TYPE_SFT9001A = 8,
  20. PHY_TYPE_QT2025C = 9,
  21. PHY_TYPE_SFT9001B = 10,
  22. };
  23. enum {
  24. SIENA_STAT_tx_bytes = GENERIC_STAT_COUNT,
  25. SIENA_STAT_tx_good_bytes,
  26. SIENA_STAT_tx_bad_bytes,
  27. SIENA_STAT_tx_packets,
  28. SIENA_STAT_tx_bad,
  29. SIENA_STAT_tx_pause,
  30. SIENA_STAT_tx_control,
  31. SIENA_STAT_tx_unicast,
  32. SIENA_STAT_tx_multicast,
  33. SIENA_STAT_tx_broadcast,
  34. SIENA_STAT_tx_lt64,
  35. SIENA_STAT_tx_64,
  36. SIENA_STAT_tx_65_to_127,
  37. SIENA_STAT_tx_128_to_255,
  38. SIENA_STAT_tx_256_to_511,
  39. SIENA_STAT_tx_512_to_1023,
  40. SIENA_STAT_tx_1024_to_15xx,
  41. SIENA_STAT_tx_15xx_to_jumbo,
  42. SIENA_STAT_tx_gtjumbo,
  43. SIENA_STAT_tx_collision,
  44. SIENA_STAT_tx_single_collision,
  45. SIENA_STAT_tx_multiple_collision,
  46. SIENA_STAT_tx_excessive_collision,
  47. SIENA_STAT_tx_deferred,
  48. SIENA_STAT_tx_late_collision,
  49. SIENA_STAT_tx_excessive_deferred,
  50. SIENA_STAT_tx_non_tcpudp,
  51. SIENA_STAT_tx_mac_src_error,
  52. SIENA_STAT_tx_ip_src_error,
  53. SIENA_STAT_rx_bytes,
  54. SIENA_STAT_rx_good_bytes,
  55. SIENA_STAT_rx_bad_bytes,
  56. SIENA_STAT_rx_packets,
  57. SIENA_STAT_rx_good,
  58. SIENA_STAT_rx_bad,
  59. SIENA_STAT_rx_pause,
  60. SIENA_STAT_rx_control,
  61. SIENA_STAT_rx_unicast,
  62. SIENA_STAT_rx_multicast,
  63. SIENA_STAT_rx_broadcast,
  64. SIENA_STAT_rx_lt64,
  65. SIENA_STAT_rx_64,
  66. SIENA_STAT_rx_65_to_127,
  67. SIENA_STAT_rx_128_to_255,
  68. SIENA_STAT_rx_256_to_511,
  69. SIENA_STAT_rx_512_to_1023,
  70. SIENA_STAT_rx_1024_to_15xx,
  71. SIENA_STAT_rx_15xx_to_jumbo,
  72. SIENA_STAT_rx_gtjumbo,
  73. SIENA_STAT_rx_bad_gtjumbo,
  74. SIENA_STAT_rx_overflow,
  75. SIENA_STAT_rx_false_carrier,
  76. SIENA_STAT_rx_symbol_error,
  77. SIENA_STAT_rx_align_error,
  78. SIENA_STAT_rx_length_error,
  79. SIENA_STAT_rx_internal_error,
  80. SIENA_STAT_rx_nodesc_drop_cnt,
  81. SIENA_STAT_COUNT
  82. };
  83. /**
  84. * struct siena_nic_data - Siena NIC state
  85. * @efx: Pointer back to main interface structure
  86. * @wol_filter_id: Wake-on-LAN packet filter id
  87. * @stats: Hardware statistics
  88. * @vf: Array of &struct siena_vf objects
  89. * @vf_buftbl_base: The zeroth buffer table index used to back VF queues.
  90. * @vfdi_status: Common VFDI status page to be dmad to VF address space.
  91. * @local_addr_list: List of local addresses. Protected by %local_lock.
  92. * @local_page_list: List of DMA addressable pages used to broadcast
  93. * %local_addr_list. Protected by %local_lock.
  94. * @local_lock: Mutex protecting %local_addr_list and %local_page_list.
  95. * @peer_work: Work item to broadcast peer addresses to VMs.
  96. */
  97. struct siena_nic_data {
  98. struct efx_nic *efx;
  99. int wol_filter_id;
  100. u64 stats[SIENA_STAT_COUNT];
  101. #ifdef CONFIG_SFC_SIENA_SRIOV
  102. struct siena_vf *vf;
  103. struct efx_channel *vfdi_channel;
  104. unsigned vf_buftbl_base;
  105. struct efx_buffer vfdi_status;
  106. struct list_head local_addr_list;
  107. struct list_head local_page_list;
  108. struct mutex local_lock;
  109. struct work_struct peer_work;
  110. #endif
  111. };
  112. extern const struct efx_nic_type siena_a0_nic_type;
  113. int falcon_probe_board(struct efx_nic *efx, u16 revision_info);
  114. /* Falcon/Siena queue operations */
  115. int efx_farch_tx_probe(struct efx_tx_queue *tx_queue);
  116. void efx_farch_tx_init(struct efx_tx_queue *tx_queue);
  117. void efx_farch_tx_fini(struct efx_tx_queue *tx_queue);
  118. void efx_farch_tx_remove(struct efx_tx_queue *tx_queue);
  119. void efx_farch_tx_write(struct efx_tx_queue *tx_queue);
  120. unsigned int efx_farch_tx_limit_len(struct efx_tx_queue *tx_queue,
  121. dma_addr_t dma_addr, unsigned int len);
  122. int efx_farch_rx_probe(struct efx_rx_queue *rx_queue);
  123. void efx_farch_rx_init(struct efx_rx_queue *rx_queue);
  124. void efx_farch_rx_fini(struct efx_rx_queue *rx_queue);
  125. void efx_farch_rx_remove(struct efx_rx_queue *rx_queue);
  126. void efx_farch_rx_write(struct efx_rx_queue *rx_queue);
  127. void efx_farch_rx_defer_refill(struct efx_rx_queue *rx_queue);
  128. int efx_farch_ev_probe(struct efx_channel *channel);
  129. int efx_farch_ev_init(struct efx_channel *channel);
  130. void efx_farch_ev_fini(struct efx_channel *channel);
  131. void efx_farch_ev_remove(struct efx_channel *channel);
  132. int efx_farch_ev_process(struct efx_channel *channel, int quota);
  133. void efx_farch_ev_read_ack(struct efx_channel *channel);
  134. void efx_farch_ev_test_generate(struct efx_channel *channel);
  135. /* Falcon/Siena filter operations */
  136. int efx_farch_filter_table_probe(struct efx_nic *efx);
  137. void efx_farch_filter_table_restore(struct efx_nic *efx);
  138. void efx_farch_filter_table_remove(struct efx_nic *efx);
  139. void efx_farch_filter_update_rx_scatter(struct efx_nic *efx);
  140. s32 efx_farch_filter_insert(struct efx_nic *efx, struct efx_filter_spec *spec,
  141. bool replace);
  142. int efx_farch_filter_remove_safe(struct efx_nic *efx,
  143. enum efx_filter_priority priority,
  144. u32 filter_id);
  145. int efx_farch_filter_get_safe(struct efx_nic *efx,
  146. enum efx_filter_priority priority, u32 filter_id,
  147. struct efx_filter_spec *);
  148. int efx_farch_filter_clear_rx(struct efx_nic *efx,
  149. enum efx_filter_priority priority);
  150. u32 efx_farch_filter_count_rx_used(struct efx_nic *efx,
  151. enum efx_filter_priority priority);
  152. u32 efx_farch_filter_get_rx_id_limit(struct efx_nic *efx);
  153. s32 efx_farch_filter_get_rx_ids(struct efx_nic *efx,
  154. enum efx_filter_priority priority, u32 *buf,
  155. u32 size);
  156. #ifdef CONFIG_RFS_ACCEL
  157. bool efx_farch_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id,
  158. unsigned int index);
  159. #endif
  160. void efx_farch_filter_sync_rx_mode(struct efx_nic *efx);
  161. /* Falcon/Siena interrupts */
  162. void efx_farch_irq_enable_master(struct efx_nic *efx);
  163. int efx_farch_irq_test_generate(struct efx_nic *efx);
  164. void efx_farch_irq_disable_master(struct efx_nic *efx);
  165. irqreturn_t efx_farch_msi_interrupt(int irq, void *dev_id);
  166. irqreturn_t efx_farch_legacy_interrupt(int irq, void *dev_id);
  167. irqreturn_t efx_farch_fatal_interrupt(struct efx_nic *efx);
  168. /* Global Resources */
  169. void efx_siena_prepare_flush(struct efx_nic *efx);
  170. int efx_farch_fini_dmaq(struct efx_nic *efx);
  171. void efx_farch_finish_flr(struct efx_nic *efx);
  172. void siena_finish_flush(struct efx_nic *efx);
  173. void falcon_start_nic_stats(struct efx_nic *efx);
  174. void falcon_stop_nic_stats(struct efx_nic *efx);
  175. int falcon_reset_xaui(struct efx_nic *efx);
  176. void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw);
  177. void efx_farch_init_common(struct efx_nic *efx);
  178. void efx_farch_rx_push_indir_table(struct efx_nic *efx);
  179. void efx_farch_rx_pull_indir_table(struct efx_nic *efx);
  180. /* Tests */
  181. struct efx_farch_register_test {
  182. unsigned address;
  183. efx_oword_t mask;
  184. };
  185. int efx_farch_test_registers(struct efx_nic *efx,
  186. const struct efx_farch_register_test *regs,
  187. size_t n_regs);
  188. void efx_farch_generate_event(struct efx_nic *efx, unsigned int evq,
  189. efx_qword_t *event);
  190. #endif /* EFX_NIC_H */