aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ntb/if_ntb/if_ntb.c
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2015-10-20 01:54:16 +0000
committerConrad Meyer <cem@FreeBSD.org>2015-10-20 01:54:16 +0000
commit25ff5df7c4a45a988b251dd78d3e04567265c08b (patch)
treeff1ef07c0856e75fdc0836f0ddc753ede012305c /sys/dev/ntb/if_ntb/if_ntb.c
parent0326e4d6b5f641f5cf0784891b994acd70022c97 (diff)
downloadsrc-25ff5df7c4a45a988b251dd78d3e04567265c08b.tar.gz
src-25ff5df7c4a45a988b251dd78d3e04567265c08b.zip
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
Notes
Notes: svn path=/head/; revision=289613
Diffstat (limited to 'sys/dev/ntb/if_ntb/if_ntb.c')
-rw-r--r--sys/dev/ntb/if_ntb/if_ntb.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/sys/dev/ntb/if_ntb/if_ntb.c b/sys/dev/ntb/if_ntb/if_ntb.c
index 81dcc80890ab..32642ddcaaaa 100644
--- a/sys/dev/ntb/if_ntb/if_ntb.c
+++ b/sys/dev/ntb/if_ntb/if_ntb.c
@@ -300,6 +300,7 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
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_transport_ctx *nt, unsigned int qp_num)
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 *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_qp *qp)
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_qp *qp)
if (rc != 0)
printf("ntb: Failed to send link down\n");
mtx_unlock(&qp->transport->tx_lock);
+
+ ntb_qp_link_down_reset(qp);
}