+
+/**
+ * @page session Session Management
+ *
+ * @ref tf_session_open_session
+ *
+ * @ref tf_session_attach_session
+ *
+ * @ref tf_session_close_session
+ *
+ * @ref tf_session_is_fid_supported
+ *
+ * @ref tf_session_get_session_internal
+ *
+ * @ref tf_session_get_session
+ *
+ * @ref tf_session_get_session_client
+ *
+ * @ref tf_session_find_session_client_by_name
+ *
+ * @ref tf_session_find_session_client_by_fid
+ *
+ * @ref tf_session_get_device
+ *
+ * @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
+ */
+
+/**
+ * Creates a host session with a corresponding firmware session.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to the session open parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_session_open_session(struct tf *tfp,
+ struct tf_session_open_session_parms *parms);
+
+/**
+ * Attaches a previous created session.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to the session attach parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_session_attach_session(struct tf *tfp,
+ struct tf_session_attach_session_parms *parms);
+
+/**
+ * Closes a previous created session. Only possible if previous
+ * registered Clients had been unregistered first.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in/out] parms
+ * Pointer to the session close parameters.
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EUSERS) if clients are still registered with the session.
+ * - (-EINVAL) on failure.
+ */
+int tf_session_close_session(struct tf *tfp,
+ struct tf_session_close_session_parms *parms);
+
+/**
+ * Verifies that the fid is supported by the session. Used to assure
+ * that a function i.e. client/control channel is registered with the
+ * session.
+ *
+ * [in] tfs
+ * Pointer to TF Session handle
+ *
+ * [in] fid
+ * FID value to check
+ *
+ * Returns
+ * - (true) if successful, else false
+ * - (-EINVAL) on failure.
+ */
+bool
+tf_session_is_fid_supported(struct tf_session *tfs,
+ uint16_t fid);
+
+/**
+ * Looks up the private session information from the TF session
+ * info. Does not perform a fid check against the registered
+ * clients. Should be used if tf_session_get_session() was used
+ * previously i.e. at the TF API boundary.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [out] tfs
+ * Pointer pointer to the session
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_session_get_session_internal(struct tf *tfp,
+ struct tf_session **tfs);
+
+/**
+ * Looks up the private session information from the TF session
+ * info. Performs a fid check against the clients on the session.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [out] tfs
+ * Pointer pointer to the session
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_session_get_session(struct tf *tfp,
+ struct tf_session **tfs);
+
+/**
+ * Looks up client within the session.
+ *
+ * [in] tfs
+ * Pointer pointer to the session
+ *
+ * [in] session_client_id
+ * Client id to look for within the session
+ *
+ * Returns
+ * client if successful.
+ * - (NULL) on failure, client not found.
+ */
+struct tf_session_client *
+tf_session_get_session_client(struct tf_session *tfs,
+ union tf_session_client_id session_client_id);
+
+/**
+ * Looks up client using name within the session.
+ *
+ * [in] session, pointer to the session
+ *
+ * [in] session_client_name, name of the client to lookup in the session
+ *
+ * Returns:
+ * - Pointer to the session, if found.
+ * - (NULL) on failure, client not found.
+ */
+struct tf_session_client *
+tf_session_find_session_client_by_name(struct tf_session *tfs,
+ const char *ctrl_chan_name);
+
+/**
+ * Looks up client using the fid.
+ *
+ * [in] session, pointer to the session
+ *
+ * [in] fid, fid of the client to find
+ *
+ * Returns:
+ * - Pointer to the session, if found.
+ * - (NULL) on failure, client not found.
+ */
+struct tf_session_client *
+tf_session_find_session_client_by_fid(struct tf_session *tfs,
+ uint16_t fid);
+
+/**
+ * Looks up the device information from the TF Session.
+ *
+ * [in] tfs
+ * Pointer to session handle
+ *
+ * [out] tfd
+ * Pointer to the device
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+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.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [out] session_id
+ * Pointer to the session_id
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_session_get_fw_session_id(struct tf *tfp,
+ uint8_t *fw_session_id);
+
+/**
+ * Looks up the Session id the requested TF handle.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [out] session_id
+ * Pointer to the session_id
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+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);
+