Doca Pcc Counters
NVIDIAOfficialCreated by NVIDIA
- Skill
- Tool integration
- Software development
- Apache-2.0
- Medium risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides instructions for using the pcc_counters.sh bash script, a tool included in the DOCA suite for monitoring Programmable Congestion Control (PCC) diagnostic counters. It enables operators and developers to arm and query fixed firmware and hardware counters, such as CNP counts, RTT performance, and WRED drops, on ConnectX or BlueField devices. The skill covers the required set-then-query workflow, troubleshooting common errors like Bad Device, and understanding the interaction with the mlx5 debugfs interface.
What it does
- Arms PCC diagnostic counters using the set operation.
- Queries and displays current counter values using the query operation.
- Resolves mst device paths for interaction with the mlx5 debugfs interface.
- Provides diagnostic steps for common script errors like Bad Device or zeroed counters.
- Identifies the fixed set of firmware and hardware counters available for monitoring.
When to use it
- When you need to verify if congestion control events like CNPs or WRED drops are occurring on a port.
- When you need to capture a snapshot of device-level PCC counters for performance investigation.
- When the pcc_counters.sh script returns errors and requires troubleshooting.
- When you need to confirm if the device is correctly armed for diagnostic data collection.
Advantages
- Provides a standardized workflow for accessing low-level firmware diagnostic data.
- Clearly separates diagnostic readout from custom congestion control algorithm development.
- Offers a structured approach to troubleshooting device-level counter issues.
- Ensures consistent usage of the two-positional-argument contract for the script.
Usage examples
- “How do I read the CNP and RTT counters on my device?”
- The agent will guide you to run the set command followed by the query command on your specific mst device path to output the current counter values.
- “The script says ERROR: Bad Device when I try to run it.”
- The agent will help you verify the correct mst device path and ensure the device is properly recognized by the system before re-running the command.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/nvidia/doca-pcc-counters/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip doca-pcc-counters.zip -d .agents/skills
Documentation by NVIDIA
DOCA PCC Counters (pcc_counters.sh)
Examples
"How do I read the PCC diagnostic counters on this device?" — this is in scope. Arm then query; do not treat this as PCC algorithm tuning.
"The script printed ERROR: Bad Device." — resolve the mst path before assuming firmware is broken.
Instructions
Follow Loading order below. Open the tasks companion for run / debug. Open the capabilities companion for the fixed counter set. Do not open every companion file.
Where to start: This is a tool skill for invoking
pcc_counters.sh — a small bash script that arms and reads the
device's fixed set of firmware / hardware PCC diagnostic
counters (CNP count, RTT-perf, WRED-drop, RTT-gen, handled
events) through the mlx5 debugfs diag_cnt interface. Open
the tasks companion and start at ## run for
the canonical set-then-query sequence, or
## debug when the user reports
"ERROR: Bad Device", "counter stuck at zero", or "the
dump is empty". Open the capabilities companion when
the question is which counters the script reports and how it
reaches them. If the user has not installed DOCA / MFT yet,
route to doca-setup/SKILL.md first.
This skill is the firmware / HW PCC counter readout surface.
It is NOT the host-side control library that loads custom
congestion-control kernels onto the DPA (that is
doca-pcc/SKILL.md) and it is NOT the
firmware PCC algorithm configuration (that path is firmware
configuration, routed via
doca-public-knowledge-map/SKILL.md).
The counters this script reads are device / firmware
diagnostic counters that exist regardless of whether a custom
doca-pcc DPA kernel is running — do not condition them on a
custom kernel being loaded.
Example questions this skill answers well
The CLASSES of pcc_counters.sh questions this skill is built
to answer, each with one worked example. The class is the
load-bearing piece; the worked example is one instance.
"How do I read the PCC diagnostic counters on this device?" — worked example: "arm and dump the CNP / RTT / WRED-drop counters for
/dev/mst/mt41692_pciconf0". Answered by the fixed counter set in the capabilities companionthe
set-then-queryinvocation in the tasks companion.
"What is the smallest legal invocation?" — worked example: "what exactly do I type?". Answered by the two-positional-argument contract (
set | query+ an mst device path) in the tasks companion."The script printed
ERROR: Bad Device— what's wrong?" — worked example: "my device path is not matching". Answered by the device-resolution layer in the capabilities companionthe tasks companion.
"A counter is stuck at zero — is the device idle, the counters not armed, or genuinely no events?" — worked example: "
PCC_CNP_COUNTreads 0 afterquery". Answered by the arm-before-read rule and the layered diagnosis in the tasks companion + the capabilities companion."Is this script on my install, and where?" — worked example: "is
pcc_counters.shpresent and where does the install put it". Answered by the install overlay in the capabilities companion, which redirects to the canonicaldoca-version/SKILL.mdrules.
Audience
This skill serves operators, developers, and AI agents who need to read a ConnectX / BlueField device's firmware PCC diagnostic counters to reason about congestion-control behaviour (CNP generation, RTT requests/responses, WRED drops) on a port. Concretely:
A network operator confirming whether congestion-control events (CNPs, RTT, WRED drops) are occurring on a device.
A developer correlating a custom
doca-pccalgorithm's effect with the device-level PCC diagnostic counters (the script reads the firmware counters; the custom algorithm itself is a separate surface owned bydoca-pcc/SKILL.md).An AI agent producing a PCC counter snapshot as evidence for a congestion-control investigation.
It is not for users debugging the script's bash itself,
not the place to learn how to write a custom PCC
algorithm — that audience belongs in
doca-pcc/SKILL.md — and not the
place for users who want to configure the factory firmware PCC
algorithm (route via
doca-public-knowledge-map/SKILL.md).
pcc_counters.sh is shipped as a plain bash script
installed under the DOCA tools directory, not a compiled binary and
not a library you link against. The skill uses the bundle's
kind: tool three-file shape (this skill + the capabilities companion
the tasks companion) so the agent's task-verb contract (
configure / build / modify / run / test / debug) is uniform across the bundle.
When to load this skill
Load this skill when the user is — or the agent needs to — arm and read the device PCC diagnostic counters on a host or BlueField Arm with the mst tools available and debugfs mounted. Concretely:
Arming the diagnostic counters with
seton a target mst device.Reading the armed counters with
queryand quoting the named counter lines verbatim.Capturing a counter readout as evidence for a congestion-control investigation.
Do not load this skill for general DOCA orientation,
custom-PCC algorithm design, the host-side doca-pcc library
API, the factory firmware PCC algorithm, or DOCA / MFT install.
For those, route to
doca-public-knowledge-map/SKILL.md,
doca-pcc/SKILL.md, or
doca-setup/SKILL.md.
What this skill provides
This is a thin loader. Substantive material lives in two companion files:
the capabilities companion — what
pcc_counters.shdoes: the exact two-operation surface (setarms the device's diagnostic counters by writing counter IDs + params to debugfs;queryreads thediag_cnt/dumpand prints the named counters), the FIXED firmware / HW counter set it knows (PCC_CNP_COUNT, theMAD_RTT_PERF_CONT_*, the*_EVENT_WRED_DROPfamily,HANDLED_*_EVENTS, theDROP_RTT_PORT*/RTT_GEN_PORT*families), how it resolves an mst device to a PCI address (mst status -v+lspci) and reaches/sys/kernel/debug/mlx5/<pci>/diag_cnt/, the install-availability overlay that redirects todoca-version/SKILL.md, the layered error taxonomy (script-not-present / bad-device / not-armed-before-query / debugfs-or-permission / counter-stuck-at-zero / cross-cutting), and the safety policy that flagssetas a privileged debugfs write and any CC tuning decision derived from a reading as high-stakes.the tasks companion — step-by-step workflows for the in-scope task verbs:
configure(route to install + confirm mst / debugfs / sudo),build(route to install; nothing to compile — it is a script),modify(refuse — do not patch the shipped script),run(theset-then-querysequence),test(confirm the dump contains the named counters with finite values),debug(the layered diagnosis ladder), plus aDeferred task verbsblock and aCommand appendix.
The skill assumes a host or BlueField where DOCA / MFT is
already installed (mst tools present, debugfs mounted, sudo
available) and the target device is visible to mst status -v.
What this skill deliberately does not ship
This skill is agent guidance, not a samples or scripts bundle. To keep the boundary clean, it deliberately does not contain — and pull requests should not add:
Invented flags or subcommands.
pcc_counters.shhas exactly two operations (set,query), takes exactly two positional arguments, and has NO--help,--version,list,snapshot,watch, ordiff. Do not invent any.Pre-baked example counter values. Counter values are device-, firmware-, and traffic-state-specific; a captured value will mislead an operator on a different device.
Wrappers, parsers, or rewritten copies of the script. The script is the contract; modifying or re-implementing it is out of scope.
A specific congestion-control tuning recommendation derived from a counter reading. That is a high-stakes domain question — the skill prescribes how to capture the counters; it refuses to translate a delta into a CC parameter change without the user's own domain analysis.
A
samples/orreference/subtree. This is a thin loader for a documented script; substantive material lives in the script and the public PCC documentation.
Loading order
Read this skill first to confirm the user's question is in scope (reading the device's firmware PCC diagnostic counters; not designing or loading a custom algorithm).
For what the script does, the fixed counter set, the debugfs mechanism, the install-availability overlay, the layered error surface, and the safety posture, see the capabilities companion.
For the documented invocations —
configure,build,modify,run,test,debug, plus theCommand appendix— see the tasks companion.
Related skills
doca-pcc/SKILL.md— the host-side library for writing and loading custom congestion-control kernels onto the DPA. It is a SEPARATE surface: the firmware PCC diagnostic counterspcc_counters.shreads exist independently of any customdoca-pcckernel, but an operator tuning a custom algorithm may read these counters to observe device-level CC behaviour. Conflating the script (firmware counter readout) with the library (custom algorithm load/control) is the most common PCC first-touch error.doca-public-knowledge-map/SKILL.md— routing to the public DOCA / PCC documentation set, including the firmware PCC algorithm configuration.doca-version/SKILL.md— canonical DOCA version-handling rules. The## Version compatibilitysection in the capabilities companion is a concise overlay that redirects here.doca-setup/SKILL.md— env preparation, install verification, mst tools, debugfs, and the I have no install yet path with the public NGC DOCA container. This skill assumes its preconditions are satisfied.doca-debug/SKILL.md— the cross-cutting debug ladder. The PCC counter readout slots in as a read-only device-state evidence source before any congestion-control tuning recommendation is made.doca-programming-guide/SKILL.md— general DOCA programming patterns shared across the bundle.
Files
- ATTRIBUTION.mdAdded by AutoGineer909 B
- BENCHMARK.md9.9 KiB
- CAPABILITIES.md13.1 KiB
- LICENSELicence file added by AutoGineer11.2 KiB
- SKILL.md11.7 KiB
- SKILLCARD.yaml2.8 KiB
- TASKS.md13.6 KiB
- evals/evals.json2.4 KiB
- skill-card.md5.2 KiB
- skill.oms.sig5.1 KiB
CAPABILITIES.md
DOCA PCC Counters (pcc_counters.sh) — Capabilities
Where to start: pcc_counters.sh is a small bash script
with exactly two operations — set (arm the device's PCC
diagnostic counters) and query (read and print them). The
pattern overview below names the recurring questions. Pick the
pattern first, then drill into the H2 that owns the substance.
For the how of executing each pattern, jump to
TASKS.md.
This file is loaded by SKILL.md. It documents
what the script does, the fixed firmware / HW counter set it
reports, how it reaches the counters through mst + debugfs,
what install / environment it needs, the layered error
surface, and the safety posture that flags the set
operation as a privileged debugfs write and any CC tuning
decision derived from a reading as high-stakes.
Pattern overview
Every pcc_counters.sh question this skill teaches resolves
into one of FOUR patterns. The patterns are CLASSES — they
apply across every device the script can address.
| Pattern | Class shape | Where the substance lives |
|---|---|---|
| 1. Arm the diagnostic counters | Run set <mst-device> to program which counters the device collects (writes the fixed counter-ID list + params to diag_cnt); this MUST happen before a meaningful query | ## Capabilities and modes set row + TASKS.md ## run step 2 |
| 2. Read the counters | Run query <mst-device> to read diag_cnt/dump and print the named counters with their values | ## Capabilities and modes query row + TASKS.md ## run step 3 |
| 3. Resolve the device | The single positional device argument is an mst path (e.g. /dev/mst/mt41692_pciconf0); the script maps it to a PCI address via mst status -v + lspci before touching debugfs | ## Capabilities and modes device-resolution row + ## Error taxonomy layer 2 |
| 4. Diagnose missing / silent output | Map symptom (ERROR: Bad Device, Bad Request, empty dump, counter pinned at zero, permission/debugfs error) to the right layer | ## Error taxonomy + TASKS.md ## debug |
Two cross-cutting rules that apply to every pattern above:
setarms,queryreads — in that order.querywithout a priorsetreads whatever the device'sdiag_cntwas last configured for (possibly nothing). The documented sequence in the script's own header comment is “alwayssetfirst thenquery”.These are firmware / HW diagnostic counters. They exist at the device level and are INDEPENDENT of any custom
doca-pccDPA kernel. Do not condition a reading on a custom kernel being loaded, and do not attribute a counter value to a custom algorithm without independent evidence.
Capabilities and modes
pcc_counters.sh is a bash script installed under the
DOCA tools directory on a standard install. There is no daemon, no library to
link against, no --help, no --version, and no subcommands
beyond the two operations below. The entire interaction model
is run the script with two positional arguments, read the
printed output.
The two operations — exact contract.
| Operation | Positional form | What it does |
|---|---|---|
set | sudo ./pcc_counters.sh set <mst-device> | Resolves the device to a PCI address, then writes the fixed counter-ID list and the sampling params to /sys/kernel/debug/mlx5/<pci>/diag_cnt/counter_id and /diag_cnt/params, and writes set to /diag_cnt/dump. This ARMS the device's diagnostic counter collection. It is a privileged debugfs write. |
query | sudo ./pcc_counters.sh query <mst-device> | Resolves the device to a PCI address, reads /sys/kernel/debug/mlx5/<pci>/diag_cnt/dump, and prints each known counter as Counter: <NAME> Value: <n>. |
Any first argument other than set or query makes the
script print Bad Request: choose 'set' or 'query'. A device
the script cannot resolve via mst status -v makes it print
ERROR: Bad Device and exit.
Device argument. The second positional argument is an
mst device path as shown by sudo mst status -v (e.g.
/dev/mst/mt41692_pciconf0). The script greps mst status -v
for that device to obtain the bus address, then resolves it to
a domain PCI address via lspci -D (filtering for
Mellanox / NVIDIA) to build the
/sys/kernel/debug/mlx5/<pci>/diag_cnt/ path.
The fixed counter set. Unlike a custom-kernel surface, the
counters are a FIXED list baked into the script's query
case-statement (firmware / HW PCC diagnostic counters). The
agent may name these because they are constant in the source:
| Counter | Meaning (class) |
|---|---|
PCC_CNP_COUNT | Congestion Notification Packets counted |
MAD_RTT_PERF_CONT_REQ | RTT-perf continuous request counter |
MAD_RTT_PERF_CONT_RES | RTT-perf continuous response counter |
SX_EVENT_WRED_DROP | WRED drops on SX events |
SX_RTT_EVENT_WRED_DROP | WRED drops on SX RTT events |
ACK_EVENT_WRED_DROP | WRED drops on ACK events |
NACK_EVENT_WRED_DROP | WRED drops on NACK events |
CNP_EVENT_WRED_DROP | WRED drops on CNP events |
RTT_EVENT_WRED_DROP | WRED drops on RTT events |
HANDLED_SXW_EVENTS | Handled SXW events |
HANDLED_RXT_EVENTS | Handled RXT events |
DROP_RTT_PORT0_REQ / DROP_RTT_PORT1_REQ | Dropped RTT requests, port 0 / 1 |
DROP_RTT_PORT0_RES / DROP_RTT_PORT1_RES | Dropped RTT responses, port 0 / 1 |
RTT_GEN_PORT0_REQ / RTT_GEN_PORT1_REQ | Generated RTT requests, port 0 / 1 |
RTT_GEN_PORT0_RES / RTT_GEN_PORT1_RES | Generated RTT responses, port 0 / 1 |
The script reads these via the mlx5 diag_cnt debugfs
interface; the set is not user-extensible without editing the
script (which this skill forbids — see
SKILL.md ## What this skill deliberately does not ship).
Version compatibility
For the canonical DOCA version-detection chain and NGC
container semantics, see
doca-version/SKILL.md. The body lives
there; this skill does not duplicate it.
The pcc_counters.sh-specific overlay is:
Confirm the script is present before assuming availability. It is installed under the DOCA tools directory on a standard install. If the script is absent, route to
doca-setup/SKILL.md; do NOT re-implement the script or quote counter values from memory.mst / MFT and debugfs are the real preconditions. The script depends on
mst status -vresolving the device and on/sys/kernel/debug/mlx5/<pci>/diag_cnt/being present (debugfs mounted, mlx5 driver loaded). These are environment facts, not DOCA-version facts; confirm them perdoca-setup/SKILL.md.The counter set is fixed in the script. Counter names do not vary by flag or version at the script level — they are the constant case-statement above. What CAN vary is whether the underlying firmware / driver exposes the
diag_cntinterface for a given device generation; confirm on the user's device rather than assuming.
Error taxonomy
The error layers the agent should distinguish, in escalating order:
Script-not-present.
pcc_counters.shis not under the DOCA tools directory. Cause: DOCA / MFT not installed, or an install that did not include it. Routing:doca-setup ## configure(doca-setup/TASKS.md#configure).Bad-device. The script prints
ERROR: Bad Device. Cause: the mst device path does not match an entry insudo mst status -v(wrong path, mst service not started, device not present). Fix: runsudo mst startthensudo mst status -vand use the exact device path it lists.Bad-request. The script prints
Bad Request: choose 'set' or 'query'. Cause: the first positional argument was something other thansetorquery(e.g. a guessedlist/snapshot/--help). Fix: use exactlysetorquery.Not-armed-before-query.
queryruns but the values are stale / zero becausesetwas never run for this device (or the device'sdiag_cntwas reconfigured by something else). Fix: runsetfirst, thenquery, per the script's documented order, once. If the same condition recurs after that single recovery, stop; preserve both captures and escalate to layer 7 to identify the external process reconfiguringdiag_cnt. Do not repeat privileged arm/read cycles.Debugfs-or-permission. The script cannot read/write
/sys/kernel/debug/mlx5/<pci>/diag_cnt/. Cause: not running as root / sudo, debugfs not mounted, or the mlx5 driver does not exposediag_cntfor this device. Fix: run under sudo, confirmmount | grep debugfs, confirm the mlx5 driver is loaded. Route env-side issues todoca-setup ## debug(doca-setup/TASKS.md#debug).Counter-stuck-at-zero. The script runs, the dump prints, but a counter reads 0. Cause is usually correct behaviour — the device genuinely saw no such events (no congestion, no RTT, no drops) — NOT a tool bug. Confirm there is relevant traffic before treating a zero as a finding.
Cross-cutting. Script runs cleanly, counters are readable, but the user's question is really about the custom
doca-pccalgorithm, firmware PCC configuration, BlueField mode, or driver / firmware behaviour. Route todoca-pcc/SKILL.md,doca-public-knowledge-map/SKILL.md, ordoca-debug TASKS.md ## debug(doca-debug/TASKS.md#debug).
Observability
pcc_counters.sh IS an observability primitive — it is the
documented way to read the device's firmware PCC diagnostic
counters from the command line. Its only output is the printed
Counter: <NAME> Value: <n> lines on stdout; it emits no
metrics, traces, or DOCA logs of its own.
Save the full
queryoutput (file or paste buffer) when capturing evidence; quote the counter lines verbatim rather than paraphrasing.For a before / after comparison, the agent runs
setonce, thenquerybefore the change andqueryafter, and diffs the two captured outputs with standard text tooling (the script has no built-in diff).For the custom-algorithm host-side report stream (a separate surface), see
doca-pcc CAPABILITIES.md ## Observability(doca-pcc/CAPABILITIES.md#observability).
Safety policy
Overlay on the bundle-wide hardware-safety meta-policy. The rules below are this skill's per-artifact overlay on the cross-cutting rules in
doca-hardware-safetyCAPABILITIES.md ## Safety policy (doca-hardware-safety/CAPABILITIES.md#safety-policy) (specifically ### Per-artifact overlay pattern (doca-hardware-safety/CAPABILITIES.md#per-artifact-overlay-pattern)). When the two layers disagree, the stricter wins; when either layer says STOP, the agent stops.
query is read-only; set writes to the device's debugfs
diag_cnt interface to reconfigure which diagnostic counters
are collected. Neither changes dataplane forwarding, but both
require root / sudo, and the downstream decisions an agent
might derive from a reading are high-stakes.
setis a privileged debugfs write. It reprograms the device's diagnostic counter selection. It does not change congestion-control behaviour, but it is a root-level write to a kernel debug interface. Before running it, show the exact resolved mst device and PCI BDF, explain that it reprograms diagnostic-counter selection, and obtain the operator's explicit confirmation. Run it on that one intended device, never speculatively across devices.The script does not mount debugfs or start mst. Those are separate host-state changes. If either prerequisite is absent, stop and route the remediation through
doca-setup; do not perform it implicitly as part of a counter read.The reading is evidence; the tuning decision it informs is high-stakes. A misread counter that drives a congestion-control parameter change can destabilize the RDMA / RoCE fabric for every node on the port. The skill captures counters; it refuses to translate a delta into a CC parameter change without the user's own domain analysis.
Confirm traffic before treating a zero as a finding. A counter at 0 usually means the device saw no such events, not that the tool failed.
Quote what the script printed. Do not paraphrase or reorder the
Counter: ... Value: ...lines; the verbatim output is the artifact downstream debug consumes.Never invent a counter name, flag, or subcommand. The script has exactly
set/query, two positional arguments, and the fixed counter set above; anything beyond that is a hallucination.
Public-source pointer
The canonical public source for device PCC behaviour and the
firmware congestion-control surface is the DOCA / PCC
documentation on docs.nvidia.com, reachable through
doca-public-knowledge-map ## DOCA tools (doca-public-knowledge-map/SKILL.md#doca-tools).
The authoritative source for the script's exact behaviour is
the script itself (/opt/mellanox/doca/tools/pcc_counters.sh) on the
user's install. For the doca-pcc library that loads custom
congestion-control kernels (a separate surface), see
doca-pcc/SKILL.md.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
The author says: Requires DOCA/MFT on Linux with a ConnectX-6 or newer (not ConnectX-8) or BlueField device, mst tools, mounted debugfs, and root access to the mlx5 diag_cnt interface. The script reads fixed firmware and hardware diagnostics independently of custom PCC code. Its set operation changes which counters are collected, not congestion-control or forwarding behavior; treat later fleet tuning as a separate high-stakes action. The validation steps require a live DOCA install.
Security
What our scanner noticed· Medium risk
- Large base64-encoded blobs
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- NVIDIA
- Publisher
- NVIDIA (Official)
- Source
- NVIDIA/skills · skills/doca-pcc-counters · commit fce3cca
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE-APACHE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by NVIDIA.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download doca-pcc-counters.zip