e1000.h 18 KB

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