1 /*
2 * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2006 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2006 QLogic Corporation. All rights reserved.
13 * Copyright (c) 2015 Intel, Inc. All rights reserved
14 * $COPYRIGHT$
15 *
16 * Additional copyrights may follow
17 *
18 * $HEADER$
19 */
20
21 #include "ompi_config.h"
22 #include "mtl_psm2.h"
23 #include "mtl_psm2_request.h"
24
25 int ompi_mtl_psm2_cancel(struct mca_mtl_base_module_t* mtl,
26 struct mca_mtl_request_t *mtl_request,
27 int flag) {
28
29 psm2_error_t err;
30 psm2_mq_status_t status;
31
32 mca_mtl_psm2_request_t *mtl_psm2_request =
33 (mca_mtl_psm2_request_t*) mtl_request;
34
35 /* PSM2 does not support canceling sends */
36 if(OMPI_mtl_psm2_ISEND == mtl_psm2_request->type) {
37 return OMPI_SUCCESS;
38 }
39
40 err = psm2_mq_cancel(&mtl_psm2_request->psm2_request);
41 if(PSM2_OK == err) {
42 err = psm2_mq_test(&mtl_psm2_request->psm2_request, &status);
43 if(PSM2_OK == err) {
44 mtl_request->ompi_req->req_status._cancelled = true;
45 mtl_psm2_request->super.completion_callback(&mtl_psm2_request->super);
46 return OMPI_SUCCESS;
47 } else {
48 return OMPI_ERROR;
49 }
50 } else if(PSM2_MQ_INCOMPLETE == err) {
51 return OMPI_SUCCESS;
52 }
53
54 return OMPI_ERROR;
55 }