param: Rename variable used for lp_interfaces szInterfaces
[Samba.git] / ctdb / ib / ibwrapper_internal.h
blob20aef7fd86b83b8a17b54a3558235855b8d2becd
1 /*
2 * Unix SMB/CIFS implementation.
3 * Wrap Infiniband calls.
5 * Copyright (C) Sven Oehme <oehmes@de.ibm.com> 2006
7 * Major code contributions by Peter Somogyi <psomogyi@gamax.hu>
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 3 of the License, or
12 * (at your option) any later version.
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.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
23 struct ibw_opts {
24 uint32_t max_send_wr;
25 uint32_t max_recv_wr;
26 uint32_t recv_bufsize;
27 uint32_t recv_threshold;
30 struct ibw_wr {
31 char *buf; /* initialized in ibw_init_memory once per connection */
32 int wr_id; /* position in wr_index list; also used as wr id */
34 char *buf_large; /* allocated specially for "large" message */
35 struct ibv_mr *mr_large;
36 int ref_cnt; /* reference count for ibw_wc_send to know when to release */
38 char *queued_msg; /* set at ibw_send - can be different than above */
39 int queued_ref_cnt; /* instead of adding the same to the queue again */
40 uint32_t queued_rlen; /* last wins when queued_ref_cnt>0; or simple msg size */
42 struct ibw_wr *next, *prev; /* in wr_list_avail or wr_list_used */
43 /* or extra_sent or extra_avail */
44 struct ibw_wr *qnext, *qprev; /* in queue */
47 struct ibw_ctx_priv {
48 struct event_context *ectx;
50 struct ibw_opts opts;
52 struct rdma_cm_id *cm_id; /* server cm id */
54 struct rdma_event_channel *cm_channel;
55 struct fd_event *cm_channel_event;
57 ibw_connstate_fn_t connstate_func; /* see ibw_init */
58 ibw_receive_fn_t receive_func; /* see ibw_init */
60 long pagesize; /* sysconf result for memalign */
63 struct ibw_part {
64 char *buf; /* talloced memory buffer */
65 uint32_t bufsize; /* allocated size of buf - always grows */
66 uint32_t len; /* message part length */
67 uint32_t to_read; /* 4 or *((uint32_t)buf) if len>=sizeof(uint32_t) */
70 struct ibw_conn_priv {
71 struct ibv_comp_channel *verbs_channel;
72 struct fd_event *verbs_channel_event;
74 struct rdma_cm_id *cm_id; /* client's cm id */
75 struct ibv_pd *pd;
76 int is_accepted;
78 struct ibv_cq *cq; /* qp is in cm_id */
80 char *buf_send; /* max_send_wr * avg_send_size */
81 struct ibv_mr *mr_send;
82 struct ibw_wr *wr_list_avail;
83 struct ibw_wr *wr_list_used;
84 struct ibw_wr **wr_index; /* array[0..(qsize-1)] of (ibw_wr *) */
85 int wr_sent; /* # of send wrs in the CQ */
87 struct ibw_wr *extra_sent;
88 struct ibw_wr *extra_avail;
89 int extra_max; /* max wr_id in the queue */
91 struct ibw_wr *queue;
93 /* buf_recv is a ring buffer */
94 char *buf_recv; /* max_recv_wr * avg_recv_size */
95 struct ibv_mr *mr_recv;
96 int recv_index; /* index of the next recv buffer when refilling */
97 struct ibw_part part;
100 /* remove an element from a list - element doesn't have to be in list. */
101 #define DLIST_REMOVE2(list, p, prev, next) \
102 do { \
103 if ((p) == (list)) { \
104 (list) = (p)->next; \
105 if (list) (list)->prev = NULL; \
106 } else { \
107 if ((p)->prev) (p)->prev->next = (p)->next; \
108 if ((p)->next) (p)->next->prev = (p)->prev; \
110 if ((p) != (list)) (p)->next = (p)->prev = NULL; \
111 } while (0)
113 /* hook into the end of the list - needs a tmp pointer */
114 #define DLIST_ADD_END2(list, p, type, prev, next) \
115 do { \
116 if (!(list)) { \
117 (list) = (p); \
118 (p)->next = (p)->prev = NULL; \
119 } else { \
120 type tmp; \
121 for (tmp = (list); tmp->next; tmp = tmp->next) ; \
122 tmp->next = (p); \
123 (p)->next = NULL; \
124 (p)->prev = tmp; \
126 } while (0)