From nobody Fri Jul 19 16:18:22 2024 X-Original-To: dev-commits-src-main@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 4WQZbf5CWWz5RvGC; Fri, 19 Jul 2024 16:18:22 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WQZbf2xz5z53wW; Fri, 19 Jul 2024 16:18:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721405902; 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=wIJjVE7vhFn8ZddRWF9oqqtaIKqJ1b2Nb66xYd8HiF8=; b=wDu79q0s8iNgu3WqqYciULa7r2WTfCrmkuE2XBmvdfVTU6kqRVjTnqYBfgbxVpQsxxXDL5 QOuMk6MsmMeDHQABMfynCS9oWzMMsPDr1BFU1ofuB7okjm5hg9wQ+zchQcDMuQwuVBTRAF MeIgMXeD4nnTlGlscwn3j7dukg8AN7ifOP0yjAP+olHaMyKxGFQEiOSt1PO2RUgwvpDZTs wYxOHcECP3n+4016mmugB0/cOJxj8Uvw8sm+ygZfKnOX+ohzWhvrWw84lkvuSp7VCIFvFH xmeASiyxehr9dE3pWtu3KIlhL59X9uJniYKQCzRmr35EI7g0KL+M+Lel/DmUhA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721405902; a=rsa-sha256; cv=none; b=VqndSYLccOFAYojDn35i/ssafb1Gk9j1WpPSLzVztZmqPR4ccZINMuBY81ohiH0rKrOQA0 YKh0q+3CJU24OOyaz1TkfPg4mOdNdmbyUQqG4u10TrRgOOsT3c04gDo4W5mmqOVyu0Kskp 8M1DwJYHW285UlWhtihkoQ3Y5FE4ucp8KO4xuhsKwgCCEJnF6zWCFsWsPpHFaeiJSAe4Rj YsIe9S7Sdpnd8cKjFuzMcETo5C5RimEY/zwEDRQNERUqbLdZj1N5fcoUQmQ5S8Iw4Ylf0U UTO9f59iBZQKqo4kQ3gO0i/93Rp/mrfyMtCXslaZ90EnDZHjF1RRE3enhe0jjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721405902; 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=wIJjVE7vhFn8ZddRWF9oqqtaIKqJ1b2Nb66xYd8HiF8=; b=tnQvXQdGx7cnRTkQc42mDr2MEfCR1kZZY3Fo0utnfbLYBwIOgIy/cz5BIsRPhTqSPI3q8/ K9C/iDTfEHRBl9hUfCRwndit0eqOcEZ0/jgtTILMjvL6epOSFnMDxW1ypBbZk2GKaxExZA Opqv6c/oWVIRe+UogwlPM0JhIgf4sEQG0tAj8GLlhtnX+v5uz/shCPFUvqaFvO8oKpbaSf RvO999RK6q0bfIgEYhsRiJr3mZ9s11wiQcNex65w53Xlsi6SgtbJmKJBY5GMqPgd+fgRdd aMmxw0fZ23d73dltWbeDPvWkpshJjPCHFQwbNTbXckILfatNh/VBz4ylzaKC6Q== 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 4WQZbf2Wwqzfw5; Fri, 19 Jul 2024 16:18:22 +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 46JGIMnn043526; Fri, 19 Jul 2024 16:18:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46JGIMP2043523; Fri, 19 Jul 2024 16:18:22 GMT (envelope-from git) Date: Fri, 19 Jul 2024 16:18:22 GMT Message-Id: <202407191618.46JGIMP2043523@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Navdeep Parhar Subject: git: cfcfd3c7bf5b - main - cxgbe(4): Make no assumptions about the start and size of the L2T table. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: cfcfd3c7bf5b60da42b13ac5d8085c762613c302 Auto-Submitted: auto-generated The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=cfcfd3c7bf5b60da42b13ac5d8085c762613c302 commit cfcfd3c7bf5b60da42b13ac5d8085c762613c302 Author: Navdeep Parhar AuthorDate: 2024-07-18 20:16:30 +0000 Commit: Navdeep Parhar CommitDate: 2024-07-19 16:12:46 +0000 cxgbe(4): Make no assumptions about the start and size of the L2T table. Do not assume that the table starts at index 0 and is typically 4K in size. The only thing the driver needs to verify is that its use of F_SYNC_WR doesn't collide with the L2T hwidx range. Reviewed by: jhb MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D46028 --- sys/dev/cxgbe/t4_l2t.c | 17 +++++++++++------ sys/dev/cxgbe/t4_l2t.h | 2 -- sys/dev/cxgbe/t4_main.c | 6 +++--- sys/dev/cxgbe/tom/t4_tom_l2t.c | 21 +++++++++++++-------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/sys/dev/cxgbe/t4_l2t.c b/sys/dev/cxgbe/t4_l2t.c index 005dce826ccb..90f184f5e666 100644 --- a/sys/dev/cxgbe/t4_l2t.c +++ b/sys/dev/cxgbe/t4_l2t.c @@ -369,14 +369,19 @@ int do_l2t_write_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) { + struct adapter *sc = iq->adapter; const struct cpl_l2t_write_rpl *rpl = (const void *)(rss + 1); - unsigned int tid = GET_TID(rpl); - unsigned int idx = tid % L2T_SIZE; + const u_int hwidx = GET_TID(rpl) & ~(F_SYNC_WR | V_TID_QID(M_TID_QID)); + const bool sync = GET_TID(rpl) & F_SYNC_WR; - if (__predict_false(rpl->status != CPL_ERR_NONE)) { - log(LOG_ERR, - "Unexpected L2T_WRITE_RPL (%u) for entry at hw_idx %u\n", - rpl->status, idx); + MPASS(iq->abs_id == G_TID_QID(GET_TID(rpl))); + + if (__predict_false(hwidx < sc->vres.l2t.start) || + __predict_false(hwidx >= sc->vres.l2t.start + sc->vres.l2t.size) || + __predict_false(rpl->status != CPL_ERR_NONE)) { + CH_ERR(sc, "%s: hwidx %u, rpl %u, sync %u; L2T st %u, sz %u\n", + __func__, hwidx, rpl->status, sync, sc->vres.l2t.start, + sc->vres.l2t.size); return (EINVAL); } diff --git a/sys/dev/cxgbe/t4_l2t.h b/sys/dev/cxgbe/t4_l2t.h index 36a41e459a5d..991b4476eb61 100644 --- a/sys/dev/cxgbe/t4_l2t.h +++ b/sys/dev/cxgbe/t4_l2t.h @@ -35,8 +35,6 @@ #define V_SYNC_WR(x) ((x) << S_SYNC_WR) #define F_SYNC_WR V_SYNC_WR(1) -enum { L2T_SIZE = 4096 }; /* # of L2T entries */ - enum { L2T_STATE_VALID, /* entry is up to date */ L2T_STATE_STALE, /* entry may be used but needs revalidation */ diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 99400dc9aadb..11dd9e1d24a3 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -5262,9 +5262,9 @@ get_params__post_init(struct adapter *sc) } sc->vres.l2t.start = val[4]; sc->vres.l2t.size = val[5] - val[4] + 1; - KASSERT(sc->vres.l2t.size <= L2T_SIZE, - ("%s: L2 table size (%u) larger than expected (%u)", - __func__, sc->vres.l2t.size, L2T_SIZE)); + /* val[5] is the last hwidx and it must not collide with F_SYNC_WR */ + if (sc->vres.l2t.size > 0) + MPASS(fls(val[5]) <= S_SYNC_WR); sc->params.core_vdd = val[6]; param[0] = FW_PARAM_PFVF(IQFLINT_END); diff --git a/sys/dev/cxgbe/tom/t4_tom_l2t.c b/sys/dev/cxgbe/tom/t4_tom_l2t.c index c397196d9cca..ee442f023970 100644 --- a/sys/dev/cxgbe/tom/t4_tom_l2t.c +++ b/sys/dev/cxgbe/tom/t4_tom_l2t.c @@ -318,18 +318,23 @@ do_l2t_write_rpl2(struct sge_iq *iq, const struct rss_header *rss, { struct adapter *sc = iq->adapter; const struct cpl_l2t_write_rpl *rpl = (const void *)(rss + 1); - unsigned int tid = GET_TID(rpl); - unsigned int idx = tid % L2T_SIZE; + const u_int hwidx = GET_TID(rpl) & ~(F_SYNC_WR | V_TID_QID(M_TID_QID)); + const bool sync = GET_TID(rpl) & F_SYNC_WR; - if (__predict_false(rpl->status != CPL_ERR_NONE)) { - log(LOG_ERR, - "Unexpected L2T_WRITE_RPL (%u) for entry at hw_idx %u\n", - rpl->status, idx); + MPASS(iq->abs_id == G_TID_QID(GET_TID(rpl))); + + if (__predict_false(hwidx < sc->vres.l2t.start) || + __predict_false(hwidx >= sc->vres.l2t.start + sc->vres.l2t.size) || + __predict_false(rpl->status != CPL_ERR_NONE)) { + CH_ERR(sc, "%s: hwidx %u, rpl %u, sync %u; L2T st %u, sz %u\n", + __func__, hwidx, rpl->status, sync, sc->vres.l2t.start, + sc->vres.l2t.size); return (EINVAL); } - if (tid & F_SYNC_WR) { - struct l2t_entry *e = &sc->l2t->l2tab[idx - sc->vres.l2t.start]; + if (sync) { + const u_int idx = hwidx - sc->vres.l2t.start; + struct l2t_entry *e = &sc->l2t->l2tab[idx]; mtx_lock(&e->lock); if (e->state != L2T_STATE_SWITCHING) {