eal: remove sys/queue.h from public headers
[dpdk.git] / drivers / net / bnxt / tf_core / tf_device.h
index bbdfb15..9b0c037 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2020 Broadcom
+ * Copyright(c) 2019-2021 Broadcom
  * All rights reserved.
  */
 
@@ -8,8 +8,13 @@
 
 #include "tf_core.h"
 #include "tf_identifier.h"
-#include "tf_tbl_type.h"
+#include "tf_tbl.h"
 #include "tf_tcam.h"
+#ifdef TF_TCAM_SHARED
+#include "tf_tcam_shared.h"
+#endif
+#include "tf_if_tbl.h"
+#include "tf_global_cfg.h"
 
 struct tf;
 struct tf_session;
@@ -52,6 +57,9 @@ struct tf_dev_info {
  * [in] resources
  *   Pointer to resource allocation information
  *
+ * [in] wc_num_slices
+ *   Number of slices per row for WC
+ *
  * [out] dev_handle
  *   Device handle
  *
@@ -60,11 +68,12 @@ struct tf_dev_info {
  *   - (-EINVAL) parameter failure.
  *   - (-ENODEV) no such device supported.
  */
-int dev_bind(struct tf *tfp,
-            enum tf_device_type type,
-            bool shadow_copy,
-            struct tf_session_resources *resources,
-            struct tf_dev_info *dev_handle);
+int tf_dev_bind(struct tf *tfp,
+               enum tf_device_type type,
+               bool shadow_copy,
+               struct tf_session_resources *resources,
+               uint16_t wc_num_slices,
+               struct tf_dev_info *dev_handle);
 
 /**
  * Device release handles cleanup of the device specific information.
@@ -80,8 +89,12 @@ int dev_bind(struct tf *tfp,
  *   - (-EINVAL) parameter failure.
  *   - (-ENODEV) no such device supported.
  */
-int dev_unbind(struct tf *tfp,
-              struct tf_dev_info *dev_handle);
+int tf_dev_unbind(struct tf *tfp,
+                 struct tf_dev_info *dev_handle);
+
+int
+tf_dev_bind_ops(enum tf_device_type type,
+               struct tf_dev_info *dev_handle);
 
 /**
  * Truflow device specific function hooks structure
@@ -109,6 +122,44 @@ struct tf_dev_ops {
        int (*tf_dev_get_max_types)(struct tf *tfp,
                                    uint16_t *max_types);
 
+       /**
+        * Retrieves the string description for the CFA resource
+        * type
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] resource_id
+        *   HCAPI cfa resource type id
+        *
+        * [out] resource_str
+        *   Pointer to a string
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_resource_str)(struct tf *tfp,
+                                      uint16_t resource_id,
+                                      const char **resource_str);
+
+       /**
+        * Set the WC TCAM slice information that the device
+        * supports.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] num_slices_per_row
+        *   Number of slices per row the device supports
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_set_tcam_slice_info)(struct tf *tfp,
+                                         enum tf_wc_num_slice num_slices_per_row);
+
        /**
         * Retrieves the WC TCAM slice information that the device
         * supports.
@@ -174,7 +225,89 @@ struct tf_dev_ops {
                                 struct tf_ident_free_parms *parms);
 
        /**
-        * Allocation of a table type element.
+        * Search of an identifier element.
+        *
+        * This API search the specified identifier element from a
+        * device specific identifier shadow DB. The allocated element
+        * is returned.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to identifier search parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_search_ident)(struct tf *tfp,
+                                  struct tf_ident_search_parms *parms);
+
+       /**
+        * Retrieves the identifier resource info.
+        *
+        * This API retrieves the identifier resource info from the rm db.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to identifier info
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_ident_resc_info)(struct tf *tfp,
+                                         struct tf_identifier_resource_info *parms);
+
+       /**
+        * Indicates whether the index table type is SRAM managed
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] type
+        *   Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD
+        *
+        * Returns
+        *   - (0) if the table is not managed by the SRAM manager
+        *   - (1) if the table is managed by the SRAM manager
+        */
+       bool (*tf_dev_is_sram_managed)(struct tf *tfp,
+                                      enum tf_tbl_type tbl_type);
+
+       /**
+        * Get SRAM table information.
+        *
+        * Converts an internal RM allocated element offset to
+        * a user address and vice versa.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] type
+        *   Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD
+        *
+        * [in/out] base
+        *   Pointer to the base address of the associated table type.
+        *
+        * [in/out] shift
+        *   Pointer to any shift required for the associated table type.
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_tbl_info)(struct tf *tfp,
+                                  void *tbl_db,
+                                  enum tf_tbl_type type,
+                                  uint16_t *base,
+                                  uint16_t *shift);
+
+       /**
+        * Allocation of an index table type element.
         *
         * This API allocates the specified table type element from a
         * device specific table type DB. The allocated element is
@@ -193,6 +326,45 @@ struct tf_dev_ops {
        int (*tf_dev_alloc_tbl)(struct tf *tfp,
                                struct tf_tbl_alloc_parms *parms);
 
+       /**
+        * Allocation of an SRAM index table type element.
+        *
+        * This API allocates the specified table type element from a
+        * device specific table type DB. The allocated element is
+        * returned.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table allocation parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_alloc_sram_tbl)(struct tf *tfp,
+                                    struct tf_tbl_alloc_parms *parms);
+       /**
+        * Allocation of a external table type element.
+        *
+        * This API allocates the specified table type element from a
+        * device specific table type DB. The allocated element is
+        * returned.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table allocation parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_alloc_ext_tbl)(struct tf *tfp,
+                                   struct tf_tbl_alloc_parms *parms);
+
        /**
         * Free of a table type element.
         *
@@ -211,28 +383,42 @@ struct tf_dev_ops {
         */
        int (*tf_dev_free_tbl)(struct tf *tfp,
                               struct tf_tbl_free_parms *parms);
-
        /**
-        * Searches for the specified table type element in a shadow DB.
+        * Free of an SRAM table type element.
         *
-        * This API searches for the specified table type element in a
-        * device specific shadow DB. If the element is found the
-        * reference count for the element is updated. If the element
-        * is not found a new element is allocated from the table type
-        * DB and then inserted into the shadow DB.
+        * This API free's a previous allocated table type element from a
+        * device specific table type DB.
         *
         * [in] tfp
         *   Pointer to TF handle
         *
         * [in] parms
-        *   Pointer to table allocation and search parameters
+        *   Pointer to table free parameters
         *
         * Returns
         *   - (0) if successful.
         *   - (-EINVAL) on failure.
         */
-       int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
-                                      struct tf_tbl_alloc_search_parms *parms);
+       int (*tf_dev_free_sram_tbl)(struct tf *tfp,
+                                   struct tf_tbl_free_parms *parms);
+       /**
+        * Free of a external table type element.
+        *
+        * This API free's a previous allocated table type element from a
+        * device specific table type DB.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table free parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_free_ext_tbl)(struct tf *tfp,
+                                  struct tf_tbl_free_parms *parms);
 
        /**
         * Sets the specified table type element.
@@ -253,6 +439,44 @@ struct tf_dev_ops {
        int (*tf_dev_set_tbl)(struct tf *tfp,
                              struct tf_tbl_set_parms *parms);
 
+       /**
+        * Sets the specified external table type element.
+        *
+        * This API sets the specified element data by invoking the
+        * firmware.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table set parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_set_ext_tbl)(struct tf *tfp,
+                                 struct tf_tbl_set_parms *parms);
+
+       /**
+        * Sets the specified SRAM table type element.
+        *
+        * This API sets the specified element data by invoking the
+        * firmware.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table set parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_set_sram_tbl)(struct tf *tfp,
+                                  struct tf_tbl_set_parms *parms);
+
        /**
         * Retrieves the specified table type element.
         *
@@ -270,7 +494,101 @@ struct tf_dev_ops {
         *   - (-EINVAL) on failure.
         */
        int (*tf_dev_get_tbl)(struct tf *tfp,
-                              struct tf_tbl_get_parms *parms);
+                             struct tf_tbl_get_parms *parms);
+
+       /**
+        * Retrieves the specified SRAM table type element.
+        *
+        * This API retrieves the specified element data by invoking the
+        * firmware.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table get parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_sram_tbl)(struct tf *tfp,
+                                  struct tf_tbl_get_parms *parms);
+
+       /**
+        * Retrieves the specified table type element using 'bulk'
+        * mechanism.
+        *
+        * This API retrieves the specified element data by invoking the
+        * firmware.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table get bulk parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
+                                  struct tf_tbl_get_bulk_parms *parms);
+
+       /**
+        * Retrieves the specified SRAM table type element using 'bulk'
+        * mechanism.
+        *
+        * This API retrieves the specified element data by invoking the
+        * firmware.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table get bulk parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_bulk_sram_tbl)(struct tf *tfp,
+                                       struct tf_tbl_get_bulk_parms *parms);
+
+       /**
+        * Gets the increment value to add to the shared session resource
+        * start offset by for each count in the "stride"
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to get shared tbl increment parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_shared_tbl_increment)(struct tf *tfp,
+                               struct tf_get_shared_tbl_increment_parms *parms);
+
+       /**
+        * Retrieves the table resource info.
+        *
+        * This API retrieves the table resource info from the rm db.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to tbl info
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_tbl_resc_info)(struct tf *tfp,
+                                        struct tf_tbl_resource_info *parms);
 
        /**
         * Allocation of a tcam element.
@@ -371,6 +689,59 @@ struct tf_dev_ops {
        int (*tf_dev_get_tcam)(struct tf *tfp,
                               struct tf_tcam_get_parms *parms);
 
+#ifdef TF_TCAM_SHARED
+       /**
+        * Move TCAM shared entries
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_move_tcam)(struct tf *tfp,
+                              struct tf_move_tcam_shared_entries_parms *parms);
+
+       /**
+        * Move TCAM shared entries
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_clear_tcam)(struct tf *tfp,
+                             struct tf_clear_tcam_shared_entries_parms *parms);
+
+#endif /* TF_TCAM_SHARED */
+
+       /**
+        * Retrieves the tcam resource info.
+        *
+        * This API retrieves the tcam resource info from the rm db.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to tcam info
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_tcam_resc_info)(struct tf *tfp,
+                                        struct tf_tcam_resource_info *parms);
+
        /**
         * Insert EM hash entry API
         *
@@ -384,8 +755,8 @@ struct tf_dev_ops {
         *    0       - Success
         *    -EINVAL - Error
         */
-       int (*tf_dev_insert_em_entry)(struct tf *tfp,
-                                     struct tf_insert_em_entry_parms *parms);
+       int (*tf_dev_insert_int_em_entry)(struct tf *tfp,
+                                         struct tf_insert_em_entry_parms *parms);
 
        /**
         * Delete EM hash entry API
@@ -400,13 +771,280 @@ struct tf_dev_ops {
         *    0       - Success
         *    -EINVAL - Error
         */
-       int (*tf_dev_delete_em_entry)(struct tf *tfp,
-                                     struct tf_delete_em_entry_parms *parms);
+       int (*tf_dev_delete_int_em_entry)(struct tf *tfp,
+                                         struct tf_delete_em_entry_parms *parms);
+
+       /**
+        * Move EM hash entry API
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to E/EM move parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_move_int_em_entry)(struct tf *tfp,
+                                       struct tf_move_em_entry_parms *parms);
+
+       /**
+        * Insert EEM hash entry API
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to E/EM insert parameters
+        *
+        *  Returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_insert_ext_em_entry)(struct tf *tfp,
+                                         struct tf_insert_em_entry_parms *parms);
+
+       /**
+        * Delete EEM hash entry API
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to E/EM delete parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_delete_ext_em_entry)(struct tf *tfp,
+                                         struct tf_delete_em_entry_parms *parms);
+
+       /**
+        * Retrieves the em resource info.
+        *
+        * This API retrieves the em resource info from the rm db.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to em info
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_em_resc_info)(struct tf *tfp,
+                                      struct tf_em_resource_info *parms);
+
+       /**
+        * Move EEM hash entry API
+        *
+        *   Pointer to E/EM move parameters
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to em info
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_move_ext_em_entry)(struct tf *tfp,
+                                       struct tf_move_em_entry_parms *parms);
+
+       /**
+        * Allocate EEM table scope
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table scope alloc parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
+                                     struct tf_alloc_tbl_scope_parms *parms);
+       /**
+        * Map EEM parif
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] pf
+        * PF associated with the table scope
+        *
+        * [in] parif_bitmask
+        * Bitmask of PARIFs to enable
+        *
+        * [in/out] pointer to the parif_2_pf data to be updated
+        *
+        * [in/out] pointer to the parif_2_pf mask to be updated
+        *
+        * [in] sz_in_bytes - number of bytes to be written
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_map_parif)(struct tf *tfp,
+                               uint16_t parif_bitmask,
+                               uint16_t pf,
+                               uint8_t *data,
+                               uint8_t *mask,
+                               uint16_t sz_in_bytes);
+       /**
+        * Map EEM table scope
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table scope map parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_map_tbl_scope)(struct tf *tfp,
+                                   struct tf_map_tbl_scope_parms *parms);
+
+       /**
+        * Free EEM table scope
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table scope free parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_free_tbl_scope)(struct tf *tfp,
+                                    struct tf_free_tbl_scope_parms *parms);
+
+       /**
+        * Sets the specified interface table type element.
+        *
+        * This API sets the specified element data by invoking the
+        * firmware.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to interface table set parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_set_if_tbl)(struct tf *tfp,
+                                struct tf_if_tbl_set_parms *parms);
+
+       /**
+        * Retrieves the specified interface table type element.
+        *
+        * This API retrieves the specified element data by invoking the
+        * firmware.
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table get parameters
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_if_tbl)(struct tf *tfp,
+                                struct tf_if_tbl_get_parms *parms);
+
+       /**
+        * Update global cfg
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to global cfg parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_set_global_cfg)(struct tf *tfp,
+                                    struct tf_global_cfg_parms *parms);
+
+       /**
+        * Get global cfg
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to global cfg parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_get_global_cfg)(struct tf *tfp,
+                                    struct tf_global_cfg_parms *parms);
+
+       /**
+        * Get mailbox
+        *
+        *    returns:
+        *      mailbox
+        */
+       int (*tf_dev_get_mailbox)(void);
+
+       /**
+        * Convert length in bit to length in byte and align to word.
+        * The word length depends on device type.
+        *
+        * [in] size
+        *   Size in bit
+        *
+        * Returns
+        *   Size in byte
+        */
+       int (*tf_dev_word_align)(uint16_t size);
+
+       /**
+        * Hash key using crc32 and lookup3
+        *
+        * [in] key_data
+        *   Pointer to key
+        *
+        * [in] bitlen
+        *   Number of key bits
+        *
+        * Returns
+        *   Hashes
+        */
+       uint64_t (*tf_dev_cfa_key_hash)(uint64_t *key_data,
+                                         uint16_t bitlen);
 };
 
 /**
  * Supported device operation structures
  */
+extern const struct tf_dev_ops tf_dev_ops_p4_init;
 extern const struct tf_dev_ops tf_dev_ops_p4;
+extern const struct tf_dev_ops tf_dev_ops_p58_init;
+extern const struct tf_dev_ops tf_dev_ops_p58;
 
 #endif /* _TF_DEVICE_H_ */