1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2022, Intel Corporation */
/*
* receive-completion-queue-common.c -- a common declarations for the 12 example
*/
#include <librpma.h>
#include <inttypes.h>
#include "receive-completion-queue-common.h"
int
get_wc_and_validate(struct rpma_cq *cq, enum ibv_wc_opcode opcode,
char *func_name)
{
struct ibv_wc wc;
int ret = rpma_cq_wait(cq);
if (ret)
return ret;
ret = rpma_cq_get_wc(cq, 1, &wc, NULL);
if (ret)
return ret;
if (wc.status != IBV_WC_SUCCESS) {
(void) fprintf(stderr, "%s failed: %s\n",
func_name, ibv_wc_status_str(wc.status));
return -1;
}
if (wc.opcode != opcode) {
(void) fprintf(stderr, "unexpected wc.opcode value "
"(0x%" PRIXPTR " != 0x%" PRIXPTR ")\n",
(uintptr_t)wc.opcode, (uintptr_t)opcode);
return -1;
}
return 0;
}
|