xref: /dpdk/drivers/net/dpaa2/dpaa2_ethdev.h (revision 1dac0f3e)
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 ( \
57*1dac0f3eSHemant Agrawal 	ETH_RSS_L2_PAYLOAD | \
58762b275fSHemant Agrawal 	ETH_RSS_IP | \
59762b275fSHemant Agrawal 	ETH_RSS_UDP | \
60762b275fSHemant Agrawal 	ETH_RSS_TCP | \
61762b275fSHemant Agrawal 	ETH_RSS_SCTP)
62762b275fSHemant Agrawal 
63a5852a94SNipun Gupta /* LX2 FRC Parsed values (Little Endian) */
64a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_ETHER		0x0060
65a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4		0x0000
66a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6		0x0020
67a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_EXT \
68a5852a94SNipun Gupta 			(0x0001 | DPAA2_PKT_TYPE_IPV4)
69a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_EXT \
70a5852a94SNipun Gupta 			(0x0001 | DPAA2_PKT_TYPE_IPV6)
71a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_TCP \
72a5852a94SNipun Gupta 			(0x000e | DPAA2_PKT_TYPE_IPV4)
73a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_TCP \
74a5852a94SNipun Gupta 			(0x000e | DPAA2_PKT_TYPE_IPV6)
75a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_UDP \
76a5852a94SNipun Gupta 			(0x0010 | DPAA2_PKT_TYPE_IPV4)
77a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_UDP \
78a5852a94SNipun Gupta 			(0x0010 | DPAA2_PKT_TYPE_IPV6)
79a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_SCTP	\
80a5852a94SNipun Gupta 			(0x000f | DPAA2_PKT_TYPE_IPV4)
81a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_SCTP	\
82a5852a94SNipun Gupta 			(0x000f | DPAA2_PKT_TYPE_IPV6)
83a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV4_ICMP \
84a5852a94SNipun Gupta 			(0x0003 | DPAA2_PKT_TYPE_IPV4_EXT)
85a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_IPV6_ICMP \
86a5852a94SNipun Gupta 			(0x0003 | DPAA2_PKT_TYPE_IPV6_EXT)
87a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_VLAN_1		0x0160
88a5852a94SNipun Gupta #define DPAA2_PKT_TYPE_VLAN_2		0x0260
89a5852a94SNipun Gupta 
90c1870f65SAkhil Goyal /* enable timestamp in mbuf*/
91c1870f65SAkhil Goyal extern enum pmd_dpaa2_ts dpaa2_enable_ts;
92c1870f65SAkhil Goyal 
93fe2b986aSSunil Kumar Kori #define DPAA2_QOS_TABLE_RECONFIGURE	1
94fe2b986aSSunil Kumar Kori #define DPAA2_FS_TABLE_RECONFIGURE	2
95fe2b986aSSunil Kumar Kori 
96fe2b986aSSunil Kumar Kori /*Externaly defined*/
97fe2b986aSSunil Kumar Kori extern const struct rte_flow_ops dpaa2_flow_ops;
98fe2b986aSSunil Kumar Kori extern enum rte_filter_type dpaa2_filter_type;
99fe2b986aSSunil Kumar Kori 
100c147eae0SHemant Agrawal struct dpaa2_dev_priv {
101c147eae0SHemant Agrawal 	void *hw;
102c147eae0SHemant Agrawal 	int32_t hw_id;
1033e5a335dSHemant Agrawal 	int32_t qdid;
104c147eae0SHemant Agrawal 	uint16_t token;
1053e5a335dSHemant Agrawal 	uint8_t nb_tx_queues;
1063e5a335dSHemant Agrawal 	uint8_t nb_rx_queues;
10716c4a3c4SNipun Gupta 	uint32_t options;
1083e5a335dSHemant Agrawal 	void *rx_vq[MAX_RX_QUEUES];
1093e5a335dSHemant Agrawal 	void *tx_vq[MAX_TX_QUEUES];
110c147eae0SHemant Agrawal 
111bee61d86SHemant Agrawal 	struct dpaa2_bp_list *bp_list; /**<Attached buffer pool list */
11233fad432SHemant Agrawal 	uint8_t max_mac_filters;
11333fad432SHemant Agrawal 	uint8_t max_vlan_filters;
11416bbc98aSShreyansh Jain 	uint8_t num_rx_tc;
115c147eae0SHemant Agrawal 	uint8_t flags; /*dpaa2 config flags */
11616c4a3c4SNipun Gupta 	uint8_t en_ordered;
11716c4a3c4SNipun Gupta 	uint8_t en_loose_ordered;
118fe2b986aSSunil Kumar Kori 
119fe2b986aSSunil Kumar Kori 	struct pattern_s {
120fe2b986aSSunil Kumar Kori 		uint8_t item_count;
121fe2b986aSSunil Kumar Kori 		uint8_t pattern_type[DPKG_MAX_NUM_OF_EXTRACTS];
122fe2b986aSSunil Kumar Kori 	} pattern[MAX_TCS + 1];
123fe2b986aSSunil Kumar Kori 
124fe2b986aSSunil Kumar Kori 	struct extract_s {
125fe2b986aSSunil Kumar Kori 		struct dpkg_profile_cfg qos_key_cfg;
126fe2b986aSSunil Kumar Kori 		struct dpkg_profile_cfg fs_key_cfg[MAX_TCS];
127fe2b986aSSunil Kumar Kori 		uint64_t qos_extract_param;
128fe2b986aSSunil Kumar Kori 		uint64_t fs_extract_param[MAX_TCS];
129fe2b986aSSunil Kumar Kori 	} extract;
1306a556bd6SHemant Agrawal 	LIST_HEAD(, rte_flow) flows; /**< Configured flow rule handles. */
131c147eae0SHemant Agrawal };
13289c2ea8fSHemant Agrawal 
133fe2b986aSSunil Kumar Kori int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set,
134fe2b986aSSunil Kumar Kori 				      struct dpkg_profile_cfg *kg_cfg);
135fe2b986aSSunil Kumar Kori 
13689c2ea8fSHemant Agrawal int dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
137bd4d9419SHemant Agrawal 			  uint64_t req_dist_set);
13889c2ea8fSHemant Agrawal 
13989c2ea8fSHemant Agrawal int dpaa2_remove_flow_dist(struct rte_eth_dev *eth_dev,
14089c2ea8fSHemant Agrawal 			   uint8_t tc_index);
14189c2ea8fSHemant Agrawal 
142bee61d86SHemant Agrawal int dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv, void *blist);
143bee61d86SHemant Agrawal 
144b677d4c6SNipun Gupta int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,
145b677d4c6SNipun Gupta 		int eth_rx_queue_id,
146b677d4c6SNipun Gupta 		uint16_t dpcon_id,
147b677d4c6SNipun Gupta 		const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
148b677d4c6SNipun Gupta 
149b677d4c6SNipun Gupta int dpaa2_eth_eventq_detach(const struct rte_eth_dev *dev,
150b677d4c6SNipun Gupta 		int eth_rx_queue_id);
151b677d4c6SNipun Gupta 
152a3a997f0SHemant Agrawal uint16_t dpaa2_dev_loopback_rx(void *queue, struct rte_mbuf **bufs,
153a3a997f0SHemant Agrawal 				uint16_t nb_pkts);
154a3a997f0SHemant Agrawal 
1555c6942fdSHemant Agrawal uint16_t dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs,
1565c6942fdSHemant Agrawal 			       uint16_t nb_pkts);
157b677d4c6SNipun Gupta void dpaa2_dev_process_parallel_event(struct qbman_swp *swp,
158b677d4c6SNipun Gupta 				      const struct qbman_fd *fd,
159b677d4c6SNipun Gupta 				      const struct qbman_result *dq,
160b677d4c6SNipun Gupta 				      struct dpaa2_queue *rxq,
161b677d4c6SNipun Gupta 				      struct rte_event *ev);
1622d378863SNipun Gupta void dpaa2_dev_process_atomic_event(struct qbman_swp *swp,
1632d378863SNipun Gupta 				    const struct qbman_fd *fd,
1642d378863SNipun Gupta 				    const struct qbman_result *dq,
1652d378863SNipun Gupta 				    struct dpaa2_queue *rxq,
1662d378863SNipun Gupta 				    struct rte_event *ev);
16716c4a3c4SNipun Gupta void dpaa2_dev_process_ordered_event(struct qbman_swp *swp,
16816c4a3c4SNipun Gupta 				     const struct qbman_fd *fd,
16916c4a3c4SNipun Gupta 				     const struct qbman_result *dq,
17016c4a3c4SNipun Gupta 				     struct dpaa2_queue *rxq,
17116c4a3c4SNipun Gupta 				     struct rte_event *ev);
172cd9935ceSHemant Agrawal uint16_t dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);
17316c4a3c4SNipun Gupta uint16_t dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs,
17416c4a3c4SNipun Gupta 			      uint16_t nb_pkts);
175a1f3a12cSHemant Agrawal uint16_t dummy_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);
17616c4a3c4SNipun Gupta void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci);
1776a556bd6SHemant Agrawal void dpaa2_flow_clean(struct rte_eth_dev *dev);
17816c4a3c4SNipun Gupta 
179c147eae0SHemant Agrawal #endif /* _DPAA2_ETHDEV_H */
180