1d19533e8SHuawei Xie /*- 2d19533e8SHuawei Xie * BSD LICENSE 3d19533e8SHuawei Xie * 445657a5cSYuanhan Liu * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. 5d19533e8SHuawei Xie * All rights reserved. 6d19533e8SHuawei Xie * 7d19533e8SHuawei Xie * Redistribution and use in source and binary forms, with or without 8d19533e8SHuawei Xie * modification, are permitted provided that the following conditions 9d19533e8SHuawei Xie * are met: 10d19533e8SHuawei Xie * 11d19533e8SHuawei Xie * * Redistributions of source code must retain the above copyright 12d19533e8SHuawei Xie * notice, this list of conditions and the following disclaimer. 13d19533e8SHuawei Xie * * Redistributions in binary form must reproduce the above copyright 14d19533e8SHuawei Xie * notice, this list of conditions and the following disclaimer in 15d19533e8SHuawei Xie * the documentation and/or other materials provided with the 16d19533e8SHuawei Xie * distribution. 17d19533e8SHuawei Xie * * Neither the name of Intel Corporation nor the names of its 18d19533e8SHuawei Xie * contributors may be used to endorse or promote products derived 19d19533e8SHuawei Xie * from this software without specific prior written permission. 20d19533e8SHuawei Xie * 21d19533e8SHuawei Xie * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22d19533e8SHuawei Xie * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23d19533e8SHuawei Xie * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24d19533e8SHuawei Xie * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25d19533e8SHuawei Xie * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26d19533e8SHuawei Xie * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27d19533e8SHuawei Xie * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28d19533e8SHuawei Xie * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29d19533e8SHuawei Xie * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30d19533e8SHuawei Xie * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31d19533e8SHuawei Xie * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32d19533e8SHuawei Xie */ 33d19533e8SHuawei Xie 34d19533e8SHuawei Xie #ifndef _MAIN_H_ 35d19533e8SHuawei Xie #define _MAIN_H_ 36d19533e8SHuawei Xie 3745657a5cSYuanhan Liu #include <sys/queue.h> 3845657a5cSYuanhan Liu 39d19533e8SHuawei Xie /* Macros for printing using RTE_LOG */ 40d19533e8SHuawei Xie #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1 41d19533e8SHuawei Xie #define RTE_LOGTYPE_VHOST_DATA RTE_LOGTYPE_USER2 42d19533e8SHuawei Xie #define RTE_LOGTYPE_VHOST_PORT RTE_LOGTYPE_USER3 43d19533e8SHuawei Xie 44*56fe86f8SYuanhan Liu struct device_statistics { 45*56fe86f8SYuanhan Liu uint64_t tx; 46*56fe86f8SYuanhan Liu uint64_t tx_total; 47*56fe86f8SYuanhan Liu rte_atomic64_t rx_atomic; 48*56fe86f8SYuanhan Liu rte_atomic64_t rx_total_atomic; 49*56fe86f8SYuanhan Liu }; 50*56fe86f8SYuanhan Liu 51e571e6b4SHuawei Xie struct vhost_dev { 52e571e6b4SHuawei Xie /**< Pointer to device created by vhost lib. */ 53e571e6b4SHuawei Xie struct virtio_net *dev; 54e571e6b4SHuawei Xie /**< Number of memory regions for gpa to hpa translation. */ 55e571e6b4SHuawei Xie uint32_t nregions_hpa; 56e571e6b4SHuawei Xie /**< Device MAC address (Obtained on first TX packet). */ 57e571e6b4SHuawei Xie struct ether_addr mac_address; 58e571e6b4SHuawei Xie /**< RX VMDQ queue number. */ 59e571e6b4SHuawei Xie uint16_t vmdq_rx_q; 60e571e6b4SHuawei Xie /**< Vlan tag assigned to the pool */ 61e571e6b4SHuawei Xie uint32_t vlan_tag; 62e571e6b4SHuawei Xie /**< Data core that the device is added to. */ 63e571e6b4SHuawei Xie uint16_t coreid; 64e571e6b4SHuawei Xie /**< A device is set as ready if the MAC address has been set. */ 65e571e6b4SHuawei Xie volatile uint8_t ready; 66e571e6b4SHuawei Xie /**< Device is marked for removal from the data core. */ 67e571e6b4SHuawei Xie volatile uint8_t remove; 6845657a5cSYuanhan Liu 69*56fe86f8SYuanhan Liu struct device_statistics stats; 7045657a5cSYuanhan Liu TAILQ_ENTRY(vhost_dev) next; 71e571e6b4SHuawei Xie } __rte_cache_aligned; 72e571e6b4SHuawei Xie 7345657a5cSYuanhan Liu TAILQ_HEAD(vhost_dev_tailq_list, vhost_dev); 7445657a5cSYuanhan Liu 7545657a5cSYuanhan Liu 7645657a5cSYuanhan Liu #define REQUEST_DEV_REMOVAL 1 7745657a5cSYuanhan Liu #define ACK_DEV_REMOVAL 0 78d19533e8SHuawei Xie 79d19533e8SHuawei Xie /* 80d19533e8SHuawei Xie * Structure containing data core specific information. 81d19533e8SHuawei Xie */ 8245657a5cSYuanhan Liu struct lcore_info { 8345657a5cSYuanhan Liu uint32_t device_num; 84d19533e8SHuawei Xie 8545657a5cSYuanhan Liu /* Flag to synchronize device removal. */ 8645657a5cSYuanhan Liu volatile uint8_t dev_removal_flag; 8745657a5cSYuanhan Liu 8845657a5cSYuanhan Liu struct vhost_dev_tailq_list vdev_list; 89d19533e8SHuawei Xie }; 90d19533e8SHuawei Xie 91d19533e8SHuawei Xie #endif /* _MAIN_H_ */ 92