nic.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. enum {
  12. PHY_TYPE_NONE = 0,
  13. PHY_TYPE_TXC43128 = 1,
  14. PHY_TYPE_88E1111 = 2,
  15. PHY_TYPE_SFX7101 = 3,
  16. PHY_TYPE_QT2022C2 = 4,
  17. PHY_TYPE_PM8358 = 6,
  18. PHY_TYPE_SFT9001A = 8,
  19. PHY_TYPE_QT2025C = 9,
  20. PHY_TYPE_SFT9001B = 10,
  21. };
  22. enum {
  23. EF10_STAT_port_tx_bytes = GENERIC_STAT_COUNT,
  24. EF10_STAT_port_tx_packets,
  25. EF10_STAT_port_tx_pause,
  26. EF10_STAT_port_tx_control,
  27. EF10_STAT_port_tx_unicast,
  28. EF10_STAT_port_tx_multicast,
  29. EF10_STAT_port_tx_broadcast,
  30. EF10_STAT_port_tx_lt64,
  31. EF10_STAT_port_tx_64,
  32. EF10_STAT_port_tx_65_to_127,
  33. EF10_STAT_port_tx_128_to_255,
  34. EF10_STAT_port_tx_256_to_511,
  35. EF10_STAT_port_tx_512_to_1023,
  36. EF10_STAT_port_tx_1024_to_15xx,
  37. EF10_STAT_port_tx_15xx_to_jumbo,
  38. EF10_STAT_port_rx_bytes,
  39. EF10_STAT_port_rx_bytes_minus_good_bytes,
  40. EF10_STAT_port_rx_good_bytes,
  41. EF10_STAT_port_rx_bad_bytes,
  42. EF10_STAT_port_rx_packets,
  43. EF10_STAT_port_rx_good,
  44. EF10_STAT_port_rx_bad,
  45. EF10_STAT_port_rx_pause,
  46. EF10_STAT_port_rx_control,
  47. EF10_STAT_port_rx_unicast,
  48. EF10_STAT_port_rx_multicast,
  49. EF10_STAT_port_rx_broadcast,
  50. EF10_STAT_port_rx_lt64,
  51. EF10_STAT_port_rx_64,
  52. EF10_STAT_port_rx_65_to_127,
  53. EF10_STAT_port_rx_128_to_255,
  54. EF10_STAT_port_rx_256_to_511,
  55. EF10_STAT_port_rx_512_to_1023,
  56. EF10_STAT_port_rx_1024_to_15xx,
  57. EF10_STAT_port_rx_15xx_to_jumbo,
  58. EF10_STAT_port_rx_gtjumbo,
  59. EF10_STAT_port_rx_bad_gtjumbo,
  60. EF10_STAT_port_rx_overflow,
  61. EF10_STAT_port_rx_align_error,
  62. EF10_STAT_port_rx_length_error,
  63. EF10_STAT_port_rx_nodesc_drops,
  64. EF10_STAT_port_rx_pm_trunc_bb_overflow,
  65. EF10_STAT_port_rx_pm_discard_bb_overflow,
  66. EF10_STAT_port_rx_pm_trunc_vfifo_full,
  67. EF10_STAT_port_rx_pm_discard_vfifo_full,
  68. EF10_STAT_port_rx_pm_trunc_qbb,
  69. EF10_STAT_port_rx_pm_discard_qbb,
  70. EF10_STAT_port_rx_pm_discard_mapping,
  71. EF10_STAT_port_rx_dp_q_disabled_packets,
  72. EF10_STAT_port_rx_dp_di_dropped_packets,
  73. EF10_STAT_port_rx_dp_streaming_packets,
  74. EF10_STAT_port_rx_dp_hlb_fetch,
  75. EF10_STAT_port_rx_dp_hlb_wait,
  76. EF10_STAT_rx_unicast,
  77. EF10_STAT_rx_unicast_bytes,
  78. EF10_STAT_rx_multicast,
  79. EF10_STAT_rx_multicast_bytes,
  80. EF10_STAT_rx_broadcast,
  81. EF10_STAT_rx_broadcast_bytes,
  82. EF10_STAT_rx_bad,
  83. EF10_STAT_rx_bad_bytes,
  84. EF10_STAT_rx_overflow,
  85. EF10_STAT_tx_unicast,
  86. EF10_STAT_tx_unicast_bytes,
  87. EF10_STAT_tx_multicast,
  88. EF10_STAT_tx_multicast_bytes,
  89. EF10_STAT_tx_broadcast,
  90. EF10_STAT_tx_broadcast_bytes,
  91. EF10_STAT_tx_bad,
  92. EF10_STAT_tx_bad_bytes,
  93. EF10_STAT_tx_overflow,
  94. EF10_STAT_V1_COUNT,
  95. EF10_STAT_fec_uncorrected_errors = EF10_STAT_V1_COUNT,
  96. EF10_STAT_fec_corrected_errors,
  97. EF10_STAT_fec_corrected_symbols_lane0,
  98. EF10_STAT_fec_corrected_symbols_lane1,
  99. EF10_STAT_fec_corrected_symbols_lane2,
  100. EF10_STAT_fec_corrected_symbols_lane3,
  101. EF10_STAT_ctpio_vi_busy_fallback,
  102. EF10_STAT_ctpio_long_write_success,
  103. EF10_STAT_ctpio_missing_dbell_fail,
  104. EF10_STAT_ctpio_overflow_fail,
  105. EF10_STAT_ctpio_underflow_fail,
  106. EF10_STAT_ctpio_timeout_fail,
  107. EF10_STAT_ctpio_noncontig_wr_fail,
  108. EF10_STAT_ctpio_frm_clobber_fail,
  109. EF10_STAT_ctpio_invalid_wr_fail,
  110. EF10_STAT_ctpio_vi_clobber_fallback,
  111. EF10_STAT_ctpio_unqualified_fallback,
  112. EF10_STAT_ctpio_runt_fallback,
  113. EF10_STAT_ctpio_success,
  114. EF10_STAT_ctpio_fallback,
  115. EF10_STAT_ctpio_poison,
  116. EF10_STAT_ctpio_erase,
  117. EF10_STAT_COUNT
  118. };
  119. /* Maximum number of TX PIO buffers we may allocate to a function.
  120. * This matches the total number of buffers on each SFC9100-family
  121. * controller.
  122. */
  123. #define EF10_TX_PIOBUF_COUNT 16
  124. /**
  125. * struct efx_ef10_nic_data - EF10 architecture NIC state
  126. * @mcdi_buf: DMA buffer for MCDI
  127. * @warm_boot_count: Last seen MC warm boot count
  128. * @vi_base: Absolute index of first VI in this function
  129. * @n_allocated_vis: Number of VIs allocated to this function
  130. * @n_piobufs: Number of PIO buffers allocated to this function
  131. * @wc_membase: Base address of write-combining mapping of the memory BAR
  132. * @pio_write_base: Base address for writing PIO buffers
  133. * @pio_write_vi_base: Relative VI number for @pio_write_base
  134. * @piobuf_handle: Handle of each PIO buffer allocated
  135. * @piobuf_size: size of a single PIO buffer
  136. * @must_restore_piobufs: Flag: PIO buffers have yet to be restored after MC
  137. * reboot
  138. * @mc_stats: Scratch buffer for converting statistics to the kernel's format
  139. * @stats: Hardware statistics
  140. * @workaround_35388: Flag: firmware supports workaround for bug 35388
  141. * @workaround_26807: Flag: firmware supports workaround for bug 26807
  142. * @workaround_61265: Flag: firmware supports workaround for bug 61265
  143. * @must_check_datapath_caps: Flag: @datapath_caps needs to be revalidated
  144. * after MC reboot
  145. * @datapath_caps: Capabilities of datapath firmware (FLAGS1 field of
  146. * %MC_CMD_GET_CAPABILITIES response)
  147. * @datapath_caps2: Further Capabilities of datapath firmware (FLAGS2 field of
  148. * %MC_CMD_GET_CAPABILITIES response)
  149. * @rx_dpcpu_fw_id: Firmware ID of the RxDPCPU
  150. * @tx_dpcpu_fw_id: Firmware ID of the TxDPCPU
  151. * @must_probe_vswitching: Flag: vswitching has yet to be setup after MC reboot
  152. * @pf_index: The number for this PF, or the parent PF if this is a VF
  153. #ifdef CONFIG_SFC_SRIOV
  154. * @vf: Pointer to VF data structure
  155. #endif
  156. * @vport_mac: The MAC address on the vport, only for PFs; VFs will be zero
  157. * @vlan_list: List of VLANs added over the interface. Serialised by vlan_lock.
  158. * @vlan_lock: Lock to serialize access to vlan_list.
  159. * @udp_tunnels: UDP tunnel port numbers and types.
  160. * @udp_tunnels_dirty: flag indicating a reboot occurred while pushing
  161. * @udp_tunnels to hardware and thus the push must be re-done.
  162. * @udp_tunnels_lock: Serialises writes to @udp_tunnels and @udp_tunnels_dirty.
  163. */
  164. struct efx_ef10_nic_data {
  165. struct efx_buffer mcdi_buf;
  166. u16 warm_boot_count;
  167. unsigned int vi_base;
  168. unsigned int n_allocated_vis;
  169. unsigned int n_piobufs;
  170. void __iomem *wc_membase, *pio_write_base;
  171. unsigned int pio_write_vi_base;
  172. unsigned int piobuf_handle[EF10_TX_PIOBUF_COUNT];
  173. u16 piobuf_size;
  174. bool must_restore_piobufs;
  175. __le64 *mc_stats;
  176. u64 stats[EF10_STAT_COUNT];
  177. bool workaround_35388;
  178. bool workaround_26807;
  179. bool workaround_61265;
  180. bool must_check_datapath_caps;
  181. u32 datapath_caps;
  182. u32 datapath_caps2;
  183. unsigned int rx_dpcpu_fw_id;
  184. unsigned int tx_dpcpu_fw_id;
  185. bool must_probe_vswitching;
  186. unsigned int pf_index;
  187. u8 port_id[ETH_ALEN];
  188. #ifdef CONFIG_SFC_SRIOV
  189. unsigned int vf_index;
  190. struct ef10_vf *vf;
  191. #endif
  192. u8 vport_mac[ETH_ALEN];
  193. struct list_head vlan_list;
  194. struct mutex vlan_lock;
  195. struct efx_udp_tunnel udp_tunnels[16];
  196. bool udp_tunnels_dirty;
  197. struct mutex udp_tunnels_lock;
  198. u64 licensed_features;
  199. };
  200. /* TSOv2 */
  201. int efx_ef10_tx_tso_desc(struct efx_tx_queue *tx_queue, struct sk_buff *skb,
  202. bool *data_mapped);
  203. extern const struct efx_nic_type efx_hunt_a0_nic_type;
  204. extern const struct efx_nic_type efx_hunt_a0_vf_nic_type;
  205. extern const struct efx_nic_type efx_x4_nic_type;
  206. #endif /* EFX_NIC_H */