* [PATCH net-next] Add support for netvsc build without CONFIG_SYSFS flag
@ 2014-05-07 22:45 Haiyang Zhang
2014-05-08 9:13 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Haiyang Zhang @ 2014-05-07 22:45 UTC (permalink / raw)
To: davem, netdev; +Cc: olaf, jasowang, driverdev-devel, linux-kernel, haiyangz
This change ensures the driver can be built successfully without the
CONFIG_SYSFS flag.
MS-TFS: 182270
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/net/hyperv/hyperv_net.h | 2 ++
drivers/net/hyperv/netvsc_drv.c | 12 +++++++++++-
drivers/net/hyperv/rndis_filter.c | 4 ++--
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 4b7df5a..23b96bc 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -87,6 +87,8 @@ struct ndis_recv_scale_cap { /* NDIS_RECEIVE_SCALE_CAPABILITIES */
#define HASH_KEYLEN NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
extern u8 netvsc_hash_key[];
+extern unsigned int netvsc_num_queue;
+
struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
struct ndis_obj_header hdr;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 939e3af..07896f3 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -52,6 +52,8 @@ static int ring_size = 128;
module_param(ring_size, int, S_IRUGO);
MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
+unsigned int netvsc_num_queue = 1;
+
static void do_set_multicast(struct work_struct *w)
{
struct net_device_context *ndevctx =
@@ -639,9 +641,11 @@ int netvsc_recv_callback(struct hv_device *device_obj,
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
packet->vlan_tci);
+#ifdef CONFIG_SYSFS
skb_record_rx_queue(skb, packet->channel->
offermsg.offer.sub_channel_index %
net->real_num_rx_queues);
+#endif
net->stats.rx_packets++;
net->stats.rx_bytes += packet->total_data_buflen;
@@ -788,7 +792,7 @@ static int netvsc_probe(struct hv_device *dev,
int ret;
net = alloc_etherdev_mq(sizeof(struct net_device_context),
- num_online_cpus());
+ netvsc_num_queue);
if (!net)
return -ENOMEM;
@@ -824,8 +828,10 @@ static int netvsc_probe(struct hv_device *dev,
nvdev = hv_get_drvdata(dev);
netif_set_real_num_tx_queues(net, nvdev->num_chn);
netif_set_real_num_rx_queues(net, nvdev->num_chn);
+#ifdef CONFIG_SYSFS
dev_info(&dev->device, "real num tx,rx queues:%u, %u\n",
net->real_num_tx_queues, net->real_num_rx_queues);
+#endif
ret = register_netdev(net);
if (ret != 0) {
@@ -897,6 +903,10 @@ static void __exit netvsc_drv_exit(void)
static int __init netvsc_drv_init(void)
{
+#ifdef CONFIG_SYSFS
+ netvsc_num_queue = num_online_cpus();
+#endif
+
if (ring_size < RING_SIZE_MIN) {
ring_size = RING_SIZE_MIN;
pr_info("Increased ring_size to %d (min allowed)\n",
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 99c527a..9db163c 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -1094,8 +1094,8 @@ int rndis_filter_device_add(struct hv_device *dev,
if (ret || rsscap.num_recv_que < 2)
goto out;
- net_device->num_chn = (num_online_cpus() < rsscap.num_recv_que) ?
- num_online_cpus() : rsscap.num_recv_que;
+ net_device->num_chn = (netvsc_num_queue < rsscap.num_recv_que) ?
+ netvsc_num_queue : rsscap.num_recv_que;
if (net_device->num_chn == 1)
goto out;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] Add support for netvsc build without CONFIG_SYSFS flag
2014-05-07 22:45 [PATCH net-next] Add support for netvsc build without CONFIG_SYSFS flag Haiyang Zhang
@ 2014-05-08 9:13 ` Greg KH
2014-05-08 15:13 ` Haiyang Zhang
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2014-05-08 9:13 UTC (permalink / raw)
To: Haiyang Zhang
Cc: olaf, netdev, jasowang, driverdev-devel, linux-kernel, davem
On Wed, May 07, 2014 at 03:45:04PM -0700, Haiyang Zhang wrote:
> This change ensures the driver can be built successfully without the
> CONFIG_SYSFS flag.
> MS-TFS: 182270
>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> drivers/net/hyperv/hyperv_net.h | 2 ++
> drivers/net/hyperv/netvsc_drv.c | 12 +++++++++++-
> drivers/net/hyperv/rndis_filter.c | 4 ++--
> 3 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
> index 4b7df5a..23b96bc 100644
> --- a/drivers/net/hyperv/hyperv_net.h
> +++ b/drivers/net/hyperv/hyperv_net.h
> @@ -87,6 +87,8 @@ struct ndis_recv_scale_cap { /* NDIS_RECEIVE_SCALE_CAPABILITIES */
> #define HASH_KEYLEN NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
> extern u8 netvsc_hash_key[];
>
> +extern unsigned int netvsc_num_queue;
> +
> struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
> struct ndis_obj_header hdr;
>
> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index 939e3af..07896f3 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -52,6 +52,8 @@ static int ring_size = 128;
> module_param(ring_size, int, S_IRUGO);
> MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
>
> +unsigned int netvsc_num_queue = 1;
> +
> static void do_set_multicast(struct work_struct *w)
> {
> struct net_device_context *ndevctx =
> @@ -639,9 +641,11 @@ int netvsc_recv_callback(struct hv_device *device_obj,
> __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
> packet->vlan_tci);
>
> +#ifdef CONFIG_SYSFS
> skb_record_rx_queue(skb, packet->channel->
> offermsg.offer.sub_channel_index %
> net->real_num_rx_queues);
> +#endif
Why is this a sysfs-only function? It should have nothing to do with
sysfs, right? So why would the driver care?
Don't put #ifdef in drivers, it's unmaintainable over time, if this
really is a sysfs-only function, this should already be handled
automatically in a .h file somewhere.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH net-next] Add support for netvsc build without CONFIG_SYSFS flag
2014-05-08 9:13 ` Greg KH
@ 2014-05-08 15:13 ` Haiyang Zhang
2014-05-08 19:07 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Haiyang Zhang @ 2014-05-08 15:13 UTC (permalink / raw)
To: Greg KH
Cc: olaf@aepfle.de, netdev@vger.kernel.org, jasowang@redhat.com,
driverdev-devel@linuxdriverproject.org,
linux-kernel@vger.kernel.org, davem@davemloft.net
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Thursday, May 8, 2014 5:13 AM
> To: Haiyang Zhang
> Cc: davem@davemloft.net; netdev@vger.kernel.org; olaf@aepfle.de;
> jasowang@redhat.com; driverdev-devel@linuxdriverproject.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH net-next] Add support for netvsc build without
> CONFIG_SYSFS flag
>
> On Wed, May 07, 2014 at 03:45:04PM -0700, Haiyang Zhang wrote:
> > This change ensures the driver can be built successfully without the
> > CONFIG_SYSFS flag.
> > MS-TFS: 182270
> >
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> > ---
> > drivers/net/hyperv/hyperv_net.h | 2 ++
> > drivers/net/hyperv/netvsc_drv.c | 12 +++++++++++-
> > drivers/net/hyperv/rndis_filter.c | 4 ++--
> > 3 files changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/hyperv/hyperv_net.h
> > b/drivers/net/hyperv/hyperv_net.h index 4b7df5a..23b96bc 100644
> > --- a/drivers/net/hyperv/hyperv_net.h
> > +++ b/drivers/net/hyperv/hyperv_net.h
> > @@ -87,6 +87,8 @@ struct ndis_recv_scale_cap { /*
> > NDIS_RECEIVE_SCALE_CAPABILITIES */ #define HASH_KEYLEN
> > NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
> > extern u8 netvsc_hash_key[];
> >
> > +extern unsigned int netvsc_num_queue;
> > +
> > struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
> > struct ndis_obj_header hdr;
> >
> > diff --git a/drivers/net/hyperv/netvsc_drv.c
> > b/drivers/net/hyperv/netvsc_drv.c index 939e3af..07896f3 100644
> > --- a/drivers/net/hyperv/netvsc_drv.c
> > +++ b/drivers/net/hyperv/netvsc_drv.c
> > @@ -52,6 +52,8 @@ static int ring_size = 128; module_param(ring_size,
> > int, S_IRUGO); MODULE_PARM_DESC(ring_size, "Ring buffer size (# of
> > pages)");
> >
> > +unsigned int netvsc_num_queue = 1;
> > +
> > static void do_set_multicast(struct work_struct *w) {
> > struct net_device_context *ndevctx = @@ -639,9 +641,11 @@ int
> > netvsc_recv_callback(struct hv_device *device_obj,
> > __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
> > packet->vlan_tci);
> >
> > +#ifdef CONFIG_SYSFS
> > skb_record_rx_queue(skb, packet->channel->
> > offermsg.offer.sub_channel_index %
> > net->real_num_rx_queues);
> > +#endif
>
> Why is this a sysfs-only function? It should have nothing to do with sysfs, right?
> So why would the driver care?
Without CONFIG_SYSFS the multi-receive queues are not allocated, see below, and
the variable real_num_rx_queues is not defined, so we skip this function.
In alloc_netdev_mqs(), file "net/core/dev.c":
#ifdef CONFIG_SYSFS
dev->num_rx_queues = rxqs;
dev->real_num_rx_queues = rxqs;
if (netif_alloc_rx_queues(dev))
goto free_all;
#endif
> Don't put #ifdef in drivers, it's unmaintainable over time, if this really is a sysfs-
> only function, this should already be handled automatically in a .h file
> somewhere.
OK, I will move the #ifdef into hyperv_net.h.
Thanks,
- Haiyang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] Add support for netvsc build without CONFIG_SYSFS flag
2014-05-08 15:13 ` Haiyang Zhang
@ 2014-05-08 19:07 ` Greg KH
2014-05-08 19:47 ` Haiyang Zhang
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2014-05-08 19:07 UTC (permalink / raw)
To: Haiyang Zhang
Cc: olaf@aepfle.de, netdev@vger.kernel.org, jasowang@redhat.com,
driverdev-devel@linuxdriverproject.org,
linux-kernel@vger.kernel.org, davem@davemloft.net
On Thu, May 08, 2014 at 03:13:19PM +0000, Haiyang Zhang wrote:
>
>
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Thursday, May 8, 2014 5:13 AM
> > To: Haiyang Zhang
> > Cc: davem@davemloft.net; netdev@vger.kernel.org; olaf@aepfle.de;
> > jasowang@redhat.com; driverdev-devel@linuxdriverproject.org; linux-
> > kernel@vger.kernel.org
> > Subject: Re: [PATCH net-next] Add support for netvsc build without
> > CONFIG_SYSFS flag
> >
> > On Wed, May 07, 2014 at 03:45:04PM -0700, Haiyang Zhang wrote:
> > > This change ensures the driver can be built successfully without the
> > > CONFIG_SYSFS flag.
> > > MS-TFS: 182270
> > >
> > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> > > ---
> > > drivers/net/hyperv/hyperv_net.h | 2 ++
> > > drivers/net/hyperv/netvsc_drv.c | 12 +++++++++++-
> > > drivers/net/hyperv/rndis_filter.c | 4 ++--
> > > 3 files changed, 15 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/net/hyperv/hyperv_net.h
> > > b/drivers/net/hyperv/hyperv_net.h index 4b7df5a..23b96bc 100644
> > > --- a/drivers/net/hyperv/hyperv_net.h
> > > +++ b/drivers/net/hyperv/hyperv_net.h
> > > @@ -87,6 +87,8 @@ struct ndis_recv_scale_cap { /*
> > > NDIS_RECEIVE_SCALE_CAPABILITIES */ #define HASH_KEYLEN
> > > NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
> > > extern u8 netvsc_hash_key[];
> > >
> > > +extern unsigned int netvsc_num_queue;
> > > +
> > > struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
> > > struct ndis_obj_header hdr;
> > >
> > > diff --git a/drivers/net/hyperv/netvsc_drv.c
> > > b/drivers/net/hyperv/netvsc_drv.c index 939e3af..07896f3 100644
> > > --- a/drivers/net/hyperv/netvsc_drv.c
> > > +++ b/drivers/net/hyperv/netvsc_drv.c
> > > @@ -52,6 +52,8 @@ static int ring_size = 128; module_param(ring_size,
> > > int, S_IRUGO); MODULE_PARM_DESC(ring_size, "Ring buffer size (# of
> > > pages)");
> > >
> > > +unsigned int netvsc_num_queue = 1;
> > > +
> > > static void do_set_multicast(struct work_struct *w) {
> > > struct net_device_context *ndevctx = @@ -639,9 +641,11 @@ int
> > > netvsc_recv_callback(struct hv_device *device_obj,
> > > __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
> > > packet->vlan_tci);
> > >
> > > +#ifdef CONFIG_SYSFS
> > > skb_record_rx_queue(skb, packet->channel->
> > > offermsg.offer.sub_channel_index %
> > > net->real_num_rx_queues);
> > > +#endif
> >
> > Why is this a sysfs-only function? It should have nothing to do with sysfs, right?
> > So why would the driver care?
>
> Without CONFIG_SYSFS the multi-receive queues are not allocated, see below, and
> the variable real_num_rx_queues is not defined, so we skip this function.
>
> In alloc_netdev_mqs(), file "net/core/dev.c":
> #ifdef CONFIG_SYSFS
> dev->num_rx_queues = rxqs;
> dev->real_num_rx_queues = rxqs;
> if (netif_alloc_rx_queues(dev))
> goto free_all;
> #endif
Then you need to structure your driver better :)
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH net-next] Add support for netvsc build without CONFIG_SYSFS flag
2014-05-08 19:07 ` Greg KH
@ 2014-05-08 19:47 ` Haiyang Zhang
0 siblings, 0 replies; 5+ messages in thread
From: Haiyang Zhang @ 2014-05-08 19:47 UTC (permalink / raw)
To: Greg KH
Cc: olaf@aepfle.de, netdev@vger.kernel.org, jasowang@redhat.com,
driverdev-devel@linuxdriverproject.org,
linux-kernel@vger.kernel.org, davem@davemloft.net
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Thursday, May 8, 2014 3:07 PM
> To: Haiyang Zhang
> Cc: davem@davemloft.net; netdev@vger.kernel.org; olaf@aepfle.de;
> jasowang@redhat.com; driverdev-devel@linuxdriverproject.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH net-next] Add support for netvsc build without
> CONFIG_SYSFS flag
>
> On Thu, May 08, 2014 at 03:13:19PM +0000, Haiyang Zhang wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Thursday, May 8, 2014 5:13 AM
> > > To: Haiyang Zhang
> > > Cc: davem@davemloft.net; netdev@vger.kernel.org; olaf@aepfle.de;
> > > jasowang@redhat.com; driverdev-devel@linuxdriverproject.org; linux-
> > > kernel@vger.kernel.org
> > > Subject: Re: [PATCH net-next] Add support for netvsc build without
> > > CONFIG_SYSFS flag
> > >
> > > On Wed, May 07, 2014 at 03:45:04PM -0700, Haiyang Zhang wrote:
> > > > This change ensures the driver can be built successfully without
> > > > the CONFIG_SYSFS flag.
> > > > MS-TFS: 182270
> > > >
> > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > ---
> > > > drivers/net/hyperv/hyperv_net.h | 2 ++
> > > > drivers/net/hyperv/netvsc_drv.c | 12 +++++++++++-
> > > > drivers/net/hyperv/rndis_filter.c | 4 ++--
> > > > 3 files changed, 15 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/net/hyperv/hyperv_net.h
> > > > b/drivers/net/hyperv/hyperv_net.h index 4b7df5a..23b96bc 100644
> > > > --- a/drivers/net/hyperv/hyperv_net.h
> > > > +++ b/drivers/net/hyperv/hyperv_net.h
> > > > @@ -87,6 +87,8 @@ struct ndis_recv_scale_cap { /*
> > > > NDIS_RECEIVE_SCALE_CAPABILITIES */ #define HASH_KEYLEN
> > > > NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
> > > > extern u8 netvsc_hash_key[];
> > > >
> > > > +extern unsigned int netvsc_num_queue;
> > > > +
> > > > struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS
> */
> > > > struct ndis_obj_header hdr;
> > > >
> > > > diff --git a/drivers/net/hyperv/netvsc_drv.c
> > > > b/drivers/net/hyperv/netvsc_drv.c index 939e3af..07896f3 100644
> > > > --- a/drivers/net/hyperv/netvsc_drv.c
> > > > +++ b/drivers/net/hyperv/netvsc_drv.c
> > > > @@ -52,6 +52,8 @@ static int ring_size = 128;
> > > > module_param(ring_size, int, S_IRUGO);
> > > > MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
> > > >
> > > > +unsigned int netvsc_num_queue = 1;
> > > > +
> > > > static void do_set_multicast(struct work_struct *w) {
> > > > struct net_device_context *ndevctx = @@ -639,9 +641,11 @@ int
> > > > netvsc_recv_callback(struct hv_device *device_obj,
> > > > __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
> > > > packet->vlan_tci);
> > > >
> > > > +#ifdef CONFIG_SYSFS
> > > > skb_record_rx_queue(skb, packet->channel->
> > > > offermsg.offer.sub_channel_index %
> > > > net->real_num_rx_queues);
> > > > +#endif
> > >
> > > Why is this a sysfs-only function? It should have nothing to do with sysfs,
> right?
> > > So why would the driver care?
> >
> > Without CONFIG_SYSFS the multi-receive queues are not allocated, see
> > below, and the variable real_num_rx_queues is not defined, so we skip this
> function.
> >
> > In alloc_netdev_mqs(), file "net/core/dev.c":
> > #ifdef CONFIG_SYSFS
> > dev->num_rx_queues = rxqs;
> > dev->real_num_rx_queues = rxqs;
> > if (netif_alloc_rx_queues(dev))
> > goto free_all;
> > #endif
>
> Then you need to structure your driver better :)
I have submitted an update patch.
Thanks,
- Haiyang
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-08 19:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-07 22:45 [PATCH net-next] Add support for netvsc build without CONFIG_SYSFS flag Haiyang Zhang
2014-05-08 9:13 ` Greg KH
2014-05-08 15:13 ` Haiyang Zhang
2014-05-08 19:07 ` Greg KH
2014-05-08 19:47 ` Haiyang Zhang
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).