Overview
The QAT Engine supports custom control messages that allow applications to communicate directly with the engine. These messages serve two primary purposes:- Configuration: Set engine options before initialization
- Runtime Control: Control engine operation during execution
Using Engine Control Messages
Engine control messages use the OpenSSLENGINE_ctrl_cmd() function:
Parameters
Pointer to the QAT Engine instance
String identifying the message type (see reference table below)
Long integer for passing numbers, or a pointer cast to long
Void pointer for passing data structures
The last two parameters to
ENGINE_ctrl_cmd() are always NULL and 0 when used with the QAT Engine.Polling Mode Messages
ENABLE_EXTERNAL_POLLING
Not used
Not used
After engine creation, before initialization
POLL message.
Example:
POLL
Not used
Pointer to int that receives the poll status
Any time after engine initialization
ENABLE_EVENT_DRIVEN_POLLING_MODE
Not used
Not used
After engine creation, before initialization
DISABLE_EVENT_DRIVEN_POLLING_MODE
Not used
Not used
After engine creation, before initialization
ENABLE_INLINE_POLLING
Not used
Not used
After engine creation, before initialization
Currently only available for synchronous RSA computation.
ENABLE_HEURISTIC_POLLING
Not used
Not used
After engine creation, before initialization
Requires external polling mode to be enabled first.
Polling Configuration Messages
SET_INTERNAL_POLL_INTERVAL
Interval in nanoseconds (min: 1, max: 10,000,000, default: 10,000)
Not used
Any time after engine creation
SET_EPOLL_TIMEOUT
Timeout in milliseconds (min: 1, max: 10,000, default: 1,000)
Not used
Any time after engine creation
epoll_wait() when event-driven polling is enabled.
SET_MAX_RETRY_COUNT
Number of retries (default: 5, max: 100,000, -1: infinite)
Not used
Any time after engine creation
Instance and Thread Management
GET_NUM_CRYPTO_INSTANCES
Not used
Pointer to int that receives the instance count
After engine initialization
GET_EXTERNAL_POLLING_FD
Instance number to retrieve fd for
Pointer to int that receives the file descriptor
After engine initialization
SET_INSTANCE_FOR_THREAD
Instance number to bind to
Not used
After engine creation (automatically triggers initialization)
Monitoring and Statistics
GET_NUM_REQUESTS_IN_FLIGHT
Request type: 1 (asym), 2 (KDF), 3 (cipher)
Pointer to int pointer that receives the address of the counter
Any time after engine initialization
1: Asymmetric key operations2: KDF operations (PRF and HKDF)3: Cipher operations (or pipelines when pipelining is used)
GET_NUM_OP_RETRIES
Not used
Pointer to unsigned int that receives the retry count
Any time after engine initialization
Engine Initialization and Lifecycle
INIT_ENGINE
Not used
Not used
After engine creation
ENGINE_init() or after fork.
Useful for performance optimization when engine is compiled with
--disable-qat_auto_engine_init_on_fork.SET_CONFIGURATION_SECTION_NAME
Not used
NULL-terminated section name (max 64 bytes including NULL)
After engine creation, before initialization
[SHIM].
Example:
Fallback and Offload Control
ENABLE_SW_FALLBACK
Not used
Not used
After engine creation, before initialization
HEARTBEAT_POLL
Not used
Pointer to int that receives success/failure status
Any time after engine initialization
Recommended polling interval: 0.5 to 1 second for timely detection of device status changes.
DISABLE_QAT_OFFLOAD
Not used
Not used
Any time after engine initialization
Algorithm Control
SET_CRYPTO_SMALL_PACKET_OFFLOAD_THRESHOLD
Not used
NULL-terminated configuration string (max 1024 bytes)
Any time after engine creation
AES-128-CBC-HMAC-SHA1AES-256-CBC-HMAC-SHA1AES-128-CBC-HMAC-SHA256AES-256-CBC-HMAC-SHA256
- Default: 2048 bytes
- Minimum: 0 bytes
- Maximum: 16,384 bytes
The threshold includes the entire TLS record: header (5B), IV (16B), payload, HMAC (20/32B), padding (0-255B), and padding length (1B).
HW_ALGO_BITMAP
Not used
Pointer to hex value bitmap
Any time after engine initialization
Default bitmap is
0xFFFF (all algorithms enabled). Only the first 16 bits are used.SW_ALGO_BITMAP
Not used
Pointer to hex value bitmap
Any time after engine initialization
Quick Reference Table
| Message | Timing | Param 3 | Param 4 | Purpose |
|---|---|---|---|---|
ENABLE_EXTERNAL_POLLING | Before init | 0 | NULL | Enable external polling mode |
POLL | After init | 0 | int* | Poll all instances |
ENABLE_EVENT_DRIVEN_POLLING_MODE | Before init | 0 | NULL | Enable event-driven polling |
DISABLE_EVENT_DRIVEN_POLLING_MODE | Before init | 0 | NULL | Disable event-driven polling |
ENABLE_INLINE_POLLING | Before init | 0 | NULL | Enable inline polling |
ENABLE_HEURISTIC_POLLING | Before init | 0 | NULL | Enable heuristic polling |
SET_INTERNAL_POLL_INTERVAL | Anytime | nanoseconds | NULL | Set poll interval |
SET_EPOLL_TIMEOUT | Anytime | milliseconds | NULL | Set epoll timeout |
SET_MAX_RETRY_COUNT | Anytime | count | NULL | Set retry limit |
GET_NUM_CRYPTO_INSTANCES | After init | 0 | int* | Get instance count |
GET_EXTERNAL_POLLING_FD | After init | instance | int* | Get polling fd |
SET_INSTANCE_FOR_THREAD | After creation | instance | NULL | Bind thread to instance |
GET_NUM_REQUESTS_IN_FLIGHT | After init | type | int** | Get in-flight counter address |
GET_NUM_OP_RETRIES | After init | 0 | unsigned int* | Get retry count |
INIT_ENGINE | After creation | 0 | NULL | Manually initialize |
SET_CONFIGURATION_SECTION_NAME | Before init | 0 | char* | Set config section |
ENABLE_SW_FALLBACK | Before init | 0 | NULL | Enable software fallback |
HEARTBEAT_POLL | After init | 0 | int* | Check device status |
DISABLE_QAT_OFFLOAD | After init | 0 | NULL | Disable HW acceleration |
SET_CRYPTO_SMALL_PACKET_OFFLOAD_THRESHOLD | Anytime | 0 | char* | Set size thresholds |
HW_ALGO_BITMAP | After init | 0 | unsigned long* | Set HW algorithm bitmap |
SW_ALGO_BITMAP | After init | 0 | unsigned long* | Set SW algorithm bitmap |