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
This commit is contained in:
parent
f54153bb08
commit
69ab30910f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296829
@ -381,7 +381,7 @@ pci_vtnet_tap_rx(struct pci_vtnet_softc *sc)
|
||||
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 *nmd, struct iovec *iov, int iovcnt)
|
||||
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 *nmd, struct iovec *iov, int iovcnt)
|
||||
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 *nmd, struct iovec *iov, int iovcnt)
|
||||
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_softc *sc)
|
||||
* 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_devinst *pi, char *opts)
|
||||
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()))
|
||||
|
Loading…
Reference in New Issue
Block a user