xref: /dpdk/drivers/net/virtio/virtio_rxtx_simple.c (revision 665b49c51639a10c553433bc2bcd85c7331c631e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation
3  */
4 
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <errno.h>
10 
11 #include <rte_cycles.h>
12 #include <rte_memory.h>
13 #include <rte_branch_prediction.h>
14 #include <rte_mempool.h>
15 #include <rte_malloc.h>
16 #include <rte_mbuf.h>
17 #include <rte_ether.h>
18 #include <ethdev_driver.h>
19 #include <rte_prefetch.h>
20 #include <rte_string_fns.h>
21 #include <rte_errno.h>
22 #include <rte_byteorder.h>
23 
24 #include "virtio_rxtx_simple.h"
25 
26 #ifndef __INTEL_COMPILER
27 #pragma GCC diagnostic ignored "-Wcast-qual"
28 #endif
29 
30 int __rte_cold
31 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
32 {
33 	struct virtqueue *vq = virtnet_rxq_to_vq(rxq);
34 	uintptr_t p;
35 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
36 
37 	mb_def.nb_segs = 1;
38 	mb_def.data_off = RTE_PKTMBUF_HEADROOM;
39 	mb_def.port = vq->hw->port_id;
40 	rte_mbuf_refcnt_set(&mb_def, 1);
41 
42 	/* prevent compiler reordering: rearm_data covers previous fields */
43 	rte_compiler_barrier();
44 	p = (uintptr_t)&mb_def.rearm_data;
45 	rxq->mbuf_initializer = *(uint64_t *)p;
46 
47 	return 0;
48 }
49 
50 /* Stub for linkage when arch specific implementation is not available */
51 __rte_weak uint16_t
52 virtio_recv_pkts_vec(void *rx_queue __rte_unused,
53 		     struct rte_mbuf **rx_pkts __rte_unused,
54 		     uint16_t nb_pkts __rte_unused)
55 {
56 	rte_panic("Wrong weak function linked by linker\n");
57 	return 0;
58 }
59