net/bnxt: add shadow table capability with search
[dpdk.git] / drivers / net / bnxt / tf_core / tf_shadow_tbl.h
index dfd336e..96a3430 100644 (file)
@@ -8,8 +8,6 @@
 
 #include "tf_core.h"
 
-struct tf;
-
 /**
  * The Shadow Table module provides shadow DB handling for table based
  * TF types. A shadow DB provides the capability that allows for reuse
@@ -32,19 +30,22 @@ struct tf;
  */
 struct tf_shadow_tbl_cfg_parms {
        /**
-        * TF Table type
+        * [in] The number of elements in the alloc_cnt and base_addr
+        * For now, it should always be equal to TF_TBL_TYPE_MAX
         */
-       enum tf_tbl_type type;
+       int num_entries;
 
        /**
-        * Number of entries the Shadow DB needs to hold
+        * [in] Resource allocation count array
+        * This array content originates from the tf_session_resources
+        * that is passed in on session open
+        * Array size is TF_TBL_TYPE_MAX
         */
-       int num_entries;
-
+       uint16_t *alloc_cnt;
        /**
-        * Element width for this table type
+        * [in] The base index for each table
         */
-       int element_width;
+       uint16_t base_addr[TF_TBL_TYPE_MAX];
 };
 
 /**
@@ -52,17 +53,17 @@ struct tf_shadow_tbl_cfg_parms {
  */
 struct tf_shadow_tbl_create_db_parms {
        /**
-        * [in] Configuration information for the shadow db
+        * [in] Receive or transmit direction
         */
-       struct tf_shadow_tbl_cfg_parms *cfg;
+       enum tf_dir dir;
        /**
-        * [in] Number of elements in the parms structure
+        * [in] Configuration information for the shadow db
         */
-       uint16_t num_elements;
+       struct tf_shadow_tbl_cfg_parms *cfg;
        /**
         * [out] Shadow table DB handle
         */
-       void *tf_shadow_tbl_db;
+       void **shadow_db;
 };
 
 /**
@@ -70,9 +71,9 @@ struct tf_shadow_tbl_create_db_parms {
  */
 struct tf_shadow_tbl_free_db_parms {
        /**
-        * Shadow table DB handle
+        * [in] Shadow table DB handle
         */
-       void *tf_shadow_tbl_db;
+       void *shadow_db;
 };
 
 /**
@@ -82,79 +83,77 @@ struct tf_shadow_tbl_search_parms {
        /**
         * [in] Shadow table DB handle
         */
-       void *tf_shadow_tbl_db;
+       void *shadow_db;
        /**
-        * [in] Table type
+        * [in,out] The search parms from tf core
         */
-       enum tf_tbl_type type;
-       /**
-        * [in] Pointer to entry blob value in remap table to match
-        */
-       uint8_t *entry;
-       /**
-        * [in] Size of the entry blob passed in bytes
-        */
-       uint16_t entry_sz;
-       /**
-        * [out] Index of the found element returned if hit
-        */
-       uint16_t *index;
+       struct tf_tbl_alloc_search_parms *sparms;
        /**
         * [out] Reference count incremented if hit
         */
-       uint16_t *ref_cnt;
+       uint32_t hb_handle;
 };
 
 /**
- * Shadow table insert parameters
+ * Shadow Table bind index parameters
  */
-struct tf_shadow_tbl_insert_parms {
+struct tf_shadow_tbl_bind_index_parms {
        /**
-        * [in] Shadow table DB handle
+        * [in] Shadow tcam DB handle
         */
-       void *tf_shadow_tbl_db;
+       void *shadow_db;
        /**
-        * [in] Tbl type
+        * [in] receive or transmit direction
+        */
+       enum tf_dir dir;
+       /**
+        * [in] TCAM table type
         */
        enum tf_tbl_type type;
        /**
-        * [in] Pointer to entry blob value in remap table to match
+        * [in] index of the entry to program
         */
-       uint8_t *entry;
+       uint16_t idx;
        /**
-        * [in] Size of the entry blob passed in bytes
+        * [in] struct containing key
         */
-       uint16_t entry_sz;
+       uint8_t *data;
        /**
-        * [in] Entry to update
+        * [in] data size in bytes
         */
-       uint16_t index;
+       uint16_t data_sz_in_bytes;
        /**
-        * [out] Reference count after insert
+        * [in] The hash bucket handled returned from the search
         */
-       uint16_t *ref_cnt;
+       uint32_t hb_handle;
 };
 
 /**
- * Shadow table remove parameters
+ * Shadow table insert parameters
  */
-struct tf_shadow_tbl_remove_parms {
+struct tf_shadow_tbl_insert_parms {
        /**
         * [in] Shadow table DB handle
         */
-       void *tf_shadow_tbl_db;
+       void *shadow_db;
        /**
-        * [in] Tbl type
+        * [in] The insert parms from tf core
         */
-       enum tf_tbl_type type;
+       struct tf_tbl_set_parms *sparms;
+};
+
+/**
+ * Shadow table remove parameters
+ */
+struct tf_shadow_tbl_remove_parms {
        /**
-        * [in] Entry to update
+        * [in] Shadow table DB handle
         */
-       uint16_t index;
+       void *shadow_db;
        /**
-        * [out] Reference count after removal
+        * [in] The free parms from tf core
         */
-       uint16_t *ref_cnt;
+       struct tf_tbl_free_parms *fparms;
 };
 
 /**
@@ -206,9 +205,26 @@ int tf_shadow_tbl_free_db(struct tf_shadow_tbl_free_db_parms *parms);
  * Returns
  *   - (0) if successful, element was found.
  *   - (-EINVAL) on failure.
+ *
+ * If there is a miss, but there is room for insertion, the hb_handle returned
+ * is used for insertion during the bind index API
  */
 int tf_shadow_tbl_search(struct tf_shadow_tbl_search_parms *parms);
 
+/**
+ * Bind Shadow table db hash and result tables with result from search/alloc
+ *
+ * [in] parms
+ *   Pointer to the search parameters
+ *
+ * Returns
+ *   - (0) if successful
+ *   - (-EINVAL) on failure.
+ *
+ * This is only called after a MISS in the search returns a hb_handle
+ */
+int tf_shadow_tbl_bind_index(struct tf_shadow_tbl_bind_index_parms *parms);
+
 /**
  * Inserts an element into the Shadow table DB. Will fail if the
  * elements ref_count is different from 0. Ref_count after insert will