1a82ab411SLuigi Rizzo /* 2a82ab411SLuigi Rizzo * Copyright (C) 2013-2016 Luigi Rizzo 3a82ab411SLuigi Rizzo * Copyright (C) 2013-2016 Giuseppe Lettieri 4*b6e66be2SVincenzo 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 * $FreeBSD$ 30a82ab411SLuigi Rizzo */ 31a82ab411SLuigi Rizzo 32a82ab411SLuigi Rizzo #ifndef NETMAP_VIRT_H 33a82ab411SLuigi Rizzo #define NETMAP_VIRT_H 34a82ab411SLuigi Rizzo 35a82ab411SLuigi Rizzo /* 36*b6e66be2SVincenzo Maffione * Register offsets and other macros for the ptnetmap paravirtual devices: 37*b6e66be2SVincenzo Maffione * ptnetmap-memdev: device used to expose memory into the guest 38*b6e66be2SVincenzo Maffione * ptnet: paravirtualized NIC exposing a netmap port in the guest 39a82ab411SLuigi Rizzo * 40a82ab411SLuigi Rizzo * These macros are used in the hypervisor frontend (QEMU, bhyve) and in the 41a82ab411SLuigi Rizzo * guest device driver. 42a82ab411SLuigi Rizzo */ 43a82ab411SLuigi Rizzo 44*b6e66be2SVincenzo Maffione /* PCI identifiers and PCI BARs for ptnetmap-memdev and ptnet. */ 45a82ab411SLuigi Rizzo #define PTNETMAP_MEMDEV_NAME "ptnetmap-memdev" 46844a6f0cSLuigi Rizzo #define PTNETMAP_PCI_VENDOR_ID 0x1b36 /* QEMU virtual devices */ 47844a6f0cSLuigi Rizzo #define PTNETMAP_PCI_DEVICE_ID 0x000c /* memory device */ 48844a6f0cSLuigi Rizzo #define PTNETMAP_PCI_NETIF_ID 0x000d /* ptnet network interface */ 49a82ab411SLuigi Rizzo #define PTNETMAP_IO_PCI_BAR 0 50a82ab411SLuigi Rizzo #define PTNETMAP_MEM_PCI_BAR 1 51a82ab411SLuigi Rizzo #define PTNETMAP_MSIX_PCI_BAR 2 52a82ab411SLuigi Rizzo 53*b6e66be2SVincenzo Maffione /* Device registers for ptnetmap-memdev */ 54844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_MEMSIZE_LO 0 /* netmap memory size (low) */ 55844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_MEMSIZE_HI 4 /* netmap_memory_size (high) */ 56844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_MEMID 8 /* memory allocator ID in the host */ 57844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_IF_POOL_OFS 64 58844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_IF_POOL_OBJNUM 68 59844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_IF_POOL_OBJSZ 72 60844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_RING_POOL_OFS 76 61844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_RING_POOL_OBJNUM 80 62844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_RING_POOL_OBJSZ 84 63844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_BUF_POOL_OFS 88 64844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_BUF_POOL_OBJNUM 92 65844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_BUF_POOL_OBJSZ 96 66844a6f0cSLuigi Rizzo #define PTNET_MDEV_IO_END 100 67a82ab411SLuigi Rizzo 68844a6f0cSLuigi Rizzo /* ptnetmap features */ 69844a6f0cSLuigi Rizzo #define PTNETMAP_F_VNET_HDR 1 70a82ab411SLuigi Rizzo 71*b6e66be2SVincenzo Maffione /* Device registers for the ptnet network device. */ 72a82ab411SLuigi Rizzo #define PTNET_IO_PTFEAT 0 73a82ab411SLuigi Rizzo #define PTNET_IO_PTCTL 4 74844a6f0cSLuigi Rizzo #define PTNET_IO_MAC_LO 8 75844a6f0cSLuigi Rizzo #define PTNET_IO_MAC_HI 12 7646023447SVincenzo Maffione #define PTNET_IO_CSBBAH 16 /* deprecated */ 7746023447SVincenzo Maffione #define PTNET_IO_CSBBAL 20 /* deprecated */ 78844a6f0cSLuigi Rizzo #define PTNET_IO_NIFP_OFS 24 79844a6f0cSLuigi Rizzo #define PTNET_IO_NUM_TX_RINGS 28 80844a6f0cSLuigi Rizzo #define PTNET_IO_NUM_RX_RINGS 32 81844a6f0cSLuigi Rizzo #define PTNET_IO_NUM_TX_SLOTS 36 82844a6f0cSLuigi Rizzo #define PTNET_IO_NUM_RX_SLOTS 40 83844a6f0cSLuigi Rizzo #define PTNET_IO_VNET_HDR_LEN 44 84844a6f0cSLuigi Rizzo #define PTNET_IO_HOSTMEMID 48 8546023447SVincenzo Maffione #define PTNET_IO_CSB_GH_BAH 52 8646023447SVincenzo Maffione #define PTNET_IO_CSB_GH_BAL 56 8746023447SVincenzo Maffione #define PTNET_IO_CSB_HG_BAH 60 8846023447SVincenzo Maffione #define PTNET_IO_CSB_HG_BAL 64 8946023447SVincenzo Maffione #define PTNET_IO_END 68 90a82ab411SLuigi Rizzo #define PTNET_IO_KICK_BASE 128 91a82ab411SLuigi Rizzo #define PTNET_IO_MASK 0xff 92a82ab411SLuigi Rizzo 93*b6e66be2SVincenzo Maffione /* ptnet control commands (values for PTCTL register): 94*b6e66be2SVincenzo Maffione * - CREATE starts the host sync-kloop 95*b6e66be2SVincenzo Maffione * - DELETE stops the host sync-kloop 96*b6e66be2SVincenzo Maffione */ 97844a6f0cSLuigi Rizzo #define PTNETMAP_PTCTL_CREATE 1 98844a6f0cSLuigi Rizzo #define PTNETMAP_PTCTL_DELETE 2 99844a6f0cSLuigi Rizzo 100a82ab411SLuigi Rizzo #endif /* NETMAP_VIRT_H */ 101