From owner-svn-soc-all@freebsd.org Fri Aug 5 14:07:41 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0491FBB059E for ; Fri, 5 Aug 2016 14:07:41 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DDA581A63 for ; Fri, 5 Aug 2016 14:07:40 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u75E7eYl002918 for ; Fri, 5 Aug 2016 14:07:40 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u75E7ea7002916 for svn-soc-all@FreeBSD.org; Fri, 5 Aug 2016 14:07:40 GMT (envelope-from vincenzo@FreeBSD.org) Date: Fri, 5 Aug 2016 14:07:40 GMT Message-Id: <201608051407.u75E7ea7002916@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r307234 - soc2016/vincenzo/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2016 14:07:41 -0000 Author: vincenzo Date: Fri Aug 5 14:07:39 2016 New Revision: 307234 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=307234 Log: bhyve: ptnet: redirect PCI read/write to the MSI-X emulation code Modified: soc2016/vincenzo/head/usr.sbin/bhyve/pci_ptnetmap_netif.c Modified: soc2016/vincenzo/head/usr.sbin/bhyve/pci_ptnetmap_netif.c ============================================================================== --- soc2016/vincenzo/head/usr.sbin/bhyve/pci_ptnetmap_netif.c Fri Aug 5 14:07:02 2016 (r307233) +++ soc2016/vincenzo/head/usr.sbin/bhyve/pci_ptnetmap_netif.c Fri Aug 5 14:07:39 2016 (r307234) @@ -195,39 +195,6 @@ sc->ioregs[PTNET_IO_PTSTS >> 2] = ret; } -static uint64_t -ptnet_bar_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, - int baridx, uint64_t offset, int size) -{ - struct ptnet_softc *sc = pi->pi_arg; - - if (sc == NULL) - return 0; - - offset &= PTNET_IO_MASK; - - if (baridx == PTNETMAP_IO_PCI_BAR && offset < PTNET_IO_END) { - switch (offset) { - case PTNET_IO_NIFP_OFS: - case PTNET_IO_NUM_TX_RINGS: - case PTNET_IO_NUM_RX_RINGS: - case PTNET_IO_NUM_TX_SLOTS: - case PTNET_IO_NUM_RX_SLOTS: - /* Fill in device registers with information about - * nifp_offset, num_*x_rings, and num_*x_slots. */ - ptnet_get_netmap_if(sc); - - default: - return sc->ioregs[offset >> 2]; - } - } - - fprintf(stderr, "%s: Unexpected register read [bar %u, offset %lx " - "size %d]\n", __func__, baridx, offset, size); - - return 0; -} - static void ptnet_csb_mapping(struct ptnet_softc *sc) { @@ -248,6 +215,13 @@ struct ptnet_softc *sc = pi->pi_arg; unsigned int index; + /* Redirect to MSI-X emulation code. */ + if (baridx == pci_msix_table_bar(pi) || + baridx == pci_msix_pba_bar(pi)) { + pci_emul_msix_twrite(pi, offset, size, value); + return; + } + if (sc == NULL) return; @@ -290,6 +264,44 @@ "size %d value %lx]\n", __func__, baridx, offset, size, value); } +static uint64_t +ptnet_bar_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, + int baridx, uint64_t offset, int size) +{ + struct ptnet_softc *sc = pi->pi_arg; + + if (baridx == pci_msix_table_bar(pi) || + baridx == pci_msix_pba_bar(pi)) { + return pci_emul_msix_tread(pi, offset, size); + } + + if (sc == NULL) + return 0; + + offset &= PTNET_IO_MASK; + + if (baridx == PTNETMAP_IO_PCI_BAR && offset < PTNET_IO_END) { + switch (offset) { + case PTNET_IO_NIFP_OFS: + case PTNET_IO_NUM_TX_RINGS: + case PTNET_IO_NUM_RX_RINGS: + case PTNET_IO_NUM_TX_SLOTS: + case PTNET_IO_NUM_RX_SLOTS: + /* Fill in device registers with information about + * nifp_offset, num_*x_rings, and num_*x_slots. */ + ptnet_get_netmap_if(sc); + + default: + return sc->ioregs[offset >> 2]; + } + } + + fprintf(stderr, "%s: Unexpected register read [bar %u, offset %lx " + "size %d]\n", __func__, baridx, offset, size); + + return 0; +} + /* PCI device initialization. */ static int ptnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)