aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Xiao <sixiao@microsoft.com>2017-09-29 14:39:46 -0400
committerDavid S. Miller <davem@davemloft.net>2017-09-30 23:10:30 -0400
commit09af87d18f6ba05588e6316c47fdacf06e28cce8 (patch)
tree15e85eec8cb6d92fbd5386303d3c70836e90385c
parent721e08dad17e226ef68819d0a23dc53c25fe8ea5 (diff)
hv_netvsc: report stop_queue and wake_queue
Report the numbers of events for stop_queue and wake_queue in ethtool stats. Example: ethtool -S eth0 NIC statistics: ... stop_queue: 7 wake_queue: 7 ... Signed-off-by: Simon Xiao <sixiao@microsoft.com> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/hyperv/hyperv_net.h2
-rw-r--r--drivers/net/hyperv/netvsc.c12
-rw-r--r--drivers/net/hyperv/netvsc_drv.c2
3 files changed, 14 insertions, 2 deletions
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 5176be76ca7d..6f550e15a41c 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -686,6 +686,8 @@ struct netvsc_ethtool_stats {
686 unsigned long tx_busy; 686 unsigned long tx_busy;
687 unsigned long tx_send_full; 687 unsigned long tx_send_full;
688 unsigned long rx_comp_busy; 688 unsigned long rx_comp_busy;
689 unsigned long stop_queue;
690 unsigned long wake_queue;
689}; 691};
690 692
691struct netvsc_vf_pcpu_stats { 693struct netvsc_vf_pcpu_stats {
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index b0d323e24978..6e5194916bbe 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -609,6 +609,7 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
609{ 609{
610 struct sk_buff *skb = (struct sk_buff *)(unsigned long)desc->trans_id; 610 struct sk_buff *skb = (struct sk_buff *)(unsigned long)desc->trans_id;
611 struct net_device *ndev = hv_get_drvdata(device); 611 struct net_device *ndev = hv_get_drvdata(device);
612 struct net_device_context *ndev_ctx = netdev_priv(ndev);
612 struct vmbus_channel *channel = device->channel; 613 struct vmbus_channel *channel = device->channel;
613 u16 q_idx = 0; 614 u16 q_idx = 0;
614 int queue_sends; 615 int queue_sends;
@@ -643,8 +644,10 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
643 644
644 if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) && 645 if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) &&
645 (hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER || 646 (hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER ||
646 queue_sends < 1)) 647 queue_sends < 1)) {
647 netif_tx_wake_queue(netdev_get_tx_queue(ndev, q_idx)); 648 netif_tx_wake_queue(netdev_get_tx_queue(ndev, q_idx));
649 ndev_ctx->eth_stats.wake_queue++;
650 }
648} 651}
649 652
650static void netvsc_send_completion(struct netvsc_device *net_device, 653static void netvsc_send_completion(struct netvsc_device *net_device,
@@ -749,6 +752,7 @@ static inline int netvsc_send_pkt(
749 &net_device->chan_table[packet->q_idx]; 752 &net_device->chan_table[packet->q_idx];
750 struct vmbus_channel *out_channel = nvchan->channel; 753 struct vmbus_channel *out_channel = nvchan->channel;
751 struct net_device *ndev = hv_get_drvdata(device); 754 struct net_device *ndev = hv_get_drvdata(device);
755 struct net_device_context *ndev_ctx = netdev_priv(ndev);
752 struct netdev_queue *txq = netdev_get_tx_queue(ndev, packet->q_idx); 756 struct netdev_queue *txq = netdev_get_tx_queue(ndev, packet->q_idx);
753 u64 req_id; 757 u64 req_id;
754 int ret; 758 int ret;
@@ -789,12 +793,16 @@ static inline int netvsc_send_pkt(
789 if (ret == 0) { 793 if (ret == 0) {
790 atomic_inc_return(&nvchan->queue_sends); 794 atomic_inc_return(&nvchan->queue_sends);
791 795
792 if (ring_avail < RING_AVAIL_PERCENT_LOWATER) 796 if (ring_avail < RING_AVAIL_PERCENT_LOWATER) {
793 netif_tx_stop_queue(txq); 797 netif_tx_stop_queue(txq);
798 ndev_ctx->eth_stats.stop_queue++;
799 }
794 } else if (ret == -EAGAIN) { 800 } else if (ret == -EAGAIN) {
795 netif_tx_stop_queue(txq); 801 netif_tx_stop_queue(txq);
802 ndev_ctx->eth_stats.stop_queue++;
796 if (atomic_read(&nvchan->queue_sends) < 1) { 803 if (atomic_read(&nvchan->queue_sends) < 1) {
797 netif_tx_wake_queue(txq); 804 netif_tx_wake_queue(txq);
805 ndev_ctx->eth_stats.wake_queue++;
798 ret = -ENOSPC; 806 ret = -ENOSPC;
799 } 807 }
800 } else { 808 } else {
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index e9d54c9ee78c..f300ae61c6c6 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1126,6 +1126,8 @@ static const struct {
1126 { "tx_busy", offsetof(struct netvsc_ethtool_stats, tx_busy) }, 1126 { "tx_busy", offsetof(struct netvsc_ethtool_stats, tx_busy) },
1127 { "tx_send_full", offsetof(struct netvsc_ethtool_stats, tx_send_full) }, 1127 { "tx_send_full", offsetof(struct netvsc_ethtool_stats, tx_send_full) },
1128 { "rx_comp_busy", offsetof(struct netvsc_ethtool_stats, rx_comp_busy) }, 1128 { "rx_comp_busy", offsetof(struct netvsc_ethtool_stats, rx_comp_busy) },
1129 { "stop_queue", offsetof(struct netvsc_ethtool_stats, stop_queue) },
1130 { "wake_queue", offsetof(struct netvsc_ethtool_stats, wake_queue) },
1129}, vf_stats[] = { 1131}, vf_stats[] = {
1130 { "vf_rx_packets", offsetof(struct netvsc_vf_pcpu_stats, rx_packets) }, 1132 { "vf_rx_packets", offsetof(struct netvsc_vf_pcpu_stats, rx_packets) },
1131 { "vf_rx_bytes", offsetof(struct netvsc_vf_pcpu_stats, rx_bytes) }, 1133 { "vf_rx_bytes", offsetof(struct netvsc_vf_pcpu_stats, rx_bytes) },