get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42649,
    "url": "http://patches.dpdk.org/api/patches/42649/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1531133103-437316-9-git-send-email-yipeng1.wang@intel.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": "<1531133103-437316-9-git-send-email-yipeng1.wang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1531133103-437316-9-git-send-email-yipeng1.wang@intel.com",
    "date": "2018-07-09T10:45:03",
    "name": "[v4,8/8] hash: add new API function to query the key count",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "09f54ae59eda5e4ee5f5f261107d4fafbf6430bb",
    "submitter": {
        "id": 754,
        "url": "http://patches.dpdk.org/api/people/754/?format=api",
        "name": "Wang, Yipeng1",
        "email": "yipeng1.wang@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1531133103-437316-9-git-send-email-yipeng1.wang@intel.com/mbox/",
    "series": [
        {
            "id": 478,
            "url": "http://patches.dpdk.org/api/series/478/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=478",
            "date": "2018-07-09T10:44:55",
            "name": "Add read-write concurrency to rte_hash library",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/478/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42649/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/42649/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 BDAEE1B152;\n\tMon,  9 Jul 2018 19:52:37 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id C00365B12\n\tfor <dev@dpdk.org>; Mon,  9 Jul 2018 19:52:24 +0200 (CEST)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t09 Jul 2018 10:52:20 -0700",
            "from skx-yipeng.jf.intel.com ([10.54.81.175])\n\tby FMSMGA003.fm.intel.com with ESMTP; 09 Jul 2018 10:52:12 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,330,1526367600\"; d=\"scan'208\";a=\"63369604\"",
        "From": "Yipeng Wang <yipeng1.wang@intel.com>",
        "To": "pablo.de.lara.guarch@intel.com",
        "Cc": "dev@dpdk.org, yipeng1.wang@intel.com, bruce.richardson@intel.com,\n\thonnappa.nagarahalli@arm.com, vguvva@caviumnetworks.com,\n\tbrijesh.s.singh@gmail.com",
        "Date": "Mon,  9 Jul 2018 03:45:03 -0700",
        "Message-Id": "<1531133103-437316-9-git-send-email-yipeng1.wang@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1531133103-437316-1-git-send-email-yipeng1.wang@intel.com>",
        "References": "<1528455078-328182-1-git-send-email-yipeng1.wang@intel.com>\n\t<1531133103-437316-1-git-send-email-yipeng1.wang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v4 8/8] hash: add new API function to query the\n\tkey count",
        "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": "Add a new function, rte_hash_count, to return the number of keys that\nare currently stored in the hash table. Corresponding test functions are\nadded into hash_test and hash_multiwriter test.\n\nSigned-off-by: Yipeng Wang <yipeng1.wang@intel.com>\nAcked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>\n---\n lib/librte_hash/rte_cuckoo_hash.c    | 24 ++++++++++++++++++++++++\n lib/librte_hash/rte_hash.h           | 11 +++++++++++\n lib/librte_hash/rte_hash_version.map |  8 ++++++++\n test/test/test_hash.c                | 12 ++++++++++++\n test/test/test_hash_multiwriter.c    |  8 ++++++++\n 5 files changed, 63 insertions(+)",
    "diff": "diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c\nindex 35631cc..bb67ade 100644\n--- a/lib/librte_hash/rte_cuckoo_hash.c\n+++ b/lib/librte_hash/rte_cuckoo_hash.c\n@@ -370,6 +370,30 @@ rte_hash_secondary_hash(const hash_sig_t primary_hash)\n \treturn primary_hash ^ ((tag + 1) * alt_bits_xor);\n }\n \n+int32_t\n+rte_hash_count(const struct rte_hash *h)\n+{\n+\tuint32_t tot_ring_cnt, cached_cnt = 0;\n+\tuint32_t i, ret;\n+\n+\tif (h == NULL)\n+\t\treturn -EINVAL;\n+\n+\tif (h->multi_writer_support) {\n+\t\ttot_ring_cnt = h->entries + (RTE_MAX_LCORE - 1) *\n+\t\t\t\t\t(LCORE_CACHE_SIZE - 1);\n+\t\tfor (i = 0; i < RTE_MAX_LCORE; i++)\n+\t\t\tcached_cnt += h->local_free_slots[i].len;\n+\n+\t\tret = tot_ring_cnt - rte_ring_count(h->free_slots) -\n+\t\t\t\t\t\t\t\tcached_cnt;\n+\t} else {\n+\t\ttot_ring_cnt = h->entries;\n+\t\tret = tot_ring_cnt - rte_ring_count(h->free_slots);\n+\t}\n+\treturn ret;\n+}\n+\n /* Read write locks implemented using rte_rwlock */\n static inline void\n __hash_rw_writer_lock(const struct rte_hash *h)\ndiff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h\nindex ecb49e4..1f1a276 100644\n--- a/lib/librte_hash/rte_hash.h\n+++ b/lib/librte_hash/rte_hash.h\n@@ -127,6 +127,17 @@ void\n rte_hash_reset(struct rte_hash *h);\n \n /**\n+ * Return the number of keys in the hash table\n+ * @param h\n+ *  Hash table to query from\n+ * @return\n+ *   - -EINVAL if parameters are invalid\n+ *   - A value indicating how many keys were inserted in the table.\n+ */\n+int32_t\n+rte_hash_count(const struct rte_hash *h);\n+\n+/**\n  * Add a key-value pair to an existing hash table.\n  * This operation is not multi-thread safe\n  * and should only be called from one thread.\ndiff --git a/lib/librte_hash/rte_hash_version.map b/lib/librte_hash/rte_hash_version.map\nindex 52a2576..e216ac8 100644\n--- a/lib/librte_hash/rte_hash_version.map\n+++ b/lib/librte_hash/rte_hash_version.map\n@@ -45,3 +45,11 @@ DPDK_16.07 {\n \trte_hash_get_key_with_position;\n \n } DPDK_2.2;\n+\n+\n+DPDK_18.08 {\n+\tglobal:\n+\n+\trte_hash_count;\n+\n+} DPDK_16.07;\ndiff --git a/test/test/test_hash.c b/test/test/test_hash.c\nindex edf41f5..b3db9fd 100644\n--- a/test/test/test_hash.c\n+++ b/test/test/test_hash.c\n@@ -1103,6 +1103,7 @@ static int test_average_table_utilization(void)\n \tunsigned i, j;\n \tunsigned added_keys, average_keys_added = 0;\n \tint ret;\n+\tunsigned int cnt;\n \n \tprintf(\"\\n# Running test to determine average utilization\"\n \t       \"\\n  before adding elements begins to fail\\n\");\n@@ -1121,13 +1122,24 @@ static int test_average_table_utilization(void)\n \t\t\tfor (i = 0; i < ut_params.key_len; i++)\n \t\t\t\tsimple_key[i] = rte_rand() % 255;\n \t\t\tret = rte_hash_add_key(handle, simple_key);\n+\t\t\tif (ret < 0)\n+\t\t\t\tbreak;\n \t\t}\n+\n \t\tif (ret != -ENOSPC) {\n \t\t\tprintf(\"Unexpected error when adding keys\\n\");\n \t\t\trte_hash_free(handle);\n \t\t\treturn -1;\n \t\t}\n \n+\t\tcnt = rte_hash_count(handle);\n+\t\tif (cnt != added_keys) {\n+\t\t\tprintf(\"rte_hash_count returned wrong value %u, %u,\"\n+\t\t\t\t\t\"%u\\n\", j, added_keys, cnt);\n+\t\t\trte_hash_free(handle);\n+\t\t\treturn -1;\n+\t\t}\n+\n \t\taverage_keys_added += added_keys;\n \n \t\t/* Reset the table */\ndiff --git a/test/test/test_hash_multiwriter.c b/test/test/test_hash_multiwriter.c\nindex ef5fce3..f182f40 100644\n--- a/test/test/test_hash_multiwriter.c\n+++ b/test/test/test_hash_multiwriter.c\n@@ -116,6 +116,7 @@ test_hash_multiwriter(void)\n \n \tuint32_t duplicated_keys = 0;\n \tuint32_t lost_keys = 0;\n+\tuint32_t count;\n \n \tsnprintf(name, 32, \"test%u\", calledCount++);\n \thash_params.name = name;\n@@ -163,6 +164,13 @@ test_hash_multiwriter(void)\n \t\t\t\t NULL, CALL_MASTER);\n \trte_eal_mp_wait_lcore();\n \n+\tcount = rte_hash_count(handle);\n+\tif (count != rounded_nb_total_tsx_insertion) {\n+\t\tprintf(\"rte_hash_count returned wrong value %u, %d\\n\",\n+\t\t\t\trounded_nb_total_tsx_insertion, count);\n+\t\tgoto err3;\n+\t}\n+\n \twhile (rte_hash_iterate(handle, &next_key, &next_data, &iter) >= 0) {\n \t\t/* Search for the key in the list of keys added .*/\n \t\ti = *(const uint32_t *)next_key;\n",
    "prefixes": [
        "v4",
        "8/8"
    ]
}