1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
5 #ifndef _VIRTIO_RXTX_SIMPLE_H_
6 #define _VIRTIO_RXTX_SIMPLE_H_
10 #include "virtio_logs.h"
11 #include "virtio_ethdev.h"
12 #include "virtqueue.h"
13 #include "virtio_rxtx.h"
15 #define RTE_VIRTIO_VPMD_RX_BURST 32
16 #define RTE_VIRTIO_VPMD_RX_REARM_THRESH RTE_VIRTIO_VPMD_RX_BURST
19 virtio_rxq_rearm_vec(struct virtnet_rx
*rxvq
)
23 struct rte_mbuf
**sw_ring
;
24 struct vring_desc
*start_dp
;
26 struct virtqueue
*vq
= rxvq
->vq
;
28 desc_idx
= vq
->vq_avail_idx
& (vq
->vq_nentries
- 1);
29 sw_ring
= &vq
->sw_ring
[desc_idx
];
30 start_dp
= &vq
->vq_split
.ring
.desc
[desc_idx
];
32 ret
= rte_mempool_get_bulk(rxvq
->mpool
, (void **)sw_ring
,
33 RTE_VIRTIO_VPMD_RX_REARM_THRESH
);
35 rte_eth_devices
[rxvq
->port_id
].data
->rx_mbuf_alloc_failed
+=
36 RTE_VIRTIO_VPMD_RX_REARM_THRESH
;
40 for (i
= 0; i
< RTE_VIRTIO_VPMD_RX_REARM_THRESH
; i
++) {
43 p
= (uintptr_t)&sw_ring
[i
]->rearm_data
;
44 *(uint64_t *)p
= rxvq
->mbuf_initializer
;
47 VIRTIO_MBUF_ADDR(sw_ring
[i
], vq
) +
48 RTE_PKTMBUF_HEADROOM
- vq
->hw
->vtnet_hdr_size
;
49 start_dp
[i
].len
= sw_ring
[i
]->buf_len
-
50 RTE_PKTMBUF_HEADROOM
+ vq
->hw
->vtnet_hdr_size
;
53 vq
->vq_avail_idx
+= RTE_VIRTIO_VPMD_RX_REARM_THRESH
;
54 vq
->vq_free_cnt
-= RTE_VIRTIO_VPMD_RX_REARM_THRESH
;
55 vq_update_avail_idx(vq
);
58 #endif /* _VIRTIO_RXTX_SIMPLE_H_ */