virtio-net: remove layout assumptions for mq ctrl
Following commit 921ac5d0f3
(virtio-net:
remove layout assumptions for ctrl vq), this patch makes multiqueue ctrl
handling not rely on the layout of descriptors.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
15054fce2d
commit
f8f7c533e2
|
@ -578,13 +578,14 @@ static int virtio_net_handle_vlan_table(VirtIONet *n, uint8_t cmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
|
static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
|
||||||
VirtQueueElement *elem)
|
struct iovec *iov, unsigned int iov_cnt)
|
||||||
{
|
{
|
||||||
struct virtio_net_ctrl_mq s;
|
struct virtio_net_ctrl_mq mq;
|
||||||
|
size_t s;
|
||||||
|
uint16_t queues;
|
||||||
|
|
||||||
if (elem->out_num != 2 ||
|
s = iov_to_buf(iov, iov_cnt, 0, &mq, sizeof(mq));
|
||||||
elem->out_sg[1].iov_len != sizeof(struct virtio_net_ctrl_mq)) {
|
if (s != sizeof(mq)) {
|
||||||
error_report("virtio-net ctrl invalid steering command");
|
|
||||||
return VIRTIO_NET_ERR;
|
return VIRTIO_NET_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,16 +593,16 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
|
||||||
return VIRTIO_NET_ERR;
|
return VIRTIO_NET_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&s, elem->out_sg[1].iov_base, sizeof(struct virtio_net_ctrl_mq));
|
queues = lduw_p(&mq.virtqueue_pairs);
|
||||||
|
|
||||||
if (s.virtqueue_pairs < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN ||
|
if (queues < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN ||
|
||||||
s.virtqueue_pairs > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX ||
|
queues > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX ||
|
||||||
s.virtqueue_pairs > n->max_queues ||
|
queues > n->max_queues ||
|
||||||
!n->multiqueue) {
|
!n->multiqueue) {
|
||||||
return VIRTIO_NET_ERR;
|
return VIRTIO_NET_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
n->curr_queues = s.virtqueue_pairs;
|
n->curr_queues = queues;
|
||||||
/* stop the backend before changing the number of queues to avoid handling a
|
/* stop the backend before changing the number of queues to avoid handling a
|
||||||
* disabled queue */
|
* disabled queue */
|
||||||
virtio_net_set_status(&n->vdev, n->vdev.status);
|
virtio_net_set_status(&n->vdev, n->vdev.status);
|
||||||
|
@ -639,7 +640,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
} else if (ctrl.class == VIRTIO_NET_CTRL_VLAN) {
|
} else if (ctrl.class == VIRTIO_NET_CTRL_VLAN) {
|
||||||
status = virtio_net_handle_vlan_table(n, ctrl.cmd, iov, iov_cnt);
|
status = virtio_net_handle_vlan_table(n, ctrl.cmd, iov, iov_cnt);
|
||||||
} else if (ctrl.class == VIRTIO_NET_CTRL_MQ) {
|
} else if (ctrl.class == VIRTIO_NET_CTRL_MQ) {
|
||||||
status = virtio_net_handle_mq(n, ctrl.cmd, &elem);
|
status = virtio_net_handle_mq(n, ctrl.cmd, iov, iov_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = iov_from_buf(elem.in_sg, elem.in_num, 0, &status, sizeof(status));
|
s = iov_from_buf(elem.in_sg, elem.in_num, 0, &status, sizeof(status));
|
||||||
|
|
Loading…
Reference in a new issue