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 smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 88B8DC25B0E for ; Tue, 16 Aug 2022 12:57:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 154A140390; Tue, 16 Aug 2022 12:57:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 154A140390 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1660654642; bh=Ofa404LGlkK0oqbwZ7ThT0kkV4hhQjNGEv1cFf5OIxE=; h=From:To:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=HBlbQNf2/LOdxo0OwJafQxP+9TfLnNQa8vkjw1zTz2iXk8ytYtsvrWlbgRpuoznv0 rmwJ/XX60GH85MMoywODmqhqco7DNdQtbCnqQvS2YUtQONX1QOGo/dEjwNKUBiNU5a owCnmxaksXn5xmpOU+vmq9uI0uSQKYDhZfa3hvG3s854rpALXV8R3C6GQ4v5fKWcGo jetu2ix7ihlHcV3pqUfjdlDJRWPohJlFU833HT9xWAiP6ZTGtAfHUJeo/ayjXR4naZ axrIJbQK89c21QbxaMWpESE5QX110mzmXHdb5EM1qbKooHp98tMCnKUatDm3WlUsS0 CQJsOPfhdnXWA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q6UPDe5Y_u4i; Tue, 16 Aug 2022 12:57:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 6095040531; Tue, 16 Aug 2022 12:57:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6095040531 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 287EC1BF31D for ; Tue, 16 Aug 2022 07:29:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id F0C544091E for ; Tue, 16 Aug 2022 07:29:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org F0C544091E 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 NgP1tBOLCmL2 for ; Tue, 16 Aug 2022 07:29:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C255E4090C Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by smtp4.osuosl.org (Postfix) with ESMTPS id C255E4090C for ; Tue, 16 Aug 2022 07:29:43 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6400,9594,10440"; a="292944744" X-IronPort-AV: E=Sophos;i="5.93,240,1654585200"; d="scan'208";a="292944744" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 00:29:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,240,1654585200"; d="scan'208";a="934793396" Received: from amlin-019-225.igk.intel.com ([10.102.19.225]) by fmsmga005.fm.intel.com with ESMTP; 16 Aug 2022 00:29:40 -0700 From: Andrii Staikov To: intel-wired-lan@lists.osuosl.org Date: Tue, 16 Aug 2022 11:43:44 +0200 Message-Id: <20220816094344.3500-1-andrii.staikov@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Aug 2022 12:57:18 +0000 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=1660634983; x=1692170983; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=z8nwwDvpHYWk50SsGTQHcGuGXbq95Du6gLc/t85PD5Y=; b=S+Zx766iKBF5AoqqcEnuQNzguNaw71EPAF9y20FLpzUsfFRxygz7ccyb azrCmH73Q01hWVHypP4xyl5Lkkrs6OnO/j+9grrQ6nPSzRt2XaL+GUK5R DViSVYVGwmxVVvPfCUO9jAOF0osZjFVxWydiV+P/KShDAwxAvHS2nwxPS plDhwCOCFLEZmgVDM/g/k1XQ25pMMEhBpWWyXYfRfajo1ymrGuyb3FidC hb6xehrOIUITfv/vxkjonWQV5pvvmQjCsXFTSAqz6Zm0EaS6SoDjc+yQ9 wlTP3+LYbIdWyF2Nusc0mDLCDKjr1rDM+tWiRA9ABY3q26g2cdkP++fKh w==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=S+Zx766i Subject: [Intel-wired-lan] [PATCH net-next v1] 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" 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. 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. bats=yes Title: i40e: Fix set max_tx_rate when it is lower than 1 Mbps Change-type: DefectResolution HSDES-Number: 16013332829 HSDES-Tenant: server_platf_lan.bug Signed-off-by: Michal Jaron Signed-off-by: Andrii Staikov --- 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