summaryrefslogtreecommitdiff
path: root/source4/cluster/ctdb/ib/ibwrapper_internal.h
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-04-16 00:18:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:50:40 -0500
commitc9f04d8648cfdd573d45d47467bc964ef01f754d (patch)
tree115acf98b7b136f07dd8b16bbd50c9f7cbcdd3bb /source4/cluster/ctdb/ib/ibwrapper_internal.h
parentbb36705c8d360a2ba865a3d8118c52afa1e46f4e (diff)
downloadsamba-c9f04d8648cfdd573d45d47467bc964ef01f754d.tar.gz
samba-c9f04d8648cfdd573d45d47467bc964ef01f754d.tar.bz2
samba-c9f04d8648cfdd573d45d47467bc964ef01f754d.zip
r22231: merge from bzr ctdb tree
(This used to be commit 807b959082d3b9a929c9f6597714e636638a940e)
Diffstat (limited to 'source4/cluster/ctdb/ib/ibwrapper_internal.h')
-rw-r--r--source4/cluster/ctdb/ib/ibwrapper_internal.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/source4/cluster/ctdb/ib/ibwrapper_internal.h b/source4/cluster/ctdb/ib/ibwrapper_internal.h
new file mode 100644
index 0000000000..9c6bfab519
--- /dev/null
+++ b/source4/cluster/ctdb/ib/ibwrapper_internal.h
@@ -0,0 +1,127 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Wrap Infiniband calls.
+ *
+ * Copyright (C) Sven Oehme <oehmes@de.ibm.com> 2006
+ *
+ * Major code contributions by Peter Somogyi <psomogyi@gamax.hu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+struct ibw_opts {
+ uint32_t max_send_wr;
+ uint32_t max_recv_wr;
+ uint32_t recv_bufsize;
+ uint32_t recv_threshold;
+};
+
+struct ibw_wr {
+ char *buf; /* initialized in ibw_init_memory once per connection */
+ int wr_id; /* position in wr_index list; also used as wr id */
+
+ char *buf_large; /* allocated specially for "large" message */
+ struct ibv_mr *mr_large;
+ int ref_cnt; /* reference count for ibw_wc_send to know when to release */
+
+ char *queued_msg; /* set at ibw_send - can be different than above */
+ int queued_ref_cnt; /* instead of adding the same to the queue again */
+ uint32_t queued_rlen; /* last wins when queued_ref_cnt>0; or simple msg size */
+
+ struct ibw_wr *next, *prev; /* in wr_list_avail or wr_list_used */
+ /* or extra_sent or extra_avail */
+ struct ibw_wr *qnext, *qprev; /* in queue */
+};
+
+struct ibw_ctx_priv {
+ struct event_context *ectx;
+
+ struct ibw_opts opts;
+
+ struct rdma_cm_id *cm_id; /* server cm id */
+
+ struct rdma_event_channel *cm_channel;
+ struct fd_event *cm_channel_event;
+
+ ibw_connstate_fn_t connstate_func; /* see ibw_init */
+ ibw_receive_fn_t receive_func; /* see ibw_init */
+
+ long pagesize; /* sysconf result for memalign */
+};
+
+struct ibw_part {
+ char *buf; /* talloced memory buffer */
+ uint32_t bufsize; /* allocated size of buf - always grows */
+ uint32_t len; /* message part length */
+ uint32_t to_read; /* 4 or *((uint32_t)buf) if len>=sizeof(uint32_t) */
+};
+
+struct ibw_conn_priv {
+ struct ibv_comp_channel *verbs_channel;
+ struct fd_event *verbs_channel_event;
+
+ struct rdma_cm_id *cm_id; /* client's cm id */
+ struct ibv_pd *pd;
+ int is_accepted;
+
+ struct ibv_cq *cq; /* qp is in cm_id */
+
+ char *buf_send; /* max_send_wr * avg_send_size */
+ struct ibv_mr *mr_send;
+ struct ibw_wr *wr_list_avail;
+ struct ibw_wr *wr_list_used;
+ struct ibw_wr **wr_index; /* array[0..(qsize-1)] of (ibw_wr *) */
+ int wr_sent; /* # of send wrs in the CQ */
+
+ struct ibw_wr *extra_sent;
+ struct ibw_wr *extra_avail;
+ int extra_max; /* max wr_id in the queue */
+
+ struct ibw_wr *queue;
+
+ /* buf_recv is a ring buffer */
+ char *buf_recv; /* max_recv_wr * avg_recv_size */
+ struct ibv_mr *mr_recv;
+ int recv_index; /* index of the next recv buffer when refilling */
+ struct ibw_part part;
+};
+
+/* remove an element from a list - element doesn't have to be in list. */
+#define DLIST_REMOVE2(list, p, prev, next) \
+do { \
+ if ((p) == (list)) { \
+ (list) = (p)->next; \
+ if (list) (list)->prev = NULL; \
+ } else { \
+ if ((p)->prev) (p)->prev->next = (p)->next; \
+ if ((p)->next) (p)->next->prev = (p)->prev; \
+ } \
+ if ((p) != (list)) (p)->next = (p)->prev = NULL; \
+} while (0)
+
+/* hook into the end of the list - needs a tmp pointer */
+#define DLIST_ADD_END2(list, p, type, prev, next) \
+do { \
+ if (!(list)) { \
+ (list) = (p); \
+ (p)->next = (p)->prev = NULL; \
+ } else { \
+ type tmp; \
+ for (tmp = (list); tmp->next; tmp = tmp->next) ; \
+ tmp->next = (p); \
+ (p)->next = NULL; \
+ (p)->prev = tmp; \
+ } \
+} while (0)