eal: remove sys/queue.h from public headers
[dpdk.git] / drivers / net / bnxt / tf_core / tf_session.h
index aa7a278..c1d7f70 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.
  */
 
 #define TF_SESSION_ID_INVALID     0xFFFFFFFF /** Invalid Session ID define */
 
 /**
- * Number of EM entries. Static for now will be removed
- * when parameter added at a later date. At this stage we
- * are using fixed size entries so that each stack entry
- * represents 4 RT (f/n)blocks. So we take the total block
- * allocation for truflow and divide that by 4.
+ * At this stage we are using fixed size entries so that each
+ * stack entry represents either 2 or 4 RT (f/n)blocks. So we
+ * take the total block allocation for truflow and divide that
+ * by either 2 or 4.
  */
-#define TF_SESSION_TOTAL_FN_BLOCKS (1024 * 8) /* 8K blocks */
+#ifdef TF_EM_ENTRY_IPV4_ONLY
+#define TF_SESSION_EM_ENTRY_SIZE 2 /* 2 blocks per entry */
+#else
 #define TF_SESSION_EM_ENTRY_SIZE 4 /* 4 blocks per entry */
-#define TF_SESSION_EM_POOL_SIZE \
-       (TF_SESSION_TOTAL_FN_BLOCKS / TF_SESSION_EM_ENTRY_SIZE)
+#endif
 
 /**
  * Session
@@ -59,7 +59,7 @@
  * tf_session_info.
  */
 struct tf_session {
-       /** TrueFlow Version. Used to control the structure layout
+       /** TruFlow Version. Used to control the structure layout
         * when sharing sessions. No guarantee that a secondary
         * process would come from the same version of an executable.
         */
@@ -70,6 +70,23 @@ struct tf_session {
         */
        union tf_session_id session_id;
 
+       /**
+        * Boolean controlling the use and availability of shared session.
+        * Shared session will allow the application to share resources
+        * on the firmware side without having to allocate them on firmware.
+        * Additional private session core_data will be allocated if this
+        * boolean is set to 'true', default 'false'.
+        *
+        */
+       bool shared_session;
+
+       /**
+        * This flag indicates the shared session on firmware side is created
+        * by this session. Some privileges may be assigned to this session.
+        *
+        */
+       bool shared_session_creator;
+
        /**
         * Boolean controlling the use and availability of shadow
         * copy. Shadow copy will allow the TruFlow Core to keep track
@@ -112,6 +129,47 @@ struct tf_session {
         * Linked list of clients registered for this session
         */
        struct ll client_ll;
+
+       /**
+        * em ext db reference for the session
+        */
+       void *em_ext_db_handle;
+
+       /**
+        * tcam db reference for the session
+        */
+       void *tcam_db_handle;
+
+       /**
+        * table db reference for the session
+        */
+       void *tbl_db_handle;
+
+       /**
+        * identifier db reference for the session
+        */
+       void *id_db_handle;
+
+       /**
+        * em db reference for the session
+        */
+       void *em_db_handle;
+
+       /**
+        * EM allocator for session
+        */
+       void *em_pool[TF_DIR_MAX];
+
+#ifdef TF_TCAM_SHARED
+       /**
+        * tcam db reference for the session
+        */
+       void *tcam_shared_db_handle;
+#endif /* TF_TCAM_SHARED */
+       /**
+        * SRAM db reference for the session
+        */
+       void *sram_handle;
 };
 
 /**
@@ -208,6 +266,26 @@ struct tf_session_close_session_parms {
  * @ref tf_session_get_fw_session_id
  *
  * @ref tf_session_get_session_id
+ *
+ * @ref tf_session_is_shared_session_creator
+ *
+ * @ref tf_session_get_db
+ *
+ * @ref tf_session_set_db
+ *
+ * @ref tf_session_get_bp
+ *
+ * @ref tf_session_is_shared_session
+ *
+ * #define TF_SHARED
+ * @ref tf_session_get_tcam_shared_db
+ *
+ * @ref tf_session_set_tcam_shared_db
+ * #endif
+ *
+ * @ref tf_session_get_sram_db
+ *
+ * @ref tf_session_set_sram_db
  */
 
 /**
@@ -365,11 +443,11 @@ tf_session_find_session_client_by_fid(struct tf_session *tfs,
 /**
  * Looks up the device information from the TF Session.
  *
- * [in] tfp
- *   Pointer to TF handle
+ * [in] tfs
+ *   Pointer to session handle
  *
  * [out] tfd
- *   Pointer pointer to the device
+ *   Pointer to the device
  *
  * Returns
  *   - (0) if successful.
@@ -378,6 +456,26 @@ tf_session_find_session_client_by_fid(struct tf_session *tfs,
 int tf_session_get_device(struct tf_session *tfs,
                          struct tf_dev_info **tfd);
 
+/**
+ * Returns the session and the device from the tfp.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] tfs
+ *   Pointer to the session
+ *
+ * [out] tfd
+ *   Pointer to the device
+
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int tf_session_get(struct tf *tfp,
+                  struct tf_session **tfs,
+                  struct tf_dev_info **tfd);
+
 /**
  * Looks up the FW Session id the requested TF handle.
  *
@@ -410,4 +508,162 @@ int tf_session_get_fw_session_id(struct tf *tfp,
 int tf_session_get_session_id(struct tf *tfp,
                              union tf_session_id *session_id);
 
+/**
+ * API to get the em_ext_db from tf_session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] em_ext_db_handle, pointer to eem handle
+ *
+ * Returns:
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_session_get_em_ext_db(struct tf *tfp,
+                       void **em_ext_db_handle);
+
+/**
+ * API to set the em_ext_db in tf_session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] em_ext_db_handle, pointer to eem handle
+ *
+ * Returns:
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_session_set_em_ext_db(struct tf *tfp,
+                       void *em_ext_db_handle);
+
+/**
+ * API to get the db from tf_session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] db_handle, pointer to db handle
+ *
+ * Returns:
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_session_get_db(struct tf *tfp,
+                  enum tf_module_type type,
+                 void **db_handle);
+
+/**
+ * API to set the db in tf_session.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] db_handle, pointer to db handle
+ *
+ * Returns:
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+int
+tf_session_set_db(struct tf *tfp,
+                  enum tf_module_type type,
+                 void *db_handle);
+
+/**
+ * Check if the session is shared session.
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - true if it is shared session
+ *   - false if it is not shared session
+ */
+static inline bool
+tf_session_is_shared_session(struct tf_session *tfs)
+{
+       return tfs->shared_session;
+}
+
+/**
+ * Check if the session is the shared session creator
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - true if it is the shared session creator
+ *   - false if it is not the shared session creator
+ */
+static inline bool
+tf_session_is_shared_session_creator(struct tf_session *tfs)
+{
+       return tfs->shared_session_creator;
+}
+
+/**
+ * Get the pointer to the parent bnxt struct
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - the pointer to the parent bnxt struct
+ */
+static inline struct bnxt*
+tf_session_get_bp(struct tf *tfp)
+{
+       return tfp->bp;
+}
+
+/**
+ * Set the pointer to the tcam shared database
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - the pointer to the parent bnxt struct
+ */
+int
+tf_session_set_tcam_shared_db(struct tf *tfp,
+                             void *tcam_shared_db_handle);
+
+/**
+ * Get the pointer to the tcam shared database
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - the pointer to the parent bnxt struct
+ */
+int
+tf_session_get_tcam_shared_db(struct tf *tfp,
+                             void **tcam_shared_db_handle);
+
+/**
+ * Set the pointer to the SRAM database
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - the pointer to the parent bnxt struct
+ */
+int
+tf_session_set_sram_db(struct tf *tfp,
+                      void *sram_handle);
+
+/**
+ * Get the pointer to the SRAM database
+ *
+ * [in] session, pointer to the session
+ *
+ * Returns:
+ *   - the pointer to the parent bnxt struct
+ */
+int
+tf_session_get_sram_db(struct tf *tfp,
+                      void **sram_handle);
+
 #endif /* _TF_SESSION_H_ */