Skip to content
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
21 changes: 18 additions & 3 deletions src/uct/ib/base/ib_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,15 +1038,31 @@ static ucs_status_t uct_ib_rkey_unpack(uct_md_component_t *mdc,
void **handle_p)
{
uint64_t packed_rkey = *(const uint64_t*)rkey_buffer;
uct_ib_md_rkey_t *rkey;

*rkey_p = packed_rkey;
rkey = malloc(sizeof(*rkey));
if (rkey == NULL) {
return UCS_ERR_NO_MEMORY;
}

rkey->rma_rkey = (uint32_t)packed_rkey;
rkey->atomic_rkey = packed_rkey >> 32;

*rkey_p = (uct_rkey_t)rkey;
*handle_p = NULL;
ucs_trace("unpacked rkey 0x%llx: direct 0x%x indirect 0x%x",
(unsigned long long)packed_rkey,
uct_ib_md_direct_rkey(*rkey_p), uct_ib_md_indirect_rkey(*rkey_p));
return UCS_OK;
}

static ucs_status_t uct_ib_rkey_release(uct_md_component_t *mdc, uct_rkey_t rkey,
void *handle)
{
free((void*)rkey);
return UCS_OK;
}

static uct_md_ops_t uct_ib_md_ops = {
.close = uct_ib_md_close,
.query = uct_ib_md_query,
Expand Down Expand Up @@ -1796,6 +1812,5 @@ UCT_IB_MD_OPS(uct_ib_verbs_md_ops, 0);

UCT_MD_COMPONENT_DEFINE(uct_ib_mdc, UCT_IB_MD_PREFIX,
uct_ib_query_md_resources, uct_ib_md_open, NULL,
uct_ib_rkey_unpack,
(void*)ucs_empty_function_return_success /* release */,
uct_ib_rkey_unpack, uct_ib_rkey_release,
"IB_", uct_ib_md_config_table, uct_ib_md_config_t);
12 changes: 10 additions & 2 deletions src/uct/ib/base/ib_md.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ enum {
};


typedef struct uct_ib_md_rkey {
uint32_t atomic_rkey;
uint32_t rma_rkey;
} uct_ib_md_rkey_t;


typedef struct uct_ib_md_ext_config {
int eth_pause; /**< Whether or not Pause Frame is
enabled on the Ethernet network */
Expand Down Expand Up @@ -188,13 +194,15 @@ uint8_t uct_ib_md_get_atomic_mr_id(uct_ib_md_t *md);

static inline uint32_t uct_ib_md_direct_rkey(uct_rkey_t uct_rkey)
{
return (uint32_t)uct_rkey;
return (uct_rkey && (uct_rkey != UCT_INVALID_RKEY)) ?
((uct_ib_md_rkey_t*)uct_rkey)->rma_rkey : 0;
}


static uint32_t uct_ib_md_indirect_rkey(uct_rkey_t uct_rkey)
{
return uct_rkey >> 32;
return (uct_rkey && (uct_rkey != UCT_INVALID_RKEY)) ?
((uct_ib_md_rkey_t*)uct_rkey)->atomic_rkey : 0;
}


Expand Down