From nobody Mon Oct 21 18:39:11 2024 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 4XXPGl4Tkvz5Zcdd; Mon, 21 Oct 2024 18:39:11 +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 4XXPGl3QWSz4G0R; Mon, 21 Oct 2024 18:39:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729535951; 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=ULQGTgAAf3kdMcN8bnQC0xJ3MIT06YkAy/Wc2kBBh2o=; b=p9O1gwv5lZ2ejBFJVxcYeWk002AVZViWnrj2a0S71QedeLLUStGpSHzYAus/s94gAUUbTS MUQNoyemC1iS2dm87rdT7slQJdWlmhjHjkdmmiwoEwp24lSROYbewG2guP+TR2o5qL0fmw KEfib2p/px1fS7xCvJGj9ve8Zb7EBlIdjj9HUwmrhAx78xo9rmf5K5a6i7idwqqtWpWB5k EWuOnPDFtXylJHjrlU4Da4+jDlbE5j3DLtXlmm/vkT7SExUnvsXgPnInINFnDVzP/tXofG ea/k6q/1Ngawoz1spcvsbwe/bwrRVCCGNSHty+DnerFmZ8s+SHYpkv7hoSgetQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729535951; 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=ULQGTgAAf3kdMcN8bnQC0xJ3MIT06YkAy/Wc2kBBh2o=; b=ELPJHYnv2Fp4yZN7I7fCjny/0Giv323gxkXgxvzRGpp8UoWD69nF0O/6FAI0Xq0L0O2YWZ nLXtjTxwIjUNHNIfpJXrCouHEOMoJWG02nT9aNk10HViBwCjReD5t4WyYrleGFIYhkBiPb lNKTRBF5estSp1dsTYWOWel8fSyjwGPfRIGwB1W8dUvieuP5nq6uNadMFVUJX/cyTcM/cO meGjvAWqD0PW8MnCnBALyGyBT+xGknBkVV8DZT3F1hdLRlPb1j1WHDi6FWmnjyS/bmaZ2l cvouQkTerbsG8oE16LcgvqlKwmzCsusPp8ajmiHgW6WudwSOhHLuqFbXbo7xBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729535951; a=rsa-sha256; cv=none; b=RU7ktkbT5BQXkeWrtmx0G8Z6OJY/JNUfojlUp1syH9Ws3MZhac1pswF/bd1LD9CIvybdvs R9b7t4vg6woVhbB8qH7SzjtNEKN/dwVdZVAO4uy0/QJZzUvx5MT7BMOu1tMokWnZHFKpwE VgcjE1DlM30yn70udQNdSf483GcfGb7jP3UiId9LMp6CV8ev6XXjMavMcnzI72++DQNgRB Du1OEDle/WoOxTZ14F2jZA7eeYNwkFqggmt7Gt1HpuUD3AzbVZ7iZNbBCjw5McIyyIAurs StDcBCmW3ttwmYfhl/C+wVS03g7DstXu5pqR0yuSftUlQqgTthPmsmHT32lyNw== 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 4XXPGl2zXvzhSP; Mon, 21 Oct 2024 18:39:11 +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 49LIdBeG036186; Mon, 21 Oct 2024 18:39:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49LIdBb7036183; Mon, 21 Oct 2024 18:39:11 GMT (envelope-from git) Date: Mon, 21 Oct 2024 18:39:11 GMT Message-Id: <202410211839.49LIdBb7036183@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: da45eba6d1de - stable/14 - cxgbe(4): Stop and restart the L2T allocator with the LLD. 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/14 X-Git-Reftype: branch X-Git-Commit: da45eba6d1de7fd334f1928258117d6b5b61f856 Auto-Submitted: auto-generated The branch stable/14 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=da45eba6d1de7fd334f1928258117d6b5b61f856 commit da45eba6d1de7fd334f1928258117d6b5b61f856 Author: Navdeep Parhar AuthorDate: 2024-07-19 16:40:44 +0000 Commit: Navdeep Parhar CommitDate: 2024-10-21 17:02:17 +0000 cxgbe(4): Stop and restart the L2T allocator with the LLD. L2T entries are used by both filters and TOE and the L2T is shared between the base driver (LLD) and the TOM ULD. Add a flag to indicate that the L2T is stopped, which means: * t4_alloc_l2e and t4_l2t_alloc_switching will not allocate new entries. * t4_tom will ignore all ARP/NDP updates from the kernel. * Previously allocated L2T entries can still be freed. Sponsored by: Chelsio Communications (cherry picked from commit cd93fdee5c8bbdb00d10f8a1fa43f30f151a1ef7) --- sys/dev/cxgbe/t4_l2t.c | 36 +++++++++++++++++++++++++++++++++--- sys/dev/cxgbe/t4_l2t.h | 5 ++++- sys/dev/cxgbe/t4_main.c | 4 +++- sys/dev/cxgbe/tom/t4_tom_l2t.c | 7 +++++++ 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/sys/dev/cxgbe/t4_l2t.c b/sys/dev/cxgbe/t4_l2t.c index 90f184f5e666..b210003cfac0 100644 --- a/sys/dev/cxgbe/t4_l2t.c +++ b/sys/dev/cxgbe/t4_l2t.c @@ -73,7 +73,8 @@ t4_alloc_l2e(struct l2t_data *d) struct l2t_entry *end, *e, **p; rw_assert(&d->lock, RA_WLOCKED); - + if (__predict_false(d->l2t_stopped)) + return (NULL); if (!atomic_load_acq_int(&d->nfree)) return (NULL); @@ -291,7 +292,10 @@ t4_l2t_alloc_switching(struct adapter *sc, uint16_t vlan, uint8_t port, int rc; rw_wlock(&d->lock); - e = find_or_alloc_l2e(d, vlan, port, eth_addr); + if (__predict_false(d->l2t_stopped)) + e = NULL; + else + e = find_or_alloc_l2e(d, vlan, port, eth_addr); if (e) { if (atomic_load_acq_int(&e->refcnt) == 0) { mtx_lock(&e->lock); /* avoid race with t4_l2t_free */ @@ -333,6 +337,7 @@ t4_init_l2t(struct adapter *sc, int flags) return (ENOMEM); d->l2t_size = l2t_size; + d->l2t_stopped = false; d->rover = d->l2tab; atomic_store_rel_int(&d->nfree, l2t_size); rw_init(&d->lock, "L2T"); @@ -353,8 +358,9 @@ t4_init_l2t(struct adapter *sc, int flags) } int -t4_free_l2t(struct l2t_data *d) +t4_free_l2t(struct adapter *sc) { + struct l2t_data *d = sc->l2t; int i; for (i = 0; i < d->l2t_size; i++) @@ -365,6 +371,30 @@ t4_free_l2t(struct l2t_data *d) return (0); } +int +t4_stop_l2t(struct adapter *sc) +{ + struct l2t_data *d = sc->l2t; + + rw_wlock(&d->lock); + d->l2t_stopped = true; + rw_wunlock(&d->lock); + + return (0); +} + +int +t4_restart_l2t(struct adapter *sc) +{ + struct l2t_data *d = sc->l2t; + + rw_wlock(&d->lock); + d->l2t_stopped = false; + rw_wunlock(&d->lock); + + return (0); +} + int do_l2t_write_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) diff --git a/sys/dev/cxgbe/t4_l2t.h b/sys/dev/cxgbe/t4_l2t.h index 991b4476eb61..f8681a4ab556 100644 --- a/sys/dev/cxgbe/t4_l2t.h +++ b/sys/dev/cxgbe/t4_l2t.h @@ -79,6 +79,7 @@ struct l2t_entry { struct l2t_data { struct rwlock lock; u_int l2t_size; + bool l2t_stopped; volatile int nfree; /* number of free entries */ struct l2t_entry *rover;/* starting point for next allocation */ struct l2t_entry l2tab[]; @@ -86,7 +87,9 @@ struct l2t_data { int t4_init_l2t(struct adapter *, int); -int t4_free_l2t(struct l2t_data *); +int t4_free_l2t(struct adapter *); +int t4_stop_l2t(struct adapter *); +int t4_restart_l2t(struct adapter *); struct l2t_entry *t4_alloc_l2e(struct l2t_data *); struct l2t_entry *t4_l2t_alloc_switching(struct adapter *, uint16_t, uint8_t, uint8_t *); diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index f1f1cccb93c2..c02fe8372946 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -1847,7 +1847,7 @@ t4_detach_common(device_t dev) sc->msix_res); if (sc->l2t) - t4_free_l2t(sc->l2t); + t4_free_l2t(sc); if (sc->smt) t4_free_smt(sc->smt); t4_free_atid_table(sc); @@ -2101,6 +2101,7 @@ stop_lld(struct adapter *sc) end_synchronized_op(sc, 0); stop_atid_allocator(sc); + t4_stop_l2t(sc); return (rc); } @@ -2454,6 +2455,7 @@ done: free(old_state, M_CXGBE); restart_atid_allocator(sc); + t4_restart_l2t(sc); return (rc); } diff --git a/sys/dev/cxgbe/tom/t4_tom_l2t.c b/sys/dev/cxgbe/tom/t4_tom_l2t.c index ee442f023970..749e5704863e 100644 --- a/sys/dev/cxgbe/tom/t4_tom_l2t.c +++ b/sys/dev/cxgbe/tom/t4_tom_l2t.c @@ -380,6 +380,10 @@ t4_l2t_get(struct port_info *pi, if_t ifp, struct sockaddr *sa) hash = l2_hash(d, sa, if_getindex(ifp)); rw_wlock(&d->lock); + if (__predict_false(d->l2t_stopped)) { + e = NULL; + goto done; + } for (e = d->l2tab[hash].first; e; e = e->next) { if (l2_cmp(sa, e) == 0 && e->ifp == ifp && e->vlan == vtag && e->smt_idx == smt_idx) { @@ -429,6 +433,8 @@ t4_l2_update(struct toedev *tod, if_t ifp, struct sockaddr *sa, hash = l2_hash(d, sa, if_getindex(ifp)); rw_rlock(&d->lock); + if (__predict_false(d->l2t_stopped)) + goto done; for (e = d->l2tab[hash].first; e; e = e->next) { if (l2_cmp(sa, e) == 0 && e->ifp == ifp) { mtx_lock(&e->lock); @@ -439,6 +445,7 @@ t4_l2_update(struct toedev *tod, if_t ifp, struct sockaddr *sa, break; } } +done: rw_runlock(&d->lock); /*