From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: krkumar2@in.ibm.com, Anthony Liguori <aliguori@us.ibm.com>,
kvm@vger.kernel.org, mprivozn@redhat.com, rusty@rustcorp.com.au,
qemu-devel@nongnu.org, Blue Swirl <blauwirbel@gmail.com>,
shajnocz@redhat.com, shiyer@redhat.com, jwhan@filewood.snu.ac.kr,
gaowanlong@cn.fujitsu.com
Subject: Re: [PATCH V2 11/20] tap: support enabling or disabling a queue
Date: Wed, 30 Jan 2013 17:46:18 +0800 [thread overview]
Message-ID: <5108EBEA.5090203@redhat.com> (raw)
In-Reply-To: <20130129230312.GA2914@redhat.com>
On 01/30/2013 07:03 AM, Michael S. Tsirkin wrote:
> On Tue, Jan 29, 2013 at 04:55:25PM -0600, Anthony Liguori wrote:
>> "Michael S. Tsirkin" <mst@redhat.com> writes:
>>
>>> On Tue, Jan 29, 2013 at 08:10:26PM +0000, Blue Swirl wrote:
>>>> On Tue, Jan 29, 2013 at 1:50 PM, Jason Wang <jasowang@redhat.com> wrote:
>>>>> On 01/26/2013 03:13 AM, Blue Swirl wrote:
>>>>>> On Fri, Jan 25, 2013 at 10:35 AM, Jason Wang <jasowang@redhat.com> wrote:
>>>>>>> This patch introduce a new bit - enabled in TAPState which tracks whether a
>>>>>>> specific queue/fd is enabled. The tap/fd is enabled during initialization and
>>>>>>> could be enabled/disabled by tap_enalbe() and tap_disable() which calls platform
>>>>>>> specific helpers to do the real work. Polling of a tap fd can only done when
>>>>>>> the tap was enabled.
>>>>>>>
>>>>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>>>>>> ---
>>>>>>> include/net/tap.h | 2 ++
>>>>>>> net/tap-win32.c | 10 ++++++++++
>>>>>>> net/tap.c | 43 ++++++++++++++++++++++++++++++++++++++++---
>>>>>>> 3 files changed, 52 insertions(+), 3 deletions(-)
>>>>>>>
>>>>>>> diff --git a/include/net/tap.h b/include/net/tap.h
>>>>>>> index bb7efb5..0caf8c4 100644
>>>>>>> --- a/include/net/tap.h
>>>>>>> +++ b/include/net/tap.h
>>>>>>> @@ -35,6 +35,8 @@ int tap_has_vnet_hdr_len(NetClientState *nc, int len);
>>>>>>> void tap_using_vnet_hdr(NetClientState *nc, int using_vnet_hdr);
>>>>>>> void tap_set_offload(NetClientState *nc, int csum, int tso4, int tso6, int ecn, int ufo);
>>>>>>> void tap_set_vnet_hdr_len(NetClientState *nc, int len);
>>>>>>> +int tap_enable(NetClientState *nc);
>>>>>>> +int tap_disable(NetClientState *nc);
>>>>>>>
>>>>>>> int tap_get_fd(NetClientState *nc);
>>>>>>>
>>>>>>> diff --git a/net/tap-win32.c b/net/tap-win32.c
>>>>>>> index 265369c..a2cd94b 100644
>>>>>>> --- a/net/tap-win32.c
>>>>>>> +++ b/net/tap-win32.c
>>>>>>> @@ -764,3 +764,13 @@ void tap_set_vnet_hdr_len(NetClientState *nc, int len)
>>>>>>> {
>>>>>>> assert(0);
>>>>>>> }
>>>>>>> +
>>>>>>> +int tap_enable(NetClientState *nc)
>>>>>>> +{
>>>>>>> + assert(0);
>>>>>> abort()
>>>>> This is just to be consistent with the reset of the helpers in this file.
>>>>>>> +}
>>>>>>> +
>>>>>>> +int tap_disable(NetClientState *nc)
>>>>>>> +{
>>>>>>> + assert(0);
>>>>>>> +}
>>>>>>> diff --git a/net/tap.c b/net/tap.c
>>>>>>> index 67080f1..95e557b 100644
>>>>>>> --- a/net/tap.c
>>>>>>> +++ b/net/tap.c
>>>>>>> @@ -59,6 +59,7 @@ typedef struct TAPState {
>>>>>>> unsigned int write_poll : 1;
>>>>>>> unsigned int using_vnet_hdr : 1;
>>>>>>> unsigned int has_ufo: 1;
>>>>>>> + unsigned int enabled : 1;
>>>>>> bool without bit field?
>>>>> Also to be consistent with other field. If you wish I can send patches
>>>>> to convert all those bit field to bool on top of this series.
>>>> That would be nice, likewise for the assert(0).
>>> OK so let's go ahead with this patchset as is,
>>> and a cleanup patch will be send after 1.4 then.
>> Why? I'd prefer that we didn't rush things into 1.4 just because.
>> There's still ample time to respin a corrected series.
>>
>> Regards,
>>
>> Anthony Liguori
> Confused. Do you want the coding style rework of net/tap.c
> switching it from assert(0)/bitfields to abort()/bool for 1.4?
I will send a new series with the patches that addresses Blue's comments
on assert(0) and bitfields.
Thanks
>>>
>>>>> Thanks
>>>>>>> VHostNetState *vhost_net;
>>>>>>> unsigned host_vnet_hdr_len;
>>>>>>> } TAPState;
>>>>>>> @@ -72,9 +73,9 @@ static void tap_writable(void *opaque);
>>>>>>> static void tap_update_fd_handler(TAPState *s)
>>>>>>> {
>>>>>>> qemu_set_fd_handler2(s->fd,
>>>>>>> - s->read_poll ? tap_can_send : NULL,
>>>>>>> - s->read_poll ? tap_send : NULL,
>>>>>>> - s->write_poll ? tap_writable : NULL,
>>>>>>> + s->read_poll && s->enabled ? tap_can_send : NULL,
>>>>>>> + s->read_poll && s->enabled ? tap_send : NULL,
>>>>>>> + s->write_poll && s->enabled ? tap_writable : NULL,
>>>>>>> s);
>>>>>>> }
>>>>>>>
>>>>>>> @@ -339,6 +340,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer,
>>>>>>> s->host_vnet_hdr_len = vnet_hdr ? sizeof(struct virtio_net_hdr) : 0;
>>>>>>> s->using_vnet_hdr = 0;
>>>>>>> s->has_ufo = tap_probe_has_ufo(s->fd);
>>>>>>> + s->enabled = 1;
>>>>>>> tap_set_offload(&s->nc, 0, 0, 0, 0, 0);
>>>>>>> /*
>>>>>>> * Make sure host header length is set correctly in tap:
>>>>>>> @@ -737,3 +739,38 @@ VHostNetState *tap_get_vhost_net(NetClientState *nc)
>>>>>>> assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
>>>>>>> return s->vhost_net;
>>>>>>> }
>>>>>>> +
>>>>>>> +int tap_enable(NetClientState *nc)
>>>>>>> +{
>>>>>>> + TAPState *s = DO_UPCAST(TAPState, nc, nc);
>>>>>>> + int ret;
>>>>>>> +
>>>>>>> + if (s->enabled) {
>>>>>>> + return 0;
>>>>>>> + } else {
>>>>>>> + ret = tap_fd_enable(s->fd);
>>>>>>> + if (ret == 0) {
>>>>>>> + s->enabled = 1;
>>>>>>> + tap_update_fd_handler(s);
>>>>>>> + }
>>>>>>> + return ret;
>>>>>>> + }
>>>>>>> +}
>>>>>>> +
>>>>>>> +int tap_disable(NetClientState *nc)
>>>>>>> +{
>>>>>>> + TAPState *s = DO_UPCAST(TAPState, nc, nc);
>>>>>>> + int ret;
>>>>>>> +
>>>>>>> + if (s->enabled == 0) {
>>>>>>> + return 0;
>>>>>>> + } else {
>>>>>>> + ret = tap_fd_disable(s->fd);
>>>>>>> + if (ret == 0) {
>>>>>>> + qemu_purge_queued_packets(nc);
>>>>>>> + s->enabled = 0;
>>>>>>> + tap_update_fd_handler(s);
>>>>>>> + }
>>>>>>> + return ret;
>>>>>>> + }
>>>>>>> +}
>>>>>>> --
>>>>>>> 1.7.1
>>>>>>>
>>>>>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-01-30 9:46 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 10:35 [PATCH V2 00/20] Multiqueue virtio-net Jason Wang
2013-01-25 10:35 ` [PATCH V2 01/20] net: introduce qemu_get_queue() Jason Wang
2013-01-25 10:35 ` [PATCH V2 02/20] net: introduce qemu_get_nic() Jason Wang
2013-01-25 10:35 ` [PATCH V2 03/20] net: intorduce qemu_del_nic() Jason Wang
2013-01-25 10:35 ` [PATCH V2 04/20] net: introduce qemu_find_net_clients_except() Jason Wang
2013-01-25 10:35 ` [PATCH V2 05/20] net: introduce qemu_net_client_setup() Jason Wang
2013-01-25 10:35 ` [PATCH V2 06/20] net: introduce NetClientState destructor Jason Wang
2013-01-25 10:35 ` [PATCH V2 07/20] net: multiqueue support Jason Wang
2013-01-25 10:35 ` [PATCH V2 08/20] tap: import linux multiqueue constants Jason Wang
2013-01-25 10:35 ` [PATCH V2 09/20] tap: factor out common tap initialization Jason Wang
2013-01-25 10:35 ` [PATCH V2 10/20] tap: add Linux multiqueue support Jason Wang
2013-01-25 10:35 ` [PATCH V2 11/20] tap: support enabling or disabling a queue Jason Wang
2013-01-25 19:13 ` [Qemu-devel] " Blue Swirl
2013-01-29 13:50 ` Jason Wang
2013-01-29 20:10 ` Blue Swirl
2013-01-29 22:11 ` [Qemu-devel] " Michael S. Tsirkin
2013-01-29 22:55 ` Anthony Liguori
2013-01-29 23:03 ` Michael S. Tsirkin
2013-01-30 9:46 ` Jason Wang [this message]
2013-01-25 10:35 ` [PATCH V2 12/20] tap: introduce a helper to get the name of an interface Jason Wang
2013-01-25 10:35 ` [PATCH V2 13/20] tap: multiqueue support Jason Wang
2013-01-25 10:35 ` [PATCH V2 14/20] vhost: " Jason Wang
2013-01-29 13:53 ` Jason Wang
2013-01-25 10:35 ` [PATCH V2 15/20] virtio: introduce virtio_del_queue() Jason Wang
2013-01-25 10:35 ` [PATCH V2 16/20] virtio: add a queue_index to VirtQueue Jason Wang
2013-01-25 10:35 ` [PATCH V2 17/20] virtio-net: separate virtqueue from VirtIONet Jason Wang
2013-01-25 10:35 ` [PATCH V2 18/20] virtio-net: multiqueue support Jason Wang
2013-01-25 10:35 ` [PATCH V2 19/20] virtio-net: migration support for multiqueue Jason Wang
2013-01-25 10:35 ` [PATCH V2 20/20] virtio-net: compat multiqueue support Jason Wang
2013-01-28 3:27 ` [PATCH V2 00/20] Multiqueue virtio-net Wanlong Gao
2013-01-28 4:24 ` [Qemu-devel] " Jason Wang
2013-01-29 5:36 ` Wanlong Gao
2013-01-29 5:44 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5108EBEA.5090203@redhat.com \
--to=jasowang@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=gaowanlong@cn.fujitsu.com \
--cc=jwhan@filewood.snu.ac.kr \
--cc=krkumar2@in.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mprivozn@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rusty@rustcorp.com.au \
--cc=shajnocz@redhat.com \
--cc=shiyer@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox