1a82ab411SLuigi Rizzo /* 2a82ab411SLuigi Rizzo * Copyright (C) 2013-2016 Luigi Rizzo 3a82ab411SLuigi Rizzo * Copyright (C) 2013-2016 Giuseppe Lettieri 4b6e66be2SVincenzo Maffione * Copyright (C) 2013-2018 Vincenzo Maffione 5a82ab411SLuigi Rizzo * Copyright (C) 2015 Stefano Garzarella 6a82ab411SLuigi Rizzo * All rights reserved. 7a82ab411SLuigi Rizzo * 8a82ab411SLuigi Rizzo * Redistribution and use in source and binary forms, with or without 9a82ab411SLuigi Rizzo * modification, are permitted provided that the following conditions 10a82ab411SLuigi Rizzo * are met: 11a82ab411SLuigi Rizzo * 1. Redistributions of source code must retain the above copyright 12a82ab411SLuigi Rizzo * notice, this list of conditions and the following disclaimer. 13a82ab411SLuigi Rizzo * 2. Redistributions in binary form must reproduce the above copyright 14a82ab411SLuigi Rizzo * notice, this list of conditions and the following disclaimer in the 15a82ab411SLuigi Rizzo * documentation and/or other materials provided with the distribution. 16a82ab411SLuigi Rizzo * 17a82ab411SLuigi Rizzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18a82ab411SLuigi Rizzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19a82ab411SLuigi Rizzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20a82ab411SLuigi Rizzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21a82ab411SLuigi Rizzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22a82ab411SLuigi Rizzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23a82ab411SLuigi Rizzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24a82ab411SLuigi Rizzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25a82ab411SLuigi Rizzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26a82ab411SLuigi Rizzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27a82ab411SLuigi Rizzo * SUCH DAMAGE. 28a82ab411SLuigi Rizzo */ 29a82ab411SLuigi Rizzo 30a82ab411SLuigi Rizzo #ifndef NETMAP_VIRT_H 31a82ab411SLuigi Rizzo #define NETMAP_VIRT_H 32a82ab411SLuigi Rizzo 33a82ab411SLuigi Rizzo /* 34b6e66be2SVincenzo Maffione * Register offsets and other macros for the ptnetmap paravirtual devices: 35b6e66be2SVincenzo Maffione * ptnetmap-memdev: device used to expose memory into the guest 36b6e66be2SVincenzo Maffione * ptnet: paravirtualized NIC exposing a netmap port in the guest 37a82ab411SLuigi Rizzo * 38a82ab411SLuigi Rizzo * These macros are used in the hypervisor frontend (QEMU, bhyve) and in the 39a82ab411SLuigi Rizzo * guest device driver. 40a82ab411SLuigi Rizzo */ 41a82ab411SLuigi Rizzo 42b6e66be2SVincenzo Maffione /* PCI identifiers and PCI BARs for ptnetmap-memdev and ptnet. */ 43a82ab411SLuigi Rizzo #define PTNETMAP_MEMDEV_NAME "ptnetmap-memdev" 44844a6f0cSLuigi Rizzo #define PTNETMAP_PCI_VENDOR_ID 0x1b36 /* QEMU virtual devices */ 45a6d768d8SVincenzo Maffione #define PTNETMAP_PCI_DEVICE_ID 0x000c /* memory device */ 46a6d768d8SVincenzo Maffione #define PTNETMAP_PCI_NETIF_ID 0x000d /* ptnet network interface */ 47a82ab411SLuigi Rizzo #define PTNETMAP_IO_PCI_BAR 0 48a82ab411SLuigi Rizzo #define PTNETMAP_MEM_PCI_BAR 1 49a82ab411SLuigi Rizzo #define PTNETMAP_MSIX_PCI_BAR 2 50a82ab411SLuigi Rizzo 51b6e66be2SVincenzo Maffione /* Device registers for ptnetmap-memdev */ 52844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_MEMSIZE_LO 0 /* netmap memory size (low) */ 53844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_MEMSIZE_HI 4 /* netmap_memory_size (high) */ 54844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_MEMID 8 /* memory allocator ID in the host */ 55844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_IF_POOL_OFS 64 56844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_IF_POOL_OBJNUM 68 57844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_IF_POOL_OBJSZ 72 58844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_RING_POOL_OFS 76 59844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_RING_POOL_OBJNUM 80 60844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_RING_POOL_OBJSZ 84 61844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_BUF_POOL_OFS 88 62844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_BUF_POOL_OBJNUM 92 63844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_BUF_POOL_OBJSZ 96 64844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_END 100 65a82ab411SLuigi Rizzo 66844a6f0cSLuigi Rizzo /* ptnetmap features */ 67844a6f0cSLuigi Rizzo #define PTNETMAP_F_VNET_HDR 1 68a82ab411SLuigi Rizzo 69b6e66be2SVincenzo Maffione /* Device registers for the ptnet network device. */ 70a82ab411SLuigi Rizzo #define PTNET_IO_PTFEAT 0 71a82ab411SLuigi Rizzo #define PTNET_IO_PTCTL 4 72844a6f0cSLuigi Rizzo #define PTNET_IO_MAC_LO 8 73844a6f0cSLuigi Rizzo #define PTNET_IO_MAC_HI 12 7446023447SVincenzo Maffione #define PTNET_IO_CSBBAH 16 /* deprecated */ 7546023447SVincenzo Maffione #define PTNET_IO_CSBBAL 20 /* deprecated */ 76844a6f0cSLuigi Rizzo #define PTNET_IO_NIFP_OFS 24 77844a6f0cSLuigi Rizzo #define PTNET_IO_NUM_TX_RINGS 28 78844a6f0cSLuigi Rizzo #define PTNET_IO_NUM_RX_RINGS 32 79844a6f0cSLuigi Rizzo #define PTNET_IO_NUM_TX_SLOTS 36 80844a6f0cSLuigi Rizzo #define PTNET_IO_NUM_RX_SLOTS 40 81844a6f0cSLuigi Rizzo #define PTNET_IO_VNET_HDR_LEN 44 82844a6f0cSLuigi Rizzo #define PTNET_IO_HOSTMEMID 48 8346023447SVincenzo Maffione #define PTNET_IO_CSB_GH_BAH 52 8446023447SVincenzo Maffione #define PTNET_IO_CSB_GH_BAL 56 8546023447SVincenzo Maffione #define PTNET_IO_CSB_HG_BAH 60 8646023447SVincenzo Maffione #define PTNET_IO_CSB_HG_BAL 64 8746023447SVincenzo Maffione #define PTNET_IO_END 68 88a82ab411SLuigi Rizzo #define PTNET_IO_KICK_BASE 128 89a82ab411SLuigi Rizzo #define PTNET_IO_MASK 0xff 90a82ab411SLuigi Rizzo 91b6e66be2SVincenzo Maffione /* ptnet control commands (values for PTCTL register): 92b6e66be2SVincenzo Maffione * - CREATE starts the host sync-kloop 93b6e66be2SVincenzo Maffione * - DELETE stops the host sync-kloop 94b6e66be2SVincenzo Maffione */ 95844a6f0cSLuigi Rizzo #define PTNETMAP_PTCTL_CREATE 1 96844a6f0cSLuigi Rizzo #define PTNETMAP_PTCTL_DELETE 2 97844a6f0cSLuigi Rizzo 98a82ab411SLuigi Rizzo #endif /* NETMAP_VIRT_H */ 99