git: 4b6ed0758dc6 - main - cxgbe: Make the TOE ISCSI RX stats per-queue instead of per adapter.

John Baldwin jhb at FreeBSD.org
Fri May 14 19:21:49 UTC 2021


The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4b6ed0758dc6fad17081d7bd791cb0edbddbddb8

commit 4b6ed0758dc6fad17081d7bd791cb0edbddbddb8
Author:     John Baldwin <jhb at FreeBSD.org>
AuthorDate: 2021-05-14 19:16:33 +0000
Commit:     John Baldwin <jhb at FreeBSD.org>
CommitDate: 2021-05-14 19:16:33 +0000

    cxgbe: Make the TOE ISCSI RX stats per-queue instead of per adapter.
    
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D29903
---
 sys/dev/cxgbe/adapter.h           |  7 +++-
 sys/dev/cxgbe/cxgbei/cxgbei.c     | 83 +++------------------------------------
 sys/dev/cxgbe/cxgbei/cxgbei.h     |  6 ---
 sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 10 +++--
 sys/dev/cxgbe/t4_main.c           |  8 ++++
 sys/dev/cxgbe/t4_sge.c            | 29 +++++++++++++-
 6 files changed, 52 insertions(+), 91 deletions(-)

diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 086918b7dff9..cce58f9729c1 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -656,11 +656,16 @@ iq_to_rxq(struct sge_iq *iq)
 	return (__containerof(iq, struct sge_rxq, iq));
 }
 
-
 /* ofld_rxq: SGE ingress queue + SGE free list + miscellaneous items */
 struct sge_ofld_rxq {
 	struct sge_iq iq;	/* MUST be first */
 	struct sge_fl fl;	/* MUST follow iq */
+	counter_u64_t rx_iscsi_ddp_setup_ok;
+	counter_u64_t rx_iscsi_ddp_setup_error;
+	uint64_t rx_iscsi_ddp_pdus;
+	uint64_t rx_iscsi_ddp_octets;
+	uint64_t rx_iscsi_fl_pdus;
+	uint64_t rx_iscsi_fl_octets;
 	u_long	rx_toe_tls_records;
 	u_long	rx_toe_tls_octets;
 } __aligned(CACHE_LINE_SIZE);
diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.c b/sys/dev/cxgbe/cxgbei/cxgbei.c
index 4acdc726e75c..07f704752305 100644
--- a/sys/dev/cxgbe/cxgbei/cxgbei.c
+++ b/sys/dev/cxgbe/cxgbei/cxgbei.c
@@ -96,50 +96,6 @@ static int worker_thread_count;
 static struct cxgbei_worker_thread_softc *cwt_softc;
 static struct proc *cxgbei_proc;
 
-static void
-free_ci_counters(struct cxgbei_data *ci)
-{
-
-#define FREE_CI_COUNTER(x) do { \
-	if (ci->x != NULL) { \
-		counter_u64_free(ci->x); \
-		ci->x = NULL; \
-	} \
-} while (0)
-
-	FREE_CI_COUNTER(ddp_setup_ok);
-	FREE_CI_COUNTER(ddp_setup_error);
-	FREE_CI_COUNTER(ddp_bytes);
-	FREE_CI_COUNTER(ddp_pdus);
-	FREE_CI_COUNTER(fl_bytes);
-	FREE_CI_COUNTER(fl_pdus);
-#undef FREE_CI_COUNTER
-}
-
-static int
-alloc_ci_counters(struct cxgbei_data *ci)
-{
-
-#define ALLOC_CI_COUNTER(x) do { \
-	ci->x = counter_u64_alloc(M_WAITOK); \
-	if (ci->x == NULL) \
-		goto fail; \
-} while (0)
-
-	ALLOC_CI_COUNTER(ddp_setup_ok);
-	ALLOC_CI_COUNTER(ddp_setup_error);
-	ALLOC_CI_COUNTER(ddp_bytes);
-	ALLOC_CI_COUNTER(ddp_pdus);
-	ALLOC_CI_COUNTER(fl_bytes);
-	ALLOC_CI_COUNTER(fl_pdus);
-#undef ALLOC_CI_COUNTER
-
-	return (0);
-fail:
-	free_ci_counters(ci);
-	return (ENOMEM);
-}
-
 static void
 read_pdu_limits(struct adapter *sc, uint32_t *max_tx_pdu_len,
     uint32_t *max_rx_pdu_len)
@@ -182,10 +138,6 @@ cxgbei_init(struct adapter *sc, struct cxgbei_data *ci)
 	MPASS(sc->vres.iscsi.size > 0);
 	MPASS(ci != NULL);
 
-	rc = alloc_ci_counters(ci);
-	if (rc != 0)
-		return (rc);
-
 	read_pdu_limits(sc, &ci->max_tx_pdu_len, &ci->max_rx_pdu_len);
 
 	pr = &ci->pr;
@@ -195,7 +147,6 @@ cxgbei_init(struct adapter *sc, struct cxgbei_data *ci)
 		device_printf(sc->dev,
 		    "%s: failed to initialize the iSCSI page pod region: %u.\n",
 		    __func__, rc);
-		free_ci_counters(ci);
 		return (rc);
 	}
 
@@ -219,30 +170,9 @@ cxgbei_init(struct adapter *sc, struct cxgbei_data *ci)
 	children = SYSCTL_CHILDREN(oid);
 
 	oid = SYSCTL_ADD_NODE(&ci->ctx, children, OID_AUTO, "iscsi",
-	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "iSCSI ULP statistics");
+	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "iSCSI ULP settings");
 	children = SYSCTL_CHILDREN(oid);
 
-	SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "ddp_setup_ok",
-	    CTLFLAG_RD, &ci->ddp_setup_ok,
-	    "# of times DDP buffer was setup successfully.");
-
-	SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "ddp_setup_error",
-	    CTLFLAG_RD, &ci->ddp_setup_error,
-	    "# of times DDP buffer setup failed.");
-
-	SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "ddp_bytes",
-	    CTLFLAG_RD, &ci->ddp_bytes, "# of bytes placed directly");
-
-	SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "ddp_pdus",
-	    CTLFLAG_RD, &ci->ddp_pdus, "# of PDUs with data placed directly.");
-
-	SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "fl_bytes",
-	    CTLFLAG_RD, &ci->fl_bytes, "# of data bytes delivered in freelist");
-
-	SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "fl_pdus",
-	    CTLFLAG_RD, &ci->fl_pdus,
-	    "# of PDUs with data delivered in freelist");
-
 	ci->ddp_threshold = 2048;
 	SYSCTL_ADD_UINT(&ci->ctx, children, OID_AUTO, "ddp_threshold",
 	    CTLFLAG_RW, &ci->ddp_threshold, 0, "Rx zero copy threshold");
@@ -291,7 +221,6 @@ static int
 do_rx_iscsi_data(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 {
 	struct adapter *sc = iq->adapter;
-	struct cxgbei_data *ci = sc->iscsi_ulp_softc;
 	struct cpl_iscsi_data *cpl =  mtod(m, struct cpl_iscsi_data *);
 	u_int tid = GET_TID(cpl);
 	struct toepcb *toep = lookup_tid(sc, tid);
@@ -311,8 +240,8 @@ do_rx_iscsi_data(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m
 
 	icp->icp_flags |= ICPF_RX_FLBUF;
 	icp->ip.ip_data_mbuf = m;
-	counter_u64_add(ci->fl_pdus, 1);
-	counter_u64_add(ci->fl_bytes, m->m_pkthdr.len);
+	toep->ofld_rxq->rx_iscsi_fl_pdus++;
+	toep->ofld_rxq->rx_iscsi_fl_octets += m->m_pkthdr.len;
 
 #if 0
 	CTR3(KTR_CXGBE, "%s: tid %u, cpl->len %u", __func__, tid,
@@ -326,7 +255,6 @@ static int
 do_rx_iscsi_ddp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 {
 	struct adapter *sc = iq->adapter;
-	struct cxgbei_data *ci = sc->iscsi_ulp_softc;
 	const struct cpl_rx_data_ddp *cpl = (const void *)(rss + 1);
 	u_int tid = GET_TID(cpl);
 	struct toepcb *toep = lookup_tid(sc, tid);
@@ -369,8 +297,8 @@ do_rx_iscsi_ddp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 		MPASS((icp->icp_flags & ICPF_RX_FLBUF) == 0);
 		MPASS(ip->ip_data_len > 0);
 		icp->icp_flags |= ICPF_RX_DDP;
-		counter_u64_add(ci->ddp_pdus, 1);
-		counter_u64_add(ci->ddp_bytes, ip->ip_data_len);
+		toep->ofld_rxq->rx_iscsi_ddp_pdus++;
+		toep->ofld_rxq->rx_iscsi_ddp_octets += ip->ip_data_len;
 	}
 
 	INP_WLOCK(inp);
@@ -527,7 +455,6 @@ cxgbei_deactivate(struct adapter *sc)
 	if (ci != NULL) {
 		sysctl_ctx_free(&ci->ctx);
 		t4_free_ppod_region(&ci->pr);
-		free_ci_counters(ci);
 		free(ci, M_CXGBE);
 		sc->iscsi_ulp_softc = NULL;
 	}
diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.h b/sys/dev/cxgbe/cxgbei/cxgbei.h
index b0369b974136..3b17a4f2b36a 100644
--- a/sys/dev/cxgbe/cxgbei/cxgbei.h
+++ b/sys/dev/cxgbe/cxgbei/cxgbei.h
@@ -113,12 +113,6 @@ struct cxgbei_data {
 	struct ppod_region pr;
 
 	struct sysctl_ctx_list ctx;	/* from uld_activate to deactivate */
-	counter_u64_t ddp_setup_ok;
-	counter_u64_t ddp_setup_error;
-	counter_u64_t ddp_bytes;
-	counter_u64_t ddp_pdus;
-	counter_u64_t fl_bytes;
-	counter_u64_t fl_pdus;
 };
 
 /* cxgbei.c */
diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
index 94963f13b601..961acfb31987 100644
--- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
+++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
@@ -819,7 +819,8 @@ no_ddp:
 		*ittp = htobe32(itt);
 		MPASS(*arg == NULL);	/* State is maintained for DDP only. */
 		if (rc != 0)
-			counter_u64_add(ci->ddp_setup_error, 1);
+			counter_u64_add(
+			    toep->ofld_rxq->rx_iscsi_ddp_setup_error, 1);
 		return (0);
 	}
 
@@ -853,7 +854,7 @@ no_ddp:
 
 	*ittp = htobe32(prsv->prsv_tag);
 	*arg = prsv;
-	counter_u64_add(ci->ddp_setup_ok, 1);
+	counter_u64_add(toep->ofld_rxq->rx_iscsi_ddp_setup_ok, 1);
 	return (0);
 }
 
@@ -922,7 +923,8 @@ no_ddp:
 			*tttp = htobe32(ttt);
 			MPASS(io_to_ppod_reservation(io) == NULL);
 			if (rc != 0)
-				counter_u64_add(ci->ddp_setup_error, 1);
+				counter_u64_add(
+				    toep->ofld_rxq->rx_iscsi_ddp_setup_error, 1);
 			return (0);
 		}
 
@@ -968,7 +970,7 @@ no_ddp:
 		*tttp = htobe32(prsv->prsv_tag);
 		io_to_ppod_reservation(io) = prsv;
 		*arg = ctsio;
-		counter_u64_add(ci->ddp_setup_ok, 1);
+		counter_u64_add(toep->ofld_rxq->rx_iscsi_ddp_setup_ok, 1);
 		return (0);
 	}
 
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index da9d7565f3a3..3cfab1ef04e2 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -11886,6 +11886,14 @@ clear_stats(struct adapter *sc, u_int port_id)
 				ofld_rxq->fl.cl_allocated = 0;
 				ofld_rxq->fl.cl_recycled = 0;
 				ofld_rxq->fl.cl_fast_recycled = 0;
+				counter_u64_zero(
+				    ofld_rxq->rx_iscsi_ddp_setup_ok);
+				counter_u64_zero(
+				    ofld_rxq->rx_iscsi_ddp_setup_error);
+				ofld_rxq->rx_iscsi_ddp_pdus = 0;
+				ofld_rxq->rx_iscsi_ddp_octets = 0;
+				ofld_rxq->rx_iscsi_fl_pdus = 0;
+				ofld_rxq->rx_iscsi_fl_octets = 0;
 				ofld_rxq->rx_toe_tls_records = 0;
 				ofld_rxq->rx_toe_tls_octets = 0;
 			}
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index 2f6c7e2e7914..ac79d8002784 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -4116,12 +4116,37 @@ add_ofld_rxq_sysctls(struct sysctl_ctx_list *ctx, struct sysctl_oid *oid,
 		return;
 
 	children = SYSCTL_CHILDREN(oid);
-	SYSCTL_ADD_ULONG(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+	SYSCTL_ADD_ULONG(ctx, children, OID_AUTO,
 	    "rx_toe_tls_records", CTLFLAG_RD, &ofld_rxq->rx_toe_tls_records,
 	    "# of TOE TLS records received");
-	SYSCTL_ADD_ULONG(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+	SYSCTL_ADD_ULONG(ctx, children, OID_AUTO,
 	    "rx_toe_tls_octets", CTLFLAG_RD, &ofld_rxq->rx_toe_tls_octets,
 	    "# of payload octets in received TOE TLS records");
+
+	oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "iscsi",
+	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "TOE iSCSI statistics");
+	children = SYSCTL_CHILDREN(oid);
+
+	ofld_rxq->rx_iscsi_ddp_setup_ok = counter_u64_alloc(M_WAITOK);
+	ofld_rxq->rx_iscsi_ddp_setup_error = counter_u64_alloc(M_WAITOK);
+	SYSCTL_ADD_COUNTER_U64(ctx, children, OID_AUTO, "ddp_setup_ok",
+	    CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_setup_ok,
+	    "# of times DDP buffer was setup successfully.");
+	SYSCTL_ADD_COUNTER_U64(ctx, children, OID_AUTO, "ddp_setup_error",
+	    CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_setup_error,
+	    "# of times DDP buffer setup failed.");
+	SYSCTL_ADD_U64(ctx, children, OID_AUTO, "ddp_octets",
+	    CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_octets, 0,
+	    "# of octets placed directly");
+	SYSCTL_ADD_U64(ctx, children, OID_AUTO, "ddp_pdus",
+	    CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_pdus, 0,
+	    "# of PDUs with data placed directly.");
+	SYSCTL_ADD_U64(ctx, children, OID_AUTO, "fl_octets",
+	    CTLFLAG_RD, &ofld_rxq->rx_iscsi_fl_octets, 0,
+	    "# of data octets delivered in freelist");
+	SYSCTL_ADD_U64(ctx, children, OID_AUTO, "fl_pdus",
+	    CTLFLAG_RD, &ofld_rxq->rx_iscsi_fl_pdus, 0,
+	    "# of PDUs with data delivered in freelist");
 }
 #endif
 


More information about the dev-commits-src-all mailing list