16c3169a3SBruce Richardson /*- 26c3169a3SBruce Richardson * BSD LICENSE 36c3169a3SBruce Richardson * 45382b188SBernard Iremonger * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. 56c3169a3SBruce Richardson * All rights reserved. 66c3169a3SBruce Richardson * 76c3169a3SBruce Richardson * Redistribution and use in source and binary forms, with or without 86c3169a3SBruce Richardson * modification, are permitted provided that the following conditions 96c3169a3SBruce Richardson * are met: 106c3169a3SBruce Richardson * 116c3169a3SBruce Richardson * * Redistributions of source code must retain the above copyright 126c3169a3SBruce Richardson * notice, this list of conditions and the following disclaimer. 136c3169a3SBruce Richardson * * Redistributions in binary form must reproduce the above copyright 146c3169a3SBruce Richardson * notice, this list of conditions and the following disclaimer in 156c3169a3SBruce Richardson * the documentation and/or other materials provided with the 166c3169a3SBruce Richardson * distribution. 176c3169a3SBruce Richardson * * Neither the name of Intel Corporation nor the names of its 186c3169a3SBruce Richardson * contributors may be used to endorse or promote products derived 196c3169a3SBruce Richardson * from this software without specific prior written permission. 206c3169a3SBruce Richardson * 216c3169a3SBruce Richardson * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 226c3169a3SBruce Richardson * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 236c3169a3SBruce Richardson * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 246c3169a3SBruce Richardson * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 256c3169a3SBruce Richardson * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 266c3169a3SBruce Richardson * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 276c3169a3SBruce Richardson * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 286c3169a3SBruce Richardson * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 296c3169a3SBruce Richardson * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 306c3169a3SBruce Richardson * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 316c3169a3SBruce Richardson * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 326c3169a3SBruce Richardson */ 336c3169a3SBruce Richardson 346c3169a3SBruce Richardson #ifndef _VIRTIO_ETHDEV_H_ 356c3169a3SBruce Richardson #define _VIRTIO_ETHDEV_H_ 366c3169a3SBruce Richardson 376c3169a3SBruce Richardson #include <stdint.h> 386c3169a3SBruce Richardson 396c3169a3SBruce Richardson #include "virtio_pci.h" 406c3169a3SBruce Richardson 416c3169a3SBruce Richardson #define SPEED_10 10 426c3169a3SBruce Richardson #define SPEED_100 100 436c3169a3SBruce Richardson #define SPEED_1000 1000 446c3169a3SBruce Richardson #define SPEED_10G 10000 456c3169a3SBruce Richardson 466c3169a3SBruce Richardson #ifndef PAGE_SIZE 476c3169a3SBruce Richardson #define PAGE_SIZE 4096 486c3169a3SBruce Richardson #endif 496c3169a3SBruce Richardson 506c3169a3SBruce Richardson #define VIRTIO_MAX_RX_QUEUES 128 516c3169a3SBruce Richardson #define VIRTIO_MAX_TX_QUEUES 128 526c3169a3SBruce Richardson #define VIRTIO_MAX_MAC_ADDRS 64 536c3169a3SBruce Richardson #define VIRTIO_MIN_RX_BUFSIZE 64 546c3169a3SBruce Richardson #define VIRTIO_MAX_RX_PKTLEN 9728 556c3169a3SBruce Richardson 566c3169a3SBruce Richardson /* Features desired/implemented by this driver. */ 574a92b671SStephen Hemminger #define VIRTIO_PMD_GUEST_FEATURES \ 584a92b671SStephen Hemminger (1u << VIRTIO_NET_F_MAC | \ 594a92b671SStephen Hemminger 1u << VIRTIO_NET_F_STATUS | \ 604a92b671SStephen Hemminger 1u << VIRTIO_NET_F_MQ | \ 614a92b671SStephen Hemminger 1u << VIRTIO_NET_F_CTRL_MAC_ADDR | \ 624a92b671SStephen Hemminger 1u << VIRTIO_NET_F_CTRL_VQ | \ 634a92b671SStephen Hemminger 1u << VIRTIO_NET_F_CTRL_RX | \ 644a92b671SStephen Hemminger 1u << VIRTIO_NET_F_CTRL_VLAN | \ 656ba1f63bSYuanhan Liu 1u << VIRTIO_NET_F_MRG_RXBUF | \ 666ba1f63bSYuanhan Liu 1ULL << VIRTIO_F_VERSION_1) 676c3169a3SBruce Richardson 686c3169a3SBruce Richardson /* 696c3169a3SBruce Richardson * CQ function prototype 706c3169a3SBruce Richardson */ 716c3169a3SBruce Richardson void virtio_dev_cq_start(struct rte_eth_dev *dev); 726c3169a3SBruce Richardson 736c3169a3SBruce Richardson /* 746c3169a3SBruce Richardson * RX/TX function prototypes 756c3169a3SBruce Richardson */ 766c3169a3SBruce Richardson void virtio_dev_rxtx_start(struct rte_eth_dev *dev); 776c3169a3SBruce Richardson 786c3169a3SBruce Richardson int virtio_dev_queue_setup(struct rte_eth_dev *dev, 796c3169a3SBruce Richardson int queue_type, 806c3169a3SBruce Richardson uint16_t queue_idx, 816c3169a3SBruce Richardson uint16_t vtpci_queue_idx, 826c3169a3SBruce Richardson uint16_t nb_desc, 836c3169a3SBruce Richardson unsigned int socket_id, 84*01ad44fdSHuawei Xie void **pvq); 856c3169a3SBruce Richardson 865382b188SBernard Iremonger void virtio_dev_queue_release(struct virtqueue *vq); 875382b188SBernard Iremonger 886c3169a3SBruce Richardson int virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, 896c3169a3SBruce Richardson uint16_t nb_rx_desc, unsigned int socket_id, 906c3169a3SBruce Richardson const struct rte_eth_rxconf *rx_conf, 916c3169a3SBruce Richardson struct rte_mempool *mb_pool); 926c3169a3SBruce Richardson 935382b188SBernard Iremonger void virtio_dev_rx_queue_release(void *rxq); 945382b188SBernard Iremonger 956c3169a3SBruce Richardson int virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, 966c3169a3SBruce Richardson uint16_t nb_tx_desc, unsigned int socket_id, 976c3169a3SBruce Richardson const struct rte_eth_txconf *tx_conf); 986c3169a3SBruce Richardson 995382b188SBernard Iremonger void virtio_dev_tx_queue_release(void *txq); 1005382b188SBernard Iremonger 1016c3169a3SBruce Richardson uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 1026c3169a3SBruce Richardson uint16_t nb_pkts); 1036c3169a3SBruce Richardson 1046c3169a3SBruce Richardson uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 1056c3169a3SBruce Richardson uint16_t nb_pkts); 1066c3169a3SBruce Richardson 1076c3169a3SBruce Richardson uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 1086c3169a3SBruce Richardson uint16_t nb_pkts); 1096c3169a3SBruce Richardson 110fc3d6621SHuawei Xie uint16_t virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, 111fc3d6621SHuawei Xie uint16_t nb_pkts); 1126c3169a3SBruce Richardson 113c121c8d6SHuawei Xie uint16_t virtio_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts, 114c121c8d6SHuawei Xie uint16_t nb_pkts); 115c121c8d6SHuawei Xie 1166c3169a3SBruce Richardson /* 1176c3169a3SBruce Richardson * The VIRTIO_NET_F_GUEST_TSO[46] features permit the host to send us 1186c3169a3SBruce Richardson * frames larger than 1514 bytes. We do not yet support software LRO 1196c3169a3SBruce Richardson * via tcp_lro_rx(). 1206c3169a3SBruce Richardson */ 1216c3169a3SBruce Richardson #define VTNET_LRO_FEATURES (VIRTIO_NET_F_GUEST_TSO4 | \ 1226c3169a3SBruce Richardson VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_ECN) 1236c3169a3SBruce Richardson 1246c3169a3SBruce Richardson 1256c3169a3SBruce Richardson #endif /* _VIRTIO_ETHDEV_H_ */ 126