diff -r 9a3eb754fe2b sys/dev/virtio/network/if_vtnet.c --- a/sys/dev/virtio/network/if_vtnet.c Fri Feb 26 16:18:47 2016 +0000 +++ b/sys/dev/virtio/network/if_vtnet.c Fri Feb 26 14:03:46 2016 -0800 @@ -653,6 +653,13 @@ } else max_pairs = 1; + /* + * This value needs to be saved before we limit it below because + * the control virtqueue is located after all the virtqueues the + * device advertises support for. + */ + sc->vtnet_device_max_vq_pairs = max_pairs; + if (max_pairs > 1) { /* * Limit the maximum number of queue pairs to the number of @@ -738,7 +745,7 @@ { int i, npairs, error; - npairs = sc->vtnet_max_vq_pairs; + npairs = sc->vtnet_device_max_vq_pairs; sc->vtnet_rxqs = malloc(sizeof(struct vtnet_rxq) * npairs, M_DEVBUF, M_NOWAIT | M_ZERO); @@ -806,14 +813,14 @@ int i; if (sc->vtnet_rxqs != NULL) { - for (i = 0; i < sc->vtnet_max_vq_pairs; i++) + for (i = 0; i < sc->vtnet_device_max_vq_pairs; i++) vtnet_destroy_rxq(&sc->vtnet_rxqs[i]); free(sc->vtnet_rxqs, M_DEVBUF); sc->vtnet_rxqs = NULL; } if (sc->vtnet_txqs != NULL) { - for (i = 0; i < sc->vtnet_max_vq_pairs; i++) + for (i = 0; i < sc->vtnet_device_max_vq_pairs; i++) vtnet_destroy_txq(&sc->vtnet_txqs[i]); free(sc->vtnet_txqs, M_DEVBUF); sc->vtnet_txqs = NULL; @@ -868,7 +875,7 @@ dev = sc->vtnet_dev; flags = 0; - nvqs = sc->vtnet_max_vq_pairs * 2; + nvqs = sc->vtnet_device_max_vq_pairs * 2; if (sc->vtnet_flags & VTNET_FLAG_CTRL_VQ) nvqs++; @@ -876,7 +883,7 @@ if (info == NULL) return (ENOMEM); - for (i = 0, idx = 0; i < sc->vtnet_max_vq_pairs; i++, idx+=2) { + for (i = 0, idx = 0; i < sc->vtnet_device_max_vq_pairs; i++, idx+=2) { rxq = &sc->vtnet_rxqs[i]; VQ_ALLOC_INFO_INIT(&info[idx], sc->vtnet_rx_nsegs, vtnet_rx_vq_intr, rxq, &rxq->vtnrx_vq, @@ -3848,6 +3855,9 @@ tree = device_get_sysctl_tree(dev); child = SYSCTL_CHILDREN(tree); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "device_max_vq_pairs", + CTLFLAG_RD, &sc->vtnet_device_max_vq_pairs, 0, + "Device supported virtqueue pairs"); SYSCTL_ADD_INT(ctx, child, OID_AUTO, "max_vq_pairs", CTLFLAG_RD, &sc->vtnet_max_vq_pairs, 0, "Maximum number of supported virtqueue pairs"); diff -r 9a3eb754fe2b sys/dev/virtio/network/if_vtnetvar.h --- a/sys/dev/virtio/network/if_vtnetvar.h Fri Feb 26 16:18:47 2016 +0000 +++ b/sys/dev/virtio/network/if_vtnetvar.h Fri Feb 26 14:03:46 2016 -0800 @@ -155,6 +155,7 @@ int vtnet_if_flags; int vtnet_act_vq_pairs; int vtnet_max_vq_pairs; + int vtnet_device_max_vq_pairs; struct virtqueue *vtnet_ctrl_vq; struct vtnet_mac_filter *vtnet_mac_filter;