How intel/qatlib works
Project Type & Purpose
• This is a low-level, system-library project (Intel QATlib) that provides hardware-accelerated crypto and compression services via user-space libraries and a management daemon. It is _not_ a web or full-stack app but a hardware offload integration toolkit.
High-Level Architecture Components
a. User-Space Applications & Samples
• Your production code or sample programs (quickassist/lookaside/.../sample_code) that call the QAT API.
b. libqat (Access Layer)
• Implements the QuickAssist API (crypto + compression) in C under quickassist/lookaside/access_layer.
• Divided into _common_ utilities, _crypto_ modules (sym/asym), _compression_ modules (dc), _direct_ transport (VFIO), controller, and firmware‐loading stubs.
c. libusdm (User-Space DMA/Mem)
• Manages hugepage allocation, pinning, IOMMU mappings (utilities/libusdm_drv).
d. OS Abstraction Layer (OSAL)
• Uniform threading, atomics, mutexes, logging, service helpers, kernel-proxy IPC (utilities/osal).
e. qatmgr Daemon
• A service (Systemd unit template under utilities/service) that enumerates devices, configures rings, manages PF/VF assignments, and publishes capabilities to clients.
f. Kernel-Space & Hardware
• VFIO driver + in-tree QAT kernel module exposed via /dev/vfio and PF/VF IOCTLs.
• On-card firmware loaded by the driver.
• QAT accelerator ASIC on PCIe bus.
Relationships & Data Flows
• Applications → link against → libqat API
• libqat → uses → libusdm for buffer allocation & mapping
• libqat → uses → OSAL for threading, mutex, logging, user-kernel proxy
• libqat → issues I/O via → VFIO ioctl to QAT kernel driver
• Kernel driver → schedules requests → hardware queues → ASIC
• Hardware → processes → returns completions → kernel → libqat callbacks
• qatmgr ↔ kernel driver: control plane for ring→service mapping, device reset, heartbeat
• Applications ↔ qatmgr: _optional_ for dynamic re-configuration or status queries
Architectural Patterns & Principles
• Layered design: API layer (libqat) → abstraction layer (OSAL) → transport layer (VFIO) → kernel → hardware
• Modular separation: crypto vs compression vs memory mgmt vs control plane
• Plugin-style firmware loading and service registration (controller interfaces)
• Daemon for out-of-band device management (qatmgr)
Key Technologies & Files
• Autotools build (configure.ac, Makefile.am) – for context only.
• quickassist/include: Public headers (cpa.h, cpa_dev.h).
• quickassist/lookaside/access_layer: core logic & transport.
• utilities/libusdm_drv: memory management.
• utilities/osal: cross-platform abstractions.
• utilities/qat_mgr: daemon logic.
• service unit (.service.in) & init script.