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 1F077A034E; Tue, 22 Feb 2022 19:20:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DF5C41174; Tue, 22 Feb 2022 19:20:01 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id EB22840DF6 for ; Tue, 22 Feb 2022 19:19:54 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21MGu1wS025489; Tue, 22 Feb 2022 10:19:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pfpt0220; bh=75YjJ7yGuE86OPIPRDoLnrqxlLA4UroRIHdfr46gmU0=; b=BeB3D6RG59nKAN4caXgGUsT/nt8eTqdzqYfxptlYDbzi+eJhq+lDOja/GPYH53h7HH2E RouI91tknV2eJoJ0CAbvnBuAmdxAklmABc13g7cj6V8Q7ZbdoTSJgnnkSeOCXXoZnuBr SELatdiqXrRtvHpZRl3k29AJySRSHgHCNTLgTipxrlezUeNLr3+KxkLNX+h0BrofoUey jSG0LmmMBN2QI2GB5Mwfa6F7xLSoI3tY6rTQyge9lOa7yeLqv9vG/pOkeyWXI+nV4ESZ g5biW266Xy0L5sERrw2tjN2cXS3lh0fXXsxf8AWexdb80jWU+a1o8OYDVXMGJphe+qhv uA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3ecw9y2a0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 22 Feb 2022 10:19:54 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 22 Feb 2022 10:19:51 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 22 Feb 2022 10:19:51 -0800 Received: from [10.28.175.194] (PE-LT1350.marvell.com [10.28.175.194]) by maili.marvell.com (Postfix) with ESMTP id D4E1A3F7060; Tue, 22 Feb 2022 10:19:47 -0800 (PST) Message-ID: Date: Tue, 22 Feb 2022 23:49:46 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH 03/20] common/cnxk: adjust shaper rates to lower boundaries Content-Language: en-US To: Jerin Jacob CC: Jerin Jacob , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , dpdk-dev References: <20220207072932.22409-1-ndabilpuram@marvell.com> <20220207072932.22409-3-ndabilpuram@marvell.com> From: Nithin Kumar Dabilpuram In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: 8MGRZBAw0yHjM6LwZEivvD_fJSRlyOTg X-Proofpoint-ORIG-GUID: 8MGRZBAw0yHjM6LwZEivvD_fJSRlyOTg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-22_06,2022-02-21_02,2021-12-02_01 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 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 ? > > >> + } 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