summaryrefslogtreecommitdiffstats
path: root/sys/dev/cxgbe/tom/t4_tom.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2016-12-02 20:16:52 +0000
committerjhb <jhb@FreeBSD.org>2016-12-02 20:16:52 +0000
commit42435a8367c86ff246ab4a7fe35c62dd984626e9 (patch)
treea6b697f4aa45e4bc4489085b52e9e33033ef0467 /sys/dev/cxgbe/tom/t4_tom.c
parent67ad66625262bc74bcf30a2c9e79bfe83ba20dea (diff)
downloadFreeBSD-src-42435a8367c86ff246ab4a7fe35c62dd984626e9.zip
FreeBSD-src-42435a8367c86ff246ab4a7fe35c62dd984626e9.tar.gz
MFC 292736:
cxgbe(4): Updates to the base NIC driver and t4_tom to support the iSCSI offload driver. These changes come from projects/cxl_iscsi. Note that these changes make use of the mbufq API from 11.0, but that API is not present in 10.x in the same form. Borrow an implementation from the CAM CTL ha code that uses m_nextpkt to implement mbufq for use in 10.
Diffstat (limited to 'sys/dev/cxgbe/tom/t4_tom.c')
-rw-r--r--sys/dev/cxgbe/tom/t4_tom.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c
index 8d3cb2f..c4cf791 100644
--- a/sys/dev/cxgbe/tom/t4_tom.c
+++ b/sys/dev/cxgbe/tom/t4_tom.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
+#include <sys/limits.h>
#include <sys/module.h>
#include <sys/protosw.h>
#include <sys/domain.h>
@@ -103,6 +104,37 @@ static int in6_ifaddr_gen;
static eventhandler_tag ifaddr_evhandler;
static struct timeout_task clip_task;
+static void
+mbufq_init(struct mbufq *q, int limit)
+{
+
+ q->head = q->tail = NULL;
+}
+
+static void
+mbufq_drain(struct mbufq *q)
+{
+ struct mbuf *m;
+
+ while ((m = q->head) != NULL) {
+ q->head = m->m_nextpkt;
+ m_freem(m);
+ }
+ q->tail = NULL;
+}
+
+static inline int
+mbufq_len(const struct mbufq *q)
+{
+ struct mbuf *m;
+ int len;
+
+ len = 0;
+ for (m = q->head; m != NULL; m = m->m_nextpkt)
+ len++;
+ return (len);
+}
+
struct toepcb *
alloc_toepcb(struct vi_info *vi, int txqid, int rxqid, int flags)
{
@@ -155,6 +187,8 @@ alloc_toepcb(struct vi_info *vi, int txqid, int rxqid, int flags)
toep->ofld_txq = &sc->sge.ofld_txq[txqid];
toep->ofld_rxq = &sc->sge.ofld_rxq[rxqid];
toep->ctrlq = &sc->sge.ctrlq[pi->port_id];
+ mbufq_init(&toep->ulp_pduq, INT_MAX);
+ mbufq_init(&toep->ulp_pdu_reclaimq, INT_MAX);
toep->txsd_total = txsd_total;
toep->txsd_avail = txsd_total;
toep->txsd_pidx = 0;
@@ -270,6 +304,14 @@ release_offload_resources(struct toepcb *toep)
CTR5(KTR_CXGBE, "%s: toep %p (tid %d, l2te %p, ce %p)",
__func__, toep, tid, toep->l2te, toep->ce);
+ /*
+ * These queues should have been emptied at approximately the same time
+ * that a normal connection's socket's so_snd would have been purged or
+ * drained. Do _not_ clean up here.
+ */
+ MPASS(mbufq_len(&toep->ulp_pduq) == 0);
+ MPASS(mbufq_len(&toep->ulp_pdu_reclaimq) == 0);
+
if (toep->ulp_mode == ULP_MODE_TCPDDP)
release_ddp_resources(toep);
@@ -377,6 +419,7 @@ final_cpl_received(struct toepcb *toep)
toep->inp = NULL;
toep->flags &= ~TPF_CPL_PENDING;
+ mbufq_drain(&toep->ulp_pdu_reclaimq);
if (!(toep->flags & TPF_ATTACHED))
release_offload_resources(toep);
OpenPOWER on IntegriCloud