From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0048.outbound.protection.outlook.com [104.47.42.48]) by dpdk.org (Postfix) with ESMTP id 3302F2C2F for ; Mon, 4 Sep 2017 16:55:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=SwBUhaxKvc34AVOTShyQ2j97drbukmx3Xi5dC0ve5Bc=; b=nkd/hqvcUByoWuQDc1flj4TAjAo8+lLAMD/c+jMBTxnyzv6PLPt2ZYtMjqoajy6JWlXgLcFr3q2YkjF3F8NqJNWNOEAqPgXaPyYKCvRzCwRvB7pIfTbOOmkqEq5AI9n5UiPDQwRENal4WpY05jx3+9sZYk5vl6dKvlrn5ZGas20= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from PBHAGAVATULA-LT (111.93.218.67) by BN6PR07MB3460.namprd07.prod.outlook.com (10.161.153.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Mon, 4 Sep 2017 14:55:42 +0000 Date: Mon, 4 Sep 2017 20:25:17 +0530 From: Pavan Nikhilesh Bhagavatula To: "Burakov, Anatoly" Cc: dev@dpdk.org Message-ID: <20170904145515.GA6181@PBHAGAVATULA-LT> References: <1504442189-4384-1-git-send-email-pbhagavatula@caviumnetworks.com> <1504442189-4384-2-git-send-email-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR01CA0100.INDPRD01.PROD.OUTLOOK.COM (10.174.208.16) To BN6PR07MB3460.namprd07.prod.outlook.com (10.161.153.23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9acba37-50c6-4f09-be2f-08d4f3a50490 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN6PR07MB3460; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3460; 3:xEh7W1jvCIJjAKIfe5PhpJvaXWekSGpZWRMhkPmxSGeP1co3WO3+I61GofDgqfRLdlVYUBVJt+EilhFBYyWsiUcZeo+AKtGjSnnkOo6ih0w4TUP3X7tR76hK8BKldhHYw7ZO7cy7k1ZqXTUzHSAJZh9uMo/nNN3MISHPpiqb/X1Lmjd5q6gPBVFPo/PzFZ6UOzpkOVN1f257EgHXpJGeMGjlpx5MeOIBEdjGdjXbCwai+/eEef4XgjVb/leFHmnn; 25:phnRll3cbNEQP0t0dK634yJ5l9pRIh3tvN3gIu+tlvJF7dzK8gf5OgdVl7DtwTXSbszj5Ar770B6X5Wu/wjl1LDxFyjrUlMoy3aI/Z/3+y1KpmryaSHWxG/W5agh1bjAiEJew3nZrx1Tm+ApucqKItSnfjZJEhRDCxdeLmYhjeY+hd2gG50FfUohJLt7J0GAu3TUojUjy3R952ZxgOMqdDInPczK/1EvfKglHkHUU9SNepJP9r9Lw6k4GGN2dg8e50ASmSWNEXL2wFdr+b4+DNOkMr/KJHqhqbc4bSWD3oqhd+RfS70B1uoyHYZk2ZLyM3Adonak5+pPnH6jmn8fpw==; 31:cEKQuFRwW+0Xm/gGasNY+hO8HwP6TlwVEUj3wa1x//yeSbrpEkc3CWtbV6fKYhehvupg+NiZdRYHJ9rjU6vWmhkrKIjAx92lAHQtve275hDTh36TN3rNFMMfPzFeWWpdU1+l4NVHYE+60fShM8wTNoiVuwN5S3zLsSqGUXwVkP+ZCzO47Truwk/rfcBEexyWoLWT/MIsc5/WatXpXS+kiyexjopBUSARXoD9LC1zoF4= X-MS-TrafficTypeDiagnostic: BN6PR07MB3460: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3460; 20:9cXm0CE0ztAV8HaQr25GFm7KKYydD38/p2P/iake0yPcEE+cWREdqvaSm10Ov5M8fh530ylU59/gSEysZsMSv3JvCb2RDOlbceDC8m/XSx9xsl5KXXJfsTSgMBddQwZf826ZyFldoUgHAnSdkdG+3vBZYTGq1sMWv4d8Uzhwka1KOHIEmk7RURpxWeOuvLXf250018goD/2vXZz6TfkBtztfAOt8EvlR3b06dQehlZdskdvf58LtC7trWCMHDg8CwFuElXozOrIiWxqks7U5YtDYax/vhEX7m9tSYt/j0GN6s7M5T47K9cYlqCXEAa7SXcePUfOcu94d++yIBJKxVvDnk3K+K6mkbfwwFh6bV6mteIGqPlbizberR/SkwoiHVe6SglrG/g88NYEjqi4zZUEjNRN/6tQfiRAJK9SURDZZJJQL3hai7Y9V+R+QeVtyx8ou29ZBRZ7Xim62EPSFVt6FYVRVd6jEDVlAGDzuAMbuhnVo/FUB/AoSyGQQ0NXbUqHVhqgyXaK47ja9+aaaNXuxjvq4wHVu/Uld6WoPQtfGB5KXJZpHM1kVk26FiE1tPJAKJ/JNz3xfsXiVZsOjb1Ktn4KJbHJ6whERUMDTBgo=; 4:TdoxtHu4ZZXOQo3Jkk6e95cbEkQnOlKjgKdBfGbkQjiYS12P46CYuX7BkznRiS0eMQlpE1ocX+Z/9NKO6RUaulxaw078QtoHCFKhK8rawvoQdeQQwTSEutqGWhncwMpwl+kNGmD01XXSTvYGUwotadfawRfFfGpgvctDdl/wdxG6rcf+QmMa6qf2WOT1XVRxKb2+Nx7xG61Hvppz0PkYQbKiLWYQYYfW7Sp4DRrAF8MGj14jv/b6NhpFNOumqfNlMbUevgQ12KHrx/FLFDm7mbjrkO3hIPhMaOBBYsf3U8w= X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(100000703101)(100105400095)(6041248)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR07MB3460; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR07MB3460; X-Forefront-PRVS: 0420213CCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(24454002)(377454003)(51914003)(199003)(189002)(8676002)(6116002)(966005)(2906002)(33716001)(3846002)(7736002)(101416001)(110136004)(50986999)(53546010)(8936002)(50466002)(53936002)(305945005)(97736004)(1076002)(23726003)(81156014)(42882006)(81166006)(6916009)(2950100002)(105586002)(83506001)(6666003)(229853002)(25786009)(4326008)(5660300001)(68736007)(5009440100003)(72206003)(33656002)(106356001)(55016002)(575784001)(47776003)(66066001)(4001350100001)(6246003)(76176999)(54356999)(9686003)(478600001)(6496005)(6306002)(189998001)(42186005)(18370500001)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3460; H:PBHAGAVATULA-LT; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR07MB3460; 23:ufgVGuc69VTFm9E8mKo+facwGszvt3P3BTLugoy8z?= =?us-ascii?Q?VvfizhqOh8SNoYbZDVT0YjgUZZ75VBykWpMUs69CTkeHp7g7h/hWD9SMoPBX?= =?us-ascii?Q?hCrIbzRHYF8jwzRROH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vPmQ4zxcQo3GX/zlFUy7s/yV4c7weQifg/3THZwM+Pj8c37RiMms=; 7:M9ijkLDERSuiupmnHpjPYcEij00tUuDUGenMyGn9NVTocC15jOLjy3OQAsYYmkDYNS5ksmHKR4dunAzcoebz+Ok55VaaoR8W3ek8SPaO/y4HoIhPlKuDbwhtbK4jO3xnI6Yt2E9ZWxh2/uwreGFDzk+ZzuKU67Z7PgUjBzHgIstQPBS+JVb9mEotEx4fbymnfSnsU3PfY6XAW/GVWgi2DAf7XRbmrhAa55wbfp9k6C0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2017 14:55:42.8143 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3460 Subject: Re: [dpdk-dev] [PATCH v3 2/3] eal: add u64 bit variant for reciprocal X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Sep 2017 14:55:47 -0000 On Mon, Sep 04, 2017 at 02:34:49PM +0000, Burakov, Anatoly wrote: > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pavan Nikhilesh > > Sent: Sunday, September 3, 2017 1:36 PM > > To: dev@dpdk.org > > Cc: Dumitrescu, Cristian ; > > stephen@networkplumber.org; Pavan Nikhilesh > > > > Subject: [dpdk-dev] [PATCH v3 2/3] eal: add u64 bit variant for reciprocal > > > > Currently, rte_reciprocal only supports unsigned 32bit divisors. This commit > > adds support for unsigned 64bit divisors. > > > > Rename unsigned 32bit specific functions appropriately and update > > librte_sched accordingly. > > > > Signed-off-by: Pavan Nikhilesh > > --- > > lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 +- > > lib/librte_eal/common/include/rte_reciprocal.h | 111 > > ++++++++++++++++++++-- > > lib/librte_eal/common/rte_reciprocal.c | 120 > > +++++++++++++++++++++--- > > lib/librte_eal/linuxapp/eal/rte_eal_version.map | 3 +- > > lib/librte_sched/Makefile | 4 +- > > lib/librte_sched/rte_sched.c | 9 +- > > 6 files changed, 222 insertions(+), 28 deletions(-) > > > > diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map > > b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > > index d0bda66..5fd6101 100644 > > --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map > > +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > > @@ -242,6 +242,7 @@ EXPERIMENTAL { > > DPDK_17.11 { > > global: > > > > - rte_reciprocal_value; > > + rte_reciprocal_value_u32; > > + rte_reciprocal_value_u64; > > > > } DPDK_17.08; > > diff --git a/lib/librte_eal/common/include/rte_reciprocal.h > > b/lib/librte_eal/common/include/rte_reciprocal.h > > index b6d752f..801d1c8 100644 > > --- a/lib/librte_eal/common/include/rte_reciprocal.h > > +++ b/lib/librte_eal/common/include/rte_reciprocal.h > > @@ -22,22 +22,117 @@ > > #ifndef _RTE_RECIPROCAL_H_ > > #define _RTE_RECIPROCAL_H_ > > > > -#include > > +#include > > > > -struct rte_reciprocal { > > +/** > > + * Unsigned 32-bit divisor structure. > > + */ > > +struct rte_reciprocal_u32 { > > uint32_t m; > > uint8_t sh1, sh2; > > -}; > > +} __rte_cache_aligned; > > + > > +/** > > + * Unsigned 64-bit divisor structure. > > + */ > > +struct rte_reciprocal_u64 { > > + uint64_t m; > > + uint8_t sh1; > > +} __rte_cache_aligned; > > > > +/** > > + * Divide given unsigned 32-bit integer with pre calculated divisor. > > + * > > + * @param a > > + * The 32-bit dividend. > > + * @param R > > + * The pointer to pre calculated divisor reciprocal structure. > > + * > > + * @return > > + * The result of the division > > + */ > > static inline uint32_t > > -rte_reciprocal_divide(uint32_t a, struct rte_reciprocal R) > > +rte_reciprocal_divide_u32(uint32_t a, struct rte_reciprocal_u32 *R) { > > + uint32_t t = (((uint64_t)a * R->m) >> 32); > > + > > + return (t + ((a - t) >> R->sh1)) >> R->sh2; } > > + > > +static inline uint64_t > > +mullhi_u64(uint64_t x, uint64_t y) > > +{ > > +#ifdef __SIZEOF_INT128__ > > + __uint128_t xl = x; > > + __uint128_t rl = xl * y; > > + > > + return (rl >> 64); > > +#else > > + uint64_t u0, u1, v0, v1, k, t; > > + uint64_t w1, w2; > > + uint64_t whi; > > + > > + u1 = x >> 32; u0 = x & 0xFFFFFFFF; > > + v1 = y >> 32; v0 = y & 0xFFFFFFFF; > > + > > + t = u0*v0; > > + k = t >> 32; > > + > > + t = u1*v0 + k; > > + w1 = t & 0xFFFFFFFF; > > + w2 = t >> 32; > > + > > + t = u0*v1 + w1; > > + k = t >> 32; > > + > > + whi = u1*v1 + w2 + k; > > + > > + return whi; > > +#endif > > +} > > + > > +/** > > + * Divide given unsigned 64-bit integer with pre calculated divisor. > > + * > > + * @param a > > + * The 64-bit dividend. > > + * @param R > > + * The pointer to pre calculated divisor reciprocal structure. > > + * > > + * @return > > + * The result of the division > > + */ > > +static inline uint64_t > > +rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R) > > { > > - uint32_t t = (uint32_t)(((uint64_t)a * R.m) >> 32); > > + uint64_t q = mullhi_u64(R->m, a); > > + uint64_t t = ((a - q) >> 1) + q; > > > > - return (t + ((a - t) >> R.sh1)) >> R.sh2; > > + return t >> R->sh1; > > } > > > > -struct rte_reciprocal > > -rte_reciprocal_value(uint32_t d); > > +/** > > + * Generate pre calculated divisor structure. > > + * > > + * @param d > > + * The unsigned 32-bit divisor. > > + * > > + * @return > > + * Divisor structure. > > + */ > > +struct rte_reciprocal_u32 > > +rte_reciprocal_value_u32(uint32_t d); > > + > > +/** > > + * Generate pre calculated divisor structure. > > + * > > + * @param d > > + * The unsigned 64-bit divisor. > > + * > > + * @return > > + * Divisor structure. > > + */ > > +struct rte_reciprocal_u64 > > +rte_reciprocal_value_u64(uint64_t d); > > > > #endif /* _RTE_RECIPROCAL_H_ */ > > diff --git a/lib/librte_eal/common/rte_reciprocal.c > > b/lib/librte_eal/common/rte_reciprocal.c > > index 7ab99b4..5d7e367 100644 > > --- a/lib/librte_eal/common/rte_reciprocal.c > > +++ b/lib/librte_eal/common/rte_reciprocal.c > > @@ -31,18 +31,13 @@ > > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > > DAMAGE. > > */ > > > > -#include > > -#include > > - > > -#include > > - > > -#include "rte_reciprocal.h" > > +#include > > > > /* find largest set bit. > > * portable and slow but does not matter for this usage. > > */ > > static inline int > > -fls(uint32_t x) > > +fls_u32(uint32_t x) > > { > > int b; > > > > @@ -54,21 +49,120 @@ fls(uint32_t x) > > return 0; > > } > > > > -struct rte_reciprocal > > -rte_reciprocal_value(uint32_t d) > > +struct rte_reciprocal_u32 > > +rte_reciprocal_value_u32(uint32_t d) > > { > > - struct rte_reciprocal R; > > + struct rte_reciprocal_u32 R; > > uint64_t m; > > int l; > > > > - l = fls(d - 1); > > + l = fls_u32(d - 1); > > m = ((1ULL << 32) * ((1ULL << l) - d)); > > m /= d; > > > > ++m; > > R.m = m; > > - R.sh1 = RTE_MIN(l, 1); > > - R.sh2 = RTE_MAX(l - 1, 0); > > + R.sh1 = l > 1 ? 1 : l; > > + R.sh2 = (l - 1 > 0) ? l - 1 : 0; > > Is there a specific reason for changing from RTE_MIN to what you have? R.sh2 seems identical to the previous version (so reason for change is unclear), and R.sh1 changes behavior (R.sh1 can now potentially be zero, even if in practice it won't) without any explanation given. > This was a oversight from my end (Testing with standalone app). Thanks for the catch, will undo in v4. -Pavan > Thanks, > Anatoly > > > + > > + return R; > > +} > > + > > +/* Code taken from Hacker's Delight: > > + * http://www.hackersdelight.org/HDcode/divlu.c. > > + * License permits inclusion here per: > > + * http://www.hackersdelight.org/permissions.htm > > + */ > > +static inline uint64_t > > +divide_128_div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v, uint64_t > > +*r) { > > + const uint64_t b = (1ULL << 32); /* Number base (16 bits). */ > > + uint64_t un1, un0, /* Norm. dividend LSD's. */ > > + vn1, vn0, /* Norm. divisor digits. */ > > + q1, q0, /* Quotient digits. */ > > + un64, un21, un10, /* Dividend digit pairs. */ > > + rhat; /* A remainder. */ > > + int s; /* Shift amount for norm. */ > > + > > + /* If overflow, set rem. to an impossible value. */ > > + if (u1 >= v) { > > + if (r != NULL) > > + *r = (uint64_t) -1; > > + return (uint64_t) -1; > > + } > > + > > + /* Count leading zeros. */ > > + s = __builtin_clzll(v); > > + if (s > 0) { > > + v = v << s; > > + un64 = (u1 << s) | ((u0 >> (64 - s)) & (-s >> 31)); > > + un10 = u0 << s; > > + } else { > > + > > + un64 = u1 | u0; > > + un10 = u0; > > + } > > + > > + vn1 = v >> 32; > > + vn0 = v & 0xFFFFFFFF; > > + > > + un1 = un10 >> 32; > > + un0 = un10 & 0xFFFFFFFF; > > + > > + q1 = un64/vn1; > > + rhat = un64 - q1*vn1; > > +again1: > > + if (q1 >= b || q1*vn0 > b*rhat + un1) { > > + q1 = q1 - 1; > > + rhat = rhat + vn1; > > + if (rhat < b) > > + goto again1; > > + } > > + > > + un21 = un64*b + un1 - q1*v; > > + > > + q0 = un21/vn1; > > + rhat = un21 - q0*vn1; > > +again2: > > + if (q0 >= b || q0*vn0 > b*rhat + un0) { > > + q0 = q0 - 1; > > + rhat = rhat + vn1; > > + if (rhat < b) > > + goto again2; > > + } > > + > > + if (r != NULL) > > + *r = (un21*b + un0 - q0*v) >> s; > > + return q1*b + q0; > > +} > > + > > +struct rte_reciprocal_u64 > > +rte_reciprocal_value_u64(uint64_t d) > > +{ > > + struct rte_reciprocal_u64 R; > > + > > + const uint32_t fld = 63 - __builtin_clzll(d); > > + > > + if ((d & (d - 1)) == 0) { > > + R.m = 0; > > + R.sh1 = (fld - 1) | 0x40; > > + } else { > > + uint64_t rem; > > + uint64_t multiplier; > > + uint8_t more; > > + > > + multiplier = divide_128_div_64_to_64(1ULL << fld, 0, d, > > &rem); > > + multiplier += multiplier; > > + > > + const uint64_t twice_rem = rem + rem; > > + if (twice_rem >= d || twice_rem < rem) > > + multiplier += 1; > > + more = fld; > > + R.m = 1 + multiplier; > > + R.sh1 = more | 0x40; > > + } > > + > > + R.sh1 &= 0x3F; > > > > return R; > > } > > diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map > > b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > > index 65117cb..63ff2b8 100644 > > --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map > > +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > > @@ -247,6 +247,7 @@ EXPERIMENTAL { > > DPDK_17.11 { > > global: > > > > - rte_reciprocal_value; > > + rte_reciprocal_value_u32; > > + rte_reciprocal_value_u64; > > > > } DPDK_17.08; > > diff --git a/lib/librte_sched/Makefile b/lib/librte_sched/Makefile index > > 569656b..a2fd6f3 100644 > > --- a/lib/librte_sched/Makefile > > +++ b/lib/librte_sched/Makefile > > @@ -54,6 +54,8 @@ LIBABIVER := 1 > > SRCS-$(CONFIG_RTE_LIBRTE_SCHED) += rte_sched.c rte_red.c rte_approx.c > > > > # install includes > > -SYMLINK-$(CONFIG_RTE_LIBRTE_SCHED)-include := rte_sched.h > > rte_bitmap.h rte_sched_common.h rte_red.h rte_approx.h > > +SYMLINK-$(CONFIG_RTE_LIBRTE_SCHED)-include := rte_sched.h > > rte_bitmap.h > > +SYMLINK-$(CONFIG_RTE_LIBRTE_SCHED)-include += rte_sched_common.h > > +rte_red.h SYMLINK-$(CONFIG_RTE_LIBRTE_SCHED)-include += > > rte_approx.h > > > > include $(RTE_SDK)/mk/rte.lib.mk > > diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index > > 3b8ccaa..7bb6d51 100644 > > --- a/lib/librte_sched/rte_sched.c > > +++ b/lib/librte_sched/rte_sched.c > > @@ -228,7 +228,7 @@ struct rte_sched_port { > > uint64_t time_cpu_cycles; /* Current CPU time measured in CPU > > cyles */ > > uint64_t time_cpu_bytes; /* Current CPU time measured in bytes > > */ > > uint64_t time; /* Current NIC TX time measured in bytes */ > > - struct rte_reciprocal inv_cycles_per_byte; /* CPU cycles per byte */ > > + struct rte_reciprocal_u32 inv_cycles_per_byte; /* CPU cycles per > > byte > > +*/ > > > > /* Scheduling loop detection */ > > uint32_t pipe_loop; > > @@ -677,7 +677,7 @@ rte_sched_port_config(struct > > rte_sched_port_params *params) > > > > cycles_per_byte = (rte_get_tsc_hz() << RTE_SCHED_TIME_SHIFT) > > / params->rate; > > - port->inv_cycles_per_byte = rte_reciprocal_value(cycles_per_byte); > > + port->inv_cycles_per_byte = > > rte_reciprocal_value_u32(cycles_per_byte); > > > > /* Scheduling loop detection */ > > port->pipe_loop = RTE_SCHED_PIPE_INVALID; @@ -2147,8 +2147,9 > > @@ rte_sched_port_time_resync(struct rte_sched_port *port) > > uint64_t bytes_diff; > > > > /* Compute elapsed time in bytes */ > > - bytes_diff = rte_reciprocal_divide(cycles_diff << > > RTE_SCHED_TIME_SHIFT, > > - port->inv_cycles_per_byte); > > + bytes_diff = rte_reciprocal_divide_u32( > > + cycles_diff << RTE_SCHED_TIME_SHIFT, > > + &port->inv_cycles_per_byte); > > > > /* Advance port time */ > > port->time_cpu_cycles = cycles; > > -- > > 2.7.4 >