RE: [PATCH net-next, 1/1] hv_netvsc: call dump_rndis_message() only in netvsc debug mode

2015-04-21 Thread Simon Xiao

> -Original Message-
> From: David Miller [mailto:da...@davemloft.net]
> Sent: Tuesday, April 21, 2015 2:49 PM
> To: Simon Xiao
> Cc: KY Srinivasan; Haiyang Zhang; de...@linuxdriverproject.org;
> net...@vger.kernel.org; linux-ker...@vger.kernel.org
> Subject: Re: [PATCH net-next,1/1] hv_netvsc: call dump_rndis_message() only in
> netvsc debug mode
> 
> From: six...@microsoft.com
> Date: Tue, 21 Apr 2015 15:58:05 -0700
> 
> > From: Simon Xiao 
> >
> > Signed-off-by: Simon Xiao 
> > Reviewed-by: K. Y. Srinivasan 
> > Reviewed-by: Haiyang Zhang 
> 
> I just gave you feedback on this patch in response to your original 
> submission,
> do not ignore it.

Thanks for your feedback, David.

In current netvsc driver, for each packet received, it will call 
dump_rndis_message() 
to try to dump the rndis packet information by netdev_dbg(). 
In non-debug mode, dump_rndis_message() will not dump anything 
but it still initialize some local variables and process the switch logic in 
the function 
of dump_rndis_message(), which is unnecessary, especially in high network 
throughput situation.

My change is to have a run-time config flag to control the execution of 
dump_rndis_message() 
and avoid above unnecessary cost in non-debug mode.
In the default case, it will be non-debug mode,
 and rndis_filter_receive() will not call dump_rndis_message() 
which saves the above extra cost for each packet received.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH net-next,v2,1/1] hv_netvsc: introduce netif-msg into netvsc module

2015-04-24 Thread Simon Xiao

> -Original Message-
> From: Joe Perches [mailto:j...@perches.com]
> Sent: Friday, April 24, 2015 1:29 PM
> To: Simon Xiao
> Cc: KY Srinivasan; Haiyang Zhang; de...@linuxdriverproject.org;
> net...@vger.kernel.org; linux-ker...@vger.kernel.org
> Subject: Re: [PATCH net-next,v2,1/1] hv_netvsc: introduce netif-msg into
> netvsc module
> 
> On Fri, 2015-04-24 at 11:34 -0700, six...@microsoft.com wrote:
> > From: Simon Xiao 
> >
> > 1. Introduce netif-msg to netvsc to control debug logging output and
> > keep msg_enable in netvsc_device_context so that it is kept
> > persistently.
> > 2. Only call dump_rndis_message() when NETIF_MSG_RX_ERR or above is
> > specified in netvsc module debug param.
> > In non-debug mode, in current code, dump_rndis_message() will not
> dump
> > anything but it still initialize some local variables and process the
> > switch logic which is unnecessary, especially in high network
> > throughput situation.
> 
> []
> 
> > diff --git a/drivers/net/hyperv/netvsc_drv.c
> > b/drivers/net/hyperv/netvsc_drv.c
> []
> > @@ -888,6 +891,11 @@ static int netvsc_probe(struct hv_device *dev,
> >
> > net_device_ctx = netdev_priv(net);
> > net_device_ctx->device_ctx = dev;
> > +   net_device_ctx->msg_enable = netif_msg_init(debug, default_msg);
> > +   if (netif_msg_probe(net_device_ctx))
> > +   netdev_dbg(net, "netvsc msg_enable: %d",
> > +  net_device_ctx->msg_enable);
> 
> Please use newlines to terminate formats.
> 
> It helps prevent log content interleaving when multiple processes are
> emitting output at the same time.
> 
> This could be shortened to use netif_ like:
> 
>   netif_dbg(net_device_ctx, probe, net, "netvsc_msg_enable: %d\n",
> net_device_ctx->msg_enable);
> 

Thanks Joe. I would like to leave this to my next patch as there are some 
places else in netvsc (rndis_filter.c) 
have the same usage. I would like to fix them in one patch to make them 
consistent.

Thanks,
Simon 


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH net-next,1/1] hv_netvsc: use per_cpu stats to calculate TX/RX data

2015-05-13 Thread Simon Xiao


> -Original Message-
> From: David Miller [mailto:da...@davemloft.net]
> Sent: Wednesday, May 13, 2015 9:52 PM
> To: Simon Xiao
> Cc: KY Srinivasan; Haiyang Zhang; de...@linuxdriverproject.org;
> net...@vger.kernel.org; linux-ker...@vger.kernel.org
> Subject: Re: [PATCH net-next,1/1] hv_netvsc: use per_cpu stats to calculate
> TX/RX data
> 
> From: six...@microsoft.com
> Date: Tue, 12 May 2015 15:50:02 -0700
> 
> > From: Simon Xiao 
> >
> > Current code does not lock anything when calculating the TX and RX stats.
> > As a result, the RX and TX data reported by ifconfig are not accuracy
> > in a system with high network throughput and multiple CPUs (in my
> > test, RX/TX = 83% between 2 HyperV VM nodes which have 8 vCPUs and 40G
> Ethernet).
> >
> > This patch fixed the above issue by using per_cpu stats.
> > netvsc_get_stats64() summarizes TX and RX data by iterating over all
> > CPUs to get their respective stats.
> >
> > Signed-off-by: Simon Xiao 
> > Reviewed-by: K. Y. Srinivasan 
> > Reviewed-by: Haiyang Zhang 
> > ---
> >  drivers/net/hyperv/hyperv_net.h |  9 +
> > drivers/net/hyperv/netvsc_drv.c | 80
> > -
> >  2 files changed, 81 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/hyperv/hyperv_net.h
> > b/drivers/net/hyperv/hyperv_net.h index 41071d3..5a92b36 100644
> > --- a/drivers/net/hyperv/hyperv_net.h
> > +++ b/drivers/net/hyperv/hyperv_net.h
> > @@ -611,6 +611,12 @@ struct multi_send_data {
> > u32 count; /* counter of batched packets */  };
> >
> > +struct netvsc_stats {
> > +   u64 packets;
> > +   u64 bytes;
> > +   struct u64_stats_sync s_sync;
> > +};
> > +
> >  /* The context of the netvsc device  */  struct net_device_context {
> > /* point back to our device context */ @@ -618,6 +624,9 @@ struct
> > net_device_context {
> > struct delayed_work dwork;
> > struct work_struct work;
> > u32 msg_enable; /* debug level */
> > +
> > +   struct netvsc_stats __percpu *tx_stats;
> > +   struct netvsc_stats __percpu *rx_stats;
> >  };
> >
> >  /* Per netvsc device */
> > diff --git a/drivers/net/hyperv/netvsc_drv.c
> > b/drivers/net/hyperv/netvsc_drv.c index 5993c7e..310b902 100644
> > --- a/drivers/net/hyperv/netvsc_drv.c
> > +++ b/drivers/net/hyperv/netvsc_drv.c
> > @@ -391,7 +391,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct
> net_device *net)
> > u32 skb_length;
> > u32 pkt_sz;
> > struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT];
> > -
> > +   struct netvsc_stats *tx_stats =
> > +this_cpu_ptr(net_device_ctx->tx_stats);
> >
> > /* We will atmost need two pages to describe the rndis
> >  * header. We can only transmit MAX_PAGE_BUFFER_COUNT number
> @@
> > -580,8 +580,10 @@ do_send:
> >
> >  drop:
> > if (ret == 0) {
> > -   net->stats.tx_bytes += skb_length;
> > -   net->stats.tx_packets++;
> > +   u64_stats_update_begin(&tx_stats->s_sync);
> > +   tx_stats->packets++;
> > +   tx_stats->bytes += skb_length;
> > +   u64_stats_update_end(&tx_stats->s_sync);
> > } else {
> > if (ret != -EAGAIN) {
> > dev_kfree_skb_any(skb);
> > @@ -644,13 +646,17 @@ int netvsc_recv_callback(struct hv_device
> *device_obj,
> > struct ndis_tcp_ip_checksum_info *csum_info)
> {
> > struct net_device *net;
> > +   struct net_device_context *net_device_ctx;
> > struct sk_buff *skb;
> > +   struct netvsc_stats *rx_stats;
> >
> > net = ((struct netvsc_device *)hv_get_drvdata(device_obj))->ndev;
> > if (!net || net->reg_state != NETREG_REGISTERED) {
> > packet->status = NVSP_STAT_FAIL;
> > return 0;
> > }
> > +   net_device_ctx = netdev_priv(net);
> > +   rx_stats = this_cpu_ptr(net_device_ctx->rx_stats);
> >
> > /* Allocate a skb - TODO direct I/O to pages? */
> > skb = netdev_alloc_skb_ip_align(net, packet->total_data_buflen); @@
> > -686,8 +692,10 @@ int netvsc_recv_callback(struct hv_device *device_obj,
> > skb_record_rx_queue(skb, packet->channel->
> > offermsg.offer.sub_channel_index);
> >
> > -   net->stats.rx_packets++;
> > -   net->stats.rx_bytes += packet->total_data_buflen;
> > +   u64_stats_update_begin(&rx

[PATCH net-next, v2, 1/1] hv_netvsc: use per_cpu stats to calculate TX/RX data

2015-05-13 Thread Simon Xiao
Current code does not lock anything when calculating the TX and RX stats.
As a result, the RX and TX data reported by ifconfig are not accuracy in a
system with high network throughput and multiple CPUs (in my test,
RX/TX = 83% between 2 HyperV VM nodes which have 8 vCPUs and 40G Ethernet).

This patch fixed the above issue by using per_cpu stats.
netvsc_get_stats64() summarizes TX and RX data by iterating over all CPUs
to get their respective stats.

This v2 patch addressed David's comments on the cleanup path when
netdev_alloc_pcpu_stats() failed.

Signed-off-by: Simon Xiao 
Reviewed-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h |  9 +
 drivers/net/hyperv/netvsc_drv.c | 85 +
 2 files changed, 86 insertions(+), 8 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 41071d3..5a92b36 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -611,6 +611,12 @@ struct multi_send_data {
u32 count; /* counter of batched packets */
 };
 
+struct netvsc_stats {
+   u64 packets;
+   u64 bytes;
+   struct u64_stats_sync s_sync;
+};
+
 /* The context of the netvsc device  */
 struct net_device_context {
/* point back to our device context */
@@ -618,6 +624,9 @@ struct net_device_context {
struct delayed_work dwork;
struct work_struct work;
u32 msg_enable; /* debug level */
+
+   struct netvsc_stats __percpu *tx_stats;
+   struct netvsc_stats __percpu *rx_stats;
 };
 
 /* Per netvsc device */
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 5993c7e..1570628 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -391,7 +391,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct 
net_device *net)
u32 skb_length;
u32 pkt_sz;
struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT];
-
+   struct netvsc_stats *tx_stats = this_cpu_ptr(net_device_ctx->tx_stats);
 
/* We will atmost need two pages to describe the rndis
 * header. We can only transmit MAX_PAGE_BUFFER_COUNT number
@@ -580,8 +580,10 @@ do_send:
 
 drop:
if (ret == 0) {
-   net->stats.tx_bytes += skb_length;
-   net->stats.tx_packets++;
+   u64_stats_update_begin(&tx_stats->s_sync);
+   tx_stats->packets++;
+   tx_stats->bytes += skb_length;
+   u64_stats_update_end(&tx_stats->s_sync);
} else {
if (ret != -EAGAIN) {
dev_kfree_skb_any(skb);
@@ -644,13 +646,17 @@ int netvsc_recv_callback(struct hv_device *device_obj,
struct ndis_tcp_ip_checksum_info *csum_info)
 {
struct net_device *net;
+   struct net_device_context *net_device_ctx;
struct sk_buff *skb;
+   struct netvsc_stats *rx_stats;
 
net = ((struct netvsc_device *)hv_get_drvdata(device_obj))->ndev;
if (!net || net->reg_state != NETREG_REGISTERED) {
packet->status = NVSP_STAT_FAIL;
return 0;
}
+   net_device_ctx = netdev_priv(net);
+   rx_stats = this_cpu_ptr(net_device_ctx->rx_stats);
 
/* Allocate a skb - TODO direct I/O to pages? */
skb = netdev_alloc_skb_ip_align(net, packet->total_data_buflen);
@@ -686,8 +692,10 @@ int netvsc_recv_callback(struct hv_device *device_obj,
skb_record_rx_queue(skb, packet->channel->
offermsg.offer.sub_channel_index);
 
-   net->stats.rx_packets++;
-   net->stats.rx_bytes += packet->total_data_buflen;
+   u64_stats_update_begin(&rx_stats->s_sync);
+   rx_stats->packets++;
+   rx_stats->bytes += packet->total_data_buflen;
+   u64_stats_update_end(&rx_stats->s_sync);
 
/*
 * Pass the skb back up. Network stack will deallocate the skb when it
@@ -753,6 +761,46 @@ static int netvsc_change_mtu(struct net_device *ndev, int 
mtu)
return 0;
 }
 
+static struct rtnl_link_stats64 *netvsc_get_stats64(struct net_device *net,
+   struct rtnl_link_stats64 *t)
+{
+   struct net_device_context *ndev_ctx = netdev_priv(net);
+   int cpu;
+
+   for_each_possible_cpu(cpu) {
+   struct netvsc_stats *tx_stats = per_cpu_ptr(ndev_ctx->tx_stats,
+   cpu);
+   struct netvsc_stats *rx_stats = per_cpu_ptr(ndev_ctx->rx_stats,
+   cpu);
+   u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
+   unsigned int start;
+
+   do {
+   start = u64_stats_fetch_begin_irq(&tx_stats->s_sync);
+ 

[PATCH net-next, 1/1] hv_netvsc: change member name of struct netvsc_stats

2015-05-15 Thread Simon Xiao
Currently the struct netvsc_stats has a member s_sync
of type u64_stats_sync.
This definition will break kernel build as the macro
netdev_alloc_pcpu_stats requires this member name to be syncp.
(see netdev_alloc_pcpu_stats definition in ./include/linux/netdevice.h)

This patch changes netvsc_stats's member name from s_sync to syncp to fix
the build break.

Signed-off-by: Simon Xiao 
---
 drivers/net/hyperv/hyperv_net.h |  2 +-
 drivers/net/hyperv/netvsc_drv.c | 16 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 5a92b36..ddcc7f8 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -614,7 +614,7 @@ struct multi_send_data {
 struct netvsc_stats {
u64 packets;
u64 bytes;
-   struct u64_stats_sync s_sync;
+   struct u64_stats_sync syncp;
 };
 
 /* The context of the netvsc device  */
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 0c858724..d9c88bc 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -580,10 +580,10 @@ do_send:
 
 drop:
if (ret == 0) {
-   u64_stats_update_begin(&tx_stats->s_sync);
+   u64_stats_update_begin(&tx_stats->syncp);
tx_stats->packets++;
tx_stats->bytes += skb_length;
-   u64_stats_update_end(&tx_stats->s_sync);
+   u64_stats_update_end(&tx_stats->syncp);
} else {
if (ret != -EAGAIN) {
dev_kfree_skb_any(skb);
@@ -692,10 +692,10 @@ int netvsc_recv_callback(struct hv_device *device_obj,
skb_record_rx_queue(skb, packet->channel->
offermsg.offer.sub_channel_index);
 
-   u64_stats_update_begin(&rx_stats->s_sync);
+   u64_stats_update_begin(&rx_stats->syncp);
rx_stats->packets++;
rx_stats->bytes += packet->total_data_buflen;
-   u64_stats_update_end(&rx_stats->s_sync);
+   u64_stats_update_end(&rx_stats->syncp);
 
/*
 * Pass the skb back up. Network stack will deallocate the skb when it
@@ -776,16 +776,16 @@ static struct rtnl_link_stats64 
*netvsc_get_stats64(struct net_device *net,
unsigned int start;
 
do {
-   start = u64_stats_fetch_begin_irq(&tx_stats->s_sync);
+   start = u64_stats_fetch_begin_irq(&tx_stats->syncp);
tx_packets = tx_stats->packets;
tx_bytes = tx_stats->bytes;
-   } while (u64_stats_fetch_retry_irq(&tx_stats->s_sync, start));
+   } while (u64_stats_fetch_retry_irq(&tx_stats->syncp, start));
 
do {
-   start = u64_stats_fetch_begin_irq(&rx_stats->s_sync);
+   start = u64_stats_fetch_begin_irq(&rx_stats->syncp);
rx_packets = rx_stats->packets;
rx_bytes = rx_stats->bytes;
-   } while (u64_stats_fetch_retry_irq(&rx_stats->s_sync, start));
+   } while (u64_stats_fetch_retry_irq(&rx_stats->syncp, start));
 
t->tx_bytes += tx_bytes;
t->tx_packets   += tx_packets;
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: linux-next network throughput performance regression

2015-11-09 Thread Simon Xiao
Thanks Eric to provide the data. I am looping Tom (as I am looking into his 
recent patches) and Olaf (from Suse).

So, if I understand it correctly, you are running netperf with single TCP 
connection, and you got ~26Gbps initially and got ~30Gbps after turning the 
tx-usecs and tx-frames.

Do you have a baseline on your environment for the best/max/or peak throughput?
Again, in my environment (SLES bare metal), if use SLES12 default kernel as a 
baseline, we can see significant performance drop (10% ~ 50%) on latest 
linux-next kernel. 
Absolutely I will try the same test on net-next soon and update the results to 
here later.

Thanks,
Simon


> -Original Message-
> From: Eric Dumazet [mailto:eric.duma...@gmail.com]
> Sent: Saturday, November 7, 2015 11:50 AM
> To: David Ahern 
> Cc: Simon Xiao ; de...@linuxdriverproject.org;
> net...@vger.kernel.org; linux-ker...@vger.kernel.org; David Miller
> ; KY Srinivasan ; Haiyang
> Zhang 
> Subject: Re: linux-next network throughput performance regression
> 
> On Sat, 2015-11-07 at 11:35 -0800, Eric Dumazet wrote:
> > On Fri, 2015-11-06 at 14:30 -0700, David Ahern wrote:
> > > On 11/6/15 2:18 PM, Simon Xiao wrote:
> > > > The .config file used to build linux-next kernel is attached to this 
> > > > mail.
> > >
> > > Thanks.
> > >
> > > Failed to notice this on the first response; my brain filled in. Why
> > > linux-next tree? Can you try net-next which is more relevant for
> > > this mailing list, post the top commit id and config file used?
> >
> > Throughput on a single TCP flow for a 40G NIC can be tricky to tune.
> >
> > Make sure IRQ are properly setup/balanced, as I know that IRQ names
> > were changed recently and your scripts might have not noticed...
> >
> > Also "ethtool -c eth0" might show very different interrupt coalescing
> > params ?
> >
> > I too have a Mellanox 40Gb in my lab and saw no difference in
> > performance with recent kernels.
> >
> > Of course, a simple "perf record -a -g sleep 4 ; perf report" might
> > point to some obvious issue. Like unexpected segmentation in case of
> > forwarding...
> >
> >
> 
> I did a test with current net tree on both sender and receiver
> 
> lpaa23:~# ./netperf -H 10.246.7.152
> MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to
> 10.246.7.152 () port 0 AF_INET
> Recv   SendSend
> Socket Socket  Message  Elapsed
> Size   SizeSize Time Throughput
> bytes  bytes   bytessecs.10^6bits/sec
> 
>  87380  16384  1638410.0026864.98
> lpaa23:~# ethtool -c eth1
> Coalesce parameters for eth1:
> Adaptive RX: on  TX: off
> stats-block-usecs: 0
> sample-interval: 0
> pkt-rate-low: 40
> pkt-rate-high: 45
> 
> rx-usecs: 16
> rx-frames: 44
> rx-usecs-irq: 0
> rx-frames-irq: 0
> 
> tx-usecs: 16
> tx-frames: 16
> tx-usecs-irq: 0
> tx-frames-irq: 256
> 
> rx-usecs-low: 0
> rx-frame-low: 0
> tx-usecs-low: 0
> tx-frame-low: 0
> 
> rx-usecs-high: 128
> rx-frame-high: 0
> tx-usecs-high: 0
> tx-frame-high: 0
> 
> lpaa23:~# ethtool -C eth1 tx-usecs 4 tx-frames 4


> lpaa23:~# ./netperf -H
> 10.246.7.152 MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0
> AF_INET to
> 10.246.7.152 () port 0 AF_INET
> Recv   SendSend
> Socket Socket  Message  Elapsed
> Size   SizeSize Time Throughput
> bytes  bytes   bytessecs.10^6bits/sec
> 
>  87380  16384  1638410.0030206.27
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next] hv_netvsc: Add feature flags NETIF_F_IPV6_CSUM and NETIF_F_TSO6 for netvsc

2016-02-03 Thread Simon Xiao
1. Adding NETIF_F_IPV6_CSUM and NETIF_F_TSO6 feature flags which are
supported by Hyper-V platform.
2. Cleanup the coding style of flag assignment by using macro.

Signed-off-by: Simon Xiao 
Reviewed-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/netvsc_drv.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 1d3a665..0cde741 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -43,6 +43,12 @@
 
 #define RING_SIZE_MIN 64
 #define LINKCHANGE_INT (2 * HZ)
+#define NETVSC_HW_FEATURES (NETIF_F_RXCSUM | \
+NETIF_F_SG | \
+NETIF_F_TSO | \
+NETIF_F_TSO6 | \
+NETIF_F_IP_CSUM | \
+NETIF_F_IPV6_CSUM)
 static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
@@ -1081,10 +1087,8 @@ static int netvsc_probe(struct hv_device *dev,
 
net->netdev_ops = &device_ops;
 
-   net->hw_features = NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_IP_CSUM |
-   NETIF_F_TSO;
-   net->features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_SG | NETIF_F_RXCSUM |
-   NETIF_F_IP_CSUM | NETIF_F_TSO;
+   net->hw_features = NETVSC_HW_FEATURES;
+   net->features = NETVSC_HW_FEATURES | NETIF_F_HW_VLAN_CTAG_TX;
 
net->ethtool_ops = ðtool_ops;
SET_NETDEV_DEV(net, &dev->device);
-- 
2.5.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 net-next] hv_netvsc: cleanup netdev feature flags for netvsc

2016-02-04 Thread Simon Xiao
1. Adding NETIF_F_TSO6 feature flag;
2. Adding NETIF_F_HW_CSUM. NETIF_F_IPV6_CSUM and NETIF_F_IP_CSUM are 
being deprecated;
3. Cleanup the coding style of flag assignment by using macro.

Signed-off-by: Simon Xiao 
Reviewed-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/netvsc_drv.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 1d3a665..c72e5b8 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -43,6 +43,11 @@
 
 #define RING_SIZE_MIN 64
 #define LINKCHANGE_INT (2 * HZ)
+#define NETVSC_HW_FEATURES (NETIF_F_RXCSUM | \
+NETIF_F_SG | \
+NETIF_F_TSO | \
+NETIF_F_TSO6 | \
+NETIF_F_HW_CSUM)
 static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
@@ -1081,10 +1086,8 @@ static int netvsc_probe(struct hv_device *dev,
 
net->netdev_ops = &device_ops;
 
-   net->hw_features = NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_IP_CSUM |
-   NETIF_F_TSO;
-   net->features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_SG | NETIF_F_RXCSUM |
-   NETIF_F_IP_CSUM | NETIF_F_TSO;
+   net->hw_features = NETVSC_HW_FEATURES;
+   net->features = NETVSC_HW_FEATURES | NETIF_F_HW_VLAN_CTAG_TX;
 
net->ethtool_ops = ðtool_ops;
SET_NETDEV_DEV(net, &dev->device);
-- 
2.5.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next] hv_netvsc: add software transmit timestamp support

2016-02-17 Thread Simon Xiao
Enable skb_tx_timestamp in hyperv netvsc.

Signed-off-by: Simon Xiao 
Reviewed-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/netvsc_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index c72e5b8..202e2b1 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -550,6 +550,8 @@ do_send:
packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size,
   skb, packet, &pb);
 
+   /* timestamp packet in software */
+   skb_tx_timestamp(skb);
ret = netvsc_send(net_device_ctx->device_ctx, packet,
  rndis_msg, &pb, skb);
 
@@ -920,6 +922,7 @@ static const struct ethtool_ops ethtool_ops = {
.get_link   = ethtool_op_get_link,
.get_channels   = netvsc_get_channels,
.set_channels   = netvsc_set_channels,
+   .get_ts_info= ethtool_op_get_ts_info,
 };
 
 static const struct net_device_ops device_ops = {
-- 
2.5.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next] hv_netvsc: add ethtool support for set and get of settings

2016-02-25 Thread Simon Xiao
This patch allows the user to set and retrieve speed and duplex of the
hv_netvsc device via ethtool.

Example:
$ ethtool eth0
Settings for eth0:
...
Speed: Unknown!
Duplex: Unknown! (255)
...
$ ethtool -s eth0 speed 1000 duplex full
$ ethtool eth0
Settings for eth0:
...
Speed: 1000Mb/s
Duplex: Full
...

This is based on patches by Roopa Prabhu and Nikolay Aleksandrov.

Signed-off-by: Simon Xiao 
---
 drivers/net/hyperv/hyperv_net.h |  4 +++
 drivers/net/hyperv/netvsc_drv.c | 56 +
 2 files changed, 60 insertions(+)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index fcb92c0..b4c6878 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -658,6 +658,10 @@ struct net_device_context {
 
struct netvsc_stats __percpu *tx_stats;
struct netvsc_stats __percpu *rx_stats;
+
+   /* Ethtool settings */
+   u8 duplex;
+   u32 speed;
 };
 
 /* Per netvsc device */
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 202e2b1..e703b9a 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -799,6 +799,58 @@ static int netvsc_set_channels(struct net_device *net,
goto do_set;
 }
 
+static bool netvsc_validate_ethtool_ss_cmd(const struct ethtool_cmd *cmd)
+{
+   struct ethtool_cmd diff1 = *cmd;
+   struct ethtool_cmd diff2 = {};
+
+   ethtool_cmd_speed_set(&diff1, 0);
+   diff1.duplex = 0;
+   /* advertising and cmd are usually set */
+   diff1.advertising = 0;
+   diff1.cmd = 0;
+   /* We set port to PORT_OTHER */
+   diff2.port = PORT_OTHER;
+
+   return !memcmp(&diff1, &diff2, sizeof(diff1));
+}
+
+static void netvsc_init_settings(struct net_device *dev)
+{
+   struct net_device_context *ndc = netdev_priv(dev);
+
+   ndc->speed = SPEED_UNKNOWN;
+   ndc->duplex = DUPLEX_UNKNOWN;
+}
+
+static int netvsc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+   struct net_device_context *ndc = netdev_priv(dev);
+
+   ethtool_cmd_speed_set(cmd, ndc->speed);
+   cmd->duplex = ndc->duplex;
+   cmd->port = PORT_OTHER;
+
+   return 0;
+}
+
+static int netvsc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+   struct net_device_context *ndc = netdev_priv(dev);
+   u32 speed;
+
+   speed = ethtool_cmd_speed(cmd);
+   if (!ethtool_validate_speed(speed) ||
+   !ethtool_validate_duplex(cmd->duplex) ||
+   !netvsc_validate_ethtool_ss_cmd(cmd))
+   return -EINVAL;
+
+   ndc->speed = speed;
+   ndc->duplex = cmd->duplex;
+
+   return 0;
+}
+
 static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 {
struct net_device_context *ndevctx = netdev_priv(ndev);
@@ -923,6 +975,8 @@ static const struct ethtool_ops ethtool_ops = {
.get_channels   = netvsc_get_channels,
.set_channels   = netvsc_set_channels,
.get_ts_info= ethtool_op_get_ts_info,
+   .get_settings   = netvsc_get_settings,
+   .set_settings   = netvsc_set_settings,
 };
 
 static const struct net_device_ops device_ops = {
@@ -1112,6 +1166,8 @@ static int netvsc_probe(struct hv_device *dev,
netif_set_real_num_tx_queues(net, nvdev->num_chn);
netif_set_real_num_rx_queues(net, nvdev->num_chn);
 
+   netvsc_init_settings(net);
+
ret = register_netdev(net);
if (ret != 0) {
pr_err("Unable to register netdev.\n");
-- 
2.5.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 1/1] hv_netvsc: fix a netvsc stats typo

2017-02-08 Thread Simon Xiao
Please ignore this patch. I will resubmit it to net-next.

> -Original Message-
> From: Simon Xiao [mailto:six...@microsoft.com]
> Sent: Tuesday, February 7, 2017 10:03 AM
> To: KY Srinivasan ; Haiyang Zhang
> ; Stephen Hemminger
> ; de...@linuxdriverproject.org;
> net...@vger.kernel.org; linux-ker...@vger.kernel.org
> Cc: Simon Xiao 
> Subject: [PATCH 1/1] hv_netvsc: fix a netvsc stats typo
> 
> [This sender failed our fraud detection checks and may not be who they
> appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]
> 
> Now, return the correct tx_errors stats in netvsc.
> 
> Signed-off-by: Simon Xiao 
> Reviewed-by: Haiyang Zhang 
> ---
>  drivers/net/hyperv/netvsc_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/hyperv/netvsc_drv.c
> b/drivers/net/hyperv/netvsc_drv.c
> index 72b0c1f..725ac19 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -920,7 +920,7 @@ static void netvsc_get_stats64(struct net_device *net,
> }
> 
> t->tx_dropped   = net->stats.tx_dropped;
> -   t->tx_errors= net->stats.tx_dropped;
> +   t->tx_errors= net->stats.tx_errors;
> 
> t->rx_dropped   = net->stats.rx_dropped;
> t->rx_errors= net->stats.rx_errors;
> --
> 2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


linux-next network throughput performance regression

2015-11-06 Thread Simon Xiao
I compared the network throughput performance on SLES12 bare metal servers, 
between SLES12 default kernel and latest linux-next (2015-11-05) kernel, based 
on the test results, I suspect there is a network regression exists on 
Linux-Next over the 40G Ethernet network:
a) iperf3 reports 50% performance drop with single TCP stream on latest 
linux-next;
b) iperf3 reports 10% ~ 30% performance drop with 2 to 128 TCP streams on 
latest linux-next;
Another throughput benchmarking tool (ntttcp-for-linux) test result is also 
listed at the end of the email for reference.


Server configuration:
--
Two servers (one client and one server, cross linked by 40G Ethernet), which 
have:
a) CPU: Intel(R) Xeon(R) CPU E5-2667 v3 @ 3.20GHz, 2 sockets, 16 CPUs, cache 
size : 20480 KB
b) Memory: 64 GB
c) Ethernet controller: Mellanox Technologies MT27520 Family [ConnectX-3 Pro], 
40G Ethernet, default driver


Test with iperf3:
--
iperf3: https://github.com/esnet/iperf

a) SLES12 default kernel, network throughput tested by iperf3:
Test Connections1   2   4   8   16  32  64  
128 
Throughput (G bps)  36.737.337.637.737.737.737.7
25.7

b) SLES12 + Linux-Next 20151105, network throughput tested by iperf3:
Test Connections1   2   4   8   16  32  64  
128
Throughput (G bps)  18.232.234.632.827.632.027.0
21.3
Percentage dropped  -50%-14%-8% -13%-27%-15%-28%
-17%


Test with ntttcp-for-linux:
--
ntttcp-for-linux: https://github.com/Microsoft/ntttcp-for-linux 

a) SLES12 default kernel, network throughput tested by ntttcp-for-linux:
Test Connections1   2   4   8   16  32  64  
128 256 512
Throughput (Gbps)   36.19   37.29   37.67   37.68   37.737.72   37.74   
37.76   37.81   37.9

b) SLES12 + Linux-Next 20151105, network throughput tested by ntttcp-for-linux:
Test Connections1   2   4   8   16  32  64  
128 256 512 
Throughput (Gbps)   28.12   34.01   37.636.53   32.94   33.07   33.63   
33.44   33.83   34.42   
Percentage dropped  -22%-9% 0%  -3% -13%-12%-11%
-11%-11%-9%
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel