Skip to content

Comments

Unify buffer and zc#27

Merged
ming1 merged 7 commits intomainfrom
unify-buffer-and-zc
Sep 2, 2025
Merged

Unify buffer and zc#27
ming1 merged 7 commits intomainfrom
unify-buffer-and-zc

Conversation

@ming1
Copy link
Collaborator

@ming1 ming1 commented Sep 2, 2025

No description provided.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Add BufDesc enum to support both copy and zero-copy buffer operations
in a unified API. The enum includes Slice variant for traditional buffer
copy operations and AutoReg variant for auto buffer registration.

- BufDesc::Slice holds buffer slice references for copy operations
- BufDesc::AutoReg stores ublk_auto_buf_reg value (8 bytes) directly
- Supports Debug and Clone traits as required
- Part of unify-buffer-and-zero-copy feature implementation

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
…st enum

- Add extensive documentation for BufDesc enum with usage examples
- Implement BufDescList enum for batch buffer operations
- Add library-level documentation for unified buffer management API
- Include migration examples from legacy APIs to unified APIs
- Document performance characteristics and validation requirements
- Provide comprehensive examples for both copy and zero-copy modes

This completes the foundational types for the unified buffer management
system while ensuring users have clear guidance for adoption.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Add validation methods to BufDesc enum that check compatibility between
buffer descriptor types and device capabilities. This implements task 3
of the unify-buffer-and-zero-copy specification.

Changes:
- Add validate_compatibility() method to check device flag compatibility
- Add from_io_buf() helper method for migration from IoBuf
- Export BufDesc and BufDescList at crate level for public API access
- Add comprehensive tests for validation logic
- Remove len() and is_empty() methods as requested

The validation ensures proper usage of buffer types:
- BufDesc::Slice works with traditional buffer management and UBLK_F_USER_COPY
- BufDesc::AutoReg requires UBLK_F_AUTO_BUF_REG flag
- Invalid flag combinations return appropriate error codes

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Changes:
- Added unified complete_io_cmd_unified() method that accepts BufDesc enum
- Updated examples (null.rs, loop.rs) to use the new unified API
- Modified all test cases in tests/basic.rs to use BufDesc::Slice() or BufDesc::AutoReg()
- Replaced direct buffer pointer usage with buffer descriptor abstraction
- Added validation logic for buffer descriptor compatibility with device flags

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Add unified submit_io_cmd_unified() method to UblkQueue that accepts BufDesc
enum for both traditional buffer slices and auto buffer registration modes.

Key changes:
- Add submit_io_cmd_unified() method with comprehensive validation and dispatch
- Update all examples (loop, null, ramdisk) to use unified API
- Update all tests to use unified API with appropriate BufDesc variants
- Add proper error handling and async pattern (unwrap().await)
- Remove unused raw pointer variables from examples
- Update README.md documentation example

The unified method maintains zero runtime overhead through compile-time
dispatch while providing a cleaner, more ergonomic API that works with
both copy and zero-copy buffer management strategies.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Add unified submit_fetch_commands_unified() method to UblkQueue that accepts
BufDescList enum for both traditional buffer slices and auto buffer registration.

Key changes:
- Add submit_fetch_commands_unified() method with comprehensive validation and dispatch
- Add BufDescList enum with Slices and AutoRegs variants for unified buffer list handling
- Update all examples (loop, null) to use unified API with BufDescList::Slices
- Update all tests to use unified API with appropriate BufDescList variants
- Replace submit_fetch_commands_with_auto_buf_reg with BufDescList::AutoRegs usage
- Add proper error handling and device capability validation
- Include comprehensive documentation with usage examples

The unified method maintains zero runtime overhead through compile-time dispatch
while providing a cleaner, more ergonomic API that works with both copy and
zero-copy buffer management strategies. This completes the unified buffer
management API trilogy alongside submit_io_cmd_unified and complete_io_cmd_unified.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
@ming1 ming1 merged commit c2dec53 into main Sep 2, 2025
8 checks passed
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