]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
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 | 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 | struct virtqueue *vq = rxvq->vq; | |
27 | ||
28 | desc_idx = vq->vq_avail_idx & (vq->vq_nentries - 1); | |
29 | sw_ring = &vq->sw_ring[desc_idx]; | |
9f95a23c | 30 | start_dp = &vq->vq_split.ring.desc[desc_idx]; |
11fdf7f2 TL |
31 | |
32 | ret = rte_mempool_get_bulk(rxvq->mpool, (void **)sw_ring, | |
33 | RTE_VIRTIO_VPMD_RX_REARM_THRESH); | |
34 | if (unlikely(ret)) { | |
35 | rte_eth_devices[rxvq->port_id].data->rx_mbuf_alloc_failed += | |
36 | RTE_VIRTIO_VPMD_RX_REARM_THRESH; | |
37 | return; | |
38 | } | |
39 | ||
40 | for (i = 0; i < RTE_VIRTIO_VPMD_RX_REARM_THRESH; i++) { | |
41 | uintptr_t p; | |
42 | ||
43 | p = (uintptr_t)&sw_ring[i]->rearm_data; | |
44 | *(uint64_t *)p = rxvq->mbuf_initializer; | |
45 | ||
46 | start_dp[i].addr = | |
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; | |
51 | } | |
52 | ||
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); | |
56 | } | |
57 | ||
58 | #endif /* _VIRTIO_RXTX_SIMPLE_H_ */ |