1d19533e8SHuawei Xie /*- 2d19533e8SHuawei Xie * BSD LICENSE 3d19533e8SHuawei Xie * 4*45657a5cSYuanhan 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 37*45657a5cSYuanhan Liu #include <sys/queue.h> 38*45657a5cSYuanhan 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 449915bb1fSHuawei Xie /* 45d19533e8SHuawei Xie * Device linked list structure for data path. 46d19533e8SHuawei Xie */ 47e571e6b4SHuawei Xie struct vhost_dev { 48e571e6b4SHuawei Xie /**< Pointer to device created by vhost lib. */ 49e571e6b4SHuawei Xie struct virtio_net *dev; 50e571e6b4SHuawei Xie /**< Number of memory regions for gpa to hpa translation. */ 51e571e6b4SHuawei Xie uint32_t nregions_hpa; 52e571e6b4SHuawei Xie /**< Device MAC address (Obtained on first TX packet). */ 53e571e6b4SHuawei Xie struct ether_addr mac_address; 54e571e6b4SHuawei Xie /**< RX VMDQ queue number. */ 55e571e6b4SHuawei Xie uint16_t vmdq_rx_q; 56e571e6b4SHuawei Xie /**< Vlan tag assigned to the pool */ 57e571e6b4SHuawei Xie uint32_t vlan_tag; 58e571e6b4SHuawei Xie /**< Data core that the device is added to. */ 59e571e6b4SHuawei Xie uint16_t coreid; 60e571e6b4SHuawei Xie /**< A device is set as ready if the MAC address has been set. */ 61e571e6b4SHuawei Xie volatile uint8_t ready; 62e571e6b4SHuawei Xie /**< Device is marked for removal from the data core. */ 63e571e6b4SHuawei Xie volatile uint8_t remove; 64*45657a5cSYuanhan Liu 65*45657a5cSYuanhan Liu TAILQ_ENTRY(vhost_dev) next; 66e571e6b4SHuawei Xie } __rte_cache_aligned; 67e571e6b4SHuawei Xie 68*45657a5cSYuanhan Liu TAILQ_HEAD(vhost_dev_tailq_list, vhost_dev); 69*45657a5cSYuanhan Liu 70*45657a5cSYuanhan Liu 71*45657a5cSYuanhan Liu #define REQUEST_DEV_REMOVAL 1 72*45657a5cSYuanhan Liu #define ACK_DEV_REMOVAL 0 73d19533e8SHuawei Xie 74d19533e8SHuawei Xie /* 75d19533e8SHuawei Xie * Structure containing data core specific information. 76d19533e8SHuawei Xie */ 77*45657a5cSYuanhan Liu struct lcore_info { 78*45657a5cSYuanhan Liu uint32_t device_num; 79d19533e8SHuawei Xie 80*45657a5cSYuanhan Liu /* Flag to synchronize device removal. */ 81*45657a5cSYuanhan Liu volatile uint8_t dev_removal_flag; 82*45657a5cSYuanhan Liu 83*45657a5cSYuanhan Liu struct vhost_dev_tailq_list vdev_list; 84d19533e8SHuawei Xie }; 85d19533e8SHuawei Xie 86d19533e8SHuawei Xie #endif /* _MAIN_H_ */ 87