Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2010-2016 Intel Corporation 3 : : */ 4 : : 5 : : #ifndef _VIRTIO_RXTX_SIMPLE_H_ 6 : : #define _VIRTIO_RXTX_SIMPLE_H_ 7 : : 8 : : #include <stdint.h> 9 : : 10 : : #include "virtio_logs.h" 11 : : #include "virtio_ethdev.h" 12 : : #include "virtqueue.h" 13 : : #include "virtio_rxtx.h" 14 : : 15 : : #define RTE_VIRTIO_VPMD_RX_BURST 32 16 : : #define RTE_VIRTIO_VPMD_RX_REARM_THRESH RTE_VIRTIO_VPMD_RX_BURST 17 : : 18 : : static inline void 19 : 0 : virtio_rxq_rearm_vec(struct virtnet_rx *rxvq) 20 : : { 21 : : int i; 22 : : uint16_t desc_idx; 23 : : struct rte_mbuf **sw_ring; 24 : : struct vring_desc *start_dp; 25 : : int ret; 26 : 0 : struct virtqueue *vq = virtnet_rxq_to_vq(rxvq); 27 : : 28 : 0 : desc_idx = vq->vq_avail_idx & (vq->vq_nentries - 1); 29 : 0 : sw_ring = &vq->rxq.sw_ring[desc_idx]; 30 : 0 : start_dp = &vq->vq_split.ring.desc[desc_idx]; 31 : : 32 [ # # ]: 0 : ret = rte_mempool_get_bulk(rxvq->mpool, (void **)sw_ring, 33 : : RTE_VIRTIO_VPMD_RX_REARM_THRESH); 34 [ # # ]: 0 : if (unlikely(ret)) { 35 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[vq->hw->port_id]; 36 : : 37 : 0 : dev->data->rx_mbuf_alloc_failed += RTE_VIRTIO_VPMD_RX_REARM_THRESH; 38 : 0 : return; 39 : : } 40 : : 41 [ # # ]: 0 : for (i = 0; i < RTE_VIRTIO_VPMD_RX_REARM_THRESH; i++) { 42 : : uintptr_t p; 43 : : 44 : 0 : p = (uintptr_t)&sw_ring[i]->rearm_data; 45 : 0 : *(uint64_t *)p = rxvq->mbuf_initializer; 46 : : 47 : 0 : start_dp[i].addr = VIRTIO_MBUF_ADDR(sw_ring[i], vq) + 48 : 0 : RTE_PKTMBUF_HEADROOM - vq->hw->vtnet_hdr_size; 49 : 0 : start_dp[i].len = sw_ring[i]->buf_len - 50 : 0 : RTE_PKTMBUF_HEADROOM + vq->hw->vtnet_hdr_size; 51 : : } 52 : : 53 : 0 : vq->vq_avail_idx += RTE_VIRTIO_VPMD_RX_REARM_THRESH; 54 [ # # ]: 0 : vq->vq_free_cnt -= RTE_VIRTIO_VPMD_RX_REARM_THRESH; 55 : : vq_update_avail_idx(vq); 56 : : } 57 : : 58 : : #endif /* _VIRTIO_RXTX_SIMPLE_H_ */