Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2023 21:56:32 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 12e299e2ab7d - stable/13 - ccr: Retire ccr_softc member in struct adapter.
Message-ID:  <202309062156.386LuW2i022422@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=12e299e2ab7ded962fbd4b083432f84efa3d3a60

commit 12e299e2ab7ded962fbd4b083432f84efa3d3a60
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-12-29 19:39:28 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-09-06 21:56:09 +0000

    ccr: Retire ccr_softc member in struct adapter.
    
    Prior to Conrad's changes to replace session integer IDs with a
    pointer to the driver-specific state in commit 1b0909d51a8aa, the
    driver had to find the softc pointer from the adapter before it could
    locate the ccr_session structure for a completed request.  Since
    Conrad's changes, the ccr_session pointer can now be obtained directly
    from the crp.  Add a backpoint from ccr_session back to ccr_softc and
    use this in place of the ccr_softc member in cxgbe's struct adapter.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 7063b9974f8a39d860b7abd03884324e71994f65)
---
 sys/dev/cxgbe/adapter.h          |  1 -
 sys/dev/cxgbe/crypto/t4_crypto.c | 81 ++++++++++++++++++++--------------------
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index ee6e23d1e43e..58ea1eb3f29a 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -942,7 +942,6 @@ struct adapter {
 	void *iwarp_softc;	/* (struct c4iw_dev *) */
 	struct iw_tunables iwt;
 	void *iscsi_ulp_softc;	/* (struct cxgbei_data *) */
-	void *ccr_softc;	/* (struct ccr_softc *) */
 	struct l2t_data *l2t;	/* L2 table */
 	struct smt_data *smt;	/* Source MAC Table */
 	struct tid_info tids;
diff --git a/sys/dev/cxgbe/crypto/t4_crypto.c b/sys/dev/cxgbe/crypto/t4_crypto.c
index 98930da6c1f4..7301174614d2 100644
--- a/sys/dev/cxgbe/crypto/t4_crypto.c
+++ b/sys/dev/cxgbe/crypto/t4_crypto.c
@@ -175,43 +175,6 @@ struct ccr_port {
 	counter_u64_t stats_completed;
 };
 
-struct ccr_session {
-#ifdef INVARIANTS
-	int pending;
-#endif
-	enum { HASH, HMAC, CIPHER, ETA, GCM, CCM } mode;
-	struct ccr_port *port;
-	union {
-		struct ccr_session_hmac hmac;
-		struct ccr_session_gmac gmac;
-		struct ccr_session_ccm_mac ccm_mac;
-	};
-	struct ccr_session_cipher cipher;
-	struct mtx lock;
-
-	/*
-	 * A fallback software session is used for certain GCM/CCM
-	 * requests that the hardware can't handle such as requests
-	 * with only AAD and no payload.
-	 */
-	crypto_session_t sw_session;
-
-	/*
-	 * Pre-allocate S/G lists used when preparing a work request.
-	 * 'sg_input' contains an sglist describing the entire input
-	 * buffer for a 'struct cryptop'.  'sg_output' contains an
-	 * sglist describing the entire output buffer.  'sg_ulptx' is
-	 * used to describe the data the engine should DMA as input
-	 * via ULPTX_SGL.  'sg_dsgl' is used to describe the
-	 * destination that cipher text and a tag should be written
-	 * to.
-	 */
-	struct sglist *sg_input;
-	struct sglist *sg_output;
-	struct sglist *sg_ulptx;
-	struct sglist *sg_dsgl;
-};
-
 struct ccr_softc {
 	struct adapter *adapter;
 	device_t dev;
@@ -251,6 +214,44 @@ struct ccr_softc {
 	struct sysctl_ctx_list ctx;
 };
 
+struct ccr_session {
+#ifdef INVARIANTS
+	int pending;
+#endif
+	enum { HASH, HMAC, CIPHER, ETA, GCM, CCM } mode;
+	struct ccr_softc *sc;
+	struct ccr_port *port;
+	union {
+		struct ccr_session_hmac hmac;
+		struct ccr_session_gmac gmac;
+		struct ccr_session_ccm_mac ccm_mac;
+	};
+	struct ccr_session_cipher cipher;
+	struct mtx lock;
+
+	/*
+	 * A fallback software session is used for certain GCM/CCM
+	 * requests that the hardware can't handle such as requests
+	 * with only AAD and no payload.
+	 */
+	crypto_session_t sw_session;
+
+	/*
+	 * Pre-allocate S/G lists used when preparing a work request.
+	 * 'sg_input' contains an sglist describing the entire input
+	 * buffer for a 'struct cryptop'.  'sg_output' contains an
+	 * sglist describing the entire output buffer.  'sg_ulptx' is
+	 * used to describe the data the engine should DMA as input
+	 * via ULPTX_SGL.  'sg_dsgl' is used to describe the
+	 * destination that cipher text and a tag should be written
+	 * to.
+	 */
+	struct sglist *sg_input;
+	struct sglist *sg_output;
+	struct sglist *sg_ulptx;
+	struct sglist *sg_dsgl;
+};
+
 /*
  * Crypto requests involve two kind of scatter/gather lists.
  *
@@ -1956,7 +1957,6 @@ ccr_attach(device_t dev)
 		return (ENXIO);
 	}
 	sc->cid = cid;
-	sc->adapter->ccr_softc = sc;
 
 	/*
 	 * The FID must be the first RXQ for port 0 regardless of
@@ -2035,7 +2035,6 @@ ccr_detach(device_t dev)
 	}
 	sglist_free(sc->sg_iv_aad);
 	free(sc->iv_aad_buf, M_CCR);
-	sc->adapter->ccr_softc = NULL;
 	return (0);
 }
 
@@ -2417,6 +2416,7 @@ ccr_newsession(device_t dev, crypto_session_t cses,
 	}
 
 	sc = device_get_softc(dev);
+	s->sc = sc;
 
 	mtx_lock(&sc->lock);
 	if (sc->detaching) {
@@ -2644,7 +2644,7 @@ static int
 do_cpl6_fw_pld(struct sge_iq *iq, const struct rss_header *rss,
     struct mbuf *m)
 {
-	struct ccr_softc *sc = iq->adapter->ccr_softc;
+	struct ccr_softc *sc;
 	struct ccr_session *s;
 	const struct cpl_fw6_pld *cpl;
 	struct cryptop *crp;
@@ -2664,6 +2664,7 @@ do_cpl6_fw_pld(struct sge_iq *iq, const struct rss_header *rss,
 	else
 		error = 0;
 
+	sc = s->sc;
 #ifdef INVARIANTS
 	mtx_lock(&s->lock);
 	s->pending--;



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