From nobody Fri Oct 3 00:04:13 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cd8654SqKz6BMvL; Fri, 03 Oct 2025 00:04:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cd8652Hdgz3rx6; Fri, 03 Oct 2025 00:04:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759449853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=t+c74AuRtz1/FxaS/S9a9Wcg0BLdA6o67b9xfG6xfC4=; b=rjRj8D13oyyg/0Bh89KusSUWCjKPsTkXqMdTf/+v1RVxG9uuEDkjp9Nm7GrVa6zJuF3UI9 6kp3REvM2Jdp+5eLMT+jIrf/A8ZAbe6NDY7mdNtSLEvKWCIz9M2lZAKD5VwoTqXC+zvw9i shdqzkvwUblbap7eNG40uBNOaXaIjMzs5fyEzml/Ut2MCUtq4uLvnNj1z/5HSJIGVs1wIz pozaLGEMJDOxkAJlxhvbBggM7ZKGazI0IWvPq8QFiPJTeey0UlEKTSBOqJTg7vsQGQztjz TiXFwzCtWmBhj9ZZPf40NhUp5YjBuOdDZZWqYeK6rp+p53yH4DMWBFltbtTH3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759449853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=t+c74AuRtz1/FxaS/S9a9Wcg0BLdA6o67b9xfG6xfC4=; b=IgMAS45KNUg4eSfNtUM0JfAawwUd3HHMmTHaOggR1obgkqBnT7C1AUs5aBUXVmSYBfCoR+ 2lx0lVh3aePCXVIJ5eHNDb86Jp3BP09tTQO1LeLiVNQiJDLPXrGsMyoEVhBv2SeMB4EPKr a7XAIvg6bGEQpgDMTAxHYvQH3k5qGkclbwTV28lGDttY6FQZ8643T7h98WvNkfH5O5vacE KlR1GNxViFHGOyTXtv89hZdH3B3RqujXxvpOh9vawyOrysh419T1o7kXIVdjAVY8g3ybtV dPK7CEIVFVS1OIfWRJs++49lQVmzIBjWO+BaLSQU2y/nBWYPvSGjfaOC8ZTIPQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759449853; a=rsa-sha256; cv=none; b=nnAfAXByNUNIVnkFYZP7v4+kWE5Hm/aGmVnOf6PM7VD/UmzBTKvwATbeACTCi//+ZGg3RN 1Gcv4Xjj6JyDORWm+CprnR370saEv+PUln9/wBdKzVgLCPKMHyPvEQcPEuvyw8LL72iXA4 WJumaS/cvnyTOP/D42Jd6zla2sM4nGD48jntXJScVnVk1aJyXJ4t68Uiwoa2r6RK+Rp3dR 2/g3t2vVngGLNEmWayX/1nvXpOJPLlLXC85WylhL6UnbKu+vFNjbKjFIDxxmuU7jHm/ISH OwkBI+tt6eajC+yxwjpbQYKLW7j0PLz5Dq1SrmGRWiV0cY/UIefvw0MYvGOk3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cd8651swkzTvS; Fri, 03 Oct 2025 00:04:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59304Dft056490; Fri, 3 Oct 2025 00:04:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59304DTF056487; Fri, 3 Oct 2025 00:04:13 GMT (envelope-from git) Date: Fri, 3 Oct 2025 00:04:13 GMT Message-Id: <202510030004.59304DTF056487@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: e27bb92b6fa6 - stable/15 - cxgbe tom: Halve the size of offload transmit software descriptors List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: e27bb92b6fa69198c615fce52910417164dda986 Auto-Submitted: auto-generated The branch stable/15 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=e27bb92b6fa69198c615fce52910417164dda986 commit e27bb92b6fa69198c615fce52910417164dda986 Author: John Baldwin AuthorDate: 2025-09-11 21:10:39 +0000 Commit: Navdeep Parhar CommitDate: 2025-10-02 22:09:03 +0000 cxgbe tom: Halve the size of offload transmit software descriptors Use bitfields to pack tx_credits and plen into a single 32-bit word. Reviewed by: np Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D47759 (cherry picked from commit 5a38857684907c52982787dbac2c5e5c8abfd4f8) --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 2 ++ sys/dev/cxgbe/iw_cxgbe/qp.c | 2 ++ sys/dev/cxgbe/tom/t4_cpl_io.c | 16 ++++++++++++++++ sys/dev/cxgbe/tom/t4_tls.c | 4 ++++ sys/dev/cxgbe/tom/t4_tom.c | 2 ++ sys/dev/cxgbe/tom/t4_tom.h | 7 +++++-- 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index c8592807f843..d805642541d3 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -1053,6 +1053,8 @@ send_iscsi_flowc_wr(struct adapter *sc, struct toepcb *toep, int maxlen) flowc->mnemval[0].mnemonic = FW_FLOWC_MNEM_TXDATAPLEN_MAX; flowc->mnemval[0].val = htobe32(maxlen); + KASSERT(howmany(flowclen, 16) <= MAX_OFLD_TX_SDESC_CREDITS, + ("%s: tx_credits %u too large", __func__, howmany(flowclen, 16))); txsd->tx_credits = howmany(flowclen, 16); txsd->plen = 0; KASSERT(toep->tx_credits >= txsd->tx_credits && toep->txsd_avail > 0, diff --git a/sys/dev/cxgbe/iw_cxgbe/qp.c b/sys/dev/cxgbe/iw_cxgbe/qp.c index 0e374bc961c4..cbf4bae00a60 100644 --- a/sys/dev/cxgbe/iw_cxgbe/qp.c +++ b/sys/dev/cxgbe/iw_cxgbe/qp.c @@ -1326,6 +1326,8 @@ creds(struct toepcb *toep, struct inpcb *inp, size_t wrsize) return (EINVAL); } txsd = &toep->txsd[toep->txsd_pidx]; + KASSERT(howmany(wrsize, 16) <= MAX_OFLD_TX_SDESC_CREDITS, + ("%s: tx_credits %zu too large", __func__, howmany(wrsize, 16))); txsd->tx_credits = howmany(wrsize, 16); txsd->plen = 0; KASSERT(toep->tx_credits >= txsd->tx_credits && toep->txsd_avail > 0, diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index 7a6b1cbdd736..9ecb4aeee939 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -148,6 +148,8 @@ send_flowc_wr(struct toepcb *toep, struct tcpcb *tp) KASSERT(paramidx == nparams, ("nparams mismatch")); + KASSERT(howmany(flowclen, 16) <= MAX_OFLD_TX_SDESC_CREDITS, + ("%s: tx_credits %u too large", __func__, howmany(flowclen, 16))); txsd->tx_credits = howmany(flowclen, 16); txsd->plen = 0; KASSERT(toep->tx_credits >= txsd->tx_credits && toep->txsd_avail > 0, @@ -215,6 +217,8 @@ update_tx_rate_limit(struct adapter *sc, struct toepcb *toep, u_int Bps) else flowc->mnemval[0].val = htobe32(tc_idx); + KASSERT(flowclen16 <= MAX_OFLD_TX_SDESC_CREDITS, + ("%s: tx_credits %u too large", __func__, flowclen16)); txsd->tx_credits = flowclen16; txsd->plen = 0; toep->tx_credits -= txsd->tx_credits; @@ -491,6 +495,9 @@ t4_close_conn(struct adapter *sc, struct toepcb *toep) #define MIN_TX_CREDITS(iso) \ (MIN_OFLD_TX_CREDITS + ((iso) ? MIN_ISO_TX_CREDITS : 0)) +_Static_assert(MAX_OFLD_TX_CREDITS <= MAX_OFLD_TX_SDESC_CREDITS, + "MAX_OFLD_TX_SDESC_CREDITS too small"); + /* Maximum amount of immediate data we could stuff in a WR */ static inline int max_imm_payload(int tx_credits, int iso) @@ -705,6 +712,8 @@ t4_push_frames(struct adapter *sc, struct toepcb *toep, int drop) if ((m->m_flags & M_NOTREADY) != 0) break; + if (plen + m->m_len > MAX_OFLD_TX_SDESC_PLEN) + break; if (m->m_flags & M_EXTPG) { #ifdef KERN_TLS if (m->m_epg_tls != NULL) { @@ -870,6 +879,8 @@ t4_push_frames(struct adapter *sc, struct toepcb *toep, int drop) toep->flags |= TPF_TX_SUSPENDED; KASSERT(toep->txsd_avail > 0, ("%s: no txsd", __func__)); + KASSERT(plen <= MAX_OFLD_TX_SDESC_PLEN, + ("%s: plen %u too large", __func__, plen)); txsd->plen = plen; txsd->tx_credits = credits; txsd++; @@ -1211,6 +1222,8 @@ t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) toep->flags |= TPF_TX_SUSPENDED; KASSERT(toep->txsd_avail > 0, ("%s: no txsd", __func__)); + KASSERT(plen <= MAX_OFLD_TX_SDESC_PLEN, + ("%s: plen %u too large", __func__, plen)); txsd->plen = plen; txsd->tx_credits = credits; txsd++; @@ -1969,6 +1982,9 @@ t4_set_tcb_field(struct adapter *sc, struct sge_wrq *wrq, struct toepcb *toep, req->val = htobe64(val); if (wrq->eq.type == EQ_OFLD) { txsd = &toep->txsd[toep->txsd_pidx]; + _Static_assert(howmany(sizeof(*req), 16) <= + MAX_OFLD_TX_SDESC_CREDITS, + "MAX_OFLD_TX_SDESC_CREDITS too small"); txsd->tx_credits = howmany(sizeof(*req), 16); txsd->plen = 0; KASSERT(toep->tx_credits >= txsd->tx_credits && diff --git a/sys/dev/cxgbe/tom/t4_tls.c b/sys/dev/cxgbe/tom/t4_tls.c index 27c16b9988ae..857832aafa5c 100644 --- a/sys/dev/cxgbe/tom/t4_tls.c +++ b/sys/dev/cxgbe/tom/t4_tls.c @@ -191,6 +191,8 @@ tls_program_key_id(struct toepcb *toep, struct ktls_session *tls, t4_tls_key_ctx(tls, direction, kctx); txsd = &toep->txsd[toep->txsd_pidx]; + _Static_assert(DIV_ROUND_UP(TLS_KEY_WR_SZ, 16) <= + MAX_OFLD_TX_SDESC_CREDITS, "MAX_OFLD_TX_SDESC_CREDITS too small"); txsd->tx_credits = DIV_ROUND_UP(TLS_KEY_WR_SZ, 16); txsd->plen = 0; toep->tx_credits -= txsd->tx_credits; @@ -694,6 +696,8 @@ t4_push_ktls(struct adapter *sc, struct toepcb *toep, int drop) toep->flags |= TPF_TX_SUSPENDED; KASSERT(toep->txsd_avail > 0, ("%s: no txsd", __func__)); + KASSERT(m->m_len <= MAX_OFLD_TX_SDESC_PLEN, + ("%s: plen %u too large", __func__, m->m_len)); txsd->plen = m->m_len; txsd->tx_credits = credits; txsd++; diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c index 9b09facd05a7..0b54fdaa5c80 100644 --- a/sys/dev/cxgbe/tom/t4_tom.c +++ b/sys/dev/cxgbe/tom/t4_tom.c @@ -882,6 +882,8 @@ send_mss_flowc_wr(struct adapter *sc, struct toepcb *toep) flowc->mnemval[0].val = htobe32(toep->params.emss); txsd = &toep->txsd[toep->txsd_pidx]; + _Static_assert(flowclen16 <= MAX_OFLD_TX_SDESC_CREDITS, + "MAX_OFLD_TX_SDESC_CREDITS too small"); txsd->tx_credits = flowclen16; txsd->plen = 0; toep->tx_credits -= txsd->tx_credits; diff --git a/sys/dev/cxgbe/tom/t4_tom.h b/sys/dev/cxgbe/tom/t4_tom.h index 6295a3484b9f..3b2243aeb69f 100644 --- a/sys/dev/cxgbe/tom/t4_tom.h +++ b/sys/dev/cxgbe/tom/t4_tom.h @@ -122,10 +122,13 @@ struct conn_params { }; struct ofld_tx_sdesc { - uint32_t plen; /* payload length */ - uint8_t tx_credits; /* firmware tx credits (unit is 16B) */ + uint32_t plen : 26; /* payload length */ + uint32_t tx_credits : 6; /* firmware tx credits (unit is 16B) */ }; +#define MAX_OFLD_TX_SDESC_PLEN ((1u << 26) - 1) +#define MAX_OFLD_TX_SDESC_CREDITS ((1u << 6) - 1) + struct ppod_region { u_int pr_start; u_int pr_len;