dpmac.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
  2. /* Copyright 2013-2016 Freescale Semiconductor Inc.
  3. * Copyright 2019 NXP
  4. */
  5. #ifndef __FSL_DPMAC_H
  6. #define __FSL_DPMAC_H
  7. /* Data Path MAC API
  8. * Contains initialization APIs and runtime control APIs for DPMAC
  9. */
  10. struct fsl_mc_io;
  11. int dpmac_open(struct fsl_mc_io *mc_io,
  12. u32 cmd_flags,
  13. int dpmac_id,
  14. u16 *token);
  15. int dpmac_close(struct fsl_mc_io *mc_io,
  16. u32 cmd_flags,
  17. u16 token);
  18. /**
  19. * enum dpmac_link_type - DPMAC link type
  20. * @DPMAC_LINK_TYPE_NONE: No link
  21. * @DPMAC_LINK_TYPE_FIXED: Link is fixed type
  22. * @DPMAC_LINK_TYPE_PHY: Link by PHY ID
  23. * @DPMAC_LINK_TYPE_BACKPLANE: Backplane link type
  24. */
  25. enum dpmac_link_type {
  26. DPMAC_LINK_TYPE_NONE,
  27. DPMAC_LINK_TYPE_FIXED,
  28. DPMAC_LINK_TYPE_PHY,
  29. DPMAC_LINK_TYPE_BACKPLANE
  30. };
  31. /**
  32. * enum dpmac_eth_if - DPMAC Ethrnet interface
  33. * @DPMAC_ETH_IF_MII: MII interface
  34. * @DPMAC_ETH_IF_RMII: RMII interface
  35. * @DPMAC_ETH_IF_SMII: SMII interface
  36. * @DPMAC_ETH_IF_GMII: GMII interface
  37. * @DPMAC_ETH_IF_RGMII: RGMII interface
  38. * @DPMAC_ETH_IF_SGMII: SGMII interface
  39. * @DPMAC_ETH_IF_QSGMII: QSGMII interface
  40. * @DPMAC_ETH_IF_XAUI: XAUI interface
  41. * @DPMAC_ETH_IF_XFI: XFI interface
  42. * @DPMAC_ETH_IF_CAUI: CAUI interface
  43. * @DPMAC_ETH_IF_1000BASEX: 1000BASEX interface
  44. * @DPMAC_ETH_IF_USXGMII: USXGMII interface
  45. */
  46. enum dpmac_eth_if {
  47. DPMAC_ETH_IF_MII,
  48. DPMAC_ETH_IF_RMII,
  49. DPMAC_ETH_IF_SMII,
  50. DPMAC_ETH_IF_GMII,
  51. DPMAC_ETH_IF_RGMII,
  52. DPMAC_ETH_IF_SGMII,
  53. DPMAC_ETH_IF_QSGMII,
  54. DPMAC_ETH_IF_XAUI,
  55. DPMAC_ETH_IF_XFI,
  56. DPMAC_ETH_IF_CAUI,
  57. DPMAC_ETH_IF_1000BASEX,
  58. DPMAC_ETH_IF_USXGMII,
  59. };
  60. /**
  61. * struct dpmac_attr - Structure representing DPMAC attributes
  62. * @id: DPMAC object ID
  63. * @max_rate: Maximum supported rate - in Mbps
  64. * @eth_if: Ethernet interface
  65. * @link_type: link type
  66. */
  67. struct dpmac_attr {
  68. u16 id;
  69. u32 max_rate;
  70. enum dpmac_eth_if eth_if;
  71. enum dpmac_link_type link_type;
  72. };
  73. int dpmac_get_attributes(struct fsl_mc_io *mc_io,
  74. u32 cmd_flags,
  75. u16 token,
  76. struct dpmac_attr *attr);
  77. /* DPMAC link configuration/state options */
  78. #define DPMAC_LINK_OPT_AUTONEG BIT_ULL(0)
  79. #define DPMAC_LINK_OPT_HALF_DUPLEX BIT_ULL(1)
  80. #define DPMAC_LINK_OPT_PAUSE BIT_ULL(2)
  81. #define DPMAC_LINK_OPT_ASYM_PAUSE BIT_ULL(3)
  82. /* Advertised link speeds */
  83. #define DPMAC_ADVERTISED_10BASET_FULL BIT_ULL(0)
  84. #define DPMAC_ADVERTISED_100BASET_FULL BIT_ULL(1)
  85. #define DPMAC_ADVERTISED_1000BASET_FULL BIT_ULL(2)
  86. #define DPMAC_ADVERTISED_10000BASET_FULL BIT_ULL(4)
  87. #define DPMAC_ADVERTISED_2500BASEX_FULL BIT_ULL(5)
  88. /* Advertise auto-negotiation enable */
  89. #define DPMAC_ADVERTISED_AUTONEG BIT_ULL(3)
  90. /**
  91. * struct dpmac_link_state - DPMAC link configuration request
  92. * @rate: Rate in Mbps
  93. * @options: Enable/Disable DPMAC link cfg features (bitmap)
  94. * @up: Link state
  95. * @state_valid: Ignore/Update the state of the link
  96. * @supported: Speeds capability of the phy (bitmap)
  97. * @advertising: Speeds that are advertised for autoneg (bitmap)
  98. */
  99. struct dpmac_link_state {
  100. u32 rate;
  101. u64 options;
  102. int up;
  103. int state_valid;
  104. u64 supported;
  105. u64 advertising;
  106. };
  107. int dpmac_set_link_state(struct fsl_mc_io *mc_io,
  108. u32 cmd_flags,
  109. u16 token,
  110. struct dpmac_link_state *link_state);
  111. /**
  112. * enum dpmac_counter_id - DPMAC counter types
  113. *
  114. * @DPMAC_CNT_ING_FRAME_64: counts 64-bytes frames, good or bad.
  115. * @DPMAC_CNT_ING_FRAME_127: counts 65- to 127-bytes frames, good or bad.
  116. * @DPMAC_CNT_ING_FRAME_255: counts 128- to 255-bytes frames, good or bad.
  117. * @DPMAC_CNT_ING_FRAME_511: counts 256- to 511-bytes frames, good or bad.
  118. * @DPMAC_CNT_ING_FRAME_1023: counts 512- to 1023-bytes frames, good or bad.
  119. * @DPMAC_CNT_ING_FRAME_1518: counts 1024- to 1518-bytes frames, good or bad.
  120. * @DPMAC_CNT_ING_FRAME_1519_MAX: counts 1519-bytes frames and larger
  121. * (up to max frame length specified),
  122. * good or bad.
  123. * @DPMAC_CNT_ING_FRAG: counts frames which are shorter than 64 bytes received
  124. * with a wrong CRC
  125. * @DPMAC_CNT_ING_JABBER: counts frames longer than the maximum frame length
  126. * specified, with a bad frame check sequence.
  127. * @DPMAC_CNT_ING_FRAME_DISCARD: counts dropped frames due to internal errors.
  128. * Occurs when a receive FIFO overflows.
  129. * Includes also frames truncated as a result of
  130. * the receive FIFO overflow.
  131. * @DPMAC_CNT_ING_ALIGN_ERR: counts frames with an alignment error
  132. * (optional used for wrong SFD).
  133. * @DPMAC_CNT_EGR_UNDERSIZED: counts frames transmitted that was less than 64
  134. * bytes long with a good CRC.
  135. * @DPMAC_CNT_ING_OVERSIZED: counts frames longer than the maximum frame length
  136. * specified, with a good frame check sequence.
  137. * @DPMAC_CNT_ING_VALID_PAUSE_FRAME: counts valid pause frames (regular and PFC)
  138. * @DPMAC_CNT_EGR_VALID_PAUSE_FRAME: counts valid pause frames transmitted
  139. * (regular and PFC).
  140. * @DPMAC_CNT_ING_BYTE: counts bytes received except preamble for all valid
  141. * frames and valid pause frames.
  142. * @DPMAC_CNT_ING_MCAST_FRAME: counts received multicast frames.
  143. * @DPMAC_CNT_ING_BCAST_FRAME: counts received broadcast frames.
  144. * @DPMAC_CNT_ING_ALL_FRAME: counts each good or bad frames received.
  145. * @DPMAC_CNT_ING_UCAST_FRAME: counts received unicast frames.
  146. * @DPMAC_CNT_ING_ERR_FRAME: counts frames received with an error
  147. * (except for undersized/fragment frame).
  148. * @DPMAC_CNT_EGR_BYTE: counts bytes transmitted except preamble for all valid
  149. * frames and valid pause frames transmitted.
  150. * @DPMAC_CNT_EGR_MCAST_FRAME: counts transmitted multicast frames.
  151. * @DPMAC_CNT_EGR_BCAST_FRAME: counts transmitted broadcast frames.
  152. * @DPMAC_CNT_EGR_UCAST_FRAME: counts transmitted unicast frames.
  153. * @DPMAC_CNT_EGR_ERR_FRAME: counts frames transmitted with an error.
  154. * @DPMAC_CNT_ING_GOOD_FRAME: counts frames received without error, including
  155. * pause frames.
  156. * @DPMAC_CNT_EGR_GOOD_FRAME: counts frames transmitted without error, including
  157. * pause frames.
  158. */
  159. enum dpmac_counter_id {
  160. DPMAC_CNT_ING_FRAME_64,
  161. DPMAC_CNT_ING_FRAME_127,
  162. DPMAC_CNT_ING_FRAME_255,
  163. DPMAC_CNT_ING_FRAME_511,
  164. DPMAC_CNT_ING_FRAME_1023,
  165. DPMAC_CNT_ING_FRAME_1518,
  166. DPMAC_CNT_ING_FRAME_1519_MAX,
  167. DPMAC_CNT_ING_FRAG,
  168. DPMAC_CNT_ING_JABBER,
  169. DPMAC_CNT_ING_FRAME_DISCARD,
  170. DPMAC_CNT_ING_ALIGN_ERR,
  171. DPMAC_CNT_EGR_UNDERSIZED,
  172. DPMAC_CNT_ING_OVERSIZED,
  173. DPMAC_CNT_ING_VALID_PAUSE_FRAME,
  174. DPMAC_CNT_EGR_VALID_PAUSE_FRAME,
  175. DPMAC_CNT_ING_BYTE,
  176. DPMAC_CNT_ING_MCAST_FRAME,
  177. DPMAC_CNT_ING_BCAST_FRAME,
  178. DPMAC_CNT_ING_ALL_FRAME,
  179. DPMAC_CNT_ING_UCAST_FRAME,
  180. DPMAC_CNT_ING_ERR_FRAME,
  181. DPMAC_CNT_EGR_BYTE,
  182. DPMAC_CNT_EGR_MCAST_FRAME,
  183. DPMAC_CNT_EGR_BCAST_FRAME,
  184. DPMAC_CNT_EGR_UCAST_FRAME,
  185. DPMAC_CNT_EGR_ERR_FRAME,
  186. DPMAC_CNT_ING_GOOD_FRAME,
  187. DPMAC_CNT_EGR_GOOD_FRAME
  188. };
  189. int dpmac_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  190. enum dpmac_counter_id id, u64 *value);
  191. int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
  192. u16 *major_ver, u16 *minor_ver);
  193. int dpmac_set_protocol(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  194. enum dpmac_eth_if protocol);
  195. #endif /* __FSL_DPMAC_H */