e1000.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /* Intel PRO/1000 Linux driver
  2. * Copyright(c) 1999 - 2014 Intel Corporation.
  3. *
  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. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * The full GNU General Public License is included in this distribution in
  14. * the file called "COPYING".
  15. *
  16. * Contact Information:
  17. * Linux NICS <linux.nics@intel.com>
  18. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. */
  21. /* Linux PRO/1000 Ethernet Driver main header file */
  22. #ifndef _E1000_H_
  23. #define _E1000_H_
  24. #include <linux/bitops.h>
  25. #include <linux/types.h>
  26. #include <linux/timer.h>
  27. #include <linux/workqueue.h>
  28. #include <linux/io.h>
  29. #include <linux/netdevice.h>
  30. #include <linux/pci.h>
  31. #include <linux/pci-aspm.h>
  32. #include <linux/crc32.h>
  33. #include <linux/if_vlan.h>
  34. #include <linux/clocksource.h>
  35. #include <linux/net_tstamp.h>
  36. #include <linux/ptp_clock_kernel.h>
  37. #include <linux/ptp_classify.h>
  38. #include <linux/mii.h>
  39. #include <linux/mdio.h>
  40. #include "hw.h"
  41. struct e1000_info;
  42. #define e_dbg(format, arg...) \
  43. netdev_dbg(hw->adapter->netdev, format, ## arg)
  44. #define e_err(format, arg...) \
  45. netdev_err(adapter->netdev, format, ## arg)
  46. #define e_info(format, arg...) \
  47. netdev_info(adapter->netdev, format, ## arg)
  48. #define e_warn(format, arg...) \
  49. netdev_warn(adapter->netdev, format, ## arg)
  50. #define e_notice(format, arg...) \
  51. netdev_notice(adapter->netdev, format, ## arg)
  52. /* Interrupt modes, as used by the IntMode parameter */
  53. #define E1000E_INT_MODE_LEGACY 0
  54. #define E1000E_INT_MODE_MSI 1
  55. #define E1000E_INT_MODE_MSIX 2
  56. /* Tx/Rx descriptor defines */
  57. #define E1000_DEFAULT_TXD 256
  58. #define E1000_MAX_TXD 4096
  59. #define E1000_MIN_TXD 64
  60. #define E1000_DEFAULT_RXD 256
  61. #define E1000_MAX_RXD 4096
  62. #define E1000_MIN_RXD 64
  63. #define E1000_MIN_ITR_USECS 10 /* 100000 irq/sec */
  64. #define E1000_MAX_ITR_USECS 10000 /* 100 irq/sec */
  65. #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
  66. /* How many Tx Descriptors do we need to call netif_wake_queue ? */
  67. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  68. #define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
  69. #define AUTO_ALL_MODES 0
  70. #define E1000_EEPROM_APME 0x0400
  71. #define E1000_MNG_VLAN_NONE (-1)
  72. #define DEFAULT_JUMBO 9234
  73. /* Time to wait before putting the device into D3 if there's no link (in ms). */
  74. #define LINK_TIMEOUT 100
  75. /* Count for polling __E1000_RESET condition every 10-20msec.
  76. * Experimentation has shown the reset can take approximately 210msec.
  77. */
  78. #define E1000_CHECK_RESET_COUNT 25
  79. #define DEFAULT_RDTR 0
  80. #define DEFAULT_RADV 8
  81. #define BURST_RDTR 0x20
  82. #define BURST_RADV 0x20
  83. /* in the case of WTHRESH, it appears at least the 82571/2 hardware
  84. * writes back 4 descriptors when WTHRESH=5, and 3 descriptors when
  85. * WTHRESH=4, so a setting of 5 gives the most efficient bus
  86. * utilization but to avoid possible Tx stalls, set it to 1
  87. */
  88. #define E1000_TXDCTL_DMA_BURST_ENABLE \
  89. (E1000_TXDCTL_GRAN | /* set descriptor granularity */ \
  90. E1000_TXDCTL_COUNT_DESC | \
  91. (1 << 16) | /* wthresh must be +1 more than desired */\
  92. (1 << 8) | /* hthresh */ \
  93. 0x1f) /* pthresh */
  94. #define E1000_RXDCTL_DMA_BURST_ENABLE \
  95. (0x01000000 | /* set descriptor granularity */ \
  96. (4 << 16) | /* set writeback threshold */ \
  97. (4 << 8) | /* set prefetch threshold */ \
  98. 0x20) /* set hthresh */
  99. #define E1000_TIDV_FPD (1 << 31)
  100. #define E1000_RDTR_FPD (1 << 31)
  101. enum e1000_boards {
  102. board_82571,
  103. board_82572,
  104. board_82573,
  105. board_82574,
  106. board_82583,
  107. board_80003es2lan,
  108. board_ich8lan,
  109. board_ich9lan,
  110. board_ich10lan,
  111. board_pchlan,
  112. board_pch2lan,
  113. board_pch_lpt,
  114. };
  115. struct e1000_ps_page {
  116. struct page *page;
  117. u64 dma; /* must be u64 - written to hw */
  118. };
  119. /* wrappers around a pointer to a socket buffer,
  120. * so a DMA handle can be stored along with the buffer
  121. */
  122. struct e1000_buffer {
  123. dma_addr_t dma;
  124. struct sk_buff *skb;
  125. union {
  126. /* Tx */
  127. struct {
  128. unsigned long time_stamp;
  129. u16 length;
  130. u16 next_to_watch;
  131. unsigned int segs;
  132. unsigned int bytecount;
  133. u16 mapped_as_page;
  134. };
  135. /* Rx */
  136. struct {
  137. /* arrays of page information for packet split */
  138. struct e1000_ps_page *ps_pages;
  139. struct page *page;
  140. };
  141. };
  142. };
  143. struct e1000_ring {
  144. struct e1000_adapter *adapter; /* back pointer to adapter */
  145. void *desc; /* pointer to ring memory */
  146. dma_addr_t dma; /* phys address of ring */
  147. unsigned int size; /* length of ring in bytes */
  148. unsigned int count; /* number of desc. in ring */
  149. u16 next_to_use;
  150. u16 next_to_clean;
  151. void __iomem *head;
  152. void __iomem *tail;
  153. /* array of buffer information structs */
  154. struct e1000_buffer *buffer_info;
  155. char name[IFNAMSIZ + 5];
  156. u32 ims_val;
  157. u32 itr_val;
  158. void __iomem *itr_register;
  159. int set_itr;
  160. struct sk_buff *rx_skb_top;
  161. };
  162. /* PHY register snapshot values */
  163. struct e1000_phy_regs {
  164. u16 bmcr; /* basic mode control register */
  165. u16 bmsr; /* basic mode status register */
  166. u16 advertise; /* auto-negotiation advertisement */
  167. u16 lpa; /* link partner ability register */
  168. u16 expansion; /* auto-negotiation expansion reg */
  169. u16 ctrl1000; /* 1000BASE-T control register */
  170. u16 stat1000; /* 1000BASE-T status register */
  171. u16 estatus; /* extended status register */
  172. };
  173. /* board specific private data structure */
  174. struct e1000_adapter {
  175. struct timer_list watchdog_timer;
  176. struct timer_list phy_info_timer;
  177. struct timer_list blink_timer;
  178. struct work_struct reset_task;
  179. struct work_struct watchdog_task;
  180. const struct e1000_info *ei;
  181. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  182. u32 bd_number;
  183. u32 rx_buffer_len;
  184. u16 mng_vlan_id;
  185. u16 link_speed;
  186. u16 link_duplex;
  187. u16 eeprom_vers;
  188. /* track device up/down/testing state */
  189. unsigned long state;
  190. /* Interrupt Throttle Rate */
  191. u32 itr;
  192. u32 itr_setting;
  193. u16 tx_itr;
  194. u16 rx_itr;
  195. /* Tx - one ring per active queue */
  196. struct e1000_ring *tx_ring ____cacheline_aligned_in_smp;
  197. u32 tx_fifo_limit;
  198. struct napi_struct napi;
  199. unsigned int uncorr_errors; /* uncorrectable ECC errors */
  200. unsigned int corr_errors; /* correctable ECC errors */
  201. unsigned int restart_queue;
  202. u32 txd_cmd;
  203. bool detect_tx_hung;
  204. bool tx_hang_recheck;
  205. u8 tx_timeout_factor;
  206. u32 tx_int_delay;
  207. u32 tx_abs_int_delay;
  208. unsigned int total_tx_bytes;
  209. unsigned int total_tx_packets;
  210. unsigned int total_rx_bytes;
  211. unsigned int total_rx_packets;
  212. /* Tx stats */
  213. u64 tpt_old;
  214. u64 colc_old;
  215. u32 gotc;
  216. u64 gotc_old;
  217. u32 tx_timeout_count;
  218. u32 tx_fifo_head;
  219. u32 tx_head_addr;
  220. u32 tx_fifo_size;
  221. u32 tx_dma_failed;
  222. u32 tx_hwtstamp_timeouts;
  223. /* Rx */
  224. bool (*clean_rx)(struct e1000_ring *ring, int *work_done,
  225. int work_to_do) ____cacheline_aligned_in_smp;
  226. void (*alloc_rx_buf)(struct e1000_ring *ring, int cleaned_count,
  227. gfp_t gfp);
  228. struct e1000_ring *rx_ring;
  229. u32 rx_int_delay;
  230. u32 rx_abs_int_delay;
  231. /* Rx stats */
  232. u64 hw_csum_err;
  233. u64 hw_csum_good;
  234. u64 rx_hdr_split;
  235. u32 gorc;
  236. u64 gorc_old;
  237. u32 alloc_rx_buff_failed;
  238. u32 rx_dma_failed;
  239. u32 rx_hwtstamp_cleared;
  240. unsigned int rx_ps_pages;
  241. u16 rx_ps_bsize0;
  242. u32 max_frame_size;
  243. u32 min_frame_size;
  244. /* OS defined structs */
  245. struct net_device *netdev;
  246. struct pci_dev *pdev;
  247. /* structs defined in e1000_hw.h */
  248. struct e1000_hw hw;
  249. spinlock_t stats64_lock; /* protects statistics counters */
  250. struct e1000_hw_stats stats;
  251. struct e1000_phy_info phy_info;
  252. struct e1000_phy_stats phy_stats;
  253. /* Snapshot of PHY registers */
  254. struct e1000_phy_regs phy_regs;
  255. struct e1000_ring test_tx_ring;
  256. struct e1000_ring test_rx_ring;
  257. u32 test_icr;
  258. u32 msg_enable;
  259. unsigned int num_vectors;
  260. struct msix_entry *msix_entries;
  261. int int_mode;
  262. u32 eiac_mask;
  263. u32 eeprom_wol;
  264. u32 wol;
  265. u32 pba;
  266. u32 max_hw_frame_size;
  267. bool fc_autoneg;
  268. unsigned int flags;
  269. unsigned int flags2;
  270. struct work_struct downshift_task;
  271. struct work_struct update_phy_task;
  272. struct work_struct print_hang_task;
  273. int phy_hang_count;
  274. u16 tx_ring_count;
  275. u16 rx_ring_count;
  276. struct hwtstamp_config hwtstamp_config;
  277. struct delayed_work systim_overflow_work;
  278. struct sk_buff *tx_hwtstamp_skb;
  279. unsigned long tx_hwtstamp_start;
  280. struct work_struct tx_hwtstamp_work;
  281. spinlock_t systim_lock; /* protects SYSTIML/H regsters */
  282. struct cyclecounter cc;
  283. struct timecounter tc;
  284. struct ptp_clock *ptp_clock;
  285. struct ptp_clock_info ptp_clock_info;
  286. u16 eee_advert;
  287. };
  288. struct e1000_info {
  289. enum e1000_mac_type mac;
  290. unsigned int flags;
  291. unsigned int flags2;
  292. u32 pba;
  293. u32 max_hw_frame_size;
  294. s32 (*get_variants)(struct e1000_adapter *);
  295. const struct e1000_mac_operations *mac_ops;
  296. const struct e1000_phy_operations *phy_ops;
  297. const struct e1000_nvm_operations *nvm_ops;
  298. };
  299. s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca);
  300. /* The system time is maintained by a 64-bit counter comprised of the 32-bit
  301. * SYSTIMH and SYSTIML registers. How the counter increments (and therefore
  302. * its resolution) is based on the contents of the TIMINCA register - it
  303. * increments every incperiod (bits 31:24) clock ticks by incvalue (bits 23:0).
  304. * For the best accuracy, the incperiod should be as small as possible. The
  305. * incvalue is scaled by a factor as large as possible (while still fitting
  306. * in bits 23:0) so that relatively small clock corrections can be made.
  307. *
  308. * As a result, a shift of INCVALUE_SHIFT_n is used to fit a value of
  309. * INCVALUE_n into the TIMINCA register allowing 32+8+(24-INCVALUE_SHIFT_n)
  310. * bits to count nanoseconds leaving the rest for fractional nonseconds.
  311. */
  312. #define INCVALUE_96MHz 125
  313. #define INCVALUE_SHIFT_96MHz 17
  314. #define INCPERIOD_SHIFT_96MHz 2
  315. #define INCPERIOD_96MHz (12 >> INCPERIOD_SHIFT_96MHz)
  316. #define INCVALUE_25MHz 40
  317. #define INCVALUE_SHIFT_25MHz 18
  318. #define INCPERIOD_25MHz 1
  319. /* Another drawback of scaling the incvalue by a large factor is the
  320. * 64-bit SYSTIM register overflows more quickly. This is dealt with
  321. * by simply reading the clock before it overflows.
  322. *
  323. * Clock ns bits Overflows after
  324. * ~~~~~~ ~~~~~~~ ~~~~~~~~~~~~~~~
  325. * 96MHz 47-bit 2^(47-INCPERIOD_SHIFT_96MHz) / 10^9 / 3600 = 9.77 hrs
  326. * 25MHz 46-bit 2^46 / 10^9 / 3600 = 19.55 hours
  327. */
  328. #define E1000_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 60 * 4)
  329. #define E1000_MAX_82574_SYSTIM_REREADS 50
  330. #define E1000_82574_SYSTIM_EPSILON (1ULL << 35ULL)
  331. /* hardware capability, feature, and workaround flags */
  332. #define FLAG_HAS_AMT (1 << 0)
  333. #define FLAG_HAS_FLASH (1 << 1)
  334. #define FLAG_HAS_HW_VLAN_FILTER (1 << 2)
  335. #define FLAG_HAS_WOL (1 << 3)
  336. /* reserved bit4 */
  337. #define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5)
  338. #define FLAG_HAS_SWSM_ON_LOAD (1 << 6)
  339. #define FLAG_HAS_JUMBO_FRAMES (1 << 7)
  340. #define FLAG_READ_ONLY_NVM (1 << 8)
  341. #define FLAG_IS_ICH (1 << 9)
  342. #define FLAG_HAS_MSIX (1 << 10)
  343. #define FLAG_HAS_SMART_POWER_DOWN (1 << 11)
  344. #define FLAG_IS_QUAD_PORT_A (1 << 12)
  345. #define FLAG_IS_QUAD_PORT (1 << 13)
  346. #define FLAG_HAS_HW_TIMESTAMP (1 << 14)
  347. #define FLAG_APME_IN_WUC (1 << 15)
  348. #define FLAG_APME_IN_CTRL3 (1 << 16)
  349. #define FLAG_APME_CHECK_PORT_B (1 << 17)
  350. #define FLAG_DISABLE_FC_PAUSE_TIME (1 << 18)
  351. #define FLAG_NO_WAKE_UCAST (1 << 19)
  352. #define FLAG_MNG_PT_ENABLED (1 << 20)
  353. #define FLAG_RESET_OVERWRITES_LAA (1 << 21)
  354. #define FLAG_TARC_SPEED_MODE_BIT (1 << 22)
  355. #define FLAG_TARC_SET_BIT_ZERO (1 << 23)
  356. #define FLAG_RX_NEEDS_RESTART (1 << 24)
  357. #define FLAG_LSC_GIG_SPEED_DROP (1 << 25)
  358. #define FLAG_SMART_POWER_DOWN (1 << 26)
  359. #define FLAG_MSI_ENABLED (1 << 27)
  360. /* reserved (1 << 28) */
  361. #define FLAG_TSO_FORCE (1 << 29)
  362. #define FLAG_RESTART_NOW (1 << 30)
  363. #define FLAG_MSI_TEST_FAILED (1 << 31)
  364. #define FLAG2_CRC_STRIPPING (1 << 0)
  365. #define FLAG2_HAS_PHY_WAKEUP (1 << 1)
  366. #define FLAG2_IS_DISCARDING (1 << 2)
  367. #define FLAG2_DISABLE_ASPM_L1 (1 << 3)
  368. #define FLAG2_HAS_PHY_STATS (1 << 4)
  369. #define FLAG2_HAS_EEE (1 << 5)
  370. #define FLAG2_DMA_BURST (1 << 6)
  371. #define FLAG2_DISABLE_ASPM_L0S (1 << 7)
  372. #define FLAG2_DISABLE_AIM (1 << 8)
  373. #define FLAG2_CHECK_PHY_HANG (1 << 9)
  374. #define FLAG2_NO_DISABLE_RX (1 << 10)
  375. #define FLAG2_PCIM2PCI_ARBITER_WA (1 << 11)
  376. #define FLAG2_DFLT_CRC_STRIPPING (1 << 12)
  377. #define FLAG2_CHECK_RX_HWTSTAMP (1 << 13)
  378. #define E1000_RX_DESC_PS(R, i) \
  379. (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
  380. #define E1000_RX_DESC_EXT(R, i) \
  381. (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
  382. #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
  383. #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
  384. #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
  385. enum e1000_state_t {
  386. __E1000_TESTING,
  387. __E1000_RESETTING,
  388. __E1000_ACCESS_SHARED_RESOURCE,
  389. __E1000_DOWN
  390. };
  391. enum latency_range {
  392. lowest_latency = 0,
  393. low_latency = 1,
  394. bulk_latency = 2,
  395. latency_invalid = 255
  396. };
  397. extern char e1000e_driver_name[];
  398. extern const char e1000e_driver_version[];
  399. void e1000e_check_options(struct e1000_adapter *adapter);
  400. void e1000e_set_ethtool_ops(struct net_device *netdev);
  401. int e1000e_up(struct e1000_adapter *adapter);
  402. void e1000e_down(struct e1000_adapter *adapter, bool reset);
  403. void e1000e_reinit_locked(struct e1000_adapter *adapter);
  404. void e1000e_reset(struct e1000_adapter *adapter);
  405. void e1000e_power_up_phy(struct e1000_adapter *adapter);
  406. int e1000e_setup_rx_resources(struct e1000_ring *ring);
  407. int e1000e_setup_tx_resources(struct e1000_ring *ring);
  408. void e1000e_free_rx_resources(struct e1000_ring *ring);
  409. void e1000e_free_tx_resources(struct e1000_ring *ring);
  410. struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
  411. struct rtnl_link_stats64 *stats);
  412. void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
  413. void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
  414. void e1000e_get_hw_control(struct e1000_adapter *adapter);
  415. void e1000e_release_hw_control(struct e1000_adapter *adapter);
  416. void e1000e_write_itr(struct e1000_adapter *adapter, u32 itr);
  417. extern unsigned int copybreak;
  418. extern const struct e1000_info e1000_82571_info;
  419. extern const struct e1000_info e1000_82572_info;
  420. extern const struct e1000_info e1000_82573_info;
  421. extern const struct e1000_info e1000_82574_info;
  422. extern const struct e1000_info e1000_82583_info;
  423. extern const struct e1000_info e1000_ich8_info;
  424. extern const struct e1000_info e1000_ich9_info;
  425. extern const struct e1000_info e1000_ich10_info;
  426. extern const struct e1000_info e1000_pch_info;
  427. extern const struct e1000_info e1000_pch2_info;
  428. extern const struct e1000_info e1000_pch_lpt_info;
  429. extern const struct e1000_info e1000_es2_info;
  430. void e1000e_ptp_init(struct e1000_adapter *adapter);
  431. void e1000e_ptp_remove(struct e1000_adapter *adapter);
  432. static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw)
  433. {
  434. return hw->phy.ops.reset(hw);
  435. }
  436. static inline s32 e1e_rphy(struct e1000_hw *hw, u32 offset, u16 *data)
  437. {
  438. return hw->phy.ops.read_reg(hw, offset, data);
  439. }
  440. static inline s32 e1e_rphy_locked(struct e1000_hw *hw, u32 offset, u16 *data)
  441. {
  442. return hw->phy.ops.read_reg_locked(hw, offset, data);
  443. }
  444. static inline s32 e1e_wphy(struct e1000_hw *hw, u32 offset, u16 data)
  445. {
  446. return hw->phy.ops.write_reg(hw, offset, data);
  447. }
  448. static inline s32 e1e_wphy_locked(struct e1000_hw *hw, u32 offset, u16 data)
  449. {
  450. return hw->phy.ops.write_reg_locked(hw, offset, data);
  451. }
  452. void e1000e_reload_nvm_generic(struct e1000_hw *hw);
  453. static inline s32 e1000e_read_mac_addr(struct e1000_hw *hw)
  454. {
  455. if (hw->mac.ops.read_mac_addr)
  456. return hw->mac.ops.read_mac_addr(hw);
  457. return e1000_read_mac_addr_generic(hw);
  458. }
  459. static inline s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
  460. {
  461. return hw->nvm.ops.validate(hw);
  462. }
  463. static inline s32 e1000e_update_nvm_checksum(struct e1000_hw *hw)
  464. {
  465. return hw->nvm.ops.update(hw);
  466. }
  467. static inline s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words,
  468. u16 *data)
  469. {
  470. return hw->nvm.ops.read(hw, offset, words, data);
  471. }
  472. static inline s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words,
  473. u16 *data)
  474. {
  475. return hw->nvm.ops.write(hw, offset, words, data);
  476. }
  477. static inline s32 e1000_get_phy_info(struct e1000_hw *hw)
  478. {
  479. return hw->phy.ops.get_info(hw);
  480. }
  481. static inline u32 __er32(struct e1000_hw *hw, unsigned long reg)
  482. {
  483. return readl(hw->hw_addr + reg);
  484. }
  485. #define er32(reg) __er32(hw, E1000_##reg)
  486. s32 __ew32_prepare(struct e1000_hw *hw);
  487. void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val);
  488. #define ew32(reg, val) __ew32(hw, E1000_##reg, (val))
  489. #define e1e_flush() er32(STATUS)
  490. #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) \
  491. (__ew32((a), (reg + ((offset) << 2)), (value)))
  492. #define E1000_READ_REG_ARRAY(a, reg, offset) \
  493. (readl((a)->hw_addr + reg + ((offset) << 2)))
  494. #endif /* _E1000_H_ */