/* SPDX-License-Identifier: BSD-3-Clause */ /* Copyright(c) 2007-2022 Intel Corporation */ /** ***************************************************************************** * @file lac_session.h * * @defgroup LacSym_Session Session * * @ingroup LacSym * * Definition of symmetric session descriptor structure * * @lld_start * * @lld_overview * A session is required for each symmetric operation. The session descriptor * holds information about the session from when the session is initialised to * when the session is removed. The session descriptor is used in the * subsequent perform operations in the paths for both sending the request and * receiving the response. The session descriptor and any other state * information required for processing responses from the QAT are stored in an * internal cookie. A pointer to this cookie is stored in the opaque data * field of the QAT request. * * The user allocates the memory for the session using the size returned from * \ref cpaCySymSessionCtxGetSize(). Internally this memory is re-aligned on a * 64 byte boundary for use by the QAT engine. The aligned pointer is saved in * the first bytes (size of void *) of the session memory. This address * is then dereferenced in subsequent performs to get access to the session * descriptor. * * LAC Session Init\n The session descriptor is re-aligned and * populated. This includes populating the content descriptor which contains * the hardware setup for the QAT engine. The content descriptor is a read * only structure after session init and a pointer to it is sent to the QAT * for each perform operation. * * LAC Perform \n * The address for the session descriptor is got by dereferencing the first * bytes of the session memory (size of void *). For each successful * request put on the ring, the pendingCbCount for the session is incremented. * * LAC Callback \n * For each successful response the pendingCbCount for the session is * decremented. See \ref LacSymCb_ProcessCallbackInternal() * * LAC Session Remove \n * The address for the session descriptor is got by dereferencing the first * bytes of the session memory (size of void *). * The pendingCbCount for the session is checked to see if it is 0. If it is * non 0 then there are requests in flight. An error is returned to the user. * * Concurrency\n * A reference count is used to prevent the descriptor being removed * while there are requests in flight. * * Reference Count\n * - The perform funcion increments the reference count for the session. * - The callback function decrements the reference count for the session. * - The Remove function checks the reference count to ensure that it is 0. * * @lld_dependencies * - \ref LacMem "Memory" - Inline memory functions * - QatUtils: logging, locking & virt to phys translations. * * @lld_initialisation * * @lld_module_algorithms * * @lld_process_context * * @lld_end * *****************************************************************************/ /***************************************************************************/ #ifndef LAC_SYM_SESSION_H #define LAC_SYM_SESSION_H /* * Common alignment attributes to ensure * hashStatePrefixBuffer is 64-byte aligned */ #define ALIGN_START(x) #define ALIGN_END(x) __attribute__((__aligned__(x))) /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "icp_accel_devices.h" #include "lac_list.h" #include "lac_sal_types.h" #include "sal_qat_cmn_msg.h" #include "lac_sym_cipher_defs.h" #include "lac_sym.h" #include "lac_sym_hash_defs.h" #include "lac_sym_qat_hash.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ /** ***************************************************************************** * @ingroup LacSym * Spc state * * @description * This enum is used to indicate the Spc state. * *****************************************************************************/ typedef enum lac_single_pass_state_e { NON_SPC, /* Algorithms other than CHACHA-POLY and AES-GCM */ LIKELY_SPC, /* AES-GCM - Likely to handle it as single pass */ SPC /* CHACHA-POLY and AES-GCM */ } lac_single_pass_state_t; /** ******************************************************************************* * @ingroup LacSym_Session * Symmetric session descriptor * @description * This structure stores information about a session * Note: struct types lac_session_d1_s and lac_session_d2_s are subsets of * this structure. Elements in all three should retain the same order * Only this structure is used in the session init call. The other two are * for determining the size of memory to allocate. * The comments section of each of the other two structures below show * the conditions that determine which session context memory size to use. *****************************************************************************/ typedef struct lac_session_desc_s { Cpa8U contentDescriptor[LAC_SYM_QAT_CONTENT_DESC_MAX_SIZE]; /**< QAT Content Descriptor for this session. * NOTE: Field must be correctly aligned in memory for access by QAT * engine */ Cpa8U contentDescriptorOptimised[LAC_SYM_OPTIMISED_CD_SIZE]; /**< QAT Optimised Content Descriptor for this session. * NOTE: Field must be correctly aligned in memory for access by QAT * engine */ CpaCySymOp symOperation; /**< type of command to be performed */ sal_qat_content_desc_info_t contentDescInfo; /**< info on the content descriptor */ sal_qat_content_desc_info_t contentDescOptimisedInfo; /**< info on the optimised content descriptor */ icp_qat_fw_la_cmd_id_t laCmdId; /**