virtio_rxtx.h revision 8b25d1ad
1/*-
2 *   BSD LICENSE
3 *
4 *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
5 *   All rights reserved.
6 *
7 *   Redistribution and use in source and binary forms, with or without
8 *   modification, are permitted provided that the following conditions
9 *   are met:
10 *
11 *     * Redistributions of source code must retain the above copyright
12 *       notice, this list of conditions and the following disclaimer.
13 *     * Redistributions in binary form must reproduce the above copyright
14 *       notice, this list of conditions and the following disclaimer in
15 *       the documentation and/or other materials provided with the
16 *       distribution.
17 *     * Neither the name of Intel Corporation nor the names of its
18 *       contributors may be used to endorse or promote products derived
19 *       from this software without specific prior written permission.
20 *
21 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _VIRTIO_RXTX_H_
35#define _VIRTIO_RXTX_H_
36
37#define RTE_PMD_VIRTIO_RX_MAX_BURST 64
38
39struct virtnet_stats {
40	uint64_t	packets;
41	uint64_t	bytes;
42	uint64_t	errors;
43	uint64_t	multicast;
44	uint64_t	broadcast;
45	/* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */
46	uint64_t	size_bins[8];
47};
48
49struct virtnet_rx {
50	struct virtqueue *vq;
51	/* dummy mbuf, for wraparound when processing RX ring. */
52	struct rte_mbuf fake_mbuf;
53	uint64_t mbuf_initializer; /**< value to init mbufs. */
54	struct rte_mempool *mpool; /**< mempool for mbuf allocation */
55
56	uint16_t queue_id;   /**< DPDK queue index. */
57	uint8_t port_id;     /**< Device port identifier. */
58
59	/* Statistics */
60	struct virtnet_stats stats;
61
62	const struct rte_memzone *mz; /**< mem zone to populate RX ring. */
63};
64
65struct virtnet_tx {
66	struct virtqueue *vq;
67	/**< memzone to populate hdr. */
68	const struct rte_memzone *virtio_net_hdr_mz;
69	phys_addr_t virtio_net_hdr_mem;  /**< hdr for each xmit packet */
70
71	uint16_t    queue_id;            /**< DPDK queue index. */
72	uint8_t     port_id;             /**< Device port identifier. */
73
74	/* Statistics */
75	struct virtnet_stats stats;
76
77	const struct rte_memzone *mz;    /**< mem zone to populate TX ring. */
78};
79
80struct virtnet_ctl {
81	struct virtqueue *vq;
82	/**< memzone to populate hdr. */
83	const struct rte_memzone *virtio_net_hdr_mz;
84	phys_addr_t virtio_net_hdr_mem; /**< hdr for each xmit packet */
85	uint8_t port_id;                /**< Device port identifier. */
86	const struct rte_memzone *mz;   /**< mem zone to populate RX ring. */
87};
88
89#ifdef RTE_MACHINE_CPUFLAG_SSSE3
90int virtio_rxq_vec_setup(struct virtnet_rx *rxvq);
91
92int virtqueue_enqueue_recv_refill_simple(struct virtqueue *vq,
93	struct rte_mbuf *m);
94#endif
95#endif /* _VIRTIO_RXTX_H_ */
96