Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2023 Intel Corporation 3 : : */ 4 : : 5 : : #ifndef _CPFL_RXTX_H_ 6 : : #define _CPFL_RXTX_H_ 7 : : 8 : : #include <idpf_common_rxtx.h> 9 : : #include "cpfl_ethdev.h" 10 : : 11 : : /* In QLEN must be whole number of 32 descriptors. */ 12 : : #define CPFL_ALIGN_RING_DESC 32 13 : : #define CPFL_MIN_RING_DESC 32 14 : : #define CPFL_MAX_RING_DESC 4096 15 : : #define CPFL_DMA_MEM_ALIGN 4096 16 : : 17 : : #define CPFL_MAX_HAIRPINQ_RX_2_TX 1 18 : : #define CPFL_MAX_HAIRPINQ_TX_2_RX 1 19 : : #define CPFL_MAX_HAIRPINQ_NB_DESC 1024 20 : : #define CPFL_MAX_P2P_NB_QUEUES 16 21 : : #define CPFL_P2P_NB_RX_BUFQ 1 22 : : #define CPFL_P2P_NB_TX_COMPLQ 1 23 : : #define CPFL_P2P_NB_QUEUE_GRPS 1 24 : : #define CPFL_P2P_QUEUE_GRP_ID 1 25 : : #define CPFL_P2P_DESC_LEN 16 26 : : #define CPFL_P2P_NB_MBUF 4096 27 : : #define CPFL_P2P_CACHE_SIZE 250 28 : : #define CPFL_P2P_MBUF_SIZE 2048 29 : : #define CPFL_P2P_RING_BUF 128 30 : : 31 : : /* Base address of the HW descriptor ring should be 128B aligned. */ 32 : : #define CPFL_RING_BASE_ALIGN 128 33 : : 34 : : #define CPFL_DEFAULT_RX_FREE_THRESH 32 35 : : #define CPFL_RXBUF_LOW_WATERMARK 64 36 : : 37 : : #define CPFL_DEFAULT_TX_RS_THRESH 32 38 : : #define CPFL_DEFAULT_TX_FREE_THRESH 32 39 : : 40 : : #define CPFL_SUPPORT_CHAIN_NUM 5 41 : : 42 : : #define CPFL_RX_BUF_STRIDE 64 43 : : 44 : : /* The value written in the RX buffer queue tail register, 45 : : * and in WritePTR field in the TX completion queue context, 46 : : * must be a multiple of 8. 47 : : */ 48 : : #define CPFL_HAIRPIN_Q_TAIL_AUX_VALUE 8 49 : : 50 : : struct virtchnl2_p2p_rx_buf_desc { 51 : : __le64 reserve0; 52 : : __le64 pkt_addr; /* Packet buffer address */ 53 : : }; 54 : : 55 : : struct cpfl_rxq_hairpin_info { 56 : : bool hairpin_q; /* if rx queue is a hairpin queue */ 57 : : uint16_t peer_txp; 58 : : uint16_t peer_txq_id; 59 : : }; 60 : : 61 : : struct cpfl_rx_queue { 62 : : struct idpf_rx_queue base; 63 : : struct cpfl_rxq_hairpin_info hairpin_info; 64 : : }; 65 : : 66 : : struct cpfl_txq_hairpin_info { 67 : : bool hairpin_q; /* if tx queue is a hairpin queue */ 68 : : uint16_t peer_rxp; 69 : : uint16_t peer_rxq_id; 70 : : }; 71 : : 72 : : struct cpfl_tx_queue { 73 : : struct idpf_tx_queue base; 74 : : struct cpfl_txq_hairpin_info hairpin_info; 75 : : }; 76 : : 77 : : static inline uint16_t 78 : : cpfl_hw_qid_get(uint16_t start_qid, uint16_t offset) 79 : : { 80 [ # # # # ]: 0 : return start_qid + offset; 81 : : } 82 : : 83 : : static inline uint64_t 84 : : cpfl_hw_qtail_get(uint64_t tail_start, uint16_t offset, uint64_t tail_spacing) 85 : : { 86 [ # # ]: 0 : return tail_start + offset * tail_spacing; 87 : : } 88 : : 89 : : int cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, 90 : : uint16_t nb_desc, unsigned int socket_id, 91 : : const struct rte_eth_txconf *tx_conf); 92 : : int cpfl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, 93 : : uint16_t nb_desc, unsigned int socket_id, 94 : : const struct rte_eth_rxconf *rx_conf, 95 : : struct rte_mempool *mp); 96 : : int cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id); 97 : : int cpfl_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); 98 : : int cpfl_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id); 99 : : int cpfl_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); 100 : : void cpfl_stop_queues(struct rte_eth_dev *dev); 101 : : int cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); 102 : : int cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); 103 : : void cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid); 104 : : void cpfl_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid); 105 : : void cpfl_set_rx_function(struct rte_eth_dev *dev); 106 : : void cpfl_set_tx_function(struct rte_eth_dev *dev); 107 : : int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, 108 : : uint16_t nb_desc, const struct rte_eth_hairpin_conf *conf); 109 : : int cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, 110 : : uint16_t nb_desc, 111 : : const struct rte_eth_hairpin_conf *conf); 112 : : int cpfl_hairpin_tx_complq_config(struct cpfl_vport *cpfl_vport); 113 : : int cpfl_hairpin_txq_config(struct idpf_vport *vport, struct cpfl_tx_queue *cpfl_txq); 114 : : int cpfl_hairpin_rx_bufq_config(struct cpfl_vport *cpfl_vport); 115 : : int cpfl_hairpin_rxq_config(struct idpf_vport *vport, struct cpfl_rx_queue *cpfl_rxq); 116 : : int cpfl_switch_hairpin_complq(struct cpfl_vport *cpfl_vport, bool on); 117 : : int cpfl_switch_hairpin_bufq(struct cpfl_vport *cpfl_vport, bool on); 118 : : int cpfl_switch_hairpin_rxtx_queue(struct cpfl_vport *cpfl_vport, uint16_t qid, 119 : : bool rx, bool on); 120 : : #endif /* _CPFL_RXTX_H_ */