From patchwork Wed Dec 18 14:45:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913802 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FD3E156238; Wed, 18 Dec 2024 14:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533218; cv=none; b=SfEVb7cUQPq6FMS0568TJCn1wyhHUZm4oodry76sPVMbcY2UUv1zHVPDq0z/f8MtMBmKvLT12EzbLUia8NqG7VUVh7LCoQQf5rCBW2l3+Z3eCb6jtMhdz4VA3uY0ZdTF349/zlKf44kyPXaDay7mipokAyi8838sON1I7TemjLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533218; c=relaxed/simple; bh=f+k9+rN62m9qDWt394hRkV40mI6z1QMtf2CbQzoW0+o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EmYfBhZ78osHaLUixk4KFa3G10a2S+qK5tPp6ta3yrQsbYTZLUDfb3ftjCV53qQd28TyrRchdNmY6SrV5JYyOEETm9jciuiWuhCgmTZpQ7kP/k10PieLlSFzXsEaVLqnddDvBkgC+WGNL4e/KDRlX6MjwP+F6EmIoaM5JbB2yD4= 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=lXavGO9M; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lXavGO9M" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-725ecc42d43so5640072b3a.3; Wed, 18 Dec 2024 06:46:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533216; x=1735138016; 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=OEKtTmaOJMjBYDbB7DZx12WJWyN2uUzQkj7ulahT+MU=; b=lXavGO9MRL8DbIRRH4UMu3qlNvYNNFGeK3bVYspwO17dtQeWOvdU9h1FedKMDkmJ0D 4ysgp2+2KiPw51P52f/pZhUWt9MLQsWb35S4Q9ncq7rtRgwDyn7nSnu8aL8ZMZi7XOIw 9TVEkugNjSqypHSp54mBozbnproaO5Gx2s4SDFp5iUGeIZ9oaiFyeeDRYZYbAvjOyvyC j3/kCKFNFPb8lP2AKkPWMEYnUKvqWrk4semBCpcYvcgM+XxQG0/Hnyj632+iIqcqOy+y 4T05br6keEXuOGg2Ejv2EJmMm8w5/+abBtuzPV+YFayIggVVWhZfXHw3gaqbV6yN7mBm hDxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533216; x=1735138016; 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=OEKtTmaOJMjBYDbB7DZx12WJWyN2uUzQkj7ulahT+MU=; b=v+qUKJLSxnmpzoUuy4pybTa5Gv9ywT8XgOrzC1DhJgeNLB7F0eGpSHfgJcCWCqNBZd hMZuqpdRQOlp2KbFNXNf9C+I9i+uBS87zTzx1izH3p1flga6Z2gKTvyamllLkGxQ4vZY fnTavutog8t+6Kofugk7fsokO+YBOQWTm9vH06edRdlevKyZRA+jxp84sx5dsVPVIdZi JIXROZyHgCKA+j4yoVRO8fUkBmJIjbrIAcYyVS3ZbZMiL+fsH2FKo8GxvhDBw0E0Ejcy dly0lKcJvGbsB2NPIW1KHAPpN9fBd4B7coAu011qVgHRwBpRfuM/wK58H67eeUIao+Sj YxGQ== X-Forwarded-Encrypted: i=1; AJvYcCUbjTuT3d7UwQqvtSzfiRrg8bmpWEf36SddZtAYNXFCd/exsNqmHQYo4x+6wRqGq/BUmM5Ags7Hyhw=@vger.kernel.org, AJvYcCWrtM8hyWP3LKdu74pdZdr7wJZgFC/31PSC2RC9fh3o9RrP59Fv019FhIaRbs/h+z7tPFKN6fkg@vger.kernel.org X-Gm-Message-State: AOJu0Yw+ZVjOhgWK9xi2a2clpu/IpYQVAsO9TJuFjJtYY5y3XvlS18qS e/qq+EanETyvsROHV15Amv0MBSJM71Uvt1A0HuJCccS7qUdvallJ X-Gm-Gg: ASbGncuv7TqiYcEsdO+8U/kYHqH++WDhOKMip1Wo3YbMRybERcaqoZKc0IHI+AoXVlR ImXEBpTiTcIxjSCWTkmyGam90RdMG6xW8xWXH6jnU+ZpEXLQhyNp4bGmzzLhLBb4QHrCTrBQvFH 8j0obI8V890eF88dgGL7KCXZCFk9khwWiiCKWMbBG6oki3nRIh9McXF2dFrp+9qyJHoAbVwqTCM KRPlr7CuGD0+UsxM1TfH02/cyRMFwy+jlrZEPX1dSAREg== X-Google-Smtp-Source: AGHT+IH8D3ZsHyPk7hmi5ozBRg6R3YCx01W67p64ytXQEMVFh9Rd+01Igp12+BbZVp/TY3zSxoNcHA== X-Received: by 2002:aa7:9316:0:b0:725:df1a:275 with SMTP id d2e1a72fcca58-72a8d2c9c99mr5412619b3a.23.1734533215515; Wed, 18 Dec 2024 06:46:55 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:46:54 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com, Andy Gospodarek Subject: [PATCH net-next v6 1/9] bnxt_en: add support for rx-copybreak ethtool command Date: Wed, 18 Dec 2024 14:45:22 +0000 Message-Id: <20241218144530.2963326-2-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The bnxt_en driver supports rx-copybreak, but it couldn't be set by userspace. Only the default value(256) has worked. This patch makes the bnxt_en driver support following command. `ethtool --set-tunable rx-copybreak ` and `ethtool --get-tunable rx-copybreak`. By this patch, hds_threshol is set to the rx-copybreak value. But it will be set by `ethtool -G eth0 hds-thresh N` in the next patch. Reviewed-by: Brett Creeley Tested-by: Stanislav Fomichev Tested-by: Andy Gospodarek Signed-off-by: Taehee Yoo --- 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 | 49 ++++++++++++++++++- 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b86f980fa7ea..c31894b9187e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -81,7 +81,6 @@ MODULE_DESCRIPTION("Broadcom NetXtreme network driver"); #define BNXT_RX_OFFSET (NET_SKB_PAD + NET_IP_ALIGN) #define BNXT_RX_DMA_OFFSET NET_SKB_PAD -#define BNXT_RX_COPY_THRESH 256 #define BNXT_TX_PUSH_THRESH 164 @@ -1343,13 +1342,13 @@ static struct sk_buff *bnxt_copy_data(struct bnxt_napi *bnapi, u8 *data, if (!skb) return NULL; - dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copy_thresh, + dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copybreak, bp->rx_dir); memcpy(skb->data - NET_IP_ALIGN, data - NET_IP_ALIGN, len + NET_IP_ALIGN); - dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copy_thresh, + dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copybreak, bp->rx_dir); skb_put(skb, len); @@ -1842,7 +1841,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, return NULL; } - if (len <= bp->rx_copy_thresh) { + if (len <= bp->rx_copybreak) { skb = bnxt_copy_skb(bnapi, data_ptr, len, mapping); if (!skb) { bnxt_abort_tpa(cpr, idx, agg_bufs); @@ -2176,7 +2175,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, } } - if (len <= bp->rx_copy_thresh) { + if (len <= bp->rx_copybreak) { if (!xdp_active) skb = bnxt_copy_skb(bnapi, data_ptr, len, dma_addr); else @@ -4601,6 +4600,11 @@ void bnxt_set_tpa_flags(struct bnxt *bp) bp->flags |= BNXT_FLAG_GRO; } +static void bnxt_init_ring_params(struct bnxt *bp) +{ + bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK; +} + /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must * be set on entry. */ @@ -4615,7 +4619,6 @@ void bnxt_set_ring_params(struct bnxt *bp) rx_space = rx_size + ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); - bp->rx_copy_thresh = BNXT_RX_COPY_THRESH; ring_size = bp->rx_ring_size; bp->rx_agg_ring_size = 0; bp->rx_agg_nr_pages = 0; @@ -4660,7 +4663,9 @@ void bnxt_set_ring_params(struct bnxt *bp) ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); } else { - rx_size = SKB_DATA_ALIGN(BNXT_RX_COPY_THRESH + NET_IP_ALIGN); + rx_size = SKB_DATA_ALIGN(max(BNXT_DEFAULT_RX_COPYBREAK, + bp->rx_copybreak) + + NET_IP_ALIGN); rx_space = rx_size + NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); } @@ -6566,16 +6571,14 @@ static int bnxt_hwrm_vnic_set_hds(struct bnxt *bp, struct bnxt_vnic_info *vnic) req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); + req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); - if (BNXT_RX_PAGE_MODE(bp)) { - req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); - } else { + if (!BNXT_RX_PAGE_MODE(bp) && (bp->flags & BNXT_FLAG_AGG_RINGS)) { req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6); req->enables |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_HDS_THRESHOLD_VALID); - req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); - req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); + req->hds_threshold = cpu_to_le16(bp->rx_copybreak); } req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); return hwrm_req_send(bp, req); @@ -16188,6 +16191,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 7df7a2233307..b73de5683063 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; @@ -2342,7 +2345,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 d87681d71106..4cdfff5d531c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -4327,6 +4327,50 @@ 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)) { + bnxt_close_nic(bp, false, false); + bp->rx_copybreak = rx_copybreak; + bnxt_set_ring_params(bp); + bnxt_open_nic(bp, false, false); + } else { + 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, @@ -4777,7 +4821,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; @@ -5350,6 +5395,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 Wed Dec 18 14:45:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913803 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.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 3D27E1ACEA3; Wed, 18 Dec 2024 14:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533226; cv=none; b=odEObKLwGjXuW9ZITHphpL5HQG+Y3uudPTeLTYKcpfzhvo4Jdn5UtOkxywbDNZ5DFXhjcpWWOBuvhDeMOrNVjPG+hz0SQ5O9c4e+6ZkFdr5qL3Nip3nsJ+2ZQWDWsfVKScxLRIIp58/54tQoMwnK0KTQDBE6S4mIQKpEt63P0wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533226; c=relaxed/simple; bh=pJxNJKaUf6zDb1m8+mn4rmuGwT+DvixiSUVm2dZq6eY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FkxQGhVU8r97VWV7ltKKPKOgUfwoCZULjcPEqbjUcA4lkSPMT5eOyjBRBdPoegviGge/zr97tza7stTJJiUt7UqhIRujLwVcyjqYJYcjD8ZD5Z50HmwH8D+DdBzVEyRCWyKFzqyb+mYV4uMzeBg3HuNc9JADG64+kH/Y5cOwpDY= 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=cYyWGnZu; arc=none smtp.client-ip=209.85.210.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="cYyWGnZu" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-725c86bbae7so5750784b3a.3; Wed, 18 Dec 2024 06:47:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533224; x=1735138024; 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=a7Rao6XieC9T0DL79hefU+Cc7jNmFKIhSEFIHF7BW+k=; b=cYyWGnZuqM/Ar6DWwZuTy1G/WNIyJIl5Rz9CeLnQWT+UhClJvCx1/RQ2qqSqZIZjy9 qOFrrMG1Drl0ZDHggXnAoxTiB2+k1ELkqnLdh6NPeDInp6QdBwE+MHUdcMO40qIqtDe4 sBzy1oG1eOKKb9/P/F4HhPIAl82n72L76WKiHrKY2G9r7Q17o3SCknC1tM2lyKqLCTjt a/aoxSCnb/uHq8DSx1FSPsASotJYAEwJBwU+gf9Zd3APudDrDqfphxMj2bHQkSjPFrtS YhyUf6sdb1tV4pmbZHqbV0rdytSpoeU0a7fdqAQkcN3dnAwBowDhVoKf2ZsBXb0L0mod ri/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533224; x=1735138024; 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=a7Rao6XieC9T0DL79hefU+Cc7jNmFKIhSEFIHF7BW+k=; b=iWlImZbXFCEHTawXi0+I2zBbeOpeW0UBYQb9Fc4grynkkaHHAAz90FsWL4BwfRQ01v nli+KNdgWdC2fxYVG2n0E9hFRPHdEqxabdj2XvdyYLwi3bWVZSB8ltnN682Gn8BYFHdy sHuSSpxrToWQZm+TWTEgfL2GXyNxCSYI7refG37oSH7ca4KwEjn703mGAOpwk23vP20Z Jx3Ns0Ey0tCv83hm8EPvNjV0wEw571+gItpAYADhZ2DvGr/lVZmGWBlO2ebdSBCT7iwa SAnk7NW8w0JDSXvKEtX17NCerxSbhMsjD3Kjyu+2JeOxeVjoJ5I9oAo9K6XdxyUG+NcN I0HQ== X-Forwarded-Encrypted: i=1; AJvYcCVZAILSirqJ7MYdU0+TuOQNzylPUnG/cTZM/NFhkd3aJjIFVvkxS3YJ85DzrLBioxMRlVCkj1WL@vger.kernel.org, AJvYcCWV+5DqR0KEoBv6kWlY9Gmm/sc5OXZZA+qLE80QhZ73osPPlyEdThllaH+ozifjS1/p2tW++nfNUFQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxsy53a+ROBkZ24Hva8J8fHBsPi6dicnBPzX8oG6wS/OFXNYlNk GE1zgFiuQsaEG1CtyxwV2Z75RLo3qJVElhqf7kfddiwTXtQiFz3U X-Gm-Gg: ASbGncvXOIvJapIaHWbrvovG9DzWwwF2tqeR0D9JA2QNT6u/+UpR4AB6v1MEmQMdysY JK1TG0+1PWvM0gu1pTWY3nBH4SkGjfjGrglAj6QQi55FMdl5eoMp1lMyCYyK9xrh7ZQ6f9rCpOG xxsni6Cm1tnMU3ToMw6uQRKo1o8pstmNM/3hCSOhWlY1tXjUEqagKIIui3Ps6FVkNDM7maDimes njIGI6MdPM9bLnZaOUbIx2ZSEbeQ6vQMgNxhm033eivgg== X-Google-Smtp-Source: AGHT+IEgWhwAzHgbjw0cJlvPT8gHa6hVp7fjys7VCgaJJLUz0t7KpBnFbrdASwxDvNBV6wqbH+litQ== X-Received: by 2002:a05:6a21:8dc4:b0:1db:9367:d018 with SMTP id adf61e73a8af0-1e5b482c0ebmr5461992637.20.1734533224486; Wed, 18 Dec 2024 06:47:04 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:47:03 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v6 2/9] net: ethtool: add hds_config member in ethtool_netdev_state Date: Wed, 18 Dec 2024 14:45:23 +0000 Message-Id: <20241218144530.2963326-3-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-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 Signed-off-by: Taehee Yoo Reviewed-by: Jakub Kicinski --- v6: - use hds_config instead of using tcp_data_split_mod. v5: - Patch added. include/linux/ethtool.h | 2 ++ net/ethtool/rings.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index f711bfd75c4d..4e451084d58a 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1134,12 +1134,14 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, * @rss_ctx: XArray of custom RSS contexts * @rss_lock: Protects entries in @rss_ctx. May be taken from * within RTNL. + * @hds_config: HDS value from userspace. * @wol_enabled: Wake-on-LAN is enabled * @module_fw_flash_in_progress: Module firmware flashing is in progress. */ struct ethtool_netdev_state { struct xarray rss_ctx; struct mutex rss_lock; + u8 hds_config; unsigned wol_enabled:1; unsigned module_fw_flash_in_progress:1; }; diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index b7865a14fdf8..2e8239a76234 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, @@ -252,6 +253,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 Wed Dec 18 14:45:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913804 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.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 A9D7D1C5CA6; Wed, 18 Dec 2024 14:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533237; cv=none; b=cLwypekEE9Dn7KnH5iIGbF+vY3l/cfOCN2xqjqL7HlnfEfyuGThmvmUVwDNEn/7Zu0kurENtiJBZpi8NtbdmPX+2NJMlhfeByzCXbgQl5wHM4DX4HozoGj61DDGjhDDuNaD6b5DJYEQlsVK2ZWhIsOp8UfvfiY9zsZ+D/+BKfT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533237; c=relaxed/simple; bh=ncUAZaty47n8Ay6yLZhAJXQq01xv2i7JiTci3Bn2Wgw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b2lZmM4sWeJoMmKA6NF4FIN0PO8yRjRSSQSeg8YNFMNfDkmNNXnCtCbWVyXSbo7DxeoUG3wbvVM8vIys+ljYB2hjcOdWYSCN1MEOH4gVtMMYQ1l5lHIadxWGrS32XFz/uBs1+bLoS6IFKOXq6FA8PmL6Dw8VGxQ8oFZdgMZ2GPA= 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=RcZYboal; arc=none smtp.client-ip=209.85.210.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="RcZYboal" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-72764c995e5so4074842b3a.2; Wed, 18 Dec 2024 06:47:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533234; x=1735138034; 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=gWmOq+VV7HWU+gYZvejEzdD6n/9uNGfIfabXSyBFwA0=; b=RcZYboalhUKVoJ3cVDikXO9m+tJHBe2ytuTK7GGpX3o82hr6QEOnHQAjN9yuxyVaxY vv8aDUl9INlsjddQnF+ff4kD2iwuGQwKEZKTPeeZ1xRXBHWS54Kq5/EptGgK1xsjXMd7 R+odD+DZb7bo5XO0I8W5Z0rJ/dM7ezNZSVRuQNsI0Ef5HUhVlpCSRAZtmd2XdCpiCkAa 2Drd31dZyQKtPXE5AipamhueJ581inpZMeXmDu0PN9rFzC/1G+zXVyBhfetmr1WYOU14 qTP0GyH3PLMuE6gMEXnFMMIoQ386kGEAEc9yE9vqGhuqJhTqEKeOlGzQhBOTjZ2RTQW2 1d1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533234; x=1735138034; 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=gWmOq+VV7HWU+gYZvejEzdD6n/9uNGfIfabXSyBFwA0=; b=GZfnIBbE317AVwhxK4DyXhYjHH+4qFVQS1LQKLYnI+5PDJ84EZYbxlpe0uKU3WFLOt 5qitzCTqmaCX/xapuYnXduf3TrQcq1fGBZENd+ZtbuVIwaGhUtfmnDBKidkMnTtgHg9X mfJSAdluHkNw2KgOnTr85KzhefhCdbMzdSeYE/96pL1jh6Xs2LIqk0tVx0g++dhbeA/w U2Dr067AfXzaPqodguVhkoRU2oX0lzR8V+50OMlMqX1rEfLqFXTsff4y6pfUyd6E3WOu fivcOGRoFtXE2KDSSC6dOe/PSFfX1psSnxUaRA0h6J9YIEi6bV1XAGStzoSCJxGia5Yk emcQ== X-Forwarded-Encrypted: i=1; AJvYcCWo2Ubgf6VgEyoU+MQKtma8E2HaqtZAwO3RFszYWDypYPPxZvjGg+I/5zU5phYJuDkWUhMr21A5@vger.kernel.org, AJvYcCWzet7POqNK9XeyycYa73WZETFJIrimLsm05Pume8zmTc6S58w/8LP3hnSDemwzxd/Z3dO+pwR2mPw=@vger.kernel.org X-Gm-Message-State: AOJu0YygztGQJECrtw+TViUJmcNyZuk71fpBvUjOiXGccCIWYzPnWEpK AKxcJ7cjvUcrPnN3OS9yuOq1lBgu3bmcYT+9toxPqMEUybNZkoDb X-Gm-Gg: ASbGncvprrmiGchq5iTJvypWTd0w8c/cRWs2UMs29hjpD95QPMLBWc2/EuHNw8q8nSP uTBl5jZ14r1JFDIn59ku0yZhURwBTPaoRFLnohEMxyHrYE/Wydsh5YHugJNkpyPWwpNpNPFSk22 fX0o787eOMwhwmKUwXWyIdbYZDafI15B36zqNm39l1w7KRYXrnHQNEkp9h++dla4lO0RjooCGg7 UemvbtYXqpYIF0CK6HLJO4uQotyDeOsRqdEcG9xX19DGQ== X-Google-Smtp-Source: AGHT+IEzLX9OyAR+LPjOI5ySVmibuUBZx0cl2zhW6CyHtWam13KWiNzBk+vkF3h9Ncr9eRzzfh8iYg== X-Received: by 2002:a05:6a00:10d0:b0:729:597:4f97 with SMTP id d2e1a72fcca58-72a8d2c43dfmr5589492b3a.20.1734533233720; Wed, 18 Dec 2024 06:47:13 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:47:12 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com, Andy Gospodarek Subject: [PATCH net-next v6 3/9] bnxt_en: add support for tcp-data-split ethtool command Date: Wed, 18 Dec 2024 14:45:24 +0000 Message-Id: <20241218144530.2963326-4-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org NICs that uses bnxt_en driver supports tcp-data-split feature by the name of HDS(header-data-split). But there is no implementation for the HDS to enable by ethtool. Only getting the current HDS status is implemented and The HDS is just automatically enabled only when either LRO, HW-GRO, or JUMBO is enabled. The hds_threshold follows rx-copybreak value. and it was unchangeable. This implements `ethtool -G tcp-data-split ` command option. The value can be and . The value is and one of LRO/GRO/JUMBO is enabled, HDS is automatically enabled and all LRO/GRO/JUMBO are disabled, HDS is automatically disabled. HDS feature relies on the aggregation ring. So, if HDS is enabled, the bnxt_en driver initializes the aggregation ring. This is the reason why BNXT_FLAG_AGG_RINGS contains HDS condition. Tested-by: Stanislav Fomichev Tested-by: Andy Gospodarek Signed-off-by: Taehee Yoo --- 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 | 21 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 ++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c31894b9187e..42ffaa88ae4e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4623,7 +4623,7 @@ void bnxt_set_ring_params(struct bnxt *bp) bp->rx_agg_ring_size = 0; bp->rx_agg_nr_pages = 0; - if (bp->flags & BNXT_FLAG_TPA) + if (bp->flags & BNXT_FLAG_TPA || bp->flags & BNXT_FLAG_HDS) agg_factor = min_t(u32, 4, 65536 / BNXT_RX_PAGE_SIZE); bp->flags &= ~BNXT_FLAG_JUMBO; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index b73de5683063..847dedf61a9e 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 4cdfff5d531c..25eb5931aea9 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -840,16 +840,36 @@ 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; + + hds_config_mod = tcp_data_split != dev->ethtool->hds_config; 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; + if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_DISABLED && hds_config_mod) + return -EOPNOTSUPP; + + 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 -EOPNOTSUPP; + } + 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); @@ -5354,6 +5374,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 Wed Dec 18 14:45:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913805 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.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 A1AE01C173D; Wed, 18 Dec 2024 14:47:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533245; cv=none; b=YR0cLiEo+IKIUURAaSds3Lj2G6d9gVnYLW0u9hoxKMWQKOWgy5k+T1sZjDt82sj4oW62pnk+tX8UZ7UTFavLjhRcXuIV95osYeIv2YRZniHaHRG6yqoHxBRSRcjjDJ3Sal1M4GsR3ae39iLIOIGm0vfe6KYOXQFVzIY4DukQUZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533245; c=relaxed/simple; bh=FS+lNas+EOrbjFcBEwXpZM6GCer2gzrU8ZOQ+WFyrgA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EFBMO3hLQlmPIxrZjg9UK4IhWyaZOKQR0eeUbr/OXdWooV1XL4qdO8eRB/gRYgvs1K2uVhmJAf7mQX/0OpG/F9Q39A5F8RdquMlUsMs93k3vRA4m3ZnyQqvWpXvow3h6AiEGUDt1zN86fwY/ba9qWHJHf1mJqul/z25Pe159EAM= 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=avE+g08m; arc=none smtp.client-ip=209.85.210.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="avE+g08m" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-725ee27e905so8347861b3a.2; Wed, 18 Dec 2024 06:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533243; x=1735138043; 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=mzy83pZIpP8yx5hu8TIVetY5D1C6cozSgWXt8NlzUu4=; b=avE+g08miSfi0xltSQINKwrxhtRbIjSjpQQT/b/bBhAvRMooq8S8VaG15wqB03sqMq WAWclyAEa2Rz3P7l4+MV7TIgAFFYVujVxZnth3Lgk5/labaV/oHtqRuajiyw256GSqyb MbjBYxLoxZGisXMW+DkNnfeCOK7grBUV7kVdyHjC9dQuDRjjRdSIR1fz0ZW41MLOAknC W2vUXHrJJeHx2+cwz3/FyzX27si+U0kmbe3jqEtWD7JxVW+rfoV1f5uVksm4b/6XbAah d+aW3hBCvGAqvjql1NtKORN55q2fbeaLW4t4Ea9/8eRsiLPqxHV2ETfQ8CFNGYWfM0c3 TEdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533243; x=1735138043; 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=mzy83pZIpP8yx5hu8TIVetY5D1C6cozSgWXt8NlzUu4=; b=swSQTBmfIdV0cp3NeYt+tRNX9jDNADx9hxmIVSDfVbpN1aeB7dlzh37WTywzEiMXjB e1PEz09NPFJ6P4EjAUCTHEg3OZyNL8evt4rqyXQgQ8dYOLBZc5Z9Hoq0oV4HOkTVbkLT bnIO4DEPA7KsLh3ZyxSZnU0Ne/JSnjomOstvPyULQo3YHVGGTLntynK64bcgwPxf2wxv 8g7dyqDvnBCO/OlWPMxjhNjEKylzwaP8Z8CVvzaIH0UPs52+9P+Q/0cQRytiJSz3Md3s 9jjduo6cXkCHvuD6+1VuyvfD7CPZqLUkap0aUnKvf4WDE72kLfvV+z4Yz9NZ3WLffDyx jIYA== X-Forwarded-Encrypted: i=1; AJvYcCVEL7MfPR0VVJqY+FbIT4IlSKLHiZs8Z2rcnkXEFefEWej7Kc9yJfxofYErZWQaNl6aJ88ivf07v0A=@vger.kernel.org, AJvYcCXNVBP5DOjJ8gUqIQqvIiii34ERyxma4qetNYMA5JFqrwX/EaOqXOqjN4P5duiLGgROwEjtYwXn@vger.kernel.org X-Gm-Message-State: AOJu0YzsUAzWqa7j/lNWrYXYm1tli4lMQI9yeunTJn0vTAC8vxHM1cID Cb54PP8UNfvGcoyhsJt7FbSoex/xlWmWZ/cXfxARsQiTLf9pL2T+7MRsy0Ds X-Gm-Gg: ASbGncsUDNmL+ULLmGuql1THbrjSq8CZfWnni7e57ekVGAwB6hfaJqQCXb4cggIu2rE sO7hHedb/gnexaxyRVVlRjjcwSw3LCEdmvHGSNwDZqwZlH6zWy0LcEJRL5r4W1PQ4/tAxSeYXhH 9Tq1e5aLfURRmvEVG22iXXGvGa2kvK5o5/r1j18dmC+nb5rztL4pAEZjtveH3QIFU1uVZp67Gos 8eN9MZiFw8EEYcHovZ5RGdKh8iI1nX1MTkswSJp5QryEw== X-Google-Smtp-Source: AGHT+IFilaLYKslxYyvg2+W9Nrrb3x3dcN5KKyr4AvoP0nlYnxLCEHm5XCZo354MMqXBqSG0mPPMfw== X-Received: by 2002:a05:6a20:a109:b0:1d9:c753:6bad with SMTP id adf61e73a8af0-1e5b47fc77emr5933834637.10.1734533242777; Wed, 18 Dec 2024 06:47:22 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:47:22 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v6 4/9] net: ethtool: add support for configuring hds-thresh Date: Wed, 18 Dec 2024 14:45:25 +0000 Message-Id: <20241218144530.2963326-5-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-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 --- 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 | 6 +++ include/linux/netdevice.h | 1 + .../uapi/linux/ethtool_netlink_generated.h | 2 + net/core/dev.c | 13 ++++++ net/ethtool/netlink.h | 2 +- net/ethtool/rings.c | 40 +++++++++++++++++-- 8 files changed, 78 insertions(+), 4 deletions(-) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 60f85fbf4156..66be04013048 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -332,6 +332,12 @@ attribute-sets: - name: tx-push-buf-len-max type: u32 + - + name: hds-thresh + type: u32 + - + name: hds-thresh-max + type: u32 - name: mm-stat @@ -1777,6 +1783,8 @@ operations: - rx-push - tx-push-buf-len - tx-push-buf-len-max + - hds-thresh + - hds-thresh-max dump: *ring-get-op - name: rings-set diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index a7ba6368a4d5..ef1d1750f960 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -899,6 +899,10 @@ Kernel response contents: ``ETHTOOL_A_RINGS_RX_PUSH`` u8 flag of RX Push mode ``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN`` u32 size of TX push buffer ``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX`` u32 max size of TX push buffer + ``ETHTOOL_A_RINGS_HDS_THRESH`` u32 threshold of + header / data split + ``ETHTOOL_A_RINGS_HDS_THRESH_MAX`` u32 max threshold of + header / data split ======================================= ====== =========================== ``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` indicates whether the device is usable with @@ -941,10 +945,12 @@ Request contents: ``ETHTOOL_A_RINGS_RX_JUMBO`` u32 size of RX jumbo ring ``ETHTOOL_A_RINGS_TX`` u32 size of TX ring ``ETHTOOL_A_RINGS_RX_BUF_LEN`` u32 size of buffers on the ring + ``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` u8 TCP header / data split ``ETHTOOL_A_RINGS_CQE_SIZE`` u32 Size of TX/RX CQE ``ETHTOOL_A_RINGS_TX_PUSH`` u8 flag of TX Push mode ``ETHTOOL_A_RINGS_RX_PUSH`` u8 flag of RX Push mode ``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN`` u32 size of TX push buffer + ``ETHTOOL_A_RINGS_HDS_THRESH`` u32 threshold of header / data split ==================================== ====== =========================== Kernel checks that requested ring sizes do not exceed limits reported by @@ -961,6 +967,10 @@ A bigger CQE can have more receive buffer pointers, and in turn the NIC can transfer a bigger frame from wire. Based on the NIC hardware, the overall completion queue size can be adjusted in the driver if CQE size is modified. +``ETHTOOL_A_RINGS_HDS_THRESH`` specifies the threshold value of +header / data split feature. If a received packet size is larger than this +threshold value, header and data will be split. + CHANNELS_GET ============ diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 4e451084d58a..4f407ce9eed1 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -78,6 +78,8 @@ enum { * @cqe_size: Size of TX/RX completion queue event * @tx_push_buf_len: Size of TX push buffer * @tx_push_buf_max_len: Maximum allowed size of TX push buffer + * @hds_thresh: Threshold value of header-data-split-thresh + * @hds_thresh_max: Maximum allowed threshold of header-data-split-thresh */ struct kernel_ethtool_ringparam { u32 rx_buf_len; @@ -87,6 +89,8 @@ struct kernel_ethtool_ringparam { u32 cqe_size; u32 tx_push_buf_len; u32 tx_push_buf_max_len; + u32 hds_thresh; + u32 hds_thresh_max; }; /** @@ -97,6 +101,7 @@ struct kernel_ethtool_ringparam { * @ETHTOOL_RING_USE_RX_PUSH: capture for setting rx_push * @ETHTOOL_RING_USE_TX_PUSH_BUF_LEN: capture for setting tx_push_buf_len * @ETHTOOL_RING_USE_TCP_DATA_SPLIT: capture for setting tcp_data_split + * @ETHTOOL_RING_USE_HDS_THRS: capture for setting header-data-split-thresh */ enum ethtool_supported_ring_param { ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0), @@ -105,6 +110,7 @@ enum ethtool_supported_ring_param { ETHTOOL_RING_USE_RX_PUSH = BIT(3), ETHTOOL_RING_USE_TX_PUSH_BUF_LEN = BIT(4), ETHTOOL_RING_USE_TCP_DATA_SPLIT = BIT(5), + ETHTOOL_RING_USE_HDS_THRS = BIT(6), }; #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 2593019ad5b1..b18f249826c5 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4083,6 +4083,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); +u8 dev_xdp_sb_prog_count(struct net_device *dev); int dev_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf); u32 dev_xdp_prog_id(struct net_device *dev, enum bpf_xdp_mode mode); 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/core/dev.c b/net/core/dev.c index c7f3dea3e0eb..6a68db95de76 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9480,6 +9480,19 @@ 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; +} +EXPORT_SYMBOL_GPL(dev_xdp_sb_prog_count); + int dev_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf) { if (!dev->netdev_ops->ndo_bpf) diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 0a09298fff92..c523b763efa3 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -456,7 +456,7 @@ extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANT extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1]; extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_FLAGS + 1]; extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_HEADER + 1]; -extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX + 1]; +extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_HDS_THRESH_MAX + 1]; extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEADER + 1]; extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1]; extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1]; diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index 2e8239a76234..c0cb9b2c6616 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, @@ -196,14 +212,16 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) struct kernel_ethtool_ringparam kernel_ringparam = {}; struct ethtool_ringparam ringparam = {}; struct net_device *dev = req_info->dev; + u8 old_hds_config, hds_config_mod; struct nlattr **tb = info->attrs; const struct nlattr *err_attr; bool mod = false; int ret; + old_hds_config = dev->ethtool->hds_config; 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 = old_hds_config; ethnl_update_u32(&ringparam.rx_pending, tb[ETHTOOL_A_RINGS_RX], &mod); ethnl_update_u32(&ringparam.rx_mini_pending, @@ -223,9 +241,25 @@ 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; + hds_config_mod = old_hds_config != kernel_ringparam.tcp_data_split; + if (kernel_ringparam.tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + hds_config_mod && dev_xdp_sb_prog_count(dev)) { + NL_SET_ERR_MSG(info->extack, + "tcp-data-split can not be enabled with single buffer XDP"); + return -EINVAL; + } + + if (kernel_ringparam.hds_thresh > kernel_ringparam.hds_thresh_max) { + NL_SET_BAD_ATTR(info->extack, + tb[ETHTOOL_A_RINGS_HDS_THRESH_MAX]); + return -ERANGE; + } + /* ensure new ring parameters are within limits */ if (ringparam.rx_pending > ringparam.rx_max_pending) err_attr = tb[ETHTOOL_A_RINGS_RX]; From patchwork Wed Dec 18 14:45:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913806 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.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 CA5251C173D; Wed, 18 Dec 2024 14:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533254; cv=none; b=qN6DWG9sTGRDULQxv6KDU44B//4k7Tiu+7YPIEAH1sqndGvxkIMNGd/RfOLQ8Li1ZtUBoMmoRfKJBZ/1hPXc+RXJ8TIV989CjoxbYHNVnEP7VykJXSmYKNak2Jaa+uiRR1qnZqdTCX9/Xbl7uWuR7z8YJwknV7v5p+71GaXj/Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533254; c=relaxed/simple; bh=8YM8iAR9+QKCqaHmSP6TVLMsr/5O5UQQs+bBLc15YCo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cT3EXvycjTySwu6evRr2fUL9Ib7SKBMxprS5IF34ky6h8CXqa6yv5jZSIVURzvwld5n4sOhvOXpz6DDD3LtitjA30Pa9KB/+fRGjuZKy8d/RamSbwqT7x4nN4DxLbvBjxGPTdIr3PFNBGiDmUw9pAVqeglaAxqyj5fWaxYqZZ9o= 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=DnLDRKS7; arc=none smtp.client-ip=209.85.210.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="DnLDRKS7" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-725c86bbae7so5751819b3a.3; Wed, 18 Dec 2024 06:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533252; x=1735138052; 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=LLj75mm4bSKqr3MH7QwBOZtnbqJWJgdC12woJpde5Ko=; b=DnLDRKS7c7JmEp+n10Su5TOKKH6iwAKC/yTTPoMldd2d45LSKKY9V9oDDv9c0pYgPB mh+hnw9Sdy+eqRh/ecrrn/KkyIHgStnhl3RJn6pA++VjglCcIYmknByrTBhnmuhD0T2G wT2ZyWsRzYF5QzIN13zc/EEzeg8gxCCHgbLsBD2fbu/Ip+IfyM2I96yK6zLmofRv4sNj F0a/Qaun1KoJHLlDltc2dOQpWE+kQJxFEE7tH5wh1MvL/3VJV0RDaY24ykYEkF+4Lkgj EMW9mgj3+6Z6URvLxTD3/tTx3JtWoCvLdJcu6G1hUSi1eo/z7q0MXh2inAFVUMVArk1/ N81g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533252; x=1735138052; 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=LLj75mm4bSKqr3MH7QwBOZtnbqJWJgdC12woJpde5Ko=; b=qjpkAAtJodOEw7Ou1p+XsU8FW5LmMRuFr8QwK4t3RKfOTtDmpVm24sNkX0rPpWcnHd ht7uBXixmHblrGNdSdQ02Ossqd5Hs5L4GfYG661memKqt2agbzkgbid5wR7Gk41k18VJ JB0JK9zzWxNBUUdVK+JHvVzughy3pprHXqjZ5RtrGX69TkMgltdnkhvts9tt6nWNOeMz 7ZTHN6y1AlBGMFbg7tFvnm4SPl/yHmlgsCAUtE8D9oktwL3I4e0uRgY1YbxqqB++odgW m2rgSZQ5ebFac1J1fXVwhdX4bbTDflilkoTeJqrdG7XRVpSNx/VWj9jDk85ahhu7XHTd yaig== X-Forwarded-Encrypted: i=1; AJvYcCX8h4u1n7cIdYUh1eDIHC9++HZeDNnnZ6ezgMfB9LTGjNrjdRN4lSC8liaIBQN5TeKYt0N5QPic@vger.kernel.org, AJvYcCXxxLVYFHofhdnNBDpkuiaB7NVchjyVCWtPwsRswL49jCZmS2vR7uPCPkX7GPNNx5eOKb+aNaOgg4Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yza0+ZeCDEuxjjr5KRP+fzrZ+QP5BI0uL0OMRhMFLWmv0xEgFb4 VVM+9NNgDVU5ZFAMEwL9wJ9tEjsn9N5EiEekScRZ0oHMuwMmB5Gx X-Gm-Gg: ASbGncvKKETEiQ8q/1ki1mTgaPn/AuQ4HabBHaeIKsY2zoVgcLuWJznYkpLg+72WqAg XBRCapnlhBGpbW9TvvKHaKWXg9gkQMBU9mBKDnm35Vao9HkwUEE8JVvHRpkUux+bYP6GtLipCUj BQ/GPp+C5iLRbjzfn1e3QTZlX7JuYQ23Jy9i/nh4SR4kgvEAMIHRNDP1M6lvB1l3B4/mOYmKh4l IGp84o/Od2FpgEO+4c3b6BQp7xTP/c4ZRFDCBkFBONOyw== X-Google-Smtp-Source: AGHT+IElePXpmfejI03ZVIWyz9L2q0s4RbYiYRe/U6V82PBPiG2lMdcaZEcz6bgPESNScSXKgZftDw== X-Received: by 2002:a05:6a00:3905:b0:725:9f02:489a with SMTP id d2e1a72fcca58-72a8d2c4061mr4177044b3a.17.1734533251933; Wed, 18 Dec 2024 06:47:31 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:47:31 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com, Andy Gospodarek Subject: [PATCH net-next v6 5/9] bnxt_en: add support for hds-thresh ethtool command Date: Wed, 18 Dec 2024 14:45:26 +0000 Message-Id: <20241218144530.2963326-6-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-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 --- 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 | 3 ++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 7 ++++++- 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 42ffaa88ae4e..5b16b2ef7739 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4603,6 +4603,7 @@ void bnxt_set_tpa_flags(struct bnxt *bp) static void bnxt_init_ring_params(struct bnxt *bp) { bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK; + bp->hds_threshold = BNXT_DEFAULT_RX_COPYBREAK; } /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must @@ -6578,7 +6579,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(bp->hds_threshold); } 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 847dedf61a9e..8fc4d630ee21 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2404,6 +2404,8 @@ struct bnxt { u8 q_ids[BNXT_MAX_QUEUE]; u8 max_q; u8 num_tc; +#define BNXT_HDS_THRESHOLD_MAX 1023 + u16 hds_threshold; unsigned int current_interval; #define BNXT_TIMER_INTERVAL HZ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 25eb5931aea9..921e7e8333e8 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 = bp->hds_threshold; + kernel_ering->hds_thresh_max = BNXT_HDS_THRESHOLD_MAX; } static int bnxt_set_ringparam(struct net_device *dev, @@ -870,6 +873,7 @@ static int bnxt_set_ringparam(struct net_device *dev, bp->flags &= ~BNXT_FLAG_HDS; } + bp->hds_threshold = (u16)kernel_ering->hds_thresh; bp->rx_ring_size = ering->rx_pending; bp->tx_ring_size = ering->tx_pending; bnxt_set_ring_params(bp); @@ -5374,7 +5378,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 Wed Dec 18 14:45:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913807 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 9072C1B424F; Wed, 18 Dec 2024 14:47:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533264; cv=none; b=p9fy21BJ11gx9Io6t+S62L6cR5n5UYkm4Nc6eOzvjiCA4zovFaLt4elskzkMRJW51lyPO8TLtbdncLxL8PRuxFLEx38wemm/H+MP9o3z+cqQNNtLrPHpzg1+qIF57pJooW1okTW60wwUpXg+8qw6VAXO3CdTE+weW2AHTgDIV7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533264; c=relaxed/simple; bh=4KGVBkIWRaTQHDZJ5D/V9ALbjqrOWO3X+FCc3ryqTzo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ahedhQCXQRoxyrazjwDjOVxqEluIfn965tDHb8+R6Jh2zZWDhUNAgZxWfa3XgFlOlZq1iKSJZOLK+pC+QJBEgXZgS4llhw9ZSJowTSDhOHDIAx1AZs/LFuYMXMtmOTj0wjCvQHJ8WKrCEdfN7aGw9d6xmHjJRZWqfYoHwQtr328= 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=C5w3YLXr; arc=none smtp.client-ip=209.85.210.170 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="C5w3YLXr" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-725ed193c9eso5729823b3a.1; Wed, 18 Dec 2024 06:47:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533262; x=1735138062; 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=Ub+N7PT2tMSkMSRd6T83pMsYqZ9p0Qa3rI1yYhkjFyw=; b=C5w3YLXrIvccE/8kdowaB2Uc45Y6YUaKsHnSqgFMdHYBbeMSDqINCVYeTxoGp2mZwb ttXiqIa8ehVAMVVsJCCf0EYycFrE2zCK86zNBoy1P9qwQYopZgKCB07D625EDTzMHxnt 2xk06TbSYZb9B0pqbj3qpvYT/6wtVTqfbx7RW2kitWZ+Gf0EZw1gEnO17WjAUsxcPuG7 xw/HkN+qzmnLrXbgVisMwN7+2sg2fHPKHhGNMYfBVPbYIexKjnBSB1QCDn8J/BpA2Xzg BZ6PNogTOW/ZqSlrWWYiqZAra4/23O+1NpqjocPwU2iDCITgDeRUFW8cWlpPXpMNMfP5 ZK8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533262; x=1735138062; 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=Ub+N7PT2tMSkMSRd6T83pMsYqZ9p0Qa3rI1yYhkjFyw=; b=JPLb6J3oc0Kt/Q5AZnuxXyjlOFMlIWctsIQ7ZsFmBztIcKiOfnd/e8abNjoU/s7bbR nXX3W0ZM3RYZ3Co6XbY0aPuBd/tg6s8Zj5JE9c+hAm31CvvVsu2+FPhkpK1fPIdLj5aF bHZ10rYGO58tH2L3Khm95L+22LG13z6o4NV7TQySY1/zmshEVtamhsK7z9gzsashH2zj zgvBidzoICy3ABir5Ajy4YoJVSfeELVrwE5VgKf+eSPJfAToCQhjC1b+fBJ9B0WotFNQ qqvMK24yoj4hpiHM+kTwAk0snn4b6T5nOXIzaojl7LeL7OrZqd5+hh0e+od88ZXwtwsY xBmw== X-Forwarded-Encrypted: i=1; AJvYcCUOEc/Kn94WGhw3pfdas3o8N8IBrKoWWyiU7k55H01/CpXCnDNx+Cn4gIFQzrZN/kfbOZ+JhUC+1ew=@vger.kernel.org, AJvYcCWy+1sghtxi1RjeCkgTO0ohGt2yqFmcJpyieDvfZyDnT2GPwqc66gk6IUNtxea25fRThObl+YiI@vger.kernel.org X-Gm-Message-State: AOJu0YxJbcXErE+HWwEl34aR7ylrSKC7cfTG1JO6iakb3ETJG+Z4rVAr hlZHQ23LjxWayhweGbWHxGwy+AmUqh9uGEftzDfghNmBNtERJTH2 X-Gm-Gg: ASbGncuJ0R4sS2OMd2K7oEDkAqWPv0fx9jpPt5e6ry+o039XhfU7dXGF6JTlgi8VWzv NUUk/4ZRDoUks0aHIcewdLOpkl9+hwSpG15pLmAQXmDiY5JMtNJzphdLUEKECipp0smqvWZrhsk VQUaDjlzjAZq6sHI4LyH0r048FWSqIhITBTYkYhOjWs0CBP7JcfUX1aAfKen8bo8zSVpxLqCuVg +5DiwQa3FatbhP3d4NI5fOl2LWLEb1HSA1LujiRFFhalQ== X-Google-Smtp-Source: AGHT+IG93HkJwM5dTZdC0kSuopm9Ai516tdFxpFnjpj9D2ML0ohkTRBi9Nagwv/xn2SFvoH+eFoR0g== X-Received: by 2002:a05:6a20:840f:b0:1e1:a693:d623 with SMTP id adf61e73a8af0-1e5b4824bb1mr4998885637.25.1734533260887; Wed, 18 Dec 2024 06:47:40 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:47:40 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v6 6/9] net: devmem: add ring parameter filtering Date: Wed, 18 Dec 2024 14:45:27 +0000 Message-Id: <20241218144530.2963326-7-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-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 --- 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/net/core/devmem.c b/net/core/devmem.c index 0b6ed7525b22..a29333af3ebd 100644 --- a/net/core/devmem.c +++ b/net/core/devmem.c @@ -8,6 +8,8 @@ */ #include +#include +#include #include #include #include @@ -131,6 +133,8 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx, struct net_devmem_dmabuf_binding *binding, struct netlink_ext_ack *extack) { + struct kernel_ethtool_ringparam kernel_ringparam = {}; + struct ethtool_ringparam ringparam = {}; struct netdev_rx_queue *rxq; u32 xa_idx; int err; @@ -140,6 +144,21 @@ 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_ops->get_ringparam) + return -EOPNOTSUPP; + + dev->ethtool_ops->get_ringparam(dev, &ringparam, &kernel_ringparam, + extack); + if (kernel_ringparam.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 Wed Dec 18 14:45:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913808 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 C7EA01BEF6A; Wed, 18 Dec 2024 14:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533272; cv=none; b=dLbeKbn4NARGIJIUIwdUNTrEOg9udQVwecGduNIsU7K+hjxLDmfjeXQLlv2gDxebpGCOpsFcA3c38ngfkyNoHYQmfANejV1CZl5P+9ulAKdV1IHPtokkX4McDPmMq4W+n+yiQHojzYmWY904kRG/IYfQh3Rm1/tUuxVgqZnyWJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533272; c=relaxed/simple; bh=GvYSFAiBsuk144oZpVaErUQ3PhXmKtvGBNNKqtNPRr8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XC0K86c+ZAvfCLBWqJ8La1FDpncUd1xbVQHDDHRvacH5m96f4i5xnEPQx3Vifvi3Iazno0XUUB3zFdi/b08LNoyqqu9qhntMQJEVGbc2irHrOU8yGCGFEskEtq3bvzAaXdsW6VBSwkByACSjtUyE5c3MxJsynz7WRNqb0HhVfGU= 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=kBID1MbL; arc=none smtp.client-ip=209.85.210.171 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="kBID1MbL" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-728f28744c5so6186568b3a.1; Wed, 18 Dec 2024 06:47:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533270; x=1735138070; 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=Mc7vxr1AV6y7PlaTyBTbDeICZHlLupBm5PfolrJFBic=; b=kBID1MbLueuBxfRY5c//7lXi/yRpsJd6rx8Up4lXw8ePzF4WLngM+rShkoWUcVbI/U 2LuOaucZgsRxw46gxVQpGt5/F0/LeXibuhqrMcsrNVppaZssrV4LrxEqcyuB4Pzm1R7G zpFlWIMWNaSns9sJWwONrXmq8tuuwLnGWWPpVlzz0GUjAcB/Ik9tJi1W01Ka4lfLVzYU H4CpwLs3bNfS3ZF918hAnMWKKfrwV/2wx/QLlOw+zd2+3y8ZmhXCoyTRtMkq67LvTrB8 39brtJ0ZgDHUlTEw8XaLTy5zdIoNZFzZ7tWxwKfNRA2eaDvM/ePKbo2eLHu4rO0uL9LC ghiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533270; x=1735138070; 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=Mc7vxr1AV6y7PlaTyBTbDeICZHlLupBm5PfolrJFBic=; b=Vxuw8T40nhJdKjYQOk+1u31wsuzzyImtP1eWPNRX4Fd5jgy6rkbAysMCl4L0iE+d7L XMLtvQ4gzxN6hlaO9mk9uB/K/JU+b0ZeUkhgzxAybA3rJ177E51i4Vb2DEDrVaXBMxgz 5pPz+ec6FMw9lWN3PQ6tH91UDp/zaYEesf5VpmxxAzuUBa+HRHBdP4kL/pJbXRB3otOe ydzfBJwsaD9UB2kA6HdMLS4QwnGgvrgnrIPMv3cGGk2CFRqBA8yc/T48Fh4jq+zcRgoX TMe91ELFkS00JmEuPKu61O5jnuclB23++D58xF3RSYB4DipOssosxVxkYSR9upafqq2s a06A== X-Forwarded-Encrypted: i=1; AJvYcCUbi++tFBriIS3aZ8EL1EJkWI2+8S68j9tqXmFdLBR6QxCi8YfAV4YStdz6V62UnARfN6GcK2hUmxA=@vger.kernel.org, AJvYcCWPe++VDHc3lAtev/m8QAOsVkpE3HoK6aGyH5IqbeFtgsO+5URoJOTY18seSWw8BSlbGFCQWxiy@vger.kernel.org X-Gm-Message-State: AOJu0Yx3iCJQUy+AzXjgdYcHbhlt6HfcXKufe/b2JOI6T4zriEqPU8MX pq+kPt4aWMv9uoYy49RpuKOcJ2rFsyD5rJr/I8uFTrTjge6Gpx9N X-Gm-Gg: ASbGnct9RHFQLLaHrULAcufigvDoZYtKcXR5GhfzDvM/rESHJS+YLf9WJp8rKpGCIsB YsPA2OwHazqoB+kNBemB46CODXXL0ObRivj9FeJykCHOME9VCouH+Hq3ypgT4mBlmcv4AtmXjdX VHPzcA3VXtX/w0vc/Vviy4NXieP8x/UrtCfUC6ZhhBI7dVJ8d3kAxL8SzCABfKsURBcIltJn3Q8 TZu72fdkdCoqoK7dmSNq0wYzLIyJsrDag6L+KvbfYlbsw== X-Google-Smtp-Source: AGHT+IGMU5TjK6pU5rW9tocNan+1bR7pjB0aDl/HnzMg82xZ2wXzaaz/UOtnCOhLeKCbuX/XbrLXGw== X-Received: by 2002:a05:6a00:3a02:b0:724:e75b:22d1 with SMTP id d2e1a72fcca58-72a8d2c407bmr3668626b3a.16.1734533269912; Wed, 18 Dec 2024 06:47:49 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:47:49 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v6 7/9] net: ethtool: add ring parameter filtering Date: Wed, 18 Dec 2024 14:45:28 +0000 Message-Id: <20241218144530.2963326-8-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org While the devmem is running, the tcp-data-split and hds-thresh configuration should not be changed. If user tries to change tcp-data-split and threshold value while the devmem is running, it fails and shows extack message. Tested-by: Stanislav Fomichev Reviewed-by: Mina Almasry Signed-off-by: Taehee Yoo --- v6: - No changes. v5: - Change extack message. - 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 c0cb9b2c6616..284ca34a3b41 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -260,6 +260,19 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) return -ERANGE; } + 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 Wed Dec 18 14:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913809 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.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 7E6511B4254; Wed, 18 Dec 2024 14:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533280; cv=none; b=RWgMAdILZQW1CnahCGbqZZju7n1CUsl3EknRvmJw+lqd8X5KRQWJRwYYXIkaVGFtrf16rZ8B/PiVGWbcNHAkypVVsXI3VxL2XimcPizaLZ6rW8TESqVEhc5H5mCpFlA8qvUzfbd0Ur+Rm/92Ujzh/GCKIaiMeIluAKhv1/mDxbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533280; c=relaxed/simple; bh=ZUp/096lTgig11kq8/t25MhHSZxNhpH7JNs1XQQouy0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ShUmyPYlfxJCMDse+eLUHyO4Eq5aCHT6db+dlHqf7kH2ItsWrA1I2SJTfRy9lhhqh8XVpHb8frXJRT7K9LVoq+X5l1bihPqTPHGbaQN8ECAsRsW8XqK9zXMw8UzI7DrBnF1XsWj5arc6zva4Bl8BmKSObRH7cH4z86xz3O6mWgM= 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=GIxv5iET; arc=none smtp.client-ip=209.85.210.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="GIxv5iET" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-728e729562fso5728876b3a.0; Wed, 18 Dec 2024 06:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533279; x=1735138079; 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=n+eemS5JfDPM0T4Ra5TmhFfyQp7rmHYSEkGxE4hfA2Y=; b=GIxv5iETGh5SyfWbhh2JjlYFwNX3ASPSEYtS3wDW6M7VWBpiDI5uInCppmptPxv1yI FRUEvVQGt9sDyY+gKGjk0nz4Fvz8NA0R3a8ZF/XRU4LziNDn9IiE49V0kzuMo/lztsxQ 1LVaF1nH95JhO8868F4304m4YoVTObYI4T8xd0IitaXT1hnZpmbRgLp1Zp4Ry6cwIdYS bPh0Q7h1T1fHc/KD/mredfCKuj1+ZN19FV5FlKoMK2sewaxCD/Ljo3ztOVfJtxdtV+ZR endhYEflourTmW7weLdG/g+vyNumsonvx8mvKYCxdwl9UigkKNZCIkqCncr7p6/2PENg 26Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533279; x=1735138079; 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=n+eemS5JfDPM0T4Ra5TmhFfyQp7rmHYSEkGxE4hfA2Y=; b=M5XvDYGu0HMY8ze9x2TzP3ngndGYHefrgF0DUx5//SuZeTMMruwsaAP/9poeOnA99i Qa/KTmFEF/FJEM46FqUB4RLoJFdVbKbsTQun5Cg9uM9Ymay8Z25xYQCPt23NeSyAVwOK YBkYDSsZdHiLpLxjtu5OosgiQgx9cJFOuMODWUu/mWtiR6YKAgg0rTzcseNQp7NIgHdj v8yaTtJ6bNfn4fiGtvF6amd3G4ZGyg7k98k9P8fJDDcqqvm1dQHZSSsc2/s5b6Hs++3K hgJuNyN+IxFYHY9V3NyWxA75BS6xIe/4wt+n5Bv7T06opoRMQW5bRZwN3rtg7K00zI2K tZ4A== X-Forwarded-Encrypted: i=1; AJvYcCU3YrT0YHzaTmDvnOfipHz1xnFJiNcPUXgz9KtClFB9JJFP76rPZwSQgQH+tSPzMIKs5wKYwxtx@vger.kernel.org, AJvYcCVHL1SKuPKM33gW4q4FON3gBpMPRVGcCvCXVtZRPAH3wi9d2RpcHV2hcHVJLyi7vqFt/ugIr5Epv3k=@vger.kernel.org X-Gm-Message-State: AOJu0YxWjYK4qzW8Wbg2phofGY/QKv+eXI6mXt6J5+PAhFFP68j/N97D bXjPv5bRPmP+mm/3QA/zEb6PAlso7NzSkEgfol38xevpGx6pq44o X-Gm-Gg: ASbGncuwcucC1OCoKI20BjWwwmgW44w29UtKYB8L0AoeC8EOmKFnh3yz72jjgfBaJFI MxQc4WLZkgQVPS6ERRVNeMGmvXNwoIHasDlEmhbslMd13dUwC+/V8/ls4GfQfSSFbGGC4jOCLfm 9cWTIQK6P2T7dZtDBkZUel828Ar2f6tnMe3C3ovR0TspTEqlj0oJqMSanF8yeYziGeWyn8MNCUA 3h4TISc/IvIW/5u/SnFA7zrC946YpL3zmc4tr7xOBNj6Q== X-Google-Smtp-Source: AGHT+IF6K0WlvzNDshTqQDZGpH5CId8EN4ZA8pxBcCsQ1VfNQm1y/wpesZcxgO0oeIZC8FUg9c0qeQ== X-Received: by 2002:a05:6a21:6f87:b0:1e1:af70:a30b with SMTP id adf61e73a8af0-1e5b487d79emr5685913637.34.1734533278967; Wed, 18 Dec 2024 06:47:58 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:47:58 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v6 8/9] net: disallow setup single buffer XDP when tcp-data-split is enabled. Date: Wed, 18 Dec 2024 14:45:29 +0000 Message-Id: <20241218144530.2963326-9-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org When a single buffer XDP is attached, NIC should guarantee only single page packets will be received. tcp-data-split feature splits packets into header and payload. single buffer XDP can't handle it properly. So attaching single buffer XDP should be disallowed when tcp-data-split is enabled. Signed-off-by: Taehee Yoo --- v6: - Patch added. net/core/dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index 6a68db95de76..da4a34bfb675 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -92,6 +92,7 @@ #include #include #include +#include #include #include #include @@ -9498,6 +9499,15 @@ 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->command == XDP_SETUP_PROG_HW) && + 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; @@ -9535,6 +9545,12 @@ static int dev_xdp_install(struct net_device *dev, enum bpf_xdp_mode mode, struct netdev_bpf xdp; int err; + if (dev->ethtool->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + prog && !prog->aux->xdp_has_frags) { + NL_SET_ERR_MSG(extack, "unable to install XDP to device using tcp-data-split"); + return -EBUSY; + } + if (dev_get_min_mp_channel_count(dev)) { NL_SET_ERR_MSG(extack, "unable to install XDP to device using memory provider"); return -EBUSY; From patchwork Wed Dec 18 14:45:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13913810 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A81471BEF6A; Wed, 18 Dec 2024 14:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533290; cv=none; b=E1jk1PM6IOtlLGe9CqQdaGhMBojTzRNG3gPghzR+ymRZSQxQihqODWq6q7Qq44Mptz+p36PZawxJDixrAXvDfxLq/vbi0ywkC97qtUeyWmr1PboBS4iEIVnI1YojxIGN+N8EazgJq7p+W/KlwxwyMJWYi+HRUlIb/I93XxwZ4ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533290; c=relaxed/simple; bh=9MtPKvDbTgpNdhT7mukCeICHI6xk+SR1837zdhmJ83I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XFnBqRjEsVGyuQhtyI9UYcxJu4QjCiUM1T5MOAFXlFdMoZQ00F+uGki+Bnpdqf2hu6/pMFiRol+QA1XvupJWd8Cefg79p6RlV/LYCyzv3YX4xJeYOb80KBwNGEl/3OT9YxN7xu/xQec2LsNR3TRYsgV3VqmDOUIjf/2x/OGzDlk= 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=Cmrw0sgg; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Cmrw0sgg" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-728ea1573c0so5804547b3a.0; Wed, 18 Dec 2024 06:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734533288; x=1735138088; 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=nurHWzKz9w0oZqDegac4s41urnhlqqdqQgodLmjtp/4=; b=Cmrw0sggId00IEOjkUyjQ5ajlJv5yZVTmW3zKnvXIG2TWdR9Bk/3PcNkqiL0NAkbd6 PUKJrEt48BU/Jr/pOPBRvCL/F0e6Ft95pBLMgATjS/AKAJrMg6BCB2jiy7imHeVy5nzU kGYeUhOmokpdDdv5zTPrlHTiSiqt7c6ASRXuzewadP6DPOh9VKXmt+l24QTlKXqCoQyN zkQGVQn2Sw+VyF2+b2llBpk36DSd9JHlO2KJmYKEeA+7ZfxoVIfgPweq6jVFgkcpaCTZ R4NUx5NzI2afGTzzD2pJ0MfCHpsTQbnzFAe2XLDc3pUPVv7qyEPtJSCOFO0e9dpXFwEh ncyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533288; x=1735138088; 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=nurHWzKz9w0oZqDegac4s41urnhlqqdqQgodLmjtp/4=; b=vNzVgIY8c6lepDjiHzM9u+U7LiLqvu8g9zODb8PtIFdug+RIlQIoemmnQa07gp4YFw 0u/Gev4qGL3He12yW9wpTrBzCMHBs+r0HjJmsjGipxfI41nWi/S29UrmM3XcalDakAVs sPQsVQWqgEsoQ9vbF/tozPcziSuagWnz/kqVrb5szcarenP2XzbqK6CSPZu4rqO+YtTX hzpD7AVNkLJahmU4eWuBBivUBtUkVGenmODD0V+FL2wpXAo6PsqjlPpm5J8u+xLqz2Bt a+9HWQPyYjwxI9Pj8aJjCel0n73ausoRaC63Dk+LDMWHXZ3Rf7jHk3rmD6wI5dTgKecI D+Vw== X-Forwarded-Encrypted: i=1; AJvYcCV0Fm/L9b0vYjpD5bXExF1lVe+riMYDHuEH4YbEPISzyloXahl8+FWVLPaHNgMzmWLxhCado+j3MVY=@vger.kernel.org, AJvYcCXX/ZoBAph2kMyTZUpwc/Mqre3uJCZXinYFRWZcLecyffSUGYf5KuSHUcM6t0pwZxSGcFmHzUQh@vger.kernel.org X-Gm-Message-State: AOJu0Yzahkd/OwhKhoeAw/gdpwG6F8PEC6tsGPbX5JDEVFLd0pl4V3er fbbRgdGp6+W2XuIyqA835dvi160EGDIeEFqfYAJwiBg3iPMB8C6G X-Gm-Gg: ASbGncs+5fkVDsqmabQwhY+P0reU5c/MwHW+CJjOaCf17m7RItVJktFCIK9JCzvMvaJ Iy+f4VsNmwCDIjGOQ2Vjmnq/AlmObFO+c5RnwrtnF5cmRJaEAg/T9rkgf3th/Siq9JazVEQyHnu mbT1ZLaVj8rHUmyt0FWP+AYHgTHlNQKGSyqUzAWBQfHnQe+J4tBMGXkAy/m0CQuaOx/I927Mx33 0s2Nq8c4gN2mxHU6SB76W4fUZ07E/NUFcWBlAdLrj9vHA== X-Google-Smtp-Source: AGHT+IGyXL/jY4ZpJVlfKFa4l0IVypUBaFxkXF0sO1ELxMEVdLOy13mZvo6Co+HDvukxp/eBLM3b7A== X-Received: by 2002:a05:6a20:d806:b0:1d9:c64a:9f72 with SMTP id adf61e73a8af0-1e5b47f252cmr4956312637.2.1734533288039; Wed, 18 Dec 2024 06:48:08 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac5183sm8912687b3a.29.2024.12.18.06.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 06:48:07 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v6 9/9] netdevsim: add HDS feature Date: Wed, 18 Dec 2024 14:45:30 +0000 Message-Id: <20241218144530.2963326-10-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241218144530.2963326-1-ap420073@gmail.com> References: <20241218144530.2963326-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 dendencies 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 DISABLED 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: off 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 --- v6: - Patch added. drivers/net/netdevsim/ethtool.c | 15 ++++++++++++++- drivers/net/netdevsim/netdevsim.h | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/net/netdevsim/ethtool.c b/drivers/net/netdevsim/ethtool.c index 5fe1eaef99b5..aa176f52fc3f 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,11 @@ static void nsim_get_ringparam(struct net_device *dev, struct netdevsim *ns = netdev_priv(dev); memcpy(ring, &ns->ethtool.ring, sizeof(ns->ethtool.ring)); + memcpy(kernel_ring, &ns->ethtool.kernel_ring, + sizeof(ns->ethtool.kernel_ring)); + + if (kernel_ring->tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN) + kernel_ring->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_DISABLED; } static int nsim_set_ringparam(struct net_device *dev, @@ -85,6 +89,9 @@ static int nsim_set_ringparam(struct net_device *dev, ns->ethtool.ring.rx_jumbo_pending = ring->rx_jumbo_pending; ns->ethtool.ring.rx_mini_pending = ring->rx_mini_pending; ns->ethtool.ring.tx_pending = ring->tx_pending; + ns->ethtool.kernel_ring.tcp_data_split = kernel_ring->tcp_data_split; + ns->ethtool.kernel_ring.hds_thresh = kernel_ring->hds_thresh; + return 0; } @@ -161,6 +168,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 +191,10 @@ 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->ethtool.kernel_ring.tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_UNKNOWN; + ns->ethtool.kernel_ring.hds_thresh = 0; + ns->ethtool.kernel_ring.hds_thresh_max = NSIM_HDS_THRESHOLD_MAX; } void nsim_ethtool_init(struct netdevsim *ns) diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index bf02efa10956..6abbc627308d 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]; @@ -87,6 +90,7 @@ struct nsim_ethtool { struct nsim_ethtool_pauseparam pauseparam; struct ethtool_coalesce coalesce; struct ethtool_ringparam ring; + struct kernel_ethtool_ringparam kernel_ring; struct ethtool_fecparam fec; };