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 #ifdef HAVE_VALGRIND_MEMCHECK_H
43 # include <valgrind/memcheck.h>
45 # ifndef VALGRIND_MAKE_MEM_DEFINED
46 # warning "Valgrind support requested, but VALGRIND_MAKE_MEM_DEFINED not available"
49 #endif /* HAVE_VALGRIND_MEMCHECK_H */
51 #ifndef VALGRIND_MAKE_MEM_DEFINED
52 # define VALGRIND_MAKE_MEM_DEFINED(addr, len)
55 #define HIDDEN __attribute__((visibility ("hidden")))
57 #define INIT __attribute__((constructor))
58 #define FINI __attribute__((destructor))
60 #define DEFAULT_ABI "IBVERBS_1.1"
62 #ifdef HAVE_SYMVER_SUPPORT
63 # define symver(name, api, ver) \
64 asm(".symver " #name "," #api "@" #ver)
65 # define default_symver(name, api) \
66 asm(".symver " #name "," #api "@@" DEFAULT_ABI)
68 # define symver(name, api, ver)
69 # define default_symver(name, api) \
70 extern __typeof(name) api __attribute__((alias(#name)))
71 #endif /* HAVE_SYMVER_SUPPORT */
73 #define PFX "libibverbs: "
75 struct ibv_abi_compat_v2 {
76 struct ibv_comp_channel channel;
77 pthread_mutex_t in_use;
80 extern HIDDEN int abi_ver;
82 HIDDEN int ibverbs_init(struct ibv_device ***list);
84 #define IBV_INIT_CMD(cmd, size, opcode) \
87 (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
89 (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
90 (cmd)->in_words = (size) / 4; \
91 (cmd)->out_words = 0; \
94 #define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \
97 (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
99 (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
100 (cmd)->in_words = (size) / 4; \
101 (cmd)->out_words = (outsize) / 4; \
102 (cmd)->response = (uintptr_t) (out); \
105 #endif /* IB_VERBS_H */