e1000.h 18 KB

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