DOCA programming guide
Examples
- "How do I write my first DOCA program?" — copy a shipped sample
and follow the modify workflow, then the canonical pkg-config + meson
build. Docker / NGC can compile and link; runtime needs a real
BlueField or ConnectX.
- "What's the lifecycle every DOCA object follows?" — create →
configure → start → connect → use → stop → destroy. Configuration
finishes before start.
Instructions
Follow Loading order below. Open the tasks companion for how-to and
the capabilities companion for coverage. Do not open every companion
file.
Where to start: Read ## Audience to confirm the user
is consuming DOCA, not contributing to it. Then jump to the H2
that matches the verb (## modify for first-app derivation,
## build for the canonical build pattern, ## test for the test
loop, ## debug for the program-class debug ladder). Docker / NGC
is the build half, not the runtime half. The NGC container can
compile and link. Flow pipe creation, RDMA QP ops, and any call
that needs a doca_dev on a port need a real BlueField or
ConnectX. Do not promise the app will work entirely inside docker.
Example questions this skill answers well
These are the CLASSES of program-class questions the skill is built
to answer, each with one worked example. Library-specific overlays
(Flow / DMS / Caps / …) live in the matching library skill; this
skill answers the library-agnostic shape.
- "How do I write my first DOCA program for <any library>?" —
worked example: "I have docker; help me build my first DOCA Flow
app." Answered by the modify-a-shipped-sample workflow in
modify plus the canonical build
pattern in ## build. Say that docker
/ NGC builds and links, but runtime needs a real NIC or DPU.
- "What's the right build line for any DOCA library?" — worked
example: "How do I compile a program that calls
doca_rdma_*?"
Answered by the pkg-config doca-<library> pattern inbuild (C/C++ Track 1) and the
FFI/bindings pattern in Track 2.
- "What's the lifecycle every DOCA object follows?" — worked
example: "What's the right order of
doca_flow_pipe_* calls in my
program?" Answered by the Core order create → configure → start →
connect → use → stop → destroy in ## Capabilities and modes
(cfg-create / init implement configure and finish before start).
- "
DOCA_ERROR_* came back — what does it mean and what do I do?"
— worked example: "My code got DOCA_ERROR_BAD_STATE." Answered
by the cross-library doca_error_get_descr() rule inError taxonomy
- the program-class debug order in
debug.
- "My program built and started, but does nothing on the wire." —
worked example: "My Flow program runs cleanly but no traffic is
matched." Answered by the validate-before-commit rule in
Safety policy
and the layered program-class debug ladder indebug.
- "What does <language> consumer of DOCA look like (FFI /
bindings)?" — worked example: "How do I call DOCA Comch from Rust
without writing C?" Answered by Track 2 of
build (FFI against the public C
ABI) and the language-neutral lifecycle inCapabilities and modes.
- "How should I classify and build all the shipped DOCA samples and
applications? What's the difference between a sample and an
application?" — worked example: "I tried to build all DOCA apps
and some failed — which ones are real regressions vs missing
optional stacks?" Answered by the sample-vs-application model and
the category / dependency / skip-vs-fail taxonomy in
sample-and-app-categorization,
which separates "the SDK is broken" from "the optional GPU /
RMAX / MPI stack is not on this BlueField".
If the question is env-class (install / build env / hugepages /
devices), route to doca-setup/SKILL.md. If it is
library-specific (Flow pipe topology, RDMA QP setup, DMS service
deploy), layer the matching library skill on top.
Audience
This skill serves external developers building applications that
consume DOCA libraries — i.e., users whose code calls one or more
doca_<library>_* symbols (directly in C/C++, or through FFI /
bindings from another language). It is programming with DOCA,
not programming of DOCA: it is not for NVIDIA developers
contributing to DOCA itself, and it does not assume access to the
DOCA source tree, internal NVIDIA tooling, or any non-public
information. The only inputs it ever points the agent at are the
ones any external user has: the public docs at
docs.nvidia.com/doca/sdk/,
the public catalog at
catalog.ngc.nvidia.com, the
public GitHub repos under
github.com/NVIDIA /
github.com/NVIDIA-DOCA, the
public developer forum, and the on-disk /opt/mellanox/doca tree
that the public DOCA install (or the public NGC DOCA container,
nvcr.io/nvidia/doca/doca) puts on the user's host. Where to find
and how to install questions are routed elsewhere — see Related
skills below.
Language scope. DOCA itself is a C library family; every shipped
sample in /opt/mellanox/doca/samples/ and every shipped reference
application in /opt/mellanox/doca/applications/ is C. C and C++
consumers are the canonical case for every prescriptive workflow in
this skill. Other-language consumers (Rust, Go, Python, …) consume the
same *.so libraries through FFI or language-specific bindings against
the public C ABI; the skill keeps the lifecycle, capability, error,
observability, and safety guidance language-neutral, and routes the
language-specific build / FFI work back to the consumer's own toolchain
without authoring wrappers.
When to load this skill
Load this skill when the user has DOCA installed and the env-class
preconditions are already satisfied (i.e.,
doca-setup/SKILL.md has produced a clean install
where pkg-config doca-<library> resolves, hugepages are mounted, and
devices are visible), and is now asking a question about how to
actually program against DOCA in a library-agnostic way:
- Understanding what DOCA's pieces are (libraries, apps, services,
tools) and which side of the wire they run on.
- The canonical
pkg-config + meson build pattern any DOCA application
follows, regardless of which library it consumes.
- The universal derive a custom first application from a shipped
sample workflow that every library skill extends with
library-specific overrides — moved here from
doca-setup because it
is a programming verb, not an env verb.
- The universal DOCA Core lifecycle (
create → configure (including permissions and task set_conf) → start → connect → use → stop → destroy) and how it manifests across libraries. Configuration MUST
finish before doca_ctx_start(). Connect is its own step after
start; do not write connect/use as one token.
- The general
DOCA_ERROR_* pattern, doca_error_t, and
doca_error_get_descr() — the cross-library shape, not Flow- or
RDMA-specific overlays.
- The validate-before-commit rule and the program-side safety policy
that every library skill inherits.
- Programming patterns that apply to consumers in any language
(C/C++ directly, FFI / bindings for Rust / Go / Python / …) — the
skill keeps the patterns language-neutral and points the agent at
the public C ABI as the authoritative surface.
Do not load this skill for:
- "Is my install healthy? Why does
pkg-config not find doca-flow?
How do I mount hugepages? I don't have DOCA installed yet — can I
use a container?" — env-class questions belong in
doca-setup/SKILL.md, which owns install
verification, env preparation, env-class debugging, and the
no-install → NGC container fallback path for any user on macOS,
Windows, or Linux without DOCA.
- "What is DOCA? Where is the Flow programming guide? Which package
do I install?" — routing / orientation questions belong in
doca-public-knowledge-map/SKILL.md.
- "How do I construct a Flow pipe / set up an RDMA queue / use Comch
to send a message?" — library-internal API questions belong in the
matching library skill (e.g.
doca-flow/SKILL.md).
What this skill provides
This is a thin loader. The body keeps only the orientation needed
to pick the right next file. The substantive material lives in two
companion files:
- the capabilities companion — what every DOCA program looks like in the
abstract: the shape of DOCA (host / DPU / switch, libraries / apps /
services / tools, build flavor selection rationale), the universal
program lifecycle, the unified version-compat rule that applies to
any program linking DOCA, the cross-library
DOCA_ERROR_* taxonomy,
the program-side observability surface (DOCA logging, capability
snapshots), and the program-side safety policy that every library
skill inherits.
- the tasks companion — step-by-step workflows for the six in-scope programming
verbs:
configure, build, modify, run, test, debug. The
## modify verb owns the universal derive a custom first app from
a sample pattern that every DOCA library skill extends with
library-specific overrides; the ## build verb owns the canonical
pkg-config doca-<library> build pattern in two language tracks
(C/C++ direct, non-C via FFI).
This skill assumes doca-setup/SKILL.md has already
produced a clean install. It does not cover env preparation; that
is doca-setup's job, including the no-install → NGC container
(nvcr.io/nvidia/doca/doca) fallback for users on macOS, Windows, or
Linux without DOCA.
What this skill deliberately does not ship
This skill is agent guidance, not a samples or templates bundle.
It deliberately does not contain — and pull requests should not add:
- Pre-written DOCA application source code, in any language. This
includes C / C++ files, Rust crates, Go packages, Python modules,
and wrapper code for any other language. The DOCA API surface
evolves between releases and code written from documentation prose
cannot be verified without compiling / linking / FFI-loading it
against the live library on a real install. The verified DOCA
application source code is the shipped C samples on the user's
installed system; the agent's job is to route the user to that file
and prescribe a minimum-diff modification on it
(## modify) — for C/C++ users — or to
route non-C users to the public C ABI surface that their bindings
will call (## build Track 2), not to
author the wrapper.
- Standalone build manifests (
meson.build, CMakeLists.txt,
Cargo.toml, setup.py, go.mod, …) parked inside the skill. The
agent constructs the build manifest in the user's project
directory against the user's installed DOCA, where pkg-config --modversion doca-<library> is the source of truth.
- A
samples/, bindings/, or reference/ subtree of any kind.
A mock or incomplete artifact in this skill's tree, even one
labeled "reference", is misleading: users will read it as
buildable.
Loading order
- Read this skill first to confirm the user's question is a
programming-class question (not env, not routing, not library-API).
- For the DOCA shape, the universal lifecycle, the cross-library
error taxonomy, the program-side observability surface, and the
safety policy that every library skill inherits, see
the capabilities companion.
- For step-by-step programming workflows —
configure, build,
modify, run, test, debug — see the tasks companion.
If the user is asking for a first app in a specific library, walk
through ## modify for the universal
copy-and-edit pattern, then hand off to the library skill (e.g.
doca-flow/SKILL.md) for the library-specific values
to swap.
Related skills
doca-public-knowledge-map/SKILL.md
— public DOCA documentation routing and the on-disk layout of an
installed DOCA package. This skill defers all "where is X
documented", "where on disk is Y", and "how do I check the
installed version" questions to the knowledge-map.
doca-setup/SKILL.md — env preparation, install
verification, env-class debugging, and the I have no install yet
procedure with the NGC container (nvcr.io/nvidia/doca/doca) as
the universal Stage-1 fallback for any user on macOS, Windows, or
Linux without DOCA. This skill assumes doca-setup's preconditions
are already satisfied.
doca-flow/SKILL.md — DOCA Flow on BlueField.
Extends this skill's ## modify (universal first-app derivation)
with the Flow-specific list of fields to swap.
doca-container-deployment/SKILL.md
— shipping an application that already builds: container manifests,
rollout, and service-readiness verification. This skill ends once the
program compiles and runs locally; it does not cover deploying it.
1---2license: Apache-2.03name: doca-programming-guide4description: >5 Use this skill when the user is writing their first DOCA app or asking6 a library-agnostic programming question — picking a shipped sample to7 copy and modify, wiring pkg-config + meson (or FFI from Rust / Go /8 Python against the public C ABI), walking the Core lifecycle (create →9 configure → start → connect → use → stop → destroy), or decoding a10 DOCA_ERROR_*. Trigger on implicit phrasing: "write my first DOCA11 program", "meson line for doca_rdma_*", "DOCA_ERROR_BAD_STATE on first12 call", "call DOCA from Rust", "built clean but nothing on the wire".13 Refuse install / hugepages / pkg-config (doca-setup), docs or version14 lookup (doca-public-knowledge-map), and library-internal API work15 (matching library skill).16metadata:17 source: https://skillmd.com/skills/nvidia/doca-programming-guide18 author: NVIDIA <doca-feedback@nvidia.com>19 kind: library20 doca_version: "3.5"21 tags:22 - doca23 - programming24 - first-app25compatibility: >26 No DOCA install required to read this skill (it is an overlay27 loaded against any DOCA artifact skill); the validation steps28 within DO require a live DOCA install at /opt/mellanox/doca.29---3031# DOCA programming guide3233## Examples3435- **"How do I write my first DOCA program?"** — copy a shipped sample36 and follow the modify workflow, then the canonical pkg-config + meson37 build. Docker / NGC can compile and link; runtime needs a real38 BlueField or ConnectX.39- **"What's the lifecycle every DOCA object follows?"** — create →40 configure → start → connect → use → stop → destroy. Configuration41 finishes before start.4243## Instructions4445Follow Loading order below. Open the tasks companion for how-to and46the capabilities companion for coverage. Do not open every companion47file.4849**Where to start:** Read [`## Audience`](#audience) to confirm the user50is *consuming* DOCA, not *contributing* to it. Then jump to the H251that matches the verb (`## modify` for first-app derivation,52`## build` for the canonical build pattern, `## test` for the test53loop, `## debug` for the program-class debug ladder). **Docker / NGC54is the build half, not the runtime half.** The NGC container can55compile and link. Flow pipe creation, RDMA QP ops, and any call56that needs a `doca_dev` on a port need a real BlueField or57ConnectX. Do not promise the app will work entirely inside docker.5859## Example questions this skill answers well6061These are the CLASSES of program-class questions the skill is built62to answer, each with one worked example. Library-specific overlays63(Flow / DMS / Caps / …) live in the matching library skill; this64skill answers the library-agnostic shape.6566- **"How do I write my first DOCA program for <any library>?"** —67 worked example: *"I have docker; help me build my first DOCA Flow68 app."* Answered by the modify-a-shipped-sample workflow in69 ## modify plus the canonical build70 pattern in ## build. Say that docker71 / NGC builds and links, but runtime needs a real NIC or DPU.72- **"What's the right build line for any DOCA library?"** — worked73 example: *"How do I compile a program that calls `doca_rdma_*`?"*74 Answered by the `pkg-config doca-<library>` pattern in75 ## build (C/C++ Track 1) and the76 FFI/bindings pattern in Track 2.77- **"What's the lifecycle every DOCA object follows?"** — worked78 example: *"What's the right order of `doca_flow_pipe_*` calls in my79 program?"* Answered by the Core order create → configure → start →80 connect → use → stop → destroy in ## Capabilities and modes81 (`cfg-create` / `init` implement configure and finish before start).82- **"`DOCA_ERROR_*` came back — what does it mean and what do I do?"**83 — worked example: *"My code got `DOCA_ERROR_BAD_STATE`."* Answered84 by the cross-library `doca_error_get_descr()` rule in85 ## Error taxonomy86 + the program-class debug order in87 ## debug.88- **"My program built and started, but does nothing on the wire."** —89 worked example: *"My Flow program runs cleanly but no traffic is90 matched."* Answered by the validate-before-commit rule in91 ## Safety policy92 and the layered program-class debug ladder in93 ## debug.94- **"What does <language> consumer of DOCA look like (FFI /95 bindings)?"** — worked example: *"How do I call DOCA Comch from Rust96 without writing C?"* Answered by Track 2 of97 ## build (FFI against the public C98 ABI) and the language-neutral lifecycle in99 ## Capabilities and modes.100- **"How should I classify and build all the shipped DOCA samples and101 applications? What's the difference between a sample and an102 application?"** — worked example: *"I tried to build all DOCA apps103 and some failed — which ones are real regressions vs missing104 optional stacks?"* Answered by the sample-vs-application model and105 the category / dependency / skip-vs-fail taxonomy in106 ## sample-and-app-categorization,107 which separates *"the SDK is broken"* from *"the optional GPU /108 RMAX / MPI stack is not on this BlueField"*.109110If the question is env-class (install / build env / hugepages /111devices), route to `doca-setup/SKILL.md`. If it is112library-specific (Flow pipe topology, RDMA QP setup, DMS service113deploy), layer the matching library skill on top.114115## Audience116117This skill serves **external developers building applications that118*consume* DOCA libraries** — i.e., users whose code calls one or more119`doca_<library>_*` symbols (directly in C/C++, or through FFI /120bindings from another language). It is *programming **with** DOCA*,121not *programming **of** DOCA*: it is *not* for NVIDIA developers122contributing to DOCA itself, and it does *not* assume access to the123DOCA source tree, internal NVIDIA tooling, or any non-public124information. The only inputs it ever points the agent at are the125ones any external user has: the public docs at126[`docs.nvidia.com/doca/sdk/`](https://docs.nvidia.com/doca/sdk/),127the public catalog at128[`catalog.ngc.nvidia.com`](https://catalog.ngc.nvidia.com/), the129public GitHub repos under130[`github.com/NVIDIA`](https://github.com/NVIDIA) /131[`github.com/NVIDIA-DOCA`](https://github.com/NVIDIA-DOCA), the132public developer forum, and the on-disk `/opt/mellanox/doca` tree133that the public DOCA install (or the public NGC DOCA container,134`nvcr.io/nvidia/doca/doca`) puts on the user's host. *Where to find*135and *how to install* questions are routed elsewhere — see *Related136skills* below.137138**Language scope.** DOCA itself is a C library family; every shipped139sample in `/opt/mellanox/doca/samples/` and every shipped reference140application in `/opt/mellanox/doca/applications/` is C. C and C++141consumers are the canonical case for every prescriptive workflow in142this skill. Other-language consumers (Rust, Go, Python, …) consume the143same `*.so` libraries through FFI or language-specific bindings against144the public C ABI; the skill keeps the lifecycle, capability, error,145observability, and safety guidance language-neutral, and routes the146language-specific build / FFI work back to the consumer's own toolchain147without authoring wrappers.148149## When to load this skill150151Load this skill when the user has DOCA installed *and* the env-class152preconditions are already satisfied (i.e.,153`doca-setup/SKILL.md` has produced a clean install154where `pkg-config doca-<library>` resolves, hugepages are mounted, and155devices are visible), and is now asking a question about **how to156actually program against DOCA** in a library-agnostic way:157158- Understanding what DOCA's pieces are (libraries, apps, services,159 tools) and which side of the wire they run on.160- The canonical `pkg-config` + meson build pattern any DOCA application161 follows, regardless of which library it consumes.162- The universal *derive a custom first application from a shipped163 sample* workflow that every library skill extends with164 library-specific overrides — moved here from `doca-setup` because it165 is a programming verb, not an env verb.166- The universal DOCA Core lifecycle (`create → configure (including167 permissions and task `set_conf`) → start → connect → use → stop →168 destroy`) and how it manifests across libraries. Configuration MUST169 finish before `doca_ctx_start()`. Connect is its own step after170 start; do not write `connect/use` as one token.171- The general `DOCA_ERROR_*` pattern, `doca_error_t`, and172 `doca_error_get_descr()` — the cross-library shape, not Flow- or173 RDMA-specific overlays.174- The validate-before-commit rule and the program-side safety policy175 that every library skill inherits.176- Programming patterns that apply to consumers in *any* language177 (C/C++ directly, FFI / bindings for Rust / Go / Python / …) — the178 skill keeps the patterns language-neutral and points the agent at179 the public C ABI as the authoritative surface.180181Do **not** load this skill for:182183- *"Is my install healthy? Why does `pkg-config` not find `doca-flow`?184 How do I mount hugepages? I don't have DOCA installed yet — can I185 use a container?"* — env-class questions belong in186 `doca-setup/SKILL.md`, which owns install187 verification, env preparation, env-class debugging, and the188 *no-install → NGC container fallback* path for any user on macOS,189 Windows, or Linux without DOCA.190- *"What is DOCA? Where is the Flow programming guide? Which package191 do I install?"* — routing / orientation questions belong in192 `doca-public-knowledge-map/SKILL.md`.193- *"How do I construct a Flow pipe / set up an RDMA queue / use Comch194 to send a message?"* — library-internal API questions belong in the195 matching library skill (e.g.196 `doca-flow/SKILL.md`).197198## What this skill provides199200This is a **thin loader**. The body keeps only the orientation needed201to pick the right next file. The substantive material lives in two202companion files:203204- the capabilities companion — what every DOCA program looks like in the205 abstract: the shape of DOCA (host / DPU / switch, libraries / apps /206 services / tools, build flavor selection rationale), the universal207 program lifecycle, the unified version-compat rule that applies to208 any program linking DOCA, the cross-library `DOCA_ERROR_*` taxonomy,209 the program-side observability surface (DOCA logging, capability210 snapshots), and the program-side safety policy that every library211 skill inherits.212- the tasks companion — step-by-step workflows for the six in-scope programming213 verbs: `configure`, `build`, `modify`, `run`, `test`, `debug`. The214 `## modify` verb owns the universal *derive a custom first app from215 a sample* pattern that every DOCA library skill extends with216 library-specific overrides; the `## build` verb owns the canonical217 `pkg-config doca-<library>` build pattern in two language tracks218 (C/C++ direct, non-C via FFI).219220This skill assumes `doca-setup/SKILL.md` has already221produced a clean install. It does **not** cover env preparation; that222is `doca-setup`'s job, including the *no-install → NGC container223(`nvcr.io/nvidia/doca/doca`)* fallback for users on macOS, Windows, or224Linux without DOCA.225226## What this skill deliberately does not ship227228This skill is **agent guidance**, not a samples or templates bundle.229It deliberately does not contain — and pull requests should not add:230231- **Pre-written DOCA application source code, in any language.** This232 includes C / C++ files, Rust crates, Go packages, Python modules,233 and wrapper code for any other language. The DOCA API surface234 evolves between releases and code written from documentation prose235 cannot be verified without compiling / linking / FFI-loading it236 against the live library on a real install. The verified DOCA237 application source code is the shipped C samples on the user's238 installed system; the agent's job is to route the user to that file239 and prescribe a minimum-diff modification on it240 (## modify) — for C/C++ users — or to241 route non-C users to the public C ABI surface that their bindings242 will call (## build Track 2), *not* to243 author the wrapper.244- **Standalone build manifests** (`meson.build`, `CMakeLists.txt`,245 `Cargo.toml`, `setup.py`, `go.mod`, …) parked inside the skill. The246 agent constructs the build manifest *in the user's project247 directory* against the user's installed DOCA, where `pkg-config248 --modversion doca-<library>` is the source of truth.249- **A `samples/`, `bindings/`, or `reference/` subtree** of any kind.250 A mock or incomplete artifact in this skill's tree, even one251 labeled "reference", is misleading: users will read it as252 buildable.253254## Loading order2552561. Read this skill first to confirm the user's question is a257 programming-class question (not env, not routing, not library-API).2582. **For the DOCA shape, the universal lifecycle, the cross-library259 error taxonomy, the program-side observability surface, and the260 safety policy that every library skill inherits, see261 the capabilities companion.**2623. **For step-by-step programming workflows — `configure`, `build`,263 `modify`, `run`, `test`, `debug` — see the tasks companion.**264265If the user is asking for a *first app* in a specific library, walk266through ## modify for the universal267copy-and-edit pattern, then hand off to the library skill (e.g.268`doca-flow/SKILL.md`) for the library-specific values269to swap.270271## Related skills272273- `doca-public-knowledge-map/SKILL.md`274 — public DOCA documentation routing and the on-disk layout of an275 installed DOCA package. This skill defers all *"where is X276 documented"*, *"where on disk is Y"*, and *"how do I check the277 installed version"* questions to the knowledge-map.278- `doca-setup/SKILL.md` — env preparation, install279 verification, env-class debugging, and the *I have no install yet*280 procedure with the NGC container (`nvcr.io/nvidia/doca/doca`) as281 the universal Stage-1 fallback for any user on macOS, Windows, or282 Linux without DOCA. This skill assumes `doca-setup`'s preconditions283 are already satisfied.284- `doca-flow/SKILL.md` — DOCA Flow on BlueField.285 Extends this skill's `## modify` (universal first-app derivation)286 with the Flow-specific list of fields to swap.287- `doca-container-deployment/SKILL.md`288 — shipping an application that already builds: container manifests,289 rollout, and service-readiness verification. This skill ends once the290 program compiles and runs locally; it does not cover deploying it.