mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
Extend the dpmac_counter_id enum with the newly added counters which can be interrogated through the MC firmware. Also add the dpmac_get_statistics() API which can be used to retrieve multiple MAC counters through a single firmware command. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://patch.msgid.link/20260323115039.3932600-2-ioana.ciornei@nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
304 lines
11 KiB
C
304 lines
11 KiB
C
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
|
|
/* Copyright 2013-2016 Freescale Semiconductor Inc.
|
|
* Copyright 2019, 2024-2026 NXP
|
|
*/
|
|
#ifndef __FSL_DPMAC_H
|
|
#define __FSL_DPMAC_H
|
|
|
|
/* Data Path MAC API
|
|
* Contains initialization APIs and runtime control APIs for DPMAC
|
|
*/
|
|
|
|
struct fsl_mc_io;
|
|
|
|
int dpmac_open(struct fsl_mc_io *mc_io,
|
|
u32 cmd_flags,
|
|
int dpmac_id,
|
|
u16 *token);
|
|
|
|
int dpmac_close(struct fsl_mc_io *mc_io,
|
|
u32 cmd_flags,
|
|
u16 token);
|
|
|
|
/**
|
|
* enum dpmac_link_type - DPMAC link type
|
|
* @DPMAC_LINK_TYPE_NONE: No link
|
|
* @DPMAC_LINK_TYPE_FIXED: Link is fixed type
|
|
* @DPMAC_LINK_TYPE_PHY: Link by PHY ID
|
|
* @DPMAC_LINK_TYPE_BACKPLANE: Backplane link type
|
|
*/
|
|
enum dpmac_link_type {
|
|
DPMAC_LINK_TYPE_NONE,
|
|
DPMAC_LINK_TYPE_FIXED,
|
|
DPMAC_LINK_TYPE_PHY,
|
|
DPMAC_LINK_TYPE_BACKPLANE
|
|
};
|
|
|
|
/**
|
|
* enum dpmac_eth_if - DPMAC Ethrnet interface
|
|
* @DPMAC_ETH_IF_MII: MII interface
|
|
* @DPMAC_ETH_IF_RMII: RMII interface
|
|
* @DPMAC_ETH_IF_SMII: SMII interface
|
|
* @DPMAC_ETH_IF_GMII: GMII interface
|
|
* @DPMAC_ETH_IF_RGMII: RGMII interface
|
|
* @DPMAC_ETH_IF_SGMII: SGMII interface
|
|
* @DPMAC_ETH_IF_QSGMII: QSGMII interface
|
|
* @DPMAC_ETH_IF_XAUI: XAUI interface
|
|
* @DPMAC_ETH_IF_XFI: XFI interface
|
|
* @DPMAC_ETH_IF_CAUI: CAUI interface
|
|
* @DPMAC_ETH_IF_1000BASEX: 1000BASEX interface
|
|
* @DPMAC_ETH_IF_USXGMII: USXGMII interface
|
|
*/
|
|
enum dpmac_eth_if {
|
|
DPMAC_ETH_IF_MII,
|
|
DPMAC_ETH_IF_RMII,
|
|
DPMAC_ETH_IF_SMII,
|
|
DPMAC_ETH_IF_GMII,
|
|
DPMAC_ETH_IF_RGMII,
|
|
DPMAC_ETH_IF_SGMII,
|
|
DPMAC_ETH_IF_QSGMII,
|
|
DPMAC_ETH_IF_XAUI,
|
|
DPMAC_ETH_IF_XFI,
|
|
DPMAC_ETH_IF_CAUI,
|
|
DPMAC_ETH_IF_1000BASEX,
|
|
DPMAC_ETH_IF_USXGMII,
|
|
};
|
|
|
|
/**
|
|
* struct dpmac_attr - Structure representing DPMAC attributes
|
|
* @id: DPMAC object ID
|
|
* @max_rate: Maximum supported rate - in Mbps
|
|
* @eth_if: Ethernet interface
|
|
* @link_type: link type
|
|
*/
|
|
struct dpmac_attr {
|
|
u16 id;
|
|
u32 max_rate;
|
|
enum dpmac_eth_if eth_if;
|
|
enum dpmac_link_type link_type;
|
|
};
|
|
|
|
int dpmac_get_attributes(struct fsl_mc_io *mc_io,
|
|
u32 cmd_flags,
|
|
u16 token,
|
|
struct dpmac_attr *attr);
|
|
|
|
/* DPMAC link configuration/state options */
|
|
|
|
#define DPMAC_LINK_OPT_AUTONEG BIT_ULL(0)
|
|
#define DPMAC_LINK_OPT_HALF_DUPLEX BIT_ULL(1)
|
|
#define DPMAC_LINK_OPT_PAUSE BIT_ULL(2)
|
|
#define DPMAC_LINK_OPT_ASYM_PAUSE BIT_ULL(3)
|
|
|
|
/* Advertised link speeds */
|
|
#define DPMAC_ADVERTISED_10BASET_FULL BIT_ULL(0)
|
|
#define DPMAC_ADVERTISED_100BASET_FULL BIT_ULL(1)
|
|
#define DPMAC_ADVERTISED_1000BASET_FULL BIT_ULL(2)
|
|
#define DPMAC_ADVERTISED_10000BASET_FULL BIT_ULL(4)
|
|
#define DPMAC_ADVERTISED_2500BASEX_FULL BIT_ULL(5)
|
|
|
|
/* Advertise auto-negotiation enable */
|
|
#define DPMAC_ADVERTISED_AUTONEG BIT_ULL(3)
|
|
|
|
/**
|
|
* struct dpmac_link_state - DPMAC link configuration request
|
|
* @rate: Rate in Mbps
|
|
* @options: Enable/Disable DPMAC link cfg features (bitmap)
|
|
* @up: Link state
|
|
* @state_valid: Ignore/Update the state of the link
|
|
* @supported: Speeds capability of the phy (bitmap)
|
|
* @advertising: Speeds that are advertised for autoneg (bitmap)
|
|
*/
|
|
struct dpmac_link_state {
|
|
u32 rate;
|
|
u64 options;
|
|
int up;
|
|
int state_valid;
|
|
u64 supported;
|
|
u64 advertising;
|
|
};
|
|
|
|
int dpmac_set_link_state(struct fsl_mc_io *mc_io,
|
|
u32 cmd_flags,
|
|
u16 token,
|
|
struct dpmac_link_state *link_state);
|
|
|
|
/**
|
|
* enum dpmac_counter_id - DPMAC counter types
|
|
*
|
|
* @DPMAC_CNT_ING_FRAME_64: counts 64-bytes frames, good or bad.
|
|
* @DPMAC_CNT_ING_FRAME_127: counts 65- to 127-bytes frames, good or bad.
|
|
* @DPMAC_CNT_ING_FRAME_255: counts 128- to 255-bytes frames, good or bad.
|
|
* @DPMAC_CNT_ING_FRAME_511: counts 256- to 511-bytes frames, good or bad.
|
|
* @DPMAC_CNT_ING_FRAME_1023: counts 512- to 1023-bytes frames, good or bad.
|
|
* @DPMAC_CNT_ING_FRAME_1518: counts 1024- to 1518-bytes frames, good or bad.
|
|
* @DPMAC_CNT_ING_FRAME_1519_MAX: counts 1519-bytes frames and larger
|
|
* (up to max frame length specified),
|
|
* good or bad.
|
|
* @DPMAC_CNT_ING_FRAG: counts frames which are shorter than 64 bytes received
|
|
* with a wrong CRC
|
|
* @DPMAC_CNT_ING_JABBER: counts frames longer than the maximum frame length
|
|
* specified, with a bad frame check sequence.
|
|
* @DPMAC_CNT_ING_FRAME_DISCARD: counts dropped frames due to internal errors.
|
|
* Occurs when a receive FIFO overflows.
|
|
* Includes also frames truncated as a result of
|
|
* the receive FIFO overflow.
|
|
* @DPMAC_CNT_ING_ALIGN_ERR: counts frames with an alignment error
|
|
* (optional used for wrong SFD).
|
|
* @DPMAC_CNT_EGR_UNDERSIZED: counts frames transmitted that was less than 64
|
|
* bytes long with a good CRC.
|
|
* @DPMAC_CNT_ING_OVERSIZED: counts frames longer than the maximum frame length
|
|
* specified, with a good frame check sequence.
|
|
* @DPMAC_CNT_ING_VALID_PAUSE_FRAME: counts valid pause frames (regular and PFC)
|
|
* @DPMAC_CNT_EGR_VALID_PAUSE_FRAME: counts valid pause frames transmitted
|
|
* (regular and PFC).
|
|
* @DPMAC_CNT_ING_BYTE: counts bytes received except preamble for all valid
|
|
* frames and valid pause frames.
|
|
* @DPMAC_CNT_ING_MCAST_FRAME: counts received multicast frames.
|
|
* @DPMAC_CNT_ING_BCAST_FRAME: counts received broadcast frames.
|
|
* @DPMAC_CNT_ING_ALL_FRAME: counts each good or bad frames received.
|
|
* @DPMAC_CNT_ING_UCAST_FRAME: counts received unicast frames.
|
|
* @DPMAC_CNT_ING_ERR_FRAME: counts frames received with an error
|
|
* (except for undersized/fragment frame).
|
|
* @DPMAC_CNT_EGR_BYTE: counts bytes transmitted except preamble for all valid
|
|
* frames and valid pause frames transmitted.
|
|
* @DPMAC_CNT_EGR_MCAST_FRAME: counts transmitted multicast frames.
|
|
* @DPMAC_CNT_EGR_BCAST_FRAME: counts transmitted broadcast frames.
|
|
* @DPMAC_CNT_EGR_UCAST_FRAME: counts transmitted unicast frames.
|
|
* @DPMAC_CNT_EGR_ERR_FRAME: counts frames transmitted with an error.
|
|
* @DPMAC_CNT_ING_GOOD_FRAME: counts frames received without error, including
|
|
* pause frames.
|
|
* @DPMAC_CNT_EGR_GOOD_FRAME: counts frames transmitted without error, including
|
|
* pause frames.
|
|
* @DPMAC_CNT_EGR_FRAME_64: counts transmitted 64-bytes frames, good or bad.
|
|
* @DPMAC_CNT_EGR_FRAME_127: counts transmitted 65 to 127-bytes frames, good or
|
|
* bad.
|
|
* @DPMAC_CNT_EGR_FRAME_255: counts transmitted 128 to 255-bytes frames, good
|
|
* or bad.
|
|
* @DPMAC_CNT_EGR_FRAME_511: counts transmitted 256 to 511-bytes frames, good
|
|
* or bad.
|
|
* @DPMAC_CNT_EGR_FRAME_1023: counts transmitted 512 to 1023-bytes frames, good
|
|
* or bad.
|
|
* @DPMAC_CNT_EGR_FRAME_1518: counts transmitted 1024 to 1518-bytes frames,
|
|
* good or bad.
|
|
* @DPMAC_CNT_EGR_FRAME_1519_MAX: counts transmitted 1519-bytes frames and
|
|
* larger (up to max frame length specified),
|
|
* good or bad.
|
|
* @DPMAC_CNT_ING_ALL_BYTE: counts bytes received in both good and bad packets
|
|
* @DPMAC_CNT_ING_FCS_ERR: counts frames received with a CRC-32 error but the
|
|
* frame is otherwise of correct length
|
|
* @DPMAC_CNT_ING_VLAN_FRAME: counts the received VLAN tagged frames which are
|
|
* valid.
|
|
* @DPMAC_CNT_ING_UNDERSIZED: counts received frames which were less than 64
|
|
* bytes long and with a good CRC.
|
|
* @DPMAC_CNT_ING_CONTROL_FRAME: counts received control frames (type 0x8808)
|
|
* but not pause frames.
|
|
* @DPMAC_CNT_ING_FRAME_DISCARD_NOT_TRUNC: counts the fully dropped frames (not
|
|
* truncated) due to internal errors of
|
|
* the MAC client. Occurs when a
|
|
* receive FIFO overflows.
|
|
* @DPMAC_CNT_EGR_ALL_BYTE: counts transmitted bytes in both good and bad
|
|
* packets.
|
|
* @DPMAC_CNT_EGR_FCS_ERR: counts trasmitted frames with a CRC-32 error except
|
|
* for underflows.
|
|
* @DPMAC_CNT_EGR_VLAN_FRAME: counts the transmitted VLAN tagged frames which
|
|
* are valid.
|
|
* @DPMAC_CNT_EGR_ALL_FRAME: counts all trasmitted frames, good or bad.
|
|
* @DPMAC_CNT_EGR_CONTROL_FRAME: counts transmitted control frames (type
|
|
* 0x8808) but not pause frames.
|
|
* @DPMAC_CNT_ING_PFC0: number of PFC frames received for class 0.
|
|
* @DPMAC_CNT_ING_PFC1: number of PFC frames received for class 1.
|
|
* @DPMAC_CNT_ING_PFC2: number of PFC frames received for class 2.
|
|
* @DPMAC_CNT_ING_PFC3: number of PFC frames received for class 3.
|
|
* @DPMAC_CNT_ING_PFC4: number of PFC frames received for class 4.
|
|
* @DPMAC_CNT_ING_PFC5: number of PFC frames received for class 5.
|
|
* @DPMAC_CNT_ING_PFC6: number of PFC frames received for class 6.
|
|
* @DPMAC_CNT_ING_PFC7: number of PFC frames received for class 7.
|
|
* @DPMAC_CNT_EGR_PFC0: number of PFC frames transmitted for class 0.
|
|
* @DPMAC_CNT_EGR_PFC1: number of PFC frames transmitted for class 1.
|
|
* @DPMAC_CNT_EGR_PFC2: number of PFC frames transmitted for class 2.
|
|
* @DPMAC_CNT_EGR_PFC3: number of PFC frames transmitted for class 3.
|
|
* @DPMAC_CNT_EGR_PFC4: number of PFC frames transmitted for class 4.
|
|
* @DPMAC_CNT_EGR_PFC5: number of PFC frames transmitted for class 5.
|
|
* @DPMAC_CNT_EGR_PFC6: number of PFC frames transmitted for class 6.
|
|
* @DPMAC_CNT_EGR_PFC7: number of PFC frames transmitted for class 7.
|
|
*/
|
|
enum dpmac_counter_id {
|
|
DPMAC_CNT_ING_FRAME_64,
|
|
DPMAC_CNT_ING_FRAME_127,
|
|
DPMAC_CNT_ING_FRAME_255,
|
|
DPMAC_CNT_ING_FRAME_511,
|
|
DPMAC_CNT_ING_FRAME_1023,
|
|
DPMAC_CNT_ING_FRAME_1518,
|
|
DPMAC_CNT_ING_FRAME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EGR_VLAN_FRAME,
|
|
DPMAC_CNT_EGR_ALL_FRAME,
|
|
DPMAC_CNT_EGR_CONTROL_FRAME,
|
|
DPMAC_CNT_ING_PFC0,
|
|
DPMAC_CNT_ING_PFC1,
|
|
DPMAC_CNT_ING_PFC2,
|
|
DPMAC_CNT_ING_PFC3,
|
|
DPMAC_CNT_ING_PFC4,
|
|
DPMAC_CNT_ING_PFC5,
|
|
DPMAC_CNT_ING_PFC6,
|
|
DPMAC_CNT_ING_PFC7,
|
|
DPMAC_CNT_EGR_PFC0,
|
|
DPMAC_CNT_EGR_PFC1,
|
|
DPMAC_CNT_EGR_PFC2,
|
|
DPMAC_CNT_EGR_PFC3,
|
|
DPMAC_CNT_EGR_PFC4,
|
|
DPMAC_CNT_EGR_PFC5,
|
|
DPMAC_CNT_EGR_PFC6,
|
|
DPMAC_CNT_EGR_PFC7,
|
|
};
|
|
|
|
int dpmac_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
|
|
enum dpmac_counter_id id, u64 *value);
|
|
|
|
int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
|
|
u16 *major_ver, u16 *minor_ver);
|
|
|
|
int dpmac_set_protocol(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
|
|
enum dpmac_eth_if protocol);
|
|
|
|
int dpmac_get_statistics(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
|
|
u64 iova_cnt, u64 iova_values, u32 num_cnt);
|
|
|
|
#endif /* __FSL_DPMAC_H */
|