Introduction
The NVIDIA DOCA™ Memos Initiator reference application runs on NVIDIA® BlueField®. It exposes a Key/Value (KV) NVMe namespace to the host, backed by remote storage reached over NVMe-oF RDMA. It shows how to combine three DOCA libraries into a working storage path:
-
DOCA DevEmu NVMe: emulates an NVMe PCIe function that the host sees as a regular NVMe controller.
-
DOCA DMA: moves command data between host memory and BlueField memory.
-
DOCA Memos Initiator: forwards the host's KV commands to a remote NVMe-oF target.
The host sees one NVMe namespace that uses the NVMe Key Value command set; its command set identifier (CSI) is KV. The host issues KV Store, Retrieve, and Exist commands on it, for example with the DOCA Memos fio Plugin or any other NVMe KV client. The application serves each command from a DOCA Memos Initiator volume attached to a namespace on the remote target.
This reference application is not production-ready. Use it only as a reference.
For the coordinated host, BlueField, and target example, see DOCA Memos Reference Application. For host workload configuration, see DOCA Memos fio Plugin.
System Design
The following diagram shows the data path from the host through BlueField to the remote target:
Host BlueField Remote target
+----------------------+ +---------------------------------------+ +------------------+
| NVMe driver | | doca_memos_initiator_ref_app | | NVMe-oF (RDMA) |
| /dev/ngXnY (KV ns) |<--->| emulated NVMe controller (DevEmu) | | subsystem with a |
| KV client (e.g. fio) | PCIe| admin + IO queues, DMA (DOCA DMA) |<->| KV namespace |
+----------------------+ | Memos Initiator volume (RDMA) | +------------------+
+---------------------------------------+
-
The host driver enumerates the emulated function and creates the admin and I/O queues as it would on any NVMe controller.
-
The application answers admin commands itself and translates each KV I/O command into a DOCA Memos Initiator task on the volume.
-
Value data moves between the host and BlueField with DOCA DMA, and between BlueField and the target with RDMA.
Application Architecture
Controller Emulation
-
Controller registers: the application follows the NVMe enable and disable handshake (CC.EN and CSTS.RDY), graceful shutdown (CC.SHN and CSTS.SHST), and function-level reset.
-
When the host enables the controller, the application brings up the admin queues and the I/O workers, then reports ready.
-
When the host disables the controller, the application drains and tears down the admin queues and the I/O workers.
-
At startup, the application clears a stale CSTS left by an earlier run, so the host's reset completes.
-
-
Admin commands: Identify (including the KV command-set structures: I/O Command Set, CNS 05h and 08h), Create/Delete I/O Submission Queue (SQ) and Completion Queue (CQ), Get/Set Features (including the I/O Command Set Profile), Get Log Page, Abort, and Asynchronous Event Request. Abort is accepted but reports that the command was not aborted; it does not cancel an in-flight command.
-
KV commands: the application handles the following commands:
|
Command |
Opcode |
Action |
|---|---|---|
|
Store |
0x01 |
DMA the value from the host, then run a Memos store task on the volume |
|
Retrieve |
0x02 |
Run a Memos retrieve task, then DMA the value to the host |
|
Exist |
0x14 |
Run a Memos exist task |
Delete and List are not implemented and complete with Invalid Opcode.
I/O Path
Each I/O queue is handled by one worker thread, pinned to a core in --core-mask. Each worker owns an I/O context, a progress engine, and its own DMA engine, so the data path needs no locks. Each worker does the following:
-
Receives a KV command.
-
Resolves the host buffer from the physical region page (PRP) entries PRP1 and PRP2.
-
Submits the DMA and Memos tasks on its own progress engine.
-
Completes the command to the host with the NVMe status that the target returned, or with a status derived from the DOCA error.
Statistics
At teardown, the application prints each worker's submitted, completed, and failed counts. It also prints the volume statistics collected from DOCA Memos Initiator: completed operations, value bytes, and the in-flight mean and standard deviation per task type.
DOCA Libraries
This application uses the following DOCA libraries:
Dependencies
-
A supported BlueField platform.
-
A reachable NVMe-oF RDMA target whose subsystem exports a KV namespace. The application serves the first namespace the target reports.
-
An RDMA device on BlueField with a route to the target (
--rdma-dev), for example the uplink representor's RDMA device. -
On the host: Linux kernel 6.2 or later, to drive the KV namespace from user space through its generic character device (
/dev/ngXnY).
Compiling the Application
Refer to the DOCA Installation Guide for Linux for software installation instructions.
DOCA reference applications are installed with full source code and build instructions. This lets you compile them as-is or modify the source code to create custom versions.
For development and compilation guidance, see DOCA Reference Applications.
The source code for the application is located in the following directory:
/opt/mellanox/doca/applications/memos_initiator_ref_app/
Compiling All Applications
All DOCA applications are defined in a single Meson project, so by default the build includes all of them.
To build all the applications together, run:
cd /opt/mellanox/doca/applications/
meson /tmp/build
ninja -C /tmp/build
doca_memos_initiator_ref_app is created under /tmp/build/memos_initiator_ref_app/.
Compiling Only the Current Application
To build only the DOCA Memos Initiator application, run:
cd /opt/mellanox/doca/applications/
meson /tmp/build -Denable_all_applications=false -Denable_memos_initiator_ref_app=true
ninja -C /tmp/build
doca_memos_initiator_ref_app is created under /tmp/build/memos_initiator_ref_app/.
Alternatively, you can set the flags in the meson_options.txt file instead of on the command line:
-
Edit the following flags in
/opt/mellanox/doca/applications/meson_options.txt:-
Set
enable_all_applicationstofalse -
Set
enable_memos_initiator_ref_apptotrue
-
-
Run the following compilation commands:
cd /opt/mellanox/doca/applications/
meson /tmp/build
ninja -C /tmp/build
doca_memos_initiator_ref_app is created under /tmp/build/memos_initiator_ref_app/.
Firmware Configuration
Configure BlueField firmware before creating the emulated function. The following procedure uses native NVMe emulation and PCI-switch hotplug; it does not provision a static NVMe physical function (PF).
This procedure requires platform and firmware support for native NVMe hotplug.
Identify the BlueField Device
Run the following commands as root on BlueField. Start the Mellanox Software Tools (MST) service and list the available devices:
mst start
mst status -v
Identify the MST device corresponding to the BlueField being configured. Replace /dev/mst/<device> in the following commands with its device path.
Review the existing firmware configuration:
mlxconfig -d /dev/mst/<device> -e query
Enable Native NVMe Emulation and PCI-switch Hotplug
Set the following firmware parameters:
mlxconfig -d /dev/mst/<device> --yes set \
INTERNAL_CPU_MODEL=1 \
PF_BAR2_ENABLE=0 \
NVME_EMULATION_ENABLE=1 \
NVME_EMULATION_NUM_PF=0 \
PCI_SWITCH_EMULATION_ENABLE=1 \
PCI_SWITCH_EMULATION_NUM_PORT=2
INTERNAL_CPU_MODEL=1 and PF_BAR2_ENABLE=0 select the DPU-side configuration used by the service deployment. NVME_EMULATION_ENABLE=1 enables native NVMe device emulation. PCI_SWITCH_EMULATION_ENABLE=1 enables the PCI switch, and PCI_SWITCH_EMULATION_NUM_PORT=2 configures the switch port capacity for this example.
The application creates the emulated function dynamically with -H -T nvme. NVME_EMULATION_NUM_PF=0 leaves no firmware-provisioned static NVMe PFs for this hotplug example. One PCI-switch port is reserved, so the number of available hotplug functions is PCI_SWITCH_EMULATION_NUM_PORT minus 1; in this example, one port is available for the dynamic function. Do not configure virtual functions (VFs): SR-IOV is not supported for this application flow.
For command sets other than standard NVM, configure NVME_EMULATION_IOCSS as required by the firmware and desired command set. This application exposes a KV namespace. See DOCA DevEmu NVMe firmware configuration for the native-emulation provisioning paths.
Apply and Verify the Configuration
Power-cycle the host server containing BlueField. A BlueField reboot alone is insufficient to apply these firmware changes.
After the host power-cycle, inspect the active configuration:
mlxconfig -d /dev/mst/<device> -e query
Confirm that the requested settings appear in the Current column and match Next Boot. Values present only in Next Boot have not yet taken effect. Then continue with Discover or Create the Emulated Function.
Running the Application
Hugepage Allocation
Use doca-hugepages to manage the shared BlueField hugepage pool. For allocation, persistence, and management instructions, see the DOCA doca-hugepages Tool guide. Select a hugepage size available on BlueField and provision enough pages for the application and other consumers. If you run the application in a container, configure the container's hugepage allocation separately; reserving the node pool does not increase the container limit.
Discover or Create the Emulated Function
List the emulated functions managed by the emulation manager:
doca_memos_initiator_ref_app -p <emulation-manager-pci> -L
Each line shows the function type, whether it is a PF or VF, its vendor unique identifier (VUID), and its host PCI address:
[0] type=nvme func=PF vuid=MT2337XZ04E8NVMES0D0F2 pci=0000:04:00.2
Create a native NVMe hotplug function, then note the VUID that the application logs:
doca_memos_initiator_ref_app -p <emulation-manager-pci> -H -T nvme
Native NVMe (nvme) is the default PCI type. The examples pass -T nvme explicitly for clarity and use the same type when creating, running, and removing the function. Use the VUID returned by the creation command in the run command in Run.
Run
To start the application, run:
doca_memos_initiator_ref_app -p <emulation-manager-pci> -u <vuid> -T nvme \
-R <rdma-dev> -a <target-ip> -s <target-port> \
-n <target-subsystem-nqn> -N <host-nqn> -m 0x1
The application logs Target connected, Volume ready: nsid=1 attached, and MEMOS initiator reference application is up; waiting for host BAR0 writes. It then waits for the host. After the application is up, load the host NVMe driver (modprobe nvme). The namespace appears as /dev/ngXnY; no block device is created for a KV namespace, and dmesg reports block device for nsid 1 not supported (csi 1). Identify the namespace by its namespace globally unique identifier (NGUID), which matches the target namespace, because controller numbering can change between runs.
To stop the application, do the following:
-
Unload the host NVMe driver (
modprobe -r nvme). -
Stop the application with Control+C.
The application drains in-flight commands, prints its statistics, and exits.
Remove the Dynamic Function
After stopping the workload and application, remove the dynamic function using its VUID as the argument to -U:
doca_memos_initiator_ref_app -p <emulation-manager-pci> -U <vuid> -T nvme
Application Arguments
|
Flag |
Long Flag |
Description |
|---|---|---|
|
|
|
PCI address of the NVMe emulation manager device ( |
|
|
|
VUID of the emulated function for a normal run. Not needed for listing or creating functions; removal takes its VUID through |
|
|
|
RDMA (ibdev) name of the device with a route to the target, for example, |
|
|
|
NVMe-oF target IPv4 address |
|
|
|
NVMe-oF target service ID (port), for example, |
|
|
|
NVMe Qualified Name (NQN) of the target subsystem that exports the KV namespace |
|
|
|
NQN this initiator presents to the target |
|
|
|
List the emulated functions managed by |
|
|
|
Create an emulated function (left powered off), log its VUID, and exit |
|
|
|
Power off (if needed) and destroy the emulated function with the given VUID |
|
|
|
PCI emulation type (default |
|
|
|
I/O queues handled per worker core (default 1) |
|
|
|
CPU bitmask of the I/O worker cores, for example, |
|
|
|
Debug only: hold or reorder I/O completions to exercise delayed and out-of-order completion |
The standard DOCA flags are also supported: -l/--log-level, --sdk-log-level, --log-filter, and -j/--json <path>. With --json, the arguments are read from a JSON file: a flat object whose keys are the long flag names.
{
"pci-addr": "<emulation-manager-pci>",
"vuid": "<vuid>",
"pci-type": "nvme",
"rdma-dev": "<rdma-dev>",
"traddr": "<target-ip>",
"trsvcid": "<target-port>",
"subnqn": "<target-subsystem-nqn>",
"hostnqn": "<host-nqn>",
"core-mask": "0x1"
}
Then run the application with the JSON file:
doca_memos_initiator_ref_app -j <path-to-json>
Limitations
-
One namespace: the application serves one KV namespace, the first one that the target subsystem reports.
-
Value size: this reference application supports values up to 4 KiB, further restricted by the backing namespace's maximum. It clamps the advertised maximum to match its 4 KiB DMA scratch slots. This is a reference-application limitation, not a limit of the Memos Initiator library or fio plugin. A value can span two host pages using PRP1 and PRP2; PRP lists and scatter-gather lists (SGLs) are not supported. An oversized Store completes with KV Invalid Value Size (SCT=0, SC=0x85).
-
Key size: the maximum key length is 16 bytes, further restricted by the backing namespace's maximum. An oversized key completes with KV Invalid Key Size (SCT=0, SC=0x86).
-
Commands: only Store, Retrieve, and Exist are supported. Delete and List are not implemented. Admin Abort does not cancel commands; it reports that the command was not aborted.
-
Restarts: state is not recovered after an application restart. The host must reset the controller, which the application triggers with CSTS.CFS if it finds the controller enabled.
-
Encryption: this reference application creates an unencrypted volume and exposes no encryption-key configuration.
Known Issues
-
Reconnect after a target-path outage: the data path might remain in reconnect progress and I/O might stall. See the Memos Initiator library known issues.
Troubleshooting
|
Symptom |
Cause and Action |
|---|---|
|
Host logs |
Stale controller state from an earlier run. Unload the host driver, restart the application, then load the driver. |
|
No |
The host kernel lacks KV or generic character device support, or the namespace is not ready. Check |
|
Startup fails with |
Check that |
|
KV commands fail with Capacity Exceeded |
The target namespace has no free slots. A store holds a slot while it is in flight. |
Application Code Flow
-
Parse the arguments.
main()inmemos_initiator_ref_app.ccallsdoca_argp_init(), registers the program flags (register_params()) and callsdoca_argp_start().--list-emulated-functions,--hotplug, and--hotunplugrun their operation and exit. -
Open the emulated function.
memos_initiator_ref_app_run()(memos_initiator_ref_app_core.c) selects the PCI type and emulation manager (prepare_pci_type_and_dev()), and opens the function's representor by VUID (open_emulated_rep()). -
Create the NVMe device. It creates the emulated NVMe device (
doca_devemu_nvme_dev_create()) and registersreg_change_cb()for host BAR0 register writes (doca_devemu_nvme_dev_event_reg_change_register()). It then sets the number of queue pairs from the core mask and queues per core (memos_initiator_ref_app_plan_io_queues()), and starts the device context. -
Bring up the data path (
bring_up_datapath()):-
memos_initiator_ref_app_kv_init()(memos_initiator_ref_app_kv.c) connects the DOCA Memos Initiator target, adopts the first target namespace, and creates and attaches the volume. -
It maps host memory (
cache_host_mmap()) and creates the admin DMA engine (memos_initiator_ref_app_dma_init()). -
It starts the I/O workers (
memos_initiator_ref_app_workers_start()), each with its own I/O context, progress engine, and DMA engine.
-
-
Make the function visible to the host. If a host could already see the function,
flag_if_host_active()normalizes its BAR state: it clears a stale CSTS, or asserts CSTS.CFS so an active host resets the controller. Otherwise the host-programmed registers are reset (reset_host_programmed_regs()). A hotplugged function is then powered on (power_on_function()). -
Main loop. The main thread progresses the device and admin contexts (
memos_initiator_ref_app_progress_all()) and the Memos Initiator engine (memos_initiator_ref_app_kv_progress()), which also carries the target keep-alives. It also handles function-level reset (memos_initiator_ref_app_recover_flr()). -
Controller enable and disable.
reg_change_cb()callshandle_cc_write()on every CC write:-
Enable: bring up the admin queues (
memos_initiator_ref_app_admin_bring_up()) and report CSTS.RDY -
Disable or shutdown: tear down the admin queues and I/O workers, and report the new status
-
-
KV commands. Each I/O command arrives at
memos_initiator_ref_app_io_handle()(memos_initiator_ref_app_io.c) on its worker, which dispatches by opcode toio_kv_store(),io_kv_retrieve(), orio_kv_exist(). These functions move the value with the worker's DMA engine and callmemos_initiator_ref_app_kv_store(),memos_initiator_ref_app_kv_retrieve(), ormemos_initiator_ref_app_kv_exist(). Those functions run the Memos Initiator task and return the NVMe status for the completion. -
Teardown. On Control+C,
teardown()powers off a hotplugged function and quiesces the data path (admin queues, I/O workers, DMA engines, and host memory map). Thenmemos_initiator_ref_app_kv_teardown()prints the statistics, destroys the volume, and disconnects the target. Finally, the device contexts are stopped and destroyed.
Last updated: