1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2018-2022 Advanced Micro Devices, Inc. 3 */ 4 5 #ifndef _IONIC_RXTX_H_ 6 #define _IONIC_RXTX_H_ 7 8 #include <stdint.h> 9 10 #include "ionic_if.h" 11 12 struct ionic_rx_qcq; 13 struct ionic_tx_qcq; 14 struct rte_eth_dev; 15 struct rte_eth_rxconf; 16 struct rte_eth_rxq_info; 17 struct rte_eth_txconf; 18 struct rte_eth_txq_info; 19 struct rte_mbuf; 20 struct rte_mempool; 21 22 struct ionic_rx_service { 23 /* cb in */ 24 struct rte_mbuf **rx_pkts; 25 /* cb out */ 26 uint16_t nb_rx; 27 }; 28 29 #define IONIC_CSUM_FLAG_MASK (IONIC_RXQ_COMP_CSUM_F_VLAN - 1) 30 31 extern const uint64_t ionic_csum_flags[IONIC_CSUM_FLAG_MASK]; 32 extern const uint32_t ionic_ptype_table[IONIC_RXQ_COMP_PKT_TYPE_MASK]; 33 34 /* ionic_rxtx.c */ 35 int ionic_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, 36 uint16_t nb_desc, uint32_t socket_id, 37 const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp); 38 void ionic_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid); 39 int ionic_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); 40 int ionic_dev_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id); 41 42 int ionic_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, 43 uint16_t nb_desc, uint32_t socket_id, 44 const struct rte_eth_txconf *tx_conf); 45 void ionic_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid); 46 int ionic_dev_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id); 47 int ionic_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); 48 49 void ionic_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, 50 struct rte_eth_rxq_info *qinfo); 51 void ionic_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, 52 struct rte_eth_txq_info *qinfo); 53 54 int ionic_dev_rx_descriptor_status(void *rx_queue, uint16_t offset); 55 int ionic_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); 56 57 const uint32_t *ionic_dev_supported_ptypes_get(struct rte_eth_dev *dev, 58 size_t *no_of_elements); 59 60 int ionic_tx_tso(struct ionic_tx_qcq *txq, struct rte_mbuf *txm); 61 62 uint16_t ionic_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 63 uint16_t nb_pkts); 64 65 /* ionic_rxtx_simple.c */ 66 uint16_t ionic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 67 uint16_t nb_pkts); 68 uint16_t ionic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 69 uint16_t nb_pkts); 70 71 int ionic_rx_fill(struct ionic_rx_qcq *rxq); 72 73 /* ionic_rxtx_sg.c */ 74 uint16_t ionic_recv_pkts_sg(void *rx_queue, struct rte_mbuf **rx_pkts, 75 uint16_t nb_pkts); 76 uint16_t ionic_xmit_pkts_sg(void *tx_queue, struct rte_mbuf **tx_pkts, 77 uint16_t nb_pkts); 78 79 int ionic_rx_fill_sg(struct ionic_rx_qcq *rxq); 80 81 static inline void 82 ionic_rxq_flush(struct ionic_queue *q) 83 { 84 struct ionic_rxq_desc *desc_base = q->base; 85 struct ionic_rxq_desc *cmb_desc_base = q->cmb_base; 86 87 if (q->cmb_base) { 88 if (q->head_idx < q->cmb_head_idx) { 89 /* copy [cmb_head, num_descs) */ 90 rte_memcpy((void *)&cmb_desc_base[q->cmb_head_idx], 91 (void *)&desc_base[q->cmb_head_idx], 92 (q->num_descs - q->cmb_head_idx) * sizeof(*desc_base)); 93 /* copy [0, head) */ 94 rte_memcpy((void *)&cmb_desc_base[0], 95 (void *)&desc_base[0], 96 q->head_idx * sizeof(*desc_base)); 97 } else { 98 /* copy [cmb_head, head) */ 99 rte_memcpy((void *)&cmb_desc_base[q->cmb_head_idx], 100 (void *)&desc_base[q->cmb_head_idx], 101 (q->head_idx - q->cmb_head_idx) * sizeof(*desc_base)); 102 } 103 q->cmb_head_idx = q->head_idx; 104 } 105 106 ionic_q_flush(q); 107 } 108 109 static inline void 110 ionic_txq_flush(struct ionic_queue *q) 111 { 112 struct ionic_txq_desc *desc_base = q->base; 113 struct ionic_txq_desc *cmb_desc_base = q->cmb_base; 114 115 if (q->cmb_base) { 116 if (q->head_idx < q->cmb_head_idx) { 117 /* copy [cmb_head, num_descs) */ 118 rte_memcpy((void *)&cmb_desc_base[q->cmb_head_idx], 119 (void *)&desc_base[q->cmb_head_idx], 120 (q->num_descs - q->cmb_head_idx) * sizeof(*desc_base)); 121 /* copy [0, head) */ 122 rte_memcpy((void *)&cmb_desc_base[0], 123 (void *)&desc_base[0], 124 q->head_idx * sizeof(*desc_base)); 125 } else { 126 /* copy [cmb_head, head) */ 127 rte_memcpy((void *)&cmb_desc_base[q->cmb_head_idx], 128 (void *)&desc_base[q->cmb_head_idx], 129 (q->head_idx - q->cmb_head_idx) * sizeof(*desc_base)); 130 } 131 q->cmb_head_idx = q->head_idx; 132 } 133 134 ionic_q_flush(q); 135 } 136 137 #endif /* _IONIC_RXTX_H_ */ 138