From patchwork Sun Jan 19 02:05:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13944331 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53498EAF1 for ; Sun, 19 Jan 2025 02:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252321; cv=none; b=ud1B05YKTdASWH3caHxg5uuqGH9w7/LdUNul/bsgsR2KWLDp6kN5pBZMpJVGIH5NQFx2PwjhpoLlG0TVVlM7rNh78hoGjJCf4iCdhjG/DtPtL72h24lXomK4FqM3bxpZM9LmGGOLvCfcJZcmhMv61mQK1KG4F1SgC//l9BA7N3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252321; c=relaxed/simple; bh=VOdEhcV+2oCHLu2dS/5gu6v+QDdJ0k1n/9hrAJAkmbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ljKGcXUEmYKs3P8o6I7RpWNVB2Jv/9/O/+LRZWkl951U96l6c7OuqS8qF4GQ8Gh3J5+dRiicPllhmoTby7kAAYJbRiakK7a+9T66/yb7AMU3L+oJtxzNEL7YGPbEz0Y8jNnuQD3nE9sNopW350+gDMxp39kPgIHLQmViTqHNqn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NSChqj1i; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NSChqj1i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C922FC4CEE4; Sun, 19 Jan 2025 02:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737252321; bh=VOdEhcV+2oCHLu2dS/5gu6v+QDdJ0k1n/9hrAJAkmbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NSChqj1ibz4v/Fyer/xmGEagt2XGkqQ6RzLBtZHfYPAcVOh0sfXsLgMk9FQt570OC M3cAZLQvBZ+gryW1sJdBadm0ZQVNBltnJPUTTap9ZlslV4/yNYgWbSnd1DOksCU7X3 B38ixprZ/rOv3OJ/xFfNBE4oCroHoL1PTeIZpgOSBA32QkUFjbz8ylBpGyDeUwpEsl MiGhAOD1yX95ajsCRGS5zljr0Hwg7dUL6DESd4G6rhw8Ht2o4ilsbCw68Qq6b4TiX3 H008RY1N9+qZIYInfwLxKKUAAqP5aRNN7oTeEOiMSY5Qmqz54nAVGmhXx7jTWL36I/ CEHOySjuHdR7w== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ap420073@gmail.com, Jakub Kicinski Subject: [PATCH net-next v2 1/7] net: move HDS config from ethtool state Date: Sat, 18 Jan 2025 18:05:11 -0800 Message-ID: <20250119020518.1962249-2-kuba@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250119020518.1962249-1-kuba@kernel.org> References: <20250119020518.1962249-1-kuba@kernel.org> 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 Separate the HDS config from the ethtool state struct. The HDS config contains just simple parameters, not state. Having it as a separate struct will make it easier to clone / copy and also long term potentially make it per-queue. Signed-off-by: Jakub Kicinski --- include/linux/ethtool.h | 4 ---- include/linux/netdevice.h | 3 +++ include/net/netdev_queues.h | 10 ++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 5 +++-- drivers/net/netdevsim/ethtool.c | 9 +++++---- drivers/net/netdevsim/netdev.c | 10 +++++----- net/core/dev.c | 10 ++++++++-- net/core/devmem.c | 4 ++-- net/ethtool/rings.c | 8 +++++--- 10 files changed, 43 insertions(+), 24 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 64301ddf2f59..870994cc3ef7 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1171,16 +1171,12 @@ 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. */ 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/linux/netdevice.h b/include/linux/netdevice.h index 8308d9c75918..173a8b3a9eb2 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -63,6 +63,7 @@ struct dsa_port; struct ip_tunnel_parm_kern; struct macsec_context; struct macsec_ops; +struct netdev_config; struct netdev_name_node; struct sd_flow_limit; struct sfp_bus; @@ -2410,6 +2411,8 @@ struct net_device { const struct udp_tunnel_nic_info *udp_tunnel_nic_info; struct udp_tunnel_nic *udp_tunnel_nic; + /** @cfg: net_device queue-related configuration */ + struct netdev_config *cfg; struct ethtool_netdev_state *ethtool; /* protected by rtnl_lock */ diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h index 5ca019d294ca..b02bb9f109d5 100644 --- a/include/net/netdev_queues.h +++ b/include/net/netdev_queues.h @@ -4,6 +4,16 @@ #include +/** + * struct netdev_config - queue-related configuration for a netdev + * @hds_thresh: HDS Threshold value. + * @hds_config: HDS value from userspace. + */ +struct netdev_config { + u32 hds_thresh; + u8 hds_config; +}; + /* See the netdev.yaml spec for definition of each statistic */ struct netdev_queue_stats_rx { u64 bytes; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 748c9b1ea701..0998b20578b4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4610,7 +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->dev->cfg->hds_thresh = BNXT_DEFAULT_RX_COPYBREAK; } /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must @@ -6585,7 +6585,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; + u16 hds_thresh = (u16)bp->dev->cfg->hds_thresh; struct hwrm_vnic_plcmodes_cfg_input *req; int rc; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 65a20931c579..0a6d47d4d66b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "bnxt_hsi.h" #include "bnxt.h" @@ -834,7 +835,7 @@ static void bnxt_get_ringparam(struct net_device *dev, 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 = dev->cfg->hds_thresh; kernel_ering->hds_thresh_max = BNXT_HDS_THRESHOLD_MAX; } @@ -852,7 +853,7 @@ static int bnxt_set_ringparam(struct net_device *dev, (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) return -EINVAL; - hds_config_mod = tcp_data_split != dev->ethtool->hds_config; + hds_config_mod = tcp_data_split != dev->cfg->hds_config; if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_DISABLED && hds_config_mod) return -EINVAL; diff --git a/drivers/net/netdevsim/ethtool.c b/drivers/net/netdevsim/ethtool.c index 12163635b759..189793debdb7 100644 --- a/drivers/net/netdevsim/ethtool.c +++ b/drivers/net/netdevsim/ethtool.c @@ -3,6 +3,7 @@ #include #include +#include #include "netdevsim.h" @@ -71,8 +72,8 @@ 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->tcp_data_split = dev->cfg->hds_config; + kernel_ring->hds_thresh = dev->cfg->hds_thresh; kernel_ring->hds_thresh_max = NSIM_HDS_THRESHOLD_MAX; if (kernel_ring->tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN) @@ -190,8 +191,8 @@ static void nsim_ethtool_ring_init(struct netdevsim *ns) 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; + ns->netdev->cfg->hds_config = ETHTOOL_TCP_DATA_SPLIT_UNKNOWN; + ns->netdev->cfg->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 f92b05ccdca9..42f247cbdcee 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -55,10 +55,10 @@ 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; + struct netdev_config *cfg; struct nsim_rq *rq; int rxq; @@ -76,11 +76,11 @@ 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; + cfg = peer_dev->cfg; 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))) + (cfg->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED || + (cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + cfg->hds_thresh > len))) skb_linearize(skb); skb_tx_timestamp(skb); diff --git a/net/core/dev.c b/net/core/dev.c index d7cbe6ff5249..71b3f786a9cd 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -106,6 +106,7 @@ #include #include #include +#include #include #include #include @@ -9716,7 +9717,7 @@ 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 && + if (dev->cfg->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, @@ -9761,7 +9762,7 @@ 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 && + if (dev->cfg->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; @@ -11539,6 +11540,10 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, if (!dev->ethtool) goto free_all; + dev->cfg = kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT); + if (!dev->cfg) + goto free_all; + napi_config_sz = array_size(maxqs, sizeof(*dev->napi_config)); dev->napi_config = kvzalloc(napi_config_sz, GFP_KERNEL_ACCOUNT); if (!dev->napi_config) @@ -11607,6 +11612,7 @@ void free_netdev(struct net_device *dev) return; } + kfree(dev->cfg); kfree(dev->ethtool); netif_free_tx_queues(dev); netif_free_rx_queues(dev); diff --git a/net/core/devmem.c b/net/core/devmem.c index c971b8aceac8..3bba3f018df0 100644 --- a/net/core/devmem.c +++ b/net/core/devmem.c @@ -141,12 +141,12 @@ 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) { + if (dev->cfg->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED) { NL_SET_ERR_MSG(extack, "tcp-data-split is disabled"); return -EINVAL; } - if (dev->ethtool->hds_thresh) { + if (dev->cfg->hds_thresh) { NL_SET_ERR_MSG(extack, "hds-thresh is not zero"); return -EINVAL; } diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index d8cd4e4d7762..7a3c2a2dff12 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only +#include + #include "netlink.h" #include "common.h" @@ -219,7 +221,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; + kernel_ringparam.tcp_data_split = dev->cfg->hds_config; ethnl_update_u32(&ringparam.rx_pending, tb[ETHTOOL_A_RINGS_RX], &mod); ethnl_update_u32(&ringparam.rx_mini_pending, @@ -295,8 +297,8 @@ 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; - dev->ethtool->hds_thresh = kernel_ringparam.hds_thresh; + dev->cfg->hds_config = kernel_ringparam.tcp_data_split; + dev->cfg->hds_thresh = kernel_ringparam.hds_thresh; } return ret < 0 ? ret : 1; From patchwork Sun Jan 19 02:05:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13944332 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2DCC29CE7 for ; Sun, 19 Jan 2025 02:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252322; cv=none; b=I6V1AWD4zjYufZYJwUFYPPXMFt2PiRhvzFz/snPvxZxLpk+WwC4ShF/xig50/Lfnpi+fe90bpQeyJCuHNk2G1pMHFUHdGIjVeHP+p/yis34W6UVUyDiA/Uvd81u8OIFPbqK71BM2s5GpC8j3LbdjvTrM2xQNIHrXVMvLp9SQyuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252322; c=relaxed/simple; bh=yA1KwJiIOYKNcrFJ32zpsCwi3SpkpgvUBGg6qkDGA7g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KRY/o8vVIw748qCFa7qWfHcRVrAG/V+EJuZpoPos+d30/3o4FZjyJWI5roa+zk16/S9uJu7CsX9dnuzxIJKmgG4V0JJwe2ECP8AKXBiUOHwFcLTh8sZHOXQyJo7+sHdpLC/glNkxOaKwmoPrl/e32mXREw3Fk5qghKboCVmnz0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nV7+2X4I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nV7+2X4I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F4DAC4CEE3; Sun, 19 Jan 2025 02:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737252321; bh=yA1KwJiIOYKNcrFJ32zpsCwi3SpkpgvUBGg6qkDGA7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nV7+2X4IQFEkwf0HL3OWGxDl0zCRDZrt6EiGiJ+E4gypn8hR6uflWNeRSwa2GOqSX NbS+ghePj/Go9NUOj4gjHKsnlBdfeaUFpwjBfHvMvR4LTmeikcIJ+lFESB+5L5M1hD UrJih/UO9OqruJvLM7yY+nDTQuTIc/xd0LY564FXbOmbD/XwwJ3uykkQxItXjlO+ov iSUH1SZLjmE46+BhDzp2xrCvMPWvqW7hOSHcQ1rHRqXQVjca5SAyruNOeNeFRTxYbA FM+Y9r9Cdk9ZwFUhaQy1222QpMbFTFA9EtJ/ih4XiRkv2q9kgWza5vuUlfiTR2u5x8 uRolv+W2f79eA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ap420073@gmail.com, Jakub Kicinski Subject: [PATCH net-next v2 2/7] net: ethtool: store netdev in a temp variable in ethnl_default_set_doit() Date: Sat, 18 Jan 2025 18:05:12 -0800 Message-ID: <20250119020518.1962249-3-kuba@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250119020518.1962249-1-kuba@kernel.org> References: <20250119020518.1962249-1-kuba@kernel.org> 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 For ease of review of the next patch store the dev pointer on the stack, instead of referring to req_info.dev every time. No functional changes. Signed-off-by: Jakub Kicinski --- net/ethtool/netlink.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 849c98e637c6..c17d8513d4c1 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -667,6 +667,7 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info) const struct ethnl_request_ops *ops; struct ethnl_req_info req_info = {}; const u8 cmd = info->genlhdr->cmd; + struct net_device *dev; int ret; ops = ethnl_default_requests[cmd]; @@ -688,19 +689,21 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info) goto out_dev; } + dev = req_info.dev; + rtnl_lock(); - ret = ethnl_ops_begin(req_info.dev); + ret = ethnl_ops_begin(dev); if (ret < 0) goto out_rtnl; ret = ops->set(&req_info, info); if (ret <= 0) goto out_ops; - ethtool_notify(req_info.dev, ops->set_ntf_cmd, NULL); + ethtool_notify(dev, ops->set_ntf_cmd, NULL); ret = 0; out_ops: - ethnl_ops_complete(req_info.dev); + ethnl_ops_complete(dev); out_rtnl: rtnl_unlock(); out_dev: From patchwork Sun Jan 19 02:05:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13944333 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2DFB29D0C for ; Sun, 19 Jan 2025 02:05:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252322; cv=none; b=iant6xf/W+S045DmEoHTVmhqtArrwYHb3Ffi+M4djAuxC4qfdnbD4Rw7ZH3x1uNlTSF8M8zWThlsF3WYLo1c7B0Gjeo6u4vcfIlgmqm+K3WPh/IK0Wp4fM1TOoLflu3tzC8GnPK2Dzos7U0r75tapPLIXFkQjiGw3lw0dazIVJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252322; c=relaxed/simple; bh=2xu0ysSj1z04iAMH7eWzt/YSIVClJH+CJ4pgARNm/rU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cUmmk5nQiKxVfAL9NMsyFm9Kw6JErwLcs3j9U1jyErQqJia4JgUHw/JFv56CEhpza0Xvwtzhm6jSiqZ9O7sVTFSeH/mOv9yIVScyTU0IU9DYsb1n1LhTGrHYYwIJI2z8c8ijecgYlmfvq3ABuDp4YrPe4CcorjAJ6VsoL3YS5N8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y+06Vx7E; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y+06Vx7E" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5AB6C4CEDF; Sun, 19 Jan 2025 02:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737252322; bh=2xu0ysSj1z04iAMH7eWzt/YSIVClJH+CJ4pgARNm/rU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y+06Vx7EOi6+WjOe576QQWCEzThS9qbSr3D1xRnJwYvf0CLJfQHegNQNRbCOcWxUK x3C+OHAVHLQalKOSYMkVPjuQ/RG2zGztB1arF2y7JSCTcnEJHHV8Gbqe7S6Dsmw+8X sQ59CHIacG81QB++W5UVsl6InIPBDIyPmf+F4nkXwGxAtET9SXzVnJfXGPrdtpMwJG YXwmEy+Y2D0ZOzYEolG/02gLatmWB9O5/Das/Zi+OIW0UJWEKuc9kcoiKUaoFLBl7O yaBuBbh5KnT56liT4iXWyoEitPWWCJTK2iKM4wbtiuNMki9fcMS+g2MHlrAmgBoBrk 6+regCPgnok+Q== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ap420073@gmail.com, Jakub Kicinski Subject: [PATCH net-next v2 3/7] net: provide pending ring configuration in net_device Date: Sat, 18 Jan 2025 18:05:13 -0800 Message-ID: <20250119020518.1962249-4-kuba@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250119020518.1962249-1-kuba@kernel.org> References: <20250119020518.1962249-1-kuba@kernel.org> 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 Record the pending configuration in net_device struct. ethtool core duplicates the current config and the specific handlers (for now just ringparam) can modify it. Signed-off-by: Jakub Kicinski --- v2: - make sure all dev->cfg changes are under rtnl_lock --- include/linux/netdevice.h | 6 ++++++ net/core/dev.c | 2 ++ net/ethtool/netlink.c | 21 ++++++++++++++++++--- net/ethtool/rings.c | 8 +++----- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 173a8b3a9eb2..8da4c61f97b9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2413,6 +2413,12 @@ struct net_device { /** @cfg: net_device queue-related configuration */ struct netdev_config *cfg; + /** + * @cfg_pending: same as @cfg but when device is being actively + * reconfigured includes any changes to the configuration + * requested by the user, but which may or may not be rejected. + */ + struct netdev_config *cfg_pending; struct ethtool_netdev_state *ethtool; /* protected by rtnl_lock */ diff --git a/net/core/dev.c b/net/core/dev.c index 71b3f786a9cd..a7883f1c94a0 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11543,6 +11543,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, dev->cfg = kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT); if (!dev->cfg) goto free_all; + dev->cfg_pending = dev->cfg; napi_config_sz = array_size(maxqs, sizeof(*dev->napi_config)); dev->napi_config = kvzalloc(napi_config_sz, GFP_KERNEL_ACCOUNT); @@ -11612,6 +11613,7 @@ void free_netdev(struct net_device *dev) return; } + WARN_ON(dev->cfg != dev->cfg_pending); kfree(dev->cfg); kfree(dev->ethtool); netif_free_tx_queues(dev); diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index c17d8513d4c1..1d2f62ef6130 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only +#include #include #include #include @@ -692,19 +693,33 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info) dev = req_info.dev; rtnl_lock(); + dev->cfg_pending = kmemdup(dev->cfg, sizeof(*dev->cfg), + GFP_KERNEL_ACCOUNT); + if (!dev->cfg_pending) { + ret = -ENOMEM; + goto out_tie_cfg; + } + ret = ethnl_ops_begin(dev); if (ret < 0) - goto out_rtnl; + goto out_free_cfg; ret = ops->set(&req_info, info); - if (ret <= 0) + if (ret < 0) + goto out_ops; + + swap(dev->cfg, dev->cfg_pending); + if (!ret) goto out_ops; ethtool_notify(dev, ops->set_ntf_cmd, NULL); ret = 0; out_ops: ethnl_ops_complete(dev); -out_rtnl: +out_free_cfg: + kfree(dev->cfg_pending); +out_tie_cfg: + dev->cfg_pending = dev->cfg; rtnl_unlock(); out_dev: ethnl_parse_header_dev_put(&req_info); diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index 7a3c2a2dff12..5e8ba81fbb3e 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -294,13 +294,11 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) return -EINVAL; } + dev->cfg_pending->hds_config = kernel_ringparam.tcp_data_split; + dev->cfg_pending->hds_thresh = kernel_ringparam.hds_thresh; + ret = dev->ethtool_ops->set_ringparam(dev, &ringparam, &kernel_ringparam, info->extack); - if (!ret) { - dev->cfg->hds_config = kernel_ringparam.tcp_data_split; - dev->cfg->hds_thresh = kernel_ringparam.hds_thresh; - } - return ret < 0 ? ret : 1; } From patchwork Sun Jan 19 02:05:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13944334 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DBA42BB13 for ; Sun, 19 Jan 2025 02:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252323; cv=none; b=LNQO4W4UBMSM06zzIrVjCsGxhKmlQRva5W3bZgREQ4kpTGp+wg6PrQXGdNl4J7kRm1T6axpojxhK4ZTLKm6cSk2JoHnBd+2sb6cog+vNfl4LO0musEO1DayDcaKr8E5g6gYJCgwYPyaGWdc4jmAbk0ZSbZS8S4TvOnsrhR9LxFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252323; c=relaxed/simple; bh=8mWEmpWCBlvUXujYpypa47nfhD+KnSA+79aLBtQdwuo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m0JtlAv15vxFA1L3P3m780DzKwJObsEo4jSeQyezkdKbINH9ywIc5byOnsqjv1Tj7IPBfXcc4CbV+nU+d2h2dv1FsgG8OKBJ+JY/eRe10P+rSruMa6eb0qsTD0gtI4NGIFY9CV4/zv3ftZ0w7W9s88xezPJAortOyYWaMWFBNmw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RIkQ27bZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RIkQ27bZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66E02C4CEE2; Sun, 19 Jan 2025 02:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737252322; bh=8mWEmpWCBlvUXujYpypa47nfhD+KnSA+79aLBtQdwuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RIkQ27bZO9fWuRw6Ys8W4SC6C/4zIenphJKjoSN/fhkfGu/OwpzDB61rfRP9pR17u FzDbvf/BISNqjlRtM7PpMV2WaO12No9hR/zareKgT8gJsGFbaQymPyMffDwUaVlnxy 3LjhDLNqc+9JVj7ANWFmRkA2Nuk85WC6wYwd2+tW6vATalVT/fOgoew7WQ9OQdd3Vs H6D+j0DGh5pTqczPnxtWelwPUKW0PEu0sOuEwfMTtokNkIPtI1fgm61V7vu2CFZEhs p6GwcGBEieABVv7p+ightyKozm3OXXd05VDxriJnMkwVax9lWexPzur+3NSKlQi5Z1 j0/JFKTh6zUgA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ap420073@gmail.com, Jakub Kicinski Subject: [PATCH net-next v2 4/7] eth: bnxt: apply hds_thrs settings correctly Date: Sat, 18 Jan 2025 18:05:14 -0800 Message-ID: <20250119020518.1962249-5-kuba@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250119020518.1962249-1-kuba@kernel.org> References: <20250119020518.1962249-1-kuba@kernel.org> 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 Use the pending config for hds_thrs. Core will only update the "current" one after we return success. Without this change 2 reconfigs would be required for the setting to reach the device. Fixes: 6b43673a25c3 ("bnxt_en: add support for hds-thresh ethtool command") Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0998b20578b4..2eeed4c11b64 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6585,7 +6585,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->cfg->hds_thresh; + u16 hds_thresh = (u16)bp->dev->cfg_pending->hds_thresh; struct hwrm_vnic_plcmodes_cfg_input *req; int rc; From patchwork Sun Jan 19 02:05:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13944335 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82AF13FB31 for ; Sun, 19 Jan 2025 02:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252323; cv=none; b=Z1X9OOIGWJM2LlpPWlMNbKNfshGDTCRgLQaiCLjqm5UGa3pnmHouXmIz/wW6BAvYY7qQGl/oYR/TSgexvfBiyOPEIXIil1lJIeYHpFZyS5HZpMnSNr5aQ1jv3lKlsNzshaxbeFFFpcslrYkWfhaPQDtj9oEyhOFkNSBTGF0Vgs0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252323; c=relaxed/simple; bh=NlIev300popf804jEDnyYpvGEa84DthL/5QWm4+964o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qyveUxlefR+0sc2tqC07x9BZLgcl0jj0yG2ACWikjfjWOBOY1I6aAgKGstr640zTq4CGab8Yl6Wz9SmsngAeipM25VtzM9Yql8jghqxNEioI/NOEEyElc+pWq2oXsGONuwjC6QOGxmw+hvlMoirpB7+WRaWpMJhLuVz3tqAolgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lADPiG4C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lADPiG4C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07A26C4CEE5; Sun, 19 Jan 2025 02:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737252323; bh=NlIev300popf804jEDnyYpvGEa84DthL/5QWm4+964o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lADPiG4CtKLH8YAYwGehy5ANccEyVCYmcBCoSeKdLTjP/Fwe30FtKZvQDucJr6PPf ftnRSFELuf59I43g2Sqq0lCllWHK1wB64KbN2hm/hts2SBJPvPoUjZvixX7jaiLZdF LpGoxoldpXxFnLufSeQfb1LJiRk5uaUCDcTVidd5JRY1t7vxS0AlSurt+vB9MWkIj+ W+Oc8vmNio+plk/05+1cnIJQ4L1wLhUacXJ0IkR8Ixc7oi9N3ImTparpmbDD1k6+QZ dqiCIczQayMPsElexEtXA15MnUlwzQ9hKv9um2upqLGTkHZEM+3PnXHwcvKCgSOBQz SLIlce/9lehxg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ap420073@gmail.com, Jakub Kicinski Subject: [PATCH net-next v2 5/7] net: ethtool: populate the default HDS params in the core Date: Sat, 18 Jan 2025 18:05:15 -0800 Message-ID: <20250119020518.1962249-6-kuba@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250119020518.1962249-1-kuba@kernel.org> References: <20250119020518.1962249-1-kuba@kernel.org> 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 core has the current HDS config, it can pre-populate the values for the drivers. While at it, remove the zero-setting in netdevsim. Zero are the default values since the config is zalloc'ed. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 - drivers/net/netdevsim/ethtool.c | 5 ----- net/ethtool/rings.c | 4 ++++ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 0a6d47d4d66b..9c5820839514 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -835,7 +835,6 @@ static void bnxt_get_ringparam(struct net_device *dev, ering->rx_jumbo_pending = bp->rx_agg_ring_size; ering->tx_pending = bp->tx_ring_size; - kernel_ering->hds_thresh = dev->cfg->hds_thresh; kernel_ering->hds_thresh_max = BNXT_HDS_THRESHOLD_MAX; } diff --git a/drivers/net/netdevsim/ethtool.c b/drivers/net/netdevsim/ethtool.c index 189793debdb7..3b23f3d3ca2b 100644 --- a/drivers/net/netdevsim/ethtool.c +++ b/drivers/net/netdevsim/ethtool.c @@ -72,8 +72,6 @@ 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->cfg->hds_config; - kernel_ring->hds_thresh = dev->cfg->hds_thresh; kernel_ring->hds_thresh_max = NSIM_HDS_THRESHOLD_MAX; if (kernel_ring->tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN) @@ -190,9 +188,6 @@ 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->cfg->hds_config = ETHTOOL_TCP_DATA_SPLIT_UNKNOWN; - ns->netdev->cfg->hds_thresh = 0; } void nsim_ethtool_init(struct netdevsim *ns) diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index 5e8ba81fbb3e..7839bfd1ac6a 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -39,6 +39,10 @@ static int rings_prepare_data(const struct ethnl_req_info *req_base, ret = ethnl_ops_begin(dev); if (ret < 0) return ret; + + data->kernel_ringparam.tcp_data_split = dev->cfg->hds_config; + data->kernel_ringparam.hds_thresh = dev->cfg->hds_thresh; + dev->ethtool_ops->get_ringparam(dev, &data->ringparam, &data->kernel_ringparam, info->extack); ethnl_ops_complete(dev); From patchwork Sun Jan 19 02:05:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13944336 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D9C084A2B for ; Sun, 19 Jan 2025 02:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252324; cv=none; b=joJeOoGVgmHd/INs42k9CdRipq343GMcKuz5iXPrZSSgaFsfNjeejgY9IXsG5s90k1FWLPkvPAQo4Ts5oXXn1sOyplO2DCYfc2+LhIvWRvAqNzAzTGhAZJXFjQqWdeDm3ALrkNh9dOkOtcyyiMY/SOmPjnfIMpnMQOIGl40SdY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252324; c=relaxed/simple; bh=liEb6FrciZS5IMCArR+0U4lSsdrh9MYWLJ5LVZqT+gg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uLMcfg9kgOKfnonmqcW3gqJIvB7KoHDjG/CdX8H66++xw0lqO6xpfRMeDD8tdZHfeQ6yKqoXp9Kyxba9cNVWjtU8+LItxg1n3VEMk5AsGcNSW8OqiXNDJJB3jDJfHQ8WvFynKs6q6aQhIoOVSebXLDvj2/85TkM9YDTKiZYE27U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XcfuuSs9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XcfuuSs9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8884FC4CED1; Sun, 19 Jan 2025 02:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737252323; bh=liEb6FrciZS5IMCArR+0U4lSsdrh9MYWLJ5LVZqT+gg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XcfuuSs9VS+7fn7nWbF33T7smYlr+3pLB+br6z8qJLtLNwAD4ib6fbOeG7pvkchCK djHsDT0V7dBEypf4XhlR6IfWHRrkh7+ImoEyuKSk6rUKHzWEocWAEDMzyy5dzm1oar mWxeltlXt/grHFJ1wfXLyYd265A+iHOYm8nBKsBlpeFkhqwYUZW91xBa9AgkXGI5vc 5YyaajPGxdBE21Mfr/DuWaE1LoN4P0rhWNVin78zDOGuzzG7hfb8x4QOn1k+7YPx3z nGbpDClTeqIEAtgfaq/VfRJAB1ctYcdEjEuUbPyU3RhmSMDtfDYnO10VMM9Ag0wsbM jmONumy82mjqQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ap420073@gmail.com, Jakub Kicinski Subject: [PATCH net-next v2 6/7] eth: bnxt: allocate enough buffer space to meet HDS threshold Date: Sat, 18 Jan 2025 18:05:16 -0800 Message-ID: <20250119020518.1962249-7-kuba@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250119020518.1962249-1-kuba@kernel.org> References: <20250119020518.1962249-1-kuba@kernel.org> 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 Now that we can configure HDS threshold separately from the rx_copybreak HDS threshold may be higher than rx_copybreak. We need to make sure that we have enough space for the headers. Fixes: 6b43673a25c3 ("bnxt_en: add support for hds-thresh ethtool command") Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 2eeed4c11b64..19e723493c4e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4671,9 +4671,10 @@ 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(max(BNXT_DEFAULT_RX_COPYBREAK, - bp->rx_copybreak) + - NET_IP_ALIGN); + rx_size = max3(BNXT_DEFAULT_RX_COPYBREAK, + bp->rx_copybreak, + bp->dev->cfg_pending->hds_thresh); + rx_size = SKB_DATA_ALIGN(rx_size + NET_IP_ALIGN); rx_space = rx_size + NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); } From patchwork Sun Jan 19 02:05:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13944337 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9088F2BB13 for ; Sun, 19 Jan 2025 02:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252324; cv=none; b=D0SErxQc8Ht4cRQ5Xx9abN/4QCOOfVlc5Bp2jJJL4jj5visyTwQny+B+Jv5EGyPyH0HWe5+BMvgo6pwaZYMkq26NDfVhDi0sYU/ZaWWEEE9/r+sRgjzAo88L6pzjVKXDw8bEp/HjkbwAjVhLIlWIRzn5tZIUL0v6aSXjXaIsx/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737252324; c=relaxed/simple; bh=W7g5mzKYbLZMyqo4vpbvxQf4UQRTdOwmKnBZtmNVrTo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uLryeuTPyleQx2zhpdCD4I/YsuiWlRmpLeKsQdgX3I4f30k8kseLdQwq2p1G97bkJA5oLk5H6p7CwDgH/YA7dUKf1VkpYs3lY8IUNTiZn6P+wGLAzjcvPbYMgVAlT1tiCW5OvaEbjCJLkQb4BoO+PEuTz1mXhdTb1dbQg9vG888= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Em6YVMe7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Em6YVMe7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16272C4CEDF; Sun, 19 Jan 2025 02:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737252324; bh=W7g5mzKYbLZMyqo4vpbvxQf4UQRTdOwmKnBZtmNVrTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Em6YVMe7V2Dh3xrN8RcfFMnOiUyXBWxKvUjAGujqaxbxaM2jXADCBQOWRYAGLxbko PEF/jwfwc+yudk9TfnVaxxTboGutu1sMvjoMmrYejxZTvTuZ69hMdKxkojp7rbmk9q VZvEc5+oyZZs/ELG1QLvm2ryjYoXz6JvjSzFRK+8+GhUTex1/+ey+oF+Vn4Fbq0QZp OsOHCBVuKg3D0h+E7DrkSJ+F8vHKkDjCswI3Afn4Xbl9BvtDqi9dl9wal6lWX2muCM 2JAAfHQ82+ENS5h3dEDxJp46MVDdLtJRYfeXFt36Ul0LWXhYWYapma+EfWrjz8hBZQ NNd2ibWKEKjzg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ap420073@gmail.com, Jakub Kicinski Subject: [PATCH net-next v2 7/7] eth: bnxt: update header sizing defaults Date: Sat, 18 Jan 2025 18:05:17 -0800 Message-ID: <20250119020518.1962249-8-kuba@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250119020518.1962249-1-kuba@kernel.org> References: <20250119020518.1962249-1-kuba@kernel.org> 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 300-400B RPC requests are fairly common. With the current default of 256B HDS threshold bnxt ends up splitting those, lowering PCIe bandwidth efficiency and increasing the number of memory allocation. Increase the HDS threshold to fit 4 buffers in a 4k page. This works out to 640B as the threshold on a typical kernel confing. This change increases the performance for a microbenchmark which receives 400B RPCs and sends empty responses by 4.5%. Admittedly this is just a single benchmark, but 256B works out to just 6 (so 2 more) packets per head page, because shinfo size dominates the headers. Now that we use page pool for the header pages I was also tempted to default rx_copybreak to 0, but in synthetic testing the copybreak size doesn't seem to make much difference. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 19e723493c4e..589a1008601c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4609,8 +4609,13 @@ void bnxt_set_tpa_flags(struct bnxt *bp) static void bnxt_init_ring_params(struct bnxt *bp) { + unsigned int rx_size; + bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK; - bp->dev->cfg->hds_thresh = BNXT_DEFAULT_RX_COPYBREAK; + /* Try to fit 4 chunks into a 4k page */ + rx_size = SZ_1K - + NET_SKB_PAD - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + bp->dev->cfg->hds_thresh = max(BNXT_DEFAULT_RX_COPYBREAK, rx_size); } /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must