From patchwork Wed Sep 11 14:55:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13800768 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 8EDD11AB6EF; Wed, 11 Sep 2024 14:56:20 +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=1726066582; cv=none; b=skTZvcHQ+ZATy861min0Jwte7NJ8+//YPjsK9xryfJmHzlKrYU8BmcrufvHLvX5sGAn4BhHjz52vmKffqgddMKgoT5SsD747aeTjkB7EufosmrJy4gZYcdb5YDduP44iBiX6/EV3OnMvc0WkQJB+DTnMlj9FJyNTbsJzEf55yQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726066582; c=relaxed/simple; bh=jNEuektr9cxfdgrOio3CsvBFVNok/dz37JrRSqsN358=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b9C+HgauIul40elv51YmT/TQYsjH31mQ6AG8uqluGpSR9oV9cg0tiEXyFUfNKHVtqRGY5letdnUu1Si8K+fi9PYFHO7KnCxfGco7DlgV3uL+a8zzjbSPjwXloAluS/mI6ZkeT9o5SK/JR6syEmIzh1qIzBjrrSNbG7K4UNKhhzk= 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=WbHCfzWQ; 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="WbHCfzWQ" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-718816be6cbso4874219b3a.1; Wed, 11 Sep 2024 07:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726066580; x=1726671380; 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=qNG2hx/XNKiQz0+4KMHEnpam4YQGht6jgnU1nTj2+2k=; b=WbHCfzWQpyN27vFvX6SrhXLcwNM2JKuHhgK8pnZIU0oY7bGT9OHNg53+K31gYVi6Gg rPjiudz9kbe2cCdLrIFyfNXfLNCVXAx+R6CLhvR2BVwZGCiCah0jIwl7yh1hx5WYBhhR ATTDr2DF7dxyfH3v7aVMGhwaokmOD4SAp4V+1j1QhYpeeBvs1jXE9lmWBB1HPAE5FdDm zc+PBysPnADF2z84kyelPZRqoABNQBFSqCK8eccRliWGdve8osbp+AmEpwHyqW8uRK6y FR/RQL13GESBOxoNPHgrRkRvUhZtgIWTj47jKJZxu3pQiBpnNL7T3u0qulV4ZFERyNEt Myjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726066580; x=1726671380; 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=qNG2hx/XNKiQz0+4KMHEnpam4YQGht6jgnU1nTj2+2k=; b=IIgI/OJq6TbqzMyIazxbGi3yEWl+QaaaxQLtAZApnYzQobFEBmVVUSzL1jMyV7khDY ymPxZDpShb1DbooltSrjnA7LQJ9oGFizhrM9dMUATXx5XlWPLARdwDqKw+S/uEGkPCuc MVwDcwiJzhkkTjnNyDrPDE+bP3KeNTEdufoNc/TQaKsuCIt2T7paxQXxokIz26bCUXz3 0A2SE6sxdAyMIUJ87+Qv/7LL24KDFGEugipnEFP/QbBPSuIDJ8240NhkiIl1iRGiGVjQ XP98WIFTDm95uWJxJV7/IoiWixdDIRfBq9jFCAf6U2wrSkmjjVSpIpaTBOpctertbbCc c0Gg== X-Forwarded-Encrypted: i=1; AJvYcCUOtdDFl+h27u/4cJcO6/gijywgFu9+wCIAMXhdJBg0vjuicb+zrVJZ8sOACjG3PNYj+1M1AGoGUyQ=@vger.kernel.org, AJvYcCVwAcCF+dCtlB5P2yKylgfMYTjZmxqwPiYdd+M8ubc+ERFWv4Zp8c/U+PZ8EkIfJs5+SJzoKhEj@vger.kernel.org X-Gm-Message-State: AOJu0Yx4pXQ4BCAIcERHN3D6LcTOloe3CNvsjiMzGQcjDtFy5GjDp5gO u5ESdBREQt/GHt7G6x1u/WgDO5rNWXHL1ccWgQpdZmN0eJ4E3Dg7 X-Google-Smtp-Source: AGHT+IF592StJiWtw7O0kU+OyBSfiXv3x72HMOLRbu9S4Pec2fG0HB5K/qEUwiIG4K6XKlH63YGDcg== X-Received: by 2002:a05:6a21:513:b0:1cf:337e:98f6 with SMTP id adf61e73a8af0-1cf5e13350amr4689266637.29.1726066579476; Wed, 11 Sep 2024 07:56:19 -0700 (PDT) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076af278aasm664995ad.28.2024.09.11.07.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 07:56:18 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, corbet@lwn.net, michael.chan@broadcom.com, netdev@vger.kernel.org, linux-doc@vger.kernel.org Cc: ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, andrew@lunn.ch, hkallweit1@gmail.com, kory.maincent@bootlin.com, ahmed.zaki@intel.com, paul.greenwalt@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, aleksander.lobakin@intel.com, ap420073@gmail.com Subject: [PATCH net-next v2 1/4] bnxt_en: add support for rx-copybreak ethtool command Date: Wed, 11 Sep 2024 14:55:52 +0000 Message-Id: <20240911145555.318605-2-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911145555.318605-1-ap420073@gmail.com> References: <20240911145555.318605-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`. Signed-off-by: Taehee Yoo --- v2: - Define max/vim rx_copybreak value. drivers/net/ethernet/broadcom/bnxt/bnxt.c | 24 ++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 6 ++- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 47 ++++++++++++++++++- 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 6e422e24750a..8da211e083a4 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 @@ -1330,13 +1329,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); @@ -1829,7 +1828,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); @@ -1931,6 +1930,7 @@ static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi, bnxt_vf_rep_rx(bp, skb); return; } + skb_record_rx_queue(skb, bnapi->index); napi_gro_receive(&bnapi->napi, skb); } @@ -2162,7 +2162,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 @@ -4451,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. */ @@ -4465,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; @@ -4510,7 +4514,8 @@ 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(bp->rx_copybreak + + NET_IP_ALIGN); rx_space = rx_size + NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); } @@ -6424,8 +6429,8 @@ 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->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); - req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); + req->jumbo_thresh = cpu_to_le16(bp->rx_copybreak); + 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); @@ -15864,6 +15869,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 69231e85140b..cff031993223 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -34,6 +34,10 @@ #include #endif +#define BNXT_DEFAULT_RX_COPYBREAK 256 +#define BNXT_MIN_RX_COPYBREAK 65 +#define BNXT_MAX_RX_COPYBREAK 1024 + extern struct list_head bnxt_block_cb_list; struct page_pool; @@ -2299,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 f71cc8188b4e..201c3fcba04e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -4319,6 +4319,49 @@ 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_MIN_RX_COPYBREAK || + rx_copybreak > BNXT_MAX_RX_COPYBREAK) + return -EINVAL; + if (rx_copybreak != bp->rx_copybreak) { + bp->rx_copybreak = rx_copybreak; + if (netif_running(dev)) { + bnxt_close_nic(bp, false, false); + bnxt_set_ring_params(bp); + bnxt_open_nic(bp, false, false); + } + } + 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, @@ -4769,7 +4812,7 @@ 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, bp->rx_copybreak); skb = netdev_alloc_skb(bp->dev, pkt_size); if (!skb) return -ENOMEM; @@ -5342,6 +5385,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 Sep 11 14:55:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13800769 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.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 3708A192B88; Wed, 11 Sep 2024 14:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726066588; cv=none; b=UQaPTGmVje2LZzZ7wyrymZwJBZ308GnTY7IsFMSyUjeE9mANTsgr7rLXH0K919+D47XDAebFRdtUjTWbtM8PhT4VfCbLIgRRwYdSWHSuNNWeU24yHDmY/aqnNIfsVlinJVot1QPh5XalDk4LywGEKvlor0NmDpg1Rw0lhGYYvWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726066588; c=relaxed/simple; bh=VlH9qghJ+ivGLa1Az3jXw3Wf8/BhZo7NkJYT/LbBYSM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Baw94MGCJPfEAgw729eYlrucTScb0OK80knv0SKVoADFbXuMHmU5KdgmpopGj+C+oyEhcIHHkQprt4iBHi0ykjTddkYx5pakYCiGqBco6242swIEXzOOSAlHMPuMj5DrTQ8O+b7p82+BUlzf11NLiznxL/h7k/KqzI1SfdKtJw4= 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=ghx53zQf; arc=none smtp.client-ip=209.85.215.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="ghx53zQf" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7d50b3a924bso2133309a12.0; Wed, 11 Sep 2024 07:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726066585; x=1726671385; 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=3TNx/nS63X+zv8pX/HRoQHqrSw4kohqQiIE/CxdrDUU=; b=ghx53zQfcMkrdwlR/Yta2N35BO8I8s2NunnoMK0ZfCWobXoxtIKMSPJk94QEe2/Kp3 0fwRnd/ai/Pe4i/2eNVVeYcAmCalTCLIdA8FOlThWzjqGe6u82+1JUCHq/RGhqjOinEP KPt4+fzm+3sFWElOTSu2TVnXQ9EyBTbwrn6w+UhaOVQtJ2xVFmTRAOq+k0WoVHth2Eyw 5SVk0iNIY1/VyCMWGhryoa8yU5uMw1MRVvvGIm8yTtGcGVWj/EasamQAmASt18N6l8f6 qxPjthz5KS887IzPn5P43G+tZlTupUrSMmgI1vyzT+Xu1eMQQ2khoFiK16ywfVrz4ynx 0cUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726066585; x=1726671385; 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=3TNx/nS63X+zv8pX/HRoQHqrSw4kohqQiIE/CxdrDUU=; b=iPDvJ/WiiABQ/33TLZR7gqBFPzs5bUTfEv6J5IfDxjNl8YRIQfk4LL3C2qdFrENKsD 9TkTAs1fzJRpS7/PF286VRMUIAziQRXSPlyuBEHNzI2BwU0kK97aVKtjY01+GH5pnRqQ P+o0+vCD/591Dj6gjXyCQfjoeXmd7/TPliMowTI1qec3lpU5tcOSP8b3CC17rdnM9RMM BHJ32Oh+vnskpvInXoG634rZSgzYOsl69vzzomCVFoSMp7MxnEpxf4U7Fvy0BuHLn/y5 Su7DCBzgx8AXRYsRasC7wq/6zBug1mDTldwd9nd6nYUSjiS4IurA3ZPIf8Drtrn/dh8H mc0w== X-Forwarded-Encrypted: i=1; AJvYcCUfxMKADH+v7EnylL+agj6wt1nh/QbMkPPaKWwmEk3SrdIe60zeFGDv82lE5radhd4mXERBOM0q@vger.kernel.org, AJvYcCVtTGcfvlDd8BuVwF1gOthyDGwO6q8jOy1Mo+g6YrJpa09A4RNSa2pKukk5DTDk+xZ8EhjTygP66ZU=@vger.kernel.org X-Gm-Message-State: AOJu0YxvjTKZaEANQkkd+oHBZ4w4j8Y/YSltjJ/CKwqpT7/e8LxABXdr H42KYfapEWIFl8u4Tz2sWvt29z8qnRrTzFvEWkpu/fsYn2FX/ZIN X-Google-Smtp-Source: AGHT+IGXBtI5qGItAG7ecCkJspCcWLlfdNiOgWezv9eulwnfJ2v+OFrjVd2dJtsMK9Zc989t8arvEA== X-Received: by 2002:a05:6a21:9201:b0:1cf:4da0:d95c with SMTP id adf61e73a8af0-1cf5e0aa0c7mr6793983637.23.1726066585393; Wed, 11 Sep 2024 07:56:25 -0700 (PDT) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076af278aasm664995ad.28.2024.09.11.07.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 07:56:24 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, corbet@lwn.net, michael.chan@broadcom.com, netdev@vger.kernel.org, linux-doc@vger.kernel.org Cc: ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, andrew@lunn.ch, hkallweit1@gmail.com, kory.maincent@bootlin.com, ahmed.zaki@intel.com, paul.greenwalt@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, aleksander.lobakin@intel.com, ap420073@gmail.com Subject: [PATCH net-next v2 2/4] bnxt_en: add support for tcp-data-split ethtool command Date: Wed, 11 Sep 2024 14:55:53 +0000 Message-Id: <20240911145555.318605-3-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911145555.318605-1-ap420073@gmail.com> References: <20240911145555.318605-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 or disable 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 but the will be automatically changed to . 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. Signed-off-by: Taehee Yoo --- v2: - Do not set hds_threshold to 0. drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 ++-- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 25 +++++++++++++++++-- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 8da211e083a4..f046478dfd2a 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->flags |= BNXT_FLAG_HDS; } /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must @@ -4474,7 +4475,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; @@ -6421,15 +6422,13 @@ 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 (bp->flags & BNXT_FLAG_HDS) { 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_copybreak); req->hds_threshold = cpu_to_le16(bp->rx_copybreak); } req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index cff031993223..35601c71dfe9 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 201c3fcba04e..ab64d7f94796 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -829,12 +829,16 @@ static void bnxt_get_ringparam(struct net_device *dev, if (bp->flags & BNXT_FLAG_AGG_RINGS) { ering->rx_max_pending = BNXT_MAX_RX_DESC_CNT_JUM_ENA; ering->rx_jumbo_max_pending = BNXT_MAX_RX_JUM_DESC_CNT; - kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_ENABLED; } else { ering->rx_max_pending = BNXT_MAX_RX_DESC_CNT; ering->rx_jumbo_max_pending = 0; - kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_DISABLED; } + + if (bp->flags & BNXT_FLAG_HDS) + kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_ENABLED; + else + kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_DISABLED; + ering->tx_max_pending = BNXT_MAX_TX_DESC_CNT; ering->rx_pending = bp->rx_ring_size; @@ -854,9 +858,25 @@ static int bnxt_set_ringparam(struct net_device *dev, (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) return -EINVAL; + if (kernel_ering->tcp_data_split != ETHTOOL_TCP_DATA_SPLIT_DISABLED && + BNXT_RX_PAGE_MODE(bp)) { + NL_SET_ERR_MSG_MOD(extack, "tcp-data-split can not be enabled with XDP"); + return -EINVAL; + } + if (netif_running(dev)) bnxt_close_nic(bp, false, false); + switch (kernel_ering->tcp_data_split) { + case ETHTOOL_TCP_DATA_SPLIT_UNKNOWN: + case ETHTOOL_TCP_DATA_SPLIT_ENABLED: + bp->flags |= BNXT_FLAG_HDS; + break; + case ETHTOOL_TCP_DATA_SPLIT_DISABLED: + bp->flags &= ~BNXT_FLAG_HDS; + break; + } + bp->rx_ring_size = ering->rx_pending; bp->tx_ring_size = ering->tx_pending; bnxt_set_ring_params(bp); @@ -5344,6 +5364,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 Sep 11 14:55:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13800770 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E5F98F6C; Wed, 11 Sep 2024 14:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726066593; cv=none; b=pPmK5ncwWN4P9sgxjHGoWshMiZzGEvesmQzCh0Rrtg7cs79oc7epfORmGRR+PAKiehEQrFYhJHO5ZYmFQtlpl+8BDxyyELNYZdbX2Hr7T2QlGAZdXNye9CAGHO165OZky990fzRvxi+b/1/HMGJik3Fr9VRHaxpjsiYjBV4uBWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726066593; c=relaxed/simple; bh=TsepaRUVqTPBrJWTJWlRwtVkvLU0gbrBfd/kfMa/mpc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YnubcofGvHYqscDUWNmAjy6Kq3frk7HSeVeySJ+hjXb8phd69mlfKZOMWQromFMLBcdX/oqfkAIWcfH8IfEWImI4Vx73wMa0oTklEKbs1pom72xRoFnBOPDPEn+NQq2JxujH4GlrTZYa96qzUNgO6zf5Zp+3cEsJ4E06QouoQsM= 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=LbJtDzXs; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LbJtDzXs" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7b0c9bbddb4so4739706a12.3; Wed, 11 Sep 2024 07:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726066591; x=1726671391; 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=mMvaqDQqcX/C936NjjZ0QVz9XsU/EnO54agZvR8BeDU=; b=LbJtDzXsTKkVE0q2c1rX6+jeZV5b04ru3If9q1De9orHrjHR5pfZXFIRuyeEm/505f AQT8bEWIjkaCgZWOtnwHitZ0kLUIOKgea6sJc53dCk79XVVcZ0MKRfZi3BdR0gEF6Eou wSn5Ua91Vh7upecn0d2sVtnwxB2wohrNDVghEqtkjZpkUT7/g1h9LTmWAi81O9qwcwsP jlRdc/7H1AMCDf/ohVmZlaGenHXcx8vXaICw65JWbvbJgISGC/e6W91SOCwm1O9PTTJv 9I2AzQFXXOJLzQpTToqPVtwTSRlzfXFF4JTPGPijfsPXkMxUJ6ifkMHHqgAsydOIjFKX noww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726066591; x=1726671391; 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=mMvaqDQqcX/C936NjjZ0QVz9XsU/EnO54agZvR8BeDU=; b=EmFPbEbh+nPHCoS/OTQsJMjGovM9SWimTcnIYfBZ4bOOw+BJgKuO/oa1cYxj3Ox0KO 60dSep789Q7OHraVenoPXoVBTZWsyv0Lur1UXC1m4AL9Sd55J1bcY1wp9BjuKIkEYzy7 b+uUK1kpmbB+PHDHzKkMrJCwbv4IvpwLUVc89SKOX7o5d8/Zy4GybD3yUrYy5I0+z3n4 tU7yLDW8X/huCICQNlV8Esvhchce3Ua4rV4kS3naAGpSTG0RFjgSnNhlUIXBWun+jkpw SDTkAueLGqqCGxRvoH5sWJoovPDYwtRaFQxiyzwLNKhSGFBt75uSCpwaiuVLrohoc5UI efFA== X-Forwarded-Encrypted: i=1; AJvYcCUcQmzLmsOcqs28vFdpHOWHJCdHfPnubr/TZlNAWKpcKAeaKCoCa5EgoZbwN7W5g91Qv9X8z57VdRk=@vger.kernel.org, AJvYcCUq4UHCeH/fKkX9Pa7wZkOajE+oKbSdWzZL+qlXP+HPLsCnQ4xvk8jrl28GZl8JFx7ZfmBExnL8@vger.kernel.org X-Gm-Message-State: AOJu0Yz5zLLrB/Oh1P+TJciGkVmOxW6RnBgnPtz1CmDI1Hu/0DuFoUpa gwuVKwXAM8y0dEuZjIdI5YrP715cY33ZUtj4yhes3KrrLgt9W7Gn X-Google-Smtp-Source: AGHT+IHju3npbPq1XRnA0GrL4E+R1Yn7NIh4rUPPw621oYKRA467TTDsmjP+QecK67UHhle5Q0alag== X-Received: by 2002:a17:902:db0f:b0:207:14e9:eb22 with SMTP id d9443c01a7336-2074c4c5622mr56584555ad.6.1726066591350; Wed, 11 Sep 2024 07:56:31 -0700 (PDT) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076af278aasm664995ad.28.2024.09.11.07.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 07:56:30 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, corbet@lwn.net, michael.chan@broadcom.com, netdev@vger.kernel.org, linux-doc@vger.kernel.org Cc: ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, andrew@lunn.ch, hkallweit1@gmail.com, kory.maincent@bootlin.com, ahmed.zaki@intel.com, paul.greenwalt@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, aleksander.lobakin@intel.com, ap420073@gmail.com Subject: [PATCH net-next v2 3/4] ethtool: Add support for configuring tcp-data-split-thresh Date: Wed, 11 Sep 2024 14:55:54 +0000 Message-Id: <20240911145555.318605-4-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911145555.318605-1-ap420073@gmail.com> References: <20240911145555.318605-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 tcp-data-split-thresh option configures the threshold value of the tcp-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 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, like the tcp-data-split option, If tcp-data-split-thresh is set, it affects UDP and TCP packets. The tcp-data-split-thresh has a dependency, that is tcp-data-split option. This threshold value can be get/set only when tcp-data-split option is enabled. Example: # ethtool -G tcp-data-split-thresh # ethtool -G enp14s0f0np0 tcp-data-split on tcp-data-split-thresh 256 # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... Current hardware settings: ... TCP data split: on TCP data split thresh: 256 The tcp-data-split is not enabled, the tcp-data-split-thresh will not be used and can't be configured. # ethtool -G enp14s0f0np0 tcp-data-split off # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... Current hardware settings: ... TCP data split: off TCP data split thresh: n/a The default/min/max values are not defined in the ethtool so the drivers should define themself. The 0 value means that all TCP and UDP packets' header and payload will be split. Users should consider the overhead due to this feature. Signed-off-by: Taehee Yoo --- v2: - Patch added. Documentation/networking/ethtool-netlink.rst | 31 +++++++++++-------- include/linux/ethtool.h | 2 ++ include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/netlink.h | 2 +- net/ethtool/rings.c | 32 +++++++++++++++++--- 5 files changed, 51 insertions(+), 17 deletions(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index ba90457b8b2d..bb74e108c8c1 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -892,6 +892,7 @@ 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_TCP_DATA_SPLIT_THRESH`` u32 threshold of TDS ======================================= ====== =========================== ``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` indicates whether the device is usable with @@ -927,18 +928,20 @@ 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_TCP_DATA_SPLIT_THRESH`` u32 threshold of TDS + ======================================= ====== =========================== Kernel checks that requested ring sizes do not exceed limits reported by driver. Driver may impose additional constraints and may not support all @@ -954,6 +957,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_TCP_DATA_SPLIT_THRESH`` specifies the threshold value of +tcp data split feature. If tcp-data-split is enabled and 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 12f6dc567598..5f3d0a231e53 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -78,6 +78,7 @@ 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 + * @tcp_data_split_thresh: Threshold value of tcp-data-split */ struct kernel_ethtool_ringparam { u32 rx_buf_len; @@ -87,6 +88,7 @@ struct kernel_ethtool_ringparam { u32 cqe_size; u32 tx_push_buf_len; u32 tx_push_buf_max_len; + u32 tcp_data_split_thresh; }; /** diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 283305f6b063..2be2d1840e7f 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -364,6 +364,7 @@ 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_TCP_DATA_SPLIT_THRESH, /* u32 */ /* add new constants above here */ __ETHTOOL_A_RINGS_CNT, diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 203b08eb6c6f..d8dad0d10c8d 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_TCP_DATA_SPLIT_THRESH + 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 b7865a14fdf8..0b68ea316815 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -61,7 +61,8 @@ 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_TCP_DATA_SPLIT_THRESH */ } static int rings_fill_reply(struct sk_buff *skb, @@ -108,7 +109,10 @@ 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))) || + (kr->tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED && + (nla_put_u32(skb, ETHTOOL_A_RINGS_TCP_DATA_SPLIT_THRESH, + kr->tcp_data_split_thresh)))) return -EMSGSIZE; return 0; @@ -130,6 +134,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_TCP_DATA_SPLIT_THRESH] = { .type = NLA_U32 }, }; static int @@ -155,6 +160,14 @@ ethnl_set_rings_validate(struct ethnl_req_info *req_info, return -EOPNOTSUPP; } + if (tb[ETHTOOL_A_RINGS_TCP_DATA_SPLIT_THRESH] && + !(ops->supported_ring_params & ETHTOOL_RING_USE_TCP_DATA_SPLIT)) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_RINGS_TCP_DATA_SPLIT_THRESH], + "setting TDS threshold 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,9 +209,9 @@ 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; + bool mod = false, thresh_mod = false; struct nlattr **tb = info->attrs; const struct nlattr *err_attr; - bool mod = false; int ret; dev->ethtool_ops->get_ringparam(dev, &ringparam, @@ -222,9 +235,20 @@ 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); - if (!mod) + ethnl_update_u32(&kernel_ringparam.tcp_data_split_thresh, + tb[ETHTOOL_A_RINGS_TCP_DATA_SPLIT_THRESH], + &thresh_mod); + if (!mod && !thresh_mod) return 0; + if (kernel_ringparam.tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_DISABLED && + thresh_mod) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_RINGS_TCP_DATA_SPLIT_THRESH], + "tcp-data-split-thresh can not be updated while tcp-data-split is disabled"); + 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 Sep 11 14:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 13800771 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C6D91AB52C; Wed, 11 Sep 2024 14:56:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726066600; cv=none; b=OtBsOKO+eSvqiuNWqUS2axM7MDHCei4m8Q5OVzBZseCpdDEZvdOhSJlYXTbd3xRvfxOVn1Eqj5Ij86explfmhSJK1dH9eMZ3PK6jdd+f6uw5yMZ+1PFIiJQzYRX4dy80sYRdk2s5N9+AUXsH20UCvhzdjLZFerfugigtrH1ncVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726066600; c=relaxed/simple; bh=EVKiSEr7Zmf+toAJhWkO8ac2WuWLD0rTI5Vk+3jNtCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t/RCEXsNXuq9/8n0qyCuZFXLA1kh1qmXd8KQkcc0g60kQKlpk37T+VPHO6BxR569GSysHw4fwi5GyxzJrU2PtoNxVrvip2RSEzfTKqsJjCa6msSMBPBEt+IbLgd8x9vmyWkwzTysmsdYbpK2bpZkypK8MyWLkVTZcN/St4YqSEk= 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=HNtevY0j; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HNtevY0j" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7179802b8fcso4995463b3a.1; Wed, 11 Sep 2024 07:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726066599; x=1726671399; 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=8APndETeuPsExoHgnwBfUz0vE90PM6EECgehWNUr71I=; b=HNtevY0jIiU9o5hv06Yk1J9NH2A4eO2OVVlYyYf9AfDrSo068m4GZbDRO+CJ8hmobc oh7Wc9rWKRZVuAChqgYwyJTNwEnzi/UwF19pjkbjcz+kuILVhwbDnPVCvT954ktQB4+3 t0XEdsUamP3osbd0WWrnvHSNG6ai9DPygKHSmRW/ZTCqQzU3pW79XiCAJPTGRgmDepb+ g+CF/QODVC5t+VrXyGnD8cA8eqSnRqF6Lf+9BeUVMzZnP2b0UOsKXymZDW7HeUU06cra b3Ub5Fn5Cr1EiLVRSFEGdL8bEDVCx5xgm2b+BHd0wLkzdXCttqowJFgXWGHzuKPfwqgL 60CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726066599; x=1726671399; 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=8APndETeuPsExoHgnwBfUz0vE90PM6EECgehWNUr71I=; b=AjW/VqC/iKh3oqS8o4ULAZ6C0RutKGkBE1XlPwQeIjPP/9SR/C6eql+l8tHEpRthIM YlNg6ZQA0xKjl8dejJqzrZCinF8ktWXSlqu+FdRxGh9THCgL/d8kkvE9knBe1iehOo8F cZAm55uWgAocY1hzCBRmzuDFC8sTe8bj6vzyKl5AzimxHOTIZiBe5PmqqCwnv2z6vp4p wYaRElwpqDQ3e+AhZN0U4vHsl1abSa2IW7ic5xAxSH3LLHz8Xben5Bqy603ttbXrq+xt HHtZzX6dn4sBKD1sNCUcc/owNvE3EEx5hXaBqHLr4wxL/39OIA3oKTa2Blv585cRBCPq lj+Q== X-Forwarded-Encrypted: i=1; AJvYcCWGOJho+gEdRdwrmEhDvdRyDeEbkg8iUkLAgUAhOXgq3Tjny/xrG5jRcvGl8H6BkXH88TuIijEcgRY=@vger.kernel.org, AJvYcCWzNBUSivbWKdRc94y7WoESDP6Hm9SoP2zAnMfoC7ugExQkPso14+6CGTgrBl/wcjsqYnMUUOez@vger.kernel.org X-Gm-Message-State: AOJu0Yxk5XIf3x6e9v7KYkbRJcCMg6XpYjnLN/hfhTH8Hr5lRZK6mqnu H9Q43z3YvP4CbQSUNeeTi3G7wbOHYGQ534GsEmOQmhjqQF8AdwL9 X-Google-Smtp-Source: AGHT+IGy9OSvr42m8WJ46ZATfSY9G59MIEIg3PMHu7SfwmYHtI8wBF7ebNJ9knnfQmsre2+z+7QF+A== X-Received: by 2002:a05:6a20:551f:b0:1cf:66a1:4d8e with SMTP id adf61e73a8af0-1cf66a14e2bmr3142494637.17.1726066598732; Wed, 11 Sep 2024 07:56:38 -0700 (PDT) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076af278aasm664995ad.28.2024.09.11.07.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 07:56:36 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, corbet@lwn.net, michael.chan@broadcom.com, netdev@vger.kernel.org, linux-doc@vger.kernel.org Cc: ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, andrew@lunn.ch, hkallweit1@gmail.com, kory.maincent@bootlin.com, ahmed.zaki@intel.com, paul.greenwalt@intel.com, rrameshbabu@nvidia.com, idosch@nvidia.com, maxime.chevallier@bootlin.com, danieller@nvidia.com, aleksander.lobakin@intel.com, ap420073@gmail.com Subject: [PATCH net-next v2 4/4] bnxt_en: add support for tcp-data-split-thresh ethtool command Date: Wed, 11 Sep 2024 14:55:55 +0000 Message-Id: <20240911145555.318605-5-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911145555.318605-1-ap420073@gmail.com> References: <20240911145555.318605-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 tcp-data-split-thresh ethtool command is added, so it adds an implementation of tcp-data-split-thresh option. Configuration of the tcp-data-split-thresh is allowed only when the tcp-data-split is enabled. The default value of tcp-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 tcp-data-split-thresh 256 # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... Current hardware settings: ... TCP data split: on TCP data split thresh: 256 It enables tcp-data-split and sets tcp-data-split-thresh value to 256. # ethtool -G enp14s0f0np0 tcp-data-split off # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... Current hardware settings: ... TCP data split: off TCP data split thresh: n/a Signed-off-by: Taehee Yoo --- 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 | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index f046478dfd2a..872b15842b11 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4455,6 +4455,7 @@ static void bnxt_init_ring_params(struct bnxt *bp) { bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK; bp->flags |= BNXT_FLAG_HDS; + 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 35601c71dfe9..48f390519c35 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2311,6 +2311,8 @@ struct bnxt { int rx_agg_nr_pages; int rx_nr_rings; int rsscos_nr_ctxs; +#define BNXT_HDS_THRESHOLD_MAX 256 + u16 hds_threshold; u32 tx_ring_size; u32 tx_ring_mask; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index ab64d7f94796..5b1f3047bf84 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -839,6 +839,8 @@ static void bnxt_get_ringparam(struct net_device *dev, else kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_DISABLED; + kernel_ering->tcp_data_split_thresh = bp->hds_threshold; + ering->tx_max_pending = BNXT_MAX_TX_DESC_CNT; ering->rx_pending = bp->rx_ring_size; @@ -864,6 +866,12 @@ static int bnxt_set_ringparam(struct net_device *dev, return -EINVAL; } + if (kernel_ering->tcp_data_split_thresh > BNXT_HDS_THRESHOLD_MAX) { + NL_SET_ERR_MSG_MOD(extack, + "tcp-data-split-thresh size too big"); + return -EINVAL; + } + if (netif_running(dev)) bnxt_close_nic(bp, false, false); @@ -871,6 +879,7 @@ static int bnxt_set_ringparam(struct net_device *dev, case ETHTOOL_TCP_DATA_SPLIT_UNKNOWN: case ETHTOOL_TCP_DATA_SPLIT_ENABLED: bp->flags |= BNXT_FLAG_HDS; + bp->hds_threshold = (u16)kernel_ering->tcp_data_split_thresh; break; case ETHTOOL_TCP_DATA_SPLIT_DISABLED: bp->flags &= ~BNXT_FLAG_HDS;