Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/virtio/network/if_vtnet.c
Show First 20 Lines • Show All 651 Lines • ▼ Show 20 Lines | #ifndef VTNET_LEGACY_TX | ||||
if (vtnet_tunable_int(sc, "mq_disable", vtnet_mq_disable)) | if (vtnet_tunable_int(sc, "mq_disable", vtnet_mq_disable)) | ||||
features &= ~VIRTIO_NET_F_MQ; | features &= ~VIRTIO_NET_F_MQ; | ||||
#else | #else | ||||
features &= ~VIRTIO_NET_F_MQ; | features &= ~VIRTIO_NET_F_MQ; | ||||
#endif | #endif | ||||
negotiated_features = virtio_negotiate_features(dev, features); | negotiated_features = virtio_negotiate_features(dev, features); | ||||
if (virtio_with_feature(dev, VIRTIO_NET_F_MQ)) { | |||||
uint16_t npairs; | |||||
npairs = virtio_read_dev_config_2(dev, | |||||
offsetof(struct virtio_net_config, max_virtqueue_pairs)); | |||||
if (npairs < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN || | |||||
npairs > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX) { | |||||
device_printf(dev, "Invalid max_virtqueue_pairs value: " | |||||
"%d. Multiqueue feature disabled.\n", npairs); | |||||
features &= ~VIRTIO_NET_F_MQ; | |||||
negotiated_features = | |||||
virtio_negotiate_features(dev, features); | |||||
} | |||||
} | |||||
if (virtio_with_feature(dev, VTNET_LRO_FEATURES) && | if (virtio_with_feature(dev, VTNET_LRO_FEATURES) && | ||||
virtio_with_feature(dev, VIRTIO_NET_F_MRG_RXBUF) == 0) { | virtio_with_feature(dev, VIRTIO_NET_F_MRG_RXBUF) == 0) { | ||||
/* | /* | ||||
* LRO without mergeable buffers requires special care. This | * LRO without mergeable buffers requires special care. This | ||||
* is not ideal because every receive buffer must be large | * is not ideal because every receive buffer must be large | ||||
* enough to hold the maximum TCP packet, the Ethernet header, | * enough to hold the maximum TCP packet, the Ethernet header, | ||||
* and the header. This requires up to 34 descriptors with | * and the header. This requires up to 34 descriptors with | ||||
* MCLBYTES clusters. If we do not have indirect descriptors, | * MCLBYTES clusters. If we do not have indirect descriptors, | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if (virtio_with_feature(dev, VIRTIO_NET_F_CTRL_VQ)) { | ||||
if (virtio_with_feature(dev, VIRTIO_NET_F_MQ)) { | if (virtio_with_feature(dev, VIRTIO_NET_F_MQ)) { | ||||
sc->vtnet_max_vq_pairs = virtio_read_dev_config_2(dev, | sc->vtnet_max_vq_pairs = virtio_read_dev_config_2(dev, | ||||
offsetof(struct virtio_net_config, | offsetof(struct virtio_net_config, | ||||
max_virtqueue_pairs)); | max_virtqueue_pairs)); | ||||
} | } | ||||
} | } | ||||
if (sc->vtnet_max_vq_pairs > 1) { | if (sc->vtnet_max_vq_pairs > 1) { | ||||
int max; | int req; | ||||
/* | /* | ||||
* Limit the maximum number of queue pairs to the lower of | * Limit the maximum number of requested queue pairs to the | ||||
* the number of CPUs and the configured maximum. The actual | * number of CPUs and the configured maximum. | ||||
* number of queues that get used may be less. | |||||
*/ | */ | ||||
max = vtnet_tunable_int(sc, "mq_max_pairs", vtnet_mq_max_pairs); | req = vtnet_tunable_int(sc, "mq_max_pairs", vtnet_mq_max_pairs); | ||||
if (max > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN) { | if (req < 1) | ||||
if (max > mp_ncpus) | req = 1; | ||||
max = mp_ncpus; | if (req > sc->vtnet_max_vq_pairs) | ||||
if (max > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX) | req = sc->vtnet_max_vq_pairs; | ||||
max = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX; | if (req > mp_ncpus) | ||||
if (max > 1) { | req = mp_ncpus; | ||||
sc->vtnet_requested_vq_pairs = max; | if (req > 1) { | ||||
sc->vtnet_req_vq_pairs = req; | |||||
sc->vtnet_flags |= VTNET_FLAG_MQ; | sc->vtnet_flags |= VTNET_FLAG_MQ; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
static int | static int | ||||
vtnet_init_rxq(struct vtnet_softc *sc, int id) | vtnet_init_rxq(struct vtnet_softc *sc, int id) | ||||
{ | { | ||||
struct vtnet_rxq *rxq; | struct vtnet_rxq *rxq; | ||||
rxq = &sc->vtnet_rxqs[id]; | rxq = &sc->vtnet_rxqs[id]; | ||||
▲ Show 20 Lines • Show All 2,473 Lines • ▼ Show 20 Lines | vtnet_set_active_vq_pairs(struct vtnet_softc *sc) | ||||
dev = sc->vtnet_dev; | dev = sc->vtnet_dev; | ||||
if ((sc->vtnet_flags & VTNET_FLAG_MQ) == 0) { | if ((sc->vtnet_flags & VTNET_FLAG_MQ) == 0) { | ||||
sc->vtnet_act_vq_pairs = 1; | sc->vtnet_act_vq_pairs = 1; | ||||
return; | return; | ||||
} | } | ||||
npairs = sc->vtnet_requested_vq_pairs; | npairs = sc->vtnet_req_vq_pairs; | ||||
if (vtnet_ctrl_mq_cmd(sc, npairs) != 0) { | if (vtnet_ctrl_mq_cmd(sc, npairs) != 0) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"cannot set active queue pairs to %d\n", npairs); | "cannot set active queue pairs to %d\n", npairs); | ||||
npairs = 1; | npairs = 1; | ||||
} | } | ||||
sc->vtnet_act_vq_pairs = npairs; | sc->vtnet_act_vq_pairs = npairs; | ||||
▲ Show 20 Lines • Show All 883 Lines • ▼ Show 20 Lines | vtnet_setup_sysctl(struct vtnet_softc *sc) | ||||
dev = sc->vtnet_dev; | dev = sc->vtnet_dev; | ||||
ctx = device_get_sysctl_ctx(dev); | ctx = device_get_sysctl_ctx(dev); | ||||
tree = device_get_sysctl_tree(dev); | tree = device_get_sysctl_tree(dev); | ||||
child = SYSCTL_CHILDREN(tree); | child = SYSCTL_CHILDREN(tree); | ||||
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "max_vq_pairs", | SYSCTL_ADD_INT(ctx, child, OID_AUTO, "max_vq_pairs", | ||||
CTLFLAG_RD, &sc->vtnet_max_vq_pairs, 0, | CTLFLAG_RD, &sc->vtnet_max_vq_pairs, 0, | ||||
"Number of maximum supported virtqueue pairs"); | "Number of maximum supported virtqueue pairs"); | ||||
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "requested_vq_pairs", | SYSCTL_ADD_INT(ctx, child, OID_AUTO, "req_vq_pairs", | ||||
CTLFLAG_RD, &sc->vtnet_requested_vq_pairs, 0, | CTLFLAG_RD, &sc->vtnet_req_vq_pairs, 0, | ||||
"Number of requested virtqueue pairs"); | "Number of requested virtqueue pairs"); | ||||
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "act_vq_pairs", | SYSCTL_ADD_INT(ctx, child, OID_AUTO, "act_vq_pairs", | ||||
CTLFLAG_RD, &sc->vtnet_act_vq_pairs, 0, | CTLFLAG_RD, &sc->vtnet_act_vq_pairs, 0, | ||||
"Number of active virtqueue pairs"); | "Number of active virtqueue pairs"); | ||||
vtnet_setup_stat_sysctl(ctx, child, sc); | vtnet_setup_stat_sysctl(ctx, child, sc); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines |