xref: /dpdk/drivers/net/dpaa2/dpaa2_ethdev.h (revision 6a556bd6)
1131a75b6SHemant Agrawal /* SPDX-License-Identifier: BSD-3-Clause
2c147eae0SHemant Agrawal  *
3c147eae0SHemant Agrawal  *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
4131a75b6SHemant Agrawal  *   Copyright 2016 NXP
5c147eae0SHemant Agrawal  *
6c147eae0SHemant Agrawal  */
7c147eae0SHemant Agrawal 
8c147eae0SHemant Agrawal #ifndef _DPAA2_ETHDEV_H
9c147eae0SHemant Agrawal #define _DPAA2_ETHDEV_H
10c147eae0SHemant Agrawal 
11b677d4c6SNipun Gupta #include <rte_event_eth_rx_adapter.h>
12c1870f65SAkhil Goyal #include <rte_pmd_dpaa2.h>
13b677d4c6SNipun Gupta 
141def64c2SNipun Gupta #include <dpaa2_hw_pvt.h>
151def64c2SNipun Gupta 
163e5a335dSHemant Agrawal #include <mc/fsl_dpni.h>
173e5a335dSHemant Agrawal #include <mc/fsl_mc_sys.h>
183e5a335dSHemant Agrawal 
19bee61d86SHemant Agrawal #define DPAA2_MIN_RX_BUF_SIZE 512
20bee61d86SHemant Agrawal #define DPAA2_MAX_RX_PKT_LEN  10240 /*WRIOP support*/
21bee61d86SHemant Agrawal 
2289c2ea8fSHemant Agrawal #define MAX_TCS			DPNI_MAX_TC
232d5f7f52SAshish Jain #define MAX_RX_QUEUES		128
243e5a335dSHemant Agrawal #define MAX_TX_QUEUES		16
253e5a335dSHemant Agrawal 
263e5a335dSHemant Agrawal /*default tc to be used for ,congestion, distribution etc configuration. */
273e5a335dSHemant Agrawal #define DPAA2_DEF_TC		0
283e5a335dSHemant Agrawal 
2929dfa62fSHemant Agrawal /* Threshold for a Tx queue to *Enter* Congestion state.
307ae777d0SHemant Agrawal  */
3129dfa62fSHemant Agrawal #define CONG_ENTER_TX_THRESHOLD   512
327ae777d0SHemant Agrawal 
337ae777d0SHemant Agrawal /* Threshold for a queue to *Exit* Congestion state.
347ae777d0SHemant Agrawal  */
3529dfa62fSHemant Agrawal #define CONG_EXIT_TX_THRESHOLD    480
367ae777d0SHemant Agrawal 
37a0840963SHemant Agrawal #define CONG_RETRY_COUNT 18000
38a0840963SHemant Agrawal 
3923d6a87eSHemant Agrawal /* RX queue tail drop threshold
4023d6a87eSHemant Agrawal  * currently considering 32 KB packets
4123d6a87eSHemant Agrawal  */
4229dfa62fSHemant Agrawal #define CONG_THRESHOLD_RX_Q  (64 * 1024)
43d47f0292SHemant Agrawal #define CONG_RX_OAL	128
4423d6a87eSHemant Agrawal 
4589c2ea8fSHemant Agrawal /* Size of the input SMMU mapped memory required by MC */
4689c2ea8fSHemant Agrawal #define DIST_PARAM_IOVA_SIZE 256
4789c2ea8fSHemant Agrawal 
487ae777d0SHemant Agrawal /* Enable TX Congestion control support
497ae777d0SHemant Agrawal  * default is disable
507ae777d0SHemant Agrawal  */
51a0840963SHemant Agrawal #define DPAA2_TX_CGR_OFF	0x01
527ae777d0SHemant Agrawal 
5323d6a87eSHemant Agrawal /* Disable RX tail drop, default is enable */
5423d6a87eSHemant Agrawal #define DPAA2_RX_TAILDROP_OFF	0x04
5523d6a87eSHemant Agrawal 
56762b275fSHemant Agrawal #define DPAA2_RSS_OFFLOAD_ALL ( \
57762b275fSHemant Agrawal 	ETH_RSS_IP | \
58762b275fSHemant Agrawal 	ETH_RSS_UDP | \
59762b275fSHemant Agrawal 	ETH_RSS_TCP | \
60762b275fSHemant Agrawal 	ETH_RSS_SCTP)
61762b275fSHemant Agrawal 
62a5852a94SNipun Gupta /* LX2 FRC Parsed values (Little Endian) */
63a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_ETHER		0x0060
64a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4		0x0000
65a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6		0x0020
66a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_EXT \
67a5852a94SNipun Gupta 			(0x0001 | DPAA2_PKT_TYPE_IPV4)
68a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_EXT \
69a5852a94SNipun Gupta 			(0x0001 | DPAA2_PKT_TYPE_IPV6)
70a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_TCP \
71a5852a94SNipun Gupta 			(0x000e | DPAA2_PKT_TYPE_IPV4)
72a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_TCP \
73a5852a94SNipun Gupta 			(0x000e | DPAA2_PKT_TYPE_IPV6)
74a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_UDP \
75a5852a94SNipun Gupta 			(0x0010 | DPAA2_PKT_TYPE_IPV4)
76a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_UDP \
77a5852a94SNipun Gupta 			(0x0010 | DPAA2_PKT_TYPE_IPV6)
78a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_SCTP	\
79a5852a94SNipun Gupta 			(0x000f | DPAA2_PKT_TYPE_IPV4)
80a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_SCTP	\
81a5852a94SNipun Gupta 			(0x000f | DPAA2_PKT_TYPE_IPV6)
82a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_ICMP \
83a5852a94SNipun Gupta 			(0x0003 | DPAA2_PKT_TYPE_IPV4_EXT)
84a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_ICMP \
85a5852a94SNipun Gupta 			(0x0003 | DPAA2_PKT_TYPE_IPV6_EXT)
86a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_VLAN_1		0x0160
87a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_VLAN_2		0x0260
88a5852a94SNipun Gupta 
89c1870f65SAkhil Goyal /* enable timestamp in mbuf*/
90c1870f65SAkhil Goyal extern enum pmd_dpaa2_ts dpaa2_enable_ts;
91c1870f65SAkhil Goyal 
92fe2b986aSSunil Kumar Kori #define DPAA2_QOS_TABLE_RECONFIGURE	1
93fe2b986aSSunil Kumar Kori #define DPAA2_FS_TABLE_RECONFIGURE	2
94fe2b986aSSunil Kumar Kori 
95fe2b986aSSunil Kumar Kori /*Externaly defined*/
96fe2b986aSSunil Kumar Kori extern const struct rte_flow_ops dpaa2_flow_ops;
97fe2b986aSSunil Kumar Kori extern enum rte_filter_type dpaa2_filter_type;
98fe2b986aSSunil Kumar Kori 
99c147eae0SHemant Agrawal struct dpaa2_dev_priv {
100c147eae0SHemant Agrawal 	void *hw;
101c147eae0SHemant Agrawal 	int32_t hw_id;
1023e5a335dSHemant Agrawal 	int32_t qdid;
103c147eae0SHemant Agrawal 	uint16_t token;
1043e5a335dSHemant Agrawal 	uint8_t nb_tx_queues;
1053e5a335dSHemant Agrawal 	uint8_t nb_rx_queues;
10616c4a3c4SNipun Gupta 	uint32_t options;
1073e5a335dSHemant Agrawal 	void *rx_vq[MAX_RX_QUEUES];
1083e5a335dSHemant Agrawal 	void *tx_vq[MAX_TX_QUEUES];
109c147eae0SHemant Agrawal 
110bee61d86SHemant Agrawal 	struct dpaa2_bp_list *bp_list; /**<Attached buffer pool list */
11133fad432SHemant Agrawal 	uint8_t max_mac_filters;
11233fad432SHemant Agrawal 	uint8_t max_vlan_filters;
11316bbc98aSShreyansh Jain 	uint8_t num_rx_tc;
114c147eae0SHemant Agrawal 	uint8_t flags; /*dpaa2 config flags */
11516c4a3c4SNipun Gupta 	uint8_t en_ordered;
11616c4a3c4SNipun Gupta 	uint8_t en_loose_ordered;
117fe2b986aSSunil Kumar Kori 
118fe2b986aSSunil Kumar Kori 	struct pattern_s {
119fe2b986aSSunil Kumar Kori 		uint8_t item_count;
120fe2b986aSSunil Kumar Kori 		uint8_t pattern_type[DPKG_MAX_NUM_OF_EXTRACTS];
121fe2b986aSSunil Kumar Kori 	} pattern[MAX_TCS + 1];
122fe2b986aSSunil Kumar Kori 
123fe2b986aSSunil Kumar Kori 	struct extract_s {
124fe2b986aSSunil Kumar Kori 		struct dpkg_profile_cfg qos_key_cfg;
125fe2b986aSSunil Kumar Kori 		struct dpkg_profile_cfg fs_key_cfg[MAX_TCS];
126fe2b986aSSunil Kumar Kori 		uint64_t qos_extract_param;
127fe2b986aSSunil Kumar Kori 		uint64_t fs_extract_param[MAX_TCS];
128fe2b986aSSunil Kumar Kori 	} extract;
129*6a556bd6SHemant Agrawal 	LIST_HEAD(, rte_flow) flows; /**< Configured flow rule handles. */
130c147eae0SHemant Agrawal };
13189c2ea8fSHemant Agrawal 
132fe2b986aSSunil Kumar Kori int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set,
133fe2b986aSSunil Kumar Kori 				      struct dpkg_profile_cfg *kg_cfg);
134fe2b986aSSunil Kumar Kori 
13589c2ea8fSHemant Agrawal int dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
136bd4d9419SHemant Agrawal 			  uint64_t req_dist_set);
13789c2ea8fSHemant Agrawal 
13889c2ea8fSHemant Agrawal int dpaa2_remove_flow_dist(struct rte_eth_dev *eth_dev,
13989c2ea8fSHemant Agrawal 			   uint8_t tc_index);
14089c2ea8fSHemant Agrawal 
141bee61d86SHemant Agrawal int dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv, void *blist);
142bee61d86SHemant Agrawal 
143b677d4c6SNipun Gupta int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,
144b677d4c6SNipun Gupta 		int eth_rx_queue_id,
145b677d4c6SNipun Gupta 		uint16_t dpcon_id,
146b677d4c6SNipun Gupta 		const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
147b677d4c6SNipun Gupta 
148b677d4c6SNipun Gupta int dpaa2_eth_eventq_detach(const struct rte_eth_dev *dev,
149b677d4c6SNipun Gupta 		int eth_rx_queue_id);
150b677d4c6SNipun Gupta 
151a3a997f0SHemant Agrawal uint16_t dpaa2_dev_loopback_rx(void *queue, struct rte_mbuf **bufs,
152a3a997f0SHemant Agrawal 				uint16_t nb_pkts);
153a3a997f0SHemant Agrawal 
1545c6942fdSHemant Agrawal uint16_t dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs,
1555c6942fdSHemant Agrawal 			       uint16_t nb_pkts);
156b677d4c6SNipun Gupta void dpaa2_dev_process_parallel_event(struct qbman_swp *swp,
157b677d4c6SNipun Gupta 				      const struct qbman_fd *fd,
158b677d4c6SNipun Gupta 				      const struct qbman_result *dq,
159b677d4c6SNipun Gupta 				      struct dpaa2_queue *rxq,
160b677d4c6SNipun Gupta 				      struct rte_event *ev);
1612d378863SNipun Gupta void dpaa2_dev_process_atomic_event(struct qbman_swp *swp,
1622d378863SNipun Gupta 				    const struct qbman_fd *fd,
1632d378863SNipun Gupta 				    const struct qbman_result *dq,
1642d378863SNipun Gupta 				    struct dpaa2_queue *rxq,
1652d378863SNipun Gupta 				    struct rte_event *ev);
16616c4a3c4SNipun Gupta void dpaa2_dev_process_ordered_event(struct qbman_swp *swp,
16716c4a3c4SNipun Gupta 				     const struct qbman_fd *fd,
16816c4a3c4SNipun Gupta 				     const struct qbman_result *dq,
16916c4a3c4SNipun Gupta 				     struct dpaa2_queue *rxq,
17016c4a3c4SNipun Gupta 				     struct rte_event *ev);
171cd9935ceSHemant Agrawal uint16_t dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);
17216c4a3c4SNipun Gupta uint16_t dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs,
17316c4a3c4SNipun Gupta 			      uint16_t nb_pkts);
174a1f3a12cSHemant Agrawal uint16_t dummy_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);
17516c4a3c4SNipun Gupta void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci);
176*6a556bd6SHemant Agrawal void dpaa2_flow_clean(struct rte_eth_dev *dev);
17716c4a3c4SNipun Gupta 
178c147eae0SHemant Agrawal #endif /* _DPAA2_ETHDEV_H */
179