stmmac.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*******************************************************************************
  2. Copyright (C) 2007-2009 STMicroelectronics Ltd
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms and conditions of the GNU General Public License,
  5. version 2, as published by the Free Software Foundation.
  6. This program is distributed in the hope it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  8. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  9. more details.
  10. You should have received a copy of the GNU General Public License along with
  11. this program; if not, write to the Free Software Foundation, Inc.,
  12. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  13. The full GNU General Public License is included in this distribution in
  14. the file called "COPYING".
  15. Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
  16. *******************************************************************************/
  17. #ifndef __STMMAC_H__
  18. #define __STMMAC_H__
  19. #define STMMAC_RESOURCE_NAME "stmmaceth"
  20. #define DRV_MODULE_VERSION "Jan_2016"
  21. #include <linux/clk.h>
  22. #include <linux/stmmac.h>
  23. #include <linux/phy.h>
  24. #include <linux/pci.h>
  25. #include "common.h"
  26. #include <linux/ptp_clock_kernel.h>
  27. #include <linux/reset.h>
  28. struct stmmac_resources {
  29. void __iomem *addr;
  30. const char *mac;
  31. int wol_irq;
  32. int lpi_irq;
  33. int irq;
  34. };
  35. struct stmmac_tx_info {
  36. dma_addr_t buf;
  37. bool map_as_page;
  38. unsigned len;
  39. bool last_segment;
  40. bool is_jumbo;
  41. };
  42. struct stmmac_priv {
  43. /* Frequently used values are kept adjacent for cache effect */
  44. struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
  45. struct dma_desc *dma_tx;
  46. struct sk_buff **tx_skbuff;
  47. unsigned int cur_tx;
  48. unsigned int dirty_tx;
  49. u32 tx_count_frames;
  50. u32 tx_coal_frames;
  51. u32 tx_coal_timer;
  52. struct stmmac_tx_info *tx_skbuff_dma;
  53. dma_addr_t dma_tx_phy;
  54. int tx_coalesce;
  55. int hwts_tx_en;
  56. spinlock_t tx_lock;
  57. bool tx_path_in_lpi_mode;
  58. struct timer_list txtimer;
  59. bool tso;
  60. struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
  61. struct dma_extended_desc *dma_erx;
  62. struct sk_buff **rx_skbuff;
  63. unsigned int cur_rx;
  64. unsigned int dirty_rx;
  65. unsigned int dma_buf_sz;
  66. unsigned int rx_copybreak;
  67. unsigned int rx_zeroc_thresh;
  68. u32 rx_riwt;
  69. int hwts_rx_en;
  70. dma_addr_t *rx_skbuff_dma;
  71. dma_addr_t dma_rx_phy;
  72. struct napi_struct napi ____cacheline_aligned_in_smp;
  73. void __iomem *ioaddr;
  74. struct net_device *dev;
  75. struct device *device;
  76. struct mac_device_info *hw;
  77. spinlock_t lock;
  78. struct phy_device *phydev ____cacheline_aligned_in_smp;
  79. int oldlink;
  80. int speed;
  81. int oldduplex;
  82. unsigned int flow_ctrl;
  83. unsigned int pause;
  84. struct mii_bus *mii;
  85. int mii_irq[PHY_MAX_ADDR];
  86. struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
  87. struct plat_stmmacenet_data *plat;
  88. struct dma_features dma_cap;
  89. struct stmmac_counters mmc;
  90. int hw_cap_support;
  91. int synopsys_id;
  92. u32 msg_enable;
  93. int wolopts;
  94. int wol_irq;
  95. struct clk *stmmac_clk;
  96. struct clk *pclk;
  97. struct reset_control *stmmac_rst;
  98. int clk_csr;
  99. struct timer_list eee_ctrl_timer;
  100. int lpi_irq;
  101. int eee_enabled;
  102. int eee_active;
  103. int tx_lpi_timer;
  104. unsigned int mode;
  105. int extend_desc;
  106. struct ptp_clock *ptp_clock;
  107. struct ptp_clock_info ptp_clock_ops;
  108. unsigned int default_addend;
  109. struct clk *clk_ptp_ref;
  110. unsigned int clk_ptp_rate;
  111. u32 adv_ts;
  112. int use_riwt;
  113. int irq_wake;
  114. spinlock_t ptp_lock;
  115. void __iomem *mmcaddr;
  116. void __iomem *ptpaddr;
  117. u32 rx_tail_addr;
  118. u32 tx_tail_addr;
  119. u32 mss;
  120. #ifdef CONFIG_DEBUG_FS
  121. struct dentry *dbgfs_dir;
  122. struct dentry *dbgfs_rings_status;
  123. struct dentry *dbgfs_dma_cap;
  124. #endif
  125. };
  126. int stmmac_mdio_unregister(struct net_device *ndev);
  127. int stmmac_mdio_register(struct net_device *ndev);
  128. int stmmac_mdio_reset(struct mii_bus *mii);
  129. void stmmac_set_ethtool_ops(struct net_device *netdev);
  130. void stmmac_ptp_register(struct stmmac_priv *priv);
  131. void stmmac_ptp_unregister(struct stmmac_priv *priv);
  132. int stmmac_resume(struct device *dev);
  133. int stmmac_suspend(struct device *dev);
  134. int stmmac_dvr_remove(struct device *dev);
  135. int stmmac_dvr_probe(struct device *device,
  136. struct plat_stmmacenet_data *plat_dat,
  137. struct stmmac_resources *res);
  138. void stmmac_disable_eee_mode(struct stmmac_priv *priv);
  139. bool stmmac_eee_init(struct stmmac_priv *priv);
  140. #endif /* __STMMAC_H__ */