From owner-svn-src-all@freebsd.org Mon Mar 14 08:48:17 2016 Return-Path: Delivered-To: svn-src-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 D0864AD07CB; Mon, 14 Mar 2016 08:48:17 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7A787F65; Mon, 14 Mar 2016 08:48:17 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2E8mGox074224; Mon, 14 Mar 2016 08:48:16 GMT (envelope-from gnn@FreeBSD.org) Received: (from gnn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2E8mGti074223; Mon, 14 Mar 2016 08:48:16 GMT (envelope-from gnn@FreeBSD.org) Message-Id: <201603140848.u2E8mGti074223@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gnn set sender to gnn@FreeBSD.org using -f From: "George V. Neville-Neil" Date: Mon, 14 Mar 2016 08:48:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296829 - head/usr.sbin/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Mar 2016 08:48:17 -0000 Author: gnn Date: Mon Mar 14 08:48:16 2016 New Revision: 296829 URL: https://svnweb.freebsd.org/changeset/base/296829 Log: Fix typo: nmd->cur_tx_ring should be used in pci_vtnet_netmap_writev() The buffer length should be checked to avoid overflow, but there is no API to get the slot length, so the hardcoded value is used. Return the currently-first request chain back to the available queue if there are no more packets. Report the link as up if we managed to open vale port. Use consistent coding style. Submitted by: btw MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D5595 Modified: head/usr.sbin/bhyve/pci_virtio_net.c Modified: head/usr.sbin/bhyve/pci_virtio_net.c ============================================================================== --- head/usr.sbin/bhyve/pci_virtio_net.c Mon Mar 14 07:26:38 2016 (r296828) +++ head/usr.sbin/bhyve/pci_virtio_net.c Mon Mar 14 08:48:16 2016 (r296829) @@ -381,7 +381,7 @@ pci_vtnet_tap_rx(struct pci_vtnet_softc vq_endchains(vq, 1); } -static int +static __inline int pci_vtnet_netmap_writev(struct nm_desc *nmd, struct iovec *iov, int iovcnt) { int r, i; @@ -396,7 +396,7 @@ pci_vtnet_netmap_writev(struct nm_desc * r++; if (r > nmd->last_tx_ring) r = nmd->first_tx_ring; - if (r == nmd->cur_rx_ring) + if (r == nmd->cur_tx_ring) break; continue; } @@ -405,6 +405,8 @@ pci_vtnet_netmap_writev(struct nm_desc * buf = NETMAP_BUF(ring, idx); for (i = 0; i < iovcnt; i++) { + if (len + iov[i].iov_len > 2048) + break; memcpy(&buf[len], iov[i].iov_base, iov[i].iov_len); len += iov[i].iov_len; } @@ -418,7 +420,7 @@ pci_vtnet_netmap_writev(struct nm_desc * return (len); } -static inline int +static __inline int pci_vtnet_netmap_readv(struct nm_desc *nmd, struct iovec *iov, int iovcnt) { int len = 0; @@ -548,6 +550,7 @@ pci_vtnet_netmap_rx(struct pci_vtnet_sof * No more packets, but still some avail ring * entries. Interrupt if needed/appropriate. */ + vq_retchain(vq); vq_endchains(vq, 0); return; } @@ -884,8 +887,9 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_NET); pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); - /* Link is up if we managed to open tap device. */ - sc->vsc_config.status = (opts == NULL || sc->vsc_tapfd >= 0); + /* Link is up if we managed to open tap device or vale port. */ + sc->vsc_config.status = (opts == NULL || sc->vsc_tapfd >= 0 || + sc->vsc_nmd != NULL); /* use BAR 1 to map MSI-X table and PBA, if we're using MSI-X */ if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix()))