Date: Thu, 13 Aug 2015 09:37:29 GMT From: stefano@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289680 - soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve Message-ID: <201508130937.t7D9bTUW024736@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: stefano Date: Thu Aug 13 09:37:29 2015 New Revision: 289680 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289680 Log: bhyve-ptnetmap: cleanup and documentation Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/bhyve.8 soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/net_backends.c soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_ptnetmap_memdev.c soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_virtio_ptnetmap.h soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/ptnetmap.h Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/bhyve.8 ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/bhyve.8 Thu Aug 13 05:42:56 2015 (r289679) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/bhyve.8 Thu Aug 13 09:37:29 2015 (r289680) @@ -167,6 +167,8 @@ .It Li lpc LPC PCI-ISA bridge with COM1 and COM2 16550 serial ports. The LPC bridge emulation can only be configured on bus 0. +.It Li ptnetmap-memdev +Device used to share netmap memory in the guest. (required with ptnetmap backend) .El .It Op Ar conf This optional parameter describes the backend for device emulations. @@ -178,6 +180,17 @@ Network devices: .Bl -tag -width 10n .It Ar tapN Ns Op , Ns Ar mac=xx:xx:xx:xx:xx:xx +.It Ar [pt]netmap:XXX Ns Op , Ns Ar mac=xx:xx:xx:xx:xx:xx +.It Ar [pt]valeXXX:YYY Ns Op , Ns Ar mac=xx:xx:xx:xx:xx:xx +Use netmap/vale port as a backend for device emualtions. +.Pp +If "pt" prefix is specified, the port is opened in passthrough mode (ptnetmap). +One +.Ar ptnetmap-memdev +emulation is required for each ptnetmap port. (If two or more ptnetmap ports +share the same netmap memory allocator, only one +.Ar ptnetmap-memdev +is required) .It Ar vmnetN Ns Op , Ns Ar mac=xx:xx:xx:xx:xx:xx .Pp If @@ -285,6 +298,18 @@ -A -H -P -m 24G bigvm .Ed .Pp +Run a 2GB single-CPU virtual machine with three network ports which use netmap +and ptnetmap backends: +.Bd -literal -offset indent +bhyve -s 0,hostbridge -s 1,lpc \\ + -s 2:1,virtio-net,vale0:1 \\ + -s 2:2,ptnetmap-memdev \\ + -s 2:3,virtio-net,ptvale1:2 \\ + -s 3,ptnetmap-memdev \\ + -s 4,virtio-net,ptnetmap:ix0 \\ + -l com1,stdio -A -H -P -m 2G netmapvm +.Ed +.Pp Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI CD-ROM, a single virtio network port, an AMD hostbridge, and the console port connected to an Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/net_backends.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/net_backends.c Thu Aug 13 05:42:56 2015 (r289679) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/net_backends.c Thu Aug 13 09:37:29 2015 (r289680) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014 Vincenzo Maffione <v.maffione@gmail.com> + * Copyright (c) 2014-2015 Vincenzo Maffione, Stefano Garzarella * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -109,6 +109,9 @@ */ uint64_t (*set_features)(struct net_backend *be, uint64_t features); + /* + * Get ptnetmap_state if the backend support ptnetmap + */ struct ptnetmap_state * (*get_ptnetmap)(struct net_backend *be); struct pci_vtnet_softc *sc; @@ -351,11 +354,11 @@ DATA_SET(net_backend_set, tap_backend); + /* * The netmap backend */ - /* The virtio-net features supported by netmap. */ #define NETMAP_FEATURES (VIRTIO_NET_F_CSUM | VIRTIO_NET_F_HOST_TSO4 | \ VIRTIO_NET_F_HOST_TSO6 | VIRTIO_NET_F_HOST_UFO | \ @@ -443,10 +446,10 @@ return 0; } -/* used by netmap and ptnetmap */ +/* used by netmap and ptnetmap during the initialization */ static int -netmap_commom_init(struct net_backend *be, struct netmap_priv *priv, uint32_t nr_flags, - const char *devname, net_backend_cb_t cb, void *param) +netmap_commom_init(struct net_backend *be, struct netmap_priv *priv, + uint32_t nr_flags, const char *devname, net_backend_cb_t cb, void *param) { const char *ndname = "/dev/netmap"; struct nmreq req; @@ -465,16 +468,6 @@ ndname, devname, strerror(errno))); goto err_open; } -#if 0 - /* check parent (nm_desc with the same allocator already mapped) */ - parent_nmd = netmap_find_parent(nmd); - /* mmap or inherit from parent */ - if (nm_mmap(nmd, parent_nmd)) { - error_report("failed to mmap %s: %s", netmap_opts->ifname, strerror(errno)); - nm_close(nmd); - return -1; - } -#endif priv->tx = NETMAP_TXRING(priv->nmd->nifp, 0); priv->rx = NETMAP_RXRING(priv->nmd->nifp, 0); @@ -500,9 +493,7 @@ netmap_init(struct net_backend *be, const char *devname, net_backend_cb_t cb, void *param) { - const char *ndname = "/dev/netmap"; struct netmap_priv *priv = NULL; - char tname[40]; priv = calloc(1, sizeof(struct netmap_priv)); if (priv == NULL) { @@ -740,6 +731,8 @@ /* * The ptnetmap backend + * + * use netmap name with "pt" prefix to open netmap port in ptnetmap mode */ #include <stddef.h> /* IFNAMSIZ */ #include <net/netmap.h> @@ -779,11 +772,8 @@ ptnbe_init(struct net_backend *be, const char *devname, net_backend_cb_t cb, void *param) { - const char *ndname = "/dev/netmap"; struct ptnbe_priv *priv = NULL; struct netmap_priv *npriv; - struct nmreq req; - char tname[40]; priv = calloc(1, sizeof(struct ptnbe_priv)); if (priv == NULL) { @@ -793,7 +783,8 @@ npriv = &priv->up; - if (netmap_commom_init(be, npriv, NR_PTNETMAP_HOST, devname + PTNETMAP_NAME_HDR, cb, param)) { + if (netmap_commom_init(be, npriv, NR_PTNETMAP_HOST, + devname + PTNETMAP_NAME_HDR, cb, param)) { goto err; } @@ -834,7 +825,8 @@ { struct ptnbe_priv *priv = be->priv; - ptn_memdev_attach(priv->up.nmd->mem, priv->up.nmd->memsize, priv->up.nmd->req.nr_arg2); + ptn_memdev_attach(priv->up.nmd->mem, priv->up.nmd->memsize, + priv->up.nmd->req.nr_arg2); priv->ptns.ptn_be = be; priv->created = 0; @@ -860,6 +852,7 @@ priv->acked_features |= features; } +/* get required netmap_if info from the netmap port opened in ptnetmap mode */ int ptnetmap_get_mem(struct ptnetmap_state *ptns) { @@ -877,6 +870,7 @@ return 0; } +/* get the memory allocator ID info from the netmap port opened in ptnetmap mode */ int ptnetmap_get_hostmemid(struct ptnetmap_state *ptns) { @@ -888,6 +882,7 @@ return npriv->nmd->req.nr_arg2; } +/* start ptnetmap mode: send ioctl to the netmap module to create the kthreads */ int ptnetmap_create(struct ptnetmap_state *ptns, struct ptnetmap_cfg *conf) { @@ -919,6 +914,7 @@ return err; } +/* stop ptnetmap mode: send ioctl to the netmap module to delete the kthreads */ int ptnetmap_delete(struct ptnetmap_state *ptns) { @@ -950,7 +946,7 @@ } static struct net_backend ptnbe_backend = { - .name = "ptnetmap|ptvale", + .name = "ptnetmap|ptvale", /* use netmap name with "pt" prefix */ .init = ptnbe_init, .cleanup = ptnbe_cleanup, .send = netmap_send, @@ -962,7 +958,6 @@ DATA_SET(net_backend_set, ptnbe_backend); - /* * make sure a backend is properly initialized */ Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_ptnetmap_memdev.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_ptnetmap_memdev.c Thu Aug 13 05:42:56 2015 (r289679) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_ptnetmap_memdev.c Thu Aug 13 09:37:29 2015 (r289680) @@ -28,24 +28,31 @@ __FBSDID("$FreeBSD$"); #include <errno.h> -//#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> -//#include <string.h> -//#include <strings.h> -//#include <unistd.h> -//#include <assert.h> + +#include <net/if.h> /* IFNAMSIZ */ +#include <net/netmap.h> +#include <dev/netmap/netmap_virt.h> #include <machine/vmm.h> #include <vmmapi.h> + #include "bhyverun.h" #include "pci_emul.h" #include "ptnetmap.h" -#include <net/if.h> /* IFNAMSIZ */ -#include <net/netmap.h> -#include <dev/netmap/netmap_virt.h> +/* + * ptnetmap memdev PCI device + * + * This device is used to map netmap memory allocator (the same allocator can + * be shared between multiple netmap ports) on the guest VM through PCI_BAR. + * + * Each netmap allocator has a unique ID assigned by netmap module. + * + * It is based on QEMU/KVM ptnetmap-memdev implementation. + */ struct ptn_memdev_softc { struct pci_devinst *pi; /* PCI device instance */ @@ -59,7 +66,33 @@ static TAILQ_HEAD(, ptn_memdev_softc) ptn_memdevs = TAILQ_HEAD_INITIALIZER(ptn_memdevs); /* - * find ptn_memdev through mem_id + * ptn_memdev_softc can be created by pe_init or ptnetmap backend, + * this depends on the order of initialization. + */ +static struct ptn_memdev_softc * +ptn_memdev_create() +{ + struct ptn_memdev_softc *sc; + + sc = calloc(1, sizeof(struct ptn_memdev_softc)); + + if (sc != NULL) { + TAILQ_INSERT_TAIL(&ptn_memdevs, sc, next); + } + + return sc; +} + +static void +ptn_memdev_delete(struct ptn_memdev_softc *sc) +{ + TAILQ_REMOVE(&ptn_memdevs, sc, next); + + free(sc); +} + +/* + * Find ptn_memdev through mem_id (netmap memory allocator ID) */ static struct ptn_memdev_softc * ptn_memdev_find_memid(uint16_t mem_id) @@ -76,7 +109,7 @@ } /* - * find ptn_memdev that has not memory + * Find ptn_memdev that has not netmap memory (attached by ptnetmap backend) */ static struct ptn_memdev_softc * ptn_memdev_find_empty_mem() @@ -93,7 +126,7 @@ } /* - * find ptn_memdev that has not PCI device istance + * Find ptn_memdev that has not PCI device istance (created by pe_init) */ static struct ptn_memdev_softc * ptn_memdev_find_empty_pi() @@ -109,28 +142,9 @@ return NULL; } -static struct ptn_memdev_softc * -ptn_memdev_create() -{ - struct ptn_memdev_softc *sc; - - sc = calloc(1, sizeof(struct ptn_memdev_softc)); - - if (sc != NULL) { - TAILQ_INSERT_TAIL(&ptn_memdevs, sc, next); - } - - return sc; -} - -static void -ptn_memdev_delete(struct ptn_memdev_softc *sc) -{ - TAILQ_REMOVE(&ptn_memdevs, sc, next); - - free(sc); -} - +/* + * Handle read on ptnetmap-memdev register + */ static uint64_t ptn_pci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size) @@ -142,14 +156,12 @@ return 0; if (baridx == PTNETMAP_MEM_PCI_BAR) { - printf("ptnetmap_memdev: unexpected MEM read - offset: %lx size: %d ret: %lx\n", + printf("ptnetmap_memdev: unexpected MEM read - \ + offset: %lx size: %d ret: %lx\n", offset, size, ret); - return 0; /* XXX */ + return 0; } - /* XXX probably should do something better than just assert() */ - assert(baridx == PTNETMAP_IO_PCI_BAR); - switch (offset) { case PTNETMAP_IO_PCI_MEMSIZE: ret = sc->mem_size; @@ -166,6 +178,9 @@ return ret; } +/* + * Handle write on ptnetmap-memdev register (unused for now) + */ static void ptn_pci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size, uint64_t value) @@ -176,7 +191,8 @@ return; if (baridx == PTNETMAP_MEM_PCI_BAR) { - printf("ptnetmap_memdev: unexpected MEM write - offset: %lx size: %d value: %lx\n", + printf("ptnetmap_memdev: unexpected MEM write - \ + offset: %lx size: %d value: %lx\n", offset, size, value); return; } @@ -188,31 +204,39 @@ } } +/* + * Configure the ptnetmap-memdev PCI-BARs + * + * Only if the PCI device is created and netmap memory is attached, + * we can create the PCI-BARs. + */ static int -ptn_memdev_configure(struct ptn_memdev_softc *sc) +ptn_memdev_configure_bars(struct ptn_memdev_softc *sc) { int ret; if (sc->pi == NULL || sc->mem_ptr == NULL) return 0; - /* init iobar */ - ret = pci_emul_alloc_bar(sc->pi, PTNETMAP_IO_PCI_BAR, PCIBAR_IO, PTNEMTAP_IO_SIZE); + /* alloc IO-BAR */ + ret = pci_emul_alloc_bar(sc->pi, PTNETMAP_IO_PCI_BAR, PCIBAR_IO, + PTNEMTAP_IO_SIZE); if (ret) { printf("ptnetmap_memdev: iobar allocation error %d\n", ret); return ret; } - - /* init membar */ - /* XXX MEM64 has MEM_PREFETCH */ - ret = pci_emul_alloc_bar(sc->pi, PTNETMAP_MEM_PCI_BAR, PCIBAR_MEM32, sc->mem_size); + /* alloc MEM-BAR */ + ret = pci_emul_alloc_bar(sc->pi, PTNETMAP_MEM_PCI_BAR, PCIBAR_MEM32, + sc->mem_size); if (ret) { printf("ptnetmap_memdev: membar allocation error %d\n", ret); return ret; } - ret = vm_map_user_buf(sc->pi->pi_vmctx, sc->pi->pi_bar[PTNETMAP_MEM_PCI_BAR].addr, + /* map netmap memory on the MEM-BAR */ + ret = vm_map_user_buf(sc->pi->pi_vmctx, + sc->pi->pi_bar[PTNETMAP_MEM_PCI_BAR].addr, sc->mem_size, sc->mem_ptr); if (ret) { printf("ptnetmap_memdev: membar map error %d\n", ret); @@ -222,6 +246,9 @@ return 0; } +/* + * PCI device initialization + */ static int ptn_memdev_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { @@ -246,10 +273,11 @@ pci_set_cfgdata16(pi, PCIR_VENDOR, PTNETMAP_PCI_VENDOR_ID); pci_set_cfgdata16(pi, PCIR_DEVICE, PTNETMAP_PCI_DEVICE_ID); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_NETWORK); - pci_set_cfgdata16(pi, PCIR_SUBDEV_0, 1); /* XXX-ste remove? */ - pci_set_cfgdata16(pi, PCIR_SUBVEND_0, PTNETMAP_PCI_VENDOR_ID); /* XXX-ste remove? */ + pci_set_cfgdata16(pi, PCIR_SUBDEV_0, 1); + pci_set_cfgdata16(pi, PCIR_SUBVEND_0, PTNETMAP_PCI_VENDOR_ID); - ret = ptn_memdev_configure(sc); + /* configure device PCI-BARs */ + ret = ptn_memdev_configure_bars(sc); if (ret) { printf("ptnetmap_memdev: configure error\n"); goto err; @@ -262,6 +290,10 @@ return ret; } +/* + * used by ptnetmap backend to attach the netmap memory allocator to the + * ptnetmap-memdev. (shared with the guest VM through PCI-BAR) + */ int ptn_memdev_attach(void *mem_ptr, uint32_t mem_size, uint16_t mem_id) { @@ -287,8 +319,8 @@ sc->mem_size = mem_size; sc->mem_id = mem_id; - /* configure device BARs */ - ret = ptn_memdev_configure(sc); + /* configure device PCI-BARs */ + ret = ptn_memdev_configure_bars(sc); if (ret) { printf("ptnetmap_memdev: configure error\n"); goto err; Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_virtio_ptnetmap.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_virtio_ptnetmap.h Thu Aug 13 05:42:56 2015 (r289679) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_virtio_ptnetmap.h Thu Aug 13 09:37:29 2015 (r289680) @@ -27,6 +27,21 @@ #ifndef __PCI_VIRTIO_PTNETMAP_H__ #define __PCI_VIRTIO_PTNETMAP_H__ +/* + * ptnetmap support for virtio-net (vtnet) pci device. + * + * This file contains functions to use virtio-net device in ptnetmap + * (netmap passthrough) mode and to handle write/read on ptnetmap registers. + * The virtio-net device is used to exchange notification (specific for each + * netmap port), instead the netmap memory is shared through ptnetmap-memdev + * PCI device because multiple netmap port can share the same allocator. + * + * The ptnetmap registers are appended to the virtio configuration + * space (vc_cfgsize). + * + * It is based on QEMU/KVM virtio-ptnetmap implementation. + */ + #ifdef BHYVE_VIRTIO_PTNETMAP #include <machine/vmm.h> #include <machine/vmm_dev.h> /* VM_LAPIC_MSI */ @@ -37,29 +52,38 @@ /* ptnetmap virtio register BASE */ #define PTNETMAP_VIRTIO_IO_BASE sizeof(struct virtio_net_config) +/* + * Get CSB (Communication Status Block) host address. + * + * The guest allocates the shared CSB and + * write its physical address at CSBAL and CSBAH + * + * We require that writes to the CSB address registers + * are in the order CSBBAH , CSBBAL so on the second one + * we have a valid 64-bit memory address. + * Any previous region is unmapped, and handlers terminated. + * The CSB is then remapped if the new pointer is != 0 + */ static void -ptnetmap_configure_csb(struct vmctx *ctx, struct paravirt_csb** csb, uint32_t csbbal, - uint32_t csbbah) +ptnetmap_configure_csb(struct vmctx *ctx, struct paravirt_csb** csb, + uint32_t csbbal, uint32_t csbbah) { - uint64_t len = 4096; + uint64_t len = NET_PARAVIRT_CSB_SIZE; uint64_t base = ((uint64_t)csbbah << 32) | csbbal; - /* - * We require that writes to the CSB address registers - * are in the order CSBBAH , CSBBAL so on the second one - * we have a valid 64-bit memory address. - * Any previous region is unmapped, and handlers terminated. - * The CSB is then remapped if the new pointer is != 0 - */ - if (*csb) { - *csb = NULL; - } + /* CSB configuration */ if (base) { *csb = paddr_guest2host(ctx, base, len); } } +/* + * Init ptnetmap state on vtnet initialization + * + * Check if the backend supports ptnetmap and extend the virtio + * cfgsize to add ptnetmap register + */ static void pci_vtnet_ptnetmap_init(struct pci_vtnet_softc *sc, struct virtio_consts *vc) { @@ -86,6 +110,10 @@ vc->vc_cfgsize += PTNEMTAP_VIRTIO_IO_SIZE; } +/* + * Expose the required netmap_if fields about the netmap port + * opened in passthrough (ptnetmap) mode to the guest through CSB + */ static int pci_vtnet_ptnetmap_get_mem(struct pci_vtnet_softc *sc) { @@ -111,6 +139,14 @@ return ret; } +/* + * Start ptnetmap mode on virtio-net device + * + * configure virtio TX/RX ring in ptnetmap mode: + * push fake packet per ring to leave enabled the interrupts, + * send I/O guest notification (writes on VTCFG_R_QNOTIFY register) + * directly to ptnetmap kthread and configure the ptnetmap backend. + */ static int pci_vtnet_ptnetmap_up(struct pci_vtnet_softc *sc) { @@ -140,11 +176,11 @@ /* Configure the RX ring */ sc->ptn.cfg.rx_ring.irqfd = vm_get_fd(vmctx); - sc->ptn.cfg.rx_ioctl.com = VM_LAPIC_MSI; + sc->ptn.cfg.rx_ring.ioctl.com = VM_LAPIC_MSI; vq = &sc->vsc_queues[VTNET_RXQ]; mte = &pi->pi_msix.table[vq->vq_msix_idx]; - sc->ptn.cfg.rx_ioctl.data.msg = mte->msg_data; - sc->ptn.cfg.rx_ioctl.data.addr = mte->addr; + sc->ptn.cfg.rx_ring.ioctl.data.msix.msg = mte->msg_data; + sc->ptn.cfg.rx_ring.ioctl.data.msix.addr = mte->addr; /* push fake-elem in the rx queue to enable interrupts */ if (vq_getchain(vq, &idx, iov, 1, NULL) > 0) { vq_relchain(vq, idx, 0); @@ -165,11 +201,11 @@ /* Configure the TX ring */ sc->ptn.cfg.tx_ring.irqfd = vm_get_fd(vmctx); - sc->ptn.cfg.tx_ioctl.com = VM_LAPIC_MSI; + sc->ptn.cfg.tx_ring.ioctl.com = VM_LAPIC_MSI; vq = &sc->vsc_queues[VTNET_TXQ]; mte = &pi->pi_msix.table[vq->vq_msix_idx]; - sc->ptn.cfg.tx_ioctl.data.msg = mte->msg_data; - sc->ptn.cfg.tx_ioctl.data.addr = mte->addr; + sc->ptn.cfg.tx_ring.ioctl.data.msix.msg = mte->msg_data; + sc->ptn.cfg.tx_ring.ioctl.data.msix.addr = mte->addr; /* push fake-elem in the tx queue to enable interrupts */ if (vq_getchain(vq, &idx, iov, 1, NULL) > 0) { vq_relchain(vq, idx, 0); @@ -217,6 +253,11 @@ return (ret); } +/* + * Stop ptnetmap mode on virtio-net device + * + * Restore I/O guest notification. + */ static int pci_vtnet_ptnetmap_down(struct pci_vtnet_softc *sc) { @@ -244,8 +285,12 @@ return (ptnetmap_delete(sc->ptn.state)); } +/* + * Handle write on ptnetmap register and talk with ptnetmap backend + */ static int -pci_vtnet_ptnetmap_write(struct pci_vtnet_softc *sc, int offset, int size, uint32_t value) +pci_vtnet_ptnetmap_write(struct pci_vtnet_softc *sc, int offset, int size, + uint32_t value) { uint32_t *val, ret; @@ -305,8 +350,12 @@ return (0); } +/* + * Handle read on ptnetmap register + */ static int -pci_vtnet_ptnetmap_read(struct pci_vtnet_softc *sc, int offset, int size, uint32_t *value) +pci_vtnet_ptnetmap_read(struct pci_vtnet_softc *sc, int offset, int size, + uint32_t *value) { if (sc->ptn.state == NULL) { printf("ERROR ptnetmap: not supported by backend\n"); @@ -322,7 +371,6 @@ case PTNETMAP_VIRTIO_IO_PTSTS: break; default: - printf("pci_vtnet_ptnentmap: write io reg unexpected\n"); break; } #endif Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/ptnetmap.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/ptnetmap.h Thu Aug 13 05:42:56 2015 (r289679) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/ptnetmap.h Thu Aug 13 09:37:29 2015 (r289680) @@ -27,21 +27,22 @@ #ifndef __PTNETMAP_H__ #define __PTNETMAP_H__ +/* + * ptnetmap state shared between frontend (virtio-net) and ptnetmap backend + */ struct ptnetmap_state { struct net_backend *ptn_be; - /* netmap info */ + /* netmap_if info to share with the guest */ uint32_t offset; uint16_t num_tx_rings; uint16_t num_rx_rings; uint16_t num_tx_slots; uint16_t num_rx_slots; - }; +/* ptnetmap-backend API (used by fronted like virtio-net) */ struct ptnetmap_cfg; - -/* ptnetmap-backend */ uint32_t ptnetmap_get_features(struct ptnetmap_state *ptns, uint32_t features); void ptnetmap_ack_features(struct ptnetmap_state *ptns, uint32_t features); int ptnetmap_get_mem(struct ptnetmap_state *ptns); @@ -49,7 +50,7 @@ int ptnetmap_create(struct ptnetmap_state *ptns, struct ptnetmap_cfg *conf); int ptnetmap_delete(struct ptnetmap_state *ptns); -/* ptnetmap-memdev */ +/* ptnetmap-memdev API (used by ptnetmap backed) */ int ptn_memdev_attach(void *mem_ptr, uint32_t mem_size, uint16_t mem_id); #endif /* __PTNETMAP_H__ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508130937.t7D9bTUW024736>