From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f47.google.com (mail-yx1-f47.google.com [74.125.224.47]) (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 33805275AE4 for ; Tue, 12 May 2026 01:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778548698; cv=none; b=eTtQBLFbUeaLH9WGcht18xjQsnMbPCZzL3M3nZaxV2Meu6Dtxen3Lk5SozLuRrmKB2fETxxufjrM0ppMbaoOx44IGliFP59C4ctGi0GxT+Dlsg9nnMrWa/sLfK0FdY+9XhcjiBJkTAox3vDuLBmqWeTa8djy2fjg2X3z34UMNIg= 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.47 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-f47.google.com with SMTP id 956f58d0204a3-65c2cd216c9so4806233d50.3 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=UAM+gT7Lt9Ru0tuikRaz9k90T9JVEpyrqW6fTLzx16AoDFU/E7m6RzV9VxaBR6lUm+ bqCPW7T0RJtuPSItxSBQ6CYpWDVGIxvg8MGuEpA6fjJ1DF9r8FP9DT/5BRu23+CwNMjT mVm0Bk13W7w8tdWHrSMTO5OqtBZ2pqCUTsyVRVEhh8prrrg6rmE8Va/VX0IKYQJ+yf5Z qE/xOMSyn875zh6pD0CGFvE/teTAgpqyZrlvR4dFyk5S1yoOpVr200Mhdcc7LHKbG4q3 35tvzkeHQQJmfievHOEqAHE9WIq+T2wBdDRU+qzOAcD3V6ZJgv7te6/jM56UYApYcQhB F43g== X-Forwarded-Encrypted: i=1; AFNElJ8HEK0sBz0J7cWVLLrxuPsA/K2OndYAQdPMRQunEi0kmhOTAhjfyZF5mnpNUP6hQwpaHSQMOuaLgRQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzU0vPeG/wtFxZzpC5a6k9wtTd6bBEucv1l5dNdhBGqwLilcDSN WvK+wocGHMyB/GunvyP0MCmSJb4mUtZhsD9Y/PcNJebp5FhmmE7J31Ir X-Gm-Gg: Acq92OHUWeFW/hUGAGnEz2PHSsoAJxnCwIuHjAuqlq/qHmU+Vrmbj01HlzOAId/MhQF n8t9ErLhrs3FuK2w0duRpHHGN27k/2Aec1y2ikWjXxh7VX6o4TNu1rVqywyq/Fbj3+Oj9+DNf05 FglpR55ShnH8ESg95E7pYQ80YEjC1Ri0Sua1LW/DPcn5SYXRTVf8pyS8rlPpaKRzMmQrpEvTfeL 2topzodJRauiO1QG6nY+62XDTwJs4ZGIe3D3gvxLHLqnUfbD04eA0hxou8TWwQ6421YIIHAi7Pf GGE1GUau67Au89JxKjlaY8hPSPGWStyrFLVIZiV2E1qjZQ/G5i8Ty6MEW9xDysGDPWFnvr/1SW1 JZXcjRP4v4oBV8uNfb/FTiZDwEDBOfbfp6L9lSJwz6JMWUmVXyyv2DB09WjCsA6ew12eY984bEy xFxAzCxFufM9YP5Cdje0JPyg== 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: linux-doc@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