Coder Social home page Coder Social logo

rdma-sys's Issues

`cargo build` failed

๐Ÿบ /root/go/src/github.com/datenlord/rdma-sys โ˜ž git:(master) โœ— cargo build
   Compiling rdma-sys v0.1.0 (/root/go/src/github.com/datenlord/rdma-sys)
error[E0412]: cannot find type `__uint32_t` in this scope
   --> src/verbs.rs:503:15
    |
503 |     let mask: __uint32_t = 0x000000ff;
    |               ^^^^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0412`.
error: could not compile `rdma-sys` due to previous error

let mask: __uint32_t = 0x000000ff;

build problem

rdma-sys build fail with new clang version.

  --- stderr
  thread 'main' panicked at '"ib_uverbs_flow_action_esp_encap_union_(anonymous_at_/usr/include/infiniband/ib_user_ioctl_verbs_h_189_2)" is not a valid Ident', /home/wy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.60/src/fallback.rs:791:9

It seem that llvm changes cause this problem according to bindgen issue 2312.

If change bindgen to "0.66.1", async-rdma will build fail with ibv_access_flags and ibv_event_type doesn't implement Debug because of derive_debug(false) build.rs#L145

`ibv_event_type` doesn't implement `Debug`
the trait `Debug` is not implemented for `ibv_event_type`
the trait `Debug` is implemented for `Arc<T>`

And if change build.rs#L145 to derive_debug(true), rdma-sys will build fail with following error.

`libc::pthread_mutex_t` doesn't implement `Debug`
the trait `Debug` is not implemented for `libc::pthread_mutex_t`

My solution is to add some no_debug

.derive_debug(true)
.no_debug("ibv_qp")
.no_debug("ibv_context")
.no_debug("ibv_cq_ex")
.no_debug("ibv_srq")
.no_debug("ibv_wq")
.no_debug("ibv_cq")

build problem

[acb8du9j30@login03 ibv]$ cargo build
   Compiling rdma-sys v0.3.0
error: failed to run custom build command for `rdma-sys v0.3.0`

Caused by:
  process didn't exit successfully: `/work/home/acb8du9j30/rdma_test/ibv/target/debug/build/rdma-sys-9b0811c26487ede9/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBIBVERBS_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'please install libibverbs-dev 1.8.28)', /work/home/acb8du9j30/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/rdma-sys-0.3.0/build.rs:10:41
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[acb8du9j30@login03 ibv]$ pkg-config --modversion libibverbs
1.10.30.0

Does it have to be version 1.8.28?

Ask for help, thank you for answering.

When I try to establish RC type connection, the ready_to_receive function return an Err Invalid argument (os error 22).
What could be the cause of this error? Thank you very much for the answer.
The most likely causes are in qp_attr.ah_attr. What else need to change in it?

modify_qp code:

    pub fn init(&self) -> Result<()> {
        let mut attr = unsafe { std::mem::zeroed::<ibv_qp_attr>() };
        attr.qp_state = ibv_qp_state::IBV_QPS_INIT;
        attr.pkey_index = 0;
        attr.port_num = 1;
        attr.qp_access_flags = (ibv_access_flags::IBV_ACCESS_LOCAL_WRITE
            | ibv_access_flags::IBV_ACCESS_REMOTE_WRITE
            | ibv_access_flags::IBV_ACCESS_REMOTE_READ)
            .0.cast();
        let attr_mask = ibv_qp_attr_mask::IBV_QP_STATE
            | ibv_qp_attr_mask::IBV_QP_PKEY_INDEX
            | ibv_qp_attr_mask::IBV_QP_PORT
            | ibv_qp_attr_mask::IBV_QP_ACCESS_FLAGS;
        if unsafe { ibv_modify_qp(self.inner(), &mut attr, attr_mask.0.cast()) } != 0 {
            return Err(Error::last_os_error());
        }
        Ok(())
    }

    pub fn ready_to_receive(&self, remote_emp: EndPoint) -> Result<()> {
        let mut attr = unsafe { std::mem::zeroed::<ibv_qp_attr>() };
        attr.qp_state = ibv_qp_state::IBV_QPS_RTR;
        attr.path_mtu = ibv_mtu::IBV_MTU_512;
        attr.dest_qp_num = remote_emp.qpn;
        // qp_attr.rq_psn(X) must be equal to qp_attr.sq_psn(Y)
        attr.rq_psn = 0;
        attr.max_dest_rd_atomic = 1;
        attr.min_rnr_timer = 18;
        attr.ah_attr = ibv_ah_attr {
            dlid: remote_emp.lid,
            sl: 0,
            src_path_bits: 0,
            static_rate: 0,
            is_global: 1,
            port_num: 1,
            grh: ibv_global_route {
                sgid_index: 1,
                dgid: remote_emp.gid,
                hop_limit: 255,
                traffic_class: 0,
                flow_label: 0,
            }
        };
        let attr_mask = ibv_qp_attr_mask::IBV_QP_STATE
            | ibv_qp_attr_mask::IBV_QP_AV
            | ibv_qp_attr_mask::IBV_QP_PATH_MTU
            | ibv_qp_attr_mask::IBV_QP_DEST_QPN
            | ibv_qp_attr_mask::IBV_QP_RQ_PSN
            | ibv_qp_attr_mask::IBV_QP_MAX_DEST_RD_ATOMIC
            | ibv_qp_attr_mask::IBV_QP_MIN_RNR_TIMER;
        if unsafe { ibv_modify_qp(self.inner(), &mut attr, attr_mask.0.cast()) } != 0 {
            return Err(Error::last_os_error());
        }
        Ok(())
    }

    pub fn ready_to_send(&self) -> Result<()> {
        let mut attr = unsafe { std::mem::zeroed::<ibv_qp_attr>() };
        attr.qp_state = ibv_qp_state::IBV_QPS_RTS;
        attr.timeout = 14;
        attr.retry_cnt = 6;
        attr.rnr_retry = 6;
        attr.sq_psn = 0;
        attr.max_rd_atomic = 1;
        let attr_mask = ibv_qp_attr_mask::IBV_QP_STATE
            | ibv_qp_attr_mask::IBV_QP_TIMEOUT
            | ibv_qp_attr_mask::IBV_QP_RETRY_CNT
            | ibv_qp_attr_mask::IBV_QP_RNR_RETRY
            | ibv_qp_attr_mask::IBV_QP_SQ_PSN
            | ibv_qp_attr_mask::IBV_QP_MAX_QP_RD_ATOMIC;
        // SAFETY: ffi, and qp will not modify by other threads
        if unsafe { ibv_modify_qp(self.inner(), &mut attr, attr_mask.0.cast()) } != 0 {
            return Err(Error::last_os_error());
        }
        Ok(())
    }

main code

lazy_static! {
    static ref DEVICE: Device = Device::new(default_device());
}

fn main() {
    let device = &DEVICE;

    let pd_client = Arc::new(PD::new(device));
    let pd_server = Arc::new(PD::new(device));

    let cq_client = Arc::new(CQ::new(device));
    let cq_server = Arc::new(CQ::new(device));

    let (tx1, rx1) = channel();
    let (tx2, rx2) = channel();

    println!("client start");
    let pd = pd_client.clone();
    let cq = cq_client.clone();
    let h1 = thread::spawn(move || client(pd, cq, tx1, rx2));

    println!("server start");
    let pd = pd_server.clone();
    let cq = cq_server.clone();
    let h2 = thread::spawn(move || server(pd, cq, tx2, rx1));
    h1.join().unwrap();
    h2.join().unwrap();
}

fn client(pd: Arc<PD>, cq: Arc<CQ>, tx: Sender<EndPoint>, rx: Receiver<EndPoint>) {
    let cap = QPCap::new(10, 10, 1, 1);
    // Create a QP
    let qp = QP::new(&pd, &cq, cap);
    if let Err(err) = qp.init() {
        println!("err: {}", err);
    }

    let enp = qp.endpoint();
    println!("client enp: {:?}", enp);

    // Exchange QP information with the remote side (e.g. using sockets)
    tx.send(enp);
    let remote_enp = rx.recv().unwrap();

    if let Err(err) = qp.ready_to_receive(remote_enp) {
        println!("client err : {}", err);
    }
    if let Err(err) = qp.ready_to_send() {...
}

fn server(pd: Arc<PD>, cq: Arc<CQ>, tx: Sender<EndPoint>, rx: Receiver<EndPoint>) {
    let cap = QPCap::new(10, 10, 1, 1);
    // Create a QP
    let qp = QP::new(&pd, &cq, cap);
    qp.init();

    let enp = qp.endpoint();
    println!("server enp: {:?}", enp);
    // Exchange QP information withw the remote side (e.g. using sockets)
    tx.send(enp);
    let remote_enp = rx.recv().unwrap();

    if let Err(err) = qp.ready_to_receive(remote_enp) {
        println!("server err : {}", err);
    }
    if let Err(err) = qp.ready_to_send() {
        println!("server err: {}", err);
    }
...
}

the output :

client start
server start
server enp: qpn: 80, lid: 0, gid: [254, 128, 0, 0, 0, 0, 0, 0, 2, 28, 66, 255, 254, 168, 185, 136]
client enp: qpn: 79, lid: 0, gid: [254, 128, 0, 0, 0, 0, 0, 0, 2, 28, 66, 255, 254, 168, 185, 136]
client err : Invalid argument (os error 22)
client err: Invalid argument (os error 22)
client ready to use
server err : Invalid argument (os error 22)
server err: Invalid argument (os error 22)
server ready to use

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.