From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0069.outbound.protection.outlook.com [104.47.38.69]) by dpdk.org (Postfix) with ESMTP id 8F458199A9 for ; Thu, 7 Sep 2017 16:40:23 +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=RC55l2wuTxGk7fGg+DC2Wm5Pz+R9hLcKdMl6LGbtGuU=; b=clKKYPgX+sqKkdgNE0q3llDuykrd8EZ2YYgLSNyhtTZlNKW3Gij/G60y3e5UPLdGFaJJneUVo45/lTgUMiYxcpwQfM7w/BAMNo2MhX56zKtkJKWXRdEQIC3yrWFktAs/lejWmSsODXtteHazBpq1FdFpbsomK4eeD76kQMoY7m8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from PBHAGAVATULA-LT.caveonetworks.com (111.93.218.67) by CY4PR07MB3461.namprd07.prod.outlook.com (10.171.252.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12; Thu, 7 Sep 2017 14:40:19 +0000 From: Pavan Nikhilesh To: cristian.dumitrescu@intel.com, stephen@networkplumber.org Cc: dev@dpdk.org, Pavan Nikhilesh Date: Thu, 7 Sep 2017 20:09:46 +0530 Message-Id: <1504795187-11087-1-git-send-email-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: PN1PR01CA0105.INDPRD01.PROD.OUTLOOK.COM (10.174.144.21) To CY4PR07MB3461.namprd07.prod.outlook.com (10.171.252.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6146bcdf-b36b-45f4-f713-08d4f5fe5e15 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY4PR07MB3461; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3461; 3:HlbowEdNj3Gd5Tu0Xnx1Z7TjHPfUCRSlwoowUdqYZW6OpIbfwB6SR7GuCHJyMuMgIPKWOpRF6KFM9NCSTp+qy9ZdkOImNBHMcfPfDMczfTKxWoGEfBADKvGMlZ/T8xZVSlmk3tKDwYPtX9Z0MXifziQCfVwIQnA5l/ejs8+kW/dBHUWoQW0kL8QAL17ixpxFMMfcDr1JokKFa54LbWTBGlUmb7W5QTfw/tZA+BHC8VKZZSiDHJvDwg8br2IBRo96; 25:ADZlV1csvcS27BpkyP4hZxqTeCpFSGxgKfO+2US2rRBXNTgUbbZQm4sx04bxDlaN6jzeYCKIflXi8r9T84SAn9+AxcLOxzJnPnJ67tn44u1gd0sApatSmldg6jhQraWJgfBBnJ4FVrSWZthPqnIx1w1uNcvqWC4/uBP3tOly4KKk7y6AZNfS9jKD2VKNmw6zwNuv4NXlc3vqh70ZdcNc3/sqFDg+2dO0CxMoqgmWXWCvHs7qRqhj67mIacsUwS6Bqu3r7orxDswqY7nCAOk0uvFGVipXL2MMpQpYUf0n1HgbtbW/kwUF4zFdnevXnKtL0JXnTMqbQ6Ik5dif5u7Bmw==; 31:LWEDa8j9zNBq7qRsoMLYUw5K7iEkvBr20qhXSEzHKlieG/lGvz/zxLrgmbJ63T/8BTXeScblaKIU8B4RtqbuaDFfYmnRn9qFwxoA03i5/95mzD6cwdQBb4MbdNoM8ECE2iYlezUTUvb2YKen4SnpIUUS/6+Dc+UZI9Tm5fpsoCFF6B9BPvL35KsQ68RWoMX7RXWpys0t33b/qb1INKEQnNQrksrEOvJjHralLfzL1AY= X-MS-TrafficTypeDiagnostic: CY4PR07MB3461: X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3461; 20:+Gnj8OX7BY6k3nzqPn8W3UjbSH98mF39sjWjqIQF9B/U5sZ5RPzq9Srz047DwRamllZbhr7oTqo7gwSzZU3tnOzxRmE9yLk6eRlmGftiERPg1gLYX05v64k/G1gXwy35gKs3oWv1tTpxLNJ9WMaZJuGTYhhd9Z1b9Y09/nAnZ+kopvkco0eRAKLgx4suYhZJca6M1ntmwfzpaa2CJi2hA9wkkGfC2dEe4vk9uspf04H6XYLxyNiBa6ZoNMabLVgHnQLA40yXJQy6MmYV+vLEtxWkMkAdF06rIgkpDfPACYRkozEz2XqseyWQFFZySeAzEn7E9AorShieRXC7Hj4HUS38dYejMg+9c03eG+85tEo0/BfGsMcBG5R1Ggen6znatOdCyoGLeolMNN7J/jR5zQtXYHjTerIQR8b9qUyrE9zhinqiNNWMlf8O8MvzjlZhI5pf0P69vwtwLtoUkNts4uXT1n2I8PNz0H9H2nBVKl2L2Kbwc0xJo9+L4JmeA08fPnkuEuX/oEZwjVo6Tfd9jmw1HhZVpgNgc6Ipuc80LdfiI1H2qyzYPxtyR9fH+iQup5QCgowHsfA2Kr3hHhRuBlLTcvKBf4Fk6tinPJVQZZI=; 4:NXegNHrbfLjkkoUu2Wlo6E3k8+QCjzuVmS16/FK7rygmETf7TfyP5eUSsRjukBOc2GL0sfBNmiWIK9AbtLBvb12AeYa//Vdawk+nZrbL+WXlZolYw4WDOr5r4ase+FbPB65+LRawFOfrC/ap/lWmQyAPVzmzvn2fc5oSUWzlLT+uJMJL1ltw948f9x73NN42FI7NeD6J7/RANwMd/WuAn/EHYUT35J4T1GQX3OTpSZiRzu1lERWJnM0HSMKezUGEDGZ2FOU5xic6wqmNqvxmORW/xyZ56OcKx5xbn4+zdzI= X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); 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)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR07MB3461; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR07MB3461; X-Forefront-PRVS: 04238CD941 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(72206003)(97736004)(25786009)(6512007)(478600001)(107886003)(110136004)(5009440100003)(6506006)(50466002)(4326008)(69596002)(48376002)(3846002)(2906002)(6116002)(50226002)(8676002)(81156014)(81166006)(42186005)(53416004)(50986999)(6666003)(5003940100001)(36756003)(6486002)(105586002)(33646002)(5660300001)(305945005)(106356001)(189998001)(66066001)(42882006)(68736007)(47776003)(101416001)(7736002)(53936002)(575784001)(8936002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB3461; H:PBHAGAVATULA-LT.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; CY4PR07MB3461; 23:/xJ4+bpnck99WtAhs132Ux2ZSr9HQDXlmyeGTUMj+?= =?us-ascii?Q?FWeIh/w2CIbfa3xbt9rVstUgLRqjZ2+3jKXCO7Iq8vYK0lsbiC4WE/zX3KZU?= =?us-ascii?Q?Q9QRaLjtJEwWhqi9yY6c52ukKyNB2BrshhsIIB6cmfzwaWbt5joEXb2CMoWr?= =?us-ascii?Q?77+Zg4GDLhGz/jEOnGo2nHegJrMe3sRhkXDkmXpLpr6mJwCgC+g6z46D8miM?= =?us-ascii?Q?exrt63JaEspwomNLtYvKMYRPYX9q+sz4H5Fd7QxQELmd6u4CUyX23DGGvWuQ?= =?us-ascii?Q?diliL3ehrWCXqGx5rbUFC746eLGKn/GqS7mpgjd4IXd1HTVCdfL0Ha1wVho8?= =?us-ascii?Q?3ZNB54bTGsWC9XqTSr4P0xwB9Auq/YrGSxhJCZBMLXdysNzEP4LwZIiTXOgV?= =?us-ascii?Q?ik6LTTZtmHkIeZn0faOUlbk//ucpklT2Qjf9z5p4MJESdQRskWg6+AAQ4O7p?= =?us-ascii?Q?y1zAGRpIMwqwv2f51Mbe4H0Sby/5Bz6m/HeSKAmetbDx3eUzjPawpad4H9wR?= =?us-ascii?Q?bwkEzfnKL+4xGoga/uxb/01AEGPyCnhTq1g878BZSPuJ37Pln4qeKto2/gjB?= =?us-ascii?Q?gbkeQ4nvQrQ7ltVfnp2ehY3STv78eLN2RW5N7jMN6p91aZlhLhY6h269YKlK?= =?us-ascii?Q?KBhZ26i9hHigCF0CDM9MEc7GODQd4s8xgFf9MlasLvTR67wPEuZfPjwnrD5y?= =?us-ascii?Q?n257HaV9RguFXFz3Lgy9QMgaicUcX+MhwvE6oFLXsNonI5QpSa2hNlNYVgsv?= =?us-ascii?Q?ha8HoE4PbcQrHp4qXLMYjdgwfVnAkgUwWQHlXjt0pt4+NdJAXunxy5fb3Kkl?= =?us-ascii?Q?RO1/UEq9T8ha+A377eeKoZuKlfsICRL7rq1G9A4C7l0rGZAD92D21EX3mjxO?= =?us-ascii?Q?e5gQdOzOPTjsJH2gciuKuPELu4IVM5NQo5s1YnwNkkxJUfxfv94i7T9LnONY?= =?us-ascii?Q?vHNtJbbGWSdttkVu7zGmS1Mlw8O8W9k8Cj1tdOXYLbJcCHsnjJvANdU/Qa8M?= =?us-ascii?Q?X+4Tn4e1H6NkIMbRW6gZ7Mpz85w4PWEXSugE9/uFL1VnQ3v9Cc3ep5jqMpiJ?= =?us-ascii?Q?HQTWt9L9VpUwCZhYki8pk8ZzUscLfhdJ+758kvnkYDrCW2GOudVEZJ4+Aez8?= =?us-ascii?Q?C6kyChkXLo=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3461; 6:RsF376rgBMRmtZTy6tublTEQO9AwAUz7NBeQjpu5/E5gO4+7QOQ3bRuEeidd2QhDYQfyZ/3wlEfsbrriKW4d/E9VX2ELtdK+Jj86b8TKaObTbFuHv7z7R80V20TlDYwBvvBP8Esg25mK84zTqWGuEi23XDMWPe2O3H0AordGLqHpP2v1AsDg5Wj/UwTp0Suq9+ELMYD2msLOa0X4SJgM+2RWsyyPGMQh8wdzY954pyqJ2SmQEwZOBHskf9ZIghk0QQ3tAmr+HPi51KSzoz02WSx5cvM5qpuofYl7BoHb9eYV2GzKcbRwM8pBEJJxOE8/c9NyPG6sC9nBga8JtzTbMg==; 5:+1HxxLdpfr3MArXzINmhBx5lqHD6LeKvbGhSS94+JQi7me316lNOEC8RGcA5CjMjdYNXwtX3VtZ3qQzh+wQkdkOGVdQIzzoZSWfW0X61Zw0LfzgkPIhlpecc7L6jqgJoUmaFrss5gwOLaPcYG8iEKA==; 24:X/u77wQe98vo/uvX+dNAGYDP24RBhyhJRyd4+M2xlcSXP7fQ88Xe4GH51ELiH9goH5p3yLTERIXm5itB3fm1Q243P4X0FeP1U4IpHkr6UlU=; 7:xhMSHPUFE4lyOZrjSImN5rbfGGJSaC0ed4XyDvb43Tr0rMHCdGGpFAXYfMTIArLIxOoGh/w5ILGj9nJ5YK/eJMmR5h6HkFwRFpuSWHcrJ3cXjY2pfKAm/BZ/fR9Oq8g7xO83V2sbmhpwQfH4H/Aua8Yco/K2uPM8h4n9bw0BGP+KHwDBkaNa2RGqWWyAQSm8fzpBVtHJLRAuhvci8VI9FsJy/ImP0BIScjsiMCCrEaQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2017 14:40:19.8515 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3461 Subject: [dpdk-dev] [PATCH 1/2] eal: move bitmap from lib sched 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: Thu, 07 Sep 2017 14:40:24 -0000 The librte_sched uses rte_bitmap to manage large arrays of bits in an optimized method so, moving it to eal/common would allow other libraries and applications to use it. Signed-off-by: Pavan Nikhilesh --- lib/librte_eal/common/Makefile | 1 + .../common/include}/rte_bitmap.h | 100 +++++++++++++-------- lib/librte_sched/Makefile | 5 +- lib/librte_sched/rte_sched.c | 2 +- 4 files changed, 70 insertions(+), 38 deletions(-) rename lib/{librte_sched => librte_eal/common/include}/rte_bitmap.h (85%) diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index e8fd67a..c2c6a7f 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -42,6 +42,7 @@ INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h rte_vdev.h INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h +INC += rte_bitmap.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_rwlock.h diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_eal/common/include/rte_bitmap.h similarity index 85% rename from lib/librte_sched/rte_bitmap.h rename to lib/librte_eal/common/include/rte_bitmap.h index 010d752..0938c63 100644 --- a/lib/librte_sched/rte_bitmap.h +++ b/lib/librte_eal/common/include/rte_bitmap.h @@ -65,6 +65,7 @@ extern "C" { ***/ #include + #include #include #include @@ -72,36 +73,46 @@ extern "C" { #include #ifndef RTE_BITMAP_OPTIMIZATIONS -#define RTE_BITMAP_OPTIMIZATIONS 1 +#define RTE_BITMAP_OPTIMIZATIONS 1 #endif /* Slab */ -#define RTE_BITMAP_SLAB_BIT_SIZE 64 -#define RTE_BITMAP_SLAB_BIT_SIZE_LOG2 6 -#define RTE_BITMAP_SLAB_BIT_MASK (RTE_BITMAP_SLAB_BIT_SIZE - 1) +#define RTE_BITMAP_SLAB_BIT_SIZE 64 +#define RTE_BITMAP_SLAB_BIT_SIZE_LOG2 6 +#define RTE_BITMAP_SLAB_BIT_MASK (RTE_BITMAP_SLAB_BIT_SIZE - 1) /* Cache line (CL) */ -#define RTE_BITMAP_CL_BIT_SIZE (RTE_CACHE_LINE_SIZE * 8) -#define RTE_BITMAP_CL_BIT_SIZE_LOG2 (RTE_CACHE_LINE_SIZE_LOG2 + 3) -#define RTE_BITMAP_CL_BIT_MASK (RTE_BITMAP_CL_BIT_SIZE - 1) +#define RTE_BITMAP_CL_BIT_SIZE (RTE_CACHE_LINE_SIZE * 8) +#define RTE_BITMAP_CL_BIT_SIZE_LOG2 (RTE_CACHE_LINE_SIZE_LOG2 + 3) +#define RTE_BITMAP_CL_BIT_MASK (RTE_BITMAP_CL_BIT_SIZE - 1) -#define RTE_BITMAP_CL_SLAB_SIZE (RTE_BITMAP_CL_BIT_SIZE / RTE_BITMAP_SLAB_BIT_SIZE) -#define RTE_BITMAP_CL_SLAB_SIZE_LOG2 (RTE_BITMAP_CL_BIT_SIZE_LOG2 - RTE_BITMAP_SLAB_BIT_SIZE_LOG2) -#define RTE_BITMAP_CL_SLAB_MASK (RTE_BITMAP_CL_SLAB_SIZE - 1) +#define RTE_BITMAP_CL_SLAB_SIZE \ + (RTE_BITMAP_CL_BIT_SIZE / RTE_BITMAP_SLAB_BIT_SIZE) +#define RTE_BITMAP_CL_SLAB_SIZE_LOG2 \ + (RTE_BITMAP_CL_BIT_SIZE_LOG2 - RTE_BITMAP_SLAB_BIT_SIZE_LOG2) +#define RTE_BITMAP_CL_SLAB_MASK (RTE_BITMAP_CL_SLAB_SIZE - 1) /** Bitmap data structure */ struct rte_bitmap { /* Context for array1 and array2 */ - uint64_t *array1; /**< Bitmap array1 */ - uint64_t *array2; /**< Bitmap array2 */ - uint32_t array1_size; /**< Number of 64-bit slabs in array1 that are actually used */ - uint32_t array2_size; /**< Number of 64-bit slabs in array2 */ + uint64_t *array1; + /**< Bitmap array1 */ + uint64_t *array2; + /**< Bitmap array2 */ + uint32_t array1_size; + /**< Number of 64-bit slabs in array1 that are actually used */ + uint32_t array2_size; + /**< Number of 64-bit slabs in array2 */ /* Context for the "scan next" operation */ - uint32_t index1; /**< Bitmap scan: Index of current array1 slab */ - uint32_t offset1; /**< Bitmap scan: Offset of current bit within current array1 slab */ - uint32_t index2; /**< Bitmap scan: Index of current array2 slab */ - uint32_t go2; /**< Bitmap scan: Go/stop condition for current array2 cache line */ + uint32_t index1; + /**< Bitmap scan: Index of current array1 slab */ + uint32_t offset1; + /**< Bitmap scan: Offset of current bit within current array1 slab */ + uint32_t index2; + /**< Bitmap scan: Index of current array2 slab */ + uint32_t go2; + /**< Bitmap scan: Go/stop condition for current array2 cache line */ /* Storage space for array1 and array2 */ uint8_t memory[]; @@ -122,7 +133,8 @@ __rte_bitmap_mask1_get(struct rte_bitmap *bmp) static inline void __rte_bitmap_index2_set(struct rte_bitmap *bmp) { - bmp->index2 = (((bmp->index1 << RTE_BITMAP_SLAB_BIT_SIZE_LOG2) + bmp->offset1) << RTE_BITMAP_CL_SLAB_SIZE_LOG2); + bmp->index2 = (((bmp->index1 << RTE_BITMAP_SLAB_BIT_SIZE_LOG2) + + bmp->offset1) << RTE_BITMAP_CL_SLAB_SIZE_LOG2); } #if RTE_BITMAP_OPTIMIZATIONS @@ -171,12 +183,18 @@ __rte_bitmap_get_memory_footprint(uint32_t n_bits, uint32_t n_cache_lines_array2; uint32_t n_bytes_total; - n_cache_lines_array2 = (n_bits + RTE_BITMAP_CL_BIT_SIZE - 1) / RTE_BITMAP_CL_BIT_SIZE; - n_slabs_array1 = (n_cache_lines_array2 + RTE_BITMAP_SLAB_BIT_SIZE - 1) / RTE_BITMAP_SLAB_BIT_SIZE; + n_cache_lines_array2 = (n_bits + RTE_BITMAP_CL_BIT_SIZE - 1) / + RTE_BITMAP_CL_BIT_SIZE; + n_slabs_array1 = (n_cache_lines_array2 + RTE_BITMAP_SLAB_BIT_SIZE - 1) / + RTE_BITMAP_SLAB_BIT_SIZE; n_slabs_array1 = rte_align32pow2(n_slabs_array1); - n_slabs_context = (sizeof(struct rte_bitmap) + (RTE_BITMAP_SLAB_BIT_SIZE / 8) - 1) / (RTE_BITMAP_SLAB_BIT_SIZE / 8); - n_cache_lines_context_and_array1 = (n_slabs_context + n_slabs_array1 + RTE_BITMAP_CL_SLAB_SIZE - 1) / RTE_BITMAP_CL_SLAB_SIZE; - n_bytes_total = (n_cache_lines_context_and_array1 + n_cache_lines_array2) * RTE_CACHE_LINE_SIZE; + n_slabs_context = (sizeof(struct rte_bitmap) + + (RTE_BITMAP_SLAB_BIT_SIZE / 8) - 1) / + (RTE_BITMAP_SLAB_BIT_SIZE / 8); + n_cache_lines_context_and_array1 = (n_slabs_context + n_slabs_array1 + + RTE_BITMAP_CL_SLAB_SIZE - 1) / RTE_BITMAP_CL_SLAB_SIZE; + n_bytes_total = (n_cache_lines_context_and_array1 + + n_cache_lines_array2) * RTE_CACHE_LINE_SIZE; if (array1_byte_offset) { *array1_byte_offset = n_slabs_context * (RTE_BITMAP_SLAB_BIT_SIZE / 8); @@ -185,7 +203,8 @@ __rte_bitmap_get_memory_footprint(uint32_t n_bits, *array1_slabs = n_slabs_array1; } if (array2_byte_offset) { - *array2_byte_offset = n_cache_lines_context_and_array1 * RTE_CACHE_LINE_SIZE; + *array2_byte_offset = n_cache_lines_context_and_array1 * + RTE_CACHE_LINE_SIZE; } if (array2_slabs) { *array2_slabs = n_cache_lines_array2 * RTE_BITMAP_CL_SLAB_SIZE; @@ -210,6 +229,7 @@ __rte_bitmap_scan_init(struct rte_bitmap *bmp) * * @param n_bits * Number of bits in the bitmap + * * @return * Bitmap memory footprint measured in bytes on success, 0 on error */ @@ -226,12 +246,14 @@ rte_bitmap_get_memory_footprint(uint32_t n_bits) { /** * Bitmap initialization * - * @param mem_size - * Minimum expected size of bitmap. + * @param n_bits + * Number of pre-allocated bits in array2. Must be non-zero and multiple of + * 512. * @param mem * Base address of array1 and array2. - * @param n_bits - * Number of pre-allocated bits in array2. Must be non-zero and multiple of 512. + * @param mem_size + * Minimum expected size of bitmap. + * * @return * Handle to bitmap instance. */ @@ -277,6 +299,7 @@ rte_bitmap_init(uint32_t n_bits, uint8_t *mem, uint32_t mem_size) * * @param bmp * Handle to bitmap instance + * * @return * 0 upon success, error code otherwise */ @@ -312,6 +335,7 @@ rte_bitmap_reset(struct rte_bitmap *bmp) * Handle to bitmap instance * @param pos * Bit position + * * @return * 0 upon success, error code otherwise */ @@ -333,6 +357,7 @@ rte_bitmap_prefetch0(struct rte_bitmap *bmp, uint32_t pos) * Handle to bitmap instance * @param pos * Bit position + * * @return * 0 when bit is cleared, non-zero when bit is set */ @@ -365,7 +390,8 @@ rte_bitmap_set(struct rte_bitmap *bmp, uint32_t pos) /* Set bit in array2 slab and set bit in array1 slab */ index2 = pos >> RTE_BITMAP_SLAB_BIT_SIZE_LOG2; offset2 = pos & RTE_BITMAP_SLAB_BIT_MASK; - index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + RTE_BITMAP_CL_BIT_SIZE_LOG2); + index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + + RTE_BITMAP_CL_BIT_SIZE_LOG2); offset1 = (pos >> RTE_BITMAP_CL_BIT_SIZE_LOG2) & RTE_BITMAP_SLAB_BIT_MASK; slab2 = bmp->array2 + index2; slab1 = bmp->array1 + index1; @@ -392,7 +418,8 @@ rte_bitmap_set_slab(struct rte_bitmap *bmp, uint32_t pos, uint64_t slab) /* Set bits in array2 slab and set bit in array1 slab */ index2 = pos >> RTE_BITMAP_SLAB_BIT_SIZE_LOG2; - index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + RTE_BITMAP_CL_BIT_SIZE_LOG2); + index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + + RTE_BITMAP_CL_BIT_SIZE_LOG2); offset1 = (pos >> RTE_BITMAP_CL_BIT_SIZE_LOG2) & RTE_BITMAP_SLAB_BIT_MASK; slab2 = bmp->array2 + index2; slab1 = bmp->array1 + index1; @@ -449,7 +476,8 @@ rte_bitmap_clear(struct rte_bitmap *bmp, uint32_t pos) } /* The array2 cache line is all-zeros, so clear bit in array1 slab */ - index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + RTE_BITMAP_CL_BIT_SIZE_LOG2); + index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + + RTE_BITMAP_CL_BIT_SIZE_LOG2); offset1 = (pos >> RTE_BITMAP_CL_BIT_SIZE_LOG2) & RTE_BITMAP_SLAB_BIT_MASK; slab1 = bmp->array1 + index1; *slab1 &= ~(1lu << offset1); @@ -500,7 +528,8 @@ __rte_bitmap_scan_read(struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab) uint64_t *slab2; slab2 = bmp->array2 + bmp->index2; - for ( ; bmp->go2 ; bmp->index2 ++, slab2 ++, bmp->go2 = bmp->index2 & RTE_BITMAP_CL_SLAB_MASK) { + for ( ; bmp->go2 ; bmp->index2 ++, slab2 ++, + bmp->go2 = bmp->index2 & RTE_BITMAP_CL_SLAB_MASK) { if (*slab2) { *pos = bmp->index2 << RTE_BITMAP_SLAB_BIT_SIZE_LOG2; *slab = *slab2; @@ -520,10 +549,10 @@ __rte_bitmap_scan_read(struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab) * * @param bmp * Handle to bitmap instance - * @param pos + * @param[out] pos * When function call returns 1, pos contains the position of the next set * bit, otherwise not modified - * @param slab + * @param[out] slab * When function call returns 1, slab contains the value of the entire 64-bit * slab where the bit indicated by pos is located. Slabs are always 64-bit * aligned, so the position of the first bit of the slab (this bit is not @@ -532,6 +561,7 @@ __rte_bitmap_scan_read(struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab) * after this slab, so the same slab will not be returned again if it * contains more than one bit which is set. When function call returns 0, * slab is not modified. + * * @return * 0 if there is no bit set in the bitmap, 1 otherwise */ diff --git a/lib/librte_sched/Makefile b/lib/librte_sched/Makefile index 18274e7..072cd63 100644 --- a/lib/librte_sched/Makefile +++ b/lib/librte_sched/Makefile @@ -55,7 +55,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_SCHED) += rte_sched.c rte_red.c rte_approx.c SRCS-$(CONFIG_RTE_LIBRTE_SCHED) += rte_reciprocal.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_reciprocal.h +SYMLINK-$(CONFIG_RTE_LIBRTE_SCHED)-include := rte_sched.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 b7cba11..b3e0d4f 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include "rte_sched.h" -#include "rte_bitmap.h" #include "rte_sched_common.h" #include "rte_approx.h" #include "rte_reciprocal.h" -- 2.7.4