Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Oct 2015 01:54:16 +0000 (UTC)
From:      "Conrad E. Meyer" <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289613 - head/sys/dev/ntb/if_ntb
Message-ID:  <201510200154.t9K1sGLe030942@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Tue Oct 20 01:54:16 2015
New Revision: 289613
URL: https://svnweb.freebsd.org/changeset/base/289613

Log:
  if_ntb: MFV 2849b5d7: Reset transport QP link stats on down
  
  Reset the link stats when the link goes down.  In particular, the TX and
  RX index and count must be reset, or else the TX side will be sending
  packets to the RX side where the RX side is not expecting them.  Reset
  all the stats, to be consistent.
  
  Authored by:	Allen Hubbe
  Obtained from:	Linux (Dual BSD/GPL driver)
  Sponsored by:	EMC / Isilon Storage Division

Modified:
  head/sys/dev/ntb/if_ntb/if_ntb.c

Modified: head/sys/dev/ntb/if_ntb/if_ntb.c
==============================================================================
--- head/sys/dev/ntb/if_ntb/if_ntb.c	Tue Oct 20 01:54:08 2015	(r289612)
+++ head/sys/dev/ntb/if_ntb/if_ntb.c	Tue Oct 20 01:54:16 2015	(r289613)
@@ -300,6 +300,7 @@ static int ntb_transport_setup_qp_mw(str
 static void ntb_qp_link_work(void *arg);
 static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt);
 static void ntb_qp_link_down(struct ntb_transport_qp *qp);
+static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp);
 static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp);
 static void ntb_transport_link_down(struct ntb_transport_qp *qp);
 static void ntb_send_link_down(struct ntb_transport_qp *qp);
@@ -642,9 +643,9 @@ ntb_transport_init_queue(struct ntb_tran
 	qp->qp_num = qp_num;
 	qp->transport = nt;
 	qp->ntb = nt->ntb;
-	qp->link_is_up = false;
 	qp->client_ready = false;
 	qp->event_handler = NULL;
+	ntb_qp_link_down_reset(qp);
 
 	if (nt->qp_count % mw_count && mw_num + 1 < nt->qp_count / mw_count)
 		num_qps_mw = nt->qp_count / mw_count + 1;
@@ -1444,16 +1445,28 @@ ntb_qp_link_down(struct ntb_transport_qp
 }
 
 static void
+ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
+{
+
+	qp->link_is_up = false;
+
+	qp->tx_index = qp->rx_index = 0;
+	qp->tx_bytes = qp->rx_bytes = 0;
+	qp->tx_pkts = qp->rx_pkts = 0;
+
+	qp->rx_ring_empty = 0;
+	qp->tx_ring_full = 0;
+
+	qp->rx_err_no_buf = qp->rx_err_oflow = qp->rx_err_ver = 0;
+}
+
+static void
 ntb_qp_link_cleanup(struct ntb_transport_qp *qp)
 {
 	struct ntb_transport_ctx *nt = qp->transport;
 
-	if (!qp->link_is_up) {
-		callout_drain(&qp->link_work);
-		return;
-	}
-
-	qp->link_is_up = false;
+	callout_drain(&qp->link_work);
+	ntb_qp_link_down_reset(qp);
 
 	if (qp->event_handler != NULL)
 		qp->event_handler(qp->cb_data, NTB_LINK_DOWN);
@@ -1502,8 +1515,6 @@ ntb_send_link_down(struct ntb_transport_
 	if (!qp->link_is_up)
 		return;
 
-	qp->link_is_up = false;
-
 	for (i = 0; i < NTB_LINK_DOWN_TIMEOUT; i++) {
 		entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q);
 		if (entry != NULL)
@@ -1524,6 +1535,8 @@ ntb_send_link_down(struct ntb_transport_
 	if (rc != 0)
 		printf("ntb: Failed to send link down\n");
 	mtx_unlock(&qp->transport->tx_lock);
+
+	ntb_qp_link_down_reset(qp);
 }
 
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510200154.t9K1sGLe030942>