1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3219820Sjeff * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 4219820Sjeff * 5219820Sjeff * This software is available to you under a choice of one of two 6219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 7219820Sjeff * General Public License (GPL) Version 2, available from the file 8219820Sjeff * COPYING in the main directory of this source tree, or the 9219820Sjeff * OpenIB.org BSD license below: 10219820Sjeff * 11219820Sjeff * Redistribution and use in source and binary forms, with or 12219820Sjeff * without modification, are permitted provided that the following 13219820Sjeff * conditions are met: 14219820Sjeff * 15219820Sjeff * - Redistributions of source code must retain the above 16219820Sjeff * copyright notice, this list of conditions and the following 17219820Sjeff * disclaimer. 18219820Sjeff * 19219820Sjeff * - Redistributions in binary form must reproduce the above 20219820Sjeff * copyright notice, this list of conditions and the following 21219820Sjeff * disclaimer in the documentation and/or other materials 22219820Sjeff * provided with the distribution. 23219820Sjeff * 24219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 28219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 29219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31219820Sjeff * SOFTWARE. 32219820Sjeff */ 33219820Sjeff 34219820Sjeff#ifndef IB_VERBS_H 35219820Sjeff#define IB_VERBS_H 36219820Sjeff 37219820Sjeff#include <pthread.h> 38219820Sjeff 39219820Sjeff#include <infiniband/driver.h> 40219820Sjeff 41219820Sjeff#ifdef HAVE_VALGRIND_MEMCHECK_H 42219820Sjeff 43219820Sjeff# include <valgrind/memcheck.h> 44219820Sjeff 45219820Sjeff# ifndef VALGRIND_MAKE_MEM_DEFINED 46219820Sjeff# warning "Valgrind support requested, but VALGRIND_MAKE_MEM_DEFINED not available" 47219820Sjeff# endif 48219820Sjeff 49219820Sjeff#endif /* HAVE_VALGRIND_MEMCHECK_H */ 50219820Sjeff 51219820Sjeff#ifndef VALGRIND_MAKE_MEM_DEFINED 52219820Sjeff# define VALGRIND_MAKE_MEM_DEFINED(addr, len) 53219820Sjeff#endif 54219820Sjeff 55219820Sjeff#define HIDDEN __attribute__((visibility ("hidden"))) 56219820Sjeff 57219820Sjeff#define INIT __attribute__((constructor)) 58219820Sjeff#define FINI __attribute__((destructor)) 59219820Sjeff 60219820Sjeff#define DEFAULT_ABI "IBVERBS_1.1" 61219820Sjeff 62219820Sjeff#ifdef HAVE_SYMVER_SUPPORT 63219820Sjeff# define symver(name, api, ver) \ 64219820Sjeff asm(".symver " #name "," #api "@" #ver) 65219820Sjeff# define default_symver(name, api) \ 66219820Sjeff asm(".symver " #name "," #api "@@" DEFAULT_ABI) 67219820Sjeff#else 68219820Sjeff# define symver(name, api, ver) 69219820Sjeff# define default_symver(name, api) \ 70219820Sjeff extern __typeof(name) api __attribute__((alias(#name))) 71219820Sjeff#endif /* HAVE_SYMVER_SUPPORT */ 72219820Sjeff 73219820Sjeff#define PFX "libibverbs: " 74219820Sjeff 75219820Sjeffstruct ibv_abi_compat_v2 { 76219820Sjeff struct ibv_comp_channel channel; 77219820Sjeff pthread_mutex_t in_use; 78219820Sjeff}; 79219820Sjeff 80219820Sjeffextern HIDDEN int abi_ver; 81219820Sjeff 82219820SjeffHIDDEN int ibverbs_init(struct ibv_device ***list); 83219820Sjeff 84219820Sjeff#define IBV_INIT_CMD(cmd, size, opcode) \ 85219820Sjeff do { \ 86219820Sjeff if (abi_ver > 2) \ 87219820Sjeff (cmd)->command = IB_USER_VERBS_CMD_##opcode; \ 88219820Sjeff else \ 89219820Sjeff (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \ 90219820Sjeff (cmd)->in_words = (size) / 4; \ 91219820Sjeff (cmd)->out_words = 0; \ 92219820Sjeff } while (0) 93219820Sjeff 94219820Sjeff#define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \ 95219820Sjeff do { \ 96219820Sjeff if (abi_ver > 2) \ 97219820Sjeff (cmd)->command = IB_USER_VERBS_CMD_##opcode; \ 98219820Sjeff else \ 99219820Sjeff (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \ 100219820Sjeff (cmd)->in_words = (size) / 4; \ 101219820Sjeff (cmd)->out_words = (outsize) / 4; \ 102219820Sjeff (cmd)->response = (uintptr_t) (out); \ 103219820Sjeff } while (0) 104219820Sjeff 105219820Sjeff#endif /* IB_VERBS_H */ 106