On Fri, Jan 4, 2013 at 5:12 AM, Jason Wang <jasowang@xxxxxxxxxx> wrote: > On 12/29/2012 01:52 AM, Blue Swirl wrote: >> On Fri, Dec 28, 2012 at 10:32 AM, Jason Wang <jasowang@xxxxxxxxxx> wrote: >>> This patch implements both userspace and vhost support for multiple queue >>> virtio-net (VIRTIO_NET_F_MQ). This is done by introducing an array of >>> VirtIONetQueue to VirtIONet. >>> >>> Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx> >>> --- >>> hw/virtio-net.c | 318 ++++++++++++++++++++++++++++++++++++++++++------------- >>> hw/virtio-net.h | 27 +++++- >>> 2 files changed, 271 insertions(+), 74 deletions(-) > [...] >>> static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) >>> { >>> VirtIONet *n = to_virtio_net(vdev); >>> @@ -464,6 +578,8 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) >>> status = virtio_net_handle_mac(n, ctrl.cmd, &elem); >>> else if (ctrl.class == VIRTIO_NET_CTRL_VLAN) >>> status = virtio_net_handle_vlan_table(n, ctrl.cmd, &elem); >>> + else if (ctrl.class == VIRTIO_NET_CTRL_MQ) >> Please add braces. > > Sure. >> >>> + status = virtio_net_handle_mq(n, ctrl.cmd, &elem); >>> >>> stb_p(elem.in_sg[elem.in_num - 1].iov_base, status); >>> >>> @@ -477,19 +593,24 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) >>> static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq) >>> { >>> VirtIONet *n = to_virtio_net(vdev); >>> + int queue_index = vq2q(virtio_get_queue_index(vq)); >>> >>> - qemu_flush_queued_packets(qemu_get_queue(n->nic)); >>> + qemu_flush_queued_packets(qemu_get_subqueue(n->nic, queue_index)); >>> } >>> >>> > [...] >>> >>> +static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue, int ctrl) >>> +{ >>> + VirtIODevice *vdev = &n->vdev; >>> + int i; >>> + >>> + n->multiqueue = multiqueue; >>> + >>> + if (!multiqueue) >>> + n->curr_queues = 1; >> Ditto. Didn't checkpatch.pl catch these or did you not check? > > Sorry, will add braces here. I run checkpatch.pl but finally find that > some or lots of the existed codes (such as this file) does not obey the > rules. So I'm not sure whether I need to correct my own codes, or left > them as this file does and correct them all in the future. The goal is to make QEMU codebase conform to CODING_STYLE. Currently this is not the case for some amounts of code, but we should use opportunities like this to advance towards that goal. >> > [...] >>> } QEMU_PACKED; >>> >>> /* This is the first element of the scatter-gather list. If you don't >>> @@ -168,6 +172,26 @@ struct virtio_net_ctrl_mac { >>> #define VIRTIO_NET_CTRL_VLAN_ADD 0 >>> #define VIRTIO_NET_CTRL_VLAN_DEL 1 >>> >>> +/* >>> + * Control Multiqueue >>> + * >>> + * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET >>> + * enables multiqueue, specifying the number of the transmit and >>> + * receive queues that will be used. After the command is consumed and acked by >>> + * the device, the device will not steer new packets on receive virtqueues >>> + * other than specified nor read from transmit virtqueues other than specified. >>> + * Accordingly, driver should not transmit new packets on virtqueues other than >>> + * specified. >>> + */ >>> +struct virtio_net_ctrl_mq { >> VirtIONetCtrlMQ and please don't forget the typedef. > > Sure, but the same question as above. (See other structures in this file). >> >>> + uint16_t virtqueue_pairs; >>> +}; >>> + >>> +#define VIRTIO_NET_CTRL_MQ 4 >>> + #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 >>> + #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 >>> + #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 >>> + >>> #define DEFINE_VIRTIO_NET_FEATURES(_state, _field) \ >>> DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \ >>> DEFINE_PROP_BIT("csum", _state, _field, VIRTIO_NET_F_CSUM, true), \ >>> @@ -186,5 +210,6 @@ struct virtio_net_ctrl_mac { >>> DEFINE_PROP_BIT("ctrl_vq", _state, _field, VIRTIO_NET_F_CTRL_VQ, true), \ >>> DEFINE_PROP_BIT("ctrl_rx", _state, _field, VIRTIO_NET_F_CTRL_RX, true), \ >>> DEFINE_PROP_BIT("ctrl_vlan", _state, _field, VIRTIO_NET_F_CTRL_VLAN, true), \ >>> - DEFINE_PROP_BIT("ctrl_rx_extra", _state, _field, VIRTIO_NET_F_CTRL_RX_EXTRA, true) >>> + DEFINE_PROP_BIT("ctrl_rx_extra", _state, _field, VIRTIO_NET_F_CTRL_RX_EXTRA, true), \ >>> + DEFINE_PROP_BIT("mq", _state, _field, VIRTIO_NET_F_MQ, true) >>> #endif >>> -- >>> 1.7.1 >>> >>> > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html