igc_hw.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2018 Intel Corporation */
  3. #ifndef _IGC_HW_H_
  4. #define _IGC_HW_H_
  5. #include <linux/types.h>
  6. #include <linux/if_ether.h>
  7. #include <linux/netdevice.h>
  8. #include "igc_regs.h"
  9. #include "igc_defines.h"
  10. #include "igc_mac.h"
  11. #include "igc_phy.h"
  12. #include "igc_nvm.h"
  13. #include "igc_i225.h"
  14. #include "igc_base.h"
  15. #define IGC_DEV_ID_I225_LM 0x15F2
  16. #define IGC_DEV_ID_I225_V 0x15F3
  17. #define IGC_DEV_ID_I225_I 0x15F8
  18. #define IGC_DEV_ID_I220_V 0x15F7
  19. #define IGC_DEV_ID_I225_K 0x3100
  20. #define IGC_DEV_ID_I225_K2 0x3101
  21. #define IGC_DEV_ID_I226_K 0x3102
  22. #define IGC_DEV_ID_I225_LMVP 0x5502
  23. #define IGC_DEV_ID_I226_LMVP 0x5503
  24. #define IGC_DEV_ID_I225_IT 0x0D9F
  25. #define IGC_DEV_ID_I226_LM 0x125B
  26. #define IGC_DEV_ID_I226_V 0x125C
  27. #define IGC_DEV_ID_I226_IT 0x125D
  28. #define IGC_DEV_ID_I221_V 0x125E
  29. #define IGC_DEV_ID_I226_BLANK_NVM 0x125F
  30. #define IGC_DEV_ID_I225_BLANK_NVM 0x15FD
  31. /* Function pointers for the MAC. */
  32. struct igc_mac_operations {
  33. s32 (*check_for_link)(struct igc_hw *hw);
  34. s32 (*reset_hw)(struct igc_hw *hw);
  35. s32 (*init_hw)(struct igc_hw *hw);
  36. s32 (*setup_physical_interface)(struct igc_hw *hw);
  37. void (*rar_set)(struct igc_hw *hw, u8 *address, u32 index);
  38. s32 (*read_mac_addr)(struct igc_hw *hw);
  39. s32 (*get_speed_and_duplex)(struct igc_hw *hw, u16 *speed,
  40. u16 *duplex);
  41. s32 (*acquire_swfw_sync)(struct igc_hw *hw, u16 mask);
  42. void (*release_swfw_sync)(struct igc_hw *hw, u16 mask);
  43. };
  44. enum igc_mac_type {
  45. igc_undefined = 0,
  46. igc_i225,
  47. igc_num_macs /* List is 1-based, so subtract 1 for true count. */
  48. };
  49. enum igc_media_type {
  50. igc_media_type_unknown = 0,
  51. igc_media_type_copper = 1,
  52. igc_num_media_types
  53. };
  54. enum igc_nvm_type {
  55. igc_nvm_unknown = 0,
  56. igc_nvm_eeprom_spi,
  57. };
  58. struct igc_info {
  59. s32 (*get_invariants)(struct igc_hw *hw);
  60. struct igc_mac_operations *mac_ops;
  61. const struct igc_phy_operations *phy_ops;
  62. struct igc_nvm_operations *nvm_ops;
  63. };
  64. extern const struct igc_info igc_base_info;
  65. struct igc_mac_info {
  66. struct igc_mac_operations ops;
  67. u8 addr[ETH_ALEN];
  68. u8 perm_addr[ETH_ALEN];
  69. enum igc_mac_type type;
  70. u32 mc_filter_type;
  71. u16 mta_reg_count;
  72. u16 uta_reg_count;
  73. u32 mta_shadow[MAX_MTA_REG];
  74. u16 rar_entry_count;
  75. bool asf_firmware_present;
  76. bool arc_subsystem_valid;
  77. bool autoneg_failed;
  78. bool get_link_status;
  79. };
  80. struct igc_nvm_operations {
  81. s32 (*acquire)(struct igc_hw *hw);
  82. s32 (*read)(struct igc_hw *hw, u16 offset, u16 i, u16 *data);
  83. void (*release)(struct igc_hw *hw);
  84. s32 (*write)(struct igc_hw *hw, u16 offset, u16 i, u16 *data);
  85. s32 (*update)(struct igc_hw *hw);
  86. s32 (*validate)(struct igc_hw *hw);
  87. };
  88. struct igc_phy_operations {
  89. s32 (*acquire)(struct igc_hw *hw);
  90. s32 (*check_reset_block)(struct igc_hw *hw);
  91. s32 (*force_speed_duplex)(struct igc_hw *hw);
  92. s32 (*get_phy_info)(struct igc_hw *hw);
  93. s32 (*read_reg)(struct igc_hw *hw, u32 address, u16 *data);
  94. void (*release)(struct igc_hw *hw);
  95. s32 (*reset)(struct igc_hw *hw);
  96. s32 (*write_reg)(struct igc_hw *hw, u32 address, u16 data);
  97. };
  98. struct igc_nvm_info {
  99. struct igc_nvm_operations ops;
  100. enum igc_nvm_type type;
  101. u16 word_size;
  102. u16 delay_usec;
  103. u16 address_bits;
  104. u16 opcode_bits;
  105. u16 page_size;
  106. };
  107. struct igc_phy_info {
  108. struct igc_phy_operations ops;
  109. u32 addr;
  110. u32 id;
  111. u32 reset_delay_us; /* in usec */
  112. u32 revision;
  113. enum igc_media_type media_type;
  114. u16 autoneg_advertised;
  115. u16 autoneg_mask;
  116. u8 mdix;
  117. bool is_mdix;
  118. bool speed_downgraded;
  119. bool autoneg_wait_to_complete;
  120. };
  121. struct igc_bus_info {
  122. u16 func;
  123. u16 pci_cmd_word;
  124. };
  125. enum igc_fc_mode {
  126. igc_fc_none = 0,
  127. igc_fc_rx_pause,
  128. igc_fc_tx_pause,
  129. igc_fc_full,
  130. igc_fc_default = 0xFF
  131. };
  132. struct igc_fc_info {
  133. u32 high_water; /* Flow control high-water mark */
  134. u32 low_water; /* Flow control low-water mark */
  135. u16 pause_time; /* Flow control pause timer */
  136. bool send_xon; /* Flow control send XON */
  137. bool strict_ieee; /* Strict IEEE mode */
  138. enum igc_fc_mode current_mode; /* Type of flow control */
  139. enum igc_fc_mode requested_mode;
  140. };
  141. struct igc_dev_spec_base {
  142. bool clear_semaphore_once;
  143. bool eee_enable;
  144. };
  145. struct igc_hw {
  146. void *back;
  147. u8 __iomem *hw_addr;
  148. unsigned long io_base;
  149. struct igc_mac_info mac;
  150. struct igc_fc_info fc;
  151. struct igc_nvm_info nvm;
  152. struct igc_phy_info phy;
  153. struct igc_bus_info bus;
  154. union {
  155. struct igc_dev_spec_base _base;
  156. } dev_spec;
  157. u16 device_id;
  158. u16 subsystem_vendor_id;
  159. u16 subsystem_device_id;
  160. u16 vendor_id;
  161. u8 revision_id;
  162. };
  163. /* Statistics counters collected by the MAC */
  164. struct igc_hw_stats {
  165. u64 crcerrs;
  166. u64 algnerrc;
  167. u64 symerrs;
  168. u64 rxerrc;
  169. u64 mpc;
  170. u64 scc;
  171. u64 ecol;
  172. u64 mcc;
  173. u64 latecol;
  174. u64 colc;
  175. u64 dc;
  176. u64 tncrs;
  177. u64 sec;
  178. u64 cexterr;
  179. u64 rlec;
  180. u64 xonrxc;
  181. u64 xontxc;
  182. u64 xoffrxc;
  183. u64 xofftxc;
  184. u64 fcruc;
  185. u64 prc64;
  186. u64 prc127;
  187. u64 prc255;
  188. u64 prc511;
  189. u64 prc1023;
  190. u64 prc1522;
  191. u64 tlpic;
  192. u64 rlpic;
  193. u64 gprc;
  194. u64 bprc;
  195. u64 mprc;
  196. u64 gptc;
  197. u64 gorc;
  198. u64 gotc;
  199. u64 rnbc;
  200. u64 ruc;
  201. u64 rfc;
  202. u64 roc;
  203. u64 rjc;
  204. u64 mgprc;
  205. u64 mgpdc;
  206. u64 mgptc;
  207. u64 tor;
  208. u64 tot;
  209. u64 tpr;
  210. u64 tpt;
  211. u64 ptc64;
  212. u64 ptc127;
  213. u64 ptc255;
  214. u64 ptc511;
  215. u64 ptc1023;
  216. u64 ptc1522;
  217. u64 mptc;
  218. u64 bptc;
  219. u64 tsctc;
  220. u64 tsctfc;
  221. u64 iac;
  222. u64 htdpmc;
  223. u64 rpthc;
  224. u64 hgptc;
  225. u64 hgorc;
  226. u64 hgotc;
  227. u64 lenerrs;
  228. u64 scvpc;
  229. u64 hrmpc;
  230. u64 doosync;
  231. u64 o2bgptc;
  232. u64 o2bspc;
  233. u64 b2ospc;
  234. u64 b2ogprc;
  235. u64 txdrop;
  236. };
  237. struct net_device *igc_get_hw_dev(struct igc_hw *hw);
  238. #define hw_dbg(format, arg...) \
  239. netdev_dbg(igc_get_hw_dev(hw), format, ##arg)
  240. #endif /* _IGC_HW_H_ */