get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/46315/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 46315,
    "url": "http://patches.dpdk.org/api/patches/46315/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1539071699-29963-2-git-send-email-vivek.sharma@caviumnetworks.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1539071699-29963-2-git-send-email-vivek.sharma@caviumnetworks.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1539071699-29963-2-git-send-email-vivek.sharma@caviumnetworks.com",
    "date": "2018-10-09T07:54:58",
    "name": "[1/2] eal/bitmap: support bitmap reverse scanning",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "a215345ed3419645b2da9223650b5e07152f6f73",
    "submitter": {
        "id": 1134,
        "url": "http://patches.dpdk.org/api/people/1134/?format=api",
        "name": "Vivek Sharma",
        "email": "vivek.sharma@caviumnetworks.com"
    },
    "delegate": {
        "id": 10018,
        "url": "http://patches.dpdk.org/api/users/10018/?format=api",
        "username": "cristian_dumitrescu",
        "first_name": "Cristian",
        "last_name": "Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1539071699-29963-2-git-send-email-vivek.sharma@caviumnetworks.com/mbox/",
    "series": [
        {
            "id": 1768,
            "url": "http://patches.dpdk.org/api/series/1768/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1768",
            "date": "2018-10-09T07:54:57",
            "name": "eal/bitmap: support reverse bitmap scan",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1768/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/46315/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/46315/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 10CE85F4D;\n\tTue,  9 Oct 2018 09:55:25 +0200 (CEST)",
            "from NAM01-SN1-obe.outbound.protection.outlook.com\n\t(mail-sn1nam01on0047.outbound.protection.outlook.com [104.47.32.47])\n\tby dpdk.org (Postfix) with ESMTP id 7E8D85F14\n\tfor <dev@dpdk.org>; Tue,  9 Oct 2018 09:55:22 +0200 (CEST)",
            "from dell-e5540.Dlink (119.82.92.140) by\n\tBN7PR07MB5380.namprd07.prod.outlook.com (2603:10b6:408:2e::27) with\n\tMicrosoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\t15.20.1185.23; Tue, 9 Oct 2018 07:55:20 +0000"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=bjUhgdlpaZzXc5GzWWqdHJ42T5durskpHNqKMSLOY+Q=;\n\tb=RkSkfJMdOo7uNjENXmUu34qDjpEPGtrRcim/TrfyShtpKZAEZC8XnoyNAPrgddOzFp5AEoUTyPrr8Cfc0UHsNCOM2nKb6Pa1tuY9Arm3l85qRSQMdQFPtHBi0EjmYqDIKoXCz5wLjJ+0j99zqYAQJwHD3ZtnEuxkSG+eteaMcAM=",
        "Authentication-Results": "spf=none (sender IP is )\n\tsmtp.mailfrom=Vivek.Sharma@cavium.com; ",
        "From": "Vivek Sharma <vivek.sharma@caviumnetworks.com>",
        "To": "dev@dpdk.org",
        "Cc": "cristian.dumitrescu@intel.com,\n\tVivek Sharma <vivek.sharma@caviumnetworks.com>",
        "Date": "Tue,  9 Oct 2018 13:24:58 +0530",
        "Message-Id": "<1539071699-29963-2-git-send-email-vivek.sharma@caviumnetworks.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1539071699-29963-1-git-send-email-vivek.sharma@caviumnetworks.com>",
        "References": "<1539071699-29963-1-git-send-email-vivek.sharma@caviumnetworks.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[119.82.92.140]",
        "X-ClientProxiedBy": "BMXPR01CA0048.INDPRD01.PROD.OUTLOOK.COM\n\t(2603:1096:b00:c::34) To BN7PR07MB5380.namprd07.prod.outlook.com\n\t(2603:10b6:408:2e::27)",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-Office365-Filtering-Correlation-Id": "982d8df9-6f02-46c4-ec94-08d62dbc900e",
        "X-Microsoft-Antispam": "BCL:0; PCL:0;\n\tRULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);\n\tSRVR:BN7PR07MB5380; ",
        "X-Microsoft-Exchange-Diagnostics": [
            "1; BN7PR07MB5380;\n\t3:6QwTDRHbTlWn56RQF0FWFDK85zywo8nGiDbR0YtisIvoH5o06MQArz+rWvFHKxyC+GBveN6mSBvvFtEAXyWeAW/WYWAL/iG9+SZwIhjM64DDrFfZIC2u0w4x8CyIS1TaDhzay130Fpumk4E+2UN79JEUzEIPGuk+QS5M8PHTfcb2IWQvfbXszRqyM5Lfx2eLJgK4ppRgh92DwkT7+peEm0Dswt3/1mnEBDZ5oslk1io7vQ5f5GpC9RVyd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DNiJCzdQ+KiAfeAf61CkaPnxrTvjrQ41DtI7Yk+nwTX+TsGRDbuEib4npjU/9Vw6E8d/pzeBptQm0bK0gVq7qM4bN/Qx0XJcKmQnd2zZELpuw9Bq0d9QMfVYndwVeQRjh8ohsrYNRCrg==;\n\t5:lp70gT09Vu/4U+tD7cTrEVm/OhUV2+Yrvc01W8dmfkS1oxC0vepT2G8Hnkt5OGEXqv50g0vLwi/p7LXBtpfTVs8Z5XhSrje4m3WVGVf3oCYgSKcKtHTncmCxknzPuXpQ+RXXCn1BHVc5D+FhS+RT4Eh9FO73fV0v0YphFGRrItw=;\n\t7:bLfysjy10bxhgUQsodWqvC6kf4kjbiuQVYoIpwumX5joqfQDEzs5Z39ybeXnQJwK1yKh1XGStXt1Qx0yfY3hqgAwA152Wr7RC5ZeyDmSuIWZC0sD6vAdIw2VnY5jMb38wDpr3N4nxJU946WyH5MaTphgf8cdhGlPhkATPSgaT1Eo39WCEUiSDhgasKlghYZDLecK3Nrw7YbYBbMZqgBFoiwdiSS0zZv1h+EeYoAOg3dMxf7WTkNoSHRKzXZkS6vD"
        ],
        "X-MS-TrafficTypeDiagnostic": "BN7PR07MB5380:",
        "X-Microsoft-Antispam-PRVS": "<BN7PR07MB5380A3A57E2411F3C12FD61FFDE70@BN7PR07MB5380.namprd07.prod.outlook.com>",
        "X-Exchange-Antispam-Report-Test": "UriScan:;",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-Exchange-Antispam-Report-CFA-Test": "BCL:0; PCL:0;\n\tRULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(3231355)(944501410)(4982022)(52105095)(3002001)(10201501046)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201708071742011)(7699051);\n\tSRVR:BN7PR07MB5380; BCL:0; PCL:0; RULEID:; SRVR:BN7PR07MB5380; ",
        "X-Forefront-PRVS": "08200063E9",
        "X-Forefront-Antispam-Report": "SFV:NSPM;\n\tSFS:(10009020)(136003)(376002)(346002)(396003)(366004)(39860400002)(199004)(189003)(2361001)(53936002)(42882007)(50226002)(107886003)(81166006)(68736007)(14444005)(72206003)(8676002)(6116002)(47776003)(97736004)(6486002)(6512007)(6306002)(16526019)(26005)(3846002)(8936002)(81156014)(186003)(25786009)(6916009)(305945005)(7736002)(478600001)(48376002)(2351001)(105586002)(2906002)(4326008)(50466002)(6666003)(36756003)(16586007)(2616005)(52116002)(51416003)(6506007)(5660300001)(11346002)(486006)(476003)(44832011)(316002)(386003)(956004)(76176011)(66066001)(106356001)(446003);\n\tDIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR07MB5380; H:dell-e5540.Dlink; FPR:;\n\tSPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; ",
        "Received-SPF": "None (protection.outlook.com: cavium.com does not designate\n\tpermitted sender hosts)",
        "X-Microsoft-Antispam-Message-Info": "93iaAYsylXzc4n4nweVcVv1pJ0T1eEPYuRKGddWrq32skmAqA/m5FPTm6+VREPwE25dNAVkcK4SboCHQwB1iOp1dGYcBHKxp3li0pi5TGhKIqQlidPLgdImAyzxUgEbLrvArBN5KdxOjC7b1AZTFJw2pIf4OX1/1bpq8bKC+2sgcn52+iFCwli+WDlzq9+jM4HFaMzAzNvLUWcPYJgVD+K7ZLoOg2Ha1zuvoxCOpip4ap7y9kBeUI7448yCEwf21rgAp0XV9Us+xfMeGlZlF9BYF8hIP4Zcw/suS/YZhkzJ+llm7a+82ds4ZSL9q2yEocolyeDFnPCuJ1TYWZpbvNwfJBfTkD5kjLC40BZ1pz4c=",
        "SpamDiagnosticOutput": "1:99",
        "SpamDiagnosticMetadata": "NSPM",
        "X-OriginatorOrg": "caviumnetworks.com",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "09 Oct 2018 07:55:20.0533\n\t(UTC)",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "982d8df9-6f02-46c4-ec94-08d62dbc900e",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "Hosted",
        "X-MS-Exchange-CrossTenant-Id": "711e4ccf-2e9b-4bcf-a551-4094005b6194",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "BN7PR07MB5380",
        "Subject": "[dpdk-dev] [PATCH 1/2] eal/bitmap: support bitmap reverse scanning",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Currently bitmap supports only forward scanning starting from zero\nbit position. This patch implements reverse scanning starting from\nhighest bit position towards zero bit position.\n\nSigned-off-by: Vivek Sharma <vivek.sharma@caviumnetworks.com>\n---\nPrerequisite:\n* Note that this patchset is dependent on patch:\n  'http://patches.dpdk.org/patch/45307/'\n\n lib/librte_eal/common/include/rte_bitmap.h | 164 +++++++++++++++++++++++++----\n 1 file changed, 143 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_bitmap.h b/lib/librte_eal/common/include/rte_bitmap.h\nindex 7a36ce7..4b3437e 100644\n--- a/lib/librte_eal/common/include/rte_bitmap.h\n+++ b/lib/librte_eal/common/include/rte_bitmap.h\n@@ -61,6 +61,11 @@ extern \"C\" {\n #define RTE_BITMAP_CL_SLAB_SIZE_LOG2             (RTE_BITMAP_CL_BIT_SIZE_LOG2 - RTE_BITMAP_SLAB_BIT_SIZE_LOG2)\n #define RTE_BITMAP_CL_SLAB_MASK                  (RTE_BITMAP_CL_SLAB_SIZE - 1)\n \n+enum rte_scan_dir {\n+\tRTE_BITMAP_REV_SCAN = -1,\n+\tRTE_BITMAP_FWD_SCAN = 1\n+};\n+\n /** Bitmap data structure */\n struct rte_bitmap {\n \t/* Context for array1 and array2 */\n@@ -74,6 +79,7 @@ struct rte_bitmap {\n \tuint32_t offset1; /**< Bitmap scan: Offset of current bit within current array1 slab */\n \tuint32_t index2;  /**< Bitmap scan: Index of current array2 slab */\n \tuint32_t go2;     /**< Bitmap scan: Go/stop condition for current array2 cache line */\n+\tenum rte_scan_dir dir; /**< Bitmap scan: Current scan direction */\n \n \t/* Storage space for array1 and array2 */\n \tuint8_t memory[];\n@@ -82,13 +88,16 @@ struct rte_bitmap {\n static inline void\n __rte_bitmap_index1_inc(struct rte_bitmap *bmp)\n {\n-\tbmp->index1 = (bmp->index1 + 1) & (bmp->array1_size - 1);\n+\tbmp->index1 = (bmp->index1 + bmp->dir) & (bmp->array1_size - 1);\n }\n \n static inline uint64_t\n __rte_bitmap_mask1_get(struct rte_bitmap *bmp)\n {\n-\treturn (~1llu) << bmp->offset1;\n+\tif (bmp->dir == RTE_BITMAP_FWD_SCAN)\n+\t\treturn (~1llu) << bmp->offset1;\n+\telse\n+\t\treturn (~0llu) ^ ((~0llu) << bmp->offset1);\n }\n \n static inline void\n@@ -110,6 +119,16 @@ rte_bsf64(uint64_t slab, uint32_t *pos)\n \treturn 1;\n }\n \n+static inline int\n+rte_bsl64(uint64_t slab, uint32_t *pos)\n+{\n+\tif (likely(!slab))\n+\t\treturn 0;\n+\n+\t*pos = RTE_BITMAP_SLAB_BIT_SIZE - 1 - __builtin_clzll(slab);\n+\treturn 1;\n+}\n+\n #else\n \n static inline int\n@@ -132,6 +151,25 @@ rte_bsf64(uint64_t slab, uint32_t *pos)\n \treturn 0;\n }\n \n+static inline int\n+rte_bsl64(uint64_t slab, uint32_t *pos)\n+{\n+\tuint64_t mask;\n+\tint i;\n+\n+\tif (likely(!slab))\n+\t\treturn 0;\n+\n+\tfor (i = RTE_BITMAP_SLAB_BIT_SIZE - 1, mask = 1; i >= 0; i--) {\n+\t\tif (unlikely(slab & (mask << i))) {\n+\t\t\t*pos = i;\n+\t\t\treturn 1;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n #endif\n \n static inline uint32_t\n@@ -167,16 +205,29 @@ __rte_bitmap_get_memory_footprint(uint32_t n_bits,\n }\n \n static inline void\n-__rte_bitmap_scan_init(struct rte_bitmap *bmp)\n+__rte_bitmap_scan_init_generic(struct rte_bitmap *bmp, enum rte_scan_dir dir)\n {\n-\tbmp->index1 = bmp->array1_size - 1;\n-\tbmp->offset1 = RTE_BITMAP_SLAB_BIT_SIZE - 1;\n-\t__rte_bitmap_index2_set(bmp);\n-\tbmp->index2 += RTE_BITMAP_CL_SLAB_SIZE;\n-\n+\tif (dir == RTE_BITMAP_FWD_SCAN) {\n+\t\tbmp->index1 = bmp->array1_size - 1;\n+\t\tbmp->offset1 = RTE_BITMAP_SLAB_BIT_SIZE - 1;\n+\t\t__rte_bitmap_index2_set(bmp);\n+\t\tbmp->index2 += RTE_BITMAP_CL_SLAB_SIZE;\n+\t\tbmp->dir = RTE_BITMAP_FWD_SCAN;\n+\t} else {\n+\t\tbmp->index1 = 0;\n+\t\tbmp->offset1 = 0;\n+\t\tbmp->index2 = 0;\n+\t\tbmp->dir = RTE_BITMAP_REV_SCAN;\n+\t}\n \tbmp->go2 = 0;\n }\n \n+static inline void\n+__rte_bitmap_scan_init(struct rte_bitmap *bmp)\n+{\n+\t__rte_bitmap_scan_init_generic(bmp, RTE_BITMAP_FWD_SCAN);\n+}\n+\n /**\n  * Bitmap memory footprint calculation\n  *\n@@ -439,19 +490,32 @@ __rte_bitmap_scan_search(struct rte_bitmap *bmp)\n \tvalue1 = bmp->array1[bmp->index1];\n \tvalue1 &= __rte_bitmap_mask1_get(bmp);\n \n-\tif (rte_bsf64(value1, &bmp->offset1)) {\n-\t\treturn 1;\n+\tif (bmp->dir == RTE_BITMAP_FWD_SCAN) {\n+\t\tif (rte_bsf64(value1, &bmp->offset1))\n+\t\t\treturn 1;\n+\t} else {\n+\t\tif (rte_bsl64(value1, &bmp->offset1))\n+\t\t\treturn 1;\n \t}\n \n \t__rte_bitmap_index1_inc(bmp);\n-\tbmp->offset1 = 0;\n+\n+\tif (bmp->dir == RTE_BITMAP_FWD_SCAN)\n+\t\tbmp->offset1 = 0;\n+\telse\n+\t\tbmp->offset1 = RTE_BITMAP_SLAB_BIT_SIZE - 1;\n \n \t/* Look for another array1 slab */\n-\tfor (i = 0; i < bmp->array1_size; i ++, __rte_bitmap_index1_inc(bmp)) {\n+\tfor (i = 0; i < bmp->array1_size;\n+\t     i++, __rte_bitmap_index1_inc(bmp)) {\n \t\tvalue1 = bmp->array1[bmp->index1];\n \n-\t\tif (rte_bsf64(value1, &bmp->offset1)) {\n-\t\t\treturn 1;\n+\t\tif (bmp->dir == RTE_BITMAP_FWD_SCAN) {\n+\t\t\tif (rte_bsf64(value1, &bmp->offset1))\n+\t\t\t\treturn 1;\n+\t\t} else {\n+\t\t\tif (rte_bsl64(value1, &bmp->offset1))\n+\t\t\t\treturn 1;\n \t\t}\n \t}\n \n@@ -462,8 +526,12 @@ static inline void\n __rte_bitmap_scan_read_init(struct rte_bitmap *bmp)\n {\n \t__rte_bitmap_index2_set(bmp);\n+\n+\tif (bmp->dir == RTE_BITMAP_REV_SCAN)\n+\t\tbmp->index2 += RTE_BITMAP_CL_SLAB_SIZE - 1;\n+\n \tbmp->go2 = 1;\n-\trte_prefetch1((void *)(bmp->array2 + bmp->index2 + 8));\n+\trte_prefetch1((void *)(bmp->array2 + bmp->index2 + 8 * bmp->dir));\n }\n \n static inline int\n@@ -472,23 +540,42 @@ __rte_bitmap_scan_read(struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab)\n \tuint64_t *slab2;\n \n \tslab2 = bmp->array2 + bmp->index2;\n-\tfor ( ; bmp->go2 ; bmp->index2 ++, slab2 ++, bmp->go2 = bmp->index2 & RTE_BITMAP_CL_SLAB_MASK) {\n+\n+\tfor ( ; bmp->go2; ) {\n \t\tif (*slab2) {\n \t\t\t*pos = bmp->index2 << RTE_BITMAP_SLAB_BIT_SIZE_LOG2;\n \t\t\t*slab = *slab2;\n \n-\t\t\tbmp->index2 ++;\n-\t\t\tslab2 ++;\n-\t\t\tbmp->go2 = bmp->index2 & RTE_BITMAP_CL_SLAB_MASK;\n+\t\t\tbmp->index2 += bmp->dir;\n+\t\t\tslab2 += bmp->dir;\n+\n+\t\t\tif (bmp->dir == RTE_BITMAP_FWD_SCAN)\n+\t\t\t\tbmp->go2 =\n+\t\t\t\t\tbmp->index2 & RTE_BITMAP_CL_SLAB_MASK;\n+\t\t\telse\n+\t\t\t\t/* stop once index2 crosses zero while\n+\t\t\t\t * decreasing.\n+\t\t\t\t */\n+\t\t\t\tbmp->go2 = (bmp->index2 ^ (~0));\n \t\t\treturn 1;\n \t\t}\n+\n+\t\tbmp->index2 += bmp->dir;\n+\t\tslab2 += bmp->dir;\n+\n+\t\tif (bmp->dir == RTE_BITMAP_FWD_SCAN)\n+\t\t\tbmp->go2 = bmp->index2 & RTE_BITMAP_CL_SLAB_MASK;\n+\t\telse\n+\t\t\tbmp->go2 = (bmp->index2 ^ (~0));\n+\n+\t\tbmp->index2 &= RTE_BITMAP_CL_SLAB_MASK;\n \t}\n \n \treturn 0;\n }\n \n /**\n- * Bitmap scan (with automatic wrap-around)\n+ * Bitmap scan generic (with automatic wrap-around)\n  *\n  * @param bmp\n  *   Handle to bitmap instance\n@@ -504,12 +591,20 @@ __rte_bitmap_scan_read(struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab)\n  *   after this slab, so the same slab will not be returned again if it\n  *   contains more than one bit which is set. When function call returns 0,\n  *   slab is not modified.\n+ * @param dir\n+ *   Scanning direction, whether in forward/positive(increasing bit index)\n+ *   or reverse/backward/negative(decreasing bit index) direction.\n  * @return\n  *   0 if there is no bit set in the bitmap, 1 otherwise\n  */\n static inline int\n-rte_bitmap_scan(struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab)\n+rte_bitmap_scan_generic(struct rte_bitmap *bmp, uint32_t *pos,\n+\t\t       uint64_t *slab, enum rte_scan_dir dir)\n {\n+\t/* Init scan parameters as per requested scan direction */\n+\tif (unlikely(bmp->dir != dir))\n+\t\t__rte_bitmap_scan_init_generic(bmp, dir);\n+\n \t/* Return data from current array2 line if available */\n \tif (__rte_bitmap_scan_read(bmp, pos, slab)) {\n \t\treturn 1;\n@@ -526,6 +621,33 @@ rte_bitmap_scan(struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab)\n \treturn 0;\n }\n \n+/**\n+ * Bitmap scan (with automatic wrap-around)\n+ *\n+ * @param bmp\n+ *   Handle to bitmap instance\n+ * @param pos\n+ *   When function call returns 1, pos contains the position of the next set\n+ *   bit, otherwise not modified\n+ * @param slab\n+ *   When function call returns 1, slab contains the value of the entire 64-bit\n+ *   slab where the bit indicated by pos is located. Slabs are always 64-bit\n+ *   aligned, so the position of the first bit of the slab (this bit is not\n+ *   necessarily set) is pos / 64. Once a slab has been returned by the bitmap\n+ *   scan operation, the internal pointers of the bitmap are updated to point\n+ *   after this slab, so the same slab will not be returned again if it\n+ *   contains more than one bit which is set. When function call returns 0,\n+ *   slab is not modified.\n+ * @return\n+ *   0 if there is no bit set in the bitmap, 1 otherwise\n+ */\n+static inline int\n+rte_bitmap_scan(struct rte_bitmap *bmp, uint32_t *pos,\n+\t\t       uint64_t *slab)\n+{\n+\treturn rte_bitmap_scan_generic(bmp, pos, slab, RTE_BITMAP_FWD_SCAN);\n+}\n+\n #ifdef __cplusplus\n }\n #endif\n",
    "prefixes": [
        "1/2"
    ]
}