cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

dpmac.h (7096B)


      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
      8/* Data Path MAC API
      9 * Contains initialization APIs and runtime control APIs for DPMAC
     10 */
     11
     12struct fsl_mc_io;
     13
     14int dpmac_open(struct fsl_mc_io *mc_io,
     15	       u32 cmd_flags,
     16	       int dpmac_id,
     17	       u16 *token);
     18
     19int dpmac_close(struct fsl_mc_io *mc_io,
     20		u32 cmd_flags,
     21		u16 token);
     22
     23/**
     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
     29 */
     30enum dpmac_link_type {
     31	DPMAC_LINK_TYPE_NONE,
     32	DPMAC_LINK_TYPE_FIXED,
     33	DPMAC_LINK_TYPE_PHY,
     34	DPMAC_LINK_TYPE_BACKPLANE
     35};
     36
     37/**
     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
     51 */
     52enum dpmac_eth_if {
     53	DPMAC_ETH_IF_MII,
     54	DPMAC_ETH_IF_RMII,
     55	DPMAC_ETH_IF_SMII,
     56	DPMAC_ETH_IF_GMII,
     57	DPMAC_ETH_IF_RGMII,
     58	DPMAC_ETH_IF_SGMII,
     59	DPMAC_ETH_IF_QSGMII,
     60	DPMAC_ETH_IF_XAUI,
     61	DPMAC_ETH_IF_XFI,
     62	DPMAC_ETH_IF_CAUI,
     63	DPMAC_ETH_IF_1000BASEX,
     64	DPMAC_ETH_IF_USXGMII,
     65};
     66
     67/**
     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
     73 */
     74struct dpmac_attr {
     75	u16 id;
     76	u32 max_rate;
     77	enum dpmac_eth_if eth_if;
     78	enum dpmac_link_type link_type;
     79};
     80
     81int dpmac_get_attributes(struct fsl_mc_io *mc_io,
     82			 u32 cmd_flags,
     83			 u16 token,
     84			 struct dpmac_attr *attr);
     85
     86/* DPMAC link configuration/state options */
     87
     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)
     92
     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)
     99
    100/* Advertise auto-negotiation enable */
    101#define DPMAC_ADVERTISED_AUTONEG		BIT_ULL(3)
    102
    103/**
    104 * struct dpmac_link_state - DPMAC link configuration request
    105 * @rate: Rate in Mbps
    106 * @options: Enable/Disable DPMAC link cfg features (bitmap)
    107 * @up: Link state
    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)
    111 */
    112struct dpmac_link_state {
    113	u32 rate;
    114	u64 options;
    115	int up;
    116	int state_valid;
    117	u64 supported;
    118	u64 advertising;
    119};
    120
    121int dpmac_set_link_state(struct fsl_mc_io *mc_io,
    122			 u32 cmd_flags,
    123			 u16 token,
    124			 struct dpmac_link_state *link_state);
    125
    126/**
    127 * enum dpmac_counter_id - DPMAC counter types
    128 *
    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),
    137 *				  good or bad.
    138 * @DPMAC_CNT_ING_FRAG: counts frames which are shorter than 64 bytes received
    139 *			with a wrong CRC
    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
    154 *				     (regular and PFC).
    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
    170 *			      pause frames.
    171 * @DPMAC_CNT_EGR_GOOD_FRAME: counts frames transmitted without error, including
    172 *			      pause frames.
    173 */
    174enum 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,
    182	DPMAC_CNT_ING_FRAG,
    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,
    190	DPMAC_CNT_ING_BYTE,
    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,
    196	DPMAC_CNT_EGR_BYTE,
    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
    203};
    204
    205int dpmac_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
    206		      enum dpmac_counter_id id, u64 *value);
    207
    208int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
    209			  u16 *major_ver, u16 *minor_ver);
    210
    211int 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 */