From patchwork Sat Jan 11 14:45:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936058 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 98BB9374F1; Sat, 11 Jan 2025 14:45:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606753; cv=none; b=UaLFhAHU8mPYexH4qHOYmzA0471qQ/5OMKtpLhb8gt9xuaboC+eZULd6mVFh7uaGZ8xl1b94k0yMfQXTR+FJGdx8nO2Z6pxgk/SUuRQGJc6sAbJU6BVmUK+4yDzXVpYmmja6NDKyYIkY7FahWYilDrnP9J7Jgr2UQdp7iEzwBeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606753; c=relaxed/simple; bh=WGu6vDMuc9AhNox5PTrNAaX0IeLh5kPU1Xfs9m2S7hg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dSlOWySpzMi4Br2YcmuOS/FHZPx07AEeYKIlaSSr1u8bNnuIPJg2KQ6FJR3706VGNANyCnloNuzoG/AQ5k/OWnSmkjGKTYR9r1VTWNuqDvriKfeofAqrW+iPwTEFwJjBNbrQU//x3jBE42z1cHFMUQQtKtbQcpp+RzPXd1CIEaE= 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=ajh9mq5X; arc=none smtp.client-ip=209.85.214.173 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="ajh9mq5X" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-21675fd60feso67267855ad.2; Sat, 11 Jan 2025 06:45:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606751; x=1737211551; 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=oGYhWUkw+Na2G/tYr31iX4XrARumPudcKMPC5N3X34A=; b=ajh9mq5X2H7wfjTq04NrCoKVf5V/QxRkU5oRP6ZMSuK28ggbOnGPTdP4h/4iU4rsql 9+xKIpvbG3xLl8XMV0Hgvg8guwg5XConyF/5PiyCKDEj69H1yQTh1P25MGvGWr9h9Lom nYc8gcQcx1SV16H+x6lGZ3VArpdpBS811f4Vj35S3JUcaSExAWgA4XLUais3QZjROcwP CqtoFlgzi4PaCQaHKbFIqTM4ALtMD0bALsa6ijhmY5lnqlLCmettwBikv7AstNqA620j 2vT80wgVniYTbUjr6wkc3DaliwIBD9BjaMvZ/ohyk9/ZtgYib/vWT5vw0ra9ubt0HE7Q LC5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606751; x=1737211551; 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=oGYhWUkw+Na2G/tYr31iX4XrARumPudcKMPC5N3X34A=; b=hDzmPot2KMJJjYCAIRTHc5y3+M8Fvf7T8RzUzXtBOo8lzvbsPjl1gLfqwuTc+n2gVT z5fmJaRCkWNKHSY44efxfLLX9yUw5btzhXeVBsswpTRhmKZWX0QyyEGbYMyx+pxRl6DK I4mrJjLENCzKXxs0GhUCdVgcCLYuTm7aOAb/1+kVziFgdZN08sOzzhBRNLTfmyJ65vaq INdf/TLXMO5lNblPSlztP4ede8N5KySwInVKNo9VHm9Q3+8lnpn0ofPpR98IOIGmb/XN AFEEWdYnDLYC40B6H+aiY/BliUadMqc95i4ggIYoP3mgdNrtx6UgBfD5GwTcBOICHL9x vjIw== X-Forwarded-Encrypted: i=1; AJvYcCVAvoy1b0Wh6Osb+vayKgueD26WV8fWzZBOpQhOmwEyWNFqcy2U00P5SreVPnlhZJ1Ie2VeeDAM@vger.kernel.org, AJvYcCWKrKXEnTu0CaLaVTf6rPZ5iZldYRIcsEbzecZ9JSJkEeh3V9/Mk3TqZNx3xw2R6XvR2DEe0F4YZwc=@vger.kernel.org X-Gm-Message-State: AOJu0YzpqWFlKXut/9ngTsLjcF25A0NRJGhUyrHG6KKudPW6thh2nzjs ZguIKF1a5uMTFXaX5JAb+aN3DEJ5q5nW+4/dcakLJCEZbdDMabLL X-Gm-Gg: ASbGncvu+jmUmltPXDNpyYgr7PvKrxiMhzSWn2wDHzZ1BJle/G+BAuVz971NiEkkr1u gDuDSPPUrBpHtfUWNtNF1geJElr9XY0UizPvsyUTjj4Gbmr5lngMYwSfS1OtkJ/ngyD0SvWggmP nuy6pQsZXv4vwjFp2/OF7xLEGWdFOty9xWAZN919xBtLZMz3YeGeU3i8+FSASuQ8cA1pAkVJCk8 kgWH/Jl3djehFxCnbyvPs7rLAQx5OLCymdN3XLczLX7AQ== X-Google-Smtp-Source: AGHT+IGhYsOWsTKHg9Mpf3L22ucdmXx84JGCpRfb1co5t/gRbf3jdEVXTI+K6NXdMh1RUL8AGQ3lrQ== X-Received: by 2002:a05:6a00:1909:b0:72a:a7a4:b4cd with SMTP id d2e1a72fcca58-72d220025bcmr22104359b3a.21.1736606750754; Sat, 11 Jan 2025 06:45:50 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:45:50 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 01/10] net: ethtool: add hds_config member in ethtool_netdev_state Date: Sat, 11 Jan 2025 14:45:04 +0000 Message-Id: <20250111144513.1289403-2-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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 --- v8: - No changes. 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 e84602e0226c..a5f12ffa903e 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 e7223972b9aa..2701920fea05 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9482,6 +9482,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 Sat Jan 11 14:45:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936059 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 8B6C2374F1; Sat, 11 Jan 2025 14:46:01 +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=1736606763; cv=none; b=TME1//mGFktu3eRd99tUmdrx6ouJiRCefBk3alL+KJL+Odgd8A6hjNvWEhUJjghfqjdZ440aSjKyLhBAMS3Pf/0lkTsIIDzgkDGgeRr1YMXbnWI528qLh5z6DsWNYBkq4p7yJNo6X+5/lfzyNg1CZmcT0uwDD+9bC8ViFRi/Nyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606763; c=relaxed/simple; bh=GEkMd3IX/iLsmpyMVtzNyFoUzUfzrXcadVlz6lxGPP0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qgqFzYBorQkb0AEgp943Lc/wxmHFW1Wv5rueOpjgnXd+nL/vxo8aNo836OkY9RLk/KZFONnqJ6xTO8+6sNYlnz3N1P8dSKw1cf6yaRh/UxpZ82y4vl6vDnv+QUtMb0AJ8WbqPkvMCc4ozqjnFvKX6XAwyjW+BCx4ViqssXj676E= 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=OV3Dl0r5; 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="OV3Dl0r5" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2163b0c09afso52280295ad.0; Sat, 11 Jan 2025 06:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606761; x=1737211561; 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=BFXY9XY1AEcuyjv44YjFbPZyhkpeSCZQhMS57baEkmQ=; b=OV3Dl0r5biXv0IpHU+nxMg5uff6d2WUArKSSiwBu/E3OVi2BtKEl6274SbWNlyY58x WD1/GdE4qMosz64MtVdmAaYNX2xaEtpEVXqOdRqWqhBYyknjpOF/7PNgF/HH9p66htZX oCuCQJpgoGVK/pOECMleWd8D/NJIsltumFS1GOZKasIZJtTMCN90Lj5JVrUkimfaalxO dI0+dJpCwu91Id5JHX9eObUJW+nmaBSAPYhYIj03g3GbgwKwYrqZoLxbk7zrzmaYCsnG MTs1U/MAuN6yqfUHuDgUpxTBZ+0tHL6zLUc6g3gcmSA5alVTpY6o81U17zHMVFFDSyXf 7/6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606761; x=1737211561; 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=BFXY9XY1AEcuyjv44YjFbPZyhkpeSCZQhMS57baEkmQ=; b=S7zPdZD5X+kv2yLoTlF2/81LQJ0tIMPM8HyntE8SnMlrodIJyJ58Wuw7M9U69vshNY eLBif8qNqHczmdx8iuQBm8uL3FiNhHCPMD3YdsluW5sHORe5RW+PNUgz1nhc91j8Q5Tv Tv1E7A5zISQ5Pi5vNVCUIlhq3eZ8RdxQoTkKnEIleeaCWPVL2aTllfDdH7PbTpGsN7+A JZwm4LNqOmFGdBlan7zxSRMAFNBe+DAyKJQ7LZq7OIlADiYCCZ0tl/xWESg/CzhdmKFF wN/UYdONblhSCOmkruptnXQ31FidCiPYstD7FuWLH/9TKnxwXHXFjAQwRNxH8TKN47qt 6cpQ== X-Forwarded-Encrypted: i=1; AJvYcCUNyuORFJDm/CebBL9MrX8z0Vrqn6yJdGsWYzCf1GEhxucdg3RIj5HlVnjlqp1pOaA+N8FY5c/CqqY=@vger.kernel.org, AJvYcCXnP/M89SWzXHTQNT9G7LxDVop+vNEmNbdPrUpieKthG0yROTk+UK3YyYS+99iO8E05RT90ygq0@vger.kernel.org X-Gm-Message-State: AOJu0YzQ6IVFY8VQNjoM8zjG4jnrwNHEwFoz/B7ti9f9dD+4CiPCBw2t VcTnKMeIiOyzBC+WKxSNLOVqMYuI2xJCQEpPeHDQS3Wslc3nC+4L X-Gm-Gg: ASbGncvc4hL+U6L6j/DTNISjuxHHwJ+Oi0VhMOo1zFePSOwEzOs5MkGjultTVAI4N2k wdZpYPbEZDRhc8NKTUqT7SI4R7JQeaSSCTYcAo4CxmFBIWh08IhJMHbLQj6YjdFly4QSEGWN6Lg OXiX7ZSyChZUUkI6M1+B9KGnvuIeHU5xXjt38mQAXcde6QdLjdiSVrP6XMHeQleNNYeEYMLc9BZ Na8wjfUi7FDn1drMixakW0906cnzSxE/ypvg1sEo9eHFg== X-Google-Smtp-Source: AGHT+IFw72PZ3G3GrVGGlhbn9YZzIQlrGxweNIubsPH5euApAy1ZY5Ojvd8rWCdT5EoROiVLlP0jNA== X-Received: by 2002:a05:6a20:3d85:b0:1e0:d848:9e83 with SMTP id adf61e73a8af0-1e88d12b3cdmr24197382637.25.1736606760688; Sat, 11 Jan 2025 06:46:00 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:46:00 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 02/10] net: ethtool: add support for configuring hds-thresh Date: Sat, 11 Jan 2025 14:45:05 +0000 Message-Id: <20250111144513.1289403-3-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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 --- v8: - Make the handling of hds_thresh similar to hds_config. - Update comments of hds_thresh and hds_thresh_max. 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 | 9 ++++++ .../uapi/linux/ethtool_netlink_generated.h | 2 ++ net/ethtool/netlink.h | 2 +- net/ethtool/rings.c | 28 +++++++++++++++++-- 6 files changed, 55 insertions(+), 4 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..45d8f107b42e 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -78,6 +78,9 @@ 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: Packet size threshold for header data split (HDS) + * @hds_thresh_max: Maximum supported setting for @hds_threshold + * */ struct kernel_ethtool_ringparam { u32 rx_buf_len; @@ -87,6 +90,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 +102,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 +111,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 +1141,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 +1149,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..a381913a19f0 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) { @@ -261,8 +281,10 @@ 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) + if (!ret) { dev->ethtool->hds_config = kernel_ringparam.tcp_data_split; + dev->ethtool->hds_thresh = kernel_ringparam.hds_thresh; + } return ret < 0 ? ret : 1; } From patchwork Sat Jan 11 14:45:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936060 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 73ECA374F1; Sat, 11 Jan 2025 14:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606772; cv=none; b=OgNNjsdemLmc36unGa0t7K4kz+jZhXhSp0wZSUIaaK1xEyxk5Yl8hPH4WcCS/he7BSAy0iE4XNODN7kuOopcB5HS+WyA28ykt7gwcbAo6HgCxEycr9H+Cj2kN8ygqcfMwunHM8jcJrpBRc0cskNhD6nRlJXIGXfpmZjvto6VinI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606772; c=relaxed/simple; bh=gZDxZR6wAyYLXNuCzPTtGo2+1ddGAwssPkoAf/rfU/M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rXsz1W47yeAWfMdyUiwb8bY1tr6qaWydU6VBNQtyd4SEBrovh5VhnU5SWerhiHP27sHa6HhNBMQstQ2CAJFTlqruKLq3djvoDRbH64CwrG8/x9mTQANl6xTf4ebJWwdJGTGMVREpiVEhwFvrVvKAwBRvrDtUKCrIVeHxZswca+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eEEPLAuH; arc=none smtp.client-ip=209.85.214.179 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="eEEPLAuH" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2162c0f6a39so70850325ad.0; Sat, 11 Jan 2025 06:46:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606771; x=1737211571; 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=XqXP+XBPEy2KO7wvgay//dP2eWiCD52Pp8bYG85Q+tA=; b=eEEPLAuHHMbije7P4sGwrdRgVvwnGQz98eRHmDwu3wrxwpgHolH4PG+Qcsj3/gYvpt aRs4bfKdNCHyd7/ZkJ3jnASXXFvtLkV1GL54yS/xjneEzsr/VjDabva8JURhEP+QKFNa utbW3tfYOdXwKNZyrAaF0NfRauMJ2bAtY1VKisg+LgI1lXIthBXp6lMXx//DIcgSXUZ5 WY2njRMD4fKo8q/kTUMR5wgdU7FLhQ9Y2g5z4/yuaAHyvTPzWhnurQxKx+DntAbsmNsF pJidaIQoEwRm+rnTQMHEliCIPlxnDnZivDcx/L+a++r7Dy/AiJsWoAQOPjflAO9J8PaX duQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606771; x=1737211571; 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=XqXP+XBPEy2KO7wvgay//dP2eWiCD52Pp8bYG85Q+tA=; b=R7yqeGTHwDKqy+1GszsWQIbF0TndNpNCRYQZpmGGU5/V8bCEH4c5jFbeFS6eLuA7Uv JkHKoKDaLEmgBDBSQKFwIWQQyiDHg89iXO8sjuxYvMaWditvtC9y+H/TII/KcQJDhiMb 9gaOf8D4HoRp+3IIQTG/O7lm78XoSwcro2hfPGQEeAFaThYKIJZU7bT9vBpPThhbIJ1w 0c3mZ+nMGoWNgFOAsirwILmuv71BvtsKpxFQp1111xa0vSc7VAtA1JrRQ3Sw6Fml/4cy EDZqrHn5l8PBqDOBFqTtzE6GYoIFqvByxOaCJCwrQLqHH2KRM60Tm9ecfNkGqFXg87Lk Mt2g== X-Forwarded-Encrypted: i=1; AJvYcCUy8d4SW22Ap4OrKsbq2eGSaKxMlYnqQBp40GD+ky4OjGNjvWoNNymsbrEJG+3cH2xj5NBgKvMW@vger.kernel.org, AJvYcCXzoQTetlAtMrkrkb3fUw66F22ZR53AsHHQPUvFof/RmmlKoB0WsE2cG+dimr7wx6DOb/ebAa0+ZAY=@vger.kernel.org X-Gm-Message-State: AOJu0Yxnt5Tfb6heksbWxF9BtNCHwUYjI00QdzyBr2uE64rYjvyxASK8 Ey5rEZaU3Y7CXHYYYr729vE8ZxLCSbWDvo89A1VSqPuAXaNIGesm X-Gm-Gg: ASbGncuaJzkcSxqgwgWZhjezH3P1Wow5l5kWz1ofECVpDEsJvZHoeKwXvsuqLpPIrGX Rr929xVqsIaafSOnJe55DuuPcqm/Hn1z1Doguo176Jr8Doaab1R1oH0Ovq+3OGuoYg+O9w6HyDn AMKiTnfm+QOIOwe8OajIrLe6UqF801YT8sGDaw60//HnH/f/XSB0ANROK6+8NtIrozie1YfTtZ5 CZdz9BExzqOeET6XAgFqa13bxJqRoLBFuEn0ZwONhd7OA== X-Google-Smtp-Source: AGHT+IHapTVGieGw3Zi0oPDCdclVjWDB1Mointj4VmrN2gRujFZdeVWV20j8x/rJXX03yJpBUYqygA== X-Received: by 2002:a05:6a00:170a:b0:725:4915:c0f with SMTP id d2e1a72fcca58-72d32506c6fmr14309817b3a.11.1736606770684; Sat, 11 Jan 2025 06:46:10 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:46:10 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 03/10] net: devmem: add ring parameter filtering Date: Sat, 11 Jan 2025 14:45:06 +0000 Message-Id: <20250111144513.1289403-4-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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 --- v8: - No changes. 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 Sat Jan 11 14:45:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936061 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 5AB411ACEB3; Sat, 11 Jan 2025 14:46:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606782; cv=none; b=SceSpelx9pezt58aUpKFumIQegrArWwfs3kzTsXV9jLxxsxAsD03B+iwWmha+fxHzuo/BHPXx7h2dbb5qimPdv6W+7Knvp6plbnGxL/Ov2pU62zv8kaekoB9rBvwMq9iF1kwzWxN04dhmXCQxsqME3EjJmLOVyGtwJ5G8BYXrMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606782; c=relaxed/simple; bh=7Hv2+j1gqFRCBBX4Vhrv90cbVH+8CBZGIHZ8eZqUCbc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nPdK0mo4I4HyvwH+JUtlds31tE3Kzlq1F6byqDsTqM5S2PE22pYqGSX2DkSZgyu/quswbDUJHUYsWT4ls7OQMH4u/KnYetMQFmMvjPifufOXDdMBgaFIp2gio7Jg/9ddbv65mfY9C0qSipUdegXeGEqDInITe+GPNaRU7GWAQ2k= 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=i2eAHOoq; arc=none smtp.client-ip=209.85.214.181 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="i2eAHOoq" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2162c0f6a39so70851595ad.0; Sat, 11 Jan 2025 06:46:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606781; x=1737211581; 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=ge7d5xxrX8Z1wZ+vMnyLBHwBGoZEYxbK6jsDnmmefh8=; b=i2eAHOoqLUpXmzWEfVzecJqGxpPQjha2ALT2pFjQoCUWiy5LP23GSLAfKXeuXQr7IN bOIe8x/fqr1VF108Vg3wV+TODsWJZi1joUlYCWqkUhAstwsw42prteuCAUxL7mGbXyxY 78Ihcan6M+PNRdremOy9LaSA6kZlpTi5rP7GDMP+AwvupP45ypNx2wVJ2v1uZMLfjajo QlI4dcrizWQ2akZvQNfuArdONMg11HtfRBnMtGMJRWyU5QDAtQSqAC0qrEntgwoodhxS 89UC14KCfbLKhPDXixfpzzTFQYhqNGJjjmnCOumtRB/E39adsJXhX2ZQ5Ndo8TWy6M1+ BK5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606781; x=1737211581; 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=ge7d5xxrX8Z1wZ+vMnyLBHwBGoZEYxbK6jsDnmmefh8=; b=V4Va8AaJ9mPBxetjgpV7CgZeOSlJK954GTtM1rRQm37x2X2OXbE0vs8Lh9zX9VwpqN iDKxwE2wS2QdVrnPDL0LCfsAiTShJI6o9qRSQ4b2VMU+qJLHh0ZfbOxu33HZbBAGn17K Ql0GhibPL6mcOKWs1C2gYOI+2lf0WZwG/yXa1VBhA6PSjQXljxFQO6scgArVGYdNbOuG KWd84X1VOUROn/Nee6zixt2zXwcDOGvYJT+h4C0xM3Jcw1SglRrGLjxW8o1e7zK6VpVg JU6o0Bf1H5ug6rBbPgJP5Z4laWSRA5aOt+ckTZq4IHgE5w+bNt++f1lEbl6D5kj5Fqz6 92Cg== X-Forwarded-Encrypted: i=1; AJvYcCUVEtfQSe0WcFL2dZvQ6CofcNHfRh4htepfi6ETuOdz/epTaeP9Ynpv1my2hObi5GolVlPOxtGb@vger.kernel.org, AJvYcCWwW7fb9NtjacwQhCS9G+oOHr2I/t9dWxXcq0bjGoJ3bkOqZLvmbYbqvtq768vix5IcM8QeLwCrtaU=@vger.kernel.org X-Gm-Message-State: AOJu0YyGzLBiNN08FpDp25miesCLINuisXWO1w6KnRLgOhx8YWmqmvxd lrx/o/sGyxWnU5rvIq/cdkIKTMm/eNtrgbcZFmW4+ibRZUR8GoW4 X-Gm-Gg: ASbGnct0M498OII0cMpzHnXoEihFl05xjnCS8yob9/NOK2gKxQYVddjP/hDeCDPnSXT hzkT2pmZzNTdarznVsT+Zjq0KPCmdlA9eIUROpgQWqME6ccONYjjzXgp4+bb1VqdWlJGZiK4zaF 5LG6A4nNGlCKTq+5yS4z6/jHbLf/K5VJG1gUG0i25bjb1fIGDaLZz9PyEhyf8ksOqCayulhyFVN eZQe6QNS+Yz/tolcPO9+jpXDpj60ibE+izMxE+hnTAoqQ== X-Google-Smtp-Source: AGHT+IHfsEL3ThCvlKUXlPsLOpROxWBTv7hhI7qC9cArSzhxPPijVCGDfHFNiAZHbvbTD+w71d82aQ== X-Received: by 2002:a05:6a00:4651:b0:728:15fd:dabb with SMTP id d2e1a72fcca58-72d324df33amr15417284b3a.8.1736606780674; Sat, 11 Jan 2025 06:46:20 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:46:20 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 04/10] net: ethtool: add ring parameter filtering Date: Sat, 11 Jan 2025 14:45:07 +0000 Message-Id: <20250111144513.1289403-5-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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. Reviewed-by: Jakub Kicinski Tested-by: Stanislav Fomichev Reviewed-by: Mina Almasry Signed-off-by: Taehee Yoo --- v8: - Add Review tag from Jakub. 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 a381913a19f0..d8cd4e4d7762 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 Sat Jan 11 14:45:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936062 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 5FBAB19AD8D; Sat, 11 Jan 2025 14:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606792; cv=none; b=VBFzoJ4MrHL1pZ9GqMRHsLzJZUvaW0nuzrLATczFSmejfuyrT5vGElFrkBTT11Muk9FSKJ+JlBaq/9BWusvOvU/4wdVV5WG8ECeJ/B4NhE9SJ1j6qVbKsYmzCdlZLg4Ll4OWmYeGvy7qbMj7ckAGKNjzBLyTjWdW7/VKrGCbLUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606792; c=relaxed/simple; bh=TFUGwOY000b7ECS/SUThlSGrc9Ir6DhmTpLcfk/T/io=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OEOyHRJqklfOsayQXsyiOlgwkFOQk+FwVjUhyZ6ozCPlF/qOChggJKlm4S688oaYiMMkH8RmGF0MXEokRH0UvkgLn0A9eFuPA0MUKZcNhWG1oIZhKMig/C2YUYy12TpriISWyUFNEpEKwTArl5PBotj4/Lc/fLZC1YRLEeie0Ls= 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=cPbPWwL3; arc=none smtp.client-ip=209.85.214.179 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="cPbPWwL3" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-21a1e6fd923so66556475ad.1; Sat, 11 Jan 2025 06:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606790; x=1737211590; 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=oleZPm/uQ58mWMFgGwU/0hEEtcx09X7TNRA0EpQNiwI=; b=cPbPWwL3k6wuh31MAB+P9O4nXxFH8kvTQ0CvgNdpwNFm08mfqJJWeyCBZyl0vTFW3B vu91wmIViFXoMRtYQ6/8PDf7KcYQUXuwaeiMfiNPYT0hZnounXhV7Yp811BUo45tTNXE +NK1nr2PCr4Wu4nKf+Ix5gZPz7irktmkA0Q2g3RDseQvhD8Tt/lVqJHwfquxtgcEisFP 2NeqAfgQQuwrIV67gY8rCmgm5wBfrTHyTc3FMI5TecJRWhGsEPDfx4gWdjEyu4iDs8te BkctpBvOA7kYAYXNo09VUu1JPKukRLkmFpuS8TW82E3+oZnXEWwXiEQL2sRDWkXfSjAC f4Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606790; x=1737211590; 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=oleZPm/uQ58mWMFgGwU/0hEEtcx09X7TNRA0EpQNiwI=; b=Ko9h0Q8qrEmT5LzPcUn4+SiD9x47eYoKudSwKNUgqZqcAFcorsA1LdSIOtdvRaXyxF yXrsR/qze0hni6+IFO/SvTKearQtCbmvo5xGpQXnbC4ouiW3+u2EVQxjULOyRn0/yeA9 y/1TxXZDbLwxXeuT6API+9bGqHv8qZVp5G4lJ3v/RSq/YvHAuxlqukgusn0rmvCmSTyI iqIXLiLARD/ATyjI99knA82XK0CH9AW055Wv9KlJOQeqhwile1smNt0eIuMr/z9tE+5k ckf+oXSKVg2vldaw2Vn/TGVVYj28FuAy3xYIt2MoGvO/Fp/mq0JCa46wFB3me/CsQ+oo iTeg== X-Forwarded-Encrypted: i=1; AJvYcCVuBYPBzrpTTdDjT/RRXgTHQRGJe3f9a7u649phtkDRSTRD9BEGGQsjelnA8da2zURV4eyu6asS@vger.kernel.org, AJvYcCXcOa/712Q1KNmO9aYjXGVPnhm6xc2MJTvLAC+SMRqaki+5bmpWyDr7XbkDB6kRTN2KVWLBZYS/dW4=@vger.kernel.org X-Gm-Message-State: AOJu0YxyzL6H1w/nlfpClUa0NkIrBOulCXUHrS7yhWXNcgoP+feFaWl6 5EzXaHsB8o3TlwqSn0aJwVfPLL7Wg6Lp270gcl3pt27z3tvdEm1J X-Gm-Gg: ASbGncvjWzh6tSP/MMGEDOOYoocxM3nzJeenHwbZKN0gXDsWeqLKTpIuHXQKJRpEJLw h0Fe2PN0ZZ+WzaqYrS2TUd611ceA6szaFSDO9gqaYK0Ho2FWsVtHRhU3z0kWIdeM4Wyi03YKYqD +BGI6gyB0fuPce+Rx0Yg0DagSh8T1hsHV79vRb4zipfTXEehSKqJ92/yM0YMZhpS9HnXC/YlC86 5hkUhFYmuDxSN+c+kjjRzepJ7D47i+Rud3+cVS9FybXhw== X-Google-Smtp-Source: AGHT+IE4AXR4vrxTUByR1P10rPN0YGKRhuE7x8hzqKu5c+XOgMg284GNWsGMbU92QAPXGfDvDKoVpQ== X-Received: by 2002:a05:6a00:39a7:b0:725:eb85:f7f7 with SMTP id d2e1a72fcca58-72d21f17c7emr20506589b3a.5.1736606790621; Sat, 11 Jan 2025 06:46:30 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:46:29 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 05/10] net: disallow setup single buffer XDP when tcp-data-split is enabled. Date: Sat, 11 Jan 2025 14:45:08 +0000 Message-Id: <20250111144513.1289403-6-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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. Acked-by: Jakub Kicinski Signed-off-by: Taehee Yoo --- v8: - Add Ack tag from Jakub. 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 2701920fea05..2b2fcca199f6 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -92,6 +92,7 @@ #include #include #include +#include #include #include #include @@ -9499,6 +9500,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; @@ -9536,6 +9545,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 Sat Jan 11 14:45:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936063 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 8F1C31494D9; Sat, 11 Jan 2025 14:46:41 +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=1736606803; cv=none; b=nOGtIJl7zjbevqK9iZqfeC2U2CUM0zPm0svwFw5VGrpSRbuqYq23gbiIPs3P64aMrFD9ysufHYVotFGx9qSWJxUczkNe88g8MmHPoe1V2zLRoDZSxAjFUl7iXfjliUl3wwhZ4quXMU4IYrmFSfoq1YHIr6UZ3ayEG6oNxsyG5QQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606803; c=relaxed/simple; bh=eeLpDNb1dB/nhj7WTgSaQW7Dn31sRGs4YapMtT+HtSQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kP47Cv27Sxf3Csyga9W84Db2prnS2bFZ7NXgTApgZswvCHUmJWyOQ5Lv/huY36WNInClCOxqsVPP8Msiq3mGQ6+8FILmLRBOJ2SUR8oYWXThRXE2XrnfCx5KCV6ITmExB4/gwuR2pIT/y64M2e9RMDGgq1Tj+R+oEC7aEUoPdjk= 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=GoXYrewB; 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="GoXYrewB" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2162c0f6a39so70853835ad.0; Sat, 11 Jan 2025 06:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606801; x=1737211601; 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=uB4GagNp0wIoPpoRAQtIq8+OKkkrtMO/POdDGJFE/s0=; b=GoXYrewBqVOvfK1FMz4CQhlB0V2PPCgE6UzQ47cFiSKYxbTvD2p5ncusRt2+Zscilj 4pDd8M9cBiTr/rMItxQncrMo8iAj4hPWsWn+vwc9cY95L6BkAieq6RI1fuQgOVL5MCiW 5MMlbUrEuzLOJsBGMKYfRg/rbBB7qj0N4dmK2A6ojGl9g0ScTt/ohYnu6L21j8h7Az1w bJFUt2GZQmovi3KayTI/IRABL9VCI0+WZDxoVRXKA/dsfIMTBn2ZogzYiVdr9JRYhL0q iLoW+fyb0pcusLlHdh0Wupb6tks4GePg2tYXLE8hO4X9Uf4jRBn8NTGqs9KhWhpVrIPF pQog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606801; x=1737211601; 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=uB4GagNp0wIoPpoRAQtIq8+OKkkrtMO/POdDGJFE/s0=; b=gOPNEPZVVPSV/T6R+qGa97ZzG8Z9hZjLvxZ+8n/dRMQpdA77P0q5YmJAYMTkt9kfFT 3bppM13Hr6F+qDSqm3voMRaLGpzBYIYibgW5ndV+1fHWWO/TN6E2M23CFTlyDNKOvnLQ c9rB6zf6OuDD0P5cnY5/rnjr2tFJNoFCHxgubg6JsFX3//6Vxtb/6LAXQWLQe+S4bauW emHeMGAYiEOvl2+my5tBDLqFrUQyd1QytDvFq+Y1MV0ZRogvJzHp+/1tKPoDI5uYWjAt +m77qWhxCLR88l8OHGDFtCeqLTX8oqNLsU8fdzQ5Mh2gbBn9y97/DNQsPwhCIpB9mCai imQA== X-Forwarded-Encrypted: i=1; AJvYcCWXl654dtdqYQMRAxELymlMlhtQK1S+JHV2dZCKltp8W9+BAh5DhUV+bd9bX34UytXWHLYIBkUKC8s=@vger.kernel.org, AJvYcCXxp9KPQaBwCgQxMmN8iUy5J7Upq1tPFiTrRMp2/m6wQqfSpwIQwA4svn5h6bBsFk/QNQHUO2lQ@vger.kernel.org X-Gm-Message-State: AOJu0YzVZ4YN8KXvJ6VSYzW75WvcWBpiSeQyr1ipNDz6fcrTI1u2AkGG xCVpDm92XNKgo0/G+0WRpkuNF2uCgbGcMaEPad+v9f1U8jx7E4PB X-Gm-Gg: ASbGncu21QX5TjSasEl60vQJVr3Wn24K0ySiGzZwR/oSZMXhnVyh+NJpY79AfNWNP3x 3p80MuXhebraekVTnKBkB0caBasbxkb/QoGmWuSDq3cDenQQRRKztIffCEupa7URdYuDVMpB4CQ N25mlWjNLZgeJjSAqr8b9d5Jenk16SBsNIsbdkWrpNH5d1IVarVrYH1yBP+RB+dlqi7DQbLXD/l k1BMou522M4o0xEElmwqCTiSRIBeet0bbzku5ditzuTbQ== X-Google-Smtp-Source: AGHT+IGdceYXlbeGTkNw5l06KUhAsLecG4XHCiC5aIAyPHSHXKqy1PsACoW44TB6wtF35ew6vYnrrg== X-Received: by 2002:a05:6a20:9150:b0:1e1:9e9f:ae4 with SMTP id adf61e73a8af0-1e8b15f7db0mr10329770637.13.1736606800808; Sat, 11 Jan 2025 06:46:40 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:46:40 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 06/10] bnxt_en: add support for rx-copybreak ethtool command Date: Sat, 11 Jan 2025 14:45:09 +0000 Message-Id: <20250111144513.1289403-7-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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: Jakub Kicinski Reviewed-by: Brett Creeley Tested-by: Stanislav Fomichev Tested-by: Andy Gospodarek Signed-off-by: Taehee Yoo --- v8: - Add Review tag from Jakub. 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 Sat Jan 11 14:45:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936064 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 AFACD1ACEB3; Sat, 11 Jan 2025 14:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606813; cv=none; b=jZ7bytc/7vRXbGhyiyvtqxs80hUS4DP9/urFTYViu7obG1eMbJGqfrSmLINYj1//soAtL1p3bHpMFT1tNmsa+2BKfvBVRBmlyFhUhESFKjggvDFO78EqsFUg6EpHraWtcnudC4hIzIFtAHmoPqFSEIG/7tMG5e2sLq9vWyXvIjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606813; c=relaxed/simple; bh=6x92Hs8vfjM72TCvNKjyk8LU0sI5S215gCWTET3u5kQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qqSE0+aAu66mLDLv3QdgK1Mxar+Tkjj1u1Y5A6sJ8t4n9Jq7jilibpesM0FiSWNUrHwJ6r8FHfZH+OASVHh1mjwgvad4GsbRkITJRXn62lKSwnihdbM9OcaHW90/x8LwwAX9gH6uE2gX5aHHPlVAszpExyk9wiIwUz/IGN6pfl4= 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=ih9IVJPJ; arc=none smtp.client-ip=209.85.214.179 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="ih9IVJPJ" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-216426b0865so49989645ad.0; Sat, 11 Jan 2025 06:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606811; x=1737211611; 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=h8kQoSzV+zNhAQr+y1fUtNkfpPO/otuNPk/v4/KvXzU=; b=ih9IVJPJBWyp7Jp2oeUQsfEFdZW5eHi9kFDQvhiLdnN1wf9d/J/pd5MSllLo3wXLp5 jfI8wU3u5YvrtJSzkEdJmLBzYjdnrRnuxqU7GNqP0y58aTwEhR8cd2WvUg6v8hIPQQHT acoz4rPZxJgLtg+0RgPpyblucmwHfDJf/em2vngEFDrQFFBwBZtdQaF9+FdPj1/9WHyh rmJfHHTH+X65yNWQqOKud8mpuA9nYP7nDd7xRDfTyJ92CfE0iR9AUIaXwNnujvNBGzUu ObeIDr59B8/Dlso01sS5PWu+RBDzf1CEbLZluGcOmiVUTMNWwiUCOMdfQ0vjSD2Dr7Tj 69+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606811; x=1737211611; 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=h8kQoSzV+zNhAQr+y1fUtNkfpPO/otuNPk/v4/KvXzU=; b=YcrunyB4PmwTjNzKWYSQWFEO2/XNix5um7ObKLNiczCWBbfOLiTeQWia2zmnMebp89 q74jRZhdv4UVuEbDV7JTeemSKy+sbmd2p71blneHJC3zxx2PS/FJCdTKc8SXltwNJWt9 5UJMOe00OCbC3vGSY/2S8E9ADb+OfRZvbWvIBjPTLn4goRyrpkn4J4mg1H/DZlLFtJCR vnQGZPnu+Sq9hJrWdu0F3OKWe8TNwRgXUJalPfx7kYOz/oKHaMITaAxN8G4QPaQWUaxX InciBqenEmARnRjAvdQHD7MNiXG+NaVsgk1XrNlwAtvgnkLaW1o6g22c8e3OxUPTxU1p fdhw== X-Forwarded-Encrypted: i=1; AJvYcCV6SQhJxwb3pQQYg/RKxDYIFRGxSMGm303F+NF5JdRUFn+KrkronBX9oHMa1xmcpq7QhpHAMtEK7m4=@vger.kernel.org, AJvYcCVvSbSjCUQuNK/JtJB0cZuPyy0c1oHDIeOBRzf0KgUuPgD0zYATllXoKRcVr29b3aAwD9gmMWx5@vger.kernel.org X-Gm-Message-State: AOJu0YwF6+krvetnseqrNA/kRePY8BYRvoxAYywnCTo71Qc6hvUiitWZ Q9qe1j2Qufjt0v004h9GRVzExA535FK41DCKTcEgUmjPYxuzVqaI X-Gm-Gg: ASbGncvdUCgkPTC+KWYyalT8U86IorONKg1zl1q9q54aqqouVV6yISgF66mXb8PKGCc ym3gqS0HfNkg1uYHANdVbfzHvOuaAf17mBTR6XznRm307AdbfXny3V4KGpiUFiTHr6SRPE0EajO JrwgT5uVHn8bB3aKDJ6Zf070Sn5q7AMIMytoDuuYVHqB35BLMOdj9FbHZO/LsBbNHuZzSyfIN9f zut4Tp4LxvjKHhgajuT94eR9roiGAmJvyHUxj7E8Yuq+w== X-Google-Smtp-Source: AGHT+IHJbLE458aCv8YGRYUjklRl7Wf9fdGG52gue6GKeD4k2nBje6dcidbbD55END0WytispeDubA== X-Received: by 2002:a05:6a00:9285:b0:725:e499:5b8a with SMTP id d2e1a72fcca58-72d21f55d89mr17557393b3a.15.1736606811002; Sat, 11 Jan 2025 06:46:51 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:46:50 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 07/10] bnxt_en: add support for tcp-data-split ethtool command Date: Sat, 11 Jan 2025 14:45:10 +0000 Message-Id: <20250111144513.1289403-8-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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. Acked-by: Jakub Kicinski Tested-by: Stanislav Fomichev Tested-by: Andy Gospodarek Signed-off-by: Taehee Yoo --- v8: - No changes. 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 Sat Jan 11 14:45:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936065 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 0B2B11AC435; Sat, 11 Jan 2025 14:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606823; cv=none; b=u5q/7gdcysnR9oRVGkmE0sGXcPxGh+Ipy0YgIN34Luqefn2pW0WaOCIaZ2f0SdJwhXE7eM4O3sfbOQg5ZJPEacAemWgFakOrtpfEdi+QKkUQZ4ufor7LWNwcXXZeHGioqWgAlmxBvSg4Sno+G5dKU+rSSUntLsaT9EhIFUxr2q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606823; c=relaxed/simple; bh=B8fSBhnMbnkd4uR1kfgOWhUnWKdhAmpBc9d0C2mjuvg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jyZQhyN5egKgU9nuzB8tOKvWqwupR1Ai2AzDF7Wdv9y4rVs6UbfXq+NKmRb03/o6TD+PDLjWm/S4KR5/5sraosgBuiA2InxUYgfiwZs/xw9RFiJ/Dh+0ObF6jT7mRm4nR1fTpckJEJGaPjF2lc2SKrauJxg6pc9Y+0/UIbhd3qk= 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=Abz9kT7n; arc=none smtp.client-ip=209.85.214.178 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="Abz9kT7n" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-21631789fcdso52213095ad.1; Sat, 11 Jan 2025 06:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606821; x=1737211621; 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=TXFGFJwQwhEvgrT0UhbMHXejXuAuLyl+ackMNSHnAe0=; b=Abz9kT7nOH+W4GJTry6gpDY4unxx8I2H+Nk9OIxca4pg1PG9xVggbpHv4+PMIGBnFb sbeL+75CMcYxOnj9LukuQGEC3f4RH8Ssi4gldzhYEviugkVlrfK8mpRIbMt+TnnVuDgw Ius1cr0oK9D/Jl/uXyFEMrzhvdvzNlCl8oJyRRczk3P3eHboaob+cGu2sdiEka9bXuGZ CaGadTdg1fEDg9Se7YdwrupFzoVHZGarJ49KXnBdgZ2yT1CJSrJDILX+b++xnSCQ+0fX o9c4LU4MBuxzJTNtUhC2dMBA9lEC/xrDVmcaSUK2VDENlcTDC8QAUl2oCeD0eSMGIkXa HcGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606821; x=1737211621; 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=TXFGFJwQwhEvgrT0UhbMHXejXuAuLyl+ackMNSHnAe0=; b=c+TV+uR0sJ8UHVakn4p7A1d79+Guw1pdIUWYimgYXNd4SN4ii9ecAbMlXAxDLaDqlh f7c2ar2hQ+ails3eD+8trYRIZd1picBt6lDeo03RYGndxAS/muoNCBMDUHc806rbo+D0 o8E1hnXabVtbkrSaKoW1Idvn70AkXZOuWkEe0imG2XM2jw4UKF20cJkBUpi3/4QA7DLy UhOMHuUyCSjx5uPYNYIVOmI9ZIR5nLEPqtyme7/yXz31UsshVGrvtVVrmurFwRztWpA5 nofp59ANR5DGRq8QtEhYldp7lv0u/mrdbB/DMYnJqsTdomrxq2B2hRh7o+gO87Njb3JQ dkJg== X-Forwarded-Encrypted: i=1; AJvYcCWBvEPlgU87E+L/TDuDPtzgCgMRcNTdN1NmMwzqEvJ1BpQdqNFbC//QpeQzZNUzwXtK0WoimQWdGlk=@vger.kernel.org, AJvYcCWEchXMV5kIsbaPbkSYRd5248ATIKTxmfM+wsn50b7m/6ABfnfMyQlUGMpkVEYptJ4VzE75E4LD@vger.kernel.org X-Gm-Message-State: AOJu0YynrwSX5JIN2Hx/Ru8hWG76k9UcQJhYJdBwg6Wjiquz8Srln7eL 67QW5aeNvWxteiPvlldHb+FdLkczcTHyJGUxqWjOTqs/tOvxT511 X-Gm-Gg: ASbGnctr2u6ZVzh/dYPXpWPXkmfkINQe4lbl3rA0E3EBL8kG8NICQT+LgQ2hr5E8hVG iEIk5fF4RIpymMU6NQEkqsPcmHmgwHNjn7WWMgujUamPQ45HIaD8n7dE0CHSJo6zNq5FdQpmx14 BX5z00lR3FLh6ysNSy+Dg9OAeIyIkqd/e6HIIqCd+pkl1WXAR6inNa61ZoLEZ9oApztkGXDvVoh 9vwv8F3Vb7FKKhKpj/gSD3mT71KPoQhBOz9/LXx9XZkPA== X-Google-Smtp-Source: AGHT+IEk3kTwxfkZdpvZ/zTwufQ4a0BPvLXi0hGXVWRqt1Ay5qncv5T3UCnn5R9H82Dtj2sABez7qg== X-Received: by 2002:a05:6a20:9150:b0:1e1:9e9f:ae4 with SMTP id adf61e73a8af0-1e8b15f7db0mr10330695637.13.1736606821208; Sat, 11 Jan 2025 06:47:01 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:47:00 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 08/10] bnxt_en: add support for hds-thresh ethtool command Date: Sat, 11 Jan 2025 14:45:11 +0000 Message-Id: <20250111144513.1289403-9-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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 --- v8: - Do not set hds_thresh in the bnxt_set_ringparam. 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 | 6 +++++- 3 files changed, 10 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..540c140d52dc 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, @@ -5390,7 +5393,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 Sat Jan 11 14:45:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936067 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 D4DAC1ACEDA; Sat, 11 Jan 2025 14:47:11 +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=1736606833; cv=none; b=u7xzt4+r0yUMQGYuK5tsCqgDFHvez+4KlOYA0TjnVFsDNpqU5JrZoYm0tIkWg45SkXdFW7DIwv2oJkmmC7JqCvQ0D+4/xOAQwQpplOHTj2PPxVPsG91WteMufluoCKtIt/mMSeHAsRS89m3obSt3UpL4P6P09sMfwSNpDh12hVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606833; c=relaxed/simple; bh=xQPGkqd3QXhUmeJxb3Z6lDJdnVUTD0HBQTjEkzm6Los=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bHAbB/ZvoDFDCAOo643OkzV1L92IJ5b36EfjABhwjO7vjxse9iDUEwq0IQju1WiC+jnOpwcRkGOaZHYxAaPgnsMOlASRulvfkTnmmMkZ3+DmTL8SGOnWyBmynaeLry/lrhOj/FTAOkPuwavf4tO1aLn7NpDwlcmFKd0uo3arIa0= 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=lKUJDFfg; 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="lKUJDFfg" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2156e078563so43537605ad.2; Sat, 11 Jan 2025 06:47:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606831; x=1737211631; 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=15zxhVcll/uVzwLl4srfX0ThEUvDwvmdVFl4uwOIbQA=; b=lKUJDFfgoWODPukiYoXn2y+E4jheLSMSWvPmq0W5GFpWSBZlQ9giSEoOLu6Tf4Ofqd 2o6Gmltg3UtaSDJOU2oTUr4yewt3vj5QqzOIUPdBo97wYBT0SFykQWSOBt1jPvI836EB kYqmihcqelXPkHCHYAuV+bHfriiHYx/HXvXh0+NQpKGubq90YEMbGwBj2zHIlmnpsi+Y 0vgGnxK3mqhlFNw/Wp7fjkS19/kry36e12cU9dsNEsYokAnRZobSOnqsFn9Ta6RBUf1z 0W17KFFawZ5/GUgSATCis5z7P/lN8bFPgDhTAXNyy8urp1fjAsFm4g0xM24SgWZN1412 MW3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606831; x=1737211631; 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=15zxhVcll/uVzwLl4srfX0ThEUvDwvmdVFl4uwOIbQA=; b=PPVaZUbGdTc0g2cOfOnCraJKBaSc96uPEJQ3vUrYczRbtibinEp4JqU78uzmuwII9N VLFppuHotBFXxhVGii5SjDYSKCsNggOwthbdPkMhZgdf7XYPi8/D1JcfKlKpNpx7nsso nwRIbimC/0Mpvr8WWwid33KOKEeI5XggCjh3OGh1Wb9yOCCMhWv0f5uE0xLSsxhbXpI7 k3n/MBZpvkdHYc6GYgNykQKL9dVI8G9uzWzMMzZhe/LUy+XoANpWtNjtDGrwNwpdw/0n 4J26QgMgpfbNFfu5sxo6F3BIdgM/jiXA3gULiW+kBhcxqKd0nPKgidbd6u0mF2iEooz0 nrkg== X-Forwarded-Encrypted: i=1; AJvYcCVrrpLcQ3lqvUv7khFEuGiEqgQflbsGgz4vvC9RiQwO/kitcUOKPfEd1NYUn/IKQkerMJfS0IBu@vger.kernel.org, AJvYcCWL3VYpBDfDTJMdMl7SSxqQRBpG6ZNaAzLy4waKuviiPLxcJf9QG1cc4sUs1t/qV2yli/xqSI0P7UI=@vger.kernel.org X-Gm-Message-State: AOJu0YxEAF6rzCeR/4Cckm7O9WD5Du8bwxX/+vIJ+lVZjcE2mqPOPxG9 zE+8r8qp1Bo9zLvsDr8ElINPex/xfmCs+0lKS6GleaR8GxEqy0IW X-Gm-Gg: ASbGncvvOTY/WqP+cU0jjy1tGnbQt2DA1SHsc8MqYuq48jw75sjkMDFSa1nJfvDG/BB xoQb78qdkzzbVtTV7pPrdqrkuChFA9/zfQKCJ2tQe2JChOYBcxsGQ4fb7F2EDomzNZlXv//05GM Mw5DDpNOJEzJRCAYqxoHwYPyX8+WrXd8nQtCm1Q28+0g8UClEI7FeFqTw5WlityC8n4Mddj7exH /jYqFrxgn15CPyJ48q86tZaU6CqAq2gjqiju5vikCLpPg== X-Google-Smtp-Source: AGHT+IEtyXV5rkpwRx0SdkhPGlvarAGZlX76er42hN1u62c+nwwt4Wk/spMMzuw9sToZdu+0/tmVNQ== X-Received: by 2002:aa7:9a87:0:b0:725:ef4b:de21 with SMTP id d2e1a72fcca58-72d21fc701dmr20239342b3a.20.1736606831127; Sat, 11 Jan 2025 06:47:11 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:47:10 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 09/10] netdevsim: add HDS feature Date: Sat, 11 Jan 2025 14:45:12 +0000 Message-Id: <20250111144513.1289403-10-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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 --- v8: - Do not set hds_config and hds_thresh in the nsim_set_ringparam. v7: - Add datapath implementation. - Remove kernel_ethtool_ringparam in the struct nsim_ethtool. v6: - Patch added. drivers/net/netdevsim/ethtool.c | 12 +++++++++++- drivers/net/netdevsim/netdev.c | 9 +++++++++ drivers/net/netdevsim/netdevsim.h | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/net/netdevsim/ethtool.c b/drivers/net/netdevsim/ethtool.c index 5fe1eaef99b5..9e0df40c71e1 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, @@ -161,6 +166,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 +189,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 Sat Jan 11 14:45:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13936068 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 C09B41AA1D5; Sat, 11 Jan 2025 14:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606843; cv=none; b=Wpcv4f9YHAgug7F3G0TKow4ToO5bJ0p7iGuxZoD6qta4Fcqh6aDVbEM87DlMLtj2qGf9oE/MyYOYLavpO7AW1ce3b15OModJQolgwB5NqACxmiBSClrfkApNjS2oIBGdyFpLpCRkHWHR3flpHwYz4da98OY8Ym+ldpFAeKUa0Ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736606843; c=relaxed/simple; bh=JmAGQTkukDDimWXHhCgRtGxrqjNAOsiaA0lMqKcmRYo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sZRv1PRLERXiSBKDKpDVuLGH1FD2BzdUtLIod8IoGMZZreTrxQYnpiFaTHtFQVrRhwcU11mydOEcfvtGhp9ws4ZdVdhkhhKlax6evjsAtgda31HKCbr6y+4WdjOWKh0jpaca2HczdUCCm1lG6SjHrcsgnfpxFa87kHaZ9RomWIw= 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=Ej+oP8at; arc=none smtp.client-ip=209.85.214.179 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="Ej+oP8at" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2161eb95317so50102795ad.1; Sat, 11 Jan 2025 06:47:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736606841; x=1737211641; 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=srPGR2762tzMufhIappCTxxPpiqvApN8ZVTAHeK3Y+w=; b=Ej+oP8atWUckTWrmiEjmhY+hbv0jvzZQ0tOxhIO9C8cLcd1eTWru0DlU2YijKuNgcV TxBhIHkyX9XVtJ0TWlTmkXdIUC6JuBesMa70kUKM6hwX3alYkct451yxAe0oI0EhvJV+ ZUBzgRk5L7+RAUYTNiD+iL3SalgHsm+KQSSVb1rkUhyJHCiFN4ks9CiR/9wg2b/PxMOG z2Lyc9iSG+f2bxEUHO3U8puENpu1gsuKWoCoA4mGQZSnicnRBvSahHmbFJMJdZsCOd5R FIAV8FEPm8Kcp1eQaJUtDrK5Xk7a+dpw6alZ1HZ4AhYUiQ/HzPeWhAKKatabRf2cB0+V 195g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736606841; x=1737211641; 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=srPGR2762tzMufhIappCTxxPpiqvApN8ZVTAHeK3Y+w=; b=UWkMgMMgBg1yt7u+JEr4I9TpY/kCv848rh+8we+DgWuNUgglwAEULSevkNPdubKpJL zLDk5ggFosoJrrk6Nw5Ui90wFf0Ss6GtJjU8TObonZs/sJxuqTfI93NCmYsalHALmR74 Yef18w7Te7dJRcb4D4eZwv3XboZm4zHzgE9pVui2x0cvS2o6g/X6Z9ASy7gMiGeBbm2j Qr2Nsja00CUOmNJx1Cl/V23LFjyY2HiMQIRmZCDQ/YWY0fCHSTqXQnnL0Z9l+QghtWPL evajW5fo48XUA0CUSnMjaBz2IEL/EIYjUJiYIoNWC8iBpWYaImClQWq3LQSmDk7ftNc0 qvWA== X-Forwarded-Encrypted: i=1; AJvYcCXO5LHvhBXOafJKOuka/Mxl9uRg8P4Igp+ZtcqpHBVtXP6WqfaJEDkxddWY1+ORFD2BR7oAeKIZ@vger.kernel.org, AJvYcCXks5j9NmBGzJC1E30NLIpEkz4Df5tmRAr35mlA97KWvPmyHh/BNZmrHJHwDqJTbeuRwzWz8Ho3fUo=@vger.kernel.org X-Gm-Message-State: AOJu0Yws6xNQJRKVok98zsJDMug+FuMDYcCHBPQ83jITqgjmYTzwNDXv rETeENIiZ6F0Fwp/buR6gyZw1lPSrC5t82KVYpSR1NqiLvep8Cj0 X-Gm-Gg: ASbGncsYl5y4fohRuVuHtFh80aZHAGGi+iomuQa9HlYYBS56wyqKgTx4Ui7pque7/cR KMMYXMfnzDWpvKDR6eIXLUSOBuDaQNElPUzqJCQ7W2moyJl7NnZGWNTqv0a0+nlFnbScCcqWO/Q V444cfyXIMD3+umOWlflBG7tRQzBqDX1Qg0HJmY10OTxzatmWjdoFAHxLm829dTMsKIw7YJe0C6 4/KRcPpjd6v/CIuH5gn8whP56P5+LojECmc/y/fLwtoLA== X-Google-Smtp-Source: AGHT+IG2xo7ONGH/g5V8MI8GwF7wwP8i/mUQoZTRaDIl1M8rkfJBkZZXBR7kGaC+C8JA6emWVkcxJw== X-Received: by 2002:a05:6a20:c703:b0:1e3:da8c:1f3b with SMTP id adf61e73a8af0-1e88d09d877mr24054953637.28.1736606841139; Sat, 11 Jan 2025 06:47:21 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40594a06sm3097466b3a.80.2025.01.11.06.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 06:47:20 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org, 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 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 v8 10/10] selftest: net-drv: hds: add test for HDS feature Date: Sat, 11 Jan 2025 14:45:13 +0000 Message-Id: <20250111144513.1289403-11-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111144513.1289403-1-ap420073@gmail.com> References: <20250111144513.1289403-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 --- v8: - Use ksft_raises. v7: - Patch added. tools/testing/selftests/drivers/net/Makefile | 1 + tools/testing/selftests/drivers/net/hds.py | 120 +++++++++++++++++++ 2 files changed, 121 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..394971b25c0b --- /dev/null +++ b/tools/testing/selftests/drivers/net/hds.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import errno +from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_raises, KsftSkipEx +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 + with ksft_raises(NlError) as e: + netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'hds-thresh': hds_gt}) + ksft_eq(e.exception.nl_msg.error, -errno.EINVAL) + +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()