Skip to content

libxscale: Introduce xscale provider - #1773

Open
tianx666 wants to merge 13 commits into
linux-rdma:masterfrom
tianx666:master
Open

libxscale: Introduce xscale provider#1773
tianx666 wants to merge 13 commits into
linux-rdma:masterfrom
tianx666:master

Conversation

@tianx666

Copy link
Copy Markdown

Introduce a new RDMA provider for Yunsilicon nics

@tianx666
tianx666 force-pushed the master branch 5 times, most recently from 460486f to d013e80 Compare July 20, 2026 03:14
This patch adds a new userspace RDMA provider driver for the xscale
family of RDMA devices. The provider implements the standard
libibverbs interface, allowing applications to
use RDMA operations via the verbs API.

The initial implementation includes:
  - Basic CMake build infrastructure and provider registration.
  - Device probing and context allocation via the verbs framework.
  - Query operations: query_port and query_device_ex with firmware
    version formatting.
  - Import of necessary kernel ABI headers (xsc-abi.h) and integration
    with the kernel driver.

This is the foundational patch; subsequent patches will add full
functionality for PD, MR, CQ, QP, and advanced features.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
@tianx666
tianx666 force-pushed the master branch 4 times, most recently from 25970ee to 80a87fe Compare July 20, 2026 05:12
tianx666 added 5 commits July 23, 2026 11:45
Define the hardware-specific structures, constants, and inline helper
functions required to interact with the XScale RDMA engine.

This patch introduces:
  - xsc_hsi.h: Host-software interface definitions, including message
    opcodes, completion queue entries (CQE), work queue elements (WQE),
    doorbell formats, and register layouts.
  - xsc_hw.h: Low-level hardware access routines for Andes and Diamond
    device families, such as setting data segments, ringing doorbells,
    updating CQ consumer indices, and translating error codes to verbs
    statuses.

These definitions are used by all subsequent patches to construct and
post work requests, poll completions, and manage hardware resources.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
Implement the basic memory management verbs required for RDMA operations:
  - alloc_pd / dealloc_pd: Manage protection domains, with reference
    counting to prevent premature deallocation.
  - reg_mr / dereg_mr: Register and deregister memory regions, supporting
    standard access flags. The implementation uses the common ibv_cmd_*
    wrappers and stores local keys (lkey/rkey) for later use.

These verbs are prerequisites for creating QPs and posting work requests.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
This patch adds complete CQ management:
  - create_cq / create_cq_ex: Allocate CQ buffers using either huge
    pages, contiguous memory, or regular anonymous memory (controlled
    by environment variables). Support for GPU‑backed buffers via dmabuf
    is also provided.
  - resize_cq: Resize an existing CQ.
  - destroy_cq: Free CQ resources and clean up associated QP error lists.

This lays the groundwork for polling completions and event handling.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
Implement the core QP lifecycle operations:
  - create_qp / create_qp_ex: Allocate QP buffers (SQ and RQ), calculate
    WQE sizes based on device capabilities, and initialize QP indices.
    Supports raw packet QPs and RC QPs.
  - modify_qp: Transition QP states (RTR, RTS, etc.) and handle error
    state transitions, including flushing pending work requests.
  - query_qp: Retrieve current QP attributes.
  - destroy_qp: Clean up QP resources, remove from the QP table, and
    flush any remaining CQEs.

A global QP table is maintained to map QP numbers to internal structures
for fast lookups during completion processing. Error state handling
ensures that CQs are notified when a QP enters the error state.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
Add the ability to post work requests to the hardware:
  - post_send: Construct send WQEs (including RDMA write/read, send,
    atomic operations) and ring the send doorbell. Inline data and
    scatter‑gather lists are supported.
  - post_recv: Build receive WQEs and ring the receive doorbell.

The implementation carefully manages WQE rings, tracks work request IDs
and completion flags, and handles overflow conditions. Doorbell ringing
is done via MMIO writes with proper barriers.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
@tianx666
tianx666 force-pushed the master branch 6 times, most recently from 6c74a18 to cd5a002 Compare July 24, 2026 10:09
tianx666 added 7 commits July 24, 2026 18:27
Implement the completion retrieval path:
  - poll_cq: Scan the CQ ring for new CQEs, parse them (both good and
    error completions), and fill ibv_wc structures.
  - arm_cq / cq_event: Arm the CQ for notification and handle event
    callbacks.

Error CQEs are translated to appropriate verbs status codes, and QPs
are moved to error state when fatal errors occur. Flush error CQEs are
generated for QPs that have been moved to error state to ensure all
pending WRs are completed.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
Extend the MR registration to handle dmabuf file descriptors, allowing
external (e.g., GPU) memory to be used as RDMA buffers. The new function
reg_dmabuf_mr wraps the common ibv_cmd_reg_dmabuf_mr and stores the
access flags for later use.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
Implement the ibv_wr_api (start, set SGE/inline data, complete).

The following operations are supported for RC QPs:
  - wr_send / wr_send_imm
  - wr_rdma_write / wr_rdma_write_imm / wr_rdma_read
  - wr_atomic_cmp_swp / wr_atomic_fetch_add
  - wr_set_sge / wr_set_sge_list / wr_set_inline_data /
    wr_set_inline_data_list

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
Add the cq_ex interface for efficient completion polling:
  - start_poll: Begin polling a CQ, lock it, and retrieve the first CQE.
  - next_poll: Fetch subsequent CQEs without releasing the lock.
  - end_poll: Release the CQ lock and update the consumer index.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
Introduce a set of xscale‑specific direct verbs that provide advanced
functionality not covered by the standard verbs API:

  - devx_create_qp / devx_destroy_qp: Create/destroy QPs with user‑supplied
    memory (e.g., GPU buffers) via devx_umem_in.
  - devx_create_cq / devx_destroy_cq: Similar for CQs.
  - devx_alloc_uar / devx_free_uar: Allocate/free User Access Regions
    (UAR) for direct doorbell ringing.
  - devx_alloc_sq_uar: Allocate dedicated SQ UAR for multi‑QP performance.
  - devx_modify_qp: Wrapper for modify_qp with DV context.
  - devx_get_device_id: Retrieve the hardware device ID.
  - devx_exp_post_send: Extended post_send that supports masked atomic
    operations (8‑byte and 4‑byte masked compare‑and‑swap and fetch‑and‑add).

Also add ECE (Extended Connection Establishment) support via set_ece and
query_ece, enabling negotiation of protocol profiles (e.g., Veroce).

These extensions enable high‑performance and custom use cases for
applications using the xscale provider.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
This patch integrates the xscale RDMA provider into the
rdma-core build and packaging system for both Debian and
RPM-based distributions.

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Signed-off-by: Wei Honggang <weihg@yunsilicon.com>
Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com>
Signed-off-by: Li Qiang <liq@yunsilicon.com>
Signed-off-by: Yan Lei <jacky@yunsilicon.com>
fix pipeline issues

Signed-off-by: Tian Xin <tianx@yunsilicon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant