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 uintptr_t p; 34 struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */ 35 36 mb_def.nb_segs = 1; 37 mb_def.data_off = RTE_PKTMBUF_HEADROOM; 38 mb_def.port = rxq->port_id; 39 rte_mbuf_refcnt_set(&mb_def, 1); 40 41 /* prevent compiler reordering: rearm_data covers previous fields */ 42 rte_compiler_barrier(); 43 p = (uintptr_t)&mb_def.rearm_data; 44 rxq->mbuf_initializer = *(uint64_t *)p; 45 46 return 0; 47 } 48 49 /* Stub for linkage when arch specific implementation is not available */ 50 __rte_weak uint16_t 51 virtio_recv_pkts_vec(void *rx_queue __rte_unused, 52 struct rte_mbuf **rx_pkts __rte_unused, 53 uint16_t nb_pkts __rte_unused) 54 { 55 rte_panic("Wrong weak function linked by linker\n"); 56 return 0; 57 } 58