e1000.h 17 KB

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