From patchwork Tue Jan 14 14:28:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938840 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 3DD341369AE; Tue, 14 Jan 2025 14:29:29 +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=1736864971; cv=none; b=h0mtiRZ8QZ9hHS5PLNW2ESiwtJUVsuWS6/l1nUyikGoYPl1CI8+yiqL6qCYvLSULRaCNTP1gDIRIpV1U2ts2DiA+uUVh7DL9og+gfg96VXYhJ5eJvQITkEdIB9D9Gk6pSNd/SmMmyhR3TvwW2LUWatJiy8xMj+k+kL/mD+i3qEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736864971; c=relaxed/simple; bh=yNnKMRknuezoR6ppUMw3FyyltXhOL9VK+7dDoUvZ7+M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qgW5IxB9pk0uCsybCkMXnhtWNILxCkqzUoXgJdD7UNBacJTU7qfLuEKE5s8XGQiiAntWoMhMnBr4Yu5yS76D29b9/GjTMOf/lvhE2fOWGpfT2uRAndWU1krl0Ok+81+Dh6guzl5p7K5GC5m9KURy7wkdE9HBV9Eh0oxkurCf0UQ= 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=V2yHlqdm; 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="V2yHlqdm" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-21654fdd5daso95167305ad.1; Tue, 14 Jan 2025 06:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736864969; x=1737469769; 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=l7AxqqkxgDKYMkGcpzMFHZETKDFuEliMwfcWuyEaZeg=; b=V2yHlqdmxLiDPVMcRfpFwtOlW9CHDCdmxA/UCox95G6XI1NvSvivGc4NvEyQ1r8SRA 7tDjw3u/D7348ztXyNFRIHqL++w7g/aTv5P4HzQvOuFN+yWBC0qqeWTogKujYXuzetYR D6HWvDKHzm5pVCPZclM6vJCTcfr2UUK2r4RXoMSdkFyPazOzlZ6d8dfq66e85n1jJLg/ BAVqvs8KvPXq387XfxcVrU2orXMu8sxIUHSPeWL2X4mpkAGYex9HO3pGYqRrFGmOUTFs A3dPDan1PEXDiQYVl3y0J5sv/Epx+VFYKI5yln48ZvnUVJunzDeY7g8SoxcROI0pgWCA boHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736864969; x=1737469769; 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=l7AxqqkxgDKYMkGcpzMFHZETKDFuEliMwfcWuyEaZeg=; b=XSBwe18VZQEiXPbiZlF1sQnkIctSwtRhiiZ1WQjStm3lGlwEKn+Atlkn//EqqJoicD WAqMYAUNmeJdXcRNA5FWIRyznAjE+VmSIuOwoj5dVSiO72B/lleq24UtDmbLOOVlEnVh 4UE7/KUBBbiploCLIExkg/rODQa1ZfFf8hl9jIgqTPzendPDy96EqYZI1HSMDv6VB7YN lQpKcb6bdc0QsHtiOomfOZ8Q47RFwtiRbJqILHk4k/yuGZ6x79GivoEqyJ3LP3NkLS27 ZljzZtbxr36m1mM/FabyWgtHbKxrr5QDG/FID0iQjzZggRKekFU0dy0QD7NuNt6JuVKu ae8g== X-Forwarded-Encrypted: i=1; AJvYcCVpunm3Weqbpy0w+CuJJ6d46B7PTEDxWWBsSAb+8F6s+eTlpW+wuND9VypIUo/QcpT8A/o/NLj6@vger.kernel.org, AJvYcCXJWKWKHIVhAqwLD+MBwFE8La186QxrcWVOxEN9U7UsrWJCxOr8LHKOQOHCQODxfO71nCVsaZZa33A=@vger.kernel.org X-Gm-Message-State: AOJu0YzYiRilpUnvu6aZEBxNcq0vLcaDGxoyIGIhQXmIoG0+uc5sX59p o+p7HtImMrAErorks4hnxFhkztFPCoPi7j60MTGO1on+I80L+ib1 X-Gm-Gg: ASbGncvZK5OHeBVcJSNUq78vfkb83UwU2XcliXbVlX3gw5KOGVHquE1WNwo1zM5446z 7J6zFd/U6K/97RI1ia7yapzpPSAnVnq/himEdXzD2Y4Uk5HRQeoPIeADhPb/jzMsu3kgwUbCbSO DcOLqt3UYYwJwKeAKgttqZhUk1rZLeDugd5QnO5sNDIpZLWTT38zBkQ6BZmgi3Eqb/og0O7Tu60 lzDwlcJIYA4qu1KcFe8jgtmP3y1LJ/VsmLUJ4yfwKWyRQ== X-Google-Smtp-Source: AGHT+IFyQl72ZwmloyTPJrmnhuvp5mXCeP9PLeZW/l7gA7DNgGzQIAZf3ki4fLObuQ5bqVRFus2kFA== X-Received: by 2002:a05:6a00:3c93:b0:728:9d19:d2ea with SMTP id d2e1a72fcca58-72d21f4b3a1mr38589844b3a.13.1736864969216; Tue, 14 Jan 2025 06:29:29 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:29:28 -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 v9 01/10] net: ethtool: add hds_config member in ethtool_netdev_state Date: Tue, 14 Jan 2025 14:28:43 +0000 Message-Id: <20250114142852.3364986-2-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 --- v9: - No changes. 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 20a86bd5f4e3..d79bd201c1c8 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1157,12 +1157,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 bced03fb349e..3e6336775baf 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4082,6 +4082,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 fda4e1039bf0..5ef817d656ef 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9550,6 +9550,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 Tue Jan 14 14:28:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938841 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9E4813A879; Tue, 14 Jan 2025 14:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736864981; cv=none; b=oo6/AD7MDpqOTTa1Am0HJqamvd6Tr+tslrKA0Exw+f5b517xGiRnOZ0pjpXgEjs54IRrUby9XqazqgvVKGhrFV1UkZHTWHGsWMg41p7PRGWqNydkgTyJlxY6GU3pzy6LVwVZ1a5NRW7i/FVY6OiJ+1ErwCljOoAJIOB9oR/GLzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736864981; c=relaxed/simple; bh=dYl+hh2R0e8lZ9vzBMq4ASINllEEjoOmqf+PWfqnqaM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qjSam77kdQayfxYo7MjtXbjMGA6Cz7sO8Os4rtBvm6VJuAgIVwUFKB6uS8BJ3hxxHGFdjxJn5XhvHLHd2Zj8mT6ZruubGxj/MpgVZSjD3Y7Jnu38Nc2fm4DFgeb6ezYAkzsKXcM7uGVsXVGJBCLmO9xs2mWb+K5TR/tiLbgOLIE= 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=CSXOfVqQ; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CSXOfVqQ" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2161eb94cceso68232295ad.2; Tue, 14 Jan 2025 06:29:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736864979; x=1737469779; 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=iARQ4MUce9zewtBA/S239IXTVNpFradI2wMq2uwOl6w=; b=CSXOfVqQTOHYEU9/SNyZxFMNijpDS87Y6E2jfQJqvWLX09kk6HrbMQxGvFv6L9DrBb 2uQ5gjxpBoUasEfOKhSirKsZrk+fOdkwciYbYyK2FsO/6LBK6RlrF7NTg1vAkgBan5/1 pn6AySRXRSohyPpdOOtrMNzHvll7Un0m7bWSNnZ2uGkYpUuVtjFMvPrQOLl/tu8AZKFr yyCcJHzgaAwqRGGoCko0cm75PY6tS8wAxXfkanYcV5g3ljWQ3SNK1ZVtTTaBA7yqdMzc EDkmqsUgIqIg+xJZ4cIQZTKIRcKAbMMYRCKWH0muvTqHwzpmfYm5BxmEVddVc71tw0OD qgfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736864979; x=1737469779; 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=iARQ4MUce9zewtBA/S239IXTVNpFradI2wMq2uwOl6w=; b=xSPaXRN0e5R7klvnjHNW/q9KauHPxiGlphKzEef9Ke4ge33rnG/6AERww47QG2oxRh RelMwSCAYTdA1FjCcLRpgube/MEbUrsRCB8/ifwoMHRtprYIaPsVI22eF/hIAC4rdzis h1SaPDBMGysszYae4gWLWdHQ/DnG2Utres7S6TyaF01Bc/yS9UvHCLMfgkiRoRZSmsuG Ud1w3Zf5evskKLkt/3PV22vNZ647TC0tOVGi3OapBBFXV98DlscBpTvbsiipCqZuce7A iJQUGc+MHam3gHh9OzXjwXSPmXqFrPFSW+epMt7qaUcelpDE1GFMgeg8HQRUGQgr5LF8 LA8Q== X-Forwarded-Encrypted: i=1; AJvYcCUrQuWpbevX1QcIPbJyfCq1rsHlJsKFkmmX3wCuhLr7hg08rzxib0bp/5/mQ+8+MtSdFsADL4KQ@vger.kernel.org, AJvYcCW+DJ3Yqfh72nsGURnYoUs8LROHKFvza70fmPRhnWPKwDfXHnKiCIun3lZO9Puk/tZ+JP39Sq6sm84=@vger.kernel.org X-Gm-Message-State: AOJu0YzUDA8dVGpYRIUf2wUpnbh/pY5onMye6ZqvmIm2F/HX59dxiVoc rUdwvZTogqkAlDcYG/Nhdu2p2e+x9UfawOG2I1WjTvFJlenOS9Xp X-Gm-Gg: ASbGncvxRpJvzTqemIV5SR9M2Rp+8cW+xHFjxdLTg9ENToj/3lHluFhIeFgFrFwi1HR vxp2yO0bFy7vNFln3+VOKCdO8mACYAjH74lliqsmUqOaF4X4Gbbh1gPAGC2vGH3K7y58ct7bILF qdc4ulz0K0p3uH/UET1Z2zjx9I9q7vzg68qkQojvooEcGdKogymIcvVV1SUSIuvOF97vpwhwYRK AgyGXTAaOY3sP61MGeQYFNwtdybdhQZMZbEe7Y55zkBtg== X-Google-Smtp-Source: AGHT+IGmVq5RS5aDcy8g0wCSk6g36G8do016xnpeCPruQZfATlSwO/iNY35/aHdXeIcq1T2Ncd0ykQ== X-Received: by 2002:a05:6a20:8412:b0:1e6:509c:1664 with SMTP id adf61e73a8af0-1e88d0edad9mr39561346637.39.1736864978996; Tue, 14 Jan 2025 06:29:38 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:29:38 -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 v9 02/10] net: ethtool: add support for configuring hds-thresh Date: Tue, 14 Jan 2025 14:28:44 +0000 Message-Id: <20250114142852.3364986-3-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 --- v9: - No changes. 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 da846f1d998e..f70c0249860c 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 d79bd201c1c8..e4136b0df892 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)) @@ -1157,6 +1164,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. @@ -1164,6 +1172,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 1ce0a3de1430..ff69ca0715de 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 Tue Jan 14 14:28:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938842 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 75CDB1411C8; Tue, 14 Jan 2025 14:29:49 +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=1736864991; cv=none; b=md1bYBr7m4bdyspiY6FZVwrZLLN2gV5hIjgHqVpp70BbYCpMrXkSbU7wp710QnkeZjHfOA+76zS/LEjvK2Xu+Z+J3ShXh/+rfHhHHggXYxfnlDGmSot3hO8lNHnxglNmjUTWj27KoLFUv+qhMy40dHZCgrET22HQMATCv9BWdow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736864991; c=relaxed/simple; bh=sYjxBhXYWCmuvkdC1A+vex//OrhDcxd0KjaG6Nsk+Tg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uQPEkAINSgDTkcKRLx1EdHNDVGBRyNBtvJV5Nr2JcZHJh6Pv4tFxqRrYJ2cddLwgcgjPcuQ49dC9abnnkA1NZDC+yPmMgotiLeDLKaStL2PK0g4jAdc1i+aDACzf719U12Q2ygZNq9OzGP/w17fgNPfOAU54u9ayVFled34Fzdo= 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=YUM8vg7I; 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="YUM8vg7I" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2164b662090so95479575ad.1; Tue, 14 Jan 2025 06:29:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736864989; x=1737469789; 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=dbE+UlgknWj3V/9EOtpyTiR9ENTWCWam96Dcz1tTLjE=; b=YUM8vg7IqAWG785DnHYvrTafe6wm9nq4wmKwoalCanTNi4vzuL75aREICUrsTZAgPC rElsgJ0eaNGhFa9l38aWm3S/TzETOnXL8qg3JOTHfOr8brYl04cW7c9nHschTQXAPubX tZKJaYa1ydY4n5suyATyakhN6ps9mGRj3HOyd75TL2hKDCRnW1fL4GWGCYPB4F48xUFo 2fW24gQevsmhyw9RS5ZK9exIV6agGRvpW3WPLCy/kLZakC0NmVHrsu3Ey3wtQkFHwX3M nqRDQ6iZwtpynp8zAboxEblMsIWE1wJfxfS2FSXM1dw9UbwmW1KKHCeGJD4ayaex6Shn 64ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736864989; x=1737469789; 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=dbE+UlgknWj3V/9EOtpyTiR9ENTWCWam96Dcz1tTLjE=; b=X4GitEDBbce+49WHRhqU83ovGyGDwJN97cxKMcr6kUzFZuCDYlQ4+iirWPmAYMPlp9 UmweBDPjmspAcA6FI0egWU3GXdiFrMAew2daV+AjHaYqkmGV0yWnJTcs7uhSWo/uiKjm rQ26D9CbfTSheC5Cc92j0QFbSWaAOYz81Q7h/KBEMfhoZPOvBC8a5YpkUCONH4P7JnQQ /pVKY7fqAcFhf0qtRLJkJRlHqdxpd7a8DdKkVArXbnupBUIgKKn4PWW02kVxE7U7/VEx /oiFMEBT/GQ7gU5WU/IZMRLBSUeqItPI97ItWHzcQ4TbFbDgZFMuLdBukIb2qvu1KjdO ceSw== X-Forwarded-Encrypted: i=1; AJvYcCWLMmn8y9xOf5ShX9+t+udEikOKTvJ4jnkbCpbfgar/zzEicTzs9yQYKnU27pmc+qX4hff1qcGP@vger.kernel.org, AJvYcCXWjZSO2APxLpztJC0vNrYIiHgOgSvjxzvLQLs6ujov620X7PTgS01pg7R3ExShvI9k7J60+kV0iMM=@vger.kernel.org X-Gm-Message-State: AOJu0YywYFTBZjceXYOAiTvV7cSqqAQkLkbSadu/CaRGAE1q4A2ll2/q 4Tw/a/0Y7jJjp1rP4+f7EZ3WJERkvthvEFOFTr+F/9Xgi4kUQTB4 X-Gm-Gg: ASbGncu4/iKo0NrGtCLnwBR3f1Bq94HYbB4BZea64L7yNhPvVhap9EBLvcskcwBGb4V baCSgXH9DXF8NbnvNjuqTX+r+IG+trFPuVQR2GvQK+AO2IcUMcfVB4xRN7AfAFbwrpsOJxxJOZ6 19QwyA9JflBb7PmHokg/OhcYi3TYYTtTPomAoEtj1SgCxETLX6RbO8ak1Ozk/Z3M3u5KmzMT60d 7YYjxXlnCu3riLLN3LqKzpg9cveIlDMx0qAoWzMVjtq2Q== X-Google-Smtp-Source: AGHT+IFx0Gm2t/wxHKpuLILPmsyGEtI7KGEThwmY6k4QZwtTLE6tL5ir0KvQzwTIlR3QUIRV+EnFog== X-Received: by 2002:a05:6a00:6f0b:b0:725:e4b9:a600 with SMTP id d2e1a72fcca58-72d22048bf7mr31969097b3a.16.1736864988684; Tue, 14 Jan 2025 06:29:48 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:29:48 -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 v9 03/10] net: devmem: add ring parameter filtering Date: Tue, 14 Jan 2025 14:28:45 +0000 Message-Id: <20250114142852.3364986-4-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 --- v9: - No changes. 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 Tue Jan 14 14:28:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938843 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 191F01369AE; Tue, 14 Jan 2025 14:29:58 +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=1736865000; cv=none; b=AJhSatz0iprwGKaxc1KRtzjeIl85SrErCCKhzjx8AAHCnXXK3wpvTWLTXGGqlDNihs2nXzLtpTuhjS6BBWh+3K/vLzOrojkrL9FZwn4V4UUf0Mrq2I9xQJMXdSBzIxk4Q88gWrFbc46LfYglDG5TuRWJuEhw3kzs0zwVI3JNyNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865000; c=relaxed/simple; bh=G03YlzkTyU0wEKIS4zU4l6oXXy3VcSxiD/ish1mzBr0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=THJAEOWfAj0St7awDJyRuYBeaJ2F8vvx56njowoF+pADuTJ8KsA295H61k0HNMokd0LGha3vvS3mZfO8PhLFbV4ija+YALCV0ww/r33eB6fkpJJ/cgBO2HBdE8wWh15ig4y0rsxR7HR3WV1qPT5qPf3lz6amdEwBuA9i6vm7aH0= 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=BnzIEmYu; 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="BnzIEmYu" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2156e078563so82792345ad.2; Tue, 14 Jan 2025 06:29:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736864998; x=1737469798; 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=N3YKvYjMS3HKIoLbog9rjcuxZ+eEkVARKjAsTJOkXTc=; b=BnzIEmYuZEaVS8S2oMoTCBrhey36H3Q3xLIVSe0Ovhxa6fzgycMBCtdz9sBbKWKsgS GR2ZEfwRm/hTo+ODmD/dUys/8bGSycqtAVFiUsruBgyrH+VtMa/m/GivMazdoRk8B7V9 LtDliEL2qntFBtGBX8sMgvg9yDNPDhiZ1iL7Wudbun0UEAhvNpGgC0behPgPv+pOC20I nfql+FEpGLACl08BPoja4iZAdtHmivggqxdevs0VvQwL/bIjR+Xz1Rj18Afzvz1gPgM9 i5vJi3H7bfH5R7fyZ/Jrg90MdMvzOjDDMRDnTt7/nGKKSy0M/hJAZZbHBIDGm457vKPq jHuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736864998; x=1737469798; 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=N3YKvYjMS3HKIoLbog9rjcuxZ+eEkVARKjAsTJOkXTc=; b=Gng5EJZkOSF6dcypcomodXAkIjTuwodMN7T5YBnshsPHe/EqsaKc/dVB0HqicUnk8L KOKcXxaxvGhUQQYj5C/H/BQxGiRJlEcspWTHqHrkQNDgxyxCoIwqX3eQUP2b1VMVyzHs JidiSu/l+fTM86SOwAeS8iBVChRHjbQ4KqR6cWgvTj5uRv7Qu1YErHxE3EgV6eeN9hC+ urwxQ//g6+Vch4Dmci5PhPTVYYgXiGJfKV+9jQaYcjK6yxSHGaCrVZd2RW4kBQvRVngl +5pV6teUBORife+d3fj4jn1/K5oswhT8DMpa8vhetYMljzxbXlAc9+tvQhbG96YbSFmx PyZw== X-Forwarded-Encrypted: i=1; AJvYcCWcba2EiGhPHHvuGisqKIy8TA0gRlB8fImFmHFEgdkpc6J3k7V1RG7b4DSQedqracVKZMWXs3F+e3M=@vger.kernel.org, AJvYcCXc7ZA12dKBZQh/5yj4zRNVs/gWuDKd4t+HYCyhDYoBEHfIA3MkG5bArjaeMroHBfrFoa6oVu/W@vger.kernel.org X-Gm-Message-State: AOJu0Yx/Urnp6n2AdPHIf2ME0VkOasol7oEXNPUVhGa2OjX6djMmP0IN b3+hN6hvqsHGYxYrrgkdP98ZBfplCsKMwip7wwu/KDXubevpCIWP X-Gm-Gg: ASbGncvyolV7LTwkjudUusSvXDQ0N28/niTYnRCF6+iKqEK56V8om0uUhHLFDFCCxW9 Z9/Xhf0D7roecchI2NuXfuSVnIp7i69uWRu8J3zim7TzpJadk+t9+5qUG2eRpAOjb7GjgZSY0Je T0mQwrJLyuFjrozJRFo4c5Kl2JBs5tJln/qYu2jsiTHStXG7dihP8+nJFgJ+nZ56JqAZOs7LF8E T71zTeZSjpaldaFFUn+ybAldtw5vrONqdV7tARY96aaLQ== X-Google-Smtp-Source: AGHT+IEOcS6m6L1FPIA2lo/58pLV4skymVLNwgqNQZqSet7D2LfqJMmrqpHRbXBKl5//TOX+Tdxfvg== X-Received: by 2002:a05:6a20:d81a:b0:1e3:e6f3:6372 with SMTP id adf61e73a8af0-1e88d132ef8mr40813558637.27.1736864998339; Tue, 14 Jan 2025 06:29:58 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:29:57 -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 v9 04/10] net: ethtool: add ring parameter filtering Date: Tue, 14 Jan 2025 14:28:46 +0000 Message-Id: <20250114142852.3364986-5-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 --- v9: - No changes. 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 Tue Jan 14 14:28:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938844 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17B3113AA53; Tue, 14 Jan 2025 14:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865010; cv=none; b=XWmndXorKRvqNpQxlyttZ0u8OAo1tOOpXFLRAz9H7Xqdzza1f7VinOrxhfzxFD1/25z5sQ3HibyB/VWv9Ow7e4C0gMkG0kCel0/tbtMnsGuLNk94XGYfO/W1kLFqwbmoAAoYGT7AWjj4YaxhLWVPmp12xHdmdaN6uFuQFqS9Y9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865010; c=relaxed/simple; bh=etDMffPKXB2glXkPg6kaiPrNyPH+kKXRtQDcidGYoHI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gv6DuRKAtAEkT9Oz2kg4PhSuT/v8WMNvn9+t88nHeUnXEOhl1+YyBmnfKKJ8CkaSH6xRZk7fwQ8yYUo9kohrxMVIzrkIIXgOxZgDxAq3JwuKfXEMMQb9BiTJHle9fh+5gf3pnmadBjMuydPzfhmCOpAwVr+UCvAvpx99WUZnPMk= 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=WG4fm7EG; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WG4fm7EG" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2164b662090so95486745ad.1; Tue, 14 Jan 2025 06:30:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736865008; x=1737469808; 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=kEQZt8Mhh9qaOtS6y84xnmH6m7isUX454+5HDJAKGe8=; b=WG4fm7EG8r59b+jjRCBsTFWZOY/CAcCTezoTlxuL7oxpEsvyg+e8XOxi7bFMn6kkqT NCHeo2HSQufalyIDmDODhnh5QoW8x24uhwm7IzzjTlKkePhDvQywi8dfF16qpBVD3T3K /IeMYumn4hI75O5BnDCPxhiy0NcBKs37dqcUBN7FZp3e033aKu38ibqgumXevdXhNehS tivmWcqZLJ41TlkNLrYuQi1NYCGEPhd9cESX2wxBt3KTLUvRLbLfAnairsLVK5Cw7Mn/ KMWep78gAvfTlzOTkpPhjZcaFdjBwBFKqnIsktDMalXwPgb+nerXNl6MLHkkhovKJ9jl vGaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736865008; x=1737469808; 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=kEQZt8Mhh9qaOtS6y84xnmH6m7isUX454+5HDJAKGe8=; b=aSY6uHy9uvLbx3o9CJWBI9cN20J+xAz12d9gODLM7uL+QE2KpyQ6vyOdMDATWqjHF6 q1q3U4IKug8w1e0TlGDT5v5VdBNBvmflQkuHlKOBpcd4aBYja6/hoxgvAbuiNp8wvmKO 4mNprMd9c7kKF+Ad/7roz8kLNpAVnFajiGIUDtXvEmf9SL0e9/t/WLKo3FNCAXurkGVN /uXRIX62oLOcnX9MK9VQPL9KLzREObhZ2kbUpOfM49NVDRmdqP5FNvjD3IHL1bEmIzga b2//WFUmQTy8eOR2TSicjzDD/Pq4e8uRoUpwQG+bxWOG9yg0oBRwf9K5gIxwbNy0ifcY WyCQ== X-Forwarded-Encrypted: i=1; AJvYcCUtvdl5ooEGdO/eIwEa5uPKm4GYitvcLCGGzBm1KH/wslRR4c5K15Yi2emcsC10paX0rKgM1fdF@vger.kernel.org, AJvYcCXqozT04mFrTaZF2nuFXchy3TBu0W9F9xV07JuX+S55inBvJyxJ0X5RR1EG6PwcLyb27wLtZdbSXmY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7IW7JrWmhfVyysSme9bNw9MhCHWl2BFM0xO0G/jTh3EIk2tmC Ih5LzHJlVYD9CKGcaPjasqFGh1tF26DIQPmtGSpVHIqvajAFIHGg X-Gm-Gg: ASbGncuTA1nNXuEBuik574jyRDEz41rzl6U/SbGnMGZRHiDBUMT3F4EW3kZ5o/JWsbl x80S1uAK6Ip4BEQoHy1kGQCEmF6tZn7euj2rkoaw9xtZ/il7JOb7W8PWszxqrNMnDujoK8V3jHQ Kofh6SSmvHX6k9qj+xbRWcbOnl8GqXc6W7zY1pXgfjbdPMNenQ8ijilCQU44Oy9p8k6uZGYPjJO 4RS1TAy3GeuARjv5yO56iNVMy+NNPHPZxJGvOj+d4n9OA== X-Google-Smtp-Source: AGHT+IFUumWrMVGU3d36eLjoWFeVK21N0UJ2nEQAuigo/Q8P2AYxFs/9SmIcqqGoGx9LSnjTBpe2pQ== X-Received: by 2002:a05:6a00:4f88:b0:729:a31:892d with SMTP id d2e1a72fcca58-72d21fa5cecmr39526499b3a.8.1736865008266; Tue, 14 Jan 2025 06:30:08 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:30:07 -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 v9 05/10] net: disallow setup single buffer XDP when tcp-data-split is enabled. Date: Tue, 14 Jan 2025 14:28:47 +0000 Message-Id: <20250114142852.3364986-6-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 --- v9: - No changes. 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 5ef817d656ef..47e6b0f73cfc 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -92,6 +92,7 @@ #include #include #include +#include #include #include #include @@ -9567,6 +9568,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; @@ -9604,6 +9613,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 Tue Jan 14 14:28:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938845 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 261E51487DD; Tue, 14 Jan 2025 14:30:18 +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=1736865021; cv=none; b=jWDi244oLcU5IJD2VvIwL23zsP47HHkexyTQRihGdwfLtpRIDL5pdGpNUubIsDPubqm9qkPdAHTrGFD6iQsAeSv6wyMEdIeWRtcDdpmGoq2/t+0Y02Z/pTBUihOETPFpPFyd7w79zjnaQ619uWAtRpe6f7mCNq8OtWSgwc/Ap1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865021; c=relaxed/simple; bh=7ME6p0cxeIX990fpzxJmJ+Ys9T9/3qPmOEU2o5G1mos=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n4OvhboT2CS3/b6yJ8q0ZXOjkEfXA+nXO8pQ86oFcbijeXXDFygusQCM4YyDxkb0F1u0pw/5FM4BE7aPuNryYUVc1bnafORG00avn4ZTpJ06gxpMS/Lx1/6QyK2RLD8XXRKqWFkN7z9jd323Ny3Icbj1UpVdQeIuWsqmrtIAE6g= 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=eOPJ/FP3; 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="eOPJ/FP3" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-21670dce0a7so120357245ad.1; Tue, 14 Jan 2025 06:30:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736865018; x=1737469818; 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=7FZiEJgrGYTMOUipOqLZmbtPVLIi83F+tuAaJIOc9dU=; b=eOPJ/FP35Qyg/x1LmwXaml7f9Kr8eM/pYJxiNjofwKTe1K0uHHalSocjJauPFhFvEy QNdumeku2EvtHfZ1iCkL0Iy4ZDzdjHOYBIpas2Gs0SuLidae1Ta7OI8pYZKzF0MKUTsn DfZUtUEqARyBXcVeko4PHqLN+40N9Ki6GMJbsg821qSAmebgOts/OScsJJjx65N2/MVw E6opGsIwzvgodvPwIjzqlP47SeJb16FM8yG316DXSwu8W/WuLflam2ypiPdCC7F1Y11R 0xmLVZ9Iflj0lG1OGV2jxAhAC3+U2Tjq0eJzlzxMLfTQzvSMoM6zrX+ZS/SmR8tYyGmv +Sow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736865018; x=1737469818; 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=7FZiEJgrGYTMOUipOqLZmbtPVLIi83F+tuAaJIOc9dU=; b=HFmUcFhT3EWn4nSeQ/bXQhHxLlmMshENFy/jJ+djcWukunzC9hy8H54O2Sn88iX3Uf 06cv1aJZoalUl9/DIRzbuXIQJqsYWvnS0ymbwlhk6Y5Q9BMUc2pDiWOpIfEy071cfn4S 0ls4ZuiBKyiYbZ0/wKmrF8rncYNgCF/gvoo8oFWpNQUyd5Y7lDVKHu4jtj1+Ova1WwVZ oZRDTFP6G/G/drE9zc1c1dPtyPJAiAzk/wZ7lNOsLZf/DjX/ANs9FuAJLzJNaOFrPEYF rB0FwrkJcxjA1UzZb/vV5qjjZkQsZUbYJVAihEJCwV+IvShHoiXZcuS02931MEQBwGLe EXUw== X-Forwarded-Encrypted: i=1; AJvYcCULHkxgiT15x1D7u5e89zL/G6rtVXUwqKtnRVwpTtuJwX2nBfxegZ9TYGonsX1rgq94WOfDgmvW@vger.kernel.org, AJvYcCVZwY7ru6THE2YYYa/6B/VYSnbV3qfBWi1C5d2d+qQdk7gC0/Sxdz71dqsdLHoEYgd/zpAegXgrkRA=@vger.kernel.org X-Gm-Message-State: AOJu0YwOI1XWxQDBJGFqO4jx46tJji9kt4jvJWsO1i1+AJJZroqwAQhx fZvOrzMcWf8DkGtJ9rFZrtPESF2auv4KNmUOm1N5WjqRIBLdqm7q X-Gm-Gg: ASbGncv/ws8w8ipsPiPkNPzbBZUWuh+MVjMuzXxfOMZFAYBf5hJbAA6itbIqOdAGNA2 hSMa4K87MEcgX13hp+TBJ4g4tFjJi32Chsn65S/Yqk5sL0s028B4KSZirNJxFCGHo1RgbuYHzMf GrsrjRr2KhwFe/t7q9HOo30AZFdl0TiaStA9JuU5tAy2Lw/taXPLSM2rQxxsTlV+XW8/JNkz+/5 pM2in4jX4KOP64U5sgqJIDlYqFfu7duIwOlLBJ6Y2N4Kg== X-Google-Smtp-Source: AGHT+IHxeIREUWidzFHwawe2Ok8o07UHtghv4lqd00pl5/cADLDDq2B7cCuIZe/BHAAgQgcrXRORmQ== X-Received: by 2002:a05:6a00:124a:b0:725:f376:f4ff with SMTP id d2e1a72fcca58-72d21f7bc52mr16155890b3a.13.1736865018251; Tue, 14 Jan 2025 06:30:18 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:30:17 -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 v9 06/10] bnxt_en: add support for rx-copybreak ethtool command Date: Tue, 14 Jan 2025 14:28:48 +0000 Message-Id: <20250114142852.3364986-7-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 Reviewed-by: Michael Chan --- v9: - No changes. 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 884d42db5554..d19c4fb588e5 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 @@ -4608,6 +4607,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. */ @@ -4622,7 +4626,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; @@ -4667,7 +4670,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)); } @@ -6573,16 +6578,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); @@ -16261,6 +16264,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 Tue Jan 14 14:28:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938846 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 0E8C614600F; Tue, 14 Jan 2025 14:30:28 +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=1736865030; cv=none; b=OmQtzxyF7/ygr9KswhjP4Isa4f5qj3di6ClWb7QzY4ZQIqLhPD/ylsQs2vGDvPPz6/YMCI4MZjsj4Ou62VaK5cUVdxqV/kvReac60m+ZNWZ5R7Ch6qdXFFC2c0wDtQHeT+l6QkhUVWbXdeKVpW0JQW0syquKZUNNF4/c0tlFQXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865030; c=relaxed/simple; bh=jV6ughD5Wjr4GVyxtlx75gHgzjzGXsG0Tx8bI179sk0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UDiQwpo1kBA7/mXU/SLXLKuzecKkmp+mg73TxcmtJRkXJQxekZg9D8eUXgDuK+uw+r7x2YVrcO2nYq/UXSQ1hEgH+9jbsyUh2ukTI5VJH/jp4xoQSdhcRh3JrhUxMVfteyAFisQPm8EGyIRxp9vge3xlcmbas2SrdC8GYBKEhq0= 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=cdbFEl6C; 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="cdbFEl6C" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2162c0f6a39so117661745ad.0; Tue, 14 Jan 2025 06:30:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736865028; x=1737469828; 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=e0PF2bMPqKZKaH/FqfzRI83Rsy0dE0M4NyqDnd9kKJs=; b=cdbFEl6C9PjhfS7A+bsk/YiMA3Xeie76pUzSUU2jC2KwHWwuzDBMqOuWAR2bMuNkar Vg4CZB4rsvbwzHnLoBFHU/fnxDyDGGqZaPH4cJkBsyFD2ZoBfjuGZ6/VXAbSE6XVms1E RCN3zmfVU4jkCSuO+vo+sCGD9lcAej6dHBAgIKXx70jk8OZm2fyLL5fxF7hTZinzo5wI VL2MntKPK1i/ygG4QWkRGDE1aIyrEi2RBE10wWZNuc0zxpSqxCfEQ8M6zH2DG16vxPgA h6tPziRCqY3/7YF1yzVsBnl/jP6eX1xJ1SJTfXFBnANApK4X4BFr8iLR2OWMp0rcNu3G OdFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736865028; x=1737469828; 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=e0PF2bMPqKZKaH/FqfzRI83Rsy0dE0M4NyqDnd9kKJs=; b=P+/M7EL2upVDn0411Dw9rsi8/0eq2EghscUrLoEtMWNjIyMwp5iY+700ZDH0hUwpYI JfBb2vssT2M7zN6Hd3tSgvaDQYL/D6EAkDuC6PPqA33VLWgwl/eMHGdWtx+J2WHDl4dh AcCfXrStga2nJUgrtHeTpEApYhtEwDL8fggdzl9B8QxQgSvVdfTeScnwE62NbDnDSWC5 bGEm0QVnXwC4LHAVO+AH5l4wHWBSigBnC3jtNr1xrA7n7oETs6zPhsr9rSUsem/P8Hyq dBzRCebf05NJIJ2WsNOGqguw+m2FrGDwXuUCNoJMQo4R3Rgp5MBX4y+TnG4dvXiD4iSW tBmw== X-Forwarded-Encrypted: i=1; AJvYcCUhV7zbjEN4JEScbNDBJFAyzd7+2j2N9+fsfLsB3xuWmU9FJHYg4CJa161sg2XaOO/3vE6wDkzJwfE=@vger.kernel.org, AJvYcCX1kqKTNrbEpV+JgRSjhIZBItAI+e4xHQvOeqM1zuO9O9y8SRDiDzazEvRquzugnLaRb/bhGAOr@vger.kernel.org X-Gm-Message-State: AOJu0YwRhdic88fP6Jjwz7HONnw19oR8uMI3kbtkTUnefOstHU77MNMm iKyzxxJtS6iE0qgYZ925niU3AOnJycLSRlsZYd1v2c/heC+8luft X-Gm-Gg: ASbGncuKUWcDwEtvvPBaKfSBg3kSitVKwSbY/AP2TK0QqpY2LGWnRLNgYLOVL1pm+D8 V+2cGWiLeiUWr5OR+AInUuTO3q/ceM3noByma/6hUfs84Ewg56if8rwQ4/xVMKoRpNtB/32ZiOK qyqkwHtfBZzpGrabIynQirJQW2hGOiewzzIrTnM2oVZXkYa/CRxbL30sqPVGQo/lVJuGNtqJ9cS UXswypiVJhfefGmQL5GFGx8WNS8KU9dyJykfc8etIRGwQ== X-Google-Smtp-Source: AGHT+IEuKyXifrQa9t+s3G5OCIi22aGU5IINUIaNF71STjbL+HOZkXbEFbB3f3BadfPqqzGzTtYx3A== X-Received: by 2002:a05:6a00:39a8:b0:728:f21b:ce4c with SMTP id d2e1a72fcca58-72d324bf1c1mr33037244b3a.5.1736865028244; Tue, 14 Jan 2025 06:30:28 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:30:27 -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 v9 07/10] bnxt_en: add support for tcp-data-split ethtool command Date: Tue, 14 Jan 2025 14:28:49 +0000 Message-Id: <20250114142852.3364986-8-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 Reviewed-by: Michael Chan --- v9: - No changes. 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 d19c4fb588e5..f029559a581e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4630,7 +4630,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 Tue Jan 14 14:28:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938847 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE6FA7E105; Tue, 14 Jan 2025 14:30:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865040; cv=none; b=FxIdx7QXp2pr2AhafJm+bbEauwUb6A76Iu+VfkM+TSVMLiW3fYju9sHO1Wc8lYQTCLBfyyUyyHXz2A4p3Ot5twX/H9iXs/Dm6xVrCUtQ64o2w2bXADRhdIOSC7wUhJSRpRqkdyF96CPmMK1A3Piz9pDeMv6HRykTuLTprCC9hMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865040; c=relaxed/simple; bh=NxdCcWgZjIQdKCN2i8i35vUmQ9Q3zb9goBI5wLHZw2c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dVDZaU0MlPXph1+N9qSFozVdnzq9w/QTn9SH46dHCUCPwR6gtfcaysupFbAmLBjrtWJrBVdYg0HT2BtQLdva2gmUdPsgwIhJGHeu93cBhF2PrRaYaB8oM/KFzD83UqhXbX//+bCFiubdpjPH8hwqd2gYT1oiqdJgOSsnkEJwrMo= 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=IC2tNE9i; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IC2tNE9i" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-218c8aca5f1so120007845ad.0; Tue, 14 Jan 2025 06:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736865038; x=1737469838; 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=JXCmCNgsZ+TRdie/2O5md9ditizTLBUi52YNNDbW5YE=; b=IC2tNE9ifOM8vlMfDmAPF795WsXEK68K5i9MY3M107iZXMb9rg3GD+k1Kt0TzG70UJ KvdzYniB/mJ45QvAG/a64Odc4+wBs54jCXJ4Z5MnZwgl6OTc9Sg9TDzf6Tks8LZNh3lT 1PMUNJfBw86L7FpeaGrO+SCJ+Cy9o2cpV+J9QFSvvdU7wslkNwAMmAXlYur23qKi1enW Y9MSGH9VaPsr7RqnTLceQNG39pHBRSoqYvN0C+ewAr6TrVIDiO4efwnbn827jZn2jtqO rEqAMXseASyiasRBGmRxmklWA3GY7F4jw2WmuNOjvIA7TgGN+pSBr8aQsYdtLDVzUBFb tVtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736865038; x=1737469838; 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=JXCmCNgsZ+TRdie/2O5md9ditizTLBUi52YNNDbW5YE=; b=lMqrzf6sVVnM3qmEMAS/+KfqOAANbI79qKc3jRPXK/QllYPZBW773eY8/otT+FaI8N XUgr0AkD1UosJUAHnfKrQXkRjOK4i/VWsVbi5yVFLFXpiSvrG/A8Fhdyr5PmJ88GJeUZ 2cx4pVonsORzWKKN0pHF9OFHsw9chD5J06MUla4GHEvVVe5k9ZWXhRcsEw1xC9o0Cvgt sP9XUQQVPBJJMajOmPe+p8Vir3/e0TGicCrFI4+kTNxdHSGX5/rzOIKCThvQVOih2vOD KJ31DoLpBswBRzZHucPJTHNX8nVkYLk+cw16i9BUuymZ1lQ6ZQpeOJktuPKv+BoDgRqE S7iQ== X-Forwarded-Encrypted: i=1; AJvYcCU4miY07A5tQsWyUrhzUkZ6u8vuqKRCeWVP5mRmhDrLVYdPLc2Of1OedNK/hipDQPQTAhWZEqVt@vger.kernel.org, AJvYcCX0Ul3dAIwF8CRP4KYE3E+nn+9gQ1fV9KoKSkKhXOIZ5N4+z28nx9BrjFd+X5KpEIqVWib70mHWX3A=@vger.kernel.org X-Gm-Message-State: AOJu0Yzp1f6KW0J/IRSfcGWEgYldCPHcSLRYvpU8ADXIXFoiTYCYSzCV jXtnlNfk5P8ndxsJuH8SVrCba/Lv56rs3RhG0dXfn80fLGUF5pI3 X-Gm-Gg: ASbGncs6yTRlGOas31t6dFed0IbppZKh0wXpo7eIYb3un/10fKXzDslJsgGYLE5UERO AmhIlrhqaOtnIjHB+WljJ53bkGhTe3eTLLGnOFKgwiI4KTsTCMHpvmnephoxXUfxOPyEPteHOcb OMthbqTNbmYnapzeNixoKMdZMR9/NnV1I2/GSOWf9D2GNWJzC+YWE7m8c+Ky/DkmvH31FJvYWN0 5pNpMIPdKWPhAtpnjEr4gBW5vYBbT/LOqu1m2ZMc8Bxsw== X-Google-Smtp-Source: AGHT+IFMgWTfs5UZsrcb7otb8gHtwBsSU5JtHlwfzqTA0/licTW8YuBUSbfCRG0ePaF7qfr3JHfkww== X-Received: by 2002:a05:6a20:43ab:b0:1e1:b1e4:e750 with SMTP id adf61e73a8af0-1e88d1c2651mr40083047637.18.1736865038156; Tue, 14 Jan 2025 06:30:38 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:30:37 -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 v9 08/10] bnxt_en: add support for hds-thresh ethtool command Date: Tue, 14 Jan 2025 14:28:50 +0000 Message-Id: <20250114142852.3364986-9-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 Reviewed-by: Michael Chan --- v9: - No changes. 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 f029559a581e..caddb5cbc024 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4610,6 +4610,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 @@ -6569,6 +6570,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; @@ -6585,7 +6587,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 Tue Jan 14 14:28:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938848 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 AA2B141C94; Tue, 14 Jan 2025 14:30:48 +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=1736865050; cv=none; b=SjRd8ePgI6ZlILCTFEbaRVyvbVkA4vsSXMV1QBfSDkC29TFObcrQ2HNjevqcuZ4zpXE2SycmM9p9oHEB399ym/ljlDdDCiWgcz30FAEXdazMuWw8+eIs1l8YK+E93cbJH1hCGRNvlL36Ih/gGdEFGblxwVVOZAFXE1ubZ5uolTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865050; c=relaxed/simple; bh=oOB7HKtxl6QmCAq8bPzGbVc17RCOUI2Sl+ygJjUnoKI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LPf2lTKncauwCOydzyuPP8Ea+Akq5VQjTLrDGhZY2EbHh1tDVtgCwR7fiAjAp8ATY1L9jKTU96lqIJf7EkoLVI97mHlRpV3vrig0h+9uJ23bkramDPB/STojFOtdPvZk0NdBFKlzhCpNVX20jBq7DpJ6rhPHVcaZ7/fWWrfSp1Y= 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=jPPh6gsh; 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="jPPh6gsh" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2167141dfa1so97934135ad.1; Tue, 14 Jan 2025 06:30:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736865048; x=1737469848; 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=vhVCWNrslkm6iZIefrpS3RD/DxTmVQixP75EKnHEJTk=; b=jPPh6gshjnWNB6nyeycPzZT+cePeUI9Irm2/+e/IUS9eHcxkh9ftjsBNj4itbaCmad TyLyokCg8NJl2DMUwfiC0p6pWUKmY8A5K0lP3/7+5UPrOW3WwUXAB52FskjseK6MCNCM 7C5v4Ho4Ra+6WYF04Z3tJ7QkknEc6aWGwgdT3BmuPm7L17EllhPioK0HM3ByOM2+Dj71 yxHi+5Wh4M0QoJGaX/Zfl7tN2FY2cl+q7nqJYxnytbUzhhBiZX0cBmrLhwrhAndVu4g1 tN8QInmPIbuIsfPPnmVCefMt2uR2V+a4myppgxDP1iI+ChXbqS18i5J6t1xSFBH5aAqW hwHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736865048; x=1737469848; 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=vhVCWNrslkm6iZIefrpS3RD/DxTmVQixP75EKnHEJTk=; b=H4PBuOLM05Pahiy39r+ne4MoNwkm3eTFgOda34n+UHptU/cCUmiXqjRwikB/72eg8f VFMQBE+4byxVTNSHXDsjxcZHR3zlBzcGfaUf+Br5pahwn6pSfuP3LniK5ckAJ25f8ygF m4ReqWbUwBeN2UiZiriPpF0iZy97jYI6rZBbnxkoinRnwtjHIEPekivQ4k/Es8YJ4FCF QqSiygbvnXcLxpMTKwKk2i+sW7kRh1xOcnQMjqdPLcIehyDDlTTAaKCP4OCQk00sMCi3 01lWfOlLvTcLu0TeocOuDZ5CUMyQMNZxWJa8Fa4AzySEugFhUl0g8gjm8JbfWpo4iXRF JrKw== X-Forwarded-Encrypted: i=1; AJvYcCUaRH0EnvE0KZ9rqsB0Rpy4cVKGbe1VWedmfO7Cxpt6/0nHWv8zFT1yhs8/KbxwDeKTUoKW+fKBlNE=@vger.kernel.org, AJvYcCVEDRikDHN6WyN8Y/wawm3H+xLd6Mkl/qdzp5KwFTI2fVOZtdLXWFkXDD3r66ztzsYPhxPdck8B@vger.kernel.org X-Gm-Message-State: AOJu0Yy5Crlmy3VIE9zh8vKKK+B2G9674g7tUpDNCsnpg2Rur3rAl0BS p3wwEFlyiHJJ1ndz+enGFkMcAQK6eAfxQk0WYPzXMGd/LtxfO+iu X-Gm-Gg: ASbGnctj7JRTtTwK65jVYj008BiEl0oQNolFLjENtj7jxjnrLMn1QoG+55bwg7MgjyH 5fhboXg+l12u16/6VtHqoCuH7cYZIspDIphPK1cnZyMNdv1bGxneZ/Ha1xwmGbzO/0K/5Jnh9Tg 37Cc6TTONAN9cWppXkMG5KlMN7DS29NA1T/DQKqZBFPGKITJKKyBAt46nVh5Wb4fppo/62FJn4C 2ABBYr2W3cmH8T96ykxUQNWgM5pRG9s3olPluZCJHgnPg== X-Google-Smtp-Source: AGHT+IEsCQchocuKWGOo5d0GSwKE3iy2BBC2w8Tum2vsnQSqh6An2Nfj/aT9mR7oqQA3eR6tVsH/Iw== X-Received: by 2002:a05:6a21:8805:b0:1e0:cc01:43da with SMTP id adf61e73a8af0-1e8b0af29b8mr21600280637.0.1736865047913; Tue, 14 Jan 2025 06:30:47 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:30:47 -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 v9 09/10] netdevsim: add HDS feature Date: Tue, 14 Jan 2025 14:28:51 +0000 Message-Id: <20250114142852.3364986-10-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 --- v9: - Rebase on the top of net-next. 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 d013b6498539..f92b05ccdca9 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -54,6 +55,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; @@ -74,6 +76,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 a70f62af4c88..dcf073bc4802 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 Tue Jan 14 14:28:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13938849 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 B170114A4F3; Tue, 14 Jan 2025 14:30:58 +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=1736865060; cv=none; b=nio2Ks/MZmtZwmSQFBPOb+5j1Eu4w6MuSrqaIL0ULDKEIRnnmIdYJd+vAzrFGAKJlaPBC1d7/c+J79IrxQPpjtLtH/c6CftcS+B/vE7ShG28hIBngH7Lsla6CatRG5Dn2Ug5GqMkYfeBjY4N7ayb8kd1beuzODeO82W4zvuzX/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736865060; c=relaxed/simple; bh=kH19/8G+ARXVXxG3Zsmf98ZfHUHinE6g2lyahxlFMK0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jeJcSVYQatxjIBkfSABNDeMoflWmcWl+gYWMl3nj7dxASNbFzsX2ONtbwJ/sOzOY6NohRA5/oxFvSPCGsOwWjpcDSeGcpJ7ueSTDpNSUj7EkTzGL70XaihUuOQHTkUHowPQrZTC7V0LX7GOGGjDmciAECS9astQ9AOPYjlYYGnE= 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=AUIg2GjV; 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="AUIg2GjV" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2166f1e589cso117940745ad.3; Tue, 14 Jan 2025 06:30:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736865058; x=1737469858; 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=HmzLiqs3xurRkTvn6Vaf/B5i5AaWeH3iqyiYXY3lnJc=; b=AUIg2GjVFC/Y/FKM8nqnKxyvc2elMLG35MZz+2dC5Oi5E0BXpNcWPL2BkZ9/zy4EI9 MgDWe76sv1lxaDqS8N0zGdOTsupKByR302JZMDrVbt9PwNI0EhoM9Lpv6lE3eYI9o2/e EF9mzgcNrNp8G7WLPDoQI0pKlAC4N91pUsrJPzokJ39P/vKvo57TIciM+VaD9FZFIk1q qD2UIcu0YPAhkXHqfS78BU2cdkvJOv9oysZ5UBxYHfDFp8QPXjfgadvFd849Ir4uSS9P Rvd3jQ3+/JdFMxTo2LUYrE7Vz2qLxUUdwNIjChoQNY1nF3CGCpq2C/H6kTq/D6lU72re vcdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736865058; x=1737469858; 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=HmzLiqs3xurRkTvn6Vaf/B5i5AaWeH3iqyiYXY3lnJc=; b=Q42vgi6TkuoAzjauZ5hI2hj4zDcSiulLZ2RUfzjf7JVH7l+SB1UyaalXVUWZFTTZRN lWonq9WEeV0UtM+k9p/UqKh9QFM4ZxZt1ciaOVhPM7zKkIrYuxwoRbxm+hacaYdYASya hmsI7/menl7wtpGyQmzZh/H1Jdd0hFLMEskz5nD630rcK28/Yecbl5WdhV7FClS9Ih3D i+/vD/RE5jGSQd8CuLvF01ebb3eOfSKG3aYG5ajFAOaIb/tGc40aTrqqvhm/jmQi4NP+ AEw0QhVgjEggngha4QC1r0qOilntTDiDZLwltZVFtW8y5HNMJxx1W0CPvnbS9ul0/guE DzWw== X-Forwarded-Encrypted: i=1; AJvYcCWaq+1kQLYYnBWzhSF4qLJ4BcZE5A2iICiE+Dq7UmwB2svQJGwsJA08e8NGdBwZVBwihf/ZvPa+V4o=@vger.kernel.org, AJvYcCWe8iaaFy6UzLAjYRBYkv5FbBZv0jjHh494Ln0DV2/ZvbY9P3/Rv3D68Le9H3MrXx2umpqBIbwC@vger.kernel.org X-Gm-Message-State: AOJu0Yw5q7Arigb9y/RRMRvBFIpHJOxxBKtoUc30FsF4HL4Gr70trtQS L530Eke9xNt8LTH79DMrnZfAODreJ5UMc0x9nhX4ImRoorcuS9fR X-Gm-Gg: ASbGncu2kf0kRgeP5Zto986HUXhIGK24hIqrc+aYB/q3ODzheKjxO1HkzfEw77FXDYz M2gLyIOZ/8K6j/rqQCowEjKlZ2W94gGB27mW8zzAjY/P2QFbjJXsCu9nkfRH1qkcWDSZpOZSZX4 N5Mh4v6QUesjlnneMk12n/KI9Ox8XGYKq35Bbt+KTttITAfSO+GeAIP9XqBP1UTg57P97XIt9Th YAvM5mgXp9oRP9xhhvbdx/X9a0ECE82pWTkh8OL+08p/g== X-Google-Smtp-Source: AGHT+IGYSckeLtY6LvPnxNoHRuEEag34sM1JW1zzC+Q67vRnk5HpMTDgqip4uX0kaYvGw4IDrB1Afw== X-Received: by 2002:a05:6a00:170a:b0:725:d64c:f113 with SMTP id d2e1a72fcca58-72d21f18064mr38564183b3a.3.1736865057673; Tue, 14 Jan 2025 06:30:57 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d406a4dfesm7474582b3a.156.2025.01.14.06.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 06:30:57 -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 v9 10/10] selftest: net-drv: hds: add test for HDS feature Date: Tue, 14 Jan 2025 14:28:52 +0000 Message-Id: <20250114142852.3364986-11-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250114142852.3364986-1-ap420073@gmail.com> References: <20250114142852.3364986-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 --- v9: - No changes. 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 469179c18935..137470bdee0c 100644 --- a/tools/testing/selftests/drivers/net/Makefile +++ b/tools/testing/selftests/drivers/net/Makefile @@ -12,6 +12,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()