From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 4437130AD07 for ; Mon, 13 Oct 2025 14:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367206; cv=none; b=biuEpEN+/+3Hc+lgCAMZpHeABXDeSL+9LaN8/FKJdO8MyJ7TOdWav/EY3uh27T7OomerJdZTJ1JBJpaMrV5qzWiO5xuQQB6nOdoYZshjFPu+TA8GHlXodWt+Dwt0vWVn0peB+WR8mAo/lf5oSkY6r8toYAz88g53nsdbCuSbEFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367206; c=relaxed/simple; bh=7sj1EbpAJnpeoVxMcwuWL5zaTTOuVyXNUSbxilQjCno=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HP8ujELh8jTAGxGpk5Kqfwj9tdU5MTNDmK3vMTevq2h0sKb2ZSOpqieSyxseqU6YqPR0fXQdKeySRcLKbpCacNoHNsuzTVuMbcv4J3jF0WcgCJS1P6ACEo4TPTGtvXNhlMlLJMl/V3ioY7XeVGCE/afR0SDIM8G5ZHV6/rJ6F+s= 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=UctH4wmB; arc=none smtp.client-ip=209.85.221.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UctH4wmB" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3f0134ccc0cso3288903f8f.1 for ; Mon, 13 Oct 2025 07:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367202; x=1760972002; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HqDy67Vpwu3GYg1tc86jhK5pz5tDZBEzHj59MW+Ighs=; b=UctH4wmBAKbnO0vP3yMu2v49mDyJRbxIaYIwLePGAWHxopZjFpXBsZIeBl+qR3GAl1 XpmCRJRlhsfcLHZmc3k9CgUSAa9gtvnyWcGJu6jZ2ZLUWj1R/bu6plny8LaRw0X6BI7I BXdh0FzvmnLxzuB9BFw5QiYieUpnqK0jia1HZKqqcYRxGlBUZhqCqUBIBCiICNxJSMI7 cLU/ixvgI53rY8lGbXKwkquaf+9ZcVLUfXjoBbz8cEPSv+PBOyQJJemBtp9HKFetixpt l7hC7IQFgNjXFv37bAp99VmdJtOJjh5FvHTyuZmfdlFQS5d9lAzhQNbTyQ0iEZcWplfn syDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367202; x=1760972002; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HqDy67Vpwu3GYg1tc86jhK5pz5tDZBEzHj59MW+Ighs=; b=xCQKls5ohVmLvg2msmgqEhR0ZbWZo5+HftOHxW/7Umfi+rMeRhAX5Ej1MRzzHHWNOd D5g/zsxszADQixJ6i5jNIIbIncWmnd+74VuJ8agjYxEFdJ9sS/jgC1a1i4o27O003W4V r7Fkimwh0ck8g7F7NV53SsYzWHmoSlEt8oPcz4vW8QtAPZ3m8TEioT7VDwRlxcqcWiKo /gMU58wXtV3tqT/OlEqCEjZzOWOLB54rgF5l9U1WvEH0IrZgL0Itt3VdWYd82OPU8bG2 QzV3qh0+9hcZ2utxUtxZkoG5z3MofpKTp/kmUlM3uvMYg0KXilqYGWB90K7L3gSEiNxE 84mA== X-Forwarded-Encrypted: i=1; AJvYcCXwKzaN3cstE46cPRaGVbt7VsxCmUFoyozfxDfznjYfP2ML7FUHttUG6PPWCNHT5wl+BGWTEIotGmrzzW4=@vger.kernel.org X-Gm-Message-State: AOJu0YzDlpAoHXFhDHT2uS1FBUFPm+OlRhSCYnulrgIpigygMf/Ur3LI SArLJL4q3fRy0N9aUbJ6c33aoGgiMJnZtPN/T4Z7uvFxsjx+WhTdLG5F X-Gm-Gg: ASbGnct3Xdph7vPcJfTm5rN+v1oL53++v38J6yaEvgP7FbELTYDecQMD1n3rAoZrrNH jgNFxfItIw6op+HzWBqke3X4AHI7sR+2bMYv7+uyzvhAhKLc14IvqEIN7LQBDg0FR2JBZPAXzYF axa5mmBjlbJVKGma7S599k2OLLUXF/QweN7ownq+FUwLaEVdG3ydTvFt0SLrsxYwcXloepjdIug RDM7Br2DCnij4P4Xh0z9vK02s+MVZwMhMt0RkL1FFqOXdKXKGWLtD+VhH+kpSoWxCsbcKqbR8iE H2sQTzx4T7TXygKuTTZgydb8BICZbg3+oo3p6eXcDu4uv1HOOYRtEu0z6o+irb9iQmEWowaCFue uAw0qUM1AD5JPgITp4EBYMEE1 X-Google-Smtp-Source: AGHT+IGuhS3kQZ1R1xe6ZB/ZEr0fg6Xs5SvekWOSlXtM50KBa0/ETxk5cO3wUCuWkLLaVPOmY7sV0A== X-Received: by 2002:a5d:5d03:0:b0:3ec:e0d0:60e5 with SMTP id ffacd0b85a97d-42667177bd4mr13708475f8f.15.1760367202162; Mon, 13 Oct 2025 07:53:22 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:21 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 01/24] net: page_pool: sanitise allocation order Date: Mon, 13 Oct 2025 15:54:03 +0100 Message-ID: <96099d1c7af73b1086ec1c7de1488b50147d07bf.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We're going to give more control over rx buffer sizes to user space, and since we can't always rely on driver validation, let's sanitise it in page_pool_init() as well. Note that we only need to reject over MAX_PAGE_ORDER allocations for normal page pools, as current memory providers don't need to use the buddy allocator and must check the order on init.i Suggested-by: Stanislav Fomichev Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- net/core/page_pool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 1a5edec485f1..635c77e8050b 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -301,6 +301,9 @@ static int page_pool_init(struct page_pool *pool, } =20 static_branch_inc(&page_pool_mem_providers); + } else if (pool->p.order > MAX_PAGE_ORDER) { + err =3D -EINVAL; + goto free_ptr_ring; } =20 return 0; --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 1C5CF30AD1E for ; Mon, 13 Oct 2025 14:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367208; cv=none; b=tqqhBbqhqW4ykjWANdX3N063LiwfNL5KlEBwT4jo/CvoD1SjIetqskG4NxLtuPkL/tL9jrH74AiJbxtR1TcHabSfVOlncuiYnaOX+os3p662EYYnYgmcR7HaHKihtx7a3jfYTmZ/KTnmyqs8DwZqUVwSDyFrbT31UszDTvpqQXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367208; c=relaxed/simple; bh=w+9GYnLfpJPuENZN1hq4bylmO2y99fnzpTWEsZZvlXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GZx1zjiUpHg5nsCNJNv+ukA24I4A0OXvUC54Vkg2DycyHPNvWaTyYAXjFzC0qb1rtEA6US4KGmHBvx0oxyt25lOvMhonHDOspsj/ZpUaZOJ4qkf3N14bVkVCIL5Tzq133SPhH/JrpJocLlCjhaPkuLZt9FHP0GkBIJPylHLIwFQ= 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=I/KBSFmk; arc=none smtp.client-ip=209.85.221.54 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I/KBSFmk" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3f99ac9acc4so3633915f8f.3 for ; Mon, 13 Oct 2025 07:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367204; x=1760972004; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Intn0C5yI8uAf2z3e0yNoFGVnV8Ruh2Zw9BITbwKtgg=; b=I/KBSFmkr823VYLJ9wwtqrnu7+aTcICtjpZOfR/GQ5E1yCUygyix9jp0J76TMiY+C5 yZd+9yDEdAH3g2i48cCgrqHH07RL2OdfWlSTn1ph8SQc6pOXb0XlHAaPIl/iuSFzDkFI cP1sJvjmu7Lx/8FAkkh4d4aQtIJck7g1rH7T6IAQxb7/fw+t/UgWDLULE8p80tOzf/QL nqZgWYDkJSrFZS4Q08d96Br4TJmIg3xi6HeuazjSD5K7g/NYlK626UE1X8NyF326HTyb qTSolPWPXrGexUR0pupc0I9yObjTg5bpRzqQ1/3YV9P7pAMQvu7uDAEdBSm6VALAyfZS crkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367204; x=1760972004; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Intn0C5yI8uAf2z3e0yNoFGVnV8Ruh2Zw9BITbwKtgg=; b=Nzn/bKRCaLPgD5PODu9pOMXQfFQELZnIy96vwzHow5GYUgnp4b1aOgGJEntB6o/QNX U3n8qfXf2SHej4EOhnUqS45QMyK7km5QdsKCitbBfsCBe0ToCkbPZSmwnFb5UL3QbbZM f9KKam1IeN0FbAbKLW2YatvVAR7X2MuAjYEil/CX6hxLmwPes9O5Ow/N/gU3cCfMPbLA k9OsCuiqR9CD+gwGgrOJ58xgknsp1pRsST5ZJF8QRka+Iu0z0fB17DTDZPDp5m1Sb0i7 A4x1YAMh2E98Uys5u6e0WZKTfJjqDWxVm9rMkqzb+PQu9Hf7F1vi26Pmhsp5IYn/FpR6 sHIg== X-Forwarded-Encrypted: i=1; AJvYcCX9sX7LstVbGve25sSDMkWyeExH2N2GKdr3j9VOn3yU6HfggSBRFQUCfClAD39wptUpmMZKXgHpHGiixwk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1SfKCBTcMERj5Q3CRf6Bdf5grxAFC5nVLxcAoQ8ozjfN4prUN wRRqLMz1zmp8RKhSaPxzus9an58XlrrNyBIphCKZ8MpO52SuOyKXykfT X-Gm-Gg: ASbGncsYc9kZAn9xO5oF+rXG5byDMkDUi5Og6SI3Uwwe5I6fDSP7uGlVjk0w0ZHHZSk WoLAGowW3iaUgP54RlKz8TIW3XYYp9o/MJBz4115A0XLiV4weyMjlaUwPpaReZbuwRmuUqBiLGZ GTIgzb1czYuoVYaACU3aleTCYK7QZHxhbcCKIxv8IhpbkGUEw8Y0WxeDA0pKeu6WhkFS8t/mmMT zu1jIDJO7nOcg4AbXG0ul7SGLzAOnB1g22uP2Mcy+NnIbSWxEMEerwOLBlup8wnuTbvpS9Zo5il KUNsETFFqL3F0HAgzJ1147McZ9OUoLTb3ZDHYyJAuEMT12l29GMRNDukK37YdRbY7C00yEDrx9I //s+3BRfiEt0z5zKyvt5kZnlwtwCK05pH3zMg9k2ZAIbTXA== X-Google-Smtp-Source: AGHT+IGM5o9+wFkfIja0oLP61fEHz91/0NGcuhmPQVULbrd0ZLVSDTzb9zJ9+EqpQiODyKQcWi27WA== X-Received: by 2002:a05:6000:1863:b0:3f6:9c5a:e1ff with SMTP id ffacd0b85a97d-4266e7dfda8mr14321226f8f.39.1760367204244; Mon, 13 Oct 2025 07:53:24 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:23 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 02/24] docs: ethtool: document that rx_buf_len must control payload lengths Date: Mon, 13 Oct 2025 15:54:04 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Document the semantics of the rx_buf_len ethtool ring param. Clarify its meaning in case of HDS, where driver may have two separate buffer pools. The various zero-copy TCP Rx schemes suffer from memory management overhead. Specifically applications aren't too impressed with the number of 4kB buffers they have to juggle. Zero-copy TCP makes most sense with larger memory transfers so using 16kB or 32kB buffers (with the help of HW-GRO) feels more natural. Signed-off-by: Jakub Kicinski Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- Documentation/networking/ethtool-netlink.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/n= etworking/ethtool-netlink.rst index b270886c5f5d..392a359a9cab 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -966,7 +966,6 @@ Kernel checks that requested ring sizes do not exceed l= imits reported by driver. Driver may impose additional constraints and may not support all attributes. =20 - ``ETHTOOL_A_RINGS_CQE_SIZE`` specifies the completion queue event size. Completion queue events (CQE) are the events posted by NIC to indicate the completion status of a packet when the packet is sent (like send success or @@ -980,6 +979,11 @@ completion queue size can be adjusted in the driver if= CQE size is modified. header / data split feature. If a received packet size is larger than this threshold value, header and data will be split. =20 +``ETHTOOL_A_RINGS_RX_BUF_LEN`` controls the size of the buffers driver +uses to receive packets. If the device uses different buffer pools for +headers and payload (due to HDS, HW-GRO etc.) this setting must +control the size of the payload buffers. + CHANNELS_GET =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 157A630B528 for ; Mon, 13 Oct 2025 14:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367210; cv=none; b=jIp0zV/4NFhz5qq4M+Uv5BxdvhQVS4XM5TgagGGf5mPG31qB+rAKIOmCEbN97onkNIcmXgNskDYHeCOLZClSU2nOF4udx3v0OmiVWmVmpwps/NAhl9f/raAbKGF40wcPT59vtXelU1Oz8rHnNWebQ++doGe6GuRcW93MnDajvhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367210; c=relaxed/simple; bh=V84/46IQukuHpDWyvrt512XHRkAzrJ/kWpdifpQbKZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SvJyiCvClTeaLNFc2eWQK03EdfG5i8L8+e43U1JGWkx4ZQN1lvqvgghKXrDmjQ99KlEKw2Mp38NffF8Li3mRBCJPaZ3VxT41eZq+ebFws3nOEEWHkGHplU2Fp/1IRZP23RPTx6cGGz5lhrsLjODeuG6USs2828gjBz/WKy/cAMk= 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=eKHhUHDh; arc=none smtp.client-ip=209.85.128.51 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eKHhUHDh" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-46e5980471eso23016475e9.2 for ; Mon, 13 Oct 2025 07:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367206; x=1760972006; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rEpNHAW5KcsbAUfQ5rP9CaFlyZXOHWCrIH1bgOMumdY=; b=eKHhUHDhZ3qUqimSKGpQWDBl4QTiW3jHEZ3cXLa9/THQvlNV6wRu5d3bdcUQe5rJ3y Ly5iwCDC5iw2MDYyi7cAX0ykX8WdLiDWnXNWVMRfgypYCbTazuckP6FFrOuVSAR912qQ 1jNHGtGTUU5AE9ztk5xsUZjcj4G+2yIIWuQ/BkwDhoNP302Z3u2bbuMx+M+VqQ3AuWGs LMl7jotEBRF304CfSiaLdHZcMliZHjZnjBftRB96cw1wf+GCnU1lQG8onlpPkJjK5OMf +4IoZEGwj7DuVOyLY/j0La1sKjyQniZtMgIkOTouaK5Qh7RiboyzOURHQXNL89Rk9E+p pPJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367206; x=1760972006; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rEpNHAW5KcsbAUfQ5rP9CaFlyZXOHWCrIH1bgOMumdY=; b=K4AKDVAh0I0I5xQtxgH5/TK/FyUg6b25K/4nbcOjx+lvi2VeeaMkaj5ruJIkaoyqKu bIyC09SWqXz7YzkiGGc2NUckAEqVEDjnUJwpCCksFvJgfGBB1UIY+8dsE3z3auHvOgy2 OZ/mmYic6ZRdZKR5gQqNRVACxYwZ817HxoIbwLeV+z9/ynZ0SzQhEkEphIhkriGqU5Lf EuouR4obnDpnZnvLhFYsfqb1xR70IkaiFVaf1wXJvY0xDgkNIkP3He3F9icJR29cuLQN OozK75UARZ2ygyn7vVjTcznmar572vehlrGNFqdbF4NtJ3qBqnL4D3EevLNgDT9gWzQ8 CokA== X-Forwarded-Encrypted: i=1; AJvYcCV5cwJ79iukTx/u4R07m4IqedJeLipdxQXczhhSlqR3D4Tcpv03vL5ORLUSQEFPonZBD1DRJCHWhKPuER8=@vger.kernel.org X-Gm-Message-State: AOJu0YwMNicuMUFf/drn6h3veUZIkcNu/koJ+tmHnEAbRaxSn2jZ6BbD SK7DLESi/cmUTbbk0+VuUucO71HQqGpI/CX1d6VDST5073QRwFDZTpaD X-Gm-Gg: ASbGncuVrxwOu4WA55jUgz+mZ9/Hg7aIC2Y7n7wqNuw9S9148N5J5JSFxMr8eMDzMjQ JoP9qXZr6MGUB7uY3aRlVjzVcVXDMKVGlFzEHXPA0KOh9U0JqNZEr+5fFd09w/HLMxtcTl/it/d czuAmXMIWS6TUK7nPHpFXmlbjVkOMOfzHLxBNqZzbMdc2oniZItWgvuOn8SyXuPMDLrJExigt8C 8SDDGTCM6pVa8WrZ9Zgs3nOBKXEgTBuaR0ohne0fTeitUrYklSfuKi/vr7vlODX6+CCQMthakGw osZ5Kk5vJatho2jOaL0oa4vwWr1el5+pZAitvqcekmtHT8ky65gGK/kH7zeZsW5wGCJEibWNDCE nLq1Hdi6RJxLyoCFfz/dV2Op2 X-Google-Smtp-Source: AGHT+IFzaDXO9su/SszejnjHzAL90Snp1i587mjZZwzGUhrRu24aIMznG8y+4vpCNDUyUpxQGWTYJw== X-Received: by 2002:a05:600c:4ed0:b0:46e:39e1:fc3c with SMTP id 5b1f17b1804b1-46fa9a8be52mr135053235e9.5.1760367206184; Mon, 13 Oct 2025 07:53:26 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:25 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 03/24] net: ethtool: report max value for rx-buf-len Date: Mon, 13 Oct 2025 15:54:05 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Unlike most of our APIs the rx-buf-len param does not have an associated max value. In theory user could set this value pretty high, but in practice most NICs have limits due to the width of the length fields in the descriptors. Signed-off-by: Jakub Kicinski Signed-off-by: Pavel Begunkov --- Documentation/netlink/specs/ethtool.yaml | 4 ++++ Documentation/networking/ethtool-netlink.rst | 1 + drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 3 ++- include/linux/ethtool.h | 2 ++ include/uapi/linux/ethtool_netlink_generated.h | 1 + net/ethtool/rings.c | 5 +++++ 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netli= nk/specs/ethtool.yaml index 6a0fb1974513..68e2b63ba970 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -452,6 +452,9 @@ attribute-sets: - name: hds-thresh-max type: u32 + - + name: rx-buf-len-max + type: u32 =20 - name: mm-stat @@ -2078,6 +2081,7 @@ operations: - rx-jumbo - tx - rx-buf-len + - rx-buf-len-max - tcp-data-split - cqe-size - tx-push diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/n= etworking/ethtool-netlink.rst index 392a359a9cab..d96a6292f37b 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -902,6 +902,7 @@ Kernel response contents: ``ETHTOOL_A_RINGS_RX_JUMBO`` u32 size of RX jumbo ring ``ETHTOOL_A_RINGS_TX`` u32 size of TX ring ``ETHTOOL_A_RINGS_RX_BUF_LEN`` u32 size of buffers on the= ring + ``ETHTOOL_A_RINGS_RX_BUF_LEN_MAX`` u32 max size of rx buffers ``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` u8 TCP header / data split ``ETHTOOL_A_RINGS_CQE_SIZE`` u32 Size of TX/RX CQE ``ETHTOOL_A_RINGS_TX_PUSH`` u8 flag of TX Push mode diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/dr= ivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index b90e23dc49de..19bcf52330d4 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -377,6 +377,7 @@ static void otx2_get_ringparam(struct net_device *netde= v, ring->tx_max_pending =3D Q_COUNT(Q_SIZE_MAX); ring->tx_pending =3D qs->sqe_cnt ? qs->sqe_cnt : Q_COUNT(Q_SIZE_4K); kernel_ring->rx_buf_len =3D pfvf->hw.rbuf_len; + kernel_ring->rx_buf_len_max =3D 32768; kernel_ring->cqe_size =3D pfvf->hw.xqe_size; } =20 @@ -399,7 +400,7 @@ static int otx2_set_ringparam(struct net_device *netdev, /* Hardware supports max size of 32k for a receive buffer * and 1536 is typical ethernet frame size. */ - if (rx_buf_len && (rx_buf_len < 1536 || rx_buf_len > 32768)) { + if (rx_buf_len && rx_buf_len < 1536) { netdev_err(netdev, "Receive buffer range is 1536 - 32768"); return -EINVAL; diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index c2d8b4ec62eb..26ef5ffdc435 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -77,6 +77,7 @@ enum { /** * struct kernel_ethtool_ringparam - RX/TX ring configuration * @rx_buf_len: Current length of buffers on the rx ring. + * @rx_buf_len_max: Max length of buffers on the rx ring. * @tcp_data_split: Scatter packet headers and data to separate buffers * @tx_push: The flag of tx push mode * @rx_push: The flag of rx push mode @@ -89,6 +90,7 @@ enum { */ struct kernel_ethtool_ringparam { u32 rx_buf_len; + u32 rx_buf_len_max; u8 tcp_data_split; u8 tx_push; u8 rx_push; diff --git a/include/uapi/linux/ethtool_netlink_generated.h b/include/uapi/= linux/ethtool_netlink_generated.h index 0e8ac0d974e2..ae59d17bd7f2 100644 --- a/include/uapi/linux/ethtool_netlink_generated.h +++ b/include/uapi/linux/ethtool_netlink_generated.h @@ -192,6 +192,7 @@ enum { ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, ETHTOOL_A_RINGS_HDS_THRESH, ETHTOOL_A_RINGS_HDS_THRESH_MAX, + ETHTOOL_A_RINGS_RX_BUF_LEN_MAX, =20 __ETHTOOL_A_RINGS_CNT, ETHTOOL_A_RINGS_MAX =3D (__ETHTOOL_A_RINGS_CNT - 1) diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index aeedd5ec6b8c..5e872ceab5dd 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -105,6 +105,9 @@ static int rings_fill_reply(struct sk_buff *skb, ringparam->tx_pending))) || (kr->rx_buf_len && (nla_put_u32(skb, ETHTOOL_A_RINGS_RX_BUF_LEN, kr->rx_buf_len))) || + (kr->rx_buf_len_max && + (nla_put_u32(skb, ETHTOOL_A_RINGS_RX_BUF_LEN_MAX, + kr->rx_buf_len_max))) || (kr->tcp_data_split && (nla_put_u8(skb, ETHTOOL_A_RINGS_TCP_DATA_SPLIT, kr->tcp_data_split))) || @@ -281,6 +284,8 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct= genl_info *info) err_attr =3D tb[ETHTOOL_A_RINGS_TX]; else if (kernel_ringparam.hds_thresh > kernel_ringparam.hds_thresh_max) err_attr =3D tb[ETHTOOL_A_RINGS_HDS_THRESH]; + else if (kernel_ringparam.rx_buf_len > kernel_ringparam.rx_buf_len_max) + err_attr =3D tb[ETHTOOL_A_RINGS_RX_BUF_LEN]; else err_attr =3D NULL; if (err_attr) { --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 37E5B30BBA4 for ; Mon, 13 Oct 2025 14:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367212; cv=none; b=BmHVH0Ocn6lpdtqm7y7RJHaNU92qHtfOM9m0b2kz+SHjR9F633hkEHyUgJnCS+VKMiM4Y8HvYNJx50lo73fk7vrupkAx+5qFUPPqOir/JCXwhDQvZsLgRFAn0BKuDjy5Dt7nsvan3QRnKZa4jqB79jEDIcv4gAmShTvkTV/n+sY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367212; c=relaxed/simple; bh=8yivflMmS6ZWIrzJSRvVg7Se0eo997CBR4EGse4XT6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RjgOwZG3rO7YX9hO7RaRBhiYjjXG0R2/vyQK7hrW/iJ51hnkID+O/XqO4P7xzjANECth69b7/HVvEoLFWWMEg8x8ZNedYSAQaNaMkkzuFBTxUlDb/y61wuKRs+/w7oVy+/hPKNaXNEl4H42t8SdAeZVCz2hBX5pqjYm2HzoYMLE= 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=dttiYk1R; arc=none smtp.client-ip=209.85.128.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dttiYk1R" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-46e3cdc1a6aso31761725e9.1 for ; Mon, 13 Oct 2025 07:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367208; x=1760972008; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OiKBlG9HlBGLvLNYc+/UZCgemFX+hK9aM2Cm2KqNb2E=; b=dttiYk1RMiXJYpx+btQtg+m0l/59NdUYe799cbaiEAZ9V4bqy1Pm1Jcyz0s/3Za6JP kisRXY9YR8vcz+PuknSdeGWa6yrnbH2Emp5lgMRHkYRyGPsDo1Jv1FCLf37IywFmh5+m v9oS6lrE/MM9xa17SIrDq1I50tVZLKhNvsbZci8JPuKo97CQwIgba9LAKFDsFynxNRlo jwqZ5UarIqNYnzKRP1pzXebrZStqBMeWRkiadfnQ3UxwCB/8ijckVZ8172f+w35+TjGm jybRi3oVO53CFZ4F94ivTVz+7RWeilop1Hk9p4b3pZgTwYRpkg8AjdwZVG7MpAWcWwjf RJmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367208; x=1760972008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OiKBlG9HlBGLvLNYc+/UZCgemFX+hK9aM2Cm2KqNb2E=; b=cxMGsDDLszXLgncpp/1L9cHaClLF2A8Ww1cMltqFUEoe+D2uN76B71W76UYhwQx9pn uCbfNUqh7xe/Nv/Zr3bgKktoYMGDtl+KmNdlZnZ1sIdacmYzZQhdS2AmWld+w4zyvVfy cJXzQ7Je3AmvlSyPtEB4MzcbpH6CpHVOMIapse+6f3knq5wd7iRiyuSIi1CJ16r87f2s rDeIlgpbOewCuThogH3HWM7/Bnj1C8Lp9efL+CYs53cf19P16MdVqP60L2kwuL0j9Oy9 AGTVmPnt/OezNhpLeiU9cSNU12LQV58OMPc4ITi+juGODGygohQWLc70KE3A9YAX6pj6 N0zg== X-Forwarded-Encrypted: i=1; AJvYcCUgadbQpY7TSjJoGCiLZllIchjBL2uje8QvNNHkG0lJiN8DvIaKBYnFBQXJOZ6fQ15YBFPFVfAcgprmJJs=@vger.kernel.org X-Gm-Message-State: AOJu0YygQGgPTdhXbc7qGVJZwn42mlnmxVB/8CJK5WsyNlHgBejRgUfE ZdEVr5vaZI7x3FA7uAvpE7v4w53fsQ7Zx53S0M29n+16NqRhk+wkzf// X-Gm-Gg: ASbGnctlwxC7mC3NH1QP8Nr6MCqboMyJBk0l2PTi3mfztJMcgFzXhfV7dHC3tDnf4sJ I2kIHpsUohB8IgCC2NSkCsVIId3PzvPjHJaG8gVo6Uy3THmCSQQAeq1BhU+XnhCMDzE97jB/iMw fGnBxx7XNIQ0QG1k+o2f6oviTgNhtaGXEFcaOwEaYkFd/Z5kRhvxz8la/fWe0H4yfv3TtsThh/3 Yz6gbbgS3AARCURkm2rvObGkg/a5Y00vOrS0VLvQv61UH92W51VzvHDE6Yyu5mPoEZqTda0/YN8 oWQJ/rh6Ue5Y2QD56pgkgZMLvK/CoGwQ23fucaTSCUYHjkU2EMo5wpOXmGdp51aHZoHQnghJYwI nDssNXoHQsZWMJnMc25JzdoLC X-Google-Smtp-Source: AGHT+IG0nnL9ogS0pl6/D61qEgnidvhF+6cZZVmeF2+ocwra6H4vaRwkXGqdq/k3KCd5ICzpoZPQag== X-Received: by 2002:a05:600c:b96:b0:46e:59bd:f7e2 with SMTP id 5b1f17b1804b1-46fa9ebe245mr152016175e9.11.1760367208347; Mon, 13 Oct 2025 07:53:28 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:27 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 04/24] net: use zero value to restore rx_buf_len to default Date: Mon, 13 Oct 2025 15:54:06 +0100 Message-ID: <271820dbf61d9de6f62440598a318926aa96f9cd.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Distinguish between rx_buf_len being driver default vs user config. Use 0 as a special value meaning "unset" or "restore driver default". This will be necessary later on to configure it per-queue, but the ability to restore defaults may be useful in itself. Signed-off-by: Jakub Kicinski Signed-off-by: Pavel Begunkov --- Documentation/networking/ethtool-netlink.rst | 2 +- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 3 +++ include/linux/ethtool.h | 1 + net/ethtool/rings.c | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/n= etworking/ethtool-netlink.rst index d96a6292f37b..41d4d81a86d1 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -983,7 +983,7 @@ threshold value, header and data will be split. ``ETHTOOL_A_RINGS_RX_BUF_LEN`` controls the size of the buffers driver uses to receive packets. If the device uses different buffer pools for headers and payload (due to HDS, HW-GRO etc.) this setting must -control the size of the payload buffers. +control the size of the payload buffers. Setting to 0 restores driver defa= ult. =20 CHANNELS_GET =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/dr= ivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index 19bcf52330d4..ada6244445da 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -397,6 +397,9 @@ static int otx2_set_ringparam(struct net_device *netdev, if (ring->rx_mini_pending || ring->rx_jumbo_pending) return -EINVAL; =20 + if (!rx_buf_len) + rx_buf_len =3D OTX2_DEFAULT_RBUF_LEN; + /* Hardware supports max size of 32k for a receive buffer * and 1536 is typical ethernet frame size. */ diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 26ef5ffdc435..0e6023df3ee9 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -77,6 +77,7 @@ enum { /** * struct kernel_ethtool_ringparam - RX/TX ring configuration * @rx_buf_len: Current length of buffers on the rx ring. + * Setting to 0 means reset to driver default. * @rx_buf_len_max: Max length of buffers on the rx ring. * @tcp_data_split: Scatter packet headers and data to separate buffers * @tx_push: The flag of tx push mode diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index 5e872ceab5dd..628546a1827b 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -139,7 +139,7 @@ const struct nla_policy ethnl_rings_set_policy[] =3D { [ETHTOOL_A_RINGS_RX_MINI] =3D { .type =3D NLA_U32 }, [ETHTOOL_A_RINGS_RX_JUMBO] =3D { .type =3D NLA_U32 }, [ETHTOOL_A_RINGS_TX] =3D { .type =3D NLA_U32 }, - [ETHTOOL_A_RINGS_RX_BUF_LEN] =3D NLA_POLICY_MIN(NLA_U32, 1), + [ETHTOOL_A_RINGS_RX_BUF_LEN] =3D { .type =3D NLA_U32 }, [ETHTOOL_A_RINGS_TCP_DATA_SPLIT] =3D NLA_POLICY_MAX(NLA_U8, ETHTOOL_TCP_DATA_SPLIT_ENABLED), [ETHTOOL_A_RINGS_CQE_SIZE] =3D NLA_POLICY_MIN(NLA_U32, 1), --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 1F2BC30BF6F for ; Mon, 13 Oct 2025 14:53:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367214; cv=none; b=GRB38U/7w+bjLwZ96jCzNs42H3KGjItw05XDBqZCykHJgWDB2hjv/aEdWy/WcaLP6UrLFEWFgwLWV0mc7gcsGXjP/D3isWrP6qHCE4jKgKHb7EsAUj9gx2q0uzH3k9cT1TYOz3AG8Q5nOZ3nivDpLeQOXyQbY5smLjYyqer4LHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367214; c=relaxed/simple; bh=+Yq4ejKTaKLjG6/YRDf0JOYouI+O/PnZAdPWT/9Qhhk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pSWJ43gkAOTw8NYqYq6T41R7oGCVpQGPHXX0i50cwMSunMfo4IKXQl7LbCVZ5H4f5In2AlC8Soae+mVOosqMIKCmqMokn29SIw0e+tu+fbhu9pDiBVX+05fTXIccv2FkyDQhkvhcFXJHhhhspkdndRR+QDbjUaXghQvSkZ/zACg= 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=UfXa/LL9; arc=none smtp.client-ip=209.85.221.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UfXa/LL9" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3ee13baf2e1so3174614f8f.3 for ; Mon, 13 Oct 2025 07:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367210; x=1760972010; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YU2s6sLvAqme/ijuimTj+jjmuWN5wreusGBihnFUvPU=; b=UfXa/LL9yt+Ysw1wELrwsK0t6iKsy3t5IUCTAtjy9DKPeEQanGkLuJByICJfJiZRCo 2Wl0lW72AvP8ho1HcN9Vh9JHkJEC/het3urWxISh4IBGSTI2zcl4uDokpum0E4gS+f6S rzKjJA0ZoNwMByGLXQsosTYoRpzxaDEu9+6EFUP7NhJ6QZpIMPouJpt0h36oOrWjjJc2 mGWA+JtH+YR7SJWokCKiE0ZMpHPgQMlW19yf/Eppm+0Svg+S2t3IQHeSgDTDa0jcTk3W sYh82YaDhp5lLDSbjYC+O2Iz7tPfhod7oVo1LybgB7st4jk7r/J9i8Iroo5GUcs8HNzb ZXrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367210; x=1760972010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YU2s6sLvAqme/ijuimTj+jjmuWN5wreusGBihnFUvPU=; b=Tp7sWBD3dHF+gEcj62jiihTJuS8gAenni8Vtc/+ggLoGZzHS4XxcCgSjiRsTEHgA1R qT5hy65uRKTlf/slH1ST5KKl0qQ+4NQ0jQiJ+LPsNhttvu6CijtAUFDWa7pkqYaqH6an Iz0ltMBGAFQrreHZtbsYNhvbL+spYMKbSyLjDxa090LMrtltCaqh7EeSxU5fVZUt589D jBnHTpGo+IL9sDQuCEQRQNpIUlFnCOJGcHhc1qY+4zMXl0D9iDaOOMKFCGdOoHpERU0+ VXAXMh6PrRDtU10Ppwgda8WkIlvYl+D69nVeLejq8Tf//+Bz6+O/zfM8W/tSQCf9M9KI Dyig== X-Forwarded-Encrypted: i=1; AJvYcCXslPm0gYjBhALuC1Afcwcjr/+pPuqaow9tv95JSxMB6yHGJfXUEmHxncMD3mM0Km+EjjQjcR8i9Wf171w=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3vLoKiph7DjrcKaTKC6Z9s3VCCsQRIGr4Uh2Y7QFwhV59HVGs Yt/4H7bsONb9KaFdItHCeeEwgV9WSl5/SE9wVkZQ0vi4f82EnujliZUt X-Gm-Gg: ASbGnctRxuptz2l1PHkmQqgTPnxcEHdCsietS7r1FDlfg861pS7BJzWAX780spp+Fbj +yO1nDrh8UWsKi1dJjNV5X3bQTeGqGXCoJReotggvt+7b0VEc4/SqukgwGYDZm9b55FzRTsES+S ArSF1Yw/nAs7YixndaHRaDqe5E0gLPwvkaVgPuNORt5ftidanKvY4XPIsttjGhVP6DxyTluUVN6 m3yvg+BXoCPeIfEDB6Zr41BAXVBl4bs4VkGBiNe8Xbd+O0nqRlR7xKAN83AK+FWNVVKDMV+cKcp g+pw6JPiTV4zWGyjmh4eopPd2EACRpO+Ss9AWf44yWiPRAYi/zS3fUOUaANWIccFRe/TAVYoNnd 9eZ6/TeIvQkYIf+gUAF8vBjCe X-Google-Smtp-Source: AGHT+IFXhn4holBktx1xsLQ9+wDO9MN5koElxro/9HDsZg+Lkdgx3g/gzvUUvtFHe8wBJMhvUCR6Yw== X-Received: by 2002:a05:6000:400a:b0:408:5363:8266 with SMTP id ffacd0b85a97d-4266e7df744mr15794027f8f.44.1760367210172; Mon, 13 Oct 2025 07:53:30 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:29 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 05/24] net: hns3: net: use zero to restore rx_buf_len to default Date: Mon, 13 Oct 2025 15:54:07 +0100 Message-ID: <17130da451bba12995b3e0de4eeddef72de70235.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As in previous commit, restore the default rx_buf_len value if the user passes 0. Also initialise rx_buf_len_max. Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/n= et/ethernet/hisilicon/hns3/hns3_ethtool.c index a5eefa28454c..3d3acc2b9402 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -10,6 +10,9 @@ #include "hns3_enet.h" #include "hns3_ethtool.h" =20 +#define RX_BUF_LEN_2K 2048 +#define RX_BUF_LEN_4K 4096 + /* tqp related stats */ #define HNS3_TQP_STAT(_string, _member) { \ .stats_string =3D _string, \ @@ -684,6 +687,7 @@ static void hns3_get_ringparam(struct net_device *netde= v, param->tx_pending =3D priv->ring[0].desc_num; param->rx_pending =3D priv->ring[rx_queue_index].desc_num; kernel_param->rx_buf_len =3D priv->ring[rx_queue_index].buf_size; + kernel_param->rx_buf_len_max =3D RX_BUF_LEN_4K; kernel_param->tx_push =3D test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state); } @@ -1113,9 +1117,6 @@ static int hns3_check_ringparam(struct net_device *nd= ev, struct ethtool_ringparam *param, struct kernel_ethtool_ringparam *kernel_param) { -#define RX_BUF_LEN_2K 2048 -#define RX_BUF_LEN_4K 4096 - struct hns3_nic_priv *priv =3D netdev_priv(ndev); =20 if (hns3_nic_resetting(ndev) || !priv->ring) { @@ -1127,6 +1128,9 @@ static int hns3_check_ringparam(struct net_device *nd= ev, if (param->rx_mini_pending || param->rx_jumbo_pending) return -EINVAL; =20 + if (!kernel_param->rx_buf_len) + kernel_param->rx_buf_len =3D RX_BUF_LEN_2K; + if (kernel_param->rx_buf_len !=3D RX_BUF_LEN_2K && kernel_param->rx_buf_len !=3D RX_BUF_LEN_4K) { netdev_err(ndev, "Rx buf len only support 2048 and 4096\n"); --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 D40F530F7E7 for ; Mon, 13 Oct 2025 14:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367216; cv=none; b=roXUgR+0mhwHwopEkah65GfUYY8pn+b+yyYo0vR0N4Wp4rxQTbQ9+xnNo2gF2P+mUCH7S4/VQPO8iLM4wwfsLah+eZjafgVVQp0c4XX8zZXuh0pC1xuhI1mWwJ6iEzRQfU/jbQPxP65KqVWs6M3NjyZWbBGjzqySReZNQaDcbbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367216; c=relaxed/simple; bh=kO++hqsqbVoh9SPKYKuZkXB0HqP9mKYieWTgGp5QmOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aB3Hy7NWUNZWoVyJRbpaV2OaSNoYD1D/bcTBTcjSWNs6hqipugxtxmn5hbeUtfkqZWsLU/Q/6o2PuZ51/rHWCCWg0w5Zk2xtIeK56Mhst3yqvlPDPh8X+X+ZHEHOJal9HXSqRGITl6XrfazwxudnEtmYWRomiMuvOBqRohRoIU8= 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=LwMBQcd8; arc=none smtp.client-ip=209.85.128.54 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LwMBQcd8" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-46e384dfde0so44343325e9.2 for ; Mon, 13 Oct 2025 07:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367212; x=1760972012; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p/S0lTizHDTDClQAPhS8aQBa6cUKMUxs8/coO2Ar/bs=; b=LwMBQcd87j/WrjYxRbL4Gl5oLQsOynEFPHXfyrYWH3SHXhURp90qFhlvm1LVwBPIBm cnEOAUH+La7y81fMqZ/0A0CSYV/xxJ0ROju+R0m6i32eXqKakYB9gMibCQOWlk7qo/ko LYaFNhHVxSoRLvaaGFqrfeBAqk19dJRjnAKhQ6uzUPApDMVbRbi8/nCH7Tf9fqFXPwxU q5QVTCSDQthgVmP5BvrVunuUi99gEtHH2lclEUgMqGlD3dLL42e7TlOcaRG2LAu3dI0t vDRn+a+7AsbqAV6GxozDuvUQn3PGTdXtflTiWj42llGP4L7ik6Aa0K376qitBlVppAfW ABwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367212; x=1760972012; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p/S0lTizHDTDClQAPhS8aQBa6cUKMUxs8/coO2Ar/bs=; b=MsETaK+j77TC9S2y3r0ATs97Kln7T8hpQXetYPlO7XSIFaDrlfxM1qsy6QVHNAEqti E2CdXNIhMrHlZMYHCUuOuAL3mcmz2HLkgcuhYzuAAW2GSD4xp9y9P+s+XQwXBRWu6ShB AeP5UjkLrvYWcSOj1FUR9Gq+PKEvZB2p7dNfsxZb0G4yfRT5GtmM2pSG71X5LeOSj7bC X0IcNnlaWjFsFbuz7z/8XvISj8l/dFvDQXfGIEy9wFj0svJ72+DrVx55T6wETjr1MBVk nYUPmt3BeOCcTeoDE+WUATYRNAzmIkWu7bX4Vd9ogfvDbTzgspoPwPL+CpoD6rje7u1g JI0w== X-Forwarded-Encrypted: i=1; AJvYcCWZjxxK9SPjtXQmZsAE+hbmmtlGNB3D8DQeMoX75l3wk0khreSddgj+CfHHT9ETBJvbADyg0ou2lhQ4uWU=@vger.kernel.org X-Gm-Message-State: AOJu0YxXKBMnS7g5yB+v9eDB7Ylk1JvsmV6voFISl9yRLTQ4tg/N3s0u 8Cw9RSBIQIkdFXhmD737a/xQATkoBXXRyzHFng3xeBVdp2xA8oyAnhv4 X-Gm-Gg: ASbGnctOiXUORVAurIQALwRnmGobPr4bqjHQXrO0HIl9C9TREJpdMWVq5iRLfBZHrpK E/NxIz77iwDBuzOSryfDIOZFElr32Ech/c1+x3erj1B23VG2dt/LC4EwWuuCvDFfoMrN4Sphj9W lWMtKJCTAZfFEbxGqCBI066WkHLG0ysYRfJ54HHL3p6BvNMSRK+8vr1jBoZDfV7PNoJZX/0Vb2L Xwxds+9by4ZnW3mZ/UIDjOVLksYI3O9ntlYdibo4pcDlRwTifhEA8T4VXWqQDhSxOOaNJiVyels JGNOECl8bYvb/bnXSOXBcpONLz/5Dp/8+SHh2C29GWtp0v/e9JcYs0+oawp4zgoPRidmJKC7Rd4 egHs4dCol/s/TwzXO4KVLxY/86M+rmxS2ZxY= X-Google-Smtp-Source: AGHT+IG30NLodqm5i6iZDMho0lRpiDey3nRByT9wCK+VDN0c//YQ5bDi8+c0ePHSQFGrSdh/9vp0GA== X-Received: by 2002:a05:600c:1394:b0:46e:432f:32ab with SMTP id 5b1f17b1804b1-46fa9b1704emr157969575e9.33.1760367212016; Mon, 13 Oct 2025 07:53:32 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:31 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 06/24] net: clarify the meaning of netdev_config members Date: Mon, 13 Oct 2025 15:54:08 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski hds_thresh and hds_config are both inside struct netdev_config but have quite different semantics. hds_config is the user config with ternary semantics (on/off/unset). hds_thresh is a straight up value, populated by the driver at init and only modified by user space. We don't expect the drivers to have to pick a special hds_thresh value based on other configuration. The two approaches have different advantages and downsides. hds_thresh ("direct value") gives core easy access to current device settings, but there's no way to express whether the value comes from the user. It also requires the initialization by the driver. hds_config ("user config values") tells us what user wanted, but doesn't give us the current value in the core. Try to explain this a bit in the comments, so at we make a conscious choice for new values which semantics we expect. Move the init inside ethtool_ringparam_get_cfg() to reflect the semantics. Commit 216a61d33c07 ("net: ethtool: fix ethtool_ringparam_get_cfg() returns a hds_thresh value always as 0.") added the setting for the benefit of netdevsim which doesn't touch the value at all on get. Again, this is just to clarify the intention, shouldn't cause any functional change. Signed-off-by: Jakub Kicinski [pavel: applied clarification on relationship b/w HDS thresh and config] Signed-off-by: Pavel Begunkov --- include/net/netdev_queues.h | 20 ++++++++++++++++++-- net/ethtool/common.c | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h index cd00e0406cf4..9d5dde36c2e5 100644 --- a/include/net/netdev_queues.h +++ b/include/net/netdev_queues.h @@ -6,11 +6,27 @@ =20 /** * struct netdev_config - queue-related configuration for a netdev - * @hds_thresh: HDS Threshold value. - * @hds_config: HDS value from userspace. */ struct netdev_config { + /* Direct value + * + * Driver default is expected to be fixed, and set in this struct + * at init. From that point on user may change the value. There is + * no explicit way to "unset" / restore driver default. Used only + * when @hds_config is set. + */ + /** @hds_thresh: HDS Threshold value (ETHTOOL_A_RINGS_HDS_THRESH). + */ u32 hds_thresh; + + /* User config values + * + * Contain user configuration. If "set" driver must obey. + * If "unset" driver is free to decide, and may change its choice + * as other parameters change. + */ + /** @hds_config: HDS enabled (ETHTOOL_A_RINGS_TCP_DATA_SPLIT). + */ u8 hds_config; }; =20 diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 55223ebc2a7e..eeb257d9ab48 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -902,12 +902,13 @@ void ethtool_ringparam_get_cfg(struct net_device *dev, memset(param, 0, sizeof(*param)); memset(kparam, 0, sizeof(*kparam)); =20 + kparam->hds_thresh =3D dev->cfg->hds_thresh; + param->cmd =3D ETHTOOL_GRINGPARAM; dev->ethtool_ops->get_ringparam(dev, param, kparam, extack); =20 /* Driver gives us current state, we want to return current config */ kparam->tcp_data_split =3D dev->cfg->hds_config; - kparam->hds_thresh =3D dev->cfg->hds_thresh; } =20 static void ethtool_init_tsinfo(struct kernel_ethtool_ts_info *info) --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 0D70330F923 for ; Mon, 13 Oct 2025 14:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367218; cv=none; b=KgC7IXLB8SV0RnkmmCIk0UaN1miAtr5E80bYIVKDNmqMl6EFqips2Cklpd31zTkfMRcXQI7QNbfN59hhOq8UjW+BqEkvb/oyERQBTnsbzNy9v5xqAx+YHuhn7BG4ivqxWs6eA3PsP88Z14PmXgWqUKtsQt0YT0/G9dZYqF8h+kc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367218; c=relaxed/simple; bh=PbuNSYS4ZvphCG8IIqw5e2RtAOtPsOlFF3aKC+mIwRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ILUasU+dtxjF7jnNV1PNc7Qwh848xnj0p7iA304yOz2uKENfP4tdpr8h7OtGEAv7J5YJdZzBH9cDi8owHXg+57pgz9uv8gpgYoyntsjS7Fvqx1GT4/FAxq0wF3FIQLK1pMCm3tsmehCKDv/zSxPSvDFflfg3FtsuTQd4106fv3o= 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=Sc9l9MkZ; arc=none smtp.client-ip=209.85.221.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Sc9l9MkZ" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-42557c5cedcso2328753f8f.0 for ; Mon, 13 Oct 2025 07:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367214; x=1760972014; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qRwTRM1YMVNfPJcUo8UFI2K+NlERkppykhGVZsYyCi8=; b=Sc9l9MkZ3jsGmKuzKFJ+WZzEdPxLvhnRI8KiyXKOgbVGZwAcnRqNP2Ec0LNq1zZ7md Mgq4VfOY21/tdd8fUZAVvlBcnBPIvU/xKZUYZw+ZPbW3jqi0ybSXxiN+ADp6xSnfF0c8 aJnV60/1bMla5WqYSH4g+oYgHEAmF0gsmgDAAfe1RLWuoaUpKKPAQ5I5cdOiUCwWuK9J /sEwPMpYtXR5vCLJYbNm1CJS1DaJGx8PL8Apt906L1RQYAMoXgFTCXplecSj7VXQf7fF 5J2uOwtwVSGXxOVIYxD+8NSZxxxZ80vhkwxl2ojns6ifMWP5ALcdJlIftTQJE/D3aG58 7pnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367214; x=1760972014; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qRwTRM1YMVNfPJcUo8UFI2K+NlERkppykhGVZsYyCi8=; b=k868Fucacj/za17otwkgXEbHoul4c14q8oVzBbZXnJQ1sVbCCCutitVDXj5O1MGQDo ChUjBMbYOnYc8BoQjGN1jnLefp0pI8HqGCheGNWx39wZXrQXFE48X/XGTUhDHJybDIEH N7g3Pg62KYMhwMFy7uRKLXmw4XNNUIYpzjPRT/pIfRFVv0achGoX4DD0KdK+TXfrZBwB ZlFe60VINeuN5YzAHFZjt2EnmPlJ7odIh7Vi980Vek8I6xuSV8h1Ers95RFQtwTMYoxJ x4gxEyJV01+Nz/s4RyrfhrcIrRSQLR6oi9tuxEdRPDpHtcbM1/4VvZk+xbHY5FwG869D 5s7w== X-Forwarded-Encrypted: i=1; AJvYcCUP5MPXxm4ss/YoDdZv40sZMAu1pqSbEHc0i3dOZwqjL2y6C321MOBECthdO7Jas2NdUhNf8qUnwMCNK2I=@vger.kernel.org X-Gm-Message-State: AOJu0YwENxqPsjwr1NqM2LP61I2cBoNv0NZPagLRUGvSyGX2avyANEPG m+8q6GJBa8UyuyW4bZOJN3eqTHy/GZHC+vHvs9/PFqxANoAzgqutQM0r X-Gm-Gg: ASbGncuI+0UbjH0UqueRlpfcaGRd2gPNNef66Ap3BCjKkEWA11Lt4ulWZ4QUHLWv9BQ TXFSpGBoQHirZbB4f4vAYaEguGuafqBRbrudkJs81Yn9g4BZJq8Yau/Ms3TkiSR+D+nlxV73WHp nvZSdS9m6W9gGH6KShYsGJJdBzAHLHnpNrWHKJzHss3YjJpzQCU1qBzaqb1BHz2Z4HU9W325txM 0QSofw01anG9rEHZTRrB2oKLJ7ZjyTCMfJ6dM/kFnAkUf55rzKowokm948sdpUaSEkSfwkcYxnR IAD8fGRLNvTI2wtQjMJ6v73JO5s/3SFg+9o9J1/807kY5rIvxm1MC+F3wGPjqscvhk3V/1E1hKY 4hGe9wfdzYu6+NiH6223Ln8Ta1IvvKT3FeJk= X-Google-Smtp-Source: AGHT+IHmUh7f1JWY1Bn/xnAz1OdnLNh1wSTUkKJWaDX80Ssi4DYZzLpugyxu+bw4gsN3KGpLNos3vw== X-Received: by 2002:a05:6000:4901:b0:426:d5bf:aa7 with SMTP id ffacd0b85a97d-426d5bf0c0bmr6709517f8f.63.1760367214055; Mon, 13 Oct 2025 07:53:34 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:33 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 07/24] net: add rx_buf_len to netdev config Date: Mon, 13 Oct 2025 15:54:09 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Add rx_buf_len to configuration maintained by the core. Use "three-state" semantics where 0 means "driver default". Signed-off-by: Jakub Kicinski Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- include/net/netdev_queues.h | 4 ++++ net/ethtool/common.c | 1 + net/ethtool/rings.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h index 9d5dde36c2e5..31559f2711de 100644 --- a/include/net/netdev_queues.h +++ b/include/net/netdev_queues.h @@ -25,6 +25,10 @@ struct netdev_config { * If "unset" driver is free to decide, and may change its choice * as other parameters change. */ + /** @rx_buf_len: Size of buffers on the Rx ring + * (ETHTOOL_A_RINGS_RX_BUF_LEN). + */ + u32 rx_buf_len; /** @hds_config: HDS enabled (ETHTOOL_A_RINGS_TCP_DATA_SPLIT). */ u8 hds_config; diff --git a/net/ethtool/common.c b/net/ethtool/common.c index eeb257d9ab48..2f05359d9782 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -909,6 +909,7 @@ void ethtool_ringparam_get_cfg(struct net_device *dev, =20 /* Driver gives us current state, we want to return current config */ kparam->tcp_data_split =3D dev->cfg->hds_config; + kparam->rx_buf_len =3D dev->cfg->rx_buf_len; } =20 static void ethtool_init_tsinfo(struct kernel_ethtool_ts_info *info) diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index 628546a1827b..6a74e7e4064e 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -41,6 +41,7 @@ static int rings_prepare_data(const struct ethnl_req_info= *req_base, return ret; =20 data->kernel_ringparam.tcp_data_split =3D dev->cfg->hds_config; + data->kernel_ringparam.rx_buf_len =3D dev->cfg->rx_buf_len; data->kernel_ringparam.hds_thresh =3D dev->cfg->hds_thresh; =20 dev->ethtool_ops->get_ringparam(dev, &data->ringparam, @@ -302,6 +303,7 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct= genl_info *info) return -EINVAL; } =20 + dev->cfg_pending->rx_buf_len =3D kernel_ringparam.rx_buf_len; dev->cfg_pending->hds_config =3D kernel_ringparam.tcp_data_split; dev->cfg_pending->hds_thresh =3D kernel_ringparam.hds_thresh; =20 --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 3D8B330BF7D for ; Mon, 13 Oct 2025 14:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367221; cv=none; b=nUbkljMcXlsMDP05nO/4kscV2ldAqzElVR5yJ151vUyaFlVEwlVPKnlslDs06OFhKj07rQoM6IVXSkQjvVDDwgKToHLuxqkcvilhu759LTAkWfjliLXNuuOSNqoCN9J0CMASwB6gSg6SzsvJbGYV0Bj9R5jf878vQxkX8XFb7u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367221; c=relaxed/simple; bh=01HcQ+bfWPiQW2hfPP1jD1pyLZ1kMeF3Kk/SUPuy8aY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=izqLPbT+g+drFPr4E4/t6pF7N655NMeVWBpvGa20iGXcjaimE+7MpXusVhbfW6zjrq4QXqEY0jNf81CEFtBUcSytaTQ2KVR69RWOT/APVPuRw1b0sW0WbH/d7SpitGmY9zXWJuw4JzVzpLJCCmhoyvM3Qtshfb35XTUhwMONFQA= 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=KBPnpKP4; arc=none smtp.client-ip=209.85.221.46 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KBPnpKP4" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3f0ae439bc3so2012012f8f.1 for ; Mon, 13 Oct 2025 07:53:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367216; x=1760972016; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HDydaL+0kX4XVTgkMgf2Tdq79K2+oRpgLC/WXO4c2NY=; b=KBPnpKP4Ji9mtBj0UtQH2XnZqsg4/0C+2FXpQjdsR/dyEBzY35xzX3LJdoTvORFimo EAZkU3SjJh2695nGmxoyKzaZm0qNSCfkqzCb6RSnn7XrW3M57vcA+5NgL6esQCyefElt vxG/+hq2TAT2si4AQIS2wocgzQiHTV1H+pzACXV6bbNI5vifQxC1A+zbSdNwShTsou1c NdzRJ+67hvJ+rGv8/uYydvw5q8Q+RZcVSpYwXTJ7VyWp/xQU9bUOwE3w5W+KKtNRzf/u C9LWKWiNbOmqW6r8VH1apStsA29QwMXUabjBtdAFwom9pXItQM9L04zM4MtxyHJEYbsX zRVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367216; x=1760972016; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HDydaL+0kX4XVTgkMgf2Tdq79K2+oRpgLC/WXO4c2NY=; b=XukD3jKw0xIltSBic+lLpXbPR+0YIPikWVEma/oeya3MAyKi1z7D2DoMqxjp+izw7F kfh46vzjzbVMLfEp5zJs+YVUnrWe1d60qTH75221gBbldlscEi/mJjTtR622bIhPJ2j1 7jZEmQAbjbLie+B0toLzebgdfc5XZnOvlLOMZlpHaEUf8GY96gcezEHoltRrCHJ1NaX3 o2GKPDRN1Oggi/EvxWkMDDsZsYtfzonq2wNqpFJB371A+R28nQPtPZuyB3b2fUAmrQWz S00en2uFEr2OVEvkaOMGNCEWmw8SQCMwfuol3e5d3xukcp3WMd+jRkGL9sV4B8G9XfuP dLCA== X-Forwarded-Encrypted: i=1; AJvYcCXp9tfjnoMTQ80DDMS1lNzgJ010ox1JR9PR8AcLzFipWyLIZ6p+S9vf+iKALEjpcHqFHeRJ4zPkBLu5Evc=@vger.kernel.org X-Gm-Message-State: AOJu0YxzV9Mz9N51R5t+ziVusY8E/qOd/5tSSDSTQ17I+GjXCvXhTelj QC5PSOzc13oU0E4MDxiXQFvEDX1pWiw9nwfmNXA/l1yWFvewTzGWXJR8 X-Gm-Gg: ASbGncu2S4qo4Mh2/Cm1Z6lWRcffWdgKwwcWqH8dx6psfijo0BM1ILpQjm81YOxjAIg af/iknovh9t7i8GvHcXalsTxg1HmHLi12SFTF5GjWcJnJvFosxnYsOMpfBVwUB9WrnL2wD648Ii bGK//cHL7iHgiAQJvVlvAUTOOlxTMz/64I+gX3EGkH34BtQzFzu5QbNOP6+NLlSqBsPZCGd2uyJ kNdM/ob8xhIGFCIIy7IMHaS0adTi66goeHNfiWqXdfc4s169DsrhAV0yxdXzrg+PIbsXLi0yKfO KL9hsrXLGEKJ0TBE1wa+gmkqdcGeWjZ0CEH8D6FKnEzNuWdsorwXRG/OHH8CdOLquN7sFBTn3CM 6dwzX4hi67a1gkWDhTQL1LRXi X-Google-Smtp-Source: AGHT+IHRs27nVpctjKFY9Eh6lI0fbhQhREsazw83w2WNaCFmZvecllGP5owrumusgM8b2+r8u2mOcQ== X-Received: by 2002:a05:6000:178c:b0:3e7:5f26:f1e8 with SMTP id ffacd0b85a97d-42666ab3390mr14959494f8f.5.1760367216021; Mon, 13 Oct 2025 07:53:36 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:35 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 08/24] eth: bnxt: read the page size from the adapter struct Date: Mon, 13 Oct 2025 15:54:10 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Switch from using a constant to storing the BNXT_RX_PAGE_SIZE inside struct bnxt. This will allow configuring the page size at runtime in subsequent patches. The MSS size calculation for older chip continues to use the constant. I'm intending to support the configuration only on more recent HW, looks like on older chips setting this per queue won't work, and that's the ultimate goal. This patch should not change the current behavior as value read from the struct will always be BNXT_RX_PAGE_SIZE at this stage. Signed-off-by: Jakub Kicinski [pavel: place const on right side in comparisons] [pavel: update __bnxt_alloc_rx_netmem's size check] Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 32 ++++++++++--------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 +-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 3fc33b1b4dfb..13286f4a2fa7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -905,7 +905,7 @@ static void bnxt_tx_int(struct bnxt *bp, struct bnxt_na= pi *bnapi, int budget) =20 static bool bnxt_separate_head_pool(struct bnxt_rx_ring_info *rxr) { - return rxr->need_head_pool || PAGE_SIZE > BNXT_RX_PAGE_SIZE; + return rxr->need_head_pool || rxr->bnapi->bp->rx_page_size < PAGE_SIZE; } =20 static struct page *__bnxt_alloc_rx_page(struct bnxt *bp, dma_addr_t *mapp= ing, @@ -915,9 +915,9 @@ static struct page *__bnxt_alloc_rx_page(struct bnxt *b= p, dma_addr_t *mapping, { struct page *page; =20 - if (PAGE_SIZE > BNXT_RX_PAGE_SIZE) { + if (bp->rx_page_size < PAGE_SIZE) { page =3D page_pool_dev_alloc_frag(rxr->page_pool, offset, - BNXT_RX_PAGE_SIZE); + bp->rx_page_size); } else { page =3D page_pool_dev_alloc_pages(rxr->page_pool); *offset =3D 0; @@ -936,8 +936,9 @@ static netmem_ref __bnxt_alloc_rx_netmem(struct bnxt *b= p, dma_addr_t *mapping, { netmem_ref netmem; =20 - if (PAGE_SIZE > BNXT_RX_PAGE_SIZE) { - netmem =3D page_pool_alloc_frag_netmem(rxr->page_pool, offset, BNXT_RX_P= AGE_SIZE, gfp); + if (bp->rx_page_size < PAGE_SIZE) { + netmem =3D page_pool_alloc_frag_netmem(rxr->page_pool, offset, + bp->rx_page_size, gfp); } else { netmem =3D page_pool_alloc_netmems(rxr->page_pool, gfp); *offset =3D 0; @@ -1155,9 +1156,9 @@ static struct sk_buff *bnxt_rx_multi_page_skb(struct = bnxt *bp, return NULL; } dma_addr -=3D bp->rx_dma_offset; - dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, + dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, bp->rx_page_size, bp->rx_dir); - skb =3D napi_build_skb(data_ptr - bp->rx_offset, BNXT_RX_PAGE_SIZE); + skb =3D napi_build_skb(data_ptr - bp->rx_offset, bp->rx_page_size); if (!skb) { page_pool_recycle_direct(rxr->page_pool, page); return NULL; @@ -1189,7 +1190,7 @@ static struct sk_buff *bnxt_rx_page_skb(struct bnxt *= bp, return NULL; } dma_addr -=3D bp->rx_dma_offset; - dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, + dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, bp->rx_page_size, bp->rx_dir); =20 if (unlikely(!payload)) @@ -1203,7 +1204,7 @@ static struct sk_buff *bnxt_rx_page_skb(struct bnxt *= bp, =20 skb_mark_for_recycle(skb); off =3D (void *)data_ptr - page_address(page); - skb_add_rx_frag(skb, 0, page, off, len, BNXT_RX_PAGE_SIZE); + skb_add_rx_frag(skb, 0, page, off, len, bp->rx_page_size); memcpy(skb->data - NET_IP_ALIGN, data_ptr - NET_IP_ALIGN, payload + NET_IP_ALIGN); =20 @@ -1288,7 +1289,7 @@ static u32 __bnxt_rx_agg_netmems(struct bnxt *bp, if (skb) { skb_add_rx_frag_netmem(skb, i, cons_rx_buf->netmem, cons_rx_buf->offset, - frag_len, BNXT_RX_PAGE_SIZE); + frag_len, bp->rx_page_size); } else { skb_frag_t *frag =3D &shinfo->frags[i]; =20 @@ -1313,7 +1314,7 @@ static u32 __bnxt_rx_agg_netmems(struct bnxt *bp, if (skb) { skb->len -=3D frag_len; skb->data_len -=3D frag_len; - skb->truesize -=3D BNXT_RX_PAGE_SIZE; + skb->truesize -=3D bp->rx_page_size; } =20 --shinfo->nr_frags; @@ -1328,7 +1329,7 @@ static u32 __bnxt_rx_agg_netmems(struct bnxt *bp, } =20 page_pool_dma_sync_netmem_for_cpu(rxr->page_pool, netmem, 0, - BNXT_RX_PAGE_SIZE); + bp->rx_page_size); =20 total_frag_len +=3D frag_len; prod =3D NEXT_RX_AGG(prod); @@ -4478,7 +4479,7 @@ static void bnxt_init_one_rx_agg_ring_rxbd(struct bnx= t *bp, ring =3D &rxr->rx_agg_ring_struct; ring->fw_ring_id =3D INVALID_HW_RING_ID; if ((bp->flags & BNXT_FLAG_AGG_RINGS)) { - type =3D ((u32)BNXT_RX_PAGE_SIZE << RX_BD_LEN_SHIFT) | + type =3D ((u32)bp->rx_page_size << RX_BD_LEN_SHIFT) | RX_BD_TYPE_RX_AGG_BD | RX_BD_FLAGS_SOP; =20 bnxt_init_rxbd_pages(ring, type); @@ -4740,7 +4741,7 @@ void bnxt_set_ring_params(struct bnxt *bp) bp->rx_agg_nr_pages =3D 0; =20 if (bp->flags & BNXT_FLAG_TPA || bp->flags & BNXT_FLAG_HDS) - agg_factor =3D min_t(u32, 4, 65536 / BNXT_RX_PAGE_SIZE); + agg_factor =3D min_t(u32, 4, 65536 / bp->rx_page_size); =20 bp->flags &=3D ~BNXT_FLAG_JUMBO; if (rx_space > PAGE_SIZE && !(bp->flags & BNXT_FLAG_NO_AGG_RINGS)) { @@ -7054,7 +7055,7 @@ static void bnxt_set_rx_ring_params_p5(struct bnxt *b= p, u32 ring_type, if (ring_type =3D=3D HWRM_RING_ALLOC_AGG) { req->ring_type =3D RING_ALLOC_REQ_RING_TYPE_RX_AGG; req->rx_ring_id =3D cpu_to_le16(grp_info->rx_fw_ring_id); - req->rx_buf_size =3D cpu_to_le16(BNXT_RX_PAGE_SIZE); + req->rx_buf_size =3D cpu_to_le16(bp->rx_page_size); enables |=3D RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID; } else { req->rx_buf_size =3D cpu_to_le16(bp->rx_buf_use_size); @@ -16631,6 +16632,7 @@ static int bnxt_init_one(struct pci_dev *pdev, cons= t struct pci_device_id *ent) bp =3D netdev_priv(dev); bp->board_idx =3D ent->driver_data; bp->msg_enable =3D BNXT_DEF_MSG_ENABLE; + bp->rx_page_size =3D BNXT_RX_PAGE_SIZE; bnxt_set_max_func_irqs(bp, max_irqs); =20 if (bnxt_vf_pciid(bp->board_idx)) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethern= et/broadcom/bnxt/bnxt.h index 741b2d854789..bbf4ff49ac0f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2361,6 +2361,7 @@ struct bnxt { u16 max_tpa; u32 rx_buf_size; u32 rx_buf_use_size; /* useable size */ + u16 rx_page_size; u16 rx_offset; u16 rx_dma_offset; enum dma_data_direction rx_dir; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/et= hernet/broadcom/bnxt/bnxt_xdp.c index 3e77a96e5a3e..c23c04007136 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c @@ -183,7 +183,7 @@ void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx= _ring_info *rxr, u16 cons, u8 *data_ptr, unsigned int len, struct xdp_buff *xdp) { - u32 buflen =3D BNXT_RX_PAGE_SIZE; + u32 buflen =3D bp->rx_page_size; struct bnxt_sw_rx_bd *rx_buf; struct pci_dev *pdev; dma_addr_t mapping; @@ -469,7 +469,7 @@ bnxt_xdp_build_skb(struct bnxt *bp, struct sk_buff *skb= , u8 num_frags, return NULL; =20 xdp_update_skb_frags_info(skb, num_frags, sinfo->xdp_frags_size, - BNXT_RX_PAGE_SIZE * num_frags, + bp->rx_page_size * num_frags, xdp_buff_get_skb_flags(xdp)); return skb; } --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 04F3A30FF2B for ; Mon, 13 Oct 2025 14:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367222; cv=none; b=e+k9k/QAC7qY/j8op+l2BODyX+nayz/g/uco4nKa7Xh1oeb7CiFYURQy3g6/jHsWFkG+wds05a773JtFN+Fp9vbkMBDw+foyunOKVhsoNR2A/2T5sGsbGihY8mPBzHge6DSTPsc7e1HheVik1DCMUI4Y+Dd7MpFvSfOmTmEUBxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367222; c=relaxed/simple; bh=kYq0RQ8YrvfPuA2ch2Lr96zLv/LgeMZHSYJ35zuO0Kg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kvnc62wLT6WGqsFzhx/Q8v03bYL+X98NDNVQnfJue+0yls7xKi3figXCCkrUuGP7ues9UqccUM5vHjkuIbMpKY06oV/18pBYMyMrRAWx2c3zfNLUGNZSBBdkBw2AxmDPohGYNGG3W4mH8sOdBZZNFGD20b9pxgDjbrXG2nFFoZg= 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=gFVHgG6J; arc=none smtp.client-ip=209.85.128.52 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gFVHgG6J" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-46e491a5b96so23542275e9.2 for ; Mon, 13 Oct 2025 07:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367218; x=1760972018; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OSdm7MHpJ+vjaDQLZoXmd6BHbOT4QBiIczgwCkXiEjY=; b=gFVHgG6J93eClI/ZIex9xvVEdr8050jQpjnhPYM8mn3NgFH8qg/9+PR4DR6l4ZjH7M f2Fi4GF4nzqZG9j+g1ckiUzhqsBO1Syfy5CRBebDGu2nxq+kLw4UltxeJ8wEUXQS27Lh 53WWBdcxD+yyQ/sLN/OMPzBk2l5UbrhOKfGerp4WDwR33RZUaQX1ugo+UVZBVS3wOb9b r5jz+sNcGj7Ga6F/EI4cBrleA2WYwRCnQtDiPowCtGrwFeOQJaRpBsdC67w+oeq4XLqB ItXWXX45h/dINsZSY0r25MtUpQvOr7poZqEfV+IEFSVvFyT3rq976kwUer5S24TmWd2H 1cPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367218; x=1760972018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OSdm7MHpJ+vjaDQLZoXmd6BHbOT4QBiIczgwCkXiEjY=; b=Z+NLhb/nrsLQav81LH62YfRE97W94PWC6/ZWF5ouOE/NUgGYrk35J7PK2Jgw6WMLka 7EtF5W1gDZYu0QEji2WsEsNwP15+lsgBqxvKSQlACYGSIU6wxdM7fBQz0yd3gmUdjGxw O0Jmbvu37OnLr0CKYkRQy8b8to9kdrHCuRPKbGuPSgctdjKddjFfHxh42KsDROU+bIbQ iVQbvizs4VLBJEkQCvDLxXfQuu09ivZkQaWISFFnFLB0JRmrbmz9qGzUB/DtqHzk2kGq MRr1cnXbXCYVQE3QbpHZwvcoOV7edGpDNBmb2DL7gjK4WvL/awwjCGk51tFWx4VCSFX1 9vEw== X-Forwarded-Encrypted: i=1; AJvYcCWh5D9NvNSHEpxP8mPsYJFSpoff8PUjqVdqY3wcccK84xM958sGVkjXE2ZvHyhQ6QSjvEN1QMiShdMAoU8=@vger.kernel.org X-Gm-Message-State: AOJu0YxAjzG+ky+Dzuyq9Aib6hABWo1i0SDR1IW12J8TCF7dYBXkp4nF tqyxsGAS6zIJ7VfhK7tIoPGfg92XqPbHjaCnoQyY0ItvszWGZNSDLUFt X-Gm-Gg: ASbGncvEGlpa3GPiJyaB9u6l725242xKA32yIiSid0EnfBwGj/UpkAzyoV8FUrsPasG TK6fB8YQe7yIHbI9g+xteWF7PPU1xaHCigoddSnQKUxHzuuxerrLKh8OyYVN/Nq3vCmS3iZuANB R7bNYQumvW+nVE8H31y2e1RY/1gB0XNY6Mi01dqwf81FFWHFsDnUMmK2yyFgtgr8uPP0KhNOA0X /kG3lxbvI6ZzwrdnKnI3LDNhFdpaO64wIBNpeUhQvs2rw6ibOjsvAHGMEJ2OKQo0j7hYIrAogcm /agrl5T2abkOJgrvYeG+GZeEhoKETsbwbrTjUjbGiGc9Vu+amICpTbB+zqay6cVlGasZi7zQ0AN OxX5CAMX2PIZWhjjdTTj6XGFnf04cfN5wjvU= X-Google-Smtp-Source: AGHT+IED3GRiP+h7v/FeCyojCF1RwIXSpzaWATh3pEDXx0dXFBUhT/YkmwA0d8YAYemw1uBFEREaKA== X-Received: by 2002:a5d:5d08:0:b0:425:7ce6:fd50 with SMTP id ffacd0b85a97d-4266e8db473mr14976457f8f.53.1760367218044; Mon, 13 Oct 2025 07:53:38 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:37 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 09/24] eth: bnxt: set page pool page order based on rx_page_size Date: Mon, 13 Oct 2025 15:54:11 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski If user decides to increase the buffer size for agg ring we need to ask the page pool for higher order pages. There is no need to use larger pages for header frags, if user increase the size of agg ring buffers switch to separate header page automatically. Signed-off-by: Jakub Kicinski [pavel: adjust max_len] Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 13286f4a2fa7..5c57b2a5c51c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -3829,11 +3829,13 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp, pp.pool_size =3D bp->rx_agg_ring_size / agg_size_fac; if (BNXT_RX_PAGE_MODE(bp)) pp.pool_size +=3D bp->rx_ring_size / rx_size_fac; + + pp.order =3D get_order(bp->rx_page_size); pp.nid =3D numa_node; pp.netdev =3D bp->dev; pp.dev =3D &bp->pdev->dev; pp.dma_dir =3D bp->rx_dir; - pp.max_len =3D PAGE_SIZE; + pp.max_len =3D PAGE_SIZE << pp.order; pp.flags =3D PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV | PP_FLAG_ALLOW_UNREADABLE_NETMEM; pp.queue_idx =3D rxr->bnapi->index; @@ -3844,7 +3846,10 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp, rxr->page_pool =3D pool; =20 rxr->need_head_pool =3D page_pool_is_unreadable(pool); + rxr->need_head_pool |=3D !!pp.order; if (bnxt_separate_head_pool(rxr)) { + pp.order =3D 0; + pp.max_len =3D PAGE_SIZE; pp.pool_size =3D min(bp->rx_ring_size / rx_size_fac, 1024); pp.flags =3D PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV; pool =3D page_pool_create(&pp); --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 24456310654 for ; Mon, 13 Oct 2025 14:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367224; cv=none; b=q6Jw5vHbaWIMdbNIBZn4A/SruAQYyHqEk0mXKAilxODCYrzkoowzyKhZqDfpxk41qZYN2bTw1ruOhftEso/+f8NxLyHRd/VXzyXV7JjT2aXG4XIcYFMv9an+pBtAC7F4Gd1BO+x/yGbhN2yAnx45SuNrvSPEFYt/4kOJt2Cr5dM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367224; c=relaxed/simple; bh=YfJ1fqXNyw5aWMbbwGECFiNPz3jXV/l4u98wRnHXoPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XCavYVMJa28/iLj8/fLYX7yuk3A9eMCIGAbgMt4NvuLiCDdZsPmm+dV90a1Qp8H13Ga/l6OPvJYN/IQ1Zy6E3fZQiC97VBd6JMldttOYXCv8ajlOkdo2S8Ylyd9xLHYz/JaLCwhF0DUbiIbDIN42NfqNOW0bII5cWXRp/6Ob1pQ= 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=lSKpqIQH; arc=none smtp.client-ip=209.85.221.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lSKpqIQH" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3ee12a63af1so2537412f8f.1 for ; Mon, 13 Oct 2025 07:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367220; x=1760972020; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JkTczQTZHYryzPDWDXYNY8z0qrPjMacwqBMHw46Z8LQ=; b=lSKpqIQHRd3woDV+87HYJx6DE8z9s2XGSHnzaW+2akoWtXg4Xe8StTaroJF71q/hdU BHEp3Y4kR75wUi+xOs/FNXY/CA/trMdZzg+6qyn3dWT4gFSXzNKLjlms46r1MKeT8RRl xCfhwqdqlt1mODLzhvoGYhzeqCms9oWhCZmIXmZAoqCQaMwBXylgPByhLdh42fXbO20P R8aR0n8ijPEB/15RMK0aqBdXb2D17WV/R0xC6aW7fspUnQ5XVfY0BTcLU/NOoFO439jJ kFuGXDcrtq7U3vaYHMOkA/QVE19Vc9bzDzU/kBp9DJQsqkuGS4QHeQ+J1f0My+FqDmmv /CSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367220; x=1760972020; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JkTczQTZHYryzPDWDXYNY8z0qrPjMacwqBMHw46Z8LQ=; b=UJk+h6r0s7TetNDRQX8iq0NUEdK1ouX0GekEZ8q5MewDic3sfmU2zdRbsfqPyrjtAX izQMsc6EwaTbTKaI7gPFxwMkW5P72a6KeHuuc23rSg0uu0kDM1gJPsQ1RlSCDVzysrFa ur98Cy1IYkFpgBRRZDo2fWDpwJsy5utRIWULkb8ZaN33KkZd0iLesVsEa9ogjhk8Utx7 Ftcx+l3nXIeK+B7vC1sFwAR8UNK5SippIgMBV5i65i20muZWE1VCb7IH/5w+o7BkXOPX L2kr+2ZcH/LmMPnrsUTaGkPFlOrgJBIkGYn2WceEUM/+eLzrMD2OS7Y7gzG7kryQ71O0 kn+A== X-Forwarded-Encrypted: i=1; AJvYcCXO6fGNtou5PyKMZ5liip2NWaw45gzdi5USLgdaXgdsHbuSOgYljHwmWRdIOS3XQHQ1uczd92Z13FWaGuY=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn27OBZOIegPsG3YFIZKokb9bOsdh89YYIsx72UXy3uUOUWQ0x j/Sm9mb1XHKtJFks8Uz+l3D3UzEJn83EO4pNVDnrlSqfSX3eDZVad7ab X-Gm-Gg: ASbGnctthzxGX6U54Oi8pTvfE3OWCT/o34QFotUvVJSsFrtAPqxiD7nPAhgWhwMLdAu 0gNz8q9kMl9S93tqxWpxrpX48x4ejIZpzMBukKw11EvsCECbaqsEuZX9TNVyXT1oLHudpReFIHp oZSnk42z3BN+xqozj2uHQn77TA1lTPdjxujMmX64bAp1D4HFKmd/blzHAwWO5fPj+7Dd31qT8r5 +zCzY2rhgaYE2Kgox7816GkuAgL1r/zld31MW7y/waZLVAMRO0HAltHdCn+pf8oWwGF2gQ0L28a MDWf06y38tmOG7RkVFZjPmLesZwcI2sKWGceebvrDimP+6uAPPSVIAnp5klb3adgUijqqqix/h9 bZ2d5qeHzBXUi/NOGpGE9K7twhwNk8lLmux8= X-Google-Smtp-Source: AGHT+IH1AcW1vbl3T0tBxKkGhV2edrcBa7q1HnLUi7VWiRaXXYXEc5A2MgNgOomw2NjVWPsYTALNzw== X-Received: by 2002:a5d:64e7:0:b0:425:769d:4426 with SMTP id ffacd0b85a97d-4266e7dfff1mr12304230f8f.34.1760367220062; Mon, 13 Oct 2025 07:53:40 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:39 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 10/24] eth: bnxt: support setting size of agg buffers via ethtool Date: Mon, 13 Oct 2025 15:54:12 +0100 Message-ID: <7760b969989404e3ea3fa5ed3404b54378b09e4e.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski bnxt seems to be able to aggregate data up to 32kB without any issue. The driver is already capable of doing this for systems with higher order pages. While for systems with 4k pages we historically preferred to stick to small buffers because they are easier to allocate, the zero-copy APIs remove the allocation problem. The ZC mem is pre-allocated and fixed size. Signed-off-by: Jakub Kicinski Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 ++- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethern= et/broadcom/bnxt/bnxt.h index bbf4ff49ac0f..3abe59e9b021 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -758,7 +758,8 @@ struct nqe_cn { #define BNXT_RX_PAGE_SHIFT PAGE_SHIFT #endif =20 -#define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT) +#define BNXT_MAX_RX_PAGE_SIZE (1 << 15) +#define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT) =20 #define BNXT_MAX_MTU 9500 =20 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/ne= t/ethernet/broadcom/bnxt/bnxt_ethtool.c index 41686a6f84b5..7b5b9781262d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -835,6 +835,8 @@ static void bnxt_get_ringparam(struct net_device *dev, ering->rx_jumbo_pending =3D bp->rx_agg_ring_size; ering->tx_pending =3D bp->tx_ring_size; =20 + kernel_ering->rx_buf_len_max =3D BNXT_MAX_RX_PAGE_SIZE; + kernel_ering->rx_buf_len =3D bp->rx_page_size; kernel_ering->hds_thresh_max =3D BNXT_HDS_THRESHOLD_MAX; } =20 @@ -862,6 +864,21 @@ static int bnxt_set_ringparam(struct net_device *dev, return -EINVAL; } =20 + if (!kernel_ering->rx_buf_len) /* Zero means restore default */ + kernel_ering->rx_buf_len =3D BNXT_RX_PAGE_SIZE; + + if (kernel_ering->rx_buf_len !=3D bp->rx_page_size && + !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) { + NL_SET_ERR_MSG_MOD(extack, "changing rx-buf-len not supported"); + return -EINVAL; + } + if (!is_power_of_2(kernel_ering->rx_buf_len) || + kernel_ering->rx_buf_len < BNXT_RX_PAGE_SIZE || + kernel_ering->rx_buf_len > BNXT_MAX_RX_PAGE_SIZE) { + NL_SET_ERR_MSG_MOD(extack, "rx-buf-len out of range, or not power of 2"); + return -ERANGE; + } + if (netif_running(dev)) bnxt_close_nic(bp, false, false); =20 @@ -874,6 +891,7 @@ static int bnxt_set_ringparam(struct net_device *dev, =20 bp->rx_ring_size =3D ering->rx_pending; bp->tx_ring_size =3D ering->tx_pending; + bp->rx_page_size =3D kernel_ering->rx_buf_len; bnxt_set_ring_params(bp); =20 if (netif_running(dev)) @@ -5577,7 +5595,8 @@ const struct ethtool_ops bnxt_ethtool_ops =3D { ETHTOOL_COALESCE_STATS_BLOCK_USECS | ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_CQE, - .supported_ring_params =3D ETHTOOL_RING_USE_TCP_DATA_SPLIT | + .supported_ring_params =3D ETHTOOL_RING_USE_RX_BUF_LEN | + ETHTOOL_RING_USE_TCP_DATA_SPLIT | ETHTOOL_RING_USE_HDS_THRS, .get_link_ksettings =3D bnxt_get_link_ksettings, .set_link_ksettings =3D bnxt_set_link_ksettings, --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 40C753112C0 for ; Mon, 13 Oct 2025 14:53:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367226; cv=none; b=lb3P7ehTH+hJM9i37eAG0/AGsqIkYM/SJVQdf1gX22ctFJIONLTK0JAs2Ieg5thf1ZeA71IvyxwA8vi/UNu6Rqb6ePbXdm/UTwKS0vJzjq4jFYnaKZzVWTjn5ZHpRkfUxXuIdzBkZV/2nTjJVXCvl+Kw3Y1fQztC5nTUzBq5BEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367226; c=relaxed/simple; bh=E8WoJuBOO+qk8Q5hqtoULQ0PwkM4ocuACiUdIi2N6so=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OaDRFUSM7Ad62tG4h7s8FTAJqtgZEZCZa6mii2oWbjXnAcIvNkFcwklWSFAnMy27vD5QcNnb87/oZfj5nX545aiSU+x+/2yIkJsS5qquzdowzGw1DsTeu6Ae0L7A1/h50pywSoi5mUTkH0ogXWeRj1sDa2nZ3oJwyWL9+VLW1FY= 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=hiNG2nGf; arc=none smtp.client-ip=209.85.221.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hiNG2nGf" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3fc36b99e92so3810151f8f.0 for ; Mon, 13 Oct 2025 07:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367222; x=1760972022; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bxISOHK0sfOtFB4YWzm4iWfmIyELFZH9BHOLFWLiapg=; b=hiNG2nGfIOADsE6zv+QCnp6aPiVdaHd6GuPVT8fBfgs6P1Ceh+IqHgXZoWTBEFkZkH a4/69ZYAqcwdOPfap5Ut7XpJFErQFPsha4AGKWF5CmCtwz9FRbmXx5cvA6Y5bsZ8YBSx QPmSYVGVKPwHebxDSKmjK7zoRoN9d49lh2s9O3YaLp3r2oUUA9B3/oibXpoSViZj/3sW iEDiycF9RUBsiUZRWqg9buB/7ynAbXx3TphsvpMV0RUOsm+xsoIrxOrWdyl1xSxOrTvS we8LnQeyHQqLvwGdlj+bDLwgtQDUBhSLTC2Ce/Hnwu3qUGVALaWi9veZy3A37I7avq16 V27A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367222; x=1760972022; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bxISOHK0sfOtFB4YWzm4iWfmIyELFZH9BHOLFWLiapg=; b=IK2Jm66SRFW7zW/azcu7SSjSe0dhCTDfy1o9Yzh4boocjS3QXw9boc8mYHKXeJgOAu 9/o3+2TS+Yow+D8Opg5rHpp3q+yoVIIVhwm5t35V8dQ/JSNrfiFoePSbUtGxocSyzwoF 14d9/oSyi3W8jkS/GKW+ZB+MCr/mlkuW807tj+o4DsJeYY56Xy4SaimBJvcNe2FBd2q5 03ghxUC3UZaaoyJMUR3CYMLrHTWr+OeZy3XNLV2wtkNyrZLXolnTV2gNxNgGHrFikSxC G+x674rEJDp3Sf74sffuHeePdfyL+fks+9WT+1bB+8A8ilZPl+PuebkTnMW6kHjQZe6h nH/g== X-Forwarded-Encrypted: i=1; AJvYcCXhvf7BKs30jSRoVSir8W0jb9m+O5rpWDYVu/SJCF05yCoN/vV/Uw2eKpCkt9kmlEdgecxauhQaUIdklcM=@vger.kernel.org X-Gm-Message-State: AOJu0YyXuNwlAQX57wajXeWLRh8G0uxgMzxzPIWq9jO5AdeqlseAQ72U XijPfD1kkOeKDhQTC3kg0XlJfqVdaOnj2wpuKXsfRz/jvrx0X9yYgJK2 X-Gm-Gg: ASbGncuApwFtHf0JzqJ9cNGeqP1DIrAbapb906LHetscZw11uFjFAH2bu/8N3kWU6Nz 2YMXtU4qgkWnIIQrziWDcaDHwhH8pSpOSOWLZ+XBNxH7mXh9yDGPlzTvWoY5zp6tuuppFPJvLYF 09bXSChV7wruHNc9bofbViCRWVokUMf1dHUkf84d8R0NImTZ5FlctySOAlIURy9+pOB2TiR2DrC HgdpHq+/I0kygvG6YcMNBQPkzN1ZB+cDafjxZYnQJDn9ADIcxxDWtJjJ2DsE3NjfCWdUWAMydMs Kxrcqklgz9p9l+wsDPlvgAVRVDgx0BD2xR/1qUWesjOgApGm+tJBOH9peWVnKaccLQKwiGGcaOF WM3pEt/Pd/iMrsMjJgXrDGFBeqFz0P9CLmLY= X-Google-Smtp-Source: AGHT+IEzTwZdHTurtXtAEUjWNLzW7QhST7sltiH1Xg9KXxn65EDy7cgKglM2V8lRa6iGebxt7MLQeg== X-Received: by 2002:a05:6000:609:b0:3ec:db87:ff53 with SMTP id ffacd0b85a97d-42666aa67demr15479799f8f.12.1760367222156; Mon, 13 Oct 2025 07:53:42 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:41 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 11/24] net: move netdev_config manipulation to dedicated helpers Date: Mon, 13 Oct 2025 15:54:13 +0100 Message-ID: <247a04527829dcc9e7a6e580b3cd5fe4745c9e84.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski netdev_config manipulation will become slightly more complicated soon and we will need to call if from ethtool as well as queue API. Encapsulate the logic into helper functions. Signed-off-by: Jakub Kicinski Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- net/core/Makefile | 1 + net/core/dev.c | 7 ++----- net/core/dev.h | 5 +++++ net/core/netdev_config.c | 43 ++++++++++++++++++++++++++++++++++++++++ net/ethtool/netlink.c | 14 ++++++------- 5 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 net/core/netdev_config.c diff --git a/net/core/Makefile b/net/core/Makefile index 9ef2099c5426..9f1f08ff585f 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -21,6 +21,7 @@ obj-y +=3D net-sysfs.o obj-y +=3D hotdata.o obj-y +=3D netdev_rx_queue.o obj-y +=3D netdev_queues.o +obj-y +=3D netdev_config.o obj-$(CONFIG_PAGE_POOL) +=3D page_pool.o page_pool_user.o obj-$(CONFIG_PROC_FS) +=3D net-procfs.o obj-$(CONFIG_NET_PKTGEN) +=3D pktgen.o diff --git a/net/core/dev.c b/net/core/dev.c index a64cef2c537e..5f92425dfdbd 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11973,10 +11973,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_pri= v, const char *name, if (!dev->ethtool) goto free_all; =20 - dev->cfg =3D kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT); - if (!dev->cfg) + if (netdev_alloc_config(dev)) goto free_all; - dev->cfg_pending =3D dev->cfg; =20 dev->num_napi_configs =3D maxqs; napi_config_sz =3D array_size(maxqs, sizeof(*dev->napi_config)); @@ -12047,8 +12045,7 @@ void free_netdev(struct net_device *dev) return; } =20 - WARN_ON(dev->cfg !=3D dev->cfg_pending); - kfree(dev->cfg); + netdev_free_config(dev); kfree(dev->ethtool); netif_free_tx_queues(dev); netif_free_rx_queues(dev); diff --git a/net/core/dev.h b/net/core/dev.h index 900880e8b5b4..1ec0b836c652 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -92,6 +92,11 @@ extern struct rw_semaphore dev_addr_sem; extern struct list_head net_todo_list; void netdev_run_todo(void); =20 +int netdev_alloc_config(struct net_device *dev); +void __netdev_free_config(struct netdev_config *cfg); +void netdev_free_config(struct net_device *dev); +int netdev_reconfig_start(struct net_device *dev); + /* netdev management, shared between various uAPI entry points */ struct netdev_name_node { struct hlist_node hlist; diff --git a/net/core/netdev_config.c b/net/core/netdev_config.c new file mode 100644 index 000000000000..270b7f10a192 --- /dev/null +++ b/net/core/netdev_config.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include + +#include "dev.h" + +int netdev_alloc_config(struct net_device *dev) +{ + struct netdev_config *cfg; + + cfg =3D kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT); + if (!cfg) + return -ENOMEM; + + dev->cfg =3D cfg; + dev->cfg_pending =3D cfg; + return 0; +} + +void __netdev_free_config(struct netdev_config *cfg) +{ + kfree(cfg); +} + +void netdev_free_config(struct net_device *dev) +{ + WARN_ON(dev->cfg !=3D dev->cfg_pending); + __netdev_free_config(dev->cfg); +} + +int netdev_reconfig_start(struct net_device *dev) +{ + struct netdev_config *cfg; + + WARN_ON(dev->cfg !=3D dev->cfg_pending); + cfg =3D kmemdup(dev->cfg, sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT); + if (!cfg) + return -ENOMEM; + + dev->cfg_pending =3D cfg; + return 0; +} diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 2f813f25f07e..d376d3043177 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -6,6 +6,7 @@ #include #include #include +#include "../core/dev.h" #include "netlink.h" #include "module_fw.h" =20 @@ -906,12 +907,9 @@ static int ethnl_default_set_doit(struct sk_buff *skb,= struct genl_info *info) =20 rtnl_lock(); netdev_lock_ops(dev); - dev->cfg_pending =3D kmemdup(dev->cfg, sizeof(*dev->cfg), - GFP_KERNEL_ACCOUNT); - if (!dev->cfg_pending) { - ret =3D -ENOMEM; - goto out_tie_cfg; - } + ret =3D netdev_reconfig_start(dev); + if (ret) + goto out_unlock; =20 ret =3D ethnl_ops_begin(dev); if (ret < 0) @@ -930,9 +928,9 @@ static int ethnl_default_set_doit(struct sk_buff *skb, = struct genl_info *info) out_ops: ethnl_ops_complete(dev); out_free_cfg: - kfree(dev->cfg_pending); -out_tie_cfg: + __netdev_free_config(dev->cfg_pending); dev->cfg_pending =3D dev->cfg; +out_unlock: netdev_unlock_ops(dev); rtnl_unlock(); out_dev: --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 0AB0B3115BD for ; Mon, 13 Oct 2025 14:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367229; cv=none; b=I6wleZN09FQMIKPRqVlFUlEHFVWddgwy8dR9+JmNbtZIiZG+w0y/hO0HfFyMX67mAGgdPB+4i0m2+17EvVXjrSc5UQYPLcqgVRt1sjyYYNL/4dImb/z7MeHinqjuPyc2rP3ekRAtFvQ15D3206yJl9YJv75jGweS9hdIgLaJAww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367229; c=relaxed/simple; bh=WjwEwnVgKDmKGf0mOT4U63jLGaTZvrYbarJ0ZWgPq60=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E95BcuH/d9+tM0A/5b6c5aqwT2rg07mZ+FMCFTbhxwX5YD2wAV9gZ/CxBfQHjRpxIjMHJnYFbQv1deCBQleR5n9nd8rMzli2x+TL4jsmbx901LgCczPKImn9Lb/VRq77Tf2OwSJwE6Px6HVCZToNk+LKcizqm8P2rESfpZJcuKY= 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=ntsjXgqp; arc=none smtp.client-ip=209.85.128.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ntsjXgqp" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-46fcf9f63b6so2510015e9.2 for ; Mon, 13 Oct 2025 07:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367224; x=1760972024; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F0ayzy+SCb9hz0mwDQVd4KG2A98cKImsuCLT5S++72Y=; b=ntsjXgqpoNwGQJFY5YTI4/Sg83v1z6IxVjIk9Ia8/LPwR54LdE2pXA8Izvo+h7sNRy glO/mdiOExwTPNkfzNwNp0FHe3Y+AGmN7+XFES9QfAIFxaq6fQs4lt9Cq9+QGhBpNQ26 oM6voQa1PSEzzHr5FszUTVh3Z+Q5evgmgXoj9OP+xpYStpIJ8uOfVQifZvBrdQ6NffnD YYIeob9os1Ds+51ZEoIZafpqhXfzBc2Whp4J0PK49IUz2RcO5wT9GirzL1rqPpuWiEMC jtJO8F7DytaTmx4tsbMHbEU3+OcDAQKIbsofYdp2qEiXFHIuu70cLPyNBQbnSZHDyOle h+Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367224; x=1760972024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F0ayzy+SCb9hz0mwDQVd4KG2A98cKImsuCLT5S++72Y=; b=R9FmpbaJsFBfKHUTwTp84hZ3y8i6GZeRlQ2Iv5JrbQ7/iG2WDZHfSPbvB+DhQ6SOfd 6Tyl853DRW2NCI5tU+U8fCcNO2Q6BX7z9QVpmlFWJ9r27Xu/V7mPXhzdETCtizi1trhk pnkGvnQ/yA4BGcfEZ0S1xzV16NxTX2sxC/u+kYig5fQYxEjkLS8RMYtoH/+GhizUz/PN UM4C8R34rP4lkaXrCdIST+wHA335U46rorF0uUEi9QVGHVCZHSiVm7RyMirorMN5vKPc hAGPwcNTaJGfUSDoSCMFii013yNzhXMm5Rl76H74N/QGwRHoiMxHbzeamBLJsngGmMi+ ufbg== X-Forwarded-Encrypted: i=1; AJvYcCUVbnL1W8567yRD6cmCYsx8mpcxiV5ZLd/Z+/pvV99ZHBflJLS9DDmV3rEF/1jOX0orPkWjdTnqtET2GNc=@vger.kernel.org X-Gm-Message-State: AOJu0Yzoz2LivN2bwTqezPih3q3p4XEGvTIYfDhuskarKHJnbcvZLT3L BB/eDL6EtVP7PxXd6Q+JzUMwQ631vh9+BfEB+zzsFXvs+FJg2euuDLZ6 X-Gm-Gg: ASbGncsXM1wSeJrmIf6UrHfTPytc30d2EuMQNlxwE3atJC9TE114wIJvugQuA4k1U1U MzDWCAc5+pJbyS8UzprBb3itYTYu0lpEkCkf/Bw9w34SRvDgiSSHKJJ3/dhGSpFt4L/vIn0iWoC q2Q4pBCALbIze7Wre4moYUvk4LvOFTaok9yyEbrMY4KuLHPDOhp7Sz03emPLOXi6siF/VrirPV6 RhCC2cWro9WCcMoZgupHPeVUcsOcx9KRqLh5KFRuZ+qvqyKTXz1Fx1//kggIMHgV6IDsO/r0BDq bDIHqBef+k4fZTTdzj4oGv1ofrwPV96PMJ/VAKii1J9zOlrD7sqFTTpCSFfwBrkNO40DZP4eejh 84rg+V58VuXMSimzcI0JenyLR X-Google-Smtp-Source: AGHT+IGrRvDbIKp6K6AMCw6Zdmo39z5Z8/jDdtEHlFD69lSVWOS65RcIgP2PsQY/WwDW9hF6vRZo3w== X-Received: by 2002:a05:600c:4687:b0:46e:37a4:d003 with SMTP id 5b1f17b1804b1-46fae33dbbdmr135008035e9.8.1760367224018; Mon, 13 Oct 2025 07:53:44 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:43 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 12/24] net: reduce indent of struct netdev_queue_mgmt_ops members Date: Mon, 13 Oct 2025 15:54:14 +0100 Message-ID: <707b02494c7748beb1e535eb82c77b5be8002492.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Trivial change, reduce the indent. I think the original is copied from real NDOs. It's unnecessarily deep, makes passing struct args problematic. Signed-off-by: Jakub Kicinski Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- include/net/netdev_queues.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h index 31559f2711de..b7c9895cd4b2 100644 --- a/include/net/netdev_queues.h +++ b/include/net/netdev_queues.h @@ -155,20 +155,20 @@ void netdev_stat_queue_sum(struct net_device *netdev, * be called for an interface which is open. */ struct netdev_queue_mgmt_ops { - size_t ndo_queue_mem_size; - int (*ndo_queue_mem_alloc)(struct net_device *dev, - void *per_queue_mem, - int idx); - void (*ndo_queue_mem_free)(struct net_device *dev, - void *per_queue_mem); - int (*ndo_queue_start)(struct net_device *dev, - void *per_queue_mem, - int idx); - int (*ndo_queue_stop)(struct net_device *dev, - void *per_queue_mem, - int idx); - struct device * (*ndo_queue_get_dma_dev)(struct net_device *dev, - int idx); + size_t ndo_queue_mem_size; + int (*ndo_queue_mem_alloc)(struct net_device *dev, + void *per_queue_mem, + int idx); + void (*ndo_queue_mem_free)(struct net_device *dev, + void *per_queue_mem); + int (*ndo_queue_start)(struct net_device *dev, + void *per_queue_mem, + int idx); + int (*ndo_queue_stop)(struct net_device *dev, + void *per_queue_mem, + int idx); + struct device * (*ndo_queue_get_dma_dev)(struct net_device *dev, + int idx); }; =20 bool netif_rxq_has_unreadable_mp(struct net_device *dev, int idx); --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 DB46130FC17 for ; Mon, 13 Oct 2025 14:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367230; cv=none; b=FWdL6EV5fBIZUq8hOA5rC+ZCbtqNOCBiVJuiqRCPJI/l06Z/czw2UcpWRoZcEtLn+Qtc/B0VV+GxO6ge64oBER/XdBubcBunZBS5Q3CDIV7YB9EkoA61cC/ZkR1miK/wR3xYk0bJstLrqyMaovC7G88044bbVtCFcBNYLSun/5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367230; c=relaxed/simple; bh=ohf51NQmqI5eH29ikGFIJZZTwuakm4SgvzB8g1tVGig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=njZm8OvSXnkvAfz8toENZFdaIJffI3mNfNsYd5jIl1rZBKFYtWMp1AxwYV0CBYNziw/KIFbq5Ws/K/fAk65s96b9iatmM0wxjrBLZbFzKto5i8W42KyYKWo4FD8RoWSdZ61bwH5/FC0OendufkSw6177rFB5hwDR12dgcm3PMHM= 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=JbVzEuG9; arc=none smtp.client-ip=209.85.221.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JbVzEuG9" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3ee12332f3dso2590788f8f.2 for ; Mon, 13 Oct 2025 07:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367226; x=1760972026; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6QA5Dn0k/m/ZYqLaKjYYKC36p5eoeH9cvfqouoo8+4U=; b=JbVzEuG9DZiYOQNPetls9vOvGeUig5GUF7nbxaOV0yDyJpKHO5BxiX89j8ESSdTUc/ FeHj7aS3VKF2UhlFlLYRXIFmBkoBEcUuGJGbF9L+8QdAHYlQhn4AUIu7s85W4hVW/1/s UsnJwj4+P0J/4mFA/HTVLYmOMEyEjtrDz083LTXAtL8YYrC5kiAKtFripSkUl6jQ3cOA Vgusv8TufH82u3zDKjkAQryFhuVbBejFZ1Va0UIqV8ObGDoikoROkI4bWNKZM8tZsUdr 9cHRztzFjgPc1RzYm7NxWRQgtBKkqBMlyCKZgwlMSjroTIyWG3nw/PrhXjpsocDDivZV YJeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367226; x=1760972026; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6QA5Dn0k/m/ZYqLaKjYYKC36p5eoeH9cvfqouoo8+4U=; b=UP9+HXi2BCvzv6OeWBLHSo1exnoNUR1rP9sFrm5yCjAOZ8YuxB0NRvm3LPjpYFUZqs X0XO7dC7VrAK2Yphx738cPzTUM56u6d5rprZM8yLGSAtO7xIzmJxySGLRTNGRyiu2Y05 MewP/UfcX9CCi/ju1B0ZvtREqH0bgrKugnGdXnhcoM1ygSYuMyFSgq3wMqhKarTbcmwg 2Aa3JCSNJlMlxs4tO6GNFWULotK7LUYUZnjV+mXPh0UQVmkSrpEGs6mlMLEaApu7D6wm lrojfymMR87TFN8IW3yZYjsWtvjgrjwyuQ6pN15rJQotzkIGGF8j1vCy6cT6DyjGgsVW ZlYg== X-Forwarded-Encrypted: i=1; AJvYcCXqcFJwMa8JHKM4fPIGXgQX5zrM2uxMlg1HenIanVVEUzaIY1KPgwwtR9AoiLi47m9Pys4Jth9Zp6urd18=@vger.kernel.org X-Gm-Message-State: AOJu0YwT5ci6skCco4fK72FzyADWUTUk+IEu1yVSUEu0L0Vzhlrv8W0Y gU4o5ENAcZ5x3neR2Hq4+Xi6zxFKZ17Kpjn5luFC3TxrhJR0Yph4+TMY X-Gm-Gg: ASbGncvud9jdCrSIMcuWDdl4hipxowGr4vffr+ieu2huykvLxoI0xKjb4pVwcPc1pvB SL7vzc0mFHEmcmitNfkUNC96gFLIPANDHx/azyV842psI4ZBkwbITODqDUNNmoPas4kBR/TqGH2 cVzBDXjuYaMQHQlMZKiEUDHLjlC9mo1ZvW1Pgw3PQsWObqVAOF3LRxHe2Q/GnzbxhK6W+Uab+kW 8MVmXv2EAW5EW9iEcHtZzU5oomG7VajUC4fUI6mHjuZNrYrg5QUvIPHjxR7IKRhJMMHu8cOBV+k Eu66t5OQzF4OEcxTCGX/Vk7q200n3S8CdTZk2xtual0OhZtewUM81OoQlH0dfTOSaaf/69jJdC9 dP9X4JLcPoqpJEoW+RDPBC+195uA2+cAoTzswR3Pq/CFthQ== X-Google-Smtp-Source: AGHT+IFeJ4IOoAxLgq+L5wlOOmHh/QBv7jI6C0T8Xf09WrG0JjgDMOfYa69q1eQ3ZU8BVd7FiZ1O0w== X-Received: by 2002:a05:6000:4283:b0:3e8:b4cb:c3dc with SMTP id ffacd0b85a97d-4266e7ce955mr14632061f8f.3.1760367225907; Mon, 13 Oct 2025 07:53:45 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:45 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 13/24] net: allocate per-queue config structs and pass them thru the queue API Date: Mon, 13 Oct 2025 15:54:15 +0100 Message-ID: <4de6f631d23a5f3019bc39922755d72c4cf50833.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Create an array of config structs to store per-queue config. Pass these structs in the queue API. Drivers can also retrieve the config for a single queue calling netdev_queue_config() directly. Signed-off-by: Jakub Kicinski [pavel: patch up mlx callbacks with unused qcfg] Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++- drivers/net/ethernet/google/gve/gve_main.c | 9 ++- .../net/ethernet/mellanox/mlx5/core/en_main.c | 10 ++-- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 8 ++- drivers/net/netdevsim/netdev.c | 6 +- include/net/netdev_queues.h | 19 ++++++ net/core/dev.h | 3 + net/core/netdev_config.c | 58 +++++++++++++++++++ net/core/netdev_rx_queue.c | 11 +++- 9 files changed, 116 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 5c57b2a5c51c..7d7a9d5bc566 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -15882,7 +15882,9 @@ static const struct netdev_stat_ops bnxt_stat_ops = =3D { .get_base_stats =3D bnxt_get_base_stats, }; =20 -static int bnxt_queue_mem_alloc(struct net_device *dev, void *qmem, int id= x) +static int bnxt_queue_mem_alloc(struct net_device *dev, + struct netdev_queue_config *qcfg, + void *qmem, int idx) { struct bnxt_rx_ring_info *rxr, *clone; struct bnxt *bp =3D netdev_priv(dev); @@ -16048,7 +16050,9 @@ static void bnxt_copy_rx_ring(struct bnxt *bp, dst->rx_agg_bmap =3D src->rx_agg_bmap; } =20 -static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx) +static int bnxt_queue_start(struct net_device *dev, + struct netdev_queue_config *qcfg, + void *qmem, int idx) { struct bnxt *bp =3D netdev_priv(dev); struct bnxt_rx_ring_info *rxr, *clone; diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ether= net/google/gve/gve_main.c index 1be1b1ef31ee..a49c28f3667b 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c @@ -2580,8 +2580,9 @@ static void gve_rx_queue_mem_free(struct net_device *= dev, void *per_q_mem) gve_rx_free_ring_dqo(priv, gve_per_q_mem, &cfg); } =20 -static int gve_rx_queue_mem_alloc(struct net_device *dev, void *per_q_mem, - int idx) +static int gve_rx_queue_mem_alloc(struct net_device *dev, + struct netdev_queue_config *qcfg, + void *per_q_mem, int idx) { struct gve_priv *priv =3D netdev_priv(dev); struct gve_rx_alloc_rings_cfg cfg =3D {0}; @@ -2602,7 +2603,9 @@ static int gve_rx_queue_mem_alloc(struct net_device *= dev, void *per_q_mem, return err; } =20 -static int gve_rx_queue_start(struct net_device *dev, void *per_q_mem, int= idx) +static int gve_rx_queue_start(struct net_device *dev, + struct netdev_queue_config *qcfg, + void *per_q_mem, int idx) { struct gve_priv *priv =3D netdev_priv(dev); struct gve_rx_ring *gve_per_q_mem; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/ne= t/ethernet/mellanox/mlx5/core/en_main.c index a56825921c23..75757abeb3dd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5562,8 +5562,9 @@ struct mlx5_qmgmt_data { struct mlx5e_channel_param cparam; }; =20 -static int mlx5e_queue_mem_alloc(struct net_device *dev, void *newq, - int queue_index) +static int mlx5e_queue_mem_alloc(struct net_device *dev, + struct netdev_queue_config *qcfg, + void *newq, int queue_index) { struct mlx5_qmgmt_data *new =3D (struct mlx5_qmgmt_data *)newq; struct mlx5e_priv *priv =3D netdev_priv(dev); @@ -5624,8 +5625,9 @@ static int mlx5e_queue_stop(struct net_device *dev, v= oid *oldq, int queue_index) return 0; } =20 -static int mlx5e_queue_start(struct net_device *dev, void *newq, - int queue_index) +static int mlx5e_queue_start(struct net_device *dev, + struct netdev_queue_config *qcfg, + void *newq, int queue_index) { struct mlx5_qmgmt_data *new =3D (struct mlx5_qmgmt_data *)newq; struct mlx5e_priv *priv =3D netdev_priv(dev); diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/eth= ernet/meta/fbnic/fbnic_txrx.c index b1e8ce89870f..8854c496f1dd 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c @@ -2789,7 +2789,9 @@ void fbnic_napi_depletion_check(struct net_device *ne= tdev) fbnic_wrfl(fbd); } =20 -static int fbnic_queue_mem_alloc(struct net_device *dev, void *qmem, int i= dx) +static int fbnic_queue_mem_alloc(struct net_device *dev, + struct netdev_queue_config *qcfg, + void *qmem, int idx) { struct fbnic_net *fbn =3D netdev_priv(dev); const struct fbnic_q_triad *real; @@ -2841,7 +2843,9 @@ static void __fbnic_nv_restart(struct fbnic_net *fbn, netif_wake_subqueue(fbn->netdev, nv->qt[i].sub0.q_idx); } =20 -static int fbnic_queue_start(struct net_device *dev, void *qmem, int idx) +static int fbnic_queue_start(struct net_device *dev, + struct netdev_queue_config *qcfg, + void *qmem, int idx) { struct fbnic_net *fbn =3D netdev_priv(dev); struct fbnic_napi_vector *nv; diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index ebc3833e95b4..032ef17dcf61 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -750,7 +750,8 @@ struct nsim_queue_mem { }; =20 static int -nsim_queue_mem_alloc(struct net_device *dev, void *per_queue_mem, int idx) +nsim_queue_mem_alloc(struct net_device *dev, struct netdev_queue_config *q= cfg, + void *per_queue_mem, int idx) { struct nsim_queue_mem *qmem =3D per_queue_mem; struct netdevsim *ns =3D netdev_priv(dev); @@ -799,7 +800,8 @@ static void nsim_queue_mem_free(struct net_device *dev,= void *per_queue_mem) } =20 static int -nsim_queue_start(struct net_device *dev, void *per_queue_mem, int idx) +nsim_queue_start(struct net_device *dev, struct netdev_queue_config *qcfg, + void *per_queue_mem, int idx) { struct nsim_queue_mem *qmem =3D per_queue_mem; struct netdevsim *ns =3D netdev_priv(dev); diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h index b7c9895cd4b2..a7b325307029 100644 --- a/include/net/netdev_queues.h +++ b/include/net/netdev_queues.h @@ -32,6 +32,13 @@ struct netdev_config { /** @hds_config: HDS enabled (ETHTOOL_A_RINGS_TCP_DATA_SPLIT). */ u8 hds_config; + + /** @qcfg: per-queue configuration */ + struct netdev_queue_config *qcfg; +}; + +/* Same semantics as fields in struct netdev_config */ +struct netdev_queue_config { }; =20 /* See the netdev.yaml spec for definition of each statistic */ @@ -136,6 +143,10 @@ void netdev_stat_queue_sum(struct net_device *netdev, * * @ndo_queue_mem_size: Size of the struct that describes a queue's memory. * + * @ndo_queue_cfg_defaults: (Optional) Populate queue config struct with + * defaults. Queue config structs are passed to this + * helper before the user-requested settings are applied. + * * @ndo_queue_mem_alloc: Allocate memory for an RX queue at the specified = index. * The new memory is written at the specified address. * @@ -156,12 +167,17 @@ void netdev_stat_queue_sum(struct net_device *netdev, */ struct netdev_queue_mgmt_ops { size_t ndo_queue_mem_size; + void (*ndo_queue_cfg_defaults)(struct net_device *dev, + int idx, + struct netdev_queue_config *qcfg); int (*ndo_queue_mem_alloc)(struct net_device *dev, + struct netdev_queue_config *qcfg, void *per_queue_mem, int idx); void (*ndo_queue_mem_free)(struct net_device *dev, void *per_queue_mem); int (*ndo_queue_start)(struct net_device *dev, + struct netdev_queue_config *qcfg, void *per_queue_mem, int idx); int (*ndo_queue_stop)(struct net_device *dev, @@ -173,6 +189,9 @@ struct netdev_queue_mgmt_ops { =20 bool netif_rxq_has_unreadable_mp(struct net_device *dev, int idx); =20 +void netdev_queue_config(struct net_device *dev, int rxq, + struct netdev_queue_config *qcfg); + /** * DOC: Lockless queue stopping / waking helpers. * diff --git a/net/core/dev.h b/net/core/dev.h index 1ec0b836c652..a2d6a181b9b0 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -9,6 +9,7 @@ #include =20 struct net; +struct netdev_queue_config; struct netlink_ext_ack; struct cpumask; =20 @@ -96,6 +97,8 @@ int netdev_alloc_config(struct net_device *dev); void __netdev_free_config(struct netdev_config *cfg); void netdev_free_config(struct net_device *dev); int netdev_reconfig_start(struct net_device *dev); +void __netdev_queue_config(struct net_device *dev, int rxq, + struct netdev_queue_config *qcfg, bool pending); =20 /* netdev management, shared between various uAPI entry points */ struct netdev_name_node { diff --git a/net/core/netdev_config.c b/net/core/netdev_config.c index 270b7f10a192..bad2d53522f0 100644 --- a/net/core/netdev_config.c +++ b/net/core/netdev_config.c @@ -8,18 +8,29 @@ int netdev_alloc_config(struct net_device *dev) { struct netdev_config *cfg; + unsigned int maxqs; =20 cfg =3D kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT); if (!cfg) return -ENOMEM; =20 + maxqs =3D max(dev->num_rx_queues, dev->num_tx_queues); + cfg->qcfg =3D kcalloc(maxqs, sizeof(*cfg->qcfg), GFP_KERNEL_ACCOUNT); + if (!cfg->qcfg) + goto err_free_cfg; + dev->cfg =3D cfg; dev->cfg_pending =3D cfg; return 0; + +err_free_cfg: + kfree(cfg); + return -ENOMEM; } =20 void __netdev_free_config(struct netdev_config *cfg) { + kfree(cfg->qcfg); kfree(cfg); } =20 @@ -32,12 +43,59 @@ void netdev_free_config(struct net_device *dev) int netdev_reconfig_start(struct net_device *dev) { struct netdev_config *cfg; + unsigned int maxqs; =20 WARN_ON(dev->cfg !=3D dev->cfg_pending); cfg =3D kmemdup(dev->cfg, sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT); if (!cfg) return -ENOMEM; =20 + maxqs =3D max(dev->num_rx_queues, dev->num_tx_queues); + cfg->qcfg =3D kmemdup_array(dev->cfg->qcfg, maxqs, sizeof(*cfg->qcfg), + GFP_KERNEL_ACCOUNT); + if (!cfg->qcfg) + goto err_free_cfg; + dev->cfg_pending =3D cfg; return 0; + +err_free_cfg: + kfree(cfg); + return -ENOMEM; +} + +void __netdev_queue_config(struct net_device *dev, int rxq, + struct netdev_queue_config *qcfg, bool pending) +{ + memset(qcfg, 0, sizeof(*qcfg)); + + /* Get defaults from the driver, in case user config not set */ + if (dev->queue_mgmt_ops->ndo_queue_cfg_defaults) + dev->queue_mgmt_ops->ndo_queue_cfg_defaults(dev, rxq, qcfg); +} + +/** + * netdev_queue_config() - get configuration for a given queue + * @dev: net_device instance + * @rxq: index of the queue of interest + * @qcfg: queue configuration struct (output) + * + * Render the configuration for a given queue. This helper should be used + * by drivers which support queue configuration to retrieve config for + * a particular queue. + * + * @qcfg is an output parameter and is always fully initialized by this + * function. Some values may not be set by the user, drivers may either + * deal with the "unset" values in @qcfg, or provide the callback + * to populate defaults in queue_management_ops. + * + * Note that this helper returns pending config, as it is expected that + * "old" queues are retained until config is successful so they can + * be restored directly without asking for the config. + */ +void netdev_queue_config(struct net_device *dev, int rxq, + struct netdev_queue_config *qcfg) +{ + __netdev_queue_config(dev, rxq, qcfg, true); } +EXPORT_SYMBOL(netdev_queue_config); diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c index c7d9341b7630..f6a07fccebd1 100644 --- a/net/core/netdev_rx_queue.c +++ b/net/core/netdev_rx_queue.c @@ -7,6 +7,7 @@ #include #include =20 +#include "dev.h" #include "page_pool_priv.h" =20 /* See also page_pool_is_unreadable() */ @@ -22,6 +23,7 @@ int netdev_rx_queue_restart(struct net_device *dev, unsig= ned int rxq_idx) { struct netdev_rx_queue *rxq =3D __netif_get_rx_queue(dev, rxq_idx); const struct netdev_queue_mgmt_ops *qops =3D dev->queue_mgmt_ops; + struct netdev_queue_config qcfg; void *new_mem, *old_mem; int err; =20 @@ -41,7 +43,9 @@ int netdev_rx_queue_restart(struct net_device *dev, unsig= ned int rxq_idx) goto err_free_new_mem; } =20 - err =3D qops->ndo_queue_mem_alloc(dev, new_mem, rxq_idx); + netdev_queue_config(dev, rxq_idx, &qcfg); + + err =3D qops->ndo_queue_mem_alloc(dev, &qcfg, new_mem, rxq_idx); if (err) goto err_free_old_mem; =20 @@ -54,7 +58,7 @@ int netdev_rx_queue_restart(struct net_device *dev, unsig= ned int rxq_idx) if (err) goto err_free_new_queue_mem; =20 - err =3D qops->ndo_queue_start(dev, new_mem, rxq_idx); + err =3D qops->ndo_queue_start(dev, &qcfg, new_mem, rxq_idx); if (err) goto err_start_queue; } else { @@ -69,6 +73,7 @@ int netdev_rx_queue_restart(struct net_device *dev, unsig= ned int rxq_idx) return 0; =20 err_start_queue: + __netdev_queue_config(dev, rxq_idx, &qcfg, false); /* Restarting the queue with old_mem should be successful as we haven't * changed any of the queue configuration, and there is not much we can * do to recover from a failure here. @@ -76,7 +81,7 @@ int netdev_rx_queue_restart(struct net_device *dev, unsig= ned int rxq_idx) * WARN if we fail to recover the old rx queue, and at least free * old_mem so we don't also leak that. */ - if (qops->ndo_queue_start(dev, old_mem, rxq_idx)) { + if (qops->ndo_queue_start(dev, &qcfg, old_mem, rxq_idx)) { WARN(1, "Failed to restart old queue in error path. RX queue %d may be unhe= althy.", rxq_idx); --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 E9ABE3126B7 for ; Mon, 13 Oct 2025 14:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367232; cv=none; b=LwmI9lGBuJOMsREJLwAYdtVeuIFtnlHb0D1IDNumeTHBbcABkrmNaIQziH5kImC/cnRsofioO+m8kS2HmQMMkx02uV8AWcGR3FDNG+oUwdS133Nm50h0eFHqHdwkhAM4l+lI2UqhrwU+xHYWyGd86I4h+pai5xtZirXW7g868Ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367232; c=relaxed/simple; bh=D68sIcGcW8AD97DUUABnw+4SAHYdP99w8kG7MJxPpuU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PQOlI5QTC44lIRo102rzNnbLnfvq+qCwGN50ppSv4lKvFnOgl/1j824A/G3Byyl3WwbbEvP0GY10Wh7k6jMbEyE3e2hDdz3GHIX4eAM6TguHWGiKaIha1GLsdNMN0786FqZHXpXz6Xeb0sVDv6YHcXuTlAEHtzvWNEHvcLKdz24= 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=fwgEaukU; arc=none smtp.client-ip=209.85.128.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fwgEaukU" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-46b303f755aso37499395e9.1 for ; Mon, 13 Oct 2025 07:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367228; x=1760972028; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ApFnEwRpSxW12wS5COVxMxaB14LXZ+AG99lB5fOtbBM=; b=fwgEaukUjhYVnmQ8AVW6BNlVQE0cMo3BWtp7IVfC1O9B0iLe1lhk8FxlPVq1fTRKyb pBz4705SNJ6SLjEATAjDzJVeK4rsXJcyRUwRkyQ9F0h2mV/D8f+uBF/vNIMLlOu9LK3A alb0iAvwxGsR43s6gCBb6VGXijw46omDMwcUd7DzijeTnXsWuAnI2Rc6KsPEmxvhjgV4 xK40mJjVCKZEXies9kmVueGSl0BcuIArtqE429PstvO2mFo7/HdoYdNJEZFi4aDJC3wC 0yXeBoiQxfhgRE8I3sroNOFrYTfjIa6k/VY/L8xbiCb6hEUgapWQc7FQDuj3CJP2XO+e 3Glw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367228; x=1760972028; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ApFnEwRpSxW12wS5COVxMxaB14LXZ+AG99lB5fOtbBM=; b=WuIPRY86CRvBiDwkUWIHS+qZHTrQN2CyR1RDF7tCzf/YN4KdbPWTDjnHANNLop3hmo 4mJeWwU81btbzedWnIkPAcM8PFNEVPp3cwW/dXq5JISof1/hwp6NYTnioT/Ng4AhxsZ6 tSytjWVSVSKHQJ5jX5kvMmVpXk97yr25CL5V3/8ZgwlgTiYz4vYQQLGAKFbGgK150CqE rE/2Nadmq6mJxSMaGsgsBQNJkdc0lnRsdb2MhzOnhPhKn3UzuCnW4mYEg0AwU8QBVet+ 4xDH0qFvvRJSViPsMPZzfT7XazqXBcieEAGj8geFpDY4zp0wc8/OXVYXu24w8jic58hu D8zA== X-Forwarded-Encrypted: i=1; AJvYcCXNUK9A6PjrHuefQNlnxSL7dSdkDsBvZVyOQ1lVED21ptiGNW8vlihm+pUapsfXsDkY0w0SEnUbJdS1avA=@vger.kernel.org X-Gm-Message-State: AOJu0YxaAAN26MT0Sz7KPIHye0opNXQsY8jCqamGnH2uJRz9IcUb7HHD 7VCBVhHxgwx1Vs2w0MX4eVru0R3f2Kxnoeef3V8otrUXUpjTTpkJHhBy X-Gm-Gg: ASbGncti7SmoTN/2L9q/S1OX4HW6Y1IoV3ozrHo8xUcifvYXAV0QMeosxVLc7OA3q+z YqChi++aPcXfIya1rpXLDoH1yZeftS99zBvqJIV8cUiGRTS072OtCHs2VmDHbufNxexbSuLV+6U Q1MC7oEh645a4dSs87h1HCMBazfk4optCs1Sxb6OUFTtJAGMIxOdLMAqYulu1gh/xq8kcUj5NJU BBNUI1UwO40PmKKSA/M4tYVVK0XcJ6Y9R+mJsC2zEY3RWjvNpsBTj9F8HAe6fofLd+reaFNv+F6 t5uLNI4gRgtSK1RL1M00lPsqVAvFlmG+1pSC+aKaJiqozWDhKZ8Yk36v+chc6azbOA/A6bWnTbp r0EeQmKhhJti5kX4oKvi3YWfn X-Google-Smtp-Source: AGHT+IGhdCNMbexhcA+WKt1V3KL/FuPKgFmigZrXjQ1ZszoP38SE47hCNbYpQqpsjRmxatSSV4+luQ== X-Received: by 2002:a05:6000:4b1a:b0:426:d818:e46a with SMTP id ffacd0b85a97d-426d818e49fmr5836115f8f.60.1760367228006; Mon, 13 Oct 2025 07:53:48 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:47 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 14/24] net: pass extack to netdev_rx_queue_restart() Date: Mon, 13 Oct 2025 15:54:16 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Pass extack to netdev_rx_queue_restart(). Subsequent change will need it. Signed-off-by: Jakub Kicinski Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/netdevsim/netdev.c | 2 +- include/net/netdev_rx_queue.h | 3 ++- net/core/netdev_rx_queue.c | 7 ++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 7d7a9d5bc566..61e5c866d946 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -11570,7 +11570,7 @@ static void bnxt_irq_affinity_notify(struct irq_aff= inity_notify *notify, =20 netdev_lock(irq->bp->dev); if (netif_running(irq->bp->dev)) { - err =3D netdev_rx_queue_restart(irq->bp->dev, irq->ring_nr); + err =3D netdev_rx_queue_restart(irq->bp->dev, irq->ring_nr, NULL); if (err) netdev_err(irq->bp->dev, "RX queue restart failed: err=3D%d\n", err); diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 032ef17dcf61..649822af352e 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -886,7 +886,7 @@ nsim_qreset_write(struct file *file, const char __user = *data, } =20 ns->rq_reset_mode =3D mode; - ret =3D netdev_rx_queue_restart(ns->netdev, queue); + ret =3D netdev_rx_queue_restart(ns->netdev, queue, NULL); ns->rq_reset_mode =3D 0; if (ret) goto exit_unlock; diff --git a/include/net/netdev_rx_queue.h b/include/net/netdev_rx_queue.h index 8cdcd138b33f..a7def1f94823 100644 --- a/include/net/netdev_rx_queue.h +++ b/include/net/netdev_rx_queue.h @@ -56,6 +56,7 @@ get_netdev_rx_queue_index(struct netdev_rx_queue *queue) return index; } =20 -int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq); +int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq, + struct netlink_ext_ack *extack); =20 #endif diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c index f6a07fccebd1..16db850aafd7 100644 --- a/net/core/netdev_rx_queue.c +++ b/net/core/netdev_rx_queue.c @@ -19,7 +19,8 @@ bool netif_rxq_has_unreadable_mp(struct net_device *dev, = int idx) } EXPORT_SYMBOL(netif_rxq_has_unreadable_mp); =20 -int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq_idx) +int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq_idx, + struct netlink_ext_ack *extack) { struct netdev_rx_queue *rxq =3D __netif_get_rx_queue(dev, rxq_idx); const struct netdev_queue_mgmt_ops *qops =3D dev->queue_mgmt_ops; @@ -143,7 +144,7 @@ int __net_mp_open_rxq(struct net_device *dev, unsigned = int rxq_idx, #endif =20 rxq->mp_params =3D *p; - ret =3D netdev_rx_queue_restart(dev, rxq_idx); + ret =3D netdev_rx_queue_restart(dev, rxq_idx, extack); if (ret) { rxq->mp_params.mp_ops =3D NULL; rxq->mp_params.mp_priv =3D NULL; @@ -186,7 +187,7 @@ void __net_mp_close_rxq(struct net_device *dev, unsigne= d int ifq_idx, =20 rxq->mp_params.mp_ops =3D NULL; rxq->mp_params.mp_priv =3D NULL; - err =3D netdev_rx_queue_restart(dev, ifq_idx); + err =3D netdev_rx_queue_restart(dev, ifq_idx, NULL); WARN_ON(err && err !=3D -ENETDOWN); } =20 --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 A4CA13126D5 for ; Mon, 13 Oct 2025 14:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367234; cv=none; b=WywE33HZ1696P6o0b78HRW+9SA1tWlR2WgFP9PuFCw6I8YtFTL/4SPi8/SIR3z/Hl89+Rz9Ei9obuUPcQ/c/kg1Tbbb9KqdV6jNYDjySzHqrd0Xq4sbsZSX5/R4fWdkBiLK2PgxSpyWfCil9WOTA0eoKvAyivSkzV5YYqTdPTcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367234; c=relaxed/simple; bh=GjwSFSwqU8rkn5De5P7jUBJg+PMBSZmYg+Q+t755HF4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=phWir7gp0px35VsaFWUsxbuBYq865/tbjeqm8U3HsL65LBcyIoREy2cPrf9jt6QY/BMXhoLhL2rS0mHjGuts69gHWSROr7C4BeMgOJid9Am3qsZAUAUkWKeQis/dhqNr37uAxq+5eyqh50uT4JIhp6Om2HyXA1+RAf+ik0cXVgc= 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=b8zixbqV; arc=none smtp.client-ip=209.85.221.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b8zixbqV" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3ecdf2b1751so3038984f8f.0 for ; Mon, 13 Oct 2025 07:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367230; x=1760972030; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GmgyMrfNSf1QbkW2cWjL4/Xd2W/yNMiKsE6jAo6f6fY=; b=b8zixbqV5pRk9k5FD4jROeZ+DDkFbbMYer7qFxsyRrZl29LYC2d2knJnJt9oNxGVKQ j5k51/sLopVHp45KcchsKvbT0eOfOW9uEoRPgNo2wVFQUFVlUCW3HgJ1ytNipQp1QfdX kxj0htVsOwTfSvMcxXNVXlny6k1t+xpE+v5vXpUKU+pVXtzDCDGLP2arAi5yeT93Y8Dj NRcd7LSkwbUxC0XD9E5kXkmNCw2CXQ4qtvmUqdIGiHQxt24fRQ06YTSIKhTReaecuvTM o1PRGXCNJ53XMb4Cwh1KtA3NavFLYlzxm4OOZre9AEC9J24nf9lUzjCUAXlF+9TKc09F dgfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367230; x=1760972030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GmgyMrfNSf1QbkW2cWjL4/Xd2W/yNMiKsE6jAo6f6fY=; b=sGWMOSADCqB74PztStmARvhhTNh4rGPXvXfN/UZOMgXy6VfcJ0N/GxkeGGfUpGYOOE IbXYA3daOs0b8vug09LqXg6YJ5PvYRbHcrZkDCXQzIkodsfW28675ZPcYrdH4g5z3hpY D+OxrHM1QqrTAigI6e8EPCGAoIUDNOmNp/LXRWsF8q6X8rvovBZp4CvcbrAz8ViJBbt+ nMVpKDceTZ+Y8shXpO0KpVf9bAI9xTaQdNlDCVc2Dip7OAbn0eRRPMrD1KHDUYHlc022 i/KmWIg22E6Gpj4BxoarLkI/EuinFvDypDJLZE8dLaDgggKAqjlD+bWBkMrAheqYzCoZ am2Q== X-Forwarded-Encrypted: i=1; AJvYcCW3LJKKRThlTwSUdOYpZVseUk4imx/FBbGsz5VLRTZgCueFdek5G0NES7F6MYN7Zpovx88x0YMgH418lAg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5iz14ack08e1DgZwu+a4Hi7XLmwSjNU5TL9bz3/Pf+KkoNESt tM3vzjQ9dMGdEKy04uvnCW9Aa8HM3G7YmARgqNHUcZquE7Q8D9pOM2AU X-Gm-Gg: ASbGncvVW2Jhatg5JehSqqKJ4bpzKKMcTbpe5errZT++zqmx57iZhjJTOXglEQikKkB o8dAbcB4IzRUnqsY8FQLRbv3hg8l2nRmUnEqzhNtwQkDWxO4Kw5jFu1y3x/HDKWn/MuEhDXU3hq u3UePXx2GOp1xQSSwPJi9PMRaWqJFQkWehsxM8zccjPTrwqRoT2GjkPsiLXejq8OgwQ8KUNw+L8 caac8pD+Of8172QFc+WDvHgaS5PIfOo00y5G1g87uHK/irnXVrndPX0YAAW7JkLZfmbevR2sFX7 fXiS9DfbJY2x1kkrcKFybRzY7aGLnkibX4WFAolPiNn52jXn7+GzZnjJVGwSMnhe3qoBMEUFLmE M8HDEMJKSGfYtQnWJSBPlCxdQ6DTsyaRKYfQ= X-Google-Smtp-Source: AGHT+IF4BqUEqPY/lEHVdfhtdHZQUBn4lD2yFKhAE2G5bjuGJP3/uoHRJB95i7fwZ4AdUzgso19ltg== X-Received: by 2002:a05:6000:260a:b0:426:d53d:a405 with SMTP id ffacd0b85a97d-426d53da458mr5999140f8f.20.1760367229805; Mon, 13 Oct 2025 07:53:49 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:49 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 15/24] net: add queue config validation callback Date: Mon, 13 Oct 2025 15:54:17 +0100 Message-ID: <4daa213af8779cbb8dfebb7ff559814f80611cfc.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski I imagine (tm) that as the number of per-queue configuration options grows some of them may conflict for certain drivers. While the drivers can obviously do all the validation locally doing so is fairly inconvenient as the config is fed to drivers piecemeal via different ops (for different params and NIC-wide vs per-queue). Add a centralized callback for validating the queue config in queue ops. The callback gets invoked before each queue restart and when ring params are modified. For NIC-wide changes the callback gets invoked for each active (or active to-be) queue, and additionally with a negative queue index for NIC-wide defaults. The NIC-wide check is needed in case all queues have an override active when NIC-wide setting is changed to an unsupported one. Alternatively we could check the settings when new queues are enabled (in the channel API), but accepting invalid config is a bad idea. Users may expect that resetting a queue override will always work. The "trick" of passing a negative index is a bit ugly, we may want to revisit if it causes confusion and bugs. Existing drivers don't care about the index so it "just works". Signed-off-by: Jakub Kicinski Signed-off-by: Pavel Begunkov --- include/net/netdev_queues.h | 12 ++++++++++++ net/core/dev.h | 2 ++ net/core/netdev_config.c | 20 ++++++++++++++++++++ net/core/netdev_rx_queue.c | 6 ++++++ net/ethtool/rings.c | 5 +++++ 5 files changed, 45 insertions(+) diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h index a7b325307029..532f60ee1a66 100644 --- a/include/net/netdev_queues.h +++ b/include/net/netdev_queues.h @@ -147,6 +147,14 @@ void netdev_stat_queue_sum(struct net_device *netdev, * defaults. Queue config structs are passed to this * helper before the user-requested settings are applied. * + * @ndo_queue_cfg_validate: (Optional) Check if queue config is supported. + * Called when configuration affecting a queue may be + * changing, either due to NIC-wide config, or config + * scoped to the queue at a specified index. + * When NIC-wide config is changed the callback will + * be invoked for all queues, and in addition to that + * with a negative queue index for the base settings. + * * @ndo_queue_mem_alloc: Allocate memory for an RX queue at the specified = index. * The new memory is written at the specified address. * @@ -170,6 +178,10 @@ struct netdev_queue_mgmt_ops { void (*ndo_queue_cfg_defaults)(struct net_device *dev, int idx, struct netdev_queue_config *qcfg); + int (*ndo_queue_cfg_validate)(struct net_device *dev, + int idx, + struct netdev_queue_config *qcfg, + struct netlink_ext_ack *extack); int (*ndo_queue_mem_alloc)(struct net_device *dev, struct netdev_queue_config *qcfg, void *per_queue_mem, diff --git a/net/core/dev.h b/net/core/dev.h index a2d6a181b9b0..a203b63198e7 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -99,6 +99,8 @@ void netdev_free_config(struct net_device *dev); int netdev_reconfig_start(struct net_device *dev); void __netdev_queue_config(struct net_device *dev, int rxq, struct netdev_queue_config *qcfg, bool pending); +int netdev_queue_config_revalidate(struct net_device *dev, + struct netlink_ext_ack *extack); =20 /* netdev management, shared between various uAPI entry points */ struct netdev_name_node { diff --git a/net/core/netdev_config.c b/net/core/netdev_config.c index bad2d53522f0..fc700b77e4eb 100644 --- a/net/core/netdev_config.c +++ b/net/core/netdev_config.c @@ -99,3 +99,23 @@ void netdev_queue_config(struct net_device *dev, int rxq, __netdev_queue_config(dev, rxq, qcfg, true); } EXPORT_SYMBOL(netdev_queue_config); + +int netdev_queue_config_revalidate(struct net_device *dev, + struct netlink_ext_ack *extack) +{ + const struct netdev_queue_mgmt_ops *qops =3D dev->queue_mgmt_ops; + struct netdev_queue_config qcfg; + int i, err; + + if (!qops || !qops->ndo_queue_cfg_validate) + return 0; + + for (i =3D -1; i < (int)dev->real_num_rx_queues; i++) { + netdev_queue_config(dev, i, &qcfg); + err =3D qops->ndo_queue_cfg_validate(dev, i, &qcfg, extack); + if (err) + return err; + } + + return 0; +} diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c index 16db850aafd7..5ae375a072a1 100644 --- a/net/core/netdev_rx_queue.c +++ b/net/core/netdev_rx_queue.c @@ -46,6 +46,12 @@ int netdev_rx_queue_restart(struct net_device *dev, unsi= gned int rxq_idx, =20 netdev_queue_config(dev, rxq_idx, &qcfg); =20 + if (qops->ndo_queue_cfg_validate) { + err =3D qops->ndo_queue_cfg_validate(dev, rxq_idx, &qcfg, extack); + if (err) + goto err_free_old_mem; + } + err =3D qops->ndo_queue_mem_alloc(dev, &qcfg, new_mem, rxq_idx); if (err) goto err_free_old_mem; diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index 6a74e7e4064e..7884d10c090f 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -4,6 +4,7 @@ =20 #include "netlink.h" #include "common.h" +#include "../core/dev.h" =20 struct rings_req_info { struct ethnl_req_info base; @@ -307,6 +308,10 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struc= t genl_info *info) dev->cfg_pending->hds_config =3D kernel_ringparam.tcp_data_split; dev->cfg_pending->hds_thresh =3D kernel_ringparam.hds_thresh; =20 + ret =3D netdev_queue_config_revalidate(dev, info->extack); + if (ret) + return ret; + ret =3D dev->ethtool_ops->set_ringparam(dev, &ringparam, &kernel_ringparam, info->extack); return ret < 0 ? ret : 1; --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 8FBAF31282A for ; Mon, 13 Oct 2025 14:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367236; cv=none; b=FS1njru1nNumddajPtCZQfMyDbBrin1ov19cVaShHtVH/JNaEQxsvAar2tY+B5ZVAdniRvqlQS9vMBPkPt7813TuROorDLTZQnczEp1JkKMfArw9geURcONoiUzbCB5JGyyChmESi7OkXJH/Rngskgf+2SKQkMt4yMh8MwG2Au8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367236; c=relaxed/simple; bh=5njEvVGvRvg5n+or8A0T0TeMIvuwdSGOGUYTMwZoZrw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H6MXeUh0N8HJCYlQK2Ba3v0OLdTkwxTzhVulRVmZ6LWQ1tHE1njlek7UjXPjDZNUUym/Z+oi8ci0BD59T/gA1UoUFkl+ObP51RUVH9OshYy4hnSpcLU8Rl6H8VmnNEEa8hI0IEamsKF1eAlSNM85shByMsPmN+SCoodxztwX+JE= 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=bYZdR/1B; arc=none smtp.client-ip=209.85.128.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bYZdR/1B" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-46e3cdc1a6aso31765425e9.1 for ; Mon, 13 Oct 2025 07:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367232; x=1760972032; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mx3rKwv8UpZmKoPpNp8c4OWFyXZ2MQ9zKc0xRf7JTbY=; b=bYZdR/1B6EnR21UtQM02QdZ/SlZlUnJJ4HgKFePQdxI8Eh4Vz5mxonv4tvx8GlyEfe QNFqDE0Hof7aL+0Jg3oW3H6WPiUMPKaN8cIc8NGDQBpMgAvthmHzN1euRS2nEHuxbeFz ueQfYEXZB+DIC4i7aXyx3HfYzKhQAyj8QCqpqhoHSVAeEet06Gm6WL/yARIQ7D2syVcm eYIzEEyZrR4F76VxwW1m3QECHx4dITHvTH/Ipc4uu4tzrxtm/vbGe+Z5rwD8hpVkaSKP XZYn9xO45FjKRQMDpCUtRS7PZjJVtGsSXz1bVqCy/mxVcAhFrxuhShn6pd50eloLt5bv eM/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367232; x=1760972032; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mx3rKwv8UpZmKoPpNp8c4OWFyXZ2MQ9zKc0xRf7JTbY=; b=W84nWhqqzESWZM3NIqDuGzEodOQ/mAuYg/iDRJGPVh/POFKZtHYJgPnfeD9pscuzyk jF+iRnINX/xNGj3l3CgeBUaLNkMCVz5Kdhew5WEAK0NRo21LzCuQ7CptshYP7i4OC+kQ 0goelojk/P1qLOUN08mwGKaWnI0XUWw0oXNmIZfRhngs9VfHRNxppXHDvWoxqPDG+Sm7 TTfGrwbyc5MjD3R5vGrQjo9NzR4VLvbFRj8COSZKjhe+NSBKOk2brEjMejne5lhP2EY9 vHEzKpzSH4Hts1QsNx3dpicEqDZb6pM6AQg315JyTpSYDV+fwpx21jgB++JqimnlpU29 e3Sg== X-Forwarded-Encrypted: i=1; AJvYcCU4Cfxt/eD397u9q6EnxoaylpzfMI9iNFnact4VB8En/vs850i1cN1KEYfJvIYZ5w6X1MbO/Rd1VrWBX1E=@vger.kernel.org X-Gm-Message-State: AOJu0YzKGGo1DUmhpNavffxinGL0K13NZAkETB2cPxahg3ByD+Y9wWiD 7aMM4QGD2uZg7ZRs45ZJePImzFIpbNil2nZy77Ttlvxi+GdcBr+WN7E+ X-Gm-Gg: ASbGncveeps+3t3RAvh+U8pmZmNjC4m3fo9SQ2vRR2c27AZTLxnGnpl4UfC0U6d94Md eOec1xzbPe2fcUhNMOB1xq8ZvLfYqWFozZa32qNTu1SrYQG69oxtY27yDb1KAqdYuw/fUQnrcup 0RUxBB/pRpRU+JoPR7RNu24sZ44vpaVgF3k96/7ZIMGXh1dLjT11rMUqauDZQZtNgRFOOMDnZNx wAhGsEwA61wb6M2UCCw61Xhg4fmsQJ6XgYvpEWjkSzqmIjNFxQoYrXFUNcVWaPSAT6glFENOzg3 arzBUj2/76gx79OQSiXma/4c0IlPyUIx7nL0EA24wl0D7BujE17wdzGXo9y6UYLYXuqI3OPcgjd Tv3PZjJiiX25a4VdoZ2B/K2KvHOwH39D3BL8= X-Google-Smtp-Source: AGHT+IE3H2i/VyBQ+RSV0mjlmorIJH69FGvZYgt2TChv0GqkPZvFJ5kiUJWgTBqn/GwNWnmRiH+YrQ== X-Received: by 2002:a05:600c:2287:b0:45d:d86b:b386 with SMTP id 5b1f17b1804b1-46fa29f13dfmr128925175e9.14.1760367231769; Mon, 13 Oct 2025 07:53:51 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:50 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 16/24] eth: bnxt: always set the queue mgmt ops Date: Mon, 13 Oct 2025 15:54:18 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Core provides a centralized callback for validating per-queue settings but the callback is part of the queue management ops. Having the ops conditionally set complicates the parts of the driver which could otherwise lean on the core to feed it the correct settings. Always set the queue ops, but provide no restart-related callbacks if queue ops are not supported by the device. This should maintain current behavior, the check in netdev_rx_queue_restart() looks both at op struct and individual ops. Signed-off-by: Jakub Kicinski [pavel: reflow mgmt ops assignment] Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 61e5c866d946..bd06171cc86c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -16187,6 +16187,9 @@ static const struct netdev_queue_mgmt_ops bnxt_queu= e_mgmt_ops =3D { .ndo_queue_stop =3D bnxt_queue_stop, }; =20 +static const struct netdev_queue_mgmt_ops bnxt_queue_mgmt_ops_unsupp =3D { +}; + static void bnxt_remove_one(struct pci_dev *pdev) { struct net_device *dev =3D pci_get_drvdata(pdev); @@ -16840,6 +16843,8 @@ static int bnxt_init_one(struct pci_dev *pdev, cons= t struct pci_device_id *ent) =20 if (BNXT_SUPPORTS_NTUPLE_VNIC(bp)) bp->rss_cap |=3D BNXT_RSS_CAP_MULTI_RSS_CTX; + + dev->queue_mgmt_ops =3D &bnxt_queue_mgmt_ops_unsupp; if (BNXT_SUPPORTS_QUEUE_API(bp)) dev->queue_mgmt_ops =3D &bnxt_queue_mgmt_ops; dev->request_ops_lock =3D true; --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 A55EF30C601 for ; Mon, 13 Oct 2025 14:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367238; cv=none; b=M24/miVWmtQQek2sfSbfEpcmI359/M/YG/BEbSGa1fLUON5621G1zzC0u4iMQ8HZo4Xy9wR9KIctGFdx270VtcK56NsJ41GAPIlTVSypGRRFVUJ+1vmJppRSh/r5bNBAQPrKy9sjpflES7Hhnqn4x221+1qSjWesQW3kOLqabTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367238; c=relaxed/simple; bh=EgGEBzf2tQ2hDKTqPSG1kRWo1QhB1J6i5AMVaMlg1M8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F7I6ziKt6s6x8Ny5sRWiI3h4wUb0kqe4Kr1/uwU9MbytbMCAwARFZl2VRBIJ7iBqMki1Ievr4tUQSRL3aL36qUYOC26CaVSCUxPA3hKM1qD9gjfUlDUk7dSXtuyRos27W/1xzsYxwO34/W/oAQQu2KPI1dx/88rbgnuO6tADKi8= 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=lqcYpra/; arc=none smtp.client-ip=209.85.221.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lqcYpra/" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3ee1221ceaaso3402636f8f.3 for ; Mon, 13 Oct 2025 07:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367234; x=1760972034; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KI8rjZmQ/L1Al+gP48JHwdpSfp4N03OffTWb0ztaxv0=; b=lqcYpra/+v7Zc6r9anKIJ2EhmEWYpJdTkwjdgP2d1BdKFs8aFn6u9VWTv2EaAsKM9T O016jZtrGwwnTKnDsWU5txRv0MUz5PqvYpGus+DJkdg6lxRhgdMOrr4C+OC4IrdQQV/0 vB0KRchWdZFGJBlw0ECXbsqNGQBF0y9Pv1A1BNNiRE61cxPwtu8JQX7hmLdFzXZ1dK9h SvktGP46mCCuu49tSEbVsykzYI3qsQFcHEcJkwm+GAPSGDeGWKqDykKzG1FIaQZ5e8L8 dwRzj76HbbfLHhvGFCMxvDYgAHqC25nST5YqOwXWFxuShlK3dgCLh8mYiR5ndR6Wleho M95g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367234; x=1760972034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KI8rjZmQ/L1Al+gP48JHwdpSfp4N03OffTWb0ztaxv0=; b=MrkjJeBFyVlOdD62bfV5gAFeJEYv39mReTUl1HgHCT38Qv3ppOFFbvIcp+D3A35VTS 8DmWktLk6ASFvegjdWpTVF2L8XgZDePbEWah0fRO991SzX/8qoTKNZ8tjBSMFsPTvzzO rc64xUnBlGkmkMUPHJ6OEoSc8QINmn1Eqd0FQkl7rfmVv/NBXwvQhD/sSjiM7+DrnS9H o2WlxnSNtaPhbkesNmovuBoof5w/wyJJZADeCfOjZIhngRTt2UwRzSvNbGk2UMVTGyYo Z/NxEuzqnIkWGVjQMG6Ew8OI0ghx8mpc+/Kz4SxS3JbjiRhilwVimYG5PpHaboLXsA/T vdNg== X-Forwarded-Encrypted: i=1; AJvYcCUIVB4h2BdbOczp20y3K5IruYEMw2fQVhq6dGIqYJrdbGFh6J5YBA7rFwJ2XIcpf0dIN9SyYSNuoeHnIWs=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9LPjJsUjMNOsG2qYOvfCYgKe2adZ9KUMnFT5mORR0bAqCLW3S NGxlUwSn7Jg14zmSY4kgABhgoASB6YljS3g0G0BmCfzE5THWH40JCK71 X-Gm-Gg: ASbGncs6suPFIK1hyt53op2ZxI03dV9FJO7YSmuuD+59JzjwliTmCyBHi9SOGp9YS6t D/uvQBpYN98r/QvDZbJyMoseZm0qpJBBZhS+TjN4VEY+HTPnHZqkKo9raGYI2llrn6mRQoTLmNE W1JGB/24mgcyabCDX/iCwXvDnV+GHzMMRAwmvrC+HN+8CrC0RZW1ITvywIB5qo5sXXST/8wB7L0 c7XPW4WUa306u9Q9cHKfG2awG86yb6UCbOeBfSO5LwbB9zO62wlYpnfoRSjtE9SdsQUGOkUfp4M L0Uq8ic1lmRhnmy4i15EVPibzikDE/3py7WQJZSdmi/wXjYHqEd0sjY3MlkG9DDtOj/4chBoVAE e59huAQOgEtiVGhQjwtD/BPQ0 X-Google-Smtp-Source: AGHT+IFq6txCfH/k7MrGiJpsm5NDxIzCJ9mtywptrzBXFlALDmTvNrOfZaqHAnA97agdoNKKpmsq8A== X-Received: by 2002:a05:6000:2c0e:b0:3ec:de3c:c56 with SMTP id ffacd0b85a97d-42667177c79mr14775692f8f.16.1760367233623; Mon, 13 Oct 2025 07:53:53 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:52 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 17/24] eth: bnxt: store the rx buf size per queue Date: Mon, 13 Oct 2025 15:54:19 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski In normal operation only a subset of queues is configured for zero-copy. Since zero-copy is the main use for larger buffer sizes we need to configure the sizes per queue. Signed-off-by: Jakub Kicinski Reviewed-by: Somnath Kotur Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 50 ++++++++++--------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 6 +-- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 2 +- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index bd06171cc86c..e4dba91332ae 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -905,7 +905,7 @@ static void bnxt_tx_int(struct bnxt *bp, struct bnxt_na= pi *bnapi, int budget) =20 static bool bnxt_separate_head_pool(struct bnxt_rx_ring_info *rxr) { - return rxr->need_head_pool || rxr->bnapi->bp->rx_page_size < PAGE_SIZE; + return rxr->need_head_pool || rxr->rx_page_size < PAGE_SIZE; } =20 static struct page *__bnxt_alloc_rx_page(struct bnxt *bp, dma_addr_t *mapp= ing, @@ -915,9 +915,9 @@ static struct page *__bnxt_alloc_rx_page(struct bnxt *b= p, dma_addr_t *mapping, { struct page *page; =20 - if (bp->rx_page_size < PAGE_SIZE) { + if (rxr->rx_page_size < PAGE_SIZE) { page =3D page_pool_dev_alloc_frag(rxr->page_pool, offset, - bp->rx_page_size); + rxr->rx_page_size); } else { page =3D page_pool_dev_alloc_pages(rxr->page_pool); *offset =3D 0; @@ -936,9 +936,9 @@ static netmem_ref __bnxt_alloc_rx_netmem(struct bnxt *b= p, dma_addr_t *mapping, { netmem_ref netmem; =20 - if (bp->rx_page_size < PAGE_SIZE) { + if (rxr->rx_page_size < PAGE_SIZE) { netmem =3D page_pool_alloc_frag_netmem(rxr->page_pool, offset, - bp->rx_page_size, gfp); + rxr->rx_page_size, gfp); } else { netmem =3D page_pool_alloc_netmems(rxr->page_pool, gfp); *offset =3D 0; @@ -1156,9 +1156,9 @@ static struct sk_buff *bnxt_rx_multi_page_skb(struct = bnxt *bp, return NULL; } dma_addr -=3D bp->rx_dma_offset; - dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, bp->rx_page_size, + dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, rxr->rx_page_size, bp->rx_dir); - skb =3D napi_build_skb(data_ptr - bp->rx_offset, bp->rx_page_size); + skb =3D napi_build_skb(data_ptr - bp->rx_offset, rxr->rx_page_size); if (!skb) { page_pool_recycle_direct(rxr->page_pool, page); return NULL; @@ -1190,7 +1190,7 @@ static struct sk_buff *bnxt_rx_page_skb(struct bnxt *= bp, return NULL; } dma_addr -=3D bp->rx_dma_offset; - dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, bp->rx_page_size, + dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, rxr->rx_page_size, bp->rx_dir); =20 if (unlikely(!payload)) @@ -1204,7 +1204,7 @@ static struct sk_buff *bnxt_rx_page_skb(struct bnxt *= bp, =20 skb_mark_for_recycle(skb); off =3D (void *)data_ptr - page_address(page); - skb_add_rx_frag(skb, 0, page, off, len, bp->rx_page_size); + skb_add_rx_frag(skb, 0, page, off, len, rxr->rx_page_size); memcpy(skb->data - NET_IP_ALIGN, data_ptr - NET_IP_ALIGN, payload + NET_IP_ALIGN); =20 @@ -1289,7 +1289,7 @@ static u32 __bnxt_rx_agg_netmems(struct bnxt *bp, if (skb) { skb_add_rx_frag_netmem(skb, i, cons_rx_buf->netmem, cons_rx_buf->offset, - frag_len, bp->rx_page_size); + frag_len, rxr->rx_page_size); } else { skb_frag_t *frag =3D &shinfo->frags[i]; =20 @@ -1314,7 +1314,7 @@ static u32 __bnxt_rx_agg_netmems(struct bnxt *bp, if (skb) { skb->len -=3D frag_len; skb->data_len -=3D frag_len; - skb->truesize -=3D bp->rx_page_size; + skb->truesize -=3D rxr->rx_page_size; } =20 --shinfo->nr_frags; @@ -1329,7 +1329,7 @@ static u32 __bnxt_rx_agg_netmems(struct bnxt *bp, } =20 page_pool_dma_sync_netmem_for_cpu(rxr->page_pool, netmem, 0, - bp->rx_page_size); + rxr->rx_page_size); =20 total_frag_len +=3D frag_len; prod =3D NEXT_RX_AGG(prod); @@ -2282,8 +2282,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_c= p_ring_info *cpr, if (!skb) goto oom_next_rx; } else { - skb =3D bnxt_xdp_build_skb(bp, skb, agg_bufs, - rxr->page_pool, &xdp); + skb =3D bnxt_xdp_build_skb(bp, skb, agg_bufs, rxr, &xdp); if (!skb) { /* we should be able to free the old skb here */ bnxt_xdp_buff_frags_free(rxr, &xdp); @@ -3830,7 +3829,7 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp, if (BNXT_RX_PAGE_MODE(bp)) pp.pool_size +=3D bp->rx_ring_size / rx_size_fac; =20 - pp.order =3D get_order(bp->rx_page_size); + pp.order =3D get_order(rxr->rx_page_size); pp.nid =3D numa_node; pp.netdev =3D bp->dev; pp.dev =3D &bp->pdev->dev; @@ -4325,6 +4324,8 @@ static void bnxt_init_ring_struct(struct bnxt *bp) if (!rxr) goto skip_rx; =20 + rxr->rx_page_size =3D bp->rx_page_size; + ring =3D &rxr->rx_ring_struct; rmem =3D &ring->ring_mem; rmem->nr_pages =3D bp->rx_nr_pages; @@ -4484,7 +4485,7 @@ static void bnxt_init_one_rx_agg_ring_rxbd(struct bnx= t *bp, ring =3D &rxr->rx_agg_ring_struct; ring->fw_ring_id =3D INVALID_HW_RING_ID; if ((bp->flags & BNXT_FLAG_AGG_RINGS)) { - type =3D ((u32)bp->rx_page_size << RX_BD_LEN_SHIFT) | + type =3D ((u32)rxr->rx_page_size << RX_BD_LEN_SHIFT) | RX_BD_TYPE_RX_AGG_BD | RX_BD_FLAGS_SOP; =20 bnxt_init_rxbd_pages(ring, type); @@ -7051,6 +7052,7 @@ static void bnxt_hwrm_ring_grp_free(struct bnxt *bp) =20 static void bnxt_set_rx_ring_params_p5(struct bnxt *bp, u32 ring_type, struct hwrm_ring_alloc_input *req, + struct bnxt_rx_ring_info *rxr, struct bnxt_ring_struct *ring) { struct bnxt_ring_grp_info *grp_info =3D &bp->grp_info[ring->grp_idx]; @@ -7060,7 +7062,7 @@ static void bnxt_set_rx_ring_params_p5(struct bnxt *b= p, u32 ring_type, if (ring_type =3D=3D HWRM_RING_ALLOC_AGG) { req->ring_type =3D RING_ALLOC_REQ_RING_TYPE_RX_AGG; req->rx_ring_id =3D cpu_to_le16(grp_info->rx_fw_ring_id); - req->rx_buf_size =3D cpu_to_le16(bp->rx_page_size); + req->rx_buf_size =3D cpu_to_le16(rxr->rx_page_size); enables |=3D RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID; } else { req->rx_buf_size =3D cpu_to_le16(bp->rx_buf_use_size); @@ -7074,6 +7076,7 @@ static void bnxt_set_rx_ring_params_p5(struct bnxt *b= p, u32 ring_type, } =20 static int hwrm_ring_alloc_send_msg(struct bnxt *bp, + struct bnxt_rx_ring_info *rxr, struct bnxt_ring_struct *ring, u32 ring_type, u32 map_index) { @@ -7130,7 +7133,8 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp, cpu_to_le32(bp->rx_ring_mask + 1) : cpu_to_le32(bp->rx_agg_ring_mask + 1); if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) - bnxt_set_rx_ring_params_p5(bp, ring_type, req, ring); + bnxt_set_rx_ring_params_p5(bp, ring_type, req, + rxr, ring); break; case HWRM_RING_ALLOC_CMPL: req->ring_type =3D RING_ALLOC_REQ_RING_TYPE_L2_CMPL; @@ -7278,7 +7282,7 @@ static int bnxt_hwrm_rx_ring_alloc(struct bnxt *bp, u32 map_idx =3D bnapi->index; int rc; =20 - rc =3D hwrm_ring_alloc_send_msg(bp, ring, type, map_idx); + rc =3D hwrm_ring_alloc_send_msg(bp, rxr, ring, type, map_idx); if (rc) return rc; =20 @@ -7298,7 +7302,7 @@ static int bnxt_hwrm_rx_agg_ring_alloc(struct bnxt *b= p, int rc; =20 map_idx =3D grp_idx + bp->rx_nr_rings; - rc =3D hwrm_ring_alloc_send_msg(bp, ring, type, map_idx); + rc =3D hwrm_ring_alloc_send_msg(bp, rxr, ring, type, map_idx); if (rc) return rc; =20 @@ -7322,7 +7326,7 @@ static int bnxt_hwrm_cp_ring_alloc_p5(struct bnxt *bp, =20 ring =3D &cpr->cp_ring_struct; ring->handle =3D BNXT_SET_NQ_HDL(cpr); - rc =3D hwrm_ring_alloc_send_msg(bp, ring, type, map_idx); + rc =3D hwrm_ring_alloc_send_msg(bp, NULL, ring, type, map_idx); if (rc) return rc; bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id); @@ -7337,7 +7341,7 @@ static int bnxt_hwrm_tx_ring_alloc(struct bnxt *bp, const u32 type =3D HWRM_RING_ALLOC_TX; int rc; =20 - rc =3D hwrm_ring_alloc_send_msg(bp, ring, type, tx_idx); + rc =3D hwrm_ring_alloc_send_msg(bp, NULL, ring, type, tx_idx); if (rc) return rc; bnxt_set_db(bp, &txr->tx_db, type, tx_idx, ring->fw_ring_id); @@ -7363,7 +7367,7 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp) =20 vector =3D bp->irq_tbl[map_idx].vector; disable_irq_nosync(vector); - rc =3D hwrm_ring_alloc_send_msg(bp, ring, type, map_idx); + rc =3D hwrm_ring_alloc_send_msg(bp, NULL, ring, type, map_idx); if (rc) { enable_irq(vector); goto err_out; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethern= et/broadcom/bnxt/bnxt.h index 3abe59e9b021..c8931de76de3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1107,6 +1107,7 @@ struct bnxt_rx_ring_info { =20 unsigned long *rx_agg_bmap; u16 rx_agg_bmap_size; + u16 rx_page_size; bool need_head_pool; =20 dma_addr_t rx_desc_mapping[MAX_RX_PAGES]; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/et= hernet/broadcom/bnxt/bnxt_xdp.c index c23c04007136..619235b151a4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c @@ -183,7 +183,7 @@ void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx= _ring_info *rxr, u16 cons, u8 *data_ptr, unsigned int len, struct xdp_buff *xdp) { - u32 buflen =3D bp->rx_page_size; + u32 buflen =3D rxr->rx_page_size; struct bnxt_sw_rx_bd *rx_buf; struct pci_dev *pdev; dma_addr_t mapping; @@ -461,7 +461,7 @@ int bnxt_xdp(struct net_device *dev, struct netdev_bpf = *xdp) =20 struct sk_buff * bnxt_xdp_build_skb(struct bnxt *bp, struct sk_buff *skb, u8 num_frags, - struct page_pool *pool, struct xdp_buff *xdp) + struct bnxt_rx_ring_info *rxr, struct xdp_buff *xdp) { struct skb_shared_info *sinfo =3D xdp_get_shared_info_from_buff(xdp); =20 @@ -469,7 +469,7 @@ bnxt_xdp_build_skb(struct bnxt *bp, struct sk_buff *skb= , u8 num_frags, return NULL; =20 xdp_update_skb_frags_info(skb, num_frags, sinfo->xdp_frags_size, - bp->rx_page_size * num_frags, + rxr->rx_page_size * num_frags, xdp_buff_get_skb_flags(xdp)); return skb; } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h b/drivers/net/et= hernet/broadcom/bnxt/bnxt_xdp.h index 220285e190fc..8933a0dec09a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h @@ -32,6 +32,6 @@ void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_r= ing_info *rxr, void bnxt_xdp_buff_frags_free(struct bnxt_rx_ring_info *rxr, struct xdp_buff *xdp); struct sk_buff *bnxt_xdp_build_skb(struct bnxt *bp, struct sk_buff *skb, - u8 num_frags, struct page_pool *pool, + u8 num_frags, struct bnxt_rx_ring_info *rxr, struct xdp_buff *xdp); #endif --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 896C6313270 for ; Mon, 13 Oct 2025 14:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367240; cv=none; b=JXVho9b/VxC5TIq3lZQLx0/Kwt8BwhixudkgVUC0/wMbvxQE9ZkWE/tB6vSLUtuibhEL1QgmyJ4WASl7JvMgLcWhTk2CRmuSbQPvpLjy3Lo+MrAWcHlrVIr9avcD3P9+MxSfMQJ7n2Cgv7JFUaC0wb11et0adbmD8WUPUOiAkU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367240; c=relaxed/simple; bh=b8FGPOYez3J824Dr7qxiyxcRaNo5kRct9HxQwv0g5HI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tbvFFnURpoJz7IVrtSKaf5XWr/CCixlOP4GhEVhp3bJiAs0PeDXHVkYk5rPI6yJOaxK1NNDGr8m3Iyk11OwrZreIeWp4rjEZyAbEU5XTr/6AcWIVyifWuPXW6pI1IBjK85f/RUe9zwSEZlmqwAerkzaeozQBxoOtdhDgRGIehA0= 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=ZMPj6k4J; arc=none smtp.client-ip=209.85.221.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZMPj6k4J" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3ecde0be34eso2755510f8f.1 for ; Mon, 13 Oct 2025 07:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367236; x=1760972036; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pxHRXya3lXGBnReUxXIEEoBgDfJjb/lzzOFKtNAVoFE=; b=ZMPj6k4J7AH41Cm38BsKO3Hkad0NDoCGKeEHI1MakyrzvfEQmya8BdeCJSTKEr1SjZ /2ts1XC9SUG89Id0fxjQ8f18w3FMAWA8wRXS3GZtAo64sot9AaP1R+uMsklLLQqA0eca 7Tq+jSV67uc1ujmy9K70ozYUXppTPVCw9QzWvzJhXAlGjgXBkRfsTVFcyqB+eyjn9fhT kx0WLzd0Z5FZjHXZ2kggYZ10G1aYjeuumIpCAUG3cVnmsmp1r2o8VnIGkM3rMjbE6ZYO KXdmX78lZGBAyVluvum3LM6xcqZK7xSbfLcmdXnG48/99TPFv+u4/hbPCtLf6hQVOMcc NlXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367236; x=1760972036; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pxHRXya3lXGBnReUxXIEEoBgDfJjb/lzzOFKtNAVoFE=; b=e0KpcFFzDrkvO3otXDujPdk8GkRiUphOZpYOLgwjQCpRGJ0H2aN2yW2QLQuM//DQKo LA2v5Alm5/sAI7+Ohz+hOpsE/EA8xsZgJSL7PCCWuBAn0bwuxcmVwCWI8h+UnzbXZAk0 qc7VpSDkyS4bMorKooBTgYWMeMxwMb/lLyh6p14EOkIkgV5uQ078eJKNqfK+xbLmsCpP cMTyO+MRgrFsG76XL50kWfxy7CL3X9rJVYqa+t3T7rkRIuzwJa2XXgdN9ewT1GxMrv1w FHOwrX3rFkZMAeBdOVmy1MPuJxzOeBZUQGD6C67EFh8BazoKtRtO8n+BcFFGCaGrw07q 7i4w== X-Forwarded-Encrypted: i=1; AJvYcCV5p23uW0nOkUD/s36Idn61xt/l8lem/FYNLy64bbcpSIXjCVTEoVgBqHomH5dQ0cK1JrjYct6AoF/y3Wk=@vger.kernel.org X-Gm-Message-State: AOJu0YyNkVEcxsNkiu/ZmudhOu+qaffuS2AMWDXbPc85VA2R4G2dbYO9 81kJHousgBH8qv2e0ujtyFXXx6dlncPTLRXMhf4wTho5mNNURb7EVQr/ X-Gm-Gg: ASbGncuZvKcDjAkq+G5N9bEcNppuIu/g/q4rFxA5xT7fDXTMU+ReHGSXFAE7rdM2dKX HXv/JBPHe6qZEZZCZXp2tcRNfz1PYaxiqMk9zSTP0xTJZAuH15ZTrNMNrYBPO57cBs6kt9Mv5QW 6iQnwWn5rBQTTMlKYZicYcOIQvj/V5I7a4g4RfSn42u3ELNZ5SOKmB5qu/RConvx0nfOBWXEFM5 3b5gxs9hqIjwjF6Xv3MQzVSvSkGyXKUQaMgQSBOBqfzBhd334LW6Yg0ZfRFpWgukqB7dOT1WkDn gtTEMzGO3Rpij4cnAqOqgZddDLj+KSpqakG299BgbLh54HQADxLTO6NW3+h48ssj0UO73DlzmpW recy/niCjxKzQxhPCy0mTPaVJ X-Google-Smtp-Source: AGHT+IG0JaMqrygloaBo/Hgni68I4c0N36CFgBnj1m1GOH+xECQ5fun7HUBRPJc+Mht1oZD+K4qurw== X-Received: by 2002:a05:6000:2502:b0:425:86da:325f with SMTP id ffacd0b85a97d-4266e7cf047mr15243982f8f.27.1760367235639; Mon, 13 Oct 2025 07:53:55 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:54 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 18/24] eth: bnxt: adjust the fill level of agg queues with larger buffers Date: Mon, 13 Oct 2025 15:54:20 +0100 Message-ID: <6c14fdceadaf7fb8e81584aec551c9a9fddc6625.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski The driver tries to provision more agg buffers than header buffers since multiple agg segments can reuse the same header. The calculation / heuristic tries to provide enough pages for 65k of data for each header (or 4 frags per header if the result is too big). This calculation is currently global to the adapter. If we increase the buffer sizes 8x we don't want 8x the amount of memory sitting on the rings. Luckily we don't have to fill the rings completely, adjust the fill level dynamically in case particular queue has buffers larger than the global size. Signed-off-by: Jakub Kicinski [pavel: rebase on top of agg_size_fac, assert agg_size_fac] Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index e4dba91332ae..1741aeffee55 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -3816,16 +3816,34 @@ static void bnxt_free_rx_rings(struct bnxt *bp) } } =20 +static int bnxt_rx_agg_ring_fill_level(struct bnxt *bp, + struct bnxt_rx_ring_info *rxr) +{ + /* User may have chosen larger than default rx_page_size, + * we keep the ring sizes uniform and also want uniform amount + * of bytes consumed per ring, so cap how much of the rings we fill. + */ + int fill_level =3D bp->rx_agg_ring_size; + + if (rxr->rx_page_size > bp->rx_page_size) + fill_level /=3D rxr->rx_page_size / bp->rx_page_size; + + return fill_level; +} + static int bnxt_alloc_rx_page_pool(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, int numa_node) { - const unsigned int agg_size_fac =3D PAGE_SIZE / BNXT_RX_PAGE_SIZE; + unsigned int agg_size_fac =3D rxr->rx_page_size / BNXT_RX_PAGE_SIZE; const unsigned int rx_size_fac =3D PAGE_SIZE / SZ_4K; struct page_pool_params pp =3D { 0 }; struct page_pool *pool; =20 - pp.pool_size =3D bp->rx_agg_ring_size / agg_size_fac; + if (WARN_ON_ONCE(agg_size_fac =3D=3D 0)) + agg_size_fac =3D 1; + + pp.pool_size =3D bnxt_rx_agg_ring_fill_level(bp, rxr) / agg_size_fac; if (BNXT_RX_PAGE_MODE(bp)) pp.pool_size +=3D bp->rx_ring_size / rx_size_fac; =20 @@ -4403,11 +4421,13 @@ static void bnxt_alloc_one_rx_ring_netmem(struct bn= xt *bp, struct bnxt_rx_ring_info *rxr, int ring_nr) { + int fill_level, i; u32 prod; - int i; + + fill_level =3D bnxt_rx_agg_ring_fill_level(bp, rxr); =20 prod =3D rxr->rx_agg_prod; - for (i =3D 0; i < bp->rx_agg_ring_size; i++) { + for (i =3D 0; i < fill_level; i++) { if (bnxt_alloc_rx_netmem(bp, rxr, prod, GFP_KERNEL)) { netdev_warn(bp->dev, "init'ed rx ring %d with %d/%d pages only\n", ring_nr, i, bp->rx_agg_ring_size); --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 7630231329F for ; Mon, 13 Oct 2025 14:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367242; cv=none; b=NHNCBSx/UmkC1G3iTJF/IMZDLi81Bm/Sji3yTA9cpDL5U11JuQ4ygdIrqRV19mkHeX0m9NOhfDIgzdmsoSJ3afcVhCxAMiY+7B6SgaRH6F9hLGBCwiMgzO1H07OMZcWN69JOC/X/5d3SerMFzYDUikkLST7VZ5Xf5nyl++qw7io= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367242; c=relaxed/simple; bh=kcyz3K/+ZD7+9nmDKS34MZXJ1XuGasqzh9S5BjHI38s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kHBOMHyaNsokrJXrWm/5aCsTQ6F3B7m/82RcLvTHUOQwB+BDnAPMmhxW3No/i9EkKg0XoQLIr6QGPtahC8w2eAyW9MXEpdJHbyMoRaRKAUZ7ANLbf/eINxGW8lmcIIAm4doEcyGQ1o+pFHIJlOHIa5N6gEzGj0LDuH3BaAv73Ww= 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=QDwuT8Nz; arc=none smtp.client-ip=209.85.221.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QDwuT8Nz" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3fa528f127fso3156685f8f.1 for ; Mon, 13 Oct 2025 07:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367238; x=1760972038; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VPtcW7QNRWzI4bwcgscdOvSibo3vgz0EjZuRg0ANq3Q=; b=QDwuT8NzZJdunMg3YXYd3RsLI9NvKi1uLf9Uryt7APKHpk6oJ6ByomF39v2EvrWzeM DV264vAssgiVS3K63j3MO+vUGDm3X6o4o/9pBhLXCyxX8FwCQyC/Q+SDXu+xp21fyvs3 xByhwEDqo75Iv31lVd5bTdRijU8T99xGs9WEZ8L4hxRidP1uhaMkztyfdCifQdpIo8D/ N4qvcdpedhV9plrfrPgiY1N0XFmw7k1C6tv0+ZH5rSyFAZZ6l229hbLA3RoFqehXdB+C YZewW+pW1QLrELF+iycsitZCSnhQqexbP/osrawMagtNb2HcaJtHs7g9WTsL9VWteJ5x yzOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367238; x=1760972038; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VPtcW7QNRWzI4bwcgscdOvSibo3vgz0EjZuRg0ANq3Q=; b=ojdG/ySOwwlluxxCchQ7U0J6l/F6nbJvWOma5APdPKO7MML6iTzzkRyP2iMT5B4XW3 zZYsR5/hiR8GOLZbvwUwKAco4H7YrQ+vBHClTYvenm5LUd8M9mcpSH1w8CO8GIqWb4sl ovaw3bsmBUgp9akWLOYgjrmoxW6Dh6R+rH5uMJ4fBy4WmpUr4vJuzER0HiZYugQm6vcJ RBBlpGDoQnnVl25i7CnFgHqybsbdRAyvxn2G/VBkDs826xjMJfFIltzKKfCInZLYktrg xHZvspH+e+OR32xIzFMJ85avLQ0+9XwUr2br1Z97IbFuZqxa/ygGSs1Pr+LxwI+46OtC mDSg== X-Forwarded-Encrypted: i=1; AJvYcCWlDuoxNlm7IS+FFJAWiATTMGKVQWFb+THhS5ndfoOiX/DNgiyh28KcflqeV0OHk98b3uRitJAtyYxVUMY=@vger.kernel.org X-Gm-Message-State: AOJu0YzDkpmY3lfn3iwvY/Ms7n0V+kb6jPoh8+gVUHX0Og+CX5zDzzda wXci1oPJrhJPsf7YdUhnC2Wy0xbOiR0g+cFxvY83OolyyNbyD44SeMzr X-Gm-Gg: ASbGncsCv7B9hn30QCxUBUFRQZrFQ7kM6tfNFT2aE1gjZ2DvutH1x5Ko9I+XeLE2oIi +QWr/EZUGE8QE10LNehBMFAi1haOIvy+zQSBahQCPKrMOm24eMwMu4rGreE0xZVh+wT3vzr14DZ DKMfIljK1vCr4BbhhvcO3G/3qw5dsiulNs0mu37zwZOsjkFoaXw07yg+4TgUqGbtzGuLnD4Aiu3 swUGAkGiIOp/LmbLSWlbflwUlo/3M2oiHEzoGG6SZgf7bB56SGnkcgc/NlD5wz2Od1VGyeBH+Lr mibcYTExX4bG1J7lTjdjJF+IL+7gPNVzyN7melYap3ak0j20pQbSnmGUD53h7a01XRzyd07IB7Q oPwWmQm/CjdfSufOScVh6kVjN6PbqNHHTbng= X-Google-Smtp-Source: AGHT+IGyTqxu1DQCG+uMhIMrq/BG38kVog29PB2V4zE54HNR0YJmUqUkMsN2dpw+NIfVGZjdAr5iZA== X-Received: by 2002:a05:6000:310b:b0:3d3:b30:4cf2 with SMTP id ffacd0b85a97d-4266e7beaa3mr12850184f8f.19.1760367237484; Mon, 13 Oct 2025 07:53:57 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:56 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 19/24] netdev: add support for setting rx-buf-len per queue Date: Mon, 13 Oct 2025 15:54:21 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Zero-copy APIs increase the cost of buffer management. They also extend this cost to user space applications which may be used to dealing with much larger buffers. Allow setting rx-buf-len per queue, devices with HW-GRO support can commonly fill buffers up to 32k (or rather 64k - 1 but that's not a power of 2..) The implementation adds a new option to the netdev netlink, rather than ethtool. The NIC-wide setting lives in ethtool ringparams so one could argue that we should be extending the ethtool API. OTOH netdev API is where we already have queue-get, and it's how zero-copy applications bind memory providers. Signed-off-by: Jakub Kicinski Signed-off-by: Pavel Begunkov --- Documentation/netlink/specs/netdev.yaml | 15 ++++ include/net/netdev_queues.h | 5 ++ include/net/netlink.h | 19 +++++ include/uapi/linux/netdev.h | 2 + net/core/netdev-genl-gen.c | 15 ++++ net/core/netdev-genl-gen.h | 1 + net/core/netdev-genl.c | 92 +++++++++++++++++++++++++ net/core/netdev_config.c | 16 +++++ tools/include/uapi/linux/netdev.h | 2 + 9 files changed, 167 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index e00d3fa1c152..fabae13f45e8 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -338,6 +338,10 @@ attribute-sets: doc: XSK information for this queue, if any. type: nest nested-attributes: xsk-info + - + name: rx-buf-len + doc: Per-queue configuration of ETHTOOL_A_RINGS_RX_BUF_LEN. + type: u32 - name: qstats doc: | @@ -771,6 +775,17 @@ operations: reply: attributes: - id + - + name: queue-set + doc: Set per-queue configurable options. + attribute-set: queue + do: + request: + attributes: + - ifindex + - type + - id + - rx-buf-len =20 kernel-family: headers: ["net/netdev_netlink.h"] diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h index 532f60ee1a66..4b59ca9d5a4b 100644 --- a/include/net/netdev_queues.h +++ b/include/net/netdev_queues.h @@ -39,6 +39,7 @@ struct netdev_config { =20 /* Same semantics as fields in struct netdev_config */ struct netdev_queue_config { + u32 rx_buf_len; }; =20 /* See the netdev.yaml spec for definition of each statistic */ @@ -141,6 +142,8 @@ void netdev_stat_queue_sum(struct net_device *netdev, /** * struct netdev_queue_mgmt_ops - netdev ops for queue management * + * @supported_ring_params: ring params supported per queue (ETHTOOL_RING_U= SE_*). + * * @ndo_queue_mem_size: Size of the struct that describes a queue's memory. * * @ndo_queue_cfg_defaults: (Optional) Populate queue config struct with @@ -174,6 +177,8 @@ void netdev_stat_queue_sum(struct net_device *netdev, * be called for an interface which is open. */ struct netdev_queue_mgmt_ops { + u32 supported_ring_params; + size_t ndo_queue_mem_size; void (*ndo_queue_cfg_defaults)(struct net_device *dev, int idx, diff --git a/include/net/netlink.h b/include/net/netlink.h index 1a8356ca4b78..29989ad81ddd 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -2200,6 +2200,25 @@ static inline struct nla_bitfield32 nla_get_bitfield= 32(const struct nlattr *nla) return tmp; } =20 +/** + * nla_update_u32() - update u32 value from NLA_U32 attribute + * @dst: value to update + * @attr: netlink attribute with new value or null + * + * Copy the u32 value from NLA_U32 netlink attribute @attr into variable + * pointed to by @dst; do nothing if @attr is null. + * + * Return: true if this function changed the value of @dst, otherwise fals= e. + */ +static inline bool nla_update_u32(u32 *dst, const struct nlattr *attr) +{ + u32 old_val =3D *dst; + + if (attr) + *dst =3D nla_get_u32(attr); + return *dst !=3D old_val; +} + /** * nla_memdup - duplicate attribute memory (kmemdup) * @src: netlink attribute to duplicate from diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index 48eb49aa03d4..820f89b67a72 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -158,6 +158,7 @@ enum { NETDEV_A_QUEUE_DMABUF, NETDEV_A_QUEUE_IO_URING, NETDEV_A_QUEUE_XSK, + NETDEV_A_QUEUE_RX_BUF_LEN, =20 __NETDEV_A_QUEUE_MAX, NETDEV_A_QUEUE_MAX =3D (__NETDEV_A_QUEUE_MAX - 1) @@ -226,6 +227,7 @@ enum { NETDEV_CMD_BIND_RX, NETDEV_CMD_NAPI_SET, NETDEV_CMD_BIND_TX, + NETDEV_CMD_QUEUE_SET, =20 __NETDEV_CMD_MAX, NETDEV_CMD_MAX =3D (__NETDEV_CMD_MAX - 1) diff --git a/net/core/netdev-genl-gen.c b/net/core/netdev-genl-gen.c index e9a2a6f26cb7..d053306a3af8 100644 --- a/net/core/netdev-genl-gen.c +++ b/net/core/netdev-genl-gen.c @@ -106,6 +106,14 @@ static const struct nla_policy netdev_bind_tx_nl_polic= y[NETDEV_A_DMABUF_FD + 1] [NETDEV_A_DMABUF_FD] =3D { .type =3D NLA_U32, }, }; =20 +/* NETDEV_CMD_QUEUE_SET - do */ +static const struct nla_policy netdev_queue_set_nl_policy[NETDEV_A_QUEUE_R= X_BUF_LEN + 1] =3D { + [NETDEV_A_QUEUE_IFINDEX] =3D NLA_POLICY_MIN(NLA_U32, 1), + [NETDEV_A_QUEUE_TYPE] =3D NLA_POLICY_MAX(NLA_U32, 1), + [NETDEV_A_QUEUE_ID] =3D { .type =3D NLA_U32, }, + [NETDEV_A_QUEUE_RX_BUF_LEN] =3D { .type =3D NLA_U32, }, +}; + /* Ops table for netdev */ static const struct genl_split_ops netdev_nl_ops[] =3D { { @@ -204,6 +212,13 @@ static const struct genl_split_ops netdev_nl_ops[] =3D= { .maxattr =3D NETDEV_A_DMABUF_FD, .flags =3D GENL_CMD_CAP_DO, }, + { + .cmd =3D NETDEV_CMD_QUEUE_SET, + .doit =3D netdev_nl_queue_set_doit, + .policy =3D netdev_queue_set_nl_policy, + .maxattr =3D NETDEV_A_QUEUE_RX_BUF_LEN, + .flags =3D GENL_CMD_CAP_DO, + }, }; =20 static const struct genl_multicast_group netdev_nl_mcgrps[] =3D { diff --git a/net/core/netdev-genl-gen.h b/net/core/netdev-genl-gen.h index cf3fad74511f..b7f5e5d9fca9 100644 --- a/net/core/netdev-genl-gen.h +++ b/net/core/netdev-genl-gen.h @@ -35,6 +35,7 @@ int netdev_nl_qstats_get_dumpit(struct sk_buff *skb, int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info); int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info); int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info); +int netdev_nl_queue_set_doit(struct sk_buff *skb, struct genl_info *info); =20 enum { NETDEV_NLGRP_MGMT, diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 470fabbeacd9..61529b600c87 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -386,6 +386,30 @@ static int nla_put_napi_id(struct sk_buff *skb, const = struct napi_struct *napi) return 0; } =20 +static int +netdev_nl_queue_fill_cfg(struct sk_buff *rsp, struct net_device *netdev, + u32 q_idx, u32 q_type) +{ + struct netdev_queue_config *qcfg; + + if (!netdev_need_ops_lock(netdev)) + return 0; + + qcfg =3D &netdev->cfg->qcfg[q_idx]; + switch (q_type) { + case NETDEV_QUEUE_TYPE_RX: + if (qcfg->rx_buf_len && + nla_put_u32(rsp, NETDEV_A_QUEUE_RX_BUF_LEN, + qcfg->rx_buf_len)) + return -EMSGSIZE; + break; + default: + break; + } + + return 0; +} + static int netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev, u32 q_idx, u32 q_type, const struct genl_info *info) @@ -433,6 +457,9 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct ne= t_device *netdev, break; } =20 + if (netdev_nl_queue_fill_cfg(rsp, netdev, q_idx, q_type)) + goto nla_put_failure; + genlmsg_end(rsp, hdr); =20 return 0; @@ -572,6 +599,71 @@ int netdev_nl_queue_get_dumpit(struct sk_buff *skb, st= ruct netlink_callback *cb) return err; } =20 +int netdev_nl_queue_set_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct nlattr * const *tb =3D info->attrs; + struct netdev_queue_config *qcfg; + u32 q_id, q_type, ifindex; + struct net_device *netdev; + bool mod; + int ret; + + if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_QUEUE_ID) || + GENL_REQ_ATTR_CHECK(info, NETDEV_A_QUEUE_TYPE) || + GENL_REQ_ATTR_CHECK(info, NETDEV_A_QUEUE_IFINDEX)) + return -EINVAL; + + q_id =3D nla_get_u32(tb[NETDEV_A_QUEUE_ID]); + q_type =3D nla_get_u32(tb[NETDEV_A_QUEUE_TYPE]); + ifindex =3D nla_get_u32(tb[NETDEV_A_QUEUE_IFINDEX]); + + if (q_type !=3D NETDEV_QUEUE_TYPE_RX) { + /* Only Rx params exist right now */ + NL_SET_BAD_ATTR(info->extack, tb[NETDEV_A_QUEUE_TYPE]); + return -EINVAL; + } + + ret =3D 0; + netdev =3D netdev_get_by_index_lock(genl_info_net(info), ifindex); + if (!netdev || !netif_device_present(netdev)) + ret =3D -ENODEV; + else if (!netdev->queue_mgmt_ops) + ret =3D -EOPNOTSUPP; + if (ret) { + NL_SET_BAD_ATTR(info->extack, tb[NETDEV_A_QUEUE_IFINDEX]); + goto exit_unlock; + } + + ret =3D netdev_nl_queue_validate(netdev, q_id, q_type); + if (ret) { + NL_SET_BAD_ATTR(info->extack, tb[NETDEV_A_QUEUE_ID]); + goto exit_unlock; + } + + ret =3D netdev_reconfig_start(netdev); + if (ret) + goto exit_unlock; + + qcfg =3D &netdev->cfg_pending->qcfg[q_id]; + mod =3D nla_update_u32(&qcfg->rx_buf_len, tb[NETDEV_A_QUEUE_RX_BUF_LEN]); + if (!mod) + goto exit_free_cfg; + + ret =3D netdev_rx_queue_restart(netdev, q_id, info->extack); + if (ret) + goto exit_free_cfg; + + swap(netdev->cfg, netdev->cfg_pending); + +exit_free_cfg: + __netdev_free_config(netdev->cfg_pending); + netdev->cfg_pending =3D netdev->cfg; +exit_unlock: + if (netdev) + netdev_unlock(netdev); + return ret; +} + #define NETDEV_STAT_NOT_SET (~0ULL) =20 static void netdev_nl_stats_add(void *_sum, const void *_add, size_t size) diff --git a/net/core/netdev_config.c b/net/core/netdev_config.c index fc700b77e4eb..ede02b77470e 100644 --- a/net/core/netdev_config.c +++ b/net/core/netdev_config.c @@ -67,11 +67,27 @@ int netdev_reconfig_start(struct net_device *dev) void __netdev_queue_config(struct net_device *dev, int rxq, struct netdev_queue_config *qcfg, bool pending) { + const struct netdev_config *cfg; + + cfg =3D pending ? dev->cfg_pending : dev->cfg; + memset(qcfg, 0, sizeof(*qcfg)); =20 /* Get defaults from the driver, in case user config not set */ if (dev->queue_mgmt_ops->ndo_queue_cfg_defaults) dev->queue_mgmt_ops->ndo_queue_cfg_defaults(dev, rxq, qcfg); + + /* Set config based on device-level settings */ + if (cfg->rx_buf_len) + qcfg->rx_buf_len =3D cfg->rx_buf_len; + + /* Set config dedicated to this queue */ + if (rxq >=3D 0) { + const struct netdev_queue_config *user_cfg =3D &cfg->qcfg[rxq]; + + if (user_cfg->rx_buf_len) + qcfg->rx_buf_len =3D user_cfg->rx_buf_len; + } } =20 /** diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/n= etdev.h index 48eb49aa03d4..820f89b67a72 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -158,6 +158,7 @@ enum { NETDEV_A_QUEUE_DMABUF, NETDEV_A_QUEUE_IO_URING, NETDEV_A_QUEUE_XSK, + NETDEV_A_QUEUE_RX_BUF_LEN, =20 __NETDEV_A_QUEUE_MAX, NETDEV_A_QUEUE_MAX =3D (__NETDEV_A_QUEUE_MAX - 1) @@ -226,6 +227,7 @@ enum { NETDEV_CMD_BIND_RX, NETDEV_CMD_NAPI_SET, NETDEV_CMD_BIND_TX, + NETDEV_CMD_QUEUE_SET, =20 __NETDEV_CMD_MAX, NETDEV_CMD_MAX =3D (__NETDEV_CMD_MAX - 1) --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 851FF30C37E for ; Mon, 13 Oct 2025 14:54:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367244; cv=none; b=npjggeIGS2CEapoWQtSCxtPEDHabxjU9P1BmmIsGA885eaXhS7H4xVCHR9cHotouTNmmHrRrCTn+JhBmQgb+lDS/DebYvHT3tcxQVPoawWI/Sn4YPP5A58l8M8KbRXDf/HRN8ivJ/15csd0Ka4xr0OBUoYMBjLh3ONJviFNS1tE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367244; c=relaxed/simple; bh=aZBe05rc0MGsCYK4sT5VGwUDz1yniV4yDrd7Hn1NTo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mUJQ/6/WHG1OOSl4SU8LsJ14eWNmeFuXukETYu/HvQcBbb9iMfNJmZpmdzeidIcsCaDpqeaxvtHluh5ODK50ja8G+KOTAP5W/ni8YYhXlYmztS98mbjuIkhnJNc3Mv37R4VDkvev7Iiia/l/AcR83eY6BXCxvOoPA0+BLO+d2vs= 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=OFMBv60X; arc=none smtp.client-ip=209.85.128.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OFMBv60X" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-46e6674caa5so22200765e9.0 for ; Mon, 13 Oct 2025 07:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367240; x=1760972040; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f2Xy6qVdWrPTN0DdBWw84p2SpFLtW6dghcLsQY6aOfc=; b=OFMBv60XD65Qy2+hYXaxL8f+Uhtx0UiACS4GdPHuUsWAGYIB86MgkjIO4QbQBIzHrX CkqVhwRQhRWso0+bkuccGLbfSta0AS6eNtngPplp8Et4VczJvUJz1IHN33hCigKJ7pPC imeywDtmncHJ54byyPFgtUS3wCJhQkTnC76lr3NT1E/l8dnlkX4wV+CcpJ7fKR0+UJPt V2MdH/y324jiAgTDpCGvrfhSHdBiKLDVL/KEfxdqV3OuMnpYaty/spEjSF9VFkx4qVXZ tv7LQQv4sby9h0dIdMmr6QJq0umVlqLxmi5b362M88fpfu2deSsEtvfih10YK1B/D4NK 0FZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367240; x=1760972040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f2Xy6qVdWrPTN0DdBWw84p2SpFLtW6dghcLsQY6aOfc=; b=UysImkX2eyg1PcSjGsm8Nz2XZKb8vqKTxBXDyuMQ13cIZ7KbcEj0Qm+GvwSUwRnLri bOQyj+M7T7Ne4a7M06tvIhn6/lb7soSCZ8S+i0iGoS+BOT3OH4vHiEx1LXWZo0SWosLc Jg0cyOimlVlGKq6GWplYgOi1h611VepJMXP5gDStsmwhXswtFQRUYYp35orQu7zHAd+z FY6hYqbeScCxjuGXNYMmWmyBzLV0/sJXy6/BiXHqU2NaT6LCi9l1WhzA+nnMS7p9prBv 6ba5EJSV2MQFnincv0m6e7WdjP5VZhKzHG4tLIZVI4NeYlF8VJsCbpvMiIvH3rxmyUXx C36A== X-Forwarded-Encrypted: i=1; AJvYcCWISDny0mAZQaIX6vU3hSpCpgjbDFzE554OFcmw06tHwTZiyq1m3ur6tc8T2YUvt7ojlQ9f5gHfLhKmrIE=@vger.kernel.org X-Gm-Message-State: AOJu0YyqlkGNYvI785TCsMZkzUsFC0TwzPoJwKVWSPJZlYAkJHgFa7Hp JFjCeU/zEj0h9p3ok7m7XYS9Mp1Nce9I2BAdkFSyFP/ACKmPPL027M0M X-Gm-Gg: ASbGnctmZwKnK9jJIegiWMcOYaThxLaGiuydVwfnZdb0jpPSvpNMuEDfz3iimxG8rpR ScEYnB8oTBmZ4WjVcLlovsaCquA8fP/KMTKpog48kFsWdv0tiz387I13+fuayIzFToXu4KawsyX 5Wl0h2rqnpqObqj0cNpeMKZuGMISb9P8XigOLnUROgWG0zYa8Wv6Rv2WH3Id8U2Hf1Ck4kOSCDt FQgH+cxkReKNfyVif8O+Grl6pmAsl0+lvABNVKqhuE/oXQceeMRYSWlxJOEiKszGAFfHSxYCpZK OxGbAm57IZ1JWBecV5bRxLXHDXRhq2FRca6gGGvR5pnoefJcJkowSfEpNDWfzyVBr/W/y2j9ISI YAeLjmmarAU9miYq3AkYSCPh4 X-Google-Smtp-Source: AGHT+IF25ZjCO04KHHq0TYmhTMidbVuQW1ShdxxUvQA1Yprokjlc765D+WOyBbnJX1oGt9SxrNvhcA== X-Received: by 2002:a05:600c:a411:b0:46e:1b9d:ac6c with SMTP id 5b1f17b1804b1-46fb1f77c2bmr85952605e9.17.1760367239377; Mon, 13 Oct 2025 07:53:59 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:53:58 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 20/24] net: wipe the setting of deactived queues Date: Mon, 13 Oct 2025 15:54:22 +0100 Message-ID: <65dc8bd105e2573b3bd41bd35c73913392590a87.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Clear out all settings of deactived queues when user changes the number of channels. We already perform similar cleanup for shapers. Signed-off-by: Jakub Kicinski Reviewed-by: Mina Almasry Signed-off-by: Pavel Begunkov --- net/core/dev.c | 5 +++++ net/core/dev.h | 2 ++ net/core/netdev_config.c | 13 +++++++++++++ 3 files changed, 20 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index 5f92425dfdbd..b253e7e29ffa 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3188,6 +3188,8 @@ int netif_set_real_num_tx_queues(struct net_device *d= ev, unsigned int txq) if (dev->num_tc) netif_setup_tc(dev, txq); =20 + netdev_queue_config_update_cnt(dev, txq, + dev->real_num_rx_queues); net_shaper_set_real_num_tx_queues(dev, txq); =20 dev_qdisc_change_real_num_tx(dev, txq); @@ -3233,6 +3235,9 @@ int netif_set_real_num_rx_queues(struct net_device *d= ev, unsigned int rxq) rxq); if (rc) return rc; + + netdev_queue_config_update_cnt(dev, dev->real_num_tx_queues, + rxq); } =20 dev->real_num_rx_queues =3D rxq; diff --git a/net/core/dev.h b/net/core/dev.h index a203b63198e7..63192dbb1895 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -101,6 +101,8 @@ void __netdev_queue_config(struct net_device *dev, int = rxq, struct netdev_queue_config *qcfg, bool pending); int netdev_queue_config_revalidate(struct net_device *dev, struct netlink_ext_ack *extack); +void netdev_queue_config_update_cnt(struct net_device *dev, unsigned int t= xq, + unsigned int rxq); =20 /* netdev management, shared between various uAPI entry points */ struct netdev_name_node { diff --git a/net/core/netdev_config.c b/net/core/netdev_config.c index ede02b77470e..c5ae39e76f40 100644 --- a/net/core/netdev_config.c +++ b/net/core/netdev_config.c @@ -64,6 +64,19 @@ int netdev_reconfig_start(struct net_device *dev) return -ENOMEM; } =20 +void netdev_queue_config_update_cnt(struct net_device *dev, unsigned int t= xq, + unsigned int rxq) +{ + size_t len; + + if (rxq < dev->real_num_rx_queues) { + len =3D (dev->real_num_rx_queues - rxq) * sizeof(*dev->cfg->qcfg); + + memset(&dev->cfg->qcfg[rxq], 0, len); + memset(&dev->cfg_pending->qcfg[rxq], 0, len); + } +} + void __netdev_queue_config(struct net_device *dev, int rxq, struct netdev_queue_config *qcfg, bool pending) { --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 53A9F313E15 for ; Mon, 13 Oct 2025 14:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367246; cv=none; b=os5842aTxmxiaagza4zK5OBoWAM1PChYUAcB0VhjYaAMelJbtDp5POjMK+gBEBE95vKWUBBXWGjrnMM0zfsLjqiCS6qE3EEpOMO8mYzYak5BSSaSNcop4/Sxero8HRupwGfzenT046Xa2OQQQ/Zw7Aod9+cayKSY7s9DEmVzA3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367246; c=relaxed/simple; bh=VbkbnL9Jd7IBf/weO/ABOH6hhH/VI1oK8B4vqYtdCZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FAsolF0uj1rSEp49WEl4HK0XB+d5D5giyqXZsrUe6ivFSuAqcFZhH95gGA0gNcI1/0p49NpjHjnIvIQv1Xw9mhpbYIay15kv6r19Xi8vc41okcC3Dke6Mq5n9KQVNuh6t42eHtSYAtehzq3b4prpzCjdVK5SOG6Z6ErljFNzJng= 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=nK8CWOB5; arc=none smtp.client-ip=209.85.221.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nK8CWOB5" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3fc36b99e92so3810447f8f.0 for ; Mon, 13 Oct 2025 07:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367241; x=1760972041; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RkGcDsrwsgWPCsuq5GDhJNJxx+ikf4u6w8tp//AtVs0=; b=nK8CWOB5unkrl3VkdLu5QANW1g/EuAZou8GsyC1Ykz6MrJJmM8L15r7wMjv+s4oXbU R2p9Snh86SXLQyE9X0KzTphJCmaJP3Z0OFpNVrIQau1R0txqeENR8EsB6CoctmwRBbkl VQW1dZ6o9fTNdgMpImWKqkQTOM0tUshnMBMwUhVs/p/mkIm6PSqShS8ETMyGfmn17fKs MiBWsAodYfGCMGZ04MJQtR4TLDvkVtCSKwd7hSaSC2HCF+dSDTum9RVkUI8E9P8zmn7d Ff6/oc2tbOtwL+772KlzQPGLbXFUtBrV50au751DLpf5Typ9aRtiLS/cvi24PA8mE8QZ gRUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367241; x=1760972041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RkGcDsrwsgWPCsuq5GDhJNJxx+ikf4u6w8tp//AtVs0=; b=nBRV+3Yivz8U14eBB4uBmwAHlIMN2wLWf/q7xPM6fUmSaX8opT2F+RJbUR9qbqgaXy BA9geCZp3kebGoM2Yyt09Y3oefnURoA4uuEmz66P76MBhCXIH1K7/A2NblC73y5bn2xp tBXf7JWCkhOj4lrkT+K9IKFE5cbhFXFMk5BQQDFhyPGaKzDRvCuPvJl1yjl1H280F7I7 Gxd8pcBVk66umPGF3Y7fU5R7tRPDoMMCfWZpFQAO6FY5NppbWtp2prk7Xwk35uYhVvWK mgS9NRt+96mJ8NtMq0PHuPg+/5g7EhbpdkkzKFAflWUe0IcFLnDixiKbaQq9z9g0s8cX Pe3Q== X-Forwarded-Encrypted: i=1; AJvYcCWRpF467cJJ6himiPfpyVEEjaYOv4fGh1xV8DE0U6wQGcZhOz6OSA61Ace0NIowAe65+jpqLY9rgMR+aPs=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+W0MuKcHEAAHUFCtG04a2D4jKjs6t0lU8l8JSGdPx4rpV2DrB 1rV6pASxqPfPAoF9LXekQVIk0lrZWZEB19dEcpc2chGkQpIEuLR1OagG X-Gm-Gg: ASbGnct+KIZlINI2GKh535j7xGJEBC/WeocdImDSotvod5YIRCoHuBI6gnuaYDIOqT0 Yf6Fx5zblnwI5pQgTjDGNeJTfEsIq+e+eOGV68QoQ0Ii7GYbSCa6gFQiX/o/P2hddC/nPGQFjU+ h7EIEsubutxGx4XC6yLBKHXZ4hdtvLrRjXrjOUvc1USjNMl7YobvsdlHJejoL1bTiL+Lw9GViHk OxQVpIWGW1ERqZsIPrF7tWQ3GatNSDzaj1vFgobduksICzHIiH8fx/AHMigZartsXrnsE13YAJA fZMF5tnvXWWE554HOKtfeelXQ5zyE3JoD0vGMzV3XB9DdIfNlFUtHk6cTYIYSNX1M2Ff/vy4KEq Jqzqj6ZsP3dniaAefgX1Mhf4gwteSoLtVbFE= X-Google-Smtp-Source: AGHT+IFZf5L5TRXz5wsFBrykN326xbtU7X5fxLPBYKQtWRmSSbTCDM7kGLqU4vBh+Qln0Ip8y76AUg== X-Received: by 2002:a05:6000:1861:b0:426:d514:286c with SMTP id ffacd0b85a97d-426d5142a25mr5987222f8f.28.1760367241180; Mon, 13 Oct 2025 07:54:01 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:54:00 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 21/24] eth: bnxt: use queue op config validate Date: Mon, 13 Oct 2025 15:54:23 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Move the rx-buf-len config validation to the queue ops. Signed-off-by: Jakub Kicinski Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 40 +++++++++++++++++++ .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 12 ------ 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 1741aeffee55..ea95a06ae62b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -16203,8 +16203,46 @@ static int bnxt_queue_stop(struct net_device *dev,= void *qmem, int idx) return 0; } =20 +static int +bnxt_queue_cfg_validate(struct net_device *dev, int idx, + struct netdev_queue_config *qcfg, + struct netlink_ext_ack *extack) +{ + struct bnxt *bp =3D netdev_priv(dev); + + /* Older chips need MSS calc so rx_buf_len is not supported, + * but we don't set queue ops for them so we should never get here. + */ + if (qcfg->rx_buf_len !=3D bp->rx_page_size && + !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) { + NL_SET_ERR_MSG_MOD(extack, "changing rx-buf-len not supported"); + return -EINVAL; + } + + if (!is_power_of_2(qcfg->rx_buf_len)) { + NL_SET_ERR_MSG_MOD(extack, "rx-buf-len is not power of 2"); + return -ERANGE; + } + if (qcfg->rx_buf_len < BNXT_RX_PAGE_SIZE || + qcfg->rx_buf_len > BNXT_MAX_RX_PAGE_SIZE) { + NL_SET_ERR_MSG_MOD(extack, "rx-buf-len out of range"); + return -ERANGE; + } + return 0; +} + +static void +bnxt_queue_cfg_defaults(struct net_device *dev, int idx, + struct netdev_queue_config *qcfg) +{ + qcfg->rx_buf_len =3D BNXT_RX_PAGE_SIZE; +} + static const struct netdev_queue_mgmt_ops bnxt_queue_mgmt_ops =3D { .ndo_queue_mem_size =3D sizeof(struct bnxt_rx_ring_info), + + .ndo_queue_cfg_defaults =3D bnxt_queue_cfg_defaults, + .ndo_queue_cfg_validate =3D bnxt_queue_cfg_validate, .ndo_queue_mem_alloc =3D bnxt_queue_mem_alloc, .ndo_queue_mem_free =3D bnxt_queue_mem_free, .ndo_queue_start =3D bnxt_queue_start, @@ -16212,6 +16250,8 @@ static const struct netdev_queue_mgmt_ops bnxt_queu= e_mgmt_ops =3D { }; =20 static const struct netdev_queue_mgmt_ops bnxt_queue_mgmt_ops_unsupp =3D { + .ndo_queue_cfg_defaults =3D bnxt_queue_cfg_defaults, + .ndo_queue_cfg_validate =3D bnxt_queue_cfg_validate, }; =20 static void bnxt_remove_one(struct pci_dev *pdev) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/ne= t/ethernet/broadcom/bnxt/bnxt_ethtool.c index 7b5b9781262d..07bdf37421ce 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -867,18 +867,6 @@ static int bnxt_set_ringparam(struct net_device *dev, if (!kernel_ering->rx_buf_len) /* Zero means restore default */ kernel_ering->rx_buf_len =3D BNXT_RX_PAGE_SIZE; =20 - if (kernel_ering->rx_buf_len !=3D bp->rx_page_size && - !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) { - NL_SET_ERR_MSG_MOD(extack, "changing rx-buf-len not supported"); - return -EINVAL; - } - if (!is_power_of_2(kernel_ering->rx_buf_len) || - kernel_ering->rx_buf_len < BNXT_RX_PAGE_SIZE || - kernel_ering->rx_buf_len > BNXT_MAX_RX_PAGE_SIZE) { - NL_SET_ERR_MSG_MOD(extack, "rx-buf-len out of range, or not power of 2"); - return -ERANGE; - } - if (netif_running(dev)) bnxt_close_nic(bp, false, false); =20 --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 34888313E3F for ; Mon, 13 Oct 2025 14:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367247; cv=none; b=iuBnaBwYKZGA5bSeVnS/2VvK31zQlTNwNproc0vQy0foVyWZtYm/FzCPI7mf4ucagC3ZqacEyBpCHGZedOEfyKbl3QMucSl0JU2v4M2k2xBAFuYumymIbCq77xAntaIaJ0/xOaN9elM8ybpOyRCNIoEjPP169g3f/GEZ38hA7Ag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367247; c=relaxed/simple; bh=UN20xXoo/DIsknQaKnQS3nE5pqQGdfuGllMStEKfLhQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L6aGTgCmoH1/sRo4uGAPczt/s6A74rdfljMBdY8j6Prmrr3iEy254KM2PequnyDF8iPSbutCUNG0rtqX3plEUNL8dDnnceBBMboRbxv0w0bsJtdcRy6aw1QU3kGUOs0qoKZXnJFw3Tw3I1uJsihBJcolM7jXZcyQQBiYMyYjy3c= 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=Vqk0YYK4; arc=none smtp.client-ip=209.85.128.41 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vqk0YYK4" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-46e430494ccso24899555e9.1 for ; Mon, 13 Oct 2025 07:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367243; x=1760972043; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kBVbea7flwKQsaU79NLWmhrt2gwy8JKbrcaG5BbSXQs=; b=Vqk0YYK4D39Lu3ifEgEsEVQoPaxkf9bJepAlOQBM79Vx3AxqTiUZmN0owgmjsEjzOG +EUXHJdOAb3fDTEloWsDBtBHUQDqOgTS4KrsQcwZ6AfcJ3pew8XTxJkywrhFfJupikPo gG6plI4kX8Stj5BPTj3JMNGg5bISxNAchPeDHn4pwm0tpwVcG0gLIPHKltmbZ+zvvQKv mgA/VlnG5okocDEzcM2C0Co+BFPDv25CGel0/VNvAtx038t3jqqACW8B8oevVONulD4+ 9NOxAE+P3JjJxpheoXkxJIKweAEnkxYtPSj43uf0lrtZUkcmIRh/utLnFyV1YR9SxEra RwWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367243; x=1760972043; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kBVbea7flwKQsaU79NLWmhrt2gwy8JKbrcaG5BbSXQs=; b=M3wj8Z7/HQJvTGCjY8EqrdqTSf59qM9LY8ULwpGnSbKNAOZPrpKDayuurE1UDQSKfH YotRhQeP6JeTaDwvjgcdtmVAFkMkdOdp0LStQusWqgbhCYA2sN/U9BP6r7FifVP155BY Q8lVaZKmX4TAlrFZQICBq9Wp+RP5d6ZTCJn1KVQkZvg1fzXdDaPWe+qVVJkCBkZqmeRX HdXXOwlPtOPeq2WLhPD7MTEPl2o2TAhAAXp0qJBcQ+S+yT5byCuLlxZLRWwop66DpbDR dLW5TtVt+7nPLRNBABYVUjvnulMkqA8addP4EaWxNe8pjecAq6VcjvtLm5O/4j9oDK4e +AMQ== X-Forwarded-Encrypted: i=1; AJvYcCXnYLkjf8bS84k35GaZH6Xs/t0azsjIWvzHmhlEJ5WJ3gi0URNyoThjlyVEJzzBtp4EIQpGzfW2kXID59o=@vger.kernel.org X-Gm-Message-State: AOJu0YyhP0KMcIrWSjuLz71f9SXgQ5DCOdGNLHC/JJWJQAR0B6AlHFAP GBFSeTTen8Jy1mnPLflszxhLlsV8YkcTEF1Xhah58cXYNs9ZCm/I6BL2 X-Gm-Gg: ASbGnctGhQ75ULRiIUDOJbD+EuQEUk6PD2UkQI9/7IORoNp/NnUiuLttgHuhqUjo+Z5 qZJ/uuJqfsjE3K0+WNzzfq6g3pSZYu8NQdL2InrQu+afhlDlQ0GiT75Y3eSq5fL8CHtH74nybwU JSpFDT+RRYInQ47yYVgNwDimCYf0yfwWgn2q2vJcpDxGvJxO3wG9BVbb7jTxYgym31Eq9Rix0IJ ayHxq1toP5BouwTu4P/8uBGA07RggJJ37SH/zKFYgH2PcSHch/4M7gzmuosv02YlPW9SwlMYgY8 gWM88YBgSJFwa+Y5SQ/zxX3oA+f3Kg2AgDyaBirPxVxXB31BEikLSkvoCJiP9zrV8X+5qPD/UIu iOwuWro36ax9ZdqXflD8RDLYT X-Google-Smtp-Source: AGHT+IGvZad4w3tGfNyelo8jRaGthiTAOmBgbASb/CfTYlM5+kxTUyX0ReE6Y+6587qOM/YD4IdmEg== X-Received: by 2002:a05:600c:1d1b:b0:46f:b32e:4f3e with SMTP id 5b1f17b1804b1-46fb32e4fa5mr121333895e9.37.1760367243089; Mon, 13 Oct 2025 07:54:03 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:54:02 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 22/24] eth: bnxt: support per queue configuration of rx-buf-len Date: Mon, 13 Oct 2025 15:54:24 +0100 Message-ID: <29f1f23b21eb1de0920aa912bcbefc6312160102.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jakub Kicinski Now that the rx_buf_len is stored and validated per queue allow it being set differently for different queues. Instead of copying the device setting for each queue ask the core for the config via netdev_queue_config(). Signed-off-by: Jakub Kicinski Signed-off-by: Pavel Begunkov --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index ea95a06ae62b..a734b18e47c4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4320,6 +4320,7 @@ static void bnxt_init_ring_struct(struct bnxt *bp) =20 for (i =3D 0; i < bp->cp_nr_rings; i++) { struct bnxt_napi *bnapi =3D bp->bnapi[i]; + struct netdev_queue_config qcfg; struct bnxt_ring_mem_info *rmem; struct bnxt_cp_ring_info *cpr; struct bnxt_rx_ring_info *rxr; @@ -4342,7 +4343,8 @@ static void bnxt_init_ring_struct(struct bnxt *bp) if (!rxr) goto skip_rx; =20 - rxr->rx_page_size =3D bp->rx_page_size; + netdev_queue_config(bp->dev, i, &qcfg); + rxr->rx_page_size =3D qcfg.rx_buf_len; =20 ring =3D &rxr->rx_ring_struct; rmem =3D &ring->ring_mem; @@ -15928,6 +15930,7 @@ static int bnxt_queue_mem_alloc(struct net_device *= dev, clone->rx_agg_prod =3D 0; clone->rx_sw_agg_prod =3D 0; clone->rx_next_cons =3D 0; + clone->rx_page_size =3D qcfg->rx_buf_len; clone->need_head_pool =3D false; =20 rc =3D bnxt_alloc_rx_page_pool(bp, clone, rxr->page_pool->p.nid); @@ -16032,6 +16035,8 @@ static void bnxt_copy_rx_ring(struct bnxt *bp, src_ring =3D &src->rx_ring_struct; src_rmem =3D &src_ring->ring_mem; =20 + dst->rx_page_size =3D src->rx_page_size; + WARN_ON(dst_rmem->nr_pages !=3D src_rmem->nr_pages); WARN_ON(dst_rmem->page_size !=3D src_rmem->page_size); WARN_ON(dst_rmem->flags !=3D src_rmem->flags); @@ -16239,6 +16244,7 @@ bnxt_queue_cfg_defaults(struct net_device *dev, int= idx, } =20 static const struct netdev_queue_mgmt_ops bnxt_queue_mgmt_ops =3D { + .supported_ring_params =3D ETHTOOL_RING_USE_RX_BUF_LEN, .ndo_queue_mem_size =3D sizeof(struct bnxt_rx_ring_info), =20 .ndo_queue_cfg_defaults =3D bnxt_queue_cfg_defaults, --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 7EF14313529 for ; Mon, 13 Oct 2025 14:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367248; cv=none; b=lK1KkcmkZD9ziSxcEh3QWjPBVaMeS+CCzguNm/7J/pjIu5pypzKsyoTA6GpssDHpBcbsit0Os9Jt+0TM8zT8iMAcEPtFU7A6jGUmLnaC8inHgCi4Gu7pVa1dGdFivzct4ZjLi3EYJNuZtqasdb4r0bmV9e1cFJu9FcT0XbwW4Q0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367248; c=relaxed/simple; bh=kvdcNejWK/mOk04H688uEbaA/cC9mhfBNv/gUTpRf6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UT/wfI4HXsOK82g+cGUoRMdldXRMvvqVFvtxbAh+ld5ZZ5tRz+MAFb8k/i2j5sYflwma4cl5/0/Tw4bPclt58XaHGdgCxP9ZhkWjimcBbpQr8TER2+SxixGfSieVv9aHAc4WVw9dDcu+VbzFRCsfCfn2Z+Ih+C4SoMxzsFYj0tk= 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=i23m9acz; arc=none smtp.client-ip=209.85.128.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i23m9acz" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-46e6c8bc46eso27926915e9.3 for ; Mon, 13 Oct 2025 07:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367245; x=1760972045; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8P7N+yGyf3ZHVe543mLefJ6kNjA/6azjCaZxnGN+ZPM=; b=i23m9aczsGFjsj5EmFXcy2Kiu7yBvPMTfa31e2oyEIasFPR2iIIApYdTCW/n1QfbhO AOu7PRmkgXm0a684VS+381yEorNxEXqEU8KWlwdV07sO/EQkyJoWjDgKbuVTYYYdMy+k yqjvshGJBDn1ECfzVLMNpsfyvIXwH3KD8Am6ZxmNmSA/b3SrZOglImgXxb85ryHFMFAT W/V0Lk0PEizffKeSqAQpo+ym0+/Bb++HzoXP6zUl2474PZMWFADV+RrXKSDchlNvsdEa fQjl+cxtK5W+aHBY30TB4juZr9WfxHycaJyiVvW6ybGeNT2gAnp0hlVknmrZlmR3wWth CzEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367245; x=1760972045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8P7N+yGyf3ZHVe543mLefJ6kNjA/6azjCaZxnGN+ZPM=; b=ugLygFS8h4yMrHcTlR2j3vy57Vi5iXfFfdLgyF/DAF11RyRqTzengCvj2JXHrITTUE 3XrVaabRCKPL77F3PdMS6D8gfT9I9SUwaQvsHoT6o11BpMAE2wUe6edm04um9TBZCfbb pTEWsytUfY1KuO81iKvqCC/GLkMwFTKqPSSvuZYGw3P0Sz8Qtn9ZrUfMEb6+bxuFTZIT V1x+QE/i1lpi9w4uzpUzn6W2Z5I1gVXY+ILaqajZu7P6LPaL88pnuhpEleeKwITL7KuV Xo956Z7zDlCeVy1gBcM9S4RWievh/yfRxatGFp5dmEF5DwZNbY6/6hbvt317rvVkBXQc 93JQ== X-Forwarded-Encrypted: i=1; AJvYcCV5tgNsqSCt/yqvuL85MhXl4+Rv/b/mV9Ij3eZJ859vYw6/Ltun301yRerXKFZ6GjwL6CPfIYjnJ6vzwJY=@vger.kernel.org X-Gm-Message-State: AOJu0YzH5yhxoMXmMh2JSSMO++uhSRbzo8zWJBc83QArVpvI41W3THOJ CSJFb9pVQ8AM9UZUdnFRt6FzUa6ly3Z9xm/wsxRy7O4EYn+9q5BnxRNw X-Gm-Gg: ASbGnctKG++/9E2cqvJxGyUlb0aY65iLaL+GJNJCjKt3vDl6L/Ndu8GQh4F/uB62S16 WIbgKL4IYDRrDVeTL3bJZ5jUo17yB7qkxDzJHwS2q3iMlvQoZBz7gdqWPgkXF4Ik+XFbkZAB912 Umwjhe3dhwmbbNLZcLCETYBqeCK2enj0dX3IN0FwVwLP04gOiXOJUiE51vp0BqbxOMq2p21Hcvp J7YtD6Z0OqYnv+bZAKRloTIPhMjjNOKBwFW8dmVKPnANpiu/YgYUMUj567DD0f1Jjgzkaz24+eE OCbGBKuLbpUDcuSJzMpO28fvCp1S8iMtVKcOtWjMZIlw4WZtK5txyY4zu9JqcK4zjYau7tHzbPk I3B0cE+ZxvHhOYz29imnn+413KQzBzLUS5IA= X-Google-Smtp-Source: AGHT+IHmYGHVzWzb5HwhHnvUieQF0ev9QYqkEuw6T8jpQDA2962Xt1Dg9W1OR3B1kwfzA7lEzjzxEA== X-Received: by 2002:a05:600d:8110:b0:45f:2922:2aef with SMTP id 5b1f17b1804b1-46fa9b09233mr146071455e9.28.1760367244820; Mon, 13 Oct 2025 07:54:04 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:54:04 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 23/24] net: let pp memory provider to specify rx buf len Date: Mon, 13 Oct 2025 15:54:25 +0100 Message-ID: <00426e189e98d808efb07370c6a0fc81ded1f787.1760364551.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow memory providers to configure rx queues with a specific receive buffer length. Pass it in sturct pp_memory_provider_params, which is copied into the queue, and make __netdev_queue_config() to check if it's present and apply to the configuration. This way the configured length will persist across queue restarts, and will be automatically removed once a memory provider is detached. Signed-off-by: Pavel Begunkov --- include/net/page_pool/types.h | 1 + net/core/netdev_config.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h index 1509a536cb85..be74e4aec7b5 100644 --- a/include/net/page_pool/types.h +++ b/include/net/page_pool/types.h @@ -161,6 +161,7 @@ struct memory_provider_ops; struct pp_memory_provider_params { void *mp_priv; const struct memory_provider_ops *mp_ops; + u32 rx_buf_len; }; =20 struct page_pool { diff --git a/net/core/netdev_config.c b/net/core/netdev_config.c index c5ae39e76f40..2c9b06f94e01 100644 --- a/net/core/netdev_config.c +++ b/net/core/netdev_config.c @@ -2,6 +2,7 @@ =20 #include #include +#include =20 #include "dev.h" =20 @@ -77,7 +78,7 @@ void netdev_queue_config_update_cnt(struct net_device *de= v, unsigned int txq, } } =20 -void __netdev_queue_config(struct net_device *dev, int rxq, +void __netdev_queue_config(struct net_device *dev, int rxq_idx, struct netdev_queue_config *qcfg, bool pending) { const struct netdev_config *cfg; @@ -88,18 +89,24 @@ void __netdev_queue_config(struct net_device *dev, int = rxq, =20 /* Get defaults from the driver, in case user config not set */ if (dev->queue_mgmt_ops->ndo_queue_cfg_defaults) - dev->queue_mgmt_ops->ndo_queue_cfg_defaults(dev, rxq, qcfg); + dev->queue_mgmt_ops->ndo_queue_cfg_defaults(dev, rxq_idx, qcfg); =20 /* Set config based on device-level settings */ if (cfg->rx_buf_len) qcfg->rx_buf_len =3D cfg->rx_buf_len; =20 /* Set config dedicated to this queue */ - if (rxq >=3D 0) { - const struct netdev_queue_config *user_cfg =3D &cfg->qcfg[rxq]; + if (rxq_idx >=3D 0) { + const struct netdev_queue_config *user_cfg; + struct netdev_rx_queue *rxq; =20 + user_cfg =3D &cfg->qcfg[rxq_idx]; if (user_cfg->rx_buf_len) qcfg->rx_buf_len =3D user_cfg->rx_buf_len; + + rxq =3D __netif_get_rx_queue(dev, rxq_idx); + if (rxq->mp_params.mp_ops && rxq->mp_params.rx_buf_len) + qcfg->rx_buf_len =3D rxq->mp_params.rx_buf_len; } } =20 --=20 2.49.0 From nobody Wed Dec 17 21:19:41 2025 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 A6579314A74 for ; Mon, 13 Oct 2025 14:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367250; cv=none; b=Iojx7hDinKpsNQ4iSH0jK82o1LZ85jcFdyp8jP4/W3U6fvHxPPF6OER3L0ecb2bRMt8nvLLjpXMqqJTfyiYMJm17fe/WcjDzWVImA5Tr9v07LLwxRvirossntpCeCtGxMriMNom7AMweQO8fu7iyfN9pclXvo3db8Y+UMwC3AtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367250; c=relaxed/simple; bh=8nj7s55nWrv3kfW1Lj+b1IRgHimBBeikPlUQlGK/E9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YloQxqsqOIORKIDrrU+t/bhRBTC3+PTcgqlJ/p3A8AfH5V4qWzVS1srHVkA32iE1JSMr+JnF0gwFKW/l6MtQHi+AOm9cKgwqiqZlM10wEPKbe7eOMf4K97eJLwBqkcuWcvXfheeeMVtWm2QhdRYfBfcL/jzKTB+pPFWOpkEoGgo= 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=mHPXqlsQ; arc=none smtp.client-ip=209.85.221.43 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mHPXqlsQ" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3ee130237a8so3467446f8f.0 for ; Mon, 13 Oct 2025 07:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760367247; x=1760972047; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4rMa+hYxMGJABpEUiqAoWqCld8h0vc8bkSgfbD76NHE=; b=mHPXqlsQr4UHdgi+7bVVHaCgbdxiNRDMqkMqr/BWvMoqSRzk/QiVccGwrwMkdh2JIb 85/Rmd9DWwgwgrx8tBGG7e+xK3o7AaVxoeL2fJys2W4gBjUY5zZ8pKZlPQZ+V6fbN03W puI7FjVGPDYLGsL3Z92Xf9MNRW3TX7o+G77oqRC4ai4i9CLR6gEvfBDLuu3FyGKJxCK3 YerGbQh0sUElOZbyOGL2qrkHw4InlHAH6ilqxu67NG6N3Wl/mEpyVbt7J4ymBlErop9O nhX9IpSMjyAm+Sj6m768qbBj76JFdFcdtUlXmJmItXojiMCm/kDjj5NuzAzC9KUo0c58 KvIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760367247; x=1760972047; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4rMa+hYxMGJABpEUiqAoWqCld8h0vc8bkSgfbD76NHE=; b=eFMZuJVWuXF7u/lFP4oPFxROFIl1q3dFqA/6a69pWHgWtUqwxvZqS+L9VjC6mBR4Wh Zf6IWeZG2ll1E/0y1tsSgajadthSdHQfCo8KGncTbZDeTp0uC8vHt7AvYqRyGvVxm8BQ NelLxo03d5oHDiMMJ6YgLiNhzz839NltZ9OAFvWs/bZ7feuK8F5BL5u7MAmsrAuNAWUw ya6g4px5iisoH2kwox1LfDt95Y1Vcb2x9T8IEtoML2zFZ21hITUOqSTCdvDzYTUgiBUS /zzl7eq46xridvKGGH6PyLPKLQERLFZfDqt5iyyEYj1Ee4S8fDpz1yokHqzhukhP2BWB Zf6w== X-Forwarded-Encrypted: i=1; AJvYcCXDXVso0qgbWEowafOXQNX5Kr5CAheTUPekl7WLyjlqP248gBpqxxpFtyt195AODe7oWvwRnqPOlqCloSc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+f6KX0ZV1YQzC30CqnxLEKec8mOum4F2VXAZ5ge3rFfcs/qW7 jHd8qcg8KXDjxfk8IdaJKL84nN4qmrwRtxwN3fOae8QN7yDmutqDyztE X-Gm-Gg: ASbGncvKWfMPo6rtf9JXW8yOkUQe8BRyTbq5DznAfcqN3r9K6fpl22wYqo44zRv2Rl0 pb3vbAgIs/sWWr7gfGBuGzsgYdpGPhtc5cZ7lvGj+AjDw2/ukLR0ubXwtyipCzf7CbJHhswNCRA cqWM/YS2aCk51rueh5GEh27kd7NBSnD5YD1ctozDaNtjoP10OW9T3mB+IngmTzixIjk+j27M4Rx HC2Du7E7nAdbyaBlmq0YXQWjHg6xa72PqEZ/jboneOMoqqjJYG8I1mBz1kDXu37+aTUFKVIHQKl fAMo7KzcJx6bINl4ZFD6UjntWIBjae1X2+kEIpePSfS+SvubRKjEUzwRobCPaJCBsR6vAOdaqYF 3xMfdNHIIhVTHgGsN4fiEX1YxM/6hgsOKSPw= X-Google-Smtp-Source: AGHT+IEpoY9zZ3UQGIBW1agBnvc5SnHYP477nBEWy4ZfZ4s18JUiHbQP7nwwR40939/5pAfGzkUEsg== X-Received: by 2002:a5d:5d02:0:b0:425:7c1b:9344 with SMTP id ffacd0b85a97d-42666ab87c3mr12930214f8f.15.1760367246796; Mon, 13 Oct 2025 07:54:06 -0700 (PDT) Received: from 127.com ([2620:10d:c092:600::1:eb09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm18641085f8f.40.2025.10.13.07.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Oct 2025 07:54:05 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Donald Hunter , Michael Chan , Pavan Chebbi , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joshua Washington , Harshitha Ramamurthy , Jian Shen , Salil Mehta , Jijie Shao , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Bharat Bhushan , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Ilias Apalodimas , Joe Damato , David Wei , Willem de Bruijn , Mina Almasry , Pavel Begunkov , Breno Leitao , Dragos Tatulea , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, Jonathan Corbet Subject: [PATCH net-next v4 24/24] net: validate driver supports passed qcfg params Date: Mon, 13 Oct 2025 15:54:26 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When we pass a qcfg to a driver, make sure it supports the set parameters by checking it against ->supported_ring_params. Suggested-by: Jakub Kicinski Signed-off-by: Pavel Begunkov --- net/core/dev.h | 3 +++ net/core/netdev_config.c | 26 ++++++++++++++++++++++++++ net/core/netdev_rx_queue.c | 8 +++----- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/net/core/dev.h b/net/core/dev.h index 63192dbb1895..96eae1c51328 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -103,6 +103,9 @@ int netdev_queue_config_revalidate(struct net_device *d= ev, struct netlink_ext_ack *extack); void netdev_queue_config_update_cnt(struct net_device *dev, unsigned int t= xq, unsigned int rxq); +int netdev_queue_config_validate(struct net_device *dev, int rxq_idx, + struct netdev_queue_config *qcfg, + struct netlink_ext_ack *extack); =20 /* netdev management, shared between various uAPI entry points */ struct netdev_name_node { diff --git a/net/core/netdev_config.c b/net/core/netdev_config.c index 2c9b06f94e01..99e64d942d44 100644 --- a/net/core/netdev_config.c +++ b/net/core/netdev_config.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only =20 #include +#include #include #include =20 @@ -136,6 +137,31 @@ void netdev_queue_config(struct net_device *dev, int r= xq, } EXPORT_SYMBOL(netdev_queue_config); =20 +int netdev_queue_config_validate(struct net_device *dev, int rxq_idx, + struct netdev_queue_config *qcfg, + struct netlink_ext_ack *extack) +{ + const struct netdev_queue_mgmt_ops *qops =3D dev->queue_mgmt_ops; + int err; + + if (WARN_ON_ONCE(!qops)) + return -EINVAL; + + if (!(qops->supported_ring_params & ETHTOOL_RING_USE_RX_BUF_LEN) && + qcfg->rx_buf_len && + qcfg->rx_buf_len !=3D dev->cfg_pending->rx_buf_len) { + NL_SET_ERR_MSG_MOD(extack, "changing rx-buf-len not supported"); + return -EINVAL; + } + + if (qops->ndo_queue_cfg_validate) { + err =3D qops->ndo_queue_cfg_validate(dev, rxq_idx, qcfg, extack); + if (err) + return err; + } + return 0; +} + int netdev_queue_config_revalidate(struct net_device *dev, struct netlink_ext_ack *extack) { diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c index 5ae375a072a1..a157964cf60d 100644 --- a/net/core/netdev_rx_queue.c +++ b/net/core/netdev_rx_queue.c @@ -46,11 +46,9 @@ int netdev_rx_queue_restart(struct net_device *dev, unsi= gned int rxq_idx, =20 netdev_queue_config(dev, rxq_idx, &qcfg); =20 - if (qops->ndo_queue_cfg_validate) { - err =3D qops->ndo_queue_cfg_validate(dev, rxq_idx, &qcfg, extack); - if (err) - goto err_free_old_mem; - } + err =3D netdev_queue_config_validate(dev, rxq_idx, &qcfg, extack); + if (err) + goto err_free_old_mem; =20 err =3D qops->ndo_queue_mem_alloc(dev, &qcfg, new_mem, rxq_idx); if (err) --=20 2.49.0