Networking DOCA SDK Documentation

DOCA Memos Target

Introduction

The NVIDIA DOCA™ Memos Target library is a C API for services that run on a CMX data node. A CMX data node is a storage-side node that holds SSDs and provides shared KV-cache capacity. The library translates incoming Key/Value (KV) STORE, EXIST, RETRIEVE, and DELETE commands into block-level read and write operations.

The library does not access storage media directly. The application that uses the library supplies the SSD management logic that performs the read and write operations on the backing storage media.

DOCA Memos Target works as a pair with DOCA Memos Initiator. For an overview of the DOCA Memos libraries and how they work together, see DOCA Memos.

The DOCA Memos Target APIs are an initial definition and are subject to change as the architecture evolves. Backward compatibility is not guaranteed. For the quality level of each DOCA library, see DOCA Libraries.

Prerequisites

This library follows the architecture of a DOCA Core Context. Before you continue, read the following DOCA Core sections:

Changes From Previous Releases

This is the first release of the DOCA Memos Target library.

Known Issues

  • A subsystem with no attached namespace does not report KV command set support to initiators until the first namespace is attached. Until then, CAP.CSS.IOCSS is cleared, and Identify I/O Command Set does not list KV. Workaround: Attach at least one KV namespace to the subsystem before initiators connect.

  • A namespace detached on the target during KV I/O can stay in "detaching" until it comes back, and the I/O in flight to it stops responding until then. Workaround: Stop all I/O to a namespace before detaching or destroying it on the target.

  • If the target reuses a removed namespace's NSID while the initiator is writing, KV stores land on a different namespace. Workaround: Stop all I/O to a namespace before detaching it on the target.

Limitations

  • Adding a backend to an attached namespace, or removing one from it, is not validated in this release. The change redistributes keys, so keys stored earlier might no longer be retrievable. Add all backends before attaching the namespace. Detaching a namespace effectively drops its existing data.

  • Disconnect all initiators from a subsystem on a port before removing that port from the subsystem. doca_memos_target_subsys_rm_port() does not drop existing connections; they stay up and continue to perform I/O after the port is removed.

  • The size of a namespace is the total capacity of its backends. The size parameter of doca_memos_target_subsys_ns_create() has no effect, and a namespace cannot be resized once it is started. A size larger than the total capacity of the backends causes doca_memos_target_subsys_attach_ns() to fail.

Environment

DOCA Memos Target applications run on the Arm cores of NVIDIA® BlueField® and require a DOCA device that supports the library. To select the device, use DOCA Core device discovery. The library validates each device that you register with doca_memos_target_add_dev() against doca_memos_target_cap_is_supported().

The library supports NVMe-oF over RDMA and the IPv4 and IPv6 address families. For details, see Device Support.

Architecture

The management context (doca_memos_target_mgmt) and the I/O contexts (doca_memos_target_io) are DOCA Core Contexts. Each one connects to a DOCA progress engine, which you progress by calling doca_pe_progress().

  • The management context handles the target's management work, such as the lifecycles of its subsystems, ports, namespaces, and backends.

  • The I/O contexts receive Key/Value commands from DOCA Memos initiators and deliver the resulting READ and WRITE requests to the application. A DOCA Core Context is not thread-safe, so each thread that handles I/O needs its own I/O context.

Each NVMe-oF entity that the target exposes also has a corresponding object: a subsystem (doca_memos_target_subsys), its namespaces (doca_memos_target_subsys_ns), and the ports through which the subsystem is reachable (doca_memos_target_port). Each namespace stores its data in one or more backends (doca_memos_target_backend), which are storage regions that the application manages. You configure and drive these objects through the management context. They do not have progress engines of their own.

Many target operations are asynchronous and report their completion through a registered handler. The handler runs only if the function that starts the operation returns DOCA_SUCCESS. If the function returns an error, the operation failed immediately, and the handler does not run.

Objects

The following table describes the DOCA Memos Target objects:

Object

Description

Scope

doca_memos_target_mgmt

This DOCA Core Context progresses all management-path work: port, subsystem, namespace, and backend operations and their completion handlers.

One per target process

doca_memos_target_subsys

A subsystem is a storage-side, exported logical endpoint that is identified like an NVMe-oF subsystem. You attach namespaces and add ports to it.

Multiple per target process

doca_memos_target_subsys_ns

A namespace is a logical Key/Value namespace that is backed by one or more backends. You attach it to a subsystem to expose it on the fabric. A subsystem can have up to its configured maximum number of namespaces.

Multiple per subsystem

doca_memos_target_backend

A backend is a contiguous, block-addressed storage region. A namespace can aggregate more than one backend, and a backend belongs to at most one namespace at a time.

Multiple per target process

doca_memos_target_port

A port is a network listen endpoint that is defined by its transport type, address family, address, and service ID. You can add a port to multiple subsystems, and a subsystem can be reachable through multiple ports.

Multiple per target process

doca_memos_target_io

This DOCA Core Context receives NVMe Key/Value commands (STORE, EXIST, RETRIEVE, and DELETE) over established NVMe-oF connections and translates them into doca_memos_target_req requests.

One per I/O thread

doca_memos_target_req

A request is an abstract I/O request that an I/O context produces from a decoded incoming command. The I/O context hands the request to the application's registered READ or WRITE handler, and the application completes it with doca_memos_target_req_complete().

One per in-flight request

The following figure shows the library components and how they interact:

library_components.png
The management context configures the subsystem, and per-thread I/O contexts pass READ and WRITE requests to the SSD management layer.

Threading and Concurrency

The following rules apply to threads and handlers:

  • The management path includes the port, subsystem, namespace, and backend lifecycle calls and the completion handlers that those operations invoke. The library does not synchronize the management path. Do not run two management-path calls at once. Do not overlap any of them with doca_pe_progress() on the management progress engine. One way to follow these rules is to issue every management call from the thread that progresses that engine.

  • Handlers must not call doca_pe_progress(). A completion handler that runs inside a doca_pe_progress() call can make more management calls because it runs on the same thread and does not overlap that call.

  • I/O contexts are not on the management path. Each I/O context handles I/O independently, and you can progress its progress engine in parallel with the management path.

  • Some management operations depend on the I/O contexts. For example, subsystem start and stop, and namespace attach and detach, might involve I/O contexts. These operations cannot complete unless you keep progressing all I/O contexts.

Initialization Flow

The following sections describe the target initialization and the subsystem and namespace initialization.

Target Initialization

  1. Register devices with doca_memos_target_add_dev(), and apply any optional configuration with doca_memos_target_set_*(). For all configuration options, see Target Configuration.

  2. Call doca_memos_target_init().

  3. For each thread that handles I/O, set up an I/O context:

    1. Create a progress engine with doca_pe_create().

    2. Create an I/O context with doca_memos_target_io_create().

    3. Register its READ and WRITE request handlers.

    4. Connect the I/O context to the progress engine with doca_pe_connect_ctx().

    5. Start the I/O context with doca_ctx_start().

  4. Set up the management context:

    1. Create the management context with doca_memos_target_mgmt_create().

    2. Connect it with doca_pe_connect_ctx() to the progress engine that handles the target's management work.

    3. Start it with doca_ctx_start().

  5. Call doca_memos_target_start(). This call ends the configuration phase and freezes the set of I/O contexts and the management context.

The following figure shows the target initialization sequence:

target_init_sequence.png
The application initializes the target, starts an I/O context for each thread and the management context, and then starts the target.

Subsystem and Namespace Initialization

A subsystem accepts namespaces and ports only after it is running. To create and start a subsystem, do the following:

  1. Create the subsystem with doca_memos_target_subsys_create().

  2. Set the NVMe Qualified Name (NQN) with doca_memos_target_subsys_set_nqn(), and set any optional subsystem properties. For the options, see Subsystems.

  3. Register the start and stop completion handlers. Both handlers are required.

  4. Register the namespace attach and detach, backend add and remove, and port add and remove completion handlers. Without them, the application cannot tell when these asynchronous operations complete or whether they succeed.

  5. Call doca_memos_target_subsys_start(). The operation is asynchronous: the subsystem enters the Starting state, and the registered start handler reports whether the subsystem reached the Running state or returned to Idle.

To make the subsystem reachable through a port, do the following:

  1. Create a listener port with doca_memos_target_port_create(). The port starts listening as soon as you create it, and you can add the same port to any number of subsystems.

  2. After the subsystem is running, add the port to it with doca_memos_target_subsys_add_port(). The operation is asynchronous, and the registered port-add handler runs when it completes.

To add a namespace and its backends after the subsystem is running, do the following:

  1. Create a namespace object with doca_memos_target_subsys_ns_create(), and configure it with doca_memos_target_subsys_ns_set_*().

  2. Start the namespace object with doca_memos_target_subsys_ns_start(). Starting the namespace locks its static configuration, and you can then add backends to it.

  3. Create a backend with doca_memos_target_backend_create(). Pass it an attributes object that you allocate with doca_memos_target_backend_create_attr_create() and configure with doca_memos_target_backend_create_attr_set_*(): block size, number of blocks, write granularity, optimal write size, and optional user data.

  4. Add the backend to the namespace with doca_memos_target_subsys_ns_add_backend(). The operation is asynchronous, and the registered backend-add handler runs when it completes.

  5. Repeat steps 3 and 4 for each additional backend.

  6. Attach the namespace to the subsystem with doca_memos_target_subsys_attach_ns(). The operation is asynchronous, and the registered namespace-attach handler runs when it completes.

The following figure shows the subsystem and namespace initialization sequence:

subsys_ns_init_sequence.png
The application creates a port, starts a subsystem, adds the port, starts a namespace, adds backends, and attaches the namespace to the subsystem.

Teardown Flow

Keep progressing every I/O context until it has stopped at the end of target teardown. Otherwise, the namespace, port, and subsystem teardown steps might not complete.

Namespace and Backend Teardown

Reverse the namespace and backend initialization steps:

  1. Detach the namespace from the subsystem with doca_memos_target_subsys_detach_ns(). The operation is asynchronous, and the registered namespace-detach handler runs when it completes.

  2. Remove each backend from the namespace with doca_memos_target_subsys_ns_rm_backend(). Each removal is asynchronous, and the registered backend-remove handler runs when it completes.

  3. Optional: If you no longer need the backends, destroy them with doca_memos_target_backend_destroy().

  4. Stop the namespace object with doca_memos_target_subsys_ns_stop(). You can then reconfigure or destroy it.

  5. Optional: If you no longer need the namespace object, destroy it with doca_memos_target_subsys_ns_destroy(). Target teardown requires every namespace object to be destroyed.

Port Removal

  1. Remove the port from the subsystem with doca_memos_target_subsys_rm_port(). The operation is asynchronous, and the registered port-remove handler runs when it completes.

  2. Optional: After you remove the port from every subsystem, destroy it with doca_memos_target_port_destroy(). Destroying the port stops the listener.

Target Teardown

After you destroy every namespace and remove every port from its subsystems, tear down the target:

  1. If you have not already destroyed the backends, destroy them with doca_memos_target_backend_destroy().

  2. Stop each subsystem with doca_memos_target_subsys_stop(). Each stop is asynchronous, and the registered stop handler runs when the subsystem reaches Idle.

  3. Destroy each subsystem with doca_memos_target_subsys_destroy().

  4. If you have not already destroyed the ports, destroy them with doca_memos_target_port_destroy().

  5. Call doca_memos_target_stop(). This call does not stop the I/O contexts or the management context.

  6. Stop and destroy the management context and every I/O context. A context that is stopped but not destroyed blocks teardown.

  7. Call doca_memos_target_teardown().

To restart the target instead of continuing the teardown after step 5, change the I/O contexts or the management context if needed, and then call doca_memos_target_start() again.

Configuration Phase

In the configuration phase, the application registers devices, initializes the target, and creates and starts the management context and one I/O context for each thread that handles I/O. Do all configuration in this phase from a single thread. The phase ends when you call doca_memos_target_start(). For the required order, see Target Initialization.

Target Configuration

Apply all target configuration before you call doca_memos_target_init(). Configuration calls that you make after initialization return DOCA_ERROR_BAD_STATE.

You must apply the following configuration:

Configuration

API

Register every DOCA device whose network interfaces the target listens on.

doca_memos_target_add_dev()

If you do not register at least one device, doca_memos_target_init() fails.

The following configuration is optional:

Configuration

API

Default

Notes

Per-request user-data buffer size

doca_memos_target_set_req_user_data_size()

0 bytes

With the default size of 0, no buffer is allocated.

Target-wide maximum namespace value length

doca_memos_target_set_max_ns_value_len()

8 MiB

The value must be at least doca_memos_target_cap_get_min_ns_value_len(), a multiple of doca_memos_target_cap_get_ns_value_len_align(), and at most doca_memos_target_cap_get_max_ns_value_len(). In this release, that maximum is 8 MiB, the same as the default. The maximum might change in later releases, so get it from doca_memos_target_cap_get_max_ns_value_len() instead of hardcoding it.

Custom request-buffer allocator

doca_memos_target_register_buffer_allocator()

Internal default allocator

The log_align value must be at least doca_memos_target_cap_get_min_buffer_log_align().

The target allocates request data buffers from the registered allocator, mostly during initialization rather than for each request, and frees them during teardown. With the internal default allocator, the application might need to DMA-map the request buffers for its backend devices on the data path. For optimal performance, register a custom allocator, for example, one that returns memory that the application has already DMA-mapped for its devices.

Management Context

The management context has no configuration of its own. To get its DOCA context, call doca_memos_target_mgmt_as_ctx(). For the setup steps, see Target Initialization.

I/O Contexts

To get the DOCA context of an I/O context, call doca_memos_target_io_as_ctx(). For the setup steps, see Target Initialization. At most doca_memos_target_get_max_num_io() I/O contexts can exist.

You must register the following handlers before you call doca_ctx_start() on the I/O context:

Configuration

API

READ request handler

doca_memos_target_register_io_event_read_req()

WRITE request handler

doca_memos_target_register_io_event_write_req()

Device Support

You can query device capabilities without creating a target instance. Use the following functions:

Capability

API

DOCA Memos Target support

doca_memos_target_cap_is_supported()

NVMe-oF transport type support

doca_memos_target_cap_is_trtype_supported()

NVMe-oF address family support

doca_memos_target_cap_is_adrfam_supported()

The capability functions report whether each recognized value is supported. For a value outside the NVMe-oF specification, doca_memos_target_cap_is_trtype_supported() and doca_memos_target_cap_is_adrfam_supported() return DOCA_ERROR_INVALID_VALUE instead.

The following table lists the NVMe-oF transport types that the library recognizes and whether the library supports each one:

NVMe-oF Transport Type

Supported

RDMA

Yes

TCP

Recognized, not supported

Fibre Channel (FC)

Recognized, not supported

Intra-host

Recognized, not supported

The following table lists the NVMe-oF address families that the library recognizes and whether the library supports each one:

NVMe-oF Address Family

Supported

IPv4

Yes

IPv6

Yes

InfiniBand (IB)

Recognized, not supported

FC

Recognized, not supported

Intra-host

Recognized, not supported

If you set a port attribute to a recognized but unsupported value with doca_memos_target_port_create_attr_set_trtype() or doca_memos_target_port_create_attr_set_adrfam(), the call returns DOCA_ERROR_NOT_SUPPORTED.

Execution Phase

After the target starts, the application creates and configures the subsystems, namespaces, backends, and ports that serve traffic. The library delivers I/O requests and the completions of management operations to the application as events. The application processes these events in the handlers that it registers. For the rules that handlers must follow, see Threading and Concurrency.

Subsystems

Configure a subsystem while it is Idle. Configuration calls that you make while the subsystem is in any other state return DOCA_ERROR_BAD_STATE.

You must apply the following configuration before you call doca_memos_target_subsys_start():

Configuration

API

NQN

doca_memos_target_subsys_set_nqn()

Start completion handler

doca_memos_target_register_subsys_event_start()

Stop completion handler

doca_memos_target_register_subsys_event_stop()

The following configuration is optional:

Configuration

API

Default

Notes

Maximum namespace count

doca_memos_target_subsys_set_max_namespaces()

Implementation-defined

The value is bounded by doca_memos_target_cap_get_max_namespaces(). To get the current value, call doca_memos_target_subsys_get_max_namespaces().

Namespace ID (NSID) range

doca_memos_target_subsys_set_namespace_range()

Implementation-defined

To get the current range, call doca_memos_target_subsys_get_namespace_range().

Namespace attach and detach completion handlers

doca_memos_target_register_subsys_event_ns_attach()

doca_memos_target_register_subsys_event_ns_detach()

Not registered

Register these handlers. Without them, the application cannot tell when an asynchronous attach or detach operation completes or whether it succeeds.

Backend add and remove completion handlers

doca_memos_target_register_subsys_event_backend_add()

doca_memos_target_register_subsys_event_backend_rm()

Not registered

Register these handlers. Without them, the application cannot tell when an asynchronous add or remove operation completes or whether it succeeds.

Port add and remove completion handlers

doca_memos_target_register_subsys_event_port_add()

doca_memos_target_register_subsys_event_port_rm()

Not registered

Register these handlers. Without them, the application cannot tell when an asynchronous add or remove operation completes or whether it succeeds.

Namespaces

Configure a namespace while it is Stopped. Configuration calls that you make while it is Started return DOCA_ERROR_BAD_STATE. The exception is the namespace size: if no attach or detach operation is pending, you can also change it with doca_memos_target_subsys_ns_set_size() while the namespace is Started.

You must set the following configuration before you call doca_memos_target_subsys_ns_start():

Configuration

API

Notes

Namespace ID (NSID)

doca_memos_target_subsys_ns_set_ns_id()

The NSID must be nonzero, unique within the subsystem, and inside the subsystem's configured NSID range.

The following configuration is optional:

Configuration

API

Default

Namespace globally unique identifier (NGUID)

doca_memos_target_subsys_ns_set_nguid()

Zero-filled

Maximum value length

doca_memos_target_subsys_ns_set_max_value_len()

Target-wide maximum (8 MiB by default)

Namespace size (NSZE)

doca_memos_target_subsys_ns_set_size()

0

User data

doca_memos_target_subsys_ns_set_user_data()

0

Tenant ID

doca_memos_target_subsys_ns_set_tenant_id()

0

The maximum value length must be at least doca_memos_target_cap_get_min_ns_value_len(), a multiple of doca_memos_target_cap_get_ns_value_len_align(), and no larger than the target-wide maximum that you set with doca_memos_target_set_max_ns_value_len().

In this release, the target stores the tenant ID but does not verify it, so the tenant ID does not restrict which initiators can perform I/O on the namespace.

Backends

To create a backend, allocate an attributes object with doca_memos_target_backend_create_attr_create(), configure it, and pass it to doca_memos_target_backend_create(). The library copies the attributes into the new backend. You cannot change them afterward. You can reuse the attributes object for more backends, or destroy it with doca_memos_target_backend_create_attr_destroy() as soon as you create the backend.

You must set the following attributes:

Attribute

API

Description

Logical block size

doca_memos_target_backend_create_attr_set_block_size()

The size is in bytes. It must be a power of two and no larger than doca_memos_target_cap_get_max_backend_block_size().

Number of logical blocks

doca_memos_target_backend_create_attr_set_num_blocks()

The number must be nonzero.

Write granularity

doca_memos_target_backend_create_attr_set_write_granularity()

The write granularity is the smallest write, in bytes, that the device performs without a read-modify-write cycle. It must be a power of two, a multiple of the block size, and no larger than doca_memos_target_cap_get_max_backend_write_granularity(). If the device does not report a write granularity, use the block size.

Optimal write size

doca_memos_target_backend_create_attr_set_optimal_write_size()

The optimal write size is the write size, in bytes, at which the device reaches its maximum performance. It must be a nonzero multiple of the block size and no larger than doca_memos_target_cap_get_max_backend_optimal_write_size(). If the device does not report an optimal write size, use the block size.

The following attribute is optional:

Attribute

API

Default

User data

doca_memos_target_backend_create_attr_set_user_data()

0

Ports

To create a port, allocate an attributes object with doca_memos_target_port_create_attr_create(), configure it, and pass it to doca_memos_target_port_create(). The library copies the attributes into the new port. You can reuse the attributes object for more ports, or destroy it with doca_memos_target_port_create_attr_destroy() as soon as you create the port.

For the supported transport types and address families, see Device Support. You must set the following attributes:

Attribute

API

Transport type

doca_memos_target_port_create_attr_set_trtype()

Address family

doca_memos_target_port_create_attr_set_adrfam()

Transport address

doca_memos_target_port_create_attr_set_traddr()

Transport service ID

doca_memos_target_port_create_attr_set_trsvcid()

I/O Events

To serve a Key/Value command, an I/O context issues one or more READ and WRITE requests, and it can issue several of them in parallel. Each request reaches the application as a doca_memos_target_req through an I/O event, and the application completes it by calling doca_memos_target_req_complete().

Requests

Each READ or WRITE I/O event carries the following properties:

Property

Description

Request

The event carries the request itself (doca_memos_target_req).

Request user data

The event carries the per-request user-data buffer. To set its size, call doca_memos_target_set_req_user_data_size().

Backend

The event carries the backend that the request targets. To get the user data that you set when you created the backend, call doca_memos_target_backend_get_user_data().

Namespace

The event carries the namespace that the request targets. To get its NSID or user data, call doca_memos_target_subsys_ns_get_ns_id() or doca_memos_target_subsys_ns_get_user_data().

Subsystem

To get the subsystem that the request targets, call doca_memos_target_req_get_subsys().

I/O context

To get the I/O context that delivered the request, call doca_memos_target_req_get_io().

Offset

The event carries the byte offset within the backend at which the request starts.

Data length

The event carries the total length, in bytes, of the data to read or write.

Data buffers

For a READ request, these are the output buffers that you fill with the data to return. For a WRITE request, they hold the data to write. To get the buffers, call doca_memos_target_req_get_iovec() and doca_memos_target_req_get_iovcnt().

The following limitations apply to requests:

  • Call doca_memos_target_req_complete() and the request getters (doca_memos_target_req_get_*()) from the same thread that invoked the handler.

  • The request, its user-data buffer, and its data buffers are valid only from handler invocation until completion.

  • Ownership of the request moves to the application when the handler is invoked, and back to the I/O context on completion.

READ Request Event

The following sections describe the configuration, trigger condition, output, and handling of the READ request event.

Event Configuration

Description

API to Set the Configuration

Register the handler

doca_memos_target_register_io_event_read_req()

Event Trigger Condition

The I/O context needs data read from a backend to serve a Key/Value command.

Event Output

The event carries a request with output buffers to fill. To get the buffers, call doca_memos_target_req_get_iovec() and doca_memos_target_req_get_iovcnt().

Event Handling

Fill the buffers that the output iovec describes with the data to return, and then call doca_memos_target_req_complete() with a status.

WRITE Request Event

The following sections describe the configuration, trigger condition, output, and handling of the WRITE request event.

Event Configuration

Description

API to Set the Configuration

Register the handler

doca_memos_target_register_io_event_write_req()

Event Trigger Condition

The I/O context needs data written to a backend to serve a Key/Value command.

Event Output

The event carries a request with the data to write. To get the buffers that hold the data, call doca_memos_target_req_get_iovec() and doca_memos_target_req_get_iovcnt().

Event Handling

Write the data in the buffers that the input iovec describes to the backend at the request's offset, and then call doca_memos_target_req_complete() with a status.

Management Events

The library delivers the following events on the management path. These events follow the rules in Threading and Concurrency.

Subsystem Events

The following sections describe the configuration, trigger condition, and output of the subsystem start and stop events.

Event Configuration

Description

API to Set the Configuration

Register the subsystem start handler

doca_memos_target_register_subsys_event_start()

Register the subsystem stop handler

doca_memos_target_register_subsys_event_stop()

Event Trigger Condition

A doca_memos_target_subsys_start() or doca_memos_target_subsys_stop() operation completes, successfully or not.

Event Output

The handler receives the following arguments:

  • subsys is the subsystem whose operation completed.

  • reg_user_data is the user data that you supplied at registration.

  • op_user_data is the user data that you supplied to the start or stop call. Use it to correlate the completion with the call.

  • status is DOCA_SUCCESS, or an error code if the operation failed.

Port Events

The following sections describe the configuration, trigger condition, and output of the port add and remove events.

Event Configuration

Description

API to Set the Configuration

Register the port add handler

doca_memos_target_register_subsys_event_port_add()

Register the port remove handler

doca_memos_target_register_subsys_event_port_rm()

Event Trigger Condition

A doca_memos_target_subsys_add_port() or doca_memos_target_subsys_rm_port() operation completes, successfully or not.

Event Output

The handler receives the following arguments:

  • subsys is the subsystem that the port was added to or removed from.

  • reg_user_data is the user data that you supplied at registration.

  • op_user_data is the user data that you supplied to the add or remove call. Use it to correlate the completion with the call.

  • status is DOCA_SUCCESS, or an error code if the operation failed.

Namespace Events

The following sections describe the configuration, trigger condition, and output of the namespace attach and detach events.

Event Configuration

Description

API to Set the Configuration

Register the namespace attach handlers

doca_memos_target_register_subsys_event_ns_attach()

Register the namespace detach handlers

doca_memos_target_register_subsys_event_ns_detach()

Event Trigger Condition

A doca_memos_target_subsys_attach_ns() or doca_memos_target_subsys_detach_ns() operation completes, successfully or not.

Event Output

The library calls the registered success handler or error handler with the following arguments:

  • subsys is the subsystem instance.

  • ns is the namespace that the operation completed for.

  • reg_user_data is the user data that you supplied at registration.

Backend Events

The following sections describe the configuration, trigger condition, and output of the backend add and remove events.

Event Configuration

Description

API to Set the Configuration

Register the backend add handlers

doca_memos_target_register_subsys_event_backend_add()

Register the backend remove handlers

doca_memos_target_register_subsys_event_backend_rm()

Event Trigger Condition

A doca_memos_target_subsys_ns_add_backend() or doca_memos_target_subsys_ns_rm_backend() operation completes, successfully or not.

Event Output

The library calls the registered success handler or error handler with the following arguments:

  • ns is the namespace that the backend was added to or removed from.

  • backend is the backend that you passed to the add or remove call.

  • reg_user_data is the user data that you supplied at registration.

State Machine

The following sections describe the states of the management context, I/O contexts, subsystems, namespaces, backends, and ports.

Management Context States

The management context (doca_memos_target_mgmt) follows the DOCA Core Context state machine.

State

Allowed Operations

How to Reach

Idle

Connect the context to a progress engine with doca_pe_connect_ctx(), call doca_ctx_start(), or call doca_memos_target_mgmt_destroy().

Create the context with doca_memos_target_mgmt_create(). A Stopping context also returns to Idle after the stop request completes.

Starting

Call doca_pe_progress().

Call doca_ctx_start() from Idle.

Running

Issue port, subsystem, namespace, and backend calls on the management path after the target starts, call doca_pe_progress(), and call doca_ctx_stop() after the target stops.

A Starting context moves to Running after the underlying start completes.

Stopping

Call doca_pe_progress().

Call doca_ctx_stop() from Running. The stop is blocked while the target is started. The underlying stop request returns immediately, without requiring the target to drain further work.

doca_memos_target_mgmt_destroy() requires the context to be Idle.

I/O Context States

Each I/O context (doca_memos_target_io) follows the DOCA Core Context state machine.

State

Allowed Operations

How to Reach

Idle

Register the READ and WRITE handlers, call doca_ctx_start(), or call doca_memos_target_io_destroy().

Create the context with doca_memos_target_io_create(). A Stopping context also returns to Idle after it drains.

Starting

Call doca_pe_progress().

Call doca_ctx_start() from Idle. If the READ or WRITE handler is not registered, the start fails back to Idle with DOCA_ERROR_BAD_CONFIG.

Running

Call doca_pe_progress(), serve READ and WRITE requests, and call doca_ctx_stop().

A Starting context moves to Running after the underlying start completes.

Stopping

Call doca_pe_progress() until the context drains.

Call doca_ctx_stop() from Running. The stop is blocked while the target is started.

doca_memos_target_io_destroy() requires the context to be Idle.

Subsystem States

A subsystem (doca_memos_target_subsys) is not a DOCA Core Context. You drive its lifecycle with doca_memos_target_subsys_start() and doca_memos_target_subsys_stop(), and the library reports state changes through the start and stop completion handlers. For details, see Subsystem Events.

State

Description

Allowed Operations

Idle

Inactive

Configure the subsystem, register event handlers, or call doca_memos_target_subsys_start().

Starting

doca_memos_target_subsys_start() was called but has not completed.

None. Wait for the registered start handler.

Running

Serving DOCA Memos initiators

Attach or detach namespaces, add or remove ports, or call doca_memos_target_subsys_stop().

Stopping

doca_memos_target_subsys_stop() was called but has not completed.

None. Wait for the registered stop handler.

doca_memos_target_subsys_destroy() requires the subsystem to be Idle.

Namespace States

A namespace has a configuration state, which controls whether its static configuration is locked, and an attachment state, which controls whether the subsystem's NVMe-oF controllers can see the namespace. The following figure shows how the two states combine:

namespace_state.png
A namespace moves between Stopped and Started. While Started, it moves through Detached, Attach in Progress, Attached, and Detach in Progress.

Configuration Lock

State

Description

Allowed Operations

Stopped

You can change the static configuration: NSID, NGUID, maximum value length, tenant ID, and user data.

Call the configuration setters or doca_memos_target_subsys_ns_start().

Started

The static configuration is locked.

Add or remove backends, attach or detach the namespace, call doca_memos_target_subsys_ns_set_size(), or call doca_memos_target_subsys_ns_stop().

doca_memos_target_subsys_ns_start() requires a nonzero NSID. doca_memos_target_subsys_ns_stop() requires the namespace to be detached and to have no backends added.

Attachment

The attachment state applies only after the namespace is Started.

State

Description

Detached

The subsystem's NVMe-oF controllers cannot see the namespace.

Attach in Progress

doca_memos_target_subsys_attach_ns() was called but has not completed.

Attached

The subsystem's NVMe-oF controllers can see the namespace.

Detach in Progress

doca_memos_target_subsys_detach_ns() was called but has not completed.

doca_memos_target_subsys_ns_destroy() requires the namespace to be both Stopped and Detached.

Backend and Port States

Backends (doca_memos_target_backend) and ports (doca_memos_target_port) have no intermediate states. A backend exists from doca_memos_target_backend_create() until doca_memos_target_backend_destroy(), and is either added to a namespace or not. To check, call doca_memos_target_backend_is_added(). A port listens from doca_memos_target_port_create() until doca_memos_target_port_destroy(), and is either added to a subsystem or not. You cannot destroy either object while it is still added.

DOCA Memos Target Samples

All DOCA samples described in this section are governed under the BSD-3 software license agreement.

DOCA Memos Simple Target

This sample shows how to use the DOCA Memos Target API to create and start a subsystem that exposes one file-backed namespace over one NVMe-oF RDMA port. The sample serves READ and WRITE requests against its backing file.

For the end-to-end example that connects this sample to the DOCA Memos Initiator Application and the DOCA Memos fio Plugin, see DOCA Memos Reference Application.

The sample logic includes the following steps:

  1. Registering the buffer allocator and every device that supports the DOCA Memos Target library, and then initializing the target.

  2. Opening and starting the target-level I/O context and the management context.

  3. Starting the target, which freezes the set of I/O contexts and the management context.

  4. Creating the target-level listener port.

  5. Creating the subsystem, registering all of its completion handlers, and starting the subsystem.

  6. Adding the listener port to the subsystem.

  7. Adding a file-backed namespace: creating the namespace, adding a backend for the backing file with its write granularity and optimal write size set, and attaching the namespace to the subsystem.

  8. Serving READ and WRITE requests against the backing file until interrupted, and then tearing everything down in reverse order.

For the source code, see the following files:

  • /opt/mellanox/doca/samples/doca_memos_target/memos_simple_target/memos_simple_target_main.c

  • /opt/mellanox/doca/samples/doca_memos_target/memos_simple_target/memos_simple_target_sample.c

  • /opt/mellanox/doca/samples/doca_memos_target/memos_simple_target/meson.build

  • /opt/mellanox/doca/samples/doca_memos_target/README.md

Build the Sample

To install BlueField-related software, see DOCA Installation Guide for Linux. If you have issues installing, compiling, or running DOCA samples, see DOCA Troubleshooting.

Build the sample:

Bash
cd /opt/mellanox/doca/samples/doca_memos_target/memos_simple_target
meson /tmp/build
ninja -C /tmp/build

The build creates the doca_memos_simple_target binary in /tmp/build/.

Run the Sample

The sample requires the following command-line arguments:

Argument

Description

-a, --addr <ip>

Transport address (IP) to listen on

-p, --port <port>

Transport service ID (port number)

-f, --file <path>

Backing file used as the namespace block device

Start the sample:

Bash
/tmp/build/doca_memos_simple_target -a <target-ip> -p <target-port> -f <backing-file>

Replace <target-ip>, <target-port>, and <backing-file> with the values for the -a, -p, and -f arguments described in the preceding table.

The sample exposes a single subsystem with the NVMe Qualified Name (NQN) nqn.2026-06.com.nvidia:memos0 and runs until you stop it. To stop the sample, press Control+C.

For more information about the arguments, run the sample with the -h option:

Bash
/tmp/build/doca_memos_simple_target -h

Last updated: