From patchwork Fri Jan 3 15:03:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925648 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 6E4CC442C; Fri, 3 Jan 2025 15:03:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916631; cv=none; b=CfmH3V0JeBk0OwHtHOzhS0h87ue1/omTCmXEuegTx7OtvsG9leGsb06YlGmCz63oNC9KZrOkxixPpKEFDrfUORvT+fHig//PkuGr1FOgWFUpyzQgQOQ0xqYbs3vPNqPC5t7AypG3aJJ1HKh7wvEPwCWS2yd6O3VbCN8Dpud4Ipk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916631; c=relaxed/simple; bh=7WlBGENIy2oPZVIfFIEmJXuBuP8Ivq681Nkvtdqy9sA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mDjgfj+rSMf+QrztcaaP+bcE4/9qG+1dtn6+G94P6a5qrTTtoZs4zDG8cD1ruy63untGvbQ2rfbfFQIiCN6Apv+0PhBmpBCLx10cbNALKxW9Tpj2V1raTEpiUsCg3xfvQPpBFoyRv/yTrnEcfz0EPuf6VCnWP7X0S6xKyokjoyI= 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=U3EqT//s; arc=none smtp.client-ip=209.85.214.176 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="U3EqT//s" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21670dce0a7so94692895ad.1; Fri, 03 Jan 2025 07:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916629; x=1736521429; 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=qURv+YWuHhVC9usfYzqIZMJoKHODK3qRvWWEegQVoXI=; b=U3EqT//s91tqH2aV4Wa2ma4aDB+wKmA4M6evE8V2pDuORk+8XqYFlYkFa6WID18F1p LsN70ieqi33dwPEEgSe0Y+iApU+qeJ6T0OY3PpgcFADLTF1Iq54eV3yOWG/MtCOidGIE nPWJTeY61TMx3NYXn7Hfdl4WzCbrjf4ApiEPmvLmJ6LHGIwYXjF3yf72zsvGqNWCj7d5 i08G+gDWUBYdHnD1ewtltGs9v2B6kXRsJSMcKCf0bmsUwfa404E+YokVjGSFrfJ3yEtb NSJgv4CuO1xH/VC4EsXnJKz7yTPxVOJjD8wg28NXuykvfwBzSJny95KW1eNmnhJfy1lk pZrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916629; x=1736521429; 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=qURv+YWuHhVC9usfYzqIZMJoKHODK3qRvWWEegQVoXI=; b=ZT1S1dGo+f82oFNt3nGgmxTJDXAo0JgWJ7fgyT8M3yU/8HLwpKEYztG/AxumUF+k8S iB/uzpSX9cb0Tw+CQYlNVqjur38LKj+kCHYBZ+N3XSKGyUh6KFEEwO11tOPeiZzZosNQ RXzZwdIsGBPGpflt4lfcPJTqwz5+ftwd22Jt/tCtn27Au+PSYEqNRgsjk6VqJ+6Ml/WL z+rz1veKObFixQ0SkAN0QexL5ds8U7EB3WkaX3aBtYzyqKQ9Ea3eiHfH3VJovpTBM6ki N7d5dRSpa7n9QLExwe2vQPFnOjJVHbd6nNkeYm32a6QeDOItiC7DhoAo1N5MF4cpwiM+ 1jMQ== X-Forwarded-Encrypted: i=1; AJvYcCU0Qwl4n/D77slV52TGKM1G5PwaniTBYGHeH0hN7VHCz3GWmWzBo+GlstjbIy9Jw0JHcQdJcnM4@vger.kernel.org, AJvYcCW6ui4Mmzo7Aqt3PK8++S4FV5NY1pvMUQ+xj/XKOKAlbC/OVt0QRV+2k7qlMDe/JSigQwT53vGa1iA=@vger.kernel.org X-Gm-Message-State: AOJu0YwYJrMCiUOva//XXl0wNiFmfTxg5pDVPwTdFf2OjiikrD6s4elH UXu9YzPwuUjoA9VERxQJZH5gZo52xImnsMeTxlSxoagMn/l0QyLM X-Gm-Gg: ASbGncvNhCkHPf39+A/p9SZk6Bc/hY4EO5ZMm7P2WK48prVrw6bR8tDZbIo0ODiDAi9 8kxybu2JwOQAWZCYlXqzlO2q7mLDWuDocdV1qkg1b1qrqs39XiUonRuWcNvTEHokCxpISg1frgj nIQ4qQclArghU+gaas3bRRclaWOYV3sIURLGpUuIpA4WQOg3sUVRr7xYsYBhrSz9HYVxuOilUyr WuSV+tZOxcaMkA8nkubVq+UwnvjLdzcU+97qyyXGMKCkw== X-Google-Smtp-Source: AGHT+IEKbKSiMUJ711ZK8IL+7z7h3fbU8nBtMpx9rbNPnFsaEiA/bR0ady7uNzOW0h6l2O5/0knKLw== X-Received: by 2002:a17:902:e809:b0:215:603e:2141 with SMTP id d9443c01a7336-219e6ea0218mr745619905ad.19.1735916628490; Fri, 03 Jan 2025 07:03:48 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:03:47 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v7 01/10] net: ethtool: add hds_config member in ethtool_netdev_state Date: Fri, 3 Jan 2025 15:03:16 +0000 Message-Id: <20250103150325.926031-2-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org When tcp-data-split is UNKNOWN mode, drivers arbitrarily handle it. For example, bnxt_en driver automatically enables if at least one of LRO/GRO/JUMBO is enabled. If tcp-data-split is UNKNOWN and LRO is enabled, a driver returns ENABLES of tcp-data-split, not UNKNOWN. So, `ethtool -g eth0` shows tcp-data-split is enabled. The problem is in the setting situation. In the ethnl_set_rings(), it first calls get_ringparam() to get the current driver's config. At that moment, if driver's tcp-data-split config is UNKNOWN, it returns ENABLE if LRO/GRO/JUMBO is enabled. Then, it sets values from the user and driver's current config to kernel_ethtool_ringparam. Last it calls .set_ringparam(). The driver, especially bnxt_en driver receives ETHTOOL_TCP_DATA_SPLIT_ENABLED. But it can't distinguish whether it is set by the user or just the current config. When user updates ring parameter, the new hds_config value is updated and current hds_config value is stored to old_hdsconfig. Driver's .set_ringparam() callback can distinguish a passed tcp-data-split value is came from user explicitly. If .set_ringparam() is failed, hds_config is rollbacked immediately. Suggested-by: Jakub Kicinski Reviewed-by: Jakub Kicinski Signed-off-by: Taehee Yoo --- v7: - Add review tag from Jakub. - Add dev_xdp_sb_prog_count(). v6: - use hds_config instead of using tcp_data_split_mod. v5: - Patch added. include/linux/ethtool.h | 2 ++ include/linux/netdevice.h | 1 + net/core/dev.c | 12 ++++++++++++ net/ethtool/rings.c | 12 ++++++++++++ 4 files changed, 27 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index f711bfd75c4d..4e451084d58a 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1134,12 +1134,14 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, * @rss_ctx: XArray of custom RSS contexts * @rss_lock: Protects entries in @rss_ctx. May be taken from * within RTNL. + * @hds_config: HDS value from userspace. * @wol_enabled: Wake-on-LAN is enabled * @module_fw_flash_in_progress: Module firmware flashing is in progress. */ struct ethtool_netdev_state { struct xarray rss_ctx; struct mutex rss_lock; + u8 hds_config; unsigned wol_enabled:1; unsigned module_fw_flash_in_progress:1; }; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 2593019ad5b1..2b06450cacd4 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4084,6 +4084,7 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog); u8 dev_xdp_prog_count(struct net_device *dev); int dev_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf); +u8 dev_xdp_sb_prog_count(struct net_device *dev); u32 dev_xdp_prog_id(struct net_device *dev, enum bpf_xdp_mode mode); u32 dev_get_min_mp_channel_count(const struct net_device *dev); diff --git a/net/core/dev.c b/net/core/dev.c index c7f3dea3e0eb..bc98f4920e12 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9480,6 +9480,18 @@ u8 dev_xdp_prog_count(struct net_device *dev) } EXPORT_SYMBOL_GPL(dev_xdp_prog_count); +u8 dev_xdp_sb_prog_count(struct net_device *dev) +{ + u8 count = 0; + int i; + + for (i = 0; i < __MAX_XDP_MODE; i++) + if (dev->xdp_state[i].prog && + !dev->xdp_state[i].prog->aux->xdp_has_frags) + count++; + return count; +} + int dev_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf) { if (!dev->netdev_ops->ndo_bpf) diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index b7865a14fdf8..b2a2586b241f 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -203,6 +203,7 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) dev->ethtool_ops->get_ringparam(dev, &ringparam, &kernel_ringparam, info->extack); + kernel_ringparam.tcp_data_split = dev->ethtool->hds_config; ethnl_update_u32(&ringparam.rx_pending, tb[ETHTOOL_A_RINGS_RX], &mod); ethnl_update_u32(&ringparam.rx_mini_pending, @@ -225,6 +226,14 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) if (!mod) return 0; + if (kernel_ringparam.tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + dev_xdp_sb_prog_count(dev)) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_RINGS_TCP_DATA_SPLIT], + "tcp-data-split can not be enabled with single buffer XDP"); + return -EINVAL; + } + /* ensure new ring parameters are within limits */ if (ringparam.rx_pending > ringparam.rx_max_pending) err_attr = tb[ETHTOOL_A_RINGS_RX]; @@ -252,6 +261,9 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) ret = dev->ethtool_ops->set_ringparam(dev, &ringparam, &kernel_ringparam, info->extack); + if (!ret) + dev->ethtool->hds_config = kernel_ringparam.tcp_data_split; + return ret < 0 ? ret : 1; } From patchwork Fri Jan 3 15:03:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925649 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 435611CCB4B; Fri, 3 Jan 2025 15:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916641; cv=none; b=qG1397/X+oupWBXWUkY/kZqLCdwxIfXuL33Ldyi4SGh+KfZasHqKVPELTiutkQQumqEPPBMhQGwrq1vPcY5El01rasp6cxN70KydtiGdH36ojDUEZ3m+NRE538vCw0fcMcvuL9a/yfY2qf1hMPPh03z0CQKsQ4fGOi9HSbiOFaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916641; c=relaxed/simple; bh=pD1ulSZCWHUXH2UcLaSHF9kAONDuYEHjcJ/vQNXwcLs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FMA1O8vRbOdWAg1MazKbMnRM3cAXuxB+HF/fUywWcUqv287XqzPWdKjtoFxAoYmSVCjCeYHZhVT4vduE3o1jmRhOPjNSXIKRIvBOTNnbkHNUwzPzRCRC6+QiAMJZYC7kJwgvfyQdvoIBP/M8cRU89LnYoCquAmwdhJmDPGRCV3g= 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=c7UGeKcs; arc=none smtp.client-ip=209.85.214.180 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="c7UGeKcs" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-21636268e43so88679505ad.2; Fri, 03 Jan 2025 07:03:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916638; x=1736521438; 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=WzfA2V84zuxacl6AnAvtutrNr3hbcEFs/i1nlzzkSfo=; b=c7UGeKcs/m6MhZZf+EEDM4zNjX7hEb+admbqIdIgUxWvQE5En/CS/ykbHLpXHh6+OZ VtzTn22Z+D+v36Rz/ITaZDcOMY98BWR1x2l1FrrWtvbFNOQVZ/FhPuGzyNOOXcrnSsOD 2/Dtrwe223hAMZr+G/ofOsZH01Z/o65qatWAFd1WpvltCPvnH7My9veaR//D1mPAYPKM H9XwqZNJOvlVw15BFHtp+HuCSysHasI7adizJvjQLl3n9oo54aZ72CnKLOYYTXNbfqwW Qhq1MpFEUHuraG5p31vKpXP0f/rwqOGuBJxdl9GosafcGb5S5aHoMxp/2uplPdJYrUnx HHHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916638; x=1736521438; 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=WzfA2V84zuxacl6AnAvtutrNr3hbcEFs/i1nlzzkSfo=; b=ar9C1J9T0Hj2p0gyUb9G7d+yBvpHn8kCa9XK3VeikC2xQ8V7Zz2J6XU7OqK86BlEYe YWZTMI//Jw1ON0XsFKx5geTDz3sDpavlkpV6Zyc1LWNOQAmN4G0LOCTtsaIg5l76jrPM EYSWFcBHp42LScF+l7bw7d0DX/SgINVJJD+1tJJQRpO/cihrompMjlgCPTg2Usjd1R3w B/zBQmrYYGzF+8N+28/aM5NCSkz6Yk2gFldnorQYHobiyGP5K1uDWuV0r+BADI4XzKXf VEp/mWptqshxRN4qC0SZ9a0pE5h3QyCj3pSKLylvKBWBBBwQ0Bn1y0E1wmKjOYwJ0fYG JAPg== X-Forwarded-Encrypted: i=1; AJvYcCWEKS/GohA+WWpwtBlr1+caB5wjbvCTJF09R25BXmf4PSSIS7j8cJ0FTW260Z2oZQwCulx6G/WX@vger.kernel.org, AJvYcCXtDpbBStPxMtp29sMfKU8VMHthEJDEWyRZeJIkKKDsQt3Y5xvjGgI9O0x/A3oZst8jgCf3U9nZBnY=@vger.kernel.org X-Gm-Message-State: AOJu0YwJLDEaGmhde9WC/YjsXiO4Khyey7kVMOjgmYYYDF9mg3JgIDPI ojxxtqXfum+I5jD8RWVu0+gXSJl/Pk9KRqaHI1maQo8PL5EVYfEk X-Gm-Gg: ASbGncsJ9HqZ6FkC3ch7+4PNPstW4S/vmK9Mbf8j8cioUXLQxgjioYAdl6ajpsgL26X +tfOzJHaq3LxwjyLNQ16BQHmlDxLmL1VHar7MwG1QKqLn2/q3WmY5Dt/tbEFwlyNisNPOHOF9Vg Oo8/HtC5EWhMmisMhZsrorOAlb8P89XNv5+4EolH4XDxpOnOwSIBtXINlcC9PqEAZh3yyJXlPkD j7MghnXvIrLmMoC80ACr90lTSlqzJXB799IdcKPZ0Baew== X-Google-Smtp-Source: AGHT+IHLKtMfojgIUEDdLWtjVYURPCJKK+xU8AP9DpnUFwZPG4htVN5TnXGBvGBpYojfHKF4Q5WOoA== X-Received: by 2002:a17:903:2cc:b0:216:4e9f:4ed4 with SMTP id d9443c01a7336-219e6f11809mr738439585ad.36.1735916637268; Fri, 03 Jan 2025 07:03:57 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:03:56 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v7 02/10] net: ethtool: add support for configuring hds-thresh Date: Fri, 3 Jan 2025 15:03:17 +0000 Message-Id: <20250103150325.926031-3-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The hds-thresh option configures the threshold value of the header-data-split. If a received packet size is larger than this threshold value, a packet will be split into header and payload. The header indicates TCP and UDP header, but it depends on driver spec. The bnxt_en driver supports HDS(Header-Data-Split) configuration at FW level, affecting TCP and UDP too. So, If hds-thresh is set, it affects UDP and TCP packets. Example: # ethtool -G hds-thresh # ethtool -G enp14s0f0np0 tcp-data-split on hds-thresh 256 # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... HDS thresh: 1023 Current hardware settings: ... TCP data split: on HDS thresh: 256 The default/min/max values are not defined in the ethtool so the drivers should define themself. The 0 value means that all TCP/UDP packets' header and payload will be split. Tested-by: Stanislav Fomichev Signed-off-by: Taehee Yoo --- v7: - Do not export dev_xdp_sb_prog_count(). - Remove dev_xdp_sb_prog_count(). - Use NL_SET_ERR_MSG_ATTR() instead of NL_SET_ERR_MSG(). - Change location of hds-thresh size check logic. v6: - Update ethtool_netlink_generated.h - Use "HDS" instead of "HEADER_DATA_SPLIT" - Add Test tag from Andy. v5: - No changes. v4: - Fix 80 charactor wrap. - Rename from tcp-data-split-thresh to header-data-split-thresh - Add description about overhead of HDS. - Add ETHTOOL_RING_USE_HDS_THRS flag. - Add dev_xdp_sb_prog_count() helper. - Add Test tag from Stanislav. v3: - Fix documentation and ynl - Update error messages - Validate configuration of tcp-data-split and tcp-data-split-thresh v2: - Patch added. Documentation/netlink/specs/ethtool.yaml | 8 +++++++ Documentation/networking/ethtool-netlink.rst | 10 ++++++++ include/linux/ethtool.h | 8 +++++++ .../uapi/linux/ethtool_netlink_generated.h | 2 ++ net/ethtool/netlink.h | 2 +- net/ethtool/rings.c | 24 +++++++++++++++++-- 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 60f85fbf4156..66be04013048 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -332,6 +332,12 @@ attribute-sets: - name: tx-push-buf-len-max type: u32 + - + name: hds-thresh + type: u32 + - + name: hds-thresh-max + type: u32 - name: mm-stat @@ -1777,6 +1783,8 @@ operations: - rx-push - tx-push-buf-len - tx-push-buf-len-max + - hds-thresh + - hds-thresh-max dump: *ring-get-op - name: rings-set diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index a7ba6368a4d5..ef1d1750f960 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -899,6 +899,10 @@ Kernel response contents: ``ETHTOOL_A_RINGS_RX_PUSH`` u8 flag of RX Push mode ``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN`` u32 size of TX push buffer ``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX`` u32 max size of TX push buffer + ``ETHTOOL_A_RINGS_HDS_THRESH`` u32 threshold of + header / data split + ``ETHTOOL_A_RINGS_HDS_THRESH_MAX`` u32 max threshold of + header / data split ======================================= ====== =========================== ``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` indicates whether the device is usable with @@ -941,10 +945,12 @@ Request 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_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 ``ETHTOOL_A_RINGS_RX_PUSH`` u8 flag of RX Push mode ``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN`` u32 size of TX push buffer + ``ETHTOOL_A_RINGS_HDS_THRESH`` u32 threshold of header / data split ==================================== ====== =========================== Kernel checks that requested ring sizes do not exceed limits reported by @@ -961,6 +967,10 @@ A bigger CQE can have more receive buffer pointers, and in turn the NIC can transfer a bigger frame from wire. Based on the NIC hardware, the overall completion queue size can be adjusted in the driver if CQE size is modified. +``ETHTOOL_A_RINGS_HDS_THRESH`` specifies the threshold value of +header / data split feature. If a received packet size is larger than this +threshold value, header and data will be split. + CHANNELS_GET ============ diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 4e451084d58a..8bab30e91022 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -78,6 +78,8 @@ enum { * @cqe_size: Size of TX/RX completion queue event * @tx_push_buf_len: Size of TX push buffer * @tx_push_buf_max_len: Maximum allowed size of TX push buffer + * @hds_thresh: Threshold value of header-data-split-thresh + * @hds_thresh_max: Maximum supprted threshold of header-data-split-thresh */ struct kernel_ethtool_ringparam { u32 rx_buf_len; @@ -87,6 +89,8 @@ struct kernel_ethtool_ringparam { u32 cqe_size; u32 tx_push_buf_len; u32 tx_push_buf_max_len; + u32 hds_thresh; + u32 hds_thresh_max; }; /** @@ -97,6 +101,7 @@ struct kernel_ethtool_ringparam { * @ETHTOOL_RING_USE_RX_PUSH: capture for setting rx_push * @ETHTOOL_RING_USE_TX_PUSH_BUF_LEN: capture for setting tx_push_buf_len * @ETHTOOL_RING_USE_TCP_DATA_SPLIT: capture for setting tcp_data_split + * @ETHTOOL_RING_USE_HDS_THRS: capture for setting header-data-split-thresh */ enum ethtool_supported_ring_param { ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0), @@ -105,6 +110,7 @@ enum ethtool_supported_ring_param { ETHTOOL_RING_USE_RX_PUSH = BIT(3), ETHTOOL_RING_USE_TX_PUSH_BUF_LEN = BIT(4), ETHTOOL_RING_USE_TCP_DATA_SPLIT = BIT(5), + ETHTOOL_RING_USE_HDS_THRS = BIT(6), }; #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) @@ -1134,6 +1140,7 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, * @rss_ctx: XArray of custom RSS contexts * @rss_lock: Protects entries in @rss_ctx. May be taken from * within RTNL. + * @hds_thresh: HDS Threshold value. * @hds_config: HDS value from userspace. * @wol_enabled: Wake-on-LAN is enabled * @module_fw_flash_in_progress: Module firmware flashing is in progress. @@ -1141,6 +1148,7 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, struct ethtool_netdev_state { struct xarray rss_ctx; struct mutex rss_lock; + u32 hds_thresh; u8 hds_config; unsigned wol_enabled:1; unsigned module_fw_flash_in_progress:1; diff --git a/include/uapi/linux/ethtool_netlink_generated.h b/include/uapi/linux/ethtool_netlink_generated.h index 43993a2d68e5..2e17ff348f89 100644 --- a/include/uapi/linux/ethtool_netlink_generated.h +++ b/include/uapi/linux/ethtool_netlink_generated.h @@ -155,6 +155,8 @@ enum { ETHTOOL_A_RINGS_RX_PUSH, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, + ETHTOOL_A_RINGS_HDS_THRESH, + ETHTOOL_A_RINGS_HDS_THRESH_MAX, __ETHTOOL_A_RINGS_CNT, ETHTOOL_A_RINGS_MAX = (__ETHTOOL_A_RINGS_CNT - 1) diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 0a09298fff92..c523b763efa3 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -456,7 +456,7 @@ extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANT extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1]; extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_FLAGS + 1]; extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_HEADER + 1]; -extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX + 1]; +extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_HDS_THRESH_MAX + 1]; extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEADER + 1]; extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1]; extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1]; diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index b2a2586b241f..9236de041271 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -61,7 +61,9 @@ static int rings_reply_size(const struct ethnl_req_info *req_base, nla_total_size(sizeof(u8)) + /* _RINGS_TX_PUSH */ nla_total_size(sizeof(u8))) + /* _RINGS_RX_PUSH */ nla_total_size(sizeof(u32)) + /* _RINGS_TX_PUSH_BUF_LEN */ - nla_total_size(sizeof(u32)); /* _RINGS_TX_PUSH_BUF_LEN_MAX */ + nla_total_size(sizeof(u32)) + /* _RINGS_TX_PUSH_BUF_LEN_MAX */ + nla_total_size(sizeof(u32)) + /* _RINGS_HDS_THRESH */ + nla_total_size(sizeof(u32)); /* _RINGS_HDS_THRESH_MAX*/ } static int rings_fill_reply(struct sk_buff *skb, @@ -108,7 +110,12 @@ static int rings_fill_reply(struct sk_buff *skb, (nla_put_u32(skb, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, kr->tx_push_buf_max_len) || nla_put_u32(skb, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN, - kr->tx_push_buf_len)))) + kr->tx_push_buf_len))) || + ((supported_ring_params & ETHTOOL_RING_USE_HDS_THRS) && + (nla_put_u32(skb, ETHTOOL_A_RINGS_HDS_THRESH, + kr->hds_thresh) || + nla_put_u32(skb, ETHTOOL_A_RINGS_HDS_THRESH_MAX, + kr->hds_thresh_max)))) return -EMSGSIZE; return 0; @@ -130,6 +137,7 @@ const struct nla_policy ethnl_rings_set_policy[] = { [ETHTOOL_A_RINGS_TX_PUSH] = NLA_POLICY_MAX(NLA_U8, 1), [ETHTOOL_A_RINGS_RX_PUSH] = NLA_POLICY_MAX(NLA_U8, 1), [ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN] = { .type = NLA_U32 }, + [ETHTOOL_A_RINGS_HDS_THRESH] = { .type = NLA_U32 }, }; static int @@ -155,6 +163,14 @@ ethnl_set_rings_validate(struct ethnl_req_info *req_info, return -EOPNOTSUPP; } + if (tb[ETHTOOL_A_RINGS_HDS_THRESH] && + !(ops->supported_ring_params & ETHTOOL_RING_USE_HDS_THRS)) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_RINGS_HDS_THRESH], + "setting hds-thresh is not supported"); + return -EOPNOTSUPP; + } + if (tb[ETHTOOL_A_RINGS_CQE_SIZE] && !(ops->supported_ring_params & ETHTOOL_RING_USE_CQE_SIZE)) { NL_SET_ERR_MSG_ATTR(info->extack, @@ -223,6 +239,8 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) tb[ETHTOOL_A_RINGS_RX_PUSH], &mod); ethnl_update_u32(&kernel_ringparam.tx_push_buf_len, tb[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN], &mod); + ethnl_update_u32(&kernel_ringparam.hds_thresh, + tb[ETHTOOL_A_RINGS_HDS_THRESH], &mod); if (!mod) return 0; @@ -243,6 +261,8 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) err_attr = tb[ETHTOOL_A_RINGS_RX_JUMBO]; else if (ringparam.tx_pending > ringparam.tx_max_pending) err_attr = tb[ETHTOOL_A_RINGS_TX]; + else if (kernel_ringparam.hds_thresh > kernel_ringparam.hds_thresh_max) + err_attr = tb[ETHTOOL_A_RINGS_HDS_THRESH]; else err_attr = NULL; if (err_attr) { From patchwork Fri Jan 3 15:03:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925650 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 9D6AD1FA156; Fri, 3 Jan 2025 15:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916652; cv=none; b=KcsYWgxu6BKpr4Tv6Z4+CsvRqoQVdQ1Vt7/0PgMeZBMyt8qeq2SbR3cRHtiZyjsir12reB5oyuLY7F2c/bFUdwikSFgOYyq1CyPy8DzfFzHcKQ57JpERgyKpYtAExmuvfMcoMA60T2Bbf70U85bJpe1uNkz+f9sUQscvXXwe+Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916652; c=relaxed/simple; bh=uSa9PUwB4OW8OGNrdSS1mmwamYRUILjAefzKeR/wxAs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y0AayH1UBtsvFUeHrBrK2Kjvi9ViiUMWa2AQMlWB8e2oXF67xkrcULpedlp5WZz1402AZsc80gn0rEu4JdFVO3vpj8kr6Z3X0NDPDl7XQfh2A6g0NiKIT1sICPvTGS9AYRlsRpi7G6v5PbbRWdzZ6KiYtaB/BSt47Aeud1CXnYE= 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=G3kefjgv; arc=none smtp.client-ip=209.85.214.169 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="G3kefjgv" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2163bd70069so73181695ad.0; Fri, 03 Jan 2025 07:04:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916646; x=1736521446; 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=0z9IG6tvWKQ6IFAPmi4m2CrBnhRTm5oc5hWuduto3yY=; b=G3kefjgvV2hkmZ7A9Qqwr/sGKpncwvuXEbNI+5JXeOoTa4yjR5UPwg81wEDCxVHFtD /4pf04lyy0xUBqBTfFPjlS/J2xti3zkyXIzCq1J4jX2W4lZnL2Ke+pPtAOGGkKpatTH9 OKQ30zuIZGBeLMZQboiFRXY0Opb18KnGO015eKBu6Ix/jqqq9Sc/JxmpdJso91cA3hY/ z9p0giafk9+Lox6MPzVv64YgcnEbVsVL/ubIPnMQvWjTdZ+HZ8Kaydo3bVgMp3LOj1XS pU0mECNcfDlxRIbuiJiumyrFV7PbIq7i6mCLAJht1F2d5SLksxp7CTRYcZKqYOr/2FTS y6Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916646; x=1736521446; 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=0z9IG6tvWKQ6IFAPmi4m2CrBnhRTm5oc5hWuduto3yY=; b=FzzotpZniy+Mvj8L7ZnanDXJBaMEaDoCnim8vBnutp6y0iCoUigQ2mmgHEFHeaT+2R X3r7pwf5c2IQpPI4xyihaAtZ3ImsnEvogL5rXfcnN5PX+wSsKo5v5sVNP30bVsP5Pn7I 0YLC+Kk0cjz62durU3z4MuOKAzR0MAzqSkEmNpwyfO+GbAsRwFK3cQGpkNCuvulCwR2D nFQXTXl30N33Iica58PquLElJAIYY0ly48CrcrO7uaXGqWHE8IKn4HWiJxlYUo2dP47u ESV+Pk3ExfJW3817roNtkNvjaclSOZJjZ9BVajQthVpVdjW7940VOeMssYbC1QANWV58 TEUA== X-Forwarded-Encrypted: i=1; AJvYcCUj8CuhrdbX51skEchAQdPaxBWH7/3FHRpJbyacK2Ym+CGFxQS2SMZ2SEWN8Gfq4C3giUjgwfd+@vger.kernel.org, AJvYcCXOTCYPY5Rh3YezxQ49R8L+/P0pQZfmncCCRs4qzZDcSj6v5oGoKimXYBki9byl7GM5+dNR7hNonKk=@vger.kernel.org X-Gm-Message-State: AOJu0YzBADNabLph7Ik/ng8JAlWTInYllGEH+dSfMDUO9NUQJso+sy0t 2unh26P1LEH68xBpmUo6R2j8Q3+bYL+Sru2At7UCR2i7XBbX/WAa X-Gm-Gg: ASbGncvqcTfTh6uKE5Hmm+bermHFR8KZ1gdjn+uhPKxg8HFCbW/vfidiqtAdSPs09wh x/7sM5Da3bxsmwWgqR3DhgC2lWWAAbKCXqtwRrd8IbATUD1AI+LsN1+P+nfU2mG+folQvd9/1u/ FXSiKG5MP1Ua2TW68O2aLvMspiI7y5n1SQPaXVWLIKozj1g48J02yUQxn9yBhStsZpwfiNyUYmQ gpbJu9JzsDUkkdQWOjwGIcwf3EvurjC0J0xPlC2nnf2pA== X-Google-Smtp-Source: AGHT+IGxhaLOaNDfKIC59zsQREZQfid08smgwim1yFU+kJqcyAYumjlfHWZpjElIc33CvoSNRg5epA== X-Received: by 2002:a17:902:d54a:b0:215:773a:c168 with SMTP id d9443c01a7336-219e6e894d3mr867393265ad.1.1735916645950; Fri, 03 Jan 2025 07:04:05 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:04:05 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v7 03/10] net: devmem: add ring parameter filtering Date: Fri, 3 Jan 2025 15:03:18 +0000 Message-Id: <20250103150325.926031-4-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org If driver doesn't support ring parameter or tcp-data-split configuration is not sufficient, the devmem should not be set up. Before setup the devmem, tcp-data-split should be ON and hds-thresh value should be 0. Tested-by: Stanislav Fomichev Reviewed-by: Mina Almasry Signed-off-by: Taehee Yoo --- v7: - Use dev->ethtool->hds members instead of calling ->get_ring_param(). v6: - No changes. v5: - Add Review tag from Mina. v4: - Check condition before __netif_get_rx_queue(). - Separate condition check. - Add Test tag from Stanislav. v3: - Patch added. net/core/devmem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/core/devmem.c b/net/core/devmem.c index 0b6ed7525b22..c971b8aceac8 100644 --- a/net/core/devmem.c +++ b/net/core/devmem.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -140,6 +141,16 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx, return -ERANGE; } + if (dev->ethtool->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED) { + NL_SET_ERR_MSG(extack, "tcp-data-split is disabled"); + return -EINVAL; + } + + if (dev->ethtool->hds_thresh) { + NL_SET_ERR_MSG(extack, "hds-thresh is not zero"); + return -EINVAL; + } + rxq = __netif_get_rx_queue(dev, rxq_idx); if (rxq->mp_params.mp_priv) { NL_SET_ERR_MSG(extack, "designated queue already memory provider bound"); From patchwork Fri Jan 3 15:03:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925658 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 7B6421FA156; Fri, 3 Jan 2025 15:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916657; cv=none; b=DWzAaMyPeSw+UuCT4ff04rjrSy9B+TuuFL8qb/rZo5cfH336oDB1ZKDqohFNLWOjd/lUTSVT0MkHqob1983Yuk81maHG4KapVQjBb2clOrVwq1C9W0wMdb4cuKKTExyG/oXs0IP+QBYlz0a2Mic3na4X138ZfTKkdts/qjvZn2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916657; c=relaxed/simple; bh=hTM4fY+CEchNJukG0pdAy3y7/+l6QgwDz2y9uH7R7Bo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n3ikYqfyQuVrPq8sQhhQqzdzuq3juU7ea3HGAtBICmkm7308sSqN5Y9/PBeRlpvAm+ce0Q6DznigHEOPwdR4X/pQs466epCfraqorA/2U9bLi7PaJ0Xg5nNViJsg1Q7m0YJEsEce53Yp4KY8UwfoQuBewRSpRAMuQ/r+a19hdR4= 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=hdOceuwI; arc=none smtp.client-ip=209.85.214.172 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="hdOceuwI" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-21669fd5c7cso174498945ad.3; Fri, 03 Jan 2025 07:04:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916655; x=1736521455; 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=uiVDEzJGRG7GNszOmxw0+7tPL+XUGWUYLAewIjAaUDY=; b=hdOceuwIdkc1aQXJu9cvPi9h3tXYFlf0whXR/FVgdEHaj5SWJZ2KkYe2s2TNG/NyHw W5/EMNW0C/Qj666MwoBTe+dDWptHVZYKOGLsKzTwVLV0V4SrMOoURAsMRexfVd3avZ20 GT1MYd1xtenSx7wd0TxAKfGuaWMnJDkfQ6fwSWw7yssYs3cg7X8FERNEjZ39iMnJK0sl KpyO+9UulwFpI3vTgarUcKDEqx3JMl5EEstGT1DpIMAORJQpg0n66IIclT4fK0SYbyEF 9ysW4u1u44XKpb37ozrjbgsBa2jqYFtK1I5Xt8LjqPnyHYa/KXERB3wfOMI8AqZMxoIE mw/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916655; x=1736521455; 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=uiVDEzJGRG7GNszOmxw0+7tPL+XUGWUYLAewIjAaUDY=; b=OruGjUB2H+2KxlKGVRWqf4MgCzj70P3yZz9vn+Bg4zuJ06rFcsVbzs6ykBwQG2t1bF Y/w7zMIoPg4MWvJ6x1r9lijt5j2593AJT3y6e65XUPufP+d3JVlHYEOKKG7UX544NM68 DvpRyG1CzJYKzAasKH2i2oOMZPzmUMLqqgvTCkCqwzG+j2Z9LrlabSSDtcIta2pYhkcC 4j5IfNLnzkuhIgi549hvqDLi31YabAOWEgNEjZRwDyTnjsdKCVLgXekSO+RviJwNzDdJ NgSmxOhhLFFppLQRUU4lUiiSA1Md5pT847Y7mTZbb/8b30YOCm9tCWmTzj0QwtD5Uz6+ zx/w== X-Forwarded-Encrypted: i=1; AJvYcCUa+qiiaJMoH/R7ZSUOkSJaCyPbjDuFtyzvj8G4Afur7Rbd7JygcEgXNu6kc6UGZqzHWxG7NKvy@vger.kernel.org, AJvYcCWz8K1wg5E6QXmpQIC/Fp2P/aWWu06bbwsHc5ECenDEDTV/MaQ9mgx7FftXzOR3IQqTwJfcma9wEP4=@vger.kernel.org X-Gm-Message-State: AOJu0YxU6t/3YWnSbifJIR8dNw72vNy2nxw6WTIlRwWF4L+dLm0jIUyN 8CW1pnkAah+TzNVB7Pcgg5I0DK9rsX3AwC57gHkpCFLWkaTueOJG X-Gm-Gg: ASbGnct7kmwuPZJRorRk6R0ScHhl10rbm8vlIWdBgfefwY47pdig9F5FRk6yjJbOC01 77Xl+8E14ad55iQMyRimomhVmL0EZ2/JLMqdb99RyU10dqdq7Tgiglmo6AuxYH5D7W2ZRwOlH5I g42yaV0SK45aGE7mEhloCBDRYciyIM33cr5G8+fkDLGyiuS+eUNzYSnc8/1vO6Q5YcqKSFjmShj 26XLbWWSq937JCTAfBc9TNu1tHSd0vc/xZYrtqVD2w8Iw== X-Google-Smtp-Source: AGHT+IGBrlHa1J1iboiih9dgBvP7s9cGnNOd2xYQbbtLPyR+HgUG/VcODg5fd6JwTzoXBXRLwTGLxg== X-Received: by 2002:a17:903:1209:b0:216:36ff:ba33 with SMTP id d9443c01a7336-219e6ebcfc7mr648739525ad.26.1735916654653; Fri, 03 Jan 2025 07:04:14 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:04:13 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v7 04/10] net: ethtool: add ring parameter filtering Date: Fri, 3 Jan 2025 15:03:19 +0000 Message-Id: <20250103150325.926031-5-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org While the devmem is running, the tcp-data-split and hds-thresh configuration should not be changed. If user tries to change tcp-data-split and threshold value while the devmem is running, it fails and shows extack message. Tested-by: Stanislav Fomichev Reviewed-by: Mina Almasry Signed-off-by: Taehee Yoo Reviewed-by: Jakub Kicinski --- v7: - Use dev->ethtool->hds members instead of calling ->get_ring_param(). v6: - No changes. v5: - Add Review tag from Mina. v4: - Check condition before __netif_get_rx_queue(). - Separate condition check. - Add Test tag from Stanislav. v3: - Patch added. net/ethtool/rings.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index 9236de041271..bbb43322845f 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -252,6 +252,19 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) return -EINVAL; } + if (dev_get_min_mp_channel_count(dev)) { + if (kernel_ringparam.tcp_data_split != + ETHTOOL_TCP_DATA_SPLIT_ENABLED) { + NL_SET_ERR_MSG(info->extack, + "can't disable tcp-data-split while device has memory provider enabled"); + return -EINVAL; + } else if (kernel_ringparam.hds_thresh) { + NL_SET_ERR_MSG(info->extack, + "can't set non-zero hds_thresh while device is memory provider enabled"); + return -EINVAL; + } + } + /* ensure new ring parameters are within limits */ if (ringparam.rx_pending > ringparam.rx_max_pending) err_attr = tb[ETHTOOL_A_RINGS_RX]; From patchwork Fri Jan 3 15:03:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925659 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 45AAF1FA851; Fri, 3 Jan 2025 15:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916665; cv=none; b=ESqBIk2cgdVkwCen3Sjyjbp0muyonceurRou9EKtS4c93jLsiEhLiLmnG1maO0QR9uKNaGK0mKMF7Oii9ap/y6eVrZ2KSxJSLt/nY0wiETd+u/MQD0Q3p3B44h+iWCS1vn4pw1gXDGOg0znBtOw10qUTDd6Ch9gJRq3jImQOnWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916665; c=relaxed/simple; bh=BKQDlt0s1wORrdqRTBkoVwnxnuGA5YRsNvdq0RF/qEY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PH+X35XfuC8olont8P1naGum0XYS87ueA2yYC4vDZuBiS26TtlAmOwk4cfdysF7BUWDNQG+vaFb+ZnwZxBr2lez4IxQN+mVgirf+pRDJGUZn+D+H3zHzRa3pJgwz0vqwJhthSJsmOnx4x4jcXX9Vyp7c0RTiz9IW8QuwvrpFET8= 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=G8y7hgGD; arc=none smtp.client-ip=209.85.214.177 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="G8y7hgGD" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2156e078563so149276215ad.2; Fri, 03 Jan 2025 07:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916663; x=1736521463; 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=VlCsNZhi+pyCRlJI1oGA5APrS8t1ogGMgB2J84mRRbM=; b=G8y7hgGDVj++0Ri1YCDrblmv28m0elouhQWpDwJk82fHOTUm8NsTOpY+96/EwidJn9 XLZZHUyVu/OW/jyT8l4shQLOWxcQCvjxBr04PvXwva5bjhBY3BowoBn1Coif+PyyuN8s NF0oL+2GHBfZBXlv3gn209PtVqIEeiucxXSdEyTag03rSkQHDAflbFwI2BX9GkcCRupi rQ5QYIsUZeH+dnc6R1p//SgwYhMU+AhZoTI10WY+pr1sEZbRUCt74r8bm92q3uq1pO6c pk7K0oLLw5WBXUWg9nktkIt4clEcqyQeqBwzGsQMq41LSFGWAeyPHiUNUXdcgtfN7Xmd 0HUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916663; x=1736521463; 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=VlCsNZhi+pyCRlJI1oGA5APrS8t1ogGMgB2J84mRRbM=; b=RyUF3ChoYb83ks6QIxQBpWGWfEa8/F9OoXFyV/1MGAJ7hA6wJshyh2WdDxOYFFFxg0 e+lvmmyTOsfvVhwg4NdEbc8OSpCmom/plLO7bBU7a5F1v0hliEGoBYskqiSxa7CmN8cr butguqUpS8yizn5tDAz9AwRY8ykWNuqGny0xUnVdyvpgVhGaxx6mz9jvwfhEkqEB6XF2 NjULUB7mVo5k67xOvdisFyJ2DkqOV7zlsxLDTyqlzeBwAauNOCMYhE6lhBKny8miLX1D 4NaXyRwGp0L6lzyRf9jPusyzNmVZA3Zp1A96eO+7fEyIRhG1csgyHu6+/sFJ9vpwFDoD RHmA== X-Forwarded-Encrypted: i=1; AJvYcCV/U92TOdZxGCdtIh99UzToFukg4oJs3Ve5M6RC5U1taT1slYhzEK2wcsXu4k2ecmwtLJlQ4veKP4w=@vger.kernel.org, AJvYcCXOSpxTOxZdHKPKrYdOJ9cZcP7mbiQH30NK5GUFgjbAgBkIi3Rn38rpFuKMloVnh+p1zCkzD32u@vger.kernel.org X-Gm-Message-State: AOJu0YzNl4LClNEBvnNK+yCvp0T3qpc4DJDeMvIyyuDC2DuzeDvaRhO0 wwCT2HeKqDxbrPYTfcIldttLurX2nXqXIHagc8RxuxevyKWwSttl X-Gm-Gg: ASbGncua+Ck+kPa9STAXk44yflsEnGvRmi7Qq1sGY5XdsIu2JuFp9GkKYQ5W54Mek5t NOz63KrZJx33sp2KVpQV2w2qySB3bv4SYuKmBlR8Rma+axvl6BZRQEXCpDYO5n3z3bVQxnwkowE XvL/M7NUv8oBQHUUMxknzQQZ0j7cvtaw1sXqwhZ9JzUeq6gZQBBRWwIt2cAt/PCI9DxfLEgQru1 nsWv1HYbLQsGum4oaYW7wDo/QPj39Y3cpyu37MGIn4+vQ== X-Google-Smtp-Source: AGHT+IGfiw8U2ntfb0cmk8qGAK/jhkvSutFKJwRC8AXPD47pNpyfLh/Cp2mlK+pgO/KKIoyrYlP8Jw== X-Received: by 2002:a17:902:db0f:b0:215:9379:4650 with SMTP id d9443c01a7336-219e6f10958mr780001455ad.42.1735916663318; Fri, 03 Jan 2025 07:04:23 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:04:22 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v7 05/10] net: disallow setup single buffer XDP when tcp-data-split is enabled. Date: Fri, 3 Jan 2025 15:03:20 +0000 Message-Id: <20250103150325.926031-6-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org When a single buffer XDP is attached, NIC should guarantee only single page packets will be received. tcp-data-split feature splits packets into header and payload. single buffer XDP can't handle it properly. So attaching single buffer XDP should be disallowed when tcp-data-split is enabled. Signed-off-by: Taehee Yoo Acked-by: Jakub Kicinski --- v7: - Do not check XDP_SETUP_PROG_HW. v6: - Patch added. net/core/dev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index bc98f4920e12..2e0a5272f466 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -92,6 +92,7 @@ #include #include #include +#include #include #include #include @@ -9497,6 +9498,14 @@ int dev_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf) if (!dev->netdev_ops->ndo_bpf) return -EOPNOTSUPP; + if (dev->ethtool->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + bpf->command == XDP_SETUP_PROG && + bpf->prog && !bpf->prog->aux->xdp_has_frags) { + NL_SET_ERR_MSG(bpf->extack, + "unable to propagate XDP to device using tcp-data-split"); + return -EBUSY; + } + if (dev_get_min_mp_channel_count(dev)) { NL_SET_ERR_MSG(bpf->extack, "unable to propagate XDP to device using memory provider"); return -EBUSY; @@ -9534,6 +9543,12 @@ static int dev_xdp_install(struct net_device *dev, enum bpf_xdp_mode mode, struct netdev_bpf xdp; int err; + if (dev->ethtool->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + prog && !prog->aux->xdp_has_frags) { + NL_SET_ERR_MSG(extack, "unable to install XDP to device using tcp-data-split"); + return -EBUSY; + } + if (dev_get_min_mp_channel_count(dev)) { NL_SET_ERR_MSG(extack, "unable to install XDP to device using memory provider"); return -EBUSY; From patchwork Fri Jan 3 15:03:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925660 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 067211FBCA2; Fri, 3 Jan 2025 15:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916675; cv=none; b=X6hTKH79rd3Yd3xw8NaEWcgS1RSzJKrLy/PLb1WW2MkVZvBZKT60uf3nhWfh1niMj2kb9NRNc+2TH2okcK/R1WJQcGBApBCmwKNHEr27pjSrYRzLlSP9UJd65EhugJ3J7efRZG2jjKcpGSY0KfLNzGjqtYR8l1GHRv9w8N4O1/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916675; c=relaxed/simple; bh=/Sv0f/WTDWkvO0+KGtnAuwjkZiN5fOi0kafYRE/UsD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c3Kn+jKyn7lyYZKVYi0tql3piVoHXsisiI5WrEAAh8FnFurNJJbMQ/r7k7cbyfESRAS51emczxBJV1knKRf+I+cZz7S2ZQy90RmbvItlbz6hmdwredVQQfHwMgJqRJul4kVF2AlJAa3pjF3so3/QnJG8if5Qw/FECDqg4mOpA2o= 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=gL4+DQ8j; arc=none smtp.client-ip=209.85.214.174 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="gL4+DQ8j" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-21619108a6bso159961815ad.3; Fri, 03 Jan 2025 07:04:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916672; x=1736521472; 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=IGwacvKKGs07/aNIoKczkKFmv6X/5lyZNVAStIHjSRQ=; b=gL4+DQ8jwPOjTwigdSqxiyioOaKkrN8vBJhsrFzYotJakWju6iGNVri9toVR4WGCuW sjAX8D8SrLSVWlnEqCGZ/0IbkyoTXrR7VTiwIq3oMRf1Fc6m7vHGZ9F828vWT9WlPgv/ CqlifTfs752dG4+fOTfNxtPTm3eh67He6hitr13RjbiHdBVYROle59iZizUKosgm/2xR gOy7B/uxgtbftG92rSwaBntKCzbRJgb+T8PzmCr7K1L/auJ1cjGE+spqpIQc9CHajM08 IaOeVF6lres4AYH+A5MP2mRRTfdtL7tBnM03kGoxmy+DsrB9h1VaZCTpG92E7MsiIkjx YBeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916672; x=1736521472; 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=IGwacvKKGs07/aNIoKczkKFmv6X/5lyZNVAStIHjSRQ=; b=c+vwc7ZmPhly0QL4KuVlcedSoObfuha7yZuDLn+Ccp2EGGmDLuAqLrVghVA7i1TsgE Iy0ORCpxWbZyZAsP++leA2Wp7qnu2nAc5josX4Sl00ymNge6dlW0xB53rs5GAvDSnwny DguEVv5ZaLw/7I4jMCMsGMB4nyZFRF5n8TWx8jq3pj/pDoVqISnL5WiVRlAjxFeRLUdw QszOk6BcFp5SKkKC4VYfJglzadlM7UCTPIfPij+dd9x2YVn0fzpk0W+sMGLh4niquyCm 1DiwoVCXP7XSu9azAbNcrMf9XE0O89BE6VxO9myTDLmWqRkEMIIar/nQmTT2LB0nudDU assg== X-Forwarded-Encrypted: i=1; AJvYcCWQzj9HCMxgoQ0cq8VRxpnDH2MrtlHarfR88yPweULxXKVs//qU3u6hid5Eh9OB9grShFmuyxpieLA=@vger.kernel.org, AJvYcCX6EHRjlxcD2JLOxZiS48JSqCwpzbKBplgo6bApymX2FKPhcFCw9ZpExXSViBomQZBQvsPdB4zB@vger.kernel.org X-Gm-Message-State: AOJu0Yyim1PPKstLjrqHTRZnYF7rFPRNERtxeuBkpdQb5GuLi5im4GZY 4rLmcFkRq9bHqlViSKLc8utjn+yGMXU/YqdrhrzaX8xnDsH9lYPO X-Gm-Gg: ASbGncvFAfCQ7pOWI9drvX2Y7nka0FPzNr2LoEjNY8VjkUEiWj9WoVNV3dtBJPCBRAx woJvvoqk8MBc3kPRuhXahnB3AHxPzfQmtem3qV0CrIntNA/1SWEnEz0gH6txnMHN27Ujnjsy/ul 487ItWODFIDe8hDAGZ9PwWklLcTSyzCJX8yg+tI+HJYqYCgDJa/jIortVHhTPujrADrypX4q/2T lK94NAUhIr68iKVa9Ufc9OfAULIW+DKs6bnmJaGUC+vaw== X-Google-Smtp-Source: AGHT+IFnkT8xstUvGxD4cK9uk4DI5SEv1AxvYlmRusxPvy4fF61zqIfU4Fi9H5WgRSgsN+JDSckvZg== X-Received: by 2002:a17:903:98e:b0:215:9bc2:42ec with SMTP id d9443c01a7336-219e6f24eecmr706055635ad.47.1735916672164; Fri, 03 Jan 2025 07:04:32 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.04.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:04:31 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com, Andy Gospodarek Subject: [PATCH net-next v7 06/10] bnxt_en: add support for rx-copybreak ethtool command Date: Fri, 3 Jan 2025 15:03:21 +0000 Message-Id: <20250103150325.926031-7-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The bnxt_en driver supports rx-copybreak, but it couldn't be set by userspace. Only the default value(256) has worked. This patch makes the bnxt_en driver support following command. `ethtool --set-tunable rx-copybreak ` and `ethtool --get-tunable rx-copybreak`. By this patch, hds_threshol is set to the rx-copybreak value. But it will be set by `ethtool -G eth0 hds-thresh N` in the next patch. Reviewed-by: Brett Creeley Tested-by: Stanislav Fomichev Tested-by: Andy Gospodarek Signed-off-by: Taehee Yoo Reviewed-by: Jakub Kicinski --- v7: - return -EBUSY when interface is not running. v6: - No changes. v5: - Do not set HDS if XDP is attached. - rx_size and pkt_size are always bigger than 256. v4: - Remove min rx-copybreak value. - Add Review tag from Brett. - Add Test tag from Stanislav. v3: - Update copybreak value after closing nic and before opening nic when the device is running. v2: - Define max/vim rx_copybreak value. drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 +++++++----- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 ++- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 44 ++++++++++++++++++- 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 46edea75e062..9b5ca1e3d99a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -81,7 +81,6 @@ MODULE_DESCRIPTION("Broadcom NetXtreme network driver"); #define BNXT_RX_OFFSET (NET_SKB_PAD + NET_IP_ALIGN) #define BNXT_RX_DMA_OFFSET NET_SKB_PAD -#define BNXT_RX_COPY_THRESH 256 #define BNXT_TX_PUSH_THRESH 164 @@ -1343,13 +1342,13 @@ static struct sk_buff *bnxt_copy_data(struct bnxt_napi *bnapi, u8 *data, if (!skb) return NULL; - dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copy_thresh, + dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copybreak, bp->rx_dir); memcpy(skb->data - NET_IP_ALIGN, data - NET_IP_ALIGN, len + NET_IP_ALIGN); - dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copy_thresh, + dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copybreak, bp->rx_dir); skb_put(skb, len); @@ -1842,7 +1841,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, return NULL; } - if (len <= bp->rx_copy_thresh) { + if (len <= bp->rx_copybreak) { skb = bnxt_copy_skb(bnapi, data_ptr, len, mapping); if (!skb) { bnxt_abort_tpa(cpr, idx, agg_bufs); @@ -2176,7 +2175,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, } } - if (len <= bp->rx_copy_thresh) { + if (len <= bp->rx_copybreak) { if (!xdp_active) skb = bnxt_copy_skb(bnapi, data_ptr, len, dma_addr); else @@ -4601,6 +4600,11 @@ void bnxt_set_tpa_flags(struct bnxt *bp) bp->flags |= BNXT_FLAG_GRO; } +static void bnxt_init_ring_params(struct bnxt *bp) +{ + bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK; +} + /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must * be set on entry. */ @@ -4615,7 +4619,6 @@ void bnxt_set_ring_params(struct bnxt *bp) rx_space = rx_size + ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); - bp->rx_copy_thresh = BNXT_RX_COPY_THRESH; ring_size = bp->rx_ring_size; bp->rx_agg_ring_size = 0; bp->rx_agg_nr_pages = 0; @@ -4660,7 +4663,9 @@ void bnxt_set_ring_params(struct bnxt *bp) ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); } else { - rx_size = SKB_DATA_ALIGN(BNXT_RX_COPY_THRESH + NET_IP_ALIGN); + rx_size = SKB_DATA_ALIGN(max(BNXT_DEFAULT_RX_COPYBREAK, + bp->rx_copybreak) + + NET_IP_ALIGN); rx_space = rx_size + NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); } @@ -6566,16 +6571,14 @@ static int bnxt_hwrm_vnic_set_hds(struct bnxt *bp, struct bnxt_vnic_info *vnic) req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); + req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); - if (BNXT_RX_PAGE_MODE(bp)) { - req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); - } else { + if (!BNXT_RX_PAGE_MODE(bp) && (bp->flags & BNXT_FLAG_AGG_RINGS)) { req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6); req->enables |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_HDS_THRESHOLD_VALID); - req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); - req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); + req->hds_threshold = cpu_to_le16(bp->rx_copybreak); } req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); return hwrm_req_send(bp, req); @@ -16233,6 +16236,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bnxt_init_l2_fltr_tbl(bp); bnxt_set_rx_skb_mode(bp, false); bnxt_set_tpa_flags(bp); + bnxt_init_ring_params(bp); bnxt_set_ring_params(bp); bnxt_rdma_aux_device_init(bp); rc = bnxt_set_dflt_rings(bp, true); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 094c9e95b463..7edb92ce5976 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -34,6 +34,9 @@ #include #endif +#define BNXT_DEFAULT_RX_COPYBREAK 256 +#define BNXT_MAX_RX_COPYBREAK 1024 + extern struct list_head bnxt_block_cb_list; struct page_pool; @@ -2347,7 +2350,7 @@ struct bnxt { enum dma_data_direction rx_dir; u32 rx_ring_size; u32 rx_agg_ring_size; - u32 rx_copy_thresh; + u32 rx_copybreak; u32 rx_ring_mask; u32 rx_agg_ring_mask; int rx_nr_pages; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 75a59dd72bce..e9e63d95df17 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -4328,6 +4328,45 @@ static int bnxt_get_eee(struct net_device *dev, struct ethtool_keee *edata) return 0; } +static int bnxt_set_tunable(struct net_device *dev, + const struct ethtool_tunable *tuna, + const void *data) +{ + struct bnxt *bp = netdev_priv(dev); + u32 rx_copybreak; + + switch (tuna->id) { + case ETHTOOL_RX_COPYBREAK: + rx_copybreak = *(u32 *)data; + if (rx_copybreak > BNXT_MAX_RX_COPYBREAK) + return -ERANGE; + if (rx_copybreak != bp->rx_copybreak) { + if (netif_running(dev)) + return -EBUSY; + bp->rx_copybreak = rx_copybreak; + } + return 0; + default: + return -EOPNOTSUPP; + } +} + +static int bnxt_get_tunable(struct net_device *dev, + const struct ethtool_tunable *tuna, void *data) +{ + struct bnxt *bp = netdev_priv(dev); + + switch (tuna->id) { + case ETHTOOL_RX_COPYBREAK: + *(u32 *)data = bp->rx_copybreak; + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + static int bnxt_read_sfp_module_eeprom_info(struct bnxt *bp, u16 i2c_addr, u16 page_number, u8 bank, u16 start_addr, u16 data_length, @@ -4790,7 +4829,8 @@ static int bnxt_run_loopback(struct bnxt *bp) cpr = &rxr->bnapi->cp_ring; if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) cpr = rxr->rx_cpr; - pkt_size = min(bp->dev->mtu + ETH_HLEN, bp->rx_copy_thresh); + pkt_size = min(bp->dev->mtu + ETH_HLEN, max(BNXT_DEFAULT_RX_COPYBREAK, + bp->rx_copybreak)); skb = netdev_alloc_skb(bp->dev, pkt_size); if (!skb) return -ENOMEM; @@ -5372,6 +5412,8 @@ const struct ethtool_ops bnxt_ethtool_ops = { .get_link_ext_stats = bnxt_get_link_ext_stats, .get_eee = bnxt_get_eee, .set_eee = bnxt_set_eee, + .get_tunable = bnxt_get_tunable, + .set_tunable = bnxt_set_tunable, .get_module_info = bnxt_get_module_info, .get_module_eeprom = bnxt_get_module_eeprom, .get_module_eeprom_by_page = bnxt_get_module_eeprom_by_page, From patchwork Fri Jan 3 15:03:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925661 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 358AC1F9428; Fri, 3 Jan 2025 15:04:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916684; cv=none; b=S327iTZ12EwawrIjOHoqC6RkZH2N4XqrXGtON4JBqYxSb6kaAny6sXThlyO9ObJBK1xwDXinR88I6ys+CPPI9xqpd/C8x2bWQfrXV9aZs6ScEIvdrPfB6KOkqHDeZMbEpAI0BJ2KbO+M8OVLtmgcbHrghUXEODB+idrcMVFo92M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916684; c=relaxed/simple; bh=TawOs3j1JwsW5rW9dQlifILRHDeeK6Ec67G4qVy6ebs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A7v4Zq2a5Q7KBblIcVLTWj4BR+v+xTc69j5BrxgLrDRzzTWAmRKzs9IAc3YKposLTxQD1GWxV6s/GnlSTb8SsV95GLwTb9E+27v392jNVd2R7Mzfcw4QcvGvb0Iee2iPAptTCV76Ukot+6HKa/ggpwGd1Brt1EaSpvov+QGa/dM= 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=GX1rV+oj; arc=none smtp.client-ip=209.85.214.175 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="GX1rV+oj" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-216395e151bso125282955ad.0; Fri, 03 Jan 2025 07:04:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916681; x=1736521481; 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=n9M7wNcVX1T/1Xwu71Cw/kXYIswzxZw/fxJpL2uVZ/g=; b=GX1rV+ojdlPB0+KP6t2LfQeLqV5zunXt2Acp1JjSquQ4/Cuv9rFivx1HVUZDveZzoA tso4Y+gfV3qRc2qozfZt6cdg7Y/i00YyxT32T9Sc4DnCPsEnaQsieBxCb1hPID/jVoeM WpqYZkmgm4Clwz2H5bUjpszkEZuUw1xpuujghqX/w4kzSz3nEu3b+H8bbGczMr4hQbUs Ogpub4DUWh9p9R05OyAi8A3CjHPcYAZaSIqtm7MYYXKX7DfC7roRbWSZOsWB1n1OtlrL +3q6etYF6Myj0blcD1W4BBhIyXI7kMeY06aGzlD3sXh58yJ8a7XUxW3DRcDv57LCjfID I6rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916681; x=1736521481; 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=n9M7wNcVX1T/1Xwu71Cw/kXYIswzxZw/fxJpL2uVZ/g=; b=A0QeNbgmcMY9+wFjACrqdaWFXLklfdK5GDHgDyI5Q/MZDLkIMcW6FxZU/UWAbJDmPN QVV0bQwlnKUrbPlO99OMwdC9U63JR7tz9HRiQjSQI4ATofgk+zIuvkQUnmLYgonr38dh VbpDCrKRN3tkKpp6zVFMvh3Uz05djqPOwiV87E1UUgajGZlY2o3mLBBtIrjjOB8+Cn3K wH4mWU11T0rFxJGtLiNxiZ12BrjQoNRDqvQoFwiJjx7c9+cO5pApU+73PQl9CmzBA9g7 RNZfkC9JRnkxu6T7zUVwDQEGDA608ZakL3pzvsWrk3Uq80MJfgtpnb/8x1ZpWLwhJYL8 VCqQ== X-Forwarded-Encrypted: i=1; AJvYcCW3QDZ3sbgY0lgVb+UEpdwmikDSdADvShVIKNkZzZOxudm0m1I5unZTDOpZdX+yh+t/XZwoRDVj@vger.kernel.org, AJvYcCWhIPP7buO34JqUPSq5XG5y1uH+IGKrYkuIdDejTtsh5z8ged6RVAdthwl4ZrXilHwiydPaHMlqB0g=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0sAFhQ7w6ADtrh5aMFsWBQCqQiZ0QdfA9ZuoG97FQsfiAIiYG lDVge/rS+VSzytRFGRoG/GH6y1FTaM1NTe220gPj6e6/VUL6WhFb X-Gm-Gg: ASbGncuRVc521yNmyfmR8NSvL4Ns5bdEUWtcRSqtfAORL9NzjUt/QGYy74jTwUtyHEO fkMb+v6N8VcJjNCxpyXHdn0onfWaWQENVnswc941StCeEFT3QXfEynR+3zsD7EvtMcvlmfyro9/ FEoPVVT1h4r2uZ24YKjS4ftQPQXxI/MImgNX4demb0La2DcyhHAsGE7LL652qlgbHD5v1UeqRsd sjukfOVOtKBQm0BsLX01PxQKdHP/VCJU0/U5MWtjVRUDA== X-Google-Smtp-Source: AGHT+IEU4Gc4os4+UvJJ2F1EahOtG2L5hh4X6mrWlIhXOL/HYp5QNc6R6dP8eV6QhhyYruhCtKZWXw== X-Received: by 2002:a17:902:e850:b0:215:7e49:8202 with SMTP id d9443c01a7336-219e6cf8cdcmr755335065ad.13.1735916681198; Fri, 03 Jan 2025 07:04:41 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:04:40 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com, Andy Gospodarek Subject: [PATCH net-next v7 07/10] bnxt_en: add support for tcp-data-split ethtool command Date: Fri, 3 Jan 2025 15:03:22 +0000 Message-Id: <20250103150325.926031-8-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org NICs that uses bnxt_en driver supports tcp-data-split feature by the name of HDS(header-data-split). But there is no implementation for the HDS to enable by ethtool. Only getting the current HDS status is implemented and The HDS is just automatically enabled only when either LRO, HW-GRO, or JUMBO is enabled. The hds_threshold follows rx-copybreak value. and it was unchangeable. This implements `ethtool -G tcp-data-split ` command option. The value can be and . The value is and one of LRO/GRO/JUMBO is enabled, HDS is automatically enabled and all LRO/GRO/JUMBO are disabled, HDS is automatically disabled. HDS feature relies on the aggregation ring. So, if HDS is enabled, the bnxt_en driver initializes the aggregation ring. This is the reason why BNXT_FLAG_AGG_RINGS contains HDS condition. Tested-by: Stanislav Fomichev Tested-by: Andy Gospodarek Signed-off-by: Taehee Yoo Acked-by: Jakub Kicinski --- v7: - Remove hds unrelated changes. - Return -EINVAL instead of -EOPNOTSUPP; v6: - Disallow to attach XDP when HDS is in use. - Add Test tag from Andy. v5: - Do not set HDS if XDP is attached. - Enable tcp-data-split only when tcp_data_split_mod is true. v4: - Do not support disable tcp-data-split. - Add Test tag from Stanislav. v3: - No changes. v2: - Do not set hds_threshold to 0. drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 +++-- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 20 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 ++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 9b5ca1e3d99a..7198d05cd27b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4623,7 +4623,7 @@ void bnxt_set_ring_params(struct bnxt *bp) bp->rx_agg_ring_size = 0; bp->rx_agg_nr_pages = 0; - if (bp->flags & BNXT_FLAG_TPA) + if (bp->flags & BNXT_FLAG_TPA || bp->flags & BNXT_FLAG_HDS) agg_factor = min_t(u32, 4, 65536 / BNXT_RX_PAGE_SIZE); bp->flags &= ~BNXT_FLAG_JUMBO; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 7edb92ce5976..7dc06e07bae2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2244,8 +2244,6 @@ struct bnxt { #define BNXT_FLAG_TPA (BNXT_FLAG_LRO | BNXT_FLAG_GRO) #define BNXT_FLAG_JUMBO 0x10 #define BNXT_FLAG_STRIP_VLAN 0x20 - #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \ - BNXT_FLAG_LRO) #define BNXT_FLAG_RFS 0x100 #define BNXT_FLAG_SHARED_RINGS 0x200 #define BNXT_FLAG_PORT_STATS 0x400 @@ -2266,6 +2264,9 @@ struct bnxt { #define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000 #define BNXT_FLAG_TX_COAL_CMPL 0x8000000 #define BNXT_FLAG_PORT_STATS_EXT 0x10000000 + #define BNXT_FLAG_HDS 0x20000000 + #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \ + BNXT_FLAG_LRO | BNXT_FLAG_HDS) #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \ BNXT_FLAG_RFS | \ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index e9e63d95df17..413007190f50 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -840,16 +840,35 @@ static int bnxt_set_ringparam(struct net_device *dev, struct kernel_ethtool_ringparam *kernel_ering, struct netlink_ext_ack *extack) { + u8 tcp_data_split = kernel_ering->tcp_data_split; struct bnxt *bp = netdev_priv(dev); + u8 hds_config_mod; if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) || (ering->tx_pending > BNXT_MAX_TX_DESC_CNT) || (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) return -EINVAL; + hds_config_mod = tcp_data_split != dev->ethtool->hds_config; + if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_DISABLED && hds_config_mod) + return -EINVAL; + + if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + hds_config_mod && BNXT_RX_PAGE_MODE(bp)) { + NL_SET_ERR_MSG_MOD(extack, "tcp-data-split is disallowed when XDP is attached"); + return -EINVAL; + } + if (netif_running(dev)) bnxt_close_nic(bp, false, false); + if (hds_config_mod) { + if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED) + bp->flags |= BNXT_FLAG_HDS; + else if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN) + bp->flags &= ~BNXT_FLAG_HDS; + } + bp->rx_ring_size = ering->rx_pending; bp->tx_ring_size = ering->tx_pending; bnxt_set_ring_params(bp); @@ -5371,6 +5390,7 @@ const struct ethtool_ops bnxt_ethtool_ops = { ETHTOOL_COALESCE_STATS_BLOCK_USECS | ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_CQE, + .supported_ring_params = ETHTOOL_RING_USE_TCP_DATA_SPLIT, .get_link_ksettings = bnxt_get_link_ksettings, .set_link_ksettings = bnxt_set_link_ksettings, .get_fec_stats = bnxt_get_fec_stats, diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c index f88b641533fc..1bfff7f29310 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c @@ -395,6 +395,10 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) bp->dev->mtu, BNXT_MAX_PAGE_MODE_MTU); return -EOPNOTSUPP; } + if (prog && bp->flags & BNXT_FLAG_HDS) { + netdev_warn(dev, "XDP is disallowed when HDS is enabled.\n"); + return -EOPNOTSUPP; + } if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) { netdev_warn(dev, "ethtool rx/tx channels must be combined to support XDP.\n"); return -EOPNOTSUPP; From patchwork Fri Jan 3 15:03:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925662 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 033911A8F9A; Fri, 3 Jan 2025 15:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916692; cv=none; b=RZsPdgx074xn9kwvgr+7SZvZe8+q+knDBSVVzPfgrQE+APBJOFbw6aVAy+ntUBbRwh4iPDhuXowuGXx0BatKAL4nslm6NESqNDKGrNfIglqvxllQ0OuJIQRFbsaHOunVJStWAPJLOHwaOqHrjMxi2LyDcXOT+qgAlQ+cfmHcJM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916692; c=relaxed/simple; bh=L6MYuD3u+xSbD2EiSkVnWj+5AwYiSsdjyBao+vMBte8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PO4fARJqBuINPYZOn0O+FhOijlI8GEKuAgq125pIu6IFs6eho4HDN4AUcD0x4nHbvhxSL9ROKdyakxa+xwnnvnu5+FgeA6w8d9Foh430dect+HhbY4mRiAu6cJuDBnHsbYSL8idqbFuiMakXxCtW2Cx5WyXbXOYuU6xPzzg+JxU= 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=bLtVbXku; arc=none smtp.client-ip=209.85.214.176 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="bLtVbXku" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21644aca3a0so95331175ad.3; Fri, 03 Jan 2025 07:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916690; x=1736521490; 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=SdIIZFCtcHdPgbtASbzKTVWoOAIV4vHIvwfLf2MMccc=; b=bLtVbXkuWGoy1Hnq2QmsAFwvBeTLfGzIatQxQgmnDU+m5A43G92zkoPhfkAH/atJq0 3RnrNaWyFFtDBQ21ScSzYJph6MWtdYH//o5onkSjHAMaoEctHQ7hWj+ON4NtREu8gwY5 TaNMxWeB6yNaltotM9gOV0PXv6Gz8mPpReOAFqvok7qFBqeGupkC7yvfwuq3XP9gHU0i TynhsS/T7wzIgbZUR6fVUOlh0SPTVCC7Np2+skzBlbst5/km6KGjaShkl2KglPWgmdu0 EcOjADRO09uXc0ujd+683QmRt2pLbznqMhvZaeKSKHmHBMuZqAxFEDH8+LCOsM4uNBSv 9CNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916690; x=1736521490; 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=SdIIZFCtcHdPgbtASbzKTVWoOAIV4vHIvwfLf2MMccc=; b=n664miVsmD4MsXP/8qovWo9d7YOpjSl0mphOAqoHq6fZGK30y/MOFAJ1L8c5DyLR+q sF82W2MjPbr2+PU8oGYlKxyg1y3YW36vTTLh6L8B2ZspOoy/5/Tue4RdxkuXCsU0//og n8JhTv5i8vmEtU+43EHpNx+dODOyeDTwWLxEoZhnRDiCdo6xJ4yfnlCvcjdXKYx8oh3d oeS0V4Cvwb3ceveIq4oRSeHLgTNC6K36epB4BVhMBH2luL3T4w3xGnsOI9E1t7nNM1lc ImC1ZnolMULw4DVeD/gnQ7neLVd6v5eXjZuWuVryKm58fL3lZp/G0qeJWZ2C3uhInQZo am5w== X-Forwarded-Encrypted: i=1; AJvYcCX6Kq/A3lrpjOpGd/A7sY4sptDOtczVIt6vUGhnvg6aeXLKXOpU/FiOR48x6gqR94o9rpKuY1CO@vger.kernel.org, AJvYcCXpKa7NF/vv6tjKhHDnnQwh5InqG++8AKQbmFZ0aIYXp1kFs8UMo6kqNNUDTuZ5XMs/3Fus0eLFNxk=@vger.kernel.org X-Gm-Message-State: AOJu0Yxg3SC4cilngOwaauMHykqLNz+9QNHczDnKq3l/9N6pP10MY2L0 go8jAFcW3kNif03nzdUFBjnW7ePjgW/AqElPgNuJlQ7hUdV/yh11 X-Gm-Gg: ASbGncsZLKn3WhxooQnoxT7nsB0cMSmbYa5jY2oWr867xjVAQOMJiq6mgErmW9ptR8t 7AMirND/2+HQ2Gbj5BEHjhTHL/gY2xPWKh/f25AP8dgdqKwTjWSXchSvmLvLybsTUx7SqNq1HjF yGuJfCzO+gUohO/Vt0Upn+rYOC5BkAVqL5azOL0Qw8GINeR3nGTLeJISdzX85OT8GXN+mwg0xhm syrOPIB46jIK3T8s10XVpLs/kfr7xjq0Px0zqq8O0jgFg== X-Google-Smtp-Source: AGHT+IHVVgUmC3Nf91vr5cN4Fy5E0NKLIHPA1YOFxQZj26nPS1aeoSIz2Hkpayi/7/kIdqZzLYxucA== X-Received: by 2002:a17:903:2444:b0:215:e98c:c5d9 with SMTP id d9443c01a7336-219e6e9fb2emr617498715ad.18.1735916690056; Fri, 03 Jan 2025 07:04:50 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:04:49 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com, Andy Gospodarek Subject: [PATCH net-next v7 08/10] bnxt_en: add support for hds-thresh ethtool command Date: Fri, 3 Jan 2025 15:03:23 +0000 Message-Id: <20250103150325.926031-9-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The bnxt_en driver has configured the hds_threshold value automatically when TPA is enabled based on the rx-copybreak default value. Now the hds-thresh ethtool command is added, so it adds an implementation of hds-thresh option. Configuration of the hds-thresh is applied only when the tcp-data-split is enabled. The default value of hds-thresh is 256, which is the default value of rx-copybreak, which used to be the hds_thresh value. The maximum hds-thresh is 1023. # Example: # ethtool -G enp14s0f0np0 tcp-data-split on hds-thresh 256 # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... HDS thresh: 1023 Current hardware settings: ... TCP data split: on HDS thresh: 256 Tested-by: Stanislav Fomichev Tested-by: Andy Gospodarek Signed-off-by: Taehee Yoo --- v7: - Use dev->ethtool->hds_thresh instead of bp->hds_thresh v6: - HDS_MAX is changed to 1023. - Add Test tag from Andy. v5: - No changes. v4: - Reduce hole in struct bnxt. - Add ETHTOOL_RING_USE_HDS_THRS to indicate bnxt_en driver support header-data-split-thresh option. - Add Test tag from Stanislav. v3: - Drop validation logic tcp-data-split and tcp-data-split-thresh. v2: - Patch added. drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 7198d05cd27b..df03f218a570 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4603,6 +4603,7 @@ void bnxt_set_tpa_flags(struct bnxt *bp) static void bnxt_init_ring_params(struct bnxt *bp) { bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK; + bp->dev->ethtool->hds_thresh = BNXT_DEFAULT_RX_COPYBREAK; } /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must @@ -6562,6 +6563,7 @@ static void bnxt_hwrm_update_rss_hash_cfg(struct bnxt *bp) static int bnxt_hwrm_vnic_set_hds(struct bnxt *bp, struct bnxt_vnic_info *vnic) { + u16 hds_thresh = (u16)bp->dev->ethtool->hds_thresh; struct hwrm_vnic_plcmodes_cfg_input *req; int rc; @@ -6578,7 +6580,7 @@ static int bnxt_hwrm_vnic_set_hds(struct bnxt *bp, struct bnxt_vnic_info *vnic) VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6); req->enables |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_HDS_THRESHOLD_VALID); - req->hds_threshold = cpu_to_le16(bp->rx_copybreak); + req->hds_threshold = cpu_to_le16(hds_thresh); } req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); return hwrm_req_send(bp, req); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 7dc06e07bae2..8f481dd9c224 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2779,6 +2779,8 @@ struct bnxt { #define SFF_MODULE_ID_QSFP28 0x11 #define BNXT_MAX_PHY_I2C_RESP_SIZE 64 +#define BNXT_HDS_THRESHOLD_MAX 1023 + static inline u32 bnxt_tx_avail(struct bnxt *bp, const struct bnxt_tx_ring_info *txr) { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 413007190f50..829697bfdab3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -833,6 +833,9 @@ static void bnxt_get_ringparam(struct net_device *dev, ering->rx_pending = bp->rx_ring_size; ering->rx_jumbo_pending = bp->rx_agg_ring_size; ering->tx_pending = bp->tx_ring_size; + + kernel_ering->hds_thresh = dev->ethtool->hds_thresh; + kernel_ering->hds_thresh_max = BNXT_HDS_THRESHOLD_MAX; } static int bnxt_set_ringparam(struct net_device *dev, @@ -869,6 +872,7 @@ static int bnxt_set_ringparam(struct net_device *dev, bp->flags &= ~BNXT_FLAG_HDS; } + dev->ethtool->hds_thresh = kernel_ering->hds_thresh; bp->rx_ring_size = ering->rx_pending; bp->tx_ring_size = ering->tx_pending; bnxt_set_ring_params(bp); @@ -5390,7 +5394,8 @@ const struct ethtool_ops bnxt_ethtool_ops = { ETHTOOL_COALESCE_STATS_BLOCK_USECS | ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_CQE, - .supported_ring_params = ETHTOOL_RING_USE_TCP_DATA_SPLIT, + .supported_ring_params = ETHTOOL_RING_USE_TCP_DATA_SPLIT | + ETHTOOL_RING_USE_HDS_THRS, .get_link_ksettings = bnxt_get_link_ksettings, .set_link_ksettings = bnxt_set_link_ksettings, .get_fec_stats = bnxt_get_fec_stats, From patchwork Fri Jan 3 15:03:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925663 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 A2A321FBC9C; Fri, 3 Jan 2025 15:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916701; cv=none; b=Cbtm9OpNvR070uAh3r1KC5StifZ2TqFMhk0RKpaoEYJcO/7tP3qHOIt7mXAEA7eB8RZVig0DLiqjPDNAmHTFc7ng/IKIWtdbhFjUrQmVDkheDnhBlbTYK/pqe1L57Dq3lRStr6Qwl47Vq++c/awdLTe9SpODXAoa4wOyZqkkaiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916701; c=relaxed/simple; bh=NvAJ5hcGuIYAqGMVBq7reo38EMrOI4ZnWrBomY9szSY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bGr4IyHYaQJHMVUwGT9KZohqRYyNFSzbERFXHLcMog6oh6ZCfep+2zqe9iJy1LRGpjj5cuAav6f3yyyQSKPjbufr67npTk2hfkbdVqSshdePAvrpFvN8hUH98W2MEjkwcpaYlzH8twkTdENuKhmUfgG2Dp/G2dCo3R4v6BM2Ads= 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=m770yjdD; arc=none smtp.client-ip=209.85.214.182 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="m770yjdD" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-21661be2c2dso156901235ad.1; Fri, 03 Jan 2025 07:04:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916699; x=1736521499; 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=RnpGvv4lfe2nj6WMe9po2SCX02YRLSRAJWmhEZZK/LU=; b=m770yjdDgagSuLZJGPWG2dFcIgAcU09MEzmxvhztYowyJfrjbpKT5OW/LGgxlRC4vX so8isbtqxo1vOCXKZQxGcbtQNU9Xu588EVZEbdleG4F2gyD4/DwzmMyCOAWXr/04rK67 Wkd7yFToYMWDSuyYDflx/MOR9tbne/B7NdZmDqYrPO1Rz6W5+1efOK/n2xGxtS/t/05F cBg3Sejs4TJbSmTHR2FZr18lx+ukwR0r1jQrAaTcmBnpgkkxW3wRRWRchZEWg86+IvB+ wMsZNnHoMEPzXKb+uinRvrMpRR3y/3bkrS7fY/y54Iivf1tI7qmvSV03vVRb4AZVnS6m 7NFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916699; x=1736521499; 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=RnpGvv4lfe2nj6WMe9po2SCX02YRLSRAJWmhEZZK/LU=; b=IcvXKAFS8AQ/LWuuSI9se6sbMbpo+BQAbAUuhRijWVgtGperqGQWRXHSGO4Pd74CeI xXonX0HIh6CI4quV2U2kHAs2GvQ9WU4GXBamGWRW9I+iIRahSfQB7hVsFc3DYqal9+ef 4iVsuiUdcpb7Hnlk++aay+EPsiBICLs31yZM8mwjVD0pU4O1mx6U4tmNJkkYKXu5pGzf yJq1SPHhgkLneH2gK5WtMC4hE1lmko9/crktwx0CyMJZ4/YDLTPHQZNwsYlwNoxxarbZ iG4coCPoqoOFFcFj8Rg3dizq56G7XTOapm5O1523/clYJj2nNZ6esuZGtFiZtqUX6TaR 3GPQ== X-Forwarded-Encrypted: i=1; AJvYcCWrI/SUw4MOdHDpSW2AWVPicjzeoI3DfdMLf/jNQDpA85HkKDYAwTEKSkf8HvnKCP9Gp/I6FbA7@vger.kernel.org, AJvYcCXXeZRg2tdc14GZdsTa+q2MfHpnQDqZntREt57MLSlxA6VkfypjtWrueAHpY9JWJrdjFjIMdwGa+q0=@vger.kernel.org X-Gm-Message-State: AOJu0YyHbDnGmIwjXbR+onh5DxS9xUfXOyVDc3flXfgMGTWdkdSzliHg 8oWtOoCHViPVRcRFfcIV7cFSLASnZ+WqdbJAcHsNzl6bxYV58cuq X-Gm-Gg: ASbGncszBey6J/VZdqgcOdAMi9hR8Nw5arc2l3DCnZVAsz4jzJ5IL6LKR3U7RNqfIa/ aZIhMxEcxAvsPbCxk1CCHcZzk9D0SQgaAE43TeaahPgJMg8x4aGTZFJaWDlurXzg66SWk7Ua0oE 9FkVjoU/uGf5LOCG5FZ7Rx8pKT+rHXMlW7wlSYlK0w90AWpwKpmNoBKZbKb6jMx1Et7qJz5k1+k y3NUM5HLYpmj8TPNoGVYTiY7QRjUgyWgbTyAcPsN1zwEA== X-Google-Smtp-Source: AGHT+IEGry5gbnlcC9i6jJZft+4fkopD4jnCwZOiO/ww7qpuCTXWh1ican4+qKz811xtt2gQ66BwHQ== X-Received: by 2002:a17:902:f550:b0:215:a04a:89d5 with SMTP id d9443c01a7336-219e6e859d8mr583560315ad.2.1735916698808; Fri, 03 Jan 2025 07:04:58 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:04:58 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v7 09/10] netdevsim: add HDS feature Date: Fri, 3 Jan 2025 15:03:24 +0000 Message-Id: <20250103150325.926031-10-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org HDS options(tcp-data-split, hds-thresh) have dependencies between other features like XDP. Basic dependencies are checked in the core API. netdevsim is very useful to check basic dependencies. The default tcp-data-split mode is UNKNOWN but netdevsim driver returns ENABLED when ethtool dumps tcp-data-split mode. The default value of HDS threshold is 0 and the maximum value is 1024. ethtool shows like this. ethtool -g eni1np1 Ring parameters for eni1np1: Pre-set maximums: ... HDS thresh: 1024 Current hardware settings: ... TCP data split: on HDS thresh: 0 ethtool -G eni1np1 tcp-data-split on hds-thresh 1024 ethtool -g eni1np1 Ring parameters for eni1np1: Pre-set maximums: ... HDS thresh: 1024 Current hardware settings: ... TCP data split: on HDS thresh: 1024 Signed-off-by: Taehee Yoo --- v7: - Add datapath implementation. - Remove kernel_ethtool_ringparam in the struct nsim_ethtool. v6: - Patch added. drivers/net/netdevsim/ethtool.c | 15 ++++++++++++++- drivers/net/netdevsim/netdev.c | 9 +++++++++ drivers/net/netdevsim/netdevsim.h | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/net/netdevsim/ethtool.c b/drivers/net/netdevsim/ethtool.c index 5fe1eaef99b5..fb0136def48a 100644 --- a/drivers/net/netdevsim/ethtool.c +++ b/drivers/net/netdevsim/ethtool.c @@ -2,7 +2,6 @@ // Copyright (c) 2020 Facebook #include -#include #include #include "netdevsim.h" @@ -72,6 +71,12 @@ static void nsim_get_ringparam(struct net_device *dev, struct netdevsim *ns = netdev_priv(dev); memcpy(ring, &ns->ethtool.ring, sizeof(ns->ethtool.ring)); + kernel_ring->tcp_data_split = dev->ethtool->hds_config; + kernel_ring->hds_thresh = dev->ethtool->hds_thresh; + kernel_ring->hds_thresh_max = NSIM_HDS_THRESHOLD_MAX; + + if (kernel_ring->tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN) + kernel_ring->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_ENABLED; } static int nsim_set_ringparam(struct net_device *dev, @@ -85,6 +90,9 @@ static int nsim_set_ringparam(struct net_device *dev, ns->ethtool.ring.rx_jumbo_pending = ring->rx_jumbo_pending; ns->ethtool.ring.rx_mini_pending = ring->rx_mini_pending; ns->ethtool.ring.tx_pending = ring->tx_pending; + dev->ethtool->hds_config = kernel_ring->tcp_data_split; + dev->ethtool->hds_thresh = kernel_ring->hds_thresh; + return 0; } @@ -161,6 +169,8 @@ static int nsim_get_ts_info(struct net_device *dev, static const struct ethtool_ops nsim_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_ALL_PARAMS, + .supported_ring_params = ETHTOOL_RING_USE_TCP_DATA_SPLIT | + ETHTOOL_RING_USE_HDS_THRS, .get_pause_stats = nsim_get_pause_stats, .get_pauseparam = nsim_get_pauseparam, .set_pauseparam = nsim_set_pauseparam, @@ -182,6 +192,9 @@ static void nsim_ethtool_ring_init(struct netdevsim *ns) ns->ethtool.ring.rx_jumbo_max_pending = 4096; ns->ethtool.ring.rx_mini_max_pending = 4096; ns->ethtool.ring.tx_max_pending = 4096; + + ns->netdev->ethtool->hds_config = ETHTOOL_TCP_DATA_SPLIT_UNKNOWN; + ns->netdev->ethtool->hds_thresh = 0; } void nsim_ethtool_init(struct netdevsim *ns) diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index e068a9761c09..fc365661039e 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -51,6 +52,7 @@ static int nsim_forward_skb(struct net_device *dev, struct sk_buff *skb, static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct netdevsim *ns = netdev_priv(dev); + struct ethtool_netdev_state *ethtool; struct net_device *peer_dev; unsigned int len = skb->len; struct netdevsim *peer_ns; @@ -71,6 +73,13 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev) rxq = rxq % peer_dev->num_rx_queues; rq = &peer_ns->rq[rxq]; + ethtool = peer_dev->ethtool; + if (skb_is_nonlinear(skb) && + (ethtool->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED || + (ethtool->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + ethtool->hds_thresh > len))) + skb_linearize(skb); + skb_tx_timestamp(skb); if (unlikely(nsim_forward_skb(peer_dev, skb, rq) == NET_RX_DROP)) goto out_drop_cnt; diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index bf02efa10956..648905f8475e 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,8 @@ #define NSIM_IPSEC_VALID BIT(31) #define NSIM_UDP_TUNNEL_N_PORTS 4 +#define NSIM_HDS_THRESHOLD_MAX 1024 + struct nsim_sa { struct xfrm_state *xs; __be32 ipaddr[4]; From patchwork Fri Jan 3 15:03:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13925664 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.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 503251FA140; Fri, 3 Jan 2025 15:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916710; cv=none; b=RhRiErTzW4296RAT4L9dideMu5EuWv6Gfs4jWVy2hDPnkzkn+4s9iund16NU8F/lse2VNjDTWdeLpGzM5SQ/FRBfFw3QaVewHo5zCFtqmCTOYSCVPkC0BdkW0Vv3lzbu/yBoBoBrgn5vGO5if6wPhfl+CrHl2RaE4H62SpVb/Q8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916710; c=relaxed/simple; bh=g+xedStwdu7vqJHteeHoaifSNpz/JPjXv9xm04kRPn8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DLVdRW7AqidA+/ahCkB3ulZVLX08UGMHW5ug6JHGmQA1/ZKRMWEQo4nfPPu97YxN0l3uukNk7ogCOUx4GhptCJhiAw8/BhNG9/tC7FvuS+BLfI0jHQf/LDm8FIXSqGR30Bxc8tJDsEEy/yl7eUWhXmuqmiy+CD8NRcwVPy/oXAY= 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=imTu2s/m; arc=none smtp.client-ip=209.85.216.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="imTu2s/m" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2eeb4d643a5so17680573a91.3; Fri, 03 Jan 2025 07:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735916707; x=1736521507; 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=1HL+ntJjREdI9rDbxoGOYSFvSnek5hf/Fz0N6hXv0ew=; b=imTu2s/mIWU4rbq0XcbvCQvdTUEtQsvCmx074uG5mel4jAXHSC2pAff3LAiSnVkzPz FPlVrFRD2D/TzC4qj9pAivfPZ5plnM+dcdz3LqURLElcT4xllU4doU67TjfE4UFDEHgy +STCkCp5hMJgQePrl5KrHv0u2j15XpsTGex8izRCWRjFpVk80NWAsUSrwXZsVY63G73T 4TaeClN09GF9IEIcG5c1pk3DzCe4Zh173SmIbdEOF98UtuXwUECWE7oMPkKnklUOzBSN GKJr9NJHeDMgC/prVxl3HWP3k/IhxhLWt8ItJrpbx3THZkxBcoBCleudraZJ7WhFGmE2 RnHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735916707; x=1736521507; 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=1HL+ntJjREdI9rDbxoGOYSFvSnek5hf/Fz0N6hXv0ew=; b=opQZPS7fVFkxLX6o3CfExSXBtXGdHMixoN5l8VsCMAy1w1mKTHyxiBUlSC7ZPcAS1z Zh7q2nHqvOtqdU9JzoZPDinrhSCzWmJNmZ6QtTq09eXxO77GYQD+dGeiewb9MZKBHhcV WsH4u7+928+gBZumNnlt6rXIFaH/aG7108Fd0c6x0QMaI764ZUk/iXkLGyYa/dSMfrKy +6V5PTBO/leSrL7acA9x+I2ubtM1ND8hs1ISHs5bsayDUWgbpCwf123Sla5+77+cb6Pa tAplddrOBJC1GQOZb5uorM/Qg7YAxhkMjwLLtZtprisokihjhlXv1U5+DU/A+ZoCmx2E vy4g== X-Forwarded-Encrypted: i=1; AJvYcCUap9Of2FAActr4KD0UNBmePoWiUhYVA7BYusAaJqJMk5lq9bakWrxPke9glSQkk7cNlgXeZOxHzto=@vger.kernel.org, AJvYcCVCUpCEsIZ4+CIb8n1aiebCXRn2PPDIWkBvuub8QAFQhuzDLY3dZmpL58k9pMlm244hTdAVVroL@vger.kernel.org X-Gm-Message-State: AOJu0YyuT2kwFCN+UL86hQmh6MQwq4K9h5Z39ILpzPJPba7AnLaCippy q9HYfwgpb5UB3CK9E9tBhLRjlsOgNllpWUQRh4VGNxExnTCRazsD X-Gm-Gg: ASbGncvlLZq82RGZ65r6vus6Vkr21kwNVcmLZIjn8RHj7IjGBNdYUqrDwK5lZb7hj5X x7i+7f46tYPZz7yI01MF04ebLOmMT0xMo1TxV5Nm9gdVemCH4v+Y3HRzbCQe1pkkq7M+oiZZ+oz bA7Zxt2RG97sJ08hqmNiPmlpRlyZDI/V7ASVw6E2BmxtDRGBApO9GRXcVNigO/crnzxjj1C6gzF p1Ik6KtKlGwWfT3sgrkPpcLIJt0kJ5aeICel7KferYVmQ== X-Google-Smtp-Source: AGHT+IFjMExgn79GILTUWDI+IttGXsuWX87E8XDfkKQxOQrTRs9cFV/F0fmm9JsGRsUA12UNI9SynQ== X-Received: by 2002:a17:90b:3d44:b0:2ea:696d:732f with SMTP id 98e67ed59e1d1-2f452eb12a3mr73835660a91.29.1735916707402; Fri, 03 Jan 2025 07:05:07 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9629d0sm247047255ad.41.2025.01.03.07.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:05:06 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v7 10/10] selftest: net-drv: hds: add test for HDS feature Date: Fri, 3 Jan 2025 15:03:25 +0000 Message-Id: <20250103150325.926031-11-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103150325.926031-1-ap420073@gmail.com> References: <20250103150325.926031-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org HDS/HDS-thresh features were updated/implemented. so add some tests for these features. HDS tests are the same with `ethtool -G eth0 tcp-data-split ` but `auto` depends on driver specification. So, it doesn't include `auto` case. HDS-thresh tests are same with `ethtool -G eth0 hds-thresh <0 - MAX>` It includes both 0 and MAX cases. It also includes exceed case, MAX + 1. Signed-off-by: Taehee Yoo --- v7: - Patch added. tools/testing/selftests/drivers/net/Makefile | 1 + tools/testing/selftests/drivers/net/hds.py | 125 +++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/hds.py diff --git a/tools/testing/selftests/drivers/net/Makefile b/tools/testing/selftests/drivers/net/Makefile index 0fec8f9801ad..a3bc22b32f2e 100644 --- a/tools/testing/selftests/drivers/net/Makefile +++ b/tools/testing/selftests/drivers/net/Makefile @@ -10,6 +10,7 @@ TEST_PROGS := \ queues.py \ stats.py \ shaper.py \ + hds.py \ # end of TEST_PROGS include ../../lib.mk diff --git a/tools/testing/selftests/drivers/net/hds.py b/tools/testing/selftests/drivers/net/hds.py new file mode 100755 index 000000000000..94790dbb0eeb --- /dev/null +++ b/tools/testing/selftests/drivers/net/hds.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import errno +from lib.py import ksft_run, ksft_exit, ksft_eq, KsftSkipEx, KsftFailEx +from lib.py import EthtoolFamily, NlError +from lib.py import NetDrvEnv + +def get_hds(cfg, netnl) -> None: + try: + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + except NlError as e: + raise KsftSkipEx('ring-get not supported by device') + if 'tcp-data-split' not in rings: + raise KsftSkipEx('tcp-data-split not supported by device') + +def get_hds_thresh(cfg, netnl) -> None: + try: + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + except NlError as e: + raise KsftSkipEx('ring-get not supported by device') + if 'hds-thresh' not in rings: + raise KsftSkipEx('hds-thresh not supported by device') + +def set_hds_enable(cfg, netnl) -> None: + try: + netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'tcp-data-split': 'enabled'}) + except NlError as e: + if e.error == errno.EINVAL: + raise KsftSkipEx("disabling of HDS not supported by the device") + elif e.error == errno.EOPNOTSUPP: + raise KsftSkipEx("ring-set not supported by the device") + try: + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + except NlError as e: + raise KsftSkipEx('ring-get not supported by device') + if 'tcp-data-split' not in rings: + raise KsftSkipEx('tcp-data-split not supported by device') + + ksft_eq('enabled', rings['tcp-data-split']) + +def set_hds_disable(cfg, netnl) -> None: + try: + netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'tcp-data-split': 'disabled'}) + except NlError as e: + if e.error == errno.EINVAL: + raise KsftSkipEx("disabling of HDS not supported by the device") + elif e.error == errno.EOPNOTSUPP: + raise KsftSkipEx("ring-set not supported by the device") + try: + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + except NlError as e: + raise KsftSkipEx('ring-get not supported by device') + if 'tcp-data-split' not in rings: + raise KsftSkipEx('tcp-data-split not supported by device') + + ksft_eq('disabled', rings['tcp-data-split']) + +def set_hds_thresh_zero(cfg, netnl) -> None: + try: + netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'hds-thresh': 0}) + except NlError as e: + if e.error == errno.EINVAL: + raise KsftSkipEx("hds-thresh-set not supported by the device") + elif e.error == errno.EOPNOTSUPP: + raise KsftSkipEx("ring-set not supported by the device") + try: + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + except NlError as e: + raise KsftSkipEx('ring-get not supported by device') + if 'hds-thresh' not in rings: + raise KsftSkipEx('hds-thresh not supported by device') + + ksft_eq(0, rings['hds-thresh']) + +def set_hds_thresh_max(cfg, netnl) -> None: + try: + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + except NlError as e: + raise KsftSkipEx('ring-get not supported by device') + if 'hds-thresh' not in rings: + raise KsftSkipEx('hds-thresh not supported by device') + try: + netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'hds-thresh': rings['hds-thresh-max']}) + except NlError as e: + if e.error == errno.EINVAL: + raise KsftSkipEx("hds-thresh-set not supported by the device") + elif e.error == errno.EOPNOTSUPP: + raise KsftSkipEx("ring-set not supported by the device") + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + ksft_eq(rings['hds-thresh'], rings['hds-thresh-max']) + +def set_hds_thresh_gt(cfg, netnl) -> None: + try: + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + except NlError as e: + raise KsftSkipEx('ring-get not supported by device') + if 'hds-thresh' not in rings: + raise KsftSkipEx('hds-thresh not supported by device') + if 'hds-thresh-max' not in rings: + raise KsftSkipEx('hds-thresh-max not defined by device') + hds_gt = rings['hds-thresh-max'] + 1 + try: + netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'hds-thresh': hds_gt}) + except NlError as e: + if e.error == errno.EOPNOTSUPP: + raise KsftSkipEx("ring-set not supported by the device") + ksft_eq(e.error, errno.EINVAL) + else: + raise KsftFailEx("exceeded hds-thresh should be failed") + +def main() -> None: + with NetDrvEnv(__file__, queue_count=3) as cfg: + ksft_run([get_hds, + get_hds_thresh, + set_hds_disable, + set_hds_enable, + set_hds_thresh_zero, + set_hds_thresh_max, + set_hds_thresh_gt], + args=(cfg, EthtoolFamily())) + ksft_exit() + +if __name__ == "__main__": + main()