From 042d9cc0be2768f8535aa24ef2a5aa7c81663f62 Mon Sep 17 00:00:00 2001 From: Tomasz Gromadzki Date: Wed, 29 Jun 2022 17:52:40 +0200 Subject: [PATCH] rpma: add flags argument to rpma_conn_wait() https://github.com/pmem/rpma/issues/1743 will be implemented later. This PR introduces only the flags argument to be able to merge all new examples with the new API. --- examples/06s-multiple-connections/server.c | 2 +- examples/common/common-conn.c | 2 +- src/conn.c | 11 ++++++----- src/include/librpma.h | 14 ++++++-------- tests/unit/conn/conn-wait.c | 16 ++++++++-------- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/examples/06s-multiple-connections/server.c b/examples/06s-multiple-connections/server.c index c6d4e4a55a..c3d1018390 100644 --- a/examples/06s-multiple-connections/server.c +++ b/examples/06s-multiple-connections/server.c @@ -237,7 +237,7 @@ client_handle_completion(struct custom_event *ce) struct rpma_cq *cq = NULL; /* wait for the completion to be ready */ - int ret = rpma_conn_wait(clnt->conn, &cq, NULL); + int ret = rpma_conn_wait(clnt->conn, 0, &cq, NULL); if (ret) { /* no completion is ready - continue */ if (ret == RPMA_E_NO_COMPLETION) diff --git a/examples/common/common-conn.c b/examples/common/common-conn.c index 5fa816b998..1c0d6010ff 100644 --- a/examples/common/common-conn.c +++ b/examples/common/common-conn.c @@ -207,7 +207,7 @@ wait_and_validate_completion(struct rpma_conn *conn, enum ibv_wc_opcode expected struct rpma_cq *cq = NULL; int ret; - if ((ret = rpma_conn_wait(conn, &cq, NULL))) + if ((ret = rpma_conn_wait(conn, 0, &cq, NULL))) return ret; if ((ret = rpma_cq_get_wc(cq, 1, wc, NULL))) return ret; diff --git a/src/conn.c b/src/conn.c index 2a0aeb8960..01277ddb62 100644 --- a/src/conn.c +++ b/src/conn.c @@ -223,13 +223,14 @@ rpma_conn_next_event(struct rpma_conn *conn, enum rpma_conn_event *event) } /* - * rpma_conn_wait -- wait for a completion event on the shared completion - * channel from CQ or RCQ, ack it and return a CQ that caused the event - * in the cq argument and a boolean value saying if it is RCQ or not - * in the is_rcq argument (if is_rcq is not NULL) + * rpma_conn_wait -- wait for a completion event on the shared completion channel from CQ or RCQ, + * ack it and return a CQ that caused the event in the cq argument and a boolean value saying + * if it is RCQ or not in the is_rcq argument (if is_rcq is not NULL), + * the flags argument is added to ensure backward compatibility in the future when + * https://github.com/pmem/rpma/issues/1743 is implemented */ int -rpma_conn_wait(struct rpma_conn *conn, struct rpma_cq **cq, bool *is_rcq) +rpma_conn_wait(struct rpma_conn *conn, int flags, struct rpma_cq **cq, bool *is_rcq) { RPMA_DEBUG_TRACE; RPMA_FAULT_INJECTION(RPMA_E_NO_COMPLETION, {}); diff --git a/src/include/librpma.h b/src/include/librpma.h index 63376a678e..012a459bbf 100644 --- a/src/include/librpma.h +++ b/src/include/librpma.h @@ -2143,15 +2143,13 @@ int rpma_conn_get_compl_fd(const struct rpma_conn *conn, int *fd); * * struct rpma_conn; * struct rpma_cq - * int rpma_conn_wait(struct rpma_conn *conn, struct rpma_cq **cq, bool *is_rcq) + * int rpma_conn_wait(struct rpma_conn *conn, int flags, struct rpma_cq **cq, bool *is_rcq) * * DESCRIPTION - * rpma_conn_wait() waits for a completion event on the shared completion - * channel from CQ or RCQ, acks it and returns a CQ that caused the event - * in the cq argument and a boolean value saying if it is RCQ or not - * in the is_rcq argument (if is_rcq is not NULL). If rpma_conn_wait() succeeds, - * then all available completions should be collected from the returned cq - * using rpma_cq_get_wc(3). + * rpma_conn_wait() waits for a completion event on the shared completion channel from CQ or RCQ, + * acks it and returns a CQ that caused the event in the cq argument and a boolean value saying + * if it is RCQ or not in the is_rcq argument (if is_rcq is not NULL). If rpma_conn_wait() succeeds, + * then all available completions should be collected from the returned cq using rpma_cq_get_wc(3). * * RETURN VALUE * The rpma_conn_wait() function returns 0 on success or a negative @@ -2169,7 +2167,7 @@ int rpma_conn_get_compl_fd(const struct rpma_conn *conn, int *fd); * SEE ALSO * rpma_conn_req_new(3), librpma(7) and https://pmem.io/rpma/ */ -int rpma_conn_wait(struct rpma_conn *conn, struct rpma_cq **cq, bool *is_rcq); +int rpma_conn_wait(struct rpma_conn *conn, int flags, struct rpma_cq **cq, bool *is_rcq); /** 3 * rpma_conn_req_recv - initiate the receive operation diff --git a/tests/unit/conn/conn-wait.c b/tests/unit/conn/conn-wait.c index ba27f6b9d4..2ac57bf2e0 100644 --- a/tests/unit/conn/conn-wait.c +++ b/tests/unit/conn/conn-wait.c @@ -22,7 +22,7 @@ wait__conn_NULL(void **unused) /* run test */ struct rpma_cq *cq = NULL; bool is_rcq; - int ret = rpma_conn_wait(NULL, &cq, &is_rcq); + int ret = rpma_conn_wait(NULL, 0, &cq, &is_rcq); /* verify the results */ assert_int_equal(ret, RPMA_E_INVAL); @@ -37,7 +37,7 @@ wait__cq_NULL(void **unused) { /* run test */ bool is_rcq; - int ret = rpma_conn_wait(MOCK_CONN, NULL, &is_rcq); + int ret = rpma_conn_wait(MOCK_CONN, 0, NULL, &is_rcq); /* verify the results */ assert_int_equal(ret, RPMA_E_INVAL); @@ -54,7 +54,7 @@ wait__channel_not_shared(void **cstate_ptr) /* run test */ struct rpma_cq *cq = NULL; bool is_rcq; - int ret = rpma_conn_wait(cstate->conn, &cq, &is_rcq); + int ret = rpma_conn_wait(cstate->conn, 0, &cq, &is_rcq); /* verify the results */ assert_int_equal(ret, RPMA_E_NOT_SHARED_CHNL); @@ -76,7 +76,7 @@ wait__get_cq_event_ERRNO(void **cstate_ptr) /* run test */ struct rpma_cq *cq = NULL; bool is_rcq; - int ret = rpma_conn_wait(cstate->conn, &cq, &is_rcq); + int ret = rpma_conn_wait(cstate->conn, 0, &cq, &is_rcq); /* verify the results */ assert_int_equal(ret, RPMA_E_NO_COMPLETION); @@ -103,7 +103,7 @@ wait__get_cq_event_UNKNOWN(void **cstate_ptr) /* run test */ struct rpma_cq *cq = NULL; bool is_rcq; - int ret = rpma_conn_wait(cstate->conn, &cq, &is_rcq); + int ret = rpma_conn_wait(cstate->conn, 0, &cq, &is_rcq); /* verify the results */ assert_int_equal(ret, RPMA_E_UNKNOWN); @@ -131,7 +131,7 @@ wait__req_notify_cq_ERRNO(void **cstate_ptr) /* run test */ struct rpma_cq *cq = NULL; bool is_rcq; - int ret = rpma_conn_wait(cstate->conn, &cq, &is_rcq); + int ret = rpma_conn_wait(cstate->conn, 0, &cq, &is_rcq); /* verify the results */ assert_int_equal(ret, RPMA_E_PROVIDER); @@ -161,7 +161,7 @@ wait__success_is_rcq_NULL(void **cstate_ptr) /* run test */ struct rpma_cq *cq = NULL; - int ret = rpma_conn_wait(cstate->conn, &cq, NULL); + int ret = rpma_conn_wait(cstate->conn, 0, &cq, NULL); /* verify the results */ assert_int_equal(ret, MOCK_OK); assert_ptr_equal(cq, MOCK_RPMA_RCQ); @@ -190,7 +190,7 @@ wait__success(void **cstate_ptr) /* run test */ struct rpma_cq *cq = NULL; bool is_rcq; - int ret = rpma_conn_wait(cstate->conn, &cq, &is_rcq); + int ret = rpma_conn_wait(cstate->conn, 0, &cq, &is_rcq); /* verify the results */ assert_int_equal(ret, MOCK_OK);