ublk-cpp v0.0
Loading...
Searching...
No Matches
helpers.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "ublk/ublk_cmd.h"
9#include <cassert>
10#include <cstdint>
11
12namespace ublk {
13
21inline uint16_t shmem_zc_index(uint64_t addr) noexcept {
22 return ublk_shmem_zc_index(addr);
23}
24
32inline uint32_t shmem_zc_offset(uint64_t addr) noexcept {
33 return ublk_shmem_zc_offset(addr);
34}
35
45inline uint64_t user_copy_pos(uint16_t q_id, uint16_t tag,
46 uint32_t offset) noexcept {
47 assert(!(offset & ~UBLK_IO_BUF_BITS_MASK));
48 return UBLKSRV_IO_BUF_OFFSET +
49 ((static_cast<uint64_t>(q_id) << UBLK_QID_OFF) |
50 (static_cast<uint64_t>(tag) << UBLK_TAG_OFF) | offset);
51}
52
53} // namespace ublk
The main namespace of the ublk-cpp library.
Definition ublk.hpp:21
uint16_t shmem_zc_index(uint64_t addr) noexcept
Extract the buffer index from a shared memory zero-copy encoded address (UBLK_IO_F_SHMEM_ZC).
Definition helpers.hpp:21
uint64_t user_copy_pos(uint16_t q_id, uint16_t tag, uint32_t offset) noexcept
Compute the byte position in /dev/ublkcN for user-space data copy (UBLK_F_USER_COPY).
Definition helpers.hpp:45
uint32_t shmem_zc_offset(uint64_t addr) noexcept
Extract the byte offset within the buffer from a shared memory zero-copy encoded address (UBLK_IO_F_S...
Definition helpers.hpp:32