Verbs to URMA Migration Skill#
Version: 1.0 | URMA API Version: 25.12.0
This skill migrates RDMA Verbs (libibverbs) code to URMA (Unified Remote Memory Access) API.
When to Use This Skill#
Trigger this skill in the following situations:
- User mentions "verbs", "libibverbs", "ibv_*" functions
- User mentions "RDMA", "InfiniBand", "RoCE"
- User wants to migrate infiniband code to URMA
- User mentions "urma" and "migration", "conversion", "port", "translate"
- User wants to convert RDMA application to use URMA
Migration Hard Constraints (Applicable Throughout)#
The following constraints apply throughout the entire migration; no phase may violate them:
- Original files are immutable — All output goes to
urma_output/, preserving original directory structure; original files must not be modified
- 4 phases cannot be skipped — Phase 4 catches runtime semantic errors that compilation cannot detect; skipping leads to resource leaks, logic errors, etc.
- System header files are highest authority — API signatures, type definitions use
urma_api.h / urma_types.h as authority; when conflicts with reference documents, use header files
- Structs must be zero-initialized — Use
{0} or {.field = value} for initialization; uninitialized fields cause undefined behavior
- Verification cannot be skipped — Check patterns/pitfalls item by item for each file; FAIL cannot be left behind
- Cannot proceed without header files — Without authoritative API source, Agent will fabricate non-existent functions; must find header files first
URMA vs Verbs Overview#
RDMA Verbs ConceptURMA EquivalentPD (Protection Domain)Implicit in URMAMR (Memory Region)urma_target_seg_t via urma_register_seg()CQ (Completion Queue)urma_jfc_t via urma_create_jfc()QP (Queue Pair)urma_jetty_t or urma_jfs_t + urma_jfr_tSRQ (Shared Receive Queue)urma_jfr_t with share_jfr=1 flagCompletion Channelurma_jfce_t via urma_create_jfce()LID + GIDurma_eid_t (16-byte endpoint ID; LID removed)QPNJPN (Jetty Pair Number)PSNPSN (Packet Sequence Number)
Quick Reference (Full list in mapping.md §1)#
VerbsURMAibv_open_device()``urma_create_context()``ibv_reg_mr()``urma_register_seg()``ibv_create_cq()``urma_create_jfc()``ibv_create_qp()``urma_create_jetty()``ibv_modify_qp(RTR/RTS)``urma_import_jetty() + urma_bind_jetty()``ibv_post_send()``urma_post_jetty_send_wr()
Migration Workflow#
Phase 1: Preparation#
Goal: Understand source code and establish complete API mapping.
Mandatory deliverables (must be produced at phase end):
- Source file classification list: which contain verbs APIs (need conversion), which don't (copy as-is)
- Verbs API list and URMA mapping table: handling method for each API (replace/delete/pending confirmation)
- Transport mode and connection model judgment (RC/RM/UM, import+bind, etc.)
- User confirmation (present above deliverables; can proceed to Phase 2 only after permission)
Must complete (hard constraints during phase):
- System header files (urma_api.h / urma_types.h / urma_opcode.h) found and read as authoritative source
- Common location:
/usr/include/ub/umdk/urma/
- If not found: ask user to install or provide path; do not continue without header files
- Each Verbs API has been looked up in mapping.md for equivalent
- APIs that cannot be mapped have been confirmed for deletion in mapping.md §No URMA Equivalents, or marked as pending confirmation
- URMA complete resource lifecycle understood (refer to patterns.md §1)
Reference consultation path (recommended, not mandatory):
- patterns.md §1 → understand URMA complete lifecycle
- mapping.md → look up mapping item by item
- pitfalls.md → understand common error overview
Phase 2: Conversion#
Goal: Create converted code in urma_output/ directory; original files remain unchanged.
Mandatory deliverables (must be produced at phase end):
urma_output/ directory containing all converted files, preserving original directory structure
- Verification results for each file (see verification requirements)
- Mapping item execution traceability for each file (see mapping traceability)
- Project-level mapping traceability summary (see mapping traceability)
- Build config updated
Conversion constraints (must be satisfied):
- All converted code goes to
urma_output/; original files must not be modified
- Header type definition changes must be consistent with all source files referencing it
- Build files (Makefile) updated after all code files are converted
- Files with most Verbs APIs should be converted first to discover mapping issues early
Each file's conversion content:
#include <infiniband/verbs.h> → #include <ub/umdk/urma/urma_api.h>
- Verbs API calls → URMA equivalents (consult mapping.md); calls with no equivalent deleted directly (consult mapping.md §No URMA Equivalents)
- Struct field name updates (e.g.,
wc.qp_num → cr.local_id)
- Enum value updates (e.g.,
IBV_MTU_1024 → URMA_MTU_1024)
- Connection establishment flow updates (consult mapping.md §Connection Establishment Decision Tree; choose correct operation by RC/RM/UM)
- Address exchange format updates (
lid:qpn:psn:gid → jpn:eid; consult mapping.md §Address Exchange Format Decision)
- Cleanup order updates (consult mapping.md §Cleanup Order Decision; choose correct order by transport mode)
Build config must be updated:
- Link libraries:
-libverbs → -lurma -lurma_common
- Header file paths:
infiniband/verbs.h → ub/umdk/urma/urma_api.h
- If original project has no Makefile, create one (link
-lurma -lurma_common)
Mapping Traceability (Preventing Mapping Item Omissions)
Problem: After Phase 1 produces mapping plan, Phase 2 file-by-file conversion easily omits non-core path mapping items (e.g., ibv_create_comp_channel → urma_create_jfce), because verification only compares patterns/pitfalls (general knowledge), not Phase 1 mapping plan (project-specific checklist).
Two-layer traceability mechanism:
File-level traceability (verify immediately after each file is converted):
- Verify each Verbs API directly appearing in that file has been handled
- Must not omit: calls in conditional branches, helper functions, initialization/cleanup paths
- Verification results become part of that file's verification
Project-level traceability (aggregate verification after all files are converted):
- Verify each item in Phase 1 mapping table has been handled in at least one file
- No mapping items allowed in "unprocessed" state
- Output traceability summary: status of each mapping item (converted/deleted) and file where handled
Verification Requirements (Must Be Satisfied After Each File Conversion)
Must verify:
- Each chapter of patterns.md: does this file's code conform to this pattern
- Each chapter of pitfalls.md: did this file's code step into this pitfall
- Numbering: P-XX corresponds to patterns.md chapter numbers, PIT-XX corresponds to pitfalls.md chapter numbers
- File-level mapping traceability: has each Verbs API in this file been handled
Must achieve state:
- Each item judged as conforming (pattern matched / pitfall avoided) or not applicable (N/A, reason required, e.g., "this file has no RDMA operations")
- Non-conforming items (FAIL) must be fixed and re-verified; cannot be left behind
- Must not skip any chapter — iterate through reference file's actual chapter numbers
- Numbering comes from reference files' actual chapters; new chapters in reference files automatically included
Output method: List verification results and judgment basis for each chapter item by item, ensuring auditable. Cannot substitute item-by-item checks with general statements like "verified".
Phase 3: Verification#
Goal: Compile, link, and verify converted code.
Mandatory deliverables (must be produced at phase end):
- Compilation success (no errors)
- Linking correct (depends on
liburma.so and liburma_common.so)
Must complete (hard constraints during phase):
- Compilation passes, no undefined references, type mismatches, or other errors
- Linking verification confirms dependency on correct URMA library
- Compilation errors investigated and fixed
Common compilation errors and troubleshooting directions:
Error TypePossible CauseTroubleshooting DirectionUndefined referenceWrong API nameCheck correct function signature in urma_api.hNo member named 'jetty_id'Wrong field namecr.local_id, not cr.jetty_id (see mapping.md)Macro redefinitionMacro already exists in headerDelete self-defined macrosType mismatchWrong parameter typeMatch exact signature in urma_api.hMissing header fileCorrect header not includedAdd #include <ub/umdk/urma/urma_api.h>
Phase 4: Review and Optimization (Mandatory)#
Goal: Check cross-file semantic issues from project perspective; verify correctness beyond compilation.
Why cannot look at single file only: Resource lifecycle spans files (created in A, destroyed in B), type declarations modified in .h but .c references not synced, Verbs residue may only appear in "copied as-is" utility files — these are issues that single-file perspective cannot discover.
Mandatory deliverables (must be produced at phase end):
- Cross-file consistency confirmed: header type definitions and source file references synced, shared variable declarations consistent
- Resource lifecycle completeness: each URMA resource's create→destroy chain complete without omissions
- Verbs residue zero: no
ibv_* / verbs.h / infiniband references in urma_output/
- Runtime semantic correctness: import/unimport pairing, wait/ack pairing, cleanup paths complete
- User-confirmed review summary
Must complete (hard constraints during phase):
- Header→Source consistency: For type definition changes in .h, confirm all .c files referencing that .h have been updated; no residual old types
- Shared variable consistency: For cross-file shared variables (e.g., global
ibv_cq *g_cq → urma_jfc_t *g_jfc), confirm .h declarations and all .c uses are consistent
- Resource ownership and lifecycle: Trace each URMA resource (context, jfc, jfr, jetty, tseg, tjetty, import_seg) to identify which file creates and which destroys; confirm create→destroy chain complete without omissions
- Verbs residue scan: Confirm no Verbs residual references in
urma_output/
- Re-examine N/A items: Items marked N/A in Phase 2 may apply from cross-file perspective (e.g., single file has no RDMA code, but other files trigger import_seg requirements)
- Cleanup path completeness: Does each success path have corresponding complete cleanup sequence (unbind→unimport→delete)
- Resource leak check: Does each
urma_import_* have corresponding urma_unimport_*; does each urma_wait_jfc have urma_ack_jfc
Fix and recompile until clean.
Phase 4 Checkpoint
Present to user:
- Issues discovered and fixed in Phase 4
- Residual risks (known issues that cannot be resolved during migration)
- New knowledge (new mappings/patterns/pitfalls discovered during migration)
- Whether to add new knowledge to reference files (requires user consent)
Mandatory: All converted code goes to new directory. Original files remain unchanged.
Final output structure:
text
project/
├── (original files - unchanged)
└── urma_output/
├── (converted .c files)
├── (converted .h files)
├── (copied non-Verbs files as-is)
└── Makefile
Contributing New Knowledge#
After successful migration, you may discover new mappings, patterns, or pitfalls.
Steps:
-
Collect new discoveries:
- New API mappings (verbs → urma)
- New struct field mappings
- New code patterns
- New pitfalls
-
Present discoveries to user:
text
I discovered the following new information during migration:
[List discoveries clearly]
Should I add these to the reference files?
-
If user agrees:
- New API mapping: Add to
references/mapping.md
- New code patterns: Add to
references/patterns.md
- New pitfalls: Add to
references/pitfalls.md
-
If user refuses:
- Skip updating reference files
This ensures the skill improves with actual usage, but only with user consent.
Reference Files Overview#
FilePurposeAgent Usage Scenariomapping.mdVerbs → URMA lookup table"What is X's URMA equivalent?"patterns.mdComplete code patterns"Show me how to write X"pitfalls.mdKnown issues and fixes"Why did X fail?"urma_sample.mdComplete working example (~1280 lines)Read on demand only when patterns.md is not detailed enough
Recommended reading order:
mapping.md - Learn API equivalents
patterns.md - View complete working code
pitfalls.md - Avoid common errors
urma_sample.md - Read only when complete reference implementation needed (~1280 lines, load on demand)