From patchwork Sun Sep 27 21:59:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3526 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id 1725B1C308E for ; Mon, 28 Sep 2026 00:03:19 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-26362-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-26362-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 9DBAF605296 for ; Sun, 27 Sep 2026 22:01:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B676E45D1BA; Sun, 27 Sep 2026 22:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UcT+P6g/" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-oo2-f36.google.com (mail-oo2-f36.google.com [74.125.231.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E20A642E013 for ; Sun, 27 Sep 2026 22:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.231.164 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790546432; cv=none; b=nVqPm9qmVTmCyhyGviTDaf/7XlyeaJJOpd28tNafP/VyHRUCJ44Py4BdyUwE5HkB012LFINXc/6pom8Gn6LLV6V4ZPGUvwRCIjs5CKRepDqyj5/fm+IJtBUA3ZCHHz2a0nBMX9x14byweabL3xWS4EygD34oIZgm9DFzdCRlesw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790546432; c=relaxed/simple; bh=e8Ab0vluYWvd/r+l2hGFayg0mumuN73e2IRX1RnFQco=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MixOOn94fHYi29snXN9L1J9RzKBJVi4rwaXBqtPCB6sNWvDe6SyExo7IlPURmGr/lAe3RA5d/MdxBFScMNYFsITXV403IMdDF4HhPVYN3CFByG3CMqKXA0DMR7tcm38aeyMW1dtGaJtPQw21T3JXdtMCOAeq7kzNmRlrPYsi4pg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UcT+P6g/; arc=none smtp.client-ip=74.125.231.164 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo2-f36.google.com with SMTP id 006d021491bc7-6d762782f99so448690eaf.0 for ; Sun, 27 Sep 2026 15:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790546423; x=1791151223; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AO44ZR+1vB6Jmo6A0lloXr+b5M9npc7CCaZmTVxm41A=; b=UcT+P6g/uCp109TMSutdeZPurK6oEGjWaQk8o3USchBjhtsERkGvvEDtNtL1S092GV xD7xk+DVeTa9R54+cAbmkCDJjh/vx6wH4mTJWU1V+AexykvZtD58y4hvlrTZDzijME1+ FNjVPao4RFzKJsyOCgE13BkaB88enqXLTC7b7n5EUIU03vGRUwdGzIPfmYgN0WGRhHev Hwg4IUxSqZzBPdfrhszDezEYlor+xgxg2lKH9PyL80gZ8IRa9A3TowM3R5ZtTPQAIIsZ ipJqv45AuH5ykoVKE+d+mGaoYgtJsO1VXUFJqnt9wt8XxE8RZGMesJIii8Jy3Ns2/a6g 72ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790546423; x=1791151223; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AO44ZR+1vB6Jmo6A0lloXr+b5M9npc7CCaZmTVxm41A=; b=LsL/5rqAgqJs5VTy4fOk6r3z8fZSF+TwAYfvKcFzDI7j4j97HxZh4CR08YiMBf44zD IrbMT03qRTvcITRI8pSrFwFXeChzExfTXF4iBIYzdRvolNp5Cuc1frDg5vjyNP8cwUZv 9tHmdLPIhyhDh9koNu739fdNSiuuBsrf4MuuQHDewg61vQJKgaNwxpwcYOQHZ5/M6jXS MsyroGR9snDQz734utpkkzKPpqjCbJ5j3hV2ndVLalJfDNfm4433B4ujwT9UAM2iL8/t DwOB5dvRnmAYVRnbB+Kw5vqiROix+QeCqyTrGu75N/6MmC0yb1ZIRO/W3W4KIrOEQYZb wLUA== X-Forwarded-Encrypted: i=1; AKwUvBwRhKtcpfXctl1ZOeP/mIAcBw9bka94jolNQMMzxlaM/XnCGDE2zMvlSRdi+RsCv1tq7fkMi5pRBoq8eA==@lists.linux.dev X-Gm-Message-State: AFuF++kk+aebiCDox4YrDh/YwryQNsbeByw4Aq/x1lMSJPRpzj5nm++n Ra8N4MyKbTzTZvWqU/Ag12qdLE4GDgOUig05CQCZNdx5dCy+3RBDfVDY X-Gm-Gg: AYBFou0gQdyEY67c8+FNJCrjGhxYqej7KPEYfKRvTXSExFIlCOH5tsXuWIg51S7imo/ CLLKykg1KjDm37v1kBrVxw+TqtUtECRVeHmOENEnlEUO33PZRW0JWF1dXaSsItnoDPIlQY4QBuX pBeo7raNfZT8tfNtLCDDco7YVYcTYumOzdJ5qadB3Mzot5queYR+B1BjDSYPuwGrc3gN/Xm8VsA hCLSMqjZ1g/+mirjz35IUJZu3ffZ4mpVCJOXDhxFdFg0fucr/NsgN1AWaxoYbxVeAhzr3trCzpI DtcOddiT+Pkw6vRxG0C4yVGd/NQgMpLZplU09cESKY1WInrsLk0JRGwrxczuK8LuNcvGWCZKBjr 1Qz/jT3CfZ8niSaZAxxeVfZ7EKTp7y1ee6nlCtRJcDWkpwrWmkADPWU1CNVYc51Emh9UXGNAQBC V7mDfRwdNtwZDDNe3twJ1VVDymjRdtKYtu8N/LFPyGTGQFa2kCWyC5S401GHimwX92vPH8JujeQ BDcmEhqkCQ7Elui+GwaPsrvOELfhoOkPJ8P7zLU/Zli6g01mtV7QfxAXxeL62/RdBOpUNj5/c9J Gb2kzUNc/EHgKaOqwzaNLb7HjH18WvCdkosn34zrH5vjcpcC2FYpYeOQ/22n15HXJ7jXEE2CdbQ tsFP/hy+t75p4yO5FIMot X-Received: by 2002:a05:6820:827:b0:6b3:f4b8:bb86 with SMTP id 006d021491bc7-6d43f4bd3c4mr10875034eaf.22.1790546423202; Sun, 27 Sep 2026 15:00:23 -0700 (PDT) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-81b3de6f7e1sm4874147a34.22.2026.09.27.15.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2026 15:00:22 -0700 (PDT) From: James Hilliard Date: Sun, 27 Sep 2026 15:59:49 -0600 Subject: [PATCH net-next v5 14/19] net: stmmac: use the tracked datapath restart for XSK pool changes Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260927-submit-stmmac-reset-fixes-v1-v5-14-feec6c14dd06@gmail.com> References: <20260927-submit-stmmac-reset-fixes-v1-v5-0-feec6c14dd06@gmail.com> In-Reply-To: <20260927-submit-stmmac-reset-fixes-v1-v5-0-feec6c14dd06@gmail.com> To: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King (Oracle)" , Maxime Chevallier , Andrew Lunn , Maxime Coquelin , Alexandre Torgue , Christian Marangi , Tiezhu Yang , Huacai Chen , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Serge Semin , Suraj Jaiswal , Richard Cochran , Joao Pinto , Vladimir Oltean , Ong Boon Leong , Voon Weifeng , "Song, Yoong Siang" , Linus Walleij , Martin Blumenstingl , Magnus Karlsson , Maciej Fijalkowski , Simon Horman , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thierry Reding , Jonathan Hunter , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jose Abreu , Yao Zi , Philipp Zabel Cc: Richard Genoud , Alastair D'Silva , Maxime Ripard , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org, ZhaoJinming , Lorenzo Bianconi , Ding Hui , Linkui Xiao , Linkui Xiao , linux-tegra@vger.kernel.org, linux-sunxi@lists.linux.dev, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.16 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.232.135.74:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.15)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FROM_HAS_DN(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; PRECEDENCE_BULK(0.00)[]; TAGGED_RCPT(0.00)[kernel,netdev]; FORGED_SENDER_MAILLIST(0.00)[]; FREEMAIL_CC(0.00)[bootlin.com,d-silva.org,kernel.org,vger.kernel.org,st-md-mailman.stormreply.com,lists.infradead.org,uniontech.com,oss.qualcomm.com,163.com,kylinos.cn,126.com,lists.linux.dev,gmail.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[sto.lore.kernel.org:rdns,sto.lore.kernel.org:helo]; RCVD_COUNT_FIVE(0.00)[6]; ASN(0.00)[asn:63949, ipnet:172.232.128.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; RCPT_COUNT_GT_50(0.00)[58]; R_SPF_ALLOW(0.00)[+ip4:172.232.135.74:c]; TO_DN_SOME(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; FREEMAIL_TO(0.00)[armlinux.org.uk,lunn.ch,gmail.com,davemloft.net,google.com,kernel.org,redhat.com,bootlin.com,foss.st.com,loongson.cn,iogearbox.net,fomichev.me,quicinc.com,synopsys.com,nxp.com,intel.com,googlemail.com,nvidia.com,sholland.org,ziyao.cc,pengutronix.de]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[bounces-26362-noreply=patchwork.local]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 1725B1C308E X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Replace the void per-queue enable helpers with the tracked XDP restart. Pause all queues and MAC link resolution while the pool bitmap and rings change, leaving the PHY running through phylink replay. Unwind a failed pool attachment without leaving NAPI over missing buffers. Pool removal must complete even if ordinary-ring rebuilding fails, after retiring all references to the departing pool. Preserve TBS configuration and return a detached interface to the ordinary down/up recovery path. Fixes: bba2556efad6 ("net: stmmac: Enable RX via AF_XDP zero-copy") Signed-off-by: James Hilliard --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 5 - drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 116 +++------------------- drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c | 44 ++++---- 3 files changed, 32 insertions(+), 133 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 6927afd01175..38370f2cbe87 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -473,11 +473,6 @@ static inline bool stmmac_tc_active(struct stmmac_priv *priv) netif_device_present(priv->dev) && !priv->hw_unavailable; } -void stmmac_disable_rx_queue(struct stmmac_priv *priv, u32 queue); -void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue); -void stmmac_disable_tx_queue(struct stmmac_priv *priv, u32 queue); -void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue); -int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags); struct timespec64 stmmac_calc_tas_basetime(ktime_t old_base_time, ktime_t current_time, u64 cycle_time); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index ad5ed2c95af7..95757f3cbc64 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2318,6 +2318,7 @@ static void __free_dma_tx_desc_resources(struct stmmac_priv *priv, kfree(tx_q->tx_skbuff); tx_q->tx_skbuff = NULL; + tx_q->xsk_pool = NULL; } static void free_dma_tx_desc_resources(struct stmmac_priv *priv, @@ -2830,6 +2831,12 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget) bool work_done = true; u32 tx_set_ic_bit = 0; + /* Nothing can be submitted while the link is down. Let NAPI complete; + * userspace can retry ndo_xsk_wakeup() once carrier has returned. + */ + if (!netif_carrier_ok(priv->dev)) + return true; + /* Avoids TX time-out as we are sharing with slow path */ txq_trans_cond_update(nq); @@ -2844,8 +2851,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget) /* We are sharing with slow path and stop XSK TX desc submission when * available TX ring is less than threshold. */ - if (unlikely(stmmac_tx_avail(priv, queue) < STMMAC_TX_XSK_AVAIL) || - !netif_carrier_ok(priv->dev)) { + if (unlikely(stmmac_tx_avail(priv, queue) < STMMAC_TX_XSK_AVAIL)) { work_done = false; break; } @@ -7450,107 +7456,6 @@ static int stmmac_xdp_xmit(struct net_device *dev, int num_frames, return nxmit; } -void stmmac_disable_rx_queue(struct stmmac_priv *priv, u32 queue) -{ - struct stmmac_channel *ch = &priv->channel[queue]; - unsigned long flags; - - spin_lock_irqsave(&ch->lock, flags); - stmmac_disable_dma_irq(priv, priv->ioaddr, queue, 1, 0); - spin_unlock_irqrestore(&ch->lock, flags); - - stmmac_stop_rx_dma(priv, queue); - __free_dma_rx_desc_resources(priv, priv->dma_conf, queue); -} - -void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue) -{ - struct stmmac_rx_queue *rx_q = &priv->dma_conf->rx_queue[queue]; - struct stmmac_channel *ch = &priv->channel[queue]; - unsigned long flags; - int ret; - - ret = __alloc_dma_rx_desc_resources(priv, priv->dma_conf, queue); - if (ret) { - netdev_err(priv->dev, "Failed to alloc RX desc.\n"); - return; - } - - ret = __init_dma_rx_desc_rings(priv, priv->dma_conf, queue, GFP_KERNEL); - if (ret) { - __free_dma_rx_desc_resources(priv, priv->dma_conf, queue); - netdev_err(priv->dev, "Failed to init RX desc.\n"); - return; - } - - stmmac_reset_rx_queue(priv, queue); - stmmac_clear_rx_descriptors(priv, priv->dma_conf, queue); - - stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, - rx_q->dma_rx_phy, queue); - - stmmac_set_queue_rx_tail_ptr(priv, rx_q, queue, rx_q->buf_alloc_num); - - stmmac_set_queue_rx_buf_size(priv, rx_q, queue); - - stmmac_start_rx_dma(priv, queue); - - spin_lock_irqsave(&ch->lock, flags); - stmmac_enable_dma_irq(priv, priv->ioaddr, queue, 1, 0); - spin_unlock_irqrestore(&ch->lock, flags); -} - -void stmmac_disable_tx_queue(struct stmmac_priv *priv, u32 queue) -{ - struct stmmac_channel *ch = &priv->channel[queue]; - unsigned long flags; - - spin_lock_irqsave(&ch->lock, flags); - stmmac_disable_dma_irq(priv, priv->ioaddr, queue, 0, 1); - spin_unlock_irqrestore(&ch->lock, flags); - - stmmac_stop_tx_dma(priv, queue); - __free_dma_tx_desc_resources(priv, priv->dma_conf, queue); -} - -void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue) -{ - struct stmmac_tx_queue *tx_q = &priv->dma_conf->tx_queue[queue]; - struct stmmac_channel *ch = &priv->channel[queue]; - unsigned long flags; - int ret; - - ret = __alloc_dma_tx_desc_resources(priv, priv->dma_conf, queue); - if (ret) { - netdev_err(priv->dev, "Failed to alloc TX desc.\n"); - return; - } - - ret = __init_dma_tx_desc_rings(priv, priv->dma_conf, queue); - if (ret) { - __free_dma_tx_desc_resources(priv, priv->dma_conf, queue); - netdev_err(priv->dev, "Failed to init TX desc.\n"); - return; - } - - stmmac_reset_tx_queue(priv, queue); - stmmac_clear_tx_descriptors(priv, priv->dma_conf, queue); - - stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, - tx_q->dma_tx_phy, queue); - - if (tx_q->tbs & STMMAC_TBS_AVAIL) - stmmac_enable_tbs(priv, priv->ioaddr, 1, queue); - - stmmac_set_queue_tx_tail_ptr(priv, tx_q, queue, 0); - - stmmac_start_tx_dma(priv, queue); - - spin_lock_irqsave(&ch->lock, flags); - stmmac_enable_dma_irq(priv, priv->ioaddr, queue, 0, 1); - spin_unlock_irqrestore(&ch->lock, flags); -} - void stmmac_xdp_release(struct net_device *dev) { struct stmmac_priv *priv = netdev_priv(dev); @@ -7650,6 +7555,9 @@ int stmmac_xdp_open(struct net_device *dev) stmmac_set_queue_tx_tail_ptr(priv, tx_q, chan, 0); + if (tx_q->tbs & STMMAC_TBS_AVAIL) + stmmac_enable_tbs(priv, priv->ioaddr, 1, chan); + hrtimer_setup(&tx_q->txtimer, stmmac_tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); } @@ -7687,7 +7595,7 @@ int stmmac_xdp_open(struct net_device *dev) return ret; } -int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags) +static int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags) { struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_channel *ch; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c index 7ecb7addd2ea..907ac49a1b76 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c @@ -9,7 +9,6 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *priv, struct xsk_buff_pool *pool, u16 queue) { - struct stmmac_channel *ch = &priv->channel[queue]; bool need_update; u32 frame_size; int err; @@ -34,23 +33,23 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *priv, need_update = priv->datapath == STMMAC_DATAPATH_RUNNING && stmmac_xdp_is_enabled(priv); - if (need_update) { - napi_disable(&ch->rx_napi); - napi_disable(&ch->tx_napi); - stmmac_disable_rx_queue(priv, queue); - stmmac_disable_tx_queue(priv, queue); - } + if (need_update) + stmmac_xdp_release(priv->dev); set_bit(queue, priv->af_xdp_zc_qps); if (need_update) { - stmmac_enable_rx_queue(priv, queue); - stmmac_enable_tx_queue(priv, queue); - napi_enable(&ch->rxtx_napi); - - err = stmmac_xsk_wakeup(priv->dev, queue, XDP_WAKEUP_RX); - if (err) + err = stmmac_xdp_open(priv->dev); + if (err) { + clear_bit(queue, priv->af_xdp_zc_qps); + xsk_pool_dma_unmap(pool, STMMAC_RX_DMA_ATTR); + netdev_err(priv->dev, "failed reopening after XSK pool attach: %pe; interface remains detached\n", + ERR_PTR(err)); return err; + } + + /* The pool is installed even if link resolution is still pending. */ + napi_schedule(&priv->channel[queue].rxtx_napi); } return 0; @@ -58,9 +57,9 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *priv, static int stmmac_xdp_disable_pool(struct stmmac_priv *priv, u16 queue) { - struct stmmac_channel *ch = &priv->channel[queue]; struct xsk_buff_pool *pool; bool need_update; + int err; if (queue >= priv->plat->rx_queues_to_use || queue >= priv->plat->tx_queues_to_use) @@ -73,24 +72,21 @@ static int stmmac_xdp_disable_pool(struct stmmac_priv *priv, u16 queue) need_update = priv->datapath == STMMAC_DATAPATH_RUNNING && stmmac_xdp_is_enabled(priv); - if (need_update) { - napi_disable(&ch->rxtx_napi); - stmmac_disable_rx_queue(priv, queue); - stmmac_disable_tx_queue(priv, queue); - synchronize_rcu(); - } + if (need_update) + stmmac_xdp_release(priv->dev); xsk_pool_dma_unmap(pool, STMMAC_RX_DMA_ATTR); clear_bit(queue, priv->af_xdp_zc_qps); if (need_update) { - stmmac_enable_rx_queue(priv, queue); - stmmac_enable_tx_queue(priv, queue); - napi_enable(&ch->rx_napi); - napi_enable(&ch->tx_napi); + err = stmmac_xdp_open(priv->dev); + if (err) + netdev_err(priv->dev, "failed reopening after XSK pool removal: %pe; interface remains detached\n", + ERR_PTR(err)); } + /* Socket teardown must be able to unmap and free the removed pool. */ return 0; }