RDMA-Rust / sideway

A better wrapper for using RDMA programming APIs in Rust flavor
Mozilla Public License 2.0
2 stars 0 forks source link

feat(qp): implement qp_attr_mask with bitmask_enum #17

Closed dragonJACson closed 1 month ago

dragonJACson commented 2 months ago

According to #13, we implement a wrapper over ibv_qp_attr_mask with bitmask_enum.

An idea is that we could provide vital and optional masks for different QP state machine transitions, so that we could check them in modify_qp easily. When users pass invalid attr / attr_mask, we could provide useful error messages indicating which mask is invalid or needed.

dragonJACson commented 2 months ago

Current state:

Modify examples/test_qp.rs, the RTR to RTS part, into this

        let mut attr = QueuePairAttribute::new();
        attr.setup_state(QueuePairState::ReadyToSend)
            .setup_sq_psn(1)
            .setup_timeout(12)
            .setup_retry_cnt(7)
            .setup_rnr_retry(7)
            .setup_port(2);

compile and run, we would get

$ ./target/debug/examples/test_qp
qp pointer is QueuePair { qp: 0x564f08d23758, _phantom: PhantomData<&()> }
thread 'main' panicked at src/verbs/queue_pair.rs:296:82:
called `Result::unwrap()` on an `Err` value: "invalid masks QueuePairAttributeMask[Port], needed masks QueuePairAttributeMask[MaxReadAtomic]"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The invalid masks QueuePairAttributeMask[Port], needed masks QueuePairAttributeMask[MaxReadAtomic] would be much more helpful I guess?

dragonJACson commented 1 month ago

After refactoring, I’ve put RC qp state table into a lazy_static variable, which should be more elegant.