get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 30537,
    "url": "http://patches.dpdk.org/api/patches/30537/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1508339034-171115-11-git-send-email-cristian.dumitrescu@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": "<1508339034-171115-11-git-send-email-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1508339034-171115-11-git-send-email-cristian.dumitrescu@intel.com",
    "date": "2017-10-18T15:03:27",
    "name": "[dpdk-dev,v3,10/18] librte_table: rework 8-byte key hash tables",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "fe19ff98270971a68483c8b4cd7dd7edb628b967",
    "submitter": {
        "id": 19,
        "url": "http://patches.dpdk.org/api/people/19/?format=api",
        "name": "Cristian Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1508339034-171115-11-git-send-email-cristian.dumitrescu@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/30537/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/30537/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 46B1F1B1FC;\n\tWed, 18 Oct 2017 17:04:31 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 50F001B1AB\n\tfor <dev@dpdk.org>; Wed, 18 Oct 2017 17:04:08 +0200 (CEST)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t18 Oct 2017 08:04:07 -0700",
            "from silpixa00382658.ir.intel.com ([10.237.223.29])\n\tby orsmga004.jf.intel.com with ESMTP; 18 Oct 2017 08:04:06 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.43,397,1503385200\"; d=\"scan'208\";a=\"139673050\"",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas@monjalon.net",
        "Date": "Wed, 18 Oct 2017 16:03:27 +0100",
        "Message-Id": "<1508339034-171115-11-git-send-email-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1508339034-171115-1-git-send-email-cristian.dumitrescu@intel.com>",
        "References": "<1507634341-72277-2-git-send-email-cristian.dumitrescu@intel.com>\n\t<1508339034-171115-1-git-send-email-cristian.dumitrescu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 10/18] librte_table: rework 8-byte key hash\n\ttables",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Rework for the 8-byte key hash tables (both the extendible\nbucket and LRU)to use the mask-based hash function and the\nunified parameter structure.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n .../pipeline/pipeline_flow_classification_be.c     |  14 +-\n .../ip_pipeline/pipeline/pipeline_routing_be.c     |  14 +-\n lib/librte_table/rte_table_hash.h                  |  54 ----\n lib/librte_table/rte_table_hash_key8.c             | 328 +++++++++++----------\n test/test-pipeline/pipeline_hash.c                 |  21 +-\n test/test/test_table_combined.c                    |  39 ++-\n test/test/test_table_tables.c                      | 101 ++-----\n 7 files changed, 242 insertions(+), 329 deletions(-)\n mode change 100644 => 100755 examples/ip_pipeline/pipeline/pipeline_routing_be.c\n mode change 100644 => 100755 test/test/test_table_combined.c\n mode change 100644 => 100755 test/test/test_table_tables.c",
    "diff": "diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c\nindex 4a4007c..47e6d35 100755\n--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c\n+++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c\n@@ -492,18 +492,6 @@ static void *pipeline_fc_init(struct pipeline_params *params,\n \t/* Tables */\n \tp->n_tables = 1;\n \t{\n-\t\tstruct rte_table_hash_key8_ext_params\n-\t\t\ttable_hash_key8_params = {\n-\t\t\t.n_entries = p_fc->n_flows,\n-\t\t\t.n_entries_ext = p_fc->n_flows,\n-\t\t\t.signature_offset = p_fc->hash_offset,\n-\t\t\t.key_offset = p_fc->key_offset,\n-\t\t\t.f_hash = hash_func[(p_fc->key_size / 8) - 1],\n-\t\t\t.key_mask = (p_fc->key_mask_present) ?\n-\t\t\t\tp_fc->key_mask : NULL,\n-\t\t\t.seed = 0,\n-\t\t};\n-\n \t\tstruct rte_table_hash_key16_ext_params\n \t\t\ttable_hash_key16_params = {\n \t\t\t.n_entries = p_fc->n_flows,\n@@ -543,7 +531,7 @@ static void *pipeline_fc_init(struct pipeline_params *params,\n \t\tswitch (p_fc->key_size) {\n \t\tcase 8:\n \t\t\ttable_params.ops = &rte_table_hash_key8_ext_ops;\n-\t\t\ttable_params.arg_create = &table_hash_key8_params;\n+\t\t\ttable_params.arg_create = &table_hash_params;\n \t\t\tbreak;\n \n \t\tcase 16:\ndiff --git a/examples/ip_pipeline/pipeline/pipeline_routing_be.c b/examples/ip_pipeline/pipeline/pipeline_routing_be.c\nold mode 100644\nnew mode 100755\nindex aa7f05e..796cde7\n--- a/examples/ip_pipeline/pipeline/pipeline_routing_be.c\n+++ b/examples/ip_pipeline/pipeline/pipeline_routing_be.c\n@@ -1349,13 +1349,15 @@ pipeline_routing_init(struct pipeline_params *params,\n \n \t/* ARP table configuration */\n \tif (p_rt->params.n_arp_entries) {\n-\t\tstruct rte_table_hash_key8_ext_params table_arp_params = {\n-\t\t\t.n_entries = p_rt->params.n_arp_entries,\n-\t\t\t.n_entries_ext = p_rt->params.n_arp_entries,\n-\t\t\t.f_hash = hash_default_key8,\n-\t\t\t.seed = 0,\n-\t\t\t.signature_offset = 0, /* Unused */\n+\t\tstruct rte_table_hash_params table_arp_params = {\n+\t\t\t.name = p->name,\n+\t\t\t.key_size = 8,\n \t\t\t.key_offset = p_rt->params.arp_key_offset,\n+\t\t\t.key_mask = NULL,\n+\t\t\t.n_keys = p_rt->params.n_arp_entries,\n+\t\t\t.n_buckets = p_rt->params.n_arp_entries / 4,\n+\t\t\t.f_hash = (rte_table_hash_op_hash)hash_default_key8,\n+\t\t\t.seed = 0,\n \t\t};\n \n \t\tstruct rte_pipeline_table_params table_params = {\ndiff --git a/lib/librte_table/rte_table_hash.h b/lib/librte_table/rte_table_hash.h\nindex fb5f4d7..6e25054 100755\n--- a/lib/librte_table/rte_table_hash.h\n+++ b/lib/librte_table/rte_table_hash.h\n@@ -139,62 +139,8 @@ extern struct rte_table_ops rte_table_hash_ext_ops;\n \n extern struct rte_table_ops rte_table_hash_lru_ops;\n \n-/**\n- * 8-byte key hash tables\n- *\n- */\n-/** LRU hash table parameters */\n-struct rte_table_hash_key8_lru_params {\n-\t/** Maximum number of entries (and keys) in the table */\n-\tuint32_t n_entries;\n-\n-\t/** Hash function */\n-\trte_table_hash_op_hash_nomask f_hash;\n-\n-\t/** Seed for the hash function */\n-\tuint64_t seed;\n-\n-\t/** Byte offset within packet meta-data where the 4-byte key signature\n-\tis located. Valid for pre-computed key signature tables, ignored for\n-\tdo-sig tables. */\n-\tuint32_t signature_offset;\n-\n-\t/** Byte offset within packet meta-data where the key is located */\n-\tuint32_t key_offset;\n-\n-\t/** Bit-mask to be AND-ed to the key on lookup */\n-\tuint8_t *key_mask;\n-};\n-\n extern struct rte_table_ops rte_table_hash_key8_lru_ops;\n \n-/** Extendible bucket hash table parameters */\n-struct rte_table_hash_key8_ext_params {\n-\t/** Maximum number of entries (and keys) in the table */\n-\tuint32_t n_entries;\n-\n-\t/** Number of entries (and keys) for hash table bucket extensions. Each\n-\t\tbucket is extended in increments of 4 keys. */\n-\tuint32_t n_entries_ext;\n-\n-\t/** Hash function */\n-\trte_table_hash_op_hash_nomask f_hash;\n-\n-\t/** Seed for the hash function */\n-\tuint64_t seed;\n-\n-\t/** Byte offset within packet meta-data where the 4-byte key signature\n-\tis located. Valid for pre-computed key signature tables, ignored for\n-\tdo-sig tables. */\n-\tuint32_t signature_offset;\n-\n-\t/** Byte offset within packet meta-data where the key is located */\n-\tuint32_t key_offset;\n-\n-\t/** Bit-mask to be AND-ed to the key on lookup */\n-\tuint8_t *key_mask;\n-};\n-\n extern struct rte_table_ops rte_table_hash_key8_ext_ops;\n \n /**\ndiff --git a/lib/librte_table/rte_table_hash_key8.c b/lib/librte_table/rte_table_hash_key8.c\nindex 4fbb02e..a44f75c 100644\n--- a/lib/librte_table/rte_table_hash_key8.c\n+++ b/lib/librte_table/rte_table_hash_key8.c\n@@ -42,7 +42,9 @@\n #include \"rte_table_hash.h\"\n #include \"rte_lru.h\"\n \n-#define RTE_TABLE_HASH_KEY_SIZE\t\t\t\t\t\t8\n+#define KEY_SIZE\t\t\t\t\t\t8\n+\n+#define KEYS_PER_BUCKET\t\t\t\t\t4\n \n #ifdef RTE_TABLE_STATS_COLLECT\n \n@@ -76,14 +78,12 @@ struct rte_table_hash {\n \n \t/* Input parameters */\n \tuint32_t n_buckets;\n-\tuint32_t n_entries_per_bucket;\n \tuint32_t key_size;\n \tuint32_t entry_size;\n \tuint32_t bucket_size;\n-\tuint32_t signature_offset;\n \tuint32_t key_offset;\n \tuint64_t key_mask;\n-\trte_table_hash_op_hash_nomask f_hash;\n+\trte_table_hash_op_hash f_hash;\n \tuint64_t seed;\n \n \t/* Extendible buckets */\n@@ -96,10 +96,46 @@ struct rte_table_hash {\n };\n \n static int\n-check_params_create_lru(struct rte_table_hash_key8_lru_params *params) {\n-\t/* n_entries */\n-\tif (params->n_entries == 0) {\n-\t\tRTE_LOG(ERR, TABLE, \"%s: n_entries is zero\\n\", __func__);\n+keycmp(void *a, void *b, void *b_mask)\n+{\n+\tuint64_t *a64 = a, *b64 = b, *b_mask64 = b_mask;\n+\n+\treturn a64[0] != (b64[0] & b_mask64[0]);\n+}\n+\n+static void\n+keycpy(void *dst, void *src, void *src_mask)\n+{\n+\tuint64_t *dst64 = dst, *src64 = src, *src_mask64 = src_mask;\n+\n+\tdst64[0] = src64[0] & src_mask64[0];\n+}\n+\n+static int\n+check_params_create(struct rte_table_hash_params *params)\n+{\n+\t/* name */\n+\tif (params->name == NULL) {\n+\t\tRTE_LOG(ERR, TABLE, \"%s: name invalid value\\n\", __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* key_size */\n+\tif (params->key_size != KEY_SIZE) {\n+\t\tRTE_LOG(ERR, TABLE, \"%s: key_size invalid value\\n\", __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* n_keys */\n+\tif (params->n_keys == 0) {\n+\t\tRTE_LOG(ERR, TABLE, \"%s: n_keys is zero\\n\", __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* n_buckets */\n+\tif ((params->n_buckets == 0) ||\n+\t\t(!rte_is_power_of_2(params->n_buckets))) {\n+\t\tRTE_LOG(ERR, TABLE, \"%s: n_buckets invalid value\\n\", __func__);\n \t\treturn -EINVAL;\n \t}\n \n@@ -116,47 +152,68 @@ check_params_create_lru(struct rte_table_hash_key8_lru_params *params) {\n static void *\n rte_table_hash_create_key8_lru(void *params, int socket_id, uint32_t entry_size)\n {\n-\tstruct rte_table_hash_key8_lru_params *p =\n-\t\t(struct rte_table_hash_key8_lru_params *) params;\n+\tstruct rte_table_hash_params *p = params;\n \tstruct rte_table_hash *f;\n-\tuint32_t n_buckets, n_entries_per_bucket, key_size, bucket_size_cl;\n-\tuint32_t total_size, i;\n+\tuint64_t bucket_size, total_size;\n+\tuint32_t n_buckets, i;\n \n \t/* Check input parameters */\n-\tif ((check_params_create_lru(p) != 0) ||\n+\tif ((check_params_create(p) != 0) ||\n \t\t((sizeof(struct rte_table_hash) % RTE_CACHE_LINE_SIZE) != 0) ||\n-\t\t((sizeof(struct rte_bucket_4_8) % 64) != 0)) {\n+\t\t((sizeof(struct rte_bucket_4_8) % 64) != 0))\n \t\treturn NULL;\n-\t}\n-\tn_entries_per_bucket = 4;\n-\tkey_size = 8;\n+\n+\t/*\n+\t * Table dimensioning\n+\t *\n+\t * Objective: Pick the number of buckets (n_buckets) so that there a chance\n+\t * to store n_keys keys in the table.\n+\t *\n+\t * Note: Since the buckets do not get extended, it is not possible to\n+\t * guarantee that n_keys keys can be stored in the table at any time. In the\n+\t * worst case scenario when all the n_keys fall into the same bucket, only\n+\t * a maximum of KEYS_PER_BUCKET keys will be stored in the table. This case\n+\t * defeats the purpose of the hash table. It indicates unsuitable f_hash or\n+\t * n_keys to n_buckets ratio.\n+\t *\n+\t * MIN(n_buckets) = (n_keys + KEYS_PER_BUCKET - 1) / KEYS_PER_BUCKET\n+\t */\n+\tn_buckets = rte_align32pow2(\n+\t\t(p->n_keys + KEYS_PER_BUCKET - 1) / KEYS_PER_BUCKET);\n+\tn_buckets = RTE_MAX(n_buckets, p->n_buckets);\n \n \t/* Memory allocation */\n-\tn_buckets = rte_align32pow2((p->n_entries + n_entries_per_bucket - 1) /\n-\t\tn_entries_per_bucket);\n-\tbucket_size_cl = (sizeof(struct rte_bucket_4_8) + n_entries_per_bucket *\n-\t\tentry_size + RTE_CACHE_LINE_SIZE - 1) / RTE_CACHE_LINE_SIZE;\n-\ttotal_size = sizeof(struct rte_table_hash) + n_buckets *\n-\t\tbucket_size_cl * RTE_CACHE_LINE_SIZE;\n-\n-\tf = rte_zmalloc_socket(\"TABLE\", total_size, RTE_CACHE_LINE_SIZE, socket_id);\n+\tbucket_size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct rte_bucket_4_8) +\n+\t\tKEYS_PER_BUCKET * entry_size);\n+\ttotal_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size;\n+\n+\tif (total_size > SIZE_MAX) {\n+\t\tRTE_LOG(ERR, TABLE, \"%s: Cannot allocate %\" PRIu64 \" bytes\"\n+\t\t\t\" for hash table %s\\n\",\n+\t\t\t__func__, total_size, p->name);\n+\t\treturn NULL;\n+\t}\n+\n+\tf = rte_zmalloc_socket(p->name,\n+\t\t(size_t)total_size,\n+\t\tRTE_CACHE_LINE_SIZE,\n+\t\tsocket_id);\n \tif (f == NULL) {\n-\t\tRTE_LOG(ERR, TABLE,\n-\t\t\t\"%s: Cannot allocate %u bytes for hash table\\n\",\n-\t\t\t__func__, total_size);\n+\t\tRTE_LOG(ERR, TABLE, \"%s: Cannot allocate %\" PRIu64 \" bytes\"\n+\t\t\t\" for hash table %s\\n\",\n+\t\t\t__func__, total_size, p->name);\n \t\treturn NULL;\n \t}\n-\tRTE_LOG(INFO, TABLE,\n-\t\t\"%s: Hash table memory footprint is %u bytes\\n\",\n-\t\t__func__, total_size);\n+\n+\tRTE_LOG(INFO, TABLE, \"%s: Hash table %s memory footprint \"\n+\t\t\"is %\" PRIu64 \" bytes\\n\",\n+\t\t__func__, p->name, total_size);\n \n \t/* Memory initialization */\n \tf->n_buckets = n_buckets;\n-\tf->n_entries_per_bucket = n_entries_per_bucket;\n-\tf->key_size = key_size;\n+\tf->key_size = KEY_SIZE;\n \tf->entry_size = entry_size;\n-\tf->bucket_size = bucket_size_cl * RTE_CACHE_LINE_SIZE;\n-\tf->signature_offset = p->signature_offset;\n+\tf->bucket_size = bucket_size;\n \tf->key_offset = p->key_offset;\n \tf->f_hash = p->f_hash;\n \tf->seed = p->seed;\n@@ -205,7 +262,7 @@ rte_table_hash_entry_add_key8_lru(\n \tuint64_t signature, mask, pos;\n \tuint32_t bucket_index, i;\n \n-\tsignature = f->f_hash(key, f->key_size, f->seed);\n+\tsignature = f->f_hash(key, &f->key_mask, f->key_size, f->seed);\n \tbucket_index = signature & (f->n_buckets - 1);\n \tbucket = (struct rte_bucket_4_8 *)\n \t\t&f->memory[bucket_index * f->bucket_size];\n@@ -213,10 +270,10 @@ rte_table_hash_entry_add_key8_lru(\n \t/* Key is present in the bucket */\n \tfor (i = 0, mask = 1LLU; i < 4; i++, mask <<= 1) {\n \t\tuint64_t bucket_signature = bucket->signature;\n-\t\tuint64_t bucket_key = bucket->key[i];\n+\t\tuint64_t *bucket_key = &bucket->key[i];\n \n \t\tif ((bucket_signature & mask) &&\n-\t\t    (*((uint64_t *) key) == bucket_key)) {\n+\t\t\t(keycmp(bucket_key, key, &f->key_mask) == 0)) {\n \t\t\tuint8_t *bucket_data = &bucket->data[i * f->entry_size];\n \n \t\t\tmemcpy(bucket_data, entry, f->entry_size);\n@@ -235,7 +292,7 @@ rte_table_hash_entry_add_key8_lru(\n \t\t\tuint8_t *bucket_data = &bucket->data[i * f->entry_size];\n \n \t\t\tbucket->signature |= mask;\n-\t\t\tbucket->key[i] = *((uint64_t *) key);\n+\t\t\tkeycpy(&bucket->key[i], key, &f->key_mask);\n \t\t\tmemcpy(bucket_data, entry, f->entry_size);\n \t\t\tlru_update(bucket, i);\n \t\t\t*key_found = 0;\n@@ -247,10 +304,10 @@ rte_table_hash_entry_add_key8_lru(\n \n \t/* Bucket full: replace LRU entry */\n \tpos = lru_pos(bucket);\n-\tbucket->key[pos] = *((uint64_t *) key);\n+\tkeycpy(&bucket->key[pos], key, &f->key_mask);\n \tmemcpy(&bucket->data[pos * f->entry_size], entry, f->entry_size);\n \tlru_update(bucket, pos);\n-\t*key_found\t= 0;\n+\t*key_found = 0;\n \t*entry_ptr = (void *) &bucket->data[pos * f->entry_size];\n \n \treturn 0;\n@@ -268,7 +325,7 @@ rte_table_hash_entry_delete_key8_lru(\n \tuint64_t signature, mask;\n \tuint32_t bucket_index, i;\n \n-\tsignature = f->f_hash(key, f->key_size, f->seed);\n+\tsignature = f->f_hash(key, &f->key_mask, f->key_size, f->seed);\n \tbucket_index = signature & (f->n_buckets - 1);\n \tbucket = (struct rte_bucket_4_8 *)\n \t\t&f->memory[bucket_index * f->bucket_size];\n@@ -276,10 +333,10 @@ rte_table_hash_entry_delete_key8_lru(\n \t/* Key is present in the bucket */\n \tfor (i = 0, mask = 1LLU; i < 4; i++, mask <<= 1) {\n \t\tuint64_t bucket_signature = bucket->signature;\n-\t\tuint64_t bucket_key = bucket->key[i];\n+\t\tuint64_t *bucket_key = &bucket->key[i];\n \n \t\tif ((bucket_signature & mask) &&\n-\t\t    (*((uint64_t *) key) == bucket_key)) {\n+\t\t\t(keycmp(bucket_key, key, &f->key_mask) == 0)) {\n \t\t\tuint8_t *bucket_data = &bucket->data[i * f->entry_size];\n \n \t\t\tbucket->signature &= ~mask;\n@@ -296,79 +353,71 @@ rte_table_hash_entry_delete_key8_lru(\n \treturn 0;\n }\n \n-static int\n-check_params_create_ext(struct rte_table_hash_key8_ext_params *params) {\n-\t/* n_entries */\n-\tif (params->n_entries == 0) {\n-\t\tRTE_LOG(ERR, TABLE, \"%s: n_entries is zero\\n\", __func__);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t/* n_entries_ext */\n-\tif (params->n_entries_ext == 0) {\n-\t\tRTE_LOG(ERR, TABLE, \"%s: n_entries_ext is zero\\n\", __func__);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t/* f_hash */\n-\tif (params->f_hash == NULL) {\n-\t\tRTE_LOG(ERR, TABLE, \"%s: f_hash function pointer is NULL\\n\",\n-\t\t\t__func__);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\treturn 0;\n-}\n-\n static void *\n rte_table_hash_create_key8_ext(void *params, int socket_id, uint32_t entry_size)\n {\n-\tstruct rte_table_hash_key8_ext_params *p =\n-\t\t(struct rte_table_hash_key8_ext_params *) params;\n+\tstruct rte_table_hash_params *p = params;\n \tstruct rte_table_hash *f;\n-\tuint32_t n_buckets, n_buckets_ext, n_entries_per_bucket, key_size;\n-\tuint32_t bucket_size_cl, stack_size_cl, total_size, i;\n+\tuint64_t bucket_size, stack_size, total_size;\n+\tuint32_t n_buckets_ext, i;\n \n \t/* Check input parameters */\n-\tif ((check_params_create_ext(p) != 0) ||\n+\tif ((check_params_create(p) != 0) ||\n \t\t((sizeof(struct rte_table_hash) % RTE_CACHE_LINE_SIZE) != 0) ||\n \t\t((sizeof(struct rte_bucket_4_8) % 64) != 0))\n \t\treturn NULL;\n \n-\tn_entries_per_bucket = 4;\n-\tkey_size = 8;\n+\t/*\n+\t * Table dimensioning\n+\t *\n+\t * Objective: Pick the number of bucket extensions (n_buckets_ext) so that\n+\t * it is guaranteed that n_keys keys can be stored in the table at any time.\n+\t *\n+\t * The worst case scenario takes place when all the n_keys keys fall into\n+\t * the same bucket. Actually, due to the KEYS_PER_BUCKET scheme, the worst\n+\t * case takes place when (n_keys - KEYS_PER_BUCKET + 1) keys fall into the\n+\t * same bucket, while the remaining (KEYS_PER_BUCKET - 1) keys each fall\n+\t * into a different bucket. This case defeats the purpose of the hash table.\n+\t * It indicates unsuitable f_hash or n_keys to n_buckets ratio.\n+\t *\n+\t * n_buckets_ext = n_keys / KEYS_PER_BUCKET + KEYS_PER_BUCKET - 1\n+\t */\n+\tn_buckets_ext = p->n_keys / KEYS_PER_BUCKET + KEYS_PER_BUCKET - 1;\n \n \t/* Memory allocation */\n-\tn_buckets = rte_align32pow2((p->n_entries + n_entries_per_bucket - 1) /\n-\t\tn_entries_per_bucket);\n-\tn_buckets_ext = (p->n_entries_ext + n_entries_per_bucket - 1) /\n-\t\tn_entries_per_bucket;\n-\tbucket_size_cl = (sizeof(struct rte_bucket_4_8) + n_entries_per_bucket *\n-\t\tentry_size + RTE_CACHE_LINE_SIZE - 1) / RTE_CACHE_LINE_SIZE;\n-\tstack_size_cl = (n_buckets_ext * sizeof(uint32_t) + RTE_CACHE_LINE_SIZE - 1)\n-\t\t/ RTE_CACHE_LINE_SIZE;\n-\ttotal_size = sizeof(struct rte_table_hash) + ((n_buckets +\n-\t\tn_buckets_ext) * bucket_size_cl + stack_size_cl) *\n-\t\tRTE_CACHE_LINE_SIZE;\n-\n-\tf = rte_zmalloc_socket(\"TABLE\", total_size, RTE_CACHE_LINE_SIZE, socket_id);\n+\tbucket_size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct rte_bucket_4_8) +\n+\t\tKEYS_PER_BUCKET * entry_size);\n+\tstack_size = RTE_CACHE_LINE_ROUNDUP(n_buckets_ext * sizeof(uint32_t));\n+\ttotal_size = sizeof(struct rte_table_hash) +\n+\t\t(p->n_buckets + n_buckets_ext) * bucket_size + stack_size;\n+\n+\tif (total_size > SIZE_MAX) {\n+\t\tRTE_LOG(ERR, TABLE, \"%s: Cannot allocate %\" PRIu64 \" bytes \"\n+\t\t\t\"for hash table %s\\n\",\n+\t\t\t__func__, total_size, p->name);\n+\t\treturn NULL;\n+\t}\n+\n+\tf = rte_zmalloc_socket(p->name,\n+\t\t(size_t)total_size,\n+\t\tRTE_CACHE_LINE_SIZE,\n+\t\tsocket_id);\n \tif (f == NULL) {\n \t\tRTE_LOG(ERR, TABLE,\n-\t\t\t\"%s: Cannot allocate %u bytes for hash table\\n\",\n-\t\t\t__func__, total_size);\n+\t\t\t\"%s: Cannot allocate %\" PRIu64 \" bytes \"\n+\t\t\t\"for hash table %s\\n\",\n+\t\t\t__func__, total_size, p->name);\n \t\treturn NULL;\n \t}\n-\tRTE_LOG(INFO, TABLE,\n-\t\t\"%s: Hash table memory footprint is %u bytes\\n\",\n-\t\t__func__, total_size);\n+\tRTE_LOG(INFO, TABLE, \"%s: Hash table %s memory footprint \"\n+\t\t\"is %\" PRIu64 \" bytes\\n\",\n+\t\t__func__, p->name, total_size);\n \n \t/* Memory initialization */\n-\tf->n_buckets = n_buckets;\n-\tf->n_entries_per_bucket = n_entries_per_bucket;\n-\tf->key_size = key_size;\n+\tf->n_buckets = p->n_buckets;\n+\tf->key_size = KEY_SIZE;\n \tf->entry_size = entry_size;\n-\tf->bucket_size = bucket_size_cl * RTE_CACHE_LINE_SIZE;\n-\tf->signature_offset = p->signature_offset;\n+\tf->bucket_size = bucket_size;\n \tf->key_offset = p->key_offset;\n \tf->f_hash = p->f_hash;\n \tf->seed = p->seed;\n@@ -376,7 +425,7 @@ rte_table_hash_create_key8_ext(void *params, int socket_id, uint32_t entry_size)\n \tf->n_buckets_ext = n_buckets_ext;\n \tf->stack_pos = n_buckets_ext;\n \tf->stack = (uint32_t *)\n-\t\t&f->memory[(n_buckets + n_buckets_ext) * f->bucket_size];\n+\t\t&f->memory[(p->n_buckets + n_buckets_ext) * f->bucket_size];\n \n \tif (p->key_mask != NULL)\n \t\tf->key_mask = ((uint64_t *)p->key_mask)[0];\n@@ -417,7 +466,7 @@ rte_table_hash_entry_add_key8_ext(\n \tuint64_t signature;\n \tuint32_t bucket_index, i;\n \n-\tsignature = f->f_hash(key, f->key_size, f->seed);\n+\tsignature = f->f_hash(key, &f->key_mask, f->key_size, f->seed);\n \tbucket_index = signature & (f->n_buckets - 1);\n \tbucket0 = (struct rte_bucket_4_8 *)\n \t\t&f->memory[bucket_index * f->bucket_size];\n@@ -428,10 +477,10 @@ rte_table_hash_entry_add_key8_ext(\n \n \t\tfor (i = 0, mask = 1LLU; i < 4; i++, mask <<= 1) {\n \t\t\tuint64_t bucket_signature = bucket->signature;\n-\t\t\tuint64_t bucket_key = bucket->key[i];\n+\t\t\tuint64_t *bucket_key = &bucket->key[i];\n \n \t\t\tif ((bucket_signature & mask) &&\n-\t\t\t\t\t(*((uint64_t *) key) == bucket_key)) {\n+\t\t\t\t(keycmp(bucket_key, key, &f->key_mask) == 0)) {\n \t\t\t\tuint8_t *bucket_data = &bucket->data[i *\n \t\t\t\t\tf->entry_size];\n \n@@ -456,7 +505,7 @@ rte_table_hash_entry_add_key8_ext(\n \t\t\t\t\tf->entry_size];\n \n \t\t\t\tbucket->signature |= mask;\n-\t\t\t\tbucket->key[i] = *((uint64_t *) key);\n+\t\t\t\tkeycpy(&bucket->key[i], key, &f->key_mask);\n \t\t\t\tmemcpy(bucket_data, entry, f->entry_size);\n \t\t\t\t*key_found = 0;\n \t\t\t\t*entry_ptr = (void *) bucket_data;\n@@ -476,7 +525,7 @@ rte_table_hash_entry_add_key8_ext(\n \t\tbucket_prev->next_valid = 1;\n \n \t\tbucket->signature = 1;\n-\t\tbucket->key[0] = *((uint64_t *) key);\n+\t\tkeycpy(&bucket->key[0], key, &f->key_mask);\n \t\tmemcpy(&bucket->data[0], entry, f->entry_size);\n \t\t*key_found = 0;\n \t\t*entry_ptr = (void *) &bucket->data[0];\n@@ -498,7 +547,7 @@ rte_table_hash_entry_delete_key8_ext(\n \tuint64_t signature;\n \tuint32_t bucket_index, i;\n \n-\tsignature = f->f_hash(key, f->key_size, f->seed);\n+\tsignature = f->f_hash(key, &f->key_mask, f->key_size, f->seed);\n \tbucket_index = signature & (f->n_buckets - 1);\n \tbucket0 = (struct rte_bucket_4_8 *)\n \t\t&f->memory[bucket_index * f->bucket_size];\n@@ -510,10 +559,10 @@ rte_table_hash_entry_delete_key8_ext(\n \n \t\tfor (i = 0, mask = 1LLU; i < 4; i++, mask <<= 1) {\n \t\t\tuint64_t bucket_signature = bucket->signature;\n-\t\t\tuint64_t bucket_key = bucket->key[i];\n+\t\t\tuint64_t *bucket_key = &bucket->key[i];\n \n \t\t\tif ((bucket_signature & mask) &&\n-\t\t\t\t(*((uint64_t *) key) == bucket_key)) {\n+\t\t\t\t(keycmp(bucket_key, key, &f->key_mask) == 0)) {\n \t\t\t\tuint8_t *bucket_data = &bucket->data[i *\n \t\t\t\t\tf->entry_size];\n \n@@ -546,16 +595,17 @@ rte_table_hash_entry_delete_key8_ext(\n \treturn 0;\n }\n \n-#define lookup_key8_cmp(key_in, bucket, pos)\t\t\t\\\n+#define lookup_key8_cmp(key_in, bucket, pos, f)\t\t\t\\\n {\t\t\t\t\t\t\t\t\\\n-\tuint64_t xor[4], signature;\t\t\t\t\\\n+\tuint64_t xor[4], signature, k;\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tsignature = ~bucket->signature;\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n-\txor[0] = (key_in[0] ^\t bucket->key[0]) | (signature & 1);\\\n-\txor[1] = (key_in[0] ^\t bucket->key[1]) | (signature & 2);\\\n-\txor[2] = (key_in[0] ^\t bucket->key[2]) | (signature & 4);\\\n-\txor[3] = (key_in[0] ^\t bucket->key[3]) | (signature & 8);\\\n+\tk = key_in[0] & f->key_mask;\t\t\t\t\\\n+\txor[0] = (k ^ bucket->key[0]) | (signature & 1);\t\t\\\n+\txor[1] = (k ^ bucket->key[1]) | (signature & 2);\t\t\\\n+\txor[2] = (k ^ bucket->key[2]) | (signature & 4);\t\t\\\n+\txor[3] = (k ^ bucket->key[3]) | (signature & 8);\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tpos = 4;\t\t\t\t\t\t\\\n \tif (xor[0] == 0)\t\t\t\t\t\\\n@@ -586,12 +636,9 @@ rte_table_hash_entry_delete_key8_ext(\n \tuint64_t *key;\t\t\t\t\t\t\\\n \tuint64_t signature;\t\t\t\t\t\\\n \tuint32_t bucket_index;\t\t\t\t\t\\\n-\tuint64_t hash_key_buffer;\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tkey = RTE_MBUF_METADATA_UINT64_PTR(mbuf1, f->key_offset);\\\n-\thash_key_buffer = *key & f->key_mask;\t\t\t\\\n-\tsignature = f->f_hash(&hash_key_buffer,\t\t\t\\\n-\t\tRTE_TABLE_HASH_KEY_SIZE, f->seed);\t\t\\\n+\tsignature = f->f_hash(key, &f->key_mask, KEY_SIZE, f->seed);\t\\\n \tbucket_index = signature & (f->n_buckets - 1);\t\t\\\n \tbucket1 = (struct rte_bucket_4_8 *)\t\t\t\\\n \t\t&f->memory[bucket_index * f->bucket_size];\t\\\n@@ -605,12 +652,9 @@ rte_table_hash_entry_delete_key8_ext(\n \tuint64_t pkt_mask;\t\t\t\t\t\\\n \tuint64_t *key;\t\t\t\t\t\t\\\n \tuint32_t pos;\t\t\t\t\t\t\\\n-\tuint64_t hash_key_buffer;\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tkey = RTE_MBUF_METADATA_UINT64_PTR(mbuf2, f->key_offset);\\\n-\thash_key_buffer = key[0] & f->key_mask;\t\t\t\\\n-\t\t\t\t\t\t\t\t\\\n-\tlookup_key8_cmp((&hash_key_buffer), bucket2, pos);\t\\\n+\tlookup_key8_cmp(key, bucket2, pos, f);\t\\\n \t\t\t\t\t\t\t\t\\\n \tpkt_mask = ((bucket2->signature >> pos) & 1LLU) << pkt2_index;\\\n \tpkts_mask_out |= pkt_mask;\t\t\t\t\\\n@@ -629,12 +673,9 @@ rte_table_hash_entry_delete_key8_ext(\n \tuint64_t pkt_mask, bucket_mask;\t\t\t\t\\\n \tuint64_t *key;\t\t\t\t\t\t\\\n \tuint32_t pos;\t\t\t\t\t\t\\\n-\tuint64_t hash_key_buffer;\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tkey = RTE_MBUF_METADATA_UINT64_PTR(mbuf2, f->key_offset);\\\n-\thash_key_buffer = *key & f->key_mask;\t\t\t\\\n-\t\t\t\t\t\t\t\t\\\n-\tlookup_key8_cmp((&hash_key_buffer), bucket2, pos);\t\\\n+\tlookup_key8_cmp(key, bucket2, pos, f);\t\\\n \t\t\t\t\t\t\t\t\\\n \tpkt_mask = ((bucket2->signature >> pos) & 1LLU) << pkt2_index;\\\n \tpkts_mask_out |= pkt_mask;\t\t\t\t\\\n@@ -658,13 +699,10 @@ rte_table_hash_entry_delete_key8_ext(\n \tuint64_t pkt_mask, bucket_mask;\t\t\t\t\\\n \tuint64_t *key;\t\t\t\t\t\t\\\n \tuint32_t pos;\t\t\t\t\t\t\\\n-\tuint64_t hash_key_buffer;\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tbucket = buckets[pkt_index];\t\t\t\t\\\n \tkey = keys[pkt_index];\t\t\t\t\t\\\n-\thash_key_buffer = (*key) & f->key_mask;\t\t\t\\\n-\t\t\t\t\t\t\t\t\\\n-\tlookup_key8_cmp((&hash_key_buffer), bucket, pos);\t\\\n+\tlookup_key8_cmp(key, bucket, pos, f);\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tpkt_mask = ((bucket->signature >> pos) & 1LLU) << pkt_index;\\\n \tpkts_mask_out |= pkt_mask;\t\t\t\t\\\n@@ -729,28 +767,22 @@ rte_table_hash_entry_delete_key8_ext(\n #define lookup2_stage1(mbuf10, mbuf11, bucket10, bucket11, f)\\\n {\t\t\t\t\t\t\t\t\\\n \tuint64_t *key10, *key11;\t\t\t\t\\\n-\tuint64_t hash_offset_buffer10;\t\t\t\t\\\n-\tuint64_t hash_offset_buffer11;\t\t\t\t\\\n \tuint64_t signature10, signature11;\t\t\t\\\n \tuint32_t bucket10_index, bucket11_index;\t\t\\\n-\trte_table_hash_op_hash_nomask f_hash = f->f_hash;\t\t\\\n+\trte_table_hash_op_hash f_hash = f->f_hash;\t\t\\\n \tuint64_t seed = f->seed;\t\t\t\t\\\n \tuint32_t key_offset = f->key_offset;\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tkey10 = RTE_MBUF_METADATA_UINT64_PTR(mbuf10, key_offset);\\\n \tkey11 = RTE_MBUF_METADATA_UINT64_PTR(mbuf11, key_offset);\\\n-\thash_offset_buffer10 = *key10 & f->key_mask;\t\t\\\n-\thash_offset_buffer11 = *key11 & f->key_mask;\t\t\\\n \t\t\t\t\t\t\t\t\\\n-\tsignature10 = f_hash(&hash_offset_buffer10,\t\t\\\n-\t\tRTE_TABLE_HASH_KEY_SIZE, seed);\t\t\t\\\n+\tsignature10 = f_hash(key10, &f->key_mask, KEY_SIZE, seed);\t\\\n \tbucket10_index = signature10 & (f->n_buckets - 1);\t\\\n \tbucket10 = (struct rte_bucket_4_8 *)\t\t\t\\\n \t\t&f->memory[bucket10_index * f->bucket_size];\t\\\n \trte_prefetch0(bucket10);\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n-\tsignature11 = f_hash(&hash_offset_buffer11,\t\t\\\n-\t\tRTE_TABLE_HASH_KEY_SIZE, seed);\t\t\t\\\n+\tsignature11 = f_hash(key11, &f->key_mask, KEY_SIZE, seed);\t\\\n \tbucket11_index = signature11 & (f->n_buckets - 1);\t\\\n \tbucket11 = (struct rte_bucket_4_8 *)\t\t\t\\\n \t\t&f->memory[bucket11_index * f->bucket_size];\t\\\n@@ -763,17 +795,13 @@ rte_table_hash_entry_delete_key8_ext(\n \tvoid *a20, *a21;\t\t\t\t\t\\\n \tuint64_t pkt20_mask, pkt21_mask;\t\t\t\\\n \tuint64_t *key20, *key21;\t\t\t\t\\\n-\tuint64_t hash_offset_buffer20;\t\t\t\t\\\n-\tuint64_t hash_offset_buffer21;\t\t\t\t\\\n \tuint32_t pos20, pos21;\t\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tkey20 = RTE_MBUF_METADATA_UINT64_PTR(mbuf20, f->key_offset);\\\n \tkey21 = RTE_MBUF_METADATA_UINT64_PTR(mbuf21, f->key_offset);\\\n-\thash_offset_buffer20 = *key20 & f->key_mask;\t\t\\\n-\thash_offset_buffer21 = *key21 & f->key_mask;\t\t\\\n \t\t\t\t\t\t\t\t\\\n-\tlookup_key8_cmp((&hash_offset_buffer20), bucket20, pos20);\\\n-\tlookup_key8_cmp((&hash_offset_buffer21), bucket21, pos21);\\\n+\tlookup_key8_cmp(key20, bucket20, pos20, f);\t\t\t\\\n+\tlookup_key8_cmp(key21, bucket21, pos21, f);\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tpkt20_mask = ((bucket20->signature >> pos20) & 1LLU) << pkt20_index;\\\n \tpkt21_mask = ((bucket21->signature >> pos21) & 1LLU) << pkt21_index;\\\n@@ -796,17 +824,13 @@ rte_table_hash_entry_delete_key8_ext(\n \tvoid *a20, *a21;\t\t\t\t\t\\\n \tuint64_t pkt20_mask, pkt21_mask, bucket20_mask, bucket21_mask;\\\n \tuint64_t *key20, *key21;\t\t\t\t\\\n-\tuint64_t hash_offset_buffer20;\t\t\t\t\\\n-\tuint64_t hash_offset_buffer21;\t\t\t\t\\\n \tuint32_t pos20, pos21;\t\t\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tkey20 = RTE_MBUF_METADATA_UINT64_PTR(mbuf20, f->key_offset);\\\n \tkey21 = RTE_MBUF_METADATA_UINT64_PTR(mbuf21, f->key_offset);\\\n-\thash_offset_buffer20 = *key20 & f->key_mask;\t\t\\\n-\thash_offset_buffer21 = *key21 & f->key_mask;\t\t\\\n \t\t\t\t\t\t\t\t\\\n-\tlookup_key8_cmp((&hash_offset_buffer20), bucket20, pos20);\\\n-\tlookup_key8_cmp((&hash_offset_buffer21), bucket21, pos21);\\\n+\tlookup_key8_cmp(key20, bucket20, pos20, f);\t\t\t\\\n+\tlookup_key8_cmp(key21, bucket21, pos21, f);\t\t\t\\\n \t\t\t\t\t\t\t\t\\\n \tpkt20_mask = ((bucket20->signature >> pos20) & 1LLU) << pkt20_index;\\\n \tpkt21_mask = ((bucket21->signature >> pos21) & 1LLU) << pkt21_index;\\\n@@ -954,7 +978,7 @@ rte_table_hash_lookup_key8_lru(\n \t*lookup_hit_mask = pkts_mask_out;\n \tRTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));\n \treturn 0;\n-} /* rte_table_hash_lookup_key8_lru() */\n+} /* lookup LRU */\n \n static int\n rte_table_hash_lookup_key8_ext(\n@@ -1104,7 +1128,7 @@ rte_table_hash_lookup_key8_ext(\n \t*lookup_hit_mask = pkts_mask_out;\n \tRTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(f, n_pkts_in - __builtin_popcountll(pkts_mask_out));\n \treturn 0;\n-} /* rte_table_hash_lookup_key8_ext() */\n+} /* lookup EXT */\n \n static int\n rte_table_hash_key8_stats_read(void *table, struct rte_table_stats *stats, int clear)\ndiff --git a/test/test-pipeline/pipeline_hash.c b/test/test-pipeline/pipeline_hash.c\nindex 3c48640..f542506 100755\n--- a/test/test-pipeline/pipeline_hash.c\n+++ b/test/test-pipeline/pipeline_hash.c\n@@ -231,13 +231,14 @@ app_main_loop_worker_pipeline_hash(void) {\n \n \tcase e_APP_PIPELINE_HASH_SPEC_KEY8_EXT:\n \t{\n-\t\tstruct rte_table_hash_key8_ext_params table_hash_params = {\n-\t\t\t.n_entries = 1 << 24,\n-\t\t\t.n_entries_ext = 1 << 23,\n-\t\t\t.signature_offset = APP_METADATA_OFFSET(0),\n+\t\tstruct rte_table_hash_params table_hash_params = {\n+\t\t\t.name = \"TABLE\",\n+\t\t\t.key_size = key_size,\n \t\t\t.key_offset = APP_METADATA_OFFSET(32),\n \t\t\t.key_mask = NULL,\n-\t\t\t.f_hash = test_hash,\n+\t\t\t.n_keys = 1 << 24,\n+\t\t\t.n_buckets = 1 << 22,\n+\t\t\t.f_hash = (rte_table_hash_op_hash)test_hash,\n \t\t\t.seed = 0,\n \t\t};\n \n@@ -257,12 +258,14 @@ app_main_loop_worker_pipeline_hash(void) {\n \n \tcase e_APP_PIPELINE_HASH_SPEC_KEY8_LRU:\n \t{\n-\t\tstruct rte_table_hash_key8_lru_params table_hash_params = {\n-\t\t\t.n_entries = 1 << 24,\n-\t\t\t.signature_offset = APP_METADATA_OFFSET(0),\n+\t\tstruct rte_table_hash_params table_hash_params = {\n+\t\t\t.name = \"TABLE\",\n+\t\t\t.key_size = key_size,\n \t\t\t.key_offset = APP_METADATA_OFFSET(32),\n \t\t\t.key_mask = NULL,\n-\t\t\t.f_hash = test_hash,\n+\t\t\t.n_keys = 1 << 24,\n+\t\t\t.n_buckets = 1 << 22,\n+\t\t\t.f_hash = (rte_table_hash_op_hash)test_hash,\n \t\t\t.seed = 0,\n \t\t};\n \ndiff --git a/test/test/test_table_combined.c b/test/test/test_table_combined.c\nold mode 100644\nnew mode 100755\nindex f65d34a..ddcd14b\n--- a/test/test/test_table_combined.c\n+++ b/test/test/test_table_combined.c\n@@ -441,12 +441,15 @@ test_table_hash8lru(void)\n \tint status, i;\n \n \t/* Traffic flow */\n-\tstruct rte_table_hash_key8_lru_params key8lru_params = {\n-\t\t.n_entries = 1<<24,\n-\t\t.f_hash = pipeline_test_hash,\n-\t\t.signature_offset = APP_METADATA_OFFSET(0),\n+\tstruct rte_table_hash_params key8lru_params = {\n+\t\t.name = \"TABLE\",\n+\t\t.key_size = 8,\n \t\t.key_offset = APP_METADATA_OFFSET(32),\n \t\t.key_mask = NULL,\n+\t\t.n_keys = 1 << 16,\n+\t\t.n_buckets = 1 << 16,\n+\t\t.f_hash = (rte_table_hash_op_hash)pipeline_test_hash,\n+\t\t.seed = 0,\n \t};\n \n \tuint8_t key8lru[8];\n@@ -475,14 +478,14 @@ test_table_hash8lru(void)\n \tVERIFY(status, CHECK_TABLE_OK);\n \n \t/* Invalid parameters */\n-\tkey8lru_params.n_entries = 0;\n+\tkey8lru_params.n_keys = 0;\n \n \tstatus = test_table_type(&rte_table_hash_key8_lru_ops,\n \t\t(void *)&key8lru_params, (void *)key8lru, &table_packets,\n \t\t\tNULL, 0);\n \tVERIFY(status, CHECK_TABLE_TABLE_CONFIG);\n \n-\tkey8lru_params.n_entries = 1<<16;\n+\tkey8lru_params.n_keys = 1<<16;\n \tkey8lru_params.f_hash = NULL;\n \n \tstatus = test_table_type(&rte_table_hash_key8_lru_ops,\n@@ -616,14 +619,15 @@ test_table_hash8ext(void)\n \tint status, i;\n \n \t/* Traffic flow */\n-\tstruct rte_table_hash_key8_ext_params key8ext_params = {\n-\t\t.n_entries = 1<<16,\n-\t\t.n_entries_ext = 1<<15,\n-\t\t.f_hash = pipeline_test_hash,\n-\t\t.seed = 0,\n-\t\t.signature_offset = APP_METADATA_OFFSET(0),\n+\tstruct rte_table_hash_params key8ext_params = {\n+\t\t.name = \"TABLE\",\n+\t\t.key_size = 8,\n \t\t.key_offset = APP_METADATA_OFFSET(32),\n \t\t.key_mask = NULL,\n+\t\t.n_keys = 1 << 16,\n+\t\t.n_buckets = 1 << 16,\n+\t\t.f_hash = (rte_table_hash_op_hash)pipeline_test_hash,\n+\t\t.seed = 0,\n \t};\n \n \tuint8_t key8ext[8];\n@@ -652,14 +656,14 @@ test_table_hash8ext(void)\n \tVERIFY(status, CHECK_TABLE_OK);\n \n \t/* Invalid parameters */\n-\tkey8ext_params.n_entries = 0;\n+\tkey8ext_params.n_keys = 0;\n \n \tstatus = test_table_type(&rte_table_hash_key8_ext_ops,\n \t\t(void *)&key8ext_params, (void *)key8ext, &table_packets,\n \t\tNULL, 0);\n \tVERIFY(status, CHECK_TABLE_TABLE_CONFIG);\n \n-\tkey8ext_params.n_entries = 1<<16;\n+\tkey8ext_params.n_keys = 1<<16;\n \tkey8ext_params.f_hash = NULL;\n \n \tstatus = test_table_type(&rte_table_hash_key8_ext_ops,\n@@ -667,13 +671,6 @@ test_table_hash8ext(void)\n \t\tNULL, 0);\n \tVERIFY(status, CHECK_TABLE_TABLE_CONFIG);\n \n-\tkey8ext_params.f_hash = pipeline_test_hash;\n-\tkey8ext_params.n_entries_ext = 0;\n-\n-\tstatus = test_table_type(&rte_table_hash_key8_ext_ops,\n-\t(void *)&key8ext_params, (void *)key8ext, &table_packets, NULL, 0);\n-\tVERIFY(status, CHECK_TABLE_TABLE_CONFIG);\n-\n \treturn 0;\n }\n \ndiff --git a/test/test/test_table_tables.c b/test/test/test_table_tables.c\nold mode 100644\nnew mode 100755\nindex efbd0c6..7f85587\n--- a/test/test/test_table_tables.c\n+++ b/test/test/test_table_tables.c\n@@ -67,9 +67,9 @@ unsigned n_table_tests = RTE_DIM(table_tests);\n \n /* Function prototypes */\n static int\n-test_table_hash_lru_generic(struct rte_table_ops *ops);\n+test_table_hash_lru_generic(struct rte_table_ops *ops, uint32_t key_size);\n static int\n-test_table_hash_ext_generic(struct rte_table_ops *ops);\n+test_table_hash_ext_generic(struct rte_table_ops *ops, uint32_t key_size);\n \n struct rte_bucket_4_8 {\n \t/* Cache line 0 */\n@@ -655,7 +655,7 @@ test_table_lpm_ipv6(void)\n }\n \n static int\n-test_table_hash_lru_generic(struct rte_table_ops *ops)\n+test_table_hash_lru_generic(struct rte_table_ops *ops, uint32_t key_size)\n {\n \tint status, i;\n \tuint64_t expected_mask = 0, result_mask;\n@@ -667,43 +667,31 @@ test_table_hash_lru_generic(struct rte_table_ops *ops)\n \tint key_found;\n \n \t/* Initialize params and create tables */\n-\tstruct rte_table_hash_key8_lru_params hash_params = {\n-\t\t.n_entries = 1 << 10,\n-\t\t.f_hash = pipeline_test_hash,\n-\t\t.seed = 0,\n-\t\t.signature_offset = APP_METADATA_OFFSET(1),\n+\tstruct rte_table_hash_params hash_params = {\n+\t\t.name = \"TABLE\",\n+\t\t.key_size = key_size,\n \t\t.key_offset = APP_METADATA_OFFSET(32),\n \t\t.key_mask = NULL,\n+\t\t.n_keys = 1 << 10,\n+\t\t.n_buckets = 1 << 10,\n+\t\t.f_hash = (rte_table_hash_op_hash)pipeline_test_hash,\n+\t\t.seed = 0,\n \t};\n \n-\thash_params.n_entries = 0;\n+\thash_params.n_keys = 0;\n \n \ttable = ops->f_create(&hash_params, 0, 1);\n \tif (table != NULL)\n \t\treturn -1;\n \n-\thash_params.n_entries = 1 << 10;\n-\thash_params.signature_offset = APP_METADATA_OFFSET(1);\n-\n-\ttable = ops->f_create(&hash_params, 0, 1);\n-\tif (table == NULL)\n-\t\treturn -2;\n-\n-\thash_params.signature_offset = APP_METADATA_OFFSET(0);\n-\thash_params.key_offset = APP_METADATA_OFFSET(1);\n-\n-\ttable = ops->f_create(&hash_params, 0, 1);\n-\tif (table == NULL)\n-\t\treturn -3;\n-\n-\thash_params.key_offset = APP_METADATA_OFFSET(32);\n+\thash_params.n_keys = 1 << 10;\n \thash_params.f_hash = NULL;\n \n \ttable = ops->f_create(&hash_params, 0, 1);\n \tif (table != NULL)\n \t\treturn -4;\n \n-\thash_params.f_hash = pipeline_test_hash;\n+\thash_params.f_hash = (rte_table_hash_op_hash)pipeline_test_hash;\n \n \ttable = ops->f_create(&hash_params, 0, 1);\n \tif (table == NULL)\n@@ -770,7 +758,7 @@ test_table_hash_lru_generic(struct rte_table_ops *ops)\n }\n \n static int\n-test_table_hash_ext_generic(struct rte_table_ops *ops)\n+test_table_hash_ext_generic(struct rte_table_ops *ops, uint32_t key_size)\n {\n \tint status, i;\n \tuint64_t expected_mask = 0, result_mask;\n@@ -782,35 +770,24 @@ test_table_hash_ext_generic(struct rte_table_ops *ops)\n \tvoid *entry_ptr;\n \n \t/* Initialize params and create tables */\n-\tstruct rte_table_hash_key8_ext_params hash_params = {\n-\t\t.n_entries = 1 << 10,\n-\t\t.n_entries_ext = 1 << 4,\n-\t\t.f_hash = pipeline_test_hash,\n-\t\t.seed = 0,\n-\t\t.signature_offset = APP_METADATA_OFFSET(1),\n+\tstruct rte_table_hash_params hash_params = {\n+\t\t.name = \"TABLE\",\n+\t\t.key_size = key_size,\n \t\t.key_offset = APP_METADATA_OFFSET(32),\n \t\t.key_mask = NULL,\n+\t\t.n_keys = 1 << 10,\n+\t\t.n_buckets = 1 << 10,\n+\t\t.f_hash = (rte_table_hash_op_hash)pipeline_test_hash,\n+\t\t.seed = 0,\n \t};\n \n-\thash_params.n_entries = 0;\n+\thash_params.n_keys = 0;\n \n \ttable = ops->f_create(&hash_params, 0, 1);\n \tif (table != NULL)\n \t\treturn -1;\n \n-\thash_params.n_entries = 1 << 10;\n-\thash_params.n_entries_ext = 0;\n-\ttable = ops->f_create(&hash_params, 0, 1);\n-\tif (table != NULL)\n-\t\treturn -2;\n-\n-\thash_params.n_entries_ext = 1 << 4;\n-\thash_params.signature_offset = APP_METADATA_OFFSET(1);\n-\ttable = ops->f_create(&hash_params, 0, 1);\n-\tif (table == NULL)\n-\t\treturn -2;\n-\n-\thash_params.signature_offset = APP_METADATA_OFFSET(0);\n+\thash_params.n_keys = 1 << 10;\n \thash_params.key_offset = APP_METADATA_OFFSET(1);\n \n \ttable = ops->f_create(&hash_params, 0, 1);\n@@ -824,7 +801,7 @@ test_table_hash_ext_generic(struct rte_table_ops *ops)\n \tif (table != NULL)\n \t\treturn -4;\n \n-\thash_params.f_hash = pipeline_test_hash;\n+\thash_params.f_hash = (rte_table_hash_op_hash)pipeline_test_hash;\n \n \ttable = ops->f_create(&hash_params, 0, 1);\n \tif (table == NULL)\n@@ -895,20 +872,9 @@ test_table_hash_lru(void)\n {\n \tint status;\n \n-\tstatus = test_table_hash_lru_generic(&rte_table_hash_key8_lru_ops);\n-\tif (status < 0)\n-\t\treturn status;\n-\n \tstatus = test_table_hash_lru_generic(\n-\t\t&rte_table_hash_key8_lru_ops);\n-\tif (status < 0)\n-\t\treturn status;\n-\n-\tstatus = test_table_hash_lru_generic(&rte_table_hash_key16_lru_ops);\n-\tif (status < 0)\n-\t\treturn status;\n-\n-\tstatus = test_table_hash_lru_generic(&rte_table_hash_key32_lru_ops);\n+\t\t&rte_table_hash_key8_lru_ops,\n+\t\t8);\n \tif (status < 0)\n \t\treturn status;\n \n@@ -924,20 +890,7 @@ test_table_hash_ext(void)\n {\n \tint status;\n \n-\tstatus = test_table_hash_ext_generic(&rte_table_hash_key8_ext_ops);\n-\tif (status < 0)\n-\t\treturn status;\n-\n-\tstatus = test_table_hash_ext_generic(\n-\t\t&rte_table_hash_key8_ext_ops);\n-\tif (status < 0)\n-\t\treturn status;\n-\n-\tstatus = test_table_hash_ext_generic(&rte_table_hash_key16_ext_ops);\n-\tif (status < 0)\n-\t\treturn status;\n-\n-\tstatus = test_table_hash_ext_generic(&rte_table_hash_key32_ext_ops);\n+\tstatus = test_table_hash_ext_generic(&rte_table_hash_key8_ext_ops, 8);\n \tif (status < 0)\n \t\treturn status;\n \n",
    "prefixes": [
        "dpdk-dev",
        "v3",
        "10/18"
    ]
}