Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user space driver: initialize the project, add some basic types and descriptor types. #8

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"vscode": {
"extensions": [
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cpptools"
"ms-vscode.cpptools",
"rust-lang.rust-analyzer"
]
}
},
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: open-rdma-driver CI test
on:
pull_request:
branches: [refactor]
push:
branches: [refactor]

jobs:
ci-check:
name: rust-driver test
runs-on: self-hosted
container:
image: ghcr.io/myrfy001/hard_devcontainer:main
options: --privileged
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout tools repo
uses: actions/checkout@v4
with:
repository: datenlord/blue-rdma
ref: next
fetch-depth: 0
submodules: 'true'
path: blue-rdma
- uses: actions/cache@v4
id: cache-building-emulator
with:
path: |
~/.bash_profile
blue-rdma/bsc-2023.01-ubuntu-22.04
blue-rdma/test
~/.cache/pip
key: ${{ runner.os }}-blue-rdma-next
- name: build emulator
if: steps.cache-building-emulator.outputs.cache-hit != 'true'
run : |
apt update && apt install -y python3-pip
pip3 install scapy
cd ./blue-rdma
./setup.sh
./run_one.sh || true
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: run cargo build
working-directory: rust-driver
run : cargo build --verbose
- name: pre run emulator
run : |
cd blue-rdma
./run_system_test.sh
- name: run cargo test
working-directory: rust-driver
run : cargo test --verbose
4 changes: 4 additions & 0 deletions rust-driver/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target
/Cargo.lock

.DS_Store
40 changes: 40 additions & 0 deletions rust-driver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "open-rdma-driver"
version = "0.1.0"
edition = "2021"
repository = "https://github.com/datenlord/open-rdma-driver"
description = "A user space RDMA driver for BlueRDMA and its software protocol stack"
readme = "README.md"
license = "GPL 2.0"
keywords = ["rdma", "driver"]
categories = ["Command line utilities", "Hardware support"]

[dependencies]
thiserror = "1.0.56"
num_enum = "0.7.2"
socket2 = { version = "0.5.6", features = ["all"] }
crc32fast = "1.4.0"
bitflags = "2.4.2"
libc = "0.2"
rand = { version = "0.8.5", features = ["std", "std_rng"], default-features = false }
serde_json = "1.0.114"
serde = { version = "1.0.197", features = ["derive"] }
bitfield = "0.14.0"
eui48 = "1.1.0"
log = {version = "0.4", features = ["std"]}
serial_test = "3.0.0"
derive_builder = "0.20.0"
smoltcp = {version = "0.11.0", features = ["verbose"]}
parking_lot = "0.12.2"
flume = "0.11.0"
atomic_enum = "0.3.0"
core_affinity = "0.8.1"


[dev-dependencies]
shared_memory = "0.12.4"
ctor = "0.2.7"
buddy_system_allocator = "0.9.1"
libc = "0.2.153"
lazy_static = "1.4.0"
serial_test = "3.0.0"
3 changes: 3 additions & 0 deletions rust-driver/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.75"
components = ["clippy", "rustfmt"]
47 changes: 47 additions & 0 deletions rust-driver/src/device/constant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
enum CsrIndex {
BaseAddrLow = 0x0,
BaseAddrHigh = 0x1,
Head = 0x2,
Tail = 0x3,
}

const fn generate_csr_addr(is_h2c: bool, queue_index: usize, reg_index: CsrIndex) -> usize {
let mut a = if is_h2c { 1 } else { 0 };
a <<= 3_i32;
a |= queue_index & 0b111;
a <<= 10_i32;
a |= reg_index as usize & 0x3FF;
a <<= 2_i32;
a
}

pub(super) const CSR_ADDR_CMD_REQ_QUEUE_ADDR_LOW: usize =
generate_csr_addr(true, 0, CsrIndex::BaseAddrLow);
pub(super) const CSR_ADDR_CMD_REQ_QUEUE_ADDR_HIGH: usize =
generate_csr_addr(true, 0, CsrIndex::BaseAddrHigh);
pub(super) const CSR_ADDR_CMD_REQ_QUEUE_HEAD: usize = generate_csr_addr(true, 0, CsrIndex::Head);
pub(super) const CSR_ADDR_CMD_REQ_QUEUE_TAIL: usize = generate_csr_addr(true, 0, CsrIndex::Tail);
pub(super) const CSR_ADDR_CMD_RESP_QUEUE_HEAD: usize = generate_csr_addr(false, 0, CsrIndex::Head);
pub(super) const CSR_ADDR_CMD_RESP_QUEUE_TAIL: usize = generate_csr_addr(false, 0, CsrIndex::Tail);
pub(super) const CSR_ADDR_CMD_RESP_QUEUE_ADDR_LOW: usize =
generate_csr_addr(false, 0, CsrIndex::BaseAddrLow);
pub(super) const CSR_ADDR_CMD_RESP_QUEUE_ADDR_HIGH: usize =
generate_csr_addr(false, 0, CsrIndex::BaseAddrHigh);
pub(super) const CSR_ADDR_SEND_QUEUE_HEAD: usize = generate_csr_addr(true, 1, CsrIndex::Head);
pub(super) const CSR_ADDR_SEND_QUEUE_TAIL: usize = generate_csr_addr(true, 1, CsrIndex::Tail);
pub(super) const CSR_ADDR_SEND_QUEUE_ADDR_LOW: usize =
generate_csr_addr(true, 1, CsrIndex::BaseAddrLow);
pub(super) const CSR_ADDR_SEND_QUEUE_ADDR_HIGH: usize =
generate_csr_addr(true, 1, CsrIndex::BaseAddrHigh);
pub(super) const CSR_ADDR_META_REPORT_QUEUE_HEAD: usize =
generate_csr_addr(false, 1, CsrIndex::Head);
pub(super) const CSR_ADDR_META_REPORT_QUEUE_TAIL: usize =
generate_csr_addr(false, 1, CsrIndex::Tail);
pub(super) const CSR_ADDR_META_REPORT_QUEUE_ADDR_LOW: usize =
generate_csr_addr(false, 1, CsrIndex::BaseAddrLow);
pub(super) const CSR_ADDR_META_REPORT_QUEUE_ADDR_HIGH: usize =
generate_csr_addr(false, 1, CsrIndex::BaseAddrHigh);

pub(super) const RINGBUF_DEPTH: usize = 128;
pub(super) const RINGBUF_ELEM_SIZE: usize = 32;
pub(super) const RINGBUF_PAGE_SIZE: usize = 4096;
Loading