From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796401758; b=nucffXls7zAFsc5wLJKT/4yLM7gx5U/NSQiV75hRlppQZbFMj90r4rAgyzAzDk1qiTBo NKonCb73FqTrXPtNWnUHKPMVOIPyiQZq34njkt389ks5vOmesFdnWW+U8Fw7hR2LRL56w fgiJ9EsXXZEKZNm4AsoHPuD5X5/a1zo8gcTeDQMU0cD7/sNdvUpciImNinD1nxRR5xGzK Kq5QCSzXEba8p8yopt6fBS+z3KzqWNTMHjlUKou3owcVwrlBUtUHbgjHmvrU2Ucc+lESh XbmlZCx0pyQzqp8LNWGOPSxCZgh5SwAQz6yWFOdudnuovut9RCgv8JRI6CeKGUPXh1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401758; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=N7ZlgbNc9W13tlpx+3GZW1X3juSAKEZ0DU3GNPvm/g0=; b=jWW0wn6W27CZKRRx0yNyaQvUzoNAtv6gRw4Dh07otUGfAYTYzSZhmn1irTr+pxvbxSNn Ia3LE4JXdMwgCSIPLhElUI6XyLK/AV9WjMgmeHx11hKGBQHmj7r/Z3w9UpvV9jk28pk/C 1qrfqHtRkyFN36GhDCG43m42jWTOgfkqXpNptaRiIxt1zqU2q9dlKHgMP4eBD4uypJc61 9x5goWqZZgu2duzDxx4TPTX4CkvL2q/dHG3HuXorw3xxBRdc/pmF9iwmGPDciVAm0jZgd kCzAehkYYqDlzZwd5OuAPvL349TijHnjA0yYN29eP5tAKLSRjE738IfVwPVsyLvF9iQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="RY9/J6ag"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E92C606A330; Fri, 4 Dec 2026 16:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RY9/J6ag Received: by smtp.kernel.org (Postfix) with ESMTPSA id B19F71F0092C; Fri, 4 Dec 2026 16:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796401758; bh=N7ZlgbNc9W13tlpx+3GZW1X3juSAKEZ0DU3GNPvm/g0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RY9/J6agiZWY839x9n9+A3RiO6G4JMBRkRAcY27J9MbYpDnqG3jD0qWfdar2WHSpe veLnQdWvu4SgUdrEfislDUSlqeuf2YKD3tG1IPB1cGdRCtRzuxkMWwPcUA0Jojssn3 ZjQWwi8qnuSBrt6PZVhA5yXuzIusb62gwAFUp50+vkNOiHawZ3zsu6VPikkW6zA16p qfLADGZrZa31RZ9Y7oBItmzLqdt6fKrAnXHjv0C2Ja2iaBaksmVpYZxZX2/ECwaiyl oevPg/pC2Cj0Pu1Tey6k6ByAXL2RB9O2x9jHWGKnduXHsLn7Jzowfr8Df75/q0JKn4 IzWi0N33cwZxA== From: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Nikolay Aleksandrov , Andrew Lunn , Ilias Apalodimas , Magnus Karlsson , Maciej Fijalkowski , Donald Hunter , Alexander Duyck , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Shuah Khan , Jonathan Corbet , netdev@vger.kernel.org, bpf@vger.kernel.org Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Simon Horman , Stanislav Fomichev , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , David Wei , Tao Cui , linux-kernel@vger.kernel.org, kernel-team@meta.com, "Mike Marciniszyn (Meta)" , linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan , Randy Dunlap , linux-doc@vger.kernel.org Subject: [PATCH net-next v2 11/15] net/mlx5e: Receive into XDP-only memory providers Date: Fri, 4 Dec 2026 17:27:16 +0100 Message-ID: <20261204162723.755897-12-bjorn@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204162723.755897-1-bjorn@kernel.org> References: <20261204162723.755897-1-bjorn@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mlx5 still refuses queue restarts with an XDP program, and its page pools take no provider next to XDP. Let striding RQs with a program take XDP-only providers, and accept queue restarts with one, as other providers refuse XDP. Binds on the cyclic RQ fail, as it would spin on a short FILL ring. While a queue has such a provider, refuse with -EBUSY: - a switch to the cyclic RQ; - PTP RX, TX port timestamps and HTB offload, as queue restarts clone no channel under them, so unbind would fail and binds fail with -EOPNOTSUPP; - growing the RQs of a device that is down, which would fail the next open. A devlink eswitch mode change bypasses these checks, leaving the queue on system pages that the socket drops. At MTU 1500, the linear RQ puts one packet per 4 KiB chunk. The nonlinear RQ puts every byte in fragments, so its head reaches the socket only with metadata. A bind or unbind pauses all channels briefly. Signed-off-by: Björn Töpel --- Notes (v2changes): Changes in v2: - Move the skip of the wait for posted WQEs to patch 10, and use the net/mlx5e prefix. - Let only striding RQs take XDP-only providers. The cyclic RQ posts whole bulks only, and would spin on a short FILL ring (Sashiko). - Refuse a switch from the striding RQ to the cyclic one, PTP RX, TX port timestamps and HTB offload while a queue has such a provider, and growing the RQs while the device is down (Sashiko). - The message covers the nonlinear RQ and its empty heads (Sashiko), and says what users see. .../net/ethernet/mellanox/mlx5/core/en_main.c | 62 ++++++++++++++++++- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 10 +-- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index a76ba297c9a9..74a2ae37a587 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1012,6 +1012,13 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params, pp_params.order = pool_order; pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV; + /* Trap and PTP RQs use queue 0 too, without a program. A + * cyclic RQ posts whole bulks only, and would spin in NAPI + * on a short FILL ring. + */ + if (params->xdp_prog && + rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) + pp_params.flags |= PP_FLAG_ALLOW_XDP_ONLY_NETMEM; pp_params.pool_size = pool_size; pp_params.nid = node; pp_params.dev = rq->pdev; @@ -3609,6 +3616,46 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv, bool old_first; int err; + /* An XDP-only memory provider takes a striding RQ, and the socket + * that installed it would lose its queue without a word, also when + * the device opens later + */ + if (priv->channels.params.rq_wq_type == + MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ && + params->rq_wq_type != MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ && + mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) { + netdev_warn(priv->netdev, + "Cannot leave the striding RQ while a queue has an XDP-only memory provider\n"); + return -EBUSY; + } + + /* mlx5e_queue_mem_alloc() clones no channel while PTP is on, so the + * provider of any queue could not go: its unbind restarts the queue + */ + if (((params->ptp_rx && !priv->channels.params.ptp_rx) || + (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_TX_PORT_TS) && + !MLX5E_GET_PFLAG(&priv->channels.params, + MLX5E_PFLAG_TX_PORT_TS))) && + mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) { + netdev_warn(priv->netdev, + "Cannot turn on PTP while a queue has an XDP-only memory provider\n"); + return -EBUSY; + } + + /* Closed channels open no RQ that would let the provider check a + * larger page pool, so the device would fail to open later + */ + if (!test_bit(MLX5E_STATE_OPENED, &priv->state) && + params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ && + mlx5e_mpwqe_get_log_rq_size(priv->mdev, params, NULL) > + mlx5e_mpwqe_get_log_rq_size(priv->mdev, &priv->channels.params, + NULL) && + mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) { + netdev_warn(priv->netdev, + "Cannot grow the RQs while the device is down and a queue has an XDP-only memory provider\n"); + return -EBUSY; + } + reset &= test_bit(MLX5E_STATE_OPENED, &priv->state); if (!reset) return mlx5e_switch_priv_params(priv, params, preactivate, context); @@ -4166,11 +4213,21 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, err = mlx5e_setup_tc_mqprio(priv, type_data); mutex_unlock(&priv->state_lock); return err; - case TC_SETUP_QDISC_HTB: + case TC_SETUP_QDISC_HTB: { + struct tc_htb_qopt_offload *htb_qopt = type_data; + + /* As for PTP, see mlx5e_safe_switch_params() */ + if (htb_qopt->command == TC_HTB_CREATE && + mlx5e_has_xdp_only_mp(priv, dev->real_num_rx_queues)) { + NL_SET_ERR_MSG_MOD(htb_qopt->extack, + "Cannot offload HTB while a queue has an XDP-only memory provider"); + return -EBUSY; + } mutex_lock(&priv->state_lock); err = mlx5e_htb_setup_tc(priv, type_data); mutex_unlock(&priv->state_lock); return err; + } default: return -EOPNOTSUPP; } @@ -5872,10 +5929,9 @@ static int mlx5e_queue_mem_alloc(struct net_device *dev, if (MLX5E_GET_PFLAG(&chs->params, MLX5E_PFLAG_TX_PORT_TS) || chs->params.ptp_rx || - chs->params.xdp_prog || priv->htb) { netdev_err(priv->netdev, - "Cloning channels with Port/rx PTP, XDP or HTB is not supported\n"); + "Cloning channels with Port/rx PTP or HTB is not supported\n"); err = -EOPNOTSUPP; goto unlock; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 1586cb2404c0..43a382fcd3ad 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -327,7 +327,7 @@ static void *mlx5e_mpwqe_get_linear_page_frag(struct mlx5e_rq *rq) frag_offset = li->frag_page.frags << MLX5E_XDP_LOG_MAX_LINEAR_SZ; WARN_ON(frag_offset >= BIT(rq->mpwqe.page_shift)); - return netmem_address(li->frag_page.netmem) + frag_offset; + return xdp_netmem_address(li->frag_page.netmem) + frag_offset; } static inline int mlx5e_get_rx_frag(struct mlx5e_rq *rq, @@ -1585,7 +1585,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi, dma_addr_t addr; u32 frag_size; - va = netmem_address(frag_page->netmem) + wi->offset; + va = xdp_netmem_address(frag_page->netmem) + wi->offset; data = va + rx_headroom; frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt); @@ -1640,7 +1640,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi frag_page = wi->frag_page; - va = netmem_address(frag_page->netmem) + wi->offset; + va = xdp_netmem_address(frag_page->netmem) + wi->offset; frag_consumed_bytes = min_t(u32, frag_info->frag_size, cqe_bcnt); addr = page_pool_get_dma_addr_netmem(frag_page->netmem); @@ -1940,7 +1940,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w prog = rcu_dereference(rq->xdp_prog); - head_addr = netmem_address(head_page->netmem) + head_offset; + head_addr = xdp_netmem_address(head_page->netmem) + head_offset; if (prog) { /* area for bpf_xdp_[store|load]_bytes */ @@ -2114,7 +2114,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi, return NULL; } - va = netmem_address(frag_page->netmem) + head_offset; + va = xdp_netmem_address(frag_page->netmem) + head_offset; data = va + rx_headroom; frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt); -- 2.56.1