This is a patch to a problem that I have faced (described in the  thread) and 
this works for me.

1)      Since the data_size_shl was getting its value from the key_size, the 
table data entries were being corrupted when the calculation to shift the 
number of bits was being made based on the key_size (according to the document 
the key_size and entry_size are independently configurable) - With this fix, we 
get the MSB that is set in entry_size (also removes the constraint of this 
having to be a power of 2 - not entirely sure if this was the reason the 
constraint was kept though)
2)      The document does not say that the entry_size needs to be a power of 2 
and this was failing silently when I was trying to bring my application up.

diff --git a/DPDK/lib/librte_table/rte_table_hash_lru.c 
b/DPDK/lib/librte_table/rte_table_hash_lru.c
index d1a4984..4ec9aa4 100644
--- a/DPDK/lib/librte_table/rte_table_hash_lru.c
+++ b/DPDK/lib/librte_table/rte_table_hash_lru.c
@@ -153,8 +153,10 @@ rte_table_hash_lru_create(void *params, int socket_id, 
uint32_t entry_size)
        uint32_t i;

        /* Check input parameters */
-       if ((check_params_create(p) != 0) ||
-               (!rte_is_power_of_2(entry_size)) ||
+       // Commenting out the power of 2 check on the entry_size since the
+       // Programmers Guide does not call this out and we are going to handle
+       // the data_size_shl of the table later on (Line 197)
+       if ((check_params_create(p) != 0) ||
                ((sizeof(struct rte_table_hash) % CACHE_LINE_SIZE) != 0) ||
                (sizeof(struct bucket) != (CACHE_LINE_SIZE / 2))) {
                return NULL;
@@ -192,7 +194,7 @@ rte_table_hash_lru_create(void *params, int socket_id, 
uint32_t entry_size)
        /* Internal */
        t->bucket_mask = t->n_buckets - 1;
        t->key_size_shl = __builtin_ctzl(p->key_size);
-       t->data_size_shl = __builtin_ctzl(p->key_size);
+       t->data_size_shl = 32 - (__builtin_clz(entry_size));

        /* Tables */
        table_meta_offset = 0;

-----Original Message-----
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Saha, Avik (AWS)
Sent: Wednesday, September 24, 2014 4:12 PM
To: dev at dpdk.org
Subject: [dpdk-dev] Strange behaviour with LRU table

1)      All the calls to add entries succeeds

2)      The key look up works as expected.

3)      The value (entry_data) that is returned is incorrect for every other 
entry - 1st  entry data on .f_action_hit is wrong, 2nd entry_data on 
.f_action_hit is correct and so on.

I have initialized my LRU as follows:

    struct rte_pipeline_table_params table_params = {
            .ops = &rte_table_hash_lru_dosig_ops,
            .arg_create = &rule_tbl_params,
            .f_action_hit = rw_pipeline_stage_2_cache_hit,
            .f_action_miss = rw_pipeline_stage_2_cache_miss,
            .arg_ah = (void *)lcore_params,
            .action_data_size = 16,
    };


Is there something obvious I am missing - from first look it seems to be a 
problem with cache lines but I really am not sure.

Avik

Reply via email to