public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] ibmvnic: Improve output for unsupported stats
@ 2017-10-02 20:31 John Allen
  2017-10-02 21:57 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: John Allen @ 2017-10-02 20:31 UTC (permalink / raw)
  To: netdev, Thomas Falcon

The vnic server can report -1 in the event that a given statistic is not
supported. Currently, the -1 value is implicitly cast to an unsigned
integer and appears through the ethtool -S output as a very large number.
This patch improves this behavior by reporting 0 in the event that a
given statistic is not supported.

Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
---
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index cb8182f..b8ad2db 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1862,6 +1862,7 @@ static void ibmvnic_get_ethtool_stats(struct net_device *dev,
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(dev);
 	union ibmvnic_crq crq;
+	u64 stat;
 	int i, j;

 	memset(&crq, 0, sizeof(crq));
@@ -1876,9 +1877,11 @@ static void ibmvnic_get_ethtool_stats(struct net_device *dev,
 	ibmvnic_send_crq(adapter, &crq);
 	wait_for_completion(&adapter->stats_done);

-	for (i = 0; i < ARRAY_SIZE(ibmvnic_stats); i++)
-		data[i] = be64_to_cpu(IBMVNIC_GET_STAT(adapter,
-						ibmvnic_stats[i].offset));
+	for (i = 0; i < ARRAY_SIZE(ibmvnic_stats); i++) {
+		stat = be64_to_cpu(IBMVNIC_GET_STAT(adapter,
+						    ibmvnic_stats[i].offset));
+		data[i] = stat == -1 ? 0 : stat;
+	}

 	for (j = 0; j < adapter->req_tx_queues; j++) {
 		data[i] = adapter->tx_stats_buffers[j].packets;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-02 23:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-02 20:31 [PATCH net-next] ibmvnic: Improve output for unsupported stats John Allen
2017-10-02 21:57 ` Andrew Lunn
2017-10-02 23:03   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox