/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h

http://github.com/mirrors/linux · C Header · 635 lines · 396 code · 53 blank · 186 comment · 0 complexity · 18ca7b9d886ea688aceb016f204d1ab8 MD5 · raw file

  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 1999 - 2010 Intel Corporation.
  4. * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD.
  5. *
  6. * This code was derived from the Intel e1000e Linux driver.
  7. */
  8. #ifndef _PCH_GBE_H_
  9. #define _PCH_GBE_H_
  10. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  11. #include <linux/mii.h>
  12. #include <linux/delay.h>
  13. #include <linux/pci.h>
  14. #include <linux/netdevice.h>
  15. #include <linux/etherdevice.h>
  16. #include <linux/ethtool.h>
  17. #include <linux/vmalloc.h>
  18. #include <net/ip.h>
  19. #include <net/tcp.h>
  20. #include <net/udp.h>
  21. /**
  22. * pch_gbe_regs_mac_adr - Structure holding values of mac address registers
  23. * @high Denotes the 1st to 4th byte from the initial of MAC address
  24. * @low Denotes the 5th to 6th byte from the initial of MAC address
  25. */
  26. struct pch_gbe_regs_mac_adr {
  27. u32 high;
  28. u32 low;
  29. };
  30. /**
  31. * pch_udc_regs - Structure holding values of MAC registers
  32. */
  33. struct pch_gbe_regs {
  34. u32 INT_ST;
  35. u32 INT_EN;
  36. u32 MODE;
  37. u32 RESET;
  38. u32 TCPIP_ACC;
  39. u32 EX_LIST;
  40. u32 INT_ST_HOLD;
  41. u32 PHY_INT_CTRL;
  42. u32 MAC_RX_EN;
  43. u32 RX_FCTRL;
  44. u32 PAUSE_REQ;
  45. u32 RX_MODE;
  46. u32 TX_MODE;
  47. u32 RX_FIFO_ST;
  48. u32 TX_FIFO_ST;
  49. u32 TX_FID;
  50. u32 TX_RESULT;
  51. u32 PAUSE_PKT1;
  52. u32 PAUSE_PKT2;
  53. u32 PAUSE_PKT3;
  54. u32 PAUSE_PKT4;
  55. u32 PAUSE_PKT5;
  56. u32 reserve[2];
  57. struct pch_gbe_regs_mac_adr mac_adr[16];
  58. u32 ADDR_MASK;
  59. u32 MIIM;
  60. u32 MAC_ADDR_LOAD;
  61. u32 RGMII_ST;
  62. u32 RGMII_CTRL;
  63. u32 reserve3[3];
  64. u32 DMA_CTRL;
  65. u32 reserve4[3];
  66. u32 RX_DSC_BASE;
  67. u32 RX_DSC_SIZE;
  68. u32 RX_DSC_HW_P;
  69. u32 RX_DSC_HW_P_HLD;
  70. u32 RX_DSC_SW_P;
  71. u32 reserve5[3];
  72. u32 TX_DSC_BASE;
  73. u32 TX_DSC_SIZE;
  74. u32 TX_DSC_HW_P;
  75. u32 TX_DSC_HW_P_HLD;
  76. u32 TX_DSC_SW_P;
  77. u32 reserve6[3];
  78. u32 RX_DMA_ST;
  79. u32 TX_DMA_ST;
  80. u32 reserve7[2];
  81. u32 WOL_ST;
  82. u32 WOL_CTRL;
  83. u32 WOL_ADDR_MASK;
  84. };
  85. /* Interrupt Status */
  86. /* Interrupt Status Hold */
  87. /* Interrupt Enable */
  88. #define PCH_GBE_INT_RX_DMA_CMPLT 0x00000001 /* Receive DMA Transfer Complete */
  89. #define PCH_GBE_INT_RX_VALID 0x00000002 /* MAC Normal Receive Complete */
  90. #define PCH_GBE_INT_RX_FRAME_ERR 0x00000004 /* Receive frame error */
  91. #define PCH_GBE_INT_RX_FIFO_ERR 0x00000008 /* Receive FIFO Overflow */
  92. #define PCH_GBE_INT_RX_DMA_ERR 0x00000010 /* Receive DMA Transfer Error */
  93. #define PCH_GBE_INT_RX_DSC_EMP 0x00000020 /* Receive Descriptor Empty */
  94. #define PCH_GBE_INT_TX_CMPLT 0x00000100 /* MAC Transmission Complete */
  95. #define PCH_GBE_INT_TX_DMA_CMPLT 0x00000200 /* DMA Transfer Complete */
  96. #define PCH_GBE_INT_TX_FIFO_ERR 0x00000400 /* Transmission FIFO underflow. */
  97. #define PCH_GBE_INT_TX_DMA_ERR 0x00000800 /* Transmission DMA Error */
  98. #define PCH_GBE_INT_PAUSE_CMPLT 0x00001000 /* Pause Transmission complete */
  99. #define PCH_GBE_INT_MIIM_CMPLT 0x00010000 /* MIIM I/F Read completion */
  100. #define PCH_GBE_INT_PHY_INT 0x00100000 /* Interruption from PHY */
  101. #define PCH_GBE_INT_WOL_DET 0x01000000 /* Wake On LAN Event detection. */
  102. #define PCH_GBE_INT_TCPIP_ERR 0x10000000 /* TCP/IP Accelerator Error */
  103. /* Mode */
  104. #define PCH_GBE_MODE_MII_ETHER 0x00000000 /* GIGA Ethernet Mode [MII] */
  105. #define PCH_GBE_MODE_GMII_ETHER 0x80000000 /* GIGA Ethernet Mode [GMII] */
  106. #define PCH_GBE_MODE_HALF_DUPLEX 0x00000000 /* Duplex Mode [half duplex] */
  107. #define PCH_GBE_MODE_FULL_DUPLEX 0x40000000 /* Duplex Mode [full duplex] */
  108. #define PCH_GBE_MODE_FR_BST 0x04000000 /* Frame bursting is done */
  109. /* Reset */
  110. #define PCH_GBE_ALL_RST 0x80000000 /* All reset */
  111. #define PCH_GBE_TX_RST 0x00008000 /* TX MAC, TX FIFO, TX DMA reset */
  112. #define PCH_GBE_RX_RST 0x00004000 /* RX MAC, RX FIFO, RX DMA reset */
  113. /* TCP/IP Accelerator Control */
  114. #define PCH_GBE_EX_LIST_EN 0x00000008 /* External List Enable */
  115. #define PCH_GBE_RX_TCPIPACC_OFF 0x00000004 /* RX TCP/IP ACC Disabled */
  116. #define PCH_GBE_TX_TCPIPACC_EN 0x00000002 /* TX TCP/IP ACC Enable */
  117. #define PCH_GBE_RX_TCPIPACC_EN 0x00000001 /* RX TCP/IP ACC Enable */
  118. /* MAC RX Enable */
  119. #define PCH_GBE_MRE_MAC_RX_EN 0x00000001 /* MAC Receive Enable */
  120. /* RX Flow Control */
  121. #define PCH_GBE_FL_CTRL_EN 0x80000000 /* Pause packet is enabled */
  122. /* Pause Packet Request */
  123. #define PCH_GBE_PS_PKT_RQ 0x80000000 /* Pause packet Request */
  124. /* RX Mode */
  125. #define PCH_GBE_ADD_FIL_EN 0x80000000 /* Address Filtering Enable */
  126. /* Multicast Filtering Enable */
  127. #define PCH_GBE_MLT_FIL_EN 0x40000000
  128. /* Receive Almost Empty Threshold */
  129. #define PCH_GBE_RH_ALM_EMP_4 0x00000000 /* 4 words */
  130. #define PCH_GBE_RH_ALM_EMP_8 0x00004000 /* 8 words */
  131. #define PCH_GBE_RH_ALM_EMP_16 0x00008000 /* 16 words */
  132. #define PCH_GBE_RH_ALM_EMP_32 0x0000C000 /* 32 words */
  133. /* Receive Almost Full Threshold */
  134. #define PCH_GBE_RH_ALM_FULL_4 0x00000000 /* 4 words */
  135. #define PCH_GBE_RH_ALM_FULL_8 0x00001000 /* 8 words */
  136. #define PCH_GBE_RH_ALM_FULL_16 0x00002000 /* 16 words */
  137. #define PCH_GBE_RH_ALM_FULL_32 0x00003000 /* 32 words */
  138. /* RX FIFO Read Triger Threshold */
  139. #define PCH_GBE_RH_RD_TRG_4 0x00000000 /* 4 words */
  140. #define PCH_GBE_RH_RD_TRG_8 0x00000200 /* 8 words */
  141. #define PCH_GBE_RH_RD_TRG_16 0x00000400 /* 16 words */
  142. #define PCH_GBE_RH_RD_TRG_32 0x00000600 /* 32 words */
  143. #define PCH_GBE_RH_RD_TRG_64 0x00000800 /* 64 words */
  144. #define PCH_GBE_RH_RD_TRG_128 0x00000A00 /* 128 words */
  145. #define PCH_GBE_RH_RD_TRG_256 0x00000C00 /* 256 words */
  146. #define PCH_GBE_RH_RD_TRG_512 0x00000E00 /* 512 words */
  147. /* Receive Descriptor bit definitions */
  148. #define PCH_GBE_RXD_ACC_STAT_BCAST 0x00000400
  149. #define PCH_GBE_RXD_ACC_STAT_MCAST 0x00000200
  150. #define PCH_GBE_RXD_ACC_STAT_UCAST 0x00000100
  151. #define PCH_GBE_RXD_ACC_STAT_TCPIPOK 0x000000C0
  152. #define PCH_GBE_RXD_ACC_STAT_IPOK 0x00000080
  153. #define PCH_GBE_RXD_ACC_STAT_TCPOK 0x00000040
  154. #define PCH_GBE_RXD_ACC_STAT_IP6ERR 0x00000020
  155. #define PCH_GBE_RXD_ACC_STAT_OFLIST 0x00000010
  156. #define PCH_GBE_RXD_ACC_STAT_TYPEIP 0x00000008
  157. #define PCH_GBE_RXD_ACC_STAT_MACL 0x00000004
  158. #define PCH_GBE_RXD_ACC_STAT_PPPOE 0x00000002
  159. #define PCH_GBE_RXD_ACC_STAT_VTAGT 0x00000001
  160. #define PCH_GBE_RXD_GMAC_STAT_PAUSE 0x0200
  161. #define PCH_GBE_RXD_GMAC_STAT_MARBR 0x0100
  162. #define PCH_GBE_RXD_GMAC_STAT_MARMLT 0x0080
  163. #define PCH_GBE_RXD_GMAC_STAT_MARIND 0x0040
  164. #define PCH_GBE_RXD_GMAC_STAT_MARNOTMT 0x0020
  165. #define PCH_GBE_RXD_GMAC_STAT_TLONG 0x0010
  166. #define PCH_GBE_RXD_GMAC_STAT_TSHRT 0x0008
  167. #define PCH_GBE_RXD_GMAC_STAT_NOTOCTAL 0x0004
  168. #define PCH_GBE_RXD_GMAC_STAT_NBLERR 0x0002
  169. #define PCH_GBE_RXD_GMAC_STAT_CRCERR 0x0001
  170. /* Transmit Descriptor bit definitions */
  171. #define PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF 0x0008
  172. #define PCH_GBE_TXD_CTRL_ITAG 0x0004
  173. #define PCH_GBE_TXD_CTRL_ICRC 0x0002
  174. #define PCH_GBE_TXD_CTRL_APAD 0x0001
  175. #define PCH_GBE_TXD_WORDS_SHIFT 2
  176. #define PCH_GBE_TXD_GMAC_STAT_CMPLT 0x2000
  177. #define PCH_GBE_TXD_GMAC_STAT_ABT 0x1000
  178. #define PCH_GBE_TXD_GMAC_STAT_EXCOL 0x0800
  179. #define PCH_GBE_TXD_GMAC_STAT_SNGCOL 0x0400
  180. #define PCH_GBE_TXD_GMAC_STAT_MLTCOL 0x0200
  181. #define PCH_GBE_TXD_GMAC_STAT_CRSER 0x0100
  182. #define PCH_GBE_TXD_GMAC_STAT_TLNG 0x0080
  183. #define PCH_GBE_TXD_GMAC_STAT_TSHRT 0x0040
  184. #define PCH_GBE_TXD_GMAC_STAT_LTCOL 0x0020
  185. #define PCH_GBE_TXD_GMAC_STAT_TFUNDFLW 0x0010
  186. #define PCH_GBE_TXD_GMAC_STAT_RTYCNT_MASK 0x000F
  187. /* TX Mode */
  188. #define PCH_GBE_TM_NO_RTRY 0x80000000 /* No Retransmission */
  189. #define PCH_GBE_TM_LONG_PKT 0x40000000 /* Long Packt TX Enable */
  190. #define PCH_GBE_TM_ST_AND_FD 0x20000000 /* Stare and Forward */
  191. #define PCH_GBE_TM_SHORT_PKT 0x10000000 /* Short Packet TX Enable */
  192. #define PCH_GBE_TM_LTCOL_RETX 0x08000000 /* Retransmission at Late Collision */
  193. /* Frame Start Threshold */
  194. #define PCH_GBE_TM_TH_TX_STRT_4 0x00000000 /* 4 words */
  195. #define PCH_GBE_TM_TH_TX_STRT_8 0x00004000 /* 8 words */
  196. #define PCH_GBE_TM_TH_TX_STRT_16 0x00008000 /* 16 words */
  197. #define PCH_GBE_TM_TH_TX_STRT_32 0x0000C000 /* 32 words */
  198. /* Transmit Almost Empty Threshold */
  199. #define PCH_GBE_TM_TH_ALM_EMP_4 0x00000000 /* 4 words */
  200. #define PCH_GBE_TM_TH_ALM_EMP_8 0x00000800 /* 8 words */
  201. #define PCH_GBE_TM_TH_ALM_EMP_16 0x00001000 /* 16 words */
  202. #define PCH_GBE_TM_TH_ALM_EMP_32 0x00001800 /* 32 words */
  203. #define PCH_GBE_TM_TH_ALM_EMP_64 0x00002000 /* 64 words */
  204. #define PCH_GBE_TM_TH_ALM_EMP_128 0x00002800 /* 128 words */
  205. #define PCH_GBE_TM_TH_ALM_EMP_256 0x00003000 /* 256 words */
  206. #define PCH_GBE_TM_TH_ALM_EMP_512 0x00003800 /* 512 words */
  207. /* Transmit Almost Full Threshold */
  208. #define PCH_GBE_TM_TH_ALM_FULL_4 0x00000000 /* 4 words */
  209. #define PCH_GBE_TM_TH_ALM_FULL_8 0x00000200 /* 8 words */
  210. #define PCH_GBE_TM_TH_ALM_FULL_16 0x00000400 /* 16 words */
  211. #define PCH_GBE_TM_TH_ALM_FULL_32 0x00000600 /* 32 words */
  212. /* RX FIFO Status */
  213. #define PCH_GBE_RF_ALM_FULL 0x80000000 /* RX FIFO is almost full. */
  214. #define PCH_GBE_RF_ALM_EMP 0x40000000 /* RX FIFO is almost empty. */
  215. #define PCH_GBE_RF_RD_TRG 0x20000000 /* Become more than RH_RD_TRG. */
  216. #define PCH_GBE_RF_STRWD 0x1FFE0000 /* The word count of RX FIFO. */
  217. #define PCH_GBE_RF_RCVING 0x00010000 /* Stored in RX FIFO. */
  218. /* MAC Address Mask */
  219. #define PCH_GBE_BUSY 0x80000000
  220. /* MIIM */
  221. #define PCH_GBE_MIIM_OPER_WRITE 0x04000000
  222. #define PCH_GBE_MIIM_OPER_READ 0x00000000
  223. #define PCH_GBE_MIIM_OPER_READY 0x04000000
  224. #define PCH_GBE_MIIM_PHY_ADDR_SHIFT 21
  225. #define PCH_GBE_MIIM_REG_ADDR_SHIFT 16
  226. /* RGMII Status */
  227. #define PCH_GBE_LINK_UP 0x80000008
  228. #define PCH_GBE_RXC_SPEED_MSK 0x00000006
  229. #define PCH_GBE_RXC_SPEED_2_5M 0x00000000 /* 2.5MHz */
  230. #define PCH_GBE_RXC_SPEED_25M 0x00000002 /* 25MHz */
  231. #define PCH_GBE_RXC_SPEED_125M 0x00000004 /* 100MHz */
  232. #define PCH_GBE_DUPLEX_FULL 0x00000001
  233. /* RGMII Control */
  234. #define PCH_GBE_CRS_SEL 0x00000010
  235. #define PCH_GBE_RGMII_RATE_125M 0x00000000
  236. #define PCH_GBE_RGMII_RATE_25M 0x00000008
  237. #define PCH_GBE_RGMII_RATE_2_5M 0x0000000C
  238. #define PCH_GBE_RGMII_MODE_GMII 0x00000000
  239. #define PCH_GBE_RGMII_MODE_RGMII 0x00000002
  240. #define PCH_GBE_CHIP_TYPE_EXTERNAL 0x00000000
  241. #define PCH_GBE_CHIP_TYPE_INTERNAL 0x00000001
  242. /* DMA Control */
  243. #define PCH_GBE_RX_DMA_EN 0x00000002 /* Enables Receive DMA */
  244. #define PCH_GBE_TX_DMA_EN 0x00000001 /* Enables Transmission DMA */
  245. /* RX DMA STATUS */
  246. #define PCH_GBE_IDLE_CHECK 0xFFFFFFFE
  247. /* Wake On LAN Status */
  248. #define PCH_GBE_WLS_BR 0x00000008 /* Broadcas Address */
  249. #define PCH_GBE_WLS_MLT 0x00000004 /* Multicast Address */
  250. /* The Frame registered in Address Recognizer */
  251. #define PCH_GBE_WLS_IND 0x00000002
  252. #define PCH_GBE_WLS_MP 0x00000001 /* Magic packet Address */
  253. /* Wake On LAN Control */
  254. #define PCH_GBE_WLC_WOL_MODE 0x00010000
  255. #define PCH_GBE_WLC_IGN_TLONG 0x00000100
  256. #define PCH_GBE_WLC_IGN_TSHRT 0x00000080
  257. #define PCH_GBE_WLC_IGN_OCTER 0x00000040
  258. #define PCH_GBE_WLC_IGN_NBLER 0x00000020
  259. #define PCH_GBE_WLC_IGN_CRCER 0x00000010
  260. #define PCH_GBE_WLC_BR 0x00000008
  261. #define PCH_GBE_WLC_MLT 0x00000004
  262. #define PCH_GBE_WLC_IND 0x00000002
  263. #define PCH_GBE_WLC_MP 0x00000001
  264. /* Wake On LAN Address Mask */
  265. #define PCH_GBE_WLA_BUSY 0x80000000
  266. /* TX/RX descriptor defines */
  267. #define PCH_GBE_MAX_TXD 4096
  268. #define PCH_GBE_DEFAULT_TXD 256
  269. #define PCH_GBE_MIN_TXD 8
  270. #define PCH_GBE_MAX_RXD 4096
  271. #define PCH_GBE_DEFAULT_RXD 256
  272. #define PCH_GBE_MIN_RXD 8
  273. /* Number of Transmit and Receive Descriptors must be a multiple of 8 */
  274. #define PCH_GBE_TX_DESC_MULTIPLE 8
  275. #define PCH_GBE_RX_DESC_MULTIPLE 8
  276. /* Read/Write operation is done through MII Management IF */
  277. #define PCH_GBE_HAL_MIIM_READ ((u32)0x00000000)
  278. #define PCH_GBE_HAL_MIIM_WRITE ((u32)0x04000000)
  279. /* flow control values */
  280. #define PCH_GBE_FC_NONE 0
  281. #define PCH_GBE_FC_RX_PAUSE 1
  282. #define PCH_GBE_FC_TX_PAUSE 2
  283. #define PCH_GBE_FC_FULL 3
  284. #define PCH_GBE_FC_DEFAULT PCH_GBE_FC_FULL
  285. /**
  286. * struct pch_gbe_mac_info - MAC information
  287. * @addr[6]: Store the MAC address
  288. * @fc: Mode of flow control
  289. * @fc_autoneg: Auto negotiation enable for flow control setting
  290. * @tx_fc_enable: Enable flag of Transmit flow control
  291. * @max_frame_size: Max transmit frame size
  292. * @min_frame_size: Min transmit frame size
  293. * @autoneg: Auto negotiation enable
  294. * @link_speed: Link speed
  295. * @link_duplex: Link duplex
  296. */
  297. struct pch_gbe_mac_info {
  298. u8 addr[6];
  299. u8 fc;
  300. u8 fc_autoneg;
  301. u8 tx_fc_enable;
  302. u32 max_frame_size;
  303. u32 min_frame_size;
  304. u8 autoneg;
  305. u16 link_speed;
  306. u16 link_duplex;
  307. };
  308. /**
  309. * struct pch_gbe_phy_info - PHY information
  310. * @addr: PHY address
  311. * @id: PHY's identifier
  312. * @revision: PHY's revision
  313. * @reset_delay_us: HW reset delay time[us]
  314. * @autoneg_advertised: Autoneg advertised
  315. */
  316. struct pch_gbe_phy_info {
  317. u32 addr;
  318. u32 id;
  319. u32 revision;
  320. u32 reset_delay_us;
  321. u16 autoneg_advertised;
  322. };
  323. /*!
  324. * @ingroup Gigabit Ether driver Layer
  325. * @struct pch_gbe_hw
  326. * @brief Hardware information
  327. */
  328. struct pch_gbe_hw {
  329. void *back;
  330. struct pch_gbe_regs __iomem *reg;
  331. spinlock_t miim_lock;
  332. struct pch_gbe_mac_info mac;
  333. struct pch_gbe_phy_info phy;
  334. };
  335. /**
  336. * struct pch_gbe_rx_desc - Receive Descriptor
  337. * @buffer_addr: RX Frame Buffer Address
  338. * @tcp_ip_status: TCP/IP Accelerator Status
  339. * @rx_words_eob: RX word count and Byte position
  340. * @gbec_status: GMAC Status
  341. * @dma_status: DMA Status
  342. * @reserved1: Reserved
  343. * @reserved2: Reserved
  344. */
  345. struct pch_gbe_rx_desc {
  346. u32 buffer_addr;
  347. u32 tcp_ip_status;
  348. u16 rx_words_eob;
  349. u16 gbec_status;
  350. u8 dma_status;
  351. u8 reserved1;
  352. u16 reserved2;
  353. };
  354. /**
  355. * struct pch_gbe_tx_desc - Transmit Descriptor
  356. * @buffer_addr: TX Frame Buffer Address
  357. * @length: Data buffer length
  358. * @reserved1: Reserved
  359. * @tx_words_eob: TX word count and Byte position
  360. * @tx_frame_ctrl: TX Frame Control
  361. * @dma_status: DMA Status
  362. * @reserved2: Reserved
  363. * @gbec_status: GMAC Status
  364. */
  365. struct pch_gbe_tx_desc {
  366. u32 buffer_addr;
  367. u16 length;
  368. u16 reserved1;
  369. u16 tx_words_eob;
  370. u16 tx_frame_ctrl;
  371. u8 dma_status;
  372. u8 reserved2;
  373. u16 gbec_status;
  374. };
  375. /**
  376. * struct pch_gbe_buffer - Buffer information
  377. * @skb: pointer to a socket buffer
  378. * @dma: DMA address
  379. * @time_stamp: time stamp
  380. * @length: data size
  381. */
  382. struct pch_gbe_buffer {
  383. struct sk_buff *skb;
  384. dma_addr_t dma;
  385. unsigned char *rx_buffer;
  386. unsigned long time_stamp;
  387. u16 length;
  388. bool mapped;
  389. };
  390. /**
  391. * struct pch_gbe_tx_ring - tx ring information
  392. * @desc: pointer to the descriptor ring memory
  393. * @dma: physical address of the descriptor ring
  394. * @size: length of descriptor ring in bytes
  395. * @count: number of descriptors in the ring
  396. * @next_to_use: next descriptor to associate a buffer with
  397. * @next_to_clean: next descriptor to check for DD status bit
  398. * @buffer_info: array of buffer information structs
  399. */
  400. struct pch_gbe_tx_ring {
  401. struct pch_gbe_tx_desc *desc;
  402. dma_addr_t dma;
  403. unsigned int size;
  404. unsigned int count;
  405. unsigned int next_to_use;
  406. unsigned int next_to_clean;
  407. struct pch_gbe_buffer *buffer_info;
  408. };
  409. /**
  410. * struct pch_gbe_rx_ring - rx ring information
  411. * @desc: pointer to the descriptor ring memory
  412. * @dma: physical address of the descriptor ring
  413. * @size: length of descriptor ring in bytes
  414. * @count: number of descriptors in the ring
  415. * @next_to_use: next descriptor to associate a buffer with
  416. * @next_to_clean: next descriptor to check for DD status bit
  417. * @buffer_info: array of buffer information structs
  418. */
  419. struct pch_gbe_rx_ring {
  420. struct pch_gbe_rx_desc *desc;
  421. dma_addr_t dma;
  422. unsigned char *rx_buff_pool;
  423. dma_addr_t rx_buff_pool_logic;
  424. unsigned int rx_buff_pool_size;
  425. unsigned int size;
  426. unsigned int count;
  427. unsigned int next_to_use;
  428. unsigned int next_to_clean;
  429. struct pch_gbe_buffer *buffer_info;
  430. };
  431. /**
  432. * struct pch_gbe_hw_stats - Statistics counters collected by the MAC
  433. * @rx_packets: total packets received
  434. * @tx_packets: total packets transmitted
  435. * @rx_bytes: total bytes received
  436. * @tx_bytes: total bytes transmitted
  437. * @rx_errors: bad packets received
  438. * @tx_errors: packet transmit problems
  439. * @rx_dropped: no space in Linux buffers
  440. * @tx_dropped: no space available in Linux
  441. * @multicast: multicast packets received
  442. * @collisions: collisions
  443. * @rx_crc_errors: received packet with crc error
  444. * @rx_frame_errors: received frame alignment error
  445. * @rx_alloc_buff_failed: allocate failure of a receive buffer
  446. * @tx_length_errors: transmit length error
  447. * @tx_aborted_errors: transmit aborted error
  448. * @tx_carrier_errors: transmit carrier error
  449. * @tx_timeout_count: Number of transmit timeout
  450. * @tx_restart_count: Number of transmit restert
  451. * @intr_rx_dsc_empty_count: Interrupt count of receive descriptor empty
  452. * @intr_rx_frame_err_count: Interrupt count of receive frame error
  453. * @intr_rx_fifo_err_count: Interrupt count of receive FIFO error
  454. * @intr_rx_dma_err_count: Interrupt count of receive DMA error
  455. * @intr_tx_fifo_err_count: Interrupt count of transmit FIFO error
  456. * @intr_tx_dma_err_count: Interrupt count of transmit DMA error
  457. * @intr_tcpip_err_count: Interrupt count of TCP/IP Accelerator
  458. */
  459. struct pch_gbe_hw_stats {
  460. u32 rx_packets;
  461. u32 tx_packets;
  462. u32 rx_bytes;
  463. u32 tx_bytes;
  464. u32 rx_errors;
  465. u32 tx_errors;
  466. u32 rx_dropped;
  467. u32 tx_dropped;
  468. u32 multicast;
  469. u32 collisions;
  470. u32 rx_crc_errors;
  471. u32 rx_frame_errors;
  472. u32 rx_alloc_buff_failed;
  473. u32 tx_length_errors;
  474. u32 tx_aborted_errors;
  475. u32 tx_carrier_errors;
  476. u32 tx_timeout_count;
  477. u32 tx_restart_count;
  478. u32 intr_rx_dsc_empty_count;
  479. u32 intr_rx_frame_err_count;
  480. u32 intr_rx_fifo_err_count;
  481. u32 intr_rx_dma_err_count;
  482. u32 intr_tx_fifo_err_count;
  483. u32 intr_tx_dma_err_count;
  484. u32 intr_tcpip_err_count;
  485. };
  486. /**
  487. * struct pch_gbe_privdata - PCI Device ID driver data
  488. * @phy_tx_clk_delay: Bool, configure the PHY TX delay in software
  489. * @phy_disable_hibernate: Bool, disable PHY hibernation
  490. * @platform_init: Platform initialization callback, called from
  491. * probe, prior to PHY initialization.
  492. */
  493. struct pch_gbe_privdata {
  494. bool phy_tx_clk_delay;
  495. bool phy_disable_hibernate;
  496. int (*platform_init)(struct pci_dev *pdev);
  497. };
  498. /**
  499. * struct pch_gbe_adapter - board specific private data structure
  500. * @stats_lock: Spinlock structure for status
  501. * @ethtool_lock: Spinlock structure for ethtool
  502. * @irq_sem: Semaphore for interrupt
  503. * @netdev: Pointer of network device structure
  504. * @pdev: Pointer of pci device structure
  505. * @polling_netdev: Pointer of polling network device structure
  506. * @napi: NAPI structure
  507. * @hw: Pointer of hardware structure
  508. * @stats: Hardware status
  509. * @reset_task: Reset task
  510. * @mii: MII information structure
  511. * @watchdog_timer: Watchdog timer list
  512. * @wake_up_evt: Wake up event
  513. * @config_space: Configuration space
  514. * @msg_enable: Driver message level
  515. * @led_status: LED status
  516. * @tx_ring: Pointer of Tx descriptor ring structure
  517. * @rx_ring: Pointer of Rx descriptor ring structure
  518. * @rx_buffer_len: Receive buffer length
  519. * @tx_queue_len: Transmit queue length
  520. * @pch_gbe_privdata: PCI Device ID driver_data
  521. */
  522. struct pch_gbe_adapter {
  523. spinlock_t stats_lock;
  524. spinlock_t ethtool_lock;
  525. atomic_t irq_sem;
  526. struct net_device *netdev;
  527. struct pci_dev *pdev;
  528. int irq;
  529. struct net_device *polling_netdev;
  530. struct napi_struct napi;
  531. struct pch_gbe_hw hw;
  532. struct pch_gbe_hw_stats stats;
  533. struct work_struct reset_task;
  534. struct mii_if_info mii;
  535. struct timer_list watchdog_timer;
  536. u32 wake_up_evt;
  537. u32 *config_space;
  538. unsigned long led_status;
  539. struct pch_gbe_tx_ring *tx_ring;
  540. struct pch_gbe_rx_ring *rx_ring;
  541. unsigned long rx_buffer_len;
  542. unsigned long tx_queue_len;
  543. bool rx_stop_flag;
  544. int hwts_tx_en;
  545. int hwts_rx_en;
  546. struct pci_dev *ptp_pdev;
  547. struct pch_gbe_privdata *pdata;
  548. };
  549. #define pch_gbe_hw_to_adapter(hw) container_of(hw, struct pch_gbe_adapter, hw)
  550. extern const char pch_driver_version[];
  551. /* pch_gbe_main.c */
  552. int pch_gbe_up(struct pch_gbe_adapter *adapter);
  553. void pch_gbe_down(struct pch_gbe_adapter *adapter);
  554. void pch_gbe_reinit_locked(struct pch_gbe_adapter *adapter);
  555. void pch_gbe_reset(struct pch_gbe_adapter *adapter);
  556. int pch_gbe_setup_tx_resources(struct pch_gbe_adapter *adapter,
  557. struct pch_gbe_tx_ring *txdr);
  558. int pch_gbe_setup_rx_resources(struct pch_gbe_adapter *adapter,
  559. struct pch_gbe_rx_ring *rxdr);
  560. void pch_gbe_free_tx_resources(struct pch_gbe_adapter *adapter,
  561. struct pch_gbe_tx_ring *tx_ring);
  562. void pch_gbe_free_rx_resources(struct pch_gbe_adapter *adapter,
  563. struct pch_gbe_rx_ring *rx_ring);
  564. void pch_gbe_update_stats(struct pch_gbe_adapter *adapter);
  565. u32 pch_ch_control_read(struct pci_dev *pdev);
  566. void pch_ch_control_write(struct pci_dev *pdev, u32 val);
  567. u32 pch_ch_event_read(struct pci_dev *pdev);
  568. void pch_ch_event_write(struct pci_dev *pdev, u32 val);
  569. u32 pch_src_uuid_lo_read(struct pci_dev *pdev);
  570. u32 pch_src_uuid_hi_read(struct pci_dev *pdev);
  571. u64 pch_rx_snap_read(struct pci_dev *pdev);
  572. u64 pch_tx_snap_read(struct pci_dev *pdev);
  573. int pch_set_station_address(u8 *addr, struct pci_dev *pdev);
  574. /* pch_gbe_param.c */
  575. void pch_gbe_check_options(struct pch_gbe_adapter *adapter);
  576. /* pch_gbe_ethtool.c */
  577. void pch_gbe_set_ethtool_ops(struct net_device *netdev);
  578. /* pch_gbe_mac.c */
  579. s32 pch_gbe_mac_force_mac_fc(struct pch_gbe_hw *hw);
  580. u16 pch_gbe_mac_ctrl_miim(struct pch_gbe_hw *hw, u32 addr, u32 dir, u32 reg,
  581. u16 data);
  582. #endif /* _PCH_GBE_H_ */