2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39 #include <infiniband/driver.h>
41 #define INIT __attribute__((constructor))
43 #define DEFAULT_ABI "IBVERBS_1.1"
45 #define symver(name, api, ver) asm(".symver " #name "," #api "@" #ver)
46 #define default_symver(name, api) \
47 asm(".symver " #name "," #api "@@" DEFAULT_ABI)
48 #define private_symver(name, api) \
49 asm(".symver " #name "," #api "@@IBVERBS_PRIVATE_14")
51 #define PFX "libibverbs: "
53 struct ibv_abi_compat_v2 {
54 struct ibv_comp_channel channel;
55 pthread_mutex_t in_use;
60 int ibverbs_init(struct ibv_device ***list);
62 struct verbs_ex_private {
63 struct ibv_cq_ex *(*create_cq_ex)(struct ibv_context *context,
64 struct ibv_cq_init_attr_ex *init_attr);
67 #define IBV_INIT_CMD(cmd, size, opcode) \
70 (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
72 (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
73 (cmd)->in_words = (size) / 4; \
74 (cmd)->out_words = 0; \
77 #define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \
80 (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
82 (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
83 (cmd)->in_words = (size) / 4; \
84 (cmd)->out_words = (outsize) / 4; \
85 (cmd)->response = (uintptr_t) (out); \
88 #define IBV_INIT_CMD_RESP_EX_V(cmd, cmd_size, size, opcode, out, resp_size,\
91 size_t c_size = cmd_size - sizeof(struct ex_hdr); \
93 (cmd)->hdr.command = IB_USER_VERBS_CMD_##opcode; \
95 (cmd)->hdr.command = \
96 IB_USER_VERBS_CMD_##opcode##_V2; \
97 (cmd)->hdr.in_words = ((c_size) / 8); \
98 (cmd)->hdr.out_words = ((resp_size) / 8); \
99 (cmd)->hdr.provider_in_words = (((size) - (cmd_size))/8);\
100 (cmd)->hdr.provider_out_words = \
101 (((outsize) - (resp_size)) / 8); \
102 (cmd)->hdr.response = (uintptr_t) (out); \
103 (cmd)->hdr.reserved = 0; \
106 #define IBV_INIT_CMD_RESP_EX_VCMD(cmd, cmd_size, size, opcode, out, outsize) \
107 IBV_INIT_CMD_RESP_EX_V(cmd, cmd_size, size, opcode, out, \
108 sizeof(*(out)), outsize)
110 #define IBV_INIT_CMD_RESP_EX(cmd, size, opcode, out, outsize) \
111 IBV_INIT_CMD_RESP_EX_V(cmd, sizeof(*(cmd)), size, opcode, out, \
112 sizeof(*(out)), outsize)
114 #define IBV_INIT_CMD_EX(cmd, size, opcode) \
115 IBV_INIT_CMD_RESP_EX_V(cmd, sizeof(*(cmd)), size, opcode, NULL, 0, 0)
117 #endif /* IB_VERBS_H */