Skip to contentSkip to conversation

qede: fix ethernet self adapter and skb failure issue

PATCH In review Bhaskar Upadhaya 2 participants 6 messages Mar 16, 2021 – Mar 17, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover qede: fix ethernet self adapter and skb failure issue

Patch 1: Fix ethernet self adapter test issue by preventing start_xmit
function to be called.start_xmit function should not be called during the execution of self adapter test, netif_tx_disable() ensures this.
Patch 2: Fix to return proper error code when sdk buffer allocation fails.

Bhaskar Upadhaya (2):
qede: fix to disable start_xmit functionality during self adapter test
qede: fix memory allocation failures under heavy load

 .../net/ethernet/qlogic/qede/qede_ethtool.c   |  4 +++-
 drivers/net/ethernet/qlogic/qede/qede_fp.c    | 19 +++++++++++++------
 2 files changed, 16 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 qede: fix to disable start_xmit functionality during self adapter test

start_xmit function should not be called during the execution of self adapter test, netif_tx_disable() gives this guarantee, since it takes the transmit queue lock while marking the queue stopped. This will wait for the transmit function to complete before returning.

Fixes 16f46bf054f8 ("qede: add implementation for internal loopback test.")
---
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +3 -1
index 1560ad3d9290..f9702cc7bc55 100644
@@ -1611,7 +1611,7 @@ static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
 		return -EINVAL;
 	}
 
-	qede_netif_stop(edev);
+	netif_tx_disable(edev->ndev);
 
 	/* Bring up the link in Loopback mode */
 	memset(&link_params, 0, sizeof(link_params));
@@ -1623,6 +1623,8 @@ static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
 	/* Wait for loopback configuration to apply */
 	msleep_interruptible(500);
 
+	qede_netif_stop(edev);
+
 	/* Setting max packet size to 1.5K to avoid data being split over
 	 * multiple BDs in cases where MTU > PAGE_SIZE.
 	 */
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH net 1/2] qede: fix to disable start_xmit functionality during self adapter test

Quoted 18 lines · On Tue, 16 Mar 2021 11:34:09 -0700 Bhaskar Upadhaya wrote:

start_xmit function should not be called during the execution of self adapter test, netif_tx_disable() gives this guarantee, since it takes the transmit queue lock while marking the queue stopped. This will wait for the transmit function to complete before returning.

Fixes 16f46bf054f8 ("qede: add implementation for internal loopback test.")
---
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +0 -0
index 1560ad3d9290..f9702cc7bc55 100644

drivers/net/ethernet/qlogic/qede/qede_ethtool.c static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode) · line 1614

Quoted 5 lines
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +1 -1
@@ -1611,7 +1611,7 @@ static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
 		return -EINVAL;
 	}
 
-	qede_netif_stop(edev);
+	netif_tx_disable(edev->ndev);

But an interrupt can come in after and enable Tx again.
I think you should keep the qede_netif_stop() here instead of moving it down, no?

Quoted 11 lines
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +2 -0
 	/* Bring up the link in Loopback mode */
 	memset(&link_params, 0, sizeof(link_params));
@@ -1623,6 +1623,8 @@ static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
 	/* Wait for loopback configuration to apply */
 	msleep_interruptible(500);
 
+	qede_netif_stop(edev);
+
 	/* Setting max packet size to 1.5K to avoid data being split over
 	 * multiple BDs in cases where MTU > PAGE_SIZE.
 	 */
#3 lore raw

RE: [EXT] Re: [PATCH net 1/2] qede: fix to disable start_xmit functionality during self adapter test

Quoted 39 lines

-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, March 17, 2021 3:30 AM
To: Bhaskar Upadhaya <[email protected]>
Cc: [email protected]; Ariel Elior <[email protected]>; Igor Russkikh <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH net 1/2] qede: fix to disable start_xmit functionality during self adapter test

External Email

----------------------------------------------------------------------

drivers/net/ethernet/qlogic/qede/qede_ethtool.c static int qede_selftest_run_loopback(struct

Quoted 20 lines · On Tue, 16 Mar 2021 11:34:09 -0700 Bhaskar Upadhaya wrote:

start_xmit function should not be called during the execution of self adapter test, netif_tx_disable() gives this guarantee, since it takes the transmit queue lock while marking the queue stopped. This will wait for the transmit function to complete before returning.

Fixes 16f46bf054f8 ("qede: add implementation for internal loopback

test.")

---
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +0 -0
index 1560ad3d9290..f9702cc7bc55 100644
@@ -1611,7 +1611,7 @@ static int qede_selftest_run_loopback(struct

qede_dev *edev, u32 loopback_mode)

Quoted 3 lines
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +0 -0
 		return -EINVAL;
 	}
 
Quoted 6 lines

drivers/net/ethernet/qlogic/qede/qede_ethtool.c static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode) · line 1614

Quoted 2 lines
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +1 -1
-	qede_netif_stop(edev);
+	netif_tx_disable(edev->ndev);

But an interrupt can come in after and enable Tx again.
I think you should keep the qede_netif_stop() here instead of moving it down, no?

Hi Jakub,
Normal Traffic flow is enabled by qede_netif_start(edev) and which is placed at the end of this qede_selftest_run_loopback() qede_netif_stop(edev) is called prior to the call to qede_netif_start(edev), so unless qede_netif_start(edev) is called Normal traffic flow will not be operational.

Quoted 14 lines

drivers/net/ethernet/qlogic/qede/qede_ethtool.c static int qede_selftest_run_loopback(struct · line 1616

Quoted 3 lines
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +0 -0
 	/* Bring up the link in Loopback mode */
 	memset(&link_params, 0, sizeof(link_params)); @@ -1623,6 +1623,8

@@

Quoted 1 line

static int qede_selftest_run_loopback(struct qede_dev *edev, u32

loopback_mode)

Quoted 8 lines
drivers/net/ethernet/qlogic/qede/qede_ethtool.c +2 -0
 	/* Wait for loopback configuration to apply */
 	msleep_interruptible(500);
 
+	qede_netif_stop(edev);
+
 	/* Setting max packet size to 1.5K to avoid data being split over
 	 * multiple BDs in cases where MTU > PAGE_SIZE.
 	 */
maintainer
#4 lore raw

Re: [EXT] Re: [PATCH net 1/2] qede: fix to disable start_xmit functionality during self adapter test

Quoted 8 lines · On Wed, 17 Mar 2021 06:33:37 +0000 Bhaskar Upadhaya wrote:
Quoted 3 lines

But an interrupt can come in after and enable Tx again.
I think you should keep the qede_netif_stop() here instead of moving it down, no?

Hi Jakub,
Normal Traffic flow is enabled by qede_netif_start(edev) and which is placed at the end of this qede_selftest_run_loopback() qede_netif_stop(edev) is called prior to the call to qede_netif_start(edev), so unless qede_netif_start(edev) is called Normal traffic flow will not be operational.

I'm not talking about submitting more traffic.

Consider the following order of events

normal traffic test

xmit()
netif_tx_disable()
IRQ
NAPI
netif_tx_wake_queue()

     <--- traffic running again --->

			qede_netif_stop()
#5 lore raw

PATCH 2/2 qede: fix memory allocation failures under heavy load

In reply to Bhaskar Upadhaya

when the system is heavily stressed, kernel get lots of memory allocation failures which causes kernel panic, so enable proper error handling during skb allocation

Fixes 8a8633978b84 ("qede: Add build_skb() support.")
---
 drivers/net/ethernet/qlogic/qede/qede_fp.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_fp.c +13 -6
index 8c47a9d2a965..f2d74b53e421 100644
@@ -751,6 +751,8 @@ qede_build_skb(struct qede_rx_queue *rxq,
 
 	buf = page_address(bd->data) + bd->page_offset;
 	skb = build_skb(buf, rxq->rx_buf_seg_size);
+	if (unlikely(!skb))
+		return NULL;
 
 	skb_reserve(skb, pad);
 	skb_put(skb, len);
@@ -767,6 +769,9 @@ qede_tpa_rx_build_skb(struct qede_dev *edev,
 	struct sk_buff *skb;
 
 	skb = qede_build_skb(rxq, bd, len, pad);
+	if (unlikely(!skb))
+		return NULL;
+
 	bd->page_offset += rxq->rx_buf_seg_size;
 
 	if (bd->page_offset == PAGE_SIZE) {
@@ -814,6 +819,8 @@ qede_rx_build_skb(struct qede_dev *edev,
 	}
 
 	skb = qede_build_skb(rxq, bd, len, pad);
+	if (unlikely(!skb))
+		return NULL;
 
 	if (unlikely(qede_realloc_rx_buffer(rxq, bd))) {
 		/* Incr page ref count to reuse on allocation failure so
@@ -851,11 +858,16 @@ static void qede_tpa_start(struct qede_dev *edev,
 	if (unlikely(!tpa_info->skb)) {
 		DP_NOTICE(edev, "Failed to allocate SKB for gro\n");
 
+		/* Re-use the buffer instantly instead doing it at tpa_end
+		 * as we are already going to throw away this aggregated packet
+		 * (i.e CQEs till tpa_end) and then going to update the
+		 * producer, so it's safe to pin the buffer here only.
+		 */
+		qede_reuse_page(rxq, sw_rx_data_cons);
 		/* Consume from ring but do not produce since
 		 * this might be used by FW still, it will be re-used
 		 * at TPA end.
 		 */
-		tpa_info->tpa_start_fail = true;
 		qede_rx_bd_ring_consume(rxq);
 		tpa_info->state = QEDE_AGG_STATE_ERROR;
 		goto cons_buf;
@@ -1025,11 +1037,6 @@ static int qede_tpa_end(struct qede_dev *edev,
 err:
 	tpa_info->state = QEDE_AGG_STATE_NONE;
 
-	if (tpa_info->tpa_start_fail) {
-		qede_reuse_page(rxq, &tpa_info->buffer);
-		tpa_info->tpa_start_fail = false;
-	}
-
 	dev_kfree_skb_any(tpa_info->skb);
 	tpa_info->skb = NULL;
 	return 0;
Signature · 1 line
2.17.1