xilinx_axienet.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. /*
  2. * Definitions for Xilinx Axi Ethernet device driver.
  3. *
  4. * Copyright (c) 2009 Secret Lab Technologies, Ltd.
  5. * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
  6. */
  7. #ifndef XILINX_AXIENET_H
  8. #define XILINX_AXIENET_H
  9. #include <linux/netdevice.h>
  10. #include <linux/spinlock.h>
  11. #include <linux/interrupt.h>
  12. /* Packet size info */
  13. #define XAE_HDR_SIZE 14 /* Size of Ethernet header */
  14. #define XAE_HDR_VLAN_SIZE 18 /* Size of an Ethernet hdr + VLAN */
  15. #define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */
  16. #define XAE_MTU 1500 /* Max MTU of an Ethernet frame */
  17. #define XAE_JUMBO_MTU 9000 /* Max MTU of a jumbo Eth. frame */
  18. #define XAE_MAX_FRAME_SIZE (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
  19. #define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + XAE_HDR_VLAN_SIZE + XAE_TRL_SIZE)
  20. #define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
  21. /* Configuration options */
  22. /* Accept all incoming packets. Default: disabled (cleared) */
  23. #define XAE_OPTION_PROMISC (1 << 0)
  24. /* Jumbo frame support for Tx & Rx. Default: disabled (cleared) */
  25. #define XAE_OPTION_JUMBO (1 << 1)
  26. /* VLAN Rx & Tx frame support. Default: disabled (cleared) */
  27. #define XAE_OPTION_VLAN (1 << 2)
  28. /* Enable recognition of flow control frames on Rx. Default: enabled (set) */
  29. #define XAE_OPTION_FLOW_CONTROL (1 << 4)
  30. /* Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not
  31. * stripped. Default: disabled (set) */
  32. #define XAE_OPTION_FCS_STRIP (1 << 5)
  33. /* Generate FCS field and add PAD automatically for outgoing frames.
  34. * Default: enabled (set) */
  35. #define XAE_OPTION_FCS_INSERT (1 << 6)
  36. /* Enable Length/Type error checking for incoming frames. When this option is
  37. * set, the MAC will filter frames that have a mismatched type/length field
  38. * and if XAE_OPTION_REPORT_RXERR is set, the user is notified when these
  39. * types of frames are encountered. When this option is cleared, the MAC will
  40. * allow these types of frames to be received. Default: enabled (set) */
  41. #define XAE_OPTION_LENTYPE_ERR (1 << 7)
  42. /* Enable the transmitter. Default: enabled (set) */
  43. #define XAE_OPTION_TXEN (1 << 11)
  44. /* Enable the receiver. Default: enabled (set) */
  45. #define XAE_OPTION_RXEN (1 << 12)
  46. /* Default options set when device is initialized or reset */
  47. #define XAE_OPTION_DEFAULTS \
  48. (XAE_OPTION_TXEN | \
  49. XAE_OPTION_FLOW_CONTROL | \
  50. XAE_OPTION_RXEN)
  51. /* Axi DMA Register definitions */
  52. #define XAXIDMA_TX_CR_OFFSET 0x00000000 /* Channel control */
  53. #define XAXIDMA_TX_SR_OFFSET 0x00000004 /* Status */
  54. #define XAXIDMA_TX_CDESC_OFFSET 0x00000008 /* Current descriptor pointer */
  55. #define XAXIDMA_TX_TDESC_OFFSET 0x00000010 /* Tail descriptor pointer */
  56. #define XAXIDMA_RX_CR_OFFSET 0x00000030 /* Channel control */
  57. #define XAXIDMA_RX_SR_OFFSET 0x00000034 /* Status */
  58. #define XAXIDMA_RX_CDESC_OFFSET 0x00000038 /* Current descriptor pointer */
  59. #define XAXIDMA_RX_TDESC_OFFSET 0x00000040 /* Tail descriptor pointer */
  60. #define XAXIDMA_CR_RUNSTOP_MASK 0x00000001 /* Start/stop DMA channel */
  61. #define XAXIDMA_CR_RESET_MASK 0x00000004 /* Reset DMA engine */
  62. #define XAXIDMA_BD_NDESC_OFFSET 0x00 /* Next descriptor pointer */
  63. #define XAXIDMA_BD_BUFA_OFFSET 0x08 /* Buffer address */
  64. #define XAXIDMA_BD_CTRL_LEN_OFFSET 0x18 /* Control/buffer length */
  65. #define XAXIDMA_BD_STS_OFFSET 0x1C /* Status */
  66. #define XAXIDMA_BD_USR0_OFFSET 0x20 /* User IP specific word0 */
  67. #define XAXIDMA_BD_USR1_OFFSET 0x24 /* User IP specific word1 */
  68. #define XAXIDMA_BD_USR2_OFFSET 0x28 /* User IP specific word2 */
  69. #define XAXIDMA_BD_USR3_OFFSET 0x2C /* User IP specific word3 */
  70. #define XAXIDMA_BD_USR4_OFFSET 0x30 /* User IP specific word4 */
  71. #define XAXIDMA_BD_ID_OFFSET 0x34 /* Sw ID */
  72. #define XAXIDMA_BD_HAS_STSCNTRL_OFFSET 0x38 /* Whether has stscntrl strm */
  73. #define XAXIDMA_BD_HAS_DRE_OFFSET 0x3C /* Whether has DRE */
  74. #define XAXIDMA_BD_HAS_DRE_SHIFT 8 /* Whether has DRE shift */
  75. #define XAXIDMA_BD_HAS_DRE_MASK 0xF00 /* Whether has DRE mask */
  76. #define XAXIDMA_BD_WORDLEN_MASK 0xFF /* Whether has DRE mask */
  77. #define XAXIDMA_BD_CTRL_LENGTH_MASK 0x007FFFFF /* Requested len */
  78. #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */
  79. #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */
  80. #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */
  81. #define XAXIDMA_DELAY_MASK 0xFF000000 /* Delay timeout counter */
  82. #define XAXIDMA_COALESCE_MASK 0x00FF0000 /* Coalesce counter */
  83. #define XAXIDMA_DELAY_SHIFT 24
  84. #define XAXIDMA_COALESCE_SHIFT 16
  85. #define XAXIDMA_IRQ_IOC_MASK 0x00001000 /* Completion intr */
  86. #define XAXIDMA_IRQ_DELAY_MASK 0x00002000 /* Delay interrupt */
  87. #define XAXIDMA_IRQ_ERROR_MASK 0x00004000 /* Error interrupt */
  88. #define XAXIDMA_IRQ_ALL_MASK 0x00007000 /* All interrupts */
  89. /* Default TX/RX Threshold and waitbound values for SGDMA mode */
  90. #define XAXIDMA_DFT_TX_THRESHOLD 24
  91. #define XAXIDMA_DFT_TX_WAITBOUND 254
  92. #define XAXIDMA_DFT_RX_THRESHOLD 24
  93. #define XAXIDMA_DFT_RX_WAITBOUND 254
  94. #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */
  95. #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */
  96. #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */
  97. #define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF /* Actual len */
  98. #define XAXIDMA_BD_STS_COMPLETE_MASK 0x80000000 /* Completed */
  99. #define XAXIDMA_BD_STS_DEC_ERR_MASK 0x40000000 /* Decode error */
  100. #define XAXIDMA_BD_STS_SLV_ERR_MASK 0x20000000 /* Slave error */
  101. #define XAXIDMA_BD_STS_INT_ERR_MASK 0x10000000 /* Internal err */
  102. #define XAXIDMA_BD_STS_ALL_ERR_MASK 0x70000000 /* All errors */
  103. #define XAXIDMA_BD_STS_RXSOF_MASK 0x08000000 /* First rx pkt */
  104. #define XAXIDMA_BD_STS_RXEOF_MASK 0x04000000 /* Last rx pkt */
  105. #define XAXIDMA_BD_STS_ALL_MASK 0xFC000000 /* All status bits */
  106. #define XAXIDMA_BD_MINIMUM_ALIGNMENT 0x40
  107. /* Axi Ethernet registers definition */
  108. #define XAE_RAF_OFFSET 0x00000000 /* Reset and Address filter */
  109. #define XAE_TPF_OFFSET 0x00000004 /* Tx Pause Frame */
  110. #define XAE_IFGP_OFFSET 0x00000008 /* Tx Inter-frame gap adjustment*/
  111. #define XAE_IS_OFFSET 0x0000000C /* Interrupt status */
  112. #define XAE_IP_OFFSET 0x00000010 /* Interrupt pending */
  113. #define XAE_IE_OFFSET 0x00000014 /* Interrupt enable */
  114. #define XAE_TTAG_OFFSET 0x00000018 /* Tx VLAN TAG */
  115. #define XAE_RTAG_OFFSET 0x0000001C /* Rx VLAN TAG */
  116. #define XAE_UAWL_OFFSET 0x00000020 /* Unicast address word lower */
  117. #define XAE_UAWU_OFFSET 0x00000024 /* Unicast address word upper */
  118. #define XAE_TPID0_OFFSET 0x00000028 /* VLAN TPID0 register */
  119. #define XAE_TPID1_OFFSET 0x0000002C /* VLAN TPID1 register */
  120. #define XAE_PPST_OFFSET 0x00000030 /* PCS PMA Soft Temac Status Reg */
  121. #define XAE_RCW0_OFFSET 0x00000400 /* Rx Configuration Word 0 */
  122. #define XAE_RCW1_OFFSET 0x00000404 /* Rx Configuration Word 1 */
  123. #define XAE_TC_OFFSET 0x00000408 /* Tx Configuration */
  124. #define XAE_FCC_OFFSET 0x0000040C /* Flow Control Configuration */
  125. #define XAE_EMMC_OFFSET 0x00000410 /* EMAC mode configuration */
  126. #define XAE_PHYC_OFFSET 0x00000414 /* RGMII/SGMII configuration */
  127. #define XAE_MDIO_MC_OFFSET 0x00000500 /* MII Management Config */
  128. #define XAE_MDIO_MCR_OFFSET 0x00000504 /* MII Management Control */
  129. #define XAE_MDIO_MWD_OFFSET 0x00000508 /* MII Management Write Data */
  130. #define XAE_MDIO_MRD_OFFSET 0x0000050C /* MII Management Read Data */
  131. #define XAE_MDIO_MIS_OFFSET 0x00000600 /* MII Management Interrupt Status */
  132. #define XAE_MDIO_MIP_OFFSET 0x00000620 /* MII Mgmt Interrupt Pending
  133. * register offset */
  134. #define XAE_MDIO_MIE_OFFSET 0x00000640 /* MII Management Interrupt Enable
  135. * register offset */
  136. #define XAE_MDIO_MIC_OFFSET 0x00000660 /* MII Management Interrupt Clear
  137. * register offset. */
  138. #define XAE_UAW0_OFFSET 0x00000700 /* Unicast address word 0 */
  139. #define XAE_UAW1_OFFSET 0x00000704 /* Unicast address word 1 */
  140. #define XAE_FMI_OFFSET 0x00000708 /* Filter Mask Index */
  141. #define XAE_AF0_OFFSET 0x00000710 /* Address Filter 0 */
  142. #define XAE_AF1_OFFSET 0x00000714 /* Address Filter 1 */
  143. #define XAE_TX_VLAN_DATA_OFFSET 0x00004000 /* TX VLAN data table address */
  144. #define XAE_RX_VLAN_DATA_OFFSET 0x00008000 /* RX VLAN data table address */
  145. #define XAE_MCAST_TABLE_OFFSET 0x00020000 /* Multicast table address */
  146. /* Bit Masks for Axi Ethernet RAF register */
  147. #define XAE_RAF_MCSTREJ_MASK 0x00000002 /* Reject receive multicast
  148. * destination address */
  149. #define XAE_RAF_BCSTREJ_MASK 0x00000004 /* Reject receive broadcast
  150. * destination address */
  151. #define XAE_RAF_TXVTAGMODE_MASK 0x00000018 /* Tx VLAN TAG mode */
  152. #define XAE_RAF_RXVTAGMODE_MASK 0x00000060 /* Rx VLAN TAG mode */
  153. #define XAE_RAF_TXVSTRPMODE_MASK 0x00000180 /* Tx VLAN STRIP mode */
  154. #define XAE_RAF_RXVSTRPMODE_MASK 0x00000600 /* Rx VLAN STRIP mode */
  155. #define XAE_RAF_NEWFNCENBL_MASK 0x00000800 /* New function mode */
  156. #define XAE_RAF_EMULTIFLTRENBL_MASK 0x00001000 /* Exteneded Multicast
  157. * Filtering mode
  158. */
  159. #define XAE_RAF_STATSRST_MASK 0x00002000 /* Stats. Counter Reset */
  160. #define XAE_RAF_RXBADFRMEN_MASK 0x00004000 /* Recv Bad Frame Enable */
  161. #define XAE_RAF_TXVTAGMODE_SHIFT 3 /* Tx Tag mode shift bits */
  162. #define XAE_RAF_RXVTAGMODE_SHIFT 5 /* Rx Tag mode shift bits */
  163. #define XAE_RAF_TXVSTRPMODE_SHIFT 7 /* Tx strip mode shift bits*/
  164. #define XAE_RAF_RXVSTRPMODE_SHIFT 9 /* Rx Strip mode shift bits*/
  165. /* Bit Masks for Axi Ethernet TPF and IFGP registers */
  166. #define XAE_TPF_TPFV_MASK 0x0000FFFF /* Tx pause frame value */
  167. #define XAE_IFGP0_IFGP_MASK 0x0000007F /* Transmit inter-frame
  168. * gap adjustment value */
  169. /* Bit Masks for Axi Ethernet IS, IE and IP registers, Same masks apply
  170. * for all 3 registers. */
  171. #define XAE_INT_HARDACSCMPLT_MASK 0x00000001 /* Hard register access
  172. * complete */
  173. #define XAE_INT_AUTONEG_MASK 0x00000002 /* Auto negotiation
  174. * complete */
  175. #define XAE_INT_RXCMPIT_MASK 0x00000004 /* Rx complete */
  176. #define XAE_INT_RXRJECT_MASK 0x00000008 /* Rx frame rejected */
  177. #define XAE_INT_RXFIFOOVR_MASK 0x00000010 /* Rx fifo overrun */
  178. #define XAE_INT_TXCMPIT_MASK 0x00000020 /* Tx complete */
  179. #define XAE_INT_RXDCMLOCK_MASK 0x00000040 /* Rx Dcm Lock */
  180. #define XAE_INT_MGTRDY_MASK 0x00000080 /* MGT clock Lock */
  181. #define XAE_INT_PHYRSTCMPLT_MASK 0x00000100 /* Phy Reset complete */
  182. #define XAE_INT_ALL_MASK 0x0000003F /* All the ints */
  183. #define XAE_INT_RECV_ERROR_MASK \
  184. (XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK) /* INT bits that
  185. * indicate receive
  186. * errors */
  187. /* Bit masks for Axi Ethernet VLAN TPID Word 0 register */
  188. #define XAE_TPID_0_MASK 0x0000FFFF /* TPID 0 */
  189. #define XAE_TPID_1_MASK 0xFFFF0000 /* TPID 1 */
  190. /* Bit masks for Axi Ethernet VLAN TPID Word 1 register */
  191. #define XAE_TPID_2_MASK 0x0000FFFF /* TPID 0 */
  192. #define XAE_TPID_3_MASK 0xFFFF0000 /* TPID 1 */
  193. /* Bit masks for Axi Ethernet RCW1 register */
  194. #define XAE_RCW1_RST_MASK 0x80000000 /* Reset */
  195. #define XAE_RCW1_JUM_MASK 0x40000000 /* Jumbo frame enable */
  196. #define XAE_RCW1_FCS_MASK 0x20000000 /* In-Band FCS enable
  197. * (FCS not stripped) */
  198. #define XAE_RCW1_RX_MASK 0x10000000 /* Receiver enable */
  199. #define XAE_RCW1_VLAN_MASK 0x08000000 /* VLAN frame enable */
  200. #define XAE_RCW1_LT_DIS_MASK 0x02000000 /* Length/type field valid check
  201. * disable */
  202. #define XAE_RCW1_CL_DIS_MASK 0x01000000 /* Control frame Length check
  203. * disable */
  204. #define XAE_RCW1_PAUSEADDR_MASK 0x0000FFFF /* Pause frame source address
  205. * bits [47:32]. Bits [31:0] are
  206. * stored in register RCW0 */
  207. /* Bit masks for Axi Ethernet TC register */
  208. #define XAE_TC_RST_MASK 0x80000000 /* Reset */
  209. #define XAE_TC_JUM_MASK 0x40000000 /* Jumbo frame enable */
  210. #define XAE_TC_FCS_MASK 0x20000000 /* In-Band FCS enable
  211. * (FCS not generated) */
  212. #define XAE_TC_TX_MASK 0x10000000 /* Transmitter enable */
  213. #define XAE_TC_VLAN_MASK 0x08000000 /* VLAN frame enable */
  214. #define XAE_TC_IFG_MASK 0x02000000 /* Inter-frame gap adjustment
  215. * enable */
  216. /* Bit masks for Axi Ethernet FCC register */
  217. #define XAE_FCC_FCRX_MASK 0x20000000 /* Rx flow control enable */
  218. #define XAE_FCC_FCTX_MASK 0x40000000 /* Tx flow control enable */
  219. /* Bit masks for Axi Ethernet EMMC register */
  220. #define XAE_EMMC_LINKSPEED_MASK 0xC0000000 /* Link speed */
  221. #define XAE_EMMC_RGMII_MASK 0x20000000 /* RGMII mode enable */
  222. #define XAE_EMMC_SGMII_MASK 0x10000000 /* SGMII mode enable */
  223. #define XAE_EMMC_GPCS_MASK 0x08000000 /* 1000BaseX mode enable */
  224. #define XAE_EMMC_HOST_MASK 0x04000000 /* Host interface enable */
  225. #define XAE_EMMC_TX16BIT 0x02000000 /* 16 bit Tx client enable */
  226. #define XAE_EMMC_RX16BIT 0x01000000 /* 16 bit Rx client enable */
  227. #define XAE_EMMC_LINKSPD_10 0x00000000 /* Link Speed mask for 10 Mbit */
  228. #define XAE_EMMC_LINKSPD_100 0x40000000 /* Link Speed mask for 100 Mbit */
  229. #define XAE_EMMC_LINKSPD_1000 0x80000000 /* Link Speed mask for 1000 Mbit */
  230. /* Bit masks for Axi Ethernet PHYC register */
  231. #define XAE_PHYC_SGMIILINKSPEED_MASK 0xC0000000 /* SGMII link speed mask*/
  232. #define XAE_PHYC_RGMIILINKSPEED_MASK 0x0000000C /* RGMII link speed */
  233. #define XAE_PHYC_RGMIIHD_MASK 0x00000002 /* RGMII Half-duplex */
  234. #define XAE_PHYC_RGMIILINK_MASK 0x00000001 /* RGMII link status */
  235. #define XAE_PHYC_RGLINKSPD_10 0x00000000 /* RGMII link 10 Mbit */
  236. #define XAE_PHYC_RGLINKSPD_100 0x00000004 /* RGMII link 100 Mbit */
  237. #define XAE_PHYC_RGLINKSPD_1000 0x00000008 /* RGMII link 1000 Mbit */
  238. #define XAE_PHYC_SGLINKSPD_10 0x00000000 /* SGMII link 10 Mbit */
  239. #define XAE_PHYC_SGLINKSPD_100 0x40000000 /* SGMII link 100 Mbit */
  240. #define XAE_PHYC_SGLINKSPD_1000 0x80000000 /* SGMII link 1000 Mbit */
  241. /* Bit masks for Axi Ethernet MDIO interface MC register */
  242. #define XAE_MDIO_MC_MDIOEN_MASK 0x00000040 /* MII management enable */
  243. #define XAE_MDIO_MC_CLOCK_DIVIDE_MAX 0x3F /* Maximum MDIO divisor */
  244. /* Bit masks for Axi Ethernet MDIO interface MCR register */
  245. #define XAE_MDIO_MCR_PHYAD_MASK 0x1F000000 /* Phy Address Mask */
  246. #define XAE_MDIO_MCR_PHYAD_SHIFT 24 /* Phy Address Shift */
  247. #define XAE_MDIO_MCR_REGAD_MASK 0x001F0000 /* Reg Address Mask */
  248. #define XAE_MDIO_MCR_REGAD_SHIFT 16 /* Reg Address Shift */
  249. #define XAE_MDIO_MCR_OP_MASK 0x0000C000 /* Operation Code Mask */
  250. #define XAE_MDIO_MCR_OP_SHIFT 13 /* Operation Code Shift */
  251. #define XAE_MDIO_MCR_OP_READ_MASK 0x00008000 /* Op Code Read Mask */
  252. #define XAE_MDIO_MCR_OP_WRITE_MASK 0x00004000 /* Op Code Write Mask */
  253. #define XAE_MDIO_MCR_INITIATE_MASK 0x00000800 /* Ready Mask */
  254. #define XAE_MDIO_MCR_READY_MASK 0x00000080 /* Ready Mask */
  255. /* Bit masks for Axi Ethernet MDIO interface MIS, MIP, MIE, MIC registers */
  256. #define XAE_MDIO_INT_MIIM_RDY_MASK 0x00000001 /* MIIM Interrupt */
  257. /* Bit masks for Axi Ethernet UAW1 register */
  258. #define XAE_UAW1_UNICASTADDR_MASK 0x0000FFFF /* Station address bits
  259. * [47:32]; Station address
  260. * bits [31:0] are stored in
  261. * register UAW0 */
  262. /* Bit masks for Axi Ethernet FMI register */
  263. #define XAE_FMI_PM_MASK 0x80000000 /* Promis. mode enable */
  264. #define XAE_FMI_IND_MASK 0x00000003 /* Index Mask */
  265. #define XAE_MDIO_DIV_DFT 29 /* Default MDIO clock divisor */
  266. /* Defines for different options for C_PHY_TYPE parameter in Axi Ethernet IP */
  267. #define XAE_PHY_TYPE_MII 0
  268. #define XAE_PHY_TYPE_GMII 1
  269. #define XAE_PHY_TYPE_RGMII_1_3 2
  270. #define XAE_PHY_TYPE_RGMII_2_0 3
  271. #define XAE_PHY_TYPE_SGMII 4
  272. #define XAE_PHY_TYPE_1000BASE_X 5
  273. #define XAE_MULTICAST_CAM_TABLE_NUM 4 /* Total number of entries in the
  274. * hardware multicast table. */
  275. /* Axi Ethernet Synthesis features */
  276. #define XAE_FEATURE_PARTIAL_RX_CSUM (1 << 0)
  277. #define XAE_FEATURE_PARTIAL_TX_CSUM (1 << 1)
  278. #define XAE_FEATURE_FULL_RX_CSUM (1 << 2)
  279. #define XAE_FEATURE_FULL_TX_CSUM (1 << 3)
  280. #define XAE_NO_CSUM_OFFLOAD 0
  281. #define XAE_FULL_CSUM_STATUS_MASK 0x00000038
  282. #define XAE_IP_UDP_CSUM_VALIDATED 0x00000003
  283. #define XAE_IP_TCP_CSUM_VALIDATED 0x00000002
  284. #define DELAY_OF_ONE_MILLISEC 1000
  285. /**
  286. * struct axidma_bd - Axi Dma buffer descriptor layout
  287. * @next: MM2S/S2MM Next Descriptor Pointer
  288. * @reserved1: Reserved and not used
  289. * @phys: MM2S/S2MM Buffer Address
  290. * @reserved2: Reserved and not used
  291. * @reserved3: Reserved and not used
  292. * @reserved4: Reserved and not used
  293. * @cntrl: MM2S/S2MM Control value
  294. * @status: MM2S/S2MM Status value
  295. * @app0: MM2S/S2MM User Application Field 0.
  296. * @app1: MM2S/S2MM User Application Field 1.
  297. * @app2: MM2S/S2MM User Application Field 2.
  298. * @app3: MM2S/S2MM User Application Field 3.
  299. * @app4: MM2S/S2MM User Application Field 4.
  300. * @sw_id_offset: MM2S/S2MM Sw ID
  301. * @reserved5: Reserved and not used
  302. * @reserved6: Reserved and not used
  303. */
  304. struct axidma_bd {
  305. u32 next; /* Physical address of next buffer descriptor */
  306. u32 reserved1;
  307. u32 phys;
  308. u32 reserved2;
  309. u32 reserved3;
  310. u32 reserved4;
  311. u32 cntrl;
  312. u32 status;
  313. u32 app0;
  314. u32 app1; /* TX start << 16 | insert */
  315. u32 app2; /* TX csum seed */
  316. u32 app3;
  317. u32 app4;
  318. u32 sw_id_offset;
  319. u32 reserved5;
  320. u32 reserved6;
  321. };
  322. /**
  323. * struct axienet_local - axienet private per device data
  324. * @ndev: Pointer for net_device to which it will be attached.
  325. * @dev: Pointer to device structure
  326. * @phy_dev: Pointer to PHY device structure attached to the axienet_local
  327. * @phy_node: Pointer to device node structure
  328. * @mii_bus: Pointer to MII bus structure
  329. * @mdio_irqs: IRQs table for MDIO bus required in mii_bus structure
  330. * @regs: Base address for the axienet_local device address space
  331. * @dma_regs: Base address for the axidma device address space
  332. * @dma_err_tasklet: Tasklet structure to process Axi DMA errors
  333. * @tx_irq: Axidma TX IRQ number
  334. * @rx_irq: Axidma RX IRQ number
  335. * @temac_type: axienet type to identify between soft and hard temac
  336. * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X
  337. * @options: AxiEthernet option word
  338. * @last_link: Phy link state in which the PHY was negotiated earlier
  339. * @features: Stores the extended features supported by the axienet hw
  340. * @tx_bd_v: Virtual address of the TX buffer descriptor ring
  341. * @tx_bd_p: Physical address(start address) of the TX buffer descr. ring
  342. * @rx_bd_v: Virtual address of the RX buffer descriptor ring
  343. * @rx_bd_p: Physical address(start address) of the RX buffer descr. ring
  344. * @tx_bd_ci: Stores the index of the Tx buffer descriptor in the ring being
  345. * accessed currently. Used while alloc. BDs before a TX starts
  346. * @tx_bd_tail: Stores the index of the Tx buffer descriptor in the ring being
  347. * accessed currently. Used while processing BDs after the TX
  348. * completed.
  349. * @rx_bd_ci: Stores the index of the Rx buffer descriptor in the ring being
  350. * accessed currently.
  351. * @max_frm_size: Stores the maximum size of the frame that can be that
  352. * Txed/Rxed in the existing hardware. If jumbo option is
  353. * supported, the maximum frame size would be 9k. Else it is
  354. * 1522 bytes (assuming support for basic VLAN)
  355. * @jumbo_support: Stores hardware configuration for jumbo support. If hardware
  356. * can handle jumbo packets, this entry will be 1, else 0.
  357. */
  358. struct axienet_local {
  359. struct net_device *ndev;
  360. struct device *dev;
  361. /* Connection to PHY device */
  362. struct phy_device *phy_dev; /* Pointer to PHY device */
  363. struct device_node *phy_node;
  364. /* MDIO bus data */
  365. struct mii_bus *mii_bus; /* MII bus reference */
  366. int mdio_irqs[PHY_MAX_ADDR]; /* IRQs table for MDIO bus */
  367. /* IO registers, dma functions and IRQs */
  368. void __iomem *regs;
  369. void __iomem *dma_regs;
  370. struct tasklet_struct dma_err_tasklet;
  371. int tx_irq;
  372. int rx_irq;
  373. u32 temac_type;
  374. u32 phy_type;
  375. u32 options; /* Current options word */
  376. u32 last_link;
  377. u32 features;
  378. /* Buffer descriptors */
  379. struct axidma_bd *tx_bd_v;
  380. dma_addr_t tx_bd_p;
  381. struct axidma_bd *rx_bd_v;
  382. dma_addr_t rx_bd_p;
  383. u32 tx_bd_ci;
  384. u32 tx_bd_tail;
  385. u32 rx_bd_ci;
  386. u32 max_frm_size;
  387. u32 jumbo_support;
  388. int csum_offload_on_tx_path;
  389. int csum_offload_on_rx_path;
  390. u32 coalesce_count_rx;
  391. u32 coalesce_count_tx;
  392. };
  393. /**
  394. * struct axiethernet_option - Used to set axi ethernet hardware options
  395. * @opt: Option to be set.
  396. * @reg: Register offset to be written for setting the option
  397. * @m_or: Mask to be ORed for setting the option in the register
  398. */
  399. struct axienet_option {
  400. u32 opt;
  401. u32 reg;
  402. u32 m_or;
  403. };
  404. /**
  405. * axienet_ior - Memory mapped Axi Ethernet register read
  406. * @lp: Pointer to axienet local structure
  407. * @offset: Address offset from the base address of Axi Ethernet core
  408. *
  409. * returns: The contents of the Axi Ethernet register
  410. *
  411. * This function returns the contents of the corresponding register.
  412. */
  413. static inline u32 axienet_ior(struct axienet_local *lp, off_t offset)
  414. {
  415. return in_be32(lp->regs + offset);
  416. }
  417. /**
  418. * axienet_iow - Memory mapped Axi Ethernet register write
  419. * @lp: Pointer to axienet local structure
  420. * @offset: Address offset from the base address of Axi Ethernet core
  421. * @value: Value to be written into the Axi Ethernet register
  422. *
  423. * This function writes the desired value into the corresponding Axi Ethernet
  424. * register.
  425. */
  426. static inline void axienet_iow(struct axienet_local *lp, off_t offset,
  427. u32 value)
  428. {
  429. out_be32((lp->regs + offset), value);
  430. }
  431. /* Function prototypes visible in xilinx_axienet_mdio.c for other files */
  432. int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np);
  433. int axienet_mdio_wait_until_ready(struct axienet_local *lp);
  434. void axienet_mdio_teardown(struct axienet_local *lp);
  435. #endif /* XILINX_AXI_ENET_H */