a879427a115ffdb49214480e40a03b62e891af6f
[vlendec/samba-autobuild/.git] / ctdb / ib / ibwrapper_internal.h
1 /*
2  * Unix SMB/CIFS implementation.
3  * Wrap Infiniband calls.
4  *
5  * Copyright (C) Sven Oehme <oehmes@de.ibm.com> 2006
6  *
7  * Major code contributions by Peter Somogyi <psomogyi@gamax.hu>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 struct ibw_opts {
25         uint32_t        max_send_wr;
26         uint32_t        max_recv_wr;
27         uint32_t        avg_send_size;
28         uint32_t        recv_bufsize;
29         uint32_t        recv_threshold;
30 };
31
32 struct ibw_wr {
33         char    *msg; /* initialized in ibw_init_memory once per connection */
34         int     wr_id; /* position in wr_index list; also used as wr id */
35
36         char    *msg_large; /* allocated specially for "large" message */
37         struct ibv_mr *mr_large;
38
39         char    *queued_msg; /* set at ibw_send - can be different than above */
40
41         struct ibw_wr *next, *prev; /* in wr_list_avail or wr_list_used */
42 };
43
44 struct ibw_ctx_priv {
45         struct event_context *ectx;
46
47         struct ibw_opts opts;
48
49         struct rdma_cm_id       *cm_id; /* server cm id */
50
51         struct rdma_event_channel *cm_channel;
52         struct fd_event *cm_channel_event;
53
54         ibw_connstate_fn_t connstate_func; /* see ibw_init */
55         ibw_receive_fn_t receive_func; /* see ibw_init */
56
57         long    pagesize; /* sysconf result for memalign */
58 };
59
60 struct ibw_part {
61         char *buf; /* talloced memory buffer */
62         uint32_t bufsize; /* allocated size of buf - always grows */
63         uint32_t len; /* message part length */
64         uint32_t to_read; /* 4 or *((uint32_t)buf) if len>=sizeof(uint32_t) */
65 };
66
67 struct ibw_conn_priv {
68         struct ibv_comp_channel *verbs_channel;
69         struct fd_event *verbs_channel_event;
70
71         struct rdma_cm_id *cm_id; /* client's cm id */
72         struct ibv_pd   *pd;
73         int     is_accepted;
74
75         struct ibv_cq   *cq; /* qp is in cm_id */
76
77         char *buf_send; /* max_send_wr * avg_send_size */
78         struct ibv_mr *mr_send;
79         struct ibw_wr *wr_list_avail;
80         struct ibw_wr *wr_list_used;
81         struct ibw_wr **wr_index; /* array[0..(qsize-1)] of (ibw_wr *) */
82         int     wr_sent; /* # of send wrs in the CQ */
83
84         struct ibw_wr *queue;
85         struct ibw_wr *extra_sent;
86         struct ibw_wr *extra_avail;
87         int     extra_max; /* max wr_id in the queue */
88
89         /* buf_recv is a ring buffer */
90         char *buf_recv; /* max_recv_wr * avg_recv_size */
91         struct ibv_mr *mr_recv;
92         int recv_index; /* index of the next recv buffer when refilling */
93         struct ibw_part part;
94 };
95