descs.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*******************************************************************************
  2. Header File to describe the DMA descriptors and related definitions.
  3. This is for DWMAC100 and 1000 cores.
  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. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
  17. *******************************************************************************/
  18. #ifndef __DESCS_H__
  19. #define __DESCS_H__
  20. #include <linux/bitops.h>
  21. /* Normal receive descriptor defines */
  22. /* RDES0 */
  23. #define RDES0_PAYLOAD_CSUM_ERR BIT(0)
  24. #define RDES0_CRC_ERROR BIT(1)
  25. #define RDES0_DRIBBLING BIT(2)
  26. #define RDES0_MII_ERROR BIT(3)
  27. #define RDES0_RECEIVE_WATCHDOG BIT(4)
  28. #define RDES0_FRAME_TYPE BIT(5)
  29. #define RDES0_COLLISION BIT(6)
  30. #define RDES0_IPC_CSUM_ERROR BIT(7)
  31. #define RDES0_LAST_DESCRIPTOR BIT(8)
  32. #define RDES0_FIRST_DESCRIPTOR BIT(9)
  33. #define RDES0_VLAN_TAG BIT(10)
  34. #define RDES0_OVERFLOW_ERROR BIT(11)
  35. #define RDES0_LENGTH_ERROR BIT(12)
  36. #define RDES0_SA_FILTER_FAIL BIT(13)
  37. #define RDES0_DESCRIPTOR_ERROR BIT(14)
  38. #define RDES0_ERROR_SUMMARY BIT(15)
  39. #define RDES0_FRAME_LEN_MASK GENMASK(29, 16)
  40. #define RDES0_FRAME_LEN_SHIFT 16
  41. #define RDES0_DA_FILTER_FAIL BIT(30)
  42. #define RDES0_OWN BIT(31)
  43. /* RDES1 */
  44. #define RDES1_BUFFER1_SIZE_MASK GENMASK(10, 0)
  45. #define RDES1_BUFFER2_SIZE_MASK GENMASK(21, 11)
  46. #define RDES1_BUFFER2_SIZE_SHIFT 11
  47. #define RDES1_SECOND_ADDRESS_CHAINED BIT(24)
  48. #define RDES1_END_RING BIT(25)
  49. #define RDES1_DISABLE_IC BIT(31)
  50. /* Enhanced receive descriptor defines */
  51. /* RDES0 (similar to normal RDES) */
  52. #define ERDES0_RX_MAC_ADDR BIT(0)
  53. /* RDES1: completely differ from normal desc definitions */
  54. #define ERDES1_BUFFER1_SIZE_MASK GENMASK(12, 0)
  55. #define ERDES1_SECOND_ADDRESS_CHAINED BIT(14)
  56. #define ERDES1_END_RING BIT(15)
  57. #define ERDES1_BUFFER2_SIZE_MASK GENMASK(28, 16)
  58. #define ERDES1_BUFFER2_SIZE_SHIFT 16
  59. #define ERDES1_DISABLE_IC BIT(31)
  60. /* Normal transmit descriptor defines */
  61. /* TDES0 */
  62. #define TDES0_DEFERRED BIT(0)
  63. #define TDES0_UNDERFLOW_ERROR BIT(1)
  64. #define TDES0_EXCESSIVE_DEFERRAL BIT(2)
  65. #define TDES0_COLLISION_COUNT_MASK GENMASK(6, 3)
  66. #define TDES0_VLAN_FRAME BIT(7)
  67. #define TDES0_EXCESSIVE_COLLISIONS BIT(8)
  68. #define TDES0_LATE_COLLISION BIT(9)
  69. #define TDES0_NO_CARRIER BIT(10)
  70. #define TDES0_LOSS_CARRIER BIT(11)
  71. #define TDES0_PAYLOAD_ERROR BIT(12)
  72. #define TDES0_FRAME_FLUSHED BIT(13)
  73. #define TDES0_JABBER_TIMEOUT BIT(14)
  74. #define TDES0_ERROR_SUMMARY BIT(15)
  75. #define TDES0_IP_HEADER_ERROR BIT(16)
  76. #define TDES0_TIME_STAMP_STATUS BIT(17)
  77. #define TDES0_OWN BIT(31)
  78. /* TDES1 */
  79. #define TDES1_BUFFER1_SIZE_MASK GENMASK(10, 0)
  80. #define TDES1_BUFFER2_SIZE_MASK GENMASK(21, 11)
  81. #define TDES1_BUFFER2_SIZE_SHIFT 11
  82. #define TDES1_TIME_STAMP_ENABLE BIT(22)
  83. #define TDES1_DISABLE_PADDING BIT(23)
  84. #define TDES1_SECOND_ADDRESS_CHAINED BIT(24)
  85. #define TDES1_END_RING BIT(25)
  86. #define TDES1_CRC_DISABLE BIT(26)
  87. #define TDES1_CHECKSUM_INSERTION_MASK GENMASK(28, 27)
  88. #define TDES1_CHECKSUM_INSERTION_SHIFT 27
  89. #define TDES1_FIRST_SEGMENT BIT(29)
  90. #define TDES1_LAST_SEGMENT BIT(30)
  91. #define TDES1_INTERRUPT BIT(31)
  92. /* Enhanced transmit descriptor defines */
  93. /* TDES0 */
  94. #define ETDES0_DEFERRED BIT(0)
  95. #define ETDES0_UNDERFLOW_ERROR BIT(1)
  96. #define ETDES0_EXCESSIVE_DEFERRAL BIT(2)
  97. #define ETDES0_COLLISION_COUNT_MASK GENMASK(6, 3)
  98. #define ETDES0_VLAN_FRAME BIT(7)
  99. #define ETDES0_EXCESSIVE_COLLISIONS BIT(8)
  100. #define ETDES0_LATE_COLLISION BIT(9)
  101. #define ETDES0_NO_CARRIER BIT(10)
  102. #define ETDES0_LOSS_CARRIER BIT(11)
  103. #define ETDES0_PAYLOAD_ERROR BIT(12)
  104. #define ETDES0_FRAME_FLUSHED BIT(13)
  105. #define ETDES0_JABBER_TIMEOUT BIT(14)
  106. #define ETDES0_ERROR_SUMMARY BIT(15)
  107. #define ETDES0_IP_HEADER_ERROR BIT(16)
  108. #define ETDES0_TIME_STAMP_STATUS BIT(17)
  109. #define ETDES0_SECOND_ADDRESS_CHAINED BIT(20)
  110. #define ETDES0_END_RING BIT(21)
  111. #define ETDES0_CHECKSUM_INSERTION_MASK GENMASK(23, 22)
  112. #define ETDES0_CHECKSUM_INSERTION_SHIFT 22
  113. #define ETDES0_TIME_STAMP_ENABLE BIT(25)
  114. #define ETDES0_DISABLE_PADDING BIT(26)
  115. #define ETDES0_CRC_DISABLE BIT(27)
  116. #define ETDES0_FIRST_SEGMENT BIT(28)
  117. #define ETDES0_LAST_SEGMENT BIT(29)
  118. #define ETDES0_INTERRUPT BIT(30)
  119. #define ETDES0_OWN BIT(31)
  120. /* TDES1 */
  121. #define ETDES1_BUFFER1_SIZE_MASK GENMASK(12, 0)
  122. #define ETDES1_BUFFER2_SIZE_MASK GENMASK(28, 16)
  123. #define ETDES1_BUFFER2_SIZE_SHIFT 16
  124. /* Extended Receive descriptor definitions */
  125. #define ERDES4_IP_PAYLOAD_TYPE_MASK GENMASK(2, 6)
  126. #define ERDES4_IP_HDR_ERR BIT(3)
  127. #define ERDES4_IP_PAYLOAD_ERR BIT(4)
  128. #define ERDES4_IP_CSUM_BYPASSED BIT(5)
  129. #define ERDES4_IPV4_PKT_RCVD BIT(6)
  130. #define ERDES4_IPV6_PKT_RCVD BIT(7)
  131. #define ERDES4_MSG_TYPE_MASK GENMASK(11, 8)
  132. #define ERDES4_PTP_FRAME_TYPE BIT(12)
  133. #define ERDES4_PTP_VER BIT(13)
  134. #define ERDES4_TIMESTAMP_DROPPED BIT(14)
  135. #define ERDES4_AV_PKT_RCVD BIT(16)
  136. #define ERDES4_AV_TAGGED_PKT_RCVD BIT(17)
  137. #define ERDES4_VLAN_TAG_PRI_VAL_MASK GENMASK(20, 18)
  138. #define ERDES4_L3_FILTER_MATCH BIT(24)
  139. #define ERDES4_L4_FILTER_MATCH BIT(25)
  140. #define ERDES4_L3_L4_FILT_NO_MATCH_MASK GENMASK(27, 26)
  141. /* Extended RDES4 message type definitions */
  142. #define RDES_EXT_NO_PTP 0x0
  143. #define RDES_EXT_SYNC 0x1
  144. #define RDES_EXT_FOLLOW_UP 0x2
  145. #define RDES_EXT_DELAY_REQ 0x3
  146. #define RDES_EXT_DELAY_RESP 0x4
  147. #define RDES_EXT_PDELAY_REQ 0x5
  148. #define RDES_EXT_PDELAY_RESP 0x6
  149. #define RDES_EXT_PDELAY_FOLLOW_UP 0x7
  150. #define RDES_PTP_ANNOUNCE 0x8
  151. #define RDES_PTP_MANAGEMENT 0x9
  152. #define RDES_PTP_SIGNALING 0xa
  153. #define RDES_PTP_PKT_RESERVED_TYPE 0xf
  154. /* Basic descriptor structure for normal and alternate descriptors */
  155. struct dma_desc {
  156. unsigned int des0;
  157. unsigned int des1;
  158. unsigned int des2;
  159. unsigned int des3;
  160. };
  161. /* Extended descriptor structure (e.g. >= databook 3.50a) */
  162. struct dma_extended_desc {
  163. struct dma_desc basic; /* Basic descriptors */
  164. unsigned int des4; /* Extended Status */
  165. unsigned int des5; /* Reserved */
  166. unsigned int des6; /* Tx/Rx Timestamp Low */
  167. unsigned int des7; /* Tx/Rx Timestamp High */
  168. };
  169. /* Transmit checksum insertion control */
  170. #define TX_CIC_FULL 3 /* Include IP header and pseudoheader */
  171. #endif /* __DESCS_H__ */