Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
0002 /* Copyright 2013-2016 Freescale Semiconductor Inc.
0003  * Copyright 2019 NXP
0004  */
0005 #ifndef __FSL_DPMAC_H
0006 #define __FSL_DPMAC_H
0007 
0008 /* Data Path MAC API
0009  * Contains initialization APIs and runtime control APIs for DPMAC
0010  */
0011 
0012 struct fsl_mc_io;
0013 
0014 int dpmac_open(struct fsl_mc_io *mc_io,
0015            u32 cmd_flags,
0016            int dpmac_id,
0017            u16 *token);
0018 
0019 int dpmac_close(struct fsl_mc_io *mc_io,
0020         u32 cmd_flags,
0021         u16 token);
0022 
0023 /**
0024  * enum dpmac_link_type -  DPMAC link type
0025  * @DPMAC_LINK_TYPE_NONE: No link
0026  * @DPMAC_LINK_TYPE_FIXED: Link is fixed type
0027  * @DPMAC_LINK_TYPE_PHY: Link by PHY ID
0028  * @DPMAC_LINK_TYPE_BACKPLANE: Backplane link type
0029  */
0030 enum dpmac_link_type {
0031     DPMAC_LINK_TYPE_NONE,
0032     DPMAC_LINK_TYPE_FIXED,
0033     DPMAC_LINK_TYPE_PHY,
0034     DPMAC_LINK_TYPE_BACKPLANE
0035 };
0036 
0037 /**
0038  * enum dpmac_eth_if - DPMAC Ethrnet interface
0039  * @DPMAC_ETH_IF_MII: MII interface
0040  * @DPMAC_ETH_IF_RMII: RMII interface
0041  * @DPMAC_ETH_IF_SMII: SMII interface
0042  * @DPMAC_ETH_IF_GMII: GMII interface
0043  * @DPMAC_ETH_IF_RGMII: RGMII interface
0044  * @DPMAC_ETH_IF_SGMII: SGMII interface
0045  * @DPMAC_ETH_IF_QSGMII: QSGMII interface
0046  * @DPMAC_ETH_IF_XAUI: XAUI interface
0047  * @DPMAC_ETH_IF_XFI: XFI interface
0048  * @DPMAC_ETH_IF_CAUI: CAUI interface
0049  * @DPMAC_ETH_IF_1000BASEX: 1000BASEX interface
0050  * @DPMAC_ETH_IF_USXGMII: USXGMII interface
0051  */
0052 enum dpmac_eth_if {
0053     DPMAC_ETH_IF_MII,
0054     DPMAC_ETH_IF_RMII,
0055     DPMAC_ETH_IF_SMII,
0056     DPMAC_ETH_IF_GMII,
0057     DPMAC_ETH_IF_RGMII,
0058     DPMAC_ETH_IF_SGMII,
0059     DPMAC_ETH_IF_QSGMII,
0060     DPMAC_ETH_IF_XAUI,
0061     DPMAC_ETH_IF_XFI,
0062     DPMAC_ETH_IF_CAUI,
0063     DPMAC_ETH_IF_1000BASEX,
0064     DPMAC_ETH_IF_USXGMII,
0065 };
0066 
0067 /**
0068  * struct dpmac_attr - Structure representing DPMAC attributes
0069  * @id:     DPMAC object ID
0070  * @max_rate:   Maximum supported rate - in Mbps
0071  * @eth_if: Ethernet interface
0072  * @link_type:  link type
0073  */
0074 struct dpmac_attr {
0075     u16 id;
0076     u32 max_rate;
0077     enum dpmac_eth_if eth_if;
0078     enum dpmac_link_type link_type;
0079 };
0080 
0081 int dpmac_get_attributes(struct fsl_mc_io *mc_io,
0082              u32 cmd_flags,
0083              u16 token,
0084              struct dpmac_attr *attr);
0085 
0086 /* DPMAC link configuration/state options */
0087 
0088 #define DPMAC_LINK_OPT_AUTONEG          BIT_ULL(0)
0089 #define DPMAC_LINK_OPT_HALF_DUPLEX      BIT_ULL(1)
0090 #define DPMAC_LINK_OPT_PAUSE            BIT_ULL(2)
0091 #define DPMAC_LINK_OPT_ASYM_PAUSE       BIT_ULL(3)
0092 
0093 /* Advertised link speeds */
0094 #define DPMAC_ADVERTISED_10BASET_FULL       BIT_ULL(0)
0095 #define DPMAC_ADVERTISED_100BASET_FULL      BIT_ULL(1)
0096 #define DPMAC_ADVERTISED_1000BASET_FULL     BIT_ULL(2)
0097 #define DPMAC_ADVERTISED_10000BASET_FULL    BIT_ULL(4)
0098 #define DPMAC_ADVERTISED_2500BASEX_FULL     BIT_ULL(5)
0099 
0100 /* Advertise auto-negotiation enable */
0101 #define DPMAC_ADVERTISED_AUTONEG        BIT_ULL(3)
0102 
0103 /**
0104  * struct dpmac_link_state - DPMAC link configuration request
0105  * @rate: Rate in Mbps
0106  * @options: Enable/Disable DPMAC link cfg features (bitmap)
0107  * @up: Link state
0108  * @state_valid: Ignore/Update the state of the link
0109  * @supported: Speeds capability of the phy (bitmap)
0110  * @advertising: Speeds that are advertised for autoneg (bitmap)
0111  */
0112 struct dpmac_link_state {
0113     u32 rate;
0114     u64 options;
0115     int up;
0116     int state_valid;
0117     u64 supported;
0118     u64 advertising;
0119 };
0120 
0121 int dpmac_set_link_state(struct fsl_mc_io *mc_io,
0122              u32 cmd_flags,
0123              u16 token,
0124              struct dpmac_link_state *link_state);
0125 
0126 /**
0127  * enum dpmac_counter_id - DPMAC counter types
0128  *
0129  * @DPMAC_CNT_ING_FRAME_64: counts 64-bytes frames, good or bad.
0130  * @DPMAC_CNT_ING_FRAME_127: counts 65- to 127-bytes frames, good or bad.
0131  * @DPMAC_CNT_ING_FRAME_255: counts 128- to 255-bytes frames, good or bad.
0132  * @DPMAC_CNT_ING_FRAME_511: counts 256- to 511-bytes frames, good or bad.
0133  * @DPMAC_CNT_ING_FRAME_1023: counts 512- to 1023-bytes frames, good or bad.
0134  * @DPMAC_CNT_ING_FRAME_1518: counts 1024- to 1518-bytes frames, good or bad.
0135  * @DPMAC_CNT_ING_FRAME_1519_MAX: counts 1519-bytes frames and larger
0136  *                (up to max frame length specified),
0137  *                good or bad.
0138  * @DPMAC_CNT_ING_FRAG: counts frames which are shorter than 64 bytes received
0139  *          with a wrong CRC
0140  * @DPMAC_CNT_ING_JABBER: counts frames longer than the maximum frame length
0141  *            specified, with a bad frame check sequence.
0142  * @DPMAC_CNT_ING_FRAME_DISCARD: counts dropped frames due to internal errors.
0143  *               Occurs when a receive FIFO overflows.
0144  *               Includes also frames truncated as a result of
0145  *               the receive FIFO overflow.
0146  * @DPMAC_CNT_ING_ALIGN_ERR: counts frames with an alignment error
0147  *               (optional used for wrong SFD).
0148  * @DPMAC_CNT_EGR_UNDERSIZED: counts frames transmitted that was less than 64
0149  *                bytes long with a good CRC.
0150  * @DPMAC_CNT_ING_OVERSIZED: counts frames longer than the maximum frame length
0151  *               specified, with a good frame check sequence.
0152  * @DPMAC_CNT_ING_VALID_PAUSE_FRAME: counts valid pause frames (regular and PFC)
0153  * @DPMAC_CNT_EGR_VALID_PAUSE_FRAME: counts valid pause frames transmitted
0154  *                   (regular and PFC).
0155  * @DPMAC_CNT_ING_BYTE: counts bytes received except preamble for all valid
0156  *          frames and valid pause frames.
0157  * @DPMAC_CNT_ING_MCAST_FRAME: counts received multicast frames.
0158  * @DPMAC_CNT_ING_BCAST_FRAME: counts received broadcast frames.
0159  * @DPMAC_CNT_ING_ALL_FRAME: counts each good or bad frames received.
0160  * @DPMAC_CNT_ING_UCAST_FRAME: counts received unicast frames.
0161  * @DPMAC_CNT_ING_ERR_FRAME: counts frames received with an error
0162  *               (except for undersized/fragment frame).
0163  * @DPMAC_CNT_EGR_BYTE: counts bytes transmitted except preamble for all valid
0164  *          frames and valid pause frames transmitted.
0165  * @DPMAC_CNT_EGR_MCAST_FRAME: counts transmitted multicast frames.
0166  * @DPMAC_CNT_EGR_BCAST_FRAME: counts transmitted broadcast frames.
0167  * @DPMAC_CNT_EGR_UCAST_FRAME: counts transmitted unicast frames.
0168  * @DPMAC_CNT_EGR_ERR_FRAME: counts frames transmitted with an error.
0169  * @DPMAC_CNT_ING_GOOD_FRAME: counts frames received without error, including
0170  *                pause frames.
0171  * @DPMAC_CNT_EGR_GOOD_FRAME: counts frames transmitted without error, including
0172  *                pause frames.
0173  */
0174 enum dpmac_counter_id {
0175     DPMAC_CNT_ING_FRAME_64,
0176     DPMAC_CNT_ING_FRAME_127,
0177     DPMAC_CNT_ING_FRAME_255,
0178     DPMAC_CNT_ING_FRAME_511,
0179     DPMAC_CNT_ING_FRAME_1023,
0180     DPMAC_CNT_ING_FRAME_1518,
0181     DPMAC_CNT_ING_FRAME_1519_MAX,
0182     DPMAC_CNT_ING_FRAG,
0183     DPMAC_CNT_ING_JABBER,
0184     DPMAC_CNT_ING_FRAME_DISCARD,
0185     DPMAC_CNT_ING_ALIGN_ERR,
0186     DPMAC_CNT_EGR_UNDERSIZED,
0187     DPMAC_CNT_ING_OVERSIZED,
0188     DPMAC_CNT_ING_VALID_PAUSE_FRAME,
0189     DPMAC_CNT_EGR_VALID_PAUSE_FRAME,
0190     DPMAC_CNT_ING_BYTE,
0191     DPMAC_CNT_ING_MCAST_FRAME,
0192     DPMAC_CNT_ING_BCAST_FRAME,
0193     DPMAC_CNT_ING_ALL_FRAME,
0194     DPMAC_CNT_ING_UCAST_FRAME,
0195     DPMAC_CNT_ING_ERR_FRAME,
0196     DPMAC_CNT_EGR_BYTE,
0197     DPMAC_CNT_EGR_MCAST_FRAME,
0198     DPMAC_CNT_EGR_BCAST_FRAME,
0199     DPMAC_CNT_EGR_UCAST_FRAME,
0200     DPMAC_CNT_EGR_ERR_FRAME,
0201     DPMAC_CNT_ING_GOOD_FRAME,
0202     DPMAC_CNT_EGR_GOOD_FRAME
0203 };
0204 
0205 int dpmac_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0206               enum dpmac_counter_id id, u64 *value);
0207 
0208 int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
0209               u16 *major_ver, u16 *minor_ver);
0210 
0211 int dpmac_set_protocol(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0212                enum dpmac_eth_if protocol);
0213 #endif /* __FSL_DPMAC_H */