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