net/bnxt: add conditional processing of templates
[dpdk.git] / drivers / net / bnxt / tf_core / tf_device_p4.c
index d0bede8..971fab7 100644 (file)
@@ -10,6 +10,9 @@
 #include "tf_identifier.h"
 #include "tf_tbl.h"
 #include "tf_tcam.h"
+#ifdef TF_TCAM_SHARED
+#include "tf_tcam_shared.h"
+#endif /* TF_TCAM_SHARED */
 #include "tf_em.h"
 #include "tf_if_tbl.h"
 #include "tfp.h"
@@ -137,15 +140,14 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,
                              uint16_t key_sz,
                              uint16_t *num_slices_per_row)
 {
-#define CFA_P4_WC_TCAM_SLICES_PER_ROW 2
+/* Single slice support */
+#define CFA_P4_WC_TCAM_SLICES_PER_ROW 1
 #define CFA_P4_WC_TCAM_SLICE_SIZE     12
 
        if (type == TF_TCAM_TBL_TYPE_WC_TCAM) {
                *num_slices_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW;
                if (key_sz > *num_slices_per_row * CFA_P4_WC_TCAM_SLICE_SIZE)
                        return -ENOTSUP;
-
-               *num_slices_per_row = 1;
        } else { /* for other type of tcam */
                *num_slices_per_row = 1;
        }
@@ -188,6 +190,26 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
        return 0;
 }
 
+/**
+ * Device specific function that retrieves the increment
+ * required for certain table types in a shared session
+ *
+ * [in] tfp
+ *  tf handle
+ *
+ * [in/out] parms
+ *   pointer to parms structure
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int tf_dev_p4_get_shared_tbl_increment(struct tf *tfp __rte_unused,
+                               struct tf_get_shared_tbl_increment_parms *parms)
+{
+       parms->increment_cnt = 1;
+       return 0;
+}
 static int tf_dev_p4_get_mailbox(void)
 {
        return TF_KONG_MB;
@@ -208,6 +230,8 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
        .tf_dev_alloc_ident = NULL,
        .tf_dev_free_ident = NULL,
        .tf_dev_search_ident = NULL,
+       .tf_dev_get_ident_resc_info = NULL,
+       .tf_dev_get_tbl_info = NULL,
        .tf_dev_alloc_ext_tbl = NULL,
        .tf_dev_alloc_tbl = NULL,
        .tf_dev_free_ext_tbl = NULL,
@@ -217,15 +241,19 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
        .tf_dev_set_ext_tbl = NULL,
        .tf_dev_get_tbl = NULL,
        .tf_dev_get_bulk_tbl = NULL,
+       .tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment,
+       .tf_dev_get_tbl_resc_info = NULL,
        .tf_dev_alloc_tcam = NULL,
        .tf_dev_free_tcam = NULL,
        .tf_dev_alloc_search_tcam = NULL,
        .tf_dev_set_tcam = NULL,
        .tf_dev_get_tcam = NULL,
+       .tf_dev_get_tcam_resc_info = NULL,
        .tf_dev_insert_int_em_entry = NULL,
        .tf_dev_delete_int_em_entry = NULL,
        .tf_dev_insert_ext_em_entry = NULL,
        .tf_dev_delete_ext_em_entry = NULL,
+       .tf_dev_get_em_resc_info = NULL,
        .tf_dev_alloc_tbl_scope = NULL,
        .tf_dev_map_tbl_scope = NULL,
        .tf_dev_map_parif = NULL,
@@ -248,6 +276,8 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
        .tf_dev_alloc_ident = tf_ident_alloc,
        .tf_dev_free_ident = tf_ident_free,
        .tf_dev_search_ident = tf_ident_search,
+       .tf_dev_get_ident_resc_info = tf_ident_get_resc_info,
+       .tf_dev_get_tbl_info = NULL,
        .tf_dev_alloc_tbl = tf_tbl_alloc,
        .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
        .tf_dev_free_tbl = tf_tbl_free,
@@ -257,15 +287,28 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
        .tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
        .tf_dev_get_tbl = tf_tbl_get,
        .tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+       .tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment,
+       .tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
+#ifdef TF_TCAM_SHARED
+       .tf_dev_alloc_tcam = tf_tcam_shared_alloc,
+       .tf_dev_free_tcam = tf_tcam_shared_free,
+       .tf_dev_set_tcam = tf_tcam_shared_set,
+       .tf_dev_get_tcam = tf_tcam_shared_get,
+       .tf_dev_move_tcam = tf_tcam_shared_move_p4,
+       .tf_dev_clear_tcam = tf_tcam_shared_clear,
+#else /* !TF_TCAM_SHARED */
        .tf_dev_alloc_tcam = tf_tcam_alloc,
        .tf_dev_free_tcam = tf_tcam_free,
-       .tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
        .tf_dev_set_tcam = tf_tcam_set,
-       .tf_dev_get_tcam = NULL,
+       .tf_dev_get_tcam = tf_tcam_get,
+#endif
+       .tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
+       .tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info,
        .tf_dev_insert_int_em_entry = tf_em_insert_int_entry,
        .tf_dev_delete_int_em_entry = tf_em_delete_int_entry,
        .tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry,
        .tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
+       .tf_dev_get_em_resc_info = tf_em_get_resc_info,
        .tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
        .tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope,
        .tf_dev_map_parif = tf_dev_p4_map_parif,
@@ -276,4 +319,5 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
        .tf_dev_get_global_cfg = tf_global_cfg_get,
        .tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
        .tf_dev_word_align = tf_dev_p4_word_align,
+       .tf_dev_cfa_key_hash = hcapi_cfa_p4_key_hash
 };