From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f43.google.com (mail-yx1-f43.google.com [74.125.224.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 EA3AA22F74A for ; Tue, 12 May 2026 01:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778548698; cv=none; b=FiR03rqz5nrzvFsvWfYmvUKhpRPMcnVHbxl0TqWzaJ2ViHsaIt2ACDlziMNGYG8jbAaSkyHn39hUVGIqEfEt7oKTEzVnxgvtuJxZSOHFmQy4Gm3+8OD3IOkbx2FhWhDnPuzCDK6F0h3KbAZ6zB6VHBHz0Z2G7qoFYpKel/PU5II= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778548698; c=relaxed/simple; bh=FkpSFBB/bX+rp9bKDxdBiyERkKc6SlIj+UXp0PrCs9o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FImuNvs9H4+e2lnbUfvpgMhp/nE9NetnGTmO7L1V2PZ6/7X+6b2QtYUVt0qt0JK7Z1yc/qyDu2e2JLlb+XSKmpR7ri0Tf79xmonAxpOGg6Ip/jQnvCo3OT8jZ6lPJguQchZDlcjYB+dVGsvzUYW/FSBWfuubpGPmWO4zg6qDCso= 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=O6OLNnaJ; arc=none smtp.client-ip=74.125.224.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="O6OLNnaJ" Received: by mail-yx1-f43.google.com with SMTP id 956f58d0204a3-65c5361142fso5339494d50.0 for ; Mon, 11 May 2026 18:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778548695; x=1779153495; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HLDMf75sSoZOlrolBDWd/AGNeQyGKtHDPvvwXPguYtg=; b=O6OLNnaJx+MlTLz/ACEqApos1UX6Lf8jPn6qF2GzWoOG7H3kLU2kMTVP9RetkuoDXw m2sov/ke7KXA/8S7iQnIWncNcOezzK0uPuMA9T1RGmbqSufQV8snuc5vzWruiJCtQa3O bsTPCZyPhtqtbf1CteG8pmrqXdFvguGGZB+dbdkGr4Sx4o0bUooZEYks0zmyK3gRN2Cl Dq6eQKCERmJphsLVqMHcFSz/DnY9+M9bsVQPXZV3udWhJiQ8TPJ7ZPLPXVF3zFiuVvB/ WF5M8HakH6sIHLNCJYcC1XpY+Tzka2RS0koVy+SPnFBkGEBGTB0DQcV86Ja7q71vuL5B R3Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778548695; x=1779153495; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=HLDMf75sSoZOlrolBDWd/AGNeQyGKtHDPvvwXPguYtg=; b=qhchXVchR8W9Q5n5Cd8yoVKvAeEzSZ2buFjMwUJ98Iptm18/bYTqjLQf1TXifsRHbp jaP6z0m4fUccg6jfdmFnVn2WAWG9LLJYwWrNtOHIqpPntVO7FbVKQuvR+jELYUz/nr1N G8sg/xYpjS1+2Sjh4pfhV5RWUVTuXEM1CnBGTu1tT/cj0wu9w8aig/rZLmC9vqRhN26B gzYUNSRqzGcVAssh9Y7b3L6jBRo/tJo0AD4lhJsawQce/3ASwqQyb4vYJm889M+HGA2t P/Of7SWjheUBnAIAw5ghw7G3kYad5cpk5ZIMGGlkGwbNfvbl3BvpSdVBfh78IRgVMdWP NLbA== X-Forwarded-Encrypted: i=1; AFNElJ/5yHJf6bMiwZYH/IfXCy5r8Z1aRVAYlecHhXXTd+rQyM2hrm+OBX+baAKzBnASdjor+cuKl3o=@vger.kernel.org X-Gm-Message-State: AOJu0YzFNr8GPTPxHuUdS0jSuuEvK2Q9xWbgubfeNG3D0YlWuyBx0orG WwgH4K0S2xdGtN+Y8+iCJfeeHhTHgs9NwH0FKbYXqPrMQEA93CVRKiPs X-Gm-Gg: Acq92OHkAfOgThAEW7qRAoCMWpsAfZeAbzgUw62GzO/W0ERm7Pkgh2vCxzgarZxz8iV YdSKB3SBeFYJhTrrkUk2x76s7pN8T6u6IVmUt4YL0NTt+DYL60dr6EGMODb373DQMkFOlbnsDMj tYbf8fni95V70qUew3K5M6G6+N/sOL/i41Q7FNuNqrB98izjRn2FKMVcqJrB+RnCjcvjCFa96Yf 442CqVzkgoHvMKE07mwnJmC6oHv/rh/H0SipopNQjgJroXNy6z6UDVhaopKs1IGpQPLOspQgYfz 8QomKXgo5OUjz2h6xFvb7OA4amWgHoJA4qOjQLorACk6yunXdwLQG0Se/ybgRyJKQY2Rxt+GM8+ 7pr4ydElS8JKngF1PPA+gTfKtAq7xn6WL0IN/mgl2R94jP2fTvwmyrWyDXoIO1zC8eCt4d20S9P 5Sl6qMUIzgNt0XiQ32sTrSAg== X-Received: by 2002:a05:690c:389:b0:7bd:6a98:58d7 with SMTP id 00721157ae682-7c1059649cbmr113947997b3.38.1778548694820; Mon, 11 May 2026 18:18:14 -0700 (PDT) Received: from localhost ([2a03:2880:f806:16::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7c535f8e757sm5443377b3.34.2026.05.11.18.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 18:18:14 -0700 (PDT) From: Bobby Eshleman Date: Mon, 11 May 2026 18:17:56 -0700 Subject: [PATCH net-next v4 2/8] net: netkit: declare NETMEM_TX_NO_DMA mode Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260511-tcp-dm-netkit-v4-2-841b78b99d74@meta.com> References: <20260511-tcp-dm-netkit-v4-0-841b78b99d74@meta.com> In-Reply-To: <20260511-tcp-dm-netkit-v4-0-841b78b99d74@meta.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Alex Shi , Yanteng Si , Dongliang Mu , Michael Chan , Pavan Chebbi , Joshua Washington , Harshitha Ramamurthy , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Daniel Borkmann , Nikolay Aleksandrov , Shuah Khan , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Alex Shi , Yanteng Si , Dongliang Mu , Michael Chan , Pavan Chebbi , Joshua Washington , Harshitha Ramamurthy , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Alexander Duyck , kernel-team@meta.com, Daniel Borkmann , Nikolay Aleksandrov , Shuah Khan Cc: dw@davidwei.uk, sdf.kernel@gmail.com, mohsin.bashr@gmail.com, willemb@google.com, jiang.kun2@zte.com.cn, xu.xin16@zte.com.cn, wang.yaxin@zte.com.cn, netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Stanislav Fomichev , Mina Almasry , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Bobby Eshleman X-Mailer: b4 0.14.3 From: Bobby Eshleman Some virtual devices like netkit (or ifb) never DMA and never touch frag contents, they just forward the skb to another device. They are unable to forward unreadable skbs, however, because they fail to pass TX validation checks on dev->netmem_tx. The existing two-state NETMEM_TX_NONE / NETMEM_TX_DMA doesn't give the TX validator enough information to differentiate devices that will attempt DMA on the unreadable skb from those that will simply route it untouched. Add a third mode to the enum so drivers can indicate 1) if they have netmem TX support, and 2) if they do, whether they are DMA-capable: NETMEM_TX_NO_DMA - pass-through, device never DMAs Widen dev->netmem_tx from a 1-bit field to 2 bits to fit the new value, and declare netkit as NETMEM_TX_NO_DMA. Devmem TX support over these devices comes in a follow-up patch. Acked-by: Stanislav Fomichev Signed-off-by: Bobby Eshleman --- Changes in v3: - net_cachelines/net_device.rst: align the netmem_tx row's type column with the rest of the table by using "unsigned_long:2" instead of "unsigned long:2" - Split this into a distinct patch (Jakub) --- Documentation/networking/net_cachelines/net_device.rst | 2 +- Documentation/networking/netmem.rst | 3 +++ Documentation/translations/zh_CN/networking/netmem.rst | 3 +++ drivers/net/netkit.c | 1 + include/linux/netdevice.h | 3 ++- 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Documentation/networking/net_cachelines/net_device.rst index 1c19bb7705df..7b3392553fd6 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -10,7 +10,7 @@ Type Name fastpath_tx_acce =================================== =========================== =================== =================== =================================================================================== unsigned_long:32 priv_flags read_mostly __dev_queue_xmit(tx) unsigned_long:1 lltx read_mostly HARD_TX_LOCK,HARD_TX_TRYLOCK,HARD_TX_UNLOCK(tx) -unsigned long:1 netmem_tx:1; read_mostly +unsigned_long:2 netmem_tx:2; read_mostly char name[16] struct netdev_name_node* name_node struct dev_ifalias* ifalias diff --git a/Documentation/networking/netmem.rst b/Documentation/networking/netmem.rst index 5ccadba4f373..217869d1108d 100644 --- a/Documentation/networking/netmem.rst +++ b/Documentation/networking/netmem.rst @@ -99,3 +99,6 @@ Driver TX Requirements appropriate mode: - `NETMEM_TX_DMA`: for physical devices that perform DMA. + + - `NETMEM_TX_NO_DMA`: for virtual or passthrough devices that do + not DMA, but still support handling of netmem-backed skbs. diff --git a/Documentation/translations/zh_CN/networking/netmem.rst b/Documentation/translations/zh_CN/networking/netmem.rst index 9c84423b7528..320f3eacf51b 100644 --- a/Documentation/translations/zh_CN/networking/netmem.rst +++ b/Documentation/translations/zh_CN/networking/netmem.rst @@ -92,3 +92,6 @@ dma-mapping API 去处理。 2. 驱动程序应将 `netdev->netmem_tx` 设置为适当的模式: - `NETMEM_TX_DMA`:适用于执行 DMA 的物理设备。 + + - `NETMEM_TX_NO_DMA`:适用于不执行 DMA 的虚拟或透传设备,但仍支持 + 处理 netmem 支持的 skb。 diff --git a/drivers/net/netkit.c b/drivers/net/netkit.c index 5e2eecc3165d..0ad6a806d7d5 100644 --- a/drivers/net/netkit.c +++ b/drivers/net/netkit.c @@ -466,6 +466,7 @@ static void netkit_setup(struct net_device *dev) dev->priv_flags |= IFF_NO_QUEUE; dev->priv_flags |= IFF_DISABLE_NETPOLL; dev->lltx = true; + dev->netmem_tx = NETMEM_TX_NO_DMA; dev->netdev_ops = &netkit_netdev_ops; dev->ethtool_ops = &netkit_ethtool_ops; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a54a37fab8d9..8ece36815ff9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1791,6 +1791,7 @@ enum netdev_stat_type { enum netmem_tx_mode { NETMEM_TX_NONE, /* no netmem TX support */ NETMEM_TX_DMA, /* DMA-capable netmem TX (real HW) */ + NETMEM_TX_NO_DMA, /* no DMA, e.g. passthrough for virtual devs */ }; enum netdev_reg_state { @@ -2137,7 +2138,7 @@ struct net_device { struct_group(priv_flags_fast, unsigned long priv_flags:32; unsigned long lltx:1; - unsigned long netmem_tx:1; + unsigned long netmem_tx:2; ); const struct net_device_ops *netdev_ops; const struct header_ops *header_ops; -- 2.53.0-Meta