netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/12] ionic: code cleanup and performance tuning
@ 2024-02-29 19:39 Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 01/12] ionic: Rework Tx start/stop flow Shannon Nelson
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

Brett has been performance testing and code tweaking and has
come up with several improvements for our fast path operations.

In a simple single thread / single queue iperf case on a 1500 MTU
connection we see an improvement from 74.2 to 86.7 Gbits/sec.

Brett Creeley (10):
  ionic: Rework Tx start/stop flow
  ionic: Change default number of descriptors for Tx and Rx
  ionic: Shorten a Tx hotpath
  ionic: Make use napi_consume_skb
  ionic: Clean up BQL logic
  ionic: Check stop no restart
  ionic: Pass local netdev instead of referencing struct
  ionic: change the hwstamp likely check
  ionic: Use CQE profile for dim
  ionic: Clean RCT ordering issues

Shannon Nelson (2):
  ionic: reduce the use of netdev
  ionic: change MODULE_AUTHOR to person name

 .../ethernet/pensando/ionic/ionic_debugfs.c   |   2 +-
 .../net/ethernet/pensando/ionic/ionic_dev.h   |   4 +-
 .../net/ethernet/pensando/ionic/ionic_lif.c   |  16 +-
 .../net/ethernet/pensando/ionic/ionic_lif.h   |   2 +-
 .../net/ethernet/pensando/ionic/ionic_main.c  |   2 +-
 .../net/ethernet/pensando/ionic/ionic_txrx.c  | 216 ++++++++++--------
 .../net/ethernet/pensando/ionic/ionic_txrx.h  |   1 -
 7 files changed, 137 insertions(+), 106 deletions(-)

-- 
2.17.1


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

* [PATCH net-next 01/12] ionic: Rework Tx start/stop flow
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 02/12] ionic: Change default number of descriptors for Tx and Rx Shannon Nelson
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

Currently the driver attempts to wake the Tx queue
for every descriptor processed. However, this is
overkill and can cause thrashing since Tx xmit can be
running concurrently on a different CPU than Tx clean.
Fix this by refactoring Tx cq servicing into its own
function so the Tx wake code can run after processing
all Tx descriptors.

The driver isn't using the expected memory barriers
to make sure the stop/start bits are coherent. Fix
this by  making sure to use the correct memory barriers.

Also, the driver is using the wake API during Tx
xmit even though it's already scheduled. Fix this by
using the start API during Tx xmit.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 .../net/ethernet/pensando/ionic/ionic_dev.h   |  2 +
 .../net/ethernet/pensando/ionic/ionic_lif.c   |  3 +-
 .../net/ethernet/pensando/ionic/ionic_txrx.c  | 89 ++++++++++---------
 .../net/ethernet/pensando/ionic/ionic_txrx.h  |  1 -
 4 files changed, 50 insertions(+), 45 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h
index bfcfc2d7bcbd..abe64086e8ca 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h
+++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h
@@ -19,6 +19,7 @@
 #define IONIC_DEF_TXRX_DESC		4096
 #define IONIC_RX_FILL_THRESHOLD		16
 #define IONIC_RX_FILL_DIV		8
+#define IONIC_TSO_DESCS_NEEDED		44 /* 64K TSO @1500B */
 #define IONIC_LIFS_MAX			1024
 #define IONIC_WATCHDOG_SECS		5
 #define IONIC_ITR_COAL_USEC_DEFAULT	64
@@ -379,6 +380,7 @@ typedef void (*ionic_cq_done_cb)(void *done_arg);
 unsigned int ionic_cq_service(struct ionic_cq *cq, unsigned int work_to_do,
 			      ionic_cq_cb cb, ionic_cq_done_cb done_cb,
 			      void *done_arg);
+unsigned int ionic_tx_cq_service(struct ionic_cq *cq, unsigned int work_to_do);
 
 int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
 		 struct ionic_queue *q, unsigned int index, const char *name,
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
index 5cfc784f1227..35a1d9927493 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -1262,8 +1262,7 @@ static int ionic_adminq_napi(struct napi_struct *napi, int budget)
 					   ionic_rx_service, NULL, NULL);
 
 	if (lif->hwstamp_txq)
-		tx_work = ionic_cq_service(&lif->hwstamp_txq->cq, budget,
-					   ionic_tx_service, NULL, NULL);
+		tx_work = ionic_tx_cq_service(&lif->hwstamp_txq->cq, budget);
 
 	work_done = max(max(n_work, a_work), max(rx_work, tx_work));
 	if (work_done < budget && napi_complete_done(napi, work_done)) {
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index 56a7ad5bff17..dcaa8a4d6ad5 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -5,13 +5,12 @@
 #include <linux/ipv6.h>
 #include <linux/if_vlan.h>
 #include <net/ip6_checksum.h>
+#include <net/netdev_queues.h>
 
 #include "ionic.h"
 #include "ionic_lif.h"
 #include "ionic_txrx.h"
 
-static int ionic_maybe_stop_tx(struct ionic_queue *q, int ndescs);
-
 static dma_addr_t ionic_tx_map_single(struct ionic_queue *q,
 				      void *data, size_t len);
 
@@ -458,7 +457,9 @@ int ionic_xdp_xmit(struct net_device *netdev, int n,
 	txq_trans_cond_update(nq);
 
 	if (netif_tx_queue_stopped(nq) ||
-	    unlikely(ionic_maybe_stop_tx(txq, 1))) {
+	    !netif_txq_maybe_stop(q_to_ndq(txq),
+				  ionic_q_space_avail(txq),
+				  1, 1)) {
 		__netif_tx_unlock(nq);
 		return -EIO;
 	}
@@ -478,7 +479,9 @@ int ionic_xdp_xmit(struct net_device *netdev, int n,
 		ionic_dbell_ring(lif->kern_dbpage, txq->hw_type,
 				 txq->dbval | txq->head_idx);
 
-	ionic_maybe_stop_tx(txq, 4);
+	netif_txq_maybe_stop(q_to_ndq(txq),
+			     ionic_q_space_avail(txq),
+			     4, 4);
 	__netif_tx_unlock(nq);
 
 	return nxmit;
@@ -571,7 +574,9 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
 		txq_trans_cond_update(nq);
 
 		if (netif_tx_queue_stopped(nq) ||
-		    unlikely(ionic_maybe_stop_tx(txq, 1))) {
+		    !netif_txq_maybe_stop(q_to_ndq(txq),
+					  ionic_q_space_avail(txq),
+					  1, 1)) {
 			__netif_tx_unlock(nq);
 			goto out_xdp_abort;
 		}
@@ -946,8 +951,7 @@ int ionic_tx_napi(struct napi_struct *napi, int budget)
 	lif = cq->bound_q->lif;
 	idev = &lif->ionic->idev;
 
-	work_done = ionic_cq_service(cq, budget,
-				     ionic_tx_service, NULL, NULL);
+	work_done = ionic_tx_cq_service(cq, budget);
 
 	if (unlikely(!budget))
 		return budget;
@@ -1038,8 +1042,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
 	txqcq = lif->txqcqs[qi];
 	txcq = &lif->txqcqs[qi]->cq;
 
-	tx_work_done = ionic_cq_service(txcq, IONIC_TX_BUDGET_DEFAULT,
-					ionic_tx_service, NULL, NULL);
+	tx_work_done = ionic_tx_cq_service(txcq, IONIC_TX_BUDGET_DEFAULT);
 
 	if (unlikely(!budget))
 		return budget;
@@ -1183,7 +1186,6 @@ static void ionic_tx_clean(struct ionic_queue *q,
 	struct ionic_tx_stats *stats = q_to_tx_stats(q);
 	struct ionic_qcq *qcq = q_to_qcq(q);
 	struct sk_buff *skb = cb_arg;
-	u16 qi;
 
 	if (desc_info->xdpf) {
 		ionic_xdp_tx_desc_clean(q->partner, desc_info);
@@ -1200,8 +1202,6 @@ static void ionic_tx_clean(struct ionic_queue *q,
 	if (!skb)
 		return;
 
-	qi = skb_get_queue_mapping(skb);
-
 	if (ionic_txq_hwstamp_enabled(q)) {
 		if (cq_info) {
 			struct skb_shared_hwtstamps hwts = {};
@@ -1227,9 +1227,6 @@ static void ionic_tx_clean(struct ionic_queue *q,
 				stats->hwstamp_invalid++;
 			}
 		}
-
-	} else if (unlikely(__netif_subqueue_stopped(q->lif->netdev, qi))) {
-		netif_wake_subqueue(q->lif->netdev, qi);
 	}
 
 	desc_info->bytes = skb->len;
@@ -1238,7 +1235,7 @@ static void ionic_tx_clean(struct ionic_queue *q,
 	dev_consume_skb_any(skb);
 }
 
-bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
+static bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
 {
 	struct ionic_queue *q = cq->bound_q;
 	struct ionic_desc_info *desc_info;
@@ -1275,6 +1272,37 @@ bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
 	return true;
 }
 
+unsigned int ionic_tx_cq_service(struct ionic_cq *cq, unsigned int work_to_do)
+{
+	struct ionic_cq_info *cq_info;
+	unsigned int work_done = 0;
+
+	if (work_to_do == 0)
+		return 0;
+
+	cq_info = &cq->info[cq->tail_idx];
+	while (ionic_tx_service(cq, cq_info)) {
+		if (cq->tail_idx == cq->num_descs - 1)
+			cq->done_color = !cq->done_color;
+		cq->tail_idx = (cq->tail_idx + 1) & (cq->num_descs - 1);
+		cq_info = &cq->info[cq->tail_idx];
+
+		if (++work_done >= work_to_do)
+			break;
+	}
+
+	if (work_done) {
+		struct ionic_queue *q = cq->bound_q;
+
+		smp_mb();	/* assure sync'd state before stopped check */
+		if (unlikely(__netif_subqueue_stopped(q->lif->netdev, q->index)) &&
+		    ionic_q_has_space(q, IONIC_TSO_DESCS_NEEDED))
+			netif_wake_subqueue(q->lif->netdev, q->index);
+	}
+
+	return work_done;
+}
+
 void ionic_tx_flush(struct ionic_cq *cq)
 {
 	struct ionic_dev *idev = &cq->lif->ionic->idev;
@@ -1724,25 +1752,6 @@ static int ionic_tx_descs_needed(struct ionic_queue *q, struct sk_buff *skb)
 	return ndescs;
 }
 
-static int ionic_maybe_stop_tx(struct ionic_queue *q, int ndescs)
-{
-	int stopped = 0;
-
-	if (unlikely(!ionic_q_has_space(q, ndescs))) {
-		netif_stop_subqueue(q->lif->netdev, q->index);
-		stopped = 1;
-
-		/* Might race with ionic_tx_clean, check again */
-		smp_rmb();
-		if (ionic_q_has_space(q, ndescs)) {
-			netif_wake_subqueue(q->lif->netdev, q->index);
-			stopped = 0;
-		}
-	}
-
-	return stopped;
-}
-
 static netdev_tx_t ionic_start_hwstamp_xmit(struct sk_buff *skb,
 					    struct net_device *netdev)
 {
@@ -1804,7 +1813,9 @@ netdev_tx_t ionic_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	if (ndescs < 0)
 		goto err_out_drop;
 
-	if (unlikely(ionic_maybe_stop_tx(q, ndescs)))
+	if (!netif_txq_maybe_stop(q_to_ndq(q),
+				  ionic_q_space_avail(q),
+				  ndescs, ndescs))
 		return NETDEV_TX_BUSY;
 
 	if (skb_is_gso(skb))
@@ -1815,12 +1826,6 @@ netdev_tx_t ionic_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	if (err)
 		goto err_out_drop;
 
-	/* Stop the queue if there aren't descriptors for the next packet.
-	 * Since our SG lists per descriptor take care of most of the possible
-	 * fragmentation, we don't need to have many descriptors available.
-	 */
-	ionic_maybe_stop_tx(q, 4);
-
 	return NETDEV_TX_OK;
 
 err_out_drop:
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.h b/drivers/net/ethernet/pensando/ionic/ionic_txrx.h
index 82fc38e0f573..68228bb8c119 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.h
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.h
@@ -15,7 +15,6 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget);
 netdev_tx_t ionic_start_xmit(struct sk_buff *skb, struct net_device *netdev);
 
 bool ionic_rx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info);
-bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info);
 
 int ionic_xdp_xmit(struct net_device *netdev, int n, struct xdp_frame **xdp, u32 flags);
 #endif /* _IONIC_TXRX_H_ */
-- 
2.17.1


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

* [PATCH net-next 02/12] ionic: Change default number of descriptors for Tx and Rx
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 01/12] ionic: Rework Tx start/stop flow Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 03/12] ionic: Shorten a Tx hotpath Shannon Nelson
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

Cut down the number of default Tx and Rx descriptors to save
initial memory requirements.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_dev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h
index abe64086e8ca..516db910e8e8 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h
+++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h
@@ -16,7 +16,7 @@
 #define IONIC_MAX_TX_DESC		8192
 #define IONIC_MAX_RX_DESC		16384
 #define IONIC_MIN_TXRX_DESC		64
-#define IONIC_DEF_TXRX_DESC		4096
+#define IONIC_DEF_TXRX_DESC		1024
 #define IONIC_RX_FILL_THRESHOLD		16
 #define IONIC_RX_FILL_DIV		8
 #define IONIC_TSO_DESCS_NEEDED		44 /* 64K TSO @1500B */
-- 
2.17.1


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

* [PATCH net-next 03/12] ionic: Shorten a Tx hotpath
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 01/12] ionic: Rework Tx start/stop flow Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 02/12] ionic: Change default number of descriptors for Tx and Rx Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 04/12] ionic: Make use napi_consume_skb Shannon Nelson
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

Perf was showing some hot spots in ionic_tx_descs_needed()
for TSO traffic.  Rework the function to return sooner where
possible.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index dcaa8a4d6ad5..2837f2cc0151 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -1669,7 +1669,7 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb)
 
 static int ionic_tx_descs_needed(struct ionic_queue *q, struct sk_buff *skb)
 {
-	struct ionic_tx_stats *stats = q_to_tx_stats(q);
+	int nr_frags = skb_shinfo(skb)->nr_frags;
 	bool too_many_frags = false;
 	skb_frag_t *frag;
 	int desc_bufs;
@@ -1685,17 +1685,20 @@ static int ionic_tx_descs_needed(struct ionic_queue *q, struct sk_buff *skb)
 	/* Each desc is mss long max, so a descriptor for each gso_seg */
 	if (skb_is_gso(skb)) {
 		ndescs = skb_shinfo(skb)->gso_segs;
+		if (!nr_frags)
+			return ndescs;
 	} else {
 		ndescs = 1;
-		if (skb_shinfo(skb)->nr_frags > q->max_sg_elems) {
+		if (!nr_frags)
+			return ndescs;
+
+		if (unlikely(nr_frags > q->max_sg_elems)) {
 			too_many_frags = true;
 			goto linearize;
 		}
-	}
 
-	/* If non-TSO, or no frags to check, we're done */
-	if (!skb_is_gso(skb) || !skb_shinfo(skb)->nr_frags)
 		return ndescs;
+	}
 
 	/* We need to scan the skb to be sure that none of the MTU sized
 	 * packets in the TSO will require more sgs per descriptor than we
@@ -1743,6 +1746,8 @@ static int ionic_tx_descs_needed(struct ionic_queue *q, struct sk_buff *skb)
 
 linearize:
 	if (too_many_frags) {
+		struct ionic_tx_stats *stats = q_to_tx_stats(q);
+
 		err = skb_linearize(skb);
 		if (err)
 			return err;
-- 
2.17.1


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

* [PATCH net-next 04/12] ionic: Make use napi_consume_skb
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (2 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 03/12] ionic: Shorten a Tx hotpath Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 05/12] ionic: Clean up BQL logic Shannon Nelson
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

Make use of napi_consume_skb so that skb recycling
can happen by way of the napi_skb_cache.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index 2837f2cc0151..3da4fd322690 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -1232,7 +1232,7 @@ static void ionic_tx_clean(struct ionic_queue *q,
 	desc_info->bytes = skb->len;
 	stats->clean++;
 
-	dev_consume_skb_any(skb);
+	napi_consume_skb(skb, 1);
 }
 
 static bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
-- 
2.17.1


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

* [PATCH net-next 05/12] ionic: Clean up BQL logic
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (3 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 04/12] ionic: Make use napi_consume_skb Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 06/12] ionic: Check stop no restart Shannon Nelson
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

The driver currently calls netdev_tx_completed_queue() for every
Tx completion. However, this API is only meant to be called once
per NAPI if any Tx work is done.  Make the necessary changes to
support calling netdev_tx_completed_queue() only once per NAPI.

Also, use the __netdev_tx_sent_queue() API, which supports the
xmit_more functionality.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 .../net/ethernet/pensando/ionic/ionic_txrx.c  | 36 +++++++++++--------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index 3da4fd322690..1397a0dcf794 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -1235,13 +1235,14 @@ static void ionic_tx_clean(struct ionic_queue *q,
 	napi_consume_skb(skb, 1);
 }
 
-static bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
+static bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info,
+			     unsigned int *total_pkts, unsigned int *total_bytes)
 {
 	struct ionic_queue *q = cq->bound_q;
 	struct ionic_desc_info *desc_info;
 	struct ionic_txq_comp *comp;
-	int bytes = 0;
-	int pkts = 0;
+	unsigned int bytes = 0;
+	unsigned int pkts = 0;
 	u16 index;
 
 	comp = cq_info->cq_desc + cq->desc_size - sizeof(*comp);
@@ -1266,8 +1267,8 @@ static bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
 		desc_info->cb_arg = NULL;
 	} while (index != le16_to_cpu(comp->comp_index));
 
-	if (pkts && bytes && !ionic_txq_hwstamp_enabled(q))
-		netdev_tx_completed_queue(q_to_ndq(q), pkts, bytes);
+	(*total_pkts) += pkts;
+	(*total_bytes) += bytes;
 
 	return true;
 }
@@ -1276,12 +1277,14 @@ unsigned int ionic_tx_cq_service(struct ionic_cq *cq, unsigned int work_to_do)
 {
 	struct ionic_cq_info *cq_info;
 	unsigned int work_done = 0;
+	unsigned int bytes = 0;
+	unsigned int pkts = 0;
 
 	if (work_to_do == 0)
 		return 0;
 
 	cq_info = &cq->info[cq->tail_idx];
-	while (ionic_tx_service(cq, cq_info)) {
+	while (ionic_tx_service(cq, cq_info, &pkts, &bytes)) {
 		if (cq->tail_idx == cq->num_descs - 1)
 			cq->done_color = !cq->done_color;
 		cq->tail_idx = (cq->tail_idx + 1) & (cq->num_descs - 1);
@@ -1294,10 +1297,10 @@ unsigned int ionic_tx_cq_service(struct ionic_cq *cq, unsigned int work_to_do)
 	if (work_done) {
 		struct ionic_queue *q = cq->bound_q;
 
-		smp_mb();	/* assure sync'd state before stopped check */
-		if (unlikely(__netif_subqueue_stopped(q->lif->netdev, q->index)) &&
-		    ionic_q_has_space(q, IONIC_TSO_DESCS_NEEDED))
-			netif_wake_subqueue(q->lif->netdev, q->index);
+		if (!ionic_txq_hwstamp_enabled(q))
+			netif_txq_completed_wake(q_to_ndq(q), pkts, bytes,
+						 ionic_q_space_avail(q),
+						 IONIC_TSO_DESCS_NEEDED);
 	}
 
 	return work_done;
@@ -1308,8 +1311,7 @@ void ionic_tx_flush(struct ionic_cq *cq)
 	struct ionic_dev *idev = &cq->lif->ionic->idev;
 	u32 work_done;
 
-	work_done = ionic_cq_service(cq, cq->num_descs,
-				     ionic_tx_service, NULL, NULL);
+	work_done = ionic_tx_cq_service(cq, cq->num_descs);
 	if (work_done)
 		ionic_intr_credits(idev->intr_ctrl, cq->bound_intr->index,
 				   work_done, IONIC_INTR_CRED_RESET_COALESCE);
@@ -1335,8 +1337,10 @@ void ionic_tx_empty(struct ionic_queue *q)
 		desc_info->cb_arg = NULL;
 	}
 
-	if (pkts && bytes && !ionic_txq_hwstamp_enabled(q))
+	if (!ionic_txq_hwstamp_enabled(q)) {
 		netdev_tx_completed_queue(q_to_ndq(q), pkts, bytes);
+		netdev_tx_reset_queue(q_to_ndq(q));
+	}
 }
 
 static int ionic_tx_tcp_inner_pseudo_csum(struct sk_buff *skb)
@@ -1643,6 +1647,7 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb)
 {
 	struct ionic_desc_info *desc_info = &q->info[q->head_idx];
 	struct ionic_tx_stats *stats = q_to_tx_stats(q);
+	bool ring_dbell = true;
 
 	if (unlikely(ionic_tx_map_skb(q, skb, desc_info)))
 		return -EIO;
@@ -1661,8 +1666,9 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb)
 	stats->bytes += skb->len;
 
 	if (!ionic_txq_hwstamp_enabled(q))
-		netdev_tx_sent_queue(q_to_ndq(q), skb->len);
-	ionic_txq_post(q, !netdev_xmit_more(), ionic_tx_clean, skb);
+		ring_dbell = __netdev_tx_sent_queue(q_to_ndq(q), skb->len,
+						    netdev_xmit_more());
+	ionic_txq_post(q, ring_dbell, ionic_tx_clean, skb);
 
 	return 0;
 }
-- 
2.17.1


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

* [PATCH net-next 06/12] ionic: Check stop no restart
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (4 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 05/12] ionic: Clean up BQL logic Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 07/12] ionic: Pass local netdev instead of referencing struct Shannon Nelson
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

If there is a lot of transmit traffic the driver can get into a
situation that the device is starved due to the doorbell never
being rung. This can happen if xmit_more is set constantly
and __netdev_tx_sent_queue() keeps returning false. Fix this
by checking if the queue needs to be stopped right before
calling __netdev_tx_sent_queue(). Use MAX_SKB_FRAGS + 1 as the
stop condition because that's the maximum number of frags
supported for non-TSO transmit.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index 1397a0dcf794..d9e23fc78e6b 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -1665,9 +1665,14 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb)
 	stats->pkts++;
 	stats->bytes += skb->len;
 
-	if (!ionic_txq_hwstamp_enabled(q))
-		ring_dbell = __netdev_tx_sent_queue(q_to_ndq(q), skb->len,
+	if (!ionic_txq_hwstamp_enabled(q)) {
+		struct netdev_queue *ndq = q_to_ndq(q);
+
+		if (unlikely(!ionic_q_has_space(q, MAX_SKB_FRAGS + 1)))
+			netif_tx_stop_queue(ndq);
+		ring_dbell = __netdev_tx_sent_queue(ndq, skb->len,
 						    netdev_xmit_more());
+	}
 	ionic_txq_post(q, ring_dbell, ionic_tx_clean, skb);
 
 	return 0;
-- 
2.17.1


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

* [PATCH net-next 07/12] ionic: Pass local netdev instead of referencing struct
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (5 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 06/12] ionic: Check stop no restart Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 08/12] ionic: reduce the use of netdev Shannon Nelson
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

Instead of using q->lif->netdev, just pass the netdev when it's
locally defined.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 .../net/ethernet/pensando/ionic/ionic_txrx.c  | 66 ++++++++++---------
 1 file changed, 36 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index d9e23fc78e6b..f217b9875f1b 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -99,9 +99,10 @@ bool ionic_rxq_poke_doorbell(struct ionic_queue *q)
 	return true;
 }
 
-static inline struct netdev_queue *q_to_ndq(struct ionic_queue *q)
+static inline struct netdev_queue *q_to_ndq(struct net_device *netdev,
+					    struct ionic_queue *q)
 {
-	return netdev_get_tx_queue(q->lif->netdev, q->index);
+	return netdev_get_tx_queue(netdev, q->index);
 }
 
 static void *ionic_rx_buf_va(struct ionic_buf_info *buf_info)
@@ -203,14 +204,14 @@ static bool ionic_rx_buf_recycle(struct ionic_queue *q,
 	return true;
 }
 
-static struct sk_buff *ionic_rx_frags(struct ionic_queue *q,
+static struct sk_buff *ionic_rx_frags(struct net_device *netdev,
+				      struct ionic_queue *q,
 				      struct ionic_desc_info *desc_info,
 				      unsigned int headroom,
 				      unsigned int len,
 				      unsigned int num_sg_elems,
 				      bool synced)
 {
-	struct net_device *netdev = q->lif->netdev;
 	struct ionic_buf_info *buf_info;
 	struct ionic_rx_stats *stats;
 	struct device *dev = q->dev;
@@ -271,13 +272,13 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q,
 	return skb;
 }
 
-static struct sk_buff *ionic_rx_copybreak(struct ionic_queue *q,
+static struct sk_buff *ionic_rx_copybreak(struct net_device *netdev,
+					  struct ionic_queue *q,
 					  struct ionic_desc_info *desc_info,
 					  unsigned int headroom,
 					  unsigned int len,
 					  bool synced)
 {
-	struct net_device *netdev = q->lif->netdev;
 	struct ionic_buf_info *buf_info;
 	struct ionic_rx_stats *stats;
 	struct device *dev = q->dev;
@@ -308,7 +309,7 @@ static struct sk_buff *ionic_rx_copybreak(struct ionic_queue *q,
 					 headroom, len, DMA_FROM_DEVICE);
 
 	skb_put(skb, len);
-	skb->protocol = eth_type_trans(skb, q->lif->netdev);
+	skb->protocol = eth_type_trans(skb, netdev);
 
 	return skb;
 }
@@ -348,8 +349,7 @@ static void ionic_xdp_tx_desc_clean(struct ionic_queue *q,
 	desc_info->act = 0;
 }
 
-static int ionic_xdp_post_frame(struct net_device *netdev,
-				struct ionic_queue *q, struct xdp_frame *frame,
+static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame,
 				enum xdp_action act, struct page *page, int off,
 				bool ring_doorbell)
 {
@@ -457,7 +457,7 @@ int ionic_xdp_xmit(struct net_device *netdev, int n,
 	txq_trans_cond_update(nq);
 
 	if (netif_tx_queue_stopped(nq) ||
-	    !netif_txq_maybe_stop(q_to_ndq(txq),
+	    !netif_txq_maybe_stop(q_to_ndq(netdev, txq),
 				  ionic_q_space_avail(txq),
 				  1, 1)) {
 		__netif_tx_unlock(nq);
@@ -466,7 +466,7 @@ int ionic_xdp_xmit(struct net_device *netdev, int n,
 
 	space = min_t(int, n, ionic_q_space_avail(txq));
 	for (nxmit = 0; nxmit < space ; nxmit++) {
-		if (ionic_xdp_post_frame(netdev, txq, xdp_frames[nxmit],
+		if (ionic_xdp_post_frame(txq, xdp_frames[nxmit],
 					 XDP_REDIRECT,
 					 virt_to_page(xdp_frames[nxmit]->data),
 					 0, false)) {
@@ -479,7 +479,7 @@ int ionic_xdp_xmit(struct net_device *netdev, int n,
 		ionic_dbell_ring(lif->kern_dbpage, txq->hw_type,
 				 txq->dbval | txq->head_idx);
 
-	netif_txq_maybe_stop(q_to_ndq(txq),
+	netif_txq_maybe_stop(q_to_ndq(netdev, txq),
 			     ionic_q_space_avail(txq),
 			     4, 4);
 	__netif_tx_unlock(nq);
@@ -574,7 +574,7 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
 		txq_trans_cond_update(nq);
 
 		if (netif_tx_queue_stopped(nq) ||
-		    !netif_txq_maybe_stop(q_to_ndq(txq),
+		    !netif_txq_maybe_stop(q_to_ndq(netdev, txq),
 					  ionic_q_space_avail(txq),
 					  1, 1)) {
 			__netif_tx_unlock(nq);
@@ -584,7 +584,7 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
 		dma_unmap_page(rxq->dev, buf_info->dma_addr,
 			       IONIC_PAGE_SIZE, DMA_FROM_DEVICE);
 
-		err = ionic_xdp_post_frame(netdev, txq, xdpf, XDP_TX,
+		err = ionic_xdp_post_frame(txq, xdpf, XDP_TX,
 					   buf_info->page,
 					   buf_info->page_offset,
 					   true);
@@ -662,9 +662,10 @@ static void ionic_rx_clean(struct ionic_queue *q,
 
 	headroom = q->xdp_rxq_info ? XDP_PACKET_HEADROOM : 0;
 	if (len <= q->lif->rx_copybreak)
-		skb = ionic_rx_copybreak(q, desc_info, headroom, len, !!xdp_prog);
+		skb = ionic_rx_copybreak(netdev, q, desc_info,
+					 headroom, len, !!xdp_prog);
 	else
-		skb = ionic_rx_frags(q, desc_info, headroom, len,
+		skb = ionic_rx_frags(netdev, q, desc_info, headroom, len,
 				     comp->num_sg_elems, !!xdp_prog);
 
 	if (unlikely(!skb)) {
@@ -1298,7 +1299,8 @@ unsigned int ionic_tx_cq_service(struct ionic_cq *cq, unsigned int work_to_do)
 		struct ionic_queue *q = cq->bound_q;
 
 		if (!ionic_txq_hwstamp_enabled(q))
-			netif_txq_completed_wake(q_to_ndq(q), pkts, bytes,
+			netif_txq_completed_wake(q_to_ndq(q->lif->netdev, q),
+						 pkts, bytes,
 						 ionic_q_space_avail(q),
 						 IONIC_TSO_DESCS_NEEDED);
 	}
@@ -1338,8 +1340,10 @@ void ionic_tx_empty(struct ionic_queue *q)
 	}
 
 	if (!ionic_txq_hwstamp_enabled(q)) {
-		netdev_tx_completed_queue(q_to_ndq(q), pkts, bytes);
-		netdev_tx_reset_queue(q_to_ndq(q));
+		struct netdev_queue *ndq = q_to_ndq(q->lif->netdev, q);
+
+		netdev_tx_completed_queue(ndq, pkts, bytes);
+		netdev_tx_reset_queue(ndq);
 	}
 }
 
@@ -1388,7 +1392,7 @@ static int ionic_tx_tcp_pseudo_csum(struct sk_buff *skb)
 	return 0;
 }
 
-static void ionic_tx_tso_post(struct ionic_queue *q,
+static void ionic_tx_tso_post(struct net_device *netdev, struct ionic_queue *q,
 			      struct ionic_desc_info *desc_info,
 			      struct sk_buff *skb,
 			      dma_addr_t addr, u8 nsge, u16 len,
@@ -1418,14 +1422,15 @@ static void ionic_tx_tso_post(struct ionic_queue *q,
 	if (start) {
 		skb_tx_timestamp(skb);
 		if (!ionic_txq_hwstamp_enabled(q))
-			netdev_tx_sent_queue(q_to_ndq(q), skb->len);
+			netdev_tx_sent_queue(q_to_ndq(netdev, q), skb->len);
 		ionic_txq_post(q, false, ionic_tx_clean, skb);
 	} else {
 		ionic_txq_post(q, done, NULL, NULL);
 	}
 }
 
-static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb)
+static int ionic_tx_tso(struct net_device *netdev, struct ionic_queue *q,
+			struct sk_buff *skb)
 {
 	struct ionic_tx_stats *stats = q_to_tx_stats(q);
 	struct ionic_desc_info *desc_info;
@@ -1533,7 +1538,7 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb)
 		seg_rem = min(tso_rem, mss);
 		done = (tso_rem == 0);
 		/* post descriptor */
-		ionic_tx_tso_post(q, desc_info, skb,
+		ionic_tx_tso_post(netdev, q, desc_info, skb,
 				  desc_addr, desc_nsge, desc_len,
 				  hdrlen, mss, outer_csum, vlan_tci, has_vlan,
 				  start, done);
@@ -1643,7 +1648,8 @@ static void ionic_tx_skb_frags(struct ionic_queue *q, struct sk_buff *skb,
 	stats->frags += skb_shinfo(skb)->nr_frags;
 }
 
-static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb)
+static int ionic_tx(struct net_device *netdev, struct ionic_queue *q,
+		    struct sk_buff *skb)
 {
 	struct ionic_desc_info *desc_info = &q->info[q->head_idx];
 	struct ionic_tx_stats *stats = q_to_tx_stats(q);
@@ -1666,7 +1672,7 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb)
 	stats->bytes += skb->len;
 
 	if (!ionic_txq_hwstamp_enabled(q)) {
-		struct netdev_queue *ndq = q_to_ndq(q);
+		struct netdev_queue *ndq = q_to_ndq(netdev, q);
 
 		if (unlikely(!ionic_q_has_space(q, MAX_SKB_FRAGS + 1)))
 			netif_tx_stop_queue(ndq);
@@ -1789,9 +1795,9 @@ static netdev_tx_t ionic_start_hwstamp_xmit(struct sk_buff *skb,
 
 	skb_shinfo(skb)->tx_flags |= SKBTX_HW_TSTAMP;
 	if (skb_is_gso(skb))
-		err = ionic_tx_tso(q, skb);
+		err = ionic_tx_tso(netdev, q, skb);
 	else
-		err = ionic_tx(q, skb);
+		err = ionic_tx(netdev, q, skb);
 
 	if (err)
 		goto err_out_drop;
@@ -1829,15 +1835,15 @@ netdev_tx_t ionic_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	if (ndescs < 0)
 		goto err_out_drop;
 
-	if (!netif_txq_maybe_stop(q_to_ndq(q),
+	if (!netif_txq_maybe_stop(q_to_ndq(netdev, q),
 				  ionic_q_space_avail(q),
 				  ndescs, ndescs))
 		return NETDEV_TX_BUSY;
 
 	if (skb_is_gso(skb))
-		err = ionic_tx_tso(q, skb);
+		err = ionic_tx_tso(netdev, q, skb);
 	else
-		err = ionic_tx(q, skb);
+		err = ionic_tx(netdev, q, skb);
 
 	if (err)
 		goto err_out_drop;
-- 
2.17.1


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

* [PATCH net-next 08/12] ionic: reduce the use of netdev
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (6 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 07/12] ionic: Pass local netdev instead of referencing struct Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 09/12] ionic: change the hwstamp likely check Shannon Nelson
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

To help make sure we're only accessing things we really need
to access we can cut down on the q->lif->netdev references by
using q->dev which is already in cache.

Reviewed-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 .../net/ethernet/pensando/ionic/ionic_txrx.c   | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index f217b9875f1b..ed095696f67a 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -123,7 +123,6 @@ static unsigned int ionic_rx_buf_size(struct ionic_buf_info *buf_info)
 static int ionic_rx_page_alloc(struct ionic_queue *q,
 			       struct ionic_buf_info *buf_info)
 {
-	struct net_device *netdev = q->lif->netdev;
 	struct ionic_rx_stats *stats;
 	struct device *dev;
 	struct page *page;
@@ -133,14 +132,14 @@ static int ionic_rx_page_alloc(struct ionic_queue *q,
 
 	if (unlikely(!buf_info)) {
 		net_err_ratelimited("%s: %s invalid buf_info in alloc\n",
-				    netdev->name, q->name);
+				    dev_name(dev), q->name);
 		return -EINVAL;
 	}
 
 	page = alloc_pages(IONIC_PAGE_GFP_MASK, 0);
 	if (unlikely(!page)) {
 		net_err_ratelimited("%s: %s page alloc failed\n",
-				    netdev->name, q->name);
+				    dev_name(dev), q->name);
 		stats->alloc_err++;
 		return -ENOMEM;
 	}
@@ -150,7 +149,7 @@ static int ionic_rx_page_alloc(struct ionic_queue *q,
 	if (unlikely(dma_mapping_error(dev, buf_info->dma_addr))) {
 		__free_pages(page, 0);
 		net_err_ratelimited("%s: %s dma map failed\n",
-				    netdev->name, q->name);
+				    dev_name(dev), q->name);
 		stats->dma_map_err++;
 		return -EIO;
 	}
@@ -164,12 +163,11 @@ static int ionic_rx_page_alloc(struct ionic_queue *q,
 static void ionic_rx_page_free(struct ionic_queue *q,
 			       struct ionic_buf_info *buf_info)
 {
-	struct net_device *netdev = q->lif->netdev;
 	struct device *dev = q->dev;
 
 	if (unlikely(!buf_info)) {
 		net_err_ratelimited("%s: %s invalid buf_info in free\n",
-				    netdev->name, q->name);
+				    dev_name(dev), q->name);
 		return;
 	}
 
@@ -228,7 +226,7 @@ static struct sk_buff *ionic_rx_frags(struct net_device *netdev,
 	skb = napi_get_frags(&q_to_qcq(q)->napi);
 	if (unlikely(!skb)) {
 		net_warn_ratelimited("%s: SKB alloc failed on %s!\n",
-				     netdev->name, q->name);
+				     dev_name(dev), q->name);
 		stats->alloc_err++;
 		return NULL;
 	}
@@ -291,7 +289,7 @@ static struct sk_buff *ionic_rx_copybreak(struct net_device *netdev,
 	skb = napi_alloc_skb(&q_to_qcq(q)->napi, len);
 	if (unlikely(!skb)) {
 		net_warn_ratelimited("%s: SKB alloc failed on %s!\n",
-				     netdev->name, q->name);
+				     dev_name(dev), q->name);
 		stats->alloc_err++;
 		return NULL;
 	}
@@ -1086,7 +1084,7 @@ static dma_addr_t ionic_tx_map_single(struct ionic_queue *q,
 	dma_addr = dma_map_single(dev, data, len, DMA_TO_DEVICE);
 	if (dma_mapping_error(dev, dma_addr)) {
 		net_warn_ratelimited("%s: DMA single map failed on %s!\n",
-				     q->lif->netdev->name, q->name);
+				     dev_name(dev), q->name);
 		stats->dma_map_err++;
 		return 0;
 	}
@@ -1104,7 +1102,7 @@ static dma_addr_t ionic_tx_map_frag(struct ionic_queue *q,
 	dma_addr = skb_frag_dma_map(dev, frag, offset, len, DMA_TO_DEVICE);
 	if (dma_mapping_error(dev, dma_addr)) {
 		net_warn_ratelimited("%s: DMA frag map failed on %s!\n",
-				     q->lif->netdev->name, q->name);
+				     dev_name(dev), q->name);
 		stats->dma_map_err++;
 	}
 	return dma_addr;
-- 
2.17.1


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

* [PATCH net-next 09/12] ionic: change the hwstamp likely check
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (7 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 08/12] ionic: reduce the use of netdev Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 10/12] ionic: Use CQE profile for dim Shannon Nelson
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

An earlier change moved the hwstamp queue check into a helper
function with an unlikely(). However, it makes more sense for
the caller to decide if it's likely() or unlikely(), so make
the change to support that.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_lif.h  |  2 +-
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h
index 42006de8069d..b4f8692a3ead 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h
@@ -327,7 +327,7 @@ static inline u32 ionic_coal_usec_to_hw(struct ionic *ionic, u32 usecs)
 
 static inline bool ionic_txq_hwstamp_enabled(struct ionic_queue *q)
 {
-	return unlikely(q->features & IONIC_TXQ_F_HWSTAMP);
+	return q->features & IONIC_TXQ_F_HWSTAMP;
 }
 
 void ionic_link_status_check_request(struct ionic_lif *lif, bool can_sleep);
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index ed095696f67a..89a40657c689 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -1201,7 +1201,7 @@ static void ionic_tx_clean(struct ionic_queue *q,
 	if (!skb)
 		return;
 
-	if (ionic_txq_hwstamp_enabled(q)) {
+	if (unlikely(ionic_txq_hwstamp_enabled(q))) {
 		if (cq_info) {
 			struct skb_shared_hwtstamps hwts = {};
 			__le64 *cq_desc_hwstamp;
@@ -1296,7 +1296,7 @@ unsigned int ionic_tx_cq_service(struct ionic_cq *cq, unsigned int work_to_do)
 	if (work_done) {
 		struct ionic_queue *q = cq->bound_q;
 
-		if (!ionic_txq_hwstamp_enabled(q))
+		if (likely(!ionic_txq_hwstamp_enabled(q)))
 			netif_txq_completed_wake(q_to_ndq(q->lif->netdev, q),
 						 pkts, bytes,
 						 ionic_q_space_avail(q),
@@ -1337,7 +1337,7 @@ void ionic_tx_empty(struct ionic_queue *q)
 		desc_info->cb_arg = NULL;
 	}
 
-	if (!ionic_txq_hwstamp_enabled(q)) {
+	if (likely(!ionic_txq_hwstamp_enabled(q))) {
 		struct netdev_queue *ndq = q_to_ndq(q->lif->netdev, q);
 
 		netdev_tx_completed_queue(ndq, pkts, bytes);
@@ -1419,7 +1419,7 @@ static void ionic_tx_tso_post(struct net_device *netdev, struct ionic_queue *q,
 
 	if (start) {
 		skb_tx_timestamp(skb);
-		if (!ionic_txq_hwstamp_enabled(q))
+		if (likely(!ionic_txq_hwstamp_enabled(q)))
 			netdev_tx_sent_queue(q_to_ndq(netdev, q), skb->len);
 		ionic_txq_post(q, false, ionic_tx_clean, skb);
 	} else {
@@ -1669,7 +1669,7 @@ static int ionic_tx(struct net_device *netdev, struct ionic_queue *q,
 	stats->pkts++;
 	stats->bytes += skb->len;
 
-	if (!ionic_txq_hwstamp_enabled(q)) {
+	if (likely(!ionic_txq_hwstamp_enabled(q))) {
 		struct netdev_queue *ndq = q_to_ndq(netdev, q);
 
 		if (unlikely(!ionic_q_has_space(q, MAX_SKB_FRAGS + 1)))
-- 
2.17.1


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

* [PATCH net-next 10/12] ionic: Use CQE profile for dim
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (8 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 09/12] ionic: change the hwstamp likely check Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 11/12] ionic: Clean RCT ordering issues Shannon Nelson
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

Use the kernel's CQE dim table to align better with the
driver's use of completion queues, and use the tx moderation
when using Tx interrupts.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
index 35a1d9927493..85255e5e8ad0 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -52,15 +52,20 @@ static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q);
 static void ionic_dim_work(struct work_struct *work)
 {
 	struct dim *dim = container_of(work, struct dim, work);
-	struct ionic_intr_info *intr;
 	struct dim_cq_moder cur_moder;
+	struct ionic_intr_info *intr;
 	struct ionic_qcq *qcq;
 	struct ionic_lif *lif;
+	struct ionic_queue *q;
 	u32 new_coal;
 
-	cur_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
 	qcq = container_of(dim, struct ionic_qcq, dim);
-	lif = qcq->q.lif;
+	q = &qcq->q;
+	if (q->type == IONIC_QTYPE_RXQ)
+		cur_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
+	else
+		cur_moder = net_dim_get_tx_moderation(dim->mode, dim->profile_ix);
+	lif = q->lif;
 	new_coal = ionic_coal_usec_to_hw(lif->ionic, cur_moder.usec);
 	new_coal = new_coal ? new_coal : 1;
 
@@ -685,7 +690,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
 	}
 
 	INIT_WORK(&new->dim.work, ionic_dim_work);
-	new->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+	new->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_CQE;
 
 	*qcq = new;
 
-- 
2.17.1


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

* [PATCH net-next 11/12] ionic: Clean RCT ordering issues
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (9 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 10/12] ionic: Use CQE profile for dim Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-02-29 19:39 ` [PATCH net-next 12/12] ionic: change MODULE_AUTHOR to person name Shannon Nelson
  2024-03-04  9:40 ` [PATCH net-next 00/12] ionic: code cleanup and performance tuning patchwork-bot+netdevbpf
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

From: Brett Creeley <brett.creeley@amd.com>

Clean up complaints from an xmastree.py scan.

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_debugfs.c | 2 +-
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c    | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c b/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c
index 91327ef670c7..c3ae11a48024 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c
@@ -113,8 +113,8 @@ static const struct debugfs_reg32 intr_ctrl_regs[] = {
 void ionic_debugfs_add_qcq(struct ionic_lif *lif, struct ionic_qcq *qcq)
 {
 	struct dentry *qcq_dentry, *q_dentry, *cq_dentry;
-	struct dentry *intr_dentry, *stats_dentry;
 	struct ionic_dev *idev = &lif->ionic->idev;
+	struct dentry *intr_dentry, *stats_dentry;
 	struct debugfs_regset32 *intr_ctrl_regset;
 	struct ionic_intr_info *intr = &qcq->intr;
 	struct debugfs_blob_wrapper *desc_blob;
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index 89a40657c689..6d168ad8c84f 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -40,8 +40,8 @@ static inline void ionic_rxq_post(struct ionic_queue *q, bool ring_dbell,
 
 bool ionic_txq_poke_doorbell(struct ionic_queue *q)
 {
-	unsigned long now, then, dif;
 	struct netdev_queue *netdev_txq;
+	unsigned long now, then, dif;
 	struct net_device *netdev;
 
 	netdev = q->lif->netdev;
@@ -1776,7 +1776,7 @@ static netdev_tx_t ionic_start_hwstamp_xmit(struct sk_buff *skb,
 					    struct net_device *netdev)
 {
 	struct ionic_lif *lif = netdev_priv(netdev);
-	struct ionic_queue *q = &lif->hwstamp_txq->q;
+	struct ionic_queue *q;
 	int err, ndescs;
 
 	/* Does not stop/start txq, because we post to a separate tx queue
@@ -1784,6 +1784,7 @@ static netdev_tx_t ionic_start_hwstamp_xmit(struct sk_buff *skb,
 	 * the timestamping queue, it is dropped.
 	 */
 
+	q = &lif->hwstamp_txq->q;
 	ndescs = ionic_tx_descs_needed(q, skb);
 	if (unlikely(ndescs < 0))
 		goto err_out_drop;
-- 
2.17.1


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

* [PATCH net-next 12/12] ionic: change MODULE_AUTHOR to person name
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (10 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 11/12] ionic: Clean RCT ordering issues Shannon Nelson
@ 2024-02-29 19:39 ` Shannon Nelson
  2024-03-04  9:40 ` [PATCH net-next 00/12] ionic: code cleanup and performance tuning patchwork-bot+netdevbpf
  12 siblings, 0 replies; 14+ messages in thread
From: Shannon Nelson @ 2024-02-29 19:39 UTC (permalink / raw)
  To: netdev, davem, kuba, edumazet, pabeni
  Cc: brett.creeley, drivers, Shannon Nelson

The MODULE_AUTHOR macro is supposed to be a person
not a company.

Reviewed-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c
index 165ab08ad2dd..7a1974668d4c 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_main.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c
@@ -15,7 +15,7 @@
 #include "ionic_debugfs.h"
 
 MODULE_DESCRIPTION(IONIC_DRV_DESCRIPTION);
-MODULE_AUTHOR("Pensando Systems, Inc");
+MODULE_AUTHOR("Shannon Nelson <shannon.nelson@amd.com>");
 MODULE_LICENSE("GPL");
 
 static const char *ionic_error_to_str(enum ionic_status_code code)
-- 
2.17.1


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

* Re: [PATCH net-next 00/12] ionic: code cleanup and performance tuning
  2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
                   ` (11 preceding siblings ...)
  2024-02-29 19:39 ` [PATCH net-next 12/12] ionic: change MODULE_AUTHOR to person name Shannon Nelson
@ 2024-03-04  9:40 ` patchwork-bot+netdevbpf
  12 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-04  9:40 UTC (permalink / raw)
  To: Nelson, Shannon
  Cc: netdev, davem, kuba, edumazet, pabeni, brett.creeley, drivers

Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 29 Feb 2024 11:39:23 -0800 you wrote:
> Brett has been performance testing and code tweaking and has
> come up with several improvements for our fast path operations.
> 
> In a simple single thread / single queue iperf case on a 1500 MTU
> connection we see an improvement from 74.2 to 86.7 Gbits/sec.
> 
> Brett Creeley (10):
>   ionic: Rework Tx start/stop flow
>   ionic: Change default number of descriptors for Tx and Rx
>   ionic: Shorten a Tx hotpath
>   ionic: Make use napi_consume_skb
>   ionic: Clean up BQL logic
>   ionic: Check stop no restart
>   ionic: Pass local netdev instead of referencing struct
>   ionic: change the hwstamp likely check
>   ionic: Use CQE profile for dim
>   ionic: Clean RCT ordering issues
> 
> [...]

Here is the summary with links:
  - [net-next,01/12] ionic: Rework Tx start/stop flow
    https://git.kernel.org/netdev/net-next/c/061b9bedbef1
  - [net-next,02/12] ionic: Change default number of descriptors for Tx and Rx
    https://git.kernel.org/netdev/net-next/c/4d140402c6e8
  - [net-next,03/12] ionic: Shorten a Tx hotpath
    https://git.kernel.org/netdev/net-next/c/97085cda1227
  - [net-next,04/12] ionic: Make use napi_consume_skb
    https://git.kernel.org/netdev/net-next/c/386e69865311
  - [net-next,05/12] ionic: Clean up BQL logic
    https://git.kernel.org/netdev/net-next/c/bc581273fead
  - [net-next,06/12] ionic: Check stop no restart
    https://git.kernel.org/netdev/net-next/c/138506ab249b
  - [net-next,07/12] ionic: Pass local netdev instead of referencing struct
    https://git.kernel.org/netdev/net-next/c/1937b7ab6bd6
  - [net-next,08/12] ionic: reduce the use of netdev
    https://git.kernel.org/netdev/net-next/c/25623ab9cb37
  - [net-next,09/12] ionic: change the hwstamp likely check
    https://git.kernel.org/netdev/net-next/c/b889bfe5bd0c
  - [net-next,10/12] ionic: Use CQE profile for dim
    https://git.kernel.org/netdev/net-next/c/8aacc71399be
  - [net-next,11/12] ionic: Clean RCT ordering issues
    https://git.kernel.org/netdev/net-next/c/bc40b88930bf
  - [net-next,12/12] ionic: change MODULE_AUTHOR to person name
    https://git.kernel.org/netdev/net-next/c/217397da4d52

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-03-04  9:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-29 19:39 [PATCH net-next 00/12] ionic: code cleanup and performance tuning Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 01/12] ionic: Rework Tx start/stop flow Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 02/12] ionic: Change default number of descriptors for Tx and Rx Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 03/12] ionic: Shorten a Tx hotpath Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 04/12] ionic: Make use napi_consume_skb Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 05/12] ionic: Clean up BQL logic Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 06/12] ionic: Check stop no restart Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 07/12] ionic: Pass local netdev instead of referencing struct Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 08/12] ionic: reduce the use of netdev Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 09/12] ionic: change the hwstamp likely check Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 10/12] ionic: Use CQE profile for dim Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 11/12] ionic: Clean RCT ordering issues Shannon Nelson
2024-02-29 19:39 ` [PATCH net-next 12/12] ionic: change MODULE_AUTHOR to person name Shannon Nelson
2024-03-04  9:40 ` [PATCH net-next 00/12] ionic: code cleanup and performance tuning patchwork-bot+netdevbpf

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).