xref: /dpdk/drivers/net/dpaa/dpaa_ethdev.h (revision d81734ca)
1*d81734caSHemant Agrawal /* SPDX-License-Identifier: BSD-3-Clause
2ff9e112dSShreyansh Jain  *
3ff9e112dSShreyansh Jain  *   Copyright (c) 2014-2016 Freescale Semiconductor, Inc. All rights reserved.
4*d81734caSHemant Agrawal  *   Copyright 2017 NXP
5ff9e112dSShreyansh Jain  *
6ff9e112dSShreyansh Jain  */
7ff9e112dSShreyansh Jain #ifndef __DPAA_ETHDEV_H__
8ff9e112dSShreyansh Jain #define __DPAA_ETHDEV_H__
9ff9e112dSShreyansh Jain 
10ff9e112dSShreyansh Jain /* System headers */
11ff9e112dSShreyansh Jain #include <stdbool.h>
12ff9e112dSShreyansh Jain #include <rte_ethdev.h>
13ff9e112dSShreyansh Jain 
14ff9e112dSShreyansh Jain #include <fsl_usd.h>
15ff9e112dSShreyansh Jain #include <fsl_qman.h>
16ff9e112dSShreyansh Jain #include <fsl_bman.h>
17ff9e112dSShreyansh Jain #include <of.h>
18ff9e112dSShreyansh Jain #include <netcfg.h>
19ff9e112dSShreyansh Jain 
20cf0fab1dSHemant Agrawal /* DPAA SoC identifier; If this is not available, it can be concluded
21cf0fab1dSHemant Agrawal  * that board is non-DPAA. Single slot is currently supported.
22cf0fab1dSHemant Agrawal  */
23cf0fab1dSHemant Agrawal #define DPAA_SOC_ID_FILE		"sys/devices/soc0/soc_id"
24cf0fab1dSHemant Agrawal 
25ff9e112dSShreyansh Jain #define DPAA_MBUF_HW_ANNOTATION		64
26ff9e112dSShreyansh Jain #define DPAA_FD_PTA_SIZE		64
27ff9e112dSShreyansh Jain 
28ff9e112dSShreyansh Jain #if (DPAA_MBUF_HW_ANNOTATION + DPAA_FD_PTA_SIZE) > RTE_PKTMBUF_HEADROOM
29ff9e112dSShreyansh Jain #error "Annotation requirement is more than RTE_PKTMBUF_HEADROOM"
30ff9e112dSShreyansh Jain #endif
31ff9e112dSShreyansh Jain 
32ff9e112dSShreyansh Jain /* we will re-use the HEADROOM for annotation in RX */
33ff9e112dSShreyansh Jain #define DPAA_HW_BUF_RESERVE	0
34ff9e112dSShreyansh Jain #define DPAA_PACKET_LAYOUT_ALIGN	64
35ff9e112dSShreyansh Jain 
36ff9e112dSShreyansh Jain /* Alignment to use for cpu-local structs to avoid coherency problems. */
37ff9e112dSShreyansh Jain #define MAX_CACHELINE			64
38ff9e112dSShreyansh Jain 
39ff9e112dSShreyansh Jain #define DPAA_MIN_RX_BUF_SIZE 512
40ff9e112dSShreyansh Jain #define DPAA_MAX_RX_PKT_LEN  10240
41ff9e112dSShreyansh Jain 
42ff9e112dSShreyansh Jain /* RX queue tail drop threshold
43ff9e112dSShreyansh Jain  * currently considering 32 KB packets.
44ff9e112dSShreyansh Jain  */
45ff9e112dSShreyansh Jain #define CONG_THRESHOLD_RX_Q  (32 * 1024)
46ff9e112dSShreyansh Jain 
47ff9e112dSShreyansh Jain /*max mac filter for memac(8) including primary mac addr*/
48ff9e112dSShreyansh Jain #define DPAA_MAX_MAC_FILTER (MEMAC_NUM_OF_PADDRS + 1)
49ff9e112dSShreyansh Jain 
50ff9e112dSShreyansh Jain /*Maximum number of slots available in TX ring*/
51ff9e112dSShreyansh Jain #define MAX_TX_RING_SLOTS	8
52ff9e112dSShreyansh Jain 
53ff9e112dSShreyansh Jain /* PCD frame queues */
54ff9e112dSShreyansh Jain #define DPAA_PCD_FQID_START		0x400
55ff9e112dSShreyansh Jain #define DPAA_PCD_FQID_MULTIPLIER	0x100
56ff9e112dSShreyansh Jain #define DPAA_DEFAULT_NUM_PCD_QUEUES	1
57ff9e112dSShreyansh Jain 
58ff9e112dSShreyansh Jain #define DPAA_IF_TX_PRIORITY		3
59ff9e112dSShreyansh Jain #define DPAA_IF_RX_PRIORITY		4
60ff9e112dSShreyansh Jain #define DPAA_IF_DEBUG_PRIORITY		7
61ff9e112dSShreyansh Jain 
62ff9e112dSShreyansh Jain #define DPAA_IF_RX_ANNOTATION_STASH	1
63ff9e112dSShreyansh Jain #define DPAA_IF_RX_DATA_STASH		1
64ff9e112dSShreyansh Jain #define DPAA_IF_RX_CONTEXT_STASH		0
65ff9e112dSShreyansh Jain 
66ff9e112dSShreyansh Jain /* Each "debug" FQ is represented by one of these */
67ff9e112dSShreyansh Jain #define DPAA_DEBUG_FQ_RX_ERROR   0
68ff9e112dSShreyansh Jain #define DPAA_DEBUG_FQ_TX_ERROR   1
69ff9e112dSShreyansh Jain 
704fa5e0bbSShreyansh Jain #define DPAA_RSS_OFFLOAD_ALL ( \
714fa5e0bbSShreyansh Jain 	ETH_RSS_FRAG_IPV4 | \
724fa5e0bbSShreyansh Jain 	ETH_RSS_NONFRAG_IPV4_TCP | \
734fa5e0bbSShreyansh Jain 	ETH_RSS_NONFRAG_IPV4_UDP | \
744fa5e0bbSShreyansh Jain 	ETH_RSS_NONFRAG_IPV4_SCTP | \
754fa5e0bbSShreyansh Jain 	ETH_RSS_FRAG_IPV6 | \
764fa5e0bbSShreyansh Jain 	ETH_RSS_NONFRAG_IPV6_TCP | \
774fa5e0bbSShreyansh Jain 	ETH_RSS_NONFRAG_IPV6_UDP | \
784fa5e0bbSShreyansh Jain 	ETH_RSS_NONFRAG_IPV6_SCTP)
794fa5e0bbSShreyansh Jain 
80ff9e112dSShreyansh Jain #define DPAA_TX_CKSUM_OFFLOAD_MASK (             \
81ff9e112dSShreyansh Jain 		PKT_TX_IP_CKSUM |                \
82ff9e112dSShreyansh Jain 		PKT_TX_TCP_CKSUM |               \
83ff9e112dSShreyansh Jain 		PKT_TX_UDP_CKSUM)
84ff9e112dSShreyansh Jain 
85ff9e112dSShreyansh Jain /* DPAA Frame descriptor macros */
86ff9e112dSShreyansh Jain 
87ff9e112dSShreyansh Jain #define DPAA_FD_CMD_FCO			0x80000000
88ff9e112dSShreyansh Jain /**< Frame queue Context Override */
89ff9e112dSShreyansh Jain #define DPAA_FD_CMD_RPD			0x40000000
90ff9e112dSShreyansh Jain /**< Read Prepended Data */
91ff9e112dSShreyansh Jain #define DPAA_FD_CMD_UPD			0x20000000
92ff9e112dSShreyansh Jain /**< Update Prepended Data */
93ff9e112dSShreyansh Jain #define DPAA_FD_CMD_DTC			0x10000000
94ff9e112dSShreyansh Jain /**< Do IP/TCP/UDP Checksum */
95ff9e112dSShreyansh Jain #define DPAA_FD_CMD_DCL4C		0x10000000
96ff9e112dSShreyansh Jain /**< Didn't calculate L4 Checksum */
97ff9e112dSShreyansh Jain #define DPAA_FD_CMD_CFQ			0x00ffffff
98ff9e112dSShreyansh Jain /**< Confirmation Frame Queue */
99ff9e112dSShreyansh Jain 
100ff9e112dSShreyansh Jain /* Each network interface is represented by one of these */
101ff9e112dSShreyansh Jain struct dpaa_if {
102ff9e112dSShreyansh Jain 	int valid;
103ff9e112dSShreyansh Jain 	char *name;
104ff9e112dSShreyansh Jain 	const struct fm_eth_port_cfg *cfg;
105ff9e112dSShreyansh Jain 	struct qman_fq *rx_queues;
106ff9e112dSShreyansh Jain 	struct qman_fq *tx_queues;
107ff9e112dSShreyansh Jain 	struct qman_fq debug_queues[2];
108ff9e112dSShreyansh Jain 	uint16_t nb_rx_queues;
109ff9e112dSShreyansh Jain 	uint16_t nb_tx_queues;
110ff9e112dSShreyansh Jain 	uint32_t ifid;
111ff9e112dSShreyansh Jain 	struct fman_if *fif;
112ff9e112dSShreyansh Jain 	struct dpaa_bp_info *bp_info;
113ff9e112dSShreyansh Jain 	struct rte_eth_fc_conf *fc_conf;
114ff9e112dSShreyansh Jain };
115ff9e112dSShreyansh Jain 
116b21ed3e2SHemant Agrawal struct dpaa_if_stats {
117b21ed3e2SHemant Agrawal 	/* Rx Statistics Counter */
118b21ed3e2SHemant Agrawal 	uint64_t reoct;		/**<Rx Eth Octets Counter */
119b21ed3e2SHemant Agrawal 	uint64_t roct;		/**<Rx Octet Counters */
120b21ed3e2SHemant Agrawal 	uint64_t raln;		/**<Rx Alignment Error Counter */
121b21ed3e2SHemant Agrawal 	uint64_t rxpf;		/**<Rx valid Pause Frame */
122b21ed3e2SHemant Agrawal 	uint64_t rfrm;		/**<Rx Frame counter */
123b21ed3e2SHemant Agrawal 	uint64_t rfcs;		/**<Rx frame check seq error */
124b21ed3e2SHemant Agrawal 	uint64_t rvlan;		/**<Rx Vlan Frame Counter */
125b21ed3e2SHemant Agrawal 	uint64_t rerr;		/**<Rx Frame error */
126b21ed3e2SHemant Agrawal 	uint64_t ruca;		/**<Rx Unicast */
127b21ed3e2SHemant Agrawal 	uint64_t rmca;		/**<Rx Multicast */
128b21ed3e2SHemant Agrawal 	uint64_t rbca;		/**<Rx Broadcast */
129b21ed3e2SHemant Agrawal 	uint64_t rdrp;		/**<Rx Dropped Packet */
130b21ed3e2SHemant Agrawal 	uint64_t rpkt;		/**<Rx packet */
131b21ed3e2SHemant Agrawal 	uint64_t rund;		/**<Rx undersized packets */
132b21ed3e2SHemant Agrawal 	uint32_t res_x[14];
133b21ed3e2SHemant Agrawal 	uint64_t rovr;		/**<Rx oversized but good */
134b21ed3e2SHemant Agrawal 	uint64_t rjbr;		/**<Rx oversized with bad csum */
135b21ed3e2SHemant Agrawal 	uint64_t rfrg;		/**<Rx fragment Packet */
136b21ed3e2SHemant Agrawal 	uint64_t rcnp;		/**<Rx control packets (0x8808 */
137b21ed3e2SHemant Agrawal 	uint64_t rdrntp;	/**<Rx dropped due to FIFO overflow */
138b21ed3e2SHemant Agrawal 	uint32_t res01d0[12];
139b21ed3e2SHemant Agrawal 	/* Tx Statistics Counter */
140b21ed3e2SHemant Agrawal 	uint64_t teoct;		/**<Tx eth octets */
141b21ed3e2SHemant Agrawal 	uint64_t toct;		/**<Tx Octets */
142b21ed3e2SHemant Agrawal 	uint32_t res0210[2];
143b21ed3e2SHemant Agrawal 	uint64_t txpf;		/**<Tx valid pause frame */
144b21ed3e2SHemant Agrawal 	uint64_t tfrm;		/**<Tx frame counter */
145b21ed3e2SHemant Agrawal 	uint64_t tfcs;		/**<Tx FCS error */
146b21ed3e2SHemant Agrawal 	uint64_t tvlan;		/**<Tx Vlan Frame */
147b21ed3e2SHemant Agrawal 	uint64_t terr;		/**<Tx frame error */
148b21ed3e2SHemant Agrawal 	uint64_t tuca;		/**<Tx Unicast */
149b21ed3e2SHemant Agrawal 	uint64_t tmca;		/**<Tx Multicast */
150b21ed3e2SHemant Agrawal 	uint64_t tbca;		/**<Tx Broadcast */
151b21ed3e2SHemant Agrawal 	uint32_t res0258[2];
152b21ed3e2SHemant Agrawal 	uint64_t tpkt;		/**<Tx Packet */
153b21ed3e2SHemant Agrawal 	uint64_t tund;		/**<Tx Undersized */
154b21ed3e2SHemant Agrawal };
155b21ed3e2SHemant Agrawal 
156ff9e112dSShreyansh Jain #endif
157