1/* 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 4 * 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: 10 * 11 * Redistribution and use in source and binary forms, with or 12 * without modification, are permitted provided that the following 13 * conditions are met: 14 * 15 * - Redistributions of source code must retain the above 16 * copyright notice, this list of conditions and the following 17 * disclaimer. 18 * 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. 23 * 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 31 * SOFTWARE. 32 */ 33 34#ifndef IB_VERBS_H 35#define IB_VERBS_H 36 37#include <pthread.h> 38 39#include <infiniband/driver.h> 40 41#ifdef HAVE_VALGRIND_MEMCHECK_H 42 43# include <valgrind/memcheck.h> 44 45# ifndef VALGRIND_MAKE_MEM_DEFINED 46# warning "Valgrind support requested, but VALGRIND_MAKE_MEM_DEFINED not available" 47# endif 48 49#endif /* HAVE_VALGRIND_MEMCHECK_H */ 50 51#ifndef VALGRIND_MAKE_MEM_DEFINED 52# define VALGRIND_MAKE_MEM_DEFINED(addr, len) 53#endif 54 55#define HIDDEN __attribute__((visibility ("hidden"))) 56 57#define INIT __attribute__((constructor)) 58#define FINI __attribute__((destructor)) 59 60#define DEFAULT_ABI "IBVERBS_1.1" 61 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) 67#else 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 */ 72 73#define PFX "libibverbs: " 74 75struct ibv_abi_compat_v2 { 76 struct ibv_comp_channel channel; 77 pthread_mutex_t in_use; 78}; 79 80extern HIDDEN int abi_ver; 81 82HIDDEN int ibverbs_init(struct ibv_device ***list); 83 84#define IBV_INIT_CMD(cmd, size, opcode) \ 85 do { \ 86 if (abi_ver > 2) \ 87 (cmd)->command = IB_USER_VERBS_CMD_##opcode; \ 88 else \ 89 (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \ 90 (cmd)->in_words = (size) / 4; \ 91 (cmd)->out_words = 0; \ 92 } while (0) 93 94#define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \ 95 do { \ 96 if (abi_ver > 2) \ 97 (cmd)->command = IB_USER_VERBS_CMD_##opcode; \ 98 else \ 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); \ 103 } while (0) 104 105#endif /* IB_VERBS_H */ 106