e1000.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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. };
  119. struct e1000_ps_page {
  120. struct page *page;
  121. u64 dma; /* must be u64 - written to hw */
  122. };
  123. /* wrappers around a pointer to a socket buffer,
  124. * so a DMA handle can be stored along with the buffer
  125. */
  126. struct e1000_buffer {
  127. dma_addr_t dma;
  128. struct sk_buff *skb;
  129. union {
  130. /* Tx */
  131. struct {
  132. unsigned long time_stamp;
  133. u16 length;
  134. u16 next_to_watch;
  135. unsigned int segs;
  136. unsigned int bytecount;
  137. u16 mapped_as_page;
  138. };
  139. /* Rx */
  140. struct {
  141. /* arrays of page information for packet split */
  142. struct e1000_ps_page *ps_pages;
  143. struct page *page;
  144. };
  145. };
  146. };
  147. struct e1000_ring {
  148. struct e1000_adapter *adapter; /* back pointer to adapter */
  149. void *desc; /* pointer to ring memory */
  150. dma_addr_t dma; /* phys address of ring */
  151. unsigned int size; /* length of ring in bytes */
  152. unsigned int count; /* number of desc. in ring */
  153. u16 next_to_use;
  154. u16 next_to_clean;
  155. void __iomem *head;
  156. void __iomem *tail;
  157. /* array of buffer information structs */
  158. struct e1000_buffer *buffer_info;
  159. char name[IFNAMSIZ + 5];
  160. u32 ims_val;
  161. u32 itr_val;
  162. void __iomem *itr_register;
  163. int set_itr;
  164. struct sk_buff *rx_skb_top;
  165. };
  166. /* PHY register snapshot values */
  167. struct e1000_phy_regs {
  168. u16 bmcr; /* basic mode control register */
  169. u16 bmsr; /* basic mode status register */
  170. u16 advertise; /* auto-negotiation advertisement */
  171. u16 lpa; /* link partner ability register */
  172. u16 expansion; /* auto-negotiation expansion reg */
  173. u16 ctrl1000; /* 1000BASE-T control register */
  174. u16 stat1000; /* 1000BASE-T status register */
  175. u16 estatus; /* extended status register */
  176. };
  177. /* board specific private data structure */
  178. struct e1000_adapter {
  179. struct timer_list watchdog_timer;
  180. struct timer_list phy_info_timer;
  181. struct timer_list blink_timer;
  182. struct work_struct reset_task;
  183. struct work_struct watchdog_task;
  184. const struct e1000_info *ei;
  185. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  186. u32 bd_number;
  187. u32 rx_buffer_len;
  188. u16 mng_vlan_id;
  189. u16 link_speed;
  190. u16 link_duplex;
  191. u16 eeprom_vers;
  192. /* track device up/down/testing state */
  193. unsigned long state;
  194. /* Interrupt Throttle Rate */
  195. u32 itr;
  196. u32 itr_setting;
  197. u16 tx_itr;
  198. u16 rx_itr;
  199. /* Tx - one ring per active queue */
  200. struct e1000_ring *tx_ring ____cacheline_aligned_in_smp;
  201. u32 tx_fifo_limit;
  202. struct napi_struct napi;
  203. unsigned int uncorr_errors; /* uncorrectable ECC errors */
  204. unsigned int corr_errors; /* correctable ECC errors */
  205. unsigned int restart_queue;
  206. u32 txd_cmd;
  207. bool detect_tx_hung;
  208. bool tx_hang_recheck;
  209. u8 tx_timeout_factor;
  210. u32 tx_int_delay;
  211. u32 tx_abs_int_delay;
  212. unsigned int total_tx_bytes;
  213. unsigned int total_tx_packets;
  214. unsigned int total_rx_bytes;
  215. unsigned int total_rx_packets;
  216. /* Tx stats */
  217. u64 tpt_old;
  218. u64 colc_old;
  219. u32 gotc;
  220. u64 gotc_old;
  221. u32 tx_timeout_count;
  222. u32 tx_fifo_head;
  223. u32 tx_head_addr;
  224. u32 tx_fifo_size;
  225. u32 tx_dma_failed;
  226. u32 tx_hwtstamp_timeouts;
  227. /* Rx */
  228. bool (*clean_rx)(struct e1000_ring *ring, int *work_done,
  229. int work_to_do) ____cacheline_aligned_in_smp;
  230. void (*alloc_rx_buf)(struct e1000_ring *ring, int cleaned_count,
  231. gfp_t gfp);
  232. struct e1000_ring *rx_ring;
  233. u32 rx_int_delay;
  234. u32 rx_abs_int_delay;
  235. /* Rx stats */
  236. u64 hw_csum_err;
  237. u64 hw_csum_good;
  238. u64 rx_hdr_split;
  239. u32 gorc;
  240. u64 gorc_old;
  241. u32 alloc_rx_buff_failed;
  242. u32 rx_dma_failed;
  243. u32 rx_hwtstamp_cleared;
  244. unsigned int rx_ps_pages;
  245. u16 rx_ps_bsize0;
  246. u32 max_frame_size;
  247. u32 min_frame_size;
  248. /* OS defined structs */
  249. struct net_device *netdev;
  250. struct pci_dev *pdev;
  251. /* structs defined in e1000_hw.h */
  252. struct e1000_hw hw;
  253. spinlock_t stats64_lock; /* protects statistics counters */
  254. struct e1000_hw_stats stats;
  255. struct e1000_phy_info phy_info;
  256. struct e1000_phy_stats phy_stats;
  257. /* Snapshot of PHY registers */
  258. struct e1000_phy_regs phy_regs;
  259. struct e1000_ring test_tx_ring;
  260. struct e1000_ring test_rx_ring;
  261. u32 test_icr;
  262. u32 msg_enable;
  263. unsigned int num_vectors;
  264. struct msix_entry *msix_entries;
  265. int int_mode;
  266. u32 eiac_mask;
  267. u32 eeprom_wol;
  268. u32 wol;
  269. u32 pba;
  270. u32 max_hw_frame_size;
  271. bool fc_autoneg;
  272. unsigned int flags;
  273. unsigned int flags2;
  274. struct work_struct downshift_task;
  275. struct work_struct update_phy_task;
  276. struct work_struct print_hang_task;
  277. int phy_hang_count;
  278. u16 tx_ring_count;
  279. u16 rx_ring_count;
  280. struct hwtstamp_config hwtstamp_config;
  281. struct delayed_work systim_overflow_work;
  282. struct sk_buff *tx_hwtstamp_skb;
  283. unsigned long tx_hwtstamp_start;
  284. struct work_struct tx_hwtstamp_work;
  285. spinlock_t systim_lock; /* protects SYSTIML/H regsters */
  286. struct cyclecounter cc;
  287. struct timecounter tc;
  288. struct ptp_clock *ptp_clock;
  289. struct ptp_clock_info ptp_clock_info;
  290. struct pm_qos_request pm_qos_req;
  291. s32 ptp_delta;
  292. u16 eee_advert;
  293. };
  294. struct e1000_info {
  295. enum e1000_mac_type mac;
  296. unsigned int flags;
  297. unsigned int flags2;
  298. u32 pba;
  299. u32 max_hw_frame_size;
  300. s32 (*get_variants)(struct e1000_adapter *);
  301. const struct e1000_mac_operations *mac_ops;
  302. const struct e1000_phy_operations *phy_ops;
  303. const struct e1000_nvm_operations *nvm_ops;
  304. };
  305. s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca);
  306. /* The system time is maintained by a 64-bit counter comprised of the 32-bit
  307. * SYSTIMH and SYSTIML registers. How the counter increments (and therefore
  308. * its resolution) is based on the contents of the TIMINCA register - it
  309. * increments every incperiod (bits 31:24) clock ticks by incvalue (bits 23:0).
  310. * For the best accuracy, the incperiod should be as small as possible. The
  311. * incvalue is scaled by a factor as large as possible (while still fitting
  312. * in bits 23:0) so that relatively small clock corrections can be made.
  313. *
  314. * As a result, a shift of INCVALUE_SHIFT_n is used to fit a value of
  315. * INCVALUE_n into the TIMINCA register allowing 32+8+(24-INCVALUE_SHIFT_n)
  316. * bits to count nanoseconds leaving the rest for fractional nonseconds.
  317. */
  318. #define INCVALUE_96MHz 125
  319. #define INCVALUE_SHIFT_96MHz 17
  320. #define INCPERIOD_SHIFT_96MHz 2
  321. #define INCPERIOD_96MHz (12 >> INCPERIOD_SHIFT_96MHz)
  322. #define INCVALUE_25MHz 40
  323. #define INCVALUE_SHIFT_25MHz 18
  324. #define INCPERIOD_25MHz 1
  325. #define INCVALUE_24MHz 125
  326. #define INCVALUE_SHIFT_24MHz 14
  327. #define INCPERIOD_24MHz 3
  328. /* Another drawback of scaling the incvalue by a large factor is the
  329. * 64-bit SYSTIM register overflows more quickly. This is dealt with
  330. * by simply reading the clock before it overflows.
  331. *
  332. * Clock ns bits Overflows after
  333. * ~~~~~~ ~~~~~~~ ~~~~~~~~~~~~~~~
  334. * 96MHz 47-bit 2^(47-INCPERIOD_SHIFT_96MHz) / 10^9 / 3600 = 9.77 hrs
  335. * 25MHz 46-bit 2^46 / 10^9 / 3600 = 19.55 hours
  336. */
  337. #define E1000_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 60 * 4)
  338. #define E1000_MAX_82574_SYSTIM_REREADS 50
  339. #define E1000_82574_SYSTIM_EPSILON (1ULL << 35ULL)
  340. /* hardware capability, feature, and workaround flags */
  341. #define FLAG_HAS_AMT BIT(0)
  342. #define FLAG_HAS_FLASH BIT(1)
  343. #define FLAG_HAS_HW_VLAN_FILTER BIT(2)
  344. #define FLAG_HAS_WOL BIT(3)
  345. /* reserved BIT(4) */
  346. #define FLAG_HAS_CTRLEXT_ON_LOAD BIT(5)
  347. #define FLAG_HAS_SWSM_ON_LOAD BIT(6)
  348. #define FLAG_HAS_JUMBO_FRAMES BIT(7)
  349. #define FLAG_READ_ONLY_NVM BIT(8)
  350. #define FLAG_IS_ICH BIT(9)
  351. #define FLAG_HAS_MSIX BIT(10)
  352. #define FLAG_HAS_SMART_POWER_DOWN BIT(11)
  353. #define FLAG_IS_QUAD_PORT_A BIT(12)
  354. #define FLAG_IS_QUAD_PORT BIT(13)
  355. #define FLAG_HAS_HW_TIMESTAMP BIT(14)
  356. #define FLAG_APME_IN_WUC BIT(15)
  357. #define FLAG_APME_IN_CTRL3 BIT(16)
  358. #define FLAG_APME_CHECK_PORT_B BIT(17)
  359. #define FLAG_DISABLE_FC_PAUSE_TIME BIT(18)
  360. #define FLAG_NO_WAKE_UCAST BIT(19)
  361. #define FLAG_MNG_PT_ENABLED BIT(20)
  362. #define FLAG_RESET_OVERWRITES_LAA BIT(21)
  363. #define FLAG_TARC_SPEED_MODE_BIT BIT(22)
  364. #define FLAG_TARC_SET_BIT_ZERO BIT(23)
  365. #define FLAG_RX_NEEDS_RESTART BIT(24)
  366. #define FLAG_LSC_GIG_SPEED_DROP BIT(25)
  367. #define FLAG_SMART_POWER_DOWN BIT(26)
  368. #define FLAG_MSI_ENABLED BIT(27)
  369. /* reserved BIT(28) */
  370. #define FLAG_TSO_FORCE BIT(29)
  371. #define FLAG_RESTART_NOW BIT(30)
  372. #define FLAG_MSI_TEST_FAILED BIT(31)
  373. #define FLAG2_CRC_STRIPPING BIT(0)
  374. #define FLAG2_HAS_PHY_WAKEUP BIT(1)
  375. #define FLAG2_IS_DISCARDING BIT(2)
  376. #define FLAG2_DISABLE_ASPM_L1 BIT(3)
  377. #define FLAG2_HAS_PHY_STATS BIT(4)
  378. #define FLAG2_HAS_EEE BIT(5)
  379. #define FLAG2_DMA_BURST BIT(6)
  380. #define FLAG2_DISABLE_ASPM_L0S BIT(7)
  381. #define FLAG2_DISABLE_AIM BIT(8)
  382. #define FLAG2_CHECK_PHY_HANG BIT(9)
  383. #define FLAG2_NO_DISABLE_RX BIT(10)
  384. #define FLAG2_PCIM2PCI_ARBITER_WA BIT(11)
  385. #define FLAG2_DFLT_CRC_STRIPPING BIT(12)
  386. #define FLAG2_CHECK_RX_HWTSTAMP BIT(13)
  387. #define FLAG2_CHECK_SYSTIM_OVERFLOW BIT(14)
  388. #define E1000_RX_DESC_PS(R, i) \
  389. (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
  390. #define E1000_RX_DESC_EXT(R, i) \
  391. (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
  392. #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
  393. #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
  394. #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
  395. enum e1000_state_t {
  396. __E1000_TESTING,
  397. __E1000_RESETTING,
  398. __E1000_ACCESS_SHARED_RESOURCE,
  399. __E1000_DOWN
  400. };
  401. enum latency_range {
  402. lowest_latency = 0,
  403. low_latency = 1,
  404. bulk_latency = 2,
  405. latency_invalid = 255
  406. };
  407. extern char e1000e_driver_name[];
  408. extern const char e1000e_driver_version[];
  409. void e1000e_check_options(struct e1000_adapter *adapter);
  410. void e1000e_set_ethtool_ops(struct net_device *netdev);
  411. int e1000e_open(struct net_device *netdev);
  412. int e1000e_close(struct net_device *netdev);
  413. void e1000e_up(struct e1000_adapter *adapter);
  414. void e1000e_down(struct e1000_adapter *adapter, bool reset);
  415. void e1000e_reinit_locked(struct e1000_adapter *adapter);
  416. void e1000e_reset(struct e1000_adapter *adapter);
  417. void e1000e_power_up_phy(struct e1000_adapter *adapter);
  418. int e1000e_setup_rx_resources(struct e1000_ring *ring);
  419. int e1000e_setup_tx_resources(struct e1000_ring *ring);
  420. void e1000e_free_rx_resources(struct e1000_ring *ring);
  421. void e1000e_free_tx_resources(struct e1000_ring *ring);
  422. struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
  423. struct rtnl_link_stats64 *stats);
  424. void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
  425. void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
  426. void e1000e_get_hw_control(struct e1000_adapter *adapter);
  427. void e1000e_release_hw_control(struct e1000_adapter *adapter);
  428. void e1000e_write_itr(struct e1000_adapter *adapter, u32 itr);
  429. extern unsigned int copybreak;
  430. extern const struct e1000_info e1000_82571_info;
  431. extern const struct e1000_info e1000_82572_info;
  432. extern const struct e1000_info e1000_82573_info;
  433. extern const struct e1000_info e1000_82574_info;
  434. extern const struct e1000_info e1000_82583_info;
  435. extern const struct e1000_info e1000_ich8_info;
  436. extern const struct e1000_info e1000_ich9_info;
  437. extern const struct e1000_info e1000_ich10_info;
  438. extern const struct e1000_info e1000_pch_info;
  439. extern const struct e1000_info e1000_pch2_info;
  440. extern const struct e1000_info e1000_pch_lpt_info;
  441. extern const struct e1000_info e1000_pch_spt_info;
  442. extern const struct e1000_info e1000_es2_info;
  443. void e1000e_ptp_init(struct e1000_adapter *adapter);
  444. void e1000e_ptp_remove(struct e1000_adapter *adapter);
  445. static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw)
  446. {
  447. return hw->phy.ops.reset(hw);
  448. }
  449. static inline s32 e1e_rphy(struct e1000_hw *hw, u32 offset, u16 *data)
  450. {
  451. return hw->phy.ops.read_reg(hw, offset, data);
  452. }
  453. static inline s32 e1e_rphy_locked(struct e1000_hw *hw, u32 offset, u16 *data)
  454. {
  455. return hw->phy.ops.read_reg_locked(hw, offset, data);
  456. }
  457. static inline s32 e1e_wphy(struct e1000_hw *hw, u32 offset, u16 data)
  458. {
  459. return hw->phy.ops.write_reg(hw, offset, data);
  460. }
  461. static inline s32 e1e_wphy_locked(struct e1000_hw *hw, u32 offset, u16 data)
  462. {
  463. return hw->phy.ops.write_reg_locked(hw, offset, data);
  464. }
  465. void e1000e_reload_nvm_generic(struct e1000_hw *hw);
  466. static inline s32 e1000e_read_mac_addr(struct e1000_hw *hw)
  467. {
  468. if (hw->mac.ops.read_mac_addr)
  469. return hw->mac.ops.read_mac_addr(hw);
  470. return e1000_read_mac_addr_generic(hw);
  471. }
  472. static inline s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
  473. {
  474. return hw->nvm.ops.validate(hw);
  475. }
  476. static inline s32 e1000e_update_nvm_checksum(struct e1000_hw *hw)
  477. {
  478. return hw->nvm.ops.update(hw);
  479. }
  480. static inline s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words,
  481. u16 *data)
  482. {
  483. return hw->nvm.ops.read(hw, offset, words, data);
  484. }
  485. static inline s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words,
  486. u16 *data)
  487. {
  488. return hw->nvm.ops.write(hw, offset, words, data);
  489. }
  490. static inline s32 e1000_get_phy_info(struct e1000_hw *hw)
  491. {
  492. return hw->phy.ops.get_info(hw);
  493. }
  494. static inline u32 __er32(struct e1000_hw *hw, unsigned long reg)
  495. {
  496. return readl(hw->hw_addr + reg);
  497. }
  498. #define er32(reg) __er32(hw, E1000_##reg)
  499. s32 __ew32_prepare(struct e1000_hw *hw);
  500. void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val);
  501. #define ew32(reg, val) __ew32(hw, E1000_##reg, (val))
  502. #define e1e_flush() er32(STATUS)
  503. #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) \
  504. (__ew32((a), (reg + ((offset) << 2)), (value)))
  505. #define E1000_READ_REG_ARRAY(a, reg, offset) \
  506. (readl((a)->hw_addr + reg + ((offset) << 2)))
  507. #endif /* _E1000_H_ */