#include "main.h"
 
+extern const struct rhashtable_params nfp_zone_table_params;
+
+/**
+ * struct nfp_fl_ct_zone_entry - Zone entry containing conntrack flow information
+ * @zone:      The zone number, used as lookup key in hashtable
+ * @hash_node: Used by the hashtable
+ * @priv:      Pointer to nfp_flower_priv data
+ * @nft:       Pointer to nf_flowtable for this zone
+ */
+struct nfp_fl_ct_zone_entry {
+       u16 zone;
+       struct rhash_head hash_node;
+
+       struct nfp_flower_priv *priv;
+       struct nf_flowtable *nft;
+};
+
 bool is_pre_ct_flow(struct flow_cls_offload *flow);
 bool is_post_ct_flow(struct flow_cls_offload *flow);
 
 
 #include <net/pkt_cls.h>
 
 #include "cmsg.h"
+#include "conntrack.h"
 #include "main.h"
 #include "../nfp_app.h"
 
        .key_len        = sizeof(u64),
 };
 
+const struct rhashtable_params nfp_zone_table_params = {
+       .head_offset            = offsetof(struct nfp_fl_ct_zone_entry, hash_node),
+       .key_len                = sizeof(u16),
+       .key_offset             = offsetof(struct nfp_fl_ct_zone_entry, zone),
+       .automatic_shrinking    = false,
+};
+
 int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count,
                             unsigned int host_num_mems)
 {
        if (err)
                goto err_free_stats_ctx_table;
 
+       err = rhashtable_init(&priv->ct_zone_table, &nfp_zone_table_params);
+       if (err)
+               goto err_free_merge_table;
+
        get_random_bytes(&priv->mask_id_seed, sizeof(priv->mask_id_seed));
 
        /* Init ring buffer and unallocated mask_ids. */
                kmalloc_array(NFP_FLOWER_MASK_ENTRY_RS,
                              NFP_FLOWER_MASK_ELEMENT_RS, GFP_KERNEL);
        if (!priv->mask_ids.mask_id_free_list.buf)
-               goto err_free_merge_table;
+               goto err_free_ct_zone_table;
 
        priv->mask_ids.init_unallocated = NFP_FLOWER_MASK_ENTRY_RS - 1;
 
        kfree(priv->mask_ids.last_used);
 err_free_mask_id:
        kfree(priv->mask_ids.mask_id_free_list.buf);
+err_free_ct_zone_table:
+       rhashtable_destroy(&priv->ct_zone_table);
 err_free_merge_table:
        rhashtable_destroy(&priv->merge_table);
 err_free_stats_ctx_table:
        return -ENOMEM;
 }
 
+static void nfp_free_zone_table_entry(void *ptr, void *arg)
+{
+}
+
 void nfp_flower_metadata_cleanup(struct nfp_app *app)
 {
        struct nfp_flower_priv *priv = app->priv;
                                    nfp_check_rhashtable_empty, NULL);
        rhashtable_free_and_destroy(&priv->merge_table,
                                    nfp_check_rhashtable_empty, NULL);
+       rhashtable_free_and_destroy(&priv->ct_zone_table,
+                                   nfp_free_zone_table_entry, NULL);
        kvfree(priv->stats);
        kfree(priv->mask_ids.mask_id_free_list.buf);
        kfree(priv->mask_ids.last_used);