Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (c) 2023 Arm Limited. 3 : : */ 4 : : 5 : : #include "testpmd.h" 6 : : 7 : : /* 8 : : * Forwarding of packets in I/O mode. 9 : : * Enable mbufs recycle mode to recycle txq used mbufs 10 : : * for rxq mbuf ring. This can bypass mempool path and 11 : : * save CPU cycles. 12 : : */ 13 : : static bool 14 : 0 : pkt_burst_recycle_mbufs(struct fwd_stream *fs) 15 : : { 16 : : struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; 17 : : uint16_t nb_rx; 18 : : 19 : : /* Recycle used mbufs from the txq, and move these mbufs into 20 : : * the rxq mbuf ring. 21 : : */ 22 : 0 : rte_eth_recycle_mbufs(fs->rx_port, fs->rx_queue, 23 : 0 : fs->tx_port, fs->tx_queue, &(fs->recycle_rxq_info)); 24 : : 25 : : /* 26 : : * Receive a burst of packets and forward them. 27 : : */ 28 : 0 : nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); 29 : 0 : if (unlikely(nb_rx == 0)) 30 : : return false; 31 : : 32 : 0 : common_fwd_stream_transmit(fs, pkts_burst, nb_rx); 33 : : 34 : 0 : return true; 35 : : } 36 : : 37 : : static void 38 : 0 : recycle_mbufs_stream_init(struct fwd_stream *fs) 39 : : { 40 : : int rc; 41 : : 42 : : /* Retrieve information about given ports's Rx queue 43 : : * for recycling mbufs. 44 : : */ 45 : 0 : rc = rte_eth_recycle_rx_queue_info_get(fs->rx_port, 46 : 0 : fs->rx_queue, &(fs->recycle_rxq_info)); 47 : 0 : if (rc != 0) 48 : 0 : TESTPMD_LOG(WARNING, 49 : : "Failed to get rx queue mbufs recycle info\n"); 50 : : 51 : 0 : common_fwd_stream_init(fs); 52 : 0 : } 53 : : 54 : : struct fwd_engine recycle_mbufs_engine = { 55 : : .fwd_mode_name = "recycle_mbufs", 56 : : .stream_init = recycle_mbufs_stream_init, 57 : : .packet_fwd = pkt_burst_recycle_mbufs, 58 : : };