diff --git a/prov/efa/src/efa_prov_info.c b/prov/efa/src/efa_prov_info.c index bddc965d53a..be3221cb791 100644 --- a/prov/efa/src/efa_prov_info.c +++ b/prov/efa/src/efa_prov_info.c @@ -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, @@ -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; } /** @@ -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 */ diff --git a/prov/efa/src/efa_user_info.c b/prov/efa/src/efa_user_info.c index 919a1cacb97..e152f2adc23 100644 --- a/prov/efa/src/efa_user_info.c +++ b/prov/efa/src/efa_user_info.c @@ -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 @@ -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) { diff --git a/prov/efa/test/efa_unit_test_info.c b/prov/efa/test/efa_unit_test_info.c index 6a53ea381a8..1380e36976c 100644 --- a/prov/efa/test/efa_unit_test_info.c +++ b/prov/efa/test/efa_unit_test_info.c @@ -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; diff --git a/prov/efa/test/efa_unit_tests.c b/prov/efa/test/efa_unit_tests.c index e6b7a324d81..1e2f2087fa2 100644 --- a/prov/efa/test/efa_unit_tests.c +++ b/prov/efa/test/efa_unit_tests.c @@ -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), diff --git a/prov/efa/test/efa_unit_tests.h b/prov/efa/test/efa_unit_tests.h index 2e62473a717..52670e8af9c 100644 --- a/prov/efa/test/efa_unit_tests.h +++ b/prov/efa/test/efa_unit_tests.h @@ -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();