1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4 * University Research and Technology
5 * Corporation. All rights reserved.
6 * Copyright (c) 2004-2019 The University of Tennessee and The University
7 * of Tennessee Research Foundation. All rights
8 * reserved.
9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 * University of Stuttgart. All rights reserved.
11 * Copyright (c) 2004-2005 The Regents of the University of California.
12 * All rights reserved.
13 * Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
14 * reserved.
15 * $COPYRIGHT$
16 *
17 * Additional copyrights may follow
18 *
19 * $HEADER$
20 */
21 /**
22 * @file
23 */
24
25 #ifndef MCA_PML_OB1_RDMAFRAG_H
26 #define MCA_PML_OB1_RDMAFRAG_H
27
28 #include "pml_ob1_hdr.h"
29
30 BEGIN_C_DECLS
31
32 typedef enum {
33 MCA_PML_OB1_RDMA_PUT,
34 MCA_PML_OB1_RDMA_GET
35 } mca_pml_ob1_rdma_state_t;
36
37 struct mca_pml_ob1_rdma_frag_t;
38
39 typedef void (*mca_pml_ob1_rdma_frag_callback_t)(struct mca_pml_ob1_rdma_frag_t *frag, int64_t rdma_length);
40
41 /**
42 * Used to keep track of local and remote RDMA operations.
43 */
44 struct mca_pml_ob1_rdma_frag_t {
45 opal_free_list_item_t super;
46 mca_bml_base_btl_t *rdma_bml;
47 mca_pml_ob1_hdr_t rdma_hdr;
48 mca_pml_ob1_rdma_state_t rdma_state;
49 size_t rdma_length; /* how much the fragment will transfer */
50 opal_atomic_size_t rdma_bytes_remaining; /* how much is left to be transferred */
51 void *rdma_req;
52 uint32_t retries;
53 mca_pml_ob1_rdma_frag_callback_t cbfunc;
54
55 uint64_t rdma_offset;
56 void *local_address;
57 mca_btl_base_registration_handle_t *local_handle;
58
59 uint64_t remote_address;
60 uint8_t remote_handle[MCA_BTL_REG_HANDLE_MAX_SIZE];
61 };
62 typedef struct mca_pml_ob1_rdma_frag_t mca_pml_ob1_rdma_frag_t;
63
64 OBJ_CLASS_DECLARATION(mca_pml_ob1_rdma_frag_t);
65
66
67 #define MCA_PML_OB1_RDMA_FRAG_ALLOC(frag) \
68 do { \
69 frag = (mca_pml_ob1_rdma_frag_t *) \
70 opal_free_list_wait (&mca_pml_ob1.rdma_frags); \
71 } while(0)
72
73 #define MCA_PML_OB1_RDMA_FRAG_RETURN(frag) \
74 do { \
75 if (frag->local_handle) { \
76 mca_bml_base_deregister_mem (frag->rdma_bml, frag->local_handle); \
77 frag->local_handle = NULL; \
78 } \
79 opal_free_list_return (&mca_pml_ob1.rdma_frags, \
80 (opal_free_list_item_t*)frag); \
81 } while (0)
82
83 END_C_DECLS
84
85 #endif
86