igc_hw.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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_nvm.h"
  12. #include "igc_i225.h"
  13. #include "igc_base.h"
  14. #define IGC_DEV_ID_I225_LM 0x15F2
  15. #define IGC_DEV_ID_I225_V 0x15F3
  16. /* Function pointers for the MAC. */
  17. struct igc_mac_operations {
  18. s32 (*check_for_link)(struct igc_hw *hw);
  19. s32 (*reset_hw)(struct igc_hw *hw);
  20. s32 (*init_hw)(struct igc_hw *hw);
  21. s32 (*setup_physical_interface)(struct igc_hw *hw);
  22. void (*rar_set)(struct igc_hw *hw, u8 *address, u32 index);
  23. s32 (*read_mac_addr)(struct igc_hw *hw);
  24. s32 (*get_speed_and_duplex)(struct igc_hw *hw, u16 *speed,
  25. u16 *duplex);
  26. s32 (*acquire_swfw_sync)(struct igc_hw *hw, u16 mask);
  27. void (*release_swfw_sync)(struct igc_hw *hw, u16 mask);
  28. };
  29. enum igc_mac_type {
  30. igc_undefined = 0,
  31. igc_i225,
  32. igc_num_macs /* List is 1-based, so subtract 1 for true count. */
  33. };
  34. enum igc_phy_type {
  35. igc_phy_unknown = 0,
  36. igc_phy_none,
  37. igc_phy_i225,
  38. };
  39. enum igc_nvm_type {
  40. igc_nvm_unknown = 0,
  41. igc_nvm_flash_hw,
  42. igc_nvm_invm,
  43. };
  44. struct igc_info {
  45. s32 (*get_invariants)(struct igc_hw *hw);
  46. struct igc_mac_operations *mac_ops;
  47. const struct igc_phy_operations *phy_ops;
  48. struct igc_nvm_operations *nvm_ops;
  49. };
  50. extern const struct igc_info igc_base_info;
  51. struct igc_mac_info {
  52. struct igc_mac_operations ops;
  53. u8 addr[ETH_ALEN];
  54. u8 perm_addr[ETH_ALEN];
  55. enum igc_mac_type type;
  56. u32 collision_delta;
  57. u32 ledctl_default;
  58. u32 ledctl_mode1;
  59. u32 ledctl_mode2;
  60. u32 mc_filter_type;
  61. u32 tx_packet_delta;
  62. u32 txcw;
  63. u16 mta_reg_count;
  64. u16 uta_reg_count;
  65. u16 rar_entry_count;
  66. u8 forced_speed_duplex;
  67. bool adaptive_ifs;
  68. bool has_fwsm;
  69. bool arc_subsystem_valid;
  70. bool autoneg;
  71. bool autoneg_failed;
  72. bool get_link_status;
  73. };
  74. struct igc_nvm_operations {
  75. s32 (*acquire)(struct igc_hw *hw);
  76. s32 (*read)(struct igc_hw *hw, u16 offset, u16 i, u16 *data);
  77. void (*release)(struct igc_hw *hw);
  78. s32 (*write)(struct igc_hw *hw, u16 offset, u16 i, u16 *data);
  79. s32 (*update)(struct igc_hw *hw);
  80. s32 (*validate)(struct igc_hw *hw);
  81. s32 (*valid_led_default)(struct igc_hw *hw, u16 *data);
  82. };
  83. struct igc_nvm_info {
  84. struct igc_nvm_operations ops;
  85. enum igc_nvm_type type;
  86. u32 flash_bank_size;
  87. u32 flash_base_addr;
  88. u16 word_size;
  89. u16 delay_usec;
  90. u16 address_bits;
  91. u16 opcode_bits;
  92. u16 page_size;
  93. };
  94. struct igc_bus_info {
  95. u16 func;
  96. u16 pci_cmd_word;
  97. };
  98. enum igc_fc_mode {
  99. igc_fc_none = 0,
  100. igc_fc_rx_pause,
  101. igc_fc_tx_pause,
  102. igc_fc_full,
  103. igc_fc_default = 0xFF
  104. };
  105. struct igc_fc_info {
  106. u32 high_water; /* Flow control high-water mark */
  107. u32 low_water; /* Flow control low-water mark */
  108. u16 pause_time; /* Flow control pause timer */
  109. bool send_xon; /* Flow control send XON */
  110. bool strict_ieee; /* Strict IEEE mode */
  111. enum igc_fc_mode current_mode; /* Type of flow control */
  112. enum igc_fc_mode requested_mode;
  113. };
  114. struct igc_dev_spec_base {
  115. bool global_device_reset;
  116. bool eee_disable;
  117. bool clear_semaphore_once;
  118. bool module_plugged;
  119. u8 media_port;
  120. };
  121. struct igc_hw {
  122. void *back;
  123. u8 __iomem *hw_addr;
  124. unsigned long io_base;
  125. struct igc_mac_info mac;
  126. struct igc_fc_info fc;
  127. struct igc_nvm_info nvm;
  128. struct igc_bus_info bus;
  129. union {
  130. struct igc_dev_spec_base _base;
  131. } dev_spec;
  132. u16 device_id;
  133. u16 subsystem_vendor_id;
  134. u16 subsystem_device_id;
  135. u16 vendor_id;
  136. u8 revision_id;
  137. };
  138. /* Statistics counters collected by the MAC */
  139. struct igc_hw_stats {
  140. u64 crcerrs;
  141. u64 algnerrc;
  142. u64 symerrs;
  143. u64 rxerrc;
  144. u64 mpc;
  145. u64 scc;
  146. u64 ecol;
  147. u64 mcc;
  148. u64 latecol;
  149. u64 colc;
  150. u64 dc;
  151. u64 tncrs;
  152. u64 sec;
  153. u64 cexterr;
  154. u64 rlec;
  155. u64 xonrxc;
  156. u64 xontxc;
  157. u64 xoffrxc;
  158. u64 xofftxc;
  159. u64 fcruc;
  160. u64 prc64;
  161. u64 prc127;
  162. u64 prc255;
  163. u64 prc511;
  164. u64 prc1023;
  165. u64 prc1522;
  166. u64 gprc;
  167. u64 bprc;
  168. u64 mprc;
  169. u64 gptc;
  170. u64 gorc;
  171. u64 gotc;
  172. u64 rnbc;
  173. u64 ruc;
  174. u64 rfc;
  175. u64 roc;
  176. u64 rjc;
  177. u64 mgprc;
  178. u64 mgpdc;
  179. u64 mgptc;
  180. u64 tor;
  181. u64 tot;
  182. u64 tpr;
  183. u64 tpt;
  184. u64 ptc64;
  185. u64 ptc127;
  186. u64 ptc255;
  187. u64 ptc511;
  188. u64 ptc1023;
  189. u64 ptc1522;
  190. u64 mptc;
  191. u64 bptc;
  192. u64 tsctc;
  193. u64 tsctfc;
  194. u64 iac;
  195. u64 icrxptc;
  196. u64 icrxatc;
  197. u64 ictxptc;
  198. u64 ictxatc;
  199. u64 ictxqec;
  200. u64 ictxqmtc;
  201. u64 icrxdmtc;
  202. u64 icrxoc;
  203. u64 cbtmpc;
  204. u64 htdpmc;
  205. u64 cbrdpc;
  206. u64 cbrmpc;
  207. u64 rpthc;
  208. u64 hgptc;
  209. u64 htcbdpc;
  210. u64 hgorc;
  211. u64 hgotc;
  212. u64 lenerrs;
  213. u64 scvpc;
  214. u64 hrmpc;
  215. u64 doosync;
  216. u64 o2bgptc;
  217. u64 o2bspc;
  218. u64 b2ospc;
  219. u64 b2ogprc;
  220. };
  221. struct net_device *igc_get_hw_dev(struct igc_hw *hw);
  222. #define hw_dbg(format, arg...) \
  223. netdev_dbg(igc_get_hw_dev(hw), format, ##arg)
  224. s32 igc_read_pcie_cap_reg(struct igc_hw *hw, u32 reg, u16 *value);
  225. s32 igc_write_pcie_cap_reg(struct igc_hw *hw, u32 reg, u16 *value);
  226. void igc_read_pci_cfg(struct igc_hw *hw, u32 reg, u16 *value);
  227. void igc_write_pci_cfg(struct igc_hw *hw, u32 reg, u16 *value);
  228. #endif /* _IGC_HW_H_ */