PageRenderTime 57ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/igb/e1000_hw.h

https://github.com/kipill-nn/Kernel-for-Mega
C Header | 601 lines | 496 code | 69 blank | 36 comment | 0 complexity | 62857557e11d965705c16c7e257b2ad0 MD5 | raw file
  1. /*******************************************************************************
  2. Intel(R) Gigabit Ethernet Linux driver
  3. Copyright(c) 2007 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  18. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  19. *******************************************************************************/
  20. #ifndef _E1000_HW_H_
  21. #define _E1000_HW_H_
  22. #include <linux/types.h>
  23. #include <linux/delay.h>
  24. #include <linux/io.h>
  25. #include "e1000_mac.h"
  26. #include "e1000_regs.h"
  27. #include "e1000_defines.h"
  28. struct e1000_hw;
  29. #define E1000_DEV_ID_82576 0x10C9
  30. #define E1000_DEV_ID_82576_FIBER 0x10E6
  31. #define E1000_DEV_ID_82576_SERDES 0x10E7
  32. #define E1000_DEV_ID_82575EB_COPPER 0x10A7
  33. #define E1000_DEV_ID_82575EB_FIBER_SERDES 0x10A9
  34. #define E1000_DEV_ID_82575GB_QUAD_COPPER 0x10D6
  35. #define E1000_REVISION_2 2
  36. #define E1000_REVISION_4 4
  37. #define E1000_FUNC_1 1
  38. enum e1000_mac_type {
  39. e1000_undefined = 0,
  40. e1000_82575,
  41. e1000_82576,
  42. e1000_num_macs /* List is 1-based, so subtract 1 for true count. */
  43. };
  44. enum e1000_media_type {
  45. e1000_media_type_unknown = 0,
  46. e1000_media_type_copper = 1,
  47. e1000_media_type_fiber = 2,
  48. e1000_media_type_internal_serdes = 3,
  49. e1000_num_media_types
  50. };
  51. enum e1000_nvm_type {
  52. e1000_nvm_unknown = 0,
  53. e1000_nvm_none,
  54. e1000_nvm_eeprom_spi,
  55. e1000_nvm_eeprom_microwire,
  56. e1000_nvm_flash_hw,
  57. e1000_nvm_flash_sw
  58. };
  59. enum e1000_nvm_override {
  60. e1000_nvm_override_none = 0,
  61. e1000_nvm_override_spi_small,
  62. e1000_nvm_override_spi_large,
  63. e1000_nvm_override_microwire_small,
  64. e1000_nvm_override_microwire_large
  65. };
  66. enum e1000_phy_type {
  67. e1000_phy_unknown = 0,
  68. e1000_phy_none,
  69. e1000_phy_m88,
  70. e1000_phy_igp,
  71. e1000_phy_igp_2,
  72. e1000_phy_gg82563,
  73. e1000_phy_igp_3,
  74. e1000_phy_ife,
  75. };
  76. enum e1000_bus_type {
  77. e1000_bus_type_unknown = 0,
  78. e1000_bus_type_pci,
  79. e1000_bus_type_pcix,
  80. e1000_bus_type_pci_express,
  81. e1000_bus_type_reserved
  82. };
  83. enum e1000_bus_speed {
  84. e1000_bus_speed_unknown = 0,
  85. e1000_bus_speed_33,
  86. e1000_bus_speed_66,
  87. e1000_bus_speed_100,
  88. e1000_bus_speed_120,
  89. e1000_bus_speed_133,
  90. e1000_bus_speed_2500,
  91. e1000_bus_speed_5000,
  92. e1000_bus_speed_reserved
  93. };
  94. enum e1000_bus_width {
  95. e1000_bus_width_unknown = 0,
  96. e1000_bus_width_pcie_x1,
  97. e1000_bus_width_pcie_x2,
  98. e1000_bus_width_pcie_x4 = 4,
  99. e1000_bus_width_pcie_x8 = 8,
  100. e1000_bus_width_32,
  101. e1000_bus_width_64,
  102. e1000_bus_width_reserved
  103. };
  104. enum e1000_1000t_rx_status {
  105. e1000_1000t_rx_status_not_ok = 0,
  106. e1000_1000t_rx_status_ok,
  107. e1000_1000t_rx_status_undefined = 0xFF
  108. };
  109. enum e1000_rev_polarity {
  110. e1000_rev_polarity_normal = 0,
  111. e1000_rev_polarity_reversed,
  112. e1000_rev_polarity_undefined = 0xFF
  113. };
  114. enum e1000_fc_type {
  115. e1000_fc_none = 0,
  116. e1000_fc_rx_pause,
  117. e1000_fc_tx_pause,
  118. e1000_fc_full,
  119. e1000_fc_default = 0xFF
  120. };
  121. /* Receive Descriptor */
  122. struct e1000_rx_desc {
  123. __le64 buffer_addr; /* Address of the descriptor's data buffer */
  124. __le16 length; /* Length of data DMAed into data buffer */
  125. __le16 csum; /* Packet checksum */
  126. u8 status; /* Descriptor status */
  127. u8 errors; /* Descriptor Errors */
  128. __le16 special;
  129. };
  130. /* Receive Descriptor - Extended */
  131. union e1000_rx_desc_extended {
  132. struct {
  133. __le64 buffer_addr;
  134. __le64 reserved;
  135. } read;
  136. struct {
  137. struct {
  138. __le32 mrq; /* Multiple Rx Queues */
  139. union {
  140. __le32 rss; /* RSS Hash */
  141. struct {
  142. __le16 ip_id; /* IP id */
  143. __le16 csum; /* Packet Checksum */
  144. } csum_ip;
  145. } hi_dword;
  146. } lower;
  147. struct {
  148. __le32 status_error; /* ext status/error */
  149. __le16 length;
  150. __le16 vlan; /* VLAN tag */
  151. } upper;
  152. } wb; /* writeback */
  153. };
  154. #define MAX_PS_BUFFERS 4
  155. /* Receive Descriptor - Packet Split */
  156. union e1000_rx_desc_packet_split {
  157. struct {
  158. /* one buffer for protocol header(s), three data buffers */
  159. __le64 buffer_addr[MAX_PS_BUFFERS];
  160. } read;
  161. struct {
  162. struct {
  163. __le32 mrq; /* Multiple Rx Queues */
  164. union {
  165. __le32 rss; /* RSS Hash */
  166. struct {
  167. __le16 ip_id; /* IP id */
  168. __le16 csum; /* Packet Checksum */
  169. } csum_ip;
  170. } hi_dword;
  171. } lower;
  172. struct {
  173. __le32 status_error; /* ext status/error */
  174. __le16 length0; /* length of buffer 0 */
  175. __le16 vlan; /* VLAN tag */
  176. } middle;
  177. struct {
  178. __le16 header_status;
  179. __le16 length[3]; /* length of buffers 1-3 */
  180. } upper;
  181. __le64 reserved;
  182. } wb; /* writeback */
  183. };
  184. /* Transmit Descriptor */
  185. struct e1000_tx_desc {
  186. __le64 buffer_addr; /* Address of the descriptor's data buffer */
  187. union {
  188. __le32 data;
  189. struct {
  190. __le16 length; /* Data buffer length */
  191. u8 cso; /* Checksum offset */
  192. u8 cmd; /* Descriptor control */
  193. } flags;
  194. } lower;
  195. union {
  196. __le32 data;
  197. struct {
  198. u8 status; /* Descriptor status */
  199. u8 css; /* Checksum start */
  200. __le16 special;
  201. } fields;
  202. } upper;
  203. };
  204. /* Offload Context Descriptor */
  205. struct e1000_context_desc {
  206. union {
  207. __le32 ip_config;
  208. struct {
  209. u8 ipcss; /* IP checksum start */
  210. u8 ipcso; /* IP checksum offset */
  211. __le16 ipcse; /* IP checksum end */
  212. } ip_fields;
  213. } lower_setup;
  214. union {
  215. __le32 tcp_config;
  216. struct {
  217. u8 tucss; /* TCP checksum start */
  218. u8 tucso; /* TCP checksum offset */
  219. __le16 tucse; /* TCP checksum end */
  220. } tcp_fields;
  221. } upper_setup;
  222. __le32 cmd_and_length;
  223. union {
  224. __le32 data;
  225. struct {
  226. u8 status; /* Descriptor status */
  227. u8 hdr_len; /* Header length */
  228. __le16 mss; /* Maximum segment size */
  229. } fields;
  230. } tcp_seg_setup;
  231. };
  232. /* Offload data descriptor */
  233. struct e1000_data_desc {
  234. __le64 buffer_addr; /* Address of the descriptor's buffer address */
  235. union {
  236. __le32 data;
  237. struct {
  238. __le16 length; /* Data buffer length */
  239. u8 typ_len_ext;
  240. u8 cmd;
  241. } flags;
  242. } lower;
  243. union {
  244. __le32 data;
  245. struct {
  246. u8 status; /* Descriptor status */
  247. u8 popts; /* Packet Options */
  248. __le16 special;
  249. } fields;
  250. } upper;
  251. };
  252. /* Statistics counters collected by the MAC */
  253. struct e1000_hw_stats {
  254. u64 crcerrs;
  255. u64 algnerrc;
  256. u64 symerrs;
  257. u64 rxerrc;
  258. u64 mpc;
  259. u64 scc;
  260. u64 ecol;
  261. u64 mcc;
  262. u64 latecol;
  263. u64 colc;
  264. u64 dc;
  265. u64 tncrs;
  266. u64 sec;
  267. u64 cexterr;
  268. u64 rlec;
  269. u64 xonrxc;
  270. u64 xontxc;
  271. u64 xoffrxc;
  272. u64 xofftxc;
  273. u64 fcruc;
  274. u64 prc64;
  275. u64 prc127;
  276. u64 prc255;
  277. u64 prc511;
  278. u64 prc1023;
  279. u64 prc1522;
  280. u64 gprc;
  281. u64 bprc;
  282. u64 mprc;
  283. u64 gptc;
  284. u64 gorc;
  285. u64 gotc;
  286. u64 rnbc;
  287. u64 ruc;
  288. u64 rfc;
  289. u64 roc;
  290. u64 rjc;
  291. u64 mgprc;
  292. u64 mgpdc;
  293. u64 mgptc;
  294. u64 tor;
  295. u64 tot;
  296. u64 tpr;
  297. u64 tpt;
  298. u64 ptc64;
  299. u64 ptc127;
  300. u64 ptc255;
  301. u64 ptc511;
  302. u64 ptc1023;
  303. u64 ptc1522;
  304. u64 mptc;
  305. u64 bptc;
  306. u64 tsctc;
  307. u64 tsctfc;
  308. u64 iac;
  309. u64 icrxptc;
  310. u64 icrxatc;
  311. u64 ictxptc;
  312. u64 ictxatc;
  313. u64 ictxqec;
  314. u64 ictxqmtc;
  315. u64 icrxdmtc;
  316. u64 icrxoc;
  317. u64 cbtmpc;
  318. u64 htdpmc;
  319. u64 cbrdpc;
  320. u64 cbrmpc;
  321. u64 rpthc;
  322. u64 hgptc;
  323. u64 htcbdpc;
  324. u64 hgorc;
  325. u64 hgotc;
  326. u64 lenerrs;
  327. u64 scvpc;
  328. u64 hrmpc;
  329. };
  330. struct e1000_phy_stats {
  331. u32 idle_errors;
  332. u32 receive_errors;
  333. };
  334. struct e1000_host_mng_dhcp_cookie {
  335. u32 signature;
  336. u8 status;
  337. u8 reserved0;
  338. u16 vlan_id;
  339. u32 reserved1;
  340. u16 reserved2;
  341. u8 reserved3;
  342. u8 checksum;
  343. };
  344. /* Host Interface "Rev 1" */
  345. struct e1000_host_command_header {
  346. u8 command_id;
  347. u8 command_length;
  348. u8 command_options;
  349. u8 checksum;
  350. };
  351. #define E1000_HI_MAX_DATA_LENGTH 252
  352. struct e1000_host_command_info {
  353. struct e1000_host_command_header command_header;
  354. u8 command_data[E1000_HI_MAX_DATA_LENGTH];
  355. };
  356. /* Host Interface "Rev 2" */
  357. struct e1000_host_mng_command_header {
  358. u8 command_id;
  359. u8 checksum;
  360. u16 reserved1;
  361. u16 reserved2;
  362. u16 command_length;
  363. };
  364. #define E1000_HI_MAX_MNG_DATA_LENGTH 0x6F8
  365. struct e1000_host_mng_command_info {
  366. struct e1000_host_mng_command_header command_header;
  367. u8 command_data[E1000_HI_MAX_MNG_DATA_LENGTH];
  368. };
  369. #include "e1000_mac.h"
  370. #include "e1000_phy.h"
  371. #include "e1000_nvm.h"
  372. struct e1000_mac_operations {
  373. s32 (*check_for_link)(struct e1000_hw *);
  374. s32 (*reset_hw)(struct e1000_hw *);
  375. s32 (*init_hw)(struct e1000_hw *);
  376. bool (*check_mng_mode)(struct e1000_hw *);
  377. s32 (*setup_physical_interface)(struct e1000_hw *);
  378. void (*rar_set)(struct e1000_hw *, u8 *, u32);
  379. s32 (*read_mac_addr)(struct e1000_hw *);
  380. s32 (*get_speed_and_duplex)(struct e1000_hw *, u16 *, u16 *);
  381. };
  382. struct e1000_phy_operations {
  383. s32 (*acquire_phy)(struct e1000_hw *);
  384. s32 (*check_reset_block)(struct e1000_hw *);
  385. s32 (*force_speed_duplex)(struct e1000_hw *);
  386. s32 (*get_cfg_done)(struct e1000_hw *hw);
  387. s32 (*get_cable_length)(struct e1000_hw *);
  388. s32 (*get_phy_info)(struct e1000_hw *);
  389. s32 (*read_phy_reg)(struct e1000_hw *, u32, u16 *);
  390. void (*release_phy)(struct e1000_hw *);
  391. s32 (*reset_phy)(struct e1000_hw *);
  392. s32 (*set_d0_lplu_state)(struct e1000_hw *, bool);
  393. s32 (*set_d3_lplu_state)(struct e1000_hw *, bool);
  394. s32 (*write_phy_reg)(struct e1000_hw *, u32, u16);
  395. };
  396. struct e1000_nvm_operations {
  397. s32 (*acquire_nvm)(struct e1000_hw *);
  398. s32 (*read_nvm)(struct e1000_hw *, u16, u16, u16 *);
  399. void (*release_nvm)(struct e1000_hw *);
  400. s32 (*write_nvm)(struct e1000_hw *, u16, u16, u16 *);
  401. };
  402. struct e1000_info {
  403. s32 (*get_invariants)(struct e1000_hw *);
  404. struct e1000_mac_operations *mac_ops;
  405. struct e1000_phy_operations *phy_ops;
  406. struct e1000_nvm_operations *nvm_ops;
  407. };
  408. extern const struct e1000_info e1000_82575_info;
  409. struct e1000_mac_info {
  410. struct e1000_mac_operations ops;
  411. u8 addr[6];
  412. u8 perm_addr[6];
  413. enum e1000_mac_type type;
  414. u32 collision_delta;
  415. u32 ledctl_default;
  416. u32 ledctl_mode1;
  417. u32 ledctl_mode2;
  418. u32 mc_filter_type;
  419. u32 tx_packet_delta;
  420. u32 txcw;
  421. u16 current_ifs_val;
  422. u16 ifs_max_val;
  423. u16 ifs_min_val;
  424. u16 ifs_ratio;
  425. u16 ifs_step_size;
  426. u16 mta_reg_count;
  427. u16 rar_entry_count;
  428. u8 forced_speed_duplex;
  429. bool adaptive_ifs;
  430. bool arc_subsystem_valid;
  431. bool asf_firmware_present;
  432. bool autoneg;
  433. bool autoneg_failed;
  434. bool disable_av;
  435. bool disable_hw_init_bits;
  436. bool get_link_status;
  437. bool ifs_params_forced;
  438. bool in_ifs_mode;
  439. bool report_tx_early;
  440. bool serdes_has_link;
  441. bool tx_pkt_filtering;
  442. };
  443. struct e1000_phy_info {
  444. struct e1000_phy_operations ops;
  445. enum e1000_phy_type type;
  446. enum e1000_1000t_rx_status local_rx;
  447. enum e1000_1000t_rx_status remote_rx;
  448. enum e1000_ms_type ms_type;
  449. enum e1000_ms_type original_ms_type;
  450. enum e1000_rev_polarity cable_polarity;
  451. enum e1000_smart_speed smart_speed;
  452. u32 addr;
  453. u32 id;
  454. u32 reset_delay_us; /* in usec */
  455. u32 revision;
  456. enum e1000_media_type media_type;
  457. u16 autoneg_advertised;
  458. u16 autoneg_mask;
  459. u16 cable_length;
  460. u16 max_cable_length;
  461. u16 min_cable_length;
  462. u8 mdix;
  463. bool disable_polarity_correction;
  464. bool is_mdix;
  465. bool polarity_correction;
  466. bool reset_disable;
  467. bool speed_downgraded;
  468. bool autoneg_wait_to_complete;
  469. };
  470. struct e1000_nvm_info {
  471. struct e1000_nvm_operations ops;
  472. enum e1000_nvm_type type;
  473. enum e1000_nvm_override override;
  474. u32 flash_bank_size;
  475. u32 flash_base_addr;
  476. u16 word_size;
  477. u16 delay_usec;
  478. u16 address_bits;
  479. u16 opcode_bits;
  480. u16 page_size;
  481. };
  482. struct e1000_bus_info {
  483. enum e1000_bus_type type;
  484. enum e1000_bus_speed speed;
  485. enum e1000_bus_width width;
  486. u32 snoop;
  487. u16 func;
  488. u16 pci_cmd_word;
  489. };
  490. struct e1000_fc_info {
  491. u32 high_water; /* Flow control high-water mark */
  492. u32 low_water; /* Flow control low-water mark */
  493. u16 pause_time; /* Flow control pause timer */
  494. bool send_xon; /* Flow control send XON */
  495. bool strict_ieee; /* Strict IEEE mode */
  496. enum e1000_fc_type type; /* Type of flow control */
  497. enum e1000_fc_type original_type;
  498. };
  499. struct e1000_hw {
  500. void *back;
  501. void *dev_spec;
  502. u8 __iomem *hw_addr;
  503. u8 __iomem *flash_address;
  504. unsigned long io_base;
  505. struct e1000_mac_info mac;
  506. struct e1000_fc_info fc;
  507. struct e1000_phy_info phy;
  508. struct e1000_nvm_info nvm;
  509. struct e1000_bus_info bus;
  510. struct e1000_host_mng_dhcp_cookie mng_cookie;
  511. u32 dev_spec_size;
  512. u16 device_id;
  513. u16 subsystem_vendor_id;
  514. u16 subsystem_device_id;
  515. u16 vendor_id;
  516. u8 revision_id;
  517. };
  518. #ifdef DEBUG
  519. extern char *igb_get_hw_dev_name(struct e1000_hw *hw);
  520. #define hw_dbg(format, arg...) \
  521. printk(KERN_DEBUG "%s: " format, igb_get_hw_dev_name(hw), ##arg)
  522. #else
  523. #define hw_dbg(format, arg...)
  524. #endif
  525. #endif