netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Falcon <tlfalcon@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, dnbanerg@us.ibm.com,
	brking@linux.vnet.ibm.com, pradeep@us.ibm.com,
	drt@linux.vnet.ibm.com, sukadev@linux.vnet.ibm.com,
	ljp@linux.vnet.ibm.com, cforno12@linux.ibm.com,
	tlfalcon@linux.ibm.com, ricklind@linux.ibm.com
Subject: [PATCH net-next 07/12] ibmvnic: Clean up TX error handling and statistics tracking
Date: Thu, 12 Nov 2020 13:10:02 -0600	[thread overview]
Message-ID: <1605208207-1896-8-git-send-email-tlfalcon@linux.ibm.com> (raw)
In-Reply-To: <1605208207-1896-1-git-send-email-tlfalcon@linux.ibm.com>

Update error handling code in ibmvnic_xmit to be more readable
and remove unused statistics counters. Also record statistics
when TX completions are received to improve accuracy.

Signed-off-by: Thomas Falcon <tlfalcon@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 38 ++++++++++--------------------
 drivers/net/ethernet/ibm/ibmvnic.h |  2 --
 2 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index b523da20bffc..2c24d4774457 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1535,13 +1535,9 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 	struct ibmvnic_tx_buff *tx_buff = NULL;
 	struct ibmvnic_sub_crq_queue *tx_scrq;
 	struct ibmvnic_tx_pool *tx_pool;
-	unsigned int tx_send_failed = 0;
 	netdev_tx_t ret = NETDEV_TX_OK;
-	unsigned int tx_map_failed = 0;
 	union sub_crq indir_arr[16];
 	unsigned int tx_dropped = 0;
-	unsigned int tx_packets = 0;
-	unsigned int tx_bytes = 0;
 	dma_addr_t data_dma_addr;
 	struct netdev_queue *txq;
 	unsigned long lpar_rc;
@@ -1558,18 +1554,13 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 		if (!netif_subqueue_stopped(netdev, skb))
 			netif_stop_subqueue(netdev, queue_num);
 		dev_kfree_skb_any(skb);
-
-		tx_send_failed++;
 		tx_dropped++;
-		ret = NETDEV_TX_OK;
-		goto out;
+		goto err_out;
 	}
 
 	if (ibmvnic_xmit_workarounds(skb, netdev)) {
 		tx_dropped++;
-		tx_send_failed++;
-		ret = NETDEV_TX_OK;
-		goto out;
+		goto err_out;
 	}
 	if (skb_is_gso(skb))
 		tx_pool = &adapter->tso_pool[queue_num];
@@ -1584,10 +1575,8 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 
 	if (index == IBMVNIC_INVALID_MAP) {
 		dev_kfree_skb_any(skb);
-		tx_send_failed++;
 		tx_dropped++;
-		ret = NETDEV_TX_OK;
-		goto out;
+		goto err_out;
 	}
 
 	tx_pool->free_map[tx_pool->consumer_index] = IBMVNIC_INVALID_MAP;
@@ -1707,12 +1696,9 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 		netif_stop_subqueue(netdev, queue_num);
 	}
 
-	tx_packets++;
-	tx_bytes += skb->len;
 	txq->trans_start = jiffies;
-	ret = NETDEV_TX_OK;
-	goto out;
 
+	return ret;
 tx_flush_err:
 	dev_kfree_skb_any(skb);
 	tx_buff->skb = NULL;
@@ -1758,14 +1744,8 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 		netif_tx_stop_all_queues(netdev);
 		netif_carrier_off(netdev);
 	}
-out:
+err_out:
 	netdev->stats.tx_dropped += tx_dropped;
-	netdev->stats.tx_bytes += tx_bytes;
-	netdev->stats.tx_packets += tx_packets;
-	adapter->tx_send_failed += tx_send_failed;
-	adapter->tx_map_failed += tx_map_failed;
-	adapter->tx_stats_buffers[queue_num].packets += tx_packets;
-	adapter->tx_stats_buffers[queue_num].bytes += tx_bytes;
 	adapter->tx_stats_buffers[queue_num].dropped_packets += tx_dropped;
 
 	return ret;
@@ -3147,6 +3127,7 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
 		int num_entries = 0;
 		int total_bytes = 0;
 		int num_packets = 0;
+		int tx_dropped = 0;
 
 		next = ibmvnic_next_scrq(adapter, scrq);
 		/* ensure that we are reading the correct queue entry */
@@ -3157,6 +3138,7 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
 			if (next->tx_comp.rcs[i]) {
 				dev_err(dev, "tx error %x\n",
 					next->tx_comp.rcs[i]);
+				tx_dropped++;
 				error = true;
 			}
 			index = be32_to_cpu(next->tx_comp.correlators[i]);
@@ -3200,6 +3182,12 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
 			netdev_dbg(adapter->netdev, "Started queue %d\n",
 				   scrq->pool_index);
 		}
+		adapter->netdev->stats.tx_packets += num_packets;
+		adapter->netdev->stats.tx_bytes += total_bytes;
+		adapter->netdev->stats.tx_dropped += tx_dropped;
+		adapter->tx_stats_buffers[scrq->pool_index].packets += num_packets;
+		adapter->tx_stats_buffers[scrq->pool_index].bytes += total_bytes;
+		adapter->tx_stats_buffers[scrq->pool_index].dropped_packets += tx_dropped;
 	}
 
 	enable_scrq_irq(adapter, scrq);
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index 11af1f29210b..c6f1842d2023 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -992,8 +992,6 @@ struct ibmvnic_adapter {
 	int replenish_add_buff_success;
 	int replenish_add_buff_failure;
 	int replenish_task_cycles;
-	int tx_send_failed;
-	int tx_map_failed;
 
 	struct ibmvnic_tx_queue_stats *tx_stats_buffers;
 	struct ibmvnic_rx_queue_stats *rx_stats_buffers;
-- 
2.26.2


  parent reply	other threads:[~2020-11-12 19:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 19:09 [PATCH net-next 00/12] ibmvnic: Performance improvements and other updates Thomas Falcon
2020-11-12 19:09 ` [PATCH net-next 01/12] ibmvnic: Ensure that subCRQ entry reads are ordered Thomas Falcon
2020-11-13  5:45   ` drt
2020-11-13 16:14   ` Brian King
2020-11-14 23:35   ` Jakub Kicinski
2020-11-16 18:28     ` Thomas Falcon
2020-11-16 18:30       ` Jakub Kicinski
2020-11-12 19:09 ` [PATCH net-next 02/12] ibmvnic: Introduce indirect subordinate Command Response Queue buffer Thomas Falcon
2020-11-13 16:17   ` Brian King
2020-11-14 23:35   ` Jakub Kicinski
2020-11-16 18:18     ` Thomas Falcon
2020-11-12 19:09 ` [PATCH net-next 03/12] ibmvnic: Introduce batched RX buffer descriptor transmission Thomas Falcon
2020-11-12 19:09 ` [PATCH net-next 04/12] ibmvnic: Introduce xmit_more support using batched subCRQ hcalls Thomas Falcon
2020-11-14 23:46   ` Jakub Kicinski
2020-11-16 18:40     ` Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 05/12] ibmvnic: Fix TX completion error handling Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 06/12] ibmvnic: Clean up TX code and TX buffer data structure Thomas Falcon
2020-11-12 19:10 ` Thomas Falcon [this message]
2020-11-12 19:10 ` [PATCH net-next 08/12] ibmvnic: Remove send_subcrq function Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 09/12] ibmvnic: Ensure that device queue memory is cache-line aligned Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 10/12] ibmvnic: Correctly re-enable interrupts in NAPI polling routine Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 11/12] ibmvnic: Use netdev_alloc_skb instead of alloc_skb to replenish RX buffers Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 12/12] ibmvnic: Do not replenish RX buffers after every polling loop Thomas Falcon
2020-11-13  5:52   ` drt

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=1605208207-1896-8-git-send-email-tlfalcon@linux.ibm.com \
    --to=tlfalcon@linux.ibm.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=cforno12@linux.ibm.com \
    --cc=dnbanerg@us.ibm.com \
    --cc=drt@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=ljp@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pradeep@us.ibm.com \
    --cc=ricklind@linux.ibm.com \
    --cc=sukadev@linux.vnet.ibm.com \
    /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).