@@ -811,7 +811,8 @@ void test_ibv_cq_ex_read_ignore_removed_peer()
811
811
#endif
812
812
813
813
static void test_efa_cq_read (struct efa_resource * resource , fi_addr_t * addr ,
814
- int ibv_wc_opcode , int status , int vendor_error )
814
+ int ibv_wc_opcode , int status , int vendor_error ,
815
+ struct efa_context * ctx )
815
816
{
816
817
int ret ;
817
818
size_t raw_addr_len = sizeof (struct efa_ep_addr );
@@ -845,16 +846,19 @@ static void test_efa_cq_read(struct efa_resource *resource, fi_addr_t *addr,
845
846
if (ibv_wc_opcode == IBV_WC_RECV ) {
846
847
ibv_cqx = container_of (base_ep -> util_ep .rx_cq , struct efa_cq , util_cq )-> ibv_cq .ibv_cq_ex ;
847
848
ibv_cqx -> start_poll = & efa_mock_ibv_start_poll_return_mock ;
848
- ibv_cqx -> wr_id = ( uintptr_t ) 12345 ;
849
+ ctx -> completion_flags = FI_RECV | FI_MSG ;
849
850
will_return (efa_mock_ibv_start_poll_return_mock , 0 );
850
851
ibv_cqx -> status = status ;
851
852
} else {
852
853
ibv_cqx = container_of (base_ep -> util_ep .tx_cq , struct efa_cq , util_cq )-> ibv_cq .ibv_cq_ex ;
853
854
/* this mock will set ibv_cq_ex->wr_id to the wr_id of the head of global send_wr,
854
855
* and set ibv_cq_ex->status to mock value */
855
856
ibv_cqx -> start_poll = & efa_mock_ibv_start_poll_use_saved_send_wr_with_mock_status ;
857
+ ctx -> completion_flags = FI_SEND | FI_MSG ;
856
858
will_return (efa_mock_ibv_start_poll_use_saved_send_wr_with_mock_status , status );
857
859
}
860
+ ctx -> addr = * addr ;
861
+ ibv_cqx -> wr_id = (uintptr_t ) ctx ;
858
862
859
863
ibv_cqx -> next_poll = & efa_mock_ibv_next_poll_return_mock ;
860
864
ibv_cqx -> end_poll = & efa_mock_ibv_end_poll_check_mock ;
@@ -892,19 +896,29 @@ void test_efa_cq_read_send_success(struct efa_resource **state)
892
896
{
893
897
struct efa_resource * resource = * state ;
894
898
struct efa_unit_test_buff send_buff ;
899
+ struct efa_base_ep * base_ep ;
900
+ struct efa_context * efa_context ;
901
+ struct fi_context2 ctx ;
895
902
struct fi_cq_data_entry cq_entry ;
896
903
fi_addr_t addr ;
897
904
int ret ;
898
905
899
- test_efa_cq_read (resource , & addr , IBV_WC_SEND , IBV_WC_SUCCESS , 0 );
906
+ test_efa_cq_read (resource , & addr , IBV_WC_SEND , IBV_WC_SUCCESS , 0 ,
907
+ (struct efa_context * ) & ctx );
900
908
efa_unit_test_buff_construct (& send_buff , resource , 4096 /* buff_size */ );
901
909
902
910
assert_int_equal (g_ibv_submitted_wr_id_cnt , 0 );
903
911
ret = fi_send (resource -> ep , send_buff .buff , send_buff .size ,
904
- fi_mr_desc (send_buff .mr ), addr , ( void * ) 12345 );
912
+ fi_mr_desc (send_buff .mr ), addr , & ctx );
905
913
assert_int_equal (ret , 0 );
906
914
assert_int_equal (g_ibv_submitted_wr_id_cnt , 1 );
907
915
916
+ base_ep = container_of (resource -> ep , struct efa_base_ep , util_ep .ep_fid );
917
+ efa_context = (struct efa_context * ) base_ep -> qp -> ibv_qp_ex -> wr_id ;
918
+ assert_true (efa_context -> completion_flags & FI_SEND );
919
+ assert_true (efa_context -> completion_flags & FI_MSG );
920
+ assert_true (efa_context -> addr == addr );
921
+
908
922
ret = fi_cq_read (resource -> cq , & cq_entry , 1 );
909
923
/* fi_cq_read() called efa_mock_ibv_start_poll_use_saved_send_wr(), which pulled one send_wr from g_ibv_submitted_wr_idv=_vec */
910
924
assert_int_equal (g_ibv_submitted_wr_id_cnt , 0 );
@@ -921,17 +935,27 @@ void test_efa_cq_read_recv_success(struct efa_resource **state)
921
935
{
922
936
struct efa_resource * resource = * state ;
923
937
struct efa_unit_test_buff recv_buff ;
938
+ struct efa_base_ep * base_ep ;
939
+ struct efa_context * efa_context ;
924
940
struct fi_cq_data_entry cq_entry ;
941
+ struct fi_context2 ctx ;
925
942
fi_addr_t addr ;
926
943
int ret ;
927
944
928
- test_efa_cq_read (resource , & addr , IBV_WC_RECV , IBV_WC_SUCCESS , 0 );
945
+ test_efa_cq_read (resource , & addr , IBV_WC_RECV , IBV_WC_SUCCESS , 0 ,
946
+ (struct efa_context * ) & ctx );
929
947
efa_unit_test_buff_construct (& recv_buff , resource , 4096 /* buff_size */ );
930
948
931
949
ret = fi_recv (resource -> ep , recv_buff .buff , recv_buff .size ,
932
- fi_mr_desc (recv_buff .mr ), addr , NULL );
950
+ fi_mr_desc (recv_buff .mr ), addr , & ctx );
933
951
assert_int_equal (ret , 0 );
934
952
953
+ base_ep = container_of (resource -> ep , struct efa_base_ep , util_ep .ep_fid );
954
+ efa_context = (struct efa_context * ) base_ep -> efa_recv_wr_vec [base_ep -> recv_wr_index ].wr .wr_id ;
955
+ assert_true (efa_context -> completion_flags & FI_RECV );
956
+ assert_true (efa_context -> completion_flags & FI_MSG );
957
+ assert_true (efa_context -> addr == addr );
958
+
935
959
ret = fi_cq_read (resource -> cq , & cq_entry , 1 );
936
960
assert_int_equal (ret , 1 );
937
961
@@ -971,20 +995,29 @@ void test_efa_cq_read_send_failure(struct efa_resource **state)
971
995
{
972
996
struct efa_resource * resource = * state ;
973
997
struct efa_unit_test_buff send_buff ;
998
+ struct efa_base_ep * base_ep ;
999
+ struct efa_context * efa_context ;
974
1000
struct fi_cq_data_entry cq_entry ;
1001
+ struct fi_context2 ctx ;
975
1002
fi_addr_t addr ;
976
1003
int ret ;
977
1004
978
1005
test_efa_cq_read (resource , & addr , IBV_WC_SEND , IBV_WC_GENERAL_ERR ,
979
- EFA_IO_COMP_STATUS_LOCAL_ERROR_UNRESP_REMOTE );
1006
+ EFA_IO_COMP_STATUS_LOCAL_ERROR_UNRESP_REMOTE , ( struct efa_context * ) & ctx );
980
1007
efa_unit_test_buff_construct (& send_buff , resource , 4096 /* buff_size */ );
981
1008
982
1009
assert_int_equal (g_ibv_submitted_wr_id_cnt , 0 );
983
1010
ret = fi_send (resource -> ep , send_buff .buff , send_buff .size ,
984
- fi_mr_desc (send_buff .mr ), addr , ( void * ) 12345 );
1011
+ fi_mr_desc (send_buff .mr ), addr , & ctx );
985
1012
assert_int_equal (ret , 0 );
986
1013
assert_int_equal (g_ibv_submitted_wr_id_cnt , 1 );
987
1014
1015
+ base_ep = container_of (resource -> ep , struct efa_base_ep , util_ep .ep_fid );
1016
+ efa_context = (struct efa_context * ) base_ep -> qp -> ibv_qp_ex -> wr_id ;
1017
+ assert_true (efa_context -> completion_flags & FI_SEND );
1018
+ assert_true (efa_context -> completion_flags & FI_MSG );
1019
+ assert_true (efa_context -> addr == addr );
1020
+
988
1021
ret = fi_cq_read (resource -> cq , & cq_entry , 1 );
989
1022
/* fi_cq_read() called efa_mock_ibv_start_poll_use_saved_send_wr(), which pulled one send_wr from g_ibv_submitted_wr_idv=_vec */
990
1023
assert_int_equal (g_ibv_submitted_wr_id_cnt , 0 );
@@ -1008,18 +1041,27 @@ void test_efa_cq_read_recv_failure(struct efa_resource **state)
1008
1041
{
1009
1042
struct efa_resource * resource = * state ;
1010
1043
struct efa_unit_test_buff recv_buff ;
1044
+ struct efa_base_ep * base_ep ;
1045
+ struct efa_context * efa_context ;
1011
1046
struct fi_cq_data_entry cq_entry ;
1047
+ struct fi_context2 ctx ;
1012
1048
fi_addr_t addr ;
1013
1049
int ret ;
1014
1050
1015
1051
test_efa_cq_read (resource , & addr , IBV_WC_RECV , IBV_WC_GENERAL_ERR ,
1016
- EFA_IO_COMP_STATUS_LOCAL_ERROR_UNRESP_REMOTE );
1052
+ EFA_IO_COMP_STATUS_LOCAL_ERROR_UNRESP_REMOTE , ( struct efa_context * ) & ctx );
1017
1053
efa_unit_test_buff_construct (& recv_buff , resource , 4096 /* buff_size */ );
1018
1054
1019
1055
ret = fi_recv (resource -> ep , recv_buff .buff , recv_buff .size ,
1020
- fi_mr_desc (recv_buff .mr ), addr , NULL );
1056
+ fi_mr_desc (recv_buff .mr ), addr , & ctx );
1021
1057
assert_int_equal (ret , 0 );
1022
1058
1059
+ base_ep = container_of (resource -> ep , struct efa_base_ep , util_ep .ep_fid );
1060
+ efa_context = (struct efa_context * ) base_ep -> efa_recv_wr_vec [base_ep -> recv_wr_index ].wr .wr_id ;
1061
+ assert_true (efa_context -> completion_flags & FI_RECV );
1062
+ assert_true (efa_context -> completion_flags & FI_MSG );
1063
+ assert_true (efa_context -> addr == addr );
1064
+
1023
1065
ret = fi_cq_read (resource -> cq , & cq_entry , 1 );
1024
1066
assert_int_equal (ret , - FI_EAVAIL );
1025
1067
0 commit comments