Print this page

        

*** 8,18 **** * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* ! * Copyright 2013 Nexenta Inc. All rights reserved. * Copyright (c) 2014, 2015 by Delphix. All rights reserved. */ /* Based on the NetBSD virtio driver by Minoura Makoto. */ /* --- 8,18 ---- * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* ! * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014, 2015 by Delphix. All rights reserved. */ /* Based on the NetBSD virtio driver by Minoura Makoto. */ /*
*** 382,391 **** --- 382,392 ---- vioif_link_state(struct vioif_softc *sc) { if (sc->sc_virtio.sc_features & VIRTIO_NET_F_STATUS) { if (virtio_read_device_config_2(&sc->sc_virtio, VIRTIO_NET_CONFIG_STATUS) & VIRTIO_NET_S_LINK_UP) { + return (LINK_STATE_UP); } else { return (LINK_STATE_DOWN); } }
*** 693,707 **** struct vq_entry *ve; struct vioif_rx_buf *buf; ve = vq_alloc_entry(sc->sc_rx_vq); if (!ve) { ! /* ! * Out of free descriptors - ring already full. ! * It would be better to update sc_norxdescavail ! * but MAC does not ask for this info, hence we ! * update sc_norecvbuf. */ sc->sc_norecvbuf++; goto exit_vq; } buf = sc->sc_rxbufs[ve->qe_index]; --- 694,707 ---- struct vq_entry *ve; struct vioif_rx_buf *buf; ve = vq_alloc_entry(sc->sc_rx_vq); if (!ve) { ! /* Out of free descriptors - ring already full. ! * would be better to update sc_norxdescavail ! * but MAC does not ask for this info ! * hence update sc_norecvbuf */ sc->sc_norecvbuf++; goto exit_vq; } buf = sc->sc_rxbufs[ve->qe_index];
*** 842,860 **** } mp->b_wptr = mp->b_rptr + len; atomic_inc_ulong(&sc->sc_rxloan); /* ! * Buffer loaned, we will have to allocte a new one * for this slot. */ sc->sc_rxbufs[ve->qe_index] = NULL; } ! ! /* ! * virtio-net does not tell us if this packet is multicast ! * or broadcast, so we have to check it. */ if (mp->b_rptr[0] & 0x1) { if (bcmp(mp->b_rptr, vioif_broadcast, ETHERADDRL) != 0) sc->sc_multircv++; else --- 842,858 ---- } mp->b_wptr = mp->b_rptr + len; atomic_inc_ulong(&sc->sc_rxloan); /* ! * Buffer loanded, we will have to allocate a new one * for this slot. */ sc->sc_rxbufs[ve->qe_index] = NULL; } ! /* virtio-net does not provide the info if this packet ! * is multicast or broadcast. So we have to check it */ if (mp->b_rptr[0] & 0x1) { if (bcmp(mp->b_rptr, vioif_broadcast, ETHERADDRL) != 0) sc->sc_multircv++; else
*** 1314,1324 **** case MAC_PROP_PRIVATE: err = vioif_set_prop_private(sc, pr_name, pr_valsize, pr_val); if (err) return (err); - break; default: return (ENOTSUP); } return (0); --- 1312,1321 ----
*** 1371,1389 **** static void vioif_propinfo(void *arg, const char *pr_name, mac_prop_id_t pr_num, mac_prop_info_handle_t prh) { struct vioif_softc *sc = arg; - char valstr[64]; - int value; switch (pr_num) { case MAC_PROP_MTU: mac_prop_info_set_range_uint32(prh, ETHERMIN, MAX_MTU); break; ! case MAC_PROP_PRIVATE: bzero(valstr, sizeof (valstr)); if (strcmp(pr_name, vioif_txcopy_thresh) == 0) { value = sc->sc_txcopy_thresh; } else if (strcmp(pr_name, --- 1368,1387 ---- static void vioif_propinfo(void *arg, const char *pr_name, mac_prop_id_t pr_num, mac_prop_info_handle_t prh) { struct vioif_softc *sc = arg; switch (pr_num) { case MAC_PROP_MTU: mac_prop_info_set_range_uint32(prh, ETHERMIN, MAX_MTU); break; ! case MAC_PROP_PRIVATE: { ! char valstr[64]; ! int value; ! bzero(valstr, sizeof (valstr)); if (strcmp(pr_name, vioif_txcopy_thresh) == 0) { value = sc->sc_txcopy_thresh; } else if (strcmp(pr_name,
*** 1391,1402 **** value = sc->sc_rxcopy_thresh; } else { return; } (void) snprintf(valstr, sizeof (valstr), "%d", value); ! break; ! default: break; } } --- 1389,1399 ---- value = sc->sc_rxcopy_thresh; } else { return; } (void) snprintf(valstr, sizeof (valstr), "%d", value); ! } default: break; } }
*** 1452,1533 **** static void vioif_show_features(struct vioif_softc *sc, const char *prefix, uint32_t features) { char buf[512]; - char *bufp = buf; - char *bufend = buf + sizeof (buf); ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, prefix); ! ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += virtio_show_features(features, bufp, bufend - bufp); ! ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "Vioif ( "); ! ! if (features & VIRTIO_NET_F_CSUM) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "CSUM "); ! if (features & VIRTIO_NET_F_GUEST_CSUM) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "GUEST_CSUM "); ! if (features & VIRTIO_NET_F_MAC) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "MAC "); ! if (features & VIRTIO_NET_F_GSO) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "GSO "); ! if (features & VIRTIO_NET_F_GUEST_TSO4) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "GUEST_TSO4 "); ! if (features & VIRTIO_NET_F_GUEST_TSO6) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "GUEST_TSO6 "); ! if (features & VIRTIO_NET_F_GUEST_ECN) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "GUEST_ECN "); ! if (features & VIRTIO_NET_F_GUEST_UFO) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "GUEST_UFO "); ! if (features & VIRTIO_NET_F_HOST_TSO4) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "HOST_TSO4 "); ! if (features & VIRTIO_NET_F_HOST_TSO6) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "HOST_TSO6 "); ! if (features & VIRTIO_NET_F_HOST_ECN) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "HOST_ECN "); ! if (features & VIRTIO_NET_F_HOST_UFO) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "HOST_UFO "); ! if (features & VIRTIO_NET_F_MRG_RXBUF) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "MRG_RXBUF "); ! if (features & VIRTIO_NET_F_STATUS) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "STATUS "); ! if (features & VIRTIO_NET_F_CTRL_VQ) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "CTRL_VQ "); ! if (features & VIRTIO_NET_F_CTRL_RX) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "CTRL_RX "); ! if (features & VIRTIO_NET_F_CTRL_VLAN) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "CTRL_VLAN "); ! if (features & VIRTIO_NET_F_CTRL_RX_EXTRA) ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, "CTRL_RX_EXTRA "); ! ! /* LINTED E_PTRDIFF_OVERFLOW */ ! bufp += snprintf(bufp, bufend - bufp, ")"); ! *bufp = '\0'; ! ! dev_err(sc->sc_dev, CE_NOTE, "%s", buf); } /* * Find out which features are supported by the device and * choose which ones we wish to use. --- 1449,1460 ---- static void vioif_show_features(struct vioif_softc *sc, const char *prefix, uint32_t features) { char buf[512]; ! dev_err(sc->sc_dev, CE_NOTE, "%s %s Vioif (%b)", prefix, virtio_show_features(...), features, "\020\1CSUM\2GUEST_CSUM\3MAC\4GSO\5GUEST_TSO4\5GUEST_TSO6\6GUEST_ECN\7GUEST_UFO\8HOST_TSO4\9HOST_TSO6\10HOST_ECN\11HOST_UFO\12MRG_RXBUF\13STATUS\14CTRL_VQ\15CTRL_RX\16CTRL_VLAN\17CTRL_RX_EXTRA", buf); } /* * Find out which features are supported by the device and * choose which ones we wish to use.
*** 1545,1555 **** VIRTIO_NET_F_STATUS | VIRTIO_F_RING_INDIRECT_DESC | VIRTIO_F_NOTIFY_ON_EMPTY); vioif_show_features(sc, "Host features: ", host_features); ! vioif_show_features(sc, "Negotiated features: ", sc->sc_virtio.sc_features); if (!(sc->sc_virtio.sc_features & VIRTIO_F_RING_INDIRECT_DESC)) { dev_err(sc->sc_dev, CE_NOTE, "Host does not support RING_INDIRECT_DESC, bye."); --- 1472,1482 ---- VIRTIO_NET_F_STATUS | VIRTIO_F_RING_INDIRECT_DESC | VIRTIO_F_NOTIFY_ON_EMPTY); vioif_show_features(sc, "Host features: ", host_features); ! vioif_show_features(sc, ", sc->sc_virtio.sc_features); if (!(sc->sc_virtio.sc_features & VIRTIO_F_RING_INDIRECT_DESC)) { dev_err(sc->sc_dev, CE_NOTE, "Host does not support RING_INDIRECT_DESC, bye.");
*** 1702,1716 **** case DDI_ATTACH: break; case DDI_RESUME: case DDI_PM_RESUME: ! /* not supported yet */ goto exit; default: ! /* unrecognized command */ goto exit; } sc = kmem_zalloc(sizeof (struct vioif_softc), KM_SLEEP); ddi_set_driver_private(devinfo, sc); --- 1629,1643 ---- case DDI_ATTACH: break; case DDI_RESUME: case DDI_PM_RESUME: ! dev_err(devinfo, CE_WARN, "resume not supported yet"); goto exit; default: ! dev_err(devinfo, CE_WARN, "cmd 0x%x unrecognized", cmd); goto exit; } sc = kmem_zalloc(sizeof (struct vioif_softc), KM_SLEEP); ddi_set_driver_private(devinfo, sc);
*** 1885,1904 **** switch (cmd) { case DDI_DETACH: break; case DDI_PM_SUSPEND: ! /* not supported yet */ return (DDI_FAILURE); default: ! /* unrecognized command */ return (DDI_FAILURE); } if (sc->sc_rxloan) { ! cmn_err(CE_NOTE, "Some rx buffers are still upstream, " "Not detaching"); return (DDI_FAILURE); } virtio_stop_vq_intr(sc->sc_rx_vq); --- 1812,1831 ---- switch (cmd) { case DDI_DETACH: break; case DDI_PM_SUSPEND: ! cmn_err(CE_WARN, "suspend not supported yet"); return (DDI_FAILURE); default: ! cmn_err(CE_WARN, "cmd 0x%x unrecognized", cmd); return (DDI_FAILURE); } if (sc->sc_rxloan) { ! cmn_err(CE_WARN, "Some rx buffers are still upstream, " "Not detaching"); return (DDI_FAILURE); } virtio_stop_vq_intr(sc->sc_rx_vq);
*** 1950,1959 **** --- 1877,1887 ---- mac_init_ops(&vioif_ops, "vioif"); ret = mod_install(&modlinkage); if (ret != DDI_SUCCESS) { mac_fini_ops(&vioif_ops); + cmn_err(CE_WARN, "Unable to install the driver"); return (ret); } return (0); }