From patchwork Wed Nov 13 17:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13874031 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E731117ADF8; Wed, 13 Nov 2024 17:32:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519170; cv=none; b=MMnlFn9YHw1jC6t7Xdu9Rqbne/pbSpQoAdEh9uFVT53Q2CCIMUDlZ8tOpDQkaoYrAiUW7W0a1Nrz7L01Tc4WciRczkcSA7ls5zMntKqMfzsUOw1lwwFVdYTi7MPc7xHjx4yOYWhKeSl2XXx+azwK5ozt94Ljn/9jGSaGOAZ8Bz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519170; c=relaxed/simple; bh=TcH9wkD8r2aLtwF4RMloBl4W7UURqK0qm0SH/gG1siY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F5L5FdDp6TJ7oQZgKS0RCXEsSYhKkfOqWKUOzFlhuOZ9xkzLmP7nThRrn5L7m1Xm8wlDgAUOGo2FnZPcaSZeztQR4GeM5IksqeFxHfNF2pqcHMqJNB7wLkxpzNqn8fzOLpM+sgYo/2kSLN99ypmuTmWcuCUSMkABvdqJX1Ia3+k= 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=C8Aj37N2; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C8Aj37N2" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20caccadbeeso77813895ad.2; Wed, 13 Nov 2024 09:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731519168; x=1732123968; 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=xtqA7W2vqCXP9dXBoVyFgPK7k8pDmFv8ZFg53+ASeAQ=; b=C8Aj37N2nPDiNhhnCXR5d7NP1Imkair1Pt9OinG1TKTp6wklWyVYrkk3DDDwycnkUz QUfh3/KeRTvYuR1eM+/KYjoNL6eurYrvBV1nZsI80LLnUwbcXjRxnZ1mgCyOW0div168 XMV/NY0ToZqhBHgCsbK7glh8Hj8ukUzVpatlPyI4vqFf7E04r9c5/PepuIKu7iJkvAV6 t/IJFbcMGAHgyRW6Ybwl0Ue68YpoflSitnSM4kU0ajlB12FJq31FStoJMOjR4h/pD9S4 O313qZfTEBdQgBZQl10vJShNxNydz2gq3Eeitl3SzKr43LU3qsTmFANbnZAoka6QaT11 Vcmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731519168; x=1732123968; 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=xtqA7W2vqCXP9dXBoVyFgPK7k8pDmFv8ZFg53+ASeAQ=; b=uBDcGVYxWrWzZid3qI4dm4miFtl4YsrU9HbedrP4nYIYVYvuFGBgH4W6yeSkFvlxmv DaGFmx1w5VTq+DDqCtwLYGTmWOfs28dnexhDoAMvAjw+Esz4dBNazKw7PqYjReVidHlc +t7SaFN1eogRsqH1hShWqIzjbxzdLaBAglwREuqqYQAcnsVtcihLFT2PKhRE8EHGD+TV TomZl2Gjpj+PGwuZICu/OOPRDiRQovd9ZPtU3Y2W83g4vdWRgy0/oZZTLC6uBqTOtkCJ 9k6MRGR0uwXX/p/Fk3iqtvOZ2RpJKp4hs6mwz0ytSkGAdop85COrl0XP4KyhaXfjQRW1 gLdw== X-Forwarded-Encrypted: i=1; AJvYcCVLaWP9xzXMlIoZU3HQr5pAJaUTUmztxmthzm4QwwNvEPv7yfJ9+5lrrUhAtH0fNeMV1NyeowDo@vger.kernel.org, AJvYcCX0BNj1PmXgQwAxPOZ2qJtYZ1nnaPHejv1ZWMjE3KEMz8rJ5WN8vV6CfVWeyGdlr/F/ka4ZU7/N9uo=@vger.kernel.org X-Gm-Message-State: AOJu0YxyXbmFnN4h+i4GR/24kDZ+KNU799O+4jiRTv128HPaInZL6u7m 08siQwODj7TEGWpGnqSV1WseXQCCCcxkxDyiibTjDW19YOjXzF1n X-Google-Smtp-Source: AGHT+IEG7otUQKyDsTesziLoOsHFhk18xPzBK4UERQ6LZcjRRfQZCqQHf7haeTiYN0QU9V+WkyXO5g== X-Received: by 2002:a17:902:ccc3:b0:20c:b8a5:38e8 with SMTP id d9443c01a7336-211b662d80amr43323675ad.23.1731519168069; Wed, 13 Nov 2024 09:32:48 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc7df5sm113140765ad.19.2024.11.13.09.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 09:32:47 -0800 (PST) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, almasrymina@google.com, donald.hunter@gmail.com, corbet@lwn.net, michael.chan@broadcom.com, andrew+netdev@lunn.ch, hawk@kernel.org, ilias.apalodimas@linaro.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, dw@davidwei.uk, sdf@fomichev.me, asml.silence@gmail.com, brett.creeley@amd.com, linux-doc@vger.kernel.org, netdev@vger.kernel.org Cc: kory.maincent@bootlin.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, hengqi@linux.alibaba.com, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, hkallweit1@gmail.com, ahmed.zaki@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, jdamato@fastly.com, aleksander.lobakin@intel.com, kaiyuanz@google.com, willemb@google.com, daniel.zahka@gmail.com, ap420073@gmail.com Subject: [PATCH net-next v5 1/7] bnxt_en: add support for rx-copybreak ethtool command Date: Wed, 13 Nov 2024 17:32:15 +0000 Message-Id: <20241113173222.372128-2-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113173222.372128-1-ap420073@gmail.com> References: <20241113173222.372128-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 header-data-split-thresh N` in the next patch. Reviewed-by: Brett Creeley Tested-by: Stanislav Fomichev Signed-off-by: Taehee Yoo --- 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 4c1302a8f72d..d521b8918c02 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 @@ -1328,13 +1327,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); @@ -1827,7 +1826,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); @@ -2161,7 +2160,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 @@ -4452,6 +4451,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. */ @@ -4466,7 +4470,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; @@ -4511,7 +4514,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)); } @@ -6417,16 +6422,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); @@ -15872,6 +15875,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 649955fa3e37..d1eef880eec5 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; @@ -2300,7 +2303,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 cfd2c65b1c90..adf30d1f738f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -4318,6 +4318,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, @@ -4768,7 +4812,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; @@ -5341,6 +5386,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 Nov 13 17:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13874032 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 69A93201106; Wed, 13 Nov 2024 17:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519178; cv=none; b=pyfLezegWLahJ/YJeL+j5eeNTVYaOb/idPiAq7nNV3jwJ0I+pYAVjz+6dtba4AsL04bjZJJlIJbHk+pzSTS4XUU7ThZ3M57mr0PBoELLjdue6YxApISJnmi85KgpazK3Vrew6l2R6L4Z0NHY1CltmXgkAiN4CGH4RYFRuKeb4ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519178; c=relaxed/simple; bh=LIBqxl0cUzUkK45JDAK+pEBJcNtYbi70BkxQP33QF+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DUhNrMsHqQVoqJGC1BdOjgxIQw57t6YZgDt4tUW/mwofkBW3+fBVR8EUIVAe/1fDZGFQdb7qH1Gl+x9hhiFbCP4g8LCNEt++4yfxR1zyrKGim0BgTRee2v6pQL/3FP4j9cUebvRUXlzMhNt5+yjOkIufAYRuMgriL/lPgIf7owg= 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=N5d40fCF; arc=none smtp.client-ip=209.85.216.51 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="N5d40fCF" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2e2b549799eso5725643a91.3; Wed, 13 Nov 2024 09:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731519177; x=1732123977; 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=3V5AK3oPRQdRZx+J39SvU4EAiowmHP3Xjjl1jyOkUHg=; b=N5d40fCFiHIixHxJYZ9GFbs2GaBX3dhgk+vZ8PB4sVrLq6qD9h20B5mCxDBlkh2Gyw XjugRU+c1DvRGzpSYoHZFPckngoPDd9a6K3DdKh74Za+C5Chop1Z/An/XnzrHWWjLP56 i/AzrkC4AocE8tjpt8hBchpR6vb1bkNM6t/56MEkPA9BIiHZRlA1FhvXSjWXDCpHX6Sw xWuPR3xia/KI4jbDjYx+6nlMSanb/vaM0bhC+L6W6/tehmGddOMOEQaRAC6MNqGjjNzq igWi8+MA3kh0y5YXVq88WdF+LqGMpQ6ue+qsQ+S+wEBOhwPV+LCKEeAq4PEjIBEm8psJ aa0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731519177; x=1732123977; 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=3V5AK3oPRQdRZx+J39SvU4EAiowmHP3Xjjl1jyOkUHg=; b=Qaq4j7u227fmt+VpGy6CRQl+uqV7pr28cNM2ZsNS6D1dit6pgaR6xLD1Iir3iTmodU aG9mwmvz/9k+j8RwFWoRci34PTKaJpoKmDmTPgSdCgQ+8rRTq6Pry5IleqBAcUdP0O5h XKry4V6T+bTAms9yIpUsNTGCcQQM9XnxSao9d8OAnGJvOEIYpu7jsbF9If0jTiY8RM2t KDlD3t/b5EDR5gzHJqbOyfPjEhQkvLt0sr7C12JZ7AM8IfxDXg7Uo+LAC+DFkX/PkROH HOvdYxt1kXBUXtj49deSc3NcKViuRWo9CJjDffLgplkbryHCBtPepvDf3CTX8a4NWdn7 KXSw== X-Forwarded-Encrypted: i=1; AJvYcCUwxa/nSKS5toQe/cdnA70tiuhjFQAaZ8cTyejIbOptMHDKFarac4w8BO1Gz7H2zf3TSBN0egL+@vger.kernel.org, AJvYcCWyjDGxp20U1CWj4CagFFm3op3w3ccgy9d4oJqUo58lT9sp4H2VcfEtpEQyWQA7PRwmMO9sqnGNHRE=@vger.kernel.org X-Gm-Message-State: AOJu0YynJlJYhgOn9BIp9CYzewikQFvUcVOsMJfZ3YDtiuMYBUxZjJ5U YdwzO7/ZGdGPOG+uXxYt5o+dr+QRd3KqYHpmbXAvOJT+fg6hk4WG X-Google-Smtp-Source: AGHT+IFSmaX/lqM8HWQiF6G2OyTpADXe8d4MIiHktHv139OCBnOj4o2G4b9pEdV/8nvX5AnWRzU3KQ== X-Received: by 2002:a17:90b:1a8c:b0:2c9:b72:7a1f with SMTP id 98e67ed59e1d1-2e9b1773966mr28069105a91.28.1731519176541; Wed, 13 Nov 2024 09:32:56 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc7df5sm113140765ad.19.2024.11.13.09.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 09:32:55 -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 v5 2/7] net: ethtool: add tcp_data_split_mod member in kernel_ethtool_ringparam Date: Wed, 13 Nov 2024 17:32:16 +0000 Message-Id: <20241113173222.372128-3-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113173222.372128-1-ap420073@gmail.com> References: <20241113173222.372128-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. The new tcp_data_split_mod member indicates the tcp-data-split value is explicitly set by the user. So the driver can handle ETHTOOL_TCP_DATA_SPLIT_ENABLED properly. Signed-off-by: Taehee Yoo --- v5: - Patch added. include/linux/ethtool.h | 2 ++ net/ethtool/rings.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 1199e308c8dd..ecd52b99a63a 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -73,6 +73,7 @@ enum { * struct kernel_ethtool_ringparam - RX/TX ring configuration * @rx_buf_len: Current length of buffers on the rx ring. * @tcp_data_split: Scatter packet headers and data to separate buffers + * @tcp_data_split_mod: Updated tcp-data-split from user * @tx_push: The flag of tx push mode * @rx_push: The flag of rx push mode * @cqe_size: Size of TX/RX completion queue event @@ -82,6 +83,7 @@ enum { struct kernel_ethtool_ringparam { u32 rx_buf_len; u8 tcp_data_split; + bool tcp_data_split_mod; u8 tx_push; u8 rx_push; u32 cqe_size; diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index b7865a14fdf8..c12ebb61394d 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -250,6 +250,9 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info) return -EINVAL; } + if (tb[ETHTOOL_A_RINGS_TCP_DATA_SPLIT]) + kernel_ringparam.tcp_data_split_mod = true; + ret = dev->ethtool_ops->set_ringparam(dev, &ringparam, &kernel_ringparam, info->extack); return ret < 0 ? ret : 1; From patchwork Wed Nov 13 17:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13874033 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED6442022EA; Wed, 13 Nov 2024 17:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519188; cv=none; b=L4M71jSMvrNRiiMsCtcy5hIwmWxD1LcBIat3OtQ0ck3hp7oVTS7vqvxlZ1TJYZvBZkVQVx6m6cSfrb+Ko9lICN0b2kupGs5lgNKAlgFoS6zcVNOrMQpk+Bfwbt+0zNWPAEt1q7Et3hmGAf08aolTTtD9ONx2+Xec3akYg5MvkNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519188; c=relaxed/simple; bh=28VI3Ejowj0Y4k0yUbjgXhUpafNQk9OsXPmVwl0rans=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lPTuRYowFf70u983Lk5/lKuWxeazpRJLNTl7La+UGKxF5rfc3rWCEd5SGPcf64SfZovVQELn0vNQJ4xVcSxpOdJWHZkGrBLgfDRy3wsmmocj4spPCVAsnyMCZrSE++UDhYLCB35pKA98jotw1VVvJ2CHqEzyoqvdwmeRJx1qMZg= 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=fJXns/FM; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fJXns/FM" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20cb7139d9dso68805865ad.1; Wed, 13 Nov 2024 09:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731519185; x=1732123985; 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=amy2lNuziNprXzNpSXa/Em2y3IstMk3e4quzHvr6Z64=; b=fJXns/FMhJ1TJjkIePF+OLTpZVMWbQK9EdcNsR9/0+l1NboeAocUPnNukqHs3dPkGY RIr/Eb2do1z62iXpB6Mi2tOUSyTxzO6PLppCbaFw4rZ/D4t8EGl8moX46SUwD/dNOMT4 yYJUn5UM8D61fDuSpPIjM8F4KpDZQr/FFIEt3ZBIUzzityqWwhSRENxyZgPBwHXumLw3 ZEPLOcGXglGvuw5f7gcIxO3SsiWWoQlYpgsAzmefLAj3VN216O0tmNhPqszVtMYIcTOx puerTgtcfT2WL2gDulz65AjZii4nXltmPjSH+zssdkM+AX6Qxksjhp+HVsOPSJOUb96l e+bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731519185; x=1732123985; 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=amy2lNuziNprXzNpSXa/Em2y3IstMk3e4quzHvr6Z64=; b=o2MaHpxdGryPKatnL1sxx6MyNzr+m4D4PZA+K0EOGi6NL+3kFM+9/TQk2jJugg4VfS Hvnjw/2zTEPwWYFpMzaae0dlXZeCbfZ0oGPmpqrx03ry6rV0FdH0x5L5Y/KPAiairfhg 0LpYwMb63QkhEe5WtTprzGnqoORFYYv4Rrqu/D4B/G+j1K2SzrXJRL8t/H14gnRpiOOq vXYXLauPvAdaniHqVqGpTvwusvQOD3SPb7Vq9jFi7hWU3pioIdagwkC5SVZWBWPeb/H5 S5ixa/KpasaZCRQLV6I6VbEqX7AjvoUnCKoXb2NMx7BqXNPeUI/osfnA7/qJWBfHHXGF /CGA== X-Forwarded-Encrypted: i=1; AJvYcCU1Otd1Al7qB50Dakrq2uL16d2/QOAMQ2MMDF4NxSLKMH+3cEFzA2oMBVdxdINTcjdbRrg0zV3Sbqk=@vger.kernel.org, AJvYcCWSASIy3kmyqH43wxhZN1Seip5luT9xkTMEMBtgfND3kf7gYqI9F41kd1aKDujQQoRED2SnQCft@vger.kernel.org X-Gm-Message-State: AOJu0YwwY0BKmjflow3uWwaEkRmP034vMDk9dwpwSZBd4f+C30URq0GZ goPbONtVkjmf41BPVSKFcFFAwgsTPdSVxUEA3IvR9xFj/9VpruR/ X-Google-Smtp-Source: AGHT+IH9x4SJxPM2GxLCSJtUCzv4mHUufsz/223ZQf+3joz4oj8B0tw9AD7gWzrLPOU4yP7Z0yst5g== X-Received: by 2002:a17:903:41c3:b0:20c:e65c:8c6c with SMTP id d9443c01a7336-21183d34368mr269317115ad.19.1731519185064; Wed, 13 Nov 2024 09:33:05 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc7df5sm113140765ad.19.2024.11.13.09.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 09:33:04 -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 v5 3/7] bnxt_en: add support for tcp-data-split ethtool command Date: Wed, 13 Nov 2024 17:32:17 +0000 Message-Id: <20241113173222.372128-4-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113173222.372128-1-ap420073@gmail.com> References: <20241113173222.372128-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 Signed-off-by: Taehee Yoo --- 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 | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index d521b8918c02..608bcca71676 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4474,7 +4474,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 d1eef880eec5..3a7d2f3ebb2a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2202,8 +2202,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 @@ -2224,6 +2222,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 adf30d1f738f..b0054eef389b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -840,6 +840,8 @@ static int bnxt_set_ringparam(struct net_device *dev, struct kernel_ethtool_ringparam *kernel_ering, struct netlink_ext_ack *extack) { + u8 tcp_data_split_mod = kernel_ering->tcp_data_split_mod; + u8 tcp_data_split = kernel_ering->tcp_data_split; struct bnxt *bp = netdev_priv(dev); if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) || @@ -847,9 +849,25 @@ static int bnxt_set_ringparam(struct net_device *dev, (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) return -EINVAL; + if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_DISABLED && + tcp_data_split_mod) + return -EOPNOTSUPP; + + if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + tcp_data_split_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 (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + tcp_data_split_mod) + 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); @@ -5345,6 +5363,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, From patchwork Wed Nov 13 17:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13874034 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AB9520262A; Wed, 13 Nov 2024 17:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519197; cv=none; b=jNScZK4msVCgd/Xc9DQ/HSdMdQRujspSjwIlequ9tfmlvmhiEdbz8NoWBxP+NpRNS/ri8jY+0IgZCQ9TVXhPB5RjSUJhLfFPYT3y0ySVwTDroIxYCfF1jGQ3A3be2qiUBz9sO7hGmATAASSAGwYcH1BjoImTJ7ZxNoqlxZgssu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519197; c=relaxed/simple; bh=gZPGA5bLddVbJVyN1uiiSXHOu0Xj+fQoxdSA7iO5WLI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uGAb9/WafTcgcpgGeRIzQQtFJA7sdXcun9Y1OOIR8gXTlbFFCFbCPQIyMpOO1GZfJldiJPPDgp9TLdCHoavjcOtv2jHXngQSC34UCTzjl30KUEIpWW1sej5MvFQ3EXyIfMwA4lzfOprV3uO0ZeJbEQYIFn5UTDpL0FJtvQlw3wY= 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=NXe1MO/m; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NXe1MO/m" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20cdb889222so72052815ad.3; Wed, 13 Nov 2024 09:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731519195; x=1732123995; 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=NvkC4WOe7NS3cmVKReVfn/+fqg/DlSXzBIx3GFroG/w=; b=NXe1MO/mSFa5xCN0HmGK7H/NkM2VX/EDOATiRyvIobiLfLCaX1INZ/bE5cWtUEXF6h uh/5q8zvevUv3fOIj5YTKfoTzf7ZTHzVzDrqdIr/hR0QTEowVngR3gLesj4/qsvhcWyO svTNvCKDlsfcgGQ/OzP0nxRz5e5M3dPoAjDS3jUYypJFcHlNbfn6rzdFs6DxrHMtjPZ+ he3GqETYeuH8Aw7PZOwem7FBnnybys7XPDSfO5VBkW3vMoTEexzqwc8PZWAY3MQ8vzOe LH831JMZkJDcWuFLaCgZVSo8i73DmAiiRtedxhQwsdirYh4+O1/gfBNx6CT+aLydOjo/ VjrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731519195; x=1732123995; 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=NvkC4WOe7NS3cmVKReVfn/+fqg/DlSXzBIx3GFroG/w=; b=o3C1gD/0U2Q7UD/RJ5+J+1M6tik5mTDKIDBANjo1MEY/7Z2XUCCNw3/XnfwDzMBRM/ SqO0tsUu3uJ8dIufJtLiDBJdyyzwkqO5JRr9OndMi/h8fPaV8SxHH/tMv2IrlsFDiOE8 fO4uf3Qp423hqy434y1OwzcW1x9emtpkMgE0BbyJIFIZ0GPVEgEATu9mQNDOvUYtLxgA GuYrRWq9moaEznIgsKMZwa81/5eK7NQgLsPYrCMs3gTX61Y3MnM3mUO930fFqFdwra3j 6otXKJx4Cqv65GMGEFBkHJbS/3cBAdjrWhKPV2bGjMrZI9rPZj/b9D+TxQo59h8jijf0 bLmA== X-Forwarded-Encrypted: i=1; AJvYcCUTVSg1eG8fOMpINVbtJzVWexLwykh1y5K91jEyFfMMIp4Y/+6w9VcyCMXF5PZGync7LX0yTAF1EY8=@vger.kernel.org, AJvYcCUvXpH86ejfUTO14l0z0PcFYxwghHZ6D+5flcVblewI4gW3Lx/S0Aboi9d64Fj3fNZI+kvkFQcF@vger.kernel.org X-Gm-Message-State: AOJu0YxS8ztWvI4ZoICzZ1BK7n0yoAQnpFbE/Qr0p/imiM0wsX6wMQak fszRANtr2w38twLslAeNA78+49tcxORZjZh/AOvuMOfr57S+GArA X-Google-Smtp-Source: AGHT+IGAHNjFbNG2z1ZOkMjbrsnSdJKSDeeav2zSEsw1DEMCoPvWZ6DazVMAHkM/dAegoKIbRPMePw== X-Received: by 2002:a17:903:228b:b0:20b:9379:f1f7 with SMTP id d9443c01a7336-211b5d29e0emr41563115ad.40.1731519194586; Wed, 13 Nov 2024 09:33:14 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc7df5sm113140765ad.19.2024.11.13.09.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 09:33: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 Subject: [PATCH net-next v5 4/7] net: ethtool: add support for configuring header-data-split-thresh Date: Wed, 13 Nov 2024 17:32:18 +0000 Message-Id: <20241113173222.372128-5-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113173222.372128-1-ap420073@gmail.com> References: <20241113173222.372128-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 header-data-split-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 header-data-split-thresh is set, it affects UDP and TCP packets. Example: # ethtool -G header-data-split-thresh # ethtool -G enp14s0f0np0 tcp-data-split on header-data-split-thresh 256 # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... Header data split thresh: 256 Current hardware settings: ... TCP data split: on Header data split 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. In general cases, HDS can increase the overhead of host memory and PCIe bus because it copies data twice. So users should consider the overhead of HDS. If the HDS threshold is 0 and then the copybreak is 256 and the packet's payload is 8 bytes. So, two pages are used, one for headers and one for payloads. By the copybreak, only the headers page is copied and then it can be reused immediately and then a payloads page is still used. If the HDS threshold is larger than 8, both headers and payloads are copied and then a page can be recycled immediately. So, too low HDS threshold has larger disadvantages than advantages aspect of performance in general cases. Users should consider the overhead of this feature. Tested-by: Stanislav Fomichev Signed-off-by: Taehee Yoo --- 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 | 79 ++++++++++++-------- include/linux/ethtool.h | 6 ++ include/linux/netdevice.h | 1 + include/uapi/linux/ethtool_netlink.h | 2 + net/core/dev.c | 13 ++++ net/ethtool/netlink.h | 2 +- net/ethtool/rings.c | 37 ++++++++- 8 files changed, 115 insertions(+), 33 deletions(-) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 93369f0eb816..edc07cc290da 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -220,6 +220,12 @@ attribute-sets: - name: tx-push-buf-len-max type: u32 + - + name: header-data-split-thresh + type: u32 + - + name: header-data-split-thresh-max + type: u32 - name: mm-stat @@ -1398,6 +1404,8 @@ operations: - rx-push - tx-push-buf-len - tx-push-buf-len-max + - header-data-split-thresh + - header-data-split-thresh-max dump: *ring-get-op - name: rings-set diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index b25926071ece..1fdfeca6f38e 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -878,24 +878,35 @@ Request contents: Kernel response contents: - ======================================= ====== =========================== - ``ETHTOOL_A_RINGS_HEADER`` nested reply header - ``ETHTOOL_A_RINGS_RX_MAX`` u32 max size of RX ring - ``ETHTOOL_A_RINGS_RX_MINI_MAX`` u32 max size of RX mini ring - ``ETHTOOL_A_RINGS_RX_JUMBO_MAX`` u32 max size of RX jumbo ring - ``ETHTOOL_A_RINGS_TX_MAX`` u32 max size of TX ring - ``ETHTOOL_A_RINGS_RX`` u32 size of RX ring - ``ETHTOOL_A_RINGS_RX_MINI`` u32 size of RX mini ring - ``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_TX_PUSH_BUF_LEN_MAX`` u32 max size of TX push buffer - ======================================= ====== =========================== + ================================================ ====== ==================== + ``ETHTOOL_A_RINGS_HEADER`` nested reply header + ``ETHTOOL_A_RINGS_RX_MAX`` u32 max size of RX ring + ``ETHTOOL_A_RINGS_RX_MINI_MAX`` u32 max size of RX mini + ring + ``ETHTOOL_A_RINGS_RX_JUMBO_MAX`` u32 max size of RX jumbo + ring + ``ETHTOOL_A_RINGS_TX_MAX`` u32 max size of TX ring + ``ETHTOOL_A_RINGS_RX`` u32 size of RX ring + ``ETHTOOL_A_RINGS_RX_MINI`` u32 size of RX mini ring + ``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_TX_PUSH_BUF_LEN_MAX`` u32 max size of TX push + buffer + ``ETHTOOL_A_RINGS_HEADER_DATA_SPLIT_THRESH`` u32 threshold of + header / data split + ``ETHTOOL_A_RINGS_HEADER_DATA_SPLIT_THRESH_MAX`` u32 max threshold of + header / data split + ================================================ ====== ==================== ``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` indicates whether the device is usable with page-flipping TCP zero-copy receive (``getsockopt(TCP_ZEROCOPY_RECEIVE)``). @@ -930,18 +941,22 @@ Sets ring sizes like ``ETHTOOL_SRINGPARAM`` ioctl request. Request contents: - ==================================== ====== =========================== - ``ETHTOOL_A_RINGS_HEADER`` nested reply header - ``ETHTOOL_A_RINGS_RX`` u32 size of RX ring - ``ETHTOOL_A_RINGS_RX_MINI`` u32 size of RX mini ring - ``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_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_HEADER`` nested reply header + ``ETHTOOL_A_RINGS_RX`` u32 size of RX ring + ``ETHTOOL_A_RINGS_RX_MINI`` u32 size of RX mini ring + ``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_HEADER_DATA_SPLIT_THRESH`` u32 threshold of + header / data split + ============================================ ====== ======================= Kernel checks that requested ring sizes do not exceed limits reported by driver. Driver may impose additional constraints and may not support all @@ -957,6 +972,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_HEADER_DATA_SPLIT_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 ecd52b99a63a..b4b6955d7ab9 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -79,6 +79,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; @@ -89,6 +91,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; }; /** @@ -99,6 +103,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), @@ -107,6 +112,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 0aae346d919e..0c29068577c4 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4028,6 +4028,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.h b/include/uapi/linux/ethtool_netlink.h index 283305f6b063..7087c5c51017 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -364,6 +364,8 @@ enum { ETHTOOL_A_RINGS_RX_PUSH, /* u8 */ ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN, /* u32 */ ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, /* u32 */ + ETHTOOL_A_RINGS_HEADER_DATA_SPLIT_THRESH, /* u32 */ + ETHTOOL_A_RINGS_HEADER_DATA_SPLIT_THRESH_MAX, /* u32 */ /* add new constants above here */ __ETHTOOL_A_RINGS_CNT, diff --git a/net/core/dev.c b/net/core/dev.c index 13d00fc10f55..0321d7cbce0f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9474,6 +9474,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 203b08eb6c6f..9f51a252ebe0 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -455,7 +455,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_HEADER_DATA_SPLIT_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 c12ebb61394d..ca836aad3fa9 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -61,7 +61,11 @@ 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_HEADER_DATA_SPLIT_THRESH */ + nla_total_size(sizeof(u32)); + /* _RINGS_HEADER_DATA_SPLIT_THRESH_MAX*/ } static int rings_fill_reply(struct sk_buff *skb, @@ -108,7 +112,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_HEADER_DATA_SPLIT_THRESH, + kr->hds_thresh) || + nla_put_u32(skb, ETHTOOL_A_RINGS_HEADER_DATA_SPLIT_THRESH_MAX, + kr->hds_thresh_max)))) return -EMSGSIZE; return 0; @@ -130,6 +139,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_HEADER_DATA_SPLIT_THRESH] = { .type = NLA_U32 }, }; static int @@ -155,6 +165,14 @@ ethnl_set_rings_validate(struct ethnl_req_info *req_info, return -EOPNOTSUPP; } + if (tb[ETHTOOL_A_RINGS_HEADER_DATA_SPLIT_THRESH] && + !(ops->supported_ring_params & ETHTOOL_RING_USE_HDS_THRS)) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_RINGS_HEADER_DATA_SPLIT_THRESH], + "setting header-data-split-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, @@ -222,9 +240,24 @@ 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_HEADER_DATA_SPLIT_THRESH], &mod); if (!mod) return 0; + if (kernel_ringparam.tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + dev_xdp_sb_prog_count(dev)) { + NL_SET_ERR_MSG(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_HEADER_DATA_SPLIT_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 Nov 13 17:32:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13874035 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5A17200C8B; Wed, 13 Nov 2024 17:33:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519205; cv=none; b=XrVNonTPRuWLUCyLSmkO91QGGAaJkKfUkBFSArqOrtM0sgpmk3MTkLubB/bWbEA7wa2ayAmsmTtSjNMbJMcuHqEjYXVo2MeEUQI+c04liZjOGY1C7IfbHvFgCUb9pyO0ZIOXxIzJGFdB5995/SRjVXep42GAfTDi6r66EdZOfk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519205; c=relaxed/simple; bh=a0ywURpwXp6Ch+RXxe+fppgK0QrL+KyFhF57mCEYTVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Jkvyb/H9u5ao7pFXMPmH56csXiiwWB2vny8I3bGBGFuFqWp9sJAXq6u//omC0F8MmK5M2xdrjXuNM+TN2byL062/EXtPOm6E1K3KFUzhoqVM4nZXLbZ0K7hfaSnIx38CJBuqViuWF0u2nP1rV8BRFBvuVg8cyFnoU0dcw5Ma72w= 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=YFeglS91; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YFeglS91" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20cb47387ceso75973925ad.1; Wed, 13 Nov 2024 09:33:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731519203; x=1732124003; 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=Aux97D7sQGZHNOQCnimj2somiyMj9aLWgp4W224VQM8=; b=YFeglS91HGtdStAd7z2/W8En7RWzrN6oS0qS1Qv1XfKTs8i5Ij9WJ/OaHFWrnVP9Vq wEEjYnp/AzGqYITnqCET586JQ6OHr7fCVPYArU+b4nRMDLHihXRqARRrH5ygpcssJTCT A+mZqNzbxBJd4TpY88DRv1bUKE/RtkYJv/Iv2J/k/C/HJe69lQZpxU7lfm+r8fauT6+N Lq9KRt3fSHlqiai0WV5hC6fpsiVANBV4iB6uP0Ag2qtCXxRIjx32wtF2bujTrGEwVMYy 4m7Vhxo+PoWan0uYi5ib2VCvNFRd4+n/0+hoqeSolwdAdi0EgDOhKNK9y4LAPGi1b9zz QPXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731519203; x=1732124003; 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=Aux97D7sQGZHNOQCnimj2somiyMj9aLWgp4W224VQM8=; b=GuGQJfLf7zvwu0HNz7cQOuvpPAfkcRR6HYg/G8it+YYyuMqAzZReHFx8We2z0ar496 fqBdbOqHIwYTkU/kH+xAMn3569Y4/zzAcXeBK6Wd0ups2MUZGu6IlfP7v5WGJXzliBdL 9uT+Oak27jdo6jzucAaKwVf1wR9RuxRnIknX888CEv0zVEjr0oT7EHGCknN3TodWo6bh ++r0zU/CciGQLwm9ywKUcU4tlhv3wDMG5T/lPpn2z9pqTusfQqJ+eEcaI/IgJUlIdeJX L6+HAaIvyV1w6xyoBI/90uCKVOQOJ8kHd7KCVryM23Veoc3nzd2Bjw90NpNaURQLCyyc ottw== X-Forwarded-Encrypted: i=1; AJvYcCVmngRa81BvQ6l7nJll3WPG7LEvTMbvN1xDxRS/jGZP9mVKHGEQBzh7XYWdyAUCqlKK9HVFOTTL@vger.kernel.org, AJvYcCVnUf3LQc0X45NR3WB9h+UajyvH0RH0geFZH9sfMMnTl7HVcVEnLwbzA0i4uBz1UdkaETaRWiEWXxw=@vger.kernel.org X-Gm-Message-State: AOJu0YyA/U8Dib9r0TAd7aVTKpBSKsy6EYYztwoV7YqntCktnEBPegWY sSsFisD3QcU18n/gpaT6oOhMQOA3fge5/aUOOtRSp7qTIc+vs414 X-Google-Smtp-Source: AGHT+IEUx+Hu8gz7B4kW9m2Z15XEfm72UxuByLcQdNj/r5pm6lSMRtOWPTewy4q0Mz+xY0EHTvFG3Q== X-Received: by 2002:a17:902:f541:b0:211:6b21:73d9 with SMTP id d9443c01a7336-2118359c225mr277915125ad.37.1731519203089; Wed, 13 Nov 2024 09:33:23 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc7df5sm113140765ad.19.2024.11.13.09.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 09:33: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 v5 5/7] bnxt_en: add support for header-data-split-thresh ethtool command Date: Wed, 13 Nov 2024 17:32:19 +0000 Message-Id: <20241113173222.372128-6-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113173222.372128-1-ap420073@gmail.com> References: <20241113173222.372128-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 header-data-split-thresh ethtool command is added, so it adds an implementation of header-data-split-thresh option. Configuration of the header-data-split-thresh is allowed only when the header-data-split is enabled. The default value of header-data-split-thresh is 256, which is the default value of rx-copybreak, which used to be the hds_thresh value. # Example: # ethtool -G enp14s0f0np0 tcp-data-split on header-data-split-thresh 256 # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... Header data split thresh: 256 Current hardware settings: ... TCP data split: on Header data split thresh: 256 Tested-by: Stanislav Fomichev Signed-off-by: Taehee Yoo --- 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 608bcca71676..27d6bac3a69a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4454,6 +4454,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 @@ -6429,7 +6430,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 3a7d2f3ebb2a..058db26fb255 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2362,6 +2362,8 @@ struct bnxt { u8 q_ids[BNXT_MAX_QUEUE]; u8 max_q; u8 num_tc; +#define BNXT_HDS_THRESHOLD_MAX 256 + 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 b0054eef389b..a51a4cedecb9 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, @@ -868,6 +871,7 @@ static int bnxt_set_ringparam(struct net_device *dev, else if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN) 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); @@ -5363,7 +5367,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 Nov 13 17:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13874036 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8ADD3201262; Wed, 13 Nov 2024 17:33:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519213; cv=none; b=H15HKBGf1XghPQU+P8goRXeuDQX0PcDm97Qf/64FpUeFmonQY8MulP1EpOcG/dUKTTlV8dT8GUoRF1lckcydfrBcLnC9i5JliG+9TF/kO/NIC+U8yHpbXbmYHzKD/gSUDl1M47UEy3K0q8rJOtyJnzzKtxjV5Ke52KjwlMyRuQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519213; c=relaxed/simple; bh=KY5nGQ1sAVQr0Mkg7C/TwvPl2QkKuJt5o7PKF8OQLTA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LflH2j4RsNke3ajVCuBPDL2mba0HMCKWKzGthAv1UzP5xeWk/mX1Xn8KAo7ekoh/4lF3cmKK+Wi+oa4EVFRR4/H3ftQo+t9ubNBvhp8C4uYD9WJMyuNY0m3uraDn1+jjGncAvhFL8qzjCp66HFrEBZpN0lIXtxG5reTdWW8/Wws= 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=Z23cE10e; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z23cE10e" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20c7edf2872so8455725ad.1; Wed, 13 Nov 2024 09:33:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731519212; x=1732124012; 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=mJlRBJcEwuvQhT4VeRCSmuKVjYnGZXZ9h57evQsgFog=; b=Z23cE10eEQjryEyWEqYIMBnKei6cO290c7X5/w/1QG4Dm90O2Q99Erh8yIAkVQoOAH d9XlwLiHaQbzUvxKTFmB235LGDWKb1F9p9me9RZIIJ4bxmPNpeQ+blwIC/H6MRtjwUmL A/178+atd6dI7XT4d7gvF5IreXS4jlyjjk4hgOXI8e0v54Ugk3kfM++FmkccdGN7pPWI cfV/gP7twdJFvRkr8CzDYz93ZckYBq8hJmYvuVtwAq60UnOTINnFxy4BejogYrTyEwNe fqll0eCB40CpXBZpjQRlO1jPxVDQw592/r3ACwZ9VQ8S0ZUYXOvuQzyly2KXhk71btCy mwzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731519212; x=1732124012; 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=mJlRBJcEwuvQhT4VeRCSmuKVjYnGZXZ9h57evQsgFog=; b=TiZCCCpaawxxyVOSVT+V/7pkszlZyybEceOL2iLacnFZgbflO82/5n3waOyNRZABCS XdNTvvw420roKJSlbySO1H0QBzQ/SWHPn9JiDXcDg73PWqshoLzJRODdELMFVFdBV2T2 xKC9+KQbRWs6V28ohYNrNOGprmUEd4uR6IUh//wxvYVsGQ7ygAj8j9WuoGZNk2iFQ3eY sooTo4RO7KYMKbdVC0pm0Vh6dvJeRsmwhqTub6635oDuAoc/KA4vNeBMijgF3euTOPhj EpJl9c/VCQL0EhsW9tFO5ojc58qPg3bO7bXMYveBdg+y06iAtezr9U90Gc2S+ewoE6Dy ohYw== X-Forwarded-Encrypted: i=1; AJvYcCW1BOiJcZttm4br/GeCy9Zxj176zMr/vXEyJCIPiD5FP9LIuyMEhS9ozgk5aunTPyyY8M0CXpkS@vger.kernel.org, AJvYcCXLdyFrVk4Uk4sCHs7HR1YwnLISFIcQ2SqS9STB9VW0WCuGaBziEXEdg4Bnkzt4if3XGebvJ7g0nCY=@vger.kernel.org X-Gm-Message-State: AOJu0YyDDvak+s+FhQle08PkZUPnv5LI/vysPgShHbe/+lXmWvOx5m5n PQaXtfDfzvmIvSBkt9iRdpUGALRGdyfyXMNkR62kBqL9EgL7KEEy3OW2wUfH X-Google-Smtp-Source: AGHT+IFU7UFJttX+KcE1oTziNc1qZYNE+s3S6bAIjvB4oNoLvLtEpLVN5RPTmcWc7kAdxo+cVTXAfQ== X-Received: by 2002:a17:902:ce86:b0:20c:cd01:79ae with SMTP id d9443c01a7336-211c0fc12a4mr2331485ad.24.1731519211658; Wed, 13 Nov 2024 09:33:31 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc7df5sm113140765ad.19.2024.11.13.09.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 09:33:30 -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 v5 6/7] net: devmem: add ring parameter filtering Date: Wed, 13 Nov 2024 17:32:20 +0000 Message-Id: <20241113173222.372128-7-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113173222.372128-1-ap420073@gmail.com> References: <20241113173222.372128-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 header-data-split-thresh value should be 0. Tested-by: Stanislav Fomichev Reviewed-by: Mina Almasry Signed-off-by: Taehee Yoo --- 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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net/core/devmem.c b/net/core/devmem.c index 11b91c12ee11..3425e872e87a 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,20 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx, return -ERANGE; } + if (!dev->ethtool_ops->get_ringparam) + return -EOPNOTSUPP; + + dev->ethtool_ops->get_ringparam(dev, &ringparam, &kernel_ringparam, + extack); + if (kernel_ringparam.tcp_data_split != ETHTOOL_TCP_DATA_SPLIT_ENABLED) { + NL_SET_ERR_MSG(extack, "tcp-data-split is disabled"); + return -EINVAL; + } + if (kernel_ringparam.hds_thresh) { + NL_SET_ERR_MSG(extack, "header-data-split-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 Nov 13 17:32:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13874042 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD018201106; Wed, 13 Nov 2024 17:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519222; cv=none; b=tCVQcf26+ecyxzzwSX7/hHmsK4VNe2EZPlet9HEv/uYalaaO1DPbcSUdhUfDjMRpvbEQchqfTlFWIseD/R7rr0iTtm2MOnhjor+8F+dOwse5z3fAIwUkmnBKQlQ83hh5JRMzw49uMu+qXY8Cs42TZDNqENF6jaLuRnxBv+3cBf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731519222; c=relaxed/simple; bh=Y7ggVn65s34L44hclSWqs9L7XSAELwhqhlkJzs+KwKU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UbMXmeBx/BWIJ7nOt7wE6DTsWaj8f+XxgFC5CeYO8sYCC5IhhY23ZxSNpOKsLC9a59/ehjqmD5q0HatEbI0U5rQP7bghBrQw2ElIGbupnCGR0oY6GJuBCmXj3DGZFbymwruNy3peN0CiilO9q6AtiAx53RBaAkVBjJvN+QjNmwg= 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=BEFv15SS; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BEFv15SS" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2113da91b53so53235335ad.3; Wed, 13 Nov 2024 09:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731519220; x=1732124020; 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=deUvSBZGMk9qIorja3waJc0OCGFfAoFCRG4VLMZ1kFI=; b=BEFv15SSOiuUM1+HjAJ9+eU7K8oCZP9JV1mCnAoloQPBhoORJ+N0frjJL8zpvu7jVy zxgaUNQHzxgNUi8Qp8JYw8fkTCPtLzFBVBY/0ZlQgJ9Df2ek8vvFyElZAydGKh1Ys3h/ 8yT8OEMXZ27c73UVTxflXyK521jjxYMUsR68Nyo1a8tDYaMMw8cPCqImweb/xe9mCHP2 s/boXxnR6GLglGeVSLfxualVNIbgJG+fXVBjY8Mb6jElOc4L7eHdhIWiex/JL8CqAYxc AMI5+aJC2EFZCZcmJ/8A0CxtpA+wXXKGYcvEa52WyYkNFC7qDOlQ/lPEgqxLucEEfQlt O2JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731519220; x=1732124020; 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=deUvSBZGMk9qIorja3waJc0OCGFfAoFCRG4VLMZ1kFI=; b=YoevnbyjY0yzGh3Ctlh3AYc28Dfo7/4ffyKz+Jjna/VGmZb6xrz23dM0FPUAkpt6Q0 DN7CQrxPllGs1YDvwK4djJSodecoy9VGDYfDCwr9Z+0YnuHDUGsEhizFlCzeBLz4QYdY O8ibRAHrZg3VwrTJhrEcuNaTrBeUvatdNiOp6OGNoQLj7mMhAgAPaDhLR9ROFCdnwDCg DUBbvI1Y9g8RIybrGHBppQE6MwZ0pkfgrk+KKexFrEcYHrugYNUlZeCwZGiO5+KD49lk EV7gbmZcfW6WUGi1oyf2bbkOcHkr4nd+Wf+n3qVppjvGN5kpeZsvVMXLwqkPfMrYVGrd JE5w== X-Forwarded-Encrypted: i=1; AJvYcCVZH6Mz6pNqBWHv1MUcYIazl2/mUxPJmgCnW2pQBOL5FUMt1J0A0ygwQFJDywdJ714BAkMCWesUwAQ=@vger.kernel.org, AJvYcCWVtrNraUpO3t4EpKYlIZnl02BfIVgvJCKWwNwNgsGDKmEWQnYErqBTN9yCd85xDrUFk/GE02/p@vger.kernel.org X-Gm-Message-State: AOJu0Yy+cmk++ltHeEdYlz1SBpckUb3kLLSacLhFHNkgbnJ5a1EGmA3p pW1aG2z+0ddY79zAt5KdptANvULJ7tLRWoucW+7JSSbr7nBF6QG2 X-Google-Smtp-Source: AGHT+IHdtEHciLFUClZY3RmcxL/NP2gFz+MEQyuFDZ5wCx0AxuicbQIW+OPt+YDqasSDlEUze0hIpA== X-Received: by 2002:a17:902:ce89:b0:20b:a10c:9bdf with SMTP id d9443c01a7336-21183d67d05mr307268665ad.32.1731519220204; Wed, 13 Nov 2024 09:33:40 -0800 (PST) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc7df5sm113140765ad.19.2024.11.13.09.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 09:33:39 -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 v5 7/7] net: ethtool: add ring parameter filtering Date: Wed, 13 Nov 2024 17:32:21 +0000 Message-Id: <20241113173222.372128-8-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113173222.372128-1-ap420073@gmail.com> References: <20241113173222.372128-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 header-data-split-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 --- 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 ca836aad3fa9..3f3be806c6c8 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -258,6 +258,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];