From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3C8F8A034E; Tue, 22 Feb 2022 19:22:28 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2EC0440DF6; Tue, 22 Feb 2022 19:22:28 +0100 (CET) Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by mails.dpdk.org (Postfix) with ESMTP id B10E640DF4 for ; Tue, 22 Feb 2022 19:22:26 +0100 (CET) Received: by mail-io1-f53.google.com with SMTP id c14so17515709ioa.12 for ; Tue, 22 Feb 2022 10:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yHUmG78Ec4J06JezBEC3wGo+C/nBcXcF51g3KCgLCwI=; b=VK2Hel2YbNQ1IQpucC98rH198esoYUrquiv0PHmLX9BDUXmUe06Px2wMS/LOtU5Xj+ zGAw9k4piGQEbPH09CLVjjXQCe/DM1+k3nIfYvVgobz7qO3cf+h/Nb06sfrAsuJFK5e3 EwILvXuCJlwVH/LukcT3J2uqhc4bOsVch9O7kpcMQj7+jxQ2U/8zjgZg4NXgFXkG9ktT deVwJoXxHjrcC2kaviMsI0bDjmnu1owmyzAngRmC85CBvhns8CbSPYaj0Xp1m30cVDOm 91hV52DwbPFdyz0PQP0ryHFvtHLmJ9H3Yjb7oGaw/lTwwD7Mq6VUXgA9VdhcXkJNhwYv mYeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yHUmG78Ec4J06JezBEC3wGo+C/nBcXcF51g3KCgLCwI=; b=eN3I3XVM2C2mmDMX7/0udsFNGrMfH2YmCD53Xufp0EPxnXMVcORIQ/CTsllJCXGHZQ Ys1TdT/uSDHaMVBHJmKkTc7dAA6ZTd5V+2LFRBCNcaYm+fzlp4ACqLPsrCCV+Z6BDsb4 BVoZkINKmT10y6IUq3SLxNlAFg0a+glilRNnZXgLyD606AmXUcfhR3+T8LQX9cMgwQUw kkP+SWBbCwzTq4jEOF7B4EXBaTVhZUAVXwT5KEkZ9ih8/X5F0uOqa63N5K/BGaW91Ear raUOIqR5+Jmo+1bodD5VBIyf2qnJl9W5wJUAvF3F4aDd2j56BIxNB8XXHxjEwPhBgwZ+ PazQ== X-Gm-Message-State: AOAM533DRud8LJ+pXJLNj550+tok+XENawuTMqV780de49CxDOoB/DfI MmdoOWS2zTKlmDN8tTsEsHVQD5kp03Yv+1CLRiz2m7vj0Go= X-Google-Smtp-Source: ABdhPJyoVFG4bi4cv3EEhlQz+OwYBmaa+z/SQy/JES9xgk52nLq3NrkjvrwwrE4BvCGwKM5ZXW2zO+qM9U0NDnr7caU= X-Received: by 2002:a02:aca:0:b0:314:9da8:7be0 with SMTP id 193-20020a020aca000000b003149da87be0mr18654631jaw.280.1645554144932; Tue, 22 Feb 2022 10:22:24 -0800 (PST) MIME-Version: 1.0 References: <20220207072932.22409-1-ndabilpuram@marvell.com> <20220207072932.22409-3-ndabilpuram@marvell.com> In-Reply-To: From: Jerin Jacob Date: Tue, 22 Feb 2022 23:51:58 +0530 Message-ID: Subject: Re: [PATCH 03/20] common/cnxk: adjust shaper rates to lower boundaries To: Nithin Kumar Dabilpuram Cc: Jerin Jacob , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , dpdk-dev Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, Feb 22, 2022 at 11:49 PM Nithin Kumar Dabilpuram wrote: > > Please see inline. > > On 2/17/22 6:50 PM, Jerin Jacob wrote: > > On Mon, Feb 7, 2022 at 1:00 PM Nithin Dabilpuram > > wrote: > >> > >> From: Satha Rao > >> > >> New api to get floor values for a requested shaper rate, which can assure > > > > Since it is internal API, no need to mention in the comment log > > > >> packets should never be transmitted at a rate higher than configured. > >> > >> Keep the old api to get HW suggested values. > >> And introduce new parameter to select appropriate api. > > > > api -> API > > > >> > >> Signed-off-by: Satha Rao > >> --- > >> +static uint64_t > >> +nix_tm_shaper_rate_conv_floor(uint64_t value, uint64_t *exponent_p, > >> + uint64_t *mantissa_p, uint64_t *div_exp_p) > >> +{ > >> + uint64_t div_exp, exponent, mantissa; > >> + > >> + /* Boundary checks */ > >> + if (value < NIX_TM_MIN_SHAPER_RATE || value > NIX_TM_MAX_SHAPER_RATE) > >> + return 0; > >> + > >> + if (value <= NIX_TM_SHAPER_RATE(0, 0, 0)) { > >> + /* Calculate rate div_exp and mantissa using > >> + * the following formula: > >> + * > >> + * value = (2E6 * (256 + mantissa) > >> + * / ((1 << div_exp) * 256)) > >> + */ > >> + div_exp = 0; > >> + exponent = 0; > >> + mantissa = NIX_TM_MAX_RATE_MANTISSA; > >> + > >> + while (value <= (NIX_TM_SHAPER_RATE_CONST / (1 << div_exp))) > >> + div_exp += 1; > >> + > >> + while (value <= ((NIX_TM_SHAPER_RATE_CONST * (256 + mantissa)) / > >> + ((1 << div_exp) * 256))) > >> + mantissa -= 1; > > > > Please move this as another static function. > This is not same as the non-floor function though it looks same. The > while loops terminate in <= in this function. Do you still need sub > functions for these ? No. It is fine. > > > > > >> + } else { > >> + /* Calculate rate exponent and mantissa using > >> + * the following formula: > >> + * > >> + * value = (2E6 * ((256 + mantissa) << exponent)) / 256 > >> + * > >> + */ > >> + div_exp = 0; > >> + exponent = NIX_TM_MAX_RATE_EXPONENT; > >> + mantissa = NIX_TM_MAX_RATE_MANTISSA; > >> + > >> + while (value <= (NIX_TM_SHAPER_RATE_CONST * (1 << exponent))) > >> + exponent -= 1; > >> + > >> + while (value <= ((NIX_TM_SHAPER_RATE_CONST * > >> + ((256 + mantissa) << exponent)) / > >> + 256)) > >> + mantissa -= 1; > > > > Please move this as another static function. > Same comment as above. > > > >> + } > >> + > >> + if (div_exp > NIX_TM_MAX_RATE_DIV_EXP || > >> + exponent > NIX_TM_MAX_RATE_EXPONENT || > >> + mantissa > NIX_TM_MAX_RATE_MANTISSA) > >> + return 0; > >> + > >> + if (div_exp_p) > >> + *div_exp_p = div_exp; > >> + if (exponent_p) > >> + *exponent_p = exponent; > >> + if (mantissa_p) > >> + *mantissa_p = mantissa; > >> + > >> + /* Calculate real rate value */ > >> + return NIX_TM_SHAPER_RATE(exponent, mantissa, div_exp); > >> +} > >> + > >> +static uint64_t > >> +nix_tm_shaper_rate_conv_exact(uint64_t value, uint64_t *exponent_p, > >> + uint64_t *mantissa_p, uint64_t *div_exp_p) > >> { > >> uint64_t div_exp, exponent, mantissa; > >> > >> @@ -188,6 +251,23 @@ nix_tm_shaper_rate_conv(uint64_t value, uint64_t *exponent_p, > >> return NIX_TM_SHAPER_RATE(exponent, mantissa, div_exp); > >> } > >> > >> +/* With zero accuracy we will tune parameters as defined by HW, > >> + * non zero accuracy will keep the parameters close to lower values > >> + * and make sure long term shaper rate will not exceed requested rate. > > > > long-term > > requested -> the requested