From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: krkumar2@in.ibm.com, kvm@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org,
bhutchings@solarflare.com, jwhan@filewood.snu.ac.kr,
shiyer@redhat.com
Subject: Re: [net-next rfc v7 3/3] virtio-net: change the number of queues through ethtool
Date: Mon, 3 Dec 2012 13:25:07 +0200 [thread overview]
Message-ID: <20121203112507.GE26167@redhat.com> (raw)
In-Reply-To: <7408756.Sj6HEpCzzZ@jason-thinkpad-t430s>
On Mon, Dec 03, 2012 at 02:09:28PM +0800, Jason Wang wrote:
> On Sunday, December 02, 2012 06:09:06 PM Michael S. Tsirkin wrote:
> > On Tue, Nov 27, 2012 at 06:16:00PM +0800, Jason Wang wrote:
> > > This patch implement the {set|get}_channels method of ethool to allow user
> > > to change the number of queues dymaically when the device is running.
> > > This would let the user to configure it on demand.
> > >
> > > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > > ---
> > >
> > > drivers/net/virtio_net.c | 41 +++++++++++++++++++++++++++++++++++++++++
> > > 1 files changed, 41 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > index bcaa6e5..f08ec2a 100644
> > > --- a/drivers/net/virtio_net.c
> > > +++ b/drivers/net/virtio_net.c
> > > @@ -1578,10 +1578,51 @@ static struct virtio_driver virtio_net_driver = {
> > >
> > > #endif
> > > };
> > >
> > > +/* TODO: Eliminate OOO packets during switching */
> > > +static int virtnet_set_channels(struct net_device *dev,
> > > + struct ethtool_channels *channels)
> > > +{
> > > + struct virtnet_info *vi = netdev_priv(dev);
> > > + u16 queue_pairs = channels->combined_count;
by the way shouldn't this be combined_count / 2?
And below channels->max_combined = vi->max_queue_pairs * 2; ?
> > > +
> > > + /* We don't support separate rx/tx channels.
> > > + * We don't allow setting 'other' channels.
> > > + */
> > > + if (channels->rx_count || channels->tx_count || channels->other_count)
> > > + return -EINVAL;
> > > +
> > > + /* Only two modes were support currently */
> > > + if (queue_pairs != vi->max_queue_pairs && queue_pairs != 1)
> > > + return -EINVAL;
> > > +
> >
> > Why the limitation?
>
> Not sure the value bettwen 1 and max_queue_pairs is useful. But anyway, I can
> remove this limitation.
I guess a reasonable value would be number of active CPUs,
which can change with CPU hotplug.
> > Also how does userspace discover what the legal values are?
>
> Userspace only check whether the value is greater than max_queue_pairs.
Exactly. One can query max combined but the fact that configuring
any less is impossible might be surprising.
> >
> > > + vi->curr_queue_pairs = queue_pairs;
> > > + BUG_ON(virtnet_set_queues(vi));
> > > +
> > > + netif_set_real_num_tx_queues(dev, vi->curr_queue_pairs);
> > > + netif_set_real_num_rx_queues(dev, vi->curr_queue_pairs);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +static void virtnet_get_channels(struct net_device *dev,
> > > + struct ethtool_channels *channels)
> > > +{
> > > + struct virtnet_info *vi = netdev_priv(dev);
> > > +
> > > + channels->combined_count = vi->curr_queue_pairs;
> > > + channels->max_combined = vi->max_queue_pairs;
> > > + channels->max_other = 0;
> > > + channels->rx_count = 0;
> > > + channels->tx_count = 0;
> > > + channels->other_count = 0;
> > > +}
> > > +
> > >
> > > static const struct ethtool_ops virtnet_ethtool_ops = {
> > >
> > > .get_drvinfo = virtnet_get_drvinfo,
> > > .get_link = ethtool_op_get_link,
> > > .get_ringparam = virtnet_get_ringparam,
> > >
> > > + .set_channels = virtnet_set_channels,
> > > + .get_channels = virtnet_get_channels,
> > >
> > > };
> > >
> > > static int __init init(void)
> >
> > --
> > 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:[~2012-12-03 11:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 10:15 [net-next rfc v7 0/3] Multiqueue virtio-net Jason Wang
2012-11-27 10:15 ` [net-next rfc v7 1/3] virtio-net: separate fields of sending/receiving queue from virtnet_info Jason Wang
2012-12-03 1:55 ` Rusty Russell
2012-12-03 5:15 ` Jason Wang
2012-12-03 11:18 ` Michael S. Tsirkin
2012-12-04 9:22 ` Jason Wang
2012-12-04 3:43 ` Rusty Russell
2012-12-04 9:23 ` Jason Wang
2012-11-27 10:15 ` [net-next rfc v7 2/3] virtio_net: multiqueue support Jason Wang
2012-12-02 16:06 ` Michael S. Tsirkin
2012-12-03 2:04 ` Rusty Russell
2012-12-03 6:05 ` Jason Wang
2012-12-03 9:47 ` Michael S. Tsirkin
2012-12-03 10:01 ` Jason Wang
2012-12-03 11:11 ` Michael S. Tsirkin
[not found] ` <20121203111118.GC26167@redhat.com>
2012-12-04 9:24 ` Jason Wang
[not found] ` <20121202160631.GA27761@redhat.com>
2012-12-03 5:47 ` Jason Wang
2012-12-03 10:14 ` Michael S. Tsirkin
[not found] ` <20121203101436.GB23009@redhat.com>
2012-12-03 10:30 ` Jason Wang
2012-12-03 11:00 ` Michael S. Tsirkin
2012-12-04 7:35 ` Michael S. Tsirkin
2012-12-04 9:27 ` Jason Wang
2012-11-27 10:16 ` [net-next rfc v7 3/3] virtio-net: change the number of queues through ethtool Jason Wang
2012-12-02 16:09 ` Michael S. Tsirkin
2012-12-03 6:09 ` Jason Wang
2012-12-03 11:25 ` Michael S. Tsirkin [this message]
2012-12-04 0:22 ` Ben Hutchings
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=20121203112507.GE26167@redhat.com \
--to=mst@redhat.com \
--cc=bhutchings@solarflare.com \
--cc=jasowang@redhat.com \
--cc=jwhan@filewood.snu.ac.kr \
--cc=krkumar2@in.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shiyer@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).