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 CBEB3A00BE; Thu, 17 Feb 2022 14:21:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CF3B4068B; Thu, 17 Feb 2022 14:21:14 +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 7C4F140042 for ; Thu, 17 Feb 2022 14:21:12 +0100 (CET) Received: by mail-io1-f53.google.com with SMTP id s20so11016ioe.4 for ; Thu, 17 Feb 2022 05:21:10 -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=ZYJLU+RR2PbEjptMjOc+9gW6V1rZUkF3h3Wa7L1Hemk=; b=GqVz27uHnTQpcuym08U6JsXsRK1eLrpHLYbPBwDLOjvqbt7p67lBdVZnk5tc3IFpFe tWe/q4dsFfq31zHQffu1KDpfTKWZ8xZ3+qWvlKf78myP7Ki+NTq7jttQ0NldXxpb8gYE ucmj05KkvUKw8ZrmFpS9teFOblpsr2Mm2f/PowTtdy6VEeWDtAmJQutYW5O9eFkWKMqK 2xF4o4Dg1RQEvf+0ua55voe7QvdAVQXIbsPKjBBd5yL8TEgzkax+mn2ow8QKhBIncw1T 3Nh0nzEzMkBHhPeA41FQWmKNkiN+HZgfVXkt0pPVaYJYI6GmHkVmjMgl76fvLkBy0GkD P6FA== 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=ZYJLU+RR2PbEjptMjOc+9gW6V1rZUkF3h3Wa7L1Hemk=; b=Z41UvQwgm+CBHa+nf+hb+fKpW/9gwur3GUptg+JTL+u4kgI2IONaR34MkC671A78FL RzvrOg6BVruNwsNe2yofKjekRbX1d1c/8VfPAy0rQEYURXUdcVqEkQ2fAAdXf8PMzdbN pTMzPVNRhNvdRJj1GDeeCHjWu7tTPwFlCfYKWSmVL+LN/vq+F5hd7Q4IU+4i3eF4r/Q0 1N0hCGP9HPagnFFOSupf+BBur/P/qzVmdpxZ/2mFcklO2M12cGVs5DCjanWs+/9Fa0a7 zEI9L5776+fYbfFByopvKtkRrSKW0sAYmjs5dk/9zLBXtCdu2GSQKcfIQWYZL4RCEEWG urYw== X-Gm-Message-State: AOAM531BsxgzD9o8F1mUtFZV7mZVwGFLh4/Gxveu3AdEQJrgtyo3I51p cqyuBNbSgY30S40vO3s1kfCTIvrwAlZfU8v9UBw= X-Google-Smtp-Source: ABdhPJyS3hitF33X2FzBrnBkSyK2IMGZ025aclnx/NysKWDPNreInFoS1rZkuBtSEpnSCwKU7qV6B+uKvDUNBLY2oGI= X-Received: by 2002:a05:6638:2608:b0:313:f4b2:1106 with SMTP id m8-20020a056638260800b00313f4b21106mr1898579jat.79.1645104065110; Thu, 17 Feb 2022 05:21:05 -0800 (PST) MIME-Version: 1.0 References: <20220207072932.22409-1-ndabilpuram@marvell.com> <20220207072932.22409-3-ndabilpuram@marvell.com> In-Reply-To: <20220207072932.22409-3-ndabilpuram@marvell.com> From: Jerin Jacob Date: Thu, 17 Feb 2022 18:50:39 +0530 Message-ID: Subject: Re: [PATCH 03/20] common/cnxk: adjust shaper rates to lower boundaries To: Nithin 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 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. > + } 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. > + } > + > + 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