Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 537D0ECAAD2 for ; Mon, 29 Aug 2022 07:20:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CF1BB408AA; Mon, 29 Aug 2022 07:20:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org CF1BB408AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1661757601; bh=dkxOI/uEljBPbQyZOT7lkp/Xua9SdRKOB7hflmlpMRo=; h=From:To:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=ck7FQOERP7DnI3m4RZCFNAkTlKPxOHKthg/Kte5AtZACzdfo5BXKuQMwJzx8/7ALN 9JFtFp+fUXXBpr6qZEjJcHzGlZ1Nqtd9qAoyTOvUpIxLOB5bjLrcYvob5qDgRtzjp1 brFcNL2ipTUMCQJthZBT3y2d4OgVY0nNvtiTCtoFT5q5P89az/18b3IucfhdyBIRlL lAfS2uBSwmPA0VGO3zvaEmKOv8nr6wA8dl8YDm3JeQdUL6CZS/wEo1QA5r18Qi7enP i5klMK0DQPdYKlWqI7O27dGgb6aWk96759mqlF6Yxz1Y8nhHfP6qdREHhCJazVrqyJ REtdVBhutulCQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9ax3AZtxpxdS; Mon, 29 Aug 2022 07:20:00 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 8AA2140896; Mon, 29 Aug 2022 07:20:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8AA2140896 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 2951E1BF2FB for ; Mon, 29 Aug 2022 07:19:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 02A9D60B77 for ; Mon, 29 Aug 2022 07:19:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 02A9D60B77 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8AYX_ewcyULw for ; Mon, 29 Aug 2022 07:19:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8AF3560B1E Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by smtp3.osuosl.org (Postfix) with ESMTPS id 8AF3560B1E for ; Mon, 29 Aug 2022 07:19:54 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10453"; a="281801214" X-IronPort-AV: E=Sophos;i="5.93,272,1654585200"; d="scan'208";a="281801214" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2022 00:19:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,272,1654585200"; d="scan'208";a="939477224" Received: from amlin-019-225.igk.intel.com ([10.102.19.225]) by fmsmga005.fm.intel.com with ESMTP; 29 Aug 2022 00:19:30 -0700 From: Andrii Staikov To: intel-wired-lan@lists.osuosl.org Date: Mon, 29 Aug 2022 09:19:24 +0200 Message-Id: <20220829071924.278755-1-andrii.staikov@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661757594; x=1693293594; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2yrBJBMZqmUcgemi3jUMLpaagavgDVHQ/ild+0IPoC4=; b=gqfw85sslCYVQs7vLVeMffpFSB/KTrgH6Bel21HfmRGaxYubpOD7sEmJ y4I/5cmB/Qlxw7DtozVVpBBaxAMWPwGQvqRFH970G6xjz0NbiwT3umkz8 GS0RQcPqt0wecTyxDIusQf+VxnFPNgYm5BuRRlHNxtnvvGtHIEsg5rrsY epheXKeHpGv9e+oyiyNhGYpPIFvYWLiAB5VgYAXf+0O5g4VfxKqTvJzb0 rtn5fPD21WVrCy/pnwghv6zJCmuQ3ehIarZTl6C2EjgZTtM71JeXcBwXk oqAlRQYYaUdkOg4T9GJCUp0Y4gPZafbchVxxQE9HbMDTU7q6mBJxccXMk Q==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=gqfw85ss Subject: [Intel-wired-lan] [PATCH net v3] i40e: Fix set max_tx_rate when it is lower than 1 Mbps X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Jaron , Andrii Staikov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Michal Jaron Value max_tx_rate is converted from bytes to Mbps. When max_tx_rate was set to lower than 125000 bytes (1 Mbps) it was cut to 0 because of this conversion. The visual behavior without this fix: qdisc mqprio 8057: root tc 3 map 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 queues:(0:1) (2:3) (4:5) mode: channel shaper:bw_rlimit max_rate:10Kbit 10Kbit 10Kbit qdisc fq_codel 0: parent 8057:6 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn qdisc fq_codel 0: parent 8057:5 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn qdisc fq_codel 0: parent 8057:4 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn qdisc fq_codel 0: parent 8057:3 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn qdisc fq_codel 0: parent 8057:2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn qdisc fq_codel 0: parent 8057:1 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn qdisc ingress ffff: parent ffff:fff1 ---------------- Add a check that if max_tx_rate is lower than 1 Mbps set this to minimum usable value of 50 Mbps. Add defined constants. Fixes: 5ecae4120a6b ("i40e: Refactor VF BW rate limiting") Signed-off-by: Michal Jaron Signed-off-by: Andrii Staikov --- v3: Providing the visual behavior without the fix. --- v2: Changing author, adding fixes tag, changing commit message. --- drivers/net/ethernet/intel/i40e/i40e_main.c | 32 +++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 10c1e1ea83a1..e3d9804aeb25 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -5908,6 +5908,26 @@ static int i40e_get_link_speed(struct i40e_vsi *vsi) } } +/** + * i40e_bw_bytes_to_mbits - Convert max_tx_rate from bytes to mbits + * @vsi: Pointer to vsi structure + * @max_tx_rate: max TX rate in bytes to be converted into Mbits + * + * Helper function to convert units before send to set BW limit + **/ +static u64 i40e_bw_bytes_to_mbits(struct i40e_vsi *vsi, u64 max_tx_rate) +{ + if (max_tx_rate < I40E_BW_MBPS_DIVISOR) { + dev_warn(&vsi->back->pdev->dev, + "Setting max tx rate to minimum usable value of 50Mbps.\n"); + max_tx_rate = I40E_BW_CREDIT_DIVISOR; + } else { + do_div(max_tx_rate, I40E_BW_MBPS_DIVISOR); + } + + return max_tx_rate; +} + /** * i40e_set_bw_limit - setup BW limit for Tx traffic based on max_tx_rate * @vsi: VSI to be configured @@ -5930,10 +5950,10 @@ int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate) max_tx_rate, seid); return -EINVAL; } - if (max_tx_rate && max_tx_rate < 50) { + if (max_tx_rate && max_tx_rate < I40E_BW_CREDIT_DIVISOR) { dev_warn(&pf->pdev->dev, "Setting max tx rate to minimum usable value of 50Mbps.\n"); - max_tx_rate = 50; + max_tx_rate = I40E_BW_CREDIT_DIVISOR; } /* Tx rate credits are in values of 50Mbps, 0 is disabled */ @@ -8224,9 +8244,9 @@ static int i40e_setup_tc(struct net_device *netdev, void *type_data) if (i40e_is_tc_mqprio_enabled(pf)) { if (vsi->mqprio_qopt.max_rate[0]) { - u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0]; + u64 max_tx_rate = i40e_bw_bytes_to_mbits(vsi, + vsi->mqprio_qopt.max_rate[0]); - do_div(max_tx_rate, I40E_BW_MBPS_DIVISOR); ret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate); if (!ret) { u64 credits = max_tx_rate; @@ -10971,10 +10991,10 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) } if (vsi->mqprio_qopt.max_rate[0]) { - u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0]; + u64 max_tx_rate = i40e_bw_bytes_to_mbits(vsi, + vsi->mqprio_qopt.max_rate[0]); u64 credits = 0; - do_div(max_tx_rate, I40E_BW_MBPS_DIVISOR); ret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate); if (ret) goto end_unlock; -- 2.25.1 _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan