All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing
@ 2023-08-18 17:37 Dave Jiang
  2023-08-18 17:37 ` [PATCH 1/4] ntb: Clean up tx tail index on link down Dave Jiang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Dave Jiang @ 2023-08-18 17:37 UTC (permalink / raw)
  To: jdmason, allenbh; +Cc: renlonglong, Yuan Y Lu, ntb

Several ntb_transport fixes after doing long term continous netdev up/down
testing.

---

Dave Jiang (4):
      ntb: Clean up tx tail index on link down
      ntb: Drop packets when qp link is down
      ntb: Fix calculation ntb_transport_tx_free_entry()
      ntb: Check tx descriptors outstanding instead of head/tail for tx queue


 drivers/ntb/ntb_transport.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

--


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

* [PATCH 1/4] ntb: Clean up tx tail index on link down
  2023-08-18 17:37 [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Dave Jiang
@ 2023-08-18 17:37 ` Dave Jiang
  2023-08-18 17:38 ` [PATCH 2/4] ntb: Drop packets when qp link is down Dave Jiang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Dave Jiang @ 2023-08-18 17:37 UTC (permalink / raw)
  To: jdmason, allenbh; +Cc: Yuan Y Lu, Yuan Y Lu, ntb

The tx tail index is not reset when the link goes down. This causes the
tail index to go out of sync when the link goes down and comes back up.
Refactor the ntb_qp_link_down_reset() and reset the tail index as well.

Fixes: 2849b5d70641 ("NTB: Reset transport QP link stats on down")
Reported-by: Yuan Y Lu <yuan.y.lu@intel.com>
Tested-by: Yuan Y Lu <yuan.y.lu@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/ntb/ntb_transport.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index a9b97ebc71ac..fbd3beb4c3e2 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -909,7 +909,7 @@ static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw,
 	return 0;
 }
 
-static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
+static void ntb_qp_link_context_reset(struct ntb_transport_qp *qp)
 {
 	qp->link_is_up = false;
 	qp->active = false;
@@ -932,6 +932,12 @@ static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
 	qp->tx_async = 0;
 }
 
+static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
+{
+	ntb_qp_link_context_reset(qp);
+	qp->remote_rx_info->entry = qp->rx_max_entry - 1;
+}
+
 static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp)
 {
 	struct ntb_transport_ctx *nt = qp->transport;
@@ -1174,7 +1180,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt,
 	qp->ndev = nt->ndev;
 	qp->client_ready = false;
 	qp->event_handler = NULL;
-	ntb_qp_link_down_reset(qp);
+	ntb_qp_link_context_reset(qp);
 
 	if (mw_num < qp_count % mw_count)
 		num_qps_mw = qp_count / mw_count + 1;



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

* [PATCH 2/4] ntb: Drop packets when qp link is down
  2023-08-18 17:37 [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Dave Jiang
  2023-08-18 17:37 ` [PATCH 1/4] ntb: Clean up tx tail index on link down Dave Jiang
@ 2023-08-18 17:38 ` Dave Jiang
  2023-08-18 17:38 ` [PATCH 3/4] ntb: Fix calculation ntb_transport_tx_free_entry() Dave Jiang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Dave Jiang @ 2023-08-18 17:38 UTC (permalink / raw)
  To: jdmason, allenbh; +Cc: Yuan Y Lu, Yuan Y Lu, ntb

Currently when the transport receive packets after netdev has closed the
transport returns error and triggers tx errors to be incremented and
carrier to be stopped. There is no reason to return error if the device is
already closed. Drop the packet and return 0.

Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers")
Reported-by: Yuan Y Lu <yuan.y.lu@intel.com>
Tested-by: Yuan Y Lu <yuan.y.lu@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/ntb/ntb_transport.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index fbd3beb4c3e2..dd2aa3cf5c2e 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -2282,9 +2282,13 @@ int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
 	struct ntb_queue_entry *entry;
 	int rc;
 
-	if (!qp || !qp->link_is_up || !len)
+	if (!qp || !len)
 		return -EINVAL;
 
+	/* If the qp link is down already, just ignore. */
+	if (!qp->link_is_up)
+		return 0;
+
 	entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q);
 	if (!entry) {
 		qp->tx_err_no_buf++;



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

* [PATCH 3/4] ntb: Fix calculation ntb_transport_tx_free_entry()
  2023-08-18 17:37 [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Dave Jiang
  2023-08-18 17:37 ` [PATCH 1/4] ntb: Clean up tx tail index on link down Dave Jiang
  2023-08-18 17:38 ` [PATCH 2/4] ntb: Drop packets when qp link is down Dave Jiang
@ 2023-08-18 17:38 ` Dave Jiang
  2023-08-18 17:38 ` [PATCH 4/4] ntb: check tx descriptors outstanding instead of head/tail for tx queue Dave Jiang
  2023-08-18 18:11 ` [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Logan Gunthorpe
  4 siblings, 0 replies; 6+ messages in thread
From: Dave Jiang @ 2023-08-18 17:38 UTC (permalink / raw)
  To: jdmason, allenbh; +Cc: renlonglong, ntb

ntb_transport_tx_free_entry() never returns 0 with the current
calculation. If head == tail, then it would return qp->tx_max_entry.
Change compare to tail >= head and when they are equal, a 0 would be
returned.

Fixes: e74bfeedad08 ("NTB: Add flow control to the ntb_netdev")
Signed-off-by: renlonglong <ren.longlong@h3c.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/ntb/ntb_transport.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index dd2aa3cf5c2e..ec6f706ff856 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -2428,7 +2428,7 @@ unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp)
 	unsigned int head = qp->tx_index;
 	unsigned int tail = qp->remote_rx_info->entry;
 
-	return tail > head ? tail - head : qp->tx_max_entry + tail - head;
+	return tail >= head ? tail - head : qp->tx_max_entry + tail - head;
 }
 EXPORT_SYMBOL_GPL(ntb_transport_tx_free_entry);
 



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

* [PATCH 4/4] ntb: check tx descriptors outstanding instead of head/tail for tx queue
  2023-08-18 17:37 [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Dave Jiang
                   ` (2 preceding siblings ...)
  2023-08-18 17:38 ` [PATCH 3/4] ntb: Fix calculation ntb_transport_tx_free_entry() Dave Jiang
@ 2023-08-18 17:38 ` Dave Jiang
  2023-08-18 18:11 ` [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Logan Gunthorpe
  4 siblings, 0 replies; 6+ messages in thread
From: Dave Jiang @ 2023-08-18 17:38 UTC (permalink / raw)
  To: jdmason, allenbh; +Cc: ntb

Use existing function ntb_transport_tx_free_entry() instead of open coding
the check to see if there are outstanding tx descriptors.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/ntb/ntb_transport.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index ec6f706ff856..e65640107180 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -1900,7 +1900,7 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,
 static int ntb_process_tx(struct ntb_transport_qp *qp,
 			  struct ntb_queue_entry *entry)
 {
-	if (qp->tx_index == qp->remote_rx_info->entry) {
+	if (!ntb_transport_tx_free_entry(qp)) {
 		qp->tx_ring_full++;
 		return -EAGAIN;
 	}



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

* Re: [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing
  2023-08-18 17:37 [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Dave Jiang
                   ` (3 preceding siblings ...)
  2023-08-18 17:38 ` [PATCH 4/4] ntb: check tx descriptors outstanding instead of head/tail for tx queue Dave Jiang
@ 2023-08-18 18:11 ` Logan Gunthorpe
  4 siblings, 0 replies; 6+ messages in thread
From: Logan Gunthorpe @ 2023-08-18 18:11 UTC (permalink / raw)
  To: Dave Jiang, jdmason, allenbh; +Cc: renlonglong, Yuan Y Lu, ntb



On 2023-08-18 11:37, Dave Jiang wrote:
> Several ntb_transport fixes after doing long term continous netdev up/down
> testing.
> 
> ---
> 
> Dave Jiang (4):
>       ntb: Clean up tx tail index on link down
>       ntb: Drop packets when qp link is down
>       ntb: Fix calculation ntb_transport_tx_free_entry()
>       ntb: Check tx descriptors outstanding instead of head/tail for tx queue
> 

All four patches look good to me, thanks.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Logan

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

end of thread, other threads:[~2023-08-18 18:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-18 17:37 [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Dave Jiang
2023-08-18 17:37 ` [PATCH 1/4] ntb: Clean up tx tail index on link down Dave Jiang
2023-08-18 17:38 ` [PATCH 2/4] ntb: Drop packets when qp link is down Dave Jiang
2023-08-18 17:38 ` [PATCH 3/4] ntb: Fix calculation ntb_transport_tx_free_entry() Dave Jiang
2023-08-18 17:38 ` [PATCH 4/4] ntb: check tx descriptors outstanding instead of head/tail for tx queue Dave Jiang
2023-08-18 18:11 ` [PATCH 0/4] ntb: ntb_transport fixes from link up/down testing Logan Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.