197f17497SC.J. Collier/*-
297f17497SC.J. Collier *   BSD LICENSE
397f17497SC.J. Collier *
497f17497SC.J. Collier *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
597f17497SC.J. Collier *   All rights reserved.
697f17497SC.J. Collier *
797f17497SC.J. Collier *   Redistribution and use in source and binary forms, with or without
897f17497SC.J. Collier *   modification, are permitted provided that the following conditions
997f17497SC.J. Collier *   are met:
1097f17497SC.J. Collier *
1197f17497SC.J. Collier *     * Redistributions of source code must retain the above copyright
1297f17497SC.J. Collier *       notice, this list of conditions and the following disclaimer.
1397f17497SC.J. Collier *     * Redistributions in binary form must reproduce the above copyright
1497f17497SC.J. Collier *       notice, this list of conditions and the following disclaimer in
1597f17497SC.J. Collier *       the documentation and/or other materials provided with the
1697f17497SC.J. Collier *       distribution.
1797f17497SC.J. Collier *     * Neither the name of Intel Corporation nor the names of its
1897f17497SC.J. Collier *       contributors may be used to endorse or promote products derived
1997f17497SC.J. Collier *       from this software without specific prior written permission.
2097f17497SC.J. Collier *
2197f17497SC.J. Collier *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2297f17497SC.J. Collier *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2397f17497SC.J. Collier *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2497f17497SC.J. Collier *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2597f17497SC.J. Collier *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2697f17497SC.J. Collier *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2797f17497SC.J. Collier *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2897f17497SC.J. Collier *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2997f17497SC.J. Collier *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3097f17497SC.J. Collier *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3197f17497SC.J. Collier *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3297f17497SC.J. Collier */
3397f17497SC.J. Collier
348b25d1adSChristian Ehrhardt#ifndef _VIRTIO_RXTX_H_
358b25d1adSChristian Ehrhardt#define _VIRTIO_RXTX_H_
368b25d1adSChristian Ehrhardt
3797f17497SC.J. Collier#define RTE_PMD_VIRTIO_RX_MAX_BURST 64
3897f17497SC.J. Collier
398b25d1adSChristian Ehrhardtstruct virtnet_stats {
408b25d1adSChristian Ehrhardt	uint64_t	packets;
418b25d1adSChristian Ehrhardt	uint64_t	bytes;
428b25d1adSChristian Ehrhardt	uint64_t	errors;
438b25d1adSChristian Ehrhardt	uint64_t	multicast;
448b25d1adSChristian Ehrhardt	uint64_t	broadcast;
458b25d1adSChristian Ehrhardt	/* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */
468b25d1adSChristian Ehrhardt	uint64_t	size_bins[8];
478b25d1adSChristian Ehrhardt};
488b25d1adSChristian Ehrhardt
498b25d1adSChristian Ehrhardtstruct virtnet_rx {
508b25d1adSChristian Ehrhardt	struct virtqueue *vq;
518b25d1adSChristian Ehrhardt	/* dummy mbuf, for wraparound when processing RX ring. */
528b25d1adSChristian Ehrhardt	struct rte_mbuf fake_mbuf;
538b25d1adSChristian Ehrhardt	uint64_t mbuf_initializer; /**< value to init mbufs. */
548b25d1adSChristian Ehrhardt	struct rte_mempool *mpool; /**< mempool for mbuf allocation */
558b25d1adSChristian Ehrhardt
568b25d1adSChristian Ehrhardt	uint16_t queue_id;   /**< DPDK queue index. */
578b25d1adSChristian Ehrhardt	uint8_t port_id;     /**< Device port identifier. */
588b25d1adSChristian Ehrhardt
598b25d1adSChristian Ehrhardt	/* Statistics */
608b25d1adSChristian Ehrhardt	struct virtnet_stats stats;
618b25d1adSChristian Ehrhardt
628b25d1adSChristian Ehrhardt	const struct rte_memzone *mz; /**< mem zone to populate RX ring. */
638b25d1adSChristian Ehrhardt};
648b25d1adSChristian Ehrhardt
658b25d1adSChristian Ehrhardtstruct virtnet_tx {
668b25d1adSChristian Ehrhardt	struct virtqueue *vq;
678b25d1adSChristian Ehrhardt	/**< memzone to populate hdr. */
688b25d1adSChristian Ehrhardt	const struct rte_memzone *virtio_net_hdr_mz;
698b25d1adSChristian Ehrhardt	phys_addr_t virtio_net_hdr_mem;  /**< hdr for each xmit packet */
708b25d1adSChristian Ehrhardt
718b25d1adSChristian Ehrhardt	uint16_t    queue_id;            /**< DPDK queue index. */
728b25d1adSChristian Ehrhardt	uint8_t     port_id;             /**< Device port identifier. */
738b25d1adSChristian Ehrhardt
748b25d1adSChristian Ehrhardt	/* Statistics */
758b25d1adSChristian Ehrhardt	struct virtnet_stats stats;
768b25d1adSChristian Ehrhardt
778b25d1adSChristian Ehrhardt	const struct rte_memzone *mz;    /**< mem zone to populate TX ring. */
788b25d1adSChristian Ehrhardt};
798b25d1adSChristian Ehrhardt
808b25d1adSChristian Ehrhardtstruct virtnet_ctl {
818b25d1adSChristian Ehrhardt	struct virtqueue *vq;
828b25d1adSChristian Ehrhardt	/**< memzone to populate hdr. */
838b25d1adSChristian Ehrhardt	const struct rte_memzone *virtio_net_hdr_mz;
848b25d1adSChristian Ehrhardt	phys_addr_t virtio_net_hdr_mem; /**< hdr for each xmit packet */
858b25d1adSChristian Ehrhardt	uint8_t port_id;                /**< Device port identifier. */
868b25d1adSChristian Ehrhardt	const struct rte_memzone *mz;   /**< mem zone to populate RX ring. */
878b25d1adSChristian Ehrhardt};
888b25d1adSChristian Ehrhardt
898b25d1adSChristian Ehrhardtint virtio_rxq_vec_setup(struct virtnet_rx *rxvq);
9097f17497SC.J. Collier
918b25d1adSChristian Ehrhardt#endif /* _VIRTIO_RXTX_H_ */
92