Skip to content

Commit

Permalink
prov/efa: Set max rma order size correctly
Browse files Browse the repository at this point in the history
EFA device doesn't support any ordering for
RMA and atomic operations. RDM endpoint supports
emulated ordered atomic protocol with max order
size as the max atomic size. EFA provider should
only return these non-zero for rdm ep type when
ordered atomic is requested: FI_ORDER_ATOMIC_*.

Signed-off-by: Shi Jin <sjina@amazon.com>
  • Loading branch information
shijin-aws committed Oct 24, 2024
1 parent 331b425 commit d6a92c7
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 8 deletions.
6 changes: 4 additions & 2 deletions prov/efa/src/efa_prov_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ const struct fi_ep_attr efa_ep_attr = {
.protocol = FI_PROTO_EFA,
.protocol_version = 1,
.msg_prefix_size = 0,
.max_order_raw_size = 0,
.max_order_war_size = 0,
.max_order_waw_size = 0,
.mem_tag_format = 0,
.tx_ctx_cnt = 1,
.rx_ctx_cnt = 1,
Expand Down Expand Up @@ -187,8 +189,6 @@ void efa_prov_info_set_ep_attr(struct fi_info *prov_info,
}

prov_info->ep_attr->max_msg_size = device->ibv_port_attr.max_msg_sz;
prov_info->ep_attr->max_order_raw_size = device->ibv_port_attr.max_msg_sz;
prov_info->ep_attr->max_order_waw_size = device->ibv_port_attr.max_msg_sz;
}

/**
Expand Down Expand Up @@ -579,6 +579,8 @@ int efa_prov_info_alloc_for_rdm(struct fi_info **prov_info_rdm_ptr,
- device->rdm_info->src_addrlen
- EFA_RDM_IOV_LIMIT * sizeof(struct fi_rma_iov);
prov_info_rdm->ep_attr->max_order_raw_size = max_atomic_size;
prov_info_rdm->ep_attr->max_order_war_size = max_atomic_size;
prov_info_rdm->ep_attr->max_order_waw_size = max_atomic_size;
}

/* update tx_attr */
Expand Down
13 changes: 7 additions & 6 deletions prov/efa/src/efa_user_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ bool efa_user_info_should_support_hmem(int version)
static
int efa_user_info_alter_rdm(int version, struct fi_info *info, const struct fi_info *hints)
{
uint64_t atomic_ordering;

if (hints && (hints->caps & FI_HMEM)) {
/*
* FI_HMEM is a primary capability, therefore only check
Expand Down Expand Up @@ -418,11 +416,14 @@ int efa_user_info_alter_rdm(int version, struct fi_info *info, const struct fi_i
* the default message order supported by the provider is returned.
*/
info->tx_attr->msg_order &= hints->tx_attr->msg_order;
atomic_ordering = FI_ORDER_ATOMIC_RAR | FI_ORDER_ATOMIC_RAW |
FI_ORDER_ATOMIC_WAR | FI_ORDER_ATOMIC_WAW;
if (!(hints->tx_attr->msg_order & atomic_ordering)) {

/* If no atomic ordering is requested, set the max_order_*_size as 0 */
if (!(hints->tx_attr->msg_order & FI_ORDER_ATOMIC_RAW))
info->ep_attr->max_order_raw_size = 0;
}
if (!(hints->tx_attr->msg_order & FI_ORDER_ATOMIC_WAR))
info->ep_attr->max_order_war_size = 0;
if (!(hints->tx_attr->msg_order & FI_ORDER_ATOMIC_WAW))
info->ep_attr->max_order_waw_size = 0;
}

if (hints->rx_attr) {
Expand Down
83 changes: 83 additions & 0 deletions prov/efa/test/efa_unit_test_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,89 @@ void test_info_tx_rx_msg_order_dgram_order_sas(struct efa_resource **state)
test_info_tx_rx_msg_order_from_hints(resource->hints, -FI_ENODATA);
}

/**
* @brief Verify max order size is set correctly according to hints
*
* @param hints hints
* @param expected_ret expected rc of fi_getinfo
* @param expected_size expected value of max_order_*_size. Ignored when expected_ret is non-zero.
*/
static void
test_info_max_order_size_from_hints(struct fi_info *hints, int expected_ret, size_t expected_size)
{
struct fi_info *info;
int err;

err = fi_getinfo(FI_VERSION(FI_MAJOR_VERSION, FI_MINOR_VERSION), NULL, NULL, 0ULL, hints, &info);

assert_int_equal(err, expected_ret);

if (expected_ret == FI_SUCCESS) {
assert_true(info->ep_attr->max_order_raw_size == expected_size);
assert_true(info->ep_attr->max_order_war_size == expected_size);
assert_true(info->ep_attr->max_order_waw_size == expected_size);
}

fi_freeinfo(info);
}

/**
* DGRAM ep type doesn't support FI_ATOMIC, fi_getinfo should return
* ENODATA when FI_ATOMIC is requested in hints.
*/
void test_info_max_order_size_dgram_with_atomic(struct efa_resource **state)
{
struct efa_resource *resource = *state;

resource->hints = efa_unit_test_alloc_hints(FI_EP_DGRAM);
assert_non_null(resource->hints);

resource->hints->caps = FI_ATOMIC;

test_info_max_order_size_from_hints(resource->hints, -FI_ENODATA, 0);
}

/**
* RDM ep type supports FI_ATOMIC. When FI_ORDER_ATOMIC_* is NOT requested,
* max_order_*_size should be 0
*/
void test_info_max_order_size_rdm_with_atomic_no_order(struct efa_resource **state)
{
struct efa_resource *resource = *state;

resource->hints = efa_unit_test_alloc_hints(FI_EP_RDM);
assert_non_null(resource->hints);


resource->hints->caps = FI_ATOMIC;
resource->hints->domain_attr->mr_mode |= FI_MR_VIRT_ADDR | FI_MR_PROV_KEY;

test_info_max_order_size_from_hints(resource->hints, FI_SUCCESS, 0);
}

/**
* RDM ep type supports FI_ATOMIC. When FI_ORDER_ATOMIC_* is requested,
* max_order_*_size should be the max atomic size derived from mtu and headers
*/
void test_info_max_order_size_rdm_with_atomic_order(struct efa_resource **state)
{
struct efa_resource *resource = *state;
size_t max_atomic_size = g_device_list[0].rdm_info->ep_attr->max_msg_size
- sizeof(struct efa_rdm_rta_hdr)
- g_device_list[0].rdm_info->src_addrlen
- EFA_RDM_IOV_LIMIT * sizeof(struct fi_rma_iov);

resource->hints = efa_unit_test_alloc_hints(FI_EP_RDM);
assert_non_null(resource->hints);

resource->hints->caps = FI_ATOMIC;
resource->hints->domain_attr->mr_mode |= FI_MR_VIRT_ADDR | FI_MR_PROV_KEY;
resource->hints->tx_attr->msg_order |= FI_ORDER_ATOMIC_RAR | FI_ORDER_ATOMIC_RAW | FI_ORDER_ATOMIC_WAR | FI_ORDER_ATOMIC_WAW;
resource->hints->rx_attr->msg_order = resource->hints->tx_attr->msg_order;

test_info_max_order_size_from_hints(resource->hints, FI_SUCCESS, max_atomic_size);
}

void test_info_tx_rx_op_flags_rdm(struct efa_resource **state)
{
struct efa_resource *resource = *state;
Expand Down
3 changes: 3 additions & 0 deletions prov/efa/test/efa_unit_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ int main(void)
cmocka_unit_test_setup_teardown(test_info_tx_rx_msg_order_rdm_order_sas, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
cmocka_unit_test_setup_teardown(test_info_tx_rx_msg_order_dgram_order_none, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
cmocka_unit_test_setup_teardown(test_info_tx_rx_msg_order_dgram_order_sas, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
cmocka_unit_test_setup_teardown(test_info_max_order_size_dgram_with_atomic, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
cmocka_unit_test_setup_teardown(test_info_max_order_size_rdm_with_atomic_no_order, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
cmocka_unit_test_setup_teardown(test_info_max_order_size_rdm_with_atomic_order, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
cmocka_unit_test_setup_teardown(test_info_tx_rx_op_flags_rdm, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
cmocka_unit_test_setup_teardown(test_info_tx_rx_size_rdm, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
cmocka_unit_test_setup_teardown(test_info_check_shm_info_hmem, efa_unit_test_mocks_setup, efa_unit_test_mocks_teardown),
Expand Down
3 changes: 3 additions & 0 deletions prov/efa/test/efa_unit_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ void test_info_tx_rx_msg_order_rdm_order_none();
void test_info_tx_rx_msg_order_rdm_order_sas();
void test_info_tx_rx_msg_order_dgram_order_none();
void test_info_tx_rx_msg_order_dgram_order_sas();
void test_info_max_order_size_dgram_with_atomic();
void test_info_max_order_size_rdm_with_atomic_no_order();
void test_info_max_order_size_rdm_with_atomic_order();
void test_info_tx_rx_op_flags_rdm();
void test_info_tx_rx_size_rdm();
void test_info_check_shm_info_hmem();
Expand Down

0 comments on commit d6a92c7

Please sign in to comment.