diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f8149d4a..cc47105a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,10 +150,6 @@ add_dependencies(hermit libiomp) build_external(ircce ${HERMIT_ROOT}/usr/ircce "") add_dependencies(hermit ircce) -## Infiniband -build_external(rdma ${HERMIT_ROOT}/usr/rdma-core "") -add_dependencies(hermit rdma) - ## XRay profiler build_external(xray ${HERMIT_ROOT}/usr/xray "") add_dependencies(hermit xray) diff --git a/include/hermit/ibv.h b/include/hermit/ibv.h index 2f5ea1c5f..8de3a8ef9 100644 --- a/include/hermit/ibv.h +++ b/include/hermit/ibv.h @@ -34,7 +34,7 @@ #ifndef __IBV_H__ #define __IBV_H__ -//#include // GEHT NICHT aus x86_64-hermit/include heraus. +#include #ifdef __cplusplus extern "C" { diff --git a/include/hermit/limits.h b/include/hermit/limits.h new file mode 100644 index 000000000..dd09c1cee --- /dev/null +++ b/include/hermit/limits.h @@ -0,0 +1,146 @@ +#ifndef _LIBC_LIMITS_H_ +# define _LIBC_LIMITS_H_ 1 + +#include +#include + +# ifdef _MB_LEN_MAX +# define MB_LEN_MAX _MB_LEN_MAX +# else +# define MB_LEN_MAX 1 +# endif + +/* Maximum number of positional arguments, if _WANT_IO_POS_ARGS. */ +# ifndef NL_ARGMAX +# define NL_ARGMAX 32 +# endif + +/* if do not have #include_next support, then we + have to define the limits here. */ +# if !defined __GNUC__ || __GNUC__ < 2 + +# ifndef _LIMITS_H +# define _LIMITS_H 1 + +# include + +/* Number of bits in a `char'. */ +# undef CHAR_BIT +# define CHAR_BIT 8 + +/* Minimum and maximum values a `signed char' can hold. */ +# undef SCHAR_MIN +# define SCHAR_MIN (-128) +# undef SCHAR_MAX +# define SCHAR_MAX 127 + +/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ +# undef UCHAR_MAX +# define UCHAR_MAX 255 + +/* Minimum and maximum values a `char' can hold. */ +# ifdef __CHAR_UNSIGNED__ +# undef CHAR_MIN +# define CHAR_MIN 0 +# undef CHAR_MAX +# define CHAR_MAX 255 +# else +# undef CHAR_MIN +# define CHAR_MIN (-128) +# undef CHAR_MAX +# define CHAR_MAX 127 +# endif + +/* Minimum and maximum values a `signed short int' can hold. */ +# undef SHRT_MIN +/* For the sake of 16 bit hosts, we may not use -32768 */ +# define SHRT_MIN (-32767-1) +# undef SHRT_MAX +# define SHRT_MAX 32767 + +/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ +# undef USHRT_MAX +# define USHRT_MAX 65535 + +/* Minimum and maximum values a `signed int' can hold. */ +# ifndef __INT_MAX__ +# define __INT_MAX__ 2147483647 +# endif +# undef INT_MIN +# define INT_MIN (-INT_MAX-1) +# undef INT_MAX +# define INT_MAX __INT_MAX__ + +/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ +# undef UINT_MAX +# define UINT_MAX (INT_MAX * 2U + 1) + +/* Minimum and maximum values a `signed long int' can hold. + (Same as `int'). */ +# ifndef __LONG_MAX__ +# if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) || defined (__sparcv9) +# define __LONG_MAX__ 9223372036854775807L +# else +# define __LONG_MAX__ 2147483647L +# endif /* __alpha__ || sparc64 */ +# endif +# undef LONG_MIN +# define LONG_MIN (-LONG_MAX-1) +# undef LONG_MAX +# define LONG_MAX __LONG_MAX__ + +/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ +# undef ULONG_MAX +# define ULONG_MAX (LONG_MAX * 2UL + 1) + +# ifndef __LONG_LONG_MAX__ +# define __LONG_LONG_MAX__ 9223372036854775807LL +# endif + +# if __ISO_C_VISIBLE >= 1999 +/* Minimum and maximum values a `signed long long int' can hold. */ +# undef LLONG_MIN +# define LLONG_MIN (-LLONG_MAX-1) +# undef LLONG_MAX +# define LLONG_MAX __LONG_LONG_MAX__ + +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ +# undef ULLONG_MAX +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) +# endif + +# if __GNU_VISIBLE +/* Minimum and maximum values a `signed long long int' can hold. */ +# undef LONG_LONG_MIN +# define LONG_LONG_MIN (-LONG_LONG_MAX-1) +# undef LONG_LONG_MAX +# define LONG_LONG_MAX __LONG_LONG_MAX__ + +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ +# undef ULONG_LONG_MAX +# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1) +# endif + +# endif /* _LIMITS_H */ +# endif /* GCC 2. */ + +#endif /* !_LIBC_LIMITS_H_ */ + +#if defined __GNUC__ && !defined _GCC_LIMITS_H_ +/* `_GCC_LIMITS_H_' is what GCC's file defines. */ +# include_next +#endif /* __GNUC__ && !_GCC_LIMITS_H_ */ + +#ifndef _POSIX2_RE_DUP_MAX +/* The maximum number of repeated occurrences of a regular expression + * permitted when using the interval notation `\{M,N\}'. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif /* _POSIX2_RE_DUP_MAX */ + +#ifndef ARG_MAX +#define ARG_MAX 4096 +#endif + +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif diff --git a/include/hermit/pte_types.h b/include/hermit/pte_types.h new file mode 100644 index 000000000..2a8e2e0e4 --- /dev/null +++ b/include/hermit/pte_types.h @@ -0,0 +1,12 @@ +/* pte_types.h */ + +#ifndef PTE_TYPES_H +#define PTE_TYPES_H + +#include +#include +#include + +typedef unsigned int tid_t; + +#endif /* PTE_TYPES_H */ diff --git a/include/hermit/pthread.h b/include/hermit/pthread.h new file mode 100644 index 000000000..f6010f34a --- /dev/null +++ b/include/hermit/pthread.h @@ -0,0 +1,1014 @@ +/* This is an implementation of the threads API of POSIX 1003.1-2001. + * + * -------------------------------------------------------------------------- + * + * Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems + * Copyright(C) 2008 Jason Schmidlapp + * + * Contact Email: jschmidlapp@users.sourceforge.net + * + * + * Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems + * Copyright(C) 2008 Jason Schmidlapp + * + * Contact Email: jschmidlapp@users.sourceforge.net + * + * + * Based upon Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright(C) 1998 John E. Bossom + * Copyright(C) 1999,2005 Pthreads-win32 contributors + * + * Contact Email: rpj@callisto.canberra.edu.au + * + * The original list of contributors to the Pthreads-win32 project + * is contained in the file CONTRIBUTORS.ptw32 included with the + * source code distribution. The list can also be seen at the + * following World Wide Web location: + * http://sources.redhat.com/pthreads-win32/contributors.html + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library in the file COPYING.LIB; + * if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#if !defined( PTHREAD_H ) +#define PTHREAD_H + +//#include + +#define PTE_VERSION 2,8,0,0 +#define PTE_VERSION_STRING "2, 8, 0, 0\0" + +/* There are two implementations of cancel cleanup. + * Note that pthread.h is included in both application + * compilation units and also internally for the library. + * The code here and within the library aims to work + * for all reasonable combinations of environments. + * + * The two implementations are: + * + * C + * C++ + * + */ + +/* + * Define defaults for cleanup code. + * Note: Unless the build explicitly defines one of the following, then + * we default to standard C style cleanup. This style uses setjmp/longjmp + * in the cancelation and thread exit implementations and therefore won't + * do stack unwinding if linked to applications that have it (e.g. + * C++ apps). This is currently consistent with most/all commercial Unix + * POSIX threads implementations. + */ +#if !defined( PTE_CLEANUP_CXX ) && !defined( PTE_CLEANUP_C ) +# define PTE_CLEANUP_C +#endif + +#undef PTE_LEVEL + +#if defined(_POSIX_SOURCE) +#define PTE_LEVEL 0 +/* Early POSIX */ +#endif + +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 +#undef PTE_LEVEL +#define PTE_LEVEL 1 +/* Include 1b, 1c and 1d */ +#endif + +#if defined(INCLUDE_NP) +#undef PTE_LEVEL +#define PTE_LEVEL 2 +/* Include Non-Portable extensions */ +#endif + +#define PTE_LEVEL_MAX 3 + +#if !defined(PTE_LEVEL) +#define PTE_LEVEL PTE_LEVEL_MAX +/* Include everything */ +#endif + +/* + * ------------------------------------------------------------- + * + * + * Module: pthread.h + * + * Purpose: + * Provides an implementation of PThreads based upon the + * standard: + * + * POSIX 1003.1-2001 + * and + * The Single Unix Specification version 3 + * + * (these two are equivalent) + * + * in order to enhance code portability between Windows, + * various commercial Unix implementations, and Linux. + * + * See the ANNOUNCE file for a full list of conforming + * routines and defined constants, and a list of missing + * routines and constants not defined in this implementation. + * + * Authors: + * There have been many contributors to this library. + * The initial implementation was contributed by + * John Bossom, and several others have provided major + * sections or revisions of parts of the implementation. + * Often significant effort has been contributed to + * find and fix important bugs and other problems to + * improve the reliability of the library, which sometimes + * is not reflected in the amount of code which changed as + * result. + * As much as possible, the contributors are acknowledged + * in the ChangeLog file in the source code distribution + * where their changes are noted in detail. + * + * Contributors are listed in the CONTRIBUTORS file. + * + * As usual, all bouquets go to the contributors, and all + * brickbats go to the project maintainer. + * + * Maintainer: + * The code base for this project is coordinated and + * eventually pre-tested, packaged, and made available by + * + * Ross Johnson + * + * QA Testers: + * Ultimately, the library is tested in the real world by + * a host of competent and demanding scientists and + * engineers who report bugs and/or provide solutions + * which are then fixed or incorporated into subsequent + * versions of the library. Each time a bug is fixed, a + * test case is written to prove the fix and ensure + * that later changes to the code don't reintroduce the + * same error. The number of test cases is slowly growing + * and therefore so is the code reliability. + * + * Compliance: + * See the file ANNOUNCE for the list of implemented + * and not-implemented routines and defined options. + * Of course, these are all defined is this file as well. + * + * Web site: + * The source code and other information about this library + * are available from + * + * http://sources.redhat.com/pthreads-win32/ + * + * ------------------------------------------------------------- + */ + +#include + +#include +#include + +/* + * Boolean values to make us independent of system includes. + */ +enum +{ + PTE_FALSE = 0, + PTE_TRUE = (! PTE_FALSE) +}; + + + /* + * ------------------------------------------------------------- + * + * POSIX 1003.1-2001 Options + * ========================= + * + * Options are normally set in , which is not provided + * with pthreads-embedded. + * + * For conformance with the Single Unix Specification (version 3), all of the + * options below are defined, and have a value of either -1 (not supported) + * or 200112L (supported). + * + * These options can neither be left undefined nor have a value of 0, because + * either indicates that sysconf(), which is not implemented, may be used at + * runtime to check the status of the option. + * + * _POSIX_THREADS (== 200112L) + * If == 200112L, you can use threads + * + * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L) + * If == 200112L, you can control the size of a thread's + * stack + * pthread_attr_getstacksize + * pthread_attr_setstacksize + * + * _POSIX_THREAD_ATTR_STACKADDR (== -1) + * If == 200112L, you can allocate and control a thread's + * stack. If not supported, the following functions + * will return ENOSYS, indicating they are not + * supported: + * pthread_attr_getstackaddr + * pthread_attr_setstackaddr + * + * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1) + * If == 200112L, you can use realtime scheduling. + * This option indicates that the behaviour of some + * implemented functions conforms to the additional TPS + * requirements in the standard. E.g. rwlocks favour + * writers over readers when threads have equal priority. + * + * _POSIX_THREAD_PRIO_INHERIT (== -1) + * If == 200112L, you can create priority inheritance + * mutexes. + * pthread_mutexattr_getprotocol + + * pthread_mutexattr_setprotocol + + * + * _POSIX_THREAD_PRIO_PROTECT (== -1) + * If == 200112L, you can create priority ceiling mutexes + * Indicates the availability of: + * pthread_mutex_getprioceiling + * pthread_mutex_setprioceiling + * pthread_mutexattr_getprioceiling + * pthread_mutexattr_getprotocol + + * pthread_mutexattr_setprioceiling + * pthread_mutexattr_setprotocol + + * + * _POSIX_THREAD_PROCESS_SHARED (== -1) + * If set, you can create mutexes and condition + * variables that can be shared with another + * process.If set, indicates the availability + * of: + * pthread_mutexattr_getpshared + * pthread_mutexattr_setpshared + * pthread_condattr_getpshared + * pthread_condattr_setpshared + * + * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L) + * If == 200112L you can use the special *_r library + * functions that provide thread-safe behaviour + * + * _POSIX_READER_WRITER_LOCKS (== 200112L) + * If == 200112L, you can use read/write locks + * + * _POSIX_SPIN_LOCKS (== 200112L) + * If == 200112L, you can use spin locks + * + * _POSIX_BARRIERS (== 200112L) + * If == 200112L, you can use barriers + * + * + These functions provide both 'inherit' and/or + * 'protect' protocol, based upon these macro + * settings. + * + * ------------------------------------------------------------- + */ + + /* + * POSIX Options + */ +#undef _POSIX_THREADS +#define _POSIX_THREADS 200112L + +#undef _POSIX_READER_WRITER_LOCKS +#define _POSIX_READER_WRITER_LOCKS 200112L + +#undef _POSIX_SPIN_LOCKS +#define _POSIX_SPIN_LOCKS 200112L + +#undef _POSIX_BARRIERS +#define _POSIX_BARRIERS 200112L + +#undef _POSIX_THREAD_SAFE_FUNCTIONS +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L + +#undef _POSIX_THREAD_ATTR_STACKSIZE +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L + + /* + * The following options are not supported + */ +#undef _POSIX_THREAD_ATTR_STACKADDR +#define _POSIX_THREAD_ATTR_STACKADDR -1 + +#undef _POSIX_THREAD_PRIO_INHERIT +#define _POSIX_THREAD_PRIO_INHERIT -1 + +#undef _POSIX_THREAD_PRIO_PROTECT +#define _POSIX_THREAD_PRIO_PROTECT -1 + + /* TPS is not fully supported. */ +#undef _POSIX_THREAD_PRIORITY_SCHEDULING +#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 + +#undef _POSIX_THREAD_PROCESS_SHARED +#define _POSIX_THREAD_PROCESS_SHARED -1 + + + /* + * POSIX 1003.1-2001 Limits + * =========================== + * + * These limits are normally set in , which is not provided with + * pthreads-embedded. + * + * PTHREAD_DESTRUCTOR_ITERATIONS + * Maximum number of attempts to destroy + * a thread's thread-specific data on + * termination (must be at least 4) + * + * PTHREAD_KEYS_MAX + * Maximum number of thread-specific data keys + * available per process (must be at least 128) + * + * PTHREAD_STACK_MIN + * Minimum supported stack size for a thread + * + * PTHREAD_THREADS_MAX + * Maximum number of threads supported per + * process (must be at least 64). + * + * SEM_NSEMS_MAX + * The maximum number of semaphores a process can have. + * (must be at least 256) + * + * SEM_VALUE_MAX + * The maximum value a semaphore can have. + * (must be at least 32767) + * + */ +#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 + +#undef PTHREAD_DESTRUCTOR_ITERATIONS +#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS + +#undef _POSIX_THREAD_KEYS_MAX +#define _POSIX_THREAD_KEYS_MAX 128 + +#undef PTHREAD_KEYS_MAX +#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX + +#undef PTHREAD_STACK_MIN +#define PTHREAD_STACK_MIN 0 + +#undef _POSIX_THREAD_THREADS_MAX +#define _POSIX_THREAD_THREADS_MAX 64 + + /* Arbitrary value */ +#undef PTHREAD_THREADS_MAX +#define PTHREAD_THREADS_MAX 2019 + +#undef _POSIX_SEM_NSEMS_MAX +#define _POSIX_SEM_NSEMS_MAX 256 + + /* Arbitrary value */ +#undef SEM_NSEMS_MAX +#define SEM_NSEMS_MAX 1024 + +#undef _POSIX_SEM_VALUE_MAX +#define _POSIX_SEM_VALUE_MAX 32767 + +#undef SEM_VALUE_MAX +#define SEM_VALUE_MAX INT_MAX + +#include + + /* + * Generic handle type - intended to extend uniqueness beyond + * that available with a simple pointer. It should scale for either + * IA-32 or IA-64. + */ + typedef struct + { + void * p; /* Pointer to actual object */ + unsigned int x; /* Extra information - reuse count etc */ + } pte_handle_t; + + typedef pte_handle_t pthread_t; + typedef struct pthread_attr_t_ * pthread_attr_t; + typedef struct pthread_once_t_ pthread_once_t; + typedef struct pthread_key_t_ * pthread_key_t; + typedef struct pthread_mutex_t_ * pthread_mutex_t; + typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t; + typedef struct pthread_cond_t_ * pthread_cond_t; + typedef struct pthread_condattr_t_ * pthread_condattr_t; + typedef struct pthread_rwlock_t_ * pthread_rwlock_t; + typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t; + typedef struct pthread_spinlock_t_ * pthread_spinlock_t; + typedef struct pthread_barrier_t_ * pthread_barrier_t; + typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; + + /* + * ==================== + * ==================== + * POSIX Threads + * ==================== + * ==================== + */ + + enum + { + /* + * pthread_attr_{get,set}detachstate + */ + PTHREAD_CREATE_JOINABLE = 0, /* Default */ + PTHREAD_CREATE_DETACHED = 1, + + /* + * pthread_attr_{get,set}inheritsched + */ + PTHREAD_INHERIT_SCHED = 0, + PTHREAD_EXPLICIT_SCHED = 1, /* Default */ + + /* + * pthread_{get,set}scope + */ + PTHREAD_SCOPE_PROCESS = 0, + PTHREAD_SCOPE_SYSTEM = 1, /* Default */ + PTHREAD_SCOPE_PROCESS_VFPU = 2, /* PSP specific */ + + /* + * pthread_setcancelstate paramters + */ + PTHREAD_CANCEL_ENABLE = 0, /* Default */ + PTHREAD_CANCEL_DISABLE = 1, + + /* + * pthread_setcanceltype parameters + */ + PTHREAD_CANCEL_ASYNCHRONOUS = 0, + PTHREAD_CANCEL_DEFERRED = 1, /* Default */ + + /* + * pthread_mutexattr_{get,set}pshared + * pthread_condattr_{get,set}pshared + */ + PTHREAD_PROCESS_PRIVATE = 0, + PTHREAD_PROCESS_SHARED = 1, + + /* + * pthread_barrier_wait + */ + PTHREAD_BARRIER_SERIAL_THREAD = -1 + }; + + /* + * ==================== + * ==================== + * Cancelation + * ==================== + * ==================== + */ +#define PTHREAD_CANCELED ((void *) -1) + + + /* + * ==================== + * ==================== + * Once Key + * ==================== + * ==================== + */ +#define PTHREAD_ONCE_INIT { PTE_FALSE, 0, 0, 0} + + struct pthread_once_t_ + { + int state; + void * semaphore; + int numSemaphoreUsers; + int done; /* indicates if user function has been executed */ +// void * lock; +// int reserved1; +// int reserved2; + }; + + + /* + * ==================== + * ==================== + * Object initialisers + * ==================== + * ==================== + */ +#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1) +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2) +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3) + + /* + * Compatibility with LinuxThreads + */ +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER + +#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1) + +#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1) + +#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t) -1) + + + /* + * Mutex types. + */ + enum + { + /* Compatibility with LinuxThreads */ + PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, + /* For compatibility with POSIX */ + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL + }; + + + typedef struct pte_cleanup_t pte_cleanup_t; + + typedef void (* pte_cleanup_callback_t)(void *); + + struct pte_cleanup_t + { + pte_cleanup_callback_t routine; + void *arg; + struct pte_cleanup_t *prev; + }; + +#ifdef PTE_CLEANUP_C + + /* + * C implementation of PThreads cancel cleanup + */ + +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + pte_cleanup_t _cleanup; \ + \ + pte_push_cleanup( &_cleanup, (pte_cleanup_callback_t) (_rout), (_arg) ); \ + +#define pthread_cleanup_pop( _execute ) \ + (void) pte_pop_cleanup( _execute ); \ + } + +#else /* PTE_CLEANUP_C */ + +#ifdef PTE_CLEANUP_CXX + + /* + * C++ version of cancel cleanup. + * - John E. Bossom. + */ + + class PThreadCleanup + { + /* + * PThreadCleanup + * + * Purpose + * This class is a C++ helper class that is + * used to implement pthread_cleanup_push/ + * pthread_cleanup_pop. + * The destructor of this class automatically + * pops the pushed cleanup routine regardless + * of how the code exits the scope + * (i.e. such as by an exception) + */ + pte_cleanup_callback_t cleanUpRout; + void * obj; + int executeIt; + + public: + PThreadCleanup() : + cleanUpRout( 0 ), + obj( 0 ), + executeIt( 0 ) + /* + * No cleanup performed + */ + { + } + + PThreadCleanup( + pte_cleanup_callback_t routine, + void * arg ) : + cleanUpRout( routine ), + obj( arg ), + executeIt( 1 ) + /* + * Registers a cleanup routine for 'arg' + */ + { + } + + ~PThreadCleanup() + { + if ( executeIt ) + { + (void) (*cleanUpRout)( obj ); + } + } + + void execute( int exec ) + { + executeIt = exec; + } + }; + + /* + * C++ implementation of PThreads cancel cleanup; + * This implementation takes advantage of a helper + * class who's destructor automatically calls the + * cleanup routine if we exit our scope weirdly + */ +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + PThreadCleanup cleanup((pte_cleanup_callback_t)(_rout), \ + (void *) (_arg) ); + +#define pthread_cleanup_pop( _execute ) \ + cleanup.execute( _execute ); \ + } + +#else + +#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. + +#endif /* PTE_CLEANUP_CXX */ + +#endif /* PTE_CLEANUP_C */ + + /* + * =============== + * =============== + * Methods + * =============== + * =============== + */ + + int pthread_init (void); + void pthread_terminate (void); + + /* + * PThread Attribute Functions + */ + int pthread_attr_init (pthread_attr_t * attr); + + int pthread_attr_destroy (pthread_attr_t * attr); + + int pthread_attr_getdetachstate (const pthread_attr_t * attr, + int *detachstate); + + int pthread_attr_getstackaddr (const pthread_attr_t * attr, + void **stackaddr); + + int pthread_attr_getstacksize (const pthread_attr_t * attr, + size_t * stacksize); + + int pthread_attr_setdetachstate (pthread_attr_t * attr, + int detachstate); + + int pthread_attr_setstackaddr (pthread_attr_t * attr, + void *stackaddr); + + int pthread_attr_setstacksize (pthread_attr_t * attr, + size_t stacksize); + + int pthread_attr_getschedparam (const pthread_attr_t *attr, + struct sched_param *param); + + int pthread_attr_setschedparam (pthread_attr_t *attr, + const struct sched_param *param); + + int pthread_attr_setschedpolicy (pthread_attr_t *, + int); + + int pthread_attr_getschedpolicy (pthread_attr_t *, + int *); + + int pthread_attr_setinheritsched(pthread_attr_t * attr, + int inheritsched); + + int pthread_attr_getinheritsched(pthread_attr_t * attr, + int * inheritsched); + + int pthread_attr_setscope (pthread_attr_t *, + int); + + int pthread_attr_getscope (const pthread_attr_t *, + int *); + + /* + * PThread Functions + */ + int pthread_create (pthread_t * tid, + const pthread_attr_t * attr, + void *(*start) (void *), + void *arg); + + int pthread_detach (pthread_t tid); + + int pthread_equal (pthread_t t1, + pthread_t t2); + + void pthread_exit (void *value_ptr); + + int pthread_join (pthread_t thread, + void **value_ptr); + + pthread_t pthread_self (void); + + int pthread_cancel (pthread_t thread); + + int pthread_setcancelstate (int state, + int *oldstate); + + int pthread_setcanceltype (int type, + int *oldtype); + + void pthread_testcancel (void); + + int pthread_once (pthread_once_t * once_control, + void (*init_routine) (void)); + +#if PTE_LEVEL >= PTE_LEVEL_MAX + pte_cleanup_t * pte_pop_cleanup (int execute); + + void pte_push_cleanup (pte_cleanup_t * cleanup, + void (*routine) (void *), + void *arg); +#endif /* PTE_LEVEL >= PTE_LEVEL_MAX */ + + /* + * Thread Specific Data Functions + */ + int pthread_key_create (pthread_key_t * key, + void (*destructor) (void *)); + + int pthread_key_delete (pthread_key_t key); + + int pthread_setspecific (pthread_key_t key, + const void *value); + + void * pthread_getspecific (pthread_key_t key); + + + /* + * Mutex Attribute Functions + */ + int pthread_mutexattr_init (pthread_mutexattr_t * attr); + + int pthread_mutexattr_destroy (pthread_mutexattr_t * attr); + + int pthread_mutexattr_getpshared (const pthread_mutexattr_t + * attr, + int *pshared); + + int pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, + int pshared); + + int pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); + int pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind); + + /* + * Barrier Attribute Functions + */ + int pthread_barrierattr_init (pthread_barrierattr_t * attr); + + int pthread_barrierattr_destroy (pthread_barrierattr_t * attr); + + int pthread_barrierattr_getpshared (const pthread_barrierattr_t + * attr, + int *pshared); + + int pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, + int pshared); + + /* + * Mutex Functions + */ + int pthread_mutex_init (pthread_mutex_t * mutex, + const pthread_mutexattr_t * attr); + + int pthread_mutex_destroy (pthread_mutex_t * mutex); + + int pthread_mutex_lock (pthread_mutex_t * mutex); + + int pthread_mutex_timedlock(pthread_mutex_t *mutex, + const struct timespec *abstime); + + int pthread_mutex_trylock (pthread_mutex_t * mutex); + + int pthread_mutex_unlock (pthread_mutex_t * mutex); + + /* + * Spinlock Functions + */ + int pthread_spin_init (pthread_spinlock_t * lock, int pshared); + + int pthread_spin_destroy (pthread_spinlock_t * lock); + + int pthread_spin_lock (pthread_spinlock_t * lock); + + int pthread_spin_trylock (pthread_spinlock_t * lock); + + int pthread_spin_unlock (pthread_spinlock_t * lock); + + /* + * Barrier Functions + */ + int pthread_barrier_init (pthread_barrier_t * barrier, + const pthread_barrierattr_t * attr, + unsigned int count); + + int pthread_barrier_destroy (pthread_barrier_t * barrier); + + int pthread_barrier_wait (pthread_barrier_t * barrier); + + /* + * Condition Variable Attribute Functions + */ + int pthread_condattr_init (pthread_condattr_t * attr); + + int pthread_condattr_destroy (pthread_condattr_t * attr); + + int pthread_condattr_getpshared (const pthread_condattr_t * attr, + int *pshared); + + int pthread_condattr_setpshared (pthread_condattr_t * attr, + int pshared); + + /* + * Condition Variable Functions + */ + int pthread_cond_init (pthread_cond_t * cond, + const pthread_condattr_t * attr); + + int pthread_cond_destroy (pthread_cond_t * cond); + + int pthread_cond_wait (pthread_cond_t * cond, + pthread_mutex_t * mutex); + + int pthread_cond_timedwait (pthread_cond_t * cond, + pthread_mutex_t * mutex, + const struct timespec *abstime); + + int pthread_cond_signal (pthread_cond_t * cond); + + int pthread_cond_broadcast (pthread_cond_t * cond); + + /* + * Scheduling + */ + int pthread_setschedparam (pthread_t thread, + int policy, + const struct sched_param *param); + + int pthread_getschedparam (pthread_t thread, + int *policy, + struct sched_param *param); + + int pthread_setconcurrency (int); + + int pthread_getconcurrency (void); + + /* + * Read-Write Lock Functions + */ + int pthread_rwlock_init(pthread_rwlock_t *lock, + const pthread_rwlockattr_t *attr); + + int pthread_rwlock_destroy(pthread_rwlock_t *lock); + + int pthread_rwlock_tryrdlock(pthread_rwlock_t *); + + int pthread_rwlock_trywrlock(pthread_rwlock_t *); + + int pthread_rwlock_rdlock(pthread_rwlock_t *lock); + + int pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, + const struct timespec *abstime); + + int pthread_rwlock_wrlock(pthread_rwlock_t *lock); + + int pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, + const struct timespec *abstime); + + int pthread_rwlock_unlock(pthread_rwlock_t *lock); + + int pthread_rwlockattr_init (pthread_rwlockattr_t * attr); + + int pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); + + int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, + int *pshared); + + int pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, + int pshared); + +#if (PTE_LEVEL >= PTE_LEVEL_MAX - 1) || defined(__hermit__) + + /* + * Signal Functions. Should be defined in but we might + * already have signal.h that don't define these. + */ + int pthread_kill(pthread_t thread, int sig); +#endif + +#if PTE_LEVEL >= PTE_LEVEL_MAX - 1 + /* + * Non-portable functions + */ + + /* + * Compatibility with Linux. + */ + int pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, + int kind); + int pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, + int *kind); + + /* + * Possibly supported by other POSIX threads implementations + */ + int pthread_delay_np (struct timespec * interval); + int pthread_num_processors_np(void); + + /* + * Register a system time change with the library. + * Causes the library to perform various functions + * in response to the change. Should be called whenever + * the application's top level window receives a + * WM_TIMECHANGE message. It can be passed directly to + * pthread_create() as a new thread if desired. + */ + void * pthread_timechange_handler_np(void *); + +#endif /*PTE_LEVEL >= PTE_LEVEL_MAX - 1 */ + +#if PTE_LEVEL >= PTE_LEVEL_MAX + + + +#endif /* PTE_LEVEL >= PTE_LEVEL_MAX */ + + /* + * Some compiler environments don't define some things. + */ +# define _ftime ftime +# define _timeb timeb + +#ifdef __cplusplus + + /* + * Internal exceptions + */ + class pte_exception {}; + class pte_exception_cancel : public pte_exception {}; + class pte_exception_exit : public pte_exception {}; + + /* Operator to be compatible to libstd++ */ + inline bool operator<(pte_handle_t const& l, pte_handle_t const& r) + { + return ((size_t) l.p) < ((size_t) r.p); + } + + /* Operator to be compatible to libstd++ */ + inline bool operator==(pte_handle_t const& l, pte_handle_t const& r) + { + return ((size_t) l.p) == ((size_t) r.p); + } +#endif + + +#ifdef PTE_CXX_EXCEPTIONS + + /* + * Redefine the C++ catch keyword to ensure that applications + * propagate our internal exceptions up to the library's internal handlers. + */ +#define catch( E ) \ + catch( pte_exception & ) { throw; } \ + catch( E ) + +#endif /* ! PTE_CXX_EXCEPTIONS */ + +#undef PTE_LEVEL +#undef PTE_LEVEL_MAX + +#endif /* PTHREAD_H */ diff --git a/include/hermit/sched.h b/include/hermit/sched.h new file mode 100644 index 000000000..504ad5274 --- /dev/null +++ b/include/hermit/sched.h @@ -0,0 +1,97 @@ +/* + * Written by Joel Sherrill . + * + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION + * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS + * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + * + * $Id$ + */ + +#ifndef _SCHED_H_ +#define _SCHED_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_POSIX_PRIORITY_SCHEDULING) +/* + * XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1803 + */ +int sched_setparam( + pid_t __pid, + const struct sched_param *__param +); + +/* + * XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1800 + */ +int sched_getparam( + pid_t __pid, + struct sched_param *__param +); + +/* + * XBD 13 - Set Scheduling Policy and Scheduling Parameters, + * P1003.1b-2008, p. 1805 + */ +int sched_setscheduler( + pid_t __pid, + int __policy, + const struct sched_param *__param +); + +/* + * XBD 13 - Get Scheduling Policy, P1003.1b-2008, p. 1801 + */ +int sched_getscheduler( + pid_t __pid +); + +/* + * XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1799 + */ +int sched_get_priority_max( + int __policy +); + +int sched_get_priority_min( + int __policy +); + +/* + * XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1802 + */ +int sched_rr_get_interval( + pid_t __pid, + struct timespec *__interval +); +#endif /* _POSIX_PRIORITY_SCHEDULING */ + +#if defined(_POSIX_THREADS) || defined(_POSIX_PRIORITY_SCHEDULING) + +/* + * XBD 13 - Yield Processor, P1003.1b-2008, p. 1807 + */ +int sched_yield( void ); + +#endif /* _POSIX_THREADS or _POSIX_PRIORITY_SCHEDULING */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SCHED_H_ */ diff --git a/include/hermit/setjmp.h b/include/hermit/setjmp.h new file mode 100644 index 000000000..521eac5a1 --- /dev/null +++ b/include/hermit/setjmp.h @@ -0,0 +1,25 @@ +/* + setjmp.h + stubs for future use. +*/ + +#ifndef _SETJMP_H_ +#define _SETJMP_H_ + +#include "_ansi.h" +#include + +_BEGIN_STD_C + +#ifdef __GNUC__ +void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval)) + __attribute__ ((__noreturn__)); +#else +void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval)); +#endif +int _EXFUN(setjmp,(jmp_buf __jmpb)); + +_END_STD_C + +#endif /* _SETJMP_H_ */ + diff --git a/usr/rdma-core/libibverbs/verbs.h b/include/hermit/verbs.h similarity index 56% rename from usr/rdma-core/libibverbs/verbs.h rename to include/hermit/verbs.h index cc633a129..540ecae19 100644 --- a/usr/rdma-core/libibverbs/verbs.h +++ b/include/hermit/verbs.h @@ -36,13 +36,19 @@ #ifndef INFINIBAND_VERBS_H #define INFINIBAND_VERBS_H -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +//#include +#include + +//#include +//#include +//#include + +//#include +//#include #ifdef __cplusplus # define BEGIN_C_DECLS extern "C" { @@ -60,6 +66,43 @@ BEGIN_C_DECLS +// Replacing in-l64.h: +typedef unsigned short __u16; +typedef unsigned int __u32; +typedef unsigned long __u64; + +// Replacing linux/types.h (left out __bitwise): +//typedef __u16 __bitwise __be16; +typedef __u16 __be16; +typedef __u32 __be32; +typedef __u64 __be64; + +// Replacing pthread.h: +typedef struct _pthread_descr_struct *_pthread_descr; // TODO +typedef long long int __pthread_cond_align_t; + +struct _pthread_fastlock { + long int __status; + int __spinlock; +}; + +typedef struct { + int __m_reserved; + int __m_count; + _pthread_descr __m_owner; + int __m_kind; + struct _pthread_fastlock __m_lock; +} pthread_mutex_t; + +typedef struct { + struct _pthread_fastlock __c_lock; + _pthread_descr __c_waiting; + char __padding[48 - sizeof(struct _pthread_fastlock) - + sizeof(_pthread_descr) - + sizeof(__pthread_cond_align_t)]; + __pthread_cond_align_t __align; +} pthread_cond_t; + union ibv_gid { uint8_t raw[16]; struct { @@ -601,26 +644,26 @@ enum ibv_rate { * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec. * @rate: rate to convert. */ -int __attribute_const ibv_rate_to_mult(enum ibv_rate rate); +//int __attribute_const ibv_rate_to_mult(enum ibv_rate rate); /** * mult_to_ibv_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate enum. * @mult: multiple to convert. */ -enum ibv_rate __attribute_const mult_to_ibv_rate(int mult); +//enum ibv_rate __attribute_const mult_to_ibv_rate(int mult); /** * ibv_rate_to_mbps - Convert the IB rate enum to Mbit/sec. * For example, IBV_RATE_5_GBPS will return the value 5000. * @rate: rate to convert. */ -int __attribute_const ibv_rate_to_mbps(enum ibv_rate rate); +//int __attribute_const ibv_rate_to_mbps(enum ibv_rate rate); /** * mbps_to_ibv_rate - Convert a Mbit/sec value to an IB rate enum. * @mbps: value to convert. */ -enum ibv_rate __attribute_const mbps_to_ibv_rate(int mbps) __attribute_const; +//enum ibv_rate __attribute_const mbps_to_ibv_rate(int mbps) __attribute_const; struct ibv_ah_attr { struct ibv_global_route grh; @@ -1116,107 +1159,107 @@ struct ibv_cq_ex { uint32_t (*read_flow_tag)(struct ibv_cq_ex *current); }; -static inline struct ibv_cq *ibv_cq_ex_to_cq(struct ibv_cq_ex *cq) -{ - return (struct ibv_cq *)cq; -} +//static inline struct ibv_cq *ibv_cq_ex_to_cq(struct ibv_cq_ex *cq) +//{ + //return (struct ibv_cq *)cq; +//} -static inline int ibv_start_poll(struct ibv_cq_ex *cq, - struct ibv_poll_cq_attr *attr) -{ - return cq->start_poll(cq, attr); -} +//static inline int ibv_start_poll(struct ibv_cq_ex *cq, + //struct ibv_poll_cq_attr *attr) +//{ + //return cq->start_poll(cq, attr); +//} -static inline int ibv_next_poll(struct ibv_cq_ex *cq) -{ - return cq->next_poll(cq); -} +//static inline int ibv_next_poll(struct ibv_cq_ex *cq) +//{ + //return cq->next_poll(cq); +//} -static inline void ibv_end_poll(struct ibv_cq_ex *cq) -{ - cq->end_poll(cq); -} +//static inline void ibv_end_poll(struct ibv_cq_ex *cq) +//{ + //cq->end_poll(cq); +//} -static inline enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex *cq) -{ - return cq->read_opcode(cq); -} +//static inline enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex *cq) +//{ + //return cq->read_opcode(cq); +//} -static inline uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex *cq) -{ - return cq->read_vendor_err(cq); -} +//static inline uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex *cq) +//{ + //return cq->read_vendor_err(cq); +//} -static inline uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex *cq) -{ - return cq->read_byte_len(cq); -} +//static inline uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex *cq) +//{ + //return cq->read_byte_len(cq); +//} -static inline __be32 ibv_wc_read_imm_data(struct ibv_cq_ex *cq) -{ - return cq->read_imm_data(cq); -} +//static inline __be32 ibv_wc_read_imm_data(struct ibv_cq_ex *cq) +//{ + //return cq->read_imm_data(cq); +//} -static inline uint32_t ibv_wc_read_invalidated_rkey(struct ibv_cq_ex *cq) -{ -#ifdef __CHECKER__ - return (__attribute__((force)) uint32_t)cq->read_imm_data(cq); -#else - return cq->read_imm_data(cq); -#endif -} +//static inline uint32_t ibv_wc_read_invalidated_rkey(struct ibv_cq_ex *cq) +//{ +//#ifdef __CHECKER__ + //return (__attribute__((force)) uint32_t)cq->read_imm_data(cq); +//#else + //return cq->read_imm_data(cq); +//#endif +//} -static inline uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex *cq) -{ - return cq->read_qp_num(cq); -} +//static inline uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex *cq) +//{ + //return cq->read_qp_num(cq); +//} -static inline uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex *cq) -{ - return cq->read_src_qp(cq); -} +//static inline uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex *cq) +//{ + //return cq->read_src_qp(cq); +//} -static inline int ibv_wc_read_wc_flags(struct ibv_cq_ex *cq) -{ - return cq->read_wc_flags(cq); -} +//static inline int ibv_wc_read_wc_flags(struct ibv_cq_ex *cq) +//{ + //return cq->read_wc_flags(cq); +//} -static inline uint32_t ibv_wc_read_slid(struct ibv_cq_ex *cq) -{ - return cq->read_slid(cq); -} +//static inline uint32_t ibv_wc_read_slid(struct ibv_cq_ex *cq) +//{ + //return cq->read_slid(cq); +//} -static inline uint8_t ibv_wc_read_sl(struct ibv_cq_ex *cq) -{ - return cq->read_sl(cq); -} +//static inline uint8_t ibv_wc_read_sl(struct ibv_cq_ex *cq) +//{ + //return cq->read_sl(cq); +//} -static inline uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex *cq) -{ - return cq->read_dlid_path_bits(cq); -} +//static inline uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex *cq) +//{ + //return cq->read_dlid_path_bits(cq); +//} -static inline uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex *cq) -{ - return cq->read_completion_ts(cq); -} +//static inline uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex *cq) +//{ + //return cq->read_completion_ts(cq); +//} -static inline uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex *cq) -{ - return cq->read_cvlan(cq); -} +//static inline uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex *cq) +//{ + //return cq->read_cvlan(cq); +//} -static inline uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex *cq) -{ - return cq->read_flow_tag(cq); -} +//static inline uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex *cq) +//{ + //return cq->read_flow_tag(cq); +//} -static inline int ibv_post_wq_recv(struct ibv_wq *wq, - struct ibv_recv_wr *recv_wr, - struct ibv_recv_wr **bad_recv_wr) -{ - return wq->post_recv(wq, recv_wr, bad_recv_wr); -} +//static inline int ibv_post_wq_recv(struct ibv_wq *wq, + //struct ibv_recv_wr *recv_wr, + //struct ibv_recv_wr **bad_recv_wr) +//{ + //return wq->post_recv(wq, recv_wr, bad_recv_wr); +//} struct ibv_ah { struct ibv_context *context; @@ -1577,11 +1620,11 @@ struct verbs_context { struct ibv_context context; /* Must be last field in the struct */ }; -static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx) -{ - return (ctx->abi_compat != __VERBS_ABI_IS_EXTENDED) ? - NULL : container_of(ctx, struct verbs_context, context); -} +//static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx) +//{ + //return (ctx->abi_compat != __VERBS_ABI_IS_EXTENDED) ? + //NULL : container_of(ctx, struct verbs_context, context); +//} #define verbs_get_ctx_op(ctx, op) ({ \ struct verbs_context *__vctx = verbs_get_ctx(ctx); \ @@ -1593,800 +1636,800 @@ static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx) if (vctx && (vctx->sz >= sizeof(*vctx) - offsetof(struct verbs_context, op))) \ vctx->op = ptr; }) -/** - * ibv_get_device_list - Get list of IB devices currently available - * @num_devices: optional. if non-NULL, set to the number of devices - * returned in the array. - * - * Return a NULL-terminated array of IB devices. The array can be - * released with ibv_free_device_list(). - */ -struct ibv_device **ibv_get_device_list(int *num_devices); - -/** - * ibv_free_device_list - Free list from ibv_get_device_list() - * - * Free an array of devices returned from ibv_get_device_list(). Once - * the array is freed, pointers to devices that were not opened with - * ibv_open_device() are no longer valid. Client code must open all - * devices it intends to use before calling ibv_free_device_list(). - */ -void ibv_free_device_list(struct ibv_device **list); - -/** - * ibv_get_device_name - Return kernel device name - */ -const char *ibv_get_device_name(struct ibv_device *device); - -/** - * ibv_get_device_guid - Return device's node GUID - */ -__be64 ibv_get_device_guid(struct ibv_device *device); - -/** - * ibv_open_device - Initialize device for use - */ -struct ibv_context *ibv_open_device(struct ibv_device *device); - -/** - * ibv_close_device - Release device - */ -int ibv_close_device(struct ibv_context *context); - -/** - * ibv_get_async_event - Get next async event - * @event: Pointer to use to return async event - * - * All async events returned by ibv_get_async_event() must eventually - * be acknowledged with ibv_ack_async_event(). - */ -int ibv_get_async_event(struct ibv_context *context, - struct ibv_async_event *event); - -/** - * ibv_ack_async_event - Acknowledge an async event - * @event: Event to be acknowledged. - * - * All async events which are returned by ibv_get_async_event() must - * be acknowledged. To avoid races, destroying an object (CQ, SRQ or - * QP) will wait for all affiliated events to be acknowledged, so - * there should be a one-to-one correspondence between acks and - * successful gets. - */ -void ibv_ack_async_event(struct ibv_async_event *event); - -/** - * ibv_query_device - Get device properties - */ -int ibv_query_device(struct ibv_context *context, - struct ibv_device_attr *device_attr); - -/** - * ibv_query_port - Get port properties - */ -int ibv_query_port(struct ibv_context *context, uint8_t port_num, - struct ibv_port_attr *port_attr); - -static inline int ___ibv_query_port(struct ibv_context *context, - uint8_t port_num, - struct ibv_port_attr *port_attr) -{ - /* For compatibility when running with old libibverbs */ - port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED; - port_attr->reserved = 0; - - return ibv_query_port(context, port_num, port_attr); -} +///** +// * ibv_get_device_list - Get list of IB devices currently available +// * @num_devices: optional. if non-NULL, set to the number of devices +// * returned in the array. +// * +// * Return a NULL-terminated array of IB devices. The array can be +// * released with ibv_free_device_list(). +// */ +//struct ibv_device **ibv_get_device_list(int *num_devices); +// +///** +// * ibv_free_device_list - Free list from ibv_get_device_list() +// * +// * Free an array of devices returned from ibv_get_device_list(). Once +// * the array is freed, pointers to devices that were not opened with +// * ibv_open_device() are no longer valid. Client code must open all +// * devices it intends to use before calling ibv_free_device_list(). +// */ +//void ibv_free_device_list(struct ibv_device **list); +// +///** +// * ibv_get_device_name - Return kernel device name +// */ +//const char *ibv_get_device_name(struct ibv_device *device); +// +///** +// * ibv_get_device_guid - Return device's node GUID +// */ +//__be64 ibv_get_device_guid(struct ibv_device *device); +// +///** +// * ibv_open_device - Initialize device for use +// */ +//struct ibv_context *ibv_open_device(struct ibv_device *device); +// +///** +// * ibv_close_device - Release device +// */ +//int ibv_close_device(struct ibv_context *context); +// +///** +// * ibv_get_async_event - Get next async event +// * @event: Pointer to use to return async event +// * +// * All async events returned by ibv_get_async_event() must eventually +// * be acknowledged with ibv_ack_async_event(). +// */ +//int ibv_get_async_event(struct ibv_context *context, +// struct ibv_async_event *event); +// +///** +// * ibv_ack_async_event - Acknowledge an async event +// * @event: Event to be acknowledged. +// * +// * All async events which are returned by ibv_get_async_event() must +// * be acknowledged. To avoid races, destroying an object (CQ, SRQ or +// * QP) will wait for all affiliated events to be acknowledged, so +// * there should be a one-to-one correspondence between acks and +// * successful gets. +// */ +//void ibv_ack_async_event(struct ibv_async_event *event); +// +///** +// * ibv_query_device - Get device properties +// */ +//int ibv_query_device(struct ibv_context *context, +// struct ibv_device_attr *device_attr); +// +///** +// * ibv_query_port - Get port properties +// */ +//int ibv_query_port(struct ibv_context *context, uint8_t port_num, +// struct ibv_port_attr *port_attr); +// +//static inline int ___ibv_query_port(struct ibv_context *context, +// uint8_t port_num, +// struct ibv_port_attr *port_attr) +//{ +// /* For compatibility when running with old libibverbs */ +// port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED; +// port_attr->reserved = 0; +// +// return ibv_query_port(context, port_num, port_attr); +//} #define ibv_query_port(context, port_num, port_attr) \ ___ibv_query_port(context, port_num, port_attr) -/** - * ibv_query_gid - Get a GID table entry - */ -int ibv_query_gid(struct ibv_context *context, uint8_t port_num, - int index, union ibv_gid *gid); - -/** - * ibv_query_pkey - Get a P_Key table entry - */ -int ibv_query_pkey(struct ibv_context *context, uint8_t port_num, - int index, __be16 *pkey); - -/** - * ibv_alloc_pd - Allocate a protection domain - */ -struct ibv_pd *ibv_alloc_pd(struct ibv_context *context); - -/** - * ibv_dealloc_pd - Free a protection domain - */ -int ibv_dealloc_pd(struct ibv_pd *pd); - -static inline struct ibv_flow *ibv_create_flow(struct ibv_qp *qp, - struct ibv_flow_attr *flow) -{ - struct verbs_context *vctx = verbs_get_ctx_op(qp->context, - ibv_create_flow); - if (!vctx || !vctx->ibv_create_flow) { - errno = ENOSYS; - return NULL; - } - - return vctx->ibv_create_flow(qp, flow); -} - -static inline int ibv_destroy_flow(struct ibv_flow *flow_id) -{ - struct verbs_context *vctx = verbs_get_ctx_op(flow_id->context, - ibv_destroy_flow); - if (!vctx || !vctx->ibv_destroy_flow) - return -ENOSYS; - return vctx->ibv_destroy_flow(flow_id); -} - -/** - * ibv_open_xrcd - Open an extended connection domain - */ -static inline struct ibv_xrcd * -ibv_open_xrcd(struct ibv_context *context, struct ibv_xrcd_init_attr *xrcd_init_attr) -{ - struct verbs_context *vctx = verbs_get_ctx_op(context, open_xrcd); - if (!vctx) { - errno = ENOSYS; - return NULL; - } - return vctx->open_xrcd(context, xrcd_init_attr); -} - -/** - * ibv_close_xrcd - Close an extended connection domain - */ -static inline int ibv_close_xrcd(struct ibv_xrcd *xrcd) -{ - struct verbs_context *vctx = verbs_get_ctx(xrcd->context); - return vctx->close_xrcd(xrcd); -} - -/** - * ibv_reg_mr - Register a memory region - */ -struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); - - -enum ibv_rereg_mr_err_code { - /* Old MR is valid, invalid input */ - IBV_REREG_MR_ERR_INPUT = -1, - /* Old MR is valid, failed via don't fork on new address range */ - IBV_REREG_MR_ERR_DONT_FORK_NEW = -2, - /* New MR is valid, failed via do fork on old address range */ - IBV_REREG_MR_ERR_DO_FORK_OLD = -3, - /* MR shouldn't be used, command error */ - IBV_REREG_MR_ERR_CMD = -4, - /* MR shouldn't be used, command error, invalid fork state on new address range */ - IBV_REREG_MR_ERR_CMD_AND_DO_FORK_NEW = -5, -}; - -/** - * ibv_rereg_mr - Re-Register a memory region - */ -int ibv_rereg_mr(struct ibv_mr *mr, int flags, - struct ibv_pd *pd, void *addr, - size_t length, int access); -/** - * ibv_dereg_mr - Deregister a memory region - */ -int ibv_dereg_mr(struct ibv_mr *mr); - -/** - * ibv_alloc_mw - Allocate a memory window - */ -static inline struct ibv_mw *ibv_alloc_mw(struct ibv_pd *pd, - enum ibv_mw_type type) -{ - struct ibv_mw *mw; - - if (!pd->context->ops.alloc_mw) { - errno = ENOSYS; - return NULL; - } - - mw = pd->context->ops.alloc_mw(pd, type); - return mw; -} - -/** - * ibv_dealloc_mw - Free a memory window - */ -static inline int ibv_dealloc_mw(struct ibv_mw *mw) -{ - return mw->context->ops.dealloc_mw(mw); -} - -/** - * ibv_inc_rkey - Increase the 8 lsb in the given rkey - */ -static inline uint32_t ibv_inc_rkey(uint32_t rkey) -{ - const uint32_t mask = 0x000000ff; - uint8_t newtag = (uint8_t)((rkey + 1) & mask); - - return (rkey & ~mask) | newtag; -} - -/** - * ibv_bind_mw - Bind a memory window to a region - */ -static inline int ibv_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw, - struct ibv_mw_bind *mw_bind) -{ - if (mw->type != IBV_MW_TYPE_1) - return EINVAL; - - return mw->context->ops.bind_mw(qp, mw, mw_bind); -} - -/** - * ibv_create_comp_channel - Create a completion event channel - */ -struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context); - -/** - * ibv_destroy_comp_channel - Destroy a completion event channel - */ -int ibv_destroy_comp_channel(struct ibv_comp_channel *channel); - -/** - * ibv_create_cq - Create a completion queue - * @context - Context CQ will be attached to - * @cqe - Minimum number of entries required for CQ - * @cq_context - Consumer-supplied context returned for completion events - * @channel - Completion channel where completion events will be queued. - * May be NULL if completion events will not be used. - * @comp_vector - Completion vector used to signal completion events. - * Must be >= 0 and < context->num_comp_vectors. - */ -struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe, - void *cq_context, - struct ibv_comp_channel *channel, - int comp_vector); - -/** - * ibv_create_cq_ex - Create a completion queue - * @context - Context CQ will be attached to - * @cq_attr - Attributes to create the CQ with - */ -static inline -struct ibv_cq_ex *ibv_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr) -{ - struct verbs_context *vctx = verbs_get_ctx_op(context, create_cq_ex); - - if (!vctx) { - errno = ENOSYS; - return NULL; - } - - if (cq_attr->comp_mask & ~(IBV_CQ_INIT_ATTR_MASK_RESERVED - 1)) { - errno = EINVAL; - return NULL; - } - - return vctx->create_cq_ex(context, cq_attr); -} - -/** - * ibv_resize_cq - Modifies the capacity of the CQ. - * @cq: The CQ to resize. - * @cqe: The minimum size of the CQ. - * - * Users can examine the cq structure to determine the actual CQ size. - */ -int ibv_resize_cq(struct ibv_cq *cq, int cqe); - -/** - * ibv_destroy_cq - Destroy a completion queue - */ -int ibv_destroy_cq(struct ibv_cq *cq); - -/** - * ibv_get_cq_event - Read next CQ event - * @channel: Channel to get next event from. - * @cq: Used to return pointer to CQ. - * @cq_context: Used to return consumer-supplied CQ context. - * - * All completion events returned by ibv_get_cq_event() must - * eventually be acknowledged with ibv_ack_cq_events(). - */ -int ibv_get_cq_event(struct ibv_comp_channel *channel, - struct ibv_cq **cq, void **cq_context); - -/** - * ibv_ack_cq_events - Acknowledge CQ completion events - * @cq: CQ to acknowledge events for - * @nevents: Number of events to acknowledge. - * - * All completion events which are returned by ibv_get_cq_event() must - * be acknowledged. To avoid races, ibv_destroy_cq() will wait for - * all completion events to be acknowledged, so there should be a - * one-to-one correspondence between acks and successful gets. An - * application may accumulate multiple completion events and - * acknowledge them in a single call to ibv_ack_cq_events() by passing - * the number of events to ack in @nevents. - */ -void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents); - -/** - * ibv_poll_cq - Poll a CQ for work completions - * @cq:the CQ being polled - * @num_entries:maximum number of completions to return - * @wc:array of at least @num_entries of &struct ibv_wc where completions - * will be returned - * - * Poll a CQ for (possibly multiple) completions. If the return value - * is < 0, an error occurred. If the return value is >= 0, it is the - * number of completions returned. If the return value is - * non-negative and strictly less than num_entries, then the CQ was - * emptied. - */ -static inline int ibv_poll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc) -{ - return cq->context->ops.poll_cq(cq, num_entries, wc); -} - -/** - * ibv_req_notify_cq - Request completion notification on a CQ. An - * event will be added to the completion channel associated with the - * CQ when an entry is added to the CQ. - * @cq: The completion queue to request notification for. - * @solicited_only: If non-zero, an event will be generated only for - * the next solicited CQ entry. If zero, any CQ entry, solicited or - * not, will generate an event. - */ -static inline int ibv_req_notify_cq(struct ibv_cq *cq, int solicited_only) -{ - return cq->context->ops.req_notify_cq(cq, solicited_only); -} - -/** - * ibv_create_srq - Creates a SRQ associated with the specified protection - * domain. - * @pd: The protection domain associated with the SRQ. - * @srq_init_attr: A list of initial attributes required to create the SRQ. - * - * srq_attr->max_wr and srq_attr->max_sge are read the determine the - * requested size of the SRQ, and set to the actual values allocated - * on return. If ibv_create_srq() succeeds, then max_wr and max_sge - * will always be at least as large as the requested values. - */ -struct ibv_srq *ibv_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *srq_init_attr); - -static inline struct ibv_srq * -ibv_create_srq_ex(struct ibv_context *context, - struct ibv_srq_init_attr_ex *srq_init_attr_ex) -{ - struct verbs_context *vctx; - uint32_t mask = srq_init_attr_ex->comp_mask; - - if (!(mask & ~(IBV_SRQ_INIT_ATTR_PD | IBV_SRQ_INIT_ATTR_TYPE)) && - (mask & IBV_SRQ_INIT_ATTR_PD) && - (!(mask & IBV_SRQ_INIT_ATTR_TYPE) || - (srq_init_attr_ex->srq_type == IBV_SRQT_BASIC))) - return ibv_create_srq(srq_init_attr_ex->pd, - (struct ibv_srq_init_attr *)srq_init_attr_ex); - - vctx = verbs_get_ctx_op(context, create_srq_ex); - if (!vctx) { - errno = ENOSYS; - return NULL; - } - return vctx->create_srq_ex(context, srq_init_attr_ex); -} - -/** - * ibv_modify_srq - Modifies the attributes for the specified SRQ. - * @srq: The SRQ to modify. - * @srq_attr: On input, specifies the SRQ attributes to modify. On output, - * the current values of selected SRQ attributes are returned. - * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ - * are being modified. - * - * The mask may contain IBV_SRQ_MAX_WR to resize the SRQ and/or - * IBV_SRQ_LIMIT to set the SRQ's limit and request notification when - * the number of receives queued drops below the limit. - */ -int ibv_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *srq_attr, - int srq_attr_mask); - -/** - * ibv_query_srq - Returns the attribute list and current values for the - * specified SRQ. - * @srq: The SRQ to query. - * @srq_attr: The attributes of the specified SRQ. - */ -int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr); - -static inline int ibv_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num) -{ - struct verbs_context *vctx = verbs_get_ctx_op(srq->context, get_srq_num); - - if (!vctx) - return ENOSYS; - - return vctx->get_srq_num(srq, srq_num); -} - -/** - * ibv_destroy_srq - Destroys the specified SRQ. - * @srq: The SRQ to destroy. - */ -int ibv_destroy_srq(struct ibv_srq *srq); - -/** - * ibv_post_srq_recv - Posts a list of work requests to the specified SRQ. - * @srq: The SRQ to post the work request on. - * @recv_wr: A list of work requests to post on the receive queue. - * @bad_recv_wr: On an immediate failure, this parameter will reference - * the work request that failed to be posted on the QP. - */ -static inline int ibv_post_srq_recv(struct ibv_srq *srq, - struct ibv_recv_wr *recv_wr, - struct ibv_recv_wr **bad_recv_wr) -{ - return srq->context->ops.post_srq_recv(srq, recv_wr, bad_recv_wr); -} - -/** - * ibv_create_qp - Create a queue pair. - */ -struct ibv_qp *ibv_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *qp_init_attr); - -static inline struct ibv_qp * -ibv_create_qp_ex(struct ibv_context *context, struct ibv_qp_init_attr_ex *qp_init_attr_ex) -{ - struct verbs_context *vctx; - uint32_t mask = qp_init_attr_ex->comp_mask; - - if (mask == IBV_QP_INIT_ATTR_PD) - return ibv_create_qp(qp_init_attr_ex->pd, - (struct ibv_qp_init_attr *)qp_init_attr_ex); - - vctx = verbs_get_ctx_op(context, create_qp_ex); - if (!vctx) { - errno = ENOSYS; - return NULL; - } - return vctx->create_qp_ex(context, qp_init_attr_ex); -} - -/** - * ibv_query_rt_values_ex - Get current real time @values of a device. - * @values - in/out - defines the attributes we need to query/queried. - * (Or's bits of enum ibv_values_mask on values->comp_mask field) - */ -static inline int -ibv_query_rt_values_ex(struct ibv_context *context, - struct ibv_values_ex *values) -{ - struct verbs_context *vctx; - - vctx = verbs_get_ctx_op(context, query_rt_values); - if (!vctx) - return ENOSYS; - - if (values->comp_mask & ~(IBV_VALUES_MASK_RESERVED - 1)) - return EINVAL; - - return vctx->query_rt_values(context, values); -} - -/** - * ibv_query_device_ex - Get extended device properties - */ -static inline int -ibv_query_device_ex(struct ibv_context *context, - const struct ibv_query_device_ex_input *input, - struct ibv_device_attr_ex *attr) -{ - struct verbs_context *vctx; - int ret; - - vctx = verbs_get_ctx_op(context, query_device_ex); - if (!vctx) - goto legacy; - - ret = vctx->query_device_ex(context, input, attr, sizeof(*attr)); - if (ret == ENOSYS) - goto legacy; - - return ret; - -legacy: - memset(attr, 0, sizeof(*attr)); - ret = ibv_query_device(context, &attr->orig_attr); - - return ret; -} - -/** - * ibv_open_qp - Open a shareable queue pair. - */ -static inline struct ibv_qp * -ibv_open_qp(struct ibv_context *context, struct ibv_qp_open_attr *qp_open_attr) -{ - struct verbs_context *vctx = verbs_get_ctx_op(context, open_qp); - if (!vctx) { - errno = ENOSYS; - return NULL; - } - return vctx->open_qp(context, qp_open_attr); -} - -/** - * ibv_modify_qp - Modify a queue pair. - */ -int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); - -/** - * ibv_query_qp - Returns the attribute list and current values for the - * specified QP. - * @qp: The QP to query. - * @attr: The attributes of the specified QP. - * @attr_mask: A bit-mask used to select specific attributes to query. - * @init_attr: Additional attributes of the selected QP. - * - * The qp_attr_mask may be used to limit the query to gathering only the - * selected attributes. - */ -int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); - -/** - * ibv_destroy_qp - Destroy a queue pair. - */ -int ibv_destroy_qp(struct ibv_qp *qp); - -/* - * ibv_create_wq - Creates a WQ associated with the specified protection - * domain. - * @context: ibv_context. - * @wq_init_attr: A list of initial attributes required to create the - * WQ. If WQ creation succeeds, then the attributes are updated to - * the actual capabilities of the created WQ. - * - * wq_init_attr->max_wr and wq_init_attr->max_sge determine - * the requested size of the WQ, and set to the actual values allocated - * on return. - * If ibv_create_wq() succeeds, then max_wr and max_sge will always be - * at least as large as the requested values. - * - * Return Value - * ibv_create_wq() returns a pointer to the created WQ, or NULL if the request - * fails. - */ -static inline struct ibv_wq *ibv_create_wq(struct ibv_context *context, - struct ibv_wq_init_attr *wq_init_attr) -{ - struct verbs_context *vctx = verbs_get_ctx_op(context, create_wq); - struct ibv_wq *wq; - - if (!vctx) { - errno = ENOSYS; - return NULL; - } - - wq = vctx->create_wq(context, wq_init_attr); - if (wq) { - wq->events_completed = 0; - pthread_mutex_init(&wq->mutex, NULL); - pthread_cond_init(&wq->cond, NULL); - } - - return wq; -} - -/* - * ibv_modify_wq - Modifies the attributes for the specified WQ. - * @wq: The WQ to modify. - * @wq_attr: On input, specifies the WQ attributes to modify. - * wq_attr->attr_mask: A bit-mask used to specify which attributes of the WQ - * are being modified. - * On output, the current values of selected WQ attributes are returned. - * - * Return Value - * ibv_modify_wq() returns 0 on success, or the value of errno - * on failure (which indicates the failure reason). - * -*/ -static inline int ibv_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr) -{ - struct verbs_context *vctx = verbs_get_ctx_op(wq->context, modify_wq); - - if (!vctx) - return ENOSYS; - - return vctx->modify_wq(wq, wq_attr); -} - -/* - * ibv_destroy_wq - Destroys the specified WQ. - * @ibv_wq: The WQ to destroy. - * Return Value - * ibv_destroy_wq() returns 0 on success, or the value of errno - * on failure (which indicates the failure reason). -*/ -static inline int ibv_destroy_wq(struct ibv_wq *wq) -{ - struct verbs_context *vctx; - - vctx = verbs_get_ctx_op(wq->context, destroy_wq); - if (!vctx) - return ENOSYS; - - return vctx->destroy_wq(wq); -} - -/* - * ibv_create_rwq_ind_table - Creates a receive work queue Indirection Table - * @context: ibv_context. - * @init_attr: A list of initial attributes required to create the Indirection Table. - * Return Value - * ibv_create_rwq_ind_table returns a pointer to the created - * Indirection Table, or NULL if the request fails. - */ -static inline struct ibv_rwq_ind_table *ibv_create_rwq_ind_table(struct ibv_context *context, - struct ibv_rwq_ind_table_init_attr *init_attr) -{ - struct verbs_context *vctx; - - vctx = verbs_get_ctx_op(context, create_rwq_ind_table); - if (!vctx) { - errno = ENOSYS; - return NULL; - } - - return vctx->create_rwq_ind_table(context, init_attr); -} - -/* - * ibv_destroy_rwq_ind_table - Destroys the specified Indirection Table. - * @rwq_ind_table: The Indirection Table to destroy. - * Return Value - * ibv_destroy_rwq_ind_table() returns 0 on success, or the value of errno - * on failure (which indicates the failure reason). -*/ -static inline int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table) -{ - struct verbs_context *vctx; - - vctx = verbs_get_ctx_op(rwq_ind_table->context, destroy_rwq_ind_table); - if (!vctx) - return ENOSYS; - - return vctx->destroy_rwq_ind_table(rwq_ind_table); -} - -/** - * ibv_post_send - Post a list of work requests to a send queue. - * - * If IBV_SEND_INLINE flag is set, the data buffers can be reused - * immediately after the call returns. - */ -static inline int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - return qp->context->ops.post_send(qp, wr, bad_wr); -} - -/** - * ibv_post_recv - Post a list of work requests to a receive queue. - */ -static inline int ibv_post_recv(struct ibv_qp *qp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - return qp->context->ops.post_recv(qp, wr, bad_wr); -} - -/** - * ibv_create_ah - Create an address handle. - */ -struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr); - -/** - * ibv_init_ah_from_wc - Initializes address handle attributes from a - * work completion. - * @context: Device context on which the received message arrived. - * @port_num: Port on which the received message arrived. - * @wc: Work completion associated with the received message. - * @grh: References the received global route header. This parameter is - * ignored unless the work completion indicates that the GRH is valid. - * @ah_attr: Returned attributes that can be used when creating an address - * handle for replying to the message. - */ -int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num, - struct ibv_wc *wc, struct ibv_grh *grh, - struct ibv_ah_attr *ah_attr); - -/** - * ibv_create_ah_from_wc - Creates an address handle associated with the - * sender of the specified work completion. - * @pd: The protection domain associated with the address handle. - * @wc: Work completion information associated with a received message. - * @grh: References the received global route header. This parameter is - * ignored unless the work completion indicates that the GRH is valid. - * @port_num: The outbound port number to associate with the address. - * - * The address handle is used to reference a local or global destination - * in all UD QP post sends. - */ -struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc, - struct ibv_grh *grh, uint8_t port_num); - -/** - * ibv_destroy_ah - Destroy an address handle. - */ -int ibv_destroy_ah(struct ibv_ah *ah); - -/** - * ibv_attach_mcast - Attaches the specified QP to a multicast group. - * @qp: QP to attach to the multicast group. The QP must be a UD QP. - * @gid: Multicast group GID. - * @lid: Multicast group LID in host byte order. - * - * In order to route multicast packets correctly, subnet - * administration must have created the multicast group and configured - * the fabric appropriately. The port associated with the specified - * QP must also be a member of the multicast group. - */ -int ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); - -/** - * ibv_detach_mcast - Detaches the specified QP from a multicast group. - * @qp: QP to detach from the multicast group. - * @gid: Multicast group GID. - * @lid: Multicast group LID in host byte order. - */ -int ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); - -/** - * ibv_fork_init - Prepare data structures so that fork() may be used - * safely. If this function is not called or returns a non-zero - * status, then libibverbs data structures are not fork()-safe and the - * effect of an application calling fork() is undefined. - */ -int ibv_fork_init(void); - -/** - * ibv_node_type_str - Return string describing node_type enum value - */ -const char *ibv_node_type_str(enum ibv_node_type node_type); - -/** - * ibv_port_state_str - Return string describing port_state enum value - */ -const char *ibv_port_state_str(enum ibv_port_state port_state); - -/** - * ibv_event_type_str - Return string describing event_type enum value - */ -const char *ibv_event_type_str(enum ibv_event_type event); - -#define ETHERNET_LL_SIZE 6 -int ibv_resolve_eth_l2_from_gid(struct ibv_context *context, - struct ibv_ah_attr *attr, - uint8_t eth_mac[ETHERNET_LL_SIZE], - uint16_t *vid); - -static inline int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt) -{ - return !!(caps & (1 << qpt)); -} +///** +// * ibv_query_gid - Get a GID table entry +// */ +//int ibv_query_gid(struct ibv_context *context, uint8_t port_num, +// int index, union ibv_gid *gid); +// +///** +// * ibv_query_pkey - Get a P_Key table entry +// */ +//int ibv_query_pkey(struct ibv_context *context, uint8_t port_num, +// int index, __be16 *pkey); +// +///** +// * ibv_alloc_pd - Allocate a protection domain +// */ +//struct ibv_pd *ibv_alloc_pd(struct ibv_context *context); +// +///** +// * ibv_dealloc_pd - Free a protection domain +// */ +//int ibv_dealloc_pd(struct ibv_pd *pd); +// +//static inline struct ibv_flow *ibv_create_flow(struct ibv_qp *qp, +// struct ibv_flow_attr *flow) +//{ +// struct verbs_context *vctx = verbs_get_ctx_op(qp->context, +// ibv_create_flow); +// if (!vctx || !vctx->ibv_create_flow) { +// errno = ENOSYS; +// return NULL; +// } +// +// return vctx->ibv_create_flow(qp, flow); +//} +// +//static inline int ibv_destroy_flow(struct ibv_flow *flow_id) +//{ +// struct verbs_context *vctx = verbs_get_ctx_op(flow_id->context, +// ibv_destroy_flow); +// if (!vctx || !vctx->ibv_destroy_flow) +// return -ENOSYS; +// return vctx->ibv_destroy_flow(flow_id); +//} +// +///** +// * ibv_open_xrcd - Open an extended connection domain +// */ +//static inline struct ibv_xrcd * +//ibv_open_xrcd(struct ibv_context *context, struct ibv_xrcd_init_attr *xrcd_init_attr) +//{ +// struct verbs_context *vctx = verbs_get_ctx_op(context, open_xrcd); +// if (!vctx) { +// errno = ENOSYS; +// return NULL; +// } +// return vctx->open_xrcd(context, xrcd_init_attr); +//} +// +///** +// * ibv_close_xrcd - Close an extended connection domain +// */ +//static inline int ibv_close_xrcd(struct ibv_xrcd *xrcd) +//{ +// struct verbs_context *vctx = verbs_get_ctx(xrcd->context); +// return vctx->close_xrcd(xrcd); +//} +// +///** +// * ibv_reg_mr - Register a memory region +// */ +//struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr, +// size_t length, int access); +// +// +//enum ibv_rereg_mr_err_code { +// /* Old MR is valid, invalid input */ +// IBV_REREG_MR_ERR_INPUT = -1, +// /* Old MR is valid, failed via don't fork on new address range */ +// IBV_REREG_MR_ERR_DONT_FORK_NEW = -2, +// /* New MR is valid, failed via do fork on old address range */ +// IBV_REREG_MR_ERR_DO_FORK_OLD = -3, +// /* MR shouldn't be used, command error */ +// IBV_REREG_MR_ERR_CMD = -4, +// /* MR shouldn't be used, command error, invalid fork state on new address range */ +// IBV_REREG_MR_ERR_CMD_AND_DO_FORK_NEW = -5, +//}; +// +///** +// * ibv_rereg_mr - Re-Register a memory region +// */ +//int ibv_rereg_mr(struct ibv_mr *mr, int flags, +// struct ibv_pd *pd, void *addr, +// size_t length, int access); +///** +// * ibv_dereg_mr - Deregister a memory region +// */ +//int ibv_dereg_mr(struct ibv_mr *mr); +// +///** +// * ibv_alloc_mw - Allocate a memory window +// */ +//static inline struct ibv_mw *ibv_alloc_mw(struct ibv_pd *pd, +// enum ibv_mw_type type) +//{ +// struct ibv_mw *mw; +// +// if (!pd->context->ops.alloc_mw) { +// errno = ENOSYS; +// return NULL; +// } +// +// mw = pd->context->ops.alloc_mw(pd, type); +// return mw; +//} +// +///** +// * ibv_dealloc_mw - Free a memory window +// */ +//static inline int ibv_dealloc_mw(struct ibv_mw *mw) +//{ +// return mw->context->ops.dealloc_mw(mw); +//} +// +///** +// * ibv_inc_rkey - Increase the 8 lsb in the given rkey +// */ +//static inline uint32_t ibv_inc_rkey(uint32_t rkey) +//{ +// const uint32_t mask = 0x000000ff; +// uint8_t newtag = (uint8_t)((rkey + 1) & mask); +// +// return (rkey & ~mask) | newtag; +//} +// +///** +// * ibv_bind_mw - Bind a memory window to a region +// */ +//static inline int ibv_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw, +// struct ibv_mw_bind *mw_bind) +//{ +// if (mw->type != IBV_MW_TYPE_1) +// return EINVAL; +// +// return mw->context->ops.bind_mw(qp, mw, mw_bind); +//} +// +///** +// * ibv_create_comp_channel - Create a completion event channel +// */ +//struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context); +// +///** +// * ibv_destroy_comp_channel - Destroy a completion event channel +// */ +//int ibv_destroy_comp_channel(struct ibv_comp_channel *channel); +// +///** +// * ibv_create_cq - Create a completion queue +// * @context - Context CQ will be attached to +// * @cqe - Minimum number of entries required for CQ +// * @cq_context - Consumer-supplied context returned for completion events +// * @channel - Completion channel where completion events will be queued. +// * May be NULL if completion events will not be used. +// * @comp_vector - Completion vector used to signal completion events. +// * Must be >= 0 and < context->num_comp_vectors. +// */ +//struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe, +// void *cq_context, +// struct ibv_comp_channel *channel, +// int comp_vector); +// +///** +// * ibv_create_cq_ex - Create a completion queue +// * @context - Context CQ will be attached to +// * @cq_attr - Attributes to create the CQ with +// */ +//static inline +//struct ibv_cq_ex *ibv_create_cq_ex(struct ibv_context *context, +// struct ibv_cq_init_attr_ex *cq_attr) +//{ +// struct verbs_context *vctx = verbs_get_ctx_op(context, create_cq_ex); +// +// if (!vctx) { +// errno = ENOSYS; +// return NULL; +// } +// +// if (cq_attr->comp_mask & ~(IBV_CQ_INIT_ATTR_MASK_RESERVED - 1)) { +// errno = EINVAL; +// return NULL; +// } +// +// return vctx->create_cq_ex(context, cq_attr); +//} +// +///** +// * ibv_resize_cq - Modifies the capacity of the CQ. +// * @cq: The CQ to resize. +// * @cqe: The minimum size of the CQ. +// * +// * Users can examine the cq structure to determine the actual CQ size. +// */ +//int ibv_resize_cq(struct ibv_cq *cq, int cqe); +// +///** +// * ibv_destroy_cq - Destroy a completion queue +// */ +//int ibv_destroy_cq(struct ibv_cq *cq); +// +///** +// * ibv_get_cq_event - Read next CQ event +// * @channel: Channel to get next event from. +// * @cq: Used to return pointer to CQ. +// * @cq_context: Used to return consumer-supplied CQ context. +// * +// * All completion events returned by ibv_get_cq_event() must +// * eventually be acknowledged with ibv_ack_cq_events(). +// */ +//int ibv_get_cq_event(struct ibv_comp_channel *channel, +// struct ibv_cq **cq, void **cq_context); +// +///** +// * ibv_ack_cq_events - Acknowledge CQ completion events +// * @cq: CQ to acknowledge events for +// * @nevents: Number of events to acknowledge. +// * +// * All completion events which are returned by ibv_get_cq_event() must +// * be acknowledged. To avoid races, ibv_destroy_cq() will wait for +// * all completion events to be acknowledged, so there should be a +// * one-to-one correspondence between acks and successful gets. An +// * application may accumulate multiple completion events and +// * acknowledge them in a single call to ibv_ack_cq_events() by passing +// * the number of events to ack in @nevents. +// */ +//void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents); +// +///** +// * ibv_poll_cq - Poll a CQ for work completions +// * @cq:the CQ being polled +// * @num_entries:maximum number of completions to return +// * @wc:array of at least @num_entries of &struct ibv_wc where completions +// * will be returned +// * +// * Poll a CQ for (possibly multiple) completions. If the return value +// * is < 0, an error occurred. If the return value is >= 0, it is the +// * number of completions returned. If the return value is +// * non-negative and strictly less than num_entries, then the CQ was +// * emptied. +// */ +//static inline int ibv_poll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc) +//{ +// return cq->context->ops.poll_cq(cq, num_entries, wc); +//} +// +///** +// * ibv_req_notify_cq - Request completion notification on a CQ. An +// * event will be added to the completion channel associated with the +// * CQ when an entry is added to the CQ. +// * @cq: The completion queue to request notification for. +// * @solicited_only: If non-zero, an event will be generated only for +// * the next solicited CQ entry. If zero, any CQ entry, solicited or +// * not, will generate an event. +// */ +//static inline int ibv_req_notify_cq(struct ibv_cq *cq, int solicited_only) +//{ +// return cq->context->ops.req_notify_cq(cq, solicited_only); +//} +// +///** +// * ibv_create_srq - Creates a SRQ associated with the specified protection +// * domain. +// * @pd: The protection domain associated with the SRQ. +// * @srq_init_attr: A list of initial attributes required to create the SRQ. +// * +// * srq_attr->max_wr and srq_attr->max_sge are read the determine the +// * requested size of the SRQ, and set to the actual values allocated +// * on return. If ibv_create_srq() succeeds, then max_wr and max_sge +// * will always be at least as large as the requested values. +// */ +//struct ibv_srq *ibv_create_srq(struct ibv_pd *pd, +// struct ibv_srq_init_attr *srq_init_attr); +// +//static inline struct ibv_srq * +//ibv_create_srq_ex(struct ibv_context *context, +// struct ibv_srq_init_attr_ex *srq_init_attr_ex) +//{ +// struct verbs_context *vctx; +// uint32_t mask = srq_init_attr_ex->comp_mask; +// +// if (!(mask & ~(IBV_SRQ_INIT_ATTR_PD | IBV_SRQ_INIT_ATTR_TYPE)) && +// (mask & IBV_SRQ_INIT_ATTR_PD) && +// (!(mask & IBV_SRQ_INIT_ATTR_TYPE) || +// (srq_init_attr_ex->srq_type == IBV_SRQT_BASIC))) +// return ibv_create_srq(srq_init_attr_ex->pd, +// (struct ibv_srq_init_attr *)srq_init_attr_ex); +// +// vctx = verbs_get_ctx_op(context, create_srq_ex); +// if (!vctx) { +// errno = ENOSYS; +// return NULL; +// } +// return vctx->create_srq_ex(context, srq_init_attr_ex); +//} +// +///** +// * ibv_modify_srq - Modifies the attributes for the specified SRQ. +// * @srq: The SRQ to modify. +// * @srq_attr: On input, specifies the SRQ attributes to modify. On output, +// * the current values of selected SRQ attributes are returned. +// * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ +// * are being modified. +// * +// * The mask may contain IBV_SRQ_MAX_WR to resize the SRQ and/or +// * IBV_SRQ_LIMIT to set the SRQ's limit and request notification when +// * the number of receives queued drops below the limit. +// */ +//int ibv_modify_srq(struct ibv_srq *srq, +// struct ibv_srq_attr *srq_attr, +// int srq_attr_mask); +// +///** +// * ibv_query_srq - Returns the attribute list and current values for the +// * specified SRQ. +// * @srq: The SRQ to query. +// * @srq_attr: The attributes of the specified SRQ. +// */ +//int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr); +// +//static inline int ibv_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num) +//{ +// struct verbs_context *vctx = verbs_get_ctx_op(srq->context, get_srq_num); +// +// if (!vctx) +// return ENOSYS; +// +// return vctx->get_srq_num(srq, srq_num); +//} +// +///** +// * ibv_destroy_srq - Destroys the specified SRQ. +// * @srq: The SRQ to destroy. +// */ +//int ibv_destroy_srq(struct ibv_srq *srq); +// +///** +// * ibv_post_srq_recv - Posts a list of work requests to the specified SRQ. +// * @srq: The SRQ to post the work request on. +// * @recv_wr: A list of work requests to post on the receive queue. +// * @bad_recv_wr: On an immediate failure, this parameter will reference +// * the work request that failed to be posted on the QP. +// */ +//static inline int ibv_post_srq_recv(struct ibv_srq *srq, +// struct ibv_recv_wr *recv_wr, +// struct ibv_recv_wr **bad_recv_wr) +//{ +// return srq->context->ops.post_srq_recv(srq, recv_wr, bad_recv_wr); +//} +// +///** +// * ibv_create_qp - Create a queue pair. +// */ +//struct ibv_qp *ibv_create_qp(struct ibv_pd *pd, +// struct ibv_qp_init_attr *qp_init_attr); +// +//static inline struct ibv_qp * +//ibv_create_qp_ex(struct ibv_context *context, struct ibv_qp_init_attr_ex *qp_init_attr_ex) +//{ +// struct verbs_context *vctx; +// uint32_t mask = qp_init_attr_ex->comp_mask; +// +// if (mask == IBV_QP_INIT_ATTR_PD) +// return ibv_create_qp(qp_init_attr_ex->pd, +// (struct ibv_qp_init_attr *)qp_init_attr_ex); +// +// vctx = verbs_get_ctx_op(context, create_qp_ex); +// if (!vctx) { +// errno = ENOSYS; +// return NULL; +// } +// return vctx->create_qp_ex(context, qp_init_attr_ex); +//} +// +///** +// * ibv_query_rt_values_ex - Get current real time @values of a device. +// * @values - in/out - defines the attributes we need to query/queried. +// * (Or's bits of enum ibv_values_mask on values->comp_mask field) +// */ +//static inline int +//ibv_query_rt_values_ex(struct ibv_context *context, +// struct ibv_values_ex *values) +//{ +// struct verbs_context *vctx; +// +// vctx = verbs_get_ctx_op(context, query_rt_values); +// if (!vctx) +// return ENOSYS; +// +// if (values->comp_mask & ~(IBV_VALUES_MASK_RESERVED - 1)) +// return EINVAL; +// +// return vctx->query_rt_values(context, values); +//} +// +///** +// * ibv_query_device_ex - Get extended device properties +// */ +//static inline int +//ibv_query_device_ex(struct ibv_context *context, +// const struct ibv_query_device_ex_input *input, +// struct ibv_device_attr_ex *attr) +//{ +// struct verbs_context *vctx; +// int ret; +// +// vctx = verbs_get_ctx_op(context, query_device_ex); +// if (!vctx) +// goto legacy; +// +// ret = vctx->query_device_ex(context, input, attr, sizeof(*attr)); +// if (ret == ENOSYS) +// goto legacy; +// +// return ret; +// +//legacy: +// memset(attr, 0, sizeof(*attr)); +// ret = ibv_query_device(context, &attr->orig_attr); +// +// return ret; +//} +// +///** +// * ibv_open_qp - Open a shareable queue pair. +// */ +//static inline struct ibv_qp * +//ibv_open_qp(struct ibv_context *context, struct ibv_qp_open_attr *qp_open_attr) +//{ +// struct verbs_context *vctx = verbs_get_ctx_op(context, open_qp); +// if (!vctx) { +// errno = ENOSYS; +// return NULL; +// } +// return vctx->open_qp(context, qp_open_attr); +//} +// +///** +// * ibv_modify_qp - Modify a queue pair. +// */ +//int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, +// int attr_mask); +// +///** +// * ibv_query_qp - Returns the attribute list and current values for the +// * specified QP. +// * @qp: The QP to query. +// * @attr: The attributes of the specified QP. +// * @attr_mask: A bit-mask used to select specific attributes to query. +// * @init_attr: Additional attributes of the selected QP. +// * +// * The qp_attr_mask may be used to limit the query to gathering only the +// * selected attributes. +// */ +//int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, +// int attr_mask, +// struct ibv_qp_init_attr *init_attr); +// +///** +// * ibv_destroy_qp - Destroy a queue pair. +// */ +//int ibv_destroy_qp(struct ibv_qp *qp); +// +///* +// * ibv_create_wq - Creates a WQ associated with the specified protection +// * domain. +// * @context: ibv_context. +// * @wq_init_attr: A list of initial attributes required to create the +// * WQ. If WQ creation succeeds, then the attributes are updated to +// * the actual capabilities of the created WQ. +// * +// * wq_init_attr->max_wr and wq_init_attr->max_sge determine +// * the requested size of the WQ, and set to the actual values allocated +// * on return. +// * If ibv_create_wq() succeeds, then max_wr and max_sge will always be +// * at least as large as the requested values. +// * +// * Return Value +// * ibv_create_wq() returns a pointer to the created WQ, or NULL if the request +// * fails. +// */ +//static inline struct ibv_wq *ibv_create_wq(struct ibv_context *context, +// struct ibv_wq_init_attr *wq_init_attr) +//{ +// struct verbs_context *vctx = verbs_get_ctx_op(context, create_wq); +// struct ibv_wq *wq; +// +// if (!vctx) { +// errno = ENOSYS; +// return NULL; +// } +// +// wq = vctx->create_wq(context, wq_init_attr); +// if (wq) { +// wq->events_completed = 0; +// pthread_mutex_init(&wq->mutex, NULL); +// pthread_cond_init(&wq->cond, NULL); +// } +// +// return wq; +//} +// +///* +// * ibv_modify_wq - Modifies the attributes for the specified WQ. +// * @wq: The WQ to modify. +// * @wq_attr: On input, specifies the WQ attributes to modify. +// * wq_attr->attr_mask: A bit-mask used to specify which attributes of the WQ +// * are being modified. +// * On output, the current values of selected WQ attributes are returned. +// * +// * Return Value +// * ibv_modify_wq() returns 0 on success, or the value of errno +// * on failure (which indicates the failure reason). +// * +//*/ +//static inline int ibv_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr) +//{ +// struct verbs_context *vctx = verbs_get_ctx_op(wq->context, modify_wq); +// +// if (!vctx) +// return ENOSYS; +// +// return vctx->modify_wq(wq, wq_attr); +//} +// +///* +// * ibv_destroy_wq - Destroys the specified WQ. +// * @ibv_wq: The WQ to destroy. +// * Return Value +// * ibv_destroy_wq() returns 0 on success, or the value of errno +// * on failure (which indicates the failure reason). +//*/ +//static inline int ibv_destroy_wq(struct ibv_wq *wq) +//{ +// struct verbs_context *vctx; +// +// vctx = verbs_get_ctx_op(wq->context, destroy_wq); +// if (!vctx) +// return ENOSYS; +// +// return vctx->destroy_wq(wq); +//} +// +///* +// * ibv_create_rwq_ind_table - Creates a receive work queue Indirection Table +// * @context: ibv_context. +// * @init_attr: A list of initial attributes required to create the Indirection Table. +// * Return Value +// * ibv_create_rwq_ind_table returns a pointer to the created +// * Indirection Table, or NULL if the request fails. +// */ +//static inline struct ibv_rwq_ind_table *ibv_create_rwq_ind_table(struct ibv_context *context, +// struct ibv_rwq_ind_table_init_attr *init_attr) +//{ +// struct verbs_context *vctx; +// +// vctx = verbs_get_ctx_op(context, create_rwq_ind_table); +// if (!vctx) { +// errno = ENOSYS; +// return NULL; +// } +// +// return vctx->create_rwq_ind_table(context, init_attr); +//} +// +///* +// * ibv_destroy_rwq_ind_table - Destroys the specified Indirection Table. +// * @rwq_ind_table: The Indirection Table to destroy. +// * Return Value +// * ibv_destroy_rwq_ind_table() returns 0 on success, or the value of errno +// * on failure (which indicates the failure reason). +//*/ +//static inline int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table) +//{ +// struct verbs_context *vctx; +// +// vctx = verbs_get_ctx_op(rwq_ind_table->context, destroy_rwq_ind_table); +// if (!vctx) +// return ENOSYS; +// +// return vctx->destroy_rwq_ind_table(rwq_ind_table); +//} +// +///** +// * ibv_post_send - Post a list of work requests to a send queue. +// * +// * If IBV_SEND_INLINE flag is set, the data buffers can be reused +// * immediately after the call returns. +// */ +//static inline int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr, +// struct ibv_send_wr **bad_wr) +//{ +// return qp->context->ops.post_send(qp, wr, bad_wr); +//} +// +///** +// * ibv_post_recv - Post a list of work requests to a receive queue. +// */ +//static inline int ibv_post_recv(struct ibv_qp *qp, struct ibv_recv_wr *wr, +// struct ibv_recv_wr **bad_wr) +//{ +// return qp->context->ops.post_recv(qp, wr, bad_wr); +//} +// +///** +// * ibv_create_ah - Create an address handle. +// */ +//struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr); +// +///** +// * ibv_init_ah_from_wc - Initializes address handle attributes from a +// * work completion. +// * @context: Device context on which the received message arrived. +// * @port_num: Port on which the received message arrived. +// * @wc: Work completion associated with the received message. +// * @grh: References the received global route header. This parameter is +// * ignored unless the work completion indicates that the GRH is valid. +// * @ah_attr: Returned attributes that can be used when creating an address +// * handle for replying to the message. +// */ +//int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num, +// struct ibv_wc *wc, struct ibv_grh *grh, +// struct ibv_ah_attr *ah_attr); +// +///** +// * ibv_create_ah_from_wc - Creates an address handle associated with the +// * sender of the specified work completion. +// * @pd: The protection domain associated with the address handle. +// * @wc: Work completion information associated with a received message. +// * @grh: References the received global route header. This parameter is +// * ignored unless the work completion indicates that the GRH is valid. +// * @port_num: The outbound port number to associate with the address. +// * +// * The address handle is used to reference a local or global destination +// * in all UD QP post sends. +// */ +//struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc, +// struct ibv_grh *grh, uint8_t port_num); +// +///** +// * ibv_destroy_ah - Destroy an address handle. +// */ +//int ibv_destroy_ah(struct ibv_ah *ah); +// +///** +// * ibv_attach_mcast - Attaches the specified QP to a multicast group. +// * @qp: QP to attach to the multicast group. The QP must be a UD QP. +// * @gid: Multicast group GID. +// * @lid: Multicast group LID in host byte order. +// * +// * In order to route multicast packets correctly, subnet +// * administration must have created the multicast group and configured +// * the fabric appropriately. The port associated with the specified +// * QP must also be a member of the multicast group. +// */ +//int ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); +// +///** +// * ibv_detach_mcast - Detaches the specified QP from a multicast group. +// * @qp: QP to detach from the multicast group. +// * @gid: Multicast group GID. +// * @lid: Multicast group LID in host byte order. +// */ +//int ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); +// +///** +// * ibv_fork_init - Prepare data structures so that fork() may be used +// * safely. If this function is not called or returns a non-zero +// * status, then libibverbs data structures are not fork()-safe and the +// * effect of an application calling fork() is undefined. +// */ +//int ibv_fork_init(void); +// +///** +// * ibv_node_type_str - Return string describing node_type enum value +// */ +//const char *ibv_node_type_str(enum ibv_node_type node_type); +// +///** +// * ibv_port_state_str - Return string describing port_state enum value +// */ +//const char *ibv_port_state_str(enum ibv_port_state port_state); +// +///** +// * ibv_event_type_str - Return string describing event_type enum value +// */ +//const char *ibv_event_type_str(enum ibv_event_type event); +// +//#define ETHERNET_LL_SIZE 6 +//int ibv_resolve_eth_l2_from_gid(struct ibv_context *context, +// struct ibv_ah_attr *attr, +// uint8_t eth_mac[ETHERNET_LL_SIZE], +// uint16_t *vid); +// +//static inline int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt) +//{ +// return !!(caps & (1 << qpt)); +//} END_C_DECLS diff --git a/usr/rdma-core/.travis.yml b/usr/rdma-core/.travis.yml deleted file mode 100644 index c190a2418..000000000 --- a/usr/rdma-core/.travis.yml +++ /dev/null @@ -1,70 +0,0 @@ -language: c -# We need at least cmake 2.12, this means we need to use trusty. -# Precise's glibc, etc predates what we are willing to support. -# sudo is required to get the trusty image, and at present to enable new llvm -sudo: required -dist: trusty -addons: - # We run our builds sequentially in one VM rather than try and use the - # matrix feature. This is because Travis is unreasonably inefficient - # doing this APT setup pass. - apt: - sources: - # sourceline because travis won't white list trusty builds, and hasn't - # whitelisted 4.0 - - sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main" - key_url: "http://apt.llvm.org/llvm-snapshot.gpg.key" - - ubuntu-toolchain-r-test - # Multiverse is not on by default and we need it to get sparse - - sourceline: "deb http://archive.ubuntu.com/ubuntu/ trusty multiverse" - packages: - - build-essential - - clang-4.0 - - cmake - - debhelper - - dh-systemd - - fakeroot - - gcc - - gcc-7 - - git - - libnl-3-dev - - libnl-route-3-dev - - libudev-dev - - make - - ninja-build - - pkg-config - - python - - valgrind - - sparse - - wget - - # 32 bit support packages - - gcc-multilib - - lib32gcc-7-dev - -before_script: - - export LATEST_GCC_LINARO_URL=`wget -qO - https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/ | grep -o ' - int main(int argc,const char *argv[]) { int access = 1; return access; }" - HAVE_C_WORKING_SHADOW - FAIL_REGEX "warning") -if (HAVE_C_WORKING_SHADOW) - RDMA_AddOptCFlag(CMAKE_C_FLAGS HAVE_C_WORKING_SHADOW "-Wshadow") -endif() -set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") - -# At some point around 5.4 gcc fixed missing-field-initializers to ignore this -# common idiom we use extensively. Since this is a useful warning for -# developers try and leave it on if the compiler supports it. -CHECK_C_SOURCE_COMPILES(" - struct foo { int a; int b; }; - int main(int argc,const char *argv[]) { struct foo tmp = {}; return tmp.a; }" - HAVE_C_WORKING_MISSING_FIELD_INITIALIZERS - FAIL_REGEX "warning") -if (NOT HAVE_C_WORKING_MISSING_FIELD_INITIALIZERS) - RDMA_AddOptCFlag(CMAKE_C_FLAGS HAVE_C_WNO_MISSING_FIELD_INITIALIZERS "-Wno-missing-field-initializers") -endif() - -# Check that the compiler supports -fno-strict-aliasing. -# The use of this flag in the source is discouraged -set(NO_STRICT_ALIASING_FLAGS "") -RDMA_AddOptCFlag(NO_STRICT_ALIASING_FLAGS HAVE_NO_STRICT_ALIASING - "-fno-strict-aliasing") - -CHECK_C_SOURCE_COMPILES(" - #include - - void entry(void); - - static void do_entry(void) {} - void entry(void) __attribute__((ifunc(\"resolve_entry\"))); - static void *resolve_entry(void) {return &do_entry;} - - int main(int argc,const char *argv[]) { entry(); }" - HAVE_FUNC_ATTRIBUTE_IFUNC - FAIL_REGEX "warning") - -# The code does not do the racy fcntl if the various CLOEXEC's are not -# supported so it really doesn't work right if this isn't available. Thus hard -# require it. -CHECK_C_SOURCE_COMPILES(" - #include - #include - #include - #include - int main(int argc,const char *argv[]) { - open(\".\",O_RDONLY | O_CLOEXEC); - socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); - return 0; - }" HAS_CLOEXEC) - -if (NOT HAS_CLOEXEC) -# At least uclibc wrongly hides this POSIX constant behind _GNU_SOURCE -CHECK_C_SOURCE_COMPILES(" - #define _GNU_SOURCE - #include - #include - #include - #include - int main(int argc,const char *argv[]) { - open(\".\",O_RDONLY | O_CLOEXEC); - socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); - return 0; - }" HAS_CLOEXEC_GNU_SOURCE) - if (HAS_CLOEXEC_GNU_SOURCE) - set(HAS_CLOEXEC 1) - add_definitions("-D_GNU_SOURCE=") - endif() -endif() - -if (NOT HAS_CLOEXEC) - message(FATAL_ERROR "O_CLOEXEC/SOCK_CLOEXEC/fopen(..,\"e\") support is required but not found") -endif() - -# always_inline is supported -CHECK_C_SOURCE_COMPILES(" - int foo(void); - inline __attribute__((always_inline)) int foo(void) {return 0;} - int main(int argc,const char *argv[]) { return foo(); }" - HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE - FAIL_REGEX "warning") - -# Provide a shim if C11 stdatomic.h is not supported. -if (NOT HAVE_SPARSE) - CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC) - RDMA_DoFixup("${HAVE_STDATOMIC}" "stdatomic.h") -endif() - -# Enable development support features -# Prune unneeded shared libraries during linking -RDMA_AddOptLDFlag(CMAKE_EXE_LINKER_FLAGS SUPPORTS_AS_NEEDED "-Wl,--as-needed") -RDMA_AddOptLDFlag(CMAKE_SHARED_LINKER_FLAGS SUPPORTS_AS_NEEDED "-Wl,--as-needed") -RDMA_AddOptLDFlag(CMAKE_MODULE_LINKER_FLAGS SUPPORTS_AS_NEEDED "-Wl,--as-needed") - -# Ensure all shared ELFs have fully described linking -RDMA_AddOptLDFlag(CMAKE_EXE_LINKER_FLAGS SUPPORTS_NO_UNDEFINED "-Wl,--no-undefined") -RDMA_AddOptLDFlag(CMAKE_SHARED_LINKER_FLAGS SUPPORTS_NO_UNDEFINED "-Wl,--no-undefined") - -# Enable gold linker - gold has different linking checks -#RDMA_AddOptLDFlag(CMAKE_EXE_LINKER_FLAGS SUPPORTS_NO_UNDEFINED "-fuse-ld=gold") -#RDMA_AddOptLDFlag(CMAKE_SHARED_LINKER_FLAGS SUPPORTS_NO_UNDEFINED "-fuse-ld=gold") -#RDMA_AddOptLDFlag(CMAKE_MODULE_LINKER_FLAGS SUPPORTS_NO_UNDEFINED "-fuse-ld=gold") - -# Verify that GNU --version-script and asm(".symver") works -find_package(LDSymVer REQUIRED) -if (NO_COMPAT_SYMS) - set(HAVE_LIMITED_SYMBOL_VERSIONS 1) -else() - set(HAVE_FULL_SYMBOL_VERSIONS 1) -endif() - -#------------------------- -# Find libraries -# pthread -FIND_PACKAGE (Threads REQUIRED) - -# libnl -if (NOT DEFINED ENABLE_RESOLVE_NEIGH) - set(ENABLE_RESOLVE_NEIGH "ON" CACHE BOOL "Enable internal resolution of neighbours for Etherent") -endif() -if (ENABLE_RESOLVE_NEIGH) - # FIXME use of pkgconfig is discouraged - pkg_check_modules(NL3 libnl-3.0 libnl-route-3.0) - if (NL3_FOUND) - set(NL_KIND 3) - set(NL_INCLUDE_DIRS ${NL3_INCLUDE_DIRS}) - set(NL_LIBRARIES ${NL3_LIBRARIES}) - else() - # FIXME: I don't know why we have this fallback, all supported distros - # have libnl3 - pkg_check_modules(NL1 libnl-1) - if (NL1_FOUND) - set(NL_KIND 1) - set(NL_INCLUDE_DIRS ${NL1_INCLUDE_DIRS}) - set(NL_LIBRARIES ${NL1_LIBRARIES}) - else() - message(FATAL_ERROR "Cannot find libnl-3.0 or libnl-1") - endif() - endif() - - include_directories(${NL_INCLUDE_DIRS}) -else() - set(NL_KIND 0) - set(NL_LIBRARIES "") -endif() - -# Older stuff blows up if these headers are included together -if (NOT NL_KIND EQUAL 0) - set(SAFE_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") - set(CMAKE_REQUIRED_INCLUDES "${NL_INCLUDE_DIRS}") - CHECK_C_SOURCE_COMPILES(" -#include -#include - int main(int argc,const char *argv[]) {return 0;}" - HAVE_WORKING_IF_H) - set(CMAKE_REQUIRED_INCLUDES "${SAFE_CMAKE_REQUIRED_INCLUDES}") -endif() - -# udev -find_package(UDev) -include_directories(${UDEV_INCLUDE_DIRS}) - -# Statically determine sizeof(long), this is largely unnecessary, no new code -# should rely on this. -check_type_size("long" SIZEOF_LONG BUILTIN_TYPES_ONLY LANGUAGE C) - -include(RDMA_LinuxHeaders) - -# Determine if this arch supports cache coherent DMA. This isn't really an -# arch specific property, but for our purposes arches that do not support it -# also do not define wmb/etc which breaks our compile. -CHECK_C_SOURCE_COMPILES(" -#include \"${CMAKE_CURRENT_SOURCE_DIR}/util/udma_barrier.h\" - int main(int argc,const char *argv[]) {return 0;}" - HAVE_COHERENT_DMA) - -find_package(Systemd) -include_directories(${SYSTEMD_INCLUDE_DIRS}) -RDMA_DoFixup("${SYSTEMD_FOUND}" "systemd/sd-daemon.h") - -#------------------------- -# Apply fixups - -# We prefer to build with valgrind memcheck.h present, but if not, or the user -# requested valgrind disabled, then replace it with our dummy stub. -if (NOT DEFINED ENABLE_VALGRIND) - set(ENABLE_VALGRIND "ON" CACHE BOOL "Enable use of valgrind annotations") -endif() -if (ENABLE_VALGRIND) - CHECK_INCLUDE_FILE("valgrind/memcheck.h" HAVE_VALGRIND_MEMCHECK) - CHECK_INCLUDE_FILE("valgrind/drd.h" HAVE_VALGRIND_DRD) -else() - set(HAVE_VALGRIND_MEMCHECK 0) - set(HAVE_VALGRIND_DRD 0) -endif() -RDMA_DoFixup("${HAVE_VALGRIND_MEMCHECK}" "valgrind/memcheck.h") -RDMA_DoFixup("${HAVE_VALGRIND_DRD}" "valgrind/drd.h") - -# Older glibc does not include librt -CHECK_C_SOURCE_COMPILES(" -#include -int main(int argc,const char *argv[]) { - clock_gettime(CLOCK_MONOTONIC,0); - clock_nanosleep(CLOCK_MONOTONIC,0,0,0); - return 0; -};" LIBC_HAS_LIBRT) -if (NOT LIBC_HAS_LIBRT) - set(RT_LIBRARIES "rt") -endif() - -#------------------------- -# Final warning flags - -# Old version of cmake used 'main(){..}' as their test program which breaks with -Werror. -# So set this flag last. -RDMA_AddOptCFlag(CMAKE_C_FLAGS HAVE_C_WSTRICT_PROTOTYPES "-Wstrict-prototypes") -RDMA_AddOptCFlag(CMAKE_C_FLAGS HAVE_C_WOLD_STYLE_DEFINITION "-Wold-style-definition") - -# Old versions of libnl have a duplicated rtnl_route_put, disbale the warning on those -# systems -if (NOT NL_KIND EQUAL 0) - set(SAFE_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") - set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_INCLUDES "${NL_INCLUDE_DIRS}") - set(CMAKE_REQUIRED_FLAGS "-Wredundant-decls") - CHECK_C_SOURCE_COMPILES(" - #include - int main(int argc,const char *argv[]) { return 0; }" - HAVE_C_WREDUNDANT_DECLS - FAIL_REGEX "warning") - set(CMAKE_REQUIRED_INCLUDES "${SAFE_CMAKE_REQUIRED_INCLUDES}") - set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") -endif() -RDMA_AddOptCFlag(CMAKE_C_FLAGS HAVE_C_WREDUNDANT_DECLS "-Wredundant-decls") - -#------------------------- -# Build Prep -# Write out a git ignore file to the build directory if it isn't the source -# directory. For developer convenience -if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) - file(WRITE ${CMAKE_BINARY_DIR}/.gitignore "*") -endif() - -configure_file("${BUILDLIB}/config.h.in" "${BUILD_INCLUDE}/config.h" ESCAPE_QUOTES @ONLY) - -#------------------------- -# Sub-directories -add_subdirectory(ccan) -add_subdirectory(util) -add_subdirectory(Documentation) -add_subdirectory(kernel-boot) -# Libraries -add_subdirectory(libibumad) -add_subdirectory(libibumad/man) -add_subdirectory(libibverbs) -add_subdirectory(libibverbs/man) -add_subdirectory(librdmacm) -add_subdirectory(librdmacm/man) -add_subdirectory(libibcm) - -# Providers -if (HAVE_COHERENT_DMA) -add_subdirectory(providers/bnxt_re) -add_subdirectory(providers/cxgb3) # NO SPARSE -add_subdirectory(providers/cxgb4) # NO SPARSE -add_subdirectory(providers/hns) # NO SPARSE -add_subdirectory(providers/i40iw) # NO SPARSE -add_subdirectory(providers/mlx4) -add_subdirectory(providers/mlx4/man) -add_subdirectory(providers/mlx5) -add_subdirectory(providers/mlx5/man) -add_subdirectory(providers/mthca) -add_subdirectory(providers/nes) # NO SPARSE -add_subdirectory(providers/ocrdma) -add_subdirectory(providers/qedr) -add_subdirectory(providers/vmw_pvrdma) -endif() - -add_subdirectory(providers/hfi1verbs) -add_subdirectory(providers/ipathverbs) -add_subdirectory(providers/rxe) -add_subdirectory(providers/rxe/man) - -# Binaries -add_subdirectory(ibacm) # NO SPARSE -if (NOT NL_KIND EQUAL 0) - add_subdirectory(iwpmd) -endif() -add_subdirectory(libibcm/examples) -add_subdirectory(libibumad/tests) -add_subdirectory(libibverbs/examples) -add_subdirectory(librdmacm/examples) -if (UDEV_FOUND) - add_subdirectory(rdma-ndd) -endif() -add_subdirectory(srp_daemon) - -rdma_finalize_libs() - -#------------------------- -# Display a summary -# Only report things that are non-ideal. -message(STATUS "Missing Optional Items:") -if (NOT HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE) - message(STATUS " Compiler attribute always_inline NOT supported") -endif() -if (NOT HAVE_FUNC_ATTRIBUTE_IFUNC) - message(STATUS " Compiler attribute ifunc NOT supported") -endif() -if (NOT HAVE_COHERENT_DMA) - message(STATUS " Architecture NOT able to do coherent DMA (check util/udma_barrier.h) some providers disabled!") -endif() -if (NOT HAVE_STDATOMIC) - message(STATUS " C11 stdatomic.h NOT available (old compiler)") -endif() -if (NOT HAVE_VALGRIND_MEMCHECK) - message(STATUS " Valgrind memcheck.h NOT enabled") -endif() -if (NOT HAVE_VALGRIND_DRD) - message(STATUS " Valgrind drd.h NOT enabled") -endif() -if (NL_KIND EQUAL 1) - message(STATUS " libnl 3 NOT found (using libnl 1 compat)") -endif() -if (NL_KIND EQUAL 0) - message(STATUS " neighbour resolution NOT enabled") -else() - if (NOT HAVE_WORKING_IF_H) - message(STATUS " netlink/route/link.h and net/if.h NOT co-includable (old headers)") - endif() -endif() -if (NOT SYSTEMD_FOUND) - message(STATUS " libsystemd NOT found (disabling features)") -endif() -if (NOT UDEV_FOUND) - message(STATUS " libudev NOT found (disabling features)") -endif() -rdma_report_missing_kheaders() -if (NOT HAVE_C_WARNINGS) - message(STATUS " extended C warnings NOT supported") -endif() -if (NOT HAVE_NO_STRICT_ALIASING) - message(STATUS " -fno-strict-aliasing NOT supported") -endif() -if (NOT HAVE_C_WORKING_MISSING_FIELD_INITIALIZERS) - message(STATUS " -Wmissing-field-initializers does NOT work") -endif() -if (NOT HAVE_C_WORKING_SHADOW) - message(STATUS " -Wshadow does NOT work") -endif() -if (NOT HAVE_C_WREDUNDANT_DECLS) - message(STATUS " -Wredundant-decls does NOT work") -endif() diff --git a/usr/rdma-core/COPYING.BSD_FB b/usr/rdma-core/COPYING.BSD_FB deleted file mode 100644 index 44237612f..000000000 --- a/usr/rdma-core/COPYING.BSD_FB +++ /dev/null @@ -1,22 +0,0 @@ - OpenIB.org BSD license (FreeBSD Variant) - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/usr/rdma-core/COPYING.BSD_MIT b/usr/rdma-core/COPYING.BSD_MIT deleted file mode 100644 index a1432b613..000000000 --- a/usr/rdma-core/COPYING.BSD_MIT +++ /dev/null @@ -1,20 +0,0 @@ - OpenIB.org BSD license (MIT variant) - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/usr/rdma-core/COPYING.GPL2 b/usr/rdma-core/COPYING.GPL2 deleted file mode 100644 index d159169d1..000000000 --- a/usr/rdma-core/COPYING.GPL2 +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/usr/rdma-core/COPYING.md b/usr/rdma-core/COPYING.md deleted file mode 100644 index 91f2fdd6a..000000000 --- a/usr/rdma-core/COPYING.md +++ /dev/null @@ -1,65 +0,0 @@ -# Default Dual License - -Unless otherwise stated this software is available to you under a choice of -one of two licenses. You may choose to be licensed under the terms of the -OpenIB.org BSD (MIT variant) license (see COPYING.BSD_MIT) or the GNU General -Public License (GPL) Version 2 (see COPYING.GPL2), both included in this -package. - -Files marked 'See COPYING file' are licensed under the above Dual License. - -# Other Options - -Individual source files may use a license different from the above Defaul Dual -License. If a license is declared in the file then it supersedes the Default -License. - -If a directory contains a COPYING file then the License from that file becomes -the Default License for files in that directory and below. - -# Copyright Holders - -Refer to individual files for information on the copyright holders. - -# License Catalog (Informative, Non Binding) - -## Utilities - -Utility source code that may be linked into any binary are available under -several licenses: - - - MIT license (see ccan/LICENSE.MIT) - - Creative Commons CC0 1.0 Universal License (see ccan/LICENSE.CC0) - -## Providers - -The following providers use a different license than the Default Dual -License. Refer to files in each directory for details. - -hfi1verbs -: Dual License: GPLv2 or Intel 3 clause BSD license - -ipathverbs -: Dual License: GPLv2 or PathScale BSD Patent license - -ocrdma -: Dual License: GPLv2 or OpenIB.org BSD (FreeBSD variant), See COPYING.BSD_FB - -## Libraries - -All library compilable source code (.c and .h files) are available under the -Default Dual License. - -Unmarked ancillary files may be available under a Dual License: GPLv2 or -OpenIB.org BSD (FreeBSD variant). - -## Tools (iwpmd, srp_daemon, ibacm) - -All compilable source code (.c and .h files) are available under the Default -Dual License. - -Unmarked ancillary files may be available under a Dual License: GPLv2 or -OpenIB.org BSD (FreeBSD variant). - -srp_daemon/srp_daemon/srp_daemon.sh: Any one of the GPLv2, a 2 clause BSD -license or the CPLv1. diff --git a/usr/rdma-core/Documentation/CMakeLists.txt b/usr/rdma-core/Documentation/CMakeLists.txt deleted file mode 100644 index d6e08ded0..000000000 --- a/usr/rdma-core/Documentation/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -install(FILES - ibacm.md - ibsrpdm.md - libibcm.md - libibverbs.md - librdmacm.md - rxe.md - udev.md - ../README.md - ../MAINTAINERS - DESTINATION "${CMAKE_INSTALL_DOCDIR}") diff --git a/usr/rdma-core/Documentation/ibacm.md b/usr/rdma-core/Documentation/ibacm.md deleted file mode 100644 index 8ed293de9..000000000 --- a/usr/rdma-core/Documentation/ibacm.md +++ /dev/null @@ -1,109 +0,0 @@ -# The Assistant for InfiniBand Communication Management (IB ACM) - -The IB ACM library implements and provides a framework for name, address, and -route resolution services over InfiniBand. The IB ACM provides information -needed to establish a connection, but does not implement the CM protocol. - -IB ACM services are used by librdmacm to implement the rdma_resolve_addr, -rdma_resolve_route, and rdma_getaddrinfo routines. - -The IB ACM is focused on being scalable and efficient. The current -implementation limits network traffic, SA interactions, and centralized -services. ACM supports multiple resolution protocols in order to handle -different fabric topologies. - -This release is limited in its handling of dynamic changes. - -The IB ACM package is comprised of two components: the ibacm service -and a test/configuration utility - ib_acme. - -# Details - -### ib_acme - -The ib_acme program serves a dual role. It acts as a utility to test -ibacm operation and help verify if the ibacm service and selected -protocol is usable for a given cluster configuration. Additionally, -it automatically generates ibacm configuration files to assist with -or eliminate manual setup. - - -### acm configuration files - -The ibacm service relies on two configuration files. - -The acm_addr.cfg file contains name and address mappings for each IB - endpoint. Although the names in the acm_addr.cfg -file can be anything, ib_acme maps the host name and IP addresses to -the IB endpoints. - -The acm_opts.cfg file provides a set of configurable options for the -ibacm service, such as timeout, number of retries, logging level, etc. -ib_acme generates the acm_opts.cfg file using static information. A -future enhancement would adjust options based on the current system -and cluster size. - -### ibacm - -The ibacm service is responsible for resolving names and addresses to -InfiniBand path information and caching such data. It is implemented as a -daemon that execute with administrative privileges. - -The ibacm implements a client interface over TCP sockets, which is -abstracted by the librdmacm library. One or more back-end protocols are -used by the ibacm service to satisfy user requests. Although the -ibacm supports standard SA path record queries on the back-end, it -provides an experimental multicast resolution protocol in hope of -achieving greater scalability. The latter is not usable on all fabric -topologies, specifically ones that may not have reversible paths. -Users should use the ib_acme utility to verify that multicast protocol -is usable before running other applications. - -Conceptually, the ibacm service implements an ARP like protocol and either -uses IB multicast records to construct path record data or queries the -SA directly, depending on the selected route protocol. By default, the -ibacm services uses and caches SA path record queries. - -Specifically, all IB endpoints join a number of multicast groups. -Multicast groups differ based on rates, mtu, sl, etc., and are prioritized. -All participating endpoints must be able to communicate on the lowest -priority multicast group. The ibacm assigns one or more names/addresses -to each IB endpoint using the acm_addr.cfg file. Clients provide source -and destination names or addresses as input to the service, and receive -as output path record data. - -The service maps a client's source name/address to a local IB endpoint. -If a client does not provide a source address, then the ibacm service -will select one based on the destination and local routing tables. If the -destination name/address is not cached locally, it sends a multicast -request out on the lowest priority multicast group on the local endpoint. -The request carries a list of multicast groups that the sender can use. -The recipient of the request selects the highest priority multicast group -that it can use as well and returns that information directly to the sender. -The request data is cached by all endpoints that receive the multicast -request message. The source endpoint also caches the response and uses -the multicast group that was selected to construct or obtain path record -data, which is returned to the client. - -The current implementation of the IB ACM has several additional restrictions: -- The ibacm is limited in its handling of dynamic changes; - the ibacm should be stopped and restarted if a cluster is reconfigured. -- Support for IPv6 has not been verified. -- The number of addresses that can be assigned to a single endpoint is - limited to 4. -- The number of multicast groups that an endpoint can support is limited to 2. - -The ibacm contains several internal caches. These include caches for -GID and LID destination addresses. These caches can be optionally -preloaded. ibacm supports the OpenSM dump_pr plugin "full" PathRecord -format which is used to preload these caches. The file format is specified -in the ibacm_opts.cfg file via the route_preload setting which should -be set to opensm_full_v1 for this file format. Default format is -none which does not preload these caches. See dump_pr.notes.txt in dump_pr -for more information on the opensm_full_v1 file format and how to configure -OpenSM to generate this file. - -Additionally, the name, IPv4, and IPv6 caches can be be preloaded by using -the addr_preload option. The default is none which does not preload these -caches. To preload these caches, set this option to acm_hosts and -configure the addr_data_file appropriately. diff --git a/usr/rdma-core/Documentation/ibsrpdm.md b/usr/rdma-core/Documentation/ibsrpdm.md deleted file mode 100644 index 0fc544d03..000000000 --- a/usr/rdma-core/Documentation/ibsrpdm.md +++ /dev/null @@ -1,41 +0,0 @@ -# Using ibsrpdm - -ibsrpdm is used for discovering and connecting to SRP SCSI targets on -InfiniBand fabrics. These targets can be accessed with the InfiniBand SRP -initiator module, "ib_srp," included in Linux kernels 2.6.15 and newer. - -To run ibsrpdm, the ib_umad module must be loaded, as well as an appropriate -low-level driver for the installed IB hardware. - -With no command line parameters, ibsrpdm displays information about -SRP targets in human-readable form: - - # ibsrpdm - IO Unit Info: - port LID: 0009 - port GID: fe800000000000000005ad00000013e9 - change ID: 73b0 - max controllers: 0x01 - - controller[ 1] - GUID: 0005ad00000013e7 - vendor ID: 0005ad - device ID: 0005ad - IO class : 0100 - ID: Topspin SRP/FC TCA - service entries: 2 - service[ 0]: 0000000000000066 / SRP.T10:20030003BA27CC7A - service[ 1]: 0000000000000066 / SRP.T10:20030003BA27CF53 - -With the "-c" flag, ibsrpdm displays information in a form that can be -written to the kernel SRP initiators add_target file to connect to the -SRP targets. For example: - - # ibsrpdm -c - id_ext=20030003BA27CC7A,ioc_guid=0005ad00000013e7,dgid=fe800000000000000005ad00000013e9,pkey=ffff,service_id=0000000000000066 - id_ext=20030003BA27CF53,ioc_guid=0005ad00000013e7,dgid=fe800000000000000005ad00000013e9,pkey=ffff,service_id=0000000000000066 - -Given this, the command below will connect to the first target -discovered from the first port of the local HCA device "mthca0": - - # echo -n id_ext=20030003BA27CC7A,ioc_guid=0005ad00000013e7,dgid=fe800000000000000005ad00000013e9,pkey=ffff,service_id=0000000000000066 > /sys/class/infiniband_srp/srp-mthca0-1/add_target diff --git a/usr/rdma-core/Documentation/libibcm.md b/usr/rdma-core/Documentation/libibcm.md deleted file mode 100644 index 663e7736d..000000000 --- a/usr/rdma-core/Documentation/libibcm.md +++ /dev/null @@ -1,16 +0,0 @@ -# Device files - -The userspace CM uses a device file per adapter present. - -To create the appropriate character device file automatically with -udev, a rule like - - KERNEL="ucm*", NAME="infiniband/%k", MODE="0666" - -can be used. This will create the device node named - - /dev/infiniband/ucm0 - -for the first HCA in the system, or you can create it manually - - mknod /dev/infiniband/ucm0 c 231 224 diff --git a/usr/rdma-core/Documentation/libibverbs.md b/usr/rdma-core/Documentation/libibverbs.md deleted file mode 100644 index cbe076e0f..000000000 --- a/usr/rdma-core/Documentation/libibverbs.md +++ /dev/null @@ -1,58 +0,0 @@ -# Introduction - -libibverbs is a library that allows programs to use RDMA "verbs" for -direct access to RDMA (currently InfiniBand and iWARP) hardware from -userspace. For more information on RDMA verbs, see the InfiniBand -Architecture Specification vol. 1, especially chapter 11, and the RDMA -Consortium's RDMA Protocol Verbs Specification. - -# Using libibverbs - -### Device nodes - -The verbs library expects special character device files named -/dev/infiniband/uverbsN to be created. When you load the kernel -modules, including both the low-level driver for your IB hardware as -well as the ib_uverbs module, you should see one or more uverbsN -entries in /sys/class/infiniband_verbs in addition to the -/dev/infiniband/uverbsN character device files. - -To create the appropriate character device files automatically with -udev, a rule like - - KERNEL="uverbs*", NAME="infiniband/%k" - -can be used. This will create device nodes named - - /dev/infiniband/uverbs0 - -and so on. Since the RDMA userspace verbs should be safe for use by -non-privileged users, you may want to add an appropriate MODE or GROUP -to your udev rule. - -### Permissions - -To use IB verbs from userspace, a process must be able to access the -appropriate /dev/infiniband/uverbsN special device file. You can -check the permissions on this file with the command - - ls -l /dev/infiniband/uverbs* - -Make sure that the permissions on these files are such that the -user/group that your verbs program runs as can access the device file. - -To use IB verbs from userspace, a process must also have permission to -tell the kernel to lock sufficient memory for all of your registered -memory regions as well as the memory used internally by IB resources -such as queue pairs (QPs) and completion queues (CQs). To check your -resource limits, use the command - - ulimit -l - -(or "limit memorylocked" for csh-like shells). - -If you see a small number such as 32 (the units are KB) then you will -need to increase this limit. This is usually done for ordinary users -via the file /etc/security/limits.conf. More configuration may be -necessary if you are logging in via OpenSSH and your sshd is -configured to use privilege separation. diff --git a/usr/rdma-core/Documentation/librdmacm.md b/usr/rdma-core/Documentation/librdmacm.md deleted file mode 100644 index 817383661..000000000 --- a/usr/rdma-core/Documentation/librdmacm.md +++ /dev/null @@ -1,46 +0,0 @@ -# Device files - -The userspace CMA uses a single device file regardless of the number -of adapters or ports present. - -To create the appropriate character device file automatically with -udev, a rule like - - KERNEL="rdma_cm", NAME="infiniband/%k", MODE="0666" - -can be used. This will create the device node named - - /dev/infiniband/rdma_cm - -or you can create it manually - - mknod /dev/infiniband/rdma_cm c 231 255 - - -# Common issues - -Using multiple interfaces -: The librdmacm does support multiple interfaces. To make use - of multiple interfaces, however, you need to instruct linux - to only send ARP reples on the interface targetted in the ARP - request. This can be done using a command similar to the - following: - - sysctl -w net.ipv4.conf.all.arp_ignore=2 - - Without this change, it's possible for linux to resopnd to ARP - requests on a different interface (IP address) than the IP - address carried in the ARP request. This causes the RDMA stack - to incorrectly map the remote IP address to the wrong RDMA - device. - -Using loopback -: The librdmacm relies on ARP to resolve IP address to RDMA - addresses. To support loopback connections between different - ports on the same system, ARP must be enabled for local - resolution: - - sysctl net.ipv4.conf.all.accept_local=1 - - Without this setting, loopback connections may timeout - during address resolution. diff --git a/usr/rdma-core/Documentation/release.md b/usr/rdma-core/Documentation/release.md deleted file mode 100644 index 2a40ef763..000000000 --- a/usr/rdma-core/Documentation/release.md +++ /dev/null @@ -1,99 +0,0 @@ -# Release Process - -Release process of rdma-core library consists from three stages - -1. Change library version, according to [Overall Pacakge Version](versioning.md) guide. -2. Push the change above to master branch and ensure that Travis CI reports successful build. -3. Create local annotated signed tag vX.X.X (`git tag vX.X.X -a -s`). -4. Issue `git release` command which will push tag, trigger Travis CI to upload - release tar.gz file and create release notes based on tag context with release notes in it. - -## git release - -There are many implmentations of different `git release` commands. We recommend you to use -the command from [this](https://github.com/mpalmer/github-release) repository due to its simplicity. - ---- -Copy&Paste from relevant [README](https://github.com/mpalmer/github-release/blob/master/README.md) - ---- - -This very simple gem provides a `git release` command, which will -automatically fill out any and all "release tags" into fully-blown "Github -Releases", complete with release notes, a heading, and all the other good -things in life. - -Using this gem, you can turn the following tag annotation: - - First Release - - It is with much fanfare and blowing of horns that I bequeath the - awesomeness of `git release` upon the world. - - Features in this release include: - - * Ability to create a release from a tag annotation or commit message; - * Automatically generates an OAuth token if needed; - * Feeds your cat while you're hacking(*) - - You should install it now! `gem install github-release` - -Into [this](https://github.com/mpalmer/github-release/releases/tag/v0.1.0) -simply by running - - git release - -### Installation - -Simply install the gem: - - gem install github-release - - -### Usage - -Using `git release` is very simple. Just make sure that your `origin` -remote points to your Github repo, and then run `git release`. All tags -that look like a "version tag" (see "Configuration", below) will be created -as Github releases (if they don't already exist) and the message from the -tag will be used as the release notes. - -The format of the release notes is quite straightforward -- the first line -of the message associated with the commit will be used as the "name" of the -release, with the rest of the message used as the "body" of the release. -The body will be interpreted as Github-flavoured markdown, so if you'd like -to get fancy, go for your life. - -The message associated with the "release tag" is either the tag's annotation -message (if it is an annotated tag) or else the commit log of the commit on -which the tag is placed. I *strongly* recommend annotated tags (but then -again, [I'm biased...](http://theshed.hezmatt.org/git-version-bump)) - -The first time you use `git release`, it will ask you for your Github -username and password. This is used to request an OAuth token to talk to -the Github API, which is then stored in your global git config. Hence you -*shouldn't* be asked for your credentials every time you use `git release`. -If you need to use multiple github accounts for different repos, you can -override the `release.api-token` config parameter in your repo configuration -(but you'll have to get your own OAuth token). - - -### Configuration - -There are a few things you can configure to make `git release` work slightly -differently. None of them should be required for normal, sane use. - - * `release.remote` (default `origin`) -- The name of the remote which is - used to determine what github repository to send release notes to. - - * `release.api-token` (default is runtime generated) -- The OAuth token - to use to authenticate access to the Github API. When you first run `git - release`, you'll be prompted for a username and password to use to - generate an initial token; if you need to override it on a per-repo - basis, this is the key you'll use. - - * `release.tag-regex` (default `v\d+\.\d+(\.\d+)?$`) -- The regular - expression to filter which tags denote releases, as opposed to other tags - you might have decided to make. Only tags which match this regular - expression will be pushed up by `git release`, and only those tags will - be marked as releases. diff --git a/usr/rdma-core/Documentation/rxe.md b/usr/rdma-core/Documentation/rxe.md deleted file mode 100644 index 8e753decb..000000000 --- a/usr/rdma-core/Documentation/rxe.md +++ /dev/null @@ -1,22 +0,0 @@ -# Configure Soft-RoCE (RXE): - -Load rdma_rxe kernel module using the rxe_cfg script included in the librxe RPM: - - # rxe_cfg start (this might require sudo or root privileges) - -Create RXE device over network interface (e.g. eth0): - - # rxe_cfg add eth0 - -Use the status command to display the current configuration: -rxe_cfg status - -If configured successfully, you should see output similar to the following: - -``` - Name Link Driver Speed NMTU IPv4_addr RDEV RMTU - eth0 yes mlx4_en rxe0 1024 (3) -``` - -If you are using a Mellanox HCA: Need to make sure that the mlx4_ib kernel module is not loaded (modprobe –rv mlx4_ib) in the soft-RoCE machine. -Now you have an Infiniband device called “rxe0” that can be used to run any RoCE app. diff --git a/usr/rdma-core/Documentation/udev.md b/usr/rdma-core/Documentation/udev.md deleted file mode 100644 index 7da3ed94b..000000000 --- a/usr/rdma-core/Documentation/udev.md +++ /dev/null @@ -1,149 +0,0 @@ -# Kernel Module Loading - -The RDMA subsystem relies on the kernel, udev and systemd to load modules on -demand when RDMA hardware is present. The RDMA subsystem is unique since it -does not do not load the optional RDMA hardware modules unless the system has -the rdma-core package installed. - -This is to avoid exposing systems not using RDMA from having RDMA enabled, for -instance if a system has a multi-protocol ethernet adapter, but is only using -the net stack interface. - -## Boot ordering with systemd - -systemd assumes everything is hot pluggable and runs in an event driven -manner. This creates a chain of hot plug events as each part of the system -autoloads based on earlier parts. The first step in the process is udev -loading the physical hardware driver. - -This can happen in several spots along the bootup: - - - From the initrd or built into the kernel. If hardware modules are present - in the initrd then they are loaded into the kernel before booting the - system. This is done largely synchronously with the boot process. - - - From udev when it auto detects PCI hardware or otherwise. - This happens asynchronously in the boot process, systemd does not wait for - udev to finish loading modules before it continues on. - - This path makes it very likely the system will experience a RDMA 'hot plug' - scenario. - - - From systemd's fixed module loader systemd-modules-load.service, e.g. from - the list in /etc/modules-load.d/. In this case the modules load happens - synchronously within systemd and it will hold off sysinit.target until - modules are loaded - -Once the hardware module is loaded it may be necessary to load a protocol -module, e.g. to enable RDMA support on an ethernet device. - -This is triggered automatically by udev rules that match the master devices -and load the protocol module with udev's module loader. This happens -asynchronously to the rest of the systemd startup. - -Once a RDMA device is created by the kernel then udev will cause systemd to -schedule ULP module loading services (e.g. rdma-load-modules@.service) specific -to the plugged hardware. If sysinit.target has not yet been passed then these -loaders will defer sysinit.target until they complete, otherwise this is a hot -plug event and things will load asynchronously to the boot up process. - -Finally udev will cause systemd to start RDMA specific daemons like -srp_daemon, rdma-ndd and iwpmd. These starts are linked to the detection of -the first RDMA hardware, and the daemons internally handle hot plug events for -other hardware. - -## Hot Plug compatible services - -Services using RDMA need to have device specific systemd dependencies in their -unit files, either created by hand by the admin or by using udev rules. - -For instance, a service that uses /dev/infiniband/umad0 requires: - -``` -After=dev-infiniband-umad0.device -BindsTo=dev-infiniband-umad0.device -``` - -Which will ensure the service will not run until the required umad device -appears, and will be stopped if the umad device is unplugged. - -This is similar to how systemd handles mounting filesystems and configuring -ethernet devices. - -## Interaction with legacy non-hotplug services - -Services that cannot handle hot plug must be ordered after -systemd-udev-settle.service, which will wait for udev to complete loading -modules and scheduling systemd services. This ensures that all RDMA hardware -present at boot is setup before proceeding to run the le.g.acy service. - -Admins using le.g.acy services can also place their RDMA hardware modules -(e.g. mlx4_ib) directly in /etc/modules-load.d/ or in their initrd which will -cause systemd to defer passing to sysinit.target until all RDMA hardware is -setup, this is usually sufficient for le.g.acy services. This is probably the -default behavior in many configurations. - -# Systemd Ordering - -Within rdma-core we have a series of units which run in the pre `basic.target` -world to setup kernel services: - - - `iwpmd` - - `rdma-ndd` - - `rdma-load-modules@.service` - - `ibacmd.socket` - -These special units use DefaultDependencies=no and order before any other unit that -uses DefaultDependencies=yes. This will happen even in the case of hotplug. - -Units for normal rdma-using daemons should use DefaultDependencies=yes, and -either this pattern for 'any RDMA device': - -``` -[Unit] -# Order after rdma-hw.target has become active and setup the kernel services -Requires=rdma-hw.target -After=rdma-hw.target - -[Install] -# Autostart when RDMA hardware is present -WantedBy=rdma-hw.target -``` - -Or this pattern for a specific RDMA device: - -``` -[Unit] -# Order after RDMA services are setup -After=rdma-hw.target -# Run only while a specific umad device is present -After=dev-infiniband-umad0.device -BindsTo=dev-infiniband-umad0.device - -[Install] -# Schedual the unit to be runnable when RDMA hardware is present, but -# it will only start once the requested device actuall appears. -WantedBy=rdma-hw.target -``` - -Note, the above does explicitly reference `After=rdma-hw.target` even though -all the current constituents of that target order before -`sysinit.target`. This is to provide greater flexibility in the future. - -## rdma-hw.target - -This target is Wanted automatically by udev as soon as any RDMA hardware is -plugged in or becomes available at boot. - -This may be used to pull in rdma management daemons dynamically when RDMA -hardware is found. Such daemons should use: - -``` -[Install] -WantedBy=rdma-hw.target -``` - -In their unit files. - -`rdma-hw.target` is also a synchronization point that orders after the low level, -pre `sysinit.target` RDMA related units have been started. diff --git a/usr/rdma-core/Documentation/versioning.md b/usr/rdma-core/Documentation/versioning.md deleted file mode 100644 index 3f19df551..000000000 --- a/usr/rdma-core/Documentation/versioning.md +++ /dev/null @@ -1,165 +0,0 @@ -# Overall Package Version - -This version number is set in the top level CMakeLists.txt: - -```sh -set(PACKAGE_VERSION "11") -```` - -For upstream releases this is a single integer showing the release -ordering. We do not attempt to encode any 'ABI' information in this version. - -Branched stabled releases can append an additional counter eg `11.2`. - -Unofficial releases should include a distributor tag, eg '11.vendor2'. - -When the PACKAGE_VERSION is changed, the packaging files should be updated: - -```diff -diff --git a/CMakeLists.txt b/CMakeLists.txt -index a2464ec5..cf237904 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -44,7 +44,7 @@ endif() - set(PACKAGE_NAME "RDMA") - - # See Documentation/versioning.md --set(PACKAGE_VERSION "15") -+set(PACKAGE_VERSION "16") - # When this is changed the values in these files need changing too: - # debian/libibverbs1.symbols - # libibverbs/libibverbs.map -diff --git a/debian/changelog b/debian/changelog -index 86b402f4..9ee7fe16 100644 ---- a/debian/changelog -+++ b/debian/changelog -@@ -1,4 +1,4 @@ --rdma-core (15-1) unstable; urgency=low -+rdma-core (16-1) unstable; urgency=low - - * New version. - * Adding debian/copyright. -diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec -index cc0c3ba0..62334730 100644 ---- a/redhat/rdma-core.spec -+++ b/redhat/rdma-core.spec -@@ -1,5 +1,5 @@ - Name: rdma-core --Version: 15 -+Version: 16 - Release: 1%{?dist} - Summary: RDMA core userspace libraries and daemons - -diff --git a/suse/rdma-core.spec b/suse/rdma-core.spec -index 76ca7286..a19f9e01 100644 ---- a/suse/rdma-core.spec -+++ b/suse/rdma-core.spec -@@ -19,7 +19,7 @@ - %bcond_without systemd - %define git_ver %{nil} - Name: rdma-core --Version: 15 -+Version: 16 - Release: 0 - Summary: RDMA core userspace libraries and daemons - License: GPL-2.0 or BSD-2-Clause - -``` - -# Shared Library Versions - -The shared libraries use the typical semantic versioning scheme, eg -*libibumad* has a version like `3.1.11`. - -The version number is broken up into three fields: -- '3' is called the SONAME and is embedded into the ELF: - ```sh - $ readelf -ds build/lib/libibumad.so.3.1.11 - 0x000000000000000e (SONAME) Library soname: [libibumad.so.3] - ``` - - We do not expect this value to ever change for our libraries. It indicates - the overall ABI, changing it means the library will not dynamically to old - programs link anymore. - -- '1' is called the ABI level and is used within the ELF as the last component - symbol version tag. This version must be changed every time a new symbol - is introduced. It allows the user to see what version of the ABI the - library provides. - -- '11' is the overall release number and is copied from `PACKAGE_VERSION` This - version increases with every package release, even if the library code did - not change. It allows the user to see what upstream source was used to build - the library. - -This version is encoded into the filename `build/lib/libibumad.so.3.1.11` and -a symlink from `libibumad.so.3` to `build/lib/libibumad.so.3.1.11` is created. - -## Shared Library Symbol Versions - -Symbol versions are a linker technique that lets the library author provide -two symbols with different ABIs that have the same API name. The linker -differentiates the two cases internally. This allows the library author to -change the ABI that the API uses. This project typically does not make use of -this feature. - -As a secondary feature, the symbol version is also used by package managers -like RPM to manage the ABI level. To make this work properly the ABI level -must be correctly encoded into the symbol version. - -## Adding a new symbol - -First, increase the ABI level of the library. It is safe to re-use the ABI -level for multiple new functions within a single release, but once a release -is tagged the ABI level becomes *immutable*. The maintainer can provide -guidence on what ABI level to use for each series. - -```diff - rdma_library(ibumad libibumad.map - # See Documentation/versioning.md -- 3 3.1.${PACKAGE_VERSION} -+ 3 3.2.${PACKAGE_VERSION} -``` - -Next, add your new symbol to the symbol version file: - -```diff -+ IBUMAD_3.2 { -+ global: -+ umad_new_symbol; -+ } IBUMAD_1.0; -``` - -NOTE: Once a release is made the stanzas in the map file are *immutable* and -cannot be changed. Do not add your new symbol to old stanzas. - -The new symbol should appear in the ELF: - -```sh -$ readelf -s build/lib/libibumad.so.3.1.11 - 35: 00000000000031e0 450 FUNC GLOBAL DEFAULT 12 umad_new_symbol@@IBUMAD_3.2 -``` - -Finally update the `debian/libibumad3.symbols` file. - -## Private symbols in libibverbs - -Many symbols in libibverbs are private to rdma-core, they are being marked in -the map file using the IBVERBS_PRIVATE_ prefix. - -For simplicity, there is only one version of the private symbol version -stanza, and it is bumped whenever any change (add/remove/modify) to any of the -private ABI is done. This makes it very clear if an incompatible provider is -being used with libibverbs. - -Due to this there is no reason to provide compat symbol versions for the -private ABI. - -### Use of private symbols between component packages - -A distribution packaging system still must have the correct dependencies -between libraries within rdma-core that may use these private symbols. - -For this reason the private symbols can only be used by provider libraries and -the distribution must ensure that a matched set of provider libraries and -libibverbs are installed. diff --git a/usr/rdma-core/MAINTAINERS b/usr/rdma-core/MAINTAINERS deleted file mode 100644 index 08286cb5d..000000000 --- a/usr/rdma-core/MAINTAINERS +++ /dev/null @@ -1,178 +0,0 @@ - List of maintainers - -Generally patches should be submitted to the main development mailing list: - -linux-rdma@vger.kernel.org - -Descriptions of section entries: - F: Files and directories with wildcard patterns. - A trailing slash includes all files and subdirectory files. - F: providers/mlx4/ all files in and below providers/mlx4/ - F: providers/* all files in providers, but not below - F: */net/* all files in "any top level directory"/net - One pattern per line. Multiple F: lines acceptable. - H: Historical authors - L: Mailing list that is relevant to this area - M: Designated reviewer: FullName - These reviewers should be CCed on patches. - S: Status, one of the following: - Supported: Someone is actually paid to look after this. - Maintained: Someone actually looks after it. - Odd Fixes: It has a maintainer but they don't have time to do - much other than throw the odd patch in. See below.. - Orphan: No current maintainer [but maybe you could take the - role as you write your new code]. - Obsolete: Old code. Something tagged obsolete generally means - it has been replaced by a better system and you - should be using that. - - ----------------------------------- - -* OVERALL PACKAGE -M: Doug Ledford -M: Leon Romanovsky -S: Supported - -BUILD SYSTEM -M: Jason Gunthorpe -S: Supported -F: */CMakeLists.txt -F: */lib*.map -F: buildlib/ - -BNXT_RE USERSPACE PROVIDER (for bnxt_re.ko) -M: Devesh Sharma -S: Supported -F: providers/bnxt_re/ - -CXGB3 USERSPACE PROVIDER (for iw_cxgb3.ko) -M: Steve Wise -S: Supported -F: providers/cxgb3/ - -CXGB4 USERSPACE PROVIDER (for iw_cxgb4.ko) -M: Steve Wise -S: Supported -F: providers/cxgb4/ - -HF1 USERSPACE PROVIDER (for hf1.ko) -M: Mike Marciniszyn -M: Dennis Dalessandro -S: Supported -L: intel-opa@lists.01.org (moderated for non-subscribers) -F: providers/hfi1verbs/ - -HNS USERSPACE PROVIDER (for hns-roce.ko) -M: Lijun Ou -M: Wei Hu(Xavier) -S: Supported -F: providers/hns/ - -I40IW USERSPACE PROVIDER (for i40iw.ko) -M: Tatyana Nikolova -S: Supported -F: providers/i40iw/ - -RDMA Communication Manager Assistant (for librdmacm.so) -M: Sean Hefty -M: Hal Rosenstock -S: Supported -F: ibacm/* - -IPATH/QIB USERSPACE PROVIDER (for ib_qib.ko) -M: Mike Marciniszyn -M: Dennis Dalessandro -L: infinipath@intel.com -S: Supported -F: providers/ipathverbs/ - -IWARP PORT MAPPER DAEMON (for iwarp kernel providers) -M: Tatyana Nikolova -M: Steve Wise -H: Robert Sharp -S: Supported -F: iwpmd/ - -LIBIBCM USERSPACE LIBRARY FOR IB CONNECTION MANAGEMENT (/dev/infiniband/ucmX) -M: Sean Hefty -H: Libor Michalek -S: Obsolete -F: libibcm/ - -LIBIBUMAD USERSPACE LIBRARY FOR SMP AND GMP MAD PROCESSING (/dev/infiniband/umadX) -M: Hal Rosenstock -H: Sasha Khapyorsky -H: Shahar Frank -S: Supported -F: libibumad/ - -LIBIBVERBS USERSPACE LIBRARY FOR RDMA VERBS (/dev/infiniband/uverbsX) -M: Doug Ledford -M: Yishai Hadas -H: Michael S. Tsirkin -H: Sean Hefty -H: Dotan Barak -H: Roland Dreier -S: Supported -F: libibverbs/ - -LIBRDMACM USERSPACE LIBRARY FOR RDMA CONNECTION MANAGEMENT (/dev/infiniband/rdma_cm) -M: Sean Hefty -S: Supported -F: librdmacm/ - -MLX4 USERSPACE PROVIDER (for mlx4_ib.ko) -M: Yishai Hadas -H: Roland Dreier -S: Supported -F: providers/mlx4/ - -MLX5 USERSPACE PROVIDER (for mlx5_ib.ko) -M: Yishai Hadas -H: Eli Cohen -S: Supported -F: providers/mlx5/ - -MTHCA USERSPACE PROVIDER (for ib_mthca.ko) -M: Vladimir Sokolovsky -H: Michael S. Tsirkin -H: Roland Dreier -S: Supported -F: providers/mthca/ - -NES USERSPACE PROVIDER (for iw_nes.ko) -M: Tatyana Nikolova -S: Supported -F: providers/nes/ - -OCRDMA USERSPACE PROVIDER (for ocrdma.ko) -M: Devesh Sharma -S: Supported -F: providers/ocrdma/ - -QEDR USERSPACE PROVIDER (for qedr.ko) -M: Ram Amrani -M: Ariel Elior -S: Supported -F: providers/qedr/ - -RXE SOFT ROCEE USERSPACE PROVIDER (for rdma_rxe.ko) -M: Moni Shoua -S: Supported -F: providers/rxe/ - -SRP DAEMON (for ib_srp.ko) -M: Bart Van Assche -S: Supported -F: srp_daemon/ - -SUSE PACKAGING -M: Nicolas Morey-Chaisemartin -S: Supported -F: suse/ - -VMWARE PVRDMA USERSPACE PROVIDER (for vmw_pvrdma.ko) -M: Adit Ranadive -L: pv-drivers@vmware.com -S: Supported -F: providers/vmw_pvrdma/ diff --git a/usr/rdma-core/README.md b/usr/rdma-core/README.md deleted file mode 100644 index b7928ab5a..000000000 --- a/usr/rdma-core/README.md +++ /dev/null @@ -1,129 +0,0 @@ -[![Build Status](https://travis-ci.org/linux-rdma/rdma-core.svg?branch=master)](https://travis-ci.org/linux-rdma/rdma-core) - -# RDMA Core Userspace Libraries and Daemons - -This is the userspace components for the Linux Kernel's drivers/infiniband -subsystem. Specifically this contains the userspace libraries for the -following device nodes: - - - /dev/infiniband/uverbsX (libibverbs) - - /dev/infiniband/rdma_cm (librdmacm) - - /dev/infiniband/umadX (libibumad) - - /dev/infiniband/ucmX (libibcm, deprecated) - -The userspace component of the libibverbs RDMA kernel drivers are included -under the providers/ directory. Support for the following Kernel RDMA drivers -is included: - - - iw_cxgb3.ko - - iw_cxgb4.ko - - hfi1.ko - - hns-roce.ko - - i40iw.ko - - ib_qib.ko - - mlx4_ib.ko - - mlx5_ib.ko - - ib_mthca.ko - - iw_nes.ko - - ocrdma.ko - - qedr.ko - - rdma_rxe.ko - - vmw_pvrdma.ko - -Additional service daemons are provided for: - - srp_daemon (ib_srp.ko) - - iwpmd (for iwarp kernel providers) - - ibacm (for InfiniBand communication management assistant) - -# Building - -This project uses a cmake based build system. Quick start: - -```sh -$ bash build.sh -``` - -*build/bin* will contain the sample programs and *build/lib* will contain the -shared libraries. The build is configured to run all the programs 'in-place' -and cannot be installed. - -NOTE: It is not currently easy to run from the build directory, the plugins -only load from the system path. - -### Debian Derived - -```sh -$ apt-get install build-essential cmake gcc libudev-dev libnl-3-dev libnl-route-3-dev ninja-build pkg-config valgrind -``` - -### Fedora - -```sh -$ dnf install cmake gcc libnl3-devel libudev-devel pkgconfig valgrind-devel ninja-build -``` - -NOTE: Fedora Core uses the name 'ninja-build' for the 'ninja' command. - -### OpenSuSE - -```sh -$ zypper install cmake gcc libnl3-devel libudev-devel ninja pkg-config valgrind-devel -``` - -## Building on CentOS 6/7 - -Install required packages: - -```sh -$ yum install cmake gcc libnl3-devel libudev-devel make pkgconfig valgrind-devel -``` - -Developers on CentOS 7 are suggested to install more modern tooling for the -best experience. - -```sh -$ yum install epel-release -$ yum install cmake3 unzip ninja-build -``` - -NOTE: EPEL uses the name 'ninja-build' for the 'ninja' command, and 'cmake3' -for the 'cmake' command. - -# Reporting bugs - -Bugs should be reported to the mailing list -In your bug report, please include: - - * Information about your system: - - Linux distribution and version - - Linux kernel and version - - InfiniBand hardware and firmware version - - ... any other relevant information - - * How to reproduce the bug. - - * If the bug is a crash, the exact output printed out when the crash - occurred, including any kernel messages produced. - -# Submitting patches - -Patches should also be submitted to the -mailing list. Please use unified diff form (the -u option to GNU diff), -and include a good description of what your patch does and why it should -be applied. If your patch fixes a bug, please make sure to describe the -bug and how your fix works. - -Make sure that your contribution can be licensed under the same -license as the original code you are patching, and that you have all -necessary permissions to release your work. - -## TravisCI - -Submitted patches must pass the TravisCI automatic builds without warnings. -A build similar to TravisCI can be run locally using docker and the -'buildlib/cbuild' script. - -```sh -$ buildlib/cbuild build-images travis -$ buildlib/cbuild pkg travis -``` diff --git a/usr/rdma-core/build.sh b/usr/rdma-core/build.sh deleted file mode 100755 index 17dc4408f..000000000 --- a/usr/rdma-core/build.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -set -e - -SRCDIR=`dirname $0` -BUILDDIR="$SRCDIR/build" - -mkdir -p "$BUILDDIR" - -if hash cmake3 2>/dev/null; then - # CentOS users are encouraged to install cmake3 from EPEL - CMAKE=cmake3 -else - CMAKE=cmake -fi - -if hash ninja-build 2>/dev/null; then - # Fedora uses this name - NINJA=ninja-build -elif hash ninja 2>/dev/null; then - NINJA=ninja -fi - -cd "$BUILDDIR" - -if [ "x$NINJA" == "x" ]; then - $CMAKE -DIN_PLACE=1 .. - make -else - $CMAKE -DIN_PLACE=1 -GNinja .. - $NINJA -fi diff --git a/usr/rdma-core/buildlib/FindLDSymVer.cmake b/usr/rdma-core/buildlib/FindLDSymVer.cmake deleted file mode 100644 index 48238f240..000000000 --- a/usr/rdma-core/buildlib/FindLDSymVer.cmake +++ /dev/null @@ -1,52 +0,0 @@ -# COPYRIGHT (c) 2016 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. -# find_package helper to detect symbol version support in the compiler and -# linker. If supported then LDSYMVER_MODE will be set to GNU - -# Basic sample GNU style map file -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.map" " -IBVERBS_1.0 { - global: - ibv_get_device_list; - local: *; -}; - -IBVERBS_1.1 { - global: - ibv_get_device_list; -} IBVERBS_1.0; -") - -# See RDMA_CHECK_C_LINKER_FLAG -set(SAFE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") -set(SAFE_CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") -if (POLICY CMP0056) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/test.map") -else() - set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/test.map") -endif() - -# And matching source, this also checks that .symver asm works -check_c_source_compiles(" -void ibv_get_device_list_1(void); -void ibv_get_device_list_1(void){} -asm(\".symver ibv_get_device_list_1, ibv_get_device_list@IBVERBS_1.1\"); -void ibv_get_device_list_0(void); -void ibv_get_device_list_0(void){} -asm(\".symver ibv_get_device_list_0, ibv_get_device_list@@IBVERBS_1.0\"); - -int main(int argc,const char *argv[]){return 0;}" _LDSYMVER_SUCCESS) - -file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test.map") -set(CMAKE_EXE_LINKER_FLAGS "${SAFE_CMAKE_EXE_LINKER_FLAGS}") -set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") - -if (_LDSYMVER_SUCCESS) - set(LDSYMVER_MODE "GNU" CACHE INTERNAL "How to set symbol versions on shared libraries") -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - LDSymVer - REQUIRED_VARS LDSYMVER_MODE - ) diff --git a/usr/rdma-core/buildlib/FindSystemd.cmake b/usr/rdma-core/buildlib/FindSystemd.cmake deleted file mode 100644 index fbced4028..000000000 --- a/usr/rdma-core/buildlib/FindSystemd.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# COPYRIGHT (c) 2015 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -find_path(LIBSYSTEMD_INCLUDE_DIRS "systemd/sd-journal.h") - -if (LIBSYSTEMD_INCLUDE_DIRS) - set(SYSTEMD_INCLUDE_DIRS ${LIBSYSTEMD_INCLUDE_DIRS}) - find_library(LIBSYSTEMD_LIBRARY NAMES systemd libsystemd) - # Older systemd uses a split library - if (NOT LIBSYSTEMD_LIBRARY) - find_library(LIBSYSTEMD_JOURNAL_LIBRARY NAMES systemd-journal libsystemd-journal) - find_library(LIBSYSTEMD_ID128_LIBRARY NAMES systemd-id128 libsystemd-id128) - find_library(LIBSYSTEMD_DAEMON_LIBRARY NAMES systemd-daemon libsystemd-daemon) - - if (LIBSYSTEMD_JOURNAL_LIBRARY AND LIBSYSTEMD_ID128_LIBRARY AND LIBSYSTEMD_DAEMON_LIBRARY) - set(SYSTEMD_LIBRARIES - ${LIBSYSTEMD_JOURNAL_LIBRARY} - ${LIBSYSTEMD_ID128_LIBRARY} - ${LIBSYSTEMD_DAEMON_LIBRARY}) - endif() - else() - set(SYSTEMD_LIBRARIES ${LIBSYSTEMD_LIBRARY}) - endif() - set(SYSTEMD_INCLUDE_DIRS) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Systemd REQUIRED_VARS SYSTEMD_LIBRARIES LIBSYSTEMD_INCLUDE_DIRS) - -mark_as_advanced(LIBSYSTEMD_LIBRARY LIBSYSTEMD_JOURNAL_LIBRARY LIBSYSTEMD_ID128_LIBRARY LIBSYSTEMD_DAEMON_LIBRARY) diff --git a/usr/rdma-core/buildlib/FindUDev.cmake b/usr/rdma-core/buildlib/FindUDev.cmake deleted file mode 100644 index 3a2694377..000000000 --- a/usr/rdma-core/buildlib/FindUDev.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# COPYRIGHT (c) 2016 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -find_library(LIBUDEV_LIBRARY NAMES udev libudev) - -set(UDEV_LIBRARIES ${LIBUDEV_LIBRARY}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(UDev REQUIRED_VARS LIBUDEV_LIBRARY) - -mark_as_advanced(LIBUDEV_LIBRARY) diff --git a/usr/rdma-core/buildlib/RDMA_BuildType.cmake b/usr/rdma-core/buildlib/RDMA_BuildType.cmake deleted file mode 100644 index 0951edade..000000000 --- a/usr/rdma-core/buildlib/RDMA_BuildType.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# COPYRIGHT (c) 2015 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -function(RDMA_BuildType) - set(build_types Debug Release RelWithDebInfo MinSizeRel) - - # Set the default build type to RelWithDebInfo. Since RDMA is typically used - # in performance contexts it doesn't make much sense to have the default build - # turn off the optimizer. - if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE String - "Options are ${build_types}" - FORCE - ) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${build_types}) - endif() - - # Release should be used by packagers, it is the same as the default RelWithDebInfo, - # this means it uses -O2 and -DNDEBUG (not -O3) - foreach (language CXX C) - set(VAR_TO_MODIFY "CMAKE_${language}_FLAGS_RELEASE") - if ("${${VAR_TO_MODIFY}}" STREQUAL "${${VAR_TO_MODIFY}_INIT}") - set(${VAR_TO_MODIFY} "${CMAKE_${language}_FLAGS_RELWITHDEBINFO_INIT}" - CACHE STRING "Default flags for Release configuration" FORCE) - endif() - endforeach() - - # RelWithDebInfo should be used by developers, it is the same as Release but - # with the -DNDEBUG removed - foreach (language CXX C) - set(VAR_TO_MODIFY "CMAKE_${language}_FLAGS_RELWITHDEBINFO") - if (${${VAR_TO_MODIFY}} STREQUAL ${${VAR_TO_MODIFY}_INIT}) - string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" - " " - replacement - "${${VAR_TO_MODIFY}}" - ) - set(${VAR_TO_MODIFY} "${replacement}" - CACHE STRING "Default flags for RelWithDebInfo configuration" FORCE) - endif() - endforeach() -endfunction() diff --git a/usr/rdma-core/buildlib/RDMA_DoFixup.cmake b/usr/rdma-core/buildlib/RDMA_DoFixup.cmake deleted file mode 100644 index cd7d3b2e7..000000000 --- a/usr/rdma-core/buildlib/RDMA_DoFixup.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# COPYRIGHT (c) 2016 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -# Execute a header fixup based on NOT_NEEDED for HEADER - -# The buildlib includes alternate header file shims for several scenarios, if -# the build system detects a feature is present then it should call RDMA_DoFixup -# with the test as true. If false then the shim header will be installed. - -# Typically the shim header will replace a missing header with stubs, or it -# will augment an existing header with include_next. -function(RDMA_DoFixup not_needed header) - cmake_parse_arguments(ARGS "NO_SHIM" "" "" ${ARGN}) - string(REPLACE / - header-bl ${header}) - - if (NOT EXISTS "${BUILDLIB}/fixup-include/${header-bl}") - # NO_SHIM lets cmake succeed if the header exists in the system but no - # shim is provided, but this will always fail if the shim is needed but - # does not exist. - if (NOT ARGS_NO_SHIM OR NOT "${not_needed}") - message(FATAL_ERROR "Fixup header ${BUILDLIB}/fixup-include/${header-bl} is not present") - endif() - endif() - - set(DEST "${BUILD_INCLUDE}/${header}") - if (NOT "${not_needed}") - if(CMAKE_VERSION VERSION_LESS "2.8.12") - get_filename_component(DIR ${DEST} PATH) - else() - get_filename_component(DIR ${DEST} DIRECTORY) - endif() - file(MAKE_DIRECTORY "${DIR}") - - rdma_create_symlink("${BUILDLIB}/fixup-include/${header-bl}" "${DEST}") - else() - file(REMOVE ${DEST}) - endif() -endfunction() diff --git a/usr/rdma-core/buildlib/RDMA_EnableCStd.cmake b/usr/rdma-core/buildlib/RDMA_EnableCStd.cmake deleted file mode 100644 index c8a8c1f55..000000000 --- a/usr/rdma-core/buildlib/RDMA_EnableCStd.cmake +++ /dev/null @@ -1,57 +0,0 @@ -# COPYRIGHT (c) 2016 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -# cmake does not have way to do this even slightly sanely until CMP0056 -function(RDMA_CHECK_C_LINKER_FLAG FLAG CACHE_VAR) - set(SAFE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - set(SAFE_CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - - if (POLICY CMP0056) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}") - else() - set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${FLAG}") - endif() - - CHECK_C_COMPILER_FLAG("" ${CACHE_VAR}) - - set(CMAKE_EXE_LINKER_FLAGS "${SAFE_CMAKE_EXE_LINKER_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") -endfunction() - -# Test if the CC compiler supports the linker flag and if so add it to TO_VAR -function(RDMA_AddOptLDFlag TO_VAR CACHE_VAR FLAG) - RDMA_CHECK_C_LINKER_FLAG("${FLAG}" ${CACHE_VAR}) - if (${CACHE_VAR}) - SET(${TO_VAR} "${${TO_VAR}} ${FLAG}" PARENT_SCOPE) - endif() -endfunction() - -# Test if the CC compiler supports the flag and if so add it to TO_VAR -function(RDMA_AddOptCFlag TO_VAR CACHE_VAR FLAG) - CHECK_C_COMPILER_FLAG("${FLAG}" ${CACHE_VAR}) - if (${CACHE_VAR}) - SET(${TO_VAR} "${${TO_VAR}} ${FLAG}" PARENT_SCOPE) - endif() -endfunction() - -# Enable the minimum required gnu11 standard in the compiler -# This was introduced in GCC 4.7 -function(RDMA_EnableCStd) - if (HAVE_SPARSE) - # Sparse doesn't support gnu11, but doesn't fail if the option is present, - # force gnu99 instead. - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99" PARENT_SCOPE) - return() - endif() - - if (CMAKE_VERSION VERSION_LESS "3.1") - # Check for support of the usual flag - CHECK_C_COMPILER_FLAG("-std=gnu11" SUPPORTS_GNU11) - if (SUPPORTS_GNU11) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11" PARENT_SCOPE) - endif() - else() - # Newer cmake can do this internally - set(CMAKE_C_STANDARD 11 PARENT_SCOPE) - endif() -endfunction() diff --git a/usr/rdma-core/buildlib/RDMA_LinuxHeaders.cmake b/usr/rdma-core/buildlib/RDMA_LinuxHeaders.cmake deleted file mode 100644 index 2893ac9ef..000000000 --- a/usr/rdma-core/buildlib/RDMA_LinuxHeaders.cmake +++ /dev/null @@ -1,98 +0,0 @@ -# COPYRIGHT (c) 2016 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -# Check that the system kernel headers are new enough, if not replace the -# headers with our internal copy. - -set(DEFAULT_TEST "int main(int argc,const char *argv[]) {return 1;}") -set(MISSING_HEADERS "") - -function(rdma_canon_header PATH OUT_VAR) - string(TOUPPER "${PATH}" HAVE) - string(REPLACE " " "_" HAVE "${HAVE}") - string(REPLACE "/" "_" HAVE "${HAVE}") - string(REPLACE "." "_" HAVE "${HAVE}") - set("${OUT_VAR}" "HAVE_${HAVE}" PARENT_SCOPE) -endfunction() - -function(rdma_check_kheader PATH C_TEST) - cmake_parse_arguments(ARGS "NO_SHIM;OPTIONAL" "" "" ${ARGN}) - - rdma_canon_header("${PATH}" HAVE) - - if(KERNEL_DIR) - # Drop a symlink back to the kernel into our include/ directory - if (EXISTS "${KERNEL_DIR}/include/uapi/${PATH}") - set(DEST "${BUILD_INCLUDE}/${PATH}") - - if(CMAKE_VERSION VERSION_LESS "2.8.12") - get_filename_component(DIR ${DEST} PATH) - else() - get_filename_component(DIR ${DEST} DIRECTORY) - endif() - file(MAKE_DIRECTORY "${DIR}") - - # We cannot just -I the kernel UAPI dir, it depends on some - # post-processing of things like linux/stddef.h. Instead we symlink the - # kernel headers into our tree and rely on the distro's fixup of - # non-rdma headers. The RDMA headers are all compatible with this - # scheme. - rdma_create_symlink("${KERNEL_DIR}/include/uapi/${PATH}" "${DEST}") - else() - message(FATAL_ERROR "Kernel tree does not contain expected UAPI header" - "${KERNEL_DIR}/include/uapi/${PATH}") - endif() - - set(CMAKE_REQUIRED_INCLUDES "${BUILD_INCLUDE}") - endif() - - # Note: The RDMA kernel headers use sockaddr{_in,_in6,}/etc so we have to - # include system headers to define sockaddrs before testing any of them. - CHECK_C_SOURCE_COMPILES(" - #include - #include - #include <${PATH}> -${C_TEST}" "${HAVE}") - - if(KERNEL_DIR) - if (NOT "${${HAVE}}") - # Run the compile test against the linked kernel header, this is to help - # make sure the compile tests work before the headers hit the distro - message(FATAL_ERROR "Kernel UAPI header failed compile test" "${PATH}") - endif() - else() - # NO_SHIM - means the header must exist in the system - # NO_SHIM OPTIONAL - menas the header will be linked from KERNEL_DIR, but is ignored otherwise - if (NOT ARGS_OPTIONAL) - # because it is only used for setting up the kernel headers. - if (ARGS_NO_SHIM) - RDMA_DoFixup("${${HAVE}}" "${PATH}" NO_SHIM) - else() - RDMA_DoFixup("${${HAVE}}" "${PATH}") - endif() - - if (NOT "${${HAVE}}") - list(APPEND MISSING_HEADERS "${PATH}") - set(MISSING_HEADERS "${MISSING_HEADERS}" PARENT_SCOPE) - endif() - endif() - endif() -endfunction() - -function(rdma_report_missing_kheaders) - foreach(I IN LISTS MISSING_HEADERS) - message(STATUS " ${I} NOT found (old system kernel headers)") - endforeach() -endfunction() - -# This list is topologically sorted -rdma_check_kheader("rdma/ib_user_verbs.h" "${DEFAULT_TEST}" NO_SHIM OPTIONAL) -rdma_check_kheader("rdma/ib_user_sa.h" "${DEFAULT_TEST}" NO_SHIM) -rdma_check_kheader("rdma/ib_user_cm.h" "${DEFAULT_TEST}" NO_SHIM) -rdma_check_kheader("rdma/hfi/hfi1_ioctl.h" "${DEFAULT_TEST}" NO_SHIM OPTIONAL) -rdma_check_kheader("rdma/rdma_user_ioctl.h" "${DEFAULT_TEST}" NO_SHIM OPTIONAL) -rdma_check_kheader("rdma/ib_user_mad.h" "${DEFAULT_TEST}" NO_SHIM OPTIONAL) -rdma_check_kheader("rdma/rdma_netlink.h" "int main(int argc,const char *argv[]) { return RDMA_NL_IWPM_REMOTE_INFO && RDMA_NL_IWCM; }") -rdma_check_kheader("rdma/rdma_user_cm.h" "${DEFAULT_TEST}" NO_SHIM OPTIONAL) -rdma_check_kheader("rdma/rdma_user_rxe.h" "${DEFAULT_TEST}") -rdma_check_kheader("rdma/vmw_pvrdma-abi.h" "${DEFAULT_TEST}") diff --git a/usr/rdma-core/buildlib/RDMA_Sparse.cmake b/usr/rdma-core/buildlib/RDMA_Sparse.cmake deleted file mode 100644 index 8fcfb758d..000000000 --- a/usr/rdma-core/buildlib/RDMA_Sparse.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# COPYRIGHT (c) 2017 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -function(RDMA_CheckSparse) - # Sparse defines __CHECKER__, but only for the 'sparse pass', which has no - # way to fail the compiler. - CHECK_C_SOURCE_COMPILES(" -#if __CHECKER__ -#warning \"SPARSE DETECTED\" -#endif -int main(int argc,const char *argv[]) {return 0;} -" - HAVE_NO_SPARSE - FAIL_REGEX "SPARSE DETECTED") - - if (HAVE_NO_SPARSE) - set(HAVE_SPARSE FALSE PARENT_SCOPE) - else() - set(HAVE_SPARSE TRUE PARENT_SCOPE) - - # Replace various glibc headers with our own versions that have embedded sparse annotations. - execute_process(COMMAND "${BUILDLIB}/gen-sparse.py" - "--out" "${BUILD_INCLUDE}/" - "--src" "${CMAKE_SOURCE_DIR}/" - RESULT_VARIABLE retcode) - if(NOT "${retcode}" STREQUAL "0") - message(FATAL_ERROR "glibc header file patching for sparse failed. Review include/*.rej and fix the rejects, then do " - "${BUILDLIB}/gen-sparse.py -out ${BUILD_INCLUDE}/ --src ${CMAKE_SOURCE_DIR}/ --save") - endif() - - # Enable endian analysis in sparse - add_definitions("-D__CHECK_ENDIAN__") - endif() -endfunction() diff --git a/usr/rdma-core/buildlib/cbuild b/usr/rdma-core/buildlib/cbuild deleted file mode 100755 index 918bf2333..000000000 --- a/usr/rdma-core/buildlib/cbuild +++ /dev/null @@ -1,789 +0,0 @@ -#!/usr/bin/env python -# Copyright 2015-2016 Obsidian Research Corp. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. -# PYTHON_ARGCOMPLETE_OK -"""cbuild - Build in a docker container - -This script helps using docker containers to run software builds. This allows -building for a wide range of distributions without having to install them. - -Each target distribution has a base docker image and a set of packages to -install. The first step is to build the customized docker container: - - $ buildlib/cbuild build-images fc25 - -This will download the base image and customize it with the required packages. - -Next, a build can be performed 'in place'. This is useful to do edit/compile -cycles with an alternate distribution. - - $ buildlib/cbuild make fc25 - -The build output will be placed in build-fc25 - -Finally, a full package build can be performed inside the container. Note this -mode actually creates a source tree inside the container based on the current -git HEAD commit, so any uncommitted edits will be lost. - - $ buildlib/cbuild pkg fc25 - -In this case only the final package results are copied outside the container -(to ..) and everything else is discarded. - -In all cases the containers that are spun up are deleted after they are -finished, only the base container created during 'build-images' is kept. The -'--run-shell' option can be used to setup the container to the point of -running the build command and instead run an interactive bash shell. This is -useful for debugging certain kinds of build problems.""" - -import argparse -import collections -import grp -import imp -import inspect -import json -import multiprocessing -import os -import pipes -import pwd -import re -import shutil -import subprocess -import sys -import tempfile -import yaml -from contextlib import contextmanager; - -project = "rdma-core"; - -def get_version(): - """Return the version string for the project, this gets automatically written - into the packaging files.""" - with open("CMakeLists.txt","r") as F: - for ln in F: - g = re.match(r'^set\(PACKAGE_VERSION "(.+)"\)',ln) - if g is None: - continue; - return g.group(1); - raise RuntimeError("Could not find version"); - -class DockerFile(object): - def __init__(self,src): - self.lines = ["FROM %s"%(src)]; - -class Environment(object): - aliases = set(); - use_make = False; - proxy = True; - - def image_name(self): - return "build-%s/%s"%(project,self.name); - -# ------------------------------------------------------------------------- - -class YumEnvironment(Environment): - is_rpm = True; - def get_docker_file(self): - res = DockerFile(self.docker_parent); - res.lines.append("RUN yum install -y %s && yum clean all"%( - " ".join(sorted(self.pkgs)))); - return res; - -class centos6(YumEnvironment): - docker_parent = "centos:6"; - pkgs = { - 'cmake', - 'gcc', - 'libnl3-devel', - 'libudev-devel', - 'make', - 'pkgconfig', - 'python', - 'rpm-build', - 'valgrind-devel', - }; - name = "centos6"; - use_make = True; - -class centos7(YumEnvironment): - docker_parent = "centos:7"; - pkgs = centos6.pkgs | {'systemd-devel'}; - name = "centos7"; - use_make = True; - specfile = "redhat/rdma-core.spec"; - -class centos7_epel(centos7): - pkgs = (centos7.pkgs - {"cmake","make"}) | {"ninja-build","cmake3"}; - name = "centos7_epel"; - use_make = False; - ninja_cmd = "ninja-build"; - # Our spec file does not know how to cope with cmake3 - is_rpm = False; - - def get_docker_file(self): - res = YumEnvironment.get_docker_file(self); - res.lines.insert(1,"RUN yum install -y epel-release"); - res.lines.append("RUN ln -s /usr/bin/cmake3 /usr/local/bin/cmake"); - return res; - -class fc26(Environment): - docker_parent = "fedora:26"; - pkgs = (centos7.pkgs - {"make"}) | {"ninja-build"}; - name = "fc26"; - specfile = "redhat/rdma-core.spec"; - ninja_cmd = "ninja-build"; - is_rpm = True; - - def get_docker_file(self): - res = DockerFile(self.docker_parent); - res.lines.append("RUN dnf install -y %s && dnf clean all"%( - " ".join(sorted(self.pkgs)))); - return res; - -# ------------------------------------------------------------------------- - -class APTEnvironment(Environment): - is_deb = True; - def get_docker_file(self): - res = DockerFile(self.docker_parent); - res.lines.append("RUN apt-get update && apt-get install -y --no-install-recommends %s && apt-get clean"%( - " ".join(sorted(self.pkgs)))); - return res; - -class trusty(APTEnvironment): - docker_parent = "ubuntu:14.04"; - common_pkgs = { - 'build-essential', - 'cmake', - 'debhelper', - 'dh-systemd', - 'gcc', - 'libnl-3-dev', - 'libnl-route-3-dev', - 'libudev-dev', - 'make', - 'ninja-build', - 'pkg-config', - 'python', - 'valgrind', - }; - pkgs = common_pkgs | { - 'libsystemd-daemon-dev', - 'libsystemd-id128-dev', - 'libsystemd-journal-dev', - }; - name = "ubuntu-14.04"; - aliases = {"trusty"}; - -class xenial(APTEnvironment): - docker_parent = "ubuntu:16.04" - pkgs = trusty.common_pkgs | {"libsystemd-dev"}; - name = "ubuntu-16.04"; - aliases = {"xenial"}; - -class jessie(APTEnvironment): - docker_parent = "debian:8" - pkgs = xenial.pkgs; - name = "debian-8"; - aliases = {"jessie"}; - -class stretch(APTEnvironment): - docker_parent = "debian:9" - pkgs = jessie.pkgs; - name = "debian-9"; - aliases = {"stretch"}; - -class debian_experimental(APTEnvironment): - docker_parent = "debian:experimental" - pkgs = (stretch.pkgs ^ {"gcc"}) | {"gcc-7"}; - name = "debian-experimental"; - - def get_docker_file(self): - res = DockerFile(self.docker_parent); - res.lines.append("RUN apt-get update && apt-get -t experimental install -y --no-install-recommends %s && apt-get clean"%( - " ".join(sorted(self.pkgs)))); - return res; - -class travis(APTEnvironment): - """This parses the .travis.yml "apt" add on and converts it to a dockerfile, - basically creating a container that is similar to what travis would - use. Note this does not use the base travis image, nor does it install the - typical travis packages.""" - docker_parent = "ubuntu:14.04"; - name = "travis"; - is_deb = True; - _yaml = None; - - def get_yaml(self): - if self._yaml: - return self._yaml; - - # Load the commands from the travis file - with open(".travis.yml") as F: - self._yaml = yaml.load(F); - return self._yaml; - yaml = property(get_yaml); - - def get_repos(self): - """Return a list of things to add with apt-add-repository""" - Source = collections.namedtuple("Source",["sourceline","key_url"]); - - # See https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json - pre_defined = { - "ubuntu-toolchain-r-test": Source("ppa:ubuntu-toolchain-r/test",None), - }; - - # Unique the sources - res = set(); - for src in self.yaml["addons"]["apt"]["sources"]: - if isinstance(src,dict): - res.add(Source(sourceline=src["sourceline"], - key_url=src.get("key_url",None))); - else: - res.add(pre_defined[src]); - - # Add the sources - scmds = []; - scmds.extend("apt-key add /etc/apt/trusted.gpg.d/%s"%(os.path.basename(I.key_url)) - for I in res if I.key_url is not None); - scmds.extend("http_proxy= apt-add-repository -y %s"%(pipes.quote(I.sourceline)) - for I in res); - - # Download the keys - cmds = ["ADD %s /etc/apt/trusted.gpg.d/"%(I.key_url) - for I in res if I.key_url is not None]; - - cmds.append("RUN " + " && ".join(scmds)); - return cmds; - - def get_before_script(self): - """Return a list of commands to run from before_script""" - cmds = ["RUN useradd -ms /bin/bash travis && \\" - "su -l -c %s"%(pipes.quote(" && ".join(self.yaml["before_script"]))) + " travis"]; - return cmds - - def get_docker_file(self): - # First this to get apt-add-repository - self.pkgs = {"software-properties-common"} - res = APTEnvironment.get_docker_file(self); - - # Sources list from the travis.yml - res.lines.extend(self.get_repos()); - - # Package list from the travis.yml - res.lines.append("RUN apt-get update && apt-get install -y --no-install-recommends %s"%( - " ".join(sorted(self.yaml["addons"]["apt"]["packages"])))); - - # Adding before_script commands - res.lines.extend(self.get_before_script()) - - return res; - -# ------------------------------------------------------------------------- - -class ZypperEnvironment(Environment): - is_rpm = True; - def get_docker_file(self): - res = DockerFile(self.docker_parent); - res.lines.append("RUN zypper --non-interactive refresh"); - res.lines.append("RUN zypper --non-interactive dist-upgrade"); - res.lines.append("RUN zypper --non-interactive install %s"%( - " ".join(sorted(self.pkgs)))); - return res; - -class leap(ZypperEnvironment): - docker_parent = "opensuse:42.2"; - specfile = "suse/rdma-core.spec"; - pkgs = { - 'cmake', - 'gcc', - 'libnl3-devel', - 'libudev-devel', - 'make', - 'ninja', - 'pkg-config', - 'python', - 'rpm-build', - 'systemd-devel', - 'valgrind-devel', - }; - name = "opensuse-42.2"; - aliases = {"leap"}; - -class tumbleweed(ZypperEnvironment): - docker_parent = "opensuse:tumbleweed"; - pkgs = leap.pkgs; - name = "tumbleweed"; - specfile = "suse/rdma-core.spec"; - -# ------------------------------------------------------------------------- - -environments = [centos6(), - centos7(), - centos7_epel(), - travis(), - trusty(), - xenial(), - jessie(), - stretch(), - fc26(), - leap(), - tumbleweed(), - debian_experimental(), -]; - -class ToEnvAction(argparse.Action): - """argparse helper to parse environment lists into environment classes""" - def __call__(self, parser, namespace, values, option_string=None): - if not isinstance(values,list): - values = [values]; - - res = set(); - for I in values: - if I == "all": - res.update(environments); - else: - for env in environments: - if env.name == I or I in env.aliases: - res.add(env); - setattr(namespace, self.dest, sorted(res,key=lambda x:x.name)) - -def env_choices(): - """All the names that can be used with ToEnvAction""" - envs = set(("all",)); - for I in environments: - envs.add(I.name); - envs.update(I.aliases); - return envs; - -def docker_cmd(env,*cmd): - """Invoke docker""" - cmd = list(cmd); - if env.sudo: - return subprocess.check_call(["sudo","docker"] + cmd); - return subprocess.check_call(["docker"] + cmd); - -def docker_cmd_str(env,*cmd): - """Invoke docker""" - cmd = list(cmd); - if env.sudo: - return subprocess.check_output(["sudo","docker"] + cmd); - return subprocess.check_output(["docker"] + cmd); - -@contextmanager -def private_tmp(args): - """Simple version of Python 3's tempfile.TemporaryDirectory""" - dfn = tempfile.mkdtemp(); - try: - yield dfn; - finally: - try: - shutil.rmtree(dfn); - except: - # The debian builds result in root owned files because we don't use fakeroot - subprocess.check_call(['sudo','rm','-rf',dfn]); - -@contextmanager -def inDirectory(dir): - cdir = os.getcwd(); - try: - os.chdir(dir); - yield True; - finally: - os.chdir(cdir); - -def get_image_id(args,image_name): - img = json.loads(docker_cmd_str(args,"inspect",image_name)); - image_id = img[0]["Id"]; - # Newer dockers put a prefix - if ":" in image_id: - image_id = image_id.partition(':')[2]; - return image_id; - -# ------------------------------------------------------------------------- - -def run_rpm_build(args,spec_file,env): - with open(spec_file,"r") as F: - for ln in F: - if ln.startswith("Version:"): - ver = ln.strip().partition(' ')[2].strip(); - assert(ver == get_version()); - - if ln.startswith("Source:"): - tarfn = ln.strip().partition(' ')[2].strip(); - - image_id = get_image_id(args,env.image_name()); - with private_tmp(args) as tmpdir: - os.mkdir(os.path.join(tmpdir,"SOURCES")); - os.mkdir(os.path.join(tmpdir,"tmp")); - - subprocess.check_call(["git","archive", - # This must match the prefix generated buildlib/github-release - "--prefix","%s-%s/"%(project,get_version()), - "--output",os.path.join(tmpdir,"SOURCES",tarfn), - "HEAD"]); - - with open(spec_file,"r") as inF: - spec = list(inF); - tspec_file = os.path.basename(spec_file); - with open(os.path.join(tmpdir,tspec_file),"w") as outF: - outF.write("".join(spec)); - - home = os.path.join(os.path.sep,"home",os.getenv("LOGNAME")); - vdir = os.path.join(home,"rpmbuild"); - - opts = [ - "run", - "--rm=true", - "-v","%s:%s"%(tmpdir,vdir), - "-w",vdir, - "-h","builder-%s"%(image_id[:12]), - "-e","HOME=%s"%(home), - "-e","TMPDIR=%s"%(os.path.join(vdir,"tmp")), - ]; - - # rpmbuild complains if we do not have an entry in passwd and group - # for the user we are going to use to do the build. - with open(os.path.join(tmpdir,"go.py"),"w") as F: - print >> F,""" -import os,subprocess; -with open("/etc/passwd","a") as F: - print >> F, {passwd!r}; -with open("/etc/group","a") as F: - print >> F, {group!r}; -os.setgid({gid:d}); -os.setuid({uid:d}); - -# Get RPM to tell us the expected tar filename. -for ln in subprocess.check_output(["rpmspec","-P",{tspec_file!r}]).splitlines(): - if ln.startswith("Source:"): - tarfn = ln.strip().partition(' ')[2].strip(); -os.symlink({tarfn!r},os.path.join("SOURCES",tarfn)); -""".format(passwd=":".join(str(I) for I in pwd.getpwuid(os.getuid())), - group=":".join(str(I) for I in grp.getgrgid(os.getgid())), - uid=os.getuid(), - gid=os.getgid(), - tarfn=tarfn, - tspec_file=tspec_file); - - bopts = ["-bb",tspec_file]; - - print >> F,'os.execlp("rpmbuild","rpmbuild",%s)'%( - ",".join(repr(I) for I in bopts)); - - if args.run_shell: - opts.append("-ti"); - opts.append(env.image_name()); - - if args.run_shell: - opts.append("/bin/bash"); - else: - opts.extend(["python","go.py"]); - - docker_cmd(args,*opts) - - print - for path,jnk,files in os.walk(os.path.join(tmpdir,"RPMS")): - for I in files: - print "Final RPM: ",os.path.join("..",I); - shutil.move(os.path.join(path,I), - os.path.join("..",I)); - -def run_deb_build(args,env): - image_id = get_image_id(args,env.image_name()); - with private_tmp(args) as tmpdir: - os.mkdir(os.path.join(tmpdir,"src")); - os.mkdir(os.path.join(tmpdir,"tmp")); - - opwd = os.getcwd(); - with inDirectory(os.path.join(tmpdir,"src")): - subprocess.check_call(["git", - "--git-dir",os.path.join(opwd,".git"), - "reset","--hard","HEAD"]); - - home = os.path.join(os.path.sep,"home",os.getenv("LOGNAME")); - - opts = [ - "run", - "--read-only", - "--rm=true", - "-v","%s:%s"%(tmpdir,home), - "-w",os.path.join(home,"src"), - "-h","builder-%s"%(image_id[:12]), - "-e","HOME=%s"%(home), - "-e","TMPDIR=%s"%(os.path.join(home,"tmp")), - "-e","DEB_BUILD_OPTIONS=parallel=%u"%(multiprocessing.cpu_count()), - ]; - - # Create a go.py that will let us run the compilation as the user and - # then switch to root only for the packaging step. - with open(os.path.join(tmpdir,"go.py"),"w") as F: - print >> F,""" -import subprocess,os; -def to_user(): - os.setgid({gid:d}); - os.setuid({uid:d}); -subprocess.check_call(["debian/rules","debian/rules","build"], - preexec_fn=to_user); -subprocess.check_call(["debian/rules","debian/rules","binary"]); -""".format(uid=os.getuid(), - gid=os.getgid()); - - if args.run_shell: - opts.append("-ti"); - opts.append(env.image_name()); - - if args.run_shell: - opts.append("/bin/bash"); - else: - opts.extend(["python",os.path.join(home,"go.py")]); - - docker_cmd(args,*opts); - - print - for I in os.listdir(tmpdir): - if I.endswith(".deb"): - print "Final DEB: ",os.path.join("..",I); - shutil.move(os.path.join(tmpdir,I), - os.path.join("..",I)); - -def run_travis_build(args,env): - with private_tmp(args) as tmpdir: - os.mkdir(os.path.join(tmpdir,"src")); - os.mkdir(os.path.join(tmpdir,"tmp")); - - opwd = os.getcwd(); - with inDirectory(os.path.join(tmpdir,"src")): - subprocess.check_call(["git", - "--git-dir",os.path.join(opwd,".git"), - "reset","--hard","HEAD"]); - subprocess.check_call(["git", - "--git-dir",os.path.join(opwd,".git"), - "fetch", - "--no-tags", - "https://github.com/linux-rdma/rdma-core.git","HEAD", - "master"]); - base = subprocess.check_output(["git", - "--git-dir",os.path.join(opwd,".git"), - "merge-base", - "HEAD","FETCH_HEAD"]).strip(); - - home = os.path.join(os.path.sep,"home","travis"); - home_build = os.path.join(os.path.sep,home,"build"); - - opts = [ - "run", - "--read-only", - "--rm=true", - "-v","%s:%s"%(tmpdir, home_build), - "-v","%s:%s:ro"%(os.path.join(opwd,".git"),os.path.join(home_build,"src",".git")), - "-w",os.path.join(home_build,"src"), - "-u",str(os.getuid()), - "-e","TRAVIS_COMMIT_RANGE=%s..HEAD"%(base), - "-e","TRAVIS_BRANCH=%s"%(base), - "-e","TRAVIS_EVENT_TYPE=pull_request", - "-e","HOME=%s"%(home), - "-e","TMPDIR=%s"%(os.path.join(home_build,"tmp")), - ]; - - # Load the commands from the travis file - with open(os.path.join(opwd,".travis.yml")) as F: - cmds = yaml.load(F)["script"]; - - with open(os.path.join(tmpdir,"go.sh"),"w") as F: - print >> F,"#!/bin/bash"; - print >> F,"set -e"; - for I in cmds: - print >> F,I; - - if args.run_shell: - opts.append("-ti"); - opts.append(env.image_name()); - - if args.run_shell: - opts.append("/bin/bash"); - else: - opts.extend(["/bin/bash",os.path.join(home_build,"go.sh")]); - - docker_cmd(args,*opts); - -def args_pkg(parser): - parser.add_argument("ENV",action=ToEnvAction,choices=env_choices()); - parser.add_argument("--run-shell",default=False,action="store_true", - help="Instead of running the build, enter a shell"); -def cmd_pkg(args): - """Build a package in the given environment.""" - for env in args.ENV: - if env.name == "travis": - run_travis_build(args,env); - elif getattr(env,"is_deb",False): - run_deb_build(args,env); - elif getattr(env,"is_rpm",False): - run_rpm_build(args, - getattr(env,"specfile","%s.spec"%(project)), - env); - else: - print "%s does not support packaging"%(env.name); - -# ------------------------------------------------------------------------- - -def args_make(parser): - parser.add_argument("--run-shell",default=False,action="store_true", - help="Instead of running the build, enter a shell"); - parser.add_argument("ENV",action=ToEnvAction,choices=env_choices()); - parser.add_argument('ARGS', nargs=argparse.REMAINDER); -def cmd_make(args): - """Run cmake and ninja within a docker container. If cmake has not yet been - run then this runs it with the given environment variables, then invokes ninja. - Otherwise ninja is invoked without calling cmake.""" - SRC = os.getcwd(); - - for env in args.ENV: - BUILD = "build-%s"%(env.name) - if not os.path.exists(BUILD): - os.mkdir(BUILD); - - home = os.path.join(os.path.sep,"home",os.getenv("LOGNAME")); - - dirs = [os.getcwd(),"/tmp"]; - # Import the symlink target too if BUILD is a symlink - BUILD_r = os.path.realpath(BUILD); - if not BUILD_r.startswith(os.path.realpath(SRC)): - dirs.append(BUILD_r); - - cmake_args = [] - cmake_envs = [] - ninja_args = [] - for I in args.ARGS: - if I.startswith("-D"): - cmake_args.append(I); - elif I.find('=') != -1: - cmake_envs.append(I); - else: - ninja_args.append(I); - - if env.use_make: - need_cmake = not os.path.exists(os.path.join(BUILD_r,"Makefile")); - else: - need_cmake = not os.path.exists(os.path.join(BUILD_r,"build.ninja")); - opts = ["run", - "--read-only", - "--rm=true", - "-ti", - "-u",str(os.getuid()), - "-e","HOME=%s"%(home), - "-w",BUILD_r, - ]; - for I in dirs: - opts.append("-v"); - opts.append("%s:%s"%(I,I)); - for I in cmake_envs: - opts.append("-e"); - opts.append(I); - if args.run_shell: - opts.append("-ti"); - opts.append(env.image_name()); - - if args.run_shell: - os.execlp("sudo","sudo","docker",*(opts + ["/bin/bash"])); - - if need_cmake: - if env.use_make: - prog_args = ["cmake",SRC] + cmake_args; - else: - prog_args = ["cmake","-GNinja",SRC] + cmake_args; - docker_cmd(args,*(opts + prog_args)); - - if env.use_make: - prog_args = ["make","-C",BUILD_r] + ninja_args; - else: - prog_args = [getattr(env,"ninja_cmd","ninja"), - "-C",BUILD_r] + ninja_args; - - if len(args.ENV) <= 1: - os.execlp("sudo","sudo","docker",*(opts + prog_args)); - else: - docker_cmd(args,*(opts + prog_args)); - -# ------------------------------------------------------------------------- - -def get_build_args(args,env): - """Return extra docker arguments for building. This is the system APT proxy.""" - res = []; - if args.pull: - res.append("--pull"); - - if env.proxy and os.path.exists("/etc/apt/apt.conf.d/01proxy"): - # The line in this file must be 'Acquire::http { Proxy "http://xxxx:3142"; };' - with open("/etc/apt/apt.conf.d/01proxy") as F: - proxy = F.read().strip().split('"')[1]; - res.append("--build-arg"); - res.append('http_proxy=%s'%(proxy)); - return res; - -def args_build_images(parser): - parser.add_argument("ENV",nargs="+",action=ToEnvAction,choices=env_choices()); - parser.add_argument("--no-pull",default=True,action="store_false", - dest="pull", - help="Instead of running the build, enter a shell"); -def cmd_build_images(args): - """Run from the top level source directory to make the docker images that are - needed for building. This only needs to be run once.""" - for env in args.ENV: - df = env.get_docker_file(); - with private_tmp(args) as tmpdir: - fn = os.path.join(tmpdir,"Dockerfile"); - with open(fn,"wt") as F: - for ln in df.lines: - print >> F,ln; - opts = (["build"] + - get_build_args(args,env) + - ["-f",fn, - "-t",env.image_name(), - tmpdir]); - docker_cmd(args,*opts); - -# ------------------------------------------------------------------------- -def args_docker_gc(parser): - pass; -def cmd_docker_gc(args): - """Run garbage collection on docker images and containers.""" - - containers = set(docker_cmd_str(args,"ps","-a","-q","--filter","status=exited").split()); - images = set(docker_cmd_str(args,"images","-q","--filter","dangling=true").split()); - - if containers: - docker_cmd(args,"rm",*sorted(containers)); - if images: - docker_cmd(args,"rmi",*sorted(images)); - -# ------------------------------------------------------------------------- - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Operate docker for building this package') - subparsers = parser.add_subparsers(title="Sub Commands"); - - funcs = globals(); - for k,v in funcs.items(): - if k.startswith("cmd_") and inspect.isfunction(v): - sparser = subparsers.add_parser(k[4:].replace('_','-'), - help=v.__doc__); - funcs["args_" + k[4:]](sparser); - sparser.set_defaults(func=v); - - try: - import argcomplete; - argcomplete.autocomplete(parser); - except ImportError: - pass; - - args = parser.parse_args(); - args.sudo = True; - - # This script must always run from the top of the git tree, and a git - # checkout is mandatory. - git_top = subprocess.check_output(["git","rev-parse","--git-dir"]).strip(); - if git_top != ".git": - os.chdir(os.path.dirname(git_top)); - - args.func(args); diff --git a/usr/rdma-core/buildlib/check-build b/usr/rdma-core/buildlib/check-build deleted file mode 100755 index 7671f4eb7..000000000 --- a/usr/rdma-core/buildlib/check-build +++ /dev/null @@ -1,205 +0,0 @@ -#!/usr/bin/env python -# Copyright 2017 Obsidian Research Corp. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. -"""check-build - Run static checks on a build""" -import argparse -import inspect -import os -import re -import shutil -import subprocess -import tempfile -from contextlib import contextmanager; - -def get_src_dir(): - """Get the source directory using git""" - git_top = subprocess.check_output(["git","rev-parse","--git-dir"]).strip(); - if git_top == ".git": - return "."; - return os.path.dirname(git_top); - -def get_package_version(args): - """Return PACKAGE_VERSION from CMake""" - with open(os.path.join(args.SRC,"CMakeLists.txt")) as F: - for ln in F: - g = re.match(r'^set\(PACKAGE_VERSION "(.+)"\)',ln) - if g is None: - continue; - return g.group(1); - raise RuntimeError("Could not find version"); - -@contextmanager -def inDirectory(dir): - cdir = os.getcwd(); - try: - os.chdir(dir); - yield True; - finally: - os.chdir(cdir); - -@contextmanager -def private_tmp(): - """Simple version of Python 3's tempfile.TemporaryDirectory""" - dfn = tempfile.mkdtemp(); - try: - yield dfn; - finally: - shutil.rmtree(dfn); - -# ------------------------------------------------------------------------- - -def get_symbol_vers(fn,exported=True): - """Return the symbol version suffixes from the ELF file, eg IB_VERBS_1.0, etc""" - syms = subprocess.check_output(["readelf","--wide","-s",fn]); - go = False; - res = set(); - for I in syms.splitlines(): - if I.startswith("Symbol table '.dynsym'"): - go = True; - continue; - - if I.startswith(" ") and go: - itms = I.split(); - if exported: - if (len(itms) == 8 and itms[3] == "OBJECT" and - itms[4] == "GLOBAL" and itms[6] == "ABS"): - res.add(itms[7]); - else: - if (len(itms) >= 8 and itms[3] == "FUNC" and - itms[4] == "GLOBAL" and itms[6] == "UND"): - res.add(itms[7]); - else: - go = False; - if not res: - raise ValueError("Failed to read ELF symbol versions from %r"%(fn)); - return res; - -def check_lib_symver(args,fn): - g = re.match(r"lib([^.]+)\.so\.(\d+)\.(\d+)\.(.*)",fn); - if g.group(4) != args.PACKAGE_VERSION: - raise ValueError("Shared Library filename %r does not have the package version %r (%r)%"( - fn,args.PACKAGE_VERSION,g.groups())); - - # umad used the wrong symbol version name when they moved to soname 3.0 - if g.group(1) == "ibumad": - newest_symver = "%s_%s.%s"%(g.group(1).upper(),'1',g.group(3)); - else: - newest_symver = "%s_%s.%s"%(g.group(1).upper(),g.group(2),g.group(3)); - - syms = get_symbol_vers(fn); - if newest_symver not in syms: - raise ValueError("Symbol version %r implied by filename %r not in ELF (%r)"%( - newest_symver,fn,syms)); - - # The private symbol tag should also be older than the package version - private = set(I for I in syms if "PRIVATE" in I) - if len(private) > 1: - raise ValueError("Too many private symbol versions in ELF %r (%r)"%(fn,private)); - if private: - private_rel = list(private)[0].split('_')[-1]; - if private_rel > args.PACKAGE_VERSION: - raise ValueError("Private Symbol Version %r is newer than the package version %r"%( - private,args.PACKAGE_VERSION)); - - syms = list(syms - private); - syms.sort(key=lambda x:re.split('[._]',x)); - if newest_symver != syms[-1]: - raise ValueError("Symbol version %r implied by filename %r not the newest in ELF (%r)"%( - newest_symver,fn,syms)); - -def test_lib_names(args): - """Check that the library filename matches the symbol versions""" - libd = os.path.join(args.BUILD,"lib"); - - # List of shlibs that follow the ABI guidelines - libs = {}; - with inDirectory(libd): - for fn in os.listdir("."): - if os.path.islink(fn): - lfn = os.readlink(fn); - if not os.path.islink(lfn): - check_lib_symver(args,lfn); -# ------------------------------------------------------------------------- - -def check_verbs_abi(args,fn): - g = re.match(r"lib([^-]+)-rdmav(\d+).so",fn); - if g is None: - raise ValueError("Provider library has unknown file name format %r"%(fn)); - - private_ver = int(g.group(2)); - syms = get_symbol_vers(fn,exported=False); - syms = {I.partition("@")[2] for I in syms}; - assert "IBVERBS_PRIVATE_%u"%(private_ver) in syms; - assert len([I for I in syms if I.startswith("IBVERBS_PRIVATE")]) == 1; - -def test_verbs_private(args): - """Check that the IBVERBS_PRIVATE symbols match the library name, eg that the - map file and the cmake stuff are in sync.""" - libd = os.path.join(args.BUILD,"lib"); - with inDirectory(libd): - for fn in os.listdir("."): - if not os.path.islink(fn) and "rdmav" in fn: - check_verbs_abi(args,fn); - -# ------------------------------------------------------------------------- - -def is_obsolete(fn): - """True if the header is obsolete and should not be compiled anyhow.""" - with open(fn) as F: - for ln in F.readlines(): - if re.search(r"#warning.*This header is obsolete",ln): - return True; - return False; - -def is_fixup(fn): - """True if this is a fixup header, fixup headers are exempted because they - required includes are not the same for kernel headers (eg netinet/in.h)""" - if os.path.islink(fn): - return "buildlib/fixup-include/" in os.readlink(fn); - return False; - -def test_public_headers(args): - """Test that every header file can be included on its own, and has no obvious - implicit dependencies. This is mainly intended to check the public - headers, but this sweeps in published internal headers too.""" - incdir = os.path.abspath(os.path.join(args.BUILD,"include")); - includes = set(); - for root,dirs,files in os.walk(incdir): - for I in files: - if I.endswith(".h"): - includes.add(os.path.join(root,I)); - - # Make a little ninja file to compile each header - with private_tmp() as tmpd: - with open(os.path.join(tmpd,"build.ninja"),"wt") as F: - print >> F,"rule comp"; - print >> F," command = %s -Werror -c -I %s $in -o $out"%(args.CC,incdir); - print >> F," description=Header check for $in"; - count = 0; - for I in sorted(includes): - if is_obsolete(I) or is_fixup(I): - continue; - print >> F,"build %s : comp %s"%("out%d.o"%(count),I); - print >> F,"default %s"%("out%d.o"%(count)); - count = count + 1; - subprocess.check_call(["ninja"],cwd=tmpd); - -# ------------------------------------------------------------------------- - -parser = argparse.ArgumentParser(description='Run build time tests') -parser.add_argument("--build",default=os.getcwd(),dest="BUILD", - help="Build directory to inpsect"); -parser.add_argument("--src",default=None,dest="SRC", - help="Top of the source tree"); -parser.add_argument("--cc",default="cc",dest="CC", - help="C compiler to use"); -args = parser.parse_args(); - -if args.SRC is None: - args.SRC = get_src_dir(); -args.PACKAGE_VERSION = get_package_version(args); - -funcs = globals(); -for k,v in funcs.items(): - if k.startswith("test_") and inspect.isfunction(v): - v(args); diff --git a/usr/rdma-core/buildlib/config.h.in b/usr/rdma-core/buildlib/config.h.in deleted file mode 100644 index 8ca0bc0f3..000000000 --- a/usr/rdma-core/buildlib/config.h.in +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef CONFIG_H_IN -#define CONFIG_H_IN - -#define HAVE_STATEMENT_EXPR 1 -#define HAVE_BUILTIN_TYPES_COMPATIBLE_P 1 -#define HAVE_TYPEOF 1 -#define HAVE_ISBLANK 1 - -// FIXME: Remove this, The cmake version hard-requires new style CLOEXEC support -#define STREAM_CLOEXEC "e" - -#define IBV_CONFIG_DIR "@CONFIG_DIR@" -#define RS_CONF_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket" -#define IWPM_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/iwpmd.conf" - -#define SRP_DEAMON_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf" -#define SRP_DEAMON_LOCK_PREFIX "@CMAKE_INSTALL_FULL_RUNDIR@/srp_daemon" - -#define ACM_CONF_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma" -#define IBACM_LIB_PATH "@ACM_PROVIDER_DIR@" -#define IBACM_BIN_PATH "@CMAKE_INSTALL_FULL_BINDIR@" -#define IBACM_PID_FILE "@CMAKE_INSTALL_FULL_RUNDIR@/ibacm.pid" -#define IBACM_PORT_FILE "@CMAKE_INSTALL_FULL_RUNDIR@/ibacm.port" -#define IBACM_LOG_FILE "@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/ibacm.log" - -#define VERBS_PROVIDER_DIR "@VERBS_PROVIDER_DIR@" -#define VERBS_PROVIDER_SUFFIX "@IBVERBS_PROVIDER_SUFFIX@" -#define IBVERBS_PABI_VERSION @IBVERBS_PABI_VERSION@ - -// FIXME This has been supported in compilers forever, we should just fail to build on such old systems. -#cmakedefine HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE 1 - -#cmakedefine HAVE_FUNC_ATTRIBUTE_IFUNC 1 - -#cmakedefine HAVE_WORKING_IF_H 1 - -// Operating mode for symbol versions -#cmakedefine HAVE_FULL_SYMBOL_VERSIONS 1 -#cmakedefine HAVE_LIMITED_SYMBOL_VERSIONS 1 - -@SIZEOF_LONG_CODE@ - -#if @NL_KIND@ == 3 -# define HAVE_LIBNL3 1 -#elif @NL_KIND@ == 1 -# define HAVE_LIBNL1 1 -#elif @NL_KIND@ == 0 -# define NRESOLVE_NEIGH 1 -#endif - -#endif diff --git a/usr/rdma-core/buildlib/const_structs.checkpatch b/usr/rdma-core/buildlib/const_structs.checkpatch deleted file mode 100644 index e69de29bb..000000000 diff --git a/usr/rdma-core/buildlib/fixup-include/rdma-rdma_netlink.h b/usr/rdma-core/buildlib/fixup-include/rdma-rdma_netlink.h deleted file mode 100644 index 02fe8390c..000000000 --- a/usr/rdma-core/buildlib/fixup-include/rdma-rdma_netlink.h +++ /dev/null @@ -1,225 +0,0 @@ -#ifndef _UAPI_RDMA_NETLINK_H -#define _UAPI_RDMA_NETLINK_H - -#include - -enum { - RDMA_NL_RDMA_CM = 1, - RDMA_NL_IWCM, - RDMA_NL_RSVD, - RDMA_NL_LS, /* RDMA Local Services */ - RDMA_NL_I40IW, - RDMA_NL_NUM_CLIENTS -}; - -enum { - RDMA_NL_GROUP_CM = 1, - RDMA_NL_GROUP_IWPM, - RDMA_NL_GROUP_LS, - RDMA_NL_NUM_GROUPS -}; - -#define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10) -#define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1)) -#define RDMA_NL_GET_TYPE(client, op) ((client << 10) + op) - -enum { - RDMA_NL_RDMA_CM_ID_STATS = 0, - RDMA_NL_RDMA_CM_NUM_OPS -}; - -enum { - RDMA_NL_RDMA_CM_ATTR_SRC_ADDR = 1, - RDMA_NL_RDMA_CM_ATTR_DST_ADDR, - RDMA_NL_RDMA_CM_NUM_ATTR, -}; - -/* iwarp port mapper op-codes */ -enum { - RDMA_NL_IWPM_REG_PID = 0, - RDMA_NL_IWPM_ADD_MAPPING, - RDMA_NL_IWPM_QUERY_MAPPING, - RDMA_NL_IWPM_REMOVE_MAPPING, - RDMA_NL_IWPM_REMOTE_INFO, - RDMA_NL_IWPM_HANDLE_ERR, - RDMA_NL_IWPM_MAPINFO, - RDMA_NL_IWPM_MAPINFO_NUM, - RDMA_NL_IWPM_NUM_OPS -}; - -struct rdma_cm_id_stats { - __u32 qp_num; - __u32 bound_dev_if; - __u32 port_space; - __s32 pid; - __u8 cm_state; - __u8 node_type; - __u8 port_num; - __u8 qp_type; -}; - -enum { - IWPM_NLA_REG_PID_UNSPEC = 0, - IWPM_NLA_REG_PID_SEQ, - IWPM_NLA_REG_IF_NAME, - IWPM_NLA_REG_IBDEV_NAME, - IWPM_NLA_REG_ULIB_NAME, - IWPM_NLA_REG_PID_MAX -}; - -enum { - IWPM_NLA_RREG_PID_UNSPEC = 0, - IWPM_NLA_RREG_PID_SEQ, - IWPM_NLA_RREG_IBDEV_NAME, - IWPM_NLA_RREG_ULIB_NAME, - IWPM_NLA_RREG_ULIB_VER, - IWPM_NLA_RREG_PID_ERR, - IWPM_NLA_RREG_PID_MAX - -}; - -enum { - IWPM_NLA_MANAGE_MAPPING_UNSPEC = 0, - IWPM_NLA_MANAGE_MAPPING_SEQ, - IWPM_NLA_MANAGE_ADDR, - IWPM_NLA_MANAGE_MAPPED_LOC_ADDR, - IWPM_NLA_RMANAGE_MAPPING_ERR, - IWPM_NLA_RMANAGE_MAPPING_MAX -}; - -#define IWPM_NLA_MANAGE_MAPPING_MAX 3 -#define IWPM_NLA_QUERY_MAPPING_MAX 4 -#define IWPM_NLA_MAPINFO_SEND_MAX 3 - -enum { - IWPM_NLA_QUERY_MAPPING_UNSPEC = 0, - IWPM_NLA_QUERY_MAPPING_SEQ, - IWPM_NLA_QUERY_LOCAL_ADDR, - IWPM_NLA_QUERY_REMOTE_ADDR, - IWPM_NLA_RQUERY_MAPPED_LOC_ADDR, - IWPM_NLA_RQUERY_MAPPED_REM_ADDR, - IWPM_NLA_RQUERY_MAPPING_ERR, - IWPM_NLA_RQUERY_MAPPING_MAX -}; - -enum { - IWPM_NLA_MAPINFO_REQ_UNSPEC = 0, - IWPM_NLA_MAPINFO_ULIB_NAME, - IWPM_NLA_MAPINFO_ULIB_VER, - IWPM_NLA_MAPINFO_REQ_MAX -}; - -enum { - IWPM_NLA_MAPINFO_UNSPEC = 0, - IWPM_NLA_MAPINFO_LOCAL_ADDR, - IWPM_NLA_MAPINFO_MAPPED_ADDR, - IWPM_NLA_MAPINFO_MAX -}; - -enum { - IWPM_NLA_MAPINFO_NUM_UNSPEC = 0, - IWPM_NLA_MAPINFO_SEQ, - IWPM_NLA_MAPINFO_SEND_NUM, - IWPM_NLA_MAPINFO_ACK_NUM, - IWPM_NLA_MAPINFO_NUM_MAX -}; - -enum { - IWPM_NLA_ERR_UNSPEC = 0, - IWPM_NLA_ERR_SEQ, - IWPM_NLA_ERR_CODE, - IWPM_NLA_ERR_MAX -}; - -/* - * Local service operations: - * RESOLVE - The client requests the local service to resolve a path. - * SET_TIMEOUT - The local service requests the client to set the timeout. - * IP_RESOLVE - The client requests the local service to resolve an IP to GID. - */ -enum { - RDMA_NL_LS_OP_RESOLVE = 0, - RDMA_NL_LS_OP_SET_TIMEOUT, - RDMA_NL_LS_OP_IP_RESOLVE, - RDMA_NL_LS_NUM_OPS -}; - -/* Local service netlink message flags */ -#define RDMA_NL_LS_F_ERR 0x0100 /* Failed response */ - -/* - * Local service resolve operation family header. - * The layout for the resolve operation: - * nlmsg header - * family header - * attributes - */ - -/* - * Local service path use: - * Specify how the path(s) will be used. - * ALL - For connected CM operation (6 pathrecords) - * UNIDIRECTIONAL - For unidirectional UD (1 pathrecord) - * GMP - For miscellaneous GMP like operation (at least 1 reversible - * pathrecord) - */ -enum { - LS_RESOLVE_PATH_USE_ALL = 0, - LS_RESOLVE_PATH_USE_UNIDIRECTIONAL, - LS_RESOLVE_PATH_USE_GMP, - LS_RESOLVE_PATH_USE_MAX -}; - -#define LS_DEVICE_NAME_MAX 64 - -struct rdma_ls_resolve_header { - __u8 device_name[LS_DEVICE_NAME_MAX]; - __u8 port_num; - __u8 path_use; -}; - -struct rdma_ls_ip_resolve_header { - __u32 ifindex; -}; - -/* Local service attribute type */ -#define RDMA_NLA_F_MANDATORY (1 << 13) -#define RDMA_NLA_TYPE_MASK (~(NLA_F_NESTED | NLA_F_NET_BYTEORDER | \ - RDMA_NLA_F_MANDATORY)) - -/* - * Local service attributes: - * Attr Name Size Byte order - * ----------------------------------------------------- - * PATH_RECORD struct ib_path_rec_data - * TIMEOUT u32 cpu - * SERVICE_ID u64 cpu - * DGID u8[16] BE - * SGID u8[16] BE - * TCLASS u8 - * PKEY u16 cpu - * QOS_CLASS u16 cpu - * IPV4 u32 BE - * IPV6 u8[16] BE - */ -enum { - LS_NLA_TYPE_UNSPEC = 0, - LS_NLA_TYPE_PATH_RECORD, - LS_NLA_TYPE_TIMEOUT, - LS_NLA_TYPE_SERVICE_ID, - LS_NLA_TYPE_DGID, - LS_NLA_TYPE_SGID, - LS_NLA_TYPE_TCLASS, - LS_NLA_TYPE_PKEY, - LS_NLA_TYPE_QOS_CLASS, - LS_NLA_TYPE_IPV4, - LS_NLA_TYPE_IPV6, - LS_NLA_TYPE_MAX -}; - -/* Local service DGID/SGID attribute: big endian */ -struct rdma_nla_ls_gid { - __u8 gid[16]; -}; - -#endif /* _UAPI_RDMA_NETLINK_H */ diff --git a/usr/rdma-core/buildlib/fixup-include/rdma-rdma_user_rxe.h b/usr/rdma-core/buildlib/fixup-include/rdma-rdma_user_rxe.h deleted file mode 100644 index 1de99cfda..000000000 --- a/usr/rdma-core/buildlib/fixup-include/rdma-rdma_user_rxe.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef RDMA_USER_RXE_H -#define RDMA_USER_RXE_H - -#include - -union rxe_gid { - __u8 raw[16]; - struct { - __be64 subnet_prefix; - __be64 interface_id; - } global; -}; - -struct rxe_global_route { - union rxe_gid dgid; - __u32 flow_label; - __u8 sgid_index; - __u8 hop_limit; - __u8 traffic_class; -}; - -struct rxe_av { - __u8 port_num; - __u8 network_type; - struct rxe_global_route grh; - union { - struct sockaddr _sockaddr; - struct sockaddr_in _sockaddr_in; - struct sockaddr_in6 _sockaddr_in6; - } sgid_addr, dgid_addr; -}; - -struct rxe_send_wr { - __u64 wr_id; - __u32 num_sge; - __u32 opcode; - __u32 send_flags; - union { - __be32 imm_data; - __u32 invalidate_rkey; - } ex; - union { - struct { - __u64 remote_addr; - __u32 rkey; - } rdma; - struct { - __u64 remote_addr; - __u64 compare_add; - __u64 swap; - __u32 rkey; - } atomic; - struct { - __u32 remote_qpn; - __u32 remote_qkey; - __u16 pkey_index; - } ud; - struct { - struct ib_mr *mr; - __u32 key; - int access; - } reg; - } wr; -}; - -struct rxe_sge { - __u64 addr; - __u32 length; - __u32 lkey; -}; - -struct mminfo { - __u64 offset; - __u32 size; - __u32 pad; -}; - -struct rxe_dma_info { - __u32 length; - __u32 resid; - __u32 cur_sge; - __u32 num_sge; - __u32 sge_offset; - union { - __u8 inline_data[0]; - struct rxe_sge sge[0]; - }; -}; - -struct rxe_send_wqe { - struct rxe_send_wr wr; - struct rxe_av av; - __u32 status; - __u32 state; - __u64 iova; - __u32 mask; - __u32 first_psn; - __u32 last_psn; - __u32 ack_length; - __u32 ssn; - __u32 has_rd_atomic; - struct rxe_dma_info dma; -}; - -struct rxe_recv_wqe { - __u64 wr_id; - __u32 num_sge; - __u32 padding; - struct rxe_dma_info dma; -}; - -#endif /* RDMA_USER_RXE_H */ diff --git a/usr/rdma-core/buildlib/fixup-include/rdma-vmw_pvrdma-abi.h b/usr/rdma-core/buildlib/fixup-include/rdma-vmw_pvrdma-abi.h deleted file mode 100644 index c8c1d2d6d..000000000 --- a/usr/rdma-core/buildlib/fixup-include/rdma-vmw_pvrdma-abi.h +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. 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 version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program available in the file COPYING in the main - * directory of this source tree. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __VMW_PVRDMA_ABI_H__ -#define __VMW_PVRDMA_ABI_H__ - -#include - -#define PVRDMA_UVERBS_ABI_VERSION 3 /* ABI Version. */ -#define PVRDMA_UAR_HANDLE_MASK 0x00FFFFFF /* Bottom 24 bits. */ -#define PVRDMA_UAR_QP_OFFSET 0 /* QP doorbell. */ -#define PVRDMA_UAR_QP_SEND BIT(30) /* Send bit. */ -#define PVRDMA_UAR_QP_RECV BIT(31) /* Recv bit. */ -#define PVRDMA_UAR_CQ_OFFSET 4 /* CQ doorbell. */ -#define PVRDMA_UAR_CQ_ARM_SOL BIT(29) /* Arm solicited bit. */ -#define PVRDMA_UAR_CQ_ARM BIT(30) /* Arm bit. */ -#define PVRDMA_UAR_CQ_POLL BIT(31) /* Poll bit. */ - -enum pvrdma_wr_opcode { - PVRDMA_WR_RDMA_WRITE, - PVRDMA_WR_RDMA_WRITE_WITH_IMM, - PVRDMA_WR_SEND, - PVRDMA_WR_SEND_WITH_IMM, - PVRDMA_WR_RDMA_READ, - PVRDMA_WR_ATOMIC_CMP_AND_SWP, - PVRDMA_WR_ATOMIC_FETCH_AND_ADD, - PVRDMA_WR_LSO, - PVRDMA_WR_SEND_WITH_INV, - PVRDMA_WR_RDMA_READ_WITH_INV, - PVRDMA_WR_LOCAL_INV, - PVRDMA_WR_FAST_REG_MR, - PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP, - PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD, - PVRDMA_WR_BIND_MW, - PVRDMA_WR_REG_SIG_MR, -}; - -enum pvrdma_wc_status { - PVRDMA_WC_SUCCESS, - PVRDMA_WC_LOC_LEN_ERR, - PVRDMA_WC_LOC_QP_OP_ERR, - PVRDMA_WC_LOC_EEC_OP_ERR, - PVRDMA_WC_LOC_PROT_ERR, - PVRDMA_WC_WR_FLUSH_ERR, - PVRDMA_WC_MW_BIND_ERR, - PVRDMA_WC_BAD_RESP_ERR, - PVRDMA_WC_LOC_ACCESS_ERR, - PVRDMA_WC_REM_INV_REQ_ERR, - PVRDMA_WC_REM_ACCESS_ERR, - PVRDMA_WC_REM_OP_ERR, - PVRDMA_WC_RETRY_EXC_ERR, - PVRDMA_WC_RNR_RETRY_EXC_ERR, - PVRDMA_WC_LOC_RDD_VIOL_ERR, - PVRDMA_WC_REM_INV_RD_REQ_ERR, - PVRDMA_WC_REM_ABORT_ERR, - PVRDMA_WC_INV_EECN_ERR, - PVRDMA_WC_INV_EEC_STATE_ERR, - PVRDMA_WC_FATAL_ERR, - PVRDMA_WC_RESP_TIMEOUT_ERR, - PVRDMA_WC_GENERAL_ERR, -}; - -enum pvrdma_wc_opcode { - PVRDMA_WC_SEND, - PVRDMA_WC_RDMA_WRITE, - PVRDMA_WC_RDMA_READ, - PVRDMA_WC_COMP_SWAP, - PVRDMA_WC_FETCH_ADD, - PVRDMA_WC_BIND_MW, - PVRDMA_WC_LSO, - PVRDMA_WC_LOCAL_INV, - PVRDMA_WC_FAST_REG_MR, - PVRDMA_WC_MASKED_COMP_SWAP, - PVRDMA_WC_MASKED_FETCH_ADD, - PVRDMA_WC_RECV = 1 << 7, - PVRDMA_WC_RECV_RDMA_WITH_IMM, -}; - -enum pvrdma_wc_flags { - PVRDMA_WC_GRH = 1 << 0, - PVRDMA_WC_WITH_IMM = 1 << 1, - PVRDMA_WC_WITH_INVALIDATE = 1 << 2, - PVRDMA_WC_IP_CSUM_OK = 1 << 3, - PVRDMA_WC_WITH_SMAC = 1 << 4, - PVRDMA_WC_WITH_VLAN = 1 << 5, - PVRDMA_WC_FLAGS_MAX = PVRDMA_WC_WITH_VLAN, -}; - -struct pvrdma_alloc_ucontext_resp { - __u32 qp_tab_size; - __u32 reserved; -}; - -struct pvrdma_alloc_pd_resp { - __u32 pdn; - __u32 reserved; -}; - -struct pvrdma_create_cq { - __u64 buf_addr; - __u32 buf_size; - __u32 reserved; -}; - -struct pvrdma_create_cq_resp { - __u32 cqn; - __u32 reserved; -}; - -struct pvrdma_resize_cq { - __u64 buf_addr; - __u32 buf_size; - __u32 reserved; -}; - -struct pvrdma_create_srq { - __u64 buf_addr; -}; - -struct pvrdma_create_srq_resp { - __u32 srqn; - __u32 reserved; -}; - -struct pvrdma_create_qp { - __u64 rbuf_addr; - __u64 sbuf_addr; - __u32 rbuf_size; - __u32 sbuf_size; - __u64 qp_addr; -}; - -/* PVRDMA masked atomic compare and swap */ -struct pvrdma_ex_cmp_swap { - __u64 swap_val; - __u64 compare_val; - __u64 swap_mask; - __u64 compare_mask; -}; - -/* PVRDMA masked atomic fetch and add */ -struct pvrdma_ex_fetch_add { - __u64 add_val; - __u64 field_boundary; -}; - -/* PVRDMA address vector. */ -struct pvrdma_av { - __u32 port_pd; - __u32 sl_tclass_flowlabel; - __u8 dgid[16]; - __u8 src_path_bits; - __u8 gid_index; - __u8 stat_rate; - __u8 hop_limit; - __u8 dmac[6]; - __u8 reserved[6]; -}; - -/* PVRDMA scatter/gather entry */ -struct pvrdma_sge { - __u64 addr; - __u32 length; - __u32 lkey; -}; - -/* PVRDMA receive queue work request */ -struct pvrdma_rq_wqe_hdr { - __u64 wr_id; /* wr id */ - __u32 num_sge; /* size of s/g array */ - __u32 total_len; /* reserved */ -}; -/* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */ - -/* PVRDMA send queue work request */ -struct pvrdma_sq_wqe_hdr { - __u64 wr_id; /* wr id */ - __u32 num_sge; /* size of s/g array */ - __u32 total_len; /* reserved */ - __u32 opcode; /* operation type */ - __u32 send_flags; /* wr flags */ - union { - __be32 imm_data; - __u32 invalidate_rkey; - } ex; - __u32 reserved; - union { - struct { - __u64 remote_addr; - __u32 rkey; - __u8 reserved[4]; - } rdma; - struct { - __u64 remote_addr; - __u64 compare_add; - __u64 swap; - __u32 rkey; - __u32 reserved; - } atomic; - struct { - __u64 remote_addr; - __u32 log_arg_sz; - __u32 rkey; - union { - struct pvrdma_ex_cmp_swap cmp_swap; - struct pvrdma_ex_fetch_add fetch_add; - } wr_data; - } masked_atomics; - struct { - __u64 iova_start; - __u64 pl_pdir_dma; - __u32 page_shift; - __u32 page_list_len; - __u32 length; - __u32 access_flags; - __u32 rkey; - } fast_reg; - struct { - __u32 remote_qpn; - __u32 remote_qkey; - struct pvrdma_av av; - } ud; - } wr; -}; -/* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */ - -/* Completion queue element. */ -struct pvrdma_cqe { - __u64 wr_id; - __u64 qp; - __u32 opcode; - __u32 status; - __u32 byte_len; - __be32 imm_data; - __u32 src_qp; - __u32 wc_flags; - __u32 vendor_err; - __u16 pkey_index; - __u16 slid; - __u8 sl; - __u8 dlid_path_bits; - __u8 port_num; - __u8 smac[6]; - __u8 reserved2[7]; /* Pad to next power of 2 (64). */ -}; - -#endif /* __VMW_PVRDMA_ABI_H__ */ diff --git a/usr/rdma-core/buildlib/fixup-include/stdatomic.h b/usr/rdma-core/buildlib/fixup-include/stdatomic.h deleted file mode 100644 index 6af810f7f..000000000 --- a/usr/rdma-core/buildlib/fixup-include/stdatomic.h +++ /dev/null @@ -1,369 +0,0 @@ -/* - * An implementation of C11 stdatomic.h directly borrowed from FreeBSD - * (original copyright follows), with minor modifications for - * portability to other systems. Works for recent Clang (that - * implement the feature c_atomic) and GCC 4.7+; includes - * compatibility for GCC below 4.7 but I wouldn't recommend it. - * - * Caveats and limitations: - * - Only the ``_Atomic parentheses'' notation is implemented, while - * the ``_Atomic space'' one is not. - * - _Atomic types must be typedef'ed, or programs using them will - * not type check correctly (incompatible anonymous structure - * types). - * - Non-scalar _Atomic types would require runtime support for - * runtime locking, which, as far as I know, is not currently - * available on any system. - */ - -/*- - * Copyright (c) 2011 Ed Schouten - * David Chisnall - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/include/stdatomic.h,v 1.10.2.2 2012/05/30 19:21:54 theraven Exp $ - */ - -#ifndef _STDATOMIC_H_ -#define _STDATOMIC_H_ - -#include -#include - -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if !defined(__has_builtin) -#define __has_builtin(x) 0 -#endif -#if !defined(__GNUC_PREREQ__) -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -#define __GNUC_PREREQ__(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -#else -#define __GNUC_PREREQ__(maj, min) 0 -#endif -#endif - -#if !defined(__CLANG_ATOMICS) && !defined(__GNUC_ATOMICS) -#if __has_feature(c_atomic) -#define __CLANG_ATOMICS -#elif __GNUC_PREREQ__(4, 7) -#define __GNUC_ATOMICS -#elif !defined(__GNUC__) -#error "stdatomic.h does not support your compiler" -#endif -#endif - -#if !defined(__CLANG_ATOMICS) -#define _Atomic(T) struct { volatile __typeof__(T) __val; } -#endif - -/* - * 7.17.2 Initialization. - */ - -#if defined(__CLANG_ATOMICS) -#define ATOMIC_VAR_INIT(value) (value) -#define atomic_init(obj, value) __c11_atomic_init(obj, value) -#else -#define ATOMIC_VAR_INIT(value) { .__val = (value) } -#define atomic_init(obj, value) do { \ - (obj)->__val = (value); \ -} while (0) -#endif - -/* - * Clang and recent GCC both provide predefined macros for the memory - * orderings. If we are using a compiler that doesn't define them, use the - * clang values - these will be ignored in the fallback path. - */ - -#ifndef __ATOMIC_RELAXED -#define __ATOMIC_RELAXED 0 -#endif -#ifndef __ATOMIC_CONSUME -#define __ATOMIC_CONSUME 1 -#endif -#ifndef __ATOMIC_ACQUIRE -#define __ATOMIC_ACQUIRE 2 -#endif -#ifndef __ATOMIC_RELEASE -#define __ATOMIC_RELEASE 3 -#endif -#ifndef __ATOMIC_ACQ_REL -#define __ATOMIC_ACQ_REL 4 -#endif -#ifndef __ATOMIC_SEQ_CST -#define __ATOMIC_SEQ_CST 5 -#endif - -/* - * 7.17.3 Order and consistency. - * - * The memory_order_* constants that denote the barrier behaviour of the - * atomic operations. - */ - -enum memory_order { - memory_order_relaxed = __ATOMIC_RELAXED, - memory_order_consume = __ATOMIC_CONSUME, - memory_order_acquire = __ATOMIC_ACQUIRE, - memory_order_release = __ATOMIC_RELEASE, - memory_order_acq_rel = __ATOMIC_ACQ_REL, - memory_order_seq_cst = __ATOMIC_SEQ_CST -}; - -typedef enum memory_order memory_order; - -/* - * 7.17.4 Fences. - */ - -#ifdef __CLANG_ATOMICS -#define atomic_thread_fence(order) __c11_atomic_thread_fence(order) -#define atomic_signal_fence(order) __c11_atomic_signal_fence(order) -#elif defined(__GNUC_ATOMICS) -#define atomic_thread_fence(order) __atomic_thread_fence(order) -#define atomic_signal_fence(order) __atomic_signal_fence(order) -#else -#define atomic_thread_fence(order) __sync_synchronize() -#define atomic_signal_fence(order) __asm volatile ("" : : : "memory") -#endif - -/* - * 7.17.5 Lock-free property. - */ - -#if defined(__CLANG_ATOMICS) -#define atomic_is_lock_free(obj) \ - __c11_atomic_is_lock_free(sizeof(obj)) -#elif defined(__GNUC_ATOMICS) -#define atomic_is_lock_free(obj) \ - __atomic_is_lock_free(sizeof((obj)->__val)) -#else -#define atomic_is_lock_free(obj) \ - (sizeof((obj)->__val) <= sizeof(void *)) -#endif - -/* - * 7.17.6 Atomic integer types. - */ - -typedef _Atomic(_Bool) atomic_bool; -typedef _Atomic(char) atomic_char; -typedef _Atomic(signed char) atomic_schar; -typedef _Atomic(unsigned char) atomic_uchar; -typedef _Atomic(short) atomic_short; -typedef _Atomic(unsigned short) atomic_ushort; -typedef _Atomic(int) atomic_int; -typedef _Atomic(unsigned int) atomic_uint; -typedef _Atomic(long) atomic_long; -typedef _Atomic(unsigned long) atomic_ulong; -typedef _Atomic(long long) atomic_llong; -typedef _Atomic(unsigned long long) atomic_ullong; -#if 0 -typedef _Atomic(char16_t) atomic_char16_t; -typedef _Atomic(char32_t) atomic_char32_t; -#endif -typedef _Atomic(wchar_t) atomic_wchar_t; -typedef _Atomic(int_least8_t) atomic_int_least8_t; -typedef _Atomic(uint_least8_t) atomic_uint_least8_t; -typedef _Atomic(int_least16_t) atomic_int_least16_t; -typedef _Atomic(uint_least16_t) atomic_uint_least16_t; -typedef _Atomic(int_least32_t) atomic_int_least32_t; -typedef _Atomic(uint_least32_t) atomic_uint_least32_t; -typedef _Atomic(int_least64_t) atomic_int_least64_t; -typedef _Atomic(uint_least64_t) atomic_uint_least64_t; -typedef _Atomic(int_fast8_t) atomic_int_fast8_t; -typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t; -typedef _Atomic(int_fast16_t) atomic_int_fast16_t; -typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t; -typedef _Atomic(int_fast32_t) atomic_int_fast32_t; -typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t; -typedef _Atomic(int_fast64_t) atomic_int_fast64_t; -typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t; -typedef _Atomic(intptr_t) atomic_intptr_t; -typedef _Atomic(uintptr_t) atomic_uintptr_t; -typedef _Atomic(size_t) atomic_size_t; -typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t; -typedef _Atomic(intmax_t) atomic_intmax_t; -typedef _Atomic(uintmax_t) atomic_uintmax_t; - -/* - * 7.17.7 Operations on atomic types. - */ - -/* - * Compiler-specific operations. - */ - -#if defined(__CLANG_ATOMICS) -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) \ - __c11_atomic_compare_exchange_strong(object, expected, desired, \ - success, failure) -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - __c11_atomic_compare_exchange_weak(object, expected, desired, \ - success, failure) -#define atomic_exchange_explicit(object, desired, order) \ - __c11_atomic_exchange(object, desired, order) -#define atomic_fetch_add_explicit(object, operand, order) \ - __c11_atomic_fetch_add(object, operand, order) -#define atomic_fetch_and_explicit(object, operand, order) \ - __c11_atomic_fetch_and(object, operand, order) -#define atomic_fetch_or_explicit(object, operand, order) \ - __c11_atomic_fetch_or(object, operand, order) -#define atomic_fetch_sub_explicit(object, operand, order) \ - __c11_atomic_fetch_sub(object, operand, order) -#define atomic_fetch_xor_explicit(object, operand, order) \ - __c11_atomic_fetch_xor(object, operand, order) -#define atomic_load_explicit(object, order) \ - __c11_atomic_load(object, order) -#define atomic_store_explicit(object, desired, order) \ - __c11_atomic_store(object, desired, order) -#elif defined(__GNUC_ATOMICS) -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) \ - __atomic_compare_exchange_n(&(object)->__val, expected, \ - desired, 0, success, failure) -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - __atomic_compare_exchange_n(&(object)->__val, expected, \ - desired, 1, success, failure) -#define atomic_exchange_explicit(object, desired, order) \ - __atomic_exchange_n(&(object)->__val, desired, order) -#define atomic_fetch_add_explicit(object, operand, order) \ - __atomic_fetch_add(&(object)->__val, operand, order) -#define atomic_fetch_and_explicit(object, operand, order) \ - __atomic_fetch_and(&(object)->__val, operand, order) -#define atomic_fetch_or_explicit(object, operand, order) \ - __atomic_fetch_or(&(object)->__val, operand, order) -#define atomic_fetch_sub_explicit(object, operand, order) \ - __atomic_fetch_sub(&(object)->__val, operand, order) -#define atomic_fetch_xor_explicit(object, operand, order) \ - __atomic_fetch_xor(&(object)->__val, operand, order) -#define atomic_load_explicit(object, order) \ - __atomic_load_n(&(object)->__val, order) -#define atomic_store_explicit(object, desired, order) \ - __atomic_store_n(&(object)->__val, desired, order) -#else -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) ({ \ - __typeof__((object)->__val) __v; \ - _Bool __r; \ - __v = __sync_val_compare_and_swap(&(object)->__val, \ - *(expected), desired); \ - __r = *(expected) == __v; \ - *(expected) = __v; \ - __r; \ -}) - -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) -#if __has_builtin(__sync_swap) -/* Clang provides a full-barrier atomic exchange - use it if available. */ -#define atomic_exchange_explicit(object, desired, order) \ - __sync_swap(&(object)->__val, desired) -#else -/* - * __sync_lock_test_and_set() is only an acquire barrier in theory (although in - * practice it is usually a full barrier) so we need an explicit barrier after - * it. - */ -#define atomic_exchange_explicit(object, desired, order) ({ \ - __typeof__((object)->__val) __v; \ - __v = __sync_lock_test_and_set(&(object)->__val, desired); \ - __sync_synchronize(); \ - __v; \ -}) -#endif -#define atomic_fetch_add_explicit(object, operand, order) \ - __sync_fetch_and_add(&(object)->__val, operand) -#define atomic_fetch_and_explicit(object, operand, order) \ - __sync_fetch_and_and(&(object)->__val, operand) -#define atomic_fetch_or_explicit(object, operand, order) \ - __sync_fetch_and_or(&(object)->__val, operand) -#define atomic_fetch_sub_explicit(object, operand, order) \ - __sync_fetch_and_sub(&(object)->__val, operand) -#define atomic_fetch_xor_explicit(object, operand, order) \ - __sync_fetch_and_xor(&(object)->__val, operand) -#define atomic_load_explicit(object, order) \ - __sync_fetch_and_add(&(object)->__val, 0) -#define atomic_store_explicit(object, desired, order) do { \ - __sync_synchronize(); \ - (object)->__val = (desired); \ - __sync_synchronize(); \ -} while (0) -#endif - -/* - * Convenience functions. - */ - -#define atomic_compare_exchange_strong(object, expected, desired) \ - atomic_compare_exchange_strong_explicit(object, expected, \ - desired, memory_order_seq_cst, memory_order_seq_cst) -#define atomic_compare_exchange_weak(object, expected, desired) \ - atomic_compare_exchange_weak_explicit(object, expected, \ - desired, memory_order_seq_cst, memory_order_seq_cst) -#define atomic_exchange(object, desired) \ - atomic_exchange_explicit(object, desired, memory_order_seq_cst) -#define atomic_fetch_add(object, operand) \ - atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_and(object, operand) \ - atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_or(object, operand) \ - atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_sub(object, operand) \ - atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_xor(object, operand) \ - atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) -#define atomic_load(object) \ - atomic_load_explicit(object, memory_order_seq_cst) -#define atomic_store(object, desired) \ - atomic_store_explicit(object, desired, memory_order_seq_cst) - -/* - * 7.17.8 Atomic flag type and operations. - */ - -typedef atomic_bool atomic_flag; - -#define ATOMIC_FLAG_INIT ATOMIC_VAR_INIT(0) - -#define atomic_flag_clear_explicit(object, order) \ - atomic_store_explicit(object, 0, order) -#define atomic_flag_test_and_set_explicit(object, order) \ - atomic_compare_exchange_strong_explicit(object, 0, 1, order, order) - -#define atomic_flag_clear(object) \ - atomic_flag_clear_explicit(object, memory_order_seq_cst) -#define atomic_flag_test_and_set(object) \ - atomic_flag_test_and_set_explicit(object, memory_order_seq_cst) - -#endif /* !_STDATOMIC_H_ */ diff --git a/usr/rdma-core/buildlib/fixup-include/systemd-sd-daemon.h b/usr/rdma-core/buildlib/fixup-include/systemd-sd-daemon.h deleted file mode 100644 index 29cb70c51..000000000 --- a/usr/rdma-core/buildlib/fixup-include/systemd-sd-daemon.h +++ /dev/null @@ -1,16 +0,0 @@ -#define SD_LISTEN_FDS_START 3 - -static inline int sd_listen_fds(int unset_environment) -{ - return 0; -} - -static inline int sd_is_socket(int fd, int family, int type, int listening) -{ - return 0; -} - -static inline int sd_notify(int unset_environment, const char *state) -{ - return 0; -} diff --git a/usr/rdma-core/buildlib/fixup-include/valgrind-drd.h b/usr/rdma-core/buildlib/fixup-include/valgrind-drd.h deleted file mode 100644 index 9e491fc68..000000000 --- a/usr/rdma-core/buildlib/fixup-include/valgrind-drd.h +++ /dev/null @@ -1,3 +0,0 @@ -static inline void ANNOTATE_BENIGN_RACE_SIZED(const void *mem,size_t len,const char *desc) {} -#define ANNOTATE_BENIGN_RACE_SIZED ANNOTATE_BENIGN_RACE_SIZED - diff --git a/usr/rdma-core/buildlib/fixup-include/valgrind-memcheck.h b/usr/rdma-core/buildlib/fixup-include/valgrind-memcheck.h deleted file mode 100644 index 6457a5a0f..000000000 --- a/usr/rdma-core/buildlib/fixup-include/valgrind-memcheck.h +++ /dev/null @@ -1,5 +0,0 @@ -static inline void VALGRIND_MAKE_MEM_DEFINED(const void *mem,size_t len) {} -#define VALGRIND_MAKE_MEM_DEFINED VALGRIND_MAKE_MEM_DEFINED - -static inline void VALGRIND_MAKE_MEM_UNDEFINED(const void *mem,size_t len) {} -#define VALGRIND_MAKE_MEM_UNDEFINED VALGRIND_MAKE_MEM_UNDEFINED diff --git a/usr/rdma-core/buildlib/gen-sparse.py b/usr/rdma-core/buildlib/gen-sparse.py deleted file mode 100755 index c289da31c..000000000 --- a/usr/rdma-core/buildlib/gen-sparse.py +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env python -# Copyright 2015-2017 Obsidian Research Corp. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. -import argparse -import subprocess -import os -import collections - -headers = { - "endian.h", - "netinet/in.h", - "pthread.h", - "sys/socket.h", - "stdatomic.h", - }; - -def norm_header(fn): - for I in headers: - flat = I.replace("/","-"); - if fn.endswith(flat): - return I; - if fn.endswith(flat + ".diff"): - return I; - return None; - -def get_buildlib_patches(dfn): - """Within the buildlib directory we store patches for the glibc headers. Each - patch is in a numbered sub directory that indicates the order to try, the - number should match the glibc version used to make the diff.""" - res = []; - for d,_,files in os.walk(dfn): - for I in files: - if d != dfn: - bn = int(os.path.basename(d)); - else: - bn = 0; - - res.append((bn,os.path.join(d,I))); - res.sort(reverse=True); - - ret = collections.defaultdict(list); - for _,I in res: - ret[norm_header(I)].append(I); - return ret; - -def is_patch(fn): - with open(fn) as F: - return F.read(10).startswith("-- /"); - -def apply_patch(src,patch,dest): - """Patch a single system header. The output goes into our include search path - and takes precedence over the system version.""" - dfn = os.path.dirname(dest); - if not os.path.isdir(dfn): - os.makedirs(dfn); - - if not patch.endswith(".diff"): - if not os.path.exists(dest): - os.symlink(patch,dest); - return True; - - try: - if os.path.exists(dest + ".rej"): - os.unlink(dest + ".rej"); - - subprocess.check_output(["patch","-f","--follow-symlinks","-V","never","-i",patch,"-o",dest,src]); - - if os.path.exists(dest + ".rej"): - print "Patch from %r failed"%(patch); - return False; - except subprocess.CalledProcessError: - print "Patch from %r failed"%(patch); - return False; - return True; - -def replace_header(fn): - tries = 0; - for pfn in patches[fn]: - if apply_patch(os.path.join(args.REF,fn), - pfn,os.path.join(args.INCLUDE,fn)): - return; - tries = tries + 1; - - print "Unable to apply any patch to %r, tries %u"%(fn,tries); - global failed; - failed = True; - -def save(fn,outdir): - """Diff the header file in our include directory against the system header and - store the diff into buildlib. This makes it fairly easy to maintain the - replacement headers.""" - if os.path.islink(os.path.join(args.INCLUDE,fn)): - return; - - flatfn = fn.replace("/","-") + ".diff"; - flatfn = os.path.join(outdir,flatfn); - - with open(flatfn,"wt") as F: - try: - subprocess.check_call(["diff","-u", - os.path.join(args.REF,fn), - os.path.join(args.INCLUDE,fn)], - stdout=F); - except subprocess.CalledProcessError as ex: - if ex.returncode == 1: - return; - raise; - -parser = argparse.ArgumentParser(description='Produce sparse shim header files') -parser.add_argument("--out",dest="INCLUDE",required=True, - help="Directory to write header files to"); -parser.add_argument("--src",dest="SRC",required=True, - help="Top of the source tree"); -parser.add_argument("--ref",dest="REF",default="/usr/include/", - help="System headers to manipulate"); -parser.add_argument("--save",action="store_true",default=False, - help="Save mode will write the current content of the headers to buildlib as a diff."); -args = parser.parse_args(); - -if args.save: - # Get the glibc version string - ver = subprocess.check_output(["ldd","--version"]).splitlines()[0].split(' ')[-1]; - ver = ver.partition(".")[-1]; - outdir = os.path.join(args.SRC,"buildlib","sparse-include",ver); - if not os.path.isdir(outdir): - os.makedirs(outdir); - - for I in headers: - save(I,outdir); -else: - failed = False; - patches = get_buildlib_patches(os.path.join(args.SRC,"buildlib","sparse-include")); - for I in headers: - replace_header(I); - - if failed: - raise ValueError("Patch applications failed"); diff --git a/usr/rdma-core/buildlib/github-release b/usr/rdma-core/buildlib/github-release deleted file mode 100755 index 9740b51d6..000000000 --- a/usr/rdma-core/buildlib/github-release +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -e - -if [[ $TRAVIS_TAG == v* ]] && [ "$TRAVIS_OS_NAME" = "linux" ]; then - # Let's create release for vX tags only. - # Strip the v from the TRAVIS_TAG for our prefix and output items - REL_TAG=`echo $TRAVIS_TAG | sed -e 's/^v//'` - git archive --prefix rdma-core-$REL_TAG/ --output rdma-core-$REL_TAG.tar.gz $TRAVIS_TAG -fi diff --git a/usr/rdma-core/buildlib/provider.map b/usr/rdma-core/buildlib/provider.map deleted file mode 100644 index e985a6fe9..000000000 --- a/usr/rdma-core/buildlib/provider.map +++ /dev/null @@ -1,6 +0,0 @@ -/* The providers do not export any symbols at all. Instead they rely on - attribute(constructor) to cause their init function to run at dlopen - time. */ -{ - local: *; -}; diff --git a/usr/rdma-core/buildlib/publish_headers.cmake b/usr/rdma-core/buildlib/publish_headers.cmake deleted file mode 100644 index 0f1e9427e..000000000 --- a/usr/rdma-core/buildlib/publish_headers.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# COPYRIGHT (c) 2016 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -# Same as publish_headers but does not install them during the install phase -function(publish_internal_headers DEST) - if(NOT ARGN) - message(SEND_ERROR "Error: publish_internal_headers called without any files") - return() - endif() - - set(DDIR "${BUILD_INCLUDE}/${DEST}") - #message(STATUS "BUILD_INCLUDE: ${BUILD_INCLUDE}") - file(MAKE_DIRECTORY "${DDIR}") - - foreach(SFIL ${ARGN}) - get_filename_component(FIL ${SFIL} NAME) - rdma_create_symlink("${CMAKE_CURRENT_SOURCE_DIR}/${SFIL}" "${DDIR}/${FIL}") - endforeach() -endfunction() - -# Copy headers from the source directory to the proper place in the -# build/include directory. This also installs them into /usr/include/xx during -# the install phase -function(publish_headers DEST) - publish_internal_headers("${DEST}" ${ARGN}) - - foreach(SFIL ${ARGN}) - get_filename_component(FIL ${SFIL} NAME) - install(FILES "${SFIL}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DEST}/" RENAME "${FIL}") - endforeach() -endfunction() diff --git a/usr/rdma-core/buildlib/rdma_functions.cmake b/usr/rdma-core/buildlib/rdma_functions.cmake deleted file mode 100644 index d69afd3de..000000000 --- a/usr/rdma-core/buildlib/rdma_functions.cmake +++ /dev/null @@ -1,296 +0,0 @@ -# COPYRIGHT (c) 2016 Obsidian Research Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -# Helper functions for use in the sub CMakeLists files to make them simpler -# and more uniform. - -# Global list of pairs of (SHARED STATIC) libary target names -set(RDMA_STATIC_LIBS "" CACHE INTERNAL "Doc" FORCE) - -set(COMMON_LIBS_PIC ccan_pic rdma_util_pic) -set(COMMON_LIBS ccan rdma_util) - -# Create a symlink at filename DEST -# If the directory containing DEST does not exist then it is created -# automatically. -function(rdma_create_symlink LINK_CONTENT DEST) - if(NOT LINK_CONTENT) - message(FATAL_ERROR "Failed to provide LINK_CONTENT") - endif() - - # Make sure the directory exists, cmake doesn't create target DESTINATION - # directories until everything is finished, do it manually here if necessary - if(CMAKE_VERSION VERSION_LESS "2.8.12") - get_filename_component(DDIR "${DEST}" PATH) - else() - get_filename_component(DDIR "${DEST}" DIRECTORY) - endif() - - IF(NOT EXISTS "${DDIR}/") - execute_process(COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" - "${BUILD_LIB}" RESULT_VARIABLE retcode) - if(NOT "${retcode}" STREQUAL "0") - message(FATAL_ERROR "Failed to create directory ${DDIR}") - endif() - endif() - - # Newer versions of cmake can use "${CMAKE_COMMAND}" "-E" "create_symlink" - # however it is broken weirdly on older versions. - execute_process(COMMAND "ln" "-Tsf" - "${LINK_CONTENT}" "${DEST}" RESULT_VARIABLE retcode) - if(NOT "${retcode}" STREQUAL "0") - message(FATAL_ERROR "Failed to create symlink in ${DEST}") - endif() -endfunction() - -# Install a symlink during 'make install' -function(rdma_install_symlink LINK_CONTENT DEST) - # Create a link in the build tree with the right content - get_filename_component(FN "${DEST}" NAME) - rdma_create_symlink("${LINK_CONTENT}" "${CMAKE_CURRENT_BINARY_DIR}/${FN}") - - # Have cmake install it. Doing it this way lets cpack work if we ever wish - # to use that. - get_filename_component(DIR "${DEST}" PATH) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${FN}" - DESTINATION "${DIR}") -endfunction() - -# Wrapper for install() that runs the single file through configure_file first. -# This only works with the basic single file install(FILE file ARGS..) pattern -function(rdma_subst_install ARG1 file) - if (NOT "${ARG1}" STREQUAL "FILES") - message(FATAL_ERROR "Bad use of rdma_subst_install") - endif() - configure_file("${file}" "${CMAKE_CURRENT_BINARY_DIR}/${file}" @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${file}" ${ARGN}) -endfunction() - -# Modify shared library target DEST to use VERSION_SCRIPT as the linker map file -function(rdma_set_library_map DEST VERSION_SCRIPT) - if (NOT IS_ABSOLUTE ${VERSION_SCRIPT}) - set(VERSION_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/${VERSION_SCRIPT}") - endif() - set_property(TARGET ${DEST} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--version-script,${VERSION_SCRIPT}") - - # NOTE: This won't work with ninja prior to cmake 3.4 - set_property(TARGET ${DEST} APPEND_STRING PROPERTY - LINK_DEPENDS ${VERSION_SCRIPT}) -endfunction() - -# Basic function to produce a standard libary with a GNU LD version script. -function(rdma_library DEST VERSION_SCRIPT SOVERSION VERSION) - # Create a static library - if (ENABLE_STATIC) - add_library(${DEST}-static STATIC ${ARGN}) - set_target_properties(${DEST}-static PROPERTIES - OUTPUT_NAME ${DEST} - ARCHIVE_OUTPUT_DIRECTORY "${BUILD_LIB}") - target_compile_definitions(${DEST}-static PRIVATE _STATIC_LIBRARY_BUILD_=1) - install(TARGETS ${DEST}-static DESTINATION "${CMAKE_INSTALL_LIBDIR}") - - list(APPEND RDMA_STATIC_LIBS ${DEST} ${DEST}-static) - set(RDMA_STATIC_LIBS "${RDMA_STATIC_LIBS}" CACHE INTERNAL "") - endif() - - # Create a shared library - add_library(${DEST} SHARED ${ARGN}) - rdma_set_library_map(${DEST} ${VERSION_SCRIPT}) - target_link_libraries(${DEST} LINK_PRIVATE ${COMMON_LIBS_PIC}) - set_target_properties(${DEST} PROPERTIES - SOVERSION ${SOVERSION} - VERSION ${VERSION} - LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") - install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}") -endfunction() - -# Create a special provider with exported symbols in it The shared provider -# exists as a normal system library with the normal shared library SONAME and -# other convections. The system library is symlinked into the -# VERBS_PROVIDER_DIR so it can be dlopened as a provider as well. -function(rdma_shared_provider DEST VERSION_SCRIPT SOVERSION VERSION) - # Installed driver file - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${DEST}.driver" "driver ${DEST}\n") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${DEST}.driver" DESTINATION "${CONFIG_DIR}") - - # Uninstalled driver file - file(MAKE_DIRECTORY "${BUILD_ETC}/libibverbs.d/") - file(WRITE "${BUILD_ETC}/libibverbs.d/${DEST}.driver" "driver ${BUILD_LIB}/lib${DEST}\n") - - # Create a static provider library - if (ENABLE_STATIC) - add_library(${DEST}-static STATIC ${ARGN}) - set_target_properties(${DEST}-static PROPERTIES OUTPUT_NAME ${DEST}) - set_target_properties(${DEST}-static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${BUILD_LIB}") - target_compile_definitions(${DEST}-static PRIVATE _STATIC_LIBRARY_BUILD_=1) - install(TARGETS ${DEST}-static DESTINATION "${CMAKE_INSTALL_LIBDIR}") - - list(APPEND RDMA_STATIC_LIBS ${DEST} ${DEST}-static) - set(RDMA_STATIC_LIBS "${RDMA_STATIC_LIBS}" CACHE INTERNAL "") - endif() - - # Create the plugin shared library - add_library(${DEST} SHARED ${ARGN}) - rdma_set_library_map(${DEST} ${VERSION_SCRIPT}) - - target_link_libraries(${DEST} LINK_PRIVATE ${COMMON_LIBS_PIC}) - target_link_libraries(${DEST} LINK_PRIVATE ibverbs) - target_link_libraries(${DEST} LINK_PRIVATE ${CMAKE_THREAD_LIBS_INIT}) - set_target_properties(${DEST} PROPERTIES - SOVERSION ${SOVERSION} - VERSION ${VERSION} - LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") - install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}") - - # Compute a relative symlink from VERBS_PROVIDER_DIR to LIBDIR - execute_process(COMMAND python ${CMAKE_SOURCE_DIR}/buildlib/relpath - "${CMAKE_INSTALL_FULL_LIBDIR}/lib${DEST}.so.${VERSION}" - "${VERBS_PROVIDER_DIR}" - OUTPUT_VARIABLE DEST_LINK_PATH OUTPUT_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE retcode) - if(NOT "${retcode}" STREQUAL "0") - message(FATAL_ERROR "Unable to run buildlib/relpath, do you have python?") - endif() - - rdma_install_symlink("${DEST_LINK_PATH}" "${VERBS_PROVIDER_DIR}/lib${DEST}${IBVERBS_PROVIDER_SUFFIX}") - rdma_create_symlink("lib${DEST}.so.${VERSION}" "${BUILD_LIB}/lib${DEST}${IBVERBS_PROVIDER_SUFFIX}") -endfunction() - -# Create a provider shared library for libibverbs -function(rdma_provider DEST) - # Installed driver file - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${DEST}.driver" "driver ${DEST}\n") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${DEST}.driver" DESTINATION "${CONFIG_DIR}") - - # Uninstalled driver file - file(MAKE_DIRECTORY "${BUILD_ETC}/libibverbs.d/") - file(WRITE "${BUILD_ETC}/libibverbs.d/${DEST}.driver" "driver ${BUILD_LIB}/lib${DEST}\n") - - # Create a static provider library - # FIXME: This is probably pointless, the provider library has no symbols so - # what good is it? Presumably it should be used with -Wl,--whole-archive, - # but we don't have any directions on how to make static linking work.. - if (ENABLE_STATIC) - add_library(${DEST} STATIC ${ARGN}) - set_target_properties(${DEST} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${BUILD_LIB}") - target_compile_definitions(${DEST} PRIVATE _STATIC_LIBRARY_BUILD_=1) - install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}") - - list(APPEND RDMA_STATIC_LIBS "${DEST}-rdmav${IBVERBS_PABI_VERSION}" ${DEST}) - set(RDMA_STATIC_LIBS "${RDMA_STATIC_LIBS}" CACHE INTERNAL "") - endif() - - # Create the plugin shared library - set(DEST "${DEST}-rdmav${IBVERBS_PABI_VERSION}") - add_library(${DEST} MODULE ${ARGN}) - # Even though these are modules we still want to use Wl,--no-undefined - set_target_properties(${DEST} PROPERTIES LINK_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) - rdma_set_library_map(${DEST} ${BUILDLIB}/provider.map) - target_link_libraries(${DEST} LINK_PRIVATE ${COMMON_LIBS_PIC}) - target_link_libraries(${DEST} LINK_PRIVATE ibverbs) - target_link_libraries(${DEST} LINK_PRIVATE ${CMAKE_THREAD_LIBS_INIT}) - set_target_properties(${DEST} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") - # Provider Plugins do not use SONAME versioning, there is no reason to - # create the usual symlinks. - - if (VERBS_PROVIDER_DIR) - install(TARGETS ${DEST} DESTINATION "${VERBS_PROVIDER_DIR}") - else() - install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}") - - # FIXME: This symlink is provided for compat with the old build, but it - # never should have existed in the first place, nothing should use this - # name, we can probably remove it. - rdma_install_symlink("lib${DEST}${IBVERBS_PROVIDER_SUFFIX}" "${CMAKE_INSTALL_LIBDIR}/lib${DEST}.so") - endif() -endfunction() - - # Create an installed executable -function(rdma_executable EXEC) - add_executable(${EXEC} ${ARGN}) - target_link_libraries(${EXEC} LINK_PRIVATE ${COMMON_LIBS}) - set_target_properties(${EXEC} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_BIN}") - install(TARGETS ${EXEC} DESTINATION "${CMAKE_INSTALL_BINDIR}") -endfunction() - - # Create an installed executable (under sbin) -function(rdma_sbin_executable EXEC) - add_executable(${EXEC} ${ARGN}) - target_link_libraries(${EXEC} LINK_PRIVATE ${COMMON_LIBS}) - set_target_properties(${EXEC} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_BIN}") - install(TARGETS ${EXEC} DESTINATION "${CMAKE_INSTALL_SBINDIR}") -endfunction() - -# Create an test executable (not-installed) -function(rdma_test_executable EXEC) - add_executable(${EXEC} ${ARGN}) - target_link_libraries(${EXEC} LINK_PRIVATE ${COMMON_LIBS}) - set_target_properties(${EXEC} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_BIN}") -endfunction() - -# Install man pages. This deduces the section from the trailing integer in the -# filename -function(rdma_man_pages) - foreach(I ${ARGN}) - if ("${I}" MATCHES "\\.in$") - string(REGEX REPLACE "^.+[.](.+)\\.in$" "\\1" MAN_SECT "${I}") - string(REGEX REPLACE "^(.+)\\.in$" "\\1" BASE_NAME "${I}") - get_filename_component(BASE_NAME "${BASE_NAME}" NAME) - rdma_subst_install(FILES "${I}" - DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/" - RENAME "${BASE_NAME}") - else() - string(REGEX REPLACE "^.+[.](.+)$" "\\1" MAN_SECT "${I}") - install(FILES "${I}" DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/") - endif() - endforeach() -endfunction() - -# Create an alias for a man page, using a symlink. -# Input is a list of pairs of names (MAN_PAGE ALIAS) -# NOTE: The section must currently be the same for both. -function(rdma_alias_man_pages) - list(LENGTH ARGN LEN) - math(EXPR LEN ${LEN}-1) - foreach(I RANGE 0 ${LEN} 2) - list(GET ARGN ${I} FROM) - math(EXPR I ${I}+1) - list(GET ARGN ${I} TO) - string(REGEX REPLACE "^.+[.](.+)$" "\\1" MAN_SECT ${FROM}) - rdma_install_symlink("${FROM}" "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/${TO}") - endforeach() -endfunction() - -# Finalize the setup of the static libraries by copying the meta information -# from the shared and setting up the libtool .la files. -function(rdma_finalize_libs) - list(LENGTH RDMA_STATIC_LIBS LEN) - if (LEN LESS 2) - return() - endif() - - math(EXPR LEN ${LEN}-1) - foreach(I RANGE 0 ${LEN} 2) - list(GET RDMA_STATIC_LIBS ${I} SHARED) - math(EXPR I ${I}+1) - list(GET RDMA_STATIC_LIBS ${I} STATIC) - - # PUBLIC libraries - set(LIBS "") - get_property(TMP TARGET ${SHARED} PROPERTY INTERFACE_LINK_LIBRARIES SET) - if (TMP) - get_target_property(TMP ${SHARED} INTERFACE_LINK_LIBRARIES) - set_target_properties(${STATIC} PROPERTIES INTERFACE_LINK_LIBRARIES "${TMP}") - set(LIBS "${TMP}") - endif() - - # PRIVATE libraries - get_property(TMP TARGET ${SHARED} PROPERTY LINK_LIBRARIES SET) - if (TMP) - get_target_property(TMP ${SHARED} LINK_LIBRARIES) - set_target_properties(${STATIC} PROPERTIES LINK_LIBRARIES "${TMP}") - list(APPEND LIBS "${TMP}") - endif() - endforeach() -endfunction() diff --git a/usr/rdma-core/buildlib/relpath b/usr/rdma-core/buildlib/relpath deleted file mode 100644 index 965ce37d3..000000000 --- a/usr/rdma-core/buildlib/relpath +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python -# Copyright 2017 Mellanox Technologies, Inc. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -import os -import sys - -print(os.path.relpath(sys.argv[1], sys.argv[2])) diff --git a/usr/rdma-core/buildlib/sparse-include/19/netinet-in.h.diff b/usr/rdma-core/buildlib/sparse-include/19/netinet-in.h.diff deleted file mode 100644 index 6dd764590..000000000 --- a/usr/rdma-core/buildlib/sparse-include/19/netinet-in.h.diff +++ /dev/null @@ -1,121 +0,0 @@ ---- /usr/include/netinet/in.h 2016-05-26 10:27:23.000000000 +0000 -+++ build-sparse/include/netinet/in.h 2017-03-15 21:50:20.436860311 +0000 -@@ -22,12 +22,12 @@ - #include - #include - #include -- -+#include - - __BEGIN_DECLS - - /* Internet address. */ --typedef uint32_t in_addr_t; -+typedef __be32 in_addr_t; - struct in_addr - { - in_addr_t s_addr; -@@ -114,7 +114,7 @@ - #endif /* !__USE_KERNEL_IPV6_DEFS */ - - /* Type to represent a port. */ --typedef uint16_t in_port_t; -+typedef __be16 in_port_t; - - /* Standard well-known ports. */ - enum -@@ -173,36 +173,36 @@ - #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) - #define IN_CLASSB_MAX 65536 - --#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000) -+#define IN_CLASSC(a) ((((uint32_t)(a)) & 0xe0000000) == 0xc0000000) - #define IN_CLASSC_NET 0xffffff00 - #define IN_CLASSC_NSHIFT 8 - #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) - --#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000) -+#define IN_CLASSD(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000) - #define IN_MULTICAST(a) IN_CLASSD(a) - --#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000) --#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000) -+#define IN_EXPERIMENTAL(a) ((((uint32_t)(a)) & 0xe0000000) == 0xe0000000) -+#define IN_BADCLASS(a) ((((uint32_t)(a)) & 0xf0000000) == 0xf0000000) - - /* Address to accept any incoming messages. */ --#define INADDR_ANY ((in_addr_t) 0x00000000) -+#define INADDR_ANY ((uint32_t) 0x00000000) - /* Address to send to all hosts. */ --#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) -+#define INADDR_BROADCAST ((uint32_t) 0xffffffff) - /* Address indicating an error return. */ --#define INADDR_NONE ((in_addr_t) 0xffffffff) -+#define INADDR_NONE ((uint32_t) 0xffffffff) - - /* Network number for local host loopback. */ - #define IN_LOOPBACKNET 127 - /* Address to loopback in software to local host. */ - #ifndef INADDR_LOOPBACK --# define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* Inet 127.0.0.1. */ -+# define INADDR_LOOPBACK ((uint32_t) 0x7f000001) /* Inet 127.0.0.1. */ - #endif - - /* Defines for Multicast INADDR. */ --#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */ --#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */ --#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */ --#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */ -+#define INADDR_UNSPEC_GROUP ((uint32_t) 0xe0000000) /* 224.0.0.0 */ -+#define INADDR_ALLHOSTS_GROUP ((uint32_t) 0xe0000001) /* 224.0.0.1 */ -+#define INADDR_ALLRTRS_GROUP ((uint32_t) 0xe0000002) /* 224.0.0.2 */ -+#define INADDR_MAX_LOCAL_GROUP ((uint32_t) 0xe00000ff) /* 224.0.0.255 */ - - #ifndef __USE_KERNEL_IPV6_DEFS - /* IPv6 address */ -@@ -212,8 +212,8 @@ - { - uint8_t __u6_addr8[16]; - #if defined __USE_MISC || defined __USE_GNU -- uint16_t __u6_addr16[8]; -- uint32_t __u6_addr32[4]; -+ __be16 __u6_addr16[8]; -+ __be32 __u6_addr32[4]; - #endif - } __in6_u; - #define s6_addr __in6_u.__u6_addr8 -@@ -253,7 +253,7 @@ - { - __SOCKADDR_COMMON (sin6_); - in_port_t sin6_port; /* Transport layer port # */ -- uint32_t sin6_flowinfo; /* IPv6 flow information */ -+ __be32 sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - uint32_t sin6_scope_id; /* IPv6 scope-id */ - }; -@@ -371,12 +371,12 @@ - this was a short-sighted decision since on different systems the types - may have different representations but the values are always the same. */ - --extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__)); --extern uint16_t ntohs (uint16_t __netshort) -+extern uint32_t ntohl (__be32 __netlong) __THROW __attribute__ ((__const__)); -+extern uint16_t ntohs (__be16 __netshort) - __THROW __attribute__ ((__const__)); --extern uint32_t htonl (uint32_t __hostlong) -+extern __be32 htonl (uint32_t __hostlong) - __THROW __attribute__ ((__const__)); --extern uint16_t htons (uint16_t __hostshort) -+extern __be16 htons (uint16_t __hostshort) - __THROW __attribute__ ((__const__)); - - #include -@@ -384,7 +384,7 @@ - /* Get machine dependent optimized versions of byte swapping functions. */ - #include - --#ifdef __OPTIMIZE__ -+#ifdef __disabled_OPTIMIZE__ - /* We can optimize calls to the conversion functions. Either nothing has - to be done or we are using directly the byte-swapping functions which - often can be inlined. */ diff --git a/usr/rdma-core/buildlib/sparse-include/23/netinet-in.h.diff b/usr/rdma-core/buildlib/sparse-include/23/netinet-in.h.diff deleted file mode 100644 index 6156a960a..000000000 --- a/usr/rdma-core/buildlib/sparse-include/23/netinet-in.h.diff +++ /dev/null @@ -1,121 +0,0 @@ ---- /usr/include/netinet/in.h 2016-11-16 15:44:03.000000000 -0700 -+++ build-sparse/include/netinet/in.h 2017-03-15 13:55:43.865288477 -0600 -@@ -22,12 +22,12 @@ - #include - #include - #include -- -+#include - - __BEGIN_DECLS - - /* Internet address. */ --typedef uint32_t in_addr_t; -+typedef __be32 in_addr_t; - struct in_addr - { - in_addr_t s_addr; -@@ -116,7 +116,7 @@ - #endif /* !__USE_KERNEL_IPV6_DEFS */ - - /* Type to represent a port. */ --typedef uint16_t in_port_t; -+typedef __be16 in_port_t; - - /* Standard well-known ports. */ - enum -@@ -175,36 +175,36 @@ - #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) - #define IN_CLASSB_MAX 65536 - --#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000) -+#define IN_CLASSC(a) ((((uint32_t)(a)) & 0xe0000000) == 0xc0000000) - #define IN_CLASSC_NET 0xffffff00 - #define IN_CLASSC_NSHIFT 8 - #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) - --#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000) -+#define IN_CLASSD(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000) - #define IN_MULTICAST(a) IN_CLASSD(a) - --#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000) --#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000) -+#define IN_EXPERIMENTAL(a) ((((uint32_t)(a)) & 0xe0000000) == 0xe0000000) -+#define IN_BADCLASS(a) ((((uint32_t)(a)) & 0xf0000000) == 0xf0000000) - - /* Address to accept any incoming messages. */ --#define INADDR_ANY ((in_addr_t) 0x00000000) -+#define INADDR_ANY ((uint32_t) 0x00000000) - /* Address to send to all hosts. */ --#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) -+#define INADDR_BROADCAST ((uint32_t) 0xffffffff) - /* Address indicating an error return. */ --#define INADDR_NONE ((in_addr_t) 0xffffffff) -+#define INADDR_NONE ((uint32_t) 0xffffffff) - - /* Network number for local host loopback. */ - #define IN_LOOPBACKNET 127 - /* Address to loopback in software to local host. */ - #ifndef INADDR_LOOPBACK --# define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* Inet 127.0.0.1. */ -+# define INADDR_LOOPBACK ((uint32_t) 0x7f000001) /* Inet 127.0.0.1. */ - #endif - - /* Defines for Multicast INADDR. */ --#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */ --#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */ --#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */ --#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */ -+#define INADDR_UNSPEC_GROUP ((uint32_t) 0xe0000000) /* 224.0.0.0 */ -+#define INADDR_ALLHOSTS_GROUP ((uint32_t) 0xe0000001) /* 224.0.0.1 */ -+#define INADDR_ALLRTRS_GROUP ((uint32_t) 0xe0000002) /* 224.0.0.2 */ -+#define INADDR_MAX_LOCAL_GROUP ((uint32_t) 0xe00000ff) /* 224.0.0.255 */ - - #ifndef __USE_KERNEL_IPV6_DEFS - /* IPv6 address */ -@@ -214,8 +214,8 @@ - { - uint8_t __u6_addr8[16]; - #ifdef __USE_MISC -- uint16_t __u6_addr16[8]; -- uint32_t __u6_addr32[4]; -+ __be16 __u6_addr16[8]; -+ __be32 __u6_addr32[4]; - #endif - } __in6_u; - #define s6_addr __in6_u.__u6_addr8 -@@ -255,7 +255,7 @@ - { - __SOCKADDR_COMMON (sin6_); - in_port_t sin6_port; /* Transport layer port # */ -- uint32_t sin6_flowinfo; /* IPv6 flow information */ -+ __be32 sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - uint32_t sin6_scope_id; /* IPv6 scope-id */ - }; -@@ -373,12 +373,12 @@ - this was a short-sighted decision since on different systems the types - may have different representations but the values are always the same. */ - --extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__)); --extern uint16_t ntohs (uint16_t __netshort) -+extern uint32_t ntohl (__be32 __netlong) __THROW __attribute__ ((__const__)); -+extern uint16_t ntohs (__be16 __netshort) - __THROW __attribute__ ((__const__)); --extern uint32_t htonl (uint32_t __hostlong) -+extern __be32 htonl (uint32_t __hostlong) - __THROW __attribute__ ((__const__)); --extern uint16_t htons (uint16_t __hostshort) -+extern __be16 htons (uint16_t __hostshort) - __THROW __attribute__ ((__const__)); - - #include -@@ -386,7 +386,7 @@ - /* Get machine dependent optimized versions of byte swapping functions. */ - #include - --#ifdef __OPTIMIZE__ -+#ifdef __disabled_OPTIMIZE__ - /* We can optimize calls to the conversion functions. Either nothing has - to be done or we are using directly the byte-swapping functions which - often can be inlined. */ diff --git a/usr/rdma-core/buildlib/sparse-include/23/sys-socket.h.diff b/usr/rdma-core/buildlib/sparse-include/23/sys-socket.h.diff deleted file mode 100644 index 09cbea58e..000000000 --- a/usr/rdma-core/buildlib/sparse-include/23/sys-socket.h.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- /usr/include/sys/socket.h 2016-11-16 15:43:53.000000000 -0700 -+++ build-sparse/include/sys/socket.h 2017-03-15 12:43:28.736376893 -0600 -@@ -65,7 +65,7 @@ - uses with any of the listed types to be allowed without complaint. - G++ 2.7 does not support transparent unions so there we want the - old-style declaration, too. */ --#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU -+#if 1 - # define __SOCKADDR_ARG struct sockaddr *__restrict - # define __CONST_SOCKADDR_ARG const struct sockaddr * - #else diff --git a/usr/rdma-core/buildlib/sparse-include/25/netinet-in.h.diff b/usr/rdma-core/buildlib/sparse-include/25/netinet-in.h.diff deleted file mode 100644 index 42380875e..000000000 --- a/usr/rdma-core/buildlib/sparse-include/25/netinet-in.h.diff +++ /dev/null @@ -1,121 +0,0 @@ ---- /usr/include/netinet/in.h 2017-03-09 00:51:29.000000000 +0000 -+++ build-tumbleweed/include/netinet/in.h 2017-03-21 18:13:51.951339197 +0000 -@@ -22,12 +22,12 @@ - #include - #include - #include -- -+#include - - __BEGIN_DECLS - - /* Internet address. */ --typedef uint32_t in_addr_t; -+typedef __be32 in_addr_t; - struct in_addr - { - in_addr_t s_addr; -@@ -116,7 +116,7 @@ - #endif /* !__USE_KERNEL_IPV6_DEFS */ - - /* Type to represent a port. */ --typedef uint16_t in_port_t; -+typedef __be16 in_port_t; - - /* Standard well-known ports. */ - enum -@@ -175,36 +175,36 @@ - #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) - #define IN_CLASSB_MAX 65536 - --#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000) -+#define IN_CLASSC(a) ((((uint32_t)(a)) & 0xe0000000) == 0xc0000000) - #define IN_CLASSC_NET 0xffffff00 - #define IN_CLASSC_NSHIFT 8 - #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) - --#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000) -+#define IN_CLASSD(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000) - #define IN_MULTICAST(a) IN_CLASSD(a) - --#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000) --#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000) -+#define IN_EXPERIMENTAL(a) ((((uint32_t)(a)) & 0xe0000000) == 0xe0000000) -+#define IN_BADCLASS(a) ((((uint32_t)(a)) & 0xf0000000) == 0xf0000000) - - /* Address to accept any incoming messages. */ --#define INADDR_ANY ((in_addr_t) 0x00000000) -+#define INADDR_ANY ((uint32_t) 0x00000000) - /* Address to send to all hosts. */ --#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) -+#define INADDR_BROADCAST ((uint32_t) 0xffffffff) - /* Address indicating an error return. */ --#define INADDR_NONE ((in_addr_t) 0xffffffff) -+#define INADDR_NONE ((uint32_t) 0xffffffff) - - /* Network number for local host loopback. */ - #define IN_LOOPBACKNET 127 - /* Address to loopback in software to local host. */ - #ifndef INADDR_LOOPBACK --# define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* Inet 127.0.0.1. */ -+# define INADDR_LOOPBACK ((uint32_t) 0x7f000001) /* Inet 127.0.0.1. */ - #endif - - /* Defines for Multicast INADDR. */ --#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */ --#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */ --#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */ --#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */ -+#define INADDR_UNSPEC_GROUP ((uint32_t) 0xe0000000) /* 224.0.0.0 */ -+#define INADDR_ALLHOSTS_GROUP ((uint32_t) 0xe0000001) /* 224.0.0.1 */ -+#define INADDR_ALLRTRS_GROUP ((uint32_t) 0xe0000002) /* 224.0.0.2 */ -+#define INADDR_MAX_LOCAL_GROUP ((uint32_t) 0xe00000ff) /* 224.0.0.255 */ - - #if !__USE_KERNEL_IPV6_DEFS - /* IPv6 address */ -@@ -213,8 +213,8 @@ - union - { - uint8_t __u6_addr8[16]; -- uint16_t __u6_addr16[8]; -- uint32_t __u6_addr32[4]; -+ __be16 __u6_addr16[8]; -+ __be32 __u6_addr32[4]; - } __in6_u; - #define s6_addr __in6_u.__u6_addr8 - #ifdef __USE_MISC -@@ -253,7 +253,7 @@ - { - __SOCKADDR_COMMON (sin6_); - in_port_t sin6_port; /* Transport layer port # */ -- uint32_t sin6_flowinfo; /* IPv6 flow information */ -+ __be32 sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - uint32_t sin6_scope_id; /* IPv6 scope-id */ - }; -@@ -371,12 +371,12 @@ - this was a short-sighted decision since on different systems the types - may have different representations but the values are always the same. */ - --extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__)); --extern uint16_t ntohs (uint16_t __netshort) -+extern uint32_t ntohl (__be32 __netlong) __THROW __attribute__ ((__const__)); -+extern uint16_t ntohs (__be16 __netshort) - __THROW __attribute__ ((__const__)); --extern uint32_t htonl (uint32_t __hostlong) -+extern __be32 htonl (uint32_t __hostlong) - __THROW __attribute__ ((__const__)); --extern uint16_t htons (uint16_t __hostshort) -+extern __be16 htons (uint16_t __hostshort) - __THROW __attribute__ ((__const__)); - - #include -@@ -385,7 +385,7 @@ - #include - #include - --#ifdef __OPTIMIZE__ -+#ifdef __disabled_OPTIMIZE__ - /* We can optimize calls to the conversion functions. Either nothing has - to be done or we are using directly the byte-swapping functions which - often can be inlined. */ diff --git a/usr/rdma-core/buildlib/sparse-include/endian.h b/usr/rdma-core/buildlib/sparse-include/endian.h deleted file mode 100644 index 26c317bc9..000000000 --- a/usr/rdma-core/buildlib/sparse-include/endian.h +++ /dev/null @@ -1,44 +0,0 @@ -/* COPYRIGHT (c) 2017 Obsidian Research Corporation. - Licensed under BSD (MIT variant) or GPLv2. See COPYING. */ - -#ifndef _SPARSE_ENDIAN_H_ -#define _SPARSE_ENDIAN_H_ - -#include_next - -#include - -#undef htobe16 -#undef htole16 -#undef be16toh -#undef le16toh - -#undef htobe32 -#undef htole32 -#undef be32toh -#undef le32toh - -#undef htobe64 -#undef htole64 -#undef be64toh -#undef le64toh - -/* These do not actually work, but this trivially ensures that sparse sees all - * the types. */ - -#define htobe16(x) ((__force __be16)__builtin_bswap16(x)) -#define htole16(x) ((__force __le16)__builtin_bswap16(x)) -#define be16toh(x) ((uint16_t)__builtin_bswap16((__force uint16_t)(__be16)(x))) -#define le16toh(x) ((uint16_t)__builtin_bswap16((__force uint16_t)(__le16)(x))) - -#define htobe32(x) ((__force __be32)__builtin_bswap32(x)) -#define htole32(x) ((__force __le32)__builtin_bswap32(x)) -#define be32toh(x) ((uint32_t)__builtin_bswap32((__force uint32_t)(__be32)(x))) -#define le32toh(x) ((uint32_t)__builtin_bswap32((__force uint32_t)(__le32)(x))) - -#define htobe64(x) ((__force __be64)__builtin_bswap64(x)) -#define htole64(x) ((__force __le64)__builtin_bswap64(x)) -#define be64toh(x) ((uint64_t)__builtin_bswap64((__force uint64_t)(__be64)(x))) -#define le64toh(x) ((uint64_t)__builtin_bswap64((__force uint64_t)(__le64)(x))) - -#endif diff --git a/usr/rdma-core/buildlib/sparse-include/pthread.h b/usr/rdma-core/buildlib/sparse-include/pthread.h deleted file mode 100644 index bd38b6096..000000000 --- a/usr/rdma-core/buildlib/sparse-include/pthread.h +++ /dev/null @@ -1,13 +0,0 @@ -/* COPYRIGHT (c) 2017 Obsidian Research Corporation. - Licensed under BSD (MIT variant) or GPLv2. See COPYING. */ - -#ifndef _SPARSE_PTHREAD_H_ -#define _SPARSE_PTHREAD_H_ - -#include_next - -/* Sparse complains that the glibc version of this has 0 instead of NULL */ -#undef PTHREAD_MUTEX_INITIALIZER -#define PTHREAD_MUTEX_INITIALIZER {} - -#endif diff --git a/usr/rdma-core/buildlib/sparse-include/stdatomic.h b/usr/rdma-core/buildlib/sparse-include/stdatomic.h deleted file mode 100644 index 20fde146f..000000000 --- a/usr/rdma-core/buildlib/sparse-include/stdatomic.h +++ /dev/null @@ -1,176 +0,0 @@ -/* COPYRIGHT (c) 2017 Obsidian Research Corporation. - * Licensed under BSD (MIT variant) or GPLv2. See COPYING. - * - * A version of C11 stdatomic.h that doesn't make spare angry. This doesn't - * actually work. - */ - -#ifndef _SPARSE_STDATOMIC_H_ -#define _SPARSE_STDATOMIC_H_ - -#include -#include - -#define _Atomic(T) struct {volatile __typeof__(T) __val; } - -#define ATOMIC_VAR_INIT(value) \ - { \ - .__val = (value) \ - } -#define atomic_init(obj, value) \ - do { \ - (obj)->__val = (value); \ - } while (0) - -enum memory_order { - memory_order_relaxed, - memory_order_consume, - memory_order_acquire, - memory_order_release, - memory_order_acq_rel, - memory_order_seq_cst, -}; - -typedef enum memory_order memory_order; - -#define atomic_thread_fence(order) __asm volatile("" : : : "memory") -#define atomic_signal_fence(order) __asm volatile("" : : : "memory") - -#define atomic_is_lock_free(obj) (sizeof((obj)->__val) <= sizeof(void *)) - -typedef _Atomic(_Bool) atomic_bool; -typedef _Atomic(char) atomic_char; -typedef _Atomic(signed char) atomic_schar; -typedef _Atomic(unsigned char) atomic_uchar; -typedef _Atomic(short) atomic_short; -typedef _Atomic(unsigned short) atomic_ushort; -typedef _Atomic(int) atomic_int; -typedef _Atomic(unsigned int) atomic_uint; -typedef _Atomic(long) atomic_long; -typedef _Atomic(unsigned long) atomic_ulong; -typedef _Atomic(long long) atomic_llong; -typedef _Atomic(unsigned long long) atomic_ullong; -typedef _Atomic(wchar_t) atomic_wchar_t; -typedef _Atomic(int_least8_t) atomic_int_least8_t; -typedef _Atomic(uint_least8_t) atomic_uint_least8_t; -typedef _Atomic(int_least16_t) atomic_int_least16_t; -typedef _Atomic(uint_least16_t) atomic_uint_least16_t; -typedef _Atomic(int_least32_t) atomic_int_least32_t; -typedef _Atomic(uint_least32_t) atomic_uint_least32_t; -typedef _Atomic(int_least64_t) atomic_int_least64_t; -typedef _Atomic(uint_least64_t) atomic_uint_least64_t; -typedef _Atomic(int_fast8_t) atomic_int_fast8_t; -typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t; -typedef _Atomic(int_fast16_t) atomic_int_fast16_t; -typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t; -typedef _Atomic(int_fast32_t) atomic_int_fast32_t; -typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t; -typedef _Atomic(int_fast64_t) atomic_int_fast64_t; -typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t; -typedef _Atomic(intptr_t) atomic_intptr_t; -typedef _Atomic(uintptr_t) atomic_uintptr_t; -typedef _Atomic(size_t) atomic_size_t; -typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t; -typedef _Atomic(intmax_t) atomic_intmax_t; -typedef _Atomic(uintmax_t) atomic_uintmax_t; - -#define atomic_compare_exchange_strong_explicit(object, expected, desired, \ - success, failure) \ - ({ \ - __typeof__((object)->__val) __v = (object)->__val; \ - bool __r; \ - if (__v == *(expected)) { \ - r = true; \ - (object)->__val = (desired); \ - } else { \ - r = false; \ - *(expected) = __val; \ - } \ - __r; \ - }) - -#define atomic_compare_exchange_weak_explicit(object, expected, desired, \ - success, failure) \ - atomic_compare_exchange_strong_explicit(object, expected, desired, \ - success, failure) - -#define atomic_exchange_explicit(object, desired, order) \ - ({ \ - __typeof__((object)->__val) __v = (object)->__val; \ - (object)->__val = (operand); \ - __v; \ - }) -#define atomic_fetch_add_explicit(object, operand, order) \ - ({ \ - __typeof__((object)->__val) __v = (object)->__val; \ - (object)->__val += (operand); \ - __v; \ - }) -#define atomic_fetch_and_explicit(object, operand, order) \ - ({ \ - __typeof__((object)->__val) __v = (object)->__val; \ - (object)->__val &= (operand); \ - __v; \ - }) -#define atomic_fetch_or_explicit(object, operand, order) \ - ({ \ - __typeof__((object)->__val) __v = (object)->__val; \ - (object)->__val |= (operand); \ - __v; \ - }) -#define atomic_fetch_sub_explicit(object, operand, order) \ - ({ \ - __typeof__((object)->__val) __v = (object)->__val; \ - (object)->__val -= (operand); \ - __v; \ - }) -#define atomic_fetch_xor_explicit(object, operand, order) \ - ({ \ - __typeof__((object)->__val) __v = (object)->__val; \ - (object)->__val ^= (operand); \ - __v; \ - }) - -#define atomic_load_explicit(object, order) ((object)->__val) -#define atomic_store_explicit(object, desired, order) \ - ({ (object)->__val = (desired); }) - -#define atomic_compare_exchange_strong(object, expected, desired) \ - atomic_compare_exchange_strong_explicit(object, expected, desired, \ - memory_order_seq_cst, \ - memory_order_seq_cst) -#define atomic_compare_exchange_weak(object, expected, desired) \ - atomic_compare_exchange_weak_explicit(object, expected, desired, \ - memory_order_seq_cst, \ - memory_order_seq_cst) -#define atomic_exchange(object, desired) \ - atomic_exchange_explicit(object, desired, memory_order_seq_cst) -#define atomic_fetch_add(object, operand) \ - atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_and(object, operand) \ - atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_or(object, operand) \ - atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_sub(object, operand) \ - atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_xor(object, operand) \ - atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) -#define atomic_load(object) atomic_load_explicit(object, memory_order_seq_cst) -#define atomic_store(object, desired) \ - atomic_store_explicit(object, desired, memory_order_seq_cst) - -typedef atomic_bool atomic_flag; - -#define ATOMIC_FLAG_INIT ATOMIC_VAR_INIT(0) - -#define atomic_flag_clear_explicit(object, order) \ - atomic_store_explicit(object, 0, order) -#define atomic_flag_test_and_set_explicit(object, order) \ - atomic_compare_exchange_strong_explicit(object, 0, 1, order, order) - -#define atomic_flag_clear(object) \ - atomic_flag_clear_explicit(object, memory_order_seq_cst) -#define atomic_flag_test_and_set(object) \ - atomic_flag_test_and_set_explicit(object, memory_order_seq_cst) - -#endif diff --git a/usr/rdma-core/buildlib/travis-build b/usr/rdma-core/buildlib/travis-build deleted file mode 100755 index bf86baa74..000000000 --- a/usr/rdma-core/buildlib/travis-build +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# Stop on error -set -e -# Echo all commands to Travis log -set -x - -mkdir build-clang build32 build-sparse build-aarch64 - -# Build with latest clang first -cd build-clang -CC=clang-4.0 CFLAGS=-Werror cmake -GNinja .. -ninja -../buildlib/check-build --src .. --cc clang-4.0 - -# 32 bit build to check format strings/etc -cd ../build32 -# travis's trusty is not configured in a way that enables all 32 bit -# packages. We could fix this with some sudo stuff.. For now turn off libnl -CC=gcc-7 CFLAGS="-Werror -m32" cmake -GNinja .. -DENABLE_RESOLVE_NEIGH=0 -ninja - -# aarch64 build to check compilation on ARM 64bit platform -cd ../build-aarch64 -CC=$HOME/aarch64/bin/aarch64-linux-gnu-gcc CFLAGS="-Werror -Wno-maybe-uninitialized" cmake -GNinja .. -DENABLE_RESOLVE_NEIGH=0 -ninja - -# Run sparse on the subdirectories which are sparse clean -cd ../build-sparse -mv ../CMakeLists.txt ../CMakeLists-orig.txt -grep -v "# NO SPARSE" ../CMakeLists-orig.txt > ../CMakeLists.txt -CC=cgcc CFLAGS="-Werror" cmake -GNinja .. -ninja > out -# sparse does not fail gcc on messages -if grep -v '^\[' out; then - false -fi -mv ../CMakeLists-orig.txt ../CMakeLists.txt - -# Test with coherent DMA mode disabled (ie as would be on ARM32, etc) -cd ../build-clang -cp ../util/udma_barrier.h ../util/udma_barrier.h.old -echo "#error Fail" >> ../util/udma_barrier.h -rm CMakeCache.txt -CC=clang-4.0 CFLAGS=-Werror cmake -GNinja .. -ninja -cp ../util/udma_barrier.h.old ../util/udma_barrier.h - -# Finally run through gcc-7 64 bit through the debian packaging This gives a -# good clue if patches are changing packaging related things, the RPM stuff -# will have to be audited by hand. - -# When running cmake through debian/rules it is hard to set -Werror, -# instead force it on by changing the CMakeLists.txt -cd .. -echo 'set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")' >> buildlib/RDMA_EnableCStd.cmake -sed -i -e 's/-DCMAKE_BUILD_TYPE=Release//g' debian/rules -sed -i -e 's/ninja \(.*\)-v/ninja \1/g' debian/rules - -CC=gcc-7 debian/rules build -fakeroot debian/rules binary diff --git a/usr/rdma-core/buildlib/travis-checkpatch b/usr/rdma-core/buildlib/travis-checkpatch deleted file mode 100755 index 5e78ec474..000000000 --- a/usr/rdma-core/buildlib/travis-checkpatch +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -# Copyright 2017 Mellanox Technologies Ltd. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - - -if [ "x$TRAVIS_EVENT_TYPE" != "xpull_request" ]; then - # Peform checkpatch checks on pull requests only - exit 0 -fi - -# The below "set" is commented, because the checkpatch.pl returns 1 (error) for warnings too. -# And the rdma-core code is not mature enough to be warning safe -# set -e - -if [ "x$TRAVIS_COMMIT_RANGE" != "x" ]; then - cd buildlib/ - wget -q https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/checkpatch.pl \ - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/spelling.txt - DIR_FOR_PATCHES_TO_CHECK=$(mktemp -d) - git format-patch --no-cover-letter $TRAVIS_COMMIT_RANGE ^$TRAVIS_BRANCH -o $DIR_FOR_PATCHES_TO_CHECK/ - CHECKPATCH_OPT="--no-tree --ignore PREFER_KERNEL_TYPES,FILE_PATH_CHANGES,EXECUTE_PERMISSIONS,USE_NEGATIVE_ERRNO,CONST_STRUCT $DIR_FOR_PATCHES_TO_CHECK/*" - perl checkpatch.pl $CHECKPATCH_OPT - if [ $? -ne 0 ]; then - # We rerun checkpatch to simplify parsing and to understand if we failed for errors - # For example, the output on some arbitrary patchset of the following line without awk is: - # total: 1 errors, 3 warnings, 42 lines checked - NUMB_ERRRORS=$(perl checkpatch.pl --terse $CHECKPATCH_OPT | awk 'BEGIN {FS = "total:"} ; {sum+=$2} END {print sum}') - exit $NUMB_ERRRORS - fi -fi diff --git a/usr/rdma-core/ccan/CMakeLists.txt b/usr/rdma-core/ccan/CMakeLists.txt deleted file mode 100644 index b5de515eb..000000000 --- a/usr/rdma-core/ccan/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -publish_internal_headers(ccan - build_assert.h - check_type.h - container_of.h - list.h - minmax.h - str.h - str_debug.h - ) - -set(C_FILES - list.c - str.c - ) -add_library(ccan STATIC ${C_FILES}) -add_library(ccan_pic STATIC ${C_FILES}) -set_property(TARGET ccan_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE) diff --git a/usr/rdma-core/ccan/LICENSE.CCO b/usr/rdma-core/ccan/LICENSE.CCO deleted file mode 100644 index 57f2f1b08..000000000 --- a/usr/rdma-core/ccan/LICENSE.CCO +++ /dev/null @@ -1,97 +0,0 @@ -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator and -subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for the -purpose of contributing to a commons of creative, cultural and scientific works -("Commons") that the public can reliably and without fear of later claims of -infringement build upon, modify, incorporate in other works, reuse and -redistribute as freely as possible in any form whatsoever and for any purposes, -including without limitation commercial purposes. These owners may contribute -to the Commons to promote the ideal of a free culture and the further -production of creative, cultural and scientific works, or to gain reputation or -greater distribution for their Work in part through the use and efforts of -others. - -For these and/or other purposes and motivations, and without any expectation of -additional consideration or compensation, the person associating CC0 with a -Work (the "Affirmer"), to the extent that he or she is an owner of Copyright -and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and -publicly distribute the Work under its terms, with knowledge of his or her -Copyright and Related Rights in the Work and the meaning and intended legal -effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not limited to, -the following: - - the right to reproduce, adapt, distribute, perform, display, communicate, -and translate a Work; moral rights retained by the original author(s) and/or -performer(s); publicity and privacy rights pertaining to a person's image or -likeness depicted in a Work; rights protecting against unfair competition in -regards to a Work, subject to the limitations in paragraph 4(a), below; rights -protecting the extraction, dissemination, use and reuse of data in a Work; -database rights (such as those arising under Directive 96/9/EC of the European -Parliament and of the Council of 11 March 1996 on the legal protection of -databases, and under any national implementation thereof, including any amended -or successor version of such directive); and other similar, equivalent or -corresponding rights throughout the world based on applicable law or treaty, -and any national implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention of, -applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and -unconditionally waives, abandons, and surrenders all of Affirmer's Copyright -and Related Rights and associated claims and causes of action, whether now -known or unknown (including existing as well as future claims and causes of -action), in the Work (i) in all territories worldwide, (ii) for the maximum -duration provided by applicable law or treaty (including future time -extensions), (iii) in any current or future medium and for any number of -copies, and (iv) for any purpose whatsoever, including without limitation -commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes -the Waiver for the benefit of each member of the public at large and to the -detriment of Affirmer's heirs and successors, fully intending that such Waiver -shall not be subject to revocation, rescission, cancellation, termination, or -any other legal or equitable action to disrupt the quiet enjoyment of the Work -by the public as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason be -judged legally invalid or ineffective under applicable law, then the Waiver -shall be preserved to the maximum extent permitted taking into account -Affirmer's express Statement of Purpose. In addition, to the extent the Waiver -is so judged Affirmer hereby grants to each affected person a royalty-free, non -transferable, non sublicensable, non exclusive, irrevocable and unconditional -license to exercise Affirmer's Copyright and Related Rights in the Work (i) in -all territories worldwide, (ii) for the maximum duration provided by applicable -law or treaty (including future time extensions), (iii) in any current or -future medium and for any number of copies, and (iv) for any purpose -whatsoever, including without limitation commercial, advertising or promotional -purposes (the "License"). The License shall be deemed effective as of the date -CC0 was applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder of the -License, and in such case Affirmer hereby affirms that he or she will not (i) -exercise any of his or her remaining Copyright and Related Rights in the Work -or (ii) assert any associated claims and causes of action with respect to the -Work, in either case contrary to Affirmer's express Statement of Purpose. - -4. Limitations and Disclaimers. - - No trademark or patent rights held by Affirmer are waived, abandoned, -surrendered, licensed or otherwise affected by this document. Affirmer offers -the Work as-is and makes no representations or warranties of any kind -concerning the Work, express, implied, statutory or otherwise, including -without limitation warranties of title, merchantability, fitness for a -particular purpose, non infringement, or the absence of latent or other -defects, accuracy, or the present or absence of errors, whether or not -discoverable, all to the greatest extent permissible under applicable law. -Affirmer disclaims responsibility for clearing rights of other persons that may -apply to the Work or any use thereof, including without limitation any person's -Copyright and Related Rights in the Work. Further, Affirmer disclaims -responsibility for obtaining any necessary consents, permissions or other -rights required for any use of the Work. Affirmer understands and acknowledges -that Creative Commons is not a party to this document and has no duty or -obligation with respect to this CC0 or use of the Work. diff --git a/usr/rdma-core/ccan/LICENSE.MIT b/usr/rdma-core/ccan/LICENSE.MIT deleted file mode 100644 index 89de35479..000000000 --- a/usr/rdma-core/ccan/LICENSE.MIT +++ /dev/null @@ -1,17 +0,0 @@ -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/usr/rdma-core/ccan/build_assert.h b/usr/rdma-core/ccan/build_assert.h deleted file mode 100644 index 0ecd7ff36..000000000 --- a/usr/rdma-core/ccan/build_assert.h +++ /dev/null @@ -1,40 +0,0 @@ -/* CC0 (Public domain) - see LICENSE.CC0 file for details */ -#ifndef CCAN_BUILD_ASSERT_H -#define CCAN_BUILD_ASSERT_H - -/** - * BUILD_ASSERT - assert a build-time dependency. - * @cond: the compile-time condition which must be true. - * - * Your compile will fail if the condition isn't true, or can't be evaluated - * by the compiler. This can only be used within a function. - * - * Example: - * #include - * ... - * static char *foo_to_char(struct foo *foo) - * { - * // This code needs string to be at start of foo. - * BUILD_ASSERT(offsetof(struct foo, string) == 0); - * return (char *)foo; - * } - */ -#define BUILD_ASSERT(cond) \ - do { (void) sizeof(char [1 - 2*!(cond)]); } while(0) - -/** - * BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression. - * @cond: the compile-time condition which must be true. - * - * Your compile will fail if the condition isn't true, or can't be evaluated - * by the compiler. This can be used in an expression: its value is "0". - * - * Example: - * #define foo_to_char(foo) \ - * ((char *)(foo) \ - * + BUILD_ASSERT_OR_ZERO(offsetof(struct foo, string) == 0)) - */ -#define BUILD_ASSERT_OR_ZERO(cond) \ - (sizeof(char [1 - 2*!(cond)]) - 1) - -#endif /* CCAN_BUILD_ASSERT_H */ diff --git a/usr/rdma-core/ccan/check_type.h b/usr/rdma-core/ccan/check_type.h deleted file mode 100644 index a576a5018..000000000 --- a/usr/rdma-core/ccan/check_type.h +++ /dev/null @@ -1,64 +0,0 @@ -/* CC0 (Public domain) - see LICENSE.CC0 file for details */ -#ifndef CCAN_CHECK_TYPE_H -#define CCAN_CHECK_TYPE_H -#include "config.h" - -/** - * check_type - issue a warning or build failure if type is not correct. - * @expr: the expression whose type we should check (not evaluated). - * @type: the exact type we expect the expression to be. - * - * This macro is usually used within other macros to try to ensure that a macro - * argument is of the expected type. No type promotion of the expression is - * done: an unsigned int is not the same as an int! - * - * check_type() always evaluates to 0. - * - * If your compiler does not support typeof, then the best we can do is fail - * to compile if the sizes of the types are unequal (a less complete check). - * - * Example: - * // They should always pass a 64-bit value to _set_some_value! - * #define set_some_value(expr) \ - * _set_some_value((check_type((expr), uint64_t), (expr))) - */ - -/** - * check_types_match - issue a warning or build failure if types are not same. - * @expr1: the first expression (not evaluated). - * @expr2: the second expression (not evaluated). - * - * This macro is usually used within other macros to try to ensure that - * arguments are of identical types. No type promotion of the expressions is - * done: an unsigned int is not the same as an int! - * - * check_types_match() always evaluates to 0. - * - * If your compiler does not support typeof, then the best we can do is fail - * to compile if the sizes of the types are unequal (a less complete check). - * - * Example: - * // Do subtraction to get to enclosing type, but make sure that - * // pointer is of correct type for that member. - * #define container_of(mbr_ptr, encl_type, mbr) \ - * (check_types_match((mbr_ptr), &((encl_type *)0)->mbr), \ - * ((encl_type *) \ - * ((char *)(mbr_ptr) - offsetof(enclosing_type, mbr)))) - */ -#if HAVE_TYPEOF -#define check_type(expr, type) \ - ((typeof(expr) *)0 != (type *)0) - -#define check_types_match(expr1, expr2) \ - ((typeof(expr1) *)0 != (typeof(expr2) *)0) -#else -#include -/* Without typeof, we can only test the sizes. */ -#define check_type(expr, type) \ - BUILD_ASSERT_OR_ZERO(sizeof(expr) == sizeof(type)) - -#define check_types_match(expr1, expr2) \ - BUILD_ASSERT_OR_ZERO(sizeof(expr1) == sizeof(expr2)) -#endif /* HAVE_TYPEOF */ - -#endif /* CCAN_CHECK_TYPE_H */ diff --git a/usr/rdma-core/ccan/container_of.h b/usr/rdma-core/ccan/container_of.h deleted file mode 100644 index 9180f37f0..000000000 --- a/usr/rdma-core/ccan/container_of.h +++ /dev/null @@ -1,146 +0,0 @@ -/* CC0 (Public domain) - see LICENSE.CC0 file for details */ -#ifndef CCAN_CONTAINER_OF_H -#define CCAN_CONTAINER_OF_H -#include - -#include "config.h" -#include - -/** - * container_of - get pointer to enclosing structure - * @member_ptr: pointer to the structure member - * @containing_type: the type this member is within - * @member: the name of this member within the structure. - * - * Given a pointer to a member of a structure, this macro does pointer - * subtraction to return the pointer to the enclosing type. - * - * Example: - * struct foo { - * int fielda, fieldb; - * // ... - * }; - * struct info { - * int some_other_field; - * struct foo my_foo; - * }; - * - * static struct info *foo_to_info(struct foo *foo) - * { - * return container_of(foo, struct info, my_foo); - * } - */ -#ifndef container_of -#define container_of(member_ptr, containing_type, member) \ - ((containing_type *) \ - ((char *)(member_ptr) \ - - container_off(containing_type, member)) \ - + check_types_match(*(member_ptr), ((containing_type *)0)->member)) -#endif - -/** - * container_of_or_null - get pointer to enclosing structure, or NULL - * @member_ptr: pointer to the structure member - * @containing_type: the type this member is within - * @member: the name of this member within the structure. - * - * Given a pointer to a member of a structure, this macro does pointer - * subtraction to return the pointer to the enclosing type, unless it - * is given NULL, in which case it also returns NULL. - * - * Example: - * struct foo { - * int fielda, fieldb; - * // ... - * }; - * struct info { - * int some_other_field; - * struct foo my_foo; - * }; - * - * static struct info *foo_to_info_allowing_null(struct foo *foo) - * { - * return container_of_or_null(foo, struct info, my_foo); - * } - */ -static inline char *container_of_or_null_(void *member_ptr, size_t offset) -{ - return member_ptr ? (char *)member_ptr - offset : NULL; -} -#define container_of_or_null(member_ptr, containing_type, member) \ - ((containing_type *) \ - container_of_or_null_(member_ptr, \ - container_off(containing_type, member)) \ - + check_types_match(*(member_ptr), ((containing_type *)0)->member)) - -/** - * container_off - get offset to enclosing structure - * @containing_type: the type this member is within - * @member: the name of this member within the structure. - * - * Given a pointer to a member of a structure, this macro does - * typechecking and figures out the offset to the enclosing type. - * - * Example: - * struct foo { - * int fielda, fieldb; - * // ... - * }; - * struct info { - * int some_other_field; - * struct foo my_foo; - * }; - * - * static struct info *foo_to_info(struct foo *foo) - * { - * size_t off = container_off(struct info, my_foo); - * return (void *)((char *)foo - off); - * } - */ -#define container_off(containing_type, member) \ - offsetof(containing_type, member) - -/** - * container_of_var - get pointer to enclosing structure using a variable - * @member_ptr: pointer to the structure member - * @container_var: a pointer of same type as this member's container - * @member: the name of this member within the structure. - * - * Given a pointer to a member of a structure, this macro does pointer - * subtraction to return the pointer to the enclosing type. - * - * Example: - * static struct info *foo_to_i(struct foo *foo) - * { - * struct info *i = container_of_var(foo, i, my_foo); - * return i; - * } - */ -#if HAVE_TYPEOF -#define container_of_var(member_ptr, container_var, member) \ - container_of(member_ptr, typeof(*container_var), member) -#else -#define container_of_var(member_ptr, container_var, member) \ - ((void *)((char *)(member_ptr) - \ - container_off_var(container_var, member))) -#endif - -/** - * container_off_var - get offset of a field in enclosing structure - * @container_var: a pointer to a container structure - * @member: the name of a member within the structure. - * - * Given (any) pointer to a structure and a its member name, this - * macro does pointer subtraction to return offset of member in a - * structure memory layout. - * - */ -#if HAVE_TYPEOF -#define container_off_var(var, member) \ - container_off(typeof(*var), member) -#else -#define container_off_var(var, member) \ - ((const char *)&(var)->member - (const char *)(var)) -#endif - -#endif /* CCAN_CONTAINER_OF_H */ diff --git a/usr/rdma-core/ccan/list.c b/usr/rdma-core/ccan/list.c deleted file mode 100644 index b49e6f6bc..000000000 --- a/usr/rdma-core/ccan/list.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Licensed under MIT - see LICENSE.MIT file for details */ -#include -#include -#include "list.h" - -static void *corrupt(const char *abortstr, - const struct list_node *head, - const struct list_node *node, - unsigned int count) -{ - if (abortstr) { - fprintf(stderr, - "%s: prev corrupt in node %p (%u) of %p\n", - abortstr, node, count, head); - abort(); - } - return NULL; -} - -struct list_node *list_check_node(const struct list_node *node, - const char *abortstr) -{ - const struct list_node *p, *n; - int count = 0; - - for (p = node, n = node->next; n != node; p = n, n = n->next) { - count++; - if (n->prev != p) - return corrupt(abortstr, node, n, count); - } - /* Check prev on head node. */ - if (node->prev != p) - return corrupt(abortstr, node, node, 0); - - return (struct list_node *)node; -} - -struct list_head *list_check(const struct list_head *h, const char *abortstr) -{ - if (!list_check_node(&h->n, abortstr)) - return NULL; - return (struct list_head *)h; -} diff --git a/usr/rdma-core/ccan/list.h b/usr/rdma-core/ccan/list.h deleted file mode 100644 index f4006660f..000000000 --- a/usr/rdma-core/ccan/list.h +++ /dev/null @@ -1,842 +0,0 @@ -/* Licensed under MIT - see LICENSE.MIT file for details */ -#ifndef CCAN_LIST_H -#define CCAN_LIST_H -//#define CCAN_LIST_DEBUG 1 -#include -#include -#include -#include -#include - -/** - * struct list_node - an entry in a doubly-linked list - * @next: next entry (self if empty) - * @prev: previous entry (self if empty) - * - * This is used as an entry in a linked list. - * Example: - * struct child { - * const char *name; - * // Linked list of all us children. - * struct list_node list; - * }; - */ -struct list_node -{ - struct list_node *next, *prev; -}; - -/** - * struct list_head - the head of a doubly-linked list - * @h: the list_head (containing next and prev pointers) - * - * This is used as the head of a linked list. - * Example: - * struct parent { - * const char *name; - * struct list_head children; - * unsigned int num_children; - * }; - */ -struct list_head -{ - struct list_node n; -}; - -/** - * list_check - check head of a list for consistency - * @h: the list_head - * @abortstr: the location to print on aborting, or NULL. - * - * Because list_nodes have redundant information, consistency checking between - * the back and forward links can be done. This is useful as a debugging check. - * If @abortstr is non-NULL, that will be printed in a diagnostic if the list - * is inconsistent, and the function will abort. - * - * Returns the list head if the list is consistent, NULL if not (it - * can never return NULL if @abortstr is set). - * - * See also: list_check_node() - * - * Example: - * static void dump_parent(struct parent *p) - * { - * struct child *c; - * - * printf("%s (%u children):\n", p->name, p->num_children); - * list_check(&p->children, "bad child list"); - * list_for_each(&p->children, c, list) - * printf(" -> %s\n", c->name); - * } - */ -struct list_head *list_check(const struct list_head *h, const char *abortstr); - -/** - * list_check_node - check node of a list for consistency - * @n: the list_node - * @abortstr: the location to print on aborting, or NULL. - * - * Check consistency of the list node is in (it must be in one). - * - * See also: list_check() - * - * Example: - * static void dump_child(const struct child *c) - * { - * list_check_node(&c->list, "bad child list"); - * printf("%s\n", c->name); - * } - */ -struct list_node *list_check_node(const struct list_node *n, - const char *abortstr); - -#define LIST_LOC __FILE__ ":" stringify(__LINE__) -#ifdef CCAN_LIST_DEBUG -#define list_debug(h, loc) list_check((h), loc) -#define list_debug_node(n, loc) list_check_node((n), loc) -#else -#define list_debug(h, loc) ((void)loc, h) -#define list_debug_node(n, loc) ((void)loc, n) -#endif - -/** - * LIST_HEAD_INIT - initializer for an empty list_head - * @name: the name of the list. - * - * Explicit initializer for an empty list. - * - * See also: - * LIST_HEAD, list_head_init() - * - * Example: - * static struct list_head my_list = LIST_HEAD_INIT(my_list); - */ -#define LIST_HEAD_INIT(name) { { &(name).n, &(name).n } } - -/** - * LIST_HEAD - define and initialize an empty list_head - * @name: the name of the list. - * - * The LIST_HEAD macro defines a list_head and initializes it to an empty - * list. It can be prepended by "static" to define a static list_head. - * - * See also: - * LIST_HEAD_INIT, list_head_init() - * - * Example: - * static LIST_HEAD(my_global_list); - */ -#define LIST_HEAD(name) \ - struct list_head name = LIST_HEAD_INIT(name) - -/** - * list_head_init - initialize a list_head - * @h: the list_head to set to the empty list - * - * Example: - * ... - * struct parent *parent = malloc(sizeof(*parent)); - * - * list_head_init(&parent->children); - * parent->num_children = 0; - */ -static inline void list_head_init(struct list_head *h) -{ - h->n.next = h->n.prev = &h->n; -} - -/** - * list_node_init - initialize a list_node - * @n: the list_node to link to itself. - * - * You don't need to use this normally! But it lets you list_del(@n) - * safely. - */ -static inline void list_node_init(struct list_node *n) -{ - n->next = n->prev = n; -} - -/** - * list_add_after - add an entry after an existing node in a linked list - * @h: the list_head to add the node to (for debugging) - * @p: the existing list_node to add the node after - * @n: the new list_node to add to the list. - * - * The existing list_node must already be a member of the list. - * The new list_node does not need to be initialized; it will be overwritten. - * - * Example: - * struct child c1, c2, c3; - * LIST_HEAD(h); - * - * list_add_tail(&h, &c1.list); - * list_add_tail(&h, &c3.list); - * list_add_after(&h, &c1.list, &c2.list); - */ -#define list_add_after(h, p, n) list_add_after_(h, p, n, LIST_LOC) -static inline void list_add_after_(struct list_head *h, - struct list_node *p, - struct list_node *n, - const char *abortstr) -{ - n->next = p->next; - n->prev = p; - p->next->prev = n; - p->next = n; - (void)list_debug(h, abortstr); -} - -/** - * list_add - add an entry at the start of a linked list. - * @h: the list_head to add the node to - * @n: the list_node to add to the list. - * - * The list_node does not need to be initialized; it will be overwritten. - * Example: - * struct child *child = malloc(sizeof(*child)); - * - * child->name = "marvin"; - * list_add(&parent->children, &child->list); - * parent->num_children++; - */ -#define list_add(h, n) list_add_(h, n, LIST_LOC) -static inline void list_add_(struct list_head *h, - struct list_node *n, - const char *abortstr) -{ - list_add_after_(h, &h->n, n, abortstr); -} - -/** - * list_add_before - add an entry before an existing node in a linked list - * @h: the list_head to add the node to (for debugging) - * @p: the existing list_node to add the node before - * @n: the new list_node to add to the list. - * - * The existing list_node must already be a member of the list. - * The new list_node does not need to be initialized; it will be overwritten. - * - * Example: - * list_head_init(&h); - * list_add_tail(&h, &c1.list); - * list_add_tail(&h, &c3.list); - * list_add_before(&h, &c3.list, &c2.list); - */ -#define list_add_before(h, p, n) list_add_before_(h, p, n, LIST_LOC) -static inline void list_add_before_(struct list_head *h, - struct list_node *p, - struct list_node *n, - const char *abortstr) -{ - n->next = p; - n->prev = p->prev; - p->prev->next = n; - p->prev = n; - (void)list_debug(h, abortstr); -} - -/** - * list_add_tail - add an entry at the end of a linked list. - * @h: the list_head to add the node to - * @n: the list_node to add to the list. - * - * The list_node does not need to be initialized; it will be overwritten. - * Example: - * list_add_tail(&parent->children, &child->list); - * parent->num_children++; - */ -#define list_add_tail(h, n) list_add_tail_(h, n, LIST_LOC) -static inline void list_add_tail_(struct list_head *h, - struct list_node *n, - const char *abortstr) -{ - list_add_before_(h, &h->n, n, abortstr); -} - -/** - * list_empty - is a list empty? - * @h: the list_head - * - * If the list is empty, returns true. - * - * Example: - * assert(list_empty(&parent->children) == (parent->num_children == 0)); - */ -#define list_empty(h) list_empty_(h, LIST_LOC) -static inline bool list_empty_(const struct list_head *h, const char* abortstr) -{ - (void)list_debug(h, abortstr); - return h->n.next == &h->n; -} - -/** - * list_empty_nodebug - is a list empty (and don't perform debug checks)? - * @h: the list_head - * - * If the list is empty, returns true. - * This differs from list_empty() in that if CCAN_LIST_DEBUG is set it - * will NOT perform debug checks. Only use this function if you REALLY - * know what you're doing. - * - * Example: - * assert(list_empty_nodebug(&parent->children) == (parent->num_children == 0)); - */ -#ifndef CCAN_LIST_DEBUG -#define list_empty_nodebug(h) list_empty(h) -#else -static inline bool list_empty_nodebug(const struct list_head *h) -{ - return h->n.next == &h->n; -} -#endif - -/** - * list_empty_nocheck - is a list empty? - * @h: the list_head - * - * If the list is empty, returns true. This doesn't perform any - * debug check for list consistency, so it can be called without - * locks, racing with the list being modified. This is ok for - * checks where an incorrect result is not an issue (optimized - * bail out path for example). - */ -static inline bool list_empty_nocheck(const struct list_head *h) -{ - return h->n.next == &h->n; -} - -/** - * list_del - delete an entry from an (unknown) linked list. - * @n: the list_node to delete from the list. - * - * Note that this leaves @n in an undefined state; it can be added to - * another list, but not deleted again. - * - * See also: - * list_del_from(), list_del_init() - * - * Example: - * list_del(&child->list); - * parent->num_children--; - */ -#define list_del(n) list_del_(n, LIST_LOC) -static inline void list_del_(struct list_node *n, const char* abortstr) -{ - (void)list_debug_node(n, abortstr); - n->next->prev = n->prev; - n->prev->next = n->next; -#ifdef CCAN_LIST_DEBUG - /* Catch use-after-del. */ - n->next = n->prev = NULL; -#endif -} - -/** - * list_del_init - delete a node, and reset it so it can be deleted again. - * @n: the list_node to be deleted. - * - * list_del(@n) or list_del_init() again after this will be safe, - * which can be useful in some cases. - * - * See also: - * list_del_from(), list_del() - * - * Example: - * list_del_init(&child->list); - * parent->num_children--; - */ -#define list_del_init(n) list_del_init_(n, LIST_LOC) -static inline void list_del_init_(struct list_node *n, const char *abortstr) -{ - list_del_(n, abortstr); - list_node_init(n); -} - -/** - * list_del_from - delete an entry from a known linked list. - * @h: the list_head the node is in. - * @n: the list_node to delete from the list. - * - * This explicitly indicates which list a node is expected to be in, - * which is better documentation and can catch more bugs. - * - * See also: list_del() - * - * Example: - * list_del_from(&parent->children, &child->list); - * parent->num_children--; - */ -static inline void list_del_from(struct list_head *h, struct list_node *n) -{ -#ifdef CCAN_LIST_DEBUG - { - /* Thorough check: make sure it was in list! */ - struct list_node *i; - for (i = h->n.next; i != n; i = i->next) - assert(i != &h->n); - } -#endif /* CCAN_LIST_DEBUG */ - - /* Quick test that catches a surprising number of bugs. */ - assert(!list_empty(h)); - list_del(n); -} - -/** - * list_swap - swap out an entry from an (unknown) linked list for a new one. - * @o: the list_node to replace from the list. - * @n: the list_node to insert in place of the old one. - * - * Note that this leaves @o in an undefined state; it can be added to - * another list, but not deleted/swapped again. - * - * See also: - * list_del() - * - * Example: - * struct child x1, x2; - * LIST_HEAD(xh); - * - * list_add(&xh, &x1.list); - * list_swap(&x1.list, &x2.list); - */ -#define list_swap(o, n) list_swap_(o, n, LIST_LOC) -static inline void list_swap_(struct list_node *o, - struct list_node *n, - const char* abortstr) -{ - (void)list_debug_node(o, abortstr); - *n = *o; - n->next->prev = n; - n->prev->next = n; -#ifdef CCAN_LIST_DEBUG - /* Catch use-after-del. */ - o->next = o->prev = NULL; -#endif -} - -/** - * list_entry - convert a list_node back into the structure containing it. - * @n: the list_node - * @type: the type of the entry - * @member: the list_node member of the type - * - * Example: - * // First list entry is children.next; convert back to child. - * child = list_entry(parent->children.n.next, struct child, list); - * - * See Also: - * list_top(), list_for_each() - */ -#define list_entry(n, type, member) container_of(n, type, member) - -/** - * list_top - get the first entry in a list - * @h: the list_head - * @type: the type of the entry - * @member: the list_node member of the type - * - * If the list is empty, returns NULL. - * - * Example: - * struct child *first; - * first = list_top(&parent->children, struct child, list); - * if (!first) - * printf("Empty list!\n"); - */ -#define list_top(h, type, member) \ - ((type *)list_top_((h), list_off_(type, member))) - -static inline const void *list_top_(const struct list_head *h, size_t off) -{ - if (list_empty(h)) - return NULL; - return (const char *)h->n.next - off; -} - -/** - * list_pop - remove the first entry in a list - * @h: the list_head - * @type: the type of the entry - * @member: the list_node member of the type - * - * If the list is empty, returns NULL. - * - * Example: - * struct child *one; - * one = list_pop(&parent->children, struct child, list); - * if (!one) - * printf("Empty list!\n"); - */ -#define list_pop(h, type, member) \ - ((type *)list_pop_((h), list_off_(type, member))) - -static inline const void *list_pop_(const struct list_head *h, size_t off) -{ - struct list_node *n; - - if (list_empty(h)) - return NULL; - n = h->n.next; - list_del(n); - return (const char *)n - off; -} - -/** - * list_tail - get the last entry in a list - * @h: the list_head - * @type: the type of the entry - * @member: the list_node member of the type - * - * If the list is empty, returns NULL. - * - * Example: - * struct child *last; - * last = list_tail(&parent->children, struct child, list); - * if (!last) - * printf("Empty list!\n"); - */ -#define list_tail(h, type, member) \ - ((type *)list_tail_((h), list_off_(type, member))) - -static inline const void *list_tail_(const struct list_head *h, size_t off) -{ - if (list_empty(h)) - return NULL; - return (const char *)h->n.prev - off; -} - -/** - * list_for_each - iterate through a list. - * @h: the list_head (warning: evaluated multiple times!) - * @i: the structure containing the list_node - * @member: the list_node member of the structure - * - * This is a convenient wrapper to iterate @i over the entire list. It's - * a for loop, so you can break and continue as normal. - * - * Example: - * list_for_each(&parent->children, child, list) - * printf("Name: %s\n", child->name); - */ -#define list_for_each(h, i, member) \ - list_for_each_off(h, i, list_off_var_(i, member)) - -/** - * list_for_each_rev - iterate through a list backwards. - * @h: the list_head - * @i: the structure containing the list_node - * @member: the list_node member of the structure - * - * This is a convenient wrapper to iterate @i over the entire list. It's - * a for loop, so you can break and continue as normal. - * - * Example: - * list_for_each_rev(&parent->children, child, list) - * printf("Name: %s\n", child->name); - */ -#define list_for_each_rev(h, i, member) \ - list_for_each_rev_off(h, i, list_off_var_(i, member)) - -/** - * list_for_each_rev_safe - iterate through a list backwards, - * maybe during deletion - * @h: the list_head - * @i: the structure containing the list_node - * @nxt: the structure containing the list_node - * @member: the list_node member of the structure - * - * This is a convenient wrapper to iterate @i over the entire list backwards. - * It's a for loop, so you can break and continue as normal. The extra - * variable * @nxt is used to hold the next element, so you can delete @i - * from the list. - * - * Example: - * struct child *next; - * list_for_each_rev_safe(&parent->children, child, next, list) { - * printf("Name: %s\n", child->name); - * } - */ -#define list_for_each_rev_safe(h, i, nxt, member) \ - list_for_each_rev_safe_off(h, i, nxt, list_off_var_(i, member)) - -/** - * list_for_each_safe - iterate through a list, maybe during deletion - * @h: the list_head - * @i: the structure containing the list_node - * @nxt: the structure containing the list_node - * @member: the list_node member of the structure - * - * This is a convenient wrapper to iterate @i over the entire list. It's - * a for loop, so you can break and continue as normal. The extra variable - * @nxt is used to hold the next element, so you can delete @i from the list. - * - * Example: - * list_for_each_safe(&parent->children, child, next, list) { - * list_del(&child->list); - * parent->num_children--; - * } - */ -#define list_for_each_safe(h, i, nxt, member) \ - list_for_each_safe_off(h, i, nxt, list_off_var_(i, member)) - -/** - * list_next - get the next entry in a list - * @h: the list_head - * @i: a pointer to an entry in the list. - * @member: the list_node member of the structure - * - * If @i was the last entry in the list, returns NULL. - * - * Example: - * struct child *second; - * second = list_next(&parent->children, first, list); - * if (!second) - * printf("No second child!\n"); - */ -#define list_next(h, i, member) \ - ((list_typeof(i))list_entry_or_null(list_debug(h, \ - __FILE__ ":" stringify(__LINE__)), \ - (i)->member.next, \ - list_off_var_((i), member))) - -/** - * list_prev - get the previous entry in a list - * @h: the list_head - * @i: a pointer to an entry in the list. - * @member: the list_node member of the structure - * - * If @i was the first entry in the list, returns NULL. - * - * Example: - * first = list_prev(&parent->children, second, list); - * if (!first) - * printf("Can't go back to first child?!\n"); - */ -#define list_prev(h, i, member) \ - ((list_typeof(i))list_entry_or_null(list_debug(h, \ - __FILE__ ":" stringify(__LINE__)), \ - (i)->member.prev, \ - list_off_var_((i), member))) - -/** - * list_append_list - empty one list onto the end of another. - * @to: the list to append into - * @from: the list to empty. - * - * This takes the entire contents of @from and moves it to the end of - * @to. After this @from will be empty. - * - * Example: - * struct list_head adopter; - * - * list_append_list(&adopter, &parent->children); - * assert(list_empty(&parent->children)); - * parent->num_children = 0; - */ -#define list_append_list(t, f) list_append_list_(t, f, \ - __FILE__ ":" stringify(__LINE__)) -static inline void list_append_list_(struct list_head *to, - struct list_head *from, - const char *abortstr) -{ - struct list_node *from_tail = list_debug(from, abortstr)->n.prev; - struct list_node *to_tail = list_debug(to, abortstr)->n.prev; - - /* Sew in head and entire list. */ - to->n.prev = from_tail; - from_tail->next = &to->n; - to_tail->next = &from->n; - from->n.prev = to_tail; - - /* Now remove head. */ - list_del(&from->n); - list_head_init(from); -} - -/** - * list_prepend_list - empty one list into the start of another. - * @to: the list to prepend into - * @from: the list to empty. - * - * This takes the entire contents of @from and moves it to the start - * of @to. After this @from will be empty. - * - * Example: - * list_prepend_list(&adopter, &parent->children); - * assert(list_empty(&parent->children)); - * parent->num_children = 0; - */ -#define list_prepend_list(t, f) list_prepend_list_(t, f, LIST_LOC) -static inline void list_prepend_list_(struct list_head *to, - struct list_head *from, - const char *abortstr) -{ - struct list_node *from_tail = list_debug(from, abortstr)->n.prev; - struct list_node *to_head = list_debug(to, abortstr)->n.next; - - /* Sew in head and entire list. */ - to->n.next = &from->n; - from->n.prev = &to->n; - to_head->prev = from_tail; - from_tail->next = to_head; - - /* Now remove head. */ - list_del(&from->n); - list_head_init(from); -} - -/* internal macros, do not use directly */ -#define list_for_each_off_dir_(h, i, off, dir) \ - for (i = list_node_to_off_(list_debug(h, LIST_LOC)->n.dir, \ - (off)); \ - list_node_from_off_((void *)i, (off)) != &(h)->n; \ - i = list_node_to_off_(list_node_from_off_((void *)i, (off))->dir, \ - (off))) - -#define list_for_each_safe_off_dir_(h, i, nxt, off, dir) \ - for (i = list_node_to_off_(list_debug(h, LIST_LOC)->n.dir, \ - (off)), \ - nxt = list_node_to_off_(list_node_from_off_(i, (off))->dir, \ - (off)); \ - list_node_from_off_(i, (off)) != &(h)->n; \ - i = nxt, \ - nxt = list_node_to_off_(list_node_from_off_(i, (off))->dir, \ - (off))) - -/** - * list_for_each_off - iterate through a list of memory regions. - * @h: the list_head - * @i: the pointer to a memory region wich contains list node data. - * @off: offset(relative to @i) at which list node data resides. - * - * This is a low-level wrapper to iterate @i over the entire list, used to - * implement all oher, more high-level, for-each constructs. It's a for loop, - * so you can break and continue as normal. - * - * WARNING! Being the low-level macro that it is, this wrapper doesn't know - * nor care about the type of @i. The only assumtion made is that @i points - * to a chunk of memory that at some @offset, relative to @i, contains a - * properly filled `struct node_list' which in turn contains pointers to - * memory chunks and it's turtles all the way down. Whith all that in mind - * remember that given the wrong pointer/offset couple this macro will - * happilly churn all you memory untill SEGFAULT stops it, in other words - * caveat emptor. - * - * It is worth mentioning that one of legitimate use-cases for that wrapper - * is operation on opaque types with known offset for `struct list_node' - * member(preferably 0), because it allows you not to disclose the type of - * @i. - * - * Example: - * list_for_each_off(&parent->children, child, - * offsetof(struct child, list)) - * printf("Name: %s\n", child->name); - */ -#define list_for_each_off(h, i, off) \ - list_for_each_off_dir_((h),(i),(off),next) - -/** - * list_for_each_rev_off - iterate through a list of memory regions backwards - * @h: the list_head - * @i: the pointer to a memory region wich contains list node data. - * @off: offset(relative to @i) at which list node data resides. - * - * See list_for_each_off for details - */ -#define list_for_each_rev_off(h, i, off) \ - list_for_each_off_dir_((h),(i),(off),prev) - -/** - * list_for_each_safe_off - iterate through a list of memory regions, maybe - * during deletion - * @h: the list_head - * @i: the pointer to a memory region wich contains list node data. - * @nxt: the structure containing the list_node - * @off: offset(relative to @i) at which list node data resides. - * - * For details see `list_for_each_off' and `list_for_each_safe' - * descriptions. - * - * Example: - * list_for_each_safe_off(&parent->children, child, - * next, offsetof(struct child, list)) - * printf("Name: %s\n", child->name); - */ -#define list_for_each_safe_off(h, i, nxt, off) \ - list_for_each_safe_off_dir_((h),(i),(nxt),(off),next) - -/** - * list_for_each_rev_safe_off - iterate backwards through a list of - * memory regions, maybe during deletion - * @h: the list_head - * @i: the pointer to a memory region wich contains list node data. - * @nxt: the structure containing the list_node - * @off: offset(relative to @i) at which list node data resides. - * - * For details see `list_for_each_rev_off' and `list_for_each_rev_safe' - * descriptions. - * - * Example: - * list_for_each_rev_safe_off(&parent->children, child, - * next, offsetof(struct child, list)) - * printf("Name: %s\n", child->name); - */ -#define list_for_each_rev_safe_off(h, i, nxt, off) \ - list_for_each_safe_off_dir_((h),(i),(nxt),(off),prev) - -/* Other -off variants. */ -#define list_entry_off(n, type, off) \ - ((type *)list_node_from_off_((n), (off))) - -#define list_head_off(h, type, off) \ - ((type *)list_head_off((h), (off))) - -#define list_tail_off(h, type, off) \ - ((type *)list_tail_((h), (off))) - -#define list_add_off(h, n, off) \ - list_add((h), list_node_from_off_((n), (off))) - -#define list_del_off(n, off) \ - list_del(list_node_from_off_((n), (off))) - -#define list_del_from_off(h, n, off) \ - list_del_from(h, list_node_from_off_((n), (off))) - -/* Offset helper functions so we only single-evaluate. */ -static inline void *list_node_to_off_(struct list_node *node, size_t off) -{ - return (void *)((char *)node - off); -} -static inline struct list_node *list_node_from_off_(void *ptr, size_t off) -{ - return (struct list_node *)((char *)ptr + off); -} - -/* Get the offset of the member, but make sure it's a list_node. */ -#define list_off_(type, member) \ - (container_off(type, member) + \ - check_type(((type *)0)->member, struct list_node)) - -#define list_off_var_(var, member) \ - (container_off_var(var, member) + \ - check_type(var->member, struct list_node)) - -#if HAVE_TYPEOF -#define list_typeof(var) typeof(var) -#else -#define list_typeof(var) void * -#endif - -/* Returns member, or NULL if at end of list. */ -static inline void *list_entry_or_null(const struct list_head *h, - const struct list_node *n, - size_t off) -{ - if (n == &h->n) - return NULL; - return (char *)n - off; -} -#endif /* CCAN_LIST_H */ diff --git a/usr/rdma-core/ccan/minmax.h b/usr/rdma-core/ccan/minmax.h deleted file mode 100644 index ab6c55472..000000000 --- a/usr/rdma-core/ccan/minmax.h +++ /dev/null @@ -1,65 +0,0 @@ -/* CC0 (Public domain) - see LICENSE.CC0 file for details */ -#ifndef CCAN_MINMAX_H -#define CCAN_MINMAX_H - -#include "config.h" - -#include - -#if !HAVE_STATEMENT_EXPR || !HAVE_TYPEOF -/* - * Without these, there's no way to avoid unsafe double evaluation of - * the arguments - */ -#error Sorry, minmax module requires statement expressions and typeof -#endif - -#if HAVE_BUILTIN_TYPES_COMPATIBLE_P -#define MINMAX_ASSERT_COMPATIBLE(a, b) \ - BUILD_ASSERT(__builtin_types_compatible_p(a, b)) -#else -#define MINMAX_ASSERT_COMPATIBLE(a, b) \ - do { } while (0) -#endif - -#define min(a, b) \ - ({ \ - typeof(a) _a = (a); \ - typeof(b) _b = (b); \ - MINMAX_ASSERT_COMPATIBLE(typeof(_a), typeof(_b)); \ - _a < _b ? _a : _b; \ - }) - -#define max(a, b) \ - ({ \ - typeof(a) _a = (a); \ - typeof(b) _b = (b); \ - MINMAX_ASSERT_COMPATIBLE(typeof(_a), typeof(_b)); \ - _a > _b ? _a : _b; \ - }) - -#define clamp(v, f, c) (max(min((v), (c)), (f))) - - -#define min_t(t, a, b) \ - ({ \ - t _ta = (a); \ - t _tb = (b); \ - min(_ta, _tb); \ - }) -#define max_t(t, a, b) \ - ({ \ - t _ta = (a); \ - t _tb = (b); \ - max(_ta, _tb); \ - }) - -#define clamp_t(t, v, f, c) \ - ({ \ - t _tv = (v); \ - t _tf = (f); \ - t _tc = (c); \ - clamp(_tv, _tf, _tc); \ - }) - -#endif /* CCAN_MINMAX_H */ diff --git a/usr/rdma-core/ccan/str.c b/usr/rdma-core/ccan/str.c deleted file mode 100644 index 3da90f4d0..000000000 --- a/usr/rdma-core/ccan/str.c +++ /dev/null @@ -1,13 +0,0 @@ -/* CC0 (Public domain) - see LICENSE.CC0 file for details */ -#include - -size_t strcount(const char *haystack, const char *needle) -{ - size_t i = 0, nlen = strlen(needle); - - while ((haystack = strstr(haystack, needle)) != NULL) { - i++; - haystack += nlen; - } - return i; -} diff --git a/usr/rdma-core/ccan/str.h b/usr/rdma-core/ccan/str.h deleted file mode 100644 index 68c8a518b..000000000 --- a/usr/rdma-core/ccan/str.h +++ /dev/null @@ -1,228 +0,0 @@ -/* CC0 (Public domain) - see LICENSE.CC0 file for details */ -#ifndef CCAN_STR_H -#define CCAN_STR_H -#include "config.h" -#include -#include -#include -#include - -/** - * streq - Are two strings equal? - * @a: first string - * @b: first string - * - * This macro is arguably more readable than "!strcmp(a, b)". - * - * Example: - * if (streq(somestring, "")) - * printf("String is empty!\n"); - */ -#define streq(a,b) (strcmp((a),(b)) == 0) - -/** - * strstarts - Does this string start with this prefix? - * @str: string to test - * @prefix: prefix to look for at start of str - * - * Example: - * if (strstarts(somestring, "foo")) - * printf("String %s begins with 'foo'!\n", somestring); - */ -#define strstarts(str,prefix) (strncmp((str),(prefix),strlen(prefix)) == 0) - -/** - * strends - Does this string end with this postfix? - * @str: string to test - * @postfix: postfix to look for at end of str - * - * Example: - * if (strends(somestring, "foo")) - * printf("String %s end with 'foo'!\n", somestring); - */ -static inline bool strends(const char *str, const char *postfix) -{ - if (strlen(str) < strlen(postfix)) - return false; - - return streq(str + strlen(str) - strlen(postfix), postfix); -} - -/** - * stringify - Turn expression into a string literal - * @expr: any C expression - * - * Example: - * #define PRINT_COND_IF_FALSE(cond) \ - * ((cond) || printf("%s is false!", stringify(cond))) - */ -#define stringify(expr) stringify_1(expr) -/* Double-indirection required to stringify expansions */ -#define stringify_1(expr) #expr - -/** - * strcount - Count number of (non-overlapping) occurrences of a substring. - * @haystack: a C string - * @needle: a substring - * - * Example: - * assert(strcount("aaa aaa", "a") == 6); - * assert(strcount("aaa aaa", "ab") == 0); - * assert(strcount("aaa aaa", "aa") == 2); - */ -size_t strcount(const char *haystack, const char *needle); - -/** - * STR_MAX_CHARS - Maximum possible size of numeric string for this type. - * @type_or_expr: a pointer or integer type or expression. - * - * This provides enough space for a nul-terminated string which represents the - * largest possible value for the type or expression. - * - * Note: The implementation adds extra space so hex values or negative - * values will fit (eg. sprintf(... "%p"). ) - * - * Example: - * char str[STR_MAX_CHARS(int)]; - * - * sprintf(str, "%i", 7); - */ -#define STR_MAX_CHARS(type_or_expr) \ - ((sizeof(type_or_expr) * CHAR_BIT + 8) / 9 * 3 + 2 \ - + STR_MAX_CHARS_TCHECK_(type_or_expr)) - -#if HAVE_TYPEOF -/* Only a simple type can have 0 assigned, so test that. */ -#define STR_MAX_CHARS_TCHECK_(type_or_expr) \ - ({ typeof(type_or_expr) x = 0; (void)x; 0; }) -#else -#define STR_MAX_CHARS_TCHECK_(type_or_expr) 0 -#endif - -/** - * cisalnum - isalnum() which takes a char (and doesn't accept EOF) - * @c: a character - * - * Surprisingly, the standard ctype.h isalnum() takes an int, which - * must have the value of EOF (-1) or an unsigned char. This variant - * takes a real char, and doesn't accept EOF. - */ -static inline bool cisalnum(char c) -{ - return isalnum((unsigned char)c); -} -static inline bool cisalpha(char c) -{ - return isalpha((unsigned char)c); -} -static inline bool cisascii(char c) -{ - return isascii((unsigned char)c); -} -#if HAVE_ISBLANK -static inline bool cisblank(char c) -{ - return isblank((unsigned char)c); -} -#endif -static inline bool ciscntrl(char c) -{ - return iscntrl((unsigned char)c); -} -static inline bool cisdigit(char c) -{ - return isdigit((unsigned char)c); -} -static inline bool cisgraph(char c) -{ - return isgraph((unsigned char)c); -} -static inline bool cislower(char c) -{ - return islower((unsigned char)c); -} -static inline bool cisprint(char c) -{ - return isprint((unsigned char)c); -} -static inline bool cispunct(char c) -{ - return ispunct((unsigned char)c); -} -static inline bool cisspace(char c) -{ - return isspace((unsigned char)c); -} -static inline bool cisupper(char c) -{ - return isupper((unsigned char)c); -} -static inline bool cisxdigit(char c) -{ - return isxdigit((unsigned char)c); -} - -#include - -/* These checks force things out of line, hence they are under DEBUG. */ -#ifdef CCAN_STR_DEBUG -#include - -/* These are commonly misused: they take -1 or an *unsigned* char value. */ -#undef isalnum -#undef isalpha -#undef isascii -#undef isblank -#undef iscntrl -#undef isdigit -#undef isgraph -#undef islower -#undef isprint -#undef ispunct -#undef isspace -#undef isupper -#undef isxdigit - -/* You can use a char if char is unsigned. */ -#if HAVE_BUILTIN_TYPES_COMPATIBLE_P && HAVE_TYPEOF -#define str_check_arg_(i) \ - ((i) + BUILD_ASSERT_OR_ZERO(!__builtin_types_compatible_p(typeof(i), \ - char) \ - || (char)255 > 0)) -#else -#define str_check_arg_(i) (i) -#endif - -#define isalnum(i) str_isalnum(str_check_arg_(i)) -#define isalpha(i) str_isalpha(str_check_arg_(i)) -#define isascii(i) str_isascii(str_check_arg_(i)) -#if HAVE_ISBLANK -#define isblank(i) str_isblank(str_check_arg_(i)) -#endif -#define iscntrl(i) str_iscntrl(str_check_arg_(i)) -#define isdigit(i) str_isdigit(str_check_arg_(i)) -#define isgraph(i) str_isgraph(str_check_arg_(i)) -#define islower(i) str_islower(str_check_arg_(i)) -#define isprint(i) str_isprint(str_check_arg_(i)) -#define ispunct(i) str_ispunct(str_check_arg_(i)) -#define isspace(i) str_isspace(str_check_arg_(i)) -#define isupper(i) str_isupper(str_check_arg_(i)) -#define isxdigit(i) str_isxdigit(str_check_arg_(i)) - -#if HAVE_TYPEOF -/* With GNU magic, we can make const-respecting standard string functions. */ -#undef strstr -#undef strchr -#undef strrchr - -/* + 0 is needed to decay array into pointer. */ -#define strstr(haystack, needle) \ - ((typeof((haystack) + 0))str_strstr((haystack), (needle))) -#define strchr(haystack, c) \ - ((typeof((haystack) + 0))str_strchr((haystack), (c))) -#define strrchr(haystack, c) \ - ((typeof((haystack) + 0))str_strrchr((haystack), (c))) -#endif -#endif /* CCAN_STR_DEBUG */ - -#endif /* CCAN_STR_H */ diff --git a/usr/rdma-core/ccan/str_debug.h b/usr/rdma-core/ccan/str_debug.h deleted file mode 100644 index 7a3343816..000000000 --- a/usr/rdma-core/ccan/str_debug.h +++ /dev/null @@ -1,30 +0,0 @@ -/* CC0 (Public domain) - see LICENSE.CC0 file for details */ -#ifndef CCAN_STR_DEBUG_H -#define CCAN_STR_DEBUG_H - -/* #define CCAN_STR_DEBUG 1 */ - -#ifdef CCAN_STR_DEBUG -/* Because we mug the real ones with macros, we need our own wrappers. */ -int str_isalnum(int i); -int str_isalpha(int i); -int str_isascii(int i); -#if HAVE_ISBLANK -int str_isblank(int i); -#endif -int str_iscntrl(int i); -int str_isdigit(int i); -int str_isgraph(int i); -int str_islower(int i); -int str_isprint(int i); -int str_ispunct(int i); -int str_isspace(int i); -int str_isupper(int i); -int str_isxdigit(int i); - -char *str_strstr(const char *haystack, const char *needle); -char *str_strchr(const char *s, int c); -char *str_strrchr(const char *s, int c); -#endif /* CCAN_STR_DEBUG */ - -#endif /* CCAN_STR_DEBUG_H */ diff --git a/usr/rdma-core/debian/changelog b/usr/rdma-core/debian/changelog deleted file mode 100644 index 9ee7fe16d..000000000 --- a/usr/rdma-core/debian/changelog +++ /dev/null @@ -1,7 +0,0 @@ -rdma-core (16-1) unstable; urgency=low - - * New version. - * Adding debian/copyright. - * Close ITP (Closes: #848971). - - -- Jason Gunthorpe Mon, 12 Sep 2016 13:44:24 -0600 diff --git a/usr/rdma-core/debian/compat b/usr/rdma-core/debian/compat deleted file mode 100644 index ec635144f..000000000 --- a/usr/rdma-core/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/usr/rdma-core/debian/control b/usr/rdma-core/debian/control deleted file mode 100644 index fef59ad5b..000000000 --- a/usr/rdma-core/debian/control +++ /dev/null @@ -1,348 +0,0 @@ -Source: rdma-core -Maintainer: Linux RDMA Mailing List -Uploaders: Benjamin Drung , - Talat Batheesh -Section: net -Priority: optional -Build-Depends: cmake (>= 2.8.11), - debhelper (>= 9), - dh-systemd, - dpkg-dev (>= 1.17), - libnl-3-dev, - libnl-route-3-dev, - libsystemd-dev, - libudev-dev, - ninja-build, - pkg-config, - python, - valgrind -Standards-Version: 4.1.0 -Vcs-Git: https://github.com/linux-rdma/rdma-core.git -Vcs-Browser: https://github.com/linux-rdma/rdma-core -Homepage: https://github.com/linux-rdma/rdma-core - -Package: rdma-core -Architecture: linux-any -Depends: lsb-base (>= 3.2-14~), - ${misc:Depends}, - ${perl:Depends}, - ${shlibs:Depends} -Recommends: dmidecode, ethtool, net-tools -Breaks: infiniband-diags (<< 2.0.0) -Replaces: infiniband-diags (<< 2.0.0) -Description: RDMA core userspace infrastructure and documentation - This package provides the basic boot time support for systems that use the - Linux kernel's remote direct memory access (RDMA) subystem which includes - InfiniBand, iWARP, and RDMA over Converged Ethernet (RoCE). - . - Several kernel RDMA support daemons are included: - - The rdma-ndd daemon which watches for RDMA device changes and/or hostname - changes and updates the Node Description of the RDMA devices based on - those changes. - - The iWARP Port Mapper Daemon (iwpmd) which provides a kernel support - service in userspace for iWARP drivers to claim TCP ports through the - standard socket interface. - -Package: ibacm -Architecture: any -Depends: lsb-base (>= 3.2-14~), - rdma-core (>= 15), - ${misc:Depends}, - ${shlibs:Depends} -Description: InfiniBand Communication Manager Assistant (ACM) - The IB ACM implements and provides a framework for name, address, and - route (path) resolution services over InfiniBand. - It is intended to address connection setup scalability issues running - MPI applications on large clusters. The IB ACM provides information - needed to establish a connection, but does not implement the CM protocol. - A primary user of the ibacm service is the librdmacm library. - -Package: ibverbs-providers -Architecture: linux-any -Multi-Arch: same -Depends: ${misc:Depends}, ${shlibs:Depends} -Provides: libcxgb3-1, libipathverbs1, libmlx4-1, libmlx5-1, libmthca1, libnes1 -Replaces: libcxgb3-1, libipathverbs1, libmlx4-1, libmlx5-1, libmthca1, libnes1 -Breaks: libcxgb3-1, libipathverbs1, libmlx4-1, libmlx5-1, libmthca1, libnes1 -Description: User space provider drivers for libibverbs - libibverbs is a library that allows userspace processes to use RDMA - "verbs" as described in the InfiniBand Architecture Specification and - the RDMA Protocol Verbs Specification. iWARP ethernet NICs support - RDMA over hardware-offloaded TCP/IP, while InfiniBand is a - high-throughput, low-latency networking technology. InfiniBand host - channel adapters (HCAs) and iWARP NICs commonly support direct - hardware access from userspace (kernel bypass), and libibverbs - supports this when available. - . - A RDMA driver consists of a kernel portion and a user space portion. - This package contains the user space verbs drivers: - . - - bnxt_re: Broadcom NetXtreme-E RoCE HCAs - - cxgb3: Chelsio T3 iWARP HCAs - - cxgb4: Chelsio T4 iWARP HCAs - - hfi1verbs: Intel Omni-Path HFI - - hns: HiSilicon Hip06 SoC - - i40iw: Intel Ethernet Connection X722 RDMA - - ipathverbs: QLogic InfiniPath HCAs - - mlx4: Mellanox ConnectX-3 InfiniBand HCAs - - mlx5: Mellanox Connect-IB/X-4+ InfiniBand HCAs - - mthca: Mellanox InfiniBand HCAs - - nes: Intel NetEffect NE020-based iWARP adapters - - ocrdma: Emulex OneConnect RDMA/RoCE device - - qedr: QLogic QL4xxx RoCE HCAs - - rxe: A software implementation of the RoCE protocol - - vmw_pvrdma: VMware paravirtual RDMA device - -Package: ibverbs-utils -Architecture: linux-any -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: Examples for the libibverbs library - libibverbs is a library that allows userspace processes to use RDMA - "verbs" as described in the InfiniBand Architecture Specification and - the RDMA Protocol Verbs Specification. iWARP ethernet NICs support - RDMA over hardware-offloaded TCP/IP, while InfiniBand is a - high-throughput, low-latency networking technology. InfiniBand host - channel adapters (HCAs) and iWARP NICs commonly support direct - hardware access from userspace (kernel bypass), and libibverbs - supports this when available. - . - This package contains useful libibverbs1 example programs such as - ibv_devinfo, which displays information about InfiniBand devices. - -Package: libibverbs-dev -Section: libdevel -Architecture: linux-any -Multi-Arch: same -Depends: ibverbs-providers (= ${binary:Version}), - libibverbs1 (= ${binary:Version}), - ${misc:Depends} -Description: Development files for the libibverbs library - libibverbs is a library that allows userspace processes to use RDMA - "verbs" as described in the InfiniBand Architecture Specification and - the RDMA Protocol Verbs Specification. iWARP ethernet NICs support - RDMA over hardware-offloaded TCP/IP, while InfiniBand is a - high-throughput, low-latency networking technology. InfiniBand host - channel adapters (HCAs) and iWARP NICs commonly support direct - hardware access from userspace (kernel bypass), and libibverbs - supports this when available. - . - This package is needed to compile programs against libibverbs1. - It contains the header files and static libraries (optionally) - needed for compiling. - -Package: libibverbs1 -Architecture: linux-any -Multi-Arch: same -Section: libs -Pre-Depends: ${misc:Pre-Depends} -Depends: adduser, ${misc:Depends}, ${shlibs:Depends} -Recommends: ibverbs-providers -Breaks: ibverbs-providers (<< 14) -Description: Library for direct userspace use of RDMA (InfiniBand/iWARP) - libibverbs is a library that allows userspace processes to use RDMA - "verbs" as described in the InfiniBand Architecture Specification and - the RDMA Protocol Verbs Specification. iWARP ethernet NICs support - RDMA over hardware-offloaded TCP/IP, while InfiniBand is a - high-throughput, low-latency networking technology. InfiniBand host - channel adapters (HCAs) and iWARP NICs commonly support direct - hardware access from userspace (kernel bypass), and libibverbs - supports this when available. - . - For this library to be useful, a device-specific plug-in module - should also be installed. - . - This package contains the shared library. - -Package: libibverbs1-dbg -Section: debug -Priority: extra -Architecture: linux-any -Multi-Arch: same -Depends: libibverbs1 (= ${binary:Version}), ${misc:Depends} -Description: Debug symbols for the libibverbs library - libibverbs is a library that allows userspace processes to use RDMA - "verbs" as described in the InfiniBand Architecture Specification and - the RDMA Protocol Verbs Specification. iWARP ethernet NICs support - RDMA over hardware-offloaded TCP/IP, while InfiniBand is a - high-throughput, low-latency networking technology. InfiniBand host - channel adapters (HCAs) and iWARP NICs commonly support direct - hardware access from userspace (kernel bypass), and libibverbs - supports this when available. - . - This package contains the debug symbols associated with - libibverbs1. They will automatically be used by gdb for debugging - libibverbs-related issues. - -Package: libibcm-dev -Section: libdevel -Architecture: linux-any -Depends: libibcm1 (= ${binary:Version}), libibverbs-dev, ${misc:Depends} -Description: Development files for the libibcm library - libibcm provides a userspace implementation of an InfiniBand - Communication Manager (CM). The CM handles both connection - establishment as well as service ID resolution. - . - This package is needed to compile programs against libibcm1. - It contains the header files and static libraries (optionally) - needed for compiling. - -Package: libibcm1 -Architecture: linux-any -Section: libs -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: InfiniBand Communication Manager (CM) library - libibcm provides a userspace implementation of an InfiniBand - Communication Manager (CM). The CM handles both connection - establishment as well as service ID resolution. - . - This package contains the shared library. - -Package: libibcm1-dbg -Section: debug -Priority: extra -Architecture: linux-any -Depends: libibcm1 (= ${binary:Version}), ${misc:Depends} -Description: Debug symbols for the libibcm1 library - libibcm provides a userspace implementation of an InfiniBand - Communication Manager (CM). The CM handles both connection - establishment as well as service ID resolution. - . - This package contains the debug symbols associated with - libibcm1. They will automatically be used by gdb for debugging - libibcm-related issues. - -Package: libibumad-dev -Section: libdevel -Architecture: linux-any -Depends: libibumad3 (= ${binary:Version}), ${misc:Depends} -Description: Development files for libibumad - libibumad provides userspace Infiniband Management Datagram (uMAD) - functions which sit on top of the uMAD modules in the kernel. - These are used by InfiniBand diagnostic and management tools. - . - This package is needed to compile programs against libibumad. - It contains the header files and static libraries (optionally) - needed for compiling. - -Package: libibumad3 -Architecture: linux-any -Section: libs -Pre-Depends: ${misc:Pre-Depends} -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: InfiniBand Userspace Management Datagram (uMAD) library - libibumad provides userspace Infiniband Management Datagram (uMAD) - functions which sit on top of the uMAD modules in the kernel. - These are used by InfiniBand diagnostic and management tools. - . - This package contains the shared library. - -Package: libibumad3-dbg -Section: debug -Priority: extra -Architecture: linux-any -Depends: libibumad3 (= ${binary:Version}), ${misc:Depends} -Description: Debug symbols for the libibumad3 library - libibumad provides userspace Infiniband Management Datagram (uMAD) - functions which sit on top of the uMAD modules in the kernel. - These are used by InfiniBand diagnostic and management tools. - . - This package contains the debug symbols associated with - libibumad3. They will automatically be used by gdb for debugging - libibumad-related issues. - -Package: librdmacm-dev -Section: libdevel -Architecture: linux-any -Depends: libibverbs-dev, librdmacm1 (= ${binary:Version}), ${misc:Depends} -Description: Development files for the librdmacm library - librdmacm is a library that allows applications to set up reliable - connected and unreliable datagram transfers when using RDMA adapters. - It provides a transport-neutral interface in the sense that the same - code can be used for both InfiniBand and iWARP adapters. The - interface is based on sockets, but adapted for queue pair (QP) based - semantics: communication must use a specific RDMA device, and data - transfers are message-based. - . - librdmacm only provides communication management (connection setup - and tear-down) and works in conjunction with the verbs interface - provided by libibverbs, which provides the interface used to actually - transfer data. - . - This package is needed to compile programs against librdmacm1. - It contains the header files and static libraries (optionally) - needed for compiling. - -Package: librdmacm1 -Architecture: linux-any -Section: libs -Pre-Depends: ${misc:Pre-Depends} -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: Library for managing RDMA connections - librdmacm is a library that allows applications to set up reliable - connected and unreliable datagram transfers when using RDMA adapters. - It provides a transport-neutral interface in the sense that the same - code can be used for both InfiniBand and iWARP adapters. The - interface is based on sockets, but adapted for queue pair (QP) based - semantics: communication must use a specific RDMA device, and data - transfers are message-based. - . - librdmacm only provides communication management (connection setup - and tear-down) and works in conjunction with the verbs interface - provided by libibverbs, which provides the interface used to actually - transfer data. - . - This package contains the shared library. - -Package: librdmacm1-dbg -Section: debug -Priority: extra -Architecture: linux-any -Depends: librdmacm1 (= ${binary:Version}), ${misc:Depends} -Description: Debug symbols for the librdmacm library - librdmacm is a library that allows applications to set up reliable - connected and unreliable datagram transfers when using RDMA adapters. - It provides a transport-neutral interface in the sense that the same - code can be used for both InfiniBand and iWARP adapters. The - interface is based on sockets, but adapted for queue pair (QP) based - semantics: communication must use a specific RDMA device, and data - transfers are message-based. - . - librdmacm only provides communication management (connection setup - and tear-down) and works in conjunction with the verbs interface - provided by libibverbs, which provides the interface used to actually - transfer data. - . - This package contains the debug symbols associated with - librdmacm1. They will automatically be used by gdb for debugging - librdmacm-related issues. - -Package: rdmacm-utils -Architecture: linux-any -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: Examples for the librdmacm library - librdmacm is a library that allows applications to set up reliable - connected and unreliable datagram transfers when using RDMA adapters. - It provides a transport-neutral interface in the sense that the same - code can be used for both InfiniBand and iWARP adapters. The - interface is based on sockets, but adapted for queue pair (QP) based - semantics: communication must use a specific RDMA device, and data - transfers are message-based. - . - librdmacm only provides communication management (connection setup - and tear-down) and works in conjunction with the verbs interface - provided by libibverbs, which provides the interface used to actually - transfer data. - . - This package contains useful librdmacm1 example programs such as - rping and udaddy. - -Package: srptools -Architecture: linux-any -Depends: lsb-base (>= 3.2-14~), - rdma-core (>= 15), - ${misc:Depends}, - ${shlibs:Depends} -Description: Tools for Infiniband attached storage (SRP) - In conjunction with the kernel ib_srp driver, srptools allows you to - discover and use Infiniband attached storage devices which use the - SCSI RDMA Protocol (SRP). diff --git a/usr/rdma-core/debian/copyright b/usr/rdma-core/debian/copyright deleted file mode 100644 index 5546882be..000000000 --- a/usr/rdma-core/debian/copyright +++ /dev/null @@ -1,663 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: rdma-core -Upstream-Contact: Doug Ledford , - Leon Romanovsky -Source: https://github.com/linux-rdma/rdma-core - -Files: * -Copyright: disclaimed -License: BSD-MIT or GPL-2 - -Files: debian/* -Copyright: 2008, Genome Research Ltd - 2014, Ana Beatriz Guerrero Lopez - 2015-2016, Jason Gunthorpe - 2016-2017, Benjamin Drung - 2016-2017, Talat Batheesh -License: GPL-2+ - 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - . - On Debian systems, the full text of the GNU General Public License - version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. - -Files: CMakeLists.txt -Copyright: 2015-2017, Obsidian Research Corporation. -License: BSD-MIT or GPL-2 - -Files: buildlib/* -Copyright: 2015-2017, Obsidian Research Corporation. - 2016-2017 Mellanox Technologies, Inc -License: BSD-MIT or GPL-2 - -Files: buildlib/fixup-include/rdma-vmw_pvrdma-abi.h -Copyright: 2012-2016 VMware, Inc. -License: BSD-2-clause or GPL-2 - -Files: buildlib/fixup-include/stdatomic.h -Copyright: 2011 Ed Schouten - David Chisnall -License: BSD-2-clause - -Files: ccan/* -Copyright: unspecified -License: CC0 - -Files: ccan/list.* -Copyright: unspecified -License: MIT - -Files: ibacm/* -Copyright: 2009-2014, Intel Corporation. - 2013, Mellanox Technologies LTD. -License: BSD-MIT - -Files: ibacm/man/* - ibacm/ibacm.init.in -Copyright: disclaimed -License: BSD-2-clause - -Files: ibacm/CMakeLists.txt - ibacm/ibacm_hosts.data -Copyright: disclaimed -License: BSD-MIT or GPL-2 - -Files: iwpmd/* -Copyright: 2013-2016, Intel Corporation. -License: BSD-MIT or GPL-2 - -Files: libibcm/* -Copyright: 2004-2006, Intel Corporation. - 2004-2005, Topspin Communications. - 2004, Voltaire Corporation. -License: BSD-MIT or GPL-2 - -Files: libibumad/* -Copyright: 2004-2017, Mellanox Technologies Ltd. - 2004, Infinicon Corporation. - 2004-2014, Intel Corporation. - 2004, Topspin Corporation. - 2004-2009, Voltaire Inc. - 2013 Lawrence Livermore National Security - 2013, Oracle and/or its affiliates. -License: BSD-MIT or GPL-2 - -Files: libibumad/man/* -Copyright: disclaimed -License: BSD-2-clause - -Files: libibverbs/* -Copyright: 2004-2012, Intel Corporation. - 2004-2005, Topspin Communications. - 2005-2007, Cisco Systems, Inc. - 2005, PathScale, Inc. - 2005, Mellanox Technologies Ltd. - 2005, Voltaire, Inc. - 2008, Lawrence Livermore National Laboratory. -License: BSD-MIT or GPL-2 - -Files: libibverbs/man/* - libibverbs/neigh.h - libibverbs/nl1_compat.h - libibverbs/neigh.c -Copyright: disclaimed -License: BSD-2-clause - -Files: librdmacm/* -Copyright: 2005-2014, Intel Corporation. - 2005, Ammasso, Inc. - 2005, Voltaire Inc. - 2006, Open Grid Computing, Inc. - 2014-2015, Mellanox Technologies LTD. -License: BSD-MIT or GPL-2 - -Files: librdmacm/examples/cmtime.c - librdmacm/examples/rcopy.c - librdmacm/examples/rdma_client.c - librdmacm/examples/rdma_server.c - librdmacm/examples/rdma_xclient.c - librdmacm/examples/rdma_xserver.c - librdmacm/examples/riostream.c - librdmacm/examples/rstream.c - librdmacm/examples/udpong.c -Copyright: 2005-2014, Intel Corporation. - 2014-2015, Mellanox Technologies LTD. -License: BSD-MIT - -Files: librdmacm/docs/rsocket -Copyright: disclaimed -License: BSD-2-clause - -Files: librdmacm/man/* -Copyright: disclaimed -License: BSD-2-clause - -Files: providers/bnxt_re/* -Copyright: 2015-2017, Broadcom Limited and/or its subsidiaries -License: BSD-2-clause or GPL-2 - -Files: providers/cxgb3/* - providers/cxgb4/* -Copyright: 2003-2016, Chelsio Communications, Inc. -License: BSD-MIT or GPL-2 - -Files: providers/hfi1verbs/* -Copyright: 2005 PathScale, Inc. - 2006-2009 QLogic Corporation - 2015 Intel Corporation -License: BSD-3-clause or GPL-2 - -Files: providers/hns/* -Copyright: 2016, Hisilicon Limited. -License: BSD-MIT or GPL-2 - -Files: providers/i40iw/* -Copyright: 2015-2016, Intel Corporation. -License: BSD-MIT or GPL-2 - -Files: providers/ipathverbs/* -Copyright: 2006-2010, QLogic Corp. - 2005, PathScale, Inc. - 2013, Intel Corporation -License: BSD-MIT or GPL-2 - -Files: providers/mlx4/* -Copyright: 2004-2005, Topspin Communications. - 2005-2007, Cisco, Inc. - 2005-2017, Mellanox Technologies Ltd. -License: BSD-MIT or GPL-2 - -Files: providers/mlx5/* -Copyright: 2010-2017, Mellanox Technologies, Inc. -License: BSD-MIT or GPL-2 - -Files: providers/mlx5/man/*.3 - providers/mlx5/man/*.7 -Copyright: disclaimed -License: BSD-MIT - -Files: providers/mthca/* -Copyright: 2004-2005, Topspin Communications. - 2005-2006, Cisco Systems. - 2005, Mellanox Technologies Ltd. -License: BSD-MIT or GPL-2 - -Files: providers/nes/* -Copyright: 2006-2010, Intel Corporation. - 2006, Open Grid Computing, Inc. -License: BSD-MIT or GPL-2 - -Files: providers/ocrdma/* -Copyright: 2008-2013, Emulex. -License: BSD-2-clause or GPL-2 - -Files: providers/qedr/* -Copyright: 2015-2016, QLogic Corporation. -License: BSD-MIT or GPL-2 - -Files: providers/rxe/* -Copyright: 2009-2011, System Fabric Works, Inc. - 2009-2011, Mellanox Technologies Ltd. - 2006-2007, QLogic Corporation. - 2005, PathScale, Inc. -License: BSD-MIT or GPL-2 - -Files: providers/vmw_pvrdma/* -Copyright: 2012-2016 VMware, Inc. -License: BSD-2-clause or GPL-2 - -Files: rdma-ndd/* -Copyright: 2004-2016, Intel Corporation. -License: BSD-MIT or GPL-2 - -Files: redhat/* -Copyright: 1996-2013, Red Hat, Inc. -License: GPL-2 - -Files: srp_daemon/* -Copyright: 2005, Topspin Communications. - 2006, Cisco Systems, Inc. - 2006, Mellanox Technologies Ltd. -License: BSD-MIT or GPL-2 - -Files: srp_daemon/srp_daemon.1.in -Copyright: 2006 Mellanox Technologies. -License: CPL-1.0 or BSD-2-clause or GPL-2 - -Files: srp_daemon/srpd.in - srp_daemon/ibsrpdm.1 -Copyright: disclaimed -License: BSD-2-clause - -Files: util/udma_barrier.h -Copyright: 2005 Topspin Communications. -License: BSD-MIT or GPL-2 - -License: BSD-MIT - OpenIB.org BSD license (MIT variant) - . - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - . - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - . - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - -License: BSD-2-clause - OpenIB.org BSD license (FreeBSD Variant) - . - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - . - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - . - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - . - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -License: BSD-3-clause - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - . - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - . - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -License: GPL-2 - 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; version 2 of the License. - . - 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - . - On Debian systems, the full text of the GNU General Public License - version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. - -License: CC0 - The laws of most jurisdictions throughout the world automatically confer - exclusive Copyright and Related Rights (defined below) upon the creator and - subsequent owner(s) (each and all, an "owner") of an original work of - authorship and/or a database (each, a "Work"). - . - Certain owners wish to permanently relinquish those rights to a Work for the - purpose of contributing to a commons of creative, cultural and scientific works - ("Commons") that the public can reliably and without fear of later claims of - infringement build upon, modify, incorporate in other works, reuse and - redistribute as freely as possible in any form whatsoever and for any purposes, - including without limitation commercial purposes. These owners may contribute - to the Commons to promote the ideal of a free culture and the further - production of creative, cultural and scientific works, or to gain reputation or - greater distribution for their Work in part through the use and efforts of - others. - . - For these and/or other purposes and motivations, and without any expectation of - additional consideration or compensation, the person associating CC0 with a - Work (the "Affirmer"), to the extent that he or she is an owner of Copyright - and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and - publicly distribute the Work under its terms, with knowledge of his or her - Copyright and Related Rights in the Work and the meaning and intended legal - effect of CC0 on those rights. - . - 1. Copyright and Related Rights. A Work made available under CC0 may be - protected by copyright and related or neighboring rights ("Copyright and - Related Rights"). Copyright and Related Rights include, but are not limited to, - the following: - . - the right to reproduce, adapt, distribute, perform, display, communicate, - and translate a Work; moral rights retained by the original author(s) and/or - performer(s); publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; rights protecting against unfair competition in - regards to a Work, subject to the limitations in paragraph 4(a), below; rights - protecting the extraction, dissemination, use and reuse of data in a Work; - database rights (such as those arising under Directive 96/9/EC of the European - Parliament and of the Council of 11 March 1996 on the legal protection of - databases, and under any national implementation thereof, including any amended - or successor version of such directive); and other similar, equivalent or - corresponding rights throughout the world based on applicable law or treaty, - and any national implementations thereof. - . - 2. Waiver. To the greatest extent permitted by, but not in contravention of, - applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and - unconditionally waives, abandons, and surrenders all of Affirmer's Copyright - and Related Rights and associated claims and causes of action, whether now - known or unknown (including existing as well as future claims and causes of - action), in the Work (i) in all territories worldwide, (ii) for the maximum - duration provided by applicable law or treaty (including future time - extensions), (iii) in any current or future medium and for any number of - copies, and (iv) for any purpose whatsoever, including without limitation - commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes - the Waiver for the benefit of each member of the public at large and to the - detriment of Affirmer's heirs and successors, fully intending that such Waiver - shall not be subject to revocation, rescission, cancellation, termination, or - any other legal or equitable action to disrupt the quiet enjoyment of the Work - by the public as contemplated by Affirmer's express Statement of Purpose. - . - 3. Public License Fallback. Should any part of the Waiver for any reason be - judged legally invalid or ineffective under applicable law, then the Waiver - shall be preserved to the maximum extent permitted taking into account - Affirmer's express Statement of Purpose. In addition, to the extent the Waiver - is so judged Affirmer hereby grants to each affected person a royalty-free, non - transferable, non sublicensable, non exclusive, irrevocable and unconditional - license to exercise Affirmer's Copyright and Related Rights in the Work (i) in - all territories worldwide, (ii) for the maximum duration provided by applicable - law or treaty (including future time extensions), (iii) in any current or - future medium and for any number of copies, and (iv) for any purpose - whatsoever, including without limitation commercial, advertising or promotional - purposes (the "License"). The License shall be deemed effective as of the date - CC0 was applied by Affirmer to the Work. Should any part of the License for any - reason be judged legally invalid or ineffective under applicable law, such - partial invalidity or ineffectiveness shall not invalidate the remainder of the - License, and in such case Affirmer hereby affirms that he or she will not (i) - exercise any of his or her remaining Copyright and Related Rights in the Work - or (ii) assert any associated claims and causes of action with respect to the - Work, in either case contrary to Affirmer's express Statement of Purpose. - . - 4. Limitations and Disclaimers. - . - No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. Affirmer offers - the Work as-is and makes no representations or warranties of any kind - concerning the Work, express, implied, statutory or otherwise, including - without limitation warranties of title, merchantability, fitness for a - particular purpose, non infringement, or the absence of latent or other - defects, accuracy, or the present or absence of errors, whether or not - discoverable, all to the greatest extent permissible under applicable law. - Affirmer disclaims responsibility for clearing rights of other persons that may - apply to the Work or any use thereof, including without limitation any person's - Copyright and Related Rights in the Work. Further, Affirmer disclaims - responsibility for obtaining any necessary consents, permissions or other - rights required for any use of the Work. Affirmer understands and acknowledges - that Creative Commons is not a party to this document and has no duty or - obligation with respect to this CC0 or use of the Work. - -License: MIT - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - . - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -License: CPL-1.0 - THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC - LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM - CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - . - 1. DEFINITIONS - . - "Contribution" means: - . - a) in the case of the initial Contributor, the initial code and - documentation distributed under this Agreement, and - . - b) in the case of each subsequent Contributor: - . - i) changes to the Program, and - . - ii) additions to the Program; - . - where such changes and/or additions to the Program originate from and are - distributed by that particular Contributor. A Contribution 'originates' from a - Contributor if it was added to the Program by such Contributor itself or anyone - acting on such Contributor's behalf. Contributions do not include additions to - the Program which: (i) are separate modules of software distributed in - conjunction with the Program under their own license agreement, and (ii) are not - derivative works of the Program. - . - "Contributor" means any person or entity that distributes the Program. - . - "Licensed Patents " mean patent claims licensable by a Contributor which are - necessarily infringed by the use or sale of its Contribution alone or when - combined with the Program. - . - "Program" means the Contributions distributed in accordance with this Agreement. - . - "Recipient" means anyone who receives the Program under this Agreement, - including all Contributors. - . - 2. GRANT OF RIGHTS - . - a) Subject to the terms of this Agreement, each Contributor hereby grants - Recipient a non-exclusive, worldwide, royalty-free copyright license to - reproduce, prepare derivative works of, publicly display, publicly perform, - distribute and sublicense the Contribution of such Contributor, if any, and such - derivative works, in source code and object code form. - . - b) Subject to the terms of this Agreement, each Contributor hereby grants - Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed - Patents to make, use, sell, offer to sell, import and otherwise transfer the - Contribution of such Contributor, if any, in source code and object code form. - This patent license shall apply to the combination of the Contribution and the - Program if, at the time the Contribution is added by the Contributor, such - addition of the Contribution causes such combination to be covered by the - Licensed Patents. The patent license shall not apply to any other combinations - which include the Contribution. No hardware per se is licensed hereunder. - . - c) Recipient understands that although each Contributor grants the licenses - to its Contributions set forth herein, no assurances are provided by any - Contributor that the Program does not infringe the patent or other intellectual - property rights of any other entity. Each Contributor disclaims any liability to - Recipient for claims brought by any other entity based on infringement of - intellectual property rights or otherwise. As a condition to exercising the - rights and licenses granted hereunder, each Recipient hereby assumes sole - responsibility to secure any other intellectual property rights needed, if any. - For example, if a third party patent license is required to allow Recipient to - distribute the Program, it is Recipient's responsibility to acquire that license - before distributing the Program. - . - d) Each Contributor represents that to its knowledge it has sufficient - copyright rights in its Contribution, if any, to grant the copyright license set - forth in this Agreement. - . - 3. REQUIREMENTS - . - A Contributor may choose to distribute the Program in object code form under its - own license agreement, provided that: - . - a) it complies with the terms and conditions of this Agreement; and - . - b) its license agreement: - . - i) effectively disclaims on behalf of all Contributors all warranties and - conditions, express and implied, including warranties or conditions of title and - non-infringement, and implied warranties or conditions of merchantability and - fitness for a particular purpose; - . - ii) effectively excludes on behalf of all Contributors all liability for - damages, including direct, indirect, special, incidental and consequential - damages, such as lost profits; - . - iii) states that any provisions which differ from this Agreement are offered - by that Contributor alone and not by any other party; and - . - iv) states that source code for the Program is available from such - Contributor, and informs licensees how to obtain it in a reasonable manner on or - through a medium customarily used for software exchange. - . - When the Program is made available in source code form: - . - a) it must be made available under this Agreement; and - . - b) a copy of this Agreement must be included with each copy of the Program. - . - Contributors may not remove or alter any copyright notices contained within the - Program. - . - Each Contributor must identify itself as the originator of its Contribution, if - any, in a manner that reasonably allows subsequent Recipients to identify the - originator of the Contribution. - . - 4. COMMERCIAL DISTRIBUTION - . - Commercial distributors of software may accept certain responsibilities with - respect to end users, business partners and the like. While this license is - intended to facilitate the commercial use of the Program, the Contributor who - includes the Program in a commercial product offering should do so in a manner - which does not create potential liability for other Contributors. Therefore, if - a Contributor includes the Program in a commercial product offering, such - Contributor ("Commercial Contributor") hereby agrees to defend and indemnify - every other Contributor ("Indemnified Contributor") against any losses, damages - and costs (collectively "Losses") arising from claims, lawsuits and other legal - actions brought by a third party against the Indemnified Contributor to the - extent caused by the acts or omissions of such Commercial Contributor in - connection with its distribution of the Program in a commercial product - offering. The obligations in this section do not apply to any claims or Losses - relating to any actual or alleged intellectual property infringement. In order - to qualify, an Indemnified Contributor must: a) promptly notify the Commercial - Contributor in writing of such claim, and b) allow the Commercial Contributor to - control, and cooperate with the Commercial Contributor in, the defense and any - related settlement negotiations. The Indemnified Contributor may participate in - any such claim at its own expense. - . - For example, a Contributor might include the Program in a commercial product - offering, Product X. That Contributor is then a Commercial Contributor. If that - Commercial Contributor then makes performance claims, or offers warranties - related to Product X, those performance claims and warranties are such - Commercial Contributor's responsibility alone. Under this section, the - Commercial Contributor would have to defend claims against the other - Contributors related to those performance claims and warranties, and if a court - requires any other Contributor to pay any damages as a result, the Commercial - Contributor must pay those damages. - . - 5. NO WARRANTY - . - EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR - IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, - NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each - Recipient is solely responsible for determining the appropriateness of using and - distributing the Program and assumes all risks associated with its exercise of - rights under this Agreement, including but not limited to the risks and costs of - program errors, compliance with applicable laws, damage to or loss of data, - programs or equipment, and unavailability or interruption of operations. - . - 6. DISCLAIMER OF LIABILITY - . - EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY - CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST - PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS - GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - . - 7. GENERAL - . - If any provision of this Agreement is invalid or unenforceable under applicable - law, it shall not affect the validity or enforceability of the remainder of the - terms of this Agreement, and without further action by the parties hereto, such - provision shall be reformed to the minimum extent necessary to make such - provision valid and enforceable. - . - If Recipient institutes patent litigation against a Contributor with respect to - a patent applicable to software (including a cross-claim or counterclaim in a - lawsuit), then any patent licenses granted by that Contributor to such Recipient - under this Agreement shall terminate as of the date such litigation is filed. In - addition, if Recipient institutes patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that the Program - itself (excluding combinations of the Program with other software or hardware) - infringes such Recipient's patent(s), then such Recipient's rights granted under - Section 2(b) shall terminate as of the date such litigation is filed. - . - All Recipient's rights under this Agreement shall terminate if it fails to - comply with any of the material terms or conditions of this Agreement and does - not cure such failure in a reasonable period of time after becoming aware of - such noncompliance. If all Recipient's rights under this Agreement terminate, - Recipient agrees to cease use and distribution of the Program as soon as - reasonably practicable. However, Recipient's obligations under this Agreement - and any licenses granted by Recipient relating to the Program shall continue and - survive. - . - Everyone is permitted to copy and distribute copies of this Agreement, but in - order to avoid inconsistency the Agreement is copyrighted and may only be - modified in the following manner. The Agreement Steward reserves the right to - publish new versions (including revisions) of this Agreement from time to time. - No one other than the Agreement Steward has the right to modify this Agreement. - IBM is the initial Agreement Steward. IBM may assign the responsibility to serve - as the Agreement Steward to a suitable separate entity. Each new version of the - Agreement will be given a distinguishing version number. The Program (including - Contributions) may always be distributed subject to the version of the Agreement - under which it was received. In addition, after a new version of the Agreement - is published, Contributor may elect to distribute the Program (including its - Contributions) under the new version. Except as expressly stated in Sections - 2(a) and 2(b) above, Recipient receives no rights or licenses to the - intellectual property of any Contributor under this Agreement, whether - expressly, by implication, estoppel or otherwise. All rights in the Program not - expressly granted under this Agreement are reserved. - . - This Agreement is governed by the laws of the State of New York and the - intellectual property laws of the United States of America. No party to this - Agreement will bring a legal action under this Agreement more than one year - after the cause of action arose. Each party waives its rights to a jury trial in - any resulting litigation. diff --git a/usr/rdma-core/debian/ibacm.install b/usr/rdma-core/debian/ibacm.install deleted file mode 100644 index d3ed2a2e8..000000000 --- a/usr/rdma-core/debian/ibacm.install +++ /dev/null @@ -1,13 +0,0 @@ -etc/init.d/ibacm -lib/systemd/system/ibacm.service -lib/systemd/system/ibacm.socket -usr/bin/ib_acme -usr/include/infiniband/acm.h -usr/include/infiniband/acm_prov.h -usr/lib/*/ibacm/libibacmp.so -usr/sbin/ibacm -usr/share/doc/rdma-core/ibacm.md usr/share/doc/ibacm/ -usr/share/man/man1/ib_acme.1 -usr/share/man/man1/ibacm.1 -usr/share/man/man7/ibacm.7 -usr/share/man/man7/ibacm_prov.7 diff --git a/usr/rdma-core/debian/ibverbs-providers.install b/usr/rdma-core/debian/ibverbs-providers.install deleted file mode 100644 index 43a8727f3..000000000 --- a/usr/rdma-core/debian/ibverbs-providers.install +++ /dev/null @@ -1,4 +0,0 @@ -etc/libibverbs.d/ -usr/lib/*/libibverbs/lib*-rdmav*.so -usr/lib/*/libmlx4.so.* -usr/lib/*/libmlx5.so.* diff --git a/usr/rdma-core/debian/ibverbs-providers.lintian-overrides b/usr/rdma-core/debian/ibverbs-providers.lintian-overrides deleted file mode 100644 index a33f879e6..000000000 --- a/usr/rdma-core/debian/ibverbs-providers.lintian-overrides +++ /dev/null @@ -1,2 +0,0 @@ -# libmlx4 and libmlx5 are ibverbs provider that provides more functions. -ibverbs-providers: package-name-doesnt-match-sonames libmlx4-1 libmlx5-1 diff --git a/usr/rdma-core/debian/ibverbs-providers.symbols b/usr/rdma-core/debian/ibverbs-providers.symbols deleted file mode 100644 index cb21dc5b1..000000000 --- a/usr/rdma-core/debian/ibverbs-providers.symbols +++ /dev/null @@ -1,15 +0,0 @@ -libmlx4.so.1 ibverbs-providers #MINVER# - MLX4_1.0@MLX4_1.0 15 - mlx4dv_init_obj@MLX4_1.0 15 - mlx4dv_query_device@MLX4_1.0 15 - mlx4dv_create_qp@MLX4_1.0 15 - mlx4dv_set_context_attr@MLX4_1.0 15 -libmlx5.so.1 ibverbs-providers #MINVER# - MLX5_1.0@MLX5_1.0 13 - MLX5_1.1@MLX5_1.1 14 - MLX5_1.2@MLX5_1.2 15 - mlx5dv_init_obj@MLX5_1.0 13 - mlx5dv_init_obj@MLX5_1.2 15 - mlx5dv_query_device@MLX5_1.0 13 - mlx5dv_create_cq@MLX5_1.1 14 - mlx5dv_set_context_attr@MLX5_1.2 15 diff --git a/usr/rdma-core/debian/ibverbs-utils.install b/usr/rdma-core/debian/ibverbs-utils.install deleted file mode 100644 index 170b8d268..000000000 --- a/usr/rdma-core/debian/ibverbs-utils.install +++ /dev/null @@ -1,16 +0,0 @@ -usr/bin/ibv_asyncwatch -usr/bin/ibv_devices -usr/bin/ibv_devinfo -usr/bin/ibv_rc_pingpong -usr/bin/ibv_srq_pingpong -usr/bin/ibv_uc_pingpong -usr/bin/ibv_ud_pingpong -usr/bin/ibv_xsrq_pingpong -usr/share/man/man1/ibv_asyncwatch.1 -usr/share/man/man1/ibv_devices.1 -usr/share/man/man1/ibv_devinfo.1 -usr/share/man/man1/ibv_rc_pingpong.1 -usr/share/man/man1/ibv_srq_pingpong.1 -usr/share/man/man1/ibv_uc_pingpong.1 -usr/share/man/man1/ibv_ud_pingpong.1 -usr/share/man/man1/ibv_xsrq_pingpong.1 diff --git a/usr/rdma-core/debian/libibcm-dev.install b/usr/rdma-core/debian/libibcm-dev.install deleted file mode 100644 index 36e1e5fe5..000000000 --- a/usr/rdma-core/debian/libibcm-dev.install +++ /dev/null @@ -1,3 +0,0 @@ -usr/include/infiniband/cm.h -usr/include/infiniband/cm_abi.h -usr/lib/*/libibcm*.so diff --git a/usr/rdma-core/debian/libibcm1.install b/usr/rdma-core/debian/libibcm1.install deleted file mode 100644 index a0ace6ebf..000000000 --- a/usr/rdma-core/debian/libibcm1.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/lib/*/libibcm*.so.* -usr/share/doc/rdma-core/libibcm.md usr/share/doc/libibcm1/ diff --git a/usr/rdma-core/debian/libibcm1.symbols b/usr/rdma-core/debian/libibcm1.symbols deleted file mode 100644 index a7b0ef434..000000000 --- a/usr/rdma-core/debian/libibcm1.symbols +++ /dev/null @@ -1,23 +0,0 @@ -libibcm.so.1 libibcm1 #MINVER# - IBCM_1.0@IBCM_1.0 12 - ib_cm_ack_event@IBCM_1.0 12 - ib_cm_attr_id@IBCM_1.0 12 - ib_cm_close_device@IBCM_1.0 12 - ib_cm_create_id@IBCM_1.0 12 - ib_cm_destroy_id@IBCM_1.0 12 - ib_cm_get_event@IBCM_1.0 12 - ib_cm_init_qp_attr@IBCM_1.0 12 - ib_cm_listen@IBCM_1.0 12 - ib_cm_notify@IBCM_1.0 12 - ib_cm_open_device@IBCM_1.0 12 - ib_cm_send_apr@IBCM_1.0 12 - ib_cm_send_drep@IBCM_1.0 12 - ib_cm_send_dreq@IBCM_1.0 12 - ib_cm_send_lap@IBCM_1.0 12 - ib_cm_send_mra@IBCM_1.0 12 - ib_cm_send_rej@IBCM_1.0 12 - ib_cm_send_rep@IBCM_1.0 12 - ib_cm_send_req@IBCM_1.0 12 - ib_cm_send_rtu@IBCM_1.0 12 - ib_cm_send_sidr_rep@IBCM_1.0 12 - ib_cm_send_sidr_req@IBCM_1.0 12 diff --git a/usr/rdma-core/debian/libibumad-dev.install b/usr/rdma-core/debian/libibumad-dev.install deleted file mode 100644 index f9ec54138..000000000 --- a/usr/rdma-core/debian/libibumad-dev.install +++ /dev/null @@ -1,3 +0,0 @@ -usr/include/infiniband/umad*.h -usr/lib/*/libibumad*.so -usr/share/man/man3/umad_* diff --git a/usr/rdma-core/debian/libibumad-dev.lintian-overrides b/usr/rdma-core/debian/libibumad-dev.lintian-overrides deleted file mode 100644 index ed71b738b..000000000 --- a/usr/rdma-core/debian/libibumad-dev.lintian-overrides +++ /dev/null @@ -1,3 +0,0 @@ -# False positive for Certificate Authoritys (CAs) -libibumad-dev: spelling-error-in-manpage usr/share/man/man3/umad_get_cas_names.3.gz cas case -libibumad-dev: spelling-error-in-manpage usr/share/man/man3/umad_get_cas_names.3.gz CAs Case diff --git a/usr/rdma-core/debian/libibumad3.install b/usr/rdma-core/debian/libibumad3.install deleted file mode 100644 index f6c298db5..000000000 --- a/usr/rdma-core/debian/libibumad3.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/libibumad*.so.* diff --git a/usr/rdma-core/debian/libibumad3.lintian-overrides b/usr/rdma-core/debian/libibumad3.lintian-overrides deleted file mode 100644 index cb001b96e..000000000 --- a/usr/rdma-core/debian/libibumad3.lintian-overrides +++ /dev/null @@ -1,2 +0,0 @@ -# False positive for Certificate Authoritys (CAs) -libibumad3: spelling-error-in-binary usr/lib/x86_64-linux-gnu/libibumad.so.3.0.15 cas case diff --git a/usr/rdma-core/debian/libibumad3.symbols b/usr/rdma-core/debian/libibumad3.symbols deleted file mode 100644 index 267ded368..000000000 --- a/usr/rdma-core/debian/libibumad3.symbols +++ /dev/null @@ -1,38 +0,0 @@ -libibumad.so.3 libibumad3 #MINVER# - IBUMAD_1.0@IBUMAD_1.0 1.3.9 - umad_addr_dump@IBUMAD_1.0 1.3.9 - umad_attribute_str@IBUMAD_1.0 1.3.10.2 - umad_class_str@IBUMAD_1.0 1.3.10.2 - umad_close_port@IBUMAD_1.0 1.3.9 - umad_common_mad_status_str@IBUMAD_1.0 1.3.10.2 - umad_debug@IBUMAD_1.0 1.3.9 - umad_done@IBUMAD_1.0 1.3.9 - umad_dump@IBUMAD_1.0 1.3.9 - umad_get_ca@IBUMAD_1.0 1.3.9 - umad_get_ca_portguids@IBUMAD_1.0 1.3.9 - umad_get_cas_names@IBUMAD_1.0 1.3.9 - umad_get_fd@IBUMAD_1.0 1.3.9 - umad_get_issm_path@IBUMAD_1.0 1.3.9 - umad_get_mad@IBUMAD_1.0 1.3.9 - umad_get_mad_addr@IBUMAD_1.0 1.3.9 - umad_get_pkey@IBUMAD_1.0 1.3.9 - umad_get_port@IBUMAD_1.0 1.3.9 - umad_init@IBUMAD_1.0 1.3.9 - umad_method_str@IBUMAD_1.0 1.3.10.2 - umad_open_port@IBUMAD_1.0 1.3.9 - umad_poll@IBUMAD_1.0 1.3.9 - umad_recv@IBUMAD_1.0 1.3.9 - umad_register2@IBUMAD_1.0 1.3.10.2 - umad_register@IBUMAD_1.0 1.3.9 - umad_register_oui@IBUMAD_1.0 1.3.9 - umad_release_ca@IBUMAD_1.0 1.3.9 - umad_release_port@IBUMAD_1.0 1.3.9 - umad_sa_mad_status_str@IBUMAD_1.0 1.3.10.2 - umad_send@IBUMAD_1.0 1.3.9 - umad_set_addr@IBUMAD_1.0 1.3.9 - umad_set_addr_net@IBUMAD_1.0 1.3.9 - umad_set_grh@IBUMAD_1.0 1.3.9 - umad_set_pkey@IBUMAD_1.0 1.3.9 - umad_size@IBUMAD_1.0 1.3.9 - umad_status@IBUMAD_1.0 1.3.9 - umad_unregister@IBUMAD_1.0 1.3.9 diff --git a/usr/rdma-core/debian/libibverbs-dev.install b/usr/rdma-core/debian/libibverbs-dev.install deleted file mode 100644 index b854a19dd..000000000 --- a/usr/rdma-core/debian/libibverbs-dev.install +++ /dev/null @@ -1,18 +0,0 @@ -usr/include/infiniband/arch.h -usr/include/infiniband/kern-abi.h -usr/include/infiniband/mlx4dv.h -usr/include/infiniband/mlx5dv.h -usr/include/infiniband/opcode.h -usr/include/infiniband/sa-kern-abi.h -usr/include/infiniband/sa.h -usr/include/infiniband/verbs.h -usr/lib/*/libibverbs*.so -usr/lib/*/libmlx4.so -usr/lib/*/libmlx5.so -usr/share/man/man3/ibv_* -usr/share/man/man3/mbps_to_ibv_rate.3 -usr/share/man/man3/mlx4dv_*.3 -usr/share/man/man3/mlx5dv_*.3 -usr/share/man/man3/mult_to_ibv_rate.3 -usr/share/man/man7/mlx4dv.7 -usr/share/man/man7/mlx5dv.7 diff --git a/usr/rdma-core/debian/libibverbs1.install b/usr/rdma-core/debian/libibverbs1.install deleted file mode 100644 index 83bdd802b..000000000 --- a/usr/rdma-core/debian/libibverbs1.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/lib/*/libibverbs*.so.* -usr/share/doc/rdma-core/libibverbs.md usr/share/doc/libibverbs1/ diff --git a/usr/rdma-core/debian/libibverbs1.postinst b/usr/rdma-core/debian/libibverbs1.postinst deleted file mode 100644 index 784458a6e..000000000 --- a/usr/rdma-core/debian/libibverbs1.postinst +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# postinst script for libibverbs1 - -set -e - -if [ "$1" = configure ]; then - getent group rdma > /dev/null 2>&1 || addgroup --system --quiet rdma -fi - -#DEBHELPER# diff --git a/usr/rdma-core/debian/libibverbs1.symbols b/usr/rdma-core/debian/libibverbs1.symbols deleted file mode 100644 index 2678fa6e9..000000000 --- a/usr/rdma-core/debian/libibverbs1.symbols +++ /dev/null @@ -1,94 +0,0 @@ -libibverbs.so.1 libibverbs1 #MINVER# - IBVERBS_1.0@IBVERBS_1.0 1.1.6 - IBVERBS_1.1@IBVERBS_1.1 1.1.6 - (symver)IBVERBS_PRIVATE_16 16 - ibv_ack_async_event@IBVERBS_1.0 1.1.6 - ibv_ack_async_event@IBVERBS_1.1 1.1.6 - ibv_ack_cq_events@IBVERBS_1.0 1.1.6 - ibv_ack_cq_events@IBVERBS_1.1 1.1.6 - ibv_alloc_pd@IBVERBS_1.0 1.1.6 - ibv_alloc_pd@IBVERBS_1.1 1.1.6 - ibv_attach_mcast@IBVERBS_1.0 1.1.6 - ibv_attach_mcast@IBVERBS_1.1 1.1.6 - ibv_close_device@IBVERBS_1.0 1.1.6 - ibv_close_device@IBVERBS_1.1 1.1.6 - ibv_copy_ah_attr_from_kern@IBVERBS_1.1 1.1.6 - ibv_copy_path_rec_from_kern@IBVERBS_1.0 1.1.6 - ibv_copy_path_rec_to_kern@IBVERBS_1.0 1.1.6 - ibv_copy_qp_attr_from_kern@IBVERBS_1.0 1.1.6 - ibv_create_ah@IBVERBS_1.0 1.1.6 - ibv_create_ah@IBVERBS_1.1 1.1.6 - ibv_create_ah_from_wc@IBVERBS_1.1 1.1.6 - ibv_create_comp_channel@IBVERBS_1.0 1.1.6 - ibv_create_cq@IBVERBS_1.0 1.1.6 - ibv_create_cq@IBVERBS_1.1 1.1.6 - ibv_create_qp@IBVERBS_1.0 1.1.6 - ibv_create_qp@IBVERBS_1.1 1.1.6 - ibv_create_srq@IBVERBS_1.0 1.1.6 - ibv_create_srq@IBVERBS_1.1 1.1.6 - ibv_dealloc_pd@IBVERBS_1.0 1.1.6 - ibv_dealloc_pd@IBVERBS_1.1 1.1.6 - ibv_dereg_mr@IBVERBS_1.0 1.1.6 - ibv_dereg_mr@IBVERBS_1.1 1.1.6 - ibv_destroy_ah@IBVERBS_1.0 1.1.6 - ibv_destroy_ah@IBVERBS_1.1 1.1.6 - ibv_destroy_comp_channel@IBVERBS_1.0 1.1.6 - ibv_destroy_cq@IBVERBS_1.0 1.1.6 - ibv_destroy_cq@IBVERBS_1.1 1.1.6 - ibv_destroy_qp@IBVERBS_1.0 1.1.6 - ibv_destroy_qp@IBVERBS_1.1 1.1.6 - ibv_destroy_srq@IBVERBS_1.0 1.1.6 - ibv_destroy_srq@IBVERBS_1.1 1.1.6 - ibv_detach_mcast@IBVERBS_1.0 1.1.6 - ibv_detach_mcast@IBVERBS_1.1 1.1.6 - ibv_dofork_range@IBVERBS_1.1 1.1.6 - ibv_dontfork_range@IBVERBS_1.1 1.1.6 - ibv_event_type_str@IBVERBS_1.1 1.1.6 - ibv_fork_init@IBVERBS_1.1 1.1.6 - ibv_free_device_list@IBVERBS_1.0 1.1.6 - ibv_free_device_list@IBVERBS_1.1 1.1.6 - ibv_get_async_event@IBVERBS_1.0 1.1.6 - ibv_get_async_event@IBVERBS_1.1 1.1.6 - ibv_get_cq_event@IBVERBS_1.0 1.1.6 - ibv_get_cq_event@IBVERBS_1.1 1.1.6 - ibv_get_device_guid@IBVERBS_1.0 1.1.6 - ibv_get_device_guid@IBVERBS_1.1 1.1.6 - ibv_get_device_list@IBVERBS_1.0 1.1.6 - ibv_get_device_list@IBVERBS_1.1 1.1.6 - ibv_get_device_name@IBVERBS_1.0 1.1.6 - ibv_get_device_name@IBVERBS_1.1 1.1.6 - ibv_get_sysfs_path@IBVERBS_1.0 1.1.6 - ibv_init_ah_from_wc@IBVERBS_1.1 1.1.6 - ibv_modify_qp@IBVERBS_1.0 1.1.6 - ibv_modify_qp@IBVERBS_1.1 1.1.6 - ibv_modify_srq@IBVERBS_1.0 1.1.6 - ibv_modify_srq@IBVERBS_1.1 1.1.6 - ibv_node_type_str@IBVERBS_1.1 1.1.6 - ibv_open_device@IBVERBS_1.0 1.1.6 - ibv_open_device@IBVERBS_1.1 1.1.6 - ibv_port_state_str@IBVERBS_1.1 1.1.6 - ibv_query_device@IBVERBS_1.0 1.1.6 - ibv_query_device@IBVERBS_1.1 1.1.6 - ibv_query_gid@IBVERBS_1.0 1.1.6 - ibv_query_gid@IBVERBS_1.1 1.1.6 - ibv_query_pkey@IBVERBS_1.0 1.1.6 - ibv_query_pkey@IBVERBS_1.1 1.1.6 - ibv_query_port@IBVERBS_1.0 1.1.6 - ibv_query_port@IBVERBS_1.1 1.1.6 - ibv_query_qp@IBVERBS_1.0 1.1.6 - ibv_query_qp@IBVERBS_1.1 1.1.6 - ibv_query_srq@IBVERBS_1.0 1.1.6 - ibv_query_srq@IBVERBS_1.1 1.1.6 - ibv_rate_to_mbps@IBVERBS_1.1 1.1.8 - ibv_rate_to_mult@IBVERBS_1.0 1.1.6 - ibv_read_sysfs_file@IBVERBS_1.0 1.1.6 - ibv_reg_mr@IBVERBS_1.0 1.1.6 - ibv_reg_mr@IBVERBS_1.1 1.1.6 - ibv_register_driver@IBVERBS_1.1 1.1.6 - ibv_rereg_mr@IBVERBS_1.1 1.2.1 - ibv_resize_cq@IBVERBS_1.0 1.1.6 - ibv_resize_cq@IBVERBS_1.1 1.1.6 - ibv_resolve_eth_l2_from_gid@IBVERBS_1.1 1.2.0 - ibv_wc_status_str@IBVERBS_1.1 1.1.6 - mbps_to_ibv_rate@IBVERBS_1.1 1.1.8 - mult_to_ibv_rate@IBVERBS_1.0 1.1.6 diff --git a/usr/rdma-core/debian/librdmacm-dev.install b/usr/rdma-core/debian/librdmacm-dev.install deleted file mode 100644 index bfd8ad837..000000000 --- a/usr/rdma-core/debian/librdmacm-dev.install +++ /dev/null @@ -1,57 +0,0 @@ -usr/include/infiniband/ib.h -usr/include/rdma/rdma_cma.h -usr/include/rdma/rdma_cma_abi.h -usr/include/rdma/rdma_verbs.h -usr/include/rdma/rsocket.h -usr/lib/*/librdmacm*.so -usr/share/man/man3/rdma_accept.3 -usr/share/man/man3/rdma_ack_cm_event.3 -usr/share/man/man3/rdma_bind_addr.3 -usr/share/man/man3/rdma_connect.3 -usr/share/man/man3/rdma_create_ep.3 -usr/share/man/man3/rdma_create_event_channel.3 -usr/share/man/man3/rdma_create_id.3 -usr/share/man/man3/rdma_create_qp.3 -usr/share/man/man3/rdma_create_srq.3 -usr/share/man/man3/rdma_dereg_mr.3 -usr/share/man/man3/rdma_destroy_ep.3 -usr/share/man/man3/rdma_destroy_event_channel.3 -usr/share/man/man3/rdma_destroy_id.3 -usr/share/man/man3/rdma_destroy_qp.3 -usr/share/man/man3/rdma_destroy_srq.3 -usr/share/man/man3/rdma_disconnect.3 -usr/share/man/man3/rdma_event_str.3 -usr/share/man/man3/rdma_free_devices.3 -usr/share/man/man3/rdma_get_cm_event.3 -usr/share/man/man3/rdma_get_devices.3 -usr/share/man/man3/rdma_get_dst_port.3 -usr/share/man/man3/rdma_get_local_addr.3 -usr/share/man/man3/rdma_get_peer_addr.3 -usr/share/man/man3/rdma_get_recv_comp.3 -usr/share/man/man3/rdma_get_request.3 -usr/share/man/man3/rdma_get_send_comp.3 -usr/share/man/man3/rdma_get_src_port.3 -usr/share/man/man3/rdma_getaddrinfo.3 -usr/share/man/man3/rdma_join_multicast.3 -usr/share/man/man3/rdma_leave_multicast.3 -usr/share/man/man3/rdma_listen.3 -usr/share/man/man3/rdma_migrate_id.3 -usr/share/man/man3/rdma_notify.3 -usr/share/man/man3/rdma_post_read.3 -usr/share/man/man3/rdma_post_readv.3 -usr/share/man/man3/rdma_post_recv.3 -usr/share/man/man3/rdma_post_recvv.3 -usr/share/man/man3/rdma_post_send.3 -usr/share/man/man3/rdma_post_sendv.3 -usr/share/man/man3/rdma_post_ud_send.3 -usr/share/man/man3/rdma_post_write.3 -usr/share/man/man3/rdma_post_writev.3 -usr/share/man/man3/rdma_reg_msgs.3 -usr/share/man/man3/rdma_reg_read.3 -usr/share/man/man3/rdma_reg_write.3 -usr/share/man/man3/rdma_reject.3 -usr/share/man/man3/rdma_resolve_addr.3 -usr/share/man/man3/rdma_resolve_route.3 -usr/share/man/man3/rdma_set_option.3 -usr/share/man/man7/rdma_cm.7 -usr/share/man/man7/rsocket.7 diff --git a/usr/rdma-core/debian/librdmacm1.install b/usr/rdma-core/debian/librdmacm1.install deleted file mode 100644 index 09140ab84..000000000 --- a/usr/rdma-core/debian/librdmacm1.install +++ /dev/null @@ -1,3 +0,0 @@ -usr/lib/*/librdmacm*.so.* -usr/lib/*/rsocket/librspreload*.so* -usr/share/doc/rdma-core/librdmacm.md usr/share/doc/librdmacm1/ diff --git a/usr/rdma-core/debian/librdmacm1.symbols b/usr/rdma-core/debian/librdmacm1.symbols deleted file mode 100644 index 7cec5c6b1..000000000 --- a/usr/rdma-core/debian/librdmacm1.symbols +++ /dev/null @@ -1,64 +0,0 @@ -librdmacm.so.1 librdmacm1 #MINVER# - RDMACM_1.0@RDMACM_1.0 1.0.15 - raccept@RDMACM_1.0 1.0.16 - rbind@RDMACM_1.0 1.0.16 - rclose@RDMACM_1.0 1.0.16 - rconnect@RDMACM_1.0 1.0.16 - rdma_accept@RDMACM_1.0 1.0.15 - rdma_ack_cm_event@RDMACM_1.0 1.0.15 - rdma_bind_addr@RDMACM_1.0 1.0.15 - rdma_connect@RDMACM_1.0 1.0.15 - rdma_create_ep@RDMACM_1.0 1.0.15 - rdma_create_event_channel@RDMACM_1.0 1.0.15 - rdma_create_id@RDMACM_1.0 1.0.15 - rdma_create_qp@RDMACM_1.0 1.0.15 - rdma_create_qp_ex@RDMACM_1.0 1.0.19 - rdma_create_srq@RDMACM_1.0 1.0.15 - rdma_create_srq_ex@RDMACM_1.0 1.0.19 - rdma_destroy_ep@RDMACM_1.0 1.0.15 - rdma_destroy_event_channel@RDMACM_1.0 1.0.15 - rdma_destroy_id@RDMACM_1.0 1.0.15 - rdma_destroy_qp@RDMACM_1.0 1.0.15 - rdma_destroy_srq@RDMACM_1.0 1.0.15 - rdma_disconnect@RDMACM_1.0 1.0.15 - rdma_event_str@RDMACM_1.0 1.0.15 - rdma_free_devices@RDMACM_1.0 1.0.15 - rdma_freeaddrinfo@RDMACM_1.0 1.0.15 - rdma_get_cm_event@RDMACM_1.0 1.0.15 - rdma_get_devices@RDMACM_1.0 1.0.15 - rdma_get_dst_port@RDMACM_1.0 1.0.19 - rdma_get_request@RDMACM_1.0 1.0.15 - rdma_get_src_port@RDMACM_1.0 1.0.19 - rdma_getaddrinfo@RDMACM_1.0 1.0.15 - rdma_join_multicast@RDMACM_1.0 1.0.15 - rdma_leave_multicast@RDMACM_1.0 1.0.15 - rdma_listen@RDMACM_1.0 1.0.15 - rdma_migrate_id@RDMACM_1.0 1.0.15 - rdma_notify@RDMACM_1.0 1.0.15 - rdma_reject@RDMACM_1.0 1.0.15 - rdma_resolve_addr@RDMACM_1.0 1.0.15 - rdma_resolve_route@RDMACM_1.0 1.0.15 - rdma_set_option@RDMACM_1.0 1.0.15 - rfcntl@RDMACM_1.0 1.0.16 - rgetpeername@RDMACM_1.0 1.0.16 - rgetsockname@RDMACM_1.0 1.0.16 - rgetsockopt@RDMACM_1.0 1.0.16 - riomap@RDMACM_1.0 1.0.19 - riounmap@RDMACM_1.0 1.0.19 - riowrite@RDMACM_1.0 1.0.19 - rlisten@RDMACM_1.0 1.0.16 - rpoll@RDMACM_1.0 1.0.16 - rread@RDMACM_1.0 1.0.16 - rreadv@RDMACM_1.0 1.0.16 - rrecv@RDMACM_1.0 1.0.16 - rrecvfrom@RDMACM_1.0 1.0.16 - rrecvmsg@RDMACM_1.0 1.0.16 - rselect@RDMACM_1.0 1.0.16 - rsend@RDMACM_1.0 1.0.16 - rsendmsg@RDMACM_1.0 1.0.16 - rsendto@RDMACM_1.0 1.0.16 - rsetsockopt@RDMACM_1.0 1.0.16 - rshutdown@RDMACM_1.0 1.0.16 - rsocket@RDMACM_1.0 1.0.16 - rwrite@RDMACM_1.0 1.0.16 - rwritev@RDMACM_1.0 1.0.16 diff --git a/usr/rdma-core/debian/rdma-core.install b/usr/rdma-core/debian/rdma-core.install deleted file mode 100644 index ca08a9d34..000000000 --- a/usr/rdma-core/debian/rdma-core.install +++ /dev/null @@ -1,34 +0,0 @@ -etc/init.d/iwpmd -etc/iwpmd.conf -etc/modprobe.d/mlx4.conf -etc/modprobe.d/truescale.conf -etc/rdma/modules/infiniband.conf -etc/rdma/modules/iwarp.conf -etc/rdma/modules/iwpmd.conf -etc/rdma/modules/opa.conf -etc/rdma/modules/rdma.conf -etc/rdma/modules/roce.conf -etc/udev/rules.d/70-persistent-ipoib.rules -lib/systemd/system/iwpmd.service -lib/systemd/system/rdma-hw.target -lib/systemd/system/rdma-load-modules@.service -lib/systemd/system/rdma-ndd.service -lib/udev/rules.d/60-rdma-ndd.rules -lib/udev/rules.d/75-rdma-description.rules -lib/udev/rules.d/90-iwpmd.rules -lib/udev/rules.d/90-rdma-hw-modules.rules -lib/udev/rules.d/90-rdma-ulp-modules.rules -lib/udev/rules.d/90-rdma-umad.rules -usr/bin/rxe_cfg -usr/lib/truescale-serdes.cmds -usr/sbin/iwpmd -usr/sbin/rdma-ndd -usr/share/doc/rdma-core/MAINTAINERS -usr/share/doc/rdma-core/README.md -usr/share/doc/rdma-core/rxe.md -usr/share/doc/rdma-core/udev.md -usr/share/man/man5/iwpmd.conf.5 -usr/share/man/man7/rxe.7 -usr/share/man/man8/iwpmd.8 -usr/share/man/man8/rdma-ndd.8 -usr/share/man/man8/rxe_cfg.8 diff --git a/usr/rdma-core/debian/rdma-core.lintian-overrides b/usr/rdma-core/debian/rdma-core.lintian-overrides deleted file mode 100644 index 01dea12b5..000000000 --- a/usr/rdma-core/debian/rdma-core.lintian-overrides +++ /dev/null @@ -1,5 +0,0 @@ -# The rdma-ndd service is started by udev. -rdma-core: systemd-service-file-missing-install-key lib/systemd/system/iwpmd.service -rdma-core: systemd-service-file-missing-install-key lib/systemd/system/rdma-ndd.service -# Example/documentary udev rules file -rdma-core: udev-rule-in-etc etc/udev/rules.d/70-persistent-ipoib.rules diff --git a/usr/rdma-core/debian/rdma-core.postinst b/usr/rdma-core/debian/rdma-core.postinst deleted file mode 100644 index 6486f62ec..000000000 --- a/usr/rdma-core/debian/rdma-core.postinst +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -e - -#DEBHELPER# - -if [ "$1" = "configure" ]; then - # we ship udev rules, so trigger an update. This has to be done after - # DEBHELPER restarts systemd to get our new service files loaded. - udevadm trigger --subsystem-match=infiniband --action=change || true - udevadm trigger --subsystem-match=net --action=change || true - udevadm trigger --subsystem-match=infiniband_mad --action=change || true -fi diff --git a/usr/rdma-core/debian/rdmacm-utils.install b/usr/rdma-core/debian/rdmacm-utils.install deleted file mode 100644 index 74506d6d8..000000000 --- a/usr/rdma-core/debian/rdmacm-utils.install +++ /dev/null @@ -1,26 +0,0 @@ -usr/bin/cmtime -usr/bin/mckey -usr/bin/rcopy -usr/bin/rdma_client -usr/bin/rdma_server -usr/bin/rdma_xclient -usr/bin/rdma_xserver -usr/bin/riostream -usr/bin/rping -usr/bin/rstream -usr/bin/ucmatose -usr/bin/udaddy -usr/bin/udpong -usr/share/man/man1/cmtime.1 -usr/share/man/man1/mckey.1 -usr/share/man/man1/rcopy.1 -usr/share/man/man1/rdma_client.1 -usr/share/man/man1/rdma_server.1 -usr/share/man/man1/rdma_xclient.1 -usr/share/man/man1/rdma_xserver.1 -usr/share/man/man1/riostream.1 -usr/share/man/man1/rping.1 -usr/share/man/man1/rstream.1 -usr/share/man/man1/ucmatose.1 -usr/share/man/man1/udaddy.1 -usr/share/man/man1/udpong.1 diff --git a/usr/rdma-core/debian/rules b/usr/rdma-core/debian/rules deleted file mode 100755 index 562fff511..000000000 --- a/usr/rdma-core/debian/rules +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/make -f - -export DEB_BUILD_MAINT_OPTIONS=hardening=+all - -%: - dh $@ --with systemd --builddirectory=build-deb - -override_dh_auto_clean: - dh_auto_clean - rm -rf build-deb - -# Upstream wishes to use CMAKE_BUILD_TYPE=Release, and ensures that has a -# sensible basis of options (eg no -O3, including -g). Debian specific options -# come from CFLAGS as usual. -# -# Upstream encourages the use of Ninja to build the source, convince dh to use -# it until someone writes native support for dh+cmake+ninja. -override_dh_auto_configure: - dh_auto_configure -- -GNinja \ - -DDISTRO_FLAVOUR=Debian \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc \ - -DCMAKE_INSTALL_SYSTEMD_SERVICEDIR:PATH=/lib/systemd/system \ - -DCMAKE_INSTALL_INITDDIR:PATH=/etc/init.d \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=/usr/lib \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=/var/lib \ - -DCMAKE_INSTALL_RUNDIR:PATH=/run \ - -DCMAKE_INSTALL_UDEV_RULESDIR:PATH=/lib/udev/rules.d - -override_dh_auto_build: - ninja -C build-deb -v - -# upstream does not ship test cases -override_dh_auto_test: - -override_dh_auto_install: - DESTDIR=$(CURDIR)/debian/tmp ninja -C build-deb install - -# The following files are not used on Debian (we ship our own sysvinit script) -INST_EXCLUDE := "etc/init.d/srpd" \ - "usr/sbin/run_srp_daemon" \ - "usr/sbin/srp_daemon.sh" -INST_EXCLUDE := $(addprefix -X,$(INST_EXCLUDE)) -override_dh_install: - dh_install --fail-missing $(INST_EXCLUDE) - -# cmake installs the correct init scripts in the correct place, just setup the -# pre-postrms -override_dh_installinit: - dh_installinit -pibacm --onlyscripts - dh_installinit -prdma-core --onlyscripts --name=iwpmd - dh_installinit --remaining-packages - -# Provider plugin libaries are not shared libraries and do not belong in the -# shlibs file. -# librspreload is a LD_PRELOAD library and does not belong in the shlib files -SHLIBS_EXCLUDE = "/libibverbs/" "librspreload" "/ibacm/" -SHLIBS_EXCLUDE := $(addprefix --exclude=,$(SHLIBS_EXCLUDE)) -override_dh_makeshlibs: - dh_makeshlibs $(SHLIBS_EXCLUDE) - -override_dh_strip: - dh_strip -plibibcm1 --dbg-package=libibcm1-dbg - dh_strip -plibibumad3 --dbg-package=libibumad3-dbg - dh_strip -plibibverbs1 --dbg-package=libibverbs1-dbg - dh_strip -plibrdmacm1 --dbg-package=librdmacm1-dbg - dh_strip --remaining-packages - -# Upstream encourages the use of 'build' as the developer build output -# directory, allow that directory to be present and still allow dh to work. -.PHONY: build -build: - dh $@ --with systemd --builddirectory=build-deb diff --git a/usr/rdma-core/debian/source/format b/usr/rdma-core/debian/source/format deleted file mode 100644 index 163aaf8d8..000000000 --- a/usr/rdma-core/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) diff --git a/usr/rdma-core/debian/srptools.default b/usr/rdma-core/debian/srptools.default deleted file mode 100644 index 77ee1a568..000000000 --- a/usr/rdma-core/debian/srptools.default +++ /dev/null @@ -1,14 +0,0 @@ -# How often should srp_daemon rescan the fabric (seconds). -RETRIES=60 - -# Where should srp_daemon log to. -LOG=/var/log/srp_daemon.log - -# What ports should srp_daemon be started on. -# Format is CA:port -# ALL or NONE will run on all ports on none -# respectively - -PORTS=NONE -#PORTS=ALL -#PORTS="mthca0:1 mlx4_0:2" diff --git a/usr/rdma-core/debian/srptools.init b/usr/rdma-core/debian/srptools.init deleted file mode 100644 index 82eaf1b75..000000000 --- a/usr/rdma-core/debian/srptools.init +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: srptools -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Discovers SRP scsi targets. -# Description: Discovers SRP scsi over infiniband targets. -### END INIT INFO - -DAEMON=/usr/sbin/srp_daemon -IBDIR=/sys/class/infiniband - -PORTS="" -RETRIES="" -RETRIES_DEFAULT=60 -LOG="" -LOG_DEFAULT=/var/log/srp_daemon.log - -[ -x $DAEMON ] || exit 0 - -. /lib/lsb/init-functions - -[ -f /etc/default/srptools ] && . /etc/default/srptools - -max() { - echo $(($1 > $2 ? $1 : $2)) -} - -run_daemon() { - # srp does not background itself; using the start-stop-daemon background - # function causes us to lose stdout, which is where it logs to - nohup start-stop-daemon --start --quiet -m \ - --pidfile "/var/run/srp_daemon.${HCA_ID}.${PORT}" \ - --exec $DAEMON -- -e -c -n \ - -i "${HCA_ID}" -p "${PORT}" -R "${RETRIES:-${RETRIES_DEFAULT}}" \ - >> "${LOG:-${LOG_DEFAULT}}" 2>&1 & - RETVAL=$(max "$RETVAL" $?) -} - -# Evaluate shell command $1 for every port in $PORTS -for_all_ports() { - local cmd=$1 p - - if [ "$PORTS" = "ALL" ]; then - for p in ${IBDIR}/*/ports/*; do - [ -e "$p" ] || continue - PORT=$(basename "$p") - HCA_ID=$(basename "$(dirname "$(dirname "$p")")") - eval "$cmd" - done - else - for ADAPTER in $PORTS; do - HCA_ID=${ADAPTER%%:*} - PORT=${ADAPTER#${HCA_ID}:} - [ -n "$HCA_ID" ] && [ -n "$PORT" ] && eval "$cmd" - done - fi -} - -start_daemon() { - local RETVAL=0 - - if [ "$PORTS" = "NONE" ] ; then - echo "srptools disabled." - exit 0 - fi - - for_all_ports run_daemon - case $RETVAL in - 0) log_success_msg "started $DAEMON";; - *) log_failure_msg "failed to start $DAEMON";; - esac - return $RETVAL -} - -stop_daemon() { - local RETVAL=0 PORTS=ALL - - for_all_ports 'start-stop-daemon --stop --quiet --oknodo -m --pidfile "/var/run/srp_daemon.${HCA_ID}.${PORT}"; RETVAL=$(max $RETVAL $?)' - case $RETVAL in - 0) log_success_msg "stopped $DAEMON";; - *) log_failure_msg "failed to stop $DAEMON";; - esac - return $RETVAL -} - -check_status() { - local pidfile=$1 pid - - [ -e "$pidfile" ] || return 3 # not running - pid=$(<"$pidfile") - [ -n "$pid" ] || return 3 # not running - [ -d "/proc/$pid" ] || return 1 # not running and pid file exists - return 0 # running -} - -daemon_status() { - local RETVAL=0 - - for_all_ports 'check_status /var/run/srp_daemon.${HCA_ID}.${PORT} $DAEMON; RETVAL=$(max $RETVAL $?)' - case $RETVAL in - 0) log_success_msg "$DAEMON is running";; - *) log_failure_msg "$DAEMON is not running";; - esac - return $RETVAL -} - -case "$1" in - start) - start_daemon - ;; - stop) - stop_daemon - ;; - status) - daemon_status - ;; - restart | reload | force-reload ) - stop_daemon - start_daemon - ;; -esac diff --git a/usr/rdma-core/debian/srptools.install b/usr/rdma-core/debian/srptools.install deleted file mode 100644 index a30798cf0..000000000 --- a/usr/rdma-core/debian/srptools.install +++ /dev/null @@ -1,13 +0,0 @@ -etc/rdma/modules/srp_daemon.conf -etc/srp_daemon.conf -lib/systemd/system/srp_daemon.service -lib/systemd/system/srp_daemon_port@.service -lib/udev/rules.d/60-srp_daemon.rules -usr/lib/srp_daemon/start_on_all_ports -usr/sbin/ibsrpdm -usr/sbin/srp_daemon -usr/share/doc/rdma-core/ibsrpdm.md usr/share/doc/srptools/ -usr/share/man/man1/ibsrpdm.1 -usr/share/man/man1/srp_daemon.1 -usr/share/man/man5/srp_daemon.service.5 -usr/share/man/man5/srp_daemon_port@.service.5 diff --git a/usr/rdma-core/debian/srptools.links b/usr/rdma-core/debian/srptools.links deleted file mode 100644 index d0bfc7b81..000000000 --- a/usr/rdma-core/debian/srptools.links +++ /dev/null @@ -1 +0,0 @@ -/lib/systemd/system/srp_daemon.service /lib/systemd/system/srptools.service diff --git a/usr/rdma-core/debian/srptools.postinst b/usr/rdma-core/debian/srptools.postinst deleted file mode 100644 index 398534dba..000000000 --- a/usr/rdma-core/debian/srptools.postinst +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -set -e - -#DEBHELPER# - -if [ "$1" = "configure" ]; then - # we ship udev rules, so trigger an update. This has to be done after - # DEBHELPER restarts systemd to get our new service files loaded. - udevadm trigger --subsystem-match=infiniband_mad --action=change || true -fi diff --git a/usr/rdma-core/debian/watch b/usr/rdma-core/debian/watch deleted file mode 100644 index fd2043a34..000000000 --- a/usr/rdma-core/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=3 -https://github.com/linux-rdma/rdma-core/releases (?:.*?/)?(?:rdma-core-|v)?(\d[\d.]*)\.tar\.gz diff --git a/usr/rdma-core/ibacm/CMakeLists.txt b/usr/rdma-core/ibacm/CMakeLists.txt deleted file mode 100644 index 3a4e2632c..000000000 --- a/usr/rdma-core/ibacm/CMakeLists.txt +++ /dev/null @@ -1,75 +0,0 @@ -publish_headers(infiniband - include/infiniband/acm.h - include/infiniband/acm_prov.h - ) - -# FIXME: Fixup the include scheme to not require all these -Is -include_directories("include") -include_directories("src") -include_directories("linux") - -# NOTE: ibacm exports symbols from its own binary for use by ibacm -rdma_sbin_executable(ibacm - src/acm.c - src/acm_util.c - ) -target_link_libraries(ibacm LINK_PRIVATE - ibverbs - ibumad - ${SYSTEMD_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ${CMAKE_DL_LIBS} - ) -# FIXME: We should probably list the symbols we want to export.. -set_target_properties(ibacm PROPERTIES ENABLE_EXPORTS TRUE) - -# This is a plugin module that dynamically links to ibacm -add_library(ibacmp MODULE - prov/acmp/src/acmp.c - ) -rdma_set_library_map(ibacmp "prov/acmp/src/libibacmp.map") -target_link_libraries(ibacmp LINK_PRIVATE - ibacm - ibverbs - ibumad - ${CMAKE_THREAD_LIBS_INIT} - ) -set_target_properties(ibacmp PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") -install(TARGETS ibacmp DESTINATION "${ACM_PROVIDER_DIR}") -# ACM providers are linked into a subdir so that IN_PLACE can work. -file(MAKE_DIRECTORY "${BUILD_LIB}/ibacm/") -rdma_create_symlink("../libibacmp.so" "${BUILD_LIB}/ibacm/libibacmp.so") - -rdma_executable(ib_acme - src/acme.c - src/libacm.c - src/parse.c - ) -target_link_libraries(ib_acme LINK_PRIVATE - ibverbs - ) -target_compile_definitions(ib_acme PRIVATE "-DACME_PRINTS") - -rdma_man_pages( - man/ib_acme.1 - man/ibacm.1 - man/ibacm.7 - man/ibacm_prov.7.in - ) - -# FIXME: update the .init.in -rdma_subst_install(FILES "ibacm.init.in" - DESTINATION "${CMAKE_INSTALL_INITDDIR}" - RENAME "ibacm" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) - -rdma_subst_install(FILES "ibacm.service.in" - DESTINATION "${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}" - RENAME ibacm.service - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) - -install(FILES "ibacm.socket" - DESTINATION "${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}" - RENAME ibacm.socket - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) diff --git a/usr/rdma-core/ibacm/ibacm.init.in b/usr/rdma-core/ibacm/ibacm.init.in deleted file mode 100644 index eba0107f6..000000000 --- a/usr/rdma-core/ibacm/ibacm.init.in +++ /dev/null @@ -1,139 +0,0 @@ -#!/bin/bash -# Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -# -# Bring up/down the ibacm daemon -# -# chkconfig: 2345 25 75 -# description: Starts/Stops InfiniBand ACM service -# -### BEGIN INIT INFO -# Provides: ibacm -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Required-Start: $network $remote_fs -# Required-Stop: $network $remote_fs -# Should-Start: -# Should-Stop: -# Short-Description: Starts and stops the InfiniBand ACM service -# Description: The InfiniBand ACM service provides a user space implementation -# of something resembling an ARP cache for InfiniBand SA queries and -# host route lookups. -### END INIT INFO - -pidfile=@CMAKE_INSTALL_FULL_RUNDIR@/ibacm.pid -subsys=/var/lock/subsys/ibacm - -daemon() { /sbin/daemon ${1+"$@"}; } - -if [ -s /etc/init.d/functions ]; then - # RHEL / CentOS / SL / Fedora - . /etc/init.d/functions - _daemon() { daemon ${1+"$@"}; } - _checkpid() { checkpid `cat $pidfile`; } - _success() { success; echo; } - _failure() { failure; echo; } -elif [ -s /lib/lsb/init-functions ]; then - # SLES / OpenSuSE / Debian - . /lib/lsb/init-functions - _daemon() { start_daemon "$@"; } - _checkpid() { checkproc -p $pidfile @CMAKE_INSTALL_FULL_SBINDIR@/ibacm; } - _success() { log_success_msg; } - _failure() { log_failure_msg; } -elif [ -s /etc/rc.status ]; then - # Older SuSE - . /etc/rc.status - _daemon() { /sbin/start_daemon ${1+"$@"}; } - _checkpid() { checkproc -p $pidfile @CMAKE_INSTALL_FULL_SBINDIR@/ibacm; } - _success() { rc_status -v; } - _failure() { rc_status -v; } -fi - -start() -{ - echo -n "Starting ibacm daemon:" - _daemon @CMAKE_INSTALL_FULL_SBINDIR@/ibacm - if [[ $RETVAL -eq 0 ]]; then - _success - else - _failure - fi -} - -stop() -{ - echo -n "Stopping ibacm daemon:" - killproc -p $pidfile ibacm - if [[ $RETVAL -eq 0 ]]; then - _success - else - _failure - fi - rm -f $subsys -} - -status() -{ - echo -n "Checking for ibacm service " - if [ ! -f $subsys -a ! -f $pidfile ]; then - RETVAL=3 - elif [ -f $pidfile ]; then - _checkpid - RETVAL=$? - elif [ -f $subsys ]; then - RETVAL=2 - else - RETVAL=0 - fi - if [[ $RETVAL -eq 0 ]]; then - _success - else - _failure - fi -} - -restart () -{ - stop - start -} - -condrestart () -{ - [ -e $subsys ] && restart || return 0 -} - -usage () -{ - echo - echo "Usage: `basename $0` {start|stop|restart|condrestart|try-restart|force-reload|status}" - echo - return 2 -} - -case $1 in - start|stop|restart|condrestart|try-restart|force-reload) - [ `id -u` != "0" ] && exit 4 ;; -esac - -case $1 in - start) - start - ;; - stop) - stop - ;; - restart | reload) - restart - ;; - condrestart | try-restart | force-reload) - condrestart - ;; - status) - status - ;; - *) - usage - ;; -esac - -exit $RETVAL diff --git a/usr/rdma-core/ibacm/ibacm.service.in b/usr/rdma-core/ibacm/ibacm.service.in deleted file mode 100644 index 23d452504..000000000 --- a/usr/rdma-core/ibacm/ibacm.service.in +++ /dev/null @@ -1,24 +0,0 @@ -[Unit] -Description=InfiniBand Address Cache Manager Daemon -Documentation=man:ibacm file:@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/ibacm_opts.cfg -# Cause systemd to always start the socket, which means the parameters in -# ibacm.socket always configures the listening socket, even if the deamon is -# started directly. -Wants=ibacm.socket -# Ensure required kernel modules are loaded before starting -Wants=rdma-load-modules@rdma.service -After=rdma-load-modules@rdma.service -# Order ibacm startup after basic RDMA hw setup. -After=rdma-hw.target - -# Implicitly after basic.target, note that ibacm writes to /var/log directly -# and thus needs writable filesystems setup. - -[Service] -Type=notify -ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/ibacm --systemd - -[Install] -Also=ibacm.socket -# Only want ibacm if RDMA hardware is present (or the socket is touched) -WantedBy=rdma-hw.target diff --git a/usr/rdma-core/ibacm/ibacm.socket b/usr/rdma-core/ibacm/ibacm.socket deleted file mode 100644 index bdf1f9f4e..000000000 --- a/usr/rdma-core/ibacm/ibacm.socket +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=Socket for InfiniBand Address Cache Manager Daemon -Documentation=man:ibacm -# Ensure that anything ordered after rdma-hw.target will see the socket, even -# if that thing is not ordered after socket.target/basic.target. -Before=rdma-hw.target -# ibacm.socket always starts - -[Socket] -ListenStream=6125 -BindToDevice=lo - -# Bind to PF_NETLINK, NETLINK_RDMA, RDMA_NL_GROUP_LS -# Supported in systemd > 234 -ListenNetlink=rdma 4 - -[Install] -# Standard for all sockets -WantedBy=sockets.target diff --git a/usr/rdma-core/ibacm/ibacm_hosts.data b/usr/rdma-core/ibacm/ibacm_hosts.data deleted file mode 100644 index 78b978d90..000000000 --- a/usr/rdma-core/ibacm/ibacm_hosts.data +++ /dev/null @@ -1,15 +0,0 @@ -# InfiniBand Communication Management Assistant for clusters hosts file -# -# Entry format is: -# address IB GID -# -# The address may be one of the following: -# host_name - ascii character string, up to 31 characters -# address - IPv4 or IPv6 formatted address -# -# There can be multiple entries for a single IB GID -# -# Samples: -# luna3 fe80::8:f104:39a:169 -# 192.168.1.3 fe80::8:f104:39a:169 -# fe80::208:f104:39a:169 fe80::8:f104:39a:169 diff --git a/usr/rdma-core/ibacm/include/acm_mad.h b/usr/rdma-core/ibacm/include/acm_mad.h deleted file mode 100644 index 34fc45d24..000000000 --- a/usr/rdma-core/ibacm/include/acm_mad.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2009 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenFabrics.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(ACM_MAD_H) -#define ACM_MAD_H - -#include -#include -#include - -#define ACM_SEND_SIZE 256 -#define ACM_RECV_SIZE (ACM_SEND_SIZE + sizeof(struct ibv_grh)) - -#define IB_METHOD_GET 0x01 -#define IB_METHOD_SET 0x02 -#define IB_METHOD_SEND 0x03 -#define IB_METHOD_GET_TABLE 0x12 -#define IB_METHOD_DELETE 0x15 -#define IB_METHOD_RESP 0x80 - -#define ACM_MGMT_CLASS 0x2C - -#define ACM_CTRL_ACK htobe16(0x8000) -#define ACM_CTRL_RESOLVE htobe16(0x0001) - -struct acm_mad { - uint8_t base_version; - uint8_t mgmt_class; - uint8_t class_version; - uint8_t method; - __be16 status; - __be16 control; - __be64 tid; - - uint8_t data[240]; -}; - -#define acm_class_status(status) ((uint8_t) (be16toh(status) >> 8)) - -#define ACM_QKEY 0x80010000 - -/* Map to ACM_EP_INFO_* */ -#define ACM_ADDRESS_INVALID 0x00 -#define ACM_ADDRESS_NAME 0x01 -#define ACM_ADDRESS_IP 0x02 -#define ACM_ADDRESS_IP6 0x03 -#define ACM_ADDRESS_GID 0x04 -#define ACM_ADDRESS_LID 0x05 -#define ACM_ADDRESS_RESERVED 0x06 /* start of reserved range */ - -#define ACM_MAX_GID_COUNT 10 - -struct acm_resolve_rec { - uint8_t dest_type; - uint8_t dest_length; - uint8_t src_type; - uint8_t src_length; - uint8_t gid_cnt; - uint8_t resp_resources; - uint8_t init_depth; - uint8_t reserved; - uint8_t dest[ACM_MAX_ADDRESS]; - uint8_t src[ACM_MAX_ADDRESS]; - union ibv_gid gid[ACM_MAX_GID_COUNT]; -}; - -#define IB_MGMT_CLASS_SA 0x03 - -struct ib_sa_mad { - uint8_t base_version; - uint8_t mgmt_class; - uint8_t class_version; - uint8_t method; - __be16 status; - __be16 reserved1; - __be64 tid; - __be16 attr_id; - __be16 reserved2; - __be32 attr_mod; - - uint8_t rmpp_version; - uint8_t rmpp_type; - uint8_t rmpp_flags; - uint8_t rmpp_status; - __be32 seg_num; - __be32 paylen_newwin; - - __be32 sm_key[2]; - __be16 attr_offset; - __be16 reserved3; - __be64 comp_mask; - - uint8_t data[200]; -}; - -#define IB_SA_ATTR_PATH_REC htobe16(0x0035) - -#define IB_COMP_MASK_PR_SERVICE_ID (htobe64(1 << 0) | \ - htobe64(1 << 1)) -#define IB_COMP_MASK_PR_DGID htobe64(1 << 2) -#define IB_COMP_MASK_PR_SGID htobe64(1 << 3) -#define IB_COMP_MASK_PR_DLID htobe64(1 << 4) -#define IB_COMP_MASK_PR_SLID htobe64(1 << 5) -#define IB_COMP_MASK_PR_RAW_TRAFFIC htobe64(1 << 6) -/* RESERVED htobe64(1 << 7) */ -#define IB_COMP_MASK_PR_FLOW_LABEL htobe64(1 << 8) -#define IB_COMP_MASK_PR_HOP_LIMIT htobe64(1 << 9) -#define IB_COMP_MASK_PR_TCLASS htobe64(1 << 10) -#define IB_COMP_MASK_PR_REVERSIBLE htobe64(1 << 11) -#define IB_COMP_MASK_PR_NUM_PATH htobe64(1 << 12) -#define IB_COMP_MASK_PR_PKEY htobe64(1 << 13) -#define IB_COMP_MASK_PR_QOS_CLASS htobe64(1 << 14) -#define IB_COMP_MASK_PR_SL htobe64(1 << 15) -#define IB_COMP_MASK_PR_MTU_SELECTOR htobe64(1 << 16) -#define IB_COMP_MASK_PR_MTU htobe64(1 << 17) -#define IB_COMP_MASK_PR_RATE_SELECTOR htobe64(1 << 18) -#define IB_COMP_MASK_PR_RATE htobe64(1 << 19) -#define IB_COMP_MASK_PR_PACKET_LIFETIME_SELECTOR htobe64(1 << 20) -#define IB_COMP_MASK_PR_PACKET_LIFETIME htobe64(1 << 21) -#define IB_COMP_MASK_PR_PREFERENCE htobe64(1 << 22) -/* RESERVED htobe64(1 << 23) */ - -#define IB_MC_QPN 0xffffff -#define IB_SA_ATTR_MC_MEMBER_REC htobe16(0x0038) - -#define IB_COMP_MASK_MC_MGID htobe64(1 << 0) -#define IB_COMP_MASK_MC_PORT_GID htobe64(1 << 1) -#define IB_COMP_MASK_MC_QKEY htobe64(1 << 2) -#define IB_COMP_MASK_MC_MLID htobe64(1 << 3) -#define IB_COMP_MASK_MC_MTU_SEL htobe64(1 << 4) -#define IB_COMP_MASK_MC_MTU htobe64(1 << 5) -#define IB_COMP_MASK_MC_TCLASS htobe64(1 << 6) -#define IB_COMP_MASK_MC_PKEY htobe64(1 << 7) -#define IB_COMP_MASK_MC_RATE_SEL htobe64(1 << 8) -#define IB_COMP_MASK_MC_RATE htobe64(1 << 9) -#define IB_COMP_MASK_MC_PACKET_LIFETIME_SEL htobe64(1 << 10) -#define IB_COMP_MASK_MC_PACKET_LIFETIME htobe64(1 << 11) -#define IB_COMP_MASK_MC_SL htobe64(1 << 12) -#define IB_COMP_MASK_MC_FLOW htobe64(1 << 13) -#define IB_COMP_MASK_MC_HOP htobe64(1 << 14) -#define IB_COMP_MASK_MC_SCOPE htobe64(1 << 15) -#define IB_COMP_MASK_MC_JOIN_STATE htobe64(1 << 16) -#define IB_COMP_MASK_MC_PROXY_JOIN htobe64(1 << 17) - -struct ib_mc_member_rec { - union ibv_gid mgid; - union ibv_gid port_gid; - __be32 qkey; - __be16 mlid; - uint8_t mtu; - uint8_t tclass; - __be16 pkey; - uint8_t rate; - uint8_t packet_lifetime; - __be32 sl_flow_hop; - uint8_t scope_state; - uint8_t proxy_join; - uint8_t reserved[2]; - uint8_t pad[4]; -}; - -#endif /* ACM_MAD_H */ diff --git a/usr/rdma-core/ibacm/include/infiniband/acm.h b/usr/rdma-core/ibacm/include/infiniband/acm.h deleted file mode 100644 index b4d677cb7..000000000 --- a/usr/rdma-core/ibacm/include/infiniband/acm.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2009 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenFabrics.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(ACM_H) -#define ACM_H - -#include -#include - -#define ACM_VERSION 1 - -#define ACM_OP_MASK 0x0F -#define ACM_OP_RESOLVE 0x01 -#define ACM_OP_PERF_QUERY 0x02 -#define ACM_OP_EP_QUERY 0x03 -#define ACM_OP_ACK 0x80 - -#define ACM_STATUS_SUCCESS 0 -#define ACM_STATUS_ENOMEM 1 -#define ACM_STATUS_EINVAL 2 -#define ACM_STATUS_ENODATA 3 -#define ACM_STATUS_ENOTCONN 5 -#define ACM_STATUS_ETIMEDOUT 6 -#define ACM_STATUS_ESRCADDR 7 -#define ACM_STATUS_ESRCTYPE 8 -#define ACM_STATUS_EDESTADDR 9 -#define ACM_STATUS_EDESTTYPE 10 - -#define ACM_FLAGS_QUERY_SA (1<<31) -#define ACM_FLAGS_NODELAY (1<<30) - -#define ACM_MSG_HDR_LENGTH 16 -#define ACM_MAX_ADDRESS 64 -#define ACM_MSG_EP_LENGTH 72 -#define ACM_MAX_PROV_NAME 64 -/* - * Support up to 6 path records (primary and alternate CM paths, - * inbound and outbound primary and alternate data paths), plus CM data. - */ -#define ACM_MSG_DATA_LENGTH (ACM_MSG_EP_LENGTH * 8) - -struct acm_hdr { - uint8_t version; - uint8_t opcode; - uint8_t status; - uint8_t data[3]; - uint16_t length; - uint64_t tid; -}; - -#define ACM_EP_INFO_NAME 0x0001 -#define ACM_EP_INFO_ADDRESS_IP 0x0002 -#define ACM_EP_INFO_ADDRESS_IP6 0x0003 -#define ACM_EP_INFO_PATH 0x0010 - -union acm_ep_info { - uint8_t addr[ACM_MAX_ADDRESS]; - uint8_t name[ACM_MAX_ADDRESS]; - struct ibv_path_record path; -}; - -#define ACM_EP_FLAG_SOURCE (1<<0) -#define ACM_EP_FLAG_DEST (1<<1) - -struct acm_ep_addr_data { - uint32_t flags; - uint16_t type; - uint16_t reserved; - union acm_ep_info info; -}; - -/* - * Resolve messages with the opcode set to ACM_OP_RESOLVE are only - * used to communicate with the local ib_acm service. Message fields - * in this case are not byte swapped, but note that the acm_ep_info - * data is in network order. - */ -struct acm_resolve_msg { - struct acm_hdr hdr; - struct acm_ep_addr_data data[0]; -}; - -enum { - ACM_CNTR_ERROR, - ACM_CNTR_RESOLVE, - ACM_CNTR_NODATA, - ACM_CNTR_ADDR_QUERY, - ACM_CNTR_ADDR_CACHE, - ACM_CNTR_ROUTE_QUERY, - ACM_CNTR_ROUTE_CACHE, - ACM_MAX_COUNTER -}; - -/* - * Performance messages are sent/received in network byte order. - */ -struct acm_perf_msg { - struct acm_hdr hdr; - uint64_t data[0]; -}; - -/* - * Endpoint query messages are sent/received in network byte order. - */ -struct acm_ep_config_data { - uint64_t dev_guid; - uint8_t port_num; - uint8_t rsvd[3]; - uint16_t pkey; - uint16_t addr_cnt; - uint8_t prov_name[ACM_MAX_PROV_NAME]; - union acm_ep_info addrs[0]; -}; - -struct acm_ep_query_msg { - struct acm_hdr hdr; - struct acm_ep_config_data data[0]; -}; - -struct acm_msg { - struct acm_hdr hdr; - union{ - uint8_t data[ACM_MSG_DATA_LENGTH]; - struct acm_ep_addr_data resolve_data[0]; - uint64_t perf_data[0]; - struct acm_ep_config_data ep_data[0]; - }; -}; - -#endif /* ACM_H */ diff --git a/usr/rdma-core/ibacm/include/infiniband/acm_prov.h b/usr/rdma-core/ibacm/include/infiniband/acm_prov.h deleted file mode 100644 index 7dd07c753..000000000 --- a/usr/rdma-core/ibacm/include/infiniband/acm_prov.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2014 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenFabrics.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(ACM_PROV_H) -#define ACM_PROV_H - -#include -#include -#include - -#define ACM_PROV_VERSION 1 - -struct acm_device { - struct ibv_context *verbs; - __be64 dev_guid; -}; - -struct acm_port { - struct acm_device *dev; - uint8_t port_num; -}; - -struct acm_endpoint { - struct acm_port *port; - uint16_t pkey; -}; - -struct acm_address { - struct acm_endpoint *endpoint; - union acm_ep_info info; - char *id_string; - uint16_t type; -}; - -struct acm_provider { - size_t size; - uint32_t version; - const char *name; - int (*open_device)(const struct acm_device *device, - void **dev_context); - void (*close_device)(void *dev_context); - int (*open_port)(const struct acm_port *port, - void *dev_context, void **port_context); - void (*close_port)(void *port_context); - int (*open_endpoint)(const struct acm_endpoint *endpoint, - void *port_context, void **ep_context); - void (*close_endpoint)(void *ep_context); - int (*add_address)(const struct acm_address *addr, void *ep_context, - void **addr_context); - void (*remove_address)(void *addr_context); - int (*resolve)(void *addr_context, struct acm_msg *msg, uint64_t id); - int (*query)(void *addr_context, struct acm_msg *msg, uint64_t id); - int (*handle_event)(void *port_context, enum ibv_event_type type); - void (*query_perf)(void *ep_context, uint64_t *values, uint8_t *cnt); -}; - -int provider_query(struct acm_provider **info, uint32_t *version); - -/* Functions exported from core */ -#define acm_log(level, format, ...) \ - acm_write(level, "%s: "format, __func__, ## __VA_ARGS__) -extern void acm_write(int level, const char *format, ...) - __attribute__((format(printf, 2, 3))); -extern void acm_format_name(int level, char *name, size_t name_size, - uint8_t addr_type, const uint8_t *addr, size_t addr_size); - -extern int ib_any_gid(union ibv_gid *gid); -extern uint8_t acm_gid_index(struct acm_port *port, union ibv_gid *gid); -extern int acm_get_gid(struct acm_port *port, int index, union ibv_gid *gid); -extern __be64 acm_path_comp_mask(struct ibv_path_record *path); - -extern int acm_resolve_response(uint64_t id, struct acm_msg *msg); -extern int acm_query_response(uint64_t id, struct acm_msg *msg); - -extern enum ibv_rate acm_get_rate(uint8_t width, uint8_t speed); -extern enum ibv_mtu acm_convert_mtu(int mtu); -extern enum ibv_rate acm_convert_rate(int rate); - -struct acm_sa_mad { - void *context; - struct ib_user_mad umad; - struct umad_sa_packet sa_mad; /* must follow umad and be 64-bit aligned */ -}; - -extern struct acm_sa_mad * -acm_alloc_sa_mad(const struct acm_endpoint *endpoint, void *context, - void (*handler)(struct acm_sa_mad *)); -extern void acm_free_sa_mad(struct acm_sa_mad *mad); -extern int acm_send_sa_mad(struct acm_sa_mad *mad); - -extern const char *acm_get_opts_file(void); -extern void acm_increment_counter(int type); - -#endif /* ACM_PROV_H */ diff --git a/usr/rdma-core/ibacm/linux/osd.h b/usr/rdma-core/ibacm/linux/osd.h deleted file mode 100644 index 95713e6ae..000000000 --- a/usr/rdma-core/ibacm/linux/osd.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2009 Intel Corporation. All rights reserved. - * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under the OpenFabrics.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(OSD_H) -#define OSD_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define ACM_ADDR_FILE "ibacm_addr.cfg" -#define ACM_OPTS_FILE "ibacm_opts.cfg" - -#if DEFINE_ATOMICS -typedef struct { pthread_mutex_t mut; int val; } atomic_t; -static inline int atomic_inc(atomic_t *atomic) -{ - int v; - - pthread_mutex_lock(&atomic->mut); - v = ++(atomic->val); - pthread_mutex_unlock(&atomic->mut); - return v; -} -static inline int atomic_dec(atomic_t *atomic) -{ - int v; - - pthread_mutex_lock(&atomic->mut); - v = --(atomic->val); - pthread_mutex_unlock(&atomic->mut); - return v; -} -static inline void atomic_init(atomic_t *atomic) -{ - pthread_mutex_init(&atomic->mut, NULL); - atomic->val = 0; -} -#else -typedef struct { volatile int val; } atomic_t; -#define atomic_inc(v) (__sync_add_and_fetch(&(v)->val, 1)) -#define atomic_dec(v) (__sync_sub_and_fetch(&(v)->val, 1)) -#define atomic_init(v) ((v)->val = 0) -#endif -#define atomic_get(v) ((v)->val) -#define atomic_set(v, s) ((v)->val = s) - -typedef struct { pthread_cond_t cond; pthread_mutex_t mutex; } event_t; -static inline void event_init(event_t *e) -{ - pthread_cond_init(&e->cond, NULL); - pthread_mutex_init(&e->mutex, NULL); -} -#define event_signal(e) pthread_cond_signal(&(e)->cond) -static inline int event_wait(event_t *e, int timeout) -{ - struct timeval curtime; - struct timespec wait; - int ret; - - gettimeofday(&curtime, NULL); - wait.tv_sec = curtime.tv_sec + ((unsigned) timeout) / 1000; - wait.tv_nsec = (curtime.tv_usec + (((unsigned) timeout) % 1000) * 1000) * 1000; - pthread_mutex_lock(&e->mutex); - ret = pthread_cond_timedwait(&e->cond, &e->mutex, &wait); - pthread_mutex_unlock(&e->mutex); - return ret; -} - -static inline uint64_t time_stamp_us(void) -{ - struct timeval curtime; - timerclear(&curtime); - gettimeofday(&curtime, NULL); - return (uint64_t) curtime.tv_sec * 1000000 + (uint64_t) curtime.tv_usec; -} - -#define time_stamp_ms() (time_stamp_us() / (uint64_t) 1000) -#define time_stamp_sec() (time_stamp_ms() / (uint64_t) 1000) -#define time_stamp_min() (time_stamp_sec() / (uint64_t) 60) - -#endif /* OSD_H */ diff --git a/usr/rdma-core/ibacm/man/ib_acme.1 b/usr/rdma-core/ibacm/man/ib_acme.1 deleted file mode 100644 index fdfcae847..000000000 --- a/usr/rdma-core/ibacm/man/ib_acme.1 +++ /dev/null @@ -1,101 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "ib_acme" 1 "2014-06-16" "ib_acme" "ib_acme" ib_acme -.SH NAME -ib_acme \- test and configuration utility for the IB ACM -.SH SYNOPSIS -.sp -.nf -\fIib_acme\fR [-f addr_format] [-s src_addr] -d dest_addr [-v] [-c] [-e] [-P] [-S svc_addr] [-C repetitions] -.fi -.nf -\fIib_acme\fR [-A [addr_file]] [-O [opt_file]] [-D dest_dir] [-V] -.fi -.SH "DESCRIPTION" -ib_acme provides assistance configuring and testing the ibacm service. -The first usage of the service will test that the ibacm is running -and operating correctly. The second usage model will automatically -create address and configuration files for the ibacm service. -.SH "OPTIONS" -.TP -\-f addr_format -Specifies the format of the src_addr and dest_addr parameters. Valid -address formats are: 'i' ip address, 'n' host name, 'l' lid, 'g' gid, -and 'u' unspecified. If the -f option is omitted, -an unspecified address format is assumed. ib_acme will use getaddrinfo or -other mechanisms to determine which format the address uses. -.TP -\-s src_addr -Specifies the local source address of the path to resolve. The source -address can be an IP address, system network name, or LID, as indicated by -the addr_format option. -.TP -\-d dest_addr -Specifies the destination address of the path to resolve. The destination -address can be an IP address, system network name, or LID, as indicated by -the addr_format option. -.TP -\-v -Indicates that the resolved path information should be verified with the -active IB SA. Use of the -v option provides a sanity check that -resolved path information is usable given the current cluster configuration. -.TP -\-c -Instructs the ACM service to only returned information that currently resides -in its local cache. -.TP -\-e [N] -Displays one (N = 1, 2, ...) or all endpoints (N = 0 or not present). -.TP -\-P [opt] -Queries performance data from the destination service. Valid options are: -"col" for outputting combined data in column format, "N" (N = 1, 2, ...) for -outputting data for a specific endpoint N, "all" for outputting data for all -endpoints, and "s" for outputting data for a specific endpoint with the address -given by the -s option. -.TP -\-S svc_addr -address of ACM service, default: local service -.TP -\-C repetitions -number of repetitions to perform resolution. Used to measure -performance of ACM cache lookups. Defaults to 1. -.TP -\-A [addr_file] -With this option, the ib_acme utility automatically generates the address -configuration file ibacm_addr.cfg. The generated file is -constructed using the system host name. -.TP -\-O [opt_file] -With this option, the ib_acme utility automatically generates the option -configuration file ibacm_opts.cfg. The generated file is currently generated -using static information. -.TP -\-D dest_dir -Specify the destination directory for the output files. -.TP -\-V -Enables verbose output. When combined with -A or -O options, ib_acme will -display additional details, such as generated address information saved -to the ibacm_addr.cfg file. -.SH "NOTES" -The ib_acme utility performs two main functions. With the -A and -O options, -it automatically generates address or options configuration files. The -generated files are text based and may be edited. These options are intended -to provide a simple way to configure address and option information on all -nodes on a cluster. -.P -The other function of the ib_acme utility is to test the ibacm service, -including helping to verify that the service is usable given the current -cluster configuration. The ib_acme utility can resolve IP addresses, -network names, or IB LIDs into a path record. It can then compare that -path record against one obtained by the SA. When used to test the -ibacm service, the ib_acme utility has the side effect of loading the -ibacm caches. -.P -Multiple, numerical destinations can be specified by adding brackets [] to -the end of a base destination name or address. Users may specify a list of -numerical ranges inside the brackets using the following example as a -guide: node[1-3,5,7-8]. This will result in testing node1, node2, node3, -node5, node7, and node8. -.SH "SEE ALSO" -ibacm(7), ibacm(1) diff --git a/usr/rdma-core/ibacm/man/ibacm.1 b/usr/rdma-core/ibacm/man/ibacm.1 deleted file mode 100644 index 733dc64dd..000000000 --- a/usr/rdma-core/ibacm/man/ibacm.1 +++ /dev/null @@ -1,175 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "ibacm" 1 "2014-06-16" "ibacm" "ibacm" ibacm -.SH NAME -ibacm \- address and route resolution services for InfiniBand. -.SH SYNOPSIS -.sp -.nf -\fIibacm\fR [-D] [-P] [-A addr_file] [-O option_file] -.fi -.SH "DESCRIPTION" -The IB ACM implements and provides a framework for name, -address, and route (path) resolution services over InfiniBand. -It is intended to address connection setup scalability issues running -MPI applications on large clusters. The IB ACM provides information -needed to establish a connection, but does not implement the CM protocol. -.P -A primary user of the ibacm service is the librdmacm library. This -enables applications to make use of the ibacm service without code -changes or needing to be aware that the service is in use. -librdmacm versions 1.0.12 - 1.0.15 can invoke IB ACM services when built using -the --with-ib_acm option. Version 1.0.16 and newer of librdmacm will automatically -use the IB ACM if it is installed. The IB ACM services tie in under the -rdma_resolve_addr, rdma_resolve_route, and rdma_getaddrinfo routines. -For maximum benefit, the rdma_getaddrinfo routine should be used, -however existing applications should still see significant connection -scaling benefits using the calls -available in librdmacm 1.0.11 and previous releases. -.P -The IB ACM is focused on being scalable, efficient, and extensible. It implements -a plugin architecture that allows a vendor to supply its proprietary provider in -addition to the default provider. The current default provider implementation -ibacmp limits network traffic, SA interactions, and centralized -services. Ibacmp supports multiple resolution protocols in order to handle -different fabric topologies. -.P -The IB ACM package is comprised of three components: the ibacm core service, -the default provider ibacmp shared library, and a test/configuration utility -- ib_acme. All three are userspace components and are available for Linux. -Additional details are given below. -.SH "OPTIONS" -.TP -\-D -run in daemon mode (default) -.TP -\-P -run as standard process -.TP -\-A addr_file -address configuration file -.TP -\-O option_file -option configuration file -.TP -\--systemd -Enable systemd integration. This includes optional socket activation of the daemon's -listening socket. -.SH "QUICK START GUIDE" -1. Prerequisites: libibverbs and libibumad must be installed. -The IB stack should be running with IPoIB configured. -These steps assume that the user has administrative privileges. -.P -2. Install the IB ACM package. This installs ibacm, ibacmp, ib_acme, and init.d scripts. -.P -3. Run 'ibacm' as administrator to start the ibacm daemon. -.P -4. Optionally, run 'ib_acme -d -v' to verify that -the ibacm service is running. -.P -5. Install librdmacm, using the build option --with-ib_acm if needed. -This build option is not needed with librdmacm 1.0.17 or newer. -The librdmacm will automatically use the ibacm service. -On failures, the librdmacm will fall back to normal resolution. -.P -6. You can use ib_acme -P to gather performance statistics from the local ibacm -daemon to see if the service is working correctly. Similarly, the command -ib_acme -e could be used to enumerate all endpoints created by the local ibacm -service. -.SH "NOTES" -ib_acme: -.P -The ib_acme program serves a dual role. It acts as a utility to test -ibacm operation and help verify if the ibacm service and selected -protocol is usable for a given cluster configuration. Additionally, -it automatically generates ibacm configuration files to assist with -or eliminate manual setup. -.P -ibacm configuration files: -.P -The ibacm service relies on two configuration files. -.P -The ibacm_addr.cfg file contains name and address mappings for each IB - endpoint. Although the names in the ibacm_addr.cfg -file can be anything, ib_acme maps the host name to the IB endpoints. IP -addresses, on the other hand, are assigned dynamically. If the address file -cannot be found, the ibacm service will attempt to create one using default -values. -.P -The ibacm_opts.cfg file provides a set of configurable options for the -ibacm core service and default provider, such as timeout, number of retries, -logging level, etc. ib_acme generates the ibacm_opts.cfg file using static -information. If an option file cannot be found, ibacm will use default values. -.P -ibacm: -.P -The ibacm service is responsible for resolving names and addresses to -InfiniBand path information and caching such data. It -should execute with administrative privileges. -.P -The ibacm implements a client interface over TCP sockets, which is -abstracted by the librdmacm library. One or more providers can be loaded -by the core service, depending on the configuration. In the default provider -ibacmp, one or more back-end protocols are used to satisfy user requests. -Although ibacmp supports standard SA path record queries on the back-end, it -also supports a resolution protocol based on multicast traffic. -The latter is not usable on all fabric topologies, specifically -ones that may not have reversible paths or fabrics using torus routing. -Users should use the ib_acme utility to verify that multicast protocol -is usable before running other applications. -.P -Conceptually, the default provider ibacmp implements an ARP like protocol and either -uses IB multicast records to construct path record data or queries the -SA directly, depending on the selected route protocol. By default, the -ibacmp provider uses and caches SA path record queries. -.P -Specifically, all IB endpoints join a number of multicast groups. -Multicast groups differ based on rates, mtu, sl, etc., and are prioritized. -All participating endpoints must be able to communicate on the lowest -priority multicast group. The ibacmp assigns one or more names/addresses -to each IB endpoint using the ibacm_addr.cfg file. Clients provide source -and destination names or addresses as input to the service, and receive -as output path record data. -.P -The service maps a client's source name/address to a local IB endpoint. -If the destination name/address is not cached locally in the default provider, -it sends a multicast request out on the lowest priority multicast group on the -local endpoint. The request carries a list of multicast groups that the sender can use. -The recipient of the request selects the highest priority multicast group -that it can use as well and returns that information directly to the sender. -The request data is cached by all endpoints that receive the multicast -request message. The source endpoint also caches the response and uses -the multicast group that was selected to construct or obtain path record -data, which is returned to the client. -.P -The current implementation of the provider ibacmp has several additional restrictions: -.P -- The ibacmp is limited in its handling of dynamic changes. -ibacm must be stopped and restarted if a cluster is reconfigured. -.P -- Cached data does not timed out and is only updated if a new resolution -request is received from a different QPN than a cached request. -.P -- Support for IPv6 has not been verified. -.P -- The number of addresses that can be assigned to a single endpoint is -limited to 4. -.P -- The number of multicast groups that an endpoint can support is limited to 2. -.P -The ibacmp contains several internal caches. These include caches for GID -and LID destination addresses. These caches can be optionally -preloaded. ibacm supports the OpenSM dump_pr plugin "full" PathRecord -format which is used to preload these caches. -The file format is specified in the ibacm_opts.cfg file via the -route_preload setting which should be set to full_opensm_v1 for this -file format. Default format is none which does not preload these caches. -See dump_pr.notes.txt in dump_pr for more information on the -full_opensm_v1 file format and how to configure OpenSM to -generate this file. -.P -Additionally, the name, IPv4, and IPv6 caches can be be preloaded by using -the addr_preload option. The default is none which does not preload these -caches. To preload these caches, set this option to acm_hosts and -configure the addr_data_file appropriately. -.SH "SEE ALSO" -ibacm(7), ib_acme(1), rdma_cm(7) diff --git a/usr/rdma-core/ibacm/man/ibacm.7 b/usr/rdma-core/ibacm/man/ibacm.7 deleted file mode 100644 index 14b5d08d8..000000000 --- a/usr/rdma-core/ibacm/man/ibacm.7 +++ /dev/null @@ -1,32 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "IBACM" 7 "2014-06-16" "IBACM" "IB ACM User Guide" IBACM -.SH NAME -ibacm \- InfiniBand communication management assistant -.SH SYNOPSIS -.B "#include " -.SH "DESCRIPTION" -Used to resolve remote endpoint information before establishing communications -over InfiniBand. -.SH "NOTES" -Th IB ACM provides scalable address and route resolution services over -InfiniBand. It resolves system network names and IP addresses to InfiniBand -path record data using efficient mechanisms, including caching of data. -.P -The IB ACM provides information needed to establish a connection, but does -not implement the communication management protocol. It provides services -similar to rdma_getaddrinfo, rdma_resolve_addr, and rdma_resolve_route using -IB multicast. -The IB ACM does not require IPoIB or use standard naming services, such as -DNS, and limits network communication, especially with the IB SA. -The ib_acme utility assists in verifying what options of the ibacm service -may be usable for the current fabric topology. -.P -Client interactions with the ibacm service are done over sockets through -a standard TCP connection. The librdmacm abstracts this interaction. -.SH "RETURN CODES" -.IP "== 0" -success -.IP "!= 0" -error -.SH "SEE ALSO" -ib_acme(1), ibacm(1) diff --git a/usr/rdma-core/ibacm/man/ibacm_prov.7.in b/usr/rdma-core/ibacm/man/ibacm_prov.7.in deleted file mode 100644 index 494fdc3b0..000000000 --- a/usr/rdma-core/ibacm/man/ibacm_prov.7.in +++ /dev/null @@ -1,81 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "IBACM_PROV" 7 "2014-06-16" "IBACM_PROV" "IB ACM Provider Guide" IBACM_PROV -.SH NAME -ibacm_prov \- InfiniBand communication management assistant provider interface -.SH SYNOPSIS -.B "#include " -.SH "DESCRIPTION" -The ibacm provider interface provides a plugin interface that allows a vendor -to implement proprietary solutions to support scalable address and route -resolution services over InfiniBand. -.P -To add a provider to the ibacm core service, the provider must -.TP -1. be implemented as a shared library; -.TP -2. be installed under a configured directory, eg., @ACM_PROVIDER_DIR@; -.TP -3 export a function provider_query() that returns a pointer to its provider info -and version info. -.P -The prototype of provider_query function is defined below: -.P -.nf -int provider_query(struct acm_provider **info, uint32_t *version); -.fi -.P -This function should return a pointer to its provider structure: -.P -.nf -struct acm_provider { - size_t size; - uint32_t version; - char *name; - int (*open_device)(const struct acm_device *device, - void **dev_context); - void (*close_device)(void *dev_context); - int (*open_port)(const struct acm_port *port, - void *dev_context, void **port_context); - void (*close_port)(void *port_context); - int (*open_endpoint)(const struct acm_endpoint *endpoint, - void *port_context, void **ep_context); - void (*close_endpoint)(void *ep_context); - int (*add_address)(const struct acm_address *addr, void *ep_context, - void **addr_context); - void (*remove_address)(void *addr_context); - int (*resolve)(void *addr_context, struct acm_msg *msg, uint64_t id); - int (*query)(void *addr_context, struct acm_msg *msg, uint64_t id); - int (*handle_event)(void *port_context, enum ibv_event_type type); - void (*query_perf)(void *ep_context, uint64_t *values, uint8_t *cnt); -}; -.fi -.P -The size and version fields provide a way to detect version compatibility. -When a port is assigned to the provider, the ibacm core will call the -open/add_address functions; Similarly, when a port is down or re-assigned to -another provider, the close/remove_address functions will be invoked to release -resources. The ibacm core will centralize the management of events for each device -and events not handled by the ibacm core will be forwarded to the relevant port -through the handle_event() function. The resolve() function will be called to -resolve a destination name into a path record. The performance of the provider -for each endpoint can be queried by calling perf_query(). -.P -To share a configuration file, the path for the ibacm configuration file is -exported through the variable opts_file. Each loaded provider can open this -configuration file and parse the contents related to its own operation. -Non-related sections should be ignored. -.P -Some helper functions are also exported by the ibacm core. For example, the -acm_log define (or the acm_write() function) can be used to log messages into -ibacm's log file (default @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/ibacm.log). For details, refer to -the acm_prov.h file. -.SH "NOTES" -A provider should always set the version in its provider info structure as the -value of the define ACM_PROV_VERSION at the time the provider is implemented. Never -set the version to ACM_PROV_VERSION itself as the define may be changed over time -when the provider interface is changed, unless the provider itself is placed in -ibacm source tree. This is to avoid the version problem when the old provider -implementation is built against a new acm_prov.h file. The ibacm will always -check the version of the provider at loading time. -.SH "SEE ALSO" -ib_acme(1), ibacm(1), ibacm(7) diff --git a/usr/rdma-core/ibacm/prov/acmp/src/acmp.c b/usr/rdma-core/ibacm/prov/acmp/src/acmp.c deleted file mode 100644 index aa7841668..000000000 --- a/usr/rdma-core/ibacm/prov/acmp/src/acmp.c +++ /dev/null @@ -1,2946 +0,0 @@ -/* - * Copyright (c) 2009-2014 Intel Corporation. All rights reserved. - * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "acm_util.h" -#include "acm_mad.h" - -#define src_out data[0] -#define src_index data[1] -#define dst_index data[2] - -#define IB_LID_MCAST_START 0xc000 - -#define MAX_EP_ADDR 4 -#define MAX_EP_MC 2 - -enum acmp_state { - ACMP_INIT, - ACMP_QUERY_ADDR, - ACMP_ADDR_RESOLVED, - ACMP_QUERY_ROUTE, - ACMP_READY -}; - -enum acmp_addr_prot { - ACMP_ADDR_PROT_ACM -}; - -enum acmp_route_prot { - ACMP_ROUTE_PROT_ACM, - ACMP_ROUTE_PROT_SA -}; - -enum acmp_loopback_prot { - ACMP_LOOPBACK_PROT_NONE, - ACMP_LOOPBACK_PROT_LOCAL -}; - -enum acmp_route_preload { - ACMP_ROUTE_PRELOAD_NONE, - ACMP_ROUTE_PRELOAD_OSM_FULL_V1 -}; - -enum acmp_addr_preload { - ACMP_ADDR_PRELOAD_NONE, - ACMP_ADDR_PRELOAD_HOSTS -}; - -/* - * Nested locking order: dest -> ep, dest -> port - */ -struct acmp_ep; - -struct acmp_dest { - uint8_t address[ACM_MAX_ADDRESS]; /* keep first */ - char name[ACM_MAX_ADDRESS]; - struct ibv_ah *ah; - struct ibv_ah_attr av; - struct ibv_path_record path; - union ibv_gid mgid; - __be64 req_id; - struct list_head req_queue; - uint32_t remote_qpn; - pthread_mutex_t lock; - enum acmp_state state; - atomic_t refcnt; - uint64_t addr_timeout; - uint64_t route_timeout; - uint8_t addr_type; - struct acmp_ep *ep; -}; - -struct acmp_device; - -struct acmp_port { - struct acmp_device *dev; - const struct acm_port *port; - struct list_head ep_list; - pthread_mutex_t lock; - struct acmp_dest sa_dest; - enum ibv_port_state state; - enum ibv_mtu mtu; - enum ibv_rate rate; - int subnet_timeout; - uint16_t default_pkey_ix; - uint16_t lid; - uint16_t lid_mask; - uint8_t port_num; -}; - -struct acmp_device { - struct ibv_context *verbs; - const struct acm_device *device; - struct ibv_comp_channel *channel; - struct ibv_pd *pd; - __be64 guid; - struct list_node entry; - pthread_t comp_thread_id; - int port_cnt; - struct acmp_port port[0]; -}; - -/* Maintain separate virtual send queues to avoid deadlock */ -struct acmp_send_queue { - int credits; - struct list_head pending; -}; - -struct acmp_addr { - uint16_t type; - union acm_ep_info info; - struct acm_address *addr; - struct acmp_ep *ep; -}; - -struct acmp_ep { - struct acmp_port *port; - struct ibv_cq *cq; - struct ibv_qp *qp; - struct ibv_mr *mr; - uint8_t *recv_bufs; - struct list_node entry; - char id_string[IBV_SYSFS_NAME_MAX + 11]; - void *dest_map[ACM_ADDRESS_RESERVED - 1]; - struct acmp_dest mc_dest[MAX_EP_MC]; - int mc_cnt; - uint16_t pkey_index; - uint16_t pkey; - const struct acm_endpoint *endpoint; - pthread_mutex_t lock; - struct acmp_send_queue resolve_queue; - struct acmp_send_queue resp_queue; - struct list_head active_queue; - struct list_head wait_queue; - enum acmp_state state; - struct acmp_addr addr_info[MAX_EP_ADDR]; - atomic_t counters[ACM_MAX_COUNTER]; -}; - -struct acmp_send_msg { - struct list_node entry; - struct acmp_ep *ep; - struct acmp_dest *dest; - struct ibv_ah *ah; - void *context; - void (*resp_handler)(struct acmp_send_msg *req, - struct ibv_wc *wc, struct acm_mad *resp); - struct acmp_send_queue *req_queue; - struct ibv_mr *mr; - struct ibv_send_wr wr; - struct ibv_sge sge; - uint64_t expires; - int tries; - uint8_t data[ACM_SEND_SIZE]; -}; - -struct acmp_request { - uint64_t id; - struct list_node entry; - struct acm_msg msg; - struct acmp_ep *ep; -}; - -static int acmp_open_dev(const struct acm_device *device, void **dev_context); -static void acmp_close_dev(void *dev_context); -static int acmp_open_port(const struct acm_port *port, void *dev_context, - void **port_context); -static void acmp_close_port(void *port_context); -static int acmp_open_endpoint(const struct acm_endpoint *endpoint, - void *port_context, void **ep_context); -static void acmp_close_endpoint(void *ep_context); -static int acmp_add_addr(const struct acm_address *addr, void *ep_context, - void **addr_context); -static void acmp_remove_addr(void *addr_context); -static int acmp_resolve(void *addr_context, struct acm_msg *msg, uint64_t id); -static int acmp_query(void *addr_context, struct acm_msg *msg, uint64_t id); -static int acmp_handle_event(void *port_context, enum ibv_event_type type); -static void acmp_query_perf(void *ep_context, uint64_t *values, uint8_t *cnt); - -static struct acm_provider def_prov = { - .size = sizeof(struct acm_provider), - .version = ACM_PROV_VERSION, - .name = "ibacmp", - .open_device = acmp_open_dev, - .close_device = acmp_close_dev, - .open_port = acmp_open_port, - .close_port = acmp_close_port, - .open_endpoint = acmp_open_endpoint, - .close_endpoint = acmp_close_endpoint, - .add_address = acmp_add_addr, - .remove_address = acmp_remove_addr, - .resolve = acmp_resolve, - .query = acmp_query, - .handle_event = acmp_handle_event, - .query_perf = acmp_query_perf, -}; - -static LIST_HEAD(acmp_dev_list); -static pthread_mutex_t acmp_dev_lock; - -static atomic_t g_tid; -static LIST_HEAD(timeout_list); -static event_t timeout_event; -static atomic_t wait_cnt; -static pthread_t retry_thread_id; -static int retry_thread_started = 0; - -static __thread char log_data[ACM_MAX_ADDRESS]; - -/* - * Service options - may be set through ibacm_opts.cfg file. - */ -static char route_data_file[128] = ACM_CONF_DIR "/ibacm_route.data"; -static char addr_data_file[128] = ACM_CONF_DIR "/ibacm_hosts.data"; -static enum acmp_addr_prot addr_prot = ACMP_ADDR_PROT_ACM; -static int addr_timeout = 1440; -static enum acmp_route_prot route_prot = ACMP_ROUTE_PROT_SA; -static int route_timeout = -1; -static enum acmp_loopback_prot loopback_prot = ACMP_LOOPBACK_PROT_LOCAL; -static int timeout = 2000; -static int retries = 2; -static int resolve_depth = 1; -static int send_depth = 1; -static int recv_depth = 1024; -static uint8_t min_mtu = IBV_MTU_2048; -static uint8_t min_rate = IBV_RATE_10_GBPS; -static enum acmp_route_preload route_preload; -static enum acmp_addr_preload addr_preload; - -static int acmp_initialized = 0; - -static int acmp_compare_dest(const void *dest1, const void *dest2) -{ - return memcmp(dest1, dest2, ACM_MAX_ADDRESS); -} - -static void -acmp_set_dest_addr(struct acmp_dest *dest, uint8_t addr_type, - const uint8_t *addr, size_t size) -{ - memcpy(dest->address, addr, size); - dest->addr_type = addr_type; - acm_format_name(0, dest->name, sizeof dest->name, addr_type, addr, size); -} - -static void -acmp_init_dest(struct acmp_dest *dest, uint8_t addr_type, - const uint8_t *addr, size_t size) -{ - list_head_init(&dest->req_queue); - atomic_init(&dest->refcnt); - atomic_set(&dest->refcnt, 1); - pthread_mutex_init(&dest->lock, NULL); - if (size) - acmp_set_dest_addr(dest, addr_type, addr, size); - dest->state = ACMP_INIT; -} - -static struct acmp_dest * -acmp_alloc_dest(uint8_t addr_type, const uint8_t *addr) -{ - struct acmp_dest *dest; - - dest = calloc(1, sizeof *dest); - if (!dest) { - acm_log(0, "ERROR - unable to allocate dest\n"); - return NULL; - } - - acmp_init_dest(dest, addr_type, addr, ACM_MAX_ADDRESS); - acm_log(1, "%s\n", dest->name); - return dest; -} - -/* Caller must hold ep lock. */ -static struct acmp_dest * -acmp_get_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr) -{ - struct acmp_dest *dest, **tdest; - - tdest = tfind(addr, &ep->dest_map[addr_type - 1], acmp_compare_dest); - if (tdest) { - dest = *tdest; - (void) atomic_inc(&dest->refcnt); - acm_log(2, "%s\n", dest->name); - } else { - dest = NULL; - acm_format_name(2, log_data, sizeof log_data, - addr_type, addr, ACM_MAX_ADDRESS); - acm_log(2, "%s not found\n", log_data); - } - return dest; -} - -static void -acmp_put_dest(struct acmp_dest *dest) -{ - acm_log(2, "%s\n", dest->name); - if (atomic_dec(&dest->refcnt) == 0) { - free(dest); - } -} - -/* Caller must hold ep lock. */ -static void -acmp_remove_dest(struct acmp_ep *ep, struct acmp_dest *dest) -{ - acm_log(2, "%s\n", dest->name); - tdelete(dest->address, &ep->dest_map[dest->addr_type - 1], - acmp_compare_dest); - acmp_put_dest(dest); -} - -static struct acmp_dest * -acmp_acquire_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr) -{ - struct acmp_dest *dest; - int64_t rec_expr_minutes; - - acm_format_name(2, log_data, sizeof log_data, - addr_type, addr, ACM_MAX_ADDRESS); - acm_log(2, "%s\n", log_data); - pthread_mutex_lock(&ep->lock); - dest = acmp_get_dest(ep, addr_type, addr); - if (dest && dest->state == ACMP_READY && - dest->addr_timeout != (uint64_t)~0ULL) { - rec_expr_minutes = dest->addr_timeout - time_stamp_min(); - if (rec_expr_minutes <= 0) { - acm_log(2, "Record expired\n"); - acmp_remove_dest(ep, dest); - dest = NULL; - } else { - acm_log(2, "Record valid for the next %" PRId64 " minute(s)\n", - rec_expr_minutes); - } - } - if (!dest) { - dest = acmp_alloc_dest(addr_type, addr); - if (dest) { - dest->ep = ep; - tsearch(dest, &ep->dest_map[addr_type - 1], acmp_compare_dest); - (void) atomic_inc(&dest->refcnt); - } - } - pthread_mutex_unlock(&ep->lock); - return dest; -} - -static struct acmp_request *acmp_alloc_req(uint64_t id, struct acm_msg *msg) -{ - struct acmp_request *req; - - req = calloc(1, sizeof *req); - if (!req) { - acm_log(0, "ERROR - unable to alloc client request\n"); - return NULL; - } - - req->id = id; - memcpy(&req->msg, msg, sizeof(req->msg)); - acm_log(2, "id %" PRIu64 ", req %p\n", id, req); - return req; -} - -static void acmp_free_req(struct acmp_request *req) -{ - acm_log(2, "%p\n", req); - free(req); -} - -static struct acmp_send_msg * -acmp_alloc_send(struct acmp_ep *ep, struct acmp_dest *dest, size_t size) -{ - struct acmp_send_msg *msg; - - msg = (struct acmp_send_msg *) calloc(1, sizeof *msg); - if (!msg) { - acm_log(0, "ERROR - unable to allocate send buffer\n"); - return NULL; - } - - msg->ep = ep; - msg->mr = ibv_reg_mr(ep->port->dev->pd, msg->data, size, 0); - if (!msg->mr) { - acm_log(0, "ERROR - failed to register send buffer\n"); - goto err1; - } - - if (!dest->ah) { - msg->ah = ibv_create_ah(ep->port->dev->pd, &dest->av); - if (!msg->ah) { - acm_log(0, "ERROR - unable to create ah\n"); - goto err2; - } - msg->wr.wr.ud.ah = msg->ah; - } else { - msg->wr.wr.ud.ah = dest->ah; - } - - acm_log(2, "get dest %s\n", dest->name); - (void) atomic_inc(&dest->refcnt); - msg->dest = dest; - - msg->wr.next = NULL; - msg->wr.sg_list = &msg->sge; - msg->wr.num_sge = 1; - msg->wr.opcode = IBV_WR_SEND; - msg->wr.send_flags = IBV_SEND_SIGNALED; - msg->wr.wr_id = (uintptr_t) msg; - msg->wr.wr.ud.remote_qpn = dest->remote_qpn; - msg->wr.wr.ud.remote_qkey = ACM_QKEY; - - msg->sge.length = size; - msg->sge.lkey = msg->mr->lkey; - msg->sge.addr = (uintptr_t) msg->data; - acm_log(2, "%p\n", msg); - return msg; - -err2: - ibv_dereg_mr(msg->mr); -err1: - free(msg); - return NULL; -} - -static void -acmp_init_send_req(struct acmp_send_msg *msg, void *context, - void (*resp_handler)(struct acmp_send_msg *req, - struct ibv_wc *wc, struct acm_mad *resp)) -{ - acm_log(2, "%p\n", msg); - msg->tries = retries + 1; - msg->context = context; - msg->resp_handler = resp_handler; -} - -static void acmp_free_send(struct acmp_send_msg *msg) -{ - acm_log(2, "%p\n", msg); - if (msg->ah) - ibv_destroy_ah(msg->ah); - ibv_dereg_mr(msg->mr); - acmp_put_dest(msg->dest); - free(msg); -} - -static void acmp_post_send(struct acmp_send_queue *queue, struct acmp_send_msg *msg) -{ - struct acmp_ep *ep = msg->ep; - struct ibv_send_wr *bad_wr; - - msg->req_queue = queue; - pthread_mutex_lock(&ep->lock); - if (queue->credits) { - acm_log(2, "posting send to QP\n"); - queue->credits--; - list_add_tail(&ep->active_queue, &msg->entry); - ibv_post_send(ep->qp, &msg->wr, &bad_wr); - } else { - acm_log(2, "no sends available, queuing message\n"); - list_add_tail(&queue->pending, &msg->entry); - } - pthread_mutex_unlock(&ep->lock); -} - -static void acmp_post_recv(struct acmp_ep *ep, uint64_t address) -{ - struct ibv_recv_wr wr, *bad_wr; - struct ibv_sge sge; - - wr.next = NULL; - wr.sg_list = &sge; - wr.num_sge = 1; - wr.wr_id = address; - - sge.length = ACM_RECV_SIZE; - sge.lkey = ep->mr->lkey; - sge.addr = address; - - ibv_post_recv(ep->qp, &wr, &bad_wr); -} - -/* Caller must hold ep lock */ -static void acmp_send_available(struct acmp_ep *ep, struct acmp_send_queue *queue) -{ - struct acmp_send_msg *msg; - struct ibv_send_wr *bad_wr; - - msg = list_pop(&queue->pending, struct acmp_send_msg, entry); - if (msg) { - acm_log(2, "posting queued send message\n"); - list_add_tail(&ep->active_queue, &msg->entry); - ibv_post_send(ep->qp, &msg->wr, &bad_wr); - } else { - queue->credits++; - } -} - -static void acmp_complete_send(struct acmp_send_msg *msg) -{ - struct acmp_ep *ep = msg->ep; - - pthread_mutex_lock(&ep->lock); - list_del(&msg->entry); - if (msg->tries) { - acm_log(2, "waiting for response\n"); - msg->expires = time_stamp_ms() + ep->port->subnet_timeout + timeout; - list_add_tail(&ep->wait_queue, &msg->entry); - if (atomic_inc(&wait_cnt) == 1) - event_signal(&timeout_event); - } else { - acm_log(2, "freeing\n"); - acmp_send_available(ep, msg->req_queue); - acmp_free_send(msg); - } - pthread_mutex_unlock(&ep->lock); -} - -static struct acmp_send_msg *acmp_get_request(struct acmp_ep *ep, __be64 tid, int *free) -{ - struct acmp_send_msg *msg, *next, *req = NULL; - struct acm_mad *mad; - - acm_log(2, "\n"); - pthread_mutex_lock(&ep->lock); - list_for_each_safe(&ep->wait_queue, msg, next, entry) { - mad = (struct acm_mad *) msg->data; - if (mad->tid == tid) { - acm_log(2, "match found in wait queue\n"); - req = msg; - list_del(&msg->entry); - (void) atomic_dec(&wait_cnt); - acmp_send_available(ep, msg->req_queue); - *free = 1; - goto unlock; - } - } - - list_for_each(&ep->active_queue, msg, entry) { - mad = (struct acm_mad *) msg->data; - if (mad->tid == tid && msg->tries) { - acm_log(2, "match found in active queue\n"); - req = msg; - req->tries = 0; - *free = 0; - break; - } - } -unlock: - pthread_mutex_unlock(&ep->lock); - return req; -} - -static int acmp_mc_index(struct acmp_ep *ep, union ibv_gid *gid) -{ - int i; - - for (i = 0; i < ep->mc_cnt; i++) { - if (!memcmp(&ep->mc_dest[i].address, gid, sizeof(*gid))) - return i; - } - return -1; -} - -/* Multicast groups are ordered lowest to highest preference. */ -static int acmp_best_mc_index(struct acmp_ep *ep, struct acm_resolve_rec *rec) -{ - int i, index; - - for (i = min_t(int, rec->gid_cnt, ACM_MAX_GID_COUNT) - 1; i >= 0; i--) { - index = acmp_mc_index(ep, &rec->gid[i]); - if (index >= 0) { - return index; - } - } - return -1; -} - -static void -acmp_record_mc_av(struct acmp_port *port, struct ib_mc_member_rec *mc_rec, - struct acmp_dest *dest) -{ - uint32_t sl_flow_hop; - - sl_flow_hop = be32toh(mc_rec->sl_flow_hop); - - dest->av.dlid = be16toh(mc_rec->mlid); - dest->av.sl = (uint8_t) (sl_flow_hop >> 28); - dest->av.src_path_bits = port->sa_dest.av.src_path_bits; - dest->av.static_rate = mc_rec->rate & 0x3F; - dest->av.port_num = port->port_num; - - dest->av.is_global = 1; - dest->av.grh.dgid = mc_rec->mgid; - dest->av.grh.flow_label = (sl_flow_hop >> 8) & 0xFFFFF; - dest->av.grh.sgid_index = acm_gid_index((struct acm_port *) port->port, - &mc_rec->port_gid); - dest->av.grh.hop_limit = (uint8_t) sl_flow_hop; - dest->av.grh.traffic_class = mc_rec->tclass; - - dest->path.dgid = mc_rec->mgid; - dest->path.sgid = mc_rec->port_gid; - dest->path.dlid = mc_rec->mlid; - dest->path.slid = htobe16(port->lid | port->sa_dest.av.src_path_bits); - dest->path.flowlabel_hoplimit = htobe32(sl_flow_hop & 0xFFFFFFF); - dest->path.tclass = mc_rec->tclass; - dest->path.reversible_numpath = IBV_PATH_RECORD_REVERSIBLE | 1; - dest->path.pkey = mc_rec->pkey; - dest->path.qosclass_sl = htobe16((uint16_t) (sl_flow_hop >> 28)); - dest->path.mtu = mc_rec->mtu; - dest->path.rate = mc_rec->rate; - dest->path.packetlifetime = mc_rec->packet_lifetime; -} - -/* Always send the GRH to transfer GID data to remote side */ -static void -acmp_init_path_av(struct acmp_port *port, struct acmp_dest *dest) -{ - uint32_t flow_hop; - - dest->av.dlid = be16toh(dest->path.dlid); - dest->av.sl = be16toh(dest->path.qosclass_sl) & 0xF; - dest->av.src_path_bits = be16toh(dest->path.slid) & 0x7F; - dest->av.static_rate = dest->path.rate & 0x3F; - dest->av.port_num = port->port_num; - - flow_hop = be32toh(dest->path.flowlabel_hoplimit); - dest->av.is_global = 1; - dest->av.grh.flow_label = (flow_hop >> 8) & 0xFFFFF; - pthread_mutex_lock(&port->lock); - if (port->port) - dest->av.grh.sgid_index = acm_gid_index( - (struct acm_port *) port->port, &dest->path.sgid); - else - dest->av.grh.sgid_index = 0; - pthread_mutex_unlock(&port->lock); - dest->av.grh.hop_limit = (uint8_t) flow_hop; - dest->av.grh.traffic_class = dest->path.tclass; -} - -static void acmp_process_join_resp(struct acm_sa_mad *sa_mad) -{ - struct acmp_dest *dest; - struct ib_mc_member_rec *mc_rec; - struct ib_sa_mad *mad; - int index, ret; - struct acmp_ep *ep = sa_mad->context; - - mad = (struct ib_sa_mad *) &sa_mad->sa_mad; - acm_log(1, "response status: 0x%x, mad status: 0x%x\n", - sa_mad->umad.status, mad->status); - pthread_mutex_lock(&ep->lock); - if (sa_mad->umad.status) { - acm_log(0, "ERROR - send join failed 0x%x\n", sa_mad->umad.status); - goto out; - } - if (mad->status) { - acm_log(0, "ERROR - join response status 0x%x\n", mad->status); - goto out; - } - - mc_rec = (struct ib_mc_member_rec *) mad->data; - index = acmp_mc_index(ep, &mc_rec->mgid); - if (index < 0) { - acm_log(0, "ERROR - MGID in join response not found\n"); - goto out; - } - - dest = &ep->mc_dest[index]; - dest->remote_qpn = IB_MC_QPN; - dest->mgid = mc_rec->mgid; - acmp_record_mc_av(ep->port, mc_rec, dest); - - if (index == 0) { - dest->ah = ibv_create_ah(ep->port->dev->pd, &dest->av); - if (!dest->ah) { - acm_log(0, "ERROR - unable to create ah\n"); - goto out; - } - ret = ibv_attach_mcast(ep->qp, &mc_rec->mgid, mc_rec->mlid); - if (ret) { - acm_log(0, "ERROR - unable to attach QP to multicast group\n"); - ibv_destroy_ah(dest->ah); - dest->ah = NULL; - goto out; - } - ep->state = ACMP_READY; - } - - atomic_set(&dest->refcnt, 1); - dest->state = ACMP_READY; - acm_log(1, "join successful\n"); -out: - acm_free_sa_mad(sa_mad); - pthread_mutex_unlock(&ep->lock); -} - -static uint8_t -acmp_record_acm_route(struct acmp_ep *ep, struct acmp_dest *dest) -{ - int i; - - acm_log(2, "\n"); - for (i = 0; i < MAX_EP_MC; i++) { - if (!memcmp(&dest->mgid, &ep->mc_dest[i].mgid, sizeof dest->mgid)) - break; - } - if (i == MAX_EP_MC) { - acm_log(0, "ERROR - cannot match mgid\n"); - return ACM_STATUS_EINVAL; - } - - dest->path = ep->mc_dest[i].path; - dest->path.dgid = dest->av.grh.dgid; - dest->path.dlid = htobe16(dest->av.dlid); - dest->addr_timeout = time_stamp_min() + (unsigned) addr_timeout; - dest->route_timeout = time_stamp_min() + (unsigned) route_timeout; - dest->state = ACMP_READY; - return ACM_STATUS_SUCCESS; -} - -static void acmp_init_path_query(struct ib_sa_mad *mad) -{ - acm_log(2, "\n"); - mad->base_version = 1; - mad->mgmt_class = IB_MGMT_CLASS_SA; - mad->class_version = 2; - mad->method = IB_METHOD_GET; - mad->tid = htobe64((uint64_t) atomic_inc(&g_tid)); - mad->attr_id = IB_SA_ATTR_PATH_REC; -} - -/* Caller must hold dest lock */ -static uint8_t acmp_resolve_path_sa(struct acmp_ep *ep, struct acmp_dest *dest, - void (*handler)(struct acm_sa_mad *)) -{ - struct ib_sa_mad *mad; - uint8_t ret; - struct acm_sa_mad *sa_mad; - - acm_log(2, "%s\n", dest->name); - - sa_mad = acm_alloc_sa_mad(ep->endpoint, dest, handler); - if (!sa_mad) { - acm_log(0, "Error - failed to allocate sa_mad\n"); - ret = ACM_STATUS_ENOMEM; - goto err; - } - - mad = (struct ib_sa_mad *) &sa_mad->sa_mad; - acmp_init_path_query(mad); - - memcpy(mad->data, &dest->path, sizeof(dest->path)); - mad->comp_mask = acm_path_comp_mask(&dest->path); - - acm_increment_counter(ACM_CNTR_ROUTE_QUERY); - atomic_inc(&ep->counters[ACM_CNTR_ROUTE_QUERY]); - dest->state = ACMP_QUERY_ROUTE; - if (acm_send_sa_mad(sa_mad)) { - acm_log(0, "Error - Failed to send sa mad\n"); - ret = ACM_STATUS_ENODATA; - goto free_mad; - } - return ACM_STATUS_SUCCESS; -free_mad: - acm_free_sa_mad(sa_mad); -err: - dest->state = ACMP_INIT; - return ret; -} - -static uint8_t -acmp_record_acm_addr(struct acmp_ep *ep, struct acmp_dest *dest, struct ibv_wc *wc, - struct acm_resolve_rec *rec) -{ - int index; - - acm_log(2, "%s\n", dest->name); - index = acmp_best_mc_index(ep, rec); - if (index < 0) { - acm_log(0, "ERROR - no shared multicast groups\n"); - dest->state = ACMP_INIT; - return ACM_STATUS_ENODATA; - } - - acm_log(2, "selecting MC group at index %d\n", index); - dest->av = ep->mc_dest[index].av; - dest->av.dlid = wc->slid; - dest->av.src_path_bits = wc->dlid_path_bits; - dest->av.grh.dgid = ((struct ibv_grh *) (uintptr_t) wc->wr_id)->sgid; - - dest->mgid = ep->mc_dest[index].mgid; - dest->path.sgid = ep->mc_dest[index].path.sgid; - dest->path.dgid = dest->av.grh.dgid; - dest->path.tclass = ep->mc_dest[index].path.tclass; - dest->path.pkey = ep->mc_dest[index].path.pkey; - dest->remote_qpn = wc->src_qp; - - dest->state = ACMP_ADDR_RESOLVED; - return ACM_STATUS_SUCCESS; -} - -static void -acmp_record_path_addr(struct acmp_ep *ep, struct acmp_dest *dest, - struct ibv_path_record *path) -{ - acm_log(2, "%s\n", dest->name); - dest->path.pkey = htobe16(ep->pkey); - dest->path.dgid = path->dgid; - if (path->slid) { - dest->path.slid = path->slid; - } else { - dest->path.slid = htobe16(ep->port->lid); - } - if (!ib_any_gid(&path->sgid)) { - dest->path.sgid = path->sgid; - } else { - dest->path.sgid = ep->mc_dest[0].path.sgid; - } - dest->path.dlid = path->dlid; - dest->state = ACMP_ADDR_RESOLVED; -} - -static uint8_t acmp_validate_addr_req(struct acm_mad *mad) -{ - struct acm_resolve_rec *rec; - - if (mad->method != IB_METHOD_GET) { - acm_log(0, "ERROR - invalid method 0x%x\n", mad->method); - return ACM_STATUS_EINVAL; - } - - rec = (struct acm_resolve_rec *) mad->data; - if (!rec->src_type || rec->src_type >= ACM_ADDRESS_RESERVED) { - acm_log(0, "ERROR - unknown src type 0x%x\n", rec->src_type); - return ACM_STATUS_EINVAL; - } - - return ACM_STATUS_SUCCESS; -} - -static void -acmp_send_addr_resp(struct acmp_ep *ep, struct acmp_dest *dest) -{ - struct acm_resolve_rec *rec; - struct acmp_send_msg *msg; - struct acm_mad *mad; - - acm_log(2, "%s\n", dest->name); - msg = acmp_alloc_send(ep, dest, sizeof (*mad)); - if (!msg) { - acm_log(0, "ERROR - failed to allocate message\n"); - return; - } - - mad = (struct acm_mad *) msg->data; - rec = (struct acm_resolve_rec *) mad->data; - - mad->base_version = 1; - mad->mgmt_class = ACM_MGMT_CLASS; - mad->class_version = 1; - mad->method = IB_METHOD_GET | IB_METHOD_RESP; - mad->status = ACM_STATUS_SUCCESS; - mad->control = ACM_CTRL_RESOLVE; - mad->tid = dest->req_id; - rec->gid_cnt = 1; - memcpy(rec->gid, dest->mgid.raw, sizeof(union ibv_gid)); - - acmp_post_send(&ep->resp_queue, msg); -} - -static int -acmp_resolve_response(uint64_t id, struct acm_msg *req_msg, - struct acmp_dest *dest, uint8_t status) -{ - struct acm_msg msg; - - acm_log(2, "client %" PRIu64 ", status 0x%x\n", id, status); - memset(&msg, 0, sizeof msg); - - if (dest) { - if (status == ACM_STATUS_ENODATA) - atomic_inc(&dest->ep->counters[ACM_CNTR_NODATA]); - else if (status) - atomic_inc(&dest->ep->counters[ACM_CNTR_ERROR]); - } - msg.hdr = req_msg->hdr; - msg.hdr.status = status; - msg.hdr.length = ACM_MSG_HDR_LENGTH; - memset(msg.hdr.data, 0, sizeof(msg.hdr.data)); - - if (status == ACM_STATUS_SUCCESS) { - msg.hdr.length += ACM_MSG_EP_LENGTH; - msg.resolve_data[0].flags = IBV_PATH_FLAG_GMP | - IBV_PATH_FLAG_PRIMARY | IBV_PATH_FLAG_BIDIRECTIONAL; - msg.resolve_data[0].type = ACM_EP_INFO_PATH; - msg.resolve_data[0].info.path = dest->path; - - if (req_msg->hdr.src_out) { - msg.hdr.length += ACM_MSG_EP_LENGTH; - memcpy(&msg.resolve_data[1], - &req_msg->resolve_data[req_msg->hdr.src_index], - ACM_MSG_EP_LENGTH); - } - } - - return acm_resolve_response(id, &msg); -} - -static void -acmp_complete_queued_req(struct acmp_dest *dest, uint8_t status) -{ - struct acmp_request *req; - - acm_log(2, "status %d\n", status); - pthread_mutex_lock(&dest->lock); - while ((req = list_pop(&dest->req_queue, struct acmp_request, entry))) { - pthread_mutex_unlock(&dest->lock); - - acm_log(2, "completing request, client %" PRIu64 "\n", req->id); - acmp_resolve_response(req->id, &req->msg, dest, status); - acmp_free_req(req); - - pthread_mutex_lock(&dest->lock); - } - pthread_mutex_unlock(&dest->lock); -} - -static void -acmp_dest_sa_resp(struct acm_sa_mad *mad) -{ - struct acmp_dest *dest = (struct acmp_dest *) mad->context; - struct ib_sa_mad *sa_mad = (struct ib_sa_mad *) &mad->sa_mad; - uint8_t status; - - if (!mad->umad.status) { - status = (uint8_t) (be16toh(sa_mad->status) >> 8); - } else { - status = ACM_STATUS_ETIMEDOUT; - } - acm_log(2, "%s status=0x%x\n", dest->name, status); - - pthread_mutex_lock(&dest->lock); - if (dest->state != ACMP_QUERY_ROUTE) { - acm_log(1, "notice - discarding SA response\n"); - pthread_mutex_unlock(&dest->lock); - goto out; - } - - if (!status) { - memcpy(&dest->path, sa_mad->data, sizeof(dest->path)); - acmp_init_path_av(dest->ep->port, dest); - dest->addr_timeout = time_stamp_min() + (unsigned) addr_timeout; - dest->route_timeout = time_stamp_min() + (unsigned) route_timeout; - acm_log(2, "timeout addr %" PRIu64 " route %" PRIu64 "\n", - dest->addr_timeout, dest->route_timeout); - dest->state = ACMP_READY; - } else { - dest->state = ACMP_INIT; - } - pthread_mutex_unlock(&dest->lock); - - acmp_complete_queued_req(dest, status); -out: - acm_free_sa_mad(mad); -} - -static void -acmp_resolve_sa_resp(struct acm_sa_mad *mad) -{ - struct acmp_dest *dest = (struct acmp_dest *) mad->context; - int send_resp; - - acm_log(2, "\n"); - acmp_dest_sa_resp(mad); - - pthread_mutex_lock(&dest->lock); - send_resp = (dest->state == ACMP_READY); - pthread_mutex_unlock(&dest->lock); - - if (send_resp) - acmp_send_addr_resp(dest->ep, dest); -} - -static struct acmp_addr * -acmp_addr_lookup(struct acmp_ep *ep, uint8_t *addr, uint16_t type) -{ - int i; - - for (i = 0; i < MAX_EP_ADDR; i++) { - if (ep->addr_info[i].type != type) - continue; - - if ((type == ACM_ADDRESS_NAME && - !strncasecmp((char *) ep->addr_info[i].info.name, - (char *) addr, ACM_MAX_ADDRESS)) || - !memcmp(ep->addr_info[i].info.addr, addr, - ACM_MAX_ADDRESS)) { - return &ep->addr_info[i]; - } - } - - return NULL; -} - -static void -acmp_process_addr_req(struct acmp_ep *ep, struct ibv_wc *wc, struct acm_mad *mad) -{ - struct acm_resolve_rec *rec; - struct acmp_dest *dest; - uint8_t status; - struct acmp_addr *addr; - - acm_log(2, "\n"); - if ((status = acmp_validate_addr_req(mad))) { - acm_log(0, "ERROR - invalid request\n"); - return; - } - - rec = (struct acm_resolve_rec *) mad->data; - dest = acmp_acquire_dest(ep, rec->src_type, rec->src); - if (!dest) { - acm_log(0, "ERROR - unable to add source\n"); - return; - } - - addr = acmp_addr_lookup(ep, rec->dest, rec->dest_type); - if (addr) - dest->req_id = mad->tid; - - pthread_mutex_lock(&dest->lock); - acm_log(2, "dest state %d\n", dest->state); - switch (dest->state) { - case ACMP_READY: - if (dest->remote_qpn == wc->src_qp) - break; - - acm_log(2, "src service has new qp, resetting\n"); - /* fall through */ - case ACMP_INIT: - case ACMP_QUERY_ADDR: - status = acmp_record_acm_addr(ep, dest, wc, rec); - if (status) - break; - /* fall through */ - case ACMP_ADDR_RESOLVED: - if (route_prot == ACMP_ROUTE_PROT_ACM) { - status = acmp_record_acm_route(ep, dest); - break; - } - if (addr || !list_empty(&dest->req_queue)) { - status = acmp_resolve_path_sa(ep, dest, acmp_resolve_sa_resp); - if (status) - break; - } - /* fall through */ - default: - pthread_mutex_unlock(&dest->lock); - acmp_put_dest(dest); - return; - } - pthread_mutex_unlock(&dest->lock); - acmp_complete_queued_req(dest, status); - - if (addr && !status) { - acmp_send_addr_resp(ep, dest); - } - acmp_put_dest(dest); -} - -static void -acmp_process_addr_resp(struct acmp_send_msg *msg, struct ibv_wc *wc, struct acm_mad *mad) -{ - struct acm_resolve_rec *resp_rec; - struct acmp_dest *dest = (struct acmp_dest *) msg->context; - uint8_t status; - - if (mad) { - status = acm_class_status(mad->status); - resp_rec = (struct acm_resolve_rec *) mad->data; - } else { - status = ACM_STATUS_ETIMEDOUT; - resp_rec = NULL; - } - acm_log(2, "resp status 0x%x\n", status); - - pthread_mutex_lock(&dest->lock); - if (dest->state != ACMP_QUERY_ADDR) { - pthread_mutex_unlock(&dest->lock); - goto put; - } - - if (!status) { - status = acmp_record_acm_addr(msg->ep, dest, wc, resp_rec); - if (!status) { - if (route_prot == ACMP_ROUTE_PROT_ACM) { - status = acmp_record_acm_route(msg->ep, dest); - } else { - status = acmp_resolve_path_sa(msg->ep, dest, acmp_dest_sa_resp); - if (!status) { - pthread_mutex_unlock(&dest->lock); - goto put; - } - } - } - } else { - dest->state = ACMP_INIT; - } - pthread_mutex_unlock(&dest->lock); - - acmp_complete_queued_req(dest, status); -put: - acmp_put_dest(dest); -} - -static void acmp_process_acm_recv(struct acmp_ep *ep, struct ibv_wc *wc, struct acm_mad *mad) -{ - struct acmp_send_msg *req; - struct acm_resolve_rec *rec; - int free; - - acm_log(2, "\n"); - if (mad->base_version != 1 || mad->class_version != 1) { - acm_log(0, "ERROR - invalid version %d %d\n", - mad->base_version, mad->class_version); - return; - } - - if (mad->control != ACM_CTRL_RESOLVE) { - acm_log(0, "ERROR - invalid control 0x%x\n", mad->control); - return; - } - - rec = (struct acm_resolve_rec *) mad->data; - acm_format_name(2, log_data, sizeof log_data, - rec->src_type, rec->src, sizeof rec->src); - acm_log(2, "src %s\n", log_data); - acm_format_name(2, log_data, sizeof log_data, - rec->dest_type, rec->dest, sizeof rec->dest); - acm_log(2, "dest %s\n", log_data); - if (mad->method & IB_METHOD_RESP) { - acm_log(2, "received response\n"); - req = acmp_get_request(ep, mad->tid, &free); - if (!req) { - acm_log(1, "notice - response did not match active request\n"); - return; - } - acm_log(2, "found matching request\n"); - req->resp_handler(req, wc, mad); - if (free) - acmp_free_send(req); - } else { - acm_log(2, "unsolicited request\n"); - acmp_process_addr_req(ep, wc, mad); - } -} - -static void -acmp_sa_resp(struct acm_sa_mad *mad) -{ - struct acmp_request *req = (struct acmp_request *) mad->context; - struct ib_sa_mad *sa_mad = (struct ib_sa_mad *) &mad->sa_mad; - - req->msg.hdr.opcode |= ACM_OP_ACK; - if (!mad->umad.status) { - req->msg.hdr.status = (uint8_t) (be16toh(sa_mad->status) >> 8); - memcpy(&req->msg.resolve_data[0].info.path, sa_mad->data, - sizeof(struct ibv_path_record)); - } else { - req->msg.hdr.status = ACM_STATUS_ETIMEDOUT; - } - acm_log(2, "status 0x%x\n", req->msg.hdr.status); - - if (req->msg.hdr.status) - atomic_inc(&req->ep->counters[ACM_CNTR_ERROR]); - acm_query_response(req->id, &req->msg); - acm_free_sa_mad(mad); - acmp_free_req(req); -} - -static void acmp_process_sa_recv(struct acmp_ep *ep, struct ibv_wc *wc, struct acm_mad *mad) -{ - struct ib_sa_mad *sa_mad = (struct ib_sa_mad *) mad; - struct acmp_send_msg *req; - int free; - - acm_log(2, "\n"); - if (mad->base_version != 1 || mad->class_version != 2 || - !(mad->method & IB_METHOD_RESP) || sa_mad->attr_id != IB_SA_ATTR_PATH_REC) { - acm_log(0, "ERROR - unexpected SA MAD %d %d\n", - mad->base_version, mad->class_version); - return; - } - - req = acmp_get_request(ep, mad->tid, &free); - if (!req) { - acm_log(1, "notice - response did not match active request\n"); - return; - } - acm_log(2, "found matching request\n"); - req->resp_handler(req, wc, mad); - if (free) - acmp_free_send(req); -} - -static void acmp_process_recv(struct acmp_ep *ep, struct ibv_wc *wc) -{ - struct acm_mad *mad; - - acm_log(2, "base endpoint name %s\n", ep->id_string); - mad = (struct acm_mad *) (uintptr_t) (wc->wr_id + sizeof(struct ibv_grh)); - switch (mad->mgmt_class) { - case IB_MGMT_CLASS_SA: - acmp_process_sa_recv(ep, wc, mad); - break; - case ACM_MGMT_CLASS: - acmp_process_acm_recv(ep, wc, mad); - break; - default: - acm_log(0, "ERROR - invalid mgmt class 0x%x\n", mad->mgmt_class); - break; - } - - acmp_post_recv(ep, wc->wr_id); -} - -static void acmp_process_comp(struct acmp_ep *ep, struct ibv_wc *wc) -{ - if (wc->status) { - acm_log(0, "ERROR - work completion error\n" - "\topcode %d, completion status %d\n", - wc->opcode, wc->status); - return; - } - - if (wc->opcode & IBV_WC_RECV) - acmp_process_recv(ep, wc); - else - acmp_complete_send((struct acmp_send_msg *) (uintptr_t) wc->wr_id); -} - -static void *acmp_comp_handler(void *context) -{ - struct acmp_device *dev = (struct acmp_device *) context; - struct acmp_ep *ep; - struct ibv_cq *cq; - struct ibv_wc wc; - int cnt; - - acm_log(1, "started\n"); - - if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { - acm_log(0, "Error: failed to set cancel type for dev %s\n", - dev->verbs->device->name); - pthread_exit(NULL); - } - - if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL)) { - acm_log(0, "Error: failed to set cancel state for dev %s\n", - dev->verbs->device->name); - pthread_exit(NULL); - } - while (1) { - pthread_testcancel(); - ibv_get_cq_event(dev->channel, &cq, (void *) &ep); - - cnt = 0; - while (ibv_poll_cq(cq, 1, &wc) > 0) { - cnt++; - acmp_process_comp(ep, &wc); - } - - ibv_req_notify_cq(cq, 0); - while (ibv_poll_cq(cq, 1, &wc) > 0) { - cnt++; - acmp_process_comp(ep, &wc); - } - - ibv_ack_cq_events(cq, cnt); - } - - return NULL; -} - -static void acmp_format_mgid(union ibv_gid *mgid, uint16_t pkey, uint8_t tos, - uint8_t rate, uint8_t mtu) -{ - mgid->raw[0] = 0xFF; - mgid->raw[1] = 0x10 | 0x05; - mgid->raw[2] = 0x40; - mgid->raw[3] = 0x01; - mgid->raw[4] = (uint8_t) (pkey >> 8); - mgid->raw[5] = (uint8_t) pkey; - mgid->raw[6] = tos; - mgid->raw[7] = rate; - mgid->raw[8] = mtu; - mgid->raw[9] = 0; - mgid->raw[10] = 0; - mgid->raw[11] = 0; - mgid->raw[12] = 0; - mgid->raw[13] = 0; - mgid->raw[14] = 0; - mgid->raw[15] = 0; -} - -static void acmp_init_join(struct ib_sa_mad *mad, union ibv_gid *port_gid, - uint16_t pkey, uint8_t tos, uint8_t tclass, uint8_t sl, uint8_t rate, uint8_t mtu) -{ - struct ib_mc_member_rec *mc_rec; - - acm_log(2, "\n"); - mad->base_version = 1; - mad->mgmt_class = IB_MGMT_CLASS_SA; - mad->class_version = 2; - mad->method = IB_METHOD_SET; - mad->tid = htobe64((uint64_t) atomic_inc(&g_tid)); - mad->attr_id = IB_SA_ATTR_MC_MEMBER_REC; - mad->comp_mask = - IB_COMP_MASK_MC_MGID | IB_COMP_MASK_MC_PORT_GID | - IB_COMP_MASK_MC_QKEY | IB_COMP_MASK_MC_MTU_SEL| IB_COMP_MASK_MC_MTU | - IB_COMP_MASK_MC_TCLASS | IB_COMP_MASK_MC_PKEY | IB_COMP_MASK_MC_RATE_SEL | - IB_COMP_MASK_MC_RATE | IB_COMP_MASK_MC_SL | IB_COMP_MASK_MC_FLOW | - IB_COMP_MASK_MC_SCOPE | IB_COMP_MASK_MC_JOIN_STATE; - - mc_rec = (struct ib_mc_member_rec *) mad->data; - acmp_format_mgid(&mc_rec->mgid, pkey | 0x8000, tos, rate, mtu); - mc_rec->port_gid = *port_gid; - mc_rec->qkey = htobe32(ACM_QKEY); - mc_rec->mtu = 0x80 | mtu; - mc_rec->tclass = tclass; - mc_rec->pkey = htobe16(pkey); - mc_rec->rate = 0x80 | rate; - mc_rec->sl_flow_hop = htobe32(((uint32_t) sl) << 28); - mc_rec->scope_state = 0x51; -} - -static void acmp_join_group(struct acmp_ep *ep, union ibv_gid *port_gid, - uint8_t tos, uint8_t tclass, uint8_t sl, uint8_t rate, uint8_t mtu) -{ - struct ib_sa_mad *mad; - struct ib_mc_member_rec *mc_rec; - struct acm_sa_mad *sa_mad; - - acm_log(2, "\n"); - sa_mad = acm_alloc_sa_mad(ep->endpoint, ep, acmp_process_join_resp); - if (!sa_mad) { - acm_log(0, "Error - failed to allocate sa_mad\n"); - return; - } - - acm_log(0, "%s %d pkey 0x%x, sl 0x%x, rate 0x%x, mtu 0x%x\n", - ep->port->dev->verbs->device->name, - ep->port->port_num, ep->pkey, sl, rate, mtu); - mad = (struct ib_sa_mad *) &sa_mad->sa_mad; - acmp_init_join(mad, port_gid, ep->pkey, tos, tclass, sl, rate, mtu); - mc_rec = (struct ib_mc_member_rec *) mad->data; - acmp_set_dest_addr(&ep->mc_dest[ep->mc_cnt++], ACM_ADDRESS_GID, - mc_rec->mgid.raw, sizeof(mc_rec->mgid)); - ep->mc_dest[ep->mc_cnt - 1].state = ACMP_INIT; - - if (acm_send_sa_mad(sa_mad)) { - acm_log(0, "Error - Failed to send sa mad\n"); - acm_free_sa_mad(sa_mad); - } -} - -static void acmp_ep_join(struct acmp_ep *ep) -{ - struct acmp_port *port; - union ibv_gid gid; - - port = ep->port; - acm_log(1, "%s\n", ep->id_string); - - if (ep->mc_dest[0].state == ACMP_READY && ep->mc_dest[0].ah) { - ibv_detach_mcast(ep->qp, &ep->mc_dest[0].mgid, - be16toh(ep->mc_dest[0].av.dlid)); - ibv_destroy_ah(ep->mc_dest[0].ah); - ep->mc_dest[0].ah = NULL; - } - ep->mc_cnt = 0; - ep->state = ACMP_INIT; - acm_get_gid((struct acm_port *)ep->port->port, 0, &gid); - acmp_join_group(ep, &gid, 0, 0, 0, min_rate, min_mtu); - - if ((route_prot == ACMP_ROUTE_PROT_ACM) && - (port->rate != min_rate || port->mtu != min_mtu)) - acmp_join_group(ep, &gid, 0, 0, 0, port->rate, port->mtu); - - acm_log(1, "join for %s complete\n", ep->id_string); -} - -static int acmp_port_join(void *port_context) -{ - struct acmp_ep *ep; - struct acmp_port *port = port_context; - - acm_log(1, "device %s port %d\n", port->dev->verbs->device->name, - port->port_num); - - list_for_each(&port->ep_list, ep, entry) { - if (!ep->endpoint) { - /* Stale endpoint */ - continue; - } - acmp_ep_join(ep); - } - acm_log(1, "joins for device %s port %d complete\n", - port->dev->verbs->device->name, port->port_num); - - return 0; -} - -static int acmp_handle_event(void *port_context, enum ibv_event_type type) -{ - int ret = 0; - - acm_log(2, "event %s\n", ibv_event_type_str(type)); - - switch (type) { - case IBV_EVENT_CLIENT_REREGISTER: - ret = acmp_port_join(port_context); - break; - default: - break; - } - return ret; -} - -static void acmp_process_timeouts(void) -{ - struct acmp_send_msg *msg; - struct acm_resolve_rec *rec; - struct acm_mad *mad; - - while ((msg = list_pop(&timeout_list, struct acmp_send_msg, entry))) { - mad = (struct acm_mad *) &msg->data[0]; - rec = (struct acm_resolve_rec *) mad->data; - - acm_format_name(0, log_data, sizeof log_data, - rec->dest_type, rec->dest, sizeof rec->dest); - acm_log(0, "notice - dest %s\n", log_data); - - msg->resp_handler(msg, NULL, NULL); - acmp_free_send(msg); - } -} - -static void acmp_process_wait_queue(struct acmp_ep *ep, uint64_t *next_expire) -{ - struct acmp_send_msg *msg, *next; - struct ibv_send_wr *bad_wr; - - list_for_each_safe(&ep->wait_queue, msg, next, entry) { - if (msg->expires < time_stamp_ms()) { - list_del(&msg->entry); - (void) atomic_dec(&wait_cnt); - if (--msg->tries) { - acm_log(1, "notice - retrying request\n"); - list_add_tail(&ep->active_queue, &msg->entry); - ibv_post_send(ep->qp, &msg->wr, &bad_wr); - } else { - acm_log(0, "notice - failing request\n"); - acmp_send_available(ep, msg->req_queue); - list_add_tail(&timeout_list, &msg->entry); - } - } else { - *next_expire = min(*next_expire, msg->expires); - break; - } - } -} - -/* While the device/port/ep will not be freed, we need to be careful of - * their addition while walking the link lists. Therefore, we need to acquire - * the appropriate locks. - */ -static void *acmp_retry_handler(void *context) -{ - struct acmp_device *dev; - struct acmp_port *port; - struct acmp_ep *ep; - uint64_t next_expire; - int i, wait; - - acm_log(0, "started\n"); - if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { - acm_log(0, "Error: failed to set cancel type \n"); - pthread_exit(NULL); - } - if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL)) { - acm_log(0, "Error: failed to set cancel state\n"); - pthread_exit(NULL); - } - retry_thread_started = 1; - - while (1) { - while (!atomic_get(&wait_cnt)) { - pthread_testcancel(); - event_wait(&timeout_event, -1); - } - - next_expire = -1; - pthread_mutex_lock(&acmp_dev_lock); - list_for_each(&acmp_dev_list, dev, entry) { - pthread_mutex_unlock(&acmp_dev_lock); - - for (i = 0; i < dev->port_cnt; i++) { - port = &dev->port[i]; - - pthread_mutex_lock(&port->lock); - list_for_each(&port->ep_list, ep, entry) { - pthread_mutex_unlock(&port->lock); - pthread_mutex_lock(&ep->lock); - if (!list_empty(&ep->wait_queue)) - acmp_process_wait_queue(ep, &next_expire); - pthread_mutex_unlock(&ep->lock); - pthread_mutex_lock(&port->lock); - } - pthread_mutex_unlock(&port->lock); - } - pthread_mutex_lock(&acmp_dev_lock); - } - pthread_mutex_unlock(&acmp_dev_lock); - - acmp_process_timeouts(); - wait = (int) (next_expire - time_stamp_ms()); - if (wait > 0 && atomic_get(&wait_cnt)) { - pthread_testcancel(); - event_wait(&timeout_event, wait); - } - } - - retry_thread_started = 0; - return NULL; -} - -static int -acmp_query(void *addr_context, struct acm_msg *msg, uint64_t id) -{ - struct acmp_request *req; - struct ib_sa_mad *mad; - struct acmp_addr *address = addr_context; - struct acmp_ep *ep = address->ep; - uint8_t status; - struct acm_sa_mad *sa_mad; - - if (ep->state != ACMP_READY) { - status = ACM_STATUS_ENODATA; - goto resp; - } - - req = acmp_alloc_req(id, msg); - if (!req) { - status = ACM_STATUS_ENOMEM; - goto resp; - } - req->ep = ep; - - sa_mad = acm_alloc_sa_mad(ep->endpoint, req, acmp_sa_resp); - if (!sa_mad) { - acm_log(0, "Error - failed to allocate sa_mad\n"); - status = ACM_STATUS_ENOMEM; - goto free_req; - } - - mad = (struct ib_sa_mad *) &sa_mad->sa_mad; - acmp_init_path_query(mad); - - memcpy(mad->data, &msg->resolve_data[0].info.path, - sizeof(struct ibv_path_record)); - mad->comp_mask = acm_path_comp_mask(&msg->resolve_data[0].info.path); - - acm_increment_counter(ACM_CNTR_ROUTE_QUERY); - atomic_inc(&ep->counters[ACM_CNTR_ROUTE_QUERY]); - if (acm_send_sa_mad(sa_mad)) { - acm_log(0, "Error - Failed to send sa mad\n"); - status = ACM_STATUS_ENODATA; - goto free_mad; - } - return ACM_STATUS_SUCCESS; - -free_mad: - acm_free_sa_mad(sa_mad); -free_req: - acmp_free_req(req); -resp: - msg->hdr.opcode |= ACM_OP_ACK; - msg->hdr.status = status; - if (status == ACM_STATUS_ENODATA) - atomic_inc(&ep->counters[ACM_CNTR_NODATA]); - else - atomic_inc(&ep->counters[ACM_CNTR_ERROR]); - return acm_query_response(id, msg); -} - -static uint8_t -acmp_send_resolve(struct acmp_ep *ep, struct acmp_dest *dest, - struct acm_ep_addr_data *saddr) -{ - struct acmp_send_msg *msg; - struct acm_mad *mad; - struct acm_resolve_rec *rec; - int i; - - acm_log(2, "\n"); - msg = acmp_alloc_send(ep, &ep->mc_dest[0], sizeof(*mad)); - if (!msg) { - acm_log(0, "ERROR - cannot allocate send msg\n"); - return ACM_STATUS_ENOMEM; - } - - acmp_init_send_req(msg, (void *) dest, acmp_process_addr_resp); - (void) atomic_inc(&dest->refcnt); - - mad = (struct acm_mad *) msg->data; - mad->base_version = 1; - mad->mgmt_class = ACM_MGMT_CLASS; - mad->class_version = 1; - mad->method = IB_METHOD_GET; - mad->control = ACM_CTRL_RESOLVE; - mad->tid = htobe64((uint64_t) atomic_inc(&g_tid)); - - rec = (struct acm_resolve_rec *) mad->data; - rec->src_type = (uint8_t) saddr->type; - rec->src_length = ACM_MAX_ADDRESS; - memcpy(rec->src, saddr->info.addr, ACM_MAX_ADDRESS); - rec->dest_type = dest->addr_type; - rec->dest_length = ACM_MAX_ADDRESS; - memcpy(rec->dest, dest->address, ACM_MAX_ADDRESS); - - rec->gid_cnt = (uint8_t) ep->mc_cnt; - for (i = 0; i < ep->mc_cnt; i++) - memcpy(&rec->gid[i], ep->mc_dest[i].address, 16); - - acm_increment_counter(ACM_CNTR_ADDR_QUERY); - atomic_inc(&ep->counters[ACM_CNTR_ADDR_QUERY]); - acmp_post_send(&ep->resolve_queue, msg); - return 0; -} - -/* Caller must hold dest lock */ -static uint8_t acmp_queue_req(struct acmp_dest *dest, uint64_t id, struct acm_msg *msg) -{ - struct acmp_request *req; - - acm_log(2, "id %" PRIu64 "\n", id); - req = acmp_alloc_req(id, msg); - if (!req) { - return ACM_STATUS_ENOMEM; - } - req->ep = dest->ep; - - list_add_tail(&dest->req_queue, &req->entry); - return ACM_STATUS_SUCCESS; -} - -static int acmp_dest_timeout(struct acmp_dest *dest) -{ - uint64_t timestamp = time_stamp_min(); - - if (timestamp > dest->addr_timeout) { - acm_log(2, "%s address timed out\n", dest->name); - dest->state = ACMP_INIT; - return 1; - } else if (timestamp > dest->route_timeout) { - acm_log(2, "%s route timed out\n", dest->name); - dest->state = ACMP_ADDR_RESOLVED; - return 1; - } - return 0; -} - -static int -acmp_check_addr_match(struct ifaddrs *iap, struct acm_ep_addr_data *saddr, - unsigned int d_family) -{ - char sip[INET6_ADDRSTRLEN] = {0}; - char dip[INET6_ADDRSTRLEN] = {0}; - const char *tmp; - size_t sock_size; - unsigned int s_family; - int ret; - - s_family = iap->ifa_addr->sa_family; - - if (!iap->ifa_addr || - !(iap->ifa_flags & IFF_UP) || - (s_family != d_family)) - return -1; - - sock_size = (s_family == AF_INET) ? sizeof(struct sockaddr_in) : - sizeof(struct sockaddr_in6); - - ret = getnameinfo(iap->ifa_addr, sock_size, - sip, sizeof(sip), - NULL, 0, NI_NUMERICHOST); - - if (ret) - return ret; - - tmp = inet_ntop(d_family, (void *)saddr->info.addr, dip, - sizeof(dip)); - if (!tmp) - return -1; - ret = memcmp(sip, dip, strlen(dip)); - return ret; -} - -static void -acmp_acquire_sgid(struct acm_ep_addr_data *saddr, - struct acmp_dest *dest) -{ - struct ifaddrs *addrs, *iap; - unsigned int d_family; - int ret; - - if (!ib_any_gid(&dest->path.sgid)) - return; - - if (dest->addr_type != ACM_ADDRESS_IP6 && - dest->addr_type != ACM_ADDRESS_IP) - return; - - if (getifaddrs(&addrs)) - return; - - d_family = (dest->addr_type == ACM_ADDRESS_IP) ? AF_INET : AF_INET6; - - for (iap = addrs; iap != NULL; iap = iap->ifa_next) { - ret = acmp_check_addr_match(iap, saddr, d_family); - if (!ret) { - ret = acm_if_get_sgid(iap->ifa_name, - &dest->path.sgid); - if (!ret) - break; - } - } - freeifaddrs(addrs); -} - -static int -acmp_resolve_dest(struct acmp_ep *ep, struct acm_msg *msg, uint64_t id) -{ - struct acmp_dest *dest; - struct acm_ep_addr_data *saddr, *daddr; - uint8_t status; - int ret; - - saddr = &msg->resolve_data[msg->hdr.src_index]; - daddr = &msg->resolve_data[msg->hdr.dst_index]; - acm_format_name(2, log_data, sizeof log_data, - daddr->type, daddr->info.addr, sizeof daddr->info.addr); - acm_log(2, "dest %s\n", log_data); - - dest = acmp_acquire_dest(ep, daddr->type, daddr->info.addr); - if (!dest) { - acm_log(0, "ERROR - unable to allocate destination in request\n"); - atomic_inc(&ep->counters[ACM_CNTR_ERROR]); - return acmp_resolve_response(id, msg, NULL, ACM_STATUS_ENOMEM); - } - - pthread_mutex_lock(&dest->lock); -test: - switch (dest->state) { - case ACMP_READY: - if (acmp_dest_timeout(dest)) - goto test; - acm_log(2, "request satisfied from local cache\n"); - acm_increment_counter(ACM_CNTR_ROUTE_CACHE); - atomic_inc(&ep->counters[ACM_CNTR_ROUTE_CACHE]); - status = ACM_STATUS_SUCCESS; - break; - case ACMP_ADDR_RESOLVED: - acm_log(2, "have address, resolving route\n"); - acm_increment_counter(ACM_CNTR_ADDR_CACHE); - atomic_inc(&ep->counters[ACM_CNTR_ADDR_CACHE]); - acmp_acquire_sgid(saddr, dest); - status = acmp_resolve_path_sa(ep, dest, acmp_dest_sa_resp); - if (status) { - break; - } - goto queue; - case ACMP_INIT: - acm_log(2, "sending resolve msg to dest\n"); - status = acmp_send_resolve(ep, dest, saddr); - if (status) { - break; - } - dest->state = ACMP_QUERY_ADDR; - /* fall through */ - default: -queue: - if (daddr->flags & ACM_FLAGS_NODELAY) { - acm_log(2, "lookup initiated, but client wants no delay\n"); - status = ACM_STATUS_ENODATA; - break; - } - status = acmp_queue_req(dest, id, msg); - if (status) { - break; - } - ret = 0; - pthread_mutex_unlock(&dest->lock); - goto put; - } - pthread_mutex_unlock(&dest->lock); - ret = acmp_resolve_response(id, msg, dest, status); -put: - acmp_put_dest(dest); - return ret; -} - -static int -acmp_resolve_path(struct acmp_ep *ep, struct acm_msg *msg, uint64_t id) -{ - struct acmp_dest *dest; - struct ibv_path_record *path; - uint8_t *addr; - uint8_t status; - int ret; - - path = &msg->resolve_data[0].info.path; - addr = msg->resolve_data[1].info.addr; - memset(addr, 0, ACM_MAX_ADDRESS); - if (path->dlid) { - * ((__be16 *) addr) = path->dlid; - dest = acmp_acquire_dest(ep, ACM_ADDRESS_LID, addr); - } else { - memcpy(addr, &path->dgid, sizeof path->dgid); - dest = acmp_acquire_dest(ep, ACM_ADDRESS_GID, addr); - } - if (!dest) { - acm_log(0, "ERROR - unable to allocate destination in request\n"); - atomic_inc(&ep->counters[ACM_CNTR_ERROR]); - return acmp_resolve_response(id, msg, NULL, ACM_STATUS_ENOMEM); - } - - pthread_mutex_lock(&dest->lock); -test: - switch (dest->state) { - case ACMP_READY: - if (acmp_dest_timeout(dest)) - goto test; - acm_log(2, "request satisfied from local cache\n"); - acm_increment_counter(ACM_CNTR_ROUTE_CACHE); - atomic_inc(&ep->counters[ACM_CNTR_ROUTE_CACHE]); - status = ACM_STATUS_SUCCESS; - break; - case ACMP_INIT: - acm_log(2, "have path, bypassing address resolution\n"); - acmp_record_path_addr(ep, dest, path); - /* fall through */ - case ACMP_ADDR_RESOLVED: - acm_log(2, "have address, resolving route\n"); - status = acmp_resolve_path_sa(ep, dest, acmp_dest_sa_resp); - if (status) { - break; - } - /* fall through */ - default: - if (msg->resolve_data[0].flags & ACM_FLAGS_NODELAY) { - acm_log(2, "lookup initiated, but client wants no delay\n"); - status = ACM_STATUS_ENODATA; - break; - } - status = acmp_queue_req(dest, id, msg); - if (status) { - break; - } - ret = 0; - pthread_mutex_unlock(&dest->lock); - goto put; - } - pthread_mutex_unlock(&dest->lock); - ret = acmp_resolve_response(id, msg, dest, status); -put: - acmp_put_dest(dest); - return ret; -} - -static int -acmp_resolve(void *addr_context, struct acm_msg *msg, uint64_t id) -{ - struct acmp_addr *address = addr_context; - struct acmp_ep *ep = address->ep; - - if (ep->state != ACMP_READY) { - atomic_inc(&ep->counters[ACM_CNTR_NODATA]); - return acmp_resolve_response(id, msg, NULL, ACM_STATUS_ENODATA); - } - - atomic_inc(&ep->counters[ACM_CNTR_RESOLVE]); - if (msg->resolve_data[0].type == ACM_EP_INFO_PATH) - return acmp_resolve_path(ep, msg, id); - else - return acmp_resolve_dest(ep, msg, id); -} - -static void acmp_query_perf(void *ep_context, uint64_t *values, uint8_t *cnt) -{ - struct acmp_ep *ep = ep_context; - int i; - - for (i = 0; i < ACM_MAX_COUNTER; i++) - values[i] = htobe64((uint64_t) atomic_get(&ep->counters[i])); - *cnt = ACM_MAX_COUNTER; -} - -static enum acmp_addr_prot acmp_convert_addr_prot(char *param) -{ - if (!strcasecmp("acm", param)) - return ACMP_ADDR_PROT_ACM; - - return addr_prot; -} - -static enum acmp_route_prot acmp_convert_route_prot(char *param) -{ - if (!strcasecmp("acm", param)) - return ACMP_ROUTE_PROT_ACM; - else if (!strcasecmp("sa", param)) - return ACMP_ROUTE_PROT_SA; - - return route_prot; -} - -static enum acmp_loopback_prot acmp_convert_loopback_prot(char *param) -{ - if (!strcasecmp("none", param)) - return ACMP_LOOPBACK_PROT_NONE; - else if (!strcasecmp("local", param)) - return ACMP_LOOPBACK_PROT_LOCAL; - - return loopback_prot; -} - -static enum acmp_route_preload acmp_convert_route_preload(char *param) -{ - if (!strcasecmp("none", param) || !strcasecmp("no", param)) - return ACMP_ROUTE_PRELOAD_NONE; - else if (!strcasecmp("opensm_full_v1", param)) - return ACMP_ROUTE_PRELOAD_OSM_FULL_V1; - - return route_preload; -} - -static enum acmp_addr_preload acmp_convert_addr_preload(char *param) -{ - if (!strcasecmp("none", param) || !strcasecmp("no", param)) - return ACMP_ADDR_PRELOAD_NONE; - else if (!strcasecmp("acm_hosts", param)) - return ACMP_ADDR_PRELOAD_HOSTS; - - return addr_preload; -} - -static int acmp_post_recvs(struct acmp_ep *ep) -{ - int i, size; - - size = recv_depth * ACM_RECV_SIZE; - ep->recv_bufs = malloc(size); - if (!ep->recv_bufs) { - acm_log(0, "ERROR - unable to allocate receive buffer\n"); - return ACM_STATUS_ENOMEM; - } - - ep->mr = ibv_reg_mr(ep->port->dev->pd, ep->recv_bufs, size, - IBV_ACCESS_LOCAL_WRITE); - if (!ep->mr) { - acm_log(0, "ERROR - unable to register receive buffer\n"); - goto err; - } - - for (i = 0; i < recv_depth; i++) { - acmp_post_recv(ep, (uintptr_t) (ep->recv_bufs + ACM_RECV_SIZE * i)); - } - return 0; - -err: - free(ep->recv_bufs); - return -1; -} - -/* Parse "opensm full v1" file to build LID to GUID table */ -static void acmp_parse_osm_fullv1_lid2guid(FILE *f, __be64 *lid2guid) -{ - char s[128]; - char *p, *ptr, *p_guid, *p_lid; - uint64_t guid; - uint16_t lid; - - while (fgets(s, sizeof s, f)) { - if (s[0] == '#') - continue; - if (!(p = strtok_r(s, " \n", &ptr))) - continue; /* ignore blank lines */ - - if (strncmp(p, "Switch", sizeof("Switch") - 1) && - strncmp(p, "Channel", sizeof("Channel") - 1) && - strncmp(p, "Router", sizeof("Router") - 1)) - continue; - - if (!strncmp(p, "Channel", sizeof("Channel") - 1)) { - p = strtok_r(NULL, " ", &ptr); /* skip 'Adapter' */ - if (!p) - continue; - } - - p_guid = strtok_r(NULL, ",", &ptr); - if (!p_guid) - continue; - - guid = (uint64_t) strtoull(p_guid, NULL, 16); - - ptr = strstr(ptr, "base LID"); - if (!ptr) - continue; - ptr += sizeof("base LID"); - p_lid = strtok_r(NULL, ",", &ptr); - if (!p_lid) - continue; - - lid = (uint16_t) strtoul(p_lid, NULL, 0); - if (lid >= IB_LID_MCAST_START) - continue; - if (lid2guid[lid]) - acm_log(0, "ERROR - duplicate lid %u\n", lid); - else - lid2guid[lid] = htobe64(guid); - } -} - -/* Parse 'opensm full v1' file to populate PR cache */ -static int acmp_parse_osm_fullv1_paths(FILE *f, __be64 *lid2guid, struct acmp_ep *ep) -{ - union ibv_gid sgid, dgid; - struct ibv_port_attr attr = {}; - struct acmp_dest *dest; - char s[128]; - char *p, *ptr, *p_guid, *p_lid; - uint64_t guid; - uint16_t lid, dlid; - __be16 net_dlid; - int sl, mtu, rate; - int ret = 1, i; - uint8_t addr[ACM_MAX_ADDRESS]; - uint8_t addr_type; - - acm_get_gid((struct acm_port *)ep->port->port, 0, &sgid); - - /* Search for endpoint's SLID */ - while (fgets(s, sizeof s, f)) { - if (s[0] == '#') - continue; - if (!(p = strtok_r(s, " \n", &ptr))) - continue; /* ignore blank lines */ - - if (strncmp(p, "Switch", sizeof("Switch") - 1) && - strncmp(p, "Channel", sizeof("Channel") - 1) && - strncmp(p, "Router", sizeof("Router") - 1)) - continue; - - if (!strncmp(p, "Channel", sizeof("Channel") - 1)) { - p = strtok_r(NULL, " ", &ptr); /* skip 'Adapter' */ - if (!p) - continue; - } - - p_guid = strtok_r(NULL, ",", &ptr); - if (!p_guid) - continue; - - guid = (uint64_t) strtoull(p_guid, NULL, 16); - if (guid != be64toh(sgid.global.interface_id)) - continue; - - ptr = strstr(ptr, "base LID"); - if (!ptr) - continue; - ptr += sizeof("base LID"); - p_lid = strtok_r(NULL, ",", &ptr); - if (!p_lid) - continue; - - lid = (uint16_t) strtoul(p_lid, NULL, 0); - if (lid != ep->port->lid) - continue; - - ibv_query_port(ep->port->dev->verbs, ep->port->port_num, &attr); - ret = 0; - break; - } - - while (fgets(s, sizeof s, f)) { - if (s[0] == '#') - continue; - if (!(p = strtok_r(s, " \n", &ptr))) - continue; /* ignore blank lines */ - - if (!strncmp(p, "Switch", sizeof("Switch") - 1) || - !strncmp(p, "Channel", sizeof("Channel") - 1) || - !strncmp(p, "Router", sizeof("Router") - 1)) - break; - - dlid = strtoul(p, NULL, 0); - net_dlid = htobe16(dlid); - - p = strtok_r(NULL, ":", &ptr); - if (!p) - continue; - if (strcmp(p, "UNREACHABLE") == 0) - continue; - sl = atoi(p); - - p = strtok_r(NULL, ":", &ptr); - if (!p) - continue; - mtu = atoi(p); - - p = strtok_r(NULL, ":", &ptr); - if (!p) - continue; - rate = atoi(p); - - if (!lid2guid[dlid]) { - acm_log(0, "ERROR - dlid %u not found in lid2guid table\n", dlid); - continue; - } - - dgid.global.subnet_prefix = sgid.global.subnet_prefix; - dgid.global.interface_id = lid2guid[dlid]; - - for (i = 0; i < 2; i++) { - memset(addr, 0, ACM_MAX_ADDRESS); - if (i == 0) { - addr_type = ACM_ADDRESS_LID; - memcpy(addr, &net_dlid, sizeof net_dlid); - } else { - addr_type = ACM_ADDRESS_GID; - memcpy(addr, &dgid, sizeof(dgid)); - } - dest = acmp_acquire_dest(ep, addr_type, addr); - if (!dest) { - acm_log(0, "ERROR - unable to create dest\n"); - break; - } - - dest->path.sgid = sgid; - dest->path.slid = htobe16(ep->port->lid); - dest->path.dgid = dgid; - dest->path.dlid = net_dlid; - dest->path.reversible_numpath = IBV_PATH_RECORD_REVERSIBLE; - dest->path.pkey = htobe16(ep->pkey); - dest->path.mtu = (uint8_t) mtu; - dest->path.rate = (uint8_t) rate; - dest->path.qosclass_sl = htobe16((uint16_t) sl & 0xF); - if (dlid == ep->port->lid) { - dest->path.packetlifetime = 0; - dest->addr_timeout = (uint64_t)~0ULL; - dest->route_timeout = (uint64_t)~0ULL; - } else { - dest->path.packetlifetime = attr.subnet_timeout; - dest->addr_timeout = time_stamp_min() + (unsigned) addr_timeout; - dest->route_timeout = time_stamp_min() + (unsigned) route_timeout; - } - dest->remote_qpn = 1; - dest->state = ACMP_READY; - acmp_put_dest(dest); - acm_log(1, "added cached dest %s\n", dest->name); - } - } - return ret; -} - -static int acmp_parse_osm_fullv1(struct acmp_ep *ep) -{ - FILE *f; - __be64 *lid2guid; - int ret = 1; - - if (!(f = fopen(route_data_file, "r"))) { - acm_log(0, "ERROR - couldn't open %s\n", route_data_file); - return ret; - } - - lid2guid = calloc(IB_LID_MCAST_START, sizeof(*lid2guid)); - if (!lid2guid) { - acm_log(0, "ERROR - no memory for path record parsing\n"); - goto err; - } - - acmp_parse_osm_fullv1_lid2guid(f, lid2guid); - rewind(f); - ret = acmp_parse_osm_fullv1_paths(f, lid2guid, ep); - free(lid2guid); -err: - fclose(f); - return ret; -} - -static void acmp_parse_hosts_file(struct acmp_ep *ep) -{ - FILE *f; - char s[120]; - char addr[INET6_ADDRSTRLEN], gid[INET6_ADDRSTRLEN]; - uint8_t name[ACM_MAX_ADDRESS]; - struct in6_addr ip_addr, ib_addr; - struct acmp_dest *dest, *gid_dest; - uint8_t addr_type; - - if (!(f = fopen(addr_data_file, "r"))) { - acm_log(0, "ERROR - couldn't open %s\n", addr_data_file); - return; - } - - while (fgets(s, sizeof s, f)) { - if (s[0] == '#') - continue; - - if (sscanf(s, "%46s%46s", addr, gid) != 2) - continue; - - acm_log(2, "%s", s); - if (inet_pton(AF_INET6, gid, &ib_addr) <= 0) { - acm_log(0, "ERROR - %s is not IB GID\n", gid); - continue; - } - memset(name, 0, ACM_MAX_ADDRESS); - if (inet_pton(AF_INET, addr, &ip_addr) > 0) { - addr_type = ACM_ADDRESS_IP; - memcpy(name, &ip_addr, 4); - } else if (inet_pton(AF_INET6, addr, &ip_addr) > 0) { - addr_type = ACM_ADDRESS_IP6; - memcpy(name, &ip_addr, sizeof(ip_addr)); - } else { - addr_type = ACM_ADDRESS_NAME; - strncpy((char *)name, addr, ACM_MAX_ADDRESS); - } - - dest = acmp_acquire_dest(ep, addr_type, name); - if (!dest) { - acm_log(0, "ERROR - unable to create dest %s\n", addr); - continue; - } - - memset(name, 0, ACM_MAX_ADDRESS); - memcpy(name, &ib_addr, sizeof(ib_addr)); - gid_dest = acmp_get_dest(ep, ACM_ADDRESS_GID, name); - if (gid_dest) { - dest->path = gid_dest->path; - dest->state = ACMP_READY; - acmp_put_dest(gid_dest); - } else { - memcpy(&dest->path.dgid, &ib_addr, 16); - //ibv_query_gid(ep->port->dev->verbs, ep->port->port_num, - // 0, &dest->path.sgid); - dest->path.slid = htobe16(ep->port->lid); - dest->path.reversible_numpath = IBV_PATH_RECORD_REVERSIBLE; - dest->path.pkey = htobe16(ep->pkey); - dest->state = ACMP_ADDR_RESOLVED; - } - - dest->remote_qpn = 1; - dest->addr_timeout = time_stamp_min() + (unsigned) addr_timeout; - dest->route_timeout = time_stamp_min() + (unsigned) route_timeout; - acmp_put_dest(dest); - acm_log(1, "added host %s address type %d IB GID %s\n", - addr, addr_type, gid); - } - - fclose(f); -} - -/* - * We currently require that the routing data be preloaded in order to - * load the address data. This is backwards from normal operation, which - * usually resolves the address before the route. - */ -static void acmp_ep_preload(struct acmp_ep *ep) -{ - switch (route_preload) { - case ACMP_ROUTE_PRELOAD_OSM_FULL_V1: - if (acmp_parse_osm_fullv1(ep)) - acm_log(0, "ERROR - failed to preload EP\n"); - break; - default: - break; - } - - switch (addr_preload) { - case ACMP_ADDR_PRELOAD_HOSTS: - acmp_parse_hosts_file(ep); - break; - default: - break; - } -} - -static int acmp_add_addr(const struct acm_address *addr, void *ep_context, - void **addr_context) -{ - struct acmp_ep *ep = ep_context; - struct acmp_dest *dest; - int i; - - acm_log(2, "\n"); - - for (i = 0; (i < MAX_EP_ADDR) && - (ep->addr_info[i].type != ACM_ADDRESS_INVALID); i++) - ; - - if (i == MAX_EP_ADDR) { - acm_log(0, "ERROR - no more space for local address\n"); - return -1; - } - ep->addr_info[i].type = addr->type; - memcpy(&ep->addr_info[i].info, &addr->info, sizeof(addr->info)); - ep->addr_info[i].addr = (struct acm_address *) addr; - ep->addr_info[i].ep = ep; - - if (loopback_prot != ACMP_LOOPBACK_PROT_LOCAL) { - *addr_context = &ep->addr_info[i]; - return 0; - } - - dest = acmp_acquire_dest(ep, addr->type, (uint8_t *) addr->info.addr); - if (!dest) { - acm_log(0, "ERROR - unable to create loopback dest %s\n", - addr->id_string); - memset(&ep->addr_info[i], 0, sizeof(ep->addr_info[i])); - return -1; - } - - acm_get_gid((struct acm_port *) ep->port->port, 0, &dest->path.sgid); - dest->path.dgid = dest->path.sgid; - dest->path.dlid = dest->path.slid = htobe16(ep->port->lid); - dest->path.reversible_numpath = IBV_PATH_RECORD_REVERSIBLE; - dest->path.pkey = htobe16(ep->pkey); - dest->path.mtu = (uint8_t) ep->port->mtu; - dest->path.rate = (uint8_t) ep->port->rate; - - dest->remote_qpn = ep->qp->qp_num; - dest->addr_timeout = (uint64_t) ~0ULL; - dest->route_timeout = (uint64_t) ~0ULL; - dest->state = ACMP_READY; - acmp_put_dest(dest); - *addr_context = &ep->addr_info[i]; - acm_log(1, "added loopback dest %s\n", dest->name); - - return 0; -} - -static void acmp_remove_addr(void *addr_context) -{ - struct acmp_addr *address = addr_context; - - acm_log(2, "\n"); - memset(address, 0, sizeof(*address)); -} - -static struct acmp_port *acmp_get_port(struct acm_endpoint *endpoint) -{ - struct acmp_device *dev; - - acm_log(1, "dev 0x%" PRIx64 " port %d pkey 0x%x\n", - be64toh(endpoint->port->dev->dev_guid), - endpoint->port->port_num, endpoint->pkey); - - list_for_each(&acmp_dev_list, dev, entry) { - if (dev->guid == endpoint->port->dev->dev_guid) - return &dev->port[endpoint->port->port_num - 1]; - } - - return NULL; -} - -static struct acmp_ep * -acmp_get_ep(struct acmp_port *port, struct acm_endpoint *endpoint) -{ - struct acmp_ep *ep; - - acm_log(1, "dev 0x%" PRIx64 " port %d pkey 0x%x\n", - be64toh(endpoint->port->dev->dev_guid), - endpoint->port->port_num, endpoint->pkey); - - list_for_each(&port->ep_list, ep, entry) { - if (ep->pkey == endpoint->pkey) - return ep; - } - - return NULL; -} - -static uint16_t acmp_get_pkey_index(struct acm_endpoint *endpoint) -{ - struct acmp_port *port; - int ret; - __be16 pkey; - uint16_t i; - - port = acmp_get_port(endpoint); - if (!port) - return 0; - - for (i = 0, ret = 0; !ret; i++) { - ret = ibv_query_pkey(port->dev->verbs, port->port_num, i, &pkey); - if (!ret && endpoint->pkey == be16toh(pkey)) - return i; - } - return 0; -} - -static void acmp_close_endpoint(void *ep_context) -{ - - struct acmp_ep *ep = ep_context; - - acm_log(1, "%s %d pkey 0x%04x\n", - ep->port->dev->verbs->device->name, - ep->port->port_num, ep->pkey); - - ep->endpoint = NULL; -} - -static struct acmp_ep * -acmp_alloc_ep(struct acmp_port *port, struct acm_endpoint *endpoint) -{ - struct acmp_ep *ep; - int i; - - acm_log(1, "\n"); - ep = calloc(1, sizeof *ep); - if (!ep) - return NULL; - - ep->port = port; - ep->endpoint = endpoint; - ep->pkey = endpoint->pkey; - ep->resolve_queue.credits = resolve_depth; - ep->resp_queue.credits = send_depth; - list_head_init(&ep->resolve_queue.pending); - list_head_init(&ep->resp_queue.pending); - list_head_init(&ep->active_queue); - list_head_init(&ep->wait_queue); - pthread_mutex_init(&ep->lock, NULL); - sprintf(ep->id_string, "%s-%d-0x%x", port->dev->verbs->device->name, - port->port_num, endpoint->pkey); - for (i = 0; i < ACM_MAX_COUNTER; i++) - atomic_init(&ep->counters[i]); - - return ep; -} - -static int acmp_open_endpoint(const struct acm_endpoint *endpoint, - void *port_context, void **ep_context) -{ - struct acmp_port *port = port_context; - struct acmp_ep *ep; - struct ibv_qp_init_attr init_attr; - struct ibv_qp_attr attr; - int ret, sq_size; - - ep = acmp_get_ep(port, (struct acm_endpoint *) endpoint); - if (ep) { - acm_log(2, "endpoint for pkey 0x%x already exists\n", endpoint->pkey); - pthread_mutex_lock(&ep->lock); - ep->endpoint = (struct acm_endpoint *) endpoint; - pthread_mutex_unlock(&ep->lock); - *ep_context = (void *) ep; - return 0; - } - - acm_log(2, "creating endpoint for pkey 0x%x\n", endpoint->pkey); - ep = acmp_alloc_ep(port, (struct acm_endpoint *) endpoint); - if (!ep) - return -1; - - sprintf(ep->id_string, "%s-%d-0x%x", - port->dev->verbs->device->name, - port->port_num, endpoint->pkey); - - sq_size = resolve_depth + send_depth; - ep->cq = ibv_create_cq(port->dev->verbs, sq_size + recv_depth, - ep, port->dev->channel, 0); - if (!ep->cq) { - acm_log(0, "ERROR - failed to create CQ\n"); - goto err0; - } - - ret = ibv_req_notify_cq(ep->cq, 0); - if (ret) { - acm_log(0, "ERROR - failed to arm CQ\n"); - goto err1; - } - - memset(&init_attr, 0, sizeof init_attr); - init_attr.cap.max_send_wr = sq_size; - init_attr.cap.max_recv_wr = recv_depth; - init_attr.cap.max_send_sge = 1; - init_attr.cap.max_recv_sge = 1; - init_attr.qp_context = ep; - init_attr.sq_sig_all = 1; - init_attr.qp_type = IBV_QPT_UD; - init_attr.send_cq = ep->cq; - init_attr.recv_cq = ep->cq; - ep->qp = ibv_create_qp(ep->port->dev->pd, &init_attr); - if (!ep->qp) { - acm_log(0, "ERROR - failed to create QP\n"); - goto err1; - } - - attr.qp_state = IBV_QPS_INIT; - attr.port_num = port->port_num; - attr.pkey_index = acmp_get_pkey_index((struct acm_endpoint *) endpoint); - attr.qkey = ACM_QKEY; - ret = ibv_modify_qp(ep->qp, &attr, IBV_QP_STATE | IBV_QP_PKEY_INDEX | - IBV_QP_PORT | IBV_QP_QKEY); - if (ret) { - acm_log(0, "ERROR - failed to modify QP to init\n"); - goto err2; - } - - attr.qp_state = IBV_QPS_RTR; - ret = ibv_modify_qp(ep->qp, &attr, IBV_QP_STATE); - if (ret) { - acm_log(0, "ERROR - failed to modify QP to rtr\n"); - goto err2; - } - - attr.qp_state = IBV_QPS_RTS; - attr.sq_psn = 0; - ret = ibv_modify_qp(ep->qp, &attr, IBV_QP_STATE | IBV_QP_SQ_PSN); - if (ret) { - acm_log(0, "ERROR - failed to modify QP to rts\n"); - goto err2; - } - - ret = acmp_post_recvs(ep); - if (ret) - goto err2; - - pthread_mutex_lock(&port->lock); - list_add(&port->ep_list, &ep->entry); - pthread_mutex_unlock(&port->lock); - acmp_ep_preload(ep); - acmp_ep_join(ep); - *ep_context = (void *) ep; - return 0; - -err2: - ibv_destroy_qp(ep->qp); -err1: - ibv_destroy_cq(ep->cq); -err0: - free(ep); - return -1; -} - -static void acmp_port_up(struct acmp_port *port) -{ - struct ibv_port_attr attr; - uint16_t pkey; - __be16 pkey_be; - __be16 sm_lid; - int i, ret; - - acm_log(1, "%s %d\n", port->dev->verbs->device->name, port->port_num); - ret = ibv_query_port(port->dev->verbs, port->port_num, &attr); - if (ret) { - acm_log(0, "ERROR - unable to get port attribute\n"); - return; - } - - port->mtu = attr.active_mtu; - port->rate = acm_get_rate(attr.active_width, attr.active_speed); - if (attr.subnet_timeout >= 8) - port->subnet_timeout = 1 << (attr.subnet_timeout - 8); - - port->lid = attr.lid; - port->lid_mask = 0xffff - ((1 << attr.lmc) - 1); - - port->sa_dest.av.src_path_bits = 0; - port->sa_dest.av.dlid = attr.sm_lid; - port->sa_dest.av.sl = attr.sm_sl; - port->sa_dest.av.port_num = port->port_num; - port->sa_dest.remote_qpn = 1; - sm_lid = htobe16(attr.sm_lid); - acmp_set_dest_addr(&port->sa_dest, ACM_ADDRESS_LID, - (uint8_t *) &sm_lid, sizeof(sm_lid)); - - atomic_set(&port->sa_dest.refcnt, 1); - port->sa_dest.state = ACMP_READY; - for (i = 0; i < attr.pkey_tbl_len; i++) { - ret = ibv_query_pkey(port->dev->verbs, port->port_num, i, &pkey_be); - if (ret) - continue; - pkey = be16toh(pkey_be); - if (!(pkey & 0x7fff)) - continue; - - /* Determine pkey index for default partition with preference - * for full membership - */ - if ((pkey & 0x7fff) == 0x7fff) { - port->default_pkey_ix = i; - break; - } - } - - port->state = IBV_PORT_ACTIVE; - acm_log(1, "%s %d is up\n", port->dev->verbs->device->name, port->port_num); -} - -static void acmp_port_down(struct acmp_port *port) -{ - acm_log(1, "%s %d\n", port->dev->verbs->device->name, port->port_num); - pthread_mutex_lock(&port->lock); - port->state = IBV_PORT_DOWN; - pthread_mutex_unlock(&port->lock); - - /* - * We wait for the SA destination to be released. We could use an - * event instead of a sleep loop, but it's not worth it given how - * infrequently we should be processing a port down event in practice. - */ - atomic_dec(&port->sa_dest.refcnt); - while (atomic_get(&port->sa_dest.refcnt)) - sleep(0); - pthread_mutex_lock(&port->sa_dest.lock); - port->sa_dest.state = ACMP_INIT; - pthread_mutex_unlock(&port->sa_dest.lock); - acm_log(1, "%s %d is down\n", port->dev->verbs->device->name, port->port_num); -} - -static int acmp_open_port(const struct acm_port *cport, void *dev_context, - void **port_context) -{ - struct acmp_device *dev = dev_context; - struct acmp_port *port; - - if (cport->port_num < 1 || cport->port_num > dev->port_cnt) { - acm_log(0, "Error: port_num %d is out of range (max %d)\n", - cport->port_num, dev->port_cnt); - return -1; - } - - port = &dev->port[cport->port_num - 1]; - pthread_mutex_lock(&port->lock); - port->port = cport; - port->state = IBV_PORT_DOWN; - pthread_mutex_unlock(&port->lock); - acmp_port_up(port); - *port_context = port; - return 0; -} - -static void acmp_close_port(void *port_context) -{ - struct acmp_port *port = port_context; - - acmp_port_down(port); - pthread_mutex_lock(&port->lock); - port->port = NULL; - pthread_mutex_unlock(&port->lock); -} - -static void acmp_init_port(struct acmp_port *port, struct acmp_device *dev, - uint8_t port_num) -{ - acm_log(1, "%s %d\n", dev->verbs->device->name, port_num); - port->dev = dev; - port->port_num = port_num; - pthread_mutex_init(&port->lock, NULL); - list_head_init(&port->ep_list); - acmp_init_dest(&port->sa_dest, ACM_ADDRESS_LID, NULL, 0); - port->state = IBV_PORT_DOWN; -} - -static int acmp_open_dev(const struct acm_device *device, void **dev_context) -{ - struct acmp_device *dev; - size_t size; - struct ibv_device_attr attr; - int i, ret; - struct ibv_context *verbs; - - acm_log(1, "dev_guid 0x%" PRIx64 " %s\n", be64toh(device->dev_guid), - device->verbs->device->name); - - list_for_each(&acmp_dev_list, dev, entry) { - if (dev->guid == device->dev_guid) { - acm_log(2, "dev_guid 0x%" PRIx64 " already exits\n", - be64toh(device->dev_guid)); - *dev_context = dev; - dev->device = device; - return 0; - } - } - - /* We need to release the core device structure when device close is - * called. But this provider does not support dynamic add/removal of - * devices/ports/endpoints. To avoid use-after-free issues, we open - * our own verbs context, rather than using the one in the core - * device structure. - */ - verbs = ibv_open_device(device->verbs->device); - if (!verbs) { - acm_log(0, "ERROR - opening device %s\n", - device->verbs->device->name); - goto err; - } - - ret = ibv_query_device(verbs, &attr); - if (ret) { - acm_log(0, "ERROR - ibv_query_device (%s) %d\n", - verbs->device->name, ret); - goto err; - } - - size = sizeof(*dev) + sizeof(struct acmp_port) * attr.phys_port_cnt; - dev = (struct acmp_device *) calloc(1, size); - if (!dev) - goto err; - - dev->verbs = verbs; - dev->device = device; - dev->port_cnt = attr.phys_port_cnt; - - dev->pd = ibv_alloc_pd(dev->verbs); - if (!dev->pd) { - acm_log(0, "ERROR - unable to allocate PD\n"); - goto err1; - } - - dev->channel = ibv_create_comp_channel(dev->verbs); - if (!dev->channel) { - acm_log(0, "ERROR - unable to create comp channel\n"); - goto err2; - } - - for (i = 0; i < dev->port_cnt; i++) { - acmp_init_port(&dev->port[i], dev, i + 1); - } - - if (pthread_create(&dev->comp_thread_id, NULL, acmp_comp_handler, dev)) { - acm_log(0, "Error -- failed to create the comp thread for dev %s", - dev->verbs->device->name); - goto err3; - } - - pthread_mutex_lock(&acmp_dev_lock); - list_add(&acmp_dev_list, &dev->entry); - pthread_mutex_unlock(&acmp_dev_lock); - dev->guid = device->dev_guid; - *dev_context = dev; - - acm_log(1, "%s opened\n", dev->verbs->device->name); - return 0; - -err3: - ibv_destroy_comp_channel(dev->channel); -err2: - ibv_dealloc_pd(dev->pd); -err1: - free(dev); -err: - return -1; -} - -static void acmp_close_dev(void *dev_context) -{ - struct acmp_device *dev = dev_context; - - acm_log(1, "dev_guid 0x%" PRIx64 "\n", be64toh(dev->device->dev_guid)); - dev->device = NULL; -} - -static void acmp_set_options(void) -{ - FILE *f; - char s[120]; - char opt[32], value[256]; - const char *opts_file = acm_get_opts_file(); - - if (!(f = fopen(opts_file, "r"))) - return; - - while (fgets(s, sizeof s, f)) { - if (s[0] == '#') - continue; - - if (sscanf(s, "%31s%255s", opt, value) != 2) - continue; - - if (!strcasecmp("addr_prot", opt)) - addr_prot = acmp_convert_addr_prot(value); - else if (!strcasecmp("addr_timeout", opt)) - addr_timeout = atoi(value); - else if (!strcasecmp("route_prot", opt)) - route_prot = acmp_convert_route_prot(value); - else if (!strcmp("route_timeout", opt)) - route_timeout = atoi(value); - else if (!strcasecmp("loopback_prot", opt)) - loopback_prot = acmp_convert_loopback_prot(value); - else if (!strcasecmp("timeout", opt)) - timeout = atoi(value); - else if (!strcasecmp("retries", opt)) - retries = atoi(value); - else if (!strcasecmp("resolve_depth", opt)) - resolve_depth = atoi(value); - else if (!strcasecmp("send_depth", opt)) - send_depth = atoi(value); - else if (!strcasecmp("recv_depth", opt)) - recv_depth = atoi(value); - else if (!strcasecmp("min_mtu", opt)) - min_mtu = acm_convert_mtu(atoi(value)); - else if (!strcasecmp("min_rate", opt)) - min_rate = acm_convert_rate(atoi(value)); - else if (!strcasecmp("route_preload", opt)) - route_preload = acmp_convert_route_preload(value); - else if (!strcasecmp("route_data_file", opt)) - strcpy(route_data_file, value); - else if (!strcasecmp("addr_preload", opt)) - addr_preload = acmp_convert_addr_preload(value); - else if (!strcasecmp("addr_data_file", opt)) - strcpy(addr_data_file, value); - } - - fclose(f); -} - -static void acmp_log_options(void) -{ - acm_log(0, "address resolution %d\n", addr_prot); - acm_log(0, "address timeout %d\n", addr_timeout); - acm_log(0, "route resolution %d\n", route_prot); - acm_log(0, "route timeout %d\n", route_timeout); - acm_log(0, "loopback resolution %d\n", loopback_prot); - acm_log(0, "timeout %d ms\n", timeout); - acm_log(0, "retries %d\n", retries); - acm_log(0, "resolve depth %d\n", resolve_depth); - acm_log(0, "send depth %d\n", send_depth); - acm_log(0, "receive depth %d\n", recv_depth); - acm_log(0, "minimum mtu %d\n", min_mtu); - acm_log(0, "minimum rate %d\n", min_rate); - acm_log(0, "route preload %d\n", route_preload); - acm_log(0, "route data file %s\n", route_data_file); - acm_log(0, "address preload %d\n", addr_preload); - acm_log(0, "address data file %s\n", addr_data_file); -} - -static void __attribute__((constructor)) acmp_init(void) -{ - acmp_set_options(); - - acmp_log_options(); - - atomic_init(&g_tid); - atomic_init(&wait_cnt); - pthread_mutex_init(&acmp_dev_lock, NULL); - event_init(&timeout_event); - - umad_init(); - - acm_log(1, "starting timeout/retry thread\n"); - if (pthread_create(&retry_thread_id, NULL, acmp_retry_handler, NULL)) { - acm_log(0, "Error: failed to create the retry thread"); - retry_thread_started = 0; - return; - } - - acmp_initialized = 1; -} - -int provider_query(struct acm_provider **provider, uint32_t *version) -{ - acm_log(1, "\n"); - - if (!acmp_initialized) - return -1; - - if (provider) - *provider = &def_prov; - if (version) - *version = ACM_PROV_VERSION; - - return 0; -} - diff --git a/usr/rdma-core/ibacm/prov/acmp/src/libibacmp.map b/usr/rdma-core/ibacm/prov/acmp/src/libibacmp.map deleted file mode 100644 index cccd1664e..000000000 --- a/usr/rdma-core/ibacm/prov/acmp/src/libibacmp.map +++ /dev/null @@ -1,5 +0,0 @@ -ACMP_1.0 { - global: - provider_query; - local: *; -}; diff --git a/usr/rdma-core/ibacm/src/acm.c b/usr/rdma-core/ibacm/src/acm.c deleted file mode 100644 index 1ccef9486..000000000 --- a/usr/rdma-core/ibacm/src/acm.c +++ /dev/null @@ -1,3114 +0,0 @@ -/* - * Copyright (c) 2009-2014 Intel Corporation. All rights reserved. - * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define _GNU_SOURCE - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "acm_mad.h" -#include "acm_util.h" - -#define src_out data[0] -#define src_index data[1] -#define dst_index data[2] - -#define MAX_EP_ADDR 4 -#define NL_MSG_BUF_SIZE 4096 -#define ACM_PROV_NAME_SIZE 64 -#define NL_CLIENT_INDEX 0 - -struct acmc_subnet { - struct list_node entry; - __be64 subnet_prefix; -}; - -struct acmc_prov { - struct acm_provider *prov; - void *handle; - struct list_node entry; - struct list_head subnet_list; -}; - -struct acmc_prov_context { - struct list_node entry; - atomic_t refcnt; - struct acm_provider *prov; - void *context; -}; - -struct acmc_device; - -struct acmc_port { - struct acmc_device *dev; - struct acm_port port; - struct acm_provider *prov; /* limit to 1 provider per port for now */ - void *prov_port_context; - int mad_portid; - int mad_agentid; - struct ib_mad_addr sa_addr; - struct list_head sa_pending; - struct list_head sa_wait; - int sa_credits; - pthread_mutex_t lock; - struct list_head ep_list; - enum ibv_port_state state; - int gid_cnt; - union ibv_gid *gid_tbl; - uint16_t lid; - uint16_t lid_mask; - int sa_pkey_index; - uint16_t def_acm_pkey; -}; - -struct acmc_device { - struct acm_device device; - struct list_node entry; - struct list_head prov_dev_context_list; - int port_cnt; - struct acmc_port port[0]; -}; - -struct acmc_addr { - struct acm_address addr; - void *prov_addr_context; - char string_buf[ACM_MAX_ADDRESS]; -}; - -struct acmc_ep { - struct acmc_port *port; - struct acm_endpoint endpoint; - void *prov_ep_context; - struct acmc_addr addr_info[MAX_EP_ADDR]; - struct list_node entry; -}; - -struct acmc_client { - pthread_mutex_t lock; /* acquire ep lock first */ - int sock; - int index; - atomic_t refcnt; -}; - -union socket_addr { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; -}; - -struct acmc_sa_req { - struct list_node entry; - struct acmc_ep *ep; - void (*resp_handler)(struct acm_sa_mad *); - struct acm_sa_mad mad; -}; - -struct acm_nl_path { - struct nlattr attr_hdr; - struct ib_path_rec_data rec; -}; - -struct acm_nl_msg { - struct nlmsghdr nlmsg_header; - union { - uint8_t data[ACM_MSG_DATA_LENGTH]; - struct rdma_ls_resolve_header resolve_header; - struct nlattr attr[0]; - struct acm_nl_path path[0]; - }; -}; - -static char def_prov_name[ACM_PROV_NAME_SIZE] = "ibacmp"; -static LIST_HEAD(provider_list); -static struct acmc_prov *def_provider = NULL; - -static LIST_HEAD(dev_list); - -static int listen_socket; -static int ip_mon_socket; -static struct acmc_client client_array[FD_SETSIZE - 1]; - -static FILE *flog; -static pthread_mutex_t log_lock; -static __thread char log_data[ACM_MAX_ADDRESS]; -static atomic_t counter[ACM_MAX_COUNTER]; - -static struct acmc_device * -acm_get_device_from_gid(union ibv_gid *sgid, uint8_t *port); -static struct acmc_ep *acm_find_ep(struct acmc_port *port, uint16_t pkey); -static int acm_ep_insert_addr(struct acmc_ep *ep, const char *name, uint8_t *addr, - size_t addr_len, uint8_t addr_type); -static void acm_event_handler(struct acmc_device *dev); -static int acm_nl_send(int sock, struct acm_msg *msg); - -static struct sa_data { - int timeout; - int retries; - int depth; - pthread_t thread_id; - struct pollfd *fds; - struct acmc_port **ports; - int nfds; -} sa = { 2000, 2, 1, 0, NULL, NULL, 0}; - -/* - * Service options - may be set through ibacm_opts.cfg file. - */ -static const char *acme = IBACM_BIN_PATH "/ib_acme -A"; -static const char *opts_file = ACM_CONF_DIR "/" ACM_OPTS_FILE; -static const char *addr_file = ACM_CONF_DIR "/" ACM_ADDR_FILE; -static char log_file[128] = IBACM_LOG_FILE; -static int log_level = 0; -static char lock_file[128] = IBACM_PID_FILE; -static short server_port = 6125; -static int support_ips_in_addr_cfg = 0; -static char prov_lib_path[256] = IBACM_LIB_PATH; - -void acm_write(int level, const char *format, ...) -{ - va_list args; - struct timeval tv; - - if (level > log_level) - return; - - gettimeofday(&tv, NULL); - va_start(args, format); - pthread_mutex_lock(&log_lock); - fprintf(flog, "%u.%03u: ", (unsigned) tv.tv_sec, (unsigned) (tv.tv_usec / 1000)); - vfprintf(flog, format, args); - fflush(flog); - pthread_mutex_unlock(&log_lock); - va_end(args); -} - -void acm_format_name(int level, char *name, size_t name_size, - uint8_t addr_type, const uint8_t *addr, size_t addr_size) -{ - struct ibv_path_record *path; - - if (level > log_level) - return; - - switch (addr_type) { - case ACM_EP_INFO_NAME: - memcpy(name, addr, addr_size); - break; - case ACM_EP_INFO_ADDRESS_IP: - inet_ntop(AF_INET, addr, name, name_size); - break; - case ACM_EP_INFO_ADDRESS_IP6: - case ACM_ADDRESS_GID: - inet_ntop(AF_INET6, addr, name, name_size); - break; - case ACM_EP_INFO_PATH: - path = (struct ibv_path_record *) addr; - if (path->dlid) { - snprintf(name, name_size, "SLID(%u) DLID(%u)", - be16toh(path->slid), be16toh(path->dlid)); - } else { - acm_format_name(level, name, name_size, ACM_ADDRESS_GID, - path->dgid.raw, sizeof path->dgid); - } - break; - case ACM_ADDRESS_LID: - snprintf(name, name_size, "LID(%u)", be16toh(*((__be16 *) addr))); - break; - default: - strcpy(name, "Unknown"); - break; - } -} - -int ib_any_gid(union ibv_gid *gid) -{ - return ((gid->global.subnet_prefix | gid->global.interface_id) == 0); -} - -const char *acm_get_opts_file(void) -{ - return opts_file; -} - -void acm_increment_counter(int type) -{ - if (type >= 0 && type < ACM_MAX_COUNTER) - atomic_inc(&counter[type]); -} - -static struct acmc_prov_context * -acm_alloc_prov_context(struct acm_provider *prov) -{ - struct acmc_prov_context *ctx; - - ctx = calloc(1, sizeof(*ctx)); - if (!ctx) { - acm_log(0, "Error: failed to allocate prov context\n"); - return NULL; - } - atomic_set(&ctx->refcnt, 1); - ctx->prov = prov; - return ctx; -} - -static struct acmc_prov_context * -acm_get_prov_context(struct list_head *list, struct acm_provider *prov) -{ - struct acmc_prov_context *ctx; - - list_for_each(list, ctx, entry) { - if (ctx->prov == prov) { - return ctx; - } - } - - return NULL; -} - -static struct acmc_prov_context * -acm_acquire_prov_context(struct list_head *list, struct acm_provider *prov) -{ - struct acmc_prov_context *ctx; - - ctx = acm_get_prov_context(list, prov); - if (!ctx) { - ctx = acm_alloc_prov_context(prov); - if (!ctx) { - acm_log(0, "Error -- failed to allocate provider context\n"); - return NULL; - } - list_add_tail(list, &ctx->entry); - } else { - atomic_inc(&ctx->refcnt); - } - - return ctx; -} - -static void -acm_release_prov_context(struct acmc_prov_context *ctx) -{ - if (atomic_dec(&ctx->refcnt) <= 0) { - list_del(&ctx->entry); - free(ctx); - } -} - -uint8_t acm_gid_index(struct acm_port *port, union ibv_gid *gid) -{ - uint8_t i; - struct acmc_port *cport; - - cport = container_of(port, struct acmc_port, port); - for (i = 0; i < cport->gid_cnt; i++) { - if (!memcmp(&cport->gid_tbl[i], gid, sizeof (*gid))) - break; - } - return i; -} - -int acm_get_gid(struct acm_port *port, int index, union ibv_gid *gid) -{ - struct acmc_port *cport; - - cport = container_of(port, struct acmc_port, port); - if (index >= 0 && index < cport->gid_cnt) { - *gid = cport->gid_tbl[index]; - return 0; - } else { - return -1; - } -} - -static void acm_mark_addr_invalid(struct acmc_ep *ep, - struct acm_ep_addr_data *data) -{ - int i; - - for (i = 0; i < MAX_EP_ADDR; i++) { - if (ep->addr_info[i].addr.type != data->type) - continue; - - if ((data->type == ACM_ADDRESS_NAME && - !strncasecmp((char *) ep->addr_info[i].addr.info.name, - (char *) data->info.addr, ACM_MAX_ADDRESS)) || - !memcmp(ep->addr_info[i].addr.info.addr, data->info.addr, - ACM_MAX_ADDRESS)) { - ep->addr_info[i].addr.type = ACM_ADDRESS_INVALID; - break; - } - } -} - -static struct acm_address * -acm_addr_lookup(const struct acm_endpoint *endpoint, uint8_t *addr, uint8_t addr_type) -{ - struct acmc_ep *ep; - int i; - - ep = container_of(endpoint, struct acmc_ep, endpoint); - for (i = 0; i < MAX_EP_ADDR; i++) { - if (ep->addr_info[i].addr.type != addr_type) - continue; - - if ((addr_type == ACM_ADDRESS_NAME && - !strncasecmp((char *) ep->addr_info[i].addr.info.name, - (char *) addr, ACM_MAX_ADDRESS)) || - !memcmp(ep->addr_info[i].addr.info.addr, addr, ACM_MAX_ADDRESS)) - return &ep->addr_info[i].addr; - } - return NULL; -} - -__be64 acm_path_comp_mask(struct ibv_path_record *path) -{ - uint32_t fl_hop; - uint16_t qos_sl; - __be64 comp_mask = 0; - - acm_log(2, "\n"); - if (path->service_id) - comp_mask |= IB_COMP_MASK_PR_SERVICE_ID; - if (!ib_any_gid(&path->dgid)) - comp_mask |= IB_COMP_MASK_PR_DGID; - if (!ib_any_gid(&path->sgid)) - comp_mask |= IB_COMP_MASK_PR_SGID; - if (path->dlid) - comp_mask |= IB_COMP_MASK_PR_DLID; - if (path->slid) - comp_mask |= IB_COMP_MASK_PR_SLID; - - fl_hop = be32toh(path->flowlabel_hoplimit); - if (fl_hop >> 8) - comp_mask |= IB_COMP_MASK_PR_FLOW_LABEL; - if (fl_hop & 0xFF) - comp_mask |= IB_COMP_MASK_PR_HOP_LIMIT; - - if (path->tclass) - comp_mask |= IB_COMP_MASK_PR_TCLASS; - if (path->reversible_numpath & 0x80) - comp_mask |= IB_COMP_MASK_PR_REVERSIBLE; - if (path->pkey) - comp_mask |= IB_COMP_MASK_PR_PKEY; - - qos_sl = be16toh(path->qosclass_sl); - if (qos_sl >> 4) - comp_mask |= IB_COMP_MASK_PR_QOS_CLASS; - if (qos_sl & 0xF) - comp_mask |= IB_COMP_MASK_PR_SL; - - if (path->mtu & 0xC0) - comp_mask |= IB_COMP_MASK_PR_MTU_SELECTOR; - if (path->mtu & 0x3F) - comp_mask |= IB_COMP_MASK_PR_MTU; - if (path->rate & 0xC0) - comp_mask |= IB_COMP_MASK_PR_RATE_SELECTOR; - if (path->rate & 0x3F) - comp_mask |= IB_COMP_MASK_PR_RATE; - if (path->packetlifetime & 0xC0) - comp_mask |= IB_COMP_MASK_PR_PACKET_LIFETIME_SELECTOR; - if (path->packetlifetime & 0x3F) - comp_mask |= IB_COMP_MASK_PR_PACKET_LIFETIME; - - return comp_mask; -} - -int acm_resolve_response(uint64_t id, struct acm_msg *msg) -{ - struct acmc_client *client = &client_array[id]; - int ret; - - acm_log(2, "client %d, status 0x%x\n", client->index, msg->hdr.status); - - if (msg->hdr.status == ACM_STATUS_ENODATA) - atomic_inc(&counter[ACM_CNTR_NODATA]); - else if (msg->hdr.status) - atomic_inc(&counter[ACM_CNTR_ERROR]); - - pthread_mutex_lock(&client->lock); - if (client->sock == -1) { - acm_log(0, "ERROR - connection lost\n"); - ret = ACM_STATUS_ENOTCONN; - goto release; - } - - if (id == NL_CLIENT_INDEX) - ret = acm_nl_send(client->sock, msg); - else - ret = send(client->sock, (char *) msg, msg->hdr.length, 0); - - if (ret != msg->hdr.length) - acm_log(0, "ERROR - failed to send response\n"); - else - ret = 0; - -release: - pthread_mutex_unlock(&client->lock); - (void) atomic_dec(&client->refcnt); - return ret; -} - -static int -acmc_resolve_response(uint64_t id, struct acm_msg *req_msg, uint8_t status) -{ - req_msg->hdr.opcode |= ACM_OP_ACK; - req_msg->hdr.status = status; - if (status != ACM_STATUS_SUCCESS) - req_msg->hdr.length = ACM_MSG_HDR_LENGTH; - memset(req_msg->hdr.data, 0, sizeof(req_msg->hdr.data)); - - return acm_resolve_response(id, req_msg); -} - -int acm_query_response(uint64_t id, struct acm_msg *msg) -{ - struct acmc_client *client = &client_array[id]; - int ret; - - acm_log(2, "status 0x%x\n", msg->hdr.status); - pthread_mutex_lock(&client->lock); - if (client->sock == -1) { - acm_log(0, "ERROR - connection lost\n"); - ret = ACM_STATUS_ENOTCONN; - goto release; - } - - ret = send(client->sock, (char *) msg, msg->hdr.length, 0); - if (ret != msg->hdr.length) - acm_log(0, "ERROR - failed to send response\n"); - else - ret = 0; - -release: - pthread_mutex_unlock(&client->lock); - (void) atomic_dec(&client->refcnt); - return ret; -} - -static int acmc_query_response(uint64_t id, struct acm_msg *msg, uint8_t status) -{ - acm_log(2, "status 0x%x\n", status); - msg->hdr.opcode |= ACM_OP_ACK; - msg->hdr.status = status; - return acm_query_response(id, msg); -} - -static void acm_init_server(void) -{ - FILE *f; - int i; - - for (i = 0; i < FD_SETSIZE - 1; i++) { - pthread_mutex_init(&client_array[i].lock, NULL); - client_array[i].index = i; - client_array[i].sock = -1; - atomic_init(&client_array[i].refcnt); - } - - if (!(f = fopen(IBACM_PORT_FILE, "w"))) { - acm_log(0, "notice - cannot publish ibacm port number\n"); - return; - } - fprintf(f, "%hu\n", server_port); - fclose(f); -} - -static int acm_listen(void) -{ - struct sockaddr_in addr; - int ret; - - acm_log(2, "\n"); - listen_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (listen_socket == -1) { - acm_log(0, "ERROR - unable to allocate listen socket\n"); - return errno; - } - - memset(&addr, 0, sizeof addr); - addr.sin_family = AF_INET; - addr.sin_port = htobe16(server_port); - ret = bind(listen_socket, (struct sockaddr *) &addr, sizeof addr); - if (ret == -1) { - acm_log(0, "ERROR - unable to bind listen socket\n"); - return errno; - } - - ret = listen(listen_socket, 0); - if (ret == -1) { - acm_log(0, "ERROR - unable to start listen\n"); - return errno; - } - - acm_log(2, "listen active\n"); - return 0; -} - -/* Retrieve the listening socket from systemd. */ -static int acm_listen_systemd(void) -{ - int fd; - - int rc = sd_listen_fds(1); - if (rc == -1) { - fprintf(stderr, "sd_listen_fds failed %d\n", rc); - return rc; - } - - if (rc > 2) { - fprintf(stderr, - "sd_listen_fds returned %d fds, expected <= 2\n", rc); - return -1; - } - - for (fd = SD_LISTEN_FDS_START; fd != SD_LISTEN_FDS_START + rc; fd++) { - if (sd_is_socket(fd, AF_NETLINK, SOCK_RAW, 0)) { - /* ListenNetlink for RDMA_NL_GROUP_LS multicast - * messages from the kernel - */ - if (client_array[NL_CLIENT_INDEX].sock != -1) { - fprintf(stderr, - "sd_listen_fds returned more than one netlink socket\n"); - return -1; - } - client_array[NL_CLIENT_INDEX].sock = fd; - - /* systemd sets NONBLOCK on the netlink socket, while - * we want blocking send to the kernel. - */ - if (set_fd_nonblock(fd, false)) { - fprintf(stderr, - "Unable to drop O_NOBLOCK on netlink socket"); - return -1; - } - } else if (sd_is_socket(SD_LISTEN_FDS_START, AF_UNSPEC, - SOCK_STREAM, 1)) { - /* Socket for user space client communication */ - if (listen_socket != -1) { - fprintf(stderr, - "sd_listen_fds returned more than one listening socket\n"); - return -1; - } - listen_socket = fd; - } else { - fprintf(stderr, - "sd_listen_fds socket is not a SOCK_STREAM/SOCK_NETLINK listening socket\n"); - return -1; - } - } - - return 0; -} - -static void acm_disconnect_client(struct acmc_client *client) -{ - pthread_mutex_lock(&client->lock); - shutdown(client->sock, SHUT_RDWR); - close(client->sock); - client->sock = -1; - pthread_mutex_unlock(&client->lock); - (void) atomic_dec(&client->refcnt); -} - -static void acm_svr_accept(void) -{ - int s; - int i; - - acm_log(2, "\n"); - s = accept(listen_socket, NULL, NULL); - if (s == -1) { - acm_log(0, "ERROR - failed to accept connection\n"); - return; - } - - for (i = 0; i < FD_SETSIZE - 1; i++) { - if (i == NL_CLIENT_INDEX) - continue; - if (!atomic_get(&client_array[i].refcnt)) - break; - } - - if (i == FD_SETSIZE - 1) { - acm_log(0, "ERROR - all connections busy - rejecting\n"); - close(s); - return; - } - - client_array[i].sock = s; - atomic_set(&client_array[i].refcnt, 1); - acm_log(2, "assigned client %d\n", i); -} - -static int -acm_is_path_from_port(struct acmc_port *port, struct ibv_path_record *path) -{ - uint8_t i; - - if (!ib_any_gid(&path->sgid)) { - return (acm_gid_index(&port->port, &path->sgid) < - port->gid_cnt); - } - - if (path->slid) { - return (port->lid == (be16toh(path->slid) & port->lid_mask)); - } - - if (ib_any_gid(&path->dgid)) { - return 1; - } - - if (acm_gid_index(&port->port, &path->dgid) < port->gid_cnt) { - return 1; - } - - for (i = 0; i < port->gid_cnt; i++) { - if (port->gid_tbl[i].global.subnet_prefix == - path->dgid.global.subnet_prefix) { - return 1; - } - } - - return 0; -} - -static struct acmc_addr * -acm_get_port_ep_address(struct acmc_port *port, struct acm_ep_addr_data *data) -{ - struct acmc_ep *ep; - struct acm_address *addr; - int i; - - if (port->state != IBV_PORT_ACTIVE) - return NULL; - - if (data->type == ACM_EP_INFO_PATH && - !acm_is_path_from_port(port, &data->info.path)) - return NULL; - - list_for_each(&port->ep_list, ep, entry) { - if ((data->type == ACM_EP_INFO_PATH) && - (!data->info.path.pkey || - (be16toh(data->info.path.pkey) == ep->endpoint.pkey))) { - for (i = 0; i < MAX_EP_ADDR; i++) { - if (ep->addr_info[i].addr.type) - return &ep->addr_info[i]; - } - return NULL; - } - - if ((addr = acm_addr_lookup(&ep->endpoint, data->info.addr, - (uint8_t) data->type))) - return container_of(addr, struct acmc_addr, addr); - } - - return NULL; -} - -static struct acmc_addr *acm_get_ep_address(struct acm_ep_addr_data *data) -{ - struct acmc_device *dev; - struct acmc_addr *addr; - int i; - - acm_format_name(2, log_data, sizeof log_data, - data->type, data->info.addr, sizeof data->info.addr); - acm_log(2, "%s\n", log_data); - list_for_each(&dev_list, dev, entry) { - for (i = 0; i < dev->port_cnt; i++) { - addr = acm_get_port_ep_address(&dev->port[i], data); - if (addr) - return addr; - } - } - - acm_format_name(0, log_data, sizeof log_data, - data->type, data->info.addr, sizeof data->info.addr); - acm_log(1, "notice - could not find %s\n", log_data); - return NULL; -} - -static struct acmc_ep *acm_get_ep(int index) -{ - struct acmc_device *dev; - struct acmc_ep *ep; - int i, inx = 0; - - acm_log(2, "ep index %d\n", index); - list_for_each(&dev_list, dev, entry) { - for (i = 0; i < dev->port_cnt; i++) { - if (dev->port[i].state != IBV_PORT_ACTIVE) - continue; - list_for_each(&dev->port[i].ep_list, ep, entry) { - if (index == inx) - return ep; - } - } - } - - acm_log(1, "notice - could not find ep %d\n", index); - return NULL; -} - -static int -acm_svr_query_path(struct acmc_client *client, struct acm_msg *msg) -{ - struct acmc_addr *addr; - struct acmc_ep *ep; - - acm_log(2, "client %d\n", client->index); - if (msg->hdr.length != ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH) { - acm_log(0, "ERROR - invalid length: 0x%x\n", msg->hdr.length); - return acmc_query_response(client->index, msg, ACM_STATUS_EINVAL); - } - - addr = acm_get_ep_address(&msg->resolve_data[0]); - if (!addr) { - acm_log(1, "notice - could not find local end point address\n"); - return acmc_query_response(client->index, msg, ACM_STATUS_ESRCADDR); - } - - ep = container_of(addr->addr.endpoint, struct acmc_ep, endpoint); - return ep->port->prov->query(addr->prov_addr_context, msg, client->index); -} - -static int acm_svr_select_src(struct acm_ep_addr_data *src, struct acm_ep_addr_data *dst) -{ - union socket_addr addr; - socklen_t len; - int ret; - int s; - - acm_log(2, "selecting source address\n"); - memset(&addr, 0, sizeof addr); - switch (dst->type) { - case ACM_EP_INFO_ADDRESS_IP: - addr.sin.sin_family = AF_INET; - memcpy(&addr.sin.sin_addr, dst->info.addr, 4); - len = sizeof(struct sockaddr_in); - break; - case ACM_EP_INFO_ADDRESS_IP6: - addr.sin6.sin6_family = AF_INET6; - memcpy(&addr.sin6.sin6_addr, dst->info.addr, 16); - len = sizeof(struct sockaddr_in6); - break; - default: - acm_log(1, "notice - bad destination type, cannot lookup source\n"); - return ACM_STATUS_EDESTTYPE; - } - - s = socket(addr.sa.sa_family, SOCK_DGRAM, IPPROTO_UDP); - if (s == -1) { - acm_log(0, "ERROR - unable to allocate socket\n"); - return errno; - } - - ret = connect(s, &addr.sa, len); - if (ret) { - acm_log(0, "ERROR - unable to connect socket\n"); - ret = errno; - goto out; - } - - ret = getsockname(s, &addr.sa, &len); - if (ret) { - acm_log(0, "ERROR - failed to get socket address\n"); - ret = errno; - goto out; - } - - src->type = dst->type; - src->flags = ACM_EP_FLAG_SOURCE; - if (dst->type == ACM_EP_INFO_ADDRESS_IP) { - memcpy(&src->info.addr, &addr.sin.sin_addr, 4); - } else { - memcpy(&src->info.addr, &addr.sin6.sin6_addr, 16); - } -out: - close(s); - return ret; -} - -/* - * Verify the resolve message from the client and return - * references to the source and destination addresses. - * The message buffer contains extra address data buffers. If a - * source address is not given, reference an empty address buffer, - * and we'll resolve a source address later. Record the location of - * the source and destination addresses in the message header data - * to avoid further searches. - */ -static uint8_t acm_svr_verify_resolve(struct acm_msg *msg) -{ - int i, cnt, have_dst = 0; - - if (msg->hdr.length < ACM_MSG_HDR_LENGTH) { - acm_log(0, "ERROR - invalid msg hdr length %d\n", msg->hdr.length); - return ACM_STATUS_EINVAL; - } - - msg->hdr.src_out = 1; - cnt = (msg->hdr.length - ACM_MSG_HDR_LENGTH) / ACM_MSG_EP_LENGTH; - for (i = 0; i < cnt; i++) { - if (msg->resolve_data[i].flags & ACM_EP_FLAG_SOURCE) { - if (!msg->hdr.src_out) { - acm_log(0, "ERROR - multiple sources specified\n"); - return ACM_STATUS_ESRCADDR; - } - if (!msg->resolve_data[i].type || - (msg->resolve_data[i].type >= ACM_ADDRESS_RESERVED)) { - acm_log(0, "ERROR - unsupported source address type\n"); - return ACM_STATUS_ESRCTYPE; - } - msg->hdr.src_out = 0; - msg->hdr.src_index = i; - } - if (msg->resolve_data[i].flags & ACM_EP_FLAG_DEST) { - if (have_dst) { - acm_log(0, "ERROR - multiple destinations specified\n"); - return ACM_STATUS_EDESTADDR; - } - if (!msg->resolve_data[i].type || - (msg->resolve_data[i].type >= ACM_ADDRESS_RESERVED)) { - acm_log(0, "ERROR - unsupported destination address type\n"); - return ACM_STATUS_EDESTTYPE; - } - have_dst = 1; - msg->hdr.dst_index = i; - } - } - - if (!have_dst) { - acm_log(0, "ERROR - destination address required\n"); - return ACM_STATUS_EDESTTYPE; - } - - if (msg->hdr.src_out) { - msg->hdr.src_index = i; - memset(&msg->resolve_data[i], 0, sizeof(struct acm_ep_addr_data)); - } - return ACM_STATUS_SUCCESS; -} - -static int -acm_svr_resolve_dest(struct acmc_client *client, struct acm_msg *msg) -{ - struct acmc_addr *addr; - struct acmc_ep *ep; - struct acm_ep_addr_data *saddr, *daddr; - uint8_t status; - - acm_log(2, "client %d\n", client->index); - status = acm_svr_verify_resolve(msg); - if (status) { - acm_log(0, "notice - misformatted or unsupported request\n"); - return acmc_resolve_response(client->index, msg, status); - } - - saddr = &msg->resolve_data[msg->hdr.src_index]; - daddr = &msg->resolve_data[msg->hdr.dst_index]; - if (msg->hdr.src_out) { - status = acm_svr_select_src(saddr, daddr); - if (status) { - acm_log(0, "notice - unable to select suitable source address\n"); - return acmc_resolve_response(client->index, msg, status); - } - } - - acm_format_name(2, log_data, sizeof log_data, - saddr->type, saddr->info.addr, sizeof saddr->info.addr); - acm_log(2, "src %s\n", log_data); - addr = acm_get_ep_address(saddr); - if (!addr) { - acm_log(0, "notice - unknown local end point address\n"); - return acmc_resolve_response(client->index, msg, ACM_STATUS_ESRCADDR); - } - - ep = container_of(addr->addr.endpoint, struct acmc_ep, endpoint); - return ep->port->prov->resolve(addr->prov_addr_context, msg, client->index); -} - -/* - * The message buffer contains extra address data buffers. We extract the - * destination address from the path record into an extra buffer, so we can - * lookup the destination by either LID or GID. - */ -static int -acm_svr_resolve_path(struct acmc_client *client, struct acm_msg *msg) -{ - struct acmc_addr *addr; - struct acmc_ep *ep; - struct ibv_path_record *path; - - acm_log(2, "client %d\n", client->index); - if (msg->hdr.length < (ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH)) { - acm_log(0, "notice - invalid msg hdr length %d\n", msg->hdr.length); - return acmc_resolve_response(client->index, msg, ACM_STATUS_EINVAL); - } - - path = &msg->resolve_data[0].info.path; - if (!path->dlid && ib_any_gid(&path->dgid)) { - acm_log(0, "notice - no destination specified\n"); - return acmc_resolve_response(client->index, msg, - ACM_STATUS_EDESTADDR); - } - - acm_format_name(2, log_data, sizeof log_data, ACM_EP_INFO_PATH, - msg->resolve_data[0].info.addr, sizeof *path); - acm_log(2, "path %s\n", log_data); - addr = acm_get_ep_address(&msg->resolve_data[0]); - if (!addr) { - acm_log(0, "notice - unknown local end point address\n"); - return acmc_resolve_response(client->index, msg, - ACM_STATUS_ESRCADDR); - } - - ep = container_of(addr->addr.endpoint, struct acmc_ep, endpoint); - return ep->port->prov->resolve(addr->prov_addr_context, msg, - client->index); -} - -static int acm_svr_resolve(struct acmc_client *client, struct acm_msg *msg) -{ - (void) atomic_inc(&client->refcnt); - - if (msg->resolve_data[0].type == ACM_EP_INFO_PATH) { - if (msg->resolve_data[0].flags & ACM_FLAGS_QUERY_SA) { - return acm_svr_query_path(client, msg); - } else { - return acm_svr_resolve_path(client, msg); - } - } else { - return acm_svr_resolve_dest(client, msg); - } -} - -static int acm_svr_perf_query(struct acmc_client *client, struct acm_msg *msg) -{ - int ret, i; - uint16_t len; - struct acmc_addr *addr; - struct acmc_ep *ep = NULL; - int index; - - acm_log(2, "client %d\n", client->index); - index = msg->hdr.data[1]; - msg->hdr.opcode |= ACM_OP_ACK; - msg->hdr.status = ACM_STATUS_SUCCESS; - msg->hdr.data[2] = 0; - - if ((be16toh(msg->hdr.length) < (ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH) - && index < 1) || - ((be16toh(msg->hdr.length) >= (ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH) - && !(msg->resolve_data[0].flags & ACM_EP_FLAG_SOURCE)))) { - for (i = 0; i < ACM_MAX_COUNTER; i++) - msg->perf_data[i] = htobe64((uint64_t) atomic_get(&counter[i])); - - msg->hdr.data[0] = ACM_MAX_COUNTER; - len = ACM_MSG_HDR_LENGTH + (ACM_MAX_COUNTER * sizeof(uint64_t)); - } else { - if (index >= 1) { - ep = acm_get_ep(index - 1); - } else { - addr = acm_get_ep_address(&msg->resolve_data[0]); - if (addr) - ep = container_of(addr->addr.endpoint, - struct acmc_ep, endpoint); - } - - if (ep) { - ep->port->prov->query_perf(ep->prov_ep_context, - msg->perf_data, &msg->hdr.data[0]); - len = ACM_MSG_HDR_LENGTH + (msg->hdr.data[0] * sizeof(uint64_t)); - } else { - msg->hdr.status = ACM_STATUS_ESRCADDR; - len = ACM_MSG_HDR_LENGTH; - } - } - msg->hdr.length = htobe16(len); - - ret = send(client->sock, (char *) msg, len, 0); - if (ret != len) - acm_log(0, "ERROR - failed to send response\n"); - else - ret = 0; - - return ret; -} - -static int acm_svr_ep_query(struct acmc_client *client, struct acm_msg *msg) -{ - int ret, i; - uint16_t len; - struct acmc_ep *ep; - int index, cnt = 0; - - acm_log(2, "client %d\n", client->index); - index = msg->hdr.data[0]; - ep = acm_get_ep(index - 1); - if (ep) { - msg->hdr.status = ACM_STATUS_SUCCESS; - msg->ep_data[0].dev_guid = ep->port->dev->device.dev_guid; - msg->ep_data[0].port_num = ep->port->port.port_num; - msg->ep_data[0].pkey = htobe16(ep->endpoint.pkey); - strncpy((char *)msg->ep_data[0].prov_name, ep->port->prov->name, - ACM_MAX_PROV_NAME - 1); - msg->ep_data[0].prov_name[ACM_MAX_PROV_NAME - 1] = '\0'; - len = ACM_MSG_HDR_LENGTH + sizeof(struct acm_ep_config_data); - for (i = 0; i < MAX_EP_ADDR; i++) { - if (ep->addr_info[i].addr.type != ACM_ADDRESS_INVALID) { - memcpy(msg->ep_data[0].addrs[cnt++].name, - ep->addr_info[i].string_buf, - ACM_MAX_ADDRESS); - } - } - msg->ep_data[0].addr_cnt = htobe16(cnt); - len += cnt * ACM_MAX_ADDRESS; - } else { - msg->hdr.status = ACM_STATUS_EINVAL; - len = ACM_MSG_HDR_LENGTH; - } - msg->hdr.opcode |= ACM_OP_ACK; - msg->hdr.data[1] = 0; - msg->hdr.data[2] = 0; - msg->hdr.length = htobe16(len); - - ret = send(client->sock, (char *) msg, len, 0); - if (ret != len) - acm_log(0, "ERROR - failed to send response\n"); - else - ret = 0; - - return ret; -} - -static int acm_msg_length(struct acm_msg *msg) -{ - return (msg->hdr.opcode == ACM_OP_RESOLVE) ? - msg->hdr.length : be16toh(msg->hdr.length); -} - -static void acm_svr_receive(struct acmc_client *client) -{ - struct acm_msg msg; - int ret; - - acm_log(2, "client %d\n", client->index); - ret = recv(client->sock, (char *) &msg, sizeof msg, 0); - if (ret <= 0 || ret != acm_msg_length(&msg)) { - acm_log(2, "client disconnected\n"); - ret = ACM_STATUS_ENOTCONN; - goto out; - } - - if (msg.hdr.version != ACM_VERSION) { - acm_log(0, "ERROR - unsupported version %d\n", msg.hdr.version); - goto out; - } - - switch (msg.hdr.opcode & ACM_OP_MASK) { - case ACM_OP_RESOLVE: - atomic_inc(&counter[ACM_CNTR_RESOLVE]); - ret = acm_svr_resolve(client, &msg); - break; - case ACM_OP_PERF_QUERY: - ret = acm_svr_perf_query(client, &msg); - break; - case ACM_OP_EP_QUERY: - ret = acm_svr_ep_query(client, &msg); - break; - default: - acm_log(0, "ERROR - unknown opcode 0x%x\n", msg.hdr.opcode); - break; - } - -out: - if (ret) - acm_disconnect_client(client); -} - -static int acm_nl_to_addr_data(struct acm_ep_addr_data *ad, - int af_family, uint8_t *addr, size_t addr_len) -{ - if (addr_len > ACM_MAX_ADDRESS) - return EINVAL; - - /* find the ep associated with this address "if any" */ - switch (af_family) { - case AF_INET: - ad->type = ACM_ADDRESS_IP; - break; - case AF_INET6: - ad->type = ACM_ADDRESS_IP6; - break; - default: - return EINVAL; - } - memcpy(&ad->info.addr, addr, addr_len); - return 0; -} - -static void acm_add_ep_ip(char *ifname, struct acm_ep_addr_data *data, char *ip_str) -{ - struct acmc_ep *ep; - struct acmc_device *dev; - uint8_t port_num; - uint16_t pkey; - union ibv_gid sgid; - struct acmc_addr *addr; - - addr = acm_get_ep_address(data); - if (addr) { - acm_log(1, "Address '%s' already available\n", ip_str); - return; - } - - if (acm_if_get_sgid(ifname, &sgid)) - return; - - dev = acm_get_device_from_gid(&sgid, &port_num); - if (!dev) - return; - - if (acm_if_get_pkey(ifname, &pkey)) - return; - - acm_log(0, " %s\n", ip_str); - - ep = acm_find_ep(&dev->port[port_num - 1], pkey); - if (ep) { - if (acm_ep_insert_addr(ep, ip_str, data->info.addr, - sizeof data->info.addr, data->type)) - acm_log(0, "Failed to add '%s' to EP\n", ip_str); - } else { - acm_log(0, "Failed to add '%s' no EP for pkey\n", ip_str); - } -} - -static void acm_rm_ep_ip(struct acm_ep_addr_data *data) -{ - struct acmc_ep *ep; - struct acmc_addr *addr; - - addr = acm_get_ep_address(data); - if (addr) { - ep = container_of(addr->addr.endpoint, struct acmc_ep, endpoint); - acm_format_name(0, log_data, sizeof log_data, - data->type, data->info.addr, sizeof data->info.addr); - acm_log(0, " %s\n", log_data); - acm_mark_addr_invalid(ep, data); - } -} - -static int acm_ipnl_create(void) -{ - struct sockaddr_nl addr; - - if ((ip_mon_socket = socket(PF_NETLINK, SOCK_RAW | SOCK_NONBLOCK, NETLINK_ROUTE)) == -1) { - acm_log(0, "Failed to open NETLINK_ROUTE socket"); - return EIO; - } - - memset(&addr, 0, sizeof(addr)); - addr.nl_family = AF_NETLINK; - addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR; - - if (bind(ip_mon_socket, (struct sockaddr *)&addr, sizeof(addr)) == -1) { - acm_log(0, "Failed to bind NETLINK_ROUTE socket"); - return EIO; - } - - return 0; -} - -static void acm_ip_iter_cb(char *ifname, union ibv_gid *gid, uint16_t pkey, - uint8_t addr_type, uint8_t *addr, size_t addr_len, - char *ip_str, void *ctx) -{ - int ret = EINVAL; - struct acmc_device *dev; - struct acmc_ep *ep; - uint8_t port_num; - char gid_str[INET6_ADDRSTRLEN]; - - dev = acm_get_device_from_gid(gid, &port_num); - if (dev) { - ep = acm_find_ep(&dev->port[port_num - 1], pkey); - if (ep) - ret = acm_ep_insert_addr(ep, ip_str, addr, addr_len, addr_type); - } - - if (ret) { - inet_ntop(AF_INET6, gid->raw, gid_str, sizeof(gid_str)); - acm_log(0, "Failed to add '%s' (gid %s; pkey 0x%x)\n", - ip_str, gid_str, pkey); - } -} - -/* Netlink updates have indicated a failure which means we are no longer in - * sync. This should be a rare condition so we handle this with a "big - * hammer" by clearing and re-reading all the system IP's. - */ -static int resync_system_ips(void) -{ - struct acmc_device *dev; - struct acmc_port *port; - struct acmc_ep *ep; - int i, cnt; - - acm_log(0, "Resyncing all IP's\n"); - - /* mark all IP's invalid */ - list_for_each(&dev_list, dev, entry) { - for (cnt = 0; cnt < dev->port_cnt; cnt++) { - port = &dev->port[cnt]; - - list_for_each(&port->ep_list, ep, entry) { - for (i = 0; i < MAX_EP_ADDR; i++) { - if (ep->addr_info[i].addr.type == ACM_ADDRESS_IP || - ep->addr_info[i].addr.type == ACM_ADDRESS_IP6) - ep->addr_info[i].addr.type = ACM_ADDRESS_INVALID; - } - } - } - } - - return acm_if_iter_sys(acm_ip_iter_cb, NULL); -} - -static void acm_ipnl_handler(void) -{ - int len; - char buffer[NL_MSG_BUF_SIZE]; - struct nlmsghdr *nlh; - char ifname[IFNAMSIZ]; - char ip_str[INET6_ADDRSTRLEN]; - struct acm_ep_addr_data ad; - - while ((len = recv(ip_mon_socket, buffer, NL_MSG_BUF_SIZE, 0)) > 0) { - nlh = (struct nlmsghdr *)buffer; - while ((NLMSG_OK(nlh, len)) && (nlh->nlmsg_type != NLMSG_DONE)) { - struct ifaddrmsg *ifa = (struct ifaddrmsg *) NLMSG_DATA(nlh); - struct ifinfomsg *ifi = (struct ifinfomsg *) NLMSG_DATA(nlh); - struct rtattr *rth = IFA_RTA(ifa); - int rtl = IFA_PAYLOAD(nlh); - - switch (nlh->nlmsg_type) { - case RTM_NEWADDR: - if_indextoname(ifa->ifa_index, ifname); - while (rtl && RTA_OK(rth, rtl)) { - if (rth->rta_type == IFA_LOCAL) { - acm_log(1, "New system address available %s : %s\n", - ifname, inet_ntop(ifa->ifa_family, RTA_DATA(rth), - ip_str, sizeof(ip_str))); - if (!acm_nl_to_addr_data(&ad, ifa->ifa_family, - RTA_DATA(rth), - RTA_PAYLOAD(rth))) { - acm_add_ep_ip(ifname, &ad, ip_str); - } - } - rth = RTA_NEXT(rth, rtl); - } - break; - case RTM_DELADDR: - if_indextoname(ifa->ifa_index, ifname); - while (rtl && RTA_OK(rth, rtl)) { - if (rth->rta_type == IFA_LOCAL) { - acm_log(1, "System address removed %s : %s\n", - ifname, inet_ntop(ifa->ifa_family, RTA_DATA(rth), - ip_str, sizeof(ip_str))); - if (!acm_nl_to_addr_data(&ad, ifa->ifa_family, - RTA_DATA(rth), - RTA_PAYLOAD(rth))) { - acm_rm_ep_ip(&ad); - } - } - rth = RTA_NEXT(rth, rtl); - } - break; - case RTM_NEWLINK: - acm_log(2, "Link added : %s\n", - if_indextoname(ifi->ifi_index, ifname)); - break; - case RTM_DELLINK: - acm_log(2, "Link removed : %s\n", - if_indextoname(ifi->ifi_index, ifname)); - break; - default: - acm_log(2, "unknown netlink message\n"); - break; - } - nlh = NLMSG_NEXT(nlh, len); - } - } - - if (len < 0 && errno == ENOBUFS) { - acm_log(0, "ENOBUFS returned from netlink...\n"); - resync_system_ips(); - } -} - -static int acm_nl_send(int sock, struct acm_msg *msg) -{ - struct sockaddr_nl dst_addr; - struct acm_nl_msg acmnlmsg; - struct acm_nl_msg *orig; - int ret; - int datalen; - - orig = (struct acm_nl_msg *)(uintptr_t)msg->hdr.tid; - - memset(&dst_addr, 0, sizeof(dst_addr)); - dst_addr.nl_family = AF_NETLINK; - dst_addr.nl_groups = (1 << (RDMA_NL_GROUP_LS - 1)); - - memset(&acmnlmsg, 0, sizeof(acmnlmsg)); - acmnlmsg.nlmsg_header.nlmsg_len = NLMSG_HDRLEN; - acmnlmsg.nlmsg_header.nlmsg_pid = getpid(); - acmnlmsg.nlmsg_header.nlmsg_type = orig->nlmsg_header.nlmsg_type; - acmnlmsg.nlmsg_header.nlmsg_seq = orig->nlmsg_header.nlmsg_seq; - - if (msg->hdr.status != ACM_STATUS_SUCCESS) { - acm_log(2, "acm status no success = %d\n", msg->hdr.status); - acmnlmsg.nlmsg_header.nlmsg_flags |= RDMA_NL_LS_F_ERR; - } else { - acm_log(2, "acm status success\n"); - acmnlmsg.nlmsg_header.nlmsg_len += - NLA_ALIGN(sizeof(struct acm_nl_path)); - acmnlmsg.path[0].attr_hdr.nla_type = LS_NLA_TYPE_PATH_RECORD; - acmnlmsg.path[0].attr_hdr.nla_len = sizeof(struct acm_nl_path); - if (orig->resolve_header.path_use == - LS_RESOLVE_PATH_USE_UNIDIRECTIONAL) - acmnlmsg.path[0].rec.flags = IB_PATH_PRIMARY | - IB_PATH_OUTBOUND; - else - acmnlmsg.path[0].rec.flags = IB_PATH_PRIMARY | - IB_PATH_GMP | IB_PATH_BIDIRECTIONAL; - memcpy(acmnlmsg.path[0].rec.path_rec, - &msg->resolve_data[0].info.path, - sizeof(struct ibv_path_record)); - } - - datalen = NLMSG_ALIGN(acmnlmsg.nlmsg_header.nlmsg_len); - ret = sendto(sock, &acmnlmsg, datalen, 0, - (const struct sockaddr *)&dst_addr, - (socklen_t)sizeof(dst_addr)); - if (ret != datalen) { - acm_log(0, "ERROR - sendto = %d errno = %d\n", ret, errno); - ret = -1; - } else { - ret = msg->hdr.length; - } - - free(orig); - - return ret; -} - -#define NLA_LEN(nla) ((nla)->nla_len - NLA_HDRLEN) -#define NLA_DATA(nla) ((char *)(nla) + NLA_HDRLEN) - -static int acm_nl_parse_path_attr(struct nlattr *attr, - struct acm_ep_addr_data *data) -{ - struct ibv_path_record *path; - uint64_t *sid; - struct rdma_nla_ls_gid *gid; - uint8_t *tcl; - uint16_t *pkey; - uint16_t *qos; - uint16_t val; - int ret = 0; - -#define IBV_PATH_RECORD_QOS_MASK 0xfff0 - - path = &data->info.path; - switch (attr->nla_type & RDMA_NLA_TYPE_MASK) { - case LS_NLA_TYPE_SERVICE_ID: - sid = (uint64_t *) NLA_DATA(attr); - if (NLA_LEN(attr) == sizeof(*sid)) { - acm_log(2, "service_id 0x%" PRIx64 "\n", *sid); - path->service_id = htobe64(*sid); - } else { - ret = -1; - } - break; - - case LS_NLA_TYPE_DGID: - gid = (struct rdma_nla_ls_gid *) NLA_DATA(attr); - if (NLA_LEN(attr) == sizeof(gid->gid)) { - acm_format_name(2, log_data, sizeof(log_data), - ACM_ADDRESS_GID, gid->gid, - sizeof(union ibv_gid)); - acm_log(2, "path dgid %s\n", log_data); - memcpy(path->dgid.raw, gid->gid, sizeof(path->dgid)); - data->flags |= ACM_EP_FLAG_DEST; - } else { - ret = -1; - } - break; - - case LS_NLA_TYPE_SGID: - gid = (struct rdma_nla_ls_gid *) NLA_DATA(attr); - if (NLA_LEN(attr) == sizeof(gid->gid)) { - acm_format_name(2, log_data, sizeof(log_data), - ACM_ADDRESS_GID, gid->gid, - sizeof(union ibv_gid)); - acm_log(2, "path sgid %s\n", log_data); - memcpy(path->sgid.raw, gid->gid, sizeof(path->sgid)); - data->flags |= ACM_EP_FLAG_SOURCE; - } else { - ret = -1; - } - break; - - case LS_NLA_TYPE_TCLASS: - tcl = (uint8_t *) NLA_DATA(attr); - if (NLA_LEN(attr) == sizeof(*tcl)) { - acm_log(2, "tclass 0x%x\n", *tcl); - path->tclass = *tcl; - } else { - ret = -1; - } - break; - - case LS_NLA_TYPE_PKEY: - pkey = (uint16_t *) NLA_DATA(attr); - if (NLA_LEN(attr) == sizeof(*pkey)) { - acm_log(2, "pkey 0x%x\n", *pkey); - path->pkey = htobe16(*pkey); - } else { - ret = -1; - } - break; - - case LS_NLA_TYPE_QOS_CLASS: - qos = (uint16_t *) NLA_DATA(attr); - if (NLA_LEN(attr) == sizeof(*qos)) { - acm_log(2, "qos_class 0x%x\n", *qos); - val = be16toh(path->qosclass_sl); - val &= ~IBV_PATH_RECORD_QOS_MASK; - val |= (*qos & IBV_PATH_RECORD_QOS_MASK); - path->qosclass_sl = htobe16(val); - } else { - ret = -1; - } - break; - - default: - acm_log(1, "WARN: unknown attr %x\n", attr->nla_type); - /* We can not ignore a mandatory attribute */ - if (attr->nla_type & RDMA_NLA_F_MANDATORY) - ret = -1; - break; - } - - return ret; -} - -static void acm_nl_process_invalid_request(struct acmc_client *client, - struct acm_nl_msg *acmnlmsg) -{ - struct acm_msg msg; - - memset(&msg, 0, sizeof(msg)); - msg.hdr.opcode = ACM_OP_RESOLVE; - msg.hdr.version = ACM_VERSION; - msg.hdr.length = ACM_MSG_HDR_LENGTH; - msg.hdr.status = ACM_STATUS_EINVAL; - msg.hdr.tid = (uintptr_t) acmnlmsg; - - acm_nl_send(client->sock, &msg); -} - -static void acm_nl_process_resolve(struct acmc_client *client, - struct acm_nl_msg *acmnlmsg) -{ - struct acm_msg msg; - struct nlattr *attr; - int payload_len; - int resolve_hdr_len; - int rem; - int total_attr_len; - int status; - unsigned char *data; - - memset(&msg, 0, sizeof(msg)); - msg.hdr.opcode = ACM_OP_RESOLVE; - msg.hdr.version = ACM_VERSION; - msg.hdr.length = ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH; - msg.hdr.status = ACM_STATUS_SUCCESS; - msg.hdr.tid = (uintptr_t) acmnlmsg; - msg.resolve_data[0].type = ACM_EP_INFO_PATH; - - /* We support only one pathrecord */ - acm_log(2, "path use 0x%x\n", acmnlmsg->resolve_header.path_use); - if (acmnlmsg->resolve_header.path_use == - LS_RESOLVE_PATH_USE_UNIDIRECTIONAL) - msg.resolve_data[0].info.path.reversible_numpath = 1; - else - msg.resolve_data[0].info.path.reversible_numpath = - IBV_PATH_RECORD_REVERSIBLE | 1; - - data = (unsigned char *) &acmnlmsg->nlmsg_header + NLMSG_HDRLEN; - resolve_hdr_len = NLMSG_ALIGN(sizeof(struct rdma_ls_resolve_header)); - attr = (struct nlattr *) (data + resolve_hdr_len); - payload_len = acmnlmsg->nlmsg_header.nlmsg_len - NLMSG_HDRLEN - - resolve_hdr_len; - rem = payload_len; - while (1) { - if (rem < (int) sizeof(*attr) || - attr->nla_len < sizeof(*attr) || - attr->nla_len > rem) - break; - - status = acm_nl_parse_path_attr(attr, &msg.resolve_data[0]); - if (status) { - acm_nl_process_invalid_request(client, acmnlmsg); - return; - } - - /* Next attribute */ - total_attr_len = NLA_ALIGN(attr->nla_len); - rem -= total_attr_len; - attr = (struct nlattr *) ((char *) attr + total_attr_len); - } - - atomic_inc(&counter[ACM_CNTR_RESOLVE]); - acm_svr_resolve(client, &msg); -} - -static int acm_nl_is_valid_resolve_request(struct acm_nl_msg *acmnlmsg) -{ - int payload_len; - - payload_len = acmnlmsg->nlmsg_header.nlmsg_len - NLMSG_HDRLEN; - if (payload_len < (sizeof(struct rdma_ls_resolve_header) + - sizeof(struct nlattr))) - return 0; - - return 1; -} - -static void acm_nl_receive(struct acmc_client *client) -{ - struct acm_nl_msg *acmnlmsg; - int datalen = sizeof(*acmnlmsg); - int ret; - uint16_t client_inx, op; - - acmnlmsg = calloc(1, sizeof(*acmnlmsg)); - if (!acmnlmsg) { - acm_log(0, "Out of memory for recving nl msg.\n"); - return; - } - ret = recv(client->sock, acmnlmsg, datalen, 0); - if (!NLMSG_OK(&acmnlmsg->nlmsg_header, ret)) { - acm_log(0, "Netlink receive error: %d.\n", ret); - goto rcv_cleanup; - } - - acm_log(2, "nlmsg: len %d type 0x%x flags 0x%x seq %d pid %d\n", - acmnlmsg->nlmsg_header.nlmsg_len, - acmnlmsg->nlmsg_header.nlmsg_type, - acmnlmsg->nlmsg_header.nlmsg_flags, - acmnlmsg->nlmsg_header.nlmsg_seq, - acmnlmsg->nlmsg_header.nlmsg_pid); - - /* Currently we handle only request from the local service client */ - client_inx = RDMA_NL_GET_CLIENT(acmnlmsg->nlmsg_header.nlmsg_type); - op = RDMA_NL_GET_OP(acmnlmsg->nlmsg_header.nlmsg_type); - if (client_inx != RDMA_NL_LS) - goto rcv_cleanup; - - switch (op) { - case RDMA_NL_LS_OP_RESOLVE: - if (acm_nl_is_valid_resolve_request(acmnlmsg)) - acm_nl_process_resolve(client, acmnlmsg); - else - acm_nl_process_invalid_request(client, acmnlmsg); - break; - default: - /* Not supported*/ - acm_log(1, "WARN - invalid opcode %x\n", op); - acm_nl_process_invalid_request(client, acmnlmsg); - break; - } - - return; -rcv_cleanup: - free(acmnlmsg); -} - -static int acm_init_nl(void) -{ - struct sockaddr_nl src_addr; - int ret; - int nl_rcv_socket; - - nl_rcv_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_RDMA); - if (nl_rcv_socket == -1) { - acm_log(0, "ERROR - unable to allocate netlink recv socket\n"); - return errno; - } - - memset(&src_addr, 0, sizeof(src_addr)); - src_addr.nl_family = AF_NETLINK; - src_addr.nl_pid = getpid(); - src_addr.nl_groups = (1 << (RDMA_NL_GROUP_LS - 1)); - - ret = bind(nl_rcv_socket, (struct sockaddr *)&src_addr, - sizeof(src_addr)); - if (ret == -1) { - acm_log(0, "ERROR - unable to bind netlink socket\n"); - close(nl_rcv_socket); - return errno; - } - - /* init nl client structure */ - client_array[NL_CLIENT_INDEX].sock = nl_rcv_socket; - return 0; -} - -static void acm_server(bool systemd) -{ - fd_set readfds; - int i, n, ret; - struct acmc_device *dev; - - acm_log(0, "started\n"); - acm_init_server(); - - client_array[NL_CLIENT_INDEX].sock = -1; - listen_socket = -1; - if (systemd) { - ret = acm_listen_systemd(); - if (ret) { - acm_log(0, "ERROR - systemd server listen failed\n"); - return; - } - } - - if (listen_socket == -1) { - ret = acm_listen(); - if (ret) { - acm_log(0, "ERROR - server listen failed\n"); - return; - } - } - - if (client_array[NL_CLIENT_INDEX].sock == -1) { - ret = acm_init_nl(); - if (ret) - acm_log(1, "Warn - Netlink init failed\n"); - } - - if (systemd) - sd_notify(0, "READY=1"); - - while (1) { - n = (int) listen_socket; - FD_ZERO(&readfds); - FD_SET(listen_socket, &readfds); - n = max(n, (int) ip_mon_socket); - FD_SET(ip_mon_socket, &readfds); - - for (i = 0; i < FD_SETSIZE - 1; i++) { - if (client_array[i].sock != -1) { - FD_SET(client_array[i].sock, &readfds); - n = max(n, (int) client_array[i].sock); - } - } - - list_for_each(&dev_list, dev, entry) { - FD_SET(dev->device.verbs->async_fd, &readfds); - n = max(n, (int) dev->device.verbs->async_fd); - } - - ret = select(n + 1, &readfds, NULL, NULL, NULL); - if (ret == -1) { - acm_log(0, "ERROR - server select error\n"); - continue; - } - - if (FD_ISSET(listen_socket, &readfds)) - acm_svr_accept(); - - if (FD_ISSET(ip_mon_socket, &readfds)) - acm_ipnl_handler(); - - for (i = 0; i < FD_SETSIZE - 1; i++) { - if (client_array[i].sock != -1 && - FD_ISSET(client_array[i].sock, &readfds)) { - acm_log(2, "receiving from client %d\n", i); - if (i == NL_CLIENT_INDEX) - acm_nl_receive(&client_array[i]); - else - acm_svr_receive(&client_array[i]); - } - } - - list_for_each(&dev_list, dev, entry) { - if (FD_ISSET(dev->device.verbs->async_fd, &readfds)) { - acm_log(2, "handling event from %s\n", - dev->device.verbs->device->name); - acm_event_handler(dev); - } - } - } -} - -enum ibv_rate acm_get_rate(uint8_t width, uint8_t speed) -{ - switch (width) { - case 1: - switch (speed) { - case 1: return IBV_RATE_2_5_GBPS; - case 2: return IBV_RATE_5_GBPS; - case 4: return IBV_RATE_10_GBPS; - default: return IBV_RATE_MAX; - } - case 2: - switch (speed) { - case 1: return IBV_RATE_10_GBPS; - case 2: return IBV_RATE_20_GBPS; - case 4: return IBV_RATE_40_GBPS; - default: return IBV_RATE_MAX; - } - case 4: - switch (speed) { - case 1: return IBV_RATE_20_GBPS; - case 2: return IBV_RATE_40_GBPS; - case 4: return IBV_RATE_80_GBPS; - default: return IBV_RATE_MAX; - } - case 8: - switch (speed) { - case 1: return IBV_RATE_30_GBPS; - case 2: return IBV_RATE_60_GBPS; - case 4: return IBV_RATE_120_GBPS; - default: return IBV_RATE_MAX; - } - default: - acm_log(0, "ERROR - unknown link width 0x%x\n", width); - return IBV_RATE_MAX; - } -} - -enum ibv_mtu acm_convert_mtu(int mtu) -{ - switch (mtu) { - case 256: return IBV_MTU_256; - case 512: return IBV_MTU_512; - case 1024: return IBV_MTU_1024; - case 2048: return IBV_MTU_2048; - case 4096: return IBV_MTU_4096; - default: return IBV_MTU_2048; - } -} - -enum ibv_rate acm_convert_rate(int rate) -{ - switch (rate) { - case 2: return IBV_RATE_2_5_GBPS; - case 5: return IBV_RATE_5_GBPS; - case 10: return IBV_RATE_10_GBPS; - case 20: return IBV_RATE_20_GBPS; - case 30: return IBV_RATE_30_GBPS; - case 40: return IBV_RATE_40_GBPS; - case 60: return IBV_RATE_60_GBPS; - case 80: return IBV_RATE_80_GBPS; - case 120: return IBV_RATE_120_GBPS; - default: return IBV_RATE_10_GBPS; - } -} - -static FILE *acm_open_addr_file(void) -{ - FILE *f; - - if ((f = fopen(addr_file, "r"))) - return f; - - acm_log(0, "notice - generating %s file\n", addr_file); - if (!(f = popen(acme, "r"))) { - acm_log(0, "ERROR - cannot generate %s\n", addr_file); - return NULL; - } - pclose(f); - return fopen(addr_file, "r"); -} - -static int -acm_ep_insert_addr(struct acmc_ep *ep, const char *name, uint8_t *addr, - size_t addr_len, uint8_t addr_type) -{ - int i, ret = -1; - uint8_t tmp[ACM_MAX_ADDRESS]; - - if (addr_len > ACM_MAX_ADDRESS) - return EINVAL; - - memset(tmp, 0, sizeof tmp); - memcpy(tmp, addr, addr_len); - - if (!acm_addr_lookup(&ep->endpoint, addr, addr_type)) { - for (i = 0; (i < MAX_EP_ADDR) && - (ep->addr_info[i].addr.type != ACM_ADDRESS_INVALID); i++) - ; - if (i == MAX_EP_ADDR) { - ret = ENOMEM; - goto out; - } - - /* Open the provider endpoint only if at least a name or - address is found */ - if (!ep->prov_ep_context) { - ret = ep->port->prov->open_endpoint(&ep->endpoint, - ep->port->prov_port_context, - &ep->prov_ep_context); - if (ret) { - acm_log(0, "Error: failed to open prov ep\n"); - goto out; - } - } - ep->addr_info[i].addr.type = addr_type; - strncpy(ep->addr_info[i].string_buf, name, ACM_MAX_ADDRESS); - memcpy(ep->addr_info[i].addr.info.addr, tmp, ACM_MAX_ADDRESS); - ret = ep->port->prov->add_address(&ep->addr_info[i].addr, - ep->prov_ep_context, - &ep->addr_info[i].prov_addr_context); - if (ret) { - acm_log(0, "Error: failed to add addr to provider\n"); - ep->addr_info[i].addr.type = ACM_ADDRESS_INVALID; - goto out; - } - } - ret = 0; -out: - return ret; -} - -static struct acmc_device * -acm_get_device_from_gid(union ibv_gid *sgid, uint8_t *port) -{ - struct acmc_device *dev; - int i; - - list_for_each(&dev_list, dev, entry) { - for (*port = 1; *port <= dev->port_cnt; (*port)++) { - - for (i = 0; i < dev->port[*port - 1].gid_cnt; i++) { - - if (!memcmp(sgid->raw, - dev->port[*port - 1].gid_tbl[i].raw, - sizeof(*sgid))) - return dev; - } - } - } - return NULL; -} - -static void acm_ep_ip_iter_cb(char *ifname, union ibv_gid *gid, uint16_t pkey, - uint8_t addr_type, uint8_t *addr, size_t addr_len, - char *ip_str, void *ctx) -{ - uint8_t port_num; - struct acmc_device *dev; - struct acmc_ep *ep = ctx; - - dev = acm_get_device_from_gid(gid, &port_num); - if (dev && ep->port->dev == dev - && ep->port->port.port_num == port_num && ep->endpoint.pkey == pkey) { - if (!acm_ep_insert_addr(ep, ip_str, addr, addr_len, addr_type)) { - acm_log(0, "Added %s %s %d 0x%x from %s\n", ip_str, - dev->device.verbs->device->name, port_num, pkey, - ifname); - } - } -} - -static int acm_get_system_ips(struct acmc_ep *ep) -{ - return acm_if_iter_sys(acm_ep_ip_iter_cb, ep); -} - -static int acm_assign_ep_names(struct acmc_ep *ep) -{ - FILE *faddr; - char *dev_name; - char s[120]; - char dev[32], name[ACM_MAX_ADDRESS], pkey_str[8]; - uint16_t pkey; - uint8_t addr[ACM_MAX_ADDRESS], type; - int port; - size_t addr_len; - - dev_name = ep->port->dev->device.verbs->device->name; - acm_log(1, "device %s, port %d, pkey 0x%x\n", - dev_name, ep->port->port.port_num, ep->endpoint.pkey); - - acm_get_system_ips(ep); - - if (!(faddr = acm_open_addr_file())) { - acm_log(0, "ERROR - address file not found\n"); - goto out; - } - - while (fgets(s, sizeof s, faddr)) { - if (s[0] == '#') - continue; - - if (sscanf(s, "%46s%32s%d%8s", name, dev, &port, pkey_str) != 4) - continue; - - acm_log(2, "%s", s); - if (inet_pton(AF_INET, name, addr) > 0) { - if (!support_ips_in_addr_cfg) { - acm_log(0, "ERROR - IP's are not configured to be read from ibacm_addr.cfg\n"); - continue; - } - type = ACM_ADDRESS_IP; - addr_len = 4; - } else if (inet_pton(AF_INET6, name, addr) > 0) { - if (!support_ips_in_addr_cfg) { - acm_log(0, "ERROR - IP's are not configured to be read from ibacm_addr.cfg\n"); - continue; - } - type = ACM_ADDRESS_IP6; - addr_len = 16; - } else { - type = ACM_ADDRESS_NAME; - addr_len = strlen(name); - memcpy(addr, name, addr_len); - } - - if (strcasecmp(pkey_str, "default")) { - if (sscanf(pkey_str, "%hx", &pkey) != 1) { - acm_log(0, "ERROR - bad pkey format %s\n", pkey_str); - continue; - } - } else { - pkey = ep->port->def_acm_pkey; - } - - if (!strcasecmp(dev_name, dev) && - (ep->port->port.port_num == (uint8_t) port) && - (ep->endpoint.pkey == pkey)) { - acm_log(1, "assigning %s\n", name); - if (acm_ep_insert_addr(ep, name, addr, addr_len, type)) { - acm_log(1, "maximum number of names assigned to EP\n"); - break; - } - } - } - fclose(faddr); - -out: - return (ep->addr_info[0].addr.type == ACM_ADDRESS_INVALID); -} - -static struct acmc_ep *acm_find_ep(struct acmc_port *port, uint16_t pkey) -{ - struct acmc_ep *ep, *res = NULL; - - acm_log(2, "pkey 0x%x\n", pkey); - - list_for_each(&port->ep_list, ep, entry) { - if (ep->endpoint.pkey == pkey) { - res = ep; - break; - } - } - return res; -} - -static void acm_ep_down(struct acmc_ep *ep) -{ - int i; - - acm_log(1, "%s %d pkey 0x%04x\n", - ep->port->dev->device.verbs->device->name, - ep->port->port.port_num, ep->endpoint.pkey); - for (i = 0; i < MAX_EP_ADDR; i++) { - if (ep->addr_info[i].addr.type && - ep->addr_info[i].prov_addr_context) - ep->port->prov->remove_address(ep->addr_info[i]. - prov_addr_context); - } - - if (ep->prov_ep_context) - ep->port->prov->close_endpoint(ep->prov_ep_context); - - free(ep); -} - -static struct acmc_ep * -acm_alloc_ep(struct acmc_port *port, uint16_t pkey) -{ - struct acmc_ep *ep; - int i; - - acm_log(1, "\n"); - ep = calloc(1, sizeof *ep); - if (!ep) - return NULL; - - ep->port = port; - ep->endpoint.port = &port->port; - ep->endpoint.pkey = pkey; - - for (i = 0; i < MAX_EP_ADDR; i++) { - ep->addr_info[i].addr.endpoint = &ep->endpoint; - ep->addr_info[i].addr.id_string = ep->addr_info[i].string_buf; - } - - return ep; -} - -static void acm_ep_up(struct acmc_port *port, uint16_t pkey) -{ - struct acmc_ep *ep; - int ret; - - acm_log(1, "\n"); - if (acm_find_ep(port, pkey)) { - acm_log(2, "endpoint for pkey 0x%x already exists\n", pkey); - return; - } - - acm_log(2, "creating endpoint for pkey 0x%x\n", pkey); - ep = acm_alloc_ep(port, pkey); - if (!ep) - return; - - ret = acm_assign_ep_names(ep); - if (ret) { - acm_log(0, "ERROR - unable to assign EP name for pkey 0x%x\n", pkey); - goto ep_close; - } - - list_add(&port->ep_list, &ep->entry); - return; - -ep_close: - if (ep->prov_ep_context) - port->prov->close_endpoint(ep->prov_ep_context); - - free(ep); -} - -static void acm_assign_provider(struct acmc_port *port) -{ - struct acmc_prov *prov; - struct acmc_subnet *subnet; - - acm_log(2, "port %s/%d\n", port->port.dev->verbs->device->name, - port->port.port_num); - list_for_each(&provider_list, prov, entry) { - list_for_each(&prov->subnet_list, subnet, entry) { - if (subnet->subnet_prefix == - port->gid_tbl[0].global.subnet_prefix) { - acm_log(2, "Found provider %s for port %s/%d\n", - prov->prov->name, - port->port.dev->verbs->device->name, - port->port.port_num); - port->prov = prov->prov; - return; - } - } - } - - /* If no provider is found, assign the default provider*/ - if (!port->prov) { - acm_log(2, "No prov found, assign default prov %s to %s/%d\n", - def_provider ? def_provider->prov->name: "NULL", - port->port.dev->verbs->device->name, - port->port.port_num); - port->prov = def_provider ? def_provider->prov : NULL; - } -} - -static void acm_port_get_gid_tbl(struct acmc_port *port) -{ - union ibv_gid gid; - int i, j, ret; - - for (i = 0;; i++) { - ret = ibv_query_gid(port->port.dev->verbs, port->port.port_num, - i, &gid); - if (ret || !gid.global.interface_id) - break; - } - - if (i > 0) { - port->gid_tbl = calloc(i, sizeof(union ibv_gid)); - if (!port->gid_tbl) { - acm_log(0, "Error: failed to allocate gid table\n"); - port->gid_cnt = 0; - return; - } - - for (j = 0; j < i; j++) { - ret = ibv_query_gid(port->port.dev->verbs, - port->port.port_num, j, - &port->gid_tbl[j]); - if (ret || !port->gid_tbl[j].global.interface_id) - break; - acm_log(2, "guid %d: 0x%" PRIx64 " %" PRIx64 "\n", j, - be64toh(port->gid_tbl[j].global.subnet_prefix), - be64toh(port->gid_tbl[j].global.interface_id)); - } - port->gid_cnt = j; - } - acm_log(2, "port %d gid_cnt %d\n", port->port.port_num, - port->gid_cnt); -} - -static void acm_port_up(struct acmc_port *port) -{ - struct ibv_port_attr attr; - uint16_t pkey; - __be16 pkey_be; - int i, ret; - struct acmc_prov_context *dev_ctx; - int index = -1; - uint16_t first_pkey = 0; - - acm_log(1, "%s %d\n", port->dev->device.verbs->device->name, - port->port.port_num); - ret = ibv_query_port(port->dev->device.verbs, port->port.port_num, - &attr); - if (ret) { - acm_log(0, "ERROR - unable to get port state\n"); - return; - } - if (attr.state != IBV_PORT_ACTIVE) { - acm_log(1, "port not active\n"); - return; - } - - acm_port_get_gid_tbl(port); - port->lid = attr.lid; - port->lid_mask = 0xffff - ((1 << attr.lmc) - 1); - port->sa_addr.lid = htobe16(attr.sm_lid); - port->sa_addr.sl = attr.sm_sl; - port->state = IBV_PORT_ACTIVE; - acm_assign_provider(port); - if (!port->prov) { - acm_log(1, "no provider assigned to port\n"); - return; - } - dev_ctx = acm_acquire_prov_context(&port->dev->prov_dev_context_list, - port->prov); - if (!dev_ctx) { - acm_log(0, "Error -- failed to acquire dev context\n"); - return; - } - - if (atomic_get(&dev_ctx->refcnt) == 1) { - if (port->prov->open_device(&port->dev->device, &dev_ctx->context)) { - acm_log(0, "Error -- failed to open the prov device\n"); - goto err1; - } - } - - if (port->prov->open_port(&port->port, dev_ctx->context, - &port->prov_port_context)) { - acm_log(0, "Error -- failed to open the prov port\n"); - goto err1; - } - - /* Determine the default pkey for SA access first. - * Order of preference: 0xffff, 0x7fff - * Use the first pkey as the default pkey for parsing address file. - */ - for (i = 0; i < attr.pkey_tbl_len; i++) { - ret = ibv_query_pkey(port->dev->device.verbs, - port->port.port_num, i, &pkey_be); - if (ret) - continue; - pkey = be16toh(pkey_be); - if (i == 0) - first_pkey = pkey; - if (pkey == 0xffff) { - index = i; - break; - } - else if (pkey == 0x7fff) { - index = i; - } - } - port->sa_pkey_index = index < 0 ? 0 : index; - port->def_acm_pkey = first_pkey; - - for (i = 0; i < attr.pkey_tbl_len; i++) { - ret = ibv_query_pkey(port->dev->device.verbs, - port->port.port_num, i, &pkey_be); - if (ret) - continue; - pkey = be16toh(pkey_be); - if (!(pkey & 0x7fff)) - continue; - - acm_ep_up(port, pkey); - } - return; -err1: - acm_release_prov_context(dev_ctx); -} - -static void acm_shutdown_port(struct acmc_port *port) -{ - struct acmc_ep *ep; - struct acmc_prov_context *dev_ctx; - - while ((ep = list_pop(&port->ep_list, struct acmc_ep, entry))) - acm_ep_down(ep); - - if (port->prov_port_context) { - port->prov->close_port(port->prov_port_context); - port->prov_port_context = NULL; - dev_ctx = acm_get_prov_context(&port->dev->prov_dev_context_list, - port->prov); - if (dev_ctx) { - if (atomic_get(&dev_ctx->refcnt) == 1) - port->prov->close_device(dev_ctx->context); - acm_release_prov_context(dev_ctx); - } - } - port->prov = NULL; - if (port->gid_tbl) { - free(port->gid_tbl); - port->gid_tbl = NULL; - } - port->gid_cnt = 0; -} - -static void acm_port_down(struct acmc_port *port) -{ - struct ibv_port_attr attr; - int ret; - - acm_log(1, "%s %d\n", port->port.dev->verbs->device->name, port->port.port_num); - ret = ibv_query_port(port->port.dev->verbs, port->port.port_num, &attr); - if (!ret && attr.state == IBV_PORT_ACTIVE) { - acm_log(1, "port active\n"); - return; - } - - port->state = attr.state; - acm_shutdown_port(port); - - acm_log(1, "%s %d is down\n", port->dev->device.verbs->device->name, - port->port.port_num); -} - -static void acm_port_change(struct acmc_port *port) -{ - struct ibv_port_attr attr; - int ret; - - acm_log(1, "%s %d\n", port->port.dev->verbs->device->name, port->port.port_num); - ret = ibv_query_port(port->port.dev->verbs, port->port.port_num, &attr); - if (ret || attr.state != IBV_PORT_ACTIVE) { - acm_log(1, "port not active: don't care\n"); - return; - } - - port->state = attr.state; - acm_shutdown_port(port); - acm_port_up(port); -} - -static void acm_event_handler(struct acmc_device *dev) -{ - struct ibv_async_event event; - int i, ret; - - ret = ibv_get_async_event(dev->device.verbs, &event); - if (ret) - return; - - acm_log(2, "processing async event %s for %s\n", - ibv_event_type_str(event.event_type), - dev->device.verbs->device->name); - i = event.element.port_num - 1; - - switch (event.event_type) { - case IBV_EVENT_PORT_ACTIVE: - if (dev->port[i].state != IBV_PORT_ACTIVE) - acm_port_up(&dev->port[i]); - break; - case IBV_EVENT_PORT_ERR: - if (dev->port[i].state == IBV_PORT_ACTIVE) - acm_port_down(&dev->port[i]); - break; - case IBV_EVENT_CLIENT_REREGISTER: - if ((dev->port[i].state == IBV_PORT_ACTIVE) && - dev->port[i].prov_port_context) { - dev->port[i].prov->handle_event(dev->port[i].prov_port_context, - event.event_type); - acm_log(1, "%s %d has reregistered\n", - dev->device.verbs->device->name, i + 1); - } - break; - case IBV_EVENT_LID_CHANGE: - case IBV_EVENT_GID_CHANGE: - case IBV_EVENT_PKEY_CHANGE: - acm_port_change(&dev->port[i]); - break; - default: - break; - } - - ibv_ack_async_event(&event); -} - -static void acm_activate_devices(void) -{ - struct acmc_device *dev; - int i; - - acm_log(1, "\n"); - list_for_each(&dev_list, dev, entry) { - for (i = 0; i < dev->port_cnt; i++) { - acm_port_up(&dev->port[i]); - } - } -} - -static void -acm_open_port(struct acmc_port *port, struct acmc_device *dev, uint8_t port_num) -{ - acm_log(1, "%s %d\n", dev->device.verbs->device->name, port_num); - port->dev = dev; - port->port.dev = &dev->device; - port->port.port_num = port_num; - pthread_mutex_init(&port->lock, NULL); - list_head_init(&port->ep_list); - list_head_init(&port->sa_pending); - list_head_init(&port->sa_wait); - port->sa_credits = sa.depth; - port->sa_addr.qpn = htobe32(1); - port->sa_addr.qkey = htobe32(ACM_QKEY); - - port->mad_portid = umad_open_port(dev->device.verbs->device->name, port_num); - if (port->mad_portid < 0) - acm_log(0, "ERROR - unable to open MAD port\n"); - - port->mad_agentid = umad_register(port->mad_portid, - IB_MGMT_CLASS_SA, 1, 1, NULL); - if (port->mad_agentid < 0) { - umad_close_port(port->mad_portid); - acm_log(0, "ERROR - unable to register MAD client\n"); - } - - port->prov = NULL; - port->state = IBV_PORT_DOWN; -} - -static void acm_open_dev(struct ibv_device *ibdev) -{ - struct acmc_device *dev; - struct ibv_device_attr attr; - struct ibv_context *verbs; - size_t size; - int i, ret; - - acm_log(1, "%s\n", ibdev->name); - verbs = ibv_open_device(ibdev); - if (verbs == NULL) { - acm_log(0, "ERROR - opening device %s\n", ibdev->name); - return; - } - - ret = ibv_query_device(verbs, &attr); - if (ret) { - acm_log(0, "ERROR - ibv_query_device (%d) %s\n", ret, ibdev->name); - goto err1; - } - - size = sizeof(*dev) + sizeof(struct acmc_port) * attr.phys_port_cnt; - dev = (struct acmc_device *) calloc(1, size); - if (!dev) - goto err1; - - dev->device.verbs = verbs; - dev->device.dev_guid = ibv_get_device_guid(ibdev); - dev->port_cnt = attr.phys_port_cnt; - list_head_init(&dev->prov_dev_context_list); - - for (i = 0; i < dev->port_cnt; i++) { - acm_open_port(&dev->port[i], dev, i + 1); - } - - list_add(&dev_list, &dev->entry); - - acm_log(1, "%s opened\n", ibdev->name); - return; - -err1: - ibv_close_device(verbs); -} - -static int acm_open_devices(void) -{ - struct ibv_device **ibdev; - int dev_cnt; - int i; - - acm_log(1, "\n"); - ibdev = ibv_get_device_list(&dev_cnt); - if (!ibdev) { - acm_log(0, "ERROR - unable to get device list\n"); - return -1; - } - - for (i = 0; i < dev_cnt; i++) - acm_open_dev(ibdev[i]); - - ibv_free_device_list(ibdev); - if (list_empty(&dev_list)) { - acm_log(0, "ERROR - no devices\n"); - return -1; - } - - return 0; -} - -static void acm_load_prov_config(void) -{ - FILE *fd; - char s[128]; - char *p, *ptr; - char prov_name[ACM_PROV_NAME_SIZE]; - uint64_t prefix; - struct acmc_prov *prov; - struct acmc_subnet *subnet; - - if (!(fd = fopen(opts_file, "r"))) - return; - - while (fgets(s, sizeof s, fd)) { - if (s[0] == '#') - continue; - - /* Ignore blank lines */ - if (!(p = strtok_r(s, " \n", &ptr))) - continue; - - if (strncasecmp(p, "provider", sizeof("provider") - 1)) - continue; - - p = strtok_r(NULL, " ", &ptr); - if (!p) - continue; - - strncpy(prov_name, p, sizeof(prov_name)); - prov_name[sizeof(prov_name) -1] = '\0'; - - p = strtok_r(NULL, " ", &ptr); - if (!p) - continue; - if (!strncasecmp(p, "default", sizeof("default") - 1)) { - strncpy(def_prov_name, prov_name, sizeof(def_prov_name)); - def_prov_name[sizeof(def_prov_name) -1] = '\0'; - acm_log(2, "default provider: %s\n", def_prov_name); - continue; - } - prefix = strtoull(p, NULL, 0); - acm_log(2, "provider %s subnet_prefix 0x%" PRIx64 "\n", - prov_name, prefix); - - list_for_each(&provider_list, prov, entry) { - if (!strcasecmp(prov->prov->name, prov_name)) { - subnet = calloc(1, sizeof (*subnet)); - if (!subnet) { - acm_log(0, "Error: out of memory\n"); - return; - } - subnet->subnet_prefix = htobe64(prefix); - list_add_after(&provider_list, &prov->entry, - &subnet->entry); - } - } - } - - fclose(fd); - - list_for_each(&provider_list, prov, entry) { - if (!strcasecmp(prov->prov->name, def_prov_name)) { - def_provider = prov; - break; - } - } -} - -static int acm_open_providers(void) -{ - DIR *shlib_dir; - struct dirent *dent; - char file_name[256]; - struct stat buf; - void *handle; - struct acmc_prov *prov; - struct acm_provider *provider; - uint32_t version; - char *err_str; - int (*query)(struct acm_provider **, uint32_t *); - - acm_log(1, "\n"); - shlib_dir = opendir(prov_lib_path); - if (!shlib_dir) { - acm_log(0, "ERROR - could not open provider lib dir: %s\n", - prov_lib_path); - return -1; - } - - while ((dent = readdir(shlib_dir))) { - if (!strstr(dent->d_name, ".so")) - continue; - - if (!check_snprintf(file_name, sizeof(file_name), "%s/%s", - prov_lib_path, dent->d_name)) - continue; - - if (lstat(file_name, &buf)) { - acm_log(0, "Error - could not stat: %s\n", file_name); - continue; - } - if (!S_ISREG(buf.st_mode)) - continue; - - acm_log(2, "Loading provider %s...\n", file_name); - if (!(handle = dlopen(file_name, RTLD_LAZY))) { - acm_log(0, "Error - could not load provider %s (%s)\n", - file_name, dlerror()); - continue; - } - - query = dlsym(handle, "provider_query"); - if ((err_str = dlerror()) != NULL) { - acm_log(0, "Error -provider_query not found in %s (%s)\n", - file_name, err_str); - dlclose(handle); - continue; - } - - if (query(&provider, &version)) { - acm_log(0, "Error - provider_query failed to %s\n", file_name); - dlclose(handle); - continue; - } - - if (version != ACM_PROV_VERSION || - provider->size != sizeof(struct acm_provider)) { - acm_log(0, "Error -unmatched provider version 0x%08x (size %zd)" - " core 0x%08x (size %zd)\n", version, provider->size, - ACM_PROV_VERSION, sizeof(struct acm_provider)); - dlclose(handle); - continue; - } - - acm_log(1, "Provider %s (%s) loaded\n", provider->name, file_name); - - prov = calloc(1, sizeof(*prov)); - if (!prov) { - acm_log(0, "Error -failed to allocate provider %s\n", file_name); - dlclose(handle); - continue; - } - - prov->prov = provider; - prov->handle = handle; - list_head_init(&prov->subnet_list); - list_add_tail(&provider_list, &prov->entry); - if (!strcasecmp(provider->name, def_prov_name)) - def_provider = prov; - } - - closedir(shlib_dir); - acm_load_prov_config(); - return 0; -} - -static void acm_close_providers(void) -{ - struct acmc_prov *prov; - struct acmc_subnet *subnet; - - acm_log(1, "\n"); - def_provider = NULL; - - while ((prov = list_pop(&provider_list, struct acmc_prov, entry))) { - while ((subnet = list_pop(&prov->subnet_list, - struct acmc_subnet, entry))) - free(subnet); - dlclose(prov->handle); - free(prov); - } -} - -static int acmc_init_sa_fds(void) -{ - struct acmc_device *dev; - int ret, p, i = 0; - - list_for_each(&dev_list, dev, entry) - sa.nfds += dev->port_cnt; - - sa.fds = calloc(sa.nfds, sizeof(*sa.fds)); - sa.ports = calloc(sa.nfds, sizeof(*sa.ports)); - if (!sa.fds || !sa.ports) - return -ENOMEM; - - list_for_each(&dev_list, dev, entry) { - for (p = 0; p < dev->port_cnt; p++) { - sa.fds[i].fd = umad_get_fd(dev->port[p].mad_portid); - sa.fds[i].events = POLLIN; - ret = set_fd_nonblock(sa.fds[i].fd, true); - if (ret) - acm_log(0, "WARNING - umad fd is blocking\n"); - - sa.ports[i++] = &dev->port[p]; - } - } - - return 0; -} - -struct acm_sa_mad * -acm_alloc_sa_mad(const struct acm_endpoint *endpoint, void *context, - void (*handler)(struct acm_sa_mad *)) -{ - struct acmc_sa_req *req; - - if (!endpoint) { - acm_log(0, "Error: NULL endpoint\n"); - return NULL; - } - req = calloc(1, sizeof (*req)); - if (!req) { - acm_log(0, "Error: failed to allocate sa request\n"); - return NULL; - } - - req->ep = container_of(endpoint, struct acmc_ep, endpoint); - req->mad.context = context; - req->resp_handler = handler; - - acm_log(2, "%p\n", req); - return &req->mad; -} - -void acm_free_sa_mad(struct acm_sa_mad *mad) -{ - struct acmc_sa_req *req; - req = container_of(mad, struct acmc_sa_req, mad); - acm_log(2, "%p\n", req); - free(req); -} - -int acm_send_sa_mad(struct acm_sa_mad *mad) -{ - struct acmc_port *port; - struct acmc_sa_req *req; - int ret; - - req = container_of(mad, struct acmc_sa_req, mad); - acm_log(2, "%p from %s\n", req, req->ep->addr_info[0].addr.id_string); - - port = req->ep->port; - mad->umad.addr.qpn = port->sa_addr.qpn; - mad->umad.addr.qkey = port->sa_addr.qkey; - mad->umad.addr.lid = port->sa_addr.lid; - mad->umad.addr.sl = port->sa_addr.sl; - mad->umad.addr.pkey_index = req->ep->port->sa_pkey_index; - - pthread_mutex_lock(&port->lock); - if (port->sa_credits && list_empty(&port->sa_wait)) { - ret = umad_send(port->mad_portid, port->mad_agentid, &mad->umad, - sizeof mad->sa_mad, sa.timeout, sa.retries); - if (!ret) { - port->sa_credits--; - list_add_tail(&port->sa_pending, &req->entry); - } - } else { - ret = 0; - list_add_tail(&port->sa_wait, &req->entry); - } - pthread_mutex_unlock(&port->lock); - return ret; -} - -static void acmc_send_queued_req(struct acmc_port *port) -{ - struct acmc_sa_req *req; - int ret; - - pthread_mutex_lock(&port->lock); - if (list_empty(&port->sa_wait) || !port->sa_credits) { - pthread_mutex_unlock(&port->lock); - return; - } - - req = list_pop(&port->sa_wait, struct acmc_sa_req, entry); - - ret = umad_send(port->mad_portid, port->mad_agentid, &req->mad.umad, - sizeof req->mad.sa_mad, sa.timeout, sa.retries); - if (!ret) { - port->sa_credits--; - list_add_tail(&port->sa_pending, &req->entry); - } - pthread_mutex_unlock(&port->lock); - - if (ret) { - req->mad.umad.status = -ret; - req->resp_handler(&req->mad); - } -} - -static void acmc_recv_mad(struct acmc_port *port) -{ - struct acmc_sa_req *req; - struct acm_sa_mad resp; - int ret, len, found; - struct umad_hdr *hdr; - - acm_log(2, "\n"); - len = sizeof(resp.sa_mad); - ret = umad_recv(port->mad_portid, &resp.umad, &len, 0); - if (ret < 0) { - acm_log(1, "umad_recv error %d\n", ret); - return; - } - - hdr = &resp.sa_mad.mad_hdr; - acm_log(2, "bv %x cls %x cv %x mtd %x st %d tid %" PRIx64 "x at %x atm %x\n", - hdr->base_version, hdr->mgmt_class, hdr->class_version, - hdr->method, hdr->status, be64toh(hdr->tid), hdr->attr_id, hdr->attr_mod); - found = 0; - pthread_mutex_lock(&port->lock); - list_for_each(&port->sa_pending, req, entry) { - /* The upper 32-bit of the tid is used for agentid in umad */ - if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid & htobe64(0xFFFFFFFF))) { - found = 1; - list_del(&req->entry); - port->sa_credits++; - break; - } - } - pthread_mutex_unlock(&port->lock); - - if (found) { - memcpy(&req->mad.umad, &resp.umad, sizeof(resp.umad) + len); - req->resp_handler(&req->mad); - } -} - -static void *acm_sa_handler(void *context) -{ - int i, ret; - - acm_log(0, "started\n"); - ret = acmc_init_sa_fds(); - if (ret) { - acm_log(0, "ERROR - failed to init fds\n"); - return NULL; - } - - if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { - acm_log(0, "Error: failed to set cancel type \n"); - return NULL; - } - - if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL)) { - acm_log(0, "Error: failed to set cancel state\n"); - return NULL; - } - - for (;;) { - pthread_testcancel(); - ret = poll(sa.fds, sa.nfds, -1); - if (ret < 0) { - acm_log(0, "ERROR - sa poll error: %d\n", errno); - continue; - } - - for (i = 0; i < sa.nfds; i++) { - if (!sa.fds[i].revents) - continue; - - if (sa.fds[i].revents & POLLIN) { - acmc_recv_mad(sa.ports[i]); - acmc_send_queued_req(sa.ports[i]); - } - sa.fds[i].revents = 0; - } - } - return NULL; -} - -static void acm_stop_sa_handler(void) -{ - if (pthread_cancel(sa.thread_id)) { - acm_log(0, "Error: failed to cancel sa resp thread \n"); - return; - } - - if (pthread_join(sa.thread_id, NULL)) { - acm_log(0, "Error: failed to join sa resp thread\n"); - return; - } -} - -static void acm_set_options(void) -{ - FILE *f; - char s[120]; - char opt[32], value[256]; - - if (!(f = fopen(opts_file, "r"))) - return; - - while (fgets(s, sizeof s, f)) { - if (s[0] == '#') - continue; - - if (sscanf(s, "%32s%256s", opt, value) != 2) - continue; - - if (!strcasecmp("log_file", opt)) - strcpy(log_file, value); - else if (!strcasecmp("log_level", opt)) - log_level = atoi(value); - else if (!strcasecmp("lock_file", opt)) - strcpy(lock_file, value); - else if (!strcasecmp("server_port", opt)) - server_port = (short) atoi(value); - else if (!strcasecmp("provider_lib_path", opt)) - strcpy(prov_lib_path, value); - else if (!strcasecmp("support_ips_in_addr_cfg", opt)) - support_ips_in_addr_cfg = atoi(value); - else if (!strcasecmp("timeout", opt)) - sa.timeout = atoi(value); - else if (!strcasecmp("retries", opt)) - sa.retries = atoi(value); - else if (!strcasecmp("sa_depth", opt)) - sa.depth = atoi(value); - } - - fclose(f); -} - -static void acm_log_options(void) -{ - acm_log(0, "log file %s\n", log_file); - acm_log(0, "log level %d\n", log_level); - acm_log(0, "lock file %s\n", lock_file); - acm_log(0, "server_port %d\n", server_port); - acm_log(0, "timeout %d ms\n", sa.timeout); - acm_log(0, "retries %d\n", sa.retries); - acm_log(0, "sa depth %d\n", sa.depth); - acm_log(0, "options file %s\n", opts_file); - acm_log(0, "addr file %s\n", addr_file); - acm_log(0, "provider lib path %s\n", prov_lib_path); - acm_log(0, "support IP's in ibacm_addr.cfg %d\n", support_ips_in_addr_cfg); -} - -static FILE *acm_open_log(void) -{ - FILE *f; - - if (!strcasecmp(log_file, "stdout")) - return stdout; - - if (!strcasecmp(log_file, "stderr")) - return stderr; - - if (!(f = fopen(log_file, "w"))) - f = stdout; - - return f; -} - -static int acm_open_lock_file(void) -{ - int lock_fd; - char pid[16]; - - lock_fd = open(lock_file, O_RDWR | O_CREAT, 0640); - if (lock_fd < 0) - return lock_fd; - - if (lockf(lock_fd, F_TLOCK, 0)) { - close(lock_fd); - return -1; - } - - snprintf(pid, sizeof pid, "%d\n", getpid()); - if (write(lock_fd, pid, strlen(pid)) != strlen(pid)){ - close(lock_fd); - return -1; - } - return 0; -} - -static void show_usage(char *program) -{ - printf("usage: %s\n", program); - printf(" [-D] - run as a daemon (default)\n"); - printf(" [-P] - run as a standard process\n"); - printf(" [-A addr_file] - address configuration file\n"); - printf(" (default %s/%s)\n", ACM_CONF_DIR, ACM_ADDR_FILE); - printf(" [-O option_file] - option configuration file\n"); - printf(" (default %s/%s)\n", ACM_CONF_DIR, ACM_OPTS_FILE); -} - -int main(int argc, char **argv) -{ - int i, op, as_daemon = 1; - bool systemd = false; - - static const struct option long_opts[] = { - {"systemd", 0, NULL, 's'}, - {} - }; - - while ((op = getopt_long(argc, argv, "DPA:O:", long_opts, NULL)) != - -1) { - switch (op) { - case 'D': - /* option no longer required */ - break; - case 'P': - as_daemon = 0; - break; - case 'A': - addr_file = optarg; - break; - case 'O': - opts_file = optarg; - break; - case 's': - systemd = true; - break; - default: - show_usage(argv[0]); - exit(1); - } - } - - if (as_daemon && !systemd) { - if (daemon(0, 0)) - return EXIT_FAILURE; - } - - acm_set_options(); - if (acm_open_lock_file()) - return -1; - - pthread_mutex_init(&log_lock, NULL); - flog = acm_open_log(); - - acm_log(0, "Assistant to the InfiniBand Communication Manager\n"); - acm_log_options(); - - for (i = 0; i < ACM_MAX_COUNTER; i++) - atomic_init(&counter[i]); - - if (umad_init() != 0) { - acm_log(0, "ERROR - fail to initialize umad\n"); - return -1; - } - - if (acm_open_providers()) { - acm_log(0, "ERROR - unable to open any providers\n"); - return -1; - } - - if (acm_open_devices()) { - acm_log(0, "ERROR - unable to open any devices\n"); - return -1; - } - - acm_log(1, "creating IP Netlink socket\n"); - acm_ipnl_create(); - - acm_log(1, "starting sa response receiving thread\n"); - if (pthread_create(&sa.thread_id, NULL, acm_sa_handler, NULL)) { - acm_log(0, "Error: failed to create sa resp rcving thread"); - return -1; - } - acm_activate_devices(); - acm_log(1, "starting server\n"); - acm_server(systemd); - - acm_log(0, "shutting down\n"); - if (client_array[NL_CLIENT_INDEX].sock != -1) - close(client_array[NL_CLIENT_INDEX].sock); - acm_close_providers(); - acm_stop_sa_handler(); - umad_done(); - fclose(flog); - return 0; -} diff --git a/usr/rdma-core/ibacm/src/acm_util.c b/usr/rdma-core/ibacm/src/acm_util.c deleted file mode 100644 index aca042de5..000000000 --- a/usr/rdma-core/ibacm/src/acm_util.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2014 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenFabrics.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "acm_mad.h" -#include "acm_util.h" - -int acm_if_is_ib(char *ifname) -{ - unsigned type; - char buf[128]; - FILE *f; - int ret; - - snprintf(buf, sizeof buf, "//sys//class//net//%s//type", ifname); - f = fopen(buf, "r"); - if (!f) { - acm_log(0, "failed to open %s\n", buf); - return 0; - } - - if (fgets(buf, sizeof buf, f)) { - type = strtol(buf, NULL, 0); - ret = (type == ARPHRD_INFINIBAND); - } else { - acm_log(0, "failed to read interface type\n"); - ret = 0; - } - - fclose(f); - return ret; -} - -int acm_if_get_pkey(char *ifname, uint16_t *pkey) -{ - char buf[128], *end; - FILE *f; - int ret; - - snprintf(buf, sizeof buf, "//sys//class//net//%s//pkey", ifname); - f = fopen(buf, "r"); - if (!f) { - acm_log(0, "failed to open %s\n", buf); - return -1; - } - - if (fgets(buf, sizeof buf, f)) { - *pkey = strtol(buf, &end, 16); - ret = 0; - } else { - acm_log(0, "failed to read pkey\n"); - ret = -1; - } - - fclose(f); - return ret; -} - -int acm_if_get_sgid(char *ifname, union ibv_gid *sgid) -{ - char buf[128], *end; - FILE *f; - int i, p, ret; - - snprintf(buf, sizeof buf, "//sys//class//net//%s//address", ifname); - f = fopen(buf, "r"); - if (!f) { - acm_log(0, "failed to open %s\n", buf); - return -1; - } - - if (fgets(buf, sizeof buf, f)) { - for (i = 0, p = 12; i < 16; i++, p += 3) { - buf[p + 2] = '\0'; - sgid->raw[i] = (uint8_t) strtol(buf + p, &end, 16); - } - ret = 0; - } else { - acm_log(0, "failed to read sgid\n"); - ret = -1; - } - - fclose(f); - return ret; -} - -int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx) -{ - struct ifconf *ifc; - struct ifreq *ifr; - char ip_str[INET6_ADDRSTRLEN]; - int s, ret, i, len; - uint16_t pkey; - union ibv_gid sgid; - uint8_t addr_type; - uint8_t addr[ACM_MAX_ADDRESS]; - size_t addr_len; - char *alias_sep; - - s = socket(AF_INET6, SOCK_DGRAM, 0); - if (!s) - return -1; - - len = sizeof(*ifc) + sizeof(*ifr) * 64; - ifc = malloc(len); - if (!ifc) { - ret = -1; - goto out1; - } - - memset(ifc, 0, len); - ifc->ifc_len = len - sizeof(*ifc); - ifc->ifc_req = (struct ifreq *) (ifc + 1); - - ret = ioctl(s, SIOCGIFCONF, ifc); - if (ret < 0) { - acm_log(0, "ioctl ifconf error %d\n", ret); - goto out2; - } - - ifr = ifc->ifc_req; - for (i = 0; i < ifc->ifc_len / sizeof(struct ifreq); i++) { - switch (ifr[i].ifr_addr.sa_family) { - case AF_INET: - addr_type = ACM_ADDRESS_IP; - memcpy(&addr, &((struct sockaddr_in *) &ifr[i].ifr_addr)->sin_addr, - sizeof addr); - addr_len = 4; - inet_ntop(ifr[i].ifr_addr.sa_family, - &((struct sockaddr_in *) &ifr[i].ifr_addr)->sin_addr, - ip_str, sizeof ip_str); - break; - case AF_INET6: - addr_type = ACM_ADDRESS_IP6; - memcpy(&addr, &((struct sockaddr_in6 *) &ifr[i].ifr_addr)->sin6_addr, - sizeof addr); - addr_len = ACM_MAX_ADDRESS; - inet_ntop(ifr[i].ifr_addr.sa_family, - &((struct sockaddr_in6 *) &ifr[i].ifr_addr)->sin6_addr, - ip_str, sizeof ip_str); - break; - default: - continue; - } - - acm_log(2, "%s\n", ifr[i].ifr_name); - - alias_sep = strchr(ifr[i].ifr_name, ':'); - if (alias_sep) - *alias_sep = '\0'; - - if (!acm_if_is_ib(ifr[i].ifr_name)) - continue; - - ret = acm_if_get_sgid(ifr[i].ifr_name, &sgid); - if (ret) - continue; - - ret = acm_if_get_pkey(ifr[i].ifr_name, &pkey); - if (ret) - continue; - - cb(ifr[i].ifr_name, &sgid, pkey, addr_type, addr, addr_len, ip_str, ctx); - } - ret = 0; - -out2: - free(ifc); -out1: - close(s); - return ret; - -} diff --git a/usr/rdma-core/ibacm/src/acm_util.h b/usr/rdma-core/ibacm/src/acm_util.h deleted file mode 100644 index a83d915f1..000000000 --- a/usr/rdma-core/ibacm/src/acm_util.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenFabrics.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(ACM_IF_H) -#define ACM_IF_H - -#include -#include - -#ifdef ACME_PRINTS - -#undef acm_log -#define acm_log(level, format, ...) \ - printf(format, ## __VA_ARGS__) - -#else /* !ACME_PRINTS */ -#define acm_log(level, format, ...) \ - acm_write(level, "%s: "format, __func__, ## __VA_ARGS__) -#endif /* ACME_PRINTS */ - -int acm_if_is_ib(char *ifname); -int acm_if_get_pkey(char *ifname, uint16_t *pkey); -int acm_if_get_sgid(char *ifname, union ibv_gid *sgid); - -typedef void (*acm_if_iter_cb)(char *ifname, union ibv_gid *gid, uint16_t pkey, - uint8_t addr_type, uint8_t *addr, size_t addr_len, - char *ip_str, void *ctx); -int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx); - -char **parse(const char *args, int *count); - -#endif /* ACM_IF_H */ diff --git a/usr/rdma-core/ibacm/src/acme.c b/usr/rdma-core/ibacm/src/acme.c deleted file mode 100644 index 62c339c4f..000000000 --- a/usr/rdma-core/ibacm/src/acme.c +++ /dev/null @@ -1,1074 +0,0 @@ -/* - * Copyright (c) 2009-2010 Intel Corporation. All rights reserved. - * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "libacm.h" -#include "acm_util.h" - -static const char *dest_dir = ACM_CONF_DIR; -static const char *addr_file = ACM_ADDR_FILE; -static const char *opts_file = ACM_OPTS_FILE; - -static char *dest_addr; -static char *src_addr; -static const char *svc_arg = "localhost"; -static char *dest_arg; -static char *src_arg; -static char addr_type = 'u'; -static int verify; -static int nodelay; -static int repetitions = 1; -static int ep_index; -static int enum_ep; - -enum perf_query_output { - PERF_QUERY_NONE, - PERF_QUERY_ROW, - PERF_QUERY_COL, - PERF_QUERY_EP_INDEX, - PERF_QUERY_EP_ALL, - PERF_QUERY_EP_ADDR -}; -static enum perf_query_output perf_query; -static int verbose; - -static struct ibv_context **verbs; -static int dev_cnt; - -#define VPRINT(format, ...) do { if (verbose) printf(format, ## __VA_ARGS__ ); } while (0) - -static void show_usage(char *program) -{ - printf("usage 1: %s\n", program); - printf("Query specified ibacm service for data\n"); - printf(" [-e [N]] - display one or all endpoints:\n"); - printf(" No index: all endpoints\n"); - printf(" N: endpoint N (N = 1, 2, ...)\n"); - printf(" [-f addr_format] - i(p), n(ame), l(id), g(gid), or u(nspecified)\n"); - printf(" address format for -s and -d options, default: 'u'\n"); - printf(" [-s src_addr] - source address for path queries\n"); - printf(" [-d dest_addr] - destination addresses for path queries\n"); - printf(" [-v] - verify ACM response against SA query response\n"); - printf(" [-c] - read ACM cached data only\n"); - printf(" [-P [opt]] - query performance data from destination service:\n"); - printf(" No option: output combined data in row format.\n"); - printf(" col: output combined data in column format.\n"); - printf(" N: output data for endpoint N (N = 1, 2,...)\n"); - printf(" all: output data for all endpoints\n"); - printf(" s: output data for the endpoint with the\n"); - printf(" address specified in -s option\n"); - printf(" [-S svc_addr] - address of ACM service, default: local service\n"); - printf(" [-C repetitions] - repeat count for resolution\n"); - printf("usage 2: %s\n", program); - printf("Generate default ibacm service configuration and option files\n"); - printf(" -A [addr_file] - generate local address configuration file\n"); - printf(" (default is %s)\n", ACM_ADDR_FILE); - printf(" -O [opt_file] - generate local ibacm_opts.cfg options file\n"); - printf(" (default is %s)\n", ACM_OPTS_FILE); - printf(" -D dest_dir - specify destination directory for output files\n"); - printf(" (default is %s)\n", ACM_CONF_DIR); - printf(" -V - enable verbose output\n"); -} - -static void gen_opts_temp(FILE *f) -{ - fprintf(f, "# InfiniBand Communication Manager Assistant for clusters configuration file\n"); - fprintf(f, "#\n"); - fprintf(f, "# Use ib_acme utility with -O option to automatically generate a sample\n"); - fprintf(f, "# ibacm_opts.cfg file for the current system.\n"); - fprintf(f, "#\n"); - fprintf(f, "# Entry format is:\n"); - fprintf(f, "# name value\n"); - fprintf(f, "\n"); - fprintf(f, "# log_file:\n"); - fprintf(f, "# Specifies the location of the ACM service output. The log file is used to\n"); - fprintf(f, "# assist with ACM service debugging and troubleshooting. The log_file can\n"); - fprintf(f, "# be set to 'stdout', 'stderr', or the name of a file.\n"); - fprintf(f, "# Examples:\n"); - fprintf(f, "# log_file stdout\n"); - fprintf(f, "# log_file stderr\n"); - fprintf(f, "# log_file %s\n", IBACM_LOG_FILE); - fprintf(f, "\n"); - fprintf(f, "log_file %s\n", IBACM_LOG_FILE); - fprintf(f, "\n"); - fprintf(f, "# log_level:\n"); - fprintf(f, "# Indicates the amount of detailed data written to the log file. Log levels\n"); - fprintf(f, "# should be one of the following values:\n"); - fprintf(f, "# 0 - basic configuration & errors\n"); - fprintf(f, "# 1 - verbose configuration & errors\n"); - fprintf(f, "# 2 - verbose operation\n"); - fprintf(f, "\n"); - fprintf(f, "log_level 0\n"); - fprintf(f, "\n"); - fprintf(f, "# lock_file:\n"); - fprintf(f, "# Specifies the location of the ACM lock file used to ensure that only a\n"); - fprintf(f, "# single instance of ACM is running.\n"); - fprintf(f, "\n"); - fprintf(f, "lock_file %s\n", IBACM_PID_FILE); - fprintf(f, "\n"); - fprintf(f, "# addr_prot:\n"); - fprintf(f, "# Default resolution protocol to resolve IP addresses into IB GIDs.\n"); - fprintf(f, "# Supported protocols are:\n"); - fprintf(f, "# acm - Use ACM multicast protocol, which is similar to ARP.\n"); - fprintf(f, "\n"); - fprintf(f, "addr_prot acm\n"); - fprintf(f, "\n"); - fprintf(f, "# addr_timeout:\n"); - fprintf(f, "# Number of minutes to maintain IP address to GID mapping before\n"); - fprintf(f, "# repeating address resolution. A value of -1 indicates that the\n"); - fprintf(f, "# mapping will not time out.\n"); - fprintf(f, "# 1 hour = 60, 1 day = 1440, 1 week = 10080, 1 month ~ 43200"); - fprintf(f, "\n"); - fprintf(f, "addr_timeout 1440\n"); - fprintf(f, "\n"); - fprintf(f, "# route_prot:\n"); - fprintf(f, "# Default resolution protocol to resolve IB routing information.\n"); - fprintf(f, "# Supported protocols are:\n"); - fprintf(f, "# sa - Query SA for path record data and cache results.\n"); - fprintf(f, "# acm - Use ACM multicast protocol.\n"); - fprintf(f, "\n"); - fprintf(f, "route_prot sa\n"); - fprintf(f, "\n"); - fprintf(f, "# route_timeout:\n"); - fprintf(f, "# Number of minutes to maintain IB routing information before\n"); - fprintf(f, "# repeating route resolution. A value of -1 indicates that the\n"); - fprintf(f, "# mapping will not time out. However, the route will\n"); - fprintf(f, "# automatically time out when the address times out.\n"); - fprintf(f, "# 1 hour = 60, 1 day = 1440, 1 week = 10080, 1 month ~ 43200"); - fprintf(f, "\n"); - fprintf(f, "route_timeout -1\n"); - fprintf(f, "\n"); - fprintf(f, "# loopback_prot:\n"); - fprintf(f, "# Address and route resolution protocol to resolve local addresses\n"); - fprintf(f, "# Supported protocols are:\n"); - fprintf(f, "# none - Use same protocols defined for addr_prot and route_prot\n"); - fprintf(f, "# local - Resolve information used locally available data\n"); - fprintf(f, "\n"); - fprintf(f, "loopback_prot local\n"); - fprintf(f, "\n"); - fprintf(f, "# server_port:\n"); - fprintf(f, "# TCP port number that the server listens on.\n"); - fprintf(f, "# If this value is changed, then a corresponding change is required for\n"); - fprintf(f, "# client applications.\n"); - fprintf(f, "\n"); - fprintf(f, "server_port 6125\n"); - fprintf(f, "\n"); - fprintf(f, "# timeout:\n"); - fprintf(f, "# Additional time, in milliseconds, that the ACM service will wait for a\n"); - fprintf(f, "# response from a remote ACM service or the IB SA. The actual request\n"); - fprintf(f, "# timeout is this value plus the subnet timeout.\n"); - fprintf(f, "\n"); - fprintf(f, "timeout 2000\n"); - fprintf(f, "\n"); - fprintf(f, "# retries:\n"); - fprintf(f, "# Number of times that the ACM service will retry a request. This affects\n"); - fprintf(f, "# both ACM multicast messages and and IB SA messages.\n"); - fprintf(f, "\n"); - fprintf(f, "retries 2\n"); - fprintf(f, "\n"); - fprintf(f, "# resolve_depth:\n"); - fprintf(f, "# Specifies the maximum number of outstanding requests that can be in\n"); - fprintf(f, "# progress simultaneously. A larger resolve depth allows for greater\n"); - fprintf(f, "# parallelism, but increases system resource usage and subnet load.\n"); - fprintf(f, "# If the number of pending requests is greater than the resolve_depth,\n"); - fprintf(f, "# the additional requests will automatically be queued until some of\n"); - fprintf(f, "# the previous requests complete.\n"); - fprintf(f, "\n"); - fprintf(f, "resolve_depth 1\n"); - fprintf(f, "\n"); - fprintf(f, "# sa_depth:\n"); - fprintf(f, "# Specifies the maximum number of outstanding requests to the SA that\n"); - fprintf(f, "# can be in progress simultaneously. A larger SA depth allows for greater\n"); - fprintf(f, "# parallelism, but increases system resource usage and SA load.\n"); - fprintf(f, "# If the number of pending SA requests is greater than the sa_depth,\n"); - fprintf(f, "# the additional requests will automatically be queued until some of\n"); - fprintf(f, "# the previous requests complete. The number of outstanding SA requests\n"); - fprintf(f, "# is separate from the specified resolve_depth.\n"); - fprintf(f, "\n"); - fprintf(f, "sa_depth 1\n"); - fprintf(f, "\n"); - fprintf(f, "# send_depth:\n"); - fprintf(f, "# Specifies the number of outstanding send operations that can\n"); - fprintf(f, "# be in progress simultaneously. A larger send depth allows for\n"); - fprintf(f, "# greater parallelism, but consumes more system resources and subnet load.\n"); - fprintf(f, "# The send_depth is in addition to resolve_depth and sa_depth, and limits\n"); - fprintf(f, "# the transfer of responses.\n"); - fprintf(f, "\n"); - fprintf(f, "send_depth 1\n"); - fprintf(f, "\n"); - fprintf(f, "# recv_depth:\n"); - fprintf(f, "# Specifies the number of buffers allocated and ready to receive remote\n"); - fprintf(f, "# requests. A larger receive depth consumes more system resources, but\n"); - fprintf(f, "# can avoid dropping requests due to insufficient receive buffers.\n"); - fprintf(f, "\n"); - fprintf(f, "recv_depth 1024\n"); - fprintf(f, "\n"); - fprintf(f, "# min_mtu:\n"); - fprintf(f, "# Indicates the minimum MTU supported by the ACM service. The ACM service\n"); - fprintf(f, "# negotiates to use the largest MTU available between both sides of a\n"); - fprintf(f, "# connection. It is most efficient and recommended that min_mtu be set\n"); - fprintf(f, "# to the largest MTU value supported by all nodes in a cluster.\n"); - fprintf(f, "\n"); - fprintf(f, "min_mtu 2048\n"); - fprintf(f, "\n"); - fprintf(f, "# min_rate:\n"); - fprintf(f, "# Indicates the minimum link rate, in Gbps, supported by the ACM service.\n"); - fprintf(f, "# The ACM service negotiates to use the highest rate available between both\n"); - fprintf(f, "# sides of a connection. It is most efficient and recommended that the\n"); - fprintf(f, "# min_rate be set to the largest rate supported by all nodes in a cluster.\n"); - fprintf(f, "\n"); - fprintf(f, "min_rate 10\n"); - fprintf(f, "\n"); - fprintf(f, "# route_preload:\n"); - fprintf(f, "# Specifies if the ACM routing cache should be preloaded, or built on demand.\n"); - fprintf(f, "# If preloaded, indicates the method used to build the cache.\n"); - fprintf(f, "# Supported preload values are:\n"); - fprintf(f, "# none - The routing cache is not pre-built (default)\n"); - fprintf(f, "# opensm_full_v1 - OpenSM 'full' path records dump file format (version 1)\n"); - fprintf(f, "\n"); - fprintf(f, "route_preload none\n"); - fprintf(f, "\n"); - fprintf(f, "# route_data_file:\n"); - fprintf(f, "# Specifies the location of the route data file to use when preloading\n"); - fprintf(f, "# the ACM cache. This option is only valid if route_preload\n"); - fprintf(f, "# indicates that routing data should be read from a file.\n"); - fprintf(f, "# Default is %s/ibacm_route.data\n", ACM_CONF_DIR); - fprintf(f, "# route_data_file %s/ibacm_route.data\n", ACM_CONF_DIR); - fprintf(f, "\n"); - fprintf(f, "# addr_preload:\n"); - fprintf(f, "# Specifies if the ACM address cache should be preloaded, or built on demand.\n"); - fprintf(f, "# If preloaded, indicates the method used to build the cache.\n"); - fprintf(f, "# Supported preload values are:\n"); - fprintf(f, "# none - The address cache is not pre-built (default)\n"); - fprintf(f, "# acm_hosts - ACM address to GID file format\n"); - fprintf(f, "\n"); - fprintf(f, "addr_preload none\n"); - fprintf(f, "\n"); - fprintf(f, "# addr_data_file:\n"); - fprintf(f, "# Specifies the location of the address data file to use when preloading\n"); - fprintf(f, "# the ACM cache. This option is only valid if addr_preload\n"); - fprintf(f, "# indicates that address data should be read from a file.\n"); - fprintf(f, "# Default is %s/ibacm_hosts.data\n", ACM_CONF_DIR); - fprintf(f, "# addr_data_file %s/ibacm_hosts.data\n", ACM_CONF_DIR); - fprintf(f, "\n"); - fprintf(f, "# support_ips_in_addr_cfg:\n"); - fprintf(f, "# If 1 continue to read IP addresses from ibacm_addr.cfg\n"); - fprintf(f, "# Default is 0 \"no\"\n"); - fprintf(f, "# support_ips_in_addr_cfg 0\n"); - fprintf(f, "\n"); - fprintf(f, "# provider_lib_path:\n"); - fprintf(f, "# Specifies the directory of the provider libraries\n"); - fprintf(f, "\n"); - fprintf(f, "# provider_lib_path %s\n", IBACM_LIB_PATH); - fprintf(f, "\n"); - fprintf(f, "# provider:\n"); - fprintf(f, "# Specifies the provider to assign to each subnet\n"); - fprintf(f, "# ACM providers may override the address and route resolution\n"); - fprintf(f, "# protocols with provider specific protocols.\n"); - fprintf(f, "# provider name (prefix | default)\n"); - fprintf(f, "# Example:\n"); - fprintf(f, "# provider ibacmp 0xFE80000000000000\n"); - fprintf(f, "# provider ibacmp default\n"); - fprintf(f, "\n"); -} - -static int open_dir(void) -{ - mkdir(dest_dir, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (chdir(dest_dir)) { - printf("Failed to open directory %s: %s\n", dest_dir, strerror(errno)); - return -1; - } - return 0; -} - -static int gen_opts(void) -{ - FILE *f; - - VPRINT("Generating %s/%s\n", dest_dir, opts_file); - if (open_dir() || !(f = fopen(opts_file, "w"))) { - printf("Failed to open option configuration file: %s\n", strerror(errno)); - return -1; - } - - gen_opts_temp(f); - fclose(f); - return 0; -} - -static void gen_addr_temp(FILE *f) -{ - fprintf(f, "# InfiniBand Communication Management Assistant for clusters address file\n"); - fprintf(f, "#\n"); - fprintf(f, "# Use ib_acme utility with -A option to automatically generate a sample\n"); - fprintf(f, "# ibacm_addr.cfg file for the current system.\n"); - fprintf(f, "#\n"); - fprintf(f, "# Entry format is:\n"); - fprintf(f, "# address device port pkey\n"); - fprintf(f, "#\n"); - fprintf(f, "# NOTE: IP addresses are now automatically read and monitored on the system.\n"); - fprintf(f, "# Therefore they are no longer required in this file.\n"); - fprintf(f, "#\n"); - fprintf(f, "# The address may be one of the following:\n"); - fprintf(f, "# host_name - ascii character string, up to 31 characters\n"); - fprintf(f, "#\n"); - fprintf(f, "# device name - struct ibv_device name\n"); - fprintf(f, "# port number - valid port number on device (numbering starts at 1)\n"); - fprintf(f, "# pkey - partition key in hex (can specify 'default' for first entry in pkey table)\n"); - fprintf(f, "#\n"); - fprintf(f, "# Up to 4 addresses can be associated with a given tuple\n"); - fprintf(f, "#\n"); - fprintf(f, "# Samples:\n"); - fprintf(f, "# node31 ibv_device0 1 default\n"); - fprintf(f, "# node31-1 ibv_device0 1 0x00FF\n"); - fprintf(f, "# node31-2 ibv_device0 2 0x00FF\n"); -} - -static int open_verbs(void) -{ - struct ibv_device **dev_array; - int i, ret; - - dev_array = ibv_get_device_list(&dev_cnt); - if (!dev_array) { - printf("ibv_get_device_list - no devices present?\n"); - return -1; - } - - verbs = malloc(sizeof(struct ibv_context *) * dev_cnt); - if (!verbs) { - ret = -1; - goto err1; - } - - for (i = 0; i < dev_cnt; i++) { - verbs[i] = ibv_open_device(dev_array[i]); - if (!verbs[i]) { - printf("ibv_open_device - failed to open device\n"); - ret = -1; - goto err2; - } - } - - ibv_free_device_list(dev_array); - return 0; - -err2: - while (i--) - ibv_close_device(verbs[i]); - free(verbs); -err1: - ibv_free_device_list(dev_array); - return ret; -} - -static void close_verbs(void) -{ - int i; - - for (i = 0; i < dev_cnt; i++) - ibv_close_device(verbs[i]); - free(verbs); -} - -static int gen_addr_names(FILE *f) -{ - struct ibv_device_attr dev_attr; - struct ibv_port_attr port_attr; - int i, index, ret, found_active; - char host_name[256]; - uint8_t p; - - ret = gethostname(host_name, sizeof host_name); - if (ret) { - printf("gethostname error: %d\n", ret); - return ret; - } - strtok(host_name, "."); - - found_active = 0; - index = 1; - for (i = 0; i < dev_cnt; i++) { - ret = ibv_query_device(verbs[i], &dev_attr); - if (ret) - break; - - for (p = 1; p <= dev_attr.phys_port_cnt; p++) { - if (!found_active) { - ret = ibv_query_port(verbs[i], p, &port_attr); - if (!ret && port_attr.state == IBV_PORT_ACTIVE) { - VPRINT("%s %s %d default\n", - host_name, verbs[i]->device->name, p); - fprintf(f, "%s %s %d default\n", - host_name, verbs[i]->device->name, p); - found_active = 1; - } - } - - VPRINT("%s-%d %s %d default\n", - host_name, index, verbs[i]->device->name, p); - fprintf(f, "%s-%d %s %d default\n", - host_name, index++, verbs[i]->device->name, p); - } - } - - return ret; -} - -static int gen_addr(void) -{ - FILE *f; - int ret; - - VPRINT("Generating %s/%s\n", dest_dir, addr_file); - if (open_dir() || !(f = fopen(addr_file, "w"))) { - printf("Failed to open address configuration file: %s\n", strerror(errno)); - return -1; - } - - ret = open_verbs(); - if (ret) { - goto out1; - } - - gen_addr_temp(f); - ret = gen_addr_names(f); - if (ret) { - printf("Failed to auto generate host names in config file\n"); - goto out2; - } - -out2: - close_verbs(); -out1: - fclose(f); - return ret; -} - -static void show_path(struct ibv_path_record *path) -{ - char gid[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"]; - uint32_t fl_hop; - - printf("Path information\n"); - inet_ntop(AF_INET6, path->dgid.raw, gid, sizeof gid); - printf(" dgid: %s\n", gid); - inet_ntop(AF_INET6, path->sgid.raw, gid, sizeof gid); - printf(" sgid: %s\n", gid); - printf(" dlid: %u\n", be16toh(path->dlid)); - printf(" slid: %u\n", be16toh(path->slid)); - fl_hop = be32toh(path->flowlabel_hoplimit); - printf(" flow label: 0x%x\n", fl_hop >> 8); - printf(" hop limit: %d\n", (uint8_t) fl_hop); - printf(" tclass: %d\n", path->tclass); - printf(" reversible: %d\n", path->reversible_numpath >> 7); - printf(" pkey: 0x%x\n", be16toh(path->pkey)); - printf(" sl: %d\n", be16toh(path->qosclass_sl) & 0xF); - printf(" mtu: %d\n", path->mtu & 0x1F); - printf(" rate: %d\n", path->rate & 0x1F); - printf(" packet lifetime: %d\n", path->packetlifetime & 0x1F); -} - -static uint32_t get_resolve_flags(void) -{ - uint32_t flags = 0; - - if (nodelay) - flags |= ACM_FLAGS_NODELAY; - - return flags; -} - -static int inet_any_pton(char *addr, struct sockaddr *sa) -{ - struct sockaddr_in *sin; - struct sockaddr_in6 *sin6; - int ret; - - sin = (struct sockaddr_in *) sa; - sa->sa_family = AF_INET; - ret = inet_pton(AF_INET, addr, &sin->sin_addr); - if (ret <= 0) { - sin6 = (struct sockaddr_in6 *) sa; - sa->sa_family = AF_INET6; - ret = inet_pton(AF_INET6, addr, &sin6->sin6_addr); - } - - return ret; -} - -static int resolve_ip(struct ibv_path_record *path) -{ - struct ibv_path_data *paths; - struct sockaddr_storage src, dest; - struct sockaddr *saddr; - int ret, count; - - if (src_addr) { - saddr = (struct sockaddr *) &src; - ret = inet_any_pton(src_addr, saddr); - if (ret <= 0) { - printf("inet_pton error on source address (%s): 0x%x\n", src_addr, ret); - return -1; - } - } else { - saddr = NULL; - } - - ret = inet_any_pton(dest_addr, (struct sockaddr *) &dest); - if (ret <= 0) { - printf("inet_pton error on destination address (%s): 0x%x\n", dest_addr, ret); - return -1; - } - - if (src_addr && src.ss_family != dest.ss_family) { - printf("source and destination address families don't match\n"); - return -1; - } - - ret = ib_acm_resolve_ip(saddr, (struct sockaddr *) &dest, - &paths, &count, get_resolve_flags(), (repetitions == 1)); - if (ret) { - printf("ib_acm_resolve_ip failed: %s\n", strerror(errno)); - return ret; - } - - *path = paths[0].path; - ib_acm_free_paths(paths); - return 0; -} - -static int resolve_name(struct ibv_path_record *path) -{ - struct ibv_path_data *paths; - int ret, count; - - ret = ib_acm_resolve_name(src_addr, dest_addr, &paths, &count, get_resolve_flags(), (repetitions == 1)); - if (ret) { - printf("ib_acm_resolve_name failed: %s\n", strerror(errno)); - return ret; - } - - *path = paths[0].path; - ib_acm_free_paths(paths); - return 0; -} - -static int resolve_lid(struct ibv_path_record *path) -{ - int ret; - - if (src_addr) - path->slid = htobe16((uint16_t) atoi(src_addr)); - path->dlid = htobe16((uint16_t) atoi(dest_addr)); - path->reversible_numpath = IBV_PATH_RECORD_REVERSIBLE | 1; - - ret = ib_acm_resolve_path(path, get_resolve_flags()); - if (ret) - printf("ib_acm_resolve_path failed: %s\n", strerror(errno)); - - return ret; -} - -static int resolve_gid(struct ibv_path_record *path) -{ - int ret; - - if (src_addr) { - ret = inet_pton(AF_INET6, src_addr, &path->sgid); - if (ret <= 0) { - printf("inet_pton error on source address (%s): 0x%x\n", - src_addr, ret); - return ret ? ret : -1; - } - } - - ret = inet_pton(AF_INET6, dest_addr, &path->dgid); - if (ret <= 0) { - printf("inet_pton error on dest address (%s): 0x%x\n", dest_addr, ret); - return ret ? ret : -1; - } - - path->reversible_numpath = IBV_PATH_RECORD_REVERSIBLE | 1; - ret = ib_acm_resolve_path(path, get_resolve_flags()); - if (ret) - printf("ib_acm_resolve_path failed: %s\n", strerror(errno)); - - return ret; -} - -static int verify_resolve(struct ibv_path_record *path) -{ - int ret; - - ret = ib_acm_resolve_path(path, ACM_FLAGS_QUERY_SA); - if (ret) - printf("SA verification: failed %s\n", strerror(errno)); - else - printf("SA verification: success\n"); - - return ret; -} - -static char *get_dest(char *arg, char *format) -{ - static char addr[64]; - struct addrinfo hint, *res; - const char *ai; - int ret; - - if (!arg || addr_type != 'u') { - *format = addr_type; - return arg; - } - - if ((inet_pton(AF_INET, arg, addr) > 0) || (inet_pton(AF_INET6, arg, addr) > 0)) { - *format = 'i'; - return arg; - } - - memset(&hint, 0, sizeof hint); - hint.ai_protocol = IPPROTO_TCP; - ret = getaddrinfo(arg, NULL, &hint, &res); - if (ret) { - *format = 'l'; - return arg; - } - - if (res->ai_family == AF_INET) { - ai = inet_ntop(AF_INET, &((struct sockaddr_in *) res->ai_addr)->sin_addr, - addr, sizeof addr); - } else { - ai = inet_ntop(AF_INET6, &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr, - addr, sizeof addr); - } - freeaddrinfo(res); - - if (ai) { - *format = 'i'; - return addr; - } else { - *format = 'n'; - return arg; - } -} - -static void resolve(char *svc) -{ - char **dest_list, **src_list; - struct ibv_path_record path; - int ret = 0, d = 0, s = 0, i; - char dest_type; - - dest_list = parse(dest_arg, NULL); - if (!dest_list) { - printf("Unable to parse destination argument\n"); - return; - } - - src_list = src_arg ? parse(src_arg, NULL) : NULL; - - printf("Service: %s\n", svc); - for (dest_addr = get_dest(dest_list[d], &dest_type); dest_addr; - dest_addr = get_dest(dest_list[++d], &dest_type)) { - s = 0; - src_addr = src_list ? src_list[s] : NULL; - do { - printf("Destination: %s\n", dest_addr); - if (src_addr) - printf("Source: %s\n", src_addr); - for (i = 0; i < repetitions; i++) { - switch (dest_type) { - case 'i': - ret = resolve_ip(&path); - break; - case 'n': - ret = resolve_name(&path); - break; - case 'l': - memset(&path, 0, sizeof path); - ret = resolve_lid(&path); - break; - case 'g': - memset(&path, 0, sizeof path); - ret = resolve_gid(&path); - break; - default: - break; - } - } - - if (!ret) - show_path(&path); - - if (verify) - ret = verify_resolve(&path); - printf("\n"); - - if (src_list) - src_addr = src_list[++s]; - } while (src_addr); - } - - free(dest_list); -} - -static int query_perf_ip(uint64_t **counters, int *cnt) -{ - union _sockaddr { - struct sockaddr_storage src; - struct sockaddr saddr; - } addr; - uint8_t type; - struct sockaddr_in *sin; - struct sockaddr_in6 *sin6; - int ret; - - VPRINT("%s: src_addr %s\n", __FUNCTION__, src_addr); - addr.saddr.sa_family = AF_INET; - sin = (struct sockaddr_in *) &addr.saddr; - ret = inet_pton(AF_INET, src_addr, &sin->sin_addr); - if (ret <= 0) { - addr.saddr.sa_family = AF_INET6; - sin6 = (struct sockaddr_in6 *)&addr.saddr; - ret = inet_pton(AF_INET6, src_addr, &sin6->sin6_addr); - if (ret <= 0) { - printf("inet_pton error on src address (%s): 0x%x\n", - src_addr, ret); - return -1; - } - type = ACM_EP_INFO_ADDRESS_IP6; - } else { - type = ACM_EP_INFO_ADDRESS_IP; - } - - ret = ib_acm_query_perf_ep_addr((uint8_t *)&addr.src, type, counters, - cnt); - if (ret) { - printf("ib_acm_query_perf failed: %s\n", strerror(errno)); - return ret; - } - - return 0; -} - -static int query_perf_name(uint64_t **counters, int *cnt) -{ - int ret; - - VPRINT("%s: src_addr %s\n", __FUNCTION__, src_addr); - ret = ib_acm_query_perf_ep_addr((uint8_t *)src_addr, ACM_EP_INFO_NAME, - counters, cnt); - if (ret) { - printf("ib_acm_query_perf failed: %s\n", strerror(errno)); - return ret; - } - - return 0; -} - -static int query_perf_ep_addr(uint64_t **counters, int *cnt) -{ - int ret; - char src_type; - - src_addr = get_dest(src_arg, &src_type); - switch (src_type) { - case 'i': - ret = query_perf_ip(counters, cnt); - break; - case 'n': - ret = query_perf_name(counters, cnt); - break; - default: - printf("Unsupported src_type %d\n", src_type); - return -1; - } - - return ret; -} - -static int query_perf_one(char *svc, int index) -{ - static int labels; - int ret, cnt, i; - uint64_t *counters; - - if (perf_query == PERF_QUERY_EP_ADDR) - ret = query_perf_ep_addr(&counters, &cnt); - else - ret = ib_acm_query_perf(index, &counters, &cnt); - - if (ret) { - if (perf_query != PERF_QUERY_EP_ALL) { - printf("%s: Failed to query perf data: %s\n", svc, - strerror(errno)); - } - return ret; - } - - if (perf_query != PERF_QUERY_COL) { - if (!labels) { - printf("svc,"); - for (i = 0; i < cnt - 1; i++) - printf("%s,", ib_acm_cntr_name(i)); - printf("%s\n", ib_acm_cntr_name(i)); - labels = 1; - } - printf("%s,", svc); - for (i = 0; i < cnt - 1; i++) - printf("%llu,", (unsigned long long) counters[i]); - printf("%llu\n", (unsigned long long) counters[i]); - } else { - printf("%s\n", svc); - for (i = 0; i < cnt; i++) { - printf("%s : ", ib_acm_cntr_name(i)); - printf("%llu\n", (unsigned long long) counters[i]); - } - } - ib_acm_free_perf(counters); - - return 0; -} - -static void query_perf(char *svc) -{ - int index = 1; - - if (perf_query != PERF_QUERY_EP_ALL) { - query_perf_one(svc, ep_index); - } - else { - while (!query_perf_one(svc, index++)); - } -} - -static int enumerate_ep(char *svc, int index) -{ - static int labels; - int ret, i; - struct acm_ep_config_data *ep_data; - - ret = ib_acm_enum_ep(index, &ep_data); - if (ret) - return ret; - - if (!labels) { - printf("svc,guid,port,pkey,ep_index,prov,addr_0,addresses\n"); - labels = 1; - } - - printf("%s,0x%016" PRIx64 ",%d,0x%04x,%d,%s", svc, ep_data->dev_guid, - ep_data->port_num, ep_data->pkey, index, ep_data->prov_name); - for (i = 0; i < ep_data->addr_cnt; i++) - printf(",%s", ep_data->addrs[i].name); - printf("\n"); - ib_acm_free_ep_data(ep_data); - - return 0; -} - -static void enumerate_eps(char *svc) -{ - int index = 1; - - if (ep_index > 0) { - if (enumerate_ep(svc, ep_index)) - printf(" Endpoint %d is not available\n", ep_index); - } else { - while (!enumerate_ep(svc, index++)); - } -} - -static int query_svcs(void) -{ - char **svc_list; - int ret = -1, i; - - svc_list = parse(svc_arg, NULL); - if (!svc_list) { - printf("Unable to parse service list argument\n"); - return -1; - } - - for (i = 0; svc_list[i]; i++) { - ret = ib_acm_connect(svc_list[i]); - if (ret) { - printf("%s,unable to contact service: %s\n", - svc_list[i], strerror(errno)); - continue; - } - - if (dest_arg) - resolve(svc_list[i]); - - if (perf_query) - query_perf(svc_list[i]); - - if (enum_ep) - enumerate_eps(svc_list[i]); - - ib_acm_disconnect(); - } - - free(svc_list); - return ret; -} - -static char *opt_arg(int argc, char **argv) -{ - if (optarg) - return optarg; - - if ((optind < argc) && (argv[optind][0] != '-')) - return argv[optind]; - - return NULL; -} - -static void parse_perf_arg(char *arg) -{ - if (!strncasecmp("col", arg, 3)) { - perf_query = PERF_QUERY_COL; - } else if (!strncasecmp("all", arg, 3)) { - perf_query = PERF_QUERY_EP_ALL; - } else if (!strcmp("s", arg)) { - perf_query = PERF_QUERY_EP_ADDR; - } else { - ep_index = atoi(arg); - if (ep_index > 0) - perf_query = PERF_QUERY_EP_INDEX; - else - perf_query = PERF_QUERY_ROW; - } -} - -int main(int argc, char **argv) -{ - int op, ret = 0; - int make_addr = 0; - int make_opts = 0; - - while ((op = getopt(argc, argv, "e::f:s:d:vcA::O::D:P::S:C:V")) != -1) { - switch (op) { - case 'e': - enum_ep = 1; - if (opt_arg(argc, argv)) - ep_index = atoi(opt_arg(argc, argv)); - break; - case 'f': - addr_type = optarg[0]; - if (addr_type != 'i' && addr_type != 'n' && - addr_type != 'l' && addr_type != 'g') - goto show_use; - break; - case 's': - src_arg = optarg; - break; - case 'd': - dest_arg = optarg; - break; - case 'v': - verify = 1; - break; - case 'c': - nodelay = 1; - break; - case 'A': - make_addr = 1; - if (opt_arg(argc, argv)) - addr_file = opt_arg(argc, argv); - break; - case 'O': - make_opts = 1; - if (opt_arg(argc, argv)) - opts_file = opt_arg(argc, argv); - break; - case 'D': - dest_dir = optarg; - break; - case 'P': - if (opt_arg(argc, argv)) - parse_perf_arg(opt_arg(argc, argv)); - else - perf_query = PERF_QUERY_ROW; - break; - case 'S': - svc_arg = optarg; - break; - case 'C': - repetitions = atoi(optarg); - if (!repetitions) - repetitions = 1; - break; - case 'V': - verbose = 1; - break; - default: - goto show_use; - } - } - - if ((src_arg && (!dest_arg && perf_query != PERF_QUERY_EP_ADDR)) || - (perf_query == PERF_QUERY_EP_ADDR && !src_arg) || - (!src_arg && !dest_arg && !perf_query && !make_addr && !make_opts && - !enum_ep)) - goto show_use; - - if (dest_arg || perf_query || enum_ep) - ret = query_svcs(); - - if (!ret && make_addr) - ret = gen_addr(); - - if (!ret && make_opts) - ret = gen_opts(); - - if (verbose || !(make_addr || make_opts) || ret) - printf("return status 0x%x\n", ret); - return ret; - -show_use: - show_usage(argv[0]); - exit(1); -} diff --git a/usr/rdma-core/ibacm/src/libacm.c b/usr/rdma-core/ibacm/src/libacm.c deleted file mode 100644 index 66ed298a3..000000000 --- a/usr/rdma-core/ibacm/src/libacm.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright (c) 2009 Intel Corporation. All rights reserved. - * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include "libacm.h" -#include -#include -#include -#include -#include - -static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER; -static int sock = -1; -static short server_port = 6125; - -static void acm_set_server_port(void) -{ - FILE *f; - - if ((f = fopen(IBACM_PORT_FILE, "r"))) { - if (fscanf(f, "%hu", (unsigned short *) &server_port) != 1) - printf("Failed to read server port\n"); - fclose(f); - } -} - -int ib_acm_connect(char *dest) -{ - struct addrinfo hint, *res; - int ret; - - acm_set_server_port(); - memset(&hint, 0, sizeof hint); - hint.ai_family = AF_INET; - hint.ai_protocol = IPPROTO_TCP; - ret = getaddrinfo(dest, NULL, &hint, &res); - if (ret) - return ret; - - sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (sock == -1) { - ret = errno; - goto err1; - } - - ((struct sockaddr_in *) res->ai_addr)->sin_port = htobe16(server_port); - ret = connect(sock, res->ai_addr, res->ai_addrlen); - if (ret) - goto err2; - - freeaddrinfo(res); - return 0; - -err2: - close(sock); - sock = -1; -err1: - freeaddrinfo(res); - return ret; -} - -void ib_acm_disconnect(void) -{ - if (sock != -1) { - shutdown(sock, SHUT_RDWR); - close(sock); - sock = -1; - } -} - -static int acm_format_resp(struct acm_msg *msg, - struct ibv_path_data **paths, int *count, int print) -{ - struct ibv_path_data *path_data; - char addr[ACM_MAX_ADDRESS]; - int i, addr_cnt; - - *count = 0; - addr_cnt = (msg->hdr.length - ACM_MSG_HDR_LENGTH) / - sizeof(struct acm_ep_addr_data); - path_data = (struct ibv_path_data *) - calloc(1, addr_cnt * sizeof(struct ibv_path_data)); - if (!path_data) - return -1; - - for (i = 0; i < addr_cnt; i++) { - switch (msg->resolve_data[i].type) { - case ACM_EP_INFO_PATH: - path_data[i].flags = msg->resolve_data[i].flags; - path_data[i].path = msg->resolve_data[i].info.path; - (*count)++; - break; - default: - if (!(msg->resolve_data[i].flags & ACM_EP_FLAG_SOURCE)) - goto err; - - switch (msg->resolve_data[i].type) { - case ACM_EP_INFO_ADDRESS_IP: - inet_ntop(AF_INET, msg->resolve_data[i].info.addr, - addr, sizeof addr); - break; - case ACM_EP_INFO_ADDRESS_IP6: - inet_ntop(AF_INET6, msg->resolve_data[i].info.addr, - addr, sizeof addr); - break; - case ACM_EP_INFO_NAME: - memcpy(addr, msg->resolve_data[i].info.name, - ACM_MAX_ADDRESS); - break; - default: - goto err; - } - if (print) - printf("Source: %s\n", addr); - break; - } - } - - *paths = path_data; - return 0; -err: - free(path_data); - return -1; -} - -static int acm_format_ep_addr(struct acm_ep_addr_data *data, uint8_t *addr, - uint8_t type, uint32_t flags) -{ - data->type = type; - data->flags = flags; - - switch (type) { - case ACM_EP_INFO_NAME: - strncpy((char *) data->info.name, (char *) addr, ACM_MAX_ADDRESS); - break; - case ACM_EP_INFO_ADDRESS_IP: - memcpy(data->info.addr, &((struct sockaddr_in *) addr)->sin_addr, 4); - break; - case ACM_EP_INFO_ADDRESS_IP6: - memcpy(data->info.addr, &((struct sockaddr_in6 *) addr)->sin6_addr, 16); - break; - default: - return -1; - } - - return 0; -} - -static inline int ERR(int err) -{ - errno = err; - return -1; -} - -static int acm_error(uint8_t status) -{ - switch (status) { - case ACM_STATUS_SUCCESS: - return 0; - case ACM_STATUS_ENOMEM: - return ERR(ENOMEM); - case ACM_STATUS_EINVAL: - return ERR(EINVAL); - case ACM_STATUS_ENODATA: - return ERR(ENODATA); - case ACM_STATUS_ENOTCONN: - return ERR(ENOTCONN); - case ACM_STATUS_ETIMEDOUT: - return ERR(ETIMEDOUT); - case ACM_STATUS_ESRCADDR: - case ACM_STATUS_EDESTADDR: - return ERR(EADDRNOTAVAIL); - case ACM_STATUS_ESRCTYPE: - case ACM_STATUS_EDESTTYPE: - default: - return ERR(EINVAL); - } -} - -static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type, - struct ibv_path_data **paths, int *count, uint32_t flags, int print) -{ - struct acm_msg msg; - int ret, cnt = 0; - - pthread_mutex_lock(&acm_lock); - memset(&msg, 0, sizeof msg); - msg.hdr.version = ACM_VERSION; - msg.hdr.opcode = ACM_OP_RESOLVE; - - if (src) { - ret = acm_format_ep_addr(&msg.resolve_data[cnt++], src, type, - ACM_EP_FLAG_SOURCE); - if (ret) - goto out; - } - - ret = acm_format_ep_addr(&msg.resolve_data[cnt++], dest, type, - ACM_EP_FLAG_DEST | flags); - if (ret) - goto out; - - msg.hdr.length = ACM_MSG_HDR_LENGTH + (cnt * ACM_MSG_EP_LENGTH); - - ret = send(sock, (char *) &msg, msg.hdr.length, 0); - if (ret != msg.hdr.length) - goto out; - - ret = recv(sock, (char *) &msg, sizeof msg, 0); - if (ret < ACM_MSG_HDR_LENGTH || ret != msg.hdr.length) - goto out; - - if (msg.hdr.status) { - ret = acm_error(msg.hdr.status); - goto out; - } - - ret = acm_format_resp(&msg, paths, count, print); -out: - pthread_mutex_unlock(&acm_lock); - return ret; -} - -int ib_acm_resolve_name(char *src, char *dest, - struct ibv_path_data **paths, int *count, uint32_t flags, int print) -{ - return acm_resolve((uint8_t *) src, (uint8_t *) dest, - ACM_EP_INFO_NAME, paths, count, flags, print); -} - -int ib_acm_resolve_ip(struct sockaddr *src, struct sockaddr *dest, - struct ibv_path_data **paths, int *count, uint32_t flags, int print) -{ - if (((struct sockaddr *) dest)->sa_family == AF_INET) { - return acm_resolve((uint8_t *) src, (uint8_t *) dest, - ACM_EP_INFO_ADDRESS_IP, paths, count, flags, print); - } else { - return acm_resolve((uint8_t *) src, (uint8_t *) dest, - ACM_EP_INFO_ADDRESS_IP6, paths, count, flags, print); - } -} - -int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags) -{ - struct acm_msg msg; - struct acm_ep_addr_data *data; - int ret; - - pthread_mutex_lock(&acm_lock); - memset(&msg, 0, sizeof msg); - msg.hdr.version = ACM_VERSION; - msg.hdr.opcode = ACM_OP_RESOLVE; - msg.hdr.length = ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH; - - data = &msg.resolve_data[0]; - data->flags = flags; - data->type = ACM_EP_INFO_PATH; - data->info.path = *path; - - ret = send(sock, (char *) &msg, msg.hdr.length, 0); - if (ret != msg.hdr.length) - goto out; - - ret = recv(sock, (char *) &msg, sizeof msg, 0); - if (ret < ACM_MSG_HDR_LENGTH || ret != msg.hdr.length) - goto out; - - ret = acm_error(msg.hdr.status); - if (!ret) - *path = data->info.path; - -out: - pthread_mutex_unlock(&acm_lock); - return ret; -} - -int ib_acm_query_perf(int index, uint64_t **counters, int *count) -{ - struct acm_msg msg; - int ret, i; - - pthread_mutex_lock(&acm_lock); - memset(&msg, 0, sizeof msg); - msg.hdr.version = ACM_VERSION; - msg.hdr.opcode = ACM_OP_PERF_QUERY; - msg.hdr.data[1] = index; - msg.hdr.length = htobe16(ACM_MSG_HDR_LENGTH); - - ret = send(sock, (char *) &msg, ACM_MSG_HDR_LENGTH, 0); - if (ret != ACM_MSG_HDR_LENGTH) - goto out; - - ret = recv(sock, (char *) &msg, sizeof msg, 0); - if (ret < ACM_MSG_HDR_LENGTH || ret != be16toh(msg.hdr.length)) { - ret = ACM_STATUS_EINVAL; - goto out; - } - - if (msg.hdr.status) { - ret = acm_error(msg.hdr.status); - goto out; - } - - *counters = malloc(sizeof(uint64_t) * msg.hdr.data[0]); - if (!*counters) { - ret = ACM_STATUS_ENOMEM; - goto out; - } - - *count = msg.hdr.data[0]; - for (i = 0; i < *count; i++) - (*counters)[i] = be64toh(msg.perf_data[i]); - ret = 0; -out: - pthread_mutex_unlock(&acm_lock); - return ret; -} - -int ib_acm_enum_ep(int index, struct acm_ep_config_data **data) -{ - struct acm_msg msg; - int ret; - int len; - int cnt; - struct acm_ep_config_data *edata; - - pthread_mutex_lock(&acm_lock); - memset(&msg, 0, sizeof msg); - msg.hdr.version = ACM_VERSION; - msg.hdr.opcode = ACM_OP_EP_QUERY; - msg.hdr.data[0] = index; - msg.hdr.length = htobe16(ACM_MSG_HDR_LENGTH); - - ret = send(sock, (char *) &msg, ACM_MSG_HDR_LENGTH, 0); - if (ret != ACM_MSG_HDR_LENGTH) - goto out; - - ret = recv(sock, (char *) &msg, sizeof msg, 0); - if (ret < ACM_MSG_HDR_LENGTH || ret != be16toh(msg.hdr.length)) { - ret = ACM_STATUS_EINVAL; - goto out; - } - - if (msg.hdr.status) { - ret = acm_error(msg.hdr.status); - goto out; - } - - cnt = be16toh(msg.ep_data[0].addr_cnt); - len = sizeof(struct acm_ep_config_data) + - ACM_MAX_ADDRESS * cnt; - edata = malloc(len); - if (!edata) { - ret = ACM_STATUS_ENOMEM; - goto out; - } - - memcpy(edata, &msg.ep_data[0], len); - edata->dev_guid = be64toh(msg.ep_data[0].dev_guid); - edata->pkey = be16toh(msg.ep_data[0].pkey); - edata->addr_cnt = cnt; - *data = edata; - ret = 0; -out: - pthread_mutex_unlock(&acm_lock); - return ret; -} - -int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type, - uint64_t **counters, int *count) -{ - struct acm_msg msg; - int ret, i, len; - - if (!src) - return -1; - - pthread_mutex_lock(&acm_lock); - memset(&msg, 0, sizeof msg); - msg.hdr.version = ACM_VERSION; - msg.hdr.opcode = ACM_OP_PERF_QUERY; - - ret = acm_format_ep_addr(&msg.resolve_data[0], src, type, - ACM_EP_FLAG_SOURCE); - if (ret) - goto out; - - len = ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH; - msg.hdr.length = htobe16(len); - - ret = send(sock, (char *) &msg, len, 0); - if (ret != len) - goto out; - - ret = recv(sock, (char *) &msg, sizeof msg, 0); - if (ret < ACM_MSG_HDR_LENGTH || ret != be16toh(msg.hdr.length)) { - ret = ACM_STATUS_EINVAL; - goto out; - } - - if (msg.hdr.status) { - ret = acm_error(msg.hdr.status); - goto out; - } - - *counters = malloc(sizeof(uint64_t) * msg.hdr.data[0]); - if (!*counters) { - ret = ACM_STATUS_ENOMEM; - goto out; - } - - *count = msg.hdr.data[0]; - for (i = 0; i < *count; i++) - (*counters)[i] = be64toh(msg.perf_data[i]); - - ret = 0; -out: - pthread_mutex_unlock(&acm_lock); - return ret; -} - - -const char *ib_acm_cntr_name(int index) -{ - static const char *const cntr_name[] = { - [ACM_CNTR_ERROR] = "Error Count", - [ACM_CNTR_RESOLVE] = "Resolve Count", - [ACM_CNTR_NODATA] = "No Data", - [ACM_CNTR_ADDR_QUERY] = "Addr Query Count", - [ACM_CNTR_ADDR_CACHE] = "Addr Cache Count", - [ACM_CNTR_ROUTE_QUERY] = "Route Query Count", - [ACM_CNTR_ROUTE_CACHE] = "Route Cache Count", - }; - - if (index < ACM_CNTR_ERROR || index > ACM_MAX_COUNTER) - return "Unknown"; - - return cntr_name[index]; -} diff --git a/usr/rdma-core/ibacm/src/libacm.h b/usr/rdma-core/ibacm/src/libacm.h deleted file mode 100644 index bf8cb79bf..000000000 --- a/usr/rdma-core/ibacm/src/libacm.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2009 Intel Corporation. All rights reserved. - * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef LIBACM_H -#define LIBACM_H - -#include - -struct sockaddr; - -int ib_acm_connect(char *dest_svc); -void ib_acm_disconnect(void); - -int ib_acm_resolve_name(char *src, char *dest, - struct ibv_path_data **paths, int *count, uint32_t flags, - int print); -int ib_acm_resolve_ip(struct sockaddr *src, struct sockaddr *dest, - struct ibv_path_data **paths, int *count, uint32_t flags, - int print); -int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags); -#define ib_acm_free_paths(paths) free(paths) - -int ib_acm_query_perf(int index, uint64_t **counters, int *count); -int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type, - uint64_t **counters, int *count); -#define ib_acm_free_perf(counters) free(counters) - -const char *ib_acm_cntr_name(int index); - -int ib_acm_enum_ep(int index, struct acm_ep_config_data **data); -#define ib_acm_free_ep_data(data) free(data) - -#endif /* LIBACM_H */ diff --git a/usr/rdma-core/ibacm/src/parse.c b/usr/rdma-core/ibacm/src/parse.c deleted file mode 100644 index 15aab17f8..000000000 --- a/usr/rdma-core/ibacm/src/parse.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2009-2010 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include "acm_util.h" - -static char *expand(char *basename, char *args, int *str_cnt, int *str_size) -{ - char buf[256]; - char *str_buf = NULL; - char *token, *tmp; - int from, to, width; - int size = 0, cnt = 0; - - token = strtok(args, ","); - do { - from = atoi(token); - tmp = index(token, '-'); - if (tmp) { - to = atoi(tmp+1); - width = tmp - token; - } else { - to = from; - width = strlen(token); - } - - while (from <= to) { - snprintf(buf, sizeof buf, "%s%0*d", basename, width, from); - str_buf = realloc(str_buf, size + strlen(buf)+1); - strcpy(&str_buf[size], buf); - - from++; - cnt++; - size += strlen(buf)+1; - } - - token = strtok(NULL, ","); - } while (token); - - *str_size = size; - *str_cnt = cnt; - return str_buf; -} - -char **parse(const char *args, int *count) -{ - char **ptrs = NULL; - char *str_buf, *cpy, *token, *next; - int cnt = 0, str_size = 0; - int i; - - /* make a copy that strtok can modify */ - cpy = strdup(args); - if (!cpy) - return NULL; - - if (args[0] == '[') { - cpy[0] = '\0'; - token = cpy; - next = strtok(cpy + 1, "]"); - } else { - token = strtok(cpy, "["); - next = strtok(NULL, "]"); - } - - if (!next) { - str_size = strlen(token) + 1; - str_buf = malloc(str_size); - if (!str_buf) - goto out_cpy; - - strcpy(str_buf, token); - cnt = 1; - } else { - str_buf = expand(cpy, next, &cnt, &str_size); - } - - ptrs = malloc((sizeof str_buf * (cnt + 1)) + str_size); - if (!ptrs) - goto out_str_buf; - - memcpy(&ptrs[cnt + 1], str_buf, str_size); - - ptrs[0] = (char*) &ptrs[cnt + 1]; - for (i = 1; i < cnt; i++) - ptrs[i] = index(ptrs[i - 1], 0) + 1; - ptrs[i] = NULL; - - if (count) - *count = cnt; - -out_str_buf: - free(str_buf); -out_cpy: - free(cpy); - return ptrs; -} diff --git a/usr/rdma-core/iwpmd/CMakeLists.txt b/usr/rdma-core/iwpmd/CMakeLists.txt deleted file mode 100644 index bf538034e..000000000 --- a/usr/rdma-core/iwpmd/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -rdma_sbin_executable(iwpmd - iwarp_pm_common.c - iwarp_pm_helper.c - iwarp_pm_server.c - ) -target_link_libraries(iwpmd LINK_PRIVATE - ${SYSTEMD_LIBRARIES} - ${NL_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ) - -rdma_man_pages( - iwpmd.8.in - iwpmd.conf.5.in - ) - -rdma_subst_install(FILES "iwpmd.service.in" - RENAME "iwpmd.service" - DESTINATION "${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}") -rdma_subst_install(FILES "iwpmd_init.in" - DESTINATION "${CMAKE_INSTALL_INITDDIR}" - RENAME "iwpmd" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) -install(FILES "iwpmd.conf" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}") - -install(FILES "iwpmd.rules" - RENAME "90-iwpmd.rules" - DESTINATION "${CMAKE_INSTALL_UDEV_RULESDIR}") - -install(FILES modules-iwpmd.conf - RENAME "iwpmd.conf" - DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/rdma/modules") diff --git a/usr/rdma-core/iwpmd/iwarp_pm.h b/usr/rdma-core/iwpmd/iwarp_pm.h deleted file mode 100644 index dc0922ab3..000000000 --- a/usr/rdma-core/iwpmd/iwarp_pm.h +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 2013 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#ifndef IWARP_PM_H -#define IWARP_PM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define IWARP_PM_PORT 3935 -#define IWARP_PM_VER_SHIFT 6 -#define IWARP_PM_VER_MASK 0xc0 -#define IWARP_PM_MT_SHIFT 4 -#define IWARP_PM_MT_MASK 0x30 -#define IWARP_PM_IPVER_SHIFT 0 -#define IWARP_PM_IPVER_MASK 0x0F -#define IWARP_PM_MESSAGE_SIZE 48 /* bytes */ -#define IWARP_PM_ASSOC_OFFSET 0x10 /* different assochandles for passive/active side map requests */ -#define IWARP_PM_IPV4_ADDR 4 - -#define IWARP_PM_MT_REQ 0 -#define IWARP_PM_MT_ACC 1 -#define IWARP_PM_MT_ACK 2 -#define IWARP_PM_MT_REJ 3 - -#define IWARP_PM_REQ_QUERY 1 -#define IWARP_PM_REQ_ACCEPT 2 -#define IWARP_PM_REQ_ACK 4 - -#define IWARP_PM_RECV_PAYLOAD 4096 -#define IWARP_PM_MAX_CLIENTS 64 -#define IWPM_MAP_REQ_TIMEOUT 10 /* sec */ -#define IWPM_SEND_MSG_RETRIES 3 - -#define IWPM_ULIB_NAME "iWarpPortMapperUser" -#define IWPM_ULIBNAME_SIZE 32 -#define IWPM_DEVNAME_SIZE 32 -#define IWPM_IFNAME_SIZE 16 -#define IWPM_IPADDR_SIZE 16 - -#define IWPM_PARAM_NUM 1 -#define IWPM_PARAM_NAME_LEN 64 - -#define IWARP_PM_NETLINK_DBG 0x01 -#define IWARP_PM_WIRE_DBG 0x02 -#define IWARP_PM_RETRY_DBG 0x04 -#define IWARP_PM_ALL_DBG 0x07 -#define IWARP_PM_DEBUG 0x08 - -#define iwpm_debug(dbg_level, str, args...) \ - do { if (dbg_level & IWARP_PM_DEBUG) { \ - syslog(LOG_WARNING, str, ##args); } \ - } while (0) - -/* Port Mapper errors */ -enum { - IWPM_INVALID_NLMSG_ERR = 10, - IWPM_CREATE_MAPPING_ERR, - IWPM_DUPLICATE_MAPPING_ERR, - IWPM_UNKNOWN_MAPPING_ERR, - IWPM_CLIENT_DEV_INFO_ERR, - IWPM_USER_LIB_INFO_ERR, - IWPM_REMOTE_QUERY_REJECT -}; - -/* iwpm param indexes */ -enum { - NL_SOCK_RBUF_SIZE -}; - -typedef struct iwpm_client { - char ifname[IWPM_IFNAME_SIZE]; /* netdev interface name */ - char ibdevname[IWPM_DEVNAME_SIZE]; /* OFED device name */ - char ulibname[IWPM_ULIBNAME_SIZE]; /* library name of the userpace PM agent provider */ - __u32 nl_seq; - char valid; -} iwpm_client; - -typedef union sockaddr_union { - struct sockaddr_storage s_sockaddr; - struct sockaddr sock_addr; - struct sockaddr_in v4_sockaddr; - struct sockaddr_in6 v6_sockaddr; - struct sockaddr_nl nl_sockaddr; -} sockaddr_union; - -typedef struct iwpm_mapped_port { - struct list_node entry; - int owner_client; - int sd; - struct sockaddr_storage local_addr; - struct sockaddr_storage mapped_addr; - int wcard; - int ref_cnt; /* the number of owners, if wcard */ -} iwpm_mapped_port; - -typedef struct iwpm_wire_msg { - __u8 magic; - __u8 pmtime; - __be16 reserved; - __be16 apport; - __be16 cpport; - __be64 assochandle; - /* big endian IP addresses and ports */ - __u8 cpipaddr[IWPM_IPADDR_SIZE]; - __u8 apipaddr[IWPM_IPADDR_SIZE]; - __u8 mapped_cpipaddr[IWPM_IPADDR_SIZE]; -} iwpm_wire_msg; - -typedef struct iwpm_send_msg { - int pm_sock; - struct sockaddr_storage dest_addr; - iwpm_wire_msg data; - int length; -} iwpm_send_msg; - -typedef struct iwpm_mapping_request { - struct list_node entry; - struct sockaddr_storage src_addr; - struct sockaddr_storage remote_addr; - __u16 nlmsg_type; /* Message content */ - __u32 nlmsg_seq; /* Sequence number */ - __u32 nlmsg_pid; - __u64 assochandle; - iwpm_send_msg * send_msg; - int timeout; - int complete; - int msg_type; -} iwpm_mapping_request; - -typedef struct iwpm_pending_msg { - struct list_node entry; - iwpm_send_msg send_msg; -} iwpm_pending_msg; - -typedef struct iwpm_msg_parms { - __u32 ip_ver; - __u16 address_family; - char apipaddr[IWPM_IPADDR_SIZE]; - __be16 apport; - char cpipaddr[IWPM_IPADDR_SIZE]; - __be16 cpport; - char mapped_cpipaddr[IWPM_IPADDR_SIZE]; - __be16 mapped_cpport; - unsigned char ver; - unsigned char mt; - unsigned char pmtime; - __u64 assochandle; - int msize; -} iwpm_msg_parms; - -/* iwarp_pm_common.c */ - -void parse_iwpm_config(FILE *); - -int create_iwpm_socket_v4(__u16); - -int create_iwpm_socket_v6(__u16); - -int create_netlink_socket(void); - -void destroy_iwpm_socket(int); - -int parse_iwpm_nlmsg(struct nlmsghdr *, int, struct nla_policy *, struct nlattr * [], const char *); - -int parse_iwpm_msg(iwpm_wire_msg *, iwpm_msg_parms *); - -void form_iwpm_request(iwpm_wire_msg *, iwpm_msg_parms *); - -void form_iwpm_accept(iwpm_wire_msg *, iwpm_msg_parms *); - -void form_iwpm_ack(iwpm_wire_msg *, iwpm_msg_parms *); - -void form_iwpm_reject(iwpm_wire_msg *, iwpm_msg_parms *); - -int send_iwpm_nlmsg(int, struct nl_msg *, int); - -struct nl_msg *create_iwpm_nlmsg(__u16, int); - -void print_iwpm_sockaddr(struct sockaddr_storage *, const char *, __u32); - -__be16 get_sockaddr_port(struct sockaddr_storage *sockaddr); - -void copy_iwpm_sockaddr(__u16, struct sockaddr_storage *, struct sockaddr_storage *, - char *, char *, __be16 *); - -int is_wcard_ipaddr(struct sockaddr_storage *); - -/* iwarp_pm_helper.c */ - -iwpm_mapped_port *create_iwpm_mapped_port(struct sockaddr_storage *, int); - -iwpm_mapped_port *reopen_iwpm_mapped_port(struct sockaddr_storage *, struct sockaddr_storage *, int); - -void add_iwpm_mapped_port(iwpm_mapped_port *); - -iwpm_mapped_port *find_iwpm_mapping(struct sockaddr_storage *, int); - -iwpm_mapped_port *find_iwpm_same_mapping(struct sockaddr_storage *, int); - -void remove_iwpm_mapped_port(iwpm_mapped_port *); - -void print_iwpm_mapped_ports(void); - -void free_iwpm_port(iwpm_mapped_port *); - -int free_iwpm_wcard_mapping(iwpm_mapped_port *); - -iwpm_mapping_request *create_iwpm_map_request(struct nlmsghdr *, struct sockaddr_storage *, - struct sockaddr_storage *, __u64, int, iwpm_send_msg *); - -void add_iwpm_map_request(iwpm_mapping_request *); - -int update_iwpm_map_request(__u64, struct sockaddr_storage *, int, iwpm_mapping_request *, int); - -void remove_iwpm_map_request(iwpm_mapping_request *); - -void form_iwpm_send_msg(int, struct sockaddr_storage *, int, iwpm_send_msg *); - -int send_iwpm_msg(void (*form_msg_type)(iwpm_wire_msg *, iwpm_msg_parms *), - iwpm_msg_parms *, struct sockaddr_storage *, int); - -int add_iwpm_pending_msg(iwpm_send_msg *); - -int check_same_sockaddr(struct sockaddr_storage *, struct sockaddr_storage *); - -void free_iwpm_mapped_ports(void); - -extern struct list_head pending_messages; -extern struct list_head mapping_reqs; - -extern iwpm_client client_list[IWARP_PM_MAX_CLIENTS]; - -extern pthread_cond_t cond_req_complete; -extern pthread_mutex_t map_req_mutex; -extern int wake; -extern pthread_cond_t cond_pending_msg; -extern pthread_mutex_t pending_msg_mutex; - -#endif diff --git a/usr/rdma-core/iwpmd/iwarp_pm_common.c b/usr/rdma-core/iwpmd/iwarp_pm_common.c deleted file mode 100644 index 8b4432042..000000000 --- a/usr/rdma-core/iwpmd/iwarp_pm_common.c +++ /dev/null @@ -1,632 +0,0 @@ -/* - * Copyright (c) 2013-2015 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include "iwarp_pm.h" -#include - -/* iwpm config params */ -static const char * iwpm_param_names[IWPM_PARAM_NUM] = - { "nl_sock_rbuf_size" }; -static int iwpm_param_vals[IWPM_PARAM_NUM] = - { 0 }; - -/** - * get_iwpm_param() - */ -static int get_iwpm_param(char *param_name, int val) -{ - int i, ret; - for (i = 0; i < IWPM_PARAM_NUM; i++) { - ret = strcmp(param_name, iwpm_param_names[i]); - if (!ret && val > 0) { - syslog(LOG_WARNING, "get_iwpm_param: Got param (name = %s val = %d)\n", param_name, val); - iwpm_param_vals[i] = val; - return ret; - } - } - return ret; -} - -/** - * parse_iwpm_config() - */ -void parse_iwpm_config(FILE *fp) -{ - char line_buf[128]; - char param_name[IWPM_PARAM_NAME_LEN]; - int n, val, ret; - char *str; - - str = fgets(line_buf, 128, fp); - while (str) { - if (line_buf[0] == '#' || line_buf[0] == '\n') - goto parse_next_line; - n = sscanf(line_buf, "%64[^= ] %*[=]%d", param_name, &val); - if (n != 2) { - syslog(LOG_WARNING, "parse_iwpm_config: Couldn't parse a line (n = %d, name = %s, val = %d\n", n, param_name, val); - goto parse_next_line; - } - ret = get_iwpm_param(param_name, val); - if (ret) - syslog(LOG_WARNING, "parse_iwpm_config: Couldn't find param (ret = %d)\n", ret); -parse_next_line: - str = fgets(line_buf, 128, fp); - } -} - -/** - * create_iwpm_socket_v4 - Create an ipv4 socket for the iwarp port mapper - * @bind_port: UDP port to bind the socket - * - * Return a handle of ipv4 socket - */ -int create_iwpm_socket_v4(__u16 bind_port) -{ - sockaddr_union bind_addr; - struct sockaddr_in *bind_in4; - int pm_sock; - socklen_t sockname_len; - char ip_address_text[INET6_ADDRSTRLEN]; - - /* create a socket */ - pm_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (pm_sock < 0) { - syslog(LOG_WARNING, "create_iwpm_socket_v4: Unable to create socket. %s.\n", - strerror(errno)); - pm_sock = -errno; - goto create_socket_v4_exit; - } - /* bind the socket to the given port */ - memset(&bind_addr, 0, sizeof(bind_addr)); - bind_in4 = &bind_addr.v4_sockaddr; - bind_in4->sin_family = AF_INET; - bind_in4->sin_addr.s_addr = htobe32(INADDR_ANY); - bind_in4->sin_port = htobe16(bind_port); - - if (bind(pm_sock, &bind_addr.sock_addr, sizeof(struct sockaddr_in))) { - syslog(LOG_WARNING, "create_iwpm_socket_v4: Unable to bind socket (port = %u). %s.\n", - bind_port, strerror(errno)); - close(pm_sock); - pm_sock = -errno; - goto create_socket_v4_exit; - } - - /* get the socket name (local port number) */ - sockname_len = sizeof(struct sockaddr_in); - if (getsockname(pm_sock, &bind_addr.sock_addr, &sockname_len)) { - syslog(LOG_WARNING, "create_iwpm_socket_v4: Unable to get socket name. %s.\n", - strerror(errno)); - close(pm_sock); - pm_sock = -errno; - goto create_socket_v4_exit; - } - - iwpm_debug(IWARP_PM_WIRE_DBG, "create_iwpm_socket_v4: Socket IP address:port %s:%u\n", - inet_ntop(bind_in4->sin_family, &bind_in4->sin_addr.s_addr, ip_address_text, - INET6_ADDRSTRLEN), be16toh(bind_in4->sin_port)); -create_socket_v4_exit: - return pm_sock; -} - -/** - * create_iwpm_socket_v6 - Create an ipv6 socket for the iwarp port mapper - * @bind_port: UDP port to bind the socket - * - * Return a handle of ipv6 socket - */ -int create_iwpm_socket_v6(__u16 bind_port) -{ - sockaddr_union bind_addr; - struct sockaddr_in6 *bind_in6; - int pm_sock, ret_value, ipv6_only; - socklen_t sockname_len; - char ip_address_text[INET6_ADDRSTRLEN]; - - /* create a socket */ - pm_sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); - if (pm_sock < 0) { - syslog(LOG_WARNING, "create_iwpm_socket_v6: Unable to create socket. %s.\n", - strerror(errno)); - pm_sock = -errno; - goto create_socket_v6_exit; - } - - ipv6_only = 1; - ret_value = setsockopt(pm_sock, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6_only, sizeof(ipv6_only)); - if (ret_value < 0) { - syslog(LOG_WARNING, "create_iwpm_socket_v6: Unable to set sock options. %s.\n", - strerror(errno)); - close(pm_sock); - pm_sock = -errno; - goto create_socket_v6_exit; - } - - /* bind the socket to the given port */ - memset(&bind_addr, 0, sizeof(bind_addr)); - bind_in6 = &bind_addr.v6_sockaddr; - bind_in6->sin6_family = AF_INET6; - bind_in6->sin6_addr = in6addr_any; - bind_in6->sin6_port = htobe16(bind_port); - - if (bind(pm_sock, &bind_addr.sock_addr, sizeof(struct sockaddr_in6))) { - syslog(LOG_WARNING, "create_iwpm_socket_v6: Unable to bind socket (port = %u). %s.\n", - bind_port, strerror(errno)); - close(pm_sock); - pm_sock = -errno; - goto create_socket_v6_exit; - } - - /* get the socket name (local port number) */ - sockname_len = sizeof(struct sockaddr_in6); - if (getsockname(pm_sock, &bind_addr.sock_addr, &sockname_len)) { - syslog(LOG_WARNING, "create_iwpm_socket_v6: Unable to get socket name. %s.\n", - strerror(errno)); - close(pm_sock); - pm_sock = -errno; - goto create_socket_v6_exit; - } - - iwpm_debug(IWARP_PM_WIRE_DBG, "create_iwpm_socket_v6: Socket IP address:port %s:%04X\n", - inet_ntop(bind_in6->sin6_family, &bind_in6->sin6_addr, ip_address_text, - INET6_ADDRSTRLEN), be16toh(bind_in6->sin6_port)); -create_socket_v6_exit: - return pm_sock; -} - -/** - * create_netlink_socket - Create netlink socket for the iwarp port mapper - */ -int create_netlink_socket(void) -{ - sockaddr_union bind_addr; - struct sockaddr_nl *bind_nl; - int nl_sock; - __u32 rbuf_size, opt_len; - - /* create a socket */ - nl_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_RDMA); - if (nl_sock < 0) { - syslog(LOG_WARNING, "create_netlink_socket: Unable to create socket. %s.\n", - strerror(errno)); - nl_sock = -errno; - goto create_nl_socket_exit; - } - - /* bind the socket */ - memset(&bind_addr, 0, sizeof(bind_addr)); - bind_nl = &bind_addr.nl_sockaddr; - bind_nl->nl_family = AF_NETLINK; - bind_nl->nl_pid = getpid(); - bind_nl->nl_groups = 3; /* != 0 support multicast */ - - if (bind(nl_sock, &bind_addr.sock_addr, sizeof(struct sockaddr_nl))) { - syslog(LOG_WARNING, "create_netlink_socket: Unable to bind socket. %s.\n", - strerror(errno)); - close(nl_sock); - nl_sock = -errno; - goto create_nl_socket_exit; - } - if (iwpm_param_vals[NL_SOCK_RBUF_SIZE] > 0) { - rbuf_size = iwpm_param_vals[NL_SOCK_RBUF_SIZE]; - - if (setsockopt(nl_sock, SOL_SOCKET, SO_RCVBUFFORCE, &rbuf_size, sizeof rbuf_size)) { - syslog(LOG_WARNING, "create_netlink_socket: Unable to set sock option " - "(rbuf_size = %u). %s.\n", rbuf_size, strerror(errno)); - if (setsockopt(nl_sock, SOL_SOCKET, SO_RCVBUF, - &rbuf_size, sizeof rbuf_size)) { - syslog(LOG_WARNING, "create_netlink_socket: " - "Unable to set sock option %s. Closing socket\n", strerror(errno)); - close(nl_sock); - nl_sock = -errno; - goto create_nl_socket_exit; - } - } - } - getsockopt(nl_sock, SOL_SOCKET, SO_RCVBUF, &rbuf_size, &opt_len); - iwpm_debug(IWARP_PM_NETLINK_DBG, "create_netlink_socket: Setting a sock option (rbuf_size = %u).\n", rbuf_size); - -create_nl_socket_exit: - return nl_sock; -} - -/** - * destroy_iwpm_socket - Close socket - */ -void destroy_iwpm_socket(int pm_sock) -{ - if (pm_sock > 0) - close(pm_sock); - pm_sock = -1; -} - -/** - * check_iwpm_nlattr - Check for NULL netlink attribute - */ -static int check_iwpm_nlattr(struct nlattr *nltb[], int nla_count) -{ - int i, ret = 0; - for (i = 1; i < nla_count; i++) { - if (!nltb[i]) { - iwpm_debug(IWARP_PM_NETLINK_DBG, "check_iwpm_nlattr: NULL (attr idx = %d)\n", i); - ret = -EINVAL; - } - } - return ret; -} - -/** - * parse_iwpm_nlmsg - Parse a netlink message - * @req_nlh: netlink header of the received message to parse - * @policy_max: the number of attributes in the policy - * @nlmsg_policy: the attribute policy - * @nltb: array to store the parsed attributes - * @msg_type: netlink message type (dbg purpose) - */ -int parse_iwpm_nlmsg(struct nlmsghdr *req_nlh, int policy_max, - struct nla_policy *nlmsg_policy, struct nlattr *nltb [], - const char *msg_type) -{ - const char *str_err; - int ret; - - if ((ret = nlmsg_validate(req_nlh, 0, policy_max-1, nlmsg_policy))) { - str_err = "nlmsg_validate error"; - goto parse_nlmsg_error; - } - if ((ret = nlmsg_parse(req_nlh, 0, nltb, policy_max-1, nlmsg_policy))) { - str_err = "nlmsg_parse error"; - goto parse_nlmsg_error; - } - if (check_iwpm_nlattr(nltb, policy_max)) { - ret = -EINVAL; - str_err = "NULL nlmsg attribute"; - goto parse_nlmsg_error; - } - return 0; -parse_nlmsg_error: - syslog(LOG_WARNING, "parse_iwpm_nlmsg: msg type = %s (%s ret = %d)\n", - msg_type, str_err, ret); - return ret; -} - -/** - * send_iwpm_nlmsg - Send a netlink message - * @nl_sock: netlink socket to use for sending the message - * @nlmsg: netlink message to send - * @dest_pid: pid of the destination of the nlmsg - */ -int send_iwpm_nlmsg(int nl_sock, struct nl_msg *nlmsg, int dest_pid) -{ - struct sockaddr_nl dest_addr; - struct nlmsghdr *nlh = nlmsg_hdr(nlmsg); - __u32 nlmsg_len = nlh->nlmsg_len; - int len; - - /* fill in the netlink address of the client */ - memset(&dest_addr, 0, sizeof(dest_addr)); - dest_addr.nl_groups = 0; - dest_addr.nl_family = AF_NETLINK; - dest_addr.nl_pid = dest_pid; - - /* send response to the client */ - len = sendto(nl_sock, (char *)nlh, nlmsg_len, 0, - (struct sockaddr *)&dest_addr, sizeof(dest_addr)); - if (len != nlmsg_len) - return -errno; - return 0; -} - -/** - * create_iwpm_nlmsg - Create a netlink message - * @nlmsg_type: type of the netlink message - * @client: the port mapper client to receive the message - */ -struct nl_msg *create_iwpm_nlmsg(__u16 nlmsg_type, int client_idx) -{ - struct nl_msg *nlmsg; - struct nlmsghdr *nlh; - __u32 seq = 0; - - nlmsg = nlmsg_alloc(); - if (!nlmsg) - return NULL; - if (client_idx > 0) - seq = client_list[client_idx].nl_seq++; - - nlh = nlmsg_put(nlmsg, getpid(), seq, nlmsg_type, 0, NLM_F_REQUEST); - if (!nlh) { - nlmsg_free(nlmsg); - return NULL; - } - return nlmsg; -} - -/** - * parse_iwpm_msg - Parse iwarp port mapper wire message - * @pm_msg: iwpm message to be parsed - * @msg_parms: contains the parameters of the iwpm message after parsing - */ -int parse_iwpm_msg(iwpm_wire_msg *pm_msg, iwpm_msg_parms *msg_parms) -{ - int ret_value = 0; - - msg_parms->pmtime = pm_msg->pmtime; - msg_parms->assochandle = be64toh(pm_msg->assochandle); - msg_parms->ip_ver = (pm_msg->magic & IWARP_PM_IPVER_MASK) >> IWARP_PM_IPVER_SHIFT; - switch (msg_parms->ip_ver) { - case 4: - msg_parms->address_family = AF_INET; - break; - case 6: - msg_parms->address_family = AF_INET6; - break; - default: - syslog(LOG_WARNING, "parse_iwpm_msg: Invalid IP version = %d.\n", - msg_parms->ip_ver); - return -EINVAL; - } - /* port mapper protocol version */ - msg_parms->ver = (pm_msg->magic & IWARP_PM_VER_MASK) >> IWARP_PM_VER_SHIFT; - /* message type */ - msg_parms->mt = (pm_msg->magic & IWARP_PM_MT_MASK) >> IWARP_PM_MT_SHIFT; - msg_parms->apport = pm_msg->apport; /* accepting peer port */ - msg_parms->cpport = pm_msg->cpport; /* connecting peer port */ - /* copy accepting peer IP address */ - memcpy(&msg_parms->apipaddr, &pm_msg->apipaddr, IWPM_IPADDR_SIZE); - /* copy connecting peer IP address */ - memcpy(&msg_parms->cpipaddr, &pm_msg->cpipaddr, IWPM_IPADDR_SIZE); - if (msg_parms->mt == IWARP_PM_MT_REQ) { - msg_parms->mapped_cpport = pm_msg->reserved; - memcpy(&msg_parms->mapped_cpipaddr, &pm_msg->mapped_cpipaddr, IWPM_IPADDR_SIZE); - } - return ret_value; -} - -/** - * form_iwpm_msg - Form iwarp port mapper wire message - * @pm_msg: iwpm message to be formed - * @msg_parms: the parameters to be packed in a iwpm message - */ -static void form_iwpm_msg(iwpm_wire_msg *pm_msg, iwpm_msg_parms *msg_parms) -{ - memset(pm_msg, 0, sizeof(struct iwpm_wire_msg)); - pm_msg->pmtime = msg_parms->pmtime; - pm_msg->assochandle = htobe64(msg_parms->assochandle); - /* record IP version, port mapper version, message type */ - pm_msg->magic = (msg_parms->ip_ver << IWARP_PM_IPVER_SHIFT) & IWARP_PM_IPVER_MASK; - pm_msg->magic |= (msg_parms->ver << IWARP_PM_VER_SHIFT) & IWARP_PM_VER_MASK; - pm_msg->magic |= (msg_parms->mt << IWARP_PM_MT_SHIFT) & IWARP_PM_MT_MASK; - - pm_msg->apport = msg_parms->apport; - pm_msg->cpport = msg_parms->cpport; - memcpy(&pm_msg->apipaddr, &msg_parms->apipaddr, IWPM_IPADDR_SIZE); - memcpy(&pm_msg->cpipaddr, &msg_parms->cpipaddr, IWPM_IPADDR_SIZE); - if (msg_parms->mt == IWARP_PM_MT_REQ) { - pm_msg->reserved = msg_parms->mapped_cpport; - memcpy(&pm_msg->mapped_cpipaddr, &msg_parms->mapped_cpipaddr, IWPM_IPADDR_SIZE); - } -} - -/** - * form_iwpm_request - Form iwarp port mapper request message - * @pm_msg: iwpm message to be formed - * @msg_parms: the parameters to be packed in a iwpm message - **/ -void form_iwpm_request(struct iwpm_wire_msg *pm_msg, - struct iwpm_msg_parms *msg_parms) -{ - msg_parms->mt = IWARP_PM_MT_REQ; - msg_parms->msize = IWARP_PM_MESSAGE_SIZE + IWPM_IPADDR_SIZE; - form_iwpm_msg(pm_msg, msg_parms); -} - -/** - * form_iwpm_accept - Form iwarp port mapper accept message - * @pm_msg: iwpm message to be formed - * @msg_parms: the parameters to be packed in a iwpm message - **/ -void form_iwpm_accept(struct iwpm_wire_msg *pm_msg, - struct iwpm_msg_parms *msg_parms) -{ - msg_parms->mt = IWARP_PM_MT_ACC; - msg_parms->msize = IWARP_PM_MESSAGE_SIZE; - form_iwpm_msg(pm_msg, msg_parms); -} - -/** - * form_iwpm_ack - Form iwarp port mapper ack message - * @pm_msg: iwpm message to be formed - * @msg_parms: the parameters to be packed in a iwpm message - **/ -void form_iwpm_ack(struct iwpm_wire_msg *pm_msg, - struct iwpm_msg_parms *msg_parms) -{ - msg_parms->mt = IWARP_PM_MT_ACK; - msg_parms->msize = IWARP_PM_MESSAGE_SIZE; - form_iwpm_msg(pm_msg, msg_parms); -} - -/** - * form_iwpm_reject - Form iwarp port mapper reject message - * @pm_msg: iwpm message to be formed - * @msg_parms: the parameters to be packed in a iwpm message - */ -void form_iwpm_reject(struct iwpm_wire_msg *pm_msg, - struct iwpm_msg_parms *msg_parms) -{ - msg_parms->mt = IWARP_PM_MT_REJ; - msg_parms->msize = IWARP_PM_MESSAGE_SIZE; - form_iwpm_msg(pm_msg, msg_parms); -} - -/** - * get_sockaddr_port - Report the tcp port number, contained in the sockaddr - * @sockaddr: sockaddr storage to get the tcp port from - */ -__be16 get_sockaddr_port(struct sockaddr_storage *sockaddr) -{ - struct sockaddr_in *sockaddr_v4; - struct sockaddr_in6 *sockaddr_v6; - __be16 port = 0; - - switch (sockaddr->ss_family) { - case AF_INET: - sockaddr_v4 = (struct sockaddr_in *)sockaddr; - port = sockaddr_v4->sin_port; - break; - case AF_INET6: - sockaddr_v6 = (struct sockaddr_in6 *)sockaddr; - port = sockaddr_v6->sin6_port; - break; - default: - syslog(LOG_WARNING, "get_sockaddr_port: Invalid sockaddr family.\n"); - break; - } - return port; -} - -/** - * copy_iwpm_sockaddr - Copy (IP address and Port) from src to dst - * @address_family: Internet address family - * @src_sockaddr: socket address to copy (if NULL, use src_addr) - * @dst_sockaddr: socket address to update (if NULL, use dst_addr) - * @src_addr: IP address to copy (if NULL, use src_sockaddr) - * @dst_addr: IP address to update (if NULL, use dst_sockaddr) - * @src_port: port to copy in dst_sockaddr, if src_sockaddr = NULL - * port to update, if src_sockaddr != NULL and dst_sockaddr = NULL - */ -void copy_iwpm_sockaddr(__u16 addr_family, struct sockaddr_storage *src_sockaddr, - struct sockaddr_storage *dst_sockaddr, - char *src_addr, char *dst_addr, __be16 *src_port) -{ - char *src = NULL, *dst = NULL; - - if (src_addr) - src = src_addr; - if (dst_addr) - dst = dst_addr; - - switch (addr_family) { - case AF_INET: - if (src_sockaddr) { - src = (char *)&((struct sockaddr_in *)src_sockaddr)->sin_addr.s_addr; - *src_port = ((struct sockaddr_in *)src_sockaddr)->sin_port; - } - if (dst_sockaddr) { - dst = (char *)&(((struct sockaddr_in *)dst_sockaddr)->sin_addr.s_addr); - ((struct sockaddr_in *)dst_sockaddr)->sin_port = *src_port; - ((struct sockaddr_in *)dst_sockaddr)->sin_family = AF_INET; - } - break; - case AF_INET6: - if (src_sockaddr) { - src = (char *)&((struct sockaddr_in6 *)src_sockaddr)->sin6_addr.s6_addr; - *src_port = ((struct sockaddr_in6 *)src_sockaddr)->sin6_port; - } - if (dst_sockaddr) { - dst = (char *)&(((struct sockaddr_in6 *)dst_sockaddr)->sin6_addr.s6_addr); - ((struct sockaddr_in6 *)dst_sockaddr)->sin6_port = *src_port; - ((struct sockaddr_in6 *)dst_sockaddr)->sin6_family = AF_INET6; - } - break; - default: - return; - } - - memcpy(dst, src, IWPM_IPADDR_SIZE); -} - -/** - * is_wcard_ipaddr - Check if the search_addr has a wild card ip address - */ -int is_wcard_ipaddr(struct sockaddr_storage *search_addr) -{ - int ret = 0; - - switch (search_addr->ss_family) { - case AF_INET: { - struct sockaddr_in wcard_addr; - struct sockaddr_in *in4addr = (struct sockaddr_in *)search_addr; - inet_pton(AF_INET, "0.0.0.0", &wcard_addr.sin_addr); - - if (in4addr->sin_addr.s_addr == wcard_addr.sin_addr.s_addr) - ret = 1; - break; - } - case AF_INET6: { - struct sockaddr_in6 wcard_addr; - struct sockaddr_in6 *in6addr = (struct sockaddr_in6 *)&search_addr; - inet_pton(AF_INET6, "::", &wcard_addr.sin6_addr); - - if (!memcmp(in6addr->sin6_addr.s6_addr, - wcard_addr.sin6_addr.s6_addr, IWPM_IPADDR_SIZE)) - ret = 1; - break; - } - default: - syslog(LOG_WARNING, "check_same_sockaddr: Invalid addr family 0x%02X\n", - search_addr->ss_family); - break; - } - return ret; -} - -/** - * print_iwpm_sockaddr - Print socket address (IP address and Port) - * @sockaddr: socket address to print - * @msg: message to print - */ -void print_iwpm_sockaddr(struct sockaddr_storage *sockaddr, const char *msg, - __u32 dbg_flag) -{ - struct sockaddr_in6 *sockaddr_v6; - struct sockaddr_in *sockaddr_v4; - char ip_address_text[INET6_ADDRSTRLEN]; - - switch (sockaddr->ss_family) { - case AF_INET: - sockaddr_v4 = (struct sockaddr_in *)sockaddr; - iwpm_debug(dbg_flag, "%s IPV4 %s:%u(0x%04X)\n", msg, - inet_ntop(AF_INET, &sockaddr_v4->sin_addr, ip_address_text, INET6_ADDRSTRLEN), - be16toh(sockaddr_v4->sin_port), be16toh(sockaddr_v4->sin_port)); - break; - case AF_INET6: - sockaddr_v6 = (struct sockaddr_in6 *)sockaddr; - iwpm_debug(dbg_flag, "%s IPV6 %s:%u(0x%04X)\n", msg, - inet_ntop(AF_INET6, &sockaddr_v6->sin6_addr, ip_address_text, INET6_ADDRSTRLEN), - be16toh(sockaddr_v6->sin6_port), be16toh(sockaddr_v6->sin6_port)); - break; - default: - break; - } -} diff --git a/usr/rdma-core/iwpmd/iwarp_pm_helper.c b/usr/rdma-core/iwpmd/iwarp_pm_helper.c deleted file mode 100644 index 8f2ff5f65..000000000 --- a/usr/rdma-core/iwpmd/iwarp_pm_helper.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - * Copyright (c) 2013-2016 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include "iwarp_pm.h" - -static LIST_HEAD(mapped_ports); /* list of mapped ports */ - -/** - * create_iwpm_map_request - Create a new map request tracking object - * @req_nlh: netlink header of the received client message - * @src_addr: the local address of the client initiating the request - * @remote_addr: the destination (the port mapper peer) address - * @assochandle: unique number per host - * @msg_type: message types are request, accept and ack - * @send_msg: message to retransmit to the remote port mapper peer, - * if the request isn't serviced on time. - */ -iwpm_mapping_request *create_iwpm_map_request(struct nlmsghdr *req_nlh, - struct sockaddr_storage *src_addr, struct sockaddr_storage *remote_addr, - __u64 assochandle, int msg_type, iwpm_send_msg *send_msg) -{ - iwpm_mapping_request *iwpm_map_req; - __u32 type = 0, seq = 0, pid = 0; - - /* create iwpm conversation tracking object */ - iwpm_map_req = malloc(sizeof(iwpm_mapping_request)); - if (!iwpm_map_req) - return NULL; - if (req_nlh) { - type = req_nlh->nlmsg_type; - seq = req_nlh->nlmsg_seq; - pid = req_nlh->nlmsg_pid; - } - memset(iwpm_map_req, 0, sizeof(iwpm_mapping_request)); - iwpm_map_req->timeout = IWPM_MAP_REQ_TIMEOUT; - iwpm_map_req->complete = 0; - iwpm_map_req->msg_type = msg_type; - iwpm_map_req->send_msg = send_msg; - - iwpm_map_req->nlmsg_type = type; - iwpm_map_req->nlmsg_seq = seq; - iwpm_map_req->nlmsg_pid = pid; - /* assochandle helps match iwpm request sent to remote peer with future iwpm accept/reject */ - iwpm_map_req->assochandle = assochandle; - if (!assochandle) - iwpm_map_req->assochandle = (uintptr_t)iwpm_map_req; - - memcpy(&iwpm_map_req->src_addr, src_addr, sizeof(struct sockaddr_storage)); - /* keep record of remote IP address and port */ - memcpy(&iwpm_map_req->remote_addr, remote_addr, sizeof(struct sockaddr_storage)); - return iwpm_map_req; -} - -/** - * add_iwpm_map_request - Add a map request tracking object to a global list - * @iwpm_map_req: mapping request to be saved - */ -void add_iwpm_map_request(iwpm_mapping_request *iwpm_map_req) -{ - pthread_mutex_lock(&map_req_mutex); - list_add(&mapping_reqs, &iwpm_map_req->entry); - /* if not wake, signal the thread that a new request has been posted */ - if (!wake) - pthread_cond_signal(&cond_req_complete); - pthread_mutex_unlock(&map_req_mutex); -} - -/** - * remove_iwpm_map_request - Free a map request tracking object - * @iwpm_map_req: mapping request to be removed - * - * Routine must be called within lock context - */ -void remove_iwpm_map_request(iwpm_mapping_request *iwpm_map_req) -{ - if (!iwpm_map_req->complete && iwpm_map_req->msg_type != IWARP_PM_REQ_ACK) { - iwpm_debug(IWARP_PM_RETRY_DBG, "remove_iwpm_map_request: " - "Timeout for request (type = %u pid = %d)\n", - iwpm_map_req->msg_type, iwpm_map_req->nlmsg_pid); - } - list_del(&iwpm_map_req->entry); - if (iwpm_map_req->send_msg) - free(iwpm_map_req->send_msg); - free(iwpm_map_req); -} - -/** - * update_iwpm_map_request - Find and update a map request tracking object - * @assochandle: the request assochandle to search for - * @src_addr: the request src address to search for - * @msg_type: the request type to search for - * @iwpm_copy_req: to store a copy of the found map request object - * @update: if set update the found request, otherwise don't update - */ -int update_iwpm_map_request(__u64 assochandle, struct sockaddr_storage *src_addr, - int msg_type, iwpm_mapping_request *iwpm_copy_req, int update) -{ - iwpm_mapping_request *iwpm_map_req; - int ret = -EINVAL; - - pthread_mutex_lock(&map_req_mutex); - /* look for a matching entry in the list */ - list_for_each(&mapping_reqs, iwpm_map_req, entry) { - if (assochandle == iwpm_map_req->assochandle && - (msg_type & iwpm_map_req->msg_type) && - check_same_sockaddr(src_addr, &iwpm_map_req->src_addr)) { - ret = 0; - /* get a copy of the request (a different thread is in charge of freeing it) */ - memcpy(iwpm_copy_req, iwpm_map_req, sizeof(iwpm_mapping_request)); - if (!update) - goto update_map_request_exit; - if (iwpm_map_req->complete) - goto update_map_request_exit; - - /* update the request object */ - if (iwpm_map_req->msg_type == IWARP_PM_REQ_ACK) { - iwpm_map_req->timeout = IWPM_MAP_REQ_TIMEOUT; - iwpm_map_req->complete = 0; - } else { - /* already serviced request could be freed */ - iwpm_map_req->timeout = 0; - iwpm_map_req->complete = 1; - } - goto update_map_request_exit; - } - } -update_map_request_exit: - pthread_mutex_unlock(&map_req_mutex); - return ret; -} - -/** - * send_iwpm_msg - Form and send iwpm message to the remote peer - */ -int send_iwpm_msg(void (*form_msg_type)(iwpm_wire_msg *, iwpm_msg_parms *), - iwpm_msg_parms *msg_parms, struct sockaddr_storage *recv_addr, int send_sock) -{ - iwpm_send_msg send_msg; - - form_msg_type(&send_msg.data, msg_parms); - form_iwpm_send_msg(send_sock, recv_addr, msg_parms->msize, &send_msg); - return add_iwpm_pending_msg(&send_msg); -} - -/** - * check_iwpm_ip_addr - Check if the local IP address is valid - * @local_addr: local IP address to verify - * - * Check if the local IP address is used by the host ethernet interfaces - */ -static int check_iwpm_ip_addr(struct sockaddr_storage *local_addr) -{ - struct ifaddrs ifa; - struct ifaddrs *ifap = &ifa; - struct ifaddrs **ifa_list = &ifap; - struct ifaddrs *ifa_current; - int found_addr = 0; - int ret = -EINVAL; - - /* get a list of host ethernet interfaces */ - if ((ret = getifaddrs(ifa_list)) < 0) { - syslog(LOG_WARNING, "check_iwpm_ip_addr: Unable to get the list of interfaces (%s).\n", - strerror(errno)); - return ret; - } - /* go through the list to make sure local IP address is valid */ - ifa_current = *ifa_list; - while (ifa_current != NULL && !found_addr) { - if (local_addr->ss_family == ifa_current->ifa_addr->sa_family) { - switch (ifa_current->ifa_addr->sa_family) { - case AF_INET: { - if (!memcmp(&((struct sockaddr_in *) - ifa_current->ifa_addr)->sin_addr.s_addr, - &((struct sockaddr_in *)local_addr)->sin_addr.s_addr, - IWARP_PM_IPV4_ADDR)) { - - found_addr = 1; - } - break; - } - case AF_INET6: { - if (!memcmp(&((struct sockaddr_in6 *) - ifa_current->ifa_addr)->sin6_addr.s6_addr, - &((struct sockaddr_in6 *)local_addr)->sin6_addr.s6_addr, - INET6_ADDRSTRLEN)) - - found_addr = 1; - break; - } - default: - break; - } - } - ifa_current = ifa_current->ifa_next; - } - if (found_addr) - ret = 0; - - freeifaddrs(*ifa_list); - return ret; -} - -/** - * get_iwpm_ip_addr - Get a mapped IP address - * @local_addr: local IP address to map - * @mapped_addr: to store the mapped local IP address - * - * Currently, don't map the local IP address - */ -static int get_iwpm_ip_addr(struct sockaddr_storage *local_addr, - struct sockaddr_storage *mapped_addr) -{ - int ret = check_iwpm_ip_addr(local_addr); - if (!ret) - memcpy(mapped_addr, local_addr, sizeof(struct sockaddr_storage)); - else - iwpm_debug(IWARP_PM_ALL_DBG, "get_iwpm_ip_addr: Invalid local IP address.\n"); - - return ret; -} - -/** - * get_iwpm_tcp_port - Get a new TCP port from the host stack - * @addr_family: should be valid AF_INET or AF_INET6 - * @requested_port: set only if reopening of mapped port - * @mapped_addr: to store the mapped TCP port - * @new_sock: to store socket handle (bound to the mapped TCP port) -*/ -static int get_iwpm_tcp_port(__u16 addr_family, __be16 requested_port, - struct sockaddr_storage *mapped_addr, int *new_sock) -{ - sockaddr_union bind_addr; - struct sockaddr_in *bind_in4; - struct sockaddr_in6 *bind_in6; - socklen_t sockname_len; - __be16 *new_port = NULL, *mapped_port = NULL; - const char *str_err = ""; - - /* create a socket */ - *new_sock = socket(addr_family, SOCK_STREAM, 0); - if (*new_sock < 0) { - str_err = "Unable to create socket"; - goto get_tcp_port_error; - } - - memset(&bind_addr, 0, sizeof(bind_addr)); - switch (addr_family) { - case AF_INET: - mapped_port = &((struct sockaddr_in *)mapped_addr)->sin_port; - bind_in4 = &bind_addr.v4_sockaddr; - bind_in4->sin_family = addr_family; - bind_in4->sin_addr.s_addr = htobe32(INADDR_ANY); - if (requested_port) - requested_port = *mapped_port; - bind_in4->sin_port = requested_port; - new_port = &bind_in4->sin_port; - break; - case AF_INET6: - mapped_port = &((struct sockaddr_in6 *)mapped_addr)->sin6_port; - bind_in6 = &bind_addr.v6_sockaddr; - bind_in6->sin6_family = addr_family; - bind_in6->sin6_addr = in6addr_any; - if (requested_port) - requested_port = *mapped_port; - bind_in6->sin6_port = requested_port; - new_port = &bind_in6->sin6_port; - break; - default: - str_err = "Invalid Internet address family"; - goto get_tcp_port_error; - } - - if (bind(*new_sock, &bind_addr.sock_addr, sizeof(bind_addr))) { - str_err = "Unable to bind the socket"; - goto get_tcp_port_error; - } - /* get the TCP port */ - sockname_len = sizeof(bind_addr); - if (getsockname(*new_sock, &bind_addr.sock_addr, &sockname_len)) { - str_err = "Unable to get socket name"; - goto get_tcp_port_error; - } - *mapped_port = *new_port; - iwpm_debug(IWARP_PM_ALL_DBG, "get_iwpm_tcp_port: Open tcp port " - "(addr family = %04X, requested port = %04X, mapped port = %04X).\n", - addr_family, be16toh(requested_port), be16toh(*mapped_port)); - return 0; -get_tcp_port_error: - syslog(LOG_WARNING, "get_iwpm_tcp_port: %s (addr family = %04X, requested port = %04X).\n", - str_err, addr_family, be16toh(requested_port)); - return -errno; -} - -/** - * get_iwpm_port - Allocate and initialize a new mapped port object - */ -static iwpm_mapped_port *get_iwpm_port(int client_idx, struct sockaddr_storage *local_addr, - struct sockaddr_storage *mapped_addr, int sd) -{ - iwpm_mapped_port *iwpm_port; - - iwpm_port = malloc(sizeof(iwpm_mapped_port)); - if (!iwpm_port) { - syslog(LOG_WARNING, "get_iwpm_port: Unable to allocate a mapped port.\n"); - return NULL; - } - memset(iwpm_port, 0, sizeof(*iwpm_port)); - - /* record local and mapped address in the mapped port object */ - memcpy(&iwpm_port->local_addr, local_addr, sizeof(struct sockaddr_storage)); - memcpy(&iwpm_port->mapped_addr, mapped_addr, sizeof(struct sockaddr_storage)); - iwpm_port->owner_client = client_idx; - iwpm_port->sd = sd; - if (is_wcard_ipaddr(local_addr)) { - iwpm_port->wcard = 1; - iwpm_port->ref_cnt = 1; - } - return iwpm_port; -} - -/** - * create_iwpm_mapped_port - Create a new mapped port object - * @local_addr: local address to be mapped (IP address and TCP port) - * @client_idx: the index of the client owner of the mapped port - */ -iwpm_mapped_port *create_iwpm_mapped_port(struct sockaddr_storage *local_addr, int client_idx) -{ - iwpm_mapped_port *iwpm_port; - struct sockaddr_storage mapped_addr; - int new_sd; - - /* check the local IP address */ - if (get_iwpm_ip_addr(local_addr, &mapped_addr)) - goto create_mapped_port_error; - /* get a tcp port from the host net stack */ - if (get_iwpm_tcp_port(local_addr->ss_family, 0, &mapped_addr, &new_sd)) - goto create_mapped_port_error; - - iwpm_port = get_iwpm_port(client_idx, local_addr, &mapped_addr, new_sd); - return iwpm_port; - -create_mapped_port_error: - iwpm_debug(IWARP_PM_ALL_DBG, "create_iwpm_mapped_port: Could not make port mapping.\n"); - return NULL; -} - -/** - * reopen_iwpm_mapped_port - Create a new mapped port object - * @local_addr: local address to be mapped (IP address and TCP port) - * @mapped_addr: mapped address to be remapped (IP address and TCP port) - * @client_idx: the index of the client owner of the mapped port - */ -iwpm_mapped_port *reopen_iwpm_mapped_port(struct sockaddr_storage *local_addr, - struct sockaddr_storage *mapped_addr, int client_idx) -{ - iwpm_mapped_port *iwpm_port; - int new_sd; - const char *str_err = ""; - int ret = check_iwpm_ip_addr(local_addr); - if (ret) { - str_err = "Invalid local IP address"; - goto reopen_mapped_port_error; - } - if (local_addr->ss_family != mapped_addr->ss_family) { - str_err = "Different local and mapped sockaddr families"; - goto reopen_mapped_port_error; - } - /* get a tcp port from the host net stack */ - if (get_iwpm_tcp_port(local_addr->ss_family, htobe16(1), mapped_addr, &new_sd)) - goto reopen_mapped_port_error; - - iwpm_port = get_iwpm_port(client_idx, local_addr, mapped_addr, new_sd); - return iwpm_port; - -reopen_mapped_port_error: - iwpm_debug(IWARP_PM_ALL_DBG, "reopen_iwpm_mapped_port: Could not make port mapping (%s).\n", - str_err); - return NULL; -} - -/** - * add_iwpm_mapped_port - Add mapping to a global list - * @iwpm_port: mapping to be saved - */ -void add_iwpm_mapped_port(iwpm_mapped_port *iwpm_port) -{ - static int dbg_idx = 1; - iwpm_debug(IWARP_PM_ALL_DBG, "add_iwpm_mapped_port: Adding a new mapping #%d\n", dbg_idx++); - /* only one mapping per wild card ip address */ - if (iwpm_port->wcard) { - if (iwpm_port->ref_cnt > 1) - return; - } - list_add(&mapped_ports, &iwpm_port->entry); -} - -/** - * check_same_sockaddr - Compare two sock addresses; - * return true if they are same, false otherwise - */ -int check_same_sockaddr(struct sockaddr_storage *sockaddr_a, struct sockaddr_storage *sockaddr_b) -{ - int ret = 0; - if (sockaddr_a->ss_family == sockaddr_b->ss_family) { - switch (sockaddr_a->ss_family) { - case AF_INET: { - struct sockaddr_in *in4addr_a = (struct sockaddr_in *)sockaddr_a; - struct sockaddr_in *in4addr_b = (struct sockaddr_in *)sockaddr_b; - - if ((in4addr_a->sin_addr.s_addr == in4addr_b->sin_addr.s_addr) - && (in4addr_a->sin_port == in4addr_b->sin_port)) - ret = 1; - - break; - } - case AF_INET6: { - struct sockaddr_in6 *in6addr_a = (struct sockaddr_in6 *)sockaddr_a; - struct sockaddr_in6 *in6addr_b = (struct sockaddr_in6 *)sockaddr_b; - - if ((!memcmp(in6addr_a->sin6_addr.s6_addr, - in6addr_b->sin6_addr.s6_addr, IWPM_IPADDR_SIZE)) && - (in6addr_a->sin6_port == in6addr_b->sin6_port)) - ret = 1; - - break; - } - default: - syslog(LOG_WARNING, "check_same_sockaddr: Invalid addr family 0x%02X\n", - sockaddr_a->ss_family); - break; - } - } - return ret; -} - -/** - * find_iwpm_mapping - Find saved mapped port object - * @search_addr: IP address and port to search for in the list - * @not_mapped: if set, compare local addresses, otherwise compare mapped addresses - * - * Compares the search_sockaddr to the addresses in the list, - * to find a saved port object with the sockaddr or - * a wild card address with the same tcp port - */ -iwpm_mapped_port *find_iwpm_mapping(struct sockaddr_storage *search_addr, - int not_mapped) -{ - iwpm_mapped_port *iwpm_port, *saved_iwpm_port = NULL; - struct sockaddr_storage *current_addr; - - list_for_each(&mapped_ports, iwpm_port, entry) { - current_addr = (not_mapped)? &iwpm_port->local_addr : &iwpm_port->mapped_addr; - - if (get_sockaddr_port(search_addr) == get_sockaddr_port(current_addr)) { - if (check_same_sockaddr(search_addr, current_addr) || - iwpm_port->wcard || is_wcard_ipaddr(search_addr)) { - saved_iwpm_port = iwpm_port; - goto find_mapping_exit; - } - } - } -find_mapping_exit: - return saved_iwpm_port; -} - -/** - * find_iwpm_same_mapping - Find saved mapped port object - * @search_addr: IP address and port to search for in the list - * @not_mapped: if set, compare local addresses, otherwise compare mapped addresses - * - * Compares the search_sockaddr to the addresses in the list, - * to find a saved port object with the same sockaddr - */ -iwpm_mapped_port *find_iwpm_same_mapping(struct sockaddr_storage *search_addr, - int not_mapped) -{ - iwpm_mapped_port *iwpm_port, *saved_iwpm_port = NULL; - struct sockaddr_storage *current_addr; - - list_for_each(&mapped_ports, iwpm_port, entry) { - current_addr = (not_mapped)? &iwpm_port->local_addr : &iwpm_port->mapped_addr; - if (check_same_sockaddr(search_addr, current_addr)) { - saved_iwpm_port = iwpm_port; - goto find_same_mapping_exit; - } - } -find_same_mapping_exit: - return saved_iwpm_port; -} - -/** - * free_iwpm_wcard_port - Free wild card mapping object - * @iwpm_port: mapped port object to be freed - * - * Mappings with wild card IP addresses can't be freed - * while their reference count > 0 - */ -int free_iwpm_wcard_mapping(iwpm_mapped_port *iwpm_port) -{ - if (iwpm_port->ref_cnt > 0) - iwpm_port->ref_cnt--; - - return iwpm_port->ref_cnt; -} - -/** - * free_iwpm_port - Free mapping object - * @iwpm_port: mapped port object to be freed - */ -void free_iwpm_port(iwpm_mapped_port *iwpm_port) -{ - close(iwpm_port->sd); - free(iwpm_port); -} - -/** - * remove_iwpm_mapped_port - Remove a mapping from a global list - * @iwpm_port: mapping to be removed - * - * Called only by the main iwarp port mapper thread - */ -void remove_iwpm_mapped_port(iwpm_mapped_port *iwpm_port) -{ - static int dbg_idx = 1; - iwpm_debug(IWARP_PM_ALL_DBG, "remove_iwpm_mapped_port: index = %d\n", dbg_idx++); - - list_del(&iwpm_port->entry); -} - -void print_iwpm_mapped_ports(void) -{ - iwpm_mapped_port *iwpm_port; - int i = 0; - - syslog(LOG_WARNING, "print_iwpm_mapped_ports:\n"); - - list_for_each(&mapped_ports, iwpm_port, entry) { - syslog(LOG_WARNING, "Mapping #%d\n", i++); - print_iwpm_sockaddr(&iwpm_port->local_addr, "Local address", IWARP_PM_DEBUG); - print_iwpm_sockaddr(&iwpm_port->mapped_addr, "Mapped address", IWARP_PM_DEBUG); - } -} - -/** - * form_iwpm_send_msg - Form a message to send on the wire - */ -void form_iwpm_send_msg(int pm_sock, struct sockaddr_storage *dest, - int length, iwpm_send_msg *send_msg) -{ - send_msg->pm_sock = pm_sock; - send_msg->length = length; - memcpy(&send_msg->dest_addr, dest, sizeof(send_msg->dest_addr)); -} - -/** - * add_iwpm_pending_msg - Add wire message to a global list of pending messages - * @send_msg: message to send to the remote port mapper peer - */ -int add_iwpm_pending_msg(iwpm_send_msg *send_msg) -{ - iwpm_pending_msg *pending_msg = (iwpm_pending_msg *)malloc(sizeof(iwpm_pending_msg)); - if (!pending_msg) { - syslog(LOG_WARNING, "add_iwpm_pending_msg: Unable to allocate message.\n"); - return -ENOMEM; - } - memcpy(&pending_msg->send_msg, send_msg, sizeof(iwpm_send_msg)); - - pthread_mutex_lock(&pending_msg_mutex); - list_add(&pending_messages, &pending_msg->entry); - pthread_mutex_unlock(&pending_msg_mutex); - pthread_mutex_unlock(&pending_msg_mutex); - /* signal the thread that a new message has been posted */ - pthread_cond_signal(&cond_pending_msg); - return 0; -} - -/** - * free_iwpm_mapped_ports - Free all iwpm mapped port objects - */ -void free_iwpm_mapped_ports(void) -{ - iwpm_mapped_port *iwpm_port; - - while ((iwpm_port = list_pop(&mapped_ports, iwpm_mapped_port, entry))) - free_iwpm_port(iwpm_port); -} diff --git a/usr/rdma-core/iwpmd/iwarp_pm_server.c b/usr/rdma-core/iwpmd/iwarp_pm_server.c deleted file mode 100644 index ebed6f9d2..000000000 --- a/usr/rdma-core/iwpmd/iwarp_pm_server.c +++ /dev/null @@ -1,1473 +0,0 @@ -/* - * Copyright (c) 2013-2016 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include "config.h" -#include -#include -#include "iwarp_pm.h" - -static const char iwpm_ulib_name [] = "iWarpPortMapperUser"; -static int iwpm_version = 3; - -LIST_HEAD(mapping_reqs); /* list of map tracking objects */ -LIST_HEAD(pending_messages); /* list of pending wire messages */ -iwpm_client client_list[IWARP_PM_MAX_CLIENTS];/* list of iwarp port mapper clients */ -static int mapinfo_num_list[IWARP_PM_MAX_CLIENTS]; /* list of iwarp port mapper clients */ - -/* socket handles */ -static int pmv4_sock, pmv6_sock, netlink_sock, pmv4_client_sock, pmv6_client_sock; - -static pthread_t map_req_thread; /* handling mapping requests timeout */ -pthread_cond_t cond_req_complete; -pthread_mutex_t map_req_mutex = PTHREAD_MUTEX_INITIALIZER; -int wake = 0; /* set if map_req_thread is wake */ - -static pthread_t pending_msg_thread; /* sending iwpm wire messages */ -pthread_cond_t cond_pending_msg; -pthread_mutex_t pending_msg_mutex = PTHREAD_MUTEX_INITIALIZER; - -static void iwpm_cleanup(void); -static int print_mappings = 0; - -/** - * iwpm_signal_handler - Handle signals which iwarp port mapper receives - * @signum: the number of the caught signal - */ -static void iwpm_signal_handler(int signum) -{ - switch(signum) { - case SIGHUP: - syslog(LOG_WARNING, "iwpm_signal_handler: Received SIGHUP signal\n"); - iwpm_cleanup(); - exit(signum); - break; - case SIGTERM: - syslog(LOG_WARNING, "iwpm_signal_handler: Received SIGTERM signal\n"); - iwpm_cleanup(); - exit(EXIT_SUCCESS); - break; - case SIGUSR1: - syslog(LOG_WARNING, "iwpm_signal_handler: Received SIGUSR1 signal\n"); - print_mappings = 1; - break; - default: - syslog(LOG_WARNING, "iwpm_signal_handler: Unhandled signal %d\n", signum); - break; - } -} - -/** - * iwpm_mapping_reqs_handler - Handle mapping requests timeouts and retries - */ -static void *iwpm_mapping_reqs_handler(void *unused) -{ - iwpm_mapping_request *iwpm_map_req, *next_map_req; - int ret = 0; - - while (1) { - pthread_mutex_lock(&map_req_mutex); - wake = 0; - if (list_empty(&mapping_reqs)) { - /* wait until a new mapping request is posted */ - ret = pthread_cond_wait(&cond_req_complete, &map_req_mutex); - if (ret) { - syslog(LOG_WARNING, "mapping_reqs_handler: " - "Condition wait failed (ret = %d)\n", ret); - pthread_mutex_unlock(&map_req_mutex); - goto mapping_reqs_handler_exit; - } - } - pthread_mutex_unlock(&map_req_mutex); - /* update timeouts of the posted mapping requests */ - do { - pthread_mutex_lock(&map_req_mutex); - wake = 1; - list_for_each_safe(&mapping_reqs, iwpm_map_req, next_map_req, entry) { - if (iwpm_map_req->timeout > 0) { - if (iwpm_map_req->timeout < IWPM_MAP_REQ_TIMEOUT && - iwpm_map_req->msg_type != IWARP_PM_REQ_ACK) { - /* the request is still incomplete, retransmit the message (every 1sec) */ - add_iwpm_pending_msg(iwpm_map_req->send_msg); - - iwpm_debug(IWARP_PM_RETRY_DBG, "mapping_reqs_handler: " - "Going to retransmit a msg, map request " - "(assochandle = %llu, type = %u, timeout = %d)\n", - iwpm_map_req->assochandle, iwpm_map_req->msg_type, - iwpm_map_req->timeout); - } - iwpm_map_req->timeout--; /* hang around for 10s */ - } else { - remove_iwpm_map_request(iwpm_map_req); - } - } - pthread_mutex_unlock(&map_req_mutex); - sleep(1); - } while (!list_empty(&mapping_reqs)); - } -mapping_reqs_handler_exit: - return NULL; -} - -/** - * iwpm_pending_msgs_handler - Handle sending iwarp port mapper wire messages - */ -static void *iwpm_pending_msgs_handler(void *unused) -{ - iwpm_pending_msg *pending_msg; - iwpm_send_msg *send_msg; - int retries = IWPM_SEND_MSG_RETRIES; - int ret = 0; - - pthread_mutex_lock(&pending_msg_mutex); - while (1) { - /* wait until a new message is posted */ - ret = pthread_cond_wait(&cond_pending_msg, &pending_msg_mutex); - if (ret) { - syslog(LOG_WARNING, "pending_msgs_handler: " - "Condition wait failed (ret = %d)\n", ret); - pthread_mutex_unlock(&pending_msg_mutex); - goto pending_msgs_handler_exit; - } - - /* try sending out each pending message and remove it from the list */ - while ((pending_msg = list_pop(&pending_messages, - iwpm_pending_msg, entry))) { - retries = IWPM_SEND_MSG_RETRIES; - while (retries) { - send_msg = &pending_msg->send_msg; - /* send out the message */ - int bytes_sent = sendto(send_msg->pm_sock, (char *)&send_msg->data, - send_msg->length, 0, - (struct sockaddr *)&send_msg->dest_addr, - sizeof(send_msg->dest_addr)); - if (bytes_sent != send_msg->length) { - retries--; - syslog(LOG_WARNING, "pending_msgs_handler: " - "Could not send to PM Socket send_msg = %p, retries = %d\n", - send_msg, retries); - } else - retries = 0; /* no need to retry */ - } - free(pending_msg); - } - } - pthread_mutex_unlock(&pending_msg_mutex); - -pending_msgs_handler_exit: - return NULL; -} - -static int send_iwpm_error_msg(__u32, __u16, int, int); - -/* Register pid query - nlmsg attributes */ -static struct nla_policy reg_pid_policy[IWPM_NLA_REG_PID_MAX] = { - [IWPM_NLA_REG_PID_SEQ] = { .type = NLA_U32 }, - [IWPM_NLA_REG_IF_NAME] = { .type = NLA_STRING, - .maxlen = IWPM_IFNAME_SIZE }, - [IWPM_NLA_REG_IBDEV_NAME] = { .type = NLA_STRING, - .maxlen = IWPM_ULIBNAME_SIZE }, - [IWPM_NLA_REG_ULIB_NAME] = { .type = NLA_STRING, - .maxlen = IWPM_ULIBNAME_SIZE } -}; - -/** - * process_iwpm_register_pid - Service a client query for port mapper pid - * @req_nlh: netlink header of the received client message - * @client_idx: the index of the client (unique for each iwpm client) - * @nl_sock: netlink socket to send a message back to the client - * - * Process a query and send a response to the client which contains the iwpm pid - * nlmsg response attributes: - * IWPM_NLA_RREG_PID_SEQ - * IWPM_NLA_RREG_IBDEV_NAME - * IWPM_NLA_RREG_ULIB_NAME - * IWPM_NLA_RREG_ULIB_VER - * IWPM_NLA_RREG_PID_ERR - */ -static int process_iwpm_register_pid(struct nlmsghdr *req_nlh, int client_idx, int nl_sock) -{ - iwpm_client *client; - struct nlattr *nltb [IWPM_NLA_REG_PID_MAX]; - struct nl_msg *resp_nlmsg = NULL; - const char *ifname, *devname, *libname; - __u16 err_code = 0; - const char *msg_type = "Register Pid Request"; - const char *str_err; - int ret = -EINVAL; - - if (parse_iwpm_nlmsg(req_nlh, IWPM_NLA_REG_PID_MAX, reg_pid_policy, nltb, msg_type)) { - str_err = "Received Invalid nlmsg"; - err_code = IWPM_INVALID_NLMSG_ERR; - goto register_pid_error; - } - - ifname = (const char *)nla_get_string(nltb[IWPM_NLA_REG_IF_NAME]); - devname = (const char *)nla_get_string(nltb[IWPM_NLA_REG_IBDEV_NAME]); - libname = (const char *)nla_get_string(nltb[IWPM_NLA_REG_ULIB_NAME]); - - iwpm_debug(IWARP_PM_NETLINK_DBG, "process_register_pid: PID request from " - "IB device %s Ethernet device %s User library %s " - "(client idx = %d, msg seq = %u).\n", - devname, ifname, libname, client_idx, req_nlh->nlmsg_seq); - - /* register a first time client */ - client = &client_list[client_idx]; - if (!client->valid) { - memcpy(client->ibdevname, devname, IWPM_DEVNAME_SIZE); - memcpy(client->ifname, ifname, IWPM_IFNAME_SIZE); - memcpy(client->ulibname, libname, IWPM_ULIBNAME_SIZE); - client->valid = 1; - } else { /* check client info */ - if (strcmp(client->ulibname, libname)) { - str_err = "Incorrect library version"; - err_code = IWPM_USER_LIB_INFO_ERR; - goto register_pid_error; - } - } - resp_nlmsg = create_iwpm_nlmsg(req_nlh->nlmsg_type, client_idx); - if (!resp_nlmsg) { - ret = -ENOMEM; - str_err = "Unable to create nlmsg response"; - goto register_pid_error; - } - str_err = "Invalid nlmsg attribute"; - if ((ret = nla_put_u32(resp_nlmsg, IWPM_NLA_RREG_PID_SEQ, req_nlh->nlmsg_seq))) - goto register_pid_error; - if ((ret = nla_put_string(resp_nlmsg, IWPM_NLA_RREG_IBDEV_NAME, devname))) - goto register_pid_error; - if ((ret = nla_put_string(resp_nlmsg, IWPM_NLA_RREG_ULIB_NAME, iwpm_ulib_name))) - goto register_pid_error; - if ((ret = nla_put_u16(resp_nlmsg, IWPM_NLA_RREG_ULIB_VER, iwpm_version))) - goto register_pid_error; - if ((ret = nla_put_u16(resp_nlmsg, IWPM_NLA_RREG_PID_ERR, err_code))) - goto register_pid_error; - - if ((ret = send_iwpm_nlmsg(nl_sock, resp_nlmsg, req_nlh->nlmsg_pid))) { - str_err = "Unable to send nlmsg response"; - goto register_pid_error; - } - nlmsg_free(resp_nlmsg); - return 0; -register_pid_error: - if (resp_nlmsg) - nlmsg_free(resp_nlmsg); - syslog(LOG_WARNING, "process_register_pid: %s ret = %d.\n", str_err, ret); - if (err_code) - send_iwpm_error_msg(req_nlh->nlmsg_seq, err_code, client_idx, nl_sock); - return ret; -} - -/* Add mapping request - nlmsg attributes */ -static struct nla_policy manage_map_policy[IWPM_NLA_MANAGE_MAPPING_MAX] = { - [IWPM_NLA_MANAGE_MAPPING_SEQ] = { .type = NLA_U32 }, - [IWPM_NLA_MANAGE_ADDR] = { .minlen = sizeof(struct sockaddr_storage) } -}; - -/** - * process_iwpm_add_mapping - Service a client request for mapping of a local address - * @req_nlh: netlink header of the received client message - * @client_idx: the index of the client (unique for each iwpm client) - * @nl_sock: netlink socket to send a message back to the client - * - * Process a mapping request for a local address and send a response to the client - * which contains the mapped local address (IP address and TCP port) - * nlmsg response attributes: - * [IWPM_NLA_MANAGE_MAPPING_SEQ] - * [IWPM_NLA_MANAGE_ADDR] - * [IWPM_NLA_MANAGE_MAPPED_LOC_ADDR] - * [IWPM_NLA_RMANAGE_MAPPING_ERR] - */ -static int process_iwpm_add_mapping(struct nlmsghdr *req_nlh, int client_idx, int nl_sock) -{ - iwpm_mapped_port *iwpm_port = NULL; - struct nlattr *nltb [IWPM_NLA_MANAGE_MAPPING_MAX]; - struct nl_msg *resp_nlmsg = NULL; - struct sockaddr_storage *local_addr; - int not_mapped = 1; - __u16 err_code = 0; - const char *msg_type = "Add Mapping Request"; - const char *str_err = ""; - int ret = -EINVAL, ref_cnt; - - if (parse_iwpm_nlmsg(req_nlh, IWPM_NLA_MANAGE_MAPPING_MAX, manage_map_policy, nltb, msg_type)) { - err_code = IWPM_INVALID_NLMSG_ERR; - str_err = "Received Invalid nlmsg"; - goto add_mapping_error; - } - local_addr = (struct sockaddr_storage *)nla_data(nltb[IWPM_NLA_MANAGE_ADDR]); - - iwpm_port = find_iwpm_mapping(local_addr, not_mapped); - if (iwpm_port) { - if (check_same_sockaddr(local_addr, &iwpm_port->local_addr) && iwpm_port->wcard) { - iwpm_port->ref_cnt++; - } else { - err_code = IWPM_DUPLICATE_MAPPING_ERR; - str_err = "Duplicate mapped port"; - goto add_mapping_error; - } - - } else { - iwpm_port = create_iwpm_mapped_port(local_addr, client_idx); - if (!iwpm_port) { - err_code = IWPM_CREATE_MAPPING_ERR; - str_err = "Unable to create new mapping"; - goto add_mapping_error; - } - } - resp_nlmsg = create_iwpm_nlmsg(req_nlh->nlmsg_type, client_idx); - if (!resp_nlmsg) { - ret = -ENOMEM; - str_err = "Unable to create nlmsg response"; - goto add_mapping_free_error; - } - str_err = "Invalid nlmsg attribute"; - if ((ret = nla_put_u32(resp_nlmsg, IWPM_NLA_MANAGE_MAPPING_SEQ, req_nlh->nlmsg_seq))) - goto add_mapping_free_error; - if ((ret = nla_put(resp_nlmsg, IWPM_NLA_MANAGE_ADDR, - sizeof(struct sockaddr_storage), &iwpm_port->local_addr))) - goto add_mapping_free_error; - if ((ret = nla_put(resp_nlmsg, IWPM_NLA_MANAGE_MAPPED_LOC_ADDR, - sizeof(struct sockaddr_storage), &iwpm_port->mapped_addr))) - goto add_mapping_free_error; - if ((ret = nla_put_u16(resp_nlmsg, IWPM_NLA_RMANAGE_MAPPING_ERR, err_code))) - goto add_mapping_free_error; - - if ((ret = send_iwpm_nlmsg(nl_sock, resp_nlmsg, req_nlh->nlmsg_pid))) { - str_err = "Unable to send nlmsg response"; - goto add_mapping_free_error; - } - /* add the new mapping to the list */ - add_iwpm_mapped_port(iwpm_port); - nlmsg_free(resp_nlmsg); - return 0; - -add_mapping_free_error: - if (resp_nlmsg) - nlmsg_free(resp_nlmsg); - if (iwpm_port) { - if (iwpm_port->wcard) { - ref_cnt = free_iwpm_wcard_mapping(iwpm_port); - if (ref_cnt) - goto add_mapping_error; - } - free_iwpm_port(iwpm_port); - } -add_mapping_error: - syslog(LOG_WARNING, "process_add_mapping: %s (failed request from client = %s).\n", - str_err, client_list[client_idx].ibdevname); - if (err_code) { - /* send error message to the client */ - send_iwpm_error_msg(req_nlh->nlmsg_seq, err_code, client_idx, nl_sock); - } - return ret; -} - -/* Query mapping request - nlmsg attributes */ -static struct nla_policy query_map_policy[IWPM_NLA_QUERY_MAPPING_MAX] = { - [IWPM_NLA_QUERY_MAPPING_SEQ] = { .type = NLA_U32 }, - [IWPM_NLA_QUERY_LOCAL_ADDR] = { .minlen = sizeof(struct sockaddr_storage) }, - [IWPM_NLA_QUERY_REMOTE_ADDR] = { .minlen = sizeof(struct sockaddr_storage) } -}; - -/** - * process_iwpm_query_mapping - Service a client request for local and remote mapping - * @req_nlh: netlink header of the received client message - * @client_idx: the index of the client (the index is unique for each iwpm client) - * @nl_sock: netlink socket to send a message back to the client - * - * Process a client request for local and remote address mapping - * Create mapping for the local address (IP address and TCP port) - * Send a request to the remote port mapper peer to find out the remote address mapping - */ -static int process_iwpm_query_mapping(struct nlmsghdr *req_nlh, int client_idx, int nl_sock) -{ - iwpm_mapped_port *iwpm_port = NULL; - iwpm_mapping_request *iwpm_map_req = NULL; - struct nlattr *nltb [IWPM_NLA_QUERY_MAPPING_MAX]; - struct sockaddr_storage *local_addr, *remote_addr; - sockaddr_union dest_addr; - iwpm_msg_parms msg_parms; - iwpm_send_msg *send_msg = NULL; - int pm_client_sock; - int not_mapped = 1; - __u16 err_code = 0; - const char *msg_type = "Add & Query Mapping Request"; - const char *str_err = ""; - int ret = -EINVAL; - - if (parse_iwpm_nlmsg(req_nlh, IWPM_NLA_QUERY_MAPPING_MAX, query_map_policy, nltb, msg_type)) { - err_code = IWPM_INVALID_NLMSG_ERR; - str_err = "Received Invalid nlmsg"; - goto query_mapping_error; - } - local_addr = (struct sockaddr_storage *)nla_data(nltb[IWPM_NLA_QUERY_LOCAL_ADDR]); - remote_addr = (struct sockaddr_storage *)nla_data(nltb[IWPM_NLA_QUERY_REMOTE_ADDR]); - - iwpm_port = find_iwpm_mapping(local_addr, not_mapped); - if (iwpm_port) { - err_code = IWPM_DUPLICATE_MAPPING_ERR; - str_err = "Duplicate mapped port"; - goto query_mapping_error; - } - iwpm_port = create_iwpm_mapped_port(local_addr, client_idx); - if (!iwpm_port) { - err_code = IWPM_CREATE_MAPPING_ERR; - str_err = "Unable to create new mapping"; - goto query_mapping_error; - } - if (iwpm_port->wcard) { - err_code = IWPM_CREATE_MAPPING_ERR; - str_err = "Invalid wild card mapping"; - goto query_mapping_free_error; - } - /* create iwpm wire message */ - memcpy(&dest_addr.s_sockaddr, remote_addr, sizeof(struct sockaddr_storage)); - switch (dest_addr.s_sockaddr.ss_family) { - case AF_INET: - dest_addr.v4_sockaddr.sin_port = htobe16(IWARP_PM_PORT); - msg_parms.ip_ver = 4; - msg_parms.address_family = AF_INET; - pm_client_sock = pmv4_client_sock; - break; - case AF_INET6: - dest_addr.v6_sockaddr.sin6_port = htobe16(IWARP_PM_PORT); - msg_parms.ip_ver = 6; - msg_parms.address_family = AF_INET6; - pm_client_sock = pmv6_client_sock; - break; - default: - str_err = "Invalid Internet address family"; - goto query_mapping_free_error; - } - /* fill in the remote peer address and the local mapped address */ - copy_iwpm_sockaddr(dest_addr.s_sockaddr.ss_family, remote_addr, NULL, NULL, - &msg_parms.apipaddr[0], &msg_parms.apport); - copy_iwpm_sockaddr(dest_addr.s_sockaddr.ss_family, local_addr, NULL, NULL, - &msg_parms.cpipaddr[0], &msg_parms.cpport); - copy_iwpm_sockaddr(dest_addr.s_sockaddr.ss_family, &iwpm_port->mapped_addr, NULL, NULL, - &msg_parms.mapped_cpipaddr[0], &msg_parms.mapped_cpport); - msg_parms.pmtime = 0; - msg_parms.ver = 0; - iwpm_debug(IWARP_PM_WIRE_DBG, "process_query_mapping: Local port = 0x%04X, " - "remote port = 0x%04X\n", - be16toh(msg_parms.cpport), be16toh(msg_parms.apport)); - ret = -ENOMEM; - send_msg = (iwpm_send_msg *)malloc(sizeof(iwpm_send_msg)); - if (!send_msg) { - str_err = "Unable to allocate send msg buffer"; - goto query_mapping_free_error; - } - iwpm_map_req = create_iwpm_map_request(req_nlh, &iwpm_port->local_addr, remote_addr, 0, - IWARP_PM_REQ_QUERY, send_msg); - if (!iwpm_map_req) { - str_err = "Unable to allocate mapping request"; - goto query_mapping_free_error; - } - msg_parms.assochandle = iwpm_map_req->assochandle; - form_iwpm_request(&send_msg->data, &msg_parms); - form_iwpm_send_msg(pm_client_sock, &dest_addr.s_sockaddr, msg_parms.msize, send_msg); - - add_iwpm_map_request(iwpm_map_req); - add_iwpm_mapped_port(iwpm_port); - return send_iwpm_msg(form_iwpm_request, &msg_parms, &dest_addr.s_sockaddr, pm_client_sock); -query_mapping_free_error: - if (iwpm_port) - free_iwpm_port(iwpm_port); - if (send_msg) - free(send_msg); - if (iwpm_map_req) - free(iwpm_map_req); -query_mapping_error: - syslog(LOG_WARNING, "process_query_mapping: %s (failed request from client = %s).\n", - str_err, client_list[client_idx].ibdevname); - if (err_code) { - /* send error message to the client */ - send_iwpm_error_msg(req_nlh->nlmsg_seq, err_code, client_idx, nl_sock); - } - return ret; -} - -/** - * process_iwpm_remove_mapping - Remove a local mapping and close the mapped TCP port - * @req_nlh: netlink header of the received client message - * @client_idx: the index of the client (the index is unique for each iwpm client) - * @nl_sock: netlink socket to send a message to the client - */ -static int process_iwpm_remove_mapping(struct nlmsghdr *req_nlh, int client_idx, int nl_sock) -{ - iwpm_mapped_port *iwpm_port = NULL; - struct sockaddr_storage *local_addr; - struct nlattr *nltb [IWPM_NLA_MANAGE_MAPPING_MAX]; - int not_mapped = 1; - const char *msg_type = "Remove Mapping Request"; - int ret = 0, ref_cnt; - - if (parse_iwpm_nlmsg(req_nlh, IWPM_NLA_MANAGE_MAPPING_MAX, manage_map_policy, nltb, msg_type)) { - send_iwpm_error_msg(req_nlh->nlmsg_seq, IWPM_INVALID_NLMSG_ERR, client_idx, nl_sock); - syslog(LOG_WARNING, "process_remove_mapping: Received Invalid nlmsg from client = %d\n", - client_idx); - ret = -EINVAL; - goto remove_mapping_exit; - } - local_addr = (struct sockaddr_storage *)nla_data(nltb[IWPM_NLA_MANAGE_ADDR]); - iwpm_debug(IWARP_PM_NETLINK_DBG, "process_remove_mapping: Going to remove mapping" - " (client idx = %d)\n", client_idx); - - iwpm_port = find_iwpm_same_mapping(local_addr, not_mapped); - if (!iwpm_port) { - iwpm_debug(IWARP_PM_NETLINK_DBG, "process_remove_mapping: Unable to find mapped port object\n"); - print_iwpm_sockaddr(local_addr, "process_remove_mapping: Local address", IWARP_PM_ALL_DBG); - /* the client sends a remove mapping request when terminating a connection - and it is possible that there isn't a successful mapping for this connection */ - goto remove_mapping_exit; - } - if (iwpm_port->owner_client != client_idx) { - syslog(LOG_WARNING, "process_remove_mapping: Invalid request from client = %d\n", - client_idx); - goto remove_mapping_exit; - } - if (iwpm_port->wcard) { - ref_cnt = free_iwpm_wcard_mapping(iwpm_port); - if (ref_cnt) - goto remove_mapping_exit; - } - remove_iwpm_mapped_port(iwpm_port); - free_iwpm_port(iwpm_port); -remove_mapping_exit: - return ret; -} - -static int send_conn_info_nlmsg(struct sockaddr_storage *local_addr, - struct sockaddr_storage *remote_addr, - struct sockaddr_storage *mapped_loc_addr, - struct sockaddr_storage *mapped_rem_addr, - int owner_client, __u16 nlmsg_type, __u32 nlmsg_seq, - __u32 nlmsg_pid, __u16 nlmsg_err, int nl_sock) - -{ - struct nl_msg *resp_nlmsg = NULL; - const char *str_err; - int ret; - - resp_nlmsg = create_iwpm_nlmsg(nlmsg_type, owner_client); - if (!resp_nlmsg) { - str_err = "Unable to create nlmsg response"; - ret = -ENOMEM; - goto nlmsg_error; - } - str_err = "Invalid nlmsg attribute"; - if ((ret = nla_put_u32(resp_nlmsg, IWPM_NLA_QUERY_MAPPING_SEQ, nlmsg_seq))) - goto nlmsg_free_error; - if ((ret = nla_put(resp_nlmsg, IWPM_NLA_QUERY_LOCAL_ADDR, - sizeof(struct sockaddr_storage), local_addr))) - goto nlmsg_free_error; - if ((ret = nla_put(resp_nlmsg, IWPM_NLA_QUERY_REMOTE_ADDR, - sizeof(struct sockaddr_storage), remote_addr))) - goto nlmsg_free_error; - if ((ret = nla_put(resp_nlmsg, IWPM_NLA_RQUERY_MAPPED_LOC_ADDR, - sizeof(struct sockaddr_storage), mapped_loc_addr))) - goto nlmsg_free_error; - if ((ret = nla_put(resp_nlmsg, IWPM_NLA_RQUERY_MAPPED_REM_ADDR, - sizeof(struct sockaddr_storage), mapped_rem_addr))) - goto nlmsg_free_error; - if ((ret = nla_put_u16(resp_nlmsg, IWPM_NLA_RQUERY_MAPPING_ERR, nlmsg_err))) - goto nlmsg_free_error; - - if ((ret = send_iwpm_nlmsg(nl_sock, resp_nlmsg, nlmsg_pid))) { - str_err = "Unable to send nlmsg response"; - goto nlmsg_free_error; - } - nlmsg_free(resp_nlmsg); - return 0; -nlmsg_free_error: - if (resp_nlmsg) - nlmsg_free(resp_nlmsg); -nlmsg_error: - syslog(LOG_WARNING, "send_conn_info_nlmsg: %s.\n", str_err); - return ret; -} - -/** - * process_iwpm_wire_request - Process a mapping query from remote port mapper peer - * @msg_parms: the received iwpm request message - * @recv_addr: address of the remote peer - * @pm_sock: socket handle to send a response to the remote iwpm peer - * - * Look up the accepting peer local address to find the corresponding mapping, - * send reject message to the remote connecting peer, if no mapping is found, - * otherwise, send accept message with the accepting peer mapping info - */ -static int process_iwpm_wire_request(iwpm_msg_parms *msg_parms, int nl_sock, - struct sockaddr_storage *recv_addr, int pm_sock) -{ - iwpm_mapped_port *iwpm_port; - iwpm_mapping_request *iwpm_map_req = NULL; - iwpm_mapping_request iwpm_copy_req; - iwpm_send_msg *send_msg = NULL; - struct sockaddr_storage local_addr, mapped_loc_addr; - struct sockaddr_storage remote_addr, mapped_rem_addr; - __u16 nlmsg_type; - int not_mapped = 1; - int ret = 0; - - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &local_addr, - &msg_parms->apipaddr[0], NULL, &msg_parms->apport); - iwpm_port = find_iwpm_mapping(&local_addr, not_mapped); - if (!iwpm_port) { - /* could not find mapping for the requested address */ - iwpm_debug(IWARP_PM_WIRE_DBG, "process_wire_request: " - "Sending Reject to port mapper peer.\n"); - print_iwpm_sockaddr(&local_addr, "process_wire_request: Local address", - IWARP_PM_ALL_DBG); - return send_iwpm_msg(form_iwpm_reject, msg_parms, recv_addr, pm_sock); - } - /* record mapping in the accept message */ - if (iwpm_port->wcard) - msg_parms->apport = get_sockaddr_port(&iwpm_port->mapped_addr); - else - copy_iwpm_sockaddr(msg_parms->address_family, &iwpm_port->mapped_addr, - NULL, NULL, &msg_parms->apipaddr[0], &msg_parms->apport); - - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &mapped_loc_addr, - &msg_parms->apipaddr[0], NULL, &msg_parms->apport); - - /* check if there is already a request */ - ret = update_iwpm_map_request(msg_parms->assochandle, &mapped_loc_addr, - IWARP_PM_REQ_ACCEPT, &iwpm_copy_req, 0); - if (!ret) { /* found request */ - iwpm_debug(IWARP_PM_WIRE_DBG,"process_wire_request: Detected retransmission " - "map request (assochandle = %llu type = %d timeout = %u complete = %d)\n", - iwpm_copy_req.assochandle, iwpm_copy_req.msg_type, - iwpm_copy_req.timeout, iwpm_copy_req.complete); - return 0; - } - /* allocate response message */ - send_msg = (iwpm_send_msg *)malloc(sizeof(iwpm_send_msg)); - if (!send_msg) { - syslog(LOG_WARNING, "process_wire_request: Unable to allocate send msg.\n"); - return -ENOMEM; - } - form_iwpm_accept(&send_msg->data, msg_parms); - form_iwpm_send_msg(pm_sock, recv_addr, msg_parms->msize, send_msg); - - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &remote_addr, - &msg_parms->cpipaddr[0], NULL, &msg_parms->cpport); - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &mapped_rem_addr, - &msg_parms->mapped_cpipaddr[0], NULL, &msg_parms->mapped_cpport); - - iwpm_map_req = create_iwpm_map_request(NULL, &mapped_loc_addr, &remote_addr, - msg_parms->assochandle, IWARP_PM_REQ_ACCEPT, send_msg); - if (!iwpm_map_req) { - syslog(LOG_WARNING, "process_wire_request: Unable to allocate mapping request.\n"); - free(send_msg); - return -ENOMEM; - } - add_iwpm_map_request(iwpm_map_req); - ret = send_iwpm_msg(form_iwpm_accept, msg_parms, recv_addr, pm_sock); - if (ret) { - syslog(LOG_WARNING, "process_wire_request: Unable to allocate accept message.\n"); - return ret; - } - nlmsg_type = RDMA_NL_GET_TYPE(iwpm_port->owner_client, RDMA_NL_IWPM_REMOTE_INFO); - ret = send_conn_info_nlmsg(&iwpm_port->local_addr, &remote_addr, - &iwpm_port->mapped_addr, &mapped_rem_addr, - iwpm_port->owner_client, nlmsg_type, 0, 0, 0, nl_sock); - return ret; -} - -/** - * process_iwpm_wire_accept - Process accept message from the remote port mapper peer - * @msg_parms: the received iwpm accept message, containing the remote peer mapping info - * @nl_sock: netlink socket to send a message to the iwpm client - * @recv_addr: address of the remote peer - * @pm_sock: socket handle to send ack message back to the remote peer - * - * Send acknowledgement to the remote/accepting peer, - * send a netlink message with the local and remote mapping info to the iwpm client - * nlmsg response attributes: - * [IWPM_NLA_QUERY_MAPPING_SEQ] - * [IWPM_NLA_QUERY_LOCAL_ADDR] - * [IWPM_NLA_QUERY_REMOTE_ADDR] - * [IWPM_NLA_RQUERY_MAPPED_LOC_ADDR] - * [IWPM_NLA_RQUERY_MAPPED_REM_ADDR] - * [IWPM_NLA_RQUERY_MAPPING_ERR] - */ -static int process_iwpm_wire_accept(iwpm_msg_parms *msg_parms, int nl_sock, - struct sockaddr_storage *recv_addr, int pm_sock) -{ - iwpm_mapping_request iwpm_map_req; - iwpm_mapping_request *iwpm_retry_req = NULL; - iwpm_mapped_port *iwpm_port; - struct sockaddr_storage local_addr, remote_mapped_addr; - int not_mapped = 1; - const char *str_err; - int ret; - - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &local_addr, - &msg_parms->cpipaddr[0], NULL, &msg_parms->cpport); - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &remote_mapped_addr, - &msg_parms->apipaddr[0], NULL, &msg_parms->apport); - ret = -EINVAL; - iwpm_port = find_iwpm_same_mapping(&local_addr, not_mapped); - if (!iwpm_port) { - iwpm_debug(IWARP_PM_WIRE_DBG, "process_wire_accept: " - "Received accept for unknown mapping.\n"); - return 0; - } - /* there should be a request for the accept message */ - ret = update_iwpm_map_request(msg_parms->assochandle, &iwpm_port->local_addr, - (IWARP_PM_REQ_QUERY|IWARP_PM_REQ_ACK), &iwpm_map_req, 1); - if (ret) { - iwpm_debug(IWARP_PM_WIRE_DBG, "process_wire_accept: " - "No matching mapping request (assochandle = %llu)\n", - msg_parms->assochandle); - return 0; /* ok when retransmission */ - } - if (iwpm_map_req.complete) - return 0; - /* if the accept has already been processed and this is retransmission */ - if (iwpm_map_req.msg_type == IWARP_PM_REQ_ACK) { - iwpm_debug(IWARP_PM_RETRY_DBG, "process_wire_accept: Detected retransmission " - "(map request assochandle = %llu)\n", iwpm_map_req.assochandle); - goto wire_accept_send_ack; - } - ret = send_conn_info_nlmsg(&iwpm_port->local_addr, &iwpm_map_req.remote_addr, - &iwpm_port->mapped_addr, &remote_mapped_addr, - iwpm_port->owner_client, iwpm_map_req.nlmsg_type, - iwpm_map_req.nlmsg_seq, iwpm_map_req.nlmsg_pid, 0, nl_sock); - if (ret) { - str_err = "Unable to send nlmsg response"; - goto wire_accept_error; - } - /* object to detect retransmission */ - iwpm_retry_req = create_iwpm_map_request(NULL, &iwpm_map_req.src_addr, &iwpm_map_req.remote_addr, - iwpm_map_req.assochandle, IWARP_PM_REQ_ACK, NULL); - if (!iwpm_retry_req) { - ret = -ENOMEM; - str_err = "Unable to allocate retry request"; - goto wire_accept_error; - } - add_iwpm_map_request(iwpm_retry_req); -wire_accept_send_ack: - return send_iwpm_msg(form_iwpm_ack, msg_parms, recv_addr, pm_sock); -wire_accept_error: - syslog(LOG_WARNING, "process_iwpm_wire_accept: %s.\n", str_err); - return ret; -} - -/** - * process_iwpm_wire_reject - Process reject message from the port mapper remote peer - * @msg_parms: the received iwpm reject message - * @nl_sock: netlink socket to send through a message to the iwpm client - * - * Send notification to the iwpm client that its - * mapping request is rejected by the remote/accepting port mapper peer - */ -static int process_iwpm_wire_reject(iwpm_msg_parms *msg_parms, int nl_sock) -{ - iwpm_mapping_request iwpm_map_req; - iwpm_mapped_port *iwpm_port; - struct sockaddr_storage local_addr, remote_addr; - int not_mapped = 1; - __u16 err_code = IWPM_REMOTE_QUERY_REJECT; - const char *str_err; - int ret = -EINVAL; - - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &local_addr, - &msg_parms->cpipaddr[0], NULL, &msg_parms->cpport); - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &remote_addr, - &msg_parms->apipaddr[0], NULL, &msg_parms->apport); - - print_iwpm_sockaddr(&local_addr, "process_wire_reject: Local address", - IWARP_PM_ALL_DBG); - print_iwpm_sockaddr(&remote_addr, "process_wire_reject: Remote address", - IWARP_PM_ALL_DBG); - ret = -EINVAL; - iwpm_port = find_iwpm_same_mapping(&local_addr, not_mapped); - if (!iwpm_port) { - syslog(LOG_WARNING, "process_wire_reject: Received reject for unknown mapping.\n"); - return 0; - } - /* make sure there is request posted */ - ret = update_iwpm_map_request(msg_parms->assochandle, &iwpm_port->local_addr, - IWARP_PM_REQ_QUERY, &iwpm_map_req, 1); - if (ret) { - iwpm_debug(IWARP_PM_WIRE_DBG, "process_wire_reject: " - "No matching mapping request (assochandle = %llu)\n", - msg_parms->assochandle); - return 0; /* ok when retransmission */ - } - if (iwpm_map_req.complete) - return 0; - - ret = send_conn_info_nlmsg(&iwpm_port->local_addr, &iwpm_map_req.remote_addr, - &iwpm_port->mapped_addr, &iwpm_map_req.remote_addr, - iwpm_port->owner_client, iwpm_map_req.nlmsg_type, - iwpm_map_req.nlmsg_seq, iwpm_map_req.nlmsg_pid, err_code, nl_sock); - if (ret) { - str_err = "Unable to send nlmsg response"; - goto wire_reject_error; - } - return 0; -wire_reject_error: - syslog(LOG_WARNING, "process_wire_reject: %s.\n", str_err); - return ret; -} - -/** - * process_iwpm_wire_ack - Process acknowledgement from the remote port mapper peer - * @msg_parms: received iwpm acknowledgement - */ -static int process_iwpm_wire_ack(iwpm_msg_parms *msg_parms) -{ - iwpm_mapped_port *iwpm_port; - iwpm_mapping_request iwpm_map_req; - struct sockaddr_storage local_mapped_addr; - int not_mapped = 0; - int ret; - - copy_iwpm_sockaddr(msg_parms->address_family, NULL, &local_mapped_addr, - &msg_parms->apipaddr[0], NULL, &msg_parms->apport); - iwpm_port = find_iwpm_mapping(&local_mapped_addr, not_mapped); - if (!iwpm_port) { - iwpm_debug(IWARP_PM_WIRE_DBG, "process_wire_ack: Received ack for unknown mapping.\n"); - return 0; - } - /* make sure there is accept for the ack */ - ret = update_iwpm_map_request(msg_parms->assochandle, &local_mapped_addr, - IWARP_PM_REQ_ACCEPT, &iwpm_map_req, 1); - if (ret) - iwpm_debug(IWARP_PM_WIRE_DBG, "process_wire_ack: No matching mapping request\n"); - return 0; -} - -/* Mapping info message - nlmsg attributes */ -static struct nla_policy mapinfo_policy[IWPM_NLA_MAPINFO_MAX] = { - [IWPM_NLA_MAPINFO_LOCAL_ADDR] = { .minlen = sizeof(struct sockaddr_storage) }, - [IWPM_NLA_MAPINFO_MAPPED_ADDR] = { .minlen = sizeof(struct sockaddr_storage) } -}; - -/** - * process_iwpm_mapinfo - Process a mapping info message from the port mapper client - * @req_nlh: netlink header of the received client message - * @client_idx: the index of the client (the index is unique for each iwpm client) - * @nl_sock: netlink socket to send a message to the client - * - * In case the userspace iwarp port mapper daemon is restarted, - * the iwpm client needs to send a record of mappings it is currently using. - * The port mapper needs to reopen the mapped ports used by the client. - */ -static int process_iwpm_mapinfo(struct nlmsghdr *req_nlh, int client_idx, int nl_sock) -{ - iwpm_mapped_port *iwpm_port = NULL; - struct sockaddr_storage *local_addr, *local_mapped_addr; - struct nlattr *nltb [IWPM_NLA_MAPINFO_MAX]; - int not_mapped = 1; - __u16 err_code = 0; - const char *msg_type = "Mapping Info Msg"; - const char *str_err = ""; - int ret = -EINVAL; - - if (parse_iwpm_nlmsg(req_nlh, IWPM_NLA_MAPINFO_MAX, mapinfo_policy, nltb, msg_type)) { - err_code = IWPM_INVALID_NLMSG_ERR; - str_err = "Received Invalid nlmsg"; - goto process_mapinfo_error; - } - local_addr = (struct sockaddr_storage *)nla_data(nltb[IWPM_NLA_MAPINFO_LOCAL_ADDR]); - local_mapped_addr = (struct sockaddr_storage *)nla_data(nltb[IWPM_NLA_MAPINFO_MAPPED_ADDR]); - - iwpm_port = find_iwpm_mapping(local_addr, not_mapped); - if (iwpm_port) { - /* Can be safely ignored, if the mapinfo is exactly the same, - * because the client will provide all the port information it has and - * it could have started using the port mapper service already */ - if (check_same_sockaddr(&iwpm_port->local_addr, local_addr) && - check_same_sockaddr(&iwpm_port->mapped_addr, local_mapped_addr)) - goto process_mapinfo_exit; - - /* partial duplicates matching wcard ip address aren't allowed as well */ - err_code = IWPM_DUPLICATE_MAPPING_ERR; - str_err = "Duplicate mapped port"; - goto process_mapinfo_error; - } - iwpm_port = reopen_iwpm_mapped_port(local_addr, local_mapped_addr, client_idx); - if (!iwpm_port) { - err_code = IWPM_CREATE_MAPPING_ERR; - str_err = "Unable to create new mapping"; - goto process_mapinfo_error; - } - /* add the new mapping to the list */ - add_iwpm_mapped_port(iwpm_port); -process_mapinfo_exit: - mapinfo_num_list[client_idx]++; - return 0; -process_mapinfo_error: - syslog(LOG_WARNING, "process_mapinfo: %s.\n", str_err); - if (err_code) { - /* send error message to the client */ - send_iwpm_error_msg(req_nlh->nlmsg_seq, err_code, client_idx, nl_sock); - } - return ret; -} - -/* Mapping info message count - nlmsg attributes */ -static struct nla_policy mapinfo_count_policy[IWPM_NLA_MAPINFO_SEND_MAX] = { - [IWPM_NLA_MAPINFO_SEQ] = { .type = NLA_U32 }, - [IWPM_NLA_MAPINFO_SEND_NUM] = { .type = NLA_U32 } -}; - -/** - * process_iwpm_mapinfo_count - Process mapinfo count message - * @req_nlh: netlink header of the received message from the client - * @client_idx: the index of the client - * @nl_sock: netlink socket to send a message to the client - * - * Mapinfo count message is a mechanism for the port mapper and the client to - * synchronize on the number of mapinfo messages which were sucessfully exchanged and processed - */ -static int process_iwpm_mapinfo_count(struct nlmsghdr *req_nlh, int client_idx, int nl_sock) -{ - struct nlattr *nltb [IWPM_NLA_MAPINFO_SEND_MAX]; - struct nl_msg *resp_nlmsg = NULL; - const char *msg_type = "Number of Mappings Msg"; - __u32 map_count; - __u16 err_code = 0; - const char *str_err = ""; - int ret = -EINVAL; - - if (parse_iwpm_nlmsg(req_nlh, IWPM_NLA_MAPINFO_SEND_MAX, - mapinfo_count_policy, nltb, msg_type)) { - str_err = "Received Invalid nlmsg"; - err_code = IWPM_INVALID_NLMSG_ERR; - goto mapinfo_count_error; - } - map_count = nla_get_u32(nltb[IWPM_NLA_MAPINFO_SEND_NUM]); - if (map_count != mapinfo_num_list[client_idx]) - iwpm_debug(IWARP_PM_NETLINK_DBG, "get_mapinfo_count: Client (idx = %d) " - "send mapinfo count = %u processed mapinfo count = %u.\n", - client_idx, map_count, mapinfo_num_list[client_idx]); - - resp_nlmsg = create_iwpm_nlmsg(req_nlh->nlmsg_type, client_idx); - if (!resp_nlmsg) { - str_err = "Unable to create nlmsg response"; - ret = -ENOMEM; - goto mapinfo_count_error; - } - str_err = "Invalid nlmsg attribute"; - if ((ret = nla_put_u32(resp_nlmsg, IWPM_NLA_MAPINFO_SEQ, req_nlh->nlmsg_seq))) - goto mapinfo_count_free_error; - if ((ret = nla_put_u32(resp_nlmsg, IWPM_NLA_MAPINFO_SEND_NUM, map_count))) - goto mapinfo_count_free_error; - if ((ret = nla_put_u32(resp_nlmsg, IWPM_NLA_MAPINFO_ACK_NUM, - mapinfo_num_list[client_idx]))) - goto mapinfo_count_free_error; - - if ((ret = send_iwpm_nlmsg(nl_sock, resp_nlmsg, req_nlh->nlmsg_pid))) { - str_err = "Unable to send nlmsg response"; - goto mapinfo_count_free_error; - } - nlmsg_free(resp_nlmsg); - return 0; -mapinfo_count_free_error: - if (resp_nlmsg) - nlmsg_free(resp_nlmsg); -mapinfo_count_error: - syslog(LOG_WARNING, "process_mapinfo_count: %s.\n", str_err); - if (err_code) { - /* send error message to the client */ - send_iwpm_error_msg(req_nlh->nlmsg_seq, err_code, client_idx, nl_sock); - } - return ret; -} - -/** - * send_iwpm_error_msg - Send error message to the iwpm client - * @seq: last received netlink message sequence - * @err_code: used to differentiante between errors - * @client_idx: the index of the client - * @nl_sock: netlink socket to send a message to the client - */ -static int send_iwpm_error_msg(__u32 seq, __u16 err_code, int client_idx, int nl_sock) -{ - struct nl_msg *resp_nlmsg; - __u16 nlmsg_type; - const char *str_err = ""; - int ret; - - nlmsg_type = RDMA_NL_GET_TYPE(client_idx, RDMA_NL_IWPM_HANDLE_ERR); - resp_nlmsg = create_iwpm_nlmsg(nlmsg_type, client_idx); - if (!resp_nlmsg) { - ret = -ENOMEM; - str_err = "Unable to create nlmsg response"; - goto send_error_msg_exit; - } - str_err = "Invalid nlmsg attribute"; - if ((ret = nla_put_u32(resp_nlmsg, IWPM_NLA_ERR_SEQ, seq))) - goto send_error_msg_exit; - if ((ret = nla_put_u16(resp_nlmsg, IWPM_NLA_ERR_CODE, err_code))) - goto send_error_msg_exit; - - if ((ret = send_iwpm_nlmsg(nl_sock, resp_nlmsg, 0))) { - str_err = "Unable to send nlmsg response"; - goto send_error_msg_exit; - } - nlmsg_free(resp_nlmsg); - return 0; -send_error_msg_exit: - if (resp_nlmsg) - nlmsg_free(resp_nlmsg); - syslog(LOG_WARNING, "send_iwpm_error_msg: %s (ret = %d).\n", str_err, ret); - return ret; -} - -/** - * process_iwpm_netlink_msg - Dispatch received netlink messages - * @nl_sock: netlink socket to read the messages from - */ -static int process_iwpm_netlink_msg(int nl_sock) -{ - char *recv_buffer = NULL; - struct nlmsghdr *nlh; - struct sockaddr_nl src_addr; - int len, type, client_idx, op; - socklen_t src_addr_len; - const char *str_err = ""; - int ret = 0; - - recv_buffer = (char *)malloc(NLMSG_SPACE(IWARP_PM_RECV_PAYLOAD)); - if (!recv_buffer) { - ret = -ENOMEM; - str_err = "Unable to allocate receive socket buffer"; - goto process_netlink_msg_exit; - } - /* receive a new message */ - nlh = (struct nlmsghdr *)recv_buffer; - memset(nlh, 0, NLMSG_SPACE(IWARP_PM_RECV_PAYLOAD)); - memset(&src_addr, 0, sizeof(src_addr)); - - src_addr_len = sizeof(src_addr); - len = recvfrom(nl_sock, (void *)nlh, NLMSG_SPACE(IWARP_PM_RECV_PAYLOAD), 0, - (struct sockaddr *)&src_addr, &src_addr_len); - if (len <= 0) { - ret = -errno; - str_err = "Unable to receive data from netlink socket"; - goto process_netlink_msg_exit; - } - /* loop for multiple netlink messages packed together */ - while (NLMSG_OK(nlh, len) != 0) { - if (nlh->nlmsg_type == NLMSG_DONE) { - goto process_netlink_msg_exit; - } - - if (nlh->nlmsg_type == NLMSG_ERROR) { - iwpm_debug(IWARP_PM_NETLINK_DBG, "process_netlink_msg: " - "Netlink error message seq = %u\n", nlh->nlmsg_seq); - goto process_netlink_msg_exit; - } - type = nlh->nlmsg_type; - client_idx = RDMA_NL_GET_CLIENT(type); - op = RDMA_NL_GET_OP(type); - iwpm_debug(IWARP_PM_NETLINK_DBG, "process_netlink_msg: Received a new message: " - "opcode = %u client idx = %u, client pid = %u," - " msg seq = %u, type = %u, length = %u.\n", - op, client_idx, nlh->nlmsg_pid, nlh->nlmsg_seq, type, len); - - if (client_idx >= IWARP_PM_MAX_CLIENTS) { - ret = -EINVAL; - str_err = "Invalid client index"; - goto process_netlink_msg_exit; - } - switch (op) { - case RDMA_NL_IWPM_REG_PID: - str_err = "Register Pid request"; - ret = process_iwpm_register_pid(nlh, client_idx, nl_sock); - break; - case RDMA_NL_IWPM_ADD_MAPPING: - str_err = "Add Mapping request"; - if (!client_list[client_idx].valid) { - ret = -EINVAL; - goto process_netlink_msg_exit; - } - ret = process_iwpm_add_mapping(nlh, client_idx, nl_sock); - break; - case RDMA_NL_IWPM_QUERY_MAPPING: - str_err = "Query Mapping request"; - if (!client_list[client_idx].valid) { - ret = -EINVAL; - goto process_netlink_msg_exit; - } - ret = process_iwpm_query_mapping(nlh, client_idx, nl_sock); - break; - case RDMA_NL_IWPM_REMOVE_MAPPING: - str_err = "Remove Mapping request"; - ret = process_iwpm_remove_mapping(nlh, client_idx, nl_sock); - break; - case RDMA_NL_IWPM_MAPINFO: - ret = process_iwpm_mapinfo(nlh, client_idx, nl_sock); - break; - case RDMA_NL_IWPM_MAPINFO_NUM: - ret = process_iwpm_mapinfo_count(nlh, client_idx, nl_sock); - break; - default: - str_err = "Netlink message with invalid opcode"; - ret = -1; - break; - } - nlh = NLMSG_NEXT(nlh, len); - if (ret) - goto process_netlink_msg_exit; - } - -process_netlink_msg_exit: - if (recv_buffer) - free(recv_buffer); - if (ret) - syslog(LOG_WARNING, "process_netlink_msg: %s error (ret = %d).\n", str_err, ret); - return ret; -} - -/** - * process_iwpm_msg - Dispatch iwpm wire messages, sent by the remote peer - * @pm_sock: socket handle to read the messages from - */ -static int process_iwpm_msg(int pm_sock) -{ - iwpm_msg_parms msg_parms; - struct sockaddr_storage recv_addr; - iwpm_wire_msg recv_buffer; /* received message */ - int bytes_recv, ret = 0; - int max_bytes_send = IWARP_PM_MESSAGE_SIZE + IWPM_IPADDR_SIZE; - socklen_t recv_addr_len = sizeof(recv_addr); - - bytes_recv = recvfrom(pm_sock, &recv_buffer, max_bytes_send, 0, - (struct sockaddr *)&recv_addr, &recv_addr_len); - - if (bytes_recv != IWARP_PM_MESSAGE_SIZE && bytes_recv != max_bytes_send) { - syslog(LOG_WARNING, - "process_iwpm_msg: Unable to receive data from PM socket. %s.\n", - strerror(errno)); - ret = -errno; - goto process_iwpm_msg_exit; - } - parse_iwpm_msg(&recv_buffer, &msg_parms); - - switch (msg_parms.mt) { - case IWARP_PM_MT_REQ: - iwpm_debug(IWARP_PM_WIRE_DBG, "process_iwpm_msg: Received Request message.\n"); - ret = process_iwpm_wire_request(&msg_parms, netlink_sock, &recv_addr, pm_sock); - break; - case IWARP_PM_MT_ACK: - iwpm_debug(IWARP_PM_WIRE_DBG, "process_iwpm_msg: Received Acknowledgement.\n"); - ret = process_iwpm_wire_ack(&msg_parms); - break; - case IWARP_PM_MT_ACC: - iwpm_debug(IWARP_PM_WIRE_DBG, "process_iwpm_msg: Received Accept message.\n"); - ret = process_iwpm_wire_accept(&msg_parms, netlink_sock, &recv_addr, pm_sock); - break; - case IWARP_PM_MT_REJ: - iwpm_debug(IWARP_PM_WIRE_DBG, "process_iwpm_msg: Received Reject message.\n"); - ret = process_iwpm_wire_reject(&msg_parms, netlink_sock); - break; - default: - syslog(LOG_WARNING, "process_iwpm_msg: Received Invalid message type = %u.\n", - msg_parms.mt); - } -process_iwpm_msg_exit: - return ret; -} - -/** - * init_iwpm_clients - Initialize the known clients of the iwarp port mapper - * @iwarp_clients - array of port mapper clients to init - * - * Return the number of known clients - */ -static int init_iwpm_clients(__u32 iwarp_clients[]) -{ - int client_num = 2; - - iwarp_clients[0] = RDMA_NL_IWCM; - iwarp_clients[1] = RDMA_NL_IWCM+1; /* Legacy RDMA_NL_C4IW for old kernels */ - - return client_num; -} - -/** - * send_iwpm_mapinfo_request - Notify the client that the iwarp port mapper is available - * @nl_sock: netlink socket to send a message to the client - * @iwarp_clients - array of port mapper clients to init - * @length - the length of the array - */ -static int send_iwpm_mapinfo_request(int nl_sock, __u32 *iwarp_clients, int length) -{ - struct nl_msg *req_nlmsg; - __u16 nlmsg_type; - int i; - const char *str_err; - int ret; - - for (i = 0; i < length; i++) { - nlmsg_type = RDMA_NL_GET_TYPE(iwarp_clients[i], RDMA_NL_IWPM_MAPINFO); - req_nlmsg = create_iwpm_nlmsg(nlmsg_type, iwarp_clients[i]); - if (!req_nlmsg) { - ret = -ENOMEM; - str_err = "Unable to create nlmsg request"; - goto send_mapinfo_error; - } - str_err = "Invalid nlmsg attribute"; - if ((ret = nla_put_string(req_nlmsg, IWPM_NLA_MAPINFO_ULIB_NAME, iwpm_ulib_name))) - goto send_mapinfo_error; - if ((ret = nla_put_u16(req_nlmsg, IWPM_NLA_MAPINFO_ULIB_VER, iwpm_version))) - goto send_mapinfo_error; - - if ((ret = send_iwpm_nlmsg(nl_sock, req_nlmsg, 0))) { - str_err = "Unable to send nlmsg response"; - goto send_mapinfo_error; - } - nlmsg_free(req_nlmsg); - } - return 0; -send_mapinfo_error: - if (req_nlmsg) - nlmsg_free(req_nlmsg); - syslog(LOG_WARNING, "send_mapinfo_request: %s ret = %d.\n", str_err, ret); - return ret; -} - -/** iwpm_cleanup - Close socket handles and free mapped ports */ -static void iwpm_cleanup(void) -{ - free_iwpm_mapped_ports(); - - destroy_iwpm_socket(netlink_sock); - destroy_iwpm_socket(pmv6_client_sock); - destroy_iwpm_socket(pmv6_sock); - destroy_iwpm_socket(pmv4_client_sock); - destroy_iwpm_socket(pmv4_sock); - /* close up logging */ - closelog(); -} - -/** - * iwarp_port_mapper - Distribute work orders for processing different types of iwpm messages - */ -static int iwarp_port_mapper(void) -{ - fd_set select_fdset; /* read fdset */ - struct timeval select_timeout; - int select_rc, max_sock = 0, ret = 0; - - if (pmv4_sock > max_sock) - max_sock = pmv4_sock; - if (pmv6_sock > max_sock) - max_sock = pmv6_sock; - if (netlink_sock > max_sock) - max_sock = netlink_sock; - if (pmv4_client_sock > max_sock) - max_sock = pmv4_client_sock; - if (pmv6_client_sock > max_sock) - max_sock = pmv6_client_sock; - - /* poll a set of sockets */ - do { - do { - if (print_mappings) { - print_iwpm_mapped_ports(); - print_mappings = 0; - } - /* initialize the file sets for select */ - FD_ZERO(&select_fdset); - /* add the UDP and Netlink sockets to the file set */ - FD_SET(pmv4_sock, &select_fdset); - FD_SET(pmv4_client_sock, &select_fdset); - FD_SET(pmv6_sock, &select_fdset); - FD_SET(pmv6_client_sock, &select_fdset); - FD_SET(netlink_sock, &select_fdset); - - /* set the timeout for select */ - select_timeout.tv_sec = 10; - select_timeout.tv_usec = 0; - /* timeout is an upper bound of time elapsed before select returns */ - select_rc = select(max_sock + 1, &select_fdset, NULL, NULL, &select_timeout); - } while (select_rc == 0); - /* select_rc is the number of fds ready for IO ( IO won't block) */ - - if (select_rc == -1) { - if (errno == EINTR) - continue; - syslog(LOG_WARNING, "iwarp_port_mapper: Select failed (%s).\n", strerror(errno)); - ret = -errno; - goto iwarp_port_mapper_exit; - } - - if (FD_ISSET(pmv4_sock, &select_fdset)) { - ret = process_iwpm_msg(pmv4_sock); - } - - if (FD_ISSET(pmv6_sock, &select_fdset)) { - ret = process_iwpm_msg(pmv6_sock); - } - - if (FD_ISSET(pmv4_client_sock, &select_fdset)) { - ret = process_iwpm_msg(pmv4_client_sock); - } - - if (FD_ISSET(pmv6_client_sock, &select_fdset)) { - ret = process_iwpm_msg(pmv6_client_sock); - } - - if (FD_ISSET(netlink_sock, &select_fdset)) { - ret = process_iwpm_netlink_msg(netlink_sock); - } - } while (1); - -iwarp_port_mapper_exit: - return ret; -} - -/** - * daemonize_iwpm_server - Make iwarp port mapper a daemon process - */ -static void daemonize_iwpm_server(void) -{ - if (daemon(0, 0) != 0) { - syslog(LOG_ERR, "Failed to daemonize\n"); - exit(EXIT_FAILURE); - } - - syslog(LOG_WARNING, "daemonize_iwpm_server: Starting iWarp Port Mapper V%d process\n", - iwpm_version); -} - -int main(int argc, char *argv[]) -{ - __u32 iwarp_clients[IWARP_PM_MAX_CLIENTS]; - int known_clients; - FILE *fp; - int c; - int ret = EXIT_FAILURE; - bool systemd = false; - - while (1) { - static const struct option long_opts[] = { - {"systemd", 0, NULL, 's'}, - {} - }; - - c = getopt_long(argc, argv, "fs", long_opts, NULL); - if (c == -1) - break; - - switch (c) { - case 's': - systemd = true; - break; - default: - break; - - } - } - - openlog(NULL, LOG_NDELAY | LOG_CONS | LOG_PID, LOG_DAEMON); - - if (!systemd) - daemonize_iwpm_server(); - umask(0); /* change file mode mask */ - - fp = fopen(IWPM_CONFIG_FILE, "r"); - if (fp) { - parse_iwpm_config(fp); - fclose(fp); - } - memset(client_list, 0, sizeof(client_list)); - - pmv4_sock = create_iwpm_socket_v4(IWARP_PM_PORT); - if (pmv4_sock < 0) - goto error_exit_v4; - - pmv4_client_sock = create_iwpm_socket_v4(0); - if (pmv4_client_sock < 0) - goto error_exit_v4_client; - - pmv6_sock = create_iwpm_socket_v6(IWARP_PM_PORT); - if (pmv6_sock < 0) - goto error_exit_v6; - - pmv6_client_sock = create_iwpm_socket_v6(0); - if (pmv6_client_sock < 0) - goto error_exit_v6_client; - - netlink_sock = create_netlink_socket(); - if (netlink_sock < 0) - goto error_exit_nl; - - signal(SIGHUP, iwpm_signal_handler); - signal(SIGTERM, iwpm_signal_handler); - signal(SIGUSR1, iwpm_signal_handler); - - pthread_cond_init(&cond_req_complete, NULL); - pthread_cond_init(&cond_pending_msg, NULL); - - ret = pthread_create(&map_req_thread, NULL, iwpm_mapping_reqs_handler, NULL); - if (ret) - goto error_exit; - - ret = pthread_create(&pending_msg_thread, NULL, iwpm_pending_msgs_handler, NULL); - if (ret) - goto error_exit; - - known_clients = init_iwpm_clients(&iwarp_clients[0]); - send_iwpm_mapinfo_request(netlink_sock, &iwarp_clients[0], known_clients); - - if (systemd) - sd_notify(0, "READY=1"); - - iwarp_port_mapper(); /* start iwarp port mapper process */ - - free_iwpm_mapped_ports(); - closelog(); - -error_exit: - destroy_iwpm_socket(netlink_sock); -error_exit_nl: - destroy_iwpm_socket(pmv6_client_sock); -error_exit_v6_client: - destroy_iwpm_socket(pmv6_sock); -error_exit_v6: - destroy_iwpm_socket(pmv4_client_sock); -error_exit_v4_client: - destroy_iwpm_socket(pmv4_sock); -error_exit_v4: - syslog(LOG_WARNING, "main: Couldn't start iWarp Port Mapper.\n"); - return ret; -} diff --git a/usr/rdma-core/iwpmd/iwpmd.8.in b/usr/rdma-core/iwpmd/iwpmd.8.in deleted file mode 100644 index 76efaa46e..000000000 --- a/usr/rdma-core/iwpmd/iwpmd.8.in +++ /dev/null @@ -1,60 +0,0 @@ -.TH "iwpmd" 8 "2016-09-16" "iwpmd" "iwpmd" iwpmd -.SH NAME -iwpmd \- port mapping services for iWARP. -.SH SYNOPSIS -.sp -.nf -\fIiwpmd\fR -.fi -.SH "DESCRIPTION" -The iWARP Port Mapper Daemon provides a user space service (iwpmd) for the -iWarp drivers to claim tcp ports through the standard socket interface. -.P -The kernel space support for the port mapper is part of the iw_cm module. -The ib_core module includes netlink support, which is used by the port -mapper clients to exchange messages with iwpmd. Both modules iw_cm and -ib_core need to be loaded in order for the libiwpm service to start -successfully. -.SH "IWARP PORT MAPPING DETAILS" -The iWARP Port Mapper implementation is based on the port mapper -specification section in the Sockets Direct Protocol: -http://www.rdmaconsortium.org/home/draft-pinkerton-iwarp-sdp-v1.0.pdf -.P -Existing iWARP RDMA providers use the same IP address as the native -TCP/IP stack when creating RDMA connections. They need a mechanism to -claim the TCP ports used for RDMA connections to prevent TCP port -collisions when other host applications use TCP ports. The iWARP Port -Mapper provides a standard mechanism to accomplish this. Without this -service it is possible for RDMA application to bind/listen on the same -port which is already being used by native TCP host application. If -that happens the incoming TCP connection data can be passed to the -RDMA stack with error. -.P -The iWARP Connection Manager (port mapper client) sends to the IWPM -service the local IP address and TCP port it has received from the RDMA -application, when starting a connection. The IWPM service performs -a socket bind from user space to get an available TCP port, called a -mapped port, and communicates it back to the client. In that sense, -the IWPM service is used to map the TCP port, which the RDMA application -uses to any port available from the host TCP port space. The mapped ports -are used in iWARP RDMA connections to avoid collisions with native TCP -stack which is aware that these ports are taken. When an RDMA connection -using a mapped port is terminated, the client notifies the IWPM service, -which then releases the TCP port. -.P -The message exchange between iwpmd and the iWARP Connection Manager -(between user space and kernel space) is implemented using netlink -sockets. -.SH OPTIONS -.sp -\fB\-s, \-\-systemd\fP -Enable systemd integration. -.SH "SIGNALS" -SIGUSR1 will force a dump of the current mappings -to the system message log. -.P -SIGTERM/SIGHUP will force iwpmd to exit. -.SH "FILES" -@CMAKE_INSTALL_FULL_SYSCONFDIR@/iwpmd.conf -.SH "SEE ALSO" -rdma_cm(7) diff --git a/usr/rdma-core/iwpmd/iwpmd.conf b/usr/rdma-core/iwpmd/iwpmd.conf deleted file mode 100644 index 4bed199a1..000000000 --- a/usr/rdma-core/iwpmd/iwpmd.conf +++ /dev/null @@ -1 +0,0 @@ -nl_sock_rbuf_size=419430400 diff --git a/usr/rdma-core/iwpmd/iwpmd.conf.5.in b/usr/rdma-core/iwpmd/iwpmd.conf.5.in deleted file mode 100644 index 8cb3b0cca..000000000 --- a/usr/rdma-core/iwpmd/iwpmd.conf.5.in +++ /dev/null @@ -1,20 +0,0 @@ -.TH "iwpmd.conf" 5 "2016-09-16" "iwpmd.conf" "iwpmd.conf" iwpmd.conf -.SH NAME -iwpmd.conf \- iWARP port mapper config file. -.SH SYNOPSIS -.sp -.nf -\fIiwpmd.conf\fR -.fi -.SH "DESCRIPTION" -The iwpmd.conf file provides configuration parameters for iwpmd. Parameters -are in the form: param=value, and one per line. Parameters include: -.P -nl_sock_rbuf_size - The socket buffer size of the netlink socket used -to communicate with the kernel port map client. The default is 400MB. -.SH "EXAMPLES" -nl_sock_rbuf_size=419430400 -.SH "FILES" -@CMAKE_INSTALL_FULL_SYSCONFDIR@/iwpmd.conf -.SH "SEE ALSO" -iwpmd(8) diff --git a/usr/rdma-core/iwpmd/iwpmd.rules b/usr/rdma-core/iwpmd/iwpmd.rules deleted file mode 100644 index 5b22cceaf..000000000 --- a/usr/rdma-core/iwpmd/iwpmd.rules +++ /dev/null @@ -1 +0,0 @@ -TAG+="systemd", ENV{ID_RDMA_IWARP}=="1", ENV{SYSTEMD_WANTS}+="iwpmd.service" diff --git a/usr/rdma-core/iwpmd/iwpmd.service.in b/usr/rdma-core/iwpmd/iwpmd.service.in deleted file mode 100644 index 596b70545..000000000 --- a/usr/rdma-core/iwpmd/iwpmd.service.in +++ /dev/null @@ -1,28 +0,0 @@ -[Unit] -Description=iWarp Port Mapper -Documentation=man:iwpmd file:/etc/iwpmd.conf -StopWhenUnneeded=yes -# iwpmd is a kernel support program and needs to run as early as possible, -# otherwise the kernel or userspace cannot establish RDMA connections and -# things will just fail, not block until iwpmd arrives. -DefaultDependencies=no -Before=sysinit.target -# Do not execute concurrently with an ongoing shutdown (required for DefaultDependencies=no) -Conflicts=shutdown.target -Before=shutdown.target -# Ensure required kernel modules are loaded before starting -Wants=rdma-load-modules@iwpmd.service -After=rdma-load-modules@iwpmd.service -# iwpmd needs to start before networking is brought up, even kernel networking -# (eg NFS) since it provides kernel support for iWarp's RDMA CM. -Wants=network-pre.target -Before=network-pre.target -# rdma-hw is not ready until iwpmd is running -Before=rdma-hw.target - -[Service] -Type=notify -ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/iwpmd --systemd -LimitNOFILE=102400 - -# iwpmd is automatically wanted by udev when an iWarp RDMA device is present diff --git a/usr/rdma-core/iwpmd/iwpmd_init.in b/usr/rdma-core/iwpmd/iwpmd_init.in deleted file mode 100644 index f3ae269c7..000000000 --- a/usr/rdma-core/iwpmd/iwpmd_init.in +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -# Start the IWPMD daemon -# -# chkconfig: 1235 90 15 -# description: iWarp Port Mapper Daemon for opening sockets to reserve ports from userspace -# processname: iwpmd -# pidfile: /var/run/iwpmd.pid -# -### BEGIN INIT INFO -# Provides: iwpmd -# Required-Start: $network $syslog $remote_fs -# Required-Stop: $remote_fs -# Default-Stop: 0 1 6 -# Default-Start: 2 3 4 5 -# Short-Description: iWarp Port Mapper Daemon -# Description: iWarp Port Mapper Daemon for opening sockets to claim TCP ports from userspace -### END INIT INFO - -IWPMD_BIN="@CMAKE_INSTALL_FULL_SBINDIR@/iwpmd" -LOCK="/var/lock/subsys/iwpmd" -IWPMD_PID=0 -RETVAL=0 - -# Source function library. -if [ -f "/etc/redhat-release" ]; then - . /etc/rc.d/init.d/functions - STARTD=daemon - STOPD=killproc - STATUSD=status - GETPID=/sbin/pidof - -else - # Debian / openSUSE / Ubuntu - . /lib/lsb/init-functions - STARTD=start_daemon - STOPD=killproc - STATUSD=/sbin/checkproc - GETPID=pidofproc -fi - -check() { - # Check if iwpm is executable - test -x $IWPMD_BIN || ( echo "Couldn't find $IWPMD_BIN"; exit 5 ) -} - -start() { - check - RETVAL=$? - [ $RETVAL -gt 0 ] && exit $RETVAL - - echo -n $"Starting iwpm daemon: " - if [ ! -f "$LOCK" ]; then - ulimit -n 102400 - $STARTD $IWPMD_BIN &> /dev/null - RETVAL=$? - [ $RETVAL -eq 0 ] && ( touch $LOCK; echo "OK" ) || echo "NO" - else - echo "NO (iwpm is already running)" - fi - return $RETVAL -} - -stop() { - check - RETVAL=$? - [ $RETVAL -gt 0 ] && exit $RETVAL - - echo -n $"Stopping iwpm daemon: " - if [ -f "$LOCK" ]; then - $STOPD $IWPMD_BIN &> /dev/null - RETVAL=$? - [ $RETVAL -eq 0 ] && ( rm -f $LOCK; echo "OK" ) || echo "NO" - else - echo "NO (iwpm is already stopped)" - fi - return $RETVAL -} - -restart() { - stop - start -} - -show_status() { - check - RETVAL=$? - [ $RETVAL -gt 0 ] && exit $RETVAL - - IWPMD_PID="$($GETPID $IWPMD_BIN)" - $STATUSD $IWPMD_BIN &> /dev/null - RETVAL=$? - [ $RETVAL -eq 0 ] && echo "iwpm daemon (pid $IWPMD_PID) is running" || echo "iwpm daemon isn't available" - - return $RETVAL -} - -case "$1" in -start) - start - ;; -stop) - stop - ;; -restart) - restart - ;; -force-reload) - restart - ;; -status) - show_status - ;; -*) - echo $"Usage: $0 {start|stop|restart|force-reload|status}" - RETVAL=2 -esac - -exit $RETVAL diff --git a/usr/rdma-core/iwpmd/modules-iwpmd.conf b/usr/rdma-core/iwpmd/modules-iwpmd.conf deleted file mode 100644 index 5544b359c..000000000 --- a/usr/rdma-core/iwpmd/modules-iwpmd.conf +++ /dev/null @@ -1,2 +0,0 @@ -# These modules are loaded by the system if iwpmd is to be run -iw_cm diff --git a/usr/rdma-core/kernel-boot/CMakeLists.txt b/usr/rdma-core/kernel-boot/CMakeLists.txt deleted file mode 100644 index 936c953ea..000000000 --- a/usr/rdma-core/kernel-boot/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -rdma_subst_install(FILES rdma-load-modules@.service.in - DESTINATION "${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}" - RENAME rdma-load-modules@.service - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) - -rdma_subst_install(FILES "rdma-hw.target.in" - RENAME "rdma-hw.target" - DESTINATION "${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) - -install(FILES - modules/infiniband.conf - modules/iwarp.conf - modules/opa.conf - modules/rdma.conf - modules/roce.conf - DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/rdma/modules") - -install(FILES "rdma-description.rules" - RENAME "75-rdma-description.rules" - DESTINATION "${CMAKE_INSTALL_UDEV_RULESDIR}") - -install(FILES "rdma-hw-modules.rules" - RENAME "90-rdma-hw-modules.rules" - DESTINATION "${CMAKE_INSTALL_UDEV_RULESDIR}") - -install(FILES "rdma-ulp-modules.rules" - RENAME "90-rdma-ulp-modules.rules" - DESTINATION "${CMAKE_INSTALL_UDEV_RULESDIR}") - -install(FILES "rdma-umad.rules" - RENAME "90-rdma-umad.rules" - DESTINATION "${CMAKE_INSTALL_UDEV_RULESDIR}") - -# This file is intended to be customized by the user, so it is installed in -# /etc/ -install(FILES "persistent-ipoib.rules" - RENAME "70-persistent-ipoib.rules" - DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/udev/rules.d") diff --git a/usr/rdma-core/kernel-boot/modules/infiniband.conf b/usr/rdma-core/kernel-boot/modules/infiniband.conf deleted file mode 100644 index 99526e156..000000000 --- a/usr/rdma-core/kernel-boot/modules/infiniband.conf +++ /dev/null @@ -1,12 +0,0 @@ -# These modules are loaded by the system if any InfiniBand device is installed -# InfiniBand over IP netdevice -ib_ipoib - -# Access to fabric management SMPs and GMPs from userspace. -ib_umad - -# SCSI Remote Protocol target support -# ib_srpt - -# ib_ucm provides the obsolete /dev/infiniband/ucm0 -# ib_ucm diff --git a/usr/rdma-core/kernel-boot/modules/iwarp.conf b/usr/rdma-core/kernel-boot/modules/iwarp.conf deleted file mode 100644 index 0cb831da5..000000000 --- a/usr/rdma-core/kernel-boot/modules/iwarp.conf +++ /dev/null @@ -1 +0,0 @@ -# These modules are loaded by the system if any iWarp device is installed diff --git a/usr/rdma-core/kernel-boot/modules/opa.conf b/usr/rdma-core/kernel-boot/modules/opa.conf deleted file mode 100644 index b9bc9f1f0..000000000 --- a/usr/rdma-core/kernel-boot/modules/opa.conf +++ /dev/null @@ -1,10 +0,0 @@ -# These modules are loaded by the system if any OmniPath Architecture device -# is installed -# Infiniband over IP netdevice -ib_ipoib - -# Access to fabric management SMPs and GMPs from userspace. -ib_umad - -# Omnipath Ethernet Virtual NIC netdevice -opa_vnic diff --git a/usr/rdma-core/kernel-boot/modules/rdma.conf b/usr/rdma-core/kernel-boot/modules/rdma.conf deleted file mode 100644 index 2d342dd82..000000000 --- a/usr/rdma-core/kernel-boot/modules/rdma.conf +++ /dev/null @@ -1,21 +0,0 @@ -# These modules are loaded by the system if any RDMA devices is installed -# iSCSI over RDMA client support -ib_iser - -# iSCSI over RDMA target support -# ib_isert - -# User access to RDMA verbs (supports libibverbs) -ib_uverbs - -# User access to RDMA connection management (supports librdmacm) -rdma_ucm - -# RDS over RDMA support -# rds_rdma - -# NFS over RDMA client support -xprtrdma - -# NFS over RDMA server support -svcrdma diff --git a/usr/rdma-core/kernel-boot/modules/roce.conf b/usr/rdma-core/kernel-boot/modules/roce.conf deleted file mode 100644 index 8e4927ce2..000000000 --- a/usr/rdma-core/kernel-boot/modules/roce.conf +++ /dev/null @@ -1,2 +0,0 @@ -# These modules are loaded by the system if any RDMA over Converged Ethernet -# device is installed diff --git a/usr/rdma-core/kernel-boot/persistent-ipoib.rules b/usr/rdma-core/kernel-boot/persistent-ipoib.rules deleted file mode 100644 index f8d700a30..000000000 --- a/usr/rdma-core/kernel-boot/persistent-ipoib.rules +++ /dev/null @@ -1,12 +0,0 @@ -# This is a sample udev rules file that demonstrates how to get udev to -# set the name of IPoIB interfaces to whatever you wish. There is a -# 16 character limit on network device names. -# -# Important items to note: ATTR{type}=="32" is IPoIB interfaces, and the -# ATTR{address} match must start with ?* and only reference the last 8 -# bytes of the address or else the address might not match the variable QPN -# portion. -# -# Modern udev is case sensitive and all addresses need to be in lower case. -# -# ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="mlx4_ib3" diff --git a/usr/rdma-core/kernel-boot/rdma-description.rules b/usr/rdma-core/kernel-boot/rdma-description.rules deleted file mode 100644 index bb33dce40..000000000 --- a/usr/rdma-core/kernel-boot/rdma-description.rules +++ /dev/null @@ -1,45 +0,0 @@ -# This is a version of net-description.rules for /sys/class/infiniband devices - -ACTION=="remove", GOTO="rdma_description_end" -SUBSYSTEM!="infiniband", GOTO="rdma_description_end" - -# NOTE: DRIVERS searches up the sysfs path to find the driver that is bound to -# the PCI/etc device that the RDMA device is linked to. This is not the kernel -# driver that is supplying the RDMA device (eg as seen in ID_NET_DRIVER) - -# FIXME: with kernel support we could actually detect the protocols the RDMA -# driver itself supports, this is a work around for lack of that support. -# In future we could do this with a udev IMPORT{program} helper program -# that extracted the ID information from the RDMA netlink. - -# Hardware that supports InfiniBand -DRIVERS=="ib_mthca", ENV{ID_RDMA_INFINIBAND}="1" -DRIVERS=="mlx4_core", ENV{ID_RDMA_INFINIBAND}="1" -DRIVERS=="mlx5_core", ENV{ID_RDMA_INFINIBAND}="1" -DRIVERS=="ib_qib", ENV{ID_RDMA_INFINIBAND}="1" - -# Hardware that supports OPA -DRIVERS=="hfi1", ENV{ID_RDMA_OPA}="1" - -# Hardware that supports iWarp -DRIVERS=="cxgb3", ENV{ID_RDMA_IWARP}="1" -DRIVERS=="cxgb4", ENV{ID_RDMA_IWARP}="1" -DRIVERS=="i40e", ENV{ID_RDMA_IWARP}="1" -DRIVERS=="nes", ENV{ID_RDMA_IWARP}="1" - -# Hardware that supports RoCE -DRIVERS=="be2net", ENV{ID_RDMA_ROCE}="1" -DRIVERS=="bnxt_en", ENV{ID_RDMA_ROCE}="1" -DRIVERS=="hns", ENV{ID_RDMA_ROCE}="1" -DRIVERS=="mlx4_core", ENV{ID_RDMA_ROCE}="1" -DRIVERS=="mlx5_core", ENV{ID_RDMA_ROCE}="1" -DRIVERS=="qede", ENV{ID_RDMA_ROCE}="1" -DRIVERS=="vmw_pvrdma", ENV{ID_RDMA_ROCE}="1" -DEVPATH=="*/infiniband/rxe*", ATTR{parent}=="*", ENV{ID_RDMA_ROCE}="1" - -# Setup the usual ID information so that systemd will display a sane name for -# the RDMA device units. -SUBSYSTEMS=="pci", ENV{ID_BUS}="pci", ENV{ID_VENDOR_ID}="$attr{vendor}", ENV{ID_MODEL_ID}="$attr{device}" -SUBSYSTEMS=="pci", IMPORT{builtin}="hwdb --subsystem=pci" - -LABEL="rdma_description_end" diff --git a/usr/rdma-core/kernel-boot/rdma-hw-modules.rules b/usr/rdma-core/kernel-boot/rdma-hw-modules.rules deleted file mode 100644 index dde0ab8da..000000000 --- a/usr/rdma-core/kernel-boot/rdma-hw-modules.rules +++ /dev/null @@ -1,39 +0,0 @@ -ACTION=="remove", GOTO="rdma_hw_modules_end" -SUBSYSTEM!="net", GOTO="rdma_hw_modules_end" - -# Automatically load RDMA specific kernel modules when a multi-function device is installed - -# These drivers autoload an ethernet driver based on hardware detection and -# need userspace to load the module that has their RDMA component to turn on -# RDMA. -ENV{ID_NET_DRIVER}=="be2net", RUN{builtin}+="kmod load ocrdma" -ENV{ID_NET_DRIVER}=="bnxt_en", RUN{builtin}+="kmod load bnxt_re" -ENV{ID_NET_DRIVER}=="cxgb3", RUN{builtin}+="kmod load iw_cxgb3" -ENV{ID_NET_DRIVER}=="cxgb4", RUN{builtin}+="kmod load iw_cxgb4" -ENV{ID_NET_DRIVER}=="hns", RUN{builtin}+="kmod load hns_roce" -ENV{ID_NET_DRIVER}=="i40e", RUN{builtin}+="kmod load i40iw" -ENV{ID_NET_DRIVER}=="mlx4_en", RUN{builtin}+="kmod load mlx4_ib" -ENV{ID_NET_DRIVER}=="mlx5_core", RUN{builtin}+="kmod load mlx5_ib" -ENV{ID_NET_DRIVER}=="qede", RUN{builtin}+="kmod load qedr" - -# The user must explicitly load these modules via /etc/modules-load.d/ or otherwise -# rxe - -# When in IB mode the kernel PCI core module autoloads the protocol modules -# for these providers -# mlx4 -# mlx5 - -# enic no longer has a userspace verbs driver, this rule should probably be -# owned by libfabric -ENV{ID_NET_DRIVER}=="enic", RUN{builtin}+="kmod load usnic_verbs" - -# These providers are single function and autoload RDMA automatically based on -# PCI probing -# hfi1verbs -# ipathverbs -# mthca -# vmw_pvrdma -# nes - -LABEL="rdma_hw_modules_end" diff --git a/usr/rdma-core/kernel-boot/rdma-hw.target.in b/usr/rdma-core/kernel-boot/rdma-hw.target.in deleted file mode 100644 index 010e21e67..000000000 --- a/usr/rdma-core/kernel-boot/rdma-hw.target.in +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=RDMA Hardware -Documentation=file:@CMAKE_INSTALL_FULL_DOCDIR@/udev.md -StopWhenUnneeded=yes - -# Start the basic ULP RDMA kernel modules when RDMA hardware is detected (note -# the rdma-load-modules@.service is already before this target) -Wants=rdma-load-modules@rdma.service -# Order after the standard network.target for compatibility with init.d -# scripts that order after networking - this will mean RDMA is ready too. -Before=network.target -# We do not order rdma-hw before basic.target, units for daemons that use RDMA -# have to manually order after rdma-hw.target diff --git a/usr/rdma-core/kernel-boot/rdma-load-modules@.service.in b/usr/rdma-core/kernel-boot/rdma-load-modules@.service.in deleted file mode 100644 index c390a8cc2..000000000 --- a/usr/rdma-core/kernel-boot/rdma-load-modules@.service.in +++ /dev/null @@ -1,25 +0,0 @@ -[Unit] -Description=Load RDMA modules from @CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/modules/%I.conf -Documentation=file:@CMAKE_INSTALL_FULL_DOCDIR@/udev.md -# Kernel module loading must take place before sysinit.target, similar to -# systemd-modules-load.service -DefaultDependencies=no -Before=sysinit.target -# Do not execute concurrently with an ongoing shutdown -Conflicts=shutdown.target -Before=shutdown.target -# Partially support distro network setup scripts that run after -# systemd-modules-load.service but before sysinit.target, eg a classic network -# setup script. Run them after modules have loaded. -Wants=network-pre.target -Before=network-pre.target -# Orders all kernel module startup before rdma-hw.target can become ready -Before=rdma-hw.target - -ConditionCapability=CAP_SYS_MODULE - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=@CMAKE_INSTALL_SYSTEMD_BINDIR@/systemd-modules-load @CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/modules/%I.conf -TimeoutSec=90s diff --git a/usr/rdma-core/kernel-boot/rdma-ulp-modules.rules b/usr/rdma-core/kernel-boot/rdma-ulp-modules.rules deleted file mode 100644 index fbd195a2c..000000000 --- a/usr/rdma-core/kernel-boot/rdma-ulp-modules.rules +++ /dev/null @@ -1,11 +0,0 @@ -ACTION=="remove", GOTO="rdma_ulp_modules_end" -SUBSYSTEM!="infiniband", GOTO="rdma_ulp_modules_end" - -# Automatically load general RDMA ULP modules when RDMA hardware is installed -TAG+="systemd", ENV{SYSTEMD_WANTS}+="rdma-hw.target" -TAG+="systemd", ENV{ID_RDMA_INFINIBAND}=="1", ENV{SYSTEMD_WANTS}+="rdma-load-modules@infiniband.service" -TAG+="systemd", ENV{ID_RDMA_IWARP}=="1", ENV{SYSTEMD_WANTS}+="rdma-load-modules@iwarp.service" -TAG+="systemd", ENV{ID_RDMA_OPA}=="1", ENV{SYSTEMD_WANTS}+="rdma-load-modules@opa.service" -TAG+="systemd", ENV{ID_RDMA_ROCE}=="1", ENV{SYSTEMD_WANTS}+="rdma-load-modules@roce.service" - -LABEL="rdma_ulp_modules_end" diff --git a/usr/rdma-core/kernel-boot/rdma-umad.rules b/usr/rdma-core/kernel-boot/rdma-umad.rules deleted file mode 100644 index ba7ee6138..000000000 --- a/usr/rdma-core/kernel-boot/rdma-umad.rules +++ /dev/null @@ -1 +0,0 @@ -SUBSYSTEM=="infiniband_mad", KERNEL=="*umad*", TAG+="systemd", ENV{SYSTEMD_ALIAS}="/sys/subsystem/rdma/devices/$attr{ibdev}:$attr{port}/umad" diff --git a/usr/rdma-core/libibcm/CMakeLists.txt b/usr/rdma-core/libibcm/CMakeLists.txt deleted file mode 100644 index 7087859ee..000000000 --- a/usr/rdma-core/libibcm/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -publish_headers(infiniband - cm.h - cm_abi.h - ) - -rdma_library(ibcm libibcm.map - # See Documentation/versioning.md - 1 1.0.${PACKAGE_VERSION} - cm.c - ) -target_link_libraries(ibcm LINK_PUBLIC ibverbs) diff --git a/usr/rdma-core/libibcm/cm.c b/usr/rdma-core/libibcm/cm.c deleted file mode 100644 index 4fd3fdd65..000000000 --- a/usr/rdma-core/libibcm/cm.c +++ /dev/null @@ -1,1025 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005-2006 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#define PFX "libibcm: " - -#define IB_USER_CM_MIN_ABI_VERSION 4 -#define IB_USER_CM_MAX_ABI_VERSION 5 - -static int abi_ver; -static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; - -enum { - IB_UCM_MAX_DEVICES = 32 -}; - -static inline int ERR(int err) -{ - errno = err; - return -1; -} - - -#define CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, type, size) \ -do { \ - struct ib_ucm_cmd_hdr *hdr; \ - \ - size = sizeof(*hdr) + sizeof(*cmd); \ - msg = alloca(size); \ - if (!msg) \ - return ERR(ENOMEM); \ - hdr = msg; \ - cmd = msg + sizeof(*hdr); \ - hdr->cmd = type; \ - hdr->in = sizeof(*cmd); \ - hdr->out = sizeof(*resp); \ - memset(cmd, 0, sizeof(*cmd)); \ - resp = alloca(sizeof(*resp)); \ - if (!resp) \ - return ERR(ENOMEM); \ - cmd->response = (uintptr_t)resp;\ -} while (0) - -#define CM_CREATE_MSG_CMD(msg, cmd, type, size) \ -do { \ - struct ib_ucm_cmd_hdr *hdr; \ - \ - size = sizeof(*hdr) + sizeof(*cmd); \ - msg = alloca(size); \ - if (!msg) \ - return ERR(ENOMEM); \ - hdr = msg; \ - cmd = msg + sizeof(*hdr); \ - hdr->cmd = type; \ - hdr->in = sizeof(*cmd); \ - hdr->out = 0; \ - memset(cmd, 0, sizeof(*cmd)); \ -} while (0) - -struct cm_id_private { - struct ib_cm_id id; - int events_completed; - pthread_cond_t cond; - pthread_mutex_t mut; -}; - -static int check_abi_version(void) -{ - char value[8]; - - if (ibv_read_sysfs_file(ibv_get_sysfs_path(), - "class/infiniband_cm/abi_version", - value, sizeof value) < 0) { - fprintf(stderr, PFX "couldn't read ABI version\n"); - return 0; - } - - abi_ver = strtol(value, NULL, 10); - if (abi_ver < IB_USER_CM_MIN_ABI_VERSION || - abi_ver > IB_USER_CM_MAX_ABI_VERSION) { - fprintf(stderr, PFX "kernel ABI version %d " - "doesn't match library version %d.\n", - abi_ver, IB_USER_CM_MAX_ABI_VERSION); - return -1; - } - return 0; -} - -static int ucm_init(void) -{ - int ret = 0; - - pthread_mutex_lock(&mut); - if (!abi_ver) - ret = check_abi_version(); - pthread_mutex_unlock(&mut); - - return ret; -} - -static int ucm_get_dev_index(char *dev_name) -{ - char *dev_path; - char ibdev[IBV_SYSFS_NAME_MAX]; - int i, ret; - - for (i = 0; i < IB_UCM_MAX_DEVICES; i++) { - ret = asprintf(&dev_path, "/sys/class/infiniband_cm/ucm%d", i); - if (ret < 0) - return -1; - - ret = ibv_read_sysfs_file(dev_path, "ibdev", ibdev, sizeof ibdev); - if (ret < 0) - continue; - - if (!strcmp(dev_name, ibdev)) { - free(dev_path); - return i; - } - - free(dev_path); - } - return -1; -} - -struct ib_cm_device* ib_cm_open_device(struct ibv_context *device_context) -{ - struct ib_cm_device *dev; - char *dev_path; - int index, ret; - - if (ucm_init()) - return NULL; - - index = ucm_get_dev_index(device_context->device->name); - if (index < 0) - return NULL; - - dev = malloc(sizeof *dev); - if (!dev) - return NULL; - - dev->device_context = device_context; - - ret = asprintf(&dev_path, "/dev/infiniband/ucm%d", index); - if (ret < 0) - goto err1; - - dev->fd = open(dev_path, O_RDWR); - if (dev->fd < 0) - goto err2; - - free(dev_path); - return dev; - -err2: - free(dev_path); -err1: - free(dev); - return NULL; -} - -void ib_cm_close_device(struct ib_cm_device *device) -{ - close(device->fd); - free(device); -} - -static void ib_cm_free_id(struct cm_id_private *cm_id_priv) -{ - pthread_cond_destroy(&cm_id_priv->cond); - pthread_mutex_destroy(&cm_id_priv->mut); - free(cm_id_priv); -} - -static struct cm_id_private *ib_cm_alloc_id(struct ib_cm_device *device, - void *context) -{ - struct cm_id_private *cm_id_priv; - - cm_id_priv = malloc(sizeof *cm_id_priv); - if (!cm_id_priv) - return NULL; - - memset(cm_id_priv, 0, sizeof *cm_id_priv); - cm_id_priv->id.device = device; - cm_id_priv->id.context = context; - pthread_mutex_init(&cm_id_priv->mut, NULL); - if (pthread_cond_init(&cm_id_priv->cond, NULL)) - goto err; - - return cm_id_priv; - -err: ib_cm_free_id(cm_id_priv); - return NULL; -} - -int ib_cm_create_id(struct ib_cm_device *device, - struct ib_cm_id **cm_id, void *context) -{ - struct ib_ucm_create_id_resp *resp; - struct ib_ucm_create_id *cmd; - struct cm_id_private *cm_id_priv; - void *msg; - int result; - int size; - - cm_id_priv = ib_cm_alloc_id(device, context); - if (!cm_id_priv) - return ERR(ENOMEM); - - CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_CREATE_ID, size); - cmd->uid = (uintptr_t) cm_id_priv; - - result = write(device->fd, msg, size); - if (result != size) - goto err; - - VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp); - - cm_id_priv->id.handle = resp->id; - *cm_id = &cm_id_priv->id; - return 0; - -err: ib_cm_free_id(cm_id_priv); - return result; -} - -int ib_cm_destroy_id(struct ib_cm_id *cm_id) -{ - struct ib_ucm_destroy_id_resp *resp; - struct ib_ucm_destroy_id *cmd; - struct cm_id_private *cm_id_priv; - void *msg; - int result; - int size; - - CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_DESTROY_ID, size); - cmd->id = cm_id->handle; - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp); - - cm_id_priv = container_of(cm_id, struct cm_id_private, id); - - pthread_mutex_lock(&cm_id_priv->mut); - while (cm_id_priv->events_completed < resp->events_reported) - pthread_cond_wait(&cm_id_priv->cond, &cm_id_priv->mut); - pthread_mutex_unlock(&cm_id_priv->mut); - - ib_cm_free_id(cm_id_priv); - return 0; -} - -int ib_cm_attr_id(struct ib_cm_id *cm_id, struct ib_cm_attr_param *param) -{ - struct ib_ucm_attr_id_resp *resp; - struct ib_ucm_attr_id *cmd; - void *msg; - int result; - int size; - - if (!param) - return ERR(EINVAL); - - CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_ATTR_ID, size); - cmd->id = cm_id->handle; - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp); - - param->service_id = resp->service_id; - param->service_mask = resp->service_mask; - param->local_id = resp->local_id; - param->remote_id = resp->remote_id; - return 0; -} - -int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, - struct ibv_qp_attr *qp_attr, - int *qp_attr_mask) -{ - struct ibv_kern_qp_attr *resp; - struct ib_ucm_init_qp_attr *cmd; - void *msg; - int result; - int size; - - if (!qp_attr || !qp_attr_mask) - return ERR(EINVAL); - - CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_INIT_QP_ATTR, size); - cmd->id = cm_id->handle; - cmd->qp_state = qp_attr->qp_state; - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : result; - - VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp); - - *qp_attr_mask = resp->qp_attr_mask; - ibv_copy_qp_attr_from_kern(qp_attr, resp); - - return 0; -} - -int ib_cm_listen(struct ib_cm_id *cm_id, - __be64 service_id, - __be64 service_mask) -{ - struct ib_ucm_listen *cmd; - void *msg; - int result; - int size; - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_LISTEN, size); - cmd->id = cm_id->handle; - cmd->service_id = service_id; - cmd->service_mask = service_mask; - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param) -{ - struct ib_user_path_rec p_path; - struct ib_user_path_rec *a_path; - struct ib_ucm_req *cmd; - void *msg; - int result; - int size; - - if (!param || !param->primary_path) - return ERR(EINVAL); - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_REQ, size); - cmd->id = cm_id->handle; - cmd->qpn = param->qp_num; - cmd->qp_type = param->qp_type; - cmd->psn = param->starting_psn; - cmd->sid = param->service_id; - cmd->peer_to_peer = param->peer_to_peer; - cmd->responder_resources = param->responder_resources; - cmd->initiator_depth = param->initiator_depth; - cmd->remote_cm_response_timeout = param->remote_cm_response_timeout; - cmd->flow_control = param->flow_control; - cmd->local_cm_response_timeout = param->local_cm_response_timeout; - cmd->retry_count = param->retry_count; - cmd->rnr_retry_count = param->rnr_retry_count; - cmd->max_cm_retries = param->max_cm_retries; - cmd->srq = param->srq; - - ibv_copy_path_rec_to_kern(&p_path, param->primary_path); - cmd->primary_path = (uintptr_t) &p_path; - - if (param->alternate_path) { - a_path = alloca(sizeof(*a_path)); - if (!a_path) - return ERR(ENOMEM); - - ibv_copy_path_rec_to_kern(a_path, param->alternate_path); - cmd->alternate_path = (uintptr_t) a_path; - } - - if (param->private_data && param->private_data_len) { - cmd->data = (uintptr_t) param->private_data; - cmd->len = param->private_data_len; - } - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int ib_cm_send_rep(struct ib_cm_id *cm_id, struct ib_cm_rep_param *param) -{ - struct ib_ucm_rep *cmd; - void *msg; - int result; - int size; - - if (!param) - return ERR(EINVAL); - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_REP, size); - cmd->uid = (uintptr_t) container_of(cm_id, struct cm_id_private, id); - cmd->id = cm_id->handle; - cmd->qpn = param->qp_num; - cmd->psn = param->starting_psn; - cmd->responder_resources = param->responder_resources; - cmd->initiator_depth = param->initiator_depth; - cmd->target_ack_delay = param->target_ack_delay; - cmd->failover_accepted = param->failover_accepted; - cmd->flow_control = param->flow_control; - cmd->rnr_retry_count = param->rnr_retry_count; - cmd->srq = param->srq; - - if (param->private_data && param->private_data_len) { - cmd->data = (uintptr_t) param->private_data; - cmd->len = param->private_data_len; - } - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -static inline int cm_send_private_data(struct ib_cm_id *cm_id, - uint32_t type, - void *private_data, - uint8_t private_data_len) -{ - struct ib_ucm_private_data *cmd; - void *msg; - int result; - int size; - - CM_CREATE_MSG_CMD(msg, cmd, type, size); - cmd->id = cm_id->handle; - - if (private_data && private_data_len) { - cmd->data = (uintptr_t) private_data; - cmd->len = private_data_len; - } - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int ib_cm_send_rtu(struct ib_cm_id *cm_id, - void *private_data, - uint8_t private_data_len) -{ - return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_RTU, - private_data, private_data_len); -} - -int ib_cm_send_dreq(struct ib_cm_id *cm_id, - void *private_data, - uint8_t private_data_len) -{ - return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_DREQ, - private_data, private_data_len); -} - -int ib_cm_send_drep(struct ib_cm_id *cm_id, - void *private_data, - uint8_t private_data_len) -{ - return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_DREP, - private_data, private_data_len); -} - -static int cm_establish(struct ib_cm_id *cm_id) -{ - /* In kernel ABI 4 ESTABLISH was repurposed as NOTIFY and gained an - extra field. For some reason the compat definitions were deleted - from the uapi headers :( */ -#define IB_USER_CM_CMD_ESTABLISH IB_USER_CM_CMD_NOTIFY - struct cm_abi_establish { /* ABI 4 support */ - __u32 id; - }; - - struct cm_abi_establish *cmd; - void *msg; - int result; - int size; - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_ESTABLISH, size); - cmd->id = cm_id->handle; - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event) -{ - struct ib_ucm_notify *cmd; - void *msg; - int result; - int size; - - if (abi_ver == 4) { - if (event == IBV_EVENT_COMM_EST) - return cm_establish(cm_id); - else - return ERR(EINVAL); - } - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_NOTIFY, size); - cmd->id = cm_id->handle; - cmd->event = event; - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -static inline int cm_send_status(struct ib_cm_id *cm_id, - uint32_t type, - int status, - void *info, - uint8_t info_length, - void *private_data, - uint8_t private_data_len) -{ - struct ib_ucm_info *cmd; - void *msg; - int result; - int size; - - CM_CREATE_MSG_CMD(msg, cmd, type, size); - cmd->id = cm_id->handle; - cmd->status = status; - - if (private_data && private_data_len) { - cmd->data = (uintptr_t) private_data; - cmd->data_len = private_data_len; - } - - if (info && info_length) { - cmd->info = (uintptr_t) info; - cmd->info_len = info_length; - } - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int ib_cm_send_rej(struct ib_cm_id *cm_id, - enum ib_cm_rej_reason reason, - void *ari, - uint8_t ari_length, - void *private_data, - uint8_t private_data_len) -{ - return cm_send_status(cm_id, IB_USER_CM_CMD_SEND_REJ, reason, - ari, ari_length, - private_data, private_data_len); -} - -int ib_cm_send_apr(struct ib_cm_id *cm_id, - enum ib_cm_apr_status status, - void *info, - uint8_t info_length, - void *private_data, - uint8_t private_data_len) -{ - return cm_send_status(cm_id, IB_USER_CM_CMD_SEND_APR, status, - info, info_length, - private_data, private_data_len); -} - -int ib_cm_send_mra(struct ib_cm_id *cm_id, - uint8_t service_timeout, - void *private_data, - uint8_t private_data_len) -{ - struct ib_ucm_mra *cmd; - void *msg; - int result; - int size; - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_MRA, size); - cmd->id = cm_id->handle; - cmd->timeout = service_timeout; - - if (private_data && private_data_len) { - cmd->data = (uintptr_t) private_data; - cmd->len = private_data_len; - } - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : result; - - return 0; -} - -int ib_cm_send_lap(struct ib_cm_id *cm_id, - struct ibv_sa_path_rec *alternate_path, - void *private_data, - uint8_t private_data_len) -{ - struct ib_user_path_rec abi_path; - struct ib_ucm_lap *cmd; - void *msg; - int result; - int size; - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_LAP, size); - cmd->id = cm_id->handle; - - ibv_copy_path_rec_to_kern(&abi_path, alternate_path); - cmd->path = (uintptr_t) &abi_path; - - if (private_data && private_data_len) { - cmd->data = (uintptr_t) private_data; - cmd->len = private_data_len; - } - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int ib_cm_send_sidr_req(struct ib_cm_id *cm_id, - struct ib_cm_sidr_req_param *param) -{ - struct ib_user_path_rec abi_path; - struct ib_ucm_sidr_req *cmd; - void *msg; - int result; - int size; - - if (!param || !param->path) - return ERR(EINVAL); - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_SIDR_REQ, size); - cmd->id = cm_id->handle; - cmd->sid = param->service_id; - cmd->timeout = param->timeout_ms; - cmd->max_cm_retries = param->max_cm_retries; - - ibv_copy_path_rec_to_kern(&abi_path, param->path); - cmd->path = (uintptr_t) &abi_path; - - if (param->private_data && param->private_data_len) { - cmd->data = (uintptr_t) param->private_data; - cmd->len = param->private_data_len; - } - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : result; - - return 0; -} - -int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id, - struct ib_cm_sidr_rep_param *param) -{ - struct ib_ucm_sidr_rep *cmd; - void *msg; - int result; - int size; - - if (!param) - return ERR(EINVAL); - - CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_SIDR_REP, size); - cmd->id = cm_id->handle; - cmd->qpn = param->qp_num; - cmd->qkey = param->qkey; - cmd->status = param->status; - - if (param->private_data && param->private_data_len) { - cmd->data = (uintptr_t) param->private_data; - cmd->data_len = param->private_data_len; - } - - if (param->info && param->info_length) { - cmd->info = (uintptr_t) param->info; - cmd->info_len = param->info_length; - } - - result = write(cm_id->device->fd, msg, size); - if (result != size) - return (result >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -static void cm_event_req_get(struct ib_cm_req_event_param *ureq, - struct ib_ucm_req_event_resp *kreq) -{ - ureq->remote_ca_guid = kreq->remote_ca_guid; - ureq->remote_qkey = kreq->remote_qkey; - ureq->remote_qpn = kreq->remote_qpn; - ureq->qp_type = kreq->qp_type; - ureq->starting_psn = kreq->starting_psn; - ureq->responder_resources = kreq->responder_resources; - ureq->initiator_depth = kreq->initiator_depth; - ureq->local_cm_response_timeout = kreq->local_cm_response_timeout; - ureq->flow_control = kreq->flow_control; - ureq->remote_cm_response_timeout = kreq->remote_cm_response_timeout; - ureq->retry_count = kreq->retry_count; - ureq->rnr_retry_count = kreq->rnr_retry_count; - ureq->srq = kreq->srq; - ureq->port = kreq->port; - - ibv_copy_path_rec_from_kern(ureq->primary_path, &kreq->primary_path); - if (ureq->alternate_path) - ibv_copy_path_rec_from_kern(ureq->alternate_path, - &kreq->alternate_path); -} - -static void cm_event_rep_get(struct ib_cm_rep_event_param *urep, - struct ib_ucm_rep_event_resp *krep) -{ - urep->remote_ca_guid = krep->remote_ca_guid; - urep->remote_qkey = krep->remote_qkey; - urep->remote_qpn = krep->remote_qpn; - urep->starting_psn = krep->starting_psn; - urep->responder_resources = krep->responder_resources; - urep->initiator_depth = krep->initiator_depth; - urep->target_ack_delay = krep->target_ack_delay; - urep->failover_accepted = krep->failover_accepted; - urep->flow_control = krep->flow_control; - urep->rnr_retry_count = krep->rnr_retry_count; - urep->srq = krep->srq; -} - -static void cm_event_sidr_rep_get(struct ib_cm_sidr_rep_event_param *urep, - struct ib_ucm_sidr_rep_event_resp *krep) -{ - urep->status = krep->status; - urep->qkey = krep->qkey; - urep->qpn = krep->qpn; -}; - -int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event) -{ - struct cm_id_private *cm_id_priv; - struct ib_ucm_cmd_hdr *hdr; - struct ib_ucm_event_get *cmd; - struct ib_ucm_event_resp *resp; - struct ib_cm_event *evt = NULL; - struct ibv_sa_path_rec *path_a = NULL; - struct ibv_sa_path_rec *path_b = NULL; - void *data = NULL; - void *info = NULL; - void *msg; - int result = 0; - int size; - - if (!event) - return ERR(EINVAL); - - size = sizeof(*hdr) + sizeof(*cmd); - msg = alloca(size); - if (!msg) - return ERR(ENOMEM); - - hdr = msg; - cmd = msg + sizeof(*hdr); - - hdr->cmd = IB_USER_CM_CMD_EVENT; - hdr->in = sizeof(*cmd); - hdr->out = sizeof(*resp); - - memset(cmd, 0, sizeof(*cmd)); - - resp = alloca(sizeof(*resp)); - if (!resp) - return ERR(ENOMEM); - - cmd->response = (uintptr_t) resp; - cmd->data_len = (uint8_t)(~0U); - cmd->info_len = (uint8_t)(~0U); - - data = malloc(cmd->data_len); - if (!data) { - result = ERR(ENOMEM); - goto done; - } - - info = malloc(cmd->info_len); - if (!info) { - result = ERR(ENOMEM); - goto done; - } - - cmd->data = (uintptr_t) data; - cmd->info = (uintptr_t) info; - - result = write(device->fd, msg, size); - if (result != size) { - result = (result >= 0) ? ERR(ENODATA) : -1; - goto done; - } - - VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp); - - /* - * decode event. - */ - evt = malloc(sizeof(*evt)); - if (!evt) { - result = ERR(ENOMEM); - goto done; - } - memset(evt, 0, sizeof(*evt)); - evt->cm_id = (void *) (uintptr_t) resp->uid; - evt->event = resp->event; - - if (resp->present & IB_UCM_PRES_PRIMARY) { - path_a = malloc(sizeof(*path_a)); - if (!path_a) { - result = ERR(ENOMEM); - goto done; - } - } - - if (resp->present & IB_UCM_PRES_ALTERNATE) { - path_b = malloc(sizeof(*path_b)); - if (!path_b) { - result = ERR(ENOMEM); - goto done; - } - } - - switch (evt->event) { - case IB_CM_REQ_RECEIVED: - evt->param.req_rcvd.listen_id = evt->cm_id; - cm_id_priv = ib_cm_alloc_id(evt->cm_id->device, - evt->cm_id->context); - if (!cm_id_priv) { - result = ERR(ENOMEM); - goto done; - } - cm_id_priv->id.handle = resp->id; - evt->cm_id = &cm_id_priv->id; - evt->param.req_rcvd.primary_path = path_a; - evt->param.req_rcvd.alternate_path = path_b; - path_a = NULL; - path_b = NULL; - cm_event_req_get(&evt->param.req_rcvd, &resp->u.req_resp); - break; - case IB_CM_REP_RECEIVED: - cm_event_rep_get(&evt->param.rep_rcvd, &resp->u.rep_resp); - break; - case IB_CM_MRA_RECEIVED: - evt->param.mra_rcvd.service_timeout = resp->u.mra_resp.timeout; - break; - case IB_CM_REJ_RECEIVED: - evt->param.rej_rcvd.reason = resp->u.rej_resp.reason; - evt->param.rej_rcvd.ari = info; - info = NULL; - break; - case IB_CM_LAP_RECEIVED: - evt->param.lap_rcvd.alternate_path = path_b; - path_b = NULL; - ibv_copy_path_rec_from_kern(evt->param.lap_rcvd.alternate_path, - &resp->u.lap_resp.path); - break; - case IB_CM_APR_RECEIVED: - evt->param.apr_rcvd.ap_status = resp->u.apr_resp.status; - evt->param.apr_rcvd.apr_info = info; - info = NULL; - break; - case IB_CM_SIDR_REQ_RECEIVED: - evt->param.sidr_req_rcvd.listen_id = evt->cm_id; - cm_id_priv = ib_cm_alloc_id(evt->cm_id->device, - evt->cm_id->context); - if (!cm_id_priv) { - result = ERR(ENOMEM); - goto done; - } - cm_id_priv->id.handle = resp->id; - evt->cm_id = &cm_id_priv->id; - evt->param.sidr_req_rcvd.pkey = resp->u.sidr_req_resp.pkey; - evt->param.sidr_req_rcvd.port = resp->u.sidr_req_resp.port; - break; - case IB_CM_SIDR_REP_RECEIVED: - cm_event_sidr_rep_get(&evt->param.sidr_rep_rcvd, - &resp->u.sidr_rep_resp); - evt->param.sidr_rep_rcvd.info = info; - info = NULL; - break; - default: - evt->param.send_status = resp->u.send_status; - break; - } - - if (resp->present & IB_UCM_PRES_DATA) { - evt->private_data = data; - data = NULL; - } - - *event = evt; - evt = NULL; - result = 0; -done: - if (data) - free(data); - if (info) - free(info); - if (path_a) - free(path_a); - if (path_b) - free(path_b); - if (evt) - free(evt); - - return result; -} - -int ib_cm_ack_event(struct ib_cm_event *event) -{ - struct cm_id_private *cm_id_priv; - - if (!event) - return ERR(EINVAL); - - if (event->private_data) - free(event->private_data); - - cm_id_priv = container_of(event->cm_id, struct cm_id_private, id); - - switch (event->event) { - case IB_CM_REQ_RECEIVED: - cm_id_priv = container_of(event->param.req_rcvd.listen_id, - struct cm_id_private, id); - free(event->param.req_rcvd.primary_path); - if (event->param.req_rcvd.alternate_path) - free(event->param.req_rcvd.alternate_path); - break; - case IB_CM_REJ_RECEIVED: - if (event->param.rej_rcvd.ari) - free(event->param.rej_rcvd.ari); - break; - case IB_CM_LAP_RECEIVED: - free(event->param.lap_rcvd.alternate_path); - break; - case IB_CM_APR_RECEIVED: - if (event->param.apr_rcvd.apr_info) - free(event->param.apr_rcvd.apr_info); - break; - case IB_CM_SIDR_REQ_RECEIVED: - cm_id_priv = container_of(event->param.sidr_req_rcvd.listen_id, - struct cm_id_private, id); - break; - case IB_CM_SIDR_REP_RECEIVED: - if (event->param.sidr_rep_rcvd.info) - free(event->param.sidr_rep_rcvd.info); - default: - break; - } - - pthread_mutex_lock(&cm_id_priv->mut); - cm_id_priv->events_completed++; - pthread_cond_signal(&cm_id_priv->cond); - pthread_mutex_unlock(&cm_id_priv->mut); - - free(event); - return 0; -} diff --git a/usr/rdma-core/libibcm/cm.h b/usr/rdma-core/libibcm/cm.h deleted file mode 100644 index 6a91e37de..000000000 --- a/usr/rdma-core/libibcm/cm.h +++ /dev/null @@ -1,587 +0,0 @@ -/* - * Copyright (c) 2004-2006 Intel Corporation. All rights reserved. - * Copyright (c) 2004 Topspin Corporation. All rights reserved. - * Copyright (c) 2004 Voltaire Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ -#if !defined(CM_H) -#define CM_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -enum ib_cm_event_type { - IB_CM_REQ_ERROR, - IB_CM_REQ_RECEIVED, - IB_CM_REP_ERROR, - IB_CM_REP_RECEIVED, - IB_CM_RTU_RECEIVED, - IB_CM_USER_ESTABLISHED, - IB_CM_DREQ_ERROR, - IB_CM_DREQ_RECEIVED, - IB_CM_DREP_RECEIVED, - IB_CM_TIMEWAIT_EXIT, - IB_CM_MRA_RECEIVED, - IB_CM_REJ_RECEIVED, - IB_CM_LAP_ERROR, - IB_CM_LAP_RECEIVED, - IB_CM_APR_RECEIVED, - IB_CM_SIDR_REQ_ERROR, - IB_CM_SIDR_REQ_RECEIVED, - IB_CM_SIDR_REP_RECEIVED -}; - -enum ib_cm_data_size { - IB_CM_REQ_PRIVATE_DATA_SIZE = 92, - IB_CM_MRA_PRIVATE_DATA_SIZE = 222, - IB_CM_REJ_PRIVATE_DATA_SIZE = 148, - IB_CM_REP_PRIVATE_DATA_SIZE = 196, - IB_CM_RTU_PRIVATE_DATA_SIZE = 224, - IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, - IB_CM_DREP_PRIVATE_DATA_SIZE = 224, - IB_CM_REJ_ARI_LENGTH = 72, - IB_CM_LAP_PRIVATE_DATA_SIZE = 168, - IB_CM_APR_PRIVATE_DATA_SIZE = 148, - IB_CM_APR_INFO_LENGTH = 72, - IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, - IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, - IB_CM_SIDR_REP_INFO_LENGTH = 72 -}; - -struct ib_cm_device { - struct ibv_context *device_context; - int fd; -}; - -struct ib_cm_id { - void *context; - struct ib_cm_device *device; - uint32_t handle; -}; - -struct ib_cm_req_event_param { - struct ib_cm_id *listen_id; - uint8_t port; - - struct ibv_sa_path_rec *primary_path; - struct ibv_sa_path_rec *alternate_path; - - __be64 remote_ca_guid; - uint32_t remote_qkey; - uint32_t remote_qpn; - enum ibv_qp_type qp_type; - - uint32_t starting_psn; - uint8_t responder_resources; - uint8_t initiator_depth; - unsigned int local_cm_response_timeout:5; - unsigned int flow_control:1; - unsigned int remote_cm_response_timeout:5; - unsigned int retry_count:3; - unsigned int rnr_retry_count:3; - unsigned int srq:1; -}; - -struct ib_cm_rep_event_param { - __be64 remote_ca_guid; - uint32_t remote_qkey; - uint32_t remote_qpn; - uint32_t starting_psn; - uint8_t responder_resources; - uint8_t initiator_depth; - unsigned int target_ack_delay:5; - unsigned int failover_accepted:2; - unsigned int flow_control:1; - unsigned int rnr_retry_count:3; - unsigned int srq:1; -}; - -enum ib_cm_rej_reason { - IB_CM_REJ_NO_QP = 1, - IB_CM_REJ_NO_EEC = 2, - IB_CM_REJ_NO_RESOURCES = 3, - IB_CM_REJ_TIMEOUT = 4, - IB_CM_REJ_UNSUPPORTED = 5, - IB_CM_REJ_INVALID_COMM_ID = 6, - IB_CM_REJ_INVALID_COMM_INSTANCE = 7, - IB_CM_REJ_INVALID_SERVICE_ID = 8, - IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, - IB_CM_REJ_STALE_CONN = 10, - IB_CM_REJ_RDC_NOT_EXIST = 11, - IB_CM_REJ_INVALID_GID = 12, - IB_CM_REJ_INVALID_LID = 13, - IB_CM_REJ_INVALID_SL = 14, - IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, - IB_CM_REJ_INVALID_HOP_LIMIT = 16, - IB_CM_REJ_INVALID_PACKET_RATE = 17, - IB_CM_REJ_INVALID_ALT_GID = 18, - IB_CM_REJ_INVALID_ALT_LID = 19, - IB_CM_REJ_INVALID_ALT_SL = 20, - IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, - IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, - IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, - IB_CM_REJ_PORT_CM_REDIRECT = 24, - IB_CM_REJ_PORT_REDIRECT = 25, - IB_CM_REJ_INVALID_MTU = 26, - IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, - IB_CM_REJ_CONSUMER_DEFINED = 28, - IB_CM_REJ_INVALID_RNR_RETRY = 29, - IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, - IB_CM_REJ_INVALID_CLASS_VERSION = 31, - IB_CM_REJ_INVALID_FLOW_LABEL = 32, - IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33 -}; - -struct ib_cm_rej_event_param { - enum ib_cm_rej_reason reason; - void *ari; - uint8_t ari_length; -}; - -struct ib_cm_mra_event_param { - uint8_t service_timeout; -}; - -struct ib_cm_lap_event_param { - struct ibv_sa_path_rec *alternate_path; -}; - -enum ib_cm_apr_status { - IB_CM_APR_SUCCESS, - IB_CM_APR_INVALID_COMM_ID, - IB_CM_APR_UNSUPPORTED, - IB_CM_APR_REJECT, - IB_CM_APR_REDIRECT, - IB_CM_APR_IS_CURRENT, - IB_CM_APR_INVALID_QPN_EECN, - IB_CM_APR_INVALID_LID, - IB_CM_APR_INVALID_GID, - IB_CM_APR_INVALID_FLOW_LABEL, - IB_CM_APR_INVALID_TCLASS, - IB_CM_APR_INVALID_HOP_LIMIT, - IB_CM_APR_INVALID_PACKET_RATE, - IB_CM_APR_INVALID_SL -}; - -struct ib_cm_apr_event_param { - enum ib_cm_apr_status ap_status; - void *apr_info; - uint8_t info_len; -}; - -struct ib_cm_sidr_req_event_param { - struct ib_cm_id *listen_id; - uint8_t port; - uint16_t pkey; -}; - -enum ib_cm_sidr_status { - IB_SIDR_SUCCESS, - IB_SIDR_UNSUPPORTED, - IB_SIDR_REJECT, - IB_SIDR_NO_QP, - IB_SIDR_REDIRECT, - IB_SIDR_UNSUPPORTED_VERSION -}; - -struct ib_cm_sidr_rep_event_param { - enum ib_cm_sidr_status status; - uint32_t qkey; - uint32_t qpn; - void *info; - uint8_t info_len; -}; - -struct ib_cm_event { - struct ib_cm_id *cm_id; - enum ib_cm_event_type event; - union { - struct ib_cm_req_event_param req_rcvd; - struct ib_cm_rep_event_param rep_rcvd; - /* No data for RTU received events. */ - struct ib_cm_rej_event_param rej_rcvd; - struct ib_cm_mra_event_param mra_rcvd; - struct ib_cm_lap_event_param lap_rcvd; - struct ib_cm_apr_event_param apr_rcvd; - /* No data for DREQ/DREP received events. */ - struct ib_cm_sidr_req_event_param sidr_req_rcvd; - struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; - enum ibv_wc_status send_status; - } param; - - void *private_data; -}; - -/** - * ib_cm_get_event - Retrieves the next pending communications event, - * if no event is pending waits for an event. - * @device: CM device to retrieve the event. - * @event: Allocated information about the next communication event. - * Event should be freed using ib_cm_ack_event() - * - * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events - * generated as a result of listen requests result in the allocation of a - * new @cm_id. - * Clients are responsible for destroying the new @cm_id. For peer-to-peer - * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds - * to a user's existing communication identifier. - */ -int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event); - -/** - * ib_cm_ack_event - Free a communications event. - * @event: Event to be released. - * - * All events which are allocated by ib_cm_get_event() must be released, - * there should be a one-to-one correspondence between successful gets - * and puts. - */ -int ib_cm_ack_event(struct ib_cm_event *event); - -/** - * ib_cm_open_device - Returns the device the CM uses to submit requests - * and retrieve events, corresponding to the specified verbs device. - * - * The CM device contains the file descriptor that the CM uses to - * communicate with the kernel CM component. The primary use of the - * file descriptor is to test for CM readiness events. When the CM - * becomes ready to READ there is a pending event ready, and a subsequent - * call to ib_cm_get_event will not block. - * Note: The user should not read or write directly to the CM file - * descriptor, it will likely result in an error or unexpected - * results. - */ -struct ib_cm_device* ib_cm_open_device(struct ibv_context *device_context); - -/** - * ib_cm_close_device - Close a CM device. - * @device: Device to close. - */ -void ib_cm_close_device(struct ib_cm_device *device); - -/** - * ib_cm_create_id - Allocate a communication identifier. - * - * Communication identifiers are used to track connection states, service - * ID resolution requests, and listen requests. - */ -int ib_cm_create_id(struct ib_cm_device *device, - struct ib_cm_id **cm_id, void *context); - -/** - * ib_cm_destroy_id - Destroy a connection identifier. - * @cm_id: Connection identifier to destroy. - */ -int ib_cm_destroy_id(struct ib_cm_id *cm_id); - -struct ib_cm_attr_param { - __be64 service_id; - __be64 service_mask; - __be32 local_id; - __be32 remote_id; -}; - -/** - * ib_cm_attr_id - Get connection identifier attributes. - * @cm_id: Connection identifier to retrieve attributes. - * @param: Destination of retreived parameters. - * - * Not all parameters are valid during all connection states. - */ -int ib_cm_attr_id(struct ib_cm_id *cm_id, - struct ib_cm_attr_param *param); - -#define IB_CM_ASSIGN_SERVICE_ID_MASK htobe64(0xFF00000000000000ULL) -#define IB_CM_ASSIGN_SERVICE_ID htobe64(0x0200000000000000ULL) - -/** - * ib_cm_listen - Initiates listening on the specified service ID for - * connection and service ID resolution requests. - * @cm_id: Connection identifier associated with the listen request. - * @service_id: Service identifier matched against incoming connection - * and service ID resolution requests. The service ID should be specified - * network-byte order. - * @service_mask: Mask applied to service ID used to listen across a - * range of service IDs. If set to 0, the service ID is matched - * exactly. - */ -int ib_cm_listen(struct ib_cm_id *cm_id, - __be64 service_id, - __be64 service_mask); - -struct ib_cm_req_param { - struct ibv_sa_path_rec *primary_path; - struct ibv_sa_path_rec *alternate_path; - __be64 service_id; - uint32_t qp_num; - enum ibv_qp_type qp_type; - uint32_t starting_psn; - void *private_data; - uint8_t private_data_len; - uint8_t peer_to_peer; - uint8_t responder_resources; - uint8_t initiator_depth; - uint8_t remote_cm_response_timeout; - uint8_t flow_control; - uint8_t local_cm_response_timeout; - uint8_t retry_count; - uint8_t rnr_retry_count; - uint8_t max_cm_retries; - uint8_t srq; -}; - -/** - * ib_cm_send_req - Sends a connection request to the remote node. - * @cm_id: Connection identifier that will be associated with the - * connection request. - * @param: Connection request information needed to establish the - * connection. - */ -int ib_cm_send_req(struct ib_cm_id *cm_id, - struct ib_cm_req_param *param); - -struct ib_cm_rep_param { - uint32_t qp_num; - uint32_t starting_psn; - void *private_data; - uint8_t private_data_len; - uint8_t responder_resources; - uint8_t initiator_depth; - uint8_t target_ack_delay; - uint8_t failover_accepted; - uint8_t flow_control; - uint8_t rnr_retry_count; - uint8_t srq; -}; - -/** - * ib_cm_send_rep - Sends a connection reply in response to a connection - * request. - * @cm_id: Connection identifier that will be associated with the - * connection request. - * @param: Connection reply information needed to establish the - * connection. - */ -int ib_cm_send_rep(struct ib_cm_id *cm_id, - struct ib_cm_rep_param *param); - -/** - * ib_cm_send_rtu - Sends a connection ready to use message in response - * to a connection reply message. - * @cm_id: Connection identifier associated with the connection request. - * @private_data: Optional user-defined private data sent with the - * ready to use message. - * @private_data_len: Size of the private data buffer, in bytes. - */ -int ib_cm_send_rtu(struct ib_cm_id *cm_id, - void *private_data, - uint8_t private_data_len); - -/** - * ib_cm_send_dreq - Sends a disconnection request for an existing - * connection. - * @cm_id: Connection identifier associated with the connection being - * released. - * @private_data: Optional user-defined private data sent with the - * disconnection request message. - * @private_data_len: Size of the private data buffer, in bytes. - */ -int ib_cm_send_dreq(struct ib_cm_id *cm_id, - void *private_data, - uint8_t private_data_len); - -/** - * ib_cm_send_drep - Sends a disconnection reply to a disconnection request. - * @cm_id: Connection identifier associated with the connection being - * released. - * @private_data: Optional user-defined private data sent with the - * disconnection reply message. - * @private_data_len: Size of the private data buffer, in bytes. - */ -int ib_cm_send_drep(struct ib_cm_id *cm_id, - void *private_data, - uint8_t private_data_len); - -/** - * ib_cm_notify - Notifies the CM of an event reported to the consumer. - * @cm_id: Connection identifier to transition to established. - * @event: Type of event. - * - * This routine should be invoked by users to notify the CM of relevant - * communication events. Events that should be reported to the CM and - * when to report them are: - * - * IBV_EVENT_COMM_EST - Used when a message is received on a connected - * QP before an RTU has been received. - * IBV_EVENT_PATH_MIG - Notifies the CM that the connection has failed over - * to the alternate path. - */ -int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event); - -/** - * ib_cm_send_rej - Sends a connection rejection message to the - * remote node. - * @cm_id: Connection identifier associated with the connection being - * rejected. - * @reason: Reason for the connection request rejection. - * @ari: Optional additional rejection information. - * @ari_length: Size of the additional rejection information, in bytes. - * @private_data: Optional user-defined private data sent with the - * rejection message. - * @private_data_len: Size of the private data buffer, in bytes. - */ -int ib_cm_send_rej(struct ib_cm_id *cm_id, - enum ib_cm_rej_reason reason, - void *ari, - uint8_t ari_length, - void *private_data, - uint8_t private_data_len); - -/** - * ib_cm_send_mra - Sends a message receipt acknowledgement to a connection - * message. - * @cm_id: Connection identifier associated with the connection message. - * @service_timeout: The maximum time required for the sender to reply to - * to the connection message. - * @private_data: Optional user-defined private data sent with the - * message receipt acknowledgement. - * @private_data_len: Size of the private data buffer, in bytes. - */ -int ib_cm_send_mra(struct ib_cm_id *cm_id, - uint8_t service_timeout, - void *private_data, - uint8_t private_data_len); - -/** - * ib_cm_send_lap - Sends a load alternate path request. - * @cm_id: Connection identifier associated with the load alternate path - * message. - * @alternate_path: A path record that identifies the alternate path to - * load. - * @private_data: Optional user-defined private data sent with the - * load alternate path message. - * @private_data_len: Size of the private data buffer, in bytes. - */ -int ib_cm_send_lap(struct ib_cm_id *cm_id, - struct ibv_sa_path_rec *alternate_path, - void *private_data, - uint8_t private_data_len); - -/** - * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning - * to a specified QP state. - * @cm_id: Communication identifier associated with the QP attributes to - * initialize. - * @qp_attr: On input, specifies the desired QP state. On output, the - * mandatory and desired optional attributes will be set in order to - * modify the QP to the specified state. - * @qp_attr_mask: The QP attribute mask that may be used to transition the - * QP to the specified state. - * - * Users must set the @qp_attr->qp_state to the desired QP state. This call - * will set all required attributes for the given transition, along with - * known optional attributes. Users may override the attributes returned from - * this call before calling ib_modify_qp. - */ -int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, - struct ibv_qp_attr *qp_attr, - int *qp_attr_mask); - -/** - * ib_cm_send_apr - Sends an alternate path response message in response to - * a load alternate path request. - * @cm_id: Connection identifier associated with the alternate path response. - * @status: Reply status sent with the alternate path response. - * @info: Optional additional information sent with the alternate path - * response. - * @info_length: Size of the additional information, in bytes. - * @private_data: Optional user-defined private data sent with the - * alternate path response message. - * @private_data_len: Size of the private data buffer, in bytes. - */ -int ib_cm_send_apr(struct ib_cm_id *cm_id, - enum ib_cm_apr_status status, - void *info, - uint8_t info_length, - void *private_data, - uint8_t private_data_len); - -struct ib_cm_sidr_req_param { - struct ibv_sa_path_rec *path; - __be64 service_id; - int timeout_ms; - void *private_data; - uint8_t private_data_len; - uint8_t max_cm_retries; -}; - -/** - * ib_cm_send_sidr_req - Sends a service ID resolution request to the - * remote node. - * @cm_id: Communication identifier that will be associated with the - * service ID resolution request. - * @param: Service ID resolution request information. - */ -int ib_cm_send_sidr_req(struct ib_cm_id *cm_id, - struct ib_cm_sidr_req_param *param); - -struct ib_cm_sidr_rep_param { - uint32_t qp_num; - uint32_t qkey; - enum ib_cm_sidr_status status; - void *info; - uint8_t info_length; - void *private_data; - uint8_t private_data_len; -}; - -/** - * ib_cm_send_sidr_rep - Sends a service ID resolution reply to the - * remote node. - * @cm_id: Communication identifier associated with the received service ID - * resolution request. - * @param: Service ID resolution reply information. - */ -int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id, - struct ib_cm_sidr_rep_param *param); - -#ifdef __cplusplus -} -#endif - -#endif /* CM_H */ diff --git a/usr/rdma-core/libibcm/cm_abi.h b/usr/rdma-core/libibcm/cm_abi.h deleted file mode 100644 index 8b76dc1fb..000000000 --- a/usr/rdma-core/libibcm/cm_abi.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef INFINIBAND_CM_ABI_H -#define INFINIBAND_CM_ABI_H - -#warning "This header is obsolete, use rdma/ib_user_cm.h instead" - -#include - -#define cm_abi_cmd_hdr ib_ucm_cmd_hdr -#define cm_abi_create_id ib_ucm_create_id -#define cm_abi_create_id_resp ib_ucm_create_id_resp -#define cm_abi_destroy_id ib_ucm_destroy_id -#define cm_abi_destroy_id_resp ib_ucm_destroy_id_resp -#define cm_abi_attr_id ib_ucm_attr_id -#define cm_abi_attr_id_resp ib_ucm_attr_id_resp -#define cm_abi_init_qp_attr ib_ucm_init_qp_attr -#define cm_abi_listen ib_ucm_listen -#define cm_abi_establish ib_ucm_establish -#define cm_abi_notify ib_ucm_notify -#define cm_abi_private_data ib_ucm_private_data -#define cm_abi_req ib_ucm_req -#define cm_abi_rep ib_ucm_rep -#define cm_abi_info ib_ucm_info -#define cm_abi_mra ib_ucm_mra -#define cm_abi_lap ib_ucm_lap -#define cm_abi_sidr_req ib_ucm_sidr_req -#define cm_abi_sidr_rep ib_ucm_sidr_rep -#define cm_abi_event_get ib_ucm_event_get -#define cm_abi_req_event_resp ib_ucm_req_event_resp -#define cm_abi_rep_event_resp ib_ucm_rep_event_resp -#define cm_abi_rej_event_resp ib_ucm_rej_event_resp -#define cm_abi_mra_event_resp ib_ucm_mra_event_resp -#define cm_abi_lap_event_resp ib_ucm_lap_event_resp -#define cm_abi_apr_event_resp ib_ucm_apr_event_resp -#define cm_abi_sidr_req_event_resp ib_ucm_sidr_req_event_resp -#define cm_abi_sidr_rep_event_resp ib_ucm_sidr_rep_event_resp -#define cm_abi_event_resp ib_ucm_event_resp - -#define CM_ABI_PRES_DATA IB_UCM_PRES_DATA -#define CM_ABI_PRES_INFO IB_UCM_PRES_INFO -#define CM_ABI_PRES_PRIMARY IB_UCM_PRES_PRIMARY -#define CM_ABI_PRES_ALTERNATE IB_UCM_PRES_ALTERNATE - -#endif diff --git a/usr/rdma-core/libibcm/examples/CMakeLists.txt b/usr/rdma-core/libibcm/examples/CMakeLists.txt deleted file mode 100644 index ef30a6e17..000000000 --- a/usr/rdma-core/libibcm/examples/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -rdma_test_executable(cmpost cmpost.c) -target_link_libraries(cmpost LINK_PRIVATE ibcm rdmacm) diff --git a/usr/rdma-core/libibcm/examples/cmpost.c b/usr/rdma-core/libibcm/examples/cmpost.c deleted file mode 100644 index b7c955139..000000000 --- a/usr/rdma-core/libibcm/examples/cmpost.c +++ /dev/null @@ -1,774 +0,0 @@ -/* - * Copyright (c) 2004-2006 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -struct cmtest { - struct ibv_device *device; - struct ib_cm_device *cm_dev; - struct ibv_context *verbs; - struct ibv_pd *pd; - struct ibv_device_attr dev_attr; - - /* cm info */ - struct ibv_sa_path_rec path_rec; - - struct cmtest_node *nodes; - int conn_index; - int connects_left; - int disconnects_left; - - /* memory region info */ - struct ibv_mr *mr; - void *mem; -}; - -static struct cmtest test; -static int message_count = 10; -static int message_size = 100; -static int connections = 1; -static int is_server = 1; - -struct cmtest_node { - int id; - struct ibv_cq *cq; - struct ibv_qp *qp; - struct ib_cm_id *cm_id; - int connected; -}; - -static int post_recvs(struct cmtest_node *node) -{ - struct ibv_recv_wr recv_wr, *recv_failure; - struct ibv_sge sge; - int i, ret = 0; - - if (!message_count) - return 0; - - recv_wr.next = NULL; - recv_wr.sg_list = &sge; - recv_wr.num_sge = 1; - recv_wr.wr_id = (uintptr_t) node; - - sge.length = message_size; - sge.lkey = test.mr->lkey; - sge.addr = (uintptr_t) test.mem; - - for (i = 0; i < message_count && !ret; i++ ) { - ret = ibv_post_recv(node->qp, &recv_wr, &recv_failure); - if (ret) { - printf("failed to post receives: %d\n", ret); - break; - } - } - return ret; -} - -static int modify_to_rtr(struct cmtest_node *node, - struct ib_cm_rep_param *rep) -{ - struct ibv_qp_attr qp_attr; - int qp_attr_mask, ret; - - qp_attr.qp_state = IBV_QPS_INIT; - ret = ib_cm_init_qp_attr(node->cm_id, &qp_attr, &qp_attr_mask); - if (ret) { - printf("failed to init QP attr for INIT: %d\n", ret); - return ret; - } - ret = ibv_modify_qp(node->qp, &qp_attr, qp_attr_mask); - if (ret) { - printf("failed to modify QP to INIT: %d\n", ret); - return ret; - } - qp_attr.qp_state = IBV_QPS_RTR; - ret = ib_cm_init_qp_attr(node->cm_id, &qp_attr, &qp_attr_mask); - if (ret) { - printf("failed to init QP attr for RTR: %d\n", ret); - return ret; - } - qp_attr.rq_psn = node->qp->qp_num; - if (rep) { - qp_attr.max_dest_rd_atomic = rep->responder_resources; - qp_attr.max_rd_atomic = rep->initiator_depth; - } - ret = ibv_modify_qp(node->qp, &qp_attr, qp_attr_mask); - if (ret) { - printf("failed to modify QP to RTR: %d\n", ret); - return ret; - } - return 0; -} - -static int modify_to_rts(struct cmtest_node *node) -{ - struct ibv_qp_attr qp_attr; - int qp_attr_mask, ret; - - qp_attr.qp_state = IBV_QPS_RTS; - ret = ib_cm_init_qp_attr(node->cm_id, &qp_attr, &qp_attr_mask); - if (ret) { - printf("failed to init QP attr for RTS: %d\n", ret); - return ret; - } - ret = ibv_modify_qp(node->qp, &qp_attr, qp_attr_mask); - if (ret) { - printf("failed to modify QP to RTS: %d\n", ret); - return ret; - } - return 0; -} - -static void req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) -{ - struct cmtest_node *node; - struct ib_cm_req_event_param *req; - struct ib_cm_rep_param rep; - int ret; - - if (test.conn_index == connections) - goto error1; - node = &test.nodes[test.conn_index++]; - - req = &event->param.req_rcvd; - memset(&rep, 0, sizeof rep); - - /* - * Limit the responder resources requested by the remote - * to our capabilities. Note that the kernel swaps - * req->responder_resources and req->initiator_depth, so - * that req->responder_resources is actually the active - * side's initiator depth. - */ - if (req->responder_resources > test.dev_attr.max_qp_rd_atom) - rep.responder_resources = test.dev_attr.max_qp_rd_atom; - else - rep.responder_resources = req->responder_resources; - - /* - * Note: if this side of the connection is never going to - * use RDMA read opreations, then initiator_depth can be set - * to 0 here. - */ - if (req->initiator_depth > test.dev_attr.max_qp_init_rd_atom) - rep.initiator_depth = test.dev_attr.max_qp_init_rd_atom; - else - rep.initiator_depth = req->initiator_depth; - - node->cm_id = cm_id; - cm_id->context = node; - - ret = modify_to_rtr(node, &rep); - if (ret) - goto error2; - - ret = post_recvs(node); - if (ret) - goto error2; - - rep.qp_num = node->qp->qp_num; - rep.srq = (node->qp->srq != NULL); - rep.starting_psn = node->qp->qp_num; - rep.target_ack_delay = 20; - rep.flow_control = req->flow_control; - rep.rnr_retry_count = req->rnr_retry_count; - - ret = ib_cm_send_rep(cm_id, &rep); - if (ret) { - printf("failed to send CM REP: %d\n", ret); - goto error2; - } - return; -error2: - test.disconnects_left--; - test.connects_left--; -error1: - printf("failing connection request\n"); - ib_cm_send_rej(cm_id, IB_CM_REJ_UNSUPPORTED, NULL, 0, NULL, 0); -} - -static void rep_handler(struct cmtest_node *node, struct ib_cm_event *event) -{ - int ret; - - ret = modify_to_rtr(node, NULL); - if (ret) - goto error; - - ret = modify_to_rts(node); - if (ret) - goto error; - - ret = post_recvs(node); - if (ret) - goto error; - - ret = ib_cm_send_rtu(node->cm_id, NULL, 0); - if (ret) { - printf("failed to send CM RTU: %d\n", ret); - goto error; - } - node->connected = 1; - test.connects_left--; - return; -error: - printf("failing connection reply\n"); - ib_cm_send_rej(node->cm_id, IB_CM_REJ_UNSUPPORTED, NULL, 0, NULL, 0); - test.disconnects_left--; - test.connects_left--; -} - -static void rtu_handler(struct cmtest_node *node) -{ - int ret; - - ret = modify_to_rts(node); - if (ret) - goto error; - - node->connected = 1; - test.connects_left--; - return; -error: - printf("aborting connection - disconnecting\n"); - ib_cm_send_dreq(node->cm_id, NULL, 0); - test.disconnects_left--; - test.connects_left--; -} - -static void cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) -{ - struct cmtest_node *node = cm_id->context; - - switch (event->event) { - case IB_CM_REQ_RECEIVED: - req_handler(cm_id, event); - break; - case IB_CM_REP_RECEIVED: - rep_handler(node, event); - break; - case IB_CM_RTU_RECEIVED: - rtu_handler(node); - break; - case IB_CM_DREQ_RECEIVED: - node->connected = 0; - ib_cm_send_drep(node->cm_id, NULL, 0); - test.disconnects_left--; - break; - case IB_CM_DREP_RECEIVED: - test.disconnects_left--; - break; - case IB_CM_REJ_RECEIVED: - printf("Received REJ\n"); - /* fall through */ - case IB_CM_REQ_ERROR: - case IB_CM_REP_ERROR: - printf("Error sending REQ or REP\n"); - test.disconnects_left--; - test.connects_left--; - break; - case IB_CM_DREQ_ERROR: - test.disconnects_left--; - printf("Error sending DREQ\n"); - break; - default: - break; - } -} - -static int init_node(struct cmtest_node *node, struct ibv_qp_init_attr *qp_attr) -{ - int cqe, ret; - - if (!is_server) { - ret = ib_cm_create_id(test.cm_dev, &node->cm_id, node); - if (ret) { - printf("failed to create cm_id: %d\n", ret); - return ret; - } - } - - cqe = message_count ? message_count * 2 : 2; - node->cq = ibv_create_cq(test.verbs, cqe, node, NULL, 0); - if (!node->cq) { - printf("unable to create CQ\n"); - goto error1; - } - - qp_attr->send_cq = node->cq; - qp_attr->recv_cq = node->cq; - node->qp = ibv_create_qp(test.pd, qp_attr); - if (!node->qp) { - printf("unable to create QP\n"); - goto error2; - } - return 0; -error2: - ibv_destroy_cq(node->cq); -error1: - if (!is_server) - ib_cm_destroy_id(node->cm_id); - return -1; -} - -static void destroy_node(struct cmtest_node *node) -{ - ibv_destroy_qp(node->qp); - ibv_destroy_cq(node->cq); - if (node->cm_id) - ib_cm_destroy_id(node->cm_id); -} - -static int create_nodes(void) -{ - struct ibv_qp_init_attr qp_attr; - int ret, i; - - test.nodes = malloc(sizeof *test.nodes * connections); - if (!test.nodes) { - printf("unable to allocate memory for test nodes\n"); - return -1; - } - memset(test.nodes, 0, sizeof *test.nodes * connections); - - memset(&qp_attr, 0, sizeof qp_attr); - qp_attr.cap.max_send_wr = message_count ? message_count : 1; - qp_attr.cap.max_recv_wr = message_count ? message_count : 1; - qp_attr.cap.max_send_sge = 1; - qp_attr.cap.max_recv_sge = 1; - qp_attr.qp_type = IBV_QPT_RC; - - for (i = 0; i < connections; i++) { - test.nodes[i].id = i; - ret = init_node(&test.nodes[i], &qp_attr); - if (ret) - goto error; - } - return 0; -error: - while (--i >= 0) - destroy_node(&test.nodes[i]); - free(test.nodes); - return ret; -} - -static void destroy_nodes(void) -{ - int i; - - for (i = 0; i < connections; i++) - destroy_node(&test.nodes[i]); - free(test.nodes); -} - -static int create_messages(void) -{ - if (!message_size) - message_count = 0; - - if (!message_count) - return 0; - - test.mem = malloc(message_size); - if (!test.mem) { - printf("failed message allocation\n"); - return -1; - } - test.mr = ibv_reg_mr(test.pd, test.mem, message_size, - IBV_ACCESS_LOCAL_WRITE); - if (!test.mr) { - printf("failed to reg MR\n"); - goto err; - } - return 0; -err: - free(test.mem); - return -1; -} - -static void destroy_messages(void) -{ - if (!message_count) - return; - - ibv_dereg_mr(test.mr); - free(test.mem); -} - -static int init(void) -{ - struct ibv_device **dev_list; - int ret; - - test.connects_left = connections; - test.disconnects_left = connections; - - dev_list = ibv_get_device_list(NULL); - if (!dev_list) - return -1; - test.device = dev_list[0]; - if (!test.device) - return -1; - - test.verbs = ibv_open_device(test.device); - if (!test.verbs) - return -1; - - if (ibv_query_device(test.verbs, &test.dev_attr)) - return -1; - - test.cm_dev = ib_cm_open_device(test.verbs); - if (!test.cm_dev) - return -1; - - test.pd = ibv_alloc_pd(test.verbs); - if (!test.pd) { - printf("failed to alloc PD\n"); - return -1; - } - ret = create_messages(); - if (ret) { - printf("unable to create test messages\n"); - goto error1; - } - ret = create_nodes(); - if (ret) { - printf("unable to create test nodes\n"); - goto error2; - } - return 0; -error2: - destroy_messages(); -error1: - ibv_dealloc_pd(test.pd); - return -1; -} - -static void cleanup(void) -{ - destroy_nodes(); - destroy_messages(); - ibv_dealloc_pd(test.pd); - ib_cm_close_device(test.cm_dev); - ibv_close_device(test.verbs); -} - -static int send_msgs(void) -{ - struct ibv_send_wr send_wr, *bad_send_wr; - struct ibv_sge sge; - int i, m, ret; - - send_wr.next = NULL; - send_wr.sg_list = &sge; - send_wr.num_sge = 1; - send_wr.opcode = IBV_WR_SEND; - send_wr.send_flags = IBV_SEND_SIGNALED; - send_wr.wr_id = 0; - - sge.addr = (uintptr_t) test.mem; - sge.length = message_size; - sge.lkey = test.mr->lkey; - - for (i = 0; i < connections; i++) { - if (!test.nodes[i].connected) - continue; - - for (m = 0; m < message_count; m++) { - ret = ibv_post_send(test.nodes[i].qp, &send_wr, - &bad_send_wr); - if (ret) - return ret; - } - } - return 0; -} - -static int poll_cqs(void) -{ - struct ibv_wc wc[8]; - int done, i, ret; - - for (i = 0; i < connections; i++) { - if (!test.nodes[i].connected) - continue; - - for (done = 0; done < message_count; done += ret) { - ret = ibv_poll_cq(test.nodes[i].cq, 8, wc); - if (ret < 0) { - printf("failed polling CQ: %d\n", ret); - return ret; - } - } - } - return 0; -} - -static void connect_events(void) -{ - struct ib_cm_event *event; - int err = 0; - - while (test.connects_left && !err) { - err = ib_cm_get_event(test.cm_dev, &event); - if (!err) { - cm_handler(event->cm_id, event); - ib_cm_ack_event(event); - } - } -} - -static void disconnect_events(void) -{ - struct ib_cm_event *event; - int err = 0; - - while (test.disconnects_left && !err) { - err = ib_cm_get_event(test.cm_dev, &event); - if (!err) { - cm_handler(event->cm_id, event); - ib_cm_ack_event(event); - } - } -} - -static void run_server(void) -{ - struct ib_cm_id *listen_id; - int i, ret; - - printf("starting server\n"); - if (ib_cm_create_id(test.cm_dev, &listen_id, &test)) { - printf("listen request failed\n"); - return; - } - ret = ib_cm_listen(listen_id, htobe64(0x1000), 0); - if (ret) { - printf("failure trying to listen: %d\n", ret); - goto out; - } - - connect_events(); - - if (message_count) { - printf("initiating data transfers\n"); - if (send_msgs()) - goto out; - printf("receiving data transfers\n"); - if (poll_cqs()) - goto out; - printf("data transfers complete\n"); - } - - printf("disconnecting\n"); - for (i = 0; i < connections; i++) { - if (!test.nodes[i].connected) - continue; - - test.nodes[i].connected = 0; - ib_cm_send_dreq(test.nodes[i].cm_id, NULL, 0); - } - disconnect_events(); - printf("disconnected\n"); -out: - ib_cm_destroy_id(listen_id); -} - -static int get_dst_addr(char *dst, struct sockaddr_in *addr_in) -{ - struct addrinfo *res; - int ret; - - ret = getaddrinfo(dst, NULL, NULL, &res); - if (ret) - return ret; - - if (res->ai_family != PF_INET) { - ret = -1; - goto out; - } - - *addr_in = *(struct sockaddr_in *) res->ai_addr; - addr_in->sin_port = htobe16(7471); -out: - freeaddrinfo(res); - return ret; -} - -static int query_for_path(char *dst) -{ - struct rdma_event_channel *channel; - struct rdma_cm_id *id; - struct sockaddr_in addr_in; - struct rdma_cm_event *event; - int ret; - - ret = get_dst_addr(dst, &addr_in); - if (ret) - return ret; - - channel = rdma_create_event_channel(); - if (!channel) - return -1; - - ret = rdma_create_id(channel, &id, NULL, RDMA_PS_TCP); - if (ret) - goto destroy_channel; - - ret = rdma_resolve_addr(id, NULL, (struct sockaddr *) &addr_in, 2000); - if (ret) - goto out; - - ret = rdma_get_cm_event(channel, &event); - if (!ret && event->event != RDMA_CM_EVENT_ADDR_RESOLVED) - ret = event->status; - rdma_ack_cm_event(event); - if (ret) - goto out; - - ret = rdma_resolve_route(id, 2000); - if (ret) - goto out; - - ret = rdma_get_cm_event(channel, &event); - if (!ret && event->event != RDMA_CM_EVENT_ROUTE_RESOLVED) - ret = event->status; - rdma_ack_cm_event(event); - if (ret) - goto out; - - test.path_rec = id->route.path_rec[0]; -out: - rdma_destroy_id(id); -destroy_channel: - rdma_destroy_event_channel(channel); - return ret; -} - -static void run_client(char *dst) -{ - struct ib_cm_req_param req; - int i, ret; - - printf("starting client\n"); - ret = query_for_path(dst); - if (ret) { - printf("failed path record query: %d\n", ret); - return; - } - - memset(&req, 0, sizeof req); - req.primary_path = &test.path_rec; - req.service_id = htobe64(0x1000); - - /* - * When choosing the responder resources for a ULP, it is usually - * best to use the maximum value of the HCA. If the other side is - * not going to use RDMA read, then it should zero out the - * initiator_depth in the REP, which will zero out the local - * responder_resources when we program the QP. Generally, the - * initiator_depth should be either set to 0 or - * min(max_qp_rd_atom, max_send_wr). Use 0 if RDMA read is - * never going to be sent from this side. - */ - req.responder_resources = test.dev_attr.max_qp_rd_atom; - req.initiator_depth = test.dev_attr.max_qp_init_rd_atom; - - req.remote_cm_response_timeout = 20; - req.local_cm_response_timeout = 20; - req.retry_count = 5; - req.max_cm_retries = 5; - - printf("connecting\n"); - for (i = 0; i < connections; i++) { - req.qp_num = test.nodes[i].qp->qp_num; - req.qp_type = IBV_QPT_RC; - req.srq = (test.nodes[i].qp->srq != NULL); - req.starting_psn = test.nodes[i].qp->qp_num; - ret = ib_cm_send_req(test.nodes[i].cm_id, &req); - if (ret) { - printf("failure sending REQ: %d\n", ret); - return; - } - } - - connect_events(); - - if (message_count) { - printf("receiving data transfers\n"); - if (poll_cqs()) - goto out; - printf("initiating data transfers\n"); - if (send_msgs()) - goto out; - printf("data transfers complete\n"); - } -out: - disconnect_events(); -} - -int main(int argc, char **argv) -{ - if (argc != 1 && argc != 2) { - printf("usage: %s [server_ip_addr]\n", argv[0]); - exit(1); - } - - is_server = (argc == 1); - if (init()) { - printf("init failed\n"); - exit(1); - } - - if (is_server) - run_server(); - else - run_client(argv[1]); - - printf("test complete\n"); - cleanup(); - return 0; -} diff --git a/usr/rdma-core/libibcm/libibcm.map b/usr/rdma-core/libibcm/libibcm.map deleted file mode 100644 index c94e420a6..000000000 --- a/usr/rdma-core/libibcm/libibcm.map +++ /dev/null @@ -1,26 +0,0 @@ -/* Do not change this file without reading Documentation/versioning.md */ -IBCM_1.0 { - global: - ib_cm_open_device; - ib_cm_close_device; - ib_cm_get_event; - ib_cm_ack_event; - ib_cm_create_id; - ib_cm_destroy_id; - ib_cm_attr_id; - ib_cm_listen; - ib_cm_send_req; - ib_cm_send_rep; - ib_cm_send_rtu; - ib_cm_send_dreq; - ib_cm_send_drep; - ib_cm_notify; - ib_cm_send_rej; - ib_cm_send_mra; - ib_cm_send_lap; - ib_cm_send_apr; - ib_cm_send_sidr_req; - ib_cm_send_sidr_rep; - ib_cm_init_qp_attr; - local: *; -}; diff --git a/usr/rdma-core/libibumad/CMakeLists.txt b/usr/rdma-core/libibumad/CMakeLists.txt deleted file mode 100644 index ba2463b47..000000000 --- a/usr/rdma-core/libibumad/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -publish_headers(infiniband - umad.h - umad_cm.h - umad_sa.h - umad_sm.h - umad_str.h - umad_types.h - ) - -rdma_library(ibumad libibumad.map - # See Documentation/versioning.md - 3 3.0.${PACKAGE_VERSION} - sysfs.c - umad.c - umad_str.c - ) diff --git a/usr/rdma-core/libibumad/libibumad.map b/usr/rdma-core/libibumad/libibumad.map deleted file mode 100644 index 8bf474e26..000000000 --- a/usr/rdma-core/libibumad/libibumad.map +++ /dev/null @@ -1,41 +0,0 @@ -/* Do not change this file without reading Documentation/versioning.md */ -IBUMAD_1.0 { - global: - umad_init; - umad_done; - umad_get_cas_names; - umad_get_ca_portguids; - umad_open_port; - umad_get_ca; - umad_release_ca; - umad_get_port; - umad_release_port; - umad_close_port; - umad_get_mad; - umad_get_issm_path; - umad_size; - umad_set_grh; - umad_set_pkey; - umad_get_pkey; - umad_set_addr; - umad_set_addr_net; - umad_send; - umad_recv; - umad_poll; - umad_get_fd; - umad_register; - umad_register2; - umad_register_oui; - umad_unregister; - umad_status; - umad_get_mad_addr; - umad_debug; - umad_addr_dump; - umad_dump; - umad_class_str; - umad_method_str; - umad_common_mad_status_str; - umad_sa_mad_status_str; - umad_attribute_str; - local: *; -}; diff --git a/usr/rdma-core/libibumad/man/CMakeLists.txt b/usr/rdma-core/libibumad/man/CMakeLists.txt deleted file mode 100644 index 4831d3b16..000000000 --- a/usr/rdma-core/libibumad/man/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -rdma_man_pages( - umad_addr_dump.3 - umad_alloc.3 - umad_class_str.3 - umad_close_port.3 - umad_debug.3 - umad_dump.3 - umad_free.3 - umad_get_ca.3 - umad_get_ca_portguids.3 - umad_get_cas_names.3 - umad_get_fd.3 - umad_get_issm_path.3 - umad_get_mad.3 - umad_get_mad_addr.3 - umad_get_pkey.3 - umad_get_port.3 - umad_init.3 - umad_open_port.3 - umad_poll.3 - umad_recv.3 - umad_register.3 - umad_register2.3 - umad_register_oui.3 - umad_send.3 - umad_set_addr.3 - umad_set_addr_net.3 - umad_set_grh.3 - umad_set_grh_net.3 - umad_set_pkey.3 - umad_size.3 - umad_status.3 - umad_unregister.3 - ) -rdma_alias_man_pages( - umad_class_str.3 umad_attribute_str.3 - umad_class_str.3 umad_mad_status_str.3 - umad_class_str.3 umad_method_str.3 - umad_get_ca.3 umad_release_ca.3 - umad_get_port.3 umad_release_port.3 - umad_init.3 umad_done.3 - ) diff --git a/usr/rdma-core/libibumad/man/umad_addr_dump.3 b/usr/rdma-core/libibumad/man/umad_addr_dump.3 deleted file mode 100644 index d082c37a0..000000000 --- a/usr/rdma-core/libibumad/man/umad_addr_dump.3 +++ /dev/null @@ -1,46 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_ADDR_DUMP 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_addr_dump \- dump addr structure to stderr -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "void umad_addr_dump(ib_mad_addr_t " "*addr"); -.fi -.SH "DESCRIPTION" -.B umad_addr_dump() -dumps the given -.I addr\fR -to stderr. -The argument -.I addr -is an -.I ib_mad_addr_t -struct, as specified in . -.PP -.nf -typedef struct ib_mad_addr { -.in +8 -uint32_t qpn; -uint32_t qkey; -uint16_t lid; -uint8_t sl; -uint8_t path_bits; -uint8_t grh_present; -uint8_t gid_index; -uint8_t hop_limit; -uint8_t traffic_class; -uint8_t gid[16]; -uint32_t flow_label; -.in -8 -} ib_mad_addr_t; -.fi -.SH "RETURN VALUE" -.B umad_addr_dump() -returns no value. -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_alloc.3 b/usr/rdma-core/libibumad/man/umad_alloc.3 deleted file mode 100644 index b5ef752a2..000000000 --- a/usr/rdma-core/libibumad/man/umad_alloc.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_ALLOC 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_alloc \- allocate memory for umad buffers -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "void * umad_alloc(int " "num" ", size_t " "size"); -.fi -.SH "DESCRIPTION" -.B umad_alloc() -allocates memory for an array of -.I num\fR -umad buffers of -.I size -bytes\fR. -Note that -.I size\fR -should include the -.B umad_size() -plus the length (MAD_BLOCK_SIZE for normal MADs or the length returned from -.B umad_recv() -for RMPP MADs). -.SH "RETURN VALUE" -.B umad_alloc() -returns NULL if out of memory. -.SH "SEE ALSO" -.BR umad_free (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_class_str.3 b/usr/rdma-core/libibumad/man/umad_class_str.3 deleted file mode 100644 index 9adb0fd50..000000000 --- a/usr/rdma-core/libibumad/man/umad_class_str.3 +++ /dev/null @@ -1,46 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_CLASS_STR 3 "Feb 15, 2013" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_*_str \- class of functions to return string representations of enums - -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "const char * umad_class_str(uint8_t mgmt_class)" -.BI "const char * umad_method_str(uint8_t mgmt_class, uint8_t method)" -.BI "const char * umad_attribute_str(uint8_t mgmt_class, be16_t attr_id)" - -.BI "const char * umad_common_mad_status_str(be16_t status)" -.BI "const char * umad_sa_mad_status_str(be16_t status)" - -.SH "DESCRIPTION" - -.B "const char * umad_class_str(uint8_t mgmt_class)" -Return string value of management class enum - -.B "const char * umad_method_str(uint8_t mgmt_class, uint8_t method)" -Return string value of the method for the mgmt_class specified - -.B "const char * umad_attribute_str(uint8_t mgmt_class, be16_t attr_id)" -Return string value of attribute specified in attr_id based on mgmt_class specified. - -.B "const char * umad_common_mad_status_str(be16_t status)" -Return string value for common MAD status values - -.B "const char * umad_sa_mad_status_str(be16_t status)" -Return string value for SA MAD status values - - -.B NOTE: -Not all classes are supported. - -.SH "RETURN VALUE" - -Returns a string representations of the fields specified. - -.SH "AUTHOR" -.TP -Ira Weiny diff --git a/usr/rdma-core/libibumad/man/umad_close_port.3 b/usr/rdma-core/libibumad/man/umad_close_port.3 deleted file mode 100644 index 341c2d271..000000000 --- a/usr/rdma-core/libibumad/man/umad_close_port.3 +++ /dev/null @@ -1,27 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_OPEN_PORT 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_close_port \- close InfiniBand device port for umad access -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_close_port(int " "portid" ); -.fi -.SH "DESCRIPTION" -.B umad_close_port() -closes the port specified by the handle -.I portid\fR. -.SH "RETURN VALUE" -.B umad_close_port() -returns 0 on success, and a negative value on error. --EINVAL is returned if the -.I portid\fR -is not a handle to a valid (open) port. -.SH "SEE ALSO" -.BR umad_open_port (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_debug.3 b/usr/rdma-core/libibumad/man/umad_debug.3 deleted file mode 100644 index 224d5c016..000000000 --- a/usr/rdma-core/libibumad/man/umad_debug.3 +++ /dev/null @@ -1,30 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_DEBUG 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_debug \- set debug level -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_debug(int " "level" ); -.fi -.SH "DESCRIPTION" -.B umad_debug() -sets the umad library internal debug level to -.I level\fR. -The following -debug levels are supported: 0 - no debug (the default), -1 - basic debug information, 2 - verbose debug information. Negative values are -ignored in terms of set. Note that the current debug level can -be queried by passing a negative value as -.I level\fR. -.SH "RETURN VALUE" -.B umad_debug() -returns the actual debug level. -.SH "AUTHORS" -.TP -Hal Rosenstock -.TP -Dotan Barak diff --git a/usr/rdma-core/libibumad/man/umad_dump.3 b/usr/rdma-core/libibumad/man/umad_dump.3 deleted file mode 100644 index c01d51bf3..000000000 --- a/usr/rdma-core/libibumad/man/umad_dump.3 +++ /dev/null @@ -1,23 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_DUMP 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_dump \- dump umad buffer to stderr -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "void umad_dump(void " "*umad"); -.fi -.SH "DESCRIPTION" -.B umad_dump() -dumps the given -.I umad\fR -buffer to stderr. -.SH "RETURN VALUE" -.B umad_dump() -returns no value. -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_free.3 b/usr/rdma-core/libibumad/man/umad_free.3 deleted file mode 100644 index e3473170a..000000000 --- a/usr/rdma-core/libibumad/man/umad_free.3 +++ /dev/null @@ -1,24 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_FREE 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_free \- frees memory of umad buffers -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "void umad_free(void " "*umad"); -.fi -.SH "DESCRIPTION" -.B umad_free() -frees memory previously allocated with -.B umad_alloc()\fR. -.SH "RETURN VALUE" -.B umad_free() -returns no value. -.SH "SEE ALSO" -.BR umad_alloc (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_get_ca.3 b/usr/rdma-core/libibumad/man/umad_get_ca.3 deleted file mode 100644 index 760b6b65c..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_ca.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_CA 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_ca, umad_release_ca \- get and release InfiniBand device port attributes -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_get_ca(char " "*ca_name" ", umad_ca_t " "*ca" ); -.sp -.BI "int umad_release_ca(umad_ca_t " "*ca" ); -.fi -.SH "DESCRIPTION" -.B umad_get_ca() -gets the attributes of the InfiniBand device -.I ca_name\fR. -It fills -the -.I ca -structure with the device attributes specified by -the -.I ca_name -or with the default device attributes if -.I ca_name -is NULL. -.B umad_release_ca() -should be called before the -.I ca -structure is deallocated. -The argument -.I ca -is an -.I umad_ca_t -struct, as specified in . -.PP -.nf -typedef struct umad_ca { -.in +8 -char ca_name[UMAD_CA_NAME_LEN]; /* Name of the device */ -uint node_type; /* Type of the device */ -int numports; /* Number of physical ports */ -char fw_ver[20]; /* FW version */ -char ca_type[40]; /* CA type (e.g. MT23108, etc.) */ -char hw_ver[20]; /* Hardware version */ -uint64_t node_guid; /* Node GUID */ -uint64_t system_guid; /* System image GUID */ -umad_port_t *ports[UMAD_CA_MAX_PORTS]; /* Array of device port properties */ -.in -8 -} umad_ca_t; -.fi -.PP -.B umad_release_ca() -releases the resources that were allocated in the function -.B umad_get_ca()\fR. -.SH "RETURN VALUE" -.B umad_get_ca() -and -.B umad_release_ca() -return 0 on success, and a negative value on error. -.SH "AUTHORS" -.TP -Hal Rosenstock -.TP -Dotan Barak diff --git a/usr/rdma-core/libibumad/man/umad_get_ca_portguids.3 b/usr/rdma-core/libibumad/man/umad_get_ca_portguids.3 deleted file mode 100644 index c2a559250..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_ca_portguids.3 +++ /dev/null @@ -1,43 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_CA_PORTGUIDS 3 "August 8, 2016" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_ca_portguids \- get the InfiniBand device ports GUIDs -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_get_ca_portguids(char " "*ca_name" ", __be64 " "*portguids" ", int " "max" ); -.fi -.SH "DESCRIPTION" -.B umad_get_ca_portguids() -fills the -.I portguids\fR -array with up to -.I max -port GUIDs belonging the specified IB device -.I ca_name -, or to the default IB device if -.I ca_name -is NULL. -The argument -.I portguids -is an array of -.I max -uint64_t entries. -.SH "RETURN VALUE" -On success, -.B umad_get_ca_portguids() -returns a non-negative value equal to the number of port GUIDs actually filled. -Not all filled entries may be valid. Invalid entries will be 0. -For example, on a CA node with only one port, this function returns a value of 2. -In this case, the value at index 0 will be invalid as it is reserved for switches. -On failure, a negative value is returned. -.SH "SEE ALSO" -.BR umad_get_cas_names (3) -.SH "AUTHORS" -.TP -Hal Rosenstock -.TP -Dotan Barak diff --git a/usr/rdma-core/libibumad/man/umad_get_cas_names.3 b/usr/rdma-core/libibumad/man/umad_get_cas_names.3 deleted file mode 100644 index 0366c16e5..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_cas_names.3 +++ /dev/null @@ -1,38 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_CAS_NAMES 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_cas_names \- get list of available InfiniBand device names -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_get_cas_names(char " "cas[][UMAD_CA_NAME_LEN]" ", int " "max" ); -.fi -.SH "DESCRIPTION" -.B umad_get_cas_names() -fills the -.I cas -array with up to -.I max -local IB devices (CAs) names. -The argument -.I cas -is a character array with -.I max -entries, each with -.B UMAD_CA_NAME_LEN -characters. -.SH "RETURN VALUE" -.B umad_get_cas_names() -returns a non-negative value equal to the number of entries filled, -or \-1 on errors. -.SH "SEE ALSO" -.BR umad_get_ca_portguids (3), -.BR umad_open_port (3) -.SH "AUTHORS" -.TP -Hal Rosenstock -.TP -Dotan Barak diff --git a/usr/rdma-core/libibumad/man/umad_get_fd.3 b/usr/rdma-core/libibumad/man/umad_get_fd.3 deleted file mode 100644 index 5fe531118..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_fd.3 +++ /dev/null @@ -1,26 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_FD 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_fd \- get the umad fd for the requested port -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_get_fd(int " "portid" ); -.fi -.SH "DESCRIPTION" -.B umad_get_fd() -returns the umad fd for the port specified by -.I portid\fR. -.SH "RETURN VALUE" -.B umad_get_fd() -returns the fd for the -.I portid\fR -requested or -EINVAL if -.I portid\fR -is invalid. -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_get_issm_path.3 b/usr/rdma-core/libibumad/man/umad_get_issm_path.3 deleted file mode 100644 index 4abef18ee..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_issm_path.3 +++ /dev/null @@ -1,39 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_ISSM_PATH 3 "Oct 18, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_issm_path \- get path of issm device -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_get_issm_path(char " "*ca_name" ", int " "portnum", char *path, int max); -.fi -.SH "DESCRIPTION" -.B umad_get_issm_path() -resolves path to issm device (which used for setting/clearing PortInfo:CapMask IsSM bit) for -.I portnum -of the IB device -.I ca_name -, it stores resolved path in -.I path -array which cannot exceed -.I max -bytes in length (including NULL terminator). -.fi -Opening issm device sets PortInfo:CapMask IsSM bit and closing clears it. -.fi -.SH "RETURN VALUE" -.B umad_open_port() -returns 0 on success and a negative value on error as follows: - -ENODEV IB device can\'t be resolved - -EINVAL port is not valid (bad -.I portnum\fR -or no umad device) -.SH "SEE ALSO" -.BR umad_open_port (3), -.BR umad_get_port (3) -.SH "AUTHOR" -.TP -Sasha Khapyorsky diff --git a/usr/rdma-core/libibumad/man/umad_get_mad.3 b/usr/rdma-core/libibumad/man/umad_get_mad.3 deleted file mode 100644 index ac56c4863..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_mad.3 +++ /dev/null @@ -1,25 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_MAD 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_mad \- get the MAD pointer of a umad buffer -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "void * umad_get_mad(void " "*umad"); -.fi -.SH "DESCRIPTION" -.B umad_get_mad() -returns a pointer to the MAD contained within the -.I umad\fR -buffer. -.SH "RETURN VALUE" -.B umad_get_mad() -returns a pointer to the MAD contained within the supplied -.I umad\fR -buffer. -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_get_mad_addr.3 b/usr/rdma-core/libibumad/man/umad_get_mad_addr.3 deleted file mode 100644 index 4a92b7b0a..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_mad_addr.3 +++ /dev/null @@ -1,43 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_MAD_ADDR 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_mad_addr \- get the address of the ib_mad_addr from a umad buffer -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "ib_mad_addr_t * umad_get_mad_addr(void " "*umad"); -.fi -.SH "DESCRIPTION" -.B umad_get_mad_addr() -returns a pointer to the ib_mad_addr struct within the specified -.I umad\fR -buffer. -.SH "RETURN VALUE" -The return value -is a pointer to an -.I ib_mad_addr_t -struct, as specified in . -.PP -.nf -typedef struct ib_mad_addr { -.in +8 -uint32_t qpn; -uint32_t qkey; -uint16_t lid; -uint8_t sl; -uint8_t path_bits; -uint8_t grh_present; -uint8_t gid_index; -uint8_t hop_limit; -uint8_t traffic_class; -uint8_t gid[16]; -uint32_t flow_label; -.in -8 -} ib_mad_addr_t; -.fi -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_get_pkey.3 b/usr/rdma-core/libibumad/man/umad_get_pkey.3 deleted file mode 100644 index b9dd1be7c..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_pkey.3 +++ /dev/null @@ -1,24 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_PKEY 3 "Jan 15, 2008" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_pkey \- get pkey index from umad buffer -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_get_pkey(void " "*umad"); -.fi -.SH "DESCRIPTION" -.B umad_get_pkey() -gets the pkey index from the specified -.I umad\fR -buffer. -.SH "RETURN VALUE" -.B umad_get_pkey() -returns value of pkey index (or zero if pkey index is not supported by -user_mad interface). -.SH "AUTHOR" -.TP -Sasha Khapyorsky diff --git a/usr/rdma-core/libibumad/man/umad_get_port.3 b/usr/rdma-core/libibumad/man/umad_get_port.3 deleted file mode 100644 index 44dbfb0a8..000000000 --- a/usr/rdma-core/libibumad/man/umad_get_port.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_GET_PORT 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_get_port, umad_release_port \- open and close an InfiniBand port -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_get_port(char " "*ca_name" ", int " "portnum" ", umad_port_t " "*port" ); -.sp -.BI "int umad_release_port(umad_port_t " "*port" ); -.fi -.SH "DESCRIPTION" -.B umad_get_port() -fills the -.I port -structure with the IB port attributes specified by -.I ca_name -and -.I portnum -, or the default port if -.I ca_name -is NULL and -.I portnum -is zero. If only one of -.I ca_name -and -.I portnum -are specified, the other is used as a filter. -For example, passing a NULL -.I ca_name -and 2 for the -.I portnum -means get a port from any of the local IB devices, as long as it is -the second port. -Note that the library may use some reference scheme to support port caching -therefore -.B umad_release_port() -should be called before the -.I port -structure can be deallocated. -The argument -.I port -is an -.B umad_port_t -struct, as specified in . -.PP -.nf -typedef struct umad_port { -.in +8 -char ca_name[UMAD_CA_NAME_LEN]; /* Name of the device */ -int portnum; /* Physical port number */ -uint base_lid; /* Base port LID */ -uint lmc; /* LMC of LID */ -uint sm_lid; /* SM LID */ -uint sm_sl; /* SM service level */ -uint state; /* Logical port state */ -uint phys_state; /* Physical port state */ -uint rate; /* Port link bit rate */ -uint64_t capmask; /* Port capabilities */ -uint64_t gid_prefix; /* Gid prefix of this port */ -uint64_t port_guid; /* GUID of this port */ -.in -8 -} umad_port_t; -.fi -.PP -.B umad_release_port() -releases the resources that were allocated by the -.B umad_get_port() -function for the specified IB -.I port\fR. -.SH "RETURN VALUE" -.B umad_get_port() -and -.B umad_release_port() -return 0 on success, and a negative value on error. -.SH "AUTHORS" -.TP -Hal Rosenstock -.TP -Dotan Barak diff --git a/usr/rdma-core/libibumad/man/umad_init.3 b/usr/rdma-core/libibumad/man/umad_init.3 deleted file mode 100644 index 64366b9de..000000000 --- a/usr/rdma-core/libibumad/man/umad_init.3 +++ /dev/null @@ -1,40 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_INIT 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_init, umad_done \- perform library initialization and finalization -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_init(void); -.sp -.BI "int umad_done(void); -.fi -.SH "DESCRIPTION" -.B umad_init() -initializes the umad library for use. Must be called before any -other call to this library. -.PP -.B umad_done() -finalizes the use of the umad library. -.SH "RETURN VALUE" -.B umad_init() -and -.B umad_done() -return 0 on success, and \-1 on error. -Error is returned from -.B umad_init() -if infiniband umad -can\'t be opened, or the abi version doesn\'t match. -There are no errors currently returned by -.B umad_done(). -.SH "NOTES" -If an error occurs during the library initialization, no further use of the -umad library should be attempted. -.SH "AUTHORS" -.TP -Hal Rosenstock -.TP -Dotan Barak diff --git a/usr/rdma-core/libibumad/man/umad_open_port.3 b/usr/rdma-core/libibumad/man/umad_open_port.3 deleted file mode 100644 index cac01a710..000000000 --- a/usr/rdma-core/libibumad/man/umad_open_port.3 +++ /dev/null @@ -1,38 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_OPEN_PORT 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_open_port \- open InfiniBand device port for umad access -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_open_port(char " "*ca_name" ", int " "portnum" ); -.fi -.SH "DESCRIPTION" -.B umad_open_port() -opens the port -.I portnum -of the IB device -.I ca_name -for umad access. The port is selected by the library if not all parameters -are provided (see -.B umad_get_port() -for details). -.fi -.SH "RETURN VALUE" -.B umad_open_port() -returns 0 or an unique positive value of umad device descriptor on success, and a negative value on error as follows: - -ENODEV IB device can\'t be resolved - -EINVAL port is not valid (bad -.I portnum\fR -or no umad device) - -EIO umad device for this port can\'t be opened -.SH "SEE ALSO" -.BR umad_close_port (3), -.BR umad_get_cas_names (3), -.BR umad_get_port (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_poll.3 b/usr/rdma-core/libibumad/man/umad_poll.3 deleted file mode 100644 index 57b7a6536..000000000 --- a/usr/rdma-core/libibumad/man/umad_poll.3 +++ /dev/null @@ -1,41 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_POLL 3 "October 23, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_poll \- poll umad -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_poll(int " "portid" ", int " "timeout_ms"); -.fi -.SH "DESCRIPTION" -.B umad_poll() -waits up to -.I timeout_ms\fR -milliseconds for a packet to be received from the port specified by -.I portid\fR. -Once a packet is ready to be read, the function -returns 0. After that the packet can be read using -.B umad_recv(). -Otherwise, \-ETIMEDOUT is returned. Note that successfully polling a port -does not guarantee that the subsequent -.B umad_recv() -will be non blocking when several threads are using -the same port. Instead, use a -.I timeout_ms\fR -parameter of zero to -.B umad_recv() -to ensure a non-blocking read. -.SH "RETURN VALUE" -.B umad_poll() -returns 0 on success, and a negative value on error as follows: - -EINVAL invalid port handle or agentid - -ETIMEDOUT poll operation timed out - -EIO poll operation failed -.SH "SEE ALSO" -.BR umad_recv (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_recv.3 b/usr/rdma-core/libibumad/man/umad_recv.3 deleted file mode 100644 index 93eec993c..000000000 --- a/usr/rdma-core/libibumad/man/umad_recv.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_RECV 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_recv \- receive umad -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_recv(int " "portid" ", void " "*umad" ", int " "*length" ", int " "timeout_ms"); -.fi -.SH "DESCRIPTION" -.B umad_recv() -waits up to -.I timeout_ms\fR -milliseconds for an incoming MAD message to be received from the port specified by -.I portid\fR. - -A MAD "message" consists of a single MAD packet -.I or -a coalesced multipacket RMPP transmission. In the RMPP case the header of the -first RMPP packet is returned as the header of the buffer and the buffer data -contains the coalesced data section of each subsequent RMPP MAD packet within -the transmission. Thus all the RMPP headers except the first are not copied to -user space from the kernel. - -The message is copied to the -.I umad\fR -buffer if there is sufficient room and the received -.I length\fR is indicated. -If the buffer is not large enough, the size of the umad -buffer needed is returned in -.I length\fR. -A negative -.I timeout_ms\fR -makes the function block until a packet is received. A -.I timeout_ms\fR -parameter of zero indicates a non blocking read. - -.B Note -.I length -is a pointer to the length of the -.B data -portion of the umad buffer. This means that -.I umad -must point to a buffer at least umad_size() + -.I *length -bytes long. - -.B Note also -that -.I *length\fR -must be >= 256 bytes. This length allows for at least a single MAD packet to -be returned. - -.SH "RETURN VALUE" -.B umad_recv() -on success return the agentid; on error, errno is set and a negative value is -returned as follows: - -EINVAL invalid port handle or agentid or *length is less than the minimum supported - -EIO receive operation failed - -EWOULDBLOCK non blocking read can't be fulfilled - -ENOSPC The provided buffer is not long enough for the complete message. -.SH "SEE ALSO" -.BR umad_poll (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_register.3 b/usr/rdma-core/libibumad/man/umad_register.3 deleted file mode 100644 index 58b88f3a3..000000000 --- a/usr/rdma-core/libibumad/man/umad_register.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_REGISTER 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_register \- register the specified management class and version for port -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_register(int " "portid" ", int " "mgmt_class" ", int " "mgmt_version" " , uint8_t " "rmpp_version" ", long " "method_mask[16/sizeof(long)]"); -.fi -.SH "DESCRIPTION" -.B umad_register() -registers the specified management class, management version, -and whether RMPP is being used for the port specified by the -.I portid\fR -parameter. If -.I method_mask\fR -array is provided, the caller is registered as a replier (server) for the -methods having their corresponding bit on in the -.I method_mask\fR. -If -.I method_mask\fR -is NULL, the caller is registered as a MAD client, meaning that it can -only receive replies on MADs that it sent (solicited MADs). -.SH "RETURN VALUE" -.B umad_register() -returns non-negative agent id number on success, and a negative value on error as follows: - -EINVAL invalid port handle - -EPERM registration failed -.SH "SEE ALSO" -.BR umad_register_oui(3), -.BR umad_unregister (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_register2.3 b/usr/rdma-core/libibumad/man/umad_register2.3 deleted file mode 100644 index 74e879436..000000000 --- a/usr/rdma-core/libibumad/man/umad_register2.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_REGISTER2 3 "March 25, 2014" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_register2 \- register the specified management class and version for port -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_register2(int " "port_fd" ", struct umad_reg_attr *" "attr" ", uint32_t *" "agent_id"); -.fi -.SH "DESCRIPTION" -.B umad_register2() -registers for a MAD agent using the provided registration attributes - -.I port_fd\fR -the port on which to register the agent - -.I attr\fR -The registration attributes as defined by the structure passed. See below for details of this structure. - -.I agent_id\fR -returned on success. agent_id identifies the kernel MAD agent a MAD is received by or to be sent by. agent_id is returned in the umad header "struct ib_user_mad" on recv and specified in umad_send when sending. - - -.SH "REGISTRATION ATTRIBUTE STRUCTURE" -.nf -struct umad_reg_attr { -.in +8 -uint8_t mgmt_class; -uint8_t mgmt_class_version; -uint32_t flags; -uint64_t method_mask[2]; -uint32_t oui; -uint8_t rmpp_version; -.in -8 -}; - -.I mgmt_class\fR -Management class to register for. - -.I mgmt_class_version\fR -Management class version to register for. - -.I flags\fR -Registration flags. If a flag specified is not supported by the kernel, -an error is returned, and the supported flags are returned in this field. - -.P -Current flags are: -.in +8 -UMAD_USER_RMPP -- flag to indicate the kernel should not process -RMPP packets. All RMPP packets will be treated like individual -MADs. The user is responsible for implementing the RMPP -protocol. -.in -8 - -.I method_mask\fR -A bit mask which indicates which unsolicited methods this agent should -receive. Setting this array to 0 will result in the agent only -receiving response MADs for which a request was sent. - -.I oui\fR -The oui (in host order) to use for vendor classes 0x30 - 0x4f. -Otherwise ignored. - -.I rmpp_version\fR -If the class supports RMPP and kernel RMPP is enabled (the default) -indicate which rmpp_version to use. - - -.SH "RETURN VALUE" -.B umad_register2() -returns 0 on success and +ERRNO on failure. - -.SH "SEE ALSO" -.BR umad_unregister (3) -.SH "AUTHOR" -.TP -Ira Weiny diff --git a/usr/rdma-core/libibumad/man/umad_register_oui.3 b/usr/rdma-core/libibumad/man/umad_register_oui.3 deleted file mode 100644 index 19430a932..000000000 --- a/usr/rdma-core/libibumad/man/umad_register_oui.3 +++ /dev/null @@ -1,38 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_REGISTER_OUI 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_register_oui \- register the specified class in vendor range 2 for port -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_register_oui(int " "portid" ", int " "mgmt_class" ", uint8_t " "rmpp_version" ", uint8_t " "oui[3]" ", uint32_t " "method_mask[4]"); -.fi -.SH "DESCRIPTION" -.B umad_register_oui() -registers the specified class in vendor range 2, the specified -.I oui\fR, -and whether RMPP is being used for the port specified by the -.I portid\fR -handle. If -.I method_mask\fR -array is provided, the caller is registered as a replier (server) for the -methods having their corresponding bit on in the -.I method_mask\fR. -If -.I method_mask\fR -is NULL, the caller is registered as a MAD client, meaning that it can -only receive replies on MADs that it sent (solicited MADs). -.SH "RETURN VALUE" -.B umad_register() -returns non-negative agent id number on success, and a negative value on error as follows: - -EINVAL invalid port handle or class is not in the vendor class 2 range - -EPERM registration failed -.SH "SEE ALSO" -.BR umad_register (3), -.BR umad_unregister (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_send.3 b/usr/rdma-core/libibumad/man/umad_send.3 deleted file mode 100644 index 59af2cb98..000000000 --- a/usr/rdma-core/libibumad/man/umad_send.3 +++ /dev/null @@ -1,49 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_SEND 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_send \- send umad -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_send(int " "portid" ", int " "agentid" ", void " "*umad" ", int " "length" ", int " "timeout_ms" ", int " "retries"); -.fi -.SH "DESCRIPTION" -.B umad_send() -sends -.I length\fR -bytes from the specified -.I umad\fR -buffer from the port specified by -.I portid\fR, -and using the agent specified by -.I agentid\fR. - -The buffer can contain a RMPP transmission which is larger than a single MAD -packet when the agentid specifies a class which utilizes RMPP and the header -flags indicate RMPP is active. NOTE currently only RMPPFlags.Active is -meaningful in the header in user space. All other RMPP fields are ignored. -The data section of the buffer will be sent in multiple RMPP MAD packets with -headers built for the user. - -.I timeout_ms\fR -controls the solicited MADs behavior as follows: -zero value means not solicited. Positive value makes kernel indicate timeout -in milliseconds. If reply is not received within the specified value, the -original buffer is returned in the read channel with the status field set (to -non zero). Negative -.I timeout_ms\fR -makes kernel wait forever for the reply. -.I retries\fR -indicates the number of times the MAD will be retried before giving up. -.SH "RETURN VALUE" -.B umad_send() -returns 0 on success; on error, errno is set and a negative value is returned -as follows: - -EINVAL invalid port handle or agentid - -EIO send operation failed -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_set_addr.3 b/usr/rdma-core/libibumad/man/umad_set_addr.3 deleted file mode 100644 index 03ac8625c..000000000 --- a/usr/rdma-core/libibumad/man/umad_set_addr.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_SET_ADDR 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_set_addr \- set MAD address fields within umad buffer using host ordering -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_set_addr(void " "*umad" ", int " "dlid" ", int " "dqp" ", int " "sl" ", int " "qkey"); -.fi -.SH "DESCRIPTION" -.B umad_set_addr() -sets the MAD address fields within the specified -.I umad\fR -buffer using the provided host ordered fields. -.I dlid\fR -is the destination LID. -.I dqp\fR -is the destination QP (queue pair). -.I sl\fR -is the SL (service level). -.I qkey\fR -is the Q_Key (queue key). -.SH "RETURN VALUE" -.B umad_set_addr() -returns 0 on success, and a negative value on errors. Currently, there -are no errors indicated. -.SH "SEE ALSO" -.BR umad_set_addr_net (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_set_addr_net.3 b/usr/rdma-core/libibumad/man/umad_set_addr_net.3 deleted file mode 100644 index b395252f8..000000000 --- a/usr/rdma-core/libibumad/man/umad_set_addr_net.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_SET_ADDR_NET 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_set_addr_net \- set MAD address fields within umad buffer using network ordering -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_set_addr_net(void " "*umad" ", __be16 " "dlid" ", __be32 " "dqp" ", int " "sl" ", __be32 " "qkey"); -.fi -.SH "DESCRIPTION" -.B umad_set_addr_net() -sets the MAD address fields within the specified -.I umad\fR -buffer using the provided network ordered fields. -.I dlid\fR -is the destination LID. -.I dqp\fR -is the destination QP (queue pair). -.I sl\fR -is the SL (service level). -.I qkey\fR -is the Q_Key (queue key). -.SH "RETURN VALUE" -.B umad_set_addr_net() -returns 0 on success, and a negative value on errors. Currently, there -are no errors indicated. -.SH "SEE ALSO" -.BR umad_set_addr (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_set_grh.3 b/usr/rdma-core/libibumad/man/umad_set_grh.3 deleted file mode 100644 index 4ff52ec20..000000000 --- a/usr/rdma-core/libibumad/man/umad_set_grh.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_SET_GRH 3 "May 24, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_set_grh \- set GRH fields within umad buffer using host ordering -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_set_grh(void " "*umad" ", void " "*mad_addr"); -.fi -.SH "DESCRIPTION" -.B umad_set_grh() -sets the GRH fields (grh_present, gid, hop_limit, traffic_class, flow_label) -within the specified -.I umad\fR -buffer based on the -.I mad_addr\fR -supplied. The provided -.I mad_addr\fR -fields are expected to be in host order. -If the -.I mad_addr\fR -pointer supplied is NULL, no GRH is set. -The argument -.I mad_addr -is a pointer to an -.I ib_mad_addr_t -struct, as specified in -.I . -The argument -.I umad -is a pointer to an -.I ib_user_mad_t -struct, as specified in -.I . -.PP -.nf -typedef struct ib_mad_addr { -.in +8 -uint32_t qpn; -uint32_t qkey; -uint16_t lid; -uint8_t sl; -uint8_t path_bits; -uint8_t grh_present; -uint8_t gid_index; -uint8_t hop_limit; -uint8_t traffic_class; -uint8_t gid[16]; -uint32_t flow_label; -.in -8 -} ib_mad_addr_t; -.PP -typedef struct ib_user_mad { -.in +8 -uint32_t agent_id; -uint32_t status; -uint32_t timeout_ms; -uint32_t retries; -uint32_t length; -ib_mad_addr_t addr; -uint8_t data[0]; -.in -8 -} ib_user_mad_t; -.fi -.SH "RETURN VALUE" -.B umad_set_grh() -returns 0 on success, and a negative value on errors. Currently, there -are no errors indicated. -.SH "SEE ALSO" -.BR umad_set_grh_net (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_set_grh_net.3 b/usr/rdma-core/libibumad/man/umad_set_grh_net.3 deleted file mode 100644 index 802b575dc..000000000 --- a/usr/rdma-core/libibumad/man/umad_set_grh_net.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_SET_GRH_NET 3 "May 24, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_set_grh_net \- set GRH fields within umad buffer using network ordering -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_set_grh_net(void " "*umad" ", void " "*mad_addr"); -.fi -.SH "DESCRIPTION" -.B umad_set_grh_net() -sets the GRH fields (grh_present, gid, hop_limit, traffic_class, flow_label) -within the specified -.I umad\fR -buffer based on the -.I mad_addr\fR -supplied. The provided -.I mad_addr\fR -fields are expected to be in network order. -If the -.I mad_addr\fR -pointer supplied is NULL, no GRH is set. -The argument -.I mad_addr -is a pointer to an -.I ib_mad_addr_t -struct, as specified in . -The argument -.I umad -is a pointer to an -.I ib_user_mad_t -struct, as specified in -.I . -.PP -.nf -typedef struct ib_mad_addr { -.in +8 -uint32_t qpn; -uint32_t qkey; -uint16_t lid; -uint8_t sl; -uint8_t path_bits; -uint8_t grh_present; -uint8_t gid_index; -uint8_t hop_limit; -uint8_t traffic_class; -uint8_t gid[16]; -uint32_t flow_label; -.in -8 -} ib_mad_addr_t; -.PP -typedef struct ib_user_mad { -.in +8 -uint32_t agent_id; -uint32_t status; -uint32_t timeout_ms; -uint32_t retries; -uint32_t length; -ib_mad_addr_t addr; -uint8_t data[0]; -.in -8 -} ib_user_mad_t; -.fi -.SH "RETURN VALUE" -.B umad_set_grh_net() -returns 0 on success, and a negative value on errors. Currently, there -are no errors indicated. -.SH "KNOWN BUGS" -Not implemented. -.SH "SEE ALSO" -.BR umad_set_grh (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_set_pkey.3 b/usr/rdma-core/libibumad/man/umad_set_pkey.3 deleted file mode 100644 index 23e858ece..000000000 --- a/usr/rdma-core/libibumad/man/umad_set_pkey.3 +++ /dev/null @@ -1,23 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_SET_PKEY 3 "June 20, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_set_pkey \- set pkey index within umad buffer -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_set_pkey(void " "*umad" ", int " "pkey_index"); -.fi -.SH "DESCRIPTION" -.B umad_set_pkey() -sets the pkey index within the specified -.I umad\fR -buffer. -.SH "RETURN VALUE" -.B umad_set_pkey() -returns 0 on success, and a negative value on an error. -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_size.3 b/usr/rdma-core/libibumad/man/umad_size.3 deleted file mode 100644 index 74737ccca..000000000 --- a/usr/rdma-core/libibumad/man/umad_size.3 +++ /dev/null @@ -1,21 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_SIZE 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_size \- get the size of umad buffer -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "size_t umad_size(void); -.fi -.SH "DESCRIPTION" -.B umad_size() -returns the size of umad buffer (in bytes). -.SH "RETURN VALUE" -.B umad_size() -returns the size of umad buffer (in bytes). -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_status.3 b/usr/rdma-core/libibumad/man/umad_status.3 deleted file mode 100644 index fd5430a3e..000000000 --- a/usr/rdma-core/libibumad/man/umad_status.3 +++ /dev/null @@ -1,27 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_STATUS 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_status \- get the status of a umad buffer -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_status(void " "*umad" ); -.fi -.SH "DESCRIPTION" -.B umad_status() -get the internal -.I umad\fR -status field. -.SH "RETURN VALUE" -After a packet is received, -.B umad_status() -returns 0 on a successful receive, or a non zero status. -ETIMEDOUT means that the packet had -a send-timeout indication. In this case, the transaction ID will be -set to the TID of the original request. -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/man/umad_unregister.3 b/usr/rdma-core/libibumad/man/umad_unregister.3 deleted file mode 100644 index 785d22dbe..000000000 --- a/usr/rdma-core/libibumad/man/umad_unregister.3 +++ /dev/null @@ -1,31 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH UMAD_UNREGISTER 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual" -.SH "NAME" -umad_unregister \- unregister umad agent -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int umad_unregister(int " "portid" ", int " "agentid"); -.fi -.SH "DESCRIPTION" -.B umad_unregister() -unregisters the specified -.I agentid\fR -previously registered using -.B umad_register() -or -.B umad_register_oui()\fR. -.SH "RETURN VALUE" -.B umad_unregister() -returns 0 on success and negative value on error as follows: - -EINVAL invalid port handle or agentid - * (kernel error codes) -.SH "SEE ALSO" -.BR umad_register (3), -.BR umad_register_oui (3) -.SH "AUTHOR" -.TP -Hal Rosenstock diff --git a/usr/rdma-core/libibumad/sysfs.c b/usr/rdma-core/libibumad/sysfs.c deleted file mode 100644 index 4584726d5..000000000 --- a/usr/rdma-core/libibumad/sysfs.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sysfs.h" - -static int ret_code(void) -{ - int e = errno; - - if (e > 0) - return -e; - return e; -} - -int sys_read_string(const char *dir_name, const char *file_name, char *str, int max_len) -{ - char path[256], *s; - int fd, r; - - snprintf(path, sizeof(path), "%s/%s", dir_name, file_name); - - if ((fd = open(path, O_RDONLY)) < 0) - return ret_code(); - - if ((r = read(fd, (void *)str, max_len)) < 0) { - int e = errno; - close(fd); - errno = e; - return ret_code(); - } - - str[(r < max_len) ? r : max_len - 1] = 0; - - if ((s = strrchr(str, '\n'))) - *s = 0; - - close(fd); - return 0; -} - -int sys_read_guid(const char *dir_name, const char *file_name, __be64 *net_guid) -{ - char buf[32], *str, *s; - uint64_t guid; - int r, i; - - if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0) - return r; - - guid = 0; - - for (s = buf, i = 0; i < 4; i++) { - if (!(str = strsep(&s, ": \t\n"))) - return -EINVAL; - guid = (guid << 16) | (strtoul(str, NULL, 16) & 0xffff); - } - - *net_guid = htobe64(guid); - - return 0; -} - -int sys_read_gid(const char *dir_name, const char *file_name, - union umad_gid *gid) -{ - char buf[64], *str, *s; - __be16 *ugid = (__be16 *) gid; - int r, i; - - if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0) - return r; - - for (s = buf, i = 0; i < 8; i++) { - if (!(str = strsep(&s, ": \t\n"))) - return -EINVAL; - ugid[i] = htobe16(strtoul(str, NULL, 16) & 0xffff); - } - - return 0; -} - -int sys_read_uint64(const char *dir_name, const char *file_name, uint64_t * u) -{ - char buf[32]; - int r; - - if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0) - return r; - - *u = strtoull(buf, NULL, 0); - - return 0; -} - -int sys_read_uint(const char *dir_name, const char *file_name, unsigned *u) -{ - char buf[32]; - int r; - - if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0) - return r; - - *u = strtoul(buf, NULL, 0); - - return 0; -} diff --git a/usr/rdma-core/libibumad/sysfs.h b/usr/rdma-core/libibumad/sysfs.h deleted file mode 100644 index bad092edc..000000000 --- a/usr/rdma-core/libibumad/sysfs.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2008 Voltaire Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -#ifndef _UMAD_SYSFS_H -#define _UMAD_SYSFS_H - -#include -#include -#include - -extern int sys_read_string(const char *dir_name, const char *file_name, char *str, int len); -extern int sys_read_guid(const char *dir_name, const char *file_name, __be64 * net_guid); -extern int sys_read_gid(const char *dir_name, const char *file_name, - union umad_gid *gid); -extern int sys_read_uint64(const char *dir_name, const char *file_name, uint64_t * u); -extern int sys_read_uint(const char *dir_name, const char *file_name, unsigned *u); - -#endif /* _UMAD_SYSFS_H */ diff --git a/usr/rdma-core/libibumad/tests/CMakeLists.txt b/usr/rdma-core/libibumad/tests/CMakeLists.txt deleted file mode 100644 index 68bb71447..000000000 --- a/usr/rdma-core/libibumad/tests/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -rdma_test_executable(umad_reg2 umad_reg2_compat.c) -target_link_libraries(umad_reg2 LINK_PRIVATE ibumad) - -rdma_test_executable(umad_register2 umad_register2.c) -target_link_libraries(umad_register2 LINK_PRIVATE ibumad) - -rdma_test_executable(umad_compile_test umad_compile_test.c) diff --git a/usr/rdma-core/libibumad/tests/umad_compile_test.c b/usr/rdma-core/libibumad/tests/umad_compile_test.c deleted file mode 100644 index bb6bb29b5..000000000 --- a/usr/rdma-core/libibumad/tests/umad_compile_test.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ -#ifndef __CHECKER__ - /* - * Hide these checks for sparse because these checks fail with - * older versions of sparse. - */ - BUILD_ASSERT(__alignof__(union umad_gid) == 4); -#endif - - /* umad_types.h structure checks */ - BUILD_ASSERT(sizeof(struct umad_hdr) == 24); - BUILD_ASSERT(sizeof(struct umad_rmpp_hdr) == 12); - BUILD_ASSERT(sizeof(struct umad_packet) == 256); - BUILD_ASSERT(sizeof(struct umad_rmpp_packet) == 256); - BUILD_ASSERT(sizeof(struct umad_dm_packet) == 256); - BUILD_ASSERT(sizeof(struct umad_vendor_packet) == 256); - BUILD_ASSERT(sizeof(struct umad_class_port_info) == 72); - BUILD_ASSERT(offsetof(struct umad_class_port_info, redirgid) == 8); - BUILD_ASSERT(offsetof(struct umad_class_port_info, trapgid) == 40); - - /* umad_sm.h structure check */ - BUILD_ASSERT(sizeof(struct umad_smp) == 256); - - /* umad_sa.h structure check */ - BUILD_ASSERT(sizeof(struct umad_sa_packet) == 256); - - return 0; -} diff --git a/usr/rdma-core/libibumad/tests/umad_reg2_compat.c b/usr/rdma-core/libibumad/tests/umad_reg2_compat.c deleted file mode 100644 index 9224372a1..000000000 --- a/usr/rdma-core/libibumad/tests/umad_reg2_compat.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2014 Intel Corporation, All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include - -#include -#include -#include - -#include - -#define UNLIKELY_MGMT_CLASS 0x2F -#define UNLIKELY_RMPP_MGMT_CLASS 0x4F - -static int test_failures = 0; - -/** ========================================================================= - * Stolen from OpenSM's register - */ -static int set_bit(int nr, void *method_mask) -{ - long mask, *addr = method_mask; - int retval; - - addr += nr / (8 * sizeof(long)); - mask = 1L << (nr % (8 * sizeof(long))); - retval = (mask & *addr) != 0; - *addr |= mask; - return retval; -} - -static void set_bit64(int b, uint64_t *buf) -{ - uint64_t mask; - uint64_t *addr = buf; - - addr += b >> 6; - mask = 1ULL << (b & 0x3f); - *addr |= mask; -} - -static void dump_reg_attr(struct umad_reg_attr *reg_attr) -{ - printf("\nmgmt_class %u\n" - "mgmt_class_version %u\n" - "flags 0x%08x\n" - "method_mask 0x%016"PRIx64" %016"PRIx64"\n" - "oui 0x%06x\n" - "rmpp_version %u\n\n", - reg_attr->mgmt_class, - reg_attr->mgmt_class_version, - reg_attr->flags, - reg_attr->method_mask[1], reg_attr->method_mask[0], - reg_attr->oui, - reg_attr->rmpp_version); -} - -static int open_test_device(void) -{ - int fd = umad_open_port(NULL, 0); - if (fd < 0) { - printf("\n *****\nOpen Port Failure... Aborting\n"); - printf(" Ensure you have an HCA to test against.\n"); - exit(0); - } - return fd; -} - -static void test_register(void) -{ - int agent_id; - long method_mask[16 / sizeof(long)]; - uint32_t class_oui = 0x001405; /* OPENIB_OUI */ - uint8_t oui[3]; - int fd; - - printf("\n old register test ... "); - - fd = open_test_device(); - - memset(&method_mask, 0, sizeof(method_mask)); - set_bit( 1, &method_mask); - set_bit(63, &method_mask); - set_bit(64, &method_mask); - - // equal to this with the new register - //reg_attr.method_mask[0] = 0x8000000000000002ULL; - //reg_attr.method_mask[1] = 0x0000000000000001ULL; - - agent_id = umad_register(fd, UNLIKELY_MGMT_CLASS, 0x1, 0x00, method_mask); - if (agent_id < 0) { - printf("\n umad_register Failure, agent_id %d\n", agent_id); - printf("\n umad_register(fd, 0x01, 0x1, 0x00, method_mask);\n"); - test_failures++; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - printf("\n old register_oui test ... "); - - oui[0] = (class_oui >> 16) & 0xff; - oui[1] = (class_oui >> 8) & 0xff; - oui[2] = class_oui & 0xff; - - agent_id = umad_register_oui(fd, UNLIKELY_RMPP_MGMT_CLASS, 0x1, oui, method_mask); - if (agent_id < 0) { - printf("\n umad_register_oui Failure, agent_id %d\n", agent_id); - printf("\n umad_register(fd, 0x30, 0x1, oui, method_mask);\n"); - test_failures++; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - umad_close_port(fd); -} - - -static void test_fall_back(void) -{ - int rc = 0; - struct umad_reg_attr reg_attr; - uint32_t agent_id; - int fd; - - fd = open_test_device(); - - memset(®_attr, 0, sizeof(reg_attr)); - reg_attr.mgmt_class = UNLIKELY_MGMT_CLASS; - reg_attr.mgmt_class_version = 0x1; - reg_attr.oui = 0x001405; /* OPENIB_OUI */ - - //reg_attr.method_mask[0] = 0x8000000000000002ULL; - //reg_attr.method_mask[1] = 0x0000000000000001ULL; - - set_bit64( 1, (uint64_t *)®_attr.method_mask); - set_bit64(63, (uint64_t *)®_attr.method_mask); - set_bit64(64, (uint64_t *)®_attr.method_mask); - - printf("\n umad_register2 fall back (set_bit) ... "); - rc = umad_register2(fd, ®_attr, &agent_id); - if (rc != 0) { - printf("\n umad_register2 failed to fall back. rc = %d\n", rc); - dump_reg_attr(®_attr); - test_failures++; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - reg_attr.method_mask[0] = 0x8000000000000002ULL; - reg_attr.method_mask[1] = 0x0000000000000001ULL; - - printf("\n umad_register2 fall back ... "); - rc = umad_register2(fd, ®_attr, &agent_id); - if (rc != 0) { - printf("\n umad_register2 failed to fall back. rc = %d\n", rc); - dump_reg_attr(®_attr); - test_failures++; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - umad_close_port(fd); - -} - -int main(int argc, char *argv[]) -{ - //umad_debug(1); - - printf("\n *****\nStart compatibility tests\n"); - - test_register(); - test_fall_back(); - printf("\n *******************\n"); - printf(" umad_reg2_compat had %d failures\n", test_failures); - printf(" *******************\n"); - return test_failures; -} diff --git a/usr/rdma-core/libibumad/tests/umad_register2.c b/usr/rdma-core/libibumad/tests/umad_register2.c deleted file mode 100644 index 477bd2972..000000000 --- a/usr/rdma-core/libibumad/tests/umad_register2.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (c) 2014 Intel Corporation, All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include - -#include -#include -#include -#include -#include - -#include - -#define UNLIKELY_MGMT_CLASS 0x2F -#define UNLIKELY_RMPP_MGMT_CLASS 0x4F - -struct ib_user_mad_reg_req2 { - uint32_t id; - uint32_t qpn; - uint8_t mgmt_class; - uint8_t mgmt_class_version; - uint16_t res; - uint32_t flags; - uint64_t method_mask[2]; - uint32_t oui; - uint8_t rmpp_version; - uint8_t reserved[3]; -}; - -static int test_failures = 0; - -static void dump_reg_attr(struct umad_reg_attr *reg_attr) -{ - printf("\nmgmt_class %u\n" - "mgmt_class_version %u\n" - "flags 0x%08x\n" - "method_mask 0x%016"PRIx64" %016"PRIx64"\n" - "oui 0x%06x\n" - "rmpp_version %u\n\n", - reg_attr->mgmt_class, - reg_attr->mgmt_class_version, - reg_attr->flags, - reg_attr->method_mask[1], reg_attr->method_mask[0], - reg_attr->oui, - reg_attr->rmpp_version); -} - -static int open_test_device(void) -{ - int fd = umad_open_port(NULL, 0); - if (fd < 0) { - printf("\n *****\nOpen Port Failure... Aborting\n"); - printf(" Ensure you have an HCA to test against.\n"); - exit(0); - } - return fd; -} - -static void test_fail(void) -{ - int rc = 0; - struct umad_reg_attr reg_attr; - uint32_t agent_id; - uint32_t agent_id2; - int fd; - - printf("\n *****\nBegin invalid tests\n"); - - fd = open_test_device(); - - memset(®_attr, 0, sizeof(reg_attr)); - reg_attr.mgmt_class = UNLIKELY_MGMT_CLASS; - reg_attr.mgmt_class_version = 0x1; - reg_attr.flags = 0x80000000; - printf("\n invalid register flags ... "); - rc = umad_register2(fd, ®_attr, &agent_id); - if (rc == 0) { - printf("\n umad_register2 registered invalid flags. rc = %d\n", - rc); - dump_reg_attr(®_attr); - test_failures++; - goto out; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - memset(®_attr, 0, sizeof(reg_attr)); - reg_attr.mgmt_class = 0x03; - reg_attr.mgmt_class_version = 0x2; - reg_attr.rmpp_version = 0x02; - printf("\n invalid rmpp_version ... "); - rc = umad_register2(fd, ®_attr, &agent_id); - if (rc == 0) { - printf("\n umad_register2 registered an invalid rmpp_version. rc = %d\n", - rc); - dump_reg_attr(®_attr); - test_failures++; - goto out; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - memset(®_attr, 0, sizeof(reg_attr)); - reg_attr.mgmt_class = UNLIKELY_RMPP_MGMT_CLASS; - reg_attr.oui = 0x0100066a; - printf("\n invalid oui ... "); - rc = umad_register2(fd, ®_attr, &agent_id); - if (rc == 0) { - printf("\n umad_register2 registered an invalid oui. rc = %d\n", - rc); - dump_reg_attr(®_attr); - test_failures++; - goto out; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - /* The following 2 registrations attempt to register the same OUI 2 - * times. The second one is supposed to fail with the same method - * mask. - */ - printf("\n duplicate oui ... "); - memset(®_attr, 0, sizeof(reg_attr)); - reg_attr.mgmt_class = UNLIKELY_RMPP_MGMT_CLASS; - reg_attr.mgmt_class_version = 0x1; - reg_attr.rmpp_version = 0x00; - reg_attr.oui = 0x00066a; - reg_attr.method_mask[0] = 0x80000000000000DEULL; - reg_attr.method_mask[1] = 0xAD00000000000001ULL; - rc = umad_register2(fd, ®_attr, &agent_id); - if (rc != 0) { - printf("\n umad_register2 Failed to register an oui for the duplicate test. rc = %d\n", - rc); - dump_reg_attr(®_attr); - test_failures++; - goto out; - } - - memset(®_attr, 0, sizeof(reg_attr)); - reg_attr.mgmt_class = UNLIKELY_RMPP_MGMT_CLASS; - reg_attr.mgmt_class_version = 0x1; - reg_attr.rmpp_version = 0x00; - reg_attr.oui = 0x00066a; - reg_attr.method_mask[0] = 0x80000000000000DEULL; - reg_attr.method_mask[1] = 0xAD00000000000001ULL; - rc = umad_register2(fd, ®_attr, &agent_id2); - if (rc == 0) { - printf("\n umad_register2 registered a duplicate oui. rc = %d\n", - rc); - dump_reg_attr(®_attr); - test_failures++; - goto out; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - umad_unregister(fd, agent_id2); - } - - umad_close_port(fd); -out: - printf("\n *****\nEnd invalid tests\n"); -} - -static void test_oui(void) -{ - int rc = 0; - struct umad_reg_attr reg_attr; - uint32_t agent_id; - int fd; - - printf("\n *****\nStart valid oui tests\n"); - - fd = open_test_device(); - - printf("\n valid oui ... "); - memset(®_attr, 0, sizeof(reg_attr)); - reg_attr.mgmt_class = UNLIKELY_RMPP_MGMT_CLASS; - reg_attr.mgmt_class_version = 0x1; - reg_attr.rmpp_version = 0x00; - reg_attr.oui = 0x00066a; - reg_attr.method_mask[0] = 0x80000000000000DEULL; - reg_attr.method_mask[1] = 0xAD00000000000001ULL; - rc = umad_register2(fd, ®_attr, &agent_id); - if (rc != 0) { - printf("\n umad_register2 failed oui 0x%x. rc = %d\n", - reg_attr.oui, rc); - dump_reg_attr(®_attr); - test_failures++; - goto out; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - printf("\n valid oui with flags ... "); - memset(®_attr, 0, sizeof(reg_attr)); - reg_attr.mgmt_class = UNLIKELY_RMPP_MGMT_CLASS; - reg_attr.mgmt_class_version = 0x1; - reg_attr.rmpp_version = 0x00; - reg_attr.flags = 0x01; - /* Use Intel OUI for testing */ - reg_attr.oui = 0x00066a; - rc = umad_register2(fd, ®_attr, &agent_id); - if (rc != 0) { - printf("\n umad_register2 failed oui 0x%x with flags 0x%x. rc = %d\n", - reg_attr.oui, reg_attr.flags, rc); - dump_reg_attr(®_attr); - test_failures++; - goto out; - } else { - printf(" PASS\n"); - umad_unregister(fd, agent_id); - } - - umad_close_port(fd); - -out: - printf("\n End valid oui tests\n *****\n"); -} - -static void check_register2_support(void) -{ - struct ib_user_mad_reg_req2 req; - int fd; - - fd = open_test_device(); - - memset(&req, 0, sizeof(req)); - req.mgmt_class = UNLIKELY_MGMT_CLASS; - req.mgmt_class_version = 0x1; - req.qpn = 0x1; - - if (ioctl(fd, IB_USER_MAD_REGISTER_AGENT2, (void *)&req) != 0) { - if (errno == ENOTTY || errno == EINVAL) { - printf("\n *****\nKernel does not support the new ioctl. Aborting tests\n"); - exit(0); - } - } - - umad_close_port(fd); -} - -int main(int argc, char *argv[]) -{ - //umad_debug(1); - check_register2_support(); - test_fail(); - test_oui(); - printf("\n *******************\n"); - printf(" umad_register2 had %d failures\n", test_failures); - printf(" *******************\n"); - return test_failures; -} diff --git a/usr/rdma-core/libibumad/umad.c b/usr/rdma-core/libibumad/umad.c deleted file mode 100644 index 535256e21..000000000 --- a/usr/rdma-core/libibumad/umad.c +++ /dev/null @@ -1,1113 +0,0 @@ -/* - * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved. - * Copyright (c) 2014 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define IB_OPENIB_OUI (0x001405) - -#include -#include "sysfs.h" - -typedef struct ib_user_mad_reg_req { - uint32_t id; - uint32_t method_mask[4]; - uint8_t qpn; - uint8_t mgmt_class; - uint8_t mgmt_class_version; - uint8_t oui[3]; - uint8_t rmpp_version; -} ib_user_mad_reg_req_t; - -struct ib_user_mad_reg_req2 { - uint32_t id; - uint32_t qpn; - uint8_t mgmt_class; - uint8_t mgmt_class_version; - uint16_t res; - uint32_t flags; - uint64_t method_mask[2]; - uint32_t oui; - uint8_t rmpp_version; - uint8_t reserved[3]; -}; - -#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## args) - -#define TRACE if (umaddebug) IBWARN -#define DEBUG if (umaddebug) IBWARN - -static int umaddebug = 0; - -#define UMAD_DEV_FILE_SZ 256 - -static const char *def_ca_name = "mthca0"; -static int def_ca_port = 1; - -static unsigned abi_version; -static unsigned new_user_mad_api; - -/************************************* - * Port - */ -static int find_cached_ca(const char *ca_name, umad_ca_t * ca) -{ - return 0; /* caching not implemented yet */ -} - -static int put_ca(umad_ca_t * ca) -{ - return 0; /* caching not implemented yet */ -} - -static int release_port(umad_port_t * port) -{ - free(port->pkeys); - port->pkeys = NULL; - port->pkeys_size = 0; - return 0; -} - -static int check_for_digit_name(const struct dirent *dent) -{ - const char *p = dent->d_name; - while (*p && isdigit(*p)) - p++; - return *p ? 0 : 1; -} - -static int get_port(const char *ca_name, const char *dir, int portnum, umad_port_t * port) -{ - char port_dir[256]; - union umad_gid gid; - struct dirent **namelist = NULL; - int i, len, num_pkeys = 0; - uint32_t capmask; - - strncpy(port->ca_name, ca_name, sizeof port->ca_name - 1); - port->portnum = portnum; - port->pkeys = NULL; - - len = snprintf(port_dir, sizeof(port_dir), "%s/%d", dir, portnum); - if (len < 0 || len > sizeof(port_dir)) - goto clean; - - if (sys_read_uint(port_dir, SYS_PORT_LMC, &port->lmc) < 0) - goto clean; - if (sys_read_uint(port_dir, SYS_PORT_SMLID, &port->sm_lid) < 0) - goto clean; - if (sys_read_uint(port_dir, SYS_PORT_SMSL, &port->sm_sl) < 0) - goto clean; - if (sys_read_uint(port_dir, SYS_PORT_LID, &port->base_lid) < 0) - goto clean; - if (sys_read_uint(port_dir, SYS_PORT_STATE, &port->state) < 0) - goto clean; - if (sys_read_uint(port_dir, SYS_PORT_PHY_STATE, &port->phys_state) < 0) - goto clean; - if (sys_read_uint(port_dir, SYS_PORT_RATE, &port->rate) < 0) - goto clean; - if (sys_read_uint(port_dir, SYS_PORT_CAPMASK, &capmask) < 0) - goto clean; - - if (sys_read_string(port_dir, SYS_PORT_LINK_LAYER, - port->link_layer, UMAD_CA_NAME_LEN) < 0) - /* assume IB by default */ - sprintf(port->link_layer, "IB"); - - port->capmask = htobe32(capmask); - - if (sys_read_gid(port_dir, SYS_PORT_GID, &gid) < 0) - goto clean; - - port->gid_prefix = gid.global.subnet_prefix; - port->port_guid = gid.global.interface_id; - - snprintf(port_dir + len, sizeof(port_dir) - len, "/pkeys"); - num_pkeys = scandir(port_dir, &namelist, check_for_digit_name, NULL); - if (num_pkeys <= 0) { - IBWARN("no pkeys found for %s:%u (at dir %s)...", - port->ca_name, port->portnum, port_dir); - goto clean; - } - port->pkeys = calloc(num_pkeys, sizeof(port->pkeys[0])); - if (!port->pkeys) { - IBWARN("get_port: calloc failed: %s", strerror(errno)); - goto clean; - } - for (i = 0; i < num_pkeys; i++) { - unsigned idx, val; - idx = strtoul(namelist[i]->d_name, NULL, 0); - sys_read_uint(port_dir, namelist[i]->d_name, &val); - port->pkeys[idx] = val; - free(namelist[i]); - } - port->pkeys_size = num_pkeys; - free(namelist); - namelist = NULL; - port_dir[len] = '\0'; - - /* FIXME: handle gids */ - - return 0; - -clean: - if (namelist) { - for (i = 0; i < num_pkeys; i++) - free(namelist[i]); - free(namelist); - } - if (port->pkeys) - free(port->pkeys); - return -EIO; -} - -static int release_ca(umad_ca_t * ca) -{ - int i; - - for (i = 0; i <= ca->numports; i++) { - if (!ca->ports[i]) - continue; - release_port(ca->ports[i]); - free(ca->ports[i]); - ca->ports[i] = NULL; - } - return 0; -} - -/* - * if *port > 0, check ca[port] state. Otherwise set *port to - * the first port that is active, and if such is not found, to - * the first port that is link up and if none are linkup, then - * the first port that is not disabled. Otherwise return -1. - */ -static int resolve_ca_port(const char *ca_name, int *port) -{ - umad_ca_t ca; - int active = -1, up = -1; - int i, ret = 0; - - TRACE("checking ca '%s'", ca_name); - - if (umad_get_ca(ca_name, &ca) < 0) - return -1; - - if (ca.node_type == 2) { - *port = 0; /* switch sma port 0 */ - ret = 1; - goto Exit; - } - - if (*port > 0) { /* check only the port the user wants */ - if (*port > ca.numports) { - ret = -1; - goto Exit; - } - if (!ca.ports[*port]) { - ret = -1; - goto Exit; - } - if (strcmp(ca.ports[*port]->link_layer, "InfiniBand") && - strcmp(ca.ports[*port]->link_layer, "IB")) { - ret = -1; - goto Exit; - } - if (ca.ports[*port]->state == 4) { - ret = 1; - goto Exit; - } - if (ca.ports[*port]->phys_state != 3) - goto Exit; - ret = -1; - goto Exit; - } - - for (i = 0; i <= ca.numports; i++) { - DEBUG("checking port %d", i); - if (!ca.ports[i]) - continue; - if (strcmp(ca.ports[i]->link_layer, "InfiniBand") && - strcmp(ca.ports[i]->link_layer, "IB")) - continue; - if (up < 0 && ca.ports[i]->phys_state == 5) - up = *port = i; - if (ca.ports[i]->state == 4) { - active = *port = i; - DEBUG("found active port %d", i); - break; - } - } - - if (active == -1 && up == -1) { /* no active or linkup port found */ - for (i = 0; i <= ca.numports; i++) { - DEBUG("checking port %d", i); - if (!ca.ports[i]) - continue; - if (ca.ports[i]->phys_state != 3) { - up = *port = i; - break; - } - } - } - - if (active >= 0) { - ret = 1; - goto Exit; - } - if (up >= 0) { - ret = 0; - goto Exit; - } - ret = -1; -Exit: - release_ca(&ca); - return ret; -} - -static const char *resolve_ca_name(const char *ca_name, int *best_port) -{ - static char names[UMAD_MAX_DEVICES][UMAD_CA_NAME_LEN]; - int phys_found = -1, port_found = 0, port, port_type; - int caidx, n; - - if (ca_name && (!best_port || *best_port)) - return ca_name; - - if (ca_name) { - if (resolve_ca_port(ca_name, best_port) < 0) - return NULL; - return ca_name; - } - - /* Get the list of CA names */ - if ((n = umad_get_cas_names((void *)names, UMAD_MAX_DEVICES)) < 0) - return NULL; - - /* Find the first existing CA with an active port */ - for (caidx = 0; caidx < n; caidx++) { - TRACE("checking ca '%s'", names[caidx]); - - port = best_port ? *best_port : 0; - if ((port_type = resolve_ca_port(names[caidx], &port)) < 0) - continue; - - DEBUG("found ca %s with port %d type %d", - names[caidx], port, port_type); - - if (port_type > 0) { - if (best_port) - *best_port = port; - DEBUG("found ca %s with active port %d", - names[caidx], port); - return (char *)(names + caidx); - } - - if (phys_found == -1) { - phys_found = caidx; - port_found = port; - } - } - - DEBUG("phys found %d on %s port %d", - phys_found, phys_found >= 0 ? names[phys_found] : NULL, - port_found); - if (phys_found >= 0) { - if (best_port) - *best_port = port_found; - return names[phys_found]; - } - - if (best_port) - *best_port = def_ca_port; - return def_ca_name; -} - -static int get_ca(const char *ca_name, umad_ca_t * ca) -{ - DIR *dir; - char dir_name[256]; - struct dirent **namelist; - int r, i, ret; - int portnum; - - ca->numports = 0; - memset(ca->ports, 0, sizeof ca->ports); - strncpy(ca->ca_name, ca_name, sizeof(ca->ca_name) - 1); - - snprintf(dir_name, sizeof(dir_name), "%s/%s", SYS_INFINIBAND, - ca->ca_name); - - if ((r = sys_read_uint(dir_name, SYS_NODE_TYPE, &ca->node_type)) < 0) - return r; - if (sys_read_string(dir_name, SYS_CA_FW_VERS, ca->fw_ver, - sizeof ca->fw_ver) < 0) - ca->fw_ver[0] = '\0'; - if (sys_read_string(dir_name, SYS_CA_HW_VERS, ca->hw_ver, - sizeof ca->hw_ver) < 0) - ca->hw_ver[0] = '\0'; - if ((r = sys_read_string(dir_name, SYS_CA_TYPE, ca->ca_type, - sizeof ca->ca_type)) < 0) - ca->ca_type[0] = '\0'; - if ((r = sys_read_guid(dir_name, SYS_CA_NODE_GUID, &ca->node_guid)) < 0) - return r; - if ((r = - sys_read_guid(dir_name, SYS_CA_SYS_GUID, &ca->system_guid)) < 0) - return r; - - snprintf(dir_name, sizeof(dir_name), "%s/%s/%s", - SYS_INFINIBAND, ca->ca_name, SYS_CA_PORTS_DIR); - - if (!(dir = opendir(dir_name))) - return -ENOENT; - - if ((r = scandir(dir_name, &namelist, NULL, alphasort)) < 0) { - ret = errno < 0 ? errno : -EIO; - goto error; - } - - ret = 0; - for (i = 0; i < r; i++) { - portnum = 0; - if (!strcmp(".", namelist[i]->d_name) || - !strcmp("..", namelist[i]->d_name)) - continue; - if (strcmp("0", namelist[i]->d_name) && - ((portnum = atoi(namelist[i]->d_name)) <= 0 || - portnum >= UMAD_CA_MAX_PORTS)) { - ret = -EIO; - goto clean; - } - if (!(ca->ports[portnum] = - calloc(1, sizeof(*ca->ports[portnum])))) { - ret = -ENOMEM; - goto clean; - } - if (get_port(ca_name, dir_name, portnum, ca->ports[portnum]) < - 0) { - free(ca->ports[portnum]); - ca->ports[portnum] = NULL; - ret = -EIO; - goto clean; - } - if (ca->numports < portnum) - ca->numports = portnum; - } - - for (i = 0; i < r; i++) - free(namelist[i]); - free(namelist); - - closedir(dir); - put_ca(ca); - return 0; - -clean: - for (i = 0; i < r; i++) - free(namelist[i]); - free(namelist); -error: - closedir(dir); - release_ca(ca); - - return ret; -} - -static int umad_id_to_dev(int umad_id, char *dev, unsigned *port) -{ - char path[256]; - int r; - - snprintf(path, sizeof(path), SYS_INFINIBAND_MAD "/umad%d/", umad_id); - - if ((r = - sys_read_string(path, SYS_IB_MAD_DEV, dev, UMAD_CA_NAME_LEN)) < 0) - return r; - - if ((r = sys_read_uint(path, SYS_IB_MAD_PORT, port)) < 0) - return r; - - return 0; -} - -static int dev_to_umad_id(const char *dev, unsigned port) -{ - char umad_dev[UMAD_CA_NAME_LEN]; - unsigned umad_port; - int id; - - for (id = 0; id < UMAD_MAX_PORTS; id++) { - if (umad_id_to_dev(id, umad_dev, &umad_port) < 0) - continue; - if (strncmp(dev, umad_dev, UMAD_CA_NAME_LEN)) - continue; - if (port != umad_port) - continue; - - DEBUG("mapped %s %d to %d", dev, port, id); - return id; - } - - return -1; /* not found */ -} - -/******************************* - * Public interface - */ - -int umad_init(void) -{ - TRACE("umad_init"); - if (sys_read_uint(IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, &abi_version) < 0) { - IBWARN - ("can't read ABI version from %s/%s (%m): is ib_umad module loaded?", - IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE); - return -1; - } - if (abi_version < IB_UMAD_ABI_VERSION) { - IBWARN - ("wrong ABI version: %s/%s is %d but library minimal ABI is %d", - IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, abi_version, - IB_UMAD_ABI_VERSION); - return -1; - } - return 0; -} - -int umad_done(void) -{ - TRACE("umad_done"); - /* FIXME - verify that all ports are closed */ - return 0; -} - -static unsigned is_ib_type(const char *ca_name) -{ - char dir_name[256]; - unsigned type; - - snprintf(dir_name, sizeof(dir_name), "%s/%s", SYS_INFINIBAND, ca_name); - - if (sys_read_uint(dir_name, SYS_NODE_TYPE, &type) < 0) - return 0; - - return type >= 1 && type <= 3 ? 1 : 0; -} - -int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max) -{ - struct dirent **namelist; - int n, i, j = 0; - - TRACE("max %d", max); - - n = scandir(SYS_INFINIBAND, &namelist, NULL, alphasort); - if (n > 0) { - for (i = 0; i < n; i++) { - if (strcmp(namelist[i]->d_name, ".") && - strcmp(namelist[i]->d_name, "..")) { - if (j < max && is_ib_type(namelist[i]->d_name)) - strncpy(cas[j++], namelist[i]->d_name, - UMAD_CA_NAME_LEN); - } - free(namelist[i]); - } - DEBUG("return %d cas", j); - } else { - /* Is this still needed ? */ - strncpy((char *)cas, def_ca_name, UMAD_CA_NAME_LEN); - DEBUG("return 1 ca"); - j = 1; - } - if (n >= 0) - free(namelist); - return j; -} - -int umad_get_ca_portguids(const char *ca_name, __be64 *portguids, int max) -{ - umad_ca_t ca; - int ports = 0, i; - - TRACE("ca name %s max port guids %d", ca_name, max); - if (!(ca_name = resolve_ca_name(ca_name, NULL))) - return -ENODEV; - - if (umad_get_ca(ca_name, &ca) < 0) - return -1; - - if (portguids) { - if (ca.numports + 1 > max) { - release_ca(&ca); - return -ENOMEM; - } - - for (i = 0; i <= ca.numports; i++) - portguids[ports++] = ca.ports[i] ? - ca.ports[i]->port_guid : htobe64(0); - } - - release_ca(&ca); - DEBUG("%s: %d ports", ca_name, ports); - - return ports; -} - -int umad_get_issm_path(const char *ca_name, int portnum, char path[], int max) -{ - int umad_id; - - TRACE("ca %s port %d", ca_name, portnum); - - if (!(ca_name = resolve_ca_name(ca_name, &portnum))) - return -ENODEV; - - if ((umad_id = dev_to_umad_id(ca_name, portnum)) < 0) - return -EINVAL; - - snprintf(path, max, "%s/issm%u", UMAD_DEV_DIR, umad_id); - - return 0; -} - -int umad_open_port(const char *ca_name, int portnum) -{ - char dev_file[UMAD_DEV_FILE_SZ]; - int umad_id, fd; - - TRACE("ca %s port %d", ca_name, portnum); - - if (!(ca_name = resolve_ca_name(ca_name, &portnum))) - return -ENODEV; - - DEBUG("opening %s port %d", ca_name, portnum); - - if ((umad_id = dev_to_umad_id(ca_name, portnum)) < 0) - return -EINVAL; - - snprintf(dev_file, sizeof(dev_file), "%s/umad%d", - UMAD_DEV_DIR, umad_id); - - if ((fd = open(dev_file, O_RDWR | O_NONBLOCK)) < 0) { - DEBUG("open %s failed: %s", dev_file, strerror(errno)); - return -EIO; - } - - if (abi_version > 5 || !ioctl(fd, IB_USER_MAD_ENABLE_PKEY, NULL)) - new_user_mad_api = 1; - else - new_user_mad_api = 0; - - DEBUG("opened %s fd %d portid %d", dev_file, fd, umad_id); - return fd; -} - -int umad_get_ca(const char *ca_name, umad_ca_t * ca) -{ - int r; - - TRACE("ca_name %s", ca_name); - if (!(ca_name = resolve_ca_name(ca_name, NULL))) - return -ENODEV; - - if (find_cached_ca(ca_name, ca) > 0) - return 0; - - if ((r = get_ca(ca_name, ca)) < 0) - return r; - - DEBUG("opened %s", ca_name); - return 0; -} - -int umad_release_ca(umad_ca_t * ca) -{ - int r; - - TRACE("ca_name %s", ca->ca_name); - if (!ca) - return -ENODEV; - - if ((r = release_ca(ca)) < 0) - return r; - - DEBUG("releasing %s", ca->ca_name); - return 0; -} - -int umad_get_port(const char *ca_name, int portnum, umad_port_t * port) -{ - char dir_name[256]; - - TRACE("ca_name %s portnum %d", ca_name, portnum); - - if (!(ca_name = resolve_ca_name(ca_name, &portnum))) - return -ENODEV; - - snprintf(dir_name, sizeof(dir_name), "%s/%s/%s", - SYS_INFINIBAND, ca_name, SYS_CA_PORTS_DIR); - - return get_port(ca_name, dir_name, portnum, port); -} - -int umad_release_port(umad_port_t * port) -{ - int r; - - TRACE("port %s:%d", port->ca_name, port->portnum); - if (!port) - return -ENODEV; - - if ((r = release_port(port)) < 0) - return r; - - DEBUG("releasing %s:%d", port->ca_name, port->portnum); - return 0; -} - -int umad_close_port(int fd) -{ - close(fd); - DEBUG("closed fd %d", fd); - return 0; -} - -void *umad_get_mad(void *umad) -{ - return new_user_mad_api ? ((struct ib_user_mad *)umad)->data : - (void *)&((struct ib_user_mad *)umad)->addr.pkey_index; -} - -size_t umad_size(void) -{ - return new_user_mad_api ? sizeof(struct ib_user_mad) : - sizeof(struct ib_user_mad) - 8; -} - -int umad_set_grh(void *umad, void *mad_addr) -{ - struct ib_user_mad *mad = umad; - struct ib_mad_addr *addr = mad_addr; - - if (mad_addr) { - mad->addr.grh_present = 1; - mad->addr.ib_gid = addr->ib_gid; - /* The definition for umad_set_grh requires that the input be - * in host order */ - mad->addr.flow_label = htobe32((__force uint32_t)addr->flow_label); - mad->addr.hop_limit = addr->hop_limit; - mad->addr.traffic_class = addr->traffic_class; - } else - mad->addr.grh_present = 0; - return 0; -} - -int umad_set_pkey(void *umad, int pkey_index) -{ - struct ib_user_mad *mad = umad; - - if (new_user_mad_api) - mad->addr.pkey_index = pkey_index; - - return 0; -} - -int umad_get_pkey(void *umad) -{ - struct ib_user_mad *mad = umad; - - if (new_user_mad_api) - return mad->addr.pkey_index; - - return 0; -} - -int umad_set_addr(void *umad, int dlid, int dqp, int sl, int qkey) -{ - struct ib_user_mad *mad = umad; - - TRACE("umad %p dlid %u dqp %d sl %d, qkey %x", - umad, dlid, dqp, sl, qkey); - mad->addr.qpn = htobe32(dqp); - mad->addr.lid = htobe16(dlid); - mad->addr.qkey = htobe32(qkey); - mad->addr.sl = sl; - - return 0; -} - -int umad_set_addr_net(void *umad, __be16 dlid, __be32 dqp, int sl, __be32 qkey) -{ - struct ib_user_mad *mad = umad; - - TRACE("umad %p dlid %u dqp %d sl %d qkey %x", - umad, be16toh(dlid), be32toh(dqp), sl, be32toh(qkey)); - mad->addr.qpn = dqp; - mad->addr.lid = dlid; - mad->addr.qkey = qkey; - mad->addr.sl = sl; - - return 0; -} - -int umad_send(int fd, int agentid, void *umad, int length, - int timeout_ms, int retries) -{ - struct ib_user_mad *mad = umad; - int n; - - TRACE("fd %d agentid %d umad %p timeout %u", - fd, agentid, umad, timeout_ms); - errno = 0; - - mad->timeout_ms = timeout_ms; - mad->retries = retries; - mad->agent_id = agentid; - - if (umaddebug > 1) - umad_dump(mad); - - n = write(fd, mad, length + umad_size()); - if (n == length + umad_size()) - return 0; - - DEBUG("write returned %d != sizeof umad %zu + length %d (%m)", - n, umad_size(), length); - if (!errno) - errno = EIO; - return -EIO; -} - -static int dev_poll(int fd, int timeout_ms) -{ - struct pollfd ufds; - int n; - - ufds.fd = fd; - ufds.events = POLLIN; - - if ((n = poll(&ufds, 1, timeout_ms)) == 1) - return 0; - - if (n == 0) - return -ETIMEDOUT; - - return -EIO; -} - -int umad_recv(int fd, void *umad, int *length, int timeout_ms) -{ - struct ib_user_mad *mad = umad; - int n; - - errno = 0; - TRACE("fd %d umad %p timeout %u", fd, umad, timeout_ms); - - if (!umad || !length) { - errno = EINVAL; - return -EINVAL; - } - - if (timeout_ms && (n = dev_poll(fd, timeout_ms)) < 0) { - if (!errno) - errno = -n; - return n; - } - - n = read(fd, umad, umad_size() + *length); - - VALGRIND_MAKE_MEM_DEFINED(umad, umad_size() + *length); - - if ((n >= 0) && (n <= umad_size() + *length)) { - DEBUG("mad received by agent %d length %d", mad->agent_id, n); - if (n > umad_size()) - *length = n - umad_size(); - else - *length = 0; - return mad->agent_id; - } - - if (n == -EWOULDBLOCK) { - if (!errno) - errno = EWOULDBLOCK; - return n; - } - - DEBUG("read returned %zu > sizeof umad %zu + length %d (%m)", - mad->length - umad_size(), umad_size(), *length); - - *length = mad->length - umad_size(); - if (!errno) - errno = EIO; - return -errno; -} - -int umad_poll(int fd, int timeout_ms) -{ - TRACE("fd %d timeout %u", fd, timeout_ms); - return dev_poll(fd, timeout_ms); -} - -int umad_get_fd(int fd) -{ - TRACE("fd %d", fd); - return fd; -} - -int umad_register_oui(int fd, int mgmt_class, uint8_t rmpp_version, - uint8_t oui[3], long method_mask[]) -{ - struct ib_user_mad_reg_req req; - - TRACE("fd %d mgmt_class %u rmpp_version %d oui 0x%x%x%x method_mask %p", - fd, mgmt_class, (int)rmpp_version, (int)oui[0], (int)oui[1], - (int)oui[2], method_mask); - - if (mgmt_class < 0x30 || mgmt_class > 0x4f) { - DEBUG("mgmt class %d not in vendor range 2", mgmt_class); - return -EINVAL; - } - - req.qpn = 1; - req.mgmt_class = mgmt_class; - req.mgmt_class_version = 1; - memcpy(req.oui, oui, sizeof req.oui); - req.rmpp_version = rmpp_version; - - if (method_mask) - memcpy(req.method_mask, method_mask, sizeof req.method_mask); - else - memset(req.method_mask, 0, sizeof req.method_mask); - - VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req); - - if (!ioctl(fd, IB_USER_MAD_REGISTER_AGENT, (void *)&req)) { - DEBUG - ("fd %d registered to use agent %d qp %d class 0x%x oui %p", - fd, req.id, req.qpn, req.mgmt_class, oui); - return req.id; /* return agentid */ - } - - DEBUG("fd %d registering qp %d class 0x%x version %d oui %p failed: %m", - fd, req.qpn, req.mgmt_class, req.mgmt_class_version, oui); - return -EPERM; -} - -int umad_register(int fd, int mgmt_class, int mgmt_version, - uint8_t rmpp_version, long method_mask[]) -{ - struct ib_user_mad_reg_req req; - __be32 oui = htobe32(IB_OPENIB_OUI); - int qp; - - TRACE - ("fd %d mgmt_class %u mgmt_version %u rmpp_version %d method_mask %p", - fd, mgmt_class, mgmt_version, rmpp_version, method_mask); - - req.qpn = qp = (mgmt_class == 0x1 || mgmt_class == 0x81) ? 0 : 1; - req.mgmt_class = mgmt_class; - req.mgmt_class_version = mgmt_version; - req.rmpp_version = rmpp_version; - - if (method_mask) - memcpy(req.method_mask, method_mask, sizeof req.method_mask); - else - memset(req.method_mask, 0, sizeof req.method_mask); - - memcpy(&req.oui, (char *)&oui + 1, sizeof req.oui); - - VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req); - - if (!ioctl(fd, IB_USER_MAD_REGISTER_AGENT, (void *)&req)) { - DEBUG("fd %d registered to use agent %d qp %d", fd, req.id, qp); - return req.id; /* return agentid */ - } - - DEBUG("fd %d registering qp %d class 0x%x version %d failed: %m", - fd, qp, mgmt_class, mgmt_version); - return -EPERM; -} - -int umad_register2(int port_fd, struct umad_reg_attr *attr, uint32_t *agent_id) -{ - struct ib_user_mad_reg_req2 req; - int rc; - - if (!attr || !agent_id) - return EINVAL; - - TRACE("fd %d mgmt_class %u mgmt_class_version %u flags 0x%08x " - "method_mask 0x%016" PRIx64 " %016" PRIx64 - "oui 0x%06x rmpp_version %u ", - port_fd, attr->mgmt_class, attr->mgmt_class_version, - attr->flags, attr->method_mask[0], attr->method_mask[1], - attr->oui, attr->rmpp_version); - - if (attr->mgmt_class >= 0x30 && attr->mgmt_class <= 0x4f && - ((attr->oui & 0x00ffffff) == 0 || (attr->oui & 0xff000000) != 0)) { - DEBUG("mgmt class %d is in vendor range 2 but oui (0x%08x) is invalid", - attr->mgmt_class, attr->oui); - return EINVAL; - } - - memset(&req, 0, sizeof(req)); - - req.mgmt_class = attr->mgmt_class; - req.mgmt_class_version = attr->mgmt_class_version; - req.qpn = (attr->mgmt_class == 0x1 || attr->mgmt_class == 0x81) ? 0 : 1; - req.flags = attr->flags; - memcpy(req.method_mask, attr->method_mask, sizeof req.method_mask); - req.oui = attr->oui; - req.rmpp_version = attr->rmpp_version; - - VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req); - - if ((rc = ioctl(port_fd, IB_USER_MAD_REGISTER_AGENT2, (void *)&req)) == 0) { - DEBUG("fd %d registered to use agent %d qp %d class 0x%x oui 0x%06x", - port_fd, req.id, req.qpn, req.mgmt_class, attr->oui); - *agent_id = req.id; - return 0; - } - - if (errno == ENOTTY || errno == EINVAL) { - - TRACE("no kernel support for registration flags"); - req.flags = 0; - - if (attr->flags == 0) { - struct ib_user_mad_reg_req req_v1; - - TRACE("attempting original register ioctl"); - - memset(&req_v1, 0, sizeof(req_v1)); - req_v1.mgmt_class = req.mgmt_class; - req_v1.mgmt_class_version = req.mgmt_class_version; - req_v1.qpn = req.qpn; - req_v1.rmpp_version = req.rmpp_version; - req_v1.oui[0] = (req.oui & 0xff0000) >> 16; - req_v1.oui[1] = (req.oui & 0x00ff00) >> 8; - req_v1.oui[2] = req.oui & 0x0000ff; - - memcpy(req_v1.method_mask, req.method_mask, sizeof req_v1.method_mask); - - if ((rc = ioctl(port_fd, IB_USER_MAD_REGISTER_AGENT, - (void *)&req_v1)) == 0) { - DEBUG("fd %d registered to use agent %d qp %d class 0x%x oui 0x%06x", - port_fd, req_v1.id, req_v1.qpn, req_v1.mgmt_class, attr->oui); - *agent_id = req_v1.id; - return 0; - } - } - } - - rc = errno; - attr->flags = req.flags; - - DEBUG("fd %d registering qp %d class 0x%x version %d " - "oui 0x%06x failed flags returned 0x%x : %m", - port_fd, req.qpn, req.mgmt_class, req.mgmt_class_version, - attr->oui, req.flags); - - return rc; -} - -int umad_unregister(int fd, int agentid) -{ - TRACE("fd %d unregistering agent %d", fd, agentid); - return ioctl(fd, IB_USER_MAD_UNREGISTER_AGENT, &agentid); -} - -int umad_status(void *umad) -{ - struct ib_user_mad *mad = umad; - - return mad->status; -} - -ib_mad_addr_t *umad_get_mad_addr(void *umad) -{ - struct ib_user_mad *mad = umad; - - return &mad->addr; -} - -int umad_debug(int level) -{ - if (level >= 0) - umaddebug = level; - return umaddebug; -} - -void umad_addr_dump(ib_mad_addr_t * addr) -{ -#define HEX(x) ((x) < 10 ? '0' + (x) : 'a' + ((x) -10)) - char gid_str[64]; - int i; - - for (i = 0; i < sizeof addr->gid; i++) { - gid_str[i * 2] = HEX(addr->gid[i] >> 4); - gid_str[i * 2 + 1] = HEX(addr->gid[i] & 0xf); - } - gid_str[i * 2] = 0; - IBWARN("qpn %d qkey 0x%x lid %u sl %d\n" - "grh_present %d gid_index %d hop_limit %d traffic_class %d flow_label 0x%x pkey_index 0x%x\n" - "Gid 0x%s", - be32toh(addr->qpn), be32toh(addr->qkey), be16toh(addr->lid), addr->sl, - addr->grh_present, (int)addr->gid_index, (int)addr->hop_limit, - (int)addr->traffic_class, addr->flow_label, addr->pkey_index, - gid_str); -} - -void umad_dump(void *umad) -{ - struct ib_user_mad *mad = umad; - - IBWARN("agent id %d status %x timeout %d", - mad->agent_id, mad->status, mad->timeout_ms); - umad_addr_dump(&mad->addr); -} diff --git a/usr/rdma-core/libibumad/umad.h b/usr/rdma-core/libibumad/umad.h deleted file mode 100644 index 479165a8f..000000000 --- a/usr/rdma-core/libibumad/umad.h +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved. - * Copyright (c) 2014 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -#ifndef _UMAD_H -#define _UMAD_H - -#include -#include -#include -#include -#include /* __be16, __be32 and __be64 */ - -#ifdef __cplusplus -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } -#else /* !__cplusplus */ -# define BEGIN_C_DECLS -# define END_C_DECLS -#endif /* __cplusplus */ - -BEGIN_C_DECLS - -typedef __be16 __attribute__((deprecated)) be16_t; -typedef __be32 __attribute__((deprecated)) be32_t; -typedef __be64 __attribute__((deprecated)) be64_t; - -/* - * A GID data structure that may be used in definitions of on-the-wire data - * structures. Do not cast umad_gid pointers to ibv_gid pointers because the - * alignment of these two data structures is different. - */ -union umad_gid { - uint8_t raw[16]; - __be16 raw_be16[8]; - struct { - __be64 subnet_prefix; - __be64 interface_id; - } global; -} __attribute__((aligned(4))) __attribute__((packed)); - -#define UMAD_MAX_DEVICES 32 -#define UMAD_ANY_PORT 0 -typedef struct ib_mad_addr { - __be32 qpn; - __be32 qkey; - __be16 lid; - uint8_t sl; - uint8_t path_bits; - uint8_t grh_present; - uint8_t gid_index; - uint8_t hop_limit; - uint8_t traffic_class; - union { - uint8_t gid[16]; /* network-byte order */ - union umad_gid ib_gid; - }; - __be32 flow_label; - uint16_t pkey_index; - uint8_t reserved[6]; -} ib_mad_addr_t; - -typedef struct ib_user_mad { - uint32_t agent_id; - uint32_t status; - uint32_t timeout_ms; - uint32_t retries; - uint32_t length; - ib_mad_addr_t addr; - uint8_t data[0]; -} ib_user_mad_t; - -#define IB_UMAD_ABI_VERSION 5 -#define IB_UMAD_ABI_DIR "/sys/class/infiniband_mad" -#define IB_UMAD_ABI_FILE "abi_version" - -#define IB_IOCTL_MAGIC 0x1b - -#define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \ - struct ib_user_mad_reg_req) -#define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, uint32_t) -#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3) -#define IB_USER_MAD_REGISTER_AGENT2 _IOWR(IB_IOCTL_MAGIC, 4, \ - struct ib_user_mad_reg_req2) - -#define UMAD_CA_NAME_LEN 20 -#define UMAD_CA_MAX_PORTS 10 /* 0 - 9 */ -#define UMAD_CA_MAX_AGENTS 32 - -#define SYS_INFINIBAND "/sys/class/infiniband" - -#define SYS_INFINIBAND_MAD "/sys/class/infiniband_mad" -#define SYS_IB_MAD_PORT "port" -#define SYS_IB_MAD_DEV "ibdev" - -#define UMAD_MAX_PORTS 64 - -#define UMAD_DEV_DIR "/dev/infiniband" - -#define SYS_CA_PORTS_DIR "ports" - -#define SYS_NODE_TYPE "node_type" -#define SYS_CA_FW_VERS "fw_ver" -#define SYS_CA_HW_VERS "hw_rev" -#define SYS_CA_TYPE "hca_type" -#define SYS_CA_NODE_GUID "node_guid" -#define SYS_CA_SYS_GUID "sys_image_guid" - -#define SYS_PORT_LMC "lid_mask_count" -#define SYS_PORT_SMLID "sm_lid" -#define SYS_PORT_SMSL "sm_sl" -#define SYS_PORT_LID "lid" -#define SYS_PORT_STATE "state" -#define SYS_PORT_PHY_STATE "phys_state" -#define SYS_PORT_CAPMASK "cap_mask" -#define SYS_PORT_RATE "rate" -#define SYS_PORT_GUID "port_guid" -#define SYS_PORT_GID "gids/0" -#define SYS_PORT_LINK_LAYER "link_layer" - -typedef struct umad_port { - char ca_name[UMAD_CA_NAME_LEN]; - int portnum; - unsigned base_lid; - unsigned lmc; - unsigned sm_lid; - unsigned sm_sl; - unsigned state; - unsigned phys_state; - unsigned rate; - __be32 capmask; - __be64 gid_prefix; - __be64 port_guid; - unsigned pkeys_size; - uint16_t *pkeys; - char link_layer[UMAD_CA_NAME_LEN]; -} umad_port_t; - -typedef struct umad_ca { - char ca_name[UMAD_CA_NAME_LEN]; - unsigned node_type; - int numports; - char fw_ver[20]; - char ca_type[40]; - char hw_ver[20]; - __be64 node_guid; - __be64 system_guid; - umad_port_t *ports[UMAD_CA_MAX_PORTS]; -} umad_ca_t; - -int umad_init(void); -int umad_done(void); - -int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max); -int umad_get_ca_portguids(const char *ca_name, __be64 *portguids, int max); - -int umad_get_ca(const char *ca_name, umad_ca_t * ca); -int umad_release_ca(umad_ca_t * ca); -int umad_get_port(const char *ca_name, int portnum, umad_port_t * port); -int umad_release_port(umad_port_t * port); - -int umad_get_issm_path(const char *ca_name, int portnum, char path[], int max); - -int umad_open_port(const char *ca_name, int portnum); -int umad_close_port(int portid); - -void *umad_get_mad(void *umad); -size_t umad_size(void); -int umad_status(void *umad); - -ib_mad_addr_t *umad_get_mad_addr(void *umad); -int umad_set_grh_net(void *umad, void *mad_addr); -int umad_set_grh(void *umad, void *mad_addr); -int umad_set_addr_net(void *umad, __be16 dlid, __be32 dqp, int sl, __be32 qkey); -int umad_set_addr(void *umad, int dlid, int dqp, int sl, int qkey); -int umad_set_pkey(void *umad, int pkey_index); -int umad_get_pkey(void *umad); - -int umad_send(int portid, int agentid, void *umad, int length, - int timeout_ms, int retries); -int umad_recv(int portid, void *umad, int *length, int timeout_ms); -int umad_poll(int portid, int timeout_ms); -int umad_get_fd(int portid); - -int umad_register(int portid, int mgmt_class, int mgmt_version, - uint8_t rmpp_version, long method_mask[16 / sizeof(long)]); -int umad_register_oui(int portid, int mgmt_class, uint8_t rmpp_version, - uint8_t oui[3], long method_mask[16 / sizeof(long)]); -int umad_unregister(int portid, int agentid); - -enum { - UMAD_USER_RMPP = (1 << 0) -}; - -struct umad_reg_attr { - uint8_t mgmt_class; - uint8_t mgmt_class_version; - uint32_t flags; - uint64_t method_mask[2]; - uint32_t oui; - uint8_t rmpp_version; -}; - -int umad_register2(int port_fd, struct umad_reg_attr *attr, - uint32_t *agent_id); - -int umad_debug(int level); -void umad_addr_dump(ib_mad_addr_t * addr); -void umad_dump(void *umad); - -static inline void *umad_alloc(int num, size_t size) -{ /* alloc array of umad buffers */ - return calloc(num, size); -} - -static inline void umad_free(void *umad) -{ - free(umad); -} - -/* Users should use the glibc functions directly, not these wrappers */ -#ifndef ntohll -#undef ntohll -static inline __attribute__((deprecated)) uint64_t ntohll(uint64_t x) { return be64toh(x); } -#define ntohll ntohll -#endif -#ifndef htonll -#undef htonll -static inline __attribute__((deprecated)) uint64_t htonll(uint64_t x) { return htobe64(x); } -#define htonll htonll -#endif - -END_C_DECLS -#endif /* _UMAD_H */ diff --git a/usr/rdma-core/libibumad/umad_cm.h b/usr/rdma-core/libibumad/umad_cm.h deleted file mode 100644 index e063f8a20..000000000 --- a/usr/rdma-core/libibumad/umad_cm.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2010 Intel Corporation. All rights reserved. - * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _UMAD_CM_H -#define _UMAD_CM_H - -#include - -#ifdef __cplusplus -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } -#else /* !__cplusplus */ -# define BEGIN_C_DECLS -# define END_C_DECLS -#endif /* __cplusplus */ - -BEGIN_C_DECLS - -/* Communication management attributes */ -enum { - UMAD_CM_ATTR_REQ = 0x0010, - UMAD_CM_ATTR_MRA = 0x0011, - UMAD_CM_ATTR_REJ = 0x0012, - UMAD_CM_ATTR_REP = 0x0013, - UMAD_CM_ATTR_RTU = 0x0014, - UMAD_CM_ATTR_DREQ = 0x0015, - UMAD_CM_ATTR_DREP = 0x0016, - UMAD_CM_ATTR_SIDR_REQ = 0x0017, - UMAD_CM_ATTR_SIDR_REP = 0x0018, - UMAD_CM_ATTR_LAP = 0x0019, - UMAD_CM_ATTR_APR = 0x001A, - UMAD_CM_ATTR_SAP = 0x001B, - UMAD_CM_ATTR_SPR = 0x001C, -}; - -END_C_DECLS -#endif /* _UMAD_CM_H */ diff --git a/usr/rdma-core/libibumad/umad_sa.h b/usr/rdma-core/libibumad/umad_sa.h deleted file mode 100644 index 3f0f877b7..000000000 --- a/usr/rdma-core/libibumad/umad_sa.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2004 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Voltaire, Inc. All rights reserved. - * Copyright (c) 2006, 2010 Intel Corporation. All rights reserved. - * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -#ifndef _UMAD_SA_H -#define _UMAD_SA_H - -#include - -#ifdef __cplusplus -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } -#else /* !__cplusplus */ -# define BEGIN_C_DECLS -# define END_C_DECLS -#endif /* __cplusplus */ - -BEGIN_C_DECLS - -/* SA specific methods */ -enum { - UMAD_SA_CLASS_VERSION = 2, /* IB spec version 1.1/1.2 */ - - UMAD_SA_METHOD_GET_TABLE = 0x12, - UMAD_SA_METHOD_GET_TABLE_RESP = 0x92, - UMAD_SA_METHOD_DELETE = 0x15, - UMAD_SA_METHOD_DELETE_RESP = 0x95, - UMAD_SA_METHOD_GET_MULTI = 0x14, - UMAD_SA_METHOD_GET_MULTI_RESP = 0x94, - UMAD_SA_METHOD_GET_TRACE_TABLE = 0x13 -}; - -enum { - UMAD_SA_STATUS_SUCCESS = 0, - UMAD_SA_STATUS_NO_RESOURCES = 1, - UMAD_SA_STATUS_REQ_INVALID = 2, - UMAD_SA_STATUS_NO_RECORDS = 3, - UMAD_SA_STATUS_TOO_MANY_RECORDS = 4, - UMAD_SA_STATUS_INVALID_GID = 5, - UMAD_SA_STATUS_INSUF_COMPS = 6, - UMAD_SA_STATUS_REQ_DENIED = 7, - UMAD_SA_STATUS_PRI_SUGGESTED = 8 -}; - -/* SA attributes */ -enum { - UMAD_SA_ATTR_NODE_REC = 0x0011, - UMAD_SA_ATTR_PORT_INFO_REC = 0x0012, - UMAD_SA_ATTR_SLVL_REC = 0x0013, - UMAD_SA_ATTR_SWITCH_INFO_REC = 0x0014, - UMAD_SA_ATTR_LINEAR_FT_REC = 0x0015, - UMAD_SA_ATTR_RANDOM_FT_REC = 0x0016, - UMAD_SA_ATTR_MCAST_FT_REC = 0x0017, - UMAD_SA_ATTR_SM_INFO_REC = 0x0018, - UMAD_SA_ATTR_LINK_SPD_WIDTH_TABLE_REC = 0x0019, - UMAD_SA_ATTR_INFORM_INFO_REC = 0x00F3, - UMAD_SA_ATTR_LINK_REC = 0x0020, - UMAD_SA_ATTR_GUID_INFO_REC = 0x0030, - UMAD_SA_ATTR_SERVICE_REC = 0x0031, - UMAD_SA_ATTR_PKEY_TABLE_REC = 0x0033, - UMAD_SA_ATTR_PATH_REC = 0x0035, - UMAD_SA_ATTR_VL_ARB_REC = 0x0036, - UMAD_SA_ATTR_MCMEMBER_REC = 0x0038, - UMAD_SA_ATTR_TRACE_REC = 0x0039, - UMAD_SA_ATTR_MULTI_PATH_REC = 0x003A, - UMAD_SA_ATTR_SERVICE_ASSOC_REC = 0x003B, - UMAD_SA_ATTR_HIERARCHY_INFO_REC = 0x003C, - UMAD_SA_ATTR_CABLE_INFO_REC = 0x003D, - UMAD_SA_ATTR_PORT_INFO_EXT_REC = 0x003E -}; - -enum { - UMAD_LEN_SA_DATA = 200 -}; - -/* CM bits */ -enum { - UMAD_SA_CAP_MASK_IS_SUBNET_OPT_REC_SUP = (1 << 8), - UMAD_SA_CAP_MASK_IS_UD_MCAST_SUP = (1 << 9), - UMAD_SA_CAP_MASK_IS_MULTIPATH_SUP = (1 << 10), - UMAD_SA_CAP_MASK_IS_REINIT_SUP = (1 << 11), - UMAD_SA_CAP_MASK_IS_GID_SCOPED_MULTIPATH_SUP = (1 << 12), - UMAD_SA_CAP_MASK_IS_PORTINFO_CAP_MASK_MATCH_SUP = (1 << 13), - UMAD_SA_CAP_MASK_IS_LINK_SPEED_WIDTH_PAIRS_REC_SUP = (1 << 14), - UMAD_SA_CAP_MASK_IS_PA_SERVICES_SUP = (1 << 15) -}; -/* CM2 bits */ -enum { - UMAD_SA_CAP_MASK2_IS_UNPATH_REPATH_SUP = (1 << 0), - UMAD_SA_CAP_MASK2_IS_QOS_SUP = (1 << 1), - UMAD_SA_CAP_MASK2_IS_REV_PATH_PKEY_MEM_BIT_SUP = (1 << 2), - UMAD_SA_CAP_MASK2_IS_MCAST_TOP_SUP = (1 << 3), - UMAD_SA_CAP_MASK2_IS_HIERARCHY_INFO_SUP = (1 << 4), - UMAD_SA_CAP_MASK2_IS_ADDITIONAL_GUID_SUP = (1 << 5), - UMAD_SA_CAP_MASK2_IS_FULL_PORTINFO_REC_SUP = (1 << 6), - UMAD_SA_CAP_MASK2_IS_EXT_SPEEDS_SUP = (1 << 7), - UMAD_SA_CAP_MASK2_IS_MCAST_SERVICE_REC_SUP = (1 << 8), - UMAD_SA_CAP_MASK2_IS_CABLE_INFO_REC_SUP = (1 << 9), - UMAD_SA_CAP_MASK2_IS_PORT_INFO_CAPMASK2_MATCH_SUP = (1 << 10), - UMAD_SA_CAP_MASK2_IS_PORT_INFO_EXT_REC_SUP = (1 << 11) -}; - -/* - * sm_key is not aligned on an 8-byte boundary, so is defined as a byte array - */ -struct umad_sa_packet { - struct umad_hdr mad_hdr; - struct umad_rmpp_hdr rmpp_hdr; - uint8_t sm_key[8]; /* network-byte order */ - __be16 attr_offset; - __be16 reserved; - __be64 comp_mask; - uint8_t data[UMAD_LEN_SA_DATA]; /* network-byte order */ -}; - -END_C_DECLS -#endif /* _UMAD_SA_H */ diff --git a/usr/rdma-core/libibumad/umad_sm.h b/usr/rdma-core/libibumad/umad_sm.h deleted file mode 100644 index d912608e2..000000000 --- a/usr/rdma-core/libibumad/umad_sm.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2004-2014 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2004 Infinicon Corporation. All rights reserved. - * Copyright (c) 2004 Intel Corporation. All rights reserved. - * Copyright (c) 2004 Topspin Corporation. All rights reserved. - * Copyright (c) 2004 Voltaire Corporation. All rights reserved. - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _UMAD_SM_H -#define _UMAD_SM_H - -#include - -#ifdef __cplusplus -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } -#else /* !__cplusplus */ -# define BEGIN_C_DECLS -# define END_C_DECLS -#endif /* __cplusplus */ - -BEGIN_C_DECLS - -enum { - UMAD_SMP_DIRECTION = 0x8000, -}; - -/* Subnet management attributes */ -enum { - UMAD_SM_ATTR_NODE_DESC = 0x0010, - UMAD_SM_ATTR_NODE_INFO = 0x0011, - UMAD_SM_ATTR_SWITCH_INFO = 0x0012, - UMAD_SM_ATTR_GUID_INFO = 0x0014, - UMAD_SM_ATTR_PORT_INFO = 0x0015, - UMAD_SM_ATTR_PKEY_TABLE = 0x0016, - UMAD_SM_ATTR_SLVL_TABLE = 0x0017, - UMAD_SM_ATTR_VL_ARB_TABLE = 0x0018, - UMAD_SM_ATTR_LINEAR_FT = 0x0019, - UMAD_SM_ATTR_RANDOM_FT = 0x001A, - UMAD_SM_ATTR_MCAST_FT = 0x001B, - UMAD_SM_ATTR_LINK_SPD_WIDTH_TABLE = 0x001C, - UMAD_SM_ATTR_VENDOR_MADS_TABLE = 0x001D, - UMAD_SM_ATTR_HIERARCHY_INFO = 0x001E, - UMAD_SM_ATTR_SM_INFO = 0x0020, - UMAD_SM_ATTR_VENDOR_DIAG = 0x0030, - UMAD_SM_ATTR_LED_INFO = 0x0031, - UMAD_SM_ATTR_CABLE_INFO = 0x0032, - UMAD_SM_ATTR_PORT_INFO_EXT = 0x0033, - UMAD_SM_ATTR_VENDOR_MASK = 0xFF00, - UMAD_SM_ATTR_MLNX_EXT_PORT_INFO = 0xFF90 -}; - -enum { - UMAD_SM_GID_IN_SERVICE_TRAP = 64, - UMAD_SM_GID_OUT_OF_SERVICE_TRAP = 65, - UMAD_SM_MGID_CREATED_TRAP = 66, - UMAD_SM_MGID_DESTROYED_TRAP = 67, - UMAD_SM_UNPATH_TRAP = 68, - UMAD_SM_REPATH_TRAP = 69, - UMAD_SM_LINK_STATE_CHANGED_TRAP = 128, - UMAD_SM_LINK_INTEGRITY_THRESHOLD_TRAP = 129, - UMAD_SM_BUFFER_OVERRUN_THRESHOLD_TRAP = 130, - UMAD_SM_WATCHDOG_TIMER_EXPIRED_TRAP = 131, - UMAD_SM_LOCAL_CHANGES_TRAP = 144, - UMAD_SM_SYS_IMG_GUID_CHANGED_TRAP = 145, - UMAD_SM_BAD_MKEY_TRAP = 256, - UMAD_SM_BAD_PKEY_TRAP = 257, - UMAD_SM_BAD_QKEY_TRAP = 258, - UMAD_SM_BAD_SWITCH_PKEY_TRAP = 259 -}; - -enum { - UMAD_LEN_SMP_DATA = 64, - UMAD_SMP_MAX_HOPS = 64 -}; - -struct umad_smp { - uint8_t base_version; - uint8_t mgmt_class; - uint8_t class_version; - uint8_t method; - __be16 status; - uint8_t hop_ptr; - uint8_t hop_cnt; - __be64 tid; - __be16 attr_id; - __be16 resv; - __be32 attr_mod; - __be64 mkey; - __be16 dr_slid; - __be16 dr_dlid; - uint8_t reserved[28]; - uint8_t data[UMAD_LEN_SMP_DATA]; - uint8_t initial_path[UMAD_SMP_MAX_HOPS]; - uint8_t return_path[UMAD_SMP_MAX_HOPS]; -}; - -END_C_DECLS -#endif /* _UMAD_SM_H */ diff --git a/usr/rdma-core/libibumad/umad_str.c b/usr/rdma-core/libibumad/umad_str.c deleted file mode 100644 index df1a1a9af..000000000 --- a/usr/rdma-core/libibumad/umad_str.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (c) 2004, 2005, 2010 Intel Corporation. All rights reserved. - * Copyright (c) 2013 Lawrence Livermore National Security. All rights reserved. - * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include "umad_str.h" - -const char * umad_class_str(uint8_t mgmt_class) -{ - switch (mgmt_class) { - case UMAD_CLASS_SUBN_LID_ROUTED: - case UMAD_CLASS_SUBN_DIRECTED_ROUTE: - return("Subn"); - case UMAD_CLASS_SUBN_ADM: - return("SubnAdm"); - case UMAD_CLASS_PERF_MGMT: - return("Perf"); - case UMAD_CLASS_BM: - return("BM"); - case UMAD_CLASS_DEVICE_MGMT: - return("DevMgt"); - case UMAD_CLASS_CM: - return("ComMgt"); - case UMAD_CLASS_SNMP: - return("SNMP"); - case UMAD_CLASS_DEVICE_ADM: - return("DevAdm"); - case UMAD_CLASS_BOOT_MGMT: - return("BootMgt"); - case UMAD_CLASS_BIS: - return("BIS"); - case UMAD_CLASS_CONG_MGMT: - return("CongestionManagment"); - default: - break; - } - - if ((UMAD_CLASS_VENDOR_RANGE1_START <= mgmt_class - && mgmt_class <= UMAD_CLASS_VENDOR_RANGE1_END) - || (UMAD_CLASS_VENDOR_RANGE2_START <= mgmt_class - && mgmt_class <= UMAD_CLASS_VENDOR_RANGE2_END)) - return("Vendor"); - - if (UMAD_CLASS_APPLICATION_START <= mgmt_class - && mgmt_class <= UMAD_CLASS_APPLICATION_END) { - return("Application"); - } - return (""); -} - -static const char * umad_common_method_str(uint8_t method) -{ - switch(method) { - case UMAD_METHOD_GET: - return ("Get"); - case UMAD_METHOD_SET: - return ("Set"); - case UMAD_METHOD_GET_RESP: - return ("GetResp"); - case UMAD_METHOD_SEND: - return ("Send"); - case UMAD_METHOD_TRAP: - return ("Trap"); - case UMAD_METHOD_REPORT: - return ("Report"); - case UMAD_METHOD_REPORT_RESP: - return ("ReportResp"); - case UMAD_METHOD_TRAP_REPRESS: - return ("TrapRepress"); - default: - return ("> 8) { - case UMAD_SA_STATUS_SUCCESS: - return ("Success"); - case UMAD_SA_STATUS_NO_RESOURCES: - return ("No Resources"); - case UMAD_SA_STATUS_REQ_INVALID: - return ("Request Invalid"); - case UMAD_SA_STATUS_NO_RECORDS: - return ("No Records"); - case UMAD_SA_STATUS_TOO_MANY_RECORDS: - return ("Too Many Records"); - case UMAD_SA_STATUS_INVALID_GID: - return ("Invalid GID"); - case UMAD_SA_STATUS_INSUF_COMPS: - return ("Insufficient Components"); - case UMAD_SA_STATUS_REQ_DENIED: - return ("Request Denied"); - case UMAD_SA_STATUS_PRI_SUGGESTED: - return ("Priority Suggested"); - } - return ("Undefined Error"); -} - -static const char *umad_common_attr_str(__be16 attr_id) -{ - switch(be16toh(attr_id)) { - case UMAD_ATTR_CLASS_PORT_INFO: - return "Class Port Info"; - case UMAD_ATTR_NOTICE: - return "Notice"; - case UMAD_ATTR_INFORM_INFO: - return "Inform Info"; - default: - return ""; - } -} - -static const char * umad_sm_attr_str(__be16 attr_id) -{ - switch(be16toh(attr_id)) { - case UMAD_SM_ATTR_NODE_DESC: - return ("NodeDescription"); - case UMAD_SM_ATTR_NODE_INFO: - return ("NodeInfo"); - case UMAD_SM_ATTR_SWITCH_INFO: - return ("SwitchInfo"); - case UMAD_SM_ATTR_GUID_INFO: - return ("GUIDInfo"); - case UMAD_SM_ATTR_PORT_INFO: - return ("PortInfo"); - case UMAD_SM_ATTR_PKEY_TABLE: - return ("P_KeyTable"); - case UMAD_SM_ATTR_SLVL_TABLE: - return ("SLtoVLMappingTable"); - case UMAD_SM_ATTR_VL_ARB_TABLE: - return ("VLArbitrationTable"); - case UMAD_SM_ATTR_LINEAR_FT: - return ("LinearForwardingTable"); - case UMAD_SM_ATTR_RANDOM_FT: - return ("RandomForwardingTable"); - case UMAD_SM_ATTR_MCAST_FT: - return ("MulticastForwardingTable"); - case UMAD_SM_ATTR_SM_INFO: - return ("SMInfo"); - case UMAD_SM_ATTR_VENDOR_DIAG: - return ("VendorDiag"); - case UMAD_SM_ATTR_LED_INFO: - return ("LedInfo"); - case UMAD_SM_ATTR_LINK_SPD_WIDTH_TABLE: - return ("LinkSpeedWidthPairsTable"); - case UMAD_SM_ATTR_VENDOR_MADS_TABLE: - return ("VendorSpecificMadsTable"); - case UMAD_SM_ATTR_HIERARCHY_INFO: - return ("HierarchyInfo"); - case UMAD_SM_ATTR_CABLE_INFO: - return ("CableInfo"); - case UMAD_SM_ATTR_PORT_INFO_EXT: - return ("PortInfoExtended"); - default: - return (umad_common_attr_str(attr_id)); - } - return (""); -} - -static const char * umad_sa_attr_str(__be16 attr_id) -{ - switch(be16toh(attr_id)) { - case UMAD_SA_ATTR_NODE_REC: - return ("NodeRecord"); - case UMAD_SA_ATTR_PORT_INFO_REC: - return ("PortInfoRecord"); - case UMAD_SA_ATTR_SLVL_REC: - return ("SLtoVLMappingTableRecord"); - case UMAD_SA_ATTR_SWITCH_INFO_REC: - return ("SwitchInfoRecord"); - case UMAD_SA_ATTR_LINEAR_FT_REC: - return ("LinearForwardingTableRecord"); - case UMAD_SA_ATTR_RANDOM_FT_REC: - return ("RandomForwardingTableRecord"); - case UMAD_SA_ATTR_MCAST_FT_REC: - return ("MulticastForwardingTableRecord"); - case UMAD_SA_ATTR_SM_INFO_REC: - return ("SMInfoRecord"); - case UMAD_SA_ATTR_INFORM_INFO_REC: - return ("InformInfoRecord"); - case UMAD_SA_ATTR_LINK_REC: - return ("LinkRecord"); - case UMAD_SA_ATTR_GUID_INFO_REC: - return ("GuidInfoRecord"); - case UMAD_SA_ATTR_SERVICE_REC: - return ("ServiceRecord"); - case UMAD_SA_ATTR_PKEY_TABLE_REC: - return ("P_KeyTableRecord"); - case UMAD_SA_ATTR_PATH_REC: - return ("PathRecord"); - case UMAD_SA_ATTR_VL_ARB_REC: - return ("VLArbitrationTableRecord"); - case UMAD_SA_ATTR_MCMEMBER_REC: - return ("MCMemberRecord"); - case UMAD_SA_ATTR_TRACE_REC: - return ("TraceRecord"); - case UMAD_SA_ATTR_MULTI_PATH_REC: - return ("MultiPathRecord"); - case UMAD_SA_ATTR_SERVICE_ASSOC_REC: - return ("ServiceAssociationRecord"); - case UMAD_SA_ATTR_LINK_SPD_WIDTH_TABLE_REC: - return ("LinkSpeedWidthPairsTableRecord"); - case UMAD_SA_ATTR_HIERARCHY_INFO_REC: - return ("HierarchyInfoRecord"); - case UMAD_SA_ATTR_CABLE_INFO_REC: - return ("CableInfoRecord"); - case UMAD_SA_ATTR_PORT_INFO_EXT_REC: - return ("PortInfoExtendedRecord"); - default: - return (umad_common_attr_str(attr_id)); - } - return (""); -} - -static const char * umad_cm_attr_str(__be16 attr_id) -{ - switch(be16toh(attr_id)) { - case UMAD_CM_ATTR_REQ: - return "ConnectRequest"; - case UMAD_CM_ATTR_MRA: - return "MsgRcptAck"; - case UMAD_CM_ATTR_REJ: - return "ConnectReject"; - case UMAD_CM_ATTR_REP: - return "ConnectReply"; - case UMAD_CM_ATTR_RTU: - return "ReadyToUse"; - case UMAD_CM_ATTR_DREQ: - return "DisconnectRequest"; - case UMAD_CM_ATTR_DREP: - return "DisconnectReply"; - case UMAD_CM_ATTR_SIDR_REQ: - return "ServiceIDResReq"; - case UMAD_CM_ATTR_SIDR_REP: - return "ServiceIDResReqResp"; - case UMAD_CM_ATTR_LAP: - return "LoadAlternatePath"; - case UMAD_CM_ATTR_APR: - return "AlternatePathResponse"; - case UMAD_CM_ATTR_SAP: - return "SuggestAlternatePath"; - case UMAD_CM_ATTR_SPR: - return "SuggestPathResponse"; - default: - return (umad_common_attr_str(attr_id)); - } - return (""); -} - -const char * umad_attribute_str(uint8_t mgmt_class, __be16 attr_id) -{ - switch (mgmt_class) { - case UMAD_CLASS_SUBN_LID_ROUTED: - case UMAD_CLASS_SUBN_DIRECTED_ROUTE: - return(umad_sm_attr_str(attr_id)); - case UMAD_CLASS_SUBN_ADM: - return(umad_sa_attr_str(attr_id)); - case UMAD_CLASS_CM: - return(umad_cm_attr_str(attr_id)); - } - - return (umad_common_attr_str(attr_id)); -} diff --git a/usr/rdma-core/libibumad/umad_str.h b/usr/rdma-core/libibumad/umad_str.h deleted file mode 100644 index f34394284..000000000 --- a/usr/rdma-core/libibumad/umad_str.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, 2005, 2010 Intel Corporation. All rights reserved. - * Copyright (c) 2013 Lawrence Livermore National Security. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -#ifndef _UMAD_STR_H -#define _UMAD_STR_H - -#include - -#ifdef __cplusplus -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } -#else /* !__cplusplus */ -# define BEGIN_C_DECLS -# define END_C_DECLS -#endif /* __cplusplus */ - -BEGIN_C_DECLS - -const char * umad_class_str(uint8_t mgmt_class); -const char * umad_method_str(uint8_t mgmt_class, uint8_t method); -const char * umad_attribute_str(uint8_t mgmt_class, __be16 attr_id); - -const char * umad_common_mad_status_str(__be16 status); -const char * umad_sa_mad_status_str(__be16 status); - -END_C_DECLS -#endif /* _UMAD_STR_H */ diff --git a/usr/rdma-core/libibumad/umad_types.h b/usr/rdma-core/libibumad/umad_types.h deleted file mode 100644 index 7d29dd48b..000000000 --- a/usr/rdma-core/libibumad/umad_types.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2004 Infinicon Corporation. All rights reserved. - * Copyright (c) 2004, 2010 Intel Corporation. All rights reserved. - * Copyright (c) 2004 Topspin Corporation. All rights reserved. - * Copyright (c) 2004-2006 Voltaire Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -#ifndef _UMAD_TYPES_H -#define _UMAD_TYPES_H - -#include -#include - -#ifdef __cplusplus -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } -#else /* !__cplusplus */ -# define BEGIN_C_DECLS -# define END_C_DECLS -#endif /* __cplusplus */ - -BEGIN_C_DECLS - -#define UMAD_BASE_VERSION 1 -#define UMAD_QKEY 0x80010000 - -/* Management classes */ -enum { - UMAD_CLASS_SUBN_LID_ROUTED = 0x01, - UMAD_CLASS_SUBN_DIRECTED_ROUTE = 0x81, - UMAD_CLASS_SUBN_ADM = 0x03, - UMAD_CLASS_PERF_MGMT = 0x04, - UMAD_CLASS_BM = 0x05, - UMAD_CLASS_DEVICE_MGMT = 0x06, - UMAD_CLASS_CM = 0x07, - UMAD_CLASS_SNMP = 0x08, - UMAD_CLASS_VENDOR_RANGE1_START = 0x09, - UMAD_CLASS_VENDOR_RANGE1_END = 0x0F, - UMAD_CLASS_APPLICATION_START = 0x10, - UMAD_CLASS_DEVICE_ADM = UMAD_CLASS_APPLICATION_START, - UMAD_CLASS_BOOT_MGMT = 0x11, - UMAD_CLASS_BIS = 0x12, - UMAD_CLASS_CONG_MGMT = 0x21, - UMAD_CLASS_APPLICATION_END = 0x2F, - UMAD_CLASS_VENDOR_RANGE2_START = 0x30, - UMAD_CLASS_VENDOR_RANGE2_END = 0x4F -}; - -/* Management methods */ -enum { - UMAD_METHOD_GET = 0x01, - UMAD_METHOD_SET = 0x02, - UMAD_METHOD_GET_RESP = 0x81, - UMAD_METHOD_SEND = 0x03, - UMAD_METHOD_TRAP = 0x05, - UMAD_METHOD_REPORT = 0x06, - UMAD_METHOD_REPORT_RESP = 0x86, - UMAD_METHOD_TRAP_REPRESS = 0x07, - UMAD_METHOD_RESP_MASK = 0x80 -}; - -enum { - UMAD_STATUS_SUCCESS = 0x0000, - UMAD_STATUS_BUSY = 0x0001, - UMAD_STATUS_REDIRECT = 0x0002, - - /* Invalid fields, bits 2-4 */ - UMAD_STATUS_BAD_VERSION = (1 << 2), - UMAD_STATUS_METHOD_NOT_SUPPORTED = (2 << 2), - UMAD_STATUS_ATTR_NOT_SUPPORTED = (3 << 2), - UMAD_STATUS_INVALID_ATTR_VALUE = (7 << 2), - - UMAD_STATUS_INVALID_FIELD_MASK = 0x001C, - UMAD_STATUS_CLASS_MASK = 0xFF00 -}; - -/* Attributes common to multiple classes */ -enum { - UMAD_ATTR_CLASS_PORT_INFO = 0x0001, - UMAD_ATTR_NOTICE = 0x0002, - UMAD_ATTR_INFORM_INFO = 0x0003 -}; - -/* RMPP information */ -#define UMAD_RMPP_VERSION 1 -enum { - UMAD_RMPP_FLAG_ACTIVE = 1, -}; - -enum { - UMAD_LEN_DATA = 232, - UMAD_LEN_RMPP_DATA = 220, - UMAD_LEN_DM_DATA = 192, - UMAD_LEN_VENDOR_DATA = 216, -}; - -struct umad_hdr { - uint8_t base_version; - uint8_t mgmt_class; - uint8_t class_version; - uint8_t method; - __be16 status; - __be16 class_specific; - __be64 tid; - __be16 attr_id; - __be16 resv; - __be32 attr_mod; -}; - -struct umad_rmpp_hdr { - uint8_t rmpp_version; - uint8_t rmpp_type; - uint8_t rmpp_rtime_flags; - uint8_t rmpp_status; - __be32 seg_num; - __be32 paylen_newwin; -}; - -struct umad_packet { - struct umad_hdr mad_hdr; - uint8_t data[UMAD_LEN_DATA]; /* network-byte order */ -}; - -struct umad_rmpp_packet { - struct umad_hdr mad_hdr; - struct umad_rmpp_hdr rmpp_hdr; - uint8_t data[UMAD_LEN_RMPP_DATA]; /* network-byte order */ -}; - -struct umad_dm_packet { - struct umad_hdr mad_hdr; - uint8_t reserved[40]; - uint8_t data[UMAD_LEN_DM_DATA]; /* network-byte order */ -}; - -struct umad_vendor_packet { - struct umad_hdr mad_hdr; - struct umad_rmpp_hdr rmpp_hdr; - uint8_t reserved; - uint8_t oui[3]; /* network-byte order */ - uint8_t data[UMAD_LEN_VENDOR_DATA]; /* network-byte order */ -}; - -enum { - UMAD_OPENIB_OUI = 0x001405 -}; - -enum { - UMAD_CLASS_RESP_TIME_MASK = 0x1F -}; -struct umad_class_port_info { - uint8_t base_ver; - uint8_t class_ver; - __be16 cap_mask; - __be32 cap_mask2_resp_time; - union { - uint8_t redir_gid[16] __attribute__((deprecated)); /* network byte order */ - union umad_gid redirgid; - }; - __be32 redir_tc_sl_fl; - __be16 redir_lid; - __be16 redir_pkey; - __be32 redir_qp; - __be32 redir_qkey; - union { - uint8_t trap_gid[16] __attribute__((deprecated)); /* network byte order */ - union umad_gid trapgid; - }; - __be32 trap_tc_sl_fl; - __be16 trap_lid; - __be16 trap_pkey; - __be32 trap_hl_qp; - __be32 trap_qkey; -}; -static inline uint32_t -umad_class_cap_mask2(struct umad_class_port_info *cpi) -{ - return (be32toh(cpi->cap_mask2_resp_time) >> 5); -} -static inline uint8_t -umad_class_resp_time(struct umad_class_port_info *cpi) -{ - return (uint8_t)(be32toh(cpi->cap_mask2_resp_time) - & UMAD_CLASS_RESP_TIME_MASK); -} - -END_C_DECLS -#endif /* _UMAD_TYPES_H */ diff --git a/usr/rdma-core/libibverbs/CMakeLists.txt b/usr/rdma-core/libibverbs/CMakeLists.txt deleted file mode 100644 index 3072aea33..000000000 --- a/usr/rdma-core/libibverbs/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -#message(STATUS "TARGET_ARCH: ${TARGET_ARCH}") # include HermitCore.cmake in CMakeLists? -#message(STATUS "LOCAL_PREFIX_ARCH_INCLUDE_DIR: ${LOCAL_PREFIX_ARCH_INCLUDE_DIR}") - -publish_headers(infiniband - arch.h - kern-abi.h - opcode.h - sa-kern-abi.h - sa.h - verbs.h - ) - -publish_internal_headers(infiniband - driver.h - marshall.h - ) - -if (NOT NL_KIND EQUAL 0) - set(NEIGH "neigh.c") -else() - set(NEIGH "") -endif() - -configure_file("libibverbs.map.in" - "${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map" @ONLY) - -# runs add_library. -rdma_library(ibverbs "${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map" - # See Documentation/versioning.md - 1 1.1.${PACKAGE_VERSION} - cmd.c - compat-1_0.c - device.c - enum_strs.c - init.c - marshall.c - memory.c - ${NEIGH} - sysfs.c - verbs.c - ) - -target_link_libraries(ibverbs LINK_PRIVATE - ${NL_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ${CMAKE_DL_LIBS} - ) - -message(STATUS "LOCAL_PREFIX_ARCH_LIB_DIR : ${LOCAL_PREFIX_ARCH_LIB_DIR}") -message(STATUS "LOCAL_PREFIX_ARCH_INCLUDE_DIR : ${LOCAL_PREFIX_ARCH_INCLUDE_DIR}") - -# Why does it work for ircce? - -# TODO: We probably also need this for the install step? -#install(TARGETS ibverbs - #DESTINATION ${LOCAL_PREFIX_ARCH_LIB_DIR}) -#install(FILES verbs.h - #DESTINATION ${LOCAL_PREFIX_ARCH_INCLUDE_DIR}) - -# Runs "execute_process(COMMAND ... ln ..." -rdma_create_symlink("${CMAKE_CURRENT_SOURCE_DIR}/verbs.h" - "${LOCAL_PREFIX_ARCH_INCLUDE_DIR}/verbs.h") # working - -# Alternative to symlink: Simply copies verbs hdr to build include dir. -#file(COPY verbs.h DESTINATION "${LOCAL_PREFIX_ARCH_INCLUDE_DIR}") - diff --git a/usr/rdma-core/libibverbs/arch.h b/usr/rdma-core/libibverbs/arch.h deleted file mode 100644 index bcbece8f2..000000000 --- a/usr/rdma-core/libibverbs/arch.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef INFINIBAND_ARCH_H -#define INFINIBAND_ARCH_H - -#include -#include - -#warning "This header is obsolete." - -#ifndef ntohll -#undef htonll -#undef ntohll -/* Users should use the glibc functions directly, not these wrappers */ -static inline __attribute__((deprecated)) uint64_t htonll(uint64_t x) { return htobe64(x); } -static inline __attribute__((deprecated)) uint64_t ntohll(uint64_t x) { return be64toh(x); } -#define htonll htonll -#define ntohll ntohll -#endif - -/* Barrier macros are no longer provided by libibverbs */ - -#endif /* INFINIBAND_ARCH_H */ diff --git a/usr/rdma-core/libibverbs/cmd.c b/usr/rdma-core/libibverbs/cmd.c deleted file mode 100644 index 9d2140fb2..000000000 --- a/usr/rdma-core/libibverbs/cmd.c +++ /dev/null @@ -1,2094 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005 PathScale, Inc. All rights reserved. - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "ibverbs.h" -#include - -int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd, - size_t cmd_size, struct ibv_get_context_resp *resp, - size_t resp_size) -{ - if (abi_ver < IB_USER_VERBS_MIN_ABI_VERSION) - return ENOSYS; - - IBV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size); - - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - context->async_fd = resp->async_fd; - context->num_comp_vectors = resp->num_comp_vectors; - - return 0; -} - -static void copy_query_dev_fields(struct ibv_device_attr *device_attr, - struct ibv_query_device_resp *resp, - uint64_t *raw_fw_ver) -{ - *raw_fw_ver = resp->fw_ver; - device_attr->node_guid = resp->node_guid; - device_attr->sys_image_guid = resp->sys_image_guid; - device_attr->max_mr_size = resp->max_mr_size; - device_attr->page_size_cap = resp->page_size_cap; - device_attr->vendor_id = resp->vendor_id; - device_attr->vendor_part_id = resp->vendor_part_id; - device_attr->hw_ver = resp->hw_ver; - device_attr->max_qp = resp->max_qp; - device_attr->max_qp_wr = resp->max_qp_wr; - device_attr->device_cap_flags = resp->device_cap_flags; - device_attr->max_sge = resp->max_sge; - device_attr->max_sge_rd = resp->max_sge_rd; - device_attr->max_cq = resp->max_cq; - device_attr->max_cqe = resp->max_cqe; - device_attr->max_mr = resp->max_mr; - device_attr->max_pd = resp->max_pd; - device_attr->max_qp_rd_atom = resp->max_qp_rd_atom; - device_attr->max_ee_rd_atom = resp->max_ee_rd_atom; - device_attr->max_res_rd_atom = resp->max_res_rd_atom; - device_attr->max_qp_init_rd_atom = resp->max_qp_init_rd_atom; - device_attr->max_ee_init_rd_atom = resp->max_ee_init_rd_atom; - device_attr->atomic_cap = resp->atomic_cap; - device_attr->max_ee = resp->max_ee; - device_attr->max_rdd = resp->max_rdd; - device_attr->max_mw = resp->max_mw; - device_attr->max_raw_ipv6_qp = resp->max_raw_ipv6_qp; - device_attr->max_raw_ethy_qp = resp->max_raw_ethy_qp; - device_attr->max_mcast_grp = resp->max_mcast_grp; - device_attr->max_mcast_qp_attach = resp->max_mcast_qp_attach; - device_attr->max_total_mcast_qp_attach = resp->max_total_mcast_qp_attach; - device_attr->max_ah = resp->max_ah; - device_attr->max_fmr = resp->max_fmr; - device_attr->max_map_per_fmr = resp->max_map_per_fmr; - device_attr->max_srq = resp->max_srq; - device_attr->max_srq_wr = resp->max_srq_wr; - device_attr->max_srq_sge = resp->max_srq_sge; - device_attr->max_pkeys = resp->max_pkeys; - device_attr->local_ca_ack_delay = resp->local_ca_ack_delay; - device_attr->phys_port_cnt = resp->phys_port_cnt; -} - -int ibv_cmd_query_device(struct ibv_context *context, - struct ibv_device_attr *device_attr, - uint64_t *raw_fw_ver, - struct ibv_query_device *cmd, size_t cmd_size) -{ - struct ibv_query_device_resp resp; - - IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_DEVICE, &resp, sizeof resp); - - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - memset(device_attr->fw_ver, 0, sizeof device_attr->fw_ver); - copy_query_dev_fields(device_attr, &resp, raw_fw_ver); - - return 0; -} - -int ibv_cmd_query_device_ex(struct ibv_context *context, - const struct ibv_query_device_ex_input *input, - struct ibv_device_attr_ex *attr, size_t attr_size, - uint64_t *raw_fw_ver, - struct ibv_query_device_ex *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_query_device_resp_ex *resp, - size_t resp_core_size, - size_t resp_size) -{ - int err; - - if (input && input->comp_mask) - return EINVAL; - - if (attr_size < offsetof(struct ibv_device_attr_ex, comp_mask) + - sizeof(attr->comp_mask)) - return EINVAL; - - if (resp_core_size < offsetof(struct ibv_query_device_resp_ex, - response_length) + - sizeof(resp->response_length)) - return EINVAL; - - IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, - QUERY_DEVICE_EX, resp, resp_core_size, - resp_size); - cmd->comp_mask = 0; - cmd->reserved = 0; - memset(attr->orig_attr.fw_ver, 0, sizeof(attr->orig_attr.fw_ver)); - memset(&attr->comp_mask, 0, attr_size - sizeof(attr->orig_attr)); - err = write(context->cmd_fd, cmd, cmd_size); - if (err != cmd_size) - return errno; - - (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - copy_query_dev_fields(&attr->orig_attr, &resp->base, raw_fw_ver); - /* Report back supported comp_mask bits. For now no comp_mask bit is - * defined */ - attr->comp_mask = resp->comp_mask & 0; - if (attr_size >= offsetof(struct ibv_device_attr_ex, odp_caps) + - sizeof(attr->odp_caps)) { - if (resp->response_length >= - offsetof(struct ibv_query_device_resp_ex, odp_caps) + - sizeof(resp->odp_caps)) { - attr->odp_caps.general_caps = resp->odp_caps.general_caps; - attr->odp_caps.per_transport_caps.rc_odp_caps = - resp->odp_caps.per_transport_caps.rc_odp_caps; - attr->odp_caps.per_transport_caps.uc_odp_caps = - resp->odp_caps.per_transport_caps.uc_odp_caps; - attr->odp_caps.per_transport_caps.ud_odp_caps = - resp->odp_caps.per_transport_caps.ud_odp_caps; - } - } - - if (attr_size >= offsetof(struct ibv_device_attr_ex, - completion_timestamp_mask) + - sizeof(attr->completion_timestamp_mask)) { - if (resp->response_length >= - offsetof(struct ibv_query_device_resp_ex, timestamp_mask) + - sizeof(resp->timestamp_mask)) - attr->completion_timestamp_mask = resp->timestamp_mask; - } - - if (attr_size >= offsetof(struct ibv_device_attr_ex, hca_core_clock) + - sizeof(attr->hca_core_clock)) { - if (resp->response_length >= - offsetof(struct ibv_query_device_resp_ex, hca_core_clock) + - sizeof(resp->hca_core_clock)) - attr->hca_core_clock = resp->hca_core_clock; - } - - if (attr_size >= offsetof(struct ibv_device_attr_ex, device_cap_flags_ex) + - sizeof(attr->device_cap_flags_ex)) { - if (resp->response_length >= - offsetof(struct ibv_query_device_resp_ex, device_cap_flags_ex) + - sizeof(resp->device_cap_flags_ex)) - attr->device_cap_flags_ex = resp->device_cap_flags_ex; - } - - if (attr_size >= offsetof(struct ibv_device_attr_ex, rss_caps) + - sizeof(attr->rss_caps)) { - if (resp->response_length >= - offsetof(struct ibv_query_device_resp_ex, rss_caps) + - sizeof(resp->rss_caps)) { - attr->rss_caps.supported_qpts = resp->rss_caps.supported_qpts; - attr->rss_caps.max_rwq_indirection_tables = resp->rss_caps.max_rwq_indirection_tables; - attr->rss_caps.max_rwq_indirection_table_size = resp->rss_caps.max_rwq_indirection_table_size; - } - } - - if (attr_size >= offsetof(struct ibv_device_attr_ex, max_wq_type_rq) + - sizeof(attr->max_wq_type_rq)) { - if (resp->response_length >= - offsetof(struct ibv_query_device_resp_ex, max_wq_type_rq) + - sizeof(resp->max_wq_type_rq)) - attr->max_wq_type_rq = resp->max_wq_type_rq; - } - - if (attr_size >= offsetof(struct ibv_device_attr_ex, raw_packet_caps) + - sizeof(attr->raw_packet_caps)) { - if (resp->response_length >= - offsetof(struct ibv_query_device_resp_ex, raw_packet_caps) + - sizeof(resp->raw_packet_caps)) - attr->raw_packet_caps = resp->raw_packet_caps; - } - - return 0; -} - -int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num, - struct ibv_port_attr *port_attr, - struct ibv_query_port *cmd, size_t cmd_size) -{ - struct ibv_query_port_resp resp; - - IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_PORT, &resp, sizeof resp); - cmd->port_num = port_num; - memset(cmd->reserved, 0, sizeof cmd->reserved); - - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - port_attr->state = resp.state; - port_attr->max_mtu = resp.max_mtu; - port_attr->active_mtu = resp.active_mtu; - port_attr->gid_tbl_len = resp.gid_tbl_len; - port_attr->port_cap_flags = resp.port_cap_flags; - port_attr->max_msg_sz = resp.max_msg_sz; - port_attr->bad_pkey_cntr = resp.bad_pkey_cntr; - port_attr->qkey_viol_cntr = resp.qkey_viol_cntr; - port_attr->pkey_tbl_len = resp.pkey_tbl_len; - port_attr->lid = resp.lid; - port_attr->sm_lid = resp.sm_lid; - port_attr->lmc = resp.lmc; - port_attr->max_vl_num = resp.max_vl_num; - port_attr->sm_sl = resp.sm_sl; - port_attr->subnet_timeout = resp.subnet_timeout; - port_attr->init_type_reply = resp.init_type_reply; - port_attr->active_width = resp.active_width; - port_attr->active_speed = resp.active_speed; - port_attr->phys_state = resp.phys_state; - port_attr->link_layer = resp.link_layer; - - return 0; -} - -int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd, - struct ibv_alloc_pd *cmd, size_t cmd_size, - struct ibv_alloc_pd_resp *resp, size_t resp_size) -{ - IBV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_PD, resp, resp_size); - - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - pd->handle = resp->pd_handle; - pd->context = context; - - return 0; -} - -int ibv_cmd_dealloc_pd(struct ibv_pd *pd) -{ - struct ibv_dealloc_pd cmd; - - IBV_INIT_CMD(&cmd, sizeof cmd, DEALLOC_PD); - cmd.pd_handle = pd->handle; - - if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - return 0; -} - -int ibv_cmd_open_xrcd(struct ibv_context *context, struct verbs_xrcd *xrcd, - int vxrcd_size, - struct ibv_xrcd_init_attr *attr, - struct ibv_open_xrcd *cmd, size_t cmd_size, - struct ibv_open_xrcd_resp *resp, size_t resp_size) -{ - IBV_INIT_CMD_RESP(cmd, cmd_size, OPEN_XRCD, resp, resp_size); - - if (attr->comp_mask >= IBV_XRCD_INIT_ATTR_RESERVED) - return ENOSYS; - - if (!(attr->comp_mask & IBV_XRCD_INIT_ATTR_FD) || - !(attr->comp_mask & IBV_XRCD_INIT_ATTR_OFLAGS)) - return EINVAL; - - cmd->fd = attr->fd; - cmd->oflags = attr->oflags; - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - xrcd->xrcd.context = context; - xrcd->comp_mask = 0; - if (vext_field_avail(struct verbs_xrcd, handle, vxrcd_size)) { - xrcd->comp_mask = VERBS_XRCD_HANDLE; - xrcd->handle = resp->xrcd_handle; - } - - return 0; -} - -int ibv_cmd_close_xrcd(struct verbs_xrcd *xrcd) -{ - struct ibv_close_xrcd cmd; - - IBV_INIT_CMD(&cmd, sizeof cmd, CLOSE_XRCD); - cmd.xrcd_handle = xrcd->handle; - - if (write(xrcd->xrcd.context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - return 0; -} - -int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length, - uint64_t hca_va, int access, - struct ibv_mr *mr, struct ibv_reg_mr *cmd, - size_t cmd_size, - struct ibv_reg_mr_resp *resp, size_t resp_size) -{ - - IBV_INIT_CMD_RESP(cmd, cmd_size, REG_MR, resp, resp_size); - - cmd->start = (uintptr_t) addr; - cmd->length = length; - cmd->hca_va = hca_va; - cmd->pd_handle = pd->handle; - cmd->access_flags = access; - - if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - mr->handle = resp->mr_handle; - mr->lkey = resp->lkey; - mr->rkey = resp->rkey; - mr->context = pd->context; - - return 0; -} - -int ibv_cmd_rereg_mr(struct ibv_mr *mr, uint32_t flags, void *addr, - size_t length, uint64_t hca_va, int access, - struct ibv_pd *pd, struct ibv_rereg_mr *cmd, - size_t cmd_sz, struct ibv_rereg_mr_resp *resp, - size_t resp_sz) -{ - IBV_INIT_CMD_RESP(cmd, cmd_sz, REREG_MR, resp, resp_sz); - - cmd->mr_handle = mr->handle; - cmd->flags = flags; - cmd->start = (uintptr_t)addr; - cmd->length = length; - cmd->hca_va = hca_va; - cmd->pd_handle = (flags & IBV_REREG_MR_CHANGE_PD) ? pd->handle : 0; - cmd->access_flags = access; - - if (write(mr->context->cmd_fd, cmd, cmd_sz) != cmd_sz) - return errno; - - (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_sz); - - mr->lkey = resp->lkey; - mr->rkey = resp->rkey; - if (flags & IBV_REREG_MR_CHANGE_PD) - mr->context = pd->context; - - return 0; -} - -int ibv_cmd_dereg_mr(struct ibv_mr *mr) -{ - struct ibv_dereg_mr cmd; - - IBV_INIT_CMD(&cmd, sizeof cmd, DEREG_MR); - cmd.mr_handle = mr->handle; - - if (write(mr->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - return 0; -} - -int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type, - struct ibv_mw *mw, struct ibv_alloc_mw *cmd, - size_t cmd_size, - struct ibv_alloc_mw_resp *resp, size_t resp_size) -{ - IBV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_MW, resp, resp_size); - cmd->pd_handle = pd->handle; - cmd->mw_type = type; - memset(cmd->reserved, 0, sizeof(cmd->reserved)); - - if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - mw->context = pd->context; - mw->pd = pd; - mw->rkey = resp->rkey; - mw->handle = resp->mw_handle; - mw->type = type; - - return 0; -} - -int ibv_cmd_dealloc_mw(struct ibv_mw *mw, - struct ibv_dealloc_mw *cmd, size_t cmd_size) -{ - IBV_INIT_CMD(cmd, cmd_size, DEALLOC_MW); - cmd->mw_handle = mw->handle; - cmd->reserved = 0; - - if (write(mw->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - return 0; -} - -int ibv_cmd_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector, struct ibv_cq *cq, - struct ibv_create_cq *cmd, size_t cmd_size, - struct ibv_create_cq_resp *resp, size_t resp_size) -{ - IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_CQ, resp, resp_size); - cmd->user_handle = (uintptr_t) cq; - cmd->cqe = cqe; - cmd->comp_vector = comp_vector; - cmd->comp_channel = channel ? channel->fd : -1; - cmd->reserved = 0; - - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - cq->handle = resp->cq_handle; - cq->cqe = resp->cqe; - cq->context = context; - - return 0; -} - -int ibv_cmd_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr, - struct ibv_cq_ex *cq, - struct ibv_create_cq_ex *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_create_cq_resp_ex *resp, - size_t resp_core_size, - size_t resp_size) -{ - int err; - - memset(cmd, 0, cmd_core_size); - IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, CREATE_CQ_EX, resp, - resp_core_size, resp_size); - - if (cq_attr->comp_mask & ~(IBV_CQ_INIT_ATTR_MASK_RESERVED - 1)) - return EINVAL; - - cmd->user_handle = (uintptr_t)cq; - cmd->cqe = cq_attr->cqe; - cmd->comp_vector = cq_attr->comp_vector; - cmd->comp_channel = cq_attr->channel ? cq_attr->channel->fd : -1; - cmd->comp_mask = 0; - - if (cmd_core_size >= offsetof(struct ibv_create_cq_ex, flags) + - sizeof(cmd->flags)) { - if ((cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS) && - (cq_attr->flags & ~(IBV_CREATE_CQ_ATTR_RESERVED - 1))) - return EOPNOTSUPP; - - if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP) - cmd->flags |= IBV_CREATE_CQ_EX_KERNEL_FLAG_COMPLETION_TIMESTAMP; - } - - err = write(context->cmd_fd, cmd, cmd_size); - if (err != cmd_size) - return errno; - - (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - cq->handle = resp->base.cq_handle; - cq->cqe = resp->base.cqe; - cq->context = context; - - return 0; -} - -int ibv_cmd_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) -{ - struct ibv_poll_cq cmd; - struct ibv_poll_cq_resp *resp; - int i; - int rsize; - int ret; - - rsize = sizeof *resp + ne * sizeof(struct ibv_kern_wc); - resp = malloc(rsize); - if (!resp) - return -1; - - IBV_INIT_CMD_RESP(&cmd, sizeof cmd, POLL_CQ, resp, rsize); - cmd.cq_handle = ibcq->handle; - cmd.ne = ne; - - if (write(ibcq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) { - ret = -1; - goto out; - } - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, rsize); - - for (i = 0; i < resp->count; i++) { - wc[i].wr_id = resp->wc[i].wr_id; - wc[i].status = resp->wc[i].status; - wc[i].opcode = resp->wc[i].opcode; - wc[i].vendor_err = resp->wc[i].vendor_err; - wc[i].byte_len = resp->wc[i].byte_len; - wc[i].imm_data = resp->wc[i].imm_data; - wc[i].qp_num = resp->wc[i].qp_num; - wc[i].src_qp = resp->wc[i].src_qp; - wc[i].wc_flags = resp->wc[i].wc_flags; - wc[i].pkey_index = resp->wc[i].pkey_index; - wc[i].slid = resp->wc[i].slid; - wc[i].sl = resp->wc[i].sl; - wc[i].dlid_path_bits = resp->wc[i].dlid_path_bits; - } - - ret = resp->count; - -out: - free(resp); - return ret; -} - -int ibv_cmd_req_notify_cq(struct ibv_cq *ibcq, int solicited_only) -{ - struct ibv_req_notify_cq cmd; - - IBV_INIT_CMD(&cmd, sizeof cmd, REQ_NOTIFY_CQ); - cmd.cq_handle = ibcq->handle; - cmd.solicited = !!solicited_only; - - if (write(ibcq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - return 0; -} - -int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe, - struct ibv_resize_cq *cmd, size_t cmd_size, - struct ibv_resize_cq_resp *resp, size_t resp_size) -{ - IBV_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, resp, resp_size); - cmd->cq_handle = cq->handle; - cmd->cqe = cqe; - - if (write(cq->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - cq->cqe = resp->cqe; - - return 0; -} - -int ibv_cmd_destroy_cq(struct ibv_cq *cq) -{ - struct ibv_destroy_cq cmd; - struct ibv_destroy_cq_resp resp; - - IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_CQ, &resp, sizeof resp); - cmd.cq_handle = cq->handle; - cmd.reserved = 0; - - if (write(cq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - pthread_mutex_lock(&cq->mutex); - while (cq->comp_events_completed != resp.comp_events_reported || - cq->async_events_completed != resp.async_events_reported) - pthread_cond_wait(&cq->cond, &cq->mutex); - pthread_mutex_unlock(&cq->mutex); - - return 0; -} - -int ibv_cmd_create_srq(struct ibv_pd *pd, - struct ibv_srq *srq, struct ibv_srq_init_attr *attr, - struct ibv_create_srq *cmd, size_t cmd_size, - struct ibv_create_srq_resp *resp, size_t resp_size) -{ - IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_SRQ, resp, resp_size); - cmd->user_handle = (uintptr_t) srq; - cmd->pd_handle = pd->handle; - cmd->max_wr = attr->attr.max_wr; - cmd->max_sge = attr->attr.max_sge; - cmd->srq_limit = attr->attr.srq_limit; - - if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - srq->handle = resp->srq_handle; - srq->context = pd->context; - - if (abi_ver > 5) { - attr->attr.max_wr = resp->max_wr; - attr->attr.max_sge = resp->max_sge; - } else { - struct ibv_create_srq_resp_v5 *resp_v5 = - (struct ibv_create_srq_resp_v5 *) resp; - - memmove((void *) resp + sizeof *resp, - (void *) resp_v5 + sizeof *resp_v5, - resp_size - sizeof *resp); - } - - return 0; -} - -int ibv_cmd_create_srq_ex(struct ibv_context *context, - struct verbs_srq *srq, int vsrq_sz, - struct ibv_srq_init_attr_ex *attr_ex, - struct ibv_create_xsrq *cmd, size_t cmd_size, - struct ibv_create_srq_resp *resp, size_t resp_size) -{ - struct verbs_xrcd *vxrcd = NULL; - - IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_XSRQ, resp, resp_size); - - if (attr_ex->comp_mask >= IBV_SRQ_INIT_ATTR_RESERVED) - return ENOSYS; - - if (!(attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_PD)) - return EINVAL; - - cmd->user_handle = (uintptr_t) srq; - cmd->pd_handle = attr_ex->pd->handle; - cmd->max_wr = attr_ex->attr.max_wr; - cmd->max_sge = attr_ex->attr.max_sge; - cmd->srq_limit = attr_ex->attr.srq_limit; - - cmd->srq_type = (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) ? - attr_ex->srq_type : IBV_SRQT_BASIC; - if (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_XRCD) { - if (!(attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_CQ)) - return EINVAL; - - vxrcd = container_of(attr_ex->xrcd, struct verbs_xrcd, xrcd); - cmd->xrcd_handle = vxrcd->handle; - cmd->cq_handle = attr_ex->cq->handle; - } - - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - srq->srq.handle = resp->srq_handle; - srq->srq.context = context; - srq->srq.srq_context = attr_ex->srq_context; - srq->srq.pd = attr_ex->pd; - srq->srq.events_completed = 0; - pthread_mutex_init(&srq->srq.mutex, NULL); - pthread_cond_init(&srq->srq.cond, NULL); - - /* - * check that the last field is available. - * If it is than all the others exist as well - */ - if (vext_field_avail(struct verbs_srq, srq_num, vsrq_sz)) { - srq->comp_mask = IBV_SRQ_INIT_ATTR_TYPE; - srq->srq_type = (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) ? - attr_ex->srq_type : IBV_SRQT_BASIC; - if (srq->srq_type == IBV_SRQT_XRC) { - srq->comp_mask |= VERBS_SRQ_NUM; - srq->srq_num = resp->srqn; - } - if (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_XRCD) { - srq->comp_mask |= VERBS_SRQ_XRCD; - srq->xrcd = vxrcd; - } - if (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_CQ) { - srq->comp_mask |= VERBS_SRQ_CQ; - srq->cq = attr_ex->cq; - } - } - - attr_ex->attr.max_wr = resp->max_wr; - attr_ex->attr.max_sge = resp->max_sge; - - return 0; -} - - -static int ibv_cmd_modify_srq_v3(struct ibv_srq *srq, - struct ibv_srq_attr *srq_attr, - int srq_attr_mask, - struct ibv_modify_srq *new_cmd, - size_t new_cmd_size) -{ - struct ibv_modify_srq_v3 *cmd; - size_t cmd_size; - - cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd; - cmd = alloca(cmd_size); - memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd); - - IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ); - - cmd->srq_handle = srq->handle; - cmd->attr_mask = srq_attr_mask; - cmd->max_wr = srq_attr->max_wr; - cmd->srq_limit = srq_attr->srq_limit; - cmd->max_sge = 0; - cmd->reserved = 0; - - if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - return 0; -} - -int ibv_cmd_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *srq_attr, - int srq_attr_mask, - struct ibv_modify_srq *cmd, size_t cmd_size) -{ - if (abi_ver == 3) - return ibv_cmd_modify_srq_v3(srq, srq_attr, srq_attr_mask, - cmd, cmd_size); - - IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ); - - cmd->srq_handle = srq->handle; - cmd->attr_mask = srq_attr_mask; - cmd->max_wr = srq_attr->max_wr; - cmd->srq_limit = srq_attr->srq_limit; - - if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - return 0; -} - -int ibv_cmd_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr, - struct ibv_query_srq *cmd, size_t cmd_size) -{ - struct ibv_query_srq_resp resp; - - IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_SRQ, &resp, sizeof resp); - cmd->srq_handle = srq->handle; - cmd->reserved = 0; - - if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - srq_attr->max_wr = resp.max_wr; - srq_attr->max_sge = resp.max_sge; - srq_attr->srq_limit = resp.srq_limit; - - return 0; -} - -int ibv_cmd_destroy_srq(struct ibv_srq *srq) -{ - struct ibv_destroy_srq cmd; - struct ibv_destroy_srq_resp resp; - - IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_SRQ, &resp, sizeof resp); - cmd.srq_handle = srq->handle; - cmd.reserved = 0; - - if (write(srq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - pthread_mutex_lock(&srq->mutex); - while (srq->events_completed != resp.events_reported) - pthread_cond_wait(&srq->cond, &srq->mutex); - pthread_mutex_unlock(&srq->mutex); - - return 0; -} - -static int create_qp_ex_common(struct verbs_qp *qp, - struct ibv_qp_init_attr_ex *qp_attr, - struct verbs_xrcd *vxrcd, - struct ibv_create_qp_common *cmd) -{ - cmd->user_handle = (uintptr_t)qp; - - if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_XRCD) { - vxrcd = container_of(qp_attr->xrcd, struct verbs_xrcd, xrcd); - cmd->pd_handle = vxrcd->handle; - } else { - if (!(qp_attr->comp_mask & IBV_QP_INIT_ATTR_PD)) - return EINVAL; - - cmd->pd_handle = qp_attr->pd->handle; - if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE) { - if (cmd->max_recv_wr || cmd->max_recv_sge || - cmd->recv_cq_handle || qp_attr->srq) - return EINVAL; - - /* send_cq is optinal */ - if (qp_attr->cap.max_send_wr) - cmd->send_cq_handle = qp_attr->send_cq->handle; - } else { - cmd->send_cq_handle = qp_attr->send_cq->handle; - - if (qp_attr->qp_type != IBV_QPT_XRC_SEND) { - cmd->recv_cq_handle = qp_attr->recv_cq->handle; - cmd->srq_handle = qp_attr->srq ? qp_attr->srq->handle : - 0; - } - } - } - - cmd->max_send_wr = qp_attr->cap.max_send_wr; - cmd->max_recv_wr = qp_attr->cap.max_recv_wr; - cmd->max_send_sge = qp_attr->cap.max_send_sge; - cmd->max_recv_sge = qp_attr->cap.max_recv_sge; - cmd->max_inline_data = qp_attr->cap.max_inline_data; - cmd->sq_sig_all = qp_attr->sq_sig_all; - cmd->qp_type = qp_attr->qp_type; - cmd->is_srq = !!qp_attr->srq; - cmd->reserved = 0; - - return 0; -} - -static void create_qp_handle_resp_common(struct ibv_context *context, - struct verbs_qp *qp, - struct ibv_qp_init_attr_ex *qp_attr, - struct ibv_create_qp_resp *resp, - struct verbs_xrcd *vxrcd, - int vqp_sz) -{ - if (abi_ver > 3) { - qp_attr->cap.max_recv_sge = resp->max_recv_sge; - qp_attr->cap.max_send_sge = resp->max_send_sge; - qp_attr->cap.max_recv_wr = resp->max_recv_wr; - qp_attr->cap.max_send_wr = resp->max_send_wr; - qp_attr->cap.max_inline_data = resp->max_inline_data; - } - - qp->qp.handle = resp->qp_handle; - qp->qp.qp_num = resp->qpn; - qp->qp.context = context; - qp->qp.qp_context = qp_attr->qp_context; - qp->qp.pd = qp_attr->pd; - qp->qp.send_cq = qp_attr->send_cq; - qp->qp.recv_cq = qp_attr->recv_cq; - qp->qp.srq = qp_attr->srq; - qp->qp.qp_type = qp_attr->qp_type; - qp->qp.state = IBV_QPS_RESET; - qp->qp.events_completed = 0; - pthread_mutex_init(&qp->qp.mutex, NULL); - pthread_cond_init(&qp->qp.cond, NULL); - - qp->comp_mask = 0; - if (vext_field_avail(struct verbs_qp, xrcd, vqp_sz) && - (qp_attr->comp_mask & IBV_QP_INIT_ATTR_XRCD)) { - qp->comp_mask |= VERBS_QP_XRCD; - qp->xrcd = vxrcd; - } -} - -enum { - CREATE_QP_EX2_SUP_CREATE_FLAGS = IBV_QP_CREATE_BLOCK_SELF_MCAST_LB | - IBV_QP_CREATE_SCATTER_FCS | - IBV_QP_CREATE_CVLAN_STRIPPING | - IBV_QP_CREATE_SOURCE_QPN, -}; - -int ibv_cmd_create_qp_ex2(struct ibv_context *context, - struct verbs_qp *qp, int vqp_sz, - struct ibv_qp_init_attr_ex *qp_attr, - struct ibv_create_qp_ex *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_create_qp_resp_ex *resp, - size_t resp_core_size, - size_t resp_size) -{ - struct verbs_xrcd *vxrcd = NULL; - int err; - - if (qp_attr->comp_mask >= IBV_QP_INIT_ATTR_RESERVED) - return EINVAL; - - if (resp_core_size < - offsetof(struct ibv_create_qp_resp_ex, response_length) + - sizeof(resp->response_length)) - return EINVAL; - - memset(cmd, 0, cmd_core_size); - - IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, CREATE_QP_EX, resp, - resp_core_size, resp_size); - - err = create_qp_ex_common(qp, qp_attr, vxrcd, &cmd->base); - if (err) - return err; - - if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_CREATE_FLAGS) { - if (qp_attr->create_flags & ~CREATE_QP_EX2_SUP_CREATE_FLAGS) - return EINVAL; - if (cmd_core_size < offsetof(struct ibv_create_qp_ex, create_flags) + - sizeof(qp_attr->create_flags)) - return EINVAL; - cmd->create_flags = qp_attr->create_flags; - - if (qp_attr->create_flags & IBV_QP_CREATE_SOURCE_QPN) - cmd->source_qpn = qp_attr->source_qpn; - } - - if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE) { - if (cmd_core_size < offsetof(struct ibv_create_qp_ex, ind_tbl_handle) + - sizeof(cmd->ind_tbl_handle)) - return EINVAL; - cmd->ind_tbl_handle = qp_attr->rwq_ind_tbl->ind_tbl_handle; - cmd->comp_mask = IBV_CREATE_QP_EX_KERNEL_MASK_IND_TABLE; - } - - err = write(context->cmd_fd, cmd, cmd_size); - if (err != cmd_size) - return errno; - - (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - create_qp_handle_resp_common(context, qp, qp_attr, &resp->base, vxrcd, - vqp_sz); - - return 0; -} - -int ibv_cmd_create_qp_ex(struct ibv_context *context, - struct verbs_qp *qp, int vqp_sz, - struct ibv_qp_init_attr_ex *attr_ex, - struct ibv_create_qp *cmd, size_t cmd_size, - struct ibv_create_qp_resp *resp, size_t resp_size) -{ - struct verbs_xrcd *vxrcd = NULL; - int err; - - IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size); - - if (attr_ex->comp_mask > (IBV_QP_INIT_ATTR_XRCD | IBV_QP_INIT_ATTR_PD)) - return ENOSYS; - - err = create_qp_ex_common(qp, attr_ex, vxrcd, - (struct ibv_create_qp_common *)&cmd->user_handle); - if (err) - return err; - - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - if (abi_ver == 4) { - struct ibv_create_qp_resp_v4 *resp_v4 = - (struct ibv_create_qp_resp_v4 *)resp; - - memmove((void *)resp + sizeof *resp, - (void *)resp_v4 + sizeof *resp_v4, - resp_size - sizeof *resp); - } else if (abi_ver <= 3) { - struct ibv_create_qp_resp_v3 *resp_v3 = - (struct ibv_create_qp_resp_v3 *)resp; - - memmove((void *)resp + sizeof *resp, - (void *)resp_v3 + sizeof *resp_v3, - resp_size - sizeof *resp); - } - - create_qp_handle_resp_common(context, qp, attr_ex, resp, vxrcd, vqp_sz); - - return 0; -} - -int ibv_cmd_create_qp(struct ibv_pd *pd, - struct ibv_qp *qp, struct ibv_qp_init_attr *attr, - struct ibv_create_qp *cmd, size_t cmd_size, - struct ibv_create_qp_resp *resp, size_t resp_size) -{ - IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size); - - cmd->user_handle = (uintptr_t) qp; - cmd->pd_handle = pd->handle; - cmd->send_cq_handle = attr->send_cq->handle; - cmd->recv_cq_handle = attr->recv_cq->handle; - cmd->srq_handle = attr->srq ? attr->srq->handle : 0; - cmd->max_send_wr = attr->cap.max_send_wr; - cmd->max_recv_wr = attr->cap.max_recv_wr; - cmd->max_send_sge = attr->cap.max_send_sge; - cmd->max_recv_sge = attr->cap.max_recv_sge; - cmd->max_inline_data = attr->cap.max_inline_data; - cmd->sq_sig_all = attr->sq_sig_all; - cmd->qp_type = attr->qp_type; - cmd->is_srq = !!attr->srq; - cmd->reserved = 0; - - if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - qp->handle = resp->qp_handle; - qp->qp_num = resp->qpn; - qp->context = pd->context; - - if (abi_ver > 3) { - attr->cap.max_recv_sge = resp->max_recv_sge; - attr->cap.max_send_sge = resp->max_send_sge; - attr->cap.max_recv_wr = resp->max_recv_wr; - attr->cap.max_send_wr = resp->max_send_wr; - attr->cap.max_inline_data = resp->max_inline_data; - } - - if (abi_ver == 4) { - struct ibv_create_qp_resp_v4 *resp_v4 = - (struct ibv_create_qp_resp_v4 *) resp; - - memmove((void *) resp + sizeof *resp, - (void *) resp_v4 + sizeof *resp_v4, - resp_size - sizeof *resp); - } else if (abi_ver <= 3) { - struct ibv_create_qp_resp_v3 *resp_v3 = - (struct ibv_create_qp_resp_v3 *) resp; - - memmove((void *) resp + sizeof *resp, - (void *) resp_v3 + sizeof *resp_v3, - resp_size - sizeof *resp); - } - - return 0; -} - -int ibv_cmd_open_qp(struct ibv_context *context, struct verbs_qp *qp, - int vqp_sz, - struct ibv_qp_open_attr *attr, - struct ibv_open_qp *cmd, size_t cmd_size, - struct ibv_create_qp_resp *resp, size_t resp_size) -{ - struct verbs_xrcd *xrcd; - IBV_INIT_CMD_RESP(cmd, cmd_size, OPEN_QP, resp, resp_size); - - if (attr->comp_mask >= IBV_QP_OPEN_ATTR_RESERVED) - return ENOSYS; - - if (!(attr->comp_mask & IBV_QP_OPEN_ATTR_XRCD) || - !(attr->comp_mask & IBV_QP_OPEN_ATTR_NUM) || - !(attr->comp_mask & IBV_QP_OPEN_ATTR_TYPE)) - return EINVAL; - - xrcd = container_of(attr->xrcd, struct verbs_xrcd, xrcd); - cmd->user_handle = (uintptr_t) qp; - cmd->pd_handle = xrcd->handle; - cmd->qpn = attr->qp_num; - cmd->qp_type = attr->qp_type; - - if (write(context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - qp->qp.handle = resp->qp_handle; - qp->qp.context = context; - qp->qp.qp_context = attr->qp_context; - qp->qp.pd = NULL; - qp->qp.send_cq = NULL; - qp->qp.recv_cq = NULL; - qp->qp.srq = NULL; - qp->qp.qp_num = attr->qp_num; - qp->qp.qp_type = attr->qp_type; - qp->qp.state = IBV_QPS_UNKNOWN; - qp->qp.events_completed = 0; - pthread_mutex_init(&qp->qp.mutex, NULL); - pthread_cond_init(&qp->qp.cond, NULL); - qp->comp_mask = 0; - if (vext_field_avail(struct verbs_qp, xrcd, vqp_sz)) { - qp->comp_mask = VERBS_QP_XRCD; - qp->xrcd = xrcd; - } - - return 0; -} - -int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr, - struct ibv_query_qp *cmd, size_t cmd_size) -{ - struct ibv_query_qp_resp resp; - - /* - * Masks over IBV_QP_DEST_QPN are not supported by - * that not extended command. - */ - if (attr_mask & ~((IBV_QP_DEST_QPN << 1) - 1)) - return EOPNOTSUPP; - - IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_QP, &resp, sizeof resp); - cmd->qp_handle = qp->handle; - cmd->attr_mask = attr_mask; - - if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - attr->qkey = resp.qkey; - attr->rq_psn = resp.rq_psn; - attr->sq_psn = resp.sq_psn; - attr->dest_qp_num = resp.dest_qp_num; - attr->qp_access_flags = resp.qp_access_flags; - attr->pkey_index = resp.pkey_index; - attr->alt_pkey_index = resp.alt_pkey_index; - attr->qp_state = resp.qp_state; - attr->cur_qp_state = resp.cur_qp_state; - attr->path_mtu = resp.path_mtu; - attr->path_mig_state = resp.path_mig_state; - attr->sq_draining = resp.sq_draining; - attr->max_rd_atomic = resp.max_rd_atomic; - attr->max_dest_rd_atomic = resp.max_dest_rd_atomic; - attr->min_rnr_timer = resp.min_rnr_timer; - attr->port_num = resp.port_num; - attr->timeout = resp.timeout; - attr->retry_cnt = resp.retry_cnt; - attr->rnr_retry = resp.rnr_retry; - attr->alt_port_num = resp.alt_port_num; - attr->alt_timeout = resp.alt_timeout; - attr->cap.max_send_wr = resp.max_send_wr; - attr->cap.max_recv_wr = resp.max_recv_wr; - attr->cap.max_send_sge = resp.max_send_sge; - attr->cap.max_recv_sge = resp.max_recv_sge; - attr->cap.max_inline_data = resp.max_inline_data; - - memcpy(attr->ah_attr.grh.dgid.raw, resp.dest.dgid, 16); - attr->ah_attr.grh.flow_label = resp.dest.flow_label; - attr->ah_attr.dlid = resp.dest.dlid; - attr->ah_attr.grh.sgid_index = resp.dest.sgid_index; - attr->ah_attr.grh.hop_limit = resp.dest.hop_limit; - attr->ah_attr.grh.traffic_class = resp.dest.traffic_class; - attr->ah_attr.sl = resp.dest.sl; - attr->ah_attr.src_path_bits = resp.dest.src_path_bits; - attr->ah_attr.static_rate = resp.dest.static_rate; - attr->ah_attr.is_global = resp.dest.is_global; - attr->ah_attr.port_num = resp.dest.port_num; - - memcpy(attr->alt_ah_attr.grh.dgid.raw, resp.alt_dest.dgid, 16); - attr->alt_ah_attr.grh.flow_label = resp.alt_dest.flow_label; - attr->alt_ah_attr.dlid = resp.alt_dest.dlid; - attr->alt_ah_attr.grh.sgid_index = resp.alt_dest.sgid_index; - attr->alt_ah_attr.grh.hop_limit = resp.alt_dest.hop_limit; - attr->alt_ah_attr.grh.traffic_class = resp.alt_dest.traffic_class; - attr->alt_ah_attr.sl = resp.alt_dest.sl; - attr->alt_ah_attr.src_path_bits = resp.alt_dest.src_path_bits; - attr->alt_ah_attr.static_rate = resp.alt_dest.static_rate; - attr->alt_ah_attr.is_global = resp.alt_dest.is_global; - attr->alt_ah_attr.port_num = resp.alt_dest.port_num; - - init_attr->qp_context = qp->qp_context; - init_attr->send_cq = qp->send_cq; - init_attr->recv_cq = qp->recv_cq; - init_attr->srq = qp->srq; - init_attr->qp_type = qp->qp_type; - init_attr->cap.max_send_wr = resp.max_send_wr; - init_attr->cap.max_recv_wr = resp.max_recv_wr; - init_attr->cap.max_send_sge = resp.max_send_sge; - init_attr->cap.max_recv_sge = resp.max_recv_sge; - init_attr->cap.max_inline_data = resp.max_inline_data; - init_attr->sq_sig_all = resp.sq_sig_all; - - return 0; -} - -static void copy_modify_qp_fields(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_modify_qp_common *cmd) -{ - cmd->qp_handle = qp->handle; - cmd->attr_mask = attr_mask; - - if (attr_mask & IBV_QP_STATE) - cmd->qp_state = attr->qp_state; - if (attr_mask & IBV_QP_CUR_STATE) - cmd->cur_qp_state = attr->cur_qp_state; - if (attr_mask & IBV_QP_EN_SQD_ASYNC_NOTIFY) - cmd->en_sqd_async_notify = attr->en_sqd_async_notify; - if (attr_mask & IBV_QP_ACCESS_FLAGS) - cmd->qp_access_flags = attr->qp_access_flags; - if (attr_mask & IBV_QP_PKEY_INDEX) - cmd->pkey_index = attr->pkey_index; - if (attr_mask & IBV_QP_PORT) - cmd->port_num = attr->port_num; - if (attr_mask & IBV_QP_QKEY) - cmd->qkey = attr->qkey; - - if (attr_mask & IBV_QP_AV) { - memcpy(cmd->dest.dgid, attr->ah_attr.grh.dgid.raw, 16); - cmd->dest.flow_label = attr->ah_attr.grh.flow_label; - cmd->dest.dlid = attr->ah_attr.dlid; - cmd->dest.reserved = 0; - cmd->dest.sgid_index = attr->ah_attr.grh.sgid_index; - cmd->dest.hop_limit = attr->ah_attr.grh.hop_limit; - cmd->dest.traffic_class = attr->ah_attr.grh.traffic_class; - cmd->dest.sl = attr->ah_attr.sl; - cmd->dest.src_path_bits = attr->ah_attr.src_path_bits; - cmd->dest.static_rate = attr->ah_attr.static_rate; - cmd->dest.is_global = attr->ah_attr.is_global; - cmd->dest.port_num = attr->ah_attr.port_num; - } - - if (attr_mask & IBV_QP_PATH_MTU) - cmd->path_mtu = attr->path_mtu; - if (attr_mask & IBV_QP_TIMEOUT) - cmd->timeout = attr->timeout; - if (attr_mask & IBV_QP_RETRY_CNT) - cmd->retry_cnt = attr->retry_cnt; - if (attr_mask & IBV_QP_RNR_RETRY) - cmd->rnr_retry = attr->rnr_retry; - if (attr_mask & IBV_QP_RQ_PSN) - cmd->rq_psn = attr->rq_psn; - if (attr_mask & IBV_QP_MAX_QP_RD_ATOMIC) - cmd->max_rd_atomic = attr->max_rd_atomic; - - if (attr_mask & IBV_QP_ALT_PATH) { - cmd->alt_pkey_index = attr->alt_pkey_index; - cmd->alt_port_num = attr->alt_port_num; - cmd->alt_timeout = attr->alt_timeout; - - memcpy(cmd->alt_dest.dgid, attr->alt_ah_attr.grh.dgid.raw, 16); - cmd->alt_dest.flow_label = attr->alt_ah_attr.grh.flow_label; - cmd->alt_dest.dlid = attr->alt_ah_attr.dlid; - cmd->alt_dest.reserved = 0; - cmd->alt_dest.sgid_index = attr->alt_ah_attr.grh.sgid_index; - cmd->alt_dest.hop_limit = attr->alt_ah_attr.grh.hop_limit; - cmd->alt_dest.traffic_class = - attr->alt_ah_attr.grh.traffic_class; - cmd->alt_dest.sl = attr->alt_ah_attr.sl; - cmd->alt_dest.src_path_bits = attr->alt_ah_attr.src_path_bits; - cmd->alt_dest.static_rate = attr->alt_ah_attr.static_rate; - cmd->alt_dest.is_global = attr->alt_ah_attr.is_global; - cmd->alt_dest.port_num = attr->alt_ah_attr.port_num; - } - - if (attr_mask & IBV_QP_MIN_RNR_TIMER) - cmd->min_rnr_timer = attr->min_rnr_timer; - if (attr_mask & IBV_QP_SQ_PSN) - cmd->sq_psn = attr->sq_psn; - if (attr_mask & IBV_QP_MAX_DEST_RD_ATOMIC) - cmd->max_dest_rd_atomic = attr->max_dest_rd_atomic; - if (attr_mask & IBV_QP_PATH_MIG_STATE) - cmd->path_mig_state = attr->path_mig_state; - if (attr_mask & IBV_QP_DEST_QPN) - cmd->dest_qp_num = attr->dest_qp_num; - - cmd->reserved[0] = cmd->reserved[1] = 0; -} - -int ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_modify_qp *cmd, size_t cmd_size) -{ - /* - * Masks over IBV_QP_DEST_QPN are only supported by - * ibv_cmd_modify_qp_ex. - */ - if (attr_mask & ~((IBV_QP_DEST_QPN << 1) - 1)) - return EOPNOTSUPP; - - IBV_INIT_CMD(cmd, cmd_size, MODIFY_QP); - - copy_modify_qp_fields(qp, attr, attr_mask, &cmd->base); - - if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - return 0; -} - -int ibv_cmd_modify_qp_ex(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_modify_qp_ex *cmd, - size_t cmd_core_size, size_t cmd_size, - struct ibv_modify_qp_resp_ex *resp, - size_t resp_core_size, size_t resp_size) -{ - if (resp_core_size < offsetof(struct ibv_modify_qp_resp_ex, - response_length) + sizeof(resp->response_length)) - return EINVAL; - - IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, MODIFY_QP_EX, - resp, resp_core_size, resp_size); - - copy_modify_qp_fields(qp, attr, attr_mask, &cmd->base); - - if (attr_mask & IBV_QP_RATE_LIMIT) { - if (cmd_size >= offsetof(struct ibv_modify_qp_ex, rate_limit) + - sizeof(cmd->rate_limit)) - cmd->rate_limit = attr->rate_limit; - else - return EINVAL; - } - - if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - return 0; -} - -int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - struct ibv_post_send *cmd; - struct ibv_post_send_resp resp; - struct ibv_send_wr *i; - struct ibv_kern_send_wr *n, *tmp; - struct ibv_sge *s; - unsigned wr_count = 0; - unsigned sge_count = 0; - int cmd_size; - int ret = 0; - - for (i = wr; i; i = i->next) { - wr_count++; - sge_count += i->num_sge; - } - - cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s; - cmd = alloca(cmd_size); - - IBV_INIT_CMD_RESP(cmd, cmd_size, POST_SEND, &resp, sizeof resp); - cmd->qp_handle = ibqp->handle; - cmd->wr_count = wr_count; - cmd->sge_count = sge_count; - cmd->wqe_size = sizeof *n; - - n = (struct ibv_kern_send_wr *) ((void *) cmd + sizeof *cmd); - s = (struct ibv_sge *) (n + wr_count); - - tmp = n; - for (i = wr; i; i = i->next) { - tmp->wr_id = i->wr_id; - tmp->num_sge = i->num_sge; - tmp->opcode = i->opcode; - tmp->send_flags = i->send_flags; - tmp->imm_data = i->imm_data; - if (ibqp->qp_type == IBV_QPT_UD) { - tmp->wr.ud.ah = i->wr.ud.ah->handle; - tmp->wr.ud.remote_qpn = i->wr.ud.remote_qpn; - tmp->wr.ud.remote_qkey = i->wr.ud.remote_qkey; - } else { - switch (i->opcode) { - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - case IBV_WR_RDMA_READ: - tmp->wr.rdma.remote_addr = - i->wr.rdma.remote_addr; - tmp->wr.rdma.rkey = i->wr.rdma.rkey; - break; - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - tmp->wr.atomic.remote_addr = - i->wr.atomic.remote_addr; - tmp->wr.atomic.compare_add = - i->wr.atomic.compare_add; - tmp->wr.atomic.swap = i->wr.atomic.swap; - tmp->wr.atomic.rkey = i->wr.atomic.rkey; - break; - default: - break; - } - } - - if (tmp->num_sge) { - memcpy(s, i->sg_list, tmp->num_sge * sizeof *s); - s += tmp->num_sge; - } - - tmp++; - } - - resp.bad_wr = 0; - if (write(ibqp->context->cmd_fd, cmd, cmd_size) != cmd_size) - ret = errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - wr_count = resp.bad_wr; - if (wr_count) { - i = wr; - while (--wr_count) - i = i->next; - *bad_wr = i; - } else if (ret) - *bad_wr = wr; - - return ret; -} - -int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct ibv_post_recv *cmd; - struct ibv_post_recv_resp resp; - struct ibv_recv_wr *i; - struct ibv_kern_recv_wr *n, *tmp; - struct ibv_sge *s; - unsigned wr_count = 0; - unsigned sge_count = 0; - int cmd_size; - int ret = 0; - - for (i = wr; i; i = i->next) { - wr_count++; - sge_count += i->num_sge; - } - - cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s; - cmd = alloca(cmd_size); - - IBV_INIT_CMD_RESP(cmd, cmd_size, POST_RECV, &resp, sizeof resp); - cmd->qp_handle = ibqp->handle; - cmd->wr_count = wr_count; - cmd->sge_count = sge_count; - cmd->wqe_size = sizeof *n; - - n = (struct ibv_kern_recv_wr *) ((void *) cmd + sizeof *cmd); - s = (struct ibv_sge *) (n + wr_count); - - tmp = n; - for (i = wr; i; i = i->next) { - tmp->wr_id = i->wr_id; - tmp->num_sge = i->num_sge; - - if (tmp->num_sge) { - memcpy(s, i->sg_list, tmp->num_sge * sizeof *s); - s += tmp->num_sge; - } - - tmp++; - } - - resp.bad_wr = 0; - if (write(ibqp->context->cmd_fd, cmd, cmd_size) != cmd_size) - ret = errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - wr_count = resp.bad_wr; - if (wr_count) { - i = wr; - while (--wr_count) - i = i->next; - *bad_wr = i; - } else if (ret) - *bad_wr = wr; - - return ret; -} - -int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct ibv_post_srq_recv *cmd; - struct ibv_post_srq_recv_resp resp; - struct ibv_recv_wr *i; - struct ibv_kern_recv_wr *n, *tmp; - struct ibv_sge *s; - unsigned wr_count = 0; - unsigned sge_count = 0; - int cmd_size; - int ret = 0; - - for (i = wr; i; i = i->next) { - wr_count++; - sge_count += i->num_sge; - } - - cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s; - cmd = alloca(cmd_size); - - IBV_INIT_CMD_RESP(cmd, cmd_size, POST_SRQ_RECV, &resp, sizeof resp); - cmd->srq_handle = srq->handle; - cmd->wr_count = wr_count; - cmd->sge_count = sge_count; - cmd->wqe_size = sizeof *n; - - n = (struct ibv_kern_recv_wr *) ((void *) cmd + sizeof *cmd); - s = (struct ibv_sge *) (n + wr_count); - - tmp = n; - for (i = wr; i; i = i->next) { - tmp->wr_id = i->wr_id; - tmp->num_sge = i->num_sge; - - if (tmp->num_sge) { - memcpy(s, i->sg_list, tmp->num_sge * sizeof *s); - s += tmp->num_sge; - } - - tmp++; - } - - resp.bad_wr = 0; - if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size) - ret = errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - wr_count = resp.bad_wr; - if (wr_count) { - i = wr; - while (--wr_count) - i = i->next; - *bad_wr = i; - } else if (ret) - *bad_wr = wr; - - return ret; -} - -int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah, - struct ibv_ah_attr *attr, - struct ibv_create_ah_resp *resp, - size_t resp_size) -{ - struct ibv_create_ah cmd; - - IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_AH, resp, resp_size); - cmd.user_handle = (uintptr_t) ah; - cmd.pd_handle = pd->handle; - cmd.attr.dlid = attr->dlid; - cmd.attr.sl = attr->sl; - cmd.attr.src_path_bits = attr->src_path_bits; - cmd.attr.static_rate = attr->static_rate; - cmd.attr.is_global = attr->is_global; - cmd.attr.port_num = attr->port_num; - cmd.attr.grh.flow_label = attr->grh.flow_label; - cmd.attr.grh.sgid_index = attr->grh.sgid_index; - cmd.attr.grh.hop_limit = attr->grh.hop_limit; - cmd.attr.grh.traffic_class = attr->grh.traffic_class; - memcpy(cmd.attr.grh.dgid, attr->grh.dgid.raw, 16); - - if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - ah->handle = resp->handle; - ah->context = pd->context; - - return 0; -} - -int ibv_cmd_destroy_ah(struct ibv_ah *ah) -{ - struct ibv_destroy_ah cmd; - - IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_AH); - cmd.ah_handle = ah->handle; - - if (write(ah->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - return 0; -} - -int ibv_cmd_destroy_qp(struct ibv_qp *qp) -{ - struct ibv_destroy_qp cmd; - struct ibv_destroy_qp_resp resp; - - IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_QP, &resp, sizeof resp); - cmd.qp_handle = qp->handle; - cmd.reserved = 0; - - if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - pthread_mutex_lock(&qp->mutex); - while (qp->events_completed != resp.events_reported) - pthread_cond_wait(&qp->cond, &qp->mutex); - pthread_mutex_unlock(&qp->mutex); - - return 0; -} - -int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - struct ibv_attach_mcast cmd; - - IBV_INIT_CMD(&cmd, sizeof cmd, ATTACH_MCAST); - memcpy(cmd.gid, gid->raw, sizeof cmd.gid); - cmd.qp_handle = qp->handle; - cmd.mlid = lid; - cmd.reserved = 0; - - if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - return 0; -} - -int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - struct ibv_detach_mcast cmd; - - IBV_INIT_CMD(&cmd, sizeof cmd, DETACH_MCAST); - memcpy(cmd.gid, gid->raw, sizeof cmd.gid); - cmd.qp_handle = qp->handle; - cmd.mlid = lid; - cmd.reserved = 0; - - if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) - return errno; - - return 0; -} - -static int buffer_is_zero(char *addr, ssize_t size) -{ - return addr[0] == 0 && !memcmp(addr, addr + 1, size - 1); -} - -static int get_filters_size(struct ibv_flow_spec *ib_spec, - struct ibv_kern_spec *kern_spec, - int *ib_filter_size, int *kern_filter_size, - enum ibv_flow_spec_type type) -{ - void *ib_spec_filter_mask; - int curr_kern_filter_size; - int min_filter_size; - - *ib_filter_size = (ib_spec->hdr.size - sizeof(ib_spec->hdr)) / 2; - - switch (type) { - case IBV_FLOW_SPEC_IPV4_EXT: - min_filter_size = - offsetof(struct ibv_kern_ipv4_ext_filter, flags) + - sizeof(kern_spec->ipv4_ext.mask.flags); - curr_kern_filter_size = min_filter_size; - ib_spec_filter_mask = (void *)&ib_spec->ipv4_ext.val + - *ib_filter_size; - break; - case IBV_FLOW_SPEC_IPV6: - min_filter_size = - offsetof(struct ibv_kern_ipv6_filter, hop_limit) + - sizeof(kern_spec->ipv6.mask.hop_limit); - curr_kern_filter_size = min_filter_size; - ib_spec_filter_mask = (void *)&ib_spec->ipv6.val + - *ib_filter_size; - break; - case IBV_FLOW_SPEC_VXLAN_TUNNEL: - min_filter_size = - offsetof(struct ibv_kern_tunnel_filter, - tunnel_id) + - sizeof(kern_spec->tunnel.mask.tunnel_id); - curr_kern_filter_size = min_filter_size; - ib_spec_filter_mask = (void *)&ib_spec->tunnel.val + - *ib_filter_size; - break; - default: - return EINVAL; - } - - if (*ib_filter_size < min_filter_size) - return EINVAL; - - if (*ib_filter_size > curr_kern_filter_size && - !buffer_is_zero(ib_spec_filter_mask + curr_kern_filter_size, - *ib_filter_size - curr_kern_filter_size)) - return EOPNOTSUPP; - - *kern_filter_size = min_t(int, curr_kern_filter_size, *ib_filter_size); - - return 0; -} - -static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, - struct ibv_kern_spec *kern_spec) -{ - int kern_filter_size; - int ib_filter_size; - int ret; - - kern_spec->hdr.type = ib_spec->hdr.type; - - switch (kern_spec->hdr.type) { - case IBV_FLOW_SPEC_ETH: - case IBV_FLOW_SPEC_ETH | IBV_FLOW_SPEC_INNER: - kern_spec->eth.size = sizeof(struct ibv_kern_spec_eth); - memcpy(&kern_spec->eth.val, &ib_spec->eth.val, - sizeof(struct ibv_flow_eth_filter)); - memcpy(&kern_spec->eth.mask, &ib_spec->eth.mask, - sizeof(struct ibv_flow_eth_filter)); - break; - case IBV_FLOW_SPEC_IPV4: - case IBV_FLOW_SPEC_IPV4 | IBV_FLOW_SPEC_INNER: - kern_spec->ipv4.size = sizeof(struct ibv_kern_spec_ipv4); - memcpy(&kern_spec->ipv4.val, &ib_spec->ipv4.val, - sizeof(struct ibv_flow_ipv4_filter)); - memcpy(&kern_spec->ipv4.mask, &ib_spec->ipv4.mask, - sizeof(struct ibv_flow_ipv4_filter)); - break; - case IBV_FLOW_SPEC_IPV4_EXT: - case IBV_FLOW_SPEC_IPV4_EXT | IBV_FLOW_SPEC_INNER: - ret = get_filters_size(ib_spec, kern_spec, - &ib_filter_size, &kern_filter_size, - IBV_FLOW_SPEC_IPV4_EXT); - if (ret) - return ret; - - kern_spec->hdr.type = IBV_FLOW_SPEC_IPV4 | - (IBV_FLOW_SPEC_INNER & ib_spec->hdr.type); - kern_spec->ipv4_ext.size = sizeof(struct - ibv_kern_spec_ipv4_ext); - memcpy(&kern_spec->ipv4_ext.val, &ib_spec->ipv4_ext.val, - kern_filter_size); - memcpy(&kern_spec->ipv4_ext.mask, (void *)&ib_spec->ipv4_ext.val - + ib_filter_size, kern_filter_size); - break; - case IBV_FLOW_SPEC_IPV6: - case IBV_FLOW_SPEC_IPV6 | IBV_FLOW_SPEC_INNER: - ret = get_filters_size(ib_spec, kern_spec, - &ib_filter_size, &kern_filter_size, - IBV_FLOW_SPEC_IPV6); - if (ret) - return ret; - - kern_spec->ipv6.size = sizeof(struct ibv_kern_spec_ipv6); - memcpy(&kern_spec->ipv6.val, &ib_spec->ipv6.val, - kern_filter_size); - memcpy(&kern_spec->ipv6.mask, (void *)&ib_spec->ipv6.val - + ib_filter_size, kern_filter_size); - break; - case IBV_FLOW_SPEC_TCP: - case IBV_FLOW_SPEC_UDP: - case IBV_FLOW_SPEC_TCP | IBV_FLOW_SPEC_INNER: - case IBV_FLOW_SPEC_UDP | IBV_FLOW_SPEC_INNER: - kern_spec->tcp_udp.size = sizeof(struct ibv_kern_spec_tcp_udp); - memcpy(&kern_spec->tcp_udp.val, &ib_spec->tcp_udp.val, - sizeof(struct ibv_flow_ipv4_filter)); - memcpy(&kern_spec->tcp_udp.mask, &ib_spec->tcp_udp.mask, - sizeof(struct ibv_flow_tcp_udp_filter)); - break; - case IBV_FLOW_SPEC_VXLAN_TUNNEL: - ret = get_filters_size(ib_spec, kern_spec, - &ib_filter_size, &kern_filter_size, - IBV_FLOW_SPEC_VXLAN_TUNNEL); - if (ret) - return ret; - - kern_spec->tunnel.size = sizeof(struct ibv_kern_spec_tunnel); - memcpy(&kern_spec->tunnel.val, &ib_spec->tunnel.val, - kern_filter_size); - memcpy(&kern_spec->tunnel.mask, (void *)&ib_spec->tunnel.val - + ib_filter_size, kern_filter_size); - break; - case IBV_FLOW_SPEC_ACTION_TAG: - kern_spec->flow_tag.size = - sizeof(struct ibv_kern_spec_action_tag); - kern_spec->flow_tag.tag_id = ib_spec->flow_tag.tag_id; - break; - case IBV_FLOW_SPEC_ACTION_DROP: - kern_spec->drop.size = sizeof(struct ibv_kern_spec_action_drop); - break; - default: - return EINVAL; - } - return 0; -} - -struct ibv_flow *ibv_cmd_create_flow(struct ibv_qp *qp, - struct ibv_flow_attr *flow_attr) -{ - struct ibv_create_flow *cmd; - struct ibv_create_flow_resp resp; - struct ibv_flow *flow_id; - size_t cmd_size; - size_t written_size; - int i, err; - void *kern_spec; - void *ib_spec; - - cmd_size = sizeof(*cmd) + (flow_attr->num_of_specs * - sizeof(struct ibv_kern_spec)); - cmd = alloca(cmd_size); - flow_id = malloc(sizeof(*flow_id)); - if (!flow_id) - return NULL; - memset(cmd, 0, cmd_size); - - cmd->qp_handle = qp->handle; - - cmd->flow_attr.type = flow_attr->type; - cmd->flow_attr.priority = flow_attr->priority; - cmd->flow_attr.num_of_specs = flow_attr->num_of_specs; - cmd->flow_attr.port = flow_attr->port; - cmd->flow_attr.flags = flow_attr->flags; - - kern_spec = cmd + 1; - ib_spec = flow_attr + 1; - for (i = 0; i < flow_attr->num_of_specs; i++) { - err = ib_spec_to_kern_spec(ib_spec, kern_spec); - if (err) { - errno = err; - goto err; - } - cmd->flow_attr.size += - ((struct ibv_kern_spec *)kern_spec)->hdr.size; - kern_spec += ((struct ibv_kern_spec *)kern_spec)->hdr.size; - ib_spec += ((struct ibv_flow_spec *)ib_spec)->hdr.size; - } - - written_size = sizeof(*cmd) + cmd->flow_attr.size; - IBV_INIT_CMD_RESP_EX_VCMD(cmd, written_size, written_size, CREATE_FLOW, - &resp, sizeof(resp)); - if (write(qp->context->cmd_fd, cmd, written_size) != written_size) - goto err; - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof(resp)); - - flow_id->context = qp->context; - flow_id->handle = resp.flow_handle; - return flow_id; -err: - free(flow_id); - return NULL; -} - -int ibv_cmd_destroy_flow(struct ibv_flow *flow_id) -{ - struct ibv_destroy_flow cmd; - int ret = 0; - - memset(&cmd, 0, sizeof(cmd)); - IBV_INIT_CMD_EX(&cmd, sizeof(cmd), DESTROY_FLOW); - cmd.flow_handle = flow_id->handle; - - if (write(flow_id->context->cmd_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) - ret = errno; - free(flow_id); - return ret; -} - -int ibv_cmd_create_wq(struct ibv_context *context, - struct ibv_wq_init_attr *wq_init_attr, - struct ibv_wq *wq, - struct ibv_create_wq *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_create_wq_resp *resp, - size_t resp_core_size, - size_t resp_size) -{ - int err; - - if (wq_init_attr->comp_mask >= IBV_WQ_INIT_ATTR_RESERVED) - return EINVAL; - - IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, - CREATE_WQ, resp, - resp_core_size, resp_size); - - cmd->user_handle = (uintptr_t)wq; - cmd->pd_handle = wq_init_attr->pd->handle; - cmd->cq_handle = wq_init_attr->cq->handle; - cmd->wq_type = wq_init_attr->wq_type; - cmd->max_sge = wq_init_attr->max_sge; - cmd->max_wr = wq_init_attr->max_wr; - cmd->comp_mask = 0; - - if (cmd_core_size >= offsetof(struct ibv_create_wq, create_flags) + - sizeof(cmd->create_flags)) { - if (wq_init_attr->comp_mask & IBV_WQ_INIT_ATTR_FLAGS) { - if (wq_init_attr->create_flags & ~(IBV_WQ_FLAGS_RESERVED - 1)) - return EOPNOTSUPP; - cmd->create_flags = wq_init_attr->create_flags; - } - } - - err = write(context->cmd_fd, cmd, cmd_size); - if (err != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - if (resp->response_length < resp_core_size) - return EINVAL; - - wq->handle = resp->wq_handle; - wq_init_attr->max_wr = resp->max_wr; - wq_init_attr->max_sge = resp->max_sge; - wq->wq_num = resp->wqn; - wq->context = context; - wq->cq = wq_init_attr->cq; - wq->pd = wq_init_attr->pd; - wq->wq_type = wq_init_attr->wq_type; - - return 0; -} - -int ibv_cmd_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr, - struct ibv_modify_wq *cmd, size_t cmd_core_size, - size_t cmd_size) -{ - if (attr->attr_mask >= IBV_WQ_ATTR_RESERVED) - return EINVAL; - - memset(cmd, 0, cmd_core_size); - IBV_INIT_CMD_EX(cmd, cmd_size, MODIFY_WQ); - - cmd->curr_wq_state = attr->curr_wq_state; - cmd->wq_state = attr->wq_state; - if (cmd_core_size >= offsetof(struct ibv_modify_wq, flags_mask) + - sizeof(cmd->flags_mask)) { - if (attr->attr_mask & IBV_WQ_ATTR_FLAGS) { - if (attr->flags_mask & ~(IBV_WQ_FLAGS_RESERVED - 1)) - return EOPNOTSUPP; - cmd->flags = attr->flags; - cmd->flags_mask = attr->flags_mask; - } - } - cmd->wq_handle = wq->handle; - cmd->attr_mask = attr->attr_mask; - - if (write(wq->context->cmd_fd, cmd, cmd_size) != cmd_size) - return errno; - - if (attr->attr_mask & IBV_WQ_ATTR_STATE) - wq->state = attr->wq_state; - - return 0; -} - -int ibv_cmd_destroy_wq(struct ibv_wq *wq) -{ - struct ibv_destroy_wq cmd; - struct ibv_destroy_wq_resp resp; - int ret = 0; - - memset(&cmd, 0, sizeof(cmd)); - memset(&resp, 0, sizeof(resp)); - - IBV_INIT_CMD_RESP_EX(&cmd, sizeof(cmd), DESTROY_WQ, &resp, sizeof(resp)); - cmd.wq_handle = wq->handle; - - if (write(wq->context->cmd_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) - return errno; - - if (resp.response_length < sizeof(resp)) - return EINVAL; - - pthread_mutex_lock(&wq->mutex); - while (wq->events_completed != resp.events_reported) - pthread_cond_wait(&wq->cond, &wq->mutex); - pthread_mutex_unlock(&wq->mutex); - - return ret; -} - -int ibv_cmd_create_rwq_ind_table(struct ibv_context *context, - struct ibv_rwq_ind_table_init_attr *init_attr, - struct ibv_rwq_ind_table *rwq_ind_table, - struct ibv_create_rwq_ind_table *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_create_rwq_ind_table_resp *resp, - size_t resp_core_size, - size_t resp_size) -{ - int err, i; - uint32_t required_tbl_size, alloc_tbl_size; - uint32_t *tbl_start; - int num_tbl_entries; - - if (init_attr->comp_mask >= IBV_CREATE_IND_TABLE_RESERVED) - return EINVAL; - - alloc_tbl_size = cmd_core_size - sizeof(*cmd); - num_tbl_entries = 1 << init_attr->log_ind_tbl_size; - - /* Data must be u64 aligned */ - required_tbl_size = (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ? - sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t)); - - if (alloc_tbl_size < required_tbl_size) - return EINVAL; - - tbl_start = (uint32_t *)((uint8_t *)cmd + sizeof(*cmd)); - for (i = 0; i < num_tbl_entries; i++) - tbl_start[i] = init_attr->ind_tbl[i]->handle; - - IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, - CREATE_RWQ_IND_TBL, resp, - resp_core_size, resp_size); - cmd->log_ind_tbl_size = init_attr->log_ind_tbl_size; - cmd->comp_mask = 0; - - err = write(context->cmd_fd, cmd, cmd_size); - if (err != cmd_size) - return errno; - - (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - - if (resp->response_length < resp_core_size) - return EINVAL; - - rwq_ind_table->ind_tbl_handle = resp->ind_tbl_handle; - rwq_ind_table->ind_tbl_num = resp->ind_tbl_num; - rwq_ind_table->context = context; - return 0; -} - -int ibv_cmd_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table) -{ - struct ibv_destroy_rwq_ind_table cmd; - int ret = 0; - - memset(&cmd, 0, sizeof(cmd)); - IBV_INIT_CMD_EX(&cmd, sizeof(cmd), DESTROY_RWQ_IND_TBL); - cmd.ind_tbl_handle = rwq_ind_table->ind_tbl_handle; - - if (write(rwq_ind_table->context->cmd_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) - ret = errno; - - return ret; -} diff --git a/usr/rdma-core/libibverbs/compat-1_0.c b/usr/rdma-core/libibverbs/compat-1_0.c deleted file mode 100644 index 695f89dea..000000000 --- a/usr/rdma-core/libibverbs/compat-1_0.c +++ /dev/null @@ -1,987 +0,0 @@ -/* - * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include - -#include -#include "ibverbs.h" - -struct ibv_pd_1_0 { - struct ibv_context_1_0 *context; - uint32_t handle; - - struct ibv_pd *real_pd; -}; - -struct ibv_mr_1_0 { - struct ibv_context_1_0 *context; - struct ibv_pd_1_0 *pd; - uint32_t handle; - uint32_t lkey; - uint32_t rkey; - - struct ibv_mr *real_mr; -}; - -struct ibv_srq_1_0 { - struct ibv_context_1_0 *context; - void *srq_context; - struct ibv_pd_1_0 *pd; - uint32_t handle; - - pthread_mutex_t mutex; - pthread_cond_t cond; - uint32_t events_completed; - - struct ibv_srq *real_srq; -}; - -struct ibv_qp_init_attr_1_0 { - void *qp_context; - struct ibv_cq_1_0 *send_cq; - struct ibv_cq_1_0 *recv_cq; - struct ibv_srq_1_0 *srq; - struct ibv_qp_cap cap; - enum ibv_qp_type qp_type; - int sq_sig_all; -}; - -struct ibv_send_wr_1_0 { - struct ibv_send_wr_1_0 *next; - uint64_t wr_id; - struct ibv_sge *sg_list; - int num_sge; - enum ibv_wr_opcode opcode; - int send_flags; - __be32 imm_data; - union { - struct { - uint64_t remote_addr; - uint32_t rkey; - } rdma; - struct { - uint64_t remote_addr; - uint64_t compare_add; - uint64_t swap; - uint32_t rkey; - } atomic; - struct { - struct ibv_ah_1_0 *ah; - uint32_t remote_qpn; - uint32_t remote_qkey; - } ud; - } wr; -}; - -struct ibv_recv_wr_1_0 { - struct ibv_recv_wr_1_0 *next; - uint64_t wr_id; - struct ibv_sge *sg_list; - int num_sge; -}; - -struct ibv_qp_1_0 { - struct ibv_context_1_0 *context; - void *qp_context; - struct ibv_pd_1_0 *pd; - struct ibv_cq_1_0 *send_cq; - struct ibv_cq_1_0 *recv_cq; - struct ibv_srq_1_0 *srq; - uint32_t handle; - uint32_t qp_num; - enum ibv_qp_state state; - enum ibv_qp_type qp_type; - - pthread_mutex_t mutex; - pthread_cond_t cond; - uint32_t events_completed; - - struct ibv_qp *real_qp; -}; - -struct ibv_cq_1_0 { - struct ibv_context_1_0 *context; - void *cq_context; - uint32_t handle; - int cqe; - - pthread_mutex_t mutex; - pthread_cond_t cond; - uint32_t comp_events_completed; - uint32_t async_events_completed; - - struct ibv_cq *real_cq; -}; - -struct ibv_ah_1_0 { - struct ibv_context_1_0 *context; - struct ibv_pd_1_0 *pd; - uint32_t handle; - - struct ibv_ah *real_ah; -}; - -struct ibv_device_1_0 { - void *obsolete_sysfs_dev; - void *obsolete_sysfs_ibdev; - struct ibv_device *real_device; /* was obsolete driver member */ - struct _ibv_device_ops _ops; -}; - -struct ibv_context_ops_1_0 { - int (*query_device)(struct ibv_context *context, - struct ibv_device_attr *device_attr); - int (*query_port)(struct ibv_context *context, uint8_t port_num, - struct ibv_port_attr *port_attr); - struct ibv_pd * (*alloc_pd)(struct ibv_context *context); - int (*dealloc_pd)(struct ibv_pd *pd); - struct ibv_mr * (*reg_mr)(struct ibv_pd *pd, void *addr, size_t length, - int access); - int (*dereg_mr)(struct ibv_mr *mr); - struct ibv_cq * (*create_cq)(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); - int (*poll_cq)(struct ibv_cq_1_0 *cq, int num_entries, - struct ibv_wc *wc); - int (*req_notify_cq)(struct ibv_cq_1_0 *cq, - int solicited_only); - void (*cq_event)(struct ibv_cq *cq); - int (*resize_cq)(struct ibv_cq *cq, int cqe); - int (*destroy_cq)(struct ibv_cq *cq); - struct ibv_srq * (*create_srq)(struct ibv_pd *pd, - struct ibv_srq_init_attr *srq_init_attr); - int (*modify_srq)(struct ibv_srq *srq, - struct ibv_srq_attr *srq_attr, - int srq_attr_mask); - int (*query_srq)(struct ibv_srq *srq, - struct ibv_srq_attr *srq_attr); - int (*destroy_srq)(struct ibv_srq *srq); - int (*post_srq_recv)(struct ibv_srq_1_0 *srq, - struct ibv_recv_wr_1_0 *recv_wr, - struct ibv_recv_wr_1_0 **bad_recv_wr); - struct ibv_qp * (*create_qp)(struct ibv_pd *pd, struct ibv_qp_init_attr *attr); - int (*query_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); - int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); - int (*destroy_qp)(struct ibv_qp *qp); - int (*post_send)(struct ibv_qp_1_0 *qp, - struct ibv_send_wr_1_0 *wr, - struct ibv_send_wr_1_0 **bad_wr); - int (*post_recv)(struct ibv_qp_1_0 *qp, - struct ibv_recv_wr_1_0 *wr, - struct ibv_recv_wr_1_0 **bad_wr); - struct ibv_ah * (*create_ah)(struct ibv_pd *pd, struct ibv_ah_attr *attr); - int (*destroy_ah)(struct ibv_ah *ah); - int (*attach_mcast)(struct ibv_qp *qp, union ibv_gid *gid, - uint16_t lid); - int (*detach_mcast)(struct ibv_qp *qp, union ibv_gid *gid, - uint16_t lid); -}; - -struct ibv_context_1_0 { - struct ibv_device_1_0 *device; - struct ibv_context_ops_1_0 ops; - int cmd_fd; - int async_fd; - int num_comp_vectors; - - struct ibv_context *real_context; /* was abi_compat member */ -}; - -typedef struct ibv_device *(*ibv_driver_init_func_1_1)(const char *uverbs_sys_path, - int abi_version); - -COMPAT_SYMVER_FUNC(ibv_get_device_list, 1_0, "IBVERBS_1.0", - struct ibv_device_1_0 **, - int *num) -{ - struct ibv_device **real_list; - struct ibv_device_1_0 **l; - int i, n; - - real_list = ibv_get_device_list(&n); - if (!real_list) - return NULL; - - l = calloc(n + 2, sizeof (struct ibv_device_1_0 *)); - if (!l) - goto free_device_list; - - l[0] = (void *) real_list; - - for (i = 0; i < n; ++i) { - l[i + 1] = calloc(1, sizeof (struct ibv_device_1_0)); - if (!l[i + 1]) - goto fail; - l[i + 1]->real_device = real_list[i]; - } - - if (num) - *num = n; - - return l + 1; - -fail: - for (i = 1; i <= n; ++i) - if (l[i]) - free(l[i]); - free(l); - -free_device_list: - ibv_free_device_list(real_list); - return NULL; -} - -COMPAT_SYMVER_FUNC(ibv_free_device_list, 1_0, "IBVERBS_1.0", - void, - struct ibv_device_1_0 **list) -{ - struct ibv_device_1_0 **l = list; - - while (*l) { - free(*l); - ++l; - } - - ibv_free_device_list((void *) list[-1]); - free(list - 1); -} - -COMPAT_SYMVER_FUNC(ibv_get_device_name, 1_0, "IBVERBS_1.0", - const char *, - struct ibv_device_1_0 *device) -{ - return ibv_get_device_name(device->real_device); -} - -COMPAT_SYMVER_FUNC(ibv_get_device_guid, 1_0, "IBVERBS_1.0", - __be64, - struct ibv_device_1_0 *device) -{ - return ibv_get_device_guid(device->real_device); -} - -static int poll_cq_wrapper_1_0(struct ibv_cq_1_0 *cq, int num_entries, - struct ibv_wc *wc) -{ - return cq->context->real_context->ops.poll_cq(cq->real_cq, num_entries, wc); -} - -static int req_notify_cq_wrapper_1_0(struct ibv_cq_1_0 *cq, int sol_only) -{ - return cq->context->real_context->ops.req_notify_cq(cq->real_cq, sol_only); -} - -static int post_srq_recv_wrapper_1_0(struct ibv_srq_1_0 *srq, struct ibv_recv_wr_1_0 *wr, - struct ibv_recv_wr_1_0 **bad_wr) -{ - struct ibv_recv_wr_1_0 *w; - struct ibv_recv_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr; - int ret; - - for (w = wr; w; w = w->next) { - real_wr = alloca(sizeof *real_wr); - real_wr->wr_id = w->wr_id; - real_wr->sg_list = w->sg_list; - real_wr->num_sge = w->num_sge; - real_wr->next = NULL; - if (tail_wr) - tail_wr->next = real_wr; - else - head_wr = real_wr; - - tail_wr = real_wr; - } - - ret = srq->context->real_context->ops.post_srq_recv(srq->real_srq, head_wr, - &real_bad_wr); - - if (ret) { - for (real_wr = head_wr, w = wr; - real_wr; - real_wr = real_wr->next, w = w->next) - if (real_wr == real_bad_wr) { - *bad_wr = w; - break; - } - } - - return ret; -} - -static int post_send_wrapper_1_0(struct ibv_qp_1_0 *qp, struct ibv_send_wr_1_0 *wr, - struct ibv_send_wr_1_0 **bad_wr) -{ - struct ibv_send_wr_1_0 *w; - struct ibv_send_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr; - int is_ud = qp->qp_type == IBV_QPT_UD; - int ret; - - for (w = wr; w; w = w->next) { - real_wr = alloca(sizeof *real_wr); - real_wr->wr_id = w->wr_id; - real_wr->next = NULL; - -#define TEST_SIZE_2_POINT(f1, f2) \ - ((offsetof(struct ibv_send_wr, f1) - offsetof(struct ibv_send_wr, f2)) \ - == offsetof(struct ibv_send_wr_1_0, f1) - offsetof(struct ibv_send_wr_1_0, f2)) -#define TEST_SIZE_TO_END(f1) \ - ((sizeof(struct ibv_send_wr) - offsetof(struct ibv_send_wr, f1)) == \ - (sizeof(struct ibv_send_wr_1_0) - offsetof(struct ibv_send_wr_1_0, f1))) - - if (TEST_SIZE_TO_END (sg_list)) - memcpy(&real_wr->sg_list, &w->sg_list, sizeof *real_wr - - offsetof(struct ibv_send_wr, sg_list)); - else if (TEST_SIZE_2_POINT (imm_data, sg_list) && - TEST_SIZE_TO_END (wr)) { - /* we have alignment up to wr, but padding between - * imm_data and wr, and we know wr itself is the - * same size */ - memcpy(&real_wr->sg_list, &w->sg_list, - offsetof(struct ibv_send_wr, imm_data) - - offsetof(struct ibv_send_wr, sg_list) + - sizeof real_wr->imm_data); - memcpy(&real_wr->wr, &w->wr, sizeof real_wr->wr); - } else { - real_wr->sg_list = w->sg_list; - real_wr->num_sge = w->num_sge; - real_wr->opcode = w->opcode; - real_wr->send_flags = w->send_flags; - real_wr->imm_data = w->imm_data; - if (TEST_SIZE_TO_END (wr)) - memcpy(&real_wr->wr, &w->wr, - sizeof real_wr->wr); - else { - real_wr->wr.atomic.remote_addr = - w->wr.atomic.remote_addr; - real_wr->wr.atomic.compare_add = - w->wr.atomic.compare_add; - real_wr->wr.atomic.swap = - w->wr.atomic.swap; - real_wr->wr.atomic.rkey = - w->wr.atomic.rkey; - } - } - - if (is_ud) - real_wr->wr.ud.ah = w->wr.ud.ah->real_ah; - - if (tail_wr) - tail_wr->next = real_wr; - else - head_wr = real_wr; - - tail_wr = real_wr; - } - - ret = qp->context->real_context->ops.post_send(qp->real_qp, head_wr, - &real_bad_wr); - - if (ret) { - for (real_wr = head_wr, w = wr; - real_wr; - real_wr = real_wr->next, w = w->next) - if (real_wr == real_bad_wr) { - *bad_wr = w; - break; - } - } - - return ret; -} - -static int post_recv_wrapper_1_0(struct ibv_qp_1_0 *qp, struct ibv_recv_wr_1_0 *wr, - struct ibv_recv_wr_1_0 **bad_wr) -{ - struct ibv_recv_wr_1_0 *w; - struct ibv_recv_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr; - int ret; - - for (w = wr; w; w = w->next) { - real_wr = alloca(sizeof *real_wr); - real_wr->wr_id = w->wr_id; - real_wr->sg_list = w->sg_list; - real_wr->num_sge = w->num_sge; - real_wr->next = NULL; - if (tail_wr) - tail_wr->next = real_wr; - else - head_wr = real_wr; - - tail_wr = real_wr; - } - - ret = qp->context->real_context->ops.post_recv(qp->real_qp, head_wr, - &real_bad_wr); - - if (ret) { - for (real_wr = head_wr, w = wr; - real_wr; - real_wr = real_wr->next, w = w->next) - if (real_wr == real_bad_wr) { - *bad_wr = w; - break; - } - } - - return ret; -} - -COMPAT_SYMVER_FUNC(ibv_open_device, 1_0, "IBVERBS_1.0", - struct ibv_context_1_0 *, - struct ibv_device_1_0 *device) -{ - struct ibv_context *real_ctx; - struct ibv_context_1_0 *ctx; - - ctx = malloc(sizeof *ctx); - if (!ctx) - return NULL; - - real_ctx = ibv_open_device(device->real_device); - if (!real_ctx) { - free(ctx); - return NULL; - } - - ctx->device = device; - ctx->real_context = real_ctx; - - ctx->ops.poll_cq = poll_cq_wrapper_1_0; - ctx->ops.req_notify_cq = req_notify_cq_wrapper_1_0; - ctx->ops.post_send = post_send_wrapper_1_0; - ctx->ops.post_recv = post_recv_wrapper_1_0; - ctx->ops.post_srq_recv = post_srq_recv_wrapper_1_0; - - return ctx; -} - -COMPAT_SYMVER_FUNC(ibv_close_device, 1_0, "IBVERBS_1.0", - int, - struct ibv_context_1_0 *context) -{ - int ret; - - ret = ibv_close_device(context->real_context); - if (ret) - return ret; - - free(context); - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_get_async_event, 1_0, "IBVERBS_1.0", - int, - struct ibv_context_1_0 *context, - struct ibv_async_event *event) -{ - int ret; - - ret = ibv_get_async_event(context->real_context, event); - if (ret) - return ret; - - switch (event->event_type) { - case IBV_EVENT_CQ_ERR: - event->element.cq = event->element.cq->cq_context; - break; - - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_PATH_MIG_ERR: - case IBV_EVENT_QP_LAST_WQE_REACHED: - event->element.qp = event->element.qp->qp_context; - break; - - case IBV_EVENT_SRQ_ERR: - case IBV_EVENT_SRQ_LIMIT_REACHED: - event->element.srq = event->element.srq->srq_context; - break; - - default: - break; - } - - return ret; -} - -COMPAT_SYMVER_FUNC(ibv_ack_async_event, 1_0, "IBVERBS_1.0", - void, - struct ibv_async_event *event) -{ - struct ibv_async_event real_event = *event; - - switch (event->event_type) { - case IBV_EVENT_CQ_ERR: - real_event.element.cq = - ((struct ibv_cq_1_0 *) event->element.cq)->real_cq; - break; - - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_PATH_MIG_ERR: - case IBV_EVENT_QP_LAST_WQE_REACHED: - real_event.element.qp = - ((struct ibv_qp_1_0 *) event->element.qp)->real_qp; - break; - - case IBV_EVENT_SRQ_ERR: - case IBV_EVENT_SRQ_LIMIT_REACHED: - real_event.element.srq = - ((struct ibv_srq_1_0 *) event->element.srq)->real_srq; - break; - - default: - break; - } - - ibv_ack_async_event(&real_event); -} - -COMPAT_SYMVER_FUNC(ibv_query_device, 1_0, "IBVERBS_1.0", - int, - struct ibv_context_1_0 *context, - struct ibv_device_attr *device_attr) -{ - return ibv_query_device(context->real_context, device_attr); -} - -COMPAT_SYMVER_FUNC(ibv_query_port, 1_0, "IBVERBS_1.0", - int, - struct ibv_context_1_0 *context, - uint8_t port_num, - struct ibv_port_attr *port_attr) -{ - return ibv_query_port(context->real_context, port_num, port_attr); -} - -COMPAT_SYMVER_FUNC(ibv_query_gid, 1_0, "IBVERBS_1.0", - int, - struct ibv_context_1_0 *context, - uint8_t port_num, int index, - union ibv_gid *gid) -{ - return ibv_query_gid(context->real_context, port_num, index, gid); -} - -COMPAT_SYMVER_FUNC(ibv_query_pkey, 1_0, "IBVERBS_1.0", - int, - struct ibv_context_1_0 *context, - uint8_t port_num, int index, - __be16 *pkey) -{ - return ibv_query_pkey(context->real_context, port_num, index, pkey); -} - -COMPAT_SYMVER_FUNC(ibv_alloc_pd, 1_0, "IBVERBS_1.0", - struct ibv_pd_1_0 *, - struct ibv_context_1_0 *context) -{ - struct ibv_pd *real_pd; - struct ibv_pd_1_0 *pd; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - - real_pd = ibv_alloc_pd(context->real_context); - if (!real_pd) { - free(pd); - return NULL; - } - - pd->context = context; - pd->real_pd = real_pd; - - return pd; -} - -COMPAT_SYMVER_FUNC(ibv_dealloc_pd, 1_0, "IBVERBS_1.0", - int, - struct ibv_pd_1_0 *pd) -{ - int ret; - - ret = ibv_dealloc_pd(pd->real_pd); - if (ret) - return ret; - - free(pd); - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_reg_mr, 1_0, "IBVERBS_1.0", - struct ibv_mr_1_0 *, - struct ibv_pd_1_0 *pd, void *addr, size_t length, - int access) -{ - struct ibv_mr *real_mr; - struct ibv_mr_1_0 *mr; - - mr = malloc(sizeof *mr); - if (!mr) - return NULL; - - real_mr = ibv_reg_mr(pd->real_pd, addr, length, access); - if (!real_mr) { - free(mr); - return NULL; - } - - mr->context = pd->context; - mr->pd = pd; - mr->lkey = real_mr->lkey; - mr->rkey = real_mr->rkey; - mr->real_mr = real_mr; - - return mr; -} - -COMPAT_SYMVER_FUNC(ibv_dereg_mr, 1_0, "IBVERBS_1.0", - int, - struct ibv_mr_1_0 *mr) -{ - int ret; - - ret = ibv_dereg_mr(mr->real_mr); - if (ret) - return ret; - - free(mr); - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_create_cq, 1_0, "IBVERBS_1.0", - struct ibv_cq_1_0 *, - struct ibv_context_1_0 *context, int cqe, void *cq_context, - struct ibv_comp_channel *channel, int comp_vector) -{ - struct ibv_cq *real_cq; - struct ibv_cq_1_0 *cq; - - cq = malloc(sizeof *cq); - if (!cq) - return NULL; - - real_cq = ibv_create_cq(context->real_context, cqe, cq_context, - channel, comp_vector); - if (!real_cq) { - free(cq); - return NULL; - } - - cq->context = context; - cq->cq_context = cq_context; - cq->cqe = cqe; - cq->real_cq = real_cq; - - real_cq->cq_context = cq; - - return cq; -} - -COMPAT_SYMVER_FUNC(ibv_resize_cq, 1_0, "IBVERBS_1.0", - int, - struct ibv_cq_1_0 *cq, int cqe) -{ - return ibv_resize_cq(cq->real_cq, cqe); -} - -COMPAT_SYMVER_FUNC(ibv_destroy_cq, 1_0, "IBVERBS_1.0", - int, - struct ibv_cq_1_0 *cq) -{ - int ret; - - ret = ibv_destroy_cq(cq->real_cq); - if (ret) - return ret; - - free(cq); - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_get_cq_event, 1_0, "IBVERBS_1.0", - int, - struct ibv_comp_channel *channel, - struct ibv_cq_1_0 **cq, - void **cq_context) -{ - struct ibv_cq *real_cq; - void *cq_ptr; - int ret; - - ret = ibv_get_cq_event(channel, &real_cq, &cq_ptr); - if (ret) - return ret; - - *cq = cq_ptr; - *cq_context = (*cq)->cq_context; - - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_ack_cq_events, 1_0, "IBVERBS_1.0", - void, - struct ibv_cq_1_0 *cq, - unsigned int nevents) -{ - ibv_ack_cq_events(cq->real_cq, nevents); -} - -COMPAT_SYMVER_FUNC(ibv_create_srq, 1_0, "IBVERBS_1.0", - struct ibv_srq_1_0 *, - struct ibv_pd_1_0 *pd, - struct ibv_srq_init_attr *srq_init_attr) -{ - struct ibv_srq *real_srq; - struct ibv_srq_1_0 *srq; - - srq = malloc(sizeof *srq); - if (!srq) - return NULL; - - real_srq = ibv_create_srq(pd->real_pd, srq_init_attr); - if (!real_srq) { - free(srq); - return NULL; - } - - srq->context = pd->context; - srq->srq_context = srq_init_attr->srq_context; - srq->pd = pd; - srq->real_srq = real_srq; - - real_srq->srq_context = srq; - - return srq; -} - -COMPAT_SYMVER_FUNC(ibv_modify_srq, 1_0, "IBVERBS_1.0", - int, - struct ibv_srq_1_0 *srq, - struct ibv_srq_attr *srq_attr, - int srq_attr_mask) -{ - return ibv_modify_srq(srq->real_srq, srq_attr, srq_attr_mask); -} - -COMPAT_SYMVER_FUNC(ibv_query_srq, 1_0, "IBVERBS_1.0", - int, - struct ibv_srq_1_0 *srq, - struct ibv_srq_attr *srq_attr) -{ - return ibv_query_srq(srq->real_srq, srq_attr); -} - -COMPAT_SYMVER_FUNC(ibv_destroy_srq, 1_0, "IBVERBS_1.0", - int, - struct ibv_srq_1_0 *srq) -{ - int ret; - - ret = ibv_destroy_srq(srq->real_srq); - if (ret) - return ret; - - free(srq); - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_create_qp, 1_0, "IBVERBS_1.0", - struct ibv_qp_1_0 *, - struct ibv_pd_1_0 *pd, - struct ibv_qp_init_attr_1_0 *qp_init_attr) -{ - struct ibv_qp *real_qp; - struct ibv_qp_1_0 *qp; - struct ibv_qp_init_attr real_init_attr; - - qp = malloc(sizeof *qp); - if (!qp) - return NULL; - - real_init_attr.qp_context = qp_init_attr->qp_context; - real_init_attr.send_cq = qp_init_attr->send_cq->real_cq; - real_init_attr.recv_cq = qp_init_attr->recv_cq->real_cq; - real_init_attr.srq = qp_init_attr->srq ? - qp_init_attr->srq->real_srq : NULL; - real_init_attr.cap = qp_init_attr->cap; - real_init_attr.qp_type = qp_init_attr->qp_type; - real_init_attr.sq_sig_all = qp_init_attr->sq_sig_all; - - real_qp = ibv_create_qp(pd->real_pd, &real_init_attr); - if (!real_qp) { - free(qp); - return NULL; - } - - qp->context = pd->context; - qp->qp_context = qp_init_attr->qp_context; - qp->pd = pd; - qp->send_cq = qp_init_attr->send_cq; - qp->recv_cq = qp_init_attr->recv_cq; - qp->srq = qp_init_attr->srq; - qp->qp_type = qp_init_attr->qp_type; - qp->qp_num = real_qp->qp_num; - qp->real_qp = real_qp; - - qp_init_attr->cap = real_init_attr.cap; - - real_qp->qp_context = qp; - - return qp; -} - -COMPAT_SYMVER_FUNC(ibv_query_qp, 1_0, "IBVERBS_1.0", - int, - struct ibv_qp_1_0 *qp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr_1_0 *init_attr) -{ - struct ibv_qp_init_attr real_init_attr; - int ret; - - ret = ibv_query_qp(qp->real_qp, attr, attr_mask, &real_init_attr); - if (ret) - return ret; - - init_attr->qp_context = qp->qp_context; - init_attr->send_cq = real_init_attr.send_cq->cq_context; - init_attr->recv_cq = real_init_attr.recv_cq->cq_context; - init_attr->srq = real_init_attr.srq->srq_context; - init_attr->qp_type = real_init_attr.qp_type; - init_attr->cap = real_init_attr.cap; - init_attr->sq_sig_all = real_init_attr.sq_sig_all; - - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_modify_qp, 1_0, "IBVERBS_1.0", - int, - struct ibv_qp_1_0 *qp, - struct ibv_qp_attr *attr, - int attr_mask) -{ - return ibv_modify_qp(qp->real_qp, attr, attr_mask); -} - -COMPAT_SYMVER_FUNC(ibv_destroy_qp, 1_0, "IBVERBS_1.0", - int, - struct ibv_qp_1_0 *qp) -{ - int ret; - - ret = ibv_destroy_qp(qp->real_qp); - if (ret) - return ret; - - free(qp); - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_create_ah, 1_0, "IBVERBS_1.0", - struct ibv_ah_1_0 *, - struct ibv_pd_1_0 *pd, struct ibv_ah_attr *attr) -{ - struct ibv_ah *real_ah; - struct ibv_ah_1_0 *ah; - - ah = malloc(sizeof *ah); - if (!ah) - return NULL; - - real_ah = ibv_create_ah(pd->real_pd, attr); - if (!real_ah) { - free(ah); - return NULL; - } - - ah->context = pd->context; - ah->pd = pd; - ah->real_ah = real_ah; - - return ah; -} - -COMPAT_SYMVER_FUNC(ibv_destroy_ah, 1_0, "IBVERBS_1.0", - int, - struct ibv_ah_1_0 *ah) -{ - int ret; - - ret = ibv_destroy_ah(ah->real_ah); - if (ret) - return ret; - - free(ah); - return 0; -} - -COMPAT_SYMVER_FUNC(ibv_attach_mcast, 1_0, "IBVERBS_1.0", - int, - struct ibv_qp_1_0 *qp, union ibv_gid *gid, uint16_t lid) -{ - return ibv_attach_mcast(qp->real_qp, gid, lid); -} - -COMPAT_SYMVER_FUNC(ibv_detach_mcast, 1_0, "IBVERBS_1.0", - int, - struct ibv_qp_1_0 *qp, union ibv_gid *gid, uint16_t lid) -{ - return ibv_detach_mcast(qp->real_qp, gid, lid); -} - -COMPAT_SYMVER_FUNC(ibv_register_driver, 1_1, "IBVERBS_1.1", - void, - const char *name, ibv_driver_init_func_1_1 init_func) -{ - /* The driver interface is private as of rdma-core 13. This stub is - * left to preserve dynamic-link compatibility with old libfabrics - * usnic providers which use this function only to suppress a fprintf - * in old versions of libibverbs. */ -} diff --git a/usr/rdma-core/libibverbs/device.c b/usr/rdma-core/libibverbs/device.c deleted file mode 100644 index 16a7d4cae..000000000 --- a/usr/rdma-core/libibverbs/device.c +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "ibverbs.h" - -static pthread_mutex_t dev_list_lock = PTHREAD_MUTEX_INITIALIZER; -static int initialized; -static struct list_head device_list = LIST_HEAD_INIT(device_list); - -LATEST_SYMVER_FUNC(ibv_get_device_list, 1_1, "IBVERBS_1.1", - struct ibv_device **, - int *num) -{ - struct ibv_device **l = NULL; - struct verbs_device *device; - int num_devices; - int i = 0; - - if (num) - *num = 0; - - pthread_mutex_lock(&dev_list_lock); - if (!initialized) { - int ret = ibverbs_init(); - initialized = (ret < 0) ? ret : 1; - } - - if (initialized < 0) { - errno = -initialized; - goto out; - } - - num_devices = ibverbs_get_device_list(&device_list); - if (num_devices < 0) { - errno = -num_devices; - goto out; - } - - l = calloc(num_devices + 1, sizeof (struct ibv_device *)); - if (!l) { - errno = ENOMEM; - goto out; - } - - list_for_each(&device_list, device, entry) { - l[i] = &device->device; - ibverbs_device_hold(l[i]); - i++; - } - if (num) - *num = num_devices; -out: - pthread_mutex_unlock(&dev_list_lock); - return l; -} - -LATEST_SYMVER_FUNC(ibv_free_device_list, 1_1, "IBVERBS_1.1", - void, - struct ibv_device **list) -{ - int i; - - for (i = 0; list[i]; i++) - ibverbs_device_put(list[i]); - free(list); -} - -LATEST_SYMVER_FUNC(ibv_get_device_name, 1_1, "IBVERBS_1.1", - const char *, - struct ibv_device *device) -{ - return device->name; -} - -LATEST_SYMVER_FUNC(ibv_get_device_guid, 1_1, "IBVERBS_1.1", - __be64, - struct ibv_device *device) -{ - char attr[24]; - uint64_t guid = 0; - uint16_t parts[4]; - int i; - - if (ibv_read_sysfs_file(device->ibdev_path, "node_guid", - attr, sizeof attr) < 0) - return 0; - - if (sscanf(attr, "%hx:%hx:%hx:%hx", - parts, parts + 1, parts + 2, parts + 3) != 4) - return 0; - - for (i = 0; i < 4; ++i) - guid = (guid << 16) | parts[i]; - - return htobe64(guid); -} - -void verbs_init_cq(struct ibv_cq *cq, struct ibv_context *context, - struct ibv_comp_channel *channel, - void *cq_context) -{ - cq->context = context; - cq->channel = channel; - - if (cq->channel) { - pthread_mutex_lock(&context->mutex); - ++cq->channel->refcnt; - pthread_mutex_unlock(&context->mutex); - } - - cq->cq_context = cq_context; - cq->comp_events_completed = 0; - cq->async_events_completed = 0; - pthread_mutex_init(&cq->mutex, NULL); - pthread_cond_init(&cq->cond, NULL); -} - -static struct ibv_cq_ex * -__lib_ibv_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr) -{ - struct verbs_context *vctx = verbs_get_ctx(context); - struct ibv_cq_ex *cq; - - if (cq_attr->wc_flags & ~IBV_CREATE_CQ_SUP_WC_FLAGS) { - errno = EOPNOTSUPP; - return NULL; - } - - cq = vctx->priv->create_cq_ex(context, cq_attr); - - if (cq) - verbs_init_cq(ibv_cq_ex_to_cq(cq), context, - cq_attr->channel, cq_attr->cq_context); - - return cq; -} - -LATEST_SYMVER_FUNC(ibv_open_device, 1_1, "IBVERBS_1.1", - struct ibv_context *, - struct ibv_device *device) -{ - struct verbs_device *verbs_device = verbs_get_device(device); - char *devpath; - int cmd_fd, ret; - struct ibv_context *context; - struct verbs_context *context_ex; - - if (asprintf(&devpath, "/dev/infiniband/%s", device->dev_name) < 0) - return NULL; - - /* - * We'll only be doing writes, but we need O_RDWR in case the - * provider needs to mmap() the file. - */ - cmd_fd = open(devpath, O_RDWR | O_CLOEXEC); - free(devpath); - - if (cmd_fd < 0) - return NULL; - - if (!verbs_device->ops->init_context) { - context = verbs_device->ops->alloc_context(device, cmd_fd); - if (!context) - goto err; - } else { - struct verbs_ex_private *priv; - - /* Library now allocates the context */ - context_ex = calloc(1, sizeof(*context_ex) + - verbs_device->size_of_context); - if (!context_ex) { - errno = ENOMEM; - goto err; - } - - priv = calloc(1, sizeof(*priv)); - if (!priv) { - errno = ENOMEM; - free(context_ex); - goto err; - } - - context_ex->priv = priv; - context_ex->context.abi_compat = __VERBS_ABI_IS_EXTENDED; - context_ex->sz = sizeof(*context_ex); - - context = &context_ex->context; - ret = verbs_device->ops->init_context(verbs_device, context, cmd_fd); - if (ret) - goto verbs_err; - /* - * In order to maintain backward/forward binary compatibility - * with apps compiled against libibverbs-1.1.8 that use the - * flow steering addition, we need to set the two - * ABI_placeholder entries to match the driver set flow - * entries. This is because apps compiled against - * libibverbs-1.1.8 use an inline ibv_create_flow and - * ibv_destroy_flow function that looks in the placeholder - * spots for the proper entry points. For apps compiled - * against libibverbs-1.1.9 and later, the inline functions - * will be looking in the right place. - */ - context_ex->ABI_placeholder1 = (void (*)(void)) context_ex->ibv_create_flow; - context_ex->ABI_placeholder2 = (void (*)(void)) context_ex->ibv_destroy_flow; - - if (context_ex->create_cq_ex) { - priv->create_cq_ex = context_ex->create_cq_ex; - context_ex->create_cq_ex = __lib_ibv_create_cq_ex; - } - } - - context->device = device; - context->cmd_fd = cmd_fd; - pthread_mutex_init(&context->mutex, NULL); - - ibverbs_device_hold(device); - - return context; - -verbs_err: - free(context_ex->priv); - free(context_ex); -err: - close(cmd_fd); - return NULL; -} - -LATEST_SYMVER_FUNC(ibv_close_device, 1_1, "IBVERBS_1.1", - int, - struct ibv_context *context) -{ - int async_fd = context->async_fd; - int cmd_fd = context->cmd_fd; - int cq_fd = -1; - struct verbs_context *context_ex; - struct verbs_device *verbs_device = verbs_get_device(context->device); - struct ibv_device *device = context->device; - - context_ex = verbs_get_ctx(context); - if (context_ex) { - verbs_device->ops->uninit_context(verbs_device, context); - free(context_ex->priv); - free(context_ex); - } else { - verbs_device->ops->free_context(context); - } - - close(async_fd); - close(cmd_fd); - if (abi_ver <= 2) - close(cq_fd); - ibverbs_device_put(device); - - return 0; -} - -LATEST_SYMVER_FUNC(ibv_get_async_event, 1_1, "IBVERBS_1.1", - int, - struct ibv_context *context, - struct ibv_async_event *event) -{ - struct ibv_kern_async_event ev; - - if (read(context->async_fd, &ev, sizeof ev) != sizeof ev) - return -1; - - event->event_type = ev.event_type; - - switch (event->event_type) { - case IBV_EVENT_CQ_ERR: - event->element.cq = (void *) (uintptr_t) ev.element; - break; - - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_PATH_MIG_ERR: - case IBV_EVENT_QP_LAST_WQE_REACHED: - event->element.qp = (void *) (uintptr_t) ev.element; - break; - - case IBV_EVENT_SRQ_ERR: - case IBV_EVENT_SRQ_LIMIT_REACHED: - event->element.srq = (void *) (uintptr_t) ev.element; - break; - - case IBV_EVENT_WQ_FATAL: - event->element.wq = (void *) (uintptr_t) ev.element; - break; - default: - event->element.port_num = ev.element; - break; - } - - if (context->ops.async_event) - context->ops.async_event(event); - - return 0; -} - -LATEST_SYMVER_FUNC(ibv_ack_async_event, 1_1, "IBVERBS_1.1", - void, - struct ibv_async_event *event) -{ - switch (event->event_type) { - case IBV_EVENT_CQ_ERR: - { - struct ibv_cq *cq = event->element.cq; - - pthread_mutex_lock(&cq->mutex); - ++cq->async_events_completed; - pthread_cond_signal(&cq->cond); - pthread_mutex_unlock(&cq->mutex); - - return; - } - - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_PATH_MIG_ERR: - case IBV_EVENT_QP_LAST_WQE_REACHED: - { - struct ibv_qp *qp = event->element.qp; - - pthread_mutex_lock(&qp->mutex); - ++qp->events_completed; - pthread_cond_signal(&qp->cond); - pthread_mutex_unlock(&qp->mutex); - - return; - } - - case IBV_EVENT_SRQ_ERR: - case IBV_EVENT_SRQ_LIMIT_REACHED: - { - struct ibv_srq *srq = event->element.srq; - - pthread_mutex_lock(&srq->mutex); - ++srq->events_completed; - pthread_cond_signal(&srq->cond); - pthread_mutex_unlock(&srq->mutex); - - return; - } - - case IBV_EVENT_WQ_FATAL: - { - struct ibv_wq *wq = event->element.wq; - - pthread_mutex_lock(&wq->mutex); - ++wq->events_completed; - pthread_cond_signal(&wq->cond); - pthread_mutex_unlock(&wq->mutex); - - return; - } - - default: - return; - } -} diff --git a/usr/rdma-core/libibverbs/driver.h b/usr/rdma-core/libibverbs/driver.h deleted file mode 100644 index a3cdbe1e6..000000000 --- a/usr/rdma-core/libibverbs/driver.h +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2005 PathScale, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef INFINIBAND_DRIVER_H -#define INFINIBAND_DRIVER_H - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } -#else /* !__cplusplus */ -# define BEGIN_C_DECLS -# define END_C_DECLS -#endif /* __cplusplus */ - -struct verbs_device; - -enum verbs_xrcd_mask { - VERBS_XRCD_HANDLE = 1 << 0, - VERBS_XRCD_RESERVED = 1 << 1 -}; - -struct verbs_xrcd { - struct ibv_xrcd xrcd; - uint32_t comp_mask; - uint32_t handle; -}; - -enum verbs_srq_mask { - VERBS_SRQ_TYPE = 1 << 0, - VERBS_SRQ_XRCD = 1 << 1, - VERBS_SRQ_CQ = 1 << 2, - VERBS_SRQ_NUM = 1 << 3, - VERBS_SRQ_RESERVED = 1 << 4 -}; - -struct verbs_srq { - struct ibv_srq srq; - uint32_t comp_mask; - enum ibv_srq_type srq_type; - struct verbs_xrcd *xrcd; - struct ibv_cq *cq; - uint32_t srq_num; -}; - -enum verbs_qp_mask { - VERBS_QP_XRCD = 1 << 0, - VERBS_QP_RESERVED = 1 << 1 -}; - -enum ibv_gid_type { - IBV_GID_TYPE_IB_ROCE_V1, - IBV_GID_TYPE_ROCE_V2, -}; - -struct verbs_qp { - struct ibv_qp qp; - uint32_t comp_mask; - struct verbs_xrcd *xrcd; -}; - -enum { - VERBS_MATCH_SENTINEL = 0, - VERBS_MATCH_PCI = 1, - VERBS_MATCH_MODALIAS = 2, -}; - -struct verbs_match_ent { - void *driver_data; - const char *modalias; - uint16_t vendor; - uint16_t device; - uint8_t kind; -}; -#define VERBS_PCI_MATCH(_vendor, _device, _data) \ - { \ - .driver_data = (_data), \ - .vendor = (_vendor), \ - .device = (_device), \ - .kind = VERBS_MATCH_PCI, \ - } - -#define VERBS_MODALIAS_MATCH(_mod_str, _data) \ - { \ - .driver_data = (_data), \ - .modalias = (_mod_str), \ - .kind = VERBS_MATCH_MODALIAS, \ - } - -/* Matching on the IB device name is STRONGLY discouraged. This will only - * match if there is no device/modalias file available, and it will eventually - * be disabled entirely if the kernel supports renaming. Use is strongly - * discouraged. - */ -#define VERBS_NAME_MATCH(_name_prefix, _data) \ - { \ - .driver_data = (_data), \ - .modalias = "rdma_device:*N" _name_prefix "*", \ - .kind = VERBS_MATCH_MODALIAS, \ - } - -/* A rdma device detected in sysfs */ -struct verbs_sysfs_dev { - struct list_node entry; - void *provider_data; - const struct verbs_match_ent *match; - char sysfs_name[IBV_SYSFS_NAME_MAX]; - char ibdev_name[IBV_SYSFS_NAME_MAX]; - char sysfs_path[IBV_SYSFS_PATH_MAX]; - char ibdev_path[IBV_SYSFS_PATH_MAX]; - char modalias[512]; - int abi_ver; - struct timespec time_created; -}; - -/* Must change the PRIVATE IBVERBS_PRIVATE_ symbol if this is changed */ -struct verbs_device_ops { - const char *name; - - int match_min_abi_version; - int match_max_abi_version; - const struct verbs_match_ent *match_table; - - bool (*match_device)(struct verbs_sysfs_dev *sysfs_dev); - - /* Old interface, do not use in new code. */ - struct ibv_context *(*alloc_context)(struct ibv_device *device, - int cmd_fd); - void (*free_context)(struct ibv_context *context); - - /* New interface */ - int (*init_context)(struct verbs_device *device, - struct ibv_context *ctx, int cmd_fd); - void (*uninit_context)(struct verbs_device *device, - struct ibv_context *ctx); - - struct verbs_device *(*alloc_device)(struct verbs_sysfs_dev *sysfs_dev); - void (*uninit_device)(struct verbs_device *device); -}; - -/* Must change the PRIVATE IBVERBS_PRIVATE_ symbol if this is changed */ -struct verbs_device { - struct ibv_device device; /* Must be first */ - const struct verbs_device_ops *ops; - size_t sz; - size_t size_of_context; - atomic_int refcount; - struct list_node entry; - struct verbs_sysfs_dev *sysfs; -}; - -static inline struct verbs_device * -verbs_get_device(const struct ibv_device *dev) -{ - return container_of(dev, struct verbs_device, device); -} - -typedef struct verbs_device *(*verbs_driver_init_func)(const char *uverbs_sys_path, - int abi_version); - -/* Wire the IBVERBS_PRIVATE version number into the verbs_register_driver - * symbol name. This guarentees we link to the correct set of symbols even if - * statically linking or using a dynmic linker with symbol versioning turned - * off. - */ -#define ___make_verbs_register_driver(x) verbs_register_driver_ ## x -#define __make_verbs_register_driver(x) ___make_verbs_register_driver(x) -#define verbs_register_driver __make_verbs_register_driver(IBVERBS_PABI_VERSION) - -void verbs_register_driver(const struct verbs_device_ops *ops); - -/* Macro for providers to use to supply verbs_device_ops to the core code */ -#define PROVIDER_DRIVER(drv) \ - static __attribute__((constructor)) void drv##__register_driver(void) \ - { \ - verbs_register_driver(&drv); \ - } - -void verbs_init_cq(struct ibv_cq *cq, struct ibv_context *context, - struct ibv_comp_channel *channel, - void *cq_context); - -int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd, - size_t cmd_size, struct ibv_get_context_resp *resp, - size_t resp_size); -int ibv_cmd_query_device(struct ibv_context *context, - struct ibv_device_attr *device_attr, - uint64_t *raw_fw_ver, - struct ibv_query_device *cmd, size_t cmd_size); -int ibv_cmd_query_device_ex(struct ibv_context *context, - const struct ibv_query_device_ex_input *input, - struct ibv_device_attr_ex *attr, size_t attr_size, - uint64_t *raw_fw_ver, - struct ibv_query_device_ex *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_query_device_resp_ex *resp, - size_t resp_core_size, - size_t resp_size); -int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num, - struct ibv_port_attr *port_attr, - struct ibv_query_port *cmd, size_t cmd_size); -int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd, - struct ibv_alloc_pd *cmd, size_t cmd_size, - struct ibv_alloc_pd_resp *resp, size_t resp_size); -int ibv_cmd_dealloc_pd(struct ibv_pd *pd); -int ibv_cmd_open_xrcd(struct ibv_context *context, struct verbs_xrcd *xrcd, - int vxrcd_size, - struct ibv_xrcd_init_attr *attr, - struct ibv_open_xrcd *cmd, size_t cmd_size, - struct ibv_open_xrcd_resp *resp, size_t resp_size); -int ibv_cmd_close_xrcd(struct verbs_xrcd *xrcd); -#define IBV_CMD_REG_MR_HAS_RESP_PARAMS -int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length, - uint64_t hca_va, int access, - struct ibv_mr *mr, struct ibv_reg_mr *cmd, - size_t cmd_size, - struct ibv_reg_mr_resp *resp, size_t resp_size); -int ibv_cmd_rereg_mr(struct ibv_mr *mr, uint32_t flags, void *addr, - size_t length, uint64_t hca_va, int access, - struct ibv_pd *pd, struct ibv_rereg_mr *cmd, - size_t cmd_sz, struct ibv_rereg_mr_resp *resp, - size_t resp_sz); -int ibv_cmd_dereg_mr(struct ibv_mr *mr); -int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type, - struct ibv_mw *mw, struct ibv_alloc_mw *cmd, - size_t cmd_size, - struct ibv_alloc_mw_resp *resp, size_t resp_size); -int ibv_cmd_dealloc_mw(struct ibv_mw *mw, - struct ibv_dealloc_mw *cmd, size_t cmd_size); -int ibv_cmd_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector, struct ibv_cq *cq, - struct ibv_create_cq *cmd, size_t cmd_size, - struct ibv_create_cq_resp *resp, size_t resp_size); -int ibv_cmd_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr, - struct ibv_cq_ex *cq, - struct ibv_create_cq_ex *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_create_cq_resp_ex *resp, - size_t resp_core_size, - size_t resp_size); -int ibv_cmd_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -int ibv_cmd_req_notify_cq(struct ibv_cq *cq, int solicited_only); -#define IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS -int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe, - struct ibv_resize_cq *cmd, size_t cmd_size, - struct ibv_resize_cq_resp *resp, size_t resp_size); -int ibv_cmd_destroy_cq(struct ibv_cq *cq); - -int ibv_cmd_create_srq(struct ibv_pd *pd, - struct ibv_srq *srq, struct ibv_srq_init_attr *attr, - struct ibv_create_srq *cmd, size_t cmd_size, - struct ibv_create_srq_resp *resp, size_t resp_size); -int ibv_cmd_create_srq_ex(struct ibv_context *context, - struct verbs_srq *srq, int vsrq_sz, - struct ibv_srq_init_attr_ex *attr_ex, - struct ibv_create_xsrq *cmd, size_t cmd_size, - struct ibv_create_srq_resp *resp, size_t resp_size); -int ibv_cmd_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *srq_attr, - int srq_attr_mask, - struct ibv_modify_srq *cmd, size_t cmd_size); -int ibv_cmd_query_srq(struct ibv_srq *srq, - struct ibv_srq_attr *srq_attr, - struct ibv_query_srq *cmd, size_t cmd_size); -int ibv_cmd_destroy_srq(struct ibv_srq *srq); - -int ibv_cmd_create_qp(struct ibv_pd *pd, - struct ibv_qp *qp, struct ibv_qp_init_attr *attr, - struct ibv_create_qp *cmd, size_t cmd_size, - struct ibv_create_qp_resp *resp, size_t resp_size); -int ibv_cmd_create_qp_ex(struct ibv_context *context, - struct verbs_qp *qp, int vqp_sz, - struct ibv_qp_init_attr_ex *attr_ex, - struct ibv_create_qp *cmd, size_t cmd_size, - struct ibv_create_qp_resp *resp, size_t resp_size); -int ibv_cmd_create_qp_ex2(struct ibv_context *context, - struct verbs_qp *qp, int vqp_sz, - struct ibv_qp_init_attr_ex *qp_attr, - struct ibv_create_qp_ex *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_create_qp_resp_ex *resp, - size_t resp_core_size, - size_t resp_size); -int ibv_cmd_open_qp(struct ibv_context *context, - struct verbs_qp *qp, int vqp_sz, - struct ibv_qp_open_attr *attr, - struct ibv_open_qp *cmd, size_t cmd_size, - struct ibv_create_qp_resp *resp, size_t resp_size); -int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr, - int attr_mask, - struct ibv_qp_init_attr *qp_init_attr, - struct ibv_query_qp *cmd, size_t cmd_size); -int ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_modify_qp *cmd, size_t cmd_size); -int ibv_cmd_modify_qp_ex(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_modify_qp_ex *cmd, - size_t cmd_core_size, size_t cmd_size, - struct ibv_modify_qp_resp_ex *resp, - size_t resp_core_size, size_t resp_size); -int ibv_cmd_destroy_qp(struct ibv_qp *qp); -int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah, - struct ibv_ah_attr *attr, - struct ibv_create_ah_resp *resp, - size_t resp_size); -int ibv_cmd_destroy_ah(struct ibv_ah *ah); -int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); -int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); - -struct ibv_flow *ibv_cmd_create_flow(struct ibv_qp *qp, - struct ibv_flow_attr *flow_attr); -int ibv_cmd_destroy_flow(struct ibv_flow *flow_id); -int ibv_cmd_create_wq(struct ibv_context *context, - struct ibv_wq_init_attr *wq_init_attr, - struct ibv_wq *wq, - struct ibv_create_wq *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_create_wq_resp *resp, - size_t resp_core_size, - size_t resp_size); - -int ibv_cmd_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr, - struct ibv_modify_wq *cmd, size_t cmd_core_size, - size_t cmd_size); -int ibv_cmd_destroy_wq(struct ibv_wq *wq); -int ibv_cmd_create_rwq_ind_table(struct ibv_context *context, - struct ibv_rwq_ind_table_init_attr *init_attr, - struct ibv_rwq_ind_table *rwq_ind_table, - struct ibv_create_rwq_ind_table *cmd, - size_t cmd_core_size, - size_t cmd_size, - struct ibv_create_rwq_ind_table_resp *resp, - size_t resp_core_size, - size_t resp_size); -int ibv_cmd_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table); -int ibv_dontfork_range(void *base, size_t size); -int ibv_dofork_range(void *base, size_t size); - -/* - * sysfs helper functions - */ -const char *ibv_get_sysfs_path(void); - -int ibv_read_sysfs_file(const char *dir, const char *file, - char *buf, size_t size); - -static inline int verbs_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num) -{ - struct verbs_srq *vsrq = container_of(srq, struct verbs_srq, srq); - if (vsrq->comp_mask & VERBS_SRQ_NUM) { - *srq_num = vsrq->srq_num; - return 0; - } - return ENOSYS; -} - -int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num, - unsigned int index, enum ibv_gid_type *type); -#endif /* INFINIBAND_DRIVER_H */ diff --git a/usr/rdma-core/libibverbs/enum_strs.c b/usr/rdma-core/libibverbs/enum_strs.c deleted file mode 100644 index b9d8e2b80..000000000 --- a/usr/rdma-core/libibverbs/enum_strs.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2008 Lawrence Livermore National Laboratory - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -const char *ibv_node_type_str(enum ibv_node_type node_type) -{ - static const char *const node_type_str[] = { - [IBV_NODE_CA] = "InfiniBand channel adapter", - [IBV_NODE_SWITCH] = "InfiniBand switch", - [IBV_NODE_ROUTER] = "InfiniBand router", - [IBV_NODE_RNIC] = "iWARP NIC", - [IBV_NODE_USNIC] = "usNIC", - [IBV_NODE_USNIC_UDP] = "usNIC UDP", - }; - - if (node_type < IBV_NODE_CA || node_type > IBV_NODE_USNIC_UDP) - return "unknown"; - - return node_type_str[node_type]; -} - -const char *ibv_port_state_str(enum ibv_port_state port_state) -{ - static const char *const port_state_str[] = { - [IBV_PORT_NOP] = "no state change (NOP)", - [IBV_PORT_DOWN] = "down", - [IBV_PORT_INIT] = "init", - [IBV_PORT_ARMED] = "armed", - [IBV_PORT_ACTIVE] = "active", - [IBV_PORT_ACTIVE_DEFER] = "active defer" - }; - - if (port_state < IBV_PORT_NOP || port_state > IBV_PORT_ACTIVE_DEFER) - return "unknown"; - - return port_state_str[port_state]; -} - -const char *ibv_event_type_str(enum ibv_event_type event) -{ - static const char *const event_type_str[] = { - [IBV_EVENT_CQ_ERR] = "CQ error", - [IBV_EVENT_QP_FATAL] = "local work queue catastrophic error", - [IBV_EVENT_QP_REQ_ERR] = "invalid request local work queue error", - [IBV_EVENT_QP_ACCESS_ERR] = "local access violation work queue error", - [IBV_EVENT_COMM_EST] = "communication established", - [IBV_EVENT_SQ_DRAINED] = "send queue drained", - [IBV_EVENT_PATH_MIG] = "path migrated", - [IBV_EVENT_PATH_MIG_ERR] = "path migration request error", - [IBV_EVENT_DEVICE_FATAL] = "local catastrophic error", - [IBV_EVENT_PORT_ACTIVE] = "port active", - [IBV_EVENT_PORT_ERR] = "port error", - [IBV_EVENT_LID_CHANGE] = "LID change", - [IBV_EVENT_PKEY_CHANGE] = "P_Key change", - [IBV_EVENT_SM_CHANGE] = "SM change", - [IBV_EVENT_SRQ_ERR] = "SRQ catastrophic error", - [IBV_EVENT_SRQ_LIMIT_REACHED] = "SRQ limit reached", - [IBV_EVENT_QP_LAST_WQE_REACHED] = "last WQE reached", - [IBV_EVENT_CLIENT_REREGISTER] = "client reregistration", - [IBV_EVENT_GID_CHANGE] = "GID table change", - [IBV_EVENT_WQ_FATAL] = "WQ fatal" - }; - - if (event < IBV_EVENT_CQ_ERR || event > IBV_EVENT_GID_CHANGE) - return "unknown"; - - return event_type_str[event]; -} - -const char *ibv_wc_status_str(enum ibv_wc_status status) -{ - static const char *const wc_status_str[] = { - [IBV_WC_SUCCESS] = "success", - [IBV_WC_LOC_LEN_ERR] = "local length error", - [IBV_WC_LOC_QP_OP_ERR] = "local QP operation error", - [IBV_WC_LOC_EEC_OP_ERR] = "local EE context operation error", - [IBV_WC_LOC_PROT_ERR] = "local protection error", - [IBV_WC_WR_FLUSH_ERR] = "Work Request Flushed Error", - [IBV_WC_MW_BIND_ERR] = "memory management operation error", - [IBV_WC_BAD_RESP_ERR] = "bad response error", - [IBV_WC_LOC_ACCESS_ERR] = "local access error", - [IBV_WC_REM_INV_REQ_ERR] = "remote invalid request error", - [IBV_WC_REM_ACCESS_ERR] = "remote access error", - [IBV_WC_REM_OP_ERR] = "remote operation error", - [IBV_WC_RETRY_EXC_ERR] = "transport retry counter exceeded", - [IBV_WC_RNR_RETRY_EXC_ERR] = "RNR retry counter exceeded", - [IBV_WC_LOC_RDD_VIOL_ERR] = "local RDD violation error", - [IBV_WC_REM_INV_RD_REQ_ERR] = "remote invalid RD request", - [IBV_WC_REM_ABORT_ERR] = "aborted error", - [IBV_WC_INV_EECN_ERR] = "invalid EE context number", - [IBV_WC_INV_EEC_STATE_ERR] = "invalid EE context state", - [IBV_WC_FATAL_ERR] = "fatal error", - [IBV_WC_RESP_TIMEOUT_ERR] = "response timeout error", - [IBV_WC_GENERAL_ERR] = "general error" - }; - - if (status < IBV_WC_SUCCESS || status > IBV_WC_GENERAL_ERR) - return "unknown"; - - return wc_status_str[status]; -} diff --git a/usr/rdma-core/libibverbs/examples/CMakeLists.txt b/usr/rdma-core/libibverbs/examples/CMakeLists.txt deleted file mode 100644 index dc4c4978d..000000000 --- a/usr/rdma-core/libibverbs/examples/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# Shared example files -add_library(ibverbs_tools STATIC - pingpong.c - ) - -rdma_executable(ibv_asyncwatch asyncwatch.c) -target_link_libraries(ibv_asyncwatch LINK_PRIVATE ibverbs) - -rdma_executable(ibv_devices device_list.c) -target_link_libraries(ibv_devices LINK_PRIVATE ibverbs) - -rdma_executable(ibv_devinfo devinfo.c) -target_link_libraries(ibv_devinfo LINK_PRIVATE ibverbs) - -rdma_executable(ibv_rc_pingpong rc_pingpong.c) -target_link_libraries(ibv_rc_pingpong LINK_PRIVATE ibverbs ibverbs_tools) - -rdma_executable(ibv_srq_pingpong srq_pingpong.c) -target_link_libraries(ibv_srq_pingpong LINK_PRIVATE ibverbs ibverbs_tools) - -rdma_executable(ibv_uc_pingpong uc_pingpong.c) -target_link_libraries(ibv_uc_pingpong LINK_PRIVATE ibverbs ibverbs_tools) - -rdma_executable(ibv_ud_pingpong ud_pingpong.c) -target_link_libraries(ibv_ud_pingpong LINK_PRIVATE ibverbs ibverbs_tools) - -rdma_executable(ibv_xsrq_pingpong xsrq_pingpong.c) -target_link_libraries(ibv_xsrq_pingpong LINK_PRIVATE ibverbs ibverbs_tools) diff --git a/usr/rdma-core/libibverbs/examples/asyncwatch.c b/usr/rdma-core/libibverbs/examples/asyncwatch.c deleted file mode 100644 index 724796e58..000000000 --- a/usr/rdma-core/libibverbs/examples/asyncwatch.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include - -#include -#include - -static const char *event_name_str(enum ibv_event_type event_type) -{ - switch (event_type) { - case IBV_EVENT_DEVICE_FATAL: - return "IBV_EVENT_DEVICE_FATAL"; - case IBV_EVENT_PORT_ACTIVE: - return "IBV_EVENT_PORT_ACTIVE"; - case IBV_EVENT_PORT_ERR: - return "IBV_EVENT_PORT_ERR"; - case IBV_EVENT_LID_CHANGE: - return "IBV_EVENT_LID_CHANGE"; - case IBV_EVENT_PKEY_CHANGE: - return "IBV_EVENT_PKEY_CHANGE"; - case IBV_EVENT_SM_CHANGE: - return "IBV_EVENT_SM_CHANGE"; - case IBV_EVENT_CLIENT_REREGISTER: - return "IBV_EVENT_CLIENT_REREGISTER"; - case IBV_EVENT_GID_CHANGE: - return "IBV_EVENT_GID_CHANGE"; - - case IBV_EVENT_CQ_ERR: - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_PATH_MIG_ERR: - case IBV_EVENT_SRQ_ERR: - case IBV_EVENT_SRQ_LIMIT_REACHED: - case IBV_EVENT_QP_LAST_WQE_REACHED: - default: - return "unexpected"; - } -} - -static void usage(const char *argv0) -{ - printf("Usage:\n"); - printf(" %s start an asyncwatch process\n", argv0); - printf("\n"); - printf("Options:\n"); - printf(" -d, --ib-dev= use IB device (default first device found)\n"); - printf(" -h, --help print a help text and exit\n"); -} - -int main(int argc, char *argv[]) -{ - struct ibv_device **dev_list; - struct ibv_context *context; - struct ibv_async_event event; - char *ib_devname = NULL; - int i = 0; - - /* Force line-buffering in case stdout is redirected */ - setvbuf(stdout, NULL, _IOLBF, 0); - - while (1) { - int ret = 1; - int c; - static struct option long_options[] = { - { .name = "ib-dev", .has_arg = 1, .val = 'd' }, - { .name = "help", .has_arg = 0, .val = 'h' }, - {} - }; - - c = getopt_long(argc, argv, "d:h", long_options, NULL); - if (c == -1) - break; - switch (c) { - case 'd': - ib_devname = strdupa(optarg); - break; - case 'h': - ret = 0; - SWITCH_FALLTHROUGH; - default: - usage(argv[0]); - return ret; - } - } - dev_list = ibv_get_device_list(NULL); - if (!dev_list) { - perror("Failed to get IB devices list"); - return 1; - } - if (ib_devname) { - for (; dev_list[i]; ++i) { - if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname)) - break; - } - } - - if (!dev_list[i]) { - fprintf(stderr, "IB device %s not found\n", - ib_devname ? ib_devname : ""); - return 1; - } - - context = ibv_open_device(dev_list[i]); - if (!context) { - fprintf(stderr, "Couldn't get context for %s\n", - ibv_get_device_name(dev_list[i])); - return 1; - } - - printf("%s: async event FD %d\n", - ibv_get_device_name(dev_list[i]), context->async_fd); - - while (1) { - if (ibv_get_async_event(context, &event)) - return 1; - - printf(" event_type %s (%d), port %d\n", - event_name_str(event.event_type), - event.event_type, event.element.port_num); - - ibv_ack_async_event(&event); - } - - return 0; -} diff --git a/usr/rdma-core/libibverbs/examples/device_list.c b/usr/rdma-core/libibverbs/examples/device_list.c deleted file mode 100644 index f5602ca19..000000000 --- a/usr/rdma-core/libibverbs/examples/device_list.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2004 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include - -#include - -#include - -int main(int argc, char *argv[]) -{ - struct ibv_device **dev_list; - int num_devices, i; - - dev_list = ibv_get_device_list(&num_devices); - if (!dev_list) { - perror("Failed to get IB devices list"); - return 1; - } - - printf(" %-16s\t node GUID\n", "device"); - printf(" %-16s\t----------------\n", "------"); - - for (i = 0; i < num_devices; ++i) { - printf(" %-16s\t%016llx\n", - ibv_get_device_name(dev_list[i]), - (unsigned long long) be64toh(ibv_get_device_guid(dev_list[i]))); - } - - ibv_free_device_list(dev_list); - - return 0; -} diff --git a/usr/rdma-core/libibverbs/examples/devinfo.c b/usr/rdma-core/libibverbs/examples/devinfo.c deleted file mode 100644 index f03c53e0e..000000000 --- a/usr/rdma-core/libibverbs/examples/devinfo.c +++ /dev/null @@ -1,698 +0,0 @@ -/* - * Copyright (c) 2005 Cisco Systems. All rights reserved. - * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -static int verbose; - -static int null_gid(union ibv_gid *gid) -{ - return !(gid->raw[8] | gid->raw[9] | gid->raw[10] | gid->raw[11] | - gid->raw[12] | gid->raw[13] | gid->raw[14] | gid->raw[15]); -} - -static const char *guid_str(__be64 _node_guid, char *str) -{ - uint64_t node_guid = be64toh(_node_guid); - sprintf(str, "%04x:%04x:%04x:%04x", - (unsigned) (node_guid >> 48) & 0xffff, - (unsigned) (node_guid >> 32) & 0xffff, - (unsigned) (node_guid >> 16) & 0xffff, - (unsigned) (node_guid >> 0) & 0xffff); - return str; -} - -static const char *transport_str(enum ibv_transport_type transport) -{ - switch (transport) { - case IBV_TRANSPORT_IB: return "InfiniBand"; - case IBV_TRANSPORT_IWARP: return "iWARP"; - case IBV_TRANSPORT_USNIC: return "usNIC"; - case IBV_TRANSPORT_USNIC_UDP: return "usNIC UDP"; - default: return "invalid transport"; - } -} - -static const char *port_state_str(enum ibv_port_state pstate) -{ - switch (pstate) { - case IBV_PORT_DOWN: return "PORT_DOWN"; - case IBV_PORT_INIT: return "PORT_INIT"; - case IBV_PORT_ARMED: return "PORT_ARMED"; - case IBV_PORT_ACTIVE: return "PORT_ACTIVE"; - default: return "invalid state"; - } -} - -static const char *port_phy_state_str(uint8_t phys_state) -{ - switch (phys_state) { - case 1: return "SLEEP"; - case 2: return "POLLING"; - case 3: return "DISABLED"; - case 4: return "PORT_CONFIGURATION TRAINNING"; - case 5: return "LINK_UP"; - case 6: return "LINK_ERROR_RECOVERY"; - case 7: return "PHY TEST"; - default: return "invalid physical state"; - } -} - -static const char *atomic_cap_str(enum ibv_atomic_cap atom_cap) -{ - switch (atom_cap) { - case IBV_ATOMIC_NONE: return "ATOMIC_NONE"; - case IBV_ATOMIC_HCA: return "ATOMIC_HCA"; - case IBV_ATOMIC_GLOB: return "ATOMIC_GLOB"; - default: return "invalid atomic capability"; - } -} - -static const char *mtu_str(enum ibv_mtu max_mtu) -{ - switch (max_mtu) { - case IBV_MTU_256: return "256"; - case IBV_MTU_512: return "512"; - case IBV_MTU_1024: return "1024"; - case IBV_MTU_2048: return "2048"; - case IBV_MTU_4096: return "4096"; - default: return "invalid MTU"; - } -} - -static const char *width_str(uint8_t width) -{ - switch (width) { - case 1: return "1"; - case 2: return "4"; - case 4: return "8"; - case 8: return "12"; - default: return "invalid width"; - } -} - -static const char *speed_str(uint8_t speed) -{ - switch (speed) { - case 1: return "2.5 Gbps"; - case 2: return "5.0 Gbps"; - - case 4: /* fall through */ - case 8: return "10.0 Gbps"; - - case 16: return "14.0 Gbps"; - case 32: return "25.0 Gbps"; - default: return "invalid speed"; - } -} - -static const char *vl_str(uint8_t vl_num) -{ - switch (vl_num) { - case 1: return "1"; - case 2: return "2"; - case 3: return "4"; - case 4: return "8"; - case 5: return "15"; - default: return "invalid value"; - } -} - -static int print_all_port_gids(struct ibv_context *ctx, uint8_t port_num, int tbl_len) -{ - union ibv_gid gid; - int rc = 0; - int i; - - for (i = 0; i < tbl_len; i++) { - rc = ibv_query_gid(ctx, port_num, i, &gid); - if (rc) { - fprintf(stderr, "Failed to query gid to port %d, index %d\n", - port_num, i); - return rc; - } - if (!null_gid(&gid)) - printf("\t\t\tGID[%3d]:\t\t%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n", - i, - gid.raw[ 0], gid.raw[ 1], - gid.raw[ 2], gid.raw[ 3], - gid.raw[ 4], gid.raw[ 5], - gid.raw[ 6], gid.raw[ 7], - gid.raw[ 8], gid.raw[ 9], - gid.raw[10], gid.raw[11], - gid.raw[12], gid.raw[13], - gid.raw[14], gid.raw[15]); - } - return rc; -} - -static const char *link_layer_str(uint8_t link_layer) -{ - switch (link_layer) { - case IBV_LINK_LAYER_UNSPECIFIED: - case IBV_LINK_LAYER_INFINIBAND: - return "InfiniBand"; - case IBV_LINK_LAYER_ETHERNET: - return "Ethernet"; - default: - return "Unknown"; - } -} - -static void print_device_cap_flags(uint32_t dev_cap_flags) -{ - uint32_t unknown_flags = ~(IBV_DEVICE_RESIZE_MAX_WR | - IBV_DEVICE_BAD_PKEY_CNTR | - IBV_DEVICE_BAD_QKEY_CNTR | - IBV_DEVICE_RAW_MULTI | - IBV_DEVICE_AUTO_PATH_MIG | - IBV_DEVICE_CHANGE_PHY_PORT | - IBV_DEVICE_UD_AV_PORT_ENFORCE | - IBV_DEVICE_CURR_QP_STATE_MOD | - IBV_DEVICE_SHUTDOWN_PORT | - IBV_DEVICE_INIT_TYPE | - IBV_DEVICE_PORT_ACTIVE_EVENT | - IBV_DEVICE_SYS_IMAGE_GUID | - IBV_DEVICE_RC_RNR_NAK_GEN | - IBV_DEVICE_SRQ_RESIZE | - IBV_DEVICE_N_NOTIFY_CQ | - IBV_DEVICE_MEM_WINDOW | - IBV_DEVICE_UD_IP_CSUM | - IBV_DEVICE_XRC | - IBV_DEVICE_MEM_MGT_EXTENSIONS | - IBV_DEVICE_MEM_WINDOW_TYPE_2A | - IBV_DEVICE_MEM_WINDOW_TYPE_2B | - IBV_DEVICE_RC_IP_CSUM | - IBV_DEVICE_RAW_IP_CSUM | - IBV_DEVICE_MANAGED_FLOW_STEERING); - - if (dev_cap_flags & IBV_DEVICE_RESIZE_MAX_WR) - printf("\t\t\t\t\tRESIZE_MAX_WR\n"); - if (dev_cap_flags & IBV_DEVICE_BAD_PKEY_CNTR) - printf("\t\t\t\t\tBAD_PKEY_CNTR\n"); - if (dev_cap_flags & IBV_DEVICE_BAD_QKEY_CNTR) - printf("\t\t\t\t\tBAD_QKEY_CNTR\n"); - if (dev_cap_flags & IBV_DEVICE_RAW_MULTI) - printf("\t\t\t\t\tRAW_MULTI\n"); - if (dev_cap_flags & IBV_DEVICE_AUTO_PATH_MIG) - printf("\t\t\t\t\tAUTO_PATH_MIG\n"); - if (dev_cap_flags & IBV_DEVICE_CHANGE_PHY_PORT) - printf("\t\t\t\t\tCHANGE_PHY_PORT\n"); - if (dev_cap_flags & IBV_DEVICE_UD_AV_PORT_ENFORCE) - printf("\t\t\t\t\tUD_AV_PORT_ENFORCE\n"); - if (dev_cap_flags & IBV_DEVICE_CURR_QP_STATE_MOD) - printf("\t\t\t\t\tCURR_QP_STATE_MOD\n"); - if (dev_cap_flags & IBV_DEVICE_SHUTDOWN_PORT) - printf("\t\t\t\t\tSHUTDOWN_PORT\n"); - if (dev_cap_flags & IBV_DEVICE_INIT_TYPE) - printf("\t\t\t\t\tINIT_TYPE\n"); - if (dev_cap_flags & IBV_DEVICE_PORT_ACTIVE_EVENT) - printf("\t\t\t\t\tPORT_ACTIVE_EVENT\n"); - if (dev_cap_flags & IBV_DEVICE_SYS_IMAGE_GUID) - printf("\t\t\t\t\tSYS_IMAGE_GUID\n"); - if (dev_cap_flags & IBV_DEVICE_RC_RNR_NAK_GEN) - printf("\t\t\t\t\tRC_RNR_NAK_GEN\n"); - if (dev_cap_flags & IBV_DEVICE_SRQ_RESIZE) - printf("\t\t\t\t\tSRQ_RESIZE\n"); - if (dev_cap_flags & IBV_DEVICE_N_NOTIFY_CQ) - printf("\t\t\t\t\tN_NOTIFY_CQ\n"); - if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW) - printf("\t\t\t\t\tMEM_WINDOW\n"); - if (dev_cap_flags & IBV_DEVICE_UD_IP_CSUM) - printf("\t\t\t\t\tUD_IP_CSUM\n"); - if (dev_cap_flags & IBV_DEVICE_XRC) - printf("\t\t\t\t\tXRC\n"); - if (dev_cap_flags & IBV_DEVICE_MEM_MGT_EXTENSIONS) - printf("\t\t\t\t\tMEM_MGT_EXTENSIONS\n"); - if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW_TYPE_2A) - printf("\t\t\t\t\tMEM_WINDOW_TYPE_2A\n"); - if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW_TYPE_2B) - printf("\t\t\t\t\tMEM_WINDOW_TYPE_2B\n"); - if (dev_cap_flags & IBV_DEVICE_RC_IP_CSUM) - printf("\t\t\t\t\tRC_IP_CSUM\n"); - if (dev_cap_flags & IBV_DEVICE_RAW_IP_CSUM) - printf("\t\t\t\t\tRAW_IP_CSUM\n"); - if (dev_cap_flags & IBV_DEVICE_MANAGED_FLOW_STEERING) - printf("\t\t\t\t\tMANAGED_FLOW_STEERING\n"); - if (dev_cap_flags & unknown_flags) - printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n", - dev_cap_flags & unknown_flags); -} - -static void print_odp_trans_caps(uint32_t trans) -{ - uint32_t unknown_transport_caps = ~(IBV_ODP_SUPPORT_SEND | - IBV_ODP_SUPPORT_RECV | - IBV_ODP_SUPPORT_WRITE | - IBV_ODP_SUPPORT_READ | - IBV_ODP_SUPPORT_ATOMIC); - - if (!trans) { - printf("\t\t\t\t\tNO SUPPORT\n"); - } else { - if (trans & IBV_ODP_SUPPORT_SEND) - printf("\t\t\t\t\tSUPPORT_SEND\n"); - if (trans & IBV_ODP_SUPPORT_RECV) - printf("\t\t\t\t\tSUPPORT_RECV\n"); - if (trans & IBV_ODP_SUPPORT_WRITE) - printf("\t\t\t\t\tSUPPORT_WRITE\n"); - if (trans & IBV_ODP_SUPPORT_READ) - printf("\t\t\t\t\tSUPPORT_READ\n"); - if (trans & IBV_ODP_SUPPORT_ATOMIC) - printf("\t\t\t\t\tSUPPORT_ATOMIC\n"); - if (trans & unknown_transport_caps) - printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n", - trans & unknown_transport_caps); - } -} - -static void print_odp_caps(const struct ibv_odp_caps *caps) -{ - uint64_t unknown_general_caps = ~(IBV_ODP_SUPPORT); - - /* general odp caps */ - printf("\tgeneral_odp_caps:\n"); - if (caps->general_caps & IBV_ODP_SUPPORT) - printf("\t\t\t\t\tODP_SUPPORT\n"); - if (caps->general_caps & unknown_general_caps) - printf("\t\t\t\t\tUnknown flags: 0x%" PRIX64 "\n", - caps->general_caps & unknown_general_caps); - - /* RC transport */ - printf("\trc_odp_caps:\n"); - print_odp_trans_caps(caps->per_transport_caps.rc_odp_caps); - printf("\tuc_odp_caps:\n"); - print_odp_trans_caps(caps->per_transport_caps.uc_odp_caps); - printf("\tud_odp_caps:\n"); - print_odp_trans_caps(caps->per_transport_caps.ud_odp_caps); -} - -static void print_device_cap_flags_ex(uint64_t device_cap_flags_ex) -{ - uint64_t ex_flags = device_cap_flags_ex & 0xffffffff00000000ULL; - uint64_t unknown_flags = ~(IBV_DEVICE_RAW_SCATTER_FCS); - - if (ex_flags & IBV_DEVICE_RAW_SCATTER_FCS) - printf("\t\t\t\t\tRAW_SCATTER_FCS\n"); - if (ex_flags & unknown_flags) - printf("\t\t\t\t\tUnknown flags: 0x%" PRIX64 "\n", - ex_flags & unknown_flags); -} - -static void print_tso_caps(const struct ibv_tso_caps *caps) -{ - uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET | - 1 << IBV_QPT_UD); - printf("\ttso_caps:\n"); - printf("\tmax_tso:\t\t\t%d\n", caps->max_tso); - - if (caps->max_tso) { - printf("\tsupported_qp:\n"); - if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET)) - printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n"); - if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD)) - printf("\t\t\t\t\tSUPPORT_UD\n"); - if (caps->supported_qpts & unknown_general_caps) - printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n", - caps->supported_qpts & unknown_general_caps); - } -} - -static void print_rss_caps(const struct ibv_rss_caps *caps) -{ - uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET | - 1 << IBV_QPT_UD); - printf("\trss_caps:\n"); - printf("\t\tmax_rwq_indirection_tables:\t\t\t%u\n", caps->max_rwq_indirection_tables); - printf("\t\tmax_rwq_indirection_table_size:\t\t\t%u\n", caps->max_rwq_indirection_table_size); - printf("\t\trx_hash_function:\t\t\t\t0x%x\n", caps->rx_hash_function); - printf("\t\trx_hash_fields_mask:\t\t\t\t0x%" PRIX64 "\n", caps->rx_hash_fields_mask); - - if (caps->supported_qpts) { - printf("\t\tsupported_qp:\n"); - if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET)) - printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n"); - if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD)) - printf("\t\t\t\t\tSUPPORT_UD\n"); - if (caps->supported_qpts & unknown_general_caps) - printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n", - caps->supported_qpts & unknown_general_caps); - } -} - -static void print_packet_pacing_caps(const struct ibv_packet_pacing_caps *caps) -{ - uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET | - 1 << IBV_QPT_UD); - printf("\tpacket_pacing_caps:\n"); - printf("\t\tqp_rate_limit_min:\t%ukbps\n", caps->qp_rate_limit_min); - printf("\t\tqp_rate_limit_max:\t%ukbps\n", caps->qp_rate_limit_max); - - if (caps->qp_rate_limit_max) { - printf("\t\tsupported_qp:\n"); - if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET)) - printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n"); - if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD)) - printf("\t\t\t\t\tSUPPORT_UD\n"); - if (caps->supported_qpts & unknown_general_caps) - printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n", - caps->supported_qpts & unknown_general_caps); - } -} - -static void print_raw_packet_caps(uint32_t raw_packet_caps) -{ - printf("\traw packet caps:\n"); - if (raw_packet_caps & IBV_RAW_PACKET_CAP_CVLAN_STRIPPING) - printf("\t\t\t\t\tC-VLAN stripping offload\n"); - if (raw_packet_caps & IBV_RAW_PACKET_CAP_SCATTER_FCS) - printf("\t\t\t\t\tScatter FCS offload\n"); - if (raw_packet_caps & IBV_RAW_PACKET_CAP_IP_CSUM) - printf("\t\t\t\t\tIP csum offload\n"); - if (raw_packet_caps & IBV_RAW_PACKET_CAP_DELAY_DROP) - printf("\t\t\t\t\tDelay drop\n"); -} - -static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port) -{ - struct ibv_context *ctx; - struct ibv_device_attr_ex device_attr; - struct ibv_port_attr port_attr; - int rc = 0; - uint8_t port; - char buf[256]; - - ctx = ibv_open_device(ib_dev); - if (!ctx) { - fprintf(stderr, "Failed to open device\n"); - rc = 1; - goto cleanup; - } - if (ibv_query_device_ex(ctx, NULL, &device_attr)) { - fprintf(stderr, "Failed to query device props\n"); - rc = 2; - goto cleanup; - } - if (ib_port && ib_port > device_attr.orig_attr.phys_port_cnt) { - fprintf(stderr, "Invalid port requested for device\n"); - /* rc = 3 is taken by failure to clean up */ - rc = 4; - goto cleanup; - } - - printf("hca_id:\t%s\n", ibv_get_device_name(ib_dev)); - printf("\ttransport:\t\t\t%s (%d)\n", - transport_str(ib_dev->transport_type), ib_dev->transport_type); - if (strlen(device_attr.orig_attr.fw_ver)) - printf("\tfw_ver:\t\t\t\t%s\n", device_attr.orig_attr.fw_ver); - printf("\tnode_guid:\t\t\t%s\n", guid_str(device_attr.orig_attr.node_guid, buf)); - printf("\tsys_image_guid:\t\t\t%s\n", guid_str(device_attr.orig_attr.sys_image_guid, buf)); - printf("\tvendor_id:\t\t\t0x%04x\n", device_attr.orig_attr.vendor_id); - printf("\tvendor_part_id:\t\t\t%d\n", device_attr.orig_attr.vendor_part_id); - printf("\thw_ver:\t\t\t\t0x%X\n", device_attr.orig_attr.hw_ver); - - if (ibv_read_sysfs_file(ib_dev->ibdev_path, "board_id", buf, sizeof buf) > 0) - printf("\tboard_id:\t\t\t%s\n", buf); - - printf("\tphys_port_cnt:\t\t\t%d\n", device_attr.orig_attr.phys_port_cnt); - - if (verbose) { - printf("\tmax_mr_size:\t\t\t0x%llx\n", - (unsigned long long) device_attr.orig_attr.max_mr_size); - printf("\tpage_size_cap:\t\t\t0x%llx\n", - (unsigned long long) device_attr.orig_attr.page_size_cap); - printf("\tmax_qp:\t\t\t\t%d\n", device_attr.orig_attr.max_qp); - printf("\tmax_qp_wr:\t\t\t%d\n", device_attr.orig_attr.max_qp_wr); - printf("\tdevice_cap_flags:\t\t0x%08x\n", device_attr.orig_attr.device_cap_flags); - print_device_cap_flags(device_attr.orig_attr.device_cap_flags); - printf("\tmax_sge:\t\t\t%d\n", device_attr.orig_attr.max_sge); - printf("\tmax_sge_rd:\t\t\t%d\n", device_attr.orig_attr.max_sge_rd); - printf("\tmax_cq:\t\t\t\t%d\n", device_attr.orig_attr.max_cq); - printf("\tmax_cqe:\t\t\t%d\n", device_attr.orig_attr.max_cqe); - printf("\tmax_mr:\t\t\t\t%d\n", device_attr.orig_attr.max_mr); - printf("\tmax_pd:\t\t\t\t%d\n", device_attr.orig_attr.max_pd); - printf("\tmax_qp_rd_atom:\t\t\t%d\n", device_attr.orig_attr.max_qp_rd_atom); - printf("\tmax_ee_rd_atom:\t\t\t%d\n", device_attr.orig_attr.max_ee_rd_atom); - printf("\tmax_res_rd_atom:\t\t%d\n", device_attr.orig_attr.max_res_rd_atom); - printf("\tmax_qp_init_rd_atom:\t\t%d\n", device_attr.orig_attr.max_qp_init_rd_atom); - printf("\tmax_ee_init_rd_atom:\t\t%d\n", device_attr.orig_attr.max_ee_init_rd_atom); - printf("\tatomic_cap:\t\t\t%s (%d)\n", - atomic_cap_str(device_attr.orig_attr.atomic_cap), device_attr.orig_attr.atomic_cap); - printf("\tmax_ee:\t\t\t\t%d\n", device_attr.orig_attr.max_ee); - printf("\tmax_rdd:\t\t\t%d\n", device_attr.orig_attr.max_rdd); - printf("\tmax_mw:\t\t\t\t%d\n", device_attr.orig_attr.max_mw); - printf("\tmax_raw_ipv6_qp:\t\t%d\n", device_attr.orig_attr.max_raw_ipv6_qp); - printf("\tmax_raw_ethy_qp:\t\t%d\n", device_attr.orig_attr.max_raw_ethy_qp); - printf("\tmax_mcast_grp:\t\t\t%d\n", device_attr.orig_attr.max_mcast_grp); - printf("\tmax_mcast_qp_attach:\t\t%d\n", device_attr.orig_attr.max_mcast_qp_attach); - printf("\tmax_total_mcast_qp_attach:\t%d\n", - device_attr.orig_attr.max_total_mcast_qp_attach); - printf("\tmax_ah:\t\t\t\t%d\n", device_attr.orig_attr.max_ah); - printf("\tmax_fmr:\t\t\t%d\n", device_attr.orig_attr.max_fmr); - if (device_attr.orig_attr.max_fmr) - printf("\tmax_map_per_fmr:\t\t%d\n", device_attr.orig_attr.max_map_per_fmr); - printf("\tmax_srq:\t\t\t%d\n", device_attr.orig_attr.max_srq); - if (device_attr.orig_attr.max_srq) { - printf("\tmax_srq_wr:\t\t\t%d\n", device_attr.orig_attr.max_srq_wr); - printf("\tmax_srq_sge:\t\t\t%d\n", device_attr.orig_attr.max_srq_sge); - } - printf("\tmax_pkeys:\t\t\t%d\n", device_attr.orig_attr.max_pkeys); - printf("\tlocal_ca_ack_delay:\t\t%d\n", device_attr.orig_attr.local_ca_ack_delay); - - print_odp_caps(&device_attr.odp_caps); - if (device_attr.completion_timestamp_mask) - printf("\tcompletion timestamp_mask:\t\t\t0x%016" PRIx64 "\n", - device_attr.completion_timestamp_mask); - else - printf("\tcompletion_timestamp_mask not supported\n"); - - if (device_attr.hca_core_clock) - printf("\thca_core_clock:\t\t\t%" PRIu64 "kHZ\n", device_attr.hca_core_clock); - else - printf("\tcore clock not supported\n"); - - if (device_attr.raw_packet_caps) - print_raw_packet_caps(device_attr.raw_packet_caps); - - printf("\tdevice_cap_flags_ex:\t\t0x%" PRIX64 "\n", device_attr.device_cap_flags_ex); - print_device_cap_flags_ex(device_attr.device_cap_flags_ex); - print_tso_caps(&device_attr.tso_caps); - print_rss_caps(&device_attr.rss_caps); - printf("\tmax_wq_type_rq:\t\t\t%u\n", device_attr.max_wq_type_rq); - print_packet_pacing_caps(&device_attr.packet_pacing_caps); - } - - for (port = 1; port <= device_attr.orig_attr.phys_port_cnt; ++port) { - /* if in the command line the user didn't ask for info about this port */ - if ((ib_port) && (port != ib_port)) - continue; - - rc = ibv_query_port(ctx, port, &port_attr); - if (rc) { - fprintf(stderr, "Failed to query port %u props\n", port); - goto cleanup; - } - printf("\t\tport:\t%d\n", port); - printf("\t\t\tstate:\t\t\t%s (%d)\n", - port_state_str(port_attr.state), port_attr.state); - printf("\t\t\tmax_mtu:\t\t%s (%d)\n", - mtu_str(port_attr.max_mtu), port_attr.max_mtu); - printf("\t\t\tactive_mtu:\t\t%s (%d)\n", - mtu_str(port_attr.active_mtu), port_attr.active_mtu); - printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid); - printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid); - printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc); - printf("\t\t\tlink_layer:\t\t%s\n", - link_layer_str(port_attr.link_layer)); - - if (verbose) { - printf("\t\t\tmax_msg_sz:\t\t0x%x\n", port_attr.max_msg_sz); - printf("\t\t\tport_cap_flags:\t\t0x%08x\n", port_attr.port_cap_flags); - printf("\t\t\tmax_vl_num:\t\t%s (%d)\n", - vl_str(port_attr.max_vl_num), port_attr.max_vl_num); - printf("\t\t\tbad_pkey_cntr:\t\t0x%x\n", port_attr.bad_pkey_cntr); - printf("\t\t\tqkey_viol_cntr:\t\t0x%x\n", port_attr.qkey_viol_cntr); - printf("\t\t\tsm_sl:\t\t\t%d\n", port_attr.sm_sl); - printf("\t\t\tpkey_tbl_len:\t\t%d\n", port_attr.pkey_tbl_len); - printf("\t\t\tgid_tbl_len:\t\t%d\n", port_attr.gid_tbl_len); - printf("\t\t\tsubnet_timeout:\t\t%d\n", port_attr.subnet_timeout); - printf("\t\t\tinit_type_reply:\t%d\n", port_attr.init_type_reply); - printf("\t\t\tactive_width:\t\t%sX (%d)\n", - width_str(port_attr.active_width), port_attr.active_width); - printf("\t\t\tactive_speed:\t\t%s (%d)\n", - speed_str(port_attr.active_speed), port_attr.active_speed); - if (ib_dev->transport_type == IBV_TRANSPORT_IB) - printf("\t\t\tphys_state:\t\t%s (%d)\n", - port_phy_state_str(port_attr.phys_state), port_attr.phys_state); - - if (print_all_port_gids(ctx, port, port_attr.gid_tbl_len)) - goto cleanup; - } - printf("\n"); - } -cleanup: - if (ctx) - if (ibv_close_device(ctx)) { - fprintf(stderr, "Failed to close device"); - rc = 3; - } - return rc; -} - -static void usage(const char *argv0) -{ - printf("Usage: %s print the ca attributes\n", argv0); - printf("\n"); - printf("Options:\n"); - printf(" -d, --ib-dev= use IB device (default first device found)\n"); - printf(" -i, --ib-port= use port of IB device (default all ports)\n"); - printf(" -l, --list print only the IB devices names\n"); - printf(" -v, --verbose print all the attributes of the IB device(s)\n"); -} - -int main(int argc, char *argv[]) -{ - char *ib_devname = NULL; - int ret = 0; - struct ibv_device **dev_list, **orig_dev_list; - int num_of_hcas; - int ib_port = 0; - - /* parse command line options */ - while (1) { - int c; - static struct option long_options[] = { - { .name = "ib-dev", .has_arg = 1, .val = 'd' }, - { .name = "ib-port", .has_arg = 1, .val = 'i' }, - { .name = "list", .has_arg = 0, .val = 'l' }, - { .name = "verbose", .has_arg = 0, .val = 'v' }, - { } - }; - - c = getopt_long(argc, argv, "d:i:lv", long_options, NULL); - if (c == -1) - break; - - switch (c) { - case 'd': - ib_devname = strdup(optarg); - break; - - case 'i': - ib_port = strtol(optarg, NULL, 0); - if (ib_port <= 0) { - usage(argv[0]); - return 1; - } - break; - - case 'v': - verbose = 1; - break; - - case 'l': - dev_list = orig_dev_list = ibv_get_device_list(&num_of_hcas); - if (!dev_list) { - perror("Failed to get IB devices list"); - return -1; - } - - printf("%d HCA%s found:\n", num_of_hcas, - num_of_hcas != 1 ? "s" : ""); - - while (*dev_list) { - printf("\t%s\n", ibv_get_device_name(*dev_list)); - ++dev_list; - } - - printf("\n"); - - ibv_free_device_list(orig_dev_list); - - return 0; - - default: - usage(argv[0]); - return -1; - } - } - - dev_list = orig_dev_list = ibv_get_device_list(NULL); - if (!dev_list) { - perror("Failed to get IB devices list"); - return -1; - } - - if (ib_devname) { - while (*dev_list) { - if (!strcmp(ibv_get_device_name(*dev_list), ib_devname)) - break; - ++dev_list; - } - - if (!*dev_list) { - fprintf(stderr, "IB device '%s' wasn't found\n", ib_devname); - return -1; - } - - ret |= print_hca_cap(*dev_list, ib_port); - } else { - if (!*dev_list) { - fprintf(stderr, "No IB devices found\n"); - return -1; - } - - while (*dev_list) { - ret |= print_hca_cap(*dev_list, ib_port); - ++dev_list; - } - } - - if (ib_devname) - free(ib_devname); - - ibv_free_device_list(orig_dev_list); - - return ret; -} diff --git a/usr/rdma-core/libibverbs/examples/pingpong.c b/usr/rdma-core/libibverbs/examples/pingpong.c deleted file mode 100644 index da08e820f..000000000 --- a/usr/rdma-core/libibverbs/examples/pingpong.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2006 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "pingpong.h" -#include -#include -#include -#include - -enum ibv_mtu pp_mtu_to_enum(int mtu) -{ - switch (mtu) { - case 256: return IBV_MTU_256; - case 512: return IBV_MTU_512; - case 1024: return IBV_MTU_1024; - case 2048: return IBV_MTU_2048; - case 4096: return IBV_MTU_4096; - default: return 0; - } -} - -int pp_get_port_info(struct ibv_context *context, int port, - struct ibv_port_attr *attr) -{ - return ibv_query_port(context, port, attr); -} - -void wire_gid_to_gid(const char *wgid, union ibv_gid *gid) -{ - char tmp[9]; - __be32 v32; - int i; - uint32_t tmp_gid[4]; - - for (tmp[8] = 0, i = 0; i < 4; ++i) { - memcpy(tmp, wgid + i * 8, 8); - sscanf(tmp, "%x", &v32); - tmp_gid[i] = be32toh(v32); - } - memcpy(gid, tmp_gid, sizeof(*gid)); -} - -void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]) -{ - uint32_t tmp_gid[4]; - int i; - - memcpy(tmp_gid, gid, sizeof(tmp_gid)); - for (i = 0; i < 4; ++i) - sprintf(&wgid[i * 8], "%08x", htobe32(tmp_gid[i])); -} diff --git a/usr/rdma-core/libibverbs/examples/pingpong.h b/usr/rdma-core/libibverbs/examples/pingpong.h deleted file mode 100644 index 8dc5dd0d0..000000000 --- a/usr/rdma-core/libibverbs/examples/pingpong.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2006 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef IBV_PINGPONG_H -#define IBV_PINGPONG_H - -#include - -enum ibv_mtu pp_mtu_to_enum(int mtu); -int pp_get_port_info(struct ibv_context *context, int port, - struct ibv_port_attr *attr); -void wire_gid_to_gid(const char *wgid, union ibv_gid *gid); -void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]); - -#endif /* IBV_PINGPONG_H */ diff --git a/usr/rdma-core/libibverbs/examples/rc_pingpong.c b/usr/rdma-core/libibverbs/examples/rc_pingpong.c deleted file mode 100644 index 7400ec8c8..000000000 --- a/usr/rdma-core/libibverbs/examples/rc_pingpong.c +++ /dev/null @@ -1,1041 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pingpong.h" - -#include - -enum { - PINGPONG_RECV_WRID = 1, - PINGPONG_SEND_WRID = 2, -}; - -static int page_size; -static int use_odp; -static int use_ts; - -struct pingpong_context { - struct ibv_context *context; - struct ibv_comp_channel *channel; - struct ibv_pd *pd; - struct ibv_mr *mr; - union { - struct ibv_cq *cq; - struct ibv_cq_ex *cq_ex; - } cq_s; - struct ibv_qp *qp; - void *buf; - int size; - int send_flags; - int rx_depth; - int pending; - struct ibv_port_attr portinfo; - uint64_t completion_timestamp_mask; -}; - -static struct ibv_cq *pp_cq(struct pingpong_context *ctx) -{ - return use_ts ? ibv_cq_ex_to_cq(ctx->cq_s.cq_ex) : - ctx->cq_s.cq; -} - -struct pingpong_dest { - int lid; - int qpn; - int psn; - union ibv_gid gid; -}; - -static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, - enum ibv_mtu mtu, int sl, - struct pingpong_dest *dest, int sgid_idx) -{ - struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_RTR, - .path_mtu = mtu, - .dest_qp_num = dest->qpn, - .rq_psn = dest->psn, - .max_dest_rd_atomic = 1, - .min_rnr_timer = 12, - .ah_attr = { - .is_global = 0, - .dlid = dest->lid, - .sl = sl, - .src_path_bits = 0, - .port_num = port - } - }; - - if (dest->gid.global.interface_id) { - attr.ah_attr.is_global = 1; - attr.ah_attr.grh.hop_limit = 1; - attr.ah_attr.grh.dgid = dest->gid; - attr.ah_attr.grh.sgid_index = sgid_idx; - } - if (ibv_modify_qp(ctx->qp, &attr, - IBV_QP_STATE | - IBV_QP_AV | - IBV_QP_PATH_MTU | - IBV_QP_DEST_QPN | - IBV_QP_RQ_PSN | - IBV_QP_MAX_DEST_RD_ATOMIC | - IBV_QP_MIN_RNR_TIMER)) { - fprintf(stderr, "Failed to modify QP to RTR\n"); - return 1; - } - - attr.qp_state = IBV_QPS_RTS; - attr.timeout = 14; - attr.retry_cnt = 7; - attr.rnr_retry = 7; - attr.sq_psn = my_psn; - attr.max_rd_atomic = 1; - if (ibv_modify_qp(ctx->qp, &attr, - IBV_QP_STATE | - IBV_QP_TIMEOUT | - IBV_QP_RETRY_CNT | - IBV_QP_RNR_RETRY | - IBV_QP_SQ_PSN | - IBV_QP_MAX_QP_RD_ATOMIC)) { - fprintf(stderr, "Failed to modify QP to RTS\n"); - return 1; - } - - return 0; -} - -static struct pingpong_dest *pp_client_exch_dest(const char *servername, int port, - const struct pingpong_dest *my_dest) -{ - struct addrinfo *res, *t; - struct addrinfo hints = { - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - char *service; - char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"]; - int n; - int sockfd = -1; - struct pingpong_dest *rem_dest = NULL; - char gid[33]; - - if (asprintf(&service, "%d", port) < 0) - return NULL; - - n = getaddrinfo(servername, service, &hints, &res); - - if (n < 0) { - fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port); - free(service); - return NULL; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - if (!connect(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port); - return NULL; - } - - gid_to_wire_gid(&my_dest->gid, gid); - sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, - my_dest->psn, gid); - if (write(sockfd, msg, sizeof msg) != sizeof msg) { - fprintf(stderr, "Couldn't send local address\n"); - goto out; - } - - if (read(sockfd, msg, sizeof msg) != sizeof msg || - write(sockfd, "done", sizeof "done") != sizeof "done") { - perror("client read/write"); - fprintf(stderr, "Couldn't read/write remote address\n"); - goto out; - } - - rem_dest = malloc(sizeof *rem_dest); - if (!rem_dest) - goto out; - - sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, - &rem_dest->psn, gid); - wire_gid_to_gid(gid, &rem_dest->gid); - -out: - close(sockfd); - return rem_dest; -} - -static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, - int ib_port, enum ibv_mtu mtu, - int port, int sl, - const struct pingpong_dest *my_dest, - int sgid_idx) -{ - struct addrinfo *res, *t; - struct addrinfo hints = { - .ai_flags = AI_PASSIVE, - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - char *service; - char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"]; - int n; - int sockfd = -1, connfd; - struct pingpong_dest *rem_dest = NULL; - char gid[33]; - - if (asprintf(&service, "%d", port) < 0) - return NULL; - - n = getaddrinfo(NULL, service, &hints, &res); - - if (n < 0) { - fprintf(stderr, "%s for port %d\n", gai_strerror(n), port); - free(service); - return NULL; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - n = 1; - - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n); - - if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't listen to port %d\n", port); - return NULL; - } - - listen(sockfd, 1); - connfd = accept(sockfd, NULL, NULL); - close(sockfd); - if (connfd < 0) { - fprintf(stderr, "accept() failed\n"); - return NULL; - } - - n = read(connfd, msg, sizeof msg); - if (n != sizeof msg) { - perror("server read"); - fprintf(stderr, "%d/%d: Couldn't read remote address\n", n, (int) sizeof msg); - goto out; - } - - rem_dest = malloc(sizeof *rem_dest); - if (!rem_dest) - goto out; - - sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, - &rem_dest->psn, gid); - wire_gid_to_gid(gid, &rem_dest->gid); - - if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest, - sgid_idx)) { - fprintf(stderr, "Couldn't connect to remote QP\n"); - free(rem_dest); - rem_dest = NULL; - goto out; - } - - - gid_to_wire_gid(&my_dest->gid, gid); - sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, - my_dest->psn, gid); - if (write(connfd, msg, sizeof msg) != sizeof msg || - read(connfd, msg, sizeof msg) != sizeof "done") { - fprintf(stderr, "Couldn't send/recv local address\n"); - free(rem_dest); - rem_dest = NULL; - goto out; - } - - -out: - close(connfd); - return rem_dest; -} - -static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, - int rx_depth, int port, - int use_event) -{ - struct pingpong_context *ctx; - int access_flags = IBV_ACCESS_LOCAL_WRITE; - - ctx = calloc(1, sizeof *ctx); - if (!ctx) - return NULL; - - ctx->size = size; - ctx->send_flags = IBV_SEND_SIGNALED; - ctx->rx_depth = rx_depth; - - ctx->buf = memalign(page_size, size); - if (!ctx->buf) { - fprintf(stderr, "Couldn't allocate work buf.\n"); - goto clean_ctx; - } - - /* FIXME memset(ctx->buf, 0, size); */ - memset(ctx->buf, 0x7b, size); - - ctx->context = ibv_open_device(ib_dev); - if (!ctx->context) { - fprintf(stderr, "Couldn't get context for %s\n", - ibv_get_device_name(ib_dev)); - goto clean_buffer; - } - - if (use_event) { - ctx->channel = ibv_create_comp_channel(ctx->context); - if (!ctx->channel) { - fprintf(stderr, "Couldn't create completion channel\n"); - goto clean_device; - } - } else - ctx->channel = NULL; - - ctx->pd = ibv_alloc_pd(ctx->context); - if (!ctx->pd) { - fprintf(stderr, "Couldn't allocate PD\n"); - goto clean_comp_channel; - } - - if (use_odp || use_ts) { - const uint32_t rc_caps_mask = IBV_ODP_SUPPORT_SEND | - IBV_ODP_SUPPORT_RECV; - struct ibv_device_attr_ex attrx; - - if (ibv_query_device_ex(ctx->context, NULL, &attrx)) { - fprintf(stderr, "Couldn't query device for its features\n"); - goto clean_comp_channel; - } - - if (use_odp) { - if (!(attrx.odp_caps.general_caps & IBV_ODP_SUPPORT) || - (attrx.odp_caps.per_transport_caps.rc_odp_caps & rc_caps_mask) != rc_caps_mask) { - fprintf(stderr, "The device isn't ODP capable or does not support RC send and receive with ODP\n"); - goto clean_comp_channel; - } - access_flags |= IBV_ACCESS_ON_DEMAND; - } - - if (use_ts) { - if (!attrx.completion_timestamp_mask) { - fprintf(stderr, "The device isn't completion timestamp capable\n"); - goto clean_comp_channel; - } - ctx->completion_timestamp_mask = attrx.completion_timestamp_mask; - } - } - ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size, access_flags); - - if (!ctx->mr) { - fprintf(stderr, "Couldn't register MR\n"); - goto clean_pd; - } - - if (use_ts) { - struct ibv_cq_init_attr_ex attr_ex = { - .cqe = rx_depth + 1, - .cq_context = NULL, - .channel = ctx->channel, - .comp_vector = 0, - .wc_flags = IBV_WC_EX_WITH_COMPLETION_TIMESTAMP - }; - - ctx->cq_s.cq_ex = ibv_create_cq_ex(ctx->context, &attr_ex); - } else { - ctx->cq_s.cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL, - ctx->channel, 0); - } - - if (!pp_cq(ctx)) { - fprintf(stderr, "Couldn't create CQ\n"); - goto clean_mr; - } - - { - struct ibv_qp_attr attr; - struct ibv_qp_init_attr init_attr = { - .send_cq = pp_cq(ctx), - .recv_cq = pp_cq(ctx), - .cap = { - .max_send_wr = 1, - .max_recv_wr = rx_depth, - .max_send_sge = 1, - .max_recv_sge = 1 - }, - .qp_type = IBV_QPT_RC - }; - - ctx->qp = ibv_create_qp(ctx->pd, &init_attr); - if (!ctx->qp) { - fprintf(stderr, "Couldn't create QP\n"); - goto clean_cq; - } - - ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr); - if (init_attr.cap.max_inline_data >= size) { - ctx->send_flags |= IBV_SEND_INLINE; - } - } - - { - struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_INIT, - .pkey_index = 0, - .port_num = port, - .qp_access_flags = 0 - }; - - if (ibv_modify_qp(ctx->qp, &attr, - IBV_QP_STATE | - IBV_QP_PKEY_INDEX | - IBV_QP_PORT | - IBV_QP_ACCESS_FLAGS)) { - fprintf(stderr, "Failed to modify QP to INIT\n"); - goto clean_qp; - } - } - - return ctx; - -clean_qp: - ibv_destroy_qp(ctx->qp); - -clean_cq: - ibv_destroy_cq(pp_cq(ctx)); - -clean_mr: - ibv_dereg_mr(ctx->mr); - -clean_pd: - ibv_dealloc_pd(ctx->pd); - -clean_comp_channel: - if (ctx->channel) - ibv_destroy_comp_channel(ctx->channel); - -clean_device: - ibv_close_device(ctx->context); - -clean_buffer: - free(ctx->buf); - -clean_ctx: - free(ctx); - - return NULL; -} - -static int pp_close_ctx(struct pingpong_context *ctx) -{ - if (ibv_destroy_qp(ctx->qp)) { - fprintf(stderr, "Couldn't destroy QP\n"); - return 1; - } - - if (ibv_destroy_cq(pp_cq(ctx))) { - fprintf(stderr, "Couldn't destroy CQ\n"); - return 1; - } - - if (ibv_dereg_mr(ctx->mr)) { - fprintf(stderr, "Couldn't deregister MR\n"); - return 1; - } - - if (ibv_dealloc_pd(ctx->pd)) { - fprintf(stderr, "Couldn't deallocate PD\n"); - return 1; - } - - if (ctx->channel) { - if (ibv_destroy_comp_channel(ctx->channel)) { - fprintf(stderr, "Couldn't destroy completion channel\n"); - return 1; - } - } - - if (ibv_close_device(ctx->context)) { - fprintf(stderr, "Couldn't release context\n"); - return 1; - } - - free(ctx->buf); - free(ctx); - - return 0; -} - -static int pp_post_recv(struct pingpong_context *ctx, int n) -{ - struct ibv_sge list = { - .addr = (uintptr_t) ctx->buf, - .length = ctx->size, - .lkey = ctx->mr->lkey - }; - struct ibv_recv_wr wr = { - .wr_id = PINGPONG_RECV_WRID, - .sg_list = &list, - .num_sge = 1, - }; - struct ibv_recv_wr *bad_wr; - int i; - - for (i = 0; i < n; ++i) - if (ibv_post_recv(ctx->qp, &wr, &bad_wr)) - break; - - return i; -} - -static int pp_post_send(struct pingpong_context *ctx) -{ - struct ibv_sge list = { - .addr = (uintptr_t) ctx->buf, - .length = ctx->size, - .lkey = ctx->mr->lkey - }; - struct ibv_send_wr wr = { - .wr_id = PINGPONG_SEND_WRID, - .sg_list = &list, - .num_sge = 1, - .opcode = IBV_WR_SEND, - .send_flags = ctx->send_flags, - }; - struct ibv_send_wr *bad_wr; - - return ibv_post_send(ctx->qp, &wr, &bad_wr); -} - -struct ts_params { - uint64_t comp_recv_max_time_delta; - uint64_t comp_recv_min_time_delta; - uint64_t comp_recv_total_time_delta; - uint64_t comp_recv_prev_time; - int last_comp_with_ts; - unsigned int comp_with_time_iters; -}; - -static inline int parse_single_wc(struct pingpong_context *ctx, int *scnt, - int *rcnt, int *routs, int iters, - uint64_t wr_id, enum ibv_wc_status status, - uint64_t completion_timestamp, - struct ts_params *ts) -{ - if (status != IBV_WC_SUCCESS) { - fprintf(stderr, "Failed status %s (%d) for wr_id %d\n", - ibv_wc_status_str(status), - status, (int)wr_id); - return 1; - } - - switch ((int)wr_id) { - case PINGPONG_SEND_WRID: - ++(*scnt); - break; - - case PINGPONG_RECV_WRID: - if (--(*routs) <= 1) { - *routs += pp_post_recv(ctx, ctx->rx_depth - *routs); - if (*routs < ctx->rx_depth) { - fprintf(stderr, - "Couldn't post receive (%d)\n", - *routs); - return 1; - } - } - - ++(*rcnt); - if (use_ts) { - if (ts->last_comp_with_ts) { - uint64_t delta; - - /* checking whether the clock was wrapped around */ - if (completion_timestamp >= ts->comp_recv_prev_time) - delta = completion_timestamp - ts->comp_recv_prev_time; - else - delta = ctx->completion_timestamp_mask - ts->comp_recv_prev_time + - completion_timestamp + 1; - - ts->comp_recv_max_time_delta = max(ts->comp_recv_max_time_delta, delta); - ts->comp_recv_min_time_delta = min(ts->comp_recv_min_time_delta, delta); - ts->comp_recv_total_time_delta += delta; - ts->comp_with_time_iters++; - } - - ts->comp_recv_prev_time = completion_timestamp; - ts->last_comp_with_ts = 1; - } else { - ts->last_comp_with_ts = 0; - } - - break; - - default: - fprintf(stderr, "Completion for unknown wr_id %d\n", - (int)wr_id); - return 1; - } - - ctx->pending &= ~(int)wr_id; - if (*scnt < iters && !ctx->pending) { - if (pp_post_send(ctx)) { - fprintf(stderr, "Couldn't post send\n"); - return 1; - } - ctx->pending = PINGPONG_RECV_WRID | - PINGPONG_SEND_WRID; - } - - return 0; -} - -static void usage(const char *argv0) -{ - printf("Usage:\n"); - printf(" %s start a server and wait for connection\n", argv0); - printf(" %s connect to server at \n", argv0); - printf("\n"); - printf("Options:\n"); - printf(" -p, --port= listen on/connect to port (default 18515)\n"); - printf(" -d, --ib-dev= use IB device (default first device found)\n"); - printf(" -i, --ib-port= use port of IB device (default 1)\n"); - printf(" -s, --size= size of message to exchange (default 4096)\n"); - printf(" -m, --mtu= path MTU (default 1024)\n"); - printf(" -r, --rx-depth= number of receives to post at a time (default 500)\n"); - printf(" -n, --iters= number of exchanges (default 1000)\n"); - printf(" -l, --sl= service level value\n"); - printf(" -e, --events sleep on CQ events (default poll)\n"); - printf(" -g, --gid-idx= local port gid index\n"); - printf(" -o, --odp use on demand paging\n"); - printf(" -t, --ts get CQE with timestamp\n"); -} - -int main(int argc, char *argv[]) -{ - struct ibv_device **dev_list; - struct ibv_device *ib_dev; - struct pingpong_context *ctx; - struct pingpong_dest my_dest; - struct pingpong_dest *rem_dest; - struct timeval start, end; - char *ib_devname = NULL; - char *servername = NULL; - unsigned int port = 18515; - int ib_port = 1; - unsigned int size = 4096; - enum ibv_mtu mtu = IBV_MTU_1024; - unsigned int rx_depth = 500; - unsigned int iters = 1000; - int use_event = 0; - int routs; - int rcnt, scnt; - int num_cq_events = 0; - int sl = 0; - int gidx = -1; - char gid[33]; - struct ts_params ts; - - srand48(getpid() * time(NULL)); - - while (1) { - int c; - - static struct option long_options[] = { - { .name = "port", .has_arg = 1, .val = 'p' }, - { .name = "ib-dev", .has_arg = 1, .val = 'd' }, - { .name = "ib-port", .has_arg = 1, .val = 'i' }, - { .name = "size", .has_arg = 1, .val = 's' }, - { .name = "mtu", .has_arg = 1, .val = 'm' }, - { .name = "rx-depth", .has_arg = 1, .val = 'r' }, - { .name = "iters", .has_arg = 1, .val = 'n' }, - { .name = "sl", .has_arg = 1, .val = 'l' }, - { .name = "events", .has_arg = 0, .val = 'e' }, - { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - { .name = "odp", .has_arg = 0, .val = 'o' }, - { .name = "ts", .has_arg = 0, .val = 't' }, - {} - }; - - c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:ot", - long_options, NULL); - - if (c == -1) - break; - - switch (c) { - case 'p': - port = strtoul(optarg, NULL, 0); - if (port > 65535) { - usage(argv[0]); - return 1; - } - break; - - case 'd': - ib_devname = strdupa(optarg); - break; - - case 'i': - ib_port = strtol(optarg, NULL, 0); - if (ib_port < 1) { - usage(argv[0]); - return 1; - } - break; - - case 's': - size = strtoul(optarg, NULL, 0); - break; - - case 'm': - mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0)); - if (mtu == 0) { - usage(argv[0]); - return 1; - } - break; - - case 'r': - rx_depth = strtoul(optarg, NULL, 0); - break; - - case 'n': - iters = strtoul(optarg, NULL, 0); - break; - - case 'l': - sl = strtol(optarg, NULL, 0); - break; - - case 'e': - ++use_event; - break; - - case 'g': - gidx = strtol(optarg, NULL, 0); - break; - - case 'o': - use_odp = 1; - break; - case 't': - use_ts = 1; - break; - - default: - usage(argv[0]); - return 1; - } - } - - if (optind == argc - 1) - servername = strdupa(argv[optind]); - else if (optind < argc) { - usage(argv[0]); - return 1; - } - - if (use_ts) { - ts.comp_recv_max_time_delta = 0; - ts.comp_recv_min_time_delta = 0xffffffff; - ts.comp_recv_total_time_delta = 0; - ts.comp_recv_prev_time = 0; - ts.last_comp_with_ts = 0; - ts.comp_with_time_iters = 0; - } - - page_size = sysconf(_SC_PAGESIZE); - - dev_list = ibv_get_device_list(NULL); - if (!dev_list) { - perror("Failed to get IB devices list"); - return 1; - } - - if (!ib_devname) { - ib_dev = *dev_list; - if (!ib_dev) { - fprintf(stderr, "No IB devices found\n"); - return 1; - } - } else { - int i; - for (i = 0; dev_list[i]; ++i) - if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname)) - break; - ib_dev = dev_list[i]; - if (!ib_dev) { - fprintf(stderr, "IB device %s not found\n", ib_devname); - return 1; - } - } - - ctx = pp_init_ctx(ib_dev, size, rx_depth, ib_port, use_event); - if (!ctx) - return 1; - - routs = pp_post_recv(ctx, ctx->rx_depth); - if (routs < ctx->rx_depth) { - fprintf(stderr, "Couldn't post receive (%d)\n", routs); - return 1; - } - - if (use_event) - if (ibv_req_notify_cq(pp_cq(ctx), 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - - - if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) { - fprintf(stderr, "Couldn't get port info\n"); - return 1; - } - - my_dest.lid = ctx->portinfo.lid; - if (ctx->portinfo.link_layer != IBV_LINK_LAYER_ETHERNET && - !my_dest.lid) { - fprintf(stderr, "Couldn't get local LID\n"); - return 1; - } - - if (gidx >= 0) { - if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) { - fprintf(stderr, "can't read sgid of index %d\n", gidx); - return 1; - } - } else - memset(&my_dest.gid, 0, sizeof my_dest.gid); - - my_dest.qpn = ctx->qp->qp_num; - my_dest.psn = lrand48() & 0xffffff; - inet_ntop(AF_INET6, &my_dest.gid, gid, sizeof gid); - printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n", - my_dest.lid, my_dest.qpn, my_dest.psn, gid); - - - if (servername) - rem_dest = pp_client_exch_dest(servername, port, &my_dest); - else - rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, - &my_dest, gidx); - - if (!rem_dest) - return 1; - - inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid); - printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n", - rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid); - - if (servername) - if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest, - gidx)) - return 1; - - ctx->pending = PINGPONG_RECV_WRID; - - if (servername) { - if (pp_post_send(ctx)) { - fprintf(stderr, "Couldn't post send\n"); - return 1; - } - ctx->pending |= PINGPONG_SEND_WRID; - } - - if (gettimeofday(&start, NULL)) { - perror("gettimeofday"); - return 1; - } - - rcnt = scnt = 0; - while (rcnt < iters || scnt < iters) { - int ret; - - if (use_event) { - struct ibv_cq *ev_cq; - void *ev_ctx; - - if (ibv_get_cq_event(ctx->channel, &ev_cq, &ev_ctx)) { - fprintf(stderr, "Failed to get cq_event\n"); - return 1; - } - - ++num_cq_events; - - if (ev_cq != pp_cq(ctx)) { - fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq); - return 1; - } - - if (ibv_req_notify_cq(pp_cq(ctx), 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - } - - if (use_ts) { - struct ibv_poll_cq_attr attr = {}; - - do { - ret = ibv_start_poll(ctx->cq_s.cq_ex, &attr); - } while (!use_event && ret == ENOENT); - - if (ret) { - fprintf(stderr, "poll CQ failed %d\n", ret); - return ret; - } - ret = parse_single_wc(ctx, &scnt, &rcnt, &routs, - iters, - ctx->cq_s.cq_ex->wr_id, - ctx->cq_s.cq_ex->status, - ibv_wc_read_completion_ts(ctx->cq_s.cq_ex), - &ts); - if (ret) { - ibv_end_poll(ctx->cq_s.cq_ex); - return ret; - } - ret = ibv_next_poll(ctx->cq_s.cq_ex); - if (!ret) - ret = parse_single_wc(ctx, &scnt, &rcnt, &routs, - iters, - ctx->cq_s.cq_ex->wr_id, - ctx->cq_s.cq_ex->status, - ibv_wc_read_completion_ts(ctx->cq_s.cq_ex), - &ts); - ibv_end_poll(ctx->cq_s.cq_ex); - if (ret && ret != ENOENT) { - fprintf(stderr, "poll CQ failed %d\n", ret); - return ret; - } - } else { - int ne, i; - struct ibv_wc wc[2]; - - do { - ne = ibv_poll_cq(pp_cq(ctx), 2, wc); - if (ne < 0) { - fprintf(stderr, "poll CQ failed %d\n", ne); - return 1; - } - } while (!use_event && ne < 1); - - for (i = 0; i < ne; ++i) { - ret = parse_single_wc(ctx, &scnt, &rcnt, &routs, - iters, - wc[i].wr_id, - wc[i].status, - 0, &ts); - if (ret) { - fprintf(stderr, "parse WC failed %d\n", ne); - return 1; - } - } - } - } - - if (gettimeofday(&end, NULL)) { - perror("gettimeofday"); - return 1; - } - - { - float usec = (end.tv_sec - start.tv_sec) * 1000000 + - (end.tv_usec - start.tv_usec); - long long bytes = (long long) size * iters * 2; - - printf("%lld bytes in %.2f seconds = %.2f Mbit/sec\n", - bytes, usec / 1000000., bytes * 8. / usec); - printf("%d iters in %.2f seconds = %.2f usec/iter\n", - iters, usec / 1000000., usec / iters); - - if (use_ts && ts.comp_with_time_iters) { - printf("Max receive completion clock cycles = %" PRIu64 "\n", - ts.comp_recv_max_time_delta); - printf("Min receive completion clock cycles = %" PRIu64 "\n", - ts.comp_recv_min_time_delta); - printf("Average receive completion clock cycles = %f\n", - (double)ts.comp_recv_total_time_delta / ts.comp_with_time_iters); - } - } - - ibv_ack_cq_events(pp_cq(ctx), num_cq_events); - - if (pp_close_ctx(ctx)) - return 1; - - ibv_free_device_list(dev_list); - free(rem_dest); - - return 0; -} diff --git a/usr/rdma-core/libibverbs/examples/srq_pingpong.c b/usr/rdma-core/libibverbs/examples/srq_pingpong.c deleted file mode 100644 index 59ce0b2e7..000000000 --- a/usr/rdma-core/libibverbs/examples/srq_pingpong.c +++ /dev/null @@ -1,985 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pingpong.h" - -enum { - PINGPONG_RECV_WRID = 1, - PINGPONG_SEND_WRID = 2, - - MAX_QP = 256, -}; - -static int page_size; - -struct pingpong_context { - struct ibv_context *context; - struct ibv_comp_channel *channel; - struct ibv_pd *pd; - struct ibv_mr *mr; - struct ibv_cq *cq; - struct ibv_srq *srq; - struct ibv_qp *qp[MAX_QP]; - void *buf; - int size; - int send_flags; - int num_qp; - int rx_depth; - int pending[MAX_QP]; - struct ibv_port_attr portinfo; -}; - -struct pingpong_dest { - int lid; - int qpn; - int psn; - union ibv_gid gid; -}; - -static int pp_connect_ctx(struct pingpong_context *ctx, int port, enum ibv_mtu mtu, - int sl, const struct pingpong_dest *my_dest, - const struct pingpong_dest *dest, int sgid_idx) -{ - int i; - - for (i = 0; i < ctx->num_qp; ++i) { - struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_RTR, - .path_mtu = mtu, - .dest_qp_num = dest[i].qpn, - .rq_psn = dest[i].psn, - .max_dest_rd_atomic = 1, - .min_rnr_timer = 12, - .ah_attr = { - .is_global = 0, - .dlid = dest[i].lid, - .sl = sl, - .src_path_bits = 0, - .port_num = port - } - }; - - if (dest->gid.global.interface_id) { - attr.ah_attr.is_global = 1; - attr.ah_attr.grh.hop_limit = 1; - attr.ah_attr.grh.dgid = dest->gid; - attr.ah_attr.grh.sgid_index = sgid_idx; - } - if (ibv_modify_qp(ctx->qp[i], &attr, - IBV_QP_STATE | - IBV_QP_AV | - IBV_QP_PATH_MTU | - IBV_QP_DEST_QPN | - IBV_QP_RQ_PSN | - IBV_QP_MAX_DEST_RD_ATOMIC | - IBV_QP_MIN_RNR_TIMER)) { - fprintf(stderr, "Failed to modify QP[%d] to RTR\n", i); - return 1; - } - - attr.qp_state = IBV_QPS_RTS; - attr.timeout = 14; - attr.retry_cnt = 7; - attr.rnr_retry = 7; - attr.sq_psn = my_dest[i].psn; - attr.max_rd_atomic = 1; - if (ibv_modify_qp(ctx->qp[i], &attr, - IBV_QP_STATE | - IBV_QP_TIMEOUT | - IBV_QP_RETRY_CNT | - IBV_QP_RNR_RETRY | - IBV_QP_SQ_PSN | - IBV_QP_MAX_QP_RD_ATOMIC)) { - fprintf(stderr, "Failed to modify QP[%d] to RTS\n", i); - return 1; - } - } - - return 0; -} - -static struct pingpong_dest *pp_client_exch_dest(const char *servername, int port, - const struct pingpong_dest *my_dest) -{ - struct addrinfo *res, *t; - struct addrinfo hints = { - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - char *service; - char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"]; - int n; - int r; - int i; - int sockfd = -1; - struct pingpong_dest *rem_dest = NULL; - char gid[33]; - - if (asprintf(&service, "%d", port) < 0) - return NULL; - - n = getaddrinfo(servername, service, &hints, &res); - - if (n < 0) { - fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port); - free(service); - return NULL; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - if (!connect(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port); - return NULL; - } - - for (i = 0; i < MAX_QP; ++i) { - gid_to_wire_gid(&my_dest[i].gid, gid); - sprintf(msg, "%04x:%06x:%06x:%s", my_dest[i].lid, - my_dest[i].qpn, my_dest[i].psn, gid); - if (write(sockfd, msg, sizeof msg) != sizeof msg) { - fprintf(stderr, "Couldn't send local address\n"); - goto out; - } - } - - rem_dest = malloc(MAX_QP * sizeof *rem_dest); - if (!rem_dest) - goto out; - - for (i = 0; i < MAX_QP; ++i) { - n = 0; - while (n < sizeof msg) { - r = read(sockfd, msg + n, sizeof msg - n); - if (r < 0) { - perror("client read"); - fprintf(stderr, "%d/%d: Couldn't read remote address [%d]\n", - n, (int) sizeof msg, i); - goto out; - } - n += r; - } - - sscanf(msg, "%x:%x:%x:%s", &rem_dest[i].lid, &rem_dest[i].qpn, - &rem_dest[i].psn, gid); - wire_gid_to_gid(gid, &rem_dest[i].gid); - } - - if (write(sockfd, "done", sizeof "done") != sizeof "done") { - perror("client write"); - goto out; - } -out: - close(sockfd); - return rem_dest; -} - -static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, - int ib_port, enum ibv_mtu mtu, - int port, int sl, - const struct pingpong_dest *my_dest, - int sgid_idx) -{ - struct addrinfo *res, *t; - struct addrinfo hints = { - .ai_flags = AI_PASSIVE, - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - char *service; - char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"]; - int n; - int r; - int i; - int sockfd = -1, connfd; - struct pingpong_dest *rem_dest = NULL; - char gid[33]; - - if (asprintf(&service, "%d", port) < 0) - return NULL; - - n = getaddrinfo(NULL, service, &hints, &res); - - if (n < 0) { - fprintf(stderr, "%s for port %d\n", gai_strerror(n), port); - free(service); - return NULL; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - n = 1; - - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n); - - if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't listen to port %d\n", port); - return NULL; - } - - listen(sockfd, 1); - connfd = accept(sockfd, NULL, NULL); - close(sockfd); - if (connfd < 0) { - fprintf(stderr, "accept() failed\n"); - return NULL; - } - - rem_dest = malloc(MAX_QP * sizeof *rem_dest); - if (!rem_dest) - goto out; - - for (i = 0; i < MAX_QP; ++i) { - n = 0; - while (n < sizeof msg) { - r = read(connfd, msg + n, sizeof msg - n); - if (r < 0) { - perror("server read"); - fprintf(stderr, "%d/%d: Couldn't read remote address [%d]\n", - n, (int) sizeof msg, i); - goto out; - } - n += r; - } - - sscanf(msg, "%x:%x:%x:%s", &rem_dest[i].lid, &rem_dest[i].qpn, - &rem_dest[i].psn, gid); - wire_gid_to_gid(gid, &rem_dest[i].gid); - } - - if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest, - sgid_idx)) { - fprintf(stderr, "Couldn't connect to remote QP\n"); - free(rem_dest); - rem_dest = NULL; - goto out; - } - - for (i = 0; i < MAX_QP; ++i) { - gid_to_wire_gid(&my_dest[i].gid, gid); - sprintf(msg, "%04x:%06x:%06x:%s", my_dest[i].lid, - my_dest[i].qpn, my_dest[i].psn, gid); - if (write(connfd, msg, sizeof msg) != sizeof msg) { - fprintf(stderr, "Couldn't send local address\n"); - free(rem_dest); - rem_dest = NULL; - goto out; - } - } - - if (read(connfd, msg, sizeof msg) != sizeof "done") { - perror("client write"); - free(rem_dest); - rem_dest = NULL; - goto out; - } - -out: - close(connfd); - return rem_dest; -} - -static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, - int num_qp, int rx_depth, int port, - int use_event) -{ - struct pingpong_context *ctx; - int i; - - ctx = calloc(1, sizeof *ctx); - if (!ctx) - return NULL; - - ctx->size = size; - ctx->send_flags = IBV_SEND_SIGNALED; - ctx->num_qp = num_qp; - ctx->rx_depth = rx_depth; - - ctx->buf = memalign(page_size, size); - if (!ctx->buf) { - fprintf(stderr, "Couldn't allocate work buf.\n"); - goto clean_ctx; - } - - memset(ctx->buf, 0, size); - - ctx->context = ibv_open_device(ib_dev); - if (!ctx->context) { - fprintf(stderr, "Couldn't get context for %s\n", - ibv_get_device_name(ib_dev)); - goto clean_buffer; - } - - if (use_event) { - ctx->channel = ibv_create_comp_channel(ctx->context); - if (!ctx->channel) { - fprintf(stderr, "Couldn't create completion channel\n"); - goto clean_device; - } - } else - ctx->channel = NULL; - - ctx->pd = ibv_alloc_pd(ctx->context); - if (!ctx->pd) { - fprintf(stderr, "Couldn't allocate PD\n"); - goto clean_comp_channel; - } - - ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size, IBV_ACCESS_LOCAL_WRITE); - if (!ctx->mr) { - fprintf(stderr, "Couldn't register MR\n"); - goto clean_pd; - } - - ctx->cq = ibv_create_cq(ctx->context, rx_depth + num_qp, NULL, - ctx->channel, 0); - if (!ctx->cq) { - fprintf(stderr, "Couldn't create CQ\n"); - goto clean_mr; - } - - { - struct ibv_srq_init_attr attr = { - .attr = { - .max_wr = rx_depth, - .max_sge = 1 - } - }; - - ctx->srq = ibv_create_srq(ctx->pd, &attr); - if (!ctx->srq) { - fprintf(stderr, "Couldn't create SRQ\n"); - goto clean_cq; - } - } - - for (i = 0; i < num_qp; ++i) { - struct ibv_qp_attr attr; - struct ibv_qp_init_attr init_attr = { - .send_cq = ctx->cq, - .recv_cq = ctx->cq, - .srq = ctx->srq, - .cap = { - .max_send_wr = 1, - .max_send_sge = 1, - }, - .qp_type = IBV_QPT_RC - }; - - ctx->qp[i] = ibv_create_qp(ctx->pd, &init_attr); - if (!ctx->qp[i]) { - fprintf(stderr, "Couldn't create QP[%d]\n", i); - goto clean_qps; - } - ibv_query_qp(ctx->qp[i], &attr, IBV_QP_CAP, &init_attr); - if (init_attr.cap.max_inline_data >= size) { - ctx->send_flags |= IBV_SEND_INLINE; - } - } - - for (i = 0; i < num_qp; ++i) { - struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_INIT, - .pkey_index = 0, - .port_num = port, - .qp_access_flags = 0 - }; - - if (ibv_modify_qp(ctx->qp[i], &attr, - IBV_QP_STATE | - IBV_QP_PKEY_INDEX | - IBV_QP_PORT | - IBV_QP_ACCESS_FLAGS)) { - fprintf(stderr, "Failed to modify QP[%d] to INIT\n", i); - goto clean_qps_full; - } - } - - return ctx; - -clean_qps_full: - i = num_qp; - -clean_qps: - for (--i; i >= 0; --i) - ibv_destroy_qp(ctx->qp[i]); - - ibv_destroy_srq(ctx->srq); - -clean_cq: - ibv_destroy_cq(ctx->cq); - -clean_mr: - ibv_dereg_mr(ctx->mr); - -clean_pd: - ibv_dealloc_pd(ctx->pd); - -clean_comp_channel: - if (ctx->channel) - ibv_destroy_comp_channel(ctx->channel); - -clean_device: - ibv_close_device(ctx->context); - -clean_buffer: - free(ctx->buf); - -clean_ctx: - free(ctx); - - return NULL; -} - -static int pp_close_ctx(struct pingpong_context *ctx, int num_qp) -{ - int i; - - for (i = 0; i < num_qp; ++i) { - if (ibv_destroy_qp(ctx->qp[i])) { - fprintf(stderr, "Couldn't destroy QP[%d]\n", i); - return 1; - } - } - - if (ibv_destroy_srq(ctx->srq)) { - fprintf(stderr, "Couldn't destroy SRQ\n"); - return 1; - } - - if (ibv_destroy_cq(ctx->cq)) { - fprintf(stderr, "Couldn't destroy CQ\n"); - return 1; - } - - if (ibv_dereg_mr(ctx->mr)) { - fprintf(stderr, "Couldn't deregister MR\n"); - return 1; - } - - if (ibv_dealloc_pd(ctx->pd)) { - fprintf(stderr, "Couldn't deallocate PD\n"); - return 1; - } - - if (ctx->channel) { - if (ibv_destroy_comp_channel(ctx->channel)) { - fprintf(stderr, "Couldn't destroy completion channel\n"); - return 1; - } - } - - if (ibv_close_device(ctx->context)) { - fprintf(stderr, "Couldn't release context\n"); - return 1; - } - - free(ctx->buf); - free(ctx); - - return 0; -} - -static int pp_post_recv(struct pingpong_context *ctx, int n) -{ - struct ibv_sge list = { - .addr = (uintptr_t) ctx->buf, - .length = ctx->size, - .lkey = ctx->mr->lkey - }; - struct ibv_recv_wr wr = { - .wr_id = PINGPONG_RECV_WRID, - .sg_list = &list, - .num_sge = 1, - }; - struct ibv_recv_wr *bad_wr; - int i; - - for (i = 0; i < n; ++i) - if (ibv_post_srq_recv(ctx->srq, &wr, &bad_wr)) - break; - - return i; -} - -static int pp_post_send(struct pingpong_context *ctx, int qp_index) -{ - struct ibv_sge list = { - .addr = (uintptr_t) ctx->buf, - .length = ctx->size, - .lkey = ctx->mr->lkey - }; - struct ibv_send_wr wr = { - .wr_id = PINGPONG_SEND_WRID, - .sg_list = &list, - .num_sge = 1, - .opcode = IBV_WR_SEND, - .send_flags = ctx->send_flags, - }; - struct ibv_send_wr *bad_wr; - - return ibv_post_send(ctx->qp[qp_index], &wr, &bad_wr); -} - -static int find_qp(int qpn, struct pingpong_context *ctx, int num_qp) -{ - int i; - - for (i = 0; i < num_qp; ++i) - if (ctx->qp[i]->qp_num == qpn) - return i; - - return -1; -} - -static void usage(const char *argv0) -{ - printf("Usage:\n"); - printf(" %s start a server and wait for connection\n", argv0); - printf(" %s connect to server at \n", argv0); - printf("\n"); - printf("Options:\n"); - printf(" -p, --port= listen on/connect to port (default 18515)\n"); - printf(" -d, --ib-dev= use IB device (default first device found)\n"); - printf(" -i, --ib-port= use port of IB device (default 1)\n"); - printf(" -s, --size= size of message to exchange (default 4096)\n"); - printf(" -m, --mtu= path MTU (default 1024)\n"); - printf(" -q, --num-qp= number of QPs to use (default 16)\n"); - printf(" -r, --rx-depth= number of receives to post at a time (default 500)\n"); - printf(" -n, --iters= number of exchanges per QP(default 1000)\n"); - printf(" -l, --sl= service level value\n"); - printf(" -e, --events sleep on CQ events (default poll)\n"); - printf(" -g, --gid-idx= local port gid index\n"); -} - -int main(int argc, char *argv[]) -{ - struct ibv_device **dev_list; - struct ibv_device *ib_dev; - struct ibv_wc *wc; - struct pingpong_context *ctx; - struct pingpong_dest my_dest[MAX_QP]; - struct pingpong_dest *rem_dest; - struct timeval start, end; - char *ib_devname = NULL; - char *servername = NULL; - unsigned int port = 18515; - int ib_port = 1; - unsigned int size = 4096; - enum ibv_mtu mtu = IBV_MTU_1024; - unsigned int num_qp = 16; - unsigned int rx_depth = 500; - unsigned int iters = 1000; - int use_event = 0; - int routs; - int rcnt, scnt; - int num_wc; - int i; - int num_cq_events = 0; - int sl = 0; - int gidx = -1; - char gid[33]; - - srand48(getpid() * time(NULL)); - - while (1) { - int c; - - static struct option long_options[] = { - { .name = "port", .has_arg = 1, .val = 'p' }, - { .name = "ib-dev", .has_arg = 1, .val = 'd' }, - { .name = "ib-port", .has_arg = 1, .val = 'i' }, - { .name = "size", .has_arg = 1, .val = 's' }, - { .name = "mtu", .has_arg = 1, .val = 'm' }, - { .name = "num-qp", .has_arg = 1, .val = 'q' }, - { .name = "rx-depth", .has_arg = 1, .val = 'r' }, - { .name = "iters", .has_arg = 1, .val = 'n' }, - { .name = "sl", .has_arg = 1, .val = 'l' }, - { .name = "events", .has_arg = 0, .val = 'e' }, - { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - {} - }; - - c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:eg:", - long_options, NULL); - if (c == -1) - break; - - switch (c) { - case 'p': - port = strtoul(optarg, NULL, 0); - if (port > 65535) { - usage(argv[0]); - return 1; - } - break; - - case 'd': - ib_devname = strdupa(optarg); - break; - - case 'i': - ib_port = strtol(optarg, NULL, 0); - if (ib_port < 1) { - usage(argv[0]); - return 1; - } - break; - - case 's': - size = strtoul(optarg, NULL, 0); - if (size < 1) { - usage(argv[0]); - return 1; - } - break; - - case 'm': - mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0)); - if (mtu == 0) { - usage(argv[0]); - return 1; - } - break; - - case 'q': - num_qp = strtoul(optarg, NULL, 0); - break; - - case 'r': - rx_depth = strtoul(optarg, NULL, 0); - break; - - case 'n': - iters = strtoul(optarg, NULL, 0); - break; - - case 'l': - sl = strtol(optarg, NULL, 0); - break; - - case 'e': - ++use_event; - break; - - case 'g': - gidx = strtol(optarg, NULL, 0); - break; - - default: - usage(argv[0]); - return 1; - } - } - - if (optind == argc - 1) - servername = strdupa(argv[optind]); - else if (optind < argc) { - usage(argv[0]); - return 1; - } - - if (num_qp > rx_depth) { - fprintf(stderr, "rx_depth %d is too small for %d QPs -- " - "must have at least one receive per QP.\n", - rx_depth, num_qp); - return 1; - } - - num_wc = num_qp + rx_depth; - wc = alloca(num_wc * sizeof *wc); - - page_size = sysconf(_SC_PAGESIZE); - - dev_list = ibv_get_device_list(NULL); - if (!dev_list) { - perror("Failed to get IB devices list"); - return 1; - } - - if (!ib_devname) { - ib_dev = *dev_list; - if (!ib_dev) { - fprintf(stderr, "No IB devices found\n"); - return 1; - } - } else { - for (i = 0; dev_list[i]; ++i) - if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname)) - break; - ib_dev = dev_list[i]; - if (!ib_dev) { - fprintf(stderr, "IB device %s not found\n", ib_devname); - return 1; - } - } - - ctx = pp_init_ctx(ib_dev, size, num_qp, rx_depth, ib_port, use_event); - if (!ctx) - return 1; - - routs = pp_post_recv(ctx, ctx->rx_depth); - if (routs < ctx->rx_depth) { - fprintf(stderr, "Couldn't post receive (%d)\n", routs); - return 1; - } - - if (use_event) - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - - memset(my_dest, 0, sizeof my_dest); - - if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) { - fprintf(stderr, "Couldn't get port info\n"); - return 1; - } - for (i = 0; i < num_qp; ++i) { - my_dest[i].qpn = ctx->qp[i]->qp_num; - my_dest[i].psn = lrand48() & 0xffffff; - my_dest[i].lid = ctx->portinfo.lid; - if (ctx->portinfo.link_layer != IBV_LINK_LAYER_ETHERNET - && !my_dest[i].lid) { - fprintf(stderr, "Couldn't get local LID\n"); - return 1; - } - - if (gidx >= 0) { - if (ibv_query_gid(ctx->context, ib_port, gidx, - &my_dest[i].gid)) { - fprintf(stderr, "Could not get local gid for " - "gid index %d\n", gidx); - return 1; - } - } else - memset(&my_dest[i].gid, 0, sizeof my_dest[i].gid); - - inet_ntop(AF_INET6, &my_dest[i].gid, gid, sizeof gid); - printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, " - "GID %s\n", my_dest[i].lid, my_dest[i].qpn, - my_dest[i].psn, gid); - } - - if (servername) - rem_dest = pp_client_exch_dest(servername, port, my_dest); - else - rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, - my_dest, gidx); - - if (!rem_dest) - return 1; - - inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid); - - for (i = 0; i < num_qp; ++i) { - inet_ntop(AF_INET6, &rem_dest[i].gid, gid, sizeof gid); - printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, " - "GID %s\n", rem_dest[i].lid, rem_dest[i].qpn, - rem_dest[i].psn, gid); - } - - if (servername) - if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest, - gidx)) - return 1; - - if (servername) - for (i = 0; i < num_qp; ++i) { - if (pp_post_send(ctx, i)) { - fprintf(stderr, "Couldn't post send\n"); - return 1; - } - ctx->pending[i] = PINGPONG_SEND_WRID | PINGPONG_RECV_WRID; - } - else - for (i = 0; i < num_qp; ++i) - ctx->pending[i] = PINGPONG_RECV_WRID; - - if (gettimeofday(&start, NULL)) { - perror("gettimeofday"); - return 1; - } - - rcnt = scnt = 0; - while (rcnt < iters || scnt < iters) { - if (use_event) { - struct ibv_cq *ev_cq; - void *ev_ctx; - - if (ibv_get_cq_event(ctx->channel, &ev_cq, &ev_ctx)) { - fprintf(stderr, "Failed to get cq_event\n"); - return 1; - } - - ++num_cq_events; - - if (ev_cq != ctx->cq) { - fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq); - return 1; - } - - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - } - - { - int ne, qp_ind; - - do { - ne = ibv_poll_cq(ctx->cq, num_wc, wc); - if (ne < 0) { - fprintf(stderr, "poll CQ failed %d\n", ne); - return 1; - } - } while (!use_event && ne < 1); - - for (i = 0; i < ne; ++i) { - if (wc[i].status != IBV_WC_SUCCESS) { - fprintf(stderr, "Failed status %s (%d) for wr_id %d\n", - ibv_wc_status_str(wc[i].status), - wc[i].status, (int) wc[i].wr_id); - return 1; - } - - qp_ind = find_qp(wc[i].qp_num, ctx, num_qp); - if (qp_ind < 0) { - fprintf(stderr, "Couldn't find QPN %06x\n", - wc[i].qp_num); - return 1; - } - - switch ((int) wc[i].wr_id) { - case PINGPONG_SEND_WRID: - ++scnt; - break; - - case PINGPONG_RECV_WRID: - if (--routs <= num_qp) { - routs += pp_post_recv(ctx, ctx->rx_depth - routs); - if (routs < ctx->rx_depth) { - fprintf(stderr, - "Couldn't post receive (%d)\n", - routs); - return 1; - } - } - - ++rcnt; - break; - - default: - fprintf(stderr, "Completion for unknown wr_id %d\n", - (int) wc[i].wr_id); - return 1; - } - - ctx->pending[qp_ind] &= ~(int) wc[i].wr_id; - if (scnt < iters && !ctx->pending[qp_ind]) { - if (pp_post_send(ctx, qp_ind)) { - fprintf(stderr, "Couldn't post send\n"); - return 1; - } - ctx->pending[qp_ind] = PINGPONG_RECV_WRID | - PINGPONG_SEND_WRID; - } - - } - } - } - - if (gettimeofday(&end, NULL)) { - perror("gettimeofday"); - return 1; - } - - { - float usec = (end.tv_sec - start.tv_sec) * 1000000 + - (end.tv_usec - start.tv_usec); - long long bytes = (long long) size * iters * 2; - - printf("%lld bytes in %.2f seconds = %.2f Mbit/sec\n", - bytes, usec / 1000000., bytes * 8. / usec); - printf("%d iters in %.2f seconds = %.2f usec/iter\n", - iters, usec / 1000000., usec / iters); - } - - ibv_ack_cq_events(ctx->cq, num_cq_events); - - if (pp_close_ctx(ctx, num_qp)) - return 1; - - ibv_free_device_list(dev_list); - free(rem_dest); - - return 0; -} diff --git a/usr/rdma-core/libibverbs/examples/uc_pingpong.c b/usr/rdma-core/libibverbs/examples/uc_pingpong.c deleted file mode 100644 index 2720ab337..000000000 --- a/usr/rdma-core/libibverbs/examples/uc_pingpong.c +++ /dev/null @@ -1,854 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pingpong.h" - -enum { - PINGPONG_RECV_WRID = 1, - PINGPONG_SEND_WRID = 2, -}; - -static int page_size; - -struct pingpong_context { - struct ibv_context *context; - struct ibv_comp_channel *channel; - struct ibv_pd *pd; - struct ibv_mr *mr; - struct ibv_cq *cq; - struct ibv_qp *qp; - void *buf; - int size; - int send_flags; - int rx_depth; - int pending; - struct ibv_port_attr portinfo; -}; - -struct pingpong_dest { - int lid; - int qpn; - int psn; - union ibv_gid gid; -}; - -static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, - enum ibv_mtu mtu, int sl, - struct pingpong_dest *dest, int sgid_idx) -{ - struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_RTR, - .path_mtu = mtu, - .dest_qp_num = dest->qpn, - .rq_psn = dest->psn, - .ah_attr = { - .is_global = 0, - .dlid = dest->lid, - .sl = sl, - .src_path_bits = 0, - .port_num = port - } - }; - - if (dest->gid.global.interface_id) { - attr.ah_attr.is_global = 1; - attr.ah_attr.grh.hop_limit = 1; - attr.ah_attr.grh.dgid = dest->gid; - attr.ah_attr.grh.sgid_index = sgid_idx; - } - if (ibv_modify_qp(ctx->qp, &attr, - IBV_QP_STATE | - IBV_QP_AV | - IBV_QP_PATH_MTU | - IBV_QP_DEST_QPN | - IBV_QP_RQ_PSN)) { - fprintf(stderr, "Failed to modify QP to RTR\n"); - return 1; - } - - attr.qp_state = IBV_QPS_RTS; - attr.sq_psn = my_psn; - if (ibv_modify_qp(ctx->qp, &attr, - IBV_QP_STATE | - IBV_QP_SQ_PSN)) { - fprintf(stderr, "Failed to modify QP to RTS\n"); - return 1; - } - - return 0; -} - -static struct pingpong_dest *pp_client_exch_dest(const char *servername, int port, - const struct pingpong_dest *my_dest) -{ - struct addrinfo *res, *t; - struct addrinfo hints = { - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - char *service; - char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"]; - int n; - int sockfd = -1; - struct pingpong_dest *rem_dest = NULL; - char gid[33]; - - if (asprintf(&service, "%d", port) < 0) - return NULL; - - n = getaddrinfo(servername, service, &hints, &res); - - if (n < 0) { - fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port); - free(service); - return NULL; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - if (!connect(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port); - return NULL; - } - - gid_to_wire_gid(&my_dest->gid, gid); - sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, - my_dest->psn, gid); - if (write(sockfd, msg, sizeof msg) != sizeof msg) { - fprintf(stderr, "Couldn't send local address\n"); - goto out; - } - - if (read(sockfd, msg, sizeof msg) != sizeof msg || - write(sockfd, "done", sizeof "done") != sizeof "done") { - perror("client read/write"); - fprintf(stderr, "Couldn't read/write remote address\n"); - goto out; - } - - - rem_dest = malloc(sizeof *rem_dest); - if (!rem_dest) - goto out; - - sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, - &rem_dest->psn, gid); - wire_gid_to_gid(gid, &rem_dest->gid); - -out: - close(sockfd); - return rem_dest; -} - -static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, - int ib_port, enum ibv_mtu mtu, - int port, int sl, - const struct pingpong_dest *my_dest, - int sgid_idx) -{ - struct addrinfo *res, *t; - struct addrinfo hints = { - .ai_flags = AI_PASSIVE, - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - char *service; - char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"]; - int n; - int sockfd = -1, connfd; - struct pingpong_dest *rem_dest = NULL; - char gid[33]; - - if (asprintf(&service, "%d", port) < 0) - return NULL; - - n = getaddrinfo(NULL, service, &hints, &res); - - if (n < 0) { - fprintf(stderr, "%s for port %d\n", gai_strerror(n), port); - free(service); - return NULL; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - n = 1; - - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n); - - if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't listen to port %d\n", port); - return NULL; - } - - listen(sockfd, 1); - connfd = accept(sockfd, NULL, NULL); - close(sockfd); - if (connfd < 0) { - fprintf(stderr, "accept() failed\n"); - return NULL; - } - - n = read(connfd, msg, sizeof msg); - if (n != sizeof msg) { - perror("server read"); - fprintf(stderr, "%d/%d: Couldn't read remote address\n", n, (int) sizeof msg); - goto out; - } - - rem_dest = malloc(sizeof *rem_dest); - if (!rem_dest) - goto out; - - sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, - &rem_dest->psn, gid); - wire_gid_to_gid(gid, &rem_dest->gid); - - if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest, - sgid_idx)) { - fprintf(stderr, "Couldn't connect to remote QP\n"); - free(rem_dest); - rem_dest = NULL; - goto out; - } - - - gid_to_wire_gid(&my_dest->gid, gid); - sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, - my_dest->psn, gid); - if (write(connfd, msg, sizeof msg) != sizeof msg || - read(connfd, msg, sizeof msg) != sizeof "done") { - fprintf(stderr, "Couldn't send/recv local address\n"); - free(rem_dest); - rem_dest = NULL; - goto out; - } - -out: - close(connfd); - return rem_dest; -} - -static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, - int rx_depth, int port, - int use_event) -{ - struct pingpong_context *ctx; - - ctx = calloc(1, sizeof *ctx); - if (!ctx) - return NULL; - - ctx->size = size; - ctx->send_flags = IBV_SEND_SIGNALED; - ctx->rx_depth = rx_depth; - - ctx->buf = memalign(page_size, size); - if (!ctx->buf) { - fprintf(stderr, "Couldn't allocate work buf.\n"); - goto clean_ctx; - } - - /* FIXME memset(ctx->buf, 0, size); */ - memset(ctx->buf, 0x7b, size); - - ctx->context = ibv_open_device(ib_dev); - if (!ctx->context) { - fprintf(stderr, "Couldn't get context for %s\n", - ibv_get_device_name(ib_dev)); - goto clean_buffer; - } - - if (use_event) { - ctx->channel = ibv_create_comp_channel(ctx->context); - if (!ctx->channel) { - fprintf(stderr, "Couldn't create completion channel\n"); - goto clean_device; - } - } else - ctx->channel = NULL; - - ctx->pd = ibv_alloc_pd(ctx->context); - if (!ctx->pd) { - fprintf(stderr, "Couldn't allocate PD\n"); - goto clean_comp_channel; - } - - ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size, IBV_ACCESS_LOCAL_WRITE); - if (!ctx->mr) { - fprintf(stderr, "Couldn't register MR\n"); - goto clean_pd; - } - - ctx->cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL, - ctx->channel, 0); - if (!ctx->cq) { - fprintf(stderr, "Couldn't create CQ\n"); - goto clean_mr; - } - - { - struct ibv_qp_attr attr; - struct ibv_qp_init_attr init_attr = { - .send_cq = ctx->cq, - .recv_cq = ctx->cq, - .cap = { - .max_send_wr = 1, - .max_recv_wr = rx_depth, - .max_send_sge = 1, - .max_recv_sge = 1 - }, - .qp_type = IBV_QPT_UC - }; - - ctx->qp = ibv_create_qp(ctx->pd, &init_attr); - if (!ctx->qp) { - fprintf(stderr, "Couldn't create QP\n"); - goto clean_cq; - } - ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr); - if (init_attr.cap.max_inline_data >= size) { - ctx->send_flags |= IBV_SEND_INLINE; - } - } - - { - struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_INIT, - .pkey_index = 0, - .port_num = port, - .qp_access_flags = 0 - }; - - if (ibv_modify_qp(ctx->qp, &attr, - IBV_QP_STATE | - IBV_QP_PKEY_INDEX | - IBV_QP_PORT | - IBV_QP_ACCESS_FLAGS)) { - fprintf(stderr, "Failed to modify QP to INIT\n"); - goto clean_qp; - } - } - - return ctx; - -clean_qp: - ibv_destroy_qp(ctx->qp); - -clean_cq: - ibv_destroy_cq(ctx->cq); - -clean_mr: - ibv_dereg_mr(ctx->mr); - -clean_pd: - ibv_dealloc_pd(ctx->pd); - -clean_comp_channel: - if (ctx->channel) - ibv_destroy_comp_channel(ctx->channel); - -clean_device: - ibv_close_device(ctx->context); - -clean_buffer: - free(ctx->buf); - -clean_ctx: - free(ctx); - - return NULL; -} - -static int pp_close_ctx(struct pingpong_context *ctx) -{ - if (ibv_destroy_qp(ctx->qp)) { - fprintf(stderr, "Couldn't destroy QP\n"); - return 1; - } - - if (ibv_destroy_cq(ctx->cq)) { - fprintf(stderr, "Couldn't destroy CQ\n"); - return 1; - } - - if (ibv_dereg_mr(ctx->mr)) { - fprintf(stderr, "Couldn't deregister MR\n"); - return 1; - } - - if (ibv_dealloc_pd(ctx->pd)) { - fprintf(stderr, "Couldn't deallocate PD\n"); - return 1; - } - - if (ctx->channel) { - if (ibv_destroy_comp_channel(ctx->channel)) { - fprintf(stderr, "Couldn't destroy completion channel\n"); - return 1; - } - } - - if (ibv_close_device(ctx->context)) { - fprintf(stderr, "Couldn't release context\n"); - return 1; - } - - free(ctx->buf); - free(ctx); - - return 0; -} - -static int pp_post_recv(struct pingpong_context *ctx, int n) -{ - struct ibv_sge list = { - .addr = (uintptr_t) ctx->buf, - .length = ctx->size, - .lkey = ctx->mr->lkey - }; - struct ibv_recv_wr wr = { - .wr_id = PINGPONG_RECV_WRID, - .sg_list = &list, - .num_sge = 1, - }; - struct ibv_recv_wr *bad_wr; - int i; - - for (i = 0; i < n; ++i) - if (ibv_post_recv(ctx->qp, &wr, &bad_wr)) - break; - - return i; -} - -static int pp_post_send(struct pingpong_context *ctx) -{ - struct ibv_sge list = { - .addr = (uintptr_t) ctx->buf, - .length = ctx->size, - .lkey = ctx->mr->lkey - }; - struct ibv_send_wr wr = { - .wr_id = PINGPONG_SEND_WRID, - .sg_list = &list, - .num_sge = 1, - .opcode = IBV_WR_SEND, - .send_flags = ctx->send_flags, - }; - struct ibv_send_wr *bad_wr; - - return ibv_post_send(ctx->qp, &wr, &bad_wr); -} - -static void usage(const char *argv0) -{ - printf("Usage:\n"); - printf(" %s start a server and wait for connection\n", argv0); - printf(" %s connect to server at \n", argv0); - printf("\n"); - printf("Options:\n"); - printf(" -p, --port= listen on/connect to port (default 18515)\n"); - printf(" -d, --ib-dev= use IB device (default first device found)\n"); - printf(" -i, --ib-port= use port of IB device (default 1)\n"); - printf(" -s, --size= size of message to exchange (default 4096)\n"); - printf(" -m, --mtu= path MTU (default 1024)\n"); - printf(" -r, --rx-depth= number of receives to post at a time (default 500)\n"); - printf(" -n, --iters= number of exchanges (default 1000)\n"); - printf(" -l, --sl= service level value\n"); - printf(" -e, --events sleep on CQ events (default poll)\n"); - printf(" -g, --gid-idx= local port gid index\n"); -} - -int main(int argc, char *argv[]) -{ - struct ibv_device **dev_list; - struct ibv_device *ib_dev; - struct pingpong_context *ctx; - struct pingpong_dest my_dest; - struct pingpong_dest *rem_dest; - struct timeval start, end; - char *ib_devname = NULL; - char *servername = NULL; - unsigned int port = 18515; - int ib_port = 1; - unsigned int size = 4096; - enum ibv_mtu mtu = IBV_MTU_1024; - unsigned int rx_depth = 500; - unsigned int iters = 1000; - int use_event = 0; - int routs; - int rcnt, scnt; - int num_cq_events = 0; - int sl = 0; - int gidx = -1; - char gid[33]; - - srand48(getpid() * time(NULL)); - - while (1) { - int c; - - static struct option long_options[] = { - { .name = "port", .has_arg = 1, .val = 'p' }, - { .name = "ib-dev", .has_arg = 1, .val = 'd' }, - { .name = "ib-port", .has_arg = 1, .val = 'i' }, - { .name = "size", .has_arg = 1, .val = 's' }, - { .name = "mtu", .has_arg = 1, .val = 'm' }, - { .name = "rx-depth", .has_arg = 1, .val = 'r' }, - { .name = "iters", .has_arg = 1, .val = 'n' }, - { .name = "sl", .has_arg = 1, .val = 'l' }, - { .name = "events", .has_arg = 0, .val = 'e' }, - { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - {} - }; - - c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:", - long_options, NULL); - if (c == -1) - break; - - switch (c) { - case 'p': - port = strtoul(optarg, NULL, 0); - if (port > 65535) { - usage(argv[0]); - return 1; - } - break; - - case 'd': - ib_devname = strdupa(optarg); - break; - - case 'i': - ib_port = strtol(optarg, NULL, 0); - if (ib_port < 1) { - usage(argv[0]); - return 1; - } - break; - - case 's': - size = strtoul(optarg, NULL, 0); - break; - - case 'm': - mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0)); - if (mtu == 0) { - usage(argv[0]); - return 1; - } - break; - - case 'r': - rx_depth = strtoul(optarg, NULL, 0); - break; - - case 'n': - iters = strtoul(optarg, NULL, 0); - break; - - case 'l': - sl = strtol(optarg, NULL, 0); - break; - - case 'e': - ++use_event; - break; - - case 'g': - gidx = strtol(optarg, NULL, 0); - break; - - default: - usage(argv[0]); - return 1; - } - } - - if (optind == argc - 1) - servername = strdupa(argv[optind]); - else if (optind < argc) { - usage(argv[0]); - return 1; - } - - page_size = sysconf(_SC_PAGESIZE); - - dev_list = ibv_get_device_list(NULL); - if (!dev_list) { - perror("Failed to get IB devices list"); - return 1; - } - - if (!ib_devname) { - ib_dev = *dev_list; - if (!ib_dev) { - fprintf(stderr, "No IB devices found\n"); - return 1; - } - } else { - int i; - for (i = 0; dev_list[i]; ++i) - if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname)) - break; - ib_dev = dev_list[i]; - if (!ib_dev) { - fprintf(stderr, "IB device %s not found\n", ib_devname); - return 1; - } - } - - ctx = pp_init_ctx(ib_dev, size, rx_depth, ib_port, use_event); - if (!ctx) - return 1; - - routs = pp_post_recv(ctx, ctx->rx_depth); - if (routs < ctx->rx_depth) { - fprintf(stderr, "Couldn't post receive (%d)\n", routs); - return 1; - } - - if (use_event) - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - - - if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) { - fprintf(stderr, "Couldn't get port info\n"); - return 1; - } - - my_dest.lid = ctx->portinfo.lid; - if (ctx->portinfo.link_layer != IBV_LINK_LAYER_ETHERNET && - !my_dest.lid) { - fprintf(stderr, "Couldn't get local LID\n"); - return 1; - } - - if (gidx >= 0) { - if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) { - fprintf(stderr, "can't read sgid of index %d\n", gidx); - return 1; - } - } else - memset(&my_dest.gid, 0, sizeof my_dest.gid); - - my_dest.qpn = ctx->qp->qp_num; - my_dest.psn = lrand48() & 0xffffff; - inet_ntop(AF_INET6, &my_dest.gid, gid, sizeof gid); - printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n", - my_dest.lid, my_dest.qpn, my_dest.psn, gid); - - - if (servername) - rem_dest = pp_client_exch_dest(servername, port, &my_dest); - else - rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, - &my_dest, gidx); - - if (!rem_dest) - return 1; - - inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid); - printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n", - rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid); - - if (servername) - if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest, - gidx)) - return 1; - - ctx->pending = PINGPONG_RECV_WRID; - - if (servername) { - if (pp_post_send(ctx)) { - fprintf(stderr, "Couldn't post send\n"); - return 1; - } - ctx->pending |= PINGPONG_SEND_WRID; - } - - if (gettimeofday(&start, NULL)) { - perror("gettimeofday"); - return 1; - } - - rcnt = scnt = 0; - while (rcnt < iters || scnt < iters) { - if (use_event) { - struct ibv_cq *ev_cq; - void *ev_ctx; - - if (ibv_get_cq_event(ctx->channel, &ev_cq, &ev_ctx)) { - fprintf(stderr, "Failed to get cq_event\n"); - return 1; - } - - ++num_cq_events; - - if (ev_cq != ctx->cq) { - fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq); - return 1; - } - - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - } - - { - struct ibv_wc wc[2]; - int ne, i; - - do { - ne = ibv_poll_cq(ctx->cq, 2, wc); - if (ne < 0) { - fprintf(stderr, "poll CQ failed %d\n", ne); - return 1; - } - - } while (!use_event && ne < 1); - - for (i = 0; i < ne; ++i) { - if (wc[i].status != IBV_WC_SUCCESS) { - fprintf(stderr, "Failed status %s (%d) for wr_id %d\n", - ibv_wc_status_str(wc[i].status), - wc[i].status, (int) wc[i].wr_id); - return 1; - } - - switch ((int) wc[i].wr_id) { - case PINGPONG_SEND_WRID: - ++scnt; - break; - - case PINGPONG_RECV_WRID: - if (--routs <= 1) { - routs += pp_post_recv(ctx, ctx->rx_depth - routs); - if (routs < ctx->rx_depth) { - fprintf(stderr, - "Couldn't post receive (%d)\n", - routs); - return 1; - } - } - - ++rcnt; - break; - - default: - fprintf(stderr, "Completion for unknown wr_id %d\n", - (int) wc[i].wr_id); - return 1; - } - - ctx->pending &= ~(int) wc[i].wr_id; - if (scnt < iters && !ctx->pending) { - if (pp_post_send(ctx)) { - fprintf(stderr, "Couldn't post send\n"); - return 1; - } - ctx->pending = PINGPONG_RECV_WRID | - PINGPONG_SEND_WRID; - } - } - } - } - - if (gettimeofday(&end, NULL)) { - perror("gettimeofday"); - return 1; - } - - { - float usec = (end.tv_sec - start.tv_sec) * 1000000 + - (end.tv_usec - start.tv_usec); - long long bytes = (long long) size * iters * 2; - - printf("%lld bytes in %.2f seconds = %.2f Mbit/sec\n", - bytes, usec / 1000000., bytes * 8. / usec); - printf("%d iters in %.2f seconds = %.2f usec/iter\n", - iters, usec / 1000000., usec / iters); - } - - ibv_ack_cq_events(ctx->cq, num_cq_events); - - if (pp_close_ctx(ctx)) - return 1; - - ibv_free_device_list(dev_list); - free(rem_dest); - - return 0; -} diff --git a/usr/rdma-core/libibverbs/examples/ud_pingpong.c b/usr/rdma-core/libibverbs/examples/ud_pingpong.c deleted file mode 100644 index d6c46f7ed..000000000 --- a/usr/rdma-core/libibverbs/examples/ud_pingpong.c +++ /dev/null @@ -1,860 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pingpong.h" - -enum { - PINGPONG_RECV_WRID = 1, - PINGPONG_SEND_WRID = 2, -}; - -static int page_size; - -struct pingpong_context { - struct ibv_context *context; - struct ibv_comp_channel *channel; - struct ibv_pd *pd; - struct ibv_mr *mr; - struct ibv_cq *cq; - struct ibv_qp *qp; - struct ibv_ah *ah; - void *buf; - int size; - int send_flags; - int rx_depth; - int pending; - struct ibv_port_attr portinfo; -}; - -struct pingpong_dest { - int lid; - int qpn; - int psn; - union ibv_gid gid; -}; - -static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, - int sl, struct pingpong_dest *dest, int sgid_idx) -{ - struct ibv_ah_attr ah_attr = { - .is_global = 0, - .dlid = dest->lid, - .sl = sl, - .src_path_bits = 0, - .port_num = port - }; - struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_RTR - }; - - if (ibv_modify_qp(ctx->qp, &attr, IBV_QP_STATE)) { - fprintf(stderr, "Failed to modify QP to RTR\n"); - return 1; - } - - attr.qp_state = IBV_QPS_RTS; - attr.sq_psn = my_psn; - - if (ibv_modify_qp(ctx->qp, &attr, - IBV_QP_STATE | - IBV_QP_SQ_PSN)) { - fprintf(stderr, "Failed to modify QP to RTS\n"); - return 1; - } - - if (dest->gid.global.interface_id) { - ah_attr.is_global = 1; - ah_attr.grh.hop_limit = 1; - ah_attr.grh.dgid = dest->gid; - ah_attr.grh.sgid_index = sgid_idx; - } - - ctx->ah = ibv_create_ah(ctx->pd, &ah_attr); - if (!ctx->ah) { - fprintf(stderr, "Failed to create AH\n"); - return 1; - } - - return 0; -} - -static struct pingpong_dest *pp_client_exch_dest(const char *servername, int port, - const struct pingpong_dest *my_dest) -{ - struct addrinfo *res, *t; - struct addrinfo hints = { - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - char *service; - char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"]; - int n; - int sockfd = -1; - struct pingpong_dest *rem_dest = NULL; - char gid[33]; - - if (asprintf(&service, "%d", port) < 0) - return NULL; - - n = getaddrinfo(servername, service, &hints, &res); - - if (n < 0) { - fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port); - free(service); - return NULL; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - if (!connect(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port); - return NULL; - } - - gid_to_wire_gid(&my_dest->gid, gid); - sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, - my_dest->psn, gid); - if (write(sockfd, msg, sizeof msg) != sizeof msg) { - fprintf(stderr, "Couldn't send local address\n"); - goto out; - } - - if (read(sockfd, msg, sizeof msg) != sizeof msg || - write(sockfd, "done", sizeof "done") != sizeof "done") { - perror("client read/write"); - fprintf(stderr, "Couldn't read/write remote address\n"); - goto out; - } - - rem_dest = malloc(sizeof *rem_dest); - if (!rem_dest) - goto out; - - sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, - &rem_dest->psn, gid); - wire_gid_to_gid(gid, &rem_dest->gid); - -out: - close(sockfd); - return rem_dest; -} - -static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, - int ib_port, int port, int sl, - const struct pingpong_dest *my_dest, - int sgid_idx) -{ - struct addrinfo *res, *t; - struct addrinfo hints = { - .ai_flags = AI_PASSIVE, - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - char *service; - char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"]; - int n; - int sockfd = -1, connfd; - struct pingpong_dest *rem_dest = NULL; - char gid[33]; - - if (asprintf(&service, "%d", port) < 0) - return NULL; - - n = getaddrinfo(NULL, service, &hints, &res); - - if (n < 0) { - fprintf(stderr, "%s for port %d\n", gai_strerror(n), port); - free(service); - return NULL; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - n = 1; - - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n); - - if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't listen to port %d\n", port); - return NULL; - } - - listen(sockfd, 1); - connfd = accept(sockfd, NULL, NULL); - close(sockfd); - if (connfd < 0) { - fprintf(stderr, "accept() failed\n"); - return NULL; - } - - n = read(connfd, msg, sizeof msg); - if (n != sizeof msg) { - perror("server read"); - fprintf(stderr, "%d/%d: Couldn't read remote address\n", n, (int) sizeof msg); - goto out; - } - - rem_dest = malloc(sizeof *rem_dest); - if (!rem_dest) - goto out; - - sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, - &rem_dest->psn, gid); - wire_gid_to_gid(gid, &rem_dest->gid); - - if (pp_connect_ctx(ctx, ib_port, my_dest->psn, sl, rem_dest, - sgid_idx)) { - fprintf(stderr, "Couldn't connect to remote QP\n"); - free(rem_dest); - rem_dest = NULL; - goto out; - } - - gid_to_wire_gid(&my_dest->gid, gid); - sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, - my_dest->psn, gid); - if (write(connfd, msg, sizeof msg) != sizeof msg || - read(connfd, msg, sizeof msg) != sizeof "done") { - fprintf(stderr, "Couldn't send/recv local address\n"); - free(rem_dest); - rem_dest = NULL; - goto out; - } -out: - close(connfd); - return rem_dest; -} - -static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, - int rx_depth, int port, - int use_event) -{ - struct pingpong_context *ctx; - - ctx = malloc(sizeof *ctx); - if (!ctx) - return NULL; - - ctx->size = size; - ctx->send_flags = IBV_SEND_SIGNALED; - ctx->rx_depth = rx_depth; - - ctx->buf = memalign(page_size, size + 40); - if (!ctx->buf) { - fprintf(stderr, "Couldn't allocate work buf.\n"); - goto clean_ctx; - } - - /* FIXME memset(ctx->buf, 0, size + 40); */ - memset(ctx->buf, 0x7b, size + 40); - - ctx->context = ibv_open_device(ib_dev); - if (!ctx->context) { - fprintf(stderr, "Couldn't get context for %s\n", - ibv_get_device_name(ib_dev)); - goto clean_buffer; - } - - { - struct ibv_port_attr port_info = {}; - int mtu; - - if (ibv_query_port(ctx->context, port, &port_info)) { - fprintf(stderr, "Unable to query port info for port %d\n", port); - goto clean_device; - } - mtu = 1 << (port_info.active_mtu + 7); - if (size > mtu) { - fprintf(stderr, "Requested size larger than port MTU (%d)\n", mtu); - goto clean_device; - } - } - - if (use_event) { - ctx->channel = ibv_create_comp_channel(ctx->context); - if (!ctx->channel) { - fprintf(stderr, "Couldn't create completion channel\n"); - goto clean_device; - } - } else - ctx->channel = NULL; - - ctx->pd = ibv_alloc_pd(ctx->context); - if (!ctx->pd) { - fprintf(stderr, "Couldn't allocate PD\n"); - goto clean_comp_channel; - } - - ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size + 40, IBV_ACCESS_LOCAL_WRITE); - if (!ctx->mr) { - fprintf(stderr, "Couldn't register MR\n"); - goto clean_pd; - } - - ctx->cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL, - ctx->channel, 0); - if (!ctx->cq) { - fprintf(stderr, "Couldn't create CQ\n"); - goto clean_mr; - } - - { - struct ibv_qp_attr attr; - struct ibv_qp_init_attr init_attr = { - .send_cq = ctx->cq, - .recv_cq = ctx->cq, - .cap = { - .max_send_wr = 1, - .max_recv_wr = rx_depth, - .max_send_sge = 1, - .max_recv_sge = 1 - }, - .qp_type = IBV_QPT_UD, - }; - - ctx->qp = ibv_create_qp(ctx->pd, &init_attr); - if (!ctx->qp) { - fprintf(stderr, "Couldn't create QP\n"); - goto clean_cq; - } - - ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr); - if (init_attr.cap.max_inline_data >= size) { - ctx->send_flags |= IBV_SEND_INLINE; - } - } - - { - struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_INIT, - .pkey_index = 0, - .port_num = port, - .qkey = 0x11111111 - }; - - if (ibv_modify_qp(ctx->qp, &attr, - IBV_QP_STATE | - IBV_QP_PKEY_INDEX | - IBV_QP_PORT | - IBV_QP_QKEY)) { - fprintf(stderr, "Failed to modify QP to INIT\n"); - goto clean_qp; - } - } - - return ctx; - -clean_qp: - ibv_destroy_qp(ctx->qp); - -clean_cq: - ibv_destroy_cq(ctx->cq); - -clean_mr: - ibv_dereg_mr(ctx->mr); - -clean_pd: - ibv_dealloc_pd(ctx->pd); - -clean_comp_channel: - if (ctx->channel) - ibv_destroy_comp_channel(ctx->channel); - -clean_device: - ibv_close_device(ctx->context); - -clean_buffer: - free(ctx->buf); - -clean_ctx: - free(ctx); - - return NULL; -} - -static int pp_close_ctx(struct pingpong_context *ctx) -{ - if (ibv_destroy_qp(ctx->qp)) { - fprintf(stderr, "Couldn't destroy QP\n"); - return 1; - } - - if (ibv_destroy_cq(ctx->cq)) { - fprintf(stderr, "Couldn't destroy CQ\n"); - return 1; - } - - if (ibv_dereg_mr(ctx->mr)) { - fprintf(stderr, "Couldn't deregister MR\n"); - return 1; - } - - if (ibv_destroy_ah(ctx->ah)) { - fprintf(stderr, "Couldn't destroy AH\n"); - return 1; - } - - if (ibv_dealloc_pd(ctx->pd)) { - fprintf(stderr, "Couldn't deallocate PD\n"); - return 1; - } - - if (ctx->channel) { - if (ibv_destroy_comp_channel(ctx->channel)) { - fprintf(stderr, "Couldn't destroy completion channel\n"); - return 1; - } - } - - if (ibv_close_device(ctx->context)) { - fprintf(stderr, "Couldn't release context\n"); - return 1; - } - - free(ctx->buf); - free(ctx); - - return 0; -} - -static int pp_post_recv(struct pingpong_context *ctx, int n) -{ - struct ibv_sge list = { - .addr = (uintptr_t) ctx->buf, - .length = ctx->size + 40, - .lkey = ctx->mr->lkey - }; - struct ibv_recv_wr wr = { - .wr_id = PINGPONG_RECV_WRID, - .sg_list = &list, - .num_sge = 1, - }; - struct ibv_recv_wr *bad_wr; - int i; - - for (i = 0; i < n; ++i) - if (ibv_post_recv(ctx->qp, &wr, &bad_wr)) - break; - - return i; -} - -static int pp_post_send(struct pingpong_context *ctx, uint32_t qpn) -{ - struct ibv_sge list = { - .addr = (uintptr_t) ctx->buf + 40, - .length = ctx->size, - .lkey = ctx->mr->lkey - }; - struct ibv_send_wr wr = { - .wr_id = PINGPONG_SEND_WRID, - .sg_list = &list, - .num_sge = 1, - .opcode = IBV_WR_SEND, - .send_flags = ctx->send_flags, - .wr = { - .ud = { - .ah = ctx->ah, - .remote_qpn = qpn, - .remote_qkey = 0x11111111 - } - } - }; - struct ibv_send_wr *bad_wr; - - return ibv_post_send(ctx->qp, &wr, &bad_wr); -} - -static void usage(const char *argv0) -{ - printf("Usage:\n"); - printf(" %s start a server and wait for connection\n", argv0); - printf(" %s connect to server at \n", argv0); - printf("\n"); - printf("Options:\n"); - printf(" -p, --port= listen on/connect to port (default 18515)\n"); - printf(" -d, --ib-dev= use IB device (default first device found)\n"); - printf(" -i, --ib-port= use port of IB device (default 1)\n"); - printf(" -s, --size= size of message to exchange (default 2048)\n"); - printf(" -r, --rx-depth= number of receives to post at a time (default 500)\n"); - printf(" -n, --iters= number of exchanges (default 1000)\n"); - printf(" -l, --sl= send messages with service level (default 0)\n"); - printf(" -e, --events sleep on CQ events (default poll)\n"); - printf(" -g, --gid-idx= local port gid index\n"); -} - -int main(int argc, char *argv[]) -{ - struct ibv_device **dev_list; - struct ibv_device *ib_dev; - struct pingpong_context *ctx; - struct pingpong_dest my_dest; - struct pingpong_dest *rem_dest; - struct timeval start, end; - char *ib_devname = NULL; - char *servername = NULL; - unsigned int port = 18515; - int ib_port = 1; - unsigned int size = 2048; - unsigned int rx_depth = 500; - unsigned int iters = 1000; - int use_event = 0; - int routs; - int rcnt, scnt; - int num_cq_events = 0; - int sl = 0; - int gidx = -1; - char gid[33]; - - srand48(getpid() * time(NULL)); - - while (1) { - int c; - - static struct option long_options[] = { - { .name = "port", .has_arg = 1, .val = 'p' }, - { .name = "ib-dev", .has_arg = 1, .val = 'd' }, - { .name = "ib-port", .has_arg = 1, .val = 'i' }, - { .name = "size", .has_arg = 1, .val = 's' }, - { .name = "rx-depth", .has_arg = 1, .val = 'r' }, - { .name = "iters", .has_arg = 1, .val = 'n' }, - { .name = "sl", .has_arg = 1, .val = 'l' }, - { .name = "events", .has_arg = 0, .val = 'e' }, - { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - {} - }; - - c = getopt_long(argc, argv, "p:d:i:s:r:n:l:eg:", - long_options, NULL); - if (c == -1) - break; - - switch (c) { - case 'p': - port = strtol(optarg, NULL, 0); - if (port > 65535) { - usage(argv[0]); - return 1; - } - break; - - case 'd': - ib_devname = strdupa(optarg); - break; - - case 'i': - ib_port = strtol(optarg, NULL, 0); - if (ib_port < 1) { - usage(argv[0]); - return 1; - } - break; - - case 's': - size = strtoul(optarg, NULL, 0); - break; - - case 'r': - rx_depth = strtoul(optarg, NULL, 0); - break; - - case 'n': - iters = strtoul(optarg, NULL, 0); - break; - - case 'l': - sl = strtol(optarg, NULL, 0); - break; - - case 'e': - ++use_event; - break; - - case 'g': - gidx = strtol(optarg, NULL, 0); - break; - - default: - usage(argv[0]); - return 1; - } - } - - if (optind == argc - 1) - servername = strdupa(argv[optind]); - else if (optind < argc) { - usage(argv[0]); - return 1; - } - - page_size = sysconf(_SC_PAGESIZE); - - dev_list = ibv_get_device_list(NULL); - if (!dev_list) { - perror("Failed to get IB devices list"); - return 1; - } - - if (!ib_devname) { - ib_dev = *dev_list; - if (!ib_dev) { - fprintf(stderr, "No IB devices found\n"); - return 1; - } - } else { - int i; - for (i = 0; dev_list[i]; ++i) - if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname)) - break; - ib_dev = dev_list[i]; - if (!ib_dev) { - fprintf(stderr, "IB device %s not found\n", ib_devname); - return 1; - } - } - - ctx = pp_init_ctx(ib_dev, size, rx_depth, ib_port, use_event); - if (!ctx) - return 1; - - routs = pp_post_recv(ctx, ctx->rx_depth); - if (routs < ctx->rx_depth) { - fprintf(stderr, "Couldn't post receive (%d)\n", routs); - return 1; - } - - if (use_event) - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - - if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) { - fprintf(stderr, "Couldn't get port info\n"); - return 1; - } - my_dest.lid = ctx->portinfo.lid; - - my_dest.qpn = ctx->qp->qp_num; - my_dest.psn = lrand48() & 0xffffff; - - if (gidx >= 0) { - if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) { - fprintf(stderr, "Could not get local gid for gid index " - "%d\n", gidx); - return 1; - } - } else - memset(&my_dest.gid, 0, sizeof my_dest.gid); - - inet_ntop(AF_INET6, &my_dest.gid, gid, sizeof gid); - printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x: GID %s\n", - my_dest.lid, my_dest.qpn, my_dest.psn, gid); - - if (servername) - rem_dest = pp_client_exch_dest(servername, port, &my_dest); - else - rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl, - &my_dest, gidx); - - if (!rem_dest) - return 1; - - inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid); - printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n", - rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid); - - if (servername) - if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest, - gidx)) - return 1; - - ctx->pending = PINGPONG_RECV_WRID; - - if (servername) { - if (pp_post_send(ctx, rem_dest->qpn)) { - fprintf(stderr, "Couldn't post send\n"); - return 1; - } - ctx->pending |= PINGPONG_SEND_WRID; - } - - if (gettimeofday(&start, NULL)) { - perror("gettimeofday"); - return 1; - } - - rcnt = scnt = 0; - while (rcnt < iters || scnt < iters) { - if (use_event) { - struct ibv_cq *ev_cq; - void *ev_ctx; - - if (ibv_get_cq_event(ctx->channel, &ev_cq, &ev_ctx)) { - fprintf(stderr, "Failed to get cq_event\n"); - return 1; - } - - ++num_cq_events; - - if (ev_cq != ctx->cq) { - fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq); - return 1; - } - - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - } - - { - struct ibv_wc wc[2]; - int ne, i; - - do { - ne = ibv_poll_cq(ctx->cq, 2, wc); - if (ne < 0) { - fprintf(stderr, "poll CQ failed %d\n", ne); - return 1; - } - } while (!use_event && ne < 1); - - for (i = 0; i < ne; ++i) { - if (wc[i].status != IBV_WC_SUCCESS) { - fprintf(stderr, "Failed status %s (%d) for wr_id %d\n", - ibv_wc_status_str(wc[i].status), - wc[i].status, (int) wc[i].wr_id); - return 1; - } - - switch ((int) wc[i].wr_id) { - case PINGPONG_SEND_WRID: - ++scnt; - break; - - case PINGPONG_RECV_WRID: - if (--routs <= 1) { - routs += pp_post_recv(ctx, ctx->rx_depth - routs); - if (routs < ctx->rx_depth) { - fprintf(stderr, - "Couldn't post receive (%d)\n", - routs); - return 1; - } - } - - ++rcnt; - break; - - default: - fprintf(stderr, "Completion for unknown wr_id %d\n", - (int) wc[i].wr_id); - return 1; - } - - ctx->pending &= ~(int) wc[i].wr_id; - if (scnt < iters && !ctx->pending) { - if (pp_post_send(ctx, rem_dest->qpn)) { - fprintf(stderr, "Couldn't post send\n"); - return 1; - } - ctx->pending = PINGPONG_RECV_WRID | - PINGPONG_SEND_WRID; - } - } - } - } - - if (gettimeofday(&end, NULL)) { - perror("gettimeofday"); - return 1; - } - - { - float usec = (end.tv_sec - start.tv_sec) * 1000000 + - (end.tv_usec - start.tv_usec); - long long bytes = (long long) size * iters * 2; - - printf("%lld bytes in %.2f seconds = %.2f Mbit/sec\n", - bytes, usec / 1000000., bytes * 8. / usec); - printf("%d iters in %.2f seconds = %.2f usec/iter\n", - iters, usec / 1000000., usec / iters); - } - - ibv_ack_cq_events(ctx->cq, num_cq_events); - - if (pp_close_ctx(ctx)) - return 1; - - ibv_free_device_list(dev_list); - free(rem_dest); - - return 0; -} diff --git a/usr/rdma-core/libibverbs/examples/xsrq_pingpong.c b/usr/rdma-core/libibverbs/examples/xsrq_pingpong.c deleted file mode 100644 index bfab2b80d..000000000 --- a/usr/rdma-core/libibverbs/examples/xsrq_pingpong.c +++ /dev/null @@ -1,1022 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2011 Intel Corporation, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pingpong.h" - -#define MSG_FORMAT "%04x:%06x:%06x:%06x:%06x:%32s" -#define MSG_SIZE 66 -#define MSG_SSCAN "%x:%x:%x:%x:%x:%s" -#define ADDR_FORMAT \ - "%8s: LID %04x, QPN RECV %06x SEND %06x, PSN %06x, SRQN %06x, GID %s\n" -#define TERMINATION_FORMAT "%s" -#define TERMINATION_MSG_SIZE 4 -#define TERMINATION_MSG "END" -static int page_size; - -struct pingpong_dest { - union ibv_gid gid; - int lid; - int recv_qpn; - int send_qpn; - int recv_psn; - int send_psn; - int srqn; - int pp_cnt; - int sockfd; -}; - -struct pingpong_context { - struct ibv_context *context; - struct ibv_comp_channel *channel; - struct ibv_pd *pd; - struct ibv_mr *mr; - struct ibv_cq *send_cq; - struct ibv_cq *recv_cq; - struct ibv_srq *srq; - struct ibv_xrcd *xrcd; - struct ibv_qp **recv_qp; - struct ibv_qp **send_qp; - struct pingpong_dest *rem_dest; - void *buf; - int lid; - int sl; - enum ibv_mtu mtu; - int ib_port; - int fd; - int size; - int num_clients; - int num_tests; - int use_event; - int gidx; -}; - -static struct pingpong_context ctx; - - -static int open_device(char *ib_devname) -{ - struct ibv_device **dev_list; - int i = 0; - - dev_list = ibv_get_device_list(NULL); - if (!dev_list) { - fprintf(stderr, "Failed to get IB devices list"); - return -1; - } - - if (ib_devname) { - for (; dev_list[i]; ++i) { - if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname)) - break; - } - } - if (!dev_list[i]) { - fprintf(stderr, "IB device %s not found\n", - ib_devname ? ib_devname : ""); - return -1; - } - - ctx.context = ibv_open_device(dev_list[i]); - if (!ctx.context) { - fprintf(stderr, "Couldn't get context for %s\n", - ibv_get_device_name(dev_list[i])); - return -1; - } - - ibv_free_device_list(dev_list); - return 0; -} - -static int create_qps(void) -{ - struct ibv_qp_init_attr_ex init; - struct ibv_qp_attr mod; - int i; - - for (i = 0; i < ctx.num_clients; ++i) { - - memset(&init, 0, sizeof init); - init.qp_type = IBV_QPT_XRC_RECV; - init.comp_mask = IBV_QP_INIT_ATTR_XRCD; - init.xrcd = ctx.xrcd; - - ctx.recv_qp[i] = ibv_create_qp_ex(ctx.context, &init); - if (!ctx.recv_qp[i]) { - fprintf(stderr, "Couldn't create recv QP[%d] errno %d\n", - i, errno); - return 1; - } - - mod.qp_state = IBV_QPS_INIT; - mod.pkey_index = 0; - mod.port_num = ctx.ib_port; - mod.qp_access_flags = IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ; - - if (ibv_modify_qp(ctx.recv_qp[i], &mod, - IBV_QP_STATE | IBV_QP_PKEY_INDEX | - IBV_QP_PORT | IBV_QP_ACCESS_FLAGS)) { - fprintf(stderr, "Failed to modify recv QP[%d] to INIT\n", i); - return 1; - } - - memset(&init, 0, sizeof init); - init.qp_type = IBV_QPT_XRC_SEND; - init.send_cq = ctx.send_cq; - init.cap.max_send_wr = ctx.num_clients * ctx.num_tests; - init.cap.max_send_sge = 1; - init.comp_mask = IBV_QP_INIT_ATTR_PD; - init.pd = ctx.pd; - - ctx.send_qp[i] = ibv_create_qp_ex(ctx.context, &init); - if (!ctx.send_qp[i]) { - fprintf(stderr, "Couldn't create send QP[%d] errno %d\n", - i, errno); - return 1; - } - - mod.qp_state = IBV_QPS_INIT; - mod.pkey_index = 0; - mod.port_num = ctx.ib_port; - mod.qp_access_flags = 0; - - if (ibv_modify_qp(ctx.send_qp[i], &mod, - IBV_QP_STATE | IBV_QP_PKEY_INDEX | - IBV_QP_PORT | IBV_QP_ACCESS_FLAGS)) { - fprintf(stderr, "Failed to modify send QP[%d] to INIT\n", i); - return 1; - } - } - - return 0; -} - -static int pp_init_ctx(char *ib_devname) -{ - struct ibv_srq_init_attr_ex attr; - struct ibv_xrcd_init_attr xrcd_attr; - struct ibv_port_attr port_attr; - - ctx.recv_qp = calloc(ctx.num_clients, sizeof *ctx.recv_qp); - ctx.send_qp = calloc(ctx.num_clients, sizeof *ctx.send_qp); - ctx.rem_dest = calloc(ctx.num_clients, sizeof *ctx.rem_dest); - if (!ctx.recv_qp || !ctx.send_qp || !ctx.rem_dest) - return 1; - - if (open_device(ib_devname)) { - fprintf(stderr, "Failed to open device\n"); - return 1; - } - - if (pp_get_port_info(ctx.context, ctx.ib_port, &port_attr)) { - fprintf(stderr, "Failed to get port info\n"); - return 1; - } - - ctx.lid = port_attr.lid; - if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET && !ctx.lid) { - fprintf(stderr, "Couldn't get local LID\n"); - return 1; - } - - ctx.buf = memalign(page_size, ctx.size); - if (!ctx.buf) { - fprintf(stderr, "Couldn't allocate work buf.\n"); - return 1; - } - - memset(ctx.buf, 0, ctx.size); - - if (ctx.use_event) { - ctx.channel = ibv_create_comp_channel(ctx.context); - if (!ctx.channel) { - fprintf(stderr, "Couldn't create completion channel\n"); - return 1; - } - } - - ctx.pd = ibv_alloc_pd(ctx.context); - if (!ctx.pd) { - fprintf(stderr, "Couldn't allocate PD\n"); - return 1; - } - - ctx.mr = ibv_reg_mr(ctx.pd, ctx.buf, ctx.size, IBV_ACCESS_LOCAL_WRITE); - if (!ctx.mr) { - fprintf(stderr, "Couldn't register MR\n"); - return 1; - } - - ctx.fd = open("/tmp/xrc_domain", O_RDONLY | O_CREAT, S_IRUSR | S_IRGRP); - if (ctx.fd < 0) { - fprintf(stderr, - "Couldn't create the file for the XRC Domain " - "but not stopping %d\n", errno); - ctx.fd = -1; - } - - memset(&xrcd_attr, 0, sizeof xrcd_attr); - xrcd_attr.comp_mask = IBV_XRCD_INIT_ATTR_FD | IBV_XRCD_INIT_ATTR_OFLAGS; - xrcd_attr.fd = ctx.fd; - xrcd_attr.oflags = O_CREAT; - ctx.xrcd = ibv_open_xrcd(ctx.context, &xrcd_attr); - if (!ctx.xrcd) { - fprintf(stderr, "Couldn't Open the XRC Domain %d\n", errno); - return 1; - } - - ctx.recv_cq = ibv_create_cq(ctx.context, ctx.num_clients, &ctx.recv_cq, - ctx.channel, 0); - if (!ctx.recv_cq) { - fprintf(stderr, "Couldn't create recv CQ\n"); - return 1; - } - - if (ctx.use_event) { - if (ibv_req_notify_cq(ctx.recv_cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - } - - ctx.send_cq = ibv_create_cq(ctx.context, ctx.num_clients, NULL, NULL, 0); - if (!ctx.send_cq) { - fprintf(stderr, "Couldn't create send CQ\n"); - return 1; - } - - memset(&attr, 0, sizeof attr); - attr.attr.max_wr = ctx.num_clients; - attr.attr.max_sge = 1; - attr.comp_mask = IBV_SRQ_INIT_ATTR_TYPE | IBV_SRQ_INIT_ATTR_XRCD | - IBV_SRQ_INIT_ATTR_CQ | IBV_SRQ_INIT_ATTR_PD; - attr.srq_type = IBV_SRQT_XRC; - attr.xrcd = ctx.xrcd; - attr.cq = ctx.recv_cq; - attr.pd = ctx.pd; - - ctx.srq = ibv_create_srq_ex(ctx.context, &attr); - if (!ctx.srq) { - fprintf(stderr, "Couldn't create SRQ\n"); - return 1; - } - - if (create_qps()) - return 1; - - return 0; -} - -static int recv_termination_ack(int index) -{ - char msg[TERMINATION_MSG_SIZE]; - int n = 0, r; - int sockfd = ctx.rem_dest[index].sockfd; - - while (n < TERMINATION_MSG_SIZE) { - r = read(sockfd, msg + n, TERMINATION_MSG_SIZE - n); - if (r < 0) { - perror("client read"); - fprintf(stderr, - "%d/%d: Couldn't read remote termination ack\n", - n, TERMINATION_MSG_SIZE); - return 1; - } - n += r; - } - - if (strcmp(msg, TERMINATION_MSG)) { - fprintf(stderr, "Invalid termination ack was accepted\n"); - return 1; - } - - return 0; -} - -static int send_termination_ack(int index) -{ - char msg[TERMINATION_MSG_SIZE]; - int sockfd = ctx.rem_dest[index].sockfd; - - sprintf(msg, TERMINATION_FORMAT, TERMINATION_MSG); - - if (write(sockfd, msg, TERMINATION_MSG_SIZE) != TERMINATION_MSG_SIZE) { - fprintf(stderr, "Couldn't send termination ack\n"); - return 1; - } - - return 0; -} - -static int pp_client_termination(void) -{ - if (send_termination_ack(0)) - return 1; - if (recv_termination_ack(0)) - return 1; - - return 0; -} - -static int pp_server_termination(void) -{ - int i; - - for (i = 0; i < ctx.num_clients; i++) { - if (recv_termination_ack(i)) - return 1; - } - - for (i = 0; i < ctx.num_clients; i++) { - if (send_termination_ack(i)) - return 1; - } - - return 0; -} - -static int send_local_dest(int sockfd, int index) -{ - char msg[MSG_SIZE]; - char gid[33]; - uint32_t srq_num; - union ibv_gid local_gid; - - if (ctx.gidx >= 0) { - if (ibv_query_gid(ctx.context, ctx.ib_port, ctx.gidx, - &local_gid)) { - fprintf(stderr, "can't read sgid of index %d\n", - ctx.gidx); - return -1; - } - } else { - memset(&local_gid, 0, sizeof(local_gid)); - } - - ctx.rem_dest[index].recv_psn = lrand48() & 0xffffff; - if (ibv_get_srq_num(ctx.srq, &srq_num)) { - fprintf(stderr, "Couldn't get SRQ num\n"); - return -1; - } - - inet_ntop(AF_INET6, &local_gid, gid, sizeof(gid)); - printf(ADDR_FORMAT, "local", ctx.lid, ctx.recv_qp[index]->qp_num, - ctx.send_qp[index]->qp_num, ctx.rem_dest[index].recv_psn, - srq_num, gid); - - gid_to_wire_gid(&local_gid, gid); - sprintf(msg, MSG_FORMAT, ctx.lid, ctx.recv_qp[index]->qp_num, - ctx.send_qp[index]->qp_num, ctx.rem_dest[index].recv_psn, - srq_num, gid); - - if (write(sockfd, msg, MSG_SIZE) != MSG_SIZE) { - fprintf(stderr, "Couldn't send local address\n"); - return -1; - } - - return 0; -} - -static int recv_remote_dest(int sockfd, int index) -{ - struct pingpong_dest *rem_dest; - char msg[MSG_SIZE]; - char gid[33]; - int n = 0, r; - - while (n < MSG_SIZE) { - r = read(sockfd, msg + n, MSG_SIZE - n); - if (r < 0) { - perror("client read"); - fprintf(stderr, - "%d/%d: Couldn't read remote address [%d]\n", - n, MSG_SIZE, index); - return -1; - } - n += r; - } - - rem_dest = &ctx.rem_dest[index]; - sscanf(msg, MSG_SSCAN, &rem_dest->lid, &rem_dest->recv_qpn, - &rem_dest->send_qpn, &rem_dest->send_psn, &rem_dest->srqn, gid); - - wire_gid_to_gid(gid, &rem_dest->gid); - inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof(gid)); - printf(ADDR_FORMAT, "remote", rem_dest->lid, rem_dest->recv_qpn, - rem_dest->send_qpn, rem_dest->send_psn, rem_dest->srqn, - gid); - - rem_dest->sockfd = sockfd; - return 0; -} - -static void set_ah_attr(struct ibv_ah_attr *attr, struct pingpong_context *myctx, - int index) -{ - attr->is_global = 1; - attr->grh.hop_limit = 5; - attr->grh.dgid = myctx->rem_dest[index].gid; - attr->grh.sgid_index = myctx->gidx; -} - -static int connect_qps(int index) -{ - struct ibv_qp_attr attr; - - memset(&attr, 0, sizeof attr); - attr.qp_state = IBV_QPS_RTR; - attr.dest_qp_num = ctx.rem_dest[index].send_qpn; - attr.path_mtu = ctx.mtu; - attr.rq_psn = ctx.rem_dest[index].send_psn; - attr.min_rnr_timer = 12; - attr.ah_attr.dlid = ctx.rem_dest[index].lid; - attr.ah_attr.sl = ctx.sl; - attr.ah_attr.port_num = ctx.ib_port; - - if (ctx.rem_dest[index].gid.global.interface_id) - set_ah_attr(&attr.ah_attr, &ctx, index); - - if (ibv_modify_qp(ctx.recv_qp[index], &attr, - IBV_QP_STATE | IBV_QP_AV | IBV_QP_PATH_MTU | - IBV_QP_DEST_QPN | IBV_QP_RQ_PSN | - IBV_QP_MAX_DEST_RD_ATOMIC | IBV_QP_MIN_RNR_TIMER)) { - fprintf(stderr, "Failed to modify recv QP[%d] to RTR\n", index); - return 1; - } - - memset(&attr, 0, sizeof attr); - attr.qp_state = IBV_QPS_RTS; - attr.timeout = 14; - attr.sq_psn = ctx.rem_dest[index].recv_psn; - - if (ibv_modify_qp(ctx.recv_qp[index], &attr, - IBV_QP_STATE | IBV_QP_TIMEOUT | IBV_QP_SQ_PSN)) { - fprintf(stderr, "Failed to modify recv QP[%d] to RTS\n", index); - return 1; - } - - memset(&attr, 0, sizeof attr); - attr.qp_state = IBV_QPS_RTR; - attr.dest_qp_num = ctx.rem_dest[index].recv_qpn; - attr.path_mtu = ctx.mtu; - attr.rq_psn = ctx.rem_dest[index].send_psn; - attr.ah_attr.dlid = ctx.rem_dest[index].lid; - attr.ah_attr.sl = ctx.sl; - attr.ah_attr.port_num = ctx.ib_port; - - if (ctx.rem_dest[index].gid.global.interface_id) - set_ah_attr(&attr.ah_attr, &ctx, index); - - if (ibv_modify_qp(ctx.send_qp[index], &attr, - IBV_QP_STATE | IBV_QP_AV | IBV_QP_PATH_MTU | - IBV_QP_DEST_QPN | IBV_QP_RQ_PSN)) { - fprintf(stderr, "Failed to modify send QP[%d] to RTR\n", index); - return 1; - } - - memset(&attr, 0, sizeof attr); - attr.qp_state = IBV_QPS_RTS; - attr.timeout = 14; - attr.retry_cnt = 7; - attr.rnr_retry = 7; - attr.sq_psn = ctx.rem_dest[index].recv_psn; - - if (ibv_modify_qp(ctx.send_qp[index], &attr, - IBV_QP_STATE | IBV_QP_TIMEOUT | IBV_QP_SQ_PSN | - IBV_QP_RETRY_CNT | IBV_QP_RNR_RETRY | IBV_QP_MAX_QP_RD_ATOMIC)) { - fprintf(stderr, "Failed to modify send QP[%d] to RTS\n", index); - return 1; - } - - return 0; -} - -static int pp_client_connect(const char *servername, int port) -{ - struct addrinfo *res, *t; - char *service; - int ret; - int sockfd = -1; - struct addrinfo hints = { - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - - if (asprintf(&service, "%d", port) < 0) - return 1; - - ret = getaddrinfo(servername, service, &hints, &res); - if (ret < 0) { - fprintf(stderr, "%s for %s:%d\n", gai_strerror(ret), servername, port); - free(service); - return 1; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - if (!connect(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port); - return 1; - } - - if (send_local_dest(sockfd, 0)) - return 1; - - if (recv_remote_dest(sockfd, 0)) - return 1; - - if (connect_qps(0)) - return 1; - - return 0; -} - -static int pp_server_connect(int port) -{ - struct addrinfo *res, *t; - char *service; - int ret, i, n; - int sockfd = -1, connfd; - struct addrinfo hints = { - .ai_flags = AI_PASSIVE, - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM - }; - - if (asprintf(&service, "%d", port) < 0) - return 1; - - ret = getaddrinfo(NULL, service, &hints, &res); - if (ret < 0) { - fprintf(stderr, "%s for port %d\n", gai_strerror(ret), port); - free(service); - return 1; - } - - for (t = res; t; t = t->ai_next) { - sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); - if (sockfd >= 0) { - n = 1; - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n); - if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) - break; - close(sockfd); - sockfd = -1; - } - } - - freeaddrinfo(res); - free(service); - - if (sockfd < 0) { - fprintf(stderr, "Couldn't listen to port %d\n", port); - return 1; - } - - listen(sockfd, ctx.num_clients); - - for (i = 0; i < ctx.num_clients; i++) { - connfd = accept(sockfd, NULL, NULL); - if (connfd < 0) { - fprintf(stderr, "accept() failed for client %d\n", i); - return 1; - } - - if (recv_remote_dest(connfd, i)) - return 1; - - if (send_local_dest(connfd, i)) - return 1; - - if (connect_qps(i)) - return 1; - } - - close(sockfd); - return 0; -} - - -static int pp_close_ctx(void) -{ - int i; - - for (i = 0; i < ctx.num_clients; ++i) { - - if (ibv_destroy_qp(ctx.send_qp[i])) { - fprintf(stderr, "Couldn't destroy INI QP[%d]\n", i); - return 1; - } - - if (ibv_destroy_qp(ctx.recv_qp[i])) { - fprintf(stderr, "Couldn't destroy TGT QP[%d]\n", i); - return 1; - } - - if (ctx.rem_dest[i].sockfd) - close(ctx.rem_dest[i].sockfd); - } - - if (ibv_destroy_srq(ctx.srq)) { - fprintf(stderr, "Couldn't destroy SRQ\n"); - return 1; - } - - if (ctx.xrcd && ibv_close_xrcd(ctx.xrcd)) { - fprintf(stderr, "Couldn't close the XRC Domain\n"); - return 1; - } - if (ctx.fd >= 0 && close(ctx.fd)) { - fprintf(stderr, "Couldn't close the file for the XRC Domain\n"); - return 1; - } - - if (ibv_destroy_cq(ctx.send_cq)) { - fprintf(stderr, "Couldn't destroy send CQ\n"); - return 1; - } - - if (ibv_destroy_cq(ctx.recv_cq)) { - fprintf(stderr, "Couldn't destroy recv CQ\n"); - return 1; - } - - if (ibv_dereg_mr(ctx.mr)) { - fprintf(stderr, "Couldn't deregister MR\n"); - return 1; - } - - if (ibv_dealloc_pd(ctx.pd)) { - fprintf(stderr, "Couldn't deallocate PD\n"); - return 1; - } - - if (ctx.channel) { - if (ibv_destroy_comp_channel(ctx.channel)) { - fprintf(stderr, - "Couldn't destroy completion channel\n"); - return 1; - } - } - - if (ibv_close_device(ctx.context)) { - fprintf(stderr, "Couldn't release context\n"); - return 1; - } - - free(ctx.buf); - free(ctx.rem_dest); - free(ctx.send_qp); - free(ctx.recv_qp); - return 0; -} - -static int pp_post_recv(int cnt) -{ - struct ibv_sge sge; - struct ibv_recv_wr wr, *bad_wr; - - sge.addr = (uintptr_t) ctx.buf; - sge.length = ctx.size; - sge.lkey = ctx.mr->lkey; - - wr.next = NULL; - wr.wr_id = (uintptr_t) &ctx; - wr.sg_list = &sge; - wr.num_sge = 1; - - while (cnt--) { - if (ibv_post_srq_recv(ctx.srq, &wr, &bad_wr)) { - fprintf(stderr, "Failed to post receive to SRQ\n"); - return 1; - } - } - return 0; -} - -/* - * Send to each client round robin on each set of xrc send/recv qp. - * Generate a completion on the last send. - */ -static int pp_post_send(int index) -{ - struct ibv_sge sge; - struct ibv_send_wr wr, *bad_wr; - int qpi; - - sge.addr = (uintptr_t) ctx.buf; - sge.length = ctx.size; - sge.lkey = ctx.mr->lkey; - - wr.wr_id = (uintptr_t) index; - wr.next = NULL; - wr.sg_list = &sge; - wr.num_sge = 1; - wr.opcode = IBV_WR_SEND; - wr.qp_type.xrc.remote_srqn = ctx.rem_dest[index].srqn; - - qpi = (index + ctx.rem_dest[index].pp_cnt) % ctx.num_clients; - wr.send_flags = (++ctx.rem_dest[index].pp_cnt >= ctx.num_tests) ? - IBV_SEND_SIGNALED : 0; - - return ibv_post_send(ctx.send_qp[qpi], &wr, &bad_wr); -} - -static int find_qp(int qpn) -{ - int i; - - if (ctx.num_clients == 1) - return 0; - - for (i = 0; i < ctx.num_clients; ++i) - if (ctx.recv_qp[i]->qp_num == qpn) - return i; - - fprintf(stderr, "Unable to find qp %x\n", qpn); - return 0; -} - -static int get_cq_event(void) -{ - struct ibv_cq *ev_cq; - void *ev_ctx; - - if (ibv_get_cq_event(ctx.channel, &ev_cq, &ev_ctx)) { - fprintf(stderr, "Failed to get cq_event\n"); - return 1; - } - - if (ev_cq != ctx.recv_cq) { - fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq); - return 1; - } - - if (ibv_req_notify_cq(ctx.recv_cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - - return 0; -} - -static void init(void) -{ - srand48(getpid() * time(NULL)); - - ctx.size = 4096; - ctx.ib_port = 1; - ctx.num_clients = 1; - ctx.num_tests = 5; - ctx.mtu = IBV_MTU_1024; - ctx.sl = 0; - ctx.gidx = -1; -} - -static void usage(const char *argv0) -{ - printf("Usage:\n"); - printf(" %s start a server and wait for connection\n", argv0); - printf(" %s connect to server at \n", argv0); - printf("\n"); - printf("Options:\n"); - printf(" -p, --port= listen on/connect to port (default 18515)\n"); - printf(" -d, --ib-dev= use IB device (default first device found)\n"); - printf(" -i, --ib-port= use port of IB device (default 1)\n"); - printf(" -s, --size= size of message to exchange (default 4096)\n"); - printf(" -m, --mtu= path MTU (default 2048)\n"); - printf(" -c, --clients= number of clients (on server only, default 1)\n"); - printf(" -n, --num_tests= number of tests per client (default 5)\n"); - printf(" -l, --sl= service level value\n"); - printf(" -e, --events sleep on CQ events (default poll)\n"); - printf(" -g, --gid-idx= local port gid index\n"); -} - -int main(int argc, char *argv[]) -{ - char *ib_devname = NULL; - char *servername = NULL; - int port = 18515; - int i, total, cnt = 0; - int ne, qpi, num_cq_events = 0; - struct ibv_wc wc; - - init(); - while (1) { - int c; - - static struct option long_options[] = { - { .name = "port", .has_arg = 1, .val = 'p' }, - { .name = "ib-dev", .has_arg = 1, .val = 'd' }, - { .name = "ib-port", .has_arg = 1, .val = 'i' }, - { .name = "size", .has_arg = 1, .val = 's' }, - { .name = "mtu", .has_arg = 1, .val = 'm' }, - { .name = "clients", .has_arg = 1, .val = 'c' }, - { .name = "num_tests", .has_arg = 1, .val = 'n' }, - { .name = "sl", .has_arg = 1, .val = 'l' }, - { .name = "events", .has_arg = 0, .val = 'e' }, - { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - {} - }; - - c = getopt_long(argc, argv, "p:d:i:s:m:c:n:l:eg:", long_options, - NULL); - if (c == -1) - break; - - switch (c) { - case 'p': - port = strtol(optarg, NULL, 0); - if (port < 0 || port > 65535) { - usage(argv[0]); - return 1; - } - break; - case 'd': - ib_devname = strdupa(optarg); - break; - case 'i': - ctx.ib_port = strtol(optarg, NULL, 0); - if (ctx.ib_port < 0) { - usage(argv[0]); - return 1; - } - break; - case 's': - ctx.size = strtol(optarg, NULL, 0); - break; - case 'm': - ctx.mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0)); - if (ctx.mtu == 0) { - usage(argv[0]); - return 1; - } - break; - case 'c': - ctx.num_clients = strtol(optarg, NULL, 0); - break; - case 'n': - ctx.num_tests = strtol(optarg, NULL, 0); - break; - case 'l': - ctx.sl = strtol(optarg, NULL, 0); - break; - case 'g': - ctx.gidx = strtol(optarg, NULL, 0); - break; - case 'e': - ctx.use_event = 1; - break; - default: - usage(argv[0]); - return 1; - } - } - - if (optind == argc - 1) { - servername = strdupa(argv[optind]); - ctx.num_clients = 1; - } else if (optind < argc) { - usage(argv[0]); - return 1; - } - - page_size = sysconf(_SC_PAGESIZE); - - if (pp_init_ctx(ib_devname)) - return 1; - - if (pp_post_recv(ctx.num_clients)) { - fprintf(stderr, "Couldn't post receives\n"); - return 1; - } - - if (servername) { - if (pp_client_connect(servername, port)) - return 1; - } else { - if (pp_server_connect(port)) - return 1; - - for (i = 0; i < ctx.num_clients; i++) - pp_post_send(i); - } - - total = ctx.num_clients * ctx.num_tests; - while (cnt < total) { - if (ctx.use_event) { - if (get_cq_event()) - return 1; - - ++num_cq_events; - } - - do { - ne = ibv_poll_cq(ctx.recv_cq, 1, &wc); - if (ne < 0) { - fprintf(stderr, "Error polling cq %d\n", ne); - return 1; - } else if (ne == 0) { - break; - } - - if (wc.status) { - fprintf(stderr, "Work completion error %d\n", wc.status); - return 1; - } - - pp_post_recv(ne); - qpi = find_qp(wc.qp_num); - if (ctx.rem_dest[qpi].pp_cnt < ctx.num_tests) - pp_post_send(qpi); - cnt += ne; - } while (ne > 0); - } - - for (cnt = 0; cnt < ctx.num_clients; cnt += ne) { - ne = ibv_poll_cq(ctx.send_cq, 1, &wc); - if (ne < 0) { - fprintf(stderr, "Error polling cq %d\n", ne); - return 1; - } - } - - if (ctx.use_event) - ibv_ack_cq_events(ctx.recv_cq, num_cq_events); - - /* Process should get an ack from the daemon to close its resources to - * make sure latest daemon's response sent via its target QP destined - * to an XSRQ created by another client won't be lost. - * Failure to do so may cause the other client to wait for that sent - * message forever. See comment on pp_post_send. - */ - if (servername) { - if (pp_client_termination()) - return 1; - } else if (pp_server_termination()) { - return 1; - } - - if (pp_close_ctx()) - return 1; - - printf("success\n"); - return 0; -} diff --git a/usr/rdma-core/libibverbs/ibverbs.h b/usr/rdma-core/libibverbs/ibverbs.h deleted file mode 100644 index 74f2ab81f..000000000 --- a/usr/rdma-core/libibverbs/ibverbs.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef IB_VERBS_H -#define IB_VERBS_H - -#include - -#include - -#include - -#define INIT __attribute__((constructor)) - -#define PFX "libibverbs: " - -struct ibv_abi_compat_v2 { - struct ibv_comp_channel channel; - pthread_mutex_t in_use; -}; - -extern int abi_ver; - -int ibverbs_get_device_list(struct list_head *list); -int ibverbs_init(void); -void ibverbs_device_put(struct ibv_device *dev); -void ibverbs_device_hold(struct ibv_device *dev); - -struct verbs_ex_private { - struct ibv_cq_ex *(*create_cq_ex)(struct ibv_context *context, - struct ibv_cq_init_attr_ex *init_attr); -}; - -#define IBV_INIT_CMD(cmd, size, opcode) \ - do { \ - if (abi_ver > 2) \ - (cmd)->command = IB_USER_VERBS_CMD_##opcode; \ - else \ - (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \ - (cmd)->in_words = (size) / 4; \ - (cmd)->out_words = 0; \ - } while (0) - -#define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \ - do { \ - if (abi_ver > 2) \ - (cmd)->command = IB_USER_VERBS_CMD_##opcode; \ - else \ - (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \ - (cmd)->in_words = (size) / 4; \ - (cmd)->out_words = (outsize) / 4; \ - (cmd)->response = (uintptr_t) (out); \ - } while (0) - -#define IBV_INIT_CMD_RESP_EX_V(cmd, cmd_size, size, opcode, out, resp_size,\ - outsize) \ - do { \ - size_t c_size = cmd_size - sizeof(struct ex_hdr); \ - if (abi_ver > 2) \ - (cmd)->hdr.command = IB_USER_VERBS_CMD_##opcode; \ - else \ - (cmd)->hdr.command = \ - IB_USER_VERBS_CMD_##opcode##_V2; \ - (cmd)->hdr.in_words = ((c_size) / 8); \ - (cmd)->hdr.out_words = ((resp_size) / 8); \ - (cmd)->hdr.provider_in_words = (((size) - (cmd_size))/8);\ - (cmd)->hdr.provider_out_words = \ - (((outsize) - (resp_size)) / 8); \ - (cmd)->hdr.response = (uintptr_t) (out); \ - (cmd)->hdr.reserved = 0; \ - } while (0) - -#define IBV_INIT_CMD_RESP_EX_VCMD(cmd, cmd_size, size, opcode, out, outsize) \ - IBV_INIT_CMD_RESP_EX_V(cmd, cmd_size, size, opcode, out, \ - sizeof(*(out)), outsize) - -#define IBV_INIT_CMD_RESP_EX(cmd, size, opcode, out, outsize) \ - IBV_INIT_CMD_RESP_EX_V(cmd, sizeof(*(cmd)), size, opcode, out, \ - sizeof(*(out)), outsize) - -#define IBV_INIT_CMD_EX(cmd, size, opcode) \ - IBV_INIT_CMD_RESP_EX_V(cmd, sizeof(*(cmd)), size, opcode, NULL, 0, 0) - -#endif /* IB_VERBS_H */ diff --git a/usr/rdma-core/libibverbs/init.c b/usr/rdma-core/libibverbs/init.c deleted file mode 100644 index ff2c60ffc..000000000 --- a/usr/rdma-core/libibverbs/init.c +++ /dev/null @@ -1,721 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "ibverbs.h" - -int abi_ver; - -struct ibv_driver_name { - struct list_node entry; - char *name; -}; - -struct ibv_driver { - struct list_node entry; - const struct verbs_device_ops *ops; -}; - -static LIST_HEAD(driver_name_list); -static LIST_HEAD(driver_list); - -static int find_sysfs_devs(struct list_head *tmp_sysfs_dev_list) -{ - char class_path[IBV_SYSFS_PATH_MAX]; - DIR *class_dir; - struct dirent *dent; - struct verbs_sysfs_dev *sysfs_dev = NULL; - char value[8]; - int ret = 0; - - if (!check_snprintf(class_path, sizeof(class_path), - "%s/class/infiniband_verbs", ibv_get_sysfs_path())) - return ENOMEM; - - class_dir = opendir(class_path); - if (!class_dir) - return ENOSYS; - - while ((dent = readdir(class_dir))) { - struct stat buf; - - if (dent->d_name[0] == '.') - continue; - - if (!sysfs_dev) - sysfs_dev = calloc(1, sizeof(*sysfs_dev)); - if (!sysfs_dev) { - ret = ENOMEM; - goto out; - } - - if (!check_snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path, - "%s/%s", class_path, dent->d_name)) - continue; - - if (stat(sysfs_dev->sysfs_path, &buf)) { - fprintf(stderr, PFX "Warning: couldn't stat '%s'.\n", - sysfs_dev->sysfs_path); - continue; - } - - if (!S_ISDIR(buf.st_mode)) - continue; - - if (!check_snprintf(sysfs_dev->sysfs_name, sizeof sysfs_dev->sysfs_name, - "%s", dent->d_name)) - continue; - - if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "ibdev", - sysfs_dev->ibdev_name, - sizeof sysfs_dev->ibdev_name) < 0) { - fprintf(stderr, PFX "Warning: no ibdev class attr for '%s'.\n", - dent->d_name); - continue; - } - - if (!check_snprintf( - sysfs_dev->ibdev_path, sizeof(sysfs_dev->ibdev_path), - "%s/class/infiniband/%s", ibv_get_sysfs_path(), - sysfs_dev->ibdev_name)) - continue; - - if (stat(sysfs_dev->ibdev_path, &buf)) { - fprintf(stderr, PFX "Warning: couldn't stat '%s'.\n", - sysfs_dev->ibdev_path); - continue; - } - - sysfs_dev->time_created = buf.st_mtim; - - if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "abi_version", - value, sizeof value) > 0) - sysfs_dev->abi_ver = strtol(value, NULL, 10); - - if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, - "device/modalias", sysfs_dev->modalias, - sizeof(sysfs_dev->modalias)) <= 0) - sysfs_dev->modalias[0] = 0; - - list_add(tmp_sysfs_dev_list, &sysfs_dev->entry); - sysfs_dev = NULL; - } - - out: - if (sysfs_dev) - free(sysfs_dev); - - closedir(class_dir); - return ret; -} - -void verbs_register_driver(const struct verbs_device_ops *ops) -{ - struct ibv_driver *driver; - - driver = malloc(sizeof *driver); - if (!driver) { - fprintf(stderr, - PFX "Warning: couldn't allocate driver for %s\n", - ops->name); - return; - } - - driver->ops = ops; - - list_add_tail(&driver_list, &driver->entry); -} - -static void load_driver(const char *name) -{ - char *so_name; - void *dlhandle; - - /* If the name is an absolute path then open that path after appending - the trailer suffix */ - if (name[0] == '/') { - if (asprintf(&so_name, "%s" VERBS_PROVIDER_SUFFIX, name) < 0) - goto out_asprintf; - dlhandle = dlopen(so_name, RTLD_NOW); - if (!dlhandle) - goto out_dlopen; - free(so_name); - return; - } - - /* If configured with a provider plugin path then try that next */ - if (sizeof(VERBS_PROVIDER_DIR) > 1) { - if (asprintf(&so_name, - VERBS_PROVIDER_DIR "/lib%s" VERBS_PROVIDER_SUFFIX, - name) < 0) - goto out_asprintf; - dlhandle = dlopen(so_name, RTLD_NOW); - free(so_name); - if (dlhandle) - return; - } - - /* Otherwise use the system libary search path. This is the historical - behavior of libibverbs */ - if (asprintf(&so_name, "lib%s" VERBS_PROVIDER_SUFFIX, name) < 0) - goto out_asprintf; - dlhandle = dlopen(so_name, RTLD_NOW); - if (!dlhandle) - goto out_dlopen; - free(so_name); - return; - -out_asprintf: - fprintf(stderr, PFX "Warning: couldn't load driver '%s'.\n", name); - return; -out_dlopen: - fprintf(stderr, PFX "Warning: couldn't load driver '%s': %s\n", so_name, - dlerror()); - free(so_name); - return; -} - -static void load_drivers(void) -{ - struct ibv_driver_name *name, *next_name; - const char *env; - char *list, *env_name; - - /* - * Only use drivers passed in through the calling user's - * environment if we're not running setuid. - */ - if (getuid() == geteuid()) { - if ((env = getenv("RDMAV_DRIVERS"))) { - list = strdupa(env); - while ((env_name = strsep(&list, ":;"))) - load_driver(env_name); - } else if ((env = getenv("IBV_DRIVERS"))) { - list = strdupa(env); - while ((env_name = strsep(&list, ":;"))) - load_driver(env_name); - } - } - - list_for_each_safe(&driver_name_list, name, next_name, entry) { - load_driver(name->name); - free(name->name); - free(name); - } -} - -static void read_config_file(const char *path) -{ - FILE *conf; - char *line = NULL; - char *config; - char *field; - size_t buflen = 0; - ssize_t len; - - conf = fopen(path, "r" STREAM_CLOEXEC); - if (!conf) { - fprintf(stderr, PFX "Warning: couldn't read config file %s.\n", - path); - return; - } - - while ((len = getline(&line, &buflen, conf)) != -1) { - config = line + strspn(line, "\t "); - if (config[0] == '\n' || config[0] == '#') - continue; - - field = strsep(&config, "\n\t "); - - if (strcmp(field, "driver") == 0 && config != NULL) { - struct ibv_driver_name *driver_name; - - config += strspn(config, "\t "); - field = strsep(&config, "\n\t "); - - driver_name = malloc(sizeof *driver_name); - if (!driver_name) { - fprintf(stderr, PFX "Warning: couldn't allocate " - "driver name '%s'.\n", field); - continue; - } - - driver_name->name = strdup(field); - if (!driver_name->name) { - fprintf(stderr, PFX "Warning: couldn't allocate " - "driver name '%s'.\n", field); - free(driver_name); - continue; - } - - list_add(&driver_name_list, &driver_name->entry); - } else - fprintf(stderr, PFX "Warning: ignoring bad config directive " - "'%s' in file '%s'.\n", field, path); - } - - if (line) - free(line); - fclose(conf); -} - -static void read_config(void) -{ - DIR *conf_dir; - struct dirent *dent; - char *path; - - conf_dir = opendir(IBV_CONFIG_DIR); - if (!conf_dir) { - fprintf(stderr, PFX "Warning: couldn't open config directory '%s'.\n", - IBV_CONFIG_DIR); - return; - } - - while ((dent = readdir(conf_dir))) { - struct stat buf; - - if (asprintf(&path, "%s/%s", IBV_CONFIG_DIR, dent->d_name) < 0) { - fprintf(stderr, PFX "Warning: couldn't read config file %s/%s.\n", - IBV_CONFIG_DIR, dent->d_name); - goto out; - } - - if (stat(path, &buf)) { - fprintf(stderr, PFX "Warning: couldn't stat config file '%s'.\n", - path); - goto next; - } - - if (!S_ISREG(buf.st_mode)) - goto next; - - read_config_file(path); -next: - free(path); - } - -out: - closedir(conf_dir); -} - -/* Match a single modalias value */ -static bool match_modalias(const struct verbs_match_ent *ent, const char *value) -{ - char pci_ma[100]; - - switch (ent->kind) { - case VERBS_MATCH_MODALIAS: - return fnmatch(ent->modalias, value, 0) == 0; - case VERBS_MATCH_PCI: - snprintf(pci_ma, sizeof(pci_ma), "pci:v%08Xd%08Xsv*", - ent->vendor, ent->device); - return fnmatch(pci_ma, value, 0) == 0; - default: - return false; - } -} - -/* Search a null terminated table of verbs_match_ent's and return the one - * that matches the device the verbs sysfs device is bound to or NULL. - */ -static const struct verbs_match_ent * -match_modalias_device(const struct verbs_device_ops *ops, - struct verbs_sysfs_dev *sysfs_dev) -{ - const struct verbs_match_ent *i; - - for (i = ops->match_table; i->kind != VERBS_MATCH_SENTINEL; i++) - if (match_modalias(i, sysfs_dev->modalias)) - return i; - - return NULL; -} - -/* Match the device name itself */ -static const struct verbs_match_ent * -match_name(const struct verbs_device_ops *ops, - struct verbs_sysfs_dev *sysfs_dev) -{ - char name_ma[100]; - const struct verbs_match_ent *i; - - if (!check_snprintf(name_ma, sizeof(name_ma), - "rdma_device:N%s", sysfs_dev->ibdev_name)) - return NULL; - - for (i = ops->match_table; i->kind != VERBS_MATCH_SENTINEL; i++) - if (match_modalias(i, name_ma)) - return i; - - return NULL; -} - -/* True if the provider matches the selected rdma sysfs device */ -static bool match_device(const struct verbs_device_ops *ops, - struct verbs_sysfs_dev *sysfs_dev) -{ - if (ops->match_table) { - /* The internally generated alias is checked first, since some - * devices like rxe can attach to a random modalias, including - * ones that match other providers. - */ - sysfs_dev->match = match_name(ops, sysfs_dev); - if (!sysfs_dev->match) - sysfs_dev->match = - match_modalias_device(ops, sysfs_dev); - } - - if (ops->match_device) { - /* If a matching function is provided then it is called - * unconditionally after the table match above, it is - * responsible for determining if the device matches based on - * the match pointer and any other internal information. - */ - if (!ops->match_device(sysfs_dev)) - return false; - } else { - /* With no match function, we must have a table match */ - if (!sysfs_dev->match) - return false; - } - - if (sysfs_dev->abi_ver < ops->match_min_abi_version || - sysfs_dev->abi_ver > ops->match_max_abi_version) { - fprintf(stderr, PFX - "Warning: Driver %s does not support the kernel ABI of %u (supports %u to %u) for device %s\n", - ops->name, sysfs_dev->abi_ver, - ops->match_min_abi_version, - ops->match_max_abi_version, - sysfs_dev->ibdev_path); - return false; - } - return true; -} - -static struct verbs_device *try_driver(const struct verbs_device_ops *ops, - struct verbs_sysfs_dev *sysfs_dev) -{ - struct verbs_device *vdev; - struct ibv_device *dev; - char value[16]; - - if (!match_device(ops, sysfs_dev)) - return NULL; - - vdev = ops->alloc_device(sysfs_dev); - if (!vdev) { - fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n", - sysfs_dev->ibdev_path); - return NULL; - } - - vdev->ops = ops; - - atomic_init(&vdev->refcount, 1); - dev = &vdev->device; - assert(dev->_ops._dummy1 == NULL); - assert(dev->_ops._dummy2 == NULL); - - if (ibv_read_sysfs_file(sysfs_dev->ibdev_path, "node_type", value, sizeof value) < 0) { - fprintf(stderr, PFX "Warning: no node_type attr under %s.\n", - sysfs_dev->ibdev_path); - dev->node_type = IBV_NODE_UNKNOWN; - } else { - dev->node_type = strtol(value, NULL, 10); - if (dev->node_type < IBV_NODE_CA || dev->node_type > IBV_NODE_USNIC_UDP) - dev->node_type = IBV_NODE_UNKNOWN; - } - - switch (dev->node_type) { - case IBV_NODE_CA: - case IBV_NODE_SWITCH: - case IBV_NODE_ROUTER: - dev->transport_type = IBV_TRANSPORT_IB; - break; - case IBV_NODE_RNIC: - dev->transport_type = IBV_TRANSPORT_IWARP; - break; - case IBV_NODE_USNIC: - dev->transport_type = IBV_TRANSPORT_USNIC; - break; - case IBV_NODE_USNIC_UDP: - dev->transport_type = IBV_TRANSPORT_USNIC_UDP; - break; - default: - dev->transport_type = IBV_TRANSPORT_UNKNOWN; - break; - } - - strcpy(dev->dev_name, sysfs_dev->sysfs_name); - strcpy(dev->dev_path, sysfs_dev->sysfs_path); - strcpy(dev->name, sysfs_dev->ibdev_name); - strcpy(dev->ibdev_path, sysfs_dev->ibdev_path); - vdev->sysfs = sysfs_dev; - - return vdev; -} - -static struct verbs_device *try_drivers(struct verbs_sysfs_dev *sysfs_dev) -{ - struct ibv_driver *driver; - struct verbs_device *dev; - - list_for_each(&driver_list, driver, entry) { - dev = try_driver(driver->ops, sysfs_dev); - if (dev) - return dev; - } - - return NULL; -} - -static int check_abi_version(const char *path) -{ - char value[8]; - - if (ibv_read_sysfs_file(path, "class/infiniband_verbs/abi_version", - value, sizeof value) < 0) { - return ENOSYS; - } - - abi_ver = strtol(value, NULL, 10); - - if (abi_ver < IB_USER_VERBS_MIN_ABI_VERSION || - abi_ver > IB_USER_VERBS_MAX_ABI_VERSION) { - fprintf(stderr, PFX "Fatal: kernel ABI version %d " - "doesn't match library version %d.\n", - abi_ver, IB_USER_VERBS_MAX_ABI_VERSION); - return ENOSYS; - } - - return 0; -} - -static void check_memlock_limit(void) -{ - struct rlimit rlim; - - if (!geteuid()) - return; - - if (getrlimit(RLIMIT_MEMLOCK, &rlim)) { - fprintf(stderr, PFX "Warning: getrlimit(RLIMIT_MEMLOCK) failed."); - return; - } - - if (rlim.rlim_cur <= 32768) - fprintf(stderr, PFX "Warning: RLIMIT_MEMLOCK is %lu bytes.\n" - " This will severely limit memory registrations.\n", - rlim.rlim_cur); -} - -static int same_sysfs_dev(struct verbs_sysfs_dev *sysfs1, - struct verbs_sysfs_dev *sysfs2) -{ - if (!strcmp(sysfs1->sysfs_name, sysfs2->sysfs_name) && - ts_cmp(&sysfs1->time_created, - &sysfs2->time_created, ==)) - return 1; - return 0; -} - -/* Match every ibv_sysfs_dev in the sysfs_list to a driver and add a new entry - * to device_list. Once matched to a driver the entry in sysfs_list is - * removed. - */ -static void try_all_drivers(struct list_head *sysfs_list, - struct list_head *device_list, - unsigned int *num_devices) -{ - struct verbs_sysfs_dev *sysfs_dev; - struct verbs_sysfs_dev *tmp; - struct verbs_device *vdev; - - list_for_each_safe(sysfs_list, sysfs_dev, tmp, entry) { - vdev = try_drivers(sysfs_dev); - if (vdev) { - list_del(&sysfs_dev->entry); - /* Ownership of sysfs_dev moves into vdev->sysfs */ - list_add(device_list, &vdev->entry); - (*num_devices)++; - } - } -} - -int ibverbs_get_device_list(struct list_head *device_list) -{ - LIST_HEAD(sysfs_list); - struct verbs_sysfs_dev *sysfs_dev, *next_dev; - struct verbs_device *vdev, *tmp; - static int drivers_loaded; - unsigned int num_devices = 0; - int statically_linked = 0; - int ret; - - ret = find_sysfs_devs(&sysfs_list); - if (ret) - return -ret; - - /* Remove entries from the sysfs_list that are already preset in the - * device_list, and remove entries from the device_list that are not - * present in the sysfs_list. - */ - list_for_each_safe(device_list, vdev, tmp, entry) { - struct verbs_sysfs_dev *old_sysfs = NULL; - - list_for_each(&sysfs_list, sysfs_dev, entry) { - if (same_sysfs_dev(vdev->sysfs, sysfs_dev)) { - old_sysfs = sysfs_dev; - break; - } - } - - if (old_sysfs) { - list_del(&old_sysfs->entry); - free(old_sysfs); - num_devices++; - } else { - list_del(&vdev->entry); - ibverbs_device_put(&vdev->device); - } - } - - try_all_drivers(&sysfs_list, device_list, &num_devices); - - if (list_empty(&sysfs_list) || drivers_loaded) - goto out; - - /* - * Check if we can dlopen() ourselves. If this fails, - * libibverbs is probably statically linked into the - * executable, and we should just give up, since trying to - * dlopen() a driver module will fail spectacularly (loading a - * driver .so will bring in dynamic copies of libibverbs and - * libdl to go along with the static copies the executable - * has, which quickly leads to a crash. - */ - { - void *hand = dlopen(NULL, RTLD_NOW); - if (!hand) { - fprintf(stderr, PFX "Warning: dlopen(NULL) failed, " - "assuming static linking.\n"); - statically_linked = 1; - goto out; - } - dlclose(hand); - } - - load_drivers(); - drivers_loaded = 1; - - try_all_drivers(&sysfs_list, device_list, &num_devices); - -out: - /* Anything left in sysfs_list was not assoicated with a - * driver. - */ - list_for_each_safe(&sysfs_list, sysfs_dev, next_dev, entry) { - if (getenv("IBV_SHOW_WARNINGS")) { - fprintf(stderr, PFX - "Warning: no userspace device-specific driver found for %s\n", - sysfs_dev->sysfs_path); - if (statically_linked) - fprintf(stderr, - " When linking libibverbs statically, driver must be statically linked too.\n"); - } - free(sysfs_dev); - } - - return num_devices; -} - -int ibverbs_init(void) -{ - const char *sysfs_path; - int ret; - - if (getenv("RDMAV_FORK_SAFE") || getenv("IBV_FORK_SAFE")) - if (ibv_fork_init()) - fprintf(stderr, PFX "Warning: fork()-safety requested " - "but init failed\n"); - - sysfs_path = ibv_get_sysfs_path(); - if (!sysfs_path) - return -ENOSYS; - - ret = check_abi_version(sysfs_path); - if (ret) - return -ret; - - check_memlock_limit(); - - read_config(); - - return 0; -} - -void ibverbs_device_hold(struct ibv_device *dev) -{ - struct verbs_device *verbs_device = verbs_get_device(dev); - - atomic_fetch_add(&verbs_device->refcount, 1); -} - -void ibverbs_device_put(struct ibv_device *dev) -{ - struct verbs_device *verbs_device = verbs_get_device(dev); - - if (atomic_fetch_sub(&verbs_device->refcount, 1) == 1) { - free(verbs_device->sysfs); - if (verbs_device->ops->uninit_device) - verbs_device->ops->uninit_device(verbs_device); - } -} diff --git a/usr/rdma-core/libibverbs/kern-abi.h b/usr/rdma-core/libibverbs/kern-abi.h deleted file mode 100644 index 3a0e02a76..000000000 --- a/usr/rdma-core/libibverbs/kern-abi.h +++ /dev/null @@ -1,1339 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. - * Copyright (c) 2005 PathScale, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef KERN_ABI_H -#define KERN_ABI_H - -#include - -/* - * This file must be kept in sync with the kernel's version of - * drivers/infiniband/include/ib_user_verbs.h - */ - -/* - * The minimum and maximum kernel ABI that we can handle. - */ -#define IB_USER_VERBS_MIN_ABI_VERSION 3 -#define IB_USER_VERBS_MAX_ABI_VERSION 6 - -#define IB_USER_VERBS_CMD_THRESHOLD 50 - -enum { - IB_USER_VERBS_CMD_GET_CONTEXT, - IB_USER_VERBS_CMD_QUERY_DEVICE, - IB_USER_VERBS_CMD_QUERY_PORT, - IB_USER_VERBS_CMD_ALLOC_PD, - IB_USER_VERBS_CMD_DEALLOC_PD, - IB_USER_VERBS_CMD_CREATE_AH, - IB_USER_VERBS_CMD_MODIFY_AH, - IB_USER_VERBS_CMD_QUERY_AH, - IB_USER_VERBS_CMD_DESTROY_AH, - IB_USER_VERBS_CMD_REG_MR, - IB_USER_VERBS_CMD_REG_SMR, - IB_USER_VERBS_CMD_REREG_MR, - IB_USER_VERBS_CMD_QUERY_MR, - IB_USER_VERBS_CMD_DEREG_MR, - IB_USER_VERBS_CMD_ALLOC_MW, - IB_USER_VERBS_CMD_BIND_MW, - IB_USER_VERBS_CMD_DEALLOC_MW, - IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL, - IB_USER_VERBS_CMD_CREATE_CQ, - IB_USER_VERBS_CMD_RESIZE_CQ, - IB_USER_VERBS_CMD_DESTROY_CQ, - IB_USER_VERBS_CMD_POLL_CQ, - IB_USER_VERBS_CMD_PEEK_CQ, - IB_USER_VERBS_CMD_REQ_NOTIFY_CQ, - IB_USER_VERBS_CMD_CREATE_QP, - IB_USER_VERBS_CMD_QUERY_QP, - IB_USER_VERBS_CMD_MODIFY_QP, - IB_USER_VERBS_CMD_DESTROY_QP, - IB_USER_VERBS_CMD_POST_SEND, - IB_USER_VERBS_CMD_POST_RECV, - IB_USER_VERBS_CMD_ATTACH_MCAST, - IB_USER_VERBS_CMD_DETACH_MCAST, - IB_USER_VERBS_CMD_CREATE_SRQ, - IB_USER_VERBS_CMD_MODIFY_SRQ, - IB_USER_VERBS_CMD_QUERY_SRQ, - IB_USER_VERBS_CMD_DESTROY_SRQ, - IB_USER_VERBS_CMD_POST_SRQ_RECV, - IB_USER_VERBS_CMD_OPEN_XRCD, - IB_USER_VERBS_CMD_CLOSE_XRCD, - IB_USER_VERBS_CMD_CREATE_XSRQ, - IB_USER_VERBS_CMD_OPEN_QP -}; - -#define IB_USER_VERBS_CMD_COMMAND_MASK 0xff -#define IB_USER_VERBS_CMD_FLAGS_MASK 0xff000000u -#define IB_USER_VERBS_CMD_FLAGS_SHIFT 24 - - -#define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80ul - -/* use this mask for creating extended commands */ -#define IB_USER_VERBS_CMD_EXTENDED_MASK \ - (IB_USER_VERBS_CMD_FLAG_EXTENDED << \ - IB_USER_VERBS_CMD_FLAGS_SHIFT) - - -enum { - IB_USER_VERBS_CMD_QUERY_DEVICE_EX = IB_USER_VERBS_CMD_EXTENDED_MASK | - IB_USER_VERBS_CMD_QUERY_DEVICE, - IB_USER_VERBS_CMD_CREATE_QP_EX = IB_USER_VERBS_CMD_EXTENDED_MASK | - IB_USER_VERBS_CMD_CREATE_QP, - IB_USER_VERBS_CMD_CREATE_CQ_EX = IB_USER_VERBS_CMD_EXTENDED_MASK | - IB_USER_VERBS_CMD_CREATE_CQ, - IB_USER_VERBS_CMD_MODIFY_QP_EX = IB_USER_VERBS_CMD_EXTENDED_MASK | - IB_USER_VERBS_CMD_MODIFY_QP, - IB_USER_VERBS_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_EXTENDED_MASK + - IB_USER_VERBS_CMD_THRESHOLD, - IB_USER_VERBS_CMD_DESTROY_FLOW, - IB_USER_VERBS_CMD_CREATE_WQ, - IB_USER_VERBS_CMD_MODIFY_WQ, - IB_USER_VERBS_CMD_DESTROY_WQ, - IB_USER_VERBS_CMD_CREATE_RWQ_IND_TBL, - IB_USER_VERBS_CMD_DESTROY_RWQ_IND_TBL, -}; - -/* - * Make sure that all structs defined in this file remain laid out so - * that they pack the same way on 32-bit and 64-bit architectures (to - * avoid incompatibility between 32-bit userspace and 64-bit kernels). - * Specifically: - * - Do not use pointer types -- pass pointers in __u64 instead. - * - Make sure that any structure larger than 4 bytes is padded to a - * multiple of 8 bytes. Otherwise the structure size will be - * different between 32-bit and 64-bit architectures. - */ - -struct hdr { - __u32 command; - __u16 in_words; - __u16 out_words; -}; - -struct response_hdr { - __u64 response; -}; - -struct ex_hdr { - struct { - __u32 command; - __u16 in_words; - __u16 out_words; - }; - struct { - __u64 response; - }; - struct { - __u16 provider_in_words; - __u16 provider_out_words; - __u32 reserved; - }; -}; - -struct ibv_kern_async_event { - __u64 element; - __u32 event_type; - __u32 reserved; -}; - -struct ibv_comp_event { - __u64 cq_handle; -}; - -/* - * All commands from userspace should start with a __u32 command field - * followed by __u16 in_words and out_words fields (which give the - * length of the command block and response buffer if any in 32-bit - * words). The kernel driver will read these fields first and read - * the rest of the command struct based on these value. - */ - -struct ibv_query_params { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; -}; - -struct ibv_query_params_resp { - __u32 num_cq_events; -}; - -struct ibv_get_context { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 driver_data[0]; -}; - -struct ibv_get_context_resp { - __u32 async_fd; - __u32 num_comp_vectors; -}; - -struct ibv_query_device { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 driver_data[0]; -}; - -struct ibv_query_device_resp { - __u64 fw_ver; - __be64 node_guid; - __be64 sys_image_guid; - __u64 max_mr_size; - __u64 page_size_cap; - __u32 vendor_id; - __u32 vendor_part_id; - __u32 hw_ver; - __u32 max_qp; - __u32 max_qp_wr; - __u32 device_cap_flags; - __u32 max_sge; - __u32 max_sge_rd; - __u32 max_cq; - __u32 max_cqe; - __u32 max_mr; - __u32 max_pd; - __u32 max_qp_rd_atom; - __u32 max_ee_rd_atom; - __u32 max_res_rd_atom; - __u32 max_qp_init_rd_atom; - __u32 max_ee_init_rd_atom; - __u32 atomic_cap; - __u32 max_ee; - __u32 max_rdd; - __u32 max_mw; - __u32 max_raw_ipv6_qp; - __u32 max_raw_ethy_qp; - __u32 max_mcast_grp; - __u32 max_mcast_qp_attach; - __u32 max_total_mcast_qp_attach; - __u32 max_ah; - __u32 max_fmr; - __u32 max_map_per_fmr; - __u32 max_srq; - __u32 max_srq_wr; - __u32 max_srq_sge; - __u16 max_pkeys; - __u8 local_ca_ack_delay; - __u8 phys_port_cnt; - __u8 reserved[4]; -}; - -struct ibv_query_device_ex { - struct ex_hdr hdr; - __u32 comp_mask; - __u32 reserved; -}; - -struct ibv_odp_caps_resp { - __u64 general_caps; - struct { - __u32 rc_odp_caps; - __u32 uc_odp_caps; - __u32 ud_odp_caps; - } per_transport_caps; - __u32 reserved; -}; - -struct ibv_rss_caps_resp { - __u32 supported_qpts; - __u32 max_rwq_indirection_tables; - __u32 max_rwq_indirection_table_size; - __u32 reserved; -}; - -struct ibv_query_device_resp_ex { - struct ibv_query_device_resp base; - __u32 comp_mask; - __u32 response_length; - struct ibv_odp_caps_resp odp_caps; - __u64 timestamp_mask; - __u64 hca_core_clock; - __u64 device_cap_flags_ex; - struct ibv_rss_caps_resp rss_caps; - __u32 max_wq_type_rq; - __u32 raw_packet_caps; -}; - -struct ibv_query_port { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u8 port_num; - __u8 reserved[7]; - __u64 driver_data[0]; -}; - -struct ibv_query_port_resp { - __u32 port_cap_flags; - __u32 max_msg_sz; - __u32 bad_pkey_cntr; - __u32 qkey_viol_cntr; - __u32 gid_tbl_len; - __u16 pkey_tbl_len; - __u16 lid; - __u16 sm_lid; - __u8 state; - __u8 max_mtu; - __u8 active_mtu; - __u8 lmc; - __u8 max_vl_num; - __u8 sm_sl; - __u8 subnet_timeout; - __u8 init_type_reply; - __u8 active_width; - __u8 active_speed; - __u8 phys_state; - __u8 link_layer; - __u8 reserved[2]; -}; - -struct ibv_alloc_pd { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 driver_data[0]; -}; - -struct ibv_alloc_pd_resp { - __u32 pd_handle; -}; - -struct ibv_dealloc_pd { - __u32 command; - __u16 in_words; - __u16 out_words; - __u32 pd_handle; -}; - -struct ibv_open_xrcd { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 fd; - __u32 oflags; - __u64 driver_data[0]; -}; - -struct ibv_open_xrcd_resp { - __u32 xrcd_handle; -}; - -struct ibv_close_xrcd { - __u32 command; - __u16 in_words; - __u16 out_words; - __u32 xrcd_handle; -}; - -struct ibv_reg_mr { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 start; - __u64 length; - __u64 hca_va; - __u32 pd_handle; - __u32 access_flags; - __u64 driver_data[0]; -}; - -struct ibv_reg_mr_resp { - __u32 mr_handle; - __u32 lkey; - __u32 rkey; -}; - -struct ibv_rereg_mr { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 mr_handle; - __u32 flags; - __u64 start; - __u64 length; - __u64 hca_va; - __u32 pd_handle; - __u32 access_flags; - __u64 driver_data[0]; -}; - -struct ibv_rereg_mr_resp { - __u32 lkey; - __u32 rkey; -}; - -struct ibv_dereg_mr { - __u32 command; - __u16 in_words; - __u16 out_words; - __u32 mr_handle; -}; - -struct ibv_alloc_mw { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 pd_handle; - __u8 mw_type; - __u8 reserved[3]; -}; - -struct ibv_alloc_mw_resp { - __u32 mw_handle; - __u32 rkey; -}; - -struct ibv_dealloc_mw { - __u32 command; - __u16 in_words; - __u16 out_words; - __u32 mw_handle; - __u32 reserved; -}; - -struct ibv_create_comp_channel { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; -}; - -struct ibv_create_comp_channel_resp { - __u32 fd; -}; - -struct ibv_create_cq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 user_handle; - __u32 cqe; - __u32 comp_vector; - __s32 comp_channel; - __u32 reserved; - __u64 driver_data[0]; -}; - -struct ibv_create_cq_resp { - __u32 cq_handle; - __u32 cqe; -}; - -enum ibv_create_cq_ex_kernel_flags { - IBV_CREATE_CQ_EX_KERNEL_FLAG_COMPLETION_TIMESTAMP = 1 << 0, -}; - -struct ibv_create_cq_ex { - struct ex_hdr hdr; - __u64 user_handle; - __u32 cqe; - __u32 comp_vector; - __s32 comp_channel; - __u32 comp_mask; - __u32 flags; - __u32 reserved; -}; - -struct ibv_create_cq_resp_ex { - struct ibv_create_cq_resp base; - __u32 comp_mask; - __u32 response_length; -}; - -struct ibv_kern_wc { - __u64 wr_id; - __u32 status; - __u32 opcode; - __u32 vendor_err; - __u32 byte_len; - __be32 imm_data; - __u32 qp_num; - __u32 src_qp; - __u32 wc_flags; - __u16 pkey_index; - __u16 slid; - __u8 sl; - __u8 dlid_path_bits; - __u8 port_num; - __u8 reserved; -}; - -struct ibv_poll_cq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 cq_handle; - __u32 ne; -}; - -struct ibv_poll_cq_resp { - __u32 count; - __u32 reserved; - struct ibv_kern_wc wc[0]; -}; - -struct ibv_req_notify_cq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u32 cq_handle; - __u32 solicited; -}; - -struct ibv_resize_cq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 cq_handle; - __u32 cqe; - __u64 driver_data[0]; -}; - -struct ibv_resize_cq_resp { - __u32 cqe; - __u32 reserved; - __u64 driver_data[0]; -}; - -struct ibv_destroy_cq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 cq_handle; - __u32 reserved; -}; - -struct ibv_destroy_cq_resp { - __u32 comp_events_reported; - __u32 async_events_reported; -}; - -struct ibv_kern_global_route { - __u8 dgid[16]; - __u32 flow_label; - __u8 sgid_index; - __u8 hop_limit; - __u8 traffic_class; - __u8 reserved; -}; - -struct ibv_kern_ah_attr { - struct ibv_kern_global_route grh; - __u16 dlid; - __u8 sl; - __u8 src_path_bits; - __u8 static_rate; - __u8 is_global; - __u8 port_num; - __u8 reserved; -}; - -struct ibv_kern_qp_attr { - __u32 qp_attr_mask; - __u32 qp_state; - __u32 cur_qp_state; - __u32 path_mtu; - __u32 path_mig_state; - __u32 qkey; - __u32 rq_psn; - __u32 sq_psn; - __u32 dest_qp_num; - __u32 qp_access_flags; - - struct ibv_kern_ah_attr ah_attr; - struct ibv_kern_ah_attr alt_ah_attr; - - /* ib_qp_cap */ - __u32 max_send_wr; - __u32 max_recv_wr; - __u32 max_send_sge; - __u32 max_recv_sge; - __u32 max_inline_data; - - __u16 pkey_index; - __u16 alt_pkey_index; - __u8 en_sqd_async_notify; - __u8 sq_draining; - __u8 max_rd_atomic; - __u8 max_dest_rd_atomic; - __u8 min_rnr_timer; - __u8 port_num; - __u8 timeout; - __u8 retry_cnt; - __u8 rnr_retry; - __u8 alt_port_num; - __u8 alt_timeout; - __u8 reserved[5]; -}; - -#define IBV_CREATE_QP_COMMON \ - __u64 user_handle; \ - __u32 pd_handle; \ - __u32 send_cq_handle; \ - __u32 recv_cq_handle; \ - __u32 srq_handle; \ - __u32 max_send_wr; \ - __u32 max_recv_wr; \ - __u32 max_send_sge; \ - __u32 max_recv_sge; \ - __u32 max_inline_data; \ - __u8 sq_sig_all; \ - __u8 qp_type; \ - __u8 is_srq; \ - __u8 reserved - -struct ibv_create_qp { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - IBV_CREATE_QP_COMMON; - __u64 driver_data[0]; -}; - -struct ibv_create_qp_common { - IBV_CREATE_QP_COMMON; -}; - -struct ibv_open_qp { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 user_handle; - __u32 pd_handle; - __u32 qpn; - __u8 qp_type; - __u8 reserved[7]; - __u64 driver_data[0]; -}; - -/* also used for open response */ -struct ibv_create_qp_resp { - __u32 qp_handle; - __u32 qpn; - __u32 max_send_wr; - __u32 max_recv_wr; - __u32 max_send_sge; - __u32 max_recv_sge; - __u32 max_inline_data; - __u32 reserved; -}; - -enum ibv_create_qp_ex_kernel_mask { - IBV_CREATE_QP_EX_KERNEL_MASK_IND_TABLE = 1 << 0, -}; - -struct ibv_create_qp_ex { - struct ex_hdr hdr; - struct ibv_create_qp_common base; - __u32 comp_mask; - __u32 create_flags; - __u32 ind_tbl_handle; - __u32 source_qpn; -}; - -struct ibv_create_qp_resp_ex { - struct ibv_create_qp_resp base; - __u32 comp_mask; - __u32 response_length; -}; - -struct ibv_qp_dest { - __u8 dgid[16]; - __u32 flow_label; - __u16 dlid; - __u16 reserved; - __u8 sgid_index; - __u8 hop_limit; - __u8 traffic_class; - __u8 sl; - __u8 src_path_bits; - __u8 static_rate; - __u8 is_global; - __u8 port_num; -}; - -struct ibv_query_qp { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 qp_handle; - __u32 attr_mask; - __u64 driver_data[0]; -}; - -struct ibv_query_qp_resp { - struct ibv_qp_dest dest; - struct ibv_qp_dest alt_dest; - __u32 max_send_wr; - __u32 max_recv_wr; - __u32 max_send_sge; - __u32 max_recv_sge; - __u32 max_inline_data; - __u32 qkey; - __u32 rq_psn; - __u32 sq_psn; - __u32 dest_qp_num; - __u32 qp_access_flags; - __u16 pkey_index; - __u16 alt_pkey_index; - __u8 qp_state; - __u8 cur_qp_state; - __u8 path_mtu; - __u8 path_mig_state; - __u8 sq_draining; - __u8 max_rd_atomic; - __u8 max_dest_rd_atomic; - __u8 min_rnr_timer; - __u8 port_num; - __u8 timeout; - __u8 retry_cnt; - __u8 rnr_retry; - __u8 alt_port_num; - __u8 alt_timeout; - __u8 sq_sig_all; - __u8 reserved[5]; - __u64 driver_data[0]; -}; - -struct ibv_modify_qp_common { - struct ibv_qp_dest dest; - struct ibv_qp_dest alt_dest; - __u32 qp_handle; - __u32 attr_mask; - __u32 qkey; - __u32 rq_psn; - __u32 sq_psn; - __u32 dest_qp_num; - __u32 qp_access_flags; - __u16 pkey_index; - __u16 alt_pkey_index; - __u8 qp_state; - __u8 cur_qp_state; - __u8 path_mtu; - __u8 path_mig_state; - __u8 en_sqd_async_notify; - __u8 max_rd_atomic; - __u8 max_dest_rd_atomic; - __u8 min_rnr_timer; - __u8 port_num; - __u8 timeout; - __u8 retry_cnt; - __u8 rnr_retry; - __u8 alt_port_num; - __u8 alt_timeout; - __u8 reserved[2]; -}; - -struct ibv_modify_qp { - __u32 command; - __u16 in_words; - __u16 out_words; - struct ibv_modify_qp_common base; - __u64 driver_data[0]; -}; - -struct ibv_modify_qp_ex { - struct ex_hdr hdr; - struct ibv_modify_qp_common base; - __u32 rate_limit; - __u32 reserved; -}; - -struct ibv_modify_qp_resp_ex { - __u32 comp_mask; - __u32 response_length; -}; - -struct ibv_destroy_qp { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 qp_handle; - __u32 reserved; -}; - -struct ibv_destroy_qp_resp { - __u32 events_reported; -}; - -struct ibv_kern_send_wr { - __u64 wr_id; - __u32 num_sge; - __u32 opcode; - __u32 send_flags; - __be32 imm_data; - union { - struct { - __u64 remote_addr; - __u32 rkey; - __u32 reserved; - } rdma; - struct { - __u64 remote_addr; - __u64 compare_add; - __u64 swap; - __u32 rkey; - __u32 reserved; - } atomic; - struct { - __u32 ah; - __u32 remote_qpn; - __u32 remote_qkey; - __u32 reserved; - } ud; - } wr; - union { - struct { - __u32 remote_srqn; - } xrc; - } qp_type; -}; - -struct ibv_kern_eth_filter { - __u8 dst_mac[6]; - __u8 src_mac[6]; - __u16 ether_type; - __u16 vlan_tag; -}; - -struct ibv_kern_spec_eth { - __u32 type; - __u16 size; - __u16 reserved; - struct ibv_kern_eth_filter val; - struct ibv_kern_eth_filter mask; -}; - -struct ibv_kern_ipv4_filter { - __u32 src_ip; - __u32 dst_ip; -}; - -struct ibv_kern_spec_ipv4 { - __u32 type; - __u16 size; - __u16 reserved; - struct ibv_kern_ipv4_filter val; - struct ibv_kern_ipv4_filter mask; -}; - -struct ibv_kern_ipv4_ext_filter { - __u32 src_ip; - __u32 dst_ip; - __u8 proto; - __u8 tos; - __u8 ttl; - __u8 flags; -}; - -struct ibv_kern_spec_ipv4_ext { - __u32 type; - __u16 size; - __u16 reserved; - struct ibv_kern_ipv4_ext_filter val; - struct ibv_kern_ipv4_ext_filter mask; -}; - -struct ibv_kern_ipv6_filter { - __u8 src_ip[16]; - __u8 dst_ip[16]; - __u32 flow_label; - __u8 next_hdr; - __u8 traffic_class; - __u8 hop_limit; - __u8 reserved; -}; - -struct ibv_kern_spec_ipv6 { - __u32 type; - __u16 size; - __u16 reserved; - struct ibv_kern_ipv6_filter val; - struct ibv_kern_ipv6_filter mask; -}; - -struct ibv_kern_tcp_udp_filter { - __u16 dst_port; - __u16 src_port; -}; - -struct ibv_kern_spec_tcp_udp { - __u32 type; - __u16 size; - __u16 reserved; - struct ibv_kern_tcp_udp_filter val; - struct ibv_kern_tcp_udp_filter mask; -}; - -struct ibv_kern_spec_action_tag { - __u32 type; - __u16 size; - __u16 reserved; - __u32 tag_id; - __u32 reserved1; -}; - -struct ibv_kern_tunnel_filter { - __u32 tunnel_id; -}; - -struct ibv_kern_spec_tunnel { - __u32 type; - __u16 size; - __u16 reserved; - struct ibv_kern_tunnel_filter val; - struct ibv_kern_tunnel_filter mask; -}; - -struct ibv_kern_spec_action_drop { - __u32 type; - __u16 size; - __u16 reserved; -}; - -struct ibv_kern_spec { - union { - struct { - __u32 type; - __u16 size; - __u16 reserved; - } hdr; - struct ibv_kern_spec_eth eth; - struct ibv_kern_spec_ipv4 ipv4; - struct ibv_kern_spec_ipv4_ext ipv4_ext; - struct ibv_kern_spec_tcp_udp tcp_udp; - struct ibv_kern_spec_ipv6 ipv6; - struct ibv_kern_spec_tunnel tunnel; - struct ibv_kern_spec_action_tag flow_tag; - struct ibv_kern_spec_action_drop drop; - }; -}; - -struct ibv_kern_flow_attr { - __u32 type; - __u16 size; - __u16 priority; - __u8 num_of_specs; - __u8 reserved[2]; - __u8 port; - __u32 flags; - /* Following are the optional layers according to user request - * struct ibv_kern_flow_spec_xxx - * struct ibv_kern_flow_spec_yyy - */ -}; - -struct ibv_post_send { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 qp_handle; - __u32 wr_count; - __u32 sge_count; - __u32 wqe_size; - struct ibv_kern_send_wr send_wr[0]; -}; - -struct ibv_post_send_resp { - __u32 bad_wr; -}; - -struct ibv_kern_recv_wr { - __u64 wr_id; - __u32 num_sge; - __u32 reserved; -}; - -struct ibv_post_recv { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 qp_handle; - __u32 wr_count; - __u32 sge_count; - __u32 wqe_size; - struct ibv_kern_recv_wr recv_wr[0]; -}; - -struct ibv_post_recv_resp { - __u32 bad_wr; -}; - -struct ibv_post_srq_recv { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 srq_handle; - __u32 wr_count; - __u32 sge_count; - __u32 wqe_size; - struct ibv_kern_recv_wr recv_wr[0]; -}; - -struct ibv_post_srq_recv_resp { - __u32 bad_wr; -}; - -struct ibv_create_ah { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 user_handle; - __u32 pd_handle; - __u32 reserved; - struct ibv_kern_ah_attr attr; -}; - -struct ibv_create_ah_resp { - __u32 handle; -}; - -struct ibv_destroy_ah { - __u32 command; - __u16 in_words; - __u16 out_words; - __u32 ah_handle; -}; - -struct ibv_attach_mcast { - __u32 command; - __u16 in_words; - __u16 out_words; - __u8 gid[16]; - __u32 qp_handle; - __u16 mlid; - __u16 reserved; - __u64 driver_data[0]; -}; - -struct ibv_create_flow { - struct ex_hdr hdr; - __u32 comp_mask; - __u32 qp_handle; - struct ibv_kern_flow_attr flow_attr; -}; - -struct ibv_create_flow_resp { - __u32 comp_mask; - __u32 flow_handle; -}; - -struct ibv_destroy_flow { - struct ex_hdr hdr; - __u32 comp_mask; - __u32 flow_handle; -}; - -struct ibv_detach_mcast { - __u32 command; - __u16 in_words; - __u16 out_words; - __u8 gid[16]; - __u32 qp_handle; - __u16 mlid; - __u16 reserved; - __u64 driver_data[0]; -}; - -struct ibv_create_srq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 user_handle; - __u32 pd_handle; - __u32 max_wr; - __u32 max_sge; - __u32 srq_limit; - __u64 driver_data[0]; -}; - -struct ibv_create_xsrq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u64 user_handle; - __u32 srq_type; - __u32 pd_handle; - __u32 max_wr; - __u32 max_sge; - __u32 srq_limit; - __u32 reserved; - __u32 xrcd_handle; - __u32 cq_handle; - __u64 driver_data[0]; -}; - -struct ibv_create_srq_resp { - __u32 srq_handle; - __u32 max_wr; - __u32 max_sge; - __u32 srqn; -}; - -struct ibv_modify_srq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u32 srq_handle; - __u32 attr_mask; - __u32 max_wr; - __u32 srq_limit; - __u64 driver_data[0]; -}; - -struct ibv_query_srq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 srq_handle; - __u32 reserved; - __u64 driver_data[0]; -}; - -struct ibv_query_srq_resp { - __u32 max_wr; - __u32 max_sge; - __u32 srq_limit; - __u32 reserved; -}; - -struct ibv_destroy_srq { - __u32 command; - __u16 in_words; - __u16 out_words; - __u64 response; - __u32 srq_handle; - __u32 reserved; -}; - -struct ibv_destroy_srq_resp { - __u32 events_reported; -}; - -/* - * Compatibility with older ABI versions - */ - -enum { - IB_USER_VERBS_CMD_QUERY_PARAMS_V2, - IB_USER_VERBS_CMD_GET_CONTEXT_V2, - IB_USER_VERBS_CMD_QUERY_DEVICE_V2, - IB_USER_VERBS_CMD_QUERY_PORT_V2, - IB_USER_VERBS_CMD_QUERY_GID_V2, - IB_USER_VERBS_CMD_QUERY_PKEY_V2, - IB_USER_VERBS_CMD_ALLOC_PD_V2, - IB_USER_VERBS_CMD_DEALLOC_PD_V2, - IB_USER_VERBS_CMD_CREATE_AH_V2, - IB_USER_VERBS_CMD_MODIFY_AH_V2, - IB_USER_VERBS_CMD_QUERY_AH_V2, - IB_USER_VERBS_CMD_DESTROY_AH_V2, - IB_USER_VERBS_CMD_REG_MR_V2, - IB_USER_VERBS_CMD_REG_SMR_V2, - IB_USER_VERBS_CMD_REREG_MR_V2, - IB_USER_VERBS_CMD_QUERY_MR_V2, - IB_USER_VERBS_CMD_DEREG_MR_V2, - IB_USER_VERBS_CMD_ALLOC_MW_V2, - IB_USER_VERBS_CMD_BIND_MW_V2, - IB_USER_VERBS_CMD_DEALLOC_MW_V2, - IB_USER_VERBS_CMD_CREATE_CQ_V2, - IB_USER_VERBS_CMD_RESIZE_CQ_V2, - IB_USER_VERBS_CMD_DESTROY_CQ_V2, - IB_USER_VERBS_CMD_POLL_CQ_V2, - IB_USER_VERBS_CMD_PEEK_CQ_V2, - IB_USER_VERBS_CMD_REQ_NOTIFY_CQ_V2, - IB_USER_VERBS_CMD_CREATE_QP_V2, - IB_USER_VERBS_CMD_QUERY_QP_V2, - IB_USER_VERBS_CMD_MODIFY_QP_V2, - IB_USER_VERBS_CMD_DESTROY_QP_V2, - IB_USER_VERBS_CMD_POST_SEND_V2, - IB_USER_VERBS_CMD_POST_RECV_V2, - IB_USER_VERBS_CMD_ATTACH_MCAST_V2, - IB_USER_VERBS_CMD_DETACH_MCAST_V2, - IB_USER_VERBS_CMD_CREATE_SRQ_V2, - IB_USER_VERBS_CMD_MODIFY_SRQ_V2, - IB_USER_VERBS_CMD_QUERY_SRQ_V2, - IB_USER_VERBS_CMD_DESTROY_SRQ_V2, - IB_USER_VERBS_CMD_POST_SRQ_RECV_V2, - /* - * Set commands that didn't exist to -1 so our compile-time - * trick opcodes in IBV_INIT_CMD() doesn't break. - */ - IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL_V2 = -1, - IB_USER_VERBS_CMD_OPEN_XRCD_V2 = -1, - IB_USER_VERBS_CMD_CLOSE_XRCD_V2 = -1, - IB_USER_VERBS_CMD_CREATE_XSRQ_V2 = -1, - IB_USER_VERBS_CMD_OPEN_QP_V2 = -1, - IB_USER_VERBS_CMD_CREATE_FLOW_V2 = -1, - IB_USER_VERBS_CMD_DESTROY_FLOW_V2 = -1, - IB_USER_VERBS_CMD_QUERY_DEVICE_EX_V2 = -1, - IB_USER_VERBS_CMD_CREATE_QP_EX_V2 = -1, - IB_USER_VERBS_CMD_CREATE_CQ_EX_V2 = -1, - IB_USER_VERBS_CMD_CREATE_WQ_V2 = -1, - IB_USER_VERBS_CMD_MODIFY_WQ_V2 = -1, - IB_USER_VERBS_CMD_DESTROY_WQ_V2 = -1, - IB_USER_VERBS_CMD_CREATE_RWQ_IND_TBL_V2 = -1, - IB_USER_VERBS_CMD_DESTROY_RWQ_IND_TBL_V2 = -1, - IB_USER_VERBS_CMD_MODIFY_QP_EX_V2 = -1, -}; - -struct ibv_modify_srq_v3 { - __u32 command; - __u16 in_words; - __u16 out_words; - __u32 srq_handle; - __u32 attr_mask; - __u32 max_wr; - __u32 max_sge; - __u32 srq_limit; - __u32 reserved; - __u64 driver_data[0]; -}; - -struct ibv_create_qp_resp_v3 { - __u32 qp_handle; - __u32 qpn; -}; - -struct ibv_create_qp_resp_v4 { - __u32 qp_handle; - __u32 qpn; - __u32 max_send_wr; - __u32 max_recv_wr; - __u32 max_send_sge; - __u32 max_recv_sge; - __u32 max_inline_data; -}; - -struct ibv_create_srq_resp_v5 { - __u32 srq_handle; -}; - -struct ibv_create_wq { - struct ex_hdr hdr; - __u32 comp_mask; - __u32 wq_type; - __u64 user_handle; - __u32 pd_handle; - __u32 cq_handle; - __u32 max_wr; - __u32 max_sge; - __u32 create_flags; - __u32 reserved; -}; - -struct ibv_create_wq_resp { - __u32 comp_mask; - __u32 response_length; - __u32 wq_handle; - __u32 max_wr; - __u32 max_sge; - __u32 wqn; -}; - -struct ibv_destroy_wq { - struct ex_hdr hdr; - __u32 comp_mask; - __u32 wq_handle; -}; - -struct ibv_destroy_wq_resp { - __u32 comp_mask; - __u32 response_length; - __u32 events_reported; - __u32 reserved; -}; - -struct ibv_modify_wq { - struct ex_hdr hdr; - __u32 attr_mask; - __u32 wq_handle; - __u32 wq_state; - __u32 curr_wq_state; - __u32 flags; - __u32 flags_mask; -}; - -struct ibv_create_rwq_ind_table { - struct ex_hdr hdr; - __u32 comp_mask; - __u32 log_ind_tbl_size; - /* Following are wq handles based on log_ind_tbl_size, must be 64 bytes aligned. - * __u32 wq_handle1 - * __u32 wq_handle2 - */ -}; - -struct ibv_create_rwq_ind_table_resp { - __u32 comp_mask; - __u32 response_length; - __u32 ind_tbl_handle; - __u32 ind_tbl_num; -}; - -struct ibv_destroy_rwq_ind_table { - struct ex_hdr hdr; - __u32 comp_mask; - __u32 ind_tbl_handle; -}; - -#endif /* KERN_ABI_H */ diff --git a/usr/rdma-core/libibverbs/libibverbs.map.in b/usr/rdma-core/libibverbs/libibverbs.map.in deleted file mode 100644 index 39d9d0510..000000000 --- a/usr/rdma-core/libibverbs/libibverbs.map.in +++ /dev/null @@ -1,142 +0,0 @@ -/* Do not change this file without reading Documentation/versioning.md */ -IBVERBS_1.0 { - global: - ibv_get_device_list; - ibv_free_device_list; - ibv_get_device_name; - ibv_get_device_guid; - ibv_open_device; - ibv_close_device; - ibv_get_async_event; - ibv_ack_async_event; - ibv_query_device; - ibv_query_device_ex; - ibv_query_port; - ibv_query_gid; - ibv_query_pkey; - ibv_alloc_pd; - ibv_dealloc_pd; - ibv_reg_mr; - ibv_dereg_mr; - ibv_create_comp_channel; - ibv_destroy_comp_channel; - ibv_create_cq; - ibv_resize_cq; - ibv_destroy_cq; - ibv_get_cq_event; - ibv_ack_cq_events; - ibv_create_srq; - ibv_modify_srq; - ibv_query_srq; - ibv_destroy_srq; - ibv_create_qp; - ibv_query_qp; - ibv_modify_qp; - ibv_destroy_qp; - ibv_create_ah; - ibv_destroy_ah; - ibv_attach_mcast; - ibv_detach_mcast; - ibv_rate_to_mult; - mult_to_ibv_rate; - - /* These historical symbols are now private to libibverbs, but used by - other rdma-core libraries. Do not change them. */ - ibv_copy_path_rec_from_kern; - ibv_copy_path_rec_to_kern; - ibv_copy_qp_attr_from_kern; - ibv_get_sysfs_path; - ibv_read_sysfs_file; - - local: *; -}; - -IBVERBS_1.1 { - global: - ibv_get_device_list; - ibv_free_device_list; - ibv_get_device_name; - ibv_get_device_guid; - ibv_open_device; - ibv_close_device; - - ibv_init_ah_from_wc; - ibv_create_ah_from_wc; - ibv_fork_init; - ibv_dontfork_range; - ibv_dofork_range; - ibv_register_driver; - - ibv_node_type_str; - ibv_port_state_str; - ibv_event_type_str; - ibv_wc_status_str; - - ibv_rate_to_mbps; - mbps_to_ibv_rate; - - ibv_resolve_eth_l2_from_gid; - - /* These historical symbols are now private to libibverbs, but used by - other rdma-core libraries. Do not change them. */ - ibv_copy_ah_attr_from_kern; -} IBVERBS_1.0; - -/* NOTE: The next stanza for public symbols should be IBVERBS_1.4 due to release 12 */ - -/* If any symbols in this stanza change ABI then the entire staza gets a new symbol - version. See the top level CMakeLists.txt for this setting. */ -IBVERBS_PRIVATE_@IBVERBS_PABI_VERSION@ { - global: - /* These historical symbols are now private to libibverbs */ - ibv_cmd_alloc_mw; - ibv_cmd_alloc_pd; - ibv_cmd_attach_mcast; - ibv_cmd_close_xrcd; - ibv_cmd_create_ah; - ibv_cmd_create_cq; - ibv_cmd_create_cq_ex; - ibv_cmd_create_flow; - ibv_cmd_create_qp; - ibv_cmd_create_qp_ex2; - ibv_cmd_create_qp_ex; - ibv_cmd_create_rwq_ind_table; - ibv_cmd_create_srq; - ibv_cmd_create_srq_ex; - ibv_cmd_create_wq; - ibv_cmd_dealloc_mw; - ibv_cmd_dealloc_pd; - ibv_cmd_dereg_mr; - ibv_cmd_destroy_ah; - ibv_cmd_destroy_cq; - ibv_cmd_destroy_flow; - ibv_cmd_destroy_qp; - ibv_cmd_destroy_rwq_ind_table; - ibv_cmd_destroy_srq; - ibv_cmd_destroy_wq; - ibv_cmd_detach_mcast; - ibv_cmd_get_context; - ibv_cmd_modify_qp; - ibv_cmd_modify_qp_ex; - ibv_cmd_modify_srq; - ibv_cmd_modify_wq; - ibv_cmd_open_qp; - ibv_cmd_open_xrcd; - ibv_cmd_poll_cq; - ibv_cmd_post_recv; - ibv_cmd_post_send; - ibv_cmd_post_srq_recv; - ibv_cmd_query_device; - ibv_cmd_query_device_ex; - ibv_cmd_query_port; - ibv_cmd_query_qp; - ibv_cmd_query_srq; - ibv_cmd_reg_mr; - ibv_cmd_req_notify_cq; - ibv_cmd_rereg_mr; - ibv_cmd_resize_cq; - ibv_query_gid_type; - ibv_register_driver; - verbs_register_driver_@IBVERBS_PABI_VERSION@; - verbs_init_cq; -}; diff --git a/usr/rdma-core/libibverbs/man/CMakeLists.txt b/usr/rdma-core/libibverbs/man/CMakeLists.txt deleted file mode 100644 index 05313e5b9..000000000 --- a/usr/rdma-core/libibverbs/man/CMakeLists.txt +++ /dev/null @@ -1,83 +0,0 @@ -rdma_man_pages( - ibv_alloc_mw.3 - ibv_alloc_pd.3 - ibv_asyncwatch.1 - ibv_attach_mcast.3 - ibv_bind_mw.3 - ibv_create_ah.3 - ibv_create_ah_from_wc.3 - ibv_create_comp_channel.3 - ibv_create_cq.3 - ibv_create_cq_ex.3 - ibv_create_flow.3 - ibv_create_qp.3 - ibv_create_qp_ex.3 - ibv_create_rwq_ind_table.3 - ibv_create_srq.3 - ibv_create_srq_ex.3 - ibv_create_wq.3 - ibv_devices.1 - ibv_devinfo.1 - ibv_event_type_str.3 - ibv_fork_init.3 - ibv_get_async_event.3 - ibv_get_cq_event.3 - ibv_get_device_guid.3 - ibv_get_device_list.3 - ibv_get_device_name.3 - ibv_get_srq_num.3 - ibv_inc_rkey.3 - ibv_modify_qp.3 - ibv_modify_srq.3 - ibv_modify_wq.3 - ibv_open_device.3 - ibv_open_qp.3 - ibv_open_xrcd.3 - ibv_poll_cq.3 - ibv_post_recv.3 - ibv_post_send.3 - ibv_post_srq_recv.3 - ibv_query_device.3 - ibv_query_device_ex.3 - ibv_query_gid.3 - ibv_query_pkey.3 - ibv_query_port.3 - ibv_query_qp.3 - ibv_query_rt_values_ex.3 - ibv_query_srq.3 - ibv_rate_to_mbps.3 - ibv_rate_to_mult.3 - ibv_rc_pingpong.1 - ibv_reg_mr.3 - ibv_req_notify_cq.3 - ibv_rereg_mr.3 - ibv_resize_cq.3 - ibv_srq_pingpong.1 - ibv_uc_pingpong.1 - ibv_ud_pingpong.1 - ibv_xsrq_pingpong.1 - ) -rdma_alias_man_pages( - ibv_alloc_mw.3 ibv_dealloc_mw.3 - ibv_alloc_pd.3 ibv_dealloc_pd.3 - ibv_attach_mcast.3 ibv_detach_mcast.3 - ibv_create_ah.3 ibv_destroy_ah.3 - ibv_create_ah_from_wc.3 ibv_init_ah_from_wc.3 - ibv_create_comp_channel.3 ibv_destroy_comp_channel.3 - ibv_create_cq.3 ibv_destroy_cq.3 - ibv_create_flow.3 ibv_destroy_flow.3 - ibv_create_qp.3 ibv_destroy_qp.3 - ibv_create_rwq_ind_table.3 ibv_destroy_rwq_ind_table.3 - ibv_create_srq.3 ibv_destroy_srq.3 - ibv_create_wq.3 ibv_destroy_wq.3 - ibv_event_type_str.3 ibv_node_type_str.3 - ibv_event_type_str.3 ibv_port_state_str.3 - ibv_get_async_event.3 ibv_ack_async_event.3 - ibv_get_cq_event.3 ibv_ack_cq_events.3 - ibv_get_device_list.3 ibv_free_device_list.3 - ibv_open_device.3 ibv_close_device.3 - ibv_open_xrcd.3 ibv_close_xrcd.3 - ibv_rate_to_mbps.3 mbps_to_ibv_rate.3 - ibv_rate_to_mult.3 mult_to_ibv_rate.3 - ibv_reg_mr.3 ibv_dereg_mr.3 - ) \ No newline at end of file diff --git a/usr/rdma-core/libibverbs/man/ibv_alloc_mw.3 b/usr/rdma-core/libibverbs/man/ibv_alloc_mw.3 deleted file mode 100644 index 86acacabf..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_alloc_mw.3 +++ /dev/null @@ -1,55 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_ALLOC_MW 3 2016-02-02 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_alloc_mw, ibv_dealloc_mw \- allocate or deallocate a memory window (MW) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_mw *ibv_alloc_mw(struct ibv_pd " "*pd" , -.BI " enum ibv_mw_type " "type"); -.sp -.BI "int ibv_dealloc_mw(struct ibv_mw " "*mw" ); -.fi -.SH "DESCRIPTION" -.B ibv_alloc_mw() -allocates a memory window (MW) associated with the protection domain -.I pd\fR. -The MW's type (1 or 2A/2B) is -.I type\fR. -.PP -The MW is created not bound. For it to be useful, the MW must be bound, through either ibv_bind_mw (type 1) or a special WR (type 2). -Once bound, the memory window allows RDMA (remote) access to a subset of the MR to which it was bound, -until invalidated by: ibv_bind_mw verb with zero length for type 1, -IBV_WR_LOCAL_INV/IBV_WR_SEND_WITH_INV WR opcode for type 2, deallocation. -.PP -.B ibv_dealloc_mw() -Unbinds in case was previously bound and deallocates the MW -.I mw\fR. -.SH "RETURN VALUE" -.B ibv_alloc_mw() -returns a pointer to the allocated MW, or NULL if the request fails. -The remote key (\fBR_Key\fR) -field -.B rkey -is used by remote processes to perform Atomic and RDMA operations. This key will be changed during bind operations. The remote process places this -.B rkey -as the rkey field of struct ibv_send_wr passed to the ibv_post_send function. -.PP -.B ibv_dealloc_mw() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_dereg_mr() -fails if any memory window is still bound to this MR. -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_post_send (3), -.BR ibv_bind_mw (3), -.BR ibv_reg_mr (3), -.SH "AUTHORS" -.TP -Majd Dibbiny -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_alloc_pd.3 b/usr/rdma-core/libibverbs/man/ibv_alloc_pd.3 deleted file mode 100644 index cc475f4a2..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_alloc_pd.3 +++ /dev/null @@ -1,41 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_ALLOC_PD 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_alloc_pd, ibv_dealloc_pd \- allocate or deallocate a protection domain (PDs) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_pd *ibv_alloc_pd(struct ibv_context " "*context" ); -.sp -.BI "int ibv_dealloc_pd(struct ibv_pd " "*pd" ); -.fi -.SH "DESCRIPTION" -.B ibv_alloc_pd() -allocates a PD for the RDMA device context -.I context\fR. -.PP -.B ibv_dealloc_pd() -deallocates the PD -.I pd\fR. -.SH "RETURN VALUE" -.B ibv_alloc_pd() -returns a pointer to the allocated PD, or NULL if the request fails. -.PP -.B ibv_dealloc_pd() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_dealloc_pd() -may fail if any other resource is still associated with the PD being -freed. -.SH "SEE ALSO" -.BR ibv_reg_mr (3), -.BR ibv_create_srq (3), -.BR ibv_create_qp (3), -.BR ibv_create_ah (3), -.BR ibv_create_ah_from_wc (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_asyncwatch.1 b/usr/rdma-core/libibverbs/man/ibv_asyncwatch.1 deleted file mode 100644 index ae1011757..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_asyncwatch.1 +++ /dev/null @@ -1,31 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_ASYNCWATCH 1 "August 30, 2005" "libibverbs" "USER COMMANDS" - -.SH NAME -ibv_asyncwatch \- display asynchronous events - -.SH SYNOPSIS -.B ibv_asyncwatch -[\-d device] [-h] - -.SH DESCRIPTION -.PP -Display asynchronous events forwarded to userspace for an RDMA device. - -.SH OPTIONS - -.PP -.TP -\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR -use IB device \fIDEVICE\fR (default first device found) -.TP -\fB\-h\fR, \fB\-\-help\fR=\fIDEVICE\fR -Print a help text and exit. - -.SH AUTHORS -.TP -Roland Dreier -.RI < rolandd@cisco.com > -.TP -Eran Ben Elisha -.RI < eranbe@mellanox.com > diff --git a/usr/rdma-core/libibverbs/man/ibv_attach_mcast.3 b/usr/rdma-core/libibverbs/man/ibv_attach_mcast.3 deleted file mode 100644 index 2ae1f5d08..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_attach_mcast.3 +++ /dev/null @@ -1,54 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_ATTACH_MCAST 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_attach_mcast, ibv_detach_mcast \- attach and detach a queue pair -(QPs) to/from a multicast group -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_attach_mcast(struct ibv_qp " "*qp" ", const union ibv_gid " "*gid" ", -.BI " uint16_t " "lid" "); -.sp -.BI "int ibv_detach_mcast(struct ibv_qp " "*qp" ", const union ibv_gid " "*gid" ", -.BI " uint16_t " "lid" "); -.fi -.SH "DESCRIPTION" -.B ibv_attach_mcast() -attaches the QP -.I qp -to the multicast group having MGID -.I gid -and MLID -.I lid\fR. -.PP -.B ibv_detach_mcast() -detaches the QP -.I qp -to the multicast group having MGID -.I gid -and MLID -.I lid\fR. -.SH "RETURN VALUE" -.B ibv_attach_mcast() -and -.B ibv_detach_mcast() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -Only QPs of Transport Service Type -.BR IBV_QPT_UD -may be attached to multicast groups. -.PP -If a QP is attached to the same multicast group multiple times, the QP will still receive a single copy of a multicast message. -.PP -In order to receive multicast messages, a join request for the -multicast group must be sent to the subnet administrator (SA), so that -the fabric's multicast routing is configured to deliver messages to -the local port. -.SH "SEE ALSO" -.BR ibv_create_qp (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_bind_mw.3 b/usr/rdma-core/libibverbs/man/ibv_bind_mw.3 deleted file mode 100644 index af309d000..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_bind_mw.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_BIND_MW 3 2016-02-02 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_bind_mw \- post a request to bind a type 1 memory window to a memory region -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_bind_mw(struct ibv_qp " "*qp" ", struct ibv_mw " "*mw" ", -.BI " struct ibv_mw_bind " "*mw_bind" "); -.fi -.SH "DESCRIPTION" -.B ibv_bind_mw() -posts to the queue pair -.I qp -a request to bind the memory window -.I mw -according to the details in -.I mw_bind\fR. -.PP -The argument -.I mw_bind -is an ibv_mw_bind struct, as defined in . -.PP -.nf -struct ibv_mw_bind { -.in +8 -uint64_t wr_id; /* User defined WR ID */ -int send_flags; /* Use ibv_send_flags */ -struct ibv_mw_bind_info bind_info; /* MW bind information */ -.in -8 -} -.fi -.PP -.nf -struct ibv_mw_bind_info { -.in +8 -struct ibv_mr *mr; /* The MR to bind the MW to */ -uint64_t addr; /* The address the MW should start at */ -uint64_t length; /* The length (in bytes) the MW should span */ -int mw_access_flags; /* Access flags to the MW. Use ibv_access_flags */ -.in -8 -}; -.fi -.PP -The QP Transport Service Type must be either UC, RC or XRC_SEND for bind operations. -.PP -The attribute send_flags describes the properties of the \s-1WR\s0. It is either 0 or the bitwise \s-1OR\s0 of one or more of the following flags: -.PP -.TP -.B IBV_SEND_FENCE \fR Set the fence indicator. -.TP -.B IBV_SEND_SIGNALED \fR Set the completion notification indicator. Relevant only if QP was created with sq_sig_all=0 -.PP -The mw_access_flags define the allowed access to the MW after the bind -completes successfully. It is either 0 or the bitwise \s-1OR\s0 of one -or more of the following flags: -.TP -.B IBV_ACCESS_REMOTE_WRITE \fR Enable Remote Write Access. Requires local write access to the MR. -.TP -.B IBV_ACCESS_REMOTE_READ\fR Enable Remote Read Access -.TP -.B IBV_ACCESS_REMOTE_ATOMIC\fR Enable Remote Atomic Operation Access (if supported). Requires local write access to the MR. -.TP -.B IBV_ACCESS_ZERO_BASED\fR If set, the address set on the 'remote_addr' field on the WR will be an offset from the MW's start address. -.SH "RETURN VALUE" -.B ibv_bind_mw() -returns 0 on success, or the value of errno on failure (which -indicates the failure reason). In case of a success, the R_key of the -memory window after the bind is returned in the mw_bind->mw->rkey field. -.SH "NOTES" -The bind does not complete when the function return - it is merely -posted to the QP. The user should keep a copy of the old R_key, and -fix the mw structure if the subsequent CQE for the bind operation -indicates a failure. The user may safely send the R_key using a send -request on the same QP, (based on QP ordering rules: a send after a bind -request on the same QP are always ordered), but must not transfer it to the -remote in any other manner before reading a successful CQE. -.PP -Note that for type 2 MW, one should directly post bind WR to the QP, -using ibv_post_send. -.SH "SEE ALSO" -.BR ibv_alloc_mw (3), -.BR ibv_post_send (3), -.BR ibv_poll_cq (3) -.BR ibv_reg_mr (3), -.SH "AUTHORS" -.TP -Majd Dibbiny -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_create_ah.3 b/usr/rdma-core/libibverbs/man/ibv_create_ah.3 deleted file mode 100644 index 0ca219887..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_ah.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_AH 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_ah, ibv_destroy_ah \- create or destroy an address handle (AH) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_ah *ibv_create_ah(struct ibv_pd " "*pd" ", -.BI " struct ibv_ah_attr " "*attr" "); -.sp -.BI "int ibv_destroy_ah(struct ibv_ah " "*ah" "); -.fi -.SH "DESCRIPTION" -.B ibv_create_ah() -creates an address handle (AH) associated with the protection domain -.I pd\fR. -The argument -.I attr -is an ibv_ah_attr struct, as defined in . -.PP -.nf -struct ibv_ah_attr { -.in +8 -struct ibv_global_route grh; /* Global Routing Header (GRH) attributes */ -uint16_t dlid; /* Destination LID */ -uint8_t sl; /* Service Level */ -uint8_t src_path_bits; /* Source path bits */ -uint8_t static_rate; /* Maximum static rate */ -uint8_t is_global; /* GRH attributes are valid */ -uint8_t port_num; /* Physical port number */ -.in -8 -}; -.sp -.nf -struct ibv_global_route { -.in +8 -union ibv_gid dgid; /* Destination GID or MGID */ -uint32_t flow_label; /* Flow label */ -uint8_t sgid_index; /* Source GID index */ -uint8_t hop_limit; /* Hop limit */ -uint8_t traffic_class; /* Traffic class */ -.in -8 -}; -.fi -.sp -.PP -.B ibv_destroy_ah() -destroys the AH -.I ah\fR. -.SH "RETURN VALUE" -.B ibv_create_ah() -returns a pointer to the created AH, or NULL if the request fails. -.PP -.B ibv_destroy_ah() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_init_ah_from_wc (3), -.BR ibv_create_ah_from_wc (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_create_ah_from_wc.3 b/usr/rdma-core/libibverbs/man/ibv_create_ah_from_wc.3 deleted file mode 100644 index ec7d29f30..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_ah_from_wc.3 +++ /dev/null @@ -1,64 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_AH_FROM_WC 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_init_ah_from_wc, ibv_create_ah_from_wc \- initialize or create an -address handle (AH) from a work completion -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_init_ah_from_wc(struct ibv_context " "*context" ", uint8_t " "port_num" , -.BI " struct ibv_wc " "*wc" ", struct ibv_grh " "*grh" , -.BI " struct ibv_ah_attr " "*ah_attr" ); -.sp -.BI "struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd " "*pd" , -.BI " struct ibv_wc " "*wc" , -.BI " struct ibv_grh " "*grh" , -.BI " uint8_t " "port_num" ); -.fi -.SH "DESCRIPTION" -.B ibv_init_ah_from_wc() -initializes the address handle (AH) attribute structure -.I ah_attr -for the RDMA device context -.I context -using the port number -.I port_num\fR, -using attributes from the work completion -.I wc -and the Global Routing Header (GRH) structure -.I grh\fR. -.PP -.B ibv_create_ah_from_wc() -creates an AH associated with the protection domain -.I pd -using the port number -.I port_num\fR, -using attributes from the work completion -.I wc -and the Global Routing Header (GRH) structure -.I grh\fR. -.SH "RETURN VALUE" -.B ibv_init_ah_from_wc() -returns 0 on success, and \-1 on error. -.PP -.B ibv_create_ah_from_wc() -returns a pointer to the created AH, or NULL if the request fails. -.SH "NOTES" -The filled structure -.I ah_attr -returned from -.B ibv_init_ah_from_wc() -can be used to create a new AH using -.B ibv_create_ah()\fR. -.SH "SEE ALSO" -.BR ibv_open_device (3), -.BR ibv_alloc_pd (3), -.BR ibv_create_ah (3), -.BR ibv_destroy_ah (3), -.BR ibv_poll_cq (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_create_comp_channel.3 b/usr/rdma-core/libibverbs/man/ibv_create_comp_channel.3 deleted file mode 100644 index 746097883..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_comp_channel.3 +++ /dev/null @@ -1,51 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_COMP_CHANNEL 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_comp_channel, ibv_destroy_comp_channel \- create or -destroy a completion event channel -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context -.BI " " "*context" ); -.sp -.BI "int ibv_destroy_comp_channel(struct ibv_comp_channel " "*channel" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_comp_channel() -creates a completion event channel for the RDMA device context -.I context\fR. -.PP -.B ibv_destroy_comp_channel() -destroys the completion event channel -.I channel\fR. -.SH "RETURN VALUE" -.B ibv_create_comp_channel() -returns a pointer to the created completion event channel, or NULL if the request fails. -.PP -.B ibv_destroy_comp_channel() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -A "completion channel" is an abstraction introduced by libibverbs that -does not exist in the InfiniBand Architecture verbs specification or -RDMA Protocol Verbs Specification. A completion channel is -essentially file descriptor that is used to deliver completion -notifications to a userspace process. When a completion event is -generated for a completion queue (CQ), the event is delivered via the -completion channel attached to that CQ. This may be useful to steer -completion events to different threads by using multiple completion -channels. -.PP -.B ibv_destroy_comp_channel() -fails if any CQs are still associated with the completion event -channel being destroyed. -.SH "SEE ALSO" -.BR ibv_open_device (3), -.BR ibv_create_cq (3), -.BR ibv_get_cq_event (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_create_cq.3 b/usr/rdma-core/libibverbs/man/ibv_create_cq.3 deleted file mode 100644 index 98ea4d278..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_cq.3 +++ /dev/null @@ -1,59 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_CQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_cq, ibv_destroy_cq \- create or destroy a completion queue (CQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_cq *ibv_create_cq(struct ibv_context " "*context" ", int " "cqe" , -.BI " void " "*cq_context" , -.BI " struct ibv_comp_channel " "*channel" , -.BI " int " "comp_vector" ); -.sp -.BI "int ibv_destroy_cq(struct ibv_cq " "*cq" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_cq() -creates a completion queue (CQ) with at least -.I cqe -entries for the RDMA device context -.I context\fR. -The pointer -.I cq_context -will be used to set user context pointer of the CQ structure. The argument -.I channel -is optional; if not NULL, the completion channel -.I channel -will be used to return completion events. The CQ will use the -completion vector -.I comp_vector -for signaling completion events; it must be at least zero and less than -.I context\fR->num_comp_vectors. -.PP -.B ibv_destroy_cq() -destroys the CQ -.I cq\fR. -.SH "RETURN VALUE" -.B ibv_create_cq() -returns a pointer to the CQ, or NULL if the request fails. -.PP -.B ibv_destroy_cq() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_create_cq() -may create a CQ with size greater than or equal to the requested -size. Check the cqe attribute in the returned CQ for the actual size. -.PP -.B ibv_destroy_cq() -fails if any queue pair is still associated with this CQ. -.SH "SEE ALSO" -.BR ibv_resize_cq (3), -.BR ibv_req_notify_cq (3), -.BR ibv_ack_cq_events (3), -.BR ibv_create_qp (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_create_cq_ex.3 b/usr/rdma-core/libibverbs/man/ibv_create_cq_ex.3 deleted file mode 100644 index e943e0e26..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_cq_ex.3 +++ /dev/null @@ -1,162 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_CQ_EX 3 2016-05-08 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_cq_ex \- create a completion queue (CQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_cq_ex *ibv_create_cq_ex(struct ibv_context " "*context" ", -.BI " struct ibv_create_cq_attr_ex " "*cq_attr" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_cq_ex() -creates a completion queue (CQ) for RDMA device context -.I context\fR. -The argument -.I cq_attr -is a pointer to struct ibv_cq_init_attr_ex as defined in . -.PP -.nf -struct ibv_cq_init_attr_ex { -.in +8 -int cqe; /* Minimum number of entries required for CQ */ -void *cq_context; /* Consumer-supplied context returned for completion events */ -struct ibv_comp_channel *channel; /* Completion channel where completion events will be queued. May be NULL if completion events will not be used. */ -int comp_vector; /* Completion vector used to signal completion events. Must be >= 0 and < context->num_comp_vectors. */ -uint64_t wc_flags; /* The wc_flags that should be returned in ibv_poll_cq_ex. Or'ed bit of enum ibv_wc_flags_ex. */ -uint32_t comp_mask; /* compatibility mask (extended verb). */ -uint32_t flags /* One or more flags from enum ibv_create_cq_attr_flags */ -.in -8 -}; - -enum ibv_wc_flags_ex { - IBV_WC_EX_WITH_BYTE_LEN = 1 << 0, /* Require byte len in WC */ - IBV_WC_EX_WITH_IMM = 1 << 1, /* Require immediate in WC */ - IBV_WC_EX_WITH_QP_NUM = 1 << 2, /* Require QP number in WC */ - IBV_WC_EX_WITH_SRC_QP = 1 << 3, /* Require source QP in WC */ - IBV_WC_EX_WITH_SLID = 1 << 4, /* Require slid in WC */ - IBV_WC_EX_WITH_SL = 1 << 5, /* Require sl in WC */ - IBV_WC_EX_WITH_DLID_PATH_BITS = 1 << 6, /* Require dlid path bits in WC */ - IBV_WC_EX_WITH_COMPLETION_TIMESTAMP = 1 << 7, /* Require completion timestamp in WC /* - IBV_WC_EX_WITH_CVLAN = 1 << 8, /* Require VLAN info in WC */ - IBV_WC_EX_WITH_FLOW_TAG = 1 << 9, /* Require flow tag in WC */ -}; - -enum ibv_cq_init_attr_mask { - IBV_CQ_INIT_ATTR_MASK_FLAGS = 1 << 0, -}; - -enum ibv_create_cq_attr_flags { - IBV_CREATE_CQ_ATTR_SINGLE_THREADED = 1 << 0, /* This CQ is used from a single threaded, thus no locking is required */ -}; - -.SH "Polling an extended CQ" -In order to poll an extended CQ efficiently, a user could use the following functions. - -.TP -.B Completion iterator functions - -.BI "int ibv_start_poll(struct ibv_cq_ex " "*cq" ", struct ibv_poll_cq_attr " "*attr") -.br -Start polling a batch of work completions. -.I attr -is given in order to make this function -easily extensible in the future. This function either returns 0 on success or an error code -otherwise. When no completions are available on the CQ, ENOENT is returned, but the CQ remains -in a valid state. On success, querying the completion's attribute could be done using the query -functions described below. If an error code is given, end_poll shouldn't be called. - -.BI "int ibv_next_poll(struct ibv_cq_ex " "*cq") -.br -This function is called in order to get the next work completion. It has to be called after -.I start_poll -and before -.I end_poll -are called. This function either returns 0 on success or an error code -otherwise. When no completions are available on the CQ, ENOENT is returned, but the CQ remains -in a valid state. On success, querying the completion's attribute could be done using the query -functions described below. If an error code is given, end_poll should still be called, -indicating this is the end of the polled batch. - -.BI "void ibv_end_poll(struct ibv_cq_ex " "*cq") -.br -This function indicates the end of polling batch of work completions. After calling this function, the user should start a new batch -by calling -.I start_poll. - -.TP -.B Polling fields in the completion -Below members and functions are used in order to poll the current completion. The current completion is the completion which the iterator points to (start_poll and next_poll advances this iterator). Only fields that the user requested via wc_flags in ibv_create_cq_ex could be queried. In addition, some fields are only valid in certain opcodes and status codes. - -.BI "uint64_t wr_id - Can be accessed directly from struct ibv_cq_ex". - -.BI "enum ibv_wc_status - Can be accessed directly from struct ibv_cq_ex". - -.BI "enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex " "*cq"); \c - Get the opcode from the current completion. - -.BI "uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex " "*cq"); \c - Get the vendor error from the current completion. - -.BI "uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex " "*cq"); \c - Get the vendor error from the current completion. - -.BI "__be32 ibv_wc_read_imm_data(struct ibv_cq_ex " "*cq"); \c - Get the immediate data field from the current completion. - -.BI "uint32_t ibv_wc_read_invalidated_rkey(struct ibv_cq_ex " "*cq"); \c - Get the rkey invalided by the SEND_INVAL from the current completion. - -.BI "uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex " "*cq"); \c - Get the QP number field from the current completion. - -.BI "uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex " "*cq"); \c - Get the source QP number field from the current completion. - -.BI "int ibv_wc_read_wc_flags(struct ibv_cq_ex " "*cq"); \c - Get the QP flags field from the current completion. - -.BI "uint16_t ibv_wc_read_pkey_index(struct ibv_cq_ex " "*cq"); \c - Get the pkey index field from the current completion. - -.BI "uint32_t ibv_wc_read_slid(struct ibv_cq_ex " "*cq"); \c - Get the slid field from the current completion. - -.BI "uint8_t ibv_wc_read_sl(struct ibv_cq_ex " "*cq"); \c - Get the sl field from the current completion. - -.BI "uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex " "*cq"); \c - Get the dlid_path_bits field from the current completion. - -.BI "uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex " "*cq"); \c - Get the completion timestamp from the current completion. - -.BI "uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex " "*cq"); \c - Get the CVLAN field from the current completion. - -.BI "uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex " "*cq"); \c - Get flow tag from the current completion. - -.SH "RETURN VALUE" -.B ibv_create_cq_ex() -returns a pointer to the CQ, or NULL if the request fails. -.SH "NOTES" -.B ibv_create_cq_ex() -may create a CQ with size greater than or equal to the requested -size. Check the cqe attribute in the returned CQ for the actual size. -.PP -CQ should be destroyed with ibv_destroy_cq. -.PP -.SH "SEE ALSO" -.BR ibv_create_cq (3), -.BR ibv_destroy_cq (3), -.BR ibv_resize_cq (3), -.BR ibv_req_notify_cq (3), -.BR ibv_ack_cq_events (3), -.BR ibv_create_qp (3) -.SH "AUTHORS" -.TP -Matan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_create_flow.3 b/usr/rdma-core/libibverbs/man/ibv_create_flow.3 deleted file mode 100644 index 48bbb14c9..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_flow.3 +++ /dev/null @@ -1,216 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_CREATE_FLOW 3 2016-03-15 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_flow, ibv_destroy_flow \- create or destroy flow steering rules -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_flow *ibv_create_flow(struct ibv_qp " "*qp" , -.BI " struct ibv_flow_attr " "*flow_attr"); -.BI "int ibv_destroy_flow(struct ibv_flow " "*flow_id"); -.sp -.fi -.SH "DESCRIPTION" -.SS ibv_create_flow() -allows a user application QP -.I qp -to be attached into a specified flow -.I flow -which is defined in -.I -.PP -.nf -struct ibv_flow_attr { -.in +8 -uint32_t comp_mask; /* Future extendibility */ -enum ibv_flow_attr_type type; /* Rule type - see below */ -uint16_t size; /* Size of command */ -uint16_t priority; /* Rule priority - see below */ -uint8_t num_of_specs; /* Number of ibv_flow_spec_xxx */ -uint8_t port; /* The uplink port number */ -uint32_t flags; /* Extra flags for rule - see below */ -/* Following are the optional layers according to user request - * struct ibv_flow_spec_xxx - * struct ibv_flow_spec_yyy - */ -.in -8 -}; -.sp -.nf -enum ibv_flow_attr_type { -.in +8 -IBV_FLOW_ATTR_NORMAL = 0x0, /* Steering according to rule specifications */ -IBV_FLOW_ATTR_ALL_DEFAULT = 0x1, /* Default unicast and multicast rule - receive all Eth traffic which isn't steered to any QP */ -IBV_FLOW_ATTR_MC_DEFAULT = 0x2, /* Default multicast rule - receive all Eth multicast traffic which isn't steered to any QP */ -IBV_FLOW_ATTR_SNIFFER = 0x3, /* Sniffer rule - receive all port traffic */ -.in -8 -}; -.sp -.nf -enum ibv_flow_flags { -.in +8 -IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK = 1 << 0, /* Apply the rules on packets that were sent from the attached QP through loopback */ -IBV_FLOW_ATTR_FLAGS_DONT_TRAP = 1 << 1, /* Rule doesn't trap received packets, allowing them to match lower prioritized rules */ -.in -8 -}; -.fi -.nf -.br - -enum ibv_flow_spec_type { -.in +8 -IBV_FLOW_SPEC_ETH = 0x20, /* Flow specification of L2 header */ -IBV_FLOW_SPEC_IPV4 = 0x30, /* Flow specification of IPv4 header */ -IBV_FLOW_SPEC_IPV6 = 0x31, /* Flow specification of IPv6 header */ -IBV_FLOW_SPEC_IPV4_EXT = 0x32, /* Extended flow specification of IPv4 */ -IBV_FLOW_SPEC_TCP = 0x40, /* Flow specification of TCP header */ -IBV_FLOW_SPEC_UDP = 0x41, /* Flow specification of UDP header */ -IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, /* Flow specification of VXLAN header */ -IBV_FLOW_SPEC_INNER = 0x100, /* Flag making L2/L3/L4 specifications to be applied on the inner header */ -IBV_FLOW_SPEC_ACTION_TAG = 0x1000, /* Action tagging matched packet */ -IBV_FLOW_SPEC_ACTION_DROP = 0x1001, /* Action dropping matched packet */ -.in -8 -}; -.br - -Flow specification general structure: -.BR -struct ibv_flow_spec_xxx { -.in +8 -enum ibv_flow_spec_type type; -uint16_t size; /* Flow specification size = sizeof(struct ibv_flow_spec_xxx) */ -struct ibv_flow_xxx_filter val; -struct ibv_flow_xxx_filter mask; /* Defines which bits from the filter value are applicable when looking for a match in the incoming packet */ -.in -8 -}; -.PP -Each spec struct holds the relevant network layer parameters for matching. To enforce the match, the user sets a mask for each parameter. -.br -If the bit is set in the mask, the corresponding bit in the value should be matched. -.br -Note that most vendors support either full mask (all "1"s) or zero mask (all "0"s). -.br -.B Network parameters in the relevant network structs should be given in network order (big endian). - -.SS Flow domains and priority -Flow steering defines the concept of domain and priority. Each domain represents an application that can attach a flow. -Domains are prioritized. A higher priority domain will always supersede a lower priority domain when their flow specifications overlap. -.br -.B IB verbs have the higher priority domain. -.br -In addition to the domain, there is priority within each of the domains. -A lower priority numeric value (higher priority) takes precedence over matching rules with higher numeric priority value (lower priority). -It is important to note that the priority value of a flow spec is used not only to establish the precedence of conflicting flow matches -but also as a way to abstract the order on which flow specs are tested for matches. Flows with higher priorities will be tested before flows with lower priorities. -.PP -.SS ibv_destroy_flow() -destroys the flow -.I flow_id\fR. -.SH "RETURN VALUE" -.B ibv_create_flow() -returns a pointer to the flow, or NULL if the request fails. In case of an error, errno is updated. -.PP -.B ibv_destroy_flow() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "ERRORS" -.SS EINVAL -.B ibv_create_flow() -flow specification, QP or priority are invalid -.PP -.B ibv_destroy_flow() -flow_id is invalid -.SS ENOMEM -Couldn't create/destroy flow, not enough memory -.SS ENXIO -Device managed flow steering isn't currently supported -.SS EPERM -No permissions to add the flow steering rule -.SH "NOTES" -1. These verbs are available only for devices supporting -.br - IBV_DEVICE_MANAGED_FLOW_STEERING and only for QPs of Transport Service Type -.BR IBV_QPT_UD -or -.BR IBV_QPT_RAW_PACKET -.br -2. User must memset the spec struct with zeros before using it. -.br -3. ether_type field in ibv_flow_eth_filter is the ethertype following the last VLAN tag of the packet. -.br -4. Only rule type IBV_FLOW_ATTR_NORMAL supports IBV_FLOW_ATTR_FLAGS_DONT_TRAP flag. -.br -5. No specifications are needed for IBV_FLOW_ATTR_SNIFFER rule type. -.br -.PP -.SH EXAMPLE -.br -Below flow_attr defines a rule in priority 0 to match a destination -mac address and a source ipv4 address. For that, L2 and L3 specs are used. -.br -If there is a hit on this rule, means the -received packet has destination mac: 66:11:22:33:44:55 and source ip: 0x0B86C806, -the packet is steered to its attached qp. -.sp -.nf -struct raw_eth_flow_attr { -.in +8 -struct ibv_flow_attr attr; -struct ibv_flow_spec_eth spec_eth; -struct ibv_flow_spec_ipv4 spec_ipv4; -.in -8 -} __attribute__((packed)); -.sp -.nf -struct raw_eth_flow_attr flow_attr = { -.in +8 - .attr = { - .comp_mask = 0, - .type = IBV_FLOW_ATTR_NORMAL, - .size = sizeof(flow_attr), - .priority = 0, - .num_of_specs = 2, - .port = 1, - .flags = 0, - }, - .spec_eth = { - .type = IBV_FLOW_SPEC_ETH, - .size = sizeof(struct ibv_flow_spec_eth), - .val = { - .dst_mac = {0x66, 0x11, 0x22, 0x33, 0x44, 0x55}, - .src_mac = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - .ether_type = 0, - .vlan_tag = 0, - }, - .mask = { - .dst_mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - .src_mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - .ether_type = 0, - .vlan_tag = 0, - } - }, - .spec_ipv4 = { - .type = IBV_FLOW_SPEC_IPV4, - .size = sizeof(struct ibv_flow_spec_ipv4), - .val = { - .src_ip = 0x0B86C806, - .dst_ip = 0, - }, - .mask = { - .src_ip = 0xFFFFFFFF, - .dst_ip = 0, - } - } -.in -8 -}; -.sp -.nf -.SH "AUTHORS" -.TP -Hadar Hen Zion -.TP -Matan Barak -.TP -Yishai Hadas -.TP -Maor Gottlieb diff --git a/usr/rdma-core/libibverbs/man/ibv_create_qp.3 b/usr/rdma-core/libibverbs/man/ibv_create_qp.3 deleted file mode 100644 index 78d7f43c1..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_qp.3 +++ /dev/null @@ -1,86 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_QP 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_qp, ibv_destroy_qp \- create or destroy a queue pair (QP) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_qp *ibv_create_qp(struct ibv_pd " "*pd" , -.BI " struct ibv_qp_init_attr " "*qp_init_attr" ); -.sp -.BI "int ibv_destroy_qp(struct ibv_qp " "*qp" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_qp() -creates a queue pair (QP) associated with the protection domain -.I pd\fR. -The argument -.I qp_init_attr -is an ibv_qp_init_attr struct, as defined in . -.PP -.nf -struct ibv_qp_init_attr { -.in +8 -void *qp_context; /* Associated context of the QP */ -struct ibv_cq *send_cq; /* CQ to be associated with the Send Queue (SQ) */ -struct ibv_cq *recv_cq; /* CQ to be associated with the Receive Queue (RQ) */ -struct ibv_srq *srq; /* SRQ handle if QP is to be associated with an SRQ, otherwise NULL */ -struct ibv_qp_cap cap; /* QP capabilities */ -enum ibv_qp_type qp_type; /* QP Transport Service Type: IBV_QPT_RC, IBV_QPT_UC, IBV_QPT_UD or IBV_QPT_RAW_PACKET */ -int sq_sig_all; /* If set, each Work Request (WR) submitted to the SQ generates a completion entry */ -.in -8 -}; -.sp -.nf -struct ibv_qp_cap { -.in +8 -uint32_t max_send_wr; /* Requested max number of outstanding WRs in the SQ */ -uint32_t max_recv_wr; /* Requested max number of outstanding WRs in the RQ */ -uint32_t max_send_sge; /* Requested max number of scatter/gather (s/g) elements in a WR in the SQ */ -uint32_t max_recv_sge; /* Requested max number of s/g elements in a WR in the SQ */ -uint32_t max_inline_data;/* Requested max number of data (bytes) that can be posted inline to the SQ, otherwise 0 */ -.in -8 -}; -.fi -.PP -The function -.B ibv_create_qp() -will update the -.I qp_init_attr\fB\fR->cap -struct with the actual \s-1QP\s0 values of the QP that was created; -the values will be greater than or equal to the values requested. -.PP -.B ibv_destroy_qp() -destroys the QP -.I qp\fR. -.SH "RETURN VALUE" -.B ibv_create_qp() -returns a pointer to the created QP, or NULL if the request fails. -Check the QP number (\fBqp_num\fR) in the returned QP. -.PP -.B ibv_destroy_qp() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_create_qp() -will fail if a it is asked to create QP of a type other than -.B IBV_QPT_RC -or -.B IBV_QPT_UD -associated with an SRQ. -.PP -The attributes max_recv_wr and max_recv_sge are ignored by -.B ibv_create_qp() -if the QP is to be associated with an SRQ. -.PP -.B ibv_destroy_qp() -fails if the QP is attached to a multicast group. -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_modify_qp (3), -.BR ibv_query_qp (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_create_qp_ex.3 b/usr/rdma-core/libibverbs/man/ibv_create_qp_ex.3 deleted file mode 100644 index fac0e0305..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_qp_ex.3 +++ /dev/null @@ -1,109 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_QP_EX 3 2013-06-26 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_qp_ex, ibv_destroy_qp \- create or destroy a queue pair (QP) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_qp *ibv_create_qp_ex(struct ibv_context " "*context" , -.BI " struct ibv_qp_init_attr_ex " "*qp_init_attr" ); -.sp -.BI "int ibv_destroy_qp(struct ibv_qp " "*qp" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_qp_ex() -creates a queue pair (QP) associated with the protection domain -.I pd\fR. -The argument -.I qp_init_attr_ex -is an ibv_qp_init_attr_ex struct, as defined in . -.PP -.nf -struct ibv_qp_init_attr_ex { -.in +8 -void *qp_context; /* Associated context of the QP */ -struct ibv_cq *send_cq; /* CQ to be associated with the Send Queue (SQ) */ -struct ibv_cq *recv_cq; /* CQ to be associated with the Receive Queue (RQ) */ -struct ibv_srq *srq; /* SRQ handle if QP is to be associated with an SRQ, otherwise NULL */ -struct ibv_qp_cap cap; /* QP capabilities */ -enum ibv_qp_type qp_type; /* QP Transport Service Type: IBV_QPT_RC, IBV_QPT_UC, IBV_QPT_UD or IBV_QPT_RAW_PACKET */ -int sq_sig_all; /* If set, each Work Request (WR) submitted to the SQ generates a completion entry */ -uint32_t comp_mask; /* Identifies valid fields */ -struct ibv_pd *pd; /* PD to be associated with the QP */ -struct ibv_xrcd *xrcd; /* XRC domain to be associated with the target QP */ -enum ibv_qp_create_flags create_flags; /* Creation flags for this QP */ -uint16_t max_tso_header; /* Maximum TSO header size */ -struct ibv_rwq_ind_table *rwq_ind_tbl; /* Indirection table to be associated with the QP */ -struct ibv_rx_hash_conf rx_hash_conf; /* RX hash configuration to be used */ -uint32_t source_qpn; /* Source QP number, creation flag IBV_QP_CREATE_SOURCE_QPN should be set, few NOTEs below */ -.in -8 -}; -.sp -.nf -struct ibv_qp_cap { -.in +8 -uint32_t max_send_wr; /* Requested max number of outstanding WRs in the SQ */ -uint32_t max_recv_wr; /* Requested max number of outstanding WRs in the RQ */ -uint32_t max_send_sge; /* Requested max number of scatter/gather (s/g) elements in a WR in the SQ */ -uint32_t max_recv_sge; /* Requested max number of s/g elements in a WR in the SQ */ -uint32_t max_inline_data;/* Requested max number of data (bytes) that can be posted inline to the SQ, otherwise 0 */ -.in -8 -}; -.nf -enum ibv_qp_create_flags { -.in +8 -IBV_QP_CREATE_BLOCK_SELF_MCAST_LB = 1 << 1, /* Prevent self multicast loopback */ -IBV_QP_CREATE_SCATTER_FCS = 1 << 8, /* FCS field will be scattered to host memory */ -IBV_QP_CREATE_CVLAN_STRIPPING = 1 << 9, /* CVLAN field will be stripped from incoming packets */ -IBV_QP_CREATE_SOURCE_QPN = 1 << 10, /* The created QP will use the source_qpn as its wire QP number */ -.in -8 -}; -.nf -struct ibv_rx_hash_conf { -.in +8 -uint8_t rx_hash_function; /* RX hash function, use enum ibv_rx_hash_function_flags */ -uint8_t rx_hash_key_len; /* RX hash key length */ -uint8_t *rx_hash_key; /* RX hash key data */ -uint64_t rx_hash_fields_mask; /* RX fields that should participate in the hashing, use enum ibv_rx_hash_fields */ -.in -8 -}; -.fi -.PP -The function -.B ibv_create_qp_ex() -will update the -.I qp_init_attr_ex\fB\fR->cap -struct with the actual \s-1QP\s0 values of the QP that was created; -the values will be greater than or equal to the values requested. -.PP -.B ibv_destroy_qp() -destroys the QP -.I qp\fR. -.SH "RETURN VALUE" -.B ibv_create_qp_ex() -returns a pointer to the created QP, or NULL if the request fails. -Check the QP number (\fBqp_num\fR) in the returned QP. -.PP -.B ibv_destroy_qp() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.PP -The attributes max_recv_wr and max_recv_sge are ignored by -.B ibv_create_qp_ex() -if the QP is to be associated with an SRQ. -.PP -The attribute source_qpn is supported only on UD QP, without flow steering RX should not be possible. -.PP -.B ibv_destroy_qp() -fails if the QP is attached to a multicast group. -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_modify_qp (3), -.BR ibv_query_qp (3), -.BR ibv_create_rwq_ind_table (3) -.SH "AUTHORS" -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_create_rwq_ind_table.3 b/usr/rdma-core/libibverbs/man/ibv_create_rwq_ind_table.3 deleted file mode 100644 index 176a5f149..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_rwq_ind_table.3 +++ /dev/null @@ -1,59 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH CREATE_RWQ_IND_TBL 3 2016-07-27 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_rwq_ind_table, ibv_destroy_rwq_ind_table \- create or destroy a Receive Work Queue Indirection Table (RWQ IND TBL). -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_rwq_ind_table *ibv_create_rwq_ind_table(struct ibv_context " "*context," -.BI " struct ibv_rwq_ind_table_init_attr " "*init_attr" ); -.sp -.BI "int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table " "*rwq_ind_table" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_rwq_ind_table() -creates a RWQ IND TBL associated with the ibv_context -.I context\fR. -The argument -.I init_attr -is an ibv_rwq_ind_table_init_attr struct, as defined in . -.PP -.nf -struct ibv_rwq_ind_table_init_attr { -.in +8 -uint32_t log_ind_tbl_size; /* Log, base 2, of Indirection table size */ -struct ibv_wq **ind_tbl; /* Each entry is a pointer to Receive Work Queue */ -uint32_t comp_mask; /* Identifies valid fields. Use ibv_ind_table_init_attr_mask */ -.in -8 -}; -.fi -.PP -The function -.B ibv_create_rwq_ind_table() -will create a RWQ IND TBL that holds a table of Receive Work Queue. -For further usage of the created object see below -.I NOTES\fR. -.PP -.B ibv_destroy_rwq_ind_table() -destroys the RWQ IND TBL -.I rwq_ind_table\fR. -.SH "RETURN VALUE" -.B ibv_create_rwq_ind_table() -returns a pointer to the created RWQ IND TBL, or NULL if the request fails. -.PP -.B ibv_destroy_rwq_ind_table() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -The created object should be used as part of -.I ibv_create_qp_ex() -to enable dispatching of incoming packets based on some RX hash configuration. -.SH "SEE ALSO" -.BR ibv_create_wq (3), -.BR ibv_modify_wq (3), -.BR ibv_create_qp_ex (3), -.SH "AUTHORS" -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_create_srq.3 b/usr/rdma-core/libibverbs/man/ibv_create_srq.3 deleted file mode 100644 index 46ab8dd5b..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_srq.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_SRQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_srq, ibv_destroy_srq \- create or destroy a shared receive queue (SRQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_srq *ibv_create_srq(struct ibv_pd " "*pd" ", struct " -.BI " ibv_srq_init_attr " "*srq_init_attr" ); -.sp -.BI "int ibv_destroy_srq(struct ibv_srq " "*srq" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_srq() -creates a shared receive queue (SRQ) associated with the protection domain -.I pd\fR. -The argument -.I srq_init_attr -is an ibv_srq_init_attr struct, as defined in . -.PP -.nf -struct ibv_srq_init_attr { -.in +8 -void *srq_context; /* Associated context of the SRQ */ -struct ibv_srq_attr attr; /* SRQ attributes */ -.in -8 -}; -.sp -.nf -struct ibv_srq_attr { -.in +8 -uint32_t max_wr; /* Requested max number of outstanding work requests (WRs) in the SRQ */ -uint32_t max_sge; /* Requested max number of scatter elements per WR */ -uint32_t srq_limit; /* The limit value of the SRQ (irrelevant for ibv_create_srq) */ -.in -8 -}; -.fi -.PP -The function -.B ibv_create_srq() -will update the -.I srq_init_attr -struct with the original values of the SRQ that was created; the -values of max_wr and max_sge will be greater than or equal to the -values requested. -.PP -.B ibv_destroy_srq() -destroys the SRQ -.I srq\fR. -.SH "RETURN VALUE" -.B ibv_create_srq() -returns a pointer to the created SRQ, or NULL if the request fails. -.PP -.B ibv_destroy_srq() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_destroy_srq() -fails if any queue pair is still associated with this SRQ. -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_modify_srq (3), -.BR ibv_query_srq (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_create_srq_ex.3 b/usr/rdma-core/libibverbs/man/ibv_create_srq_ex.3 deleted file mode 100644 index c0319067b..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_srq_ex.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_SRQ_EX 3 2013-06-26 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_srq_ex, ibv_destroy_srq \- create or destroy a shared receive queue (SRQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_srq *ibv_create_srq_ex(struct ibv_context " "*context" ", struct " -.BI " ibv_srq_init_attr_ex " "*srq_init_attr_ex" ); -.sp -.BI "int ibv_destroy_srq(struct ibv_srq " "*srq" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_srq_ex() -creates a shared receive queue (SRQ) supporting both basic and xrc modes. -The argument -.I srq_init_attr_ex -is an ibv_srq_init_attr_ex struct, as defined in . -.PP -.nf -struct ibv_srq_init_attr_ex { -.in +8 -void *srq_context; /* Associated context of the SRQ */ -struct ibv_srq_attr attr; /* SRQ attributes */ -uint32_t comp_mask; /* Identifies valid fields */ -enum ibv_srq_type srq_type; /* Basic / XRC */ -struct ibv_pd *pd; /* PD associated with the SRQ */ -struct ibv_xrcd *xrcd; /* XRC domain to associate with the SRQ */ -struct ibv_cq *cq; /* CQ to associate with the SRQ for XRC mode */ -.in -8 -}; -.sp -.nf -struct ibv_srq_attr { -.in +8 -uint32_t max_wr; /* Requested max number of outstanding work requests (WRs) in the SRQ */ -uint32_t max_sge; /* Requested max number of scatter elements per WR */ -uint32_t srq_limit; /* The limit value of the SRQ */ -.in -8 -}; -.fi -.PP -The function -.B ibv_create_srq_ex() -will update the -.I srq_init_attr_ex -struct with the original values of the SRQ that was created; the -values of max_wr and max_sge will be greater than or equal to the -values requested. -.PP -.B ibv_destroy_srq() -destroys the SRQ -.I srq\fR. -.SH "RETURN VALUE" -.B ibv_create_srq_ex() -returns a pointer to the created SRQ, or NULL if the request fails. -.PP -.B ibv_destroy_srq() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_destroy_srq() -fails if any queue pair is still associated with this SRQ. -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_modify_srq (3), -.BR ibv_query_srq (3) -.SH "AUTHORS" -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_create_wq.3 b/usr/rdma-core/libibverbs/man/ibv_create_wq.3 deleted file mode 100644 index a540130c2..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_create_wq.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_CREATE_WQ 3 2016-07-27 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_create_wq, ibv_destroy_wq \- create or destroy a Work Queue (WQ). -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_wq *ibv_create_wq(struct ibv_context " "*context," -.BI " struct ibv_wq_init_attr " "*wq_init_attr" ); -.sp -.BI "int ibv_destroy_wq(struct ibv_wq " "*wq" ); -.fi -.SH "DESCRIPTION" -.B ibv_create_wq() -creates a WQ associated with the ibv_context -.I context\fR. -The argument -.I wq_init_attr -is an ibv_wq_init_attr struct, as defined in . -.PP -.nf -struct ibv_wq_init_attr { -.in +8 -void *wq_context; /* Associated context of the WQ */ -enum ibv_wq_type wq_type; /* WQ type */ -uint32_t max_wr; /* Requested max number of outstanding WRs in the WQ */ -uint32_t max_sge; /* Requested max number of scatter/gather (s/g) elements per WR in the WQ */ -struct ibv_pd *pd; /* PD to be associated with the WQ */ -struct ibv_cq *cq; /* CQ to be associated with the WQ */ -uint32_t comp_mask; /* Identifies valid fields. Use ibv_wq_init_attr_mask */ -uint32_t create_flags /* Creation flags for this WQ, use enum ibv_wq_flags */ -.in -8 -}; - -.sp -.nf -enum ibv_wq_flags { -.in +8 -IBV_WQ_FLAGS_CVLAN_STRIPPING = 1 << 0, /* CVLAN field will be stripped from incoming packets */ -IBV_WQ_FLAGS_SCATTER_FCS = 1 << 1, /* FCS field will be scattered to host memory */ -IBV_WQ_FLAGS_DELAY_DROP = 1 << 2, /* Packets won't be dropped immediately if no receive WQEs */ -IBV_WQ_FLAGS_RESERVED = 1 << 3, -.in -8 -}; -.nf -.fi -.PP -The function -.B ibv_create_wq() -will update the -.I wq_init_attr\fB\fR->max_wr -and -.I wq_init_attr\fB\fR->max_sge -fields with the actual \s-1WQ\s0 values of the WQ that was created; -the values will be greater than or equal to the values requested. -.PP -.B ibv_destroy_wq() -destroys the WQ -.I wq\fR. -.SH "RETURN VALUE" -.B ibv_create_wq() -returns a pointer to the created WQ, or NULL if the request fails. -.PP -.B ibv_destroy_wq() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "SEE ALSO" -.BR ibv_modify_wq (3), -.SH "AUTHORS" -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_devices.1 b/usr/rdma-core/libibverbs/man/ibv_devices.1 deleted file mode 100644 index ffd57f8e6..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_devices.1 +++ /dev/null @@ -1,20 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_DEVICES 1 "August 30, 2005" "libibverbs" "USER COMMANDS" - -.SH NAME -ibv_devices \- list RDMA devices - -.SH SYNOPSIS -.B ibv_devices - -.SH DESCRIPTION -.PP -List RDMA devices available for use from userspace. - -.SH SEE ALSO -.BR ibv_devinfo (1) - -.SH AUTHORS -.TP -Roland Dreier -.RI < rolandd@cisco.com > diff --git a/usr/rdma-core/libibverbs/man/ibv_devinfo.1 b/usr/rdma-core/libibverbs/man/ibv_devinfo.1 deleted file mode 100644 index b5e9a58a8..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_devinfo.1 +++ /dev/null @@ -1,40 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_DEVINFO 1 "August 30, 2005" "libibverbs" "USER COMMANDS" - -.SH NAME -ibv_devinfo \- query RDMA devices - -.SH SYNOPSIS -.B ibv_devinfo -[\-d device] [\-i port] [\-l] [\-v] - -.SH DESCRIPTION -.PP -Print information about RDMA devices available for use from userspace. - -.SH OPTIONS - -.PP -.TP -\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR -use IB device \fIDEVICE\fR (default first device found) - -\fB\-i\fR, \fB\-\-ib\-port\fR=\fIPORT\fR -query port \fIPORT\fR (default all ports) - -\fB\-l\fR, \fB\-\-list\fR -only list names of RDMA devices - -\fB\-v\fR, \fB\-\-verbose\fR -print all available information about RDMA devices - -.SH SEE ALSO -.BR ibv_devices (1) - -.SH AUTHORS -.TP -Dotan Barak -.RI < dotanba@gmail.com > -.TP -Roland Dreier -.RI < rolandd@cisco.com > diff --git a/usr/rdma-core/libibverbs/man/ibv_event_type_str.3 b/usr/rdma-core/libibverbs/man/ibv_event_type_str.3 deleted file mode 100644 index 2ae8b1c7e..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_event_type_str.3 +++ /dev/null @@ -1,41 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_EVENT_TYPE_STR 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -.nf -ibv_event_type_str \- Return string describing event_type enum value -.sp -ibv_node_type_str \- Return string describing node_type enum value -.sp -ibv_port_state_str \- Return string describing port_state enum value -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "const char *ibv_event_type_str(enum ibv_event_type " "event_type"); -.sp -.BI "const char *ibv_node_type_str(enum ibv_node_type " "node_type"); -.sp -.BI "const char *ibv_port_state_str(enum ibv_port_state " "port_state"); -.fi -.SH "DESCRIPTION" -.B ibv_node_type_str() -returns a string describing the node type enum value -.IR node_type . -.PP -.B ibv_port_state_str() -returns a string describing the port state enum value -.IR port_state . -.PP -.B ibv_event_type_str() -returns a string describing the event type enum value -.IR event_type . -.SH "RETURN VALUE" -These functions return a constant string that describes the enum value -passed as their argument. -.SH "AUTHOR" -.TP -Roland Dreier -.RI < rolandd@cisco.com > - diff --git a/usr/rdma-core/libibverbs/man/ibv_fork_init.3 b/usr/rdma-core/libibverbs/man/ibv_fork_init.3 deleted file mode 100644 index 012ea20a4..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_fork_init.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_FORK_INIT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_fork_init \- initialize libibverbs to support fork() -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_fork_init(void); -.fi -.SH "DESCRIPTION" -.B ibv_fork_init() -initializes libibverbs's data structures to handle -.B fork() -function calls correctly and avoid data corruption, whether -.B fork() -is called explicitly or implicitly (such as in -.B system()\fR). -.PP -It is not necessary to use this function if all parent process threads -are always blocked until all child processes end or change address -spaces via an -.B exec() -operation. -.SH "RETURN VALUE" -.B ibv_fork_init() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_fork_init() -works on Linux kernels supporting the -.BR MADV_DONTFORK -flag for -.B madvise() -(2.6.17 and higher). -.PP -Setting the environment variable -.BR RDMAV_FORK_SAFE -or -.BR IBV_FORK_SAFE -has the same effect as calling -.B ibv_fork_init()\fR. -.PP -Setting the environment variable -.BR RDMAV_HUGEPAGES_SAFE -tells the library to check the underlying page size used by the kernel -for memory regions. This is required if an application uses huge -pages either directly or indirectly via a library such as libhugetlbfs. -.PP -Calling -.B ibv_fork_init() -will reduce performance due to an extra system call for every memory -registration, and the additional memory allocated to track memory -regions. The precise performance impact depends on the workload and -usually will not be significant. -.PP -Setting -.BR RDMAV_HUGEPAGES_SAFE -adds further overhead to all memory registrations. -.SH "SEE ALSO" -.BR fork (2), -.BR wait (2), -.BR system (3), -.BR exec (3), -.BR ibv_get_device_list (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_get_async_event.3 b/usr/rdma-core/libibverbs/man/ibv_get_async_event.3 deleted file mode 100644 index 85ce6e16c..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_get_async_event.3 +++ /dev/null @@ -1,165 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_GET_ASYNC_EVENT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_get_async_event, ibv_ack_async_event \- get or acknowledge asynchronous events -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_get_async_event(struct ibv_context " "*context" , -.BI " struct ibv_async_event " "*event" ); -.sp -.BI "void ibv_ack_async_event(struct ibv_async_event " "*event" ); -.fi -.SH "DESCRIPTION" -.B ibv_get_async_event() -waits for the next async event of the RDMA device context -.I context -and returns it through the pointer -.I event\fR, -which is an ibv_async_event struct, as defined in . -.PP -.nf -struct ibv_async_event { -.in +8 -union { -.in +8 -struct ibv_cq *cq; /* CQ that got the event */ -struct ibv_qp *qp; /* QP that got the event */ -struct ibv_srq *srq; /* SRQ that got the event */ -int port_num; /* port number that got the event */ -.in -8 -} element; -enum ibv_event_type event_type; /* type of the event */ -.in -8 -}; -.fi -.PP -One member of the element union will be valid, depending on the -event_type member of the structure. event_type will be one of the -following events: -.PP -.I QP events: -.TP -.B IBV_EVENT_QP_FATAL \fR Error occurred on a QP and it transitioned to error state -.TP -.B IBV_EVENT_QP_REQ_ERR \fR Invalid Request Local Work Queue Error -.TP -.B IBV_EVENT_QP_ACCESS_ERR \fR Local access violation error -.TP -.B IBV_EVENT_COMM_EST \fR Communication was established on a QP -.TP -.B IBV_EVENT_SQ_DRAINED \fR Send Queue was drained of outstanding messages in progress -.TP -.B IBV_EVENT_PATH_MIG \fR A connection has migrated to the alternate path -.TP -.B IBV_EVENT_PATH_MIG_ERR \fR A connection failed to migrate to the alternate path -.TP -.B IBV_EVENT_QP_LAST_WQE_REACHED \fR Last WQE Reached on a QP associated with an SRQ -.PP -.I CQ events: -.TP -.B IBV_EVENT_CQ_ERR \fR CQ is in error (CQ overrun) -.PP -.I SRQ events: -.TP -.B IBV_EVENT_SRQ_ERR \fR Error occurred on an SRQ -.TP -.B IBV_EVENT_SRQ_LIMIT_REACHED \fR SRQ limit was reached -.PP -.I Port events: -.TP -.B IBV_EVENT_PORT_ACTIVE \fR Link became active on a port -.TP -.B IBV_EVENT_PORT_ERR \fR Link became unavailable on a port -.TP -.B IBV_EVENT_LID_CHANGE \fR LID was changed on a port -.TP -.B IBV_EVENT_PKEY_CHANGE \fR P_Key table was changed on a port -.TP -.B IBV_EVENT_SM_CHANGE \fR SM was changed on a port -.TP -.B IBV_EVENT_CLIENT_REREGISTER \fR SM sent a CLIENT_REREGISTER request to a port -.TP -.B IBV_EVENT_GID_CHANGE \fR GID table was changed on a port -.PP -.I CA events: -.TP -.B IBV_EVENT_DEVICE_FATAL \fR CA is in FATAL state -.PP -.B ibv_ack_async_event() -acknowledge the async event -.I event\fR. -.SH "RETURN VALUE" -.B ibv_get_async_event() -returns 0 on success, and \-1 on error. -.PP -.B ibv_ack_async_event() -returns no value. -.SH "NOTES" -All async events that -.B ibv_get_async_event() -returns must be acknowledged using -.B ibv_ack_async_event()\fR. -To avoid races, destroying an object (CQ, SRQ or QP) will wait for all -affiliated events for the object to be acknowledged; this avoids an -application retrieving an affiliated event after the corresponding -object has already been destroyed. -.PP -.B ibv_get_async_event() -is a blocking function. If multiple threads call this function -simultaneously, then when an async event occurs, only one thread will -receive it, and it is not possible to predict which thread will -receive it. -.SH "EXAMPLES" -The following code example demonstrates one possible way to work with async events in non-blocking mode. -It performs the following steps: -.PP -1. Set the async events queue work mode to be non-blocked -.br -2. Poll the queue until it has an async event -.br -3. Get the async event and ack it -.PP -.nf -/* change the blocking mode of the async event queue */ -flags = fcntl(ctx->async_fd, F_GETFL); -rc = fcntl(ctx->async_fd, F_SETFL, flags | O_NONBLOCK); -if (rc < 0) { - fprintf(stderr, "Failed to change file descriptor of async event queue\en"); - return 1; -} - -/* - * poll the queue until it has an event and sleep ms_timeout - * milliseconds between any iteration - */ -my_pollfd.fd = ctx->async_fd; -my_pollfd.events = POLLIN; -my_pollfd.revents = 0; - -do { - rc = poll(&my_pollfd, 1, ms_timeout); -} while (rc == 0); -if (rc < 0) { - fprintf(stderr, "poll failed\en"); - return 1; -} - -/* Get the async event */ -if (ibv_get_async_event(ctx, &async_event)) { - fprintf(stderr, "Failed to get async_event\en"); - return 1; -} - -/* Ack the event */ -ibv_ack_async_event(&async_event); - -.fi -.SH "SEE ALSO" -.BR ibv_open_device (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_get_cq_event.3 b/usr/rdma-core/libibverbs/man/ibv_get_cq_event.3 deleted file mode 100644 index a1a42e646..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_get_cq_event.3 +++ /dev/null @@ -1,186 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_GET_CQ_EVENT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_get_cq_event, ibv_ack_cq_events \- get and acknowledge completion queue (CQ) events - -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_get_cq_event(struct ibv_comp_channel " "*channel" , -.BI " struct ibv_cq " "**cq" ", void " "**cq_context" ); -.sp -.BI "void ibv_ack_cq_events(struct ibv_cq " "*cq" ", unsigned int " "nevents" ); -.fi - -.SH "DESCRIPTION" -.B ibv_get_cq_event() -waits for the next completion event in the completion event channel -.I channel\fR. -Fills the arguments -.I cq -with the CQ that got the event and -.I cq_context -with the CQ's context\fR. -.PP -.B ibv_ack_cq_events() -acknowledges -.I nevents -events on the CQ -.I cq\fR. - -.SH "RETURN VALUE" -.B ibv_get_cq_event() -returns 0 on success, and \-1 on error. -.PP -.B ibv_ack_cq_events() -returns no value. -.SH "NOTES" -All completion events that -.B ibv_get_cq_event() -returns must be acknowledged using -.B ibv_ack_cq_events()\fR. -To avoid races, destroying a CQ will wait for all completion events to -be acknowledged; this guarantees a one-to-one correspondence between -acks and successful gets. -.PP -Calling -.B ibv_ack_cq_events() -may be relatively expensive in the datapath, since it must take a -mutex. Therefore it may be better to amortize this cost by -keeping a count of the number of events needing acknowledgement and -acking several completion events in one call to -.B ibv_ack_cq_events()\fR. -.SH "EXAMPLES" -The following code example demonstrates one possible way to work with -completion events. It performs the following steps: -.PP -Stage I: Preparation -.br -1. Creates a CQ -.br -2. Requests for notification upon a new (first) completion event -.PP -Stage II: Completion Handling Routine -.br -3. Wait for the completion event and ack it -.br -4. Request for notification upon the next completion event -.br -5. Empty the CQ -.PP -Note that an extra event may be triggered without having a -corresponding completion entry in the CQ. This occurs if a completion -entry is added to the CQ between Step 4 and Step 5, and the CQ is then -emptied (polled) in Step 5. -.PP -.nf -cq = ibv_create_cq(ctx, 1, ev_ctx, channel, 0); -if (!cq) { - fprintf(stderr, "Failed to create CQ\en"); - return 1; -} -.PP -/* Request notification before any completion can be created */ -if (ibv_req_notify_cq(cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\en"); - return 1; -} -.PP -\&. -\&. -\&. -.PP -/* Wait for the completion event */ -if (ibv_get_cq_event(channel, &ev_cq, &ev_ctx)) { - fprintf(stderr, "Failed to get cq_event\en"); - return 1; -} - -/* Ack the event */ -ibv_ack_cq_events(ev_cq, 1); -.PP -/* Request notification upon the next completion event */ -if (ibv_req_notify_cq(ev_cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\en"); - return 1; -} -.PP -/* Empty the CQ: poll all of the completions from the CQ (if any exist) */ -do { - ne = ibv_poll_cq(cq, 1, &wc); - if (ne < 0) { - fprintf(stderr, "Failed to poll completions from the CQ\en"); - return 1; - } - - /* there may be an extra event with no completion in the CQ */ - if (ne == 0) - continue; -.PP - if (wc.status != IBV_WC_SUCCESS) { - fprintf(stderr, "Completion with status 0x%x was found\en", wc.status); - return 1; - } -} while (ne); -.fi - -The following code example demonstrates one possible way to work with -completion events in non-blocking mode. It performs the following -steps: -.PP -1. Set the completion event channel to be non-blocked -.br -2. Poll the channel until there it has a completion event -.br -3. Get the completion event and ack it -.PP -.nf -/* change the blocking mode of the completion channel */ -flags = fcntl(channel->fd, F_GETFL); -rc = fcntl(channel->fd, F_SETFL, flags | O_NONBLOCK); -if (rc < 0) { - fprintf(stderr, "Failed to change file descriptor of completion event channel\en"); - return 1; -} - - -/* - * poll the channel until it has an event and sleep ms_timeout - * milliseconds between any iteration - */ -my_pollfd.fd = channel->fd; -my_pollfd.events = POLLIN; -my_pollfd.revents = 0; - -do { - rc = poll(&my_pollfd, 1, ms_timeout); -} while (rc == 0); -if (rc < 0) { - fprintf(stderr, "poll failed\en"); - return 1; -} -ev_cq = cq; - -/* Wait for the completion event */ -if (ibv_get_cq_event(channel, &ev_cq, &ev_ctx)) { - fprintf(stderr, "Failed to get cq_event\en"); - return 1; -} - -/* Ack the event */ -ibv_ack_cq_events(ev_cq, 1); - -.fi -.SH "SEE ALSO" -.BR ibv_create_comp_channel (3), -.BR ibv_create_cq (3), -.BR ibv_req_notify_cq (3), -.BR ibv_poll_cq (3) - -.SH "AUTHORS" -.TP -Dotan Barak -.RI < dotanba@gmail.com > diff --git a/usr/rdma-core/libibverbs/man/ibv_get_device_guid.3 b/usr/rdma-core/libibverbs/man/ibv_get_device_guid.3 deleted file mode 100644 index 465261403..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_get_device_guid.3 +++ /dev/null @@ -1,26 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_GET_DEVICE_GUID 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_get_device_guid \- get an RDMA device's GUID -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "uint64_t ibv_get_device_guid(struct ibv_device " "*device" "); -.fi -.SH "DESCRIPTION" -.B ibv_get_device_name() -returns the Global Unique IDentifier (GUID) of the RDMA device -.I device\fR. -.SH "RETURN VALUE" -.B ibv_get_device_guid() -returns the GUID of the device in network byte order. -.SH "SEE ALSO" -.BR ibv_get_device_list (3), -.BR ibv_get_device_name (3), -.BR ibv_open_device (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_get_device_list.3 b/usr/rdma-core/libibverbs/man/ibv_get_device_list.3 deleted file mode 100644 index 71c4a740e..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_get_device_list.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_GET_DEVICE_LIST 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_get_device_list, ibv_free_device_list \- get and release list of available RDMA devices -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_device **ibv_get_device_list(int " "*num_devices" ); -.sp -.BI "void ibv_free_device_list(struct ibv_device " "**list" ); -.fi -.SH "DESCRIPTION" -.B ibv_get_device_list() -returns a NULL-terminated array of RDMA devices currently available. -The argument -.I num_devices -is optional; if not NULL, it is set to the number of devices returned in the array. -.PP -.B ibv_free_device_list() -frees the array of devices -.I list -returned by -.B ibv_get_device_list()\fR. -.SH "RETURN VALUE" -.B ibv_get_device_list() -returns the array of available RDMA devices, or sets -.I errno -and returns NULL if the request fails. If no devices are found then -.I num_devices -is set to 0, and non-NULL is returned. -.PP -.B ibv_free_device_list() -returns no value. -.SH "ERRORS" -.TP -.B EPERM -Permission denied. -.TP -.B ENOSYS -No kernel support for RDMA. -.TP -.B ENOMEM -Insufficient memory to complete the operation. -.SH "NOTES" -Client code should open all the devices it intends to use with -.B ibv_open_device()\fR before calling -.B ibv_free_device_list()\fR. -Once it frees the array with -.B ibv_free_device_list()\fR, -it will be able to use only the open devices; pointers to unopened devices will no longer be valid. -.P -Setting the environment variable -.BR IBV_SHOW_WARNINGS -will cause warnings to be emitted to stderr if a kernel verbs device -is discovered, but no corresponding userspace driver can be found for -it. -.SH "SEE ALSO" -.BR ibv_fork_init (3), -.BR ibv_get_device_name (3), -.BR ibv_get_device_guid (3), -.BR ibv_open_device (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_get_device_name.3 b/usr/rdma-core/libibverbs/man/ibv_get_device_name.3 deleted file mode 100644 index ff9fa7fca..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_get_device_name.3 +++ /dev/null @@ -1,26 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_GET_DEVICE_NAME 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_get_device_name \- get an RDMA device's name -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "const char *ibv_get_device_name(struct ibv_device " "*device" "); -.fi -.SH "DESCRIPTION" -.B ibv_get_device_name() -returns a human-readable name associated with the RDMA device -.I device\fR. -.SH "RETURN VALUE" -.B ibv_get_device_name() -returns a pointer to the device name, or NULL if the request fails. -.SH "SEE ALSO" -.BR ibv_get_device_list (3), -.BR ibv_get_device_guid (3), -.BR ibv_open_device (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_get_srq_num.3 b/usr/rdma-core/libibverbs/man/ibv_get_srq_num.3 deleted file mode 100644 index 4a1c92f32..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_get_srq_num.3 +++ /dev/null @@ -1,33 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_GET_SRQ_NUM 3 2013-06-26 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_get_srq_num \- return srq number associated with the given shared receive queue (SRQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_get_srq_num(struct ibv_srq " "*srq" , -.BI " uint32_t " "*srq_num" ); -.fi -.SH "DESCRIPTION" -.B ibv_get_srq_num() -return srq number associated with the given shared receive queue -The argument -.I srq -is an ibv_srq struct, as defined in . -.I srq_num -is an output parameter that holds the returned srq number. -.PP -.nf -.SH "RETURN VALUE" -.B ibv_get_srq_num() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_modify_srq (3), -.BR ibv_create_srq_ex (3) -.SH "AUTHORS" -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_inc_rkey.3 b/usr/rdma-core/libibverbs/man/ibv_inc_rkey.3 deleted file mode 100644 index 5c54a68bf..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_inc_rkey.3 +++ /dev/null @@ -1,33 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_INC_RKEY 3 2015-01-29 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -.nf -ibv_inc_rkey \- creates a new rkey from the given one -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "uint32_t ibv_inc_rkey(uint32_t " "rkey" "); -.fi -.SH "DESCRIPTION" -.B ibv_inc_rkey() -Increases the 8 LSB of -.I rkey -and returns the new value. -.PP -.SH "RETURN VALUE" -.B ibv_inc_rkey() -returns the new rkey. -.SH "NOTES" -.PP -The verb generates a new rkey that is different from the previous one on its tag part -but has the same index (bits 0xffffff00). -A use case for this verb can be to create a new rkey from a Memory window's rkey -when binding it to a Memory region. -.SH "AUTHORS" -.TP -Majd Dibbiny -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_modify_qp.3 b/usr/rdma-core/libibverbs/man/ibv_modify_qp.3 deleted file mode 100644 index 487aa9408..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_modify_qp.3 +++ /dev/null @@ -1,182 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_MODIFY_QP 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_modify_qp \- modify the attributes of a queue pair (QP) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_modify_qp(struct ibv_qp " "*qp" ", struct ibv_qp_attr " "*attr" , -.BI " int " "attr_mask" ); -.fi -.SH "DESCRIPTION" -.B ibv_modify_qp() -modifies the attributes of QP -.I qp -with the attributes in -.I attr -according to the mask -.I attr_mask\fR. -The argument \fIattr\fR is an ibv_qp_attr struct, as defined in . -.PP -.nf -struct ibv_qp_attr { -.in +8 -enum ibv_qp_state qp_state; /* Move the QP to this state */ -enum ibv_qp_state cur_qp_state; /* Assume this is the current QP state */ -enum ibv_mtu path_mtu; /* Path MTU (valid only for RC/UC QPs) */ -enum ibv_mig_state path_mig_state; /* Path migration state (valid if HCA supports APM) */ -uint32_t qkey; /* Q_Key for the QP (valid only for UD QPs) */ -uint32_t rq_psn; /* PSN for receive queue (valid only for RC/UC QPs) */ -uint32_t sq_psn; /* PSN for send queue (valid only for RC/UC QPs) */ -uint32_t dest_qp_num; /* Destination QP number (valid only for RC/UC QPs) */ -int qp_access_flags; /* Mask of enabled remote access operations (valid only for RC/UC QPs) */ -struct ibv_qp_cap cap; /* QP capabilities (valid if HCA supports QP resizing) */ -struct ibv_ah_attr ah_attr; /* Primary path address vector (valid only for RC/UC QPs) */ -struct ibv_ah_attr alt_ah_attr; /* Alternate path address vector (valid only for RC/UC QPs) */ -uint16_t pkey_index; /* Primary P_Key index */ -uint16_t alt_pkey_index; /* Alternate P_Key index */ -uint8_t en_sqd_async_notify; /* Enable SQD.drained async notification (Valid only if qp_state is SQD) */ -uint8_t sq_draining; /* Is the QP draining? Irrelevant for ibv_modify_qp() */ -uint8_t max_rd_atomic; /* Number of outstanding RDMA reads & atomic operations on the destination QP (valid only for RC QPs) */ -uint8_t max_dest_rd_atomic; /* Number of responder resources for handling incoming RDMA reads & atomic operations (valid only for RC QPs) */ -uint8_t min_rnr_timer; /* Minimum RNR NAK timer (valid only for RC QPs) */ -uint8_t port_num; /* Primary port number */ -uint8_t timeout; /* Local ack timeout for primary path (valid only for RC QPs) */ -uint8_t retry_cnt; /* Retry count (valid only for RC QPs) */ -uint8_t rnr_retry; /* RNR retry (valid only for RC QPs) */ -uint8_t alt_port_num; /* Alternate port number */ -uint8_t alt_timeout; /* Local ack timeout for alternate path (valid only for RC QPs) */ -uint32_t rate_limit; /* Rate limit in kbps for packet pacing */ -.in -8 -}; -.fi -.PP -For details on struct ibv_qp_cap see the description of -.B ibv_create_qp()\fR. -For details on struct ibv_ah_attr see the description of -.B ibv_create_ah()\fR. -.PP -The argument -.I attr_mask -specifies the QP attributes to be modified. -The argument is either 0 or the bitwise OR of one or more of the following flags: -.PP -.TP -.B IBV_QP_STATE \fR Modify qp_state -.TP -.B IBV_QP_CUR_STATE \fR Set cur_qp_state -.TP -.B IBV_QP_EN_SQD_ASYNC_NOTIFY \fR Set en_sqd_async_notify -.TP -.B IBV_QP_ACCESS_FLAGS \fR Set qp_access_flags -.TP -.B IBV_QP_PKEY_INDEX \fR Set pkey_index -.TP -.B IBV_QP_PORT \fR Set port_num -.TP -.B IBV_QP_QKEY \fR Set qkey -.TP -.B IBV_QP_AV \fR Set ah_attr -.TP -.B IBV_QP_PATH_MTU \fR Set path_mtu -.TP -.B IBV_QP_TIMEOUT \fR Set timeout -.TP -.B IBV_QP_RETRY_CNT \fR Set retry_cnt -.TP -.B IBV_QP_RNR_RETRY \fR Set rnr_retry -.TP -.B IBV_QP_RQ_PSN \fR Set rq_psn -.TP -.B IBV_QP_MAX_QP_RD_ATOMIC \fR Set max_rd_atomic -.TP -.B IBV_QP_ALT_PATH \fR Set the alternative path via: alt_ah_attr, alt_pkey_index, alt_port_num, alt_timeout -.TP -.B IBV_QP_MIN_RNR_TIMER \fR Set min_rnr_timer -.TP -.B IBV_QP_SQ_PSN \fR Set sq_psn -.TP -.B IBV_QP_MAX_DEST_RD_ATOMIC \fR Set max_dest_rd_atomic -.TP -.B IBV_QP_PATH_MIG_STATE \fR Set path_mig_state -.TP -.B IBV_QP_CAP \fR Set cap -.TP -.B IBV_QP_DEST_QPN \fR Set dest_qp_num -.B IBV_QP_RATE_LIMIT \fR Set rate_limit -.SH "RETURN VALUE" -.B ibv_modify_qp() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -If any of the modify attributes or the modify mask are invalid, none -of the attributes will be modified (including the QP state). -.PP -Not all devices support resizing QPs. To check if a device supports it, check if the -.B IBV_DEVICE_RESIZE_MAX_WR -bit is set in the device capabilities flags. -.PP -Not all devices support alternate paths. To check if a device supports it, check if the -.B IBV_DEVICE_AUTO_PATH_MIG -bit is set in the device capabilities flags. -.PP -The following tables indicate for each QP Transport Service Type, the -minimum list of attributes that must be changed upon transitioning QP -state from: Reset \-\-> Init \-\-> RTR \-\-> RTS. -.PP -.nf -For QP Transport Service Type \fB IBV_QPT_UD\fR: -.sp -Next state Required attributes -\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- -Init \fB IBV_QP_STATE, IBV_QP_PKEY_INDEX, IBV_QP_PORT, \fR - \fB IBV_QP_QKEY \fR -RTR \fB IBV_QP_STATE \fR -RTS \fB IBV_QP_STATE, IBV_QP_SQ_PSN \fR -.fi -.PP -.nf -For QP Transport Service Type \fB IBV_QPT_UC\fR: -.sp -Next state Required attributes -\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- -Init \fB IBV_QP_STATE, IBV_QP_PKEY_INDEX, IBV_QP_PORT, \fR - \fB IBV_QP_ACCESS_FLAGS \fR -RTR \fB IBV_QP_STATE, IBV_QP_AV, IBV_QP_PATH_MTU, \fR - \fB IBV_QP_DEST_QPN, IBV_QP_RQ_PSN \fR -RTS \fB IBV_QP_STATE, IBV_QP_SQ_PSN \fR -.fi -.PP -.nf -For QP Transport Service Type \fB IBV_QPT_RC\fR: -.sp -Next state Required attributes -\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- -Init \fB IBV_QP_STATE, IBV_QP_PKEY_INDEX, IBV_QP_PORT, \fR - \fB IBV_QP_ACCESS_FLAGS \fR -RTR \fB IBV_QP_STATE, IBV_QP_AV, IBV_QP_PATH_MTU, \fR - \fB IBV_QP_DEST_QPN, IBV_QP_RQ_PSN, \fR - \fB IBV_QP_MAX_DEST_RD_ATOMIC, IBV_QP_MIN_RNR_TIMER \fR -RTS \fB IBV_QP_STATE, IBV_QP_SQ_PSN, IBV_QP_MAX_QP_RD_ATOMIC, \fR - \fB IBV_QP_RETRY_CNT, IBV_QP_RNR_RETRY, IBV_QP_TIMEOUT \fR -.fi -.PP -.nf -For QP Transport Service Type \fB IBV_QPT_RAW_PACKET\fR: -.sp -Next state Required attributes -\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- -Init \fB IBV_QP_STATE, IBV_QP_PORT\fR -RTR \fB IBV_QP_STATE\fR -RTS \fB IBV_QP_STATE\fR -.fi -.SH "SEE ALSO" -.BR ibv_create_qp (3), -.BR ibv_destroy_qp (3), -.BR ibv_query_qp (3), -.BR ibv_create_ah (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_modify_srq.3 b/usr/rdma-core/libibverbs/man/ibv_modify_srq.3 deleted file mode 100644 index 523392289..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_modify_srq.3 +++ /dev/null @@ -1,64 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_MODIFY_SRQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_modify_srq \- modify attributes of a shared receive queue (SRQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_modify_srq(struct ibv_srq " "*srq" , -.BI " struct ibv_srq_attr " "*srq_attr" , -.BI " int " "srq_attr_mask" ); -.fi -.SH "DESCRIPTION" -.B ibv_modify_srq() -modifies the attributes of SRQ -.I srq -with the attributes in -.I srq_attr -according to the mask -.I srq_attr_mask\fR. -The argument \fIsrq_attr\fR is an ibv_srq_attr struct, as defined in . -.PP -.nf -struct ibv_srq_attr { -.in +8 -uint32_t max_wr; /* maximum number of outstanding work requests (WRs) in the SRQ */ -uint32_t max_sge; /* number of scatter elements per WR (irrelevant for ibv_modify_srq) */ -uint32_t srq_limit; /* the limit value of the SRQ */ -.in -8 -}; -.fi -.PP -The argument -.I srq_attr_mask -specifies the SRQ attributes to be modified. -The argument is either 0 or the bitwise OR of one or more of the following flags: -.PP -.TP -.B IBV_SRQ_MAX_WR \fR Resize the SRQ -.TP -.B IBV_SRQ_LIMIT \fR Set the SRQ limit -.SH "RETURN VALUE" -.B ibv_modify_srq() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -If any of the modify attributes is invalid, none of the attributes will be modified. -.PP -Not all devices support resizing SRQs. To check if a device supports it, check if the -.B IBV_DEVICE_SRQ_RESIZE -bit is set in the device capabilities flags. -.PP -Modifying the srq_limit arms the SRQ to produce an -.B IBV_EVENT_SRQ_LIMIT_REACHED -"low watermark" asynchronous event once the number of WRs in the SRQ drops below srq_limit. -.SH "SEE ALSO" -.BR ibv_query_device (3), -.BR ibv_create_srq (3), -.BR ibv_destroy_srq (3), -.BR ibv_query_srq (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_modify_wq.3 b/usr/rdma-core/libibverbs/man/ibv_modify_wq.3 deleted file mode 100644 index 1972ec2a8..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_modify_wq.3 +++ /dev/null @@ -1,46 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_MODIFY_WQ 3 2016-07-27 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_modify_wq \- Modify a Work Queue (WQ). -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct int ibv_modify_wq(struct ibv_wq " "*wq," -.BI " struct ibv_wq_attr " "*wq_attr" ); -.sp -.fi -.SH "DESCRIPTION" -.B ibv_modify_wq() -modifys a WQ -.I wq\fR. -The argument -.I wq_attr -is an ibv_wq_attr struct, as defined in . -.PP -.nf -struct ibv_wq_attr { -.in +8 -uint32_t attr_mask; /* Use enum ibv_wq_attr_mask */ -enum ibv_wq_state wq_state; /* Move to this state */ -enum ibv_wq_state curr_wq_state; /* Assume this is the current state */ -uint32_t flags; /* Flags values to modify, use enum ibv_wq_flags */ -uint32_t flags_mask; /* Which flags to modify, use enum ibv_wq_flags */ -.in -8 -}; -.fi -.PP -The function -.B ibv_modify_wq() -will modify the WQ based on the given -.I wq_attr\fB\fR->attr_mask -.SH "RETURN VALUE" -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "SEE ALSO" -.BR ibv_create_wq (3), -.BR ibv_destroy_wq (3), -.SH "AUTHORS" -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_open_device.3 b/usr/rdma-core/libibverbs/man/ibv_open_device.3 deleted file mode 100644 index cae2c4d32..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_open_device.3 +++ /dev/null @@ -1,44 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_OPEN_DEVICE 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_open_device, ibv_close_device \- open and close an RDMA device context -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_context *ibv_open_device(struct ibv_device " "*device" "); -.sp -.BI "int ibv_close_device(struct ibv_context " "*context" "); -.fi -.SH "DESCRIPTION" -.B ibv_open_device() -opens the device -.I device -and creates a context for further use. -.PP -.B ibv_close_device() -closes the device context -.I context\fR. -.SH "RETURN VALUE" -.B ibv_open_device() -returns a pointer to the allocated device context, or NULL if the request fails. -.PP -.B ibv_close_device() -returns 0 on success, \-1 on failure. -.SH "NOTES" -.B ibv_close_device() -does not release all the resources allocated using context -.I context\fR. -To avoid resource leaks, the user should release all associated -resources before closing a context. -.SH "SEE ALSO" -.BR ibv_get_device_list (3), -.BR ibv_query_device (3), -.BR ibv_query_port (3), -.BR ibv_query_gid (3), -.BR ibv_query_pkey (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_open_qp.3 b/usr/rdma-core/libibverbs/man/ibv_open_qp.3 deleted file mode 100644 index e25e93389..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_open_qp.3 +++ /dev/null @@ -1,52 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_OPEN_QP 3 2011-08-12 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_open_qp \- open a shareable queue pair (QP) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_qp *ibv_open_qp(struct ibv_context " "*context" , -.BI " struct ibv_qp_open_attr " "*qp_open_attr" ); -.fi -.SH "DESCRIPTION" -.B ibv_open_qp() -opens an existing queue pair (QP) associated with the extended protection domain -.I xrcd\fR. -The argument -.I qp_open_attr -is an ibv_qp_open_attr struct, as defined in . -.PP -.nf -struct ibv_qp_open_attr { -.in +8 -uint32_t comp_mask; /* Identifies valid fields */ -uint32_t qp_num; /* QP number */ -struct *ibv_xrcd; /* XRC domain */ -void *qp_context; /* User defined opaque value */ -enum ibv_qp_type qp_type; /* QP transport service type */ -.fi -.PP -.B ibv_destroy_qp() -closes the opened QP and destroys the underlying QP if it has no -other references. -.I qp\fR. -.SH "RETURN VALUE" -.B ibv_open_qp() -returns a pointer to the opened QP, or NULL if the request fails. -Check the QP number (\fBqp_num\fR) in the returned QP. -.SH "NOTES" -.B ibv_open_qp() -will fail if a it is asked to open a QP that does not exist within -the xrcd with the specified qp_num and qp_type. -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_create_qp (3), -.BR ibv_create_qp_ex (3), -.BR ibv_modify_qp (3), -.BR ibv_query_qp (3) -.SH "AUTHORS" -.TP -Sean Hefty diff --git a/usr/rdma-core/libibverbs/man/ibv_open_xrcd.3 b/usr/rdma-core/libibverbs/man/ibv_open_xrcd.3 deleted file mode 100644 index 239af2da3..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_open_xrcd.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_OPEN_XRCD 3 2011-06-17 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_open_xrcd, ibv_close_xrcd \- open or close an XRC protection domain (XRCDs) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_xrcd *ibv_open_xrcd(struct ibv_context " "*context" "," -.BI " struct ibv_xrcd_init_attr " "*xrcd_init_attr" ); -.sp -.BI "int ibv_close_xrcd(struct ibv_xrcd " "*xrcd" ); -.fi -.SH "DESCRIPTION" -.B ibv_open_xrcd() -open an XRC domain for the RDMA device context -.I context -.I xrcd_init_attr -is an ibv_xrcd_init_attr struct, as defined in . -.PP -.nf -struct ibv_xrcd_init_attr { -.in +8 -uint32_t comp_mask; /* Identifies valid fields */ -int fd; -int oflag; -.fi -.PP -.I fd -is the file descriptor to associate with the XRCD. -.I oflag -describes the desired creation attributes. It is a bitwise OR of zero or more -of the following flags: -.PP -.TP -.B O_CREAT -Indicates that an XRCD should be created and associated with the inode referenced -by the given fd. If the XRCD exists, this flag has no effect except as noted under -.BR O_EXCL -below.\fR -.TP -.B O_EXCL -If -.BR O_EXCL -and -.BR O_CREAT -are set, open will fail if an XRCD associated with the inode exists. -.PP -If -.I fd -equals -1, no inode is associated with the XRCD. To indicate that XRCD should be created, use -.I oflag -= -.B O_CREAT\fR. -.PP -.B ibv_close_xrcd() -closes the XRCD -.I xrcd\fR. -If this is the last reference, the XRCD will be destroyed. -.SH "RETURN VALUE" -.B ibv_open_xrcd() -returns a pointer to the opened XRCD, or NULL if the request fails. -.PP -.B ibv_close_xrcd() -returns 0 on success, or the value of errno on failure (which indicates the -failure reason). -.SH "NOTES" -.B ibv_close_xrcd() -may fail if any other resource is still associated with the XRCD being closed. -.SH "SEE ALSO" -.BR ibv_create_srq_ex (3), -.BR ibv_create_qp_ex (3), -.SH "AUTHORS" -.TP -Sean Hefty diff --git a/usr/rdma-core/libibverbs/man/ibv_poll_cq.3 b/usr/rdma-core/libibverbs/man/ibv_poll_cq.3 deleted file mode 100644 index 12d1a7674..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_poll_cq.3 +++ /dev/null @@ -1,90 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_POLL_CQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_poll_cq \- poll a completion queue (CQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_poll_cq(struct ibv_cq " "*cq" ", int " "num_entries" , -.BI " struct ibv_wc " "*wc" ); -.fi -.SH "DESCRIPTION" -.B ibv_poll_cq() -polls the CQ -.I cq -for work completions and returns the first -.I num_entries -(or all available completions if the CQ contains fewer than this number) in the array -.I wc\fR. -The argument -.I wc -is a pointer to an array of ibv_wc structs, as defined in . -.PP -.nf -struct ibv_wc { -.in +8 -uint64_t wr_id; /* ID of the completed Work Request (WR) */ -enum ibv_wc_status status; /* Status of the operation */ -enum ibv_wc_opcode opcode; /* Operation type specified in the completed WR */ -uint32_t vendor_err; /* Vendor error syndrome */ -uint32_t byte_len; /* Number of bytes transferred */ -union { -.in +8 -__be32 imm_data; /* Immediate data (in network byte order) */ -uint32_t invalidated_rkey; /* Local RKey that was invalidated */ -.in -8 -}; -uint32_t qp_num; /* Local QP number of completed WR */ -uint32_t src_qp; /* Source QP number (remote QP number) of completed WR (valid only for UD QPs) */ -int wc_flags; /* Flags of the completed WR */ -uint16_t pkey_index; /* P_Key index (valid only for GSI QPs) */ -uint16_t slid; /* Source LID */ -uint8_t sl; /* Service Level */ -uint8_t dlid_path_bits; /* DLID path bits (not applicable for multicast messages) */ -.in -8 -}; -.sp -.fi -.PP -The attribute wc_flags describes the properties of the work completion. -It is either 0 or the bitwise OR of one or more of the following flags: -.PP -.TP -.B IBV_WC_GRH \fR GRH is present (valid only for UD QPs) -.TP -.B IBV_WC_WITH_IMM \fR Immediate data value is valid -.TP -.B IBV_WC_WITH_INV \fR Invalidated RKey data value is valid (cannot be combined with IBV_WC_WITH_IMM) -.TP -.B IBV_WC_IP_CSUM_OK \fR TCP/UDP checksum over IPv4 and IPv4 header checksum are -verified. -Valid only when \fBdevice_cap_flags\fR in device_attr indicates current QP is -supported by checksum offload. -.PP -Not all -.I wc -attributes are always valid. If the completion status is other than -.B IBV_WC_SUCCESS\fR, -only the following attributes are valid: wr_id, status, qp_num, and vendor_err. -.SH "RETURN VALUE" -On success, -.B ibv_poll_cq() -returns a non-negative value equal to the number of completions -found. On failure, a negative value is returned. -.SH "NOTES" -.PP -Each polled completion is removed from the CQ and cannot be returned to it. -.PP -The user should consume work completions at a rate that prevents CQ -overrun from occurrence. In case of a CQ overrun, the async event -.B IBV_EVENT_CQ_ERR -will be triggered, and the CQ cannot be used. -.SH "SEE ALSO" -.BR ibv_post_send (3), -.BR ibv_post_recv (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_post_recv.3 b/usr/rdma-core/libibverbs/man/ibv_post_recv.3 deleted file mode 100644 index affca74cf..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_post_recv.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_POST_RECV 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_post_recv \- post a list of work requests (WRs) to a receive queue -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_post_recv(struct ibv_qp " "*qp" ", struct ibv_recv_wr " "*wr" , -.BI " struct ibv_recv_wr " "**bad_wr" ); -.fi -.SH "DESCRIPTION" -.B ibv_post_recv() -posts the linked list of work requests (WRs) starting with -.I wr -to the receive queue of the queue pair -.I qp\fR. -It stops processing WRs from this list at the first failure (that can -be detected immediately while requests are being posted), and returns -this failing WR through -.I bad_wr\fR. -.PP -The argument -.I wr -is an ibv_recv_wr struct, as defined in . -.PP -.nf -struct ibv_recv_wr { -.in +8 -uint64_t wr_id; /* User defined WR ID */ -struct ibv_recv_wr *next; /* Pointer to next WR in list, NULL if last WR */ -struct ibv_sge *sg_list; /* Pointer to the s/g array */ -int num_sge; /* Size of the s/g array */ -.in -8 -}; -.sp -.nf -struct ibv_sge { -.in +8 -uint64_t addr; /* Start address of the local memory buffer */ -uint32_t length; /* Length of the buffer */ -uint32_t lkey; /* Key of the local Memory Region */ -.in -8 -}; -.fi -.SH "RETURN VALUE" -.B ibv_post_recv() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -The buffers used by a WR can only be safely reused after WR the -request is fully executed and a work completion has been retrieved -from the corresponding completion queue (CQ). -.PP -If the QP -.I qp -is associated with a shared receive queue, you must use the function -.B ibv_post_srq_recv()\fR, -and not -.B ibv_post_recv()\fR, -since the QP's own receive queue will not be used. -.PP -If a WR is being posted to a UD QP, the Global Routing Header (GRH) of -the incoming message will be placed in the first 40 bytes of the -buffer(s) in the scatter list. If no GRH is present in the incoming -message, then the first bytes will be undefined. This means that in -all cases, the actual data of the incoming message will start at an -offset of 40 bytes into the buffer(s) in the scatter list. -.SH "SEE ALSO" -.BR ibv_create_qp (3), -.BR ibv_post_send (3), -.BR ibv_post_srq_recv (3), -.BR ibv_poll_cq (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_post_send.3 b/usr/rdma-core/libibverbs/man/ibv_post_send.3 deleted file mode 100644 index d0ee27532..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_post_send.3 +++ /dev/null @@ -1,180 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_POST_SEND 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_post_send \- post a list of work requests (WRs) to a send queue -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_post_send(struct ibv_qp " "*qp" ", struct ibv_send_wr " "*wr" , -.BI " struct ibv_send_wr " "**bad_wr" ); -.fi -.SH "DESCRIPTION" -.B ibv_post_send() -posts the linked list of work requests (WRs) starting with -.I wr -to the send queue of the queue pair -.I qp\fR. -It stops processing WRs from this list at the first failure (that can -be detected immediately while requests are being posted), and returns -this failing WR through -.I bad_wr\fR. -.PP -The argument -.I wr -is an ibv_send_wr struct, as defined in . -.PP -.nf -struct ibv_send_wr { -.in +8 -uint64_t wr_id; /* User defined WR ID */ -struct ibv_send_wr *next; /* Pointer to next WR in list, NULL if last WR */ -struct ibv_sge *sg_list; /* Pointer to the s/g array */ -int num_sge; /* Size of the s/g array */ -enum ibv_wr_opcode opcode; /* Operation type */ -int send_flags; /* Flags of the WR properties */ -union { -.in +8 -__be32 imm_data; /* Immediate data (in network byte order) */ -uint32_t invalidate_rkey; /* Remote rkey to invalidate */ -.in -8 -}; -union { -.in +8 -struct { -.in +8 -uint64_t remote_addr; /* Start address of remote memory buffer */ -uint32_t rkey; /* Key of the remote Memory Region */ -.in -8 -} rdma; -struct { -.in +8 -uint64_t remote_addr; /* Start address of remote memory buffer */ -uint64_t compare_add; /* Compare operand */ -uint64_t swap; /* Swap operand */ -uint32_t rkey; /* Key of the remote Memory Region */ -.in -8 -} atomic; -struct { -.in +8 -struct ibv_ah *ah; /* Address handle (AH) for the remote node address */ -uint32_t remote_qpn; /* QP number of the destination QP */ -uint32_t remote_qkey; /* Q_Key number of the destination QP */ -.in -8 -} ud; -.in -8 -} wr; -union { -.in +8 -struct { -.in +8 -uint32_t remote_srqn; /* Number of the remote SRQ */ -.in -8 -} xrc; -.in -8 -} qp_type; -union { -.in +8 -struct { -.in +8 -struct ibv_mw *mw; /* Memory window (MW) of type 2 to bind */ -uint32_t rkey; /* The desired new rkey of the MW */ -struct ibv_mw_bind_info bind_info; /* MW additional bind information */ -.in -8 -} bind_mw; -struct { -.in +8 -void *hdr; /* Pointer address of inline header */ -uint16_t hdr_sz; /* Inline header size */ -uint16_t mss; /* Maximum segment size for each TSO fragment */ -.in -8 -} tso; -.in -8 -}; -.in -8 -}; -.fi -.sp -.nf -struct ibv_mw_bind_info { -.in +8 -struct ibv_mr *mr; /* The Memory region (MR) to bind the MW to */ -uint64_t addr; /* The address the MW should start at */ -uint64_t length; /* The length (in bytes) the MW should span */ -int mw_access_flags; /* Access flags to the MW. Use ibv_access_flags */ -.in -8 -}; -.fi -.sp -.nf -struct ibv_sge { -.in +8 -uint64_t addr; /* Start address of the local memory buffer */ -uint32_t length; /* Length of the buffer */ -uint32_t lkey; /* Key of the local Memory Region */ -.in -8 -}; -.fi -.PP -Each QP Transport Service Type supports a specific set of opcodes, as shown in the following table: -.PP -.nf -OPCODE | IBV_QPT_UD | IBV_QPT_UC | IBV_QPT_RC | IBV_QPT_XRC_SEND | IBV_QPT_RAW_PACKET -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- -IBV_WR_SEND | X | X | X | X | X -IBV_WR_SEND_WITH_IMM | X | X | X | X | -IBV_WR_RDMA_WRITE | | X | X | X | -IBV_WR_RDMA_WRITE_WITH_IMM | | X | X | X | -IBV_WR_RDMA_READ | | | X | X | -IBV_WR_ATOMIC_CMP_AND_SWP | | | X | X | -IBV_WR_ATOMIC_FETCH_AND_ADD | | | X | X | -IBV_WR_LOCAL_INV | | X | X | X | -IBV_WR_BIND_MW | | X | X | X | -IBV_WR_SEND_WITH_INV | | X | X | X | -IBV_WR_TSO | X | | | | X -.fi -.PP -The attribute send_flags describes the properties of the \s-1WR\s0. It is either 0 or the bitwise \s-1OR\s0 of one or more of the following flags: -.PP -.TP -.B IBV_SEND_FENCE \fR Set the fence indicator. Valid only for QPs with Transport Service Type \fBIBV_QPT_RC -.TP -.B IBV_SEND_SIGNALED \fR Set the completion notification indicator. Relevant only if QP was created with sq_sig_all=0 -.TP -.B IBV_SEND_SOLICITED \fR Set the solicited event indicator. Valid only for Send and RDMA Write with immediate -.TP -.B IBV_SEND_INLINE \fR Send data in given gather list as inline data -in a send WQE. Valid only for Send and RDMA Write. The L_Key will not be checked. -.TP -.B IBV_SEND_IP_CSUM \fR Offload the IPv4 and TCP/UDP checksum calculation. -Valid only when \fBdevice_cap_flags\fR in device_attr indicates current QP is -supported by checksum offload. -.SH "RETURN VALUE" -.B ibv_post_send() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -The user should not alter or destroy AHs associated with WRs until -request is fully executed and a work completion has been retrieved -from the corresponding completion queue (CQ) to avoid unexpected -behavior. -.PP -The buffers used by a WR can only be safely reused after WR the -request is fully executed and a work completion has been retrieved -from the corresponding completion queue (CQ). However, if the -IBV_SEND_INLINE flag was set, the buffer can be reused immediately -after the call returns. -.SH "SEE ALSO" -.BR ibv_create_qp (3), -.BR ibv_create_ah (3), -.BR ibv_post_recv (3), -.BR ibv_post_srq_recv (3), -.BR ibv_poll_cq (3) -.SH "AUTHORS" -.TP -Dotan Barak -.TP -Majd Dibbiny -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_post_srq_recv.3 b/usr/rdma-core/libibverbs/man/ibv_post_srq_recv.3 deleted file mode 100644 index 51d1516bd..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_post_srq_recv.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_POST_SRQ_RECV 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_post_srq_recv \- post a list of work requests (WRs) to a shared receive queue (SRQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_post_srq_recv(struct ibv_srq " "*srq" ", struct ibv_recv_wr " "*wr" , -.BI " struct ibv_recv_wr " "**bad_wr" ); -.fi -.SH "DESCRIPTION" -.B ibv_post_srq_recv() -posts the linked list of work requests (WRs) starting with -.I wr -to the shared receive queue (SRQ) -.I srq\fR. -It stops processing WRs from this list at the first failure (that can -be detected immediately while requests are being posted), and returns -this failing WR through -.I bad_wr\fR. -.PP -The argument -.I wr -is an ibv_recv_wr struct, as defined in . -.PP -.nf -struct ibv_recv_wr { -.in +8 -uint64_t wr_id; /* User defined WR ID */ -struct ibv_recv_wr *next; /* Pointer to next WR in list, NULL if last WR */ -struct ibv_sge *sg_list; /* Pointer to the s/g array */ -int num_sge; /* Size of the s/g array */ -.in -8 -}; -.sp -.nf -struct ibv_sge { -.in +8 -uint64_t addr; /* Start address of the local memory buffer */ -uint32_t length; /* Length of the buffer */ -uint32_t lkey; /* Key of the local Memory Region */ -.in -8 -}; -.fi -.SH "RETURN VALUE" -.B ibv_post_srq_recv() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -The buffers used by a WR can only be safely reused after WR the -request is fully executed and a work completion has been retrieved -from the corresponding completion queue (CQ). -.PP -If a WR is being posted to a UD QP, the Global Routing Header (GRH) of -the incoming message will be placed in the first 40 bytes of the -buffer(s) in the scatter list. If no GRH is present in the incoming -message, then the first bytes will be undefined. This means that in -all cases, the actual data of the incoming message will start at an -offset of 40 bytes into the buffer(s) in the scatter list. -.SH "SEE ALSO" -.BR ibv_create_qp (3), -.BR ibv_post_send (3), -.BR ibv_post_recv (3), -.BR ibv_poll_cq (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_query_device.3 b/usr/rdma-core/libibverbs/man/ibv_query_device.3 deleted file mode 100644 index 0e9d2860d..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_query_device.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_QUERY_DEVICE 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_query_device \- query an RDMA device's attributes -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_query_device(struct ibv_context " "*context", -.BI " struct ibv_device_attr " "*device_attr" ); -.fi -.SH "DESCRIPTION" -.B ibv_query_device() -returns the attributes of the device with context -.I context\fR. -The argument -.I device_attr -is a pointer to an ibv_device_attr struct, as defined in . -.PP -.nf -struct ibv_device_attr { -.in +8 -char fw_ver[64]; /* FW version */ -uint64_t node_guid; /* Node GUID (in network byte order) */ -uint64_t sys_image_guid; /* System image GUID (in network byte order) */ -uint64_t max_mr_size; /* Largest contiguous block that can be registered */ -uint64_t page_size_cap; /* Supported memory shift sizes */ -uint32_t vendor_id; /* Vendor ID, per IEEE */ -uint32_t vendor_part_id; /* Vendor supplied part ID */ -uint32_t hw_ver; /* Hardware version */ -int max_qp; /* Maximum number of supported QPs */ -int max_qp_wr; /* Maximum number of outstanding WR on any work queue */ -int device_cap_flags; /* HCA capabilities mask */ -int max_sge; /* Maximum number of s/g per WR for SQ & RQ of QP for non RDMA Read operations */ -int max_sge_rd; /* Maximum number of s/g per WR for RDMA Read operations */ -int max_cq; /* Maximum number of supported CQs */ -int max_cqe; /* Maximum number of CQE capacity per CQ */ -int max_mr; /* Maximum number of supported MRs */ -int max_pd; /* Maximum number of supported PDs */ -int max_qp_rd_atom; /* Maximum number of RDMA Read & Atomic operations that can be outstanding per QP */ -int max_ee_rd_atom; /* Maximum number of RDMA Read & Atomic operations that can be outstanding per EEC */ -int max_res_rd_atom; /* Maximum number of resources used for RDMA Read & Atomic operations by this HCA as the Target */ -int max_qp_init_rd_atom; /* Maximum depth per QP for initiation of RDMA Read & Atomic operations */ -int max_ee_init_rd_atom; /* Maximum depth per EEC for initiation of RDMA Read & Atomic operations */ -enum ibv_atomic_cap atomic_cap; /* Atomic operations support level */ -int max_ee; /* Maximum number of supported EE contexts */ -int max_rdd; /* Maximum number of supported RD domains */ -int max_mw; /* Maximum number of supported MWs */ -int max_raw_ipv6_qp; /* Maximum number of supported raw IPv6 datagram QPs */ -int max_raw_ethy_qp; /* Maximum number of supported Ethertype datagram QPs */ -int max_mcast_grp; /* Maximum number of supported multicast groups */ -int max_mcast_qp_attach; /* Maximum number of QPs per multicast group which can be attached */ -int max_total_mcast_qp_attach;/* Maximum number of QPs which can be attached to multicast groups */ -int max_ah; /* Maximum number of supported address handles */ -int max_fmr; /* Maximum number of supported FMRs */ -int max_map_per_fmr; /* Maximum number of (re)maps per FMR before an unmap operation in required */ -int max_srq; /* Maximum number of supported SRQs */ -int max_srq_wr; /* Maximum number of WRs per SRQ */ -int max_srq_sge; /* Maximum number of s/g per SRQ */ -uint16_t max_pkeys; /* Maximum number of partitions */ -uint8_t local_ca_ack_delay; /* Local CA ack delay */ -uint8_t phys_port_cnt; /* Number of physical ports */ -.in -8 -}; -.fi -.SH "RETURN VALUE" -.B ibv_query_device() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -The maximum values returned by this function are the upper limits of -supported resources by the device. However, it may not be possible to -use these maximum values, since the actual number of any resource that -can be created may be limited by the machine configuration, the amount -of host memory, user permissions, and the amount of resources already -in use by other users/processes. -.SH "SEE ALSO" -.BR ibv_open_device (3), -.BR ibv_query_port (3), -.BR ibv_query_pkey (3), -.BR ibv_query_gid (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_query_device_ex.3 b/usr/rdma-core/libibverbs/man/ibv_query_device_ex.3 deleted file mode 100644 index fdfb70811..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_query_device_ex.3 +++ /dev/null @@ -1,106 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_QUERY_DEVICE_EX 3 2014-12-17 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_query_device_ex \- query an RDMA device's attributes -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_query_device_ex(struct ibv_context " "*context", -.BI " struct ibv_device_attr_ex " "*attr" ); -.fi -.SH "DESCRIPTION" -.B ibv_query_device_ex() -returns the attributes of the device with context -.I context\fR. -The argument -.I attr -is a pointer to an ibv_device_attr_ex struct, as defined in . -.PP -.nf -struct ibv_device_attr_ex { -.in +8 -struct ibv_device_attr orig_attr; -uint32_t comp_mask; /* Compatibility mask that defines which of the following variables are valid */ -struct ibv_odp_caps odp_caps; /* On-Demand Paging capabilities */ -uint64_t completion_timestamp_mask; /* Completion timestamp mask (0 = unsupported) */ -uint64_t hca_core_clock; /* The frequency (in kHZ) of the HCA (0 = unsupported) */ -uint64_t device_cap_flags_ex; /* Extended device capability flags */ -struct ibv_tso_caps tso_caps; /* TCP segmentation offload capabilities */ -struct ibv_rss_caps rss_caps; /* RSS capabilities */ -uint32_t max_wq_type_rq; /* Max Work Queue from type RQ */ -struct ibv_packet_pacing_caps packet_pacing_caps; /* Packet pacing capabilities */ -uint32_t raw_packet_caps; /* Raw packet capabilities, use enum ibv_raw_packet_caps */ -.in -8 -}; - -struct ibv_odp_caps { - uint64_t general_odp_caps; /* Mask with enum ibv_odp_general_cap_bits */ - struct { - uint32_t rc_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */ - uint32_t uc_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */ - uint32_t ud_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */ - } per_transport_caps; -}; - -enum ibv_odp_general_cap_bits { - IBV_ODP_SUPPORT = 1 << 0, /* On demand paging is supported */ -}; - -enum ibv_odp_transport_cap_bits { - IBV_ODP_SUPPORT_SEND = 1 << 0, /* Send operations support on-demand paging */ - IBV_ODP_SUPPORT_RECV = 1 << 1, /* Receive operations support on-demand paging */ - IBV_ODP_SUPPORT_WRITE = 1 << 2, /* RDMA-Write operations support on-demand paging */ - IBV_ODP_SUPPORT_READ = 1 << 3, /* RDMA-Read operations support on-demand paging */ - IBV_ODP_SUPPORT_ATOMIC = 1 << 4, /* RDMA-Atomic operations support on-demand paging */ -}; - -struct ibv_tso_caps { - uint32_t max_tso; /* Maximum payload size in bytes supported for segmentation by TSO engine.*/ - uint32_t supported_qpts; /* Bitmap showing which QP types are supported by TSO operation. */ -}; - -struct ibv_rss_caps { - uint32_t supported_qpts; /* Bitmap showing which QP types are supported RSS */ - uint32_t max_rwq_indirection_tables; /* Max receive work queue indirection tables */ - uint32_t max_rwq_indirection_table_size; /* Max receive work queue indirection table size */ - uint64_t rx_hash_fields_mask; /* Mask with enum ibv_rx_hash_fields to know which incoming packet's field can participates in the RX hash */ - uint8_t rx_hash_function; /* Mask with enum ibv_rx_hash_function_flags to know which hash functions are supported */ -}; - -struct ibv_packet_pacing_caps { - uint32_t qp_rate_limit_min; /* Minimum rate limit in kbps */ - uint32_t qp_rate_limit_max; /* Maximum rate limit in kbps */ - uint32_t supported_qpts; /* Bitmap showing which QP types are supported. */ -}; - -enum ibv_raw_packet_caps { -.in +8 -IBV_RAW_PACKET_CAP_CVLAN_STRIPPING = 1 << 0, /* CVLAN stripping is supported */ -IBV_RAW_PACKET_CAP_SCATTER_FCS = 1 << 1, /* FCS scattering is supported */ -IBV_RAW_PACKET_CAP_IP_CSUM = 1 << 2, /* IP CSUM offload is supported */ -.in -8 -}; - -.fi -.SH "RETURN VALUE" -.B ibv_query_device_ex() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -The maximum values returned by this function are the upper limits of -supported resources by the device. However, it may not be possible to -use these maximum values, since the actual number of any resource that -can be created may be limited by the machine configuration, the amount -of host memory, user permissions, and the amount of resources already -in use by other users/processes. -.SH "SEE ALSO" -.BR ibv_query_device (3), -.BR ibv_open_device (3), -.BR ibv_query_port (3), -.BR ibv_query_pkey (3), -.BR ibv_query_gid (3) -.SH "AUTHORS" -.TP -Majd Dibbiny diff --git a/usr/rdma-core/libibverbs/man/ibv_query_gid.3 b/usr/rdma-core/libibverbs/man/ibv_query_gid.3 deleted file mode 100644 index 45e128bcd..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_query_gid.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_QUERY_GID 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_query_gid \- query an InfiniBand port's GID table -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_query_gid(struct ibv_context " "*context" ", uint8_t " "port_num" , -.BI " int " "index" ", union ibv_gid " "*gid" ); -.fi -.SH "DESCRIPTION" -.B ibv_query_gid() -returns the GID value in entry -.I index -of port -.I port_num -for device context -.I context -through the pointer -.I gid\fR. -.SH "RETURN VALUE" -.B ibv_query_gid() -returns 0 on success, and \-1 on error. -.SH "SEE ALSO" -.BR ibv_open_device (3), -.BR ibv_query_device (3), -.BR ibv_query_port (3), -.BR ibv_query_pkey (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_query_pkey.3 b/usr/rdma-core/libibverbs/man/ibv_query_pkey.3 deleted file mode 100644 index 3af40443b..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_query_pkey.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_QUERY_PKEY 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_query_pkey \- query an InfiniBand port's P_Key table -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_query_pkey(struct ibv_context " "*context" ", uint8_t " "port_num" , -.BI " int " "index" ", uint16_t " "*pkey" "); -.fi -.SH "DESCRIPTION" -.B ibv_query_pkey() -returns the P_Key value (in network byte order) in entry -.I index -of port -.I port_num -for device context -.I context -through the pointer -.I pkey\fR. -.SH "RETURN VALUE" -.B ibv_query_pkey() -returns 0 on success, and \-1 on error. -.SH "SEE ALSO" -.BR ibv_open_device (3), -.BR ibv_query_device (3), -.BR ibv_query_port (3), -.BR ibv_query_gid (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_query_port.3 b/usr/rdma-core/libibverbs/man/ibv_query_port.3 deleted file mode 100644 index 6e480d6c1..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_query_port.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_QUERY_PORT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_query_port \- query an RDMA port's attributes -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_query_port(struct ibv_context " "*context" ", uint8_t " "port_num" , -.BI " struct ibv_port_attr " "*port_attr" "); -.fi -.SH "DESCRIPTION" -.B ibv_query_port() -returns the attributes of port -.I port_num -for device context -.I context -through the pointer -.I port_attr\fR. -The argument -.I port_attr -is an ibv_port_attr struct, as defined in . -.PP -.nf -struct ibv_port_attr { -.in +8 -enum ibv_port_state state; /* Logical port state */ -enum ibv_mtu max_mtu; /* Max MTU supported by port */ -enum ibv_mtu active_mtu; /* Actual MTU */ -int gid_tbl_len; /* Length of source GID table */ -uint32_t port_cap_flags; /* Port capabilities */ -uint32_t max_msg_sz; /* Maximum message size */ -uint32_t bad_pkey_cntr; /* Bad P_Key counter */ -uint32_t qkey_viol_cntr; /* Q_Key violation counter */ -uint16_t pkey_tbl_len; /* Length of partition table */ -uint16_t lid; /* Base port LID */ -uint16_t sm_lid; /* SM LID */ -uint8_t lmc; /* LMC of LID */ -uint8_t max_vl_num; /* Maximum number of VLs */ -uint8_t sm_sl; /* SM service level */ -uint8_t subnet_timeout; /* Subnet propagation delay */ -uint8_t init_type_reply;/* Type of initialization performed by SM */ -uint8_t active_width; /* Currently active link width */ -uint8_t active_speed; /* Currently active link speed */ -uint8_t phys_state; /* Physical port state */ -uint8_t link_layer; /* link layer protocol of the port */ -.in -8 -}; -.sp -possible values for the link layer field are IBV_LINK_LAYER_INFINIBAND, -IBV_LINK_LAYER_ETHERNET, or IBV_LINK_LAYER_UNSPECIFIED. -.sp -.fi -.SH "RETURN VALUE" -.B ibv_query_port() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "SEE ALSO" -.BR ibv_create_qp (3), -.BR ibv_destroy_qp (3), -.BR ibv_query_qp (3), -.BR ibv_create_ah (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_query_qp.3 b/usr/rdma-core/libibverbs/man/ibv_query_qp.3 deleted file mode 100644 index 907bc56a5..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_query_qp.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_QUERY_QP 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_query_qp \- get the attributes of a queue pair (QP) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_query_qp(struct ibv_qp " "*qp" ", struct ibv_qp_attr " "*attr" , -.BI " int " "attr_mask" , -.BI " struct ibv_qp_init_attr " "*init_attr" ); -.fi -.SH "DESCRIPTION" -.B ibv_query_qp() -gets the attributes specified in -.I attr_mask -for the QP -.I qp -and returns them through the pointers -.I attr -and -.I init_attr\fR. -The argument -.I attr -is an ibv_qp_attr struct, as defined in . -.PP -.nf -struct ibv_qp_attr { -.in +8 -enum ibv_qp_state qp_state; /* Current QP state */ -enum ibv_qp_state cur_qp_state; /* Current QP state - irrelevant for ibv_query_qp */ -enum ibv_mtu path_mtu; /* Path MTU (valid only for RC/UC QPs) */ -enum ibv_mig_state path_mig_state; /* Path migration state (valid if HCA supports APM) */ -uint32_t qkey; /* Q_Key of the QP (valid only for UD QPs) */ -uint32_t rq_psn; /* PSN for receive queue (valid only for RC/UC QPs) */ -uint32_t sq_psn; /* PSN for send queue (valid only for RC/UC QPs) */ -uint32_t dest_qp_num; /* Destination QP number (valid only for RC/UC QPs) */ -int qp_access_flags; /* Mask of enabled remote access operations (valid only for RC/UC QPs) */ -struct ibv_qp_cap cap; /* QP capabilities */ -struct ibv_ah_attr ah_attr; /* Primary path address vector (valid only for RC/UC QPs) */ -struct ibv_ah_attr alt_ah_attr; /* Alternate path address vector (valid only for RC/UC QPs) */ -uint16_t pkey_index; /* Primary P_Key index */ -uint16_t alt_pkey_index; /* Alternate P_Key index */ -uint8_t en_sqd_async_notify; /* Enable SQD.drained async notification - irrelevant for ibv_query_qp */ -uint8_t sq_draining; /* Is the QP draining? (Valid only if qp_state is SQD) */ -uint8_t max_rd_atomic; /* Number of outstanding RDMA reads & atomic operations on the destination QP (valid only for RC QPs) */ -uint8_t max_dest_rd_atomic; /* Number of responder resources for handling incoming RDMA reads & atomic operations (valid only for RC QPs) */ -uint8_t min_rnr_timer; /* Minimum RNR NAK timer (valid only for RC QPs) */ -uint8_t port_num; /* Primary port number */ -uint8_t timeout; /* Local ack timeout for primary path (valid only for RC QPs) */ -uint8_t retry_cnt; /* Retry count (valid only for RC QPs) */ -uint8_t rnr_retry; /* RNR retry (valid only for RC QPs) */ -uint8_t alt_port_num; /* Alternate port number */ -uint8_t alt_timeout; /* Local ack timeout for alternate path (valid only for RC QPs) */ -.in -8 -}; -.fi -.PP -For details on struct ibv_qp_cap see the description of -.B ibv_create_qp()\fR. -For details on struct ibv_ah_attr see the description of -.B ibv_create_ah()\fR. -.SH "RETURN VALUE" -.B ibv_query_qp() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -The argument -.I attr_mask -is a hint that specifies the minimum list of attributes to retrieve. -Some RDMA devices may return extra attributes not requested, for -example if the value can be returned cheaply. This has the same -form as in -.B ibv_modify_qp()\fR. -.PP -Attribute values are valid if they have been set using -.B ibv_modify_qp()\fR. -The exact list of valid attributes depends on the QP state. -.PP -Multiple calls to -.B ibv_query_qp() -may yield some differences in the values returned for the following attributes: qp_state, path_mig_state, sq_draining, ah_attr (if APM is enabled). -.SH "SEE ALSO" -.BR ibv_create_qp (3), -.BR ibv_destroy_qp (3), -.BR ibv_modify_qp (3), -.BR ibv_create_ah (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_query_rt_values_ex.3 b/usr/rdma-core/libibverbs/man/ibv_query_rt_values_ex.3 deleted file mode 100644 index 8ff5b6634..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_query_rt_values_ex.3 +++ /dev/null @@ -1,51 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_QUERY_RT_VALUES_EX 3 2016-2-20 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_query_rt_values_ex \- query an RDMA device for some real time values -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_query_rt_values_ex(struct ibv_context " "*context", -.BI " struct ibv_values_ex " "*values" ); -.fi -.SH "DESCRIPTION" -.B ibv_query_rt_values_ex() -returns certain real time values of a device -.I context\fR. -The argument -.I attr -is a pointer to an ibv_device_attr_ex struct, as defined in . -.PP -.nf -struct ibv_values_ex { -.in +8 -uint32_t comp_mask; /* Compatibility mask that defines the query/queried fields [in/out] */ -struct timespec raw_clock; /* HW raw clock */ -.in -8 -}; - -enum ibv_values_mask { - IBV_VALUES_MASK_RAW_CLOCK = 1 << 0, /* HW raw clock */ -}; - -.fi -.SH "RETURN VALUE" -.B ibv_query_rt_values_ex() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -This extension verb only calls the provider, the provider has to query this value somehow and mark -the queried values in the comp_mask field. -.SH "SEE ALSO" -.BR ibv_query_device (3), -.BR ibv_open_device (3), -.BR ibv_query_port (3), -.BR ibv_query_pkey (3), -.BR ibv_query_gid (3) -.SH "AUTHORS" -.TP -Matan Barak -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_query_srq.3 b/usr/rdma-core/libibverbs/man/ibv_query_srq.3 deleted file mode 100644 index 8a35ce03d..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_query_srq.3 +++ /dev/null @@ -1,45 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_QUERY_SRQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_query_srq \- get the attributes of a shared receive queue (SRQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_query_srq(struct ibv_srq " "*srq" ", struct ibv_srq_attr " "*srq_attr" ); -.fi -.SH "DESCRIPTION" -.B ibv_query_srq() -gets the attributes of the SRQ -.I srq -and returns them through the pointer -.I srq_attr\fR. -The argument -.I srq_attr -is an ibv_srq_attr struct, as defined in . -.PP -.nf -struct ibv_srq_attr { -.in +8 -uint32_t max_wr; /* maximum number of outstanding work requests (WRs) in the SRQ */ -uint32_t max_sge; /* maximum number of scatter elements per WR */ -uint32_t srq_limit; /* the limit value of the SRQ */ -.in -8 -}; -.fi -.SH "RETURN VALUE" -.B ibv_query_srq() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -If the value returned for srq_limit is 0, then the SRQ limit reached -("low watermark") event is not (or no longer) armed, and no -asynchronous events will be generated until the event is rearmed. -.SH "SEE ALSO" -.BR ibv_create_srq (3), -.BR ibv_destroy_srq (3), -.BR ibv_modify_srq (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_rate_to_mbps.3 b/usr/rdma-core/libibverbs/man/ibv_rate_to_mbps.3 deleted file mode 100644 index 27e8724b5..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_rate_to_mbps.3 +++ /dev/null @@ -1,46 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_RATE_TO_MBPS 3 2012-03-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -.nf -ibv_rate_to_mbps \- convert IB rate enumeration to Mbit/sec -.sp -mbps_to_ibv_rate \- convert Mbit/sec to an IB rate enumeration -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_rate_to_mbps(enum ibv_rate " "rate" "); -.sp -.BI "enum ibv_rate mbps_to_ibv_rate(int " "mbps" "); -.fi -.SH "DESCRIPTION" -.B ibv_rate_to_mbps() -converts the IB transmission rate enumeration -.I rate -to a number of Mbit/sec. For example, if -.I rate -is -.BR IBV_RATE_5_GBPS\fR, -the value 5000 will be returned (5 Gbit/sec = 5000 Mbit/sec). -.PP -.B mbps_to_ibv_rate() -converts the number of Mbit/sec -.I mult -to an IB transmission rate enumeration. For example, if -.I mult -is 5000, the rate enumeration -.BR IBV_RATE_5_GBPS -will be returned. -.SH "RETURN VALUE" -.B ibv_rate_to_mbps() -returns the number of Mbit/sec. -.PP -.B mbps_to_ibv_rate() -returns the enumeration representing the IB transmission rate. -.SH "SEE ALSO" -.BR ibv_query_port (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_rate_to_mult.3 b/usr/rdma-core/libibverbs/man/ibv_rate_to_mult.3 deleted file mode 100644 index 6e2a59ddf..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_rate_to_mult.3 +++ /dev/null @@ -1,47 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_RATE_TO_MULT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -.nf -ibv_rate_to_mult \- convert IB rate enumeration to multiplier of 2.5 Gbit/sec -.sp -mult_to_ibv_rate \- convert multiplier of 2.5 Gbit/sec to an IB rate enumeration -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_rate_to_mult(enum ibv_rate " "rate" "); -.sp -.BI "enum ibv_rate mult_to_ibv_rate(int " "mult" "); -.fi -.SH "DESCRIPTION" -.B ibv_rate_to_mult() -converts the IB transmission rate enumeration -.I rate -to a multiple of 2.5 Gbit/sec (the base rate). For example, if -.I rate -is -.BR IBV_RATE_5_GBPS\fR, -the value 2 will be returned (5 Gbit/sec = 2 * 2.5 Gbit/sec). -.PP -.B mult_to_ibv_rate() -converts the multiplier value (of 2.5 Gbit/sec) -.I mult -to an IB transmission rate enumeration. For example, if -.I mult -is 2, the rate enumeration -.BR IBV_RATE_5_GBPS -will be returned. -.SH "RETURN VALUE" -.B -ibv_rate_to_mult() -returns the multiplier of the base rate 2.5 Gbit/sec. -.PP -.B mult_to_ibv_rate() -returns the enumeration representing the IB transmission rate. -.SH "SEE ALSO" -.BR ibv_query_port (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_rc_pingpong.1 b/usr/rdma-core/libibverbs/man/ibv_rc_pingpong.1 deleted file mode 100644 index 84200b38d..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_rc_pingpong.1 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_RC_PINGPONG 1 "August 30, 2005" "libibverbs" "USER COMMANDS" - -.SH NAME -ibv_rc_pingpong \- simple InfiniBand RC transport test - -.SH SYNOPSIS -.B ibv_rc_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size] -[\-r rx depth] [\-n iters] [\-l sl] [\-e] [\-g gid index] -[\-o] [\-t] \fBHOSTNAME\fR - -.B ibv_rc_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size] -[\-r rx depth] [\-n iters] [\-l sl] [\-e] [\-g gid index] -[\-o] [\-t] - -.SH DESCRIPTION -.PP -Run a simple ping-pong test over InfiniBand via the reliable -connected (RC) transport. - -.SH OPTIONS - -.PP -.TP -\fB\-p\fR, \fB\-\-port\fR=\fIPORT\fR -use TCP port \fIPORT\fR for initial synchronization (default 18515) -.TP -\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR -use IB device \fIDEVICE\fR (default first device found) -.TP -\fB\-i\fR, \fB\-\-ib\-port\fR=\fIPORT\fR -use IB port \fIPORT\fR (default port 1) -.TP -\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR -ping-pong messages of size \fISIZE\fR (default 4096) -.TP -\fB\-m\fR, \fB\-\-mtu\fR=\fISIZE\fR -path MTU \fISIZE\fR (default 1024) -.TP -\fB\-r\fR, \fB\-\-rx\-depth\fR=\fIDEPTH\fR -post \fIDEPTH\fR receives at a time (default 1000) -.TP -\fB\-n\fR, \fB\-\-iters\fR=\fIITERS\fR -perform \fIITERS\fR message exchanges (default 1000) -.TP -\fB\-l\fR, \fB\-\-sl\fR=\fISL\fR -use \fISL\fR as the service level value of the QP (default 0) -.TP -\fB\-e\fR, \fB\-\-events\fR -sleep while waiting for work completion events (default is to poll for -completions) -.TP -\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR -local port \fIGIDINDEX\fR -.TP -\fB\-o\fR, \fB\-\-odp\fR -use on demand paging -.TP -\fB\-t\fR, \fB\-\-ts\fR -get CQE with timestamp - -.SH SEE ALSO -.BR ibv_uc_pingpong (1), -.BR ibv_ud_pingpong (1), -.BR ibv_srq_pingpong (1), -.BR ibv_xsrq_pingpong (1) - -.SH AUTHORS -.TP -Roland Dreier -.RI < rolandd@cisco.com > - -.SH BUGS -The network synchronization between client and server instances is -weak, and does not prevent incompatible options from being used on the -two instances. The method used for retrieving work completions is not -strictly correct, and race conditions may cause failures on some -systems. diff --git a/usr/rdma-core/libibverbs/man/ibv_reg_mr.3 b/usr/rdma-core/libibverbs/man/ibv_reg_mr.3 deleted file mode 100644 index d3f09c0da..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_reg_mr.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_REG_MR 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_reg_mr, ibv_dereg_mr \- register or deregister a memory region (MR) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "struct ibv_mr *ibv_reg_mr(struct ibv_pd " "*pd" ", void " "*addr" , -.BI " size_t " "length" ", int " "access" ); -.sp -.BI "int ibv_dereg_mr(struct ibv_mr " "*mr" ); -.fi -.SH "DESCRIPTION" -.B ibv_reg_mr() -registers a memory region (MR) associated with the protection domain -.I pd\fR. -The MR's starting address is -.I addr -and its size is -.I length\fR. -The argument -.I access -describes the desired memory protection attributes; it is either 0 or the bitwise OR of one or more of the following flags: -.PP -.TP -.B IBV_ACCESS_LOCAL_WRITE \fR Enable Local Write Access -.TP -.B IBV_ACCESS_REMOTE_WRITE \fR Enable Remote Write Access -.TP -.B IBV_ACCESS_REMOTE_READ\fR Enable Remote Read Access -.TP -.B IBV_ACCESS_REMOTE_ATOMIC\fR Enable Remote Atomic Operation Access (if supported) -.TP -.B IBV_ACCESS_MW_BIND\fR Enable Memory Window Binding -.TP -.B IBV_ACCESS_ON_DEMAND\fR Create an on-demand paging MR -.PP -If -.B IBV_ACCESS_REMOTE_WRITE -or -.B IBV_ACCESS_REMOTE_ATOMIC -is set, then -.B IBV_ACCESS_LOCAL_WRITE -must be set too. -.PP -Local read access is always enabled for the MR. -.PP -.B ibv_dereg_mr() -deregisters the MR -.I mr\fR. -.SH "RETURN VALUE" -.B ibv_reg_mr() -returns a pointer to the registered MR, or NULL if the request fails. -The local key (\fBL_Key\fR) field -.B lkey -is used as the lkey field of struct ibv_sge when posting buffers with -ibv_post_* verbs, and the the remote key (\fBR_Key\fR) -field -.B rkey -is used by remote processes to perform Atomic and RDMA operations. The remote process places this -.B rkey -as the rkey field of struct ibv_send_wr passed to the ibv_post_send function. -.PP -.B ibv_dereg_mr() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_dereg_mr() -fails if any memory window is still bound to this MR. -.SH "SEE ALSO" -.BR ibv_alloc_pd (3), -.BR ibv_post_send (3), -.BR ibv_post_recv (3), -.BR ibv_post_srq_recv (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_req_notify_cq.3 b/usr/rdma-core/libibverbs/man/ibv_req_notify_cq.3 deleted file mode 100644 index 1d1d62130..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_req_notify_cq.3 +++ /dev/null @@ -1,44 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_REQ_NOTIFY_CQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_req_notify_cq \- request completion notification on a completion queue (CQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_req_notify_cq(struct ibv_cq " "*cq" ", int " "solicited_only" "); -.SH "DESCRIPTION" -.B ibv_req_notify_cq() -requests a completion notification on the completion queue (CQ) -.I cq\fR. -.PP -Upon the addition of a new CQ entry (CQE) to -.I cq\fR, -a completion event will be added to the completion channel associated -with the CQ. -If the argument -.I solicited_only -is zero, a completion event is generated for any new CQE. If -.I solicited_only -is non\-zero, an event is only generated for a new CQE with that is -considered "solicited." A CQE is solicited if it is a receive -completion for a message with the Solicited Event header bit set, or -if the status is not successful. All other successful receive -completions, or any successful send completion is unsolicited. -.SH "RETURN VALUE" -.B -ibv_req_notify_cq() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -The request for notification is "one shot." Only one completion event -will be generated for each call to -.B ibv_req_notify_cq()\fR. -.SH "SEE ALSO" -.BR ibv_create_comp_channel (3), -.BR ibv_create_cq (3), -.BR ibv_get_cq_event (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_rereg_mr.3 b/usr/rdma-core/libibverbs/man/ibv_rereg_mr.3 deleted file mode 100644 index 9fa567c2a..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_rereg_mr.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_REREG_MR 3 2016-03-13 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_rereg_mr \- re-register a memory region (MR) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_rereg_mr(struct ibv_mr " "*mr" ", int " " flags" , -.BI " struct ibv_pd * " "pd" ", void " " *addr", -.BI " size_t " " length" ", int " " access"); -.fi -.fi -.SH "DESCRIPTION" -.B ibv_rereg_mr() -Modifies the attributes of an existing memory region (MR) -.I mr\fR. -Conceptually, this call performs the functions deregister memory region -followed by register memory region. Where possible, -resources are reused instead of deallocated and reallocated. -.PP -.I flags\fR -is a bit-mask used to indicate which of the following properties of the memory region are being modified. Flags should be a combination (bit field) of: -.PP -.TP -.B IBV_REREG_MR_CHANGE_TRANSLATION \fR Change translation (location and length) -.TP -.B IBV_REREG_MR_CHANGE_PD \fR Change protection domain -.TP -.B IBV_REREG_MR_CHANGE_ACCESS \fR Change access flags -.PP -When -.B IBV_REREG_MR_CHANGE_PD -is used, -.I pd\fR -represents the new PD this MR should be registered to. -.br -When -.B IBV_REREG_MR_CHANGE_TRANSLATION -is used, -.I addr\fR. -represents the virtual address (user-space pointer) of the new MR, while -.I length\fR -represents its length. -.PP -The access and other flags are represented in the field -.I access\fR. -This field describes the desired memory protection attributes; it is either 0 or the bitwise OR of one or more of ibv_access_flags. -.TP -.SH "RETURN VALUE" -.B ibv_rereg_mr() -returns 0 on success, otherwise an error has occurred, -.I enum ibv_rereg_mr_err_code\fR -represents the error as of below. -.br -IBV_REREG_MR_ERR_INPUT - Old MR is valid, an input error was detected by libibverbs. -.br -IBV_REREG_MR_ERR_DONT_FORK_NEW - Old MR is valid, failed via don't fork on new address range. -.br -IBV_REREG_MR_ERR_DO_FORK_OLD - New MR is valid, failed via do fork on old address range. -.br -IBV_REREG_MR_ERR_CMD - MR shouldn't be used, command error. -.br -IBV_REREG_MR_ERR_CMD_AND_DO_FORK_NEW - MR shouldn't be used, command error, invalid fork state on new address range. - -.SH "NOTES" -Even on a failure, the user still needs to call ibv_dereg_mr on this MR. -.SH "SEE ALSO" -.BR ibv_reg_mr (3), -.BR ibv_dereg_mr (3), -.SH "AUTHORS" -.TP -Matan Barak -.TP -Yishai Hadas diff --git a/usr/rdma-core/libibverbs/man/ibv_resize_cq.3 b/usr/rdma-core/libibverbs/man/ibv_resize_cq.3 deleted file mode 100644 index b15950103..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_resize_cq.3 +++ /dev/null @@ -1,43 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.\" -.TH IBV_RESIZE_CQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual" -.SH "NAME" -ibv_resize_cq \- resize a completion queue (CQ) -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int ibv_resize_cq(struct ibv_cq " "*cq" ", int " "cqe" "); -.fi -.SH "DESCRIPTION" -.B ibv_resize_cq() -resizes the completion queue (CQ) -.I cq -to have at least -.I cqe -entries. -.I cqe -must be at least the number of unpolled entries in the CQ -.I cq\fR. -If -.I cqe -is a valid value less than the current CQ size, -.B ibv_resize_cq() -may not do anything, since this function is only guaranteed to resize -the CQ to a size at least as big as the requested size. -.SH "RETURN VALUE" -.B ibv_resize_cq() -returns 0 on success, or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" -.B ibv_resize_cq() -may assign a CQ size greater than or equal to the requested size. -The cqe member of -.I cq -will be updated to the actual size. -.SH "SEE ALSO" -.BR ibv_create_cq (3) -.BR ibv_destroy_cq (3) -.SH "AUTHORS" -.TP -Dotan Barak diff --git a/usr/rdma-core/libibverbs/man/ibv_srq_pingpong.1 b/usr/rdma-core/libibverbs/man/ibv_srq_pingpong.1 deleted file mode 100644 index b3fd00e18..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_srq_pingpong.1 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_SRQ_PINGPONG 1 "August 30, 2005" "libibverbs" "USER COMMANDS" - -.SH NAME -ibv_srq_pingpong \- simple InfiniBand shared receive queue test - -.SH SYNOPSIS -.B ibv_srq_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size] -[\-q num QPs] [\-r rx depth] [\-n iters] [\-l sl] [\-e] -[\-g gid index] \fBHOSTNAME\fR - -.B ibv_srq_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size] -[\-q num QPs] [\-r rx depth] [\-n iters] [\-l sl] [\-e] -[\-g gid index] - -.SH DESCRIPTION -.PP -Run a simple ping-pong test over InfiniBand via the reliable -connected (RC) transport, using multiple queue pairs (QPs) and a -single shared receive queue (SRQ). - -.SH OPTIONS - -.PP -.TP -\fB\-p\fR, \fB\-\-port\fR=\fIPORT\fR -use TCP port \fIPORT\fR for initial synchronization (default 18515) -.TP -\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR -use IB device \fIDEVICE\fR (default first device found) -.TP -\fB\-i\fR, \fB\-\-ib\-port\fR=\fIPORT\fR -use IB port \fIPORT\fR (default port 1) -.TP -\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR -ping-pong messages of size \fISIZE\fR (default 4096) -.TP -\fB\-m\fR, \fB\-\-mtu\fR=\fISIZE\fR -path MTU \fISIZE\fR (default 1024) -.TP -\fB\-q\fR, \fB\-\-num\-qp\fR=\fINUM\fR -use \fINUM\fR queue pairs for test (default 16) -.TP -\fB\-r\fR, \fB\-\-rx\-depth\fR=\fIDEPTH\fR -post \fIDEPTH\fR receives at a time (default 1000) -.TP -\fB\-n\fR, \fB\-\-iters\fR=\fIITERS\fR -perform \fIITERS\fR message exchanges (default 1000) -.TP -\fB\-l\fR, \fB\-\-sl\fR=\fISL\fR -use \fISL\fR as the service level value of the QPs (default 0) -.TP -\fB\-e\fR, \fB\-\-events\fR -sleep while waiting for work completion events (default is to poll for -completions) -.TP -\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR -local port \fIGIDINDEX\fR - -.SH SEE ALSO -.BR ibv_rc_pingpong (1), -.BR ibv_uc_pingpong (1), -.BR ibv_ud_pingpong (1), -.BR ibv_xsrq_pingpong (1) - -.SH AUTHORS -.TP -Roland Dreier -.RI < rolandd@cisco.com > - -.SH BUGS -The network synchronization between client and server instances is -weak, and does not prevent incompatible options from being used on the -two instances. The method used for retrieving work completions is not -strictly correct, and race conditions may cause failures on some -systems. diff --git a/usr/rdma-core/libibverbs/man/ibv_uc_pingpong.1 b/usr/rdma-core/libibverbs/man/ibv_uc_pingpong.1 deleted file mode 100644 index a90063f7e..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_uc_pingpong.1 +++ /dev/null @@ -1,73 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_UC_PINGPONG 1 "August 30, 2005" "libibverbs" "USER COMMANDS" - -.SH NAME -ibv_uc_pingpong \- simple InfiniBand UC transport test - -.SH SYNOPSIS -.B ibv_uc_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size] -[\-r rx depth] [\-n iters] [\-l sl] [\-e] [\-g gid index] -\fBHOSTNAME\fR - -.B ibv_uc_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size] -[\-r rx depth] [\-n iters] [\-l sl] [\-e] [\-g gid index] - -.SH DESCRIPTION -.PP -Run a simple ping-pong test over InfiniBand via the reliable -connected (RC) transport. - -.SH OPTIONS - -.PP -.TP -\fB\-p\fR, \fB\-\-port\fR=\fIPORT\fR -use TCP port \fIPORT\fR for initial synchronization (default 18515) -.TP -\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR -use IB device \fIDEVICE\fR (default first device found) -.TP -\fB\-i\fR, \fB\-\-ib\-port\fR=\fIPORT\fR -use IB port \fIPORT\fR (default port 1) -.TP -\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR -ping-pong messages of size \fISIZE\fR (default 4096) -.TP -\fB\-m\fR, \fB\-\-mtu\fR=\fISIZE\fR -path MTU \fISIZE\fR (default 1024) -.TP -\fB\-r\fR, \fB\-\-rx\-depth\fR=\fIDEPTH\fR -post \fIDEPTH\fR receives at a time (default 1000) -.TP -\fB\-n\fR, \fB\-\-iters\fR=\fIITERS\fR -perform \fIITERS\fR message exchanges (default 1000) -.TP -\fB\-l\fR, \fB\-\-sl\fR=\fISL\fR -use \fISL\fR as the service level value of the QP (default 0) -.TP -\fB\-e\fR, \fB\-\-events\fR -sleep while waiting for work completion events (default is to poll for -completions) -.TP -\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR -local port \fIGIDINDEX\fR - -.SH SEE ALSO -.BR ibv_rc_pingpong (1), -.BR ibv_ud_pingpong (1), -.BR ibv_srq_pingpong (1), -.BR ibv_xsrq_pingpong (1) - -.SH AUTHORS -.TP -Roland Dreier -.RI < rolandd@cisco.com > - -.SH BUGS -The network synchronization between client and server instances is -weak, and does not prevent incompatible options from being used on the -two instances. The method used for retrieving work completions is not -strictly correct, and race conditions may cause failures on some -systems. diff --git a/usr/rdma-core/libibverbs/man/ibv_ud_pingpong.1 b/usr/rdma-core/libibverbs/man/ibv_ud_pingpong.1 deleted file mode 100644 index fc71ee6fa..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_ud_pingpong.1 +++ /dev/null @@ -1,69 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_UD_PINGPONG 1 "August 30, 2005" "libibverbs" "USER COMMANDS" - -.SH NAME -ibv_ud_pingpong \- simple InfiniBand UD transport test - -.SH SYNOPSIS -.B ibv_ud_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-r rx depth] -[\-n iters] [\-l sl] [\-e] [\-g gid index] \fBHOSTNAME\fR - -.B ibv_ud_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-r rx depth] -[\-n iters] [\-l sl] [\-e] [\-g gid index] - -.SH DESCRIPTION -.PP -Run a simple ping-pong test over InfiniBand via the unreliable -datagram (UD) transport. - -.SH OPTIONS - -.PP -.TP -\fB\-p\fR, \fB\-\-port\fR=\fIPORT\fR -use TCP port \fIPORT\fR for initial synchronization (default 18515) -.TP -\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR -use IB device \fIDEVICE\fR (default first device found) -.TP -\fB\-i\fR, \fB\-\-ib\-port\fR=\fIPORT\fR -use IB port \fIPORT\fR (default port 1) -.TP -\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR -ping-pong messages of size \fISIZE\fR (default 2048) -.TP -\fB\-r\fR, \fB\-\-rx\-depth\fR=\fIDEPTH\fR -post \fIDEPTH\fR receives at a time (default 500) -.TP -\fB\-n\fR, \fB\-\-iters\fR=\fIITERS\fR -perform \fIITERS\fR message exchanges (default 1000) -.TP -\fB\-l\fR, \fB\-\-sl\fR=\fISL\fR -send messages with service level \fISL\fR (default 0) -.TP -\fB\-e\fR, \fB\-\-events\fR -sleep while waiting for work completion events (default is to poll for -completions) -.TP -\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR -local port \fIGIDINDEX\fR - -.SH SEE ALSO -.BR ibv_rc_pingpong (1), -.BR ibv_uc_pingpong (1), -.BR ibv_srq_pingpong (1), -.BR ibv_xsrq_pingpong (1) - -.SH AUTHORS -.TP -Roland Dreier -.RI < rolandd@cisco.com > - -.SH BUGS -The network synchronization between client and server instances is -weak, and does not prevent incompatible options from being used on the -two instances. The method used for retrieving work completions is not -strictly correct, and race conditions may cause failures on some -systems. diff --git a/usr/rdma-core/libibverbs/man/ibv_xsrq_pingpong.1 b/usr/rdma-core/libibverbs/man/ibv_xsrq_pingpong.1 deleted file mode 100644 index b225d9b31..000000000 --- a/usr/rdma-core/libibverbs/man/ibv_xsrq_pingpong.1 +++ /dev/null @@ -1,75 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBV_XSRQ_PINGPONG 1 "May 24, 2016" "libibverbs" "USER COMMANDS" - -.SH NAME -ibv_xsrq_pingpong \- simple InfiniBand shared receive queue test - -.SH SYNOPSIS -.B ibv_xsrq_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m mtu] [\-c clients] -[\-n num_tests] [\-l sl] [\-e] [\-g gid index] \fBHOSTNAME\fR - -.B ibv_xsrq_pingpong -[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m mtu] [\-c clients] -[\-n num_tests] [\-l sl] [\-e] [\-g gid index] - -.SH DESCRIPTION -.PP -Run a simple ping-pong test over InfiniBand via the extended reliable -connected (XRC) transport service, using a shared receive queue (SRQ). - -.SH OPTIONS - -.PP -.TP -\fB\-p\fR, \fB\-\-port\fR=\fIPORT\fR -use TCP port \fIPORT\fR for initial synchronization (default 18515) -.TP -\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR -use IB device \fIDEVICE\fR (default first device found) -.TP -\fB\-i\fR, \fB\-\-ib\-port\fR=\fIPORT\fR -use IB port \fIPORT\fR (default port 1) -.TP -\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR -ping-pong messages of size \fISIZE\fR (default 4096) -.TP -\fB\-m\fR, \fB\-\-mtu\fR=\fIMTU\fR -use path mtu of size \fIMTU\fR (default 2048) -.TP -\fB\-c\fR, \fB\-\-clients\fR=\fICLIENTS\fR -number of clients \fICLIENTS\fR (on server only, default 1) -.TP -\fB\-n\fR, \fB\-\-num\-tests\fR=\fINUM_TESTS\fR -perform \fINUM_TESTS\fR tests per client (default 5) -.TP -\fB\-l\fR, \fB\-\-sl\fR=\fISL\fR -use \fISL\fR as the service level value (default 0) -.TP -\fB\-e\fR, \fB\-\-events\fR -sleep while waiting for work completion events (default is to poll for -completions) -.TP -\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR -local port \fIGIDINDEX\fR - -.SH SEE ALSO -.BR ibv_rc_pingpong (1), -.BR ibv_uc_pingpong (1), -.BR ibv_ud_pingpong (1) -.BR ibv_srq_pingpong (1) - -.SH AUTHORS -.TP -Roland Dreier -.RI < roland@purestorage.com > -.TP -Jarod Wilson -.RI < jarod@redhat.com > - -.SH BUGS -The network synchronization between client and server instances is -weak, and does not prevent incompatible options from being used on the -two instances. The method used for retrieving work completions is not -strictly correct, and race conditions may cause failures on some -systems. diff --git a/usr/rdma-core/libibverbs/marshall.c b/usr/rdma-core/libibverbs/marshall.c deleted file mode 100644 index 5b0260832..000000000 --- a/usr/rdma-core/libibverbs/marshall.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2005 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include - -#include - -void ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst, - struct ibv_kern_ah_attr *src) -{ - memcpy(dst->grh.dgid.raw, src->grh.dgid, sizeof dst->grh.dgid); - dst->grh.flow_label = src->grh.flow_label; - dst->grh.sgid_index = src->grh.sgid_index; - dst->grh.hop_limit = src->grh.hop_limit; - dst->grh.traffic_class = src->grh.traffic_class; - - dst->dlid = src->dlid; - dst->sl = src->sl; - dst->src_path_bits = src->src_path_bits; - dst->static_rate = src->static_rate; - dst->is_global = src->is_global; - dst->port_num = src->port_num; -} - -void ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst, - struct ibv_kern_qp_attr *src) -{ - dst->cur_qp_state = src->cur_qp_state; - dst->path_mtu = src->path_mtu; - dst->path_mig_state = src->path_mig_state; - dst->qkey = src->qkey; - dst->rq_psn = src->rq_psn; - dst->sq_psn = src->sq_psn; - dst->dest_qp_num = src->dest_qp_num; - dst->qp_access_flags = src->qp_access_flags; - - dst->cap.max_send_wr = src->max_send_wr; - dst->cap.max_recv_wr = src->max_recv_wr; - dst->cap.max_send_sge = src->max_send_sge; - dst->cap.max_recv_sge = src->max_recv_sge; - dst->cap.max_inline_data = src->max_inline_data; - - ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr); - ibv_copy_ah_attr_from_kern(&dst->alt_ah_attr, &src->alt_ah_attr); - - dst->pkey_index = src->pkey_index; - dst->alt_pkey_index = src->alt_pkey_index; - dst->en_sqd_async_notify = src->en_sqd_async_notify; - dst->sq_draining = src->sq_draining; - dst->max_rd_atomic = src->max_rd_atomic; - dst->max_dest_rd_atomic = src->max_dest_rd_atomic; - dst->min_rnr_timer = src->min_rnr_timer; - dst->port_num = src->port_num; - dst->timeout = src->timeout; - dst->retry_cnt = src->retry_cnt; - dst->rnr_retry = src->rnr_retry; - dst->alt_port_num = src->alt_port_num; - dst->alt_timeout = src->alt_timeout; -} - -void ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst, - struct ib_user_path_rec *src) -{ - memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid); - memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid); - - dst->dlid = src->dlid; - dst->slid = src->slid; - dst->raw_traffic = src->raw_traffic; - dst->flow_label = src->flow_label; - dst->hop_limit = src->hop_limit; - dst->traffic_class = src->traffic_class; - dst->reversible = src->reversible; - dst->numb_path = src->numb_path; - dst->pkey = src->pkey; - dst->sl = src->sl; - dst->mtu_selector = src->mtu_selector; - dst->mtu = src->mtu; - dst->rate_selector = src->rate_selector; - dst->rate = src->rate; - dst->packet_life_time = src->packet_life_time; - dst->preference = src->preference; - dst->packet_life_time_selector = src->packet_life_time_selector; -} - -void ibv_copy_path_rec_to_kern(struct ib_user_path_rec *dst, - struct ibv_sa_path_rec *src) -{ - memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid); - memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid); - - dst->dlid = src->dlid; - dst->slid = src->slid; - dst->raw_traffic = src->raw_traffic; - dst->flow_label = src->flow_label; - dst->hop_limit = src->hop_limit; - dst->traffic_class = src->traffic_class; - dst->reversible = src->reversible; - dst->numb_path = src->numb_path; - dst->pkey = src->pkey; - dst->sl = src->sl; - dst->mtu_selector = src->mtu_selector; - dst->mtu = src->mtu; - dst->rate_selector = src->rate_selector; - dst->rate = src->rate; - dst->packet_life_time = src->packet_life_time; - dst->preference = src->preference; - dst->packet_life_time_selector = src->packet_life_time_selector; -} diff --git a/usr/rdma-core/libibverbs/marshall.h b/usr/rdma-core/libibverbs/marshall.h deleted file mode 100644 index 1dab1114a..000000000 --- a/usr/rdma-core/libibverbs/marshall.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2005 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef INFINIBAND_MARSHALL_H -#define INFINIBAND_MARSHALL_H - -#include -#include -#include -#include - -#ifdef __cplusplus -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } -#else /* !__cplusplus */ -# define BEGIN_C_DECLS -# define END_C_DECLS -#endif /* __cplusplus */ - -BEGIN_C_DECLS - -void ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst, - struct ibv_kern_qp_attr *src); - -void ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst, - struct ibv_kern_ah_attr *src); - -void ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst, - struct ib_user_path_rec *src); - -void ibv_copy_path_rec_to_kern(struct ib_user_path_rec *dst, - struct ibv_sa_path_rec *src); - -END_C_DECLS - -#endif /* INFINIBAND_MARSHALL_H */ diff --git a/usr/rdma-core/libibverbs/memory.c b/usr/rdma-core/libibverbs/memory.c deleted file mode 100644 index 5c8255d47..000000000 --- a/usr/rdma-core/libibverbs/memory.c +++ /dev/null @@ -1,704 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ibverbs.h" - -struct ibv_mem_node { - enum { - IBV_RED, - IBV_BLACK - } color; - struct ibv_mem_node *parent; - struct ibv_mem_node *left, *right; - uintptr_t start, end; - int refcnt; -}; - -static struct ibv_mem_node *mm_root; -static pthread_mutex_t mm_mutex = PTHREAD_MUTEX_INITIALIZER; -static int page_size; -static int huge_page_enabled; -static int too_late; - -static unsigned long smaps_page_size(FILE *file) -{ - int n; - unsigned long size = page_size; - char buf[1024]; - - while (fgets(buf, sizeof(buf), file) != NULL) { - if (!strstr(buf, "KernelPageSize:")) - continue; - - n = sscanf(buf, "%*s %lu", &size); - if (n < 1) - continue; - - /* page size is printed in Kb */ - size = size * 1024; - - break; - } - - return size; -} - -static unsigned long get_page_size(void *base) -{ - unsigned long ret = page_size; - pid_t pid; - FILE *file; - char buf[1024]; - - pid = getpid(); - snprintf(buf, sizeof(buf), "/proc/%d/smaps", pid); - - file = fopen(buf, "r" STREAM_CLOEXEC); - if (!file) - goto out; - - while (fgets(buf, sizeof(buf), file) != NULL) { - int n; - uintptr_t range_start, range_end; - - n = sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, &range_start, &range_end); - - if (n < 2) - continue; - - if ((uintptr_t) base >= range_start && (uintptr_t) base < range_end) { - ret = smaps_page_size(file); - break; - } - } - - fclose(file); - -out: - return ret; -} - -int ibv_fork_init(void) -{ - void *tmp, *tmp_aligned; - int ret; - unsigned long size; - - if (getenv("RDMAV_HUGEPAGES_SAFE")) - huge_page_enabled = 1; - - if (mm_root) - return 0; - - if (too_late) - return EINVAL; - - page_size = sysconf(_SC_PAGESIZE); - if (page_size < 0) - return errno; - - if (posix_memalign(&tmp, page_size, page_size)) - return ENOMEM; - - if (huge_page_enabled) { - size = get_page_size(tmp); - tmp_aligned = (void *) ((uintptr_t) tmp & ~(size - 1)); - } else { - size = page_size; - tmp_aligned = tmp; - } - - ret = madvise(tmp_aligned, size, MADV_DONTFORK) || - madvise(tmp_aligned, size, MADV_DOFORK); - - free(tmp); - - if (ret) - return ENOSYS; - - mm_root = malloc(sizeof *mm_root); - if (!mm_root) - return ENOMEM; - - mm_root->parent = NULL; - mm_root->left = NULL; - mm_root->right = NULL; - mm_root->color = IBV_BLACK; - mm_root->start = 0; - mm_root->end = UINTPTR_MAX; - mm_root->refcnt = 0; - - return 0; -} - -static struct ibv_mem_node *__mm_prev(struct ibv_mem_node *node) -{ - if (node->left) { - node = node->left; - while (node->right) - node = node->right; - } else { - while (node->parent && node == node->parent->left) - node = node->parent; - - node = node->parent; - } - - return node; -} - -static struct ibv_mem_node *__mm_next(struct ibv_mem_node *node) -{ - if (node->right) { - node = node->right; - while (node->left) - node = node->left; - } else { - while (node->parent && node == node->parent->right) - node = node->parent; - - node = node->parent; - } - - return node; -} - -static void __mm_rotate_right(struct ibv_mem_node *node) -{ - struct ibv_mem_node *tmp; - - tmp = node->left; - - node->left = tmp->right; - if (node->left) - node->left->parent = node; - - if (node->parent) { - if (node->parent->right == node) - node->parent->right = tmp; - else - node->parent->left = tmp; - } else - mm_root = tmp; - - tmp->parent = node->parent; - - tmp->right = node; - node->parent = tmp; -} - -static void __mm_rotate_left(struct ibv_mem_node *node) -{ - struct ibv_mem_node *tmp; - - tmp = node->right; - - node->right = tmp->left; - if (node->right) - node->right->parent = node; - - if (node->parent) { - if (node->parent->right == node) - node->parent->right = tmp; - else - node->parent->left = tmp; - } else - mm_root = tmp; - - tmp->parent = node->parent; - - tmp->left = node; - node->parent = tmp; -} - -#if 0 -static int verify(struct ibv_mem_node *node) -{ - int hl, hr; - - if (!node) - return 1; - - hl = verify(node->left); - hr = verify(node->left); - - if (!hl || !hr) - return 0; - if (hl != hr) - return 0; - - if (node->color == IBV_RED) { - if (node->left && node->left->color != IBV_BLACK) - return 0; - if (node->right && node->right->color != IBV_BLACK) - return 0; - return hl; - } - - return hl + 1; -} -#endif - -static void __mm_add_rebalance(struct ibv_mem_node *node) -{ - struct ibv_mem_node *parent, *gp, *uncle; - - while (node->parent && node->parent->color == IBV_RED) { - parent = node->parent; - gp = node->parent->parent; - - if (parent == gp->left) { - uncle = gp->right; - - if (uncle && uncle->color == IBV_RED) { - parent->color = IBV_BLACK; - uncle->color = IBV_BLACK; - gp->color = IBV_RED; - - node = gp; - } else { - if (node == parent->right) { - __mm_rotate_left(parent); - node = parent; - parent = node->parent; - } - - parent->color = IBV_BLACK; - gp->color = IBV_RED; - - __mm_rotate_right(gp); - } - } else { - uncle = gp->left; - - if (uncle && uncle->color == IBV_RED) { - parent->color = IBV_BLACK; - uncle->color = IBV_BLACK; - gp->color = IBV_RED; - - node = gp; - } else { - if (node == parent->left) { - __mm_rotate_right(parent); - node = parent; - parent = node->parent; - } - - parent->color = IBV_BLACK; - gp->color = IBV_RED; - - __mm_rotate_left(gp); - } - } - } - - mm_root->color = IBV_BLACK; -} - -static void __mm_add(struct ibv_mem_node *new) -{ - struct ibv_mem_node *node, *parent = NULL; - - node = mm_root; - while (node) { - parent = node; - if (node->start < new->start) - node = node->right; - else - node = node->left; - } - - if (parent->start < new->start) - parent->right = new; - else - parent->left = new; - - new->parent = parent; - new->left = NULL; - new->right = NULL; - - new->color = IBV_RED; - __mm_add_rebalance(new); -} - -static void __mm_remove(struct ibv_mem_node *node) -{ - struct ibv_mem_node *child, *parent, *sib, *tmp; - int nodecol; - - if (node->left && node->right) { - tmp = node->left; - while (tmp->right) - tmp = tmp->right; - - nodecol = tmp->color; - child = tmp->left; - tmp->color = node->color; - - if (tmp->parent != node) { - parent = tmp->parent; - parent->right = tmp->left; - if (tmp->left) - tmp->left->parent = parent; - - tmp->left = node->left; - node->left->parent = tmp; - } else - parent = tmp; - - tmp->right = node->right; - node->right->parent = tmp; - - tmp->parent = node->parent; - if (node->parent) { - if (node->parent->left == node) - node->parent->left = tmp; - else - node->parent->right = tmp; - } else - mm_root = tmp; - } else { - nodecol = node->color; - - child = node->left ? node->left : node->right; - parent = node->parent; - - if (child) - child->parent = parent; - if (parent) { - if (parent->left == node) - parent->left = child; - else - parent->right = child; - } else - mm_root = child; - } - - free(node); - - if (nodecol == IBV_RED) - return; - - while ((!child || child->color == IBV_BLACK) && child != mm_root) { - if (parent->left == child) { - sib = parent->right; - - if (sib->color == IBV_RED) { - parent->color = IBV_RED; - sib->color = IBV_BLACK; - __mm_rotate_left(parent); - sib = parent->right; - } - - if ((!sib->left || sib->left->color == IBV_BLACK) && - (!sib->right || sib->right->color == IBV_BLACK)) { - sib->color = IBV_RED; - child = parent; - parent = child->parent; - } else { - if (!sib->right || sib->right->color == IBV_BLACK) { - if (sib->left) - sib->left->color = IBV_BLACK; - sib->color = IBV_RED; - __mm_rotate_right(sib); - sib = parent->right; - } - - sib->color = parent->color; - parent->color = IBV_BLACK; - if (sib->right) - sib->right->color = IBV_BLACK; - __mm_rotate_left(parent); - child = mm_root; - break; - } - } else { - sib = parent->left; - - if (sib->color == IBV_RED) { - parent->color = IBV_RED; - sib->color = IBV_BLACK; - __mm_rotate_right(parent); - sib = parent->left; - } - - if ((!sib->left || sib->left->color == IBV_BLACK) && - (!sib->right || sib->right->color == IBV_BLACK)) { - sib->color = IBV_RED; - child = parent; - parent = child->parent; - } else { - if (!sib->left || sib->left->color == IBV_BLACK) { - if (sib->right) - sib->right->color = IBV_BLACK; - sib->color = IBV_RED; - __mm_rotate_left(sib); - sib = parent->left; - } - - sib->color = parent->color; - parent->color = IBV_BLACK; - if (sib->left) - sib->left->color = IBV_BLACK; - __mm_rotate_right(parent); - child = mm_root; - break; - } - } - } - - if (child) - child->color = IBV_BLACK; -} - -static struct ibv_mem_node *__mm_find_start(uintptr_t start, uintptr_t end) -{ - struct ibv_mem_node *node = mm_root; - - while (node) { - if (node->start <= start && node->end >= start) - break; - - if (node->start < start) - node = node->right; - else - node = node->left; - } - - return node; -} - -static struct ibv_mem_node *merge_ranges(struct ibv_mem_node *node, - struct ibv_mem_node *prev) -{ - prev->end = node->end; - prev->refcnt = node->refcnt; - __mm_remove(node); - - return prev; -} - -static struct ibv_mem_node *split_range(struct ibv_mem_node *node, - uintptr_t cut_line) -{ - struct ibv_mem_node *new_node = NULL; - - new_node = malloc(sizeof *new_node); - if (!new_node) - return NULL; - new_node->start = cut_line; - new_node->end = node->end; - new_node->refcnt = node->refcnt; - node->end = cut_line - 1; - __mm_add(new_node); - - return new_node; -} - -static struct ibv_mem_node *get_start_node(uintptr_t start, uintptr_t end, - int inc) -{ - struct ibv_mem_node *node, *tmp = NULL; - - node = __mm_find_start(start, end); - if (node->start < start) - node = split_range(node, start); - else { - tmp = __mm_prev(node); - if (tmp && tmp->refcnt == node->refcnt + inc) - node = merge_ranges(node, tmp); - } - return node; -} - -/* - * This function is called if madvise() fails to undo merging/splitting - * operations performed on the node. - */ -static struct ibv_mem_node *undo_node(struct ibv_mem_node *node, - uintptr_t start, int inc) -{ - struct ibv_mem_node *tmp = NULL; - - /* - * This condition can be true only if we merged this - * node with the previous one, so we need to split them. - */ - if (start > node->start) { - tmp = split_range(node, start); - if (tmp) { - node->refcnt += inc; - node = tmp; - } else - return NULL; - } - - tmp = __mm_prev(node); - if (tmp && tmp->refcnt == node->refcnt) - node = merge_ranges(node, tmp); - - tmp = __mm_next(node); - if (tmp && tmp->refcnt == node->refcnt) - node = merge_ranges(tmp, node); - - return node; -} - -static int ibv_madvise_range(void *base, size_t size, int advice) -{ - uintptr_t start, end; - struct ibv_mem_node *node, *tmp; - int inc; - int rolling_back = 0; - int ret = 0; - unsigned long range_page_size; - - if (!size) - return 0; - - if (huge_page_enabled) - range_page_size = get_page_size(base); - else - range_page_size = page_size; - - start = (uintptr_t) base & ~(range_page_size - 1); - end = ((uintptr_t) (base + size + range_page_size - 1) & - ~(range_page_size - 1)) - 1; - - pthread_mutex_lock(&mm_mutex); -again: - inc = advice == MADV_DONTFORK ? 1 : -1; - - node = get_start_node(start, end, inc); - if (!node) { - ret = -1; - goto out; - } - - while (node && node->start <= end) { - if (node->end > end) { - if (!split_range(node, end + 1)) { - ret = -1; - goto out; - } - } - - if ((inc == -1 && node->refcnt == 1) || - (inc == 1 && node->refcnt == 0)) { - /* - * If this is the first time through the loop, - * and we merged this node with the previous - * one, then we only want to do the madvise() - * on start ... node->end (rather than - * starting at node->start). - * - * Otherwise we end up doing madvise() on - * bigger region than we're being asked to, - * and that may lead to a spurious failure. - */ - if (start > node->start) - ret = madvise((void *) start, node->end - start + 1, - advice); - else - ret = madvise((void *) node->start, - node->end - node->start + 1, - advice); - if (ret) { - node = undo_node(node, start, inc); - - if (rolling_back || !node) - goto out; - - /* madvise failed, roll back previous changes */ - rolling_back = 1; - advice = advice == MADV_DONTFORK ? - MADV_DOFORK : MADV_DONTFORK; - tmp = __mm_prev(node); - if (!tmp || start > tmp->end) - goto out; - end = tmp->end; - goto again; - } - } - - node->refcnt += inc; - node = __mm_next(node); - } - - if (node) { - tmp = __mm_prev(node); - if (tmp && node->refcnt == tmp->refcnt) - node = merge_ranges(node, tmp); - } - -out: - if (rolling_back) - ret = -1; - - pthread_mutex_unlock(&mm_mutex); - - return ret; -} - -int ibv_dontfork_range(void *base, size_t size) -{ - if (mm_root) - return ibv_madvise_range(base, size, MADV_DONTFORK); - else { - too_late = 1; - return 0; - } -} - -int ibv_dofork_range(void *base, size_t size) -{ - if (mm_root) - return ibv_madvise_range(base, size, MADV_DOFORK); - else { - too_late = 1; - return 0; - } -} diff --git a/usr/rdma-core/libibverbs/neigh.c b/usr/rdma-core/libibverbs/neigh.c deleted file mode 100644 index 3e9ee9261..000000000 --- a/usr/rdma-core/libibverbs/neigh.c +++ /dev/null @@ -1,848 +0,0 @@ -/* Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md - */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include - -#if HAVE_WORKING_IF_H -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#if !HAVE_WORKING_IF_H -/* We need this decl from net/if.h but old systems do not let use co-include - net/if.h and netlink/route/link.h */ -extern unsigned int if_nametoindex(__const char *__ifname) __THROW; -#endif - -/* for PFX */ -#include "ibverbs.h" -#include - -#include "neigh.h" - -#ifndef HAVE_LIBNL1 -#include -#endif - -static pthread_once_t device_neigh_alloc = PTHREAD_ONCE_INIT; -static struct nl_sock *zero_socket; - -union sktaddr { - struct sockaddr s; - struct sockaddr_in s4; - struct sockaddr_in6 s6; -}; - -struct skt { - union sktaddr sktaddr; - socklen_t len; -}; - -static int set_link_port(union sktaddr *s, __be16 port, int oif) -{ - switch (s->s.sa_family) { - case AF_INET: - s->s4.sin_port = port; - break; - case AF_INET6: - s->s6.sin6_port = port; - s->s6.sin6_scope_id = oif; - break; - default: - return -EINVAL; - } - - return 0; -} - -static bool cmp_address(const struct sockaddr *s1, - const struct sockaddr *s2) -{ - if (s1->sa_family != s2->sa_family) - return false; - - switch (s1->sa_family) { - case AF_INET: - return ((struct sockaddr_in *)s1)->sin_addr.s_addr == - ((struct sockaddr_in *)s2)->sin_addr.s_addr; - case AF_INET6: - return !memcmp( - ((struct sockaddr_in6 *)s1)->sin6_addr.s6_addr, - ((struct sockaddr_in6 *)s2)->sin6_addr.s6_addr, - sizeof(((struct sockaddr_in6 *)s1)->sin6_addr.s6_addr)); - default: - return false; - } -} - -static int get_ifindex(const struct sockaddr *s) -{ - struct ifaddrs *ifaddr, *ifa; - int name2index = -ENODEV; - - if (-1 == getifaddrs(&ifaddr)) - return errno; - - for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { - if (ifa->ifa_addr == NULL) - continue; - - if (cmp_address(ifa->ifa_addr, s)) { - name2index = if_nametoindex(ifa->ifa_name); - break; - } - } - - freeifaddrs(ifaddr); - - return name2index; -} - -static struct nl_addr *get_neigh_mac(struct get_neigh_handler *neigh_handler) -{ - struct rtnl_neigh *neigh; - struct nl_addr *ll_addr = NULL; - - /* future optimization - if link local address - parse address and - * return mac now instead of doing so after the routing CB. This - * is of course referred to GIDs */ - neigh = rtnl_neigh_get(neigh_handler->neigh_cache, - neigh_handler->oif, - neigh_handler->dst); - if (neigh == NULL) - return NULL; - - ll_addr = rtnl_neigh_get_lladdr(neigh); - if (NULL != ll_addr) - ll_addr = nl_addr_clone(ll_addr); - - rtnl_neigh_put(neigh); - return ll_addr; -} - -static void get_neigh_cb_event(struct nl_object *obj, void *arg) -{ - struct get_neigh_handler *neigh_handler = - (struct get_neigh_handler *)arg; - /* assumed serilized callback (no parallel execution of function) */ - if (nl_object_match_filter( - obj, - (struct nl_object *)neigh_handler->filter_neigh)) { - struct rtnl_neigh *neigh = (struct rtnl_neigh *)obj; - /* check that we didn't set it already */ - if (neigh_handler->found_ll_addr == NULL) { - if (rtnl_neigh_get_lladdr(neigh) == NULL) - return; - - neigh_handler->found_ll_addr = - nl_addr_clone(rtnl_neigh_get_lladdr(neigh)); - } - } -} - -static int get_neigh_cb(struct nl_msg *msg, void *arg) -{ - struct get_neigh_handler *neigh_handler = - (struct get_neigh_handler *)arg; - - if (nl_msg_parse(msg, &get_neigh_cb_event, neigh_handler) < 0) - errno = ENOMSG; - - return NL_OK; -} - -static void set_neigh_filter(struct get_neigh_handler *neigh_handler, - struct rtnl_neigh *filter) { - neigh_handler->filter_neigh = filter; -} - -static struct rtnl_neigh *create_filter_neigh_for_dst(struct nl_addr *dst_addr, - int oif) -{ - struct rtnl_neigh *filter_neigh; - - filter_neigh = rtnl_neigh_alloc(); - if (filter_neigh == NULL) - return NULL; - - rtnl_neigh_set_ifindex(filter_neigh, oif); - rtnl_neigh_set_dst(filter_neigh, dst_addr); - - return filter_neigh; -} - -#define PORT_DISCARD htobe16(9) -#define SEND_PAYLOAD "H" - -static int create_socket(struct get_neigh_handler *neigh_handler, - struct skt *addr_dst, int *psock_fd) -{ - int err; - struct skt addr_src; - int sock_fd; - - memset(addr_dst, 0, sizeof(*addr_dst)); - memset(&addr_src, 0, sizeof(addr_src)); - addr_src.len = sizeof(addr_src.sktaddr); - - err = nl_addr_fill_sockaddr(neigh_handler->src, - &addr_src.sktaddr.s, - &addr_src.len); - if (err) { - errno = EADDRNOTAVAIL; - return -1; - } - - addr_dst->len = sizeof(addr_dst->sktaddr); - err = nl_addr_fill_sockaddr(neigh_handler->dst, - &addr_dst->sktaddr.s, - &addr_dst->len); - if (err) { - errno = EADDRNOTAVAIL; - return -1; - } - - err = set_link_port(&addr_dst->sktaddr, PORT_DISCARD, - neigh_handler->oif); - if (err) - return -1; - - sock_fd = socket(addr_dst->sktaddr.s.sa_family, - SOCK_DGRAM | SOCK_CLOEXEC, 0); - if (sock_fd == -1) - return -1; - err = bind(sock_fd, &addr_src.sktaddr.s, addr_src.len); - if (err) { - close(sock_fd); - return -1; - } - - *psock_fd = sock_fd; - - return 0; -} - -#define NUM_OF_RETRIES 10 -#define NUM_OF_TRIES ((NUM_OF_RETRIES) + 1) -#if NUM_OF_TRIES < 1 -#error "neigh: invalid value of NUM_OF_RETRIES" -#endif -static int create_timer(struct get_neigh_handler *neigh_handler) -{ - int user_timeout = neigh_handler->timeout/NUM_OF_TRIES; - struct timespec timeout = { - .tv_sec = user_timeout / 1000, - .tv_nsec = (user_timeout % 1000) * 1000000 - }; - struct itimerspec timer_time = {.it_value = timeout}; - int timer_fd; - - timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC); - if (timer_fd == -1) - return timer_fd; - - if (neigh_handler->timeout) { - if (NUM_OF_TRIES <= 1) - bzero(&timer_time.it_interval, - sizeof(timer_time.it_interval)); - else - timer_time.it_interval = timeout; - if (timerfd_settime(timer_fd, 0, &timer_time, NULL)) { - close(timer_fd); - return -1; - } - } - - return timer_fd; -} - -#define UDP_SOCKET_MAX_SENDTO 100000ULL -static int try_send_to(int sock_fd, void *buff, size_t buf_size, - struct skt *addr_dst) -{ - uint64_t max_count = UDP_SOCKET_MAX_SENDTO; - int err; - - do { - err = sendto(sock_fd, buff, buf_size, 0, - &addr_dst->sktaddr.s, - addr_dst->len); - if (err > 0) - err = 0; - } while (-1 == err && EADDRNOTAVAIL == errno && --max_count); - - return err; -} - -static struct nl_addr *process_get_neigh_mac( - struct get_neigh_handler *neigh_handler) -{ - int err; - struct nl_addr *ll_addr = get_neigh_mac(neigh_handler); - struct rtnl_neigh *neigh_filter; - fd_set fdset; - int sock_fd; - int fd; - int nfds; - int timer_fd; - int ret; - struct skt addr_dst; - char buff[sizeof(SEND_PAYLOAD)] = SEND_PAYLOAD; - int retries = 0; - - if (NULL != ll_addr) - return ll_addr; - - err = nl_socket_add_membership(neigh_handler->sock, - RTNLGRP_NEIGH); - if (err < 0) - return NULL; - - neigh_filter = create_filter_neigh_for_dst(neigh_handler->dst, - neigh_handler->oif); - if (neigh_filter == NULL) - return NULL; - - set_neigh_filter(neigh_handler, neigh_filter); - - nl_socket_disable_seq_check(neigh_handler->sock); - nl_socket_modify_cb(neigh_handler->sock, NL_CB_VALID, NL_CB_CUSTOM, - &get_neigh_cb, neigh_handler); - - fd = nl_socket_get_fd(neigh_handler->sock); - - err = create_socket(neigh_handler, &addr_dst, &sock_fd); - - if (err) - return NULL; - - err = try_send_to(sock_fd, buff, sizeof(buff), &addr_dst); - if (err) - goto close_socket; - - timer_fd = create_timer(neigh_handler); - if (timer_fd < 0) - goto close_socket; - - nfds = max(fd, timer_fd) + 1; - - while (1) { - FD_ZERO(&fdset); - FD_SET(fd, &fdset); - FD_SET(timer_fd, &fdset); - - /* wait for an incoming message on the netlink socket */ - ret = select(nfds, &fdset, NULL, NULL, NULL); - if (ret == -1) { - goto select_err; - } else if (ret) { - if (FD_ISSET(fd, &fdset)) { - nl_recvmsgs_default(neigh_handler->sock); - if (neigh_handler->found_ll_addr) - break; - } else { - nl_cache_refill(neigh_handler->sock, - neigh_handler->neigh_cache); - ll_addr = get_neigh_mac(neigh_handler); - if (NULL != ll_addr) { - break; - } else if (FD_ISSET(timer_fd, &fdset) && - retries < NUM_OF_RETRIES) { - try_send_to(sock_fd, buff, sizeof(buff), - &addr_dst); - } - } - - if (FD_ISSET(timer_fd, &fdset)) { - uint64_t read_val; - ssize_t rc; - - rc = - read(timer_fd, &read_val, sizeof(read_val)); - assert(rc == sizeof(read_val)); - if (++retries >= NUM_OF_TRIES) { - if (!errno) - errno = EDESTADDRREQ; - break; - } - } - } - } -select_err: - close(timer_fd); -close_socket: - close(sock_fd); - return ll_addr ? ll_addr : neigh_handler->found_ll_addr; -} - -static int get_mcast_mac_ipv4(struct nl_addr *dst, struct nl_addr **ll_addr) -{ - uint8_t mac_addr[6] = {0x01, 0x00, 0x5E}; - uint32_t addr = be32toh(*(__be32 *)nl_addr_get_binary_addr(dst)); - - mac_addr[5] = addr & 0xFF; - addr >>= 8; - mac_addr[4] = addr & 0xFF; - addr >>= 8; - mac_addr[3] = addr & 0x7F; - - *ll_addr = nl_addr_build(AF_LLC, mac_addr, sizeof(mac_addr)); - - return *ll_addr == NULL ? -EINVAL : 0; -} - -static int get_mcast_mac_ipv6(struct nl_addr *dst, struct nl_addr **ll_addr) -{ - uint8_t mac_addr[6] = {0x33, 0x33}; - - memcpy(mac_addr + 2, (uint8_t *)nl_addr_get_binary_addr(dst) + 12, 4); - - *ll_addr = nl_addr_build(AF_LLC, mac_addr, sizeof(mac_addr)); - - return *ll_addr == NULL ? -EINVAL : 0; -} - -static int get_link_local_mac_ipv6(struct nl_addr *dst, - struct nl_addr **ll_addr) -{ - uint8_t mac_addr[6]; - - memcpy(mac_addr + 3, (uint8_t *)nl_addr_get_binary_addr(dst) + 13, 3); - memcpy(mac_addr, (uint8_t *)nl_addr_get_binary_addr(dst) + 8, 3); - mac_addr[0] ^= 2; - - *ll_addr = nl_addr_build(AF_LLC, mac_addr, sizeof(mac_addr)); - return *ll_addr == NULL ? -EINVAL : 0; -} - -static const struct encoded_l3_addr { - short family; - uint8_t prefix_bits; - const uint8_t data[16]; - int (*getter)(struct nl_addr *dst, struct nl_addr **ll_addr); -} encoded_prefixes[] = { - {.family = AF_INET, - .prefix_bits = 4, - .data = {0xe0}, - .getter = &get_mcast_mac_ipv4}, - {.family = AF_INET6, - .prefix_bits = 8, - .data = {0xff}, - .getter = &get_mcast_mac_ipv6}, - {.family = AF_INET6, - .prefix_bits = 64, - .data = {0xfe, 0x80}, - .getter = get_link_local_mac_ipv6}, -}; - -static int nl_addr_cmp_prefix_msb(void *addr1, int len1, void *addr2, int len2) -{ - int len = min(len1, len2); - int bytes = len / 8; - int d = memcmp(addr1, addr2, bytes); - - if (d == 0) { - int mask = ((1UL << (len % 8)) - 1UL) << (8 - len); - - d = (((uint8_t *)addr1)[bytes] & mask) - - (((uint8_t *)addr2)[bytes] & mask); - } - - return d; -} - -static int handle_encoded_mac(struct nl_addr *dst, struct nl_addr **ll_addr) -{ - uint32_t family = nl_addr_get_family(dst); - struct nl_addr *prefix = NULL; - int i; - int ret = 1; - - for (i = 0; - i < sizeof(encoded_prefixes)/sizeof(encoded_prefixes[0]) && - ret; prefix = NULL, i++) { - if (encoded_prefixes[i].family != family) - continue; - - prefix = nl_addr_build( - family, (void *)encoded_prefixes[i].data, - min_t(size_t, encoded_prefixes[i].prefix_bits / 8 + - !!(encoded_prefixes[i].prefix_bits % 8), - sizeof(encoded_prefixes[i].data))); - - if (prefix == NULL) - return -ENOMEM; - nl_addr_set_prefixlen(prefix, - encoded_prefixes[i].prefix_bits); - - if (nl_addr_cmp_prefix_msb(nl_addr_get_binary_addr(dst), - nl_addr_get_prefixlen(dst), - nl_addr_get_binary_addr(prefix), - nl_addr_get_prefixlen(prefix))) - continue; - - ret = encoded_prefixes[i].getter(dst, ll_addr); - nl_addr_put(prefix); - } - - return ret; -} - -static void get_route_cb_parser(struct nl_object *obj, void *arg) -{ - struct get_neigh_handler *neigh_handler = - (struct get_neigh_handler *)arg; - - struct rtnl_route *route = (struct rtnl_route *)obj; - struct nl_addr *gateway = NULL; - struct nl_addr *src = rtnl_route_get_pref_src(route); - int oif; - int type = rtnl_route_get_type(route); - struct rtnl_link *link; - - struct rtnl_nexthop *nh = rtnl_route_nexthop_n(route, 0); - - if (nh != NULL) - gateway = rtnl_route_nh_get_gateway(nh); - oif = rtnl_route_nh_get_ifindex(nh); - - if (gateway) { - nl_addr_put(neigh_handler->dst); - neigh_handler->dst = nl_addr_clone(gateway); - } - - if (RTN_BLACKHOLE == type || - RTN_UNREACHABLE == type || - RTN_PROHIBIT == type || - RTN_THROW == type) { - errno = ENETUNREACH; - goto err; - } - - if (!neigh_handler->src && src) - neigh_handler->src = nl_addr_clone(src); - - if (neigh_handler->oif < 0 && oif > 0) - neigh_handler->oif = oif; - - /* Link Local */ - if (RTN_LOCAL == type) { - struct nl_addr *lladdr; - - link = rtnl_link_get(neigh_handler->link_cache, - neigh_handler->oif); - - if (link == NULL) - goto err; - - lladdr = rtnl_link_get_addr(link); - - if (lladdr == NULL) - goto err_link; - - neigh_handler->found_ll_addr = nl_addr_clone(lladdr); - rtnl_link_put(link); - } else { - handle_encoded_mac( - neigh_handler->dst, - &neigh_handler->found_ll_addr); - } - - return; - -err_link: - rtnl_link_put(link); -err: - if (neigh_handler->src) { - nl_addr_put(neigh_handler->src); - neigh_handler->src = NULL; - } -} - -static int get_route_cb(struct nl_msg *msg, void *arg) -{ - struct get_neigh_handler *neigh_handler = - (struct get_neigh_handler *)arg; - int err; - - err = nl_msg_parse(msg, &get_route_cb_parser, neigh_handler); - if (err < 0) { - errno = ENOMSG; - return err; - } - - if (!neigh_handler->dst || !neigh_handler->src || - neigh_handler->oif <= 0) { - errno = EINVAL; - return -1; - } - - if (NULL != neigh_handler->found_ll_addr) - goto found; - - neigh_handler->found_ll_addr = - process_get_neigh_mac(neigh_handler); - -found: - return neigh_handler->found_ll_addr ? 0 : -1; -} - -int neigh_get_oif_from_src(struct get_neigh_handler *neigh_handler) -{ - int oif = -ENODEV; - struct addrinfo *src_info; - int err; - - err = nl_addr_info(neigh_handler->src, &src_info); - if (err) { - if (!errno) - errno = ENXIO; - return oif; - } - - oif = get_ifindex(src_info->ai_addr); - if (oif <= 0) - goto free; - -free: - freeaddrinfo(src_info); - return oif; -} - -static void alloc_zero_based_socket(void) -{ - zero_socket = nl_socket_alloc(); -} - -int neigh_init_resources(struct get_neigh_handler *neigh_handler, int timeout) -{ - int err; - - pthread_once(&device_neigh_alloc, &alloc_zero_based_socket); - neigh_handler->sock = nl_socket_alloc(); - if (neigh_handler->sock == NULL) { - errno = ENOMEM; - return -1; - } - - err = nl_connect(neigh_handler->sock, NETLINK_ROUTE); - if (err < 0) - goto free_socket; - - err = rtnl_link_alloc_cache(neigh_handler->sock, AF_UNSPEC, - &neigh_handler->link_cache); - if (err) { - err = -1; - errno = ENOMEM; - goto close_connection; - } - - nl_cache_mngt_provide(neigh_handler->link_cache); - - err = rtnl_route_alloc_cache(neigh_handler->sock, AF_UNSPEC, 0, - &neigh_handler->route_cache); - if (err) { - err = -1; - errno = ENOMEM; - goto free_link_cache; - } - - nl_cache_mngt_provide(neigh_handler->route_cache); - - err = rtnl_neigh_alloc_cache(neigh_handler->sock, - &neigh_handler->neigh_cache); - if (err) { - err = -ENOMEM; - goto free_route_cache; - } - - nl_cache_mngt_provide(neigh_handler->neigh_cache); - - /* init structure */ - neigh_handler->timeout = timeout; - neigh_handler->oif = -1; - neigh_handler->filter_neigh = NULL; - neigh_handler->found_ll_addr = NULL; - neigh_handler->dst = NULL; - neigh_handler->src = NULL; - neigh_handler->vid = -1; - - return 0; - -free_route_cache: - nl_cache_mngt_unprovide(neigh_handler->route_cache); - nl_cache_free(neigh_handler->route_cache); - neigh_handler->route_cache = NULL; -free_link_cache: - nl_cache_mngt_unprovide(neigh_handler->link_cache); - nl_cache_free(neigh_handler->link_cache); - neigh_handler->link_cache = NULL; -close_connection: - nl_close(neigh_handler->sock); -free_socket: - nl_socket_free(neigh_handler->sock); - neigh_handler->sock = NULL; - return err; -} - -uint16_t neigh_get_vlan_id_from_dev(struct get_neigh_handler *neigh_handler) -{ - struct rtnl_link *link; - int vid = 0xffff; - - link = rtnl_link_get(neigh_handler->link_cache, neigh_handler->oif); - if (link == NULL) { - errno = EINVAL; - return vid; - } - - if (rtnl_link_is_vlan(link)) - vid = rtnl_link_vlan_get_id(link); - rtnl_link_put(link); - return vid >= 0 && vid <= 0xfff ? vid : 0xffff; -} - -void neigh_set_vlan_id(struct get_neigh_handler *neigh_handler, uint16_t vid) -{ - if (vid <= 0xfff) - neigh_handler->vid = vid; -} - -int neigh_set_dst(struct get_neigh_handler *neigh_handler, - int family, void *buf, size_t size) -{ - neigh_handler->dst = nl_addr_build(family, buf, size); - return neigh_handler->dst == NULL; -} - -int neigh_set_src(struct get_neigh_handler *neigh_handler, - int family, void *buf, size_t size) -{ - neigh_handler->src = nl_addr_build(family, buf, size); - return neigh_handler->src == NULL; -} - -void neigh_set_oif(struct get_neigh_handler *neigh_handler, int oif) -{ - neigh_handler->oif = oif; -} - -int neigh_get_ll(struct get_neigh_handler *neigh_handler, void *addr_buff, - int addr_size) { - int neigh_len; - - if (neigh_handler->found_ll_addr == NULL) - return -EINVAL; - - neigh_len = nl_addr_get_len(neigh_handler->found_ll_addr); - - if (neigh_len > addr_size) - return -EINVAL; - - memcpy(addr_buff, nl_addr_get_binary_addr(neigh_handler->found_ll_addr), - neigh_len); - - return neigh_len; -} - -void neigh_free_resources(struct get_neigh_handler *neigh_handler) -{ - /* Should be released first because it's holding a reference to dst */ - if (neigh_handler->filter_neigh != NULL) { - rtnl_neigh_put(neigh_handler->filter_neigh); - neigh_handler->filter_neigh = NULL; - } - - if (neigh_handler->src != NULL) { - nl_addr_put(neigh_handler->src); - neigh_handler->src = NULL; - } - - if (neigh_handler->dst != NULL) { - nl_addr_put(neigh_handler->dst); - neigh_handler->dst = NULL; - } - - if (neigh_handler->found_ll_addr != NULL) { - nl_addr_put(neigh_handler->found_ll_addr); - neigh_handler->found_ll_addr = NULL; - } - - if (neigh_handler->neigh_cache != NULL) { - nl_cache_mngt_unprovide(neigh_handler->neigh_cache); - nl_cache_free(neigh_handler->neigh_cache); - neigh_handler->neigh_cache = NULL; - } - - if (neigh_handler->route_cache != NULL) { - nl_cache_mngt_unprovide(neigh_handler->route_cache); - nl_cache_free(neigh_handler->route_cache); - neigh_handler->route_cache = NULL; - } - - if (neigh_handler->link_cache != NULL) { - nl_cache_mngt_unprovide(neigh_handler->link_cache); - nl_cache_free(neigh_handler->link_cache); - neigh_handler->link_cache = NULL; - } - - if (neigh_handler->sock != NULL) { - nl_close(neigh_handler->sock); - nl_socket_free(neigh_handler->sock); - neigh_handler->sock = NULL; - } -} - -int process_get_neigh(struct get_neigh_handler *neigh_handler) -{ - struct nl_msg *m; - struct rtmsg rmsg = { - .rtm_family = nl_addr_get_family(neigh_handler->dst), - .rtm_dst_len = nl_addr_get_prefixlen(neigh_handler->dst), - }; - int err; - - m = nlmsg_alloc_simple(RTM_GETROUTE, 0); - - if (m == NULL) - return -ENOMEM; - - nlmsg_append(m, &rmsg, sizeof(rmsg), NLMSG_ALIGNTO); - - nla_put_addr(m, RTA_DST, neigh_handler->dst); - - if (neigh_handler->oif > 0) - nla_put_u32(m, RTA_OIF, neigh_handler->oif); - - err = nl_send_auto_complete(neigh_handler->sock, m); - nlmsg_free(m); - if (err < 0) - return err; - - nl_socket_modify_cb(neigh_handler->sock, NL_CB_VALID, - NL_CB_CUSTOM, &get_route_cb, neigh_handler); - - err = nl_recvmsgs_default(neigh_handler->sock); - - return err; -} diff --git a/usr/rdma-core/libibverbs/neigh.h b/usr/rdma-core/libibverbs/neigh.h deleted file mode 100644 index 88211bf2f..000000000 --- a/usr/rdma-core/libibverbs/neigh.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md - */ - -#ifndef _NEIGH_H_ -#define _NEIGH_H_ - -#include -#include -#include "config.h" -#ifdef HAVE_LIBNL1 -#include -#include "nl1_compat.h" -#else -#include -#endif - -struct get_neigh_handler { -#ifdef HAVE_LIBNL1 - struct nl_handle *sock; -#else - struct nl_sock *sock; -#endif - struct nl_cache *link_cache; - struct nl_cache *neigh_cache; - struct nl_cache *route_cache; - int32_t oif; - int vid; - struct rtnl_neigh *filter_neigh; - struct nl_addr *found_ll_addr; - struct nl_addr *dst; - struct nl_addr *src; - uint64_t timeout; -}; - -int process_get_neigh(struct get_neigh_handler *neigh_handler); -void neigh_free_resources(struct get_neigh_handler *neigh_handler); -void neigh_set_vlan_id(struct get_neigh_handler *neigh_handler, uint16_t vid); -uint16_t neigh_get_vlan_id_from_dev(struct get_neigh_handler *neigh_handler); -int neigh_init_resources(struct get_neigh_handler *neigh_handler, int timeout); - -int neigh_set_src(struct get_neigh_handler *neigh_handler, - int family, void *buf, size_t size); -void neigh_set_oif(struct get_neigh_handler *neigh_handler, int oif); -int neigh_set_dst(struct get_neigh_handler *neigh_handler, - int family, void *buf, size_t size); -int neigh_get_oif_from_src(struct get_neigh_handler *neigh_handler); -int neigh_get_ll(struct get_neigh_handler *neigh_handler, void *addr_buf, - int addr_size); - -#endif diff --git a/usr/rdma-core/libibverbs/nl1_compat.h b/usr/rdma-core/libibverbs/nl1_compat.h deleted file mode 100644 index 321088240..000000000 --- a/usr/rdma-core/libibverbs/nl1_compat.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md - */ - -#ifndef _NL1_COMPAT_H_ -#define _NL1_COMPAT_H_ - -#include -#include -#include -#include - -struct nl_handle; - -/* Workaround - declaration missing */ -extern int rtnl_link_vlan_get_id(struct rtnl_link *); - -#define nl_geterror(x) nl_geterror() -#define nl_sock nl_handle - -static inline void nl_socket_disable_seq_check(struct nl_sock *sock) -{ - nl_disable_sequence_check(sock); -} - -struct rtnl_nexthop {}; - -static inline struct rtnl_nexthop *rtnl_route_nexthop_n( - struct rtnl_route *r, int n) -{ - return (struct rtnl_nexthop *)r; -} - -static inline struct nl_addr *rtnl_route_nh_get_gateway(struct rtnl_nexthop *nh) -{ - return rtnl_route_get_gateway((struct rtnl_route *)nh); -} - -static inline int rtnl_route_nh_get_ifindex(struct rtnl_nexthop *nh) -{ - return rtnl_route_get_oif((struct rtnl_route *)nh); -} - -#define nl_addr_info(addr, result) ( \ - *(result) = nl_addr_info(addr), \ - (*(result) == NULL) ? nl_get_errno() : 0 \ -) - -static inline void nl_socket_free(struct nl_sock *sock) -{ - nl_close(sock); -} - -static inline struct nl_sock *nl_socket_alloc(void) -{ - return nl_handle_alloc(); -} - -#define rtnl_link_alloc_cache(sock, family, result) ( \ - *result = rtnl_link_alloc_cache(sock), \ - (*result == NULL) ? nl_get_errno() : 0 \ -) - -#define rtnl_route_alloc_cache(sock, family, flags, result) ( \ - *result = rtnl_route_alloc_cache(sock), \ - (*result == NULL) ? nl_get_errno() : 0 \ -) - -#define rtnl_neigh_alloc_cache(sock, result) ( \ - *result = rtnl_neigh_alloc_cache(sock), \ - (*result == NULL) ? nl_get_errno() : 0 \ -) - -static inline int rtnl_link_is_vlan(struct rtnl_link *link) -{ - return rtnl_link_vlan_get_id(link) <= 0; -} - -#endif diff --git a/usr/rdma-core/libibverbs/opcode.h b/usr/rdma-core/libibverbs/opcode.h deleted file mode 100644 index fd4bc96a2..000000000 --- a/usr/rdma-core/libibverbs/opcode.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef INFINIBAND_OPCODE_H -#define INFINIBAND_OPCODE_H - -/* - * This macro cleans up the definitions of constants for BTH opcodes. - * It is used to define constants such as IBV_OPCODE_UD_SEND_ONLY, - * which becomes IBV_OPCODE_UD + IBV_OPCODE_SEND_ONLY, and this gives - * the correct value. - * - * In short, user code should use the constants defined using the - * macro rather than worrying about adding together other constants. -*/ -#define IBV_OPCODE(transport, op) \ - IBV_OPCODE_ ## transport ## _ ## op = \ - IBV_OPCODE_ ## transport + IBV_OPCODE_ ## op - -enum { - /* transport types -- just used to define real constants */ - IBV_OPCODE_RC = 0x00, - IBV_OPCODE_UC = 0x20, - IBV_OPCODE_RD = 0x40, - IBV_OPCODE_UD = 0x60, - - /* operations -- just used to define real constants */ - IBV_OPCODE_SEND_FIRST = 0x00, - IBV_OPCODE_SEND_MIDDLE = 0x01, - IBV_OPCODE_SEND_LAST = 0x02, - IBV_OPCODE_SEND_LAST_WITH_IMMEDIATE = 0x03, - IBV_OPCODE_SEND_ONLY = 0x04, - IBV_OPCODE_SEND_ONLY_WITH_IMMEDIATE = 0x05, - IBV_OPCODE_RDMA_WRITE_FIRST = 0x06, - IBV_OPCODE_RDMA_WRITE_MIDDLE = 0x07, - IBV_OPCODE_RDMA_WRITE_LAST = 0x08, - IBV_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE = 0x09, - IBV_OPCODE_RDMA_WRITE_ONLY = 0x0a, - IBV_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE = 0x0b, - IBV_OPCODE_RDMA_READ_REQUEST = 0x0c, - IBV_OPCODE_RDMA_READ_RESPONSE_FIRST = 0x0d, - IBV_OPCODE_RDMA_READ_RESPONSE_MIDDLE = 0x0e, - IBV_OPCODE_RDMA_READ_RESPONSE_LAST = 0x0f, - IBV_OPCODE_RDMA_READ_RESPONSE_ONLY = 0x10, - IBV_OPCODE_ACKNOWLEDGE = 0x11, - IBV_OPCODE_ATOMIC_ACKNOWLEDGE = 0x12, - IBV_OPCODE_COMPARE_SWAP = 0x13, - IBV_OPCODE_FETCH_ADD = 0x14, - - /* real constants follow -- see comment about above IBV_OPCODE() - macro for more details */ - - /* RC */ - IBV_OPCODE(RC, SEND_FIRST), - IBV_OPCODE(RC, SEND_MIDDLE), - IBV_OPCODE(RC, SEND_LAST), - IBV_OPCODE(RC, SEND_LAST_WITH_IMMEDIATE), - IBV_OPCODE(RC, SEND_ONLY), - IBV_OPCODE(RC, SEND_ONLY_WITH_IMMEDIATE), - IBV_OPCODE(RC, RDMA_WRITE_FIRST), - IBV_OPCODE(RC, RDMA_WRITE_MIDDLE), - IBV_OPCODE(RC, RDMA_WRITE_LAST), - IBV_OPCODE(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE), - IBV_OPCODE(RC, RDMA_WRITE_ONLY), - IBV_OPCODE(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE), - IBV_OPCODE(RC, RDMA_READ_REQUEST), - IBV_OPCODE(RC, RDMA_READ_RESPONSE_FIRST), - IBV_OPCODE(RC, RDMA_READ_RESPONSE_MIDDLE), - IBV_OPCODE(RC, RDMA_READ_RESPONSE_LAST), - IBV_OPCODE(RC, RDMA_READ_RESPONSE_ONLY), - IBV_OPCODE(RC, ACKNOWLEDGE), - IBV_OPCODE(RC, ATOMIC_ACKNOWLEDGE), - IBV_OPCODE(RC, COMPARE_SWAP), - IBV_OPCODE(RC, FETCH_ADD), - - /* UC */ - IBV_OPCODE(UC, SEND_FIRST), - IBV_OPCODE(UC, SEND_MIDDLE), - IBV_OPCODE(UC, SEND_LAST), - IBV_OPCODE(UC, SEND_LAST_WITH_IMMEDIATE), - IBV_OPCODE(UC, SEND_ONLY), - IBV_OPCODE(UC, SEND_ONLY_WITH_IMMEDIATE), - IBV_OPCODE(UC, RDMA_WRITE_FIRST), - IBV_OPCODE(UC, RDMA_WRITE_MIDDLE), - IBV_OPCODE(UC, RDMA_WRITE_LAST), - IBV_OPCODE(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE), - IBV_OPCODE(UC, RDMA_WRITE_ONLY), - IBV_OPCODE(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE), - - /* RD */ - IBV_OPCODE(RD, SEND_FIRST), - IBV_OPCODE(RD, SEND_MIDDLE), - IBV_OPCODE(RD, SEND_LAST), - IBV_OPCODE(RD, SEND_LAST_WITH_IMMEDIATE), - IBV_OPCODE(RD, SEND_ONLY), - IBV_OPCODE(RD, SEND_ONLY_WITH_IMMEDIATE), - IBV_OPCODE(RD, RDMA_WRITE_FIRST), - IBV_OPCODE(RD, RDMA_WRITE_MIDDLE), - IBV_OPCODE(RD, RDMA_WRITE_LAST), - IBV_OPCODE(RD, RDMA_WRITE_LAST_WITH_IMMEDIATE), - IBV_OPCODE(RD, RDMA_WRITE_ONLY), - IBV_OPCODE(RD, RDMA_WRITE_ONLY_WITH_IMMEDIATE), - IBV_OPCODE(RD, RDMA_READ_REQUEST), - IBV_OPCODE(RD, RDMA_READ_RESPONSE_FIRST), - IBV_OPCODE(RD, RDMA_READ_RESPONSE_MIDDLE), - IBV_OPCODE(RD, RDMA_READ_RESPONSE_LAST), - IBV_OPCODE(RD, RDMA_READ_RESPONSE_ONLY), - IBV_OPCODE(RD, ACKNOWLEDGE), - IBV_OPCODE(RD, ATOMIC_ACKNOWLEDGE), - IBV_OPCODE(RD, COMPARE_SWAP), - IBV_OPCODE(RD, FETCH_ADD), - - /* UD */ - IBV_OPCODE(UD, SEND_ONLY), - IBV_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE) -}; - -#endif /* INFINIBAND_OPCODE_H */ diff --git a/usr/rdma-core/libibverbs/sa-kern-abi.h b/usr/rdma-core/libibverbs/sa-kern-abi.h deleted file mode 100644 index 134aeccb4..000000000 --- a/usr/rdma-core/libibverbs/sa-kern-abi.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef INFINIBAND_SA_KERN_ABI_H -#define INFINIBAND_SA_KERN_ABI_H - -#warning "This header is obsolete, use rdma/ib_user_sa.h instead" - -#include - -#define ib_kern_path_rec ib_user_path_rec -#define ibv_kern_path_rec ib_user_path_rec - -#endif diff --git a/usr/rdma-core/libibverbs/sa.h b/usr/rdma-core/libibverbs/sa.h deleted file mode 100644 index e7f96dd5e..000000000 --- a/usr/rdma-core/libibverbs/sa.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2004 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Voltaire, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef INFINIBAND_SA_H -#define INFINIBAND_SA_H - -#include -#include - -struct ibv_sa_path_rec { - /* reserved */ - /* reserved */ - union ibv_gid dgid; - union ibv_gid sgid; - __be16 dlid; - __be16 slid; - int raw_traffic; - /* reserved */ - __be32 flow_label; - uint8_t hop_limit; - uint8_t traffic_class; - int reversible; - uint8_t numb_path; - __be16 pkey; - /* reserved */ - uint8_t sl; - uint8_t mtu_selector; - uint8_t mtu; - uint8_t rate_selector; - uint8_t rate; - uint8_t packet_life_time_selector; - uint8_t packet_life_time; - uint8_t preference; -}; - -struct ibv_sa_mcmember_rec { - union ibv_gid mgid; - union ibv_gid port_gid; - uint32_t qkey; - uint16_t mlid; - uint8_t mtu_selector; - uint8_t mtu; - uint8_t traffic_class; - uint16_t pkey; - uint8_t rate_selector; - uint8_t rate; - uint8_t packet_life_time_selector; - uint8_t packet_life_time; - uint8_t sl; - uint32_t flow_label; - uint8_t hop_limit; - uint8_t scope; - uint8_t join_state; - int proxy_join; -}; - -struct ibv_sa_service_rec { - uint64_t id; - union ibv_gid gid; - uint16_t pkey; - /* uint16_t resv; */ - uint32_t lease; - uint8_t key[16]; - uint8_t name[64]; - uint8_t data8[16]; - uint16_t data16[8]; - uint32_t data32[4]; - uint64_t data64[2]; -}; - -#define IBV_PATH_RECORD_REVERSIBLE 0x80 - -struct ibv_path_record { - __be64 service_id; - union ibv_gid dgid; - union ibv_gid sgid; - __be16 dlid; - __be16 slid; - __be32 flowlabel_hoplimit; /* resv-31:28 flow label-27:8 hop limit-7:0*/ - uint8_t tclass; - uint8_t reversible_numpath; /* reversible-7:7 num path-6:0 */ - __be16 pkey; - __be16 qosclass_sl; /* qos class-15:4 sl-3:0 */ - uint8_t mtu; /* mtu selector-7:6 mtu-5:0 */ - uint8_t rate; /* rate selector-7:6 rate-5:0 */ - uint8_t packetlifetime; /* lifetime selector-7:6 lifetime-5:0 */ - uint8_t preference; - uint8_t reserved[6]; -}; - -#define IBV_PATH_FLAG_GMP (1<<0) -#define IBV_PATH_FLAG_PRIMARY (1<<1) -#define IBV_PATH_FLAG_ALTERNATE (1<<2) -#define IBV_PATH_FLAG_OUTBOUND (1<<3) -#define IBV_PATH_FLAG_INBOUND (1<<4) -#define IBV_PATH_FLAG_INBOUND_REVERSE (1<<5) -#define IBV_PATH_FLAG_BIDIRECTIONAL (IBV_PATH_FLAG_OUTBOUND | \ - IBV_PATH_FLAG_INBOUND_REVERSE) - -struct ibv_path_data { - uint32_t flags; - uint32_t reserved; - struct ibv_path_record path; -}; - -#endif /* INFINIBAND_SA_H */ diff --git a/usr/rdma-core/libibverbs/sysfs.c b/usr/rdma-core/libibverbs/sysfs.c deleted file mode 100644 index f45fa1a36..000000000 --- a/usr/rdma-core/libibverbs/sysfs.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "ibverbs.h" - -static const char *sysfs_path; - -const char *ibv_get_sysfs_path(void) -{ - const char *env = NULL; - - if (sysfs_path) - return sysfs_path; - - /* - * Only follow use path passed in through the calling user's - * environment if we're not running SUID. - */ - if (getuid() == geteuid()) - env = getenv("SYSFS_PATH"); - - if (env) { - int len; - char *dup; - - sysfs_path = dup = strndup(env, IBV_SYSFS_PATH_MAX); - len = strlen(dup); - while (len > 0 && dup[len - 1] == '/') { - --len; - dup[len] = '\0'; - } - } else - sysfs_path = "/sys"; - - return sysfs_path; -} - -int ibv_read_sysfs_file(const char *dir, const char *file, - char *buf, size_t size) -{ - char *path; - int fd; - int len; - - if (asprintf(&path, "%s/%s", dir, file) < 0) - return -1; - - fd = open(path, O_RDONLY | O_CLOEXEC); - if (fd < 0) { - free(path); - return -1; - } - - len = read(fd, buf, size); - - close(fd); - free(path); - - if (len > 0) { - if (buf[len - 1] == '\n') - buf[--len] = '\0'; - else if (len < size) - buf[len] = '\0'; - else - /* We would have to truncate the contents to NULL - * terminate, so we are going to fail no matter - * what we do, either right now or later when - * we pass around an unterminated string. Fail now. - */ - return -1; - } - - return len; -} diff --git a/usr/rdma-core/libibverbs/verbs.c b/usr/rdma-core/libibverbs/verbs.c deleted file mode 100644 index 65d9c1c8c..000000000 --- a/usr/rdma-core/libibverbs/verbs.c +++ /dev/null @@ -1,1004 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "ibverbs.h" -#ifndef NRESOLVE_NEIGH -#include -#include -#include "neigh.h" -#endif - -#undef ibv_query_port - -int __attribute__((const)) ibv_rate_to_mult(enum ibv_rate rate) -{ - switch (rate) { - case IBV_RATE_2_5_GBPS: return 1; - case IBV_RATE_5_GBPS: return 2; - case IBV_RATE_10_GBPS: return 4; - case IBV_RATE_20_GBPS: return 8; - case IBV_RATE_30_GBPS: return 12; - case IBV_RATE_40_GBPS: return 16; - case IBV_RATE_60_GBPS: return 24; - case IBV_RATE_80_GBPS: return 32; - case IBV_RATE_120_GBPS: return 48; - default: return -1; - } -} - -enum ibv_rate __attribute__((const)) mult_to_ibv_rate(int mult) -{ - switch (mult) { - case 1: return IBV_RATE_2_5_GBPS; - case 2: return IBV_RATE_5_GBPS; - case 4: return IBV_RATE_10_GBPS; - case 8: return IBV_RATE_20_GBPS; - case 12: return IBV_RATE_30_GBPS; - case 16: return IBV_RATE_40_GBPS; - case 24: return IBV_RATE_60_GBPS; - case 32: return IBV_RATE_80_GBPS; - case 48: return IBV_RATE_120_GBPS; - default: return IBV_RATE_MAX; - } -} - -int __attribute__((const)) ibv_rate_to_mbps(enum ibv_rate rate) -{ - switch (rate) { - case IBV_RATE_2_5_GBPS: return 2500; - case IBV_RATE_5_GBPS: return 5000; - case IBV_RATE_10_GBPS: return 10000; - case IBV_RATE_20_GBPS: return 20000; - case IBV_RATE_30_GBPS: return 30000; - case IBV_RATE_40_GBPS: return 40000; - case IBV_RATE_60_GBPS: return 60000; - case IBV_RATE_80_GBPS: return 80000; - case IBV_RATE_120_GBPS: return 120000; - case IBV_RATE_14_GBPS: return 14062; - case IBV_RATE_56_GBPS: return 56250; - case IBV_RATE_112_GBPS: return 112500; - case IBV_RATE_168_GBPS: return 168750; - case IBV_RATE_25_GBPS: return 25781; - case IBV_RATE_100_GBPS: return 103125; - case IBV_RATE_200_GBPS: return 206250; - case IBV_RATE_300_GBPS: return 309375; - default: return -1; - } -} - -enum ibv_rate __attribute__((const)) mbps_to_ibv_rate(int mbps) -{ - switch (mbps) { - case 2500: return IBV_RATE_2_5_GBPS; - case 5000: return IBV_RATE_5_GBPS; - case 10000: return IBV_RATE_10_GBPS; - case 20000: return IBV_RATE_20_GBPS; - case 30000: return IBV_RATE_30_GBPS; - case 40000: return IBV_RATE_40_GBPS; - case 60000: return IBV_RATE_60_GBPS; - case 80000: return IBV_RATE_80_GBPS; - case 120000: return IBV_RATE_120_GBPS; - case 14062: return IBV_RATE_14_GBPS; - case 56250: return IBV_RATE_56_GBPS; - case 112500: return IBV_RATE_112_GBPS; - case 168750: return IBV_RATE_168_GBPS; - case 25781: return IBV_RATE_25_GBPS; - case 103125: return IBV_RATE_100_GBPS; - case 206250: return IBV_RATE_200_GBPS; - case 309375: return IBV_RATE_300_GBPS; - default: return IBV_RATE_MAX; - } -} - -LATEST_SYMVER_FUNC(ibv_query_device, 1_1, "IBVERBS_1.1", - int, - struct ibv_context *context, - struct ibv_device_attr *device_attr) -{ - return context->ops.query_device(context, device_attr); -} - -LATEST_SYMVER_FUNC(ibv_query_port, 1_1, "IBVERBS_1.1", - int, - struct ibv_context *context, uint8_t port_num, - struct ibv_port_attr *port_attr) -{ - return context->ops.query_port(context, port_num, port_attr); -} - -LATEST_SYMVER_FUNC(ibv_query_gid, 1_1, "IBVERBS_1.1", - int, - struct ibv_context *context, uint8_t port_num, - int index, union ibv_gid *gid) -{ - char name[24]; - char attr[41]; - uint16_t val; - int i; - - snprintf(name, sizeof name, "ports/%d/gids/%d", port_num, index); - - if (ibv_read_sysfs_file(context->device->ibdev_path, name, - attr, sizeof attr) < 0) - return -1; - - for (i = 0; i < 8; ++i) { - if (sscanf(attr + i * 5, "%hx", &val) != 1) - return -1; - gid->raw[i * 2 ] = val >> 8; - gid->raw[i * 2 + 1] = val & 0xff; - } - - return 0; -} - -LATEST_SYMVER_FUNC(ibv_query_pkey, 1_1, "IBVERBS_1.1", - int, - struct ibv_context *context, uint8_t port_num, - int index, __be16 *pkey) -{ - char name[24]; - char attr[8]; - uint16_t val; - - snprintf(name, sizeof name, "ports/%d/pkeys/%d", port_num, index); - - if (ibv_read_sysfs_file(context->device->ibdev_path, name, - attr, sizeof attr) < 0) - return -1; - - if (sscanf(attr, "%hx", &val) != 1) - return -1; - - *pkey = htobe16(val); - return 0; -} - -LATEST_SYMVER_FUNC(ibv_alloc_pd, 1_1, "IBVERBS_1.1", - struct ibv_pd *, - struct ibv_context *context) -{ - struct ibv_pd *pd; - - pd = context->ops.alloc_pd(context); - if (pd) - pd->context = context; - - return pd; -} - -LATEST_SYMVER_FUNC(ibv_dealloc_pd, 1_1, "IBVERBS_1.1", - int, - struct ibv_pd *pd) -{ - return pd->context->ops.dealloc_pd(pd); -} - -LATEST_SYMVER_FUNC(ibv_reg_mr, 1_1, "IBVERBS_1.1", - struct ibv_mr *, - struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - struct ibv_mr *mr; - - if (ibv_dontfork_range(addr, length)) - return NULL; - - mr = pd->context->ops.reg_mr(pd, addr, length, access); - if (mr) { - mr->context = pd->context; - mr->pd = pd; - mr->addr = addr; - mr->length = length; - } else - ibv_dofork_range(addr, length); - - return mr; -} - -LATEST_SYMVER_FUNC(ibv_rereg_mr, 1_1, "IBVERBS_1.1", - int, - struct ibv_mr *mr, int flags, - struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - int dofork_onfail = 0; - int err; - void *old_addr; - size_t old_len; - - if (flags & ~IBV_REREG_MR_FLAGS_SUPPORTED) { - errno = EINVAL; - return IBV_REREG_MR_ERR_INPUT; - } - - if ((flags & IBV_REREG_MR_CHANGE_TRANSLATION) && - (!length || !addr)) { - errno = EINVAL; - return IBV_REREG_MR_ERR_INPUT; - } - - if (access && !(flags & IBV_REREG_MR_CHANGE_ACCESS)) { - errno = EINVAL; - return IBV_REREG_MR_ERR_INPUT; - } - - if (!mr->context->ops.rereg_mr) { - errno = ENOSYS; - return IBV_REREG_MR_ERR_INPUT; - } - - if (flags & IBV_REREG_MR_CHANGE_TRANSLATION) { - err = ibv_dontfork_range(addr, length); - if (err) - return IBV_REREG_MR_ERR_DONT_FORK_NEW; - dofork_onfail = 1; - } - - old_addr = mr->addr; - old_len = mr->length; - err = mr->context->ops.rereg_mr(mr, flags, pd, addr, length, access); - if (!err) { - if (flags & IBV_REREG_MR_CHANGE_PD) - mr->pd = pd; - if (flags & IBV_REREG_MR_CHANGE_TRANSLATION) { - mr->addr = addr; - mr->length = length; - err = ibv_dofork_range(old_addr, old_len); - if (err) - return IBV_REREG_MR_ERR_DO_FORK_OLD; - } - } else { - err = IBV_REREG_MR_ERR_CMD; - if (dofork_onfail) { - if (ibv_dofork_range(addr, length)) - err = IBV_REREG_MR_ERR_CMD_AND_DO_FORK_NEW; - } - } - - return err; -} - -LATEST_SYMVER_FUNC(ibv_dereg_mr, 1_1, "IBVERBS_1.1", - int, - struct ibv_mr *mr) -{ - int ret; - void *addr = mr->addr; - size_t length = mr->length; - - ret = mr->context->ops.dereg_mr(mr); - if (!ret) - ibv_dofork_range(addr, length); - - return ret; -} - -static struct ibv_comp_channel *ibv_create_comp_channel_v2(struct ibv_context *context) -{ - struct ibv_abi_compat_v2 *t = context->abi_compat; - static int warned; - - if (!pthread_mutex_trylock(&t->in_use)) - return &t->channel; - - if (!warned) { - fprintf(stderr, PFX "Warning: kernel's ABI version %d limits capacity.\n" - " Only one completion channel can be created per context.\n", - abi_ver); - ++warned; - } - - return NULL; -} - -struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context) -{ - struct ibv_comp_channel *channel; - struct ibv_create_comp_channel cmd; - struct ibv_create_comp_channel_resp resp; - - if (abi_ver <= 2) - return ibv_create_comp_channel_v2(context); - - channel = malloc(sizeof *channel); - if (!channel) - return NULL; - - IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_COMP_CHANNEL, &resp, sizeof resp); - if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) { - free(channel); - return NULL; - } - - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - channel->context = context; - channel->fd = resp.fd; - channel->refcnt = 0; - - return channel; -} - -static int ibv_destroy_comp_channel_v2(struct ibv_comp_channel *channel) -{ - struct ibv_abi_compat_v2 *t = (struct ibv_abi_compat_v2 *) channel; - pthread_mutex_unlock(&t->in_use); - return 0; -} - -int ibv_destroy_comp_channel(struct ibv_comp_channel *channel) -{ - struct ibv_context *context; - int ret; - - context = channel->context; - pthread_mutex_lock(&context->mutex); - - if (channel->refcnt) { - ret = EBUSY; - goto out; - } - - if (abi_ver <= 2) { - ret = ibv_destroy_comp_channel_v2(channel); - goto out; - } - - close(channel->fd); - free(channel); - ret = 0; - -out: - pthread_mutex_unlock(&context->mutex); - - return ret; -} - -LATEST_SYMVER_FUNC(ibv_create_cq, 1_1, "IBVERBS_1.1", - struct ibv_cq *, - struct ibv_context *context, int cqe, void *cq_context, - struct ibv_comp_channel *channel, int comp_vector) -{ - struct ibv_cq *cq; - - cq = context->ops.create_cq(context, cqe, channel, comp_vector); - - if (cq) - verbs_init_cq(cq, context, channel, cq_context); - - return cq; -} - -LATEST_SYMVER_FUNC(ibv_resize_cq, 1_1, "IBVERBS_1.1", - int, - struct ibv_cq *cq, int cqe) -{ - if (!cq->context->ops.resize_cq) - return ENOSYS; - - return cq->context->ops.resize_cq(cq, cqe); -} - -LATEST_SYMVER_FUNC(ibv_destroy_cq, 1_1, "IBVERBS_1.1", - int, - struct ibv_cq *cq) -{ - struct ibv_comp_channel *channel = cq->channel; - int ret; - - ret = cq->context->ops.destroy_cq(cq); - - if (channel) { - if (!ret) { - pthread_mutex_lock(&channel->context->mutex); - --channel->refcnt; - pthread_mutex_unlock(&channel->context->mutex); - } - } - - return ret; -} - -LATEST_SYMVER_FUNC(ibv_get_cq_event, 1_1, "IBVERBS_1.1", - int, - struct ibv_comp_channel *channel, - struct ibv_cq **cq, void **cq_context) -{ - struct ibv_comp_event ev; - - if (read(channel->fd, &ev, sizeof ev) != sizeof ev) - return -1; - - *cq = (struct ibv_cq *) (uintptr_t) ev.cq_handle; - *cq_context = (*cq)->cq_context; - - if ((*cq)->context->ops.cq_event) - (*cq)->context->ops.cq_event(*cq); - - return 0; -} - -LATEST_SYMVER_FUNC(ibv_ack_cq_events, 1_1, "IBVERBS_1.1", - void, - struct ibv_cq *cq, unsigned int nevents) -{ - pthread_mutex_lock(&cq->mutex); - cq->comp_events_completed += nevents; - pthread_cond_signal(&cq->cond); - pthread_mutex_unlock(&cq->mutex); -} - -LATEST_SYMVER_FUNC(ibv_create_srq, 1_1, "IBVERBS_1.1", - struct ibv_srq *, - struct ibv_pd *pd, - struct ibv_srq_init_attr *srq_init_attr) -{ - struct ibv_srq *srq; - - if (!pd->context->ops.create_srq) - return NULL; - - srq = pd->context->ops.create_srq(pd, srq_init_attr); - if (srq) { - srq->context = pd->context; - srq->srq_context = srq_init_attr->srq_context; - srq->pd = pd; - srq->events_completed = 0; - pthread_mutex_init(&srq->mutex, NULL); - pthread_cond_init(&srq->cond, NULL); - } - - return srq; -} - -LATEST_SYMVER_FUNC(ibv_modify_srq, 1_1, "IBVERBS_1.1", - int, - struct ibv_srq *srq, - struct ibv_srq_attr *srq_attr, - int srq_attr_mask) -{ - return srq->context->ops.modify_srq(srq, srq_attr, srq_attr_mask); -} - -LATEST_SYMVER_FUNC(ibv_query_srq, 1_1, "IBVERBS_1.1", - int, - struct ibv_srq *srq, struct ibv_srq_attr *srq_attr) -{ - return srq->context->ops.query_srq(srq, srq_attr); -} - -LATEST_SYMVER_FUNC(ibv_destroy_srq, 1_1, "IBVERBS_1.1", - int, - struct ibv_srq *srq) -{ - return srq->context->ops.destroy_srq(srq); -} - -LATEST_SYMVER_FUNC(ibv_create_qp, 1_1, "IBVERBS_1.1", - struct ibv_qp *, - struct ibv_pd *pd, - struct ibv_qp_init_attr *qp_init_attr) -{ - struct ibv_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr); - - if (qp) { - qp->context = pd->context; - qp->qp_context = qp_init_attr->qp_context; - qp->pd = pd; - qp->send_cq = qp_init_attr->send_cq; - qp->recv_cq = qp_init_attr->recv_cq; - qp->srq = qp_init_attr->srq; - qp->qp_type = qp_init_attr->qp_type; - qp->state = IBV_QPS_RESET; - qp->events_completed = 0; - pthread_mutex_init(&qp->mutex, NULL); - pthread_cond_init(&qp->cond, NULL); - } - - return qp; -} - -LATEST_SYMVER_FUNC(ibv_query_qp, 1_1, "IBVERBS_1.1", - int, - struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr) -{ - int ret; - - ret = qp->context->ops.query_qp(qp, attr, attr_mask, init_attr); - if (ret) - return ret; - - if (attr_mask & IBV_QP_STATE) - qp->state = attr->qp_state; - - return 0; -} - -LATEST_SYMVER_FUNC(ibv_modify_qp, 1_1, "IBVERBS_1.1", - int, - struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - int ret; - - ret = qp->context->ops.modify_qp(qp, attr, attr_mask); - if (ret) - return ret; - - if (attr_mask & IBV_QP_STATE) - qp->state = attr->qp_state; - - return 0; -} - -LATEST_SYMVER_FUNC(ibv_destroy_qp, 1_1, "IBVERBS_1.1", - int, - struct ibv_qp *qp) -{ - return qp->context->ops.destroy_qp(qp); -} - -LATEST_SYMVER_FUNC(ibv_create_ah, 1_1, "IBVERBS_1.1", - struct ibv_ah *, - struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - struct ibv_ah *ah = pd->context->ops.create_ah(pd, attr); - - if (ah) { - ah->context = pd->context; - ah->pd = pd; - } - - return ah; -} - -/* GID types as appear in sysfs, no change is expected as of ABI - * compatibility. - */ -#define V1_TYPE "IB/RoCE v1" -#define V2_TYPE "RoCE v2" -int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num, - unsigned int index, enum ibv_gid_type *type) -{ - char name[32]; - char buff[11]; - - snprintf(name, sizeof(name), "ports/%d/gid_attrs/types/%d", port_num, - index); - - /* Reset errno so that we can rely on its value upon any error flow in - * ibv_read_sysfs_file. - */ - errno = 0; - if (ibv_read_sysfs_file(context->device->ibdev_path, name, buff, - sizeof(buff)) <= 0) { - char *dir_path; - DIR *dir; - - if (errno == EINVAL) { - /* In IB, this file doesn't exist and the kernel sets - * errno to -EINVAL. - */ - *type = IBV_GID_TYPE_IB_ROCE_V1; - return 0; - } - if (asprintf(&dir_path, "%s/%s/%d/%s/", - context->device->ibdev_path, "ports", port_num, - "gid_attrs") < 0) - return -1; - dir = opendir(dir_path); - free(dir_path); - if (!dir) { - if (errno == ENOENT) - /* Assuming that if gid_attrs doesn't exist, - * we have an old kernel and all GIDs are - * IB/RoCE v1 - */ - *type = IBV_GID_TYPE_IB_ROCE_V1; - else - return -1; - } else { - closedir(dir); - errno = EFAULT; - return -1; - } - } else { - if (!strcmp(buff, V1_TYPE)) { - *type = IBV_GID_TYPE_IB_ROCE_V1; - } else if (!strcmp(buff, V2_TYPE)) { - *type = IBV_GID_TYPE_ROCE_V2; - } else { - errno = ENOTSUP; - return -1; - } - } - - return 0; -} - -static int ibv_find_gid_index(struct ibv_context *context, uint8_t port_num, - union ibv_gid *gid, enum ibv_gid_type gid_type) -{ - enum ibv_gid_type sgid_type = 0; - union ibv_gid sgid; - int i = 0, ret; - - do { - ret = ibv_query_gid(context, port_num, i, &sgid); - if (!ret) { - ret = ibv_query_gid_type(context, port_num, i, - &sgid_type); - } - i++; - } while (!ret && (memcmp(&sgid, gid, sizeof(*gid)) || - (gid_type != sgid_type))); - - return ret ? ret : i - 1; -} - -static inline void map_ipv4_addr_to_ipv6(__be32 ipv4, struct in6_addr *ipv6) -{ - ipv6->s6_addr32[0] = 0; - ipv6->s6_addr32[1] = 0; - ipv6->s6_addr32[2] = htobe32(0x0000FFFF); - ipv6->s6_addr32[3] = ipv4; -} - -static inline __sum16 ipv4_calc_hdr_csum(uint16_t *data, unsigned int num_hwords) -{ - unsigned int i = 0; - uint32_t sum = 0; - - for (i = 0; i < num_hwords; i++) - sum += *(data++); - - sum = (sum & 0xffff) + (sum >> 16); - - return (__force __sum16)~sum; -} - -static inline int get_grh_header_version(struct ibv_grh *grh) -{ - int ip6h_version = (be32toh(grh->version_tclass_flow) >> 28) & 0xf; - struct iphdr *ip4h = (struct iphdr *)((void *)grh + 20); - struct iphdr ip4h_checked; - - if (ip6h_version != 6) { - if (ip4h->version == 4) - return 4; - errno = EPROTONOSUPPORT; - return -1; - } - /* version may be 6 or 4 */ - if (ip4h->ihl != 5) /* IPv4 header length must be 5 for RoCE v2. */ - return 6; - /* - * Verify checksum. - * We can't write on scattered buffers so we have to copy to temp - * buffer. - */ - memcpy(&ip4h_checked, ip4h, sizeof(ip4h_checked)); - /* Need to set the checksum field (check) to 0 before re-calculating - * the checksum. - */ - ip4h_checked.check = 0; - ip4h_checked.check = ipv4_calc_hdr_csum((uint16_t *)&ip4h_checked, 10); - /* if IPv4 header checksum is OK, believe it */ - if (ip4h->check == ip4h_checked.check) - return 4; - return 6; -} - -static inline void set_ah_attr_generic_fields(struct ibv_ah_attr *ah_attr, - struct ibv_wc *wc, - struct ibv_grh *grh, - uint8_t port_num) -{ - uint32_t flow_class; - - flow_class = be32toh(grh->version_tclass_flow); - ah_attr->grh.flow_label = flow_class & 0xFFFFF; - ah_attr->dlid = wc->slid; - ah_attr->sl = wc->sl; - ah_attr->src_path_bits = wc->dlid_path_bits; - ah_attr->port_num = port_num; -} - -static inline int set_ah_attr_by_ipv4(struct ibv_context *context, - struct ibv_ah_attr *ah_attr, - struct iphdr *ip4h, uint8_t port_num) -{ - union ibv_gid sgid; - int ret; - - /* No point searching multicast GIDs in GID table */ - if (IN_CLASSD(be32toh(ip4h->daddr))) { - errno = EINVAL; - return -1; - } - - map_ipv4_addr_to_ipv6(ip4h->daddr, (struct in6_addr *)&sgid); - ret = ibv_find_gid_index(context, port_num, &sgid, - IBV_GID_TYPE_ROCE_V2); - if (ret < 0) - return ret; - - map_ipv4_addr_to_ipv6(ip4h->saddr, - (struct in6_addr *)&ah_attr->grh.dgid); - ah_attr->grh.sgid_index = (uint8_t) ret; - ah_attr->grh.hop_limit = ip4h->ttl; - ah_attr->grh.traffic_class = ip4h->tos; - - return 0; -} - -#define IB_NEXT_HDR 0x1b -static inline int set_ah_attr_by_ipv6(struct ibv_context *context, - struct ibv_ah_attr *ah_attr, - struct ibv_grh *grh, uint8_t port_num) -{ - uint32_t flow_class; - uint32_t sgid_type; - int ret; - - /* No point searching multicast GIDs in GID table */ - if (grh->dgid.raw[0] == 0xFF) { - errno = EINVAL; - return -1; - } - - ah_attr->grh.dgid = grh->sgid; - if (grh->next_hdr == IPPROTO_UDP) { - sgid_type = IBV_GID_TYPE_ROCE_V2; - } else if (grh->next_hdr == IB_NEXT_HDR) { - sgid_type = IBV_GID_TYPE_IB_ROCE_V1; - } else { - errno = EPROTONOSUPPORT; - return -1; - } - - ret = ibv_find_gid_index(context, port_num, &grh->dgid, - sgid_type); - if (ret < 0) - return ret; - - ah_attr->grh.sgid_index = (uint8_t) ret; - flow_class = be32toh(grh->version_tclass_flow); - ah_attr->grh.hop_limit = grh->hop_limit; - ah_attr->grh.traffic_class = (flow_class >> 20) & 0xFF; - - return 0; -} - -int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num, - struct ibv_wc *wc, struct ibv_grh *grh, - struct ibv_ah_attr *ah_attr) -{ - int version; - int ret = 0; - - memset(ah_attr, 0, sizeof *ah_attr); - set_ah_attr_generic_fields(ah_attr, wc, grh, port_num); - - if (wc->wc_flags & IBV_WC_GRH) { - ah_attr->is_global = 1; - version = get_grh_header_version(grh); - - if (version == 4) - ret = set_ah_attr_by_ipv4(context, ah_attr, - (struct iphdr *)((void *)grh + 20), - port_num); - else if (version == 6) - ret = set_ah_attr_by_ipv6(context, ah_attr, grh, - port_num); - else - ret = -1; - } - - return ret; -} - -struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc, - struct ibv_grh *grh, uint8_t port_num) -{ - struct ibv_ah_attr ah_attr; - int ret; - - ret = ibv_init_ah_from_wc(pd->context, port_num, wc, grh, &ah_attr); - if (ret) - return NULL; - - return ibv_create_ah(pd, &ah_attr); -} - -LATEST_SYMVER_FUNC(ibv_destroy_ah, 1_1, "IBVERBS_1.1", - int, - struct ibv_ah *ah) -{ - return ah->context->ops.destroy_ah(ah); -} - -LATEST_SYMVER_FUNC(ibv_attach_mcast, 1_1, "IBVERBS_1.1", - int, - struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - return qp->context->ops.attach_mcast(qp, gid, lid); -} - -LATEST_SYMVER_FUNC(ibv_detach_mcast, 1_1, "IBVERBS_1.1", - int, - struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - return qp->context->ops.detach_mcast(qp, gid, lid); -} - -static inline int ipv6_addr_v4mapped(const struct in6_addr *a) -{ - return IN6_IS_ADDR_V4MAPPED(&a->s6_addr32) || - /* IPv4 encoded multicast addresses */ - (a->s6_addr32[0] == htobe32(0xff0e0000) && - ((a->s6_addr32[1] | - (a->s6_addr32[2] ^ htobe32(0x0000ffff))) == 0UL)); -} - -struct peer_address { - void *address; - uint32_t size; -}; - -static inline int create_peer_from_gid(int family, void *raw_gid, - struct peer_address *peer_address) -{ - switch (family) { - case AF_INET: - peer_address->address = raw_gid + 12; - peer_address->size = 4; - break; - case AF_INET6: - peer_address->address = raw_gid; - peer_address->size = 16; - break; - default: - return -1; - } - - return 0; -} - -#define NEIGH_GET_DEFAULT_TIMEOUT_MS 3000 -int ibv_resolve_eth_l2_from_gid(struct ibv_context *context, - struct ibv_ah_attr *attr, - uint8_t eth_mac[ETHERNET_LL_SIZE], - uint16_t *vid) -{ -#ifndef NRESOLVE_NEIGH - int dst_family; - int src_family; - int oif; - struct get_neigh_handler neigh_handler; - union ibv_gid sgid; - int ether_len; - struct peer_address src; - struct peer_address dst; - uint16_t ret_vid; - int ret = -EINVAL; - int err; - - err = ibv_query_gid(context, attr->port_num, - attr->grh.sgid_index, &sgid); - - if (err) - return err; - - err = neigh_init_resources(&neigh_handler, - NEIGH_GET_DEFAULT_TIMEOUT_MS); - - if (err) - return err; - - dst_family = ipv6_addr_v4mapped((struct in6_addr *)attr->grh.dgid.raw) ? - AF_INET : AF_INET6; - src_family = ipv6_addr_v4mapped((struct in6_addr *)sgid.raw) ? - AF_INET : AF_INET6; - - if (create_peer_from_gid(dst_family, attr->grh.dgid.raw, &dst)) - goto free_resources; - - if (create_peer_from_gid(src_family, &sgid.raw, &src)) - goto free_resources; - - if (neigh_set_dst(&neigh_handler, dst_family, dst.address, - dst.size)) - goto free_resources; - - if (neigh_set_src(&neigh_handler, src_family, src.address, - src.size)) - goto free_resources; - - oif = neigh_get_oif_from_src(&neigh_handler); - - if (oif > 0) - neigh_set_oif(&neigh_handler, oif); - else - goto free_resources; - - ret = -EHOSTUNREACH; - - /* blocking call */ - if (process_get_neigh(&neigh_handler)) - goto free_resources; - - ret_vid = neigh_get_vlan_id_from_dev(&neigh_handler); - - if (ret_vid <= 0xfff) - neigh_set_vlan_id(&neigh_handler, ret_vid); - - /* We are using only Ethernet here */ - ether_len = neigh_get_ll(&neigh_handler, - eth_mac, - sizeof(uint8_t) * ETHERNET_LL_SIZE); - - if (ether_len <= 0) - goto free_resources; - - *vid = ret_vid; - - ret = 0; - -free_resources: - neigh_free_resources(&neigh_handler); - - return ret; -#else - return -ENOSYS; -#endif -} diff --git a/usr/rdma-core/librdmacm/CMakeLists.txt b/usr/rdma-core/librdmacm/CMakeLists.txt deleted file mode 100644 index dc410d976..000000000 --- a/usr/rdma-core/librdmacm/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -publish_headers(rdma - rdma_cma.h - rdma_cma_abi.h - rdma_verbs.h - rsocket.h - ) -publish_headers(infiniband - ib.h - ) - -rdma_library(rdmacm librdmacm.map - # See Documentation/versioning.md - 1 1.0.${PACKAGE_VERSION} - acm.c - addrinfo.c - cma.c - indexer.c - rsocket.c - ) -target_link_libraries(rdmacm LINK_PUBLIC ibverbs) -target_link_libraries(rdmacm LINK_PRIVATE ${CMAKE_THREAD_LIBS_INIT}) - -# The preload library is a bit special, it needs to be open coded -# Since it is a LD_PRELOAD it has no soname, and is installed in sub dir -add_library(rspreload MODULE - preload.c - indexer.c - ) -# Even though this is a module we still want to use Wl,--no-undefined -set_target_properties(rspreload PROPERTIES LINK_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) -set_target_properties(rspreload PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") -rdma_set_library_map(rspreload librspreload.map) -target_link_libraries(rspreload LINK_PRIVATE - rdmacm - ${CMAKE_THREAD_LIBS_INIT} - ${CMAKE_DL_LIBS} -) -install(TARGETS rspreload DESTINATION "${CMAKE_INSTALL_LIBDIR}/rsocket/") - -# These are for compat with old packaging, these name should not be used. -# FIXME: Maybe we can get rid of them? -rdma_install_symlink("librspreload.so" "${CMAKE_INSTALL_LIBDIR}/rsocket/librspreload.so.1") -rdma_install_symlink("librspreload.so" "${CMAKE_INSTALL_LIBDIR}/rsocket/librspreload.so.1.0.0") diff --git a/usr/rdma-core/librdmacm/acm.c b/usr/rdma-core/librdmacm/acm.c deleted file mode 100644 index b533e297e..000000000 --- a/usr/rdma-core/librdmacm/acm.c +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Copyright (c) 2010-2012 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "cma.h" -#include -#include -#include - -#define ACM_VERSION 1 - -#define ACM_OP_RESOLVE 0x01 -#define ACM_OP_ACK 0x80 - -#define ACM_STATUS_SUCCESS 0 -#define ACM_STATUS_ENOMEM 1 -#define ACM_STATUS_EINVAL 2 -#define ACM_STATUS_ENODATA 3 -#define ACM_STATUS_ENOTCONN 5 -#define ACM_STATUS_ETIMEDOUT 6 -#define ACM_STATUS_ESRCADDR 7 -#define ACM_STATUS_ESRCTYPE 8 -#define ACM_STATUS_EDESTADDR 9 -#define ACM_STATUS_EDESTTYPE 10 - -#define ACM_FLAGS_NODELAY (1<<30) - -#define ACM_MSG_HDR_LENGTH 16 -#define ACM_MAX_ADDRESS 64 -#define ACM_MSG_EP_LENGTH 72 -#define ACM_MSG_DATA_LENGTH (ACM_MSG_EP_LENGTH * 8) - -struct acm_hdr { - uint8_t version; - uint8_t opcode; - uint8_t status; - uint8_t data[3]; - uint16_t length; - uint64_t tid; -}; - -#define ACM_EP_INFO_NAME 0x0001 -#define ACM_EP_INFO_ADDRESS_IP 0x0002 -#define ACM_EP_INFO_ADDRESS_IP6 0x0003 -#define ACM_EP_INFO_PATH 0x0010 - -union acm_ep_info { - uint8_t addr[ACM_MAX_ADDRESS]; - uint8_t name[ACM_MAX_ADDRESS]; - struct ibv_path_record path; -}; - -#define ACM_EP_FLAG_SOURCE (1<<0) -#define ACM_EP_FLAG_DEST (1<<1) - -struct acm_ep_addr_data { - uint32_t flags; - uint16_t type; - uint16_t reserved; - union acm_ep_info info; -}; - -struct acm_resolve_msg { - struct acm_hdr hdr; - struct acm_ep_addr_data data[0]; -}; - -struct acm_msg { - struct acm_hdr hdr; - union{ - uint8_t data[ACM_MSG_DATA_LENGTH]; - struct acm_ep_addr_data resolve_data[0]; - }; -}; - -static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER; -static int sock = -1; -static uint16_t server_port; - -static int ucma_set_server_port(void) -{ - FILE *f; - - if ((f = fopen(IBACM_PORT_FILE, "r" STREAM_CLOEXEC))) { - if (fscanf(f, "%" SCNu16, &server_port) != 1) - server_port = 0; - fclose(f); - } - return server_port; -} - -void ucma_ib_init(void) -{ - struct sockaddr_in addr; - static int init; - int ret; - - if (init) - return; - - pthread_mutex_lock(&acm_lock); - if (init) - goto unlock; - - if (!ucma_set_server_port()) - goto out; - - sock = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP); - if (sock < 0) - goto out; - - memset(&addr, 0, sizeof addr); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = htobe32(INADDR_LOOPBACK); - addr.sin_port = htobe16(server_port); - ret = connect(sock, (struct sockaddr *) &addr, sizeof(addr)); - if (ret) { - close(sock); - sock = -1; - } -out: - init = 1; -unlock: - pthread_mutex_unlock(&acm_lock); -} - -void ucma_ib_cleanup(void) -{ - if (sock >= 0) { - shutdown(sock, SHUT_RDWR); - close(sock); - } -} - -static int ucma_ib_set_addr(struct rdma_addrinfo *ib_rai, - struct rdma_addrinfo *rai) -{ - struct sockaddr_ib *src, *dst; - struct ibv_path_record *path; - - src = calloc(1, sizeof(*src)); - if (!src) - return ERR(ENOMEM); - - dst = calloc(1, sizeof(*dst)); - if (!dst) { - free(src); - return ERR(ENOMEM); - } - - path = &((struct ibv_path_data *) ib_rai->ai_route)->path; - - src->sib_family = AF_IB; - src->sib_pkey = path->pkey; - src->sib_flowinfo = htobe32(be32toh(path->flowlabel_hoplimit) >> 8); - memcpy(&src->sib_addr, &path->sgid, 16); - ucma_set_sid(ib_rai->ai_port_space, rai->ai_src_addr, src); - - dst->sib_family = AF_IB; - dst->sib_pkey = path->pkey; - dst->sib_flowinfo = htobe32(be32toh(path->flowlabel_hoplimit) >> 8); - memcpy(&dst->sib_addr, &path->dgid, 16); - ucma_set_sid(ib_rai->ai_port_space, rai->ai_dst_addr, dst); - - ib_rai->ai_src_addr = (struct sockaddr *) src; - ib_rai->ai_src_len = sizeof(*src); - - ib_rai->ai_dst_addr = (struct sockaddr *) dst; - ib_rai->ai_dst_len = sizeof(*dst); - - return 0; -} - -static int ucma_ib_set_connect(struct rdma_addrinfo *ib_rai, - struct rdma_addrinfo *rai) -{ - struct ib_connect_hdr *hdr; - - if (rai->ai_family == AF_IB) - return 0; - - hdr = calloc(1, sizeof(*hdr)); - if (!hdr) - return ERR(ENOMEM); - - if (rai->ai_family == AF_INET) { - hdr->ip_version = 4 << 4; - memcpy(&hdr->cma_src_ip4, - &((struct sockaddr_in *) rai->ai_src_addr)->sin_addr, 4); - memcpy(&hdr->cma_dst_ip4, - &((struct sockaddr_in *) rai->ai_dst_addr)->sin_addr, 4); - } else { - hdr->ip_version = 6 << 4; - memcpy(&hdr->cma_src_ip6, - &((struct sockaddr_in6 *) rai->ai_src_addr)->sin6_addr, 16); - memcpy(&hdr->cma_dst_ip6, - &((struct sockaddr_in6 *) rai->ai_dst_addr)->sin6_addr, 16); - } - - ib_rai->ai_connect = hdr; - ib_rai->ai_connect_len = sizeof(*hdr); - return 0; -} - -static void ucma_resolve_af_ib(struct rdma_addrinfo **rai) -{ - struct rdma_addrinfo *ib_rai; - - ib_rai = calloc(1, sizeof(*ib_rai)); - if (!ib_rai) - return; - - ib_rai->ai_flags = (*rai)->ai_flags; - ib_rai->ai_family = AF_IB; - ib_rai->ai_qp_type = (*rai)->ai_qp_type; - ib_rai->ai_port_space = (*rai)->ai_port_space; - - ib_rai->ai_route = calloc(1, (*rai)->ai_route_len); - if (!ib_rai->ai_route) - goto err; - - memcpy(ib_rai->ai_route, (*rai)->ai_route, (*rai)->ai_route_len); - ib_rai->ai_route_len = (*rai)->ai_route_len; - - if ((*rai)->ai_src_canonname) { - ib_rai->ai_src_canonname = strdup((*rai)->ai_src_canonname); - if (!ib_rai->ai_src_canonname) - goto err; - } - - if ((*rai)->ai_dst_canonname) { - ib_rai->ai_dst_canonname = strdup((*rai)->ai_dst_canonname); - if (!ib_rai->ai_dst_canonname) - goto err; - } - - if (ucma_ib_set_connect(ib_rai, *rai)) - goto err; - - if (ucma_ib_set_addr(ib_rai, *rai)) - goto err; - - ib_rai->ai_next = *rai; - *rai = ib_rai; - return; - -err: - rdma_freeaddrinfo(ib_rai); -} - -static void ucma_ib_save_resp(struct rdma_addrinfo *rai, struct acm_msg *msg) -{ - struct acm_ep_addr_data *ep_data; - struct ibv_path_data *path_data = NULL; - struct sockaddr_in *sin; - struct sockaddr_in6 *sin6; - int i, cnt, path_cnt = 0; - - cnt = (msg->hdr.length - ACM_MSG_HDR_LENGTH) / ACM_MSG_EP_LENGTH; - for (i = 0; i < cnt; i++) { - ep_data = &msg->resolve_data[i]; - switch (ep_data->type) { - case ACM_EP_INFO_PATH: - ep_data->type = 0; - if (!path_data) - path_data = (struct ibv_path_data *) ep_data; - path_cnt++; - break; - case ACM_EP_INFO_ADDRESS_IP: - if (!(ep_data->flags & ACM_EP_FLAG_SOURCE) || rai->ai_src_len) - break; - - sin = calloc(1, sizeof(*sin)); - if (!sin) - break; - - sin->sin_family = AF_INET; - memcpy(&sin->sin_addr, &ep_data->info.addr, 4); - rai->ai_src_len = sizeof(*sin); - rai->ai_src_addr = (struct sockaddr *) sin; - break; - case ACM_EP_INFO_ADDRESS_IP6: - if (!(ep_data->flags & ACM_EP_FLAG_SOURCE) || rai->ai_src_len) - break; - - sin6 = calloc(1, sizeof(*sin6)); - if (!sin6) - break; - - sin6->sin6_family = AF_INET6; - memcpy(&sin6->sin6_addr, &ep_data->info.addr, 16); - rai->ai_src_len = sizeof(*sin6); - rai->ai_src_addr = (struct sockaddr *) sin6; - break; - default: - break; - } - } - - rai->ai_route = calloc(path_cnt, sizeof(*path_data)); - if (rai->ai_route) { - memcpy(rai->ai_route, path_data, path_cnt * sizeof(*path_data)); - rai->ai_route_len = path_cnt * sizeof(*path_data); - } -} - -static void ucma_set_ep_addr(struct acm_ep_addr_data *data, struct sockaddr *addr) -{ - if (addr->sa_family == AF_INET) { - data->type = ACM_EP_INFO_ADDRESS_IP; - memcpy(data->info.addr, &((struct sockaddr_in *) addr)->sin_addr, 4); - } else { - data->type = ACM_EP_INFO_ADDRESS_IP6; - memcpy(data->info.addr, &((struct sockaddr_in6 *) addr)->sin6_addr, 16); - } -} - -static int ucma_inet_addr(struct sockaddr *addr, socklen_t len) -{ - return len && addr && (addr->sa_family == AF_INET || - addr->sa_family == AF_INET6); -} - -static int ucma_ib_addr(struct sockaddr *addr, socklen_t len) -{ - return len && addr && (addr->sa_family == AF_IB); -} - -void ucma_ib_resolve(struct rdma_addrinfo **rai, - const struct rdma_addrinfo *hints) -{ - struct acm_msg msg; - struct acm_ep_addr_data *data; - int ret; - - ucma_ib_init(); - if (sock < 0) - return; - - memset(&msg, 0, sizeof msg); - msg.hdr.version = ACM_VERSION; - msg.hdr.opcode = ACM_OP_RESOLVE; - msg.hdr.length = ACM_MSG_HDR_LENGTH; - - data = &msg.resolve_data[0]; - if (ucma_inet_addr((*rai)->ai_src_addr, (*rai)->ai_src_len)) { - data->flags = ACM_EP_FLAG_SOURCE; - ucma_set_ep_addr(data, (*rai)->ai_src_addr); - data++; - msg.hdr.length += ACM_MSG_EP_LENGTH; - } - - if (ucma_inet_addr((*rai)->ai_dst_addr, (*rai)->ai_dst_len)) { - data->flags = ACM_EP_FLAG_DEST; - if (hints->ai_flags & (RAI_NUMERICHOST | RAI_NOROUTE)) - data->flags |= ACM_FLAGS_NODELAY; - ucma_set_ep_addr(data, (*rai)->ai_dst_addr); - data++; - msg.hdr.length += ACM_MSG_EP_LENGTH; - } - - if (hints->ai_route_len || - ucma_ib_addr((*rai)->ai_src_addr, (*rai)->ai_src_len) || - ucma_ib_addr((*rai)->ai_dst_addr, (*rai)->ai_dst_len)) { - struct ibv_path_record *path; - - if (hints->ai_route_len == sizeof(struct ibv_path_record)) - path = (struct ibv_path_record *) hints->ai_route; - else if (hints->ai_route_len == sizeof(struct ibv_path_data)) - path = &((struct ibv_path_data *) hints->ai_route)->path; - else - path = NULL; - - if (path) - memcpy(&data->info.path, path, sizeof(*path)); - - if (ucma_ib_addr((*rai)->ai_src_addr, (*rai)->ai_src_len)) { - memcpy(&data->info.path.sgid, - &((struct sockaddr_ib *) (*rai)->ai_src_addr)->sib_addr, 16); - } - if (ucma_ib_addr((*rai)->ai_dst_addr, (*rai)->ai_dst_len)) { - memcpy(&data->info.path.dgid, - &((struct sockaddr_ib *) (*rai)->ai_dst_addr)->sib_addr, 16); - } - data->type = ACM_EP_INFO_PATH; - data++; - msg.hdr.length += ACM_MSG_EP_LENGTH; - } - - pthread_mutex_lock(&acm_lock); - ret = send(sock, (char *) &msg, msg.hdr.length, 0); - if (ret != msg.hdr.length) { - pthread_mutex_unlock(&acm_lock); - return; - } - - ret = recv(sock, (char *) &msg, sizeof msg, 0); - pthread_mutex_unlock(&acm_lock); - if (ret < ACM_MSG_HDR_LENGTH || ret != msg.hdr.length || msg.hdr.status) - return; - - ucma_ib_save_resp(*rai, &msg); - - if (af_ib_support && !(hints->ai_flags & RAI_ROUTEONLY) && (*rai)->ai_route_len) - ucma_resolve_af_ib(rai); -} diff --git a/usr/rdma-core/librdmacm/addrinfo.c b/usr/rdma-core/librdmacm/addrinfo.c deleted file mode 100644 index 7e6606592..000000000 --- a/usr/rdma-core/librdmacm/addrinfo.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2010-2014 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id: cm.c 3453 2005-09-15 21:43:21Z sean.hefty $ - */ - -#include - -#include -#include -#include -#include - -#include "cma.h" -#include -#include - -static struct rdma_addrinfo nohints; - -static void ucma_convert_to_ai(struct addrinfo *ai, - const struct rdma_addrinfo *rai) -{ - memset(ai, 0, sizeof(*ai)); - if (rai->ai_flags & RAI_PASSIVE) - ai->ai_flags = AI_PASSIVE; - if (rai->ai_flags & RAI_NUMERICHOST) - ai->ai_flags |= AI_NUMERICHOST; - if (rai->ai_family != AF_IB) - ai->ai_family = rai->ai_family; - - switch (rai->ai_qp_type) { - case IBV_QPT_RC: - case IBV_QPT_UC: - case IBV_QPT_XRC_SEND: - case IBV_QPT_XRC_RECV: - ai->ai_socktype = SOCK_STREAM; - break; - case IBV_QPT_UD: - ai->ai_socktype = SOCK_DGRAM; - break; - } - - switch (rai->ai_port_space) { - case RDMA_PS_TCP: - ai->ai_protocol = IPPROTO_TCP; - break; - case RDMA_PS_IPOIB: - case RDMA_PS_UDP: - ai->ai_protocol = IPPROTO_UDP; - break; - case RDMA_PS_IB: - if (ai->ai_socktype == SOCK_STREAM) - ai->ai_protocol = IPPROTO_TCP; - else if (ai->ai_socktype == SOCK_DGRAM) - ai->ai_protocol = IPPROTO_UDP; - break; - } - - if (rai->ai_flags & RAI_PASSIVE) { - ai->ai_addrlen = rai->ai_src_len; - ai->ai_addr = rai->ai_src_addr; - } else { - ai->ai_addrlen = rai->ai_dst_len; - ai->ai_addr = rai->ai_dst_addr; - } - ai->ai_canonname = rai->ai_dst_canonname; - ai->ai_next = NULL; -} - -static int ucma_copy_addr(struct sockaddr **dst, socklen_t *dst_len, - struct sockaddr *src, socklen_t src_len) -{ - *dst = malloc(src_len); - if (!(*dst)) - return ERR(ENOMEM); - - memcpy(*dst, src, src_len); - *dst_len = src_len; - return 0; -} - -void ucma_set_sid(enum rdma_port_space ps, struct sockaddr *addr, - struct sockaddr_ib *sib) -{ - __be16 port; - - port = addr ? ucma_get_port(addr) : 0; - sib->sib_sid = htobe64(((uint64_t) ps << 16) + be16toh(port)); - - if (ps) - sib->sib_sid_mask = htobe64(RDMA_IB_IP_PS_MASK); - if (port) - sib->sib_sid_mask |= htobe64(RDMA_IB_IP_PORT_MASK); -} - -static int ucma_convert_in6(int ps, struct sockaddr_ib **dst, socklen_t *dst_len, - struct sockaddr_in6 *src, socklen_t src_len) -{ - *dst = calloc(1, sizeof(struct sockaddr_ib)); - if (!(*dst)) - return ERR(ENOMEM); - - (*dst)->sib_family = AF_IB; - (*dst)->sib_pkey = htobe16(0xFFFF); - (*dst)->sib_flowinfo = src->sin6_flowinfo; - ib_addr_set(&(*dst)->sib_addr, src->sin6_addr.s6_addr32[0], - src->sin6_addr.s6_addr32[1], src->sin6_addr.s6_addr32[2], - src->sin6_addr.s6_addr32[3]); - ucma_set_sid(ps, (struct sockaddr *) src, *dst); - (*dst)->sib_scope_id = src->sin6_scope_id; - - *dst_len = sizeof(struct sockaddr_ib); - return 0; -} - -static int ucma_convert_to_rai(struct rdma_addrinfo *rai, - const struct rdma_addrinfo *hints, - const struct addrinfo *ai) -{ - int ret; - - if (hints->ai_qp_type) { - rai->ai_qp_type = hints->ai_qp_type; - } else { - switch (ai->ai_socktype) { - case SOCK_STREAM: - rai->ai_qp_type = IBV_QPT_RC; - break; - case SOCK_DGRAM: - rai->ai_qp_type = IBV_QPT_UD; - break; - } - } - - if (hints->ai_port_space) { - rai->ai_port_space = hints->ai_port_space; - } else { - switch (ai->ai_protocol) { - case IPPROTO_TCP: - rai->ai_port_space = RDMA_PS_TCP; - break; - case IPPROTO_UDP: - rai->ai_port_space = RDMA_PS_UDP; - break; - } - } - - if (ai->ai_flags & AI_PASSIVE) { - rai->ai_flags = RAI_PASSIVE; - if (ai->ai_canonname) - rai->ai_src_canonname = strdup(ai->ai_canonname); - - if ((hints->ai_flags & RAI_FAMILY) && (hints->ai_family == AF_IB) && - (hints->ai_flags & RAI_NUMERICHOST)) { - rai->ai_family = AF_IB; - ret = ucma_convert_in6(rai->ai_port_space, - (struct sockaddr_ib **) &rai->ai_src_addr, - &rai->ai_src_len, - (struct sockaddr_in6 *) ai->ai_addr, - ai->ai_addrlen); - } else { - rai->ai_family = ai->ai_family; - ret = ucma_copy_addr(&rai->ai_src_addr, &rai->ai_src_len, - ai->ai_addr, ai->ai_addrlen); - } - } else { - if (ai->ai_canonname) - rai->ai_dst_canonname = strdup(ai->ai_canonname); - - if ((hints->ai_flags & RAI_FAMILY) && (hints->ai_family == AF_IB) && - (hints->ai_flags & RAI_NUMERICHOST)) { - rai->ai_family = AF_IB; - ret = ucma_convert_in6(rai->ai_port_space, - (struct sockaddr_ib **) &rai->ai_dst_addr, - &rai->ai_dst_len, - (struct sockaddr_in6 *) ai->ai_addr, - ai->ai_addrlen); - } else { - rai->ai_family = ai->ai_family; - ret = ucma_copy_addr(&rai->ai_dst_addr, &rai->ai_dst_len, - ai->ai_addr, ai->ai_addrlen); - } - } - return ret; -} - -static int ucma_getaddrinfo(const char *node, const char *service, - const struct rdma_addrinfo *hints, - struct rdma_addrinfo *rai) -{ - struct addrinfo ai_hints; - struct addrinfo *ai; - int ret; - - if (hints != &nohints) { - ucma_convert_to_ai(&ai_hints, hints); - ret = getaddrinfo(node, service, &ai_hints, &ai); - } else { - ret = getaddrinfo(node, service, NULL, &ai); - } - if (ret) - return ret; - - ret = ucma_convert_to_rai(rai, hints, ai); - freeaddrinfo(ai); - return ret; -} - -int rdma_getaddrinfo(const char *node, const char *service, - const struct rdma_addrinfo *hints, - struct rdma_addrinfo **res) -{ - struct rdma_addrinfo *rai; - int ret; - - if (!service && !node && !hints) - return ERR(EINVAL); - - ret = ucma_init(); - if (ret) - return ret; - - rai = calloc(1, sizeof(*rai)); - if (!rai) - return ERR(ENOMEM); - - if (!hints) - hints = &nohints; - - if (node || service) { - ret = ucma_getaddrinfo(node, service, hints, rai); - } else { - rai->ai_flags = hints->ai_flags; - rai->ai_family = hints->ai_family; - rai->ai_qp_type = hints->ai_qp_type; - rai->ai_port_space = hints->ai_port_space; - if (hints->ai_dst_len) { - ret = ucma_copy_addr(&rai->ai_dst_addr, &rai->ai_dst_len, - hints->ai_dst_addr, hints->ai_dst_len); - } - } - if (ret) - goto err; - - if (!rai->ai_src_len && hints->ai_src_len) { - ret = ucma_copy_addr(&rai->ai_src_addr, &rai->ai_src_len, - hints->ai_src_addr, hints->ai_src_len); - if (ret) - goto err; - } - - if (!(rai->ai_flags & RAI_PASSIVE)) - ucma_ib_resolve(&rai, hints); - - *res = rai; - return 0; - -err: - rdma_freeaddrinfo(rai); - return ret; -} - -void rdma_freeaddrinfo(struct rdma_addrinfo *res) -{ - struct rdma_addrinfo *rai; - - while (res) { - rai = res; - res = res->ai_next; - - if (rai->ai_connect) - free(rai->ai_connect); - - if (rai->ai_route) - free(rai->ai_route); - - if (rai->ai_src_canonname) - free(rai->ai_src_canonname); - - if (rai->ai_dst_canonname) - free(rai->ai_dst_canonname); - - if (rai->ai_src_addr) - free(rai->ai_src_addr); - - if (rai->ai_dst_addr) - free(rai->ai_dst_addr); - - free(rai); - } -} diff --git a/usr/rdma-core/librdmacm/cma.c b/usr/rdma-core/librdmacm/cma.c deleted file mode 100644 index 7aaf45f2c..000000000 --- a/usr/rdma-core/librdmacm/cma.c +++ /dev/null @@ -1,2460 +0,0 @@ -/* - * Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cma.h" -#include "indexer.h" -#include -#include -#include -#include -#include -#include - -#define CMA_INIT_CMD(req, req_size, op) \ -do { \ - memset(req, 0, req_size); \ - (req)->cmd = UCMA_CMD_##op; \ - (req)->in = req_size - sizeof(struct ucma_abi_cmd_hdr); \ -} while (0) - -#define CMA_INIT_CMD_RESP(req, req_size, op, resp, resp_size) \ -do { \ - CMA_INIT_CMD(req, req_size, op); \ - (req)->out = resp_size; \ - (req)->response = (uintptr_t) (resp); \ -} while (0) - -struct cma_port { - uint8_t link_layer; -}; - -struct cma_device { - struct ibv_context *verbs; - struct ibv_pd *pd; - struct ibv_xrcd *xrcd; - struct cma_port *port; - __be64 guid; - int port_cnt; - int refcnt; - int max_qpsize; - uint8_t max_initiator_depth; - uint8_t max_responder_resources; -}; - -struct cma_id_private { - struct rdma_cm_id id; - struct cma_device *cma_dev; - void *connect; - size_t connect_len; - int events_completed; - int connect_error; - int sync; - pthread_cond_t cond; - pthread_mutex_t mut; - uint32_t handle; - struct cma_multicast *mc_list; - struct ibv_qp_init_attr *qp_init_attr; - uint8_t initiator_depth; - uint8_t responder_resources; -}; - -struct cma_multicast { - struct cma_multicast *next; - struct cma_id_private *id_priv; - void *context; - int events_completed; - pthread_cond_t cond; - uint32_t handle; - union ibv_gid mgid; - uint16_t mlid; - struct sockaddr_storage addr; -}; - -struct cma_event { - struct rdma_cm_event event; - uint8_t private_data[RDMA_MAX_PRIVATE_DATA]; - struct cma_id_private *id_priv; - struct cma_multicast *mc; -}; - -static struct cma_device *cma_dev_array; -static int cma_dev_cnt; -static int cma_init_cnt; -static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; -static int abi_ver = RDMA_USER_CM_MAX_ABI_VERSION; -int af_ib_support; -static struct index_map ucma_idm; -static fastlock_t idm_lock; - -static int check_abi_version(void) -{ - char value[8]; - - if ((ibv_read_sysfs_file(ibv_get_sysfs_path(), - "class/misc/rdma_cm/abi_version", - value, sizeof value) < 0) && - (ibv_read_sysfs_file(ibv_get_sysfs_path(), - "class/infiniband_ucma/abi_version", - value, sizeof value) < 0)) { - /* - * Older version of Linux do not have class/misc. To support - * backports, assume the most recent version of the ABI. If - * we're wrong, we'll simply fail later when calling the ABI. - */ - return 0; - } - - abi_ver = strtol(value, NULL, 10); - if (abi_ver < RDMA_USER_CM_MIN_ABI_VERSION || - abi_ver > RDMA_USER_CM_MAX_ABI_VERSION) { - return -1; - } - return 0; -} - -/* - * This function is called holding the mutex lock - * cma_dev_cnt must be set before calling this function to - * ensure that the lock is not acquired recursively. - */ -static void ucma_set_af_ib_support(void) -{ - struct rdma_cm_id *id; - struct sockaddr_ib sib; - int ret; - - ret = rdma_create_id(NULL, &id, NULL, RDMA_PS_IB); - if (ret) - return; - - memset(&sib, 0, sizeof sib); - sib.sib_family = AF_IB; - sib.sib_sid = htobe64(RDMA_IB_IP_PS_TCP); - sib.sib_sid_mask = htobe64(RDMA_IB_IP_PS_MASK); - af_ib_support = 1; - ret = rdma_bind_addr(id, (struct sockaddr *) &sib); - af_ib_support = !ret; - - rdma_destroy_id(id); -} - -int ucma_init(void) -{ - struct ibv_device **dev_list = NULL; - int i, ret, dev_cnt; - - /* Quick check without lock to see if we're already initialized */ - if (cma_dev_cnt) - return 0; - - pthread_mutex_lock(&mut); - if (cma_dev_cnt) { - pthread_mutex_unlock(&mut); - return 0; - } - - fastlock_init(&idm_lock); - ret = check_abi_version(); - if (ret) - goto err1; - - dev_list = ibv_get_device_list(&dev_cnt); - if (!dev_list) { - ret = ERR(ENODEV); - goto err1; - } - - if (!dev_cnt) { - ret = ERR(ENODEV); - goto err2; - } - - cma_dev_array = calloc(dev_cnt, sizeof(*cma_dev_array)); - if (!cma_dev_array) { - ret = ERR(ENOMEM); - goto err2; - } - - for (i = 0; dev_list[i]; i++) - cma_dev_array[i].guid = ibv_get_device_guid(dev_list[i]); - - cma_dev_cnt = dev_cnt; - ucma_set_af_ib_support(); - pthread_mutex_unlock(&mut); - ibv_free_device_list(dev_list); - return 0; - -err2: - ibv_free_device_list(dev_list); -err1: - fastlock_destroy(&idm_lock); - pthread_mutex_unlock(&mut); - return ret; -} - -static struct ibv_context *ucma_open_device(__be64 guid) -{ - struct ibv_device **dev_list; - struct ibv_context *verbs = NULL; - int i; - - dev_list = ibv_get_device_list(NULL); - if (!dev_list) { - return NULL; - } - - for (i = 0; dev_list[i]; i++) { - if (ibv_get_device_guid(dev_list[i]) == guid) { - verbs = ibv_open_device(dev_list[i]); - break; - } - } - - ibv_free_device_list(dev_list); - return verbs; -} - -static int ucma_init_device(struct cma_device *cma_dev) -{ - struct ibv_port_attr port_attr; - struct ibv_device_attr attr; - int i, ret; - - if (cma_dev->verbs) - return 0; - - cma_dev->verbs = ucma_open_device(cma_dev->guid); - if (!cma_dev->verbs) - return ERR(ENODEV); - - ret = ibv_query_device(cma_dev->verbs, &attr); - if (ret) { - ret = ERR(ret); - goto err; - } - - cma_dev->port = malloc(sizeof(*cma_dev->port) * attr.phys_port_cnt); - if (!cma_dev->port) { - ret = ERR(ENOMEM); - goto err; - } - - for (i = 1; i <= attr.phys_port_cnt; i++) { - if (ibv_query_port(cma_dev->verbs, i, &port_attr)) - cma_dev->port[i - 1].link_layer = IBV_LINK_LAYER_UNSPECIFIED; - else - cma_dev->port[i - 1].link_layer = port_attr.link_layer; - } - - cma_dev->port_cnt = attr.phys_port_cnt; - cma_dev->max_qpsize = attr.max_qp_wr; - cma_dev->max_initiator_depth = (uint8_t) attr.max_qp_init_rd_atom; - cma_dev->max_responder_resources = (uint8_t) attr.max_qp_rd_atom; - cma_init_cnt++; - return 0; - -err: - ibv_close_device(cma_dev->verbs); - cma_dev->verbs = NULL; - return ret; -} - -static int ucma_init_all(void) -{ - int i, ret = 0; - - if (!cma_dev_cnt) { - ret = ucma_init(); - if (ret) - return ret; - } - - if (cma_init_cnt == cma_dev_cnt) - return 0; - - pthread_mutex_lock(&mut); - for (i = 0; i < cma_dev_cnt; i++) { - ret = ucma_init_device(&cma_dev_array[i]); - if (ret) - break; - } - pthread_mutex_unlock(&mut); - return ret; -} - -struct ibv_context **rdma_get_devices(int *num_devices) -{ - struct ibv_context **devs = NULL; - int i; - - if (ucma_init_all()) - goto out; - - devs = malloc(sizeof(*devs) * (cma_dev_cnt + 1)); - if (!devs) - goto out; - - for (i = 0; i < cma_dev_cnt; i++) - devs[i] = cma_dev_array[i].verbs; - devs[i] = NULL; -out: - if (num_devices) - *num_devices = devs ? cma_dev_cnt : 0; - return devs; -} - -void rdma_free_devices(struct ibv_context **list) -{ - free(list); -} - -struct rdma_event_channel *rdma_create_event_channel(void) -{ - struct rdma_event_channel *channel; - - if (ucma_init()) - return NULL; - - channel = malloc(sizeof(*channel)); - if (!channel) - return NULL; - - channel->fd = open("/dev/infiniband/rdma_cm", O_RDWR | O_CLOEXEC); - if (channel->fd < 0) { - goto err; - } - return channel; -err: - free(channel); - return NULL; -} - -void rdma_destroy_event_channel(struct rdma_event_channel *channel) -{ - close(channel->fd); - free(channel); -} - -static int ucma_get_device(struct cma_id_private *id_priv, __be64 guid) -{ - struct cma_device *cma_dev; - int i, ret; - - for (i = 0; i < cma_dev_cnt; i++) { - cma_dev = &cma_dev_array[i]; - if (cma_dev->guid == guid) - goto match; - } - - return ERR(ENODEV); -match: - pthread_mutex_lock(&mut); - if ((ret = ucma_init_device(cma_dev))) - goto out; - - if (!cma_dev->refcnt++) { - cma_dev->pd = ibv_alloc_pd(cma_dev->verbs); - if (!cma_dev->pd) { - cma_dev->refcnt--; - ret = ERR(ENOMEM); - goto out; - } - } - id_priv->cma_dev = cma_dev; - id_priv->id.verbs = cma_dev->verbs; - id_priv->id.pd = cma_dev->pd; -out: - pthread_mutex_unlock(&mut); - return ret; -} - -static void ucma_put_device(struct cma_device *cma_dev) -{ - pthread_mutex_lock(&mut); - if (!--cma_dev->refcnt) { - ibv_dealloc_pd(cma_dev->pd); - if (cma_dev->xrcd) - ibv_close_xrcd(cma_dev->xrcd); - } - pthread_mutex_unlock(&mut); -} - -static struct ibv_xrcd *ucma_get_xrcd(struct cma_device *cma_dev) -{ - struct ibv_xrcd_init_attr attr; - - pthread_mutex_lock(&mut); - if (!cma_dev->xrcd) { - memset(&attr, 0, sizeof attr); - attr.comp_mask = IBV_XRCD_INIT_ATTR_FD | IBV_XRCD_INIT_ATTR_OFLAGS; - attr.fd = -1; - attr.oflags = O_CREAT; - cma_dev->xrcd = ibv_open_xrcd(cma_dev->verbs, &attr); - } - pthread_mutex_unlock(&mut); - return cma_dev->xrcd; -} - -static void ucma_insert_id(struct cma_id_private *id_priv) -{ - fastlock_acquire(&idm_lock); - idm_set(&ucma_idm, id_priv->handle, id_priv); - fastlock_release(&idm_lock); -} - -static void ucma_remove_id(struct cma_id_private *id_priv) -{ - if (id_priv->handle <= IDX_MAX_INDEX) - idm_clear(&ucma_idm, id_priv->handle); -} - -static struct cma_id_private *ucma_lookup_id(int handle) -{ - return idm_lookup(&ucma_idm, handle); -} - -static void ucma_free_id(struct cma_id_private *id_priv) -{ - ucma_remove_id(id_priv); - if (id_priv->cma_dev) - ucma_put_device(id_priv->cma_dev); - pthread_cond_destroy(&id_priv->cond); - pthread_mutex_destroy(&id_priv->mut); - if (id_priv->id.route.path_rec) - free(id_priv->id.route.path_rec); - - if (id_priv->sync) - rdma_destroy_event_channel(id_priv->id.channel); - if (id_priv->connect_len) - free(id_priv->connect); - free(id_priv); -} - -static struct cma_id_private *ucma_alloc_id(struct rdma_event_channel *channel, - void *context, - enum rdma_port_space ps, - enum ibv_qp_type qp_type) -{ - struct cma_id_private *id_priv; - - id_priv = calloc(1, sizeof(*id_priv)); - if (!id_priv) - return NULL; - - id_priv->id.context = context; - id_priv->id.ps = ps; - id_priv->id.qp_type = qp_type; - id_priv->handle = 0xFFFFFFFF; - - if (!channel) { - id_priv->id.channel = rdma_create_event_channel(); - if (!id_priv->id.channel) - goto err; - id_priv->sync = 1; - } else { - id_priv->id.channel = channel; - } - - pthread_mutex_init(&id_priv->mut, NULL); - if (pthread_cond_init(&id_priv->cond, NULL)) - goto err; - - return id_priv; - -err: ucma_free_id(id_priv); - return NULL; -} - -static int rdma_create_id2(struct rdma_event_channel *channel, - struct rdma_cm_id **id, void *context, - enum rdma_port_space ps, enum ibv_qp_type qp_type) -{ - struct ucma_abi_create_id_resp resp; - struct ucma_abi_create_id cmd; - struct cma_id_private *id_priv; - int ret; - - ret = ucma_init(); - if (ret) - return ret; - - id_priv = ucma_alloc_id(channel, context, ps, qp_type); - if (!id_priv) - return ERR(ENOMEM); - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_ID, &resp, sizeof resp); - cmd.uid = (uintptr_t) id_priv; - cmd.ps = ps; - cmd.qp_type = qp_type; - - ret = write(id_priv->id.channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - goto err; - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - id_priv->handle = resp.id; - ucma_insert_id(id_priv); - *id = &id_priv->id; - return 0; - -err: ucma_free_id(id_priv); - return ret; -} - -int rdma_create_id(struct rdma_event_channel *channel, - struct rdma_cm_id **id, void *context, - enum rdma_port_space ps) -{ - enum ibv_qp_type qp_type; - - qp_type = (ps == RDMA_PS_IPOIB || ps == RDMA_PS_UDP) ? - IBV_QPT_UD : IBV_QPT_RC; - return rdma_create_id2(channel, id, context, ps, qp_type); -} - -static int ucma_destroy_kern_id(int fd, uint32_t handle) -{ - struct ucma_abi_destroy_id_resp resp; - struct ucma_abi_destroy_id cmd; - int ret; - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_ID, &resp, sizeof resp); - cmd.id = handle; - - ret = write(fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - return resp.events_reported; -} - -int rdma_destroy_id(struct rdma_cm_id *id) -{ - struct cma_id_private *id_priv; - int ret; - - id_priv = container_of(id, struct cma_id_private, id); - ret = ucma_destroy_kern_id(id->channel->fd, id_priv->handle); - if (ret < 0) - return ret; - - if (id_priv->id.event) - rdma_ack_cm_event(id_priv->id.event); - - pthread_mutex_lock(&id_priv->mut); - while (id_priv->events_completed < ret) - pthread_cond_wait(&id_priv->cond, &id_priv->mut); - pthread_mutex_unlock(&id_priv->mut); - - ucma_free_id(id_priv); - return 0; -} - -int ucma_addrlen(struct sockaddr *addr) -{ - if (!addr) - return 0; - - switch (addr->sa_family) { - case PF_INET: - return sizeof(struct sockaddr_in); - case PF_INET6: - return sizeof(struct sockaddr_in6); - case PF_IB: - return af_ib_support ? sizeof(struct sockaddr_ib) : 0; - default: - return 0; - } -} - -static int ucma_query_addr(struct rdma_cm_id *id) -{ - struct ucma_abi_query_addr_resp resp; - struct ucma_abi_query cmd; - struct cma_id_private *id_priv; - int ret; - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY, &resp, sizeof resp); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - cmd.option = UCMA_QUERY_ADDR; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - memcpy(&id->route.addr.src_addr, &resp.src_addr, resp.src_size); - memcpy(&id->route.addr.dst_addr, &resp.dst_addr, resp.dst_size); - - if (!id_priv->cma_dev && resp.node_guid) { - ret = ucma_get_device(id_priv, resp.node_guid); - if (ret) - return ret; - id->port_num = resp.port_num; - id->route.addr.addr.ibaddr.pkey = resp.pkey; - } - - return 0; -} - -static int ucma_query_gid(struct rdma_cm_id *id) -{ - struct ucma_abi_query_addr_resp resp; - struct ucma_abi_query cmd; - struct cma_id_private *id_priv; - struct sockaddr_ib *sib; - int ret; - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY, &resp, sizeof resp); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - cmd.option = UCMA_QUERY_GID; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - sib = (struct sockaddr_ib *) &resp.src_addr; - memcpy(id->route.addr.addr.ibaddr.sgid.raw, sib->sib_addr.sib_raw, - sizeof id->route.addr.addr.ibaddr.sgid); - - sib = (struct sockaddr_ib *) &resp.dst_addr; - memcpy(id->route.addr.addr.ibaddr.dgid.raw, sib->sib_addr.sib_raw, - sizeof id->route.addr.addr.ibaddr.dgid); - - return 0; -} - -static void ucma_convert_path(struct ibv_path_data *path_data, - struct ibv_sa_path_rec *sa_path) -{ - uint32_t fl_hop; - - sa_path->dgid = path_data->path.dgid; - sa_path->sgid = path_data->path.sgid; - sa_path->dlid = path_data->path.dlid; - sa_path->slid = path_data->path.slid; - sa_path->raw_traffic = 0; - - fl_hop = be32toh(path_data->path.flowlabel_hoplimit); - sa_path->flow_label = htobe32(fl_hop >> 8); - sa_path->hop_limit = (uint8_t) fl_hop; - - sa_path->traffic_class = path_data->path.tclass; - sa_path->reversible = path_data->path.reversible_numpath >> 7; - sa_path->numb_path = 1; - sa_path->pkey = path_data->path.pkey; - sa_path->sl = be16toh(path_data->path.qosclass_sl) & 0xF; - sa_path->mtu_selector = 2; /* exactly */ - sa_path->mtu = path_data->path.mtu & 0x1F; - sa_path->rate_selector = 2; - sa_path->rate = path_data->path.rate & 0x1F; - sa_path->packet_life_time_selector = 2; - sa_path->packet_life_time = path_data->path.packetlifetime & 0x1F; - - sa_path->preference = (uint8_t) path_data->flags; -} - -static int ucma_query_path(struct rdma_cm_id *id) -{ - struct ucma_abi_query_path_resp *resp; - struct ucma_abi_query cmd; - struct cma_id_private *id_priv; - int ret, i, size; - - size = sizeof(*resp) + sizeof(struct ibv_path_data) * 6; - resp = alloca(size); - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY, resp, size); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - cmd.option = UCMA_QUERY_PATH; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - VALGRIND_MAKE_MEM_DEFINED(resp, size); - - if (resp->num_paths) { - id->route.path_rec = malloc(sizeof(*id->route.path_rec) * - resp->num_paths); - if (!id->route.path_rec) - return ERR(ENOMEM); - - id->route.num_paths = resp->num_paths; - for (i = 0; i < resp->num_paths; i++) - ucma_convert_path(&resp->path_data[i], &id->route.path_rec[i]); - } - - return 0; -} - -static int ucma_query_route(struct rdma_cm_id *id) -{ - struct ucma_abi_query_route_resp resp; - struct ucma_abi_query cmd; - struct cma_id_private *id_priv; - int ret, i; - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY_ROUTE, &resp, sizeof resp); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - if (resp.num_paths) { - id->route.path_rec = malloc(sizeof(*id->route.path_rec) * - resp.num_paths); - if (!id->route.path_rec) - return ERR(ENOMEM); - - id->route.num_paths = resp.num_paths; - for (i = 0; i < resp.num_paths; i++) - ibv_copy_path_rec_from_kern(&id->route.path_rec[i], - &resp.ib_route[i]); - } - - memcpy(id->route.addr.addr.ibaddr.sgid.raw, resp.ib_route[0].sgid, - sizeof id->route.addr.addr.ibaddr.sgid); - memcpy(id->route.addr.addr.ibaddr.dgid.raw, resp.ib_route[0].dgid, - sizeof id->route.addr.addr.ibaddr.dgid); - id->route.addr.addr.ibaddr.pkey = resp.ib_route[0].pkey; - memcpy(&id->route.addr.src_addr, &resp.src_addr, - sizeof resp.src_addr); - memcpy(&id->route.addr.dst_addr, &resp.dst_addr, - sizeof resp.dst_addr); - - if (!id_priv->cma_dev && resp.node_guid) { - ret = ucma_get_device(id_priv, resp.node_guid); - if (ret) - return ret; - id_priv->id.port_num = resp.port_num; - } - - return 0; -} - -static int rdma_bind_addr2(struct rdma_cm_id *id, struct sockaddr *addr, - socklen_t addrlen) -{ - struct ucma_abi_bind cmd; - struct cma_id_private *id_priv; - int ret; - - CMA_INIT_CMD(&cmd, sizeof cmd, BIND); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - cmd.addr_size = addrlen; - memcpy(&cmd.addr, addr, addrlen); - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - ret = ucma_query_addr(id); - if (!ret) - ret = ucma_query_gid(id); - return ret; -} - -int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) -{ - struct ucma_abi_bind_ip cmd; - struct cma_id_private *id_priv; - int ret, addrlen; - - addrlen = ucma_addrlen(addr); - if (!addrlen) - return ERR(EINVAL); - - if (af_ib_support) - return rdma_bind_addr2(id, addr, addrlen); - - CMA_INIT_CMD(&cmd, sizeof cmd, BIND_IP); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - memcpy(&cmd.addr, addr, addrlen); - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - return ucma_query_route(id); -} - -int ucma_complete(struct rdma_cm_id *id) -{ - struct cma_id_private *id_priv; - int ret; - - id_priv = container_of(id, struct cma_id_private, id); - if (!id_priv->sync) - return 0; - - if (id_priv->id.event) { - rdma_ack_cm_event(id_priv->id.event); - id_priv->id.event = NULL; - } - - ret = rdma_get_cm_event(id_priv->id.channel, &id_priv->id.event); - if (ret) - return ret; - - if (id_priv->id.event->status) { - if (id_priv->id.event->event == RDMA_CM_EVENT_REJECTED) - ret = ERR(ECONNREFUSED); - else if (id_priv->id.event->status < 0) - ret = ERR(-id_priv->id.event->status); - else - ret = ERR(-id_priv->id.event->status); - } - return ret; -} - -static int rdma_resolve_addr2(struct rdma_cm_id *id, struct sockaddr *src_addr, - socklen_t src_len, struct sockaddr *dst_addr, - socklen_t dst_len, int timeout_ms) -{ - struct ucma_abi_resolve_addr cmd; - struct cma_id_private *id_priv; - int ret; - - CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_ADDR); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - if ((cmd.src_size = src_len)) - memcpy(&cmd.src_addr, src_addr, src_len); - memcpy(&cmd.dst_addr, dst_addr, dst_len); - cmd.dst_size = dst_len; - cmd.timeout_ms = timeout_ms; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - memcpy(&id->route.addr.dst_addr, dst_addr, dst_len); - return ucma_complete(id); -} - -int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, - struct sockaddr *dst_addr, int timeout_ms) -{ - struct ucma_abi_resolve_ip cmd; - struct cma_id_private *id_priv; - int ret, dst_len, src_len; - - dst_len = ucma_addrlen(dst_addr); - if (!dst_len) - return ERR(EINVAL); - - src_len = ucma_addrlen(src_addr); - if (src_addr && !src_len) - return ERR(EINVAL); - - if (af_ib_support) - return rdma_resolve_addr2(id, src_addr, src_len, dst_addr, - dst_len, timeout_ms); - - CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_IP); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - if (src_addr) - memcpy(&cmd.src_addr, src_addr, src_len); - memcpy(&cmd.dst_addr, dst_addr, dst_len); - cmd.timeout_ms = timeout_ms; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - memcpy(&id->route.addr.dst_addr, dst_addr, dst_len); - return ucma_complete(id); -} - -static int ucma_set_ib_route(struct rdma_cm_id *id) -{ - struct rdma_addrinfo hint, *rai; - int ret; - - memset(&hint, 0, sizeof hint); - hint.ai_flags = RAI_ROUTEONLY; - hint.ai_family = id->route.addr.src_addr.sa_family; - hint.ai_src_len = ucma_addrlen((struct sockaddr *) &id->route.addr.src_addr); - hint.ai_src_addr = &id->route.addr.src_addr; - hint.ai_dst_len = ucma_addrlen((struct sockaddr *) &id->route.addr.dst_addr); - hint.ai_dst_addr = &id->route.addr.dst_addr; - - ret = rdma_getaddrinfo(NULL, NULL, &hint, &rai); - if (ret) - return ret; - - if (rai->ai_route_len) - ret = rdma_set_option(id, RDMA_OPTION_IB, RDMA_OPTION_IB_PATH, - rai->ai_route, rai->ai_route_len); - else - ret = -1; - - rdma_freeaddrinfo(rai); - return ret; -} - -int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms) -{ - struct ucma_abi_resolve_route cmd; - struct cma_id_private *id_priv; - int ret; - - id_priv = container_of(id, struct cma_id_private, id); - if (id->verbs->device->transport_type == IBV_TRANSPORT_IB) { - ret = ucma_set_ib_route(id); - if (!ret) - goto out; - } - - CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_ROUTE); - cmd.id = id_priv->handle; - cmd.timeout_ms = timeout_ms; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - -out: - return ucma_complete(id); -} - -static int ucma_is_ud_qp(enum ibv_qp_type qp_type) -{ - return (qp_type == IBV_QPT_UD); -} - -static int rdma_init_qp_attr(struct rdma_cm_id *id, struct ibv_qp_attr *qp_attr, - int *qp_attr_mask) -{ - struct ucma_abi_init_qp_attr cmd; - struct ibv_kern_qp_attr resp; - struct cma_id_private *id_priv; - int ret; - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, INIT_QP_ATTR, &resp, sizeof resp); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - cmd.qp_state = qp_attr->qp_state; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - ibv_copy_qp_attr_from_kern(qp_attr, &resp); - *qp_attr_mask = resp.qp_attr_mask; - return 0; -} - -static int ucma_modify_qp_rtr(struct rdma_cm_id *id, uint8_t resp_res) -{ - struct cma_id_private *id_priv; - struct ibv_qp_attr qp_attr; - int qp_attr_mask, ret; - uint8_t link_layer; - - if (!id->qp) - return ERR(EINVAL); - - /* Need to update QP attributes from default values. */ - qp_attr.qp_state = IBV_QPS_INIT; - ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask); - if (ret) - return ret; - - ret = ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask); - if (ret) - return ERR(ret); - - qp_attr.qp_state = IBV_QPS_RTR; - ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask); - if (ret) - return ret; - - /* - * Workaround for rdma_ucm kernel bug: - * mask off qp_attr_mask bits 21-24 which are used for RoCE - */ - id_priv = container_of(id, struct cma_id_private, id); - link_layer = id_priv->cma_dev->port[id->port_num - 1].link_layer; - - if (link_layer == IBV_LINK_LAYER_INFINIBAND) - qp_attr_mask &= UINT_MAX ^ 0xe00000; - - if (resp_res != RDMA_MAX_RESP_RES) - qp_attr.max_dest_rd_atomic = resp_res; - return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask)); -} - -static int ucma_modify_qp_rts(struct rdma_cm_id *id, uint8_t init_depth) -{ - struct ibv_qp_attr qp_attr; - int qp_attr_mask, ret; - - qp_attr.qp_state = IBV_QPS_RTS; - ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask); - if (ret) - return ret; - - if (init_depth != RDMA_MAX_INIT_DEPTH) - qp_attr.max_rd_atomic = init_depth; - return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask)); -} - -static int ucma_modify_qp_sqd(struct rdma_cm_id *id) -{ - struct ibv_qp_attr qp_attr; - - if (!id->qp) - return 0; - - qp_attr.qp_state = IBV_QPS_SQD; - return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, IBV_QP_STATE)); -} - -static int ucma_modify_qp_err(struct rdma_cm_id *id) -{ - struct ibv_qp_attr qp_attr; - - if (!id->qp) - return 0; - - qp_attr.qp_state = IBV_QPS_ERR; - return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, IBV_QP_STATE)); -} - -static int ucma_find_pkey(struct cma_device *cma_dev, uint8_t port_num, - __be16 pkey, uint16_t *pkey_index) -{ - int ret, i; - __be16 chk_pkey; - - for (i = 0, ret = 0; !ret; i++) { - ret = ibv_query_pkey(cma_dev->verbs, port_num, i, &chk_pkey); - if (!ret && pkey == chk_pkey) { - *pkey_index = (uint16_t) i; - return 0; - } - } - return ERR(EINVAL); -} - -static int ucma_init_conn_qp3(struct cma_id_private *id_priv, struct ibv_qp *qp) -{ - struct ibv_qp_attr qp_attr; - int ret; - - ret = ucma_find_pkey(id_priv->cma_dev, id_priv->id.port_num, - id_priv->id.route.addr.addr.ibaddr.pkey, - &qp_attr.pkey_index); - if (ret) - return ret; - - qp_attr.port_num = id_priv->id.port_num; - qp_attr.qp_state = IBV_QPS_INIT; - qp_attr.qp_access_flags = 0; - - ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_ACCESS_FLAGS | - IBV_QP_PKEY_INDEX | IBV_QP_PORT); - return rdma_seterrno(ret); -} - -static int ucma_init_conn_qp(struct cma_id_private *id_priv, struct ibv_qp *qp) -{ - struct ibv_qp_attr qp_attr; - int qp_attr_mask, ret; - - if (abi_ver == 3) - return ucma_init_conn_qp3(id_priv, qp); - - qp_attr.qp_state = IBV_QPS_INIT; - ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask); - if (ret) - return ret; - - return rdma_seterrno(ibv_modify_qp(qp, &qp_attr, qp_attr_mask)); -} - -static int ucma_init_ud_qp3(struct cma_id_private *id_priv, struct ibv_qp *qp) -{ - struct ibv_qp_attr qp_attr; - int ret; - - ret = ucma_find_pkey(id_priv->cma_dev, id_priv->id.port_num, - id_priv->id.route.addr.addr.ibaddr.pkey, - &qp_attr.pkey_index); - if (ret) - return ret; - - qp_attr.port_num = id_priv->id.port_num; - qp_attr.qp_state = IBV_QPS_INIT; - qp_attr.qkey = RDMA_UDP_QKEY; - - ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_QKEY | - IBV_QP_PKEY_INDEX | IBV_QP_PORT); - if (ret) - return ERR(ret); - - qp_attr.qp_state = IBV_QPS_RTR; - ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE); - if (ret) - return ERR(ret); - - qp_attr.qp_state = IBV_QPS_RTS; - qp_attr.sq_psn = 0; - ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_SQ_PSN); - return rdma_seterrno(ret); -} - -static int ucma_init_ud_qp(struct cma_id_private *id_priv, struct ibv_qp *qp) -{ - struct ibv_qp_attr qp_attr; - int qp_attr_mask, ret; - - if (abi_ver == 3) - return ucma_init_ud_qp3(id_priv, qp); - - qp_attr.qp_state = IBV_QPS_INIT; - ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask); - if (ret) - return ret; - - ret = ibv_modify_qp(qp, &qp_attr, qp_attr_mask); - if (ret) - return ERR(ret); - - qp_attr.qp_state = IBV_QPS_RTR; - ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE); - if (ret) - return ERR(ret); - - qp_attr.qp_state = IBV_QPS_RTS; - qp_attr.sq_psn = 0; - ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_SQ_PSN); - return rdma_seterrno(ret); -} - -static void ucma_destroy_cqs(struct rdma_cm_id *id) -{ - if (id->qp_type == IBV_QPT_XRC_RECV && id->srq) - return; - - if (id->recv_cq) { - ibv_destroy_cq(id->recv_cq); - if (id->send_cq && (id->send_cq != id->recv_cq)) { - ibv_destroy_cq(id->send_cq); - id->send_cq = NULL; - } - id->recv_cq = NULL; - } - - if (id->recv_cq_channel) { - ibv_destroy_comp_channel(id->recv_cq_channel); - if (id->send_cq_channel && (id->send_cq_channel != id->recv_cq_channel)) { - ibv_destroy_comp_channel(id->send_cq_channel); - id->send_cq_channel = NULL; - } - id->recv_cq_channel = NULL; - } -} - -static int ucma_create_cqs(struct rdma_cm_id *id, uint32_t send_size, uint32_t recv_size) -{ - if (recv_size) { - id->recv_cq_channel = ibv_create_comp_channel(id->verbs); - if (!id->recv_cq_channel) - goto err; - - id->recv_cq = ibv_create_cq(id->verbs, recv_size, - id, id->recv_cq_channel, 0); - if (!id->recv_cq) - goto err; - } - - if (send_size) { - id->send_cq_channel = ibv_create_comp_channel(id->verbs); - if (!id->send_cq_channel) - goto err; - - id->send_cq = ibv_create_cq(id->verbs, send_size, - id, id->send_cq_channel, 0); - if (!id->send_cq) - goto err; - } - - return 0; -err: - ucma_destroy_cqs(id); - return ERR(ENOMEM); -} - -int rdma_create_srq_ex(struct rdma_cm_id *id, struct ibv_srq_init_attr_ex *attr) -{ - struct cma_id_private *id_priv; - struct ibv_srq *srq; - int ret; - - id_priv = container_of(id, struct cma_id_private, id); - if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_TYPE)) - return ERR(EINVAL); - - if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_PD) || !attr->pd) { - attr->pd = id->pd; - attr->comp_mask |= IBV_SRQ_INIT_ATTR_PD; - } - - if (attr->srq_type == IBV_SRQT_XRC) { - if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_XRCD) || !attr->xrcd) { - attr->xrcd = ucma_get_xrcd(id_priv->cma_dev); - if (!attr->xrcd) - return -1; - } - if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_CQ) || !attr->cq) { - ret = ucma_create_cqs(id, 0, attr->attr.max_wr); - if (ret) - return ret; - attr->cq = id->recv_cq; - } - attr->comp_mask |= IBV_SRQ_INIT_ATTR_XRCD | IBV_SRQ_INIT_ATTR_CQ; - } - - srq = ibv_create_srq_ex(id->verbs, attr); - if (!srq) { - ret = -1; - goto err; - } - - if (!id->pd) - id->pd = attr->pd; - id->srq = srq; - return 0; -err: - ucma_destroy_cqs(id); - return ret; -} - -int rdma_create_srq(struct rdma_cm_id *id, struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct ibv_srq_init_attr_ex attr_ex; - int ret; - - memcpy(&attr_ex, attr, sizeof(*attr)); - attr_ex.comp_mask = IBV_SRQ_INIT_ATTR_TYPE | IBV_SRQ_INIT_ATTR_PD; - if (id->qp_type == IBV_QPT_XRC_RECV) { - attr_ex.srq_type = IBV_SRQT_XRC; - } else { - attr_ex.srq_type = IBV_SRQT_BASIC; - } - attr_ex.pd = pd; - ret = rdma_create_srq_ex(id, &attr_ex); - memcpy(attr, &attr_ex, sizeof(*attr)); - return ret; -} - -void rdma_destroy_srq(struct rdma_cm_id *id) -{ - ibv_destroy_srq(id->srq); - id->srq = NULL; - ucma_destroy_cqs(id); -} - -int rdma_create_qp_ex(struct rdma_cm_id *id, - struct ibv_qp_init_attr_ex *attr) -{ - struct cma_id_private *id_priv; - struct ibv_qp *qp; - int ret; - - if (id->qp) - return ERR(EINVAL); - - id_priv = container_of(id, struct cma_id_private, id); - if (!(attr->comp_mask & IBV_QP_INIT_ATTR_PD) || !attr->pd) { - attr->comp_mask |= IBV_QP_INIT_ATTR_PD; - attr->pd = id->pd; - } else if (id->verbs != attr->pd->context) - return ERR(EINVAL); - - if ((id->recv_cq && attr->recv_cq && id->recv_cq != attr->recv_cq) || - (id->send_cq && attr->send_cq && id->send_cq != attr->send_cq)) - return ERR(EINVAL); - - if (id->qp_type == IBV_QPT_XRC_RECV) { - if (!(attr->comp_mask & IBV_QP_INIT_ATTR_XRCD) || !attr->xrcd) { - attr->xrcd = ucma_get_xrcd(id_priv->cma_dev); - if (!attr->xrcd) - return -1; - attr->comp_mask |= IBV_QP_INIT_ATTR_XRCD; - } - } - - ret = ucma_create_cqs(id, attr->send_cq || id->send_cq ? 0 : attr->cap.max_send_wr, - attr->recv_cq || id->recv_cq ? 0 : attr->cap.max_recv_wr); - if (ret) - return ret; - - if (!attr->send_cq) - attr->send_cq = id->send_cq; - if (!attr->recv_cq) - attr->recv_cq = id->recv_cq; - if (id->srq && !attr->srq) - attr->srq = id->srq; - qp = ibv_create_qp_ex(id->verbs, attr); - if (!qp) { - ret = ERR(ENOMEM); - goto err1; - } - - if (ucma_is_ud_qp(id->qp_type)) - ret = ucma_init_ud_qp(id_priv, qp); - else - ret = ucma_init_conn_qp(id_priv, qp); - if (ret) - goto err2; - - id->pd = qp->pd; - id->qp = qp; - return 0; -err2: - ibv_destroy_qp(qp); -err1: - ucma_destroy_cqs(id); - return ret; -} - -int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd, - struct ibv_qp_init_attr *qp_init_attr) -{ - struct ibv_qp_init_attr_ex attr_ex; - int ret; - - memcpy(&attr_ex, qp_init_attr, sizeof(*qp_init_attr)); - attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD; - attr_ex.pd = pd ? pd : id->pd; - ret = rdma_create_qp_ex(id, &attr_ex); - memcpy(qp_init_attr, &attr_ex, sizeof(*qp_init_attr)); - return ret; -} - -void rdma_destroy_qp(struct rdma_cm_id *id) -{ - ibv_destroy_qp(id->qp); - id->qp = NULL; - ucma_destroy_cqs(id); -} - -static int ucma_valid_param(struct cma_id_private *id_priv, - struct rdma_conn_param *param) -{ - if (id_priv->id.ps != RDMA_PS_TCP) - return 0; - - if (!id_priv->id.qp && !param) - goto err; - - if (!param) - return 0; - - if ((param->responder_resources != RDMA_MAX_RESP_RES) && - (param->responder_resources > id_priv->cma_dev->max_responder_resources)) - goto err; - - if ((param->initiator_depth != RDMA_MAX_INIT_DEPTH) && - (param->initiator_depth > id_priv->cma_dev->max_initiator_depth)) - goto err; - - return 0; -err: - return ERR(EINVAL); -} - -static void ucma_copy_conn_param_to_kern(struct cma_id_private *id_priv, - struct ucma_abi_conn_param *dst, - struct rdma_conn_param *src, - uint32_t qp_num, uint8_t srq) -{ - dst->qp_num = qp_num; - dst->srq = srq; - dst->responder_resources = id_priv->responder_resources; - dst->initiator_depth = id_priv->initiator_depth; - dst->valid = 1; - - if (id_priv->connect_len) { - memcpy(dst->private_data, id_priv->connect, id_priv->connect_len); - dst->private_data_len = id_priv->connect_len; - } - - if (src) { - dst->flow_control = src->flow_control; - dst->retry_count = src->retry_count; - dst->rnr_retry_count = src->rnr_retry_count; - - if (src->private_data && src->private_data_len) { - memcpy(dst->private_data + dst->private_data_len, - src->private_data, src->private_data_len); - dst->private_data_len += src->private_data_len; - } - } else { - dst->retry_count = 7; - dst->rnr_retry_count = 7; - } -} - -int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param) -{ - struct ucma_abi_connect cmd; - struct cma_id_private *id_priv; - int ret; - - id_priv = container_of(id, struct cma_id_private, id); - ret = ucma_valid_param(id_priv, conn_param); - if (ret) - return ret; - - if (conn_param && conn_param->initiator_depth != RDMA_MAX_INIT_DEPTH) - id_priv->initiator_depth = conn_param->initiator_depth; - else - id_priv->initiator_depth = id_priv->cma_dev->max_initiator_depth; - if (conn_param && conn_param->responder_resources != RDMA_MAX_RESP_RES) - id_priv->responder_resources = conn_param->responder_resources; - else - id_priv->responder_resources = id_priv->cma_dev->max_responder_resources; - - CMA_INIT_CMD(&cmd, sizeof cmd, CONNECT); - cmd.id = id_priv->handle; - if (id->qp) { - ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param, - conn_param, id->qp->qp_num, - (id->qp->srq != NULL)); - } else if (conn_param) { - ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param, - conn_param, conn_param->qp_num, - conn_param->srq); - } else { - ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param, - conn_param, 0, 0); - } - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - if (id_priv->connect_len) { - free(id_priv->connect); - id_priv->connect_len = 0; - } - - return ucma_complete(id); -} - -int rdma_listen(struct rdma_cm_id *id, int backlog) -{ - struct ucma_abi_listen cmd; - struct cma_id_private *id_priv; - int ret; - - CMA_INIT_CMD(&cmd, sizeof cmd, LISTEN); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - cmd.backlog = backlog; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - if (af_ib_support) - return ucma_query_addr(id); - else - return ucma_query_route(id); -} - -int rdma_get_request(struct rdma_cm_id *listen, struct rdma_cm_id **id) -{ - struct cma_id_private *id_priv; - struct rdma_cm_event *event; - int ret; - - id_priv = container_of(listen, struct cma_id_private, id); - if (!id_priv->sync) - return ERR(EINVAL); - - if (listen->event) { - rdma_ack_cm_event(listen->event); - listen->event = NULL; - } - - ret = rdma_get_cm_event(listen->channel, &event); - if (ret) - return ret; - - if (event->status) { - ret = ERR(event->status); - goto err; - } - - if (event->event != RDMA_CM_EVENT_CONNECT_REQUEST) { - ret = ERR(EINVAL); - goto err; - } - - if (id_priv->qp_init_attr) { - struct ibv_qp_init_attr attr; - - attr = *id_priv->qp_init_attr; - ret = rdma_create_qp(event->id, listen->pd, &attr); - if (ret) - goto err; - } - - *id = event->id; - (*id)->event = event; - return 0; - -err: - listen->event = event; - return ret; -} - -int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param) -{ - struct ucma_abi_accept cmd; - struct cma_id_private *id_priv; - int ret; - - id_priv = container_of(id, struct cma_id_private, id); - ret = ucma_valid_param(id_priv, conn_param); - if (ret) - return ret; - - if (!conn_param || conn_param->initiator_depth == RDMA_MAX_INIT_DEPTH) { - id_priv->initiator_depth = min(id_priv->initiator_depth, - id_priv->cma_dev->max_initiator_depth); - } else { - id_priv->initiator_depth = conn_param->initiator_depth; - } - if (!conn_param || conn_param->responder_resources == RDMA_MAX_RESP_RES) { - id_priv->responder_resources = min(id_priv->responder_resources, - id_priv->cma_dev->max_responder_resources); - } else { - id_priv->responder_resources = conn_param->responder_resources; - } - - if (!ucma_is_ud_qp(id->qp_type)) { - ret = ucma_modify_qp_rtr(id, id_priv->responder_resources); - if (ret) - return ret; - - ret = ucma_modify_qp_rts(id, id_priv->initiator_depth); - if (ret) - return ret; - } - - CMA_INIT_CMD(&cmd, sizeof cmd, ACCEPT); - cmd.id = id_priv->handle; - cmd.uid = (uintptr_t) id_priv; - if (id->qp) - ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param, - conn_param, id->qp->qp_num, - (id->qp->srq != NULL)); - else - ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param, - conn_param, conn_param->qp_num, - conn_param->srq); - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) { - ucma_modify_qp_err(id); - return (ret >= 0) ? ERR(ENODATA) : -1; - } - - if (ucma_is_ud_qp(id->qp_type)) - return 0; - - return ucma_complete(id); -} - -int rdma_reject(struct rdma_cm_id *id, const void *private_data, - uint8_t private_data_len) -{ - struct ucma_abi_reject cmd; - struct cma_id_private *id_priv; - int ret; - - CMA_INIT_CMD(&cmd, sizeof cmd, REJECT); - - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - if (private_data && private_data_len) { - memcpy(cmd.private_data, private_data, private_data_len); - cmd.private_data_len = private_data_len; - } - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int rdma_notify(struct rdma_cm_id *id, enum ibv_event_type event) -{ - struct ucma_abi_notify cmd; - struct cma_id_private *id_priv; - int ret; - - CMA_INIT_CMD(&cmd, sizeof cmd, NOTIFY); - - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - cmd.event = event; - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int ucma_shutdown(struct rdma_cm_id *id) -{ - switch (id->verbs->device->transport_type) { - case IBV_TRANSPORT_IB: - return ucma_modify_qp_err(id); - case IBV_TRANSPORT_IWARP: - return ucma_modify_qp_sqd(id); - default: - return ERR(EINVAL); - } -} - -int rdma_disconnect(struct rdma_cm_id *id) -{ - struct ucma_abi_disconnect cmd; - struct cma_id_private *id_priv; - int ret; - - ret = ucma_shutdown(id); - if (ret) - return ret; - - CMA_INIT_CMD(&cmd, sizeof cmd, DISCONNECT); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - return ucma_complete(id); -} - -static int rdma_join_multicast2(struct rdma_cm_id *id, struct sockaddr *addr, - socklen_t addrlen, void *context) -{ - struct ucma_abi_create_id_resp resp; - struct cma_id_private *id_priv; - struct cma_multicast *mc, **pos; - int ret; - - id_priv = container_of(id, struct cma_id_private, id); - mc = calloc(1, sizeof(*mc)); - if (!mc) - return ERR(ENOMEM); - - mc->context = context; - mc->id_priv = id_priv; - memcpy(&mc->addr, addr, addrlen); - if (pthread_cond_init(&mc->cond, NULL)) { - ret = -1; - goto err1; - } - - pthread_mutex_lock(&id_priv->mut); - mc->next = id_priv->mc_list; - id_priv->mc_list = mc; - pthread_mutex_unlock(&id_priv->mut); - - if (af_ib_support) { - struct ucma_abi_join_mcast cmd; - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, JOIN_MCAST, &resp, sizeof resp); - cmd.id = id_priv->handle; - memcpy(&cmd.addr, addr, addrlen); - cmd.addr_size = addrlen; - cmd.uid = (uintptr_t) mc; - cmd.reserved = 0; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) { - ret = (ret >= 0) ? ERR(ENODATA) : -1; - goto err2; - } - } else { - struct ucma_abi_join_ip_mcast cmd; - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, JOIN_IP_MCAST, &resp, sizeof resp); - cmd.id = id_priv->handle; - memcpy(&cmd.addr, addr, addrlen); - cmd.uid = (uintptr_t) mc; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) { - ret = (ret >= 0) ? ERR(ENODATA) : -1; - goto err2; - } - } - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - mc->handle = resp.id; - return ucma_complete(id); - -err2: - pthread_mutex_lock(&id_priv->mut); - for (pos = &id_priv->mc_list; *pos != mc; pos = &(*pos)->next) - ; - *pos = mc->next; - pthread_mutex_unlock(&id_priv->mut); -err1: - free(mc); - return ret; -} - -int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, - void *context) -{ - int addrlen; - - addrlen = ucma_addrlen(addr); - if (!addrlen) - return ERR(EINVAL); - - return rdma_join_multicast2(id, addr, addrlen, context); -} - -int rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) -{ - struct ucma_abi_destroy_id cmd; - struct ucma_abi_destroy_id_resp resp; - struct cma_id_private *id_priv; - struct cma_multicast *mc, **pos; - int ret, addrlen; - - addrlen = ucma_addrlen(addr); - if (!addrlen) - return ERR(EINVAL); - - id_priv = container_of(id, struct cma_id_private, id); - pthread_mutex_lock(&id_priv->mut); - for (pos = &id_priv->mc_list; *pos; pos = &(*pos)->next) - if (!memcmp(&(*pos)->addr, addr, addrlen)) - break; - - mc = *pos; - if (*pos) - *pos = mc->next; - pthread_mutex_unlock(&id_priv->mut); - if (!mc) - return ERR(EADDRNOTAVAIL); - - if (id->qp) - ibv_detach_mcast(id->qp, &mc->mgid, mc->mlid); - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, LEAVE_MCAST, &resp, sizeof resp); - cmd.id = mc->handle; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) { - ret = (ret >= 0) ? ERR(ENODATA) : -1; - goto free; - } - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - pthread_mutex_lock(&id_priv->mut); - while (mc->events_completed < resp.events_reported) - pthread_cond_wait(&mc->cond, &id_priv->mut); - pthread_mutex_unlock(&id_priv->mut); - - ret = 0; -free: - free(mc); - return ret; -} - -static void ucma_complete_event(struct cma_id_private *id_priv) -{ - pthread_mutex_lock(&id_priv->mut); - id_priv->events_completed++; - pthread_cond_signal(&id_priv->cond); - pthread_mutex_unlock(&id_priv->mut); -} - -static void ucma_complete_mc_event(struct cma_multicast *mc) -{ - pthread_mutex_lock(&mc->id_priv->mut); - mc->events_completed++; - pthread_cond_signal(&mc->cond); - mc->id_priv->events_completed++; - pthread_cond_signal(&mc->id_priv->cond); - pthread_mutex_unlock(&mc->id_priv->mut); -} - -int rdma_ack_cm_event(struct rdma_cm_event *event) -{ - struct cma_event *evt; - - if (!event) - return ERR(EINVAL); - - evt = container_of(event, struct cma_event, event); - - if (evt->mc) - ucma_complete_mc_event(evt->mc); - else - ucma_complete_event(evt->id_priv); - free(evt); - return 0; -} - -static void ucma_process_addr_resolved(struct cma_event *evt) -{ - if (af_ib_support) { - evt->event.status = ucma_query_addr(&evt->id_priv->id); - if (!evt->event.status && - evt->id_priv->id.verbs->device->transport_type == IBV_TRANSPORT_IB) - evt->event.status = ucma_query_gid(&evt->id_priv->id); - } else { - evt->event.status = ucma_query_route(&evt->id_priv->id); - } - - if (evt->event.status) - evt->event.event = RDMA_CM_EVENT_ADDR_ERROR; -} - -static void ucma_process_route_resolved(struct cma_event *evt) -{ - if (evt->id_priv->id.verbs->device->transport_type != IBV_TRANSPORT_IB) - return; - - if (af_ib_support) - evt->event.status = ucma_query_path(&evt->id_priv->id); - else - evt->event.status = ucma_query_route(&evt->id_priv->id); - - if (evt->event.status) - evt->event.event = RDMA_CM_EVENT_ROUTE_ERROR; -} - -static int ucma_query_req_info(struct rdma_cm_id *id) -{ - int ret; - - if (!af_ib_support) - return ucma_query_route(id); - - ret = ucma_query_addr(id); - if (ret) - return ret; - - ret = ucma_query_gid(id); - if (ret) - return ret; - - ret = ucma_query_path(id); - if (ret) - return ret; - - return 0; -} - -static int ucma_process_conn_req(struct cma_event *evt, - uint32_t handle) -{ - struct cma_id_private *id_priv; - int ret; - - id_priv = ucma_alloc_id(evt->id_priv->id.channel, - evt->id_priv->id.context, evt->id_priv->id.ps, - evt->id_priv->id.qp_type); - if (!id_priv) { - ucma_destroy_kern_id(evt->id_priv->id.channel->fd, handle); - ret = ERR(ENOMEM); - goto err1; - } - - evt->event.listen_id = &evt->id_priv->id; - evt->event.id = &id_priv->id; - id_priv->handle = handle; - ucma_insert_id(id_priv); - id_priv->initiator_depth = evt->event.param.conn.initiator_depth; - id_priv->responder_resources = evt->event.param.conn.responder_resources; - - if (evt->id_priv->sync) { - ret = rdma_migrate_id(&id_priv->id, NULL); - if (ret) - goto err2; - } - - ret = ucma_query_req_info(&id_priv->id); - if (ret) - goto err2; - - return 0; - -err2: - rdma_destroy_id(&id_priv->id); -err1: - ucma_complete_event(evt->id_priv); - return ret; -} - -static int ucma_process_conn_resp(struct cma_id_private *id_priv) -{ - struct ucma_abi_accept cmd; - int ret; - - ret = ucma_modify_qp_rtr(&id_priv->id, RDMA_MAX_RESP_RES); - if (ret) - goto err; - - ret = ucma_modify_qp_rts(&id_priv->id, RDMA_MAX_INIT_DEPTH); - if (ret) - goto err; - - CMA_INIT_CMD(&cmd, sizeof cmd, ACCEPT); - cmd.id = id_priv->handle; - - ret = write(id_priv->id.channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) { - ret = (ret >= 0) ? ERR(ENODATA) : -1; - goto err; - } - - return 0; -err: - ucma_modify_qp_err(&id_priv->id); - return ret; -} - -static int ucma_process_join(struct cma_event *evt) -{ - evt->mc->mgid = evt->event.param.ud.ah_attr.grh.dgid; - evt->mc->mlid = evt->event.param.ud.ah_attr.dlid; - - if (!evt->id_priv->id.qp) - return 0; - - return rdma_seterrno(ibv_attach_mcast(evt->id_priv->id.qp, - &evt->mc->mgid, evt->mc->mlid)); -} - -static void ucma_copy_conn_event(struct cma_event *event, - struct ucma_abi_conn_param *src) -{ - struct rdma_conn_param *dst = &event->event.param.conn; - - dst->private_data_len = src->private_data_len; - if (src->private_data_len) { - dst->private_data = &event->private_data; - memcpy(&event->private_data, src->private_data, - src->private_data_len); - } - - dst->responder_resources = src->responder_resources; - dst->initiator_depth = src->initiator_depth; - dst->flow_control = src->flow_control; - dst->retry_count = src->retry_count; - dst->rnr_retry_count = src->rnr_retry_count; - dst->srq = src->srq; - dst->qp_num = src->qp_num; -} - -static void ucma_copy_ud_event(struct cma_event *event, - struct ucma_abi_ud_param *src) -{ - struct rdma_ud_param *dst = &event->event.param.ud; - - dst->private_data_len = src->private_data_len; - if (src->private_data_len) { - dst->private_data = &event->private_data; - memcpy(&event->private_data, src->private_data, - src->private_data_len); - } - - ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr); - dst->qp_num = src->qp_num; - dst->qkey = src->qkey; -} - -int rdma_get_cm_event(struct rdma_event_channel *channel, - struct rdma_cm_event **event) -{ - struct ucma_abi_event_resp resp; - struct ucma_abi_get_event cmd; - struct cma_event *evt; - int ret; - - ret = ucma_init(); - if (ret) - return ret; - - if (!event) - return ERR(EINVAL); - - evt = malloc(sizeof(*evt)); - if (!evt) - return ERR(ENOMEM); - -retry: - memset(evt, 0, sizeof(*evt)); - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, GET_EVENT, &resp, sizeof resp); - ret = write(channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) { - free(evt); - return (ret >= 0) ? ERR(ENODATA) : -1; - } - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - evt->event.event = resp.event; - /* - * We should have a non-zero uid, except for connection requests. - * But a bug in older kernels can report a uid 0. Work-around this - * issue by looking up the cma_id based on the kernel's id when the - * uid is 0 and we're processing a connection established event. - * In all other cases, if the uid is 0, we discard the event, like - * the kernel should have done. - */ - if (resp.uid) { - evt->id_priv = (void *) (uintptr_t) resp.uid; - } else { - evt->id_priv = ucma_lookup_id(resp.id); - if (!evt->id_priv) { - syslog(LOG_WARNING, PFX "Warning: discarding unmatched " - "event - rdma_destroy_id may hang.\n"); - goto retry; - } - if (resp.event != RDMA_CM_EVENT_ESTABLISHED) { - ucma_complete_event(evt->id_priv); - goto retry; - } - } - evt->event.id = &evt->id_priv->id; - evt->event.status = resp.status; - - switch (resp.event) { - case RDMA_CM_EVENT_ADDR_RESOLVED: - ucma_process_addr_resolved(evt); - break; - case RDMA_CM_EVENT_ROUTE_RESOLVED: - ucma_process_route_resolved(evt); - break; - case RDMA_CM_EVENT_CONNECT_REQUEST: - evt->id_priv = (void *) (uintptr_t) resp.uid; - if (ucma_is_ud_qp(evt->id_priv->id.qp_type)) - ucma_copy_ud_event(evt, &resp.param.ud); - else - ucma_copy_conn_event(evt, &resp.param.conn); - - ret = ucma_process_conn_req(evt, resp.id); - if (ret) - goto retry; - break; - case RDMA_CM_EVENT_CONNECT_RESPONSE: - ucma_copy_conn_event(evt, &resp.param.conn); - evt->event.status = ucma_process_conn_resp(evt->id_priv); - if (!evt->event.status) - evt->event.event = RDMA_CM_EVENT_ESTABLISHED; - else { - evt->event.event = RDMA_CM_EVENT_CONNECT_ERROR; - evt->id_priv->connect_error = 1; - } - break; - case RDMA_CM_EVENT_ESTABLISHED: - if (ucma_is_ud_qp(evt->id_priv->id.qp_type)) { - ucma_copy_ud_event(evt, &resp.param.ud); - break; - } - - ucma_copy_conn_event(evt, &resp.param.conn); - break; - case RDMA_CM_EVENT_REJECTED: - if (evt->id_priv->connect_error) { - ucma_complete_event(evt->id_priv); - goto retry; - } - ucma_copy_conn_event(evt, &resp.param.conn); - ucma_modify_qp_err(evt->event.id); - break; - case RDMA_CM_EVENT_DISCONNECTED: - if (evt->id_priv->connect_error) { - ucma_complete_event(evt->id_priv); - goto retry; - } - ucma_copy_conn_event(evt, &resp.param.conn); - break; - case RDMA_CM_EVENT_MULTICAST_JOIN: - evt->mc = (void *) (uintptr_t) resp.uid; - evt->id_priv = evt->mc->id_priv; - evt->event.id = &evt->id_priv->id; - ucma_copy_ud_event(evt, &resp.param.ud); - evt->event.param.ud.private_data = evt->mc->context; - evt->event.status = ucma_process_join(evt); - if (evt->event.status) - evt->event.event = RDMA_CM_EVENT_MULTICAST_ERROR; - break; - case RDMA_CM_EVENT_MULTICAST_ERROR: - evt->mc = (void *) (uintptr_t) resp.uid; - evt->id_priv = evt->mc->id_priv; - evt->event.id = &evt->id_priv->id; - evt->event.param.ud.private_data = evt->mc->context; - break; - default: - evt->id_priv = (void *) (uintptr_t) resp.uid; - evt->event.id = &evt->id_priv->id; - evt->event.status = resp.status; - if (ucma_is_ud_qp(evt->id_priv->id.qp_type)) - ucma_copy_ud_event(evt, &resp.param.ud); - else - ucma_copy_conn_event(evt, &resp.param.conn); - break; - } - - *event = &evt->event; - return 0; -} - -const char *rdma_event_str(enum rdma_cm_event_type event) -{ - switch (event) { - case RDMA_CM_EVENT_ADDR_RESOLVED: - return "RDMA_CM_EVENT_ADDR_RESOLVED"; - case RDMA_CM_EVENT_ADDR_ERROR: - return "RDMA_CM_EVENT_ADDR_ERROR"; - case RDMA_CM_EVENT_ROUTE_RESOLVED: - return "RDMA_CM_EVENT_ROUTE_RESOLVED"; - case RDMA_CM_EVENT_ROUTE_ERROR: - return "RDMA_CM_EVENT_ROUTE_ERROR"; - case RDMA_CM_EVENT_CONNECT_REQUEST: - return "RDMA_CM_EVENT_CONNECT_REQUEST"; - case RDMA_CM_EVENT_CONNECT_RESPONSE: - return "RDMA_CM_EVENT_CONNECT_RESPONSE"; - case RDMA_CM_EVENT_CONNECT_ERROR: - return "RDMA_CM_EVENT_CONNECT_ERROR"; - case RDMA_CM_EVENT_UNREACHABLE: - return "RDMA_CM_EVENT_UNREACHABLE"; - case RDMA_CM_EVENT_REJECTED: - return "RDMA_CM_EVENT_REJECTED"; - case RDMA_CM_EVENT_ESTABLISHED: - return "RDMA_CM_EVENT_ESTABLISHED"; - case RDMA_CM_EVENT_DISCONNECTED: - return "RDMA_CM_EVENT_DISCONNECTED"; - case RDMA_CM_EVENT_DEVICE_REMOVAL: - return "RDMA_CM_EVENT_DEVICE_REMOVAL"; - case RDMA_CM_EVENT_MULTICAST_JOIN: - return "RDMA_CM_EVENT_MULTICAST_JOIN"; - case RDMA_CM_EVENT_MULTICAST_ERROR: - return "RDMA_CM_EVENT_MULTICAST_ERROR"; - case RDMA_CM_EVENT_ADDR_CHANGE: - return "RDMA_CM_EVENT_ADDR_CHANGE"; - case RDMA_CM_EVENT_TIMEWAIT_EXIT: - return "RDMA_CM_EVENT_TIMEWAIT_EXIT"; - default: - return "UNKNOWN EVENT"; - } -} - -int rdma_set_option(struct rdma_cm_id *id, int level, int optname, - void *optval, size_t optlen) -{ - struct ucma_abi_set_option cmd; - struct cma_id_private *id_priv; - int ret; - - CMA_INIT_CMD(&cmd, sizeof cmd, SET_OPTION); - id_priv = container_of(id, struct cma_id_private, id); - cmd.id = id_priv->handle; - cmd.optval = (uintptr_t) optval; - cmd.level = level; - cmd.optname = optname; - cmd.optlen = optlen; - - ret = write(id->channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) - return (ret >= 0) ? ERR(ENODATA) : -1; - - return 0; -} - -int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel) -{ - struct ucma_abi_migrate_resp resp; - struct ucma_abi_migrate_id cmd; - struct cma_id_private *id_priv; - int ret, sync; - - id_priv = container_of(id, struct cma_id_private, id); - if (id_priv->sync && !channel) - return ERR(EINVAL); - - if ((sync = (channel == NULL))) { - channel = rdma_create_event_channel(); - if (!channel) - return -1; - } - - CMA_INIT_CMD_RESP(&cmd, sizeof cmd, MIGRATE_ID, &resp, sizeof resp); - cmd.id = id_priv->handle; - cmd.fd = id->channel->fd; - - ret = write(channel->fd, &cmd, sizeof cmd); - if (ret != sizeof cmd) { - if (sync) - rdma_destroy_event_channel(channel); - return (ret >= 0) ? ERR(ENODATA) : -1; - } - - VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - - if (id_priv->sync) { - if (id->event) { - rdma_ack_cm_event(id->event); - id->event = NULL; - } - rdma_destroy_event_channel(id->channel); - } - - /* - * Eventually if we want to support migrating channels while events are - * being processed on the current channel, we need to block here while - * there are any outstanding events on the current channel for this id - * to prevent the user from processing events for this id on the old - * channel after this call returns. - */ - pthread_mutex_lock(&id_priv->mut); - id_priv->sync = sync; - id->channel = channel; - while (id_priv->events_completed < resp.events_reported) - pthread_cond_wait(&id_priv->cond, &id_priv->mut); - pthread_mutex_unlock(&id_priv->mut); - - return 0; -} - -static int ucma_passive_ep(struct rdma_cm_id *id, struct rdma_addrinfo *res, - struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr) -{ - struct cma_id_private *id_priv; - int ret; - - if (af_ib_support) - ret = rdma_bind_addr2(id, res->ai_src_addr, res->ai_src_len); - else - ret = rdma_bind_addr(id, res->ai_src_addr); - if (ret) - return ret; - - id_priv = container_of(id, struct cma_id_private, id); - if (pd) - id->pd = pd; - - if (qp_init_attr) { - id_priv->qp_init_attr = malloc(sizeof(*qp_init_attr)); - if (!id_priv->qp_init_attr) - return ERR(ENOMEM); - - *id_priv->qp_init_attr = *qp_init_attr; - id_priv->qp_init_attr->qp_type = res->ai_qp_type; - } - - return 0; -} - -int rdma_create_ep(struct rdma_cm_id **id, struct rdma_addrinfo *res, - struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr) -{ - struct rdma_cm_id *cm_id; - struct cma_id_private *id_priv; - int ret; - - ret = rdma_create_id2(NULL, &cm_id, NULL, res->ai_port_space, res->ai_qp_type); - if (ret) - return ret; - - if (res->ai_flags & RAI_PASSIVE) { - ret = ucma_passive_ep(cm_id, res, pd, qp_init_attr); - if (ret) - goto err; - goto out; - } - - if (af_ib_support) - ret = rdma_resolve_addr2(cm_id, res->ai_src_addr, res->ai_src_len, - res->ai_dst_addr, res->ai_dst_len, 2000); - else - ret = rdma_resolve_addr(cm_id, res->ai_src_addr, res->ai_dst_addr, 2000); - if (ret) - goto err; - - if (res->ai_route_len) { - ret = rdma_set_option(cm_id, RDMA_OPTION_IB, RDMA_OPTION_IB_PATH, - res->ai_route, res->ai_route_len); - if (!ret) - ret = ucma_complete(cm_id); - } else { - ret = rdma_resolve_route(cm_id, 2000); - } - if (ret) - goto err; - - if (qp_init_attr) { - qp_init_attr->qp_type = res->ai_qp_type; - ret = rdma_create_qp(cm_id, pd, qp_init_attr); - if (ret) - goto err; - } - - if (res->ai_connect_len) { - id_priv = container_of(cm_id, struct cma_id_private, id); - id_priv->connect = malloc(res->ai_connect_len); - if (!id_priv->connect) { - ret = ERR(ENOMEM); - goto err; - } - memcpy(id_priv->connect, res->ai_connect, res->ai_connect_len); - id_priv->connect_len = res->ai_connect_len; - } - -out: - *id = cm_id; - return 0; - -err: - rdma_destroy_ep(cm_id); - return ret; -} - -void rdma_destroy_ep(struct rdma_cm_id *id) -{ - struct cma_id_private *id_priv; - - if (id->qp) - rdma_destroy_qp(id); - - if (id->srq) - rdma_destroy_srq(id); - - id_priv = container_of(id, struct cma_id_private, id); - if (id_priv->qp_init_attr) - free(id_priv->qp_init_attr); - - rdma_destroy_id(id); -} - -int ucma_max_qpsize(struct rdma_cm_id *id) -{ - struct cma_id_private *id_priv; - int i, max_size = 0; - - id_priv = container_of(id, struct cma_id_private, id); - if (id && id_priv->cma_dev) { - max_size = id_priv->cma_dev->max_qpsize; - } else { - ucma_init_all(); - for (i = 0; i < cma_dev_cnt; i++) { - if (!max_size || max_size > cma_dev_array[i].max_qpsize) - max_size = cma_dev_array[i].max_qpsize; - } - } - return max_size; -} - -__be16 ucma_get_port(struct sockaddr *addr) -{ - switch (addr->sa_family) { - case AF_INET: - return ((struct sockaddr_in *) addr)->sin_port; - case AF_INET6: - return ((struct sockaddr_in6 *) addr)->sin6_port; - case AF_IB: - return htobe16((uint16_t) be64toh(((struct sockaddr_ib *) addr)->sib_sid)); - default: - return 0; - } -} - -__be16 rdma_get_src_port(struct rdma_cm_id *id) -{ - return ucma_get_port(&id->route.addr.src_addr); -} - -__be16 rdma_get_dst_port(struct rdma_cm_id *id) -{ - return ucma_get_port(&id->route.addr.dst_addr); -} - diff --git a/usr/rdma-core/librdmacm/cma.h b/usr/rdma-core/librdmacm/cma.h deleted file mode 100644 index 62821055a..000000000 --- a/usr/rdma-core/librdmacm/cma.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#if !defined(CMA_H) -#define CMA_H - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#define PFX "librdmacm: " - -/* - * Fast synchronization for low contention locking. - */ -typedef struct { - sem_t sem; - _Atomic(int) cnt; -} fastlock_t; -static inline void fastlock_init(fastlock_t *lock) -{ - sem_init(&lock->sem, 0, 0); - atomic_store(&lock->cnt, 0); -} -static inline void fastlock_destroy(fastlock_t *lock) -{ - sem_destroy(&lock->sem); -} -static inline void fastlock_acquire(fastlock_t *lock) -{ - if (atomic_fetch_add(&lock->cnt, 1) > 0) - sem_wait(&lock->sem); -} -static inline void fastlock_release(fastlock_t *lock) -{ - if (atomic_fetch_sub(&lock->cnt, 1) > 1) - sem_post(&lock->sem); -} - -__be16 ucma_get_port(struct sockaddr *addr); -int ucma_addrlen(struct sockaddr *addr); -void ucma_set_sid(enum rdma_port_space ps, struct sockaddr *addr, - struct sockaddr_ib *sib); -int ucma_max_qpsize(struct rdma_cm_id *id); -int ucma_complete(struct rdma_cm_id *id); -int ucma_shutdown(struct rdma_cm_id *id); - -static inline int ERR(int err) -{ - errno = err; - return -1; -} - -int ucma_init(void); -extern int af_ib_support; - -#define RAI_ROUTEONLY 0x01000000 - -void ucma_ib_init(void); -void ucma_ib_cleanup(void); -void ucma_ib_resolve(struct rdma_addrinfo **rai, - const struct rdma_addrinfo *hints); - -struct ib_connect_hdr { - uint8_t cma_version; - uint8_t ip_version; /* IP version: 7:4 */ - uint16_t port; - uint32_t src_addr[4]; - uint32_t dst_addr[4]; -#define cma_src_ip4 src_addr[3] -#define cma_src_ip6 src_addr[0] -#define cma_dst_ip4 dst_addr[3] -#define cma_dst_ip6 dst_addr[0] -}; - -#endif /* CMA_H */ diff --git a/usr/rdma-core/librdmacm/docs/rsocket b/usr/rdma-core/librdmacm/docs/rsocket deleted file mode 100644 index 43834e04b..000000000 --- a/usr/rdma-core/librdmacm/docs/rsocket +++ /dev/null @@ -1,280 +0,0 @@ -.. Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -rsocket Protocol and Design Guide 11/11/2012 - -Data Streaming (TCP) Overview ------------------------------ -Rsockets is a protocol over RDMA that supports a socket-level API -for applications. For details on the current state of the -implementation, readers should refer to the rsocket man page. This -document describes the rsocket protocol, general design, and -some implementation details. - -Rsockets exchanges data by performing RDMA write operations into -exposed data buffers. In addition to RDMA write data, rsockets uses -small, 32-bit messages for internal communication. RDMA writes -are used to transfer application data into remote data buffers -and to notify the peer when new target data buffers are available. -The following figure highlights the operation. - - host A host B - remote SGL - target SGL <------------- [ ] - [ ] ------ - [ ] -- ------ receive buffer(s) - -- -----> +--+ - -- | | - -- | | - -- | | - -- +--+ - -- - ---> +--+ - | | - | | - +--+ - -The remote SGL contains the address, size, and rkey of the target SGL. As -receive buffers become available on host B, rsockets will issue an RDMA -write against one of the entries in the target SGL on host A. The -updated entry will reference an available receive buffer. Immediate data -included with the RDMA write will indicate to host A that a target SGE -has been updated. - -When host A has data to send, it will check its target SGL. The current -target SGE will contain the address, size, and rkey of the next receive -buffer on host B. If the data transfer is smaller than the size of the -remote receive buffer, host A will update its target SGE to reflect the -remaining size of the receive buffer. That is, once a receive buffer has -been published to a remote peer, it will be fully consumed before a second -buffer is used. - -Rsockets relies on immediate data to notify the remote peer when data has -been transferred or when a target SGL has been updated. Because immediate -data requires that the remote QP have a posted receive, rsockets also uses -a credit based flow control mechanism. The number of credits is based on -the size of the receive queue, with initial credits exchanged during -connection setup. In order to transfer data, rsockets requires both -available receive buffers (published via the target SGL) and data credits. - -Since immediate data is limited to 32-bits, messages may either indicate -the arrival of application data or may be an internal message, but not both. -To avoid credit deadlock, rsockets reserves a small number of available -credits for control messages only, with the protocol relying on RNR NAKs -and retries to make forward progress. - - -Connection Establishment ------------------------- -rsockets uses the RDMA CM for connection establishment. Struct rs_conn_data -is exchanged during the connection exchange as private data in the request -and reply messages. - -struct rs_sge { - uint64_t addr; - uint32_t key; - uint32_t length; -}; - -#define RS_CONN_FLAG_NET 1 - -struct rs_conn_data { - uint8_t version; - uint8_t flags; - uint16_t credits; - uint32_t reserved2; - struct rs_sge target_sgl; - struct rs_sge data_buf; -}; - -Version - current version is 1 -Flags -RS_CONN_FLAG_NET - Set to 1 if host is big Endian. - Determines byte ordering for RDMA write messages -Credits - number of initial receive credits -Reserved2 - set to 0 -Target SGL - Address, size (# entries), and rkey of target SGL. - Remote side will copy this into their remote SGL. -Data Buffer - Initial receive buffer address, size (in bytes), and rkey. - Remote side will copy this into their first target SGE. - - -Message Format --------------- -Rsocket uses RDMA writes with immediate data for all message exchanges. -RDMA writes of 0 length are used if no additional data beyond the message -needs to be exchanged. Immediate data is limited to 32-bits. Rsockets -defines the following format for messages. - -The upper 3 bits are used to define the type of message being exchanged, -with the meaning of the lower 29 bits determined by the upper bits. - -Bits Message Meaning of -31:29 Type Bits 28:0 -000 Data Transfer bytes transfered -001 reserved -010 reserved - used internally, available for future use -011 reserved -100 Credit Update received credits granted -101 reserved -110 Iomap Updated index of updated entry -111 Control control message type - -Data Transfer -Indicates that application data has been written into the next available -receive buffer. The size of the transfer, in bytes, is carried in the lower -bits of the message. - -Credit Update -Used to indicate that additional receive buffers and credits are available. -The number of available credits is carried in the lower bits of the message. -A credit update message is also used to indicate that a target SGE has been -updated, in which case the number of additional credits may be 0. The -receiver of a credit update message must check for updates to the target SGL -by inspecting the contents of the SGL. The rsocket implementation must take -care not to modify a remote target SGL while it may be in use. This is done -by tracking when a receive buffer referenced by a remote target SGL has been -filled. - -Iomap Updated -Used to indicate that a remote iomap entry was updated. The updated entry -contains the offset value associated with an address, length, and rkey. Once -an iomap has been updated, the local application can issue directed IO -transfers against the corresponding remote buffer. - -Control Message - DISCONNECT -Indicates that the rsocket connection has been fully disconnected and will no -longer send or receive data. Data received before the disconnect message was -processed may still be available for reading. - -Control Message - SHUTDOWN -Indicates that the remote rsocket has shutdown the send side of its -connection. The recipient of a shutdown message will no longer accept -incoming data, but may still transfer outbound data. - - -Iomapped Buffers ----------------- -Rsockets allows for zero-copy transfers using what it refers to as iomapped -buffers. Iomapping and direct data placement (zero-copy) transfers are done -using rsocket specific extensions. The general operation is similar to -that used for normal data transfers described above. - - host A host B - remote iomap - target iomap <----------- [ ] - [ ] ------ - [ ] -- ------ iomapped buffer(s) - -- -----> +--+ - -- | | - -- | | - -- | | - -- +--+ - -- - ---> +--+ - | | - | | - +--+ - -The remote iomap contains the address, size, and rkey of the target iomap. As -the applicaton maps buffers host B to a given rsocket, rsockets will issue an RDMA -write against one of the entries in the target iomap on host A. The -updated entry will reference an available iomapped buffer. Immediate data -included with the RDMA write will indicate to host A that a target iomap -has been updated. - -When host A wishes to transfer directly into an iomapped buffer, it will check -its target iomap for an offset corresponding to a remotely mapped buffer. A -matching iomap entry will contain the address, size, and rkey of the target -buffer on host B. Host A will then issue an RDMA operation against the -registered remote data buffer. - -From host A's perspective, the transfer appears as a normal send/write -operation, with the data stream redirected directly into the receiving -application's buffer. - - - -Datagram Overview ------------------ -The rsocket API supports datagram sockets. Datagram support is handled through an -entirely different protocol and internal implementation. Unlike connected rsockets, -datagram rsockets are not necessarily bound to a network (IP) address. A datagram -socket may use any number of network (IP) addresses, including those which map to -different RDMA devices. As a result, a single datagram rsocket must support -using multiple RDMA devices and ports, and a datagram rsocket references a single -UDP socket, plus zero or more UD QPs. - -Rsockets uses headers inserted before user data sent over UDP sockets to resolve -remote UD QP numbers. When a user first attempts to send a datagram to a remote -address (IP and UDP port), rsockets will take the following steps: - -1. Store the destination address into a lookup table. -2. Resolve which local network address should be used when sending - to the specified destination. -3. Allocate a UD QP on the RDMA device associated with the local address. -4. Send the user's datagram to the remote UDP socket. - -A header is inserted before the user's datagram. The header specifies the -UD QP number associated with the local network address (IP and UDP port) of -the send. - -A service thread is used to process messages received on the UDP socket. This -thread updates the rsocket lookup tables with the remote QPN and path record -data. The service thread forwards data received on the UDP socket to an -rsocket QP. After the remote QPN and path records have been resolved, datagram -communication between two nodes are done over the UD QP. - -UDP Message Format ------------------- -Rsockets uses messages exchanged over UDP sockets to resolve remote QP numbers. -If a user sends a datagram to a remote service and the local rsocket is not -yet configured to send directly to a remote UD QP, the user data is sent over -a UDP socket with the following header inserted before the user data. - -struct ds_udp_header { - uint32_t tag; - uint8_t version; - uint8_t op; - uint8_t length; - uint8_t reserved; - uint32_t qpn; /* lower 8-bits reserved */ - union { - uint32_t ipv4; - uint8_t ipv6[16]; - } addr; -}; - -Tag - Marker used to help identify that the UDP header is present. -#define DS_UDP_TAG 0x55555555 - -Version - IP address version, either 4 or 6 -Op - Indicates message type, used to control the receiver's operation. - Valid operations are RS_OP_DATA and RS_OP_CTRL. Data messages - carry user data, while control messages are used to reply with the - local QP number. -Length - Size of the UDP header. -QPN - UD QP number associated with sender's IP address and port. - The sender's address and port is extracted from the received UDP - datagram. -Addr - Target IP address of the sent datagram. - -Once the remote QP information has been resolved, data is sent directly -between UD QPs. The following header is inserted before any user data that -is transferred over a UD QP. - -struct ds_header { - uint8_t version; - uint8_t length; - uint16_t port; - union { - uint32_t ipv4; - struct { - uint32_t flowinfo; - uint8_t addr[16]; - } ipv6; - } addr; -}; - -Verion - IP address version -Length - Size of the header -Port - Associated source address UDP port -Addr - Associated source IP address \ No newline at end of file diff --git a/usr/rdma-core/librdmacm/examples/CMakeLists.txt b/usr/rdma-core/librdmacm/examples/CMakeLists.txt deleted file mode 100644 index 39971754f..000000000 --- a/usr/rdma-core/librdmacm/examples/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Shared example files -add_library(rdmacm_tools STATIC - common.c - ) - -rdma_executable(cmtime cmtime.c) -target_link_libraries(cmtime LINK_PRIVATE rdmacm ${CMAKE_THREAD_LIBS_INIT} rdmacm_tools) - -rdma_executable(mckey mckey.c) -target_link_libraries(mckey LINK_PRIVATE rdmacm ${CMAKE_THREAD_LIBS_INIT}) - -rdma_executable(rcopy rcopy.c) -target_link_libraries(rcopy LINK_PRIVATE rdmacm) - -rdma_executable(rdma_client rdma_client.c) -target_link_libraries(rdma_client LINK_PRIVATE rdmacm) - -rdma_executable(rdma_server rdma_server.c) -target_link_libraries(rdma_server LINK_PRIVATE rdmacm) - -rdma_executable(rdma_xclient rdma_xclient.c) -target_link_libraries(rdma_xclient LINK_PRIVATE rdmacm) - -rdma_executable(rdma_xserver rdma_xserver.c) -target_link_libraries(rdma_xserver LINK_PRIVATE rdmacm) - -rdma_executable(riostream riostream.c) -target_link_libraries(riostream LINK_PRIVATE rdmacm rdmacm_tools) - -rdma_executable(rping rping.c) -target_link_libraries(rping LINK_PRIVATE rdmacm ${CMAKE_THREAD_LIBS_INIT}) - -rdma_executable(rstream rstream.c) -target_link_libraries(rstream LINK_PRIVATE rdmacm rdmacm_tools) - -rdma_executable(ucmatose cmatose.c) -target_link_libraries(ucmatose LINK_PRIVATE rdmacm rdmacm_tools) - -rdma_executable(udaddy udaddy.c) -target_link_libraries(udaddy LINK_PRIVATE rdmacm rdmacm_tools) - -rdma_executable(udpong udpong.c) -target_link_libraries(udpong LINK_PRIVATE rdmacm rdmacm_tools) diff --git a/usr/rdma-core/librdmacm/examples/cmatose.c b/usr/rdma-core/librdmacm/examples/cmatose.c deleted file mode 100644 index b1c9dd13e..000000000 --- a/usr/rdma-core/librdmacm/examples/cmatose.c +++ /dev/null @@ -1,726 +0,0 @@ -/* - * Copyright (c) 2005-2006,2011-2012 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "common.h" - -struct cmatest_node { - int id; - struct rdma_cm_id *cma_id; - int connected; - struct ibv_pd *pd; - struct ibv_cq *cq[2]; - struct ibv_mr *mr; - void *mem; -}; - -enum CQ_INDEX { - SEND_CQ_INDEX, - RECV_CQ_INDEX -}; - -struct cmatest { - struct rdma_event_channel *channel; - struct cmatest_node *nodes; - int conn_index; - int connects_left; - int disconnects_left; - - struct rdma_addrinfo *rai; -}; - -static struct cmatest test; -static int connections = 1; -static int message_size = 100; -static int message_count = 10; -static const char *port = "7471"; -static uint8_t set_tos = 0; -static uint8_t tos; -static uint8_t migrate = 0; -static char *dst_addr; -static char *src_addr; -static struct rdma_addrinfo hints; - -static int create_message(struct cmatest_node *node) -{ - if (!message_size) - message_count = 0; - - if (!message_count) - return 0; - - node->mem = malloc(message_size); - if (!node->mem) { - printf("failed message allocation\n"); - return -1; - } - node->mr = ibv_reg_mr(node->pd, node->mem, message_size, - IBV_ACCESS_LOCAL_WRITE); - if (!node->mr) { - printf("failed to reg MR\n"); - goto err; - } - return 0; -err: - free(node->mem); - return -1; -} - -static int init_node(struct cmatest_node *node) -{ - struct ibv_qp_init_attr init_qp_attr; - int cqe, ret; - - node->pd = ibv_alloc_pd(node->cma_id->verbs); - if (!node->pd) { - ret = -ENOMEM; - printf("cmatose: unable to allocate PD\n"); - goto out; - } - - cqe = message_count ? message_count : 1; - node->cq[SEND_CQ_INDEX] = ibv_create_cq(node->cma_id->verbs, cqe, node, NULL, 0); - node->cq[RECV_CQ_INDEX] = ibv_create_cq(node->cma_id->verbs, cqe, node, NULL, 0); - if (!node->cq[SEND_CQ_INDEX] || !node->cq[RECV_CQ_INDEX]) { - ret = -ENOMEM; - printf("cmatose: unable to create CQ\n"); - goto out; - } - - memset(&init_qp_attr, 0, sizeof init_qp_attr); - init_qp_attr.cap.max_send_wr = cqe; - init_qp_attr.cap.max_recv_wr = cqe; - init_qp_attr.cap.max_send_sge = 1; - init_qp_attr.cap.max_recv_sge = 1; - init_qp_attr.qp_context = node; - init_qp_attr.sq_sig_all = 1; - init_qp_attr.qp_type = IBV_QPT_RC; - init_qp_attr.send_cq = node->cq[SEND_CQ_INDEX]; - init_qp_attr.recv_cq = node->cq[RECV_CQ_INDEX]; - ret = rdma_create_qp(node->cma_id, node->pd, &init_qp_attr); - if (ret) { - perror("cmatose: unable to create QP"); - goto out; - } - - ret = create_message(node); - if (ret) { - printf("cmatose: failed to create messages: %d\n", ret); - goto out; - } -out: - return ret; -} - -static int post_recvs(struct cmatest_node *node) -{ - struct ibv_recv_wr recv_wr, *recv_failure; - struct ibv_sge sge; - int i, ret = 0; - - if (!message_count) - return 0; - - recv_wr.next = NULL; - recv_wr.sg_list = &sge; - recv_wr.num_sge = 1; - recv_wr.wr_id = (uintptr_t) node; - - sge.length = message_size; - sge.lkey = node->mr->lkey; - sge.addr = (uintptr_t) node->mem; - - for (i = 0; i < message_count && !ret; i++ ) { - ret = ibv_post_recv(node->cma_id->qp, &recv_wr, &recv_failure); - if (ret) { - printf("failed to post receives: %d\n", ret); - break; - } - } - return ret; -} - -static int post_sends(struct cmatest_node *node) -{ - struct ibv_send_wr send_wr, *bad_send_wr; - struct ibv_sge sge; - int i, ret = 0; - - if (!node->connected || !message_count) - return 0; - - send_wr.next = NULL; - send_wr.sg_list = &sge; - send_wr.num_sge = 1; - send_wr.opcode = IBV_WR_SEND; - send_wr.send_flags = 0; - send_wr.wr_id = (unsigned long)node; - - sge.length = message_size; - sge.lkey = node->mr->lkey; - sge.addr = (uintptr_t) node->mem; - - for (i = 0; i < message_count && !ret; i++) { - ret = ibv_post_send(node->cma_id->qp, &send_wr, &bad_send_wr); - if (ret) - printf("failed to post sends: %d\n", ret); - } - return ret; -} - -static void connect_error(void) -{ - test.connects_left--; -} - -static int addr_handler(struct cmatest_node *node) -{ - int ret; - - if (set_tos) { - ret = rdma_set_option(node->cma_id, RDMA_OPTION_ID, - RDMA_OPTION_ID_TOS, &tos, sizeof tos); - if (ret) - perror("cmatose: set TOS option failed"); - } - - ret = rdma_resolve_route(node->cma_id, 2000); - if (ret) { - perror("cmatose: resolve route failed"); - connect_error(); - } - return ret; -} - -static int route_handler(struct cmatest_node *node) -{ - struct rdma_conn_param conn_param; - int ret; - - ret = init_node(node); - if (ret) - goto err; - - ret = post_recvs(node); - if (ret) - goto err; - - memset(&conn_param, 0, sizeof conn_param); - conn_param.responder_resources = 1; - conn_param.initiator_depth = 1; - conn_param.retry_count = 5; - conn_param.private_data = test.rai->ai_connect; - conn_param.private_data_len = test.rai->ai_connect_len; - ret = rdma_connect(node->cma_id, &conn_param); - if (ret) { - perror("cmatose: failure connecting"); - goto err; - } - return 0; -err: - connect_error(); - return ret; -} - -static int connect_handler(struct rdma_cm_id *cma_id) -{ - struct cmatest_node *node; - int ret; - - if (test.conn_index == connections) { - ret = -ENOMEM; - goto err1; - } - node = &test.nodes[test.conn_index++]; - - node->cma_id = cma_id; - cma_id->context = node; - - ret = init_node(node); - if (ret) - goto err2; - - ret = post_recvs(node); - if (ret) - goto err2; - - ret = rdma_accept(node->cma_id, NULL); - if (ret) { - perror("cmatose: failure accepting"); - goto err2; - } - return 0; - -err2: - node->cma_id = NULL; - connect_error(); -err1: - printf("cmatose: failing connection request\n"); - rdma_reject(cma_id, NULL, 0); - return ret; -} - -static int cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) -{ - int ret = 0; - - switch (event->event) { - case RDMA_CM_EVENT_ADDR_RESOLVED: - ret = addr_handler(cma_id->context); - break; - case RDMA_CM_EVENT_ROUTE_RESOLVED: - ret = route_handler(cma_id->context); - break; - case RDMA_CM_EVENT_CONNECT_REQUEST: - ret = connect_handler(cma_id); - break; - case RDMA_CM_EVENT_ESTABLISHED: - ((struct cmatest_node *) cma_id->context)->connected = 1; - test.connects_left--; - test.disconnects_left++; - break; - case RDMA_CM_EVENT_ADDR_ERROR: - case RDMA_CM_EVENT_ROUTE_ERROR: - case RDMA_CM_EVENT_CONNECT_ERROR: - case RDMA_CM_EVENT_UNREACHABLE: - case RDMA_CM_EVENT_REJECTED: - printf("cmatose: event: %s, error: %d\n", - rdma_event_str(event->event), event->status); - connect_error(); - ret = event->status; - break; - case RDMA_CM_EVENT_DISCONNECTED: - rdma_disconnect(cma_id); - test.disconnects_left--; - break; - case RDMA_CM_EVENT_DEVICE_REMOVAL: - /* Cleanup will occur after test completes. */ - break; - default: - break; - } - return ret; -} - -static void destroy_node(struct cmatest_node *node) -{ - if (!node->cma_id) - return; - - if (node->cma_id->qp) - rdma_destroy_qp(node->cma_id); - - if (node->cq[SEND_CQ_INDEX]) - ibv_destroy_cq(node->cq[SEND_CQ_INDEX]); - - if (node->cq[RECV_CQ_INDEX]) - ibv_destroy_cq(node->cq[RECV_CQ_INDEX]); - - if (node->mem) { - ibv_dereg_mr(node->mr); - free(node->mem); - } - - if (node->pd) - ibv_dealloc_pd(node->pd); - - /* Destroy the RDMA ID after all device resources */ - rdma_destroy_id(node->cma_id); -} - -static int alloc_nodes(void) -{ - int ret, i; - - test.nodes = malloc(sizeof *test.nodes * connections); - if (!test.nodes) { - printf("cmatose: unable to allocate memory for test nodes\n"); - return -ENOMEM; - } - memset(test.nodes, 0, sizeof *test.nodes * connections); - - for (i = 0; i < connections; i++) { - test.nodes[i].id = i; - if (dst_addr) { - ret = rdma_create_id(test.channel, - &test.nodes[i].cma_id, - &test.nodes[i], hints.ai_port_space); - if (ret) - goto err; - } - } - return 0; -err: - while (--i >= 0) - rdma_destroy_id(test.nodes[i].cma_id); - free(test.nodes); - return ret; -} - -static void destroy_nodes(void) -{ - int i; - - for (i = 0; i < connections; i++) - destroy_node(&test.nodes[i]); - free(test.nodes); -} - -static int poll_cqs(enum CQ_INDEX index) -{ - struct ibv_wc wc[8]; - int done, i, ret; - - for (i = 0; i < connections; i++) { - if (!test.nodes[i].connected) - continue; - - for (done = 0; done < message_count; done += ret) { - ret = ibv_poll_cq(test.nodes[i].cq[index], 8, wc); - if (ret < 0) { - printf("cmatose: failed polling CQ: %d\n", ret); - return ret; - } - } - } - return 0; -} - -static int connect_events(void) -{ - struct rdma_cm_event *event; - int ret = 0; - - while (test.connects_left && !ret) { - ret = rdma_get_cm_event(test.channel, &event); - if (!ret) { - ret = cma_handler(event->id, event); - rdma_ack_cm_event(event); - } else { - perror("cmatose: failure in rdma_get_cm_event in connect events"); - ret = errno; - } - } - - return ret; -} - -static int disconnect_events(void) -{ - struct rdma_cm_event *event; - int ret = 0; - - while (test.disconnects_left && !ret) { - ret = rdma_get_cm_event(test.channel, &event); - if (!ret) { - ret = cma_handler(event->id, event); - rdma_ack_cm_event(event); - } else { - perror("cmatose: failure in rdma_get_cm_event in disconnect events"); - ret = errno; - } - } - - return ret; -} - -static int migrate_channel(struct rdma_cm_id *listen_id) -{ - struct rdma_event_channel *channel; - int i, ret; - - printf("migrating to new event channel\n"); - - channel = rdma_create_event_channel(); - if (!channel) { - perror("cmatose: failed to create event channel"); - return -1; - } - - ret = 0; - if (listen_id) - ret = rdma_migrate_id(listen_id, channel); - - for (i = 0; i < connections && !ret; i++) - ret = rdma_migrate_id(test.nodes[i].cma_id, channel); - - if (!ret) { - rdma_destroy_event_channel(test.channel); - test.channel = channel; - } else - perror("cmatose: failure migrating to channel"); - - return ret; -} - -static int run_server(void) -{ - struct rdma_cm_id *listen_id; - int i, ret; - - printf("cmatose: starting server\n"); - ret = rdma_create_id(test.channel, &listen_id, &test, hints.ai_port_space); - if (ret) { - perror("cmatose: listen request failed"); - return ret; - } - - ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai); - if (ret) { - printf("cmatose: getrdmaaddr error: %s\n", gai_strerror(ret)); - goto out; - } - - ret = rdma_bind_addr(listen_id, test.rai->ai_src_addr); - if (ret) { - perror("cmatose: bind address failed"); - goto out; - } - - ret = rdma_listen(listen_id, 0); - if (ret) { - perror("cmatose: failure trying to listen"); - goto out; - } - - ret = connect_events(); - if (ret) - goto out; - - if (message_count) { - printf("initiating data transfers\n"); - for (i = 0; i < connections; i++) { - ret = post_sends(&test.nodes[i]); - if (ret) - goto out; - } - - printf("completing sends\n"); - ret = poll_cqs(SEND_CQ_INDEX); - if (ret) - goto out; - - printf("receiving data transfers\n"); - ret = poll_cqs(RECV_CQ_INDEX); - if (ret) - goto out; - printf("data transfers complete\n"); - - } - - if (migrate) { - ret = migrate_channel(listen_id); - if (ret) - goto out; - } - - printf("cmatose: disconnecting\n"); - for (i = 0; i < connections; i++) { - if (!test.nodes[i].connected) - continue; - - test.nodes[i].connected = 0; - rdma_disconnect(test.nodes[i].cma_id); - } - - ret = disconnect_events(); - - printf("disconnected\n"); - -out: - rdma_destroy_id(listen_id); - return ret; -} - -static int run_client(void) -{ - int i, ret, ret2; - - printf("cmatose: starting client\n"); - - ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai); - if (ret) { - printf("cmatose: getaddrinfo error: %s\n", gai_strerror(ret)); - return ret; - } - - printf("cmatose: connecting\n"); - for (i = 0; i < connections; i++) { - ret = rdma_resolve_addr(test.nodes[i].cma_id, test.rai->ai_src_addr, - test.rai->ai_dst_addr, 2000); - if (ret) { - perror("cmatose: failure getting addr"); - connect_error(); - return ret; - } - } - - ret = connect_events(); - if (ret) - goto disc; - - if (message_count) { - printf("receiving data transfers\n"); - ret = poll_cqs(RECV_CQ_INDEX); - if (ret) - goto disc; - - printf("sending replies\n"); - for (i = 0; i < connections; i++) { - ret = post_sends(&test.nodes[i]); - if (ret) - goto disc; - } - - printf("data transfers complete\n"); - } - - ret = 0; - - if (migrate) { - ret = migrate_channel(NULL); - if (ret) - goto out; - } -disc: - ret2 = disconnect_events(); - if (ret2) - ret = ret2; -out: - return ret; -} - -int main(int argc, char **argv) -{ - int op, ret; - - hints.ai_port_space = RDMA_PS_TCP; - while ((op = getopt(argc, argv, "s:b:f:P:c:C:S:t:p:m")) != -1) { - switch (op) { - case 's': - dst_addr = optarg; - break; - case 'b': - src_addr = optarg; - break; - case 'f': - if (!strncasecmp("ip", optarg, 2)) { - hints.ai_flags = RAI_NUMERICHOST; - } else if (!strncasecmp("gid", optarg, 3)) { - hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY; - hints.ai_family = AF_IB; - } else if (strncasecmp("name", optarg, 4)) { - fprintf(stderr, "Warning: unknown address format\n"); - } - break; - case 'P': - if (!strncasecmp("ib", optarg, 2)) { - hints.ai_port_space = RDMA_PS_IB; - } else if (strncasecmp("tcp", optarg, 3)) { - fprintf(stderr, "Warning: unknown port space format\n"); - } - break; - case 'c': - connections = atoi(optarg); - break; - case 'C': - message_count = atoi(optarg); - break; - case 'S': - message_size = atoi(optarg); - break; - case 't': - set_tos = 1; - tos = (uint8_t) strtoul(optarg, NULL, 0); - break; - case 'p': - port = optarg; - break; - case 'm': - migrate = 1; - break; - default: - printf("usage: %s\n", argv[0]); - printf("\t[-s server_address]\n"); - printf("\t[-b bind_address]\n"); - printf("\t[-f address_format]\n"); - printf("\t name, ip, ipv6, or gid\n"); - printf("\t[-P port_space]\n"); - printf("\t tcp or ib\n"); - printf("\t[-c connections]\n"); - printf("\t[-C message_count]\n"); - printf("\t[-S message_size]\n"); - printf("\t[-t type_of_service]\n"); - printf("\t[-p port_number]\n"); - printf("\t[-m(igrate)]\n"); - exit(1); - } - } - - test.connects_left = connections; - - test.channel = rdma_create_event_channel(); - if (!test.channel) { - printf("failed to create event channel\n"); - exit(1); - } - - if (alloc_nodes()) - exit(1); - - if (dst_addr) { - ret = run_client(); - } else { - hints.ai_flags |= RAI_PASSIVE; - ret = run_server(); - } - - printf("test complete\n"); - destroy_nodes(); - rdma_destroy_event_channel(test.channel); - if (test.rai) - rdma_freeaddrinfo(test.rai); - - printf("return status %d\n", ret); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/cmtime.c b/usr/rdma-core/librdmacm/examples/cmtime.c deleted file mode 100644 index aa96b9019..000000000 --- a/usr/rdma-core/librdmacm/examples/cmtime.c +++ /dev/null @@ -1,677 +0,0 @@ -/* - * Copyright (c) 2013 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "common.h" - -static struct rdma_addrinfo hints, *rai; -static struct rdma_event_channel *channel; -static const char *port = "7471"; -static char *dst_addr; -static char *src_addr; -static int timeout = 2000; -static int retries = 2; - -enum step { - STEP_CREATE_ID, - STEP_BIND, - STEP_RESOLVE_ADDR, - STEP_RESOLVE_ROUTE, - STEP_CREATE_QP, - STEP_CONNECT, - STEP_DISCONNECT, - STEP_DESTROY, - STEP_CNT -}; - -static const char *step_str[] = { - "create id", - "bind addr", - "resolve addr", - "resolve route", - "create qp", - "connect", - "disconnect", - "destroy" -}; - -struct node { - struct rdma_cm_id *id; - struct timeval times[STEP_CNT][2]; - int error; - int retries; -}; - -struct list_head { - struct list_head *prev; - struct list_head *next; - struct rdma_cm_id *id; -}; - -struct work_list { - pthread_mutex_t lock; - pthread_cond_t cond; - struct list_head list; -}; - -#define INIT_LIST(x) ((x)->prev = (x)->next = (x)) - -static struct work_list req_work; -static struct work_list disc_work; -static struct node *nodes; -static struct timeval times[STEP_CNT][2]; -static int connections = 100; -static volatile int started[STEP_CNT]; -static volatile int completed[STEP_CNT]; -static struct ibv_qp_init_attr init_qp_attr; -static struct rdma_conn_param conn_param; - -#define start_perf(n, s) gettimeofday(&((n)->times[s][0]), NULL) -#define end_perf(n, s) gettimeofday(&((n)->times[s][1]), NULL) -#define start_time(s) gettimeofday(×[s][0], NULL) -#define end_time(s) gettimeofday(×[s][1], NULL) - -static inline void __list_delete(struct list_head *list) -{ - struct list_head *prev, *next; - prev = list->prev; - next = list->next; - prev->next = next; - next->prev = prev; - INIT_LIST(list); -} - -static inline int __list_empty(struct work_list *list) -{ - return list->list.next == &list->list; -} - -static inline struct list_head *__list_remove_head(struct work_list *work_list) -{ - struct list_head *list_item; - - list_item = work_list->list.next; - __list_delete(list_item); - return list_item; -} - -static inline void list_add_tail(struct work_list *work_list, struct list_head *req) -{ - int empty; - pthread_mutex_lock(&work_list->lock); - empty = __list_empty(work_list); - req->prev = work_list->list.prev; - req->next = &work_list->list; - req->prev->next = work_list->list.prev = req; - pthread_mutex_unlock(&work_list->lock); - if (empty) - pthread_cond_signal(&work_list->cond); -} - -static int zero_time(struct timeval *t) -{ - return !(t->tv_sec || t->tv_usec); -} - -static float diff_us(struct timeval *end, struct timeval *start) -{ - return (end->tv_sec - start->tv_sec) * 1000000. + (end->tv_usec - start->tv_usec); -} - -static void show_perf(void) -{ - int c, i; - float us, max[STEP_CNT], min[STEP_CNT]; - - for (i = 0; i < STEP_CNT; i++) { - max[i] = 0; - min[i] = 999999999.; - for (c = 0; c < connections; c++) { - if (!zero_time(&nodes[c].times[i][0]) && - !zero_time(&nodes[c].times[i][1])) { - us = diff_us(&nodes[c].times[i][1], &nodes[c].times[i][0]); - if (us > max[i]) - max[i] = us; - if (us < min[i]) - min[i] = us; - } - } - } - - printf("step total ms max ms min us us / conn\n"); - for (i = 0; i < STEP_CNT; i++) { - if (i == STEP_BIND && !src_addr) - continue; - - us = diff_us(×[i][1], ×[i][0]); - printf("%-13s: %11.2f%11.2f%11.2f%11.2f\n", step_str[i], us / 1000., - max[i] / 1000., min[i], us / connections); - } -} - -static void addr_handler(struct node *n) -{ - end_perf(n, STEP_RESOLVE_ADDR); - completed[STEP_RESOLVE_ADDR]++; -} - -static void route_handler(struct node *n) -{ - end_perf(n, STEP_RESOLVE_ROUTE); - completed[STEP_RESOLVE_ROUTE]++; -} - -static void conn_handler(struct node *n) -{ - end_perf(n, STEP_CONNECT); - completed[STEP_CONNECT]++; -} - -static void disc_handler(struct node *n) -{ - end_perf(n, STEP_DISCONNECT); - completed[STEP_DISCONNECT]++; -} - -static void __req_handler(struct rdma_cm_id *id) -{ - int ret; - - ret = rdma_create_qp(id, NULL, &init_qp_attr); - if (ret) { - perror("failure creating qp"); - goto err; - } - - ret = rdma_accept(id, NULL); - if (ret) { - perror("failure accepting"); - goto err; - } - return; - -err: - printf("failing connection request\n"); - rdma_reject(id, NULL, 0); - rdma_destroy_id(id); - return; -} - -static void *req_handler_thread(void *arg) -{ - struct list_head *work; - do { - pthread_mutex_lock(&req_work.lock); - if (__list_empty(&req_work)) - pthread_cond_wait(&req_work.cond, &req_work.lock); - work = __list_remove_head(&req_work); - pthread_mutex_unlock(&req_work.lock); - __req_handler(work->id); - free(work); - } while (1); - return NULL; -} - -static void *disc_handler_thread(void *arg) -{ - struct list_head *work; - do { - pthread_mutex_lock(&disc_work.lock); - if (__list_empty(&disc_work)) - pthread_cond_wait(&disc_work.cond, &disc_work.lock); - work = __list_remove_head(&disc_work); - pthread_mutex_unlock(&disc_work.lock); - rdma_disconnect(work->id); - rdma_destroy_id(work->id); - free(work); - } while (1); - return NULL; -} - -static void cma_handler(struct rdma_cm_id *id, struct rdma_cm_event *event) -{ - struct node *n = id->context; - struct list_head *request; - - switch (event->event) { - case RDMA_CM_EVENT_ADDR_RESOLVED: - addr_handler(n); - break; - case RDMA_CM_EVENT_ROUTE_RESOLVED: - route_handler(n); - break; - case RDMA_CM_EVENT_CONNECT_REQUEST: - request = malloc(sizeof *request); - if (!request) { - perror("out of memory accepting connect request"); - rdma_reject(id, NULL, 0); - rdma_destroy_id(id); - } else { - INIT_LIST(request); - request->id = id; - list_add_tail(&req_work, request); - } - break; - case RDMA_CM_EVENT_ESTABLISHED: - if (n) - conn_handler(n); - break; - case RDMA_CM_EVENT_ADDR_ERROR: - if (n->retries--) { - if (!rdma_resolve_addr(n->id, rai->ai_src_addr, - rai->ai_dst_addr, timeout)) - break; - } - printf("RDMA_CM_EVENT_ADDR_ERROR, error: %d\n", event->status); - addr_handler(n); - n->error = 1; - break; - case RDMA_CM_EVENT_ROUTE_ERROR: - if (n->retries--) { - if (!rdma_resolve_route(n->id, timeout)) - break; - } - printf("RDMA_CM_EVENT_ROUTE_ERROR, error: %d\n", event->status); - route_handler(n); - n->error = 1; - break; - case RDMA_CM_EVENT_CONNECT_ERROR: - case RDMA_CM_EVENT_UNREACHABLE: - case RDMA_CM_EVENT_REJECTED: - printf("event: %s, error: %d\n", - rdma_event_str(event->event), event->status); - conn_handler(n); - n->error = 1; - break; - case RDMA_CM_EVENT_DISCONNECTED: - if (!n) { - request = malloc(sizeof *request); - if (!request) { - perror("out of memory queueing disconnect request, handling synchronously"); - rdma_disconnect(id); - rdma_destroy_id(id); - } else { - INIT_LIST(request); - request->id = id; - list_add_tail(&disc_work, request); - } - } else - disc_handler(n); - break; - case RDMA_CM_EVENT_DEVICE_REMOVAL: - /* Cleanup will occur after test completes. */ - break; - default: - break; - } - rdma_ack_cm_event(event); -} - -static int alloc_nodes(void) -{ - int ret, i; - - nodes = calloc(sizeof *nodes, connections); - if (!nodes) - return -ENOMEM; - - printf("creating id\n"); - start_time(STEP_CREATE_ID); - for (i = 0; i < connections; i++) { - start_perf(&nodes[i], STEP_CREATE_ID); - if (dst_addr) { - ret = rdma_create_id(channel, &nodes[i].id, &nodes[i], - hints.ai_port_space); - if (ret) - goto err; - } - end_perf(&nodes[i], STEP_CREATE_ID); - } - end_time(STEP_CREATE_ID); - return 0; - -err: - while (--i >= 0) - rdma_destroy_id(nodes[i].id); - free(nodes); - return ret; -} - -static void cleanup_nodes(void) -{ - int i; - - printf("destroying id\n"); - start_time(STEP_DESTROY); - for (i = 0; i < connections; i++) { - start_perf(&nodes[i], STEP_DESTROY); - if (nodes[i].id) - rdma_destroy_id(nodes[i].id); - end_perf(&nodes[i], STEP_DESTROY); - } - end_time(STEP_DESTROY); -} - -static void *process_events(void *arg) -{ - struct rdma_cm_event *event; - int ret = 0; - - while (!ret) { - ret = rdma_get_cm_event(channel, &event); - if (!ret) { - cma_handler(event->id, event); - } else { - perror("failure in rdma_get_cm_event in process_server_events"); - ret = errno; - } - } - return NULL; -} - -static int run_server(void) -{ - pthread_t req_thread, disc_thread; - struct rdma_cm_id *listen_id; - int ret; - - INIT_LIST(&req_work.list); - INIT_LIST(&disc_work.list); - ret = pthread_mutex_init(&req_work.lock, NULL); - if (ret) { - perror("initializing mutex for req work"); - return ret; - } - - ret = pthread_mutex_init(&disc_work.lock, NULL); - if (ret) { - perror("initializing mutex for disc work"); - return ret; - } - - ret = pthread_cond_init(&req_work.cond, NULL); - if (ret) { - perror("initializing cond for req work"); - return ret; - } - - ret = pthread_cond_init(&disc_work.cond, NULL); - if (ret) { - perror("initializing cond for disc work"); - return ret; - } - - ret = pthread_create(&req_thread, NULL, req_handler_thread, NULL); - if (ret) { - perror("failed to create req handler thread"); - return ret; - } - - ret = pthread_create(&disc_thread, NULL, disc_handler_thread, NULL); - if (ret) { - perror("failed to create disconnect handler thread"); - return ret; - } - - ret = rdma_create_id(channel, &listen_id, NULL, hints.ai_port_space); - if (ret) { - perror("listen request failed"); - return ret; - } - - ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai); - if (ret) { - printf("getrdmaaddr error: %s\n", gai_strerror(ret)); - goto out; - } - - ret = rdma_bind_addr(listen_id, rai->ai_src_addr); - if (ret) { - perror("bind address failed"); - goto out; - } - - ret = rdma_listen(listen_id, 0); - if (ret) { - perror("failure trying to listen"); - goto out; - } - - process_events(NULL); - out: - rdma_destroy_id(listen_id); - return ret; -} - -static int run_client(void) -{ - pthread_t event_thread; - int i, ret; - - ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai); - if (ret) { - printf("getaddrinfo error: %s\n", gai_strerror(ret)); - return ret; - } - - conn_param.responder_resources = 1; - conn_param.initiator_depth = 1; - conn_param.retry_count = retries; - conn_param.private_data = rai->ai_connect; - conn_param.private_data_len = rai->ai_connect_len; - - ret = pthread_create(&event_thread, NULL, process_events, NULL); - if (ret) { - perror("failure creating event thread"); - return ret; - } - - if (src_addr) { - printf("binding source address\n"); - start_time(STEP_BIND); - for (i = 0; i < connections; i++) { - start_perf(&nodes[i], STEP_BIND); - ret = rdma_bind_addr(nodes[i].id, rai->ai_src_addr); - if (ret) { - perror("failure bind addr"); - nodes[i].error = 1; - continue; - } - end_perf(&nodes[i], STEP_BIND); - } - end_time(STEP_BIND); - } - - printf("resolving address\n"); - start_time(STEP_RESOLVE_ADDR); - for (i = 0; i < connections; i++) { - if (nodes[i].error) - continue; - nodes[i].retries = retries; - start_perf(&nodes[i], STEP_RESOLVE_ADDR); - ret = rdma_resolve_addr(nodes[i].id, rai->ai_src_addr, - rai->ai_dst_addr, timeout); - if (ret) { - perror("failure getting addr"); - nodes[i].error = 1; - continue; - } - started[STEP_RESOLVE_ADDR]++; - } - while (started[STEP_RESOLVE_ADDR] != completed[STEP_RESOLVE_ADDR]) sched_yield(); - end_time(STEP_RESOLVE_ADDR); - - printf("resolving route\n"); - start_time(STEP_RESOLVE_ROUTE); - for (i = 0; i < connections; i++) { - if (nodes[i].error) - continue; - nodes[i].retries = retries; - start_perf(&nodes[i], STEP_RESOLVE_ROUTE); - ret = rdma_resolve_route(nodes[i].id, timeout); - if (ret) { - perror("failure resolving route"); - nodes[i].error = 1; - continue; - } - started[STEP_RESOLVE_ROUTE]++; - } - while (started[STEP_RESOLVE_ROUTE] != completed[STEP_RESOLVE_ROUTE]) sched_yield(); - end_time(STEP_RESOLVE_ROUTE); - - printf("creating qp\n"); - start_time(STEP_CREATE_QP); - for (i = 0; i < connections; i++) { - if (nodes[i].error) - continue; - start_perf(&nodes[i], STEP_CREATE_QP); - ret = rdma_create_qp(nodes[i].id, NULL, &init_qp_attr); - if (ret) { - perror("failure creating qp"); - nodes[i].error = 1; - continue; - } - end_perf(&nodes[i], STEP_CREATE_QP); - } - end_time(STEP_CREATE_QP); - - printf("connecting\n"); - start_time(STEP_CONNECT); - for (i = 0; i < connections; i++) { - if (nodes[i].error) - continue; - start_perf(&nodes[i], STEP_CONNECT); - ret = rdma_connect(nodes[i].id, &conn_param); - if (ret) { - perror("failure rconnecting"); - nodes[i].error = 1; - continue; - } - started[STEP_CONNECT]++; - } - while (started[STEP_CONNECT] != completed[STEP_CONNECT]) sched_yield(); - end_time(STEP_CONNECT); - - printf("disconnecting\n"); - start_time(STEP_DISCONNECT); - for (i = 0; i < connections; i++) { - if (nodes[i].error) - continue; - start_perf(&nodes[i], STEP_DISCONNECT); - rdma_disconnect(nodes[i].id); - started[STEP_DISCONNECT]++; - } - while (started[STEP_DISCONNECT] != completed[STEP_DISCONNECT]) sched_yield(); - end_time(STEP_DISCONNECT); - - return ret; -} - -int main(int argc, char **argv) -{ - int op, ret; - - hints.ai_port_space = RDMA_PS_TCP; - hints.ai_qp_type = IBV_QPT_RC; - while ((op = getopt(argc, argv, "s:b:c:p:r:t:")) != -1) { - switch (op) { - case 's': - dst_addr = optarg; - break; - case 'b': - src_addr = optarg; - break; - case 'c': - connections = atoi(optarg); - break; - case 'p': - port = optarg; - break; - case 'r': - retries = atoi(optarg); - break; - case 't': - timeout = atoi(optarg); - break; - default: - printf("usage: %s\n", argv[0]); - printf("\t[-s server_address]\n"); - printf("\t[-b bind_address]\n"); - printf("\t[-c connections]\n"); - printf("\t[-p port_number]\n"); - printf("\t[-r retries]\n"); - printf("\t[-t timeout_ms]\n"); - exit(1); - } - } - - init_qp_attr.cap.max_send_wr = 1; - init_qp_attr.cap.max_recv_wr = 1; - init_qp_attr.cap.max_send_sge = 1; - init_qp_attr.cap.max_recv_sge = 1; - init_qp_attr.qp_type = IBV_QPT_RC; - - channel = rdma_create_event_channel(); - if (!channel) { - printf("failed to create event channel\n"); - exit(1); - } - - if (dst_addr) { - alloc_nodes(); - ret = run_client(); - } else { - hints.ai_flags |= RAI_PASSIVE; - ret = run_server(); - } - - cleanup_nodes(); - rdma_destroy_event_channel(channel); - if (rai) - rdma_freeaddrinfo(rai); - - show_perf(); - free(nodes); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/common.c b/usr/rdma-core/librdmacm/examples/common.c deleted file mode 100644 index 6225821c0..000000000 --- a/usr/rdma-core/librdmacm/examples/common.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2005-2006,2012 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "common.h" - -int use_rs = 1; - -int get_rdma_addr(const char *src, const char *dst, const char *port, - struct rdma_addrinfo *hints, struct rdma_addrinfo **rai) -{ - struct rdma_addrinfo rai_hints, *res; - int ret; - - if (hints->ai_flags & RAI_PASSIVE) - return rdma_getaddrinfo(src, port, hints, rai); - - rai_hints = *hints; - if (src) { - rai_hints.ai_flags |= RAI_PASSIVE; - ret = rdma_getaddrinfo(src, NULL, &rai_hints, &res); - if (ret) - return ret; - - rai_hints.ai_src_addr = res->ai_src_addr; - rai_hints.ai_src_len = res->ai_src_len; - rai_hints.ai_flags &= ~RAI_PASSIVE; - } - - ret = rdma_getaddrinfo(dst, port, &rai_hints, rai); - if (src) - rdma_freeaddrinfo(res); - - return ret; -} - -void size_str(char *str, size_t ssize, long long size) -{ - long long base, fraction = 0; - char mag; - - if (size >= (1 << 30)) { - base = 1 << 30; - mag = 'g'; - } else if (size >= (1 << 20)) { - base = 1 << 20; - mag = 'm'; - } else if (size >= (1 << 10)) { - base = 1 << 10; - mag = 'k'; - } else { - base = 1; - mag = '\0'; - } - - if (size / base < 10) - fraction = (size % base) * 10 / base; - if (fraction) { - snprintf(str, ssize, "%lld.%lld%c", size / base, fraction, mag); - } else { - snprintf(str, ssize, "%lld%c", size / base, mag); - } -} - -void cnt_str(char *str, size_t ssize, long long cnt) -{ - if (cnt >= 1000000000) - snprintf(str, ssize, "%lldb", cnt / 1000000000); - else if (cnt >= 1000000) - snprintf(str, ssize, "%lldm", cnt / 1000000); - else if (cnt >= 1000) - snprintf(str, ssize, "%lldk", cnt / 1000); - else - snprintf(str, ssize, "%lld", cnt); -} - -int size_to_count(int size) -{ - if (size >= (1 << 20)) - return 100; - else if (size >= (1 << 16)) - return 1000; - else if (size >= (1 << 10)) - return 10000; - else - return 100000; -} - -void format_buf(void *buf, int size) -{ - uint8_t *array = buf; - static uint8_t data; - int i; - - for (i = 0; i < size; i++) - array[i] = data++; -} - -int verify_buf(void *buf, int size) -{ - static long long total_bytes; - uint8_t *array = buf; - static uint8_t data; - int i; - - for (i = 0; i < size; i++, total_bytes++) { - if (array[i] != data++) { - printf("data verification failed byte %lld\n", total_bytes); - return -1; - } - } - return 0; -} - -int do_poll(struct pollfd *fds, int timeout) -{ - int ret; - - do { - ret = rs_poll(fds, 1, timeout); - } while (!ret); - - return ret == 1 ? (fds->revents & (POLLERR | POLLHUP)) : ret; -} diff --git a/usr/rdma-core/librdmacm/examples/common.h b/usr/rdma-core/librdmacm/examples/common.h deleted file mode 100644 index 1e69f5091..000000000 --- a/usr/rdma-core/librdmacm/examples/common.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2005-2012 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#include -#include -#include -#include - -#include -#include -#include - -extern int use_rs; - -#define rs_socket(f,t,p) use_rs ? rsocket(f,t,p) : socket(f,t,p) -#define rs_bind(s,a,l) use_rs ? rbind(s,a,l) : bind(s,a,l) -#define rs_listen(s,b) use_rs ? rlisten(s,b) : listen(s,b) -#define rs_connect(s,a,l) use_rs ? rconnect(s,a,l) : connect(s,a,l) -#define rs_accept(s,a,l) use_rs ? raccept(s,a,l) : accept(s,a,l) -#define rs_shutdown(s,h) use_rs ? rshutdown(s,h) : shutdown(s,h) -#define rs_close(s) use_rs ? rclose(s) : close(s) -#define rs_recv(s,b,l,f) use_rs ? rrecv(s,b,l,f) : recv(s,b,l,f) -#define rs_send(s,b,l,f) use_rs ? rsend(s,b,l,f) : send(s,b,l,f) -#define rs_recvfrom(s,b,l,f,a,al) \ - use_rs ? rrecvfrom(s,b,l,f,a,al) : recvfrom(s,b,l,f,a,al) -#define rs_sendto(s,b,l,f,a,al) \ - use_rs ? rsendto(s,b,l,f,a,al) : sendto(s,b,l,f,a,al) -#define rs_poll(f,n,t) use_rs ? rpoll(f,n,t) : poll(f,n,t) -#define rs_fcntl(s,c,p) use_rs ? rfcntl(s,c,p) : fcntl(s,c,p) -#define rs_setsockopt(s,l,n,v,ol) \ - use_rs ? rsetsockopt(s,l,n,v,ol) : setsockopt(s,l,n,v,ol) -#define rs_getsockopt(s,l,n,v,ol) \ - use_rs ? rgetsockopt(s,l,n,v,ol) : getsockopt(s,l,n,v,ol) - -union socket_addr { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; -}; - -enum rs_optimization { - opt_mixed, - opt_latency, - opt_bandwidth -}; - -int get_rdma_addr(const char *src, const char *dst, const char *port, - struct rdma_addrinfo *hints, struct rdma_addrinfo **rai); - -void size_str(char *str, size_t ssize, long long size); -void cnt_str(char *str, size_t ssize, long long cnt); -int size_to_count(int size); -void format_buf(void *buf, int size); -int verify_buf(void *buf, int size); -int do_poll(struct pollfd *fds, int timeout); diff --git a/usr/rdma-core/librdmacm/examples/mckey.c b/usr/rdma-core/librdmacm/examples/mckey.c deleted file mode 100644 index 60cf8a240..000000000 --- a/usr/rdma-core/librdmacm/examples/mckey.c +++ /dev/null @@ -1,629 +0,0 @@ -/* - * Copyright (c) 2005-2007 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -struct cmatest_node { - int id; - struct rdma_cm_id *cma_id; - int connected; - struct ibv_pd *pd; - struct ibv_cq *cq; - struct ibv_mr *mr; - struct ibv_ah *ah; - uint32_t remote_qpn; - uint32_t remote_qkey; - void *mem; -}; - -struct cmatest { - struct rdma_event_channel *channel; - pthread_t cmathread; - struct cmatest_node *nodes; - int conn_index; - int connects_left; - - struct sockaddr_storage dst_in; - struct sockaddr *dst_addr; - struct sockaddr_storage src_in; - struct sockaddr *src_addr; -}; - -static struct cmatest test; -static int connections = 1; -static int message_size = 100; -static int message_count = 10; -static int is_sender; -static int unmapped_addr; -static char *dst_addr; -static char *src_addr; -static enum rdma_port_space port_space = RDMA_PS_UDP; - -static int create_message(struct cmatest_node *node) -{ - if (!message_size) - message_count = 0; - - if (!message_count) - return 0; - - node->mem = malloc(message_size + sizeof(struct ibv_grh)); - if (!node->mem) { - printf("failed message allocation\n"); - return -1; - } - node->mr = ibv_reg_mr(node->pd, node->mem, - message_size + sizeof(struct ibv_grh), - IBV_ACCESS_LOCAL_WRITE); - if (!node->mr) { - printf("failed to reg MR\n"); - goto err; - } - return 0; -err: - free(node->mem); - return -1; -} - -static int verify_test_params(struct cmatest_node *node) -{ - struct ibv_port_attr port_attr; - int ret; - - ret = ibv_query_port(node->cma_id->verbs, node->cma_id->port_num, - &port_attr); - if (ret) - return ret; - - if (message_count && message_size > (1 << (port_attr.active_mtu + 7))) { - printf("mckey: message_size %d is larger than active mtu %d\n", - message_size, 1 << (port_attr.active_mtu + 7)); - return -EINVAL; - } - - return 0; -} - -static int init_node(struct cmatest_node *node) -{ - struct ibv_qp_init_attr init_qp_attr; - int cqe, ret; - - node->pd = ibv_alloc_pd(node->cma_id->verbs); - if (!node->pd) { - ret = -ENOMEM; - printf("mckey: unable to allocate PD\n"); - goto out; - } - - cqe = message_count ? message_count * 2 : 2; - node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, NULL, 0); - if (!node->cq) { - ret = -ENOMEM; - printf("mckey: unable to create CQ\n"); - goto out; - } - - memset(&init_qp_attr, 0, sizeof init_qp_attr); - init_qp_attr.cap.max_send_wr = message_count ? message_count : 1; - init_qp_attr.cap.max_recv_wr = message_count ? message_count : 1; - init_qp_attr.cap.max_send_sge = 1; - init_qp_attr.cap.max_recv_sge = 1; - init_qp_attr.qp_context = node; - init_qp_attr.sq_sig_all = 0; - init_qp_attr.qp_type = IBV_QPT_UD; - init_qp_attr.send_cq = node->cq; - init_qp_attr.recv_cq = node->cq; - ret = rdma_create_qp(node->cma_id, node->pd, &init_qp_attr); - if (ret) { - perror("mckey: unable to create QP"); - goto out; - } - - ret = create_message(node); - if (ret) { - printf("mckey: failed to create messages: %d\n", ret); - goto out; - } -out: - return ret; -} - -static int post_recvs(struct cmatest_node *node) -{ - struct ibv_recv_wr recv_wr, *recv_failure; - struct ibv_sge sge; - int i, ret = 0; - - if (!message_count) - return 0; - - recv_wr.next = NULL; - recv_wr.sg_list = &sge; - recv_wr.num_sge = 1; - recv_wr.wr_id = (uintptr_t) node; - - sge.length = message_size + sizeof(struct ibv_grh); - sge.lkey = node->mr->lkey; - sge.addr = (uintptr_t) node->mem; - - for (i = 0; i < message_count && !ret; i++ ) { - ret = ibv_post_recv(node->cma_id->qp, &recv_wr, &recv_failure); - if (ret) { - printf("failed to post receives: %d\n", ret); - break; - } - } - return ret; -} - -static int post_sends(struct cmatest_node *node, int signal_flag) -{ - struct ibv_send_wr send_wr, *bad_send_wr; - struct ibv_sge sge; - int i, ret = 0; - - if (!node->connected || !message_count) - return 0; - - send_wr.next = NULL; - send_wr.sg_list = &sge; - send_wr.num_sge = 1; - send_wr.opcode = IBV_WR_SEND_WITH_IMM; - send_wr.send_flags = signal_flag; - send_wr.wr_id = (unsigned long)node; - send_wr.imm_data = htobe32(node->cma_id->qp->qp_num); - - send_wr.wr.ud.ah = node->ah; - send_wr.wr.ud.remote_qpn = node->remote_qpn; - send_wr.wr.ud.remote_qkey = node->remote_qkey; - - sge.length = message_size; - sge.lkey = node->mr->lkey; - sge.addr = (uintptr_t) node->mem; - - for (i = 0; i < message_count && !ret; i++) { - ret = ibv_post_send(node->cma_id->qp, &send_wr, &bad_send_wr); - if (ret) - printf("failed to post sends: %d\n", ret); - } - return ret; -} - -static void connect_error(void) -{ - test.connects_left--; -} - -static int addr_handler(struct cmatest_node *node) -{ - int ret; - - ret = verify_test_params(node); - if (ret) - goto err; - - ret = init_node(node); - if (ret) - goto err; - - if (!is_sender) { - ret = post_recvs(node); - if (ret) - goto err; - } - - ret = rdma_join_multicast(node->cma_id, test.dst_addr, node); - if (ret) { - perror("mckey: failure joining"); - goto err; - } - return 0; -err: - connect_error(); - return ret; -} - -static int join_handler(struct cmatest_node *node, - struct rdma_ud_param *param) -{ - char buf[40]; - - inet_ntop(AF_INET6, param->ah_attr.grh.dgid.raw, buf, 40); - printf("mckey: joined dgid: %s mlid 0x%x sl %d\n", buf, - param->ah_attr.dlid, param->ah_attr.sl); - - node->remote_qpn = param->qp_num; - node->remote_qkey = param->qkey; - node->ah = ibv_create_ah(node->pd, ¶m->ah_attr); - if (!node->ah) { - printf("mckey: failure creating address handle\n"); - goto err; - } - - node->connected = 1; - test.connects_left--; - return 0; -err: - connect_error(); - return -1; -} - -static int cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) -{ - int ret = 0; - - switch (event->event) { - case RDMA_CM_EVENT_ADDR_RESOLVED: - ret = addr_handler(cma_id->context); - break; - case RDMA_CM_EVENT_MULTICAST_JOIN: - ret = join_handler(cma_id->context, &event->param.ud); - break; - case RDMA_CM_EVENT_ADDR_ERROR: - case RDMA_CM_EVENT_ROUTE_ERROR: - case RDMA_CM_EVENT_MULTICAST_ERROR: - printf("mckey: event: %s, error: %d\n", - rdma_event_str(event->event), event->status); - connect_error(); - ret = event->status; - break; - case RDMA_CM_EVENT_DEVICE_REMOVAL: - /* Cleanup will occur after test completes. */ - break; - default: - break; - } - return ret; -} - -static void *cma_thread(void *arg) -{ - struct rdma_cm_event *event; - int ret; - - while (1) { - ret = rdma_get_cm_event(test.channel, &event); - if (ret) { - perror("rdma_get_cm_event"); - break; - } - - switch (event->event) { - case RDMA_CM_EVENT_MULTICAST_ERROR: - case RDMA_CM_EVENT_ADDR_CHANGE: - printf("mckey: event: %s, status: %d\n", - rdma_event_str(event->event), event->status); - break; - default: - break; - } - - rdma_ack_cm_event(event); - } - return NULL; -} - -static void destroy_node(struct cmatest_node *node) -{ - if (!node->cma_id) - return; - - if (node->ah) - ibv_destroy_ah(node->ah); - - if (node->cma_id->qp) - rdma_destroy_qp(node->cma_id); - - if (node->cq) - ibv_destroy_cq(node->cq); - - if (node->mem) { - ibv_dereg_mr(node->mr); - free(node->mem); - } - - if (node->pd) - ibv_dealloc_pd(node->pd); - - /* Destroy the RDMA ID after all device resources */ - rdma_destroy_id(node->cma_id); -} - -static int alloc_nodes(void) -{ - int ret, i; - - test.nodes = malloc(sizeof *test.nodes * connections); - if (!test.nodes) { - printf("mckey: unable to allocate memory for test nodes\n"); - return -ENOMEM; - } - memset(test.nodes, 0, sizeof *test.nodes * connections); - - for (i = 0; i < connections; i++) { - test.nodes[i].id = i; - ret = rdma_create_id(test.channel, &test.nodes[i].cma_id, - &test.nodes[i], port_space); - if (ret) - goto err; - } - return 0; -err: - while (--i >= 0) - rdma_destroy_id(test.nodes[i].cma_id); - free(test.nodes); - return ret; -} - -static void destroy_nodes(void) -{ - int i; - - for (i = 0; i < connections; i++) - destroy_node(&test.nodes[i]); - free(test.nodes); -} - -static int poll_cqs(void) -{ - struct ibv_wc wc[8]; - int done, i, ret; - - for (i = 0; i < connections; i++) { - if (!test.nodes[i].connected) - continue; - - for (done = 0; done < message_count; done += ret) { - ret = ibv_poll_cq(test.nodes[i].cq, 8, wc); - if (ret < 0) { - printf("mckey: failed polling CQ: %d\n", ret); - return ret; - } - } - } - return 0; -} - -static int connect_events(void) -{ - struct rdma_cm_event *event; - int ret = 0; - - while (test.connects_left && !ret) { - ret = rdma_get_cm_event(test.channel, &event); - if (!ret) { - ret = cma_handler(event->id, event); - rdma_ack_cm_event(event); - } - } - return ret; -} - -static int get_addr(char *dst, struct sockaddr *addr) -{ - struct addrinfo *res; - int ret; - - ret = getaddrinfo(dst, NULL, NULL, &res); - if (ret) { - printf("getaddrinfo failed (%s) - invalid hostname or IP address\n", gai_strerror(ret)); - return ret; - } - - memcpy(addr, res->ai_addr, res->ai_addrlen); - freeaddrinfo(res); - return ret; -} - -static int get_dst_addr(char *dst, struct sockaddr *addr) -{ - struct sockaddr_ib *sib; - - if (!unmapped_addr) - return get_addr(dst, addr); - - sib = (struct sockaddr_ib *) addr; - memset(sib, 0, sizeof *sib); - sib->sib_family = AF_IB; - inet_pton(AF_INET6, dst, &sib->sib_addr); - return 0; -} - -static int run(void) -{ - int i, ret; - - printf("mckey: starting %s\n", is_sender ? "client" : "server"); - if (src_addr) { - ret = get_addr(src_addr, (struct sockaddr *) &test.src_in); - if (ret) - return ret; - } - - ret = get_dst_addr(dst_addr, (struct sockaddr *) &test.dst_in); - if (ret) - return ret; - - printf("mckey: joining\n"); - for (i = 0; i < connections; i++) { - if (src_addr) { - ret = rdma_bind_addr(test.nodes[i].cma_id, - test.src_addr); - if (ret) { - perror("mckey: addr bind failure"); - connect_error(); - return ret; - } - } - - if (unmapped_addr) - ret = addr_handler(&test.nodes[i]); - else - ret = rdma_resolve_addr(test.nodes[i].cma_id, - test.src_addr, test.dst_addr, - 2000); - if (ret) { - perror("mckey: resolve addr failure"); - connect_error(); - return ret; - } - } - - ret = connect_events(); - if (ret) - goto out; - - pthread_create(&test.cmathread, NULL, cma_thread, NULL); - - /* - * Pause to give SM chance to configure switches. We don't want to - * handle reliability issue in this simple test program. - */ - sleep(3); - - if (message_count) { - if (is_sender) { - printf("initiating data transfers\n"); - for (i = 0; i < connections; i++) { - ret = post_sends(&test.nodes[i], 0); - if (ret) - goto out; - } - } else { - printf("receiving data transfers\n"); - ret = poll_cqs(); - if (ret) - goto out; - } - printf("data transfers complete\n"); - } -out: - for (i = 0; i < connections; i++) { - ret = rdma_leave_multicast(test.nodes[i].cma_id, - test.dst_addr); - if (ret) - perror("mckey: failure leaving"); - } - return ret; -} - -int main(int argc, char **argv) -{ - int op, ret; - - - while ((op = getopt(argc, argv, "m:M:sb:c:C:S:p:")) != -1) { - switch (op) { - case 'm': - dst_addr = optarg; - break; - case 'M': - unmapped_addr = 1; - dst_addr = optarg; - break; - case 's': - is_sender = 1; - break; - case 'b': - src_addr = optarg; - test.src_addr = (struct sockaddr *) &test.src_in; - break; - case 'c': - connections = atoi(optarg); - break; - case 'C': - message_count = atoi(optarg); - break; - case 'S': - message_size = atoi(optarg); - break; - case 'p': - port_space = strtol(optarg, NULL, 0); - break; - default: - printf("usage: %s\n", argv[0]); - printf("\t-m multicast_address\n"); - printf("\t[-M unmapped_multicast_address]\n" - "\t replaces -m and requires -b\n"); - printf("\t[-s(ender)]\n"); - printf("\t[-b bind_address]\n"); - printf("\t[-c connections]\n"); - printf("\t[-C message_count]\n"); - printf("\t[-S message_size]\n"); - printf("\t[-p port_space - %#x for UDP (default), " - "%#x for IPOIB]\n", RDMA_PS_UDP, RDMA_PS_IPOIB); - exit(1); - } - } - - if (unmapped_addr && !src_addr) { - printf("unmapped multicast address requires binding " - "to source address\n"); - exit(1); - } - - test.dst_addr = (struct sockaddr *) &test.dst_in; - test.connects_left = connections; - - test.channel = rdma_create_event_channel(); - if (!test.channel) { - perror("failed to create event channel"); - exit(1); - } - - if (alloc_nodes()) - exit(1); - - ret = run(); - - printf("test complete\n"); - destroy_nodes(); - rdma_destroy_event_channel(test.channel); - - printf("return status %d\n", ret); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/rcopy.c b/usr/rdma-core/librdmacm/examples/rcopy.c deleted file mode 100644 index c85ce8ee9..000000000 --- a/usr/rdma-core/librdmacm/examples/rcopy.c +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Copyright (c) 2011 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -union rsocket_address { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; - struct sockaddr_storage storage; -}; - -static const char *port = "7427"; -static char *dst_addr; -static char *dst_file; -static char *src_file; -static struct timeval start, end; -//static void buf[1024 * 1024]; -static uint64_t bytes; -static int fd; -static void *file_addr; - -enum { - CMD_NOOP, - CMD_OPEN, - CMD_CLOSE, - CMD_WRITE, - CMD_RESP = 0x80, -}; - -/* TODO: handle byte swapping */ -struct msg_hdr { - uint8_t version; - uint8_t command; - uint16_t len; - uint32_t data; - uint64_t id; -}; - -struct msg_open { - struct msg_hdr hdr; - char path[0]; -}; - -struct msg_write { - struct msg_hdr hdr; - uint64_t size; -}; - -static void show_perf(void) -{ - float usec; - - usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec); - - printf("%lld bytes in %.2f seconds = %.2f Gb/sec\n", - (long long) bytes, usec / 1000000., (bytes * 8) / (1000. * usec)); -} - -static char *_ntop(union rsocket_address *rsa) -{ - static char addr[32]; - - switch (rsa->sa.sa_family) { - case AF_INET: - inet_ntop(AF_INET, &rsa->sin.sin_addr, addr, sizeof addr); - break; - case AF_INET6: - inet_ntop(AF_INET6, &rsa->sin6.sin6_addr, addr, sizeof addr); - break; - default: - addr[0] = '\0'; - break; - } - - return addr; -} - -static size_t _recv(int rs, char *msg, size_t len) -{ - size_t ret, offset; - - for (offset = 0; offset < len; offset += ret) { - ret = rrecv(rs, msg + offset, len - offset, 0); - if (ret <= 0) - return ret; - } - - return len; -} - -static int msg_recv_hdr(int rs, struct msg_hdr *hdr) -{ - int ret; - - ret = _recv(rs, (char *) hdr, sizeof *hdr); - if (ret != sizeof *hdr) - return -1; - - if (hdr->version || hdr->len < sizeof *hdr) { - printf("invalid version %d or length %d\n", - hdr->version, hdr->len); - return -1; - } - - return sizeof *hdr; -} - -static int msg_get_resp(int rs, struct msg_hdr *msg, uint8_t cmd) -{ - int ret; - - ret = msg_recv_hdr(rs, msg); - if (ret != sizeof *msg) - return ret; - - if ((msg->len != sizeof *msg) || (msg->command != (cmd | CMD_RESP))) { - printf("invalid length %d or bad command response %x:%x\n", - msg->len, msg->command, cmd | CMD_RESP); - return -1; - } - - return msg->data; -} - -static void msg_send_resp(int rs, struct msg_hdr *msg, uint32_t status) -{ - struct msg_hdr resp; - - resp.version = 0; - resp.command = msg->command | CMD_RESP; - resp.len = sizeof resp; - resp.data = status; - resp.id = msg->id; - rsend(rs, (char *) &resp, sizeof resp, 0); -} - -static int server_listen(void) -{ - struct addrinfo hints, *res; - int ret, rs; - - memset(&hints, 0, sizeof hints); - hints.ai_flags = RAI_PASSIVE; - ret = getaddrinfo(NULL, port, &hints, &res); - if (ret) { - printf("getaddrinfo failed: %s\n", gai_strerror(ret)); - return ret; - } - - rs = rsocket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (rs < 0) { - perror("rsocket failed\n"); - ret = rs; - goto free; - } - - ret = 1; - ret = rsetsockopt(rs, SOL_SOCKET, SO_REUSEADDR, &ret, sizeof ret); - if (ret) { - perror("rsetsockopt failed"); - goto close; - } - - ret = rbind(rs, res->ai_addr, res->ai_addrlen); - if (ret) { - perror("rbind failed"); - goto close; - } - - ret = rlisten(rs, 1); - if (ret) { - perror("rlisten failed"); - goto close; - } - - ret = rs; - goto free; - -close: - rclose(rs); -free: - freeaddrinfo(res); - return ret; -} - -static int server_open(int rs, struct msg_hdr *msg) -{ - char *path = NULL; - int ret, len; - - printf("opening: "); - fflush(NULL); - if (file_addr || fd > 0) { - printf("cannot open another file\n"); - ret = EBUSY; - goto out; - } - - len = msg->len - sizeof *msg; - path = malloc(len); - if (!path) { - printf("cannot allocate path name\n"); - ret = ENOMEM; - goto out; - } - - ret = _recv(rs, path, len); - if (ret != len) { - printf("error receiving path\n"); - goto out; - } - - printf("%s, ", path); - fflush(NULL); - fd = open(path, O_RDWR | O_CREAT | O_TRUNC, msg->data); - if (fd < 0) { - printf("unable to open destination file\n"); - ret = errno; - } - - ret = 0; -out: - if (path) - free(path); - - msg_send_resp(rs, msg, ret); - return ret; -} - -static void server_close(int rs, struct msg_hdr *msg) -{ - printf("closing..."); - fflush(NULL); - msg_send_resp(rs, msg, 0); - - if (file_addr) { - munmap(file_addr, bytes); - file_addr = NULL; - } - - if (fd > 0) { - close(fd); - fd = 0; - } - printf("done\n"); -} - -static int server_write(int rs, struct msg_hdr *msg) -{ - size_t len; - int ret; - - printf("transferring"); - fflush(NULL); - if (fd <= 0) { - printf("...file not opened\n"); - ret = EINVAL; - goto out; - } - - if (msg->len != sizeof(struct msg_write)) { - printf("...invalid message length %d\n", msg->len); - ret = EINVAL; - goto out; - } - - ret = _recv(rs, (char *) &bytes, sizeof bytes); - if (ret != sizeof bytes) - goto out; - - ret = ftruncate(fd, bytes); - if (ret) - goto out; - - file_addr = mmap(NULL, bytes, PROT_WRITE, MAP_SHARED, fd, 0); - if (file_addr == (void *) -1) { - printf("...error mapping file\n"); - ret = errno; - goto out; - } - - printf("...%lld bytes...", (long long) bytes); - fflush(NULL); - len = _recv(rs, file_addr, bytes); - if (len != bytes) { - printf("...error receiving data\n"); - ret = (int) len; - } -out: - msg_send_resp(rs, msg, ret); - return ret; -} - -static void server_process(int rs) -{ - struct msg_hdr msg; - int ret; - - do { - ret = msg_recv_hdr(rs, &msg); - if (ret != sizeof msg) - break; - - switch (msg.command) { - case CMD_OPEN: - ret = server_open(rs, &msg); - break; - case CMD_CLOSE: - server_close(rs, &msg); - ret = 0; - break; - case CMD_WRITE: - ret = server_write(rs, &msg); - break; - default: - msg_send_resp(rs, &msg, EINVAL); - ret = -1; - break; - } - - } while (!ret); -} - -static int server_run(void) -{ - int lrs, rs; - union rsocket_address rsa; - socklen_t len; - - lrs = server_listen(); - if (lrs < 0) - return lrs; - - while (1) { - len = sizeof rsa; - printf("waiting for connection..."); - fflush(NULL); - rs = raccept(lrs, &rsa.sa, &len); - - printf("client: %s\n", _ntop(&rsa)); - server_process(rs); - - rshutdown(rs, SHUT_RDWR); - rclose(rs); - } - return 0; -} - -static int client_connect(void) -{ - struct addrinfo *res; - int ret, rs; - - ret = getaddrinfo(dst_addr, port, NULL, &res); - if (ret) { - printf("getaddrinfo failed: %s\n", gai_strerror(ret)); - return ret; - } - - rs = rsocket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (rs < 0) { - perror("rsocket failed\n"); - goto free; - } - - ret = rconnect(rs, res->ai_addr, res->ai_addrlen); - if (ret) { - perror("rconnect failed\n"); - rclose(rs); - rs = ret; - } - -free: - freeaddrinfo(res); - return rs; -} - -static int client_open(int rs) -{ - struct msg_open *msg; - struct stat stats; - uint32_t len; - int ret; - - printf("opening..."); - fflush(NULL); - fd = open(src_file, O_RDONLY); - if (fd < 0) - return fd; - - ret = fstat(fd, &stats); - if (ret < 0) - goto err1; - - bytes = (uint64_t) stats.st_size; - file_addr = mmap(NULL, bytes, PROT_READ, MAP_SHARED, fd, 0); - if (file_addr == (void *) -1) { - ret = errno; - goto err1; - } - - len = (((uint32_t) strlen(dst_file)) + 8) & 0xFFFFFFF8; - msg = calloc(1, sizeof(*msg) + len); - if (!msg) { - ret = -1; - goto err2; - } - - msg->hdr.command = CMD_OPEN; - msg->hdr.len = sizeof(*msg) + len; - msg->hdr.data = (uint32_t) stats.st_mode; - strcpy(msg->path, dst_file); - ret = rsend(rs, msg, msg->hdr.len, 0); - if (ret != msg->hdr.len) - goto err3; - - ret = msg_get_resp(rs, &msg->hdr, CMD_OPEN); - if (ret) - goto err3; - - return 0; - -err3: - free(msg); -err2: - munmap(file_addr, bytes); -err1: - close(fd); - return ret; -} - -static int client_start_write(int rs) -{ - struct msg_write msg; - int ret; - - printf("transferring"); - fflush(NULL); - memset(&msg, 0, sizeof msg); - msg.hdr.command = CMD_WRITE; - msg.hdr.len = sizeof(msg); - msg.size = bytes; - - ret = rsend(rs, &msg, sizeof msg, 0); - if (ret != msg.hdr.len) - return ret; - - return 0; -} - -static int client_close(int rs) -{ - struct msg_hdr msg; - int ret; - - printf("closing..."); - fflush(NULL); - memset(&msg, 0, sizeof msg); - msg.command = CMD_CLOSE; - msg.len = sizeof msg; - ret = rsend(rs, (char *) &msg, msg.len, 0); - if (ret != msg.len) - goto out; - - ret = msg_get_resp(rs, &msg, CMD_CLOSE); - if (ret) - goto out; - - printf("done\n"); -out: - munmap(file_addr, bytes); - close(fd); - return ret; -} - -static int client_run(void) -{ - struct msg_hdr ack; - int ret, rs; - size_t len; - - rs = client_connect(); - if (rs < 0) - return rs; - - ret = client_open(rs); - if (ret) - goto shutdown; - - ret = client_start_write(rs); - if (ret) - goto close; - - printf("..."); - fflush(NULL); - gettimeofday(&start, NULL); - len = rsend(rs, file_addr, bytes, 0); - if (len == bytes) - ret = msg_get_resp(rs, &ack, CMD_WRITE); - else - ret = (int) len; - - gettimeofday(&end, NULL); - -close: - client_close(rs); -shutdown: - rshutdown(rs, SHUT_RDWR); - rclose(rs); - if (!ret) - show_perf(); - return ret; -} - -static void show_usage(char *program) -{ - printf("usage 1: %s [options]\n", program); - printf("\t starts the server application\n"); - printf("\t[-p port_number]\n"); - printf("usage 2: %s source server[:destination] [options]\n", program); - printf("\t source - file name and path\n"); - printf("\t server - name or address\n"); - printf("\t destination - file name and path\n"); - printf("\t[-p port_number]\n"); - exit(1); -} - -static void server_opts(int argc, char **argv) -{ - int op; - - while ((op = getopt(argc, argv, "p:")) != -1) { - switch (op) { - case 'p': - port = optarg; - break; - default: - show_usage(argv[0]); - } - } -} - -static void client_opts(int argc, char **argv) -{ - int op; - - if (argc < 3) - show_usage(argv[0]); - - src_file = argv[1]; - dst_addr = argv[2]; - dst_file = strchr(dst_addr, ':'); - if (dst_file) { - *dst_file = '\0'; - dst_file++; - } - if (!dst_file) - dst_file = src_file; - - while ((op = getopt(argc, argv, "p:")) != -1) { - switch (op) { - case 'p': - port = optarg; - break; - default: - show_usage(argv[0]); - } - } - -} - -int main(int argc, char **argv) -{ - int ret; - - if (argc == 1 || argv[1][0] == '-') { - server_opts(argc, argv); - ret = server_run(); - } else { - client_opts(argc, argv); - ret = client_run(); - } - - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/rdma_client.c b/usr/rdma-core/librdmacm/examples/rdma_client.c deleted file mode 100644 index c27047c51..000000000 --- a/usr/rdma-core/librdmacm/examples/rdma_client.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2010 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -static const char *server = "127.0.0.1"; -static const char *port = "7471"; - -static struct rdma_cm_id *id; -static struct ibv_mr *mr, *send_mr; -static int send_flags; -static uint8_t send_msg[16]; -static uint8_t recv_msg[16]; - -static int run(void) -{ - struct rdma_addrinfo hints, *res; - struct ibv_qp_init_attr attr; - struct ibv_wc wc; - int ret; - - memset(&hints, 0, sizeof hints); - hints.ai_port_space = RDMA_PS_TCP; - ret = rdma_getaddrinfo(server, port, &hints, &res); - if (ret) { - printf("rdma_getaddrinfo: %s\n", gai_strerror(ret)); - goto out; - } - - memset(&attr, 0, sizeof attr); - attr.cap.max_send_wr = attr.cap.max_recv_wr = 1; - attr.cap.max_send_sge = attr.cap.max_recv_sge = 1; - attr.cap.max_inline_data = 16; - attr.qp_context = id; - attr.sq_sig_all = 1; - ret = rdma_create_ep(&id, res, NULL, &attr); - // Check to see if we got inline data allowed or not - if (attr.cap.max_inline_data >= 16) - send_flags = IBV_SEND_INLINE; - else - printf("rdma_client: device doesn't support IBV_SEND_INLINE, " - "using sge sends\n"); - - if (ret) { - perror("rdma_create_ep"); - goto out_free_addrinfo; - } - - mr = rdma_reg_msgs(id, recv_msg, 16); - if (!mr) { - perror("rdma_reg_msgs for recv_msg"); - ret = -1; - goto out_destroy_ep; - } - if ((send_flags & IBV_SEND_INLINE) == 0) { - send_mr = rdma_reg_msgs(id, send_msg, 16); - if (!send_mr) { - perror("rdma_reg_msgs for send_msg"); - ret = -1; - goto out_dereg_recv; - } - } - - ret = rdma_post_recv(id, NULL, recv_msg, 16, mr); - if (ret) { - perror("rdma_post_recv"); - goto out_dereg_send; - } - - ret = rdma_connect(id, NULL); - if (ret) { - perror("rdma_connect"); - goto out_dereg_send; - } - - ret = rdma_post_send(id, NULL, send_msg, 16, send_mr, send_flags); - if (ret) { - perror("rdma_post_send"); - goto out_disconnect; - } - - while ((ret = rdma_get_send_comp(id, &wc)) == 0); - if (ret < 0) { - perror("rdma_get_send_comp"); - goto out_disconnect; - } - - while ((ret = rdma_get_recv_comp(id, &wc)) == 0); - if (ret < 0) - perror("rdma_get_recv_comp"); - else - ret = 0; - -out_disconnect: - rdma_disconnect(id); -out_dereg_send: - if ((send_flags & IBV_SEND_INLINE) == 0) - rdma_dereg_mr(send_mr); -out_dereg_recv: - rdma_dereg_mr(mr); -out_destroy_ep: - rdma_destroy_ep(id); -out_free_addrinfo: - rdma_freeaddrinfo(res); -out: - return ret; -} - -int main(int argc, char **argv) -{ - int op, ret; - - while ((op = getopt(argc, argv, "s:p:")) != -1) { - switch (op) { - case 's': - server = optarg; - break; - case 'p': - port = optarg; - break; - default: - printf("usage: %s\n", argv[0]); - printf("\t[-s server_address]\n"); - printf("\t[-p port_number]\n"); - exit(1); - } - } - - printf("rdma_client: start\n"); - ret = run(); - printf("rdma_client: end %d\n", ret); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/rdma_server.c b/usr/rdma-core/librdmacm/examples/rdma_server.c deleted file mode 100644 index bcf649feb..000000000 --- a/usr/rdma-core/librdmacm/examples/rdma_server.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2005-2009 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -static const char *port = "7471"; - -static struct rdma_cm_id *listen_id, *id; -static struct ibv_mr *mr, *send_mr; -static int send_flags; -static uint8_t send_msg[16]; -static uint8_t recv_msg[16]; - -static int run(void) -{ - struct rdma_addrinfo hints, *res; - struct ibv_qp_init_attr init_attr; - struct ibv_qp_attr qp_attr; - struct ibv_wc wc; - int ret; - - memset(&hints, 0, sizeof hints); - hints.ai_flags = RAI_PASSIVE; - hints.ai_port_space = RDMA_PS_TCP; - ret = rdma_getaddrinfo(NULL, port, &hints, &res); - if (ret) { - printf("rdma_getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - memset(&init_attr, 0, sizeof init_attr); - init_attr.cap.max_send_wr = init_attr.cap.max_recv_wr = 1; - init_attr.cap.max_send_sge = init_attr.cap.max_recv_sge = 1; - init_attr.cap.max_inline_data = 16; - init_attr.sq_sig_all = 1; - ret = rdma_create_ep(&listen_id, res, NULL, &init_attr); - if (ret) { - perror("rdma_create_ep"); - goto out_free_addrinfo; - } - - ret = rdma_listen(listen_id, 0); - if (ret) { - perror("rdma_listen"); - goto out_destroy_listen_ep; - } - - ret = rdma_get_request(listen_id, &id); - if (ret) { - perror("rdma_get_request"); - goto out_destroy_listen_ep; - } - - memset(&qp_attr, 0, sizeof qp_attr); - memset(&init_attr, 0, sizeof init_attr); - ret = ibv_query_qp(id->qp, &qp_attr, IBV_QP_CAP, - &init_attr); - if (ret) { - perror("ibv_query_qp"); - goto out_destroy_accept_ep; - } - if (init_attr.cap.max_inline_data >= 16) - send_flags = IBV_SEND_INLINE; - else - printf("rdma_server: device doesn't support IBV_SEND_INLINE, " - "using sge sends\n"); - - mr = rdma_reg_msgs(id, recv_msg, 16); - if (!mr) { - ret = -1; - perror("rdma_reg_msgs for recv_msg"); - goto out_destroy_accept_ep; - } - if ((send_flags & IBV_SEND_INLINE) == 0) { - send_mr = rdma_reg_msgs(id, send_msg, 16); - if (!send_mr) { - ret = -1; - perror("rdma_reg_msgs for send_msg"); - goto out_dereg_recv; - } - } - - ret = rdma_post_recv(id, NULL, recv_msg, 16, mr); - if (ret) { - perror("rdma_post_recv"); - goto out_dereg_send; - } - - ret = rdma_accept(id, NULL); - if (ret) { - perror("rdma_accept"); - goto out_dereg_send; - } - - while ((ret = rdma_get_recv_comp(id, &wc)) == 0); - if (ret < 0) { - perror("rdma_get_recv_comp"); - goto out_disconnect; - } - - ret = rdma_post_send(id, NULL, send_msg, 16, send_mr, send_flags); - if (ret) { - perror("rdma_post_send"); - goto out_disconnect; - } - - while ((ret = rdma_get_send_comp(id, &wc)) == 0); - if (ret < 0) - perror("rdma_get_send_comp"); - else - ret = 0; - -out_disconnect: - rdma_disconnect(id); -out_dereg_send: - if ((send_flags & IBV_SEND_INLINE) == 0) - rdma_dereg_mr(send_mr); -out_dereg_recv: - rdma_dereg_mr(mr); -out_destroy_accept_ep: - rdma_destroy_ep(id); -out_destroy_listen_ep: - rdma_destroy_ep(listen_id); -out_free_addrinfo: - rdma_freeaddrinfo(res); - return ret; -} - -int main(int argc, char **argv) -{ - int op, ret; - - while ((op = getopt(argc, argv, "p:")) != -1) { - switch (op) { - case 'p': - port = optarg; - break; - default: - printf("usage: %s\n", argv[0]); - printf("\t[-p port_number]\n"); - exit(1); - } - } - - printf("rdma_server: start\n"); - ret = run(); - printf("rdma_server: end %d\n", ret); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/rdma_xclient.c b/usr/rdma-core/librdmacm/examples/rdma_xclient.c deleted file mode 100644 index 63dfb6dfc..000000000 --- a/usr/rdma-core/librdmacm/examples/rdma_xclient.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2010-2014 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const char *server = "127.0.0.1"; -static char port[6] = "7471"; - -static struct rdma_cm_id *id; -static struct ibv_mr *mr; -static struct rdma_addrinfo hints; - -static uint8_t send_msg[16]; -static uint32_t srqn; - -static int post_send(void) -{ - struct ibv_send_wr wr, *bad; - struct ibv_sge sge; - int ret; - - sge.addr = (uint64_t) (uintptr_t) send_msg; - sge.length = (uint32_t) sizeof send_msg; - sge.lkey = 0; - wr.wr_id = (uintptr_t) NULL; - wr.next = NULL; - wr.sg_list = &sge; - wr.num_sge = 1; - wr.opcode = IBV_WR_SEND; - wr.send_flags = IBV_SEND_INLINE; - if (hints.ai_qp_type == IBV_QPT_XRC_SEND) - wr.qp_type.xrc.remote_srqn = srqn; - - ret = ibv_post_send(id->qp, &wr, &bad); - if (ret) - perror("rdma_post_send"); - - return ret; -} - -static int test(void) -{ - struct rdma_addrinfo *res; - struct ibv_qp_init_attr attr; - struct ibv_wc wc; - int ret; - - ret = rdma_getaddrinfo(server, port, &hints, &res); - if (ret) { - printf("rdma_getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - memset(&attr, 0, sizeof attr); - attr.cap.max_send_wr = attr.cap.max_recv_wr = 1; - attr.cap.max_send_sge = attr.cap.max_recv_sge = 1; - attr.sq_sig_all = 1; - ret = rdma_create_ep(&id, res, NULL, &attr); - rdma_freeaddrinfo(res); - if (ret) { - perror("rdma_create_ep"); - return ret; - } - - mr = rdma_reg_msgs(id, send_msg, sizeof send_msg); - if (!mr) { - perror("rdma_reg_msgs"); - return ret; - } - - ret = rdma_connect(id, NULL); - if (ret) { - perror("rdma_connect"); - return ret; - } - - if (hints.ai_qp_type == IBV_QPT_XRC_SEND) - srqn = be32toh(*(__be32 *) id->event->param.conn.private_data); - - ret = post_send(); - if (ret) { - perror("post_send"); - return ret; - } - - ret = rdma_get_send_comp(id, &wc); - if (ret <= 0) { - perror("rdma_get_recv_comp"); - return ret; - } - - rdma_disconnect(id); - rdma_dereg_mr(mr); - rdma_destroy_ep(id); - return 0; -} - -int main(int argc, char **argv) -{ - int op, ret; - - hints.ai_port_space = RDMA_PS_TCP; - hints.ai_qp_type = IBV_QPT_RC; - - while ((op = getopt(argc, argv, "s:p:c:")) != -1) { - switch (op) { - case 's': - server = optarg; - break; - case 'p': - strncpy(port, optarg, sizeof port - 1); - break; - case 'c': - switch (tolower(optarg[0])) { - case 'r': - break; - case 'x': - hints.ai_port_space = RDMA_PS_IB; - hints.ai_qp_type = IBV_QPT_XRC_SEND; - break; - default: - goto err; - } - break; - default: - goto err; - } - } - - printf("%s: start\n", argv[0]); - ret = test(); - printf("%s: end %d\n", argv[0], ret); - return ret; - -err: - printf("usage: %s\n", argv[0]); - printf("\t[-s server]\n"); - printf("\t[-p port_number]\n"); - printf("\t[-c communication type]\n"); - printf("\t r - RC: reliable-connected (default)\n"); - printf("\t x - XRC: extended-reliable-connected\n"); - exit(1); -} diff --git a/usr/rdma-core/librdmacm/examples/rdma_xserver.c b/usr/rdma-core/librdmacm/examples/rdma_xserver.c deleted file mode 100644 index 8d8ac3146..000000000 --- a/usr/rdma-core/librdmacm/examples/rdma_xserver.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const char *port = "7471"; - -static struct rdma_cm_id *listen_id, *id; -static struct ibv_mr *mr; -static struct rdma_addrinfo hints; - -static uint8_t recv_msg[16]; -static __be32 srqn; - -static int create_srq(void) -{ - struct ibv_srq_init_attr attr; - int ret; - uint32_t tmp_srqn; - - attr.attr.max_wr = 1; - attr.attr.max_sge = 1; - attr.attr.srq_limit = 0; - attr.srq_context = id; - - ret = rdma_create_srq(id, NULL, &attr); - if (ret) - perror("rdma_create_srq:"); - - if (id->srq) { - ibv_get_srq_num(id->srq, &tmp_srqn); - srqn = htobe32(tmp_srqn); - } - return ret; -} - -static int test(void) -{ - struct rdma_addrinfo *res; - struct ibv_qp_init_attr attr; - struct rdma_conn_param param; - struct ibv_wc wc; - int ret; - - ret = rdma_getaddrinfo(NULL, port, &hints, &res); - if (ret) { - printf("rdma_getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - memset(&attr, 0, sizeof attr); - attr.cap.max_send_wr = attr.cap.max_recv_wr = 1; - attr.cap.max_send_sge = attr.cap.max_recv_sge = 1; - ret = rdma_create_ep(&listen_id, res, NULL, &attr); - rdma_freeaddrinfo(res); - if (ret) { - perror("rdma_create_ep"); - return ret; - } - - ret = rdma_listen(listen_id, 0); - if (ret) { - perror("rdma_listen"); - return ret; - } - - ret = rdma_get_request(listen_id, &id); - if (ret) { - perror("rdma_get_request"); - return ret; - } - - if (hints.ai_qp_type == IBV_QPT_XRC_RECV) { - ret = create_srq(); - if (ret) - return ret; - } - - mr = rdma_reg_msgs(id, recv_msg, sizeof recv_msg); - if (!mr) { - perror("rdma_reg_msgs"); - return ret; - } - - ret = rdma_post_recv(id, NULL, recv_msg, sizeof recv_msg, mr); - if (ret) { - perror("rdma_post_recv"); - return ret; - } - - memset(¶m, 0, sizeof param); - param.private_data = &srqn; - param.private_data_len = sizeof srqn; - ret = rdma_accept(id, ¶m); - if (ret) { - perror("rdma_accept"); - return ret; - } - - ret = rdma_get_recv_comp(id, &wc); - if (ret <= 0) { - perror("rdma_get_recv_comp"); - return ret; - } - - rdma_disconnect(id); - rdma_dereg_mr(mr); - rdma_destroy_ep(id); - rdma_destroy_ep(listen_id); - return 0; -} - -int main(int argc, char **argv) -{ - int op, ret; - - hints.ai_flags = RAI_PASSIVE; - hints.ai_port_space = RDMA_PS_TCP; - hints.ai_qp_type = IBV_QPT_RC; - - while ((op = getopt(argc, argv, "p:c:")) != -1) { - switch (op) { - case 'p': - port = optarg; - break; - case 'c': - switch (tolower(optarg[0])) { - case 'r': - break; - case 'x': - hints.ai_port_space = RDMA_PS_IB; - hints.ai_qp_type = IBV_QPT_XRC_RECV; - break; - default: - goto err; - } - break; - default: - goto err; - } - } - - printf("%s: start\n", argv[0]); - ret = test(); - printf("%s: end %d\n", argv[0], ret); - return ret; - -err: - printf("usage: %s\n", argv[0]); - printf("\t[-p port_number]\n"); - printf("\t[-c communication type]\n"); - printf("\t r - RC: reliable-connected (default)\n"); - printf("\t x - XRC: extended-reliable-connected\n"); - exit(1); -} diff --git a/usr/rdma-core/librdmacm/examples/riostream.c b/usr/rdma-core/librdmacm/examples/riostream.c deleted file mode 100644 index bdf4fd34e..000000000 --- a/usr/rdma-core/librdmacm/examples/riostream.c +++ /dev/null @@ -1,674 +0,0 @@ -/* - * Copyright (c) 2011-2012 Intel Corporation. All rights reserved. - * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "common.h" - -struct test_size_param { - int size; - int option; -}; - -static struct test_size_param test_size[] = { - { 1 << 6, 0 }, - { 1 << 7, 1 }, { (1 << 7) + (1 << 6), 1}, - { 1 << 8, 1 }, { (1 << 8) + (1 << 7), 1}, - { 1 << 9, 1 }, { (1 << 9) + (1 << 8), 1}, - { 1 << 10, 1 }, { (1 << 10) + (1 << 9), 1}, - { 1 << 11, 1 }, { (1 << 11) + (1 << 10), 1}, - { 1 << 12, 0 }, { (1 << 12) + (1 << 11), 1}, - { 1 << 13, 1 }, { (1 << 13) + (1 << 12), 1}, - { 1 << 14, 1 }, { (1 << 14) + (1 << 13), 1}, - { 1 << 15, 1 }, { (1 << 15) + (1 << 14), 1}, - { 1 << 16, 0 }, { (1 << 16) + (1 << 15), 1}, - { 1 << 17, 1 }, { (1 << 17) + (1 << 16), 1}, - { 1 << 18, 1 }, { (1 << 18) + (1 << 17), 1}, - { 1 << 19, 1 }, { (1 << 19) + (1 << 18), 1}, - { 1 << 20, 0 }, { (1 << 20) + (1 << 19), 1}, - { 1 << 21, 1 }, { (1 << 21) + (1 << 20), 1}, - { 1 << 22, 1 }, { (1 << 22) + (1 << 21), 1}, -}; -#define TEST_CNT (sizeof test_size / sizeof test_size[0]) - -static int rs, lrs; -static int use_async; -static int use_rgai; -static int verify; -static int flags = MSG_DONTWAIT; -static int poll_timeout = 0; -static int custom; -static enum rs_optimization optimization; -static int size_option; -static int iterations = 1; -static int transfer_size = 1000; -static int transfer_count = 1000; -static int buffer_size, inline_size = 64; -static char test_name[10] = "custom"; -static const char *port = "7471"; -static char *dst_addr; -static char *src_addr; -static struct timeval start, end; -static void *buf; -static volatile uint8_t *poll_byte; -static struct rdma_addrinfo rai_hints; -static struct addrinfo ai_hints; - -static void show_perf(void) -{ - char str[32]; - float usec; - long long bytes; - - usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec); - bytes = (long long) iterations * transfer_count * transfer_size * 2; - - /* name size transfers iterations bytes seconds Gb/sec usec/xfer */ - printf("%-10s", test_name); - size_str(str, sizeof str, transfer_size); - printf("%-8s", str); - cnt_str(str, sizeof str, transfer_count); - printf("%-8s", str); - cnt_str(str, sizeof str, iterations); - printf("%-8s", str); - size_str(str, sizeof str, bytes); - printf("%-8s", str); - printf("%8.2fs%10.2f%11.2f\n", - usec / 1000000., (bytes * 8) / (1000. * usec), - (usec / iterations) / (transfer_count * 2)); -} - -static void init_latency_test(int size) -{ - char sstr[5]; - - size_str(sstr, sizeof sstr, size); - snprintf(test_name, sizeof test_name, "%s_lat", sstr); - transfer_count = 1; - transfer_size = size; - iterations = size_to_count(transfer_size); -} - -static void init_bandwidth_test(int size) -{ - char sstr[5]; - - size_str(sstr, sizeof sstr, size); - snprintf(test_name, sizeof test_name, "%s_bw", sstr); - iterations = 1; - transfer_size = size; - transfer_count = size_to_count(transfer_size); -} - -static int send_msg(int size) -{ - struct pollfd fds; - int offset, ret; - - if (use_async) { - fds.fd = rs; - fds.events = POLLOUT; - } - - for (offset = 0; offset < size; ) { - if (use_async) { - ret = do_poll(&fds, poll_timeout); - if (ret) - return ret; - } - - ret = rsend(rs, buf + offset, size - offset, flags); - if (ret > 0) { - offset += ret; - } else if (errno != EWOULDBLOCK && errno != EAGAIN) { - perror("rsend"); - return ret; - } - } - - return 0; -} - -static int send_xfer(int size) -{ - struct pollfd fds; - int offset, ret; - - if (use_async) { - fds.fd = rs; - fds.events = POLLOUT; - } - - for (offset = 0; offset < size; ) { - if (use_async) { - ret = do_poll(&fds, poll_timeout); - if (ret) - return ret; - } - - ret = riowrite(rs, buf + offset, size - offset, offset, flags); - if (ret > 0) { - offset += ret; - } else if (errno != EWOULDBLOCK && errno != EAGAIN) { - perror("riowrite"); - return ret; - } - } - - return 0; -} - -static int recv_msg(int size) -{ - struct pollfd fds; - int offset, ret; - - if (use_async) { - fds.fd = rs; - fds.events = POLLIN; - } - - for (offset = 0; offset < size; ) { - if (use_async) { - ret = do_poll(&fds, poll_timeout); - if (ret) - return ret; - } - - ret = rrecv(rs, buf + offset, size - offset, flags); - if (ret > 0) { - offset += ret; - } else if (errno != EWOULDBLOCK && errno != EAGAIN) { - perror("rrecv"); - return ret; - } - } - - return 0; -} - -static int recv_xfer(int size, uint8_t marker) -{ - int ret; - - while (*poll_byte != marker) - ; - - if (verify) { - ret = verify_buf(buf, size - 1); - if (ret) - return ret; - } - - return 0; -} - -static int sync_test(void) -{ - int ret; - - ret = dst_addr ? send_msg(16) : recv_msg(16); - if (ret) - return ret; - - return dst_addr ? recv_msg(16) : send_msg(16); -} - -static int run_test(void) -{ - int ret, i, t; - off_t offset; - uint8_t marker = 0; - - poll_byte = buf + transfer_size - 1; - *poll_byte = -1; - offset = riomap(rs, buf, transfer_size, PROT_WRITE, 0, 0); - if (offset == -1) { - perror("riomap"); - ret = -1; - goto out; - } - ret = sync_test(); - if (ret) - goto out; - - gettimeofday(&start, NULL); - for (i = 0; i < iterations; i++) { - if (dst_addr) { - for (t = 0; t < transfer_count - 1; t++) { - ret = send_xfer(transfer_size); - if (ret) - goto out; - } - *poll_byte = (uint8_t) marker++; - if (verify) - format_buf(buf, transfer_size - 1); - ret = send_xfer(transfer_size); - if (ret) - goto out; - - ret = recv_xfer(transfer_size, marker++); - } else { - ret = recv_xfer(transfer_size, marker++); - if (ret) - goto out; - - for (t = 0; t < transfer_count - 1; t++) { - ret = send_xfer(transfer_size); - if (ret) - goto out; - } - *poll_byte = (uint8_t) marker++; - if (verify) - format_buf(buf, transfer_size - 1); - ret = send_xfer(transfer_size); - } - if (ret) - goto out; - } - gettimeofday(&end, NULL); - show_perf(); - ret = riounmap(rs, buf, transfer_size); - -out: - return ret; -} - -static void set_options(int fd) -{ - int val; - - if (buffer_size) { - rsetsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &buffer_size, - sizeof buffer_size); - rsetsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &buffer_size, - sizeof buffer_size); - } else { - val = 1 << 19; - rsetsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &val, sizeof val); - rsetsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &val, sizeof val); - } - - val = 1; - rsetsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void *) &val, sizeof(val)); - rsetsockopt(fd, SOL_RDMA, RDMA_IOMAPSIZE, (void *) &val, sizeof val); - - if (flags & MSG_DONTWAIT) - rfcntl(fd, F_SETFL, O_NONBLOCK); - - /* Inline size based on experimental data */ - if (optimization == opt_latency) { - rsetsockopt(fd, SOL_RDMA, RDMA_INLINE, &inline_size, - sizeof inline_size); - } else if (optimization == opt_bandwidth) { - val = 0; - rsetsockopt(fd, SOL_RDMA, RDMA_INLINE, &val, sizeof val); - } -} - -static int server_listen(void) -{ - struct rdma_addrinfo *rai = NULL; - struct addrinfo *ai; - int val, ret; - - if (use_rgai) { - rai_hints.ai_flags |= RAI_PASSIVE; - ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai); - } else { - ai_hints.ai_flags |= AI_PASSIVE; - ret = getaddrinfo(src_addr, port, &ai_hints, &ai); - } - if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - lrs = rai ? rsocket(rai->ai_family, SOCK_STREAM, 0) : - rsocket(ai->ai_family, SOCK_STREAM, 0); - if (lrs < 0) { - perror("rsocket"); - ret = lrs; - goto free; - } - - val = 1; - ret = rsetsockopt(lrs, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val); - if (ret) { - perror("rsetsockopt SO_REUSEADDR"); - goto close; - } - - ret = rai ? rbind(lrs, rai->ai_src_addr, rai->ai_src_len) : - rbind(lrs, ai->ai_addr, ai->ai_addrlen); - if (ret) { - perror("rbind"); - goto close; - } - - ret = rlisten(lrs, 1); - if (ret) - perror("rlisten"); - -close: - if (ret) - rclose(lrs); -free: - if (rai) - rdma_freeaddrinfo(rai); - else - freeaddrinfo(ai); - return ret; -} - -static int server_connect(void) -{ - struct pollfd fds; - int ret = 0; - - set_options(lrs); - do { - if (use_async) { - fds.fd = lrs; - fds.events = POLLIN; - - ret = do_poll(&fds, poll_timeout); - if (ret) { - perror("rpoll"); - return ret; - } - } - - rs = raccept(lrs, NULL, NULL); - } while (rs < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)); - if (rs < 0) { - perror("raccept"); - return rs; - } - - set_options(rs); - return ret; -} - -static int client_connect(void) -{ - struct rdma_addrinfo *rai = NULL; - struct addrinfo *ai; - struct pollfd fds; - int ret, err; - socklen_t len; - - ret = use_rgai ? rdma_getaddrinfo(dst_addr, port, &rai_hints, &rai) : - getaddrinfo(dst_addr, port, &ai_hints, &ai); - if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - rs = rai ? rsocket(rai->ai_family, SOCK_STREAM, 0) : - rsocket(ai->ai_family, SOCK_STREAM, 0); - if (rs < 0) { - perror("rsocket"); - ret = rs; - goto free; - } - - set_options(rs); - /* TODO: bind client to src_addr */ - - ret = rai ? rconnect(rs, rai->ai_dst_addr, rai->ai_dst_len) : - rconnect(rs, ai->ai_addr, ai->ai_addrlen); - if (ret && (errno != EINPROGRESS)) { - perror("rconnect"); - goto close; - } - - if (ret && (errno == EINPROGRESS)) { - fds.fd = rs; - fds.events = POLLOUT; - ret = do_poll(&fds, poll_timeout); - if (ret) { - perror("rpoll"); - goto close; - } - - len = sizeof err; - ret = rgetsockopt(rs, SOL_SOCKET, SO_ERROR, &err, &len); - if (ret) - goto close; - if (err) { - ret = -1; - errno = err; - perror("async rconnect"); - } - } - -close: - if (ret) - rclose(rs); -free: - if (rai) - rdma_freeaddrinfo(rai); - else - freeaddrinfo(ai); - return ret; -} - -static int run(void) -{ - int i, ret = 0; - - buf = malloc(!custom ? test_size[TEST_CNT - 1].size : transfer_size); - if (!buf) { - perror("malloc"); - return -1; - } - - if (!dst_addr) { - ret = server_listen(); - if (ret) - goto free; - } - - printf("%-10s%-8s%-8s%-8s%-8s%8s %10s%13s\n", - "name", "bytes", "xfers", "iters", "total", "time", "Gb/sec", "usec/xfer"); - if (!custom) { - optimization = opt_latency; - ret = dst_addr ? client_connect() : server_connect(); - if (ret) - goto free; - - for (i = 0; i < TEST_CNT; i++) { - if (test_size[i].option > size_option) - continue; - init_latency_test(test_size[i].size); - run_test(); - } - rshutdown(rs, SHUT_RDWR); - rclose(rs); - - optimization = opt_bandwidth; - ret = dst_addr ? client_connect() : server_connect(); - if (ret) - goto free; - for (i = 0; i < TEST_CNT; i++) { - if (test_size[i].option > size_option) - continue; - init_bandwidth_test(test_size[i].size); - run_test(); - } - } else { - ret = dst_addr ? client_connect() : server_connect(); - if (ret) - goto free; - - ret = run_test(); - } - - rshutdown(rs, SHUT_RDWR); - rclose(rs); -free: - free(buf); - return ret; -} - -static int set_test_opt(const char *arg) -{ - if (strlen(arg) == 1) { - switch (arg[0]) { - case 'a': - use_async = 1; - break; - case 'b': - flags = (flags & ~MSG_DONTWAIT) | MSG_WAITALL; - break; - case 'n': - flags |= MSG_DONTWAIT; - break; - case 'v': - verify = 1; - break; - default: - return -1; - } - } else { - if (!strncasecmp("async", arg, 5)) { - use_async = 1; - } else if (!strncasecmp("block", arg, 5)) { - flags = (flags & ~MSG_DONTWAIT) | MSG_WAITALL; - } else if (!strncasecmp("nonblock", arg, 8)) { - flags |= MSG_DONTWAIT; - } else if (!strncasecmp("verify", arg, 6)) { - verify = 1; - } else { - return -1; - } - } - return 0; -} - -int main(int argc, char **argv) -{ - int op, ret; - - ai_hints.ai_socktype = SOCK_STREAM; - rai_hints.ai_port_space = RDMA_PS_TCP; - while ((op = getopt(argc, argv, "s:b:f:B:i:I:C:S:p:T:")) != -1) { - switch (op) { - case 's': - dst_addr = optarg; - break; - case 'b': - src_addr = optarg; - break; - case 'f': - if (!strncasecmp("ip", optarg, 2)) { - ai_hints.ai_flags = AI_NUMERICHOST; - } else if (!strncasecmp("gid", optarg, 3)) { - rai_hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY; - rai_hints.ai_family = AF_IB; - use_rgai = 1; - } else { - fprintf(stderr, "Warning: unknown address format\n"); - } - break; - case 'B': - buffer_size = atoi(optarg); - break; - case 'i': - inline_size = atoi(optarg); - break; - case 'I': - custom = 1; - iterations = atoi(optarg); - break; - case 'C': - custom = 1; - transfer_count = atoi(optarg); - break; - case 'S': - if (!strncasecmp("all", optarg, 3)) { - size_option = 1; - } else { - custom = 1; - transfer_size = atoi(optarg); - } - break; - case 'p': - port = optarg; - break; - case 'T': - if (!set_test_opt(optarg)) - break; - /* invalid option - fall through */ - SWITCH_FALLTHROUGH; - default: - printf("usage: %s\n", argv[0]); - printf("\t[-s server_address]\n"); - printf("\t[-b bind_address]\n"); - printf("\t[-f address_format]\n"); - printf("\t name, ip, ipv6, or gid\n"); - printf("\t[-B buffer_size]\n"); - printf("\t[-i inline_size]\n"); - printf("\t[-I iterations]\n"); - printf("\t[-C transfer_count]\n"); - printf("\t[-S transfer_size or all]\n"); - printf("\t[-p port_number]\n"); - printf("\t[-T test_option]\n"); - printf("\t a|async - asynchronous operation (use poll)\n"); - printf("\t b|blocking - use blocking calls\n"); - printf("\t n|nonblocking - use nonblocking calls\n"); - printf("\t v|verify - verify data\n"); - exit(1); - } - } - - if (!(flags & MSG_DONTWAIT)) - poll_timeout = -1; - - ret = run(); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/rping.c b/usr/rdma-core/librdmacm/examples/rping.c deleted file mode 100644 index 6a9539d32..000000000 --- a/usr/rdma-core/librdmacm/examples/rping.c +++ /dev/null @@ -1,1289 +0,0 @@ -/* - * Copyright (c) 2005 Ammasso, Inc. All rights reserved. - * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static int debug = 0; -#define DEBUG_LOG if (debug) printf - -/* - * rping "ping/pong" loop: - * client sends source rkey/addr/len - * server receives source rkey/add/len - * server rdma reads "ping" data from source - * server sends "go ahead" on rdma read completion - * client sends sink rkey/addr/len - * server receives sink rkey/addr/len - * server rdma writes "pong" data to sink - * server sends "go ahead" on rdma write completion - * - */ - -/* - * These states are used to signal events between the completion handler - * and the main client or server thread. - * - * Once CONNECTED, they cycle through RDMA_READ_ADV, RDMA_WRITE_ADV, - * and RDMA_WRITE_COMPLETE for each ping. - */ -enum test_state { - IDLE = 1, - CONNECT_REQUEST, - ADDR_RESOLVED, - ROUTE_RESOLVED, - CONNECTED, - RDMA_READ_ADV, - RDMA_READ_COMPLETE, - RDMA_WRITE_ADV, - RDMA_WRITE_COMPLETE, - DISCONNECTED, - ERROR -}; - -struct rping_rdma_info { - __be64 buf; - __be32 rkey; - __be32 size; -}; - -/* - * Default max buffer size for IO... - */ -#define RPING_BUFSIZE 64*1024 -#define RPING_SQ_DEPTH 16 - -/* Default string for print data and - * minimum buffer size - */ -#define _stringify( _x ) # _x -#define stringify( _x ) _stringify( _x ) - -#define RPING_MSG_FMT "rdma-ping-%d: " -#define RPING_MIN_BUFSIZE sizeof(stringify(INT_MAX)) + sizeof(RPING_MSG_FMT) - -/* - * Control block struct. - */ -struct rping_cb { - int server; /* 0 iff client */ - pthread_t cqthread; - pthread_t persistent_server_thread; - struct ibv_comp_channel *channel; - struct ibv_cq *cq; - struct ibv_pd *pd; - struct ibv_qp *qp; - - struct ibv_recv_wr rq_wr; /* recv work request record */ - struct ibv_sge recv_sgl; /* recv single SGE */ - struct rping_rdma_info recv_buf;/* malloc'd buffer */ - struct ibv_mr *recv_mr; /* MR associated with this buffer */ - - struct ibv_send_wr sq_wr; /* send work request record */ - struct ibv_sge send_sgl; - struct rping_rdma_info send_buf;/* single send buf */ - struct ibv_mr *send_mr; - - struct ibv_send_wr rdma_sq_wr; /* rdma work request record */ - struct ibv_sge rdma_sgl; /* rdma single SGE */ - char *rdma_buf; /* used as rdma sink */ - struct ibv_mr *rdma_mr; - - uint32_t remote_rkey; /* remote guys RKEY */ - uint64_t remote_addr; /* remote guys TO */ - uint32_t remote_len; /* remote guys LEN */ - - char *start_buf; /* rdma read src */ - struct ibv_mr *start_mr; - - enum test_state state; /* used for cond/signalling */ - sem_t sem; - - struct sockaddr_storage sin; - struct sockaddr_storage ssource; - __be16 port; /* dst port in NBO */ - int verbose; /* verbose logging */ - int count; /* ping count */ - int size; /* ping data size */ - int validate; /* validate ping data */ - - /* CM stuff */ - pthread_t cmthread; - struct rdma_event_channel *cm_channel; - struct rdma_cm_id *cm_id; /* connection on client side,*/ - /* listener on service side. */ - struct rdma_cm_id *child_cm_id; /* connection on server side */ -}; - -static int rping_cma_event_handler(struct rdma_cm_id *cma_id, - struct rdma_cm_event *event) -{ - int ret = 0; - struct rping_cb *cb = cma_id->context; - - DEBUG_LOG("cma_event type %s cma_id %p (%s)\n", - rdma_event_str(event->event), cma_id, - (cma_id == cb->cm_id) ? "parent" : "child"); - - switch (event->event) { - case RDMA_CM_EVENT_ADDR_RESOLVED: - cb->state = ADDR_RESOLVED; - ret = rdma_resolve_route(cma_id, 2000); - if (ret) { - cb->state = ERROR; - perror("rdma_resolve_route"); - sem_post(&cb->sem); - } - break; - - case RDMA_CM_EVENT_ROUTE_RESOLVED: - cb->state = ROUTE_RESOLVED; - sem_post(&cb->sem); - break; - - case RDMA_CM_EVENT_CONNECT_REQUEST: - cb->state = CONNECT_REQUEST; - cb->child_cm_id = cma_id; - DEBUG_LOG("child cma %p\n", cb->child_cm_id); - sem_post(&cb->sem); - break; - - case RDMA_CM_EVENT_ESTABLISHED: - DEBUG_LOG("ESTABLISHED\n"); - - /* - * Server will wake up when first RECV completes. - */ - if (!cb->server) { - cb->state = CONNECTED; - } - sem_post(&cb->sem); - break; - - case RDMA_CM_EVENT_ADDR_ERROR: - case RDMA_CM_EVENT_ROUTE_ERROR: - case RDMA_CM_EVENT_CONNECT_ERROR: - case RDMA_CM_EVENT_UNREACHABLE: - case RDMA_CM_EVENT_REJECTED: - fprintf(stderr, "cma event %s, error %d\n", - rdma_event_str(event->event), event->status); - sem_post(&cb->sem); - ret = -1; - break; - - case RDMA_CM_EVENT_DISCONNECTED: - fprintf(stderr, "%s DISCONNECT EVENT...\n", - cb->server ? "server" : "client"); - cb->state = DISCONNECTED; - sem_post(&cb->sem); - break; - - case RDMA_CM_EVENT_DEVICE_REMOVAL: - fprintf(stderr, "cma detected device removal!!!!\n"); - cb->state = ERROR; - sem_post(&cb->sem); - ret = -1; - break; - - default: - fprintf(stderr, "unhandled event: %s, ignoring\n", - rdma_event_str(event->event)); - break; - } - - return ret; -} - -static int server_recv(struct rping_cb *cb, struct ibv_wc *wc) -{ - if (wc->byte_len != sizeof(cb->recv_buf)) { - fprintf(stderr, "Received bogus data, size %d\n", wc->byte_len); - return -1; - } - - cb->remote_rkey = be32toh(cb->recv_buf.rkey); - cb->remote_addr = be64toh(cb->recv_buf.buf); - cb->remote_len = be32toh(cb->recv_buf.size); - DEBUG_LOG("Received rkey %x addr %" PRIx64 " len %d from peer\n", - cb->remote_rkey, cb->remote_addr, cb->remote_len); - - if (cb->state <= CONNECTED || cb->state == RDMA_WRITE_COMPLETE) - cb->state = RDMA_READ_ADV; - else - cb->state = RDMA_WRITE_ADV; - - return 0; -} - -static int client_recv(struct rping_cb *cb, struct ibv_wc *wc) -{ - if (wc->byte_len != sizeof(cb->recv_buf)) { - fprintf(stderr, "Received bogus data, size %d\n", wc->byte_len); - return -1; - } - - if (cb->state == RDMA_READ_ADV) - cb->state = RDMA_WRITE_ADV; - else - cb->state = RDMA_WRITE_COMPLETE; - - return 0; -} - -static int rping_cq_event_handler(struct rping_cb *cb) -{ - struct ibv_wc wc; - struct ibv_recv_wr *bad_wr; - int ret; - int flushed = 0; - - while ((ret = ibv_poll_cq(cb->cq, 1, &wc)) == 1) { - ret = 0; - - if (wc.status) { - if (wc.status == IBV_WC_WR_FLUSH_ERR) { - flushed = 1; - continue; - - } - fprintf(stderr, - "cq completion failed status %d\n", - wc.status); - ret = -1; - goto error; - } - - switch (wc.opcode) { - case IBV_WC_SEND: - DEBUG_LOG("send completion\n"); - break; - - case IBV_WC_RDMA_WRITE: - DEBUG_LOG("rdma write completion\n"); - cb->state = RDMA_WRITE_COMPLETE; - sem_post(&cb->sem); - break; - - case IBV_WC_RDMA_READ: - DEBUG_LOG("rdma read completion\n"); - cb->state = RDMA_READ_COMPLETE; - sem_post(&cb->sem); - break; - - case IBV_WC_RECV: - DEBUG_LOG("recv completion\n"); - ret = cb->server ? server_recv(cb, &wc) : - client_recv(cb, &wc); - if (ret) { - fprintf(stderr, "recv wc error: %d\n", ret); - goto error; - } - - ret = ibv_post_recv(cb->qp, &cb->rq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "post recv error: %d\n", ret); - goto error; - } - sem_post(&cb->sem); - break; - - default: - DEBUG_LOG("unknown!!!!! completion\n"); - ret = -1; - goto error; - } - } - if (ret) { - fprintf(stderr, "poll error %d\n", ret); - goto error; - } - return flushed; - -error: - cb->state = ERROR; - sem_post(&cb->sem); - return ret; -} - -static int rping_accept(struct rping_cb *cb) -{ - int ret; - - DEBUG_LOG("accepting client connection request\n"); - - ret = rdma_accept(cb->child_cm_id, NULL); - if (ret) { - perror("rdma_accept"); - return ret; - } - - sem_wait(&cb->sem); - if (cb->state == ERROR) { - fprintf(stderr, "wait for CONNECTED state %d\n", cb->state); - return -1; - } - return 0; -} - -static void rping_setup_wr(struct rping_cb *cb) -{ - cb->recv_sgl.addr = (uint64_t) (unsigned long) &cb->recv_buf; - cb->recv_sgl.length = sizeof cb->recv_buf; - cb->recv_sgl.lkey = cb->recv_mr->lkey; - cb->rq_wr.sg_list = &cb->recv_sgl; - cb->rq_wr.num_sge = 1; - - cb->send_sgl.addr = (uint64_t) (unsigned long) &cb->send_buf; - cb->send_sgl.length = sizeof cb->send_buf; - cb->send_sgl.lkey = cb->send_mr->lkey; - - cb->sq_wr.opcode = IBV_WR_SEND; - cb->sq_wr.send_flags = IBV_SEND_SIGNALED; - cb->sq_wr.sg_list = &cb->send_sgl; - cb->sq_wr.num_sge = 1; - - cb->rdma_sgl.addr = (uint64_t) (unsigned long) cb->rdma_buf; - cb->rdma_sgl.lkey = cb->rdma_mr->lkey; - cb->rdma_sq_wr.send_flags = IBV_SEND_SIGNALED; - cb->rdma_sq_wr.sg_list = &cb->rdma_sgl; - cb->rdma_sq_wr.num_sge = 1; -} - -static int rping_setup_buffers(struct rping_cb *cb) -{ - int ret; - - DEBUG_LOG("rping_setup_buffers called on cb %p\n", cb); - - cb->recv_mr = ibv_reg_mr(cb->pd, &cb->recv_buf, sizeof cb->recv_buf, - IBV_ACCESS_LOCAL_WRITE); - if (!cb->recv_mr) { - fprintf(stderr, "recv_buf reg_mr failed\n"); - return errno; - } - - cb->send_mr = ibv_reg_mr(cb->pd, &cb->send_buf, sizeof cb->send_buf, 0); - if (!cb->send_mr) { - fprintf(stderr, "send_buf reg_mr failed\n"); - ret = errno; - goto err1; - } - - cb->rdma_buf = malloc(cb->size); - if (!cb->rdma_buf) { - fprintf(stderr, "rdma_buf malloc failed\n"); - ret = -ENOMEM; - goto err2; - } - - cb->rdma_mr = ibv_reg_mr(cb->pd, cb->rdma_buf, cb->size, - IBV_ACCESS_LOCAL_WRITE | - IBV_ACCESS_REMOTE_READ | - IBV_ACCESS_REMOTE_WRITE); - if (!cb->rdma_mr) { - fprintf(stderr, "rdma_buf reg_mr failed\n"); - ret = errno; - goto err3; - } - - if (!cb->server) { - cb->start_buf = malloc(cb->size); - if (!cb->start_buf) { - fprintf(stderr, "start_buf malloc failed\n"); - ret = -ENOMEM; - goto err4; - } - - cb->start_mr = ibv_reg_mr(cb->pd, cb->start_buf, cb->size, - IBV_ACCESS_LOCAL_WRITE | - IBV_ACCESS_REMOTE_READ | - IBV_ACCESS_REMOTE_WRITE); - if (!cb->start_mr) { - fprintf(stderr, "start_buf reg_mr failed\n"); - ret = errno; - goto err5; - } - } - - rping_setup_wr(cb); - DEBUG_LOG("allocated & registered buffers...\n"); - return 0; - -err5: - free(cb->start_buf); -err4: - ibv_dereg_mr(cb->rdma_mr); -err3: - free(cb->rdma_buf); -err2: - ibv_dereg_mr(cb->send_mr); -err1: - ibv_dereg_mr(cb->recv_mr); - return ret; -} - -static void rping_free_buffers(struct rping_cb *cb) -{ - DEBUG_LOG("rping_free_buffers called on cb %p\n", cb); - ibv_dereg_mr(cb->recv_mr); - ibv_dereg_mr(cb->send_mr); - ibv_dereg_mr(cb->rdma_mr); - free(cb->rdma_buf); - if (!cb->server) { - ibv_dereg_mr(cb->start_mr); - free(cb->start_buf); - } -} - -static int rping_create_qp(struct rping_cb *cb) -{ - struct ibv_qp_init_attr init_attr; - int ret; - - memset(&init_attr, 0, sizeof(init_attr)); - init_attr.cap.max_send_wr = RPING_SQ_DEPTH; - init_attr.cap.max_recv_wr = 2; - init_attr.cap.max_recv_sge = 1; - init_attr.cap.max_send_sge = 1; - init_attr.qp_type = IBV_QPT_RC; - init_attr.send_cq = cb->cq; - init_attr.recv_cq = cb->cq; - - if (cb->server) { - ret = rdma_create_qp(cb->child_cm_id, cb->pd, &init_attr); - if (!ret) - cb->qp = cb->child_cm_id->qp; - } else { - ret = rdma_create_qp(cb->cm_id, cb->pd, &init_attr); - if (!ret) - cb->qp = cb->cm_id->qp; - } - - return ret; -} - -static void rping_free_qp(struct rping_cb *cb) -{ - ibv_destroy_qp(cb->qp); - ibv_destroy_cq(cb->cq); - ibv_destroy_comp_channel(cb->channel); - ibv_dealloc_pd(cb->pd); -} - -static int rping_setup_qp(struct rping_cb *cb, struct rdma_cm_id *cm_id) -{ - int ret; - - cb->pd = ibv_alloc_pd(cm_id->verbs); - if (!cb->pd) { - fprintf(stderr, "ibv_alloc_pd failed\n"); - return errno; - } - DEBUG_LOG("created pd %p\n", cb->pd); - - cb->channel = ibv_create_comp_channel(cm_id->verbs); - if (!cb->channel) { - fprintf(stderr, "ibv_create_comp_channel failed\n"); - ret = errno; - goto err1; - } - DEBUG_LOG("created channel %p\n", cb->channel); - - cb->cq = ibv_create_cq(cm_id->verbs, RPING_SQ_DEPTH * 2, cb, - cb->channel, 0); - if (!cb->cq) { - fprintf(stderr, "ibv_create_cq failed\n"); - ret = errno; - goto err2; - } - DEBUG_LOG("created cq %p\n", cb->cq); - - ret = ibv_req_notify_cq(cb->cq, 0); - if (ret) { - fprintf(stderr, "ibv_create_cq failed\n"); - ret = errno; - goto err3; - } - - ret = rping_create_qp(cb); - if (ret) { - perror("rdma_create_qp"); - goto err3; - } - DEBUG_LOG("created qp %p\n", cb->qp); - return 0; - -err3: - ibv_destroy_cq(cb->cq); -err2: - ibv_destroy_comp_channel(cb->channel); -err1: - ibv_dealloc_pd(cb->pd); - return ret; -} - -static void *cm_thread(void *arg) -{ - struct rping_cb *cb = arg; - struct rdma_cm_event *event; - int ret; - - while (1) { - ret = rdma_get_cm_event(cb->cm_channel, &event); - if (ret) { - perror("rdma_get_cm_event"); - exit(ret); - } - ret = rping_cma_event_handler(event->id, event); - rdma_ack_cm_event(event); - if (ret) - exit(ret); - } -} - -static void *cq_thread(void *arg) -{ - struct rping_cb *cb = arg; - struct ibv_cq *ev_cq; - void *ev_ctx; - int ret; - - DEBUG_LOG("cq_thread started.\n"); - - while (1) { - pthread_testcancel(); - - ret = ibv_get_cq_event(cb->channel, &ev_cq, &ev_ctx); - if (ret) { - fprintf(stderr, "Failed to get cq event!\n"); - pthread_exit(NULL); - } - if (ev_cq != cb->cq) { - fprintf(stderr, "Unknown CQ!\n"); - pthread_exit(NULL); - } - ret = ibv_req_notify_cq(cb->cq, 0); - if (ret) { - fprintf(stderr, "Failed to set notify!\n"); - pthread_exit(NULL); - } - ret = rping_cq_event_handler(cb); - ibv_ack_cq_events(cb->cq, 1); - if (ret) - pthread_exit(NULL); - } -} - -static void rping_format_send(struct rping_cb *cb, char *buf, struct ibv_mr *mr) -{ - struct rping_rdma_info *info = &cb->send_buf; - - info->buf = htobe64((uint64_t) (unsigned long) buf); - info->rkey = htobe32(mr->rkey); - info->size = htobe32(cb->size); - - DEBUG_LOG("RDMA addr %" PRIx64" rkey %x len %d\n", - be64toh(info->buf), be32toh(info->rkey), be32toh(info->size)); -} - -static int rping_test_server(struct rping_cb *cb) -{ - struct ibv_send_wr *bad_wr; - int ret; - - while (1) { - /* Wait for client's Start STAG/TO/Len */ - sem_wait(&cb->sem); - if (cb->state != RDMA_READ_ADV) { - fprintf(stderr, "wait for RDMA_READ_ADV state %d\n", - cb->state); - ret = -1; - break; - } - - DEBUG_LOG("server received sink adv\n"); - - /* Issue RDMA Read. */ - cb->rdma_sq_wr.opcode = IBV_WR_RDMA_READ; - cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey; - cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr; - cb->rdma_sq_wr.sg_list->length = cb->remote_len; - - ret = ibv_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "post send error %d\n", ret); - break; - } - DEBUG_LOG("server posted rdma read req \n"); - - /* Wait for read completion */ - sem_wait(&cb->sem); - if (cb->state != RDMA_READ_COMPLETE) { - fprintf(stderr, "wait for RDMA_READ_COMPLETE state %d\n", - cb->state); - ret = -1; - break; - } - DEBUG_LOG("server received read complete\n"); - - /* Display data in recv buf */ - if (cb->verbose) - printf("server ping data: %s\n", cb->rdma_buf); - - /* Tell client to continue */ - ret = ibv_post_send(cb->qp, &cb->sq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "post send error %d\n", ret); - break; - } - DEBUG_LOG("server posted go ahead\n"); - - /* Wait for client's RDMA STAG/TO/Len */ - sem_wait(&cb->sem); - if (cb->state != RDMA_WRITE_ADV) { - fprintf(stderr, "wait for RDMA_WRITE_ADV state %d\n", - cb->state); - ret = -1; - break; - } - DEBUG_LOG("server received sink adv\n"); - - /* RDMA Write echo data */ - cb->rdma_sq_wr.opcode = IBV_WR_RDMA_WRITE; - cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey; - cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr; - cb->rdma_sq_wr.sg_list->length = strlen(cb->rdma_buf) + 1; - DEBUG_LOG("rdma write from lkey %x laddr %" PRIx64 " len %d\n", - cb->rdma_sq_wr.sg_list->lkey, - cb->rdma_sq_wr.sg_list->addr, - cb->rdma_sq_wr.sg_list->length); - - ret = ibv_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "post send error %d\n", ret); - break; - } - - /* Wait for completion */ - ret = sem_wait(&cb->sem); - if (cb->state != RDMA_WRITE_COMPLETE) { - fprintf(stderr, "wait for RDMA_WRITE_COMPLETE state %d\n", - cb->state); - ret = -1; - break; - } - DEBUG_LOG("server rdma write complete \n"); - - /* Tell client to begin again */ - ret = ibv_post_send(cb->qp, &cb->sq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "post send error %d\n", ret); - break; - } - DEBUG_LOG("server posted go ahead\n"); - } - - return (cb->state == DISCONNECTED) ? 0 : ret; -} - -static int rping_bind_server(struct rping_cb *cb) -{ - int ret; - - if (cb->sin.ss_family == AF_INET) - ((struct sockaddr_in *) &cb->sin)->sin_port = cb->port; - else - ((struct sockaddr_in6 *) &cb->sin)->sin6_port = cb->port; - - ret = rdma_bind_addr(cb->cm_id, (struct sockaddr *) &cb->sin); - if (ret) { - perror("rdma_bind_addr"); - return ret; - } - DEBUG_LOG("rdma_bind_addr successful\n"); - - DEBUG_LOG("rdma_listen\n"); - ret = rdma_listen(cb->cm_id, 3); - if (ret) { - perror("rdma_listen"); - return ret; - } - - return 0; -} - -static struct rping_cb *clone_cb(struct rping_cb *listening_cb) -{ - struct rping_cb *cb = malloc(sizeof *cb); - if (!cb) - return NULL; - memset(cb, 0, sizeof *cb); - *cb = *listening_cb; - cb->child_cm_id->context = cb; - return cb; -} - -static void free_cb(struct rping_cb *cb) -{ - free(cb); -} - -static void *rping_persistent_server_thread(void *arg) -{ - struct rping_cb *cb = arg; - struct ibv_recv_wr *bad_wr; - int ret; - - ret = rping_setup_qp(cb, cb->child_cm_id); - if (ret) { - fprintf(stderr, "setup_qp failed: %d\n", ret); - goto err0; - } - - ret = rping_setup_buffers(cb); - if (ret) { - fprintf(stderr, "rping_setup_buffers failed: %d\n", ret); - goto err1; - } - - ret = ibv_post_recv(cb->qp, &cb->rq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "ibv_post_recv failed: %d\n", ret); - goto err2; - } - - ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb); - if (ret) { - perror("pthread_create"); - goto err2; - } - - ret = rping_accept(cb); - if (ret) { - fprintf(stderr, "connect error %d\n", ret); - goto err3; - } - - rping_test_server(cb); - rdma_disconnect(cb->child_cm_id); - pthread_join(cb->cqthread, NULL); - rping_free_buffers(cb); - rping_free_qp(cb); - rdma_destroy_id(cb->child_cm_id); - free_cb(cb); - return NULL; -err3: - pthread_cancel(cb->cqthread); - pthread_join(cb->cqthread, NULL); -err2: - rping_free_buffers(cb); -err1: - rping_free_qp(cb); -err0: - free_cb(cb); - return NULL; -} - -static int rping_run_persistent_server(struct rping_cb *listening_cb) -{ - int ret; - struct rping_cb *cb; - pthread_attr_t attr; - - ret = rping_bind_server(listening_cb); - if (ret) - return ret; - - /* - * Set persistent server threads to DEATCHED state so - * they release all their resources when they exit. - */ - ret = pthread_attr_init(&attr); - if (ret) { - perror("pthread_attr_init"); - return ret; - } - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if (ret) { - perror("pthread_attr_setdetachstate"); - return ret; - } - - while (1) { - sem_wait(&listening_cb->sem); - if (listening_cb->state != CONNECT_REQUEST) { - fprintf(stderr, "wait for CONNECT_REQUEST state %d\n", - listening_cb->state); - return -1; - } - - cb = clone_cb(listening_cb); - if (!cb) - return -1; - - ret = pthread_create(&cb->persistent_server_thread, &attr, rping_persistent_server_thread, cb); - if (ret) { - perror("pthread_create"); - return ret; - } - } - return 0; -} - -static int rping_run_server(struct rping_cb *cb) -{ - struct ibv_recv_wr *bad_wr; - int ret; - - ret = rping_bind_server(cb); - if (ret) - return ret; - - sem_wait(&cb->sem); - if (cb->state != CONNECT_REQUEST) { - fprintf(stderr, "wait for CONNECT_REQUEST state %d\n", - cb->state); - return -1; - } - - ret = rping_setup_qp(cb, cb->child_cm_id); - if (ret) { - fprintf(stderr, "setup_qp failed: %d\n", ret); - return ret; - } - - ret = rping_setup_buffers(cb); - if (ret) { - fprintf(stderr, "rping_setup_buffers failed: %d\n", ret); - goto err1; - } - - ret = ibv_post_recv(cb->qp, &cb->rq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "ibv_post_recv failed: %d\n", ret); - goto err2; - } - - ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb); - if (ret) { - perror("pthread_create"); - goto err2; - } - - ret = rping_accept(cb); - if (ret) { - fprintf(stderr, "connect error %d\n", ret); - goto err2; - } - - ret = rping_test_server(cb); - if (ret) { - fprintf(stderr, "rping server failed: %d\n", ret); - goto err3; - } - - ret = 0; -err3: - rdma_disconnect(cb->child_cm_id); - pthread_join(cb->cqthread, NULL); - rdma_destroy_id(cb->child_cm_id); -err2: - rping_free_buffers(cb); -err1: - rping_free_qp(cb); - - return ret; -} - -static int rping_test_client(struct rping_cb *cb) -{ - int ping, start, cc, i, ret = 0; - struct ibv_send_wr *bad_wr; - unsigned char c; - - start = 65; - for (ping = 0; !cb->count || ping < cb->count; ping++) { - cb->state = RDMA_READ_ADV; - - /* Put some ascii text in the buffer. */ - cc = snprintf(cb->start_buf, cb->size, RPING_MSG_FMT, ping); - for (i = cc, c = start; i < cb->size; i++) { - cb->start_buf[i] = c; - c++; - if (c > 122) - c = 65; - } - start++; - if (start > 122) - start = 65; - cb->start_buf[cb->size - 1] = 0; - - rping_format_send(cb, cb->start_buf, cb->start_mr); - ret = ibv_post_send(cb->qp, &cb->sq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "post send error %d\n", ret); - break; - } - - /* Wait for server to ACK */ - sem_wait(&cb->sem); - if (cb->state != RDMA_WRITE_ADV) { - fprintf(stderr, "wait for RDMA_WRITE_ADV state %d\n", - cb->state); - ret = -1; - break; - } - - rping_format_send(cb, cb->rdma_buf, cb->rdma_mr); - ret = ibv_post_send(cb->qp, &cb->sq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "post send error %d\n", ret); - break; - } - - /* Wait for the server to say the RDMA Write is complete. */ - sem_wait(&cb->sem); - if (cb->state != RDMA_WRITE_COMPLETE) { - fprintf(stderr, "wait for RDMA_WRITE_COMPLETE state %d\n", - cb->state); - ret = -1; - break; - } - - if (cb->validate) - if (memcmp(cb->start_buf, cb->rdma_buf, cb->size)) { - fprintf(stderr, "data mismatch!\n"); - ret = -1; - break; - } - - if (cb->verbose) - printf("ping data: %s\n", cb->rdma_buf); - } - - return (cb->state == DISCONNECTED) ? 0 : ret; -} - -static int rping_connect_client(struct rping_cb *cb) -{ - struct rdma_conn_param conn_param; - int ret; - - memset(&conn_param, 0, sizeof conn_param); - conn_param.responder_resources = 1; - conn_param.initiator_depth = 1; - conn_param.retry_count = 7; - - ret = rdma_connect(cb->cm_id, &conn_param); - if (ret) { - perror("rdma_connect"); - return ret; - } - - sem_wait(&cb->sem); - if (cb->state != CONNECTED) { - fprintf(stderr, "wait for CONNECTED state %d\n", cb->state); - return -1; - } - - DEBUG_LOG("rmda_connect successful\n"); - return 0; -} - -static int rping_bind_client(struct rping_cb *cb) -{ - int ret; - - if (cb->sin.ss_family == AF_INET) - ((struct sockaddr_in *) &cb->sin)->sin_port = cb->port; - else - ((struct sockaddr_in6 *) &cb->sin)->sin6_port = cb->port; - - if (cb->ssource.ss_family) - ret = rdma_resolve_addr(cb->cm_id, (struct sockaddr *) &cb->ssource, - (struct sockaddr *) &cb->sin, 2000); - else - ret = rdma_resolve_addr(cb->cm_id, NULL, (struct sockaddr *) &cb->sin, 2000); - - if (ret) { - perror("rdma_resolve_addr"); - return ret; - } - - sem_wait(&cb->sem); - if (cb->state != ROUTE_RESOLVED) { - fprintf(stderr, "waiting for addr/route resolution state %d\n", - cb->state); - return -1; - } - - DEBUG_LOG("rdma_resolve_addr - rdma_resolve_route successful\n"); - return 0; -} - -static int rping_run_client(struct rping_cb *cb) -{ - struct ibv_recv_wr *bad_wr; - int ret; - - ret = rping_bind_client(cb); - if (ret) - return ret; - - ret = rping_setup_qp(cb, cb->cm_id); - if (ret) { - fprintf(stderr, "setup_qp failed: %d\n", ret); - return ret; - } - - ret = rping_setup_buffers(cb); - if (ret) { - fprintf(stderr, "rping_setup_buffers failed: %d\n", ret); - goto err1; - } - - ret = ibv_post_recv(cb->qp, &cb->rq_wr, &bad_wr); - if (ret) { - fprintf(stderr, "ibv_post_recv failed: %d\n", ret); - goto err2; - } - - ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb); - if (ret) { - perror("pthread_create"); - goto err2; - } - - ret = rping_connect_client(cb); - if (ret) { - fprintf(stderr, "connect error %d\n", ret); - goto err3; - } - - ret = rping_test_client(cb); - if (ret) { - fprintf(stderr, "rping client failed: %d\n", ret); - goto err4; - } - - ret = 0; -err4: - rdma_disconnect(cb->cm_id); -err3: - pthread_join(cb->cqthread, NULL); -err2: - rping_free_buffers(cb); -err1: - rping_free_qp(cb); - - return ret; -} - -static int get_addr(char *dst, struct sockaddr *addr) -{ - struct addrinfo *res; - int ret; - - ret = getaddrinfo(dst, NULL, NULL, &res); - if (ret) { - printf("getaddrinfo failed (%s) - invalid hostname or IP address\n", gai_strerror(ret)); - return ret; - } - - if (res->ai_family == PF_INET) - memcpy(addr, res->ai_addr, sizeof(struct sockaddr_in)); - else if (res->ai_family == PF_INET6) - memcpy(addr, res->ai_addr, sizeof(struct sockaddr_in6)); - else - ret = -1; - - freeaddrinfo(res); - return ret; -} - -static void usage(const char *name) -{ - printf("%s -s [-vVd] [-S size] [-C count] [-a addr] [-p port]\n", - basename(name)); - printf("%s -c [-vVd] [-S size] [-C count] [-I addr] -a addr [-p port]\n", - basename(name)); - printf("\t-c\t\tclient side\n"); - printf("\t-I\t\tSource address to bind to for client.\n"); - printf("\t-s\t\tserver side. To bind to any address with IPv6 use -a ::0\n"); - printf("\t-v\t\tdisplay ping data to stdout\n"); - printf("\t-V\t\tvalidate ping data\n"); - printf("\t-d\t\tdebug printfs\n"); - printf("\t-S size \tping data size\n"); - printf("\t-C count\tping count times\n"); - printf("\t-a addr\t\taddress\n"); - printf("\t-p port\t\tport\n"); - printf("\t-P\t\tpersistent server mode allowing multiple connections\n"); -} - -int main(int argc, char *argv[]) -{ - struct rping_cb *cb; - int op; - int ret = 0; - int persistent_server = 0; - - cb = malloc(sizeof(*cb)); - if (!cb) - return -ENOMEM; - - memset(cb, 0, sizeof(*cb)); - cb->server = -1; - cb->state = IDLE; - cb->size = 64; - cb->sin.ss_family = PF_INET; - cb->port = htobe16(7174); - sem_init(&cb->sem, 0, 0); - - opterr = 0; - while ((op=getopt(argc, argv, "a:I:Pp:C:S:t:scvVd")) != -1) { - switch (op) { - case 'a': - ret = get_addr(optarg, (struct sockaddr *) &cb->sin); - break; - case 'I': - ret = get_addr(optarg, (struct sockaddr *) &cb->ssource); - break; - case 'P': - persistent_server = 1; - break; - case 'p': - cb->port = htobe16(atoi(optarg)); - DEBUG_LOG("port %d\n", (int) atoi(optarg)); - break; - case 's': - cb->server = 1; - DEBUG_LOG("server\n"); - break; - case 'c': - cb->server = 0; - DEBUG_LOG("client\n"); - break; - case 'S': - cb->size = atoi(optarg); - if ((cb->size < RPING_MIN_BUFSIZE) || - (cb->size > (RPING_BUFSIZE - 1))) { - fprintf(stderr, "Invalid size %d " - "(valid range is %zd to %d)\n", - cb->size, RPING_MIN_BUFSIZE, RPING_BUFSIZE); - ret = EINVAL; - } else - DEBUG_LOG("size %d\n", (int) atoi(optarg)); - break; - case 'C': - cb->count = atoi(optarg); - if (cb->count < 0) { - fprintf(stderr, "Invalid count %d\n", - cb->count); - ret = EINVAL; - } else - DEBUG_LOG("count %d\n", (int) cb->count); - break; - case 'v': - cb->verbose++; - DEBUG_LOG("verbose\n"); - break; - case 'V': - cb->validate++; - DEBUG_LOG("validate data\n"); - break; - case 'd': - debug++; - break; - default: - usage("rping"); - ret = EINVAL; - goto out; - } - } - if (ret) - goto out; - - if (cb->server == -1) { - usage("rping"); - ret = EINVAL; - goto out; - } - - cb->cm_channel = rdma_create_event_channel(); - if (!cb->cm_channel) { - perror("rdma_create_event_channel"); - ret = errno; - goto out; - } - - ret = rdma_create_id(cb->cm_channel, &cb->cm_id, cb, RDMA_PS_TCP); - if (ret) { - perror("rdma_create_id"); - goto out2; - } - DEBUG_LOG("created cm_id %p\n", cb->cm_id); - - ret = pthread_create(&cb->cmthread, NULL, cm_thread, cb); - if (ret) { - perror("pthread_create"); - goto out2; - } - - if (cb->server) { - if (persistent_server) - ret = rping_run_persistent_server(cb); - else - ret = rping_run_server(cb); - } else { - ret = rping_run_client(cb); - } - - DEBUG_LOG("destroy cm_id %p\n", cb->cm_id); - rdma_destroy_id(cb->cm_id); -out2: - rdma_destroy_event_channel(cb->cm_channel); -out: - free(cb); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/rstream.c b/usr/rdma-core/librdmacm/examples/rstream.c deleted file mode 100644 index 7523269cb..000000000 --- a/usr/rdma-core/librdmacm/examples/rstream.c +++ /dev/null @@ -1,707 +0,0 @@ -/* - * Copyright (c) 2011-2012 Intel Corporation. All rights reserved. - * Copyright (c) 2014-2015 Mellanox Technologies LTD. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "common.h" - -struct test_size_param { - int size; - int option; -}; - -static struct test_size_param test_size[] = { - { 1 << 6, 0 }, - { 1 << 7, 1 }, { (1 << 7) + (1 << 6), 1}, - { 1 << 8, 1 }, { (1 << 8) + (1 << 7), 1}, - { 1 << 9, 1 }, { (1 << 9) + (1 << 8), 1}, - { 1 << 10, 1 }, { (1 << 10) + (1 << 9), 1}, - { 1 << 11, 1 }, { (1 << 11) + (1 << 10), 1}, - { 1 << 12, 0 }, { (1 << 12) + (1 << 11), 1}, - { 1 << 13, 1 }, { (1 << 13) + (1 << 12), 1}, - { 1 << 14, 1 }, { (1 << 14) + (1 << 13), 1}, - { 1 << 15, 1 }, { (1 << 15) + (1 << 14), 1}, - { 1 << 16, 0 }, { (1 << 16) + (1 << 15), 1}, - { 1 << 17, 1 }, { (1 << 17) + (1 << 16), 1}, - { 1 << 18, 1 }, { (1 << 18) + (1 << 17), 1}, - { 1 << 19, 1 }, { (1 << 19) + (1 << 18), 1}, - { 1 << 20, 0 }, { (1 << 20) + (1 << 19), 1}, - { 1 << 21, 1 }, { (1 << 21) + (1 << 20), 1}, - { 1 << 22, 1 }, { (1 << 22) + (1 << 21), 1}, -}; -#define TEST_CNT (sizeof test_size / sizeof test_size[0]) - -static int rs, lrs; -static int use_async; -static int use_rgai; -static int verify; -static int flags = MSG_DONTWAIT; -static int poll_timeout = 0; -static int custom; -static int use_fork; -static pid_t fork_pid; -static enum rs_optimization optimization; -static int size_option; -static int iterations = 1; -static int transfer_size = 1000; -static int transfer_count = 1000; -static int buffer_size, inline_size = 64; -static char test_name[10] = "custom"; -static const char *port = "7471"; -static int keepalive; -static char *dst_addr; -static char *src_addr; -static struct timeval start, end; -static void *buf; -static struct rdma_addrinfo rai_hints; -static struct addrinfo ai_hints; - -static void show_perf(void) -{ - char str[32]; - float usec; - long long bytes; - - usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec); - bytes = (long long) iterations * transfer_count * transfer_size * 2; - - /* name size transfers iterations bytes seconds Gb/sec usec/xfer */ - printf("%-10s", test_name); - size_str(str, sizeof str, transfer_size); - printf("%-8s", str); - cnt_str(str, sizeof str, transfer_count); - printf("%-8s", str); - cnt_str(str, sizeof str, iterations); - printf("%-8s", str); - size_str(str, sizeof str, bytes); - printf("%-8s", str); - printf("%8.2fs%10.2f%11.2f\n", - usec / 1000000., (bytes * 8) / (1000. * usec), - (usec / iterations) / (transfer_count * 2)); -} - -static void init_latency_test(int size) -{ - char sstr[5]; - - size_str(sstr, sizeof sstr, size); - snprintf(test_name, sizeof test_name, "%s_lat", sstr); - transfer_count = 1; - transfer_size = size; - iterations = size_to_count(transfer_size); -} - -static void init_bandwidth_test(int size) -{ - char sstr[5]; - - size_str(sstr, sizeof sstr, size); - snprintf(test_name, sizeof test_name, "%s_bw", sstr); - iterations = 1; - transfer_size = size; - transfer_count = size_to_count(transfer_size); -} - -static int send_xfer(int size) -{ - struct pollfd fds; - int offset, ret; - - if (verify) - format_buf(buf, size); - - if (use_async) { - fds.fd = rs; - fds.events = POLLOUT; - } - - for (offset = 0; offset < size; ) { - if (use_async) { - ret = do_poll(&fds, poll_timeout); - if (ret) - return ret; - } - - ret = rs_send(rs, buf + offset, size - offset, flags); - if (ret > 0) { - offset += ret; - } else if (errno != EWOULDBLOCK && errno != EAGAIN) { - perror("rsend"); - return ret; - } - } - - return 0; -} - -static int recv_xfer(int size) -{ - struct pollfd fds; - int offset, ret; - - if (use_async) { - fds.fd = rs; - fds.events = POLLIN; - } - - for (offset = 0; offset < size; ) { - if (use_async) { - ret = do_poll(&fds, poll_timeout); - if (ret) - return ret; - } - - ret = rs_recv(rs, buf + offset, size - offset, flags); - if (ret > 0) { - offset += ret; - } else if (errno != EWOULDBLOCK && errno != EAGAIN) { - perror("rrecv"); - return ret; - } - } - - if (verify) { - ret = verify_buf(buf, size); - if (ret) - return ret; - } - - return 0; -} - -static int sync_test(void) -{ - int ret; - - ret = dst_addr ? send_xfer(16) : recv_xfer(16); - if (ret) - return ret; - - return dst_addr ? recv_xfer(16) : send_xfer(16); -} - -static int run_test(void) -{ - int ret, i, t; - - ret = sync_test(); - if (ret) - goto out; - - gettimeofday(&start, NULL); - for (i = 0; i < iterations; i++) { - for (t = 0; t < transfer_count; t++) { - ret = dst_addr ? send_xfer(transfer_size) : - recv_xfer(transfer_size); - if (ret) - goto out; - } - - for (t = 0; t < transfer_count; t++) { - ret = dst_addr ? recv_xfer(transfer_size) : - send_xfer(transfer_size); - if (ret) - goto out; - } - } - gettimeofday(&end, NULL); - show_perf(); - ret = 0; - -out: - return ret; -} - -static void set_keepalive(int fd) -{ - int optval; - socklen_t optlen = sizeof(optlen); - - optval = 1; - if (rs_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen)) { - perror("rsetsockopt SO_KEEPALIVE"); - return; - } - - optval = keepalive; - if (rs_setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &optval, optlen)) - perror("rsetsockopt TCP_KEEPIDLE"); - - if (!(rs_getsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen))) - printf("Keepalive: %s\n", (optval ? "ON" : "OFF")); - - if (!(rs_getsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &optval, &optlen))) - printf(" time: %i\n", optval); -} - -static void set_options(int fd) -{ - int val; - - if (buffer_size) { - rs_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &buffer_size, - sizeof buffer_size); - rs_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &buffer_size, - sizeof buffer_size); - } else { - val = 1 << 19; - rs_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &val, sizeof val); - rs_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &val, sizeof val); - } - - val = 1; - rs_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void *) &val, sizeof(val)); - - if (flags & MSG_DONTWAIT) - rs_fcntl(fd, F_SETFL, O_NONBLOCK); - - if (use_rs) { - /* Inline size based on experimental data */ - if (optimization == opt_latency) { - rs_setsockopt(fd, SOL_RDMA, RDMA_INLINE, &inline_size, - sizeof inline_size); - } else if (optimization == opt_bandwidth) { - val = 0; - rs_setsockopt(fd, SOL_RDMA, RDMA_INLINE, &val, sizeof val); - } - } - - if (keepalive) - set_keepalive(fd); -} - -static int server_listen(void) -{ - struct rdma_addrinfo *rai = NULL; - struct addrinfo *ai; - int val, ret; - - if (use_rgai) { - rai_hints.ai_flags |= RAI_PASSIVE; - ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai); - } else { - ai_hints.ai_flags |= AI_PASSIVE; - ret = getaddrinfo(src_addr, port, &ai_hints, &ai); - } - if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - lrs = rai ? rs_socket(rai->ai_family, SOCK_STREAM, 0) : - rs_socket(ai->ai_family, SOCK_STREAM, 0); - if (lrs < 0) { - perror("rsocket"); - ret = lrs; - goto free; - } - - val = 1; - ret = rs_setsockopt(lrs, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val); - if (ret) { - perror("rsetsockopt SO_REUSEADDR"); - goto close; - } - - ret = rai ? rs_bind(lrs, rai->ai_src_addr, rai->ai_src_len) : - rs_bind(lrs, ai->ai_addr, ai->ai_addrlen); - if (ret) { - perror("rbind"); - goto close; - } - - ret = rs_listen(lrs, 1); - if (ret) - perror("rlisten"); - -close: - if (ret) - rs_close(lrs); -free: - if (rai) - rdma_freeaddrinfo(rai); - else - freeaddrinfo(ai); - return ret; -} - -static int server_connect(void) -{ - struct pollfd fds; - int ret = 0; - - set_options(lrs); - do { - if (use_async) { - fds.fd = lrs; - fds.events = POLLIN; - - ret = do_poll(&fds, poll_timeout); - if (ret) { - perror("rpoll"); - return ret; - } - } - - rs = rs_accept(lrs, NULL, NULL); - } while (rs < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)); - if (rs < 0) { - perror("raccept"); - return rs; - } - - if (use_fork) - fork_pid = fork(); - if (!fork_pid) - set_options(rs); - return ret; -} - -static int client_connect(void) -{ - struct rdma_addrinfo *rai = NULL, *rai_src = NULL; - struct addrinfo *ai, *ai_src; - struct pollfd fds; - int ret, err; - socklen_t len; - - ret = use_rgai ? rdma_getaddrinfo(dst_addr, port, &rai_hints, &rai) : - getaddrinfo(dst_addr, port, &ai_hints, &ai); - - if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - if (src_addr) { - if (use_rgai) { - rai_hints.ai_flags |= RAI_PASSIVE; - ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai_src); - } else { - ai_hints.ai_flags |= AI_PASSIVE; - ret = getaddrinfo(src_addr, port, &ai_hints, &ai_src); - } - if (ret) { - printf("getaddrinfo src_addr: %s\n", gai_strerror(ret)); - return ret; - } - } - - rs = rai ? rs_socket(rai->ai_family, SOCK_STREAM, 0) : - rs_socket(ai->ai_family, SOCK_STREAM, 0); - if (rs < 0) { - perror("rsocket"); - ret = rs; - goto free; - } - - set_options(rs); - - if (src_addr) { - ret = rai ? rs_bind(rs, rai_src->ai_src_addr, rai_src->ai_src_len) : - rs_bind(rs, ai_src->ai_addr, ai_src->ai_addrlen); - if (ret) { - perror("rbind"); - goto close; - } - } - - if (rai && rai->ai_route) { - ret = rs_setsockopt(rs, SOL_RDMA, RDMA_ROUTE, rai->ai_route, - rai->ai_route_len); - if (ret) { - perror("rsetsockopt RDMA_ROUTE"); - goto close; - } - } - - ret = rai ? rs_connect(rs, rai->ai_dst_addr, rai->ai_dst_len) : - rs_connect(rs, ai->ai_addr, ai->ai_addrlen); - if (ret && (errno != EINPROGRESS)) { - perror("rconnect"); - goto close; - } - - if (ret && (errno == EINPROGRESS)) { - fds.fd = rs; - fds.events = POLLOUT; - ret = do_poll(&fds, poll_timeout); - if (ret) { - perror("rpoll"); - goto close; - } - - len = sizeof err; - ret = rs_getsockopt(rs, SOL_SOCKET, SO_ERROR, &err, &len); - if (ret) - goto close; - if (err) { - ret = -1; - errno = err; - perror("async rconnect"); - } - } - -close: - if (ret) - rs_close(rs); -free: - if (rai) - rdma_freeaddrinfo(rai); - else - freeaddrinfo(ai); - return ret; -} - -static int run(void) -{ - int i, ret = 0; - - buf = malloc(!custom ? test_size[TEST_CNT - 1].size : transfer_size); - if (!buf) { - perror("malloc"); - return -1; - } - - if (!dst_addr) { - ret = server_listen(); - if (ret) - goto free; - } - - printf("%-10s%-8s%-8s%-8s%-8s%8s %10s%13s\n", - "name", "bytes", "xfers", "iters", "total", "time", "Gb/sec", "usec/xfer"); - if (!custom) { - optimization = opt_latency; - ret = dst_addr ? client_connect() : server_connect(); - if (ret) - goto free; - - for (i = 0; i < TEST_CNT && !fork_pid; i++) { - if (test_size[i].option > size_option) - continue; - init_latency_test(test_size[i].size); - run_test(); - } - if (fork_pid) - waitpid(fork_pid, NULL, 0); - else - rs_shutdown(rs, SHUT_RDWR); - rs_close(rs); - - if (!dst_addr && use_fork && !fork_pid) - goto free; - - optimization = opt_bandwidth; - ret = dst_addr ? client_connect() : server_connect(); - if (ret) - goto free; - for (i = 0; i < TEST_CNT && !fork_pid; i++) { - if (test_size[i].option > size_option) - continue; - init_bandwidth_test(test_size[i].size); - run_test(); - } - } else { - ret = dst_addr ? client_connect() : server_connect(); - if (ret) - goto free; - - if (!fork_pid) - ret = run_test(); - } - - if (fork_pid) - waitpid(fork_pid, NULL, 0); - else - rs_shutdown(rs, SHUT_RDWR); - rs_close(rs); -free: - free(buf); - return ret; -} - -static int set_test_opt(const char *arg) -{ - if (strlen(arg) == 1) { - switch (arg[0]) { - case 's': - use_rs = 0; - break; - case 'a': - use_async = 1; - break; - case 'b': - flags = (flags & ~MSG_DONTWAIT) | MSG_WAITALL; - break; - case 'f': - use_fork = 1; - use_rs = 0; - break; - case 'n': - flags |= MSG_DONTWAIT; - break; - case 'r': - use_rgai = 1; - break; - case 'v': - verify = 1; - break; - default: - return -1; - } - } else { - if (!strncasecmp("socket", arg, 6)) { - use_rs = 0; - } else if (!strncasecmp("async", arg, 5)) { - use_async = 1; - } else if (!strncasecmp("block", arg, 5)) { - flags = (flags & ~MSG_DONTWAIT) | MSG_WAITALL; - } else if (!strncasecmp("nonblock", arg, 8)) { - flags |= MSG_DONTWAIT; - } else if (!strncasecmp("resolve", arg, 7)) { - use_rgai = 1; - } else if (!strncasecmp("verify", arg, 6)) { - verify = 1; - } else if (!strncasecmp("fork", arg, 4)) { - use_fork = 1; - use_rs = 0; - } else { - return -1; - } - } - return 0; -} - -int main(int argc, char **argv) -{ - int op, ret; - - ai_hints.ai_socktype = SOCK_STREAM; - rai_hints.ai_port_space = RDMA_PS_TCP; - while ((op = getopt(argc, argv, "s:b:f:B:i:I:C:S:p:k:T:")) != -1) { - switch (op) { - case 's': - dst_addr = optarg; - break; - case 'b': - src_addr = optarg; - break; - case 'f': - if (!strncasecmp("ip", optarg, 2)) { - ai_hints.ai_flags = AI_NUMERICHOST; - } else if (!strncasecmp("gid", optarg, 3)) { - rai_hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY; - rai_hints.ai_family = AF_IB; - use_rgai = 1; - } else { - fprintf(stderr, "Warning: unknown address format\n"); - } - break; - case 'B': - buffer_size = atoi(optarg); - break; - case 'i': - inline_size = atoi(optarg); - break; - case 'I': - custom = 1; - iterations = atoi(optarg); - break; - case 'C': - custom = 1; - transfer_count = atoi(optarg); - break; - case 'S': - if (!strncasecmp("all", optarg, 3)) { - size_option = 1; - } else { - custom = 1; - transfer_size = atoi(optarg); - } - break; - case 'p': - port = optarg; - break; - case 'k': - keepalive = atoi(optarg); - break; - case 'T': - if (!set_test_opt(optarg)) - break; - /* invalid option - fall through */ - SWITCH_FALLTHROUGH; - default: - printf("usage: %s\n", argv[0]); - printf("\t[-s server_address]\n"); - printf("\t[-b bind_address]\n"); - printf("\t[-f address_format]\n"); - printf("\t name, ip, ipv6, or gid\n"); - printf("\t[-B buffer_size]\n"); - printf("\t[-i inline_size]\n"); - printf("\t[-I iterations]\n"); - printf("\t[-C transfer_count]\n"); - printf("\t[-S transfer_size or all]\n"); - printf("\t[-p port_number]\n"); - printf("\t[-k keepalive_time]\n"); - printf("\t[-T test_option]\n"); - printf("\t s|sockets - use standard tcp/ip sockets\n"); - printf("\t a|async - asynchronous operation (use poll)\n"); - printf("\t b|blocking - use blocking calls\n"); - printf("\t f|fork - fork server processing\n"); - printf("\t n|nonblocking - use nonblocking calls\n"); - printf("\t r|resolve - use rdma cm to resolve address\n"); - printf("\t v|verify - verify data\n"); - exit(1); - } - } - - if (!(flags & MSG_DONTWAIT)) - poll_timeout = -1; - - ret = run(); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/udaddy.c b/usr/rdma-core/librdmacm/examples/udaddy.c deleted file mode 100644 index b1ac90c38..000000000 --- a/usr/rdma-core/librdmacm/examples/udaddy.c +++ /dev/null @@ -1,693 +0,0 @@ -/* - * Copyright (c) 2005-2006 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "common.h" - -struct cmatest_node { - int id; - struct rdma_cm_id *cma_id; - int connected; - struct ibv_pd *pd; - struct ibv_cq *cq; - struct ibv_mr *mr; - struct ibv_ah *ah; - uint32_t remote_qpn; - uint32_t remote_qkey; - void *mem; -}; - -struct cmatest { - struct rdma_event_channel *channel; - struct cmatest_node *nodes; - int conn_index; - int connects_left; - - struct rdma_addrinfo *rai; -}; - -static struct cmatest test; -static int connections = 1; -static int message_size = 100; -static int message_count = 10; -static const char *port = "7174"; -static uint8_t set_tos = 0; -static uint8_t tos; -static char *dst_addr; -static char *src_addr; -static struct rdma_addrinfo hints; - -static int create_message(struct cmatest_node *node) -{ - if (!message_size) - message_count = 0; - - if (!message_count) - return 0; - - node->mem = malloc(message_size + sizeof(struct ibv_grh)); - if (!node->mem) { - printf("failed message allocation\n"); - return -1; - } - node->mr = ibv_reg_mr(node->pd, node->mem, - message_size + sizeof(struct ibv_grh), - IBV_ACCESS_LOCAL_WRITE); - if (!node->mr) { - printf("failed to reg MR\n"); - goto err; - } - return 0; -err: - free(node->mem); - return -1; -} - -static int verify_test_params(struct cmatest_node *node) -{ - struct ibv_port_attr port_attr; - int ret; - - ret = ibv_query_port(node->cma_id->verbs, node->cma_id->port_num, - &port_attr); - if (ret) - return ret; - - if (message_count && message_size > (1 << (port_attr.active_mtu + 7))) { - printf("udaddy: message_size %d is larger than active mtu %d\n", - message_size, 1 << (port_attr.active_mtu + 7)); - return -EINVAL; - } - - return 0; -} - -static int init_node(struct cmatest_node *node) -{ - struct ibv_qp_init_attr init_qp_attr; - int cqe, ret; - - node->pd = ibv_alloc_pd(node->cma_id->verbs); - if (!node->pd) { - ret = -ENOMEM; - printf("udaddy: unable to allocate PD\n"); - goto out; - } - - cqe = message_count ? message_count * 2 : 2; - node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, NULL, 0); - if (!node->cq) { - ret = -ENOMEM; - printf("udaddy: unable to create CQ\n"); - goto out; - } - - memset(&init_qp_attr, 0, sizeof init_qp_attr); - init_qp_attr.cap.max_send_wr = message_count ? message_count : 1; - init_qp_attr.cap.max_recv_wr = message_count ? message_count : 1; - init_qp_attr.cap.max_send_sge = 1; - init_qp_attr.cap.max_recv_sge = 1; - init_qp_attr.qp_context = node; - init_qp_attr.sq_sig_all = 0; - init_qp_attr.qp_type = IBV_QPT_UD; - init_qp_attr.send_cq = node->cq; - init_qp_attr.recv_cq = node->cq; - ret = rdma_create_qp(node->cma_id, node->pd, &init_qp_attr); - if (ret) { - perror("udaddy: unable to create QP"); - goto out; - } - - ret = create_message(node); - if (ret) { - printf("udaddy: failed to create messages: %d\n", ret); - goto out; - } -out: - return ret; -} - -static int post_recvs(struct cmatest_node *node) -{ - struct ibv_recv_wr recv_wr, *recv_failure; - struct ibv_sge sge; - int i, ret = 0; - - if (!message_count) - return 0; - - recv_wr.next = NULL; - recv_wr.sg_list = &sge; - recv_wr.num_sge = 1; - recv_wr.wr_id = (uintptr_t) node; - - sge.length = message_size + sizeof(struct ibv_grh); - sge.lkey = node->mr->lkey; - sge.addr = (uintptr_t) node->mem; - - for (i = 0; i < message_count && !ret; i++ ) { - ret = ibv_post_recv(node->cma_id->qp, &recv_wr, &recv_failure); - if (ret) { - printf("failed to post receives: %d\n", ret); - break; - } - } - return ret; -} - -static int post_sends(struct cmatest_node *node, int signal_flag) -{ - struct ibv_send_wr send_wr, *bad_send_wr; - struct ibv_sge sge; - int i, ret = 0; - - if (!node->connected || !message_count) - return 0; - - send_wr.next = NULL; - send_wr.sg_list = &sge; - send_wr.num_sge = 1; - send_wr.opcode = IBV_WR_SEND_WITH_IMM; - send_wr.send_flags = signal_flag; - send_wr.wr_id = (unsigned long)node; - send_wr.imm_data = htobe32(node->cma_id->qp->qp_num); - - send_wr.wr.ud.ah = node->ah; - send_wr.wr.ud.remote_qpn = node->remote_qpn; - send_wr.wr.ud.remote_qkey = node->remote_qkey; - - sge.length = message_size; - sge.lkey = node->mr->lkey; - sge.addr = (uintptr_t) node->mem; - - for (i = 0; i < message_count && !ret; i++) { - ret = ibv_post_send(node->cma_id->qp, &send_wr, &bad_send_wr); - if (ret) - printf("failed to post sends: %d\n", ret); - } - return ret; -} - -static void connect_error(void) -{ - test.connects_left--; -} - -static int addr_handler(struct cmatest_node *node) -{ - int ret; - - if (set_tos) { - ret = rdma_set_option(node->cma_id, RDMA_OPTION_ID, - RDMA_OPTION_ID_TOS, &tos, sizeof tos); - if (ret) - perror("udaddy: set TOS option failed"); - } - - ret = rdma_resolve_route(node->cma_id, 2000); - if (ret) { - perror("udaddy: resolve route failed"); - connect_error(); - } - return ret; -} - -static int route_handler(struct cmatest_node *node) -{ - struct rdma_conn_param conn_param; - int ret; - - ret = verify_test_params(node); - if (ret) - goto err; - - ret = init_node(node); - if (ret) - goto err; - - ret = post_recvs(node); - if (ret) - goto err; - - memset(&conn_param, 0, sizeof conn_param); - conn_param.private_data = test.rai->ai_connect; - conn_param.private_data_len = test.rai->ai_connect_len; - ret = rdma_connect(node->cma_id, &conn_param); - if (ret) { - perror("udaddy: failure connecting"); - goto err; - } - return 0; -err: - connect_error(); - return ret; -} - -static int connect_handler(struct rdma_cm_id *cma_id) -{ - struct cmatest_node *node; - struct rdma_conn_param conn_param; - int ret; - - if (test.conn_index == connections) { - ret = -ENOMEM; - goto err1; - } - node = &test.nodes[test.conn_index++]; - - node->cma_id = cma_id; - cma_id->context = node; - - ret = verify_test_params(node); - if (ret) - goto err2; - - ret = init_node(node); - if (ret) - goto err2; - - ret = post_recvs(node); - if (ret) - goto err2; - - memset(&conn_param, 0, sizeof conn_param); - conn_param.qp_num = node->cma_id->qp->qp_num; - ret = rdma_accept(node->cma_id, &conn_param); - if (ret) { - perror("udaddy: failure accepting"); - goto err2; - } - node->connected = 1; - test.connects_left--; - return 0; - -err2: - node->cma_id = NULL; - connect_error(); -err1: - printf("udaddy: failing connection request\n"); - rdma_reject(cma_id, NULL, 0); - return ret; -} - -static int resolved_handler(struct cmatest_node *node, - struct rdma_cm_event *event) -{ - node->remote_qpn = event->param.ud.qp_num; - node->remote_qkey = event->param.ud.qkey; - node->ah = ibv_create_ah(node->pd, &event->param.ud.ah_attr); - if (!node->ah) { - printf("udaddy: failure creating address handle\n"); - goto err; - } - - node->connected = 1; - test.connects_left--; - return 0; -err: - connect_error(); - return -1; -} - -static int cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) -{ - int ret = 0; - - switch (event->event) { - case RDMA_CM_EVENT_ADDR_RESOLVED: - ret = addr_handler(cma_id->context); - break; - case RDMA_CM_EVENT_ROUTE_RESOLVED: - ret = route_handler(cma_id->context); - break; - case RDMA_CM_EVENT_CONNECT_REQUEST: - ret = connect_handler(cma_id); - break; - case RDMA_CM_EVENT_ESTABLISHED: - ret = resolved_handler(cma_id->context, event); - break; - case RDMA_CM_EVENT_ADDR_ERROR: - case RDMA_CM_EVENT_ROUTE_ERROR: - case RDMA_CM_EVENT_CONNECT_ERROR: - case RDMA_CM_EVENT_UNREACHABLE: - case RDMA_CM_EVENT_REJECTED: - printf("udaddy: event: %s, error: %d\n", - rdma_event_str(event->event), event->status); - connect_error(); - ret = event->status; - break; - case RDMA_CM_EVENT_DEVICE_REMOVAL: - /* Cleanup will occur after test completes. */ - break; - default: - break; - } - return ret; -} - -static void destroy_node(struct cmatest_node *node) -{ - if (!node->cma_id) - return; - - if (node->ah) - ibv_destroy_ah(node->ah); - - if (node->cma_id->qp) - rdma_destroy_qp(node->cma_id); - - if (node->cq) - ibv_destroy_cq(node->cq); - - if (node->mem) { - ibv_dereg_mr(node->mr); - free(node->mem); - } - - if (node->pd) - ibv_dealloc_pd(node->pd); - - /* Destroy the RDMA ID after all device resources */ - rdma_destroy_id(node->cma_id); -} - -static int alloc_nodes(void) -{ - int ret, i; - - test.nodes = malloc(sizeof *test.nodes * connections); - if (!test.nodes) { - printf("udaddy: unable to allocate memory for test nodes\n"); - return -ENOMEM; - } - memset(test.nodes, 0, sizeof *test.nodes * connections); - - for (i = 0; i < connections; i++) { - test.nodes[i].id = i; - if (dst_addr) { - ret = rdma_create_id(test.channel, - &test.nodes[i].cma_id, - &test.nodes[i], hints.ai_port_space); - if (ret) - goto err; - } - } - return 0; -err: - while (--i >= 0) - rdma_destroy_id(test.nodes[i].cma_id); - free(test.nodes); - return ret; -} - -static void destroy_nodes(void) -{ - int i; - - for (i = 0; i < connections; i++) - destroy_node(&test.nodes[i]); - free(test.nodes); -} - -static void create_reply_ah(struct cmatest_node *node, struct ibv_wc *wc) -{ - struct ibv_qp_attr attr; - struct ibv_qp_init_attr init_attr; - - node->ah = ibv_create_ah_from_wc(node->pd, wc, node->mem, - node->cma_id->port_num); - node->remote_qpn = be32toh(wc->imm_data); - - ibv_query_qp(node->cma_id->qp, &attr, IBV_QP_QKEY, &init_attr); - node->remote_qkey = attr.qkey; -} - -static int poll_cqs(void) -{ - struct ibv_wc wc[8]; - int done, i, ret; - - for (i = 0; i < connections; i++) { - if (!test.nodes[i].connected) - continue; - - for (done = 0; done < message_count; done += ret) { - ret = ibv_poll_cq(test.nodes[i].cq, 8, wc); - if (ret < 0) { - printf("udaddy: failed polling CQ: %d\n", ret); - return ret; - } - - if (ret && !test.nodes[i].ah) - create_reply_ah(&test.nodes[i], wc); - } - } - return 0; -} - -static int connect_events(void) -{ - struct rdma_cm_event *event; - int ret = 0; - - while (test.connects_left && !ret) { - ret = rdma_get_cm_event(test.channel, &event); - if (!ret) { - ret = cma_handler(event->id, event); - rdma_ack_cm_event(event); - } - } - return ret; -} - -static int run_server(void) -{ - struct rdma_cm_id *listen_id; - int i, ret; - - printf("udaddy: starting server\n"); - ret = rdma_create_id(test.channel, &listen_id, &test, hints.ai_port_space); - if (ret) { - perror("udaddy: listen request failed"); - return ret; - } - - ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai); - if (ret) { - printf("udaddy: getrdmaaddr error: %s\n", gai_strerror(ret)); - goto out; - } - - ret = rdma_bind_addr(listen_id, test.rai->ai_src_addr); - if (ret) { - perror("udaddy: bind address failed"); - goto out; - } - - ret = rdma_listen(listen_id, 0); - if (ret) { - perror("udaddy: failure trying to listen"); - goto out; - } - - connect_events(); - - if (message_count) { - printf("receiving data transfers\n"); - ret = poll_cqs(); - if (ret) - goto out; - - printf("sending replies\n"); - for (i = 0; i < connections; i++) { - ret = post_sends(&test.nodes[i], IBV_SEND_SIGNALED); - if (ret) - goto out; - } - - ret = poll_cqs(); - if (ret) - goto out; - printf("data transfers complete\n"); - } -out: - rdma_destroy_id(listen_id); - return ret; -} - -static int run_client(void) -{ - int i, ret; - - printf("udaddy: starting client\n"); - - ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai); - if (ret) { - printf("udaddy: getaddrinfo error: %s\n", gai_strerror(ret)); - return ret; - } - - printf("udaddy: connecting\n"); - for (i = 0; i < connections; i++) { - ret = rdma_resolve_addr(test.nodes[i].cma_id, test.rai->ai_src_addr, - test.rai->ai_dst_addr, 2000); - if (ret) { - perror("udaddy: failure getting addr"); - connect_error(); - return ret; - } - } - - ret = connect_events(); - if (ret) - goto out; - - if (message_count) { - printf("initiating data transfers\n"); - for (i = 0; i < connections; i++) { - ret = post_sends(&test.nodes[i], 0); - if (ret) - goto out; - } - printf("receiving data transfers\n"); - ret = poll_cqs(); - if (ret) - goto out; - - printf("data transfers complete\n"); - } -out: - return ret; -} - -int main(int argc, char **argv) -{ - int op, ret; - - hints.ai_port_space = RDMA_PS_UDP; - while ((op = getopt(argc, argv, "s:b:c:C:S:t:p:P:f:")) != -1) { - switch (op) { - case 's': - dst_addr = optarg; - break; - case 'b': - src_addr = optarg; - break; - case 'c': - connections = atoi(optarg); - break; - case 'C': - message_count = atoi(optarg); - break; - case 'S': - message_size = atoi(optarg); - break; - case 't': - set_tos = 1; - tos = (uint8_t) strtoul(optarg, NULL, 0); - break; - case 'p': /* for backwards compatibility - use -P */ - hints.ai_port_space = strtol(optarg, NULL, 0); - break; - case 'f': - if (!strncasecmp("ip", optarg, 2)) { - hints.ai_flags = RAI_NUMERICHOST; - } else if (!strncasecmp("gid", optarg, 3)) { - hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY; - hints.ai_family = AF_IB; - } else if (strncasecmp("name", optarg, 4)) { - fprintf(stderr, "Warning: unknown address format\n"); - } - break; - case 'P': - if (!strncasecmp("ipoib", optarg, 5)) { - hints.ai_port_space = RDMA_PS_IPOIB; - } else if (strncasecmp("udp", optarg, 3)) { - fprintf(stderr, "Warning: unknown port space format\n"); - } - break; - default: - printf("usage: %s\n", argv[0]); - printf("\t[-s server_address]\n"); - printf("\t[-b bind_address]\n"); - printf("\t[-f address_format]\n"); - printf("\t name, ip, ipv6, or gid\n"); - printf("\t[-P port_space]\n"); - printf("\t udp or ipoib\n"); - printf("\t[-c connections]\n"); - printf("\t[-C message_count]\n"); - printf("\t[-S message_size]\n"); - printf("\t[-t type_of_service]\n"); - printf("\t[-p port_space - %#x for UDP (default), " - "%#x for IPOIB]\n", RDMA_PS_UDP, RDMA_PS_IPOIB); - exit(1); - } - } - - test.connects_left = connections; - - test.channel = rdma_create_event_channel(); - if (!test.channel) { - perror("failed to create event channel"); - exit(1); - } - - if (alloc_nodes()) - exit(1); - - if (dst_addr) { - ret = run_client(); - } else { - hints.ai_flags |= RAI_PASSIVE; - ret = run_server(); - } - - printf("test complete\n"); - destroy_nodes(); - rdma_destroy_event_channel(test.channel); - if (test.rai) - rdma_freeaddrinfo(test.rai); - - printf("return status %d\n", ret); - return ret; -} diff --git a/usr/rdma-core/librdmacm/examples/udpong.c b/usr/rdma-core/librdmacm/examples/udpong.c deleted file mode 100644 index 8894a0762..000000000 --- a/usr/rdma-core/librdmacm/examples/udpong.c +++ /dev/null @@ -1,570 +0,0 @@ -/* - * Copyright (c) 2012 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "common.h" - -static int test_size[] = { - (1 << 6), - (1 << 7), ((1 << 7) + (1 << 6)), - (1 << 8), ((1 << 8) + (1 << 7)), - (1 << 9), ((1 << 9) + (1 << 8)), - (1 << 10), ((1 << 10) + (1 << 9)), -}; -#define TEST_CNT (sizeof test_size / sizeof test_size[0]) - -enum { - msg_op_login, - msg_op_start, - msg_op_data, - msg_op_echo, - msg_op_end -}; - -struct message { - uint8_t op; - uint8_t id; - uint8_t seqno; - uint8_t reserved; - __be32 data; - uint8_t buf[2048]; -}; - -#define CTRL_MSG_SIZE 16 - -struct client { - uint64_t recvcnt; -}; - -static struct client clients[256]; -static uint8_t id; - -static int rs; -static int use_async; -static int flags = MSG_DONTWAIT; -static int poll_timeout; -static int custom; -static int echo; -static int transfer_size = 1000; -static int transfer_count = 1000; -static int buffer_size; -static char test_name[10] = "custom"; -static const char *port = "7174"; -static char *dst_addr; -static char *src_addr; -static union socket_addr g_addr; -static socklen_t g_addrlen; -static struct timeval start, end; -static struct message g_msg; - -static void show_perf(void) -{ - char str[32]; - float usec; - long long bytes; - int transfers; - - usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec); - transfers = echo ? transfer_count * 2 : be32toh(g_msg.data); - bytes = (long long) transfers * transfer_size; - - /* name size transfers bytes seconds Gb/sec usec/xfer */ - printf("%-10s", test_name); - size_str(str, sizeof str, transfer_size); - printf("%-8s", str); - cnt_str(str, sizeof str, transfers); - printf("%-8s", str); - size_str(str, sizeof str, bytes); - printf("%-8s", str); - printf("%8.2fs%10.2f%11.2f\n", - usec / 1000000., (bytes * 8) / (1000. * usec), - (usec / transfers)); -} - -static void init_latency_test(int size) -{ - char sstr[5]; - - size_str(sstr, sizeof sstr, size); - snprintf(test_name, sizeof test_name, "%s_lat", sstr); - transfer_size = size; - transfer_count = size_to_count(transfer_size) / 10; - echo = 1; -} - -static void init_bandwidth_test(int size) -{ - char sstr[5]; - - size_str(sstr, sizeof sstr, size); - snprintf(test_name, sizeof test_name, "%s_bw", sstr); - transfer_size = size; - transfer_count = size_to_count(transfer_size); - echo = 0; -} - -static void set_options(int fd) -{ - int val; - - if (buffer_size) { - rs_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &buffer_size, - sizeof buffer_size); - rs_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &buffer_size, - sizeof buffer_size); - } else { - val = 1 << 19; - rs_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &val, sizeof val); - rs_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &val, sizeof val); - } - - if (flags & MSG_DONTWAIT) - rs_fcntl(fd, F_SETFL, O_NONBLOCK); -} - -static ssize_t svr_send(struct message *msg, size_t size, - union socket_addr *addr, socklen_t addrlen) -{ - struct pollfd fds; - ssize_t ret; - - if (use_async) { - fds.fd = rs; - fds.events = POLLOUT; - } - - do { - if (use_async) { - ret = do_poll(&fds, poll_timeout); - if (ret) - return ret; - } - - ret = rs_sendto(rs, msg, size, flags, &addr->sa, addrlen); - } while (ret < 0 && (errno == EWOULDBLOCK || errno == EAGAIN)); - - if (ret < 0) - perror("rsend"); - - return ret; -} - -static ssize_t svr_recv(struct message *msg, size_t size, - union socket_addr *addr, socklen_t *addrlen) -{ - struct pollfd fds; - ssize_t ret; - - if (use_async) { - fds.fd = rs; - fds.events = POLLIN; - } - - do { - if (use_async) { - ret = do_poll(&fds, poll_timeout); - if (ret) - return ret; - } - - ret = rs_recvfrom(rs, msg, size, flags, &addr->sa, addrlen); - } while (ret < 0 && (errno == EWOULDBLOCK || errno == EAGAIN)); - - if (ret < 0) - perror("rrecv"); - - return ret; -} - -static int svr_process(struct message *msg, size_t size, - union socket_addr *addr, socklen_t addrlen) -{ - char str[64]; - ssize_t ret; - - switch (msg->op) { - case msg_op_login: - if (addr->sa.sa_family == AF_INET) { - printf("client login from %s\n", - inet_ntop(AF_INET, &addr->sin.sin_addr.s_addr, - str, sizeof str)); - } else { - printf("client login from %s\n", - inet_ntop(AF_INET6, &addr->sin6.sin6_addr.s6_addr, - str, sizeof str)); - } - msg->id = id++; - /* fall through */ - case msg_op_start: - memset(&clients[msg->id], 0, sizeof clients[msg->id]); - break; - case msg_op_echo: - clients[msg->id].recvcnt++; - break; - case msg_op_end: - msg->data = htobe32(clients[msg->id].recvcnt); - break; - default: - clients[msg->id].recvcnt++; - return 0; - } - - ret = svr_send(msg, size, addr, addrlen); - return (ret == size) ? 0 : (int) ret; -} - -static int svr_bind(void) -{ - struct addrinfo hints, *res; - int ret; - - memset(&hints, 0, sizeof hints); - hints.ai_socktype = SOCK_DGRAM; - ret = getaddrinfo(src_addr, port, &hints, &res); - if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - rs = rs_socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (rs < 0) { - perror("rsocket"); - ret = rs; - goto out; - } - - set_options(rs); - ret = rs_bind(rs, res->ai_addr, res->ai_addrlen); - if (ret) { - perror("rbind"); - rs_close(rs); - } - -out: - free(res); - return ret; -} - -static int svr_run(void) -{ - ssize_t len; - int ret; - - ret = svr_bind(); - while (!ret) { - g_addrlen = sizeof g_addr; - len = svr_recv(&g_msg, sizeof g_msg, &g_addr, &g_addrlen); - if (len < 0) - return len; - - ret = svr_process(&g_msg, len, &g_addr, g_addrlen); - } - return ret; -} - -static ssize_t client_send(struct message *msg, size_t size) -{ - struct pollfd fds; - int ret; - - if (use_async) { - fds.fd = rs; - fds.events = POLLOUT; - } - - do { - if (use_async) { - ret = do_poll(&fds, poll_timeout); - if (ret) - return ret; - } - - ret = rs_send(rs, msg, size, flags); - } while (ret < 0 && (errno == EWOULDBLOCK || errno == EAGAIN)); - - if (ret < 0) - perror("rsend"); - - return ret; -} - -static ssize_t client_recv(struct message *msg, size_t size, int timeout) -{ - struct pollfd fds; - int ret; - - if (timeout) { - fds.fd = rs; - fds.events = POLLIN; - - ret = rs_poll(&fds, 1, timeout); - if (ret <= 0) - return ret; - } - - ret = rs_recv(rs, msg, size, flags | MSG_DONTWAIT); - if (ret < 0 && errno != EWOULDBLOCK && errno != EAGAIN) - perror("rrecv"); - - return ret; -} - -static int client_send_recv(struct message *msg, size_t size, int timeout) -{ - static uint8_t seqno; - int ret; - - msg->seqno = seqno; - do { - ret = client_send(msg, size); - if (ret != size) - return ret; - - ret = client_recv(msg, size, timeout); - } while (ret <= 0 || msg->seqno != seqno); - - seqno++; - return ret; -} - -static int run_test(void) -{ - int ret, i; - - g_msg.op = msg_op_start; - ret = client_send_recv(&g_msg, CTRL_MSG_SIZE, 1000); - if (ret != CTRL_MSG_SIZE) - goto out; - - g_msg.op = echo ? msg_op_echo : msg_op_data; - gettimeofday(&start, NULL); - for (i = 0; i < transfer_count; i++) { - ret = echo ? client_send_recv(&g_msg, transfer_size, 1) : - client_send(&g_msg, transfer_size); - if (ret != transfer_size) - goto out; - } - - g_msg.op = msg_op_end; - ret = client_send_recv(&g_msg, CTRL_MSG_SIZE, 1); - if (ret != CTRL_MSG_SIZE) - goto out; - - gettimeofday(&end, NULL); - show_perf(); - ret = 0; - -out: - return ret; -} - -static int client_connect(void) -{ - struct addrinfo hints, *res; - int ret; - - memset(&hints, 0, sizeof hints); - hints.ai_socktype = SOCK_DGRAM; - ret = getaddrinfo(dst_addr, port, &hints, &res); - if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); - return ret; - } - - rs = rs_socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (rs < 0) { - perror("rsocket"); - ret = rs; - goto out; - } - - set_options(rs); - ret = rs_connect(rs, res->ai_addr, res->ai_addrlen); - if (ret) { - perror("rconnect"); - rs_close(rs); - goto out; - } - - g_msg.op = msg_op_login; - ret = client_send_recv(&g_msg, CTRL_MSG_SIZE, 1000); - if (ret == CTRL_MSG_SIZE) - ret = 0; - -out: - freeaddrinfo(res); - return ret; -} - -static int client_run(void) -{ - int i, ret; - - printf("%-10s%-8s%-8s%-8s%8s %10s%13s\n", - "name", "bytes", "xfers", "total", "time", "Gb/sec", "usec/xfer"); - - ret = client_connect(); - if (ret) - return ret; - - if (!custom) { - for (i = 0; i < TEST_CNT; i++) { - init_latency_test(test_size[i]); - run_test(); - } - for (i = 0; i < TEST_CNT; i++) { - init_bandwidth_test(test_size[i]); - run_test(); - } - } else { - run_test(); - } - rs_close(rs); - - return ret; -} - -static int set_test_opt(const char *arg) -{ - if (strlen(arg) == 1) { - switch (arg[0]) { - case 's': - use_rs = 0; - break; - case 'a': - use_async = 1; - break; - case 'b': - flags = 0; - break; - case 'n': - flags = MSG_DONTWAIT; - break; - case 'e': - echo = 1; - break; - default: - return -1; - } - } else { - if (!strncasecmp("socket", arg, 6)) { - use_rs = 0; - } else if (!strncasecmp("async", arg, 5)) { - use_async = 1; - } else if (!strncasecmp("block", arg, 5)) { - flags = 0; - } else if (!strncasecmp("nonblock", arg, 8)) { - flags = MSG_DONTWAIT; - } else if (!strncasecmp("echo", arg, 4)) { - echo = 1; - } else { - return -1; - } - } - return 0; -} - -int main(int argc, char **argv) -{ - int op, ret; - - while ((op = getopt(argc, argv, "s:b:B:C:S:p:T:")) != -1) { - switch (op) { - case 's': - dst_addr = optarg; - break; - case 'b': - src_addr = optarg; - break; - case 'B': - buffer_size = atoi(optarg); - break; - case 'C': - custom = 1; - transfer_count = atoi(optarg); - break; - case 'S': - custom = 1; - transfer_size = atoi(optarg); - if (transfer_size < CTRL_MSG_SIZE) { - printf("size must be at least %d bytes\n", - CTRL_MSG_SIZE); - exit(1); - } - break; - case 'p': - port = optarg; - break; - case 'T': - if (!set_test_opt(optarg)) - break; - /* invalid option - fall through */ - SWITCH_FALLTHROUGH; - default: - printf("usage: %s\n", argv[0]); - printf("\t[-s server_address]\n"); - printf("\t[-b bind_address]\n"); - printf("\t[-B buffer_size]\n"); - printf("\t[-C transfer_count]\n"); - printf("\t[-S transfer_size]\n"); - printf("\t[-p port_number]\n"); - printf("\t[-T test_option]\n"); - printf("\t s|sockets - use standard tcp/ip sockets\n"); - printf("\t a|async - asynchronous operation (use poll)\n"); - printf("\t b|blocking - use blocking calls\n"); - printf("\t n|nonblocking - use nonblocking calls\n"); - printf("\t e|echo - server echoes all messages\n"); - exit(1); - } - } - - if (flags) - poll_timeout = -1; - - ret = dst_addr ? client_run() : svr_run(); - return ret; -} diff --git a/usr/rdma-core/librdmacm/ib.h b/usr/rdma-core/librdmacm/ib.h deleted file mode 100644 index 875cddbbc..000000000 --- a/usr/rdma-core/librdmacm/ib.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2010 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(_RDMA_IB_H) -#define _RDMA_IB_H - -#include -#include -#include - -#ifndef AF_IB -#define AF_IB 27 -#endif -#ifndef PF_IB -#define PF_IB AF_IB -#endif - -struct ib_addr { - union { - __u8 uib_addr8[16]; - __be16 uib_addr16[8]; - __be32 uib_addr32[4]; - __be64 uib_addr64[2]; - } ib_u; -#define sib_addr8 ib_u.uib_addr8 -#define sib_addr16 ib_u.uib_addr16 -#define sib_addr32 ib_u.uib_addr32 -#define sib_addr64 ib_u.uib_addr64 -#define sib_raw ib_u.uib_addr8 -#define sib_subnet_prefix ib_u.uib_addr64[0] -#define sib_interface_id ib_u.uib_addr64[1] -}; - -static inline int ib_addr_any(const struct ib_addr *a) -{ - return ((a->sib_addr64[0] | a->sib_addr64[1]) == 0); -} - -static inline int ib_addr_loopback(const struct ib_addr *a) -{ - return ((a->sib_addr32[0] | a->sib_addr32[1] | - a->sib_addr32[2] | (a->sib_addr32[3] ^ htobe32(1))) == 0); -} - -static inline void ib_addr_set(struct ib_addr *addr, - __be32 w1, __be32 w2, __be32 w3, __be32 w4) -{ - addr->sib_addr32[0] = w1; - addr->sib_addr32[1] = w2; - addr->sib_addr32[2] = w3; - addr->sib_addr32[3] = w4; -} - -static inline int ib_addr_cmp(const struct ib_addr *a1, const struct ib_addr *a2) -{ - return memcmp(a1, a2, sizeof(struct ib_addr)); -} - -struct sockaddr_ib { - unsigned short int sib_family; /* AF_IB */ - __be16 sib_pkey; - __be32 sib_flowinfo; - struct ib_addr sib_addr; - __be64 sib_sid; - __be64 sib_sid_mask; - __u64 sib_scope_id; -}; - -#endif /* _RDMA_IB_H */ diff --git a/usr/rdma-core/librdmacm/indexer.c b/usr/rdma-core/librdmacm/indexer.c deleted file mode 100644 index 00be7d04c..000000000 --- a/usr/rdma-core/librdmacm/indexer.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2011 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include - -#include -#include -#include - -#include "indexer.h" - -/* - * Indexer - to find a structure given an index - * - * We store pointers using a double lookup and return an index to the - * user which is then used to retrieve the pointer. The upper bits of - * the index are itself an index into an array of memory allocations. - * The lower bits specify the offset into the allocated memory where - * the pointer is stored. - * - * This allows us to adjust the number of pointers stored by the index - * list without taking a lock during data lookups. - */ - -static int idx_grow(struct indexer *idx) -{ - union idx_entry *entry; - int i, start_index; - - if (idx->size >= IDX_ARRAY_SIZE) - goto nomem; - - idx->array[idx->size] = calloc(IDX_ENTRY_SIZE, sizeof(union idx_entry)); - if (!idx->array[idx->size]) - goto nomem; - - entry = idx->array[idx->size]; - start_index = idx->size << IDX_ENTRY_BITS; - entry[IDX_ENTRY_SIZE - 1].next = idx->free_list; - - for (i = IDX_ENTRY_SIZE - 2; i >= 0; i--) - entry[i].next = start_index + i + 1; - - /* Index 0 is reserved */ - if (start_index == 0) - start_index++; - idx->free_list = start_index; - idx->size++; - return start_index; - -nomem: - errno = ENOMEM; - return -1; -} - -int idx_insert(struct indexer *idx, void *item) -{ - union idx_entry *entry; - int index; - - if ((index = idx->free_list) == 0) { - if ((index = idx_grow(idx)) <= 0) - return index; - } - - entry = idx->array[idx_array_index(index)]; - idx->free_list = entry[idx_entry_index(index)].next; - entry[idx_entry_index(index)].item = item; - return index; -} - -void *idx_remove(struct indexer *idx, int index) -{ - union idx_entry *entry; - void *item; - - entry = idx->array[idx_array_index(index)]; - item = entry[idx_entry_index(index)].item; - entry[idx_entry_index(index)].next = idx->free_list; - idx->free_list = index; - return item; -} - -void idx_replace(struct indexer *idx, int index, void *item) -{ - union idx_entry *entry; - - entry = idx->array[idx_array_index(index)]; - entry[idx_entry_index(index)].item = item; -} - - -static int idm_grow(struct index_map *idm, int index) -{ - idm->array[idx_array_index(index)] = calloc(IDX_ENTRY_SIZE, sizeof(void *)); - if (!idm->array[idx_array_index(index)]) - goto nomem; - - return index; - -nomem: - errno = ENOMEM; - return -1; -} - -int idm_set(struct index_map *idm, int index, void *item) -{ - void **entry; - - if (index > IDX_MAX_INDEX) { - errno = ENOMEM; - return -1; - } - - if (!idm->array[idx_array_index(index)]) { - if (idm_grow(idm, index) < 0) - return -1; - } - - entry = idm->array[idx_array_index(index)]; - entry[idx_entry_index(index)] = item; - return index; -} - -void *idm_clear(struct index_map *idm, int index) -{ - void **entry; - void *item; - - entry = idm->array[idx_array_index(index)]; - item = entry[idx_entry_index(index)]; - entry[idx_entry_index(index)] = NULL; - return item; -} diff --git a/usr/rdma-core/librdmacm/indexer.h b/usr/rdma-core/librdmacm/indexer.h deleted file mode 100644 index e6ffc60c1..000000000 --- a/usr/rdma-core/librdmacm/indexer.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2011 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#if !defined(INDEXER_H) -#define INDEXER_H - -#include -#include -#include - -/* - * Indexer - to find a structure given an index. Synchronization - * must be provided by the caller. Caller must initialize the - * indexer by setting free_list and size to 0. - */ - -union idx_entry { - void *item; - int next; -}; - -#define IDX_INDEX_BITS 16 -#define IDX_ENTRY_BITS 10 -#define IDX_ENTRY_SIZE (1 << IDX_ENTRY_BITS) -#define IDX_ARRAY_SIZE (1 << (IDX_INDEX_BITS - IDX_ENTRY_BITS)) -#define IDX_MAX_INDEX ((1 << IDX_INDEX_BITS) - 1) - -struct indexer -{ - union idx_entry *array[IDX_ARRAY_SIZE]; - int free_list; - int size; -}; - -#define idx_array_index(index) (index >> IDX_ENTRY_BITS) -#define idx_entry_index(index) (index & (IDX_ENTRY_SIZE - 1)) - -int idx_insert(struct indexer *idx, void *item); -void *idx_remove(struct indexer *idx, int index); -void idx_replace(struct indexer *idx, int index, void *item); - -static inline void *idx_at(struct indexer *idx, int index) -{ - return (idx->array[idx_array_index(index)] + idx_entry_index(index))->item; -} - -/* - * Index map - associates a structure with an index. Synchronization - * must be provided by the caller. Caller must initialize the - * index map by setting it to 0. - */ - -struct index_map -{ - void **array[IDX_ARRAY_SIZE]; -}; - -int idm_set(struct index_map *idm, int index, void *item); -void *idm_clear(struct index_map *idm, int index); - -static inline void *idm_at(struct index_map *idm, int index) -{ - void **entry; - entry = idm->array[idx_array_index(index)]; - return entry[idx_entry_index(index)]; -} - -static inline void *idm_lookup(struct index_map *idm, int index) -{ - return ((index <= IDX_MAX_INDEX) && idm->array[idx_array_index(index)]) ? - idm_at(idm, index) : NULL; -} - -typedef struct _dlist_entry { - struct _dlist_entry *next; - struct _dlist_entry *prev; -} dlist_entry; - -static inline void dlist_init(dlist_entry *head) -{ - head->next = head; - head->prev = head; -} - -static inline int dlist_empty(dlist_entry *head) -{ - return head->next == head; -} - -static inline void dlist_insert_after(dlist_entry *item, dlist_entry *head) -{ - item->next = head->next; - item->prev = head; - head->next->prev = item; - head->next = item; -} - -static inline void dlist_insert_before(dlist_entry *item, dlist_entry *head) -{ - dlist_insert_after(item, head->prev); -} - -#define dlist_insert_head dlist_insert_after -#define dlist_insert_tail dlist_insert_before - -static inline void dlist_remove(dlist_entry *item) -{ - item->prev->next = item->next; - item->next->prev = item->prev; -} - -#endif /* INDEXER_H */ diff --git a/usr/rdma-core/librdmacm/librdmacm.map b/usr/rdma-core/librdmacm/librdmacm.map deleted file mode 100644 index 65c049211..000000000 --- a/usr/rdma-core/librdmacm/librdmacm.map +++ /dev/null @@ -1,73 +0,0 @@ -/* Do not change this file without reading Documentation/versioning.md */ -RDMACM_1.0 { - global: - rdma_create_event_channel; - rdma_destroy_event_channel; - rdma_create_id; - rdma_destroy_id; - rdma_bind_addr; - rdma_resolve_addr; - rdma_resolve_route; - rdma_create_qp; - rdma_destroy_qp; - rdma_connect; - rdma_listen; - rdma_accept; - rdma_reject; - rdma_notify; - rdma_disconnect; - rdma_get_cm_event; - rdma_ack_cm_event; - rdma_get_src_port; - rdma_get_dst_port; - rdma_join_multicast; - rdma_leave_multicast; - rdma_get_devices; - rdma_free_devices; - rdma_event_str; - rdma_set_option; - rdma_get_local_addr; - rdma_get_peer_addr; - rdma_migrate_id; - rdma_getaddrinfo; - rdma_freeaddrinfo; - rdma_get_request; - rdma_create_ep; - rdma_destroy_ep; - rdma_create_srq; - rdma_destroy_srq; - rsocket; - rbind; - rlisten; - raccept; - rconnect; - rshutdown; - rclose; - rrecv; - rrecvfrom; - rrecvmsg; - rsend; - rsendto; - rsendmsg; - rread; - rreadv; - rwrite; - rwritev; - rpoll; - rselect; - rgetpeername; - rgetsockname; - rsetsockopt; - rgetsockopt; - rfcntl; - rpoll; - rselect; - rdma_get_src_port; - rdma_get_dst_port; - riomap; - riounmap; - riowrite; - rdma_create_srq_ex; - rdma_create_qp_ex; - local: *; -}; diff --git a/usr/rdma-core/librdmacm/librspreload.map b/usr/rdma-core/librdmacm/librspreload.map deleted file mode 100644 index 67ecf33b8..000000000 --- a/usr/rdma-core/librdmacm/librspreload.map +++ /dev/null @@ -1,33 +0,0 @@ -{ - /* FIXME: It is probably not a great idea to not tag these with the - proper symbol version from glibc, at least if glibc ever changes - the signature this will go sideways.. */ - global: - accept; - bind; - close; - connect; - dup2; - fcntl; - getpeername; - getsockname; - getsockopt; - listen; - poll; - read; - readv; - recv; - recvfrom; - recvmsg; - select; - send; - sendfile; - sendmsg; - sendto; - setsockopt; - shutdown; - socket; - write; - writev; - local: *; -}; diff --git a/usr/rdma-core/librdmacm/man/CMakeLists.txt b/usr/rdma-core/librdmacm/man/CMakeLists.txt deleted file mode 100644 index d4d54c58a..000000000 --- a/usr/rdma-core/librdmacm/man/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -rdma_man_pages( - cmtime.1 - mckey.1 - rcopy.1 - rdma_accept.3 - rdma_ack_cm_event.3 - rdma_bind_addr.3 - rdma_client.1 - rdma_cm.7 - rdma_connect.3 - rdma_create_ep.3 - rdma_create_event_channel.3 - rdma_create_id.3 - rdma_create_qp.3 - rdma_create_srq.3 - rdma_dereg_mr.3 - rdma_destroy_ep.3 - rdma_destroy_event_channel.3 - rdma_destroy_id.3 - rdma_destroy_qp.3 - rdma_destroy_srq.3 - rdma_disconnect.3 - rdma_event_str.3 - rdma_free_devices.3 - rdma_get_cm_event.3 - rdma_get_devices.3 - rdma_get_dst_port.3 - rdma_get_local_addr.3 - rdma_get_peer_addr.3 - rdma_get_recv_comp.3 - rdma_get_request.3 - rdma_get_send_comp.3 - rdma_get_src_port.3 - rdma_getaddrinfo.3 - rdma_join_multicast.3 - rdma_leave_multicast.3 - rdma_listen.3 - rdma_migrate_id.3 - rdma_notify.3 - rdma_post_read.3 - rdma_post_readv.3 - rdma_post_recv.3 - rdma_post_recvv.3 - rdma_post_send.3 - rdma_post_sendv.3 - rdma_post_ud_send.3 - rdma_post_write.3 - rdma_post_writev.3 - rdma_reg_msgs.3 - rdma_reg_read.3 - rdma_reg_write.3 - rdma_reject.3 - rdma_resolve_addr.3 - rdma_resolve_route.3 - rdma_server.1 - rdma_set_option.3 - rdma_xclient.1 - rdma_xserver.1 - riostream.1 - rping.1 - rsocket.7.in - rstream.1 - ucmatose.1 - udaddy.1 - udpong.1 - ) diff --git a/usr/rdma-core/librdmacm/man/cmtime.1 b/usr/rdma-core/librdmacm/man/cmtime.1 deleted file mode 100644 index 434373d57..000000000 --- a/usr/rdma-core/librdmacm/man/cmtime.1 +++ /dev/null @@ -1,50 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "CMTIME" 1 "2017-04-28" "librdmacm" "librdmacm" librdmacm -.SH NAME -cmtime \- RDMA CM connection steps timing test. -.SH SYNOPSIS -.sp -.nf -\fIcmtime\fR [-s server_address] [-b bind_address] - [-c connections] [-p port_number] - [-r retries] [-t timeout_ms] -.fi -.SH "DESCRIPTION" -Determines min and max times for various "steps" in RDMA CM -connection setup and teardown between a client and server -application. - -"Steps" that are timed are: create id, bind address, resolve address, -resolve route, create qp, connect, disconnect, and destroy. -.SH "OPTIONS" -.TP -\-s server_address -The network name or IP address of the server system listening for -connections. The used name or address must route over an RDMA device. -This option must be specified by the client. -.TP -\-b bind_address -The local network address to bind to. -.TP -\-c connections -The number of connections to establish between the client and -server. (default 100) -.TP -\-p port_number -The server's port number. -.TP -\-r retries -Number of retries when resolving address or route. (default 2) -.TP -\-t timeout_ms -Timeout in millseconds (ms) when resolving address or -route. (default 2000 - 2 seconds) -.SH "NOTES" -Basic usage is to start cmtime on a server system, then run -cmtime -s server_name on a client system. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7) diff --git a/usr/rdma-core/librdmacm/man/mckey.1 b/usr/rdma-core/librdmacm/man/mckey.1 deleted file mode 100644 index a36f57ba9..000000000 --- a/usr/rdma-core/librdmacm/man/mckey.1 +++ /dev/null @@ -1,60 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "MCKEY" 1 "2007-05-15" "librdmacm" "librdmacm" librdmacm -.SH NAME -mckey \- RDMA CM multicast setup and simple data transfer test. -.SH SYNOPSIS -.sp -.nf -\fImckey\fR -m multicast_address [-s] [-b bind_address] [-c connections] - [-C message_count] [-S message_size] [-p port_space] -\fImckey\fR -m multicast_address -s [-b bind_address] [-c connections] - [-C message_count] [-S message_size] [-p port_space] -\fImckey\fR -M unmapped_multicast_address -b bind_address [-s] [-c connections] - [-C message_count] [-S message_size] [-p port_space] -.fi -.SH "DESCRIPTION" -Establishes a set of RDMA multicast communication paths between nodes -using the librdmacm, optionally transfers datagrams to receiving nodes, -then tears down the communication. -.SH "OPTIONS" -.TP -\-m multicast_address -IP multicast address to join. -.TP -\-M unmapped_multicast_address -RDMA transport specific multicast address to join. -.TP -\-s -Send datagrams to the multicast group. -.TP -\-b bind_address -The local network address to bind to. -.TP -\-c connections -The number of QPs to join the multicast group. (default 1) -.TP -\-C message_count -The number of messages to transfer over each connection. (default 10) -.TP -\-S message_size -The size of each message transferred, in bytes. This value must be smaller -than the MTU of the underlying RDMA transport, or an error will occur. -(default 100) -.TP -\-p port_space -The port space of the datagram communication. May be either the RDMA -UDP (0x0111) or IPoIB (0x0002) port space. (default RDMA_PS_UDP) -.SH "NOTES" -Basic usage is to start mckey -m multicast_address on a server system, -then run mckey -m multicast_address -s on a client system. -.P -Unique Infiniband SA assigned multicast GIDs can be retrieved by -invoking mckey with a zero MGID or IP address. (Example, -M 0 or --m 0.0.0.0). The assigned address will be displayed to allow -mckey clients to join the created group. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7), ucmatose(1), udaddy(1), rping(1) diff --git a/usr/rdma-core/librdmacm/man/rcopy.1 b/usr/rdma-core/librdmacm/man/rcopy.1 deleted file mode 100644 index 1dcca494e..000000000 --- a/usr/rdma-core/librdmacm/man/rcopy.1 +++ /dev/null @@ -1,38 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RCOPY" 1 "2011-12-2" "librdmacm" "librdmacm" librdmacm -.SH NAME -rcopy \- simple file copy over RDMA. -.SH SYNOPSIS -.sp -.nf -\fIrcopy\fR source server[:destination] [-p port] -\fIrcopy\fR [-p port] -.fi -.SH "DESCRIPTION" -Uses sockets over RDMA interface to copy a source file to the -specified destination. -.SH "OPTIONS" -.TP -source -The name and path of the source file to copy. -.TP -server -The name or address of the destination server. -.TP -:destination -An optional destination filename and path. If not given, the destination -filename will match that of the source. -.TP -\-p server_port -The server's port number. -.TP -.SH "NOTES" -Basic usage is to start rcopy on a server system, then run -rcopy sourcefile servername. The server application will continue to run after -copying the file, but is currently single-threaded. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7) diff --git a/usr/rdma-core/librdmacm/man/rdma_accept.3 b/usr/rdma-core/librdmacm/man/rdma_accept.3 deleted file mode 100644 index a146a8d39..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_accept.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_ACCEPT" 3 "2014-05-27" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_accept \- Called to accept a connection request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_accept -.BI "(struct rdma_cm_id *" id "," -.BI "struct rdma_conn_param *" conn_param ");" -.SH ARGUMENTS -.IP "id" 12 -Connection identifier associated with the request. -.IP "conn_param" 12 -Information needed to establish the connection. See CONNECTION PROPERTIES -below for details. -.SH "DESCRIPTION" -Called from the listening side to accept a connection or datagram -service lookup request. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Unlike the socket accept routine, rdma_accept is not called on a -listening rdma_cm_id. Instead, after calling rdma_listen, the user -waits for an RDMA_CM_EVENT_CONNECT_REQUEST event to occur. Connection request -events give the user a newly created rdma_cm_id, similar to a new -socket, but the rdma_cm_id is bound to a specific RDMA device. -rdma_accept is called on the new rdma_cm_id. -.SH "CONNECTION PROPERTIES" -The following properties are used to configure the communication and specified -by the conn_param parameter when accepting a connection or datagram -communication request. Users should use the rdma_conn_param values reported -in the connection request event to determine appropriate values for these -fields when accepting. Users may reference the rdma_conn_param structure in -the connection event directly, or can reference their own structure. If the -rdma_conn_param structure from an event is referenced, the event must not be -acked until after this call returns. -.P -If the conn_param parameter is NULL, the values reported in the connection -request event are used, adjusted down based on local hardware restrictions. -.IP private_data -References a user-controlled data buffer. The contents of the buffer are -copied and transparently passed to the remote side as part of the -communication request. May be NULL if private_data is not required. -.IP private_data_len -Specifies the size of the user-controlled data buffer. Note that the actual -amount of data transferred to the remote side is transport dependent and may -be larger than that requested. -.IP responder_resources -The maximum number of outstanding RDMA read and atomic operations that the -local side will accept from the remote side. Applies only to RDMA_PS_TCP. -This value must be less than or equal to the local RDMA device attribute -max_qp_rd_atom, but preferably greater than or equal to the responder_resources -value reported in the connect request event. -.IP initiator_depth -The maximum number of outstanding RDMA read and atomic operations that the -local side will have to the remote side. Applies only to RDMA_PS_TCP. -This value must be less than or equal to the local RDMA device attribute -max_qp_init_rd_atom and the initiator_depth value reported in the connect -request event. -.IP flow_control -Specifies if hardware flow control is available. This value is exchanged -with the remote peer and is not used to configure the QP. Applies only to -RDMA_PS_TCP. -.IP retry_count -This value is ignored. -.IP rnr_retry_count -The maximum number of times that a send operation from the remote peer -should be retried on a connection after receiving a receiver not ready (RNR) -error. RNR errors are generated when a send request arrives before a buffer -has been posted to receive the incoming data. Applies only to RDMA_PS_TCP. -.IP srq -Specifies if the QP associated with the connection is using a shared receive -queue. This field is ignored by the library if a QP has been created on the -rdma_cm_id. Applies only to RDMA_PS_TCP. -.IP qp_num -Specifies the QP number associated with the connection. This field is ignored -by the library if a QP has been created on the rdma_cm_id. -.SH "INFINIBAND SPECIFIC" -In addition to the connection properties defined above, InfiniBand QPs are -configured with minimum RNR NAK timer and local ACK timeout values. The -minimum RNR NAK timer value is set to 0, for a delay of 655 ms. -The local ACK timeout is calculated based on the packet lifetime and local -HCA ACK delay. The packet lifetime is determined by the InfiniBand Subnet -Administrator and is part of the route (path record) information obtained -by the active side of the connection. The HCA ACK delay is a property of -the locally used HCA. -.P -The RNR retry count is a 3-bit value. -.P -The length of the private data provided by the user is limited to 196 bytes -for RDMA_PS_TCP, or 136 bytes for RDMA_PS_UDP. -.SH "SEE ALSO" -rdma_listen(3), rdma_reject(3), rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_ack_cm_event.3 b/usr/rdma-core/librdmacm/man/rdma_ack_cm_event.3 deleted file mode 100644 index a9a616aa0..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_ack_cm_event.3 +++ /dev/null @@ -1,22 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_ACK_CM_EVENT" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_ack_cm_event \- Free a communication event. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_ack_cm_event -.BI "(struct rdma_cm_event *" event ");" -.SH ARGUMENTS -.IP "event" 12 -Event to be released. -.SH "DESCRIPTION" -All events which are allocated by rdma_get_cm_event must be released, -there should be a one-to-one correspondence between successful gets -and acks. This call frees the event structure and any memory that it -references. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "SEE ALSO" -rdma_get_cm_event(3), rdma_destroy_id(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_bind_addr.3 b/usr/rdma-core/librdmacm/man/rdma_bind_addr.3 deleted file mode 100644 index 37db52c72..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_bind_addr.3 +++ /dev/null @@ -1,33 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_BIND_ADDR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_bind_addr \- Bind an RDMA identifier to a source address. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_bind_addr -.BI "(struct rdma_cm_id *" id "," -.BI "struct sockaddr *" addr ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "addr" 12 -Local address information. Wildcard values are permitted. -.SH "DESCRIPTION" -Associates a source address with an rdma_cm_id. The address may be -wildcarded. If binding to a specific local address, the rdma_cm_id -will also be bound to a local RDMA device. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Typically, this routine is called before calling rdma_listen to bind -to a specific port number, but it may also be called on the active side -of a connection before calling rdma_resolve_addr to bind to a specific -address. -.P -If used to bind to port 0, the rdma_cm will select an available port, -which can be retrieved with rdma_get_src_port(3). -.SH "SEE ALSO" -rdma_create_id(3), rdma_listen(3), rdma_resolve_addr(3), rdma_create_qp(3), -rdma_get_local_addr(3), rdma_get_src_port(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_client.1 b/usr/rdma-core/librdmacm/man/rdma_client.1 deleted file mode 100644 index 91b2d6322..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_client.1 +++ /dev/null @@ -1,32 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_CLIENT" 1 "2010-07-19" "librdmacm" "librdmacm" librdmacm -.SH NAME -rdma_client \- simple RDMA CM connection and ping-pong test. -.SH SYNOPSIS -.sp -.nf -\fIrdma_client\fR [-s server_address] [-p server_port] -.fi -.SH "DESCRIPTION" -Uses synchronous librdmam calls to establish an RDMA connection between -two nodes. This example is intended to provide a very simple coding -example of how to use RDMA. -.SH "OPTIONS" -.TP -\-s server_address -Specifies the address of the system that the rdma_server is running on. -By default, the client will attempt to connect to the server using -127.0.0.1. -.TP -\-p server_port -Specifies the port number that the server listens on. By default the server -listens on port 7471. -.SH "NOTES" -Basic usage is to start rdma_server, then connect to the server using the -rdma_client program. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7), udaddy(1), mckey(1), rping(1), rdma_server(1) diff --git a/usr/rdma-core/librdmacm/man/rdma_cm.7 b/usr/rdma-core/librdmacm/man/rdma_cm.7 deleted file mode 100644 index 8e5ad99e6..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_cm.7 +++ /dev/null @@ -1,230 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_CM" 7 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_cm \- RDMA communication manager. -.SH SYNOPSIS -.B "#include " -.SH "DESCRIPTION" -Used to establish communication over RDMA transports. -.SH "NOTES" -The RDMA CM is a communication manager used to setup reliable, connected -and unreliable datagram data transfers. It provides an RDMA transport -neutral interface for establishing connections. The API concepts are -based on sockets, but adapted for queue pair (QP) based semantics: -communication must be over a specific RDMA device, and data transfers -are message based. -.P -The RDMA CM can control both the QP and communication management (connection setup / -teardown) portions of an RDMA API, or only the communication management -piece. It works in conjunction with the verbs -API defined by the libibverbs library. The libibverbs library provides the -underlying interfaces needed to send and receive data. -.P -The RDMA CM can operate asynchronously or synchronously. The mode of -operation is controlled by the user through the use of the rdma_cm event channel -parameter in specific calls. If an event channel is provided, an rdma_cm identifier -will report its event data (results of connecting, for example), on that channel. -If a channel is not provided, then all rdma_cm operations for the selected -rdma_cm identifier will block until they complete. -.SH "RDMA VERBS" -The rdma_cm supports the full range of verbs available through the libibverbs -library and interfaces. However, it also provides wrapper functions for some -of the more commonly used verbs funcationality. The full set of abstracted -verb calls are: -.P -rdma_reg_msgs - register an array of buffers for sending and receiving -.P -rdma_reg_read - registers a buffer for RDMA read operations -.P -rdma_reg_write - registers a buffer for RDMA write operations -.P -rdma_dereg_mr - deregisters a memory region -.P -rdma_post_recv - post a buffer to receive a message -.P -rdma_post_send - post a buffer to send a message -.P -rdma_post_read - post an RDMA to read data into a buffer -.P -rdma_post_write - post an RDMA to send data from a buffer -.P -rdma_post_recvv - post a vector of buffers to receive a message -.P -rdma_post_sendv - post a vector of buffers to send a message -.P -rdma_post_readv - post a vector of buffers to receive an RDMA read -.P -rdma_post_writev - post a vector of buffers to send an RDMA write -.P -rdma_post_ud_send - post a buffer to send a message on a UD QP -.P -rdma_get_send_comp - get completion status for a send or RDMA operation -.P -rdma_get_recv_comp - get information about a completed receive -.SH "CLIENT OPERATION" -This section provides a general overview of the basic operation for the active, -or client, side of communication. This flow assume asynchronous operation with -low level call details shown. For -synchronous operation, calls to rdma_create_event_channel, rdma_get_cm_event, -rdma_ack_cm_event, and rdma_destroy_event_channel -would be eliminated. Abstracted calls, such as rdma_create_ep encapsulate -several of these calls under a single API. -Users may also refer to the example applications for -code samples. A general connection flow would be: -.IP rdma_getaddrinfo -retrieve address information of the destination -.IP rdma_create_event_channel -create channel to receive events -.IP rdma_create_id -allocate an rdma_cm_id, this is conceptually similar to a socket -.IP rdma_resolve_addr -obtain a local RDMA device to reach the remote address -.IP rdma_get_cm_event -wait for RDMA_CM_EVENT_ADDR_RESOLVED event -.IP rdma_ack_cm_event -ack event -.IP rdma_create_qp -allocate a QP for the communication -.IP rdma_resolve_route -determine the route to the remote address -.IP rdma_get_cm_event -wait for RDMA_CM_EVENT_ROUTE_RESOLVED event -.IP rdma_ack_cm_event -ack event -.IP rdma_connect -connect to the remote server -.IP rdma_get_cm_event -wait for RDMA_CM_EVENT_ESTABLISHED event -.IP rdma_ack_cm_event -ack event -.P -Perform data transfers over connection -.IP rdma_disconnect -tear-down connection -.IP rdma_get_cm_event -wait for RDMA_CM_EVENT_DISCONNECTED event -.IP rdma_ack_cm_event -ack event -.IP rdma_destroy_qp -destroy the QP -.IP rdma_destroy_id -release the rdma_cm_id -.IP rdma_destroy_event_channel -release the event channel -.P -An almost identical process is used to setup unreliable datagram (UD) -communication between nodes. No actual connection is formed between QPs -however, so disconnection is not needed. -.P -Although this example shows the client initiating the disconnect, either side -of a connection may initiate the disconnect. -.SH "SERVER OPERATION" -This section provides a general overview of the basic operation for the passive, -or server, side of communication. A general connection flow would be: -.IP rdma_create_event_channel -create channel to receive events -.IP rdma_create_id -allocate an rdma_cm_id, this is conceptually similar to a socket -.IP rdma_bind_addr -set the local port number to listen on -.IP rdma_listen -begin listening for connection requests -.IP rdma_get_cm_event -wait for RDMA_CM_EVENT_CONNECT_REQUEST event with a new rdma_cm_id -.IP rdma_create_qp -allocate a QP for the communication on the new rdma_cm_id -.IP rdma_accept -accept the connection request -.IP rdma_ack_cm_event -ack event -.IP rdma_get_cm_event -wait for RDMA_CM_EVENT_ESTABLISHED event -.IP rdma_ack_cm_event -ack event -.P -Perform data transfers over connection -.IP rdma_get_cm_event -wait for RDMA_CM_EVENT_DISCONNECTED event -.IP rdma_ack_cm_event -ack event -.IP rdma_disconnect -tear-down connection -.IP rdma_destroy_qp -destroy the QP -.IP rdma_destroy_id -release the connected rdma_cm_id -.IP rdma_destroy_id -release the listening rdma_cm_id -.IP rdma_destroy_event_channel -release the event channel -.SH "RETURN CODES" -.IP "= 0" -success -.IP "= -1" -error - see errno for more details -.P -Most librdmacm functions return 0 to indicate success, and a -1 return value -to indicate failure. If a function operates asynchronously, a return value of 0 -means that the operation was successfully started. The operation could still -complete in error; users should check the status of the related event. If the -return value is -1, then errno will contain additional information -regarding the reason for the failure. -.P -Prior versions of the library would return -errno and not set errno for some cases -related to ENOMEM, ENODEV, ENODATA, EINVAL, and EADDRNOTAVAIL codes. Applications -that want to check these codes and have compatibility with prior library versions -must manually set errno to the negative of the return code if it is < -1. -.SH "SEE ALSO" -rdma_accept(3), -rdma_ack_cm_event(3), -rdma_bind_addr(3), -rdma_connect(3), -rdma_create_ep(3), -rdma_create_event_channel(3), -rdma_create_id(3), -rdma_create_qp(3), -rdma_dereg_mr(3), -rdma_destroy_ep(3), -rdma_destroy_event_channel(3), -rdma_destroy_id(3), -rdma_destroy_qp(3), -rdma_disconnect(3), -rdma_event_str(3), -rdma_free_devices(3), -rdma_getaddrinfo(3), -rdma_get_cm_event(3), -rdma_get_devices(3), -rdma_get_dst_port(3), -rdma_get_local_addr(3), -rdma_get_peer_addr(3), -rdma_get_recv_comp(3), -rdma_get_request(3), -rdma_get_send_comp(3), -rdma_get_src_port(3), -rdma_join_multicast(3), -rdma_leave_multicast(3), -rdma_listen(3), -rdma_migrate_id(3), -rdma_notify(3), -rdma_post_read(3) -rdma_post_readv(3), -rdma_post_recv(3), -rdma_post_recvv(3), -rdma_post_send(3), -rdma_post_sendv(3), -rdma_post_ud_send(3), -rdma_post_write(3), -rdma_post_writev(3), -rdma_reg_msgs(3), -rdma_reg_read(3), -rdma_reg_write(3), -rdma_reject(3), -rdma_resolve_addr(3), -rdma_resolve_route(3), -rdma_set_option(3) -mckey(1), -rdma_client(1), -rdma_server(1), -rping(1), -ucmatose(1), -udaddy(1) diff --git a/usr/rdma-core/librdmacm/man/rdma_connect.3 b/usr/rdma-core/librdmacm/man/rdma_connect.3 deleted file mode 100644 index ef88e38a7..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_connect.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_CONNECT" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_connect \- Initiate an active connection request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_connect -.BI "(struct rdma_cm_id *" id "," -.BI "struct rdma_conn_param *" conn_param ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "conn_param" 12 -connection parameters. See CONNECTION PROPERTIES below for details. -.SH "DESCRIPTION" -For an rdma_cm_id of type RDMA_PS_TCP, this call initiates a connection request -to a remote destination. For an rdma_cm_id of type RDMA_PS_UDP, it initiates -a lookup of the remote QP providing the datagram service. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Users must have resolved a route to the destination address -by having called rdma_resolve_route or rdma_create_ep before calling -this routine. -.SH "CONNECTION PROPERTIES" -The following properties are used to configure the communication and specified -by the conn_param parameter when connecting or establishing datagram -communication. -.IP private_data -References a user-controlled data buffer. The contents of the buffer are -copied and transparently passed to the remote side as part of the -communication request. May be NULL if private_data is not required. -.IP private_data_len -Specifies the size of the user-controlled data buffer. Note that the actual -amount of data transferred to the remote side is transport dependent and may -be larger than that requested. -.IP responder_resources -The maximum number of outstanding RDMA read and atomic operations that the -local side will accept from the remote side. Applies only to RDMA_PS_TCP. -This value must be less than or equal to the local RDMA device attribute -max_qp_rd_atom and remote RDMA device attribute max_qp_init_rd_atom. The -remote endpoint can adjust this value when accepting the connection. -.IP initiator_depth -The maximum number of outstanding RDMA read and atomic operations that the -local side will have to the remote side. Applies only to RDMA_PS_TCP. -This value must be less than or equal to the local RDMA device attribute -max_qp_init_rd_atom and remote RDMA device attribute max_qp_rd_atom. The -remote endpoint can adjust this value when accepting the connection. -.IP flow_control -Specifies if hardware flow control is available. This value is exchanged -with the remote peer and is not used to configure the QP. Applies only to -RDMA_PS_TCP. -.IP retry_count -The maximum number of times that a data transfer operation should be retried -on the connection when an error occurs. This setting controls the number of -times to retry send, RDMA, and atomic operations when timeouts occur. -Applies only to RDMA_PS_TCP. -.IP rnr_retry_count -The maximum number of times that a send operation from the remote peer -should be retried on a connection after receiving a receiver not ready (RNR) -error. RNR errors are generated when a send request arrives before a buffer -has been posted to receive the incoming data. Applies only to RDMA_PS_TCP. -.IP srq -Specifies if the QP associated with the connection is using a shared receive -queue. This field is ignored by the library if a QP has been created on the -rdma_cm_id. Applies only to RDMA_PS_TCP. -.IP qp_num -Specifies the QP number associated with the connection. This field is ignored -by the library if a QP has been created on the rdma_cm_id. Applies only to -RDMA_PS_TCP. -.SH "INFINIBAND SPECIFIC" -In addition to the connection properties defined above, InfiniBand QPs are -configured with minimum RNR NAK timer and local ACK timeout values. The -minimum RNR NAK timer value is set to 0, for a delay of 655 ms. -The local ACK timeout is calculated based on the packet lifetime and local -HCA ACK delay. The packet lifetime is determined by the InfiniBand Subnet -Administrator and is part of the resolved route (path record) information. -The HCA ACK delay is a property of the locally used HCA. -.P -Retry count and RNR retry count values are 3-bit values. -.P -The length of the private data provided by the user is limited to 56 bytes -for RDMA_PS_TCP, or 180 bytes for RDMA_PS_UDP. -.SH "IWARP SPECIFIC" -Connections established over iWarp RDMA devices currently require that the -active side of the connection send the first message. -.SH "SEE ALSO" -rdma_cm(7), rdma_create_id(3), rdma_resolve_route(3), rdma_disconnect(3), -rdma_listen(3), rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_create_ep.3 b/usr/rdma-core/librdmacm/man/rdma_create_ep.3 deleted file mode 100644 index b1f397625..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_create_ep.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_CREATE_EP" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_create_ep \- Allocate a communication identifier and optional QP. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_create_ep -.BI "(struct rdma_cm_id **" id "," -.BI "struct rdma_addrinfo *" res "," -.BI "struct ibv_pd *" pd "," -.BI "struct ibv_qp_init_attr *" qp_init_attr ");" -.SH ARGUMENTS -.IP "id" 12 -A reference where the allocated communication identifier will be -returned. -.IP "res" 12 -Address information associated with the rdma_cm_id returned from -rdma_getaddrinfo. -.IP "pd" 12 -Optional protection domain if a QP is associated with the rdma_cm_id. -.IP "qp_init_attr" 12 -Optional initial QP attributes. -.SH "DESCRIPTION" -Creates an identifier that is used to track communication information. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -After resolving address information using rdma_getaddrinfo, a user -may use this call to allocate an rdma_cm_id based on the results. -.P -If the rdma_cm_id will be used on the active side of a connection, -meaning that res->ai_flag does not have RAI_PASSIVE set, rdma_create_ep -will automatically create a QP on the rdma_cm_id if qp_init_attr is -not NULL. The QP will be associated with the specified protection -domain, if provided, or a default protection domain if not. Users -should see rdma_create_qp for details on the use of the pd and -qp_init_attr parameters. After calling rdma_create_ep, the returned -rdma_cm_id may be connected by calling rdma_connect. The active side -calls rdma_resolve_addr and rdma_resolve_route are not necessary. -.P -If the rdma_cm_id will be used on the passive side of a connection, -indicated by having res->ai_flag RAI_PASSIVE set, this call will save -the provided pd and qp_init_attr parameters. When a new connection -request is retrieved by calling rdma_get_request, the rdma_cm_id -associated with the new connection will automatically be associated -with a QP using the pd and qp_init_attr parameters. After calling -rdma_create_ep, the returned rdma_cm_id may be placed into a listening -state by immediately calling rdma_listen. The passive side call -rdma_bind_addr is not necessary. Connection requests may then be -retrieved by calling rdma_get_request. -.P -The newly created rdma_cm_id will be set to use synchronous operation. -Users that wish asynchronous operation must migrate the rdma_cm_id -to a user created event channel using rdma_migrate_id. -.P -Users must release the created rdma_cm_id by calling rdma_destroy_ep. -.SH "SEE ALSO" -rdma_cm(7), rdma_getaddrinfo(3), rdma_create_event_channel(3), -rdma_connect(3), rdma_listen(3), rdma_destroy_ep(3), rdma_migrate_id(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_create_event_channel.3 b/usr/rdma-core/librdmacm/man/rdma_create_event_channel.3 deleted file mode 100644 index 928c79701..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_create_event_channel.3 +++ /dev/null @@ -1,32 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_CREATE_EVENT_CHANNEL" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_create_event_channel \- Open a channel used to report communication events. -.SH SYNOPSIS -.B "#include " -.P -.B "struct rdma_event_channel *" rdma_create_event_channel -.BI "(" void ");" -.SH ARGUMENTS -.IP "void" 12 -no arguments -.SH "DESCRIPTION" -Asynchronous events are reported to users through event channels. -.SH "RETURN VALUE" -Returns a pointer to the created event channel, or NULL if the request -fails. On failure, errno will be set to indicate the failure reason. -.SH "NOTES" -Event channels are used to direct all events on an rdma_cm_id. For many -clients, a single event channel may be sufficient, however, when managing -a large number of connections or cm_id's, users may find it useful to direct -events for different cm_id's to different channels for processing. -.P -All created event channels must be destroyed by calling -rdma_destroy_event_channel. Users should call rdma_get_cm_event to -retrieve events on an event channel. -.P -Each event channel is mapped to a file descriptor. The associated file -descriptor can be used and manipulated like any other fd to change its -behavior. Users may make the fd non-blocking, poll or select the fd, etc. -.SH "SEE ALSO" -rdma_cm(7), rdma_get_cm_event(3), rdma_destroy_event_channel(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_create_id.3 b/usr/rdma-core/librdmacm/man/rdma_create_id.3 deleted file mode 100644 index 0a5093af6..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_create_id.3 +++ /dev/null @@ -1,56 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_CREATE_ID" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_create_id \- Allocate a communication identifier. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_create_id -.BI "(struct rdma_event_channel *" channel "," -.BI "struct rdma_cm_id **" id "," -.BI "void *" context "," -.BI "enum rdma_port_space " ps ");" -.SH ARGUMENTS -.IP "channel" 12 -The communication channel that events associated with the -allocated rdma_cm_id will be reported on. This may be NULL. -.IP "id" 12 -A reference where the allocated communication identifier will be -returned. -.IP "context" 12 -User specified context associated with the rdma_cm_id. -.IP "ps" 12 -RDMA port space. -.SH "DESCRIPTION" -Creates an identifier that is used to track communication information. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Rdma_cm_id's are conceptually equivalent to a socket for RDMA -communication. The difference is that RDMA communication requires -explicitly binding to a specified RDMA device before communication -can occur, and most operations are asynchronous in nature. Asynchronous -communication events on an rdma_cm_id are reported through the associated -event channel. If the channel parameter is NULL, the rdma_cm_id will -be placed into synchronous operation. While operating synchronously, -calls that result in an event will block until the operation completes. -The event will be returned to the user through the rdma_cm_id structure, -and be available for access until another rdma_cm call is made. -.P -Users must release the rdma_cm_id by calling rdma_destroy_id. -.SH "PORT SPACE" -Details of the services provided by the different port spaces are outlined -below. -.IP RDMA_PS_TCP -Provides reliable, connection-oriented QP communication. Unlike TCP, the RDMA -port space provides message, not stream, based communication. -.IP RDMA_PS_UDP -Provides unreliable, connectionless QP communication. Supports both datagram -and multicast communication. -.IP RDMA_PS_IB -Provides for any IB services (UD, UC, RC, XRC, etc.). -.SH "SEE ALSO" -rdma_cm(7), rdma_create_event_channel(3), rdma_destroy_id(3), rdma_get_devices(3), -rdma_bind_addr(3), rdma_resolve_addr(3), rdma_connect(3), rdma_listen(3), -rdma_set_option(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_create_qp.3 b/usr/rdma-core/librdmacm/man/rdma_create_qp.3 deleted file mode 100644 index cd4708f7d..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_create_qp.3 +++ /dev/null @@ -1,49 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_CREATE_QP" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_create_qp \- Allocate a QP. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_create_qp -.BI "(struct rdma_cm_id *" id "," -.BI "struct ibv_pd *" pd "," -.BI "struct ibv_qp_init_attr *" qp_init_attr ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "pd" 12 -Optional protection domain for the QP. -.IP "qp_init_attr" 12 -Initial QP attributes. -.SH "DESCRIPTION" -Allocate a QP associated with the specified rdma_cm_id and transition it -for sending and receiving. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -The rdma_cm_id must be bound to a local RDMA device before calling this -function, and the protection domain must be for that same device. -QPs allocated to an rdma_cm_id are automatically transitioned by the -librdmacm through their states. After being allocated, the QP will be -ready to handle posting of receives. If the QP is unconnected, it will -be ready to post sends. -.P -If a protection domain is not given - pd parameter is NULL - then -the rdma_cm_id will be created using a default protection domain. One -default protection domain is allocated per RDMA device. -.P -The initial QP attributes are specified by the qp_init_attr parameter. The -send_cq and recv_cq fields in the ibv_qp_init_attr are optional. If -a send or receive completion queue is not specified, then a CQ will be -allocated by the rdma_cm for the QP, along with corresponding completion -channels. Completion channels and CQ data created by the rdma_cm are -exposed to the user through the rdma_cm_id structure. -.P -The actual capabilities and properties of the created QP will be -returned to the user through the qp_init_attr parameter. An rdma_cm_id -may only be associated with a single QP. -.SH "SEE ALSO" -rdma_bind_addr(3), rdma_resolve_addr(3), rdma_destroy_qp(3), ibv_create_qp(3), -ibv_modify_qp(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_create_srq.3 b/usr/rdma-core/librdmacm/man/rdma_create_srq.3 deleted file mode 100644 index 6257e86b3..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_create_srq.3 +++ /dev/null @@ -1,45 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_CREATE_SRQ" 3 "2011-06-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_create_srq \- Allocate a shared receive queue. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_create_srq -.BI "(struct rdma_cm_id *" id "," -.BI "struct ibv_pd *" pd "," -.BI "struct ibv_srq_init_attr *" attr ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "pd" 12 -Optional protection domain for the SRQ. -.IP "attr" 12 -Initial SRQ attributes. -.SH "DESCRIPTION" -Allocate a SRQ associated with the specified rdma_cm_id. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -The rdma_cm_id must be bound to a local RDMA device before calling this -function, and the protection domain, if provided, must be for that same device. -After being allocated, the SRQ will be ready to handle posting of receives. -.P -If a protection domain is not given - pd parameter is NULL - then -the rdma_cm_id will be created using a default protection domain. One -default protection domain is allocated per RDMA device. -.P -The initial SRQ attributes are specified by the attr parameter. The -ext.xrc.cq fields in the ibv_srq_init_attr is optional. If -a completion queue is not specified for an XRC SRQ, then a CQ will be -allocated by the rdma_cm for the SRQ, along with corresponding completion -channels. Completion channels and CQ data created by the rdma_cm are -exposed to the user through the rdma_cm_id structure. -.P -The actual capabilities and properties of the created SRQ will be -returned to the user through the attr parameter. An rdma_cm_id -may only be associated with a single SRQ. -.SH "SEE ALSO" -rdma_bind_addr(3), rdma_resolve_addr(3), rdma_create_ep(3), -rdma_destroy_srq(3), ibv_create_srq(3), ibv_create_xsrq(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_dereg_mr.3 b/usr/rdma-core/librdmacm/man/rdma_dereg_mr.3 deleted file mode 100644 index 893eb14b6..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_dereg_mr.3 +++ /dev/null @@ -1,29 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_DEREG_MR" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_dereg_mr \- deregisters a registered memory region. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_dereg_mr -.BI "(struct ibv_mr *" mr ");" -.SH ARGUMENTS -.IP "mr" 12 -A reference to a registered memory buffer. -.SH "DESCRIPTION" -Deregisters a memory buffer that had been registered for RDMA -or message operations. A user should call rdma_dereg_mr for all -registered memory associated with an rdma_cm_id before destroying -the rdma_cm_id. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -All memory registered with an rdma_cm_id is associated with the -protection domain associated with the id. Users must deregister -all registered memory before the protection domain can be destroyed. -.SH "SEE ALSO" -rdma_cm(7), rdma_create_id(3), rdma_create_ep(3), -rdma_destroy_id(3), rdma_destroy_ep(3), -rdma_reg_msgs(3), rdma_reg_read(3), rdma_reg_write(3), -ibv_reg_mr(3), ibv_dereg_mr(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_destroy_ep.3 b/usr/rdma-core/librdmacm/man/rdma_destroy_ep.3 deleted file mode 100644 index 1211f4b55..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_destroy_ep.3 +++ /dev/null @@ -1,20 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md - -.TH "RDMA_DESTROY_EP" 3 "2011-06-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_destroy_ep \- Release a communication identifier. -.SH SYNOPSIS -.B "#include " -.P -.B "void" rdma_destroy_ep -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -The communication identifier to destroy. -.SH "DESCRIPTION" -Destroys the specified rdma_cm_id and all associated resources -.SH "NOTES" -rdma_destroy_ep will automatically destroy any QP and SRQ associated with -the rdma_cm_id. -.SH "SEE ALSO" -rdma_create_ep(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_destroy_event_channel.3 b/usr/rdma-core/librdmacm/man/rdma_destroy_event_channel.3 deleted file mode 100644 index 5c5d663cb..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_destroy_event_channel.3 +++ /dev/null @@ -1,22 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_DESTROY_EVENT_CHANNEL" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_destroy_event_channel \- Close an event communication channel. -.SH SYNOPSIS -.B "#include " -.P -.B "void" rdma_destroy_event_channel -.BI "(struct rdma_event_channel *" channel ");" -.SH ARGUMENTS -.IP "channel" 12 -The communication channel to destroy. -.SH "DESCRIPTION" -Release all resources associated with an event channel and closes the -associated file descriptor. -.SH "RETURN VALUE" -None -.SH "NOTES" -All rdma_cm_id's associated with the event channel must be destroyed, -and all returned events must be acked before calling this function. -.SH "SEE ALSO" -rdma_create_event_channel(3), rdma_get_cm_event(3), rdma_ack_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_destroy_id.3 b/usr/rdma-core/librdmacm/man/rdma_destroy_id.3 deleted file mode 100644 index 1d95ff2d8..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_destroy_id.3 +++ /dev/null @@ -1,23 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_DESTROY_ID" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_destroy_id \- Release a communication identifier. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_destroy_id -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -The communication identifier to destroy. -.SH "DESCRIPTION" -Destroys the specified rdma_cm_id and cancels any outstanding -asynchronous operation. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Users must free any associated QP with the rdma_cm_id before -calling this routine and ack all related events. -.SH "SEE ALSO" -rdma_create_id(3), rdma_destroy_qp(3), rdma_ack_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_destroy_qp.3 b/usr/rdma-core/librdmacm/man/rdma_destroy_qp.3 deleted file mode 100644 index 03fba27e3..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_destroy_qp.3 +++ /dev/null @@ -1,19 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_DESTROY_QP" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_destroy_qp \- Deallocate a QP. -.SH SYNOPSIS -.B "#include " -.P -.B "void" rdma_destroy_qp -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.SH "DESCRIPTION" -Destroy a QP allocated on the rdma_cm_id. -.SH "NOTES" -Users must destroy any QP associated with an rdma_cm_id before -destroying the ID. -.SH "SEE ALSO" -rdma_create_qp(3), rdma_destroy_id(3), ibv_destroy_qp(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_destroy_srq.3 b/usr/rdma-core/librdmacm/man/rdma_destroy_srq.3 deleted file mode 100644 index 75c23c730..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_destroy_srq.3 +++ /dev/null @@ -1,21 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_DESTROY_SRQ" 3 "2011-06-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_destroy_srq \- Deallocate a SRQ. -.SH SYNOPSIS -.B "#include " -.P -.B "void" rdma_destroy_srq -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.SH "DESCRIPTION" -Destroy an SRQ allocated on the rdma_cm_id. -.SH "RETURN VALUE" -None -.SH "NOTES" -Users should destroy any SRQ associated with an rdma_cm_id before -destroying the ID. -.SH "SEE ALSO" -rdma_create_srq(3), rdma_destroy_id(3), ibv_destroy_srq(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_disconnect.3 b/usr/rdma-core/librdmacm/man/rdma_disconnect.3 deleted file mode 100644 index 23aec9869..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_disconnect.3 +++ /dev/null @@ -1,23 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_DISCONNECT" 3 "2008-01-02" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_disconnect \- This function disconnects a connection. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_disconnect -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.SH "DESCRIPTION" -Disconnects a connection and transitions any associated QP to the error state, -which will flush any posted work requests to the completion queue. This -routine should be called by both the client and server side of a connection. -After successfully disconnecting, an RDMA_CM_EVENT_DISCONNECTED event will be -generated on both sides of the connection. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "SEE ALSO" -rdma_connect(3), rdma_listen(3), rdma_accept(3), rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_event_str.3 b/usr/rdma-core/librdmacm/man/rdma_event_str.3 deleted file mode 100644 index 24c9e165a..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_event_str.3 +++ /dev/null @@ -1,18 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_EVENT_STR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_event_str \- Returns a string representation of an rdma cm event. -.SH SYNOPSIS -.B "#include " -.P -.B "char *" rdma_event_str -.BI "("enum rdma_cm_event_type " event ");" -.SH ARGUMENTS -.IP "event" 12 -Asynchronous event. -.SH "DESCRIPTION" -Returns a string representation of an asynchronous event. -.SH "RETURN VALUE" -Returns a pointer to a static character string corresponding to the event. -.SH "SEE ALSO" -rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_free_devices.3 b/usr/rdma-core/librdmacm/man/rdma_free_devices.3 deleted file mode 100644 index c46bcbfe6..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_free_devices.3 +++ /dev/null @@ -1,18 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_FREE_DEVICES" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_free_devices \- Frees the list of devices returned by rdma_get_devices. -.SH SYNOPSIS -.B "#include " -.P -.B "void" rdma_free_devices -.BI "(struct ibv_context **" list ");" -.SH ARGUMENTS -.IP "list" 12 -List of devices returned from rdma_get_devices. -.SH "DESCRIPTION" -Frees the device array returned by rdma_get_devices. -.SH "RETURN VALUE" -None -.SH "SEE ALSO" -rdma_get_devices(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_cm_event.3 b/usr/rdma-core/librdmacm/man/rdma_get_cm_event.3 deleted file mode 100644 index 2623eab8a..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_cm_event.3 +++ /dev/null @@ -1,168 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_CM_EVENT" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_cm_event \- Retrieves the next pending communication event. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_get_cm_event -.BI "(struct rdma_event_channel *" channel "," -.BI "struct rdma_cm_event **" event ");" -.SH ARGUMENTS -.IP "channel" 12 -Event channel to check for events. -.IP "event" 12 -Allocated information about the next communication event. -.SH "DESCRIPTION" -Retrieves a communication event. If no events are pending, by default, -the call will block until an event is received. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -The default synchronous behavior of this routine can be changed by -modifying the file descriptor associated with the given channel. All -events that are reported must be acknowledged by calling rdma_ack_cm_event. -Destruction of an rdma_cm_id will block until related events have been -acknowledged. -.SH "EVENT DATA" -Communication event details are returned in the rdma_cm_event structure. -This structure is allocated by the rdma_cm and released by the -rdma_ack_cm_event routine. Details of the rdma_cm_event structure are -given below. -.IP "id" 12 -The rdma_cm identifier associated with the event. If the event type is -RDMA_CM_EVENT_CONNECT_REQUEST, then this references a new id for that -communication. -.IP "listen_id" 12 -For RDMA_CM_EVENT_CONNECT_REQUEST event types, this references the -corresponding listening request identifier. -.IP "event" 12 -Specifies the type of communication event which occurred. See EVENT TYPES -below. -.IP "status" 12 -Returns any asynchronous error information associated with an event. The -status is zero if the operation was successful, otherwise the status value -is non-zero and is either set to an errno or a transport specific value. -For details on transport specific status values, see the event type information -below. -.IP "param" 12 -Provides additional details based on the type of event. Users should -select the conn or ud subfields based on the rdma_port_space of the -rdma_cm_id associated with the event. See UD EVENT DATA and CONN EVENT -DATA below. -.SH "UD EVENT DATA" -Event parameters related to unreliable datagram (UD) services: RDMA_PS_UDP and -RDMA_PS_IPOIB. The UD event data is valid for RDMA_CM_EVENT_ESTABLISHED and -RDMA_CM_EVENT_MULTICAST_JOIN events, unless stated otherwise. -.IP "private_data" 12 -References any user-specified data associated with RDMA_CM_EVENT_CONNECT_REQUEST -or RDMA_CM_EVENT_ESTABLISHED events. The data referenced by this field matches -that specified by the remote side when calling rdma_connect or rdma_accept. -This field is NULL if the event does not include private data. The buffer -referenced by this pointer is deallocated when calling rdma_ack_cm_event. -.IP "private_data_len" 12 -The size of the private data buffer. Users should note that the size of -the private data buffer may be larger than the amount of private data -sent by the remote side. Any additional space in the buffer will be -zeroed out. -.IP "ah_attr" 12 -Address information needed to send data to the remote endpoint(s). -Users should use this structure when allocating their address handle. -.IP "qp_num" 12 -QP number of the remote endpoint or multicast group. -.IP "qkey" 12 -QKey needed to send data to the remote endpoint(s). -.SH "CONN EVENT DATA" -Event parameters related to connected QP services: RDMA_PS_TCP. The -connection related event data is valid for RDMA_CM_EVENT_CONNECT_REQUEST -and RDMA_CM_EVENT_ESTABLISHED events, unless stated otherwise. -.IP "private_data" 12 -References any user-specified data associated with the event. The data -referenced by this field matches that specified by the remote side when -calling rdma_connect or rdma_accept. This field is NULL if the event -does not include private data. The buffer referenced by this pointer is -deallocated when calling rdma_ack_cm_event. -.IP "private_data_len" 12 -The size of the private data buffer. Users should note that the size of -the private data buffer may be larger than the amount of private data -sent by the remote side. Any additional space in the buffer will be -zeroed out. -.IP "responder_resources" 12 -The number of responder resources requested of the recipient. -This field matches the initiator depth specified by the remote node when -calling rdma_connect and rdma_accept. -.IP "initiator_depth" 12 -The maximum number of outstanding RDMA read/atomic operations -that the recipient may have outstanding. This field matches the responder -resources specified by the remote node when calling rdma_connect and -rdma_accept. -.IP "flow_control" 12 -Indicates if hardware level flow control is provided by the sender. -.IP "retry_count" 12 -For RDMA_CM_EVENT_CONNECT_REQUEST events only, indicates the number of times -that the recipient should retry send operations. -.IP "rnr_retry_count" 12 -The number of times that the recipient should retry receiver not ready (RNR) -NACK errors. -.IP "srq" 12 -Specifies if the sender is using a shared-receive queue. -.IP "qp_num" 12 -Indicates the remote QP number for the connection. -.SH "EVENT TYPES" -The following types of communication events may be reported. -.IP RDMA_CM_EVENT_ADDR_RESOLVED -Address resolution (rdma_resolve_addr) completed successfully. -.IP RDMA_CM_EVENT_ADDR_ERROR -Address resolution (rdma_resolve_addr) failed. -.IP RDMA_CM_EVENT_ROUTE_RESOLVED -Route resolution (rdma_resolve_route) completed successfully. -.IP RDMA_CM_EVENT_ROUTE_ERROR -Route resolution (rdma_resolve_route) failed. -.IP RDMA_CM_EVENT_CONNECT_REQUEST -Generated on the passive side to notify the user of a new connection request. -.IP RDMA_CM_EVENT_CONNECT_RESPONSE -Generated on the active side to notify the user of a successful response -to a connection request. It is only generated on rdma_cm_id's that do not -have a QP associated with them. -.IP RDMA_CM_EVENT_CONNECT_ERROR -Indicates that an error has occurred trying to establish or a connection. -May be generated on the active or passive side of a connection. -.IP RDMA_CM_EVENT_UNREACHABLE -Generated on the active side to notify the user that the remote server is -not reachable or unable to respond to a connection request. If this event -is generated in response to a UD QP resolution request over InfiniBand, -the event status field will contain an errno, if negative, or the status -result carried in the IB CM SIDR REP message. -.IP RDMA_CM_EVENT_REJECTED -Indicates that a connection request or response was rejected by the remote -end point. The event status field will contain the transport specific -reject reason if available. Under InfiniBand, this is the reject reason -carried in the IB CM REJ message. -.IP RDMA_CM_EVENT_ESTABLISHED -Indicates that a connection has been established with the remote end point. -.IP RDMA_CM_EVENT_DISCONNECTED -The connection has been disconnected. -.IP RDMA_CM_EVENT_DEVICE_REMOVAL -The local RDMA device associated with the rdma_cm_id has been removed. -Upon receiving this event, the user must destroy the related rdma_cm_id. -.IP RDMA_CM_EVENT_MULTICAST_JOIN -The multicast join operation (rdma_join_multicast) completed successfully. -.IP RDMA_CM_EVENT_MULTICAST_ERROR -An error either occurred joining a multicast group, or, if the group had -already been joined, on an existing group. The specified multicast group is -no longer accessible and should be rejoined, if desired. -.IP RDMA_CM_EVENT_ADDR_CHANGE -The network device associated with this ID through address resolution changed -its HW address, eg following of bonding failover. This event can serve as a -hint for applications who want the links used for their RDMA sessions to -align with the network stack. -.IP RDMA_CM_EVENT_TIMEWAIT_EXIT -The QP associated with a connection has exited its timewait state and is now -ready to be re-used. After a QP has been disconnected, it is maintained in -a timewait state to allow any in flight packets to exit the network. After -the timewait state has completed, the rdma_cm will report this event. -.SH "SEE ALSO" -rdma_ack_cm_event(3), rdma_create_event_channel(3), rdma_resolve_addr(3), -rdma_resolve_route(3), rdma_connect(3), rdma_listen(3), rdma_join_multicast(3), -rdma_destroy_id(3), rdma_event_str(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_devices.3 b/usr/rdma-core/librdmacm/man/rdma_get_devices.3 deleted file mode 100644 index be41514e8..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_devices.3 +++ /dev/null @@ -1,24 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_DEVICES" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_devices \- Get a list of RDMA devices currently available. -.SH SYNOPSIS -.B "#include " -.P -.B "struct ibv_context **" rdma_get_devices -.BI "(int *" num_devices ");" -.SH ARGUMENTS -.IP "num_devices" 12 -If non-NULL, set to the number of devices returned. -.SH "DESCRIPTION" -Return a NULL-terminated array of opened RDMA devices. Callers can use -this routine to allocate resources on specific RDMA devices that will be -shared across multiple rdma_cm_id's. -.SH "RETURN VALUE" -Returns an array of available RDMA devices, or NULL if the request -fails. On failure, errno will be set to indicate the failure reason. -.SH "NOTES" -The returned array must be released by calling rdma_free_devices. Devices -remain opened while the librdmacm is loaded. -.SH "SEE ALSO" -rdma_free_devices(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_dst_port.3 b/usr/rdma-core/librdmacm/man/rdma_get_dst_port.3 deleted file mode 100644 index 18637838d..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_dst_port.3 +++ /dev/null @@ -1,21 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_DST_PORT" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_dst_port \- Returns the remote port number of a bound rdma_cm_id. -.SH SYNOPSIS -.B "#include " -.P -.B "uint16_t" rdma_get_dst_port -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.SH "DESCRIPTION" -Returns the remote port number for an rdma_cm_id that has been bound to -a remote address. -.SH "RETURN VALUE" -Returns the 16-bit port identifier associated with the peer endpoint. If -the rdma_cm_id is not connected, the returned value is 0. -.SH "SEE ALSO" -rdma_connect(3), rdma_accept(3), rdma_get_cm_event(3), rdma_get_src_port(3), -rdma_get_local_addr(3), rdma_get_peer_addr(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_local_addr.3 b/usr/rdma-core/librdmacm/man/rdma_get_local_addr.3 deleted file mode 100644 index eeaa71420..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_local_addr.3 +++ /dev/null @@ -1,22 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_LOCAL_ADDR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_local_addr \- Returns the local IP address of a bound rdma_cm_id. -.SH SYNOPSIS -.B "#include " -.P -.B "struct sockaddr *" rdma_get_local_addr -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.SH "DESCRIPTION" -Returns the local IP address for an rdma_cm_id that has been bound to -a local device. -.SH "RETURN VALUE" -Returns a pointer to the local sockaddr address of the rdma_cm_id. If -the rdma_cm_id is not bound to an address, the contents of the sockaddr -structure will be set to all zeroes. -.SH "SEE ALSO" -rdma_bind_addr(3), rdma_resolve_addr(3), rdma_get_src_port(3), -rdma_get_dst_port(3), rdma_get_peer_addr(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_peer_addr.3 b/usr/rdma-core/librdmacm/man/rdma_get_peer_addr.3 deleted file mode 100644 index ff8ce4eab..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_peer_addr.3 +++ /dev/null @@ -1,21 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_PEER_ADDR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_peer_addr \- Returns the remote IP address of a bound rdma_cm_id. -.SH SYNOPSIS -.B "#include " -.P -.B "struct sockaddr *" rdma_get_peer_addr -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.SH "DESCRIPTION" -Returns the remote IP address associated with an rdma_cm_id. -.SH "RETURN VALUE" -Returns a pointer to the sockaddr address of the connected peer. If -the rdma_cm_id is not connected, the contents of the sockaddr -structure will be set to all zeroes. -.SH "SEE ALSO" -rdma_resolve_addr(3), rdma_get_src_port(3), rdma_get_dst_port(3), -rdma_get_local_addr(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_recv_comp.3 b/usr/rdma-core/librdmacm/man/rdma_get_recv_comp.3 deleted file mode 100644 index 6894e5d96..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_recv_comp.3 +++ /dev/null @@ -1,32 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_RECV_COMP" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_recv_comp \- retrieves a completed receive request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_get_recv_comp -.BI "(struct rdma_cm_id *" id "," -.BI "struct ibv_wc *" wc ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier to check for completions. -.IP "wc" 12 -A reference to a work completion structure to fill in. -.SH "DESCRIPTION" -Retrieves a completed work request for a receive -operation. Information about the completed request is returned through -the wc parameter, with the wr_id set to the context of the request. For -details on the work completion structure, see ibv_poll_cq. -.SH "RETURN VALUE" -Returns the number of returned completions (0 or 1) on success, or -1 on error. -If an error occurs, errno will be set to indicate the failure reason. -.SH "NOTES" -This calls polls the receive completion queue associated with an rdma_cm_id. -If a completion is not found, the call blocks until a request completes. -This call should only be used on rdma_cm_id's that do not share CQs -with other rdma_cm_id's, and maintain separate CQs for sends and receive -completions. -.SH "SEE ALSO" -rdma_cm(7), ibv_poll_cq(3), rdma_get_send_comp(3), -rdma_post_send(3), rdma_post_read(3), rdma_post_write(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_request.3 b/usr/rdma-core/librdmacm/man/rdma_get_request.3 deleted file mode 100644 index 86cb6102d..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_request.3 +++ /dev/null @@ -1,35 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_REQUEST" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_request \- Retrieves the next pending connection request event. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_get_request -.BI "(struct rdma_cm_id *" listen "," -.BI "struct rdma_cm_id **" id ");" -.SH ARGUMENTS -.IP "listen" 12 -Listening rdma_cm_id. -.IP "id" 12 -rdma_cm_id associated with the new connection. -.SH "DESCRIPTION" -Retrieves a connection request event. If no requests are pending, -the call will block until an event is received. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -This call may only be used on listening rdma_cm_id's operating -synchronously. On success, a new rdma_cm_id representing the -connection request will be returned to the user. The new rdma_cm_id -will reference event information associated with the request until -the user calls rdma_reject, rdma_accept, or rdma_destroy_id on the -newly created identifier. For a description of the event data, -see rdma_get_cm_event. -.P -If QP attributes are associated with the listening endpoint, the -returned rdma_cm_id will also reference an allocated QP. -.SH "SEE ALSO" -rdma_get_cm_event(3), rdma_accept(3), rdma_reject(3), -rdma_connect(3), rdma_listen(3), rdma_destroy_id(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_send_comp.3 b/usr/rdma-core/librdmacm/man/rdma_get_send_comp.3 deleted file mode 100644 index 5085ddb7a..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_send_comp.3 +++ /dev/null @@ -1,32 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_SEND_COMP" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_send_comp \- retrieves a completed send, read, or write request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_get_send_comp -.BI "(struct rdma_cm_id *" id "," -.BI "struct ibv_wc *" wc ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier to check for completions. -.IP "wc" 12 -A reference to a work completion structure to fill in. -.SH "DESCRIPTION" -Retrieves a completed work request for a send, RDMA read, or RDMA write -operation. Information about the completed request is returned through -the wc parameter, with the wr_id set to the context of the request. For -details on the work completion structure, see ibv_poll_cq. -.SH "RETURN VALUE" -Returns the number of returned completions (0 or 1) on success, or -1 on error. -If an error occurs, errno will be set to indicate the failure reason. -.SH "NOTES" -This calls polls the send completion queue associated with an rdma_cm_id. -If a completion is not found, the call blocks until a request completes. -This call should only be used on rdma_cm_id's that do not share CQs -with other rdma_cm_id's, and maintain separate CQs for sends and receive -completions. -.SH "SEE ALSO" -rdma_cm(7), ibv_poll_cq(3), rdma_get_recv_comp(3), -rdma_post_send(3), rdma_post_read(3), rdma_post_write(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_get_src_port.3 b/usr/rdma-core/librdmacm/man/rdma_get_src_port.3 deleted file mode 100644 index 1e36a92cd..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_get_src_port.3 +++ /dev/null @@ -1,21 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GET_SRC_PORT" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_get_src_port \- Returns the local port number of a bound rdma_cm_id. -.SH SYNOPSIS -.B "#include " -.P -.B "uint16_t" rdma_get_src_port -.BI "(struct rdma_cm_id *" id ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.SH "DESCRIPTION" -Returns the local port number for an rdma_cm_id that has been bound to -a local address. -.SH "RETURN VALUE" -Returns the 16-bit port identifier associated with the local endpoint. If -the rdma_cm_id is not bound to a port, the returned value is 0. -.SH "SEE ALSO" -rdma_bind_addr(3), rdma_resolve_addr(3), rdma_get_dst_port(3), -rdma_get_local_addr(3), rdma_get_peer_addr(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_getaddrinfo.3 b/usr/rdma-core/librdmacm/man/rdma_getaddrinfo.3 deleted file mode 100644 index 3ad639360..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_getaddrinfo.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_GETADDRINFO" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_getaddrinfo \- Provides transport independent address translation. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_getaddrinfo -.BI "(const char *" node "," -.BI "const char *" service "," -.BI "const struct rdma_addrinfo *" hints "," -.BI "struct rdma_addrinfo **" res ");" -.SH ARGUMENTS -.IP "node" 12 -Optional, name, dotted-decimal IPv4, or IPv6 hex address to resolve. -.IP "service" 12 -Service name or port number of address. -.IP "hints" 12 -Reference to an rdma_addrinfo structure containing hints about the type -of service the caller supports. -.IP "res" 12 -A pointer to a linked list of rdma_addrinfo structures containing response -information. -.SH "DESCRIPTION" -Resolves the destination node and service address and returns -information needed to establish communication. Provides the -RDMA functional equivalent to getaddrinfo. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Either node, service, or hints must be provided. If hints are provided, the -operation will be controlled by hints.ai_flags. If RAI_PASSIVE is -specified, the call will resolve address information for use on the -passive side of a connection. -If node is provided, rdma_getaddrinfo will attempt to resolve the RDMA address, -route, and connection data to the given node. The hints parameter, if provided, -may be used to control the resulting output as indicated below. -If node is not given, rdma_getaddrinfo will attempt to resolve the RDMA addressing -information based on the hints.ai_src_addr, hints.ai_dst_addr, or hints.ai_route. -.SH "rdma_addrinfo" -.IP "ai_flags" 12 -Hint flags that control the operation. Supported flags are: -.IP "RAI_PASSIVE" 12 -Indicates that the results will be used on the passive/listening -side of a connection. -.IP "RAI_NUMERICHOST" 12 -If specified, then the node parameter, if provided, must be a numerical -network address. This flag suppresses any lengthy address resolution. -.IP "RAI_NOROUTE" 12 -If set, this flag suppresses any lengthy route resolution. -.IP "RAI_FAMILY" 12 -If set, the ai_family setting should be used as an input hint for interpretting -the node parameter. -.IP "ai_family" 12 -Address family for the source and destination address. Supported families -are: AF_INET, AF_INET6, and AF_IB. -.IP "ai_qp_type" 12 -Indicates the type of RDMA QP used for communication. Supported types are: -IBV_UD (unreliable datagram) and IBV_RC (reliable connected). -.IP "ai_port_space" 12 -RDMA port space in use. Supported values are: RDMA_PS_UDP, RDMA_PS_TCP, -and RDMA_PS_IB. -.IP "ai_src_len" 12 -The length of the source address referenced by ai_src_addr. This will be 0 -if an appropriate source address could not be discovered for a given -destination. -.IP "ai_dst_len" 12 -The length of the destination address referenced by ai_dst_addr. This -will be 0 if the RAI_PASSIVE flag was specified as part of the hints. -.IP "ai_src_addr" 12 -If provided, the address for the local RDMA device. -.IP "ai_dst_addr" 12 -If provided, the address for the destination RDMA device. -.IP "ai_src_canonname" 12 -The canonical for the source. -.IP "ai_dst_canonname" 12 -The canonical for the destination. -.IP "ai_route_len" 12 -Size of the routing information buffer referenced by ai_route. This will -be 0 if the underlying transport does not require routing data, or none -could be resolved. -.IP "ai_route" 12 -Routing information for RDMA transports that require routing data as part -of connection establishment. The format of the routing data depends on -the underlying transport. If Infiniband transports are -used, ai_route will reference an array of struct ibv_path_data on output, -if routing data is available. Routing paths may be restricted by setting -desired routing data fields on input to rdma_getaddrinfo. For Infiniband, -hints.ai_route may reference an array of struct ibv_path_record or -struct ibv_path_data on input. -.IP "ai_connect_len" 12 -Size of connection information referenced by ai_connect. This will be -0 if the underlying transport does not require additional connection -information. -.IP "ai_connect" 12 -Data exchanged as part of the connection establishment process. If provided, -ai_connect data must be transferred as private data, with any user supplied -private data following it. -.IP "ai_next" 12 -Pointer to the next rdma_addrinfo structure in the list. Will be NULL -if no more structures exist. -.SH "SEE ALSO" -rdma_create_id(3), rdma_resolve_route(3), rdma_connect(3), rdma_create_qp(3), -rdma_bind_addr(3), rdma_create_ep(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_join_multicast.3 b/usr/rdma-core/librdmacm/man/rdma_join_multicast.3 deleted file mode 100644 index 4e52e859e..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_join_multicast.3 +++ /dev/null @@ -1,39 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_JOIN_MULTICAST" 3 "2008-01-02" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_join_multicast \- Joins a multicast group. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_join_multicast -.BI "(struct rdma_cm_id *" id "," -.BI "struct sockaddr *" addr "," -.BI "void *" context ");" -.SH ARGUMENTS -.IP "id" 12 -Communication identifier associated with the request. -.IP "addr" 12 -Multicast address identifying the group to join. -.IP "context" 12 -User-defined context associated with the join request. -.SH "DESCRIPTION" -Joins a multicast group and attaches an associated QP to the group. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Before joining a multicast group, the rdma_cm_id must be bound to -an RDMA device by calling rdma_bind_addr or rdma_resolve_addr. Use of -rdma_resolve_addr requires the local routing tables to resolve the -multicast address to an RDMA device, unless a specific source address -is provided. The user must call rdma_leave_multicast to leave the -multicast group and release any multicast resources. After the join -operation completes, if a QP is associated with the rdma_cm_id, -it is automatically attached to the multicast group when the multicast -event is retrieved by the user. Otherwise, the user is responsible -for calling ibv_attach_mcast to bind the QP to the multicast group. -The join context is returned to the user through the private_data -field in the rdma_cm_event. -.SH "SEE ALSO" -rdma_leave_multicast(3), rdma_bind_addr(3), rdma_resolve_addr(3), rdma_create_qp(3), -rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_leave_multicast.3 b/usr/rdma-core/librdmacm/man/rdma_leave_multicast.3 deleted file mode 100644 index 9e112d31a..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_leave_multicast.3 +++ /dev/null @@ -1,28 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_LEAVE_MULTICAST" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_leave_multicast \- Leaves a multicast group. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_leave_multicast -.BI "(struct rdma_cm_id *" id "," -.BI "struct sockaddr *" addr ");" -.SH ARGUMENTS -.IP "id" 12 -Communication identifier associated with the request. -.IP "addr" 12 -Multicast address identifying the group to leave. -.SH "DESCRIPTION" -Leaves a multicast group and detaches an associated QP from the group. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Calling this function before a group has been fully joined results in -canceling the join operation. Users should be aware that messages -received from the multicast group may stilled be queued for -completion processing immediately after leaving a multicast group. -Destroying an rdma_cm_id will automatically leave all multicast groups. -.SH "SEE ALSO" -rdma_join_multicast(3), rdma_destroy_qp(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_listen.3 b/usr/rdma-core/librdmacm/man/rdma_listen.3 deleted file mode 100644 index 78fd27083..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_listen.3 +++ /dev/null @@ -1,32 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_LISTEN" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_listen \- Listen for incoming connection requests. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_listen -.BI "(struct rdma_cm_id *" id "," -.BI "int " backlog ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "backlog" 12 -backlog of incoming connection requests. -.SH "DESCRIPTION" -Initiates a listen for incoming connection requests or datagram service -lookup. The listen will be restricted to the locally bound source -address. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Users must have bound the rdma_cm_id to a local address by calling -rdma_bind_addr before calling this routine. If the rdma_cm_id is -bound to a specific IP address, the listen will be restricted to that -address and the associated RDMA device. If the rdma_cm_id is bound -to an RDMA port number only, the listen will occur across all RDMA -devices. -.SH "SEE ALSO" -rdma_cm(7), rdma_bind_addr(3), rdma_connect(3), rdma_accept(3), rdma_reject(3), -rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_migrate_id.3 b/usr/rdma-core/librdmacm/man/rdma_migrate_id.3 deleted file mode 100644 index f0f7bcee0..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_migrate_id.3 +++ /dev/null @@ -1,35 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_MIGRATE_ID" 3 "2007-11-13" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_migrate_id \- Move a communication identifier to a different event channel. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_migrate_id -.BI "(struct rdma_cm_id *" id "," -.BI "struct rdma_event_channel *" channel ");" -.SH ARGUMENTS -.IP "id" 12 -An existing communication identifier to migrate. -.IP "channel" 12 -The communication channel that events associated with the -allocated rdma_cm_id will be reported on. May be NULL. -.SH "DESCRIPTION" -Migrates a communication identifier to a different event channel. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -This routine migrates a communication identifier to the specified event -channel and moves any pending events associated with the rdma_cm_id -to the new channel. Users should not poll for events on the -rdma_cm_id's current event channel or invoke other routines on the -rdma_cm_id while migrating between channels. This call will block while -there are any unacknowledged events on the current event channel. -.P -If the channel parameter is NULL, the specified rdma_cm_id will be -placed into synchronous operation mode. All calls on the id -will block until the operation completes. -.SH "SEE ALSO" -rdma_cm(7), rdma_create_event_channel(3), rdma_create_id(3), -rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_notify.3 b/usr/rdma-core/librdmacm/man/rdma_notify.3 deleted file mode 100644 index c80733a17..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_notify.3 +++ /dev/null @@ -1,39 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_NOTIFY" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_notify \- Notifies the librdmacm of an asynchronous event. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_notify -.BI "(struct rdma_cm_id *" id "," -.BI "enum ibv_event_type " event ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "event" 12 -Asynchronous event. -.SH "DESCRIPTION" -Used to notify the librdmacm of asynchronous events that have occurred -on a QP associated with the rdma_cm_id. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. If errno is set to EISCONN -(transport endpoint is already connected), this indicates that the -the underlying communication manager established the connection before -the call to rdma_notify could be processed. In this case, the error may -safely be ignored. -.SH "NOTES" -Asynchronous events that occur on a QP are reported through the user's -device event handler. This routine is used to notify the librdmacm of -communication events. In most cases, use of this routine is not -necessary, however if connection establishment is done out of band -(such as done through Infiniband), it's possible to receive data on a -QP that is not yet considered connected. This routine forces the -connection into an established state in this case in order to handle -the rare situation where the connection never forms on its own. -Calling this routine ensures the delivery of the RDMA_CM_EVENT_ESTABLISHED -event to the application. -Events that should be reported to the CM are: IB_EVENT_COMM_EST. -.SH "SEE ALSO" -rdma_connect(3), rdma_accept(3), rdma_listen(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_read.3 b/usr/rdma-core/librdmacm/man/rdma_post_read.3 deleted file mode 100644 index 11b3e09e1..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_read.3 +++ /dev/null @@ -1,56 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_READ" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_read \- post an RDMA read work request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_read -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "void *" addr "," -.BI "size_t " length "," -.BI "struct ibv_mr *" mr "," -.BI "int " flags "," -.BI "uint64_t " remote_addr "," -.BI "uint32_t " rkey ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the request -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "addr" 12 -The address of the local destination of the read request. -.IP "length" 12 -The length of the read operation. -.IP "mr" 12 -Registered memory region associated with the local buffer. -.IP "flags" 12 -Optional flags used to control the read operation. -.IP "remote_addr" 12 -The address of the remote registered memory to read from. -.IP "rkey" 12 -The registered memory key associated with the remote address. -.SH "DESCRIPTION" -Posts a work request to the send queue of the queue pair associated -with the rdma_cm_id. The contents of the remote memory region will be -read into the local data buffer. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -For a list of supported flags, see ibv_post_send. -Both the remote and local data buffers must have been registered -before the read is issued, and the buffers must remain registered -until the read completes. -.P -Read operations may not be posted to an rdma_cm_id or the corresponding -queue pair until it has been connected. -.P -The user-defined context associated with the read request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_connect(3), rdma_accept(3), -ibv_post_send(3), rdma_post_readv(3), rdma_reg_read(3), rdma_reg_msgs(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_readv.3 b/usr/rdma-core/librdmacm/man/rdma_post_readv.3 deleted file mode 100644 index 95e415595..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_readv.3 +++ /dev/null @@ -1,53 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_READV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_readv \- post an RDMA read work request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_readv -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "struct ibv_sge *" sgl "," -.BI "int " nsge "," -.BI "int " flags "," -.BI "uint64_t " remote_addr "," -.BI "uint32_t " rkey ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the request -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "sgl" 12 -A scatter-gather list of the destination buffers of the read. -.IP "nsge" 12 -The number of scatter-gather array entries. -.IP "flags" 12 -Optional flags used to control the read operation. -.IP "remote_addr" 12 -The address of the remote registered memory to read from. -.IP "rkey" 12 -The registered memory key associated with the remote address. -.SH "DESCRIPTION" -Posts a work request to the send queue of the queue pair associated -with the rdma_cm_id. The contents of the remote memory region will be -read into the local data buffers. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -For a list of supported flags, see ibv_post_send. -Both the remote and local data buffers must have been registered -before the read is issued, and the buffers must remain registered -until the read completes. -.P -Read operations may not be posted to an rdma_cm_id or the corresponding -queue pair until it has been connected. -.P -The user-defined context associated with the read request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_connect(3), rdma_accept(3), -ibv_post_send(3), rdma_post_read(3), rdma_reg_read(3), rdma_reg_msgs(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_recv.3 b/usr/rdma-core/librdmacm/man/rdma_post_recv.3 deleted file mode 100644 index 5e0530d46..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_recv.3 +++ /dev/null @@ -1,51 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_RECV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_recv \- post a work request to receive an incoming message. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_recv -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "void *" addr "," -.BI "size_t " length "," -.BI "struct ibv_mr *" mr ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the message buffer -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "addr" 12 -The address of the memory buffer to post. -.IP "length" 12 -The length of the memory buffer. -.IP "mr" 12 -A registered memory region associated with the posted buffer. -.SH "DESCRIPTION" -Posts a work request to the receive queue of the queue pair associated -with the rdma_cm_id. The posted buffer will be queued to receive an incoming -message sent by the remote peer. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -The user is responsible for ensuring that a receive buffer is posted -and large enough to contain all sent data before the peer posts the -corresponding send message. The message buffer must have been registered -before being posted, with the mr parameter referencing the registration. -The buffer must remain registered until the receive completes. -.P -Messages may be posted to an rdma_cm_id only after a queue pair has -been associated with it. A queue pair is bound to an rdma_cm_id after -calling rdma_create_ep or rdma_create_qp, if the rdma_cm_id is allocated -using rdma_create_id. -.P -The user-defined context associated with the receive request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_create_id(3), rdma_create_ep(3), rdma_create_qp(3), -rdma_reg_read(3), ibv_reg_mr(3), ibv_dereg_mr(3), -rdma_post_recvv(3), rdma_post_send(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_recvv.3 b/usr/rdma-core/librdmacm/man/rdma_post_recvv.3 deleted file mode 100644 index bd03930c8..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_recvv.3 +++ /dev/null @@ -1,48 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_RECVV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_recvv \- post a work request to receive incoming messages. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_recvv -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "struct ibv_sge *" sgl "," -.BI "int " nsge ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the message buffer(s) -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "sgl" 12 -A scatter-gather list of memory buffers posted as a single request. -.IP "nsge" 12 -The number of scatter-gather entries in the sgl array. -.SH "DESCRIPTION" -Posts a single work request to the receive queue of the queue pair associated -with the rdma_cm_id. The posted buffers will be queued to receive an -incoming message sent by the remote peer. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -The user is responsible for ensuring that the receive is posted, -and the total buffer space is large enough to contain all sent data -before the peer posts the corresponding send message. The message buffers -must have been registered before being posted, and the buffers must -remain registered until the receive completes. -.P -Messages may be posted to an rdma_cm_id only after a queue pair has -been associated with it. A queue pair is bound to an rdma_cm_id after -calling rdma_create_ep or rdma_create_qp, if the rdma_cm_id is allocated -using rdma_create_id. -.P -The user-defined context associated with the receive request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_create_id(3), rdma_create_ep(3), rdma_create_qp(3), -rdma_reg_read(3), ibv_reg_mr(3), ibv_dereg_mr(3), -rdma_post_recv(3), rdma_post_send(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_send.3 b/usr/rdma-core/librdmacm/man/rdma_post_send.3 deleted file mode 100644 index 5d0e6d603..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_send.3 +++ /dev/null @@ -1,52 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_SEND" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_send \- post a work request to send a message. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_send -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "void *" addr "," -.BI "size_t " length "," -.BI "struct ibv_mr *" mr "," -.BI "int " flags ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the message buffer -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "addr" 12 -The address of the memory buffer to post. -.IP "length" 12 -The length of the memory buffer. -.IP "mr" 12 -Optional registered memory region associated with the posted buffer. -.IP "flags" 12 -Optional flags used to control the send operation. -.SH "DESCRIPTION" -Posts a work request to the send queue of the queue pair associated -with the rdma_cm_id. The contents of the posted buffer will be sent -to the remote peer of a connection. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -The user is responsible for ensuring that the remote peer has queued a -receive request before issuing the send operations. For a list of -supported flags, see ibv_post_send. Unless the send request is using -inline data, the message buffer must have been registered -before being posted, with the mr parameter referencing the registration. -The buffer must remain registered until the send completes. -.P -Send operations may not be posted to an rdma_cm_id or the corresponding -queue pair until it has been connected. -.P -The user-defined context associated with the send request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_connect(3), rdma_accept(3), -ibv_post_send(3), rdma_post_sendv(3), rdma_post_recv(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_sendv.3 b/usr/rdma-core/librdmacm/man/rdma_post_sendv.3 deleted file mode 100644 index 9b347b1f4..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_sendv.3 +++ /dev/null @@ -1,49 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_SENDV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_sendv \- post a work request to send a message. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_sendv -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "struct ibv_sge *" slg "," -.BI "int " nsge "," -.BI "int " flags ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the message buffer -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "slg" 12 -A scatter-gather list of memory buffers posted as a single request. -.IP "nsge" 12 -The number of scatter-gather entries in the slg array. -.IP "flags" 12 -Optional flags used to control the send operation. -.SH "DESCRIPTION" -Posts a work request to the send queue of the queue pair associated -with the rdma_cm_id. The contents of the posted buffers will be sent -to the remote peer of a connection. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -The user is responsible for ensuring that the remote peer has queued a -receive request before issuing the send operations. For a list of -supported flags, see ibv_post_send. Unless the send request is using -inline data, the message buffers must have been registered -before being posted, and the buffers must remain registered -until the send completes. -.P -Send operations may not be posted to an rdma_cm_id or the corresponding -queue pair until it has been connected. -.P -The user-defined context associated with the send request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_connect(3), rdma_accept(3), -ibv_post_send(3), rdma_post_send(3), rdma_post_recv(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_ud_send.3 b/usr/rdma-core/librdmacm/man/rdma_post_ud_send.3 deleted file mode 100644 index 0fcce79e1..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_ud_send.3 +++ /dev/null @@ -1,55 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_UD_SEND" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_ud_send \- post a work request to send a datagram. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_ud_send -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "void *" addr "," -.BI "size_t " length "," -.BI "struct ibv_mr *" mr "," -.BI "int " flags "," -.BI "struct ibv_ah *" ah "," -.BI "uint32_t " remote_qpn ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the message buffer -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "addr" 12 -The address of the memory buffer to post. -.IP "length" 12 -The length of the memory buffer. -.IP "mr" 12 -Optional registered memory region associated with the posted buffer. -.IP "flags" 12 -Optional flags used to control the send operation. -.IP "ah" 12 -An address handle describing the address of the remote node. -.IP "remote_qpn" 12 -The number of the destination queue pair. -.SH "DESCRIPTION" -Posts a work request to the send queue of the queue pair associated -with the rdma_cm_id. The contents of the posted buffer will be sent -to the specified destination queue pair. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -The user is responsible for ensuring that the destination queue pair -has queued a receive request before issuing the send operations. For a list of -supported flags, see ibv_post_send. Unless the send request is using -inline data, the message buffer must have been registered -before being posted, with the mr parameter referencing the registration. -The buffer must remain registered until the send completes. -.P -The user-defined context associated with the send request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_connect(3), rdma_accept(3), rdma_reg_msgs(3) -ibv_post_send(3), rdma_post_recv(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_write.3 b/usr/rdma-core/librdmacm/man/rdma_post_write.3 deleted file mode 100644 index 62a1e49c3..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_write.3 +++ /dev/null @@ -1,56 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_WRITE" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_write \- post an RDMA write work request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_write -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "void *" addr "," -.BI "size_t " length "," -.BI "struct ibv_mr *" mr "," -.BI "int " flags "," -.BI "uint64_t " remote_addr "," -.BI "uint32_t " rkey ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the request -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "addr" 12 -The local address of the source of the write request. -.IP "length" 12 -The length of the write operation. -.IP "mr" 12 -Optional memory region associated with the local buffer. -.IP "flags" 12 -Optional flags used to control the write operation. -.IP "remote_addr" 12 -The address of the remote registered memory to write into. -.IP "rkey" 12 -The registered memory key associated with the remote address. -.SH "DESCRIPTION" -Posts a work request to the send queue of the queue pair associated -with the rdma_cm_id. The contents of the local data buffer will be -written into the remote memory region. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -For a list of supported flags, see ibv_post_send. Unless inline -data is specified, the local data buffer must have been registered -before the write is issued, and the buffer must remain registered -until the write completes. The remote buffer must always be registered. -.P -Write operations may not be posted to an rdma_cm_id or the corresponding -queue pair until it has been connected. -.P -The user-defined context associated with the write request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_connect(3), rdma_accept(3), -ibv_post_send(3), rdma_post_writev(3), rdma_reg_write(3), rdma_reg_msgs(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_post_writev.3 b/usr/rdma-core/librdmacm/man/rdma_post_writev.3 deleted file mode 100644 index 22ee0fe12..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_post_writev.3 +++ /dev/null @@ -1,53 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_POST_WRITEV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_post_writev \- post an RDMA write work request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_post_writev -.BI "(struct rdma_cm_id *" id "," -.BI "void *" context "," -.BI "struct ibv_sge *" sgl "," -.BI "int " nsge "," -.BI "int " flags "," -.BI "uint64_t " remote_addr "," -.BI "uint32_t " rkey ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the request -will be posted. -.IP "context" 12 -User-defined context associated with the request. -.IP "sgl" 12 -A scatter-gather list of the source buffers of the write. -.IP "nsge" 12 -The number of scatter-gather array entries. -.IP "flags" 12 -Optional flags used to control the write operation. -.IP "remote_addr" 12 -The address of the remote registered memory to write into. -.IP "rkey" 12 -The registered memory key associated with the remote address. -.SH "DESCRIPTION" -Posts a work request to the send queue of the queue pair associated -with the rdma_cm_id. The contents of the local data buffers will be -written into the remote memory region. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -For a list of supported flags, see ibv_post_send. Unless inline -data is specified, the local data buffers must have been registered -before the write is issued, and the buffers must remain registered -until the write completes. The remote buffers must always be registered. -.P -Write operations may not be posted to an rdma_cm_id or the corresponding -queue pair until it has been connected. -.P -The user-defined context associated with the write request will be -returned to the user through the work completion wr_id, work request -identifier, field. -.SH "SEE ALSO" -rdma_cm(7), rdma_connect(3), rdma_accept(3), -ibv_post_send(3), rdma_post_write(3), rdma_reg_write(3), rdma_reg_msgs(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_reg_msgs.3 b/usr/rdma-core/librdmacm/man/rdma_reg_msgs.3 deleted file mode 100644 index 48c75b309..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_reg_msgs.3 +++ /dev/null @@ -1,43 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_REG_MSGS" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_reg_msgs \- register data buffer(s) for sending or receiving messages. -.SH SYNOPSIS -.B "#include " -.P -.B "struct ibv_mr *" rdma_reg_msgs -.BI "(struct rdma_cm_id *" id "," -.BI "void *" addr "," -.BI "size_t " length ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the message buffer(s) -will be used. -.IP "addr" 12 -The address of the memory buffer(s) to register. -.IP "length" 12 -The total length of the memory to register. -.SH "DESCRIPTION" -Registers an array of memory buffers used for sending and receiving -messages or for RDMA operations. Memory buffers registered using -rdma_reg_msgs may be posted to an rdma_cm_id using -rdma_post_send or rdma_post_recv, or specified as the target of an RDMA -read operation or the source of an RDMA write request. -.SH "RETURN VALUE" -Returns a reference to the registered memory region on success, or NULL on -error. If an error occurs, errno will be set to indicate the failure reason. -.SH "NOTES" -rdma_reg_msgs is used to register an array of data buffers -that will be used send and/or receive messages on a queue pair associated with -an rdma_cm_id. The memory buffer is registered with the proteection -domain associated with the idenfier. The start of the data buffer array -is specified through the addr parameter, and the total size of the array -is given by length. -.P -All data buffers should be registered before being posted as a work request. -Users must deregister all registered memory by calling rdma_dereg_mr. -.SH "SEE ALSO" -rdma_cm(7), rdma_create_id(3), rdma_create_ep(3), -rdma_reg_read(3), rdma_reg_write(3), -ibv_reg_mr(3), ibv_dereg_mr(3), rdma_post_send(3), rdma_post_recv(3), -rdma_post_read(3), rdma_post_readv(3), rdma_post_write(3), rdma_post_writev(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_reg_read.3 b/usr/rdma-core/librdmacm/man/rdma_reg_read.3 deleted file mode 100644 index 07813e828..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_reg_read.3 +++ /dev/null @@ -1,42 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_REG_READ" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_reg_read \- register data buffer(s) for remote RDMA read access. -.SH SYNOPSIS -.B "#include " -.P -.B "struct ibv_mr *" rdma_reg_read -.BI "(struct rdma_cm_id *" id "," -.BI "void *" addr "," -.BI "size_t " length ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the message buffer(s) -will be used. -.IP "addr" 12 -The address of the memory buffer(s) to register. -.IP "length" 12 -The total length of the memory to register. -.SH "DESCRIPTION" -Registers a memory buffer that will be accessed by a remote RDMA read -operation. Memory buffers registered using rdma_reg_read may be -targeted in an RDMA read request, allowing the buffer to be -specified on the remote side of an RDMA connection as the remote_addr -of rdma_post_read, or similar call. -.SH "RETURN VALUE" -Returns a reference to the registered memory region on success, or NULL on -error. If an error occurs, errno will be set to indicate the failure reason. -.SH "NOTES" -rdma_reg_read is used to register a data buffer that will be the -target of an RDMA read operation on a queue pair associated with -an rdma_cm_id. The memory buffer is registered with the proteection -domain associated with the idenfier. The start of the data buffer -is specified through the addr parameter, and the total size of the buffer -is given by length. -.P -All data buffers should be registered before being posted as a work request. -Users must deregister all registered memory by calling rdma_dereg_mr. -.SH "SEE ALSO" -rdma_cm(7), rdma_create_id(3), rdma_create_ep(3), -rdma_reg_msgs(3), rdma_reg_write(3), -ibv_reg_mr(3), ibv_dereg_mr(3), rdma_post_read(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_reg_write.3 b/usr/rdma-core/librdmacm/man/rdma_reg_write.3 deleted file mode 100644 index 2be3cc0ce..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_reg_write.3 +++ /dev/null @@ -1,42 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_REG_WRITE" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_reg_write \- register data buffer(s) for remote RDMA write access. -.SH SYNOPSIS -.B "#include " -.P -.B "struct ibv_mr *" rdma_reg_write -.BI "(struct rdma_cm_id *" id "," -.BI "void *" addr "," -.BI "size_t " length ");" -.SH ARGUMENTS -.IP "id" 12 -A reference to a communication identifier where the message buffer(s) -will be used. -.IP "addr" 12 -The address of the memory buffer(s) to register. -.IP "length" 12 -The total length of the memory to register. -.SH "DESCRIPTION" -Registers a memory buffer that will be accessed by a remote RDMA write -operation. Memory buffers registered using rdma_reg_write may be -targeted in an RDMA write request, allowing the buffer to be -specified on the remote side of an RDMA connection as the remote_addr -of rdma_post_write, or similar call. -.SH "RETURN VALUE" -Returns a reference to the registered memory region on success, or NULL on -error. If an error occurs, errno will be set to indicate the failure reason. -.SH "NOTES" -rdma_reg_write is used to register a data buffer that will be the -target of an RDMA write operation on a queue pair associated with -an rdma_cm_id. The memory buffer is registered with the proteection -domain associated with the idenfier. The start of the data buffer -is specified through the addr parameter, and the total size of the buffer -is given by length. -.P -All data buffers should be registered before being posted as a work request. -Users must deregister all registered memory by calling rdma_dereg_mr. -.SH "SEE ALSO" -rdma_cm(7), rdma_create_id(3), rdma_create_ep(3), -rdma_reg_msgs(3), rdma_reg_read(3), -ibv_reg_mr(3), ibv_dereg_mr(3), rdma_post_write(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_reject.3 b/usr/rdma-core/librdmacm/man/rdma_reject.3 deleted file mode 100644 index 53f038fcc..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_reject.3 +++ /dev/null @@ -1,33 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_REJECT" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_reject \- Called to reject a connection request. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_reject -.BI "(struct rdma_cm_id *" id "," -.BI "const void *" private_data "," -.BI "uint8_t " private_data_len ");" -.SH ARGUMENTS -.IP "id" 12 -Connection identifier associated with the request. -.IP "private_data" 12 -Optional private data to send with the reject message. -.IP "private_data_len" 12 -Specifies the size of the user-controlled data buffer. Note that the actual -amount of data transferred to the remote side is transport dependent and may -be larger than that requested. -.SH "DESCRIPTION" -Called from the listening side to reject a connection or datagram -service lookup request. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -After receiving a connection request event, a user may call rdma_reject -to reject the request. If the underlying RDMA transport supports -private data in the reject message, the specified data will be passed to -the remote side. -.SH "SEE ALSO" -rdma_listen(3), rdma_accept(3), rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_resolve_addr.3 b/usr/rdma-core/librdmacm/man/rdma_resolve_addr.3 deleted file mode 100644 index ce6dcd6a8..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_resolve_addr.3 +++ /dev/null @@ -1,47 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_RESOLVE_ADDR" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_resolve_addr \- Resolve destination and optional source addresses. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_resolve_addr -.BI "(struct rdma_cm_id *" id "," -.BI "struct sockaddr *" src_addr "," -.BI "struct sockaddr *" dst_addr "," -.BI "int " timeout_ms ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "src_addr" 12 -Source address information. This parameter may be NULL. -.IP "dst_addr" 12 -Destination address information. -.IP "timeout_ms" 12 -Time to wait for resolution to complete. -.SH "DESCRIPTION" -Resolve destination and optional source addresses from IP addresses -to an RDMA address. If successful, the specified rdma_cm_id will -be bound to a local device. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -This call is used to map a given destination IP address to a usable RDMA -address. The IP to RDMA address mapping is done using the local routing -tables, or via ARP. -If a source address is given, the rdma_cm_id is bound to that -address, the same as if rdma_bind_addr were called. If no source -address is given, and the rdma_cm_id has not yet been bound to a device, -then the rdma_cm_id will be bound to a source address based on the -local routing tables. After this call, the rdma_cm_id will be bound to -an RDMA device. This call is typically made from the active side of a -connection before calling rdma_resolve_route and rdma_connect. -.SH "INFINIBAND SPECIFIC" -This call maps the destination and, if given, source IP addresses to GIDs. -In order to perform the mapping, IPoIB must be running on both the local -and remote nodes. -.SH "SEE ALSO" -rdma_create_id(3), rdma_resolve_route(3), rdma_connect(3), rdma_create_qp(3), -rdma_get_cm_event(3), rdma_bind_addr(3), rdma_get_src_port(3), -rdma_get_dst_port(3), rdma_get_local_addr(3), rdma_get_peer_addr(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_resolve_route.3 b/usr/rdma-core/librdmacm/man/rdma_resolve_route.3 deleted file mode 100644 index 114f666dc..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_resolve_route.3 +++ /dev/null @@ -1,29 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_RESOLVE_ROUTE" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_resolve_route \- Resolve the route information needed to establish a connection. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_resolve_route -.BI "(struct rdma_cm_id *" id "," -.BI "int " timeout_ms ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "timeout_ms" 12 -Time to wait for resolution to complete. -.SH "DESCRIPTION" -Resolves an RDMA route to the destination address in order to establish -a connection. The destination address must have already been resolved -by calling rdma_resolve_addr. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -This is called on the client side of a connection after calling -rdma_resolve_addr, but before calling rdma_connect. -.SH "INFINIBAND SPECIFIC" -This call obtains a path record that is used by the connection. -.SH "SEE ALSO" -rdma_resolve_addr(3), rdma_connect(3), rdma_get_cm_event(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_server.1 b/usr/rdma-core/librdmacm/man/rdma_server.1 deleted file mode 100644 index ada256498..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_server.1 +++ /dev/null @@ -1,27 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_SERVER" 1 "2010-07-19" "librdmacm" "librdmacm" librdmacm -.SH NAME -rdma_server \- simple RDMA CM connection and ping-pong test. -.SH SYNOPSIS -.sp -.nf -\fIrdma_server\fR [-p port] -.fi -.SH "DESCRIPTION" -Uses synchronous librdmam calls to establish an RDMA connections between -two nodes. This example is intended to provide a very simple coding -example of how to use RDMA. -.SH "OPTIONS" -.TP -\-p port -Changes the port number that the server listens on. By default the server -listens on port 7471. -.SH "NOTES" -Basic usage is to start rdma_server, then connect to the server using the -rdma_client program. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7), udaddy(1), mckey(1), rping(1), rdma_client(1) diff --git a/usr/rdma-core/librdmacm/man/rdma_set_option.3 b/usr/rdma-core/librdmacm/man/rdma_set_option.3 deleted file mode 100644 index 93a60476f..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_set_option.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_SET_OPTION" 3 "2007-08-06" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rdma_set_option \- Set communication options for an rdma_cm_id. -.SH SYNOPSIS -.B "#include " -.P -.B "int" rdma_set_option -.BI "(struct rdma_cm_id *" id "," -.BI "int " level "," -.BI "int " optname "," -.BI "void *" optval "," -.BI "size_t " optlen ");" -.SH ARGUMENTS -.IP "id" 12 -RDMA identifier. -.IP "level" 12 -Protocol level of the option to set. -.IP "optname" 12 -Name of the option, relative to the level, to set. -.IP "optval" 12 -Reference to the option data. The data is dependent on the level and optname. -.IP "optlen" 12 -The size of the %optval buffer. -.SH "DESCRIPTION" -Sets communication options for an rdma_cm_id. This call is used to override -the default system settings. -.SH "RETURN VALUE" -Returns 0 on success, or -1 on error. If an error occurs, errno will be -set to indicate the failure reason. -.SH "NOTES" -Option details may be found in the relevant header files. -.SH "SEE ALSO" -rdma_create_id(3) diff --git a/usr/rdma-core/librdmacm/man/rdma_xclient.1 b/usr/rdma-core/librdmacm/man/rdma_xclient.1 deleted file mode 100644 index d874c6e91..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_xclient.1 +++ /dev/null @@ -1,37 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_XCLIENT" 1 "2011-06-15" "librdmacm" "librdmacm" librdmacm -.SH NAME -rdma_xclient \- RDMA CM communication client test program -.SH SYNOPSIS -.sp -.nf -\fIrdma_xclient\fR [-s server_address] [-p server_port] [-c comm_type] -.fi -.SH "DESCRIPTION" -Uses synchronous librdmam calls to establish an RDMA connection between -two nodes. This example is intended to provide a very simple coding -example of how to use RDMA. -.SH "OPTIONS" -.TP -\-s server_address -Specifies the address of the system that the rdma_server is running on. -By default, the client will attempt to connect to the server using -127.0.0.1. -.TP -\-p server_port -Specifies the port number that the server listens on. By default the server -listens on port 7471. -.TP -\-c communication type -Specifies the type of communication established with the server program. 'r' -results in using a reliable-connected QP (the default). 'x' uses -extended reliable-connected XRC QPs. -.SH "NOTES" -Basic usage is to start rdma_xserver, then connect to the server using the -rdma_client program. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7), udaddy(1), mckey(1), rping(1), rdma_xserver(1), rdma_client(1) diff --git a/usr/rdma-core/librdmacm/man/rdma_xserver.1 b/usr/rdma-core/librdmacm/man/rdma_xserver.1 deleted file mode 100644 index 4c12e2563..000000000 --- a/usr/rdma-core/librdmacm/man/rdma_xserver.1 +++ /dev/null @@ -1,31 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RDMA_XSERVER" 1 "2011-06-15" "librdmacm" "librdmacm" librdmacm -.SH NAME -rdma_xserver \- RDMA CM communication server test program -.SH SYNOPSIS -.sp -.nf -\fIrdma_xserver\fR [-p port] [-c comm_type] -.fi -.SH "DESCRIPTION" -Uses the librdmacm to establish various forms of communication and exchange -data. -.SH "OPTIONS" -.TP -\-p port -Changes the port number that the server listens on. By default the server -listens on port 7471. -.TP -\-c communication type -Specifies the type of communication established with the client program. 'r' -results in using a reliable-connected QP (the default). 'x' uses -extended reliable-connected XRC QPs. -.SH "NOTES" -Basic usage is to start rdma_xserver, then connect to the server using the -rdma_xclient program. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7), udaddy(1), mckey(1), rping(1), rdma_server(1), rdma_xclient(1) diff --git a/usr/rdma-core/librdmacm/man/riostream.1 b/usr/rdma-core/librdmacm/man/riostream.1 deleted file mode 100644 index 537302b60..000000000 --- a/usr/rdma-core/librdmacm/man/riostream.1 +++ /dev/null @@ -1,65 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RIOSTREAM" 1 "2012-10-24" "librdmacm" "librdmacm" librdmacm -.SH NAME -riostream \- zero-copy streaming over RDMA ping-pong test. -.SH SYNOPSIS -.sp -.nf -\fIriostream\fR [-s server_address] [-b bind_address] [-B buffer_size] - [-I iterations] [-C transfer_count] - [-S transfer_size] [-p server_port] [-T test_option] -.fi -.SH "DESCRIPTION" -Uses the streaming over RDMA protocol (rsocket) to connect and exchange -data between a client and server application. -.SH "OPTIONS" -.TP -\-s server_address -The network name or IP address of the server system listening for -connections. The used name or address must route over an RDMA device. -This option must be specified by the client. -.TP -\-b bind_address -The local network address to bind to. -.TP -\-B buffer_size -Indicates the size of the send and receive network buffers. -.TP -\-I iterations -The number of times that the specified number of messages will be -exchanged between the client and server. (default 1000) -.TP -\-C transfer_count -The number of messages to transfer from the client to the server and -back again on each iteration. (default 1) -.TP -\-S transfer_size -The size of each send transfer, in bytes. (default 1000) If 'all' -is specified, rstream will run a series of tests of various sizes. -.TP -\-p server_port -The server's port number. -.TP -\-T test_option -Specifies test parameters. Available options are: -.P -a | async - uses asynchronous operation (e.g. select / poll) -.P -b | blocking - uses blocking calls -.P -n | nonblocking - uses non-blocking calls -.P -v | verify - verifies data transfers -.SH "NOTES" -Basic usage is to start riostream on a server system, then run -riostream -s server_name on a client system. By default, riostream -will run a series of latency and bandwidth performance tests. -Specifying a different iterations, transfer_count, or transfer_size -will run a user customized test using default values where none -have been specified. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7) rstream(1) diff --git a/usr/rdma-core/librdmacm/man/rping.1 b/usr/rdma-core/librdmacm/man/rping.1 deleted file mode 100644 index 8d4f15702..000000000 --- a/usr/rdma-core/librdmacm/man/rping.1 +++ /dev/null @@ -1,60 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RPING" 1 "2007-05-15" "librdmacm" "librdmacm" librdmacm -.SH NAME -rping \- RDMA CM connection and RDMA ping-pong test. -.SH SYNOPSIS -.sp -.nf -\fIrping\fR -s [-v] [-V] [-d] [-P] [-a address] [-p port] - [-C message_count] [-S message_size] -\fIrping\fR -c [-v] [-V] [-d] [-I address] -a address [-p port] - [-C message_count] [-S message_size] -.fi -.SH "DESCRIPTION" -Establishes a reliable RDMA connection between two nodes using the -librdmacm, optionally performs RDMA transfers between the nodes, -then disconnects. -.SH "OPTIONS" -.TP -\-s -Run as the server. -.TP -\-c -Run as the client. -.TP -\-a address -On the server, specifies the network address to bind the connection to. -To bind to any address with IPv6 use -a ::0 . -On the client, specifies the server address to connect to. -.TP -\-I address -The address to bind to as the source IP address to use. This is useful -if you have multiple addresses on the same network or complex routing. -.TP -\-p -Port number for listening server. -.TP -\-v -Display ping data. -.TP -\-V -Validate ping data. -.TP -\-d -Display debug information. -.TP -\-C message_count -The number of messages to transfer over each connection. (default infinite) -.TP -\-S message_size -The size of each message transferred, in bytes. (default 100) -.TP -\-P -Run the server in persistent mode. This allows multiple rping clients -to connect to a single server instance. The server will run until killed. -.SH "NOTES" -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7), ucmatose(1), udaddy(1), mckey(1) diff --git a/usr/rdma-core/librdmacm/man/rsocket.7.in b/usr/rdma-core/librdmacm/man/rsocket.7.in deleted file mode 100644 index 5b7776900..000000000 --- a/usr/rdma-core/librdmacm/man/rsocket.7.in +++ /dev/null @@ -1,159 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RSOCKET" 7 "2013-01-21" "librdmacm" "Librdmacm Programmer's Manual" librdmacm -.SH NAME -rsocket \- RDMA socket API -.SH SYNOPSIS -.B "#include " -.SH "DESCRIPTION" -RDMA socket API and protocol -.SH "NOTES" -Rsockets is a protocol over RDMA that supports a socket-level API -for applications. Rsocket APIs are intended to match the behavior -of corresponding socket calls, except where noted. Rsocket -functions match the name and function signature of socket calls, -with the exception that all function calls are prefixed with an 'r'. -.P -The following functions are defined: -.P -rsocket -.P -rbind, rlisten, raccept, rconnect -.P -rshutdown, rclose -.P -rrecv, rrecvfrom, rrecvmsg, rread, rreadv -.P -rsend, rsendto, rsendmsg, rwrite, rwritev -.P -rpoll, rselect -.P -rgetpeername, rgetsockname -.P -rsetsockopt, rgetsockopt, rfcntl -.P -Functions take the same parameters as that used for sockets. The -follow capabilities and flags are supported at this time: -.P -PF_INET, PF_INET6, SOCK_STREAM, SOCK_DGRAM -.P -SOL_SOCKET - SO_ERROR, SO_KEEPALIVE (flag supported, but ignored), -SO_LINGER, SO_OOBINLINE, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF -.P -IPPROTO_TCP - TCP_NODELAY, TCP_MAXSEG -.P -IPPROTO_IPV6 - IPV6_V6ONLY -.P -MSG_DONTWAIT, MSG_PEEK, O_NONBLOCK -.P -Rsockets provides extensions beyond normal socket routines that -allow for direct placement of data into an application's buffer. -This is also known as zero-copy support, since data is sent and -received directly, bypassing copies into network controlled buffers. -The following calls and options support direct data placement. -.P -riomap, riounmap, riowrite -.TP -off_t riomap(int socket, void *buf, size_t len, int prot, int flags, off_t offset) -.TP -Riomap registers an application buffer with the RDMA hardware -associated with an rsocket. The buffer is registered either for -local only access (PROT_NONE) or for remote write access (PROT_WRITE). -When registered for remote access, the buffer is mapped to a given -offset. The offset is either provided by the user, or if the user -selects -1 for the offset, rsockets selects one. The remote peer may -access an iomapped buffer directly by specifying the correct offset. -The mapping is not guaranteed to be available until after the remote -peer receives a data transfer initiated after riomap has completed. -.PP -In order to enable the use of remote IO mapping calls on an rsocket, -an application must set the number of IO mappings that are available -to the remote peer. This may be done using the rsetsockopt -RDMA_IOMAPSIZE option. By default, an rsocket does not support -remote IO mappings. -riounmap -.TP -int riounmap(int socket, void *buf, size_t len) -.TP -Riounmap removes the mapping between a buffer and an rsocket. -.P -riowrite -.TP -size_t riowrite(int socket, const void *buf, size_t count, off_t offset, int flags) -.TP -Riowrite allows an application to transfer data over an rsocket -directly into a remotely iomapped buffer. The remote buffer is specified -through an offset parameter, which corresponds to a remote iomapped buffer. -From the sender's perspective, riowrite behaves similar to rwrite. From -a receiver's view, riowrite transfers are silently redirected into a pre- -determined data buffer. Data is received automatically, and the receiver -is not informed of the transfer. However, iowrite data is still considered -part of the data stream, such that iowrite data will be written before a -subsequent transfer is received. A message sent immediately after initiating -an iowrite may be used to notify the receiver of the iowrite. -.P -In addition to standard socket options, rsockets supports options -specific to RDMA devices and protocols. These options are accessible -through rsetsockopt using SOL_RDMA option level. -.TP -RDMA_SQSIZE - Integer size of the underlying send queue. -.TP -RDMA_RQSIZE - Integer size of the underlying receive queue. -.TP -RDMA_INLINE - Integer size of inline data. -.TP -RDMA_IOMAPSIZE - Integer number of remote IO mappings supported -.TP -RDMA_ROUTE - struct ibv_path_data of path record for connection. -.P -Note that rsockets fd's cannot be passed into non-rsocket calls. For -applications which must mix rsocket fd's with standard socket fd's or -opened files, rpoll and rselect support polling both rsockets and -normal fd's. -.P -Existing applications can make use of rsockets through the use of a -preload library. Because rsockets implements an end-to-end protocol, -both sides of a connection must use rsockets. The rdma_cm library -provides such a preload library, librspreload. To reduce the chance -of the preload library intercepting calls without the user's explicit -knowledge, the librspreload library is installed into %libdir%/rsocket -subdirectory. -.P -The preload library can be used by setting LD_PRELOAD when running. -Note that not all applications will work with rsockets. Support is -limited based on the socket options used by the application. -Support for fork() is limited, but available. To use rsockets with -the preload library for applications that call fork, users must -set the environment variable RDMAV_FORK_SAFE=1 on both the client -and server side of the connection. In general, fork is -supportable for server applications that accept a connection, then -fork off a process to handle the new connection. -.P -rsockets uses configuration files that give an administrator control -over the default settings used by rsockets. Use files under -@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket as shown: -.P -.P -mem_default - default size of receive buffer(s) -.P -wmem_default - default size of send buffer(s) -.P -sqsize_default - default size of send queue -.P -rqsize_default - default size of receive queue -.P -inline_default - default size of inline data -.P -iomap_size - default size of remote iomapping table -.P -polling_time - default number of microseconds to poll for data before waiting -.P -All configuration files should contain a single integer value. Values may -be set by issuing a command similar to the following example. -.P -echo 1000000 > @CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket/mem_default -.P -If configuration files are not available, rsockets uses internal defaults. -Applications can override default values programmatically through the -rsetsockopt routine. -.SH "SEE ALSO" -rdma_cm(7) diff --git a/usr/rdma-core/librdmacm/man/rstream.1 b/usr/rdma-core/librdmacm/man/rstream.1 deleted file mode 100644 index 3fc3b17f5..000000000 --- a/usr/rdma-core/librdmacm/man/rstream.1 +++ /dev/null @@ -1,74 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "RSTREAM" 1 "2011-11-16" "librdmacm" "librdmacm" librdmacm -.SH NAME -rstream \- streaming over RDMA ping-pong test. -.SH SYNOPSIS -.sp -.nf -\fIrstream\fR [-s server_address] [-b bind_address] [-f address_format] - [-B buffer_size] [-I iterations] [-C transfer_count] - [-S transfer_size] [-p server_port] [-T test_option] -.fi -.SH "DESCRIPTION" -Uses the streaming over RDMA protocol (rsocket) to connect and exchange -data between a client and server application. -.SH "OPTIONS" -.TP -\-s server_address -The network name or IP address of the server system listening for -connections. The used name or address must route over an RDMA device. -This option must be specified by the client. -.TP -\-b bind_address -The local network address to bind to. -.TP -\-f address_format -Supported address formats are ip, ipv6, gid, or name. -.TP -\-B buffer_size -Indicates the size of the send and receive network buffers. -.TP -\-I iterations -The number of times that the specified number of messages will be -exchanged between the client and server. (default 1000) -.TP -\-C transfer_count -The number of messages to transfer from the client to the server and -back again on each iteration. (default 1000) -.TP -\-S transfer_size -The size of each send transfer, in bytes. (default 1000) If 'all' -is specified, rstream will run a series of tests of various sizes. -.TP -\-p server_port -The server's port number. -.TP -\-T test_option -Specifies test parameters. Available options are: -.P -s | socket - uses standard socket calls to transfer data -.P -a | async - uses asynchronous operation (e.g. select / poll) -.P -b | blocking - uses blocking calls -.P -f | fork - fork server processing (forces -T s option) -.P -n | nonblocking - uses non-blocking calls -.P -r | resolve - use rdma cm to resolve address -.P -v | verify - verifies data transfers -.SH "NOTES" -Basic usage is to start rstream on a server system, then run -rstream -s server_name on a client system. By default, rstream -will run a series of latency and bandwidth performance tests. -Specifying a different iterations, transfer_count, or transfer_size -will run a user customized test using default values where none -have been specified. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7) diff --git a/usr/rdma-core/librdmacm/man/ucmatose.1 b/usr/rdma-core/librdmacm/man/ucmatose.1 deleted file mode 100644 index 56e070298..000000000 --- a/usr/rdma-core/librdmacm/man/ucmatose.1 +++ /dev/null @@ -1,66 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "UCMATOSE" 1 "2007-05-15" "librdmacm" "librdmacm" librdmacm -.SH NAME -ucmatose \- RDMA CM connection and simple ping-pong test. -.SH SYNOPSIS -.sp -.nf -\fIucmatose\fR [-s server_address] [-b bind_address] - [-f address_format] [-P port_space] - [-c connections] [-C message_count] [-S message_size] -\fIucmatose\fR -s server_address [-b bind_address] - [-f address_format] [-P port_space] - [-c connections] [-C message_count] [-S message_size] [-t tos] -.fi -.SH "DESCRIPTION" -Establishes a set of reliable RDMA connections between two nodes using the -librdmacm, optionally transfers data between the nodes, then disconnects. -.SH "OPTIONS" -.TP -\-s server_address -The network name or IP address of the server system listening for -connections. The used name or address must route over an RDMA device. -This option must be specified by the client. -.TP -\-b bind_address -The local network address to bind to. -To bind to any address with IPv6 use -b ::0 . -.TP -\-f address_format -Specifies the format of the server and bind address. Be default, the -format is determined by getaddrinfo() as either being a hostname, an IPv4 -address, or an IPv6 address. This option may be used to indicate that -a specific address format has been provided. Supported address_format -values are: name, ip, ipv6, and gid. -.TP -\-P port_space -Specifies the port space for the connection. Be default, the port space -is the RDMA TCP port space. (Note that the RDMA port space may be separate -from that used for IP.) Supported port_space values are: tcp and ib. -.TP -\-c connections -The number of connections to establish between the client and server. -(default 1) -.TP -\-C message_count -The number of messages to transfer over each connection. (default 10) -.TP -\-S message_size -The size of each message transferred, in bytes. (default 100) -.TP -\-t tos -Indicates the type of service used for the communication. Type of service -is implementation dependent based on subnet configuration. -.TP -\-m -Tests event channel migration. Migrates all communication identifiers to -a different event channel for disconnect events. -.SH "NOTES" -Basic usage is to start ucmatose on a server system, then run -ucmatose -s server_name on a client system. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7), udaddy(1), mckey(1), rping(1) diff --git a/usr/rdma-core/librdmacm/man/udaddy.1 b/usr/rdma-core/librdmacm/man/udaddy.1 deleted file mode 100644 index bc8450434..000000000 --- a/usr/rdma-core/librdmacm/man/udaddy.1 +++ /dev/null @@ -1,56 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "UDADDY" 1 "2007-05-15" "librdmacm" "librdmacm" librdmacm -.SH NAME -udaddy \- RDMA CM datagram setup and simple ping-pong test. -.SH SYNOPSIS -.sp -.nf -\fIudaddy\fR [-s server_address] [-b bind_address] [-c connections] - [-C message_count] [-S message_size] [-p port_space] -\fIudaddy\fR -s server_address [-b bind_address] [-c connections] - [-C message_count] [-S message_size] [-t tos] [-p port_space] -.fi -.SH "DESCRIPTION" -Establishes a set of unreliable RDMA datagram communication paths between two -nodes using the librdmacm, optionally transfers datagrams between the nodes, -then tears down the communication. -.SH "OPTIONS" -.TP -\-s server_address -The network name or IP address of the server system listening for -communication. The used name or address must route over an RDMA device. -This option must be specified by the client. -.TP -\-b bind_address -The local network address to bind to. -To bind to any address with IPv6 use -b ::0 . -.TP -\-c connections -The number of communication paths to establish between the client and server. -The test uses unreliable datagram communication, so no actual connections are -formed. (default 1) -.TP -\-C message_count -The number of messages to transfer over each connection. (default 10) -.TP -\-S message_size -The size of each message transferred, in bytes. This value must be smaller -than the MTU of the underlying RDMA transport, or an error will occur. -(default 100) -.TP -\-t tos -Indicates the type of service used for the communication. Type of service -is implementation dependent based on subnet configuration. -.TP -\-p port_space -The port space of the datagram communication. May be either the RDMA -UDP (0x0111) or IPoIB (0x0002) port space. (default RDMA_PS_UDP) -.SH "NOTES" -Basic usage is to start udaddy on a server system, then run -udaddy -s server_name on a client system. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7), ucmatose(1), mckey(1), rping(1) diff --git a/usr/rdma-core/librdmacm/man/udpong.1 b/usr/rdma-core/librdmacm/man/udpong.1 deleted file mode 100644 index 008178b8f..000000000 --- a/usr/rdma-core/librdmacm/man/udpong.1 +++ /dev/null @@ -1,62 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH "UDPONG" 1 "2017-04-28" "librdmacm" "librdmacm" librdmacm -.SH NAME -udpong \- unreliable datagram streaming over RDMA ping-pong test. -.SH SYNOPSIS -.sp -.nf -\fIudpong\fR [-s server_address] [-b bind_address] - [-B buffer_size] [-C transfer_count] - [-S transfer_size] [-p server_port] [-T test_option] -.fi -.SH "DESCRIPTION" -Uses unreliable datagram streaming over RDMA protocol (rsocket) to -connect and exchange data between a client and server application. -.SH "OPTIONS" -.TP -\-s server_address -The network name or IP address of the server system listening for -connections. The used name or address must route over an RDMA device. -This option must be specified by the client. -.TP -\-b bind_address -The local network address to bind to. -.TP -\-B buffer_size -Indicates the size of the send and receive network buffers. -.TP -\-C transfer_count -The number of messages to transfer from the client to the server and -back again on each iteration. (default 1000) -.TP -\-S transfer_size -The size of each send transfer, in bytes. (default 1000) -.TP -\-p server_port -The server's port number. -.TP -\-T test_option -Specifies test parameters. Available options are: -.P -s | socket - uses standard socket calls to transfer data -.P -a | async - uses asynchronous operation (e.g. select / poll) -.P -b | blocking - uses blocking calls -.P -n | nonblocking - uses non-blocking calls -.P -e | echo - server echoes all messages -.SH "NOTES" -Basic usage is to start udpong on a server system, then run -udpong -s server_name on a client system. udpong -will run a series of latency and bandwidth performance tests. -Specifying a different transfer_count or transfer_size -will run a user customized test using default values where none -have been specified. -.P -Because this test maps RDMA resources to userspace, users must ensure -that they have available system resources and permissions. See the -libibverbs README file for additional details. -.SH "SEE ALSO" -rdma_cm(7) diff --git a/usr/rdma-core/librdmacm/preload.c b/usr/rdma-core/librdmacm/preload.c deleted file mode 100644 index dfc236480..000000000 --- a/usr/rdma-core/librdmacm/preload.c +++ /dev/null @@ -1,1186 +0,0 @@ -/* - * Copyright (c) 2011-2012 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "cma.h" -#include "indexer.h" - -struct socket_calls { - int (*socket)(int domain, int type, int protocol); - int (*bind)(int socket, const struct sockaddr *addr, socklen_t addrlen); - int (*listen)(int socket, int backlog); - int (*accept)(int socket, struct sockaddr *addr, socklen_t *addrlen); - int (*connect)(int socket, const struct sockaddr *addr, socklen_t addrlen); - ssize_t (*recv)(int socket, void *buf, size_t len, int flags); - ssize_t (*recvfrom)(int socket, void *buf, size_t len, int flags, - struct sockaddr *src_addr, socklen_t *addrlen); - ssize_t (*recvmsg)(int socket, struct msghdr *msg, int flags); - ssize_t (*read)(int socket, void *buf, size_t count); - ssize_t (*readv)(int socket, const struct iovec *iov, int iovcnt); - ssize_t (*send)(int socket, const void *buf, size_t len, int flags); - ssize_t (*sendto)(int socket, const void *buf, size_t len, int flags, - const struct sockaddr *dest_addr, socklen_t addrlen); - ssize_t (*sendmsg)(int socket, const struct msghdr *msg, int flags); - ssize_t (*write)(int socket, const void *buf, size_t count); - ssize_t (*writev)(int socket, const struct iovec *iov, int iovcnt); - int (*poll)(struct pollfd *fds, nfds_t nfds, int timeout); - int (*shutdown)(int socket, int how); - int (*close)(int socket); - int (*getpeername)(int socket, struct sockaddr *addr, socklen_t *addrlen); - int (*getsockname)(int socket, struct sockaddr *addr, socklen_t *addrlen); - int (*setsockopt)(int socket, int level, int optname, - const void *optval, socklen_t optlen); - int (*getsockopt)(int socket, int level, int optname, - void *optval, socklen_t *optlen); - int (*fcntl)(int socket, int cmd, ... /* arg */); - int (*dup2)(int oldfd, int newfd); - ssize_t (*sendfile)(int out_fd, int in_fd, off_t *offset, size_t count); - int (*fxstat)(int ver, int fd, struct stat *buf); -}; - -static struct socket_calls real; -static struct socket_calls rs; - -static struct index_map idm; -static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; - -static int sq_size; -static int rq_size; -static int sq_inline; -static int fork_support; - -enum fd_type { - fd_normal, - fd_rsocket -}; - -enum fd_fork_state { - fd_ready, - fd_fork, - fd_fork_listen, - fd_fork_active, - fd_fork_passive -}; - -struct fd_info { - enum fd_type type; - enum fd_fork_state state; - int fd; - int dupfd; - _Atomic(int) refcnt; -}; - -struct config_entry { - char *name; - int domain; - int type; - int protocol; -}; - -static struct config_entry *config; -static int config_cnt; - -static void free_config(void) -{ - while (config_cnt) - free(config[--config_cnt].name); - - free(config); -} - -/* - * Config file format: - * # Starting '#' indicates comment - * # wild card values are supported using '*' - * # domain - *, INET, INET6, IB - * # type - *, STREAM, DGRAM - * # protocol - *, TCP, UDP - * program_name domain type protocol - */ -static void scan_config(void) -{ - struct config_entry *new_config; - FILE *fp; - char line[120], prog[64], dom[16], type[16], proto[16]; - - fp = fopen(RS_CONF_DIR "/preload_config", "r"); - if (!fp) - return; - - while (fgets(line, sizeof(line), fp)) { - if (line[0] == '#') - continue; - - if (sscanf(line, "%64s%16s%16s%16s", prog, dom, type, proto) != 4) - continue; - - new_config = realloc(config, (config_cnt + 1) * - sizeof(struct config_entry)); - if (!new_config) - break; - - config = new_config; - memset(&config[config_cnt], 0, sizeof(struct config_entry)); - - if (!strcasecmp(dom, "INET") || - !strcasecmp(dom, "AF_INET") || - !strcasecmp(dom, "PF_INET")) { - config[config_cnt].domain = AF_INET; - } else if (!strcasecmp(dom, "INET6") || - !strcasecmp(dom, "AF_INET6") || - !strcasecmp(dom, "PF_INET6")) { - config[config_cnt].domain = AF_INET6; - } else if (!strcasecmp(dom, "IB") || - !strcasecmp(dom, "AF_IB") || - !strcasecmp(dom, "PF_IB")) { - config[config_cnt].domain = AF_IB; - } else if (strcmp(dom, "*")) { - continue; - } - - if (!strcasecmp(type, "STREAM") || - !strcasecmp(type, "SOCK_STREAM")) { - config[config_cnt].type = SOCK_STREAM; - } else if (!strcasecmp(type, "DGRAM") || - !strcasecmp(type, "SOCK_DGRAM")) { - config[config_cnt].type = SOCK_DGRAM; - } else if (strcmp(type, "*")) { - continue; - } - - if (!strcasecmp(proto, "TCP") || - !strcasecmp(proto, "IPPROTO_TCP")) { - config[config_cnt].protocol = IPPROTO_TCP; - } else if (!strcasecmp(proto, "UDP") || - !strcasecmp(proto, "IPPROTO_UDP")) { - config[config_cnt].protocol = IPPROTO_UDP; - } else if (strcmp(proto, "*")) { - continue; - } - - if (strcmp(prog, "*")) { - if (!(config[config_cnt].name = strdup(prog))) - continue; - } - - config_cnt++; - } - - fclose(fp); - if (config_cnt) - atexit(free_config); -} - -static int intercept_socket(int domain, int type, int protocol) -{ - int i; - - if (!config_cnt) - return 1; - - if (!protocol) { - if (type == SOCK_STREAM) - protocol = IPPROTO_TCP; - else if (type == SOCK_DGRAM) - protocol = IPPROTO_UDP; - } - - for (i = 0; i < config_cnt; i++) { - if ((!config[i].name || - !strncasecmp(config[i].name, program_invocation_short_name, - strlen(config[i].name))) && - (!config[i].domain || config[i].domain == domain) && - (!config[i].type || config[i].type == type) && - (!config[i].protocol || config[i].protocol == protocol)) - return 1; - } - - return 0; -} - -static int fd_open(void) -{ - struct fd_info *fdi; - int ret, index; - - fdi = calloc(1, sizeof(*fdi)); - if (!fdi) - return ERR(ENOMEM); - - index = open("/dev/null", O_RDONLY); - if (index < 0) { - ret = index; - goto err1; - } - - fdi->dupfd = -1; - atomic_store(&fdi->refcnt, 1); - pthread_mutex_lock(&mut); - ret = idm_set(&idm, index, fdi); - pthread_mutex_unlock(&mut); - if (ret < 0) - goto err2; - - return index; - -err2: - real.close(index); -err1: - free(fdi); - return ret; -} - -static void fd_store(int index, int fd, enum fd_type type, enum fd_fork_state state) -{ - struct fd_info *fdi; - - fdi = idm_at(&idm, index); - fdi->fd = fd; - fdi->type = type; - fdi->state = state; -} - -static inline enum fd_type fd_get(int index, int *fd) -{ - struct fd_info *fdi; - - fdi = idm_lookup(&idm, index); - if (fdi) { - *fd = fdi->fd; - return fdi->type; - - } else { - *fd = index; - return fd_normal; - } -} - -static inline int fd_getd(int index) -{ - struct fd_info *fdi; - - fdi = idm_lookup(&idm, index); - return fdi ? fdi->fd : index; -} - -static inline enum fd_fork_state fd_gets(int index) -{ - struct fd_info *fdi; - - fdi = idm_lookup(&idm, index); - return fdi ? fdi->state : fd_ready; -} - -static inline enum fd_type fd_gett(int index) -{ - struct fd_info *fdi; - - fdi = idm_lookup(&idm, index); - return fdi ? fdi->type : fd_normal; -} - -static enum fd_type fd_close(int index, int *fd) -{ - struct fd_info *fdi; - enum fd_type type; - - fdi = idm_lookup(&idm, index); - if (fdi) { - idm_clear(&idm, index); - *fd = fdi->fd; - type = fdi->type; - real.close(index); - free(fdi); - } else { - *fd = index; - type = fd_normal; - } - return type; -} - -static void getenv_options(void) -{ - char *var; - - var = getenv("RS_SQ_SIZE"); - if (var) - sq_size = atoi(var); - - var = getenv("RS_RQ_SIZE"); - if (var) - rq_size = atoi(var); - - var = getenv("RS_INLINE"); - if (var) - sq_inline = atoi(var); - - var = getenv("RDMAV_FORK_SAFE"); - if (var) - fork_support = atoi(var); -} - -static void init_preload(void) -{ - static int init; - - /* Quick check without lock */ - if (init) - return; - - pthread_mutex_lock(&mut); - if (init) - goto out; - - real.socket = dlsym(RTLD_NEXT, "socket"); - real.bind = dlsym(RTLD_NEXT, "bind"); - real.listen = dlsym(RTLD_NEXT, "listen"); - real.accept = dlsym(RTLD_NEXT, "accept"); - real.connect = dlsym(RTLD_NEXT, "connect"); - real.recv = dlsym(RTLD_NEXT, "recv"); - real.recvfrom = dlsym(RTLD_NEXT, "recvfrom"); - real.recvmsg = dlsym(RTLD_NEXT, "recvmsg"); - real.read = dlsym(RTLD_NEXT, "read"); - real.readv = dlsym(RTLD_NEXT, "readv"); - real.send = dlsym(RTLD_NEXT, "send"); - real.sendto = dlsym(RTLD_NEXT, "sendto"); - real.sendmsg = dlsym(RTLD_NEXT, "sendmsg"); - real.write = dlsym(RTLD_NEXT, "write"); - real.writev = dlsym(RTLD_NEXT, "writev"); - real.poll = dlsym(RTLD_NEXT, "poll"); - real.shutdown = dlsym(RTLD_NEXT, "shutdown"); - real.close = dlsym(RTLD_NEXT, "close"); - real.getpeername = dlsym(RTLD_NEXT, "getpeername"); - real.getsockname = dlsym(RTLD_NEXT, "getsockname"); - real.setsockopt = dlsym(RTLD_NEXT, "setsockopt"); - real.getsockopt = dlsym(RTLD_NEXT, "getsockopt"); - real.fcntl = dlsym(RTLD_NEXT, "fcntl"); - real.dup2 = dlsym(RTLD_NEXT, "dup2"); - real.sendfile = dlsym(RTLD_NEXT, "sendfile"); - real.fxstat = dlsym(RTLD_NEXT, "__fxstat"); - - rs.socket = dlsym(RTLD_DEFAULT, "rsocket"); - rs.bind = dlsym(RTLD_DEFAULT, "rbind"); - rs.listen = dlsym(RTLD_DEFAULT, "rlisten"); - rs.accept = dlsym(RTLD_DEFAULT, "raccept"); - rs.connect = dlsym(RTLD_DEFAULT, "rconnect"); - rs.recv = dlsym(RTLD_DEFAULT, "rrecv"); - rs.recvfrom = dlsym(RTLD_DEFAULT, "rrecvfrom"); - rs.recvmsg = dlsym(RTLD_DEFAULT, "rrecvmsg"); - rs.read = dlsym(RTLD_DEFAULT, "rread"); - rs.readv = dlsym(RTLD_DEFAULT, "rreadv"); - rs.send = dlsym(RTLD_DEFAULT, "rsend"); - rs.sendto = dlsym(RTLD_DEFAULT, "rsendto"); - rs.sendmsg = dlsym(RTLD_DEFAULT, "rsendmsg"); - rs.write = dlsym(RTLD_DEFAULT, "rwrite"); - rs.writev = dlsym(RTLD_DEFAULT, "rwritev"); - rs.poll = dlsym(RTLD_DEFAULT, "rpoll"); - rs.shutdown = dlsym(RTLD_DEFAULT, "rshutdown"); - rs.close = dlsym(RTLD_DEFAULT, "rclose"); - rs.getpeername = dlsym(RTLD_DEFAULT, "rgetpeername"); - rs.getsockname = dlsym(RTLD_DEFAULT, "rgetsockname"); - rs.setsockopt = dlsym(RTLD_DEFAULT, "rsetsockopt"); - rs.getsockopt = dlsym(RTLD_DEFAULT, "rgetsockopt"); - rs.fcntl = dlsym(RTLD_DEFAULT, "rfcntl"); - - getenv_options(); - scan_config(); - init = 1; -out: - pthread_mutex_unlock(&mut); -} - -/* - * We currently only handle copying a few common values. - */ -static int copysockopts(int dfd, int sfd, struct socket_calls *dapi, - struct socket_calls *sapi) -{ - socklen_t len; - int param, ret; - - ret = sapi->fcntl(sfd, F_GETFL); - if (ret > 0) - ret = dapi->fcntl(dfd, F_SETFL, ret); - if (ret) - return ret; - - len = sizeof param; - ret = sapi->getsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, ¶m, &len); - if (param && !ret) - ret = dapi->setsockopt(dfd, SOL_SOCKET, SO_REUSEADDR, ¶m, len); - if (ret) - return ret; - - len = sizeof param; - ret = sapi->getsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, ¶m, &len); - if (param && !ret) - ret = dapi->setsockopt(dfd, IPPROTO_TCP, TCP_NODELAY, ¶m, len); - if (ret) - return ret; - - return 0; -} - -/* - * Convert between an rsocket and a normal socket. - */ -static int transpose_socket(int socket, enum fd_type new_type) -{ - socklen_t len = 0; - int sfd, dfd, param, ret; - struct socket_calls *sapi, *dapi; - - sfd = fd_getd(socket); - if (new_type == fd_rsocket) { - dapi = &rs; - sapi = ℜ - } else { - dapi = ℜ - sapi = &rs; - } - - ret = sapi->getsockname(sfd, NULL, &len); - if (ret) - return ret; - - param = (len == sizeof(struct sockaddr_in6)) ? PF_INET6 : PF_INET; - dfd = dapi->socket(param, SOCK_STREAM, 0); - if (dfd < 0) - return dfd; - - ret = copysockopts(dfd, sfd, dapi, sapi); - if (ret) - goto err; - - fd_store(socket, dfd, new_type, fd_ready); - return dfd; - -err: - dapi->close(dfd); - return ret; -} - -/* - * Use defaults on failure. - */ -static void set_rsocket_options(int rsocket) -{ - if (sq_size) - rsetsockopt(rsocket, SOL_RDMA, RDMA_SQSIZE, &sq_size, sizeof sq_size); - - if (rq_size) - rsetsockopt(rsocket, SOL_RDMA, RDMA_RQSIZE, &rq_size, sizeof rq_size); - - if (sq_inline) - rsetsockopt(rsocket, SOL_RDMA, RDMA_INLINE, &sq_inline, sizeof sq_inline); -} - -int socket(int domain, int type, int protocol) -{ - static __thread int recursive; - int index, ret; - - init_preload(); - - if (recursive || !intercept_socket(domain, type, protocol)) - goto real; - - index = fd_open(); - if (index < 0) - return index; - - if (fork_support && (domain == PF_INET || domain == PF_INET6) && - (type == SOCK_STREAM) && (!protocol || protocol == IPPROTO_TCP)) { - ret = real.socket(domain, type, protocol); - if (ret < 0) - return ret; - fd_store(index, ret, fd_normal, fd_fork); - return index; - } - - recursive = 1; - ret = rsocket(domain, type, protocol); - recursive = 0; - if (ret >= 0) { - fd_store(index, ret, fd_rsocket, fd_ready); - set_rsocket_options(ret); - return index; - } - fd_close(index, &ret); -real: - return real.socket(domain, type, protocol); -} - -int bind(int socket, const struct sockaddr *addr, socklen_t addrlen) -{ - int fd; - return (fd_get(socket, &fd) == fd_rsocket) ? - rbind(fd, addr, addrlen) : real.bind(fd, addr, addrlen); -} - -int listen(int socket, int backlog) -{ - int fd, ret; - if (fd_get(socket, &fd) == fd_rsocket) { - ret = rlisten(fd, backlog); - } else { - ret = real.listen(fd, backlog); - if (!ret && fd_gets(socket) == fd_fork) - fd_store(socket, fd, fd_normal, fd_fork_listen); - } - return ret; -} - -int accept(int socket, struct sockaddr *addr, socklen_t *addrlen) -{ - int fd, index, ret; - - if (fd_get(socket, &fd) == fd_rsocket) { - index = fd_open(); - if (index < 0) - return index; - - ret = raccept(fd, addr, addrlen); - if (ret < 0) { - fd_close(index, &fd); - return ret; - } - - fd_store(index, ret, fd_rsocket, fd_ready); - return index; - } else if (fd_gets(socket) == fd_fork_listen) { - index = fd_open(); - if (index < 0) - return index; - - ret = real.accept(fd, addr, addrlen); - if (ret < 0) { - fd_close(index, &fd); - return ret; - } - - fd_store(index, ret, fd_normal, fd_fork_passive); - return index; - } else { - return real.accept(fd, addr, addrlen); - } -} - -/* - * We can't fork RDMA connections and pass them from the parent to the child - * process. Instead, we need to establish the RDMA connection after calling - * fork. To do this, we delay establishing the RDMA connection until we try - * to send/receive on the server side. - */ -static void fork_active(int socket) -{ - struct sockaddr_storage addr; - int sfd, dfd, ret; - socklen_t len; - uint32_t msg; - long flags; - - sfd = fd_getd(socket); - - flags = real.fcntl(sfd, F_GETFL); - real.fcntl(sfd, F_SETFL, 0); - ret = real.recv(sfd, &msg, sizeof msg, MSG_PEEK); - real.fcntl(sfd, F_SETFL, flags); - if ((ret != sizeof msg) || msg) - goto err1; - - len = sizeof addr; - ret = real.getpeername(sfd, (struct sockaddr *) &addr, &len); - if (ret) - goto err1; - - dfd = rsocket(addr.ss_family, SOCK_STREAM, 0); - if (dfd < 0) - goto err1; - - ret = rconnect(dfd, (struct sockaddr *) &addr, len); - if (ret) - goto err2; - - set_rsocket_options(dfd); - copysockopts(dfd, sfd, &rs, &real); - real.shutdown(sfd, SHUT_RDWR); - real.close(sfd); - fd_store(socket, dfd, fd_rsocket, fd_ready); - return; - -err2: - rclose(dfd); -err1: - fd_store(socket, sfd, fd_normal, fd_ready); -} - -/* - * The server will start listening for the new connection, then send a - * message to the active side when the listen is ready. This does leave - * fork unsupported in the following case: the server is nonblocking and - * calls select/poll waiting to receive data from the client. - */ -static void fork_passive(int socket) -{ - struct sockaddr_in6 sin6; - sem_t *sem; - int lfd, sfd, dfd, ret, param; - socklen_t len; - uint32_t msg; - - sfd = fd_getd(socket); - - len = sizeof sin6; - ret = real.getsockname(sfd, (struct sockaddr *) &sin6, &len); - if (ret) - goto out; - sin6.sin6_flowinfo = 0; - sin6.sin6_scope_id = 0; - memset(&sin6.sin6_addr, 0, sizeof sin6.sin6_addr); - - sem = sem_open("/rsocket_fork", O_CREAT | O_RDWR, - S_IRWXU | S_IRWXG, 1); - if (sem == SEM_FAILED) { - ret = -1; - goto out; - } - - lfd = rsocket(sin6.sin6_family, SOCK_STREAM, 0); - if (lfd < 0) { - ret = lfd; - goto sclose; - } - - param = 1; - rsetsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, ¶m, sizeof param); - - sem_wait(sem); - ret = rbind(lfd, (struct sockaddr *) &sin6, sizeof sin6); - if (ret) - goto lclose; - - ret = rlisten(lfd, 1); - if (ret) - goto lclose; - - msg = 0; - len = real.write(sfd, &msg, sizeof msg); - if (len != sizeof msg) - goto lclose; - - dfd = raccept(lfd, NULL, NULL); - if (dfd < 0) { - ret = dfd; - goto lclose; - } - - set_rsocket_options(dfd); - copysockopts(dfd, sfd, &rs, &real); - real.shutdown(sfd, SHUT_RDWR); - real.close(sfd); - fd_store(socket, dfd, fd_rsocket, fd_ready); - -lclose: - rclose(lfd); - sem_post(sem); -sclose: - sem_close(sem); -out: - if (ret) - fd_store(socket, sfd, fd_normal, fd_ready); -} - -static inline enum fd_type fd_fork_get(int index, int *fd) -{ - struct fd_info *fdi; - - fdi = idm_lookup(&idm, index); - if (fdi) { - if (fdi->state == fd_fork_passive) - fork_passive(index); - else if (fdi->state == fd_fork_active) - fork_active(index); - *fd = fdi->fd; - return fdi->type; - - } else { - *fd = index; - return fd_normal; - } -} - -int connect(int socket, const struct sockaddr *addr, socklen_t addrlen) -{ - int fd, ret; - - if (fd_get(socket, &fd) == fd_rsocket) { - ret = rconnect(fd, addr, addrlen); - if (!ret || errno == EINPROGRESS) - return ret; - - ret = transpose_socket(socket, fd_normal); - if (ret < 0) - return ret; - - rclose(fd); - fd = ret; - } else if (fd_gets(socket) == fd_fork) { - fd_store(socket, fd, fd_normal, fd_fork_active); - } - - return real.connect(fd, addr, addrlen); -} - -ssize_t recv(int socket, void *buf, size_t len, int flags) -{ - int fd; - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rrecv(fd, buf, len, flags) : real.recv(fd, buf, len, flags); -} - -ssize_t recvfrom(int socket, void *buf, size_t len, int flags, - struct sockaddr *src_addr, socklen_t *addrlen) -{ - int fd; - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rrecvfrom(fd, buf, len, flags, src_addr, addrlen) : - real.recvfrom(fd, buf, len, flags, src_addr, addrlen); -} - -ssize_t recvmsg(int socket, struct msghdr *msg, int flags) -{ - int fd; - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rrecvmsg(fd, msg, flags) : real.recvmsg(fd, msg, flags); -} - -ssize_t read(int socket, void *buf, size_t count) -{ - int fd; - init_preload(); - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rread(fd, buf, count) : real.read(fd, buf, count); -} - -ssize_t readv(int socket, const struct iovec *iov, int iovcnt) -{ - int fd; - init_preload(); - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rreadv(fd, iov, iovcnt) : real.readv(fd, iov, iovcnt); -} - -ssize_t send(int socket, const void *buf, size_t len, int flags) -{ - int fd; - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rsend(fd, buf, len, flags) : real.send(fd, buf, len, flags); -} - -ssize_t sendto(int socket, const void *buf, size_t len, int flags, - const struct sockaddr *dest_addr, socklen_t addrlen) -{ - int fd; - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rsendto(fd, buf, len, flags, dest_addr, addrlen) : - real.sendto(fd, buf, len, flags, dest_addr, addrlen); -} - -ssize_t sendmsg(int socket, const struct msghdr *msg, int flags) -{ - int fd; - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rsendmsg(fd, msg, flags) : real.sendmsg(fd, msg, flags); -} - -ssize_t write(int socket, const void *buf, size_t count) -{ - int fd; - init_preload(); - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rwrite(fd, buf, count) : real.write(fd, buf, count); -} - -ssize_t writev(int socket, const struct iovec *iov, int iovcnt) -{ - int fd; - init_preload(); - return (fd_fork_get(socket, &fd) == fd_rsocket) ? - rwritev(fd, iov, iovcnt) : real.writev(fd, iov, iovcnt); -} - -static struct pollfd *fds_alloc(nfds_t nfds) -{ - static __thread struct pollfd *rfds; - static __thread nfds_t rnfds; - - if (nfds > rnfds) { - if (rfds) - free(rfds); - - rfds = malloc(sizeof(*rfds) * nfds); - rnfds = rfds ? nfds : 0; - } - - return rfds; -} - -int poll(struct pollfd *fds, nfds_t nfds, int timeout) -{ - struct pollfd *rfds; - int i, ret; - - init_preload(); - for (i = 0; i < nfds; i++) { - if (fd_gett(fds[i].fd) == fd_rsocket) - goto use_rpoll; - } - - return real.poll(fds, nfds, timeout); - -use_rpoll: - rfds = fds_alloc(nfds); - if (!rfds) - return ERR(ENOMEM); - - for (i = 0; i < nfds; i++) { - rfds[i].fd = fd_getd(fds[i].fd); - rfds[i].events = fds[i].events; - rfds[i].revents = 0; - } - - ret = rpoll(rfds, nfds, timeout); - - for (i = 0; i < nfds; i++) - fds[i].revents = rfds[i].revents; - - return ret; -} - -static void select_to_rpoll(struct pollfd *fds, int *nfds, - fd_set *readfds, fd_set *writefds, fd_set *exceptfds) -{ - int fd, events, i = 0; - - for (fd = 0; fd < *nfds; fd++) { - events = (readfds && FD_ISSET(fd, readfds)) ? POLLIN : 0; - if (writefds && FD_ISSET(fd, writefds)) - events |= POLLOUT; - - if (events || (exceptfds && FD_ISSET(fd, exceptfds))) { - fds[i].fd = fd_getd(fd); - fds[i++].events = events; - } - } - - *nfds = i; -} - -static int rpoll_to_select(struct pollfd *fds, int nfds, - fd_set *readfds, fd_set *writefds, fd_set *exceptfds) -{ - int fd, rfd, i, cnt = 0; - - for (i = 0, fd = 0; i < nfds; fd++) { - rfd = fd_getd(fd); - if (rfd != fds[i].fd) - continue; - - if (readfds && (fds[i].revents & POLLIN)) { - FD_SET(fd, readfds); - cnt++; - } - - if (writefds && (fds[i].revents & POLLOUT)) { - FD_SET(fd, writefds); - cnt++; - } - - if (exceptfds && (fds[i].revents & ~(POLLIN | POLLOUT))) { - FD_SET(fd, exceptfds); - cnt++; - } - i++; - } - - return cnt; -} - -static int rs_convert_timeout(struct timeval *timeout) -{ - return !timeout ? -1 : timeout->tv_sec * 1000 + timeout->tv_usec / 1000; -} - -int select(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) -{ - struct pollfd *fds; - int ret; - - fds = fds_alloc(nfds); - if (!fds) - return ERR(ENOMEM); - - select_to_rpoll(fds, &nfds, readfds, writefds, exceptfds); - ret = rpoll(fds, nfds, rs_convert_timeout(timeout)); - - if (readfds) - FD_ZERO(readfds); - if (writefds) - FD_ZERO(writefds); - if (exceptfds) - FD_ZERO(exceptfds); - - if (ret > 0) - ret = rpoll_to_select(fds, nfds, readfds, writefds, exceptfds); - - return ret; -} - -int shutdown(int socket, int how) -{ - int fd; - return (fd_get(socket, &fd) == fd_rsocket) ? - rshutdown(fd, how) : real.shutdown(fd, how); -} - -int close(int socket) -{ - struct fd_info *fdi; - int ret; - - init_preload(); - fdi = idm_lookup(&idm, socket); - if (!fdi) - return real.close(socket); - - if (fdi->dupfd != -1) { - ret = close(fdi->dupfd); - if (ret) - return ret; - } - - if (atomic_fetch_sub(&fdi->refcnt, 1) != 1) - return 0; - - idm_clear(&idm, socket); - real.close(socket); - ret = (fdi->type == fd_rsocket) ? rclose(fdi->fd) : real.close(fdi->fd); - free(fdi); - return ret; -} - -int getpeername(int socket, struct sockaddr *addr, socklen_t *addrlen) -{ - int fd; - return (fd_get(socket, &fd) == fd_rsocket) ? - rgetpeername(fd, addr, addrlen) : - real.getpeername(fd, addr, addrlen); -} - -int getsockname(int socket, struct sockaddr *addr, socklen_t *addrlen) -{ - int fd; - init_preload(); - return (fd_get(socket, &fd) == fd_rsocket) ? - rgetsockname(fd, addr, addrlen) : - real.getsockname(fd, addr, addrlen); -} - -int setsockopt(int socket, int level, int optname, - const void *optval, socklen_t optlen) -{ - int fd; - return (fd_get(socket, &fd) == fd_rsocket) ? - rsetsockopt(fd, level, optname, optval, optlen) : - real.setsockopt(fd, level, optname, optval, optlen); -} - -int getsockopt(int socket, int level, int optname, - void *optval, socklen_t *optlen) -{ - int fd; - return (fd_get(socket, &fd) == fd_rsocket) ? - rgetsockopt(fd, level, optname, optval, optlen) : - real.getsockopt(fd, level, optname, optval, optlen); -} - -int fcntl(int socket, int cmd, ... /* arg */) -{ - va_list args; - long lparam; - void *pparam; - int fd, ret; - - init_preload(); - va_start(args, cmd); - switch (cmd) { - case F_GETFD: - case F_GETFL: - case F_GETOWN: - case F_GETSIG: - case F_GETLEASE: - ret = (fd_get(socket, &fd) == fd_rsocket) ? - rfcntl(fd, cmd) : real.fcntl(fd, cmd); - break; - case F_DUPFD: - /*case F_DUPFD_CLOEXEC:*/ - case F_SETFD: - case F_SETFL: - case F_SETOWN: - case F_SETSIG: - case F_SETLEASE: - case F_NOTIFY: - lparam = va_arg(args, long); - ret = (fd_get(socket, &fd) == fd_rsocket) ? - rfcntl(fd, cmd, lparam) : real.fcntl(fd, cmd, lparam); - break; - default: - pparam = va_arg(args, void *); - ret = (fd_get(socket, &fd) == fd_rsocket) ? - rfcntl(fd, cmd, pparam) : real.fcntl(fd, cmd, pparam); - break; - } - va_end(args); - return ret; -} - -/* - * dup2 is not thread safe - */ -int dup2(int oldfd, int newfd) -{ - struct fd_info *oldfdi, *newfdi; - int ret; - - init_preload(); - oldfdi = idm_lookup(&idm, oldfd); - if (oldfdi) { - if (oldfdi->state == fd_fork_passive) - fork_passive(oldfd); - else if (oldfdi->state == fd_fork_active) - fork_active(oldfd); - } - - newfdi = idm_lookup(&idm, newfd); - if (newfdi) { - /* newfd cannot have been dup'ed directly */ - if (atomic_load(&newfdi->refcnt) > 1) - return ERR(EBUSY); - close(newfd); - } - - ret = real.dup2(oldfd, newfd); - if (!oldfdi || ret != newfd) - return ret; - - newfdi = calloc(1, sizeof(*newfdi)); - if (!newfdi) { - close(newfd); - return ERR(ENOMEM); - } - - pthread_mutex_lock(&mut); - idm_set(&idm, newfd, newfdi); - pthread_mutex_unlock(&mut); - - newfdi->fd = oldfdi->fd; - newfdi->type = oldfdi->type; - if (oldfdi->dupfd != -1) { - newfdi->dupfd = oldfdi->dupfd; - oldfdi = idm_lookup(&idm, oldfdi->dupfd); - } else { - newfdi->dupfd = oldfd; - } - atomic_store(&newfdi->refcnt, 1); - atomic_fetch_add(&oldfdi->refcnt, 1); - return newfd; -} - -ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) -{ - void *file_addr; - int fd; - size_t ret; - - if (fd_get(out_fd, &fd) != fd_rsocket) - return real.sendfile(fd, in_fd, offset, count); - - file_addr = mmap(NULL, count, PROT_READ, 0, in_fd, offset ? *offset : 0); - if (file_addr == (void *) -1) - return -1; - - ret = rwrite(fd, file_addr, count); - if ((ret > 0) && offset) - lseek(in_fd, ret, SEEK_CUR); - munmap(file_addr, count); - return ret; -} - -int __fxstat(int ver, int socket, struct stat *buf) -{ - int fd, ret; - - init_preload(); - if (fd_get(socket, &fd) == fd_rsocket) { - ret = real.fxstat(ver, socket, buf); - if (!ret) - buf->st_mode = (buf->st_mode & ~S_IFMT) | __S_IFSOCK; - } else { - ret = real.fxstat(ver, fd, buf); - } - return ret; -} diff --git a/usr/rdma-core/librdmacm/rdma_cma.h b/usr/rdma-core/librdmacm/rdma_cma.h deleted file mode 100644 index e0fc58ede..000000000 --- a/usr/rdma-core/librdmacm/rdma_cma.h +++ /dev/null @@ -1,681 +0,0 @@ -/* - * Copyright (c) 2005 Voltaire Inc. All rights reserved. - * Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(RDMA_CMA_H) -#define RDMA_CMA_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Upon receiving a device removal event, users must destroy the associated - * RDMA identifier and release all resources allocated with the device. - */ -enum rdma_cm_event_type { - RDMA_CM_EVENT_ADDR_RESOLVED, - RDMA_CM_EVENT_ADDR_ERROR, - RDMA_CM_EVENT_ROUTE_RESOLVED, - RDMA_CM_EVENT_ROUTE_ERROR, - RDMA_CM_EVENT_CONNECT_REQUEST, - RDMA_CM_EVENT_CONNECT_RESPONSE, - RDMA_CM_EVENT_CONNECT_ERROR, - RDMA_CM_EVENT_UNREACHABLE, - RDMA_CM_EVENT_REJECTED, - RDMA_CM_EVENT_ESTABLISHED, - RDMA_CM_EVENT_DISCONNECTED, - RDMA_CM_EVENT_DEVICE_REMOVAL, - RDMA_CM_EVENT_MULTICAST_JOIN, - RDMA_CM_EVENT_MULTICAST_ERROR, - RDMA_CM_EVENT_ADDR_CHANGE, - RDMA_CM_EVENT_TIMEWAIT_EXIT -}; - -enum rdma_port_space { - RDMA_PS_IPOIB = 0x0002, - RDMA_PS_TCP = 0x0106, - RDMA_PS_UDP = 0x0111, - RDMA_PS_IB = 0x013F, -}; - -#define RDMA_IB_IP_PS_MASK 0xFFFFFFFFFFFF0000ULL -#define RDMA_IB_IP_PORT_MASK 0x000000000000FFFFULL -#define RDMA_IB_IP_PS_TCP 0x0000000001060000ULL -#define RDMA_IB_IP_PS_UDP 0x0000000001110000ULL -#define RDMA_IB_PS_IB 0x00000000013F0000ULL - -/* - * Global qkey value for UDP QPs and multicast groups created via the - * RDMA CM. - */ -#define RDMA_UDP_QKEY 0x01234567 - -struct rdma_ib_addr { - union ibv_gid sgid; - union ibv_gid dgid; - __be16 pkey; -}; - -struct rdma_addr { - union { - struct sockaddr src_addr; - struct sockaddr_in src_sin; - struct sockaddr_in6 src_sin6; - struct sockaddr_storage src_storage; - }; - union { - struct sockaddr dst_addr; - struct sockaddr_in dst_sin; - struct sockaddr_in6 dst_sin6; - struct sockaddr_storage dst_storage; - }; - union { - struct rdma_ib_addr ibaddr; - } addr; -}; - -struct rdma_route { - struct rdma_addr addr; - struct ibv_sa_path_rec *path_rec; - int num_paths; -}; - -struct rdma_event_channel { - int fd; -}; - -struct rdma_cm_id { - struct ibv_context *verbs; - struct rdma_event_channel *channel; - void *context; - struct ibv_qp *qp; - struct rdma_route route; - enum rdma_port_space ps; - uint8_t port_num; - struct rdma_cm_event *event; - struct ibv_comp_channel *send_cq_channel; - struct ibv_cq *send_cq; - struct ibv_comp_channel *recv_cq_channel; - struct ibv_cq *recv_cq; - struct ibv_srq *srq; - struct ibv_pd *pd; - enum ibv_qp_type qp_type; -}; - -enum { - RDMA_MAX_RESP_RES = 0xFF, - RDMA_MAX_INIT_DEPTH = 0xFF -}; - -struct rdma_conn_param { - const void *private_data; - uint8_t private_data_len; - uint8_t responder_resources; - uint8_t initiator_depth; - uint8_t flow_control; - uint8_t retry_count; /* ignored when accepting */ - uint8_t rnr_retry_count; - /* Fields below ignored if a QP is created on the rdma_cm_id. */ - uint8_t srq; - uint32_t qp_num; -}; - -struct rdma_ud_param { - const void *private_data; - uint8_t private_data_len; - struct ibv_ah_attr ah_attr; - uint32_t qp_num; - uint32_t qkey; -}; - -struct rdma_cm_event { - struct rdma_cm_id *id; - struct rdma_cm_id *listen_id; - enum rdma_cm_event_type event; - int status; - union { - struct rdma_conn_param conn; - struct rdma_ud_param ud; - } param; -}; - -#define RAI_PASSIVE 0x00000001 -#define RAI_NUMERICHOST 0x00000002 -#define RAI_NOROUTE 0x00000004 -#define RAI_FAMILY 0x00000008 - -struct rdma_addrinfo { - int ai_flags; - int ai_family; - int ai_qp_type; - int ai_port_space; - socklen_t ai_src_len; - socklen_t ai_dst_len; - struct sockaddr *ai_src_addr; - struct sockaddr *ai_dst_addr; - char *ai_src_canonname; - char *ai_dst_canonname; - size_t ai_route_len; - void *ai_route; - size_t ai_connect_len; - void *ai_connect; - struct rdma_addrinfo *ai_next; -}; - -/** - * rdma_create_event_channel - Open a channel used to report communication events. - * Description: - * Asynchronous events are reported to users through event channels. Each - * event channel maps to a file descriptor. - * Notes: - * All created event channels must be destroyed by calling - * rdma_destroy_event_channel. Users should call rdma_get_cm_event to - * retrieve events on an event channel. - * See also: - * rdma_get_cm_event, rdma_destroy_event_channel - */ -struct rdma_event_channel *rdma_create_event_channel(void); - -/** - * rdma_destroy_event_channel - Close an event communication channel. - * @channel: The communication channel to destroy. - * Description: - * Release all resources associated with an event channel and closes the - * associated file descriptor. - * Notes: - * All rdma_cm_id's associated with the event channel must be destroyed, - * and all returned events must be acked before calling this function. - * See also: - * rdma_create_event_channel, rdma_get_cm_event, rdma_ack_cm_event - */ -void rdma_destroy_event_channel(struct rdma_event_channel *channel); - -/** - * rdma_create_id - Allocate a communication identifier. - * @channel: The communication channel that events associated with the - * allocated rdma_cm_id will be reported on. - * @id: A reference where the allocated communication identifier will be - * returned. - * @context: User specified context associated with the rdma_cm_id. - * @ps: RDMA port space. - * Description: - * Creates an identifier that is used to track communication information. - * Notes: - * Rdma_cm_id's are conceptually equivalent to a socket for RDMA - * communication. The difference is that RDMA communication requires - * explicitly binding to a specified RDMA device before communication - * can occur, and most operations are asynchronous in nature. Communication - * events on an rdma_cm_id are reported through the associated event - * channel. Users must release the rdma_cm_id by calling rdma_destroy_id. - * See also: - * rdma_create_event_channel, rdma_destroy_id, rdma_get_devices, - * rdma_bind_addr, rdma_resolve_addr, rdma_connect, rdma_listen, - */ -int rdma_create_id(struct rdma_event_channel *channel, - struct rdma_cm_id **id, void *context, - enum rdma_port_space ps); - -/** - * rdma_create_ep - Allocate a communication identifier and qp. - * @id: A reference where the allocated communication identifier will be - * returned. - * @res: Result from rdma_getaddrinfo, which specifies the source and - * destination addresses, plus optional routing and connection information. - * @pd: Optional protection domain. This parameter is ignored if qp_init_attr - * is NULL. - * @qp_init_attr: Optional attributes for a QP created on the rdma_cm_id. - * Description: - * Create an identifier and option QP used for communication. - * Notes: - * If qp_init_attr is provided, then a queue pair will be allocated and - * associated with the rdma_cm_id. If a pd is provided, the QP will be - * created on that PD. Otherwise, the QP will be allocated on a default - * PD. - * The rdma_cm_id will be set to use synchronous operations (connect, - * listen, and get_request). To convert to asynchronous operation, the - * rdma_cm_id should be migrated to a user allocated event channel. - * See also: - * rdma_create_id, rdma_create_qp, rdma_migrate_id, rdma_connect, - * rdma_listen - */ -int rdma_create_ep(struct rdma_cm_id **id, struct rdma_addrinfo *res, - struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr); - -/** - * rdma_destroy_ep - Deallocates a communication identifier and qp. - * @id: The communication identifier to destroy. - * Description: - * Destroys the specified rdma_cm_id and any associated QP created - * on that id. - * See also: - * rdma_create_ep - */ -void rdma_destroy_ep(struct rdma_cm_id *id); - -/** - * rdma_destroy_id - Release a communication identifier. - * @id: The communication identifier to destroy. - * Description: - * Destroys the specified rdma_cm_id and cancels any outstanding - * asynchronous operation. - * Notes: - * Users must free any associated QP with the rdma_cm_id before - * calling this routine and ack an related events. - * See also: - * rdma_create_id, rdma_destroy_qp, rdma_ack_cm_event - */ -int rdma_destroy_id(struct rdma_cm_id *id); - -/** - * rdma_bind_addr - Bind an RDMA identifier to a source address. - * @id: RDMA identifier. - * @addr: Local address information. Wildcard values are permitted. - * Description: - * Associates a source address with an rdma_cm_id. The address may be - * wildcarded. If binding to a specific local address, the rdma_cm_id - * will also be bound to a local RDMA device. - * Notes: - * Typically, this routine is called before calling rdma_listen to bind - * to a specific port number, but it may also be called on the active side - * of a connection before calling rdma_resolve_addr to bind to a specific - * address. - * See also: - * rdma_create_id, rdma_listen, rdma_resolve_addr, rdma_create_qp - */ -int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr); - -/** - * rdma_resolve_addr - Resolve destination and optional source addresses. - * @id: RDMA identifier. - * @src_addr: Source address information. This parameter may be NULL. - * @dst_addr: Destination address information. - * @timeout_ms: Time to wait for resolution to complete. - * Description: - * Resolve destination and optional source addresses from IP addresses - * to an RDMA address. If successful, the specified rdma_cm_id will - * be bound to a local device. - * Notes: - * This call is used to map a given destination IP address to a usable RDMA - * address. If a source address is given, the rdma_cm_id is bound to that - * address, the same as if rdma_bind_addr were called. If no source - * address is given, and the rdma_cm_id has not yet been bound to a device, - * then the rdma_cm_id will be bound to a source address based on the - * local routing tables. After this call, the rdma_cm_id will be bound to - * an RDMA device. This call is typically made from the active side of a - * connection before calling rdma_resolve_route and rdma_connect. - * See also: - * rdma_create_id, rdma_resolve_route, rdma_connect, rdma_create_qp, - * rdma_get_cm_event, rdma_bind_addr - */ -int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, - struct sockaddr *dst_addr, int timeout_ms); - -/** - * rdma_resolve_route - Resolve the route information needed to establish a connection. - * @id: RDMA identifier. - * @timeout_ms: Time to wait for resolution to complete. - * Description: - * Resolves an RDMA route to the destination address in order to establish - * a connection. The destination address must have already been resolved - * by calling rdma_resolve_addr. - * Notes: - * This is called on the client side of a connection after calling - * rdma_resolve_addr, but before calling rdma_connect. - * See also: - * rdma_resolve_addr, rdma_connect, rdma_get_cm_event - */ -int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms); - -/** - * rdma_create_qp - Allocate a QP. - * @id: RDMA identifier. - * @pd: Optional protection domain for the QP. - * @qp_init_attr: initial QP attributes. - * Description: - * Allocate a QP associated with the specified rdma_cm_id and transition it - * for sending and receiving. - * Notes: - * The rdma_cm_id must be bound to a local RDMA device before calling this - * function, and the protection domain must be for that same device. - * QPs allocated to an rdma_cm_id are automatically transitioned by the - * librdmacm through their states. After being allocated, the QP will be - * ready to handle posting of receives. If the QP is unconnected, it will - * be ready to post sends. - * If pd is NULL, then the QP will be allocated using a default protection - * domain associated with the underlying RDMA device. - * See also: - * rdma_bind_addr, rdma_resolve_addr, rdma_destroy_qp, ibv_create_qp, - * ibv_modify_qp - */ -int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd, - struct ibv_qp_init_attr *qp_init_attr); -int rdma_create_qp_ex(struct rdma_cm_id *id, - struct ibv_qp_init_attr_ex *qp_init_attr); - -/** - * rdma_destroy_qp - Deallocate a QP. - * @id: RDMA identifier. - * Description: - * Destroy a QP allocated on the rdma_cm_id. - * Notes: - * Users must destroy any QP associated with an rdma_cm_id before - * destroying the ID. - * See also: - * rdma_create_qp, rdma_destroy_id, ibv_destroy_qp - */ -void rdma_destroy_qp(struct rdma_cm_id *id); - -/** - * rdma_connect - Initiate an active connection request. - * @id: RDMA identifier. - * @conn_param: optional connection parameters. - * Description: - * For a connected rdma_cm_id, this call initiates a connection request - * to a remote destination. For an unconnected rdma_cm_id, it initiates - * a lookup of the remote QP providing the datagram service. - * Notes: - * Users must have resolved a route to the destination address - * by having called rdma_resolve_route before calling this routine. - * A user may override the default connection parameters and exchange - * private data as part of the connection by using the conn_param parameter. - * See also: - * rdma_resolve_route, rdma_disconnect, rdma_listen, rdma_get_cm_event - */ -int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param); - -/** - * rdma_listen - Listen for incoming connection requests. - * @id: RDMA identifier. - * @backlog: backlog of incoming connection requests. - * Description: - * Initiates a listen for incoming connection requests or datagram service - * lookup. The listen will be restricted to the locally bound source - * address. - * Notes: - * Users must have bound the rdma_cm_id to a local address by calling - * rdma_bind_addr before calling this routine. If the rdma_cm_id is - * bound to a specific IP address, the listen will be restricted to that - * address and the associated RDMA device. If the rdma_cm_id is bound - * to an RDMA port number only, the listen will occur across all RDMA - * devices. - * See also: - * rdma_bind_addr, rdma_connect, rdma_accept, rdma_reject, rdma_get_cm_event - */ -int rdma_listen(struct rdma_cm_id *id, int backlog); - -/** - * rdma_get_request - */ -int rdma_get_request(struct rdma_cm_id *listen, struct rdma_cm_id **id); - -/** - * rdma_accept - Called to accept a connection request. - * @id: Connection identifier associated with the request. - * @conn_param: Optional information needed to establish the connection. - * Description: - * Called from the listening side to accept a connection or datagram - * service lookup request. - * Notes: - * Unlike the socket accept routine, rdma_accept is not called on a - * listening rdma_cm_id. Instead, after calling rdma_listen, the user - * waits for a connection request event to occur. Connection request - * events give the user a newly created rdma_cm_id, similar to a new - * socket, but the rdma_cm_id is bound to a specific RDMA device. - * rdma_accept is called on the new rdma_cm_id. - * A user may override the default connection parameters and exchange - * private data as part of the connection by using the conn_param parameter. - * See also: - * rdma_listen, rdma_reject, rdma_get_cm_event - */ -int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param); - -/** - * rdma_reject - Called to reject a connection request. - * @id: Connection identifier associated with the request. - * @private_data: Optional private data to send with the reject message. - * @private_data_len: Size of the private_data to send, in bytes. - * Description: - * Called from the listening side to reject a connection or datagram - * service lookup request. - * Notes: - * After receiving a connection request event, a user may call rdma_reject - * to reject the request. If the underlying RDMA transport supports - * private data in the reject message, the specified data will be passed to - * the remote side. - * See also: - * rdma_listen, rdma_accept, rdma_get_cm_event - */ -int rdma_reject(struct rdma_cm_id *id, const void *private_data, - uint8_t private_data_len); - -/** - * rdma_notify - Notifies the librdmacm of an asynchronous event. - * @id: RDMA identifier. - * @event: Asynchronous event. - * Description: - * Used to notify the librdmacm of asynchronous events that have occurred - * on a QP associated with the rdma_cm_id. - * Notes: - * Asynchronous events that occur on a QP are reported through the user's - * device event handler. This routine is used to notify the librdmacm of - * communication events. In most cases, use of this routine is not - * necessary, however if connection establishment is done out of band - * (such as done through Infiniband), it's possible to receive data on a - * QP that is not yet considered connected. This routine forces the - * connection into an established state in this case in order to handle - * the rare situation where the connection never forms on its own. - * Events that should be reported to the CM are: IB_EVENT_COMM_EST. - * See also: - * rdma_connect, rdma_accept, rdma_listen - */ -int rdma_notify(struct rdma_cm_id *id, enum ibv_event_type event); - -/** - * rdma_disconnect - This function disconnects a connection. - * @id: RDMA identifier. - * Description: - * Disconnects a connection and transitions any associated QP to the - * error state. - * See also: - * rdma_connect, rdma_listen, rdma_accept - */ -int rdma_disconnect(struct rdma_cm_id *id); - -/** - * rdma_join_multicast - Joins a multicast group. - * @id: Communication identifier associated with the request. - * @addr: Multicast address identifying the group to join. - * @context: User-defined context associated with the join request. - * Description: - * Joins a multicast group and attaches an associated QP to the group. - * Notes: - * Before joining a multicast group, the rdma_cm_id must be bound to - * an RDMA device by calling rdma_bind_addr or rdma_resolve_addr. Use of - * rdma_resolve_addr requires the local routing tables to resolve the - * multicast address to an RDMA device. The user must call - * rdma_leave_multicast to leave the multicast group and release any - * multicast resources. The context is returned to the user through - * the private_data field in the rdma_cm_event. - * See also: - * rdma_leave_multicast, rdma_bind_addr, rdma_resolve_addr, rdma_create_qp - */ -int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, - void *context); - -/** - * rdma_leave_multicast - Leaves a multicast group. - * @id: Communication identifier associated with the request. - * @addr: Multicast address identifying the group to leave. - * Description: - * Leaves a multicast group and detaches an associated QP from the group. - * Notes: - * Calling this function before a group has been fully joined results in - * canceling the join operation. Users should be aware that messages - * received from the multicast group may stilled be queued for - * completion processing immediately after leaving a multicast group. - * Destroying an rdma_cm_id will automatically leave all multicast groups. - * See also: - * rdma_join_multicast, rdma_destroy_qp - */ -int rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr); - -/** - * rdma_get_cm_event - Retrieves the next pending communication event. - * @channel: Event channel to check for events. - * @event: Allocated information about the next communication event. - * Description: - * Retrieves a communication event. If no events are pending, by default, - * the call will block until an event is received. - * Notes: - * The default synchronous behavior of this routine can be changed by - * modifying the file descriptor associated with the given channel. All - * events that are reported must be acknowledged by calling rdma_ack_cm_event. - * Destruction of an rdma_cm_id will block until related events have been - * acknowledged. - * See also: - * rdma_ack_cm_event, rdma_create_event_channel, rdma_event_str - */ -int rdma_get_cm_event(struct rdma_event_channel *channel, - struct rdma_cm_event **event); - -/** - * rdma_ack_cm_event - Free a communication event. - * @event: Event to be released. - * Description: - * All events which are allocated by rdma_get_cm_event must be released, - * there should be a one-to-one correspondence between successful gets - * and acks. - * See also: - * rdma_get_cm_event, rdma_destroy_id - */ -int rdma_ack_cm_event(struct rdma_cm_event *event); - -__be16 rdma_get_src_port(struct rdma_cm_id *id); -__be16 rdma_get_dst_port(struct rdma_cm_id *id); - -static inline struct sockaddr *rdma_get_local_addr(struct rdma_cm_id *id) -{ - return &id->route.addr.src_addr; -} - -static inline struct sockaddr *rdma_get_peer_addr(struct rdma_cm_id *id) -{ - return &id->route.addr.dst_addr; -} - -/** - * rdma_get_devices - Get list of RDMA devices currently available. - * @num_devices: If non-NULL, set to the number of devices returned. - * Description: - * Return a NULL-terminated array of opened RDMA devices. Callers can use - * this routine to allocate resources on specific RDMA devices that will be - * shared across multiple rdma_cm_id's. - * Notes: - * The returned array must be released by calling rdma_free_devices. Devices - * remain opened while the librdmacm is loaded. - * See also: - * rdma_free_devices - */ -struct ibv_context **rdma_get_devices(int *num_devices); - -/** - * rdma_free_devices - Frees the list of devices returned by rdma_get_devices. - * @list: List of devices returned from rdma_get_devices. - * Description: - * Frees the device array returned by rdma_get_devices. - * See also: - * rdma_get_devices - */ -void rdma_free_devices(struct ibv_context **list); - -/** - * rdma_event_str - Returns a string representation of an rdma cm event. - * @event: Asynchronous event. - * Description: - * Returns a string representation of an asynchronous event. - * See also: - * rdma_get_cm_event - */ -const char *rdma_event_str(enum rdma_cm_event_type event); - -/* Option levels */ -enum { - RDMA_OPTION_ID = 0, - RDMA_OPTION_IB = 1 -}; - -/* Option details */ -enum { - RDMA_OPTION_ID_TOS = 0, /* uint8_t: RFC 2474 */ - RDMA_OPTION_ID_REUSEADDR = 1, /* int: ~SO_REUSEADDR */ - RDMA_OPTION_ID_AFONLY = 2, /* int: ~IPV6_V6ONLY */ - RDMA_OPTION_IB_PATH = 1 /* struct ibv_path_data[] */ -}; - -/** - * rdma_set_option - Set options for an rdma_cm_id. - * @id: Communication identifier to set option for. - * @level: Protocol level of the option to set. - * @optname: Name of the option to set. - * @optval: Reference to the option data. - * @optlen: The size of the %optval buffer. - */ -int rdma_set_option(struct rdma_cm_id *id, int level, int optname, - void *optval, size_t optlen); - -/** - * rdma_migrate_id - Move an rdma_cm_id to a new event channel. - * @id: Communication identifier to migrate. - * @channel: New event channel for rdma_cm_id events. - */ -int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel); - -/** - * rdma_getaddrinfo - RDMA address and route resolution service. - */ -int rdma_getaddrinfo(const char *node, const char *service, - const struct rdma_addrinfo *hints, - struct rdma_addrinfo **res); - -void rdma_freeaddrinfo(struct rdma_addrinfo *res); - -#ifdef __cplusplus -} -#endif - -#endif /* RDMA_CMA_H */ diff --git a/usr/rdma-core/librdmacm/rdma_cma_abi.h b/usr/rdma-core/librdmacm/rdma_cma_abi.h deleted file mode 100644 index 29d6f0dbb..000000000 --- a/usr/rdma-core/librdmacm/rdma_cma_abi.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (c) 2005-2011 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef RDMA_CMA_ABI_H -#define RDMA_CMA_ABI_H - -#include -#include -#include -#include - -/* - * This file must be kept in sync with the kernel's version of rdma_user_cm.h - */ - -#define RDMA_USER_CM_MIN_ABI_VERSION 3 -#define RDMA_USER_CM_MAX_ABI_VERSION 4 - -#define RDMA_MAX_PRIVATE_DATA 256 - -enum { - UCMA_CMD_CREATE_ID, - UCMA_CMD_DESTROY_ID, - UCMA_CMD_BIND_IP, - UCMA_CMD_RESOLVE_IP, - UCMA_CMD_RESOLVE_ROUTE, - UCMA_CMD_QUERY_ROUTE, - UCMA_CMD_CONNECT, - UCMA_CMD_LISTEN, - UCMA_CMD_ACCEPT, - UCMA_CMD_REJECT, - UCMA_CMD_DISCONNECT, - UCMA_CMD_INIT_QP_ATTR, - UCMA_CMD_GET_EVENT, - UCMA_CMD_GET_OPTION, - UCMA_CMD_SET_OPTION, - UCMA_CMD_NOTIFY, - UCMA_CMD_JOIN_IP_MCAST, - UCMA_CMD_LEAVE_MCAST, - UCMA_CMD_MIGRATE_ID, - UCMA_CMD_QUERY, - UCMA_CMD_BIND, - UCMA_CMD_RESOLVE_ADDR, - UCMA_CMD_JOIN_MCAST -}; - -struct ucma_abi_cmd_hdr { - __u32 cmd; - __u16 in; - __u16 out; -}; - -struct ucma_abi_create_id { - __u32 cmd; - __u16 in; - __u16 out; - __u64 uid; - __u64 response; - __u16 ps; - __u8 qp_type; - __u8 reserved[5]; -}; - -struct ucma_abi_create_id_resp { - __u32 id; -}; - -struct ucma_abi_destroy_id { - __u32 cmd; - __u16 in; - __u16 out; - __u64 response; - __u32 id; - __u32 reserved; -}; - -struct ucma_abi_destroy_id_resp { - __u32 events_reported; -}; - -struct ucma_abi_bind_ip { - __u32 cmd; - __u16 in; - __u16 out; - __u64 response; - struct sockaddr_in6 addr; - __u32 id; -}; - -struct ucma_abi_bind { - __u32 cmd; - __u16 in; - __u16 out; - __u32 id; - __u16 addr_size; - __u16 reserved; - struct sockaddr_storage addr; -}; - -struct ucma_abi_resolve_ip { - __u32 cmd; - __u16 in; - __u16 out; - struct sockaddr_in6 src_addr; - struct sockaddr_in6 dst_addr; - __u32 id; - __u32 timeout_ms; -}; - -struct ucma_abi_resolve_addr { - __u32 cmd; - __u16 in; - __u16 out; - __u32 id; - __u32 timeout_ms; - __u16 src_size; - __u16 dst_size; - __u32 reserved; - struct sockaddr_storage src_addr; - struct sockaddr_storage dst_addr; -}; - -struct ucma_abi_resolve_route { - __u32 cmd; - __u16 in; - __u16 out; - __u32 id; - __u32 timeout_ms; -}; - -enum { - UCMA_QUERY_ADDR, - UCMA_QUERY_PATH, - UCMA_QUERY_GID -}; - -struct ucma_abi_query { - __u32 cmd; - __u16 in; - __u16 out; - __u64 response; - __u32 id; - __u32 option; -}; - -struct ucma_abi_query_route_resp { - __be64 node_guid; - struct ib_user_path_rec ib_route[2]; - struct sockaddr_in6 src_addr; - struct sockaddr_in6 dst_addr; - __u32 num_paths; - __u8 port_num; - __u8 reserved[3]; -}; - -struct ucma_abi_query_addr_resp { - __be64 node_guid; - __u8 port_num; - __u8 reserved; - __be16 pkey; - __u16 src_size; - __u16 dst_size; - struct sockaddr_storage src_addr; - struct sockaddr_storage dst_addr; -}; - -struct ucma_abi_query_path_resp { - __u32 num_paths; - __u32 reserved; - struct ibv_path_data path_data[0]; -}; - -struct ucma_abi_conn_param { - __u32 qp_num; - __u32 reserved; - __u8 private_data[RDMA_MAX_PRIVATE_DATA]; - __u8 private_data_len; - __u8 srq; - __u8 responder_resources; - __u8 initiator_depth; - __u8 flow_control; - __u8 retry_count; - __u8 rnr_retry_count; - __u8 valid; -}; - -struct ucma_abi_ud_param { - __u32 qp_num; - __u32 qkey; - struct ibv_kern_ah_attr ah_attr; - __u8 private_data[RDMA_MAX_PRIVATE_DATA]; - __u8 private_data_len; - __u8 reserved[7]; - __u8 reserved2[4]; /* Round to 8-byte boundary to support 32/64 */ -}; - -struct ucma_abi_connect { - __u32 cmd; - __u16 in; - __u16 out; - struct ucma_abi_conn_param conn_param; - __u32 id; - __u32 reserved; -}; - -struct ucma_abi_listen { - __u32 cmd; - __u16 in; - __u16 out; - __u32 id; - __u32 backlog; -}; - -struct ucma_abi_accept { - __u32 cmd; - __u16 in; - __u16 out; - __u64 uid; - struct ucma_abi_conn_param conn_param; - __u32 id; - __u32 reserved; -}; - -struct ucma_abi_reject { - __u32 cmd; - __u16 in; - __u16 out; - __u32 id; - __u8 private_data_len; - __u8 reserved[3]; - __u8 private_data[RDMA_MAX_PRIVATE_DATA]; -}; - -struct ucma_abi_disconnect { - __u32 cmd; - __u16 in; - __u16 out; - __u32 id; -}; - -struct ucma_abi_init_qp_attr { - __u32 cmd; - __u16 in; - __u16 out; - __u64 response; - __u32 id; - __u32 qp_state; -}; - -struct ucma_abi_notify { - __u32 cmd; - __u16 in; - __u16 out; - __u32 id; - __u32 event; -}; - -struct ucma_abi_join_ip_mcast { - __u32 cmd; - __u16 in; - __u16 out; - __u64 response; /* ucma_abi_create_id_resp */ - __u64 uid; - struct sockaddr_in6 addr; - __u32 id; -}; - -struct ucma_abi_join_mcast { - __u32 cmd; - __u16 in; - __u16 out; - __u64 response; /* rdma_ucma_create_id_resp */ - __u64 uid; - __u32 id; - __u16 addr_size; - __u16 reserved; - struct sockaddr_storage addr; -}; - -struct ucma_abi_get_event { - __u32 cmd; - __u16 in; - __u16 out; - __u64 response; -}; - -struct ucma_abi_event_resp { - __u64 uid; - __u32 id; - __u32 event; - __u32 status; - union { - struct ucma_abi_conn_param conn; - struct ucma_abi_ud_param ud; - } param; -}; - -struct ucma_abi_set_option { - __u32 cmd; - __u16 in; - __u16 out; - __u64 optval; - __u32 id; - __u32 level; - __u32 optname; - __u32 optlen; -}; - -struct ucma_abi_migrate_id { - __u32 cmd; - __u16 in; - __u16 out; - __u64 response; - __u32 id; - __u32 fd; -}; - -struct ucma_abi_migrate_resp { - __u32 events_reported; -}; - -#endif /* RDMA_CMA_ABI_H */ diff --git a/usr/rdma-core/librdmacm/rdma_verbs.h b/usr/rdma-core/librdmacm/rdma_verbs.h deleted file mode 100644 index 10049c31c..000000000 --- a/usr/rdma-core/librdmacm/rdma_verbs.h +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright (c) 2010-2014 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(RDMA_VERBS_H) -#define RDMA_VERBS_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -static inline int rdma_seterrno(int ret) -{ - if (ret) { - errno = ret; - ret = -1; - } - return ret; -} - -/* - * Shared receive queues. - */ -int rdma_create_srq(struct rdma_cm_id *id, struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); -int rdma_create_srq_ex(struct rdma_cm_id *id, struct ibv_srq_init_attr_ex *attr); - -void rdma_destroy_srq(struct rdma_cm_id *id); - - -/* - * Memory registration helpers. - */ -static inline struct ibv_mr * -rdma_reg_msgs(struct rdma_cm_id *id, void *addr, size_t length) -{ - return ibv_reg_mr(id->pd, addr, length, IBV_ACCESS_LOCAL_WRITE); -} - -static inline struct ibv_mr * -rdma_reg_read(struct rdma_cm_id *id, void *addr, size_t length) -{ - return ibv_reg_mr(id->pd, addr, length, IBV_ACCESS_LOCAL_WRITE | - IBV_ACCESS_REMOTE_READ); -} - -static inline struct ibv_mr * -rdma_reg_write(struct rdma_cm_id *id, void *addr, size_t length) -{ - return ibv_reg_mr(id->pd, addr, length, IBV_ACCESS_LOCAL_WRITE | - IBV_ACCESS_REMOTE_WRITE); -} - -static inline int -rdma_dereg_mr(struct ibv_mr *mr) -{ - return rdma_seterrno(ibv_dereg_mr(mr)); -} - - -/* - * Vectored send, receive, and RDMA operations. - * Support multiple scatter-gather entries. - */ -static inline int -rdma_post_recvv(struct rdma_cm_id *id, void *context, struct ibv_sge *sgl, - int nsge) -{ - struct ibv_recv_wr wr, *bad; - - wr.wr_id = (uintptr_t) context; - wr.next = NULL; - wr.sg_list = sgl; - wr.num_sge = nsge; - - if (id->srq) - return rdma_seterrno(ibv_post_srq_recv(id->srq, &wr, &bad)); - else - return rdma_seterrno(ibv_post_recv(id->qp, &wr, &bad)); -} - -static inline int -rdma_post_sendv(struct rdma_cm_id *id, void *context, struct ibv_sge *sgl, - int nsge, int flags) -{ - struct ibv_send_wr wr, *bad; - - wr.wr_id = (uintptr_t) context; - wr.next = NULL; - wr.sg_list = sgl; - wr.num_sge = nsge; - wr.opcode = IBV_WR_SEND; - wr.send_flags = flags; - - return rdma_seterrno(ibv_post_send(id->qp, &wr, &bad)); -} - -static inline int -rdma_post_readv(struct rdma_cm_id *id, void *context, struct ibv_sge *sgl, - int nsge, int flags, uint64_t remote_addr, uint32_t rkey) -{ - struct ibv_send_wr wr, *bad; - - wr.wr_id = (uintptr_t) context; - wr.next = NULL; - wr.sg_list = sgl; - wr.num_sge = nsge; - wr.opcode = IBV_WR_RDMA_READ; - wr.send_flags = flags; - wr.wr.rdma.remote_addr = remote_addr; - wr.wr.rdma.rkey = rkey; - - return rdma_seterrno(ibv_post_send(id->qp, &wr, &bad)); -} - -static inline int -rdma_post_writev(struct rdma_cm_id *id, void *context, struct ibv_sge *sgl, - int nsge, int flags, uint64_t remote_addr, uint32_t rkey) -{ - struct ibv_send_wr wr, *bad; - - wr.wr_id = (uintptr_t) context; - wr.next = NULL; - wr.sg_list = sgl; - wr.num_sge = nsge; - wr.opcode = IBV_WR_RDMA_WRITE; - wr.send_flags = flags; - wr.wr.rdma.remote_addr = remote_addr; - wr.wr.rdma.rkey = rkey; - - return rdma_seterrno(ibv_post_send(id->qp, &wr, &bad)); -} - -/* - * Simple send, receive, and RDMA calls. - */ -static inline int -rdma_post_recv(struct rdma_cm_id *id, void *context, void *addr, - size_t length, struct ibv_mr *mr) -{ - struct ibv_sge sge; - - assert((addr >= mr->addr) && - (((uint8_t *) addr + length) <= ((uint8_t *) mr->addr + mr->length))); - sge.addr = (uint64_t) (uintptr_t) addr; - sge.length = (uint32_t) length; - sge.lkey = mr->lkey; - - return rdma_post_recvv(id, context, &sge, 1); -} - -static inline int -rdma_post_send(struct rdma_cm_id *id, void *context, void *addr, - size_t length, struct ibv_mr *mr, int flags) -{ - struct ibv_sge sge; - - sge.addr = (uint64_t) (uintptr_t) addr; - sge.length = (uint32_t) length; - sge.lkey = mr ? mr->lkey : 0; - - return rdma_post_sendv(id, context, &sge, 1, flags); -} - -static inline int -rdma_post_read(struct rdma_cm_id *id, void *context, void *addr, - size_t length, struct ibv_mr *mr, int flags, - uint64_t remote_addr, uint32_t rkey) -{ - struct ibv_sge sge; - - sge.addr = (uint64_t) (uintptr_t) addr; - sge.length = (uint32_t) length; - sge.lkey = mr->lkey; - - return rdma_post_readv(id, context, &sge, 1, flags, remote_addr, rkey); -} - -static inline int -rdma_post_write(struct rdma_cm_id *id, void *context, void *addr, - size_t length, struct ibv_mr *mr, int flags, - uint64_t remote_addr, uint32_t rkey) -{ - struct ibv_sge sge; - - sge.addr = (uint64_t) (uintptr_t) addr; - sge.length = (uint32_t) length; - sge.lkey = mr ? mr->lkey : 0; - - return rdma_post_writev(id, context, &sge, 1, flags, remote_addr, rkey); -} - -static inline int -rdma_post_ud_send(struct rdma_cm_id *id, void *context, void *addr, - size_t length, struct ibv_mr *mr, int flags, - struct ibv_ah *ah, uint32_t remote_qpn) -{ - struct ibv_send_wr wr, *bad; - struct ibv_sge sge; - - sge.addr = (uint64_t) (uintptr_t) addr; - sge.length = (uint32_t) length; - sge.lkey = mr ? mr->lkey : 0; - - wr.wr_id = (uintptr_t) context; - wr.next = NULL; - wr.sg_list = &sge; - wr.num_sge = 1; - wr.opcode = IBV_WR_SEND; - wr.send_flags = flags; - wr.wr.ud.ah = ah; - wr.wr.ud.remote_qpn = remote_qpn; - wr.wr.ud.remote_qkey = RDMA_UDP_QKEY; - - return rdma_seterrno(ibv_post_send(id->qp, &wr, &bad)); -} - -static inline int -rdma_get_send_comp(struct rdma_cm_id *id, struct ibv_wc *wc) -{ - struct ibv_cq *cq; - void *context; - int ret; - - do { - ret = ibv_poll_cq(id->send_cq, 1, wc); - if (ret) - break; - - ret = ibv_req_notify_cq(id->send_cq, 0); - if (ret) - return rdma_seterrno(ret); - - ret = ibv_poll_cq(id->send_cq, 1, wc); - if (ret) - break; - - ret = ibv_get_cq_event(id->send_cq_channel, &cq, &context); - if (ret) - return ret; - - assert(cq == id->send_cq && context == id); - ibv_ack_cq_events(id->send_cq, 1); - } while (1); - - return (ret < 0) ? rdma_seterrno(ret) : ret; -} - -static inline int -rdma_get_recv_comp(struct rdma_cm_id *id, struct ibv_wc *wc) -{ - struct ibv_cq *cq; - void *context; - int ret; - - do { - ret = ibv_poll_cq(id->recv_cq, 1, wc); - if (ret) - break; - - ret = ibv_req_notify_cq(id->recv_cq, 0); - if (ret) - return rdma_seterrno(ret); - - ret = ibv_poll_cq(id->recv_cq, 1, wc); - if (ret) - break; - - ret = ibv_get_cq_event(id->recv_cq_channel, &cq, &context); - if (ret) - return ret; - - assert(cq == id->recv_cq && context == id); - ibv_ack_cq_events(id->recv_cq, 1); - } while (1); - - return (ret < 0) ? rdma_seterrno(ret) : ret; -} - -#ifdef __cplusplus -} -#endif - -#endif /* RDMA_CMA_H */ diff --git a/usr/rdma-core/librdmacm/rsocket.c b/usr/rdma-core/librdmacm/rsocket.c deleted file mode 100644 index 693d9eb5c..000000000 --- a/usr/rdma-core/librdmacm/rsocket.c +++ /dev/null @@ -1,4360 +0,0 @@ -/* - * Copyright (c) 2008-2014 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "cma.h" -#include "indexer.h" - -#define RS_OLAP_START_SIZE 2048 -#define RS_MAX_TRANSFER 65536 -#define RS_SNDLOWAT 2048 -#define RS_QP_MIN_SIZE 16 -#define RS_QP_MAX_SIZE 0xFFFE -#define RS_QP_CTRL_SIZE 4 /* must be power of 2 */ -#define RS_CONN_RETRIES 6 -#define RS_SGL_SIZE 2 -static struct index_map idm; -static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; - -struct rsocket; - -enum { - RS_SVC_NOOP, - RS_SVC_ADD_DGRAM, - RS_SVC_REM_DGRAM, - RS_SVC_ADD_KEEPALIVE, - RS_SVC_REM_KEEPALIVE, - RS_SVC_MOD_KEEPALIVE -}; - -struct rs_svc_msg { - uint32_t cmd; - uint32_t status; - struct rsocket *rs; -}; - -struct rs_svc { - pthread_t id; - int sock[2]; - int cnt; - int size; - int context_size; - void *(*run)(void *svc); - struct rsocket **rss; - void *contexts; -}; - -static struct pollfd *udp_svc_fds; -static void *udp_svc_run(void *arg); -static struct rs_svc udp_svc = { - .context_size = sizeof(*udp_svc_fds), - .run = udp_svc_run -}; -static uint32_t *tcp_svc_timeouts; -static void *tcp_svc_run(void *arg); -static struct rs_svc tcp_svc = { - .context_size = sizeof(*tcp_svc_timeouts), - .run = tcp_svc_run -}; - -static uint16_t def_iomap_size = 0; -static uint16_t def_inline = 64; -static uint16_t def_sqsize = 384; -static uint16_t def_rqsize = 384; -static uint32_t def_mem = (1 << 17); -static uint32_t def_wmem = (1 << 17); -static uint32_t polling_time = 10; - -/* - * Immediate data format is determined by the upper bits - * bit 31: message type, 0 - data, 1 - control - * bit 30: buffers updated, 0 - target, 1 - direct-receive - * bit 29: more data, 0 - end of transfer, 1 - more data available - * - * for data transfers: - * bits [28:0]: bytes transferred - * for control messages: - * SGL, CTRL - * bits [28-0]: receive credits granted - * IOMAP_SGL - * bits [28-16]: reserved, bits [15-0]: index - */ - -enum { - RS_OP_DATA, - RS_OP_RSVD_DATA_MORE, - RS_OP_WRITE, /* opcode is not transmitted over the network */ - RS_OP_RSVD_DRA_MORE, - RS_OP_SGL, - RS_OP_RSVD, - RS_OP_IOMAP_SGL, - RS_OP_CTRL -}; -#define rs_msg_set(op, data) ((op << 29) | (uint32_t) (data)) -#define rs_msg_op(imm_data) (imm_data >> 29) -#define rs_msg_data(imm_data) (imm_data & 0x1FFFFFFF) -#define RS_MSG_SIZE sizeof(uint32_t) - -#define RS_WR_ID_FLAG_RECV (((uint64_t) 1) << 63) -#define RS_WR_ID_FLAG_MSG_SEND (((uint64_t) 1) << 62) /* See RS_OPT_MSG_SEND */ -#define rs_send_wr_id(data) ((uint64_t) data) -#define rs_recv_wr_id(data) (RS_WR_ID_FLAG_RECV | (uint64_t) data) -#define rs_wr_is_recv(wr_id) (wr_id & RS_WR_ID_FLAG_RECV) -#define rs_wr_is_msg_send(wr_id) (wr_id & RS_WR_ID_FLAG_MSG_SEND) -#define rs_wr_data(wr_id) ((uint32_t) wr_id) - -enum { - RS_CTRL_DISCONNECT, - RS_CTRL_KEEPALIVE, - RS_CTRL_SHUTDOWN -}; - -struct rs_msg { - uint32_t op; - uint32_t data; -}; - -struct ds_qp; - -struct ds_rmsg { - struct ds_qp *qp; - uint32_t offset; - uint32_t length; -}; - -struct ds_smsg { - struct ds_smsg *next; -}; - -struct rs_sge { - uint64_t addr; - uint32_t key; - uint32_t length; -}; - -struct rs_iomap { - uint64_t offset; - struct rs_sge sge; -}; - -struct rs_iomap_mr { - uint64_t offset; - struct ibv_mr *mr; - dlist_entry entry; - _Atomic(int) refcnt; - int index; /* -1 if mapping is local and not in iomap_list */ -}; - -#define RS_MAX_CTRL_MSG (sizeof(struct rs_sge)) -#define rs_host_is_net() (__BYTE_ORDER == __BIG_ENDIAN) -#define RS_CONN_FLAG_NET (1 << 0) -#define RS_CONN_FLAG_IOMAP (1 << 1) - -struct rs_conn_data { - uint8_t version; - uint8_t flags; - __be16 credits; - uint8_t reserved[3]; - uint8_t target_iomap_size; - struct rs_sge target_sgl; - struct rs_sge data_buf; -}; - -struct rs_conn_private_data { - union { - struct rs_conn_data conn_data; - struct { - struct ib_connect_hdr ib_hdr; - struct rs_conn_data conn_data; - } af_ib; - }; -}; - -/* - * rsocket states are ordered as passive, connecting, connected, disconnected. - */ -enum rs_state { - rs_init, - rs_bound = 0x0001, - rs_listening = 0x0002, - rs_opening = 0x0004, - rs_resolving_addr = rs_opening | 0x0010, - rs_resolving_route = rs_opening | 0x0020, - rs_connecting = rs_opening | 0x0040, - rs_accepting = rs_opening | 0x0080, - rs_connected = 0x0100, - rs_writable = 0x0200, - rs_readable = 0x0400, - rs_connect_rdwr = rs_connected | rs_readable | rs_writable, - rs_connect_error = 0x0800, - rs_disconnected = 0x1000, - rs_error = 0x2000, -}; - -#define RS_OPT_SWAP_SGL (1 << 0) -/* - * iWarp does not support RDMA write with immediate data. For iWarp, we - * transfer rsocket messages as inline sends. - */ -#define RS_OPT_MSG_SEND (1 << 1) -#define RS_OPT_SVC_ACTIVE (1 << 2) - -union socket_addr { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; -}; - -struct ds_header { - uint8_t version; - uint8_t length; - __be16 port; - union { - __be32 ipv4; - struct { - __be32 flowinfo; - uint8_t addr[16]; - } ipv6; - } addr; -}; - -#define DS_IPV4_HDR_LEN 8 -#define DS_IPV6_HDR_LEN 24 - -struct ds_dest { - union socket_addr addr; /* must be first */ - struct ds_qp *qp; - struct ibv_ah *ah; - uint32_t qpn; -}; - -struct ds_qp { - dlist_entry list; - struct rsocket *rs; - struct rdma_cm_id *cm_id; - struct ds_header hdr; - struct ds_dest dest; - - struct ibv_mr *smr; - struct ibv_mr *rmr; - uint8_t *rbuf; - - int cq_armed; -}; - -struct rsocket { - int type; - int index; - fastlock_t slock; - fastlock_t rlock; - fastlock_t cq_lock; - fastlock_t cq_wait_lock; - fastlock_t map_lock; /* acquire slock first if needed */ - - union { - /* data stream */ - struct { - struct rdma_cm_id *cm_id; - uint64_t tcp_opts; - unsigned int keepalive_time; - - unsigned int ctrl_seqno; - unsigned int ctrl_max_seqno; - uint16_t sseq_no; - uint16_t sseq_comp; - uint16_t rseq_no; - uint16_t rseq_comp; - - int remote_sge; - struct rs_sge remote_sgl; - struct rs_sge remote_iomap; - - struct ibv_mr *target_mr; - int target_sge; - int target_iomap_size; - void *target_buffer_list; - volatile struct rs_sge *target_sgl; - struct rs_iomap *target_iomap; - - int rbuf_msg_index; - int rbuf_bytes_avail; - int rbuf_free_offset; - int rbuf_offset; - struct ibv_mr *rmr; - uint8_t *rbuf; - - int sbuf_bytes_avail; - struct ibv_mr *smr; - struct ibv_sge ssgl[2]; - }; - /* datagram */ - struct { - struct ds_qp *qp_list; - void *dest_map; - struct ds_dest *conn_dest; - - int udp_sock; - int epfd; - int rqe_avail; - struct ds_smsg *smsg_free; - }; - }; - - int opts; - int fd_flags; - uint64_t so_opts; - uint64_t ipv6_opts; - void *optval; - size_t optlen; - int state; - int cq_armed; - int retries; - int err; - - int sqe_avail; - uint32_t sbuf_size; - uint16_t sq_size; - uint16_t sq_inline; - - uint32_t rbuf_size; - uint16_t rq_size; - int rmsg_head; - int rmsg_tail; - union { - struct rs_msg *rmsg; - struct ds_rmsg *dmsg; - }; - - uint8_t *sbuf; - struct rs_iomap_mr *remote_iomappings; - dlist_entry iomap_list; - dlist_entry iomap_queue; - int iomap_pending; - int unack_cqe; -}; - -#define DS_UDP_TAG 0x55555555 - -struct ds_udp_header { - __be32 tag; - uint8_t version; - uint8_t op; - uint8_t length; - uint8_t reserved; - __be32 qpn; /* lower 8-bits reserved */ - union { - __be32 ipv4; - uint8_t ipv6[16]; - } addr; -}; - -#define DS_UDP_IPV4_HDR_LEN 16 -#define DS_UDP_IPV6_HDR_LEN 28 - -#define ds_next_qp(qp) container_of((qp)->list.next, struct ds_qp, list) - -static void write_all(int fd, const void *msg, size_t len) -{ - // FIXME: if fd is a socket this really needs to handle EINTR and other conditions. - ssize_t rc = write(fd, msg, len); - assert(rc == len); -} - -static void read_all(int fd, void *msg, size_t len) -{ - // FIXME: if fd is a socket this really needs to handle EINTR and other conditions. - ssize_t rc = read(fd, msg, len); - assert(rc == len); -} - -static void ds_insert_qp(struct rsocket *rs, struct ds_qp *qp) -{ - if (!rs->qp_list) - dlist_init(&qp->list); - else - dlist_insert_head(&qp->list, &rs->qp_list->list); - rs->qp_list = qp; -} - -static void ds_remove_qp(struct rsocket *rs, struct ds_qp *qp) -{ - if (qp->list.next != &qp->list) { - rs->qp_list = ds_next_qp(qp); - dlist_remove(&qp->list); - } else { - rs->qp_list = NULL; - } -} - -static int rs_notify_svc(struct rs_svc *svc, struct rsocket *rs, int cmd) -{ - struct rs_svc_msg msg; - int ret; - - pthread_mutex_lock(&mut); - if (!svc->cnt) { - ret = socketpair(AF_UNIX, SOCK_STREAM, 0, svc->sock); - if (ret) - goto unlock; - - ret = pthread_create(&svc->id, NULL, svc->run, svc); - if (ret) { - ret = ERR(ret); - goto closepair; - } - } - - msg.cmd = cmd; - msg.status = EINVAL; - msg.rs = rs; - write_all(svc->sock[0], &msg, sizeof msg); - read_all(svc->sock[0], &msg, sizeof msg); - ret = rdma_seterrno(msg.status); - if (svc->cnt) - goto unlock; - - pthread_join(svc->id, NULL); -closepair: - close(svc->sock[0]); - close(svc->sock[1]); -unlock: - pthread_mutex_unlock(&mut); - return ret; -} - -static int ds_compare_addr(const void *dst1, const void *dst2) -{ - const struct sockaddr *sa1, *sa2; - size_t len; - - sa1 = (const struct sockaddr *) dst1; - sa2 = (const struct sockaddr *) dst2; - - len = (sa1->sa_family == AF_INET6 && sa2->sa_family == AF_INET6) ? - sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in); - return memcmp(dst1, dst2, len); -} - -static int rs_value_to_scale(int value, int bits) -{ - return value <= (1 << (bits - 1)) ? - value : (1 << (bits - 1)) | (value >> bits); -} - -static int rs_scale_to_value(int value, int bits) -{ - return value <= (1 << (bits - 1)) ? - value : (value & ~(1 << (bits - 1))) << bits; -} - -/* gcc > ~5 will not allow (void)fscanf to suppress -Wunused-result, but this - will do it. In this case ignoring the result is OK (but horribly - unfriendly to user) since the library has a sane default. */ -#define failable_fscanf(f, fmt, ...) \ - { \ - int rc = fscanf(f, fmt, __VA_ARGS__); \ - (void) rc; \ - } - -static void rs_configure(void) -{ - FILE *f; - static int init; - - if (init) - return; - - pthread_mutex_lock(&mut); - if (init) - goto out; - - if (ucma_init()) - goto out; - ucma_ib_init(); - - if ((f = fopen(RS_CONF_DIR "/polling_time", "r"))) { - failable_fscanf(f, "%u", &polling_time); - fclose(f); - } - - if ((f = fopen(RS_CONF_DIR "/inline_default", "r"))) { - failable_fscanf(f, "%hu", &def_inline); - fclose(f); - } - - if ((f = fopen(RS_CONF_DIR "/sqsize_default", "r"))) { - failable_fscanf(f, "%hu", &def_sqsize); - fclose(f); - } - - if ((f = fopen(RS_CONF_DIR "/rqsize_default", "r"))) { - failable_fscanf(f, "%hu", &def_rqsize); - fclose(f); - } - - if ((f = fopen(RS_CONF_DIR "/mem_default", "r"))) { - failable_fscanf(f, "%u", &def_mem); - fclose(f); - - if (def_mem < 1) - def_mem = 1; - } - - if ((f = fopen(RS_CONF_DIR "/wmem_default", "r"))) { - failable_fscanf(f, "%u", &def_wmem); - fclose(f); - if (def_wmem < RS_SNDLOWAT) - def_wmem = RS_SNDLOWAT << 1; - } - - if ((f = fopen(RS_CONF_DIR "/iomap_size", "r"))) { - failable_fscanf(f, "%hu", &def_iomap_size); - fclose(f); - - /* round to supported values */ - def_iomap_size = (uint8_t) rs_value_to_scale( - (uint16_t) rs_scale_to_value(def_iomap_size, 8), 8); - } - init = 1; -out: - pthread_mutex_unlock(&mut); -} - -static int rs_insert(struct rsocket *rs, int index) -{ - pthread_mutex_lock(&mut); - rs->index = idm_set(&idm, index, rs); - pthread_mutex_unlock(&mut); - return rs->index; -} - -static void rs_remove(struct rsocket *rs) -{ - pthread_mutex_lock(&mut); - idm_clear(&idm, rs->index); - pthread_mutex_unlock(&mut); -} - -/* We only inherit from listening sockets */ -static struct rsocket *rs_alloc(struct rsocket *inherited_rs, int type) -{ - struct rsocket *rs; - - rs = calloc(1, sizeof(*rs)); - if (!rs) - return NULL; - - rs->type = type; - rs->index = -1; - if (type == SOCK_DGRAM) { - rs->udp_sock = -1; - rs->epfd = -1; - } - - if (inherited_rs) { - rs->sbuf_size = inherited_rs->sbuf_size; - rs->rbuf_size = inherited_rs->rbuf_size; - rs->sq_inline = inherited_rs->sq_inline; - rs->sq_size = inherited_rs->sq_size; - rs->rq_size = inherited_rs->rq_size; - if (type == SOCK_STREAM) { - rs->ctrl_max_seqno = inherited_rs->ctrl_max_seqno; - rs->target_iomap_size = inherited_rs->target_iomap_size; - } - } else { - rs->sbuf_size = def_wmem; - rs->rbuf_size = def_mem; - rs->sq_inline = def_inline; - rs->sq_size = def_sqsize; - rs->rq_size = def_rqsize; - if (type == SOCK_STREAM) { - rs->ctrl_max_seqno = RS_QP_CTRL_SIZE; - rs->target_iomap_size = def_iomap_size; - } - } - fastlock_init(&rs->slock); - fastlock_init(&rs->rlock); - fastlock_init(&rs->cq_lock); - fastlock_init(&rs->cq_wait_lock); - fastlock_init(&rs->map_lock); - dlist_init(&rs->iomap_list); - dlist_init(&rs->iomap_queue); - return rs; -} - -static int rs_set_nonblocking(struct rsocket *rs, int arg) -{ - struct ds_qp *qp; - int ret = 0; - - if (rs->type == SOCK_STREAM) { - if (rs->cm_id->recv_cq_channel) - ret = fcntl(rs->cm_id->recv_cq_channel->fd, F_SETFL, arg); - - if (!ret && rs->state < rs_connected) - ret = fcntl(rs->cm_id->channel->fd, F_SETFL, arg); - } else { - ret = fcntl(rs->epfd, F_SETFL, arg); - if (!ret && rs->qp_list) { - qp = rs->qp_list; - do { - ret = fcntl(qp->cm_id->recv_cq_channel->fd, - F_SETFL, arg); - qp = ds_next_qp(qp); - } while (qp != rs->qp_list && !ret); - } - } - - return ret; -} - -static void rs_set_qp_size(struct rsocket *rs) -{ - uint16_t max_size; - - max_size = min(ucma_max_qpsize(rs->cm_id), RS_QP_MAX_SIZE); - - if (rs->sq_size > max_size) - rs->sq_size = max_size; - else if (rs->sq_size < RS_QP_MIN_SIZE) - rs->sq_size = RS_QP_MIN_SIZE; - - if (rs->rq_size > max_size) - rs->rq_size = max_size; - else if (rs->rq_size < RS_QP_MIN_SIZE) - rs->rq_size = RS_QP_MIN_SIZE; -} - -static void ds_set_qp_size(struct rsocket *rs) -{ - uint16_t max_size; - - max_size = min(ucma_max_qpsize(NULL), RS_QP_MAX_SIZE); - - if (rs->sq_size > max_size) - rs->sq_size = max_size; - if (rs->rq_size > max_size) - rs->rq_size = max_size; - - if (rs->rq_size > (rs->rbuf_size / RS_SNDLOWAT)) - rs->rq_size = rs->rbuf_size / RS_SNDLOWAT; - else - rs->rbuf_size = rs->rq_size * RS_SNDLOWAT; - - if (rs->sq_size > (rs->sbuf_size / RS_SNDLOWAT)) - rs->sq_size = rs->sbuf_size / RS_SNDLOWAT; - else - rs->sbuf_size = rs->sq_size * RS_SNDLOWAT; -} - -static int rs_init_bufs(struct rsocket *rs) -{ - uint32_t total_rbuf_size, total_sbuf_size; - size_t len; - - rs->rmsg = calloc(rs->rq_size + 1, sizeof(*rs->rmsg)); - if (!rs->rmsg) - return ERR(ENOMEM); - - total_sbuf_size = rs->sbuf_size; - if (rs->sq_inline < RS_MAX_CTRL_MSG) - total_sbuf_size += RS_MAX_CTRL_MSG * RS_QP_CTRL_SIZE; - rs->sbuf = calloc(total_sbuf_size, 1); - if (!rs->sbuf) - return ERR(ENOMEM); - - rs->smr = rdma_reg_msgs(rs->cm_id, rs->sbuf, total_sbuf_size); - if (!rs->smr) - return -1; - - len = sizeof(*rs->target_sgl) * RS_SGL_SIZE + - sizeof(*rs->target_iomap) * rs->target_iomap_size; - rs->target_buffer_list = malloc(len); - if (!rs->target_buffer_list) - return ERR(ENOMEM); - - rs->target_mr = rdma_reg_write(rs->cm_id, rs->target_buffer_list, len); - if (!rs->target_mr) - return -1; - - memset(rs->target_buffer_list, 0, len); - rs->target_sgl = rs->target_buffer_list; - if (rs->target_iomap_size) - rs->target_iomap = (struct rs_iomap *) (rs->target_sgl + RS_SGL_SIZE); - - total_rbuf_size = rs->rbuf_size; - if (rs->opts & RS_OPT_MSG_SEND) - total_rbuf_size += rs->rq_size * RS_MSG_SIZE; - rs->rbuf = calloc(total_rbuf_size, 1); - if (!rs->rbuf) - return ERR(ENOMEM); - - rs->rmr = rdma_reg_write(rs->cm_id, rs->rbuf, total_rbuf_size); - if (!rs->rmr) - return -1; - - rs->ssgl[0].addr = rs->ssgl[1].addr = (uintptr_t) rs->sbuf; - rs->sbuf_bytes_avail = rs->sbuf_size; - rs->ssgl[0].lkey = rs->ssgl[1].lkey = rs->smr->lkey; - - rs->rbuf_free_offset = rs->rbuf_size >> 1; - rs->rbuf_bytes_avail = rs->rbuf_size >> 1; - rs->sqe_avail = rs->sq_size - rs->ctrl_max_seqno; - rs->rseq_comp = rs->rq_size >> 1; - return 0; -} - -static int ds_init_bufs(struct ds_qp *qp) -{ - qp->rbuf = calloc(qp->rs->rbuf_size + sizeof(struct ibv_grh), 1); - if (!qp->rbuf) - return ERR(ENOMEM); - - qp->smr = rdma_reg_msgs(qp->cm_id, qp->rs->sbuf, qp->rs->sbuf_size); - if (!qp->smr) - return -1; - - qp->rmr = rdma_reg_msgs(qp->cm_id, qp->rbuf, qp->rs->rbuf_size + - sizeof(struct ibv_grh)); - if (!qp->rmr) - return -1; - - return 0; -} - -/* - * If a user is waiting on a datagram rsocket through poll or select, then - * we need the first completion to generate an event on the related epoll fd - * in order to signal the user. We arm the CQ on creation for this purpose - */ -static int rs_create_cq(struct rsocket *rs, struct rdma_cm_id *cm_id) -{ - cm_id->recv_cq_channel = ibv_create_comp_channel(cm_id->verbs); - if (!cm_id->recv_cq_channel) - return -1; - - cm_id->recv_cq = ibv_create_cq(cm_id->verbs, rs->sq_size + rs->rq_size, - cm_id, cm_id->recv_cq_channel, 0); - if (!cm_id->recv_cq) - goto err1; - - if (rs->fd_flags & O_NONBLOCK) { - if (set_fd_nonblock(cm_id->recv_cq_channel->fd, true)) - goto err2; - } - - ibv_req_notify_cq(cm_id->recv_cq, 0); - cm_id->send_cq_channel = cm_id->recv_cq_channel; - cm_id->send_cq = cm_id->recv_cq; - return 0; - -err2: - ibv_destroy_cq(cm_id->recv_cq); - cm_id->recv_cq = NULL; -err1: - ibv_destroy_comp_channel(cm_id->recv_cq_channel); - cm_id->recv_cq_channel = NULL; - return -1; -} - -static inline int rs_post_recv(struct rsocket *rs) -{ - struct ibv_recv_wr wr, *bad; - struct ibv_sge sge; - - wr.next = NULL; - if (!(rs->opts & RS_OPT_MSG_SEND)) { - wr.wr_id = rs_recv_wr_id(0); - wr.sg_list = NULL; - wr.num_sge = 0; - } else { - wr.wr_id = rs_recv_wr_id(rs->rbuf_msg_index); - sge.addr = (uintptr_t) rs->rbuf + rs->rbuf_size + - (rs->rbuf_msg_index * RS_MSG_SIZE); - sge.length = RS_MSG_SIZE; - sge.lkey = rs->rmr->lkey; - - wr.sg_list = &sge; - wr.num_sge = 1; - if(++rs->rbuf_msg_index == rs->rq_size) - rs->rbuf_msg_index = 0; - } - - return rdma_seterrno(ibv_post_recv(rs->cm_id->qp, &wr, &bad)); -} - -static inline int ds_post_recv(struct rsocket *rs, struct ds_qp *qp, uint32_t offset) -{ - struct ibv_recv_wr wr, *bad; - struct ibv_sge sge[2]; - - sge[0].addr = (uintptr_t) qp->rbuf + rs->rbuf_size; - sge[0].length = sizeof(struct ibv_grh); - sge[0].lkey = qp->rmr->lkey; - sge[1].addr = (uintptr_t) qp->rbuf + offset; - sge[1].length = RS_SNDLOWAT; - sge[1].lkey = qp->rmr->lkey; - - wr.wr_id = rs_recv_wr_id(offset); - wr.next = NULL; - wr.sg_list = sge; - wr.num_sge = 2; - - return rdma_seterrno(ibv_post_recv(qp->cm_id->qp, &wr, &bad)); -} - -static int rs_create_ep(struct rsocket *rs) -{ - struct ibv_qp_init_attr qp_attr; - int i, ret; - - rs_set_qp_size(rs); - if (rs->cm_id->verbs->device->transport_type == IBV_TRANSPORT_IWARP) - rs->opts |= RS_OPT_MSG_SEND; - ret = rs_create_cq(rs, rs->cm_id); - if (ret) - return ret; - - memset(&qp_attr, 0, sizeof qp_attr); - qp_attr.qp_context = rs; - qp_attr.send_cq = rs->cm_id->send_cq; - qp_attr.recv_cq = rs->cm_id->recv_cq; - qp_attr.qp_type = IBV_QPT_RC; - qp_attr.sq_sig_all = 1; - qp_attr.cap.max_send_wr = rs->sq_size; - qp_attr.cap.max_recv_wr = rs->rq_size; - qp_attr.cap.max_send_sge = 2; - qp_attr.cap.max_recv_sge = 1; - qp_attr.cap.max_inline_data = rs->sq_inline; - - ret = rdma_create_qp(rs->cm_id, NULL, &qp_attr); - if (ret) - return ret; - - rs->sq_inline = qp_attr.cap.max_inline_data; - if ((rs->opts & RS_OPT_MSG_SEND) && (rs->sq_inline < RS_MSG_SIZE)) - return ERR(ENOTSUP); - - ret = rs_init_bufs(rs); - if (ret) - return ret; - - for (i = 0; i < rs->rq_size; i++) { - ret = rs_post_recv(rs); - if (ret) - return ret; - } - return 0; -} - -static void rs_release_iomap_mr(struct rs_iomap_mr *iomr) -{ - if (atomic_fetch_sub(&iomr->refcnt, 1) != 1) - return; - - dlist_remove(&iomr->entry); - ibv_dereg_mr(iomr->mr); - if (iomr->index >= 0) - iomr->mr = NULL; - else - free(iomr); -} - -static void rs_free_iomappings(struct rsocket *rs) -{ - struct rs_iomap_mr *iomr; - - while (!dlist_empty(&rs->iomap_list)) { - iomr = container_of(rs->iomap_list.next, - struct rs_iomap_mr, entry); - riounmap(rs->index, iomr->mr->addr, iomr->mr->length); - } - while (!dlist_empty(&rs->iomap_queue)) { - iomr = container_of(rs->iomap_queue.next, - struct rs_iomap_mr, entry); - riounmap(rs->index, iomr->mr->addr, iomr->mr->length); - } -} - -static void ds_free_qp(struct ds_qp *qp) -{ - if (qp->smr) - rdma_dereg_mr(qp->smr); - - if (qp->rbuf) { - if (qp->rmr) - rdma_dereg_mr(qp->rmr); - free(qp->rbuf); - } - - if (qp->cm_id) { - if (qp->cm_id->qp) { - tdelete(&qp->dest.addr, &qp->rs->dest_map, ds_compare_addr); - epoll_ctl(qp->rs->epfd, EPOLL_CTL_DEL, - qp->cm_id->recv_cq_channel->fd, NULL); - rdma_destroy_qp(qp->cm_id); - } - rdma_destroy_id(qp->cm_id); - } - - free(qp); -} - -static void ds_free(struct rsocket *rs) -{ - struct ds_qp *qp; - - if (rs->udp_sock >= 0) - close(rs->udp_sock); - - if (rs->index >= 0) - rs_remove(rs); - - if (rs->dmsg) - free(rs->dmsg); - - while ((qp = rs->qp_list)) { - ds_remove_qp(rs, qp); - ds_free_qp(qp); - } - - if (rs->epfd >= 0) - close(rs->epfd); - - if (rs->sbuf) - free(rs->sbuf); - - tdestroy(rs->dest_map, free); - fastlock_destroy(&rs->map_lock); - fastlock_destroy(&rs->cq_wait_lock); - fastlock_destroy(&rs->cq_lock); - fastlock_destroy(&rs->rlock); - fastlock_destroy(&rs->slock); - free(rs); -} - -static void rs_free(struct rsocket *rs) -{ - if (rs->type == SOCK_DGRAM) { - ds_free(rs); - return; - } - - if (rs->rmsg) - free(rs->rmsg); - - if (rs->sbuf) { - if (rs->smr) - rdma_dereg_mr(rs->smr); - free(rs->sbuf); - } - - if (rs->rbuf) { - if (rs->rmr) - rdma_dereg_mr(rs->rmr); - free(rs->rbuf); - } - - if (rs->target_buffer_list) { - if (rs->target_mr) - rdma_dereg_mr(rs->target_mr); - free(rs->target_buffer_list); - } - - if (rs->index >= 0) - rs_remove(rs); - - if (rs->cm_id) { - rs_free_iomappings(rs); - if (rs->cm_id->qp) { - ibv_ack_cq_events(rs->cm_id->recv_cq, rs->unack_cqe); - rdma_destroy_qp(rs->cm_id); - } - rdma_destroy_id(rs->cm_id); - } - - fastlock_destroy(&rs->map_lock); - fastlock_destroy(&rs->cq_wait_lock); - fastlock_destroy(&rs->cq_lock); - fastlock_destroy(&rs->rlock); - fastlock_destroy(&rs->slock); - free(rs); -} - -static size_t rs_conn_data_offset(struct rsocket *rs) -{ - return (rs->cm_id->route.addr.src_addr.sa_family == AF_IB) ? - sizeof(struct ib_connect_hdr) : 0; -} - -static void rs_format_conn_data(struct rsocket *rs, struct rs_conn_data *conn) -{ - conn->version = 1; - conn->flags = RS_CONN_FLAG_IOMAP | - (rs_host_is_net() ? RS_CONN_FLAG_NET : 0); - conn->credits = htobe16(rs->rq_size); - memset(conn->reserved, 0, sizeof conn->reserved); - conn->target_iomap_size = (uint8_t) rs_value_to_scale(rs->target_iomap_size, 8); - - conn->target_sgl.addr = (__force uint64_t)htobe64((uintptr_t) rs->target_sgl); - conn->target_sgl.length = (__force uint32_t)htobe32(RS_SGL_SIZE); - conn->target_sgl.key = (__force uint32_t)htobe32(rs->target_mr->rkey); - - conn->data_buf.addr = (__force uint64_t)htobe64((uintptr_t) rs->rbuf); - conn->data_buf.length = (__force uint32_t)htobe32(rs->rbuf_size >> 1); - conn->data_buf.key = (__force uint32_t)htobe32(rs->rmr->rkey); -} - -static void rs_save_conn_data(struct rsocket *rs, struct rs_conn_data *conn) -{ - rs->remote_sgl.addr = be64toh((__force __be64)conn->target_sgl.addr); - rs->remote_sgl.length = be32toh((__force __be32)conn->target_sgl.length); - rs->remote_sgl.key = be32toh((__force __be32)conn->target_sgl.key); - rs->remote_sge = 1; - if ((rs_host_is_net() && !(conn->flags & RS_CONN_FLAG_NET)) || - (!rs_host_is_net() && (conn->flags & RS_CONN_FLAG_NET))) - rs->opts = RS_OPT_SWAP_SGL; - - if (conn->flags & RS_CONN_FLAG_IOMAP) { - rs->remote_iomap.addr = rs->remote_sgl.addr + - sizeof(rs->remote_sgl) * rs->remote_sgl.length; - rs->remote_iomap.length = rs_scale_to_value(conn->target_iomap_size, 8); - rs->remote_iomap.key = rs->remote_sgl.key; - } - - rs->target_sgl[0].addr = be64toh((__force __be64)conn->data_buf.addr); - rs->target_sgl[0].length = be32toh((__force __be32)conn->data_buf.length); - rs->target_sgl[0].key = be32toh((__force __be32)conn->data_buf.key); - - rs->sseq_comp = be16toh(conn->credits); -} - -static int ds_init(struct rsocket *rs, int domain) -{ - rs->udp_sock = socket(domain, SOCK_DGRAM, 0); - if (rs->udp_sock < 0) - return rs->udp_sock; - - rs->epfd = epoll_create(2); - if (rs->epfd < 0) - return rs->epfd; - - return 0; -} - -static int ds_init_ep(struct rsocket *rs) -{ - struct ds_smsg *msg; - int i, ret; - - ds_set_qp_size(rs); - - rs->sbuf = calloc(rs->sq_size, RS_SNDLOWAT); - if (!rs->sbuf) - return ERR(ENOMEM); - - rs->dmsg = calloc(rs->rq_size + 1, sizeof(*rs->dmsg)); - if (!rs->dmsg) - return ERR(ENOMEM); - - rs->sqe_avail = rs->sq_size; - rs->rqe_avail = rs->rq_size; - - rs->smsg_free = (struct ds_smsg *) rs->sbuf; - msg = rs->smsg_free; - for (i = 0; i < rs->sq_size - 1; i++) { - msg->next = (void *) msg + RS_SNDLOWAT; - msg = msg->next; - } - msg->next = NULL; - - ret = rs_notify_svc(&udp_svc, rs, RS_SVC_ADD_DGRAM); - if (ret) - return ret; - - rs->state = rs_readable | rs_writable; - return 0; -} - -int rsocket(int domain, int type, int protocol) -{ - struct rsocket *rs; - int index, ret; - - if ((domain != AF_INET && domain != AF_INET6 && domain != AF_IB) || - ((type != SOCK_STREAM) && (type != SOCK_DGRAM)) || - (type == SOCK_STREAM && protocol && protocol != IPPROTO_TCP) || - (type == SOCK_DGRAM && protocol && protocol != IPPROTO_UDP)) - return ERR(ENOTSUP); - - rs_configure(); - rs = rs_alloc(NULL, type); - if (!rs) - return ERR(ENOMEM); - - if (type == SOCK_STREAM) { - ret = rdma_create_id(NULL, &rs->cm_id, rs, RDMA_PS_TCP); - if (ret) - goto err; - - rs->cm_id->route.addr.src_addr.sa_family = domain; - index = rs->cm_id->channel->fd; - } else { - ret = ds_init(rs, domain); - if (ret) - goto err; - - index = rs->udp_sock; - } - - ret = rs_insert(rs, index); - if (ret < 0) - goto err; - - return rs->index; - -err: - rs_free(rs); - return ret; -} - -int rbind(int socket, const struct sockaddr *addr, socklen_t addrlen) -{ - struct rsocket *rs; - int ret; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_STREAM) { - ret = rdma_bind_addr(rs->cm_id, (struct sockaddr *) addr); - if (!ret) - rs->state = rs_bound; - } else { - if (rs->state == rs_init) { - ret = ds_init_ep(rs); - if (ret) - return ret; - } - ret = bind(rs->udp_sock, addr, addrlen); - } - return ret; -} - -int rlisten(int socket, int backlog) -{ - struct rsocket *rs; - int ret; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - - if (rs->state != rs_listening) { - ret = rdma_listen(rs->cm_id, backlog); - if (!ret) - rs->state = rs_listening; - } else { - ret = 0; - } - return ret; -} - -/* - * Nonblocking is usually not inherited between sockets, but we need to - * inherit it here to establish the connection only. This is needed to - * prevent rdma_accept from blocking until the remote side finishes - * establishing the connection. If we were to allow rdma_accept to block, - * then a single thread cannot establish a connection with itself, or - * two threads which try to connect to each other can deadlock trying to - * form a connection. - * - * Data transfers on the new socket remain blocking unless the user - * specifies otherwise through rfcntl. - */ -int raccept(int socket, struct sockaddr *addr, socklen_t *addrlen) -{ - struct rsocket *rs, *new_rs; - struct rdma_conn_param param; - struct rs_conn_data *creq, cresp; - int ret; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - new_rs = rs_alloc(rs, rs->type); - if (!new_rs) - return ERR(ENOMEM); - - ret = rdma_get_request(rs->cm_id, &new_rs->cm_id); - if (ret) - goto err; - - ret = rs_insert(new_rs, new_rs->cm_id->channel->fd); - if (ret < 0) - goto err; - - creq = (struct rs_conn_data *) - (new_rs->cm_id->event->param.conn.private_data + rs_conn_data_offset(rs)); - if (creq->version != 1) { - ret = ERR(ENOTSUP); - goto err; - } - - if (rs->fd_flags & O_NONBLOCK) - set_fd_nonblock(new_rs->cm_id->channel->fd, true); - - ret = rs_create_ep(new_rs); - if (ret) - goto err; - - rs_save_conn_data(new_rs, creq); - param = new_rs->cm_id->event->param.conn; - rs_format_conn_data(new_rs, &cresp); - param.private_data = &cresp; - param.private_data_len = sizeof cresp; - ret = rdma_accept(new_rs->cm_id, ¶m); - if (!ret) - new_rs->state = rs_connect_rdwr; - else if (errno == EAGAIN || errno == EWOULDBLOCK) - new_rs->state = rs_accepting; - else - goto err; - - if (addr && addrlen) - rgetpeername(new_rs->index, addr, addrlen); - return new_rs->index; - -err: - rs_free(new_rs); - return ret; -} - -static int rs_do_connect(struct rsocket *rs) -{ - struct rdma_conn_param param; - struct rs_conn_private_data cdata; - struct rs_conn_data *creq, *cresp; - int to, ret; - - switch (rs->state) { - case rs_init: - case rs_bound: -resolve_addr: - to = 1000 << rs->retries++; - ret = rdma_resolve_addr(rs->cm_id, NULL, - &rs->cm_id->route.addr.dst_addr, to); - if (!ret) - goto resolve_route; - if (errno == EAGAIN || errno == EWOULDBLOCK) - rs->state = rs_resolving_addr; - break; - case rs_resolving_addr: - ret = ucma_complete(rs->cm_id); - if (ret) { - if (errno == ETIMEDOUT && rs->retries <= RS_CONN_RETRIES) - goto resolve_addr; - break; - } - - rs->retries = 0; -resolve_route: - to = 1000 << rs->retries++; - if (rs->optval) { - ret = rdma_set_option(rs->cm_id, RDMA_OPTION_IB, - RDMA_OPTION_IB_PATH, rs->optval, - rs->optlen); - free(rs->optval); - rs->optval = NULL; - if (!ret) { - rs->state = rs_resolving_route; - goto resolving_route; - } - } else { - ret = rdma_resolve_route(rs->cm_id, to); - if (!ret) - goto do_connect; - } - if (errno == EAGAIN || errno == EWOULDBLOCK) - rs->state = rs_resolving_route; - break; - case rs_resolving_route: -resolving_route: - ret = ucma_complete(rs->cm_id); - if (ret) { - if (errno == ETIMEDOUT && rs->retries <= RS_CONN_RETRIES) - goto resolve_route; - break; - } -do_connect: - ret = rs_create_ep(rs); - if (ret) - break; - - memset(¶m, 0, sizeof param); - creq = (void *) &cdata + rs_conn_data_offset(rs); - rs_format_conn_data(rs, creq); - param.private_data = (void *) creq - rs_conn_data_offset(rs); - param.private_data_len = sizeof(*creq) + rs_conn_data_offset(rs); - param.flow_control = 1; - param.retry_count = 7; - param.rnr_retry_count = 7; - /* work-around: iWarp issues RDMA read during connection */ - if (rs->opts & RS_OPT_MSG_SEND) - param.initiator_depth = 1; - rs->retries = 0; - - ret = rdma_connect(rs->cm_id, ¶m); - if (!ret) - goto connected; - if (errno == EAGAIN || errno == EWOULDBLOCK) - rs->state = rs_connecting; - break; - case rs_connecting: - ret = ucma_complete(rs->cm_id); - if (ret) - break; -connected: - cresp = (struct rs_conn_data *) rs->cm_id->event->param.conn.private_data; - if (cresp->version != 1) { - ret = ERR(ENOTSUP); - break; - } - - rs_save_conn_data(rs, cresp); - rs->state = rs_connect_rdwr; - break; - case rs_accepting: - if (!(rs->fd_flags & O_NONBLOCK)) - set_fd_nonblock(rs->cm_id->channel->fd, true); - - ret = ucma_complete(rs->cm_id); - if (ret) - break; - - rs->state = rs_connect_rdwr; - break; - default: - ret = ERR(EINVAL); - break; - } - - if (ret) { - if (errno == EAGAIN || errno == EWOULDBLOCK) { - errno = EINPROGRESS; - } else { - rs->state = rs_connect_error; - rs->err = errno; - } - } - return ret; -} - -static int rs_any_addr(const union socket_addr *addr) -{ - if (addr->sa.sa_family == AF_INET) { - return (addr->sin.sin_addr.s_addr == htobe32(INADDR_ANY) || - addr->sin.sin_addr.s_addr == htobe32(INADDR_LOOPBACK)); - } else { - return (!memcmp(&addr->sin6.sin6_addr, &in6addr_any, 16) || - !memcmp(&addr->sin6.sin6_addr, &in6addr_loopback, 16)); - } -} - -static int ds_get_src_addr(struct rsocket *rs, - const struct sockaddr *dest_addr, socklen_t dest_len, - union socket_addr *src_addr, socklen_t *src_len) -{ - int sock, ret; - __be16 port; - - *src_len = sizeof(*src_addr); - ret = getsockname(rs->udp_sock, &src_addr->sa, src_len); - if (ret || !rs_any_addr(src_addr)) - return ret; - - port = src_addr->sin.sin_port; - sock = socket(dest_addr->sa_family, SOCK_DGRAM, 0); - if (sock < 0) - return sock; - - ret = connect(sock, dest_addr, dest_len); - if (ret) - goto out; - - *src_len = sizeof(*src_addr); - ret = getsockname(sock, &src_addr->sa, src_len); - src_addr->sin.sin_port = port; -out: - close(sock); - return ret; -} - -static void ds_format_hdr(struct ds_header *hdr, union socket_addr *addr) -{ - if (addr->sa.sa_family == AF_INET) { - hdr->version = 4; - hdr->length = DS_IPV4_HDR_LEN; - hdr->port = addr->sin.sin_port; - hdr->addr.ipv4 = addr->sin.sin_addr.s_addr; - } else { - hdr->version = 6; - hdr->length = DS_IPV6_HDR_LEN; - hdr->port = addr->sin6.sin6_port; - hdr->addr.ipv6.flowinfo= addr->sin6.sin6_flowinfo; - memcpy(&hdr->addr.ipv6.addr, &addr->sin6.sin6_addr, 16); - } -} - -static int ds_add_qp_dest(struct ds_qp *qp, union socket_addr *addr, - socklen_t addrlen) -{ - struct ibv_port_attr port_attr; - struct ibv_ah_attr attr; - int ret; - - memcpy(&qp->dest.addr, addr, addrlen); - qp->dest.qp = qp; - qp->dest.qpn = qp->cm_id->qp->qp_num; - - ret = ibv_query_port(qp->cm_id->verbs, qp->cm_id->port_num, &port_attr); - if (ret) - return ret; - - memset(&attr, 0, sizeof attr); - attr.dlid = port_attr.lid; - attr.port_num = qp->cm_id->port_num; - qp->dest.ah = ibv_create_ah(qp->cm_id->pd, &attr); - if (!qp->dest.ah) - return ERR(ENOMEM); - - tsearch(&qp->dest.addr, &qp->rs->dest_map, ds_compare_addr); - return 0; -} - -static int ds_create_qp(struct rsocket *rs, union socket_addr *src_addr, - socklen_t addrlen, struct ds_qp **new_qp) -{ - struct ds_qp *qp; - struct ibv_qp_init_attr qp_attr; - struct epoll_event event; - int i, ret; - - qp = calloc(1, sizeof(*qp)); - if (!qp) - return ERR(ENOMEM); - - qp->rs = rs; - ret = rdma_create_id(NULL, &qp->cm_id, qp, RDMA_PS_UDP); - if (ret) - goto err; - - ds_format_hdr(&qp->hdr, src_addr); - ret = rdma_bind_addr(qp->cm_id, &src_addr->sa); - if (ret) - goto err; - - ret = ds_init_bufs(qp); - if (ret) - goto err; - - ret = rs_create_cq(rs, qp->cm_id); - if (ret) - goto err; - - memset(&qp_attr, 0, sizeof qp_attr); - qp_attr.qp_context = qp; - qp_attr.send_cq = qp->cm_id->send_cq; - qp_attr.recv_cq = qp->cm_id->recv_cq; - qp_attr.qp_type = IBV_QPT_UD; - qp_attr.sq_sig_all = 1; - qp_attr.cap.max_send_wr = rs->sq_size; - qp_attr.cap.max_recv_wr = rs->rq_size; - qp_attr.cap.max_send_sge = 1; - qp_attr.cap.max_recv_sge = 2; - qp_attr.cap.max_inline_data = rs->sq_inline; - ret = rdma_create_qp(qp->cm_id, NULL, &qp_attr); - if (ret) - goto err; - - rs->sq_inline = qp_attr.cap.max_inline_data; - ret = ds_add_qp_dest(qp, src_addr, addrlen); - if (ret) - goto err; - - event.events = EPOLLIN; - event.data.ptr = qp; - ret = epoll_ctl(rs->epfd, EPOLL_CTL_ADD, - qp->cm_id->recv_cq_channel->fd, &event); - if (ret) - goto err; - - for (i = 0; i < rs->rq_size; i++) { - ret = ds_post_recv(rs, qp, i * RS_SNDLOWAT); - if (ret) - goto err; - } - - ds_insert_qp(rs, qp); - *new_qp = qp; - return 0; -err: - ds_free_qp(qp); - return ret; -} - -static int ds_get_qp(struct rsocket *rs, union socket_addr *src_addr, - socklen_t addrlen, struct ds_qp **qp) -{ - if (rs->qp_list) { - *qp = rs->qp_list; - do { - if (!ds_compare_addr(rdma_get_local_addr((*qp)->cm_id), - src_addr)) - return 0; - - *qp = ds_next_qp(*qp); - } while (*qp != rs->qp_list); - } - - return ds_create_qp(rs, src_addr, addrlen, qp); -} - -static int ds_get_dest(struct rsocket *rs, const struct sockaddr *addr, - socklen_t addrlen, struct ds_dest **dest) -{ - union socket_addr src_addr; - socklen_t src_len; - struct ds_qp *qp; - struct ds_dest **tdest, *new_dest; - int ret = 0; - - fastlock_acquire(&rs->map_lock); - tdest = tfind(addr, &rs->dest_map, ds_compare_addr); - if (tdest) - goto found; - - ret = ds_get_src_addr(rs, addr, addrlen, &src_addr, &src_len); - if (ret) - goto out; - - ret = ds_get_qp(rs, &src_addr, src_len, &qp); - if (ret) - goto out; - - tdest = tfind(addr, &rs->dest_map, ds_compare_addr); - if (!tdest) { - new_dest = calloc(1, sizeof(*new_dest)); - if (!new_dest) { - ret = ERR(ENOMEM); - goto out; - } - - memcpy(&new_dest->addr, addr, addrlen); - new_dest->qp = qp; - tdest = tsearch(&new_dest->addr, &rs->dest_map, ds_compare_addr); - } - -found: - *dest = *tdest; -out: - fastlock_release(&rs->map_lock); - return ret; -} - -int rconnect(int socket, const struct sockaddr *addr, socklen_t addrlen) -{ - struct rsocket *rs; - int ret; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_STREAM) { - memcpy(&rs->cm_id->route.addr.dst_addr, addr, addrlen); - ret = rs_do_connect(rs); - } else { - if (rs->state == rs_init) { - ret = ds_init_ep(rs); - if (ret) - return ret; - } - - fastlock_acquire(&rs->slock); - ret = connect(rs->udp_sock, addr, addrlen); - if (!ret) - ret = ds_get_dest(rs, addr, addrlen, &rs->conn_dest); - fastlock_release(&rs->slock); - } - return ret; -} - -static void *rs_get_ctrl_buf(struct rsocket *rs) -{ - return rs->sbuf + rs->sbuf_size + - RS_MAX_CTRL_MSG * (rs->ctrl_seqno & (RS_QP_CTRL_SIZE - 1)); -} - -static int rs_post_msg(struct rsocket *rs, uint32_t msg) -{ - struct ibv_send_wr wr, *bad; - struct ibv_sge sge; - - wr.wr_id = rs_send_wr_id(msg); - wr.next = NULL; - if (!(rs->opts & RS_OPT_MSG_SEND)) { - wr.sg_list = NULL; - wr.num_sge = 0; - wr.opcode = IBV_WR_RDMA_WRITE_WITH_IMM; - wr.send_flags = 0; - wr.imm_data = htobe32(msg); - } else { - sge.addr = (uintptr_t) &msg; - sge.lkey = 0; - sge.length = sizeof msg; - wr.sg_list = &sge; - wr.num_sge = 1; - wr.opcode = IBV_WR_SEND; - wr.send_flags = IBV_SEND_INLINE; - } - - return rdma_seterrno(ibv_post_send(rs->cm_id->qp, &wr, &bad)); -} - -static int rs_post_write(struct rsocket *rs, - struct ibv_sge *sgl, int nsge, - uint32_t wr_data, int flags, - uint64_t addr, uint32_t rkey) -{ - struct ibv_send_wr wr, *bad; - - wr.wr_id = rs_send_wr_id(wr_data); - wr.next = NULL; - wr.sg_list = sgl; - wr.num_sge = nsge; - wr.opcode = IBV_WR_RDMA_WRITE; - wr.send_flags = flags; - wr.wr.rdma.remote_addr = addr; - wr.wr.rdma.rkey = rkey; - - return rdma_seterrno(ibv_post_send(rs->cm_id->qp, &wr, &bad)); -} - -static int rs_post_write_msg(struct rsocket *rs, - struct ibv_sge *sgl, int nsge, - uint32_t msg, int flags, - uint64_t addr, uint32_t rkey) -{ - struct ibv_send_wr wr, *bad; - struct ibv_sge sge; - int ret; - - wr.next = NULL; - if (!(rs->opts & RS_OPT_MSG_SEND)) { - wr.wr_id = rs_send_wr_id(msg); - wr.sg_list = sgl; - wr.num_sge = nsge; - wr.opcode = IBV_WR_RDMA_WRITE_WITH_IMM; - wr.send_flags = flags; - wr.imm_data = htobe32(msg); - wr.wr.rdma.remote_addr = addr; - wr.wr.rdma.rkey = rkey; - - return rdma_seterrno(ibv_post_send(rs->cm_id->qp, &wr, &bad)); - } else { - ret = rs_post_write(rs, sgl, nsge, msg, flags, addr, rkey); - if (!ret) { - wr.wr_id = rs_send_wr_id(rs_msg_set(rs_msg_op(msg), 0)) | - RS_WR_ID_FLAG_MSG_SEND; - sge.addr = (uintptr_t) &msg; - sge.lkey = 0; - sge.length = sizeof msg; - wr.sg_list = &sge; - wr.num_sge = 1; - wr.opcode = IBV_WR_SEND; - wr.send_flags = IBV_SEND_INLINE; - - ret = rdma_seterrno(ibv_post_send(rs->cm_id->qp, &wr, &bad)); - } - return ret; - } -} - -static int ds_post_send(struct rsocket *rs, struct ibv_sge *sge, - uint32_t wr_data) -{ - struct ibv_send_wr wr, *bad; - - wr.wr_id = rs_send_wr_id(wr_data); - wr.next = NULL; - wr.sg_list = sge; - wr.num_sge = 1; - wr.opcode = IBV_WR_SEND; - wr.send_flags = (sge->length <= rs->sq_inline) ? IBV_SEND_INLINE : 0; - wr.wr.ud.ah = rs->conn_dest->ah; - wr.wr.ud.remote_qpn = rs->conn_dest->qpn; - wr.wr.ud.remote_qkey = RDMA_UDP_QKEY; - - return rdma_seterrno(ibv_post_send(rs->conn_dest->qp->cm_id->qp, &wr, &bad)); -} - -/* - * Update target SGE before sending data. Otherwise the remote side may - * update the entry before we do. - */ -static int rs_write_data(struct rsocket *rs, - struct ibv_sge *sgl, int nsge, - uint32_t length, int flags) -{ - uint64_t addr; - uint32_t rkey; - - rs->sseq_no++; - rs->sqe_avail--; - if (rs->opts & RS_OPT_MSG_SEND) - rs->sqe_avail--; - rs->sbuf_bytes_avail -= length; - - addr = rs->target_sgl[rs->target_sge].addr; - rkey = rs->target_sgl[rs->target_sge].key; - - rs->target_sgl[rs->target_sge].addr += length; - rs->target_sgl[rs->target_sge].length -= length; - - if (!rs->target_sgl[rs->target_sge].length) { - if (++rs->target_sge == RS_SGL_SIZE) - rs->target_sge = 0; - } - - return rs_post_write_msg(rs, sgl, nsge, rs_msg_set(RS_OP_DATA, length), - flags, addr, rkey); -} - -static int rs_write_direct(struct rsocket *rs, struct rs_iomap *iom, uint64_t offset, - struct ibv_sge *sgl, int nsge, uint32_t length, int flags) -{ - uint64_t addr; - - rs->sqe_avail--; - rs->sbuf_bytes_avail -= length; - - addr = iom->sge.addr + offset - iom->offset; - return rs_post_write(rs, sgl, nsge, rs_msg_set(RS_OP_WRITE, length), - flags, addr, iom->sge.key); -} - -static int rs_write_iomap(struct rsocket *rs, struct rs_iomap_mr *iomr, - struct ibv_sge *sgl, int nsge, int flags) -{ - uint64_t addr; - - rs->sseq_no++; - rs->sqe_avail--; - if (rs->opts & RS_OPT_MSG_SEND) - rs->sqe_avail--; - rs->sbuf_bytes_avail -= sizeof(struct rs_iomap); - - addr = rs->remote_iomap.addr + iomr->index * sizeof(struct rs_iomap); - return rs_post_write_msg(rs, sgl, nsge, rs_msg_set(RS_OP_IOMAP_SGL, iomr->index), - flags, addr, rs->remote_iomap.key); -} - -static uint32_t rs_sbuf_left(struct rsocket *rs) -{ - return (uint32_t) (((uint64_t) (uintptr_t) &rs->sbuf[rs->sbuf_size]) - - rs->ssgl[0].addr); -} - -static void rs_send_credits(struct rsocket *rs) -{ - struct ibv_sge ibsge; - struct rs_sge sge, *sge_buf; - int flags; - - rs->ctrl_seqno++; - rs->rseq_comp = rs->rseq_no + (rs->rq_size >> 1); - if (rs->rbuf_bytes_avail >= (rs->rbuf_size >> 1)) { - if (rs->opts & RS_OPT_MSG_SEND) - rs->ctrl_seqno++; - - if (!(rs->opts & RS_OPT_SWAP_SGL)) { - sge.addr = (uintptr_t) &rs->rbuf[rs->rbuf_free_offset]; - sge.key = rs->rmr->rkey; - sge.length = rs->rbuf_size >> 1; - } else { - sge.addr = bswap_64((uintptr_t) &rs->rbuf[rs->rbuf_free_offset]); - sge.key = bswap_32(rs->rmr->rkey); - sge.length = bswap_32(rs->rbuf_size >> 1); - } - - if (rs->sq_inline < sizeof sge) { - sge_buf = rs_get_ctrl_buf(rs); - memcpy(sge_buf, &sge, sizeof sge); - ibsge.addr = (uintptr_t) sge_buf; - ibsge.lkey = rs->smr->lkey; - flags = 0; - } else { - ibsge.addr = (uintptr_t) &sge; - ibsge.lkey = 0; - flags = IBV_SEND_INLINE; - } - ibsge.length = sizeof(sge); - - rs_post_write_msg(rs, &ibsge, 1, - rs_msg_set(RS_OP_SGL, rs->rseq_no + rs->rq_size), flags, - rs->remote_sgl.addr + rs->remote_sge * sizeof(struct rs_sge), - rs->remote_sgl.key); - - rs->rbuf_bytes_avail -= rs->rbuf_size >> 1; - rs->rbuf_free_offset += rs->rbuf_size >> 1; - if (rs->rbuf_free_offset >= rs->rbuf_size) - rs->rbuf_free_offset = 0; - if (++rs->remote_sge == rs->remote_sgl.length) - rs->remote_sge = 0; - } else { - rs_post_msg(rs, rs_msg_set(RS_OP_SGL, rs->rseq_no + rs->rq_size)); - } -} - -static inline int rs_ctrl_avail(struct rsocket *rs) -{ - return rs->ctrl_seqno != rs->ctrl_max_seqno; -} - -/* Protocols that do not support RDMA write with immediate may require 2 msgs */ -static inline int rs_2ctrl_avail(struct rsocket *rs) -{ - return (int)((rs->ctrl_seqno + 1) - rs->ctrl_max_seqno) < 0; -} - -static int rs_give_credits(struct rsocket *rs) -{ - if (!(rs->opts & RS_OPT_MSG_SEND)) { - return ((rs->rbuf_bytes_avail >= (rs->rbuf_size >> 1)) || - ((short) ((short) rs->rseq_no - (short) rs->rseq_comp) >= 0)) && - rs_ctrl_avail(rs) && (rs->state & rs_connected); - } else { - return ((rs->rbuf_bytes_avail >= (rs->rbuf_size >> 1)) || - ((short) ((short) rs->rseq_no - (short) rs->rseq_comp) >= 0)) && - rs_2ctrl_avail(rs) && (rs->state & rs_connected); - } -} - -static void rs_update_credits(struct rsocket *rs) -{ - if (rs_give_credits(rs)) - rs_send_credits(rs); -} - -static int rs_poll_cq(struct rsocket *rs) -{ - struct ibv_wc wc; - uint32_t msg; - int ret, rcnt = 0; - - while ((ret = ibv_poll_cq(rs->cm_id->recv_cq, 1, &wc)) > 0) { - if (rs_wr_is_recv(wc.wr_id)) { - if (wc.status != IBV_WC_SUCCESS) - continue; - rcnt++; - - if (wc.wc_flags & IBV_WC_WITH_IMM) { - msg = be32toh(wc.imm_data); - } else { - msg = ((uint32_t *) (rs->rbuf + rs->rbuf_size)) - [rs_wr_data(wc.wr_id)]; - - } - switch (rs_msg_op(msg)) { - case RS_OP_SGL: - rs->sseq_comp = (uint16_t) rs_msg_data(msg); - break; - case RS_OP_IOMAP_SGL: - /* The iomap was updated, that's nice to know. */ - break; - case RS_OP_CTRL: - if (rs_msg_data(msg) == RS_CTRL_DISCONNECT) { - rs->state = rs_disconnected; - return 0; - } else if (rs_msg_data(msg) == RS_CTRL_SHUTDOWN) { - if (rs->state & rs_writable) { - rs->state &= ~rs_readable; - } else { - rs->state = rs_disconnected; - return 0; - } - } - break; - case RS_OP_WRITE: - /* We really shouldn't be here. */ - break; - default: - rs->rmsg[rs->rmsg_tail].op = rs_msg_op(msg); - rs->rmsg[rs->rmsg_tail].data = rs_msg_data(msg); - if (++rs->rmsg_tail == rs->rq_size + 1) - rs->rmsg_tail = 0; - break; - } - } else { - switch (rs_msg_op(rs_wr_data(wc.wr_id))) { - case RS_OP_SGL: - rs->ctrl_max_seqno++; - break; - case RS_OP_CTRL: - rs->ctrl_max_seqno++; - if (rs_msg_data(rs_wr_data(wc.wr_id)) == RS_CTRL_DISCONNECT) - rs->state = rs_disconnected; - break; - case RS_OP_IOMAP_SGL: - rs->sqe_avail++; - if (!rs_wr_is_msg_send(wc.wr_id)) - rs->sbuf_bytes_avail += sizeof(struct rs_iomap); - break; - default: - rs->sqe_avail++; - rs->sbuf_bytes_avail += rs_msg_data(rs_wr_data(wc.wr_id)); - break; - } - if (wc.status != IBV_WC_SUCCESS && (rs->state & rs_connected)) { - rs->state = rs_error; - rs->err = EIO; - } - } - } - - if (rs->state & rs_connected) { - while (!ret && rcnt--) - ret = rs_post_recv(rs); - - if (ret) { - rs->state = rs_error; - rs->err = errno; - } - } - return ret; -} - -static int rs_get_cq_event(struct rsocket *rs) -{ - struct ibv_cq *cq; - void *context; - int ret; - - if (!rs->cq_armed) - return 0; - - ret = ibv_get_cq_event(rs->cm_id->recv_cq_channel, &cq, &context); - if (!ret) { - if (++rs->unack_cqe >= rs->sq_size + rs->rq_size) { - ibv_ack_cq_events(rs->cm_id->recv_cq, rs->unack_cqe); - rs->unack_cqe = 0; - } - rs->cq_armed = 0; - } else if (!(errno == EAGAIN || errno == EINTR)) { - rs->state = rs_error; - } - - return ret; -} - -/* - * Although we serialize rsend and rrecv calls with respect to themselves, - * both calls may run simultaneously and need to poll the CQ for completions. - * We need to serialize access to the CQ, but rsend and rrecv need to - * allow each other to make forward progress. - * - * For example, rsend may need to wait for credits from the remote side, - * which could be stalled until the remote process calls rrecv. This should - * not block rrecv from receiving data from the remote side however. - * - * We handle this by using two locks. The cq_lock protects against polling - * the CQ and processing completions. The cq_wait_lock serializes access to - * waiting on the CQ. - */ -static int rs_process_cq(struct rsocket *rs, int nonblock, int (*test)(struct rsocket *rs)) -{ - int ret; - - fastlock_acquire(&rs->cq_lock); - do { - rs_update_credits(rs); - ret = rs_poll_cq(rs); - if (test(rs)) { - ret = 0; - break; - } else if (ret) { - break; - } else if (nonblock) { - ret = ERR(EWOULDBLOCK); - } else if (!rs->cq_armed) { - ibv_req_notify_cq(rs->cm_id->recv_cq, 0); - rs->cq_armed = 1; - } else { - rs_update_credits(rs); - fastlock_acquire(&rs->cq_wait_lock); - fastlock_release(&rs->cq_lock); - - ret = rs_get_cq_event(rs); - fastlock_release(&rs->cq_wait_lock); - fastlock_acquire(&rs->cq_lock); - } - } while (!ret); - - rs_update_credits(rs); - fastlock_release(&rs->cq_lock); - return ret; -} - -static int rs_get_comp(struct rsocket *rs, int nonblock, int (*test)(struct rsocket *rs)) -{ - struct timeval s, e; - uint32_t poll_time = 0; - int ret; - - do { - ret = rs_process_cq(rs, 1, test); - if (!ret || nonblock || errno != EWOULDBLOCK) - return ret; - - if (!poll_time) - gettimeofday(&s, NULL); - - gettimeofday(&e, NULL); - poll_time = (e.tv_sec - s.tv_sec) * 1000000 + - (e.tv_usec - s.tv_usec) + 1; - } while (poll_time <= polling_time); - - ret = rs_process_cq(rs, 0, test); - return ret; -} - -static int ds_valid_recv(struct ds_qp *qp, struct ibv_wc *wc) -{ - struct ds_header *hdr; - - hdr = (struct ds_header *) (qp->rbuf + rs_wr_data(wc->wr_id)); - return ((wc->byte_len >= sizeof(struct ibv_grh) + DS_IPV4_HDR_LEN) && - ((hdr->version == 4 && hdr->length == DS_IPV4_HDR_LEN) || - (hdr->version == 6 && hdr->length == DS_IPV6_HDR_LEN))); -} - -/* - * Poll all CQs associated with a datagram rsocket. We need to drop any - * received messages that we do not have room to store. To limit drops, - * we only poll if we have room to store the receive or we need a send - * buffer. To ensure fairness, we poll the CQs round robin, remembering - * where we left off. - */ -static void ds_poll_cqs(struct rsocket *rs) -{ - struct ds_qp *qp; - struct ds_smsg *smsg; - struct ds_rmsg *rmsg; - struct ibv_wc wc; - int ret, cnt; - - if (!(qp = rs->qp_list)) - return; - - do { - cnt = 0; - do { - ret = ibv_poll_cq(qp->cm_id->recv_cq, 1, &wc); - if (ret <= 0) { - qp = ds_next_qp(qp); - continue; - } - - if (rs_wr_is_recv(wc.wr_id)) { - if (rs->rqe_avail && wc.status == IBV_WC_SUCCESS && - ds_valid_recv(qp, &wc)) { - rs->rqe_avail--; - rmsg = &rs->dmsg[rs->rmsg_tail]; - rmsg->qp = qp; - rmsg->offset = rs_wr_data(wc.wr_id); - rmsg->length = wc.byte_len - sizeof(struct ibv_grh); - if (++rs->rmsg_tail == rs->rq_size + 1) - rs->rmsg_tail = 0; - } else { - ds_post_recv(rs, qp, rs_wr_data(wc.wr_id)); - } - } else { - smsg = (struct ds_smsg *) (rs->sbuf + rs_wr_data(wc.wr_id)); - smsg->next = rs->smsg_free; - rs->smsg_free = smsg; - rs->sqe_avail++; - } - - qp = ds_next_qp(qp); - if (!rs->rqe_avail && rs->sqe_avail) { - rs->qp_list = qp; - return; - } - cnt++; - } while (qp != rs->qp_list); - } while (cnt); -} - -static void ds_req_notify_cqs(struct rsocket *rs) -{ - struct ds_qp *qp; - - if (!(qp = rs->qp_list)) - return; - - do { - if (!qp->cq_armed) { - ibv_req_notify_cq(qp->cm_id->recv_cq, 0); - qp->cq_armed = 1; - } - qp = ds_next_qp(qp); - } while (qp != rs->qp_list); -} - -static int ds_get_cq_event(struct rsocket *rs) -{ - struct epoll_event event; - struct ds_qp *qp; - struct ibv_cq *cq; - void *context; - int ret; - - if (!rs->cq_armed) - return 0; - - ret = epoll_wait(rs->epfd, &event, 1, -1); - if (ret <= 0) - return ret; - - qp = event.data.ptr; - ret = ibv_get_cq_event(qp->cm_id->recv_cq_channel, &cq, &context); - if (!ret) { - ibv_ack_cq_events(qp->cm_id->recv_cq, 1); - qp->cq_armed = 0; - rs->cq_armed = 0; - } - - return ret; -} - -static int ds_process_cqs(struct rsocket *rs, int nonblock, int (*test)(struct rsocket *rs)) -{ - int ret = 0; - - fastlock_acquire(&rs->cq_lock); - do { - ds_poll_cqs(rs); - if (test(rs)) { - ret = 0; - break; - } else if (nonblock) { - ret = ERR(EWOULDBLOCK); - } else if (!rs->cq_armed) { - ds_req_notify_cqs(rs); - rs->cq_armed = 1; - } else { - fastlock_acquire(&rs->cq_wait_lock); - fastlock_release(&rs->cq_lock); - - ret = ds_get_cq_event(rs); - fastlock_release(&rs->cq_wait_lock); - fastlock_acquire(&rs->cq_lock); - } - } while (!ret); - - fastlock_release(&rs->cq_lock); - return ret; -} - -static int ds_get_comp(struct rsocket *rs, int nonblock, int (*test)(struct rsocket *rs)) -{ - struct timeval s, e; - uint32_t poll_time = 0; - int ret; - - do { - ret = ds_process_cqs(rs, 1, test); - if (!ret || nonblock || errno != EWOULDBLOCK) - return ret; - - if (!poll_time) - gettimeofday(&s, NULL); - - gettimeofday(&e, NULL); - poll_time = (e.tv_sec - s.tv_sec) * 1000000 + - (e.tv_usec - s.tv_usec) + 1; - } while (poll_time <= polling_time); - - ret = ds_process_cqs(rs, 0, test); - return ret; -} - -static int rs_nonblocking(struct rsocket *rs, int flags) -{ - return (rs->fd_flags & O_NONBLOCK) || (flags & MSG_DONTWAIT); -} - -static int rs_is_cq_armed(struct rsocket *rs) -{ - return rs->cq_armed; -} - -static int rs_poll_all(struct rsocket *rs) -{ - return 1; -} - -/* - * We use hardware flow control to prevent over running the remote - * receive queue. However, data transfers still require space in - * the remote rmsg queue, or we risk losing notification that data - * has been transfered. - * - * Be careful with race conditions in the check below. The target SGL - * may be updated by a remote RDMA write. - */ -static int rs_can_send(struct rsocket *rs) -{ - if (!(rs->opts & RS_OPT_MSG_SEND)) { - return rs->sqe_avail && (rs->sbuf_bytes_avail >= RS_SNDLOWAT) && - (rs->sseq_no != rs->sseq_comp) && - (rs->target_sgl[rs->target_sge].length != 0); - } else { - return (rs->sqe_avail >= 2) && (rs->sbuf_bytes_avail >= RS_SNDLOWAT) && - (rs->sseq_no != rs->sseq_comp) && - (rs->target_sgl[rs->target_sge].length != 0); - } -} - -static int ds_can_send(struct rsocket *rs) -{ - return rs->sqe_avail; -} - -static int ds_all_sends_done(struct rsocket *rs) -{ - return rs->sqe_avail == rs->sq_size; -} - -static int rs_conn_can_send(struct rsocket *rs) -{ - return rs_can_send(rs) || !(rs->state & rs_writable); -} - -static int rs_conn_can_send_ctrl(struct rsocket *rs) -{ - return rs_ctrl_avail(rs) || !(rs->state & rs_connected); -} - -static int rs_have_rdata(struct rsocket *rs) -{ - return (rs->rmsg_head != rs->rmsg_tail); -} - -static int rs_conn_have_rdata(struct rsocket *rs) -{ - return rs_have_rdata(rs) || !(rs->state & rs_readable); -} - -static int rs_conn_all_sends_done(struct rsocket *rs) -{ - return ((((int) rs->ctrl_max_seqno) - ((int) rs->ctrl_seqno)) + - rs->sqe_avail == rs->sq_size) || - !(rs->state & rs_connected); -} - -static void ds_set_src(struct sockaddr *addr, socklen_t *addrlen, - struct ds_header *hdr) -{ - union socket_addr sa; - - memset(&sa, 0, sizeof sa); - if (hdr->version == 4) { - if (*addrlen > sizeof(sa.sin)) - *addrlen = sizeof(sa.sin); - - sa.sin.sin_family = AF_INET; - sa.sin.sin_port = hdr->port; - sa.sin.sin_addr.s_addr = hdr->addr.ipv4; - } else { - if (*addrlen > sizeof(sa.sin6)) - *addrlen = sizeof(sa.sin6); - - sa.sin6.sin6_family = AF_INET6; - sa.sin6.sin6_port = hdr->port; - sa.sin6.sin6_flowinfo = hdr->addr.ipv6.flowinfo; - memcpy(&sa.sin6.sin6_addr, &hdr->addr.ipv6.addr, 16); - } - memcpy(addr, &sa, *addrlen); -} - -static ssize_t ds_recvfrom(struct rsocket *rs, void *buf, size_t len, int flags, - struct sockaddr *src_addr, socklen_t *addrlen) -{ - struct ds_rmsg *rmsg; - struct ds_header *hdr; - int ret; - - if (!(rs->state & rs_readable)) - return ERR(EINVAL); - - if (!rs_have_rdata(rs)) { - ret = ds_get_comp(rs, rs_nonblocking(rs, flags), - rs_have_rdata); - if (ret) - return ret; - } - - rmsg = &rs->dmsg[rs->rmsg_head]; - hdr = (struct ds_header *) (rmsg->qp->rbuf + rmsg->offset); - if (len > rmsg->length - hdr->length) - len = rmsg->length - hdr->length; - - memcpy(buf, (void *) hdr + hdr->length, len); - if (addrlen) - ds_set_src(src_addr, addrlen, hdr); - - if (!(flags & MSG_PEEK)) { - ds_post_recv(rs, rmsg->qp, rmsg->offset); - if (++rs->rmsg_head == rs->rq_size + 1) - rs->rmsg_head = 0; - rs->rqe_avail++; - } - - return len; -} - -static ssize_t rs_peek(struct rsocket *rs, void *buf, size_t len) -{ - size_t left = len; - uint32_t end_size, rsize; - int rmsg_head, rbuf_offset; - - rmsg_head = rs->rmsg_head; - rbuf_offset = rs->rbuf_offset; - - for (; left && (rmsg_head != rs->rmsg_tail); left -= rsize) { - if (left < rs->rmsg[rmsg_head].data) { - rsize = left; - } else { - rsize = rs->rmsg[rmsg_head].data; - if (++rmsg_head == rs->rq_size + 1) - rmsg_head = 0; - } - - end_size = rs->rbuf_size - rbuf_offset; - if (rsize > end_size) { - memcpy(buf, &rs->rbuf[rbuf_offset], end_size); - rbuf_offset = 0; - buf += end_size; - rsize -= end_size; - left -= end_size; - } - memcpy(buf, &rs->rbuf[rbuf_offset], rsize); - rbuf_offset += rsize; - buf += rsize; - } - - return len - left; -} - -/* - * Continue to receive any queued data even if the remote side has disconnected. - */ -ssize_t rrecv(int socket, void *buf, size_t len, int flags) -{ - struct rsocket *rs; - size_t left = len; - uint32_t end_size, rsize; - int ret = 0; - - rs = idm_at(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_DGRAM) { - fastlock_acquire(&rs->rlock); - ret = ds_recvfrom(rs, buf, len, flags, NULL, NULL); - fastlock_release(&rs->rlock); - return ret; - } - - if (rs->state & rs_opening) { - ret = rs_do_connect(rs); - if (ret) { - if (errno == EINPROGRESS) - errno = EAGAIN; - return ret; - } - } - fastlock_acquire(&rs->rlock); - do { - if (!rs_have_rdata(rs)) { - ret = rs_get_comp(rs, rs_nonblocking(rs, flags), - rs_conn_have_rdata); - if (ret) - break; - } - - if (flags & MSG_PEEK) { - left = len - rs_peek(rs, buf, left); - break; - } - - for (; left && rs_have_rdata(rs); left -= rsize) { - if (left < rs->rmsg[rs->rmsg_head].data) { - rsize = left; - rs->rmsg[rs->rmsg_head].data -= left; - } else { - rs->rseq_no++; - rsize = rs->rmsg[rs->rmsg_head].data; - if (++rs->rmsg_head == rs->rq_size + 1) - rs->rmsg_head = 0; - } - - end_size = rs->rbuf_size - rs->rbuf_offset; - if (rsize > end_size) { - memcpy(buf, &rs->rbuf[rs->rbuf_offset], end_size); - rs->rbuf_offset = 0; - buf += end_size; - rsize -= end_size; - left -= end_size; - rs->rbuf_bytes_avail += end_size; - } - memcpy(buf, &rs->rbuf[rs->rbuf_offset], rsize); - rs->rbuf_offset += rsize; - buf += rsize; - rs->rbuf_bytes_avail += rsize; - } - - } while (left && (flags & MSG_WAITALL) && (rs->state & rs_readable)); - - fastlock_release(&rs->rlock); - return (ret && left == len) ? ret : len - left; -} - -ssize_t rrecvfrom(int socket, void *buf, size_t len, int flags, - struct sockaddr *src_addr, socklen_t *addrlen) -{ - struct rsocket *rs; - int ret; - - rs = idm_at(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_DGRAM) { - fastlock_acquire(&rs->rlock); - ret = ds_recvfrom(rs, buf, len, flags, src_addr, addrlen); - fastlock_release(&rs->rlock); - return ret; - } - - ret = rrecv(socket, buf, len, flags); - if (ret > 0 && src_addr) - rgetpeername(socket, src_addr, addrlen); - - return ret; -} - -/* - * Simple, straightforward implementation for now that only tries to fill - * in the first vector. - */ -static ssize_t rrecvv(int socket, const struct iovec *iov, int iovcnt, int flags) -{ - return rrecv(socket, iov[0].iov_base, iov[0].iov_len, flags); -} - -ssize_t rrecvmsg(int socket, struct msghdr *msg, int flags) -{ - if (msg->msg_control && msg->msg_controllen) - return ERR(ENOTSUP); - - return rrecvv(socket, msg->msg_iov, (int) msg->msg_iovlen, msg->msg_flags); -} - -ssize_t rread(int socket, void *buf, size_t count) -{ - return rrecv(socket, buf, count, 0); -} - -ssize_t rreadv(int socket, const struct iovec *iov, int iovcnt) -{ - return rrecvv(socket, iov, iovcnt, 0); -} - -static int rs_send_iomaps(struct rsocket *rs, int flags) -{ - struct rs_iomap_mr *iomr; - struct ibv_sge sge; - struct rs_iomap iom; - int ret; - - fastlock_acquire(&rs->map_lock); - while (!dlist_empty(&rs->iomap_queue)) { - if (!rs_can_send(rs)) { - ret = rs_get_comp(rs, rs_nonblocking(rs, flags), - rs_conn_can_send); - if (ret) - break; - if (!(rs->state & rs_writable)) { - ret = ERR(ECONNRESET); - break; - } - } - - iomr = container_of(rs->iomap_queue.next, struct rs_iomap_mr, entry); - if (!(rs->opts & RS_OPT_SWAP_SGL)) { - iom.offset = iomr->offset; - iom.sge.addr = (uintptr_t) iomr->mr->addr; - iom.sge.length = iomr->mr->length; - iom.sge.key = iomr->mr->rkey; - } else { - iom.offset = bswap_64(iomr->offset); - iom.sge.addr = bswap_64((uintptr_t) iomr->mr->addr); - iom.sge.length = bswap_32(iomr->mr->length); - iom.sge.key = bswap_32(iomr->mr->rkey); - } - - if (rs->sq_inline >= sizeof iom) { - sge.addr = (uintptr_t) &iom; - sge.length = sizeof iom; - sge.lkey = 0; - ret = rs_write_iomap(rs, iomr, &sge, 1, IBV_SEND_INLINE); - } else if (rs_sbuf_left(rs) >= sizeof iom) { - memcpy((void *) (uintptr_t) rs->ssgl[0].addr, &iom, sizeof iom); - rs->ssgl[0].length = sizeof iom; - ret = rs_write_iomap(rs, iomr, rs->ssgl, 1, 0); - if (rs_sbuf_left(rs) > sizeof iom) - rs->ssgl[0].addr += sizeof iom; - else - rs->ssgl[0].addr = (uintptr_t) rs->sbuf; - } else { - rs->ssgl[0].length = rs_sbuf_left(rs); - memcpy((void *) (uintptr_t) rs->ssgl[0].addr, &iom, - rs->ssgl[0].length); - rs->ssgl[1].length = sizeof iom - rs->ssgl[0].length; - memcpy(rs->sbuf, ((void *) &iom) + rs->ssgl[0].length, - rs->ssgl[1].length); - ret = rs_write_iomap(rs, iomr, rs->ssgl, 2, 0); - rs->ssgl[0].addr = (uintptr_t) rs->sbuf + rs->ssgl[1].length; - } - dlist_remove(&iomr->entry); - dlist_insert_tail(&iomr->entry, &rs->iomap_list); - if (ret) - break; - } - - rs->iomap_pending = !dlist_empty(&rs->iomap_queue); - fastlock_release(&rs->map_lock); - return ret; -} - -static ssize_t ds_sendv_udp(struct rsocket *rs, const struct iovec *iov, - int iovcnt, int flags, uint8_t op) -{ - struct ds_udp_header hdr; - struct msghdr msg; - struct iovec miov[8]; - ssize_t ret; - - if (iovcnt > 8) - return ERR(ENOTSUP); - - hdr.tag = htobe32(DS_UDP_TAG); - hdr.version = rs->conn_dest->qp->hdr.version; - hdr.op = op; - hdr.reserved = 0; - hdr.qpn = htobe32(rs->conn_dest->qp->cm_id->qp->qp_num & 0xFFFFFF); - if (rs->conn_dest->qp->hdr.version == 4) { - hdr.length = DS_UDP_IPV4_HDR_LEN; - hdr.addr.ipv4 = rs->conn_dest->qp->hdr.addr.ipv4; - } else { - hdr.length = DS_UDP_IPV6_HDR_LEN; - memcpy(hdr.addr.ipv6, &rs->conn_dest->qp->hdr.addr.ipv6, 16); - } - - miov[0].iov_base = &hdr; - miov[0].iov_len = hdr.length; - if (iov && iovcnt) - memcpy(&miov[1], iov, sizeof(*iov) * iovcnt); - - memset(&msg, 0, sizeof msg); - msg.msg_name = &rs->conn_dest->addr; - msg.msg_namelen = ucma_addrlen(&rs->conn_dest->addr.sa); - msg.msg_iov = miov; - msg.msg_iovlen = iovcnt + 1; - ret = sendmsg(rs->udp_sock, &msg, flags); - return ret > 0 ? ret - hdr.length : ret; -} - -static ssize_t ds_send_udp(struct rsocket *rs, const void *buf, size_t len, - int flags, uint8_t op) -{ - struct iovec iov; - if (buf && len) { - iov.iov_base = (void *) buf; - iov.iov_len = len; - return ds_sendv_udp(rs, &iov, 1, flags, op); - } else { - return ds_sendv_udp(rs, NULL, 0, flags, op); - } -} - -static ssize_t dsend(struct rsocket *rs, const void *buf, size_t len, int flags) -{ - struct ds_smsg *msg; - struct ibv_sge sge; - uint64_t offset; - int ret = 0; - - if (!rs->conn_dest->ah) - return ds_send_udp(rs, buf, len, flags, RS_OP_DATA); - - if (!ds_can_send(rs)) { - ret = ds_get_comp(rs, rs_nonblocking(rs, flags), ds_can_send); - if (ret) - return ret; - } - - msg = rs->smsg_free; - rs->smsg_free = msg->next; - rs->sqe_avail--; - - memcpy((void *) msg, &rs->conn_dest->qp->hdr, rs->conn_dest->qp->hdr.length); - memcpy((void *) msg + rs->conn_dest->qp->hdr.length, buf, len); - sge.addr = (uintptr_t) msg; - sge.length = rs->conn_dest->qp->hdr.length + len; - sge.lkey = rs->conn_dest->qp->smr->lkey; - offset = (uint8_t *) msg - rs->sbuf; - - ret = ds_post_send(rs, &sge, offset); - return ret ? ret : len; -} - -/* - * We overlap sending the data, by posting a small work request immediately, - * then increasing the size of the send on each iteration. - */ -ssize_t rsend(int socket, const void *buf, size_t len, int flags) -{ - struct rsocket *rs; - struct ibv_sge sge; - size_t left = len; - uint32_t xfer_size, olen = RS_OLAP_START_SIZE; - int ret = 0; - - rs = idm_at(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_DGRAM) { - fastlock_acquire(&rs->slock); - ret = dsend(rs, buf, len, flags); - fastlock_release(&rs->slock); - return ret; - } - - if (rs->state & rs_opening) { - ret = rs_do_connect(rs); - if (ret) { - if (errno == EINPROGRESS) - errno = EAGAIN; - return ret; - } - } - - fastlock_acquire(&rs->slock); - if (rs->iomap_pending) { - ret = rs_send_iomaps(rs, flags); - if (ret) - goto out; - } - for (; left; left -= xfer_size, buf += xfer_size) { - if (!rs_can_send(rs)) { - ret = rs_get_comp(rs, rs_nonblocking(rs, flags), - rs_conn_can_send); - if (ret) - break; - if (!(rs->state & rs_writable)) { - ret = ERR(ECONNRESET); - break; - } - } - - if (olen < left) { - xfer_size = olen; - if (olen < RS_MAX_TRANSFER) - olen <<= 1; - } else { - xfer_size = left; - } - - if (xfer_size > rs->sbuf_bytes_avail) - xfer_size = rs->sbuf_bytes_avail; - if (xfer_size > rs->target_sgl[rs->target_sge].length) - xfer_size = rs->target_sgl[rs->target_sge].length; - - if (xfer_size <= rs->sq_inline) { - sge.addr = (uintptr_t) buf; - sge.length = xfer_size; - sge.lkey = 0; - ret = rs_write_data(rs, &sge, 1, xfer_size, IBV_SEND_INLINE); - } else if (xfer_size <= rs_sbuf_left(rs)) { - memcpy((void *) (uintptr_t) rs->ssgl[0].addr, buf, xfer_size); - rs->ssgl[0].length = xfer_size; - ret = rs_write_data(rs, rs->ssgl, 1, xfer_size, 0); - if (xfer_size < rs_sbuf_left(rs)) - rs->ssgl[0].addr += xfer_size; - else - rs->ssgl[0].addr = (uintptr_t) rs->sbuf; - } else { - rs->ssgl[0].length = rs_sbuf_left(rs); - memcpy((void *) (uintptr_t) rs->ssgl[0].addr, buf, - rs->ssgl[0].length); - rs->ssgl[1].length = xfer_size - rs->ssgl[0].length; - memcpy(rs->sbuf, buf + rs->ssgl[0].length, rs->ssgl[1].length); - ret = rs_write_data(rs, rs->ssgl, 2, xfer_size, 0); - rs->ssgl[0].addr = (uintptr_t) rs->sbuf + rs->ssgl[1].length; - } - if (ret) - break; - } -out: - fastlock_release(&rs->slock); - - return (ret && left == len) ? ret : len - left; -} - -ssize_t rsendto(int socket, const void *buf, size_t len, int flags, - const struct sockaddr *dest_addr, socklen_t addrlen) -{ - struct rsocket *rs; - int ret; - - rs = idm_at(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_STREAM) { - if (dest_addr || addrlen) - return ERR(EISCONN); - - return rsend(socket, buf, len, flags); - } - - if (rs->state == rs_init) { - ret = ds_init_ep(rs); - if (ret) - return ret; - } - - fastlock_acquire(&rs->slock); - if (!rs->conn_dest || ds_compare_addr(dest_addr, &rs->conn_dest->addr)) { - ret = ds_get_dest(rs, dest_addr, addrlen, &rs->conn_dest); - if (ret) - goto out; - } - - ret = dsend(rs, buf, len, flags); -out: - fastlock_release(&rs->slock); - return ret; -} - -static void rs_copy_iov(void *dst, const struct iovec **iov, size_t *offset, size_t len) -{ - size_t size; - - while (len) { - size = (*iov)->iov_len - *offset; - if (size > len) { - memcpy (dst, (*iov)->iov_base + *offset, len); - *offset += len; - break; - } - - memcpy(dst, (*iov)->iov_base + *offset, size); - len -= size; - dst += size; - (*iov)++; - *offset = 0; - } -} - -static ssize_t rsendv(int socket, const struct iovec *iov, int iovcnt, int flags) -{ - struct rsocket *rs; - const struct iovec *cur_iov; - size_t left, len, offset = 0; - uint32_t xfer_size, olen = RS_OLAP_START_SIZE; - int i, ret = 0; - - rs = idm_at(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->state & rs_opening) { - ret = rs_do_connect(rs); - if (ret) { - if (errno == EINPROGRESS) - errno = EAGAIN; - return ret; - } - } - - cur_iov = iov; - len = iov[0].iov_len; - for (i = 1; i < iovcnt; i++) - len += iov[i].iov_len; - left = len; - - fastlock_acquire(&rs->slock); - if (rs->iomap_pending) { - ret = rs_send_iomaps(rs, flags); - if (ret) - goto out; - } - for (; left; left -= xfer_size) { - if (!rs_can_send(rs)) { - ret = rs_get_comp(rs, rs_nonblocking(rs, flags), - rs_conn_can_send); - if (ret) - break; - if (!(rs->state & rs_writable)) { - ret = ERR(ECONNRESET); - break; - } - } - - if (olen < left) { - xfer_size = olen; - if (olen < RS_MAX_TRANSFER) - olen <<= 1; - } else { - xfer_size = left; - } - - if (xfer_size > rs->sbuf_bytes_avail) - xfer_size = rs->sbuf_bytes_avail; - if (xfer_size > rs->target_sgl[rs->target_sge].length) - xfer_size = rs->target_sgl[rs->target_sge].length; - - if (xfer_size <= rs_sbuf_left(rs)) { - rs_copy_iov((void *) (uintptr_t) rs->ssgl[0].addr, - &cur_iov, &offset, xfer_size); - rs->ssgl[0].length = xfer_size; - ret = rs_write_data(rs, rs->ssgl, 1, xfer_size, - xfer_size <= rs->sq_inline ? IBV_SEND_INLINE : 0); - if (xfer_size < rs_sbuf_left(rs)) - rs->ssgl[0].addr += xfer_size; - else - rs->ssgl[0].addr = (uintptr_t) rs->sbuf; - } else { - rs->ssgl[0].length = rs_sbuf_left(rs); - rs_copy_iov((void *) (uintptr_t) rs->ssgl[0].addr, &cur_iov, - &offset, rs->ssgl[0].length); - rs->ssgl[1].length = xfer_size - rs->ssgl[0].length; - rs_copy_iov(rs->sbuf, &cur_iov, &offset, rs->ssgl[1].length); - ret = rs_write_data(rs, rs->ssgl, 2, xfer_size, - xfer_size <= rs->sq_inline ? IBV_SEND_INLINE : 0); - rs->ssgl[0].addr = (uintptr_t) rs->sbuf + rs->ssgl[1].length; - } - if (ret) - break; - } -out: - fastlock_release(&rs->slock); - - return (ret && left == len) ? ret : len - left; -} - -ssize_t rsendmsg(int socket, const struct msghdr *msg, int flags) -{ - if (msg->msg_control && msg->msg_controllen) - return ERR(ENOTSUP); - - return rsendv(socket, msg->msg_iov, (int) msg->msg_iovlen, flags); -} - -ssize_t rwrite(int socket, const void *buf, size_t count) -{ - return rsend(socket, buf, count, 0); -} - -ssize_t rwritev(int socket, const struct iovec *iov, int iovcnt) -{ - return rsendv(socket, iov, iovcnt, 0); -} - -static struct pollfd *rs_fds_alloc(nfds_t nfds) -{ - static __thread struct pollfd *rfds; - static __thread nfds_t rnfds; - - if (nfds > rnfds) { - if (rfds) - free(rfds); - - rfds = malloc(sizeof(*rfds) * nfds); - rnfds = rfds ? nfds : 0; - } - - return rfds; -} - -static int rs_poll_rs(struct rsocket *rs, int events, - int nonblock, int (*test)(struct rsocket *rs)) -{ - struct pollfd fds; - short revents; - int ret; - -check_cq: - if ((rs->type == SOCK_STREAM) && ((rs->state & rs_connected) || - (rs->state == rs_disconnected) || (rs->state & rs_error))) { - rs_process_cq(rs, nonblock, test); - - revents = 0; - if ((events & POLLIN) && rs_conn_have_rdata(rs)) - revents |= POLLIN; - if ((events & POLLOUT) && rs_can_send(rs)) - revents |= POLLOUT; - if (!(rs->state & rs_connected)) { - if (rs->state == rs_disconnected) - revents |= POLLHUP; - else - revents |= POLLERR; - } - - return revents; - } else if (rs->type == SOCK_DGRAM) { - ds_process_cqs(rs, nonblock, test); - - revents = 0; - if ((events & POLLIN) && rs_have_rdata(rs)) - revents |= POLLIN; - if ((events & POLLOUT) && ds_can_send(rs)) - revents |= POLLOUT; - - return revents; - } - - if (rs->state == rs_listening) { - fds.fd = rs->cm_id->channel->fd; - fds.events = events; - fds.revents = 0; - poll(&fds, 1, 0); - return fds.revents; - } - - if (rs->state & rs_opening) { - ret = rs_do_connect(rs); - if (ret && (errno == EINPROGRESS)) { - errno = 0; - } else { - goto check_cq; - } - } - - if (rs->state == rs_connect_error) { - revents = 0; - if (events & POLLOUT) - revents |= POLLOUT; - if (events & POLLIN) - revents |= POLLIN; - revents |= POLLERR; - return revents; - } - - return 0; -} - -static int rs_poll_check(struct pollfd *fds, nfds_t nfds) -{ - struct rsocket *rs; - int i, cnt = 0; - - for (i = 0; i < nfds; i++) { - rs = idm_lookup(&idm, fds[i].fd); - if (rs) - fds[i].revents = rs_poll_rs(rs, fds[i].events, 1, rs_poll_all); - else - poll(&fds[i], 1, 0); - - if (fds[i].revents) - cnt++; - } - return cnt; -} - -static int rs_poll_arm(struct pollfd *rfds, struct pollfd *fds, nfds_t nfds) -{ - struct rsocket *rs; - int i; - - for (i = 0; i < nfds; i++) { - rs = idm_lookup(&idm, fds[i].fd); - if (rs) { - fds[i].revents = rs_poll_rs(rs, fds[i].events, 0, rs_is_cq_armed); - if (fds[i].revents) - return 1; - - if (rs->type == SOCK_STREAM) { - if (rs->state >= rs_connected) - rfds[i].fd = rs->cm_id->recv_cq_channel->fd; - else - rfds[i].fd = rs->cm_id->channel->fd; - } else { - rfds[i].fd = rs->epfd; - } - rfds[i].events = POLLIN; - } else { - rfds[i].fd = fds[i].fd; - rfds[i].events = fds[i].events; - } - rfds[i].revents = 0; - } - return 0; -} - -static int rs_poll_events(struct pollfd *rfds, struct pollfd *fds, nfds_t nfds) -{ - struct rsocket *rs; - int i, cnt = 0; - - for (i = 0; i < nfds; i++) { - if (!rfds[i].revents) - continue; - - rs = idm_lookup(&idm, fds[i].fd); - if (rs) { - fastlock_acquire(&rs->cq_wait_lock); - if (rs->type == SOCK_STREAM) - rs_get_cq_event(rs); - else - ds_get_cq_event(rs); - fastlock_release(&rs->cq_wait_lock); - fds[i].revents = rs_poll_rs(rs, fds[i].events, 1, rs_poll_all); - } else { - fds[i].revents = rfds[i].revents; - } - if (fds[i].revents) - cnt++; - } - return cnt; -} - -/* - * We need to poll *all* fd's that the user specifies at least once. - * Note that we may receive events on an rsocket that may not be reported - * to the user (e.g. connection events or credit updates). Process those - * events, then return to polling until we find ones of interest. - */ -int rpoll(struct pollfd *fds, nfds_t nfds, int timeout) -{ - struct timeval s, e; - struct pollfd *rfds; - uint32_t poll_time = 0; - int ret; - - do { - ret = rs_poll_check(fds, nfds); - if (ret || !timeout) - return ret; - - if (!poll_time) - gettimeofday(&s, NULL); - - gettimeofday(&e, NULL); - poll_time = (e.tv_sec - s.tv_sec) * 1000000 + - (e.tv_usec - s.tv_usec) + 1; - } while (poll_time <= polling_time); - - rfds = rs_fds_alloc(nfds); - if (!rfds) - return ERR(ENOMEM); - - do { - ret = rs_poll_arm(rfds, fds, nfds); - if (ret) - break; - - ret = poll(rfds, nfds, timeout); - if (ret <= 0) - break; - - ret = rs_poll_events(rfds, fds, nfds); - } while (!ret); - - return ret; -} - -static struct pollfd * -rs_select_to_poll(int *nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds) -{ - struct pollfd *fds; - int fd, i = 0; - - fds = calloc(*nfds, sizeof(*fds)); - if (!fds) - return NULL; - - for (fd = 0; fd < *nfds; fd++) { - if (readfds && FD_ISSET(fd, readfds)) { - fds[i].fd = fd; - fds[i].events = POLLIN; - } - - if (writefds && FD_ISSET(fd, writefds)) { - fds[i].fd = fd; - fds[i].events |= POLLOUT; - } - - if (exceptfds && FD_ISSET(fd, exceptfds)) - fds[i].fd = fd; - - if (fds[i].fd) - i++; - } - - *nfds = i; - return fds; -} - -static int -rs_poll_to_select(int nfds, struct pollfd *fds, fd_set *readfds, - fd_set *writefds, fd_set *exceptfds) -{ - int i, cnt = 0; - - for (i = 0; i < nfds; i++) { - if (readfds && (fds[i].revents & (POLLIN | POLLHUP))) { - FD_SET(fds[i].fd, readfds); - cnt++; - } - - if (writefds && (fds[i].revents & POLLOUT)) { - FD_SET(fds[i].fd, writefds); - cnt++; - } - - if (exceptfds && (fds[i].revents & ~(POLLIN | POLLOUT))) { - FD_SET(fds[i].fd, exceptfds); - cnt++; - } - } - return cnt; -} - -static int rs_convert_timeout(struct timeval *timeout) -{ - return !timeout ? -1 : - timeout->tv_sec * 1000 + timeout->tv_usec / 1000; -} - -int rselect(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) -{ - struct pollfd *fds; - int ret; - - fds = rs_select_to_poll(&nfds, readfds, writefds, exceptfds); - if (!fds) - return ERR(ENOMEM); - - ret = rpoll(fds, nfds, rs_convert_timeout(timeout)); - - if (readfds) - FD_ZERO(readfds); - if (writefds) - FD_ZERO(writefds); - if (exceptfds) - FD_ZERO(exceptfds); - - if (ret > 0) - ret = rs_poll_to_select(nfds, fds, readfds, writefds, exceptfds); - - free(fds); - return ret; -} - -/* - * For graceful disconnect, notify the remote side that we're - * disconnecting and wait until all outstanding sends complete, provided - * that the remote side has not sent a disconnect message. - */ -int rshutdown(int socket, int how) -{ - struct rsocket *rs; - int ctrl, ret = 0; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->opts & RS_OPT_SVC_ACTIVE) - rs_notify_svc(&tcp_svc, rs, RS_SVC_REM_KEEPALIVE); - - if (rs->fd_flags & O_NONBLOCK) - rs_set_nonblocking(rs, 0); - - if (rs->state & rs_connected) { - if (how == SHUT_RDWR) { - ctrl = RS_CTRL_DISCONNECT; - rs->state &= ~(rs_readable | rs_writable); - } else if (how == SHUT_WR) { - rs->state &= ~rs_writable; - ctrl = (rs->state & rs_readable) ? - RS_CTRL_SHUTDOWN : RS_CTRL_DISCONNECT; - } else { - rs->state &= ~rs_readable; - if (rs->state & rs_writable) - goto out; - ctrl = RS_CTRL_DISCONNECT; - } - if (!rs_ctrl_avail(rs)) { - ret = rs_process_cq(rs, 0, rs_conn_can_send_ctrl); - if (ret) - goto out; - } - - if ((rs->state & rs_connected) && rs_ctrl_avail(rs)) { - rs->ctrl_seqno++; - ret = rs_post_msg(rs, rs_msg_set(RS_OP_CTRL, ctrl)); - } - } - - if (rs->state & rs_connected) - rs_process_cq(rs, 0, rs_conn_all_sends_done); - -out: - if ((rs->fd_flags & O_NONBLOCK) && (rs->state & rs_connected)) - rs_set_nonblocking(rs, rs->fd_flags); - - if (rs->state & rs_disconnected) { - /* Generate event by flushing receives to unblock rpoll */ - ibv_req_notify_cq(rs->cm_id->recv_cq, 0); - ucma_shutdown(rs->cm_id); - } - - return ret; -} - -static void ds_shutdown(struct rsocket *rs) -{ - if (rs->opts & RS_OPT_SVC_ACTIVE) - rs_notify_svc(&udp_svc, rs, RS_SVC_REM_DGRAM); - - if (rs->fd_flags & O_NONBLOCK) - rs_set_nonblocking(rs, 0); - - rs->state &= ~(rs_readable | rs_writable); - ds_process_cqs(rs, 0, ds_all_sends_done); - - if (rs->fd_flags & O_NONBLOCK) - rs_set_nonblocking(rs, rs->fd_flags); -} - -int rclose(int socket) -{ - struct rsocket *rs; - - rs = idm_lookup(&idm, socket); - if (!rs) - return EBADF; - if (rs->type == SOCK_STREAM) { - if (rs->state & rs_connected) - rshutdown(socket, SHUT_RDWR); - else if (rs->opts & RS_OPT_SVC_ACTIVE) - rs_notify_svc(&tcp_svc, rs, RS_SVC_REM_KEEPALIVE); - } else { - ds_shutdown(rs); - } - - rs_free(rs); - return 0; -} - -static void rs_copy_addr(struct sockaddr *dst, struct sockaddr *src, socklen_t *len) -{ - socklen_t size; - - if (src->sa_family == AF_INET) { - size = min_t(socklen_t, *len, sizeof(struct sockaddr_in)); - *len = sizeof(struct sockaddr_in); - } else { - size = min_t(socklen_t, *len, sizeof(struct sockaddr_in6)); - *len = sizeof(struct sockaddr_in6); - } - memcpy(dst, src, size); -} - -int rgetpeername(int socket, struct sockaddr *addr, socklen_t *addrlen) -{ - struct rsocket *rs; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_STREAM) { - rs_copy_addr(addr, rdma_get_peer_addr(rs->cm_id), addrlen); - return 0; - } else { - return getpeername(rs->udp_sock, addr, addrlen); - } -} - -int rgetsockname(int socket, struct sockaddr *addr, socklen_t *addrlen) -{ - struct rsocket *rs; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_STREAM) { - rs_copy_addr(addr, rdma_get_local_addr(rs->cm_id), addrlen); - return 0; - } else { - return getsockname(rs->udp_sock, addr, addrlen); - } -} - -static int rs_set_keepalive(struct rsocket *rs, int on) -{ - FILE *f; - int ret; - - if ((on && (rs->opts & RS_OPT_SVC_ACTIVE)) || - (!on && !(rs->opts & RS_OPT_SVC_ACTIVE))) - return 0; - - if (on) { - if (!rs->keepalive_time) { - if ((f = fopen("/proc/sys/net/ipv4/tcp_keepalive_time", "r"))) { - if (fscanf(f, "%u", &rs->keepalive_time) != 1) - rs->keepalive_time = 7200; - fclose(f); - } else { - rs->keepalive_time = 7200; - } - } - ret = rs_notify_svc(&tcp_svc, rs, RS_SVC_ADD_KEEPALIVE); - } else { - ret = rs_notify_svc(&tcp_svc, rs, RS_SVC_REM_KEEPALIVE); - } - - return ret; -} - -int rsetsockopt(int socket, int level, int optname, - const void *optval, socklen_t optlen) -{ - struct rsocket *rs; - int ret, opt_on = 0; - uint64_t *opts = NULL; - - ret = ERR(ENOTSUP); - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - if (rs->type == SOCK_DGRAM && level != SOL_RDMA) { - ret = setsockopt(rs->udp_sock, level, optname, optval, optlen); - if (ret) - return ret; - } - - switch (level) { - case SOL_SOCKET: - opts = &rs->so_opts; - switch (optname) { - case SO_REUSEADDR: - if (rs->type == SOCK_STREAM) { - ret = rdma_set_option(rs->cm_id, RDMA_OPTION_ID, - RDMA_OPTION_ID_REUSEADDR, - (void *) optval, optlen); - if (ret && ((errno == ENOSYS) || ((rs->state != rs_init) && - rs->cm_id->context && - (rs->cm_id->verbs->device->transport_type == IBV_TRANSPORT_IB)))) - ret = 0; - } - opt_on = *(int *) optval; - break; - case SO_RCVBUF: - if ((rs->type == SOCK_STREAM && !rs->rbuf) || - (rs->type == SOCK_DGRAM && !rs->qp_list)) - rs->rbuf_size = (*(uint32_t *) optval) << 1; - ret = 0; - break; - case SO_SNDBUF: - if (!rs->sbuf) - rs->sbuf_size = (*(uint32_t *) optval) << 1; - if (rs->sbuf_size < RS_SNDLOWAT) - rs->sbuf_size = RS_SNDLOWAT << 1; - ret = 0; - break; - case SO_LINGER: - /* Invert value so default so_opt = 0 is on */ - opt_on = !((struct linger *) optval)->l_onoff; - ret = 0; - break; - case SO_KEEPALIVE: - ret = rs_set_keepalive(rs, *(int *) optval); - opt_on = rs->opts & RS_OPT_SVC_ACTIVE; - break; - case SO_OOBINLINE: - opt_on = *(int *) optval; - ret = 0; - break; - default: - break; - } - break; - case IPPROTO_TCP: - opts = &rs->tcp_opts; - switch (optname) { - case TCP_KEEPCNT: - case TCP_KEEPINTVL: - ret = 0; /* N/A - we're using a reliable connection */ - break; - case TCP_KEEPIDLE: - if (*(int *) optval <= 0) { - ret = ERR(EINVAL); - break; - } - rs->keepalive_time = *(int *) optval; - ret = (rs->opts & RS_OPT_SVC_ACTIVE) ? - rs_notify_svc(&tcp_svc, rs, RS_SVC_MOD_KEEPALIVE) : 0; - break; - case TCP_NODELAY: - opt_on = *(int *) optval; - ret = 0; - break; - case TCP_MAXSEG: - ret = 0; - break; - default: - break; - } - break; - case IPPROTO_IPV6: - opts = &rs->ipv6_opts; - switch (optname) { - case IPV6_V6ONLY: - if (rs->type == SOCK_STREAM) { - ret = rdma_set_option(rs->cm_id, RDMA_OPTION_ID, - RDMA_OPTION_ID_AFONLY, - (void *) optval, optlen); - } - opt_on = *(int *) optval; - break; - default: - break; - } - break; - case SOL_RDMA: - if (rs->state >= rs_opening) { - ret = ERR(EINVAL); - break; - } - - switch (optname) { - case RDMA_SQSIZE: - rs->sq_size = min_t(uint32_t, (*(uint32_t *)optval), - RS_QP_MAX_SIZE); - ret = 0; - break; - case RDMA_RQSIZE: - rs->rq_size = min_t(uint32_t, (*(uint32_t *)optval), - RS_QP_MAX_SIZE); - ret = 0; - break; - case RDMA_INLINE: - rs->sq_inline = min_t(uint32_t, *(uint32_t *)optval, - RS_QP_MAX_SIZE); - ret = 0; - break; - case RDMA_IOMAPSIZE: - rs->target_iomap_size = (uint16_t) rs_scale_to_value( - (uint8_t) rs_value_to_scale(*(int *) optval, 8), 8); - ret = 0; - break; - case RDMA_ROUTE: - if ((rs->optval = malloc(optlen))) { - memcpy(rs->optval, optval, optlen); - rs->optlen = optlen; - ret = 0; - } else { - ret = ERR(ENOMEM); - } - break; - default: - break; - } - break; - default: - break; - } - - if (!ret && opts) { - if (opt_on) - *opts |= (1 << optname); - else - *opts &= ~(1 << optname); - } - - return ret; -} - -static void rs_convert_sa_path(struct ibv_sa_path_rec *sa_path, - struct ibv_path_data *path_data) -{ - uint32_t fl_hop; - - memset(path_data, 0, sizeof(*path_data)); - path_data->path.dgid = sa_path->dgid; - path_data->path.sgid = sa_path->sgid; - path_data->path.dlid = sa_path->dlid; - path_data->path.slid = sa_path->slid; - fl_hop = be32toh(sa_path->flow_label) << 8; - path_data->path.flowlabel_hoplimit = htobe32(fl_hop | sa_path->hop_limit); - path_data->path.tclass = sa_path->traffic_class; - path_data->path.reversible_numpath = sa_path->reversible << 7 | 1; - path_data->path.pkey = sa_path->pkey; - path_data->path.qosclass_sl = htobe16(sa_path->sl); - path_data->path.mtu = sa_path->mtu | 2 << 6; /* exactly */ - path_data->path.rate = sa_path->rate | 2 << 6; - path_data->path.packetlifetime = sa_path->packet_life_time | 2 << 6; - path_data->flags= sa_path->preference; -} - -int rgetsockopt(int socket, int level, int optname, - void *optval, socklen_t *optlen) -{ - struct rsocket *rs; - void *opt; - struct ibv_sa_path_rec *path_rec; - struct ibv_path_data path_data; - socklen_t len; - int ret = 0; - int num_paths; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - switch (level) { - case SOL_SOCKET: - switch (optname) { - case SO_REUSEADDR: - case SO_KEEPALIVE: - case SO_OOBINLINE: - *((int *) optval) = !!(rs->so_opts & (1 << optname)); - *optlen = sizeof(int); - break; - case SO_RCVBUF: - *((int *) optval) = rs->rbuf_size; - *optlen = sizeof(int); - break; - case SO_SNDBUF: - *((int *) optval) = rs->sbuf_size; - *optlen = sizeof(int); - break; - case SO_LINGER: - /* Value is inverted so default so_opt = 0 is on */ - ((struct linger *) optval)->l_onoff = - !(rs->so_opts & (1 << optname)); - ((struct linger *) optval)->l_linger = 0; - *optlen = sizeof(struct linger); - break; - case SO_ERROR: - *((int *) optval) = rs->err; - *optlen = sizeof(int); - rs->err = 0; - break; - default: - ret = ENOTSUP; - break; - } - break; - case IPPROTO_TCP: - switch (optname) { - case TCP_KEEPCNT: - case TCP_KEEPINTVL: - *((int *) optval) = 1; /* N/A */ - break; - case TCP_KEEPIDLE: - *((int *) optval) = (int) rs->keepalive_time; - *optlen = sizeof(int); - break; - case TCP_NODELAY: - *((int *) optval) = !!(rs->tcp_opts & (1 << optname)); - *optlen = sizeof(int); - break; - case TCP_MAXSEG: - *((int *) optval) = (rs->cm_id && rs->cm_id->route.num_paths) ? - 1 << (7 + rs->cm_id->route.path_rec->mtu) : - 2048; - *optlen = sizeof(int); - break; - default: - ret = ENOTSUP; - break; - } - break; - case IPPROTO_IPV6: - switch (optname) { - case IPV6_V6ONLY: - *((int *) optval) = !!(rs->ipv6_opts & (1 << optname)); - *optlen = sizeof(int); - break; - default: - ret = ENOTSUP; - break; - } - break; - case SOL_RDMA: - switch (optname) { - case RDMA_SQSIZE: - *((int *) optval) = rs->sq_size; - *optlen = sizeof(int); - break; - case RDMA_RQSIZE: - *((int *) optval) = rs->rq_size; - *optlen = sizeof(int); - break; - case RDMA_INLINE: - *((int *) optval) = rs->sq_inline; - *optlen = sizeof(int); - break; - case RDMA_IOMAPSIZE: - *((int *) optval) = rs->target_iomap_size; - *optlen = sizeof(int); - break; - case RDMA_ROUTE: - if (rs->optval) { - if (*optlen < rs->optlen) { - ret = EINVAL; - } else { - memcpy(rs->optval, optval, rs->optlen); - *optlen = rs->optlen; - } - } else { - if (*optlen < sizeof(path_data)) { - ret = EINVAL; - } else { - len = 0; - opt = optval; - path_rec = rs->cm_id->route.path_rec; - num_paths = 0; - while (len + sizeof(path_data) <= *optlen && - num_paths < rs->cm_id->route.num_paths) { - rs_convert_sa_path(path_rec, &path_data); - memcpy(opt, &path_data, sizeof(path_data)); - len += sizeof(path_data); - opt += sizeof(path_data); - path_rec++; - num_paths++; - } - *optlen = len; - ret = 0; - } - } - break; - default: - ret = ENOTSUP; - break; - } - break; - default: - ret = ENOTSUP; - break; - } - - return rdma_seterrno(ret); -} - -int rfcntl(int socket, int cmd, ... /* arg */ ) -{ - struct rsocket *rs; - va_list args; - int param; - int ret = 0; - - rs = idm_lookup(&idm, socket); - if (!rs) - return ERR(EBADF); - va_start(args, cmd); - switch (cmd) { - case F_GETFL: - ret = rs->fd_flags; - break; - case F_SETFL: - param = va_arg(args, int); - if ((rs->fd_flags & O_NONBLOCK) != (param & O_NONBLOCK)) - ret = rs_set_nonblocking(rs, param & O_NONBLOCK); - - if (!ret) - rs->fd_flags = param; - break; - default: - ret = ERR(ENOTSUP); - break; - } - va_end(args); - return ret; -} - -static struct rs_iomap_mr *rs_get_iomap_mr(struct rsocket *rs) -{ - int i; - - if (!rs->remote_iomappings) { - rs->remote_iomappings = calloc(rs->remote_iomap.length, - sizeof(*rs->remote_iomappings)); - if (!rs->remote_iomappings) - return NULL; - - for (i = 0; i < rs->remote_iomap.length; i++) - rs->remote_iomappings[i].index = i; - } - - for (i = 0; i < rs->remote_iomap.length; i++) { - if (!rs->remote_iomappings[i].mr) - return &rs->remote_iomappings[i]; - } - return NULL; -} - -/* - * If an offset is given, we map to it. If offset is -1, then we map the - * offset to the address of buf. We do not check for conflicts, which must - * be fixed at some point. - */ -off_t riomap(int socket, void *buf, size_t len, int prot, int flags, off_t offset) -{ - struct rsocket *rs; - struct rs_iomap_mr *iomr; - int access = IBV_ACCESS_LOCAL_WRITE; - - rs = idm_at(&idm, socket); - if (!rs) - return ERR(EBADF); - if (!rs->cm_id->pd || (prot & ~(PROT_WRITE | PROT_NONE))) - return ERR(EINVAL); - - fastlock_acquire(&rs->map_lock); - if (prot & PROT_WRITE) { - iomr = rs_get_iomap_mr(rs); - access |= IBV_ACCESS_REMOTE_WRITE; - } else { - iomr = calloc(1, sizeof(*iomr)); - iomr->index = -1; - } - if (!iomr) { - offset = ERR(ENOMEM); - goto out; - } - - iomr->mr = ibv_reg_mr(rs->cm_id->pd, buf, len, access); - if (!iomr->mr) { - if (iomr->index < 0) - free(iomr); - offset = -1; - goto out; - } - - if (offset == -1) - offset = (uintptr_t) buf; - iomr->offset = offset; - atomic_store(&iomr->refcnt, 1); - - if (iomr->index >= 0) { - dlist_insert_tail(&iomr->entry, &rs->iomap_queue); - rs->iomap_pending = 1; - } else { - dlist_insert_tail(&iomr->entry, &rs->iomap_list); - } -out: - fastlock_release(&rs->map_lock); - return offset; -} - -int riounmap(int socket, void *buf, size_t len) -{ - struct rsocket *rs; - struct rs_iomap_mr *iomr; - dlist_entry *entry; - int ret = 0; - - rs = idm_at(&idm, socket); - if (!rs) - return ERR(EBADF); - fastlock_acquire(&rs->map_lock); - - for (entry = rs->iomap_list.next; entry != &rs->iomap_list; - entry = entry->next) { - iomr = container_of(entry, struct rs_iomap_mr, entry); - if (iomr->mr->addr == buf && iomr->mr->length == len) { - rs_release_iomap_mr(iomr); - goto out; - } - } - - for (entry = rs->iomap_queue.next; entry != &rs->iomap_queue; - entry = entry->next) { - iomr = container_of(entry, struct rs_iomap_mr, entry); - if (iomr->mr->addr == buf && iomr->mr->length == len) { - rs_release_iomap_mr(iomr); - goto out; - } - } - ret = ERR(EINVAL); -out: - fastlock_release(&rs->map_lock); - return ret; -} - -static struct rs_iomap *rs_find_iomap(struct rsocket *rs, off_t offset) -{ - int i; - - for (i = 0; i < rs->target_iomap_size; i++) { - if (offset >= rs->target_iomap[i].offset && - offset < rs->target_iomap[i].offset + rs->target_iomap[i].sge.length) - return &rs->target_iomap[i]; - } - return NULL; -} - -size_t riowrite(int socket, const void *buf, size_t count, off_t offset, int flags) -{ - struct rsocket *rs; - struct rs_iomap *iom = NULL; - struct ibv_sge sge; - size_t left = count; - uint32_t xfer_size, olen = RS_OLAP_START_SIZE; - int ret = 0; - - rs = idm_at(&idm, socket); - if (!rs) - return ERR(EBADF); - fastlock_acquire(&rs->slock); - if (rs->iomap_pending) { - ret = rs_send_iomaps(rs, flags); - if (ret) - goto out; - } - for (; left; left -= xfer_size, buf += xfer_size, offset += xfer_size) { - if (!iom || offset > iom->offset + iom->sge.length) { - iom = rs_find_iomap(rs, offset); - if (!iom) - break; - } - - if (!rs_can_send(rs)) { - ret = rs_get_comp(rs, rs_nonblocking(rs, flags), - rs_conn_can_send); - if (ret) - break; - if (!(rs->state & rs_writable)) { - ret = ERR(ECONNRESET); - break; - } - } - - if (olen < left) { - xfer_size = olen; - if (olen < RS_MAX_TRANSFER) - olen <<= 1; - } else { - xfer_size = left; - } - - if (xfer_size > rs->sbuf_bytes_avail) - xfer_size = rs->sbuf_bytes_avail; - if (xfer_size > iom->offset + iom->sge.length - offset) - xfer_size = iom->offset + iom->sge.length - offset; - - if (xfer_size <= rs->sq_inline) { - sge.addr = (uintptr_t) buf; - sge.length = xfer_size; - sge.lkey = 0; - ret = rs_write_direct(rs, iom, offset, &sge, 1, - xfer_size, IBV_SEND_INLINE); - } else if (xfer_size <= rs_sbuf_left(rs)) { - memcpy((void *) (uintptr_t) rs->ssgl[0].addr, buf, xfer_size); - rs->ssgl[0].length = xfer_size; - ret = rs_write_direct(rs, iom, offset, rs->ssgl, 1, xfer_size, 0); - if (xfer_size < rs_sbuf_left(rs)) - rs->ssgl[0].addr += xfer_size; - else - rs->ssgl[0].addr = (uintptr_t) rs->sbuf; - } else { - rs->ssgl[0].length = rs_sbuf_left(rs); - memcpy((void *) (uintptr_t) rs->ssgl[0].addr, buf, - rs->ssgl[0].length); - rs->ssgl[1].length = xfer_size - rs->ssgl[0].length; - memcpy(rs->sbuf, buf + rs->ssgl[0].length, rs->ssgl[1].length); - ret = rs_write_direct(rs, iom, offset, rs->ssgl, 2, xfer_size, 0); - rs->ssgl[0].addr = (uintptr_t) rs->sbuf + rs->ssgl[1].length; - } - if (ret) - break; - } -out: - fastlock_release(&rs->slock); - - return (ret && left == count) ? ret : count - left; -} - -/**************************************************************************** - * Service Processing Threads - ****************************************************************************/ - -static int rs_svc_grow_sets(struct rs_svc *svc, int grow_size) -{ - struct rsocket **rss; - void *set, *contexts; - - set = calloc(svc->size + grow_size, sizeof(*rss) + svc->context_size); - if (!set) - return ENOMEM; - - svc->size += grow_size; - rss = set; - contexts = set + sizeof(*rss) * svc->size; - if (svc->cnt) { - memcpy(rss, svc->rss, sizeof(*rss) * (svc->cnt + 1)); - memcpy(contexts, svc->contexts, svc->context_size * (svc->cnt + 1)); - } - - free(svc->rss); - svc->rss = rss; - svc->contexts = contexts; - return 0; -} - -/* - * Index 0 is reserved for the service's communication socket. - */ -static int rs_svc_add_rs(struct rs_svc *svc, struct rsocket *rs) -{ - int ret; - - if (svc->cnt >= svc->size - 1) { - ret = rs_svc_grow_sets(svc, 4); - if (ret) - return ret; - } - - svc->rss[++svc->cnt] = rs; - return 0; -} - -static int rs_svc_index(struct rs_svc *svc, struct rsocket *rs) -{ - int i; - - for (i = 1; i <= svc->cnt; i++) { - if (svc->rss[i] == rs) - return i; - } - return -1; -} - -static int rs_svc_rm_rs(struct rs_svc *svc, struct rsocket *rs) -{ - int i; - - if ((i = rs_svc_index(svc, rs)) >= 0) { - svc->rss[i] = svc->rss[svc->cnt]; - memcpy(svc->contexts + i * svc->context_size, - svc->contexts + svc->cnt * svc->context_size, - svc->context_size); - svc->cnt--; - return 0; - } - return EBADF; -} - -static void udp_svc_process_sock(struct rs_svc *svc) -{ - struct rs_svc_msg msg; - - read_all(svc->sock[1], &msg, sizeof msg); - switch (msg.cmd) { - case RS_SVC_ADD_DGRAM: - msg.status = rs_svc_add_rs(svc, msg.rs); - if (!msg.status) { - msg.rs->opts |= RS_OPT_SVC_ACTIVE; - udp_svc_fds = svc->contexts; - udp_svc_fds[svc->cnt].fd = msg.rs->udp_sock; - udp_svc_fds[svc->cnt].events = POLLIN; - udp_svc_fds[svc->cnt].revents = 0; - } - break; - case RS_SVC_REM_DGRAM: - msg.status = rs_svc_rm_rs(svc, msg.rs); - if (!msg.status) - msg.rs->opts &= ~RS_OPT_SVC_ACTIVE; - break; - case RS_SVC_NOOP: - msg.status = 0; - break; - default: - break; - } - - write_all(svc->sock[1], &msg, sizeof msg); -} - -static uint8_t udp_svc_sgid_index(struct ds_dest *dest, union ibv_gid *sgid) -{ - union ibv_gid gid; - int i; - - for (i = 0; i < 16; i++) { - ibv_query_gid(dest->qp->cm_id->verbs, dest->qp->cm_id->port_num, - i, &gid); - if (!memcmp(sgid, &gid, sizeof gid)) - return i; - } - return 0; -} - -static uint8_t udp_svc_path_bits(struct ds_dest *dest) -{ - struct ibv_port_attr attr; - - if (!ibv_query_port(dest->qp->cm_id->verbs, dest->qp->cm_id->port_num, &attr)) - return (uint8_t) ((1 << attr.lmc) - 1); - return 0x7f; -} - -static void udp_svc_create_ah(struct rsocket *rs, struct ds_dest *dest, uint32_t qpn) -{ - union socket_addr saddr; - struct rdma_cm_id *id; - struct ibv_ah_attr attr; - int ret; - - if (dest->ah) { - fastlock_acquire(&rs->slock); - ibv_destroy_ah(dest->ah); - dest->ah = NULL; - fastlock_release(&rs->slock); - } - - ret = rdma_create_id(NULL, &id, NULL, dest->qp->cm_id->ps); - if (ret) - return; - - memcpy(&saddr, rdma_get_local_addr(dest->qp->cm_id), - ucma_addrlen(rdma_get_local_addr(dest->qp->cm_id))); - if (saddr.sa.sa_family == AF_INET) - saddr.sin.sin_port = 0; - else - saddr.sin6.sin6_port = 0; - ret = rdma_resolve_addr(id, &saddr.sa, &dest->addr.sa, 2000); - if (ret) - goto out; - - ret = rdma_resolve_route(id, 2000); - if (ret) - goto out; - - memset(&attr, 0, sizeof attr); - if (id->route.path_rec->hop_limit > 1) { - attr.is_global = 1; - attr.grh.dgid = id->route.path_rec->dgid; - attr.grh.flow_label = be32toh(id->route.path_rec->flow_label); - attr.grh.sgid_index = udp_svc_sgid_index(dest, &id->route.path_rec->sgid); - attr.grh.hop_limit = id->route.path_rec->hop_limit; - attr.grh.traffic_class = id->route.path_rec->traffic_class; - } - attr.dlid = be16toh(id->route.path_rec->dlid); - attr.sl = id->route.path_rec->sl; - attr.src_path_bits = be16toh(id->route.path_rec->slid) & udp_svc_path_bits(dest); - attr.static_rate = id->route.path_rec->rate; - attr.port_num = id->port_num; - - fastlock_acquire(&rs->slock); - dest->qpn = qpn; - dest->ah = ibv_create_ah(dest->qp->cm_id->pd, &attr); - fastlock_release(&rs->slock); -out: - rdma_destroy_id(id); -} - -static int udp_svc_valid_udp_hdr(struct ds_udp_header *udp_hdr, - union socket_addr *addr) -{ - return (udp_hdr->tag == htobe32(DS_UDP_TAG)) && - ((udp_hdr->version == 4 && addr->sa.sa_family == AF_INET && - udp_hdr->length == DS_UDP_IPV4_HDR_LEN) || - (udp_hdr->version == 6 && addr->sa.sa_family == AF_INET6 && - udp_hdr->length == DS_UDP_IPV6_HDR_LEN)); -} - -static void udp_svc_forward(struct rsocket *rs, void *buf, size_t len, - union socket_addr *src) -{ - struct ds_header hdr; - struct ds_smsg *msg; - struct ibv_sge sge; - uint64_t offset; - - if (!ds_can_send(rs)) { - if (ds_get_comp(rs, 0, ds_can_send)) - return; - } - - msg = rs->smsg_free; - rs->smsg_free = msg->next; - rs->sqe_avail--; - - ds_format_hdr(&hdr, src); - memcpy((void *) msg, &hdr, hdr.length); - memcpy((void *) msg + hdr.length, buf, len); - sge.addr = (uintptr_t) msg; - sge.length = hdr.length + len; - sge.lkey = rs->conn_dest->qp->smr->lkey; - offset = (uint8_t *) msg - rs->sbuf; - - ds_post_send(rs, &sge, offset); -} - -static void udp_svc_process_rs(struct rsocket *rs) -{ - static uint8_t buf[RS_SNDLOWAT]; - struct ds_dest *dest, *cur_dest; - struct ds_udp_header *udp_hdr; - union socket_addr addr; - socklen_t addrlen = sizeof addr; - int len, ret; - uint32_t qpn; - - ret = recvfrom(rs->udp_sock, buf, sizeof buf, 0, &addr.sa, &addrlen); - if (ret < DS_UDP_IPV4_HDR_LEN) - return; - - udp_hdr = (struct ds_udp_header *) buf; - if (!udp_svc_valid_udp_hdr(udp_hdr, &addr)) - return; - - len = ret - udp_hdr->length; - qpn = be32toh(udp_hdr->qpn) & 0xFFFFFF; - - udp_hdr->tag = (__force __be32)be32toh(udp_hdr->tag); - udp_hdr->qpn = (__force __be32)qpn; - - ret = ds_get_dest(rs, &addr.sa, addrlen, &dest); - if (ret) - return; - - if (udp_hdr->op == RS_OP_DATA) { - fastlock_acquire(&rs->slock); - cur_dest = rs->conn_dest; - rs->conn_dest = dest; - ds_send_udp(rs, NULL, 0, 0, RS_OP_CTRL); - rs->conn_dest = cur_dest; - fastlock_release(&rs->slock); - } - - if (!dest->ah || (dest->qpn != qpn)) - udp_svc_create_ah(rs, dest, qpn); - - /* to do: handle when dest local ip address doesn't match udp ip */ - if (udp_hdr->op == RS_OP_DATA) { - fastlock_acquire(&rs->slock); - cur_dest = rs->conn_dest; - rs->conn_dest = &dest->qp->dest; - udp_svc_forward(rs, buf + udp_hdr->length, len, &addr); - rs->conn_dest = cur_dest; - fastlock_release(&rs->slock); - } -} - -static void *udp_svc_run(void *arg) -{ - struct rs_svc *svc = arg; - struct rs_svc_msg msg; - int i, ret; - - ret = rs_svc_grow_sets(svc, 4); - if (ret) { - msg.status = ret; - write_all(svc->sock[1], &msg, sizeof msg); - return (void *) (uintptr_t) ret; - } - - udp_svc_fds = svc->contexts; - udp_svc_fds[0].fd = svc->sock[1]; - udp_svc_fds[0].events = POLLIN; - do { - for (i = 0; i <= svc->cnt; i++) - udp_svc_fds[i].revents = 0; - - poll(udp_svc_fds, svc->cnt + 1, -1); - if (udp_svc_fds[0].revents) - udp_svc_process_sock(svc); - - for (i = 1; i <= svc->cnt; i++) { - if (udp_svc_fds[i].revents) - udp_svc_process_rs(svc->rss[i]); - } - } while (svc->cnt >= 1); - - return NULL; -} - -static uint32_t rs_get_time(void) -{ - struct timeval now; - - memset(&now, 0, sizeof now); - gettimeofday(&now, NULL); - return (uint32_t) now.tv_sec; -} - -static void tcp_svc_process_sock(struct rs_svc *svc) -{ - struct rs_svc_msg msg; - int i; - - read_all(svc->sock[1], &msg, sizeof msg); - switch (msg.cmd) { - case RS_SVC_ADD_KEEPALIVE: - msg.status = rs_svc_add_rs(svc, msg.rs); - if (!msg.status) { - msg.rs->opts |= RS_OPT_SVC_ACTIVE; - tcp_svc_timeouts = svc->contexts; - tcp_svc_timeouts[svc->cnt] = rs_get_time() + - msg.rs->keepalive_time; - } - break; - case RS_SVC_REM_KEEPALIVE: - msg.status = rs_svc_rm_rs(svc, msg.rs); - if (!msg.status) - msg.rs->opts &= ~RS_OPT_SVC_ACTIVE; - break; - case RS_SVC_MOD_KEEPALIVE: - i = rs_svc_index(svc, msg.rs); - if (i >= 0) { - tcp_svc_timeouts[i] = rs_get_time() + msg.rs->keepalive_time; - msg.status = 0; - } else { - msg.status = EBADF; - } - break; - case RS_SVC_NOOP: - msg.status = 0; - break; - default: - break; - } - write_all(svc->sock[1], &msg, sizeof msg); -} - -/* - * Send a 0 byte RDMA write with immediate as keep-alive message. - * This avoids the need for the receive side to do any acknowledgment. - */ -static void tcp_svc_send_keepalive(struct rsocket *rs) -{ - fastlock_acquire(&rs->cq_lock); - if (rs_ctrl_avail(rs) && (rs->state & rs_connected)) { - rs->ctrl_seqno++; - rs_post_write(rs, NULL, 0, rs_msg_set(RS_OP_CTRL, RS_CTRL_KEEPALIVE), - 0, (uintptr_t) NULL, (uintptr_t) NULL); - } - fastlock_release(&rs->cq_lock); -} - -static void *tcp_svc_run(void *arg) -{ - struct rs_svc *svc = arg; - struct rs_svc_msg msg; - struct pollfd fds; - uint32_t now, next_timeout; - int i, ret, timeout; - - ret = rs_svc_grow_sets(svc, 16); - if (ret) { - msg.status = ret; - write_all(svc->sock[1], &msg, sizeof msg); - return (void *) (uintptr_t) ret; - } - - tcp_svc_timeouts = svc->contexts; - fds.fd = svc->sock[1]; - fds.events = POLLIN; - timeout = -1; - do { - poll(&fds, 1, timeout * 1000); - if (fds.revents) - tcp_svc_process_sock(svc); - - now = rs_get_time(); - next_timeout = ~0; - for (i = 1; i <= svc->cnt; i++) { - if (tcp_svc_timeouts[i] <= now) { - tcp_svc_send_keepalive(svc->rss[i]); - tcp_svc_timeouts[i] = - now + svc->rss[i]->keepalive_time; - } - if (tcp_svc_timeouts[i] < next_timeout) - next_timeout = tcp_svc_timeouts[i]; - } - timeout = (int) (next_timeout - now); - } while (svc->cnt >= 1); - - return NULL; -} diff --git a/usr/rdma-core/librdmacm/rsocket.h b/usr/rdma-core/librdmacm/rsocket.h deleted file mode 100644 index efd0db58b..000000000 --- a/usr/rdma-core/librdmacm/rsocket.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2011-2012 Intel Corporation. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(RSOCKET_H) -#define RSOCKET_H - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int rsocket(int domain, int type, int protocol); -int rbind(int socket, const struct sockaddr *addr, socklen_t addrlen); -int rlisten(int socket, int backlog); -int raccept(int socket, struct sockaddr *addr, socklen_t *addrlen); -int rconnect(int socket, const struct sockaddr *addr, socklen_t addrlen); -int rshutdown(int socket, int how); -int rclose(int socket); - -ssize_t rrecv(int socket, void *buf, size_t len, int flags); -ssize_t rrecvfrom(int socket, void *buf, size_t len, int flags, - struct sockaddr *src_addr, socklen_t *addrlen); -ssize_t rrecvmsg(int socket, struct msghdr *msg, int flags); -ssize_t rsend(int socket, const void *buf, size_t len, int flags); -ssize_t rsendto(int socket, const void *buf, size_t len, int flags, - const struct sockaddr *dest_addr, socklen_t addrlen); -ssize_t rsendmsg(int socket, const struct msghdr *msg, int flags); -ssize_t rread(int socket, void *buf, size_t count); -ssize_t rreadv(int socket, const struct iovec *iov, int iovcnt); -ssize_t rwrite(int socket, const void *buf, size_t count); -ssize_t rwritev(int socket, const struct iovec *iov, int iovcnt); - -int rpoll(struct pollfd *fds, nfds_t nfds, int timeout); -int rselect(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout); - -int rgetpeername(int socket, struct sockaddr *addr, socklen_t *addrlen); -int rgetsockname(int socket, struct sockaddr *addr, socklen_t *addrlen); - -#define SOL_RDMA 0x10000 -enum { - RDMA_SQSIZE, - RDMA_RQSIZE, - RDMA_INLINE, - RDMA_IOMAPSIZE, - RDMA_ROUTE -}; - -int rsetsockopt(int socket, int level, int optname, - const void *optval, socklen_t optlen); -int rgetsockopt(int socket, int level, int optname, - void *optval, socklen_t *optlen); -int rfcntl(int socket, int cmd, ... /* arg */ ); - -off_t riomap(int socket, void *buf, size_t len, int prot, int flags, off_t offset); -int riounmap(int socket, void *buf, size_t len); -size_t riowrite(int socket, const void *buf, size_t count, off_t offset, int flags); - -#ifdef __cplusplus -} -#endif - -#endif /* RSOCKET_H */ diff --git a/usr/rdma-core/providers/bnxt_re/CMakeLists.txt b/usr/rdma-core/providers/bnxt_re/CMakeLists.txt deleted file mode 100644 index 13ad287c1..000000000 --- a/usr/rdma-core/providers/bnxt_re/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -rdma_provider(bnxt_re - db.c - main.c - memory.c - verbs.c -) diff --git a/usr/rdma-core/providers/bnxt_re/bnxt_re-abi.h b/usr/rdma-core/providers/bnxt_re/bnxt_re-abi.h deleted file mode 100644 index 73beef598..000000000 --- a/usr/rdma-core/providers/bnxt_re/bnxt_re-abi.h +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: ABI data structure definition - */ - -#ifndef __BNXT_RE_ABI_H__ -#define __BNXT_RE_ABI_H__ - -#include - -#define BNXT_RE_ABI_VERSION 1 - -#define BNXT_RE_FULL_FLAG_DELTA 0x80 - -enum bnxt_re_wr_opcode { - BNXT_RE_WR_OPCD_SEND = 0x00, - BNXT_RE_WR_OPCD_SEND_IMM = 0x01, - BNXT_RE_WR_OPCD_SEND_INVAL = 0x02, - BNXT_RE_WR_OPCD_RDMA_WRITE = 0x04, - BNXT_RE_WR_OPCD_RDMA_WRITE_IMM = 0x05, - BNXT_RE_WR_OPCD_RDMA_READ = 0x06, - BNXT_RE_WR_OPCD_ATOMIC_CS = 0x08, - BNXT_RE_WR_OPCD_ATOMIC_FA = 0x0B, - BNXT_RE_WR_OPCD_LOC_INVAL = 0x0C, - BNXT_RE_WR_OPCD_BIND = 0x0E, - BNXT_RE_WR_OPCD_RECV = 0x80, - BNXT_RE_WR_OPCD_INVAL = 0xFF -}; - -enum bnxt_re_wr_flags { - BNXT_RE_WR_FLAGS_INLINE = 0x10, - BNXT_RE_WR_FLAGS_SE = 0x08, - BNXT_RE_WR_FLAGS_UC_FENCE = 0x04, - BNXT_RE_WR_FLAGS_RD_FENCE = 0x02, - BNXT_RE_WR_FLAGS_SIGNALED = 0x01 -}; - -enum bnxt_re_wc_type { - BNXT_RE_WC_TYPE_SEND = 0x00, - BNXT_RE_WC_TYPE_RECV_RC = 0x01, - BNXT_RE_WC_TYPE_RECV_UD = 0x02, - BNXT_RE_WC_TYPE_RECV_RAW = 0x03, - BNXT_RE_WC_TYPE_TERM = 0x0E, - BNXT_RE_WC_TYPE_COFF = 0x0F -}; - -enum bnxt_re_req_wc_status { - BNXT_RE_REQ_ST_OK = 0x00, - BNXT_RE_REQ_ST_BAD_RESP = 0x01, - BNXT_RE_REQ_ST_LOC_LEN = 0x02, - BNXT_RE_REQ_ST_LOC_QP_OP = 0x03, - BNXT_RE_REQ_ST_PROT = 0x04, - BNXT_RE_REQ_ST_MEM_OP = 0x05, - BNXT_RE_REQ_ST_REM_INVAL = 0x06, - BNXT_RE_REQ_ST_REM_ACC = 0x07, - BNXT_RE_REQ_ST_REM_OP = 0x08, - BNXT_RE_REQ_ST_RNR_NAK_XCED = 0x09, - BNXT_RE_REQ_ST_TRNSP_XCED = 0x0A, - BNXT_RE_REQ_ST_WR_FLUSH = 0x0B -}; - -enum bnxt_re_rsp_wc_status { - BNXT_RE_RSP_ST_OK = 0x00, - BNXT_RE_RSP_ST_LOC_ACC = 0x01, - BNXT_RE_RSP_ST_LOC_LEN = 0x02, - BNXT_RE_RSP_ST_LOC_PROT = 0x03, - BNXT_RE_RSP_ST_LOC_QP_OP = 0x04, - BNXT_RE_RSP_ST_MEM_OP = 0x05, - BNXT_RE_RSP_ST_REM_INVAL = 0x06, - BNXT_RE_RSP_ST_WR_FLUSH = 0x07, - BNXT_RE_RSP_ST_HW_FLUSH = 0x08 -}; - -enum bnxt_re_hdr_offset { - BNXT_RE_HDR_WT_MASK = 0xFF, - BNXT_RE_HDR_FLAGS_MASK = 0xFF, - BNXT_RE_HDR_FLAGS_SHIFT = 0x08, - BNXT_RE_HDR_WS_MASK = 0xFF, - BNXT_RE_HDR_WS_SHIFT = 0x10 -}; - -enum bnxt_re_db_que_type { - BNXT_RE_QUE_TYPE_SQ = 0x00, - BNXT_RE_QUE_TYPE_RQ = 0x01, - BNXT_RE_QUE_TYPE_SRQ = 0x02, - BNXT_RE_QUE_TYPE_SRQ_ARM = 0x03, - BNXT_RE_QUE_TYPE_CQ = 0x04, - BNXT_RE_QUE_TYPE_CQ_ARMSE = 0x05, - BNXT_RE_QUE_TYPE_CQ_ARMALL = 0x06, - BNXT_RE_QUE_TYPE_CQ_ARMENA = 0x07, - BNXT_RE_QUE_TYPE_SRQ_ARMENA = 0x08, - BNXT_RE_QUE_TYPE_CQ_CUT_ACK = 0x09, - BNXT_RE_QUE_TYPE_NULL = 0x0F -}; - -enum bnxt_re_db_mask { - BNXT_RE_DB_INDX_MASK = 0xFFFFFUL, - BNXT_RE_DB_QID_MASK = 0xFFFFFUL, - BNXT_RE_DB_TYP_MASK = 0x0FUL, - BNXT_RE_DB_TYP_SHIFT = 0x1C -}; - -enum bnxt_re_psns_mask { - BNXT_RE_PSNS_SPSN_MASK = 0xFFFFFF, - BNXT_RE_PSNS_OPCD_MASK = 0xFF, - BNXT_RE_PSNS_OPCD_SHIFT = 0x18, - BNXT_RE_PSNS_NPSN_MASK = 0xFFFFFF, - BNXT_RE_PSNS_FLAGS_MASK = 0xFF, - BNXT_RE_PSNS_FLAGS_SHIFT = 0x18 -}; - -enum bnxt_re_bcqe_mask { - BNXT_RE_BCQE_PH_MASK = 0x01, - BNXT_RE_BCQE_TYPE_MASK = 0x0F, - BNXT_RE_BCQE_TYPE_SHIFT = 0x01, - BNXT_RE_BCQE_STATUS_MASK = 0xFF, - BNXT_RE_BCQE_STATUS_SHIFT = 0x08, - BNXT_RE_BCQE_FLAGS_MASK = 0xFFFFU, - BNXT_RE_BCQE_FLAGS_SHIFT = 0x10, - BNXT_RE_BCQE_RWRID_MASK = 0xFFFFFU, - BNXT_RE_BCQE_SRCQP_MASK = 0xFF, - BNXT_RE_BCQE_SRCQP_SHIFT = 0x18 -}; - -enum bnxt_re_rc_flags_mask { - BNXT_RE_RC_FLAGS_SRQ_RQ_MASK = 0x01, - BNXT_RE_RC_FLAGS_IMM_MASK = 0x02, - BNXT_RE_RC_FLAGS_IMM_SHIFT = 0x01, - BNXT_RE_RC_FLAGS_INV_MASK = 0x04, - BNXT_RE_RC_FLAGS_INV_SHIFT = 0x02, - BNXT_RE_RC_FLAGS_RDMA_MASK = 0x08, - BNXT_RE_RC_FLAGS_RDMA_SHIFT = 0x03 -}; - -enum bnxt_re_ud_flags_mask { - BNXT_RE_UD_FLAGS_SRQ_RQ_MASK = 0x01, - BNXT_RE_UD_FLAGS_IMM_MASK = 0x02, - BNXT_RE_UD_FLAGS_HDR_TYP_MASK = 0x0C, - - BNXT_RE_UD_FLAGS_SRQ = 0x01, - BNXT_RE_UD_FLAGS_RQ = 0x00, - BNXT_RE_UD_FLAGS_ROCE = 0x00, - BNXT_RE_UD_FLAGS_ROCE_IPV4 = 0x02, - BNXT_RE_UD_FLAGS_ROCE_IPV6 = 0x03 -}; - -enum bnxt_re_ud_cqe_mask { - BNXT_RE_UD_CQE_MAC_MASK = 0xFFFFFFFFFFFFULL, - BNXT_RE_UD_CQE_SRCQPLO_MASK = 0xFFFF, - BNXT_RE_UD_CQE_SRCQPLO_SHIFT = 0x30 -}; - -enum bnxt_re_shpg_offt { - BNXT_RE_SHPG_BEG_RESV_OFFT = 0x00, - BNXT_RE_SHPG_AVID_OFFT = 0x10, - BNXT_RE_SHPG_AVID_SIZE = 0x04, - BNXT_RE_SHPG_END_RESV_OFFT = 0xFF0 -}; - -struct bnxt_re_db_hdr { - __le32 indx; - __le32 typ_qid; /* typ: 4, qid:20*/ -}; - -struct bnxt_re_cntx_resp { - struct ibv_get_context_resp resp; - __u32 dev_id; - __u32 max_qp; /* To allocate qp-table */ - __u32 pg_size; - __u32 cqe_size; - __u32 max_cqd; - __u32 rsvd; -}; - -struct bnxt_re_pd_resp { - struct ibv_alloc_pd_resp resp; - __u32 pdid; - __u32 dpi; - __u64 dbr; -}; - -struct bnxt_re_mr_resp { - struct ibv_reg_mr_resp resp; -}; - -struct bnxt_re_cq_req { - struct ibv_create_cq cmd; - __u64 cq_va; - __u64 cq_handle; -}; - -struct bnxt_re_cq_resp { - struct ibv_create_cq_resp resp; - __u32 cqid; - __u32 tail; - __u32 phase; - __u32 rsvd; -}; - -struct bnxt_re_bcqe { - __le32 flg_st_typ_ph; - __le32 qphi_rwrid; -}; - -struct bnxt_re_req_cqe { - __le64 qp_handle; - __le32 con_indx; /* 16 bits valid. */ - __le32 rsvd1; - __le64 rsvd2; -}; - -struct bnxt_re_rc_cqe { - __le32 length; - __le32 imm_key; - __le64 qp_handle; - __le64 mr_handle; -}; - -struct bnxt_re_ud_cqe { - __le32 length; /* 14 bits */ - __le32 immd; - __le64 qp_handle; - __le64 qplo_mac; /* 16:48*/ -}; - -struct bnxt_re_term_cqe { - __le64 qp_handle; - __le32 rq_sq_cidx; - __le32 rsvd; - __le64 rsvd1; -}; - -struct bnxt_re_qp_req { - struct ibv_create_qp cmd; - __u64 qpsva; - __u64 qprva; - __u64 qp_handle; -}; - -struct bnxt_re_qp_resp { - struct ibv_create_qp_resp resp; - __u32 qpid; - __u32 rsvd; -}; - -struct bnxt_re_bsqe { - __le32 rsv_ws_fl_wt; - __le32 key_immd; -}; - -struct bnxt_re_psns { - __le32 opc_spsn; - __le32 flg_npsn; -}; - -struct bnxt_re_sge { - __le64 pa; - __le32 lkey; - __le32 length; -}; - -/* Cu+ max inline data */ -#define BNXT_RE_MAX_INLINE_SIZE 0x60 - -struct bnxt_re_send { - __le32 length; - __le32 qkey; - __le32 dst_qp; - __le32 avid; - __le64 rsvd; -}; - -struct bnxt_re_raw { - __le32 length; - __le32 rsvd1; - __le32 cfa_meta; - __le32 rsvd2; - __le64 rsvd3; -}; - -struct bnxt_re_rdma { - __le32 length; - __le32 rsvd1; - __le64 rva; - __le32 rkey; - __le32 rsvd2; -}; - -struct bnxt_re_atomic { - __le64 rva; - __le64 swp_dt; - __le64 cmp_dt; -}; - -struct bnxt_re_inval { - __le64 rsvd[3]; -}; - -struct bnxt_re_bind { - __le32 plkey; - __le32 lkey; - __le64 va; - __le64 len; /* only 40 bits are valid */ -}; - -struct bnxt_re_brqe { - __le32 rsv_ws_fl_wt; - __le32 rsvd; -}; - -struct bnxt_re_rqe { - __le32 wrid; - __le32 rsvd1; - __le64 rsvd[2]; -}; - -struct bnxt_re_srqe { - __le32 srq_tag; /* 20 bits are valid */ - __le32 rsvd1; - __le64 rsvd[2]; -}; -#endif diff --git a/usr/rdma-core/providers/bnxt_re/db.c b/usr/rdma-core/providers/bnxt_re/db.c deleted file mode 100644 index c5ab4dbbc..000000000 --- a/usr/rdma-core/providers/bnxt_re/db.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: Doorbell handling functions. - */ - -#include -#include "main.h" - -static void bnxt_re_ring_db(struct bnxt_re_dpi *dpi, - struct bnxt_re_db_hdr *hdr) -{ - __le64 *dbval; - - pthread_spin_lock(&dpi->db_lock); - dbval = (__le64 *)&hdr->indx; - udma_to_device_barrier(); - iowrite64(dpi->dbpage, dbval); - pthread_spin_unlock(&dpi->db_lock); -} - -static void bnxt_re_init_db_hdr(struct bnxt_re_db_hdr *hdr, uint32_t indx, - uint32_t qid, uint32_t typ) -{ - hdr->indx = htole32(indx & BNXT_RE_DB_INDX_MASK); - hdr->typ_qid = htole32(qid & BNXT_RE_DB_QID_MASK); - hdr->typ_qid |= htole32(((typ & BNXT_RE_DB_TYP_MASK) << - BNXT_RE_DB_TYP_SHIFT)); -} - -void bnxt_re_ring_rq_db(struct bnxt_re_qp *qp) -{ - struct bnxt_re_db_hdr hdr; - - bnxt_re_init_db_hdr(&hdr, qp->rqq->tail, qp->qpid, BNXT_RE_QUE_TYPE_RQ); - bnxt_re_ring_db(qp->udpi, &hdr); -} - -void bnxt_re_ring_sq_db(struct bnxt_re_qp *qp) -{ - struct bnxt_re_db_hdr hdr; - - bnxt_re_init_db_hdr(&hdr, qp->sqq->tail, qp->qpid, BNXT_RE_QUE_TYPE_SQ); - bnxt_re_ring_db(qp->udpi, &hdr); -} - -void bnxt_re_ring_cq_db(struct bnxt_re_cq *cq) -{ - struct bnxt_re_db_hdr hdr; - - bnxt_re_init_db_hdr(&hdr, cq->cqq.head, cq->cqid, BNXT_RE_QUE_TYPE_CQ); - bnxt_re_ring_db(cq->udpi, &hdr); -} - -void bnxt_re_ring_cq_arm_db(struct bnxt_re_cq *cq, uint8_t aflag) -{ - struct bnxt_re_db_hdr hdr; - - bnxt_re_init_db_hdr(&hdr, cq->cqq.head, cq->cqid, aflag); - bnxt_re_ring_db(cq->udpi, &hdr); -} diff --git a/usr/rdma-core/providers/bnxt_re/flush.h b/usr/rdma-core/providers/bnxt_re/flush.h deleted file mode 100644 index a39ea7151..000000000 --- a/usr/rdma-core/providers/bnxt_re/flush.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: A few wrappers for flush queue management - */ - -#ifndef __FLUSH_H__ -#define __FLUSH_H__ - -#include - -struct bnxt_re_fque_node { - uint8_t valid; - struct list_node list; -}; - -static inline void fque_init_node(struct bnxt_re_fque_node *node) -{ - list_node_init(&node->list); - node->valid = false; -} - -static inline void fque_add_node_tail(struct list_head *head, - struct bnxt_re_fque_node *new) -{ - list_add_tail(head, &new->list); - new->valid = true; -} - -static inline void fque_del_node(struct bnxt_re_fque_node *entry) -{ - entry->valid = false; - list_del(&entry->list); -} - -static inline uint8_t _fque_node_valid(struct bnxt_re_fque_node *node) -{ - return node->valid; -} - -static inline void bnxt_re_fque_add_node(struct list_head *head, - struct bnxt_re_fque_node *node) -{ - if (!_fque_node_valid(node)) - fque_add_node_tail(head, node); -} - -static inline void bnxt_re_fque_del_node(struct bnxt_re_fque_node *node) -{ - if (_fque_node_valid(node)) - fque_del_node(node); -} -#endif /* __FLUSH_H__ */ diff --git a/usr/rdma-core/providers/bnxt_re/main.c b/usr/rdma-core/providers/bnxt_re/main.c deleted file mode 100644 index 998c9fe33..000000000 --- a/usr/rdma-core/providers/bnxt_re/main.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: Device detection and initializatoin - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "main.h" -#include "verbs.h" - -#define PCI_VENDOR_ID_BROADCOM 0x14E4 - -#define CNA(v, d) VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, d, NULL) -static const struct verbs_match_ent cna_table[] = { - CNA(BROADCOM, 0x16C0), /* BCM57417 NPAR */ - CNA(BROADCOM, 0x16CE), /* BMC57311 */ - CNA(BROADCOM, 0x16CF), /* BMC57312 */ - CNA(BROADCOM, 0x16DF), /* BMC57314 */ - CNA(BROADCOM, 0x16E5), /* BMC57314 VF */ - CNA(BROADCOM, 0x16E2), /* BMC57417 */ - CNA(BROADCOM, 0x16E3), /* BMC57416 */ - CNA(BROADCOM, 0x16D6), /* BMC57412*/ - CNA(BROADCOM, 0x16D7), /* BMC57414 */ - CNA(BROADCOM, 0x16D8), /* BMC57416 Cu */ - CNA(BROADCOM, 0x16D9), /* BMC57417 Cu */ - CNA(BROADCOM, 0x16C1), /* BMC57414 VF */ - CNA(BROADCOM, 0x16EF), /* BCM57416 NPAR */ - CNA(BROADCOM, 0x16ED), /* BCM57414 NPAR */ - CNA(BROADCOM, 0x16EB), /* BCM57412 NPAR */ - CNA(BROADCOM, 0x16F0), /* BCM58730 */ - CNA(BROADCOM, 0x16F1), /* BCM57452 */ - CNA(BROADCOM, 0xD802), /* BCM58802 */ - {} -}; - -static struct ibv_context_ops bnxt_re_cntx_ops = { - .query_device = bnxt_re_query_device, - .query_port = bnxt_re_query_port, - .alloc_pd = bnxt_re_alloc_pd, - .dealloc_pd = bnxt_re_free_pd, - .reg_mr = bnxt_re_reg_mr, - .dereg_mr = bnxt_re_dereg_mr, - .create_cq = bnxt_re_create_cq, - .poll_cq = bnxt_re_poll_cq, - .req_notify_cq = bnxt_re_arm_cq, - .cq_event = bnxt_re_cq_event, - .resize_cq = bnxt_re_resize_cq, - .destroy_cq = bnxt_re_destroy_cq, - .create_srq = bnxt_re_create_srq, - .modify_srq = bnxt_re_modify_srq, - .query_srq = bnxt_re_query_srq, - .destroy_srq = bnxt_re_destroy_srq, - .post_srq_recv = bnxt_re_post_srq_recv, - .create_qp = bnxt_re_create_qp, - .query_qp = bnxt_re_query_qp, - .modify_qp = bnxt_re_modify_qp, - .destroy_qp = bnxt_re_destroy_qp, - .post_send = bnxt_re_post_send, - .post_recv = bnxt_re_post_recv, - .create_ah = bnxt_re_create_ah, - .destroy_ah = bnxt_re_destroy_ah -}; - -/* Context Init functions */ -static int bnxt_re_init_context(struct verbs_device *vdev, - struct ibv_context *ibvctx, int cmd_fd) -{ - struct ibv_get_context cmd; - struct bnxt_re_cntx_resp resp; - struct bnxt_re_dev *dev; - struct bnxt_re_context *cntx; - - dev = to_bnxt_re_dev(&vdev->device); - cntx = to_bnxt_re_context(ibvctx); - - memset(&resp, 0, sizeof(resp)); - ibvctx->cmd_fd = cmd_fd; - if (ibv_cmd_get_context(ibvctx, &cmd, sizeof(cmd), - &resp.resp, sizeof(resp))) - return errno; - - cntx->dev_id = resp.dev_id; - cntx->max_qp = resp.max_qp; - dev->pg_size = resp.pg_size; - dev->cqe_size = resp.cqe_size; - dev->max_cq_depth = resp.max_cqd; - pthread_spin_init(&cntx->fqlock, PTHREAD_PROCESS_PRIVATE); - /* mmap shared page. */ - cntx->shpg = mmap(NULL, dev->pg_size, PROT_READ | PROT_WRITE, - MAP_SHARED, cmd_fd, 0); - if (cntx->shpg == MAP_FAILED) { - cntx->shpg = NULL; - goto failed; - } - pthread_mutex_init(&cntx->shlock, NULL); - - ibvctx->ops = bnxt_re_cntx_ops; - - return 0; -failed: - fprintf(stderr, DEV "Failed to allocate context for device\n"); - return errno; -} - -static void bnxt_re_uninit_context(struct verbs_device *vdev, - struct ibv_context *ibvctx) -{ - struct bnxt_re_dev *dev; - struct bnxt_re_context *cntx; - - dev = to_bnxt_re_dev(&vdev->device); - cntx = to_bnxt_re_context(ibvctx); - /* Unmap if anything device specific was mapped in init_context. */ - pthread_mutex_destroy(&cntx->shlock); - if (cntx->shpg) - munmap(cntx->shpg, dev->pg_size); - pthread_spin_destroy(&cntx->fqlock); - - /* Un-map DPI only for the first PD that was - * allocated in this context. - */ - if (cntx->udpi.dbpage && cntx->udpi.dbpage != MAP_FAILED) { - pthread_spin_destroy(&cntx->udpi.db_lock); - munmap(cntx->udpi.dbpage, dev->pg_size); - cntx->udpi.dbpage = NULL; - } -} - -static struct verbs_device * -bnxt_re_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct bnxt_re_dev *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->vdev.sz = sizeof(*dev); - dev->vdev.size_of_context = - sizeof(struct bnxt_re_context) - sizeof(struct ibv_context); - - return &dev->vdev; -} - -static const struct verbs_device_ops bnxt_re_dev_ops = { - .name = "bnxt_re", - .match_min_abi_version = BNXT_RE_ABI_VERSION, - .match_max_abi_version = BNXT_RE_ABI_VERSION, - .match_table = cna_table, - .alloc_device = bnxt_re_device_alloc, - .init_context = bnxt_re_init_context, - .uninit_context = bnxt_re_uninit_context, -}; -PROVIDER_DRIVER(bnxt_re_dev_ops); diff --git a/usr/rdma-core/providers/bnxt_re/main.h b/usr/rdma-core/providers/bnxt_re/main.h deleted file mode 100644 index 9688fec67..000000000 --- a/usr/rdma-core/providers/bnxt_re/main.h +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: Basic device data structures needed for book-keeping - */ - -#ifndef __MAIN_H__ -#define __MAIN_H__ - -#include -#include -#include -#include -#include - -#include -#include - -#include "bnxt_re-abi.h" -#include "memory.h" -#include "flush.h" - -#define DEV "bnxt_re : " - -#define BNXT_RE_UD_QP_HW_STALL 0x400000 - -struct bnxt_re_dpi { - __u32 dpindx; - __u64 *dbpage; - pthread_spinlock_t db_lock; -}; - -struct bnxt_re_pd { - struct ibv_pd ibvpd; - uint32_t pdid; -}; - -struct bnxt_re_cq { - struct ibv_cq ibvcq; - uint32_t cqid; - struct bnxt_re_queue cqq; - struct bnxt_re_dpi *udpi; - struct list_head sfhead; - struct list_head rfhead; - uint32_t cqe_size; - uint8_t phase; -}; - -struct bnxt_re_srq { - struct ibv_srq ibvsrq; -}; - -struct bnxt_re_wrid { - struct bnxt_re_psns *psns; - uint64_t wrid; - uint32_t bytes; - uint8_t sig; -}; - -struct bnxt_re_qpcap { - uint32_t max_swr; - uint32_t max_rwr; - uint32_t max_ssge; - uint32_t max_rsge; - uint32_t max_inline; - uint8_t sqsig; -}; - -struct bnxt_re_qp { - struct ibv_qp ibvqp; - struct bnxt_re_queue *sqq; - struct bnxt_re_wrid *swrid; - struct bnxt_re_queue *rqq; - struct bnxt_re_wrid *rwrid; - struct bnxt_re_srq *srq; - struct bnxt_re_cq *scq; - struct bnxt_re_cq *rcq; - struct bnxt_re_dpi *udpi; - struct bnxt_re_qpcap cap; - struct bnxt_re_fque_node snode; - struct bnxt_re_fque_node rnode; - uint32_t qpid; - uint32_t tbl_indx; - uint32_t sq_psn; - uint32_t pending_db; - uint64_t wqe_cnt; - uint16_t mtu; - uint16_t qpst; - uint8_t qptyp; - /* irdord? */ -}; - -struct bnxt_re_mr { - struct ibv_mr ibvmr; -}; - -struct bnxt_re_ah { - struct ibv_ah ibvah; - uint32_t avid; -}; - -struct bnxt_re_dev { - struct verbs_device vdev; - uint8_t abi_version; - uint32_t pg_size; - - uint32_t cqe_size; - uint32_t max_cq_depth; -}; - -struct bnxt_re_context { - struct ibv_context ibvctx; - uint32_t dev_id; - uint32_t max_qp; - uint32_t max_srq; - struct bnxt_re_dpi udpi; - void *shpg; - pthread_mutex_t shlock; - pthread_spinlock_t fqlock; -}; - -/* DB ring functions used internally*/ -void bnxt_re_ring_rq_db(struct bnxt_re_qp *qp); -void bnxt_re_ring_sq_db(struct bnxt_re_qp *qp); -void bnxt_re_ring_srq_db(struct bnxt_re_srq *srq); -void bnxt_re_ring_cq_db(struct bnxt_re_cq *cq); -void bnxt_re_ring_cq_arm_db(struct bnxt_re_cq *cq, uint8_t aflag); - -/* pointer conversion functions*/ -static inline struct bnxt_re_dev *to_bnxt_re_dev(struct ibv_device *ibvdev) -{ - return container_of(ibvdev, struct bnxt_re_dev, vdev); -} - -static inline struct bnxt_re_context *to_bnxt_re_context( - struct ibv_context *ibvctx) -{ - return container_of(ibvctx, struct bnxt_re_context, ibvctx); -} - -static inline struct bnxt_re_pd *to_bnxt_re_pd(struct ibv_pd *ibvpd) -{ - return container_of(ibvpd, struct bnxt_re_pd, ibvpd); -} - -static inline struct bnxt_re_cq *to_bnxt_re_cq(struct ibv_cq *ibvcq) -{ - return container_of(ibvcq, struct bnxt_re_cq, ibvcq); -} - -static inline struct bnxt_re_qp *to_bnxt_re_qp(struct ibv_qp *ibvqp) -{ - return container_of(ibvqp, struct bnxt_re_qp, ibvqp); -} - -static inline struct bnxt_re_ah *to_bnxt_re_ah(struct ibv_ah *ibvah) -{ - return container_of(ibvah, struct bnxt_re_ah, ibvah); -} - -static inline uint32_t bnxt_re_get_sqe_sz(void) -{ - return sizeof(struct bnxt_re_bsqe) + - sizeof(struct bnxt_re_send) + - BNXT_RE_MAX_INLINE_SIZE; -} - -static inline uint32_t bnxt_re_get_sqe_hdr_sz(void) -{ - return sizeof(struct bnxt_re_bsqe) + sizeof(struct bnxt_re_send); -} - -static inline uint32_t bnxt_re_get_rqe_sz(void) -{ - return sizeof(struct bnxt_re_brqe) + - sizeof(struct bnxt_re_rqe) + - BNXT_RE_MAX_INLINE_SIZE; -} - -static inline uint32_t bnxt_re_get_rqe_hdr_sz(void) -{ - return sizeof(struct bnxt_re_brqe) + sizeof(struct bnxt_re_rqe); -} - -static inline uint32_t bnxt_re_get_cqe_sz(void) -{ - return sizeof(struct bnxt_re_req_cqe) + sizeof(struct bnxt_re_bcqe); -} - -static inline uint8_t bnxt_re_ibv_to_bnxt_wr_opcd(uint8_t ibv_opcd) -{ - uint8_t bnxt_opcd; - - switch (ibv_opcd) { - case IBV_WR_SEND: - bnxt_opcd = BNXT_RE_WR_OPCD_SEND; - break; - case IBV_WR_SEND_WITH_IMM: - bnxt_opcd = BNXT_RE_WR_OPCD_SEND_IMM; - break; - case IBV_WR_RDMA_WRITE: - bnxt_opcd = BNXT_RE_WR_OPCD_RDMA_WRITE; - break; - case IBV_WR_RDMA_WRITE_WITH_IMM: - bnxt_opcd = BNXT_RE_WR_OPCD_RDMA_WRITE_IMM; - break; - case IBV_WR_RDMA_READ: - bnxt_opcd = BNXT_RE_WR_OPCD_RDMA_READ; - break; - case IBV_WR_ATOMIC_CMP_AND_SWP: - bnxt_opcd = BNXT_RE_WR_OPCD_ATOMIC_CS; - break; - case IBV_WR_ATOMIC_FETCH_AND_ADD: - bnxt_opcd = BNXT_RE_WR_OPCD_ATOMIC_FA; - break; - /* TODO: Add other opcodes */ - default: - bnxt_opcd = BNXT_RE_WR_OPCD_INVAL; - break; - }; - - return bnxt_opcd; -} - -static inline uint8_t bnxt_re_ibv_wr_to_wc_opcd(uint8_t wr_opcd) -{ - uint8_t wc_opcd; - - switch (wr_opcd) { - case IBV_WR_SEND_WITH_IMM: - case IBV_WR_SEND: - wc_opcd = IBV_WC_SEND; - break; - case IBV_WR_RDMA_WRITE_WITH_IMM: - case IBV_WR_RDMA_WRITE: - wc_opcd = IBV_WC_RDMA_WRITE; - break; - case IBV_WR_RDMA_READ: - wc_opcd = IBV_WC_RDMA_READ; - break; - case IBV_WR_ATOMIC_CMP_AND_SWP: - wc_opcd = IBV_WC_COMP_SWAP; - break; - case IBV_WR_ATOMIC_FETCH_AND_ADD: - wc_opcd = IBV_WC_FETCH_ADD; - break; - default: - wc_opcd = 0xFF; - break; - } - - return wc_opcd; -} - -static inline uint8_t bnxt_re_to_ibv_wc_status(uint8_t bnxt_wcst, - uint8_t is_req) -{ - uint8_t ibv_wcst; - - if (is_req) { - switch (bnxt_wcst) { - case BNXT_RE_REQ_ST_BAD_RESP: - ibv_wcst = IBV_WC_BAD_RESP_ERR; - break; - case BNXT_RE_REQ_ST_LOC_LEN: - ibv_wcst = IBV_WC_LOC_LEN_ERR; - break; - case BNXT_RE_REQ_ST_LOC_QP_OP: - ibv_wcst = IBV_WC_LOC_QP_OP_ERR; - break; - case BNXT_RE_REQ_ST_PROT: - ibv_wcst = IBV_WC_LOC_PROT_ERR; - break; - case BNXT_RE_REQ_ST_MEM_OP: - ibv_wcst = IBV_WC_MW_BIND_ERR; - break; - case BNXT_RE_REQ_ST_REM_INVAL: - ibv_wcst = IBV_WC_REM_INV_REQ_ERR; - break; - case BNXT_RE_REQ_ST_REM_ACC: - ibv_wcst = IBV_WC_REM_ACCESS_ERR; - break; - case BNXT_RE_REQ_ST_REM_OP: - ibv_wcst = IBV_WC_REM_OP_ERR; - break; - case BNXT_RE_REQ_ST_RNR_NAK_XCED: - ibv_wcst = IBV_WC_RNR_RETRY_EXC_ERR; - break; - case BNXT_RE_REQ_ST_TRNSP_XCED: - ibv_wcst = IBV_WC_RETRY_EXC_ERR; - break; - case BNXT_RE_REQ_ST_WR_FLUSH: - ibv_wcst = IBV_WC_WR_FLUSH_ERR; - break; - default: - ibv_wcst = IBV_WC_GENERAL_ERR; - break; - } - } else { - switch (bnxt_wcst) { - case BNXT_RE_RSP_ST_LOC_ACC: - ibv_wcst = IBV_WC_LOC_ACCESS_ERR; - break; - case BNXT_RE_RSP_ST_LOC_LEN: - ibv_wcst = IBV_WC_LOC_LEN_ERR; - break; - case BNXT_RE_RSP_ST_LOC_PROT: - ibv_wcst = IBV_WC_LOC_PROT_ERR; - break; - case BNXT_RE_RSP_ST_LOC_QP_OP: - ibv_wcst = IBV_WC_LOC_QP_OP_ERR; - break; - case BNXT_RE_RSP_ST_MEM_OP: - ibv_wcst = IBV_WC_MW_BIND_ERR; - break; - case BNXT_RE_RSP_ST_REM_INVAL: - ibv_wcst = IBV_WC_REM_INV_REQ_ERR; - break; - case BNXT_RE_RSP_ST_WR_FLUSH: - ibv_wcst = IBV_WC_WR_FLUSH_ERR; - break; - case BNXT_RE_RSP_ST_HW_FLUSH: - ibv_wcst = IBV_WC_FATAL_ERR; - break; - default: - ibv_wcst = IBV_WC_GENERAL_ERR; - break; - } - } - - return ibv_wcst; -} - -static inline uint8_t bnxt_re_is_cqe_valid(struct bnxt_re_cq *cq, - struct bnxt_re_bcqe *hdr) -{ - udma_from_device_barrier(); - return ((le32toh(hdr->flg_st_typ_ph) & - BNXT_RE_BCQE_PH_MASK) == cq->phase); -} - -static inline void bnxt_re_change_cq_phase(struct bnxt_re_cq *cq) -{ - if (!cq->cqq.head) - cq->phase = (~cq->phase & BNXT_RE_BCQE_PH_MASK); -} -#endif diff --git a/usr/rdma-core/providers/bnxt_re/memory.c b/usr/rdma-core/providers/bnxt_re/memory.c deleted file mode 100644 index 67125e9ef..000000000 --- a/usr/rdma-core/providers/bnxt_re/memory.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: Implements method to allocate page-aligned memory - * buffers. - */ - -#include -#include - -#include "main.h" - -int bnxt_re_alloc_aligned(struct bnxt_re_queue *que, uint32_t pg_size) -{ - int ret, bytes; - - bytes = (que->depth * que->stride); - que->bytes = get_aligned(bytes, pg_size); - que->va = mmap(NULL, que->bytes, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (que->va == MAP_FAILED) { - que->bytes = 0; - return errno; - } - /* Touch pages before proceeding. */ - memset(que->va, 0, que->bytes); - - ret = ibv_dontfork_range(que->va, que->bytes); - if (ret) { - munmap(que->va, que->bytes); - que->bytes = 0; - } - - return ret; -} - -void bnxt_re_free_aligned(struct bnxt_re_queue *que) -{ - if (que->bytes) { - ibv_dofork_range(que->va, que->bytes); - munmap(que->va, que->bytes); - que->bytes = 0; - } -} diff --git a/usr/rdma-core/providers/bnxt_re/memory.h b/usr/rdma-core/providers/bnxt_re/memory.h deleted file mode 100644 index aac0ff3da..000000000 --- a/usr/rdma-core/providers/bnxt_re/memory.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: Implements data-struture to allocate page-aligned - * memory buffer. - */ - -#ifndef __MEMORY_H__ -#define __MEMORY_H__ - -#include - -struct bnxt_re_queue { - void *va; - uint32_t bytes; /* for munmap */ - uint32_t depth; /* no. of entries */ - uint32_t head; - uint32_t tail; - uint32_t stride; - /* Represents the difference between the real queue depth allocated in - * HW and the user requested queue depth and is used to correctly flag - * queue full condition based on user supplied queue depth. - * This value can vary depending on the type of queue and any HW - * requirements that mandate keeping a fixed gap between the producer - * and the consumer indices in the queue - */ - uint32_t diff; - pthread_spinlock_t qlock; -}; - -static inline unsigned long get_aligned(uint32_t size, uint32_t al_size) -{ - return (unsigned long)(size + al_size - 1) & ~(al_size - 1); -} - -static inline unsigned long roundup_pow_of_two(unsigned long val) -{ - unsigned long roundup = 1; - - if (val == 1) - return (roundup << 1); - - while (roundup < val) - roundup <<= 1; - - return roundup; -} - -int bnxt_re_alloc_aligned(struct bnxt_re_queue *que, uint32_t pg_size); -void bnxt_re_free_aligned(struct bnxt_re_queue *que); - -static inline void iowrite64(__u64 *dst, __le64 *src) -{ - *(volatile __le64 *)dst = *src; -} - -static inline void iowrite32(__u32 *dst, __le32 *src) -{ - *(volatile __le32 *)dst = *src; -} - -/* Basic queue operation */ -static inline uint32_t bnxt_re_is_que_full(struct bnxt_re_queue *que) -{ - return (((que->diff + que->tail) & (que->depth - 1)) == que->head); -} - -static inline uint32_t bnxt_re_is_que_empty(struct bnxt_re_queue *que) -{ - return que->tail == que->head; -} - -static inline uint32_t bnxt_re_incr(uint32_t val, uint32_t max) -{ - return (++val & (max - 1)); -} - -static inline void bnxt_re_incr_tail(struct bnxt_re_queue *que) -{ - que->tail = bnxt_re_incr(que->tail, que->depth); -} - -static inline void bnxt_re_incr_head(struct bnxt_re_queue *que) -{ - que->head = bnxt_re_incr(que->head, que->depth); -} - -#endif diff --git a/usr/rdma-core/providers/bnxt_re/verbs.c b/usr/rdma-core/providers/bnxt_re/verbs.c deleted file mode 100644 index 4d9b044a1..000000000 --- a/usr/rdma-core/providers/bnxt_re/verbs.c +++ /dev/null @@ -1,1430 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: User IB-Verbs implementation - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "main.h" -#include "verbs.h" - -int bnxt_re_query_device(struct ibv_context *ibvctx, - struct ibv_device_attr *dev_attr) -{ - struct ibv_query_device cmd; - uint64_t fw_ver; - int status; - - memset(dev_attr, 0, sizeof(struct ibv_device_attr)); - status = ibv_cmd_query_device(ibvctx, dev_attr, &fw_ver, - &cmd, sizeof(cmd)); - return status; -} - -int bnxt_re_query_port(struct ibv_context *ibvctx, uint8_t port, - struct ibv_port_attr *port_attr) -{ - struct ibv_query_port cmd; - - memset(port_attr, 0, sizeof(struct ibv_port_attr)); - return ibv_cmd_query_port(ibvctx, port, port_attr, &cmd, sizeof(cmd)); -} - -struct ibv_pd *bnxt_re_alloc_pd(struct ibv_context *ibvctx) -{ - struct ibv_alloc_pd cmd; - struct bnxt_re_pd_resp resp; - struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); - struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvctx->device); - struct bnxt_re_pd *pd; - uint64_t dbr; - - pd = calloc(1, sizeof(*pd)); - if (!pd) - return NULL; - - memset(&resp, 0, sizeof(resp)); - if (ibv_cmd_alloc_pd(ibvctx, &pd->ibvpd, &cmd, sizeof(cmd), - &resp.resp, sizeof(resp))) - goto out; - - pd->pdid = resp.pdid; - dbr = *(uint64_t *)((uint32_t *)&resp + 3); - - /* Map DB page now. */ - if (!cntx->udpi.dbpage) { - cntx->udpi.dpindx = resp.dpi; - cntx->udpi.dbpage = mmap(NULL, dev->pg_size, PROT_WRITE, - MAP_SHARED, ibvctx->cmd_fd, dbr); - if (cntx->udpi.dbpage == MAP_FAILED) { - (void)ibv_cmd_dealloc_pd(&pd->ibvpd); - goto out; - } - pthread_spin_init(&cntx->udpi.db_lock, - PTHREAD_PROCESS_PRIVATE); - } - - return &pd->ibvpd; -out: - free(pd); - return NULL; -} - -int bnxt_re_free_pd(struct ibv_pd *ibvpd) -{ - struct bnxt_re_pd *pd = to_bnxt_re_pd(ibvpd); - int status; - - status = ibv_cmd_dealloc_pd(ibvpd); - if (status) - return status; - /* DPI un-mapping will be during uninit_ucontext */ - free(pd); - - return 0; -} - -struct ibv_mr *bnxt_re_reg_mr(struct ibv_pd *ibvpd, void *sva, size_t len, - int access) -{ - struct bnxt_re_mr *mr; - struct ibv_reg_mr cmd; - struct bnxt_re_mr_resp resp; - - mr = calloc(1, sizeof(*mr)); - if (!mr) - return NULL; - - if (ibv_cmd_reg_mr(ibvpd, sva, len, (uintptr_t)sva, access, &mr->ibvmr, - &cmd, sizeof(cmd), &resp.resp, sizeof(resp))) { - free(mr); - return NULL; - } - - return &mr->ibvmr; -} - -int bnxt_re_dereg_mr(struct ibv_mr *ibvmr) -{ - struct bnxt_re_mr *mr = (struct bnxt_re_mr *)ibvmr; - int status; - - status = ibv_cmd_dereg_mr(ibvmr); - if (status) - return status; - free(mr); - - return 0; -} - -struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe, - struct ibv_comp_channel *channel, int vec) -{ - struct bnxt_re_cq *cq; - struct bnxt_re_cq_req cmd; - struct bnxt_re_cq_resp resp; - - struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); - struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvctx->device); - - if (ncqe > dev->max_cq_depth) - return NULL; - - cq = calloc(1, sizeof(*cq)); - if (!cq) - return NULL; - - cq->cqq.depth = roundup_pow_of_two(ncqe + 1); - if (cq->cqq.depth > dev->max_cq_depth + 1) - cq->cqq.depth = dev->max_cq_depth + 1; - cq->cqq.stride = dev->cqe_size; - if (bnxt_re_alloc_aligned(&cq->cqq, dev->pg_size)) - goto fail; - - pthread_spin_init(&cq->cqq.qlock, PTHREAD_PROCESS_PRIVATE); - - cmd.cq_va = (uintptr_t)cq->cqq.va; - cmd.cq_handle = (uintptr_t)cq; - - memset(&resp, 0, sizeof(resp)); - if (ibv_cmd_create_cq(ibvctx, ncqe, channel, vec, - &cq->ibvcq, &cmd.cmd, sizeof(cmd), - &resp.resp, sizeof(resp))) - goto cmdfail; - - cq->cqid = resp.cqid; - cq->phase = resp.phase; - cq->cqq.tail = resp.tail; - cq->udpi = &cntx->udpi; - - list_head_init(&cq->sfhead); - list_head_init(&cq->rfhead); - - return &cq->ibvcq; -cmdfail: - bnxt_re_free_aligned(&cq->cqq); -fail: - free(cq); - return NULL; -} - -int bnxt_re_resize_cq(struct ibv_cq *ibvcq, int ncqe) -{ - return -ENOSYS; -} - -int bnxt_re_destroy_cq(struct ibv_cq *ibvcq) -{ - int status; - struct bnxt_re_cq *cq = to_bnxt_re_cq(ibvcq); - - status = ibv_cmd_destroy_cq(ibvcq); - if (status) - return status; - - bnxt_re_free_aligned(&cq->cqq); - free(cq); - - return 0; -} - -static uint8_t bnxt_re_poll_err_scqe(struct bnxt_re_qp *qp, - struct ibv_wc *ibvwc, - struct bnxt_re_bcqe *hdr, - struct bnxt_re_req_cqe *scqe, int *cnt) -{ - struct bnxt_re_queue *sq = qp->sqq; - struct bnxt_re_context *cntx; - struct bnxt_re_wrid *swrid; - struct bnxt_re_psns *spsn; - struct bnxt_re_cq *scq; - uint32_t head = sq->head; - uint8_t status; - - scq = to_bnxt_re_cq(qp->ibvqp.send_cq); - cntx = to_bnxt_re_context(scq->ibvcq.context); - swrid = &qp->swrid[head]; - spsn = swrid->psns; - - *cnt = 1; - status = (le32toh(hdr->flg_st_typ_ph) >> BNXT_RE_BCQE_STATUS_SHIFT) & - BNXT_RE_BCQE_STATUS_MASK; - ibvwc->status = bnxt_re_to_ibv_wc_status(status, true); - ibvwc->wc_flags = 0; - ibvwc->wr_id = swrid->wrid; - ibvwc->qp_num = qp->qpid; - ibvwc->opcode = (le32toh(spsn->opc_spsn) >> - BNXT_RE_PSNS_OPCD_SHIFT) & - BNXT_RE_PSNS_OPCD_MASK; - ibvwc->byte_len = 0; - - bnxt_re_incr_head(qp->sqq); - - if (qp->qpst != IBV_QPS_ERR) - qp->qpst = IBV_QPS_ERR; - pthread_spin_lock(&cntx->fqlock); - bnxt_re_fque_add_node(&scq->sfhead, &qp->snode); - pthread_spin_unlock(&cntx->fqlock); - - return false; -} - -static uint8_t bnxt_re_poll_success_scqe(struct bnxt_re_qp *qp, - struct ibv_wc *ibvwc, - struct bnxt_re_bcqe *hdr, - struct bnxt_re_req_cqe *scqe, - int *cnt) -{ - struct bnxt_re_queue *sq = qp->sqq; - struct bnxt_re_wrid *swrid; - struct bnxt_re_psns *spsn; - uint8_t pcqe = false; - uint32_t head = sq->head; - uint32_t cindx; - - swrid = &qp->swrid[head]; - spsn = swrid->psns; - cindx = le32toh(scqe->con_indx); - - if (!(swrid->sig & IBV_SEND_SIGNALED)) { - *cnt = 0; - } else { - ibvwc->status = IBV_WC_SUCCESS; - ibvwc->wc_flags = 0; - ibvwc->qp_num = qp->qpid; - ibvwc->wr_id = swrid->wrid; - ibvwc->opcode = (le32toh(spsn->opc_spsn) >> - BNXT_RE_PSNS_OPCD_SHIFT) & - BNXT_RE_PSNS_OPCD_MASK; - if (ibvwc->opcode == IBV_WC_RDMA_READ || - ibvwc->opcode == IBV_WC_COMP_SWAP || - ibvwc->opcode == IBV_WC_FETCH_ADD) - ibvwc->byte_len = swrid->bytes; - - *cnt = 1; - } - - bnxt_re_incr_head(sq); - if (sq->head != cindx) - pcqe = true; - - return pcqe; -} - -static uint8_t bnxt_re_poll_scqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, - void *cqe, int *cnt) -{ - struct bnxt_re_bcqe *hdr; - struct bnxt_re_req_cqe *scqe; - uint8_t status, pcqe = false; - - scqe = cqe; - hdr = cqe + sizeof(struct bnxt_re_req_cqe); - - status = (le32toh(hdr->flg_st_typ_ph) >> BNXT_RE_BCQE_STATUS_SHIFT) & - BNXT_RE_BCQE_STATUS_MASK; - if (status == BNXT_RE_REQ_ST_OK) - pcqe = bnxt_re_poll_success_scqe(qp, ibvwc, hdr, scqe, cnt); - else - pcqe = bnxt_re_poll_err_scqe(qp, ibvwc, hdr, scqe, cnt); - - return pcqe; -} - -static int bnxt_re_poll_err_rcqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, - struct bnxt_re_bcqe *hdr, void *cqe) -{ - struct bnxt_re_queue *rq = qp->rqq; - struct bnxt_re_wrid *rwrid; - struct bnxt_re_cq *rcq; - struct bnxt_re_context *cntx; - uint32_t head = rq->head; - uint8_t status; - - rcq = to_bnxt_re_cq(qp->ibvqp.recv_cq); - cntx = to_bnxt_re_context(rcq->ibvcq.context); - - rwrid = &qp->rwrid[head]; - status = (le32toh(hdr->flg_st_typ_ph) >> BNXT_RE_BCQE_STATUS_SHIFT) & - BNXT_RE_BCQE_STATUS_MASK; - /* skip h/w flush errors */ - if (status == BNXT_RE_RSP_ST_HW_FLUSH) - return 0; - ibvwc->status = bnxt_re_to_ibv_wc_status(status, false); - /* TODO: Add SRQ Processing here */ - if (qp->rqq) { - ibvwc->wr_id = rwrid->wrid; - ibvwc->qp_num = qp->qpid; - ibvwc->opcode = IBV_WC_RECV; - ibvwc->byte_len = 0; - ibvwc->wc_flags = 0; - if (qp->qptyp == IBV_QPT_UD) - ibvwc->src_qp = 0; - - bnxt_re_incr_head(qp->rqq); - if (qp->qpst != IBV_QPS_ERR) - qp->qpst = IBV_QPS_ERR; - pthread_spin_lock(&cntx->fqlock); - bnxt_re_fque_add_node(&rcq->rfhead, &qp->rnode); - pthread_spin_unlock(&cntx->fqlock); - } - - return 1; -} - -static void bnxt_re_fill_ud_cqe(struct ibv_wc *ibvwc, - struct bnxt_re_bcqe *hdr, void *cqe) -{ - struct bnxt_re_ud_cqe *ucqe = cqe; - uint32_t qpid; - - qpid = ((le32toh(hdr->qphi_rwrid) >> BNXT_RE_BCQE_SRCQP_SHIFT) & - BNXT_RE_BCQE_SRCQP_SHIFT) << 0x10; /* higher 8 bits of 24 */ - qpid |= (le64toh(ucqe->qplo_mac) >> BNXT_RE_UD_CQE_SRCQPLO_SHIFT) & - BNXT_RE_UD_CQE_SRCQPLO_MASK; /*lower 16 of 24 */ - ibvwc->src_qp = qpid; - ibvwc->wc_flags |= IBV_WC_GRH; - /*IB-stack ABI in user do not ask for MAC to be reported. */ -} - -static void bnxt_re_poll_success_rcqe(struct bnxt_re_qp *qp, - struct ibv_wc *ibvwc, - struct bnxt_re_bcqe *hdr, void *cqe) -{ - struct bnxt_re_queue *rq = qp->rqq; - struct bnxt_re_wrid *rwrid; - struct bnxt_re_rc_cqe *rcqe; - uint32_t head = rq->head; - uint8_t flags, is_imm, is_rdma; - - rcqe = cqe; - rwrid = &qp->rwrid[head]; - - ibvwc->status = IBV_WC_SUCCESS; - ibvwc->wr_id = rwrid->wrid; - ibvwc->qp_num = qp->qpid; - ibvwc->byte_len = le32toh(rcqe->length); - ibvwc->opcode = IBV_WC_RECV; - - flags = (le32toh(hdr->flg_st_typ_ph) >> BNXT_RE_BCQE_FLAGS_SHIFT) & - BNXT_RE_BCQE_FLAGS_MASK; - is_imm = (flags & BNXT_RE_RC_FLAGS_IMM_MASK) >> - BNXT_RE_RC_FLAGS_IMM_SHIFT; - is_rdma = (flags & BNXT_RE_RC_FLAGS_RDMA_MASK) >> - BNXT_RE_RC_FLAGS_RDMA_SHIFT; - ibvwc->wc_flags = 0; - if (is_imm) { - ibvwc->wc_flags |= IBV_WC_WITH_IMM; - /* Completion reports the raw-data in LE format, While - * user expects it in BE format. Thus, swapping on outgoing - * data is needed. On a BE platform le32toh will do the swap - * while on LE platform htobe32 will do the job. - */ - ibvwc->imm_data = htobe32(le32toh(rcqe->imm_key)); - if (is_rdma) - ibvwc->opcode = IBV_WC_RECV_RDMA_WITH_IMM; - } - - if (qp->qptyp == IBV_QPT_UD) - bnxt_re_fill_ud_cqe(ibvwc, hdr, cqe); - - bnxt_re_incr_head(rq); -} - -static uint8_t bnxt_re_poll_rcqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, - void *cqe, int *cnt) -{ - struct bnxt_re_bcqe *hdr; - uint8_t status, pcqe = false; - - hdr = cqe + sizeof(struct bnxt_re_rc_cqe); - - status = (le32toh(hdr->flg_st_typ_ph) >> BNXT_RE_BCQE_STATUS_SHIFT) & - BNXT_RE_BCQE_STATUS_MASK; - *cnt = 1; - if (status == BNXT_RE_RSP_ST_OK) - bnxt_re_poll_success_rcqe(qp, ibvwc, hdr, cqe); - else - *cnt = bnxt_re_poll_err_rcqe(qp, ibvwc, hdr, cqe); - - return pcqe; -} - -static uint8_t bnxt_re_poll_term_cqe(struct bnxt_re_qp *qp, - struct ibv_wc *ibvwc, void *cqe, int *cnt) -{ - struct bnxt_re_context *cntx; - struct bnxt_re_cq *scq, *rcq; - uint8_t pcqe = false; - - scq = to_bnxt_re_cq(qp->ibvqp.send_cq); - rcq = to_bnxt_re_cq(qp->ibvqp.recv_cq); - cntx = to_bnxt_re_context(scq->ibvcq.context); - /* For now just add the QP to flush list without - * considering the index reported in the CQE. - * Continue reporting flush completions until the - * SQ and RQ are empty. - */ - *cnt = 0; - if (qp->qpst != IBV_QPS_ERR) - qp->qpst = IBV_QPS_ERR; - pthread_spin_lock(&cntx->fqlock); - bnxt_re_fque_add_node(&rcq->rfhead, &qp->rnode); - bnxt_re_fque_add_node(&scq->sfhead, &qp->snode); - pthread_spin_unlock(&cntx->fqlock); - - return pcqe; -} - -static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc) -{ - struct bnxt_re_queue *cqq = &cq->cqq; - struct bnxt_re_qp *qp; - struct bnxt_re_bcqe *hdr; - struct bnxt_re_req_cqe *scqe; - struct bnxt_re_ud_cqe *rcqe; - void *cqe; - uint64_t *qp_handle = NULL; - int type, cnt = 0, dqed = 0, hw_polled = 0; - uint8_t pcqe = false; - - while (nwc) { - cqe = cqq->va + cqq->head * bnxt_re_get_cqe_sz(); - hdr = cqe + sizeof(struct bnxt_re_req_cqe); - if (!bnxt_re_is_cqe_valid(cq, hdr)) - break; - type = (le32toh(hdr->flg_st_typ_ph) >> - BNXT_RE_BCQE_TYPE_SHIFT) & BNXT_RE_BCQE_TYPE_MASK; - switch (type) { - case BNXT_RE_WC_TYPE_SEND: - scqe = cqe; - qp_handle = (uint64_t *)&scqe->qp_handle; - qp = (struct bnxt_re_qp *) - (uintptr_t)le64toh(scqe->qp_handle); - if (!qp) - break; /*stale cqe. should be rung.*/ - pcqe = bnxt_re_poll_scqe(qp, wc, cqe, &cnt); - break; - case BNXT_RE_WC_TYPE_RECV_RC: - case BNXT_RE_WC_TYPE_RECV_UD: - rcqe = cqe; - qp_handle = (uint64_t *)&rcqe->qp_handle; - qp = (struct bnxt_re_qp *) - (uintptr_t)le64toh(rcqe->qp_handle); - if (!qp) - break; /*stale cqe. should be rung.*/ - if (qp->srq) - goto bail; /*TODO: Add SRQ poll */ - - pcqe = bnxt_re_poll_rcqe(qp, wc, cqe, &cnt); - break; - case BNXT_RE_WC_TYPE_RECV_RAW: - break; - case BNXT_RE_WC_TYPE_TERM: - scqe = cqe; - qp_handle = (uint64_t *)&scqe->qp_handle; - qp = (struct bnxt_re_qp *) - (uintptr_t)le64toh(scqe->qp_handle); - if (!qp) - break; - pcqe = bnxt_re_poll_term_cqe(qp, wc, cqe, &cnt); - break; - case BNXT_RE_WC_TYPE_COFF: - break; - default: - break; - }; - - if (pcqe) - goto skipp_real; - - hw_polled++; - if (qp_handle) { - *qp_handle = 0x0ULL; /* mark cqe as read */ - qp_handle = NULL; - } - bnxt_re_incr_head(&cq->cqq); - bnxt_re_change_cq_phase(cq); -skipp_real: - if (cnt) { - cnt = 0; - dqed++; - nwc--; - wc++; - } - } - - if (hw_polled) - bnxt_re_ring_cq_db(cq); -bail: - return dqed; -} - -static int bnxt_re_poll_flush_wcs(struct bnxt_re_queue *que, - struct bnxt_re_wrid *wridp, - struct ibv_wc *ibvwc, uint32_t qpid, - int nwc) -{ - struct bnxt_re_wrid *wrid; - struct bnxt_re_psns *psns; - uint32_t cnt = 0, head; - uint8_t opcode = IBV_WC_RECV; - - while (nwc) { - if (bnxt_re_is_que_empty(que)) - break; - head = que->head; - wrid = &wridp[head]; - if (wrid->psns) { - psns = wrid->psns; - opcode = (le32toh(psns->opc_spsn) >> - BNXT_RE_PSNS_OPCD_SHIFT) & - BNXT_RE_PSNS_OPCD_MASK; - } - - ibvwc->status = IBV_WC_WR_FLUSH_ERR; - ibvwc->opcode = opcode; - ibvwc->wr_id = wrid->wrid; - ibvwc->qp_num = qpid; - ibvwc->byte_len = 0; - ibvwc->wc_flags = 0; - - bnxt_re_incr_head(que); - nwc--; - cnt++; - ibvwc++; - } - - return cnt; -} - -static int bnxt_re_poll_flush_lists(struct bnxt_re_cq *cq, uint32_t nwc, - struct ibv_wc *ibvwc) -{ - struct bnxt_re_fque_node *cur, *tmp; - struct bnxt_re_qp *qp; - struct bnxt_re_queue *que; - int dqed = 0, left; - - /* Check if flush Qs are empty */ - if (list_empty(&cq->sfhead) && list_empty(&cq->rfhead)) - return 0; - - if (!list_empty(&cq->sfhead)) { - list_for_each_safe(&cq->sfhead, cur, tmp, list) { - qp = container_of(cur, struct bnxt_re_qp, snode); - que = qp->sqq; - if (bnxt_re_is_que_empty(que)) - continue; - dqed = bnxt_re_poll_flush_wcs(que, qp->swrid, ibvwc, - qp->qpid, nwc); - } - } - - left = nwc - dqed; - if (!left) - return dqed; - - if (!list_empty(&cq->rfhead)) { - list_for_each_safe(&cq->rfhead, cur, tmp, list) { - qp = container_of(cur, struct bnxt_re_qp, rnode); - que = qp->rqq; - if (!que || bnxt_re_is_que_empty(que)) - continue; - dqed += bnxt_re_poll_flush_wcs(que, qp->rwrid, - ibvwc + dqed, qp->qpid, - left); - } - } - - return dqed; -} - -int bnxt_re_poll_cq(struct ibv_cq *ibvcq, int nwc, struct ibv_wc *wc) -{ - struct bnxt_re_cq *cq = to_bnxt_re_cq(ibvcq); - struct bnxt_re_context *cntx = to_bnxt_re_context(ibvcq->context); - int dqed, left = 0; - - pthread_spin_lock(&cq->cqq.qlock); - dqed = bnxt_re_poll_one(cq, nwc, wc); - pthread_spin_unlock(&cq->cqq.qlock); - /* Check if anything is there to flush. */ - pthread_spin_lock(&cntx->fqlock); - left = nwc - dqed; - if (left) - dqed += bnxt_re_poll_flush_lists(cq, left, (wc + dqed)); - pthread_spin_unlock(&cntx->fqlock); - - return dqed; -} - -static void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq) -{ - struct bnxt_re_context *cntx; - struct bnxt_re_queue *que = &cq->cqq; - struct bnxt_re_bcqe *hdr; - struct bnxt_re_req_cqe *scqe; - struct bnxt_re_rc_cqe *rcqe; - void *cqe; - int indx, type; - - cntx = to_bnxt_re_context(cq->ibvcq.context); - - pthread_spin_lock(&que->qlock); - for (indx = 0; indx < que->depth; indx++) { - cqe = que->va + indx * bnxt_re_get_cqe_sz(); - hdr = cqe + sizeof(struct bnxt_re_req_cqe); - type = (le32toh(hdr->flg_st_typ_ph) >> - BNXT_RE_BCQE_TYPE_SHIFT) & BNXT_RE_BCQE_TYPE_MASK; - - if (type == BNXT_RE_WC_TYPE_COFF) - continue; - if (type == BNXT_RE_WC_TYPE_SEND || - type == BNXT_RE_WC_TYPE_TERM) { - scqe = cqe; - if (le64toh(scqe->qp_handle) == (uintptr_t)qp) - scqe->qp_handle = 0ULL; - } else { - rcqe = cqe; - if (le64toh(rcqe->qp_handle) == (uintptr_t)qp) - rcqe->qp_handle = 0ULL; - } - - } - pthread_spin_unlock(&que->qlock); - - pthread_spin_lock(&cntx->fqlock); - bnxt_re_fque_del_node(&qp->snode); - bnxt_re_fque_del_node(&qp->rnode); - pthread_spin_unlock(&cntx->fqlock); -} - -void bnxt_re_cq_event(struct ibv_cq *ibvcq) -{ - -} - -int bnxt_re_arm_cq(struct ibv_cq *ibvcq, int flags) -{ - struct bnxt_re_cq *cq = to_bnxt_re_cq(ibvcq); - - pthread_spin_lock(&cq->cqq.qlock); - flags = !flags ? BNXT_RE_QUE_TYPE_CQ_ARMALL : - BNXT_RE_QUE_TYPE_CQ_ARMSE; - bnxt_re_ring_cq_arm_db(cq, flags); - pthread_spin_unlock(&cq->cqq.qlock); - - return 0; -} - -static int bnxt_re_check_qp_limits(struct bnxt_re_context *cntx, - struct ibv_qp_init_attr *attr) -{ - struct ibv_device_attr devattr; - int ret; - - ret = bnxt_re_query_device(&cntx->ibvctx, &devattr); - if (ret) - return ret; - if (attr->cap.max_send_sge > devattr.max_sge) - return EINVAL; - if (attr->cap.max_recv_sge > devattr.max_sge) - return EINVAL; - if (attr->cap.max_inline_data > BNXT_RE_MAX_INLINE_SIZE) - return EINVAL; - if (attr->cap.max_send_wr > devattr.max_qp_wr) - attr->cap.max_send_wr = devattr.max_qp_wr; - if (attr->cap.max_recv_wr > devattr.max_qp_wr) - attr->cap.max_recv_wr = devattr.max_qp_wr; - - return 0; -} - -static void bnxt_re_free_queue_ptr(struct bnxt_re_qp *qp) -{ - if (qp->rqq) - free(qp->rqq); - if (qp->sqq) - free(qp->sqq); -} - -static int bnxt_re_alloc_queue_ptr(struct bnxt_re_qp *qp, - struct ibv_qp_init_attr *attr) -{ - qp->sqq = calloc(1, sizeof(struct bnxt_re_queue)); - if (!qp->sqq) - return -ENOMEM; - if (attr->srq) - qp->srq = NULL;/*TODO: to_bnxt_re_srq(attr->srq);*/ - else { - qp->rqq = calloc(1, sizeof(struct bnxt_re_queue)); - if (!qp->rqq) { - free(qp->sqq); - return -ENOMEM; - } - } - - return 0; -} - -static void bnxt_re_free_queues(struct bnxt_re_qp *qp) -{ - if (qp->rwrid) - free(qp->rwrid); - pthread_spin_destroy(&qp->rqq->qlock); - bnxt_re_free_aligned(qp->rqq); - - if (qp->swrid) - free(qp->swrid); - pthread_spin_destroy(&qp->sqq->qlock); - bnxt_re_free_aligned(qp->sqq); -} - -static int bnxt_re_alloc_queues(struct bnxt_re_qp *qp, - struct ibv_qp_init_attr *attr, - uint32_t pg_size) { - struct bnxt_re_queue *que; - struct bnxt_re_psns *psns; - uint32_t psn_depth; - int ret, indx; - - que = qp->sqq; - que->stride = bnxt_re_get_sqe_sz(); - /* 8916 adjustment */ - que->depth = roundup_pow_of_two(attr->cap.max_send_wr + 1 + - BNXT_RE_FULL_FLAG_DELTA); - que->diff = que->depth - attr->cap.max_send_wr; - - /* psn_depth extra entries of size que->stride */ - psn_depth = (que->depth * sizeof(struct bnxt_re_psns)) / - que->stride; - if ((que->depth * sizeof(struct bnxt_re_psns)) % que->stride) - psn_depth++; - - que->depth += psn_depth; - /* PSN-search memory is allocated without checking for - * QP-Type. Kenrel driver do not map this memory if it - * is UD-qp. UD-qp use this memory to maintain WC-opcode. - * See definition of bnxt_re_fill_psns() for the use case. - */ - ret = bnxt_re_alloc_aligned(qp->sqq, pg_size); - if (ret) - return ret; - /* exclude psns depth*/ - que->depth -= psn_depth; - /* start of spsn space sizeof(struct bnxt_re_psns) each. */ - psns = (que->va + que->stride * que->depth); - pthread_spin_init(&que->qlock, PTHREAD_PROCESS_PRIVATE); - qp->swrid = calloc(que->depth, sizeof(struct bnxt_re_wrid)); - if (!qp->swrid) { - ret = -ENOMEM; - goto fail; - } - - for (indx = 0 ; indx < que->depth; indx++, psns++) - qp->swrid[indx].psns = psns; - qp->cap.max_swr = que->depth; - - if (qp->rqq) { - que = qp->rqq; - que->stride = bnxt_re_get_rqe_sz(); - que->depth = roundup_pow_of_two(attr->cap.max_recv_wr + 1); - que->diff = que->depth - attr->cap.max_recv_wr; - ret = bnxt_re_alloc_aligned(qp->rqq, pg_size); - if (ret) - goto fail; - pthread_spin_init(&que->qlock, PTHREAD_PROCESS_PRIVATE); - /* For RQ only bnxt_re_wri.wrid is used. */ - qp->rwrid = calloc(que->depth, sizeof(struct bnxt_re_wrid)); - if (!qp->rwrid) { - ret = -ENOMEM; - goto fail; - } - qp->cap.max_rwr = que->depth; - } - - return 0; -fail: - bnxt_re_free_queues(qp); - return ret; -} - -struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd, - struct ibv_qp_init_attr *attr) -{ - struct bnxt_re_qp *qp; - struct bnxt_re_qp_req req; - struct bnxt_re_qp_resp resp; - struct bnxt_re_qpcap *cap; - - struct bnxt_re_context *cntx = to_bnxt_re_context(ibvpd->context); - struct bnxt_re_dev *dev = to_bnxt_re_dev(cntx->ibvctx.device); - - if (bnxt_re_check_qp_limits(cntx, attr)) - return NULL; - - qp = calloc(1, sizeof(*qp)); - if (!qp) - return NULL; - /* alloc queue pointers */ - if (bnxt_re_alloc_queue_ptr(qp, attr)) - goto fail; - /* alloc queues */ - if (bnxt_re_alloc_queues(qp, attr, dev->pg_size)) - goto failq; - /* Fill ibv_cmd */ - cap = &qp->cap; - req.qpsva = (uintptr_t)qp->sqq->va; - req.qprva = qp->rqq ? (uintptr_t)qp->rqq->va : 0; - req.qp_handle = (uintptr_t)qp; - - if (ibv_cmd_create_qp(ibvpd, &qp->ibvqp, attr, &req.cmd, sizeof(req), - &resp.resp, sizeof(resp))) { - goto failcmd; - } - - qp->qpid = resp.qpid; - qp->qptyp = attr->qp_type; - qp->qpst = IBV_QPS_RESET; - qp->scq = to_bnxt_re_cq(attr->send_cq); - qp->rcq = to_bnxt_re_cq(attr->recv_cq); - qp->udpi = &cntx->udpi; - /* Save/return the altered Caps. */ - cap->max_ssge = attr->cap.max_send_sge; - cap->max_rsge = attr->cap.max_recv_sge; - cap->max_inline = attr->cap.max_inline_data; - cap->sqsig = attr->sq_sig_all; - fque_init_node(&qp->snode); - fque_init_node(&qp->rnode); - - return &qp->ibvqp; -failcmd: - bnxt_re_free_queues(qp); -failq: - bnxt_re_free_queue_ptr(qp); -fail: - free(qp); - - return NULL; -} - -int bnxt_re_modify_qp(struct ibv_qp *ibvqp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - struct bnxt_re_qp *qp = to_bnxt_re_qp(ibvqp); - int rc; - - rc = ibv_cmd_modify_qp(ibvqp, attr, attr_mask, &cmd, sizeof(cmd)); - if (!rc) { - if (attr_mask & IBV_QP_STATE) { - qp->qpst = attr->qp_state; - /* transition to reset */ - if (qp->qpst == IBV_QPS_RESET) { - qp->sqq->head = 0; - qp->sqq->tail = 0; - if (qp->rqq) { - qp->rqq->head = 0; - qp->rqq->tail = 0; - } - } - } - if (attr_mask & IBV_QP_SQ_PSN) - qp->sq_psn = attr->sq_psn; - if (attr_mask & IBV_QP_PATH_MTU) - qp->mtu = (0x80 << attr->path_mtu); - } - - return rc; -} - -int bnxt_re_query_qp(struct ibv_qp *ibvqp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - struct bnxt_re_qp *qp = to_bnxt_re_qp(ibvqp); - int rc; - - rc = ibv_cmd_query_qp(ibvqp, attr, attr_mask, init_attr, - &cmd, sizeof(cmd)); - if (!rc) - qp->qpst = ibvqp->state; - - return rc; -} - -int bnxt_re_destroy_qp(struct ibv_qp *ibvqp) -{ - struct bnxt_re_qp *qp = to_bnxt_re_qp(ibvqp); - int status; - - status = ibv_cmd_destroy_qp(ibvqp); - if (status) - return status; - - bnxt_re_cleanup_cq(qp, qp->rcq); - bnxt_re_cleanup_cq(qp, qp->scq); - bnxt_re_free_queues(qp); - bnxt_re_free_queue_ptr(qp); - free(qp); - - return 0; -} - -static inline uint8_t bnxt_re_set_hdr_flags(struct bnxt_re_bsqe *hdr, - uint32_t send_flags, uint8_t sqsig) -{ - uint8_t is_inline = false; - uint32_t hdrval = 0; - - if (send_flags & IBV_SEND_SIGNALED || sqsig) - hdrval |= ((BNXT_RE_WR_FLAGS_SIGNALED & BNXT_RE_HDR_FLAGS_MASK) - << BNXT_RE_HDR_FLAGS_SHIFT); - if (send_flags & IBV_SEND_FENCE) - /*TODO: See when RD fence can be used. */ - hdrval |= ((BNXT_RE_WR_FLAGS_UC_FENCE & BNXT_RE_HDR_FLAGS_MASK) - << BNXT_RE_HDR_FLAGS_SHIFT); - if (send_flags & IBV_SEND_SOLICITED) - hdrval |= ((BNXT_RE_WR_FLAGS_SE & BNXT_RE_HDR_FLAGS_MASK) - << BNXT_RE_HDR_FLAGS_SHIFT); - - if (send_flags & IBV_SEND_INLINE) { - hdrval |= ((BNXT_RE_WR_FLAGS_INLINE & BNXT_RE_HDR_FLAGS_MASK) - << BNXT_RE_HDR_FLAGS_SHIFT); - is_inline = true; - } - hdr->rsv_ws_fl_wt = htole32(hdrval); - - return is_inline; -} - -static int bnxt_re_build_sge(struct bnxt_re_sge *sge, struct ibv_sge *sg_list, - uint32_t num_sge, uint8_t is_inline) { - int indx, length = 0; - void *dst; - - if (!num_sge) { - memset(sge, 0, sizeof(*sge)); - return 0; - } - - if (is_inline) { - dst = sge; - for (indx = 0; indx < num_sge; indx++) { - length += sg_list[indx].length; - if (length > BNXT_RE_MAX_INLINE_SIZE) - return -ENOMEM; - memcpy(dst, (void *)(uintptr_t)sg_list[indx].addr, - sg_list[indx].length); - dst = dst + sg_list[indx].length; - } - } else { - for (indx = 0; indx < num_sge; indx++) { - sge[indx].pa = htole64(sg_list[indx].addr); - sge[indx].lkey = htole32(sg_list[indx].lkey); - sge[indx].length = htole32(sg_list[indx].length); - length += sg_list[indx].length; - } - } - - return length; -} - -static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns, - uint8_t opcode, uint32_t len) -{ - uint32_t pkt_cnt = 0, nxt_psn; - - memset(psns, 0, sizeof(*psns)); - if (qp->qptyp == IBV_QPT_RC) { - psns->opc_spsn = htole32(qp->sq_psn & BNXT_RE_PSNS_SPSN_MASK); - pkt_cnt = (len / qp->mtu); - if (len % qp->mtu) - pkt_cnt++; - nxt_psn = ((qp->sq_psn + pkt_cnt) & BNXT_RE_PSNS_NPSN_MASK); - psns->flg_npsn = htole32(nxt_psn); - qp->sq_psn = nxt_psn; - } - opcode = bnxt_re_ibv_wr_to_wc_opcd(opcode); - psns->opc_spsn |= htole32(((opcode & BNXT_RE_PSNS_OPCD_MASK) << - BNXT_RE_PSNS_OPCD_SHIFT)); -} - -static void bnxt_re_fill_wrid(struct bnxt_re_wrid *wrid, struct ibv_send_wr *wr, - uint32_t len, uint8_t sqsig) -{ - wrid->wrid = wr->wr_id; - wrid->bytes = len; - wrid->sig = 0; - if (wr->send_flags & IBV_SEND_SIGNALED || sqsig) - wrid->sig = IBV_SEND_SIGNALED; -} - -static int bnxt_re_build_send_sqe(struct bnxt_re_qp *qp, void *wqe, - struct ibv_send_wr *wr, uint8_t is_inline) -{ - struct bnxt_re_bsqe *hdr = wqe; - struct bnxt_re_send *sqe = ((void *)wqe + sizeof(struct bnxt_re_bsqe)); - struct bnxt_re_sge *sge = ((void *)wqe + bnxt_re_get_sqe_hdr_sz()); - uint32_t wrlen, hdrval = 0; - int len; - uint8_t opcode, qesize; - - len = bnxt_re_build_sge(sge, wr->sg_list, wr->num_sge, is_inline); - if (len < 0) - return len; - sqe->length = htole32(len); - - /* Fill Header */ - opcode = bnxt_re_ibv_to_bnxt_wr_opcd(wr->opcode); - if (opcode == BNXT_RE_WR_OPCD_INVAL) - return -EINVAL; - hdrval = (opcode & BNXT_RE_HDR_WT_MASK); - - if (is_inline) { - wrlen = get_aligned(len, 16); - qesize = wrlen >> 4; - } else { - qesize = wr->num_sge; - } - /* HW requires wqe size has room for atleast one sge even if none was - * supplied by application - */ - if (!wr->num_sge) - qesize++; - qesize += (bnxt_re_get_sqe_hdr_sz() >> 4); - hdrval |= (qesize & BNXT_RE_HDR_WS_MASK) << BNXT_RE_HDR_WS_SHIFT; - hdr->rsv_ws_fl_wt |= htole32(hdrval); - return len; -} - -static int bnxt_re_build_ud_sqe(struct bnxt_re_qp *qp, void *wqe, - struct ibv_send_wr *wr, uint8_t is_inline) -{ - struct bnxt_re_send *sqe = ((void *)wqe + sizeof(struct bnxt_re_bsqe)); - struct bnxt_re_ah *ah; - int len; - - len = bnxt_re_build_send_sqe(qp, wqe, wr, is_inline); - sqe->qkey = htole32(wr->wr.ud.remote_qkey); - sqe->dst_qp = htole32(wr->wr.ud.remote_qpn); - if (!wr->wr.ud.ah) { - len = -EINVAL; - goto bail; - } - ah = to_bnxt_re_ah(wr->wr.ud.ah); - sqe->avid = htole32(ah->avid & 0xFFFFF); -bail: - return len; -} - -static int bnxt_re_build_rdma_sqe(struct bnxt_re_qp *qp, void *wqe, - struct ibv_send_wr *wr, uint8_t is_inline) -{ - struct bnxt_re_rdma *sqe = ((void *)wqe + sizeof(struct bnxt_re_bsqe)); - int len; - - len = bnxt_re_build_send_sqe(qp, wqe, wr, is_inline); - sqe->rva = htole64(wr->wr.rdma.remote_addr); - sqe->rkey = htole32(wr->wr.rdma.rkey); - - return len; -} - -static int bnxt_re_build_cns_sqe(struct bnxt_re_qp *qp, void *wqe, - struct ibv_send_wr *wr) -{ - struct bnxt_re_bsqe *hdr = wqe; - struct bnxt_re_atomic *sqe = ((void *)wqe + - sizeof(struct bnxt_re_bsqe)); - int len; - - len = bnxt_re_build_send_sqe(qp, wqe, wr, false); - hdr->key_immd = htole32(wr->wr.atomic.rkey); - sqe->rva = htole64(wr->wr.atomic.remote_addr); - sqe->cmp_dt = htole64(wr->wr.atomic.compare_add); - sqe->swp_dt = htole64(wr->wr.atomic.swap); - - return len; -} - -static int bnxt_re_build_fna_sqe(struct bnxt_re_qp *qp, void *wqe, - struct ibv_send_wr *wr) -{ - struct bnxt_re_bsqe *hdr = wqe; - struct bnxt_re_atomic *sqe = ((void *)wqe + - sizeof(struct bnxt_re_bsqe)); - int len; - - len = bnxt_re_build_send_sqe(qp, wqe, wr, false); - hdr->key_immd = htole32(wr->wr.atomic.rkey); - sqe->rva = htole64(wr->wr.atomic.remote_addr); - sqe->cmp_dt = htole64(wr->wr.atomic.compare_add); - - return len; -} - -int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad) -{ - struct bnxt_re_qp *qp = to_bnxt_re_qp(ibvqp); - struct bnxt_re_queue *sq = qp->sqq; - struct bnxt_re_bsqe *hdr; - struct bnxt_re_wrid *wrid; - struct bnxt_re_psns *psns; - void *sqe; - int ret = 0, bytes = 0; - uint8_t is_inline = false; - - pthread_spin_lock(&sq->qlock); - while (wr) { - if ((qp->qpst != IBV_QPS_RTS) && (qp->qpst != IBV_QPS_SQD)) { - *bad = wr; - pthread_spin_unlock(&sq->qlock); - return EINVAL; - } - - if ((qp->qptyp == IBV_QPT_UD) && - (wr->opcode != IBV_WR_SEND && - wr->opcode != IBV_WR_SEND_WITH_IMM)) { - *bad = wr; - pthread_spin_unlock(&sq->qlock); - return EINVAL; - } - - if (bnxt_re_is_que_full(sq) || - wr->num_sge > qp->cap.max_ssge) { - *bad = wr; - pthread_spin_unlock(&sq->qlock); - return ENOMEM; - } - - sqe = (void *)(sq->va + (sq->tail * sq->stride)); - wrid = &qp->swrid[sq->tail]; - psns = wrid->psns; - - memset(sqe, 0, bnxt_re_get_sqe_sz()); - hdr = sqe; - is_inline = bnxt_re_set_hdr_flags(hdr, wr->send_flags, - qp->cap.sqsig); - switch (wr->opcode) { - case IBV_WR_SEND_WITH_IMM: - /* Since our h/w is LE and user supplies raw-data in - * BE format. Swapping on incoming data is needed. - * On a BE platform htole32 will do the swap while on - * LE platform be32toh will do the job. - */ - hdr->key_immd = htole32(be32toh(wr->imm_data)); - SWITCH_FALLTHROUGH; - case IBV_WR_SEND: - if (qp->qptyp == IBV_QPT_UD) - bytes = bnxt_re_build_ud_sqe(qp, sqe, wr, - is_inline); - else - bytes = bnxt_re_build_send_sqe(qp, sqe, wr, - is_inline); - break; - case IBV_WR_RDMA_WRITE_WITH_IMM: - hdr->key_immd = htole32(be32toh(wr->imm_data)); - SWITCH_FALLTHROUGH; - case IBV_WR_RDMA_WRITE: - bytes = bnxt_re_build_rdma_sqe(qp, sqe, wr, is_inline); - break; - case IBV_WR_RDMA_READ: - bytes = bnxt_re_build_rdma_sqe(qp, sqe, wr, false); - break; - case IBV_WR_ATOMIC_CMP_AND_SWP: - bytes = bnxt_re_build_cns_sqe(qp, sqe, wr); - break; - case IBV_WR_ATOMIC_FETCH_AND_ADD: - bytes = bnxt_re_build_fna_sqe(qp, sqe, wr); - break; - default: - bytes = -EINVAL; - break; - } - - if (bytes < 0) { - ret = (bytes == -EINVAL) ? EINVAL : ENOMEM; - *bad = wr; - break; - } - - bnxt_re_fill_wrid(wrid, wr, bytes, qp->cap.sqsig); - bnxt_re_fill_psns(qp, psns, wr->opcode, bytes); - bnxt_re_incr_tail(sq); - qp->wqe_cnt++; - wr = wr->next; - bnxt_re_ring_sq_db(qp); - if (qp->wqe_cnt == BNXT_RE_UD_QP_HW_STALL && qp->qptyp == - IBV_QPT_UD) { - /* Move RTS to RTS since it is time. */ - struct ibv_qp_attr attr; - int attr_mask; - - attr_mask = IBV_QP_STATE; - attr.qp_state = IBV_QPS_RTS; - bnxt_re_modify_qp(&qp->ibvqp, &attr, attr_mask); - qp->wqe_cnt = 0; - } - } - - pthread_spin_unlock(&sq->qlock); - return ret; -} - -static int bnxt_re_build_rqe(struct bnxt_re_qp *qp, struct ibv_recv_wr *wr, - void *rqe) -{ - struct bnxt_re_brqe *hdr = rqe; - struct bnxt_re_rqe *rwr; - struct bnxt_re_sge *sge; - struct bnxt_re_wrid *wrid; - int wqe_sz, len; - uint32_t hdrval; - - rwr = (rqe + sizeof(struct bnxt_re_brqe)); - sge = (rqe + bnxt_re_get_rqe_hdr_sz()); - wrid = &qp->rwrid[qp->rqq->tail]; - - len = bnxt_re_build_sge(sge, wr->sg_list, wr->num_sge, false); - wqe_sz = wr->num_sge + (bnxt_re_get_rqe_hdr_sz() >> 4); /* 16B align */ - /* HW requires wqe size has room for atleast one sge even if none was - * supplied by application - */ - if (!wr->num_sge) - wqe_sz++; - hdrval = BNXT_RE_WR_OPCD_RECV; - hdrval |= ((wqe_sz & BNXT_RE_HDR_WS_MASK) << BNXT_RE_HDR_WS_SHIFT); - hdr->rsv_ws_fl_wt = htole32(hdrval); - rwr->wrid = htole32(qp->rqq->tail); - - /* Fill wrid */ - wrid->wrid = wr->wr_id; - wrid->bytes = len; /* N.A. for RQE */ - wrid->sig = 0; /* N.A. for RQE */ - - return len; -} - -int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad) -{ - struct bnxt_re_qp *qp = to_bnxt_re_qp(ibvqp); - struct bnxt_re_queue *rq = qp->rqq; - void *rqe; - int ret; - - pthread_spin_lock(&rq->qlock); - while (wr) { - /* check QP state, abort if it is ERR or RST */ - if (qp->qpst == IBV_QPS_RESET || qp->qpst == IBV_QPS_ERR) { - *bad = wr; - pthread_spin_unlock(&rq->qlock); - return EINVAL; - } - - if (bnxt_re_is_que_full(rq) || - wr->num_sge > qp->cap.max_rsge) { - pthread_spin_unlock(&rq->qlock); - *bad = wr; - return ENOMEM; - } - - rqe = (void *)(rq->va + (rq->tail * rq->stride)); - memset(rqe, 0, bnxt_re_get_rqe_sz()); - ret = bnxt_re_build_rqe(qp, wr, rqe); - if (ret < 0) { - pthread_spin_unlock(&rq->qlock); - *bad = wr; - return ENOMEM; - } - - bnxt_re_incr_tail(rq); - wr = wr->next; - bnxt_re_ring_rq_db(qp); - } - pthread_spin_unlock(&rq->qlock); - - return 0; -} - -struct ibv_srq *bnxt_re_create_srq(struct ibv_pd *ibvpd, - struct ibv_srq_init_attr *attr) -{ - return NULL; -} - -int bnxt_re_modify_srq(struct ibv_srq *ibvsrq, struct ibv_srq_attr *attr, - int init_attr) -{ - return -ENOSYS; -} - -int bnxt_re_destroy_srq(struct ibv_srq *ibvsrq) -{ - return -ENOSYS; -} - -int bnxt_re_query_srq(struct ibv_srq *ibvsrq, struct ibv_srq_attr *attr) -{ - return -ENOSYS; -} - -int bnxt_re_post_srq_recv(struct ibv_srq *ibvsrq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad) -{ - return -ENOSYS; -} - -struct ibv_ah *bnxt_re_create_ah(struct ibv_pd *ibvpd, struct ibv_ah_attr *attr) -{ - struct bnxt_re_context *uctx; - struct bnxt_re_ah *ah; - struct ibv_create_ah_resp resp; - int status; - - uctx = to_bnxt_re_context(ibvpd->context); - - ah = calloc(1, sizeof(*ah)); - if (!ah) - goto failed; - - pthread_mutex_lock(&uctx->shlock); - memset(&resp, 0, sizeof(resp)); - status = ibv_cmd_create_ah(ibvpd, &ah->ibvah, attr, - &resp, sizeof(resp)); - if (status) { - pthread_mutex_unlock(&uctx->shlock); - free(ah); - goto failed; - } - /* read AV ID now. */ - ah->avid = *(uint32_t *)(uctx->shpg + BNXT_RE_SHPG_AVID_OFFT); - pthread_mutex_unlock(&uctx->shlock); - - return &ah->ibvah; -failed: - return NULL; -} - -int bnxt_re_destroy_ah(struct ibv_ah *ibvah) -{ - struct bnxt_re_ah *ah; - int status; - - ah = to_bnxt_re_ah(ibvah); - status = ibv_cmd_destroy_ah(ibvah); - if (status) - return status; - free(ah); - - return 0; -} diff --git a/usr/rdma-core/providers/bnxt_re/verbs.h b/usr/rdma-core/providers/bnxt_re/verbs.h deleted file mode 100644 index 1b2a4a753..000000000 --- a/usr/rdma-core/providers/bnxt_re/verbs.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Broadcom NetXtreme-E User Space RoCE driver - * - * Copyright (c) 2015-2017, Broadcom. All rights reserved. The term - * Broadcom refers to Broadcom Limited and/or its subsidiaries. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Description: Internal IB-verbs function declaration - */ - -#ifndef __VERBS_H__ -#define __VERBS_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -int bnxt_re_query_device(struct ibv_context *uctx, - struct ibv_device_attr *attr); -int bnxt_re_query_port(struct ibv_context *uctx, uint8_t port, - struct ibv_port_attr *attr); -struct ibv_pd *bnxt_re_alloc_pd(struct ibv_context *uctx); -int bnxt_re_free_pd(struct ibv_pd *ibvpd); -struct ibv_mr *bnxt_re_reg_mr(struct ibv_pd *ibvpd, void *buf, size_t len, - int ibv_access_flags); -int bnxt_re_dereg_mr(struct ibv_mr *ibvmr); - -struct ibv_cq *bnxt_re_create_cq(struct ibv_context *uctx, int ncqe, - struct ibv_comp_channel *ch, int vec); -int bnxt_re_resize_cq(struct ibv_cq *ibvcq, int ncqe); -int bnxt_re_destroy_cq(struct ibv_cq *ibvcq); -int bnxt_re_poll_cq(struct ibv_cq *ibvcq, int nwc, struct ibv_wc *wc); -void bnxt_re_cq_event(struct ibv_cq *ibvcq); -int bnxt_re_arm_cq(struct ibv_cq *ibvcq, int flags); - -struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd, - struct ibv_qp_init_attr *attr); -int bnxt_re_modify_qp(struct ibv_qp *ibvqp, struct ibv_qp_attr *attr, - int ibv_qp_attr_mask); -int bnxt_re_query_qp(struct ibv_qp *ibvqp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr); -int bnxt_re_destroy_qp(struct ibv_qp *ibvqp); -int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad); -int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad); - -struct ibv_srq *bnxt_re_create_srq(struct ibv_pd *ibvpd, - struct ibv_srq_init_attr *attr); -int bnxt_re_modify_srq(struct ibv_srq *ibvsrq, - struct ibv_srq_attr *attr, int mask); -int bnxt_re_destroy_srq(struct ibv_srq *ibvsrq); -int bnxt_re_query_srq(struct ibv_srq *ibvsrq, struct ibv_srq_attr *attr); -int bnxt_re_post_srq_recv(struct ibv_srq *ibvsrq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad); - -struct ibv_ah *bnxt_re_create_ah(struct ibv_pd *ibvpd, - struct ibv_ah_attr *attr); -int bnxt_re_destroy_ah(struct ibv_ah *ibvah); - -#endif /* __BNXT_RE_VERBS_H__ */ diff --git a/usr/rdma-core/providers/cxgb3/CMakeLists.txt b/usr/rdma-core/providers/cxgb3/CMakeLists.txt deleted file mode 100644 index a578105e7..000000000 --- a/usr/rdma-core/providers/cxgb3/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -rdma_provider(cxgb3 - cq.c - iwch.c - qp.c - verbs.c -) diff --git a/usr/rdma-core/providers/cxgb3/cq.c b/usr/rdma-core/providers/cxgb3/cq.c deleted file mode 100644 index 6cb4fe74d..000000000 --- a/usr/rdma-core/providers/cxgb3/cq.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -#include -#include -#include - -#include - -#include "iwch.h" -#include "iwch-abi.h" - -int iwch_arm_cq(struct ibv_cq *ibcq, int solicited) -{ - int ret; - struct iwch_cq *chp = to_iwch_cq(ibcq); - - pthread_spin_lock(&chp->lock); - ret = ibv_cmd_req_notify_cq(ibcq, solicited); - pthread_spin_unlock(&chp->lock); - - return ret; -} - -static inline void flush_completed_wrs(struct t3_wq *wq, struct t3_cq *cq) -{ - struct t3_swsq *sqp; - uint32_t ptr = wq->sq_rptr; - int count = Q_COUNT(wq->sq_rptr, wq->sq_wptr); - - sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2); - while (count--) { - if (!sqp->signaled) { - ptr++; - sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2); - } else if (sqp->complete) { - - /* - * Insert this completed cqe into the swcq. - */ - sqp->cqe.header |= htobe32(V_CQE_SWCQE(1)); - *(cq->sw_queue + Q_PTR2IDX(cq->sw_wptr, cq->size_log2)) - = sqp->cqe; - cq->sw_wptr++; - sqp->signaled = 0; - break; - } else - break; - } -} - -static inline void create_read_req_cqe(struct t3_wq *wq, - struct t3_cqe *hw_cqe, - struct t3_cqe *read_cqe) -{ - CQE_WRID_SQ_WPTR(*read_cqe) = wq->oldest_read->sq_wptr; - read_cqe->len = wq->oldest_read->read_len; - read_cqe->header = htobe32(V_CQE_QPID(CQE_QPID(*hw_cqe)) | - V_CQE_SWCQE(SW_CQE(*hw_cqe)) | - V_CQE_OPCODE(T3_READ_REQ) | - V_CQE_TYPE(1)); -} - -/* - * Return a ptr to the next read wr in the SWSQ or NULL. - */ -static inline void advance_oldest_read(struct t3_wq *wq) -{ - - uint32_t rptr = wq->oldest_read - wq->sq + 1; - uint32_t wptr = Q_PTR2IDX(wq->sq_wptr, wq->sq_size_log2); - - while (Q_PTR2IDX(rptr, wq->sq_size_log2) != wptr) { - wq->oldest_read = wq->sq + Q_PTR2IDX(rptr, wq->sq_size_log2); - - if (wq->oldest_read->opcode == T3_READ_REQ) { - return; - } - rptr++; - } - wq->oldest_read = NULL; -} - -static inline int cxio_poll_cq(struct t3_wq *wq, struct t3_cq *cq, - struct t3_cqe *cqe, uint8_t *cqe_flushed, - uint64_t *cookie) -{ - int ret = 0; - struct t3_cqe *hw_cqe, read_cqe; - - *cqe_flushed = 0; - hw_cqe = cxio_next_cqe(cq); - udma_from_device_barrier(); - - /* - * Skip cqes not affiliated with a QP. - */ - if (wq == NULL) { - ret = -1; - goto skip_cqe; - } - - /* - * Gotta tweak READ completions: - * 1) the cqe doesn't contain the sq_wptr from the wr. - * 2) opcode not reflected from the wr. - * 3) read_len not reflected from the wr. - * 4) cq_type is RQ_TYPE not SQ_TYPE. - */ - if (CQE_OPCODE(*hw_cqe) == T3_READ_RESP) { - - /* - * If this is an unsolicited read response to local stag 1, - * then the read was generated by the kernel driver as part - * of peer-2-peer connection setup. So ignore the completion. - */ - if (CQE_WRID_STAG(*hw_cqe) == 1) { - if (CQE_STATUS(*hw_cqe)) - wq->error = 1; - ret = -1; - goto skip_cqe; - } - - /* - * Don't write to the HWCQ, so create a new read req CQE - * in local memory. - */ - create_read_req_cqe(wq, hw_cqe, &read_cqe); - hw_cqe = &read_cqe; - advance_oldest_read(wq); - } - - /* - * Errors. - */ - if (CQE_STATUS(*hw_cqe) || t3_wq_in_error(wq)) { - *cqe_flushed = t3_wq_in_error(wq); - t3_set_wq_in_error(wq); - goto proc_cqe; - } - - /* - * RECV completion. - */ - if (RQ_TYPE(*hw_cqe)) { - - /* - * HW only validates 4 bits of MSN. So we must validate that - * the MSN in the SEND is the next expected MSN. If its not, - * then we complete this with TPT_ERR_MSN and mark the wq in - * error. - */ - if ((CQE_WRID_MSN(*hw_cqe) != (wq->rq_rptr + 1))) { - t3_set_wq_in_error(wq); - hw_cqe->header |= htobe32(V_CQE_STATUS(TPT_ERR_MSN)); - } - goto proc_cqe; - } - - /* - * If we get here its a send completion. - * - * Handle out of order completion. These get stuffed - * in the SW SQ. Then the SW SQ is walked to move any - * now in-order completions into the SW CQ. This handles - * 2 cases: - * 1) reaping unsignaled WRs when the first subsequent - * signaled WR is completed. - * 2) out of order read completions. - */ - if (!SW_CQE(*hw_cqe) && (CQE_WRID_SQ_WPTR(*hw_cqe) != wq->sq_rptr)) { - struct t3_swsq *sqp; - - sqp = wq->sq + - Q_PTR2IDX(CQE_WRID_SQ_WPTR(*hw_cqe), wq->sq_size_log2); - sqp->cqe = *hw_cqe; - sqp->complete = 1; - ret = -1; - goto flush_wq; - } - -proc_cqe: - *cqe = *hw_cqe; - - /* - * Reap the associated WR(s) that are freed up with this - * completion. - */ - if (SQ_TYPE(*hw_cqe)) { - wq->sq_rptr = CQE_WRID_SQ_WPTR(*hw_cqe); - *cookie = (wq->sq + - Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2))->wr_id; - wq->sq_rptr++; - } else { - *cookie = *(wq->rq + Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); - wq->rq_rptr++; - } - -flush_wq: - /* - * Flush any completed cqes that are now in-order. - */ - flush_completed_wrs(wq, cq); - -skip_cqe: - if (SW_CQE(*hw_cqe)) { - PDBG("%s cq %p cqid 0x%x skip sw cqe sw_rptr 0x%x\n", - __FUNCTION__, cq, cq->cqid, cq->sw_rptr); - ++cq->sw_rptr; - } else { - PDBG("%s cq %p cqid 0x%x skip hw cqe sw_rptr 0x%x\n", - __FUNCTION__, cq, cq->cqid, cq->rptr); - ++cq->rptr; - } - - return ret; -} - -/* - * Get one cq entry from cxio and map it to openib. - * - * Returns: - * 0 EMPTY; - * 1 cqe returned - * -EAGAIN caller must try again - * any other -errno fatal error - */ -static int iwch_poll_cq_one(struct iwch_device *rhp, struct iwch_cq *chp, - struct ibv_wc *wc) -{ - struct iwch_qp *qhp = NULL; - struct t3_cqe cqe, *hw_cqe; - struct t3_wq *wq; - uint8_t cqe_flushed; - uint64_t cookie; - int ret = 1; - - hw_cqe = cxio_next_cqe(&chp->cq); - udma_from_device_barrier(); - - if (!hw_cqe) - return 0; - - qhp = rhp->qpid2ptr[CQE_QPID(*hw_cqe)]; - if (!qhp) - wq = NULL; - else { - pthread_spin_lock(&qhp->lock); - wq = &(qhp->wq); - } - ret = cxio_poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie); - if (ret) { - ret = -EAGAIN; - goto out; - } - ret = 1; - - wc->wr_id = cookie; - wc->qp_num = qhp->wq.qpid; - wc->vendor_err = CQE_STATUS(cqe); - wc->wc_flags = 0; - - PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x " - "lo 0x%x cookie 0x%" PRIx64 "\n", - __FUNCTION__, CQE_QPID(cqe), CQE_TYPE(cqe), - CQE_OPCODE(cqe), CQE_STATUS(cqe), CQE_WRID_HI(cqe), - CQE_WRID_LOW(cqe), cookie); - - if (CQE_TYPE(cqe) == 0) { - if (!CQE_STATUS(cqe)) - wc->byte_len = CQE_LEN(cqe); - else - wc->byte_len = 0; - wc->opcode = IBV_WC_RECV; - } else { - switch (CQE_OPCODE(cqe)) { - case T3_RDMA_WRITE: - wc->opcode = IBV_WC_RDMA_WRITE; - break; - case T3_READ_REQ: - wc->opcode = IBV_WC_RDMA_READ; - wc->byte_len = CQE_LEN(cqe); - break; - case T3_SEND: - case T3_SEND_WITH_SE: - wc->opcode = IBV_WC_SEND; - break; - case T3_BIND_MW: - wc->opcode = IBV_WC_BIND_MW; - break; - - /* these aren't supported yet */ - case T3_SEND_WITH_INV: - case T3_SEND_WITH_SE_INV: - case T3_LOCAL_INV: - case T3_FAST_REGISTER: - default: - PDBG("%s Unexpected opcode %d CQID 0x%x QPID 0x%x\n", - __FUNCTION__, CQE_OPCODE(cqe), chp->cq.cqid, - CQE_QPID(cqe)); - ret = -EINVAL; - goto out; - } - } - - if (cqe_flushed) { - wc->status = IBV_WC_WR_FLUSH_ERR; - } else { - - switch (CQE_STATUS(cqe)) { - case TPT_ERR_SUCCESS: - wc->status = IBV_WC_SUCCESS; - break; - case TPT_ERR_STAG: - wc->status = IBV_WC_LOC_ACCESS_ERR; - break; - case TPT_ERR_PDID: - wc->status = IBV_WC_LOC_PROT_ERR; - break; - case TPT_ERR_QPID: - case TPT_ERR_ACCESS: - wc->status = IBV_WC_LOC_ACCESS_ERR; - break; - case TPT_ERR_WRAP: - wc->status = IBV_WC_GENERAL_ERR; - break; - case TPT_ERR_BOUND: - wc->status = IBV_WC_LOC_LEN_ERR; - break; - case TPT_ERR_INVALIDATE_SHARED_MR: - case TPT_ERR_INVALIDATE_MR_WITH_MW_BOUND: - wc->status = IBV_WC_MW_BIND_ERR; - break; - case TPT_ERR_CRC: - case TPT_ERR_MARKER: - case TPT_ERR_PDU_LEN_ERR: - case TPT_ERR_OUT_OF_RQE: - case TPT_ERR_DDP_VERSION: - case TPT_ERR_RDMA_VERSION: - case TPT_ERR_DDP_QUEUE_NUM: - case TPT_ERR_MSN: - case TPT_ERR_TBIT: - case TPT_ERR_MO: - case TPT_ERR_MSN_RANGE: - case TPT_ERR_IRD_OVERFLOW: - case TPT_ERR_OPCODE: - wc->status = IBV_WC_FATAL_ERR; - break; - case TPT_ERR_SWFLUSH: - wc->status = IBV_WC_WR_FLUSH_ERR; - break; - default: - PDBG("%s Unexpected status 0x%x CQID 0x%x QPID 0x%0x\n", - __FUNCTION__, CQE_STATUS(cqe), chp->cq.cqid, - CQE_QPID(cqe)); - ret = -EINVAL; - } - } -out: - if (wq) - pthread_spin_unlock(&qhp->lock); - return ret; -} - -int t3b_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc) -{ - struct iwch_device *rhp; - struct iwch_cq *chp; - int npolled; - int err = 0; - - chp = to_iwch_cq(ibcq); - rhp = chp->rhp; - - if (rhp->abi_version > 0 && t3_cq_in_error(&chp->cq)) { - t3_reset_cq_in_error(&chp->cq); - iwch_flush_qps(rhp); - } - - pthread_spin_lock(&chp->lock); - for (npolled = 0; npolled < num_entries; ++npolled) { - - /* - * Because T3 can post CQEs that are out of order, - * we might have to poll again after removing - * one of these. - */ - do { - err = iwch_poll_cq_one(rhp, chp, wc + npolled); - } while (err == -EAGAIN); - if (err <= 0) - break; - } - pthread_spin_unlock(&chp->lock); - - if (err < 0) - return err; - else { - return npolled; - } -} - -int t3a_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc) -{ - int ret; - struct iwch_cq *chp = to_iwch_cq(ibcq); - - pthread_spin_lock(&chp->lock); - ret = ibv_cmd_poll_cq(ibcq, num_entries, wc); - pthread_spin_unlock(&chp->lock); - return ret; -} diff --git a/usr/rdma-core/providers/cxgb3/cxio_wr.h b/usr/rdma-core/providers/cxgb3/cxio_wr.h deleted file mode 100644 index 042bd9414..000000000 --- a/usr/rdma-core/providers/cxgb3/cxio_wr.h +++ /dev/null @@ -1,758 +0,0 @@ -/* - * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __CXIO_WR_H__ -#define __CXIO_WR_H__ - -#include -#include -#include -#include -#include "firmware_exports.h" - -#define T3_MAX_NUM_QP (1<<15) -#define T3_MAX_NUM_CQ (1<<15) -#define T3_MAX_NUM_PD (1<<15) -#define T3_MAX_NUM_STAG (1<<15) -#define T3_MAX_SGE 4 -#define T3_MAX_INLINE 64 - -#define Q_EMPTY(rptr,wptr) ((rptr)==(wptr)) -#define Q_FULL(rptr,wptr,size_log2) ( (((wptr)-(rptr))>>(size_log2)) && \ - ((rptr)!=(wptr)) ) -#define Q_GENBIT(ptr,size_log2) (!(((ptr)>>size_log2)&0x1)) -#define Q_FREECNT(rptr,wptr,size_log2) ((1UL<> S_FW_RIWR_OP)) & M_FW_RIWR_OP) - -#define S_FW_RIWR_SOPEOP 22 -#define M_FW_RIWR_SOPEOP 0x3 -#define V_FW_RIWR_SOPEOP(x) ((x) << S_FW_RIWR_SOPEOP) - -#define S_FW_RIWR_FLAGS 8 -#define M_FW_RIWR_FLAGS 0x3fffff -#define V_FW_RIWR_FLAGS(x) ((x) << S_FW_RIWR_FLAGS) -#define G_FW_RIWR_FLAGS(x) ((((x) >> S_FW_RIWR_FLAGS)) & M_FW_RIWR_FLAGS) - -#define S_FW_RIWR_TID 8 -#define V_FW_RIWR_TID(x) ((x) << S_FW_RIWR_TID) - -#define S_FW_RIWR_LEN 0 -#define V_FW_RIWR_LEN(x) ((x) << S_FW_RIWR_LEN) - -#define S_FW_RIWR_GEN 31 -#define V_FW_RIWR_GEN(x) ((x) << S_FW_RIWR_GEN) - -struct t3_sge { - uint32_t stag; - uint32_t len; - uint64_t to; -}; - -/* If num_sgle is zero, flit 5+ contains immediate data.*/ -struct t3_send_wr { - struct fw_riwrh wrh; /* 0 */ - union t3_wrid wrid; /* 1 */ - - enum t3_rdma_opcode rdmaop:8; - uint32_t reserved:24; /* 2 */ - uint32_t rem_stag; /* 2 */ - uint32_t plen; /* 3 */ - uint32_t num_sgle; - struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */ -}; - -struct t3_local_inv_wr { - struct fw_riwrh wrh; /* 0 */ - union t3_wrid wrid; /* 1 */ - uint32_t stag; /* 2 */ - uint32_t reserved3; -}; - -struct t3_rdma_write_wr { - struct fw_riwrh wrh; /* 0 */ - union t3_wrid wrid; /* 1 */ - enum t3_rdma_opcode rdmaop:8; /* 2 */ - uint32_t reserved:24; /* 2 */ - uint32_t stag_sink; - uint64_t to_sink; /* 3 */ - uint32_t plen; /* 4 */ - uint32_t num_sgle; - struct t3_sge sgl[T3_MAX_SGE]; /* 5+ */ -}; - -struct t3_rdma_read_wr { - struct fw_riwrh wrh; /* 0 */ - union t3_wrid wrid; /* 1 */ - enum t3_rdma_opcode rdmaop:8; /* 2 */ - uint32_t reserved:24; - uint32_t rem_stag; - uint64_t rem_to; /* 3 */ - uint32_t local_stag; /* 4 */ - uint32_t local_len; - uint64_t local_to; /* 5 */ -}; - -enum t3_addr_type { - T3_VA_BASED_TO = 0x0, - T3_ZERO_BASED_TO = 0x1 -} __attribute__ ((packed)); - -enum t3_mem_perms { - T3_MEM_ACCESS_LOCAL_READ = 0x1, - T3_MEM_ACCESS_LOCAL_WRITE = 0x2, - T3_MEM_ACCESS_REM_READ = 0x4, - T3_MEM_ACCESS_REM_WRITE = 0x8 -} __attribute__ ((packed)); - -struct t3_bind_mw_wr { - struct fw_riwrh wrh; /* 0 */ - union t3_wrid wrid; /* 1 */ - uint32_t reserved:16; - enum t3_addr_type type:8; - enum t3_mem_perms perms:8; /* 2 */ - uint32_t mr_stag; - uint32_t mw_stag; /* 3 */ - uint32_t mw_len; - uint64_t mw_va; /* 4 */ - uint32_t mr_pbl_addr; /* 5 */ - uint32_t reserved2:24; - uint32_t mr_pagesz:8; -}; - -struct t3_receive_wr { - struct fw_riwrh wrh; /* 0 */ - union t3_wrid wrid; /* 1 */ - uint8_t pagesz[T3_MAX_SGE]; - uint32_t num_sgle; /* 2 */ - struct t3_sge sgl[T3_MAX_SGE]; /* 3+ */ - uint32_t pbl_addr[T3_MAX_SGE]; -}; - -struct t3_bypass_wr { - struct fw_riwrh wrh; - union t3_wrid wrid; /* 1 */ -}; - -struct t3_modify_qp_wr { - struct fw_riwrh wrh; /* 0 */ - union t3_wrid wrid; /* 1 */ - uint32_t flags; /* 2 */ - uint32_t quiesce; /* 2 */ - uint32_t max_ird; /* 3 */ - uint32_t max_ord; /* 3 */ - uint64_t sge_cmd; /* 4 */ - uint64_t ctx1; /* 5 */ - uint64_t ctx0; /* 6 */ -}; - -enum t3_modify_qp_flags { - MODQP_QUIESCE = 0x01, - MODQP_MAX_IRD = 0x02, - MODQP_MAX_ORD = 0x04, - MODQP_WRITE_EC = 0x08, - MODQP_READ_EC = 0x10, -}; - - -enum t3_mpa_attrs { - uP_RI_MPA_RX_MARKER_ENABLE = 0x1, - uP_RI_MPA_TX_MARKER_ENABLE = 0x2, - uP_RI_MPA_CRC_ENABLE = 0x4, - uP_RI_MPA_IETF_ENABLE = 0x8 -} __attribute__ ((packed)); - -enum t3_qp_caps { - uP_RI_QP_RDMA_READ_ENABLE = 0x01, - uP_RI_QP_RDMA_WRITE_ENABLE = 0x02, - uP_RI_QP_BIND_ENABLE = 0x04, - uP_RI_QP_FAST_REGISTER_ENABLE = 0x08, - uP_RI_QP_STAG0_ENABLE = 0x10 -} __attribute__ ((packed)); - -struct t3_rdma_init_attr { - uint32_t tid; - uint32_t qpid; - uint32_t pdid; - uint32_t scqid; - uint32_t rcqid; - uint32_t rq_addr; - uint32_t rq_size; - enum t3_mpa_attrs mpaattrs; - enum t3_qp_caps qpcaps; - uint16_t tcp_emss; - uint32_t ord; - uint32_t ird; - uint64_t qp_dma_addr; - uint32_t qp_dma_size; - uint8_t rqes_posted; -}; - -struct t3_rdma_init_wr { - struct fw_riwrh wrh; /* 0 */ - union t3_wrid wrid; /* 1 */ - uint32_t qpid; /* 2 */ - uint32_t pdid; - uint32_t scqid; /* 3 */ - uint32_t rcqid; - uint32_t rq_addr; /* 4 */ - uint32_t rq_size; - enum t3_mpa_attrs mpaattrs:8; /* 5 */ - enum t3_qp_caps qpcaps:8; - uint32_t ulpdu_size:16; - uint32_t rqes_posted; /* bits 31-1 - reservered */ - /* bit 0 - set if RECV posted */ - uint32_t ord; /* 6 */ - uint32_t ird; - uint64_t qp_dma_addr; /* 7 */ - uint32_t qp_dma_size; /* 8 */ - uint32_t rsvd; -}; - -union t3_wr { - struct t3_send_wr send; - struct t3_rdma_write_wr write; - struct t3_rdma_read_wr read; - struct t3_receive_wr recv; - struct t3_local_inv_wr local_inv; - struct t3_bind_mw_wr bind; - struct t3_bypass_wr bypass; - struct t3_rdma_init_wr init; - struct t3_modify_qp_wr qp_mod; - uint64_t flit[16]; -}; - -#define T3_SQ_CQE_FLIT 13 -#define T3_SQ_COOKIE_FLIT 14 - -#define T3_RQ_COOKIE_FLIT 13 -#define T3_RQ_CQE_FLIT 14 - -static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op, - enum t3_wr_flags flags, uint8_t genbit, - uint32_t tid, uint8_t len) -{ - wqe->op_seop_flags = htobe32(V_FW_RIWR_OP(op) | - V_FW_RIWR_SOPEOP(M_FW_RIWR_SOPEOP) | - V_FW_RIWR_FLAGS(flags)); - udma_to_device_barrier(); - wqe->gen_tid_len = htobe32(V_FW_RIWR_GEN(genbit) | V_FW_RIWR_TID(tid) | - V_FW_RIWR_LEN(len)); - /* 2nd gen bit... */ - ((union t3_wr *)wqe)->flit[15] = htobe64(genbit); -} - -/* - * T3 ULP2_TX commands - */ -enum t3_utx_mem_op { - T3_UTX_MEM_READ = 2, - T3_UTX_MEM_WRITE = 3 -}; - -/* T3 MC7 RDMA TPT entry format */ - -enum tpt_mem_type { - TPT_NON_SHARED_MR = 0x0, - TPT_SHARED_MR = 0x1, - TPT_MW = 0x2, - TPT_MW_RELAXED_PROTECTION = 0x3 -}; - -enum tpt_addr_type { - TPT_ZBTO = 0, - TPT_VATO = 1 -}; - -enum tpt_mem_perm { - TPT_LOCAL_READ = 0x8, - TPT_LOCAL_WRITE = 0x4, - TPT_REMOTE_READ = 0x2, - TPT_REMOTE_WRITE = 0x1 -}; - -struct tpt_entry { - uint32_t valid_stag_pdid; - uint32_t flags_pagesize_qpid; - - uint32_t rsvd_pbl_addr; - uint32_t len; - uint32_t va_hi; - uint32_t va_low_or_fbo; - - uint32_t rsvd_bind_cnt_or_pstag; - uint32_t rsvd_pbl_size; -}; - -#define S_TPT_VALID 31 -#define V_TPT_VALID(x) ((x) << S_TPT_VALID) -#define F_TPT_VALID V_TPT_VALID(1U) - -#define S_TPT_STAG_KEY 23 -#define M_TPT_STAG_KEY 0xFF -#define V_TPT_STAG_KEY(x) ((x) << S_TPT_STAG_KEY) -#define G_TPT_STAG_KEY(x) (((x) >> S_TPT_STAG_KEY) & M_TPT_STAG_KEY) - -#define S_TPT_STAG_STATE 22 -#define V_TPT_STAG_STATE(x) ((x) << S_TPT_STAG_STATE) -#define F_TPT_STAG_STATE V_TPT_STAG_STATE(1U) - -#define S_TPT_STAG_TYPE 20 -#define M_TPT_STAG_TYPE 0x3 -#define V_TPT_STAG_TYPE(x) ((x) << S_TPT_STAG_TYPE) -#define G_TPT_STAG_TYPE(x) (((x) >> S_TPT_STAG_TYPE) & M_TPT_STAG_TYPE) - -#define S_TPT_PDID 0 -#define M_TPT_PDID 0xFFFFF -#define V_TPT_PDID(x) ((x) << S_TPT_PDID) -#define G_TPT_PDID(x) (((x) >> S_TPT_PDID) & M_TPT_PDID) - -#define S_TPT_PERM 28 -#define M_TPT_PERM 0xF -#define V_TPT_PERM(x) ((x) << S_TPT_PERM) -#define G_TPT_PERM(x) (((x) >> S_TPT_PERM) & M_TPT_PERM) - -#define S_TPT_REM_INV_DIS 27 -#define V_TPT_REM_INV_DIS(x) ((x) << S_TPT_REM_INV_DIS) -#define F_TPT_REM_INV_DIS V_TPT_REM_INV_DIS(1U) - -#define S_TPT_ADDR_TYPE 26 -#define V_TPT_ADDR_TYPE(x) ((x) << S_TPT_ADDR_TYPE) -#define F_TPT_ADDR_TYPE V_TPT_ADDR_TYPE(1U) - -#define S_TPT_MW_BIND_ENABLE 25 -#define V_TPT_MW_BIND_ENABLE(x) ((x) << S_TPT_MW_BIND_ENABLE) -#define F_TPT_MW_BIND_ENABLE V_TPT_MW_BIND_ENABLE(1U) - -#define S_TPT_PAGE_SIZE 20 -#define M_TPT_PAGE_SIZE 0x1F -#define V_TPT_PAGE_SIZE(x) ((x) << S_TPT_PAGE_SIZE) -#define G_TPT_PAGE_SIZE(x) (((x) >> S_TPT_PAGE_SIZE) & M_TPT_PAGE_SIZE) - -#define S_TPT_PBL_ADDR 0 -#define M_TPT_PBL_ADDR 0x1FFFFFFF -#define V_TPT_PBL_ADDR(x) ((x) << S_TPT_PBL_ADDR) -#define G_TPT_PBL_ADDR(x) (((x) >> S_TPT_PBL_ADDR) & M_TPT_PBL_ADDR) - -#define S_TPT_QPID 0 -#define M_TPT_QPID 0xFFFFF -#define V_TPT_QPID(x) ((x) << S_TPT_QPID) -#define G_TPT_QPID(x) (((x) >> S_TPT_QPID) & M_TPT_QPID) - -#define S_TPT_PSTAG 0 -#define M_TPT_PSTAG 0xFFFFFF -#define V_TPT_PSTAG(x) ((x) << S_TPT_PSTAG) -#define G_TPT_PSTAG(x) (((x) >> S_TPT_PSTAG) & M_TPT_PSTAG) - -#define S_TPT_PBL_SIZE 0 -#define M_TPT_PBL_SIZE 0xFFFFF -#define V_TPT_PBL_SIZE(x) ((x) << S_TPT_PBL_SIZE) -#define G_TPT_PBL_SIZE(x) (((x) >> S_TPT_PBL_SIZE) & M_TPT_PBL_SIZE) - -/* - * CQE defs - */ -struct t3_cqe { - uint32_t header:32; - uint32_t len:32; - uint32_t wrid_hi_stag:32; - uint32_t wrid_low_msn:32; -}; - -#define S_CQE_OOO 31 -#define M_CQE_OOO 0x1 -#define G_CQE_OOO(x) ((((x) >> S_CQE_OOO)) & M_CQE_OOO) -#define V_CEQ_OOO(x) ((x)<> S_CQE_QPID)) & M_CQE_QPID) -#define V_CQE_QPID(x) ((x)<> S_CQE_SWCQE)) & M_CQE_SWCQE) -#define V_CQE_SWCQE(x) ((x)<> S_CQE_GENBIT) & M_CQE_GENBIT) -#define V_CQE_GENBIT(x) ((x)<> S_CQE_STATUS)) & M_CQE_STATUS) -#define V_CQE_STATUS(x) ((x)<> S_CQE_TYPE)) & M_CQE_TYPE) -#define V_CQE_TYPE(x) ((x)<> S_CQE_OPCODE)) & M_CQE_OPCODE) -#define V_CQE_OPCODE(x) ((x)<size_log2); -} - -static inline unsigned t3_sq_depth(struct t3_wq *wq) -{ - return (1UL<sq_size_log2); -} - -static inline unsigned t3_rq_depth(struct t3_wq *wq) -{ - return (1UL<rq_size_log2); -} - -static inline unsigned t3_cq_depth(struct t3_cq *cq) -{ - return (1UL<size_log2); -} - -extern unsigned long iwch_page_size; -extern unsigned long iwch_page_shift; -extern unsigned long iwch_page_mask; - -#define PAGE_ALIGN(x) (((x) + iwch_page_mask) & ~iwch_page_mask) - -static inline unsigned t3_wq_memsize(struct t3_wq *wq) -{ - return PAGE_ALIGN((1UL<size_log2) * sizeof (union t3_wr)); -} - -static inline unsigned t3_cq_memsize(struct t3_cq *cq) -{ - return cq->memsize; -} - -static inline unsigned t3_mmid(uint32_t stag) -{ - return (stag>>8); -} - -struct t3_cq_status_page { - uint32_t cq_err; -}; - -static inline int t3_cq_in_error(struct t3_cq *cq) -{ - return ((struct t3_cq_status_page *) - &cq->queue[1 << cq->size_log2])->cq_err; -} - -static inline void t3_set_cq_in_error(struct t3_cq *cq) -{ - ((struct t3_cq_status_page *) - &cq->queue[1 << cq->size_log2])->cq_err = 1; -} - -static inline void t3_reset_cq_in_error(struct t3_cq *cq) -{ - ((struct t3_cq_status_page *) - &cq->queue[1 << cq->size_log2])->cq_err = 0; -} - -static inline int t3_wq_in_error(struct t3_wq *wq) -{ - /* - * The kernel sets bit 0 in the first WR of the WQ memory - * when the QP moves out of RTS... - */ - return (wq->queue->flit[13] & 1); -} - -static inline void t3_set_wq_in_error(struct t3_wq *wq) -{ - wq->queue->flit[13] |= 1; -} - -static inline int t3_wq_db_enabled(struct t3_wq *wq) -{ - return !(wq->queue->flit[13] & 2); -} - -#define CQ_VLD_ENTRY(ptr,size_log2,cqe) (Q_GENBIT(ptr,size_log2) == \ - CQE_GENBIT(*cqe)) - -static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq) -{ - struct t3_cqe *cqe; - - cqe = cq->queue + (Q_PTR2IDX(cq->rptr, cq->size_log2)); - if (CQ_VLD_ENTRY(cq->rptr, cq->size_log2, cqe)) - return cqe; - return NULL; -} - -static inline struct t3_cqe *cxio_next_sw_cqe(struct t3_cq *cq) -{ - struct t3_cqe *cqe; - - if (!Q_EMPTY(cq->sw_rptr, cq->sw_wptr)) { - cqe = cq->sw_queue + (Q_PTR2IDX(cq->sw_rptr, cq->size_log2)); - return cqe; - } - return NULL; -} - -static inline struct t3_cqe *cxio_next_cqe(struct t3_cq *cq) -{ - struct t3_cqe *cqe; - - if (!Q_EMPTY(cq->sw_rptr, cq->sw_wptr)) { - cqe = cq->sw_queue + (Q_PTR2IDX(cq->sw_rptr, cq->size_log2)); - return cqe; - } - cqe = cq->queue + (Q_PTR2IDX(cq->rptr, cq->size_log2)); - if (CQ_VLD_ENTRY(cq->rptr, cq->size_log2, cqe)) - return cqe; - return NULL; -} - -/* - * Return a ptr to the next read wr in the SWSQ or NULL. - */ -static inline struct t3_swsq *next_read_wr(struct t3_wq *wq) -{ - uint32_t rptr = wq->oldest_read - wq->sq + 1; - int count = Q_COUNT(rptr, wq->sq_wptr); - struct t3_swsq *sqp; - - while (count--) { - sqp = wq->sq + Q_PTR2IDX(rptr, wq->sq_size_log2); - - if (sqp->opcode == T3_READ_REQ) - return sqp; - - rptr++; - } - return NULL; -} -#endif diff --git a/usr/rdma-core/providers/cxgb3/firmware_exports.h b/usr/rdma-core/providers/cxgb3/firmware_exports.h deleted file mode 100644 index 831140a4c..000000000 --- a/usr/rdma-core/providers/cxgb3/firmware_exports.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2004-2007 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef _FIRMWARE_EXPORTS_H_ -#define _FIRMWARE_EXPORTS_H_ - -/* WR OPCODES supported by the firmware. - */ -#define FW_WROPCODE_FORWARD 0x01 -#define FW_WROPCODE_BYPASS 0x05 - -#define FW_WROPCODE_TUNNEL_TX_PKT 0x03 - -#define FW_WROPOCDE_ULPTX_DATA_SGL 0x00 -#define FW_WROPCODE_ULPTX_MEM_READ 0x02 -#define FW_WROPCODE_ULPTX_PKT 0x04 -#define FW_WROPCODE_ULPTX_INVALIDATE 0x06 - -#define FW_WROPCODE_TUNNEL_RX_PKT 0x07 - -#define FW_WROPCODE_TOE_GETTCB_RPL 0x08 -#define FW_WROPCODE_TOE_CLOSE_CON 0x09 -#define FW_WROPCODE_TOE_TP_ABORT_CON_REQ 0x0A -#define FW_WROPCODE_TOE_HOST_ABORT_CON_RPL 0x0F -#define FW_WROPCODE_TOE_HOST_ABORT_CON_REQ 0x0B -#define FW_WROPCODE_TOE_TP_ABORT_CON_RPL 0x0C -#define FW_WROPCODE_TOE_TX_DATA 0x0D -#define FW_WROPCODE_TOE_TX_DATA_ACK 0x0E - -#define FW_WROPCODE_RI_RDMA_INIT 0x10 -#define FW_WROPCODE_RI_RDMA_WRITE 0x11 -#define FW_WROPCODE_RI_RDMA_READ_REQ 0x12 -#define FW_WROPCODE_RI_RDMA_READ_RESP 0x13 -#define FW_WROPCODE_RI_SEND 0x14 -#define FW_WROPCODE_RI_TERMINATE 0x15 -#define FW_WROPCODE_RI_RDMA_READ 0x16 -#define FW_WROPCODE_RI_RECEIVE 0x17 -#define FW_WROPCODE_RI_BIND_MW 0x18 -#define FW_WROPCODE_RI_FASTREGISTER_MR 0x19 -#define FW_WROPCODE_RI_LOCAL_INV 0x1A -#define FW_WROPCODE_RI_MODIFY_QP 0x1B -#define FW_WROPCODE_RI_BYPASS 0x1C - -#define FW_WROPOCDE_RSVD 0x1E - -#define FW_WROPCODE_SGE_EGRESSCONTEXT_RR 0x1F - -#define FW_WROPCODE_MNGT 0x1D -#define FW_MNGTOPCODE_PKTSCHED_SET 0x00 - -/* Maximum size of a WR sent from the host, limited by the SGE. - * - * Note: WR coming from ULP or TP are only limited by CIM. - */ -#define FW_WR_SIZE 128 - -/* Maximum number of outstanding WRs sent from the host. Value must be - * programmed in the CTRL/TUNNEL/QP SGE Egress Context and used by TOM to - * limit the number of WRs per connection. - */ -#ifndef N3 -# define FW_WR_NUM 16 -#else -# define FW_WR_NUM 7 -#endif - -/* FW_TUNNEL_NUM corresponds to the number of supported TUNNEL Queues. These - * queues must start at SGE Egress Context FW_TUNNEL_SGEEC_START and must - * start at 'TID' (or 'uP Token') FW_TUNNEL_TID_START. - * - * Ingress Traffic (e.g. DMA completion credit) for TUNNEL Queue[i] is sent - * to RESP Queue[i]. - */ -#define FW_TUNNEL_NUM 8 -#define FW_TUNNEL_SGEEC_START 8 -#define FW_TUNNEL_TID_START 65544 - - -/* FW_CTRL_NUM corresponds to the number of supported CTRL Queues. These queues - * must start at SGE Egress Context FW_CTRL_SGEEC_START and must start at 'TID' - * (or 'uP Token') FW_CTRL_TID_START. - * - * Ingress Traffic for CTRL Queue[i] is sent to RESP Queue[i]. - */ -#define FW_CTRL_NUM 8 -#define FW_CTRL_SGEEC_START 65528 -#define FW_CTRL_TID_START 65536 - -/* FW_TOE_NUM corresponds to the number of supported TOE Queues. These queues - * must start at SGE Egress Context FW_TOE_SGEEC_START. - * - * Note: the 'uP Token' in the SGE Egress Context fields is irrelevant for - * TOE Queues, as the host is responsible for providing the correct TID in - * every WR. - * - * Ingress Trafffic for TOE Queue[i] is sent to RESP Queue[i]. - */ -#define FW_TOE_NUM 8 -#define FW_TOE_SGEEC_START 0 - -/* - * - */ -#define FW_RI_NUM 1 -#define FW_RI_SGEEC_START 65527 -#define FW_RI_TID_START 65552 - -/* - * The RX_PKT_TID - */ -#define FW_RX_PKT_NUM 1 -#define FW_RX_PKT_TID_START 65553 - -/* FW_WRC_NUM corresponds to the number of Work Request Context that supported - * by the firmware. - */ -#define FW_WRC_NUM (65536 + FW_TUNNEL_NUM + FW_CTRL_NUM +\ - FW_RI_NUM + FW_RX_PKT_NUM) - -#endif /* _FIRMWARE_EXPORTS_H_ */ diff --git a/usr/rdma-core/providers/cxgb3/iwch-abi.h b/usr/rdma-core/providers/cxgb3/iwch-abi.h deleted file mode 100644 index 7f2c12d98..000000000 --- a/usr/rdma-core/providers/cxgb3/iwch-abi.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef IWCH_ABI_H -#define IWCH_ABI_H - -#include -#include - -struct iwch_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; -}; - -struct iwch_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - uint32_t pdid; -}; - -struct iwch_create_cq { - struct ibv_create_cq ibv_cmd; - uint64_t user_rptr_addr; -}; - -struct iwch_reg_mr_resp { - struct ibv_reg_mr_resp ibv_resp; - uint32_t pbl_addr; -}; - -struct iwch_create_cq_resp_v0 { - struct ibv_create_cq_resp ibv_resp; - uint64_t physaddr; - uint32_t cqid; - uint32_t size_log2; -}; - -struct iwch_create_cq_resp_v1 { - struct ibv_create_cq_resp ibv_resp; - uint64_t physaddr; - uint32_t cqid; - uint32_t size_log2; - uint32_t memsize; - uint32_t reserved; /* for proper alignment */ -}; - -struct iwch_create_qp { - struct ibv_create_qp ibv_cmd; -}; - -struct iwch_create_qp_resp { - struct ibv_create_qp_resp ibv_resp; - uint64_t physaddr; - uint64_t doorbell; - uint32_t qpid; - uint32_t size_log2; - uint32_t sq_size_log2; - uint32_t rq_size_log2; -}; -#endif /* IWCH_ABI_H */ diff --git a/usr/rdma-core/providers/cxgb3/iwch.c b/usr/rdma-core/providers/cxgb3/iwch.c deleted file mode 100644 index 3cc1d4c18..000000000 --- a/usr/rdma-core/providers/cxgb3/iwch.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "iwch.h" -#include "iwch-abi.h" - -#define PCI_VENDOR_ID_CHELSIO 0x1425 -#define PCI_DEVICE_ID_CHELSIO_PE9000_2C 0x0020 -#define PCI_DEVICE_ID_CHELSIO_T302E 0x0021 -#define PCI_DEVICE_ID_CHELSIO_T310E 0x0022 -#define PCI_DEVICE_ID_CHELSIO_T320X 0x0023 -#define PCI_DEVICE_ID_CHELSIO_T302X 0x0024 -#define PCI_DEVICE_ID_CHELSIO_T320E 0x0025 -#define PCI_DEVICE_ID_CHELSIO_T310X 0x0026 -#define PCI_DEVICE_ID_CHELSIO_T3B10 0x0030 -#define PCI_DEVICE_ID_CHELSIO_T3B20 0x0031 -#define PCI_DEVICE_ID_CHELSIO_T3B02 0x0032 -#define PCI_DEVICE_ID_CHELSIO_T3C20 0x0035 -#define PCI_DEVICE_ID_CHELSIO_S320E 0x0036 - -#define HCA(v, d, t) \ - VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, PCI_DEVICE_ID_CHELSIO_##d, \ - (void *)(CHELSIO_##t)) -static const struct verbs_match_ent hca_table[] = { - HCA(CHELSIO, PE9000_2C, T3B), - HCA(CHELSIO, T302E, T3A), - HCA(CHELSIO, T302X, T3A), - HCA(CHELSIO, T310E, T3A), - HCA(CHELSIO, T310X, T3A), - HCA(CHELSIO, T320E, T3A), - HCA(CHELSIO, T320X, T3A), - HCA(CHELSIO, T3B10, T3B), - HCA(CHELSIO, T3B20, T3B), - HCA(CHELSIO, T3B02, T3B), - HCA(CHELSIO, T3C20, T3B), - HCA(CHELSIO, S320E, T3B), -}; - -static struct ibv_context_ops iwch_ctx_ops = { - .query_device = iwch_query_device, - .query_port = iwch_query_port, - .alloc_pd = iwch_alloc_pd, - .dealloc_pd = iwch_free_pd, - .reg_mr = iwch_reg_mr, - .dereg_mr = iwch_dereg_mr, - .create_cq = iwch_create_cq, - .resize_cq = iwch_resize_cq, - .destroy_cq = iwch_destroy_cq, - .create_srq = iwch_create_srq, - .modify_srq = iwch_modify_srq, - .destroy_srq = iwch_destroy_srq, - .create_qp = iwch_create_qp, - .modify_qp = iwch_modify_qp, - .destroy_qp = iwch_destroy_qp, - .query_qp = iwch_query_qp, - .create_ah = iwch_create_ah, - .destroy_ah = iwch_destroy_ah, - .attach_mcast = iwch_attach_mcast, - .detach_mcast = iwch_detach_mcast, - .post_srq_recv = iwch_post_srq_recv, - .req_notify_cq = iwch_arm_cq, -}; - -unsigned long iwch_page_size; -unsigned long iwch_page_shift; -unsigned long iwch_page_mask; - -static struct ibv_context *iwch_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - struct iwch_context *context; - struct ibv_get_context cmd; - struct iwch_alloc_ucontext_resp resp; - struct iwch_device *rhp = to_iwch_dev(ibdev); - - context = malloc(sizeof *context); - if (!context) - return NULL; - - memset(context, 0, sizeof *context); - context->ibv_ctx.cmd_fd = cmd_fd; - - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) - goto err_free; - - context->ibv_ctx.device = ibdev; - context->ibv_ctx.ops = iwch_ctx_ops; - - switch (rhp->hca_type) { - case CHELSIO_T3B: - PDBG("%s T3B device\n", __FUNCTION__); - context->ibv_ctx.ops.async_event = t3b_async_event; - context->ibv_ctx.ops.post_send = t3b_post_send; - context->ibv_ctx.ops.post_recv = t3b_post_recv; - context->ibv_ctx.ops.poll_cq = t3b_poll_cq; - break; - case CHELSIO_T3A: - PDBG("%s T3A device\n", __FUNCTION__); - context->ibv_ctx.ops.async_event = NULL; - context->ibv_ctx.ops.post_send = t3a_post_send; - context->ibv_ctx.ops.post_recv = t3a_post_recv; - context->ibv_ctx.ops.poll_cq = t3a_poll_cq; - break; - default: - PDBG("%s unknown hca type %d\n", __FUNCTION__, rhp->hca_type); - goto err_free; - break; - } - - return &context->ibv_ctx; - -err_free: - free(context); - return NULL; -} - -static void iwch_free_context(struct ibv_context *ibctx) -{ - struct iwch_context *context = to_iwch_ctx(ibctx); - - free(context); -} - -static void iwch_uninit_device(struct verbs_device *verbs_device) -{ - struct iwch_device *dev = to_iwch_dev(&verbs_device->device); - - free(dev); -} - -static bool iwch_device_match(struct verbs_sysfs_dev *sysfs_dev) -{ - char value[32], *cp; - unsigned int fw_maj, fw_min; - - /* Rely on the core code to match PCI devices */ - if (!sysfs_dev->match) - return false; - - /* - * Verify that the firmware major number matches. Major number - * mismatches are fatal. Minor number mismatches are tolerated. - */ - if (ibv_read_sysfs_file(sysfs_dev->ibdev_path, "fw_ver", value, - sizeof(value)) < 0) - return false; - - cp = strtok(value+1, "."); - sscanf(cp, "%i", &fw_maj); - cp = strtok(NULL, "."); - sscanf(cp, "%i", &fw_min); - - if (fw_maj < FW_MAJ) { - fprintf(stderr, "libcxgb3: Fatal firmware version mismatch. " - "Firmware major number is %u and libcxgb3 needs %u.\n", - fw_maj, FW_MAJ); - fflush(stderr); - return false; - } - - DBGLOG("libcxgb3"); - - if ((signed int)fw_min < FW_MIN) { - PDBG("libcxgb3: non-fatal firmware version mismatch. " - "Firmware minor number is %u and libcxgb3 needs %u.\n", - fw_min, FW_MIN); - fflush(stderr); - } - - return true; -} - -static struct verbs_device *iwch_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct iwch_device *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - pthread_spin_init(&dev->lock, PTHREAD_PROCESS_PRIVATE); - dev->hca_type = (uintptr_t)sysfs_dev->match->driver_data; - dev->abi_version = sysfs_dev->abi_ver; - - iwch_page_size = sysconf(_SC_PAGESIZE); - iwch_page_shift = long_log2(iwch_page_size); - iwch_page_mask = iwch_page_size - 1; - - dev->mmid2ptr = calloc(T3_MAX_NUM_STAG, sizeof(void *)); - if (!dev->mmid2ptr) { - goto err1; - } - dev->qpid2ptr = calloc(T3_MAX_NUM_QP, sizeof(void *)); - if (!dev->qpid2ptr) { - goto err2; - } - dev->cqid2ptr = calloc(T3_MAX_NUM_CQ, sizeof(void *)); - if (!dev->cqid2ptr) - goto err3; - - return &dev->ibv_dev; - -err3: - free(dev->qpid2ptr); -err2: - free(dev->mmid2ptr); -err1: - free(dev); - return NULL; -} - -static const struct verbs_device_ops iwch_dev_ops = { - .name = "cxgb3", - .match_min_abi_version = 0, - .match_max_abi_version = ABI_VERS, - .match_table = hca_table, - .match_device = iwch_device_match, - .alloc_device = iwch_device_alloc, - .uninit_device = iwch_uninit_device, - .alloc_context = iwch_alloc_context, - .free_context = iwch_free_context, -}; -PROVIDER_DRIVER(iwch_dev_ops); diff --git a/usr/rdma-core/providers/cxgb3/iwch.h b/usr/rdma-core/providers/cxgb3/iwch.h deleted file mode 100644 index ba6e610cb..000000000 --- a/usr/rdma-core/providers/cxgb3/iwch.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef IWCH_H -#define IWCH_H - -#include -#include -#include - -#include -#include - -#include "cxio_wr.h" - -enum iwch_hca_type { - CHELSIO_T3A = 0, - CHELSIO_T3B = 1, -}; - -struct iwch_mr; - -#define ABI_VERS 1 - -struct iwch_device { - struct verbs_device ibv_dev; - enum iwch_hca_type hca_type; - struct iwch_mr **mmid2ptr; - struct iwch_qp **qpid2ptr; - struct iwch_cq **cqid2ptr; - pthread_spinlock_t lock; - int abi_version; -}; - -static inline int t3b_device(struct iwch_device *dev) -{ - return (dev->hca_type == CHELSIO_T3B); -} - -static inline int t3a_device(struct iwch_device *dev) -{ - return (dev->hca_type == CHELSIO_T3A); -} - -struct iwch_context { - struct ibv_context ibv_ctx; -}; - -struct iwch_pd { - struct ibv_pd ibv_pd; -}; - -struct iwch_mr { - struct ibv_mr ibv_mr; - uint64_t va_fbo; - uint32_t page_size; - uint32_t pbl_addr; - uint32_t len; -}; - -struct iwch_cq { - struct ibv_cq ibv_cq; - struct iwch_device *rhp; - struct t3_cq cq; - pthread_spinlock_t lock; -}; - -struct iwch_qp { - struct ibv_qp ibv_qp; - struct iwch_device *rhp; - struct t3_wq wq; - pthread_spinlock_t lock; - int sq_sig_all; -}; - -#define to_iwch_xxx(xxx, type) \ - ((struct iwch_##type *) \ - ((void *) ib##xxx - offsetof(struct iwch_##type, ibv_##xxx))) - -static inline struct iwch_device *to_iwch_dev(struct ibv_device *ibdev) -{ - return to_iwch_xxx(dev, device); -} - -static inline struct iwch_context *to_iwch_ctx(struct ibv_context *ibctx) -{ - return to_iwch_xxx(ctx, context); -} - -static inline struct iwch_pd *to_iwch_pd(struct ibv_pd *ibpd) -{ - return to_iwch_xxx(pd, pd); -} - -static inline struct iwch_cq *to_iwch_cq(struct ibv_cq *ibcq) -{ - return to_iwch_xxx(cq, cq); -} - -static inline struct iwch_qp *to_iwch_qp(struct ibv_qp *ibqp) -{ - return to_iwch_xxx(qp, qp); -} - -static inline struct iwch_mr *to_iwch_mr(struct ibv_mr *ibmr) -{ - return to_iwch_xxx(mr, mr); -} - -static inline unsigned long long_log2(unsigned long x) -{ - unsigned long r = 0; - for (x >>= 1; x > 0; x >>= 1) - r++; - return r; -} - -extern int iwch_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); -extern int iwch_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -extern struct ibv_pd *iwch_alloc_pd(struct ibv_context *context); -extern int iwch_free_pd(struct ibv_pd *pd); - -extern struct ibv_mr *iwch_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); -extern int iwch_dereg_mr(struct ibv_mr *mr); - -struct ibv_cq *iwch_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); -extern int iwch_resize_cq(struct ibv_cq *cq, int cqe); -extern int iwch_destroy_cq(struct ibv_cq *cq); -extern int t3a_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -extern int t3b_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -extern int iwch_arm_cq(struct ibv_cq *cq, int solicited); -extern void iwch_cq_event(struct ibv_cq *cq); -extern void iwch_init_cq_buf(struct iwch_cq *cq, int nent); - -extern struct ibv_srq *iwch_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); -extern int iwch_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int mask); -extern int iwch_destroy_srq(struct ibv_srq *srq); -extern int iwch_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -extern struct ibv_qp *iwch_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr); -extern int iwch_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); -extern int iwch_destroy_qp(struct ibv_qp *qp); -extern int iwch_query_qp(struct ibv_qp *qp, - struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); -extern void iwch_flush_qp(struct iwch_qp *qhp); -extern void iwch_flush_qps(struct iwch_device *dev); -extern int t3a_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -extern int t3b_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -extern int t3a_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -extern int t3b_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -extern struct ibv_ah *iwch_create_ah(struct ibv_pd *pd, - struct ibv_ah_attr *ah_attr); -extern int iwch_destroy_ah(struct ibv_ah *ah); -extern int iwch_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, - uint16_t lid); -extern int iwch_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, - uint16_t lid); -extern void t3b_async_event(struct ibv_async_event *event); -#ifdef DEBUG -#include -#define DBGLOG(s) openlog(s, LOG_NDELAY|LOG_PID, LOG_LOCAL7) -#define PDBG(fmt, args...) do {syslog(LOG_DEBUG, fmt, ##args);} while (0) -#else -#define DBGLOG(s) -#define PDBG(fmt, args...) do {} while (0) -#endif - -#define FW_MAJ 5 -#define FW_MIN 0 - -#endif /* IWCH_H */ diff --git a/usr/rdma-core/providers/cxgb3/qp.c b/usr/rdma-core/providers/cxgb3/qp.c deleted file mode 100644 index 4a1e7397c..000000000 --- a/usr/rdma-core/providers/cxgb3/qp.c +++ /dev/null @@ -1,560 +0,0 @@ -/* - * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -#include -#include -#include - -#include "iwch.h" -#include - -#define ROUNDUP8(a) (((a) + 7) & ~7) - -static inline int iwch_build_rdma_send(union t3_wr *wqe, struct ibv_send_wr *wr, - uint8_t *flit_cnt) -{ - int i; - - if (wr->num_sge > T3_MAX_SGE) - return -1; - if (wr->send_flags & IBV_SEND_SOLICITED) - wqe->send.rdmaop = T3_SEND_WITH_SE; - else - wqe->send.rdmaop = T3_SEND; - wqe->send.rem_stag = 0; - wqe->send.reserved = 0; - if ((wr->send_flags & IBV_SEND_INLINE) || wr->num_sge == 0) { - uint8_t *datap; - - wqe->send.plen = 0; - datap = (uint8_t *)&wqe->send.sgl[0]; - wqe->send.num_sgle = 0; /* indicates in-line data */ - for (i = 0; i < wr->num_sge; i++) { - if ((wqe->send.plen + wr->sg_list[i].length) > - T3_MAX_INLINE) - return -1; - wqe->send.plen += wr->sg_list[i].length; - memcpy(datap, - (void *)(unsigned long)wr->sg_list[i].addr, - wr->sg_list[i].length); - datap += wr->sg_list[i].length; - } - *flit_cnt = 4 + (ROUNDUP8(wqe->send.plen) >> 3); - wqe->send.plen = htobe32(wqe->send.plen); - } else { - wqe->send.plen = 0; - for (i = 0; i < wr->num_sge; i++) { - if ((wqe->send.plen + wr->sg_list[i].length) < - wqe->send.plen) { - return -1; - } - wqe->send.plen += wr->sg_list[i].length; - wqe->send.sgl[i].stag = - htobe32(wr->sg_list[i].lkey); - wqe->send.sgl[i].len = - htobe32(wr->sg_list[i].length); - wqe->send.sgl[i].to = htobe64(wr->sg_list[i].addr); - } - wqe->send.plen = htobe32(wqe->send.plen); - wqe->send.num_sgle = htobe32(wr->num_sge); - *flit_cnt = 4 + ((wr->num_sge) << 1); - } - return 0; -} - -static inline int iwch_build_rdma_write(union t3_wr *wqe, - struct ibv_send_wr *wr, - uint8_t *flit_cnt) -{ - int i; - - if (wr->num_sge > T3_MAX_SGE) - return -1; - wqe->write.rdmaop = T3_RDMA_WRITE; - wqe->write.reserved = 0; - wqe->write.stag_sink = htobe32(wr->wr.rdma.rkey); - wqe->write.to_sink = htobe64(wr->wr.rdma.remote_addr); - - wqe->write.num_sgle = wr->num_sge; - - if ((wr->send_flags & IBV_SEND_INLINE) || wr->num_sge == 0) { - uint8_t *datap; - - wqe->write.plen = 0; - datap = (uint8_t *)&wqe->write.sgl[0]; - wqe->write.num_sgle = 0; /* indicates in-line data */ - for (i = 0; i < wr->num_sge; i++) { - if ((wqe->write.plen + wr->sg_list[i].length) > - T3_MAX_INLINE) - return -1; - wqe->write.plen += wr->sg_list[i].length; - memcpy(datap, - (void *)(unsigned long)wr->sg_list[i].addr, - wr->sg_list[i].length); - datap += wr->sg_list[i].length; - } - *flit_cnt = 5 + (ROUNDUP8(wqe->write.plen) >> 3); - wqe->write.plen = htobe32(wqe->write.plen); - } else { - wqe->write.plen = 0; - for (i = 0; i < wr->num_sge; i++) { - if ((wqe->write.plen + wr->sg_list[i].length) < - wqe->write.plen) { - return -1; - } - wqe->write.plen += wr->sg_list[i].length; - wqe->write.sgl[i].stag = - htobe32(wr->sg_list[i].lkey); - wqe->write.sgl[i].len = - htobe32(wr->sg_list[i].length); - wqe->write.sgl[i].to = - htobe64(wr->sg_list[i].addr); - } - wqe->write.plen = htobe32(wqe->write.plen); - wqe->write.num_sgle = htobe32(wr->num_sge); - *flit_cnt = 5 + ((wr->num_sge) << 1); - } - return 0; -} - -static inline int iwch_build_rdma_read(union t3_wr *wqe, struct ibv_send_wr *wr, - uint8_t *flit_cnt) -{ - if (wr->num_sge > 1) - return -1; - wqe->read.rdmaop = T3_READ_REQ; - wqe->read.reserved = 0; - if (wr->num_sge == 1 && wr->sg_list[0].length > 0) { - wqe->read.rem_stag = htobe32(wr->wr.rdma.rkey); - wqe->read.rem_to = htobe64(wr->wr.rdma.remote_addr); - wqe->read.local_stag = htobe32(wr->sg_list[0].lkey); - wqe->read.local_len = htobe32(wr->sg_list[0].length); - wqe->read.local_to = htobe64(wr->sg_list[0].addr); - } else { - - /* build passable 0B read request */ - wqe->read.rem_stag = 2; - wqe->read.rem_to = 2; - wqe->read.local_stag = 2; - wqe->read.local_len = 0; - wqe->read.local_to = 2; - } - *flit_cnt = sizeof(struct t3_rdma_read_wr) >> 3; - return 0; -} - -int t3b_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - int err = 0; - uint8_t t3_wr_flit_cnt; - enum t3_wr_opcode t3_wr_opcode = 0; - enum t3_wr_flags t3_wr_flags; - struct iwch_qp *qhp; - uint32_t idx; - union t3_wr *wqe; - uint32_t num_wrs; - struct t3_swsq *sqp; - - qhp = to_iwch_qp(ibqp); - pthread_spin_lock(&qhp->lock); - if (t3_wq_in_error(&qhp->wq)) { - iwch_flush_qp(qhp); - pthread_spin_unlock(&qhp->lock); - return -1; - } - num_wrs = Q_FREECNT(qhp->wq.sq_rptr, qhp->wq.sq_wptr, - qhp->wq.sq_size_log2); - if (num_wrs <= 0) { - pthread_spin_unlock(&qhp->lock); - return -1; - } - while (wr) { - if (num_wrs == 0) { - err = -1; - *bad_wr = wr; - break; - } - idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); - wqe = (union t3_wr *) (qhp->wq.queue + idx); - t3_wr_flags = 0; - if (wr->send_flags & IBV_SEND_SOLICITED) - t3_wr_flags |= T3_SOLICITED_EVENT_FLAG; - if (wr->send_flags & IBV_SEND_FENCE) - t3_wr_flags |= T3_READ_FENCE_FLAG; - if ((wr->send_flags & IBV_SEND_SIGNALED) || qhp->sq_sig_all) - t3_wr_flags |= T3_COMPLETION_FLAG; - sqp = qhp->wq.sq + - Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); - switch (wr->opcode) { - case IBV_WR_SEND: - t3_wr_opcode = T3_WR_SEND; - err = iwch_build_rdma_send(wqe, wr, &t3_wr_flit_cnt); - break; - case IBV_WR_RDMA_WRITE: - t3_wr_opcode = T3_WR_WRITE; - err = iwch_build_rdma_write(wqe, wr, &t3_wr_flit_cnt); - break; - case IBV_WR_RDMA_READ: - t3_wr_opcode = T3_WR_READ; - t3_wr_flags = 0; - err = iwch_build_rdma_read(wqe, wr, &t3_wr_flit_cnt); - if (err) - break; - sqp->read_len = wqe->read.local_len; - if (!qhp->wq.oldest_read) - qhp->wq.oldest_read = sqp; - break; - default: - PDBG("%s post of type=%d TBD!\n", __FUNCTION__, - wr->opcode); - err = -1; - } - if (err) { - *bad_wr = wr; - break; - } - wqe->send.wrid.id0.hi = qhp->wq.sq_wptr; - sqp->wr_id = wr->wr_id; - sqp->opcode = wr2opcode(t3_wr_opcode); - sqp->sq_wptr = qhp->wq.sq_wptr; - sqp->complete = 0; - sqp->signaled = (wr->send_flags & IBV_SEND_SIGNALED); - - build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags, - Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), - 0, t3_wr_flit_cnt); - PDBG("%s cookie 0x%" PRIx64 - " wq idx 0x%x swsq idx %ld opcode %d\n", - __FUNCTION__, wr->wr_id, idx, - Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2), - sqp->opcode); - wr = wr->next; - num_wrs--; - ++(qhp->wq.wptr); - ++(qhp->wq.sq_wptr); - } - pthread_spin_unlock(&qhp->lock); - if (t3_wq_db_enabled(&qhp->wq)) - RING_DOORBELL(qhp->wq.doorbell, qhp->wq.qpid); - return err; -} - -int t3a_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - int ret; - struct iwch_qp *qhp = to_iwch_qp(ibqp); - - pthread_spin_lock(&qhp->lock); - ret = ibv_cmd_post_send(ibqp, wr, bad_wr); - pthread_spin_unlock(&qhp->lock); - return ret; -} - -static inline int iwch_build_rdma_recv(struct iwch_device *rhp, - union t3_wr *wqe, - struct ibv_recv_wr *wr) -{ - int i; - if (wr->num_sge > T3_MAX_SGE) - return -1; - - wqe->recv.num_sgle = htobe32(wr->num_sge); - for (i = 0; i < wr->num_sge; i++) { - wqe->recv.sgl[i].stag = htobe32(wr->sg_list[i].lkey); - wqe->recv.sgl[i].len = htobe32(wr->sg_list[i].length); - wqe->recv.sgl[i].to = htobe64(wr->sg_list[i].addr); - } - for (; i < T3_MAX_SGE; i++) { - wqe->recv.sgl[i].stag = 0; - wqe->recv.sgl[i].len = 0; - wqe->recv.sgl[i].to = 0; - } - return 0; -} - -static void insert_recv_cqe(struct t3_wq *wq, struct t3_cq *cq) -{ - struct t3_cqe cqe; - - PDBG("%s wq %p cq %p sw_rptr 0x%x sw_wptr 0x%x\n", __FUNCTION__, - wq, cq, cq->sw_rptr, cq->sw_wptr); - memset(&cqe, 0, sizeof(cqe)); - cqe.header = V_CQE_STATUS(TPT_ERR_SWFLUSH) | - V_CQE_OPCODE(T3_SEND) | - V_CQE_TYPE(0) | - V_CQE_SWCQE(1) | - V_CQE_QPID(wq->qpid) | - V_CQE_GENBIT(Q_GENBIT(cq->sw_wptr, cq->size_log2)); - cqe.header = htobe32(cqe.header); - *(cq->sw_queue + Q_PTR2IDX(cq->sw_wptr, cq->size_log2)) = cqe; - cq->sw_wptr++; -} - -static void flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count) -{ - uint32_t ptr; - - /* flush RQ */ - PDBG("%s rq_rptr 0x%x rq_wptr 0x%x skip count %u\n", __FUNCTION__, - wq->rq_rptr, wq->rq_wptr, count); - ptr = wq->rq_rptr + count; - while (ptr++ != wq->rq_wptr) { - insert_recv_cqe(wq, cq); - } -} - -static void insert_sq_cqe(struct t3_wq *wq, struct t3_cq *cq, - struct t3_swsq *sqp) -{ - struct t3_cqe cqe; - - PDBG("%s wq %p cq %p sw_rptr 0x%x sw_wptr 0x%x\n", __FUNCTION__, - wq, cq, cq->sw_rptr, cq->sw_wptr); - memset(&cqe, 0, sizeof(cqe)); - cqe.header = V_CQE_STATUS(TPT_ERR_SWFLUSH) | - V_CQE_OPCODE(sqp->opcode) | - V_CQE_TYPE(1) | - V_CQE_SWCQE(1) | - V_CQE_QPID(wq->qpid) | - V_CQE_GENBIT(Q_GENBIT(cq->sw_wptr, cq->size_log2)); - cqe.header = htobe32(cqe.header); - CQE_WRID_SQ_WPTR(cqe) = sqp->sq_wptr; - - *(cq->sw_queue + Q_PTR2IDX(cq->sw_wptr, cq->size_log2)) = cqe; - cq->sw_wptr++; -} - -static void flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count) -{ - uint32_t ptr; - struct t3_swsq *sqp; - - ptr = wq->sq_rptr + count; - sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2); - while (ptr != wq->sq_wptr) { - insert_sq_cqe(wq, cq, sqp); - ptr++; - sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2); - } -} - -/* - * Move all CQEs from the HWCQ into the SWCQ. - */ -static void flush_hw_cq(struct t3_cq *cq) -{ - struct t3_cqe *cqe, *swcqe; - - PDBG("%s cq %p cqid 0x%x\n", __FUNCTION__, cq, cq->cqid); - cqe = cxio_next_hw_cqe(cq); - while (cqe) { - PDBG("%s flushing hwcq rptr 0x%x to swcq wptr 0x%x\n", - __FUNCTION__, cq->rptr, cq->sw_wptr); - swcqe = cq->sw_queue + Q_PTR2IDX(cq->sw_wptr, cq->size_log2); - *swcqe = *cqe; - swcqe->header |= htobe32(V_CQE_SWCQE(1)); - cq->sw_wptr++; - cq->rptr++; - cqe = cxio_next_hw_cqe(cq); - } -} - -static void count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count) -{ - struct t3_cqe *cqe; - uint32_t ptr; - - *count = 0; - ptr = cq->sw_rptr; - while (!Q_EMPTY(ptr, cq->sw_wptr)) { - cqe = cq->sw_queue + (Q_PTR2IDX(ptr, cq->size_log2)); - if ((SQ_TYPE(*cqe) || - (CQE_OPCODE(*cqe) == T3_READ_RESP && CQE_WRID_STAG(*cqe) != 1)) && - (CQE_QPID(*cqe) == wq->qpid)) - (*count)++; - ptr++; - } - PDBG("%s cq %p count %d\n", __FUNCTION__, cq, *count); -} - -static void count_rcqes(struct t3_cq *cq, struct t3_wq *wq, int *count) -{ - struct t3_cqe *cqe; - uint32_t ptr; - - *count = 0; - ptr = cq->sw_rptr; - while (!Q_EMPTY(ptr, cq->sw_wptr)) { - cqe = cq->sw_queue + (Q_PTR2IDX(ptr, cq->size_log2)); - if (RQ_TYPE(*cqe) && (CQE_OPCODE(*cqe) != T3_READ_RESP) && - (CQE_QPID(*cqe) == wq->qpid)) - (*count)++; - ptr++; - } - PDBG("%s cq %p count %d\n", __FUNCTION__, cq, *count); -} - -/* - * Assumes qhp lock is held. - */ -void iwch_flush_qp(struct iwch_qp *qhp) -{ - struct iwch_cq *rchp, *schp; - int count; - - if (qhp->wq.flushed) - return; - - rchp = qhp->rhp->cqid2ptr[to_iwch_cq(qhp->ibv_qp.recv_cq)->cq.cqid]; - schp = qhp->rhp->cqid2ptr[to_iwch_cq(qhp->ibv_qp.send_cq)->cq.cqid]; - - PDBG("%s qhp %p rchp %p schp %p\n", __FUNCTION__, qhp, rchp, schp); - qhp->wq.flushed = 1; - -#ifdef notyet - /* take a ref on the qhp since we must release the lock */ - atomic_inc(&qhp->refcnt); -#endif - pthread_spin_unlock(&qhp->lock); - - /* locking heirarchy: cq lock first, then qp lock. */ - pthread_spin_lock(&rchp->lock); - pthread_spin_lock(&qhp->lock); - flush_hw_cq(&rchp->cq); - count_rcqes(&rchp->cq, &qhp->wq, &count); - flush_rq(&qhp->wq, &rchp->cq, count); - pthread_spin_unlock(&qhp->lock); - pthread_spin_unlock(&rchp->lock); - - /* locking heirarchy: cq lock first, then qp lock. */ - pthread_spin_lock(&schp->lock); - pthread_spin_lock(&qhp->lock); - flush_hw_cq(&schp->cq); - count_scqes(&schp->cq, &qhp->wq, &count); - flush_sq(&qhp->wq, &schp->cq, count); - pthread_spin_unlock(&qhp->lock); - pthread_spin_unlock(&schp->lock); - -#ifdef notyet - /* deref */ - if (atomic_dec_and_test(&qhp->refcnt)) - wake_up(&qhp->wait); -#endif - pthread_spin_lock(&qhp->lock); -} - -void iwch_flush_qps(struct iwch_device *dev) -{ - int i; - - pthread_spin_lock(&dev->lock); - for (i=0; i < T3_MAX_NUM_QP; i++) { - struct iwch_qp *qhp = dev->qpid2ptr[i]; - if (qhp) { - if (!qhp->wq.flushed && t3_wq_in_error(&qhp->wq)) { - pthread_spin_lock(&qhp->lock); - iwch_flush_qp(qhp); - pthread_spin_unlock(&qhp->lock); - } - } - } - pthread_spin_unlock(&dev->lock); - -} - -int t3b_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - int err = 0; - struct iwch_qp *qhp; - uint32_t idx; - union t3_wr *wqe; - uint32_t num_wrs; - - qhp = to_iwch_qp(ibqp); - pthread_spin_lock(&qhp->lock); - if (t3_wq_in_error(&qhp->wq)) { - iwch_flush_qp(qhp); - pthread_spin_unlock(&qhp->lock); - return -1; - } - num_wrs = Q_FREECNT(qhp->wq.rq_rptr, qhp->wq.rq_wptr, - qhp->wq.rq_size_log2) - 1; - if (!wr) { - pthread_spin_unlock(&qhp->lock); - return -1; - } - while (wr) { - idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); - wqe = (union t3_wr *) (qhp->wq.queue + idx); - if (num_wrs) - err = iwch_build_rdma_recv(qhp->rhp, wqe, wr); - else - err = -1; - if (err) { - *bad_wr = wr; - break; - } - qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, qhp->wq.rq_size_log2)] = - wr->wr_id; - build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG, - Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), - 0, sizeof(struct t3_receive_wr) >> 3); - PDBG("%s cookie 0x%" PRIx64 - " idx 0x%x rq_wptr 0x%x rw_rptr 0x%x " - "wqe %p \n", __FUNCTION__, wr->wr_id, idx, - qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe); - ++(qhp->wq.rq_wptr); - ++(qhp->wq.wptr); - wr = wr->next; - num_wrs--; - } - pthread_spin_unlock(&qhp->lock); - if (t3_wq_db_enabled(&qhp->wq)) - RING_DOORBELL(qhp->wq.doorbell, qhp->wq.qpid); - return err; -} - -int t3a_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - int ret; - struct iwch_qp *qhp = to_iwch_qp(ibqp); - - pthread_spin_lock(&qhp->lock); - ret = ibv_cmd_post_recv(ibqp, wr, bad_wr); - pthread_spin_unlock(&qhp->lock); - return ret; -} diff --git a/usr/rdma-core/providers/cxgb3/verbs.c b/usr/rdma-core/providers/cxgb3/verbs.c deleted file mode 100644 index 17a88fa1b..000000000 --- a/usr/rdma-core/providers/cxgb3/verbs.c +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "iwch.h" -#include "iwch-abi.h" - -int iwch_query_device(struct ibv_context *context, struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, - sizeof cmd); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%d", major, minor, sub_minor); - - return 0; -} - -int iwch_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); -} - -struct ibv_pd *iwch_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct iwch_alloc_pd_resp resp; - struct iwch_pd *pd; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(pd); - return NULL; - } - - return &pd->ibv_pd; -} - -int iwch_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - free(pd); - return 0; -} - -static struct ibv_mr *__iwch_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, uint64_t hca_va, - int access) -{ - struct iwch_mr *mhp; - struct ibv_reg_mr cmd; - struct iwch_reg_mr_resp resp; - struct iwch_device *dev = to_iwch_dev(pd->context->device); - - mhp = malloc(sizeof *mhp); - if (!mhp) - return NULL; - - if (ibv_cmd_reg_mr(pd, addr, length, hca_va, - access, &mhp->ibv_mr, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(mhp); - return NULL; - } - - mhp->va_fbo = hca_va; - mhp->page_size = iwch_page_shift - 12; - mhp->pbl_addr = resp.pbl_addr; - mhp->len = length; - - PDBG("%s stag 0x%x va_fbo 0x%" PRIx64 - " page_size %d pbl_addr 0x%x len %d\n", - __FUNCTION__, mhp->ibv_mr.rkey, mhp->va_fbo, - mhp->page_size, mhp->pbl_addr, mhp->len); - - pthread_spin_lock(&dev->lock); - dev->mmid2ptr[t3_mmid(mhp->ibv_mr.lkey)] = mhp; - pthread_spin_unlock(&dev->lock); - - return &mhp->ibv_mr; -} - -struct ibv_mr *iwch_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - PDBG("%s addr %p length %ld\n", __FUNCTION__, addr, length); - return __iwch_reg_mr(pd, addr, length, (uintptr_t) addr, access); -} - -int iwch_dereg_mr(struct ibv_mr *mr) -{ - int ret; - struct iwch_device *dev = to_iwch_dev(mr->pd->context->device); - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - pthread_spin_lock(&dev->lock); - dev->mmid2ptr[t3_mmid(mr->lkey)] = NULL; - pthread_spin_unlock(&dev->lock); - - free(to_iwch_mr(mr)); - - return 0; -} - -struct ibv_cq *iwch_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, int comp_vector) -{ - struct iwch_create_cq cmd; - struct iwch_create_cq_resp_v1 resp; - struct iwch_cq *chp; - struct iwch_device *dev = to_iwch_dev(context->device); - int ret; - - chp = calloc(1, sizeof *chp); - if (!chp) { - return NULL; - } - - cmd.user_rptr_addr = (uint64_t)(unsigned long)&chp->cq.rptr; - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &chp->ibv_cq, &cmd.ibv_cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) - goto err1; - - pthread_spin_init(&chp->lock, PTHREAD_PROCESS_PRIVATE); - chp->rhp = dev; - chp->cq.cqid = resp.cqid; - chp->cq.size_log2 = resp.size_log2; - if (dev->abi_version == 0) - chp->cq.memsize = PAGE_ALIGN((1UL << chp->cq.size_log2) * - sizeof(struct t3_cqe)); - else - chp->cq.memsize = resp.memsize; - chp->cq.queue = mmap(NULL, t3_cq_memsize(&chp->cq), - PROT_READ|PROT_WRITE, MAP_SHARED, context->cmd_fd, - resp.physaddr); - if (chp->cq.queue == MAP_FAILED) - goto err2; - - chp->cq.sw_queue = calloc(t3_cq_depth(&chp->cq), sizeof(struct t3_cqe)); - if (!chp->cq.sw_queue) - goto err3; - - PDBG("%s cqid 0x%x physaddr %" PRIx64 " va %p memsize %d\n", - __FUNCTION__, chp->cq.cqid, resp.physaddr, chp->cq.queue, - t3_cq_memsize(&chp->cq)); - - pthread_spin_lock(&dev->lock); - dev->cqid2ptr[chp->cq.cqid] = chp; - pthread_spin_unlock(&dev->lock); - - return &chp->ibv_cq; -err3: - munmap(chp->cq.queue, t3_cq_memsize(&chp->cq)); -err2: - (void)ibv_cmd_destroy_cq(&chp->ibv_cq); -err1: - free(chp); - return NULL; -} - -int iwch_resize_cq(struct ibv_cq *ibcq, int cqe) -{ -#ifdef notyet - int ret; - struct ibv_resize_cq cmd; - struct iwch_cq *chp = to_iwch_cq(ibcq); - - pthread_spin_lock(&chp->lock); - ret = ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd); - /* remap and realloc swcq here */ - pthread_spin_unlock(&chp->lock); - return ret; -#else - return -ENOSYS; -#endif -} - -int iwch_destroy_cq(struct ibv_cq *ibcq) -{ - int ret; - struct iwch_cq *chp = to_iwch_cq(ibcq); - void *cqva = chp->cq.queue; - unsigned size = t3_cq_memsize(&chp->cq); - struct iwch_device *dev = to_iwch_dev(ibcq->context->device); - - munmap(cqva, size); - ret = ibv_cmd_destroy_cq(ibcq); - if (ret) { - return ret; - } - - pthread_spin_lock(&dev->lock); - dev->cqid2ptr[chp->cq.cqid] = NULL; - pthread_spin_unlock(&dev->lock); - - free(chp->cq.sw_queue); - free(chp); - return 0; -} - -struct ibv_srq *iwch_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - return NULL; -} - -int iwch_modify_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr, - int attr_mask) -{ - return -ENOSYS; -} - -int iwch_destroy_srq(struct ibv_srq *srq) -{ - return -ENOSYS; -} - -int iwch_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - return -ENOSYS; -} - -struct ibv_qp *iwch_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) -{ - struct iwch_create_qp cmd; - struct iwch_create_qp_resp resp; - struct iwch_qp *qhp; - struct iwch_device *dev = to_iwch_dev(pd->context->device); - int ret; - void *dbva; - - PDBG("%s enter qp\n", __FUNCTION__); - qhp = calloc(1, sizeof *qhp); - if (!qhp) - goto err1; - - ret = ibv_cmd_create_qp(pd, &qhp->ibv_qp, attr, &cmd.ibv_cmd, - sizeof cmd, &resp.ibv_resp, sizeof resp); - if (ret) - goto err2; - - PDBG("%s qpid 0x%x physaddr %" PRIx64 " doorbell %" PRIx64 - " size %d sq_size %d rq_size %d\n", - __FUNCTION__, resp.qpid, resp.physaddr, resp.doorbell, - 1 << resp.size_log2, 1 << resp.sq_size_log2, - 1 << resp.rq_size_log2); - - qhp->rhp = dev; - qhp->wq.qpid = resp.qpid; - qhp->wq.size_log2 = resp.size_log2; - qhp->wq.sq_size_log2 = resp.sq_size_log2; - qhp->wq.rq_size_log2 = resp.rq_size_log2; - pthread_spin_init(&qhp->lock, PTHREAD_PROCESS_PRIVATE); - dbva = mmap(NULL, iwch_page_size, PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.doorbell & ~(iwch_page_mask)); - if (dbva == MAP_FAILED) - goto err3; - - qhp->wq.doorbell = dbva + (resp.doorbell & (iwch_page_mask)); - qhp->wq.queue = mmap(NULL, t3_wq_memsize(&qhp->wq), - PROT_READ|PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.physaddr); - if (qhp->wq.queue == MAP_FAILED) - goto err4; - - qhp->wq.rq = calloc(t3_rq_depth(&qhp->wq), sizeof (uint64_t)); - if (!qhp->wq.rq) - goto err5; - - qhp->wq.sq = calloc(t3_sq_depth(&qhp->wq), sizeof (struct t3_swsq)); - if (!qhp->wq.sq) - goto err6; - - PDBG("%s dbva %p wqva %p wq memsize %d\n", __FUNCTION__, - qhp->wq.doorbell, qhp->wq.queue, t3_wq_memsize(&qhp->wq)); - - qhp->sq_sig_all = attr->sq_sig_all; - - pthread_spin_lock(&dev->lock); - dev->qpid2ptr[qhp->wq.qpid] = qhp; - pthread_spin_unlock(&dev->lock); - - return &qhp->ibv_qp; -err6: - free(qhp->wq.rq); -err5: - munmap((void *)qhp->wq.queue, t3_wq_memsize(&qhp->wq)); -err4: - munmap((void *)dbva, iwch_page_size); -err3: - (void)ibv_cmd_destroy_qp(&qhp->ibv_qp); -err2: - free(qhp); -err1: - return NULL; -} - -static void reset_qp(struct iwch_qp *qhp) -{ - PDBG("%s enter qp %p\n", __FUNCTION__, qhp); - qhp->wq.wptr = 0; - qhp->wq.rq_wptr = qhp->wq.rq_rptr = 0; - qhp->wq.sq_wptr = qhp->wq.sq_rptr = 0; - qhp->wq.error = 0; - qhp->wq.oldest_read = NULL; - memset(qhp->wq.queue, 0, t3_wq_memsize(&qhp->wq)); -} - -int iwch_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - struct iwch_qp *qhp = to_iwch_qp(ibqp); - int ret; - - PDBG("%s enter qp %p new state %d\n", __FUNCTION__, ibqp, attr_mask & IBV_QP_STATE ? attr->qp_state : -1); - pthread_spin_lock(&qhp->lock); - if (t3b_device(qhp->rhp) && t3_wq_in_error(&qhp->wq)) - iwch_flush_qp(qhp); - ret = ibv_cmd_modify_qp(ibqp, attr, attr_mask, &cmd, sizeof cmd); - if (!ret && (attr_mask & IBV_QP_STATE) && attr->qp_state == IBV_QPS_RESET) - reset_qp(qhp); - pthread_spin_unlock(&qhp->lock); - return ret; -} - -int iwch_destroy_qp(struct ibv_qp *ibqp) -{ - int ret; - struct iwch_qp *qhp = to_iwch_qp(ibqp); - struct iwch_device *dev = to_iwch_dev(ibqp->context->device); - void *dbva, *wqva; - unsigned wqsize; - - PDBG("%s enter qp %p\n", __FUNCTION__, ibqp); - if (t3b_device(dev)) { - pthread_spin_lock(&qhp->lock); - iwch_flush_qp(qhp); - pthread_spin_unlock(&qhp->lock); - } - - dbva = (void *)((unsigned long)qhp->wq.doorbell & ~(iwch_page_mask)); - wqva = qhp->wq.queue; - wqsize = t3_wq_memsize(&qhp->wq); - - munmap(dbva, iwch_page_size); - munmap(wqva, wqsize); - ret = ibv_cmd_destroy_qp(ibqp); - if (ret) { - return ret; - } - - pthread_spin_lock(&dev->lock); - dev->qpid2ptr[qhp->wq.qpid] = NULL; - pthread_spin_unlock(&dev->lock); - - free(qhp->wq.rq); - free(qhp->wq.sq); - free(qhp); - return 0; -} - -int iwch_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr) -{ - return -ENOSYS; -} - -struct ibv_ah *iwch_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - return NULL; -} - -int iwch_destroy_ah(struct ibv_ah *ah) -{ - return -ENOSYS; -} - -int iwch_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - return -ENOSYS; -} - -int iwch_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - return -ENOSYS; -} - -void t3b_async_event(struct ibv_async_event *event) -{ - PDBG("%s type %d obj %p\n", __FUNCTION__, event->event_type, - event->element.cq); - - switch (event->event_type) { - case IBV_EVENT_CQ_ERR: - break; - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_PATH_MIG_ERR: { - struct iwch_qp *qhp = to_iwch_qp(event->element.qp); - pthread_spin_lock(&qhp->lock); - iwch_flush_qp(qhp); - pthread_spin_unlock(&qhp->lock); - break; - } - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_QP_LAST_WQE_REACHED: - default: - break; - } -} diff --git a/usr/rdma-core/providers/cxgb4/CMakeLists.txt b/usr/rdma-core/providers/cxgb4/CMakeLists.txt deleted file mode 100644 index a9b654601..000000000 --- a/usr/rdma-core/providers/cxgb4/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NO_STRICT_ALIASING_FLAGS}") - -rdma_provider(cxgb4 - cq.c - dev.c - qp.c - verbs.c -) diff --git a/usr/rdma-core/providers/cxgb4/cq.c b/usr/rdma-core/providers/cxgb4/cq.c deleted file mode 100644 index be6cf2f2d..000000000 --- a/usr/rdma-core/providers/cxgb4/cq.c +++ /dev/null @@ -1,751 +0,0 @@ -/* - * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -#include -#include -#include -#include -#include -#include -#include "libcxgb4.h" -#include "cxgb4-abi.h" - -static void insert_recv_cqe(struct t4_wq *wq, struct t4_cq *cq) -{ - struct t4_cqe cqe; - - PDBG("%s wq %p cq %p sw_cidx %u sw_pidx %u\n", __func__, - wq, cq, cq->sw_cidx, cq->sw_pidx); - memset(&cqe, 0, sizeof(cqe)); - cqe.header = htobe32(V_CQE_STATUS(T4_ERR_SWFLUSH) | - V_CQE_OPCODE(FW_RI_SEND) | - V_CQE_TYPE(0) | - V_CQE_SWCQE(1) | - V_CQE_QPID(wq->sq.qid)); - cqe.bits_type_ts = htobe64(V_CQE_GENBIT((u64)cq->gen)); - cq->sw_queue[cq->sw_pidx] = cqe; - t4_swcq_produce(cq); -} - -int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count) -{ - int flushed = 0; - int in_use = wq->rq.in_use - count; - - BUG_ON(in_use < 0); - PDBG("%s wq %p cq %p rq.in_use %u skip count %u\n", __func__, - wq, cq, wq->rq.in_use, count); - while (in_use--) { - insert_recv_cqe(wq, cq); - flushed++; - } - return flushed; -} - -static void insert_sq_cqe(struct t4_wq *wq, struct t4_cq *cq, - struct t4_swsqe *swcqe) -{ - struct t4_cqe cqe; - - PDBG("%s wq %p cq %p sw_cidx %u sw_pidx %u\n", __func__, - wq, cq, cq->sw_cidx, cq->sw_pidx); - memset(&cqe, 0, sizeof(cqe)); - cqe.header = htobe32(V_CQE_STATUS(T4_ERR_SWFLUSH) | - V_CQE_OPCODE(swcqe->opcode) | - V_CQE_TYPE(1) | - V_CQE_SWCQE(1) | - V_CQE_QPID(wq->sq.qid)); - CQE_WRID_SQ_IDX(&cqe) = swcqe->idx; - cqe.bits_type_ts = htobe64(V_CQE_GENBIT((u64)cq->gen)); - cq->sw_queue[cq->sw_pidx] = cqe; - t4_swcq_produce(cq); -} - -static void advance_oldest_read(struct t4_wq *wq); - -void c4iw_flush_sq(struct c4iw_qp *qhp) -{ - unsigned short flushed = 0; - struct t4_wq *wq = &qhp->wq; - struct c4iw_cq *chp = to_c4iw_cq(qhp->ibv_qp.send_cq); - struct t4_cq *cq = &chp->cq; - int idx; - struct t4_swsqe *swsqe; - - if (wq->sq.flush_cidx == -1) - wq->sq.flush_cidx = wq->sq.cidx; - idx = wq->sq.flush_cidx; - BUG_ON(idx >= wq->sq.size); - while (idx != wq->sq.pidx) { - swsqe = &wq->sq.sw_sq[idx]; - BUG_ON(swsqe->flushed); - swsqe->flushed = 1; - insert_sq_cqe(wq, cq, swsqe); - if (wq->sq.oldest_read == swsqe) { - BUG_ON(swsqe->opcode != FW_RI_READ_REQ); - advance_oldest_read(wq); - } - flushed++; - if (++idx == wq->sq.size) - idx = 0; - } - wq->sq.flush_cidx += flushed; - if (wq->sq.flush_cidx >= wq->sq.size) - wq->sq.flush_cidx -= wq->sq.size; -} - -static void flush_completed_wrs(struct t4_wq *wq, struct t4_cq *cq) -{ - struct t4_swsqe *swsqe; - unsigned short cidx; - - if (wq->sq.flush_cidx == -1) - wq->sq.flush_cidx = wq->sq.cidx; - cidx = wq->sq.flush_cidx; - BUG_ON(cidx >= wq->sq.size); - - while (cidx != wq->sq.pidx) { - swsqe = &wq->sq.sw_sq[cidx]; - if (!swsqe->signaled) { - if (++cidx == wq->sq.size) - cidx = 0; - } else if (swsqe->complete) { - - BUG_ON(swsqe->flushed); - - /* - * Insert this completed cqe into the swcq. - */ - PDBG("%s moving cqe into swcq sq idx %u cq idx %u\n", - __func__, cidx, cq->sw_pidx); - - swsqe->cqe.header |= htobe32(V_CQE_SWCQE(1)); - cq->sw_queue[cq->sw_pidx] = swsqe->cqe; - t4_swcq_produce(cq); - swsqe->flushed = 1; - if (++cidx == wq->sq.size) - cidx = 0; - wq->sq.flush_cidx = cidx; - } else - break; - } -} - -static void create_read_req_cqe(struct t4_wq *wq, struct t4_cqe *hw_cqe, - struct t4_cqe *read_cqe) -{ - read_cqe->u.scqe.cidx = wq->sq.oldest_read->idx; - read_cqe->len = be32toh(wq->sq.oldest_read->read_len); - read_cqe->header = htobe32(V_CQE_QPID(CQE_QPID(hw_cqe)) | - V_CQE_SWCQE(SW_CQE(hw_cqe)) | - V_CQE_OPCODE(FW_RI_READ_REQ) | - V_CQE_TYPE(1)); - read_cqe->bits_type_ts = hw_cqe->bits_type_ts; -} - -static void advance_oldest_read(struct t4_wq *wq) -{ - - u32 rptr = wq->sq.oldest_read - wq->sq.sw_sq + 1; - - if (rptr == wq->sq.size) - rptr = 0; - while (rptr != wq->sq.pidx) { - wq->sq.oldest_read = &wq->sq.sw_sq[rptr]; - - if (wq->sq.oldest_read->opcode == FW_RI_READ_REQ) - return; - if (++rptr == wq->sq.size) - rptr = 0; - } - wq->sq.oldest_read = NULL; -} - -/* - * Move all CQEs from the HWCQ into the SWCQ. - * Deal with out-of-order and/or completions that complete - * prior unsignalled WRs. - */ -void c4iw_flush_hw_cq(struct c4iw_cq *chp) -{ - struct t4_cqe *hw_cqe, *swcqe, read_cqe; - struct c4iw_qp *qhp; - struct t4_swsqe *swsqe; - int ret; - - PDBG("%s cqid 0x%x\n", __func__, chp->cq.cqid); - ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); - - /* - * This logic is similar to poll_cq(), but not quite the same - * unfortunately. Need to move pertinent HW CQEs to the SW CQ but - * also do any translation magic that poll_cq() normally does. - */ - while (!ret) { - qhp = get_qhp(chp->rhp, CQE_QPID(hw_cqe)); - - /* - * drop CQEs with no associated QP - */ - if (qhp == NULL) - goto next_cqe; - - if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) - goto next_cqe; - - if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) { - - /* - * If we have reached here because of async - * event or other error, and have egress error - * then drop - */ - if (CQE_TYPE(hw_cqe) == 1) { - syslog(LOG_CRIT, "%s: got egress error in \ - read-response, dropping!\n", __func__); - goto next_cqe; - } - - /* - * drop peer2peer RTR reads. - */ - if (CQE_WRID_STAG(hw_cqe) == 1) - goto next_cqe; - - /* - * Eat completions for unsignaled read WRs. - */ - if (!qhp->wq.sq.oldest_read->signaled) { - advance_oldest_read(&qhp->wq); - goto next_cqe; - } - - /* - * Don't write to the HWCQ, create a new read req CQE - * in local memory and move it into the swcq. - */ - create_read_req_cqe(&qhp->wq, hw_cqe, &read_cqe); - hw_cqe = &read_cqe; - advance_oldest_read(&qhp->wq); - } - - /* if its a SQ completion, then do the magic to move all the - * unsignaled and now in-order completions into the swcq. - */ - if (SQ_TYPE(hw_cqe)) { - int idx = CQE_WRID_SQ_IDX(hw_cqe); - - BUG_ON(idx >= qhp->wq.sq.size); - swsqe = &qhp->wq.sq.sw_sq[idx]; - swsqe->cqe = *hw_cqe; - swsqe->complete = 1; - flush_completed_wrs(&qhp->wq, &chp->cq); - } else { - swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx]; - *swcqe = *hw_cqe; - swcqe->header |= htobe32(V_CQE_SWCQE(1)); - t4_swcq_produce(&chp->cq); - } -next_cqe: - t4_hwcq_consume(&chp->cq); - ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); - } -} - -static int cqe_completes_wr(struct t4_cqe *cqe, struct t4_wq *wq) -{ - if (CQE_OPCODE(cqe) == FW_RI_TERMINATE) - return 0; - - if ((CQE_OPCODE(cqe) == FW_RI_RDMA_WRITE) && RQ_TYPE(cqe)) - return 0; - - if ((CQE_OPCODE(cqe) == FW_RI_READ_RESP) && SQ_TYPE(cqe)) - return 0; - - if (CQE_SEND_OPCODE(cqe) && RQ_TYPE(cqe) && t4_rq_empty(wq)) - return 0; - return 1; -} - -void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count) -{ - struct t4_cqe *cqe; - u32 ptr; - - *count = 0; - ptr = cq->sw_cidx; - BUG_ON(ptr >= cq->size); - while (ptr != cq->sw_pidx) { - cqe = &cq->sw_queue[ptr]; - if (RQ_TYPE(cqe) && (CQE_OPCODE(cqe) != FW_RI_READ_RESP) && - (CQE_QPID(cqe) == wq->sq.qid) && cqe_completes_wr(cqe, wq)) - (*count)++; - if (++ptr == cq->size) - ptr = 0; - } - PDBG("%s cq %p count %d\n", __func__, cq, *count); -} - -static void dump_cqe(void *arg) -{ - u64 *p = arg; - syslog(LOG_NOTICE, "cxgb4 err cqe %016llx %016llx %016llx %016llx\n", - (long long)be64toh(p[0]), - (long long)be64toh(p[1]), - (long long)be64toh(p[2]), - (long long)be64toh(p[3])); -} - -/* - * poll_cq - * - * Caller must: - * check the validity of the first CQE, - * supply the wq assicated with the qpid. - * - * credit: cq credit to return to sge. - * cqe_flushed: 1 iff the CQE is flushed. - * cqe: copy of the polled CQE. - * - * return value: - * 0 CQE returned ok. - * -EAGAIN CQE skipped, try again. - * -EOVERFLOW CQ overflow detected. - */ -static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe, - u8 *cqe_flushed, u64 *cookie, u32 *credit) -{ - int ret = 0; - struct t4_cqe *hw_cqe, read_cqe; - - *cqe_flushed = 0; - *credit = 0; - - ret = t4_next_cqe(cq, &hw_cqe); - if (ret) - return ret; - - PDBG("%s CQE OVF %u qpid 0x%0x genbit %u type %u status 0x%0x" - " opcode 0x%0x len 0x%0x wrid_hi_stag 0x%x wrid_low_msn 0x%x\n", - __func__, CQE_OVFBIT(hw_cqe), CQE_QPID(hw_cqe), - CQE_GENBIT(hw_cqe), CQE_TYPE(hw_cqe), CQE_STATUS(hw_cqe), - CQE_OPCODE(hw_cqe), CQE_LEN(hw_cqe), CQE_WRID_HI(hw_cqe), - CQE_WRID_LOW(hw_cqe)); - - /* - * skip cqe's not affiliated with a QP. - */ - if (wq == NULL) { - ret = -EAGAIN; - goto skip_cqe; - } - - /* - * Gotta tweak READ completions: - * 1) the cqe doesn't contain the sq_wptr from the wr. - * 2) opcode not reflected from the wr. - * 3) read_len not reflected from the wr. - * 4) T4 HW (for now) inserts target read response failures which - * need to be skipped. - */ - if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) { - - /* - * If we have reached here because of async - * event or other error, and have egress error - * then drop - */ - if (CQE_TYPE(hw_cqe) == 1) { - syslog(LOG_CRIT, "%s: got egress error in \ - read-response, dropping!\n", __func__); - if (CQE_STATUS(hw_cqe)) - t4_set_wq_in_error(wq); - ret = -EAGAIN; - goto skip_cqe; - } - - /* - * If this is an unsolicited read response, then the read - * was generated by the kernel driver as part of peer-2-peer - * connection setup, or a target read response failure. - * So skip the completion. - */ - if (CQE_WRID_STAG(hw_cqe) == 1) { - if (CQE_STATUS(hw_cqe)) - t4_set_wq_in_error(wq); - ret = -EAGAIN; - goto skip_cqe; - } - - /* - * Eat completions for unsignaled read WRs. - */ - if (!wq->sq.oldest_read->signaled) { - advance_oldest_read(wq); - ret = -EAGAIN; - goto skip_cqe; - } - - /* - * Don't write to the HWCQ, so create a new read req CQE - * in local memory. - */ - create_read_req_cqe(wq, hw_cqe, &read_cqe); - hw_cqe = &read_cqe; - advance_oldest_read(wq); - } - - if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) { - ret = -EAGAIN; - goto skip_cqe; - } - - if (CQE_STATUS(hw_cqe) || t4_wq_in_error(wq)) { - *cqe_flushed = (CQE_STATUS(hw_cqe) == T4_ERR_SWFLUSH); - wq->error = 1; - - if (!*cqe_flushed && CQE_STATUS(hw_cqe)) - dump_cqe(hw_cqe); - - BUG_ON((*cqe_flushed == 0) && !SW_CQE(hw_cqe)); - goto proc_cqe; - } - - /* - * RECV completion. - */ - if (RQ_TYPE(hw_cqe)) { - - /* - * HW only validates 4 bits of MSN. So we must validate that - * the MSN in the SEND is the next expected MSN. If its not, - * then we complete this with T4_ERR_MSN and mark the wq in - * error. - */ - - if (t4_rq_empty(wq)) { - t4_set_wq_in_error(wq); - ret = -EAGAIN; - goto skip_cqe; - } - if (unlikely((CQE_WRID_MSN(hw_cqe) != (wq->rq.msn)))) { - t4_set_wq_in_error(wq); - hw_cqe->header |= htobe32(V_CQE_STATUS(T4_ERR_MSN)); - goto proc_cqe; - } - goto proc_cqe; - } - - /* - * If we get here its a send completion. - * - * Handle out of order completion. These get stuffed - * in the SW SQ. Then the SW SQ is walked to move any - * now in-order completions into the SW CQ. This handles - * 2 cases: - * 1) reaping unsignaled WRs when the first subsequent - * signaled WR is completed. - * 2) out of order read completions. - */ - if (!SW_CQE(hw_cqe) && (CQE_WRID_SQ_IDX(hw_cqe) != wq->sq.cidx)) { - struct t4_swsqe *swsqe; - int idx = CQE_WRID_SQ_IDX(hw_cqe); - - PDBG("%s out of order completion going in sw_sq at idx %u\n", - __func__, idx); - BUG_ON(idx >= wq->sq.size); - swsqe = &wq->sq.sw_sq[idx]; - swsqe->cqe = *hw_cqe; - swsqe->complete = 1; - ret = -EAGAIN; - goto flush_wq; - } - -proc_cqe: - *cqe = *hw_cqe; - - /* - * Reap the associated WR(s) that are freed up with this - * completion. - */ - if (SQ_TYPE(hw_cqe)) { - int idx = CQE_WRID_SQ_IDX(hw_cqe); - BUG_ON(idx >= wq->sq.size); - - /* - * Account for any unsignaled completions completed by - * this signaled completion. In this case, cidx points - * to the first unsignaled one, and idx points to the - * signaled one. So adjust in_use based on this delta. - * if this is not completing any unsigned wrs, then the - * delta will be 0. Handle wrapping also! - */ - if (idx < wq->sq.cidx) - wq->sq.in_use -= wq->sq.size + idx - wq->sq.cidx; - else - wq->sq.in_use -= idx - wq->sq.cidx; - BUG_ON(wq->sq.in_use <= 0 || wq->sq.in_use >= wq->sq.size); - - wq->sq.cidx = (u16)idx; - PDBG("%s completing sq idx %u\n", __func__, wq->sq.cidx); - *cookie = wq->sq.sw_sq[wq->sq.cidx].wr_id; - t4_sq_consume(wq); - } else { - PDBG("%s completing rq idx %u\n", __func__, wq->rq.cidx); - BUG_ON(wq->rq.cidx >= wq->rq.size); - *cookie = wq->rq.sw_rq[wq->rq.cidx].wr_id; - BUG_ON(t4_rq_empty(wq)); - t4_rq_consume(wq); - goto skip_cqe; - } - -flush_wq: - /* - * Flush any completed cqes that are now in-order. - */ - flush_completed_wrs(wq, cq); - -skip_cqe: - if (SW_CQE(hw_cqe)) { - PDBG("%s cq %p cqid 0x%x skip sw cqe cidx %u\n", - __func__, cq, cq->cqid, cq->sw_cidx); - t4_swcq_consume(cq); - } else { - PDBG("%s cq %p cqid 0x%x skip hw cqe cidx %u\n", - __func__, cq, cq->cqid, cq->cidx); - t4_hwcq_consume(cq); - } - return ret; -} - -/* - * Get one cq entry from c4iw and map it to openib. - * - * Returns: - * 0 cqe returned - * -ENODATA EMPTY; - * -EAGAIN caller must try again - * any other -errno fatal error - */ -static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ibv_wc *wc) -{ - struct c4iw_qp *qhp = NULL; - struct t4_cqe uninitialized_var(cqe), *rd_cqe; - struct t4_wq *wq; - u32 credit = 0; - u8 cqe_flushed; - u64 cookie = 0; - int ret; - - ret = t4_next_cqe(&chp->cq, &rd_cqe); - - if (ret) { -#ifdef STALL_DETECTION - if (ret == -ENODATA && stall_to && !chp->dumped) { - struct timeval t; - - gettimeofday(&t, NULL); - if ((t.tv_sec - chp->time.tv_sec) > stall_to) { - dump_state(); - chp->dumped = 1; - } - } -#endif - return ret; - } - -#ifdef STALL_DETECTION - gettimeofday(&chp->time, NULL); -#endif - - qhp = get_qhp(chp->rhp, CQE_QPID(rd_cqe)); - if (!qhp) - wq = NULL; - else { - pthread_spin_lock(&qhp->lock); - wq = &(qhp->wq); - } - ret = poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit); - if (ret) - goto out; - - INC_STAT(cqe); - wc->wr_id = cookie; - wc->qp_num = qhp->wq.sq.qid; - wc->vendor_err = CQE_STATUS(&cqe); - wc->wc_flags = 0; - - PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x " - "lo 0x%x cookie 0x%llx\n", __func__, - CQE_QPID(&cqe), CQE_TYPE(&cqe), - CQE_OPCODE(&cqe), CQE_STATUS(&cqe), CQE_WRID_HI(&cqe), - CQE_WRID_LOW(&cqe), (unsigned long long)cookie); - - if (CQE_TYPE(&cqe) == 0) { - if (!CQE_STATUS(&cqe)) - wc->byte_len = CQE_LEN(&cqe); - else - wc->byte_len = 0; - wc->opcode = IBV_WC_RECV; - } else { - switch (CQE_OPCODE(&cqe)) { - case FW_RI_RDMA_WRITE: - wc->opcode = IBV_WC_RDMA_WRITE; - break; - case FW_RI_READ_REQ: - wc->opcode = IBV_WC_RDMA_READ; - wc->byte_len = CQE_LEN(&cqe); - break; - case FW_RI_SEND: - case FW_RI_SEND_WITH_SE: - case FW_RI_SEND_WITH_INV: - case FW_RI_SEND_WITH_SE_INV: - wc->opcode = IBV_WC_SEND; - break; - case FW_RI_BIND_MW: - wc->opcode = IBV_WC_BIND_MW; - break; - default: - PDBG("Unexpected opcode %d " - "in the CQE received for QPID=0x%0x\n", - CQE_OPCODE(&cqe), CQE_QPID(&cqe)); - ret = -EINVAL; - goto out; - } - } - - if (cqe_flushed) - wc->status = IBV_WC_WR_FLUSH_ERR; - else { - - switch (CQE_STATUS(&cqe)) { - case T4_ERR_SUCCESS: - wc->status = IBV_WC_SUCCESS; - break; - case T4_ERR_STAG: - wc->status = IBV_WC_LOC_ACCESS_ERR; - break; - case T4_ERR_PDID: - wc->status = IBV_WC_LOC_PROT_ERR; - break; - case T4_ERR_QPID: - case T4_ERR_ACCESS: - wc->status = IBV_WC_LOC_ACCESS_ERR; - break; - case T4_ERR_WRAP: - wc->status = IBV_WC_GENERAL_ERR; - break; - case T4_ERR_BOUND: - wc->status = IBV_WC_LOC_LEN_ERR; - break; - case T4_ERR_INVALIDATE_SHARED_MR: - case T4_ERR_INVALIDATE_MR_WITH_MW_BOUND: - wc->status = IBV_WC_MW_BIND_ERR; - break; - case T4_ERR_CRC: - case T4_ERR_MARKER: - case T4_ERR_PDU_LEN_ERR: - case T4_ERR_OUT_OF_RQE: - case T4_ERR_DDP_VERSION: - case T4_ERR_RDMA_VERSION: - case T4_ERR_DDP_QUEUE_NUM: - case T4_ERR_MSN: - case T4_ERR_TBIT: - case T4_ERR_MO: - case T4_ERR_MSN_RANGE: - case T4_ERR_IRD_OVERFLOW: - case T4_ERR_OPCODE: - case T4_ERR_INTERNAL_ERR: - wc->status = IBV_WC_FATAL_ERR; - break; - case T4_ERR_SWFLUSH: - wc->status = IBV_WC_WR_FLUSH_ERR; - break; - default: - PDBG("Unexpected cqe_status 0x%x for QPID=0x%0x\n", - CQE_STATUS(&cqe), CQE_QPID(&cqe)); - wc->status = IBV_WC_FATAL_ERR; - } - } - if (wc->status && wc->status != IBV_WC_WR_FLUSH_ERR) - syslog(LOG_NOTICE, "cxgb4 app err cqid %u qpid %u " - "type %u opcode %u status 0x%x\n", - chp->cq.cqid, CQE_QPID(&cqe), CQE_TYPE(&cqe), - CQE_OPCODE(&cqe), CQE_STATUS(&cqe)); -out: - if (wq) - pthread_spin_unlock(&qhp->lock); - return ret; -} - -int c4iw_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc) -{ - struct c4iw_cq *chp; - int npolled; - int err = 0; - - chp = to_c4iw_cq(ibcq); - - if (t4_cq_in_error(&chp->cq)) { - t4_reset_cq_in_error(&chp->cq); - c4iw_flush_qps(chp->rhp); - } - - if (!num_entries) - return t4_cq_notempty(&chp->cq); - - pthread_spin_lock(&chp->lock); - for (npolled = 0; npolled < num_entries; ++npolled) { - do { - err = c4iw_poll_cq_one(chp, wc + npolled); - } while (err == -EAGAIN); - if (err) - break; - } - pthread_spin_unlock(&chp->lock); - return !err || err == -ENODATA ? npolled : err; -} - -int c4iw_arm_cq(struct ibv_cq *ibcq, int solicited) -{ - struct c4iw_cq *chp; - int ret; - - INC_STAT(arm); - chp = to_c4iw_cq(ibcq); - pthread_spin_lock(&chp->lock); - ret = t4_arm_cq(&chp->cq, solicited); - pthread_spin_unlock(&chp->lock); - return ret; -} diff --git a/usr/rdma-core/providers/cxgb4/cxgb4-abi.h b/usr/rdma-core/providers/cxgb4/cxgb4-abi.h deleted file mode 100644 index 91e68d552..000000000 --- a/usr/rdma-core/providers/cxgb4/cxgb4-abi.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef IWCH_ABI_H -#define IWCH_ABI_H - -#include -#include - -struct c4iw_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - __u64 status_page_key; - __u32 status_page_size; - __u32 reserved; -}; - -struct c4iw_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - uint32_t pdid; -}; - -struct c4iw_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u64 key; - __u64 gts_key; - __u64 memsize; - __u32 cqid; - __u32 size; - __u32 qid_mask; - __u32 reserved; -}; - -enum { - C4IW_QPF_ONCHIP = (1<<0), -}; - -struct c4iw_create_qp_resp_v0 { - struct ibv_create_qp_resp ibv_resp; - __u64 sq_key; - __u64 rq_key; - __u64 sq_db_gts_key; - __u64 rq_db_gts_key; - __u64 sq_memsize; - __u64 rq_memsize; - __u32 sqid; - __u32 rqid; - __u32 sq_size; - __u32 rq_size; - __u32 qid_mask; -}; - -struct c4iw_create_qp_resp { - struct ibv_create_qp_resp ibv_resp; - __u64 ma_sync_key; - __u64 sq_key; - __u64 rq_key; - __u64 sq_db_gts_key; - __u64 rq_db_gts_key; - __u64 sq_memsize; - __u64 rq_memsize; - __u32 sqid; - __u32 rqid; - __u32 sq_size; - __u32 rq_size; - __u32 qid_mask; - __u32 flags; -}; -#endif /* IWCH_ABI_H */ diff --git a/usr/rdma-core/providers/cxgb4/dev.c b/usr/rdma-core/providers/cxgb4/dev.c deleted file mode 100644 index b6775da8a..000000000 --- a/usr/rdma-core/providers/cxgb4/dev.c +++ /dev/null @@ -1,510 +0,0 @@ -/* - * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libcxgb4.h" -#include "cxgb4-abi.h" - -#define PCI_VENDOR_ID_CHELSIO 0x1425 - -/* - * Macros needed to support the PCI Device ID Table ... - */ -#define CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN \ - static const struct verbs_match_ent hca_table[] = { - -#define CH_PCI_DEVICE_ID_FUNCTION \ - 0x4 - -#define CH_PCI_ID_TABLE_ENTRY(__DeviceID) \ - VERBS_PCI_MATCH(PCI_VENDOR_ID_CHELSIO, __DeviceID, NULL) - -#define CH_PCI_DEVICE_ID_TABLE_DEFINE_END \ - {} } - -#include "t4_chip_type.h" -#include "t4_pci_id_tbl.h" - -unsigned long c4iw_page_size; -unsigned long c4iw_page_shift; -unsigned long c4iw_page_mask; -int ma_wr; -int t5_en_wc = 1; - -static LIST_HEAD(devices); - -static struct ibv_context_ops c4iw_ctx_ops = { - .query_device = c4iw_query_device, - .query_port = c4iw_query_port, - .alloc_pd = c4iw_alloc_pd, - .dealloc_pd = c4iw_free_pd, - .reg_mr = c4iw_reg_mr, - .dereg_mr = c4iw_dereg_mr, - .create_cq = c4iw_create_cq, - .resize_cq = c4iw_resize_cq, - .destroy_cq = c4iw_destroy_cq, - .create_srq = c4iw_create_srq, - .modify_srq = c4iw_modify_srq, - .destroy_srq = c4iw_destroy_srq, - .create_qp = c4iw_create_qp, - .modify_qp = c4iw_modify_qp, - .destroy_qp = c4iw_destroy_qp, - .query_qp = c4iw_query_qp, - .create_ah = c4iw_create_ah, - .destroy_ah = c4iw_destroy_ah, - .attach_mcast = c4iw_attach_mcast, - .detach_mcast = c4iw_detach_mcast, - .post_srq_recv = c4iw_post_srq_recv, - .req_notify_cq = c4iw_arm_cq, -}; - -static struct ibv_context *c4iw_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - struct c4iw_context *context; - struct ibv_get_context cmd; - struct c4iw_alloc_ucontext_resp resp; - struct c4iw_dev *rhp = to_c4iw_dev(ibdev); - struct ibv_query_device qcmd; - uint64_t raw_fw_ver; - struct ibv_device_attr attr; - - context = malloc(sizeof *context); - if (!context) - return NULL; - - memset(context, 0, sizeof *context); - context->ibv_ctx.cmd_fd = cmd_fd; - - resp.status_page_size = 0; - resp.reserved = 0; - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) - goto err_free; - - if (resp.reserved) - PDBG("%s c4iw_alloc_ucontext_resp reserved field modified by kernel\n", - __FUNCTION__); - - context->status_page_size = resp.status_page_size; - if (resp.status_page_size) { - context->status_page = mmap(NULL, resp.status_page_size, - PROT_READ, MAP_SHARED, cmd_fd, - resp.status_page_key); - if (context->status_page == MAP_FAILED) - goto err_free; - } - - context->ibv_ctx.device = ibdev; - context->ibv_ctx.ops = c4iw_ctx_ops; - - switch (rhp->chip_version) { - case CHELSIO_T6: - PDBG("%s T6/T5/T4 device\n", __FUNCTION__); - case CHELSIO_T5: - PDBG("%s T5/T4 device\n", __FUNCTION__); - case CHELSIO_T4: - PDBG("%s T4 device\n", __FUNCTION__); - context->ibv_ctx.ops.async_event = c4iw_async_event; - context->ibv_ctx.ops.post_send = c4iw_post_send; - context->ibv_ctx.ops.post_recv = c4iw_post_receive; - context->ibv_ctx.ops.poll_cq = c4iw_poll_cq; - context->ibv_ctx.ops.req_notify_cq = c4iw_arm_cq; - break; - default: - PDBG("%s unknown hca type %d\n", __FUNCTION__, - rhp->chip_version); - goto err_unmap; - break; - } - - if (!rhp->mmid2ptr) { - int ret; - - ret = ibv_cmd_query_device(&context->ibv_ctx, &attr, &raw_fw_ver, &qcmd, - sizeof qcmd); - if (ret) - goto err_unmap; - rhp->max_mr = attr.max_mr; - rhp->mmid2ptr = calloc(attr.max_mr, sizeof(void *)); - if (!rhp->mmid2ptr) { - goto err_unmap; - } - if (rhp->abi_version < 3) { - fprintf(stderr, "Warning: iw_cxgb4 driver is of older version" - " than libcxgb4:: %d\n", rhp->abi_version); - rhp->max_qp = T4_QID_BASE + attr.max_qp; - } else { - rhp->max_qp = context->status_page->qp_start + - context->status_page->qp_size; - } - rhp->qpid2ptr = calloc(rhp->max_qp, sizeof(void *)); - if (!rhp->qpid2ptr) { - goto err_unmap; - } - if (rhp->abi_version < 3) - rhp->max_cq = T4_QID_BASE + attr.max_cq; - else - rhp->max_cq = context->status_page->cq_start + - context->status_page->cq_size; - rhp->cqid2ptr = calloc(rhp->max_cq, sizeof(void *)); - if (!rhp->cqid2ptr) - goto err_unmap; - } - - return &context->ibv_ctx; - -err_unmap: - munmap(context->status_page, context->status_page_size); -err_free: - if (rhp->cqid2ptr) - free(rhp->cqid2ptr); - if (rhp->qpid2ptr) - free(rhp->cqid2ptr); - if (rhp->mmid2ptr) - free(rhp->cqid2ptr); - free(context); - return NULL; -} - -static void c4iw_free_context(struct ibv_context *ibctx) -{ - struct c4iw_context *context = to_c4iw_context(ibctx); - - if (context->status_page_size) - munmap(context->status_page, context->status_page_size); - free(context); -} - -static void c4iw_uninit_device(struct verbs_device *verbs_device) -{ - struct c4iw_dev *dev = to_c4iw_dev(&verbs_device->device); - - free(dev); -} - -#ifdef STALL_DETECTION - -int stall_to; - -static void dump_cq(struct c4iw_cq *chp) -{ - int i; - - fprintf(stderr, - "CQ: %p id %u queue %p cidx 0x%08x sw_queue %p sw_cidx %d sw_pidx %d sw_in_use %d depth %u error %u gen %d " - "cidx_inc %d bits_type_ts %016" PRIx64 " notempty %d\n", chp, - chp->cq.cqid, chp->cq.queue, chp->cq.cidx, - chp->cq.sw_queue, chp->cq.sw_cidx, chp->cq.sw_pidx, chp->cq.sw_in_use, - chp->cq.size, chp->cq.error, chp->cq.gen, chp->cq.cidx_inc, be64toh(chp->cq.bits_type_ts), - t4_cq_notempty(&chp->cq)); - - for (i=0; i < chp->cq.size; i++) { - u64 *p = (u64 *)(chp->cq.queue + i); - - fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64, i, be64toh(p[0]), be64toh(p[1])); - if (i == chp->cq.cidx) - fprintf(stderr, " <-- cidx\n"); - else - fprintf(stderr, "\n"); - p+= 2; - fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64toh(p[0]), be64toh(p[1])); - p+= 2; - fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64toh(p[0]), be64toh(p[1])); - p+= 2; - fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64toh(p[0]), be64toh(p[1])); - p+= 2; - } -} - -static void dump_qp(struct c4iw_qp *qhp) -{ - int i; - int j; - struct t4_swsqe *swsqe; - struct t4_swrqe *swrqe; - u16 cidx, pidx; - u64 *p; - - fprintf(stderr, - "QP: %p id %u error %d flushed %d qid_mask 0x%x\n" - " SQ: id %u queue %p sw_queue %p cidx %u pidx %u in_use %u wq_pidx %u depth %u flags 0x%x flush_cidx %d\n" - " RQ: id %u queue %p sw_queue %p cidx %u pidx %u in_use %u depth %u\n", - qhp, - qhp->wq.sq.qid, - qhp->wq.error, - qhp->wq.flushed, - qhp->wq.qid_mask, - qhp->wq.sq.qid, - qhp->wq.sq.queue, - qhp->wq.sq.sw_sq, - qhp->wq.sq.cidx, - qhp->wq.sq.pidx, - qhp->wq.sq.in_use, - qhp->wq.sq.wq_pidx, - qhp->wq.sq.size, - qhp->wq.sq.flags, - qhp->wq.sq.flush_cidx, - qhp->wq.rq.qid, - qhp->wq.rq.queue, - qhp->wq.rq.sw_rq, - qhp->wq.rq.cidx, - qhp->wq.rq.pidx, - qhp->wq.rq.in_use, - qhp->wq.rq.size); - cidx = qhp->wq.sq.cidx; - pidx = qhp->wq.sq.pidx; - if (cidx != pidx) - fprintf(stderr, "SQ: \n"); - while (cidx != pidx) { - swsqe = &qhp->wq.sq.sw_sq[cidx]; - fprintf(stderr, "%04u: wr_id %016" PRIx64 - " sq_wptr %08x read_len %u opcode 0x%x " - "complete %u signaled %u cqe %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n", - cidx, - swsqe->wr_id, - swsqe->idx, - swsqe->read_len, - swsqe->opcode, - swsqe->complete, - swsqe->signaled, - htobe64(((uint64_t *)&swsqe->cqe)[0]), - htobe64(((uint64_t *)&swsqe->cqe)[1]), - htobe64(((uint64_t *)&swsqe->cqe)[2]), - htobe64(((uint64_t *)&swsqe->cqe)[3])); - if (++cidx == qhp->wq.sq.size) - cidx = 0; - } - - fprintf(stderr, "SQ WQ: \n"); - p = (u64 *)qhp->wq.sq.queue; - for (i=0; i < qhp->wq.sq.size * T4_SQ_NUM_SLOTS; i++) { - for (j=0; j < T4_EQ_ENTRY_SIZE / 16; j++) { - fprintf(stderr, "%04u %016" PRIx64 " %016" PRIx64 " ", - i, be64toh(p[0]), be64toh(p[1])); - if (j == 0 && i == qhp->wq.sq.wq_pidx) - fprintf(stderr, " <-- pidx"); - fprintf(stderr, "\n"); - p += 2; - } - } - cidx = qhp->wq.rq.cidx; - pidx = qhp->wq.rq.pidx; - if (cidx != pidx) - fprintf(stderr, "RQ: \n"); - while (cidx != pidx) { - swrqe = &qhp->wq.rq.sw_rq[cidx]; - fprintf(stderr, "%04u: wr_id %016" PRIx64 "\n", - cidx, - swrqe->wr_id ); - if (++cidx == qhp->wq.rq.size) - cidx = 0; - } - - fprintf(stderr, "RQ WQ: \n"); - p = (u64 *)qhp->wq.rq.queue; - for (i=0; i < qhp->wq.rq.size * T4_RQ_NUM_SLOTS; i++) { - for (j=0; j < T4_EQ_ENTRY_SIZE / 16; j++) { - fprintf(stderr, "%04u %016" PRIx64 " %016" PRIx64 " ", - i, be64toh(p[0]), be64toh(p[1])); - if (j == 0 && i == qhp->wq.rq.pidx) - fprintf(stderr, " <-- pidx"); - if (j == 0 && i == qhp->wq.rq.cidx) - fprintf(stderr, " <-- cidx"); - fprintf(stderr, "\n"); - p+=2; - } - } -} - -void dump_state(void) -{ - struct c4iw_dev *dev; - int i; - - fprintf(stderr, "STALL DETECTED:\n"); - list_for_each(&devices, dev, list) { - //pthread_spin_lock(&dev->lock); - fprintf(stderr, "Device %s\n", dev->ibv_dev.name); - for (i=0; i < dev->max_cq; i++) { - if (dev->cqid2ptr[i]) { - struct c4iw_cq *chp = dev->cqid2ptr[i]; - //pthread_spin_lock(&chp->lock); - dump_cq(chp); - //pthread_spin_unlock(&chp->lock); - } - } - for (i=0; i < dev->max_qp; i++) { - if (dev->qpid2ptr[i]) { - struct c4iw_qp *qhp = dev->qpid2ptr[i]; - //pthread_spin_lock(&qhp->lock); - dump_qp(qhp); - //pthread_spin_unlock(&qhp->lock); - } - } - //pthread_spin_unlock(&dev->lock); - } - fprintf(stderr, "DUMP COMPLETE:\n"); - fflush(stderr); -} -#endif /* end of STALL_DETECTION */ - -/* - * c4iw_abi_version is used to store ABI for iw_cxgb4 so the user mode library - * can know if the driver supports the kernel mode db ringing. - */ -int c4iw_abi_version = 1; - -static bool c4iw_device_match(struct verbs_sysfs_dev *sysfs_dev) -{ - char value[32], *cp; - unsigned int fw_maj, fw_min; - - /* Rely on the core code to match PCI devices */ - if (!sysfs_dev->match) - return false; - - /* - * Verify that the firmware major number matches. Major number - * mismatches are fatal. Minor number mismatches are tolerated. - */ - if (ibv_read_sysfs_file(sysfs_dev->ibdev_path, "fw_ver", value, - sizeof(value)) < 0) - return false; - - cp = strtok(value+1, "."); - sscanf(cp, "%i", &fw_maj); - cp = strtok(NULL, "."); - sscanf(cp, "%i", &fw_min); - - if ((signed int)fw_maj < FW_MAJ) { - fprintf(stderr, "libcxgb4: Fatal firmware version mismatch. " - "Firmware major number is %u and libcxgb4 needs %u.\n", - fw_maj, FW_MAJ); - fflush(stderr); - return false; - } - - DBGLOG("libcxgb4"); - - if ((signed int)fw_min < FW_MIN) { - PDBG("libcxgb4: non-fatal firmware version mismatch. " - "Firmware minor number is %u and libcxgb4 needs %u.\n", - fw_min, FW_MIN); - fflush(stderr); - } - return true; -} - -static struct verbs_device *c4iw_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct c4iw_dev *dev; - - c4iw_page_size = sysconf(_SC_PAGESIZE); - c4iw_page_shift = long_log2(c4iw_page_size); - c4iw_page_mask = ~(c4iw_page_size - 1); - - dev = calloc(1, sizeof *dev); - if (!dev) - return NULL; - - pthread_spin_init(&dev->lock, PTHREAD_PROCESS_PRIVATE); - c4iw_abi_version = sysfs_dev->abi_ver; - dev->chip_version = CHELSIO_CHIP_VERSION(sysfs_dev->match->device >> 8); - dev->abi_version = sysfs_dev->abi_ver; - list_node_init(&dev->list); - - PDBG("%s device claimed\n", __FUNCTION__); - list_add_tail(&devices, &dev->list); -#ifdef STALL_DETECTION -{ - char *c = getenv("CXGB4_STALL_TIMEOUT"); - if (c) { - stall_to = strtol(c, NULL, 0); - if (errno || stall_to < 0) - stall_to = 0; - } -} -#endif -{ - char *c = getenv("CXGB4_MA_WR"); - if (c) { - ma_wr = strtol(c, NULL, 0); - if (ma_wr != 1) - ma_wr = 0; - } -} -{ - char *c = getenv("T5_ENABLE_WC"); - if (c) { - t5_en_wc = strtol(c, NULL, 0); - if (t5_en_wc != 1) - t5_en_wc = 0; - } -} - - return &dev->ibv_dev; -} - -static const struct verbs_device_ops c4iw_dev_ops = { - .name = "cxgb4", - .match_min_abi_version = 0, - .match_max_abi_version = INT_MAX, - .match_table = hca_table, - .match_device = c4iw_device_match, - .alloc_device = c4iw_device_alloc, - .uninit_device = c4iw_uninit_device, - .alloc_context = c4iw_alloc_context, - .free_context = c4iw_free_context, -}; -PROVIDER_DRIVER(c4iw_dev_ops); - -#ifdef STATS -void __attribute__ ((destructor)) cs_fini(void); -void __attribute__ ((destructor)) cs_fini(void) -{ - syslog(LOG_NOTICE, "cxgb4 stats - sends %lu recv %lu read %lu " - "write %lu arm %lu cqe %lu mr %lu qp %lu cq %lu\n", - c4iw_stats.send, c4iw_stats.recv, c4iw_stats.read, - c4iw_stats.write, c4iw_stats.arm, c4iw_stats.cqe, - c4iw_stats.mr, c4iw_stats.qp, c4iw_stats.cq); -} -#endif diff --git a/usr/rdma-core/providers/cxgb4/libcxgb4.h b/usr/rdma-core/providers/cxgb4/libcxgb4.h deleted file mode 100644 index e7d13c5ec..000000000 --- a/usr/rdma-core/providers/cxgb4/libcxgb4.h +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef IWCH_H -#define IWCH_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "t4.h" - -extern unsigned long c4iw_page_size; -extern unsigned long c4iw_page_shift; -extern unsigned long c4iw_page_mask; - -struct c4iw_mr; - -struct c4iw_dev { - struct verbs_device ibv_dev; - unsigned chip_version; - int max_mr; - struct c4iw_mr **mmid2ptr; - int max_qp; - struct c4iw_qp **qpid2ptr; - int max_cq; - struct c4iw_cq **cqid2ptr; - pthread_spinlock_t lock; - struct list_node list; - int abi_version; -}; - -static inline int dev_is_t6(struct c4iw_dev *dev) -{ - return dev->chip_version == CHELSIO_T6; -} - -static inline int dev_is_t5(struct c4iw_dev *dev) -{ - return dev->chip_version == CHELSIO_T5; -} - -static inline int dev_is_t4(struct c4iw_dev *dev) -{ - return dev->chip_version == CHELSIO_T4; -} - -struct c4iw_context { - struct ibv_context ibv_ctx; - struct t4_dev_status_page *status_page; - int status_page_size; -}; - -struct c4iw_pd { - struct ibv_pd ibv_pd; -}; - -struct c4iw_mr { - struct ibv_mr ibv_mr; - uint64_t va_fbo; - uint32_t len; -}; - -static inline u32 c4iw_mmid(u32 stag) -{ - return (stag >> 8); -} - -struct c4iw_cq { - struct ibv_cq ibv_cq; - struct c4iw_dev *rhp; - struct t4_cq cq; - pthread_spinlock_t lock; -#ifdef STALL_DETECTION - struct timeval time; - int dumped; -#endif -}; - -struct c4iw_qp { - struct ibv_qp ibv_qp; - struct c4iw_dev *rhp; - struct t4_wq wq; - pthread_spinlock_t lock; - int sq_sig_all; -}; - -#define to_c4iw_xxx(xxx, type) \ - ((struct c4iw_##type *) \ - ((void *) ib##xxx - offsetof(struct c4iw_##type, ibv_##xxx))) - -static inline struct c4iw_dev *to_c4iw_dev(struct ibv_device *ibdev) -{ - return to_c4iw_xxx(dev, dev); -} - -static inline struct c4iw_context *to_c4iw_context(struct ibv_context *ibctx) -{ - return to_c4iw_xxx(ctx, context); -} - -static inline struct c4iw_pd *to_c4iw_pd(struct ibv_pd *ibpd) -{ - return to_c4iw_xxx(pd, pd); -} - -static inline struct c4iw_cq *to_c4iw_cq(struct ibv_cq *ibcq) -{ - return to_c4iw_xxx(cq, cq); -} - -static inline struct c4iw_qp *to_c4iw_qp(struct ibv_qp *ibqp) -{ - return to_c4iw_xxx(qp, qp); -} - -static inline struct c4iw_mr *to_c4iw_mr(struct ibv_mr *ibmr) -{ - return to_c4iw_xxx(mr, mr); -} - -static inline struct c4iw_qp *get_qhp(struct c4iw_dev *rhp, u32 qid) -{ - return rhp->qpid2ptr[qid]; -} - -static inline struct c4iw_cq *get_chp(struct c4iw_dev *rhp, u32 qid) -{ - return rhp->cqid2ptr[qid]; -} - -static inline unsigned long_log2(unsigned long x) -{ - unsigned r = 0; - for (x >>= 1; x > 0; x >>= 1) - r++; - return r; -} - -int c4iw_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); -int c4iw_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -struct ibv_pd *c4iw_alloc_pd(struct ibv_context *context); -int c4iw_free_pd(struct ibv_pd *pd); - -struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); -int c4iw_dereg_mr(struct ibv_mr *mr); - -struct ibv_cq *c4iw_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); -int c4iw_resize_cq(struct ibv_cq *cq, int cqe); -int c4iw_destroy_cq(struct ibv_cq *cq); -int c4iw_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -int c4iw_arm_cq(struct ibv_cq *cq, int solicited); -void c4iw_cq_event(struct ibv_cq *cq); -void c4iw_init_cq_buf(struct c4iw_cq *cq, int nent); - -struct ibv_srq *c4iw_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); -int c4iw_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int mask); -int c4iw_destroy_srq(struct ibv_srq *srq); -int c4iw_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -struct ibv_qp *c4iw_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr); -int c4iw_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); -int c4iw_destroy_qp(struct ibv_qp *qp); -int c4iw_query_qp(struct ibv_qp *qp, - struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); -void c4iw_flush_qp(struct c4iw_qp *qhp); -void c4iw_flush_qps(struct c4iw_dev *dev); -int c4iw_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -int c4iw_post_receive(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -struct ibv_ah *c4iw_create_ah(struct ibv_pd *pd, - struct ibv_ah_attr *ah_attr); -int c4iw_destroy_ah(struct ibv_ah *ah); -int c4iw_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, - uint16_t lid); -int c4iw_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, - uint16_t lid); -void c4iw_async_event(struct ibv_async_event *event); -void c4iw_flush_hw_cq(struct c4iw_cq *chp); -int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count); -void c4iw_flush_sq(struct c4iw_qp *qhp); -void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count); - -#define FW_MAJ 0 -#define FW_MIN 0 - -static inline unsigned long align(unsigned long val, unsigned long align) -{ - return (val + align - 1) & ~(align - 1); -} - -#ifdef STATS - -#define INC_STAT(a) { c4iw_stats.a++; } - -struct c4iw_stats { - unsigned long send; - unsigned long recv; - unsigned long read; - unsigned long write; - unsigned long arm; - unsigned long cqe; - unsigned long mr; - unsigned long qp; - unsigned long cq; -}; -extern struct c4iw_stats c4iw_stats; -#else -#define INC_STAT(a) -#endif - -#ifdef STALL_DETECTION -void dump_state(void); -extern int stall_to; -#endif - -#endif /* IWCH_H */ diff --git a/usr/rdma-core/providers/cxgb4/qp.c b/usr/rdma-core/providers/cxgb4/qp.c deleted file mode 100644 index af04e3a1f..000000000 --- a/usr/rdma-core/providers/cxgb4/qp.c +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -#include -#include -#include -#include -#include -#include -#include "libcxgb4.h" - -#ifdef STATS -struct c4iw_stats c4iw_stats; -#endif - -static void copy_wr_to_sq(struct t4_wq *wq, union t4_wr *wqe, u8 len16) -{ - u64 *src, *dst; - - src = (u64 *)wqe; - dst = (u64 *)((u8 *)wq->sq.queue + wq->sq.wq_pidx * T4_EQ_ENTRY_SIZE); - if (t4_sq_onchip(wq)) { - len16 = align(len16, 4); - - /* In onchip mode the copy below will be made to WC memory and - * could trigger DMA. In offchip mode the copy below only - * queues the WQE, DMA cannot start until t4_ring_sq_db - * happens */ - mmio_wc_start(); - } - while (len16) { - *dst++ = *src++; - if (dst == (u64 *)&wq->sq.queue[wq->sq.size]) - dst = (u64 *)wq->sq.queue; - *dst++ = *src++; - if (dst == (u64 *)&wq->sq.queue[wq->sq.size]) - dst = (u64 *)wq->sq.queue; - len16--; - - /* NOTE len16 cannot be large enough to write to the - same sq.queue memory twice in this loop */ - } - - if (t4_sq_onchip(wq)) - mmio_flush_writes(); -} - -static void copy_wr_to_rq(struct t4_wq *wq, union t4_recv_wr *wqe, u8 len16) -{ - u64 *src, *dst; - - src = (u64 *)wqe; - dst = (u64 *)((u8 *)wq->rq.queue + wq->rq.wq_pidx * T4_EQ_ENTRY_SIZE); - while (len16) { - *dst++ = *src++; - if (dst >= (u64 *)&wq->rq.queue[wq->rq.size]) - dst = (u64 *)wq->rq.queue; - *dst++ = *src++; - if (dst >= (u64 *)&wq->rq.queue[wq->rq.size]) - dst = (u64 *)wq->rq.queue; - len16--; - } -} - -static int build_immd(struct t4_sq *sq, struct fw_ri_immd *immdp, - struct ibv_send_wr *wr, int max, u32 *plenp) -{ - u8 *dstp, *srcp; - u32 plen = 0; - int i; - int len; - - dstp = (u8 *)immdp->data; - for (i = 0; i < wr->num_sge; i++) { - if ((plen + wr->sg_list[i].length) > max) - return -EMSGSIZE; - srcp = (u8 *)(unsigned long)wr->sg_list[i].addr; - plen += wr->sg_list[i].length; - len = wr->sg_list[i].length; - memcpy(dstp, srcp, len); - dstp += len; - srcp += len; - } - len = ROUND_UP(plen + 8, 16) - (plen + 8); - if (len) - memset(dstp, 0, len); - immdp->op = FW_RI_DATA_IMMD; - immdp->r1 = 0; - immdp->r2 = 0; - immdp->immdlen = htobe32(plen); - *plenp = plen; - return 0; -} - -static int build_isgl(struct fw_ri_isgl *isglp, struct ibv_sge *sg_list, - int num_sge, u32 *plenp) -{ - int i; - u32 plen = 0; - __be64 *flitp = (__be64 *)isglp->sge; - - for (i = 0; i < num_sge; i++) { - if ((plen + sg_list[i].length) < plen) - return -EMSGSIZE; - plen += sg_list[i].length; - *flitp++ = htobe64(((u64)sg_list[i].lkey << 32) | - sg_list[i].length); - *flitp++ = htobe64(sg_list[i].addr); - } - *flitp = 0; - isglp->op = FW_RI_DATA_ISGL; - isglp->r1 = 0; - isglp->nsge = htobe16(num_sge); - isglp->r2 = 0; - if (plenp) - *plenp = plen; - return 0; -} - -static int build_rdma_send(struct t4_sq *sq, union t4_wr *wqe, - struct ibv_send_wr *wr, u8 *len16) -{ - u32 plen; - int size; - int ret; - - if (wr->num_sge > T4_MAX_SEND_SGE) - return -EINVAL; - if (wr->send_flags & IBV_SEND_SOLICITED) - wqe->send.sendop_pkd = htobe32( - FW_RI_SEND_WR_SENDOP_V(FW_RI_SEND_WITH_SE)); - else - wqe->send.sendop_pkd = htobe32( - FW_RI_SEND_WR_SENDOP_V(FW_RI_SEND)); - wqe->send.stag_inv = 0; - wqe->send.r3 = 0; - wqe->send.r4 = 0; - - plen = 0; - if (wr->num_sge) { - if (wr->send_flags & IBV_SEND_INLINE) { - ret = build_immd(sq, wqe->send.u.immd_src, wr, - T4_MAX_SEND_INLINE, &plen); - if (ret) - return ret; - size = sizeof wqe->send + sizeof(struct fw_ri_immd) + - plen; - } else { - ret = build_isgl(wqe->send.u.isgl_src, - wr->sg_list, wr->num_sge, &plen); - if (ret) - return ret; - size = sizeof wqe->send + sizeof(struct fw_ri_isgl) + - wr->num_sge * sizeof (struct fw_ri_sge); - } - } else { - wqe->send.u.immd_src[0].op = FW_RI_DATA_IMMD; - wqe->send.u.immd_src[0].r1 = 0; - wqe->send.u.immd_src[0].r2 = 0; - wqe->send.u.immd_src[0].immdlen = 0; - size = sizeof wqe->send + sizeof(struct fw_ri_immd); - plen = 0; - } - *len16 = DIV_ROUND_UP(size, 16); - wqe->send.plen = htobe32(plen); - return 0; -} - -static int build_rdma_write(struct t4_sq *sq, union t4_wr *wqe, - struct ibv_send_wr *wr, u8 *len16) -{ - u32 plen; - int size; - int ret; - - if (wr->num_sge > T4_MAX_SEND_SGE) - return -EINVAL; - wqe->write.r2 = 0; - wqe->write.stag_sink = htobe32(wr->wr.rdma.rkey); - wqe->write.to_sink = htobe64(wr->wr.rdma.remote_addr); - if (wr->num_sge) { - if (wr->send_flags & IBV_SEND_INLINE) { - ret = build_immd(sq, wqe->write.u.immd_src, wr, - T4_MAX_WRITE_INLINE, &plen); - if (ret) - return ret; - size = sizeof wqe->write + sizeof(struct fw_ri_immd) + - plen; - } else { - ret = build_isgl(wqe->write.u.isgl_src, - wr->sg_list, wr->num_sge, &plen); - if (ret) - return ret; - size = sizeof wqe->write + sizeof(struct fw_ri_isgl) + - wr->num_sge * sizeof (struct fw_ri_sge); - } - } else { - wqe->write.u.immd_src[0].op = FW_RI_DATA_IMMD; - wqe->write.u.immd_src[0].r1 = 0; - wqe->write.u.immd_src[0].r2 = 0; - wqe->write.u.immd_src[0].immdlen = 0; - size = sizeof wqe->write + sizeof(struct fw_ri_immd); - plen = 0; - } - *len16 = DIV_ROUND_UP(size, 16); - wqe->write.plen = htobe32(plen); - return 0; -} - -static int build_rdma_read(union t4_wr *wqe, struct ibv_send_wr *wr, u8 *len16) -{ - if (wr->num_sge > 1) - return -EINVAL; - if (wr->num_sge) { - wqe->read.stag_src = htobe32(wr->wr.rdma.rkey); - wqe->read.to_src_hi = htobe32((u32)(wr->wr.rdma.remote_addr >>32)); - wqe->read.to_src_lo = htobe32((u32)wr->wr.rdma.remote_addr); - wqe->read.stag_sink = htobe32(wr->sg_list[0].lkey); - wqe->read.plen = htobe32(wr->sg_list[0].length); - wqe->read.to_sink_hi = htobe32((u32)(wr->sg_list[0].addr >> 32)); - wqe->read.to_sink_lo = htobe32((u32)(wr->sg_list[0].addr)); - } else { - wqe->read.stag_src = htobe32(2); - wqe->read.to_src_hi = 0; - wqe->read.to_src_lo = 0; - wqe->read.stag_sink = htobe32(2); - wqe->read.plen = 0; - wqe->read.to_sink_hi = 0; - wqe->read.to_sink_lo = 0; - } - wqe->read.r2 = 0; - wqe->read.r5 = 0; - *len16 = DIV_ROUND_UP(sizeof wqe->read, 16); - return 0; -} - -static int build_rdma_recv(struct c4iw_qp *qhp, union t4_recv_wr *wqe, - struct ibv_recv_wr *wr, u8 *len16) -{ - int ret; - - ret = build_isgl(&wqe->recv.isgl, wr->sg_list, wr->num_sge, NULL); - if (ret) - return ret; - *len16 = DIV_ROUND_UP(sizeof wqe->recv + - wr->num_sge * sizeof(struct fw_ri_sge), 16); - return 0; -} - -static void ring_kernel_db(struct c4iw_qp *qhp, u32 qid, u16 idx) -{ - struct ibv_modify_qp cmd = {}; - struct ibv_qp_attr attr; - int mask; - int __attribute__((unused)) ret; - - /* FIXME: Why do we need this barrier if the kernel is going to - trigger the DMA? */ - udma_to_device_barrier(); - if (qid == qhp->wq.sq.qid) { - attr.sq_psn = idx; - mask = IBV_QP_SQ_PSN; - } else { - attr.rq_psn = idx; - mask = IBV_QP_RQ_PSN; - } - ret = ibv_cmd_modify_qp(&qhp->ibv_qp, &attr, mask, &cmd, sizeof cmd); - assert(!ret); -} - -int c4iw_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - int err = 0; - u8 uninitialized_var(len16); - enum fw_wr_opcodes fw_opcode; - enum fw_ri_wr_flags fw_flags; - struct c4iw_qp *qhp; - union t4_wr *wqe, lwqe; - u32 num_wrs; - struct t4_swsqe *swsqe; - u16 idx = 0; - - qhp = to_c4iw_qp(ibqp); - pthread_spin_lock(&qhp->lock); - if (t4_wq_in_error(&qhp->wq)) { - pthread_spin_unlock(&qhp->lock); - *bad_wr = wr; - return -EINVAL; - } - num_wrs = t4_sq_avail(&qhp->wq); - if (num_wrs == 0) { - pthread_spin_unlock(&qhp->lock); - *bad_wr = wr; - return -ENOMEM; - } - while (wr) { - if (num_wrs == 0) { - err = -ENOMEM; - *bad_wr = wr; - break; - } - - wqe = &lwqe; - fw_flags = 0; - if (wr->send_flags & IBV_SEND_SOLICITED) - fw_flags |= FW_RI_SOLICITED_EVENT_FLAG; - if (wr->send_flags & IBV_SEND_SIGNALED || qhp->sq_sig_all) - fw_flags |= FW_RI_COMPLETION_FLAG; - swsqe = &qhp->wq.sq.sw_sq[qhp->wq.sq.pidx]; - switch (wr->opcode) { - case IBV_WR_SEND: - INC_STAT(send); - if (wr->send_flags & IBV_SEND_FENCE) - fw_flags |= FW_RI_READ_FENCE_FLAG; - fw_opcode = FW_RI_SEND_WR; - swsqe->opcode = FW_RI_SEND; - err = build_rdma_send(&qhp->wq.sq, wqe, wr, &len16); - break; - case IBV_WR_RDMA_WRITE: - INC_STAT(write); - fw_opcode = FW_RI_RDMA_WRITE_WR; - swsqe->opcode = FW_RI_RDMA_WRITE; - err = build_rdma_write(&qhp->wq.sq, wqe, wr, &len16); - break; - case IBV_WR_RDMA_READ: - INC_STAT(read); - fw_opcode = FW_RI_RDMA_READ_WR; - swsqe->opcode = FW_RI_READ_REQ; - fw_flags = 0; - err = build_rdma_read(wqe, wr, &len16); - if (err) - break; - swsqe->read_len = wr->sg_list ? wr->sg_list[0].length : - 0; - if (!qhp->wq.sq.oldest_read) - qhp->wq.sq.oldest_read = swsqe; - break; - default: - PDBG("%s post of type=%d TBD!\n", __func__, - wr->opcode); - err = -EINVAL; - } - if (err) { - *bad_wr = wr; - break; - } - swsqe->idx = qhp->wq.sq.pidx; - swsqe->complete = 0; - swsqe->signaled = (wr->send_flags & IBV_SEND_SIGNALED) || - qhp->sq_sig_all; - swsqe->flushed = 0; - swsqe->wr_id = wr->wr_id; - - init_wr_hdr(wqe, qhp->wq.sq.pidx, fw_opcode, fw_flags, len16); - PDBG("%s cookie 0x%llx pidx 0x%x opcode 0x%x\n", - __func__, (unsigned long long)wr->wr_id, qhp->wq.sq.pidx, - swsqe->opcode); - wr = wr->next; - num_wrs--; - copy_wr_to_sq(&qhp->wq, wqe, len16); - t4_sq_produce(&qhp->wq, len16); - idx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE); - } - if (t4_wq_db_enabled(&qhp->wq)) { - t4_ring_sq_db(&qhp->wq, idx, dev_is_t4(qhp->rhp), - len16, wqe); - } else - ring_kernel_db(qhp, qhp->wq.sq.qid, idx); - /* This write is only for debugging, the value does not matter for DMA - */ - qhp->wq.sq.queue[qhp->wq.sq.size].status.host_wq_pidx = \ - (qhp->wq.sq.wq_pidx); - - pthread_spin_unlock(&qhp->lock); - return err; -} - -int c4iw_post_receive(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - int err = 0; - struct c4iw_qp *qhp; - union t4_recv_wr *wqe, lwqe; - u32 num_wrs; - u8 len16 = 0; - u16 idx = 0; - - qhp = to_c4iw_qp(ibqp); - pthread_spin_lock(&qhp->lock); - if (t4_wq_in_error(&qhp->wq)) { - pthread_spin_unlock(&qhp->lock); - *bad_wr = wr; - return -EINVAL; - } - INC_STAT(recv); - num_wrs = t4_rq_avail(&qhp->wq); - if (num_wrs == 0) { - pthread_spin_unlock(&qhp->lock); - *bad_wr = wr; - return -ENOMEM; - } - while (wr) { - if (wr->num_sge > T4_MAX_RECV_SGE) { - err = -EINVAL; - *bad_wr = wr; - break; - } - wqe = &lwqe; - if (num_wrs) - err = build_rdma_recv(qhp, wqe, wr, &len16); - else - err = -ENOMEM; - if (err) { - *bad_wr = wr; - break; - } - - qhp->wq.rq.sw_rq[qhp->wq.rq.pidx].wr_id = wr->wr_id; - - wqe->recv.opcode = FW_RI_RECV_WR; - wqe->recv.r1 = 0; - wqe->recv.wrid = qhp->wq.rq.pidx; - wqe->recv.r2[0] = 0; - wqe->recv.r2[1] = 0; - wqe->recv.r2[2] = 0; - wqe->recv.len16 = len16; - PDBG("%s cookie 0x%llx pidx %u\n", __func__, - (unsigned long long) wr->wr_id, qhp->wq.rq.pidx); - copy_wr_to_rq(&qhp->wq, wqe, len16); - t4_rq_produce(&qhp->wq, len16); - idx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE); - wr = wr->next; - num_wrs--; - } - if (t4_wq_db_enabled(&qhp->wq)) - t4_ring_rq_db(&qhp->wq, idx, dev_is_t4(qhp->rhp), - len16, wqe); - else - ring_kernel_db(qhp, qhp->wq.rq.qid, idx); - qhp->wq.rq.queue[qhp->wq.rq.size].status.host_wq_pidx = \ - (qhp->wq.rq.wq_pidx); - pthread_spin_unlock(&qhp->lock); - return err; -} - -static void update_qp_state(struct c4iw_qp *qhp) -{ - struct ibv_query_qp cmd; - struct ibv_qp_attr attr; - struct ibv_qp_init_attr iattr; - int ret; - - ret = ibv_cmd_query_qp(&qhp->ibv_qp, &attr, IBV_QP_STATE, &iattr, - &cmd, sizeof cmd); - assert(!ret); - if (!ret) - qhp->ibv_qp.state = attr.qp_state; -} - -/* - * Assumes qhp lock is held. - */ -void c4iw_flush_qp(struct c4iw_qp *qhp) -{ - struct c4iw_cq *rchp, *schp; - int count; - - if (qhp->wq.flushed) - return; - - update_qp_state(qhp); - - rchp = to_c4iw_cq(qhp->ibv_qp.recv_cq); - schp = to_c4iw_cq(qhp->ibv_qp.send_cq); - - PDBG("%s qhp %p rchp %p schp %p\n", __func__, qhp, rchp, schp); - qhp->wq.flushed = 1; - pthread_spin_unlock(&qhp->lock); - - /* locking heirarchy: cq lock first, then qp lock. */ - pthread_spin_lock(&rchp->lock); - pthread_spin_lock(&qhp->lock); - c4iw_flush_hw_cq(rchp); - c4iw_count_rcqes(&rchp->cq, &qhp->wq, &count); - c4iw_flush_rq(&qhp->wq, &rchp->cq, count); - pthread_spin_unlock(&qhp->lock); - pthread_spin_unlock(&rchp->lock); - - /* locking heirarchy: cq lock first, then qp lock. */ - pthread_spin_lock(&schp->lock); - pthread_spin_lock(&qhp->lock); - if (schp != rchp) - c4iw_flush_hw_cq(schp); - c4iw_flush_sq(qhp); - pthread_spin_unlock(&qhp->lock); - pthread_spin_unlock(&schp->lock); - pthread_spin_lock(&qhp->lock); -} - -void c4iw_flush_qps(struct c4iw_dev *dev) -{ - int i; - - pthread_spin_lock(&dev->lock); - for (i=0; i < dev->max_qp; i++) { - struct c4iw_qp *qhp = dev->qpid2ptr[i]; - if (qhp) { - if (!qhp->wq.flushed && t4_wq_in_error(&qhp->wq)) { - pthread_spin_lock(&qhp->lock); - c4iw_flush_qp(qhp); - pthread_spin_unlock(&qhp->lock); - } - } - } - pthread_spin_unlock(&dev->lock); -} diff --git a/usr/rdma-core/providers/cxgb4/t4.h b/usr/rdma-core/providers/cxgb4/t4.h deleted file mode 100644 index fb10002b9..000000000 --- a/usr/rdma-core/providers/cxgb4/t4.h +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __T4_H__ -#define __T4_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Try and minimize the changes from the kernel code that is pull in - * here for kernel bypass ops. - */ -#define u8 uint8_t -#define u16 uint16_t -#define u32 uint32_t -#define u64 uint64_t -#define DECLARE_PCI_UNMAP_ADDR(a) -#define __iomem -#define BUG_ON(c) assert(!(c)) -#define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u)) -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) - -/* FIXME: Move me to a generic PCI mmio accessor */ -#define cpu_to_pci32(val) htole32(val) - -#define writel(v, a) do { *((volatile u32 *)(a)) = cpu_to_pci32(v); } while (0) - -#include "t4_regs.h" -#include "t4_chip_type.h" -#include "t4fw_api.h" -#include "t4fw_ri_api.h" - -#ifdef DEBUG -#define DBGLOG(s) -#define PDBG(fmt, args...) do {syslog(LOG_DEBUG, fmt, ##args); } while (0) -#else -#define DBGLOG(s) -#define PDBG(fmt, args...) do {} while (0) -#endif - -#define A_PCIE_MA_SYNC 0x30b4 - -#define T4_MAX_READ_DEPTH 16 -#define T4_QID_BASE 1024 -#define T4_MAX_QIDS 256 -#define T4_MAX_NUM_PD 65536 -#define T4_EQ_STATUS_ENTRIES (L1_CACHE_BYTES > 64 ? 2 : 1) -#define T4_MAX_EQ_SIZE (65520 - T4_EQ_STATUS_ENTRIES) -#define T4_MAX_IQ_SIZE (65520 - 1) -#define T4_MAX_RQ_SIZE (8192 - T4_EQ_STATUS_ENTRIES) -#define T4_MAX_SQ_SIZE (T4_MAX_EQ_SIZE - 1) -#define T4_MAX_QP_DEPTH (T4_MAX_RQ_SIZE - 1) -#define T4_MAX_CQ_DEPTH (T4_MAX_IQ_SIZE - 1) -#define T4_MAX_NUM_STAG (1<<15) -#define T4_MAX_MR_SIZE (~0ULL - 1) -#define T4_PAGESIZE_MASK 0xffff000 /* 4KB-128MB */ -#define T4_STAG_UNSET 0xffffffff -#define T4_FW_MAJ 0 - -struct t4_status_page { - __be32 rsvd1; /* flit 0 - hw owns */ - __be16 rsvd2; - __be16 qid; - __be16 cidx; - __be16 pidx; - u8 qp_err; /* flit 1 - sw owns */ - u8 db_off; - u8 pad; - u16 host_wq_pidx; - u16 host_cidx; - u16 host_pidx; -}; - -#define T4_EQ_ENTRY_SIZE 64 - -#define T4_SQ_NUM_SLOTS 5 -#define T4_SQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_SQ_NUM_SLOTS) -#define T4_MAX_SEND_SGE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_send_wr) - sizeof(struct fw_ri_isgl)) / sizeof (struct fw_ri_sge)) -#define T4_MAX_SEND_INLINE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_send_wr) - sizeof(struct fw_ri_immd))) -#define T4_MAX_WRITE_INLINE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_rdma_write_wr) - sizeof(struct fw_ri_immd))) -#define T4_MAX_WRITE_SGE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_rdma_write_wr) - sizeof(struct fw_ri_isgl)) / sizeof (struct fw_ri_sge)) -#define T4_MAX_FR_IMMD ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_fr_nsmr_wr) - sizeof(struct fw_ri_immd))) -#define T4_MAX_FR_DEPTH 255 - -#define T4_RQ_NUM_SLOTS 2 -#define T4_RQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_RQ_NUM_SLOTS) -#define T4_MAX_RECV_SGE 4 - -union t4_wr { - struct fw_ri_res_wr res; - struct fw_ri_wr init; - struct fw_ri_rdma_write_wr write; - struct fw_ri_send_wr send; - struct fw_ri_rdma_read_wr read; - struct fw_ri_bind_mw_wr bind; - struct fw_ri_fr_nsmr_wr fr; - struct fw_ri_inv_lstag_wr inv; - struct t4_status_page status; - __be64 flits[T4_EQ_ENTRY_SIZE / sizeof(__be64) * T4_SQ_NUM_SLOTS]; -}; - -union t4_recv_wr { - struct fw_ri_recv_wr recv; - struct t4_status_page status; - __be64 flits[T4_EQ_ENTRY_SIZE / sizeof(__be64) * T4_RQ_NUM_SLOTS]; -}; - -static inline void init_wr_hdr(union t4_wr *wqe, u16 wrid, - enum fw_wr_opcodes opcode, u8 flags, u8 len16) -{ - wqe->send.opcode = (u8)opcode; - wqe->send.flags = flags; - wqe->send.wrid = wrid; - wqe->send.r1[0] = 0; - wqe->send.r1[1] = 0; - wqe->send.r1[2] = 0; - wqe->send.len16 = len16; -} - -/* CQE/AE status codes */ -#define T4_ERR_SUCCESS 0x0 -#define T4_ERR_STAG 0x1 /* STAG invalid: either the */ - /* STAG is offlimt, being 0, */ - /* or STAG_key mismatch */ -#define T4_ERR_PDID 0x2 /* PDID mismatch */ -#define T4_ERR_QPID 0x3 /* QPID mismatch */ -#define T4_ERR_ACCESS 0x4 /* Invalid access right */ -#define T4_ERR_WRAP 0x5 /* Wrap error */ -#define T4_ERR_BOUND 0x6 /* base and bounds voilation */ -#define T4_ERR_INVALIDATE_SHARED_MR 0x7 /* attempt to invalidate a */ - /* shared memory region */ -#define T4_ERR_INVALIDATE_MR_WITH_MW_BOUND 0x8 /* attempt to invalidate a */ - /* shared memory region */ -#define T4_ERR_ECC 0x9 /* ECC error detected */ -#define T4_ERR_ECC_PSTAG 0xA /* ECC error detected when */ - /* reading PSTAG for a MW */ - /* Invalidate */ -#define T4_ERR_PBL_ADDR_BOUND 0xB /* pbl addr out of bounds: */ - /* software error */ -#define T4_ERR_SWFLUSH 0xC /* SW FLUSHED */ -#define T4_ERR_CRC 0x10 /* CRC error */ -#define T4_ERR_MARKER 0x11 /* Marker error */ -#define T4_ERR_PDU_LEN_ERR 0x12 /* invalid PDU length */ -#define T4_ERR_OUT_OF_RQE 0x13 /* out of RQE */ -#define T4_ERR_DDP_VERSION 0x14 /* wrong DDP version */ -#define T4_ERR_RDMA_VERSION 0x15 /* wrong RDMA version */ -#define T4_ERR_OPCODE 0x16 /* invalid rdma opcode */ -#define T4_ERR_DDP_QUEUE_NUM 0x17 /* invalid ddp queue number */ -#define T4_ERR_MSN 0x18 /* MSN error */ -#define T4_ERR_TBIT 0x19 /* tag bit not set correctly */ -#define T4_ERR_MO 0x1A /* MO not 0 for TERMINATE */ - /* or READ_REQ */ -#define T4_ERR_MSN_GAP 0x1B -#define T4_ERR_MSN_RANGE 0x1C -#define T4_ERR_IRD_OVERFLOW 0x1D -#define T4_ERR_RQE_ADDR_BOUND 0x1E /* RQE addr out of bounds: */ - /* software error */ -#define T4_ERR_INTERNAL_ERR 0x1F /* internal error (opcode */ - /* mismatch) */ -/* - * CQE defs - */ -struct t4_cqe { - __be32 header; - __be32 len; - union { - struct { - __be32 stag; - __be32 msn; - } rcqe; - struct { - u32 nada1; - u16 nada2; - u16 cidx; - } scqe; - struct { - __be32 wrid_hi; - __be32 wrid_low; - } gen; - } u; - __be64 reserved; - __be64 bits_type_ts; -}; - -/* macros for flit 0 of the cqe */ - -#define S_CQE_QPID 12 -#define M_CQE_QPID 0xFFFFF -#define G_CQE_QPID(x) ((((x) >> S_CQE_QPID)) & M_CQE_QPID) -#define V_CQE_QPID(x) ((x)<> S_CQE_SWCQE)) & M_CQE_SWCQE) -#define V_CQE_SWCQE(x) ((x)<> S_CQE_STATUS)) & M_CQE_STATUS) -#define V_CQE_STATUS(x) ((x)<> S_CQE_TYPE)) & M_CQE_TYPE) -#define V_CQE_TYPE(x) ((x)<> S_CQE_OPCODE)) & M_CQE_OPCODE) -#define V_CQE_OPCODE(x) ((x)<header))) -#define CQE_QPID(x) (G_CQE_QPID(be32toh((x)->header))) -#define CQE_TYPE(x) (G_CQE_TYPE(be32toh((x)->header))) -#define SQ_TYPE(x) (CQE_TYPE((x))) -#define RQ_TYPE(x) (!CQE_TYPE((x))) -#define CQE_STATUS(x) (G_CQE_STATUS(be32toh((x)->header))) -#define CQE_OPCODE(x) (G_CQE_OPCODE(be32toh((x)->header))) - -#define CQE_SEND_OPCODE(x)( \ - (G_CQE_OPCODE(be32toh((x)->header)) == FW_RI_SEND) || \ - (G_CQE_OPCODE(be32toh((x)->header)) == FW_RI_SEND_WITH_SE) || \ - (G_CQE_OPCODE(be32toh((x)->header)) == FW_RI_SEND_WITH_INV) || \ - (G_CQE_OPCODE(be32toh((x)->header)) == FW_RI_SEND_WITH_SE_INV)) - -#define CQE_LEN(x) (be32toh((x)->len)) - -/* used for RQ completion processing */ -#define CQE_WRID_STAG(x) (be32toh((x)->u.rcqe.stag)) -#define CQE_WRID_MSN(x) (be32toh((x)->u.rcqe.msn)) - -/* used for SQ completion processing */ -#define CQE_WRID_SQ_IDX(x) (x)->u.scqe.cidx - -/* generic accessor macros */ -#define CQE_WRID_HI(x) ((x)->u.gen.wrid_hi) -#define CQE_WRID_LOW(x) ((x)->u.gen.wrid_low) - -/* macros for flit 3 of the cqe */ -#define S_CQE_GENBIT 63 -#define M_CQE_GENBIT 0x1 -#define G_CQE_GENBIT(x) (((x) >> S_CQE_GENBIT) & M_CQE_GENBIT) -#define V_CQE_GENBIT(x) ((x)<> S_CQE_OVFBIT)) & M_CQE_OVFBIT) - -#define S_CQE_IQTYPE 60 -#define M_CQE_IQTYPE 0x3 -#define G_CQE_IQTYPE(x) ((((x) >> S_CQE_IQTYPE)) & M_CQE_IQTYPE) - -#define M_CQE_TS 0x0fffffffffffffffULL -#define G_CQE_TS(x) ((x) & M_CQE_TS) - -#define CQE_OVFBIT(x) ((unsigned)G_CQE_OVFBIT(be64toh((x)->bits_type_ts))) -#define CQE_GENBIT(x) ((unsigned)G_CQE_GENBIT(be64toh((x)->bits_type_ts))) -#define CQE_TS(x) (G_CQE_TS(be64toh((x)->bits_type_ts))) - -struct t4_swsqe { - u64 wr_id; - struct t4_cqe cqe; - __be32 read_len; - int opcode; - int complete; - int signaled; - u16 idx; - int flushed; -}; - -enum { - T4_SQ_ONCHIP = (1<<0), -}; - -struct t4_sq { - /* queue is either host memory or WC MMIO memory if - * t4_sq_onchip(). */ - union t4_wr *queue; - struct t4_swsqe *sw_sq; - struct t4_swsqe *oldest_read; - /* udb is either UC or WC MMIO memory depending on device version. */ - volatile u32 *udb; - size_t memsize; - u32 qid; - u32 bar2_qid; - void *ma_sync; - u16 in_use; - u16 size; - u16 cidx; - u16 pidx; - u16 wq_pidx; - u16 flags; - short flush_cidx; - int wc_reg_available; -}; - -struct t4_swrqe { - u64 wr_id; -}; - -struct t4_rq { - union t4_recv_wr *queue; - struct t4_swrqe *sw_rq; - volatile u32 *udb; - size_t memsize; - u32 qid; - u32 bar2_qid; - u32 msn; - u32 rqt_hwaddr; - u16 rqt_size; - u16 in_use; - u16 size; - u16 cidx; - u16 pidx; - u16 wq_pidx; - int wc_reg_available; -}; - -struct t4_wq { - struct t4_sq sq; - struct t4_rq rq; - struct c4iw_rdev *rdev; - u32 qid_mask; - int error; - int flushed; - u8 *db_offp; -}; - -static inline int t4_rqes_posted(struct t4_wq *wq) -{ - return wq->rq.in_use; -} - -static inline int t4_rq_empty(struct t4_wq *wq) -{ - return wq->rq.in_use == 0; -} - -static inline int t4_rq_full(struct t4_wq *wq) -{ - return wq->rq.in_use == (wq->rq.size - 1); -} - -static inline u32 t4_rq_avail(struct t4_wq *wq) -{ - return wq->rq.size - 1 - wq->rq.in_use; -} - -static inline void t4_rq_produce(struct t4_wq *wq, u8 len16) -{ - wq->rq.in_use++; - if (++wq->rq.pidx == wq->rq.size) - wq->rq.pidx = 0; - wq->rq.wq_pidx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE); - if (wq->rq.wq_pidx >= wq->rq.size * T4_RQ_NUM_SLOTS) - wq->rq.wq_pidx %= wq->rq.size * T4_RQ_NUM_SLOTS; - if (!wq->error) - wq->rq.queue[wq->rq.size].status.host_pidx = wq->rq.pidx; -} - -static inline void t4_rq_consume(struct t4_wq *wq) -{ - wq->rq.in_use--; - wq->rq.msn++; - if (++wq->rq.cidx == wq->rq.size) - wq->rq.cidx = 0; - assert((wq->rq.cidx != wq->rq.pidx) || wq->rq.in_use == 0); - if (!wq->error) - wq->rq.queue[wq->rq.size].status.host_cidx = wq->rq.cidx; -} - -static inline int t4_sq_empty(struct t4_wq *wq) -{ - return wq->sq.in_use == 0; -} - -static inline int t4_sq_full(struct t4_wq *wq) -{ - return wq->sq.in_use == (wq->sq.size - 1); -} - -static inline u32 t4_sq_avail(struct t4_wq *wq) -{ - return wq->sq.size - 1 - wq->sq.in_use; -} - -static inline int t4_sq_onchip(struct t4_wq *wq) -{ - return wq->sq.flags & T4_SQ_ONCHIP; -} - -static inline void t4_sq_produce(struct t4_wq *wq, u8 len16) -{ - wq->sq.in_use++; - if (++wq->sq.pidx == wq->sq.size) - wq->sq.pidx = 0; - wq->sq.wq_pidx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE); - if (wq->sq.wq_pidx >= wq->sq.size * T4_SQ_NUM_SLOTS) - wq->sq.wq_pidx %= wq->sq.size * T4_SQ_NUM_SLOTS; - if (!wq->error) { - /* This write is only for debugging, the value does not matter - * for DMA */ - wq->sq.queue[wq->sq.size].status.host_pidx = (wq->sq.pidx); - } -} - -static inline void t4_sq_consume(struct t4_wq *wq) -{ - assert(wq->sq.in_use >= 1); - if (wq->sq.cidx == wq->sq.flush_cidx) - wq->sq.flush_cidx = -1; - wq->sq.in_use--; - if (++wq->sq.cidx == wq->sq.size) - wq->sq.cidx = 0; - assert((wq->sq.cidx != wq->sq.pidx) || wq->sq.in_use == 0); - if (!wq->error){ - /* This write is only for debugging, the value does not matter - * for DMA */ - wq->sq.queue[wq->sq.size].status.host_cidx = wq->sq.cidx; - } -} - -/* Copies to WC MMIO memory */ -static void copy_wqe_to_udb(volatile u32 *udb_offset, void *wqe) -{ - u64 *src, *dst; - int len16 = 4; - - src = (u64 *)wqe; - dst = (u64 *)udb_offset; - - while (len16) { - *dst++ = *src++; - *dst++ = *src++; - len16--; - } -} - -extern int ma_wr; -extern int t5_en_wc; - -static inline void t4_ring_sq_db(struct t4_wq *wq, u16 inc, u8 t4, u8 len16, - union t4_wr *wqe) -{ - if (!t4) { - mmio_wc_start(); - if (t5_en_wc && inc == 1 && wq->sq.wc_reg_available) { - PDBG("%s: WC wq->sq.pidx = %d; len16=%d\n", - __func__, wq->sq.pidx, len16); - copy_wqe_to_udb(wq->sq.udb + 14, wqe); - } else { - PDBG("%s: DB wq->sq.pidx = %d; len16=%d\n", - __func__, wq->sq.pidx, len16); - writel(QID_V(wq->sq.bar2_qid) | PIDX_T5_V(inc), - wq->sq.udb); - } - /* udb is WC for > t4 devices */ - mmio_flush_writes(); - return; - } - - udma_to_device_barrier(); - if (ma_wr) { - if (t4_sq_onchip(wq)) { - int i; - - mmio_wc_start(); - for (i = 0; i < 16; i++) - *(volatile u32 *)&wq->sq.queue[wq->sq.size].flits[2+i] = i; - mmio_flush_writes(); - } - } else { - if (t4_sq_onchip(wq)) { - int i; - - mmio_wc_start(); - for (i = 0; i < 16; i++) - /* FIXME: What is this supposed to be doing? - * Writing to the same address multiple times - * with WC memory is not guarenteed to - * generate any more than one TLP. Why isn't - * writing to WC memory marked volatile? */ - *(u32 *)&wq->sq.queue[wq->sq.size].flits[2] = i; - mmio_flush_writes(); - } - } - /* udb is UC for t4 devices */ - writel(QID_V(wq->sq.qid & wq->qid_mask) | PIDX_V(inc), wq->sq.udb); -} - -static inline void t4_ring_rq_db(struct t4_wq *wq, u16 inc, u8 t4, u8 len16, - union t4_recv_wr *wqe) -{ - if (!t4) { - mmio_wc_start(); - if (t5_en_wc && inc == 1 && wq->sq.wc_reg_available) { - PDBG("%s: WC wq->rq.pidx = %d; len16=%d\n", - __func__, wq->rq.pidx, len16); - copy_wqe_to_udb(wq->rq.udb + 14, wqe); - } else { - PDBG("%s: DB wq->rq.pidx = %d; len16=%d\n", - __func__, wq->rq.pidx, len16); - writel(QID_V(wq->rq.bar2_qid) | PIDX_T5_V(inc), - wq->rq.udb); - } - /* udb is WC for > t4 devices */ - mmio_flush_writes(); - return; - } - /* udb is UC for t4 devices */ - udma_to_device_barrier(); - writel(QID_V(wq->rq.qid & wq->qid_mask) | PIDX_V(inc), wq->rq.udb); -} - -static inline int t4_wq_in_error(struct t4_wq *wq) -{ - return wq->error || wq->rq.queue[wq->rq.size].status.qp_err; -} - -static inline void t4_set_wq_in_error(struct t4_wq *wq) -{ - wq->rq.queue[wq->rq.size].status.qp_err = 1; -} - -extern int c4iw_abi_version; - -static inline int t4_wq_db_enabled(struct t4_wq *wq) -{ - /* - * If iw_cxgb4 driver supports door bell drop recovery then its - * c4iw_abi_version would be greater than or equal to 2. In such - * case return the status of db_off flag to ring the kernel mode - * DB from user mode library. - */ - if ( c4iw_abi_version >= 2 ) - return ! *wq->db_offp; - else - return 1; -} - -struct t4_cq { - struct t4_cqe *queue; - struct t4_cqe *sw_queue; - struct c4iw_rdev *rdev; - volatile u32 *ugts; - size_t memsize; - u64 bits_type_ts; - u32 cqid; - u32 qid_mask; - u16 size; /* including status page */ - u16 cidx; - u16 sw_pidx; - u16 sw_cidx; - u16 sw_in_use; - u16 cidx_inc; - u8 gen; - u8 error; -}; - -static inline int t4_arm_cq(struct t4_cq *cq, int se) -{ - u32 val; - - while (cq->cidx_inc > CIDXINC_M) { - val = SEINTARM_V(0) | CIDXINC_V(CIDXINC_M) | TIMERREG_V(7) | - INGRESSQID_V(cq->cqid & cq->qid_mask); - writel(val, cq->ugts); - cq->cidx_inc -= CIDXINC_M; - } - val = SEINTARM_V(se) | CIDXINC_V(cq->cidx_inc) | TIMERREG_V(6) | - INGRESSQID_V(cq->cqid & cq->qid_mask); - writel(val, cq->ugts); - cq->cidx_inc = 0; - return 0; -} - -static inline void t4_swcq_produce(struct t4_cq *cq) -{ - cq->sw_in_use++; - if (cq->sw_in_use == cq->size) { - syslog(LOG_NOTICE, "cxgb4 sw cq overflow cqid %u\n", cq->cqid); - cq->error = 1; - assert(0); - } - if (++cq->sw_pidx == cq->size) - cq->sw_pidx = 0; -} - -static inline void t4_swcq_consume(struct t4_cq *cq) -{ - assert(cq->sw_in_use >= 1); - cq->sw_in_use--; - if (++cq->sw_cidx == cq->size) - cq->sw_cidx = 0; -} - -static inline void t4_hwcq_consume(struct t4_cq *cq) -{ - cq->bits_type_ts = cq->queue[cq->cidx].bits_type_ts; - if (++cq->cidx_inc == (cq->size >> 4) || cq->cidx_inc == CIDXINC_M) { - uint32_t val; - - val = SEINTARM_V(0) | CIDXINC_V(cq->cidx_inc) | TIMERREG_V(7) | - INGRESSQID_V(cq->cqid & cq->qid_mask); - writel(val, cq->ugts); - cq->cidx_inc = 0; - } - if (++cq->cidx == cq->size) { - cq->cidx = 0; - cq->gen ^= 1; - } - ((struct t4_status_page *)&cq->queue[cq->size])->host_cidx = cq->cidx; -} - -static inline int t4_valid_cqe(struct t4_cq *cq, struct t4_cqe *cqe) -{ - return (CQE_GENBIT(cqe) == cq->gen); -} - -static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe) -{ - int ret; - u16 prev_cidx; - - if (cq->cidx == 0) - prev_cidx = cq->size - 1; - else - prev_cidx = cq->cidx - 1; - - if (cq->queue[prev_cidx].bits_type_ts != cq->bits_type_ts) { - ret = -EOVERFLOW; - syslog(LOG_NOTICE, "cxgb4 cq overflow cqid %u\n", cq->cqid); - cq->error = 1; - assert(0); - } else if (t4_valid_cqe(cq, &cq->queue[cq->cidx])) { - udma_from_device_barrier(); - *cqe = &cq->queue[cq->cidx]; - ret = 0; - } else - ret = -ENODATA; - return ret; -} - -static inline struct t4_cqe *t4_next_sw_cqe(struct t4_cq *cq) -{ - if (cq->sw_in_use == cq->size) { - syslog(LOG_NOTICE, "cxgb4 sw cq overflow cqid %u\n", cq->cqid); - cq->error = 1; - assert(0); - return NULL; - } - if (cq->sw_in_use) - return &cq->sw_queue[cq->sw_cidx]; - return NULL; -} - -static inline int t4_cq_notempty(struct t4_cq *cq) -{ - return cq->sw_in_use || t4_valid_cqe(cq, &cq->queue[cq->cidx]); -} - -static inline int t4_next_cqe(struct t4_cq *cq, struct t4_cqe **cqe) -{ - int ret = 0; - - if (cq->error) - ret = -ENODATA; - else if (cq->sw_in_use) - *cqe = &cq->sw_queue[cq->sw_cidx]; - else ret = t4_next_hw_cqe(cq, cqe); - return ret; -} - -static inline int t4_cq_in_error(struct t4_cq *cq) -{ - return ((struct t4_status_page *)&cq->queue[cq->size])->qp_err; -} - -static inline void t4_set_cq_in_error(struct t4_cq *cq) -{ - ((struct t4_status_page *)&cq->queue[cq->size])->qp_err = 1; -} - -static inline void t4_reset_cq_in_error(struct t4_cq *cq) -{ - ((struct t4_status_page *)&cq->queue[cq->size])->qp_err = 0; -} - -struct t4_dev_status_page -{ - u8 db_off; - u8 pad1; - u16 pad2; - u32 pad3; - u64 qp_start; - u64 qp_size; - u64 cq_start; - u64 cq_size; -}; - -#endif diff --git a/usr/rdma-core/providers/cxgb4/t4_chip_type.h b/usr/rdma-core/providers/cxgb4/t4_chip_type.h deleted file mode 100644 index 54b718111..000000000 --- a/usr/rdma-core/providers/cxgb4/t4_chip_type.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is part of the Chelsio T4 Ethernet driver for Linux. - * - * Copyright (c) 2003-2015 Chelsio Communications, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __T4_CHIP_TYPE_H__ -#define __T4_CHIP_TYPE_H__ - -#define CHELSIO_T4 0x4 -#define CHELSIO_T5 0x5 -#define CHELSIO_T6 0x6 - -/* We code the Chelsio T4 Family "Chip Code" as a tuple: - * - * (Chip Version, Chip Revision) - * - * where: - * - * Chip Version: is T4, T5, etc. - * Chip Revision: is the FAB "spin" of the Chip Version. - */ -#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision)) -#define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf) -#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf) - -enum chip_type { - T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1), - T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2), - T4_FIRST_REV = T4_A1, - T4_LAST_REV = T4_A2, - - T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0), - T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1), - T5_FIRST_REV = T5_A0, - T5_LAST_REV = T5_A1, - - T6_A0 = CHELSIO_CHIP_CODE(CHELSIO_T6, 0), - T6_FIRST_REV = T6_A0, - T6_LAST_REV = T6_A0, -}; - -static inline int is_t4(enum chip_type chip) -{ - return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4); -} - -static inline int is_t5(enum chip_type chip) -{ - return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T5); -} - -static inline int is_t6(enum chip_type chip) -{ - return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T6); -} - -#endif /* __T4_CHIP_TYPE_H__ */ diff --git a/usr/rdma-core/providers/cxgb4/t4_pci_id_tbl.h b/usr/rdma-core/providers/cxgb4/t4_pci_id_tbl.h deleted file mode 100644 index 50812a1d6..000000000 --- a/usr/rdma-core/providers/cxgb4/t4_pci_id_tbl.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * This file is part of the Chelsio T4/T5 Ethernet driver for Linux. - * - * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __T4_PCI_ID_TBL_H__ -#define __T4_PCI_ID_TBL_H__ - -/* The code can defined cpp macros for creating a PCI Device ID Table. This is - * useful because it allows the PCI ID Table to be maintained in a single place. - * - * The macros are: - * - * CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN - * -- Used to start the definition of the PCI ID Table. - * - * CH_PCI_DEVICE_ID_FUNCTION - * -- The PCI Function Number to use in the PCI Device ID Table. "0" - * -- for drivers attaching to PF0-3, "4" for drivers attaching to PF4, - * -- "8" for drivers attaching to SR-IOV Virtual Functions, etc. - * - * CH_PCI_DEVICE_ID_FUNCTION2 [optional] - * -- If defined, create a PCI Device ID Table with both - * -- CH_PCI_DEVICE_ID_FUNCTION and CH_PCI_DEVICE_ID_FUNCTION2 populated. - * - * CH_PCI_ID_TABLE_ENTRY(DeviceID) - * -- Used for the individual PCI Device ID entries. Note that we will - * -- be adding a trailing comma (",") after all of the entries (and - * -- between the pairs of entries if CH_PCI_DEVICE_ID_FUNCTION2 is defined). - * - * CH_PCI_DEVICE_ID_TABLE_DEFINE_END - * -- Used to finish the definition of the PCI ID Table. Note that we - * -- will be adding a trailing semi-colon (";") here. - */ -#ifndef CH_PCI_DEVICE_ID_FUNCTION -#error CH_PCI_DEVICE_ID_FUNCTION not defined! -#endif -#ifndef CH_PCI_ID_TABLE_ENTRY -#error CH_PCI_ID_TABLE_ENTRY not defined! -#endif -#ifndef CH_PCI_DEVICE_ID_TABLE_DEFINE_END -#error CH_PCI_DEVICE_ID_TABLE_DEFINE_END not defined! -#endif - -/* T4 and later ASICs use a PCI Device ID scheme of 0xVFPP where: - * - * V = "4" for T4; "5" for T5, etc. - * F = "0" for PF 0..3; "4".."7" for PF4..7; and "8" for VFs - * PP = adapter product designation - * - * We use this consistency in order to create the proper PCI Device IDs - * for the specified CH_PCI_DEVICE_ID_FUNCTION. - */ -#ifndef CH_PCI_DEVICE_ID_FUNCTION2 -#define CH_PCI_ID_TABLE_FENTRY(devid) \ - CH_PCI_ID_TABLE_ENTRY((devid) | \ - ((CH_PCI_DEVICE_ID_FUNCTION) << 8)) -#else -#define CH_PCI_ID_TABLE_FENTRY(devid) \ - CH_PCI_ID_TABLE_ENTRY((devid) | \ - ((CH_PCI_DEVICE_ID_FUNCTION) << 8)), \ - CH_PCI_ID_TABLE_ENTRY((devid) | \ - ((CH_PCI_DEVICE_ID_FUNCTION2) << 8)) -#endif - -CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN - /* T4 adapters: - */ - CH_PCI_ID_TABLE_FENTRY(0x4000), /* T440-dbg */ - CH_PCI_ID_TABLE_FENTRY(0x4001), /* T420-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4002), /* T422-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4003), /* T440-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4004), /* T420-bch */ - CH_PCI_ID_TABLE_FENTRY(0x4005), /* T440-bch */ - CH_PCI_ID_TABLE_FENTRY(0x4006), /* T440-ch */ - CH_PCI_ID_TABLE_FENTRY(0x4007), /* T420-so */ - CH_PCI_ID_TABLE_FENTRY(0x4008), /* T420-cx */ - CH_PCI_ID_TABLE_FENTRY(0x4009), /* T420-bt */ - CH_PCI_ID_TABLE_FENTRY(0x400a), /* T404-bt */ - CH_PCI_ID_TABLE_FENTRY(0x400b), /* B420-sr */ - CH_PCI_ID_TABLE_FENTRY(0x400c), /* B404-bt */ - CH_PCI_ID_TABLE_FENTRY(0x400d), /* T480-cr */ - CH_PCI_ID_TABLE_FENTRY(0x400e), /* T440-LP-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4080), /* Custom T480-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4081), /* Custom T440-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4082), /* Custom T420-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4083), /* Custom T420-xaui */ - CH_PCI_ID_TABLE_FENTRY(0x4084), /* Custom T440-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4085), /* Custom T420-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4086), /* Custom T440-bt */ - CH_PCI_ID_TABLE_FENTRY(0x4087), /* Custom T440-cr */ - CH_PCI_ID_TABLE_FENTRY(0x4088), /* Custom T440 2-xaui, 2-xfi */ - - /* T5 adapters: - */ - CH_PCI_ID_TABLE_FENTRY(0x5000), /* T580-dbg */ - CH_PCI_ID_TABLE_FENTRY(0x5001), /* T520-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5002), /* T522-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5003), /* T540-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5004), /* T520-bch */ - CH_PCI_ID_TABLE_FENTRY(0x5005), /* T540-bch */ - CH_PCI_ID_TABLE_FENTRY(0x5006), /* T540-ch */ - CH_PCI_ID_TABLE_FENTRY(0x5007), /* T520-so */ - CH_PCI_ID_TABLE_FENTRY(0x5008), /* T520-cx */ - CH_PCI_ID_TABLE_FENTRY(0x5009), /* T520-bt */ - CH_PCI_ID_TABLE_FENTRY(0x500a), /* T504-bt */ - CH_PCI_ID_TABLE_FENTRY(0x500b), /* B520-sr */ - CH_PCI_ID_TABLE_FENTRY(0x500c), /* B504-bt */ - CH_PCI_ID_TABLE_FENTRY(0x500d), /* T580-cr */ - CH_PCI_ID_TABLE_FENTRY(0x500e), /* T540-LP-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5010), /* T580-LP-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5011), /* T520-LL-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5012), /* T560-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5013), /* T580-chr */ - CH_PCI_ID_TABLE_FENTRY(0x5014), /* T580-so */ - CH_PCI_ID_TABLE_FENTRY(0x5015), /* T502-bt */ - CH_PCI_ID_TABLE_FENTRY(0x5016), /* T580-OCP-SO */ - CH_PCI_ID_TABLE_FENTRY(0x5017), /* T520-OCP-SO */ - CH_PCI_ID_TABLE_FENTRY(0x5018), /* T540-BT */ - CH_PCI_ID_TABLE_FENTRY(0x5080), /* Custom T540-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5081), /* Custom T540-LL-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5082), /* Custom T504-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5083), /* Custom T540-LP-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5084), /* Custom T580-cr */ - CH_PCI_ID_TABLE_FENTRY(0x5085), /* Custom 3x T580-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5086), /* Custom 2x T580-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5087), /* Custom T580-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5088), /* Custom T570-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5089), /* Custom T520-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5090), /* Custom T540-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5091), /* Custom T522-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5092), /* Custom T520-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5093), /* Custom T580-LP-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5094), /* Custom T540-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5095), /* Custom T540-CR-SO */ - CH_PCI_ID_TABLE_FENTRY(0x5096), /* Custom T580-CR */ - CH_PCI_ID_TABLE_FENTRY(0x5097), /* Custom T520-KR */ - CH_PCI_ID_TABLE_FENTRY(0x5098), /* Custom 2x40G QSFP */ - CH_PCI_ID_TABLE_FENTRY(0x5099), /* Custom 2x40G QSFP */ - CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */ - CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */ - CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR*/ - - /* T6 adapters: - */ - CH_PCI_ID_TABLE_FENTRY(0x6001), - CH_PCI_ID_TABLE_FENTRY(0x6002), - CH_PCI_ID_TABLE_FENTRY(0x6003), - CH_PCI_ID_TABLE_FENTRY(0x6004), - CH_PCI_ID_TABLE_FENTRY(0x6005), - CH_PCI_ID_TABLE_FENTRY(0x6006), - CH_PCI_ID_TABLE_FENTRY(0x6007), - CH_PCI_ID_TABLE_FENTRY(0x6009), - CH_PCI_ID_TABLE_FENTRY(0x600d), - CH_PCI_ID_TABLE_FENTRY(0x6010), - CH_PCI_ID_TABLE_FENTRY(0x6011), - CH_PCI_ID_TABLE_FENTRY(0x6014), - CH_PCI_ID_TABLE_FENTRY(0x6015), -CH_PCI_DEVICE_ID_TABLE_DEFINE_END; - -#endif /* __T4_PCI_ID_TBL_H__ */ diff --git a/usr/rdma-core/providers/cxgb4/t4_regs.h b/usr/rdma-core/providers/cxgb4/t4_regs.h deleted file mode 100644 index 9fea255c7..000000000 --- a/usr/rdma-core/providers/cxgb4/t4_regs.h +++ /dev/null @@ -1,3125 +0,0 @@ -/* - * This file is part of the Chelsio T4 Ethernet driver for Linux. - * - * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __T4_REGS_H -#define __T4_REGS_H - -#define MYPF_BASE 0x1b000 -#define MYPF_REG(reg_addr) (MYPF_BASE + (reg_addr)) - -#define PF0_BASE 0x1e000 -#define PF0_REG(reg_addr) (PF0_BASE + (reg_addr)) - -#define PF_STRIDE 0x400 -#define PF_BASE(idx) (PF0_BASE + (idx) * PF_STRIDE) -#define PF_REG(idx, reg) (PF_BASE(idx) + (reg)) - -#define MYPORT_BASE 0x1c000 -#define MYPORT_REG(reg_addr) (MYPORT_BASE + (reg_addr)) - -#define PORT0_BASE 0x20000 -#define PORT0_REG(reg_addr) (PORT0_BASE + (reg_addr)) - -#define PORT_STRIDE 0x2000 -#define PORT_BASE(idx) (PORT0_BASE + (idx) * PORT_STRIDE) -#define PORT_REG(idx, reg) (PORT_BASE(idx) + (reg)) - -#define EDC_STRIDE (EDC_1_BASE_ADDR - EDC_0_BASE_ADDR) -#define EDC_REG(reg, idx) (reg + EDC_STRIDE * idx) - -#define PCIE_MEM_ACCESS_REG(reg_addr, idx) ((reg_addr) + (idx) * 8) -#define PCIE_MAILBOX_REG(reg_addr, idx) ((reg_addr) + (idx) * 8) -#define MC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4) -#define EDC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4) - -#define PCIE_FW_REG(reg_addr, idx) ((reg_addr) + (idx) * 4) - -#define SGE_PF_KDOORBELL_A 0x0 - -#define QID_S 15 -#define QID_V(x) ((x) << QID_S) - -#define DBPRIO_S 14 -#define DBPRIO_V(x) ((x) << DBPRIO_S) -#define DBPRIO_F DBPRIO_V(1U) - -#define PIDX_S 0 -#define PIDX_V(x) ((x) << PIDX_S) - -#define SGE_VF_KDOORBELL_A 0x0 - -#define DBTYPE_S 13 -#define DBTYPE_V(x) ((x) << DBTYPE_S) -#define DBTYPE_F DBTYPE_V(1U) - -#define PIDX_T5_S 0 -#define PIDX_T5_M 0x1fffU -#define PIDX_T5_V(x) ((x) << PIDX_T5_S) -#define PIDX_T5_G(x) (((x) >> PIDX_T5_S) & PIDX_T5_M) - -#define SGE_PF_GTS_A 0x4 - -#define INGRESSQID_S 16 -#define INGRESSQID_V(x) ((x) << INGRESSQID_S) - -#define TIMERREG_S 13 -#define TIMERREG_V(x) ((x) << TIMERREG_S) - -#define SEINTARM_S 12 -#define SEINTARM_V(x) ((x) << SEINTARM_S) - -#define CIDXINC_S 0 -#define CIDXINC_M 0xfffU -#define CIDXINC_V(x) ((x) << CIDXINC_S) - -#define SGE_CONTROL_A 0x1008 -#define SGE_CONTROL2_A 0x1124 - -#define RXPKTCPLMODE_S 18 -#define RXPKTCPLMODE_V(x) ((x) << RXPKTCPLMODE_S) -#define RXPKTCPLMODE_F RXPKTCPLMODE_V(1U) - -#define EGRSTATUSPAGESIZE_S 17 -#define EGRSTATUSPAGESIZE_V(x) ((x) << EGRSTATUSPAGESIZE_S) -#define EGRSTATUSPAGESIZE_F EGRSTATUSPAGESIZE_V(1U) - -#define PKTSHIFT_S 10 -#define PKTSHIFT_M 0x7U -#define PKTSHIFT_V(x) ((x) << PKTSHIFT_S) -#define PKTSHIFT_G(x) (((x) >> PKTSHIFT_S) & PKTSHIFT_M) - -#define INGPCIEBOUNDARY_S 7 -#define INGPCIEBOUNDARY_V(x) ((x) << INGPCIEBOUNDARY_S) - -#define INGPADBOUNDARY_S 4 -#define INGPADBOUNDARY_M 0x7U -#define INGPADBOUNDARY_V(x) ((x) << INGPADBOUNDARY_S) -#define INGPADBOUNDARY_G(x) (((x) >> INGPADBOUNDARY_S) & INGPADBOUNDARY_M) - -#define EGRPCIEBOUNDARY_S 1 -#define EGRPCIEBOUNDARY_V(x) ((x) << EGRPCIEBOUNDARY_S) - -#define INGPACKBOUNDARY_S 16 -#define INGPACKBOUNDARY_M 0x7U -#define INGPACKBOUNDARY_V(x) ((x) << INGPACKBOUNDARY_S) -#define INGPACKBOUNDARY_G(x) (((x) >> INGPACKBOUNDARY_S) \ - & INGPACKBOUNDARY_M) - -#define VFIFO_ENABLE_S 10 -#define VFIFO_ENABLE_V(x) ((x) << VFIFO_ENABLE_S) -#define VFIFO_ENABLE_F VFIFO_ENABLE_V(1U) - -#define SGE_DBVFIFO_BADDR_A 0x1138 - -#define DBVFIFO_SIZE_S 6 -#define DBVFIFO_SIZE_M 0xfffU -#define DBVFIFO_SIZE_G(x) (((x) >> DBVFIFO_SIZE_S) & DBVFIFO_SIZE_M) - -#define T6_DBVFIFO_SIZE_S 0 -#define T6_DBVFIFO_SIZE_M 0x1fffU -#define T6_DBVFIFO_SIZE_G(x) (((x) >> T6_DBVFIFO_SIZE_S) & T6_DBVFIFO_SIZE_M) - -#define GLOBALENABLE_S 0 -#define GLOBALENABLE_V(x) ((x) << GLOBALENABLE_S) -#define GLOBALENABLE_F GLOBALENABLE_V(1U) - -#define SGE_HOST_PAGE_SIZE_A 0x100c - -#define HOSTPAGESIZEPF7_S 28 -#define HOSTPAGESIZEPF7_M 0xfU -#define HOSTPAGESIZEPF7_V(x) ((x) << HOSTPAGESIZEPF7_S) -#define HOSTPAGESIZEPF7_G(x) (((x) >> HOSTPAGESIZEPF7_S) & HOSTPAGESIZEPF7_M) - -#define HOSTPAGESIZEPF6_S 24 -#define HOSTPAGESIZEPF6_M 0xfU -#define HOSTPAGESIZEPF6_V(x) ((x) << HOSTPAGESIZEPF6_S) -#define HOSTPAGESIZEPF6_G(x) (((x) >> HOSTPAGESIZEPF6_S) & HOSTPAGESIZEPF6_M) - -#define HOSTPAGESIZEPF5_S 20 -#define HOSTPAGESIZEPF5_M 0xfU -#define HOSTPAGESIZEPF5_V(x) ((x) << HOSTPAGESIZEPF5_S) -#define HOSTPAGESIZEPF5_G(x) (((x) >> HOSTPAGESIZEPF5_S) & HOSTPAGESIZEPF5_M) - -#define HOSTPAGESIZEPF4_S 16 -#define HOSTPAGESIZEPF4_M 0xfU -#define HOSTPAGESIZEPF4_V(x) ((x) << HOSTPAGESIZEPF4_S) -#define HOSTPAGESIZEPF4_G(x) (((x) >> HOSTPAGESIZEPF4_S) & HOSTPAGESIZEPF4_M) - -#define HOSTPAGESIZEPF3_S 12 -#define HOSTPAGESIZEPF3_M 0xfU -#define HOSTPAGESIZEPF3_V(x) ((x) << HOSTPAGESIZEPF3_S) -#define HOSTPAGESIZEPF3_G(x) (((x) >> HOSTPAGESIZEPF3_S) & HOSTPAGESIZEPF3_M) - -#define HOSTPAGESIZEPF2_S 8 -#define HOSTPAGESIZEPF2_M 0xfU -#define HOSTPAGESIZEPF2_V(x) ((x) << HOSTPAGESIZEPF2_S) -#define HOSTPAGESIZEPF2_G(x) (((x) >> HOSTPAGESIZEPF2_S) & HOSTPAGESIZEPF2_M) - -#define HOSTPAGESIZEPF1_S 4 -#define HOSTPAGESIZEPF1_M 0xfU -#define HOSTPAGESIZEPF1_V(x) ((x) << HOSTPAGESIZEPF1_S) -#define HOSTPAGESIZEPF1_G(x) (((x) >> HOSTPAGESIZEPF1_S) & HOSTPAGESIZEPF1_M) - -#define HOSTPAGESIZEPF0_S 0 -#define HOSTPAGESIZEPF0_M 0xfU -#define HOSTPAGESIZEPF0_V(x) ((x) << HOSTPAGESIZEPF0_S) -#define HOSTPAGESIZEPF0_G(x) (((x) >> HOSTPAGESIZEPF0_S) & HOSTPAGESIZEPF0_M) - -#define SGE_EGRESS_QUEUES_PER_PAGE_PF_A 0x1010 -#define SGE_EGRESS_QUEUES_PER_PAGE_VF_A 0x1014 - -#define QUEUESPERPAGEPF1_S 4 - -#define QUEUESPERPAGEPF0_S 0 -#define QUEUESPERPAGEPF0_M 0xfU -#define QUEUESPERPAGEPF0_V(x) ((x) << QUEUESPERPAGEPF0_S) -#define QUEUESPERPAGEPF0_G(x) (((x) >> QUEUESPERPAGEPF0_S) & QUEUESPERPAGEPF0_M) - -#define SGE_INT_CAUSE1_A 0x1024 -#define SGE_INT_CAUSE2_A 0x1030 -#define SGE_INT_CAUSE3_A 0x103c - -#define ERR_FLM_DBP_S 31 -#define ERR_FLM_DBP_V(x) ((x) << ERR_FLM_DBP_S) -#define ERR_FLM_DBP_F ERR_FLM_DBP_V(1U) - -#define ERR_FLM_IDMA1_S 30 -#define ERR_FLM_IDMA1_V(x) ((x) << ERR_FLM_IDMA1_S) -#define ERR_FLM_IDMA1_F ERR_FLM_IDMA1_V(1U) - -#define ERR_FLM_IDMA0_S 29 -#define ERR_FLM_IDMA0_V(x) ((x) << ERR_FLM_IDMA0_S) -#define ERR_FLM_IDMA0_F ERR_FLM_IDMA0_V(1U) - -#define ERR_FLM_HINT_S 28 -#define ERR_FLM_HINT_V(x) ((x) << ERR_FLM_HINT_S) -#define ERR_FLM_HINT_F ERR_FLM_HINT_V(1U) - -#define ERR_PCIE_ERROR3_S 27 -#define ERR_PCIE_ERROR3_V(x) ((x) << ERR_PCIE_ERROR3_S) -#define ERR_PCIE_ERROR3_F ERR_PCIE_ERROR3_V(1U) - -#define ERR_PCIE_ERROR2_S 26 -#define ERR_PCIE_ERROR2_V(x) ((x) << ERR_PCIE_ERROR2_S) -#define ERR_PCIE_ERROR2_F ERR_PCIE_ERROR2_V(1U) - -#define ERR_PCIE_ERROR1_S 25 -#define ERR_PCIE_ERROR1_V(x) ((x) << ERR_PCIE_ERROR1_S) -#define ERR_PCIE_ERROR1_F ERR_PCIE_ERROR1_V(1U) - -#define ERR_PCIE_ERROR0_S 24 -#define ERR_PCIE_ERROR0_V(x) ((x) << ERR_PCIE_ERROR0_S) -#define ERR_PCIE_ERROR0_F ERR_PCIE_ERROR0_V(1U) - -#define ERR_CPL_EXCEED_IQE_SIZE_S 22 -#define ERR_CPL_EXCEED_IQE_SIZE_V(x) ((x) << ERR_CPL_EXCEED_IQE_SIZE_S) -#define ERR_CPL_EXCEED_IQE_SIZE_F ERR_CPL_EXCEED_IQE_SIZE_V(1U) - -#define ERR_INVALID_CIDX_INC_S 21 -#define ERR_INVALID_CIDX_INC_V(x) ((x) << ERR_INVALID_CIDX_INC_S) -#define ERR_INVALID_CIDX_INC_F ERR_INVALID_CIDX_INC_V(1U) - -#define ERR_CPL_OPCODE_0_S 19 -#define ERR_CPL_OPCODE_0_V(x) ((x) << ERR_CPL_OPCODE_0_S) -#define ERR_CPL_OPCODE_0_F ERR_CPL_OPCODE_0_V(1U) - -#define ERR_DROPPED_DB_S 18 -#define ERR_DROPPED_DB_V(x) ((x) << ERR_DROPPED_DB_S) -#define ERR_DROPPED_DB_F ERR_DROPPED_DB_V(1U) - -#define ERR_DATA_CPL_ON_HIGH_QID1_S 17 -#define ERR_DATA_CPL_ON_HIGH_QID1_V(x) ((x) << ERR_DATA_CPL_ON_HIGH_QID1_S) -#define ERR_DATA_CPL_ON_HIGH_QID1_F ERR_DATA_CPL_ON_HIGH_QID1_V(1U) - -#define ERR_DATA_CPL_ON_HIGH_QID0_S 16 -#define ERR_DATA_CPL_ON_HIGH_QID0_V(x) ((x) << ERR_DATA_CPL_ON_HIGH_QID0_S) -#define ERR_DATA_CPL_ON_HIGH_QID0_F ERR_DATA_CPL_ON_HIGH_QID0_V(1U) - -#define ERR_BAD_DB_PIDX3_S 15 -#define ERR_BAD_DB_PIDX3_V(x) ((x) << ERR_BAD_DB_PIDX3_S) -#define ERR_BAD_DB_PIDX3_F ERR_BAD_DB_PIDX3_V(1U) - -#define ERR_BAD_DB_PIDX2_S 14 -#define ERR_BAD_DB_PIDX2_V(x) ((x) << ERR_BAD_DB_PIDX2_S) -#define ERR_BAD_DB_PIDX2_F ERR_BAD_DB_PIDX2_V(1U) - -#define ERR_BAD_DB_PIDX1_S 13 -#define ERR_BAD_DB_PIDX1_V(x) ((x) << ERR_BAD_DB_PIDX1_S) -#define ERR_BAD_DB_PIDX1_F ERR_BAD_DB_PIDX1_V(1U) - -#define ERR_BAD_DB_PIDX0_S 12 -#define ERR_BAD_DB_PIDX0_V(x) ((x) << ERR_BAD_DB_PIDX0_S) -#define ERR_BAD_DB_PIDX0_F ERR_BAD_DB_PIDX0_V(1U) - -#define ERR_ING_CTXT_PRIO_S 10 -#define ERR_ING_CTXT_PRIO_V(x) ((x) << ERR_ING_CTXT_PRIO_S) -#define ERR_ING_CTXT_PRIO_F ERR_ING_CTXT_PRIO_V(1U) - -#define ERR_EGR_CTXT_PRIO_S 9 -#define ERR_EGR_CTXT_PRIO_V(x) ((x) << ERR_EGR_CTXT_PRIO_S) -#define ERR_EGR_CTXT_PRIO_F ERR_EGR_CTXT_PRIO_V(1U) - -#define DBFIFO_HP_INT_S 8 -#define DBFIFO_HP_INT_V(x) ((x) << DBFIFO_HP_INT_S) -#define DBFIFO_HP_INT_F DBFIFO_HP_INT_V(1U) - -#define DBFIFO_LP_INT_S 7 -#define DBFIFO_LP_INT_V(x) ((x) << DBFIFO_LP_INT_S) -#define DBFIFO_LP_INT_F DBFIFO_LP_INT_V(1U) - -#define INGRESS_SIZE_ERR_S 5 -#define INGRESS_SIZE_ERR_V(x) ((x) << INGRESS_SIZE_ERR_S) -#define INGRESS_SIZE_ERR_F INGRESS_SIZE_ERR_V(1U) - -#define EGRESS_SIZE_ERR_S 4 -#define EGRESS_SIZE_ERR_V(x) ((x) << EGRESS_SIZE_ERR_S) -#define EGRESS_SIZE_ERR_F EGRESS_SIZE_ERR_V(1U) - -#define SGE_INT_ENABLE3_A 0x1040 -#define SGE_FL_BUFFER_SIZE0_A 0x1044 -#define SGE_FL_BUFFER_SIZE1_A 0x1048 -#define SGE_FL_BUFFER_SIZE2_A 0x104c -#define SGE_FL_BUFFER_SIZE3_A 0x1050 -#define SGE_FL_BUFFER_SIZE4_A 0x1054 -#define SGE_FL_BUFFER_SIZE5_A 0x1058 -#define SGE_FL_BUFFER_SIZE6_A 0x105c -#define SGE_FL_BUFFER_SIZE7_A 0x1060 -#define SGE_FL_BUFFER_SIZE8_A 0x1064 - -#define SGE_IMSG_CTXT_BADDR_A 0x1088 -#define SGE_FLM_CACHE_BADDR_A 0x108c -#define SGE_INGRESS_RX_THRESHOLD_A 0x10a0 - -#define THRESHOLD_0_S 24 -#define THRESHOLD_0_M 0x3fU -#define THRESHOLD_0_V(x) ((x) << THRESHOLD_0_S) -#define THRESHOLD_0_G(x) (((x) >> THRESHOLD_0_S) & THRESHOLD_0_M) - -#define THRESHOLD_1_S 16 -#define THRESHOLD_1_M 0x3fU -#define THRESHOLD_1_V(x) ((x) << THRESHOLD_1_S) -#define THRESHOLD_1_G(x) (((x) >> THRESHOLD_1_S) & THRESHOLD_1_M) - -#define THRESHOLD_2_S 8 -#define THRESHOLD_2_M 0x3fU -#define THRESHOLD_2_V(x) ((x) << THRESHOLD_2_S) -#define THRESHOLD_2_G(x) (((x) >> THRESHOLD_2_S) & THRESHOLD_2_M) - -#define THRESHOLD_3_S 0 -#define THRESHOLD_3_M 0x3fU -#define THRESHOLD_3_V(x) ((x) << THRESHOLD_3_S) -#define THRESHOLD_3_G(x) (((x) >> THRESHOLD_3_S) & THRESHOLD_3_M) - -#define SGE_CONM_CTRL_A 0x1094 - -#define EGRTHRESHOLD_S 8 -#define EGRTHRESHOLD_M 0x3fU -#define EGRTHRESHOLD_V(x) ((x) << EGRTHRESHOLD_S) -#define EGRTHRESHOLD_G(x) (((x) >> EGRTHRESHOLD_S) & EGRTHRESHOLD_M) - -#define EGRTHRESHOLDPACKING_S 14 -#define EGRTHRESHOLDPACKING_M 0x3fU -#define EGRTHRESHOLDPACKING_V(x) ((x) << EGRTHRESHOLDPACKING_S) -#define EGRTHRESHOLDPACKING_G(x) \ - (((x) >> EGRTHRESHOLDPACKING_S) & EGRTHRESHOLDPACKING_M) - -#define T6_EGRTHRESHOLDPACKING_S 16 -#define T6_EGRTHRESHOLDPACKING_M 0xffU -#define T6_EGRTHRESHOLDPACKING_G(x) \ - (((x) >> T6_EGRTHRESHOLDPACKING_S) & T6_EGRTHRESHOLDPACKING_M) - -#define SGE_TIMESTAMP_LO_A 0x1098 -#define SGE_TIMESTAMP_HI_A 0x109c - -#define TSOP_S 28 -#define TSOP_M 0x3U -#define TSOP_V(x) ((x) << TSOP_S) -#define TSOP_G(x) (((x) >> TSOP_S) & TSOP_M) - -#define TSVAL_S 0 -#define TSVAL_M 0xfffffffU -#define TSVAL_V(x) ((x) << TSVAL_S) -#define TSVAL_G(x) (((x) >> TSVAL_S) & TSVAL_M) - -#define SGE_DBFIFO_STATUS_A 0x10a4 -#define SGE_DBVFIFO_SIZE_A 0x113c - -#define HP_INT_THRESH_S 28 -#define HP_INT_THRESH_M 0xfU -#define HP_INT_THRESH_V(x) ((x) << HP_INT_THRESH_S) - -#define LP_INT_THRESH_S 12 -#define LP_INT_THRESH_M 0xfU -#define LP_INT_THRESH_V(x) ((x) << LP_INT_THRESH_S) - -#define SGE_DOORBELL_CONTROL_A 0x10a8 - -#define NOCOALESCE_S 26 -#define NOCOALESCE_V(x) ((x) << NOCOALESCE_S) -#define NOCOALESCE_F NOCOALESCE_V(1U) - -#define ENABLE_DROP_S 13 -#define ENABLE_DROP_V(x) ((x) << ENABLE_DROP_S) -#define ENABLE_DROP_F ENABLE_DROP_V(1U) - -#define SGE_TIMER_VALUE_0_AND_1_A 0x10b8 - -#define TIMERVALUE0_S 16 -#define TIMERVALUE0_M 0xffffU -#define TIMERVALUE0_V(x) ((x) << TIMERVALUE0_S) -#define TIMERVALUE0_G(x) (((x) >> TIMERVALUE0_S) & TIMERVALUE0_M) - -#define TIMERVALUE1_S 0 -#define TIMERVALUE1_M 0xffffU -#define TIMERVALUE1_V(x) ((x) << TIMERVALUE1_S) -#define TIMERVALUE1_G(x) (((x) >> TIMERVALUE1_S) & TIMERVALUE1_M) - -#define SGE_TIMER_VALUE_2_AND_3_A 0x10bc - -#define TIMERVALUE2_S 16 -#define TIMERVALUE2_M 0xffffU -#define TIMERVALUE2_V(x) ((x) << TIMERVALUE2_S) -#define TIMERVALUE2_G(x) (((x) >> TIMERVALUE2_S) & TIMERVALUE2_M) - -#define TIMERVALUE3_S 0 -#define TIMERVALUE3_M 0xffffU -#define TIMERVALUE3_V(x) ((x) << TIMERVALUE3_S) -#define TIMERVALUE3_G(x) (((x) >> TIMERVALUE3_S) & TIMERVALUE3_M) - -#define SGE_TIMER_VALUE_4_AND_5_A 0x10c0 - -#define TIMERVALUE4_S 16 -#define TIMERVALUE4_M 0xffffU -#define TIMERVALUE4_V(x) ((x) << TIMERVALUE4_S) -#define TIMERVALUE4_G(x) (((x) >> TIMERVALUE4_S) & TIMERVALUE4_M) - -#define TIMERVALUE5_S 0 -#define TIMERVALUE5_M 0xffffU -#define TIMERVALUE5_V(x) ((x) << TIMERVALUE5_S) -#define TIMERVALUE5_G(x) (((x) >> TIMERVALUE5_S) & TIMERVALUE5_M) - -#define SGE_DEBUG_INDEX_A 0x10cc -#define SGE_DEBUG_DATA_HIGH_A 0x10d0 -#define SGE_DEBUG_DATA_LOW_A 0x10d4 - -#define SGE_DEBUG_DATA_LOW_INDEX_2_A 0x12c8 -#define SGE_DEBUG_DATA_LOW_INDEX_3_A 0x12cc -#define SGE_DEBUG_DATA_HIGH_INDEX_10_A 0x12a8 - -#define SGE_INGRESS_QUEUES_PER_PAGE_PF_A 0x10f4 -#define SGE_INGRESS_QUEUES_PER_PAGE_VF_A 0x10f8 - -#define SGE_ERROR_STATS_A 0x1100 - -#define UNCAPTURED_ERROR_S 18 -#define UNCAPTURED_ERROR_V(x) ((x) << UNCAPTURED_ERROR_S) -#define UNCAPTURED_ERROR_F UNCAPTURED_ERROR_V(1U) - -#define ERROR_QID_VALID_S 17 -#define ERROR_QID_VALID_V(x) ((x) << ERROR_QID_VALID_S) -#define ERROR_QID_VALID_F ERROR_QID_VALID_V(1U) - -#define ERROR_QID_S 0 -#define ERROR_QID_M 0x1ffffU -#define ERROR_QID_G(x) (((x) >> ERROR_QID_S) & ERROR_QID_M) - -#define HP_INT_THRESH_S 28 -#define HP_INT_THRESH_M 0xfU -#define HP_INT_THRESH_V(x) ((x) << HP_INT_THRESH_S) - -#define HP_COUNT_S 16 -#define HP_COUNT_M 0x7ffU -#define HP_COUNT_G(x) (((x) >> HP_COUNT_S) & HP_COUNT_M) - -#define LP_INT_THRESH_S 12 -#define LP_INT_THRESH_M 0xfU -#define LP_INT_THRESH_V(x) ((x) << LP_INT_THRESH_S) - -#define LP_COUNT_S 0 -#define LP_COUNT_M 0x7ffU -#define LP_COUNT_G(x) (((x) >> LP_COUNT_S) & LP_COUNT_M) - -#define LP_INT_THRESH_T5_S 18 -#define LP_INT_THRESH_T5_M 0xfffU -#define LP_INT_THRESH_T5_V(x) ((x) << LP_INT_THRESH_T5_S) - -#define LP_COUNT_T5_S 0 -#define LP_COUNT_T5_M 0x3ffffU -#define LP_COUNT_T5_G(x) (((x) >> LP_COUNT_T5_S) & LP_COUNT_T5_M) - -#define SGE_DOORBELL_CONTROL_A 0x10a8 - -#define SGE_STAT_TOTAL_A 0x10e4 -#define SGE_STAT_MATCH_A 0x10e8 -#define SGE_STAT_CFG_A 0x10ec - -#define STATMODE_S 2 -#define STATMODE_V(x) ((x) << STATMODE_S) - -#define STATSOURCE_T5_S 9 -#define STATSOURCE_T5_M 0xfU -#define STATSOURCE_T5_V(x) ((x) << STATSOURCE_T5_S) -#define STATSOURCE_T5_G(x) (((x) >> STATSOURCE_T5_S) & STATSOURCE_T5_M) - -#define T6_STATMODE_S 0 -#define T6_STATMODE_V(x) ((x) << T6_STATMODE_S) - -#define SGE_DBFIFO_STATUS2_A 0x1118 - -#define HP_INT_THRESH_T5_S 10 -#define HP_INT_THRESH_T5_M 0xfU -#define HP_INT_THRESH_T5_V(x) ((x) << HP_INT_THRESH_T5_S) - -#define HP_COUNT_T5_S 0 -#define HP_COUNT_T5_M 0x3ffU -#define HP_COUNT_T5_G(x) (((x) >> HP_COUNT_T5_S) & HP_COUNT_T5_M) - -#define ENABLE_DROP_S 13 -#define ENABLE_DROP_V(x) ((x) << ENABLE_DROP_S) -#define ENABLE_DROP_F ENABLE_DROP_V(1U) - -#define DROPPED_DB_S 0 -#define DROPPED_DB_V(x) ((x) << DROPPED_DB_S) -#define DROPPED_DB_F DROPPED_DB_V(1U) - -#define SGE_CTXT_CMD_A 0x11fc -#define SGE_DBQ_CTXT_BADDR_A 0x1084 - -/* registers for module PCIE */ -#define PCIE_PF_CFG_A 0x40 - -#define AIVEC_S 4 -#define AIVEC_M 0x3ffU -#define AIVEC_V(x) ((x) << AIVEC_S) - -#define PCIE_PF_CLI_A 0x44 -#define PCIE_INT_CAUSE_A 0x3004 - -#define UNXSPLCPLERR_S 29 -#define UNXSPLCPLERR_V(x) ((x) << UNXSPLCPLERR_S) -#define UNXSPLCPLERR_F UNXSPLCPLERR_V(1U) - -#define PCIEPINT_S 28 -#define PCIEPINT_V(x) ((x) << PCIEPINT_S) -#define PCIEPINT_F PCIEPINT_V(1U) - -#define PCIESINT_S 27 -#define PCIESINT_V(x) ((x) << PCIESINT_S) -#define PCIESINT_F PCIESINT_V(1U) - -#define RPLPERR_S 26 -#define RPLPERR_V(x) ((x) << RPLPERR_S) -#define RPLPERR_F RPLPERR_V(1U) - -#define RXWRPERR_S 25 -#define RXWRPERR_V(x) ((x) << RXWRPERR_S) -#define RXWRPERR_F RXWRPERR_V(1U) - -#define RXCPLPERR_S 24 -#define RXCPLPERR_V(x) ((x) << RXCPLPERR_S) -#define RXCPLPERR_F RXCPLPERR_V(1U) - -#define PIOTAGPERR_S 23 -#define PIOTAGPERR_V(x) ((x) << PIOTAGPERR_S) -#define PIOTAGPERR_F PIOTAGPERR_V(1U) - -#define MATAGPERR_S 22 -#define MATAGPERR_V(x) ((x) << MATAGPERR_S) -#define MATAGPERR_F MATAGPERR_V(1U) - -#define INTXCLRPERR_S 21 -#define INTXCLRPERR_V(x) ((x) << INTXCLRPERR_S) -#define INTXCLRPERR_F INTXCLRPERR_V(1U) - -#define FIDPERR_S 20 -#define FIDPERR_V(x) ((x) << FIDPERR_S) -#define FIDPERR_F FIDPERR_V(1U) - -#define CFGSNPPERR_S 19 -#define CFGSNPPERR_V(x) ((x) << CFGSNPPERR_S) -#define CFGSNPPERR_F CFGSNPPERR_V(1U) - -#define HRSPPERR_S 18 -#define HRSPPERR_V(x) ((x) << HRSPPERR_S) -#define HRSPPERR_F HRSPPERR_V(1U) - -#define HREQPERR_S 17 -#define HREQPERR_V(x) ((x) << HREQPERR_S) -#define HREQPERR_F HREQPERR_V(1U) - -#define HCNTPERR_S 16 -#define HCNTPERR_V(x) ((x) << HCNTPERR_S) -#define HCNTPERR_F HCNTPERR_V(1U) - -#define DRSPPERR_S 15 -#define DRSPPERR_V(x) ((x) << DRSPPERR_S) -#define DRSPPERR_F DRSPPERR_V(1U) - -#define DREQPERR_S 14 -#define DREQPERR_V(x) ((x) << DREQPERR_S) -#define DREQPERR_F DREQPERR_V(1U) - -#define DCNTPERR_S 13 -#define DCNTPERR_V(x) ((x) << DCNTPERR_S) -#define DCNTPERR_F DCNTPERR_V(1U) - -#define CRSPPERR_S 12 -#define CRSPPERR_V(x) ((x) << CRSPPERR_S) -#define CRSPPERR_F CRSPPERR_V(1U) - -#define CREQPERR_S 11 -#define CREQPERR_V(x) ((x) << CREQPERR_S) -#define CREQPERR_F CREQPERR_V(1U) - -#define CCNTPERR_S 10 -#define CCNTPERR_V(x) ((x) << CCNTPERR_S) -#define CCNTPERR_F CCNTPERR_V(1U) - -#define TARTAGPERR_S 9 -#define TARTAGPERR_V(x) ((x) << TARTAGPERR_S) -#define TARTAGPERR_F TARTAGPERR_V(1U) - -#define PIOREQPERR_S 8 -#define PIOREQPERR_V(x) ((x) << PIOREQPERR_S) -#define PIOREQPERR_F PIOREQPERR_V(1U) - -#define PIOCPLPERR_S 7 -#define PIOCPLPERR_V(x) ((x) << PIOCPLPERR_S) -#define PIOCPLPERR_F PIOCPLPERR_V(1U) - -#define MSIXDIPERR_S 6 -#define MSIXDIPERR_V(x) ((x) << MSIXDIPERR_S) -#define MSIXDIPERR_F MSIXDIPERR_V(1U) - -#define MSIXDATAPERR_S 5 -#define MSIXDATAPERR_V(x) ((x) << MSIXDATAPERR_S) -#define MSIXDATAPERR_F MSIXDATAPERR_V(1U) - -#define MSIXADDRHPERR_S 4 -#define MSIXADDRHPERR_V(x) ((x) << MSIXADDRHPERR_S) -#define MSIXADDRHPERR_F MSIXADDRHPERR_V(1U) - -#define MSIXADDRLPERR_S 3 -#define MSIXADDRLPERR_V(x) ((x) << MSIXADDRLPERR_S) -#define MSIXADDRLPERR_F MSIXADDRLPERR_V(1U) - -#define MSIDATAPERR_S 2 -#define MSIDATAPERR_V(x) ((x) << MSIDATAPERR_S) -#define MSIDATAPERR_F MSIDATAPERR_V(1U) - -#define MSIADDRHPERR_S 1 -#define MSIADDRHPERR_V(x) ((x) << MSIADDRHPERR_S) -#define MSIADDRHPERR_F MSIADDRHPERR_V(1U) - -#define MSIADDRLPERR_S 0 -#define MSIADDRLPERR_V(x) ((x) << MSIADDRLPERR_S) -#define MSIADDRLPERR_F MSIADDRLPERR_V(1U) - -#define READRSPERR_S 29 -#define READRSPERR_V(x) ((x) << READRSPERR_S) -#define READRSPERR_F READRSPERR_V(1U) - -#define TRGT1GRPPERR_S 28 -#define TRGT1GRPPERR_V(x) ((x) << TRGT1GRPPERR_S) -#define TRGT1GRPPERR_F TRGT1GRPPERR_V(1U) - -#define IPSOTPERR_S 27 -#define IPSOTPERR_V(x) ((x) << IPSOTPERR_S) -#define IPSOTPERR_F IPSOTPERR_V(1U) - -#define IPRETRYPERR_S 26 -#define IPRETRYPERR_V(x) ((x) << IPRETRYPERR_S) -#define IPRETRYPERR_F IPRETRYPERR_V(1U) - -#define IPRXDATAGRPPERR_S 25 -#define IPRXDATAGRPPERR_V(x) ((x) << IPRXDATAGRPPERR_S) -#define IPRXDATAGRPPERR_F IPRXDATAGRPPERR_V(1U) - -#define IPRXHDRGRPPERR_S 24 -#define IPRXHDRGRPPERR_V(x) ((x) << IPRXHDRGRPPERR_S) -#define IPRXHDRGRPPERR_F IPRXHDRGRPPERR_V(1U) - -#define MAGRPPERR_S 22 -#define MAGRPPERR_V(x) ((x) << MAGRPPERR_S) -#define MAGRPPERR_F MAGRPPERR_V(1U) - -#define VFIDPERR_S 21 -#define VFIDPERR_V(x) ((x) << VFIDPERR_S) -#define VFIDPERR_F VFIDPERR_V(1U) - -#define HREQWRPERR_S 16 -#define HREQWRPERR_V(x) ((x) << HREQWRPERR_S) -#define HREQWRPERR_F HREQWRPERR_V(1U) - -#define DREQWRPERR_S 13 -#define DREQWRPERR_V(x) ((x) << DREQWRPERR_S) -#define DREQWRPERR_F DREQWRPERR_V(1U) - -#define CREQRDPERR_S 11 -#define CREQRDPERR_V(x) ((x) << CREQRDPERR_S) -#define CREQRDPERR_F CREQRDPERR_V(1U) - -#define MSTTAGQPERR_S 10 -#define MSTTAGQPERR_V(x) ((x) << MSTTAGQPERR_S) -#define MSTTAGQPERR_F MSTTAGQPERR_V(1U) - -#define PIOREQGRPPERR_S 8 -#define PIOREQGRPPERR_V(x) ((x) << PIOREQGRPPERR_S) -#define PIOREQGRPPERR_F PIOREQGRPPERR_V(1U) - -#define PIOCPLGRPPERR_S 7 -#define PIOCPLGRPPERR_V(x) ((x) << PIOCPLGRPPERR_S) -#define PIOCPLGRPPERR_F PIOCPLGRPPERR_V(1U) - -#define MSIXSTIPERR_S 2 -#define MSIXSTIPERR_V(x) ((x) << MSIXSTIPERR_S) -#define MSIXSTIPERR_F MSIXSTIPERR_V(1U) - -#define MSTTIMEOUTPERR_S 1 -#define MSTTIMEOUTPERR_V(x) ((x) << MSTTIMEOUTPERR_S) -#define MSTTIMEOUTPERR_F MSTTIMEOUTPERR_V(1U) - -#define MSTGRPPERR_S 0 -#define MSTGRPPERR_V(x) ((x) << MSTGRPPERR_S) -#define MSTGRPPERR_F MSTGRPPERR_V(1U) - -#define PCIE_NONFAT_ERR_A 0x3010 -#define PCIE_CFG_SPACE_REQ_A 0x3060 -#define PCIE_CFG_SPACE_DATA_A 0x3064 -#define PCIE_MEM_ACCESS_BASE_WIN_A 0x3068 - -#define PCIEOFST_S 10 -#define PCIEOFST_M 0x3fffffU -#define PCIEOFST_G(x) (((x) >> PCIEOFST_S) & PCIEOFST_M) - -#define BIR_S 8 -#define BIR_M 0x3U -#define BIR_V(x) ((x) << BIR_S) -#define BIR_G(x) (((x) >> BIR_S) & BIR_M) - -#define WINDOW_S 0 -#define WINDOW_M 0xffU -#define WINDOW_V(x) ((x) << WINDOW_S) -#define WINDOW_G(x) (((x) >> WINDOW_S) & WINDOW_M) - -#define PCIE_MEM_ACCESS_OFFSET_A 0x306c - -#define ENABLE_S 30 -#define ENABLE_V(x) ((x) << ENABLE_S) -#define ENABLE_F ENABLE_V(1U) - -#define LOCALCFG_S 28 -#define LOCALCFG_V(x) ((x) << LOCALCFG_S) -#define LOCALCFG_F LOCALCFG_V(1U) - -#define FUNCTION_S 12 -#define FUNCTION_V(x) ((x) << FUNCTION_S) - -#define REGISTER_S 0 -#define REGISTER_V(x) ((x) << REGISTER_S) - -#define T6_ENABLE_S 31 -#define T6_ENABLE_V(x) ((x) << T6_ENABLE_S) -#define T6_ENABLE_F T6_ENABLE_V(1U) - -#define PFNUM_S 0 -#define PFNUM_V(x) ((x) << PFNUM_S) - -#define PCIE_FW_A 0x30b8 -#define PCIE_FW_PF_A 0x30bc - -#define PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS_A 0x5908 - -#define RNPP_S 31 -#define RNPP_V(x) ((x) << RNPP_S) -#define RNPP_F RNPP_V(1U) - -#define RPCP_S 29 -#define RPCP_V(x) ((x) << RPCP_S) -#define RPCP_F RPCP_V(1U) - -#define RCIP_S 27 -#define RCIP_V(x) ((x) << RCIP_S) -#define RCIP_F RCIP_V(1U) - -#define RCCP_S 26 -#define RCCP_V(x) ((x) << RCCP_S) -#define RCCP_F RCCP_V(1U) - -#define RFTP_S 23 -#define RFTP_V(x) ((x) << RFTP_S) -#define RFTP_F RFTP_V(1U) - -#define PTRP_S 20 -#define PTRP_V(x) ((x) << PTRP_S) -#define PTRP_F PTRP_V(1U) - -#define PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS_A 0x59a4 - -#define TPCP_S 30 -#define TPCP_V(x) ((x) << TPCP_S) -#define TPCP_F TPCP_V(1U) - -#define TNPP_S 29 -#define TNPP_V(x) ((x) << TNPP_S) -#define TNPP_F TNPP_V(1U) - -#define TFTP_S 28 -#define TFTP_V(x) ((x) << TFTP_S) -#define TFTP_F TFTP_V(1U) - -#define TCAP_S 27 -#define TCAP_V(x) ((x) << TCAP_S) -#define TCAP_F TCAP_V(1U) - -#define TCIP_S 26 -#define TCIP_V(x) ((x) << TCIP_S) -#define TCIP_F TCIP_V(1U) - -#define RCAP_S 25 -#define RCAP_V(x) ((x) << RCAP_S) -#define RCAP_F RCAP_V(1U) - -#define PLUP_S 23 -#define PLUP_V(x) ((x) << PLUP_S) -#define PLUP_F PLUP_V(1U) - -#define PLDN_S 22 -#define PLDN_V(x) ((x) << PLDN_S) -#define PLDN_F PLDN_V(1U) - -#define OTDD_S 21 -#define OTDD_V(x) ((x) << OTDD_S) -#define OTDD_F OTDD_V(1U) - -#define GTRP_S 20 -#define GTRP_V(x) ((x) << GTRP_S) -#define GTRP_F GTRP_V(1U) - -#define RDPE_S 18 -#define RDPE_V(x) ((x) << RDPE_S) -#define RDPE_F RDPE_V(1U) - -#define TDCE_S 17 -#define TDCE_V(x) ((x) << TDCE_S) -#define TDCE_F TDCE_V(1U) - -#define TDUE_S 16 -#define TDUE_V(x) ((x) << TDUE_S) -#define TDUE_F TDUE_V(1U) - -/* registers for module MC */ -#define MC_INT_CAUSE_A 0x7518 -#define MC_P_INT_CAUSE_A 0x41318 - -#define ECC_UE_INT_CAUSE_S 2 -#define ECC_UE_INT_CAUSE_V(x) ((x) << ECC_UE_INT_CAUSE_S) -#define ECC_UE_INT_CAUSE_F ECC_UE_INT_CAUSE_V(1U) - -#define ECC_CE_INT_CAUSE_S 1 -#define ECC_CE_INT_CAUSE_V(x) ((x) << ECC_CE_INT_CAUSE_S) -#define ECC_CE_INT_CAUSE_F ECC_CE_INT_CAUSE_V(1U) - -#define PERR_INT_CAUSE_S 0 -#define PERR_INT_CAUSE_V(x) ((x) << PERR_INT_CAUSE_S) -#define PERR_INT_CAUSE_F PERR_INT_CAUSE_V(1U) - -#define MC_ECC_STATUS_A 0x751c -#define MC_P_ECC_STATUS_A 0x4131c - -#define ECC_CECNT_S 16 -#define ECC_CECNT_M 0xffffU -#define ECC_CECNT_V(x) ((x) << ECC_CECNT_S) -#define ECC_CECNT_G(x) (((x) >> ECC_CECNT_S) & ECC_CECNT_M) - -#define ECC_UECNT_S 0 -#define ECC_UECNT_M 0xffffU -#define ECC_UECNT_V(x) ((x) << ECC_UECNT_S) -#define ECC_UECNT_G(x) (((x) >> ECC_UECNT_S) & ECC_UECNT_M) - -#define MC_BIST_CMD_A 0x7600 - -#define START_BIST_S 31 -#define START_BIST_V(x) ((x) << START_BIST_S) -#define START_BIST_F START_BIST_V(1U) - -#define BIST_CMD_GAP_S 8 -#define BIST_CMD_GAP_V(x) ((x) << BIST_CMD_GAP_S) - -#define BIST_OPCODE_S 0 -#define BIST_OPCODE_V(x) ((x) << BIST_OPCODE_S) - -#define MC_BIST_CMD_ADDR_A 0x7604 -#define MC_BIST_CMD_LEN_A 0x7608 -#define MC_BIST_DATA_PATTERN_A 0x760c - -#define MC_BIST_STATUS_RDATA_A 0x7688 - -/* registers for module MA */ -#define MA_EDRAM0_BAR_A 0x77c0 - -#define EDRAM0_BASE_S 16 -#define EDRAM0_BASE_M 0xfffU -#define EDRAM0_BASE_G(x) (((x) >> EDRAM0_BASE_S) & EDRAM0_BASE_M) - -#define EDRAM0_SIZE_S 0 -#define EDRAM0_SIZE_M 0xfffU -#define EDRAM0_SIZE_V(x) ((x) << EDRAM0_SIZE_S) -#define EDRAM0_SIZE_G(x) (((x) >> EDRAM0_SIZE_S) & EDRAM0_SIZE_M) - -#define MA_EDRAM1_BAR_A 0x77c4 - -#define EDRAM1_BASE_S 16 -#define EDRAM1_BASE_M 0xfffU -#define EDRAM1_BASE_G(x) (((x) >> EDRAM1_BASE_S) & EDRAM1_BASE_M) - -#define EDRAM1_SIZE_S 0 -#define EDRAM1_SIZE_M 0xfffU -#define EDRAM1_SIZE_V(x) ((x) << EDRAM1_SIZE_S) -#define EDRAM1_SIZE_G(x) (((x) >> EDRAM1_SIZE_S) & EDRAM1_SIZE_M) - -#define MA_EXT_MEMORY_BAR_A 0x77c8 - -#define EXT_MEM_BASE_S 16 -#define EXT_MEM_BASE_M 0xfffU -#define EXT_MEM_BASE_V(x) ((x) << EXT_MEM_BASE_S) -#define EXT_MEM_BASE_G(x) (((x) >> EXT_MEM_BASE_S) & EXT_MEM_BASE_M) - -#define EXT_MEM_SIZE_S 0 -#define EXT_MEM_SIZE_M 0xfffU -#define EXT_MEM_SIZE_V(x) ((x) << EXT_MEM_SIZE_S) -#define EXT_MEM_SIZE_G(x) (((x) >> EXT_MEM_SIZE_S) & EXT_MEM_SIZE_M) - -#define MA_EXT_MEMORY1_BAR_A 0x7808 - -#define EXT_MEM1_BASE_S 16 -#define EXT_MEM1_BASE_M 0xfffU -#define EXT_MEM1_BASE_G(x) (((x) >> EXT_MEM1_BASE_S) & EXT_MEM1_BASE_M) - -#define EXT_MEM1_SIZE_S 0 -#define EXT_MEM1_SIZE_M 0xfffU -#define EXT_MEM1_SIZE_V(x) ((x) << EXT_MEM1_SIZE_S) -#define EXT_MEM1_SIZE_G(x) (((x) >> EXT_MEM1_SIZE_S) & EXT_MEM1_SIZE_M) - -#define MA_EXT_MEMORY0_BAR_A 0x77c8 - -#define EXT_MEM0_BASE_S 16 -#define EXT_MEM0_BASE_M 0xfffU -#define EXT_MEM0_BASE_G(x) (((x) >> EXT_MEM0_BASE_S) & EXT_MEM0_BASE_M) - -#define EXT_MEM0_SIZE_S 0 -#define EXT_MEM0_SIZE_M 0xfffU -#define EXT_MEM0_SIZE_V(x) ((x) << EXT_MEM0_SIZE_S) -#define EXT_MEM0_SIZE_G(x) (((x) >> EXT_MEM0_SIZE_S) & EXT_MEM0_SIZE_M) - -#define MA_TARGET_MEM_ENABLE_A 0x77d8 - -#define EXT_MEM_ENABLE_S 2 -#define EXT_MEM_ENABLE_V(x) ((x) << EXT_MEM_ENABLE_S) -#define EXT_MEM_ENABLE_F EXT_MEM_ENABLE_V(1U) - -#define EDRAM1_ENABLE_S 1 -#define EDRAM1_ENABLE_V(x) ((x) << EDRAM1_ENABLE_S) -#define EDRAM1_ENABLE_F EDRAM1_ENABLE_V(1U) - -#define EDRAM0_ENABLE_S 0 -#define EDRAM0_ENABLE_V(x) ((x) << EDRAM0_ENABLE_S) -#define EDRAM0_ENABLE_F EDRAM0_ENABLE_V(1U) - -#define EXT_MEM1_ENABLE_S 4 -#define EXT_MEM1_ENABLE_V(x) ((x) << EXT_MEM1_ENABLE_S) -#define EXT_MEM1_ENABLE_F EXT_MEM1_ENABLE_V(1U) - -#define EXT_MEM0_ENABLE_S 2 -#define EXT_MEM0_ENABLE_V(x) ((x) << EXT_MEM0_ENABLE_S) -#define EXT_MEM0_ENABLE_F EXT_MEM0_ENABLE_V(1U) - -#define MA_INT_CAUSE_A 0x77e0 - -#define MEM_PERR_INT_CAUSE_S 1 -#define MEM_PERR_INT_CAUSE_V(x) ((x) << MEM_PERR_INT_CAUSE_S) -#define MEM_PERR_INT_CAUSE_F MEM_PERR_INT_CAUSE_V(1U) - -#define MEM_WRAP_INT_CAUSE_S 0 -#define MEM_WRAP_INT_CAUSE_V(x) ((x) << MEM_WRAP_INT_CAUSE_S) -#define MEM_WRAP_INT_CAUSE_F MEM_WRAP_INT_CAUSE_V(1U) - -#define MA_INT_WRAP_STATUS_A 0x77e4 - -#define MEM_WRAP_ADDRESS_S 4 -#define MEM_WRAP_ADDRESS_M 0xfffffffU -#define MEM_WRAP_ADDRESS_G(x) (((x) >> MEM_WRAP_ADDRESS_S) & MEM_WRAP_ADDRESS_M) - -#define MEM_WRAP_CLIENT_NUM_S 0 -#define MEM_WRAP_CLIENT_NUM_M 0xfU -#define MEM_WRAP_CLIENT_NUM_G(x) \ - (((x) >> MEM_WRAP_CLIENT_NUM_S) & MEM_WRAP_CLIENT_NUM_M) - -#define MA_PARITY_ERROR_STATUS_A 0x77f4 -#define MA_PARITY_ERROR_STATUS1_A 0x77f4 -#define MA_PARITY_ERROR_STATUS2_A 0x7804 - -/* registers for module EDC_0 */ -#define EDC_0_BASE_ADDR 0x7900 - -#define EDC_BIST_CMD_A 0x7904 -#define EDC_BIST_CMD_ADDR_A 0x7908 -#define EDC_BIST_CMD_LEN_A 0x790c -#define EDC_BIST_DATA_PATTERN_A 0x7910 -#define EDC_BIST_STATUS_RDATA_A 0x7928 -#define EDC_INT_CAUSE_A 0x7978 - -#define ECC_UE_PAR_S 5 -#define ECC_UE_PAR_V(x) ((x) << ECC_UE_PAR_S) -#define ECC_UE_PAR_F ECC_UE_PAR_V(1U) - -#define ECC_CE_PAR_S 4 -#define ECC_CE_PAR_V(x) ((x) << ECC_CE_PAR_S) -#define ECC_CE_PAR_F ECC_CE_PAR_V(1U) - -#define PERR_PAR_CAUSE_S 3 -#define PERR_PAR_CAUSE_V(x) ((x) << PERR_PAR_CAUSE_S) -#define PERR_PAR_CAUSE_F PERR_PAR_CAUSE_V(1U) - -#define EDC_ECC_STATUS_A 0x797c - -/* registers for module EDC_1 */ -#define EDC_1_BASE_ADDR 0x7980 - -/* registers for module CIM */ -#define CIM_BOOT_CFG_A 0x7b00 -#define CIM_SDRAM_BASE_ADDR_A 0x7b14 -#define CIM_SDRAM_ADDR_SIZE_A 0x7b18 -#define CIM_EXTMEM2_BASE_ADDR_A 0x7b1c -#define CIM_EXTMEM2_ADDR_SIZE_A 0x7b20 -#define CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A 0x290 - -#define BOOTADDR_M 0xffffff00U - -#define UPCRST_S 0 -#define UPCRST_V(x) ((x) << UPCRST_S) -#define UPCRST_F UPCRST_V(1U) - -#define CIM_PF_MAILBOX_DATA_A 0x240 -#define CIM_PF_MAILBOX_CTRL_A 0x280 - -#define MBMSGVALID_S 3 -#define MBMSGVALID_V(x) ((x) << MBMSGVALID_S) -#define MBMSGVALID_F MBMSGVALID_V(1U) - -#define MBINTREQ_S 2 -#define MBINTREQ_V(x) ((x) << MBINTREQ_S) -#define MBINTREQ_F MBINTREQ_V(1U) - -#define MBOWNER_S 0 -#define MBOWNER_M 0x3U -#define MBOWNER_V(x) ((x) << MBOWNER_S) -#define MBOWNER_G(x) (((x) >> MBOWNER_S) & MBOWNER_M) - -#define CIM_PF_HOST_INT_ENABLE_A 0x288 - -#define MBMSGRDYINTEN_S 19 -#define MBMSGRDYINTEN_V(x) ((x) << MBMSGRDYINTEN_S) -#define MBMSGRDYINTEN_F MBMSGRDYINTEN_V(1U) - -#define CIM_PF_HOST_INT_CAUSE_A 0x28c - -#define MBMSGRDYINT_S 19 -#define MBMSGRDYINT_V(x) ((x) << MBMSGRDYINT_S) -#define MBMSGRDYINT_F MBMSGRDYINT_V(1U) - -#define CIM_HOST_INT_CAUSE_A 0x7b2c - -#define TIEQOUTPARERRINT_S 20 -#define TIEQOUTPARERRINT_V(x) ((x) << TIEQOUTPARERRINT_S) -#define TIEQOUTPARERRINT_F TIEQOUTPARERRINT_V(1U) - -#define TIEQINPARERRINT_S 19 -#define TIEQINPARERRINT_V(x) ((x) << TIEQINPARERRINT_S) -#define TIEQINPARERRINT_F TIEQINPARERRINT_V(1U) - -#define PREFDROPINT_S 1 -#define PREFDROPINT_V(x) ((x) << PREFDROPINT_S) -#define PREFDROPINT_F PREFDROPINT_V(1U) - -#define UPACCNONZERO_S 0 -#define UPACCNONZERO_V(x) ((x) << UPACCNONZERO_S) -#define UPACCNONZERO_F UPACCNONZERO_V(1U) - -#define MBHOSTPARERR_S 18 -#define MBHOSTPARERR_V(x) ((x) << MBHOSTPARERR_S) -#define MBHOSTPARERR_F MBHOSTPARERR_V(1U) - -#define MBUPPARERR_S 17 -#define MBUPPARERR_V(x) ((x) << MBUPPARERR_S) -#define MBUPPARERR_F MBUPPARERR_V(1U) - -#define IBQTP0PARERR_S 16 -#define IBQTP0PARERR_V(x) ((x) << IBQTP0PARERR_S) -#define IBQTP0PARERR_F IBQTP0PARERR_V(1U) - -#define IBQTP1PARERR_S 15 -#define IBQTP1PARERR_V(x) ((x) << IBQTP1PARERR_S) -#define IBQTP1PARERR_F IBQTP1PARERR_V(1U) - -#define IBQULPPARERR_S 14 -#define IBQULPPARERR_V(x) ((x) << IBQULPPARERR_S) -#define IBQULPPARERR_F IBQULPPARERR_V(1U) - -#define IBQSGELOPARERR_S 13 -#define IBQSGELOPARERR_V(x) ((x) << IBQSGELOPARERR_S) -#define IBQSGELOPARERR_F IBQSGELOPARERR_V(1U) - -#define IBQSGEHIPARERR_S 12 -#define IBQSGEHIPARERR_V(x) ((x) << IBQSGEHIPARERR_S) -#define IBQSGEHIPARERR_F IBQSGEHIPARERR_V(1U) - -#define IBQNCSIPARERR_S 11 -#define IBQNCSIPARERR_V(x) ((x) << IBQNCSIPARERR_S) -#define IBQNCSIPARERR_F IBQNCSIPARERR_V(1U) - -#define OBQULP0PARERR_S 10 -#define OBQULP0PARERR_V(x) ((x) << OBQULP0PARERR_S) -#define OBQULP0PARERR_F OBQULP0PARERR_V(1U) - -#define OBQULP1PARERR_S 9 -#define OBQULP1PARERR_V(x) ((x) << OBQULP1PARERR_S) -#define OBQULP1PARERR_F OBQULP1PARERR_V(1U) - -#define OBQULP2PARERR_S 8 -#define OBQULP2PARERR_V(x) ((x) << OBQULP2PARERR_S) -#define OBQULP2PARERR_F OBQULP2PARERR_V(1U) - -#define OBQULP3PARERR_S 7 -#define OBQULP3PARERR_V(x) ((x) << OBQULP3PARERR_S) -#define OBQULP3PARERR_F OBQULP3PARERR_V(1U) - -#define OBQSGEPARERR_S 6 -#define OBQSGEPARERR_V(x) ((x) << OBQSGEPARERR_S) -#define OBQSGEPARERR_F OBQSGEPARERR_V(1U) - -#define OBQNCSIPARERR_S 5 -#define OBQNCSIPARERR_V(x) ((x) << OBQNCSIPARERR_S) -#define OBQNCSIPARERR_F OBQNCSIPARERR_V(1U) - -#define CIM_HOST_UPACC_INT_CAUSE_A 0x7b34 - -#define EEPROMWRINT_S 30 -#define EEPROMWRINT_V(x) ((x) << EEPROMWRINT_S) -#define EEPROMWRINT_F EEPROMWRINT_V(1U) - -#define TIMEOUTMAINT_S 29 -#define TIMEOUTMAINT_V(x) ((x) << TIMEOUTMAINT_S) -#define TIMEOUTMAINT_F TIMEOUTMAINT_V(1U) - -#define TIMEOUTINT_S 28 -#define TIMEOUTINT_V(x) ((x) << TIMEOUTINT_S) -#define TIMEOUTINT_F TIMEOUTINT_V(1U) - -#define RSPOVRLOOKUPINT_S 27 -#define RSPOVRLOOKUPINT_V(x) ((x) << RSPOVRLOOKUPINT_S) -#define RSPOVRLOOKUPINT_F RSPOVRLOOKUPINT_V(1U) - -#define REQOVRLOOKUPINT_S 26 -#define REQOVRLOOKUPINT_V(x) ((x) << REQOVRLOOKUPINT_S) -#define REQOVRLOOKUPINT_F REQOVRLOOKUPINT_V(1U) - -#define BLKWRPLINT_S 25 -#define BLKWRPLINT_V(x) ((x) << BLKWRPLINT_S) -#define BLKWRPLINT_F BLKWRPLINT_V(1U) - -#define BLKRDPLINT_S 24 -#define BLKRDPLINT_V(x) ((x) << BLKRDPLINT_S) -#define BLKRDPLINT_F BLKRDPLINT_V(1U) - -#define SGLWRPLINT_S 23 -#define SGLWRPLINT_V(x) ((x) << SGLWRPLINT_S) -#define SGLWRPLINT_F SGLWRPLINT_V(1U) - -#define SGLRDPLINT_S 22 -#define SGLRDPLINT_V(x) ((x) << SGLRDPLINT_S) -#define SGLRDPLINT_F SGLRDPLINT_V(1U) - -#define BLKWRCTLINT_S 21 -#define BLKWRCTLINT_V(x) ((x) << BLKWRCTLINT_S) -#define BLKWRCTLINT_F BLKWRCTLINT_V(1U) - -#define BLKRDCTLINT_S 20 -#define BLKRDCTLINT_V(x) ((x) << BLKRDCTLINT_S) -#define BLKRDCTLINT_F BLKRDCTLINT_V(1U) - -#define SGLWRCTLINT_S 19 -#define SGLWRCTLINT_V(x) ((x) << SGLWRCTLINT_S) -#define SGLWRCTLINT_F SGLWRCTLINT_V(1U) - -#define SGLRDCTLINT_S 18 -#define SGLRDCTLINT_V(x) ((x) << SGLRDCTLINT_S) -#define SGLRDCTLINT_F SGLRDCTLINT_V(1U) - -#define BLKWREEPROMINT_S 17 -#define BLKWREEPROMINT_V(x) ((x) << BLKWREEPROMINT_S) -#define BLKWREEPROMINT_F BLKWREEPROMINT_V(1U) - -#define BLKRDEEPROMINT_S 16 -#define BLKRDEEPROMINT_V(x) ((x) << BLKRDEEPROMINT_S) -#define BLKRDEEPROMINT_F BLKRDEEPROMINT_V(1U) - -#define SGLWREEPROMINT_S 15 -#define SGLWREEPROMINT_V(x) ((x) << SGLWREEPROMINT_S) -#define SGLWREEPROMINT_F SGLWREEPROMINT_V(1U) - -#define SGLRDEEPROMINT_S 14 -#define SGLRDEEPROMINT_V(x) ((x) << SGLRDEEPROMINT_S) -#define SGLRDEEPROMINT_F SGLRDEEPROMINT_V(1U) - -#define BLKWRFLASHINT_S 13 -#define BLKWRFLASHINT_V(x) ((x) << BLKWRFLASHINT_S) -#define BLKWRFLASHINT_F BLKWRFLASHINT_V(1U) - -#define BLKRDFLASHINT_S 12 -#define BLKRDFLASHINT_V(x) ((x) << BLKRDFLASHINT_S) -#define BLKRDFLASHINT_F BLKRDFLASHINT_V(1U) - -#define SGLWRFLASHINT_S 11 -#define SGLWRFLASHINT_V(x) ((x) << SGLWRFLASHINT_S) -#define SGLWRFLASHINT_F SGLWRFLASHINT_V(1U) - -#define SGLRDFLASHINT_S 10 -#define SGLRDFLASHINT_V(x) ((x) << SGLRDFLASHINT_S) -#define SGLRDFLASHINT_F SGLRDFLASHINT_V(1U) - -#define BLKWRBOOTINT_S 9 -#define BLKWRBOOTINT_V(x) ((x) << BLKWRBOOTINT_S) -#define BLKWRBOOTINT_F BLKWRBOOTINT_V(1U) - -#define BLKRDBOOTINT_S 8 -#define BLKRDBOOTINT_V(x) ((x) << BLKRDBOOTINT_S) -#define BLKRDBOOTINT_F BLKRDBOOTINT_V(1U) - -#define SGLWRBOOTINT_S 7 -#define SGLWRBOOTINT_V(x) ((x) << SGLWRBOOTINT_S) -#define SGLWRBOOTINT_F SGLWRBOOTINT_V(1U) - -#define SGLRDBOOTINT_S 6 -#define SGLRDBOOTINT_V(x) ((x) << SGLRDBOOTINT_S) -#define SGLRDBOOTINT_F SGLRDBOOTINT_V(1U) - -#define ILLWRBEINT_S 5 -#define ILLWRBEINT_V(x) ((x) << ILLWRBEINT_S) -#define ILLWRBEINT_F ILLWRBEINT_V(1U) - -#define ILLRDBEINT_S 4 -#define ILLRDBEINT_V(x) ((x) << ILLRDBEINT_S) -#define ILLRDBEINT_F ILLRDBEINT_V(1U) - -#define ILLRDINT_S 3 -#define ILLRDINT_V(x) ((x) << ILLRDINT_S) -#define ILLRDINT_F ILLRDINT_V(1U) - -#define ILLWRINT_S 2 -#define ILLWRINT_V(x) ((x) << ILLWRINT_S) -#define ILLWRINT_F ILLWRINT_V(1U) - -#define ILLTRANSINT_S 1 -#define ILLTRANSINT_V(x) ((x) << ILLTRANSINT_S) -#define ILLTRANSINT_F ILLTRANSINT_V(1U) - -#define RSVDSPACEINT_S 0 -#define RSVDSPACEINT_V(x) ((x) << RSVDSPACEINT_S) -#define RSVDSPACEINT_F RSVDSPACEINT_V(1U) - -/* registers for module TP */ -#define DBGLAWHLF_S 23 -#define DBGLAWHLF_V(x) ((x) << DBGLAWHLF_S) -#define DBGLAWHLF_F DBGLAWHLF_V(1U) - -#define DBGLAWPTR_S 16 -#define DBGLAWPTR_M 0x7fU -#define DBGLAWPTR_G(x) (((x) >> DBGLAWPTR_S) & DBGLAWPTR_M) - -#define DBGLAENABLE_S 12 -#define DBGLAENABLE_V(x) ((x) << DBGLAENABLE_S) -#define DBGLAENABLE_F DBGLAENABLE_V(1U) - -#define DBGLARPTR_S 0 -#define DBGLARPTR_M 0x7fU -#define DBGLARPTR_V(x) ((x) << DBGLARPTR_S) - -#define TP_DBG_LA_DATAL_A 0x7ed8 -#define TP_DBG_LA_CONFIG_A 0x7ed4 -#define TP_OUT_CONFIG_A 0x7d04 -#define TP_GLOBAL_CONFIG_A 0x7d08 - -#define TP_CMM_TCB_BASE_A 0x7d10 -#define TP_CMM_MM_BASE_A 0x7d14 -#define TP_CMM_TIMER_BASE_A 0x7d18 -#define TP_PMM_TX_BASE_A 0x7d20 -#define TP_PMM_RX_BASE_A 0x7d28 -#define TP_PMM_RX_PAGE_SIZE_A 0x7d2c -#define TP_PMM_RX_MAX_PAGE_A 0x7d30 -#define TP_PMM_TX_PAGE_SIZE_A 0x7d34 -#define TP_PMM_TX_MAX_PAGE_A 0x7d38 -#define TP_CMM_MM_MAX_PSTRUCT_A 0x7e6c - -#define PMRXNUMCHN_S 31 -#define PMRXNUMCHN_V(x) ((x) << PMRXNUMCHN_S) -#define PMRXNUMCHN_F PMRXNUMCHN_V(1U) - -#define PMTXNUMCHN_S 30 -#define PMTXNUMCHN_M 0x3U -#define PMTXNUMCHN_G(x) (((x) >> PMTXNUMCHN_S) & PMTXNUMCHN_M) - -#define PMTXMAXPAGE_S 0 -#define PMTXMAXPAGE_M 0x1fffffU -#define PMTXMAXPAGE_G(x) (((x) >> PMTXMAXPAGE_S) & PMTXMAXPAGE_M) - -#define PMRXMAXPAGE_S 0 -#define PMRXMAXPAGE_M 0x1fffffU -#define PMRXMAXPAGE_G(x) (((x) >> PMRXMAXPAGE_S) & PMRXMAXPAGE_M) - -#define DBGLAMODE_S 14 -#define DBGLAMODE_M 0x3U -#define DBGLAMODE_G(x) (((x) >> DBGLAMODE_S) & DBGLAMODE_M) - -#define FIVETUPLELOOKUP_S 17 -#define FIVETUPLELOOKUP_M 0x3U -#define FIVETUPLELOOKUP_V(x) ((x) << FIVETUPLELOOKUP_S) -#define FIVETUPLELOOKUP_G(x) (((x) >> FIVETUPLELOOKUP_S) & FIVETUPLELOOKUP_M) - -#define TP_PARA_REG2_A 0x7d68 - -#define MAXRXDATA_S 16 -#define MAXRXDATA_M 0xffffU -#define MAXRXDATA_G(x) (((x) >> MAXRXDATA_S) & MAXRXDATA_M) - -#define TP_TIMER_RESOLUTION_A 0x7d90 - -#define TIMERRESOLUTION_S 16 -#define TIMERRESOLUTION_M 0xffU -#define TIMERRESOLUTION_G(x) (((x) >> TIMERRESOLUTION_S) & TIMERRESOLUTION_M) - -#define TIMESTAMPRESOLUTION_S 8 -#define TIMESTAMPRESOLUTION_M 0xffU -#define TIMESTAMPRESOLUTION_G(x) \ - (((x) >> TIMESTAMPRESOLUTION_S) & TIMESTAMPRESOLUTION_M) - -#define DELAYEDACKRESOLUTION_S 0 -#define DELAYEDACKRESOLUTION_M 0xffU -#define DELAYEDACKRESOLUTION_G(x) \ - (((x) >> DELAYEDACKRESOLUTION_S) & DELAYEDACKRESOLUTION_M) - -#define TP_SHIFT_CNT_A 0x7dc0 -#define TP_RXT_MIN_A 0x7d98 -#define TP_RXT_MAX_A 0x7d9c -#define TP_PERS_MIN_A 0x7da0 -#define TP_PERS_MAX_A 0x7da4 -#define TP_KEEP_IDLE_A 0x7da8 -#define TP_KEEP_INTVL_A 0x7dac -#define TP_INIT_SRTT_A 0x7db0 -#define TP_DACK_TIMER_A 0x7db4 -#define TP_FINWAIT2_TIMER_A 0x7db8 - -#define INITSRTT_S 0 -#define INITSRTT_M 0xffffU -#define INITSRTT_G(x) (((x) >> INITSRTT_S) & INITSRTT_M) - -#define PERSMAX_S 0 -#define PERSMAX_M 0x3fffffffU -#define PERSMAX_V(x) ((x) << PERSMAX_S) -#define PERSMAX_G(x) (((x) >> PERSMAX_S) & PERSMAX_M) - -#define SYNSHIFTMAX_S 24 -#define SYNSHIFTMAX_M 0xffU -#define SYNSHIFTMAX_V(x) ((x) << SYNSHIFTMAX_S) -#define SYNSHIFTMAX_G(x) (((x) >> SYNSHIFTMAX_S) & SYNSHIFTMAX_M) - -#define RXTSHIFTMAXR1_S 20 -#define RXTSHIFTMAXR1_M 0xfU -#define RXTSHIFTMAXR1_V(x) ((x) << RXTSHIFTMAXR1_S) -#define RXTSHIFTMAXR1_G(x) (((x) >> RXTSHIFTMAXR1_S) & RXTSHIFTMAXR1_M) - -#define RXTSHIFTMAXR2_S 16 -#define RXTSHIFTMAXR2_M 0xfU -#define RXTSHIFTMAXR2_V(x) ((x) << RXTSHIFTMAXR2_S) -#define RXTSHIFTMAXR2_G(x) (((x) >> RXTSHIFTMAXR2_S) & RXTSHIFTMAXR2_M) - -#define PERSHIFTBACKOFFMAX_S 12 -#define PERSHIFTBACKOFFMAX_M 0xfU -#define PERSHIFTBACKOFFMAX_V(x) ((x) << PERSHIFTBACKOFFMAX_S) -#define PERSHIFTBACKOFFMAX_G(x) \ - (((x) >> PERSHIFTBACKOFFMAX_S) & PERSHIFTBACKOFFMAX_M) - -#define PERSHIFTMAX_S 8 -#define PERSHIFTMAX_M 0xfU -#define PERSHIFTMAX_V(x) ((x) << PERSHIFTMAX_S) -#define PERSHIFTMAX_G(x) (((x) >> PERSHIFTMAX_S) & PERSHIFTMAX_M) - -#define KEEPALIVEMAXR1_S 4 -#define KEEPALIVEMAXR1_M 0xfU -#define KEEPALIVEMAXR1_V(x) ((x) << KEEPALIVEMAXR1_S) -#define KEEPALIVEMAXR1_G(x) (((x) >> KEEPALIVEMAXR1_S) & KEEPALIVEMAXR1_M) - -#define KEEPALIVEMAXR2_S 0 -#define KEEPALIVEMAXR2_M 0xfU -#define KEEPALIVEMAXR2_V(x) ((x) << KEEPALIVEMAXR2_S) -#define KEEPALIVEMAXR2_G(x) (((x) >> KEEPALIVEMAXR2_S) & KEEPALIVEMAXR2_M) - -#define ROWINDEX_S 16 -#define ROWINDEX_V(x) ((x) << ROWINDEX_S) - -#define TP_CCTRL_TABLE_A 0x7ddc -#define TP_MTU_TABLE_A 0x7de4 - -#define MTUINDEX_S 24 -#define MTUINDEX_V(x) ((x) << MTUINDEX_S) - -#define MTUWIDTH_S 16 -#define MTUWIDTH_M 0xfU -#define MTUWIDTH_V(x) ((x) << MTUWIDTH_S) -#define MTUWIDTH_G(x) (((x) >> MTUWIDTH_S) & MTUWIDTH_M) - -#define MTUVALUE_S 0 -#define MTUVALUE_M 0x3fffU -#define MTUVALUE_V(x) ((x) << MTUVALUE_S) -#define MTUVALUE_G(x) (((x) >> MTUVALUE_S) & MTUVALUE_M) - -#define TP_RSS_LKP_TABLE_A 0x7dec -#define TP_CMM_MM_RX_FLST_BASE_A 0x7e60 -#define TP_CMM_MM_TX_FLST_BASE_A 0x7e64 -#define TP_CMM_MM_PS_FLST_BASE_A 0x7e68 - -#define LKPTBLROWVLD_S 31 -#define LKPTBLROWVLD_V(x) ((x) << LKPTBLROWVLD_S) -#define LKPTBLROWVLD_F LKPTBLROWVLD_V(1U) - -#define LKPTBLQUEUE1_S 10 -#define LKPTBLQUEUE1_M 0x3ffU -#define LKPTBLQUEUE1_G(x) (((x) >> LKPTBLQUEUE1_S) & LKPTBLQUEUE1_M) - -#define LKPTBLQUEUE0_S 0 -#define LKPTBLQUEUE0_M 0x3ffU -#define LKPTBLQUEUE0_G(x) (((x) >> LKPTBLQUEUE0_S) & LKPTBLQUEUE0_M) - -#define TP_PIO_ADDR_A 0x7e40 -#define TP_PIO_DATA_A 0x7e44 -#define TP_MIB_INDEX_A 0x7e50 -#define TP_MIB_DATA_A 0x7e54 -#define TP_INT_CAUSE_A 0x7e74 - -#define FLMTXFLSTEMPTY_S 30 -#define FLMTXFLSTEMPTY_V(x) ((x) << FLMTXFLSTEMPTY_S) -#define FLMTXFLSTEMPTY_F FLMTXFLSTEMPTY_V(1U) - -#define TP_TX_ORATE_A 0x7ebc - -#define OFDRATE3_S 24 -#define OFDRATE3_M 0xffU -#define OFDRATE3_G(x) (((x) >> OFDRATE3_S) & OFDRATE3_M) - -#define OFDRATE2_S 16 -#define OFDRATE2_M 0xffU -#define OFDRATE2_G(x) (((x) >> OFDRATE2_S) & OFDRATE2_M) - -#define OFDRATE1_S 8 -#define OFDRATE1_M 0xffU -#define OFDRATE1_G(x) (((x) >> OFDRATE1_S) & OFDRATE1_M) - -#define OFDRATE0_S 0 -#define OFDRATE0_M 0xffU -#define OFDRATE0_G(x) (((x) >> OFDRATE0_S) & OFDRATE0_M) - -#define TP_TX_TRATE_A 0x7ed0 - -#define TNLRATE3_S 24 -#define TNLRATE3_M 0xffU -#define TNLRATE3_G(x) (((x) >> TNLRATE3_S) & TNLRATE3_M) - -#define TNLRATE2_S 16 -#define TNLRATE2_M 0xffU -#define TNLRATE2_G(x) (((x) >> TNLRATE2_S) & TNLRATE2_M) - -#define TNLRATE1_S 8 -#define TNLRATE1_M 0xffU -#define TNLRATE1_G(x) (((x) >> TNLRATE1_S) & TNLRATE1_M) - -#define TNLRATE0_S 0 -#define TNLRATE0_M 0xffU -#define TNLRATE0_G(x) (((x) >> TNLRATE0_S) & TNLRATE0_M) - -#define TP_VLAN_PRI_MAP_A 0x140 - -#define FRAGMENTATION_S 9 -#define FRAGMENTATION_V(x) ((x) << FRAGMENTATION_S) -#define FRAGMENTATION_F FRAGMENTATION_V(1U) - -#define MPSHITTYPE_S 8 -#define MPSHITTYPE_V(x) ((x) << MPSHITTYPE_S) -#define MPSHITTYPE_F MPSHITTYPE_V(1U) - -#define MACMATCH_S 7 -#define MACMATCH_V(x) ((x) << MACMATCH_S) -#define MACMATCH_F MACMATCH_V(1U) - -#define ETHERTYPE_S 6 -#define ETHERTYPE_V(x) ((x) << ETHERTYPE_S) -#define ETHERTYPE_F ETHERTYPE_V(1U) - -#define PROTOCOL_S 5 -#define PROTOCOL_V(x) ((x) << PROTOCOL_S) -#define PROTOCOL_F PROTOCOL_V(1U) - -#define TOS_S 4 -#define TOS_V(x) ((x) << TOS_S) -#define TOS_F TOS_V(1U) - -#define VLAN_S 3 -#define VLAN_V(x) ((x) << VLAN_S) -#define VLAN_F VLAN_V(1U) - -#define VNIC_ID_S 2 -#define VNIC_ID_V(x) ((x) << VNIC_ID_S) -#define VNIC_ID_F VNIC_ID_V(1U) - -#define PORT_S 1 -#define PORT_V(x) ((x) << PORT_S) -#define PORT_F PORT_V(1U) - -#define FCOE_S 0 -#define FCOE_V(x) ((x) << FCOE_S) -#define FCOE_F FCOE_V(1U) - -#define FILTERMODE_S 15 -#define FILTERMODE_V(x) ((x) << FILTERMODE_S) -#define FILTERMODE_F FILTERMODE_V(1U) - -#define FCOEMASK_S 14 -#define FCOEMASK_V(x) ((x) << FCOEMASK_S) -#define FCOEMASK_F FCOEMASK_V(1U) - -#define TP_INGRESS_CONFIG_A 0x141 - -#define VNIC_S 11 -#define VNIC_V(x) ((x) << VNIC_S) -#define VNIC_F VNIC_V(1U) - -#define CSUM_HAS_PSEUDO_HDR_S 10 -#define CSUM_HAS_PSEUDO_HDR_V(x) ((x) << CSUM_HAS_PSEUDO_HDR_S) -#define CSUM_HAS_PSEUDO_HDR_F CSUM_HAS_PSEUDO_HDR_V(1U) - -#define TP_MIB_MAC_IN_ERR_0_A 0x0 -#define TP_MIB_HDR_IN_ERR_0_A 0x4 -#define TP_MIB_TCP_IN_ERR_0_A 0x8 -#define TP_MIB_TCP_OUT_RST_A 0xc -#define TP_MIB_TCP_IN_SEG_HI_A 0x10 -#define TP_MIB_TCP_IN_SEG_LO_A 0x11 -#define TP_MIB_TCP_OUT_SEG_HI_A 0x12 -#define TP_MIB_TCP_OUT_SEG_LO_A 0x13 -#define TP_MIB_TCP_RXT_SEG_HI_A 0x14 -#define TP_MIB_TCP_RXT_SEG_LO_A 0x15 -#define TP_MIB_TNL_CNG_DROP_0_A 0x18 -#define TP_MIB_OFD_CHN_DROP_0_A 0x1c -#define TP_MIB_TCP_V6IN_ERR_0_A 0x28 -#define TP_MIB_TCP_V6OUT_RST_A 0x2c -#define TP_MIB_OFD_ARP_DROP_A 0x36 -#define TP_MIB_CPL_IN_REQ_0_A 0x38 -#define TP_MIB_CPL_OUT_RSP_0_A 0x3c -#define TP_MIB_TNL_DROP_0_A 0x44 -#define TP_MIB_FCOE_DDP_0_A 0x48 -#define TP_MIB_FCOE_DROP_0_A 0x4c -#define TP_MIB_FCOE_BYTE_0_HI_A 0x50 -#define TP_MIB_OFD_VLN_DROP_0_A 0x58 -#define TP_MIB_USM_PKTS_A 0x5c -#define TP_MIB_RQE_DFR_PKT_A 0x64 - -#define ULP_TX_INT_CAUSE_A 0x8dcc -#define ULP_TX_TPT_LLIMIT_A 0x8dd4 -#define ULP_TX_TPT_ULIMIT_A 0x8dd8 -#define ULP_TX_PBL_LLIMIT_A 0x8ddc -#define ULP_TX_PBL_ULIMIT_A 0x8de0 -#define ULP_TX_ERR_TABLE_BASE_A 0x8e04 - -#define PBL_BOUND_ERR_CH3_S 31 -#define PBL_BOUND_ERR_CH3_V(x) ((x) << PBL_BOUND_ERR_CH3_S) -#define PBL_BOUND_ERR_CH3_F PBL_BOUND_ERR_CH3_V(1U) - -#define PBL_BOUND_ERR_CH2_S 30 -#define PBL_BOUND_ERR_CH2_V(x) ((x) << PBL_BOUND_ERR_CH2_S) -#define PBL_BOUND_ERR_CH2_F PBL_BOUND_ERR_CH2_V(1U) - -#define PBL_BOUND_ERR_CH1_S 29 -#define PBL_BOUND_ERR_CH1_V(x) ((x) << PBL_BOUND_ERR_CH1_S) -#define PBL_BOUND_ERR_CH1_F PBL_BOUND_ERR_CH1_V(1U) - -#define PBL_BOUND_ERR_CH0_S 28 -#define PBL_BOUND_ERR_CH0_V(x) ((x) << PBL_BOUND_ERR_CH0_S) -#define PBL_BOUND_ERR_CH0_F PBL_BOUND_ERR_CH0_V(1U) - -#define PM_RX_INT_CAUSE_A 0x8fdc -#define PM_RX_STAT_CONFIG_A 0x8fc8 -#define PM_RX_STAT_COUNT_A 0x8fcc -#define PM_RX_STAT_LSB_A 0x8fd0 -#define PM_RX_DBG_CTRL_A 0x8fd0 -#define PM_RX_DBG_DATA_A 0x8fd4 -#define PM_RX_DBG_STAT_MSB_A 0x10013 - -#define PMRX_FRAMING_ERROR_F 0x003ffff0U - -#define ZERO_E_CMD_ERROR_S 22 -#define ZERO_E_CMD_ERROR_V(x) ((x) << ZERO_E_CMD_ERROR_S) -#define ZERO_E_CMD_ERROR_F ZERO_E_CMD_ERROR_V(1U) - -#define OCSPI_PAR_ERROR_S 3 -#define OCSPI_PAR_ERROR_V(x) ((x) << OCSPI_PAR_ERROR_S) -#define OCSPI_PAR_ERROR_F OCSPI_PAR_ERROR_V(1U) - -#define DB_OPTIONS_PAR_ERROR_S 2 -#define DB_OPTIONS_PAR_ERROR_V(x) ((x) << DB_OPTIONS_PAR_ERROR_S) -#define DB_OPTIONS_PAR_ERROR_F DB_OPTIONS_PAR_ERROR_V(1U) - -#define IESPI_PAR_ERROR_S 1 -#define IESPI_PAR_ERROR_V(x) ((x) << IESPI_PAR_ERROR_S) -#define IESPI_PAR_ERROR_F IESPI_PAR_ERROR_V(1U) - -#define PMRX_E_PCMD_PAR_ERROR_S 0 -#define PMRX_E_PCMD_PAR_ERROR_V(x) ((x) << PMRX_E_PCMD_PAR_ERROR_S) -#define PMRX_E_PCMD_PAR_ERROR_F PMRX_E_PCMD_PAR_ERROR_V(1U) - -#define PM_TX_INT_CAUSE_A 0x8ffc -#define PM_TX_STAT_CONFIG_A 0x8fe8 -#define PM_TX_STAT_COUNT_A 0x8fec -#define PM_TX_STAT_LSB_A 0x8ff0 -#define PM_TX_DBG_CTRL_A 0x8ff0 -#define PM_TX_DBG_DATA_A 0x8ff4 -#define PM_TX_DBG_STAT_MSB_A 0x1001a - -#define PCMD_LEN_OVFL0_S 31 -#define PCMD_LEN_OVFL0_V(x) ((x) << PCMD_LEN_OVFL0_S) -#define PCMD_LEN_OVFL0_F PCMD_LEN_OVFL0_V(1U) - -#define PCMD_LEN_OVFL1_S 30 -#define PCMD_LEN_OVFL1_V(x) ((x) << PCMD_LEN_OVFL1_S) -#define PCMD_LEN_OVFL1_F PCMD_LEN_OVFL1_V(1U) - -#define PCMD_LEN_OVFL2_S 29 -#define PCMD_LEN_OVFL2_V(x) ((x) << PCMD_LEN_OVFL2_S) -#define PCMD_LEN_OVFL2_F PCMD_LEN_OVFL2_V(1U) - -#define ZERO_C_CMD_ERROR_S 28 -#define ZERO_C_CMD_ERROR_V(x) ((x) << ZERO_C_CMD_ERROR_S) -#define ZERO_C_CMD_ERROR_F ZERO_C_CMD_ERROR_V(1U) - -#define PMTX_FRAMING_ERROR_F 0x0ffffff0U - -#define OESPI_PAR_ERROR_S 3 -#define OESPI_PAR_ERROR_V(x) ((x) << OESPI_PAR_ERROR_S) -#define OESPI_PAR_ERROR_F OESPI_PAR_ERROR_V(1U) - -#define ICSPI_PAR_ERROR_S 1 -#define ICSPI_PAR_ERROR_V(x) ((x) << ICSPI_PAR_ERROR_S) -#define ICSPI_PAR_ERROR_F ICSPI_PAR_ERROR_V(1U) - -#define PMTX_C_PCMD_PAR_ERROR_S 0 -#define PMTX_C_PCMD_PAR_ERROR_V(x) ((x) << PMTX_C_PCMD_PAR_ERROR_S) -#define PMTX_C_PCMD_PAR_ERROR_F PMTX_C_PCMD_PAR_ERROR_V(1U) - -#define MPS_PORT_STAT_TX_PORT_BYTES_L 0x400 -#define MPS_PORT_STAT_TX_PORT_BYTES_H 0x404 -#define MPS_PORT_STAT_TX_PORT_FRAMES_L 0x408 -#define MPS_PORT_STAT_TX_PORT_FRAMES_H 0x40c -#define MPS_PORT_STAT_TX_PORT_BCAST_L 0x410 -#define MPS_PORT_STAT_TX_PORT_BCAST_H 0x414 -#define MPS_PORT_STAT_TX_PORT_MCAST_L 0x418 -#define MPS_PORT_STAT_TX_PORT_MCAST_H 0x41c -#define MPS_PORT_STAT_TX_PORT_UCAST_L 0x420 -#define MPS_PORT_STAT_TX_PORT_UCAST_H 0x424 -#define MPS_PORT_STAT_TX_PORT_ERROR_L 0x428 -#define MPS_PORT_STAT_TX_PORT_ERROR_H 0x42c -#define MPS_PORT_STAT_TX_PORT_64B_L 0x430 -#define MPS_PORT_STAT_TX_PORT_64B_H 0x434 -#define MPS_PORT_STAT_TX_PORT_65B_127B_L 0x438 -#define MPS_PORT_STAT_TX_PORT_65B_127B_H 0x43c -#define MPS_PORT_STAT_TX_PORT_128B_255B_L 0x440 -#define MPS_PORT_STAT_TX_PORT_128B_255B_H 0x444 -#define MPS_PORT_STAT_TX_PORT_256B_511B_L 0x448 -#define MPS_PORT_STAT_TX_PORT_256B_511B_H 0x44c -#define MPS_PORT_STAT_TX_PORT_512B_1023B_L 0x450 -#define MPS_PORT_STAT_TX_PORT_512B_1023B_H 0x454 -#define MPS_PORT_STAT_TX_PORT_1024B_1518B_L 0x458 -#define MPS_PORT_STAT_TX_PORT_1024B_1518B_H 0x45c -#define MPS_PORT_STAT_TX_PORT_1519B_MAX_L 0x460 -#define MPS_PORT_STAT_TX_PORT_1519B_MAX_H 0x464 -#define MPS_PORT_STAT_TX_PORT_DROP_L 0x468 -#define MPS_PORT_STAT_TX_PORT_DROP_H 0x46c -#define MPS_PORT_STAT_TX_PORT_PAUSE_L 0x470 -#define MPS_PORT_STAT_TX_PORT_PAUSE_H 0x474 -#define MPS_PORT_STAT_TX_PORT_PPP0_L 0x478 -#define MPS_PORT_STAT_TX_PORT_PPP0_H 0x47c -#define MPS_PORT_STAT_TX_PORT_PPP1_L 0x480 -#define MPS_PORT_STAT_TX_PORT_PPP1_H 0x484 -#define MPS_PORT_STAT_TX_PORT_PPP2_L 0x488 -#define MPS_PORT_STAT_TX_PORT_PPP2_H 0x48c -#define MPS_PORT_STAT_TX_PORT_PPP3_L 0x490 -#define MPS_PORT_STAT_TX_PORT_PPP3_H 0x494 -#define MPS_PORT_STAT_TX_PORT_PPP4_L 0x498 -#define MPS_PORT_STAT_TX_PORT_PPP4_H 0x49c -#define MPS_PORT_STAT_TX_PORT_PPP5_L 0x4a0 -#define MPS_PORT_STAT_TX_PORT_PPP5_H 0x4a4 -#define MPS_PORT_STAT_TX_PORT_PPP6_L 0x4a8 -#define MPS_PORT_STAT_TX_PORT_PPP6_H 0x4ac -#define MPS_PORT_STAT_TX_PORT_PPP7_L 0x4b0 -#define MPS_PORT_STAT_TX_PORT_PPP7_H 0x4b4 -#define MPS_PORT_STAT_LB_PORT_BYTES_L 0x4c0 -#define MPS_PORT_STAT_LB_PORT_BYTES_H 0x4c4 -#define MPS_PORT_STAT_LB_PORT_FRAMES_L 0x4c8 -#define MPS_PORT_STAT_LB_PORT_FRAMES_H 0x4cc -#define MPS_PORT_STAT_LB_PORT_BCAST_L 0x4d0 -#define MPS_PORT_STAT_LB_PORT_BCAST_H 0x4d4 -#define MPS_PORT_STAT_LB_PORT_MCAST_L 0x4d8 -#define MPS_PORT_STAT_LB_PORT_MCAST_H 0x4dc -#define MPS_PORT_STAT_LB_PORT_UCAST_L 0x4e0 -#define MPS_PORT_STAT_LB_PORT_UCAST_H 0x4e4 -#define MPS_PORT_STAT_LB_PORT_ERROR_L 0x4e8 -#define MPS_PORT_STAT_LB_PORT_ERROR_H 0x4ec -#define MPS_PORT_STAT_LB_PORT_64B_L 0x4f0 -#define MPS_PORT_STAT_LB_PORT_64B_H 0x4f4 -#define MPS_PORT_STAT_LB_PORT_65B_127B_L 0x4f8 -#define MPS_PORT_STAT_LB_PORT_65B_127B_H 0x4fc -#define MPS_PORT_STAT_LB_PORT_128B_255B_L 0x500 -#define MPS_PORT_STAT_LB_PORT_128B_255B_H 0x504 -#define MPS_PORT_STAT_LB_PORT_256B_511B_L 0x508 -#define MPS_PORT_STAT_LB_PORT_256B_511B_H 0x50c -#define MPS_PORT_STAT_LB_PORT_512B_1023B_L 0x510 -#define MPS_PORT_STAT_LB_PORT_512B_1023B_H 0x514 -#define MPS_PORT_STAT_LB_PORT_1024B_1518B_L 0x518 -#define MPS_PORT_STAT_LB_PORT_1024B_1518B_H 0x51c -#define MPS_PORT_STAT_LB_PORT_1519B_MAX_L 0x520 -#define MPS_PORT_STAT_LB_PORT_1519B_MAX_H 0x524 -#define MPS_PORT_STAT_LB_PORT_DROP_FRAMES 0x528 -#define MPS_PORT_STAT_LB_PORT_DROP_FRAMES_L 0x528 -#define MPS_PORT_STAT_RX_PORT_BYTES_L 0x540 -#define MPS_PORT_STAT_RX_PORT_BYTES_H 0x544 -#define MPS_PORT_STAT_RX_PORT_FRAMES_L 0x548 -#define MPS_PORT_STAT_RX_PORT_FRAMES_H 0x54c -#define MPS_PORT_STAT_RX_PORT_BCAST_L 0x550 -#define MPS_PORT_STAT_RX_PORT_BCAST_H 0x554 -#define MPS_PORT_STAT_RX_PORT_MCAST_L 0x558 -#define MPS_PORT_STAT_RX_PORT_MCAST_H 0x55c -#define MPS_PORT_STAT_RX_PORT_UCAST_L 0x560 -#define MPS_PORT_STAT_RX_PORT_UCAST_H 0x564 -#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_L 0x568 -#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_H 0x56c -#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_L 0x570 -#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_H 0x574 -#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_L 0x578 -#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_H 0x57c -#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_L 0x580 -#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_H 0x584 -#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_L 0x588 -#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_H 0x58c -#define MPS_PORT_STAT_RX_PORT_64B_L 0x590 -#define MPS_PORT_STAT_RX_PORT_64B_H 0x594 -#define MPS_PORT_STAT_RX_PORT_65B_127B_L 0x598 -#define MPS_PORT_STAT_RX_PORT_65B_127B_H 0x59c -#define MPS_PORT_STAT_RX_PORT_128B_255B_L 0x5a0 -#define MPS_PORT_STAT_RX_PORT_128B_255B_H 0x5a4 -#define MPS_PORT_STAT_RX_PORT_256B_511B_L 0x5a8 -#define MPS_PORT_STAT_RX_PORT_256B_511B_H 0x5ac -#define MPS_PORT_STAT_RX_PORT_512B_1023B_L 0x5b0 -#define MPS_PORT_STAT_RX_PORT_512B_1023B_H 0x5b4 -#define MPS_PORT_STAT_RX_PORT_1024B_1518B_L 0x5b8 -#define MPS_PORT_STAT_RX_PORT_1024B_1518B_H 0x5bc -#define MPS_PORT_STAT_RX_PORT_1519B_MAX_L 0x5c0 -#define MPS_PORT_STAT_RX_PORT_1519B_MAX_H 0x5c4 -#define MPS_PORT_STAT_RX_PORT_PAUSE_L 0x5c8 -#define MPS_PORT_STAT_RX_PORT_PAUSE_H 0x5cc -#define MPS_PORT_STAT_RX_PORT_PPP0_L 0x5d0 -#define MPS_PORT_STAT_RX_PORT_PPP0_H 0x5d4 -#define MPS_PORT_STAT_RX_PORT_PPP1_L 0x5d8 -#define MPS_PORT_STAT_RX_PORT_PPP1_H 0x5dc -#define MPS_PORT_STAT_RX_PORT_PPP2_L 0x5e0 -#define MPS_PORT_STAT_RX_PORT_PPP2_H 0x5e4 -#define MPS_PORT_STAT_RX_PORT_PPP3_L 0x5e8 -#define MPS_PORT_STAT_RX_PORT_PPP3_H 0x5ec -#define MPS_PORT_STAT_RX_PORT_PPP4_L 0x5f0 -#define MPS_PORT_STAT_RX_PORT_PPP4_H 0x5f4 -#define MPS_PORT_STAT_RX_PORT_PPP5_L 0x5f8 -#define MPS_PORT_STAT_RX_PORT_PPP5_H 0x5fc -#define MPS_PORT_STAT_RX_PORT_PPP6_L 0x600 -#define MPS_PORT_STAT_RX_PORT_PPP6_H 0x604 -#define MPS_PORT_STAT_RX_PORT_PPP7_L 0x608 -#define MPS_PORT_STAT_RX_PORT_PPP7_H 0x60c -#define MPS_PORT_STAT_RX_PORT_LESS_64B_L 0x610 -#define MPS_PORT_STAT_RX_PORT_LESS_64B_H 0x614 -#define MAC_PORT_MAGIC_MACID_LO 0x824 -#define MAC_PORT_MAGIC_MACID_HI 0x828 - -#define MAC_PORT_EPIO_DATA0_A 0x8c0 -#define MAC_PORT_EPIO_DATA1_A 0x8c4 -#define MAC_PORT_EPIO_DATA2_A 0x8c8 -#define MAC_PORT_EPIO_DATA3_A 0x8cc -#define MAC_PORT_EPIO_OP_A 0x8d0 - -#define MAC_PORT_CFG2_A 0x818 - -#define MPS_CMN_CTL_A 0x9000 - -#define NUMPORTS_S 0 -#define NUMPORTS_M 0x3U -#define NUMPORTS_G(x) (((x) >> NUMPORTS_S) & NUMPORTS_M) - -#define MPS_INT_CAUSE_A 0x9008 -#define MPS_TX_INT_CAUSE_A 0x9408 - -#define FRMERR_S 15 -#define FRMERR_V(x) ((x) << FRMERR_S) -#define FRMERR_F FRMERR_V(1U) - -#define SECNTERR_S 14 -#define SECNTERR_V(x) ((x) << SECNTERR_S) -#define SECNTERR_F SECNTERR_V(1U) - -#define BUBBLE_S 13 -#define BUBBLE_V(x) ((x) << BUBBLE_S) -#define BUBBLE_F BUBBLE_V(1U) - -#define TXDESCFIFO_S 9 -#define TXDESCFIFO_M 0xfU -#define TXDESCFIFO_V(x) ((x) << TXDESCFIFO_S) - -#define TXDATAFIFO_S 5 -#define TXDATAFIFO_M 0xfU -#define TXDATAFIFO_V(x) ((x) << TXDATAFIFO_S) - -#define NCSIFIFO_S 4 -#define NCSIFIFO_V(x) ((x) << NCSIFIFO_S) -#define NCSIFIFO_F NCSIFIFO_V(1U) - -#define TPFIFO_S 0 -#define TPFIFO_M 0xfU -#define TPFIFO_V(x) ((x) << TPFIFO_S) - -#define MPS_STAT_PERR_INT_CAUSE_SRAM_A 0x9614 -#define MPS_STAT_PERR_INT_CAUSE_TX_FIFO_A 0x9620 -#define MPS_STAT_PERR_INT_CAUSE_RX_FIFO_A 0x962c - -#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_L 0x9640 -#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_H 0x9644 -#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_L 0x9648 -#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_H 0x964c -#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_L 0x9650 -#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_H 0x9654 -#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_L 0x9658 -#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_H 0x965c -#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_L 0x9660 -#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_H 0x9664 -#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_L 0x9668 -#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_H 0x966c -#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_L 0x9670 -#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_H 0x9674 -#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_L 0x9678 -#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_H 0x967c -#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L 0x9680 -#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_H 0x9684 -#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_L 0x9688 -#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_H 0x968c -#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_L 0x9690 -#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_H 0x9694 -#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_L 0x9698 -#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_H 0x969c -#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_L 0x96a0 -#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_H 0x96a4 -#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_L 0x96a8 -#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_H 0x96ac -#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_L 0x96b0 -#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_H 0x96b4 -#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_L 0x96b8 -#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_H 0x96bc - -#define MPS_TRC_CFG_A 0x9800 - -#define TRCFIFOEMPTY_S 4 -#define TRCFIFOEMPTY_V(x) ((x) << TRCFIFOEMPTY_S) -#define TRCFIFOEMPTY_F TRCFIFOEMPTY_V(1U) - -#define TRCIGNOREDROPINPUT_S 3 -#define TRCIGNOREDROPINPUT_V(x) ((x) << TRCIGNOREDROPINPUT_S) -#define TRCIGNOREDROPINPUT_F TRCIGNOREDROPINPUT_V(1U) - -#define TRCKEEPDUPLICATES_S 2 -#define TRCKEEPDUPLICATES_V(x) ((x) << TRCKEEPDUPLICATES_S) -#define TRCKEEPDUPLICATES_F TRCKEEPDUPLICATES_V(1U) - -#define TRCEN_S 1 -#define TRCEN_V(x) ((x) << TRCEN_S) -#define TRCEN_F TRCEN_V(1U) - -#define TRCMULTIFILTER_S 0 -#define TRCMULTIFILTER_V(x) ((x) << TRCMULTIFILTER_S) -#define TRCMULTIFILTER_F TRCMULTIFILTER_V(1U) - -#define MPS_TRC_RSS_CONTROL_A 0x9808 -#define MPS_TRC_FILTER1_RSS_CONTROL_A 0x9ff4 -#define MPS_TRC_FILTER2_RSS_CONTROL_A 0x9ffc -#define MPS_TRC_FILTER3_RSS_CONTROL_A 0xa004 -#define MPS_T5_TRC_RSS_CONTROL_A 0xa00c - -#define RSSCONTROL_S 16 -#define RSSCONTROL_V(x) ((x) << RSSCONTROL_S) - -#define QUEUENUMBER_S 0 -#define QUEUENUMBER_V(x) ((x) << QUEUENUMBER_S) - -#define TFINVERTMATCH_S 24 -#define TFINVERTMATCH_V(x) ((x) << TFINVERTMATCH_S) -#define TFINVERTMATCH_F TFINVERTMATCH_V(1U) - -#define TFEN_S 22 -#define TFEN_V(x) ((x) << TFEN_S) -#define TFEN_F TFEN_V(1U) - -#define TFPORT_S 18 -#define TFPORT_M 0xfU -#define TFPORT_V(x) ((x) << TFPORT_S) -#define TFPORT_G(x) (((x) >> TFPORT_S) & TFPORT_M) - -#define TFLENGTH_S 8 -#define TFLENGTH_M 0x1fU -#define TFLENGTH_V(x) ((x) << TFLENGTH_S) -#define TFLENGTH_G(x) (((x) >> TFLENGTH_S) & TFLENGTH_M) - -#define TFOFFSET_S 0 -#define TFOFFSET_M 0x1fU -#define TFOFFSET_V(x) ((x) << TFOFFSET_S) -#define TFOFFSET_G(x) (((x) >> TFOFFSET_S) & TFOFFSET_M) - -#define T5_TFINVERTMATCH_S 25 -#define T5_TFINVERTMATCH_V(x) ((x) << T5_TFINVERTMATCH_S) -#define T5_TFINVERTMATCH_F T5_TFINVERTMATCH_V(1U) - -#define T5_TFEN_S 23 -#define T5_TFEN_V(x) ((x) << T5_TFEN_S) -#define T5_TFEN_F T5_TFEN_V(1U) - -#define T5_TFPORT_S 18 -#define T5_TFPORT_M 0x1fU -#define T5_TFPORT_V(x) ((x) << T5_TFPORT_S) -#define T5_TFPORT_G(x) (((x) >> T5_TFPORT_S) & T5_TFPORT_M) - -#define MPS_TRC_FILTER_MATCH_CTL_A_A 0x9810 -#define MPS_TRC_FILTER_MATCH_CTL_B_A 0x9820 - -#define TFMINPKTSIZE_S 16 -#define TFMINPKTSIZE_M 0x1ffU -#define TFMINPKTSIZE_V(x) ((x) << TFMINPKTSIZE_S) -#define TFMINPKTSIZE_G(x) (((x) >> TFMINPKTSIZE_S) & TFMINPKTSIZE_M) - -#define TFCAPTUREMAX_S 0 -#define TFCAPTUREMAX_M 0x3fffU -#define TFCAPTUREMAX_V(x) ((x) << TFCAPTUREMAX_S) -#define TFCAPTUREMAX_G(x) (((x) >> TFCAPTUREMAX_S) & TFCAPTUREMAX_M) - -#define MPS_TRC_FILTER0_MATCH_A 0x9c00 -#define MPS_TRC_FILTER0_DONT_CARE_A 0x9c80 -#define MPS_TRC_FILTER1_MATCH_A 0x9d00 - -#define TP_RSS_CONFIG_A 0x7df0 - -#define TNL4TUPENIPV6_S 31 -#define TNL4TUPENIPV6_V(x) ((x) << TNL4TUPENIPV6_S) -#define TNL4TUPENIPV6_F TNL4TUPENIPV6_V(1U) - -#define TNL2TUPENIPV6_S 30 -#define TNL2TUPENIPV6_V(x) ((x) << TNL2TUPENIPV6_S) -#define TNL2TUPENIPV6_F TNL2TUPENIPV6_V(1U) - -#define TNL4TUPENIPV4_S 29 -#define TNL4TUPENIPV4_V(x) ((x) << TNL4TUPENIPV4_S) -#define TNL4TUPENIPV4_F TNL4TUPENIPV4_V(1U) - -#define TNL2TUPENIPV4_S 28 -#define TNL2TUPENIPV4_V(x) ((x) << TNL2TUPENIPV4_S) -#define TNL2TUPENIPV4_F TNL2TUPENIPV4_V(1U) - -#define TNLTCPSEL_S 27 -#define TNLTCPSEL_V(x) ((x) << TNLTCPSEL_S) -#define TNLTCPSEL_F TNLTCPSEL_V(1U) - -#define TNLIP6SEL_S 26 -#define TNLIP6SEL_V(x) ((x) << TNLIP6SEL_S) -#define TNLIP6SEL_F TNLIP6SEL_V(1U) - -#define TNLVRTSEL_S 25 -#define TNLVRTSEL_V(x) ((x) << TNLVRTSEL_S) -#define TNLVRTSEL_F TNLVRTSEL_V(1U) - -#define TNLMAPEN_S 24 -#define TNLMAPEN_V(x) ((x) << TNLMAPEN_S) -#define TNLMAPEN_F TNLMAPEN_V(1U) - -#define OFDHASHSAVE_S 19 -#define OFDHASHSAVE_V(x) ((x) << OFDHASHSAVE_S) -#define OFDHASHSAVE_F OFDHASHSAVE_V(1U) - -#define OFDVRTSEL_S 18 -#define OFDVRTSEL_V(x) ((x) << OFDVRTSEL_S) -#define OFDVRTSEL_F OFDVRTSEL_V(1U) - -#define OFDMAPEN_S 17 -#define OFDMAPEN_V(x) ((x) << OFDMAPEN_S) -#define OFDMAPEN_F OFDMAPEN_V(1U) - -#define OFDLKPEN_S 16 -#define OFDLKPEN_V(x) ((x) << OFDLKPEN_S) -#define OFDLKPEN_F OFDLKPEN_V(1U) - -#define SYN4TUPENIPV6_S 15 -#define SYN4TUPENIPV6_V(x) ((x) << SYN4TUPENIPV6_S) -#define SYN4TUPENIPV6_F SYN4TUPENIPV6_V(1U) - -#define SYN2TUPENIPV6_S 14 -#define SYN2TUPENIPV6_V(x) ((x) << SYN2TUPENIPV6_S) -#define SYN2TUPENIPV6_F SYN2TUPENIPV6_V(1U) - -#define SYN4TUPENIPV4_S 13 -#define SYN4TUPENIPV4_V(x) ((x) << SYN4TUPENIPV4_S) -#define SYN4TUPENIPV4_F SYN4TUPENIPV4_V(1U) - -#define SYN2TUPENIPV4_S 12 -#define SYN2TUPENIPV4_V(x) ((x) << SYN2TUPENIPV4_S) -#define SYN2TUPENIPV4_F SYN2TUPENIPV4_V(1U) - -#define SYNIP6SEL_S 11 -#define SYNIP6SEL_V(x) ((x) << SYNIP6SEL_S) -#define SYNIP6SEL_F SYNIP6SEL_V(1U) - -#define SYNVRTSEL_S 10 -#define SYNVRTSEL_V(x) ((x) << SYNVRTSEL_S) -#define SYNVRTSEL_F SYNVRTSEL_V(1U) - -#define SYNMAPEN_S 9 -#define SYNMAPEN_V(x) ((x) << SYNMAPEN_S) -#define SYNMAPEN_F SYNMAPEN_V(1U) - -#define SYNLKPEN_S 8 -#define SYNLKPEN_V(x) ((x) << SYNLKPEN_S) -#define SYNLKPEN_F SYNLKPEN_V(1U) - -#define CHANNELENABLE_S 7 -#define CHANNELENABLE_V(x) ((x) << CHANNELENABLE_S) -#define CHANNELENABLE_F CHANNELENABLE_V(1U) - -#define PORTENABLE_S 6 -#define PORTENABLE_V(x) ((x) << PORTENABLE_S) -#define PORTENABLE_F PORTENABLE_V(1U) - -#define TNLALLLOOKUP_S 5 -#define TNLALLLOOKUP_V(x) ((x) << TNLALLLOOKUP_S) -#define TNLALLLOOKUP_F TNLALLLOOKUP_V(1U) - -#define VIRTENABLE_S 4 -#define VIRTENABLE_V(x) ((x) << VIRTENABLE_S) -#define VIRTENABLE_F VIRTENABLE_V(1U) - -#define CONGESTIONENABLE_S 3 -#define CONGESTIONENABLE_V(x) ((x) << CONGESTIONENABLE_S) -#define CONGESTIONENABLE_F CONGESTIONENABLE_V(1U) - -#define HASHTOEPLITZ_S 2 -#define HASHTOEPLITZ_V(x) ((x) << HASHTOEPLITZ_S) -#define HASHTOEPLITZ_F HASHTOEPLITZ_V(1U) - -#define UDPENABLE_S 1 -#define UDPENABLE_V(x) ((x) << UDPENABLE_S) -#define UDPENABLE_F UDPENABLE_V(1U) - -#define DISABLE_S 0 -#define DISABLE_V(x) ((x) << DISABLE_S) -#define DISABLE_F DISABLE_V(1U) - -#define TP_RSS_CONFIG_TNL_A 0x7df4 - -#define MASKSIZE_S 28 -#define MASKSIZE_M 0xfU -#define MASKSIZE_V(x) ((x) << MASKSIZE_S) -#define MASKSIZE_G(x) (((x) >> MASKSIZE_S) & MASKSIZE_M) - -#define MASKFILTER_S 16 -#define MASKFILTER_M 0x7ffU -#define MASKFILTER_V(x) ((x) << MASKFILTER_S) -#define MASKFILTER_G(x) (((x) >> MASKFILTER_S) & MASKFILTER_M) - -#define USEWIRECH_S 0 -#define USEWIRECH_V(x) ((x) << USEWIRECH_S) -#define USEWIRECH_F USEWIRECH_V(1U) - -#define HASHALL_S 2 -#define HASHALL_V(x) ((x) << HASHALL_S) -#define HASHALL_F HASHALL_V(1U) - -#define HASHETH_S 1 -#define HASHETH_V(x) ((x) << HASHETH_S) -#define HASHETH_F HASHETH_V(1U) - -#define TP_RSS_CONFIG_OFD_A 0x7df8 - -#define RRCPLMAPEN_S 20 -#define RRCPLMAPEN_V(x) ((x) << RRCPLMAPEN_S) -#define RRCPLMAPEN_F RRCPLMAPEN_V(1U) - -#define RRCPLQUEWIDTH_S 16 -#define RRCPLQUEWIDTH_M 0xfU -#define RRCPLQUEWIDTH_V(x) ((x) << RRCPLQUEWIDTH_S) -#define RRCPLQUEWIDTH_G(x) (((x) >> RRCPLQUEWIDTH_S) & RRCPLQUEWIDTH_M) - -#define TP_RSS_CONFIG_SYN_A 0x7dfc -#define TP_RSS_CONFIG_VRT_A 0x7e00 - -#define VFRDRG_S 25 -#define VFRDRG_V(x) ((x) << VFRDRG_S) -#define VFRDRG_F VFRDRG_V(1U) - -#define VFRDEN_S 24 -#define VFRDEN_V(x) ((x) << VFRDEN_S) -#define VFRDEN_F VFRDEN_V(1U) - -#define VFPERREN_S 23 -#define VFPERREN_V(x) ((x) << VFPERREN_S) -#define VFPERREN_F VFPERREN_V(1U) - -#define KEYPERREN_S 22 -#define KEYPERREN_V(x) ((x) << KEYPERREN_S) -#define KEYPERREN_F KEYPERREN_V(1U) - -#define DISABLEVLAN_S 21 -#define DISABLEVLAN_V(x) ((x) << DISABLEVLAN_S) -#define DISABLEVLAN_F DISABLEVLAN_V(1U) - -#define ENABLEUP0_S 20 -#define ENABLEUP0_V(x) ((x) << ENABLEUP0_S) -#define ENABLEUP0_F ENABLEUP0_V(1U) - -#define HASHDELAY_S 16 -#define HASHDELAY_M 0xfU -#define HASHDELAY_V(x) ((x) << HASHDELAY_S) -#define HASHDELAY_G(x) (((x) >> HASHDELAY_S) & HASHDELAY_M) - -#define VFWRADDR_S 8 -#define VFWRADDR_M 0x7fU -#define VFWRADDR_V(x) ((x) << VFWRADDR_S) -#define VFWRADDR_G(x) (((x) >> VFWRADDR_S) & VFWRADDR_M) - -#define KEYMODE_S 6 -#define KEYMODE_M 0x3U -#define KEYMODE_V(x) ((x) << KEYMODE_S) -#define KEYMODE_G(x) (((x) >> KEYMODE_S) & KEYMODE_M) - -#define VFWREN_S 5 -#define VFWREN_V(x) ((x) << VFWREN_S) -#define VFWREN_F VFWREN_V(1U) - -#define KEYWREN_S 4 -#define KEYWREN_V(x) ((x) << KEYWREN_S) -#define KEYWREN_F KEYWREN_V(1U) - -#define KEYWRADDR_S 0 -#define KEYWRADDR_M 0xfU -#define KEYWRADDR_V(x) ((x) << KEYWRADDR_S) -#define KEYWRADDR_G(x) (((x) >> KEYWRADDR_S) & KEYWRADDR_M) - -#define KEYWRADDRX_S 30 -#define KEYWRADDRX_M 0x3U -#define KEYWRADDRX_V(x) ((x) << KEYWRADDRX_S) -#define KEYWRADDRX_G(x) (((x) >> KEYWRADDRX_S) & KEYWRADDRX_M) - -#define KEYEXTEND_S 26 -#define KEYEXTEND_V(x) ((x) << KEYEXTEND_S) -#define KEYEXTEND_F KEYEXTEND_V(1U) - -#define LKPIDXSIZE_S 24 -#define LKPIDXSIZE_M 0x3U -#define LKPIDXSIZE_V(x) ((x) << LKPIDXSIZE_S) -#define LKPIDXSIZE_G(x) (((x) >> LKPIDXSIZE_S) & LKPIDXSIZE_M) - -#define TP_RSS_VFL_CONFIG_A 0x3a -#define TP_RSS_VFH_CONFIG_A 0x3b - -#define ENABLEUDPHASH_S 31 -#define ENABLEUDPHASH_V(x) ((x) << ENABLEUDPHASH_S) -#define ENABLEUDPHASH_F ENABLEUDPHASH_V(1U) - -#define VFUPEN_S 30 -#define VFUPEN_V(x) ((x) << VFUPEN_S) -#define VFUPEN_F VFUPEN_V(1U) - -#define VFVLNEX_S 28 -#define VFVLNEX_V(x) ((x) << VFVLNEX_S) -#define VFVLNEX_F VFVLNEX_V(1U) - -#define VFPRTEN_S 27 -#define VFPRTEN_V(x) ((x) << VFPRTEN_S) -#define VFPRTEN_F VFPRTEN_V(1U) - -#define VFCHNEN_S 26 -#define VFCHNEN_V(x) ((x) << VFCHNEN_S) -#define VFCHNEN_F VFCHNEN_V(1U) - -#define DEFAULTQUEUE_S 16 -#define DEFAULTQUEUE_M 0x3ffU -#define DEFAULTQUEUE_G(x) (((x) >> DEFAULTQUEUE_S) & DEFAULTQUEUE_M) - -#define VFIP6TWOTUPEN_S 6 -#define VFIP6TWOTUPEN_V(x) ((x) << VFIP6TWOTUPEN_S) -#define VFIP6TWOTUPEN_F VFIP6TWOTUPEN_V(1U) - -#define VFIP4FOURTUPEN_S 5 -#define VFIP4FOURTUPEN_V(x) ((x) << VFIP4FOURTUPEN_S) -#define VFIP4FOURTUPEN_F VFIP4FOURTUPEN_V(1U) - -#define VFIP4TWOTUPEN_S 4 -#define VFIP4TWOTUPEN_V(x) ((x) << VFIP4TWOTUPEN_S) -#define VFIP4TWOTUPEN_F VFIP4TWOTUPEN_V(1U) - -#define KEYINDEX_S 0 -#define KEYINDEX_M 0xfU -#define KEYINDEX_G(x) (((x) >> KEYINDEX_S) & KEYINDEX_M) - -#define MAPENABLE_S 31 -#define MAPENABLE_V(x) ((x) << MAPENABLE_S) -#define MAPENABLE_F MAPENABLE_V(1U) - -#define CHNENABLE_S 30 -#define CHNENABLE_V(x) ((x) << CHNENABLE_S) -#define CHNENABLE_F CHNENABLE_V(1U) - -#define PRTENABLE_S 29 -#define PRTENABLE_V(x) ((x) << PRTENABLE_S) -#define PRTENABLE_F PRTENABLE_V(1U) - -#define UDPFOURTUPEN_S 28 -#define UDPFOURTUPEN_V(x) ((x) << UDPFOURTUPEN_S) -#define UDPFOURTUPEN_F UDPFOURTUPEN_V(1U) - -#define IP6FOURTUPEN_S 27 -#define IP6FOURTUPEN_V(x) ((x) << IP6FOURTUPEN_S) -#define IP6FOURTUPEN_F IP6FOURTUPEN_V(1U) - -#define IP6TWOTUPEN_S 26 -#define IP6TWOTUPEN_V(x) ((x) << IP6TWOTUPEN_S) -#define IP6TWOTUPEN_F IP6TWOTUPEN_V(1U) - -#define IP4FOURTUPEN_S 25 -#define IP4FOURTUPEN_V(x) ((x) << IP4FOURTUPEN_S) -#define IP4FOURTUPEN_F IP4FOURTUPEN_V(1U) - -#define IP4TWOTUPEN_S 24 -#define IP4TWOTUPEN_V(x) ((x) << IP4TWOTUPEN_S) -#define IP4TWOTUPEN_F IP4TWOTUPEN_V(1U) - -#define IVFWIDTH_S 20 -#define IVFWIDTH_M 0xfU -#define IVFWIDTH_V(x) ((x) << IVFWIDTH_S) -#define IVFWIDTH_G(x) (((x) >> IVFWIDTH_S) & IVFWIDTH_M) - -#define CH1DEFAULTQUEUE_S 10 -#define CH1DEFAULTQUEUE_M 0x3ffU -#define CH1DEFAULTQUEUE_V(x) ((x) << CH1DEFAULTQUEUE_S) -#define CH1DEFAULTQUEUE_G(x) (((x) >> CH1DEFAULTQUEUE_S) & CH1DEFAULTQUEUE_M) - -#define CH0DEFAULTQUEUE_S 0 -#define CH0DEFAULTQUEUE_M 0x3ffU -#define CH0DEFAULTQUEUE_V(x) ((x) << CH0DEFAULTQUEUE_S) -#define CH0DEFAULTQUEUE_G(x) (((x) >> CH0DEFAULTQUEUE_S) & CH0DEFAULTQUEUE_M) - -#define VFLKPIDX_S 8 -#define VFLKPIDX_M 0xffU -#define VFLKPIDX_G(x) (((x) >> VFLKPIDX_S) & VFLKPIDX_M) - -#define T6_VFWRADDR_S 8 -#define T6_VFWRADDR_M 0xffU -#define T6_VFWRADDR_V(x) ((x) << T6_VFWRADDR_S) -#define T6_VFWRADDR_G(x) (((x) >> T6_VFWRADDR_S) & T6_VFWRADDR_M) - -#define TP_RSS_CONFIG_CNG_A 0x7e04 -#define TP_RSS_SECRET_KEY0_A 0x40 -#define TP_RSS_PF0_CONFIG_A 0x30 -#define TP_RSS_PF_MAP_A 0x38 -#define TP_RSS_PF_MSK_A 0x39 - -#define PF1LKPIDX_S 3 - -#define PF0LKPIDX_M 0x7U - -#define PF1MSKSIZE_S 4 -#define PF1MSKSIZE_M 0xfU - -#define CHNCOUNT3_S 31 -#define CHNCOUNT3_V(x) ((x) << CHNCOUNT3_S) -#define CHNCOUNT3_F CHNCOUNT3_V(1U) - -#define CHNCOUNT2_S 30 -#define CHNCOUNT2_V(x) ((x) << CHNCOUNT2_S) -#define CHNCOUNT2_F CHNCOUNT2_V(1U) - -#define CHNCOUNT1_S 29 -#define CHNCOUNT1_V(x) ((x) << CHNCOUNT1_S) -#define CHNCOUNT1_F CHNCOUNT1_V(1U) - -#define CHNCOUNT0_S 28 -#define CHNCOUNT0_V(x) ((x) << CHNCOUNT0_S) -#define CHNCOUNT0_F CHNCOUNT0_V(1U) - -#define CHNUNDFLOW3_S 27 -#define CHNUNDFLOW3_V(x) ((x) << CHNUNDFLOW3_S) -#define CHNUNDFLOW3_F CHNUNDFLOW3_V(1U) - -#define CHNUNDFLOW2_S 26 -#define CHNUNDFLOW2_V(x) ((x) << CHNUNDFLOW2_S) -#define CHNUNDFLOW2_F CHNUNDFLOW2_V(1U) - -#define CHNUNDFLOW1_S 25 -#define CHNUNDFLOW1_V(x) ((x) << CHNUNDFLOW1_S) -#define CHNUNDFLOW1_F CHNUNDFLOW1_V(1U) - -#define CHNUNDFLOW0_S 24 -#define CHNUNDFLOW0_V(x) ((x) << CHNUNDFLOW0_S) -#define CHNUNDFLOW0_F CHNUNDFLOW0_V(1U) - -#define RSTCHN3_S 19 -#define RSTCHN3_V(x) ((x) << RSTCHN3_S) -#define RSTCHN3_F RSTCHN3_V(1U) - -#define RSTCHN2_S 18 -#define RSTCHN2_V(x) ((x) << RSTCHN2_S) -#define RSTCHN2_F RSTCHN2_V(1U) - -#define RSTCHN1_S 17 -#define RSTCHN1_V(x) ((x) << RSTCHN1_S) -#define RSTCHN1_F RSTCHN1_V(1U) - -#define RSTCHN0_S 16 -#define RSTCHN0_V(x) ((x) << RSTCHN0_S) -#define RSTCHN0_F RSTCHN0_V(1U) - -#define UPDVLD_S 15 -#define UPDVLD_V(x) ((x) << UPDVLD_S) -#define UPDVLD_F UPDVLD_V(1U) - -#define XOFF_S 14 -#define XOFF_V(x) ((x) << XOFF_S) -#define XOFF_F XOFF_V(1U) - -#define UPDCHN3_S 13 -#define UPDCHN3_V(x) ((x) << UPDCHN3_S) -#define UPDCHN3_F UPDCHN3_V(1U) - -#define UPDCHN2_S 12 -#define UPDCHN2_V(x) ((x) << UPDCHN2_S) -#define UPDCHN2_F UPDCHN2_V(1U) - -#define UPDCHN1_S 11 -#define UPDCHN1_V(x) ((x) << UPDCHN1_S) -#define UPDCHN1_F UPDCHN1_V(1U) - -#define UPDCHN0_S 10 -#define UPDCHN0_V(x) ((x) << UPDCHN0_S) -#define UPDCHN0_F UPDCHN0_V(1U) - -#define QUEUE_S 0 -#define QUEUE_M 0x3ffU -#define QUEUE_V(x) ((x) << QUEUE_S) -#define QUEUE_G(x) (((x) >> QUEUE_S) & QUEUE_M) - -#define MPS_TRC_INT_CAUSE_A 0x985c - -#define MISCPERR_S 8 -#define MISCPERR_V(x) ((x) << MISCPERR_S) -#define MISCPERR_F MISCPERR_V(1U) - -#define PKTFIFO_S 4 -#define PKTFIFO_M 0xfU -#define PKTFIFO_V(x) ((x) << PKTFIFO_S) - -#define FILTMEM_S 0 -#define FILTMEM_M 0xfU -#define FILTMEM_V(x) ((x) << FILTMEM_S) - -#define MPS_CLS_INT_CAUSE_A 0xd028 - -#define HASHSRAM_S 2 -#define HASHSRAM_V(x) ((x) << HASHSRAM_S) -#define HASHSRAM_F HASHSRAM_V(1U) - -#define MATCHTCAM_S 1 -#define MATCHTCAM_V(x) ((x) << MATCHTCAM_S) -#define MATCHTCAM_F MATCHTCAM_V(1U) - -#define MATCHSRAM_S 0 -#define MATCHSRAM_V(x) ((x) << MATCHSRAM_S) -#define MATCHSRAM_F MATCHSRAM_V(1U) - -#define MPS_RX_PG_RSV0_A 0x11010 -#define MPS_RX_PG_RSV4_A 0x11020 -#define MPS_RX_PERR_INT_CAUSE_A 0x11074 -#define MPS_RX_MAC_BG_PG_CNT0_A 0x11208 -#define MPS_RX_LPBK_BG_PG_CNT0_A 0x11218 - -#define MPS_CLS_TCAM_Y_L_A 0xf000 -#define MPS_CLS_TCAM_DATA0_A 0xf000 -#define MPS_CLS_TCAM_DATA1_A 0xf004 - -#define VIDL_S 16 -#define VIDL_M 0xffffU -#define VIDL_G(x) (((x) >> VIDL_S) & VIDL_M) - -#define DATALKPTYPE_S 10 -#define DATALKPTYPE_M 0x3U -#define DATALKPTYPE_G(x) (((x) >> DATALKPTYPE_S) & DATALKPTYPE_M) - -#define DATAPORTNUM_S 12 -#define DATAPORTNUM_M 0xfU -#define DATAPORTNUM_G(x) (((x) >> DATAPORTNUM_S) & DATAPORTNUM_M) - -#define DATADIPHIT_S 8 -#define DATADIPHIT_V(x) ((x) << DATADIPHIT_S) -#define DATADIPHIT_F DATADIPHIT_V(1U) - -#define DATAVIDH2_S 7 -#define DATAVIDH2_V(x) ((x) << DATAVIDH2_S) -#define DATAVIDH2_F DATAVIDH2_V(1U) - -#define DATAVIDH1_S 0 -#define DATAVIDH1_M 0x7fU -#define DATAVIDH1_G(x) (((x) >> DATAVIDH1_S) & DATAVIDH1_M) - -#define USED_S 16 -#define USED_M 0x7ffU -#define USED_G(x) (((x) >> USED_S) & USED_M) - -#define ALLOC_S 0 -#define ALLOC_M 0x7ffU -#define ALLOC_G(x) (((x) >> ALLOC_S) & ALLOC_M) - -#define T5_USED_S 16 -#define T5_USED_M 0xfffU -#define T5_USED_G(x) (((x) >> T5_USED_S) & T5_USED_M) - -#define T5_ALLOC_S 0 -#define T5_ALLOC_M 0xfffU -#define T5_ALLOC_G(x) (((x) >> T5_ALLOC_S) & T5_ALLOC_M) - -#define DMACH_S 0 -#define DMACH_M 0xffffU -#define DMACH_G(x) (((x) >> DMACH_S) & DMACH_M) - -#define MPS_CLS_TCAM_X_L_A 0xf008 -#define MPS_CLS_TCAM_DATA2_CTL_A 0xf008 - -#define CTLCMDTYPE_S 31 -#define CTLCMDTYPE_V(x) ((x) << CTLCMDTYPE_S) -#define CTLCMDTYPE_F CTLCMDTYPE_V(1U) - -#define CTLTCAMSEL_S 25 -#define CTLTCAMSEL_V(x) ((x) << CTLTCAMSEL_S) - -#define CTLTCAMINDEX_S 17 -#define CTLTCAMINDEX_V(x) ((x) << CTLTCAMINDEX_S) - -#define CTLXYBITSEL_S 16 -#define CTLXYBITSEL_V(x) ((x) << CTLXYBITSEL_S) - -#define MPS_CLS_TCAM_Y_L(idx) (MPS_CLS_TCAM_Y_L_A + (idx) * 16) -#define NUM_MPS_CLS_TCAM_Y_L_INSTANCES 512 - -#define MPS_CLS_TCAM_X_L(idx) (MPS_CLS_TCAM_X_L_A + (idx) * 16) -#define NUM_MPS_CLS_TCAM_X_L_INSTANCES 512 - -#define MPS_CLS_SRAM_L_A 0xe000 - -#define T6_MULTILISTEN0_S 26 - -#define T6_SRAM_PRIO3_S 23 -#define T6_SRAM_PRIO3_M 0x7U -#define T6_SRAM_PRIO3_G(x) (((x) >> T6_SRAM_PRIO3_S) & T6_SRAM_PRIO3_M) - -#define T6_SRAM_PRIO2_S 20 -#define T6_SRAM_PRIO2_M 0x7U -#define T6_SRAM_PRIO2_G(x) (((x) >> T6_SRAM_PRIO2_S) & T6_SRAM_PRIO2_M) - -#define T6_SRAM_PRIO1_S 17 -#define T6_SRAM_PRIO1_M 0x7U -#define T6_SRAM_PRIO1_G(x) (((x) >> T6_SRAM_PRIO1_S) & T6_SRAM_PRIO1_M) - -#define T6_SRAM_PRIO0_S 14 -#define T6_SRAM_PRIO0_M 0x7U -#define T6_SRAM_PRIO0_G(x) (((x) >> T6_SRAM_PRIO0_S) & T6_SRAM_PRIO0_M) - -#define T6_SRAM_VLD_S 13 -#define T6_SRAM_VLD_V(x) ((x) << T6_SRAM_VLD_S) -#define T6_SRAM_VLD_F T6_SRAM_VLD_V(1U) - -#define T6_REPLICATE_S 12 -#define T6_REPLICATE_V(x) ((x) << T6_REPLICATE_S) -#define T6_REPLICATE_F T6_REPLICATE_V(1U) - -#define T6_PF_S 9 -#define T6_PF_M 0x7U -#define T6_PF_G(x) (((x) >> T6_PF_S) & T6_PF_M) - -#define T6_VF_VALID_S 8 -#define T6_VF_VALID_V(x) ((x) << T6_VF_VALID_S) -#define T6_VF_VALID_F T6_VF_VALID_V(1U) - -#define T6_VF_S 0 -#define T6_VF_M 0xffU -#define T6_VF_G(x) (((x) >> T6_VF_S) & T6_VF_M) - -#define MPS_CLS_SRAM_H_A 0xe004 - -#define MPS_CLS_SRAM_L(idx) (MPS_CLS_SRAM_L_A + (idx) * 8) -#define NUM_MPS_CLS_SRAM_L_INSTANCES 336 - -#define MPS_CLS_SRAM_H(idx) (MPS_CLS_SRAM_H_A + (idx) * 8) -#define NUM_MPS_CLS_SRAM_H_INSTANCES 336 - -#define MULTILISTEN0_S 25 - -#define REPLICATE_S 11 -#define REPLICATE_V(x) ((x) << REPLICATE_S) -#define REPLICATE_F REPLICATE_V(1U) - -#define PF_S 8 -#define PF_M 0x7U -#define PF_G(x) (((x) >> PF_S) & PF_M) - -#define VF_VALID_S 7 -#define VF_VALID_V(x) ((x) << VF_VALID_S) -#define VF_VALID_F VF_VALID_V(1U) - -#define VF_S 0 -#define VF_M 0x7fU -#define VF_G(x) (((x) >> VF_S) & VF_M) - -#define SRAM_PRIO3_S 22 -#define SRAM_PRIO3_M 0x7U -#define SRAM_PRIO3_G(x) (((x) >> SRAM_PRIO3_S) & SRAM_PRIO3_M) - -#define SRAM_PRIO2_S 19 -#define SRAM_PRIO2_M 0x7U -#define SRAM_PRIO2_G(x) (((x) >> SRAM_PRIO2_S) & SRAM_PRIO2_M) - -#define SRAM_PRIO1_S 16 -#define SRAM_PRIO1_M 0x7U -#define SRAM_PRIO1_G(x) (((x) >> SRAM_PRIO1_S) & SRAM_PRIO1_M) - -#define SRAM_PRIO0_S 13 -#define SRAM_PRIO0_M 0x7U -#define SRAM_PRIO0_G(x) (((x) >> SRAM_PRIO0_S) & SRAM_PRIO0_M) - -#define SRAM_VLD_S 12 -#define SRAM_VLD_V(x) ((x) << SRAM_VLD_S) -#define SRAM_VLD_F SRAM_VLD_V(1U) - -#define PORTMAP_S 0 -#define PORTMAP_M 0xfU -#define PORTMAP_G(x) (((x) >> PORTMAP_S) & PORTMAP_M) - -#define CPL_INTR_CAUSE_A 0x19054 - -#define CIM_OP_MAP_PERR_S 5 -#define CIM_OP_MAP_PERR_V(x) ((x) << CIM_OP_MAP_PERR_S) -#define CIM_OP_MAP_PERR_F CIM_OP_MAP_PERR_V(1U) - -#define CIM_OVFL_ERROR_S 4 -#define CIM_OVFL_ERROR_V(x) ((x) << CIM_OVFL_ERROR_S) -#define CIM_OVFL_ERROR_F CIM_OVFL_ERROR_V(1U) - -#define TP_FRAMING_ERROR_S 3 -#define TP_FRAMING_ERROR_V(x) ((x) << TP_FRAMING_ERROR_S) -#define TP_FRAMING_ERROR_F TP_FRAMING_ERROR_V(1U) - -#define SGE_FRAMING_ERROR_S 2 -#define SGE_FRAMING_ERROR_V(x) ((x) << SGE_FRAMING_ERROR_S) -#define SGE_FRAMING_ERROR_F SGE_FRAMING_ERROR_V(1U) - -#define CIM_FRAMING_ERROR_S 1 -#define CIM_FRAMING_ERROR_V(x) ((x) << CIM_FRAMING_ERROR_S) -#define CIM_FRAMING_ERROR_F CIM_FRAMING_ERROR_V(1U) - -#define ZERO_SWITCH_ERROR_S 0 -#define ZERO_SWITCH_ERROR_V(x) ((x) << ZERO_SWITCH_ERROR_S) -#define ZERO_SWITCH_ERROR_F ZERO_SWITCH_ERROR_V(1U) - -#define SMB_INT_CAUSE_A 0x19090 - -#define MSTTXFIFOPARINT_S 21 -#define MSTTXFIFOPARINT_V(x) ((x) << MSTTXFIFOPARINT_S) -#define MSTTXFIFOPARINT_F MSTTXFIFOPARINT_V(1U) - -#define MSTRXFIFOPARINT_S 20 -#define MSTRXFIFOPARINT_V(x) ((x) << MSTRXFIFOPARINT_S) -#define MSTRXFIFOPARINT_F MSTRXFIFOPARINT_V(1U) - -#define SLVFIFOPARINT_S 19 -#define SLVFIFOPARINT_V(x) ((x) << SLVFIFOPARINT_S) -#define SLVFIFOPARINT_F SLVFIFOPARINT_V(1U) - -#define ULP_RX_INT_CAUSE_A 0x19158 -#define ULP_RX_ISCSI_LLIMIT_A 0x1915c -#define ULP_RX_ISCSI_ULIMIT_A 0x19160 -#define ULP_RX_ISCSI_TAGMASK_A 0x19164 -#define ULP_RX_ISCSI_PSZ_A 0x19168 -#define ULP_RX_TDDP_LLIMIT_A 0x1916c -#define ULP_RX_TDDP_ULIMIT_A 0x19170 -#define ULP_RX_STAG_LLIMIT_A 0x1917c -#define ULP_RX_STAG_ULIMIT_A 0x19180 -#define ULP_RX_RQ_LLIMIT_A 0x19184 -#define ULP_RX_RQ_ULIMIT_A 0x19188 -#define ULP_RX_PBL_LLIMIT_A 0x1918c -#define ULP_RX_PBL_ULIMIT_A 0x19190 -#define ULP_RX_CTX_BASE_A 0x19194 -#define ULP_RX_RQUDP_LLIMIT_A 0x191a4 -#define ULP_RX_RQUDP_ULIMIT_A 0x191a8 -#define ULP_RX_LA_CTL_A 0x1923c -#define ULP_RX_LA_RDPTR_A 0x19240 -#define ULP_RX_LA_RDDATA_A 0x19244 -#define ULP_RX_LA_WRPTR_A 0x19248 - -#define HPZ3_S 24 -#define HPZ3_V(x) ((x) << HPZ3_S) - -#define HPZ2_S 16 -#define HPZ2_V(x) ((x) << HPZ2_S) - -#define HPZ1_S 8 -#define HPZ1_V(x) ((x) << HPZ1_S) - -#define HPZ0_S 0 -#define HPZ0_V(x) ((x) << HPZ0_S) - -#define ULP_RX_TDDP_PSZ_A 0x19178 - -/* registers for module SF */ -#define SF_DATA_A 0x193f8 -#define SF_OP_A 0x193fc - -#define SF_BUSY_S 31 -#define SF_BUSY_V(x) ((x) << SF_BUSY_S) -#define SF_BUSY_F SF_BUSY_V(1U) - -#define SF_LOCK_S 4 -#define SF_LOCK_V(x) ((x) << SF_LOCK_S) -#define SF_LOCK_F SF_LOCK_V(1U) - -#define SF_CONT_S 3 -#define SF_CONT_V(x) ((x) << SF_CONT_S) -#define SF_CONT_F SF_CONT_V(1U) - -#define BYTECNT_S 1 -#define BYTECNT_V(x) ((x) << BYTECNT_S) - -#define OP_S 0 -#define OP_V(x) ((x) << OP_S) -#define OP_F OP_V(1U) - -#define PL_PF_INT_CAUSE_A 0x3c0 - -#define PFSW_S 3 -#define PFSW_V(x) ((x) << PFSW_S) -#define PFSW_F PFSW_V(1U) - -#define PFCIM_S 1 -#define PFCIM_V(x) ((x) << PFCIM_S) -#define PFCIM_F PFCIM_V(1U) - -#define PL_PF_INT_ENABLE_A 0x3c4 -#define PL_PF_CTL_A 0x3c8 - -#define PL_WHOAMI_A 0x19400 - -#define SOURCEPF_S 8 -#define SOURCEPF_M 0x7U -#define SOURCEPF_G(x) (((x) >> SOURCEPF_S) & SOURCEPF_M) - -#define T6_SOURCEPF_S 9 -#define T6_SOURCEPF_M 0x7U -#define T6_SOURCEPF_G(x) (((x) >> T6_SOURCEPF_S) & T6_SOURCEPF_M) - -#define PL_INT_CAUSE_A 0x1940c - -#define ULP_TX_S 27 -#define ULP_TX_V(x) ((x) << ULP_TX_S) -#define ULP_TX_F ULP_TX_V(1U) - -#define SGE_S 26 -#define SGE_V(x) ((x) << SGE_S) -#define SGE_F SGE_V(1U) - -#define CPL_SWITCH_S 24 -#define CPL_SWITCH_V(x) ((x) << CPL_SWITCH_S) -#define CPL_SWITCH_F CPL_SWITCH_V(1U) - -#define ULP_RX_S 23 -#define ULP_RX_V(x) ((x) << ULP_RX_S) -#define ULP_RX_F ULP_RX_V(1U) - -#define PM_RX_S 22 -#define PM_RX_V(x) ((x) << PM_RX_S) -#define PM_RX_F PM_RX_V(1U) - -#define PM_TX_S 21 -#define PM_TX_V(x) ((x) << PM_TX_S) -#define PM_TX_F PM_TX_V(1U) - -#define MA_S 20 -#define MA_V(x) ((x) << MA_S) -#define MA_F MA_V(1U) - -#define TP_S 19 -#define TP_V(x) ((x) << TP_S) -#define TP_F TP_V(1U) - -#define LE_S 18 -#define LE_V(x) ((x) << LE_S) -#define LE_F LE_V(1U) - -#define EDC1_S 17 -#define EDC1_V(x) ((x) << EDC1_S) -#define EDC1_F EDC1_V(1U) - -#define EDC0_S 16 -#define EDC0_V(x) ((x) << EDC0_S) -#define EDC0_F EDC0_V(1U) - -#define MC_S 15 -#define MC_V(x) ((x) << MC_S) -#define MC_F MC_V(1U) - -#define PCIE_S 14 -#define PCIE_V(x) ((x) << PCIE_S) -#define PCIE_F PCIE_V(1U) - -#define XGMAC_KR1_S 12 -#define XGMAC_KR1_V(x) ((x) << XGMAC_KR1_S) -#define XGMAC_KR1_F XGMAC_KR1_V(1U) - -#define XGMAC_KR0_S 11 -#define XGMAC_KR0_V(x) ((x) << XGMAC_KR0_S) -#define XGMAC_KR0_F XGMAC_KR0_V(1U) - -#define XGMAC1_S 10 -#define XGMAC1_V(x) ((x) << XGMAC1_S) -#define XGMAC1_F XGMAC1_V(1U) - -#define XGMAC0_S 9 -#define XGMAC0_V(x) ((x) << XGMAC0_S) -#define XGMAC0_F XGMAC0_V(1U) - -#define SMB_S 8 -#define SMB_V(x) ((x) << SMB_S) -#define SMB_F SMB_V(1U) - -#define SF_S 7 -#define SF_V(x) ((x) << SF_S) -#define SF_F SF_V(1U) - -#define PL_S 6 -#define PL_V(x) ((x) << PL_S) -#define PL_F PL_V(1U) - -#define NCSI_S 5 -#define NCSI_V(x) ((x) << NCSI_S) -#define NCSI_F NCSI_V(1U) - -#define MPS_S 4 -#define MPS_V(x) ((x) << MPS_S) -#define MPS_F MPS_V(1U) - -#define CIM_S 0 -#define CIM_V(x) ((x) << CIM_S) -#define CIM_F CIM_V(1U) - -#define MC1_S 31 -#define MC1_V(x) ((x) << MC1_S) -#define MC1_F MC1_V(1U) - -#define PL_INT_ENABLE_A 0x19410 -#define PL_INT_MAP0_A 0x19414 -#define PL_RST_A 0x19428 - -#define PIORST_S 1 -#define PIORST_V(x) ((x) << PIORST_S) -#define PIORST_F PIORST_V(1U) - -#define PIORSTMODE_S 0 -#define PIORSTMODE_V(x) ((x) << PIORSTMODE_S) -#define PIORSTMODE_F PIORSTMODE_V(1U) - -#define PL_PL_INT_CAUSE_A 0x19430 - -#define FATALPERR_S 4 -#define FATALPERR_V(x) ((x) << FATALPERR_S) -#define FATALPERR_F FATALPERR_V(1U) - -#define PERRVFID_S 0 -#define PERRVFID_V(x) ((x) << PERRVFID_S) -#define PERRVFID_F PERRVFID_V(1U) - -#define PL_REV_A 0x1943c - -#define REV_S 0 -#define REV_M 0xfU -#define REV_V(x) ((x) << REV_S) -#define REV_G(x) (((x) >> REV_S) & REV_M) - -#define T6_UNKNOWNCMD_S 3 -#define T6_UNKNOWNCMD_V(x) ((x) << T6_UNKNOWNCMD_S) -#define T6_UNKNOWNCMD_F T6_UNKNOWNCMD_V(1U) - -#define T6_LIP0_S 2 -#define T6_LIP0_V(x) ((x) << T6_LIP0_S) -#define T6_LIP0_F T6_LIP0_V(1U) - -#define T6_LIPMISS_S 1 -#define T6_LIPMISS_V(x) ((x) << T6_LIPMISS_S) -#define T6_LIPMISS_F T6_LIPMISS_V(1U) - -#define LE_DB_CONFIG_A 0x19c04 -#define LE_DB_SERVER_INDEX_A 0x19c18 -#define LE_DB_SRVR_START_INDEX_A 0x19c18 -#define LE_DB_ACT_CNT_IPV4_A 0x19c20 -#define LE_DB_ACT_CNT_IPV6_A 0x19c24 -#define LE_DB_HASH_TID_BASE_A 0x19c30 -#define LE_DB_HASH_TBL_BASE_ADDR_A 0x19c30 -#define LE_DB_INT_CAUSE_A 0x19c3c -#define LE_DB_TID_HASHBASE_A 0x19df8 -#define T6_LE_DB_HASH_TID_BASE_A 0x19df8 - -#define HASHEN_S 20 -#define HASHEN_V(x) ((x) << HASHEN_S) -#define HASHEN_F HASHEN_V(1U) - -#define ASLIPCOMPEN_S 17 -#define ASLIPCOMPEN_V(x) ((x) << ASLIPCOMPEN_S) -#define ASLIPCOMPEN_F ASLIPCOMPEN_V(1U) - -#define REQQPARERR_S 16 -#define REQQPARERR_V(x) ((x) << REQQPARERR_S) -#define REQQPARERR_F REQQPARERR_V(1U) - -#define UNKNOWNCMD_S 15 -#define UNKNOWNCMD_V(x) ((x) << UNKNOWNCMD_S) -#define UNKNOWNCMD_F UNKNOWNCMD_V(1U) - -#define PARITYERR_S 6 -#define PARITYERR_V(x) ((x) << PARITYERR_S) -#define PARITYERR_F PARITYERR_V(1U) - -#define LIPMISS_S 5 -#define LIPMISS_V(x) ((x) << LIPMISS_S) -#define LIPMISS_F LIPMISS_V(1U) - -#define LIP0_S 4 -#define LIP0_V(x) ((x) << LIP0_S) -#define LIP0_F LIP0_V(1U) - -#define BASEADDR_S 3 -#define BASEADDR_M 0x1fffffffU -#define BASEADDR_G(x) (((x) >> BASEADDR_S) & BASEADDR_M) - -#define TCAMINTPERR_S 13 -#define TCAMINTPERR_V(x) ((x) << TCAMINTPERR_S) -#define TCAMINTPERR_F TCAMINTPERR_V(1U) - -#define SSRAMINTPERR_S 10 -#define SSRAMINTPERR_V(x) ((x) << SSRAMINTPERR_S) -#define SSRAMINTPERR_F SSRAMINTPERR_V(1U) - -#define NCSI_INT_CAUSE_A 0x1a0d8 - -#define CIM_DM_PRTY_ERR_S 8 -#define CIM_DM_PRTY_ERR_V(x) ((x) << CIM_DM_PRTY_ERR_S) -#define CIM_DM_PRTY_ERR_F CIM_DM_PRTY_ERR_V(1U) - -#define MPS_DM_PRTY_ERR_S 7 -#define MPS_DM_PRTY_ERR_V(x) ((x) << MPS_DM_PRTY_ERR_S) -#define MPS_DM_PRTY_ERR_F MPS_DM_PRTY_ERR_V(1U) - -#define TXFIFO_PRTY_ERR_S 1 -#define TXFIFO_PRTY_ERR_V(x) ((x) << TXFIFO_PRTY_ERR_S) -#define TXFIFO_PRTY_ERR_F TXFIFO_PRTY_ERR_V(1U) - -#define RXFIFO_PRTY_ERR_S 0 -#define RXFIFO_PRTY_ERR_V(x) ((x) << RXFIFO_PRTY_ERR_S) -#define RXFIFO_PRTY_ERR_F RXFIFO_PRTY_ERR_V(1U) - -#define XGMAC_PORT_CFG2_A 0x1018 - -#define PATEN_S 18 -#define PATEN_V(x) ((x) << PATEN_S) -#define PATEN_F PATEN_V(1U) - -#define MAGICEN_S 17 -#define MAGICEN_V(x) ((x) << MAGICEN_S) -#define MAGICEN_F MAGICEN_V(1U) - -#define XGMAC_PORT_MAGIC_MACID_LO 0x1024 -#define XGMAC_PORT_MAGIC_MACID_HI 0x1028 - -#define XGMAC_PORT_EPIO_DATA0_A 0x10c0 -#define XGMAC_PORT_EPIO_DATA1_A 0x10c4 -#define XGMAC_PORT_EPIO_DATA2_A 0x10c8 -#define XGMAC_PORT_EPIO_DATA3_A 0x10cc -#define XGMAC_PORT_EPIO_OP_A 0x10d0 - -#define EPIOWR_S 8 -#define EPIOWR_V(x) ((x) << EPIOWR_S) -#define EPIOWR_F EPIOWR_V(1U) - -#define ADDRESS_S 0 -#define ADDRESS_V(x) ((x) << ADDRESS_S) - -#define MAC_PORT_INT_CAUSE_A 0x8dc -#define XGMAC_PORT_INT_CAUSE_A 0x10dc - -#define TP_TX_MOD_QUEUE_REQ_MAP_A 0x7e28 - -#define TP_TX_MOD_QUEUE_WEIGHT0_A 0x7e30 -#define TP_TX_MOD_CHANNEL_WEIGHT_A 0x7e34 - -#define TX_MOD_QUEUE_REQ_MAP_S 0 -#define TX_MOD_QUEUE_REQ_MAP_V(x) ((x) << TX_MOD_QUEUE_REQ_MAP_S) - -#define TX_MODQ_WEIGHT3_S 24 -#define TX_MODQ_WEIGHT3_V(x) ((x) << TX_MODQ_WEIGHT3_S) - -#define TX_MODQ_WEIGHT2_S 16 -#define TX_MODQ_WEIGHT2_V(x) ((x) << TX_MODQ_WEIGHT2_S) - -#define TX_MODQ_WEIGHT1_S 8 -#define TX_MODQ_WEIGHT1_V(x) ((x) << TX_MODQ_WEIGHT1_S) - -#define TX_MODQ_WEIGHT0_S 0 -#define TX_MODQ_WEIGHT0_V(x) ((x) << TX_MODQ_WEIGHT0_S) - -#define TP_TX_SCHED_HDR_A 0x23 -#define TP_TX_SCHED_FIFO_A 0x24 -#define TP_TX_SCHED_PCMD_A 0x25 - -#define NUM_MPS_CLS_SRAM_L_INSTANCES 336 -#define NUM_MPS_T5_CLS_SRAM_L_INSTANCES 512 - -#define T5_PORT0_BASE 0x30000 -#define T5_PORT_STRIDE 0x4000 -#define T5_PORT_BASE(idx) (T5_PORT0_BASE + (idx) * T5_PORT_STRIDE) -#define T5_PORT_REG(idx, reg) (T5_PORT_BASE(idx) + (reg)) - -#define MC_0_BASE_ADDR 0x40000 -#define MC_1_BASE_ADDR 0x48000 -#define MC_STRIDE (MC_1_BASE_ADDR - MC_0_BASE_ADDR) -#define MC_REG(reg, idx) (reg + MC_STRIDE * idx) - -#define MC_P_BIST_CMD_A 0x41400 -#define MC_P_BIST_CMD_ADDR_A 0x41404 -#define MC_P_BIST_CMD_LEN_A 0x41408 -#define MC_P_BIST_DATA_PATTERN_A 0x4140c -#define MC_P_BIST_STATUS_RDATA_A 0x41488 - -#define EDC_T50_BASE_ADDR 0x50000 - -#define EDC_H_BIST_CMD_A 0x50004 -#define EDC_H_BIST_CMD_ADDR_A 0x50008 -#define EDC_H_BIST_CMD_LEN_A 0x5000c -#define EDC_H_BIST_DATA_PATTERN_A 0x50010 -#define EDC_H_BIST_STATUS_RDATA_A 0x50028 - -#define EDC_H_ECC_ERR_ADDR_A 0x50084 -#define EDC_T51_BASE_ADDR 0x50800 - -#define EDC_T5_STRIDE (EDC_T51_BASE_ADDR - EDC_T50_BASE_ADDR) -#define EDC_T5_REG(reg, idx) (reg + EDC_T5_STRIDE * idx) - -#define PL_VF_REV_A 0x4 -#define PL_VF_WHOAMI_A 0x0 -#define PL_VF_REVISION_A 0x8 - -/* registers for module CIM */ -#define CIM_HOST_ACC_CTRL_A 0x7b50 -#define CIM_HOST_ACC_DATA_A 0x7b54 -#define UP_UP_DBG_LA_CFG_A 0x140 -#define UP_UP_DBG_LA_DATA_A 0x144 - -#define HOSTBUSY_S 17 -#define HOSTBUSY_V(x) ((x) << HOSTBUSY_S) -#define HOSTBUSY_F HOSTBUSY_V(1U) - -#define HOSTWRITE_S 16 -#define HOSTWRITE_V(x) ((x) << HOSTWRITE_S) -#define HOSTWRITE_F HOSTWRITE_V(1U) - -#define CIM_IBQ_DBG_CFG_A 0x7b60 - -#define IBQDBGADDR_S 16 -#define IBQDBGADDR_M 0xfffU -#define IBQDBGADDR_V(x) ((x) << IBQDBGADDR_S) -#define IBQDBGADDR_G(x) (((x) >> IBQDBGADDR_S) & IBQDBGADDR_M) - -#define IBQDBGBUSY_S 1 -#define IBQDBGBUSY_V(x) ((x) << IBQDBGBUSY_S) -#define IBQDBGBUSY_F IBQDBGBUSY_V(1U) - -#define IBQDBGEN_S 0 -#define IBQDBGEN_V(x) ((x) << IBQDBGEN_S) -#define IBQDBGEN_F IBQDBGEN_V(1U) - -#define CIM_OBQ_DBG_CFG_A 0x7b64 - -#define OBQDBGADDR_S 16 -#define OBQDBGADDR_M 0xfffU -#define OBQDBGADDR_V(x) ((x) << OBQDBGADDR_S) -#define OBQDBGADDR_G(x) (((x) >> OBQDBGADDR_S) & OBQDBGADDR_M) - -#define OBQDBGBUSY_S 1 -#define OBQDBGBUSY_V(x) ((x) << OBQDBGBUSY_S) -#define OBQDBGBUSY_F OBQDBGBUSY_V(1U) - -#define OBQDBGEN_S 0 -#define OBQDBGEN_V(x) ((x) << OBQDBGEN_S) -#define OBQDBGEN_F OBQDBGEN_V(1U) - -#define CIM_IBQ_DBG_DATA_A 0x7b68 -#define CIM_OBQ_DBG_DATA_A 0x7b6c -#define CIM_DEBUGCFG_A 0x7b70 -#define CIM_DEBUGSTS_A 0x7b74 - -#define POLADBGRDPTR_S 23 -#define POLADBGRDPTR_M 0x1ffU -#define POLADBGRDPTR_V(x) ((x) << POLADBGRDPTR_S) - -#define POLADBGWRPTR_S 16 -#define POLADBGWRPTR_M 0x1ffU -#define POLADBGWRPTR_G(x) (((x) >> POLADBGWRPTR_S) & POLADBGWRPTR_M) - -#define PILADBGRDPTR_S 14 -#define PILADBGRDPTR_M 0x1ffU -#define PILADBGRDPTR_V(x) ((x) << PILADBGRDPTR_S) - -#define PILADBGWRPTR_S 0 -#define PILADBGWRPTR_M 0x1ffU -#define PILADBGWRPTR_G(x) (((x) >> PILADBGWRPTR_S) & PILADBGWRPTR_M) - -#define LADBGEN_S 12 -#define LADBGEN_V(x) ((x) << LADBGEN_S) -#define LADBGEN_F LADBGEN_V(1U) - -#define CIM_PO_LA_DEBUGDATA_A 0x7b78 -#define CIM_PI_LA_DEBUGDATA_A 0x7b7c -#define CIM_PO_LA_MADEBUGDATA_A 0x7b80 -#define CIM_PI_LA_MADEBUGDATA_A 0x7b84 - -#define UPDBGLARDEN_S 1 -#define UPDBGLARDEN_V(x) ((x) << UPDBGLARDEN_S) -#define UPDBGLARDEN_F UPDBGLARDEN_V(1U) - -#define UPDBGLAEN_S 0 -#define UPDBGLAEN_V(x) ((x) << UPDBGLAEN_S) -#define UPDBGLAEN_F UPDBGLAEN_V(1U) - -#define UPDBGLARDPTR_S 2 -#define UPDBGLARDPTR_M 0xfffU -#define UPDBGLARDPTR_V(x) ((x) << UPDBGLARDPTR_S) - -#define UPDBGLAWRPTR_S 16 -#define UPDBGLAWRPTR_M 0xfffU -#define UPDBGLAWRPTR_G(x) (((x) >> UPDBGLAWRPTR_S) & UPDBGLAWRPTR_M) - -#define UPDBGLACAPTPCONLY_S 30 -#define UPDBGLACAPTPCONLY_V(x) ((x) << UPDBGLACAPTPCONLY_S) -#define UPDBGLACAPTPCONLY_F UPDBGLACAPTPCONLY_V(1U) - -#define CIM_QUEUE_CONFIG_REF_A 0x7b48 -#define CIM_QUEUE_CONFIG_CTRL_A 0x7b4c - -#define CIMQSIZE_S 24 -#define CIMQSIZE_M 0x3fU -#define CIMQSIZE_G(x) (((x) >> CIMQSIZE_S) & CIMQSIZE_M) - -#define CIMQBASE_S 16 -#define CIMQBASE_M 0x3fU -#define CIMQBASE_G(x) (((x) >> CIMQBASE_S) & CIMQBASE_M) - -#define QUEFULLTHRSH_S 0 -#define QUEFULLTHRSH_M 0x1ffU -#define QUEFULLTHRSH_G(x) (((x) >> QUEFULLTHRSH_S) & QUEFULLTHRSH_M) - -#define UP_IBQ_0_RDADDR_A 0x10 -#define UP_IBQ_0_SHADOW_RDADDR_A 0x280 -#define UP_OBQ_0_REALADDR_A 0x104 -#define UP_OBQ_0_SHADOW_REALADDR_A 0x394 - -#define IBQRDADDR_S 0 -#define IBQRDADDR_M 0x1fffU -#define IBQRDADDR_G(x) (((x) >> IBQRDADDR_S) & IBQRDADDR_M) - -#define IBQWRADDR_S 0 -#define IBQWRADDR_M 0x1fffU -#define IBQWRADDR_G(x) (((x) >> IBQWRADDR_S) & IBQWRADDR_M) - -#define QUERDADDR_S 0 -#define QUERDADDR_M 0x7fffU -#define QUERDADDR_G(x) (((x) >> QUERDADDR_S) & QUERDADDR_M) - -#define QUEREMFLITS_S 0 -#define QUEREMFLITS_M 0x7ffU -#define QUEREMFLITS_G(x) (((x) >> QUEREMFLITS_S) & QUEREMFLITS_M) - -#define QUEEOPCNT_S 16 -#define QUEEOPCNT_M 0xfffU -#define QUEEOPCNT_G(x) (((x) >> QUEEOPCNT_S) & QUEEOPCNT_M) - -#define QUESOPCNT_S 0 -#define QUESOPCNT_M 0xfffU -#define QUESOPCNT_G(x) (((x) >> QUESOPCNT_S) & QUESOPCNT_M) - -#define OBQSELECT_S 4 -#define OBQSELECT_V(x) ((x) << OBQSELECT_S) -#define OBQSELECT_F OBQSELECT_V(1U) - -#define IBQSELECT_S 3 -#define IBQSELECT_V(x) ((x) << IBQSELECT_S) -#define IBQSELECT_F IBQSELECT_V(1U) - -#define QUENUMSELECT_S 0 -#define QUENUMSELECT_V(x) ((x) << QUENUMSELECT_S) - -#endif /* __T4_REGS_H */ diff --git a/usr/rdma-core/providers/cxgb4/t4fw_api.h b/usr/rdma-core/providers/cxgb4/t4fw_api.h deleted file mode 100644 index 49bbca188..000000000 --- a/usr/rdma-core/providers/cxgb4/t4fw_api.h +++ /dev/null @@ -1,3260 +0,0 @@ -/* - * This file is part of the Chelsio T4 Ethernet driver for Linux. - * - * Copyright (c) 2009-2014 Chelsio Communications, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _T4FW_INTERFACE_H_ -#define _T4FW_INTERFACE_H_ - -#include - -enum fw_retval { - FW_SUCCESS = 0, /* completed successfully */ - FW_EPERM = 1, /* operation not permitted */ - FW_ENOENT = 2, /* no such file or directory */ - FW_EIO = 5, /* input/output error; hw bad */ - FW_ENOEXEC = 8, /* exec format error; inv microcode */ - FW_EAGAIN = 11, /* try again */ - FW_ENOMEM = 12, /* out of memory */ - FW_EFAULT = 14, /* bad address; fw bad */ - FW_EBUSY = 16, /* resource busy */ - FW_EEXIST = 17, /* file exists */ - FW_ENODEV = 19, /* no such device */ - FW_EINVAL = 22, /* invalid argument */ - FW_ENOSPC = 28, /* no space left on device */ - FW_ENOSYS = 38, /* functionality not implemented */ - FW_ENODATA = 61, /* no data available */ - FW_EPROTO = 71, /* protocol error */ - FW_EADDRINUSE = 98, /* address already in use */ - FW_EADDRNOTAVAIL = 99, /* cannot assigned requested address */ - FW_ENETDOWN = 100, /* network is down */ - FW_ENETUNREACH = 101, /* network is unreachable */ - FW_ENOBUFS = 105, /* no buffer space available */ - FW_ETIMEDOUT = 110, /* timeout */ - FW_EINPROGRESS = 115, /* fw internal */ - FW_SCSI_ABORT_REQUESTED = 128, /* */ - FW_SCSI_ABORT_TIMEDOUT = 129, /* */ - FW_SCSI_ABORTED = 130, /* */ - FW_SCSI_CLOSE_REQUESTED = 131, /* */ - FW_ERR_LINK_DOWN = 132, /* */ - FW_RDEV_NOT_READY = 133, /* */ - FW_ERR_RDEV_LOST = 134, /* */ - FW_ERR_RDEV_LOGO = 135, /* */ - FW_FCOE_NO_XCHG = 136, /* */ - FW_SCSI_RSP_ERR = 137, /* */ - FW_ERR_RDEV_IMPL_LOGO = 138, /* */ - FW_SCSI_UNDER_FLOW_ERR = 139, /* */ - FW_SCSI_OVER_FLOW_ERR = 140, /* */ - FW_SCSI_DDP_ERR = 141, /* DDP error*/ - FW_SCSI_TASK_ERR = 142, /* No SCSI tasks available */ -}; - -#define FW_T4VF_SGE_BASE_ADDR 0x0000 -#define FW_T4VF_MPS_BASE_ADDR 0x0100 -#define FW_T4VF_PL_BASE_ADDR 0x0200 -#define FW_T4VF_MBDATA_BASE_ADDR 0x0240 -#define FW_T4VF_CIM_BASE_ADDR 0x0300 - -enum fw_wr_opcodes { - FW_FILTER_WR = 0x02, - FW_ULPTX_WR = 0x04, - FW_TP_WR = 0x05, - FW_ETH_TX_PKT_WR = 0x08, - FW_OFLD_CONNECTION_WR = 0x2f, - FW_FLOWC_WR = 0x0a, - FW_OFLD_TX_DATA_WR = 0x0b, - FW_CMD_WR = 0x10, - FW_ETH_TX_PKT_VM_WR = 0x11, - FW_RI_RES_WR = 0x0c, - FW_RI_INIT_WR = 0x0d, - FW_RI_RDMA_WRITE_WR = 0x14, - FW_RI_SEND_WR = 0x15, - FW_RI_RDMA_READ_WR = 0x16, - FW_RI_RECV_WR = 0x17, - FW_RI_BIND_MW_WR = 0x18, - FW_RI_FR_NSMR_WR = 0x19, - FW_RI_INV_LSTAG_WR = 0x1a, - FW_ISCSI_TX_DATA_WR = 0x45, - FW_LASTC2E_WR = 0x70 -}; - -struct fw_wr_hdr { - __be32 hi; - __be32 lo; -}; - -/* work request opcode (hi) */ -#define FW_WR_OP_S 24 -#define FW_WR_OP_M 0xff -#define FW_WR_OP_V(x) ((x) << FW_WR_OP_S) -#define FW_WR_OP_G(x) (((x) >> FW_WR_OP_S) & FW_WR_OP_M) - -/* atomic flag (hi) - firmware encapsulates CPLs in CPL_BARRIER */ -#define FW_WR_ATOMIC_S 23 -#define FW_WR_ATOMIC_V(x) ((x) << FW_WR_ATOMIC_S) - -/* flush flag (hi) - firmware flushes flushable work request buffered - * in the flow context. - */ -#define FW_WR_FLUSH_S 22 -#define FW_WR_FLUSH_V(x) ((x) << FW_WR_FLUSH_S) - -/* completion flag (hi) - firmware generates a cpl_fw6_ack */ -#define FW_WR_COMPL_S 21 -#define FW_WR_COMPL_V(x) ((x) << FW_WR_COMPL_S) -#define FW_WR_COMPL_F FW_WR_COMPL_V(1U) - -/* work request immediate data length (hi) */ -#define FW_WR_IMMDLEN_S 0 -#define FW_WR_IMMDLEN_M 0xff -#define FW_WR_IMMDLEN_V(x) ((x) << FW_WR_IMMDLEN_S) - -/* egress queue status update to associated ingress queue entry (lo) */ -#define FW_WR_EQUIQ_S 31 -#define FW_WR_EQUIQ_V(x) ((x) << FW_WR_EQUIQ_S) -#define FW_WR_EQUIQ_F FW_WR_EQUIQ_V(1U) - -/* egress queue status update to egress queue status entry (lo) */ -#define FW_WR_EQUEQ_S 30 -#define FW_WR_EQUEQ_V(x) ((x) << FW_WR_EQUEQ_S) -#define FW_WR_EQUEQ_F FW_WR_EQUEQ_V(1U) - -/* flow context identifier (lo) */ -#define FW_WR_FLOWID_S 8 -#define FW_WR_FLOWID_V(x) ((x) << FW_WR_FLOWID_S) - -/* length in units of 16-bytes (lo) */ -#define FW_WR_LEN16_S 0 -#define FW_WR_LEN16_V(x) ((x) << FW_WR_LEN16_S) - -#define HW_TPL_FR_MT_PR_IV_P_FC 0X32B -#define HW_TPL_FR_MT_PR_OV_P_FC 0X327 - -/* filter wr reply code in cookie in CPL_SET_TCB_RPL */ -enum fw_filter_wr_cookie { - FW_FILTER_WR_SUCCESS, - FW_FILTER_WR_FLT_ADDED, - FW_FILTER_WR_FLT_DELETED, - FW_FILTER_WR_SMT_TBL_FULL, - FW_FILTER_WR_EINVAL, -}; - -struct fw_filter_wr { - __be32 op_pkd; - __be32 len16_pkd; - __be64 r3; - __be32 tid_to_iq; - __be32 del_filter_to_l2tix; - __be16 ethtype; - __be16 ethtypem; - __u8 frag_to_ovlan_vldm; - __u8 smac_sel; - __be16 rx_chan_rx_rpl_iq; - __be32 maci_to_matchtypem; - __u8 ptcl; - __u8 ptclm; - __u8 ttyp; - __u8 ttypm; - __be16 ivlan; - __be16 ivlanm; - __be16 ovlan; - __be16 ovlanm; - __u8 lip[16]; - __u8 lipm[16]; - __u8 fip[16]; - __u8 fipm[16]; - __be16 lp; - __be16 lpm; - __be16 fp; - __be16 fpm; - __be16 r7; - __u8 sma[6]; -}; - -#define FW_FILTER_WR_TID_S 12 -#define FW_FILTER_WR_TID_M 0xfffff -#define FW_FILTER_WR_TID_V(x) ((x) << FW_FILTER_WR_TID_S) -#define FW_FILTER_WR_TID_G(x) \ - (((x) >> FW_FILTER_WR_TID_S) & FW_FILTER_WR_TID_M) - -#define FW_FILTER_WR_RQTYPE_S 11 -#define FW_FILTER_WR_RQTYPE_M 0x1 -#define FW_FILTER_WR_RQTYPE_V(x) ((x) << FW_FILTER_WR_RQTYPE_S) -#define FW_FILTER_WR_RQTYPE_G(x) \ - (((x) >> FW_FILTER_WR_RQTYPE_S) & FW_FILTER_WR_RQTYPE_M) -#define FW_FILTER_WR_RQTYPE_F FW_FILTER_WR_RQTYPE_V(1U) - -#define FW_FILTER_WR_NOREPLY_S 10 -#define FW_FILTER_WR_NOREPLY_M 0x1 -#define FW_FILTER_WR_NOREPLY_V(x) ((x) << FW_FILTER_WR_NOREPLY_S) -#define FW_FILTER_WR_NOREPLY_G(x) \ - (((x) >> FW_FILTER_WR_NOREPLY_S) & FW_FILTER_WR_NOREPLY_M) -#define FW_FILTER_WR_NOREPLY_F FW_FILTER_WR_NOREPLY_V(1U) - -#define FW_FILTER_WR_IQ_S 0 -#define FW_FILTER_WR_IQ_M 0x3ff -#define FW_FILTER_WR_IQ_V(x) ((x) << FW_FILTER_WR_IQ_S) -#define FW_FILTER_WR_IQ_G(x) \ - (((x) >> FW_FILTER_WR_IQ_S) & FW_FILTER_WR_IQ_M) - -#define FW_FILTER_WR_DEL_FILTER_S 31 -#define FW_FILTER_WR_DEL_FILTER_M 0x1 -#define FW_FILTER_WR_DEL_FILTER_V(x) ((x) << FW_FILTER_WR_DEL_FILTER_S) -#define FW_FILTER_WR_DEL_FILTER_G(x) \ - (((x) >> FW_FILTER_WR_DEL_FILTER_S) & FW_FILTER_WR_DEL_FILTER_M) -#define FW_FILTER_WR_DEL_FILTER_F FW_FILTER_WR_DEL_FILTER_V(1U) - -#define FW_FILTER_WR_RPTTID_S 25 -#define FW_FILTER_WR_RPTTID_M 0x1 -#define FW_FILTER_WR_RPTTID_V(x) ((x) << FW_FILTER_WR_RPTTID_S) -#define FW_FILTER_WR_RPTTID_G(x) \ - (((x) >> FW_FILTER_WR_RPTTID_S) & FW_FILTER_WR_RPTTID_M) -#define FW_FILTER_WR_RPTTID_F FW_FILTER_WR_RPTTID_V(1U) - -#define FW_FILTER_WR_DROP_S 24 -#define FW_FILTER_WR_DROP_M 0x1 -#define FW_FILTER_WR_DROP_V(x) ((x) << FW_FILTER_WR_DROP_S) -#define FW_FILTER_WR_DROP_G(x) \ - (((x) >> FW_FILTER_WR_DROP_S) & FW_FILTER_WR_DROP_M) -#define FW_FILTER_WR_DROP_F FW_FILTER_WR_DROP_V(1U) - -#define FW_FILTER_WR_DIRSTEER_S 23 -#define FW_FILTER_WR_DIRSTEER_M 0x1 -#define FW_FILTER_WR_DIRSTEER_V(x) ((x) << FW_FILTER_WR_DIRSTEER_S) -#define FW_FILTER_WR_DIRSTEER_G(x) \ - (((x) >> FW_FILTER_WR_DIRSTEER_S) & FW_FILTER_WR_DIRSTEER_M) -#define FW_FILTER_WR_DIRSTEER_F FW_FILTER_WR_DIRSTEER_V(1U) - -#define FW_FILTER_WR_MASKHASH_S 22 -#define FW_FILTER_WR_MASKHASH_M 0x1 -#define FW_FILTER_WR_MASKHASH_V(x) ((x) << FW_FILTER_WR_MASKHASH_S) -#define FW_FILTER_WR_MASKHASH_G(x) \ - (((x) >> FW_FILTER_WR_MASKHASH_S) & FW_FILTER_WR_MASKHASH_M) -#define FW_FILTER_WR_MASKHASH_F FW_FILTER_WR_MASKHASH_V(1U) - -#define FW_FILTER_WR_DIRSTEERHASH_S 21 -#define FW_FILTER_WR_DIRSTEERHASH_M 0x1 -#define FW_FILTER_WR_DIRSTEERHASH_V(x) ((x) << FW_FILTER_WR_DIRSTEERHASH_S) -#define FW_FILTER_WR_DIRSTEERHASH_G(x) \ - (((x) >> FW_FILTER_WR_DIRSTEERHASH_S) & FW_FILTER_WR_DIRSTEERHASH_M) -#define FW_FILTER_WR_DIRSTEERHASH_F FW_FILTER_WR_DIRSTEERHASH_V(1U) - -#define FW_FILTER_WR_LPBK_S 20 -#define FW_FILTER_WR_LPBK_M 0x1 -#define FW_FILTER_WR_LPBK_V(x) ((x) << FW_FILTER_WR_LPBK_S) -#define FW_FILTER_WR_LPBK_G(x) \ - (((x) >> FW_FILTER_WR_LPBK_S) & FW_FILTER_WR_LPBK_M) -#define FW_FILTER_WR_LPBK_F FW_FILTER_WR_LPBK_V(1U) - -#define FW_FILTER_WR_DMAC_S 19 -#define FW_FILTER_WR_DMAC_M 0x1 -#define FW_FILTER_WR_DMAC_V(x) ((x) << FW_FILTER_WR_DMAC_S) -#define FW_FILTER_WR_DMAC_G(x) \ - (((x) >> FW_FILTER_WR_DMAC_S) & FW_FILTER_WR_DMAC_M) -#define FW_FILTER_WR_DMAC_F FW_FILTER_WR_DMAC_V(1U) - -#define FW_FILTER_WR_SMAC_S 18 -#define FW_FILTER_WR_SMAC_M 0x1 -#define FW_FILTER_WR_SMAC_V(x) ((x) << FW_FILTER_WR_SMAC_S) -#define FW_FILTER_WR_SMAC_G(x) \ - (((x) >> FW_FILTER_WR_SMAC_S) & FW_FILTER_WR_SMAC_M) -#define FW_FILTER_WR_SMAC_F FW_FILTER_WR_SMAC_V(1U) - -#define FW_FILTER_WR_INSVLAN_S 17 -#define FW_FILTER_WR_INSVLAN_M 0x1 -#define FW_FILTER_WR_INSVLAN_V(x) ((x) << FW_FILTER_WR_INSVLAN_S) -#define FW_FILTER_WR_INSVLAN_G(x) \ - (((x) >> FW_FILTER_WR_INSVLAN_S) & FW_FILTER_WR_INSVLAN_M) -#define FW_FILTER_WR_INSVLAN_F FW_FILTER_WR_INSVLAN_V(1U) - -#define FW_FILTER_WR_RMVLAN_S 16 -#define FW_FILTER_WR_RMVLAN_M 0x1 -#define FW_FILTER_WR_RMVLAN_V(x) ((x) << FW_FILTER_WR_RMVLAN_S) -#define FW_FILTER_WR_RMVLAN_G(x) \ - (((x) >> FW_FILTER_WR_RMVLAN_S) & FW_FILTER_WR_RMVLAN_M) -#define FW_FILTER_WR_RMVLAN_F FW_FILTER_WR_RMVLAN_V(1U) - -#define FW_FILTER_WR_HITCNTS_S 15 -#define FW_FILTER_WR_HITCNTS_M 0x1 -#define FW_FILTER_WR_HITCNTS_V(x) ((x) << FW_FILTER_WR_HITCNTS_S) -#define FW_FILTER_WR_HITCNTS_G(x) \ - (((x) >> FW_FILTER_WR_HITCNTS_S) & FW_FILTER_WR_HITCNTS_M) -#define FW_FILTER_WR_HITCNTS_F FW_FILTER_WR_HITCNTS_V(1U) - -#define FW_FILTER_WR_TXCHAN_S 13 -#define FW_FILTER_WR_TXCHAN_M 0x3 -#define FW_FILTER_WR_TXCHAN_V(x) ((x) << FW_FILTER_WR_TXCHAN_S) -#define FW_FILTER_WR_TXCHAN_G(x) \ - (((x) >> FW_FILTER_WR_TXCHAN_S) & FW_FILTER_WR_TXCHAN_M) - -#define FW_FILTER_WR_PRIO_S 12 -#define FW_FILTER_WR_PRIO_M 0x1 -#define FW_FILTER_WR_PRIO_V(x) ((x) << FW_FILTER_WR_PRIO_S) -#define FW_FILTER_WR_PRIO_G(x) \ - (((x) >> FW_FILTER_WR_PRIO_S) & FW_FILTER_WR_PRIO_M) -#define FW_FILTER_WR_PRIO_F FW_FILTER_WR_PRIO_V(1U) - -#define FW_FILTER_WR_L2TIX_S 0 -#define FW_FILTER_WR_L2TIX_M 0xfff -#define FW_FILTER_WR_L2TIX_V(x) ((x) << FW_FILTER_WR_L2TIX_S) -#define FW_FILTER_WR_L2TIX_G(x) \ - (((x) >> FW_FILTER_WR_L2TIX_S) & FW_FILTER_WR_L2TIX_M) - -#define FW_FILTER_WR_FRAG_S 7 -#define FW_FILTER_WR_FRAG_M 0x1 -#define FW_FILTER_WR_FRAG_V(x) ((x) << FW_FILTER_WR_FRAG_S) -#define FW_FILTER_WR_FRAG_G(x) \ - (((x) >> FW_FILTER_WR_FRAG_S) & FW_FILTER_WR_FRAG_M) -#define FW_FILTER_WR_FRAG_F FW_FILTER_WR_FRAG_V(1U) - -#define FW_FILTER_WR_FRAGM_S 6 -#define FW_FILTER_WR_FRAGM_M 0x1 -#define FW_FILTER_WR_FRAGM_V(x) ((x) << FW_FILTER_WR_FRAGM_S) -#define FW_FILTER_WR_FRAGM_G(x) \ - (((x) >> FW_FILTER_WR_FRAGM_S) & FW_FILTER_WR_FRAGM_M) -#define FW_FILTER_WR_FRAGM_F FW_FILTER_WR_FRAGM_V(1U) - -#define FW_FILTER_WR_IVLAN_VLD_S 5 -#define FW_FILTER_WR_IVLAN_VLD_M 0x1 -#define FW_FILTER_WR_IVLAN_VLD_V(x) ((x) << FW_FILTER_WR_IVLAN_VLD_S) -#define FW_FILTER_WR_IVLAN_VLD_G(x) \ - (((x) >> FW_FILTER_WR_IVLAN_VLD_S) & FW_FILTER_WR_IVLAN_VLD_M) -#define FW_FILTER_WR_IVLAN_VLD_F FW_FILTER_WR_IVLAN_VLD_V(1U) - -#define FW_FILTER_WR_OVLAN_VLD_S 4 -#define FW_FILTER_WR_OVLAN_VLD_M 0x1 -#define FW_FILTER_WR_OVLAN_VLD_V(x) ((x) << FW_FILTER_WR_OVLAN_VLD_S) -#define FW_FILTER_WR_OVLAN_VLD_G(x) \ - (((x) >> FW_FILTER_WR_OVLAN_VLD_S) & FW_FILTER_WR_OVLAN_VLD_M) -#define FW_FILTER_WR_OVLAN_VLD_F FW_FILTER_WR_OVLAN_VLD_V(1U) - -#define FW_FILTER_WR_IVLAN_VLDM_S 3 -#define FW_FILTER_WR_IVLAN_VLDM_M 0x1 -#define FW_FILTER_WR_IVLAN_VLDM_V(x) ((x) << FW_FILTER_WR_IVLAN_VLDM_S) -#define FW_FILTER_WR_IVLAN_VLDM_G(x) \ - (((x) >> FW_FILTER_WR_IVLAN_VLDM_S) & FW_FILTER_WR_IVLAN_VLDM_M) -#define FW_FILTER_WR_IVLAN_VLDM_F FW_FILTER_WR_IVLAN_VLDM_V(1U) - -#define FW_FILTER_WR_OVLAN_VLDM_S 2 -#define FW_FILTER_WR_OVLAN_VLDM_M 0x1 -#define FW_FILTER_WR_OVLAN_VLDM_V(x) ((x) << FW_FILTER_WR_OVLAN_VLDM_S) -#define FW_FILTER_WR_OVLAN_VLDM_G(x) \ - (((x) >> FW_FILTER_WR_OVLAN_VLDM_S) & FW_FILTER_WR_OVLAN_VLDM_M) -#define FW_FILTER_WR_OVLAN_VLDM_F FW_FILTER_WR_OVLAN_VLDM_V(1U) - -#define FW_FILTER_WR_RX_CHAN_S 15 -#define FW_FILTER_WR_RX_CHAN_M 0x1 -#define FW_FILTER_WR_RX_CHAN_V(x) ((x) << FW_FILTER_WR_RX_CHAN_S) -#define FW_FILTER_WR_RX_CHAN_G(x) \ - (((x) >> FW_FILTER_WR_RX_CHAN_S) & FW_FILTER_WR_RX_CHAN_M) -#define FW_FILTER_WR_RX_CHAN_F FW_FILTER_WR_RX_CHAN_V(1U) - -#define FW_FILTER_WR_RX_RPL_IQ_S 0 -#define FW_FILTER_WR_RX_RPL_IQ_M 0x3ff -#define FW_FILTER_WR_RX_RPL_IQ_V(x) ((x) << FW_FILTER_WR_RX_RPL_IQ_S) -#define FW_FILTER_WR_RX_RPL_IQ_G(x) \ - (((x) >> FW_FILTER_WR_RX_RPL_IQ_S) & FW_FILTER_WR_RX_RPL_IQ_M) - -#define FW_FILTER_WR_MACI_S 23 -#define FW_FILTER_WR_MACI_M 0x1ff -#define FW_FILTER_WR_MACI_V(x) ((x) << FW_FILTER_WR_MACI_S) -#define FW_FILTER_WR_MACI_G(x) \ - (((x) >> FW_FILTER_WR_MACI_S) & FW_FILTER_WR_MACI_M) - -#define FW_FILTER_WR_MACIM_S 14 -#define FW_FILTER_WR_MACIM_M 0x1ff -#define FW_FILTER_WR_MACIM_V(x) ((x) << FW_FILTER_WR_MACIM_S) -#define FW_FILTER_WR_MACIM_G(x) \ - (((x) >> FW_FILTER_WR_MACIM_S) & FW_FILTER_WR_MACIM_M) - -#define FW_FILTER_WR_FCOE_S 13 -#define FW_FILTER_WR_FCOE_M 0x1 -#define FW_FILTER_WR_FCOE_V(x) ((x) << FW_FILTER_WR_FCOE_S) -#define FW_FILTER_WR_FCOE_G(x) \ - (((x) >> FW_FILTER_WR_FCOE_S) & FW_FILTER_WR_FCOE_M) -#define FW_FILTER_WR_FCOE_F FW_FILTER_WR_FCOE_V(1U) - -#define FW_FILTER_WR_FCOEM_S 12 -#define FW_FILTER_WR_FCOEM_M 0x1 -#define FW_FILTER_WR_FCOEM_V(x) ((x) << FW_FILTER_WR_FCOEM_S) -#define FW_FILTER_WR_FCOEM_G(x) \ - (((x) >> FW_FILTER_WR_FCOEM_S) & FW_FILTER_WR_FCOEM_M) -#define FW_FILTER_WR_FCOEM_F FW_FILTER_WR_FCOEM_V(1U) - -#define FW_FILTER_WR_PORT_S 9 -#define FW_FILTER_WR_PORT_M 0x7 -#define FW_FILTER_WR_PORT_V(x) ((x) << FW_FILTER_WR_PORT_S) -#define FW_FILTER_WR_PORT_G(x) \ - (((x) >> FW_FILTER_WR_PORT_S) & FW_FILTER_WR_PORT_M) - -#define FW_FILTER_WR_PORTM_S 6 -#define FW_FILTER_WR_PORTM_M 0x7 -#define FW_FILTER_WR_PORTM_V(x) ((x) << FW_FILTER_WR_PORTM_S) -#define FW_FILTER_WR_PORTM_G(x) \ - (((x) >> FW_FILTER_WR_PORTM_S) & FW_FILTER_WR_PORTM_M) - -#define FW_FILTER_WR_MATCHTYPE_S 3 -#define FW_FILTER_WR_MATCHTYPE_M 0x7 -#define FW_FILTER_WR_MATCHTYPE_V(x) ((x) << FW_FILTER_WR_MATCHTYPE_S) -#define FW_FILTER_WR_MATCHTYPE_G(x) \ - (((x) >> FW_FILTER_WR_MATCHTYPE_S) & FW_FILTER_WR_MATCHTYPE_M) - -#define FW_FILTER_WR_MATCHTYPEM_S 0 -#define FW_FILTER_WR_MATCHTYPEM_M 0x7 -#define FW_FILTER_WR_MATCHTYPEM_V(x) ((x) << FW_FILTER_WR_MATCHTYPEM_S) -#define FW_FILTER_WR_MATCHTYPEM_G(x) \ - (((x) >> FW_FILTER_WR_MATCHTYPEM_S) & FW_FILTER_WR_MATCHTYPEM_M) - -struct fw_ulptx_wr { - __be32 op_to_compl; - __be32 flowid_len16; - u64 cookie; -}; - -struct fw_tp_wr { - __be32 op_to_immdlen; - __be32 flowid_len16; - u64 cookie; -}; - -struct fw_eth_tx_pkt_wr { - __be32 op_immdlen; - __be32 equiq_to_len16; - __be64 r3; -}; - -struct fw_ofld_connection_wr { - __be32 op_compl; - __be32 len16_pkd; - __u64 cookie; - __be64 r2; - __be64 r3; - struct fw_ofld_connection_le { - __be32 version_cpl; - __be32 filter; - __be32 r1; - __be16 lport; - __be16 pport; - union fw_ofld_connection_leip { - struct fw_ofld_connection_le_ipv4 { - __be32 pip; - __be32 lip; - __be64 r0; - __be64 r1; - __be64 r2; - } ipv4; - struct fw_ofld_connection_le_ipv6 { - __be64 pip_hi; - __be64 pip_lo; - __be64 lip_hi; - __be64 lip_lo; - } ipv6; - } u; - } le; - struct fw_ofld_connection_tcb { - __be32 t_state_to_astid; - __be16 cplrxdataack_cplpassacceptrpl; - __be16 rcv_adv; - __be32 rcv_nxt; - __be32 tx_max; - __be64 opt0; - __be32 opt2; - __be32 r1; - __be64 r2; - __be64 r3; - } tcb; -}; - -#define FW_OFLD_CONNECTION_WR_VERSION_S 31 -#define FW_OFLD_CONNECTION_WR_VERSION_M 0x1 -#define FW_OFLD_CONNECTION_WR_VERSION_V(x) \ - ((x) << FW_OFLD_CONNECTION_WR_VERSION_S) -#define FW_OFLD_CONNECTION_WR_VERSION_G(x) \ - (((x) >> FW_OFLD_CONNECTION_WR_VERSION_S) & \ - FW_OFLD_CONNECTION_WR_VERSION_M) -#define FW_OFLD_CONNECTION_WR_VERSION_F \ - FW_OFLD_CONNECTION_WR_VERSION_V(1U) - -#define FW_OFLD_CONNECTION_WR_CPL_S 30 -#define FW_OFLD_CONNECTION_WR_CPL_M 0x1 -#define FW_OFLD_CONNECTION_WR_CPL_V(x) ((x) << FW_OFLD_CONNECTION_WR_CPL_S) -#define FW_OFLD_CONNECTION_WR_CPL_G(x) \ - (((x) >> FW_OFLD_CONNECTION_WR_CPL_S) & FW_OFLD_CONNECTION_WR_CPL_M) -#define FW_OFLD_CONNECTION_WR_CPL_F FW_OFLD_CONNECTION_WR_CPL_V(1U) - -#define FW_OFLD_CONNECTION_WR_T_STATE_S 28 -#define FW_OFLD_CONNECTION_WR_T_STATE_M 0xf -#define FW_OFLD_CONNECTION_WR_T_STATE_V(x) \ - ((x) << FW_OFLD_CONNECTION_WR_T_STATE_S) -#define FW_OFLD_CONNECTION_WR_T_STATE_G(x) \ - (((x) >> FW_OFLD_CONNECTION_WR_T_STATE_S) & \ - FW_OFLD_CONNECTION_WR_T_STATE_M) - -#define FW_OFLD_CONNECTION_WR_RCV_SCALE_S 24 -#define FW_OFLD_CONNECTION_WR_RCV_SCALE_M 0xf -#define FW_OFLD_CONNECTION_WR_RCV_SCALE_V(x) \ - ((x) << FW_OFLD_CONNECTION_WR_RCV_SCALE_S) -#define FW_OFLD_CONNECTION_WR_RCV_SCALE_G(x) \ - (((x) >> FW_OFLD_CONNECTION_WR_RCV_SCALE_S) & \ - FW_OFLD_CONNECTION_WR_RCV_SCALE_M) - -#define FW_OFLD_CONNECTION_WR_ASTID_S 0 -#define FW_OFLD_CONNECTION_WR_ASTID_M 0xffffff -#define FW_OFLD_CONNECTION_WR_ASTID_V(x) \ - ((x) << FW_OFLD_CONNECTION_WR_ASTID_S) -#define FW_OFLD_CONNECTION_WR_ASTID_G(x) \ - (((x) >> FW_OFLD_CONNECTION_WR_ASTID_S) & FW_OFLD_CONNECTION_WR_ASTID_M) - -#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_S 15 -#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_M 0x1 -#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_V(x) \ - ((x) << FW_OFLD_CONNECTION_WR_CPLRXDATAACK_S) -#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_G(x) \ - (((x) >> FW_OFLD_CONNECTION_WR_CPLRXDATAACK_S) & \ - FW_OFLD_CONNECTION_WR_CPLRXDATAACK_M) -#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_F \ - FW_OFLD_CONNECTION_WR_CPLRXDATAACK_V(1U) - -#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_S 14 -#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_M 0x1 -#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_V(x) \ - ((x) << FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_S) -#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_G(x) \ - (((x) >> FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_S) & \ - FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_M) -#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_F \ - FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_V(1U) - -enum fw_flowc_mnem { - FW_FLOWC_MNEM_PFNVFN, /* PFN [15:8] VFN [7:0] */ - FW_FLOWC_MNEM_CH, - FW_FLOWC_MNEM_PORT, - FW_FLOWC_MNEM_IQID, - FW_FLOWC_MNEM_SNDNXT, - FW_FLOWC_MNEM_RCVNXT, - FW_FLOWC_MNEM_SNDBUF, - FW_FLOWC_MNEM_MSS, - FW_FLOWC_MNEM_TXDATAPLEN_MAX, - FW_FLOWC_MNEM_TCPSTATE, - FW_FLOWC_MNEM_EOSTATE, - FW_FLOWC_MNEM_SCHEDCLASS, - FW_FLOWC_MNEM_DCBPRIO, - FW_FLOWC_MNEM_SND_SCALE, - FW_FLOWC_MNEM_RCV_SCALE, -}; - -struct fw_flowc_mnemval { - u8 mnemonic; - u8 r4[3]; - __be32 val; -}; - -struct fw_flowc_wr { - __be32 op_to_nparams; - __be32 flowid_len16; - struct fw_flowc_mnemval mnemval[0]; -}; - -#define FW_FLOWC_WR_NPARAMS_S 0 -#define FW_FLOWC_WR_NPARAMS_V(x) ((x) << FW_FLOWC_WR_NPARAMS_S) - -struct fw_ofld_tx_data_wr { - __be32 op_to_immdlen; - __be32 flowid_len16; - __be32 plen; - __be32 tunnel_to_proxy; -}; - -#define FW_OFLD_TX_DATA_WR_TUNNEL_S 19 -#define FW_OFLD_TX_DATA_WR_TUNNEL_V(x) ((x) << FW_OFLD_TX_DATA_WR_TUNNEL_S) - -#define FW_OFLD_TX_DATA_WR_SAVE_S 18 -#define FW_OFLD_TX_DATA_WR_SAVE_V(x) ((x) << FW_OFLD_TX_DATA_WR_SAVE_S) - -#define FW_OFLD_TX_DATA_WR_FLUSH_S 17 -#define FW_OFLD_TX_DATA_WR_FLUSH_V(x) ((x) << FW_OFLD_TX_DATA_WR_FLUSH_S) -#define FW_OFLD_TX_DATA_WR_FLUSH_F FW_OFLD_TX_DATA_WR_FLUSH_V(1U) - -#define FW_OFLD_TX_DATA_WR_URGENT_S 16 -#define FW_OFLD_TX_DATA_WR_URGENT_V(x) ((x) << FW_OFLD_TX_DATA_WR_URGENT_S) - -#define FW_OFLD_TX_DATA_WR_MORE_S 15 -#define FW_OFLD_TX_DATA_WR_MORE_V(x) ((x) << FW_OFLD_TX_DATA_WR_MORE_S) - -#define FW_OFLD_TX_DATA_WR_SHOVE_S 14 -#define FW_OFLD_TX_DATA_WR_SHOVE_V(x) ((x) << FW_OFLD_TX_DATA_WR_SHOVE_S) -#define FW_OFLD_TX_DATA_WR_SHOVE_F FW_OFLD_TX_DATA_WR_SHOVE_V(1U) - -#define FW_OFLD_TX_DATA_WR_ULPMODE_S 10 -#define FW_OFLD_TX_DATA_WR_ULPMODE_V(x) ((x) << FW_OFLD_TX_DATA_WR_ULPMODE_S) - -#define FW_OFLD_TX_DATA_WR_ULPSUBMODE_S 6 -#define FW_OFLD_TX_DATA_WR_ULPSUBMODE_V(x) \ - ((x) << FW_OFLD_TX_DATA_WR_ULPSUBMODE_S) - -struct fw_cmd_wr { - __be32 op_dma; - __be32 len16_pkd; - __be64 cookie_daddr; -}; - -#define FW_CMD_WR_DMA_S 17 -#define FW_CMD_WR_DMA_V(x) ((x) << FW_CMD_WR_DMA_S) - -struct fw_eth_tx_pkt_vm_wr { - __be32 op_immdlen; - __be32 equiq_to_len16; - __be32 r3[2]; - u8 ethmacdst[6]; - u8 ethmacsrc[6]; - __be16 ethtype; - __be16 vlantci; -}; - -#define FW_CMD_MAX_TIMEOUT 10000 - -/* - * If a host driver does a HELLO and discovers that there's already a MASTER - * selected, we may have to wait for that MASTER to finish issuing RESET, - * configuration and INITIALIZE commands. Also, there's a possibility that - * our own HELLO may get lost if it happens right as the MASTER is issuign a - * RESET command, so we need to be willing to make a few retries of our HELLO. - */ -#define FW_CMD_HELLO_TIMEOUT (3 * FW_CMD_MAX_TIMEOUT) -#define FW_CMD_HELLO_RETRIES 3 - - -enum fw_cmd_opcodes { - FW_LDST_CMD = 0x01, - FW_RESET_CMD = 0x03, - FW_HELLO_CMD = 0x04, - FW_BYE_CMD = 0x05, - FW_INITIALIZE_CMD = 0x06, - FW_CAPS_CONFIG_CMD = 0x07, - FW_PARAMS_CMD = 0x08, - FW_PFVF_CMD = 0x09, - FW_IQ_CMD = 0x10, - FW_EQ_MNGT_CMD = 0x11, - FW_EQ_ETH_CMD = 0x12, - FW_EQ_CTRL_CMD = 0x13, - FW_EQ_OFLD_CMD = 0x21, - FW_VI_CMD = 0x14, - FW_VI_MAC_CMD = 0x15, - FW_VI_RXMODE_CMD = 0x16, - FW_VI_ENABLE_CMD = 0x17, - FW_ACL_MAC_CMD = 0x18, - FW_ACL_VLAN_CMD = 0x19, - FW_VI_STATS_CMD = 0x1a, - FW_PORT_CMD = 0x1b, - FW_PORT_STATS_CMD = 0x1c, - FW_PORT_LB_STATS_CMD = 0x1d, - FW_PORT_TRACE_CMD = 0x1e, - FW_PORT_TRACE_MMAP_CMD = 0x1f, - FW_RSS_IND_TBL_CMD = 0x20, - FW_RSS_GLB_CONFIG_CMD = 0x22, - FW_RSS_VI_CONFIG_CMD = 0x23, - FW_DEVLOG_CMD = 0x25, - FW_CLIP_CMD = 0x28, - FW_LASTC2E_CMD = 0x40, - FW_ERROR_CMD = 0x80, - FW_DEBUG_CMD = 0x81, -}; - -enum fw_cmd_cap { - FW_CMD_CAP_PF = 0x01, - FW_CMD_CAP_DMAQ = 0x02, - FW_CMD_CAP_PORT = 0x04, - FW_CMD_CAP_PORTPROMISC = 0x08, - FW_CMD_CAP_PORTSTATS = 0x10, - FW_CMD_CAP_VF = 0x80, -}; - -/* - * Generic command header flit0 - */ -struct fw_cmd_hdr { - __be32 hi; - __be32 lo; -}; - -#define FW_CMD_OP_S 24 -#define FW_CMD_OP_M 0xff -#define FW_CMD_OP_V(x) ((x) << FW_CMD_OP_S) -#define FW_CMD_OP_G(x) (((x) >> FW_CMD_OP_S) & FW_CMD_OP_M) - -#define FW_CMD_REQUEST_S 23 -#define FW_CMD_REQUEST_V(x) ((x) << FW_CMD_REQUEST_S) -#define FW_CMD_REQUEST_F FW_CMD_REQUEST_V(1U) - -#define FW_CMD_READ_S 22 -#define FW_CMD_READ_V(x) ((x) << FW_CMD_READ_S) -#define FW_CMD_READ_F FW_CMD_READ_V(1U) - -#define FW_CMD_WRITE_S 21 -#define FW_CMD_WRITE_V(x) ((x) << FW_CMD_WRITE_S) -#define FW_CMD_WRITE_F FW_CMD_WRITE_V(1U) - -#define FW_CMD_EXEC_S 20 -#define FW_CMD_EXEC_V(x) ((x) << FW_CMD_EXEC_S) -#define FW_CMD_EXEC_F FW_CMD_EXEC_V(1U) - -#define FW_CMD_RAMASK_S 20 -#define FW_CMD_RAMASK_V(x) ((x) << FW_CMD_RAMASK_S) - -#define FW_CMD_RETVAL_S 8 -#define FW_CMD_RETVAL_M 0xff -#define FW_CMD_RETVAL_V(x) ((x) << FW_CMD_RETVAL_S) -#define FW_CMD_RETVAL_G(x) (((x) >> FW_CMD_RETVAL_S) & FW_CMD_RETVAL_M) - -#define FW_CMD_LEN16_S 0 -#define FW_CMD_LEN16_V(x) ((x) << FW_CMD_LEN16_S) - -#define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16) - -enum fw_ldst_addrspc { - FW_LDST_ADDRSPC_FIRMWARE = 0x0001, - FW_LDST_ADDRSPC_SGE_EGRC = 0x0008, - FW_LDST_ADDRSPC_SGE_INGC = 0x0009, - FW_LDST_ADDRSPC_SGE_FLMC = 0x000a, - FW_LDST_ADDRSPC_SGE_CONMC = 0x000b, - FW_LDST_ADDRSPC_TP_PIO = 0x0010, - FW_LDST_ADDRSPC_TP_TM_PIO = 0x0011, - FW_LDST_ADDRSPC_TP_MIB = 0x0012, - FW_LDST_ADDRSPC_MDIO = 0x0018, - FW_LDST_ADDRSPC_MPS = 0x0020, - FW_LDST_ADDRSPC_FUNC = 0x0028, - FW_LDST_ADDRSPC_FUNC_PCIE = 0x0029, -}; - -enum fw_ldst_mps_fid { - FW_LDST_MPS_ATRB, - FW_LDST_MPS_RPLC -}; - -enum fw_ldst_func_access_ctl { - FW_LDST_FUNC_ACC_CTL_VIID, - FW_LDST_FUNC_ACC_CTL_FID -}; - -enum fw_ldst_func_mod_index { - FW_LDST_FUNC_MPS -}; - -struct fw_ldst_cmd { - __be32 op_to_addrspace; - __be32 cycles_to_len16; - union fw_ldst { - struct fw_ldst_addrval { - __be32 addr; - __be32 val; - } addrval; - struct fw_ldst_idctxt { - __be32 physid; - __be32 msg_ctxtflush; - __be32 ctxt_data7; - __be32 ctxt_data6; - __be32 ctxt_data5; - __be32 ctxt_data4; - __be32 ctxt_data3; - __be32 ctxt_data2; - __be32 ctxt_data1; - __be32 ctxt_data0; - } idctxt; - struct fw_ldst_mdio { - __be16 paddr_mmd; - __be16 raddr; - __be16 vctl; - __be16 rval; - } mdio; - struct fw_ldst_cim_rq { - u8 req_first64[8]; - u8 req_second64[8]; - u8 resp_first64[8]; - u8 resp_second64[8]; - __be32 r3[2]; - } cim_rq; - union fw_ldst_mps { - struct fw_ldst_mps_rplc { - __be16 fid_idx; - __be16 rplcpf_pkd; - __be32 rplc255_224; - __be32 rplc223_192; - __be32 rplc191_160; - __be32 rplc159_128; - __be32 rplc127_96; - __be32 rplc95_64; - __be32 rplc63_32; - __be32 rplc31_0; - } rplc; - struct fw_ldst_mps_atrb { - __be16 fid_mpsid; - __be16 r2[3]; - __be32 r3[2]; - __be32 r4; - __be32 atrb; - __be16 vlan[16]; - } atrb; - } mps; - struct fw_ldst_func { - u8 access_ctl; - u8 mod_index; - __be16 ctl_id; - __be32 offset; - __be64 data0; - __be64 data1; - } func; - struct fw_ldst_pcie { - u8 ctrl_to_fn; - u8 bnum; - u8 r; - u8 ext_r; - u8 select_naccess; - u8 pcie_fn; - __be16 nset_pkd; - __be32 data[12]; - } pcie; - struct fw_ldst_i2c_deprecated { - u8 pid_pkd; - u8 base; - u8 boffset; - u8 data; - __be32 r9; - } i2c_deprecated; - struct fw_ldst_i2c { - u8 pid; - u8 did; - u8 boffset; - u8 blen; - __be32 r9; - __u8 data[48]; - } i2c; - struct fw_ldst_le { - __be32 index; - __be32 r9; - u8 val[33]; - u8 r11[7]; - } le; - } u; -}; - -#define FW_LDST_CMD_ADDRSPACE_S 0 -#define FW_LDST_CMD_ADDRSPACE_V(x) ((x) << FW_LDST_CMD_ADDRSPACE_S) - -#define FW_LDST_CMD_MSG_S 31 -#define FW_LDST_CMD_MSG_V(x) ((x) << FW_LDST_CMD_MSG_S) - -#define FW_LDST_CMD_CTXTFLUSH_S 30 -#define FW_LDST_CMD_CTXTFLUSH_V(x) ((x) << FW_LDST_CMD_CTXTFLUSH_S) -#define FW_LDST_CMD_CTXTFLUSH_F FW_LDST_CMD_CTXTFLUSH_V(1U) - -#define FW_LDST_CMD_PADDR_S 8 -#define FW_LDST_CMD_PADDR_V(x) ((x) << FW_LDST_CMD_PADDR_S) - -#define FW_LDST_CMD_MMD_S 0 -#define FW_LDST_CMD_MMD_V(x) ((x) << FW_LDST_CMD_MMD_S) - -#define FW_LDST_CMD_FID_S 15 -#define FW_LDST_CMD_FID_V(x) ((x) << FW_LDST_CMD_FID_S) - -#define FW_LDST_CMD_IDX_S 0 -#define FW_LDST_CMD_IDX_V(x) ((x) << FW_LDST_CMD_IDX_S) - -#define FW_LDST_CMD_RPLCPF_S 0 -#define FW_LDST_CMD_RPLCPF_V(x) ((x) << FW_LDST_CMD_RPLCPF_S) - -#define FW_LDST_CMD_LC_S 4 -#define FW_LDST_CMD_LC_V(x) ((x) << FW_LDST_CMD_LC_S) -#define FW_LDST_CMD_LC_F FW_LDST_CMD_LC_V(1U) - -#define FW_LDST_CMD_FN_S 0 -#define FW_LDST_CMD_FN_V(x) ((x) << FW_LDST_CMD_FN_S) - -#define FW_LDST_CMD_NACCESS_S 0 -#define FW_LDST_CMD_NACCESS_V(x) ((x) << FW_LDST_CMD_NACCESS_S) - -struct fw_reset_cmd { - __be32 op_to_write; - __be32 retval_len16; - __be32 val; - __be32 halt_pkd; -}; - -#define FW_RESET_CMD_HALT_S 31 -#define FW_RESET_CMD_HALT_M 0x1 -#define FW_RESET_CMD_HALT_V(x) ((x) << FW_RESET_CMD_HALT_S) -#define FW_RESET_CMD_HALT_G(x) \ - (((x) >> FW_RESET_CMD_HALT_S) & FW_RESET_CMD_HALT_M) -#define FW_RESET_CMD_HALT_F FW_RESET_CMD_HALT_V(1U) - -enum fw_hellow_cmd { - fw_hello_cmd_stage_os = 0x0 -}; - -struct fw_hello_cmd { - __be32 op_to_write; - __be32 retval_len16; - __be32 err_to_clearinit; - __be32 fwrev; -}; - -#define FW_HELLO_CMD_ERR_S 31 -#define FW_HELLO_CMD_ERR_V(x) ((x) << FW_HELLO_CMD_ERR_S) -#define FW_HELLO_CMD_ERR_F FW_HELLO_CMD_ERR_V(1U) - -#define FW_HELLO_CMD_INIT_S 30 -#define FW_HELLO_CMD_INIT_V(x) ((x) << FW_HELLO_CMD_INIT_S) -#define FW_HELLO_CMD_INIT_F FW_HELLO_CMD_INIT_V(1U) - -#define FW_HELLO_CMD_MASTERDIS_S 29 -#define FW_HELLO_CMD_MASTERDIS_V(x) ((x) << FW_HELLO_CMD_MASTERDIS_S) - -#define FW_HELLO_CMD_MASTERFORCE_S 28 -#define FW_HELLO_CMD_MASTERFORCE_V(x) ((x) << FW_HELLO_CMD_MASTERFORCE_S) - -#define FW_HELLO_CMD_MBMASTER_S 24 -#define FW_HELLO_CMD_MBMASTER_M 0xfU -#define FW_HELLO_CMD_MBMASTER_V(x) ((x) << FW_HELLO_CMD_MBMASTER_S) -#define FW_HELLO_CMD_MBMASTER_G(x) \ - (((x) >> FW_HELLO_CMD_MBMASTER_S) & FW_HELLO_CMD_MBMASTER_M) - -#define FW_HELLO_CMD_MBASYNCNOTINT_S 23 -#define FW_HELLO_CMD_MBASYNCNOTINT_V(x) ((x) << FW_HELLO_CMD_MBASYNCNOTINT_S) - -#define FW_HELLO_CMD_MBASYNCNOT_S 20 -#define FW_HELLO_CMD_MBASYNCNOT_V(x) ((x) << FW_HELLO_CMD_MBASYNCNOT_S) - -#define FW_HELLO_CMD_STAGE_S 17 -#define FW_HELLO_CMD_STAGE_V(x) ((x) << FW_HELLO_CMD_STAGE_S) - -#define FW_HELLO_CMD_CLEARINIT_S 16 -#define FW_HELLO_CMD_CLEARINIT_V(x) ((x) << FW_HELLO_CMD_CLEARINIT_S) -#define FW_HELLO_CMD_CLEARINIT_F FW_HELLO_CMD_CLEARINIT_V(1U) - -struct fw_bye_cmd { - __be32 op_to_write; - __be32 retval_len16; - __be64 r3; -}; - -struct fw_initialize_cmd { - __be32 op_to_write; - __be32 retval_len16; - __be64 r3; -}; - -enum fw_caps_config_hm { - FW_CAPS_CONFIG_HM_PCIE = 0x00000001, - FW_CAPS_CONFIG_HM_PL = 0x00000002, - FW_CAPS_CONFIG_HM_SGE = 0x00000004, - FW_CAPS_CONFIG_HM_CIM = 0x00000008, - FW_CAPS_CONFIG_HM_ULPTX = 0x00000010, - FW_CAPS_CONFIG_HM_TP = 0x00000020, - FW_CAPS_CONFIG_HM_ULPRX = 0x00000040, - FW_CAPS_CONFIG_HM_PMRX = 0x00000080, - FW_CAPS_CONFIG_HM_PMTX = 0x00000100, - FW_CAPS_CONFIG_HM_MC = 0x00000200, - FW_CAPS_CONFIG_HM_LE = 0x00000400, - FW_CAPS_CONFIG_HM_MPS = 0x00000800, - FW_CAPS_CONFIG_HM_XGMAC = 0x00001000, - FW_CAPS_CONFIG_HM_CPLSWITCH = 0x00002000, - FW_CAPS_CONFIG_HM_T4DBG = 0x00004000, - FW_CAPS_CONFIG_HM_MI = 0x00008000, - FW_CAPS_CONFIG_HM_I2CM = 0x00010000, - FW_CAPS_CONFIG_HM_NCSI = 0x00020000, - FW_CAPS_CONFIG_HM_SMB = 0x00040000, - FW_CAPS_CONFIG_HM_MA = 0x00080000, - FW_CAPS_CONFIG_HM_EDRAM = 0x00100000, - FW_CAPS_CONFIG_HM_PMU = 0x00200000, - FW_CAPS_CONFIG_HM_UART = 0x00400000, - FW_CAPS_CONFIG_HM_SF = 0x00800000, -}; - -enum fw_caps_config_nbm { - FW_CAPS_CONFIG_NBM_IPMI = 0x00000001, - FW_CAPS_CONFIG_NBM_NCSI = 0x00000002, -}; - -enum fw_caps_config_link { - FW_CAPS_CONFIG_LINK_PPP = 0x00000001, - FW_CAPS_CONFIG_LINK_QFC = 0x00000002, - FW_CAPS_CONFIG_LINK_DCBX = 0x00000004, -}; - -enum fw_caps_config_switch { - FW_CAPS_CONFIG_SWITCH_INGRESS = 0x00000001, - FW_CAPS_CONFIG_SWITCH_EGRESS = 0x00000002, -}; - -enum fw_caps_config_nic { - FW_CAPS_CONFIG_NIC = 0x00000001, - FW_CAPS_CONFIG_NIC_VM = 0x00000002, -}; - -enum fw_caps_config_ofld { - FW_CAPS_CONFIG_OFLD = 0x00000001, -}; - -enum fw_caps_config_rdma { - FW_CAPS_CONFIG_RDMA_RDDP = 0x00000001, - FW_CAPS_CONFIG_RDMA_RDMAC = 0x00000002, -}; - -enum fw_caps_config_iscsi { - FW_CAPS_CONFIG_ISCSI_INITIATOR_PDU = 0x00000001, - FW_CAPS_CONFIG_ISCSI_TARGET_PDU = 0x00000002, - FW_CAPS_CONFIG_ISCSI_INITIATOR_CNXOFLD = 0x00000004, - FW_CAPS_CONFIG_ISCSI_TARGET_CNXOFLD = 0x00000008, -}; - -enum fw_caps_config_fcoe { - FW_CAPS_CONFIG_FCOE_INITIATOR = 0x00000001, - FW_CAPS_CONFIG_FCOE_TARGET = 0x00000002, - FW_CAPS_CONFIG_FCOE_CTRL_OFLD = 0x00000004, -}; - -enum fw_memtype_cf { - FW_MEMTYPE_CF_EDC0 = 0x0, - FW_MEMTYPE_CF_EDC1 = 0x1, - FW_MEMTYPE_CF_EXTMEM = 0x2, - FW_MEMTYPE_CF_FLASH = 0x4, - FW_MEMTYPE_CF_INTERNAL = 0x5, - FW_MEMTYPE_CF_EXTMEM1 = 0x6, -}; - -struct fw_caps_config_cmd { - __be32 op_to_write; - __be32 cfvalid_to_len16; - __be32 r2; - __be32 hwmbitmap; - __be16 nbmcaps; - __be16 linkcaps; - __be16 switchcaps; - __be16 r3; - __be16 niccaps; - __be16 ofldcaps; - __be16 rdmacaps; - __be16 r4; - __be16 iscsicaps; - __be16 fcoecaps; - __be32 cfcsum; - __be32 finiver; - __be32 finicsum; -}; - -#define FW_CAPS_CONFIG_CMD_CFVALID_S 27 -#define FW_CAPS_CONFIG_CMD_CFVALID_V(x) ((x) << FW_CAPS_CONFIG_CMD_CFVALID_S) -#define FW_CAPS_CONFIG_CMD_CFVALID_F FW_CAPS_CONFIG_CMD_CFVALID_V(1U) - -#define FW_CAPS_CONFIG_CMD_MEMTYPE_CF_S 24 -#define FW_CAPS_CONFIG_CMD_MEMTYPE_CF_V(x) \ - ((x) << FW_CAPS_CONFIG_CMD_MEMTYPE_CF_S) - -#define FW_CAPS_CONFIG_CMD_MEMADDR64K_CF_S 16 -#define FW_CAPS_CONFIG_CMD_MEMADDR64K_CF_V(x) \ - ((x) << FW_CAPS_CONFIG_CMD_MEMADDR64K_CF_S) - -/* - * params command mnemonics - */ -enum fw_params_mnem { - FW_PARAMS_MNEM_DEV = 1, /* device params */ - FW_PARAMS_MNEM_PFVF = 2, /* function params */ - FW_PARAMS_MNEM_REG = 3, /* limited register access */ - FW_PARAMS_MNEM_DMAQ = 4, /* dma queue params */ - FW_PARAMS_MNEM_CHNET = 5, /* chnet params */ - FW_PARAMS_MNEM_LAST -}; - -/* - * device parameters - */ -enum fw_params_param_dev { - FW_PARAMS_PARAM_DEV_CCLK = 0x00, /* chip core clock in khz */ - FW_PARAMS_PARAM_DEV_PORTVEC = 0x01, /* the port vector */ - FW_PARAMS_PARAM_DEV_NTID = 0x02, /* reads the number of TIDs - * allocated by the device's - * Lookup Engine - */ - FW_PARAMS_PARAM_DEV_FLOWC_BUFFIFO_SZ = 0x03, - FW_PARAMS_PARAM_DEV_INTVER_NIC = 0x04, - FW_PARAMS_PARAM_DEV_INTVER_VNIC = 0x05, - FW_PARAMS_PARAM_DEV_INTVER_OFLD = 0x06, - FW_PARAMS_PARAM_DEV_INTVER_RI = 0x07, - FW_PARAMS_PARAM_DEV_INTVER_ISCSIPDU = 0x08, - FW_PARAMS_PARAM_DEV_INTVER_ISCSI = 0x09, - FW_PARAMS_PARAM_DEV_INTVER_FCOE = 0x0A, - FW_PARAMS_PARAM_DEV_FWREV = 0x0B, - FW_PARAMS_PARAM_DEV_TPREV = 0x0C, - FW_PARAMS_PARAM_DEV_CF = 0x0D, - FW_PARAMS_PARAM_DEV_PHYFW = 0x0F, - FW_PARAMS_PARAM_DEV_DIAG = 0x11, - FW_PARAMS_PARAM_DEV_MAXORDIRD_QP = 0x13, /* max supported QP IRD/ORD */ - FW_PARAMS_PARAM_DEV_MAXIRD_ADAPTER = 0x14, /* max supported adap IRD */ - FW_PARAMS_PARAM_DEV_ULPTX_MEMWRITE_DSGL = 0x17, - FW_PARAMS_PARAM_DEV_FWCACHE = 0x18, -}; - -/* - * physical and virtual function parameters - */ -enum fw_params_param_pfvf { - FW_PARAMS_PARAM_PFVF_RWXCAPS = 0x00, - FW_PARAMS_PARAM_PFVF_ROUTE_START = 0x01, - FW_PARAMS_PARAM_PFVF_ROUTE_END = 0x02, - FW_PARAMS_PARAM_PFVF_CLIP_START = 0x03, - FW_PARAMS_PARAM_PFVF_CLIP_END = 0x04, - FW_PARAMS_PARAM_PFVF_FILTER_START = 0x05, - FW_PARAMS_PARAM_PFVF_FILTER_END = 0x06, - FW_PARAMS_PARAM_PFVF_SERVER_START = 0x07, - FW_PARAMS_PARAM_PFVF_SERVER_END = 0x08, - FW_PARAMS_PARAM_PFVF_TDDP_START = 0x09, - FW_PARAMS_PARAM_PFVF_TDDP_END = 0x0A, - FW_PARAMS_PARAM_PFVF_ISCSI_START = 0x0B, - FW_PARAMS_PARAM_PFVF_ISCSI_END = 0x0C, - FW_PARAMS_PARAM_PFVF_STAG_START = 0x0D, - FW_PARAMS_PARAM_PFVF_STAG_END = 0x0E, - FW_PARAMS_PARAM_PFVF_RQ_START = 0x1F, - FW_PARAMS_PARAM_PFVF_RQ_END = 0x10, - FW_PARAMS_PARAM_PFVF_PBL_START = 0x11, - FW_PARAMS_PARAM_PFVF_PBL_END = 0x12, - FW_PARAMS_PARAM_PFVF_L2T_START = 0x13, - FW_PARAMS_PARAM_PFVF_L2T_END = 0x14, - FW_PARAMS_PARAM_PFVF_SQRQ_START = 0x15, - FW_PARAMS_PARAM_PFVF_SQRQ_END = 0x16, - FW_PARAMS_PARAM_PFVF_CQ_START = 0x17, - FW_PARAMS_PARAM_PFVF_CQ_END = 0x18, - FW_PARAMS_PARAM_PFVF_SCHEDCLASS_ETH = 0x20, - FW_PARAMS_PARAM_PFVF_VIID = 0x24, - FW_PARAMS_PARAM_PFVF_CPMASK = 0x25, - FW_PARAMS_PARAM_PFVF_OCQ_START = 0x26, - FW_PARAMS_PARAM_PFVF_OCQ_END = 0x27, - FW_PARAMS_PARAM_PFVF_CONM_MAP = 0x28, - FW_PARAMS_PARAM_PFVF_IQFLINT_START = 0x29, - FW_PARAMS_PARAM_PFVF_IQFLINT_END = 0x2A, - FW_PARAMS_PARAM_PFVF_EQ_START = 0x2B, - FW_PARAMS_PARAM_PFVF_EQ_END = 0x2C, - FW_PARAMS_PARAM_PFVF_ACTIVE_FILTER_START = 0x2D, - FW_PARAMS_PARAM_PFVF_ACTIVE_FILTER_END = 0x2E, - FW_PARAMS_PARAM_PFVF_ETHOFLD_END = 0x30, - FW_PARAMS_PARAM_PFVF_CPLFW4MSG_ENCAP = 0x31 -}; - -/* - * dma queue parameters - */ -enum fw_params_param_dmaq { - FW_PARAMS_PARAM_DMAQ_IQ_DCAEN_DCACPU = 0x00, - FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH = 0x01, - FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_MNGT = 0x10, - FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_CTRL = 0x11, - FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH = 0x12, - FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH = 0x13, - FW_PARAMS_PARAM_DMAQ_CONM_CTXT = 0x20, -}; - -enum fw_params_param_dev_phyfw { - FW_PARAMS_PARAM_DEV_PHYFW_DOWNLOAD = 0x00, - FW_PARAMS_PARAM_DEV_PHYFW_VERSION = 0x01, -}; - -enum fw_params_param_dev_diag { - FW_PARAM_DEV_DIAG_TMP = 0x00, - FW_PARAM_DEV_DIAG_VDD = 0x01, -}; - -enum fw_params_param_dev_fwcache { - FW_PARAM_DEV_FWCACHE_FLUSH = 0x00, - FW_PARAM_DEV_FWCACHE_FLUSHINV = 0x01, -}; - -#define FW_PARAMS_MNEM_S 24 -#define FW_PARAMS_MNEM_V(x) ((x) << FW_PARAMS_MNEM_S) - -#define FW_PARAMS_PARAM_X_S 16 -#define FW_PARAMS_PARAM_X_V(x) ((x) << FW_PARAMS_PARAM_X_S) - -#define FW_PARAMS_PARAM_Y_S 8 -#define FW_PARAMS_PARAM_Y_M 0xffU -#define FW_PARAMS_PARAM_Y_V(x) ((x) << FW_PARAMS_PARAM_Y_S) -#define FW_PARAMS_PARAM_Y_G(x) (((x) >> FW_PARAMS_PARAM_Y_S) &\ - FW_PARAMS_PARAM_Y_M) - -#define FW_PARAMS_PARAM_Z_S 0 -#define FW_PARAMS_PARAM_Z_M 0xffu -#define FW_PARAMS_PARAM_Z_V(x) ((x) << FW_PARAMS_PARAM_Z_S) -#define FW_PARAMS_PARAM_Z_G(x) (((x) >> FW_PARAMS_PARAM_Z_S) &\ - FW_PARAMS_PARAM_Z_M) - -#define FW_PARAMS_PARAM_XYZ_S 0 -#define FW_PARAMS_PARAM_XYZ_V(x) ((x) << FW_PARAMS_PARAM_XYZ_S) - -#define FW_PARAMS_PARAM_YZ_S 0 -#define FW_PARAMS_PARAM_YZ_V(x) ((x) << FW_PARAMS_PARAM_YZ_S) - -struct fw_params_cmd { - __be32 op_to_vfn; - __be32 retval_len16; - struct fw_params_param { - __be32 mnem; - __be32 val; - } param[7]; -}; - -#define FW_PARAMS_CMD_PFN_S 8 -#define FW_PARAMS_CMD_PFN_V(x) ((x) << FW_PARAMS_CMD_PFN_S) - -#define FW_PARAMS_CMD_VFN_S 0 -#define FW_PARAMS_CMD_VFN_V(x) ((x) << FW_PARAMS_CMD_VFN_S) - -struct fw_pfvf_cmd { - __be32 op_to_vfn; - __be32 retval_len16; - __be32 niqflint_niq; - __be32 type_to_neq; - __be32 tc_to_nexactf; - __be32 r_caps_to_nethctrl; - __be16 nricq; - __be16 nriqp; - __be32 r4; -}; - -#define FW_PFVF_CMD_PFN_S 8 -#define FW_PFVF_CMD_PFN_V(x) ((x) << FW_PFVF_CMD_PFN_S) - -#define FW_PFVF_CMD_VFN_S 0 -#define FW_PFVF_CMD_VFN_V(x) ((x) << FW_PFVF_CMD_VFN_S) - -#define FW_PFVF_CMD_NIQFLINT_S 20 -#define FW_PFVF_CMD_NIQFLINT_M 0xfff -#define FW_PFVF_CMD_NIQFLINT_V(x) ((x) << FW_PFVF_CMD_NIQFLINT_S) -#define FW_PFVF_CMD_NIQFLINT_G(x) \ - (((x) >> FW_PFVF_CMD_NIQFLINT_S) & FW_PFVF_CMD_NIQFLINT_M) - -#define FW_PFVF_CMD_NIQ_S 0 -#define FW_PFVF_CMD_NIQ_M 0xfffff -#define FW_PFVF_CMD_NIQ_V(x) ((x) << FW_PFVF_CMD_NIQ_S) -#define FW_PFVF_CMD_NIQ_G(x) \ - (((x) >> FW_PFVF_CMD_NIQ_S) & FW_PFVF_CMD_NIQ_M) - -#define FW_PFVF_CMD_TYPE_S 31 -#define FW_PFVF_CMD_TYPE_M 0x1 -#define FW_PFVF_CMD_TYPE_V(x) ((x) << FW_PFVF_CMD_TYPE_S) -#define FW_PFVF_CMD_TYPE_G(x) \ - (((x) >> FW_PFVF_CMD_TYPE_S) & FW_PFVF_CMD_TYPE_M) -#define FW_PFVF_CMD_TYPE_F FW_PFVF_CMD_TYPE_V(1U) - -#define FW_PFVF_CMD_CMASK_S 24 -#define FW_PFVF_CMD_CMASK_M 0xf -#define FW_PFVF_CMD_CMASK_V(x) ((x) << FW_PFVF_CMD_CMASK_S) -#define FW_PFVF_CMD_CMASK_G(x) \ - (((x) >> FW_PFVF_CMD_CMASK_S) & FW_PFVF_CMD_CMASK_M) - -#define FW_PFVF_CMD_PMASK_S 20 -#define FW_PFVF_CMD_PMASK_M 0xf -#define FW_PFVF_CMD_PMASK_V(x) ((x) << FW_PFVF_CMD_PMASK_S) -#define FW_PFVF_CMD_PMASK_G(x) \ - (((x) >> FW_PFVF_CMD_PMASK_S) & FW_PFVF_CMD_PMASK_M) - -#define FW_PFVF_CMD_NEQ_S 0 -#define FW_PFVF_CMD_NEQ_M 0xfffff -#define FW_PFVF_CMD_NEQ_V(x) ((x) << FW_PFVF_CMD_NEQ_S) -#define FW_PFVF_CMD_NEQ_G(x) \ - (((x) >> FW_PFVF_CMD_NEQ_S) & FW_PFVF_CMD_NEQ_M) - -#define FW_PFVF_CMD_TC_S 24 -#define FW_PFVF_CMD_TC_M 0xff -#define FW_PFVF_CMD_TC_V(x) ((x) << FW_PFVF_CMD_TC_S) -#define FW_PFVF_CMD_TC_G(x) (((x) >> FW_PFVF_CMD_TC_S) & FW_PFVF_CMD_TC_M) - -#define FW_PFVF_CMD_NVI_S 16 -#define FW_PFVF_CMD_NVI_M 0xff -#define FW_PFVF_CMD_NVI_V(x) ((x) << FW_PFVF_CMD_NVI_S) -#define FW_PFVF_CMD_NVI_G(x) (((x) >> FW_PFVF_CMD_NVI_S) & FW_PFVF_CMD_NVI_M) - -#define FW_PFVF_CMD_NEXACTF_S 0 -#define FW_PFVF_CMD_NEXACTF_M 0xffff -#define FW_PFVF_CMD_NEXACTF_V(x) ((x) << FW_PFVF_CMD_NEXACTF_S) -#define FW_PFVF_CMD_NEXACTF_G(x) \ - (((x) >> FW_PFVF_CMD_NEXACTF_S) & FW_PFVF_CMD_NEXACTF_M) - -#define FW_PFVF_CMD_R_CAPS_S 24 -#define FW_PFVF_CMD_R_CAPS_M 0xff -#define FW_PFVF_CMD_R_CAPS_V(x) ((x) << FW_PFVF_CMD_R_CAPS_S) -#define FW_PFVF_CMD_R_CAPS_G(x) \ - (((x) >> FW_PFVF_CMD_R_CAPS_S) & FW_PFVF_CMD_R_CAPS_M) - -#define FW_PFVF_CMD_WX_CAPS_S 16 -#define FW_PFVF_CMD_WX_CAPS_M 0xff -#define FW_PFVF_CMD_WX_CAPS_V(x) ((x) << FW_PFVF_CMD_WX_CAPS_S) -#define FW_PFVF_CMD_WX_CAPS_G(x) \ - (((x) >> FW_PFVF_CMD_WX_CAPS_S) & FW_PFVF_CMD_WX_CAPS_M) - -#define FW_PFVF_CMD_NETHCTRL_S 0 -#define FW_PFVF_CMD_NETHCTRL_M 0xffff -#define FW_PFVF_CMD_NETHCTRL_V(x) ((x) << FW_PFVF_CMD_NETHCTRL_S) -#define FW_PFVF_CMD_NETHCTRL_G(x) \ - (((x) >> FW_PFVF_CMD_NETHCTRL_S) & FW_PFVF_CMD_NETHCTRL_M) - -enum fw_iq_type { - FW_IQ_TYPE_FL_INT_CAP, - FW_IQ_TYPE_NO_FL_INT_CAP -}; - -struct fw_iq_cmd { - __be32 op_to_vfn; - __be32 alloc_to_len16; - __be16 physiqid; - __be16 iqid; - __be16 fl0id; - __be16 fl1id; - __be32 type_to_iqandstindex; - __be16 iqdroprss_to_iqesize; - __be16 iqsize; - __be64 iqaddr; - __be32 iqns_to_fl0congen; - __be16 fl0dcaen_to_fl0cidxfthresh; - __be16 fl0size; - __be64 fl0addr; - __be32 fl1cngchmap_to_fl1congen; - __be16 fl1dcaen_to_fl1cidxfthresh; - __be16 fl1size; - __be64 fl1addr; -}; - -#define FW_IQ_CMD_PFN_S 8 -#define FW_IQ_CMD_PFN_V(x) ((x) << FW_IQ_CMD_PFN_S) - -#define FW_IQ_CMD_VFN_S 0 -#define FW_IQ_CMD_VFN_V(x) ((x) << FW_IQ_CMD_VFN_S) - -#define FW_IQ_CMD_ALLOC_S 31 -#define FW_IQ_CMD_ALLOC_V(x) ((x) << FW_IQ_CMD_ALLOC_S) -#define FW_IQ_CMD_ALLOC_F FW_IQ_CMD_ALLOC_V(1U) - -#define FW_IQ_CMD_FREE_S 30 -#define FW_IQ_CMD_FREE_V(x) ((x) << FW_IQ_CMD_FREE_S) -#define FW_IQ_CMD_FREE_F FW_IQ_CMD_FREE_V(1U) - -#define FW_IQ_CMD_MODIFY_S 29 -#define FW_IQ_CMD_MODIFY_V(x) ((x) << FW_IQ_CMD_MODIFY_S) -#define FW_IQ_CMD_MODIFY_F FW_IQ_CMD_MODIFY_V(1U) - -#define FW_IQ_CMD_IQSTART_S 28 -#define FW_IQ_CMD_IQSTART_V(x) ((x) << FW_IQ_CMD_IQSTART_S) -#define FW_IQ_CMD_IQSTART_F FW_IQ_CMD_IQSTART_V(1U) - -#define FW_IQ_CMD_IQSTOP_S 27 -#define FW_IQ_CMD_IQSTOP_V(x) ((x) << FW_IQ_CMD_IQSTOP_S) -#define FW_IQ_CMD_IQSTOP_F FW_IQ_CMD_IQSTOP_V(1U) - -#define FW_IQ_CMD_TYPE_S 29 -#define FW_IQ_CMD_TYPE_V(x) ((x) << FW_IQ_CMD_TYPE_S) - -#define FW_IQ_CMD_IQASYNCH_S 28 -#define FW_IQ_CMD_IQASYNCH_V(x) ((x) << FW_IQ_CMD_IQASYNCH_S) - -#define FW_IQ_CMD_VIID_S 16 -#define FW_IQ_CMD_VIID_V(x) ((x) << FW_IQ_CMD_VIID_S) - -#define FW_IQ_CMD_IQANDST_S 15 -#define FW_IQ_CMD_IQANDST_V(x) ((x) << FW_IQ_CMD_IQANDST_S) - -#define FW_IQ_CMD_IQANUS_S 14 -#define FW_IQ_CMD_IQANUS_V(x) ((x) << FW_IQ_CMD_IQANUS_S) - -#define FW_IQ_CMD_IQANUD_S 12 -#define FW_IQ_CMD_IQANUD_V(x) ((x) << FW_IQ_CMD_IQANUD_S) - -#define FW_IQ_CMD_IQANDSTINDEX_S 0 -#define FW_IQ_CMD_IQANDSTINDEX_V(x) ((x) << FW_IQ_CMD_IQANDSTINDEX_S) - -#define FW_IQ_CMD_IQDROPRSS_S 15 -#define FW_IQ_CMD_IQDROPRSS_V(x) ((x) << FW_IQ_CMD_IQDROPRSS_S) -#define FW_IQ_CMD_IQDROPRSS_F FW_IQ_CMD_IQDROPRSS_V(1U) - -#define FW_IQ_CMD_IQGTSMODE_S 14 -#define FW_IQ_CMD_IQGTSMODE_V(x) ((x) << FW_IQ_CMD_IQGTSMODE_S) -#define FW_IQ_CMD_IQGTSMODE_F FW_IQ_CMD_IQGTSMODE_V(1U) - -#define FW_IQ_CMD_IQPCIECH_S 12 -#define FW_IQ_CMD_IQPCIECH_V(x) ((x) << FW_IQ_CMD_IQPCIECH_S) - -#define FW_IQ_CMD_IQDCAEN_S 11 -#define FW_IQ_CMD_IQDCAEN_V(x) ((x) << FW_IQ_CMD_IQDCAEN_S) - -#define FW_IQ_CMD_IQDCACPU_S 6 -#define FW_IQ_CMD_IQDCACPU_V(x) ((x) << FW_IQ_CMD_IQDCACPU_S) - -#define FW_IQ_CMD_IQINTCNTTHRESH_S 4 -#define FW_IQ_CMD_IQINTCNTTHRESH_V(x) ((x) << FW_IQ_CMD_IQINTCNTTHRESH_S) - -#define FW_IQ_CMD_IQO_S 3 -#define FW_IQ_CMD_IQO_V(x) ((x) << FW_IQ_CMD_IQO_S) -#define FW_IQ_CMD_IQO_F FW_IQ_CMD_IQO_V(1U) - -#define FW_IQ_CMD_IQCPRIO_S 2 -#define FW_IQ_CMD_IQCPRIO_V(x) ((x) << FW_IQ_CMD_IQCPRIO_S) - -#define FW_IQ_CMD_IQESIZE_S 0 -#define FW_IQ_CMD_IQESIZE_V(x) ((x) << FW_IQ_CMD_IQESIZE_S) - -#define FW_IQ_CMD_IQNS_S 31 -#define FW_IQ_CMD_IQNS_V(x) ((x) << FW_IQ_CMD_IQNS_S) - -#define FW_IQ_CMD_IQRO_S 30 -#define FW_IQ_CMD_IQRO_V(x) ((x) << FW_IQ_CMD_IQRO_S) - -#define FW_IQ_CMD_IQFLINTIQHSEN_S 28 -#define FW_IQ_CMD_IQFLINTIQHSEN_V(x) ((x) << FW_IQ_CMD_IQFLINTIQHSEN_S) - -#define FW_IQ_CMD_IQFLINTCONGEN_S 27 -#define FW_IQ_CMD_IQFLINTCONGEN_V(x) ((x) << FW_IQ_CMD_IQFLINTCONGEN_S) -#define FW_IQ_CMD_IQFLINTCONGEN_F FW_IQ_CMD_IQFLINTCONGEN_V(1U) - -#define FW_IQ_CMD_IQFLINTISCSIC_S 26 -#define FW_IQ_CMD_IQFLINTISCSIC_V(x) ((x) << FW_IQ_CMD_IQFLINTISCSIC_S) - -#define FW_IQ_CMD_FL0CNGCHMAP_S 20 -#define FW_IQ_CMD_FL0CNGCHMAP_V(x) ((x) << FW_IQ_CMD_FL0CNGCHMAP_S) - -#define FW_IQ_CMD_FL0CACHELOCK_S 15 -#define FW_IQ_CMD_FL0CACHELOCK_V(x) ((x) << FW_IQ_CMD_FL0CACHELOCK_S) - -#define FW_IQ_CMD_FL0DBP_S 14 -#define FW_IQ_CMD_FL0DBP_V(x) ((x) << FW_IQ_CMD_FL0DBP_S) - -#define FW_IQ_CMD_FL0DATANS_S 13 -#define FW_IQ_CMD_FL0DATANS_V(x) ((x) << FW_IQ_CMD_FL0DATANS_S) - -#define FW_IQ_CMD_FL0DATARO_S 12 -#define FW_IQ_CMD_FL0DATARO_V(x) ((x) << FW_IQ_CMD_FL0DATARO_S) -#define FW_IQ_CMD_FL0DATARO_F FW_IQ_CMD_FL0DATARO_V(1U) - -#define FW_IQ_CMD_FL0CONGCIF_S 11 -#define FW_IQ_CMD_FL0CONGCIF_V(x) ((x) << FW_IQ_CMD_FL0CONGCIF_S) -#define FW_IQ_CMD_FL0CONGCIF_F FW_IQ_CMD_FL0CONGCIF_V(1U) - -#define FW_IQ_CMD_FL0ONCHIP_S 10 -#define FW_IQ_CMD_FL0ONCHIP_V(x) ((x) << FW_IQ_CMD_FL0ONCHIP_S) - -#define FW_IQ_CMD_FL0STATUSPGNS_S 9 -#define FW_IQ_CMD_FL0STATUSPGNS_V(x) ((x) << FW_IQ_CMD_FL0STATUSPGNS_S) - -#define FW_IQ_CMD_FL0STATUSPGRO_S 8 -#define FW_IQ_CMD_FL0STATUSPGRO_V(x) ((x) << FW_IQ_CMD_FL0STATUSPGRO_S) - -#define FW_IQ_CMD_FL0FETCHNS_S 7 -#define FW_IQ_CMD_FL0FETCHNS_V(x) ((x) << FW_IQ_CMD_FL0FETCHNS_S) - -#define FW_IQ_CMD_FL0FETCHRO_S 6 -#define FW_IQ_CMD_FL0FETCHRO_V(x) ((x) << FW_IQ_CMD_FL0FETCHRO_S) -#define FW_IQ_CMD_FL0FETCHRO_F FW_IQ_CMD_FL0FETCHRO_V(1U) - -#define FW_IQ_CMD_FL0HOSTFCMODE_S 4 -#define FW_IQ_CMD_FL0HOSTFCMODE_V(x) ((x) << FW_IQ_CMD_FL0HOSTFCMODE_S) - -#define FW_IQ_CMD_FL0CPRIO_S 3 -#define FW_IQ_CMD_FL0CPRIO_V(x) ((x) << FW_IQ_CMD_FL0CPRIO_S) - -#define FW_IQ_CMD_FL0PADEN_S 2 -#define FW_IQ_CMD_FL0PADEN_V(x) ((x) << FW_IQ_CMD_FL0PADEN_S) -#define FW_IQ_CMD_FL0PADEN_F FW_IQ_CMD_FL0PADEN_V(1U) - -#define FW_IQ_CMD_FL0PACKEN_S 1 -#define FW_IQ_CMD_FL0PACKEN_V(x) ((x) << FW_IQ_CMD_FL0PACKEN_S) -#define FW_IQ_CMD_FL0PACKEN_F FW_IQ_CMD_FL0PACKEN_V(1U) - -#define FW_IQ_CMD_FL0CONGEN_S 0 -#define FW_IQ_CMD_FL0CONGEN_V(x) ((x) << FW_IQ_CMD_FL0CONGEN_S) -#define FW_IQ_CMD_FL0CONGEN_F FW_IQ_CMD_FL0CONGEN_V(1U) - -#define FW_IQ_CMD_FL0DCAEN_S 15 -#define FW_IQ_CMD_FL0DCAEN_V(x) ((x) << FW_IQ_CMD_FL0DCAEN_S) - -#define FW_IQ_CMD_FL0DCACPU_S 10 -#define FW_IQ_CMD_FL0DCACPU_V(x) ((x) << FW_IQ_CMD_FL0DCACPU_S) - -#define FW_IQ_CMD_FL0FBMIN_S 7 -#define FW_IQ_CMD_FL0FBMIN_V(x) ((x) << FW_IQ_CMD_FL0FBMIN_S) - -#define FW_IQ_CMD_FL0FBMAX_S 4 -#define FW_IQ_CMD_FL0FBMAX_V(x) ((x) << FW_IQ_CMD_FL0FBMAX_S) - -#define FW_IQ_CMD_FL0CIDXFTHRESHO_S 3 -#define FW_IQ_CMD_FL0CIDXFTHRESHO_V(x) ((x) << FW_IQ_CMD_FL0CIDXFTHRESHO_S) -#define FW_IQ_CMD_FL0CIDXFTHRESHO_F FW_IQ_CMD_FL0CIDXFTHRESHO_V(1U) - -#define FW_IQ_CMD_FL0CIDXFTHRESH_S 0 -#define FW_IQ_CMD_FL0CIDXFTHRESH_V(x) ((x) << FW_IQ_CMD_FL0CIDXFTHRESH_S) - -#define FW_IQ_CMD_FL1CNGCHMAP_S 20 -#define FW_IQ_CMD_FL1CNGCHMAP_V(x) ((x) << FW_IQ_CMD_FL1CNGCHMAP_S) - -#define FW_IQ_CMD_FL1CACHELOCK_S 15 -#define FW_IQ_CMD_FL1CACHELOCK_V(x) ((x) << FW_IQ_CMD_FL1CACHELOCK_S) - -#define FW_IQ_CMD_FL1DBP_S 14 -#define FW_IQ_CMD_FL1DBP_V(x) ((x) << FW_IQ_CMD_FL1DBP_S) - -#define FW_IQ_CMD_FL1DATANS_S 13 -#define FW_IQ_CMD_FL1DATANS_V(x) ((x) << FW_IQ_CMD_FL1DATANS_S) - -#define FW_IQ_CMD_FL1DATARO_S 12 -#define FW_IQ_CMD_FL1DATARO_V(x) ((x) << FW_IQ_CMD_FL1DATARO_S) - -#define FW_IQ_CMD_FL1CONGCIF_S 11 -#define FW_IQ_CMD_FL1CONGCIF_V(x) ((x) << FW_IQ_CMD_FL1CONGCIF_S) - -#define FW_IQ_CMD_FL1ONCHIP_S 10 -#define FW_IQ_CMD_FL1ONCHIP_V(x) ((x) << FW_IQ_CMD_FL1ONCHIP_S) - -#define FW_IQ_CMD_FL1STATUSPGNS_S 9 -#define FW_IQ_CMD_FL1STATUSPGNS_V(x) ((x) << FW_IQ_CMD_FL1STATUSPGNS_S) - -#define FW_IQ_CMD_FL1STATUSPGRO_S 8 -#define FW_IQ_CMD_FL1STATUSPGRO_V(x) ((x) << FW_IQ_CMD_FL1STATUSPGRO_S) - -#define FW_IQ_CMD_FL1FETCHNS_S 7 -#define FW_IQ_CMD_FL1FETCHNS_V(x) ((x) << FW_IQ_CMD_FL1FETCHNS_S) - -#define FW_IQ_CMD_FL1FETCHRO_S 6 -#define FW_IQ_CMD_FL1FETCHRO_V(x) ((x) << FW_IQ_CMD_FL1FETCHRO_S) - -#define FW_IQ_CMD_FL1HOSTFCMODE_S 4 -#define FW_IQ_CMD_FL1HOSTFCMODE_V(x) ((x) << FW_IQ_CMD_FL1HOSTFCMODE_S) - -#define FW_IQ_CMD_FL1CPRIO_S 3 -#define FW_IQ_CMD_FL1CPRIO_V(x) ((x) << FW_IQ_CMD_FL1CPRIO_S) - -#define FW_IQ_CMD_FL1PADEN_S 2 -#define FW_IQ_CMD_FL1PADEN_V(x) ((x) << FW_IQ_CMD_FL1PADEN_S) -#define FW_IQ_CMD_FL1PADEN_F FW_IQ_CMD_FL1PADEN_V(1U) - -#define FW_IQ_CMD_FL1PACKEN_S 1 -#define FW_IQ_CMD_FL1PACKEN_V(x) ((x) << FW_IQ_CMD_FL1PACKEN_S) -#define FW_IQ_CMD_FL1PACKEN_F FW_IQ_CMD_FL1PACKEN_V(1U) - -#define FW_IQ_CMD_FL1CONGEN_S 0 -#define FW_IQ_CMD_FL1CONGEN_V(x) ((x) << FW_IQ_CMD_FL1CONGEN_S) -#define FW_IQ_CMD_FL1CONGEN_F FW_IQ_CMD_FL1CONGEN_V(1U) - -#define FW_IQ_CMD_FL1DCAEN_S 15 -#define FW_IQ_CMD_FL1DCAEN_V(x) ((x) << FW_IQ_CMD_FL1DCAEN_S) - -#define FW_IQ_CMD_FL1DCACPU_S 10 -#define FW_IQ_CMD_FL1DCACPU_V(x) ((x) << FW_IQ_CMD_FL1DCACPU_S) - -#define FW_IQ_CMD_FL1FBMIN_S 7 -#define FW_IQ_CMD_FL1FBMIN_V(x) ((x) << FW_IQ_CMD_FL1FBMIN_S) - -#define FW_IQ_CMD_FL1FBMAX_S 4 -#define FW_IQ_CMD_FL1FBMAX_V(x) ((x) << FW_IQ_CMD_FL1FBMAX_S) - -#define FW_IQ_CMD_FL1CIDXFTHRESHO_S 3 -#define FW_IQ_CMD_FL1CIDXFTHRESHO_V(x) ((x) << FW_IQ_CMD_FL1CIDXFTHRESHO_S) -#define FW_IQ_CMD_FL1CIDXFTHRESHO_F FW_IQ_CMD_FL1CIDXFTHRESHO_V(1U) - -#define FW_IQ_CMD_FL1CIDXFTHRESH_S 0 -#define FW_IQ_CMD_FL1CIDXFTHRESH_V(x) ((x) << FW_IQ_CMD_FL1CIDXFTHRESH_S) - -struct fw_eq_eth_cmd { - __be32 op_to_vfn; - __be32 alloc_to_len16; - __be32 eqid_pkd; - __be32 physeqid_pkd; - __be32 fetchszm_to_iqid; - __be32 dcaen_to_eqsize; - __be64 eqaddr; - __be32 viid_pkd; - __be32 r8_lo; - __be64 r9; -}; - -#define FW_EQ_ETH_CMD_PFN_S 8 -#define FW_EQ_ETH_CMD_PFN_V(x) ((x) << FW_EQ_ETH_CMD_PFN_S) - -#define FW_EQ_ETH_CMD_VFN_S 0 -#define FW_EQ_ETH_CMD_VFN_V(x) ((x) << FW_EQ_ETH_CMD_VFN_S) - -#define FW_EQ_ETH_CMD_ALLOC_S 31 -#define FW_EQ_ETH_CMD_ALLOC_V(x) ((x) << FW_EQ_ETH_CMD_ALLOC_S) -#define FW_EQ_ETH_CMD_ALLOC_F FW_EQ_ETH_CMD_ALLOC_V(1U) - -#define FW_EQ_ETH_CMD_FREE_S 30 -#define FW_EQ_ETH_CMD_FREE_V(x) ((x) << FW_EQ_ETH_CMD_FREE_S) -#define FW_EQ_ETH_CMD_FREE_F FW_EQ_ETH_CMD_FREE_V(1U) - -#define FW_EQ_ETH_CMD_MODIFY_S 29 -#define FW_EQ_ETH_CMD_MODIFY_V(x) ((x) << FW_EQ_ETH_CMD_MODIFY_S) -#define FW_EQ_ETH_CMD_MODIFY_F FW_EQ_ETH_CMD_MODIFY_V(1U) - -#define FW_EQ_ETH_CMD_EQSTART_S 28 -#define FW_EQ_ETH_CMD_EQSTART_V(x) ((x) << FW_EQ_ETH_CMD_EQSTART_S) -#define FW_EQ_ETH_CMD_EQSTART_F FW_EQ_ETH_CMD_EQSTART_V(1U) - -#define FW_EQ_ETH_CMD_EQSTOP_S 27 -#define FW_EQ_ETH_CMD_EQSTOP_V(x) ((x) << FW_EQ_ETH_CMD_EQSTOP_S) -#define FW_EQ_ETH_CMD_EQSTOP_F FW_EQ_ETH_CMD_EQSTOP_V(1U) - -#define FW_EQ_ETH_CMD_EQID_S 0 -#define FW_EQ_ETH_CMD_EQID_M 0xfffff -#define FW_EQ_ETH_CMD_EQID_V(x) ((x) << FW_EQ_ETH_CMD_EQID_S) -#define FW_EQ_ETH_CMD_EQID_G(x) \ - (((x) >> FW_EQ_ETH_CMD_EQID_S) & FW_EQ_ETH_CMD_EQID_M) - -#define FW_EQ_ETH_CMD_PHYSEQID_S 0 -#define FW_EQ_ETH_CMD_PHYSEQID_M 0xfffff -#define FW_EQ_ETH_CMD_PHYSEQID_V(x) ((x) << FW_EQ_ETH_CMD_PHYSEQID_S) -#define FW_EQ_ETH_CMD_PHYSEQID_G(x) \ - (((x) >> FW_EQ_ETH_CMD_PHYSEQID_S) & FW_EQ_ETH_CMD_PHYSEQID_M) - -#define FW_EQ_ETH_CMD_FETCHSZM_S 26 -#define FW_EQ_ETH_CMD_FETCHSZM_V(x) ((x) << FW_EQ_ETH_CMD_FETCHSZM_S) -#define FW_EQ_ETH_CMD_FETCHSZM_F FW_EQ_ETH_CMD_FETCHSZM_V(1U) - -#define FW_EQ_ETH_CMD_STATUSPGNS_S 25 -#define FW_EQ_ETH_CMD_STATUSPGNS_V(x) ((x) << FW_EQ_ETH_CMD_STATUSPGNS_S) - -#define FW_EQ_ETH_CMD_STATUSPGRO_S 24 -#define FW_EQ_ETH_CMD_STATUSPGRO_V(x) ((x) << FW_EQ_ETH_CMD_STATUSPGRO_S) - -#define FW_EQ_ETH_CMD_FETCHNS_S 23 -#define FW_EQ_ETH_CMD_FETCHNS_V(x) ((x) << FW_EQ_ETH_CMD_FETCHNS_S) - -#define FW_EQ_ETH_CMD_FETCHRO_S 22 -#define FW_EQ_ETH_CMD_FETCHRO_V(x) ((x) << FW_EQ_ETH_CMD_FETCHRO_S) -#define FW_EQ_ETH_CMD_FETCHRO_F FW_EQ_ETH_CMD_FETCHRO_V(1U) - -#define FW_EQ_ETH_CMD_HOSTFCMODE_S 20 -#define FW_EQ_ETH_CMD_HOSTFCMODE_V(x) ((x) << FW_EQ_ETH_CMD_HOSTFCMODE_S) - -#define FW_EQ_ETH_CMD_CPRIO_S 19 -#define FW_EQ_ETH_CMD_CPRIO_V(x) ((x) << FW_EQ_ETH_CMD_CPRIO_S) - -#define FW_EQ_ETH_CMD_ONCHIP_S 18 -#define FW_EQ_ETH_CMD_ONCHIP_V(x) ((x) << FW_EQ_ETH_CMD_ONCHIP_S) - -#define FW_EQ_ETH_CMD_PCIECHN_S 16 -#define FW_EQ_ETH_CMD_PCIECHN_V(x) ((x) << FW_EQ_ETH_CMD_PCIECHN_S) - -#define FW_EQ_ETH_CMD_IQID_S 0 -#define FW_EQ_ETH_CMD_IQID_V(x) ((x) << FW_EQ_ETH_CMD_IQID_S) - -#define FW_EQ_ETH_CMD_DCAEN_S 31 -#define FW_EQ_ETH_CMD_DCAEN_V(x) ((x) << FW_EQ_ETH_CMD_DCAEN_S) - -#define FW_EQ_ETH_CMD_DCACPU_S 26 -#define FW_EQ_ETH_CMD_DCACPU_V(x) ((x) << FW_EQ_ETH_CMD_DCACPU_S) - -#define FW_EQ_ETH_CMD_FBMIN_S 23 -#define FW_EQ_ETH_CMD_FBMIN_V(x) ((x) << FW_EQ_ETH_CMD_FBMIN_S) - -#define FW_EQ_ETH_CMD_FBMAX_S 20 -#define FW_EQ_ETH_CMD_FBMAX_V(x) ((x) << FW_EQ_ETH_CMD_FBMAX_S) - -#define FW_EQ_ETH_CMD_CIDXFTHRESHO_S 19 -#define FW_EQ_ETH_CMD_CIDXFTHRESHO_V(x) ((x) << FW_EQ_ETH_CMD_CIDXFTHRESHO_S) - -#define FW_EQ_ETH_CMD_CIDXFTHRESH_S 16 -#define FW_EQ_ETH_CMD_CIDXFTHRESH_V(x) ((x) << FW_EQ_ETH_CMD_CIDXFTHRESH_S) - -#define FW_EQ_ETH_CMD_EQSIZE_S 0 -#define FW_EQ_ETH_CMD_EQSIZE_V(x) ((x) << FW_EQ_ETH_CMD_EQSIZE_S) - -#define FW_EQ_ETH_CMD_AUTOEQUEQE_S 30 -#define FW_EQ_ETH_CMD_AUTOEQUEQE_V(x) ((x) << FW_EQ_ETH_CMD_AUTOEQUEQE_S) -#define FW_EQ_ETH_CMD_AUTOEQUEQE_F FW_EQ_ETH_CMD_AUTOEQUEQE_V(1U) - -#define FW_EQ_ETH_CMD_VIID_S 16 -#define FW_EQ_ETH_CMD_VIID_V(x) ((x) << FW_EQ_ETH_CMD_VIID_S) - -struct fw_eq_ctrl_cmd { - __be32 op_to_vfn; - __be32 alloc_to_len16; - __be32 cmpliqid_eqid; - __be32 physeqid_pkd; - __be32 fetchszm_to_iqid; - __be32 dcaen_to_eqsize; - __be64 eqaddr; -}; - -#define FW_EQ_CTRL_CMD_PFN_S 8 -#define FW_EQ_CTRL_CMD_PFN_V(x) ((x) << FW_EQ_CTRL_CMD_PFN_S) - -#define FW_EQ_CTRL_CMD_VFN_S 0 -#define FW_EQ_CTRL_CMD_VFN_V(x) ((x) << FW_EQ_CTRL_CMD_VFN_S) - -#define FW_EQ_CTRL_CMD_ALLOC_S 31 -#define FW_EQ_CTRL_CMD_ALLOC_V(x) ((x) << FW_EQ_CTRL_CMD_ALLOC_S) -#define FW_EQ_CTRL_CMD_ALLOC_F FW_EQ_CTRL_CMD_ALLOC_V(1U) - -#define FW_EQ_CTRL_CMD_FREE_S 30 -#define FW_EQ_CTRL_CMD_FREE_V(x) ((x) << FW_EQ_CTRL_CMD_FREE_S) -#define FW_EQ_CTRL_CMD_FREE_F FW_EQ_CTRL_CMD_FREE_V(1U) - -#define FW_EQ_CTRL_CMD_MODIFY_S 29 -#define FW_EQ_CTRL_CMD_MODIFY_V(x) ((x) << FW_EQ_CTRL_CMD_MODIFY_S) -#define FW_EQ_CTRL_CMD_MODIFY_F FW_EQ_CTRL_CMD_MODIFY_V(1U) - -#define FW_EQ_CTRL_CMD_EQSTART_S 28 -#define FW_EQ_CTRL_CMD_EQSTART_V(x) ((x) << FW_EQ_CTRL_CMD_EQSTART_S) -#define FW_EQ_CTRL_CMD_EQSTART_F FW_EQ_CTRL_CMD_EQSTART_V(1U) - -#define FW_EQ_CTRL_CMD_EQSTOP_S 27 -#define FW_EQ_CTRL_CMD_EQSTOP_V(x) ((x) << FW_EQ_CTRL_CMD_EQSTOP_S) -#define FW_EQ_CTRL_CMD_EQSTOP_F FW_EQ_CTRL_CMD_EQSTOP_V(1U) - -#define FW_EQ_CTRL_CMD_CMPLIQID_S 20 -#define FW_EQ_CTRL_CMD_CMPLIQID_V(x) ((x) << FW_EQ_CTRL_CMD_CMPLIQID_S) - -#define FW_EQ_CTRL_CMD_EQID_S 0 -#define FW_EQ_CTRL_CMD_EQID_M 0xfffff -#define FW_EQ_CTRL_CMD_EQID_V(x) ((x) << FW_EQ_CTRL_CMD_EQID_S) -#define FW_EQ_CTRL_CMD_EQID_G(x) \ - (((x) >> FW_EQ_CTRL_CMD_EQID_S) & FW_EQ_CTRL_CMD_EQID_M) - -#define FW_EQ_CTRL_CMD_PHYSEQID_S 0 -#define FW_EQ_CTRL_CMD_PHYSEQID_M 0xfffff -#define FW_EQ_CTRL_CMD_PHYSEQID_G(x) \ - (((x) >> FW_EQ_CTRL_CMD_PHYSEQID_S) & FW_EQ_CTRL_CMD_PHYSEQID_M) - -#define FW_EQ_CTRL_CMD_FETCHSZM_S 26 -#define FW_EQ_CTRL_CMD_FETCHSZM_V(x) ((x) << FW_EQ_CTRL_CMD_FETCHSZM_S) -#define FW_EQ_CTRL_CMD_FETCHSZM_F FW_EQ_CTRL_CMD_FETCHSZM_V(1U) - -#define FW_EQ_CTRL_CMD_STATUSPGNS_S 25 -#define FW_EQ_CTRL_CMD_STATUSPGNS_V(x) ((x) << FW_EQ_CTRL_CMD_STATUSPGNS_S) -#define FW_EQ_CTRL_CMD_STATUSPGNS_F FW_EQ_CTRL_CMD_STATUSPGNS_V(1U) - -#define FW_EQ_CTRL_CMD_STATUSPGRO_S 24 -#define FW_EQ_CTRL_CMD_STATUSPGRO_V(x) ((x) << FW_EQ_CTRL_CMD_STATUSPGRO_S) -#define FW_EQ_CTRL_CMD_STATUSPGRO_F FW_EQ_CTRL_CMD_STATUSPGRO_V(1U) - -#define FW_EQ_CTRL_CMD_FETCHNS_S 23 -#define FW_EQ_CTRL_CMD_FETCHNS_V(x) ((x) << FW_EQ_CTRL_CMD_FETCHNS_S) -#define FW_EQ_CTRL_CMD_FETCHNS_F FW_EQ_CTRL_CMD_FETCHNS_V(1U) - -#define FW_EQ_CTRL_CMD_FETCHRO_S 22 -#define FW_EQ_CTRL_CMD_FETCHRO_V(x) ((x) << FW_EQ_CTRL_CMD_FETCHRO_S) -#define FW_EQ_CTRL_CMD_FETCHRO_F FW_EQ_CTRL_CMD_FETCHRO_V(1U) - -#define FW_EQ_CTRL_CMD_HOSTFCMODE_S 20 -#define FW_EQ_CTRL_CMD_HOSTFCMODE_V(x) ((x) << FW_EQ_CTRL_CMD_HOSTFCMODE_S) - -#define FW_EQ_CTRL_CMD_CPRIO_S 19 -#define FW_EQ_CTRL_CMD_CPRIO_V(x) ((x) << FW_EQ_CTRL_CMD_CPRIO_S) - -#define FW_EQ_CTRL_CMD_ONCHIP_S 18 -#define FW_EQ_CTRL_CMD_ONCHIP_V(x) ((x) << FW_EQ_CTRL_CMD_ONCHIP_S) - -#define FW_EQ_CTRL_CMD_PCIECHN_S 16 -#define FW_EQ_CTRL_CMD_PCIECHN_V(x) ((x) << FW_EQ_CTRL_CMD_PCIECHN_S) - -#define FW_EQ_CTRL_CMD_IQID_S 0 -#define FW_EQ_CTRL_CMD_IQID_V(x) ((x) << FW_EQ_CTRL_CMD_IQID_S) - -#define FW_EQ_CTRL_CMD_DCAEN_S 31 -#define FW_EQ_CTRL_CMD_DCAEN_V(x) ((x) << FW_EQ_CTRL_CMD_DCAEN_S) - -#define FW_EQ_CTRL_CMD_DCACPU_S 26 -#define FW_EQ_CTRL_CMD_DCACPU_V(x) ((x) << FW_EQ_CTRL_CMD_DCACPU_S) - -#define FW_EQ_CTRL_CMD_FBMIN_S 23 -#define FW_EQ_CTRL_CMD_FBMIN_V(x) ((x) << FW_EQ_CTRL_CMD_FBMIN_S) - -#define FW_EQ_CTRL_CMD_FBMAX_S 20 -#define FW_EQ_CTRL_CMD_FBMAX_V(x) ((x) << FW_EQ_CTRL_CMD_FBMAX_S) - -#define FW_EQ_CTRL_CMD_CIDXFTHRESHO_S 19 -#define FW_EQ_CTRL_CMD_CIDXFTHRESHO_V(x) \ - ((x) << FW_EQ_CTRL_CMD_CIDXFTHRESHO_S) - -#define FW_EQ_CTRL_CMD_CIDXFTHRESH_S 16 -#define FW_EQ_CTRL_CMD_CIDXFTHRESH_V(x) ((x) << FW_EQ_CTRL_CMD_CIDXFTHRESH_S) - -#define FW_EQ_CTRL_CMD_EQSIZE_S 0 -#define FW_EQ_CTRL_CMD_EQSIZE_V(x) ((x) << FW_EQ_CTRL_CMD_EQSIZE_S) - -struct fw_eq_ofld_cmd { - __be32 op_to_vfn; - __be32 alloc_to_len16; - __be32 eqid_pkd; - __be32 physeqid_pkd; - __be32 fetchszm_to_iqid; - __be32 dcaen_to_eqsize; - __be64 eqaddr; -}; - -#define FW_EQ_OFLD_CMD_PFN_S 8 -#define FW_EQ_OFLD_CMD_PFN_V(x) ((x) << FW_EQ_OFLD_CMD_PFN_S) - -#define FW_EQ_OFLD_CMD_VFN_S 0 -#define FW_EQ_OFLD_CMD_VFN_V(x) ((x) << FW_EQ_OFLD_CMD_VFN_S) - -#define FW_EQ_OFLD_CMD_ALLOC_S 31 -#define FW_EQ_OFLD_CMD_ALLOC_V(x) ((x) << FW_EQ_OFLD_CMD_ALLOC_S) -#define FW_EQ_OFLD_CMD_ALLOC_F FW_EQ_OFLD_CMD_ALLOC_V(1U) - -#define FW_EQ_OFLD_CMD_FREE_S 30 -#define FW_EQ_OFLD_CMD_FREE_V(x) ((x) << FW_EQ_OFLD_CMD_FREE_S) -#define FW_EQ_OFLD_CMD_FREE_F FW_EQ_OFLD_CMD_FREE_V(1U) - -#define FW_EQ_OFLD_CMD_MODIFY_S 29 -#define FW_EQ_OFLD_CMD_MODIFY_V(x) ((x) << FW_EQ_OFLD_CMD_MODIFY_S) -#define FW_EQ_OFLD_CMD_MODIFY_F FW_EQ_OFLD_CMD_MODIFY_V(1U) - -#define FW_EQ_OFLD_CMD_EQSTART_S 28 -#define FW_EQ_OFLD_CMD_EQSTART_V(x) ((x) << FW_EQ_OFLD_CMD_EQSTART_S) -#define FW_EQ_OFLD_CMD_EQSTART_F FW_EQ_OFLD_CMD_EQSTART_V(1U) - -#define FW_EQ_OFLD_CMD_EQSTOP_S 27 -#define FW_EQ_OFLD_CMD_EQSTOP_V(x) ((x) << FW_EQ_OFLD_CMD_EQSTOP_S) -#define FW_EQ_OFLD_CMD_EQSTOP_F FW_EQ_OFLD_CMD_EQSTOP_V(1U) - -#define FW_EQ_OFLD_CMD_EQID_S 0 -#define FW_EQ_OFLD_CMD_EQID_M 0xfffff -#define FW_EQ_OFLD_CMD_EQID_V(x) ((x) << FW_EQ_OFLD_CMD_EQID_S) -#define FW_EQ_OFLD_CMD_EQID_G(x) \ - (((x) >> FW_EQ_OFLD_CMD_EQID_S) & FW_EQ_OFLD_CMD_EQID_M) - -#define FW_EQ_OFLD_CMD_PHYSEQID_S 0 -#define FW_EQ_OFLD_CMD_PHYSEQID_M 0xfffff -#define FW_EQ_OFLD_CMD_PHYSEQID_G(x) \ - (((x) >> FW_EQ_OFLD_CMD_PHYSEQID_S) & FW_EQ_OFLD_CMD_PHYSEQID_M) - -#define FW_EQ_OFLD_CMD_FETCHSZM_S 26 -#define FW_EQ_OFLD_CMD_FETCHSZM_V(x) ((x) << FW_EQ_OFLD_CMD_FETCHSZM_S) - -#define FW_EQ_OFLD_CMD_STATUSPGNS_S 25 -#define FW_EQ_OFLD_CMD_STATUSPGNS_V(x) ((x) << FW_EQ_OFLD_CMD_STATUSPGNS_S) - -#define FW_EQ_OFLD_CMD_STATUSPGRO_S 24 -#define FW_EQ_OFLD_CMD_STATUSPGRO_V(x) ((x) << FW_EQ_OFLD_CMD_STATUSPGRO_S) - -#define FW_EQ_OFLD_CMD_FETCHNS_S 23 -#define FW_EQ_OFLD_CMD_FETCHNS_V(x) ((x) << FW_EQ_OFLD_CMD_FETCHNS_S) - -#define FW_EQ_OFLD_CMD_FETCHRO_S 22 -#define FW_EQ_OFLD_CMD_FETCHRO_V(x) ((x) << FW_EQ_OFLD_CMD_FETCHRO_S) -#define FW_EQ_OFLD_CMD_FETCHRO_F FW_EQ_OFLD_CMD_FETCHRO_V(1U) - -#define FW_EQ_OFLD_CMD_HOSTFCMODE_S 20 -#define FW_EQ_OFLD_CMD_HOSTFCMODE_V(x) ((x) << FW_EQ_OFLD_CMD_HOSTFCMODE_S) - -#define FW_EQ_OFLD_CMD_CPRIO_S 19 -#define FW_EQ_OFLD_CMD_CPRIO_V(x) ((x) << FW_EQ_OFLD_CMD_CPRIO_S) - -#define FW_EQ_OFLD_CMD_ONCHIP_S 18 -#define FW_EQ_OFLD_CMD_ONCHIP_V(x) ((x) << FW_EQ_OFLD_CMD_ONCHIP_S) - -#define FW_EQ_OFLD_CMD_PCIECHN_S 16 -#define FW_EQ_OFLD_CMD_PCIECHN_V(x) ((x) << FW_EQ_OFLD_CMD_PCIECHN_S) - -#define FW_EQ_OFLD_CMD_IQID_S 0 -#define FW_EQ_OFLD_CMD_IQID_V(x) ((x) << FW_EQ_OFLD_CMD_IQID_S) - -#define FW_EQ_OFLD_CMD_DCAEN_S 31 -#define FW_EQ_OFLD_CMD_DCAEN_V(x) ((x) << FW_EQ_OFLD_CMD_DCAEN_S) - -#define FW_EQ_OFLD_CMD_DCACPU_S 26 -#define FW_EQ_OFLD_CMD_DCACPU_V(x) ((x) << FW_EQ_OFLD_CMD_DCACPU_S) - -#define FW_EQ_OFLD_CMD_FBMIN_S 23 -#define FW_EQ_OFLD_CMD_FBMIN_V(x) ((x) << FW_EQ_OFLD_CMD_FBMIN_S) - -#define FW_EQ_OFLD_CMD_FBMAX_S 20 -#define FW_EQ_OFLD_CMD_FBMAX_V(x) ((x) << FW_EQ_OFLD_CMD_FBMAX_S) - -#define FW_EQ_OFLD_CMD_CIDXFTHRESHO_S 19 -#define FW_EQ_OFLD_CMD_CIDXFTHRESHO_V(x) \ - ((x) << FW_EQ_OFLD_CMD_CIDXFTHRESHO_S) - -#define FW_EQ_OFLD_CMD_CIDXFTHRESH_S 16 -#define FW_EQ_OFLD_CMD_CIDXFTHRESH_V(x) ((x) << FW_EQ_OFLD_CMD_CIDXFTHRESH_S) - -#define FW_EQ_OFLD_CMD_EQSIZE_S 0 -#define FW_EQ_OFLD_CMD_EQSIZE_V(x) ((x) << FW_EQ_OFLD_CMD_EQSIZE_S) - -/* - * Macros for VIID parsing: - * VIID - [10:8] PFN, [7] VI Valid, [6:0] VI number - */ - -#define FW_VIID_PFN_S 8 -#define FW_VIID_PFN_M 0x7 -#define FW_VIID_PFN_G(x) (((x) >> FW_VIID_PFN_S) & FW_VIID_PFN_M) - -#define FW_VIID_VIVLD_S 7 -#define FW_VIID_VIVLD_M 0x1 -#define FW_VIID_VIVLD_G(x) (((x) >> FW_VIID_VIVLD_S) & FW_VIID_VIVLD_M) - -#define FW_VIID_VIN_S 0 -#define FW_VIID_VIN_M 0x7F -#define FW_VIID_VIN_G(x) (((x) >> FW_VIID_VIN_S) & FW_VIID_VIN_M) - -struct fw_vi_cmd { - __be32 op_to_vfn; - __be32 alloc_to_len16; - __be16 type_viid; - u8 mac[6]; - u8 portid_pkd; - u8 nmac; - u8 nmac0[6]; - __be16 rsssize_pkd; - u8 nmac1[6]; - __be16 idsiiq_pkd; - u8 nmac2[6]; - __be16 idseiq_pkd; - u8 nmac3[6]; - __be64 r9; - __be64 r10; -}; - -#define FW_VI_CMD_PFN_S 8 -#define FW_VI_CMD_PFN_V(x) ((x) << FW_VI_CMD_PFN_S) - -#define FW_VI_CMD_VFN_S 0 -#define FW_VI_CMD_VFN_V(x) ((x) << FW_VI_CMD_VFN_S) - -#define FW_VI_CMD_ALLOC_S 31 -#define FW_VI_CMD_ALLOC_V(x) ((x) << FW_VI_CMD_ALLOC_S) -#define FW_VI_CMD_ALLOC_F FW_VI_CMD_ALLOC_V(1U) - -#define FW_VI_CMD_FREE_S 30 -#define FW_VI_CMD_FREE_V(x) ((x) << FW_VI_CMD_FREE_S) -#define FW_VI_CMD_FREE_F FW_VI_CMD_FREE_V(1U) - -#define FW_VI_CMD_VIID_S 0 -#define FW_VI_CMD_VIID_M 0xfff -#define FW_VI_CMD_VIID_V(x) ((x) << FW_VI_CMD_VIID_S) -#define FW_VI_CMD_VIID_G(x) (((x) >> FW_VI_CMD_VIID_S) & FW_VI_CMD_VIID_M) - -#define FW_VI_CMD_PORTID_S 4 -#define FW_VI_CMD_PORTID_M 0xf -#define FW_VI_CMD_PORTID_V(x) ((x) << FW_VI_CMD_PORTID_S) -#define FW_VI_CMD_PORTID_G(x) \ - (((x) >> FW_VI_CMD_PORTID_S) & FW_VI_CMD_PORTID_M) - -#define FW_VI_CMD_RSSSIZE_S 0 -#define FW_VI_CMD_RSSSIZE_M 0x7ff -#define FW_VI_CMD_RSSSIZE_G(x) \ - (((x) >> FW_VI_CMD_RSSSIZE_S) & FW_VI_CMD_RSSSIZE_M) - -/* Special VI_MAC command index ids */ -#define FW_VI_MAC_ADD_MAC 0x3FF -#define FW_VI_MAC_ADD_PERSIST_MAC 0x3FE -#define FW_VI_MAC_MAC_BASED_FREE 0x3FD -#define FW_CLS_TCAM_NUM_ENTRIES 336 - -enum fw_vi_mac_smac { - FW_VI_MAC_MPS_TCAM_ENTRY, - FW_VI_MAC_MPS_TCAM_ONLY, - FW_VI_MAC_SMT_ONLY, - FW_VI_MAC_SMT_AND_MPSTCAM -}; - -enum fw_vi_mac_result { - FW_VI_MAC_R_SUCCESS, - FW_VI_MAC_R_F_NONEXISTENT_NOMEM, - FW_VI_MAC_R_SMAC_FAIL, - FW_VI_MAC_R_F_ACL_CHECK -}; - -struct fw_vi_mac_cmd { - __be32 op_to_viid; - __be32 freemacs_to_len16; - union fw_vi_mac { - struct fw_vi_mac_exact { - __be16 valid_to_idx; - u8 macaddr[6]; - } exact[7]; - struct fw_vi_mac_hash { - __be64 hashvec; - } hash; - } u; -}; - -#define FW_VI_MAC_CMD_VIID_S 0 -#define FW_VI_MAC_CMD_VIID_V(x) ((x) << FW_VI_MAC_CMD_VIID_S) - -#define FW_VI_MAC_CMD_FREEMACS_S 31 -#define FW_VI_MAC_CMD_FREEMACS_V(x) ((x) << FW_VI_MAC_CMD_FREEMACS_S) - -#define FW_VI_MAC_CMD_HASHVECEN_S 23 -#define FW_VI_MAC_CMD_HASHVECEN_V(x) ((x) << FW_VI_MAC_CMD_HASHVECEN_S) -#define FW_VI_MAC_CMD_HASHVECEN_F FW_VI_MAC_CMD_HASHVECEN_V(1U) - -#define FW_VI_MAC_CMD_HASHUNIEN_S 22 -#define FW_VI_MAC_CMD_HASHUNIEN_V(x) ((x) << FW_VI_MAC_CMD_HASHUNIEN_S) - -#define FW_VI_MAC_CMD_VALID_S 15 -#define FW_VI_MAC_CMD_VALID_V(x) ((x) << FW_VI_MAC_CMD_VALID_S) -#define FW_VI_MAC_CMD_VALID_F FW_VI_MAC_CMD_VALID_V(1U) - -#define FW_VI_MAC_CMD_PRIO_S 12 -#define FW_VI_MAC_CMD_PRIO_V(x) ((x) << FW_VI_MAC_CMD_PRIO_S) - -#define FW_VI_MAC_CMD_SMAC_RESULT_S 10 -#define FW_VI_MAC_CMD_SMAC_RESULT_M 0x3 -#define FW_VI_MAC_CMD_SMAC_RESULT_V(x) ((x) << FW_VI_MAC_CMD_SMAC_RESULT_S) -#define FW_VI_MAC_CMD_SMAC_RESULT_G(x) \ - (((x) >> FW_VI_MAC_CMD_SMAC_RESULT_S) & FW_VI_MAC_CMD_SMAC_RESULT_M) - -#define FW_VI_MAC_CMD_IDX_S 0 -#define FW_VI_MAC_CMD_IDX_M 0x3ff -#define FW_VI_MAC_CMD_IDX_V(x) ((x) << FW_VI_MAC_CMD_IDX_S) -#define FW_VI_MAC_CMD_IDX_G(x) \ - (((x) >> FW_VI_MAC_CMD_IDX_S) & FW_VI_MAC_CMD_IDX_M) - -#define FW_RXMODE_MTU_NO_CHG 65535 - -struct fw_vi_rxmode_cmd { - __be32 op_to_viid; - __be32 retval_len16; - __be32 mtu_to_vlanexen; - __be32 r4_lo; -}; - -#define FW_VI_RXMODE_CMD_VIID_S 0 -#define FW_VI_RXMODE_CMD_VIID_V(x) ((x) << FW_VI_RXMODE_CMD_VIID_S) - -#define FW_VI_RXMODE_CMD_MTU_S 16 -#define FW_VI_RXMODE_CMD_MTU_M 0xffff -#define FW_VI_RXMODE_CMD_MTU_V(x) ((x) << FW_VI_RXMODE_CMD_MTU_S) - -#define FW_VI_RXMODE_CMD_PROMISCEN_S 14 -#define FW_VI_RXMODE_CMD_PROMISCEN_M 0x3 -#define FW_VI_RXMODE_CMD_PROMISCEN_V(x) ((x) << FW_VI_RXMODE_CMD_PROMISCEN_S) - -#define FW_VI_RXMODE_CMD_ALLMULTIEN_S 12 -#define FW_VI_RXMODE_CMD_ALLMULTIEN_M 0x3 -#define FW_VI_RXMODE_CMD_ALLMULTIEN_V(x) \ - ((x) << FW_VI_RXMODE_CMD_ALLMULTIEN_S) - -#define FW_VI_RXMODE_CMD_BROADCASTEN_S 10 -#define FW_VI_RXMODE_CMD_BROADCASTEN_M 0x3 -#define FW_VI_RXMODE_CMD_BROADCASTEN_V(x) \ - ((x) << FW_VI_RXMODE_CMD_BROADCASTEN_S) - -#define FW_VI_RXMODE_CMD_VLANEXEN_S 8 -#define FW_VI_RXMODE_CMD_VLANEXEN_M 0x3 -#define FW_VI_RXMODE_CMD_VLANEXEN_V(x) ((x) << FW_VI_RXMODE_CMD_VLANEXEN_S) - -struct fw_vi_enable_cmd { - __be32 op_to_viid; - __be32 ien_to_len16; - __be16 blinkdur; - __be16 r3; - __be32 r4; -}; - -#define FW_VI_ENABLE_CMD_VIID_S 0 -#define FW_VI_ENABLE_CMD_VIID_V(x) ((x) << FW_VI_ENABLE_CMD_VIID_S) - -#define FW_VI_ENABLE_CMD_IEN_S 31 -#define FW_VI_ENABLE_CMD_IEN_V(x) ((x) << FW_VI_ENABLE_CMD_IEN_S) - -#define FW_VI_ENABLE_CMD_EEN_S 30 -#define FW_VI_ENABLE_CMD_EEN_V(x) ((x) << FW_VI_ENABLE_CMD_EEN_S) - -#define FW_VI_ENABLE_CMD_LED_S 29 -#define FW_VI_ENABLE_CMD_LED_V(x) ((x) << FW_VI_ENABLE_CMD_LED_S) -#define FW_VI_ENABLE_CMD_LED_F FW_VI_ENABLE_CMD_LED_V(1U) - -#define FW_VI_ENABLE_CMD_DCB_INFO_S 28 -#define FW_VI_ENABLE_CMD_DCB_INFO_V(x) ((x) << FW_VI_ENABLE_CMD_DCB_INFO_S) - -/* VI VF stats offset definitions */ -#define VI_VF_NUM_STATS 16 -enum fw_vi_stats_vf_index { - FW_VI_VF_STAT_TX_BCAST_BYTES_IX, - FW_VI_VF_STAT_TX_BCAST_FRAMES_IX, - FW_VI_VF_STAT_TX_MCAST_BYTES_IX, - FW_VI_VF_STAT_TX_MCAST_FRAMES_IX, - FW_VI_VF_STAT_TX_UCAST_BYTES_IX, - FW_VI_VF_STAT_TX_UCAST_FRAMES_IX, - FW_VI_VF_STAT_TX_DROP_FRAMES_IX, - FW_VI_VF_STAT_TX_OFLD_BYTES_IX, - FW_VI_VF_STAT_TX_OFLD_FRAMES_IX, - FW_VI_VF_STAT_RX_BCAST_BYTES_IX, - FW_VI_VF_STAT_RX_BCAST_FRAMES_IX, - FW_VI_VF_STAT_RX_MCAST_BYTES_IX, - FW_VI_VF_STAT_RX_MCAST_FRAMES_IX, - FW_VI_VF_STAT_RX_UCAST_BYTES_IX, - FW_VI_VF_STAT_RX_UCAST_FRAMES_IX, - FW_VI_VF_STAT_RX_ERR_FRAMES_IX -}; - -/* VI PF stats offset definitions */ -#define VI_PF_NUM_STATS 17 -enum fw_vi_stats_pf_index { - FW_VI_PF_STAT_TX_BCAST_BYTES_IX, - FW_VI_PF_STAT_TX_BCAST_FRAMES_IX, - FW_VI_PF_STAT_TX_MCAST_BYTES_IX, - FW_VI_PF_STAT_TX_MCAST_FRAMES_IX, - FW_VI_PF_STAT_TX_UCAST_BYTES_IX, - FW_VI_PF_STAT_TX_UCAST_FRAMES_IX, - FW_VI_PF_STAT_TX_OFLD_BYTES_IX, - FW_VI_PF_STAT_TX_OFLD_FRAMES_IX, - FW_VI_PF_STAT_RX_BYTES_IX, - FW_VI_PF_STAT_RX_FRAMES_IX, - FW_VI_PF_STAT_RX_BCAST_BYTES_IX, - FW_VI_PF_STAT_RX_BCAST_FRAMES_IX, - FW_VI_PF_STAT_RX_MCAST_BYTES_IX, - FW_VI_PF_STAT_RX_MCAST_FRAMES_IX, - FW_VI_PF_STAT_RX_UCAST_BYTES_IX, - FW_VI_PF_STAT_RX_UCAST_FRAMES_IX, - FW_VI_PF_STAT_RX_ERR_FRAMES_IX -}; - -struct fw_vi_stats_cmd { - __be32 op_to_viid; - __be32 retval_len16; - union fw_vi_stats { - struct fw_vi_stats_ctl { - __be16 nstats_ix; - __be16 r6; - __be32 r7; - __be64 stat0; - __be64 stat1; - __be64 stat2; - __be64 stat3; - __be64 stat4; - __be64 stat5; - } ctl; - struct fw_vi_stats_pf { - __be64 tx_bcast_bytes; - __be64 tx_bcast_frames; - __be64 tx_mcast_bytes; - __be64 tx_mcast_frames; - __be64 tx_ucast_bytes; - __be64 tx_ucast_frames; - __be64 tx_offload_bytes; - __be64 tx_offload_frames; - __be64 rx_pf_bytes; - __be64 rx_pf_frames; - __be64 rx_bcast_bytes; - __be64 rx_bcast_frames; - __be64 rx_mcast_bytes; - __be64 rx_mcast_frames; - __be64 rx_ucast_bytes; - __be64 rx_ucast_frames; - __be64 rx_err_frames; - } pf; - struct fw_vi_stats_vf { - __be64 tx_bcast_bytes; - __be64 tx_bcast_frames; - __be64 tx_mcast_bytes; - __be64 tx_mcast_frames; - __be64 tx_ucast_bytes; - __be64 tx_ucast_frames; - __be64 tx_drop_frames; - __be64 tx_offload_bytes; - __be64 tx_offload_frames; - __be64 rx_bcast_bytes; - __be64 rx_bcast_frames; - __be64 rx_mcast_bytes; - __be64 rx_mcast_frames; - __be64 rx_ucast_bytes; - __be64 rx_ucast_frames; - __be64 rx_err_frames; - } vf; - } u; -}; - -#define FW_VI_STATS_CMD_VIID_S 0 -#define FW_VI_STATS_CMD_VIID_V(x) ((x) << FW_VI_STATS_CMD_VIID_S) - -#define FW_VI_STATS_CMD_NSTATS_S 12 -#define FW_VI_STATS_CMD_NSTATS_V(x) ((x) << FW_VI_STATS_CMD_NSTATS_S) - -#define FW_VI_STATS_CMD_IX_S 0 -#define FW_VI_STATS_CMD_IX_V(x) ((x) << FW_VI_STATS_CMD_IX_S) - -struct fw_acl_mac_cmd { - __be32 op_to_vfn; - __be32 en_to_len16; - u8 nmac; - u8 r3[7]; - __be16 r4; - u8 macaddr0[6]; - __be16 r5; - u8 macaddr1[6]; - __be16 r6; - u8 macaddr2[6]; - __be16 r7; - u8 macaddr3[6]; -}; - -#define FW_ACL_MAC_CMD_PFN_S 8 -#define FW_ACL_MAC_CMD_PFN_V(x) ((x) << FW_ACL_MAC_CMD_PFN_S) - -#define FW_ACL_MAC_CMD_VFN_S 0 -#define FW_ACL_MAC_CMD_VFN_V(x) ((x) << FW_ACL_MAC_CMD_VFN_S) - -#define FW_ACL_MAC_CMD_EN_S 31 -#define FW_ACL_MAC_CMD_EN_V(x) ((x) << FW_ACL_MAC_CMD_EN_S) - -struct fw_acl_vlan_cmd { - __be32 op_to_vfn; - __be32 en_to_len16; - u8 nvlan; - u8 dropnovlan_fm; - u8 r3_lo[6]; - __be16 vlanid[16]; -}; - -#define FW_ACL_VLAN_CMD_PFN_S 8 -#define FW_ACL_VLAN_CMD_PFN_V(x) ((x) << FW_ACL_VLAN_CMD_PFN_S) - -#define FW_ACL_VLAN_CMD_VFN_S 0 -#define FW_ACL_VLAN_CMD_VFN_V(x) ((x) << FW_ACL_VLAN_CMD_VFN_S) - -#define FW_ACL_VLAN_CMD_EN_S 31 -#define FW_ACL_VLAN_CMD_EN_V(x) ((x) << FW_ACL_VLAN_CMD_EN_S) - -#define FW_ACL_VLAN_CMD_DROPNOVLAN_S 7 -#define FW_ACL_VLAN_CMD_DROPNOVLAN_V(x) ((x) << FW_ACL_VLAN_CMD_DROPNOVLAN_S) - -#define FW_ACL_VLAN_CMD_FM_S 6 -#define FW_ACL_VLAN_CMD_FM_V(x) ((x) << FW_ACL_VLAN_CMD_FM_S) - -enum fw_port_cap { - FW_PORT_CAP_SPEED_100M = 0x0001, - FW_PORT_CAP_SPEED_1G = 0x0002, - FW_PORT_CAP_SPEED_25G = 0x0004, - FW_PORT_CAP_SPEED_10G = 0x0008, - FW_PORT_CAP_SPEED_40G = 0x0010, - FW_PORT_CAP_SPEED_100G = 0x0020, - FW_PORT_CAP_FC_RX = 0x0040, - FW_PORT_CAP_FC_TX = 0x0080, - FW_PORT_CAP_ANEG = 0x0100, - FW_PORT_CAP_MDIX = 0x0200, - FW_PORT_CAP_MDIAUTO = 0x0400, - FW_PORT_CAP_FEC = 0x0800, - FW_PORT_CAP_TECHKR = 0x1000, - FW_PORT_CAP_TECHKX4 = 0x2000, - FW_PORT_CAP_802_3_PAUSE = 0x4000, - FW_PORT_CAP_802_3_ASM_DIR = 0x8000, -}; - -#define FW_PORT_CAP_SPEED_S 0 -#define FW_PORT_CAP_SPEED_M 0x3f -#define FW_PORT_CAP_SPEED_V(x) ((x) << FW_PORT_CAP_SPEED_S) -#define FW_PORT_CAP_SPEED_G(x) \ - (((x) >> FW_PORT_CAP_SPEED_S) & FW_PORT_CAP_SPEED_M) - -enum fw_port_mdi { - FW_PORT_CAP_MDI_UNCHANGED, - FW_PORT_CAP_MDI_AUTO, - FW_PORT_CAP_MDI_F_STRAIGHT, - FW_PORT_CAP_MDI_F_CROSSOVER -}; - -#define FW_PORT_CAP_MDI_S 9 -#define FW_PORT_CAP_MDI_V(x) ((x) << FW_PORT_CAP_MDI_S) - -enum fw_port_action { - FW_PORT_ACTION_L1_CFG = 0x0001, - FW_PORT_ACTION_L2_CFG = 0x0002, - FW_PORT_ACTION_GET_PORT_INFO = 0x0003, - FW_PORT_ACTION_L2_PPP_CFG = 0x0004, - FW_PORT_ACTION_L2_DCB_CFG = 0x0005, - FW_PORT_ACTION_DCB_READ_TRANS = 0x0006, - FW_PORT_ACTION_DCB_READ_RECV = 0x0007, - FW_PORT_ACTION_DCB_READ_DET = 0x0008, - FW_PORT_ACTION_LOW_PWR_TO_NORMAL = 0x0010, - FW_PORT_ACTION_L1_LOW_PWR_EN = 0x0011, - FW_PORT_ACTION_L2_WOL_MODE_EN = 0x0012, - FW_PORT_ACTION_LPBK_TO_NORMAL = 0x0020, - FW_PORT_ACTION_L1_LPBK = 0x0021, - FW_PORT_ACTION_L1_PMA_LPBK = 0x0022, - FW_PORT_ACTION_L1_PCS_LPBK = 0x0023, - FW_PORT_ACTION_L1_PHYXS_CSIDE_LPBK = 0x0024, - FW_PORT_ACTION_L1_PHYXS_ESIDE_LPBK = 0x0025, - FW_PORT_ACTION_PHY_RESET = 0x0040, - FW_PORT_ACTION_PMA_RESET = 0x0041, - FW_PORT_ACTION_PCS_RESET = 0x0042, - FW_PORT_ACTION_PHYXS_RESET = 0x0043, - FW_PORT_ACTION_DTEXS_REEST = 0x0044, - FW_PORT_ACTION_AN_RESET = 0x0045 -}; - -enum fw_port_l2cfg_ctlbf { - FW_PORT_L2_CTLBF_OVLAN0 = 0x01, - FW_PORT_L2_CTLBF_OVLAN1 = 0x02, - FW_PORT_L2_CTLBF_OVLAN2 = 0x04, - FW_PORT_L2_CTLBF_OVLAN3 = 0x08, - FW_PORT_L2_CTLBF_IVLAN = 0x10, - FW_PORT_L2_CTLBF_TXIPG = 0x20 -}; - -enum fw_port_dcb_versions { - FW_PORT_DCB_VER_UNKNOWN, - FW_PORT_DCB_VER_CEE1D0, - FW_PORT_DCB_VER_CEE1D01, - FW_PORT_DCB_VER_IEEE, - FW_PORT_DCB_VER_AUTO = 7 -}; - -enum fw_port_dcb_cfg { - FW_PORT_DCB_CFG_PG = 0x01, - FW_PORT_DCB_CFG_PFC = 0x02, - FW_PORT_DCB_CFG_APPL = 0x04 -}; - -enum fw_port_dcb_cfg_rc { - FW_PORT_DCB_CFG_SUCCESS = 0x0, - FW_PORT_DCB_CFG_ERROR = 0x1 -}; - -enum fw_port_dcb_type { - FW_PORT_DCB_TYPE_PGID = 0x00, - FW_PORT_DCB_TYPE_PGRATE = 0x01, - FW_PORT_DCB_TYPE_PRIORATE = 0x02, - FW_PORT_DCB_TYPE_PFC = 0x03, - FW_PORT_DCB_TYPE_APP_ID = 0x04, - FW_PORT_DCB_TYPE_CONTROL = 0x05, -}; - -enum fw_port_dcb_feature_state { - FW_PORT_DCB_FEATURE_STATE_PENDING = 0x0, - FW_PORT_DCB_FEATURE_STATE_SUCCESS = 0x1, - FW_PORT_DCB_FEATURE_STATE_ERROR = 0x2, - FW_PORT_DCB_FEATURE_STATE_TIMEOUT = 0x3, -}; - -struct fw_port_cmd { - __be32 op_to_portid; - __be32 action_to_len16; - union fw_port { - struct fw_port_l1cfg { - __be32 rcap; - __be32 r; - } l1cfg; - struct fw_port_l2cfg { - __u8 ctlbf; - __u8 ovlan3_to_ivlan0; - __be16 ivlantype; - __be16 txipg_force_pinfo; - __be16 mtu; - __be16 ovlan0mask; - __be16 ovlan0type; - __be16 ovlan1mask; - __be16 ovlan1type; - __be16 ovlan2mask; - __be16 ovlan2type; - __be16 ovlan3mask; - __be16 ovlan3type; - } l2cfg; - struct fw_port_info { - __be32 lstatus_to_modtype; - __be16 pcap; - __be16 acap; - __be16 mtu; - __u8 cbllen; - __u8 auxlinfo; - __u8 dcbxdis_pkd; - __u8 r8_lo; - __be16 lpacap; - __be64 r9; - } info; - struct fw_port_diags { - __u8 diagop; - __u8 r[3]; - __be32 diagval; - } diags; - union fw_port_dcb { - struct fw_port_dcb_pgid { - __u8 type; - __u8 apply_pkd; - __u8 r10_lo[2]; - __be32 pgid; - __be64 r11; - } pgid; - struct fw_port_dcb_pgrate { - __u8 type; - __u8 apply_pkd; - __u8 r10_lo[5]; - __u8 num_tcs_supported; - __u8 pgrate[8]; - __u8 tsa[8]; - } pgrate; - struct fw_port_dcb_priorate { - __u8 type; - __u8 apply_pkd; - __u8 r10_lo[6]; - __u8 strict_priorate[8]; - } priorate; - struct fw_port_dcb_pfc { - __u8 type; - __u8 pfcen; - __u8 r10[5]; - __u8 max_pfc_tcs; - __be64 r11; - } pfc; - struct fw_port_app_priority { - __u8 type; - __u8 r10[2]; - __u8 idx; - __u8 user_prio_map; - __u8 sel_field; - __be16 protocolid; - __be64 r12; - } app_priority; - struct fw_port_dcb_control { - __u8 type; - __u8 all_syncd_pkd; - __be16 dcb_version_to_app_state; - __be32 r11; - __be64 r12; - } control; - } dcb; - } u; -}; - -#define FW_PORT_CMD_READ_S 22 -#define FW_PORT_CMD_READ_V(x) ((x) << FW_PORT_CMD_READ_S) -#define FW_PORT_CMD_READ_F FW_PORT_CMD_READ_V(1U) - -#define FW_PORT_CMD_PORTID_S 0 -#define FW_PORT_CMD_PORTID_M 0xf -#define FW_PORT_CMD_PORTID_V(x) ((x) << FW_PORT_CMD_PORTID_S) -#define FW_PORT_CMD_PORTID_G(x) \ - (((x) >> FW_PORT_CMD_PORTID_S) & FW_PORT_CMD_PORTID_M) - -#define FW_PORT_CMD_ACTION_S 16 -#define FW_PORT_CMD_ACTION_M 0xffff -#define FW_PORT_CMD_ACTION_V(x) ((x) << FW_PORT_CMD_ACTION_S) -#define FW_PORT_CMD_ACTION_G(x) \ - (((x) >> FW_PORT_CMD_ACTION_S) & FW_PORT_CMD_ACTION_M) - -#define FW_PORT_CMD_OVLAN3_S 7 -#define FW_PORT_CMD_OVLAN3_V(x) ((x) << FW_PORT_CMD_OVLAN3_S) - -#define FW_PORT_CMD_OVLAN2_S 6 -#define FW_PORT_CMD_OVLAN2_V(x) ((x) << FW_PORT_CMD_OVLAN2_S) - -#define FW_PORT_CMD_OVLAN1_S 5 -#define FW_PORT_CMD_OVLAN1_V(x) ((x) << FW_PORT_CMD_OVLAN1_S) - -#define FW_PORT_CMD_OVLAN0_S 4 -#define FW_PORT_CMD_OVLAN0_V(x) ((x) << FW_PORT_CMD_OVLAN0_S) - -#define FW_PORT_CMD_IVLAN0_S 3 -#define FW_PORT_CMD_IVLAN0_V(x) ((x) << FW_PORT_CMD_IVLAN0_S) - -#define FW_PORT_CMD_TXIPG_S 3 -#define FW_PORT_CMD_TXIPG_V(x) ((x) << FW_PORT_CMD_TXIPG_S) - -#define FW_PORT_CMD_LSTATUS_S 31 -#define FW_PORT_CMD_LSTATUS_M 0x1 -#define FW_PORT_CMD_LSTATUS_V(x) ((x) << FW_PORT_CMD_LSTATUS_S) -#define FW_PORT_CMD_LSTATUS_G(x) \ - (((x) >> FW_PORT_CMD_LSTATUS_S) & FW_PORT_CMD_LSTATUS_M) -#define FW_PORT_CMD_LSTATUS_F FW_PORT_CMD_LSTATUS_V(1U) - -#define FW_PORT_CMD_LSPEED_S 24 -#define FW_PORT_CMD_LSPEED_M 0x3f -#define FW_PORT_CMD_LSPEED_V(x) ((x) << FW_PORT_CMD_LSPEED_S) -#define FW_PORT_CMD_LSPEED_G(x) \ - (((x) >> FW_PORT_CMD_LSPEED_S) & FW_PORT_CMD_LSPEED_M) - -#define FW_PORT_CMD_TXPAUSE_S 23 -#define FW_PORT_CMD_TXPAUSE_V(x) ((x) << FW_PORT_CMD_TXPAUSE_S) -#define FW_PORT_CMD_TXPAUSE_F FW_PORT_CMD_TXPAUSE_V(1U) - -#define FW_PORT_CMD_RXPAUSE_S 22 -#define FW_PORT_CMD_RXPAUSE_V(x) ((x) << FW_PORT_CMD_RXPAUSE_S) -#define FW_PORT_CMD_RXPAUSE_F FW_PORT_CMD_RXPAUSE_V(1U) - -#define FW_PORT_CMD_MDIOCAP_S 21 -#define FW_PORT_CMD_MDIOCAP_V(x) ((x) << FW_PORT_CMD_MDIOCAP_S) -#define FW_PORT_CMD_MDIOCAP_F FW_PORT_CMD_MDIOCAP_V(1U) - -#define FW_PORT_CMD_MDIOADDR_S 16 -#define FW_PORT_CMD_MDIOADDR_M 0x1f -#define FW_PORT_CMD_MDIOADDR_G(x) \ - (((x) >> FW_PORT_CMD_MDIOADDR_S) & FW_PORT_CMD_MDIOADDR_M) - -#define FW_PORT_CMD_LPTXPAUSE_S 15 -#define FW_PORT_CMD_LPTXPAUSE_V(x) ((x) << FW_PORT_CMD_LPTXPAUSE_S) -#define FW_PORT_CMD_LPTXPAUSE_F FW_PORT_CMD_LPTXPAUSE_V(1U) - -#define FW_PORT_CMD_LPRXPAUSE_S 14 -#define FW_PORT_CMD_LPRXPAUSE_V(x) ((x) << FW_PORT_CMD_LPRXPAUSE_S) -#define FW_PORT_CMD_LPRXPAUSE_F FW_PORT_CMD_LPRXPAUSE_V(1U) - -#define FW_PORT_CMD_PTYPE_S 8 -#define FW_PORT_CMD_PTYPE_M 0x1f -#define FW_PORT_CMD_PTYPE_G(x) \ - (((x) >> FW_PORT_CMD_PTYPE_S) & FW_PORT_CMD_PTYPE_M) - -#define FW_PORT_CMD_LINKDNRC_S 5 -#define FW_PORT_CMD_LINKDNRC_M 0x7 -#define FW_PORT_CMD_LINKDNRC_G(x) \ - (((x) >> FW_PORT_CMD_LINKDNRC_S) & FW_PORT_CMD_LINKDNRC_M) - -#define FW_PORT_CMD_MODTYPE_S 0 -#define FW_PORT_CMD_MODTYPE_M 0x1f -#define FW_PORT_CMD_MODTYPE_V(x) ((x) << FW_PORT_CMD_MODTYPE_S) -#define FW_PORT_CMD_MODTYPE_G(x) \ - (((x) >> FW_PORT_CMD_MODTYPE_S) & FW_PORT_CMD_MODTYPE_M) - -#define FW_PORT_CMD_DCBXDIS_S 7 -#define FW_PORT_CMD_DCBXDIS_V(x) ((x) << FW_PORT_CMD_DCBXDIS_S) -#define FW_PORT_CMD_DCBXDIS_F FW_PORT_CMD_DCBXDIS_V(1U) - -#define FW_PORT_CMD_APPLY_S 7 -#define FW_PORT_CMD_APPLY_V(x) ((x) << FW_PORT_CMD_APPLY_S) -#define FW_PORT_CMD_APPLY_F FW_PORT_CMD_APPLY_V(1U) - -#define FW_PORT_CMD_ALL_SYNCD_S 7 -#define FW_PORT_CMD_ALL_SYNCD_V(x) ((x) << FW_PORT_CMD_ALL_SYNCD_S) -#define FW_PORT_CMD_ALL_SYNCD_F FW_PORT_CMD_ALL_SYNCD_V(1U) - -#define FW_PORT_CMD_DCB_VERSION_S 12 -#define FW_PORT_CMD_DCB_VERSION_M 0x7 -#define FW_PORT_CMD_DCB_VERSION_G(x) \ - (((x) >> FW_PORT_CMD_DCB_VERSION_S) & FW_PORT_CMD_DCB_VERSION_M) - -enum fw_port_type { - FW_PORT_TYPE_FIBER_XFI, - FW_PORT_TYPE_FIBER_XAUI, - FW_PORT_TYPE_BT_SGMII, - FW_PORT_TYPE_BT_XFI, - FW_PORT_TYPE_BT_XAUI, - FW_PORT_TYPE_KX4, - FW_PORT_TYPE_CX4, - FW_PORT_TYPE_KX, - FW_PORT_TYPE_KR, - FW_PORT_TYPE_SFP, - FW_PORT_TYPE_BP_AP, - FW_PORT_TYPE_BP4_AP, - FW_PORT_TYPE_QSFP_10G, - FW_PORT_TYPE_QSA, - FW_PORT_TYPE_QSFP, - FW_PORT_TYPE_BP40_BA, - FW_PORT_TYPE_KR4_100G, - FW_PORT_TYPE_CR4_QSFP, - FW_PORT_TYPE_CR_QSFP, - FW_PORT_TYPE_CR2_QSFP, - FW_PORT_TYPE_SFP28, - - FW_PORT_TYPE_NONE = FW_PORT_CMD_PTYPE_M -}; - -enum fw_port_module_type { - FW_PORT_MOD_TYPE_NA, - FW_PORT_MOD_TYPE_LR, - FW_PORT_MOD_TYPE_SR, - FW_PORT_MOD_TYPE_ER, - FW_PORT_MOD_TYPE_TWINAX_PASSIVE, - FW_PORT_MOD_TYPE_TWINAX_ACTIVE, - FW_PORT_MOD_TYPE_LRM, - FW_PORT_MOD_TYPE_ERROR = FW_PORT_CMD_MODTYPE_M - 3, - FW_PORT_MOD_TYPE_UNKNOWN = FW_PORT_CMD_MODTYPE_M - 2, - FW_PORT_MOD_TYPE_NOTSUPPORTED = FW_PORT_CMD_MODTYPE_M - 1, - - FW_PORT_MOD_TYPE_NONE = FW_PORT_CMD_MODTYPE_M -}; - -enum fw_port_mod_sub_type { - FW_PORT_MOD_SUB_TYPE_NA, - FW_PORT_MOD_SUB_TYPE_MV88E114X = 0x1, - FW_PORT_MOD_SUB_TYPE_TN8022 = 0x2, - FW_PORT_MOD_SUB_TYPE_AQ1202 = 0x3, - FW_PORT_MOD_SUB_TYPE_88x3120 = 0x4, - FW_PORT_MOD_SUB_TYPE_BCM84834 = 0x5, - FW_PORT_MOD_SUB_TYPE_BT_VSC8634 = 0x8, - - /* The following will never been in the VPD. They are TWINAX cable - * lengths decoded from SFP+ module i2c PROMs. These should - * almost certainly go somewhere else ... - */ - FW_PORT_MOD_SUB_TYPE_TWINAX_1 = 0x9, - FW_PORT_MOD_SUB_TYPE_TWINAX_3 = 0xA, - FW_PORT_MOD_SUB_TYPE_TWINAX_5 = 0xB, - FW_PORT_MOD_SUB_TYPE_TWINAX_7 = 0xC, -}; - -enum fw_port_stats_tx_index { - FW_STAT_TX_PORT_BYTES_IX = 0, - FW_STAT_TX_PORT_FRAMES_IX, - FW_STAT_TX_PORT_BCAST_IX, - FW_STAT_TX_PORT_MCAST_IX, - FW_STAT_TX_PORT_UCAST_IX, - FW_STAT_TX_PORT_ERROR_IX, - FW_STAT_TX_PORT_64B_IX, - FW_STAT_TX_PORT_65B_127B_IX, - FW_STAT_TX_PORT_128B_255B_IX, - FW_STAT_TX_PORT_256B_511B_IX, - FW_STAT_TX_PORT_512B_1023B_IX, - FW_STAT_TX_PORT_1024B_1518B_IX, - FW_STAT_TX_PORT_1519B_MAX_IX, - FW_STAT_TX_PORT_DROP_IX, - FW_STAT_TX_PORT_PAUSE_IX, - FW_STAT_TX_PORT_PPP0_IX, - FW_STAT_TX_PORT_PPP1_IX, - FW_STAT_TX_PORT_PPP2_IX, - FW_STAT_TX_PORT_PPP3_IX, - FW_STAT_TX_PORT_PPP4_IX, - FW_STAT_TX_PORT_PPP5_IX, - FW_STAT_TX_PORT_PPP6_IX, - FW_STAT_TX_PORT_PPP7_IX, - FW_NUM_PORT_TX_STATS -}; - -enum fw_port_stat_rx_index { - FW_STAT_RX_PORT_BYTES_IX = 0, - FW_STAT_RX_PORT_FRAMES_IX, - FW_STAT_RX_PORT_BCAST_IX, - FW_STAT_RX_PORT_MCAST_IX, - FW_STAT_RX_PORT_UCAST_IX, - FW_STAT_RX_PORT_MTU_ERROR_IX, - FW_STAT_RX_PORT_MTU_CRC_ERROR_IX, - FW_STAT_RX_PORT_CRC_ERROR_IX, - FW_STAT_RX_PORT_LEN_ERROR_IX, - FW_STAT_RX_PORT_SYM_ERROR_IX, - FW_STAT_RX_PORT_64B_IX, - FW_STAT_RX_PORT_65B_127B_IX, - FW_STAT_RX_PORT_128B_255B_IX, - FW_STAT_RX_PORT_256B_511B_IX, - FW_STAT_RX_PORT_512B_1023B_IX, - FW_STAT_RX_PORT_1024B_1518B_IX, - FW_STAT_RX_PORT_1519B_MAX_IX, - FW_STAT_RX_PORT_PAUSE_IX, - FW_STAT_RX_PORT_PPP0_IX, - FW_STAT_RX_PORT_PPP1_IX, - FW_STAT_RX_PORT_PPP2_IX, - FW_STAT_RX_PORT_PPP3_IX, - FW_STAT_RX_PORT_PPP4_IX, - FW_STAT_RX_PORT_PPP5_IX, - FW_STAT_RX_PORT_PPP6_IX, - FW_STAT_RX_PORT_PPP7_IX, - FW_STAT_RX_PORT_LESS_64B_IX, - FW_STAT_RX_PORT_MAC_ERROR_IX, - FW_NUM_PORT_RX_STATS -}; - -/* port stats */ -#define FW_NUM_PORT_STATS (FW_NUM_PORT_TX_STATS + FW_NUM_PORT_RX_STATS) - -struct fw_port_stats_cmd { - __be32 op_to_portid; - __be32 retval_len16; - union fw_port_stats { - struct fw_port_stats_ctl { - u8 nstats_bg_bm; - u8 tx_ix; - __be16 r6; - __be32 r7; - __be64 stat0; - __be64 stat1; - __be64 stat2; - __be64 stat3; - __be64 stat4; - __be64 stat5; - } ctl; - struct fw_port_stats_all { - __be64 tx_bytes; - __be64 tx_frames; - __be64 tx_bcast; - __be64 tx_mcast; - __be64 tx_ucast; - __be64 tx_error; - __be64 tx_64b; - __be64 tx_65b_127b; - __be64 tx_128b_255b; - __be64 tx_256b_511b; - __be64 tx_512b_1023b; - __be64 tx_1024b_1518b; - __be64 tx_1519b_max; - __be64 tx_drop; - __be64 tx_pause; - __be64 tx_ppp0; - __be64 tx_ppp1; - __be64 tx_ppp2; - __be64 tx_ppp3; - __be64 tx_ppp4; - __be64 tx_ppp5; - __be64 tx_ppp6; - __be64 tx_ppp7; - __be64 rx_bytes; - __be64 rx_frames; - __be64 rx_bcast; - __be64 rx_mcast; - __be64 rx_ucast; - __be64 rx_mtu_error; - __be64 rx_mtu_crc_error; - __be64 rx_crc_error; - __be64 rx_len_error; - __be64 rx_sym_error; - __be64 rx_64b; - __be64 rx_65b_127b; - __be64 rx_128b_255b; - __be64 rx_256b_511b; - __be64 rx_512b_1023b; - __be64 rx_1024b_1518b; - __be64 rx_1519b_max; - __be64 rx_pause; - __be64 rx_ppp0; - __be64 rx_ppp1; - __be64 rx_ppp2; - __be64 rx_ppp3; - __be64 rx_ppp4; - __be64 rx_ppp5; - __be64 rx_ppp6; - __be64 rx_ppp7; - __be64 rx_less_64b; - __be64 rx_bg_drop; - __be64 rx_bg_trunc; - } all; - } u; -}; - -/* port loopback stats */ -#define FW_NUM_LB_STATS 16 -enum fw_port_lb_stats_index { - FW_STAT_LB_PORT_BYTES_IX, - FW_STAT_LB_PORT_FRAMES_IX, - FW_STAT_LB_PORT_BCAST_IX, - FW_STAT_LB_PORT_MCAST_IX, - FW_STAT_LB_PORT_UCAST_IX, - FW_STAT_LB_PORT_ERROR_IX, - FW_STAT_LB_PORT_64B_IX, - FW_STAT_LB_PORT_65B_127B_IX, - FW_STAT_LB_PORT_128B_255B_IX, - FW_STAT_LB_PORT_256B_511B_IX, - FW_STAT_LB_PORT_512B_1023B_IX, - FW_STAT_LB_PORT_1024B_1518B_IX, - FW_STAT_LB_PORT_1519B_MAX_IX, - FW_STAT_LB_PORT_DROP_FRAMES_IX -}; - -struct fw_port_lb_stats_cmd { - __be32 op_to_lbport; - __be32 retval_len16; - union fw_port_lb_stats { - struct fw_port_lb_stats_ctl { - u8 nstats_bg_bm; - u8 ix_pkd; - __be16 r6; - __be32 r7; - __be64 stat0; - __be64 stat1; - __be64 stat2; - __be64 stat3; - __be64 stat4; - __be64 stat5; - } ctl; - struct fw_port_lb_stats_all { - __be64 tx_bytes; - __be64 tx_frames; - __be64 tx_bcast; - __be64 tx_mcast; - __be64 tx_ucast; - __be64 tx_error; - __be64 tx_64b; - __be64 tx_65b_127b; - __be64 tx_128b_255b; - __be64 tx_256b_511b; - __be64 tx_512b_1023b; - __be64 tx_1024b_1518b; - __be64 tx_1519b_max; - __be64 rx_lb_drop; - __be64 rx_lb_trunc; - } all; - } u; -}; - -struct fw_rss_ind_tbl_cmd { - __be32 op_to_viid; - __be32 retval_len16; - __be16 niqid; - __be16 startidx; - __be32 r3; - __be32 iq0_to_iq2; - __be32 iq3_to_iq5; - __be32 iq6_to_iq8; - __be32 iq9_to_iq11; - __be32 iq12_to_iq14; - __be32 iq15_to_iq17; - __be32 iq18_to_iq20; - __be32 iq21_to_iq23; - __be32 iq24_to_iq26; - __be32 iq27_to_iq29; - __be32 iq30_iq31; - __be32 r15_lo; -}; - -#define FW_RSS_IND_TBL_CMD_VIID_S 0 -#define FW_RSS_IND_TBL_CMD_VIID_V(x) ((x) << FW_RSS_IND_TBL_CMD_VIID_S) - -#define FW_RSS_IND_TBL_CMD_IQ0_S 20 -#define FW_RSS_IND_TBL_CMD_IQ0_V(x) ((x) << FW_RSS_IND_TBL_CMD_IQ0_S) - -#define FW_RSS_IND_TBL_CMD_IQ1_S 10 -#define FW_RSS_IND_TBL_CMD_IQ1_V(x) ((x) << FW_RSS_IND_TBL_CMD_IQ1_S) - -#define FW_RSS_IND_TBL_CMD_IQ2_S 0 -#define FW_RSS_IND_TBL_CMD_IQ2_V(x) ((x) << FW_RSS_IND_TBL_CMD_IQ2_S) - -struct fw_rss_glb_config_cmd { - __be32 op_to_write; - __be32 retval_len16; - union fw_rss_glb_config { - struct fw_rss_glb_config_manual { - __be32 mode_pkd; - __be32 r3; - __be64 r4; - __be64 r5; - } manual; - struct fw_rss_glb_config_basicvirtual { - __be32 mode_pkd; - __be32 synmapen_to_hashtoeplitz; - __be64 r8; - __be64 r9; - } basicvirtual; - } u; -}; - -#define FW_RSS_GLB_CONFIG_CMD_MODE_S 28 -#define FW_RSS_GLB_CONFIG_CMD_MODE_M 0xf -#define FW_RSS_GLB_CONFIG_CMD_MODE_V(x) ((x) << FW_RSS_GLB_CONFIG_CMD_MODE_S) -#define FW_RSS_GLB_CONFIG_CMD_MODE_G(x) \ - (((x) >> FW_RSS_GLB_CONFIG_CMD_MODE_S) & FW_RSS_GLB_CONFIG_CMD_MODE_M) - -#define FW_RSS_GLB_CONFIG_CMD_MODE_MANUAL 0 -#define FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL 1 - -#define FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_S 8 -#define FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_S) -#define FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_F \ - FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_V(1U) - -#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_S 7 -#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_S) -#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_F \ - FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_V(1U) - -#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_S 6 -#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_S) -#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_F \ - FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_V(1U) - -#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_S 5 -#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_S) -#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_F \ - FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_V(1U) - -#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_S 4 -#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_S) -#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_F \ - FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_V(1U) - -#define FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_S 3 -#define FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_S) -#define FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_F \ - FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_V(1U) - -#define FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_S 2 -#define FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_S) -#define FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_F \ - FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_V(1U) - -#define FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_S 1 -#define FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_S) -#define FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_F \ - FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_V(1U) - -#define FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_S 0 -#define FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_V(x) \ - ((x) << FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_S) -#define FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_F \ - FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_V(1U) - -struct fw_rss_vi_config_cmd { - __be32 op_to_viid; -#define FW_RSS_VI_CONFIG_CMD_VIID(x) ((x) << 0) - __be32 retval_len16; - union fw_rss_vi_config { - struct fw_rss_vi_config_manual { - __be64 r3; - __be64 r4; - __be64 r5; - } manual; - struct fw_rss_vi_config_basicvirtual { - __be32 r6; - __be32 defaultq_to_udpen; - __be64 r9; - __be64 r10; - } basicvirtual; - } u; -}; - -#define FW_RSS_VI_CONFIG_CMD_VIID_S 0 -#define FW_RSS_VI_CONFIG_CMD_VIID_V(x) ((x) << FW_RSS_VI_CONFIG_CMD_VIID_S) - -#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_S 16 -#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_M 0x3ff -#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_V(x) \ - ((x) << FW_RSS_VI_CONFIG_CMD_DEFAULTQ_S) -#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_G(x) \ - (((x) >> FW_RSS_VI_CONFIG_CMD_DEFAULTQ_S) & \ - FW_RSS_VI_CONFIG_CMD_DEFAULTQ_M) - -#define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_S 4 -#define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_V(x) \ - ((x) << FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_S) -#define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_F \ - FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_V(1U) - -#define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_S 3 -#define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_V(x) \ - ((x) << FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_S) -#define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_F \ - FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_V(1U) - -#define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_S 2 -#define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_V(x) \ - ((x) << FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_S) -#define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_F \ - FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_V(1U) - -#define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_S 1 -#define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_V(x) \ - ((x) << FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_S) -#define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_F \ - FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_V(1U) - -#define FW_RSS_VI_CONFIG_CMD_UDPEN_S 0 -#define FW_RSS_VI_CONFIG_CMD_UDPEN_V(x) ((x) << FW_RSS_VI_CONFIG_CMD_UDPEN_S) -#define FW_RSS_VI_CONFIG_CMD_UDPEN_F FW_RSS_VI_CONFIG_CMD_UDPEN_V(1U) - -struct fw_clip_cmd { - __be32 op_to_write; - __be32 alloc_to_len16; - __be64 ip_hi; - __be64 ip_lo; - __be32 r4[2]; -}; - -#define FW_CLIP_CMD_ALLOC_S 31 -#define FW_CLIP_CMD_ALLOC_V(x) ((x) << FW_CLIP_CMD_ALLOC_S) -#define FW_CLIP_CMD_ALLOC_F FW_CLIP_CMD_ALLOC_V(1U) - -#define FW_CLIP_CMD_FREE_S 30 -#define FW_CLIP_CMD_FREE_V(x) ((x) << FW_CLIP_CMD_FREE_S) -#define FW_CLIP_CMD_FREE_F FW_CLIP_CMD_FREE_V(1U) - -enum fw_error_type { - FW_ERROR_TYPE_EXCEPTION = 0x0, - FW_ERROR_TYPE_HWMODULE = 0x1, - FW_ERROR_TYPE_WR = 0x2, - FW_ERROR_TYPE_ACL = 0x3, -}; - -struct fw_error_cmd { - __be32 op_to_type; - __be32 len16_pkd; - union fw_error { - struct fw_error_exception { - __be32 info[6]; - } exception; - struct fw_error_hwmodule { - __be32 regaddr; - __be32 regval; - } hwmodule; - struct fw_error_wr { - __be16 cidx; - __be16 pfn_vfn; - __be32 eqid; - u8 wrhdr[16]; - } wr; - struct fw_error_acl { - __be16 cidx; - __be16 pfn_vfn; - __be32 eqid; - __be16 mv_pkd; - u8 val[6]; - __be64 r4; - } acl; - } u; -}; - -struct fw_debug_cmd { - __be32 op_type; - __be32 len16_pkd; - union fw_debug { - struct fw_debug_assert { - __be32 fcid; - __be32 line; - __be32 x; - __be32 y; - u8 filename_0_7[8]; - u8 filename_8_15[8]; - __be64 r3; - } assert; - struct fw_debug_prt { - __be16 dprtstridx; - __be16 r3[3]; - __be32 dprtstrparam0; - __be32 dprtstrparam1; - __be32 dprtstrparam2; - __be32 dprtstrparam3; - } prt; - } u; -}; - -#define FW_DEBUG_CMD_TYPE_S 0 -#define FW_DEBUG_CMD_TYPE_M 0xff -#define FW_DEBUG_CMD_TYPE_G(x) \ - (((x) >> FW_DEBUG_CMD_TYPE_S) & FW_DEBUG_CMD_TYPE_M) - -#define PCIE_FW_ERR_S 31 -#define PCIE_FW_ERR_V(x) ((x) << PCIE_FW_ERR_S) -#define PCIE_FW_ERR_F PCIE_FW_ERR_V(1U) - -#define PCIE_FW_INIT_S 30 -#define PCIE_FW_INIT_V(x) ((x) << PCIE_FW_INIT_S) -#define PCIE_FW_INIT_F PCIE_FW_INIT_V(1U) - -#define PCIE_FW_HALT_S 29 -#define PCIE_FW_HALT_V(x) ((x) << PCIE_FW_HALT_S) -#define PCIE_FW_HALT_F PCIE_FW_HALT_V(1U) - -#define PCIE_FW_EVAL_S 24 -#define PCIE_FW_EVAL_M 0x7 -#define PCIE_FW_EVAL_G(x) (((x) >> PCIE_FW_EVAL_S) & PCIE_FW_EVAL_M) - -#define PCIE_FW_MASTER_VLD_S 15 -#define PCIE_FW_MASTER_VLD_V(x) ((x) << PCIE_FW_MASTER_VLD_S) -#define PCIE_FW_MASTER_VLD_F PCIE_FW_MASTER_VLD_V(1U) - -#define PCIE_FW_MASTER_S 12 -#define PCIE_FW_MASTER_M 0x7 -#define PCIE_FW_MASTER_V(x) ((x) << PCIE_FW_MASTER_S) -#define PCIE_FW_MASTER_G(x) (((x) >> PCIE_FW_MASTER_S) & PCIE_FW_MASTER_M) - -struct fw_hdr { - u8 ver; - u8 chip; /* terminator chip type */ - __be16 len512; /* bin length in units of 512-bytes */ - __be32 fw_ver; /* firmware version */ - __be32 tp_microcode_ver; - u8 intfver_nic; - u8 intfver_vnic; - u8 intfver_ofld; - u8 intfver_ri; - u8 intfver_iscsipdu; - u8 intfver_iscsi; - u8 intfver_fcoepdu; - u8 intfver_fcoe; - __u32 reserved2; - __u32 reserved3; - __u32 reserved4; - __be32 flags; - __be32 reserved6[23]; -}; - -enum fw_hdr_chip { - FW_HDR_CHIP_T4, - FW_HDR_CHIP_T5, - FW_HDR_CHIP_T6 -}; - -#define FW_HDR_FW_VER_MAJOR_S 24 -#define FW_HDR_FW_VER_MAJOR_M 0xff -#define FW_HDR_FW_VER_MAJOR_V(x) \ - ((x) << FW_HDR_FW_VER_MAJOR_S) -#define FW_HDR_FW_VER_MAJOR_G(x) \ - (((x) >> FW_HDR_FW_VER_MAJOR_S) & FW_HDR_FW_VER_MAJOR_M) - -#define FW_HDR_FW_VER_MINOR_S 16 -#define FW_HDR_FW_VER_MINOR_M 0xff -#define FW_HDR_FW_VER_MINOR_V(x) \ - ((x) << FW_HDR_FW_VER_MINOR_S) -#define FW_HDR_FW_VER_MINOR_G(x) \ - (((x) >> FW_HDR_FW_VER_MINOR_S) & FW_HDR_FW_VER_MINOR_M) - -#define FW_HDR_FW_VER_MICRO_S 8 -#define FW_HDR_FW_VER_MICRO_M 0xff -#define FW_HDR_FW_VER_MICRO_V(x) \ - ((x) << FW_HDR_FW_VER_MICRO_S) -#define FW_HDR_FW_VER_MICRO_G(x) \ - (((x) >> FW_HDR_FW_VER_MICRO_S) & FW_HDR_FW_VER_MICRO_M) - -#define FW_HDR_FW_VER_BUILD_S 0 -#define FW_HDR_FW_VER_BUILD_M 0xff -#define FW_HDR_FW_VER_BUILD_V(x) \ - ((x) << FW_HDR_FW_VER_BUILD_S) -#define FW_HDR_FW_VER_BUILD_G(x) \ - (((x) >> FW_HDR_FW_VER_BUILD_S) & FW_HDR_FW_VER_BUILD_M) - -enum fw_hdr_intfver { - FW_HDR_INTFVER_NIC = 0x00, - FW_HDR_INTFVER_VNIC = 0x00, - FW_HDR_INTFVER_OFLD = 0x00, - FW_HDR_INTFVER_RI = 0x00, - FW_HDR_INTFVER_ISCSIPDU = 0x00, - FW_HDR_INTFVER_ISCSI = 0x00, - FW_HDR_INTFVER_FCOEPDU = 0x00, - FW_HDR_INTFVER_FCOE = 0x00, -}; - -enum fw_hdr_flags { - FW_HDR_FLAGS_RESET_HALT = 0x00000001, -}; - -/* length of the formatting string */ -#define FW_DEVLOG_FMT_LEN 192 - -/* maximum number of the formatting string parameters */ -#define FW_DEVLOG_FMT_PARAMS_NUM 8 - -/* priority levels */ -enum fw_devlog_level { - FW_DEVLOG_LEVEL_EMERG = 0x0, - FW_DEVLOG_LEVEL_CRIT = 0x1, - FW_DEVLOG_LEVEL_ERR = 0x2, - FW_DEVLOG_LEVEL_NOTICE = 0x3, - FW_DEVLOG_LEVEL_INFO = 0x4, - FW_DEVLOG_LEVEL_DEBUG = 0x5, - FW_DEVLOG_LEVEL_MAX = 0x5, -}; - -/* facilities that may send a log message */ -enum fw_devlog_facility { - FW_DEVLOG_FACILITY_CORE = 0x00, - FW_DEVLOG_FACILITY_CF = 0x01, - FW_DEVLOG_FACILITY_SCHED = 0x02, - FW_DEVLOG_FACILITY_TIMER = 0x04, - FW_DEVLOG_FACILITY_RES = 0x06, - FW_DEVLOG_FACILITY_HW = 0x08, - FW_DEVLOG_FACILITY_FLR = 0x10, - FW_DEVLOG_FACILITY_DMAQ = 0x12, - FW_DEVLOG_FACILITY_PHY = 0x14, - FW_DEVLOG_FACILITY_MAC = 0x16, - FW_DEVLOG_FACILITY_PORT = 0x18, - FW_DEVLOG_FACILITY_VI = 0x1A, - FW_DEVLOG_FACILITY_FILTER = 0x1C, - FW_DEVLOG_FACILITY_ACL = 0x1E, - FW_DEVLOG_FACILITY_TM = 0x20, - FW_DEVLOG_FACILITY_QFC = 0x22, - FW_DEVLOG_FACILITY_DCB = 0x24, - FW_DEVLOG_FACILITY_ETH = 0x26, - FW_DEVLOG_FACILITY_OFLD = 0x28, - FW_DEVLOG_FACILITY_RI = 0x2A, - FW_DEVLOG_FACILITY_ISCSI = 0x2C, - FW_DEVLOG_FACILITY_FCOE = 0x2E, - FW_DEVLOG_FACILITY_FOISCSI = 0x30, - FW_DEVLOG_FACILITY_FOFCOE = 0x32, - FW_DEVLOG_FACILITY_CHNET = 0x34, - FW_DEVLOG_FACILITY_MAX = 0x34, -}; - -/* log message format */ -struct fw_devlog_e { - __be64 timestamp; - __be32 seqno; - __be16 reserved1; - __u8 level; - __u8 facility; - __u8 fmt[FW_DEVLOG_FMT_LEN]; - __be32 params[FW_DEVLOG_FMT_PARAMS_NUM]; - __be32 reserved3[4]; -}; - -struct fw_devlog_cmd { - __be32 op_to_write; - __be32 retval_len16; - __u8 level; - __u8 r2[7]; - __be32 memtype_devlog_memaddr16_devlog; - __be32 memsize_devlog; - __be32 r3[2]; -}; - -#define FW_DEVLOG_CMD_MEMTYPE_DEVLOG_S 28 -#define FW_DEVLOG_CMD_MEMTYPE_DEVLOG_M 0xf -#define FW_DEVLOG_CMD_MEMTYPE_DEVLOG_G(x) \ - (((x) >> FW_DEVLOG_CMD_MEMTYPE_DEVLOG_S) & \ - FW_DEVLOG_CMD_MEMTYPE_DEVLOG_M) - -#define FW_DEVLOG_CMD_MEMADDR16_DEVLOG_S 0 -#define FW_DEVLOG_CMD_MEMADDR16_DEVLOG_M 0xfffffff -#define FW_DEVLOG_CMD_MEMADDR16_DEVLOG_G(x) \ - (((x) >> FW_DEVLOG_CMD_MEMADDR16_DEVLOG_S) & \ - FW_DEVLOG_CMD_MEMADDR16_DEVLOG_M) - -/* P C I E F W P F 7 R E G I S T E R */ - -/* PF7 stores the Firmware Device Log parameters which allows Host Drivers to - * access the "devlog" which needing to contact firmware. The encoding is - * mostly the same as that returned by the DEVLOG command except for the size - * which is encoded as the number of entries in multiples-1 of 128 here rather - * than the memory size as is done in the DEVLOG command. Thus, 0 means 128 - * and 15 means 2048. This of course in turn constrains the allowed values - * for the devlog size ... - */ -#define PCIE_FW_PF_DEVLOG 7 - -#define PCIE_FW_PF_DEVLOG_NENTRIES128_S 28 -#define PCIE_FW_PF_DEVLOG_NENTRIES128_M 0xf -#define PCIE_FW_PF_DEVLOG_NENTRIES128_V(x) \ - ((x) << PCIE_FW_PF_DEVLOG_NENTRIES128_S) -#define PCIE_FW_PF_DEVLOG_NENTRIES128_G(x) \ - (((x) >> PCIE_FW_PF_DEVLOG_NENTRIES128_S) & \ - PCIE_FW_PF_DEVLOG_NENTRIES128_M) - -#define PCIE_FW_PF_DEVLOG_ADDR16_S 4 -#define PCIE_FW_PF_DEVLOG_ADDR16_M 0xffffff -#define PCIE_FW_PF_DEVLOG_ADDR16_V(x) ((x) << PCIE_FW_PF_DEVLOG_ADDR16_S) -#define PCIE_FW_PF_DEVLOG_ADDR16_G(x) \ - (((x) >> PCIE_FW_PF_DEVLOG_ADDR16_S) & PCIE_FW_PF_DEVLOG_ADDR16_M) - -#define PCIE_FW_PF_DEVLOG_MEMTYPE_S 0 -#define PCIE_FW_PF_DEVLOG_MEMTYPE_M 0xf -#define PCIE_FW_PF_DEVLOG_MEMTYPE_V(x) ((x) << PCIE_FW_PF_DEVLOG_MEMTYPE_S) -#define PCIE_FW_PF_DEVLOG_MEMTYPE_G(x) \ - (((x) >> PCIE_FW_PF_DEVLOG_MEMTYPE_S) & PCIE_FW_PF_DEVLOG_MEMTYPE_M) - -#endif /* _T4FW_INTERFACE_H_ */ diff --git a/usr/rdma-core/providers/cxgb4/t4fw_ri_api.h b/usr/rdma-core/providers/cxgb4/t4fw_ri_api.h deleted file mode 100644 index 1e2666979..000000000 --- a/usr/rdma-core/providers/cxgb4/t4fw_ri_api.h +++ /dev/null @@ -1,756 +0,0 @@ -/* - * Copyright (c) 2009-2010 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef _T4FW_RI_API_H_ -#define _T4FW_RI_API_H_ - -#include "t4fw_api.h" - -enum fw_ri_wr_opcode { - FW_RI_RDMA_WRITE = 0x0, /* IETF RDMAP v1.0 ... */ - FW_RI_READ_REQ = 0x1, - FW_RI_READ_RESP = 0x2, - FW_RI_SEND = 0x3, - FW_RI_SEND_WITH_INV = 0x4, - FW_RI_SEND_WITH_SE = 0x5, - FW_RI_SEND_WITH_SE_INV = 0x6, - FW_RI_TERMINATE = 0x7, - FW_RI_RDMA_INIT = 0x8, /* CHELSIO RI specific ... */ - FW_RI_BIND_MW = 0x9, - FW_RI_FAST_REGISTER = 0xa, - FW_RI_LOCAL_INV = 0xb, - FW_RI_QP_MODIFY = 0xc, - FW_RI_BYPASS = 0xd, - FW_RI_RECEIVE = 0xe, - - FW_RI_SGE_EC_CR_RETURN = 0xf -}; - -enum fw_ri_wr_flags { - FW_RI_COMPLETION_FLAG = 0x01, - FW_RI_NOTIFICATION_FLAG = 0x02, - FW_RI_SOLICITED_EVENT_FLAG = 0x04, - FW_RI_READ_FENCE_FLAG = 0x08, - FW_RI_LOCAL_FENCE_FLAG = 0x10, - FW_RI_RDMA_READ_INVALIDATE = 0x20 -}; - -enum fw_ri_mpa_attrs { - FW_RI_MPA_RX_MARKER_ENABLE = 0x01, - FW_RI_MPA_TX_MARKER_ENABLE = 0x02, - FW_RI_MPA_CRC_ENABLE = 0x04, - FW_RI_MPA_IETF_ENABLE = 0x08 -}; - -enum fw_ri_qp_caps { - FW_RI_QP_RDMA_READ_ENABLE = 0x01, - FW_RI_QP_RDMA_WRITE_ENABLE = 0x02, - FW_RI_QP_BIND_ENABLE = 0x04, - FW_RI_QP_FAST_REGISTER_ENABLE = 0x08, - FW_RI_QP_STAG0_ENABLE = 0x10 -}; - -enum fw_ri_addr_type { - FW_RI_ZERO_BASED_TO = 0x00, - FW_RI_VA_BASED_TO = 0x01 -}; - -enum fw_ri_mem_perms { - FW_RI_MEM_ACCESS_REM_WRITE = 0x01, - FW_RI_MEM_ACCESS_REM_READ = 0x02, - FW_RI_MEM_ACCESS_REM = 0x03, - FW_RI_MEM_ACCESS_LOCAL_WRITE = 0x04, - FW_RI_MEM_ACCESS_LOCAL_READ = 0x08, - FW_RI_MEM_ACCESS_LOCAL = 0x0C -}; - -enum fw_ri_stag_type { - FW_RI_STAG_NSMR = 0x00, - FW_RI_STAG_SMR = 0x01, - FW_RI_STAG_MW = 0x02, - FW_RI_STAG_MW_RELAXED = 0x03 -}; - -enum fw_ri_data_op { - FW_RI_DATA_IMMD = 0x81, - FW_RI_DATA_DSGL = 0x82, - FW_RI_DATA_ISGL = 0x83 -}; - -enum fw_ri_sgl_depth { - FW_RI_SGL_DEPTH_MAX_SQ = 16, - FW_RI_SGL_DEPTH_MAX_RQ = 4 -}; - -struct fw_ri_dsge_pair { - __be32 len[2]; - __be64 addr[2]; -}; - -struct fw_ri_dsgl { - __u8 op; - __u8 r1; - __be16 nsge; - __be32 len0; - __be64 addr0; -#ifndef C99_NOT_SUPPORTED - struct fw_ri_dsge_pair sge[0]; -#endif -}; - -struct fw_ri_sge { - __be32 stag; - __be32 len; - __be64 to; -}; - -struct fw_ri_isgl { - __u8 op; - __u8 r1; - __be16 nsge; - __be32 r2; -#ifndef C99_NOT_SUPPORTED - struct fw_ri_sge sge[0]; -#endif -}; - -struct fw_ri_immd { - __u8 op; - __u8 r1; - __be16 r2; - __be32 immdlen; -#ifndef C99_NOT_SUPPORTED - __u8 data[0]; -#endif -}; - -struct fw_ri_tpte { - __be32 valid_to_pdid; - __be32 locread_to_qpid; - __be32 nosnoop_pbladdr; - __be32 len_lo; - __be32 va_hi; - __be32 va_lo_fbo; - __be32 dca_mwbcnt_pstag; - __be32 len_hi; -}; - -#define FW_RI_TPTE_VALID_S 31 -#define FW_RI_TPTE_VALID_M 0x1 -#define FW_RI_TPTE_VALID_V(x) ((x) << FW_RI_TPTE_VALID_S) -#define FW_RI_TPTE_VALID_G(x) \ - (((x) >> FW_RI_TPTE_VALID_S) & FW_RI_TPTE_VALID_M) -#define FW_RI_TPTE_VALID_F FW_RI_TPTE_VALID_V(1U) - -#define FW_RI_TPTE_STAGKEY_S 23 -#define FW_RI_TPTE_STAGKEY_M 0xff -#define FW_RI_TPTE_STAGKEY_V(x) ((x) << FW_RI_TPTE_STAGKEY_S) -#define FW_RI_TPTE_STAGKEY_G(x) \ - (((x) >> FW_RI_TPTE_STAGKEY_S) & FW_RI_TPTE_STAGKEY_M) - -#define FW_RI_TPTE_STAGSTATE_S 22 -#define FW_RI_TPTE_STAGSTATE_M 0x1 -#define FW_RI_TPTE_STAGSTATE_V(x) ((x) << FW_RI_TPTE_STAGSTATE_S) -#define FW_RI_TPTE_STAGSTATE_G(x) \ - (((x) >> FW_RI_TPTE_STAGSTATE_S) & FW_RI_TPTE_STAGSTATE_M) -#define FW_RI_TPTE_STAGSTATE_F FW_RI_TPTE_STAGSTATE_V(1U) - -#define FW_RI_TPTE_STAGTYPE_S 20 -#define FW_RI_TPTE_STAGTYPE_M 0x3 -#define FW_RI_TPTE_STAGTYPE_V(x) ((x) << FW_RI_TPTE_STAGTYPE_S) -#define FW_RI_TPTE_STAGTYPE_G(x) \ - (((x) >> FW_RI_TPTE_STAGTYPE_S) & FW_RI_TPTE_STAGTYPE_M) - -#define FW_RI_TPTE_PDID_S 0 -#define FW_RI_TPTE_PDID_M 0xfffff -#define FW_RI_TPTE_PDID_V(x) ((x) << FW_RI_TPTE_PDID_S) -#define FW_RI_TPTE_PDID_G(x) \ - (((x) >> FW_RI_TPTE_PDID_S) & FW_RI_TPTE_PDID_M) - -#define FW_RI_TPTE_PERM_S 28 -#define FW_RI_TPTE_PERM_M 0xf -#define FW_RI_TPTE_PERM_V(x) ((x) << FW_RI_TPTE_PERM_S) -#define FW_RI_TPTE_PERM_G(x) \ - (((x) >> FW_RI_TPTE_PERM_S) & FW_RI_TPTE_PERM_M) - -#define FW_RI_TPTE_REMINVDIS_S 27 -#define FW_RI_TPTE_REMINVDIS_M 0x1 -#define FW_RI_TPTE_REMINVDIS_V(x) ((x) << FW_RI_TPTE_REMINVDIS_S) -#define FW_RI_TPTE_REMINVDIS_G(x) \ - (((x) >> FW_RI_TPTE_REMINVDIS_S) & FW_RI_TPTE_REMINVDIS_M) -#define FW_RI_TPTE_REMINVDIS_F FW_RI_TPTE_REMINVDIS_V(1U) - -#define FW_RI_TPTE_ADDRTYPE_S 26 -#define FW_RI_TPTE_ADDRTYPE_M 1 -#define FW_RI_TPTE_ADDRTYPE_V(x) ((x) << FW_RI_TPTE_ADDRTYPE_S) -#define FW_RI_TPTE_ADDRTYPE_G(x) \ - (((x) >> FW_RI_TPTE_ADDRTYPE_S) & FW_RI_TPTE_ADDRTYPE_M) -#define FW_RI_TPTE_ADDRTYPE_F FW_RI_TPTE_ADDRTYPE_V(1U) - -#define FW_RI_TPTE_MWBINDEN_S 25 -#define FW_RI_TPTE_MWBINDEN_M 0x1 -#define FW_RI_TPTE_MWBINDEN_V(x) ((x) << FW_RI_TPTE_MWBINDEN_S) -#define FW_RI_TPTE_MWBINDEN_G(x) \ - (((x) >> FW_RI_TPTE_MWBINDEN_S) & FW_RI_TPTE_MWBINDEN_M) -#define FW_RI_TPTE_MWBINDEN_F FW_RI_TPTE_MWBINDEN_V(1U) - -#define FW_RI_TPTE_PS_S 20 -#define FW_RI_TPTE_PS_M 0x1f -#define FW_RI_TPTE_PS_V(x) ((x) << FW_RI_TPTE_PS_S) -#define FW_RI_TPTE_PS_G(x) \ - (((x) >> FW_RI_TPTE_PS_S) & FW_RI_TPTE_PS_M) - -#define FW_RI_TPTE_QPID_S 0 -#define FW_RI_TPTE_QPID_M 0xfffff -#define FW_RI_TPTE_QPID_V(x) ((x) << FW_RI_TPTE_QPID_S) -#define FW_RI_TPTE_QPID_G(x) \ - (((x) >> FW_RI_TPTE_QPID_S) & FW_RI_TPTE_QPID_M) - -#define FW_RI_TPTE_NOSNOOP_S 30 -#define FW_RI_TPTE_NOSNOOP_M 0x1 -#define FW_RI_TPTE_NOSNOOP_V(x) ((x) << FW_RI_TPTE_NOSNOOP_S) -#define FW_RI_TPTE_NOSNOOP_G(x) \ - (((x) >> FW_RI_TPTE_NOSNOOP_S) & FW_RI_TPTE_NOSNOOP_M) -#define FW_RI_TPTE_NOSNOOP_F FW_RI_TPTE_NOSNOOP_V(1U) - -#define FW_RI_TPTE_PBLADDR_S 0 -#define FW_RI_TPTE_PBLADDR_M 0x1fffffff -#define FW_RI_TPTE_PBLADDR_V(x) ((x) << FW_RI_TPTE_PBLADDR_S) -#define FW_RI_TPTE_PBLADDR_G(x) \ - (((x) >> FW_RI_TPTE_PBLADDR_S) & FW_RI_TPTE_PBLADDR_M) - -#define FW_RI_TPTE_DCA_S 24 -#define FW_RI_TPTE_DCA_M 0x1f -#define FW_RI_TPTE_DCA_V(x) ((x) << FW_RI_TPTE_DCA_S) -#define FW_RI_TPTE_DCA_G(x) \ - (((x) >> FW_RI_TPTE_DCA_S) & FW_RI_TPTE_DCA_M) - -#define FW_RI_TPTE_MWBCNT_PSTAG_S 0 -#define FW_RI_TPTE_MWBCNT_PSTAG_M 0xffffff -#define FW_RI_TPTE_MWBCNT_PSTAT_V(x) \ - ((x) << FW_RI_TPTE_MWBCNT_PSTAG_S) -#define FW_RI_TPTE_MWBCNT_PSTAG_G(x) \ - (((x) >> FW_RI_TPTE_MWBCNT_PSTAG_S) & FW_RI_TPTE_MWBCNT_PSTAG_M) - -enum fw_ri_res_type { - FW_RI_RES_TYPE_SQ, - FW_RI_RES_TYPE_RQ, - FW_RI_RES_TYPE_CQ, -}; - -enum fw_ri_res_op { - FW_RI_RES_OP_WRITE, - FW_RI_RES_OP_RESET, -}; - -struct fw_ri_res { - union fw_ri_restype { - struct fw_ri_res_sqrq { - __u8 restype; - __u8 op; - __be16 r3; - __be32 eqid; - __be32 r4[2]; - __be32 fetchszm_to_iqid; - __be32 dcaen_to_eqsize; - __be64 eqaddr; - } sqrq; - struct fw_ri_res_cq { - __u8 restype; - __u8 op; - __be16 r3; - __be32 iqid; - __be32 r4[2]; - __be32 iqandst_to_iqandstindex; - __be16 iqdroprss_to_iqesize; - __be16 iqsize; - __be64 iqaddr; - __be32 iqns_iqro; - __be32 r6_lo; - __be64 r7; - } cq; - } u; -}; - -struct fw_ri_res_wr { - __be32 op_nres; - __be32 len16_pkd; - __u64 cookie; -#ifndef C99_NOT_SUPPORTED - struct fw_ri_res res[0]; -#endif -}; - -#define FW_RI_RES_WR_NRES_S 0 -#define FW_RI_RES_WR_NRES_M 0xff -#define FW_RI_RES_WR_NRES_V(x) ((x) << FW_RI_RES_WR_NRES_S) -#define FW_RI_RES_WR_NRES_G(x) \ - (((x) >> FW_RI_RES_WR_NRES_S) & FW_RI_RES_WR_NRES_M) - -#define FW_RI_RES_WR_FETCHSZM_S 26 -#define FW_RI_RES_WR_FETCHSZM_M 0x1 -#define FW_RI_RES_WR_FETCHSZM_V(x) ((x) << FW_RI_RES_WR_FETCHSZM_S) -#define FW_RI_RES_WR_FETCHSZM_G(x) \ - (((x) >> FW_RI_RES_WR_FETCHSZM_S) & FW_RI_RES_WR_FETCHSZM_M) -#define FW_RI_RES_WR_FETCHSZM_F FW_RI_RES_WR_FETCHSZM_V(1U) - -#define FW_RI_RES_WR_STATUSPGNS_S 25 -#define FW_RI_RES_WR_STATUSPGNS_M 0x1 -#define FW_RI_RES_WR_STATUSPGNS_V(x) ((x) << FW_RI_RES_WR_STATUSPGNS_S) -#define FW_RI_RES_WR_STATUSPGNS_G(x) \ - (((x) >> FW_RI_RES_WR_STATUSPGNS_S) & FW_RI_RES_WR_STATUSPGNS_M) -#define FW_RI_RES_WR_STATUSPGNS_F FW_RI_RES_WR_STATUSPGNS_V(1U) - -#define FW_RI_RES_WR_STATUSPGRO_S 24 -#define FW_RI_RES_WR_STATUSPGRO_M 0x1 -#define FW_RI_RES_WR_STATUSPGRO_V(x) ((x) << FW_RI_RES_WR_STATUSPGRO_S) -#define FW_RI_RES_WR_STATUSPGRO_G(x) \ - (((x) >> FW_RI_RES_WR_STATUSPGRO_S) & FW_RI_RES_WR_STATUSPGRO_M) -#define FW_RI_RES_WR_STATUSPGRO_F FW_RI_RES_WR_STATUSPGRO_V(1U) - -#define FW_RI_RES_WR_FETCHNS_S 23 -#define FW_RI_RES_WR_FETCHNS_M 0x1 -#define FW_RI_RES_WR_FETCHNS_V(x) ((x) << FW_RI_RES_WR_FETCHNS_S) -#define FW_RI_RES_WR_FETCHNS_G(x) \ - (((x) >> FW_RI_RES_WR_FETCHNS_S) & FW_RI_RES_WR_FETCHNS_M) -#define FW_RI_RES_WR_FETCHNS_F FW_RI_RES_WR_FETCHNS_V(1U) - -#define FW_RI_RES_WR_FETCHRO_S 22 -#define FW_RI_RES_WR_FETCHRO_M 0x1 -#define FW_RI_RES_WR_FETCHRO_V(x) ((x) << FW_RI_RES_WR_FETCHRO_S) -#define FW_RI_RES_WR_FETCHRO_G(x) \ - (((x) >> FW_RI_RES_WR_FETCHRO_S) & FW_RI_RES_WR_FETCHRO_M) -#define FW_RI_RES_WR_FETCHRO_F FW_RI_RES_WR_FETCHRO_V(1U) - -#define FW_RI_RES_WR_HOSTFCMODE_S 20 -#define FW_RI_RES_WR_HOSTFCMODE_M 0x3 -#define FW_RI_RES_WR_HOSTFCMODE_V(x) ((x) << FW_RI_RES_WR_HOSTFCMODE_S) -#define FW_RI_RES_WR_HOSTFCMODE_G(x) \ - (((x) >> FW_RI_RES_WR_HOSTFCMODE_S) & FW_RI_RES_WR_HOSTFCMODE_M) - -#define FW_RI_RES_WR_CPRIO_S 19 -#define FW_RI_RES_WR_CPRIO_M 0x1 -#define FW_RI_RES_WR_CPRIO_V(x) ((x) << FW_RI_RES_WR_CPRIO_S) -#define FW_RI_RES_WR_CPRIO_G(x) \ - (((x) >> FW_RI_RES_WR_CPRIO_S) & FW_RI_RES_WR_CPRIO_M) -#define FW_RI_RES_WR_CPRIO_F FW_RI_RES_WR_CPRIO_V(1U) - -#define FW_RI_RES_WR_ONCHIP_S 18 -#define FW_RI_RES_WR_ONCHIP_M 0x1 -#define FW_RI_RES_WR_ONCHIP_V(x) ((x) << FW_RI_RES_WR_ONCHIP_S) -#define FW_RI_RES_WR_ONCHIP_G(x) \ - (((x) >> FW_RI_RES_WR_ONCHIP_S) & FW_RI_RES_WR_ONCHIP_M) -#define FW_RI_RES_WR_ONCHIP_F FW_RI_RES_WR_ONCHIP_V(1U) - -#define FW_RI_RES_WR_PCIECHN_S 16 -#define FW_RI_RES_WR_PCIECHN_M 0x3 -#define FW_RI_RES_WR_PCIECHN_V(x) ((x) << FW_RI_RES_WR_PCIECHN_S) -#define FW_RI_RES_WR_PCIECHN_G(x) \ - (((x) >> FW_RI_RES_WR_PCIECHN_S) & FW_RI_RES_WR_PCIECHN_M) - -#define FW_RI_RES_WR_IQID_S 0 -#define FW_RI_RES_WR_IQID_M 0xffff -#define FW_RI_RES_WR_IQID_V(x) ((x) << FW_RI_RES_WR_IQID_S) -#define FW_RI_RES_WR_IQID_G(x) \ - (((x) >> FW_RI_RES_WR_IQID_S) & FW_RI_RES_WR_IQID_M) - -#define FW_RI_RES_WR_DCAEN_S 31 -#define FW_RI_RES_WR_DCAEN_M 0x1 -#define FW_RI_RES_WR_DCAEN_V(x) ((x) << FW_RI_RES_WR_DCAEN_S) -#define FW_RI_RES_WR_DCAEN_G(x) \ - (((x) >> FW_RI_RES_WR_DCAEN_S) & FW_RI_RES_WR_DCAEN_M) -#define FW_RI_RES_WR_DCAEN_F FW_RI_RES_WR_DCAEN_V(1U) - -#define FW_RI_RES_WR_DCACPU_S 26 -#define FW_RI_RES_WR_DCACPU_M 0x1f -#define FW_RI_RES_WR_DCACPU_V(x) ((x) << FW_RI_RES_WR_DCACPU_S) -#define FW_RI_RES_WR_DCACPU_G(x) \ - (((x) >> FW_RI_RES_WR_DCACPU_S) & FW_RI_RES_WR_DCACPU_M) - -#define FW_RI_RES_WR_FBMIN_S 23 -#define FW_RI_RES_WR_FBMIN_M 0x7 -#define FW_RI_RES_WR_FBMIN_V(x) ((x) << FW_RI_RES_WR_FBMIN_S) -#define FW_RI_RES_WR_FBMIN_G(x) \ - (((x) >> FW_RI_RES_WR_FBMIN_S) & FW_RI_RES_WR_FBMIN_M) - -#define FW_RI_RES_WR_FBMAX_S 20 -#define FW_RI_RES_WR_FBMAX_M 0x7 -#define FW_RI_RES_WR_FBMAX_V(x) ((x) << FW_RI_RES_WR_FBMAX_S) -#define FW_RI_RES_WR_FBMAX_G(x) \ - (((x) >> FW_RI_RES_WR_FBMAX_S) & FW_RI_RES_WR_FBMAX_M) - -#define FW_RI_RES_WR_CIDXFTHRESHO_S 19 -#define FW_RI_RES_WR_CIDXFTHRESHO_M 0x1 -#define FW_RI_RES_WR_CIDXFTHRESHO_V(x) ((x) << FW_RI_RES_WR_CIDXFTHRESHO_S) -#define FW_RI_RES_WR_CIDXFTHRESHO_G(x) \ - (((x) >> FW_RI_RES_WR_CIDXFTHRESHO_S) & FW_RI_RES_WR_CIDXFTHRESHO_M) -#define FW_RI_RES_WR_CIDXFTHRESHO_F FW_RI_RES_WR_CIDXFTHRESHO_V(1U) - -#define FW_RI_RES_WR_CIDXFTHRESH_S 16 -#define FW_RI_RES_WR_CIDXFTHRESH_M 0x7 -#define FW_RI_RES_WR_CIDXFTHRESH_V(x) ((x) << FW_RI_RES_WR_CIDXFTHRESH_S) -#define FW_RI_RES_WR_CIDXFTHRESH_G(x) \ - (((x) >> FW_RI_RES_WR_CIDXFTHRESH_S) & FW_RI_RES_WR_CIDXFTHRESH_M) - -#define FW_RI_RES_WR_EQSIZE_S 0 -#define FW_RI_RES_WR_EQSIZE_M 0xffff -#define FW_RI_RES_WR_EQSIZE_V(x) ((x) << FW_RI_RES_WR_EQSIZE_S) -#define FW_RI_RES_WR_EQSIZE_G(x) \ - (((x) >> FW_RI_RES_WR_EQSIZE_S) & FW_RI_RES_WR_EQSIZE_M) - -#define FW_RI_RES_WR_IQANDST_S 15 -#define FW_RI_RES_WR_IQANDST_M 0x1 -#define FW_RI_RES_WR_IQANDST_V(x) ((x) << FW_RI_RES_WR_IQANDST_S) -#define FW_RI_RES_WR_IQANDST_G(x) \ - (((x) >> FW_RI_RES_WR_IQANDST_S) & FW_RI_RES_WR_IQANDST_M) -#define FW_RI_RES_WR_IQANDST_F FW_RI_RES_WR_IQANDST_V(1U) - -#define FW_RI_RES_WR_IQANUS_S 14 -#define FW_RI_RES_WR_IQANUS_M 0x1 -#define FW_RI_RES_WR_IQANUS_V(x) ((x) << FW_RI_RES_WR_IQANUS_S) -#define FW_RI_RES_WR_IQANUS_G(x) \ - (((x) >> FW_RI_RES_WR_IQANUS_S) & FW_RI_RES_WR_IQANUS_M) -#define FW_RI_RES_WR_IQANUS_F FW_RI_RES_WR_IQANUS_V(1U) - -#define FW_RI_RES_WR_IQANUD_S 12 -#define FW_RI_RES_WR_IQANUD_M 0x3 -#define FW_RI_RES_WR_IQANUD_V(x) ((x) << FW_RI_RES_WR_IQANUD_S) -#define FW_RI_RES_WR_IQANUD_G(x) \ - (((x) >> FW_RI_RES_WR_IQANUD_S) & FW_RI_RES_WR_IQANUD_M) - -#define FW_RI_RES_WR_IQANDSTINDEX_S 0 -#define FW_RI_RES_WR_IQANDSTINDEX_M 0xfff -#define FW_RI_RES_WR_IQANDSTINDEX_V(x) ((x) << FW_RI_RES_WR_IQANDSTINDEX_S) -#define FW_RI_RES_WR_IQANDSTINDEX_G(x) \ - (((x) >> FW_RI_RES_WR_IQANDSTINDEX_S) & FW_RI_RES_WR_IQANDSTINDEX_M) - -#define FW_RI_RES_WR_IQDROPRSS_S 15 -#define FW_RI_RES_WR_IQDROPRSS_M 0x1 -#define FW_RI_RES_WR_IQDROPRSS_V(x) ((x) << FW_RI_RES_WR_IQDROPRSS_S) -#define FW_RI_RES_WR_IQDROPRSS_G(x) \ - (((x) >> FW_RI_RES_WR_IQDROPRSS_S) & FW_RI_RES_WR_IQDROPRSS_M) -#define FW_RI_RES_WR_IQDROPRSS_F FW_RI_RES_WR_IQDROPRSS_V(1U) - -#define FW_RI_RES_WR_IQGTSMODE_S 14 -#define FW_RI_RES_WR_IQGTSMODE_M 0x1 -#define FW_RI_RES_WR_IQGTSMODE_V(x) ((x) << FW_RI_RES_WR_IQGTSMODE_S) -#define FW_RI_RES_WR_IQGTSMODE_G(x) \ - (((x) >> FW_RI_RES_WR_IQGTSMODE_S) & FW_RI_RES_WR_IQGTSMODE_M) -#define FW_RI_RES_WR_IQGTSMODE_F FW_RI_RES_WR_IQGTSMODE_V(1U) - -#define FW_RI_RES_WR_IQPCIECH_S 12 -#define FW_RI_RES_WR_IQPCIECH_M 0x3 -#define FW_RI_RES_WR_IQPCIECH_V(x) ((x) << FW_RI_RES_WR_IQPCIECH_S) -#define FW_RI_RES_WR_IQPCIECH_G(x) \ - (((x) >> FW_RI_RES_WR_IQPCIECH_S) & FW_RI_RES_WR_IQPCIECH_M) - -#define FW_RI_RES_WR_IQDCAEN_S 11 -#define FW_RI_RES_WR_IQDCAEN_M 0x1 -#define FW_RI_RES_WR_IQDCAEN_V(x) ((x) << FW_RI_RES_WR_IQDCAEN_S) -#define FW_RI_RES_WR_IQDCAEN_G(x) \ - (((x) >> FW_RI_RES_WR_IQDCAEN_S) & FW_RI_RES_WR_IQDCAEN_M) -#define FW_RI_RES_WR_IQDCAEN_F FW_RI_RES_WR_IQDCAEN_V(1U) - -#define FW_RI_RES_WR_IQDCACPU_S 6 -#define FW_RI_RES_WR_IQDCACPU_M 0x1f -#define FW_RI_RES_WR_IQDCACPU_V(x) ((x) << FW_RI_RES_WR_IQDCACPU_S) -#define FW_RI_RES_WR_IQDCACPU_G(x) \ - (((x) >> FW_RI_RES_WR_IQDCACPU_S) & FW_RI_RES_WR_IQDCACPU_M) - -#define FW_RI_RES_WR_IQINTCNTTHRESH_S 4 -#define FW_RI_RES_WR_IQINTCNTTHRESH_M 0x3 -#define FW_RI_RES_WR_IQINTCNTTHRESH_V(x) \ - ((x) << FW_RI_RES_WR_IQINTCNTTHRESH_S) -#define FW_RI_RES_WR_IQINTCNTTHRESH_G(x) \ - (((x) >> FW_RI_RES_WR_IQINTCNTTHRESH_S) & FW_RI_RES_WR_IQINTCNTTHRESH_M) - -#define FW_RI_RES_WR_IQO_S 3 -#define FW_RI_RES_WR_IQO_M 0x1 -#define FW_RI_RES_WR_IQO_V(x) ((x) << FW_RI_RES_WR_IQO_S) -#define FW_RI_RES_WR_IQO_G(x) \ - (((x) >> FW_RI_RES_WR_IQO_S) & FW_RI_RES_WR_IQO_M) -#define FW_RI_RES_WR_IQO_F FW_RI_RES_WR_IQO_V(1U) - -#define FW_RI_RES_WR_IQCPRIO_S 2 -#define FW_RI_RES_WR_IQCPRIO_M 0x1 -#define FW_RI_RES_WR_IQCPRIO_V(x) ((x) << FW_RI_RES_WR_IQCPRIO_S) -#define FW_RI_RES_WR_IQCPRIO_G(x) \ - (((x) >> FW_RI_RES_WR_IQCPRIO_S) & FW_RI_RES_WR_IQCPRIO_M) -#define FW_RI_RES_WR_IQCPRIO_F FW_RI_RES_WR_IQCPRIO_V(1U) - -#define FW_RI_RES_WR_IQESIZE_S 0 -#define FW_RI_RES_WR_IQESIZE_M 0x3 -#define FW_RI_RES_WR_IQESIZE_V(x) ((x) << FW_RI_RES_WR_IQESIZE_S) -#define FW_RI_RES_WR_IQESIZE_G(x) \ - (((x) >> FW_RI_RES_WR_IQESIZE_S) & FW_RI_RES_WR_IQESIZE_M) - -#define FW_RI_RES_WR_IQNS_S 31 -#define FW_RI_RES_WR_IQNS_M 0x1 -#define FW_RI_RES_WR_IQNS_V(x) ((x) << FW_RI_RES_WR_IQNS_S) -#define FW_RI_RES_WR_IQNS_G(x) \ - (((x) >> FW_RI_RES_WR_IQNS_S) & FW_RI_RES_WR_IQNS_M) -#define FW_RI_RES_WR_IQNS_F FW_RI_RES_WR_IQNS_V(1U) - -#define FW_RI_RES_WR_IQRO_S 30 -#define FW_RI_RES_WR_IQRO_M 0x1 -#define FW_RI_RES_WR_IQRO_V(x) ((x) << FW_RI_RES_WR_IQRO_S) -#define FW_RI_RES_WR_IQRO_G(x) \ - (((x) >> FW_RI_RES_WR_IQRO_S) & FW_RI_RES_WR_IQRO_M) -#define FW_RI_RES_WR_IQRO_F FW_RI_RES_WR_IQRO_V(1U) - -struct fw_ri_rdma_write_wr { - __u8 opcode; - __u8 flags; - __u16 wrid; - __u8 r1[3]; - __u8 len16; - __be64 r2; - __be32 plen; - __be32 stag_sink; - __be64 to_sink; -#ifndef C99_NOT_SUPPORTED - union { - struct fw_ri_immd immd_src[0]; - struct fw_ri_isgl isgl_src[0]; - } u; -#endif -}; - -struct fw_ri_send_wr { - __u8 opcode; - __u8 flags; - __u16 wrid; - __u8 r1[3]; - __u8 len16; - __be32 sendop_pkd; - __be32 stag_inv; - __be32 plen; - __be32 r3; - __be64 r4; -#ifndef C99_NOT_SUPPORTED - union { - struct fw_ri_immd immd_src[0]; - struct fw_ri_isgl isgl_src[0]; - } u; -#endif -}; - -#define FW_RI_SEND_WR_SENDOP_S 0 -#define FW_RI_SEND_WR_SENDOP_M 0xf -#define FW_RI_SEND_WR_SENDOP_V(x) ((x) << FW_RI_SEND_WR_SENDOP_S) -#define FW_RI_SEND_WR_SENDOP_G(x) \ - (((x) >> FW_RI_SEND_WR_SENDOP_S) & FW_RI_SEND_WR_SENDOP_M) - -struct fw_ri_rdma_read_wr { - __u8 opcode; - __u8 flags; - __u16 wrid; - __u8 r1[3]; - __u8 len16; - __be64 r2; - __be32 stag_sink; - __be32 to_sink_hi; - __be32 to_sink_lo; - __be32 plen; - __be32 stag_src; - __be32 to_src_hi; - __be32 to_src_lo; - __be32 r5; -}; - -struct fw_ri_recv_wr { - __u8 opcode; - __u8 r1; - __u16 wrid; - __u8 r2[3]; - __u8 len16; - struct fw_ri_isgl isgl; -}; - -struct fw_ri_bind_mw_wr { - __u8 opcode; - __u8 flags; - __u16 wrid; - __u8 r1[3]; - __u8 len16; - __u8 qpbinde_to_dcacpu; - __u8 pgsz_shift; - __u8 addr_type; - __u8 mem_perms; - __be32 stag_mr; - __be32 stag_mw; - __be32 r3; - __be64 len_mw; - __be64 va_fbo; - __be64 r4; -}; - -#define FW_RI_BIND_MW_WR_QPBINDE_S 6 -#define FW_RI_BIND_MW_WR_QPBINDE_M 0x1 -#define FW_RI_BIND_MW_WR_QPBINDE_V(x) ((x) << FW_RI_BIND_MW_WR_QPBINDE_S) -#define FW_RI_BIND_MW_WR_QPBINDE_G(x) \ - (((x) >> FW_RI_BIND_MW_WR_QPBINDE_S) & FW_RI_BIND_MW_WR_QPBINDE_M) -#define FW_RI_BIND_MW_WR_QPBINDE_F FW_RI_BIND_MW_WR_QPBINDE_V(1U) - -#define FW_RI_BIND_MW_WR_NS_S 5 -#define FW_RI_BIND_MW_WR_NS_M 0x1 -#define FW_RI_BIND_MW_WR_NS_V(x) ((x) << FW_RI_BIND_MW_WR_NS_S) -#define FW_RI_BIND_MW_WR_NS_G(x) \ - (((x) >> FW_RI_BIND_MW_WR_NS_S) & FW_RI_BIND_MW_WR_NS_M) -#define FW_RI_BIND_MW_WR_NS_F FW_RI_BIND_MW_WR_NS_V(1U) - -#define FW_RI_BIND_MW_WR_DCACPU_S 0 -#define FW_RI_BIND_MW_WR_DCACPU_M 0x1f -#define FW_RI_BIND_MW_WR_DCACPU_V(x) ((x) << FW_RI_BIND_MW_WR_DCACPU_S) -#define FW_RI_BIND_MW_WR_DCACPU_G(x) \ - (((x) >> FW_RI_BIND_MW_WR_DCACPU_S) & FW_RI_BIND_MW_WR_DCACPU_M) - -struct fw_ri_fr_nsmr_wr { - __u8 opcode; - __u8 flags; - __u16 wrid; - __u8 r1[3]; - __u8 len16; - __u8 qpbinde_to_dcacpu; - __u8 pgsz_shift; - __u8 addr_type; - __u8 mem_perms; - __be32 stag; - __be32 len_hi; - __be32 len_lo; - __be32 va_hi; - __be32 va_lo_fbo; -}; - -#define FW_RI_FR_NSMR_WR_QPBINDE_S 6 -#define FW_RI_FR_NSMR_WR_QPBINDE_M 0x1 -#define FW_RI_FR_NSMR_WR_QPBINDE_V(x) ((x) << FW_RI_FR_NSMR_WR_QPBINDE_S) -#define FW_RI_FR_NSMR_WR_QPBINDE_G(x) \ - (((x) >> FW_RI_FR_NSMR_WR_QPBINDE_S) & FW_RI_FR_NSMR_WR_QPBINDE_M) -#define FW_RI_FR_NSMR_WR_QPBINDE_F FW_RI_FR_NSMR_WR_QPBINDE_V(1U) - -#define FW_RI_FR_NSMR_WR_NS_S 5 -#define FW_RI_FR_NSMR_WR_NS_M 0x1 -#define FW_RI_FR_NSMR_WR_NS_V(x) ((x) << FW_RI_FR_NSMR_WR_NS_S) -#define FW_RI_FR_NSMR_WR_NS_G(x) \ - (((x) >> FW_RI_FR_NSMR_WR_NS_S) & FW_RI_FR_NSMR_WR_NS_M) -#define FW_RI_FR_NSMR_WR_NS_F FW_RI_FR_NSMR_WR_NS_V(1U) - -#define FW_RI_FR_NSMR_WR_DCACPU_S 0 -#define FW_RI_FR_NSMR_WR_DCACPU_M 0x1f -#define FW_RI_FR_NSMR_WR_DCACPU_V(x) ((x) << FW_RI_FR_NSMR_WR_DCACPU_S) -#define FW_RI_FR_NSMR_WR_DCACPU_G(x) \ - (((x) >> FW_RI_FR_NSMR_WR_DCACPU_S) & FW_RI_FR_NSMR_WR_DCACPU_M) - -struct fw_ri_inv_lstag_wr { - __u8 opcode; - __u8 flags; - __u16 wrid; - __u8 r1[3]; - __u8 len16; - __be32 r2; - __be32 stag_inv; -}; - -enum fw_ri_type { - FW_RI_TYPE_INIT, - FW_RI_TYPE_FINI, - FW_RI_TYPE_TERMINATE -}; - -enum fw_ri_init_p2ptype { - FW_RI_INIT_P2PTYPE_RDMA_WRITE = FW_RI_RDMA_WRITE, - FW_RI_INIT_P2PTYPE_READ_REQ = FW_RI_READ_REQ, - FW_RI_INIT_P2PTYPE_SEND = FW_RI_SEND, - FW_RI_INIT_P2PTYPE_SEND_WITH_INV = FW_RI_SEND_WITH_INV, - FW_RI_INIT_P2PTYPE_SEND_WITH_SE = FW_RI_SEND_WITH_SE, - FW_RI_INIT_P2PTYPE_SEND_WITH_SE_INV = FW_RI_SEND_WITH_SE_INV, - FW_RI_INIT_P2PTYPE_DISABLED = 0xf, -}; - -struct fw_ri_wr { - __be32 op_compl; - __be32 flowid_len16; - __u64 cookie; - union fw_ri { - struct fw_ri_init { - __u8 type; - __u8 mpareqbit_p2ptype; - __u8 r4[2]; - __u8 mpa_attrs; - __u8 qp_caps; - __be16 nrqe; - __be32 pdid; - __be32 qpid; - __be32 sq_eqid; - __be32 rq_eqid; - __be32 scqid; - __be32 rcqid; - __be32 ord_max; - __be32 ird_max; - __be32 iss; - __be32 irs; - __be32 hwrqsize; - __be32 hwrqaddr; - __be64 r5; - union fw_ri_init_p2p { - struct fw_ri_rdma_write_wr write; - struct fw_ri_rdma_read_wr read; - struct fw_ri_send_wr send; - } u; - } init; - struct fw_ri_fini { - __u8 type; - __u8 r3[7]; - __be64 r4; - } fini; - struct fw_ri_terminate { - __u8 type; - __u8 r3[3]; - __be32 immdlen; - __u8 termmsg[40]; - } terminate; - } u; -}; - -#define FW_RI_WR_MPAREQBIT_S 7 -#define FW_RI_WR_MPAREQBIT_M 0x1 -#define FW_RI_WR_MPAREQBIT_V(x) ((x) << FW_RI_WR_MPAREQBIT_S) -#define FW_RI_WR_MPAREQBIT_G(x) \ - (((x) >> FW_RI_WR_MPAREQBIT_S) & FW_RI_WR_MPAREQBIT_M) -#define FW_RI_WR_MPAREQBIT_F FW_RI_WR_MPAREQBIT_V(1U) - -#define FW_RI_WR_P2PTYPE_S 0 -#define FW_RI_WR_P2PTYPE_M 0xf -#define FW_RI_WR_P2PTYPE_V(x) ((x) << FW_RI_WR_P2PTYPE_S) -#define FW_RI_WR_P2PTYPE_G(x) \ - (((x) >> FW_RI_WR_P2PTYPE_S) & FW_RI_WR_P2PTYPE_M) - -#endif /* _T4FW_RI_API_H_ */ diff --git a/usr/rdma-core/providers/cxgb4/verbs.c b/usr/rdma-core/providers/cxgb4/verbs.c deleted file mode 100644 index 251a337d2..000000000 --- a/usr/rdma-core/providers/cxgb4/verbs.c +++ /dev/null @@ -1,710 +0,0 @@ -/* - * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libcxgb4.h" -#include "cxgb4-abi.h" - -#define MASKED(x) (void *)((unsigned long)(x) & c4iw_page_mask) - -int c4iw_query_device(struct ibv_context *context, struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - u8 major, minor, sub_minor, build; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, - sizeof cmd); - if (ret) - return ret; - - major = (raw_fw_ver >> 24) & 0xff; - minor = (raw_fw_ver >> 16) & 0xff; - sub_minor = (raw_fw_ver >> 8) & 0xff; - build = raw_fw_ver & 0xff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%d.%d", major, minor, sub_minor, build); - - return 0; -} - -int c4iw_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); -} - -struct ibv_pd *c4iw_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct c4iw_alloc_pd_resp resp; - struct c4iw_pd *pd; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(pd); - return NULL; - } - - return &pd->ibv_pd; -} - -int c4iw_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - free(pd); - return 0; -} - -static struct ibv_mr *__c4iw_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, uint64_t hca_va, - int access) -{ - struct c4iw_mr *mhp; - struct ibv_reg_mr cmd; - struct ibv_reg_mr_resp resp; - struct c4iw_dev *dev = to_c4iw_dev(pd->context->device); - - mhp = malloc(sizeof *mhp); - if (!mhp) - return NULL; - - if (ibv_cmd_reg_mr(pd, addr, length, hca_va, - access, &mhp->ibv_mr, &cmd, sizeof cmd, - &resp, sizeof resp)) { - free(mhp); - return NULL; - } - - mhp->va_fbo = hca_va; - mhp->len = length; - - PDBG("%s stag 0x%x va_fbo 0x%" PRIx64 " len %d\n", - __func__, mhp->ibv_mr.rkey, mhp->va_fbo, mhp->len); - - pthread_spin_lock(&dev->lock); - dev->mmid2ptr[c4iw_mmid(mhp->ibv_mr.lkey)] = mhp; - pthread_spin_unlock(&dev->lock); - INC_STAT(mr); - return &mhp->ibv_mr; -} - -struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - PDBG("%s addr %p length %ld\n", __func__, addr, length); - return __c4iw_reg_mr(pd, addr, length, (uintptr_t) addr, access); -} - -int c4iw_dereg_mr(struct ibv_mr *mr) -{ - int ret; - struct c4iw_dev *dev = to_c4iw_dev(mr->pd->context->device); - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - pthread_spin_lock(&dev->lock); - dev->mmid2ptr[c4iw_mmid(mr->lkey)] = NULL; - pthread_spin_unlock(&dev->lock); - - free(to_c4iw_mr(mr)); - - return 0; -} - -struct ibv_cq *c4iw_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, int comp_vector) -{ - struct ibv_create_cq cmd; - struct c4iw_create_cq_resp resp; - struct c4iw_cq *chp; - struct c4iw_dev *dev = to_c4iw_dev(context->device); - int ret; - - chp = calloc(1, sizeof *chp); - if (!chp) { - return NULL; - } - - resp.reserved = 0; - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &chp->ibv_cq, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) - goto err1; - - if (resp.reserved) - PDBG("%s c4iw_create_cq_resp reserved field modified by kernel\n", - __FUNCTION__); - - pthread_spin_init(&chp->lock, PTHREAD_PROCESS_PRIVATE); -#ifdef STALL_DETECTION - gettimeofday(&chp->time, NULL); -#endif - chp->rhp = dev; - chp->cq.qid_mask = resp.qid_mask; - chp->cq.cqid = resp.cqid; - chp->cq.size = resp.size; - chp->cq.memsize = resp.memsize; - chp->cq.gen = 1; - chp->cq.queue = mmap(NULL, chp->cq.memsize, PROT_READ|PROT_WRITE, - MAP_SHARED, context->cmd_fd, resp.key); - if (chp->cq.queue == MAP_FAILED) - goto err2; - - chp->cq.ugts = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED, - context->cmd_fd, resp.gts_key); - if (chp->cq.ugts == MAP_FAILED) - goto err3; - - if (dev_is_t4(chp->rhp)) - chp->cq.ugts += 1; - else - chp->cq.ugts += 5; - chp->cq.sw_queue = calloc(chp->cq.size, sizeof *chp->cq.queue); - if (!chp->cq.sw_queue) - goto err4; - - PDBG("%s cqid 0x%x key %" PRIx64 " va %p memsize %lu gts_key %" - PRIx64 " va %p qid_mask 0x%x\n", - __func__, chp->cq.cqid, resp.key, chp->cq.queue, - chp->cq.memsize, resp.gts_key, chp->cq.ugts, chp->cq.qid_mask); - - pthread_spin_lock(&dev->lock); - dev->cqid2ptr[chp->cq.cqid] = chp; - pthread_spin_unlock(&dev->lock); - INC_STAT(cq); - return &chp->ibv_cq; -err4: - munmap(MASKED(chp->cq.ugts), c4iw_page_size); -err3: - munmap(chp->cq.queue, chp->cq.memsize); -err2: - (void)ibv_cmd_destroy_cq(&chp->ibv_cq); -err1: - free(chp); - return NULL; -} - -int c4iw_resize_cq(struct ibv_cq *ibcq, int cqe) -{ -#if 0 - int ret; - - struct ibv_resize_cq cmd; - struct ibv_resize_cq_resp resp; - ret = ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd, &resp, sizeof resp); - PDBG("%s ret %d\n", __func__, ret); - return ret; -#else - return -ENOSYS; -#endif -} - -int c4iw_destroy_cq(struct ibv_cq *ibcq) -{ - int ret; - struct c4iw_cq *chp = to_c4iw_cq(ibcq); - struct c4iw_dev *dev = to_c4iw_dev(ibcq->context->device); - - chp->cq.error = 1; - ret = ibv_cmd_destroy_cq(ibcq); - if (ret) { - return ret; - } - munmap(MASKED(chp->cq.ugts), c4iw_page_size); - munmap(chp->cq.queue, chp->cq.memsize); - - pthread_spin_lock(&dev->lock); - dev->cqid2ptr[chp->cq.cqid] = NULL; - pthread_spin_unlock(&dev->lock); - - free(chp->cq.sw_queue); - free(chp); - return 0; -} - -struct ibv_srq *c4iw_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - return NULL; -} - -int c4iw_modify_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr, - int attr_mask) -{ - return ENOSYS; -} - -int c4iw_destroy_srq(struct ibv_srq *srq) -{ - return ENOSYS; -} - -int c4iw_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - return ENOSYS; -} - -static struct ibv_qp *create_qp_v0(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - struct ibv_create_qp cmd; - struct c4iw_create_qp_resp_v0 resp; - struct c4iw_qp *qhp; - struct c4iw_dev *dev = to_c4iw_dev(pd->context->device); - int ret; - void *dbva; - - PDBG("%s enter qp\n", __func__); - qhp = calloc(1, sizeof *qhp); - if (!qhp) - goto err1; - - ret = ibv_cmd_create_qp(pd, &qhp->ibv_qp, attr, &cmd, - sizeof cmd, &resp.ibv_resp, sizeof resp); - if (ret) - goto err2; - - PDBG("%s sqid 0x%x sq key %" PRIx64 " sq db/gts key %" PRIx64 - " rqid 0x%x rq key %" PRIx64 " rq db/gts key %" PRIx64 - " qid_mask 0x%x\n", - __func__, - resp.sqid, resp.sq_key, resp.sq_db_gts_key, - resp.rqid, resp.rq_key, resp.rq_db_gts_key, resp.qid_mask); - - qhp->wq.qid_mask = resp.qid_mask; - qhp->rhp = dev; - qhp->wq.sq.qid = resp.sqid; - qhp->wq.sq.size = resp.sq_size; - qhp->wq.sq.memsize = resp.sq_memsize; - qhp->wq.sq.flags = 0; - qhp->wq.rq.msn = 1; - qhp->wq.rq.qid = resp.rqid; - qhp->wq.rq.size = resp.rq_size; - qhp->wq.rq.memsize = resp.rq_memsize; - pthread_spin_init(&qhp->lock, PTHREAD_PROCESS_PRIVATE); - - dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.sq_db_gts_key); - if (dbva == MAP_FAILED) - goto err3; - - qhp->wq.sq.udb = dbva; - qhp->wq.sq.queue = mmap(NULL, qhp->wq.sq.memsize, - PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.sq_key); - if (qhp->wq.sq.queue == MAP_FAILED) - goto err4; - - dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.rq_db_gts_key); - if (dbva == MAP_FAILED) - goto err5; - qhp->wq.rq.udb = dbva; - qhp->wq.rq.queue = mmap(NULL, qhp->wq.rq.memsize, - PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.rq_key); - if (qhp->wq.rq.queue == MAP_FAILED) - goto err6; - - qhp->wq.sq.sw_sq = calloc(qhp->wq.sq.size, sizeof (struct t4_swsqe)); - if (!qhp->wq.sq.sw_sq) - goto err7; - - qhp->wq.rq.sw_rq = calloc(qhp->wq.rq.size, sizeof (uint64_t)); - if (!qhp->wq.rq.sw_rq) - goto err8; - - PDBG("%s sq dbva %p sq qva %p sq depth %u sq memsize %lu " - " rq dbva %p rq qva %p rq depth %u rq memsize %lu\n", - __func__, - qhp->wq.sq.udb, qhp->wq.sq.queue, - qhp->wq.sq.size, qhp->wq.sq.memsize, - qhp->wq.rq.udb, qhp->wq.rq.queue, - qhp->wq.rq.size, qhp->wq.rq.memsize); - - qhp->sq_sig_all = attr->sq_sig_all; - - pthread_spin_lock(&dev->lock); - dev->qpid2ptr[qhp->wq.sq.qid] = qhp; - pthread_spin_unlock(&dev->lock); - INC_STAT(qp); - return &qhp->ibv_qp; -err8: - free(qhp->wq.sq.sw_sq); -err7: - munmap((void *)qhp->wq.rq.queue, qhp->wq.rq.memsize); -err6: - munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size); -err5: - munmap((void *)qhp->wq.sq.queue, qhp->wq.sq.memsize); -err4: - munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size); -err3: - (void)ibv_cmd_destroy_qp(&qhp->ibv_qp); -err2: - free(qhp); -err1: - return NULL; -} - -static struct ibv_qp *create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - struct ibv_create_qp cmd; - struct c4iw_create_qp_resp resp; - struct c4iw_qp *qhp; - struct c4iw_dev *dev = to_c4iw_dev(pd->context->device); - struct c4iw_context *ctx = to_c4iw_context(pd->context); - int ret; - void *dbva; - - PDBG("%s enter qp\n", __func__); - qhp = calloc(1, sizeof *qhp); - if (!qhp) - goto err1; - - ret = ibv_cmd_create_qp(pd, &qhp->ibv_qp, attr, &cmd, - sizeof cmd, &resp.ibv_resp, sizeof resp); - if (ret) - goto err2; - - PDBG("%s sqid 0x%x sq key %" PRIx64 " sq db/gts key %" PRIx64 - " rqid 0x%x rq key %" PRIx64 " rq db/gts key %" PRIx64 - " qid_mask 0x%x\n", - __func__, - resp.sqid, resp.sq_key, resp.sq_db_gts_key, - resp.rqid, resp.rq_key, resp.rq_db_gts_key, resp.qid_mask); - - qhp->wq.qid_mask = resp.qid_mask; - qhp->rhp = dev; - qhp->wq.sq.qid = resp.sqid; - qhp->wq.sq.size = resp.sq_size; - qhp->wq.sq.memsize = resp.sq_memsize; - qhp->wq.sq.flags = resp.flags & C4IW_QPF_ONCHIP ? T4_SQ_ONCHIP : 0; - qhp->wq.sq.flush_cidx = -1; - qhp->wq.rq.msn = 1; - qhp->wq.rq.qid = resp.rqid; - qhp->wq.rq.size = resp.rq_size; - qhp->wq.rq.memsize = resp.rq_memsize; - if (ma_wr && resp.sq_memsize < (resp.sq_size + 1) * - sizeof *qhp->wq.sq.queue + 16*sizeof(__be64) ) { - ma_wr = 0; - fprintf(stderr, "libcxgb4 warning - downlevel iw_cxgb4 driver. " - "MA workaround disabled.\n"); - } - pthread_spin_init(&qhp->lock, PTHREAD_PROCESS_PRIVATE); - - dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.sq_db_gts_key); - if (dbva == MAP_FAILED) - goto err3; - qhp->wq.sq.udb = dbva; - if (!dev_is_t4(qhp->rhp)) { - unsigned long segment_offset = 128 * (qhp->wq.sq.qid & - qhp->wq.qid_mask); - - if (segment_offset < c4iw_page_size) { - qhp->wq.sq.udb += segment_offset / 4; - qhp->wq.sq.wc_reg_available = 1; - } else - qhp->wq.sq.bar2_qid = qhp->wq.sq.qid & qhp->wq.qid_mask; - qhp->wq.sq.udb += 2; - } - - qhp->wq.sq.queue = mmap(NULL, qhp->wq.sq.memsize, - PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.sq_key); - if (qhp->wq.sq.queue == MAP_FAILED) - goto err4; - - dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.rq_db_gts_key); - if (dbva == MAP_FAILED) - goto err5; - qhp->wq.rq.udb = dbva; - if (!dev_is_t4(qhp->rhp)) { - unsigned long segment_offset = 128 * (qhp->wq.rq.qid & - qhp->wq.qid_mask); - - if (segment_offset < c4iw_page_size) { - qhp->wq.rq.udb += segment_offset / 4; - qhp->wq.rq.wc_reg_available = 1; - } else - qhp->wq.rq.bar2_qid = qhp->wq.rq.qid & qhp->wq.qid_mask; - qhp->wq.rq.udb += 2; - } - qhp->wq.rq.queue = mmap(NULL, qhp->wq.rq.memsize, - PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.rq_key); - if (qhp->wq.rq.queue == MAP_FAILED) - goto err6; - - qhp->wq.sq.sw_sq = calloc(qhp->wq.sq.size, sizeof (struct t4_swsqe)); - if (!qhp->wq.sq.sw_sq) - goto err7; - - qhp->wq.rq.sw_rq = calloc(qhp->wq.rq.size, sizeof (uint64_t)); - if (!qhp->wq.rq.sw_rq) - goto err8; - - if (t4_sq_onchip(&qhp->wq)) { - qhp->wq.sq.ma_sync = mmap(NULL, c4iw_page_size, PROT_WRITE, - MAP_SHARED, pd->context->cmd_fd, - resp.ma_sync_key); - if (qhp->wq.sq.ma_sync == MAP_FAILED) - goto err9; - qhp->wq.sq.ma_sync += (A_PCIE_MA_SYNC & (c4iw_page_size - 1)); - } - - if (ctx->status_page_size) { - qhp->wq.db_offp = &ctx->status_page->db_off; - } else { - qhp->wq.db_offp = - &qhp->wq.rq.queue[qhp->wq.rq.size].status.db_off; - } - - PDBG("%s sq dbva %p sq qva %p sq depth %u sq memsize %lu " - " rq dbva %p rq qva %p rq depth %u rq memsize %lu\n", - __func__, - qhp->wq.sq.udb, qhp->wq.sq.queue, - qhp->wq.sq.size, qhp->wq.sq.memsize, - qhp->wq.rq.udb, qhp->wq.rq.queue, - qhp->wq.rq.size, qhp->wq.rq.memsize); - - qhp->sq_sig_all = attr->sq_sig_all; - - pthread_spin_lock(&dev->lock); - dev->qpid2ptr[qhp->wq.sq.qid] = qhp; - pthread_spin_unlock(&dev->lock); - INC_STAT(qp); - return &qhp->ibv_qp; -err9: - free(qhp->wq.rq.sw_rq); -err8: - free(qhp->wq.sq.sw_sq); -err7: - munmap((void *)qhp->wq.rq.queue, qhp->wq.rq.memsize); -err6: - munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size); -err5: - munmap((void *)qhp->wq.sq.queue, qhp->wq.sq.memsize); -err4: - munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size); -err3: - (void)ibv_cmd_destroy_qp(&qhp->ibv_qp); -err2: - free(qhp); -err1: - return NULL; -} - -struct ibv_qp *c4iw_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - struct c4iw_dev *dev = to_c4iw_dev(pd->context->device); - - if (dev->abi_version == 0) - return create_qp_v0(pd, attr); - return create_qp(pd, attr); -} - -static void reset_qp(struct c4iw_qp *qhp) -{ - PDBG("%s enter qp %p\n", __func__, qhp); - qhp->wq.sq.cidx = 0; - qhp->wq.sq.wq_pidx = qhp->wq.sq.pidx = qhp->wq.sq.in_use = 0; - qhp->wq.rq.cidx = qhp->wq.rq.pidx = qhp->wq.rq.in_use = 0; - qhp->wq.sq.oldest_read = NULL; - memset(qhp->wq.sq.queue, 0, qhp->wq.sq.memsize); - if (t4_sq_onchip(&qhp->wq)) - mmio_flush_writes(); - memset(qhp->wq.rq.queue, 0, qhp->wq.rq.memsize); -} - -int c4iw_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - struct c4iw_qp *qhp = to_c4iw_qp(ibqp); - int ret; - - PDBG("%s enter qp %p new state %d\n", __func__, ibqp, attr_mask & IBV_QP_STATE ? attr->qp_state : -1); - pthread_spin_lock(&qhp->lock); - if (t4_wq_in_error(&qhp->wq)) - c4iw_flush_qp(qhp); - ret = ibv_cmd_modify_qp(ibqp, attr, attr_mask, &cmd, sizeof cmd); - if (!ret && (attr_mask & IBV_QP_STATE) && attr->qp_state == IBV_QPS_RESET) - reset_qp(qhp); - pthread_spin_unlock(&qhp->lock); - return ret; -} - -int c4iw_destroy_qp(struct ibv_qp *ibqp) -{ - int ret; - struct c4iw_qp *qhp = to_c4iw_qp(ibqp); - struct c4iw_dev *dev = to_c4iw_dev(ibqp->context->device); - - PDBG("%s enter qp %p\n", __func__, ibqp); - pthread_spin_lock(&qhp->lock); - c4iw_flush_qp(qhp); - pthread_spin_unlock(&qhp->lock); - - ret = ibv_cmd_destroy_qp(ibqp); - if (ret) { - return ret; - } - if (t4_sq_onchip(&qhp->wq)) { - qhp->wq.sq.ma_sync -= (A_PCIE_MA_SYNC & (c4iw_page_size - 1)); - munmap((void *)qhp->wq.sq.ma_sync, c4iw_page_size); - } - munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size); - munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size); - munmap(qhp->wq.sq.queue, qhp->wq.sq.memsize); - munmap(qhp->wq.rq.queue, qhp->wq.rq.memsize); - - pthread_spin_lock(&dev->lock); - dev->qpid2ptr[qhp->wq.sq.qid] = NULL; - pthread_spin_unlock(&dev->lock); - - free(qhp->wq.rq.sw_rq); - free(qhp->wq.sq.sw_sq); - free(qhp); - return 0; -} - -int c4iw_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - struct c4iw_qp *qhp = to_c4iw_qp(ibqp); - int ret; - - pthread_spin_lock(&qhp->lock); - if (t4_wq_in_error(&qhp->wq)) - c4iw_flush_qp(qhp); - ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof cmd); - pthread_spin_unlock(&qhp->lock); - return ret; -} - -struct ibv_ah *c4iw_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - return NULL; -} - -int c4iw_destroy_ah(struct ibv_ah *ah) -{ - return ENOSYS; -} - -int c4iw_attach_mcast(struct ibv_qp *ibqp, const union ibv_gid *gid, - uint16_t lid) -{ - struct c4iw_qp *qhp = to_c4iw_qp(ibqp); - int ret; - - pthread_spin_lock(&qhp->lock); - if (t4_wq_in_error(&qhp->wq)) - c4iw_flush_qp(qhp); - ret = ibv_cmd_attach_mcast(ibqp, gid, lid); - pthread_spin_unlock(&qhp->lock); - return ret; -} - -int c4iw_detach_mcast(struct ibv_qp *ibqp, const union ibv_gid *gid, - uint16_t lid) -{ - struct c4iw_qp *qhp = to_c4iw_qp(ibqp); - int ret; - - pthread_spin_lock(&qhp->lock); - if (t4_wq_in_error(&qhp->wq)) - c4iw_flush_qp(qhp); - ret = ibv_cmd_detach_mcast(ibqp, gid, lid); - pthread_spin_unlock(&qhp->lock); - return ret; -} - -void c4iw_async_event(struct ibv_async_event *event) -{ - PDBG("%s type %d obj %p\n", __func__, event->event_type, - event->element.cq); - - switch (event->event_type) { - case IBV_EVENT_CQ_ERR: - break; - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_PATH_MIG_ERR: { - struct c4iw_qp *qhp = to_c4iw_qp(event->element.qp); - pthread_spin_lock(&qhp->lock); - c4iw_flush_qp(qhp); - pthread_spin_unlock(&qhp->lock); - break; - } - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_QP_LAST_WQE_REACHED: - default: - break; - } -} diff --git a/usr/rdma-core/providers/hfi1verbs/CMakeLists.txt b/usr/rdma-core/providers/hfi1verbs/CMakeLists.txt deleted file mode 100644 index 702bb5e23..000000000 --- a/usr/rdma-core/providers/hfi1verbs/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -rdma_provider(hfi1verbs - hfiverbs.c - verbs.c - ) diff --git a/usr/rdma-core/providers/hfi1verbs/hfi-abi.h b/usr/rdma-core/providers/hfi1verbs/hfi-abi.h deleted file mode 100644 index 2df637d00..000000000 --- a/usr/rdma-core/providers/hfi1verbs/hfi-abi.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright(c) 2015 Intel Corporation. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - 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. - - Contact Information: - Intel Corporation - www.intel.com - - BSD LICENSE - - Copyright(c) 2015 Intel Corporation. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Copyright (C) 2006-2007 QLogic Corporation, All rights reserved. - -*/ - -#ifndef HFI1_ABI_H -#define HFI1_ABI_H - -#include - -struct hfi1_get_context_resp { - struct ibv_get_context_resp ibv_resp; - __u32 version; -}; - -struct hfi1_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u64 offset; -}; - -struct hfi1_resize_cq_resp { - struct ibv_resize_cq_resp ibv_resp; - __u64 offset; -}; - -struct hfi1_create_qp_resp { - struct ibv_create_qp_resp ibv_resp; - __u64 offset; -}; - -struct hfi1_create_srq_resp { - struct ibv_create_srq_resp ibv_resp; - __u64 offset; -}; - -struct hfi1_modify_srq_cmd { - struct ibv_modify_srq ibv_cmd; - __u64 offset_addr; -}; - -#endif /* HFI1_ABI_H */ diff --git a/usr/rdma-core/providers/hfi1verbs/hfiverbs.c b/usr/rdma-core/providers/hfi1verbs/hfiverbs.c deleted file mode 100644 index 7f8f5714d..000000000 --- a/usr/rdma-core/providers/hfi1verbs/hfiverbs.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright(c) 2015 Intel Corporation. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - 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. - - Contact Information: - Intel Corporation - www.intel.com - - BSD LICENSE - - Copyright(c) 2015 Intel Corporation. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Copyright (C) 2006-2007 QLogic Corporation, All rights reserved. - Copyright (c) 2005. PathScale, Inc. All rights reserved. - -*/ - -#include - -#include -#include -#include -#include - -#include "hfiverbs.h" -#include "hfi-abi.h" - -#ifndef PCI_VENDOR_ID_INTEL -#define PCI_VENDOR_ID_INTEL 0x8086 -#endif - -#ifndef PCI_DEVICE_ID_INTEL0 -#define PCI_DEVICE_ID_HFI_INTEL0 0x24f0 -#endif - -#ifndef PCI_DEVICE_ID_INTEL1 -#define PCI_DEVICE_ID_HFI_INTEL1 0x24f1 -#endif - -#define HFI(v, d) \ - VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, PCI_DEVICE_ID_HFI_##d, NULL) -static const struct verbs_match_ent hca_table[] = { - HFI(INTEL, INTEL0), - HFI(INTEL, INTEL1), - {} -}; - -static struct ibv_context_ops hfi1_ctx_ops = { - .query_device = hfi1_query_device, - .query_port = hfi1_query_port, - - .alloc_pd = hfi1_alloc_pd, - .dealloc_pd = hfi1_free_pd, - - .reg_mr = hfi1_reg_mr, - .dereg_mr = hfi1_dereg_mr, - - .create_cq = hfi1_create_cq, - .poll_cq = hfi1_poll_cq, - .req_notify_cq = ibv_cmd_req_notify_cq, - .cq_event = NULL, - .resize_cq = hfi1_resize_cq, - .destroy_cq = hfi1_destroy_cq, - - .create_srq = hfi1_create_srq, - .modify_srq = hfi1_modify_srq, - .query_srq = hfi1_query_srq, - .destroy_srq = hfi1_destroy_srq, - .post_srq_recv = hfi1_post_srq_recv, - - .create_qp = hfi1_create_qp, - .query_qp = hfi1_query_qp, - .modify_qp = hfi1_modify_qp, - .destroy_qp = hfi1_destroy_qp, - - .post_send = hfi1_post_send, - .post_recv = hfi1_post_recv, - - .create_ah = hfi1_create_ah, - .destroy_ah = hfi1_destroy_ah, - - .attach_mcast = ibv_cmd_attach_mcast, - .detach_mcast = ibv_cmd_detach_mcast -}; - -static struct ibv_context *hfi1_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - struct hfi1_context *context; - struct ibv_get_context cmd; - struct ibv_get_context_resp resp; - struct hfi1_device *dev; - - context = malloc(sizeof *context); - if (!context) - return NULL; - memset(context, 0, sizeof *context); - context->ibv_ctx.cmd_fd = cmd_fd; - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, - sizeof cmd, &resp, sizeof resp)) - goto err_free; - - context->ibv_ctx.ops = hfi1_ctx_ops; - dev = to_idev(ibdev); - if (dev->abi_version == 1) { - context->ibv_ctx.ops.create_cq = hfi1_create_cq_v1; - context->ibv_ctx.ops.poll_cq = ibv_cmd_poll_cq; - context->ibv_ctx.ops.resize_cq = hfi1_resize_cq_v1; - context->ibv_ctx.ops.destroy_cq = hfi1_destroy_cq_v1; - context->ibv_ctx.ops.create_srq = hfi1_create_srq_v1; - context->ibv_ctx.ops.destroy_srq = hfi1_destroy_srq_v1; - context->ibv_ctx.ops.modify_srq = hfi1_modify_srq_v1; - context->ibv_ctx.ops.post_srq_recv = ibv_cmd_post_srq_recv; - context->ibv_ctx.ops.create_qp = hfi1_create_qp_v1; - context->ibv_ctx.ops.destroy_qp = hfi1_destroy_qp_v1; - context->ibv_ctx.ops.post_recv = ibv_cmd_post_recv; - } - return &context->ibv_ctx; - -err_free: - free(context); - return NULL; -} - -static void hfi1_free_context(struct ibv_context *ibctx) -{ - struct hfi1_context *context = to_ictx(ibctx); - - free(context); -} - -static void hf11_uninit_device(struct verbs_device *verbs_device) -{ - struct hfi1_device *dev = to_idev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device *hfi1_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct hfi1_device *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->abi_version = sysfs_dev->abi_ver; - - return &dev->ibv_dev; -} - -static const struct verbs_device_ops hfi1_dev_ops = { - .name = "hfi1verbs", - .match_min_abi_version = 0, - .match_max_abi_version = INT_MAX, - .match_table = hca_table, - .alloc_device = hfi1_device_alloc, - .uninit_device = hf11_uninit_device, - .alloc_context = hfi1_alloc_context, - .free_context = hfi1_free_context, -}; -PROVIDER_DRIVER(hfi1_dev_ops); diff --git a/usr/rdma-core/providers/hfi1verbs/hfiverbs.h b/usr/rdma-core/providers/hfi1verbs/hfiverbs.h deleted file mode 100644 index 456d36872..000000000 --- a/usr/rdma-core/providers/hfi1verbs/hfiverbs.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright(c) 2015 Intel Corporation. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - 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. - - Contact Information: - Intel Corporation - www.intel.com - - BSD LICENSE - - Copyright(c) 2015 Intel Corporation. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Copyright (C) 2006-2009 QLogic Corporation, All rights reserved. - Copyright (c) 2005. PathScale, Inc. All rights reserved. - -*/ - -#ifndef HFI1_H -#define HFI1_H - -#include -#include -#include -#include - -#include -#include - -#define PFX "hfi1: " - -struct hfi1_device { - struct verbs_device ibv_dev; - int abi_version; -}; - -struct hfi1_context { - struct ibv_context ibv_ctx; -}; - -/* - * This structure needs to have the same size and offsets as - * the kernel's ib_wc structure since it is memory mapped. - */ -struct hfi1_wc { - uint64_t wr_id; - enum ibv_wc_status status; - enum ibv_wc_opcode opcode; - uint32_t vendor_err; - uint32_t byte_len; - uint32_t imm_data; /* in network byte order */ - uint32_t qp_num; - uint32_t src_qp; - enum ibv_wc_flags wc_flags; - uint16_t pkey_index; - uint16_t slid; - uint8_t sl; - uint8_t dlid_path_bits; - uint8_t port_num; -}; - -struct hfi1_cq_wc { - _Atomic(uint32_t) head; - _Atomic(uint32_t) tail; - struct hfi1_wc queue[1]; -}; - -struct hfi1_cq { - struct ibv_cq ibv_cq; - struct hfi1_cq_wc *queue; - pthread_spinlock_t lock; -}; - -/* - * Receive work request queue entry. - * The size of the sg_list is determined when the QP is created and stored - * in qp->r_max_sge. - */ -struct hfi1_rwqe { - uint64_t wr_id; - uint8_t num_sge; - uint8_t padding[7]; - struct ibv_sge sg_list[0]; -}; - -/* - * This struture is used to contain the head pointer, tail pointer, - * and receive work queue entries as a single memory allocation so - * it can be mmap'ed into user space. - * Note that the wq array elements are variable size so you can't - * just index into the array to get the N'th element; - * use get_rwqe_ptr() instead. - */ -struct hfi1_rwq { - _Atomic(uint32_t) head; /* new requests posted to the head. */ - _Atomic(uint32_t) tail; /* receives pull requests from here. */ - struct hfi1_rwqe wq[0]; -}; - -struct hfi1_rq { - struct hfi1_rwq *rwq; - pthread_spinlock_t lock; - uint32_t size; - uint32_t max_sge; -}; - -struct hfi1_qp { - struct ibv_qp ibv_qp; - struct hfi1_rq rq; -}; - -struct hfi1_srq { - struct ibv_srq ibv_srq; - struct hfi1_rq rq; -}; - -#define to_ixxx(xxx, type) \ - ((struct hfi1_##type *) \ - ((void *) ib##xxx - offsetof(struct hfi1_##type, ibv_##xxx))) - -static inline struct hfi1_context *to_ictx(struct ibv_context *ibctx) -{ - return to_ixxx(ctx, context); -} - -static inline struct hfi1_device *to_idev(struct ibv_device *ibdev) -{ - return to_ixxx(dev, device); -} - -static inline struct hfi1_cq *to_icq(struct ibv_cq *ibcq) -{ - return to_ixxx(cq, cq); -} - -static inline struct hfi1_qp *to_iqp(struct ibv_qp *ibqp) -{ - return to_ixxx(qp, qp); -} - -static inline struct hfi1_srq *to_isrq(struct ibv_srq *ibsrq) -{ - return to_ixxx(srq, srq); -} - -/* - * Since struct hfi1_rwqe is not a fixed size, we can't simply index into - * struct hfi1_rq.wq. This function does the array index computation. - */ -static inline struct hfi1_rwqe *get_rwqe_ptr(struct hfi1_rq *rq, - unsigned n) -{ - return (struct hfi1_rwqe *) - ((char *) rq->rwq->wq + - (sizeof(struct hfi1_rwqe) + - rq->max_sge * sizeof(struct ibv_sge)) * n); -} - -extern int hfi1_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); - -extern int hfi1_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -struct ibv_pd *hfi1_alloc_pd(struct ibv_context *pd); - -int hfi1_free_pd(struct ibv_pd *pd); - -struct ibv_mr *hfi1_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); - -int hfi1_dereg_mr(struct ibv_mr *mr); - -struct ibv_cq *hfi1_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); - -struct ibv_cq *hfi1_create_cq_v1(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); - -int hfi1_resize_cq(struct ibv_cq *cq, int cqe); - -int hfi1_resize_cq_v1(struct ibv_cq *cq, int cqe); - -int hfi1_destroy_cq(struct ibv_cq *cq); - -int hfi1_destroy_cq_v1(struct ibv_cq *cq); - -int hfi1_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); - -struct ibv_qp *hfi1_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr); - -struct ibv_qp *hfi1_create_qp_v1(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr); - -int hfi1_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); - -int hfi1_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); - -int hfi1_destroy_qp(struct ibv_qp *qp); - -int hfi1_destroy_qp_v1(struct ibv_qp *qp); - -int hfi1_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); - -int hfi1_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -struct ibv_srq *hfi1_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); - -struct ibv_srq *hfi1_create_srq_v1(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); - -int hfi1_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int attr_mask); - -int hfi1_modify_srq_v1(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int attr_mask); - -int hfi1_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr); - -int hfi1_destroy_srq(struct ibv_srq *srq); - -int hfi1_destroy_srq_v1(struct ibv_srq *srq); - -int hfi1_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -struct ibv_ah *hfi1_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr); - -int hfi1_destroy_ah(struct ibv_ah *ah); - -#endif /* HFI1_H */ diff --git a/usr/rdma-core/providers/hfi1verbs/verbs.c b/usr/rdma-core/providers/hfi1verbs/verbs.c deleted file mode 100644 index 145708d7b..000000000 --- a/usr/rdma-core/providers/hfi1verbs/verbs.c +++ /dev/null @@ -1,706 +0,0 @@ -/* - - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright(c) 2015 Intel Corporation. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - 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. - - Contact Information: - Intel Corporation - www.intel.com - - BSD LICENSE - - Copyright(c) 2015 Intel Corporation. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Copyright (C) 2006-2009 QLogic Corporation, All rights reserved. - Copyright (c) 2005. PathScale, Inc. All rights reserved. - -*/ - -#include - -#include -#include -#include -#include -#include -#include - -#include "hfiverbs.h" -#include "hfi-abi.h" - -int hfi1_query_device(struct ibv_context *context, - struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, - &cmd, sizeof cmd); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%d", major, minor, sub_minor); - - return 0; -} - -int hfi1_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); -} - -struct ibv_pd *hfi1_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct ibv_alloc_pd_resp resp; - struct ibv_pd *pd; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, pd, &cmd, sizeof cmd, - &resp, sizeof resp)) { - free(pd); - return NULL; - } - - return pd; -} - -int hfi1_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - free(pd); - return 0; -} - -struct ibv_mr *hfi1_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - struct ibv_mr *mr; - struct ibv_reg_mr cmd; - struct ibv_reg_mr_resp resp; - int ret; - - mr = malloc(sizeof *mr); - if (!mr) - return NULL; - - ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr, - &cmd, sizeof cmd, &resp, sizeof resp); - - if (ret) { - free(mr); - return NULL; - } - - return mr; -} - -int hfi1_dereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - free(mr); - return 0; -} - -struct ibv_cq *hfi1_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct hfi1_cq *cq; - struct ibv_create_cq cmd; - struct hfi1_create_cq_resp resp; - int ret; - size_t size; - - memset(&resp, 0, sizeof(resp)); - cq = malloc(sizeof *cq); - if (!cq) - return NULL; - - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &cq->ibv_cq, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(cq); - return NULL; - } - - size = sizeof(struct hfi1_cq_wc) + sizeof(struct hfi1_wc) * cqe; - cq->queue = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - context->cmd_fd, resp.offset); - if ((void *) cq->queue == MAP_FAILED) { - ibv_cmd_destroy_cq(&cq->ibv_cq); - free(cq); - return NULL; - } - - pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE); - return &cq->ibv_cq; -} - -struct ibv_cq *hfi1_create_cq_v1(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct ibv_cq *cq; - struct ibv_create_cq cmd; - struct ibv_create_cq_resp resp; - int ret; - - cq = malloc(sizeof *cq); - if (!cq) - return NULL; - - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - cq, &cmd, sizeof cmd, &resp, sizeof resp); - if (ret) { - free(cq); - return NULL; - } - - return cq; -} - -int hfi1_resize_cq(struct ibv_cq *ibcq, int cqe) -{ - struct hfi1_cq *cq = to_icq(ibcq); - struct ibv_resize_cq cmd; - struct hfi1_resize_cq_resp resp; - size_t size; - int ret; - - memset(&resp, 0, sizeof(resp)); - pthread_spin_lock(&cq->lock); - /* Save the old size so we can unmmap the queue. */ - size = sizeof(struct hfi1_cq_wc) + - (sizeof(struct hfi1_wc) * cq->ibv_cq.cqe); - ret = ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - pthread_spin_unlock(&cq->lock); - return ret; - } - (void) munmap(cq->queue, size); - size = sizeof(struct hfi1_cq_wc) + - (sizeof(struct hfi1_wc) * cq->ibv_cq.cqe); - cq->queue = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - ibcq->context->cmd_fd, resp.offset); - ret = errno; - pthread_spin_unlock(&cq->lock); - if ((void *) cq->queue == MAP_FAILED) - return ret; - return 0; -} - -int hfi1_resize_cq_v1(struct ibv_cq *ibcq, int cqe) -{ - struct ibv_resize_cq cmd; - struct ibv_resize_cq_resp resp; - - return ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd, - &resp, sizeof resp); -} - -int hfi1_destroy_cq(struct ibv_cq *ibcq) -{ - struct hfi1_cq *cq = to_icq(ibcq); - int ret; - - ret = ibv_cmd_destroy_cq(ibcq); - if (ret) - return ret; - - (void) munmap(cq->queue, sizeof(struct hfi1_cq_wc) + - (sizeof(struct hfi1_wc) * cq->ibv_cq.cqe)); - free(cq); - return 0; -} - -int hfi1_destroy_cq_v1(struct ibv_cq *ibcq) -{ - int ret; - - ret = ibv_cmd_destroy_cq(ibcq); - if (!ret) - free(ibcq); - return ret; -} - -int hfi1_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) -{ - struct hfi1_cq *cq = to_icq(ibcq); - struct hfi1_cq_wc *q; - int npolled; - uint32_t tail; - - pthread_spin_lock(&cq->lock); - q = cq->queue; - tail = atomic_load_explicit(&q->tail, memory_order_relaxed); - for (npolled = 0; npolled < ne; ++npolled, ++wc) { - if (tail == atomic_load(&q->head)) - break; - /* Make sure entry is read after head index is read. */ - atomic_thread_fence(memory_order_acquire); - memcpy(wc, &q->queue[tail], sizeof(*wc)); - if (tail == cq->ibv_cq.cqe) - tail = 0; - else - tail++; - } - atomic_store(&q->tail, tail); - pthread_spin_unlock(&cq->lock); - - return npolled; -} - -struct ibv_qp *hfi1_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) -{ - struct ibv_create_qp cmd; - struct hfi1_create_qp_resp resp; - struct hfi1_qp *qp; - int ret; - size_t size; - - memset(&resp, 0, sizeof(resp)); - qp = malloc(sizeof *qp); - if (!qp) - return NULL; - - ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(qp); - return NULL; - } - - if (attr->srq) { - qp->rq.size = 0; - qp->rq.max_sge = 0; - qp->rq.rwq = NULL; - } else { - qp->rq.size = attr->cap.max_recv_wr + 1; - qp->rq.max_sge = attr->cap.max_recv_sge; - size = sizeof(struct hfi1_rwq) + - (sizeof(struct hfi1_rwqe) + - (sizeof(struct ibv_sge) * qp->rq.max_sge)) * - qp->rq.size; - qp->rq.rwq = mmap(NULL, size, - PROT_READ | PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.offset); - if ((void *) qp->rq.rwq == MAP_FAILED) { - ibv_cmd_destroy_qp(&qp->ibv_qp); - free(qp); - return NULL; - } - } - - pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE); - return &qp->ibv_qp; -} - -struct ibv_qp *hfi1_create_qp_v1(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - struct ibv_create_qp cmd; - struct ibv_create_qp_resp resp; - struct ibv_qp *qp; - int ret; - - qp = malloc(sizeof *qp); - if (!qp) - return NULL; - - ret = ibv_cmd_create_qp(pd, qp, attr, &cmd, sizeof cmd, - &resp, sizeof resp); - if (ret) { - free(qp); - return NULL; - } - - return qp; -} - -int hfi1_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - - return ibv_cmd_query_qp(qp, attr, attr_mask, init_attr, - &cmd, sizeof cmd); -} - -int hfi1_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - - return ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof cmd); -} - -int hfi1_destroy_qp(struct ibv_qp *ibqp) -{ - struct hfi1_qp *qp = to_iqp(ibqp); - int ret; - - ret = ibv_cmd_destroy_qp(ibqp); - if (ret) - return ret; - - if (qp->rq.rwq) { - size_t size; - - size = sizeof(struct hfi1_rwq) + - (sizeof(struct hfi1_rwqe) + - (sizeof(struct ibv_sge) * qp->rq.max_sge)) * - qp->rq.size; - (void) munmap(qp->rq.rwq, size); - } - free(qp); - return 0; -} - -int hfi1_destroy_qp_v1(struct ibv_qp *ibqp) -{ - int ret; - - ret = ibv_cmd_destroy_qp(ibqp); - if (!ret) - free(ibqp); - return ret; -} - -int hfi1_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - unsigned wr_count; - struct ibv_send_wr *i; - - /* Sanity check the number of WRs being posted */ - for (i = wr, wr_count = 0; i; i = i->next) - if (++wr_count > 10) - goto iter; - - return ibv_cmd_post_send(qp, wr, bad_wr); - -iter: - do { - struct ibv_send_wr *next; - int ret; - - next = i->next; - i->next = NULL; - ret = ibv_cmd_post_send(qp, wr, bad_wr); - i->next = next; - if (ret) - return ret; - if (next == NULL) - break; - wr = next; - for (i = wr, wr_count = 0; i->next; i = i->next) - if (++wr_count > 2) - break; - } while (1); - return 0; -} - -static int post_recv(struct hfi1_rq *rq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct ibv_recv_wr *i; - struct hfi1_rwq *rwq; - struct hfi1_rwqe *wqe; - uint32_t head; - int n, ret; - - pthread_spin_lock(&rq->lock); - rwq = rq->rwq; - head = atomic_load_explicit(&rwq->head, memory_order_relaxed); - for (i = wr; i; i = i->next) { - if ((unsigned) i->num_sge > rq->max_sge) { - ret = EINVAL; - goto bad; - } - wqe = get_rwqe_ptr(rq, head); - if (++head >= rq->size) - head = 0; - if (head == atomic_load(&rwq->tail)) { - ret = ENOMEM; - goto bad; - } - wqe->wr_id = i->wr_id; - wqe->num_sge = i->num_sge; - for (n = 0; n < wqe->num_sge; n++) - wqe->sg_list[n] = i->sg_list[n]; - - /* Make sure queue entry is written before the head index. */ - atomic_thread_fence(memory_order_release); - atomic_store(&rwq->head, head); - } - ret = 0; - goto done; - -bad: - if (bad_wr) - *bad_wr = i; -done: - pthread_spin_unlock(&rq->lock); - return ret; -} - -int hfi1_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct hfi1_qp *qp = to_iqp(ibqp); - - return post_recv(&qp->rq, wr, bad_wr); -} - -struct ibv_srq *hfi1_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct hfi1_srq *srq; - struct ibv_create_srq cmd; - struct hfi1_create_srq_resp resp; - int ret; - size_t size; - - memset(&resp, 0, sizeof(resp)); - srq = malloc(sizeof *srq); - if (srq == NULL) - return NULL; - - ret = ibv_cmd_create_srq(pd, &srq->ibv_srq, attr, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(srq); - return NULL; - } - - srq->rq.size = attr->attr.max_wr + 1; - srq->rq.max_sge = attr->attr.max_sge; - size = sizeof(struct hfi1_rwq) + - (sizeof(struct hfi1_rwqe) + - (sizeof(struct ibv_sge) * srq->rq.max_sge)) * srq->rq.size; - srq->rq.rwq = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.offset); - if ((void *) srq->rq.rwq == MAP_FAILED) { - ibv_cmd_destroy_srq(&srq->ibv_srq); - free(srq); - return NULL; - } - - pthread_spin_init(&srq->rq.lock, PTHREAD_PROCESS_PRIVATE); - return &srq->ibv_srq; -} - -struct ibv_srq *hfi1_create_srq_v1(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct ibv_srq *srq; - struct ibv_create_srq cmd; - struct ibv_create_srq_resp resp; - int ret; - - srq = malloc(sizeof *srq); - if (srq == NULL) - return NULL; - - ret = ibv_cmd_create_srq(pd, srq, attr, &cmd, sizeof cmd, - &resp, sizeof resp); - if (ret) { - free(srq); - return NULL; - } - - return srq; -} - -int hfi1_modify_srq(struct ibv_srq *ibsrq, - struct ibv_srq_attr *attr, - int attr_mask) -{ - struct hfi1_srq *srq = to_isrq(ibsrq); - struct hfi1_modify_srq_cmd cmd; - __u64 offset; - size_t size = 0; /* Shut up gcc */ - int ret; - - if (attr_mask & IBV_SRQ_MAX_WR) { - pthread_spin_lock(&srq->rq.lock); - /* Save the old size so we can unmmap the queue. */ - size = sizeof(struct hfi1_rwq) + - (sizeof(struct hfi1_rwqe) + - (sizeof(struct ibv_sge) * srq->rq.max_sge)) * - srq->rq.size; - } - cmd.offset_addr = (uintptr_t) &offset; - ret = ibv_cmd_modify_srq(ibsrq, attr, attr_mask, - &cmd.ibv_cmd, sizeof cmd); - if (ret) { - if (attr_mask & IBV_SRQ_MAX_WR) - pthread_spin_unlock(&srq->rq.lock); - return ret; - } - if (attr_mask & IBV_SRQ_MAX_WR) { - (void) munmap(srq->rq.rwq, size); - srq->rq.size = attr->max_wr + 1; - size = sizeof(struct hfi1_rwq) + - (sizeof(struct hfi1_rwqe) + - (sizeof(struct ibv_sge) * srq->rq.max_sge)) * - srq->rq.size; - srq->rq.rwq = mmap(NULL, size, - PROT_READ | PROT_WRITE, MAP_SHARED, - ibsrq->context->cmd_fd, offset); - pthread_spin_unlock(&srq->rq.lock); - /* XXX Now we have no receive queue. */ - if ((void *) srq->rq.rwq == MAP_FAILED) - return errno; - } - return 0; -} - -int hfi1_modify_srq_v1(struct ibv_srq *ibsrq, - struct ibv_srq_attr *attr, - int attr_mask) -{ - struct ibv_modify_srq cmd; - - return ibv_cmd_modify_srq(ibsrq, attr, attr_mask, - &cmd, sizeof cmd); -} - -int hfi1_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr) -{ - struct ibv_query_srq cmd; - - return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd); -} - -int hfi1_destroy_srq(struct ibv_srq *ibsrq) -{ - struct hfi1_srq *srq = to_isrq(ibsrq); - size_t size; - int ret; - - ret = ibv_cmd_destroy_srq(ibsrq); - if (ret) - return ret; - - size = sizeof(struct hfi1_rwq) + - (sizeof(struct hfi1_rwqe) + - (sizeof(struct ibv_sge) * srq->rq.max_sge)) * srq->rq.size; - (void) munmap(srq->rq.rwq, size); - free(srq); - return 0; -} - -int hfi1_destroy_srq_v1(struct ibv_srq *ibsrq) -{ - int ret; - - ret = ibv_cmd_destroy_srq(ibsrq); - if (!ret) - free(ibsrq); - return ret; -} - -int hfi1_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct hfi1_srq *srq = to_isrq(ibsrq); - - return post_recv(&srq->rq, wr, bad_wr); -} - -struct ibv_ah *hfi1_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - struct ibv_ah *ah; - struct ibv_create_ah_resp resp; - - ah = malloc(sizeof *ah); - if (ah == NULL) - return NULL; - - memset(&resp, 0, sizeof(resp)); - if (ibv_cmd_create_ah(pd, ah, attr, &resp, sizeof(resp))) { - free(ah); - return NULL; - } - - return ah; -} - -int hfi1_destroy_ah(struct ibv_ah *ah) -{ - int ret; - - ret = ibv_cmd_destroy_ah(ah); - if (ret) - return ret; - - free(ah); - return 0; -} diff --git a/usr/rdma-core/providers/hns/CMakeLists.txt b/usr/rdma-core/providers/hns/CMakeLists.txt deleted file mode 100644 index 19a793e39..000000000 --- a/usr/rdma-core/providers/hns/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -rdma_provider(hns - hns_roce_u.c - hns_roce_u_buf.c - hns_roce_u_hw_v1.c - hns_roce_u_verbs.c -) diff --git a/usr/rdma-core/providers/hns/hns_roce_u.c b/usr/rdma-core/providers/hns/hns_roce_u.c deleted file mode 100644 index c27212ac7..000000000 --- a/usr/rdma-core/providers/hns/hns_roce_u.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2016 Hisilicon Limited. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "hns_roce_u.h" -#include "hns_roce_u_abi.h" - -#define HID_LEN 15 -#define DEV_MATCH_LEN 128 - -static const struct verbs_match_ent hca_table[] = { - VERBS_MODALIAS_MATCH("acpi*:HISI00D1:*", &hns_roce_u_hw_v1), - VERBS_MODALIAS_MATCH("of:N*T*Chisilicon,hns-roce-v1C*", &hns_roce_u_hw_v1), - VERBS_MODALIAS_MATCH("of:N*T*Chisilicon,hns-roce-v1", &hns_roce_u_hw_v1), - {} -}; - -static struct ibv_context *hns_roce_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - int i; - struct ibv_get_context cmd; - struct ibv_device_attr dev_attrs; - struct hns_roce_context *context; - struct hns_roce_alloc_ucontext_resp resp; - struct hns_roce_device *hr_dev = to_hr_dev(ibdev); - - context = calloc(1, sizeof(*context)); - if (!context) - return NULL; - - context->ibv_ctx.cmd_fd = cmd_fd; - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp))) - goto err_free; - - context->num_qps = resp.qp_tab_size; - context->qp_table_shift = ffs(context->num_qps) - 1 - - HNS_ROCE_QP_TABLE_BITS; - context->qp_table_mask = (1 << context->qp_table_shift) - 1; - - pthread_mutex_init(&context->qp_table_mutex, NULL); - for (i = 0; i < HNS_ROCE_QP_TABLE_SIZE; ++i) - context->qp_table[i].refcnt = 0; - - context->uar = mmap(NULL, to_hr_dev(ibdev)->page_size, - PROT_READ | PROT_WRITE, MAP_SHARED, cmd_fd, 0); - if (context->uar == MAP_FAILED) { - fprintf(stderr, PFX "Warning: failed to mmap() uar page.\n"); - goto err_free; - } - - if (hr_dev->hw_version == HNS_ROCE_HW_VER1) { - /* - * when vma->vm_pgoff is 1, the cq_tptr_base includes 64K CQ, - * a pointer of CQ need 2B size - */ - context->cq_tptr_base = mmap(NULL, HNS_ROCE_CQ_DB_BUF_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, - cmd_fd, HNS_ROCE_TPTR_OFFSET); - if (context->cq_tptr_base == MAP_FAILED) { - fprintf(stderr, - PFX "Warning: Failed to mmap cq_tptr page.\n"); - goto db_free; - } - } - - pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE); - - context->ibv_ctx.ops.query_device = hns_roce_u_query_device; - context->ibv_ctx.ops.query_port = hns_roce_u_query_port; - context->ibv_ctx.ops.alloc_pd = hns_roce_u_alloc_pd; - context->ibv_ctx.ops.dealloc_pd = hns_roce_u_free_pd; - context->ibv_ctx.ops.reg_mr = hns_roce_u_reg_mr; - context->ibv_ctx.ops.dereg_mr = hns_roce_u_dereg_mr; - - context->ibv_ctx.ops.create_cq = hns_roce_u_create_cq; - context->ibv_ctx.ops.poll_cq = hr_dev->u_hw->poll_cq; - context->ibv_ctx.ops.req_notify_cq = hr_dev->u_hw->arm_cq; - context->ibv_ctx.ops.cq_event = hns_roce_u_cq_event; - context->ibv_ctx.ops.destroy_cq = hns_roce_u_destroy_cq; - - context->ibv_ctx.ops.create_qp = hns_roce_u_create_qp; - context->ibv_ctx.ops.query_qp = hns_roce_u_query_qp; - context->ibv_ctx.ops.modify_qp = hr_dev->u_hw->modify_qp; - context->ibv_ctx.ops.destroy_qp = hr_dev->u_hw->destroy_qp; - context->ibv_ctx.ops.post_send = hr_dev->u_hw->post_send; - context->ibv_ctx.ops.post_recv = hr_dev->u_hw->post_recv; - - if (hns_roce_u_query_device(&context->ibv_ctx, &dev_attrs)) - goto tptr_free; - - context->max_qp_wr = dev_attrs.max_qp_wr; - context->max_sge = dev_attrs.max_sge; - context->max_cqe = dev_attrs.max_cqe; - - return &context->ibv_ctx; - -tptr_free: - if (hr_dev->hw_version == HNS_ROCE_HW_VER1) { - if (munmap(context->cq_tptr_base, HNS_ROCE_CQ_DB_BUF_SIZE)) - fprintf(stderr, PFX "Warning: Munmap tptr failed.\n"); - context->cq_tptr_base = NULL; - } - -db_free: - munmap(context->uar, to_hr_dev(ibdev)->page_size); - context->uar = NULL; - -err_free: - free(context); - return NULL; -} - -static void hns_roce_free_context(struct ibv_context *ibctx) -{ - struct hns_roce_context *context = to_hr_ctx(ibctx); - - munmap(context->uar, to_hr_dev(ibctx->device)->page_size); - if (to_hr_dev(ibctx->device)->hw_version == HNS_ROCE_HW_VER1) - munmap(context->cq_tptr_base, HNS_ROCE_CQ_DB_BUF_SIZE); - - context->uar = NULL; - - free(context); - context = NULL; -} - -static void hns_uninit_device(struct verbs_device *verbs_device) -{ - struct hns_roce_device *dev = to_hr_dev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device *hns_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct hns_roce_device *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->u_hw = sysfs_dev->match->driver_data; - dev->hw_version = dev->u_hw->hw_version; - dev->page_size = sysconf(_SC_PAGESIZE); - return &dev->ibv_dev; -} - -static const struct verbs_device_ops hns_roce_dev_ops = { - .name = "hns", - .match_min_abi_version = 0, - .match_max_abi_version = INT_MAX, - .match_table = hca_table, - .alloc_device = hns_device_alloc, - .uninit_device = hns_uninit_device, - .alloc_context = hns_roce_alloc_context, - .free_context = hns_roce_free_context, -}; -PROVIDER_DRIVER(hns_roce_dev_ops); diff --git a/usr/rdma-core/providers/hns/hns_roce_u.h b/usr/rdma-core/providers/hns/hns_roce_u.h deleted file mode 100644 index d0e2351fc..000000000 --- a/usr/rdma-core/providers/hns/hns_roce_u.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) 2016 Hisilicon Limited. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _HNS_ROCE_U_H -#define _HNS_ROCE_U_H - -#include -#include - -#include -#include -#include -#include - -#define HNS_ROCE_CQE_ENTRY_SIZE 0x20 - -#define HNS_ROCE_MAX_CQ_NUM 0x10000 -#define HNS_ROCE_MIN_CQE_NUM 0x40 -#define HNS_ROCE_MIN_WQE_NUM 0x20 -#define HNS_ROCE_CQ_DB_BUF_SIZE ((HNS_ROCE_MAX_CQ_NUM >> 11) << 12) -#define HNS_ROCE_TPTR_OFFSET 0x1000 -#define HNS_ROCE_HW_VER1 ('h' << 24 | 'i' << 16 | '0' << 8 | '6') - -#define PFX "hns: " - -#define roce_get_field(origin, mask, shift) \ - (((origin) & (mask)) >> (shift)) - -#define roce_get_bit(origin, shift) \ - roce_get_field((origin), (1ul << (shift)), (shift)) - -#define roce_set_field(origin, mask, shift, val) \ - do { \ - (origin) &= (~(mask)); \ - (origin) |= (((unsigned int)(val) << (shift)) & (mask)); \ - } while (0) - -#define roce_set_bit(origin, shift, val) \ - roce_set_field((origin), (1ul << (shift)), (shift), (val)) - -enum { - HNS_ROCE_QP_TABLE_BITS = 8, - HNS_ROCE_QP_TABLE_SIZE = 1 << HNS_ROCE_QP_TABLE_BITS, -}; - -/* operation type list */ -enum { - /* rq&srq operation */ - HNS_ROCE_OPCODE_SEND_DATA_RECEIVE = 0x06, - HNS_ROCE_OPCODE_RDMA_WITH_IMM_RECEIVE = 0x07, -}; - -struct hns_roce_device { - struct verbs_device ibv_dev; - int page_size; - struct hns_roce_u_hw *u_hw; - int hw_version; -}; - -struct hns_roce_buf { - void *buf; - unsigned int length; -}; - -struct hns_roce_context { - struct ibv_context ibv_ctx; - void *uar; - pthread_spinlock_t uar_lock; - - void *cq_tptr_base; - - struct { - struct hns_roce_qp **table; - int refcnt; - } qp_table[HNS_ROCE_QP_TABLE_SIZE]; - - pthread_mutex_t qp_table_mutex; - - int num_qps; - int qp_table_shift; - int qp_table_mask; - unsigned int max_qp_wr; - unsigned int max_sge; - int max_cqe; -}; - -struct hns_roce_pd { - struct ibv_pd ibv_pd; - unsigned int pdn; -}; - -struct hns_roce_cq { - struct ibv_cq ibv_cq; - struct hns_roce_buf buf; - pthread_spinlock_t lock; - unsigned int cqn; - unsigned int cq_depth; - unsigned int cons_index; - unsigned int *set_ci_db; - unsigned int *arm_db; - int arm_sn; -}; - -struct hns_roce_srq { - struct ibv_srq ibv_srq; - struct hns_roce_buf buf; - pthread_spinlock_t lock; - unsigned long *wrid; - unsigned int srqn; - int max; - unsigned int max_gs; - int wqe_shift; - int head; - int tail; - unsigned int *db; - unsigned short counter; -}; - -struct hns_roce_wq { - unsigned long *wrid; - pthread_spinlock_t lock; - unsigned int wqe_cnt; - int max_post; - unsigned int head; - unsigned int tail; - unsigned int max_gs; - int wqe_shift; - int offset; -}; - -struct hns_roce_qp { - struct ibv_qp ibv_qp; - struct hns_roce_buf buf; - int max_inline_data; - int buf_size; - unsigned int sq_signal_bits; - struct hns_roce_wq sq; - struct hns_roce_wq rq; - int port_num; - int sl; -}; - -struct hns_roce_u_hw { - uint32_t hw_version; - int (*poll_cq)(struct ibv_cq *ibvcq, int ne, struct ibv_wc *wc); - int (*arm_cq)(struct ibv_cq *ibvcq, int solicited); - int (*post_send)(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); - int (*post_recv)(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); - int (*destroy_qp)(struct ibv_qp *ibqp); -}; - -static inline unsigned long align(unsigned long val, unsigned long align) -{ - return (val + align - 1) & ~(align - 1); -} - -static inline struct hns_roce_device *to_hr_dev(struct ibv_device *ibv_dev) -{ - return container_of(ibv_dev, struct hns_roce_device, ibv_dev); -} - -static inline struct hns_roce_context *to_hr_ctx(struct ibv_context *ibv_ctx) -{ - return container_of(ibv_ctx, struct hns_roce_context, ibv_ctx); -} - -static inline struct hns_roce_pd *to_hr_pd(struct ibv_pd *ibv_pd) -{ - return container_of(ibv_pd, struct hns_roce_pd, ibv_pd); -} - -static inline struct hns_roce_cq *to_hr_cq(struct ibv_cq *ibv_cq) -{ - return container_of(ibv_cq, struct hns_roce_cq, ibv_cq); -} - -static inline struct hns_roce_srq *to_hr_srq(struct ibv_srq *ibv_srq) -{ - return container_of(ibv_srq, struct hns_roce_srq, ibv_srq); -} - -static inline struct hns_roce_qp *to_hr_qp(struct ibv_qp *ibv_qp) -{ - return container_of(ibv_qp, struct hns_roce_qp, ibv_qp); -} - -int hns_roce_u_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); -int hns_roce_u_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -struct ibv_pd *hns_roce_u_alloc_pd(struct ibv_context *context); -int hns_roce_u_free_pd(struct ibv_pd *pd); - -struct ibv_mr *hns_roce_u_reg_mr(struct ibv_pd *pd, void *addr, size_t length, - int access); -int hns_roce_u_dereg_mr(struct ibv_mr *mr); - -struct ibv_cq *hns_roce_u_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); - -int hns_roce_u_destroy_cq(struct ibv_cq *cq); -void hns_roce_u_cq_event(struct ibv_cq *cq); - -struct ibv_qp *hns_roce_u_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr); - -int hns_roce_u_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr); - -int hns_roce_alloc_buf(struct hns_roce_buf *buf, unsigned int size, - int page_size); -void hns_roce_free_buf(struct hns_roce_buf *buf); - -void hns_roce_init_qp_indices(struct hns_roce_qp *qp); - -extern struct hns_roce_u_hw hns_roce_u_hw_v1; - -#endif /* _HNS_ROCE_U_H */ diff --git a/usr/rdma-core/providers/hns/hns_roce_u_abi.h b/usr/rdma-core/providers/hns/hns_roce_u_abi.h deleted file mode 100644 index 2a57f464a..000000000 --- a/usr/rdma-core/providers/hns/hns_roce_u_abi.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2016 Hisilicon Limited. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _HNS_ROCE_U_ABI_H -#define _HNS_ROCE_U_ABI_H - -#include - -struct hns_roce_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - __u32 qp_tab_size; -}; - -struct hns_roce_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - __u32 pdn; - __u32 reserved; -}; - -struct hns_roce_create_cq { - struct ibv_create_cq ibv_cmd; - __u64 buf_addr; - __u64 db_addr; -}; - -struct hns_roce_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u32 cqn; - __u32 reserved; -}; - -struct hns_roce_create_qp { - struct ibv_create_qp ibv_cmd; - __u64 buf_addr; - __u64 db_addr; - __u8 log_sq_bb_count; - __u8 log_sq_stride; - __u8 sq_no_prefetch; - __u8 reserved[5]; -}; - -#endif /* _HNS_ROCE_U_ABI_H */ diff --git a/usr/rdma-core/providers/hns/hns_roce_u_buf.c b/usr/rdma-core/providers/hns/hns_roce_u_buf.c deleted file mode 100644 index f92ea6513..000000000 --- a/usr/rdma-core/providers/hns/hns_roce_u_buf.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016 Hisilicon Limited. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#include "hns_roce_u.h" - -int hns_roce_alloc_buf(struct hns_roce_buf *buf, unsigned int size, - int page_size) -{ - int ret; - - buf->length = align(size, page_size); - buf->buf = mmap(NULL, buf->length, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (buf->buf == MAP_FAILED) - return errno; - - ret = ibv_dontfork_range(buf->buf, size); - if (ret) - munmap(buf->buf, buf->length); - - return ret; -} - -void hns_roce_free_buf(struct hns_roce_buf *buf) -{ - ibv_dofork_range(buf->buf, buf->length); - - munmap(buf->buf, buf->length); -} diff --git a/usr/rdma-core/providers/hns/hns_roce_u_db.h b/usr/rdma-core/providers/hns/hns_roce_u_db.h deleted file mode 100644 index 76d13ce9b..000000000 --- a/usr/rdma-core/providers/hns/hns_roce_u_db.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016 Hisilicon Limited. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include "hns_roce_u.h" - -#ifndef _HNS_ROCE_U_DB_H -#define _HNS_ROCE_U_DB_H - -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define HNS_ROCE_PAIR_TO_64(val) ((uint64_t) val[1] << 32 | val[0]) -#elif __BYTE_ORDER == __BIG_ENDIAN -#define HNS_ROCE_PAIR_TO_64(val) ((uint64_t) val[0] << 32 | val[1]) -#else -#error __BYTE_ORDER not defined -#endif - -static inline void hns_roce_write64(uint32_t val[2], - struct hns_roce_context *ctx, int offset) -{ - *(volatile uint64_t *) (ctx->uar + offset) = HNS_ROCE_PAIR_TO_64(val); -} - -#endif /* _HNS_ROCE_U_DB_H */ diff --git a/usr/rdma-core/providers/hns/hns_roce_u_hw_v1.c b/usr/rdma-core/providers/hns/hns_roce_u_hw_v1.c deleted file mode 100644 index 482eac90d..000000000 --- a/usr/rdma-core/providers/hns/hns_roce_u_hw_v1.c +++ /dev/null @@ -1,839 +0,0 @@ -/* - * Copyright (c) 2016 Hisilicon Limited. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include "hns_roce_u_db.h" -#include "hns_roce_u_hw_v1.h" -#include "hns_roce_u.h" - -static inline void set_raddr_seg(struct hns_roce_wqe_raddr_seg *rseg, - uint64_t remote_addr, uint32_t rkey) -{ - rseg->raddr = remote_addr; - rseg->rkey = rkey; - rseg->len = 0; -} - -static void set_data_seg(struct hns_roce_wqe_data_seg *dseg, struct ibv_sge *sg) -{ - - dseg->lkey = sg->lkey; - dseg->addr = sg->addr; - dseg->len = sg->length; -} - -static void hns_roce_update_rq_head(struct hns_roce_context *ctx, - unsigned int qpn, unsigned int rq_head) -{ - struct hns_roce_rq_db rq_db; - - rq_db.u32_4 = 0; - rq_db.u32_8 = 0; - - roce_set_field(rq_db.u32_4, RQ_DB_U32_4_RQ_HEAD_M, - RQ_DB_U32_4_RQ_HEAD_S, rq_head); - roce_set_field(rq_db.u32_8, RQ_DB_U32_8_QPN_M, RQ_DB_U32_8_QPN_S, qpn); - roce_set_field(rq_db.u32_8, RQ_DB_U32_8_CMD_M, RQ_DB_U32_8_CMD_S, 1); - roce_set_bit(rq_db.u32_8, RQ_DB_U32_8_HW_SYNC_S, 1); - - udma_to_device_barrier(); - - hns_roce_write64((uint32_t *)&rq_db, ctx, ROCEE_DB_OTHERS_L_0_REG); -} - -static void hns_roce_update_sq_head(struct hns_roce_context *ctx, - unsigned int qpn, unsigned int port, - unsigned int sl, unsigned int sq_head) -{ - struct hns_roce_sq_db sq_db; - - sq_db.u32_4 = 0; - sq_db.u32_8 = 0; - - roce_set_field(sq_db.u32_4, SQ_DB_U32_4_SQ_HEAD_M, - SQ_DB_U32_4_SQ_HEAD_S, sq_head); - roce_set_field(sq_db.u32_4, SQ_DB_U32_4_PORT_M, SQ_DB_U32_4_PORT_S, - port); - roce_set_field(sq_db.u32_4, SQ_DB_U32_4_SL_M, SQ_DB_U32_4_SL_S, sl); - roce_set_field(sq_db.u32_8, SQ_DB_U32_8_QPN_M, SQ_DB_U32_8_QPN_S, qpn); - roce_set_bit(sq_db.u32_8, SQ_DB_U32_8_HW_SYNC, 1); - - udma_to_device_barrier(); - - hns_roce_write64((uint32_t *)&sq_db, ctx, ROCEE_DB_SQ_L_0_REG); -} - -static void hns_roce_update_cq_cons_index(struct hns_roce_context *ctx, - struct hns_roce_cq *cq) -{ - struct hns_roce_cq_db cq_db; - - cq_db.u32_4 = 0; - cq_db.u32_8 = 0; - - roce_set_bit(cq_db.u32_8, CQ_DB_U32_8_HW_SYNC_S, 1); - roce_set_field(cq_db.u32_8, CQ_DB_U32_8_CMD_M, CQ_DB_U32_8_CMD_S, 3); - roce_set_field(cq_db.u32_8, CQ_DB_U32_8_CMD_MDF_M, - CQ_DB_U32_8_CMD_MDF_S, 0); - roce_set_field(cq_db.u32_8, CQ_DB_U32_8_CQN_M, CQ_DB_U32_8_CQN_S, - cq->cqn); - roce_set_field(cq_db.u32_4, CQ_DB_U32_4_CONS_IDX_M, - CQ_DB_U32_4_CONS_IDX_S, - cq->cons_index & ((cq->cq_depth << 1) - 1)); - - hns_roce_write64((uint32_t *)&cq_db, ctx, ROCEE_DB_OTHERS_L_0_REG); -} - -static void hns_roce_handle_error_cqe(struct hns_roce_cqe *cqe, - struct ibv_wc *wc) -{ - fprintf(stderr, PFX "error cqe!\n"); - switch (roce_get_field(cqe->cqe_byte_4, - CQE_BYTE_4_STATUS_OF_THE_OPERATION_M, - CQE_BYTE_4_STATUS_OF_THE_OPERATION_S) & - HNS_ROCE_CQE_STATUS_MASK) { - case HNS_ROCE_CQE_SYNDROME_LOCAL_LENGTH_ERR: - wc->status = IBV_WC_LOC_LEN_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_LOCAL_QP_OP_ERR: - wc->status = IBV_WC_LOC_QP_OP_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_LOCAL_PROT_ERR: - wc->status = IBV_WC_LOC_PROT_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_WR_FLUSH_ERR: - wc->status = IBV_WC_WR_FLUSH_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_MEM_MANAGE_OPERATE_ERR: - wc->status = IBV_WC_MW_BIND_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_BAD_RESP_ERR: - wc->status = IBV_WC_BAD_RESP_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_LOCAL_ACCESS_ERR: - wc->status = IBV_WC_LOC_ACCESS_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR: - wc->status = IBV_WC_REM_INV_REQ_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_REMOTE_ACCESS_ERR: - wc->status = IBV_WC_REM_ACCESS_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_REMOTE_OP_ERR: - wc->status = IBV_WC_REM_OP_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR: - wc->status = IBV_WC_RETRY_EXC_ERR; - break; - case HNS_ROCE_CQE_SYNDROME_RNR_RETRY_EXC_ERR: - wc->status = IBV_WC_RNR_RETRY_EXC_ERR; - break; - default: - wc->status = IBV_WC_GENERAL_ERR; - break; - } -} - -static struct hns_roce_cqe *get_cqe(struct hns_roce_cq *cq, int entry) -{ - return cq->buf.buf + entry * HNS_ROCE_CQE_ENTRY_SIZE; -} - -static void *get_sw_cqe(struct hns_roce_cq *cq, int n) -{ - struct hns_roce_cqe *cqe = get_cqe(cq, n & cq->ibv_cq.cqe); - - return (!!(roce_get_bit(cqe->cqe_byte_4, CQE_BYTE_4_OWNER_S)) ^ - !!(n & (cq->ibv_cq.cqe + 1))) ? cqe : NULL; -} - -static struct hns_roce_cqe *next_cqe_sw(struct hns_roce_cq *cq) -{ - return get_sw_cqe(cq, cq->cons_index); -} - -static void *get_recv_wqe(struct hns_roce_qp *qp, int n) -{ - if ((n < 0) || (n > qp->rq.wqe_cnt)) { - printf("rq wqe index:%d,rq wqe cnt:%d\r\n", n, qp->rq.wqe_cnt); - return NULL; - } - - return qp->buf.buf + qp->rq.offset + (n << qp->rq.wqe_shift); -} - -static void *get_send_wqe(struct hns_roce_qp *qp, int n) -{ - if ((n < 0) || (n > qp->sq.wqe_cnt)) { - printf("sq wqe index:%d,sq wqe cnt:%d\r\n", n, qp->sq.wqe_cnt); - return NULL; - } - - return (void *)(qp->buf.buf + qp->sq.offset + (n << qp->sq.wqe_shift)); -} - -static int hns_roce_wq_overflow(struct hns_roce_wq *wq, int nreq, - struct hns_roce_cq *cq) -{ - unsigned int cur; - - cur = wq->head - wq->tail; - if (cur + nreq < wq->max_post) - return 0; - - /* While the num of wqe exceeds cap of the device, cq will be locked */ - pthread_spin_lock(&cq->lock); - cur = wq->head - wq->tail; - pthread_spin_unlock(&cq->lock); - - printf("wq:(head = %d, tail = %d, max_post = %d), nreq = 0x%x\n", - wq->head, wq->tail, wq->max_post, nreq); - - return cur + nreq >= wq->max_post; -} - -static struct hns_roce_qp *hns_roce_find_qp(struct hns_roce_context *ctx, - uint32_t qpn) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (ctx->qp_table[tind].refcnt) { - return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask]; - } else { - printf("hns_roce_find_qp fail!\n"); - return NULL; - } -} - -static void hns_roce_clear_qp(struct hns_roce_context *ctx, uint32_t qpn) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (!--ctx->qp_table[tind].refcnt) - free(ctx->qp_table[tind].table); - else - ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = NULL; -} - -static int hns_roce_v1_poll_one(struct hns_roce_cq *cq, - struct hns_roce_qp **cur_qp, struct ibv_wc *wc) -{ - uint32_t qpn; - int is_send; - uint16_t wqe_ctr; - uint32_t local_qpn; - struct hns_roce_wq *wq = NULL; - struct hns_roce_cqe *cqe = NULL; - struct hns_roce_wqe_ctrl_seg *sq_wqe = NULL; - - /* According to CI, find the relative cqe */ - cqe = next_cqe_sw(cq); - if (!cqe) - return CQ_EMPTY; - - /* Get the next cqe, CI will be added gradually */ - ++cq->cons_index; - - udma_from_device_barrier(); - - qpn = roce_get_field(cqe->cqe_byte_16, CQE_BYTE_16_LOCAL_QPN_M, - CQE_BYTE_16_LOCAL_QPN_S); - - is_send = (roce_get_bit(cqe->cqe_byte_4, CQE_BYTE_4_SQ_RQ_FLAG_S) == - HNS_ROCE_CQE_IS_SQ); - - local_qpn = roce_get_field(cqe->cqe_byte_16, CQE_BYTE_16_LOCAL_QPN_M, - CQE_BYTE_16_LOCAL_QPN_S); - - /* if qp is zero, it will not get the correct qpn */ - if (!*cur_qp || - (local_qpn & HNS_ROCE_CQE_QPN_MASK) != (*cur_qp)->ibv_qp.qp_num) { - - *cur_qp = hns_roce_find_qp(to_hr_ctx(cq->ibv_cq.context), - qpn & 0xffffff); - if (!*cur_qp) { - fprintf(stderr, PFX "can't find qp!\n"); - return CQ_POLL_ERR; - } - } - wc->qp_num = qpn & 0xffffff; - - if (is_send) { - wq = &(*cur_qp)->sq; - /* - * if sq_signal_bits is 1, the tail pointer first update to - * the wqe corresponding the current cqe - */ - if ((*cur_qp)->sq_signal_bits) { - wqe_ctr = (uint16_t)(roce_get_field(cqe->cqe_byte_4, - CQE_BYTE_4_WQE_INDEX_M, - CQE_BYTE_4_WQE_INDEX_S)); - /* - * wq->tail will plus a positive number every time, - * when wq->tail exceeds 32b, it is 0 and acc - */ - wq->tail += (wqe_ctr - (uint16_t) wq->tail) & - (wq->wqe_cnt - 1); - } - /* write the wr_id of wq into the wc */ - wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; - ++wq->tail; - } else { - wq = &(*cur_qp)->rq; - wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; - ++wq->tail; - } - - /* - * HW maintains wc status, set the err type and directly return, after - * generated the incorrect CQE - */ - if (roce_get_field(cqe->cqe_byte_4, - CQE_BYTE_4_STATUS_OF_THE_OPERATION_M, - CQE_BYTE_4_STATUS_OF_THE_OPERATION_S) != HNS_ROCE_CQE_SUCCESS) { - hns_roce_handle_error_cqe(cqe, wc); - return CQ_OK; - } - wc->status = IBV_WC_SUCCESS; - - /* - * According to the opcode type of cqe, mark the opcode and other - * information of wc - */ - if (is_send) { - /* Get opcode and flag before update the tail point for send */ - sq_wqe = (struct hns_roce_wqe_ctrl_seg *) - get_send_wqe(*cur_qp, roce_get_field(cqe->cqe_byte_4, - CQE_BYTE_4_WQE_INDEX_M, - CQE_BYTE_4_WQE_INDEX_S)); - switch (sq_wqe->flag & HNS_ROCE_WQE_OPCODE_MASK) { - case HNS_ROCE_WQE_OPCODE_SEND: - wc->opcode = IBV_WC_SEND; - break; - case HNS_ROCE_WQE_OPCODE_RDMA_READ: - wc->opcode = IBV_WC_RDMA_READ; - wc->byte_len = cqe->byte_cnt; - break; - case HNS_ROCE_WQE_OPCODE_RDMA_WRITE: - wc->opcode = IBV_WC_RDMA_WRITE; - break; - case HNS_ROCE_WQE_OPCODE_BIND_MW2: - wc->opcode = IBV_WC_BIND_MW; - break; - default: - wc->status = IBV_WC_GENERAL_ERR; - break; - } - wc->wc_flags = (sq_wqe->flag & HNS_ROCE_WQE_IMM ? - IBV_WC_WITH_IMM : 0); - } else { - /* Get opcode and flag in rq&srq */ - wc->byte_len = (cqe->byte_cnt); - - switch (roce_get_field(cqe->cqe_byte_4, - CQE_BYTE_4_OPERATION_TYPE_M, - CQE_BYTE_4_OPERATION_TYPE_S) & - HNS_ROCE_CQE_OPCODE_MASK) { - case HNS_ROCE_OPCODE_RDMA_WITH_IMM_RECEIVE: - wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM; - wc->wc_flags = IBV_WC_WITH_IMM; - wc->imm_data = cqe->immediate_data; - break; - case HNS_ROCE_OPCODE_SEND_DATA_RECEIVE: - if (roce_get_bit(cqe->cqe_byte_4, - CQE_BYTE_4_IMMEDIATE_DATA_FLAG_S)) { - wc->opcode = IBV_WC_RECV; - wc->wc_flags = IBV_WC_WITH_IMM; - wc->imm_data = cqe->immediate_data; - } else { - wc->opcode = IBV_WC_RECV; - wc->wc_flags = 0; - } - break; - default: - wc->status = IBV_WC_GENERAL_ERR; - break; - } - } - - return CQ_OK; -} - -static int hns_roce_u_v1_poll_cq(struct ibv_cq *ibvcq, int ne, - struct ibv_wc *wc) -{ - int npolled; - int err = CQ_OK; - struct hns_roce_qp *qp = NULL; - struct hns_roce_cq *cq = to_hr_cq(ibvcq); - struct hns_roce_context *ctx = to_hr_ctx(ibvcq->context); - struct hns_roce_device *dev = to_hr_dev(ibvcq->context->device); - - pthread_spin_lock(&cq->lock); - - for (npolled = 0; npolled < ne; ++npolled) { - err = hns_roce_v1_poll_one(cq, &qp, wc + npolled); - if (err != CQ_OK) - break; - } - - if (npolled) { - if (dev->hw_version == HNS_ROCE_HW_VER1) { - *cq->set_ci_db = (unsigned short)(cq->cons_index & - ((cq->cq_depth << 1) - 1)); - mmio_ordered_writes_hack(); - } - - hns_roce_update_cq_cons_index(ctx, cq); - } - - pthread_spin_unlock(&cq->lock); - - return err == CQ_POLL_ERR ? err : npolled; -} - -/** - * hns_roce_u_v1_arm_cq - request completion notification on a CQ - * @ibvcq: The completion queue to request notification for. - * @solicited: If non-zero, a event will be generated only for - * the next solicited CQ entry. If zero, any CQ entry, - * solicited or not, will generate an event - */ -static int hns_roce_u_v1_arm_cq(struct ibv_cq *ibvcq, int solicited) -{ - uint32_t ci; - uint32_t solicited_flag; - struct hns_roce_cq_db cq_db; - struct hns_roce_cq *cq = to_hr_cq(ibvcq); - - ci = cq->cons_index & ((cq->cq_depth << 1) - 1); - solicited_flag = solicited ? HNS_ROCE_CQ_DB_REQ_SOL : - HNS_ROCE_CQ_DB_REQ_NEXT; - - cq_db.u32_4 = 0; - cq_db.u32_8 = 0; - - roce_set_bit(cq_db.u32_8, CQ_DB_U32_8_HW_SYNC_S, 1); - roce_set_field(cq_db.u32_8, CQ_DB_U32_8_CMD_M, CQ_DB_U32_8_CMD_S, 3); - roce_set_field(cq_db.u32_8, CQ_DB_U32_8_CMD_MDF_M, - CQ_DB_U32_8_CMD_MDF_S, 1); - roce_set_bit(cq_db.u32_8, CQ_DB_U32_8_NOTIFY_TYPE_S, solicited_flag); - roce_set_field(cq_db.u32_8, CQ_DB_U32_8_CQN_M, CQ_DB_U32_8_CQN_S, - cq->cqn); - roce_set_field(cq_db.u32_4, CQ_DB_U32_4_CONS_IDX_M, - CQ_DB_U32_4_CONS_IDX_S, ci); - - hns_roce_write64((uint32_t *)&cq_db, to_hr_ctx(ibvcq->context), - ROCEE_DB_OTHERS_L_0_REG); - return 0; -} - -static int hns_roce_u_v1_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - unsigned int ind; - void *wqe; - int nreq; - int ps_opcode, i; - int ret = 0; - struct hns_roce_wqe_ctrl_seg *ctrl = NULL; - struct hns_roce_wqe_data_seg *dseg = NULL; - struct hns_roce_qp *qp = to_hr_qp(ibvqp); - struct hns_roce_context *ctx = to_hr_ctx(ibvqp->context); - - pthread_spin_lock(&qp->sq.lock); - - /* check that state is OK to post send */ - ind = qp->sq.head; - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (hns_roce_wq_overflow(&qp->sq, nreq, - to_hr_cq(qp->ibv_qp.send_cq))) { - ret = -1; - *bad_wr = wr; - goto out; - } - if (wr->num_sge > qp->sq.max_gs) { - ret = -1; - *bad_wr = wr; - printf("wr->num_sge(<=%d) = %d, check failed!\r\n", - qp->sq.max_gs, wr->num_sge); - goto out; - } - - ctrl = wqe = get_send_wqe(qp, ind & (qp->sq.wqe_cnt - 1)); - memset(ctrl, 0, sizeof(struct hns_roce_wqe_ctrl_seg)); - - qp->sq.wrid[ind & (qp->sq.wqe_cnt - 1)] = wr->wr_id; - for (i = 0; i < wr->num_sge; i++) - ctrl->msg_length += wr->sg_list[i].length; - - - ctrl->flag |= ((wr->send_flags & IBV_SEND_SIGNALED) ? - HNS_ROCE_WQE_CQ_NOTIFY : 0) | - (wr->send_flags & IBV_SEND_SOLICITED ? - HNS_ROCE_WQE_SE : 0) | - ((wr->opcode == IBV_WR_SEND_WITH_IMM || - wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM) ? - HNS_ROCE_WQE_IMM : 0) | - (wr->send_flags & IBV_SEND_FENCE ? - HNS_ROCE_WQE_FENCE : 0); - - if (wr->opcode == IBV_WR_SEND_WITH_IMM || - wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM) - ctrl->imm_data = wr->imm_data; - - wqe += sizeof(struct hns_roce_wqe_ctrl_seg); - - /* set remote addr segment */ - switch (ibvqp->qp_type) { - case IBV_QPT_RC: - switch (wr->opcode) { - case IBV_WR_RDMA_READ: - ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_READ; - set_raddr_seg(wqe, wr->wr.rdma.remote_addr, - wr->wr.rdma.rkey); - break; - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_WRITE; - set_raddr_seg(wqe, wr->wr.rdma.remote_addr, - wr->wr.rdma.rkey); - break; - case IBV_WR_SEND: - case IBV_WR_SEND_WITH_IMM: - ps_opcode = HNS_ROCE_WQE_OPCODE_SEND; - break; - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - default: - ps_opcode = HNS_ROCE_WQE_OPCODE_MASK; - break; - } - ctrl->flag |= (ps_opcode); - wqe += sizeof(struct hns_roce_wqe_raddr_seg); - break; - case IBV_QPT_UC: - case IBV_QPT_UD: - default: - break; - } - - dseg = wqe; - - /* Inline */ - if (wr->send_flags & IBV_SEND_INLINE && wr->num_sge) { - if (ctrl->msg_length > qp->max_inline_data) { - ret = -1; - *bad_wr = wr; - printf("inline data len(1-32)=%d, send_flags = 0x%x, check failed!\r\n", - wr->send_flags, ctrl->msg_length); - return ret; - } - - for (i = 0; i < wr->num_sge; i++) { - memcpy(wqe, - ((void *) (uintptr_t) wr->sg_list[i].addr), - wr->sg_list[i].length); - wqe = wqe + wr->sg_list[i].length; - } - - ctrl->flag |= HNS_ROCE_WQE_INLINE; - } else { - /* set sge */ - for (i = 0; i < wr->num_sge; i++) - set_data_seg(dseg+i, wr->sg_list + i); - - ctrl->flag |= wr->num_sge << HNS_ROCE_WQE_SGE_NUM_BIT; - } - - ind++; - } - -out: - /* Set DB return */ - if (likely(nreq)) { - qp->sq.head += nreq; - - hns_roce_update_sq_head(ctx, qp->ibv_qp.qp_num, - qp->port_num - 1, qp->sl, - qp->sq.head & ((qp->sq.wqe_cnt << 1) - 1)); - } - - pthread_spin_unlock(&qp->sq.lock); - - return ret; -} - -static void __hns_roce_v1_cq_clean(struct hns_roce_cq *cq, uint32_t qpn, - struct hns_roce_srq *srq) -{ - int nfreed = 0; - uint32_t prod_index; - uint8_t owner_bit = 0; - struct hns_roce_cqe *cqe, *dest; - struct hns_roce_context *ctx = to_hr_ctx(cq->ibv_cq.context); - - for (prod_index = cq->cons_index; get_sw_cqe(cq, prod_index); - ++prod_index) - if (prod_index == cq->cons_index + cq->ibv_cq.cqe) - break; - - while ((int) --prod_index - (int) cq->cons_index >= 0) { - cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe); - if ((roce_get_field(cqe->cqe_byte_16, CQE_BYTE_16_LOCAL_QPN_M, - CQE_BYTE_16_LOCAL_QPN_S) & 0xffffff) == qpn) { - ++nfreed; - } else if (nfreed) { - dest = get_cqe(cq, - (prod_index + nfreed) & cq->ibv_cq.cqe); - owner_bit = roce_get_bit(dest->cqe_byte_4, - CQE_BYTE_4_OWNER_S); - memcpy(dest, cqe, sizeof(*cqe)); - roce_set_bit(dest->cqe_byte_4, CQE_BYTE_4_OWNER_S, - owner_bit); - } - } - - if (nfreed) { - cq->cons_index += nfreed; - udma_to_device_barrier(); - hns_roce_update_cq_cons_index(ctx, cq); - } -} - -static void hns_roce_v1_cq_clean(struct hns_roce_cq *cq, unsigned int qpn, - struct hns_roce_srq *srq) -{ - pthread_spin_lock(&cq->lock); - __hns_roce_v1_cq_clean(cq, qpn, srq); - pthread_spin_unlock(&cq->lock); -} - -static int hns_roce_u_v1_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - int ret; - struct ibv_modify_qp cmd = {}; - struct hns_roce_qp *hr_qp = to_hr_qp(qp); - - ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof(cmd)); - - if (!ret && (attr_mask & IBV_QP_STATE) && - attr->qp_state == IBV_QPS_RESET) { - hns_roce_v1_cq_clean(to_hr_cq(qp->recv_cq), qp->qp_num, - qp->srq ? to_hr_srq(qp->srq) : NULL); - if (qp->send_cq != qp->recv_cq) - hns_roce_v1_cq_clean(to_hr_cq(qp->send_cq), qp->qp_num, - NULL); - - hns_roce_init_qp_indices(to_hr_qp(qp)); - } - - if (!ret && (attr_mask & IBV_QP_PORT)) { - hr_qp->port_num = attr->port_num; - printf("hr_qp->port_num= 0x%x\n", hr_qp->port_num); - } - - hr_qp->sl = attr->ah_attr.sl; - - return ret; -} - -static void hns_roce_lock_cqs(struct ibv_qp *qp) -{ - struct hns_roce_cq *send_cq = to_hr_cq(qp->send_cq); - struct hns_roce_cq *recv_cq = to_hr_cq(qp->recv_cq); - - if (send_cq == recv_cq) { - pthread_spin_lock(&send_cq->lock); - } else if (send_cq->cqn < recv_cq->cqn) { - pthread_spin_lock(&send_cq->lock); - pthread_spin_lock(&recv_cq->lock); - } else { - pthread_spin_lock(&recv_cq->lock); - pthread_spin_lock(&send_cq->lock); - } -} - -static void hns_roce_unlock_cqs(struct ibv_qp *qp) -{ - struct hns_roce_cq *send_cq = to_hr_cq(qp->send_cq); - struct hns_roce_cq *recv_cq = to_hr_cq(qp->recv_cq); - - if (send_cq == recv_cq) { - pthread_spin_unlock(&send_cq->lock); - } else if (send_cq->cqn < recv_cq->cqn) { - pthread_spin_unlock(&recv_cq->lock); - pthread_spin_unlock(&send_cq->lock); - } else { - pthread_spin_unlock(&send_cq->lock); - pthread_spin_unlock(&recv_cq->lock); - } -} - -static int hns_roce_u_v1_destroy_qp(struct ibv_qp *ibqp) -{ - int ret; - struct hns_roce_qp *qp = to_hr_qp(ibqp); - - pthread_mutex_lock(&to_hr_ctx(ibqp->context)->qp_table_mutex); - ret = ibv_cmd_destroy_qp(ibqp); - if (ret) { - pthread_mutex_unlock(&to_hr_ctx(ibqp->context)->qp_table_mutex); - return ret; - } - - hns_roce_lock_cqs(ibqp); - - __hns_roce_v1_cq_clean(to_hr_cq(ibqp->recv_cq), ibqp->qp_num, - ibqp->srq ? to_hr_srq(ibqp->srq) : NULL); - - if (ibqp->send_cq != ibqp->recv_cq) - __hns_roce_v1_cq_clean(to_hr_cq(ibqp->send_cq), ibqp->qp_num, - NULL); - - hns_roce_clear_qp(to_hr_ctx(ibqp->context), ibqp->qp_num); - - hns_roce_unlock_cqs(ibqp); - pthread_mutex_unlock(&to_hr_ctx(ibqp->context)->qp_table_mutex); - - free(qp->sq.wrid); - if (qp->rq.wqe_cnt) - free(qp->rq.wrid); - - hns_roce_free_buf(&qp->buf); - free(qp); - - return ret; -} - -static int hns_roce_u_v1_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - int ret = 0; - int nreq; - int ind; - struct ibv_sge *sg; - struct hns_roce_rc_rq_wqe *rq_wqe; - struct hns_roce_qp *qp = to_hr_qp(ibvqp); - struct hns_roce_context *ctx = to_hr_ctx(ibvqp->context); - - pthread_spin_lock(&qp->rq.lock); - - /* check that state is OK to post receive */ - ind = qp->rq.head & (qp->rq.wqe_cnt - 1); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (hns_roce_wq_overflow(&qp->rq, nreq, - to_hr_cq(qp->ibv_qp.recv_cq))) { - ret = -1; - *bad_wr = wr; - goto out; - } - - if (wr->num_sge > qp->rq.max_gs) { - ret = -1; - *bad_wr = wr; - goto out; - } - - rq_wqe = get_recv_wqe(qp, ind); - if (wr->num_sge > HNS_ROCE_RC_RQ_WQE_MAX_SGE_NUM) { - ret = -1; - *bad_wr = wr; - goto out; - } - - if (wr->num_sge == HNS_ROCE_RC_RQ_WQE_MAX_SGE_NUM) { - roce_set_field(rq_wqe->u32_2, - RC_RQ_WQE_NUMBER_OF_DATA_SEG_M, - RC_RQ_WQE_NUMBER_OF_DATA_SEG_S, - HNS_ROCE_RC_RQ_WQE_MAX_SGE_NUM); - sg = wr->sg_list; - - rq_wqe->va0 = (sg->addr); - rq_wqe->l_key0 = (sg->lkey); - rq_wqe->length0 = (sg->length); - - sg = wr->sg_list + 1; - - rq_wqe->va1 = (sg->addr); - rq_wqe->l_key1 = (sg->lkey); - rq_wqe->length1 = (sg->length); - } else if (wr->num_sge == HNS_ROCE_RC_RQ_WQE_MAX_SGE_NUM - 1) { - roce_set_field(rq_wqe->u32_2, - RC_RQ_WQE_NUMBER_OF_DATA_SEG_M, - RC_RQ_WQE_NUMBER_OF_DATA_SEG_S, - HNS_ROCE_RC_RQ_WQE_MAX_SGE_NUM - 1); - sg = wr->sg_list; - - rq_wqe->va0 = (sg->addr); - rq_wqe->l_key0 = (sg->lkey); - rq_wqe->length0 = (sg->length); - - } else if (wr->num_sge == HNS_ROCE_RC_RQ_WQE_MAX_SGE_NUM - 2) { - roce_set_field(rq_wqe->u32_2, - RC_RQ_WQE_NUMBER_OF_DATA_SEG_M, - RC_RQ_WQE_NUMBER_OF_DATA_SEG_S, - HNS_ROCE_RC_RQ_WQE_MAX_SGE_NUM - 2); - } - - qp->rq.wrid[ind] = wr->wr_id; - - ind = (ind + 1) & (qp->rq.wqe_cnt - 1); - } - -out: - if (nreq) { - qp->rq.head += nreq; - - hns_roce_update_rq_head(ctx, qp->ibv_qp.qp_num, - qp->rq.head & ((qp->rq.wqe_cnt << 1) - 1)); - } - - pthread_spin_unlock(&qp->rq.lock); - - return ret; -} - -struct hns_roce_u_hw hns_roce_u_hw_v1 = { - .hw_version = HNS_ROCE_HW_VER1, - .poll_cq = hns_roce_u_v1_poll_cq, - .arm_cq = hns_roce_u_v1_arm_cq, - .post_send = hns_roce_u_v1_post_send, - .post_recv = hns_roce_u_v1_post_recv, - .modify_qp = hns_roce_u_v1_modify_qp, - .destroy_qp = hns_roce_u_v1_destroy_qp, -}; diff --git a/usr/rdma-core/providers/hns/hns_roce_u_hw_v1.h b/usr/rdma-core/providers/hns/hns_roce_u_hw_v1.h deleted file mode 100644 index 5ba34372c..000000000 --- a/usr/rdma-core/providers/hns/hns_roce_u_hw_v1.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2016 Hisilicon Limited. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _HNS_ROCE_U_HW_V1_H -#define _HNS_ROCE_U_HW_V1_H - -#include -#include - -#define HNS_ROCE_CQ_DB_REQ_SOL 1 -#define HNS_ROCE_CQ_DB_REQ_NEXT 0 - -#define HNS_ROCE_CQE_IS_SQ 0 - -#define HNS_ROCE_RC_WQE_INLINE_DATA_MAX_LEN 32 -#define HNS_ROCE_RC_RQ_WQE_MAX_SGE_NUM 2 - -enum { - HNS_ROCE_WQE_INLINE = 1 << 31, - HNS_ROCE_WQE_SE = 1 << 30, - HNS_ROCE_WQE_SGE_NUM_BIT = 24, - HNS_ROCE_WQE_IMM = 1 << 23, - HNS_ROCE_WQE_FENCE = 1 << 21, - HNS_ROCE_WQE_CQ_NOTIFY = 1 << 20, - HNS_ROCE_WQE_OPCODE_SEND = 0 << 16, - HNS_ROCE_WQE_OPCODE_RDMA_READ = 1 << 16, - HNS_ROCE_WQE_OPCODE_RDMA_WRITE = 2 << 16, - HNS_ROCE_WQE_OPCODE_BIND_MW2 = 6 << 16, - HNS_ROCE_WQE_OPCODE_MASK = 15 << 16, -}; - -struct hns_roce_wqe_ctrl_seg { - __be32 sgl_pa_h; - __be32 flag; - __be32 imm_data; - __be32 msg_length; -}; - -struct hns_roce_wqe_data_seg { - __be64 addr; - __be32 lkey; - __be32 len; -}; - -struct hns_roce_wqe_raddr_seg { - __be32 rkey; - __be32 len; - __be64 raddr; -}; - -enum { - CQ_OK = 0, - CQ_EMPTY = -1, - CQ_POLL_ERR = -2, -}; - -enum { - HNS_ROCE_CQE_QPN_MASK = 0x3ffff, - HNS_ROCE_CQE_STATUS_MASK = 0x1f, - HNS_ROCE_CQE_OPCODE_MASK = 0xf, -}; - -enum { - HNS_ROCE_CQE_SUCCESS, - HNS_ROCE_CQE_SYNDROME_LOCAL_LENGTH_ERR, - HNS_ROCE_CQE_SYNDROME_LOCAL_QP_OP_ERR, - HNS_ROCE_CQE_SYNDROME_LOCAL_PROT_ERR, - HNS_ROCE_CQE_SYNDROME_WR_FLUSH_ERR, - HNS_ROCE_CQE_SYNDROME_MEM_MANAGE_OPERATE_ERR, - HNS_ROCE_CQE_SYNDROME_BAD_RESP_ERR, - HNS_ROCE_CQE_SYNDROME_LOCAL_ACCESS_ERR, - HNS_ROCE_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR, - HNS_ROCE_CQE_SYNDROME_REMOTE_ACCESS_ERR, - HNS_ROCE_CQE_SYNDROME_REMOTE_OP_ERR, - HNS_ROCE_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR, - HNS_ROCE_CQE_SYNDROME_RNR_RETRY_EXC_ERR, -}; - -struct hns_roce_cq_db { - unsigned int u32_4; - unsigned int u32_8; -}; -#define CQ_DB_U32_4_CONS_IDX_S 0 -#define CQ_DB_U32_4_CONS_IDX_M (((1UL << 16) - 1) << CQ_DB_U32_4_CONS_IDX_S) - -#define CQ_DB_U32_8_CQN_S 0 -#define CQ_DB_U32_8_CQN_M (((1UL << 16) - 1) << CQ_DB_U32_8_CQN_S) - -#define CQ_DB_U32_8_NOTIFY_TYPE_S 16 - -#define CQ_DB_U32_8_CMD_MDF_S 24 -#define CQ_DB_U32_8_CMD_MDF_M (((1UL << 4) - 1) << CQ_DB_U32_8_CMD_MDF_S) - -#define CQ_DB_U32_8_CMD_S 28 -#define CQ_DB_U32_8_CMD_M (((1UL << 3) - 1) << CQ_DB_U32_8_CMD_S) - -#define CQ_DB_U32_8_HW_SYNC_S 31 - -struct hns_roce_rq_db { - unsigned int u32_4; - unsigned int u32_8; -}; - -#define RQ_DB_U32_4_RQ_HEAD_S 0 -#define RQ_DB_U32_4_RQ_HEAD_M (((1UL << 15) - 1) << RQ_DB_U32_4_RQ_HEAD_S) - -#define RQ_DB_U32_8_QPN_S 0 -#define RQ_DB_U32_8_QPN_M (((1UL << 24) - 1) << RQ_DB_U32_8_QPN_S) - -#define RQ_DB_U32_8_CMD_S 28 -#define RQ_DB_U32_8_CMD_M (((1UL << 3) - 1) << RQ_DB_U32_8_CMD_S) - -#define RQ_DB_U32_8_HW_SYNC_S 31 - -struct hns_roce_sq_db { - unsigned int u32_4; - unsigned int u32_8; -}; - -#define SQ_DB_U32_4_SQ_HEAD_S 0 -#define SQ_DB_U32_4_SQ_HEAD_M (((1UL << 15) - 1) << SQ_DB_U32_4_SQ_HEAD_S) - -#define SQ_DB_U32_4_SL_S 16 -#define SQ_DB_U32_4_SL_M (((1UL << 2) - 1) << SQ_DB_U32_4_SL_S) - -#define SQ_DB_U32_4_PORT_S 18 -#define SQ_DB_U32_4_PORT_M (((1UL << 3) - 1) << SQ_DB_U32_4_PORT_S) - -#define SQ_DB_U32_4_DIRECT_WQE_S 31 - -#define SQ_DB_U32_8_QPN_S 0 -#define SQ_DB_U32_8_QPN_M (((1UL << 24) - 1) << SQ_DB_U32_8_QPN_S) - -#define SQ_DB_U32_8_HW_SYNC 31 - -struct hns_roce_cqe { - unsigned int cqe_byte_4; - union { - unsigned int r_key; - unsigned int immediate_data; - }; - unsigned int byte_cnt; - unsigned int cqe_byte_16; - unsigned int cqe_byte_20; - unsigned int s_mac_l; - unsigned int cqe_byte_28; - unsigned int reserved; -}; -#define CQE_BYTE_4_OPERATION_TYPE_S 0 -#define CQE_BYTE_4_OPERATION_TYPE_M \ - (((1UL << 4) - 1) << CQE_BYTE_4_OPERATION_TYPE_S) - -#define CQE_BYTE_4_OWNER_S 7 - -#define CQE_BYTE_4_STATUS_OF_THE_OPERATION_S 8 -#define CQE_BYTE_4_STATUS_OF_THE_OPERATION_M \ - (((1UL << 5) - 1) << CQE_BYTE_4_STATUS_OF_THE_OPERATION_S) - -#define CQE_BYTE_4_SQ_RQ_FLAG_S 14 - -#define CQE_BYTE_4_IMMEDIATE_DATA_FLAG_S 15 - -#define CQE_BYTE_4_WQE_INDEX_S 16 -#define CQE_BYTE_4_WQE_INDEX_M (((1UL << 14) - 1) << CQE_BYTE_4_WQE_INDEX_S) - -#define CQE_BYTE_16_LOCAL_QPN_S 0 -#define CQE_BYTE_16_LOCAL_QPN_M (((1UL << 24) - 1) << CQE_BYTE_16_LOCAL_QPN_S) - -#define ROCEE_DB_SQ_L_0_REG 0x230 - -#define ROCEE_DB_OTHERS_L_0_REG 0x238 - -struct hns_roce_rc_send_wqe { - unsigned int sgl_ba_31_0; - unsigned int u32_1; - union { - unsigned int r_key; - unsigned int immediate_data; - }; - unsigned int msg_length; - unsigned int rvd_3; - unsigned int rvd_4; - unsigned int rvd_5; - unsigned int rvd_6; - uint64_t va0; - unsigned int l_key0; - unsigned int length0; - - uint64_t va1; - unsigned int l_key1; - unsigned int length1; -}; - -struct hns_roce_rc_rq_wqe { - unsigned int u32_0; - unsigned int sgl_ba_31_0; - unsigned int u32_2; - unsigned int rvd_5; - unsigned int rvd_6; - unsigned int rvd_7; - unsigned int rvd_8; - unsigned int rvd_9; - - uint64_t va0; - unsigned int l_key0; - unsigned int length0; - - uint64_t va1; - unsigned int l_key1; - unsigned int length1; -}; -#define RC_RQ_WQE_NUMBER_OF_DATA_SEG_S 16 -#define RC_RQ_WQE_NUMBER_OF_DATA_SEG_M \ - (((1UL << 6) - 1) << RC_RQ_WQE_NUMBER_OF_DATA_SEG_S) - -#endif /* _HNS_ROCE_U_HW_V1_H */ diff --git a/usr/rdma-core/providers/hns/hns_roce_u_verbs.c b/usr/rdma-core/providers/hns/hns_roce_u_verbs.c deleted file mode 100644 index 0b8f444f4..000000000 --- a/usr/rdma-core/providers/hns/hns_roce_u_verbs.c +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright (c) 2016 Hisilicon Limited. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "hns_roce_u.h" -#include "hns_roce_u_abi.h" -#include "hns_roce_u_hw_v1.h" - -void hns_roce_init_qp_indices(struct hns_roce_qp *qp) -{ - qp->sq.head = 0; - qp->sq.tail = 0; - qp->rq.head = 0; - qp->rq.tail = 0; -} - -int hns_roce_u_query_device(struct ibv_context *context, - struct ibv_device_attr *attr) -{ - int ret; - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned int major, minor, sub_minor; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, - sizeof(cmd)); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof(attr->fw_ver), "%d.%d.%03d", major, minor, - sub_minor); - - return 0; -} - -int hns_roce_u_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof(cmd)); -} - -struct ibv_pd *hns_roce_u_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct hns_roce_pd *pd; - struct hns_roce_alloc_pd_resp resp; - - pd = (struct hns_roce_pd *)malloc(sizeof(*pd)); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp))) { - free(pd); - return NULL; - } - - pd->pdn = resp.pdn; - - return &pd->ibv_pd; -} - -int hns_roce_u_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - free(to_hr_pd(pd)); - - return ret; -} - -struct ibv_mr *hns_roce_u_reg_mr(struct ibv_pd *pd, void *addr, size_t length, - int access) -{ - int ret; - struct ibv_mr *mr; - struct ibv_reg_mr cmd; - struct ibv_reg_mr_resp resp; - - if (!addr) { - fprintf(stderr, "2nd parm addr is NULL!\n"); - return NULL; - } - - if (!length) { - fprintf(stderr, "3st parm length is 0!\n"); - return NULL; - } - - mr = malloc(sizeof(*mr)); - if (!mr) - return NULL; - - ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, access, mr, - &cmd, sizeof(cmd), &resp, sizeof(resp)); - if (ret) { - free(mr); - return NULL; - } - - return mr; -} - -int hns_roce_u_dereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - free(mr); - - return ret; -} - -static int align_cq_size(int req) -{ - int nent; - - for (nent = HNS_ROCE_MIN_CQE_NUM; nent < req; nent <<= 1) - ; - - return nent; -} - -static int align_qp_size(int req) -{ - int nent; - - for (nent = HNS_ROCE_MIN_WQE_NUM; nent < req; nent <<= 1) - ; - - return nent; -} - -static void hns_roce_set_sq_sizes(struct hns_roce_qp *qp, - struct ibv_qp_cap *cap, enum ibv_qp_type type) -{ - struct hns_roce_context *ctx = to_hr_ctx(qp->ibv_qp.context); - - qp->sq.max_gs = 2; - cap->max_send_sge = min(ctx->max_sge, qp->sq.max_gs); - qp->sq.max_post = min(ctx->max_qp_wr, qp->sq.wqe_cnt); - cap->max_send_wr = qp->sq.max_post; - qp->max_inline_data = 32; - cap->max_inline_data = qp->max_inline_data; -} - -static int hns_roce_verify_cq(int *cqe, struct hns_roce_context *context) -{ - if (*cqe < HNS_ROCE_MIN_CQE_NUM) { - fprintf(stderr, "cqe = %d, less than minimum CQE number.\n", - *cqe); - *cqe = HNS_ROCE_MIN_CQE_NUM; - } - - if (*cqe > context->max_cqe) - return -1; - - return 0; -} - -static int hns_roce_alloc_cq_buf(struct hns_roce_device *dev, - struct hns_roce_buf *buf, int nent) -{ - if (hns_roce_alloc_buf(buf, - align(nent * HNS_ROCE_CQE_ENTRY_SIZE, dev->page_size), - dev->page_size)) - return -1; - memset(buf->buf, 0, nent * HNS_ROCE_CQE_ENTRY_SIZE); - - return 0; -} - -static void hns_roce_calc_sq_wqe_size(struct ibv_qp_cap *cap, - enum ibv_qp_type type, - struct hns_roce_qp *qp) -{ - int size = sizeof(struct hns_roce_rc_send_wqe); - - for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size; - qp->sq.wqe_shift++) - ; -} - -struct ibv_cq *hns_roce_u_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct hns_roce_create_cq cmd; - struct hns_roce_create_cq_resp resp; - struct hns_roce_cq *cq; - int ret; - - if (hns_roce_verify_cq(&cqe, to_hr_ctx(context))) - return NULL; - - cq = malloc(sizeof(*cq)); - if (!cq) - return NULL; - - cq->cons_index = 0; - - if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE)) - goto err; - - cqe = align_cq_size(cqe); - - if (hns_roce_alloc_cq_buf(to_hr_dev(context->device), &cq->buf, cqe)) - goto err; - - cmd.buf_addr = (uintptr_t) cq->buf.buf; - - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &cq->ibv_cq, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (ret) - goto err_db; - - cq->cqn = resp.cqn; - cq->cq_depth = cqe; - - if (to_hr_dev(context->device)->hw_version == HNS_ROCE_HW_VER1) - cq->set_ci_db = to_hr_ctx(context)->cq_tptr_base + cq->cqn * 2; - else - cq->set_ci_db = to_hr_ctx(context)->uar + - ROCEE_DB_OTHERS_L_0_REG; - - cq->arm_db = cq->set_ci_db; - cq->arm_sn = 1; - *(cq->set_ci_db) = 0; - *(cq->arm_db) = 0; - - return &cq->ibv_cq; - -err_db: - hns_roce_free_buf(&cq->buf); - -err: - free(cq); - - return NULL; -} - -void hns_roce_u_cq_event(struct ibv_cq *cq) -{ - to_hr_cq(cq)->arm_sn++; -} - -int hns_roce_u_destroy_cq(struct ibv_cq *cq) -{ - int ret; - - ret = ibv_cmd_destroy_cq(cq); - if (ret) - return ret; - - hns_roce_free_buf(&to_hr_cq(cq)->buf); - free(to_hr_cq(cq)); - - return ret; -} - -static int hns_roce_verify_qp(struct ibv_qp_init_attr *attr, - struct hns_roce_context *context) -{ - if (attr->cap.max_send_wr < HNS_ROCE_MIN_WQE_NUM) { - fprintf(stderr, - "max_send_wr = %d, less than minimum WQE number.\n", - attr->cap.max_send_wr); - attr->cap.max_send_wr = HNS_ROCE_MIN_WQE_NUM; - } - - if (attr->cap.max_recv_wr < HNS_ROCE_MIN_WQE_NUM) { - fprintf(stderr, - "max_recv_wr = %d, less than minimum WQE number.\n", - attr->cap.max_recv_wr); - attr->cap.max_recv_wr = HNS_ROCE_MIN_WQE_NUM; - } - - if (attr->cap.max_recv_sge < 1) - attr->cap.max_recv_sge = 1; - if (attr->cap.max_send_wr > context->max_qp_wr || - attr->cap.max_recv_wr > context->max_qp_wr || - attr->cap.max_send_sge > context->max_sge || - attr->cap.max_recv_sge > context->max_sge) - return -1; - - if ((attr->qp_type != IBV_QPT_RC) && (attr->qp_type != IBV_QPT_UD)) - return -1; - - if ((attr->qp_type == IBV_QPT_RC) && - (attr->cap.max_inline_data > HNS_ROCE_RC_WQE_INLINE_DATA_MAX_LEN)) - return -1; - - if (attr->qp_type == IBV_QPT_UC) - return -1; - - return 0; -} - -static int hns_roce_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap, - enum ibv_qp_type type, struct hns_roce_qp *qp) -{ - qp->sq.wrid = - (unsigned long *)malloc(qp->sq.wqe_cnt * sizeof(uint64_t)); - if (!qp->sq.wrid) - return -1; - - if (qp->rq.wqe_cnt) { - qp->rq.wrid = malloc(qp->rq.wqe_cnt * sizeof(uint64_t)); - if (!qp->rq.wrid) { - free(qp->sq.wrid); - return -1; - } - } - - for (qp->rq.wqe_shift = 4; - 1 << qp->rq.wqe_shift < sizeof(struct hns_roce_rc_send_wqe); - qp->rq.wqe_shift++) - ; - - qp->buf_size = align((qp->sq.wqe_cnt << qp->sq.wqe_shift), 0x1000) + - (qp->rq.wqe_cnt << qp->rq.wqe_shift); - - if (qp->rq.wqe_shift > qp->sq.wqe_shift) { - qp->rq.offset = 0; - qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift; - } else { - qp->rq.offset = align((qp->sq.wqe_cnt << qp->sq.wqe_shift), - 0x1000); - qp->sq.offset = 0; - } - - if (hns_roce_alloc_buf(&qp->buf, align(qp->buf_size, 0x1000), - to_hr_dev(pd->context->device)->page_size)) { - free(qp->sq.wrid); - free(qp->rq.wrid); - return -1; - } - - memset(qp->buf.buf, 0, qp->buf_size); - - return 0; -} - -static int hns_roce_store_qp(struct hns_roce_context *ctx, uint32_t qpn, - struct hns_roce_qp *qp) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (!ctx->qp_table[tind].refcnt) { - ctx->qp_table[tind].table = calloc(ctx->qp_table_mask + 1, - sizeof(struct hns_roce_qp *)); - if (!ctx->qp_table[tind].table) - return -1; - } - - ++ctx->qp_table[tind].refcnt; - ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = qp; - - return 0; -} - -struct ibv_qp *hns_roce_u_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - int ret; - struct hns_roce_qp *qp = NULL; - struct hns_roce_create_qp cmd; - struct ibv_create_qp_resp resp; - struct hns_roce_context *context = to_hr_ctx(pd->context); - - if (hns_roce_verify_qp(attr, context)) { - fprintf(stderr, "hns_roce_verify_sizes failed!\n"); - return NULL; - } - - qp = malloc(sizeof(*qp)); - if (!qp) { - fprintf(stderr, "malloc failed!\n"); - return NULL; - } - - hns_roce_calc_sq_wqe_size(&attr->cap, attr->qp_type, qp); - qp->sq.wqe_cnt = align_qp_size(attr->cap.max_send_wr); - qp->rq.wqe_cnt = align_qp_size(attr->cap.max_recv_wr); - - if (hns_roce_alloc_qp_buf(pd, &attr->cap, attr->qp_type, qp)) { - fprintf(stderr, "hns_roce_alloc_qp_buf failed!\n"); - goto err; - } - - hns_roce_init_qp_indices(qp); - - if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) || - pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE)) { - fprintf(stderr, "pthread_spin_init failed!\n"); - goto err_free; - } - - cmd.buf_addr = (uintptr_t) qp->buf.buf; - cmd.log_sq_stride = qp->sq.wqe_shift; - for (cmd.log_sq_bb_count = 0; qp->sq.wqe_cnt > 1 << cmd.log_sq_bb_count; - ++cmd.log_sq_bb_count) - ; - - memset(cmd.reserved, 0, sizeof(cmd.reserved)); - - pthread_mutex_lock(&to_hr_ctx(pd->context)->qp_table_mutex); - - ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd.ibv_cmd, - sizeof(cmd), &resp, sizeof(resp)); - if (ret) { - fprintf(stderr, "ibv_cmd_create_qp failed!\n"); - goto err_rq_db; - } - - ret = hns_roce_store_qp(to_hr_ctx(pd->context), qp->ibv_qp.qp_num, qp); - if (ret) { - fprintf(stderr, "hns_roce_store_qp failed!\n"); - goto err_destroy; - } - pthread_mutex_unlock(&to_hr_ctx(pd->context)->qp_table_mutex); - - qp->rq.wqe_cnt = attr->cap.max_recv_wr; - qp->rq.max_gs = attr->cap.max_recv_sge; - - /* adjust rq maxima to not exceed reported device maxima */ - attr->cap.max_recv_wr = min(context->max_qp_wr, attr->cap.max_recv_wr); - attr->cap.max_recv_sge = min(context->max_sge, attr->cap.max_recv_sge); - - qp->rq.max_post = attr->cap.max_recv_wr; - hns_roce_set_sq_sizes(qp, &attr->cap, attr->qp_type); - - qp->sq_signal_bits = attr->sq_sig_all ? 0 : 1; - - return &qp->ibv_qp; - -err_destroy: - ibv_cmd_destroy_qp(&qp->ibv_qp); - -err_rq_db: - pthread_mutex_unlock(&to_hr_ctx(pd->context)->qp_table_mutex); - -err_free: - free(qp->sq.wrid); - if (qp->rq.wqe_cnt) - free(qp->rq.wrid); - hns_roce_free_buf(&qp->buf); - -err: - free(qp); - - return NULL; -} - -int hns_roce_u_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr) -{ - int ret; - struct ibv_query_qp cmd; - struct hns_roce_qp *qp = to_hr_qp(ibqp); - - ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, - sizeof(cmd)); - if (ret) - return ret; - - init_attr->cap.max_send_wr = qp->sq.max_post; - init_attr->cap.max_send_sge = qp->sq.max_gs; - init_attr->cap.max_inline_data = qp->max_inline_data; - - attr->cap = init_attr->cap; - - return ret; -} diff --git a/usr/rdma-core/providers/i40iw/CMakeLists.txt b/usr/rdma-core/providers/i40iw/CMakeLists.txt deleted file mode 100644 index d8a3a3c2c..000000000 --- a/usr/rdma-core/providers/i40iw/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -rdma_provider(i40iw - i40iw_uk.c - i40iw_umain.c - i40iw_uverbs.c -) diff --git a/usr/rdma-core/providers/i40iw/i40e_devids.h b/usr/rdma-core/providers/i40iw/i40e_devids.h deleted file mode 100644 index 6c09a6651..000000000 --- a/usr/rdma-core/providers/i40iw/i40e_devids.h +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#ifndef _I40E_DEVIDS_H_ -#define _I40E_DEVIDS_H_ - -/* Vendor ID */ -#define I40E_INTEL_VENDOR_ID 0x8086 - -/* Device IDs */ -#define I40E_DEV_ID_SFP_XL710 0x1572 -#define I40E_DEV_ID_QEMU 0x1574 -#define I40E_DEV_ID_KX_B 0x1580 -#define I40E_DEV_ID_KX_C 0x1581 -#define I40E_DEV_ID_QSFP_A 0x1583 -#define I40E_DEV_ID_QSFP_B 0x1584 -#define I40E_DEV_ID_QSFP_C 0x1585 -#define I40E_DEV_ID_10G_BASE_T 0x1586 -#define I40E_DEV_ID_20G_KR2 0x1587 -#define I40E_DEV_ID_20G_KR2_A 0x1588 -#define I40E_DEV_ID_10G_BASE_T4 0x1589 -#define I40E_DEV_ID_25G_B 0x158A -#define I40E_DEV_ID_25G_SFP28 0x158B -#define I40E_DEV_ID_VF 0x154C -#define I40E_DEV_ID_VF_HV 0x1571 -#define I40E_DEV_ID_X722_A0 0x374C -#define I40E_DEV_ID_X722_A0_VF 0x374D -#define I40E_DEV_ID_KX_X722 0x37CE -#define I40E_DEV_ID_QSFP_X722 0x37CF -#define I40E_DEV_ID_SFP_X722 0x37D0 -#define I40E_DEV_ID_1G_BASE_T_X722 0x37D1 -#define I40E_DEV_ID_10G_BASE_T_X722 0x37D2 -#define I40E_DEV_ID_SFP_I_X722 0x37D3 -#define I40E_DEV_ID_X722_VF 0x37CD -#define I40E_DEV_ID_X722_VF_HV 0x37D9 - -#define i40e_is_40G_device(d) ((d) == I40E_DEV_ID_QSFP_A || \ - (d) == I40E_DEV_ID_QSFP_B || \ - (d) == I40E_DEV_ID_QSFP_C) - -#endif /* _I40E_DEVIDS_H_ */ diff --git a/usr/rdma-core/providers/i40iw/i40iw-abi.h b/usr/rdma-core/providers/i40iw/i40iw-abi.h deleted file mode 100644 index df2df0765..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw-abi.h +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#ifndef I40IW_ABI_H -#define I40IW_ABI_H - -#include - -#define I40IW_ABI_VER 5 - -struct i40iw_get_context { - struct ibv_get_context cmd; - __u32 reserved32; - __u8 userspace_ver; - __u8 reserved8[3]; -}; - -struct i40iw_ualloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - __u32 max_pds; /* maximum pds allowed for this user process */ - __u32 max_qps; /* maximum qps allowed for this user process */ - __u32 wq_size; /* defines the size of the WQs (sq+rq) allocated to the mmaped area */ - __u8 kernel_ver; - __u8 reserved[3]; -}; - -struct i40iw_ualloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - __u32 pd_id; - __u8 reserved[4]; -}; - -struct i40iw_ucreate_cq { - struct ibv_create_cq ibv_cmd; - __u64 user_cq_buffer; -}; - -struct i40iw_ucreate_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u32 cq_id; - __u32 cq_size; - __u32 mmap_db_index; - __u32 reserved; -}; - -enum i40iw_umemreg_type { - I40IW_UMEMREG_TYPE_MEM = 0x0000, - I40IW_UMEMREG_TYPE_QP = 0x0001, - I40IW_UMEMREG_TYPE_CQ = 0x0002 -}; - -struct i40iw_ureg_mr { - struct ibv_reg_mr ibv_cmd; - __u16 reg_type; - __u16 cq_pages; - __u16 rq_pages; - __u16 sq_pages; -}; - -struct i40iw_ucreate_qp { - struct ibv_create_qp ibv_cmd; - __u64 user_wqe_buffers; - __u64 user_compl_ctx; -}; - -struct i40iw_ucreate_qp_resp { - struct ibv_create_qp_resp ibv_resp; - __u32 qp_id; - __u32 actual_sq_size; - __u32 actual_rq_size; - __u32 i40iw_drv_opt; - __u16 push_idx; - __u8 rsvd1; - __u8 rsvd2; -}; - -#endif /* I40IW_ABI_H */ diff --git a/usr/rdma-core/providers/i40iw/i40iw_d.h b/usr/rdma-core/providers/i40iw/i40iw_d.h deleted file mode 100644 index 174115c39..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_d.h +++ /dev/null @@ -1,1744 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#ifndef I40IW_D_H -#define I40IW_D_H - -#define I40IW_DB_ADDR_OFFSET (4 * 1024 * 1024 - 64 * 1024) -#define I40IW_VF_DB_ADDR_OFFSET (64 * 1024) - -#define I40IW_PUSH_OFFSET (4 * 1024 * 1024) -#define I40IW_PF_FIRST_PUSH_PAGE_INDEX 16 -#define I40IW_VF_PUSH_OFFSET ((8 + 64) * 1024) -#define I40IW_VF_FIRST_PUSH_PAGE_INDEX 2 - -#define I40IW_PE_DB_SIZE_4M 1 -#define I40IW_PE_DB_SIZE_8M 2 - -#define I40IW_DDP_VER 1 -#define I40IW_RDMAP_VER 1 - -#define I40IW_RDMA_MODE_RDMAC 0 -#define I40IW_RDMA_MODE_IETF 1 - -#define I40IW_QP_STATE_INVALID 0 -#define I40IW_QP_STATE_IDLE 1 -#define I40IW_QP_STATE_RTS 2 -#define I40IW_QP_STATE_CLOSING 3 -#define I40IW_QP_STATE_RESERVED 4 -#define I40IW_QP_STATE_TERMINATE 5 -#define I40IW_QP_STATE_ERROR 6 - -#define I40IW_STAG_STATE_INVALID 0 -#define I40IW_STAG_STATE_VALID 1 - -#define I40IW_STAG_TYPE_SHARED 0 -#define I40IW_STAG_TYPE_NONSHARED 1 - -#define I40IW_MAX_USER_PRIORITY 8 - -#define LS_64_1(val, bits) ((u64)(uintptr_t)val << bits) -#define RS_64_1(val, bits) ((u64)(uintptr_t)val >> bits) -#define LS_32_1(val, bits) (u32)(val << bits) -#define RS_32_1(val, bits) (u32)(val >> bits) -#define I40E_HI_DWORD(x) ((u32)((((x) >> 16) >> 16) & 0xFFFFFFFF)) - -#define LS_64(val, field) (((u64)val << field ## _SHIFT) & (field ## _MASK)) - -#define RS_64(val, field) ((u64)(val & field ## _MASK) >> field ## _SHIFT) -#define LS_32(val, field) ((val << field ## _SHIFT) & (field ## _MASK)) -#define RS_32(val, field) ((val & field ## _MASK) >> field ## _SHIFT) - -#define TERM_DDP_LEN_TAGGED 14 -#define TERM_DDP_LEN_UNTAGGED 18 -#define TERM_RDMA_LEN 28 -#define RDMA_OPCODE_MASK 0x0f -#define RDMA_READ_REQ_OPCODE 1 -#define Q2_BAD_FRAME_OFFSET 72 -#define CQE_MAJOR_DRV 0x8000 - -#define I40IW_TERM_SENT 0x01 -#define I40IW_TERM_RCVD 0x02 -#define I40IW_TERM_DONE 0x04 -#define I40IW_MAC_HLEN 14 -#define I40IW_BYTE_0 0 -#define I40IW_BYTE_8 8 -#define I40IW_BYTE_16 16 -#define I40IW_BYTE_24 24 -#define I40IW_BYTE_32 32 -#define I40IW_BYTE_40 40 -#define I40IW_BYTE_48 48 -#define I40IW_BYTE_56 56 -#define I40IW_BYTE_64 64 -#define I40IW_BYTE_72 72 -#define I40IW_BYTE_80 80 -#define I40IW_BYTE_88 88 -#define I40IW_BYTE_96 96 -#define I40IW_BYTE_104 104 -#define I40IW_BYTE_112 112 -#define I40IW_BYTE_120 120 -#define I40IW_BYTE_128 128 -#define I40IW_BYTE_136 136 -#define I40IW_BYTE_144 144 -#define I40IW_BYTE_152 152 -#define I40IW_BYTE_160 160 -#define I40IW_BYTE_168 168 -#define I40IW_BYTE_176 176 -#define I40IW_BYTE_184 184 -#define I40IW_BYTE_192 192 -#define I40IW_BYTE_200 200 -#define I40IW_BYTE_208 208 - -#define I40IW_INVALID_WQE_INDEX 0xffffffff - -#define I40IW_CQP_WAIT_POLL_REGS 1 -#define I40IW_CQP_WAIT_POLL_CQ 2 -#define I40IW_CQP_WAIT_EVENT 3 - -#define I40IW_CQP_INIT_WQE(wqe) memset(wqe, 0, 64) - -#define I40IW_GET_CURRENT_CQ_ELEMENT(_cq) \ - ( \ - &((_cq)->cq_base[I40IW_RING_GETCURRENT_HEAD((_cq)->cq_ring)]) \ - ) -#define I40IW_GET_CURRENT_EXTENDED_CQ_ELEMENT(_cq) \ - ( \ - &(((struct i40iw_extended_cqe *) \ - ((_cq)->cq_base))[I40IW_RING_GETCURRENT_HEAD((_cq)->cq_ring)]) \ - ) - -#define I40IW_GET_CURRENT_AEQ_ELEMENT(_aeq) \ - ( \ - &_aeq->aeqe_base[I40IW_RING_GETCURRENT_TAIL(_aeq->aeq_ring)] \ - ) - -#define I40IW_GET_CURRENT_CEQ_ELEMENT(_ceq) \ - ( \ - &_ceq->ceqe_base[I40IW_RING_GETCURRENT_TAIL(_ceq->ceq_ring)] \ - ) - -#define I40IW_AE_SOURCE_RQ 0x1 -#define I40IW_AE_SOURCE_RQ_0011 0x3 - -#define I40IW_AE_SOURCE_CQ 0x2 -#define I40IW_AE_SOURCE_CQ_0110 0x6 -#define I40IW_AE_SOURCE_CQ_1010 0xA -#define I40IW_AE_SOURCE_CQ_1110 0xE - -#define I40IW_AE_SOURCE_SQ 0x5 -#define I40IW_AE_SOURCE_SQ_0111 0x7 - -#define I40IW_AE_SOURCE_IN_RR_WR 0x9 -#define I40IW_AE_SOURCE_IN_RR_WR_1011 0xB -#define I40IW_AE_SOURCE_OUT_RR 0xD -#define I40IW_AE_SOURCE_OUT_RR_1111 0xF - -#define I40IW_TCP_STATE_NON_EXISTENT 0 -#define I40IW_TCP_STATE_CLOSED 1 -#define I40IW_TCP_STATE_LISTEN 2 -#define I40IW_STATE_SYN_SEND 3 -#define I40IW_TCP_STATE_SYN_RECEIVED 4 -#define I40IW_TCP_STATE_ESTABLISHED 5 -#define I40IW_TCP_STATE_CLOSE_WAIT 6 -#define I40IW_TCP_STATE_FIN_WAIT_1 7 -#define I40IW_TCP_STATE_CLOSING 8 -#define I40IW_TCP_STATE_LAST_ACK 9 -#define I40IW_TCP_STATE_FIN_WAIT_2 10 -#define I40IW_TCP_STATE_TIME_WAIT 11 -#define I40IW_TCP_STATE_RESERVED_1 12 -#define I40IW_TCP_STATE_RESERVED_2 13 -#define I40IW_TCP_STATE_RESERVED_3 14 -#define I40IW_TCP_STATE_RESERVED_4 15 - -/* ILQ CQP hash table fields */ -#define I40IW_CQPSQ_QHASH_VLANID_SHIFT 32 -#define I40IW_CQPSQ_QHASH_VLANID_MASK \ - ((u64)0xfff << I40IW_CQPSQ_QHASH_VLANID_SHIFT) - -#define I40IW_CQPSQ_QHASH_QPN_SHIFT 32 -#define I40IW_CQPSQ_QHASH_QPN_MASK \ - ((u64)0x3ffff << I40IW_CQPSQ_QHASH_QPN_SHIFT) - -#define I40IW_CQPSQ_QHASH_QS_HANDLE_SHIFT 0 -#define I40IW_CQPSQ_QHASH_QS_HANDLE_MASK ((u64)0x3ff << I40IW_CQPSQ_QHASH_QS_HANDLE_SHIFT) - -#define I40IW_CQPSQ_QHASH_SRC_PORT_SHIFT 16 -#define I40IW_CQPSQ_QHASH_SRC_PORT_MASK \ - ((u64)0xffff << I40IW_CQPSQ_QHASH_SRC_PORT_SHIFT) - -#define I40IW_CQPSQ_QHASH_DEST_PORT_SHIFT 0 -#define I40IW_CQPSQ_QHASH_DEST_PORT_MASK \ - ((u64)0xffff << I40IW_CQPSQ_QHASH_DEST_PORT_SHIFT) - -#define I40IW_CQPSQ_QHASH_ADDR0_SHIFT 32 -#define I40IW_CQPSQ_QHASH_ADDR0_MASK \ - ((u64)0xffffffff << I40IW_CQPSQ_QHASH_ADDR0_SHIFT) - -#define I40IW_CQPSQ_QHASH_ADDR1_SHIFT 0 -#define I40IW_CQPSQ_QHASH_ADDR1_MASK \ - ((u64)0xffffffff << I40IW_CQPSQ_QHASH_ADDR1_SHIFT) - -#define I40IW_CQPSQ_QHASH_ADDR2_SHIFT 32 -#define I40IW_CQPSQ_QHASH_ADDR2_MASK \ - ((u64)0xffffffff << I40IW_CQPSQ_QHASH_ADDR2_SHIFT) - -#define I40IW_CQPSQ_QHASH_ADDR3_SHIFT 0 -#define I40IW_CQPSQ_QHASH_ADDR3_MASK \ - ((u64)0xffffffff << I40IW_CQPSQ_QHASH_ADDR3_SHIFT) - -#define I40IW_CQPSQ_QHASH_WQEVALID_SHIFT 63 -#define I40IW_CQPSQ_QHASH_WQEVALID_MASK \ - ((u64)0x1 << I40IW_CQPSQ_QHASH_WQEVALID_SHIFT) -#define I40IW_CQPSQ_QHASH_OPCODE_SHIFT 32 -#define I40IW_CQPSQ_QHASH_OPCODE_MASK \ - ((u64)0x3f << I40IW_CQPSQ_QHASH_OPCODE_SHIFT) - -#define I40IW_CQPSQ_QHASH_MANAGE_SHIFT 61 -#define I40IW_CQPSQ_QHASH_MANAGE_MASK \ - ((u64)0x3 << I40IW_CQPSQ_QHASH_MANAGE_SHIFT) - -#define I40IW_CQPSQ_QHASH_IPV4VALID_SHIFT 60 -#define I40IW_CQPSQ_QHASH_IPV4VALID_MASK \ - ((u64)0x1 << I40IW_CQPSQ_QHASH_IPV4VALID_SHIFT) - -#define I40IW_CQPSQ_QHASH_VLANVALID_SHIFT 59 -#define I40IW_CQPSQ_QHASH_VLANVALID_MASK \ - ((u64)0x1 << I40IW_CQPSQ_QHASH_VLANVALID_SHIFT) - -#define I40IW_CQPSQ_QHASH_ENTRYTYPE_SHIFT 42 -#define I40IW_CQPSQ_QHASH_ENTRYTYPE_MASK \ - ((u64)0x7 << I40IW_CQPSQ_QHASH_ENTRYTYPE_SHIFT) -/* CQP Host Context */ -#define I40IW_CQPHC_EN_DC_TCP_SHIFT 0 -#define I40IW_CQPHC_EN_DC_TCP_MASK (1UL << I40IW_CQPHC_EN_DC_TCP_SHIFT) - -#define I40IW_CQPHC_SQSIZE_SHIFT 8 -#define I40IW_CQPHC_SQSIZE_MASK (0xfUL << I40IW_CQPHC_SQSIZE_SHIFT) - -#define I40IW_CQPHC_DISABLE_PFPDUS_SHIFT 1 -#define I40IW_CQPHC_DISABLE_PFPDUS_MASK (0x1UL << I40IW_CQPHC_DISABLE_PFPDUS_SHIFT) - -#define I40IW_CQPHC_ENABLED_VFS_SHIFT 32 -#define I40IW_CQPHC_ENABLED_VFS_MASK (0x3fULL << I40IW_CQPHC_ENABLED_VFS_SHIFT) - -#define I40IW_CQPHC_HMC_PROFILE_SHIFT 0 -#define I40IW_CQPHC_HMC_PROFILE_MASK (0x7ULL << I40IW_CQPHC_HMC_PROFILE_SHIFT) - -#define I40IW_CQPHC_SVER_SHIFT 24 -#define I40IW_CQPHC_SVER_MASK (0xffUL << I40IW_CQPHC_SVER_SHIFT) - -#define I40IW_CQPHC_SQBASE_SHIFT 9 -#define I40IW_CQPHC_SQBASE_MASK \ - (0xfffffffffffffeULL << I40IW_CQPHC_SQBASE_SHIFT) - -#define I40IW_CQPHC_QPCTX_SHIFT 0 -#define I40IW_CQPHC_QPCTX_MASK \ - (0xffffffffffffffffULL << I40IW_CQPHC_QPCTX_SHIFT) -#define I40IW_CQPHC_SVER 1 - -#define I40IW_CQP_SW_SQSIZE_4 4 -#define I40IW_CQP_SW_SQSIZE_2048 2048 - -/* iWARP QP Doorbell shadow area */ -#define I40IW_QP_DBSA_HW_SQ_TAIL_SHIFT 0 -#define I40IW_QP_DBSA_HW_SQ_TAIL_MASK \ - (0x3fffUL << I40IW_QP_DBSA_HW_SQ_TAIL_SHIFT) - -/* Completion Queue Doorbell shadow area */ -#define I40IW_CQ_DBSA_CQEIDX_SHIFT 0 -#define I40IW_CQ_DBSA_CQEIDX_MASK (0xfffffUL << I40IW_CQ_DBSA_CQEIDX_SHIFT) - -#define I40IW_CQ_DBSA_SW_CQ_SELECT_SHIFT 0 -#define I40IW_CQ_DBSA_SW_CQ_SELECT_MASK \ - (0x3fffUL << I40IW_CQ_DBSA_SW_CQ_SELECT_SHIFT) - -#define I40IW_CQ_DBSA_ARM_NEXT_SHIFT 14 -#define I40IW_CQ_DBSA_ARM_NEXT_MASK (1UL << I40IW_CQ_DBSA_ARM_NEXT_SHIFT) - -#define I40IW_CQ_DBSA_ARM_NEXT_SE_SHIFT 15 -#define I40IW_CQ_DBSA_ARM_NEXT_SE_MASK (1UL << I40IW_CQ_DBSA_ARM_NEXT_SE_SHIFT) - -#define I40IW_CQ_DBSA_ARM_SEQ_NUM_SHIFT 16 -#define I40IW_CQ_DBSA_ARM_SEQ_NUM_MASK \ - (0x3UL << I40IW_CQ_DBSA_ARM_SEQ_NUM_SHIFT) - -/* CQP and iWARP Completion Queue */ -#define I40IW_CQ_QPCTX_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQ_QPCTX_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_CCQ_OPRETVAL_SHIFT 0 -#define I40IW_CCQ_OPRETVAL_MASK (0xffffffffUL << I40IW_CCQ_OPRETVAL_SHIFT) - -#define I40IW_CQ_MINERR_SHIFT 0 -#define I40IW_CQ_MINERR_MASK (0xffffUL << I40IW_CQ_MINERR_SHIFT) - -#define I40IW_CQ_MAJERR_SHIFT 16 -#define I40IW_CQ_MAJERR_MASK (0xffffUL << I40IW_CQ_MAJERR_SHIFT) - -#define I40IW_CQ_WQEIDX_SHIFT 32 -#define I40IW_CQ_WQEIDX_MASK (0x3fffULL << I40IW_CQ_WQEIDX_SHIFT) - -#define I40IW_CQ_ERROR_SHIFT 55 -#define I40IW_CQ_ERROR_MASK (1ULL << I40IW_CQ_ERROR_SHIFT) - -#define I40IW_CQ_SQ_SHIFT 62 -#define I40IW_CQ_SQ_MASK (1ULL << I40IW_CQ_SQ_SHIFT) - -#define I40IW_CQ_VALID_SHIFT 63 -#define I40IW_CQ_VALID_MASK (1ULL << I40IW_CQ_VALID_SHIFT) - -#define I40IWCQ_PAYLDLEN_SHIFT 0 -#define I40IWCQ_PAYLDLEN_MASK (0xffffffffUL << I40IWCQ_PAYLDLEN_SHIFT) - -#define I40IWCQ_TCPSEQNUM_SHIFT 32 -#define I40IWCQ_TCPSEQNUM_MASK (0xffffffffULL << I40IWCQ_TCPSEQNUM_SHIFT) - -#define I40IWCQ_INVSTAG_SHIFT 0 -#define I40IWCQ_INVSTAG_MASK (0xffffffffUL << I40IWCQ_INVSTAG_SHIFT) - -#define I40IWCQ_QPID_SHIFT 32 -#define I40IWCQ_QPID_MASK (0x3ffffULL << I40IWCQ_QPID_SHIFT) - -#define I40IWCQ_PSHDROP_SHIFT 51 -#define I40IWCQ_PSHDROP_MASK (1ULL << I40IWCQ_PSHDROP_SHIFT) - -#define I40IWCQ_SRQ_SHIFT 52 -#define I40IWCQ_SRQ_MASK (1ULL << I40IWCQ_SRQ_SHIFT) - -#define I40IWCQ_STAG_SHIFT 53 -#define I40IWCQ_STAG_MASK (1ULL << I40IWCQ_STAG_SHIFT) - -#define I40IWCQ_SOEVENT_SHIFT 54 -#define I40IWCQ_SOEVENT_MASK (1ULL << I40IWCQ_SOEVENT_SHIFT) - -#define I40IWCQ_OP_SHIFT 56 -#define I40IWCQ_OP_MASK (0x3fULL << I40IWCQ_OP_SHIFT) - -/* CEQE format */ -#define I40IW_CEQE_CQCTX_SHIFT 0 -#define I40IW_CEQE_CQCTX_MASK \ - (0x7fffffffffffffffULL << I40IW_CEQE_CQCTX_SHIFT) - -#define I40IW_CEQE_VALID_SHIFT 63 -#define I40IW_CEQE_VALID_MASK (1ULL << I40IW_CEQE_VALID_SHIFT) - -/* AEQE format */ -#define I40IW_AEQE_COMPCTX_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_AEQE_COMPCTX_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_AEQE_QPCQID_SHIFT 0 -#define I40IW_AEQE_QPCQID_MASK (0x3ffffUL << I40IW_AEQE_QPCQID_SHIFT) - -#define I40IW_AEQE_WQDESCIDX_SHIFT 18 -#define I40IW_AEQE_WQDESCIDX_MASK (0x3fffULL << I40IW_AEQE_WQDESCIDX_SHIFT) - -#define I40IW_AEQE_OVERFLOW_SHIFT 33 -#define I40IW_AEQE_OVERFLOW_MASK (1ULL << I40IW_AEQE_OVERFLOW_SHIFT) - -#define I40IW_AEQE_AECODE_SHIFT 34 -#define I40IW_AEQE_AECODE_MASK (0xffffULL << I40IW_AEQE_AECODE_SHIFT) - -#define I40IW_AEQE_AESRC_SHIFT 50 -#define I40IW_AEQE_AESRC_MASK (0xfULL << I40IW_AEQE_AESRC_SHIFT) - -#define I40IW_AEQE_IWSTATE_SHIFT 54 -#define I40IW_AEQE_IWSTATE_MASK (0x7ULL << I40IW_AEQE_IWSTATE_SHIFT) - -#define I40IW_AEQE_TCPSTATE_SHIFT 57 -#define I40IW_AEQE_TCPSTATE_MASK (0xfULL << I40IW_AEQE_TCPSTATE_SHIFT) - -#define I40IW_AEQE_Q2DATA_SHIFT 61 -#define I40IW_AEQE_Q2DATA_MASK (0x3ULL << I40IW_AEQE_Q2DATA_SHIFT) - -#define I40IW_AEQE_VALID_SHIFT 63 -#define I40IW_AEQE_VALID_MASK (1ULL << I40IW_AEQE_VALID_SHIFT) - -/* CQP SQ WQES */ -#define I40IW_QP_TYPE_IWARP 1 -#define I40IW_QP_TYPE_UDA 2 -#define I40IW_QP_TYPE_CQP 4 - -#define I40IW_CQ_TYPE_IWARP 1 -#define I40IW_CQ_TYPE_ILQ 2 -#define I40IW_CQ_TYPE_IEQ 3 -#define I40IW_CQ_TYPE_CQP 4 - -#define I40IWQP_TERM_SEND_TERM_AND_FIN 0 -#define I40IWQP_TERM_SEND_TERM_ONLY 1 -#define I40IWQP_TERM_SEND_FIN_ONLY 2 -#define I40IWQP_TERM_DONOT_SEND_TERM_OR_FIN 3 - -#define I40IW_CQP_OP_CREATE_QP 0 -#define I40IW_CQP_OP_MODIFY_QP 0x1 -#define I40IW_CQP_OP_DESTROY_QP 0x02 -#define I40IW_CQP_OP_CREATE_CQ 0x03 -#define I40IW_CQP_OP_MODIFY_CQ 0x04 -#define I40IW_CQP_OP_DESTROY_CQ 0x05 -#define I40IW_CQP_OP_CREATE_SRQ 0x06 -#define I40IW_CQP_OP_MODIFY_SRQ 0x07 -#define I40IW_CQP_OP_DESTROY_SRQ 0x08 -#define I40IW_CQP_OP_ALLOC_STAG 0x09 -#define I40IW_CQP_OP_REG_MR 0x0a -#define I40IW_CQP_OP_QUERY_STAG 0x0b -#define I40IW_CQP_OP_REG_SMR 0x0c -#define I40IW_CQP_OP_DEALLOC_STAG 0x0d -#define I40IW_CQP_OP_MANAGE_LOC_MAC_IP_TABLE 0x0e -#define I40IW_CQP_OP_MANAGE_ARP 0x0f -#define I40IW_CQP_OP_MANAGE_VF_PBLE_BP 0x10 -#define I40IW_CQP_OP_MANAGE_PUSH_PAGES 0x11 -#define I40IW_CQP_OP_MANAGE_PE_TEAM 0x12 -#define I40IW_CQP_OP_UPLOAD_CONTEXT 0x13 -#define I40IW_CQP_OP_ALLOCATE_LOC_MAC_IP_TABLE_ENTRY 0x14 -#define I40IW_CQP_OP_MANAGE_HMC_PM_FUNC_TABLE 0x15 -#define I40IW_CQP_OP_CREATE_CEQ 0x16 -#define I40IW_CQP_OP_DESTROY_CEQ 0x18 -#define I40IW_CQP_OP_CREATE_AEQ 0x19 -#define I40IW_CQP_OP_DESTROY_AEQ 0x1b -#define I40IW_CQP_OP_CREATE_ADDR_VECT 0x1c -#define I40IW_CQP_OP_MODIFY_ADDR_VECT 0x1d -#define I40IW_CQP_OP_DESTROY_ADDR_VECT 0x1e -#define I40IW_CQP_OP_UPDATE_PE_SDS 0x1f -#define I40IW_CQP_OP_QUERY_FPM_VALUES 0x20 -#define I40IW_CQP_OP_COMMIT_FPM_VALUES 0x21 -#define I40IW_CQP_OP_FLUSH_WQES 0x22 -#define I40IW_CQP_OP_MANAGE_APBVT 0x23 -#define I40IW_CQP_OP_NOP 0x24 -#define I40IW_CQP_OP_MANAGE_QUAD_HASH_TABLE_ENTRY 0x25 -#define I40IW_CQP_OP_CREATE_UDA_MCAST_GROUP 0x26 -#define I40IW_CQP_OP_MODIFY_UDA_MCAST_GROUP 0x27 -#define I40IW_CQP_OP_DESTROY_UDA_MCAST_GROUP 0x28 -#define I40IW_CQP_OP_SUSPEND_QP 0x29 -#define I40IW_CQP_OP_RESUME_QP 0x2a -#define I40IW_CQP_OP_SHMC_PAGES_ALLOCATED 0x2b -#define I40IW_CQP_OP_SET_HMC_RESOURCE_PROFILE 0x2d - -#define I40IW_UDA_QPSQ_NEXT_HEADER_SHIFT 16 -#define I40IW_UDA_QPSQ_NEXT_HEADER_MASK ((u64)0xff << I40IW_UDA_QPSQ_NEXT_HEADER_SHIFT) - -#define I40IW_UDA_QPSQ_OPCODE_SHIFT 32 -#define I40IW_UDA_QPSQ_OPCODE_MASK ((u64)0x3f << I40IW_UDA_QPSQ_OPCODE_SHIFT) - -#define I40IW_UDA_QPSQ_MACLEN_SHIFT 56 -#define I40IW_UDA_QPSQ_MACLEN_MASK \ - ((u64)0x7f << I40IW_UDA_QPSQ_MACLEN_SHIFT) - -#define I40IW_UDA_QPSQ_IPLEN_SHIFT 48 -#define I40IW_UDA_QPSQ_IPLEN_MASK \ - ((u64)0x7f << I40IW_UDA_QPSQ_IPLEN_SHIFT) - -#define I40IW_UDA_QPSQ_L4T_SHIFT 30 -#define I40IW_UDA_QPSQ_L4T_MASK \ - ((u64)0x3 << I40IW_UDA_QPSQ_L4T_SHIFT) - -#define I40IW_UDA_QPSQ_IIPT_SHIFT 28 -#define I40IW_UDA_QPSQ_IIPT_MASK \ - ((u64)0x3 << I40IW_UDA_QPSQ_IIPT_SHIFT) - -#define I40IW_UDA_QPSQ_L4LEN_SHIFT 24 -#define I40IW_UDA_QPSQ_L4LEN_MASK ((u64)0xf << I40IW_UDA_QPSQ_L4LEN_SHIFT) - -#define I40IW_UDA_QPSQ_AVIDX_SHIFT 0 -#define I40IW_UDA_QPSQ_AVIDX_MASK ((u64)0xffff << I40IW_UDA_QPSQ_AVIDX_SHIFT) - -#define I40IW_UDA_QPSQ_VALID_SHIFT 63 -#define I40IW_UDA_QPSQ_VALID_MASK \ - ((u64)0x1 << I40IW_UDA_QPSQ_VALID_SHIFT) - -#define I40IW_UDA_QPSQ_SIGCOMPL_SHIFT 62 -#define I40IW_UDA_QPSQ_SIGCOMPL_MASK ((u64)0x1 << I40IW_UDA_QPSQ_SIGCOMPL_SHIFT) - -#define I40IW_UDA_PAYLOADLEN_SHIFT 0 -#define I40IW_UDA_PAYLOADLEN_MASK ((u64)0x3fff << I40IW_UDA_PAYLOADLEN_SHIFT) - -#define I40IW_UDA_HDRLEN_SHIFT 16 -#define I40IW_UDA_HDRLEN_MASK ((u64)0x1ff << I40IW_UDA_HDRLEN_SHIFT) - -#define I40IW_VLAN_TAG_VALID_SHIFT 50 -#define I40IW_VLAN_TAG_VALID_MASK ((u64)0x1 << I40IW_VLAN_TAG_VALID_SHIFT) - -#define I40IW_UDA_L3PROTO_SHIFT 0 -#define I40IW_UDA_L3PROTO_MASK ((u64)0x3 << I40IW_UDA_L3PROTO_SHIFT) - -#define I40IW_UDA_L4PROTO_SHIFT 16 -#define I40IW_UDA_L4PROTO_MASK ((u64)0x3 << I40IW_UDA_L4PROTO_SHIFT) - -#define I40IW_UDA_QPSQ_DOLOOPBACK_SHIFT 44 -#define I40IW_UDA_QPSQ_DOLOOPBACK_MASK \ - ((u64)0x1 << I40IW_UDA_QPSQ_DOLOOPBACK_SHIFT) - -/* CQP SQ WQE common fields */ -#define I40IW_CQPSQ_OPCODE_SHIFT 32 -#define I40IW_CQPSQ_OPCODE_MASK (0x3fULL << I40IW_CQPSQ_OPCODE_SHIFT) - -#define I40IW_CQPSQ_WQEVALID_SHIFT 63 -#define I40IW_CQPSQ_WQEVALID_MASK (1ULL << I40IW_CQPSQ_WQEVALID_SHIFT) - -#define I40IW_CQPSQ_TPHVAL_SHIFT 0 -#define I40IW_CQPSQ_TPHVAL_MASK (0xffUL << I40IW_CQPSQ_TPHVAL_SHIFT) - -#define I40IW_CQPSQ_TPHEN_SHIFT 60 -#define I40IW_CQPSQ_TPHEN_MASK (1ULL << I40IW_CQPSQ_TPHEN_SHIFT) - -#define I40IW_CQPSQ_PBUFADDR_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_PBUFADDR_MASK I40IW_CQPHC_QPCTX_MASK - -/* Create/Modify/Destroy QP */ - -#define I40IW_CQPSQ_QP_NEWMSS_SHIFT 32 -#define I40IW_CQPSQ_QP_NEWMSS_MASK (0x3fffULL << I40IW_CQPSQ_QP_NEWMSS_SHIFT) - -#define I40IW_CQPSQ_QP_TERMLEN_SHIFT 48 -#define I40IW_CQPSQ_QP_TERMLEN_MASK (0xfULL << I40IW_CQPSQ_QP_TERMLEN_SHIFT) - -#define I40IW_CQPSQ_QP_QPCTX_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_QP_QPCTX_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_CQPSQ_QP_QPID_SHIFT 0 -#define I40IW_CQPSQ_QP_QPID_MASK (0x3FFFFUL) -/* I40IWCQ_QPID_MASK */ - -#define I40IW_CQPSQ_QP_OP_SHIFT 32 -#define I40IW_CQPSQ_QP_OP_MASK I40IWCQ_OP_MASK - -#define I40IW_CQPSQ_QP_ORDVALID_SHIFT 42 -#define I40IW_CQPSQ_QP_ORDVALID_MASK (1ULL << I40IW_CQPSQ_QP_ORDVALID_SHIFT) - -#define I40IW_CQPSQ_QP_TOECTXVALID_SHIFT 43 -#define I40IW_CQPSQ_QP_TOECTXVALID_MASK \ - (1ULL << I40IW_CQPSQ_QP_TOECTXVALID_SHIFT) - -#define I40IW_CQPSQ_QP_CACHEDVARVALID_SHIFT 44 -#define I40IW_CQPSQ_QP_CACHEDVARVALID_MASK \ - (1ULL << I40IW_CQPSQ_QP_CACHEDVARVALID_SHIFT) - -#define I40IW_CQPSQ_QP_VQ_SHIFT 45 -#define I40IW_CQPSQ_QP_VQ_MASK (1ULL << I40IW_CQPSQ_QP_VQ_SHIFT) - -#define I40IW_CQPSQ_QP_FORCELOOPBACK_SHIFT 46 -#define I40IW_CQPSQ_QP_FORCELOOPBACK_MASK \ - (1ULL << I40IW_CQPSQ_QP_FORCELOOPBACK_SHIFT) - -#define I40IW_CQPSQ_QP_CQNUMVALID_SHIFT 47 -#define I40IW_CQPSQ_QP_CQNUMVALID_MASK \ - (1ULL << I40IW_CQPSQ_QP_CQNUMVALID_SHIFT) - -#define I40IW_CQPSQ_QP_QPTYPE_SHIFT 48 -#define I40IW_CQPSQ_QP_QPTYPE_MASK (0x3ULL << I40IW_CQPSQ_QP_QPTYPE_SHIFT) - -#define I40IW_CQPSQ_QP_MSSCHANGE_SHIFT 52 -#define I40IW_CQPSQ_QP_MSSCHANGE_MASK (1ULL << I40IW_CQPSQ_QP_MSSCHANGE_SHIFT) - -#define I40IW_CQPSQ_QP_STATRSRC_SHIFT 53 -#define I40IW_CQPSQ_QP_STATRSRC_MASK (1ULL << I40IW_CQPSQ_QP_STATRSRC_SHIFT) - -#define I40IW_CQPSQ_QP_IGNOREMWBOUND_SHIFT 54 -#define I40IW_CQPSQ_QP_IGNOREMWBOUND_MASK \ - (1ULL << I40IW_CQPSQ_QP_IGNOREMWBOUND_SHIFT) - -#define I40IW_CQPSQ_QP_REMOVEHASHENTRY_SHIFT 55 -#define I40IW_CQPSQ_QP_REMOVEHASHENTRY_MASK \ - (1ULL << I40IW_CQPSQ_QP_REMOVEHASHENTRY_SHIFT) - -#define I40IW_CQPSQ_QP_TERMACT_SHIFT 56 -#define I40IW_CQPSQ_QP_TERMACT_MASK (0x3ULL << I40IW_CQPSQ_QP_TERMACT_SHIFT) - -#define I40IW_CQPSQ_QP_RESETCON_SHIFT 58 -#define I40IW_CQPSQ_QP_RESETCON_MASK (1ULL << I40IW_CQPSQ_QP_RESETCON_SHIFT) - -#define I40IW_CQPSQ_QP_ARPTABIDXVALID_SHIFT 59 -#define I40IW_CQPSQ_QP_ARPTABIDXVALID_MASK \ - (1ULL << I40IW_CQPSQ_QP_ARPTABIDXVALID_SHIFT) - -#define I40IW_CQPSQ_QP_NEXTIWSTATE_SHIFT 60 -#define I40IW_CQPSQ_QP_NEXTIWSTATE_MASK \ - (0x7ULL << I40IW_CQPSQ_QP_NEXTIWSTATE_SHIFT) - -#define I40IW_CQPSQ_QP_DBSHADOWADDR_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_QP_DBSHADOWADDR_MASK I40IW_CQPHC_QPCTX_MASK - -/* Create/Modify/Destroy CQ */ -#define I40IW_CQPSQ_CQ_CQSIZE_SHIFT 0 -#define I40IW_CQPSQ_CQ_CQSIZE_MASK (0x3ffffUL << I40IW_CQPSQ_CQ_CQSIZE_SHIFT) - -#define I40IW_CQPSQ_CQ_CQCTX_SHIFT 0 -#define I40IW_CQPSQ_CQ_CQCTX_MASK \ - (0x7fffffffffffffffULL << I40IW_CQPSQ_CQ_CQCTX_SHIFT) - -#define I40IW_CQPSQ_CQ_CQCTX_SHIFT 0 -#define I40IW_CQPSQ_CQ_CQCTX_MASK \ - (0x7fffffffffffffffULL << I40IW_CQPSQ_CQ_CQCTX_SHIFT) - -#define I40IW_CQPSQ_CQ_SHADOW_READ_THRESHOLD_SHIFT 0 -#define I40IW_CQPSQ_CQ_SHADOW_READ_THRESHOLD_MASK \ - (0x3ffff << I40IW_CQPSQ_CQ_SHADOW_READ_THRESHOLD_SHIFT) - -#define I40IW_CQPSQ_CQ_CEQID_SHIFT 24 -#define I40IW_CQPSQ_CQ_CEQID_MASK (0x7fUL << I40IW_CQPSQ_CQ_CEQID_SHIFT) - -#define I40IW_CQPSQ_CQ_OP_SHIFT 32 -#define I40IW_CQPSQ_CQ_OP_MASK (0x3fULL << I40IW_CQPSQ_CQ_OP_SHIFT) - -#define I40IW_CQPSQ_CQ_CQRESIZE_SHIFT 43 -#define I40IW_CQPSQ_CQ_CQRESIZE_MASK (1ULL << I40IW_CQPSQ_CQ_CQRESIZE_SHIFT) - -#define I40IW_CQPSQ_CQ_LPBLSIZE_SHIFT 44 -#define I40IW_CQPSQ_CQ_LPBLSIZE_MASK (3ULL << I40IW_CQPSQ_CQ_LPBLSIZE_SHIFT) - -#define I40IW_CQPSQ_CQ_CHKOVERFLOW_SHIFT 46 -#define I40IW_CQPSQ_CQ_CHKOVERFLOW_MASK \ - (1ULL << I40IW_CQPSQ_CQ_CHKOVERFLOW_SHIFT) - -#define I40IW_CQPSQ_CQ_VIRTMAP_SHIFT 47 -#define I40IW_CQPSQ_CQ_VIRTMAP_MASK (1ULL << I40IW_CQPSQ_CQ_VIRTMAP_SHIFT) - -#define I40IW_CQPSQ_CQ_ENCEQEMASK_SHIFT 48 -#define I40IW_CQPSQ_CQ_ENCEQEMASK_MASK \ - (1ULL << I40IW_CQPSQ_CQ_ENCEQEMASK_SHIFT) - -#define I40IW_CQPSQ_CQ_CEQIDVALID_SHIFT 49 -#define I40IW_CQPSQ_CQ_CEQIDVALID_MASK \ - (1ULL << I40IW_CQPSQ_CQ_CEQIDVALID_SHIFT) - -#define I40IW_CQPSQ_CQ_AVOIDMEMCNFLCT_SHIFT 61 -#define I40IW_CQPSQ_CQ_AVOIDMEMCNFLCT_MASK \ - (1ULL << I40IW_CQPSQ_CQ_AVOIDMEMCNFLCT_SHIFT) - -/* Create/Modify/Destroy Shared Receive Queue */ - -#define I40IW_CQPSQ_SRQ_RQSIZE_SHIFT 0 -#define I40IW_CQPSQ_SRQ_RQSIZE_MASK (0xfUL << I40IW_CQPSQ_SRQ_RQSIZE_SHIFT) - -#define I40IW_CQPSQ_SRQ_RQWQESIZE_SHIFT 4 -#define I40IW_CQPSQ_SRQ_RQWQESIZE_MASK \ - (0x7UL << I40IW_CQPSQ_SRQ_RQWQESIZE_SHIFT) - -#define I40IW_CQPSQ_SRQ_SRQLIMIT_SHIFT 32 -#define I40IW_CQPSQ_SRQ_SRQLIMIT_MASK \ - (0xfffULL << I40IW_CQPSQ_SRQ_SRQLIMIT_SHIFT) - -#define I40IW_CQPSQ_SRQ_SRQCTX_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_SRQ_SRQCTX_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_CQPSQ_SRQ_PDID_SHIFT 16 -#define I40IW_CQPSQ_SRQ_PDID_MASK \ - (0x7fffULL << I40IW_CQPSQ_SRQ_PDID_SHIFT) - -#define I40IW_CQPSQ_SRQ_SRQID_SHIFT 0 -#define I40IW_CQPSQ_SRQ_SRQID_MASK (0x7fffUL << I40IW_CQPSQ_SRQ_SRQID_SHIFT) - -#define I40IW_CQPSQ_SRQ_LPBLSIZE_SHIFT I40IW_CQPSQ_CQ_LPBLSIZE_SHIFT -#define I40IW_CQPSQ_SRQ_LPBLSIZE_MASK I40IW_CQPSQ_CQ_LPBLSIZE_MASK - -#define I40IW_CQPSQ_SRQ_VIRTMAP_SHIFT I40IW_CQPSQ_CQ_VIRTMAP_SHIFT -#define I40IW_CQPSQ_SRQ_VIRTMAP_MASK I40IW_CQPSQ_CQ_VIRTMAP_MASK - -#define I40IW_CQPSQ_SRQ_TPHEN_SHIFT I40IW_CQPSQ_TPHEN_SHIFT -#define I40IW_CQPSQ_SRQ_TPHEN_MASK I40IW_CQPSQ_TPHEN_MASK - -#define I40IW_CQPSQ_SRQ_ARMLIMITEVENT_SHIFT 61 -#define I40IW_CQPSQ_SRQ_ARMLIMITEVENT_MASK \ - (1ULL << I40IW_CQPSQ_SRQ_ARMLIMITEVENT_SHIFT) - -#define I40IW_CQPSQ_SRQ_DBSHADOWAREA_SHIFT 6 -#define I40IW_CQPSQ_SRQ_DBSHADOWAREA_MASK \ - (0x3ffffffffffffffULL << I40IW_CQPSQ_SRQ_DBSHADOWAREA_SHIFT) - -#define I40IW_CQPSQ_SRQ_FIRSTPMPBLIDX_SHIFT 0 -#define I40IW_CQPSQ_SRQ_FIRSTPMPBLIDX_MASK \ - (0xfffffffUL << I40IW_CQPSQ_SRQ_FIRSTPMPBLIDX_SHIFT) - -/* Allocate/Register/Register Shared/Deallocate Stag */ -#define I40IW_CQPSQ_STAG_VA_FBO_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_STAG_VA_FBO_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_CQPSQ_STAG_STAGLEN_SHIFT 0 -#define I40IW_CQPSQ_STAG_STAGLEN_MASK \ - (0x3fffffffffffULL << I40IW_CQPSQ_STAG_STAGLEN_SHIFT) - -#define I40IW_CQPSQ_STAG_PDID_SHIFT 48 -#define I40IW_CQPSQ_STAG_PDID_MASK (0x7fffULL << I40IW_CQPSQ_STAG_PDID_SHIFT) - -#define I40IW_CQPSQ_STAG_KEY_SHIFT 0 -#define I40IW_CQPSQ_STAG_KEY_MASK (0xffUL << I40IW_CQPSQ_STAG_KEY_SHIFT) - -#define I40IW_CQPSQ_STAG_IDX_SHIFT 8 -#define I40IW_CQPSQ_STAG_IDX_MASK (0xffffffUL << I40IW_CQPSQ_STAG_IDX_SHIFT) - -#define I40IW_CQPSQ_STAG_PARENTSTAGIDX_SHIFT 32 -#define I40IW_CQPSQ_STAG_PARENTSTAGIDX_MASK \ - (0xffffffULL << I40IW_CQPSQ_STAG_PARENTSTAGIDX_SHIFT) - -#define I40IW_CQPSQ_STAG_MR_SHIFT 43 -#define I40IW_CQPSQ_STAG_MR_MASK (1ULL << I40IW_CQPSQ_STAG_MR_SHIFT) - -#define I40IW_CQPSQ_STAG_LPBLSIZE_SHIFT I40IW_CQPSQ_CQ_LPBLSIZE_SHIFT -#define I40IW_CQPSQ_STAG_LPBLSIZE_MASK I40IW_CQPSQ_CQ_LPBLSIZE_MASK - -#define I40IW_CQPSQ_STAG_HPAGESIZE_SHIFT 46 -#define I40IW_CQPSQ_STAG_HPAGESIZE_MASK \ - (1ULL << I40IW_CQPSQ_STAG_HPAGESIZE_SHIFT) - -#define I40IW_CQPSQ_STAG_ARIGHTS_SHIFT 48 -#define I40IW_CQPSQ_STAG_ARIGHTS_MASK \ - (0x1fULL << I40IW_CQPSQ_STAG_ARIGHTS_SHIFT) - -#define I40IW_CQPSQ_STAG_REMACCENABLED_SHIFT 53 -#define I40IW_CQPSQ_STAG_REMACCENABLED_MASK \ - (1ULL << I40IW_CQPSQ_STAG_REMACCENABLED_SHIFT) - -#define I40IW_CQPSQ_STAG_VABASEDTO_SHIFT 59 -#define I40IW_CQPSQ_STAG_VABASEDTO_MASK \ - (1ULL << I40IW_CQPSQ_STAG_VABASEDTO_SHIFT) - -#define I40IW_CQPSQ_STAG_USEHMCFNIDX_SHIFT 60 -#define I40IW_CQPSQ_STAG_USEHMCFNIDX_MASK \ - (1ULL << I40IW_CQPSQ_STAG_USEHMCFNIDX_SHIFT) - -#define I40IW_CQPSQ_STAG_USEPFRID_SHIFT 61 -#define I40IW_CQPSQ_STAG_USEPFRID_MASK \ - (1ULL << I40IW_CQPSQ_STAG_USEPFRID_SHIFT) - -#define I40IW_CQPSQ_STAG_PBA_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_STAG_PBA_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_CQPSQ_STAG_HMCFNIDX_SHIFT 0 -#define I40IW_CQPSQ_STAG_HMCFNIDX_MASK \ - (0x3fUL << I40IW_CQPSQ_STAG_HMCFNIDX_SHIFT) - -#define I40IW_CQPSQ_STAG_FIRSTPMPBLIDX_SHIFT 0 -#define I40IW_CQPSQ_STAG_FIRSTPMPBLIDX_MASK \ - (0xfffffffUL << I40IW_CQPSQ_STAG_FIRSTPMPBLIDX_SHIFT) - -/* Query stag */ -#define I40IW_CQPSQ_QUERYSTAG_IDX_SHIFT I40IW_CQPSQ_STAG_IDX_SHIFT -#define I40IW_CQPSQ_QUERYSTAG_IDX_MASK I40IW_CQPSQ_STAG_IDX_MASK - -/* Allocate Local IP Address Entry */ - -/* Manage Local IP Address Table - MLIPA */ -#define I40IW_CQPSQ_MLIPA_IPV6LO_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_MLIPA_IPV6LO_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_CQPSQ_MLIPA_IPV6HI_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_MLIPA_IPV6HI_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_CQPSQ_MLIPA_IPV4_SHIFT 0 -#define I40IW_CQPSQ_MLIPA_IPV4_MASK \ - (0xffffffffUL << I40IW_CQPSQ_MLIPA_IPV4_SHIFT) - -#define I40IW_CQPSQ_MLIPA_IPTABLEIDX_SHIFT 0 -#define I40IW_CQPSQ_MLIPA_IPTABLEIDX_MASK \ - (0x3fUL << I40IW_CQPSQ_MLIPA_IPTABLEIDX_SHIFT) - -#define I40IW_CQPSQ_MLIPA_IPV4VALID_SHIFT 42 -#define I40IW_CQPSQ_MLIPA_IPV4VALID_MASK \ - (1ULL << I40IW_CQPSQ_MLIPA_IPV4VALID_SHIFT) - -#define I40IW_CQPSQ_MLIPA_IPV6VALID_SHIFT 43 -#define I40IW_CQPSQ_MLIPA_IPV6VALID_MASK \ - (1ULL << I40IW_CQPSQ_MLIPA_IPV6VALID_SHIFT) - -#define I40IW_CQPSQ_MLIPA_FREEENTRY_SHIFT 62 -#define I40IW_CQPSQ_MLIPA_FREEENTRY_MASK \ - (1ULL << I40IW_CQPSQ_MLIPA_FREEENTRY_SHIFT) - -#define I40IW_CQPSQ_MLIPA_IGNORE_REF_CNT_SHIFT 61 -#define I40IW_CQPSQ_MLIPA_IGNORE_REF_CNT_MASK \ - (1ULL << I40IW_CQPSQ_MLIPA_IGNORE_REF_CNT_SHIFT) - -#define I40IW_CQPSQ_MLIPA_MAC0_SHIFT 0 -#define I40IW_CQPSQ_MLIPA_MAC0_MASK (0xffUL << I40IW_CQPSQ_MLIPA_MAC0_SHIFT) - -#define I40IW_CQPSQ_MLIPA_MAC1_SHIFT 8 -#define I40IW_CQPSQ_MLIPA_MAC1_MASK (0xffUL << I40IW_CQPSQ_MLIPA_MAC1_SHIFT) - -#define I40IW_CQPSQ_MLIPA_MAC2_SHIFT 16 -#define I40IW_CQPSQ_MLIPA_MAC2_MASK (0xffUL << I40IW_CQPSQ_MLIPA_MAC2_SHIFT) - -#define I40IW_CQPSQ_MLIPA_MAC3_SHIFT 24 -#define I40IW_CQPSQ_MLIPA_MAC3_MASK (0xffUL << I40IW_CQPSQ_MLIPA_MAC3_SHIFT) - -#define I40IW_CQPSQ_MLIPA_MAC4_SHIFT 32 -#define I40IW_CQPSQ_MLIPA_MAC4_MASK (0xffULL << I40IW_CQPSQ_MLIPA_MAC4_SHIFT) - -#define I40IW_CQPSQ_MLIPA_MAC5_SHIFT 40 -#define I40IW_CQPSQ_MLIPA_MAC5_MASK (0xffULL << I40IW_CQPSQ_MLIPA_MAC5_SHIFT) - -/* Manage ARP Table - MAT */ -#define I40IW_CQPSQ_MAT_REACHMAX_SHIFT 0 -#define I40IW_CQPSQ_MAT_REACHMAX_MASK \ - (0xffffffffUL << I40IW_CQPSQ_MAT_REACHMAX_SHIFT) - -#define I40IW_CQPSQ_MAT_MACADDR_SHIFT 0 -#define I40IW_CQPSQ_MAT_MACADDR_MASK \ - (0xffffffffffffULL << I40IW_CQPSQ_MAT_MACADDR_SHIFT) - -#define I40IW_CQPSQ_MAT_ARPENTRYIDX_SHIFT 0 -#define I40IW_CQPSQ_MAT_ARPENTRYIDX_MASK \ - (0xfffUL << I40IW_CQPSQ_MAT_ARPENTRYIDX_SHIFT) - -#define I40IW_CQPSQ_MAT_ENTRYVALID_SHIFT 42 -#define I40IW_CQPSQ_MAT_ENTRYVALID_MASK \ - (1ULL << I40IW_CQPSQ_MAT_ENTRYVALID_SHIFT) - -#define I40IW_CQPSQ_MAT_PERMANENT_SHIFT 43 -#define I40IW_CQPSQ_MAT_PERMANENT_MASK \ - (1ULL << I40IW_CQPSQ_MAT_PERMANENT_SHIFT) - -#define I40IW_CQPSQ_MAT_QUERY_SHIFT 44 -#define I40IW_CQPSQ_MAT_QUERY_MASK (1ULL << I40IW_CQPSQ_MAT_QUERY_SHIFT) - -/* Manage VF PBLE Backing Pages - MVPBP*/ -#define I40IW_CQPSQ_MVPBP_PD_ENTRY_CNT_SHIFT 0 -#define I40IW_CQPSQ_MVPBP_PD_ENTRY_CNT_MASK \ - (0x3ffULL << I40IW_CQPSQ_MVPBP_PD_ENTRY_CNT_SHIFT) - -#define I40IW_CQPSQ_MVPBP_FIRST_PD_INX_SHIFT 16 -#define I40IW_CQPSQ_MVPBP_FIRST_PD_INX_MASK \ - (0x1ffULL << I40IW_CQPSQ_MVPBP_FIRST_PD_INX_SHIFT) - -#define I40IW_CQPSQ_MVPBP_SD_INX_SHIFT 32 -#define I40IW_CQPSQ_MVPBP_SD_INX_MASK \ - (0xfffULL << I40IW_CQPSQ_MVPBP_SD_INX_SHIFT) - -#define I40IW_CQPSQ_MVPBP_INV_PD_ENT_SHIFT 62 -#define I40IW_CQPSQ_MVPBP_INV_PD_ENT_MASK \ - (0x1ULL << I40IW_CQPSQ_MVPBP_INV_PD_ENT_SHIFT) - -#define I40IW_CQPSQ_MVPBP_PD_PLPBA_SHIFT 3 -#define I40IW_CQPSQ_MVPBP_PD_PLPBA_MASK \ - (0x1fffffffffffffffULL << I40IW_CQPSQ_MVPBP_PD_PLPBA_SHIFT) - -/* Manage Push Page - MPP */ -#define I40IW_INVALID_PUSH_PAGE_INDEX 0xffff - -#define I40IW_CQPSQ_MPP_QS_HANDLE_SHIFT 0 -#define I40IW_CQPSQ_MPP_QS_HANDLE_MASK (0xffffUL << \ - I40IW_CQPSQ_MPP_QS_HANDLE_SHIFT) - -#define I40IW_CQPSQ_MPP_PPIDX_SHIFT 0 -#define I40IW_CQPSQ_MPP_PPIDX_MASK (0x3ffUL << I40IW_CQPSQ_MPP_PPIDX_SHIFT) - -#define I40IW_CQPSQ_MPP_FREE_PAGE_SHIFT 62 -#define I40IW_CQPSQ_MPP_FREE_PAGE_MASK (1ULL << I40IW_CQPSQ_MPP_FREE_PAGE_SHIFT) - -/* Upload Context - UCTX */ -#define I40IW_CQPSQ_UCTX_QPCTXADDR_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IW_CQPSQ_UCTX_QPCTXADDR_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IW_CQPSQ_UCTX_QPID_SHIFT 0 -#define I40IW_CQPSQ_UCTX_QPID_MASK (0x3ffffUL << I40IW_CQPSQ_UCTX_QPID_SHIFT) - -#define I40IW_CQPSQ_UCTX_QPTYPE_SHIFT 48 -#define I40IW_CQPSQ_UCTX_QPTYPE_MASK (0xfULL << I40IW_CQPSQ_UCTX_QPTYPE_SHIFT) - -#define I40IW_CQPSQ_UCTX_RAWFORMAT_SHIFT 61 -#define I40IW_CQPSQ_UCTX_RAWFORMAT_MASK \ - (1ULL << I40IW_CQPSQ_UCTX_RAWFORMAT_SHIFT) - -#define I40IW_CQPSQ_UCTX_FREEZEQP_SHIFT 62 -#define I40IW_CQPSQ_UCTX_FREEZEQP_MASK \ - (1ULL << I40IW_CQPSQ_UCTX_FREEZEQP_SHIFT) - -/* Manage HMC PM Function Table - MHMC */ -#define I40IW_CQPSQ_MHMC_VFIDX_SHIFT 0 -#define I40IW_CQPSQ_MHMC_VFIDX_MASK (0x7fUL << I40IW_CQPSQ_MHMC_VFIDX_SHIFT) - -#define I40IW_CQPSQ_MHMC_FREEPMFN_SHIFT 62 -#define I40IW_CQPSQ_MHMC_FREEPMFN_MASK \ - (1ULL << I40IW_CQPSQ_MHMC_FREEPMFN_SHIFT) - -/* Set HMC Resource Profile - SHMCRP */ -#define I40IW_CQPSQ_SHMCRP_HMC_PROFILE_SHIFT 0 -#define I40IW_CQPSQ_SHMCRP_HMC_PROFILE_MASK \ - (0x7ULL << I40IW_CQPSQ_SHMCRP_HMC_PROFILE_SHIFT) -#define I40IW_CQPSQ_SHMCRP_VFNUM_SHIFT 32 -#define I40IW_CQPSQ_SHMCRP_VFNUM_MASK (0x3fULL << I40IW_CQPSQ_SHMCRP_VFNUM_SHIFT) - -/* Create/Destroy CEQ */ -#define I40IW_CQPSQ_CEQ_CEQSIZE_SHIFT 0 -#define I40IW_CQPSQ_CEQ_CEQSIZE_MASK \ - (0x1ffffUL << I40IW_CQPSQ_CEQ_CEQSIZE_SHIFT) - -#define I40IW_CQPSQ_CEQ_CEQID_SHIFT 0 -#define I40IW_CQPSQ_CEQ_CEQID_MASK (0x7fUL << I40IW_CQPSQ_CEQ_CEQID_SHIFT) - -#define I40IW_CQPSQ_CEQ_LPBLSIZE_SHIFT I40IW_CQPSQ_CQ_LPBLSIZE_SHIFT -#define I40IW_CQPSQ_CEQ_LPBLSIZE_MASK I40IW_CQPSQ_CQ_LPBLSIZE_MASK - -#define I40IW_CQPSQ_CEQ_VMAP_SHIFT 47 -#define I40IW_CQPSQ_CEQ_VMAP_MASK (1ULL << I40IW_CQPSQ_CEQ_VMAP_SHIFT) - -#define I40IW_CQPSQ_CEQ_FIRSTPMPBLIDX_SHIFT 0 -#define I40IW_CQPSQ_CEQ_FIRSTPMPBLIDX_MASK \ - (0xfffffffUL << I40IW_CQPSQ_CEQ_FIRSTPMPBLIDX_SHIFT) - -/* Create/Destroy AEQ */ -#define I40IW_CQPSQ_AEQ_AEQECNT_SHIFT 0 -#define I40IW_CQPSQ_AEQ_AEQECNT_MASK \ - (0x7ffffUL << I40IW_CQPSQ_AEQ_AEQECNT_SHIFT) - -#define I40IW_CQPSQ_AEQ_LPBLSIZE_SHIFT I40IW_CQPSQ_CQ_LPBLSIZE_SHIFT -#define I40IW_CQPSQ_AEQ_LPBLSIZE_MASK I40IW_CQPSQ_CQ_LPBLSIZE_MASK - -#define I40IW_CQPSQ_AEQ_VMAP_SHIFT 47 -#define I40IW_CQPSQ_AEQ_VMAP_MASK (1ULL << I40IW_CQPSQ_AEQ_VMAP_SHIFT) - -#define I40IW_CQPSQ_AEQ_FIRSTPMPBLIDX_SHIFT 0 -#define I40IW_CQPSQ_AEQ_FIRSTPMPBLIDX_MASK \ - (0xfffffffUL << I40IW_CQPSQ_AEQ_FIRSTPMPBLIDX_SHIFT) - -/* Commit FPM Values - CFPM */ -#define I40IW_CQPSQ_CFPM_HMCFNID_SHIFT 0 -#define I40IW_CQPSQ_CFPM_HMCFNID_MASK (0x3fUL << I40IW_CQPSQ_CFPM_HMCFNID_SHIFT) - -/* Flush WQEs - FWQE */ -#define I40IW_CQPSQ_FWQE_AECODE_SHIFT 0 -#define I40IW_CQPSQ_FWQE_AECODE_MASK (0xffffUL << I40IW_CQPSQ_FWQE_AECODE_SHIFT) - -#define I40IW_CQPSQ_FWQE_AESOURCE_SHIFT 16 -#define I40IW_CQPSQ_FWQE_AESOURCE_MASK \ - (0xfUL << I40IW_CQPSQ_FWQE_AESOURCE_SHIFT) - -#define I40IW_CQPSQ_FWQE_RQMNERR_SHIFT 0 -#define I40IW_CQPSQ_FWQE_RQMNERR_MASK \ - (0xffffUL << I40IW_CQPSQ_FWQE_RQMNERR_SHIFT) - -#define I40IW_CQPSQ_FWQE_RQMJERR_SHIFT 16 -#define I40IW_CQPSQ_FWQE_RQMJERR_MASK \ - (0xffffUL << I40IW_CQPSQ_FWQE_RQMJERR_SHIFT) - -#define I40IW_CQPSQ_FWQE_SQMNERR_SHIFT 32 -#define I40IW_CQPSQ_FWQE_SQMNERR_MASK \ - (0xffffULL << I40IW_CQPSQ_FWQE_SQMNERR_SHIFT) - -#define I40IW_CQPSQ_FWQE_SQMJERR_SHIFT 48 -#define I40IW_CQPSQ_FWQE_SQMJERR_MASK \ - (0xffffULL << I40IW_CQPSQ_FWQE_SQMJERR_SHIFT) - -#define I40IW_CQPSQ_FWQE_QPID_SHIFT 0 -#define I40IW_CQPSQ_FWQE_QPID_MASK (0x3ffffULL << I40IW_CQPSQ_FWQE_QPID_SHIFT) - -#define I40IW_CQPSQ_FWQE_GENERATE_AE_SHIFT 59 -#define I40IW_CQPSQ_FWQE_GENERATE_AE_MASK (1ULL << \ - I40IW_CQPSQ_FWQE_GENERATE_AE_SHIFT) - -#define I40IW_CQPSQ_FWQE_USERFLCODE_SHIFT 60 -#define I40IW_CQPSQ_FWQE_USERFLCODE_MASK \ - (1ULL << I40IW_CQPSQ_FWQE_USERFLCODE_SHIFT) - -#define I40IW_CQPSQ_FWQE_FLUSHSQ_SHIFT 61 -#define I40IW_CQPSQ_FWQE_FLUSHSQ_MASK (1ULL << I40IW_CQPSQ_FWQE_FLUSHSQ_SHIFT) - -#define I40IW_CQPSQ_FWQE_FLUSHRQ_SHIFT 62 -#define I40IW_CQPSQ_FWQE_FLUSHRQ_MASK (1ULL << I40IW_CQPSQ_FWQE_FLUSHRQ_SHIFT) - -/* Manage Accelerated Port Table - MAPT */ -#define I40IW_CQPSQ_MAPT_PORT_SHIFT 0 -#define I40IW_CQPSQ_MAPT_PORT_MASK (0xffffUL << I40IW_CQPSQ_MAPT_PORT_SHIFT) - -#define I40IW_CQPSQ_MAPT_ADDPORT_SHIFT 62 -#define I40IW_CQPSQ_MAPT_ADDPORT_MASK (1ULL << I40IW_CQPSQ_MAPT_ADDPORT_SHIFT) - -/* Update Protocol Engine SDs */ -#define I40IW_CQPSQ_UPESD_SDCMD_SHIFT 0 -#define I40IW_CQPSQ_UPESD_SDCMD_MASK (0xffffffffUL << I40IW_CQPSQ_UPESD_SDCMD_SHIFT) - -#define I40IW_CQPSQ_UPESD_SDDATALOW_SHIFT 0 -#define I40IW_CQPSQ_UPESD_SDDATALOW_MASK \ - (0xffffffffUL << I40IW_CQPSQ_UPESD_SDDATALOW_SHIFT) - -#define I40IW_CQPSQ_UPESD_SDDATAHI_SHIFT 32 -#define I40IW_CQPSQ_UPESD_SDDATAHI_MASK \ - (0xffffffffULL << I40IW_CQPSQ_UPESD_SDDATAHI_SHIFT) -#define I40IW_CQPSQ_UPESD_HMCFNID_SHIFT 0 -#define I40IW_CQPSQ_UPESD_HMCFNID_MASK \ - (0x3fUL << I40IW_CQPSQ_UPESD_HMCFNID_SHIFT) - -#define I40IW_CQPSQ_UPESD_ENTRY_VALID_SHIFT 63 -#define I40IW_CQPSQ_UPESD_ENTRY_VALID_MASK \ - ((u64)1 << I40IW_CQPSQ_UPESD_ENTRY_VALID_SHIFT) - -#define I40IW_CQPSQ_UPESD_ENTRY_COUNT_SHIFT 0 -#define I40IW_CQPSQ_UPESD_ENTRY_COUNT_MASK \ - (0xfUL << I40IW_CQPSQ_UPESD_ENTRY_COUNT_SHIFT) - -#define I40IW_CQPSQ_UPESD_SKIP_ENTRY_SHIFT 7 -#define I40IW_CQPSQ_UPESD_SKIP_ENTRY_MASK \ - (0x1UL << I40IW_CQPSQ_UPESD_SKIP_ENTRY_SHIFT) - -/* Suspend QP */ -#define I40IW_CQPSQ_SUSPENDQP_QPID_SHIFT 0 -#define I40IW_CQPSQ_SUSPENDQP_QPID_MASK (0x3FFFFUL) -/* I40IWCQ_QPID_MASK */ - -/* Resume QP */ -#define I40IW_CQPSQ_RESUMEQP_QSHANDLE_SHIFT 0 -#define I40IW_CQPSQ_RESUMEQP_QSHANDLE_MASK \ - (0xffffffffUL << I40IW_CQPSQ_RESUMEQP_QSHANDLE_SHIFT) - -#define I40IW_CQPSQ_RESUMEQP_QPID_SHIFT 0 -#define I40IW_CQPSQ_RESUMEQP_QPID_MASK (0x3FFFFUL) -/* I40IWCQ_QPID_MASK */ - -/* IW QP Context */ -#define I40IWQPC_DDP_VER_SHIFT 0 -#define I40IWQPC_DDP_VER_MASK (3UL << I40IWQPC_DDP_VER_SHIFT) - -#define I40IWQPC_SNAP_SHIFT 2 -#define I40IWQPC_SNAP_MASK (1UL << I40IWQPC_SNAP_SHIFT) - -#define I40IWQPC_IPV4_SHIFT 3 -#define I40IWQPC_IPV4_MASK (1UL << I40IWQPC_IPV4_SHIFT) - -#define I40IWQPC_NONAGLE_SHIFT 4 -#define I40IWQPC_NONAGLE_MASK (1UL << I40IWQPC_NONAGLE_SHIFT) - -#define I40IWQPC_INSERTVLANTAG_SHIFT 5 -#define I40IWQPC_INSERTVLANTAG_MASK (1 << I40IWQPC_INSERTVLANTAG_SHIFT) - -#define I40IWQPC_USESRQ_SHIFT 6 -#define I40IWQPC_USESRQ_MASK (1UL << I40IWQPC_USESRQ_SHIFT) - -#define I40IWQPC_TIMESTAMP_SHIFT 7 -#define I40IWQPC_TIMESTAMP_MASK (1UL << I40IWQPC_TIMESTAMP_SHIFT) - -#define I40IWQPC_RQWQESIZE_SHIFT 8 -#define I40IWQPC_RQWQESIZE_MASK (3UL << I40IWQPC_RQWQESIZE_SHIFT) - -#define I40IWQPC_INSERTL2TAG2_SHIFT 11 -#define I40IWQPC_INSERTL2TAG2_MASK (1UL << I40IWQPC_INSERTL2TAG2_SHIFT) - -#define I40IWQPC_LIMIT_SHIFT 12 -#define I40IWQPC_LIMIT_MASK (3UL << I40IWQPC_LIMIT_SHIFT) - -#define I40IWQPC_DROPOOOSEG_SHIFT 15 -#define I40IWQPC_DROPOOOSEG_MASK (1UL << I40IWQPC_DROPOOOSEG_SHIFT) - -#define I40IWQPC_DUPACK_THRESH_SHIFT 16 -#define I40IWQPC_DUPACK_THRESH_MASK (7UL << I40IWQPC_DUPACK_THRESH_SHIFT) - -#define I40IWQPC_ERR_RQ_IDX_VALID_SHIFT 19 -#define I40IWQPC_ERR_RQ_IDX_VALID_MASK (1UL << I40IWQPC_ERR_RQ_IDX_VALID_SHIFT) - -#define I40IWQPC_DIS_VLAN_CHECKS_SHIFT 19 -#define I40IWQPC_DIS_VLAN_CHECKS_MASK (7UL << I40IWQPC_DIS_VLAN_CHECKS_SHIFT) - -#define I40IWQPC_RCVTPHEN_SHIFT 28 -#define I40IWQPC_RCVTPHEN_MASK (1UL << I40IWQPC_RCVTPHEN_SHIFT) - -#define I40IWQPC_XMITTPHEN_SHIFT 29 -#define I40IWQPC_XMITTPHEN_MASK (1ULL << I40IWQPC_XMITTPHEN_SHIFT) - -#define I40IWQPC_RQTPHEN_SHIFT 30 -#define I40IWQPC_RQTPHEN_MASK (1UL << I40IWQPC_RQTPHEN_SHIFT) - -#define I40IWQPC_SQTPHEN_SHIFT 31 -#define I40IWQPC_SQTPHEN_MASK (1ULL << I40IWQPC_SQTPHEN_SHIFT) - -#define I40IWQPC_PPIDX_SHIFT 32 -#define I40IWQPC_PPIDX_MASK (0x3ffULL << I40IWQPC_PPIDX_SHIFT) - -#define I40IWQPC_PMENA_SHIFT 47 -#define I40IWQPC_PMENA_MASK (1ULL << I40IWQPC_PMENA_SHIFT) - -#define I40IWQPC_RDMAP_VER_SHIFT 62 -#define I40IWQPC_RDMAP_VER_MASK (3ULL << I40IWQPC_RDMAP_VER_SHIFT) - -#define I40IWQPC_SQADDR_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPC_SQADDR_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IWQPC_RQADDR_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPC_RQADDR_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IWQPC_TTL_SHIFT 0 -#define I40IWQPC_TTL_MASK (0xffUL << I40IWQPC_TTL_SHIFT) - -#define I40IWQPC_RQSIZE_SHIFT 8 -#define I40IWQPC_RQSIZE_MASK (0xfUL << I40IWQPC_RQSIZE_SHIFT) - -#define I40IWQPC_SQSIZE_SHIFT 12 -#define I40IWQPC_SQSIZE_MASK (0xfUL << I40IWQPC_SQSIZE_SHIFT) - -#define I40IWQPC_SRCMACADDRIDX_SHIFT 16 -#define I40IWQPC_SRCMACADDRIDX_MASK (0x3fUL << I40IWQPC_SRCMACADDRIDX_SHIFT) - -#define I40IWQPC_AVOIDSTRETCHACK_SHIFT 23 -#define I40IWQPC_AVOIDSTRETCHACK_MASK (1UL << I40IWQPC_AVOIDSTRETCHACK_SHIFT) - -#define I40IWQPC_TOS_SHIFT 24 -#define I40IWQPC_TOS_MASK (0xffUL << I40IWQPC_TOS_SHIFT) - -#define I40IWQPC_SRCPORTNUM_SHIFT 32 -#define I40IWQPC_SRCPORTNUM_MASK (0xffffULL << I40IWQPC_SRCPORTNUM_SHIFT) - -#define I40IWQPC_DESTPORTNUM_SHIFT 48 -#define I40IWQPC_DESTPORTNUM_MASK (0xffffULL << I40IWQPC_DESTPORTNUM_SHIFT) - -#define I40IWQPC_DESTIPADDR0_SHIFT 32 -#define I40IWQPC_DESTIPADDR0_MASK \ - (0xffffffffULL << I40IWQPC_DESTIPADDR0_SHIFT) - -#define I40IWQPC_DESTIPADDR1_SHIFT 0 -#define I40IWQPC_DESTIPADDR1_MASK \ - (0xffffffffULL << I40IWQPC_DESTIPADDR1_SHIFT) - -#define I40IWQPC_DESTIPADDR2_SHIFT 32 -#define I40IWQPC_DESTIPADDR2_MASK \ - (0xffffffffULL << I40IWQPC_DESTIPADDR2_SHIFT) - -#define I40IWQPC_DESTIPADDR3_SHIFT 0 -#define I40IWQPC_DESTIPADDR3_MASK \ - (0xffffffffULL << I40IWQPC_DESTIPADDR3_SHIFT) - -#define I40IWQPC_SNDMSS_SHIFT 16 -#define I40IWQPC_SNDMSS_MASK (0x3fffUL << I40IWQPC_SNDMSS_SHIFT) - -#define I40IWQPC_VLANTAG_SHIFT 32 -#define I40IWQPC_VLANTAG_MASK (0xffffULL << I40IWQPC_VLANTAG_SHIFT) - -#define I40IWQPC_ARPIDX_SHIFT 48 -#define I40IWQPC_ARPIDX_MASK (0xfffULL << I40IWQPC_ARPIDX_SHIFT) - -#define I40IWQPC_FLOWLABEL_SHIFT 0 -#define I40IWQPC_FLOWLABEL_MASK (0xfffffUL << I40IWQPC_FLOWLABEL_SHIFT) - -#define I40IWQPC_WSCALE_SHIFT 20 -#define I40IWQPC_WSCALE_MASK (1UL << I40IWQPC_WSCALE_SHIFT) - -#define I40IWQPC_KEEPALIVE_SHIFT 21 -#define I40IWQPC_KEEPALIVE_MASK (1UL << I40IWQPC_KEEPALIVE_SHIFT) - -#define I40IWQPC_IGNORE_TCP_OPT_SHIFT 22 -#define I40IWQPC_IGNORE_TCP_OPT_MASK (1UL << I40IWQPC_IGNORE_TCP_OPT_SHIFT) - -#define I40IWQPC_IGNORE_TCP_UNS_OPT_SHIFT 23 -#define I40IWQPC_IGNORE_TCP_UNS_OPT_MASK \ - (1UL << I40IWQPC_IGNORE_TCP_UNS_OPT_SHIFT) - -#define I40IWQPC_TCPSTATE_SHIFT 28 -#define I40IWQPC_TCPSTATE_MASK (0xfUL << I40IWQPC_TCPSTATE_SHIFT) - -#define I40IWQPC_RCVSCALE_SHIFT 32 -#define I40IWQPC_RCVSCALE_MASK (0xfULL << I40IWQPC_RCVSCALE_SHIFT) - -#define I40IWQPC_SNDSCALE_SHIFT 40 -#define I40IWQPC_SNDSCALE_MASK (0xfULL << I40IWQPC_SNDSCALE_SHIFT) - -#define I40IWQPC_PDIDX_SHIFT 48 -#define I40IWQPC_PDIDX_MASK (0x7fffULL << I40IWQPC_PDIDX_SHIFT) - -#define I40IWQPC_KALIVE_TIMER_MAX_PROBES_SHIFT 16 -#define I40IWQPC_KALIVE_TIMER_MAX_PROBES_MASK \ - (0xffUL << I40IWQPC_KALIVE_TIMER_MAX_PROBES_SHIFT) - -#define I40IWQPC_KEEPALIVE_INTERVAL_SHIFT 24 -#define I40IWQPC_KEEPALIVE_INTERVAL_MASK \ - (0xffUL << I40IWQPC_KEEPALIVE_INTERVAL_SHIFT) - -#define I40IWQPC_TIMESTAMP_RECENT_SHIFT 0 -#define I40IWQPC_TIMESTAMP_RECENT_MASK \ - (0xffffffffUL << I40IWQPC_TIMESTAMP_RECENT_SHIFT) - -#define I40IWQPC_TIMESTAMP_AGE_SHIFT 32 -#define I40IWQPC_TIMESTAMP_AGE_MASK \ - (0xffffffffULL << I40IWQPC_TIMESTAMP_AGE_SHIFT) - -#define I40IWQPC_SNDNXT_SHIFT 0 -#define I40IWQPC_SNDNXT_MASK (0xffffffffUL << I40IWQPC_SNDNXT_SHIFT) - -#define I40IWQPC_SNDWND_SHIFT 32 -#define I40IWQPC_SNDWND_MASK (0xffffffffULL << I40IWQPC_SNDWND_SHIFT) - -#define I40IWQPC_RCVNXT_SHIFT 0 -#define I40IWQPC_RCVNXT_MASK (0xffffffffUL << I40IWQPC_RCVNXT_SHIFT) - -#define I40IWQPC_RCVWND_SHIFT 32 -#define I40IWQPC_RCVWND_MASK (0xffffffffULL << I40IWQPC_RCVWND_SHIFT) - -#define I40IWQPC_SNDMAX_SHIFT 0 -#define I40IWQPC_SNDMAX_MASK (0xffffffffUL << I40IWQPC_SNDMAX_SHIFT) - -#define I40IWQPC_SNDUNA_SHIFT 32 -#define I40IWQPC_SNDUNA_MASK (0xffffffffULL << I40IWQPC_SNDUNA_SHIFT) - -#define I40IWQPC_SRTT_SHIFT 0 -#define I40IWQPC_SRTT_MASK (0xffffffffUL << I40IWQPC_SRTT_SHIFT) - -#define I40IWQPC_RTTVAR_SHIFT 32 -#define I40IWQPC_RTTVAR_MASK (0xffffffffULL << I40IWQPC_RTTVAR_SHIFT) - -#define I40IWQPC_SSTHRESH_SHIFT 0 -#define I40IWQPC_SSTHRESH_MASK (0xffffffffUL << I40IWQPC_SSTHRESH_SHIFT) - -#define I40IWQPC_CWND_SHIFT 32 -#define I40IWQPC_CWND_MASK (0xffffffffULL << I40IWQPC_CWND_SHIFT) - -#define I40IWQPC_SNDWL1_SHIFT 0 -#define I40IWQPC_SNDWL1_MASK (0xffffffffUL << I40IWQPC_SNDWL1_SHIFT) - -#define I40IWQPC_SNDWL2_SHIFT 32 -#define I40IWQPC_SNDWL2_MASK (0xffffffffULL << I40IWQPC_SNDWL2_SHIFT) - -#define I40IWQPC_ERR_RQ_IDX_SHIFT 32 -#define I40IWQPC_ERR_RQ_IDX_MASK (0x3fffULL << I40IWQPC_ERR_RQ_IDX_SHIFT) - -#define I40IWQPC_MAXSNDWND_SHIFT 0 -#define I40IWQPC_MAXSNDWND_MASK (0xffffffffUL << I40IWQPC_MAXSNDWND_SHIFT) - -#define I40IWQPC_REXMIT_THRESH_SHIFT 48 -#define I40IWQPC_REXMIT_THRESH_MASK (0x3fULL << I40IWQPC_REXMIT_THRESH_SHIFT) - -#define I40IWQPC_TXCQNUM_SHIFT 0 -#define I40IWQPC_TXCQNUM_MASK (0x1ffffUL << I40IWQPC_TXCQNUM_SHIFT) - -#define I40IWQPC_RXCQNUM_SHIFT 32 -#define I40IWQPC_RXCQNUM_MASK (0x1ffffULL << I40IWQPC_RXCQNUM_SHIFT) - -#define I40IWQPC_Q2ADDR_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPC_Q2ADDR_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IWQPC_LASTBYTESENT_SHIFT 0 -#define I40IWQPC_LASTBYTESENT_MASK (0xffUL << I40IWQPC_LASTBYTESENT_SHIFT) - -#define I40IWQPC_SRQID_SHIFT 32 -#define I40IWQPC_SRQID_MASK (0xffULL << I40IWQPC_SRQID_SHIFT) - -#define I40IWQPC_ORDSIZE_SHIFT 0 -#define I40IWQPC_ORDSIZE_MASK (0x7fUL << I40IWQPC_ORDSIZE_SHIFT) - -#define I40IWQPC_IRDSIZE_SHIFT 16 -#define I40IWQPC_IRDSIZE_MASK (0x3UL << I40IWQPC_IRDSIZE_SHIFT) - -#define I40IWQPC_WRRDRSPOK_SHIFT 20 -#define I40IWQPC_WRRDRSPOK_MASK (1UL << I40IWQPC_WRRDRSPOK_SHIFT) - -#define I40IWQPC_RDOK_SHIFT 21 -#define I40IWQPC_RDOK_MASK (1UL << I40IWQPC_RDOK_SHIFT) - -#define I40IWQPC_SNDMARKERS_SHIFT 22 -#define I40IWQPC_SNDMARKERS_MASK (1UL << I40IWQPC_SNDMARKERS_SHIFT) - -#define I40IWQPC_BINDEN_SHIFT 23 -#define I40IWQPC_BINDEN_MASK (1UL << I40IWQPC_BINDEN_SHIFT) - -#define I40IWQPC_FASTREGEN_SHIFT 24 -#define I40IWQPC_FASTREGEN_MASK (1UL << I40IWQPC_FASTREGEN_SHIFT) - -#define I40IWQPC_PRIVEN_SHIFT 25 -#define I40IWQPC_PRIVEN_MASK (1UL << I40IWQPC_PRIVEN_SHIFT) - -#define I40IWQPC_LSMMPRESENT_SHIFT 26 -#define I40IWQPC_LSMMPRESENT_MASK (1UL << I40IWQPC_LSMMPRESENT_SHIFT) - -#define I40IWQPC_ADJUSTFORLSMM_SHIFT 27 -#define I40IWQPC_ADJUSTFORLSMM_MASK (1UL << I40IWQPC_ADJUSTFORLSMM_SHIFT) - -#define I40IWQPC_IWARPMODE_SHIFT 28 -#define I40IWQPC_IWARPMODE_MASK (1UL << I40IWQPC_IWARPMODE_SHIFT) - -#define I40IWQPC_RCVMARKERS_SHIFT 29 -#define I40IWQPC_RCVMARKERS_MASK (1UL << I40IWQPC_RCVMARKERS_SHIFT) - -#define I40IWQPC_ALIGNHDRS_SHIFT 30 -#define I40IWQPC_ALIGNHDRS_MASK (1UL << I40IWQPC_ALIGNHDRS_SHIFT) - -#define I40IWQPC_RCVNOMPACRC_SHIFT 31 -#define I40IWQPC_RCVNOMPACRC_MASK (1UL << I40IWQPC_RCVNOMPACRC_SHIFT) - -#define I40IWQPC_RCVMARKOFFSET_SHIFT 33 -#define I40IWQPC_RCVMARKOFFSET_MASK (0x1ffULL << I40IWQPC_RCVMARKOFFSET_SHIFT) - -#define I40IWQPC_SNDMARKOFFSET_SHIFT 48 -#define I40IWQPC_SNDMARKOFFSET_MASK (0x1ffULL << I40IWQPC_SNDMARKOFFSET_SHIFT) - -#define I40IWQPC_QPCOMPCTX_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPC_QPCOMPCTX_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IWQPC_SQTPHVAL_SHIFT 0 -#define I40IWQPC_SQTPHVAL_MASK (0xffUL << I40IWQPC_SQTPHVAL_SHIFT) - -#define I40IWQPC_RQTPHVAL_SHIFT 8 -#define I40IWQPC_RQTPHVAL_MASK (0xffUL << I40IWQPC_RQTPHVAL_SHIFT) - -#define I40IWQPC_QSHANDLE_SHIFT 16 -#define I40IWQPC_QSHANDLE_MASK (0x3ffUL << I40IWQPC_QSHANDLE_SHIFT) - -#define I40IWQPC_EXCEPTION_LAN_QUEUE_SHIFT 32 -#define I40IWQPC_EXCEPTION_LAN_QUEUE_MASK (0xfffULL << \ - I40IWQPC_EXCEPTION_LAN_QUEUE_SHIFT) - -#define I40IWQPC_LOCAL_IPADDR3_SHIFT 0 -#define I40IWQPC_LOCAL_IPADDR3_MASK \ - (0xffffffffUL << I40IWQPC_LOCAL_IPADDR3_SHIFT) - -#define I40IWQPC_LOCAL_IPADDR2_SHIFT 32 -#define I40IWQPC_LOCAL_IPADDR2_MASK \ - (0xffffffffULL << I40IWQPC_LOCAL_IPADDR2_SHIFT) - -#define I40IWQPC_LOCAL_IPADDR1_SHIFT 0 -#define I40IWQPC_LOCAL_IPADDR1_MASK \ - (0xffffffffUL << I40IWQPC_LOCAL_IPADDR1_SHIFT) - -#define I40IWQPC_LOCAL_IPADDR0_SHIFT 32 -#define I40IWQPC_LOCAL_IPADDR0_MASK \ - (0xffffffffULL << I40IWQPC_LOCAL_IPADDR0_SHIFT) - -/* wqe size considering 32 bytes per wqe*/ -#define I40IWQP_SW_MIN_WQSIZE 4 /* 128 bytes */ -#define I40IWQP_SW_MAX_WQSIZE 2048 /* 2048 bytes */ -#define I40IWQP_OP_RDMA_WRITE 0 -#define I40IWQP_OP_RDMA_READ 1 -#define I40IWQP_OP_RDMA_SEND 3 -#define I40IWQP_OP_RDMA_SEND_INV 4 -#define I40IWQP_OP_RDMA_SEND_SOL_EVENT 5 -#define I40IWQP_OP_RDMA_SEND_SOL_EVENT_INV 6 -#define I40IWQP_OP_BIND_MW 8 -#define I40IWQP_OP_FAST_REGISTER 9 -#define I40IWQP_OP_LOCAL_INVALIDATE 10 -#define I40IWQP_OP_RDMA_READ_LOC_INV 11 -#define I40IWQP_OP_NOP 12 - -#define I40IW_RSVD_SHIFT 41 -#define I40IW_RSVD_MASK (0x7fffULL << I40IW_RSVD_SHIFT) - -/* iwarp QP SQ WQE common fields */ -#define I40IWQPSQ_OPCODE_SHIFT 32 -#define I40IWQPSQ_OPCODE_MASK (0x3fULL << I40IWQPSQ_OPCODE_SHIFT) - -#define I40IWQPSQ_ADDFRAGCNT_SHIFT 38 -#define I40IWQPSQ_ADDFRAGCNT_MASK (0x7ULL << I40IWQPSQ_ADDFRAGCNT_SHIFT) - -#define I40IWQPSQ_PUSHWQE_SHIFT 56 -#define I40IWQPSQ_PUSHWQE_MASK (1ULL << I40IWQPSQ_PUSHWQE_SHIFT) - -#define I40IWQPSQ_STREAMMODE_SHIFT 58 -#define I40IWQPSQ_STREAMMODE_MASK (1ULL << I40IWQPSQ_STREAMMODE_SHIFT) - -#define I40IWQPSQ_WAITFORRCVPDU_SHIFT 59 -#define I40IWQPSQ_WAITFORRCVPDU_MASK (1ULL << I40IWQPSQ_WAITFORRCVPDU_SHIFT) - -#define I40IWQPSQ_READFENCE_SHIFT 60 -#define I40IWQPSQ_READFENCE_MASK (1ULL << I40IWQPSQ_READFENCE_SHIFT) - -#define I40IWQPSQ_LOCALFENCE_SHIFT 61 -#define I40IWQPSQ_LOCALFENCE_MASK (1ULL << I40IWQPSQ_LOCALFENCE_SHIFT) - -#define I40IWQPSQ_SIGCOMPL_SHIFT 62 -#define I40IWQPSQ_SIGCOMPL_MASK (1ULL << I40IWQPSQ_SIGCOMPL_SHIFT) - -#define I40IWQPSQ_VALID_SHIFT 63 -#define I40IWQPSQ_VALID_MASK (1ULL << I40IWQPSQ_VALID_SHIFT) - -#define I40IWQPSQ_FRAG_TO_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPSQ_FRAG_TO_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IWQPSQ_FRAG_LEN_SHIFT 0 -#define I40IWQPSQ_FRAG_LEN_MASK (0xffffffffUL << I40IWQPSQ_FRAG_LEN_SHIFT) - -#define I40IWQPSQ_FRAG_STAG_SHIFT 32 -#define I40IWQPSQ_FRAG_STAG_MASK (0xffffffffULL << I40IWQPSQ_FRAG_STAG_SHIFT) - -#define I40IWQPSQ_REMSTAGINV_SHIFT 0 -#define I40IWQPSQ_REMSTAGINV_MASK (0xffffffffUL << I40IWQPSQ_REMSTAGINV_SHIFT) - -#define I40IWQPSQ_INLINEDATAFLAG_SHIFT 57 -#define I40IWQPSQ_INLINEDATAFLAG_MASK (1ULL << I40IWQPSQ_INLINEDATAFLAG_SHIFT) - -#define I40IWQPSQ_INLINEDATALEN_SHIFT 48 -#define I40IWQPSQ_INLINEDATALEN_MASK \ - (0x7fULL << I40IWQPSQ_INLINEDATALEN_SHIFT) - -/* iwarp send with push mode */ -#define I40IWQPSQ_WQDESCIDX_SHIFT 0 -#define I40IWQPSQ_WQDESCIDX_MASK (0x3fffUL << I40IWQPSQ_WQDESCIDX_SHIFT) - -/* rdma write */ -#define I40IWQPSQ_REMSTAG_SHIFT 0 -#define I40IWQPSQ_REMSTAG_MASK (0xffffffffUL << I40IWQPSQ_REMSTAG_SHIFT) - -#define I40IWQPSQ_REMTO_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPSQ_REMTO_MASK I40IW_CQPHC_QPCTX_MASK - -/* memory window */ -#define I40IWQPSQ_STAGRIGHTS_SHIFT 48 -#define I40IWQPSQ_STAGRIGHTS_MASK (0x1fULL << I40IWQPSQ_STAGRIGHTS_SHIFT) - -#define I40IWQPSQ_VABASEDTO_SHIFT 53 -#define I40IWQPSQ_VABASEDTO_MASK (1ULL << I40IWQPSQ_VABASEDTO_SHIFT) - -#define I40IWQPSQ_MWLEN_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPSQ_MWLEN_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IWQPSQ_PARENTMRSTAG_SHIFT 0 -#define I40IWQPSQ_PARENTMRSTAG_MASK \ - (0xffffffffUL << I40IWQPSQ_PARENTMRSTAG_SHIFT) - -#define I40IWQPSQ_MWSTAG_SHIFT 32 -#define I40IWQPSQ_MWSTAG_MASK (0xffffffffULL << I40IWQPSQ_MWSTAG_SHIFT) - -#define I40IWQPSQ_BASEVA_TO_FBO_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPSQ_BASEVA_TO_FBO_MASK I40IW_CQPHC_QPCTX_MASK - -/* Local Invalidate */ -#define I40IWQPSQ_LOCSTAG_SHIFT 32 -#define I40IWQPSQ_LOCSTAG_MASK (0xffffffffULL << I40IWQPSQ_LOCSTAG_SHIFT) - -/* Fast Register */ -#define I40IWQPSQ_STAGKEY_SHIFT 0 -#define I40IWQPSQ_STAGKEY_MASK (0xffUL << I40IWQPSQ_STAGKEY_SHIFT) - -#define I40IWQPSQ_STAGINDEX_SHIFT 8 -#define I40IWQPSQ_STAGINDEX_MASK (0xffffffUL << I40IWQPSQ_STAGINDEX_SHIFT) - -#define I40IWQPSQ_COPYHOSTPBLS_SHIFT 43 -#define I40IWQPSQ_COPYHOSTPBLS_MASK (1ULL << I40IWQPSQ_COPYHOSTPBLS_SHIFT) - -#define I40IWQPSQ_LPBLSIZE_SHIFT 44 -#define I40IWQPSQ_LPBLSIZE_MASK (3ULL << I40IWQPSQ_LPBLSIZE_SHIFT) - -#define I40IWQPSQ_HPAGESIZE_SHIFT 46 -#define I40IWQPSQ_HPAGESIZE_MASK (3ULL << I40IWQPSQ_HPAGESIZE_SHIFT) - -#define I40IWQPSQ_STAGLEN_SHIFT 0 -#define I40IWQPSQ_STAGLEN_MASK (0x1ffffffffffULL << I40IWQPSQ_STAGLEN_SHIFT) - -#define I40IWQPSQ_FIRSTPMPBLIDXLO_SHIFT 48 -#define I40IWQPSQ_FIRSTPMPBLIDXLO_MASK \ - (0xffffULL << I40IWQPSQ_FIRSTPMPBLIDXLO_SHIFT) - -#define I40IWQPSQ_FIRSTPMPBLIDXHI_SHIFT 0 -#define I40IWQPSQ_FIRSTPMPBLIDXHI_MASK \ - (0xfffUL << I40IWQPSQ_FIRSTPMPBLIDXHI_SHIFT) - -#define I40IWQPSQ_PBLADDR_SHIFT 12 -#define I40IWQPSQ_PBLADDR_MASK (0xfffffffffffffULL << I40IWQPSQ_PBLADDR_SHIFT) - -/* iwarp QP RQ WQE common fields */ -#define I40IWQPRQ_ADDFRAGCNT_SHIFT I40IWQPSQ_ADDFRAGCNT_SHIFT -#define I40IWQPRQ_ADDFRAGCNT_MASK I40IWQPSQ_ADDFRAGCNT_MASK - -#define I40IWQPRQ_VALID_SHIFT I40IWQPSQ_VALID_SHIFT -#define I40IWQPRQ_VALID_MASK I40IWQPSQ_VALID_MASK - -#define I40IWQPRQ_COMPLCTX_SHIFT I40IW_CQPHC_QPCTX_SHIFT -#define I40IWQPRQ_COMPLCTX_MASK I40IW_CQPHC_QPCTX_MASK - -#define I40IWQPRQ_FRAG_LEN_SHIFT I40IWQPSQ_FRAG_LEN_SHIFT -#define I40IWQPRQ_FRAG_LEN_MASK I40IWQPSQ_FRAG_LEN_MASK - -#define I40IWQPRQ_STAG_SHIFT I40IWQPSQ_FRAG_STAG_SHIFT -#define I40IWQPRQ_STAG_MASK I40IWQPSQ_FRAG_STAG_MASK - -#define I40IWQPRQ_TO_SHIFT I40IWQPSQ_FRAG_TO_SHIFT -#define I40IWQPRQ_TO_MASK I40IWQPSQ_FRAG_TO_MASK - -/* Query FPM CQP buf */ -#define I40IW_QUERY_FPM_MAX_QPS_SHIFT 0 -#define I40IW_QUERY_FPM_MAX_QPS_MASK \ - (0x7ffffUL << I40IW_QUERY_FPM_MAX_QPS_SHIFT) - -#define I40IW_QUERY_FPM_MAX_CQS_SHIFT 0 -#define I40IW_QUERY_FPM_MAX_CQS_MASK \ - (0x3ffffUL << I40IW_QUERY_FPM_MAX_CQS_SHIFT) - -#define I40IW_QUERY_FPM_FIRST_PE_SD_INDEX_SHIFT 0 -#define I40IW_QUERY_FPM_FIRST_PE_SD_INDEX_MASK \ - (0x3fffUL << I40IW_QUERY_FPM_FIRST_PE_SD_INDEX_SHIFT) - -#define I40IW_QUERY_FPM_MAX_PE_SDS_SHIFT 32 -#define I40IW_QUERY_FPM_MAX_PE_SDS_MASK \ - (0x3fffULL << I40IW_QUERY_FPM_MAX_PE_SDS_SHIFT) - -#define I40IW_QUERY_FPM_MAX_QPS_SHIFT 0 -#define I40IW_QUERY_FPM_MAX_QPS_MASK \ - (0x7ffffUL << I40IW_QUERY_FPM_MAX_QPS_SHIFT) - -#define I40IW_QUERY_FPM_MAX_CQS_SHIFT 0 -#define I40IW_QUERY_FPM_MAX_CQS_MASK \ - (0x3ffffUL << I40IW_QUERY_FPM_MAX_CQS_SHIFT) - -#define I40IW_QUERY_FPM_MAX_CEQS_SHIFT 0 -#define I40IW_QUERY_FPM_MAX_CEQS_MASK \ - (0xffUL << I40IW_QUERY_FPM_MAX_CEQS_SHIFT) - -#define I40IW_QUERY_FPM_XFBLOCKSIZE_SHIFT 32 -#define I40IW_QUERY_FPM_XFBLOCKSIZE_MASK \ - (0xffffffffULL << I40IW_QUERY_FPM_XFBLOCKSIZE_SHIFT) - -#define I40IW_QUERY_FPM_Q1BLOCKSIZE_SHIFT 32 -#define I40IW_QUERY_FPM_Q1BLOCKSIZE_MASK \ - (0xffffffffULL << I40IW_QUERY_FPM_Q1BLOCKSIZE_SHIFT) - -#define I40IW_QUERY_FPM_HTMULTIPLIER_SHIFT 16 -#define I40IW_QUERY_FPM_HTMULTIPLIER_MASK \ - (0xfUL << I40IW_QUERY_FPM_HTMULTIPLIER_SHIFT) - -#define I40IW_QUERY_FPM_TIMERBUCKET_SHIFT 32 -#define I40IW_QUERY_FPM_TIMERBUCKET_MASK \ - (0xffFFULL << I40IW_QUERY_FPM_TIMERBUCKET_SHIFT) - -/* Static HMC pages allocated buf */ -#define I40IW_SHMC_PAGE_ALLOCATED_HMC_FN_ID_SHIFT 0 -#define I40IW_SHMC_PAGE_ALLOCATED_HMC_FN_ID_MASK \ - (0x3fUL << I40IW_SHMC_PAGE_ALLOCATED_HMC_FN_ID_SHIFT) - -#define I40IW_HW_PAGE_SIZE 4096 -#define I40IW_DONE_COUNT 1000 -#define I40IW_SLEEP_COUNT 10 - -enum { - I40IW_QUEUES_ALIGNMENT_MASK = (128 - 1), - I40IW_AEQ_ALIGNMENT_MASK = (256 - 1), - I40IW_Q2_ALIGNMENT_MASK = (256 - 1), - I40IW_CEQ_ALIGNMENT_MASK = (256 - 1), - I40IW_CQ0_ALIGNMENT_MASK = (256 - 1), - I40IW_HOST_CTX_ALIGNMENT_MASK = (4 - 1), - I40IW_SHADOWAREA_MASK = (128 - 1), - I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK = 0, - I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK = 0 -}; - -enum i40iw_alignment { - I40IW_CQP_ALIGNMENT = 0x200, - I40IW_AEQ_ALIGNMENT = 0x100, - I40IW_CEQ_ALIGNMENT = 0x100, - I40IW_CQ0_ALIGNMENT = 0x100, - I40IW_SD_BUF_ALIGNMENT = 0x100 -}; - -#define I40IW_WQE_SIZE_64 64 - -#define I40IW_QP_WQE_MIN_SIZE 32 -#define I40IW_QP_WQE_MAX_SIZE 128 - -#define I40IW_CQE_QTYPE_RQ 0 -#define I40IW_CQE_QTYPE_SQ 1 - -#define I40IW_RING_INIT(_ring, _size) \ - { \ - (_ring).head = 0; \ - (_ring).tail = 0; \ - (_ring).size = (_size); \ - } -#define I40IW_RING_GETSIZE(_ring) ((_ring).size) -#define I40IW_RING_GETCURRENT_HEAD(_ring) ((_ring).head) -#define I40IW_RING_GETCURRENT_TAIL(_ring) ((_ring).tail) - -#define I40IW_RING_MOVE_HEAD(_ring, _retcode) \ - { \ - register u32 size; \ - size = (_ring).size; \ - if (!I40IW_RING_FULL_ERR(_ring)) { \ - (_ring).head = ((_ring).head + 1) % size; \ - (_retcode) = 0; \ - } else { \ - (_retcode) = I40IW_ERR_RING_FULL; \ - } \ - } - -#define I40IW_RING_MOVE_HEAD_BY_COUNT(_ring, _count, _retcode) \ - { \ - register u32 size; \ - size = (_ring).size; \ - if ((I40IW_RING_WORK_AVAILABLE(_ring) + (_count)) < size) { \ - (_ring).head = ((_ring).head + (_count)) % size; \ - (_retcode) = 0; \ - } else { \ - (_retcode) = I40IW_ERR_RING_FULL; \ - } \ - } - -#define I40IW_RING_MOVE_TAIL(_ring) \ - (_ring).tail = ((_ring).tail + 1) % (_ring).size - -#define I40IW_RING_MOVE_HEAD_NOCHECK(_ring) \ - (_ring).head = ((_ring).head + 1) % (_ring).size - -#define I40IW_RING_MOVE_TAIL_BY_COUNT(_ring, _count) \ - (_ring).tail = ((_ring).tail + (_count)) % (_ring).size - -#define I40IW_RING_SET_TAIL(_ring, _pos) \ - (_ring).tail = (_pos) % (_ring).size - -#define I40IW_RING_FULL_ERR(_ring) \ - ( \ - (I40IW_RING_WORK_AVAILABLE(_ring) == ((_ring).size - 1)) \ - ) - -#define I40IW_ERR_RING_FULL2(_ring) \ - ( \ - (I40IW_RING_WORK_AVAILABLE(_ring) == ((_ring).size - 2)) \ - ) - -#define I40IW_ERR_RING_FULL3(_ring) \ - ( \ - (I40IW_RING_WORK_AVAILABLE(_ring) == ((_ring).size - 3)) \ - ) - -#define I40IW_RING_MORE_WORK(_ring) \ - ( \ - (I40IW_RING_WORK_AVAILABLE(_ring) != 0) \ - ) - -#define I40IW_RING_WORK_AVAILABLE(_ring) \ - ( \ - (((_ring).head + (_ring).size - (_ring).tail) % (_ring).size) \ - ) - -#define I40IW_RING_GET_WQES_AVAILABLE(_ring) \ - ( \ - ((_ring).size - I40IW_RING_WORK_AVAILABLE(_ring) - 1) \ - ) - -#define I40IW_ATOMIC_RING_MOVE_HEAD(_ring, index, _retcode) \ - { \ - index = I40IW_RING_GETCURRENT_HEAD(_ring); \ - I40IW_RING_MOVE_HEAD(_ring, _retcode); \ - } - -/* Async Events codes */ -#define I40IW_AE_AMP_UNALLOCATED_STAG 0x0102 -#define I40IW_AE_AMP_INVALID_STAG 0x0103 -#define I40IW_AE_AMP_BAD_QP 0x0104 -#define I40IW_AE_AMP_BAD_PD 0x0105 -#define I40IW_AE_AMP_BAD_STAG_KEY 0x0106 -#define I40IW_AE_AMP_BAD_STAG_INDEX 0x0107 -#define I40IW_AE_AMP_BOUNDS_VIOLATION 0x0108 -#define I40IW_AE_AMP_RIGHTS_VIOLATION 0x0109 -#define I40IW_AE_AMP_TO_WRAP 0x010a -#define I40IW_AE_AMP_FASTREG_SHARED 0x010b -#define I40IW_AE_AMP_FASTREG_VALID_STAG 0x010c -#define I40IW_AE_AMP_FASTREG_MW_STAG 0x010d -#define I40IW_AE_AMP_FASTREG_INVALID_RIGHTS 0x010e -#define I40IW_AE_AMP_FASTREG_PBL_TABLE_OVERFLOW 0x010f -#define I40IW_AE_AMP_FASTREG_INVALID_LENGTH 0x0110 -#define I40IW_AE_AMP_INVALIDATE_SHARED 0x0111 -#define I40IW_AE_AMP_INVALIDATE_NO_REMOTE_ACCESS_RIGHTS 0x0112 -#define I40IW_AE_AMP_INVALIDATE_MR_WITH_BOUND_WINDOWS 0x0113 -#define I40IW_AE_AMP_MWBIND_VALID_STAG 0x0114 -#define I40IW_AE_AMP_MWBIND_OF_MR_STAG 0x0115 -#define I40IW_AE_AMP_MWBIND_TO_ZERO_BASED_STAG 0x0116 -#define I40IW_AE_AMP_MWBIND_TO_MW_STAG 0x0117 -#define I40IW_AE_AMP_MWBIND_INVALID_RIGHTS 0x0118 -#define I40IW_AE_AMP_MWBIND_INVALID_BOUNDS 0x0119 -#define I40IW_AE_AMP_MWBIND_TO_INVALID_PARENT 0x011a -#define I40IW_AE_AMP_MWBIND_BIND_DISABLED 0x011b -#define I40IW_AE_AMP_WQE_INVALID_PARAMETER 0x0130 -#define I40IW_AE_BAD_CLOSE 0x0201 -#define I40IW_AE_RDMAP_ROE_BAD_LLP_CLOSE 0x0202 -#define I40IW_AE_CQ_OPERATION_ERROR 0x0203 -#define I40IW_AE_PRIV_OPERATION_DENIED 0x011c -#define I40IW_AE_RDMA_READ_WHILE_ORD_ZERO 0x0205 -#define I40IW_AE_STAG_ZERO_INVALID 0x0206 -#define I40IW_AE_IB_RREQ_AND_Q1_FULL 0x0207 -#define I40IW_AE_SRQ_LIMIT 0x0209 -#define I40IW_AE_WQE_UNEXPECTED_OPCODE 0x020a -#define I40IW_AE_WQE_INVALID_PARAMETER 0x020b -#define I40IW_AE_WQE_LSMM_TOO_LONG 0x0220 -#define I40IW_AE_DDP_INVALID_MSN_GAP_IN_MSN 0x0301 -#define I40IW_AE_DDP_INVALID_MSN_RANGE_IS_NOT_VALID 0x0302 -#define I40IW_AE_DDP_UBE_DDP_MESSAGE_TOO_LONG_FOR_AVAILABLE_BUFFER 0x0303 -#define I40IW_AE_DDP_UBE_INVALID_DDP_VERSION 0x0304 -#define I40IW_AE_DDP_UBE_INVALID_MO 0x0305 -#define I40IW_AE_DDP_UBE_INVALID_MSN_NO_BUFFER_AVAILABLE 0x0306 -#define I40IW_AE_DDP_UBE_INVALID_QN 0x0307 -#define I40IW_AE_DDP_NO_L_BIT 0x0308 -#define I40IW_AE_RDMAP_ROE_INVALID_RDMAP_VERSION 0x0311 -#define I40IW_AE_RDMAP_ROE_UNEXPECTED_OPCODE 0x0312 -#define I40IW_AE_ROE_INVALID_RDMA_READ_REQUEST 0x0313 -#define I40IW_AE_ROE_INVALID_RDMA_WRITE_OR_READ_RESP 0x0314 -#define I40IW_AE_INVALID_ARP_ENTRY 0x0401 -#define I40IW_AE_INVALID_TCP_OPTION_RCVD 0x0402 -#define I40IW_AE_STALE_ARP_ENTRY 0x0403 -#define I40IW_AE_INVALID_WQE_LENGTH 0x0404 -#define I40IW_AE_INVALID_MAC_ENTRY 0x0405 -#define I40IW_AE_LLP_CLOSE_COMPLETE 0x0501 -#define I40IW_AE_LLP_CONNECTION_RESET 0x0502 -#define I40IW_AE_LLP_FIN_RECEIVED 0x0503 -#define I40IW_AE_LLP_RECEIVED_MARKER_AND_LENGTH_FIELDS_DONT_MATCH 0x0504 -#define I40IW_AE_LLP_RECEIVED_MPA_CRC_ERROR 0x0505 -#define I40IW_AE_LLP_SEGMENT_TOO_LARGE 0x0506 -#define I40IW_AE_LLP_SEGMENT_TOO_SMALL 0x0507 -#define I40IW_AE_LLP_SYN_RECEIVED 0x0508 -#define I40IW_AE_LLP_TERMINATE_RECEIVED 0x0509 -#define I40IW_AE_LLP_TOO_MANY_RETRIES 0x050a -#define I40IW_AE_LLP_TOO_MANY_KEEPALIVE_RETRIES 0x050b -#define I40IW_AE_LLP_DOUBT_REACHABILITY 0x050c -#define I40IW_AE_LLP_RX_VLAN_MISMATCH 0x050d -#define I40IW_AE_RESOURCE_EXHAUSTION 0x0520 -#define I40IW_AE_RESET_SENT 0x0601 -#define I40IW_AE_TERMINATE_SENT 0x0602 -#define I40IW_AE_RESET_NOT_SENT 0x0603 -#define I40IW_AE_LCE_QP_CATASTROPHIC 0x0700 -#define I40IW_AE_LCE_FUNCTION_CATASTROPHIC 0x0701 -#define I40IW_AE_LCE_CQ_CATASTROPHIC 0x0702 -#define I40IW_AE_UDA_XMIT_FRAG_SEQ 0x0800 -#define I40IW_AE_UDA_XMIT_DGRAM_TOO_LONG 0x0801 -#define I40IW_AE_UDA_XMIT_IPADDR_MISMATCH 0x0802 -#define I40IW_AE_QP_SUSPEND_COMPLETE 0x0900 - -#define OP_DELETE_LOCAL_MAC_IPADDR_ENTRY 1 -#define OP_CEQ_DESTROY 2 -#define OP_AEQ_DESTROY 3 -#define OP_DELETE_ARP_CACHE_ENTRY 4 -#define OP_MANAGE_APBVT_ENTRY 5 -#define OP_CEQ_CREATE 6 -#define OP_AEQ_CREATE 7 -#define OP_ALLOC_LOCAL_MAC_IPADDR_ENTRY 8 -#define OP_ADD_LOCAL_MAC_IPADDR_ENTRY 9 -#define OP_MANAGE_QHASH_TABLE_ENTRY 10 -#define OP_QP_MODIFY 11 -#define OP_QP_UPLOAD_CONTEXT 12 -#define OP_CQ_CREATE 13 -#define OP_CQ_DESTROY 14 -#define OP_QP_CREATE 15 -#define OP_QP_DESTROY 16 -#define OP_ALLOC_STAG 17 -#define OP_MR_REG_NON_SHARED 18 -#define OP_DEALLOC_STAG 19 -#define OP_MW_ALLOC 20 -#define OP_QP_FLUSH_WQES 21 -#define OP_ADD_ARP_CACHE_ENTRY 22 -#define OP_MANAGE_PUSH_PAGE 23 -#define OP_UPDATE_PE_SDS 24 -#define OP_MANAGE_HMC_PM_FUNC_TABLE 25 -#define OP_SUSPEND 26 -#define OP_RESUME 27 -#define OP_MANAGE_VF_PBLE_BP 28 -#define OP_QUERY_FPM_VALUES 29 -#define OP_COMMIT_FPM_VALUES 30 -#define OP_SIZE_CQP_STAT_ARRAY 31 - -#endif diff --git a/usr/rdma-core/providers/i40iw/i40iw_osdep.h b/usr/rdma-core/providers/i40iw/i40iw_osdep.h deleted file mode 100644 index 92bedd316..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_osdep.h +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#ifndef I40IW_OSDEP_H -#define I40IW_OSDEP_H - -#include -#include -#include -#include -#include -typedef unsigned char u8; -typedef unsigned long long u64; -typedef unsigned int u32; -typedef unsigned short u16; -typedef unsigned long i40iw_uintptr; -typedef unsigned long *i40iw_bits_t; -typedef __be16 BE16; -typedef __be32 BE32; -typedef __be64 BE64; -typedef __le16 LE16; -typedef __le32 LE32; -typedef __le64 LE64; - -#define STATS_TIMER_DELAY 1000 -#define INLINE inline - -static inline void set_64bit_val(u64 *wqe_words, u32 byte_index, u64 value) -{ - wqe_words[byte_index >> 3] = value; -} - -/** - * set_32bit_val - set 32 value to hw wqe - * @wqe_words: wqe addr to write - * @byte_index: index in wqe - * @value: value to write - **/ -static inline void set_32bit_val(u32 *wqe_words, u32 byte_index, u32 value) -{ - wqe_words[byte_index >> 2] = value; -} - -/** - * get_64bit_val - read 64 bit value from wqe - * @wqe_words: wqe addr - * @byte_index: index to read from - * @value: read value - **/ -static inline void get_64bit_val(u64 *wqe_words, u32 byte_index, u64 *value) -{ - *value = wqe_words[byte_index >> 3]; -} - -/** - * get_32bit_val - read 32 bit value from wqe - * @wqe_words: wqe addr - * @byte_index: index to reaad from - * @value: return 32 bit value - **/ -static inline void get_32bit_val(u32 *wqe_words, u32 byte_index, u32 *value) -{ - *value = wqe_words[byte_index >> 2]; -} - -#define i40iw_get_virt_to_phy -#define IOMEM - -static inline void db_wr32(u32 value, u32 *wqe_word) -{ - *wqe_word = value; -} - -#define ACQUIRE_LOCK() -#define RELEASE_LOCK() - -#endif /* _I40IW_OSDEP_H_ */ diff --git a/usr/rdma-core/providers/i40iw/i40iw_register.h b/usr/rdma-core/providers/i40iw/i40iw_register.h deleted file mode 100644 index 57768184e..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_register.h +++ /dev/null @@ -1,1030 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#ifndef I40IW_REGISTER_H -#define I40IW_REGISTER_H - -#define I40E_GLGEN_STAT 0x000B612C /* Reset: POR */ - -#define I40E_PFHMC_PDINV 0x000C0300 /* Reset: PFR */ -#define I40E_PFHMC_PDINV_PMSDIDX_SHIFT 0 -#define I40E_PFHMC_PDINV_PMSDIDX_MASK (0xFFF << I40E_PFHMC_PDINV_PMSDIDX_SHIFT) -#define I40E_PFHMC_PDINV_PMPDIDX_SHIFT 16 -#define I40E_PFHMC_PDINV_PMPDIDX_MASK (0x1FF << I40E_PFHMC_PDINV_PMPDIDX_SHIFT) -#define I40E_PFHMC_SDCMD_PMSDWR_SHIFT 31 -#define I40E_PFHMC_SDCMD_PMSDWR_MASK (0x1 << I40E_PFHMC_SDCMD_PMSDWR_SHIFT) -#define I40E_PFHMC_SDDATALOW_PMSDVALID_SHIFT 0 -#define I40E_PFHMC_SDDATALOW_PMSDVALID_MASK (0x1 << I40E_PFHMC_SDDATALOW_PMSDVALID_SHIFT) -#define I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT 1 -#define I40E_PFHMC_SDDATALOW_PMSDTYPE_MASK (0x1 << I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT) -#define I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT 2 -#define I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_MASK (0x3FF << I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT) - -#define I40E_PFINT_DYN_CTLN(_INTPF) (0x00034800 + ((_INTPF) * 4)) /* _i=0...511 */ /* Reset: PFR */ -#define I40E_PFINT_DYN_CTLN_INTENA_SHIFT 0 -#define I40E_PFINT_DYN_CTLN_INTENA_MASK (0x1 << I40E_PFINT_DYN_CTLN_INTENA_SHIFT) -#define I40E_PFINT_DYN_CTLN_CLEARPBA_SHIFT 1 -#define I40E_PFINT_DYN_CTLN_CLEARPBA_MASK (0x1 << I40E_PFINT_DYN_CTLN_CLEARPBA_SHIFT) -#define I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT 3 -#define I40E_PFINT_DYN_CTLN_ITR_INDX_MASK (0x3 << I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT) - -#define I40E_VFINT_DYN_CTLN1(_INTVF) (0x00003800 + ((_INTVF) * 4)) /* _i=0...15 */ /* Reset: VFR */ -#define I40E_GLHMC_VFPDINV(_i) (0x000C8300 + ((_i) * 4)) /* _i=0...31 */ /* Reset: CORER */ - -#define I40E_PFHMC_PDINV_PMSDPARTSEL_SHIFT 15 -#define I40E_PFHMC_PDINV_PMSDPARTSEL_MASK (0x1 << I40E_PFHMC_PDINV_PMSDPARTSEL_SHIFT) -#define I40E_GLPCI_LBARCTRL 0x000BE484 /* Reset: POR */ -#define I40E_GLPCI_LBARCTRL_PE_DB_SIZE_SHIFT 4 -#define I40E_GLPCI_LBARCTRL_PE_DB_SIZE_MASK (0x3 << I40E_GLPCI_LBARCTRL_PE_DB_SIZE_SHIFT) -#define I40E_GLPCI_DREVID 0x0009C480 /* Reset: PCIR */ -#define I40E_GLPCI_DREVID_DEFAULT_REVID_SHIFT 0 -#define I40E_GLPCI_DREVID_DEFAULT_REVID_MASK 0xFF - -#define I40E_PFPE_AEQALLOC 0x00131180 /* Reset: PFR */ -#define I40E_PFPE_AEQALLOC_AECOUNT_SHIFT 0 -#define I40E_PFPE_AEQALLOC_AECOUNT_MASK (0xFFFFFFFF << I40E_PFPE_AEQALLOC_AECOUNT_SHIFT) -#define I40E_PFPE_CCQPHIGH 0x00008200 /* Reset: PFR */ -#define I40E_PFPE_CCQPHIGH_PECCQPHIGH_SHIFT 0 -#define I40E_PFPE_CCQPHIGH_PECCQPHIGH_MASK (0xFFFFFFFF << I40E_PFPE_CCQPHIGH_PECCQPHIGH_SHIFT) -#define I40E_PFPE_CCQPLOW 0x00008180 /* Reset: PFR */ -#define I40E_PFPE_CCQPLOW_PECCQPLOW_SHIFT 0 -#define I40E_PFPE_CCQPLOW_PECCQPLOW_MASK (0xFFFFFFFF << I40E_PFPE_CCQPLOW_PECCQPLOW_SHIFT) -#define I40E_PFPE_CCQPSTATUS 0x00008100 /* Reset: PFR */ -#define I40E_PFPE_CCQPSTATUS_CCQP_DONE_SHIFT 0 -#define I40E_PFPE_CCQPSTATUS_CCQP_DONE_MASK (0x1 << I40E_PFPE_CCQPSTATUS_CCQP_DONE_SHIFT) -#define I40E_PFPE_CCQPSTATUS_HMC_PROFILE_SHIFT 4 -#define I40E_PFPE_CCQPSTATUS_HMC_PROFILE_MASK (0x7 << I40E_PFPE_CCQPSTATUS_HMC_PROFILE_SHIFT) -#define I40E_PFPE_CCQPSTATUS_RDMA_EN_VFS_SHIFT 16 -#define I40E_PFPE_CCQPSTATUS_RDMA_EN_VFS_MASK (0x3F << I40E_PFPE_CCQPSTATUS_RDMA_EN_VFS_SHIFT) -#define I40E_PFPE_CCQPSTATUS_CCQP_ERR_SHIFT 31 -#define I40E_PFPE_CCQPSTATUS_CCQP_ERR_MASK (0x1 << I40E_PFPE_CCQPSTATUS_CCQP_ERR_SHIFT) -#define I40E_PFPE_CQACK 0x00131100 /* Reset: PFR */ -#define I40E_PFPE_CQACK_PECQID_SHIFT 0 -#define I40E_PFPE_CQACK_PECQID_MASK (0x1FFFF << I40E_PFPE_CQACK_PECQID_SHIFT) -#define I40E_PFPE_CQARM 0x00131080 /* Reset: PFR */ -#define I40E_PFPE_CQARM_PECQID_SHIFT 0 -#define I40E_PFPE_CQARM_PECQID_MASK (0x1FFFF << I40E_PFPE_CQARM_PECQID_SHIFT) -#define I40E_PFPE_CQPDB 0x00008000 /* Reset: PFR */ -#define I40E_PFPE_CQPDB_WQHEAD_SHIFT 0 -#define I40E_PFPE_CQPDB_WQHEAD_MASK (0x7FF << I40E_PFPE_CQPDB_WQHEAD_SHIFT) -#define I40E_PFPE_CQPERRCODES 0x00008880 /* Reset: PFR */ -#define I40E_PFPE_CQPERRCODES_CQP_MINOR_CODE_SHIFT 0 -#define I40E_PFPE_CQPERRCODES_CQP_MINOR_CODE_MASK (0xFFFF << I40E_PFPE_CQPERRCODES_CQP_MINOR_CODE_SHIFT) -#define I40E_PFPE_CQPERRCODES_CQP_MAJOR_CODE_SHIFT 16 -#define I40E_PFPE_CQPERRCODES_CQP_MAJOR_CODE_MASK (0xFFFF << I40E_PFPE_CQPERRCODES_CQP_MAJOR_CODE_SHIFT) -#define I40E_PFPE_CQPTAIL 0x00008080 /* Reset: PFR */ -#define I40E_PFPE_CQPTAIL_WQTAIL_SHIFT 0 -#define I40E_PFPE_CQPTAIL_WQTAIL_MASK (0x7FF << I40E_PFPE_CQPTAIL_WQTAIL_SHIFT) -#define I40E_PFPE_CQPTAIL_CQP_OP_ERR_SHIFT 31 -#define I40E_PFPE_CQPTAIL_CQP_OP_ERR_MASK (0x1 << I40E_PFPE_CQPTAIL_CQP_OP_ERR_SHIFT) -#define I40E_PFPE_FLMQ1ALLOCERR 0x00008980 /* Reset: PFR */ -#define I40E_PFPE_FLMQ1ALLOCERR_ERROR_COUNT_SHIFT 0 -#define I40E_PFPE_FLMQ1ALLOCERR_ERROR_COUNT_MASK (0xFFFF << I40E_PFPE_FLMQ1ALLOCERR_ERROR_COUNT_SHIFT) -#define I40E_PFPE_FLMXMITALLOCERR 0x00008900 /* Reset: PFR */ -#define I40E_PFPE_FLMXMITALLOCERR_ERROR_COUNT_SHIFT 0 -#define I40E_PFPE_FLMXMITALLOCERR_ERROR_COUNT_MASK (0xFFFF << I40E_PFPE_FLMXMITALLOCERR_ERROR_COUNT_SHIFT) -#define I40E_PFPE_IPCONFIG0 0x00008280 /* Reset: PFR */ -#define I40E_PFPE_IPCONFIG0_PEIPID_SHIFT 0 -#define I40E_PFPE_IPCONFIG0_PEIPID_MASK (0xFFFF << I40E_PFPE_IPCONFIG0_PEIPID_SHIFT) -#define I40E_PFPE_IPCONFIG0_USEENTIREIDRANGE_SHIFT 16 -#define I40E_PFPE_IPCONFIG0_USEENTIREIDRANGE_MASK (0x1 << I40E_PFPE_IPCONFIG0_USEENTIREIDRANGE_SHIFT) -#define I40E_PFPE_MRTEIDXMASK 0x00008600 /* Reset: PFR */ -#define I40E_PFPE_MRTEIDXMASK_MRTEIDXMASKBITS_SHIFT 0 -#define I40E_PFPE_MRTEIDXMASK_MRTEIDXMASKBITS_MASK (0x1F << I40E_PFPE_MRTEIDXMASK_MRTEIDXMASKBITS_SHIFT) -#define I40E_PFPE_RCVUNEXPECTEDERROR 0x00008680 /* Reset: PFR */ -#define I40E_PFPE_RCVUNEXPECTEDERROR_TCP_RX_UNEXP_ERR_SHIFT 0 -#define I40E_PFPE_RCVUNEXPECTEDERROR_TCP_RX_UNEXP_ERR_MASK (0xFFFFFF << I40E_PFPE_RCVUNEXPECTEDERROR_TCP_RX_UNEXP_ERR_SHIFT) -#define I40E_PFPE_TCPNOWTIMER 0x00008580 /* Reset: PFR */ -#define I40E_PFPE_TCPNOWTIMER_TCP_NOW_SHIFT 0 -#define I40E_PFPE_TCPNOWTIMER_TCP_NOW_MASK (0xFFFFFFFF << I40E_PFPE_TCPNOWTIMER_TCP_NOW_SHIFT) - -#define I40E_PFPE_WQEALLOC 0x00138C00 /* Reset: PFR */ -#define I40E_PFPE_WQEALLOC_PEQPID_SHIFT 0 -#define I40E_PFPE_WQEALLOC_PEQPID_MASK (0x3FFFF << I40E_PFPE_WQEALLOC_PEQPID_SHIFT) -#define I40E_PFPE_WQEALLOC_WQE_DESC_INDEX_SHIFT 20 -#define I40E_PFPE_WQEALLOC_WQE_DESC_INDEX_MASK (0xFFF << I40E_PFPE_WQEALLOC_WQE_DESC_INDEX_SHIFT) - -#define I40E_VFPE_AEQALLOC(_VF) (0x00130C00 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_AEQALLOC_MAX_INDEX 127 -#define I40E_VFPE_AEQALLOC_AECOUNT_SHIFT 0 -#define I40E_VFPE_AEQALLOC_AECOUNT_MASK (0xFFFFFFFF << I40E_VFPE_AEQALLOC_AECOUNT_SHIFT) -#define I40E_VFPE_CCQPHIGH(_VF) (0x00001000 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_CCQPHIGH_MAX_INDEX 127 -#define I40E_VFPE_CCQPHIGH_PECCQPHIGH_SHIFT 0 -#define I40E_VFPE_CCQPHIGH_PECCQPHIGH_MASK (0xFFFFFFFF << I40E_VFPE_CCQPHIGH_PECCQPHIGH_SHIFT) -#define I40E_VFPE_CCQPLOW(_VF) (0x00000C00 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_CCQPLOW_MAX_INDEX 127 -#define I40E_VFPE_CCQPLOW_PECCQPLOW_SHIFT 0 -#define I40E_VFPE_CCQPLOW_PECCQPLOW_MASK (0xFFFFFFFF << I40E_VFPE_CCQPLOW_PECCQPLOW_SHIFT) -#define I40E_VFPE_CCQPSTATUS(_VF) (0x00000800 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_CCQPSTATUS_MAX_INDEX 127 -#define I40E_VFPE_CCQPSTATUS_CCQP_DONE_SHIFT 0 -#define I40E_VFPE_CCQPSTATUS_CCQP_DONE_MASK (0x1 << I40E_VFPE_CCQPSTATUS_CCQP_DONE_SHIFT) -#define I40E_VFPE_CCQPSTATUS_HMC_PROFILE_SHIFT 4 -#define I40E_VFPE_CCQPSTATUS_HMC_PROFILE_MASK (0x7 << I40E_VFPE_CCQPSTATUS_HMC_PROFILE_SHIFT) -#define I40E_VFPE_CCQPSTATUS_RDMA_EN_VFS_SHIFT 16 -#define I40E_VFPE_CCQPSTATUS_RDMA_EN_VFS_MASK (0x3F << I40E_VFPE_CCQPSTATUS_RDMA_EN_VFS_SHIFT) -#define I40E_VFPE_CCQPSTATUS_CCQP_ERR_SHIFT 31 -#define I40E_VFPE_CCQPSTATUS_CCQP_ERR_MASK (0x1 << I40E_VFPE_CCQPSTATUS_CCQP_ERR_SHIFT) -#define I40E_VFPE_CQACK(_VF) (0x00130800 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_CQACK_MAX_INDEX 127 -#define I40E_VFPE_CQACK_PECQID_SHIFT 0 -#define I40E_VFPE_CQACK_PECQID_MASK (0x1FFFF << I40E_VFPE_CQACK_PECQID_SHIFT) -#define I40E_VFPE_CQARM(_VF) (0x00130400 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_CQARM_MAX_INDEX 127 -#define I40E_VFPE_CQARM_PECQID_SHIFT 0 -#define I40E_VFPE_CQARM_PECQID_MASK (0x1FFFF << I40E_VFPE_CQARM_PECQID_SHIFT) -#define I40E_VFPE_CQPDB(_VF) (0x00000000 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_CQPDB_MAX_INDEX 127 -#define I40E_VFPE_CQPDB_WQHEAD_SHIFT 0 -#define I40E_VFPE_CQPDB_WQHEAD_MASK (0x7FF << I40E_VFPE_CQPDB_WQHEAD_SHIFT) -#define I40E_VFPE_CQPERRCODES(_VF) (0x00001800 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_CQPERRCODES_MAX_INDEX 127 -#define I40E_VFPE_CQPERRCODES_CQP_MINOR_CODE_SHIFT 0 -#define I40E_VFPE_CQPERRCODES_CQP_MINOR_CODE_MASK (0xFFFF << I40E_VFPE_CQPERRCODES_CQP_MINOR_CODE_SHIFT) -#define I40E_VFPE_CQPERRCODES_CQP_MAJOR_CODE_SHIFT 16 -#define I40E_VFPE_CQPERRCODES_CQP_MAJOR_CODE_MASK (0xFFFF << I40E_VFPE_CQPERRCODES_CQP_MAJOR_CODE_SHIFT) -#define I40E_VFPE_CQPTAIL(_VF) (0x00000400 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_CQPTAIL_MAX_INDEX 127 -#define I40E_VFPE_CQPTAIL_WQTAIL_SHIFT 0 -#define I40E_VFPE_CQPTAIL_WQTAIL_MASK (0x7FF << I40E_VFPE_CQPTAIL_WQTAIL_SHIFT) -#define I40E_VFPE_CQPTAIL_CQP_OP_ERR_SHIFT 31 -#define I40E_VFPE_CQPTAIL_CQP_OP_ERR_MASK (0x1 << I40E_VFPE_CQPTAIL_CQP_OP_ERR_SHIFT) -#define I40E_VFPE_IPCONFIG0(_VF) (0x00001400 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_IPCONFIG0_MAX_INDEX 127 -#define I40E_VFPE_IPCONFIG0_PEIPID_SHIFT 0 -#define I40E_VFPE_IPCONFIG0_PEIPID_MASK (0xFFFF << I40E_VFPE_IPCONFIG0_PEIPID_SHIFT) -#define I40E_VFPE_IPCONFIG0_USEENTIREIDRANGE_SHIFT 16 -#define I40E_VFPE_IPCONFIG0_USEENTIREIDRANGE_MASK (0x1 << I40E_VFPE_IPCONFIG0_USEENTIREIDRANGE_SHIFT) -#define I40E_VFPE_MRTEIDXMASK(_VF) (0x00003000 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_MRTEIDXMASK_MAX_INDEX 127 -#define I40E_VFPE_MRTEIDXMASK_MRTEIDXMASKBITS_SHIFT 0 -#define I40E_VFPE_MRTEIDXMASK_MRTEIDXMASKBITS_MASK (0x1F << I40E_VFPE_MRTEIDXMASK_MRTEIDXMASKBITS_SHIFT) -#define I40E_VFPE_RCVUNEXPECTEDERROR(_VF) (0x00003400 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_RCVUNEXPECTEDERROR_MAX_INDEX 127 -#define I40E_VFPE_RCVUNEXPECTEDERROR_TCP_RX_UNEXP_ERR_SHIFT 0 -#define I40E_VFPE_RCVUNEXPECTEDERROR_TCP_RX_UNEXP_ERR_MASK (0xFFFFFF << I40E_VFPE_RCVUNEXPECTEDERROR_TCP_RX_UNEXP_ERR_SHIFT) -#define I40E_VFPE_TCPNOWTIMER(_VF) (0x00002C00 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_TCPNOWTIMER_MAX_INDEX 127 -#define I40E_VFPE_TCPNOWTIMER_TCP_NOW_SHIFT 0 -#define I40E_VFPE_TCPNOWTIMER_TCP_NOW_MASK (0xFFFFFFFF << I40E_VFPE_TCPNOWTIMER_TCP_NOW_SHIFT) -#define I40E_VFPE_WQEALLOC(_VF) (0x00138000 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: VFR */ -#define I40E_VFPE_WQEALLOC_MAX_INDEX 127 -#define I40E_VFPE_WQEALLOC_PEQPID_SHIFT 0 -#define I40E_VFPE_WQEALLOC_PEQPID_MASK (0x3FFFF << I40E_VFPE_WQEALLOC_PEQPID_SHIFT) -#define I40E_VFPE_WQEALLOC_WQE_DESC_INDEX_SHIFT 20 -#define I40E_VFPE_WQEALLOC_WQE_DESC_INDEX_MASK (0xFFF << I40E_VFPE_WQEALLOC_WQE_DESC_INDEX_SHIFT) - -#define I40E_GLPE_CPUSTATUS0 0x0000D040 /* Reset: PE_CORER */ -#define I40E_GLPE_CPUSTATUS0_PECPUSTATUS0_SHIFT 0 -#define I40E_GLPE_CPUSTATUS0_PECPUSTATUS0_MASK (0xFFFFFFFF << I40E_GLPE_CPUSTATUS0_PECPUSTATUS0_SHIFT) -#define I40E_GLPE_CPUSTATUS1 0x0000D044 /* Reset: PE_CORER */ -#define I40E_GLPE_CPUSTATUS1_PECPUSTATUS1_SHIFT 0 -#define I40E_GLPE_CPUSTATUS1_PECPUSTATUS1_MASK (0xFFFFFFFF << I40E_GLPE_CPUSTATUS1_PECPUSTATUS1_SHIFT) -#define I40E_GLPE_CPUSTATUS2 0x0000D048 /* Reset: PE_CORER */ -#define I40E_GLPE_CPUSTATUS2_PECPUSTATUS2_SHIFT 0 -#define I40E_GLPE_CPUSTATUS2_PECPUSTATUS2_MASK (0xFFFFFFFF << I40E_GLPE_CPUSTATUS2_PECPUSTATUS2_SHIFT) -#define I40E_GLPE_CPUTRIG0 0x0000D060 /* Reset: PE_CORER */ -#define I40E_GLPE_CPUTRIG0_PECPUTRIG0_SHIFT 0 -#define I40E_GLPE_CPUTRIG0_PECPUTRIG0_MASK (0xFFFF << I40E_GLPE_CPUTRIG0_PECPUTRIG0_SHIFT) -#define I40E_GLPE_CPUTRIG0_TEPREQUEST0_SHIFT 17 -#define I40E_GLPE_CPUTRIG0_TEPREQUEST0_MASK (0x1 << I40E_GLPE_CPUTRIG0_TEPREQUEST0_SHIFT) -#define I40E_GLPE_CPUTRIG0_OOPREQUEST0_SHIFT 18 -#define I40E_GLPE_CPUTRIG0_OOPREQUEST0_MASK (0x1 << I40E_GLPE_CPUTRIG0_OOPREQUEST0_SHIFT) -#define I40E_GLPE_DUAL40_RUPM 0x0000DA04 /* Reset: PE_CORER */ -#define I40E_GLPE_DUAL40_RUPM_DUAL_40G_MODE_SHIFT 0 -#define I40E_GLPE_DUAL40_RUPM_DUAL_40G_MODE_MASK (0x1 << I40E_GLPE_DUAL40_RUPM_DUAL_40G_MODE_SHIFT) -#define I40E_GLPE_PFAEQEDROPCNT(_i) (0x00131440 + ((_i) * 4)) /* _i=0...15 */ /* Reset: CORER */ -#define I40E_GLPE_PFAEQEDROPCNT_MAX_INDEX 15 -#define I40E_GLPE_PFAEQEDROPCNT_AEQEDROPCNT_SHIFT 0 -#define I40E_GLPE_PFAEQEDROPCNT_AEQEDROPCNT_MASK (0xFFFF << I40E_GLPE_PFAEQEDROPCNT_AEQEDROPCNT_SHIFT) -#define I40E_GLPE_PFCEQEDROPCNT(_i) (0x001313C0 + ((_i) * 4)) /* _i=0...15 */ /* Reset: CORER */ -#define I40E_GLPE_PFCEQEDROPCNT_MAX_INDEX 15 -#define I40E_GLPE_PFCEQEDROPCNT_CEQEDROPCNT_SHIFT 0 -#define I40E_GLPE_PFCEQEDROPCNT_CEQEDROPCNT_MASK (0xFFFF << I40E_GLPE_PFCEQEDROPCNT_CEQEDROPCNT_SHIFT) -#define I40E_GLPE_PFCQEDROPCNT(_i) (0x00131340 + ((_i) * 4)) /* _i=0...15 */ /* Reset: CORER */ -#define I40E_GLPE_PFCQEDROPCNT_MAX_INDEX 15 -#define I40E_GLPE_PFCQEDROPCNT_CQEDROPCNT_SHIFT 0 -#define I40E_GLPE_PFCQEDROPCNT_CQEDROPCNT_MASK (0xFFFF << I40E_GLPE_PFCQEDROPCNT_CQEDROPCNT_SHIFT) -#define I40E_GLPE_RUPM_CQPPOOL 0x0000DACC /* Reset: PE_CORER */ -#define I40E_GLPE_RUPM_CQPPOOL_CQPSPADS_SHIFT 0 -#define I40E_GLPE_RUPM_CQPPOOL_CQPSPADS_MASK (0xFF << I40E_GLPE_RUPM_CQPPOOL_CQPSPADS_SHIFT) -#define I40E_GLPE_RUPM_FLRPOOL 0x0000DAC4 /* Reset: PE_CORER */ -#define I40E_GLPE_RUPM_FLRPOOL_FLRSPADS_SHIFT 0 -#define I40E_GLPE_RUPM_FLRPOOL_FLRSPADS_MASK (0xFF << I40E_GLPE_RUPM_FLRPOOL_FLRSPADS_SHIFT) -#define I40E_GLPE_RUPM_GCTL 0x0000DA00 /* Reset: PE_CORER */ -#define I40E_GLPE_RUPM_GCTL_ALLOFFTH_SHIFT 0 -#define I40E_GLPE_RUPM_GCTL_ALLOFFTH_MASK (0xFF << I40E_GLPE_RUPM_GCTL_ALLOFFTH_SHIFT) -#define I40E_GLPE_RUPM_GCTL_RUPM_P0_DIS_SHIFT 26 -#define I40E_GLPE_RUPM_GCTL_RUPM_P0_DIS_MASK (0x1 << I40E_GLPE_RUPM_GCTL_RUPM_P0_DIS_SHIFT) -#define I40E_GLPE_RUPM_GCTL_RUPM_P1_DIS_SHIFT 27 -#define I40E_GLPE_RUPM_GCTL_RUPM_P1_DIS_MASK (0x1 << I40E_GLPE_RUPM_GCTL_RUPM_P1_DIS_SHIFT) -#define I40E_GLPE_RUPM_GCTL_RUPM_P2_DIS_SHIFT 28 -#define I40E_GLPE_RUPM_GCTL_RUPM_P2_DIS_MASK (0x1 << I40E_GLPE_RUPM_GCTL_RUPM_P2_DIS_SHIFT) -#define I40E_GLPE_RUPM_GCTL_RUPM_P3_DIS_SHIFT 29 -#define I40E_GLPE_RUPM_GCTL_RUPM_P3_DIS_MASK (0x1 << I40E_GLPE_RUPM_GCTL_RUPM_P3_DIS_SHIFT) -#define I40E_GLPE_RUPM_GCTL_RUPM_DIS_SHIFT 30 -#define I40E_GLPE_RUPM_GCTL_RUPM_DIS_MASK (0x1 << I40E_GLPE_RUPM_GCTL_RUPM_DIS_SHIFT) -#define I40E_GLPE_RUPM_GCTL_SWLB_MODE_SHIFT 31 -#define I40E_GLPE_RUPM_GCTL_SWLB_MODE_MASK (0x1 << I40E_GLPE_RUPM_GCTL_SWLB_MODE_SHIFT) -#define I40E_GLPE_RUPM_PTXPOOL 0x0000DAC8 /* Reset: PE_CORER */ -#define I40E_GLPE_RUPM_PTXPOOL_PTXSPADS_SHIFT 0 -#define I40E_GLPE_RUPM_PTXPOOL_PTXSPADS_MASK (0xFF << I40E_GLPE_RUPM_PTXPOOL_PTXSPADS_SHIFT) -#define I40E_GLPE_RUPM_PUSHPOOL 0x0000DAC0 /* Reset: PE_CORER */ -#define I40E_GLPE_RUPM_PUSHPOOL_PUSHSPADS_SHIFT 0 -#define I40E_GLPE_RUPM_PUSHPOOL_PUSHSPADS_MASK (0xFF << I40E_GLPE_RUPM_PUSHPOOL_PUSHSPADS_SHIFT) -#define I40E_GLPE_RUPM_TXHOST_EN 0x0000DA08 /* Reset: PE_CORER */ -#define I40E_GLPE_RUPM_TXHOST_EN_TXHOST_EN_SHIFT 0 -#define I40E_GLPE_RUPM_TXHOST_EN_TXHOST_EN_MASK (0x1 << I40E_GLPE_RUPM_TXHOST_EN_TXHOST_EN_SHIFT) -#define I40E_GLPE_VFAEQEDROPCNT(_i) (0x00132540 + ((_i) * 4)) /* _i=0...31 */ /* Reset: CORER */ -#define I40E_GLPE_VFAEQEDROPCNT_MAX_INDEX 31 -#define I40E_GLPE_VFAEQEDROPCNT_AEQEDROPCNT_SHIFT 0 -#define I40E_GLPE_VFAEQEDROPCNT_AEQEDROPCNT_MASK (0xFFFF << I40E_GLPE_VFAEQEDROPCNT_AEQEDROPCNT_SHIFT) -#define I40E_GLPE_VFCEQEDROPCNT(_i) (0x00132440 + ((_i) * 4)) /* _i=0...31 */ /* Reset: CORER */ -#define I40E_GLPE_VFCEQEDROPCNT_MAX_INDEX 31 -#define I40E_GLPE_VFCEQEDROPCNT_CEQEDROPCNT_SHIFT 0 -#define I40E_GLPE_VFCEQEDROPCNT_CEQEDROPCNT_MASK (0xFFFF << I40E_GLPE_VFCEQEDROPCNT_CEQEDROPCNT_SHIFT) -#define I40E_GLPE_VFCQEDROPCNT(_i) (0x00132340 + ((_i) * 4)) /* _i=0...31 */ /* Reset: CORER */ -#define I40E_GLPE_VFCQEDROPCNT_MAX_INDEX 31 -#define I40E_GLPE_VFCQEDROPCNT_CQEDROPCNT_SHIFT 0 -#define I40E_GLPE_VFCQEDROPCNT_CQEDROPCNT_MASK (0xFFFF << I40E_GLPE_VFCQEDROPCNT_CQEDROPCNT_SHIFT) -#define I40E_GLPE_VFFLMOBJCTRL(_i) (0x0000D400 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPE_VFFLMOBJCTRL_MAX_INDEX 31 -#define I40E_GLPE_VFFLMOBJCTRL_XMIT_BLOCKSIZE_SHIFT 0 -#define I40E_GLPE_VFFLMOBJCTRL_XMIT_BLOCKSIZE_MASK (0x7 << I40E_GLPE_VFFLMOBJCTRL_XMIT_BLOCKSIZE_SHIFT) -#define I40E_GLPE_VFFLMOBJCTRL_Q1_BLOCKSIZE_SHIFT 8 -#define I40E_GLPE_VFFLMOBJCTRL_Q1_BLOCKSIZE_MASK (0x7 << I40E_GLPE_VFFLMOBJCTRL_Q1_BLOCKSIZE_SHIFT) -#define I40E_GLPE_VFFLMQ1ALLOCERR(_i) (0x0000C700 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPE_VFFLMQ1ALLOCERR_MAX_INDEX 31 -#define I40E_GLPE_VFFLMQ1ALLOCERR_ERROR_COUNT_SHIFT 0 -#define I40E_GLPE_VFFLMQ1ALLOCERR_ERROR_COUNT_MASK (0xFFFF << I40E_GLPE_VFFLMQ1ALLOCERR_ERROR_COUNT_SHIFT) -#define I40E_GLPE_VFFLMXMITALLOCERR(_i) (0x0000C600 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPE_VFFLMXMITALLOCERR_MAX_INDEX 31 -#define I40E_GLPE_VFFLMXMITALLOCERR_ERROR_COUNT_SHIFT 0 -#define I40E_GLPE_VFFLMXMITALLOCERR_ERROR_COUNT_MASK (0xFFFF << I40E_GLPE_VFFLMXMITALLOCERR_ERROR_COUNT_SHIFT) -#define I40E_GLPE_VFUDACTRL(_i) (0x0000C000 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPE_VFUDACTRL_MAX_INDEX 31 -#define I40E_GLPE_VFUDACTRL_IPV4MCFRAGRESBP_SHIFT 0 -#define I40E_GLPE_VFUDACTRL_IPV4MCFRAGRESBP_MASK (0x1 << I40E_GLPE_VFUDACTRL_IPV4MCFRAGRESBP_SHIFT) -#define I40E_GLPE_VFUDACTRL_IPV4UCFRAGRESBP_SHIFT 1 -#define I40E_GLPE_VFUDACTRL_IPV4UCFRAGRESBP_MASK (0x1 << I40E_GLPE_VFUDACTRL_IPV4UCFRAGRESBP_SHIFT) -#define I40E_GLPE_VFUDACTRL_IPV6MCFRAGRESBP_SHIFT 2 -#define I40E_GLPE_VFUDACTRL_IPV6MCFRAGRESBP_MASK (0x1 << I40E_GLPE_VFUDACTRL_IPV6MCFRAGRESBP_SHIFT) -#define I40E_GLPE_VFUDACTRL_IPV6UCFRAGRESBP_SHIFT 3 -#define I40E_GLPE_VFUDACTRL_IPV6UCFRAGRESBP_MASK (0x1 << I40E_GLPE_VFUDACTRL_IPV6UCFRAGRESBP_SHIFT) -#define I40E_GLPE_VFUDACTRL_UDPMCFRAGRESFAIL_SHIFT 4 -#define I40E_GLPE_VFUDACTRL_UDPMCFRAGRESFAIL_MASK (0x1 << I40E_GLPE_VFUDACTRL_UDPMCFRAGRESFAIL_SHIFT) -#define I40E_GLPE_VFUDAUCFBQPN(_i) (0x0000C100 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPE_VFUDAUCFBQPN_MAX_INDEX 31 -#define I40E_GLPE_VFUDAUCFBQPN_QPN_SHIFT 0 -#define I40E_GLPE_VFUDAUCFBQPN_QPN_MASK (0x3FFFF << I40E_GLPE_VFUDAUCFBQPN_QPN_SHIFT) -#define I40E_GLPE_VFUDAUCFBQPN_VALID_SHIFT 31 -#define I40E_GLPE_VFUDAUCFBQPN_VALID_MASK (0x1 << I40E_GLPE_VFUDAUCFBQPN_VALID_SHIFT) - -#define I40E_GLPES_PFIP4RXDISCARD(_i) (0x00010600 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXDISCARD_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXDISCARD_IP4RXDISCARD_SHIFT 0 -#define I40E_GLPES_PFIP4RXDISCARD_IP4RXDISCARD_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4RXDISCARD_IP4RXDISCARD_SHIFT) -#define I40E_GLPES_PFIP4RXFRAGSHI(_i) (0x00010804 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXFRAGSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXFRAGSHI_IP4RXFRAGSHI_SHIFT 0 -#define I40E_GLPES_PFIP4RXFRAGSHI_IP4RXFRAGSHI_MASK (0xFFFF << I40E_GLPES_PFIP4RXFRAGSHI_IP4RXFRAGSHI_SHIFT) -#define I40E_GLPES_PFIP4RXFRAGSLO(_i) (0x00010800 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXFRAGSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXFRAGSLO_IP4RXFRAGSLO_SHIFT 0 -#define I40E_GLPES_PFIP4RXFRAGSLO_IP4RXFRAGSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4RXFRAGSLO_IP4RXFRAGSLO_SHIFT) -#define I40E_GLPES_PFIP4RXMCOCTSHI(_i) (0x00010A04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXMCOCTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXMCOCTSHI_IP4RXMCOCTSHI_SHIFT 0 -#define I40E_GLPES_PFIP4RXMCOCTSHI_IP4RXMCOCTSHI_MASK (0xFFFF << I40E_GLPES_PFIP4RXMCOCTSHI_IP4RXMCOCTSHI_SHIFT) -#define I40E_GLPES_PFIP4RXMCOCTSLO(_i) (0x00010A00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXMCOCTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXMCOCTSLO_IP4RXMCOCTSLO_SHIFT 0 -#define I40E_GLPES_PFIP4RXMCOCTSLO_IP4RXMCOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4RXMCOCTSLO_IP4RXMCOCTSLO_SHIFT) -#define I40E_GLPES_PFIP4RXMCPKTSHI(_i) (0x00010C04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXMCPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXMCPKTSHI_IP4RXMCPKTSHI_SHIFT 0 -#define I40E_GLPES_PFIP4RXMCPKTSHI_IP4RXMCPKTSHI_MASK (0xFFFF << I40E_GLPES_PFIP4RXMCPKTSHI_IP4RXMCPKTSHI_SHIFT) -#define I40E_GLPES_PFIP4RXMCPKTSLO(_i) (0x00010C00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXMCPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXMCPKTSLO_IP4RXMCPKTSLO_SHIFT 0 -#define I40E_GLPES_PFIP4RXMCPKTSLO_IP4RXMCPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4RXMCPKTSLO_IP4RXMCPKTSLO_SHIFT) -#define I40E_GLPES_PFIP4RXOCTSHI(_i) (0x00010204 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXOCTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXOCTSHI_IP4RXOCTSHI_SHIFT 0 -#define I40E_GLPES_PFIP4RXOCTSHI_IP4RXOCTSHI_MASK (0xFFFF << I40E_GLPES_PFIP4RXOCTSHI_IP4RXOCTSHI_SHIFT) -#define I40E_GLPES_PFIP4RXOCTSLO(_i) (0x00010200 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXOCTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXOCTSLO_IP4RXOCTSLO_SHIFT 0 -#define I40E_GLPES_PFIP4RXOCTSLO_IP4RXOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4RXOCTSLO_IP4RXOCTSLO_SHIFT) -#define I40E_GLPES_PFIP4RXPKTSHI(_i) (0x00010404 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXPKTSHI_IP4RXPKTSHI_SHIFT 0 -#define I40E_GLPES_PFIP4RXPKTSHI_IP4RXPKTSHI_MASK (0xFFFF << I40E_GLPES_PFIP4RXPKTSHI_IP4RXPKTSHI_SHIFT) -#define I40E_GLPES_PFIP4RXPKTSLO(_i) (0x00010400 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXPKTSLO_IP4RXPKTSLO_SHIFT 0 -#define I40E_GLPES_PFIP4RXPKTSLO_IP4RXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4RXPKTSLO_IP4RXPKTSLO_SHIFT) -#define I40E_GLPES_PFIP4RXTRUNC(_i) (0x00010700 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4RXTRUNC_MAX_INDEX 15 -#define I40E_GLPES_PFIP4RXTRUNC_IP4RXTRUNC_SHIFT 0 -#define I40E_GLPES_PFIP4RXTRUNC_IP4RXTRUNC_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4RXTRUNC_IP4RXTRUNC_SHIFT) -#define I40E_GLPES_PFIP4TXFRAGSHI(_i) (0x00011E04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXFRAGSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXFRAGSHI_IP4TXFRAGSHI_SHIFT 0 -#define I40E_GLPES_PFIP4TXFRAGSHI_IP4TXFRAGSHI_MASK (0xFFFF << I40E_GLPES_PFIP4TXFRAGSHI_IP4TXFRAGSHI_SHIFT) -#define I40E_GLPES_PFIP4TXFRAGSLO(_i) (0x00011E00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXFRAGSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXFRAGSLO_IP4TXFRAGSLO_SHIFT 0 -#define I40E_GLPES_PFIP4TXFRAGSLO_IP4TXFRAGSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4TXFRAGSLO_IP4TXFRAGSLO_SHIFT) -#define I40E_GLPES_PFIP4TXMCOCTSHI(_i) (0x00012004 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXMCOCTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXMCOCTSHI_IP4TXMCOCTSHI_SHIFT 0 -#define I40E_GLPES_PFIP4TXMCOCTSHI_IP4TXMCOCTSHI_MASK (0xFFFF << I40E_GLPES_PFIP4TXMCOCTSHI_IP4TXMCOCTSHI_SHIFT) -#define I40E_GLPES_PFIP4TXMCOCTSLO(_i) (0x00012000 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXMCOCTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXMCOCTSLO_IP4TXMCOCTSLO_SHIFT 0 -#define I40E_GLPES_PFIP4TXMCOCTSLO_IP4TXMCOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4TXMCOCTSLO_IP4TXMCOCTSLO_SHIFT) -#define I40E_GLPES_PFIP4TXMCPKTSHI(_i) (0x00012204 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXMCPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXMCPKTSHI_IP4TXMCPKTSHI_SHIFT 0 -#define I40E_GLPES_PFIP4TXMCPKTSHI_IP4TXMCPKTSHI_MASK (0xFFFF << I40E_GLPES_PFIP4TXMCPKTSHI_IP4TXMCPKTSHI_SHIFT) -#define I40E_GLPES_PFIP4TXMCPKTSLO(_i) (0x00012200 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXMCPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXMCPKTSLO_IP4TXMCPKTSLO_SHIFT 0 -#define I40E_GLPES_PFIP4TXMCPKTSLO_IP4TXMCPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4TXMCPKTSLO_IP4TXMCPKTSLO_SHIFT) -#define I40E_GLPES_PFIP4TXNOROUTE(_i) (0x00012E00 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXNOROUTE_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXNOROUTE_IP4TXNOROUTE_SHIFT 0 -#define I40E_GLPES_PFIP4TXNOROUTE_IP4TXNOROUTE_MASK (0xFFFFFF << I40E_GLPES_PFIP4TXNOROUTE_IP4TXNOROUTE_SHIFT) -#define I40E_GLPES_PFIP4TXOCTSHI(_i) (0x00011A04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXOCTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXOCTSHI_IP4TXOCTSHI_SHIFT 0 -#define I40E_GLPES_PFIP4TXOCTSHI_IP4TXOCTSHI_MASK (0xFFFF << I40E_GLPES_PFIP4TXOCTSHI_IP4TXOCTSHI_SHIFT) -#define I40E_GLPES_PFIP4TXOCTSLO(_i) (0x00011A00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXOCTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXOCTSLO_IP4TXOCTSLO_SHIFT 0 -#define I40E_GLPES_PFIP4TXOCTSLO_IP4TXOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4TXOCTSLO_IP4TXOCTSLO_SHIFT) -#define I40E_GLPES_PFIP4TXPKTSHI(_i) (0x00011C04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXPKTSHI_IP4TXPKTSHI_SHIFT 0 -#define I40E_GLPES_PFIP4TXPKTSHI_IP4TXPKTSHI_MASK (0xFFFF << I40E_GLPES_PFIP4TXPKTSHI_IP4TXPKTSHI_SHIFT) -#define I40E_GLPES_PFIP4TXPKTSLO(_i) (0x00011C00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP4TXPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP4TXPKTSLO_IP4TXPKTSLO_SHIFT 0 -#define I40E_GLPES_PFIP4TXPKTSLO_IP4TXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP4TXPKTSLO_IP4TXPKTSLO_SHIFT) -#define I40E_GLPES_PFIP6RXDISCARD(_i) (0x00011200 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXDISCARD_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXDISCARD_IP6RXDISCARD_SHIFT 0 -#define I40E_GLPES_PFIP6RXDISCARD_IP6RXDISCARD_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6RXDISCARD_IP6RXDISCARD_SHIFT) -#define I40E_GLPES_PFIP6RXFRAGSHI(_i) (0x00011404 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXFRAGSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXFRAGSHI_IP6RXFRAGSHI_SHIFT 0 -#define I40E_GLPES_PFIP6RXFRAGSHI_IP6RXFRAGSHI_MASK (0xFFFF << I40E_GLPES_PFIP6RXFRAGSHI_IP6RXFRAGSHI_SHIFT) -#define I40E_GLPES_PFIP6RXFRAGSLO(_i) (0x00011400 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXFRAGSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXFRAGSLO_IP6RXFRAGSLO_SHIFT 0 -#define I40E_GLPES_PFIP6RXFRAGSLO_IP6RXFRAGSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6RXFRAGSLO_IP6RXFRAGSLO_SHIFT) -#define I40E_GLPES_PFIP6RXMCOCTSHI(_i) (0x00011604 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXMCOCTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXMCOCTSHI_IP6RXMCOCTSHI_SHIFT 0 -#define I40E_GLPES_PFIP6RXMCOCTSHI_IP6RXMCOCTSHI_MASK (0xFFFF << I40E_GLPES_PFIP6RXMCOCTSHI_IP6RXMCOCTSHI_SHIFT) -#define I40E_GLPES_PFIP6RXMCOCTSLO(_i) (0x00011600 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXMCOCTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXMCOCTSLO_IP6RXMCOCTSLO_SHIFT 0 -#define I40E_GLPES_PFIP6RXMCOCTSLO_IP6RXMCOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6RXMCOCTSLO_IP6RXMCOCTSLO_SHIFT) -#define I40E_GLPES_PFIP6RXMCPKTSHI(_i) (0x00011804 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXMCPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXMCPKTSHI_IP6RXMCPKTSHI_SHIFT 0 -#define I40E_GLPES_PFIP6RXMCPKTSHI_IP6RXMCPKTSHI_MASK (0xFFFF << I40E_GLPES_PFIP6RXMCPKTSHI_IP6RXMCPKTSHI_SHIFT) -#define I40E_GLPES_PFIP6RXMCPKTSLO(_i) (0x00011800 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXMCPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXMCPKTSLO_IP6RXMCPKTSLO_SHIFT 0 -#define I40E_GLPES_PFIP6RXMCPKTSLO_IP6RXMCPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6RXMCPKTSLO_IP6RXMCPKTSLO_SHIFT) -#define I40E_GLPES_PFIP6RXOCTSHI(_i) (0x00010E04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXOCTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXOCTSHI_IP6RXOCTSHI_SHIFT 0 -#define I40E_GLPES_PFIP6RXOCTSHI_IP6RXOCTSHI_MASK (0xFFFF << I40E_GLPES_PFIP6RXOCTSHI_IP6RXOCTSHI_SHIFT) -#define I40E_GLPES_PFIP6RXOCTSLO(_i) (0x00010E00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXOCTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXOCTSLO_IP6RXOCTSLO_SHIFT 0 -#define I40E_GLPES_PFIP6RXOCTSLO_IP6RXOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6RXOCTSLO_IP6RXOCTSLO_SHIFT) -#define I40E_GLPES_PFIP6RXPKTSHI(_i) (0x00011004 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXPKTSHI_IP6RXPKTSHI_SHIFT 0 -#define I40E_GLPES_PFIP6RXPKTSHI_IP6RXPKTSHI_MASK (0xFFFF << I40E_GLPES_PFIP6RXPKTSHI_IP6RXPKTSHI_SHIFT) -#define I40E_GLPES_PFIP6RXPKTSLO(_i) (0x00011000 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXPKTSLO_IP6RXPKTSLO_SHIFT 0 -#define I40E_GLPES_PFIP6RXPKTSLO_IP6RXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6RXPKTSLO_IP6RXPKTSLO_SHIFT) -#define I40E_GLPES_PFIP6RXTRUNC(_i) (0x00011300 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6RXTRUNC_MAX_INDEX 15 -#define I40E_GLPES_PFIP6RXTRUNC_IP6RXTRUNC_SHIFT 0 -#define I40E_GLPES_PFIP6RXTRUNC_IP6RXTRUNC_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6RXTRUNC_IP6RXTRUNC_SHIFT) -#define I40E_GLPES_PFIP6TXFRAGSHI(_i) (0x00012804 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXFRAGSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXFRAGSHI_IP6TXFRAGSHI_SHIFT 0 -#define I40E_GLPES_PFIP6TXFRAGSHI_IP6TXFRAGSHI_MASK (0xFFFF << I40E_GLPES_PFIP6TXFRAGSHI_IP6TXFRAGSHI_SHIFT) -#define I40E_GLPES_PFIP6TXFRAGSLO(_i) (0x00012800 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXFRAGSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXFRAGSLO_IP6TXFRAGSLO_SHIFT 0 -#define I40E_GLPES_PFIP6TXFRAGSLO_IP6TXFRAGSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6TXFRAGSLO_IP6TXFRAGSLO_SHIFT) -#define I40E_GLPES_PFIP6TXMCOCTSHI(_i) (0x00012A04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXMCOCTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXMCOCTSHI_IP6TXMCOCTSHI_SHIFT 0 -#define I40E_GLPES_PFIP6TXMCOCTSHI_IP6TXMCOCTSHI_MASK (0xFFFF << I40E_GLPES_PFIP6TXMCOCTSHI_IP6TXMCOCTSHI_SHIFT) -#define I40E_GLPES_PFIP6TXMCOCTSLO(_i) (0x00012A00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXMCOCTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXMCOCTSLO_IP6TXMCOCTSLO_SHIFT 0 -#define I40E_GLPES_PFIP6TXMCOCTSLO_IP6TXMCOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6TXMCOCTSLO_IP6TXMCOCTSLO_SHIFT) -#define I40E_GLPES_PFIP6TXMCPKTSHI(_i) (0x00012C04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXMCPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXMCPKTSHI_IP6TXMCPKTSHI_SHIFT 0 -#define I40E_GLPES_PFIP6TXMCPKTSHI_IP6TXMCPKTSHI_MASK (0xFFFF << I40E_GLPES_PFIP6TXMCPKTSHI_IP6TXMCPKTSHI_SHIFT) -#define I40E_GLPES_PFIP6TXMCPKTSLO(_i) (0x00012C00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXMCPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXMCPKTSLO_IP6TXMCPKTSLO_SHIFT 0 -#define I40E_GLPES_PFIP6TXMCPKTSLO_IP6TXMCPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6TXMCPKTSLO_IP6TXMCPKTSLO_SHIFT) -#define I40E_GLPES_PFIP6TXNOROUTE(_i) (0x00012F00 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXNOROUTE_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXNOROUTE_IP6TXNOROUTE_SHIFT 0 -#define I40E_GLPES_PFIP6TXNOROUTE_IP6TXNOROUTE_MASK (0xFFFFFF << I40E_GLPES_PFIP6TXNOROUTE_IP6TXNOROUTE_SHIFT) -#define I40E_GLPES_PFIP6TXOCTSHI(_i) (0x00012404 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXOCTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXOCTSHI_IP6TXOCTSHI_SHIFT 0 -#define I40E_GLPES_PFIP6TXOCTSHI_IP6TXOCTSHI_MASK (0xFFFF << I40E_GLPES_PFIP6TXOCTSHI_IP6TXOCTSHI_SHIFT) -#define I40E_GLPES_PFIP6TXOCTSLO(_i) (0x00012400 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXOCTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXOCTSLO_IP6TXOCTSLO_SHIFT 0 -#define I40E_GLPES_PFIP6TXOCTSLO_IP6TXOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6TXOCTSLO_IP6TXOCTSLO_SHIFT) -#define I40E_GLPES_PFIP6TXPKTSHI(_i) (0x00012604 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXPKTSHI_IP6TXPKTSHI_SHIFT 0 -#define I40E_GLPES_PFIP6TXPKTSHI_IP6TXPKTSHI_MASK (0xFFFF << I40E_GLPES_PFIP6TXPKTSHI_IP6TXPKTSHI_SHIFT) -#define I40E_GLPES_PFIP6TXPKTSLO(_i) (0x00012600 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFIP6TXPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFIP6TXPKTSLO_IP6TXPKTSLO_SHIFT 0 -#define I40E_GLPES_PFIP6TXPKTSLO_IP6TXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFIP6TXPKTSLO_IP6TXPKTSLO_SHIFT) -#define I40E_GLPES_PFRDMARXRDSHI(_i) (0x00013E04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMARXRDSHI_MAX_INDEX 15 -#define I40E_GLPES_PFRDMARXRDSHI_RDMARXRDSHI_SHIFT 0 -#define I40E_GLPES_PFRDMARXRDSHI_RDMARXRDSHI_MASK (0xFFFF << I40E_GLPES_PFRDMARXRDSHI_RDMARXRDSHI_SHIFT) -#define I40E_GLPES_PFRDMARXRDSLO(_i) (0x00013E00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMARXRDSLO_MAX_INDEX 15 -#define I40E_GLPES_PFRDMARXRDSLO_RDMARXRDSLO_SHIFT 0 -#define I40E_GLPES_PFRDMARXRDSLO_RDMARXRDSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMARXRDSLO_RDMARXRDSLO_SHIFT) -#define I40E_GLPES_PFRDMARXSNDSHI(_i) (0x00014004 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMARXSNDSHI_MAX_INDEX 15 -#define I40E_GLPES_PFRDMARXSNDSHI_RDMARXSNDSHI_SHIFT 0 -#define I40E_GLPES_PFRDMARXSNDSHI_RDMARXSNDSHI_MASK (0xFFFF << I40E_GLPES_PFRDMARXSNDSHI_RDMARXSNDSHI_SHIFT) -#define I40E_GLPES_PFRDMARXSNDSLO(_i) (0x00014000 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMARXSNDSLO_MAX_INDEX 15 -#define I40E_GLPES_PFRDMARXSNDSLO_RDMARXSNDSLO_SHIFT 0 -#define I40E_GLPES_PFRDMARXSNDSLO_RDMARXSNDSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMARXSNDSLO_RDMARXSNDSLO_SHIFT) -#define I40E_GLPES_PFRDMARXWRSHI(_i) (0x00013C04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMARXWRSHI_MAX_INDEX 15 -#define I40E_GLPES_PFRDMARXWRSHI_RDMARXWRSHI_SHIFT 0 -#define I40E_GLPES_PFRDMARXWRSHI_RDMARXWRSHI_MASK (0xFFFF << I40E_GLPES_PFRDMARXWRSHI_RDMARXWRSHI_SHIFT) -#define I40E_GLPES_PFRDMARXWRSLO(_i) (0x00013C00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMARXWRSLO_MAX_INDEX 15 -#define I40E_GLPES_PFRDMARXWRSLO_RDMARXWRSLO_SHIFT 0 -#define I40E_GLPES_PFRDMARXWRSLO_RDMARXWRSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMARXWRSLO_RDMARXWRSLO_SHIFT) -#define I40E_GLPES_PFRDMATXRDSHI(_i) (0x00014404 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMATXRDSHI_MAX_INDEX 15 -#define I40E_GLPES_PFRDMATXRDSHI_RDMARXRDSHI_SHIFT 0 -#define I40E_GLPES_PFRDMATXRDSHI_RDMARXRDSHI_MASK (0xFFFF << I40E_GLPES_PFRDMATXRDSHI_RDMARXRDSHI_SHIFT) -#define I40E_GLPES_PFRDMATXRDSLO(_i) (0x00014400 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMATXRDSLO_MAX_INDEX 15 -#define I40E_GLPES_PFRDMATXRDSLO_RDMARXRDSLO_SHIFT 0 -#define I40E_GLPES_PFRDMATXRDSLO_RDMARXRDSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMATXRDSLO_RDMARXRDSLO_SHIFT) -#define I40E_GLPES_PFRDMATXSNDSHI(_i) (0x00014604 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMATXSNDSHI_MAX_INDEX 15 -#define I40E_GLPES_PFRDMATXSNDSHI_RDMARXSNDSHI_SHIFT 0 -#define I40E_GLPES_PFRDMATXSNDSHI_RDMARXSNDSHI_MASK (0xFFFF << I40E_GLPES_PFRDMATXSNDSHI_RDMARXSNDSHI_SHIFT) -#define I40E_GLPES_PFRDMATXSNDSLO(_i) (0x00014600 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMATXSNDSLO_MAX_INDEX 15 -#define I40E_GLPES_PFRDMATXSNDSLO_RDMARXSNDSLO_SHIFT 0 -#define I40E_GLPES_PFRDMATXSNDSLO_RDMARXSNDSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMATXSNDSLO_RDMARXSNDSLO_SHIFT) -#define I40E_GLPES_PFRDMATXWRSHI(_i) (0x00014204 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMATXWRSHI_MAX_INDEX 15 -#define I40E_GLPES_PFRDMATXWRSHI_RDMARXWRSHI_SHIFT 0 -#define I40E_GLPES_PFRDMATXWRSHI_RDMARXWRSHI_MASK (0xFFFF << I40E_GLPES_PFRDMATXWRSHI_RDMARXWRSHI_SHIFT) -#define I40E_GLPES_PFRDMATXWRSLO(_i) (0x00014200 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMATXWRSLO_MAX_INDEX 15 -#define I40E_GLPES_PFRDMATXWRSLO_RDMARXWRSLO_SHIFT 0 -#define I40E_GLPES_PFRDMATXWRSLO_RDMARXWRSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMATXWRSLO_RDMARXWRSLO_SHIFT) -#define I40E_GLPES_PFRDMAVBNDHI(_i) (0x00014804 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMAVBNDHI_MAX_INDEX 15 -#define I40E_GLPES_PFRDMAVBNDHI_RDMAVBNDHI_SHIFT 0 -#define I40E_GLPES_PFRDMAVBNDHI_RDMAVBNDHI_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMAVBNDHI_RDMAVBNDHI_SHIFT) -#define I40E_GLPES_PFRDMAVBNDLO(_i) (0x00014800 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMAVBNDLO_MAX_INDEX 15 -#define I40E_GLPES_PFRDMAVBNDLO_RDMAVBNDLO_SHIFT 0 -#define I40E_GLPES_PFRDMAVBNDLO_RDMAVBNDLO_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMAVBNDLO_RDMAVBNDLO_SHIFT) -#define I40E_GLPES_PFRDMAVINVHI(_i) (0x00014A04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMAVINVHI_MAX_INDEX 15 -#define I40E_GLPES_PFRDMAVINVHI_RDMAVINVHI_SHIFT 0 -#define I40E_GLPES_PFRDMAVINVHI_RDMAVINVHI_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMAVINVHI_RDMAVINVHI_SHIFT) -#define I40E_GLPES_PFRDMAVINVLO(_i) (0x00014A00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRDMAVINVLO_MAX_INDEX 15 -#define I40E_GLPES_PFRDMAVINVLO_RDMAVINVLO_SHIFT 0 -#define I40E_GLPES_PFRDMAVINVLO_RDMAVINVLO_MASK (0xFFFFFFFF << I40E_GLPES_PFRDMAVINVLO_RDMAVINVLO_SHIFT) -#define I40E_GLPES_PFRXVLANERR(_i) (0x00010000 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFRXVLANERR_MAX_INDEX 15 -#define I40E_GLPES_PFRXVLANERR_RXVLANERR_SHIFT 0 -#define I40E_GLPES_PFRXVLANERR_RXVLANERR_MASK (0xFFFFFF << I40E_GLPES_PFRXVLANERR_RXVLANERR_SHIFT) -#define I40E_GLPES_PFTCPRTXSEG(_i) (0x00013600 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFTCPRTXSEG_MAX_INDEX 15 -#define I40E_GLPES_PFTCPRTXSEG_TCPRTXSEG_SHIFT 0 -#define I40E_GLPES_PFTCPRTXSEG_TCPRTXSEG_MASK (0xFFFFFFFF << I40E_GLPES_PFTCPRTXSEG_TCPRTXSEG_SHIFT) -#define I40E_GLPES_PFTCPRXOPTERR(_i) (0x00013200 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFTCPRXOPTERR_MAX_INDEX 15 -#define I40E_GLPES_PFTCPRXOPTERR_TCPRXOPTERR_SHIFT 0 -#define I40E_GLPES_PFTCPRXOPTERR_TCPRXOPTERR_MASK (0xFFFFFF << I40E_GLPES_PFTCPRXOPTERR_TCPRXOPTERR_SHIFT) -#define I40E_GLPES_PFTCPRXPROTOERR(_i) (0x00013300 + ((_i) * 4)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFTCPRXPROTOERR_MAX_INDEX 15 -#define I40E_GLPES_PFTCPRXPROTOERR_TCPRXPROTOERR_SHIFT 0 -#define I40E_GLPES_PFTCPRXPROTOERR_TCPRXPROTOERR_MASK (0xFFFFFF << I40E_GLPES_PFTCPRXPROTOERR_TCPRXPROTOERR_SHIFT) -#define I40E_GLPES_PFTCPRXSEGSHI(_i) (0x00013004 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFTCPRXSEGSHI_MAX_INDEX 15 -#define I40E_GLPES_PFTCPRXSEGSHI_TCPRXSEGSHI_SHIFT 0 -#define I40E_GLPES_PFTCPRXSEGSHI_TCPRXSEGSHI_MASK (0xFFFF << I40E_GLPES_PFTCPRXSEGSHI_TCPRXSEGSHI_SHIFT) -#define I40E_GLPES_PFTCPRXSEGSLO(_i) (0x00013000 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFTCPRXSEGSLO_MAX_INDEX 15 -#define I40E_GLPES_PFTCPRXSEGSLO_TCPRXSEGSLO_SHIFT 0 -#define I40E_GLPES_PFTCPRXSEGSLO_TCPRXSEGSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFTCPRXSEGSLO_TCPRXSEGSLO_SHIFT) -#define I40E_GLPES_PFTCPTXSEGHI(_i) (0x00013404 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFTCPTXSEGHI_MAX_INDEX 15 -#define I40E_GLPES_PFTCPTXSEGHI_TCPTXSEGHI_SHIFT 0 -#define I40E_GLPES_PFTCPTXSEGHI_TCPTXSEGHI_MASK (0xFFFF << I40E_GLPES_PFTCPTXSEGHI_TCPTXSEGHI_SHIFT) -#define I40E_GLPES_PFTCPTXSEGLO(_i) (0x00013400 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFTCPTXSEGLO_MAX_INDEX 15 -#define I40E_GLPES_PFTCPTXSEGLO_TCPTXSEGLO_SHIFT 0 -#define I40E_GLPES_PFTCPTXSEGLO_TCPTXSEGLO_MASK (0xFFFFFFFF << I40E_GLPES_PFTCPTXSEGLO_TCPTXSEGLO_SHIFT) -#define I40E_GLPES_PFUDPRXPKTSHI(_i) (0x00013804 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFUDPRXPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFUDPRXPKTSHI_UDPRXPKTSHI_SHIFT 0 -#define I40E_GLPES_PFUDPRXPKTSHI_UDPRXPKTSHI_MASK (0xFFFF << I40E_GLPES_PFUDPRXPKTSHI_UDPRXPKTSHI_SHIFT) -#define I40E_GLPES_PFUDPRXPKTSLO(_i) (0x00013800 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFUDPRXPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFUDPRXPKTSLO_UDPRXPKTSLO_SHIFT 0 -#define I40E_GLPES_PFUDPRXPKTSLO_UDPRXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFUDPRXPKTSLO_UDPRXPKTSLO_SHIFT) -#define I40E_GLPES_PFUDPTXPKTSHI(_i) (0x00013A04 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFUDPTXPKTSHI_MAX_INDEX 15 -#define I40E_GLPES_PFUDPTXPKTSHI_UDPTXPKTSHI_SHIFT 0 -#define I40E_GLPES_PFUDPTXPKTSHI_UDPTXPKTSHI_MASK (0xFFFF << I40E_GLPES_PFUDPTXPKTSHI_UDPTXPKTSHI_SHIFT) -#define I40E_GLPES_PFUDPTXPKTSLO(_i) (0x00013A00 + ((_i) * 8)) /* _i=0...15 */ /* Reset: PE_CORER */ -#define I40E_GLPES_PFUDPTXPKTSLO_MAX_INDEX 15 -#define I40E_GLPES_PFUDPTXPKTSLO_UDPTXPKTSLO_SHIFT 0 -#define I40E_GLPES_PFUDPTXPKTSLO_UDPTXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_PFUDPTXPKTSLO_UDPTXPKTSLO_SHIFT) -#define I40E_GLPES_RDMARXMULTFPDUSHI 0x0001E014 /* Reset: PE_CORER */ -#define I40E_GLPES_RDMARXMULTFPDUSHI_RDMARXMULTFPDUSHI_SHIFT 0 -#define I40E_GLPES_RDMARXMULTFPDUSHI_RDMARXMULTFPDUSHI_MASK (0xFFFFFF << I40E_GLPES_RDMARXMULTFPDUSHI_RDMARXMULTFPDUSHI_SHIFT) -#define I40E_GLPES_RDMARXMULTFPDUSLO 0x0001E010 /* Reset: PE_CORER */ -#define I40E_GLPES_RDMARXMULTFPDUSLO_RDMARXMULTFPDUSLO_SHIFT 0 -#define I40E_GLPES_RDMARXMULTFPDUSLO_RDMARXMULTFPDUSLO_MASK (0xFFFFFFFF << I40E_GLPES_RDMARXMULTFPDUSLO_RDMARXMULTFPDUSLO_SHIFT) -#define I40E_GLPES_RDMARXOOODDPHI 0x0001E01C /* Reset: PE_CORER */ -#define I40E_GLPES_RDMARXOOODDPHI_RDMARXOOODDPHI_SHIFT 0 -#define I40E_GLPES_RDMARXOOODDPHI_RDMARXOOODDPHI_MASK (0xFFFFFF << I40E_GLPES_RDMARXOOODDPHI_RDMARXOOODDPHI_SHIFT) -#define I40E_GLPES_RDMARXOOODDPLO 0x0001E018 /* Reset: PE_CORER */ -#define I40E_GLPES_RDMARXOOODDPLO_RDMARXOOODDPLO_SHIFT 0 -#define I40E_GLPES_RDMARXOOODDPLO_RDMARXOOODDPLO_MASK (0xFFFFFFFF << I40E_GLPES_RDMARXOOODDPLO_RDMARXOOODDPLO_SHIFT) -#define I40E_GLPES_RDMARXOOONOMARK 0x0001E004 /* Reset: PE_CORER */ -#define I40E_GLPES_RDMARXOOONOMARK_RDMAOOONOMARK_SHIFT 0 -#define I40E_GLPES_RDMARXOOONOMARK_RDMAOOONOMARK_MASK (0xFFFFFFFF << I40E_GLPES_RDMARXOOONOMARK_RDMAOOONOMARK_SHIFT) -#define I40E_GLPES_RDMARXUNALIGN 0x0001E000 /* Reset: PE_CORER */ -#define I40E_GLPES_RDMARXUNALIGN_RDMRXAUNALIGN_SHIFT 0 -#define I40E_GLPES_RDMARXUNALIGN_RDMRXAUNALIGN_MASK (0xFFFFFFFF << I40E_GLPES_RDMARXUNALIGN_RDMRXAUNALIGN_SHIFT) -#define I40E_GLPES_TCPRXFOURHOLEHI 0x0001E044 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXFOURHOLEHI_TCPRXFOURHOLEHI_SHIFT 0 -#define I40E_GLPES_TCPRXFOURHOLEHI_TCPRXFOURHOLEHI_MASK (0xFFFFFF << I40E_GLPES_TCPRXFOURHOLEHI_TCPRXFOURHOLEHI_SHIFT) -#define I40E_GLPES_TCPRXFOURHOLELO 0x0001E040 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXFOURHOLELO_TCPRXFOURHOLELO_SHIFT 0 -#define I40E_GLPES_TCPRXFOURHOLELO_TCPRXFOURHOLELO_MASK (0xFFFFFFFF << I40E_GLPES_TCPRXFOURHOLELO_TCPRXFOURHOLELO_SHIFT) -#define I40E_GLPES_TCPRXONEHOLEHI 0x0001E02C /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXONEHOLEHI_TCPRXONEHOLEHI_SHIFT 0 -#define I40E_GLPES_TCPRXONEHOLEHI_TCPRXONEHOLEHI_MASK (0xFFFFFF << I40E_GLPES_TCPRXONEHOLEHI_TCPRXONEHOLEHI_SHIFT) -#define I40E_GLPES_TCPRXONEHOLELO 0x0001E028 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXONEHOLELO_TCPRXONEHOLELO_SHIFT 0 -#define I40E_GLPES_TCPRXONEHOLELO_TCPRXONEHOLELO_MASK (0xFFFFFFFF << I40E_GLPES_TCPRXONEHOLELO_TCPRXONEHOLELO_SHIFT) -#define I40E_GLPES_TCPRXPUREACKHI 0x0001E024 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXPUREACKHI_TCPRXPUREACKSHI_SHIFT 0 -#define I40E_GLPES_TCPRXPUREACKHI_TCPRXPUREACKSHI_MASK (0xFFFFFF << I40E_GLPES_TCPRXPUREACKHI_TCPRXPUREACKSHI_SHIFT) -#define I40E_GLPES_TCPRXPUREACKSLO 0x0001E020 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXPUREACKSLO_TCPRXPUREACKLO_SHIFT 0 -#define I40E_GLPES_TCPRXPUREACKSLO_TCPRXPUREACKLO_MASK (0xFFFFFFFF << I40E_GLPES_TCPRXPUREACKSLO_TCPRXPUREACKLO_SHIFT) -#define I40E_GLPES_TCPRXTHREEHOLEHI 0x0001E03C /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXTHREEHOLEHI_TCPRXTHREEHOLEHI_SHIFT 0 -#define I40E_GLPES_TCPRXTHREEHOLEHI_TCPRXTHREEHOLEHI_MASK (0xFFFFFF << I40E_GLPES_TCPRXTHREEHOLEHI_TCPRXTHREEHOLEHI_SHIFT) -#define I40E_GLPES_TCPRXTHREEHOLELO 0x0001E038 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXTHREEHOLELO_TCPRXTHREEHOLELO_SHIFT 0 -#define I40E_GLPES_TCPRXTHREEHOLELO_TCPRXTHREEHOLELO_MASK (0xFFFFFFFF << I40E_GLPES_TCPRXTHREEHOLELO_TCPRXTHREEHOLELO_SHIFT) -#define I40E_GLPES_TCPRXTWOHOLEHI 0x0001E034 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXTWOHOLEHI_TCPRXTWOHOLEHI_SHIFT 0 -#define I40E_GLPES_TCPRXTWOHOLEHI_TCPRXTWOHOLEHI_MASK (0xFFFFFF << I40E_GLPES_TCPRXTWOHOLEHI_TCPRXTWOHOLEHI_SHIFT) -#define I40E_GLPES_TCPRXTWOHOLELO 0x0001E030 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPRXTWOHOLELO_TCPRXTWOHOLELO_SHIFT 0 -#define I40E_GLPES_TCPRXTWOHOLELO_TCPRXTWOHOLELO_MASK (0xFFFFFFFF << I40E_GLPES_TCPRXTWOHOLELO_TCPRXTWOHOLELO_SHIFT) -#define I40E_GLPES_TCPTXRETRANSFASTHI 0x0001E04C /* Reset: PE_CORER */ -#define I40E_GLPES_TCPTXRETRANSFASTHI_TCPTXRETRANSFASTHI_SHIFT 0 -#define I40E_GLPES_TCPTXRETRANSFASTHI_TCPTXRETRANSFASTHI_MASK (0xFFFFFF << I40E_GLPES_TCPTXRETRANSFASTHI_TCPTXRETRANSFASTHI_SHIFT) -#define I40E_GLPES_TCPTXRETRANSFASTLO 0x0001E048 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPTXRETRANSFASTLO_TCPTXRETRANSFASTLO_SHIFT 0 -#define I40E_GLPES_TCPTXRETRANSFASTLO_TCPTXRETRANSFASTLO_MASK (0xFFFFFFFF << I40E_GLPES_TCPTXRETRANSFASTLO_TCPTXRETRANSFASTLO_SHIFT) -#define I40E_GLPES_TCPTXTOUTSFASTHI 0x0001E054 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPTXTOUTSFASTHI_TCPTXTOUTSFASTHI_SHIFT 0 -#define I40E_GLPES_TCPTXTOUTSFASTHI_TCPTXTOUTSFASTHI_MASK (0xFFFFFF << I40E_GLPES_TCPTXTOUTSFASTHI_TCPTXTOUTSFASTHI_SHIFT) -#define I40E_GLPES_TCPTXTOUTSFASTLO 0x0001E050 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPTXTOUTSFASTLO_TCPTXTOUTSFASTLO_SHIFT 0 -#define I40E_GLPES_TCPTXTOUTSFASTLO_TCPTXTOUTSFASTLO_MASK (0xFFFFFFFF << I40E_GLPES_TCPTXTOUTSFASTLO_TCPTXTOUTSFASTLO_SHIFT) -#define I40E_GLPES_TCPTXTOUTSHI 0x0001E05C /* Reset: PE_CORER */ -#define I40E_GLPES_TCPTXTOUTSHI_TCPTXTOUTSHI_SHIFT 0 -#define I40E_GLPES_TCPTXTOUTSHI_TCPTXTOUTSHI_MASK (0xFFFFFF << I40E_GLPES_TCPTXTOUTSHI_TCPTXTOUTSHI_SHIFT) -#define I40E_GLPES_TCPTXTOUTSLO 0x0001E058 /* Reset: PE_CORER */ -#define I40E_GLPES_TCPTXTOUTSLO_TCPTXTOUTSLO_SHIFT 0 -#define I40E_GLPES_TCPTXTOUTSLO_TCPTXTOUTSLO_MASK (0xFFFFFFFF << I40E_GLPES_TCPTXTOUTSLO_TCPTXTOUTSLO_SHIFT) -#define I40E_GLPES_VFIP4RXDISCARD(_i) (0x00018600 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXDISCARD_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXDISCARD_IP4RXDISCARD_SHIFT 0 -#define I40E_GLPES_VFIP4RXDISCARD_IP4RXDISCARD_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4RXDISCARD_IP4RXDISCARD_SHIFT) -#define I40E_GLPES_VFIP4RXFRAGSHI(_i) (0x00018804 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXFRAGSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXFRAGSHI_IP4RXFRAGSHI_SHIFT 0 -#define I40E_GLPES_VFIP4RXFRAGSHI_IP4RXFRAGSHI_MASK (0xFFFF << I40E_GLPES_VFIP4RXFRAGSHI_IP4RXFRAGSHI_SHIFT) -#define I40E_GLPES_VFIP4RXFRAGSLO(_i) (0x00018800 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXFRAGSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXFRAGSLO_IP4RXFRAGSLO_SHIFT 0 -#define I40E_GLPES_VFIP4RXFRAGSLO_IP4RXFRAGSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4RXFRAGSLO_IP4RXFRAGSLO_SHIFT) -#define I40E_GLPES_VFIP4RXMCOCTSHI(_i) (0x00018A04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXMCOCTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXMCOCTSHI_IP4RXMCOCTSHI_SHIFT 0 -#define I40E_GLPES_VFIP4RXMCOCTSHI_IP4RXMCOCTSHI_MASK (0xFFFF << I40E_GLPES_VFIP4RXMCOCTSHI_IP4RXMCOCTSHI_SHIFT) -#define I40E_GLPES_VFIP4RXMCOCTSLO(_i) (0x00018A00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXMCOCTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXMCOCTSLO_IP4RXMCOCTSLO_SHIFT 0 -#define I40E_GLPES_VFIP4RXMCOCTSLO_IP4RXMCOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4RXMCOCTSLO_IP4RXMCOCTSLO_SHIFT) -#define I40E_GLPES_VFIP4RXMCPKTSHI(_i) (0x00018C04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXMCPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXMCPKTSHI_IP4RXMCPKTSHI_SHIFT 0 -#define I40E_GLPES_VFIP4RXMCPKTSHI_IP4RXMCPKTSHI_MASK (0xFFFF << I40E_GLPES_VFIP4RXMCPKTSHI_IP4RXMCPKTSHI_SHIFT) -#define I40E_GLPES_VFIP4RXMCPKTSLO(_i) (0x00018C00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXMCPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXMCPKTSLO_IP4RXMCPKTSLO_SHIFT 0 -#define I40E_GLPES_VFIP4RXMCPKTSLO_IP4RXMCPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4RXMCPKTSLO_IP4RXMCPKTSLO_SHIFT) -#define I40E_GLPES_VFIP4RXOCTSHI(_i) (0x00018204 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXOCTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXOCTSHI_IP4RXOCTSHI_SHIFT 0 -#define I40E_GLPES_VFIP4RXOCTSHI_IP4RXOCTSHI_MASK (0xFFFF << I40E_GLPES_VFIP4RXOCTSHI_IP4RXOCTSHI_SHIFT) -#define I40E_GLPES_VFIP4RXOCTSLO(_i) (0x00018200 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXOCTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXOCTSLO_IP4RXOCTSLO_SHIFT 0 -#define I40E_GLPES_VFIP4RXOCTSLO_IP4RXOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4RXOCTSLO_IP4RXOCTSLO_SHIFT) -#define I40E_GLPES_VFIP4RXPKTSHI(_i) (0x00018404 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXPKTSHI_IP4RXPKTSHI_SHIFT 0 -#define I40E_GLPES_VFIP4RXPKTSHI_IP4RXPKTSHI_MASK (0xFFFF << I40E_GLPES_VFIP4RXPKTSHI_IP4RXPKTSHI_SHIFT) -#define I40E_GLPES_VFIP4RXPKTSLO(_i) (0x00018400 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXPKTSLO_IP4RXPKTSLO_SHIFT 0 -#define I40E_GLPES_VFIP4RXPKTSLO_IP4RXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4RXPKTSLO_IP4RXPKTSLO_SHIFT) -#define I40E_GLPES_VFIP4RXTRUNC(_i) (0x00018700 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4RXTRUNC_MAX_INDEX 31 -#define I40E_GLPES_VFIP4RXTRUNC_IP4RXTRUNC_SHIFT 0 -#define I40E_GLPES_VFIP4RXTRUNC_IP4RXTRUNC_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4RXTRUNC_IP4RXTRUNC_SHIFT) -#define I40E_GLPES_VFIP4TXFRAGSHI(_i) (0x00019E04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXFRAGSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXFRAGSHI_IP4TXFRAGSHI_SHIFT 0 -#define I40E_GLPES_VFIP4TXFRAGSHI_IP4TXFRAGSHI_MASK (0xFFFF << I40E_GLPES_VFIP4TXFRAGSHI_IP4TXFRAGSHI_SHIFT) -#define I40E_GLPES_VFIP4TXFRAGSLO(_i) (0x00019E00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXFRAGSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXFRAGSLO_IP4TXFRAGSLO_SHIFT 0 -#define I40E_GLPES_VFIP4TXFRAGSLO_IP4TXFRAGSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4TXFRAGSLO_IP4TXFRAGSLO_SHIFT) -#define I40E_GLPES_VFIP4TXMCOCTSHI(_i) (0x0001A004 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXMCOCTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXMCOCTSHI_IP4TXMCOCTSHI_SHIFT 0 -#define I40E_GLPES_VFIP4TXMCOCTSHI_IP4TXMCOCTSHI_MASK (0xFFFF << I40E_GLPES_VFIP4TXMCOCTSHI_IP4TXMCOCTSHI_SHIFT) -#define I40E_GLPES_VFIP4TXMCOCTSLO(_i) (0x0001A000 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXMCOCTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXMCOCTSLO_IP4TXMCOCTSLO_SHIFT 0 -#define I40E_GLPES_VFIP4TXMCOCTSLO_IP4TXMCOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4TXMCOCTSLO_IP4TXMCOCTSLO_SHIFT) -#define I40E_GLPES_VFIP4TXMCPKTSHI(_i) (0x0001A204 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXMCPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXMCPKTSHI_IP4TXMCPKTSHI_SHIFT 0 -#define I40E_GLPES_VFIP4TXMCPKTSHI_IP4TXMCPKTSHI_MASK (0xFFFF << I40E_GLPES_VFIP4TXMCPKTSHI_IP4TXMCPKTSHI_SHIFT) -#define I40E_GLPES_VFIP4TXMCPKTSLO(_i) (0x0001A200 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXMCPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXMCPKTSLO_IP4TXMCPKTSLO_SHIFT 0 -#define I40E_GLPES_VFIP4TXMCPKTSLO_IP4TXMCPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4TXMCPKTSLO_IP4TXMCPKTSLO_SHIFT) -#define I40E_GLPES_VFIP4TXNOROUTE(_i) (0x0001AE00 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXNOROUTE_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXNOROUTE_IP4TXNOROUTE_SHIFT 0 -#define I40E_GLPES_VFIP4TXNOROUTE_IP4TXNOROUTE_MASK (0xFFFFFF << I40E_GLPES_VFIP4TXNOROUTE_IP4TXNOROUTE_SHIFT) -#define I40E_GLPES_VFIP4TXOCTSHI(_i) (0x00019A04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXOCTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXOCTSHI_IP4TXOCTSHI_SHIFT 0 -#define I40E_GLPES_VFIP4TXOCTSHI_IP4TXOCTSHI_MASK (0xFFFF << I40E_GLPES_VFIP4TXOCTSHI_IP4TXOCTSHI_SHIFT) -#define I40E_GLPES_VFIP4TXOCTSLO(_i) (0x00019A00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXOCTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXOCTSLO_IP4TXOCTSLO_SHIFT 0 -#define I40E_GLPES_VFIP4TXOCTSLO_IP4TXOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4TXOCTSLO_IP4TXOCTSLO_SHIFT) -#define I40E_GLPES_VFIP4TXPKTSHI(_i) (0x00019C04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXPKTSHI_IP4TXPKTSHI_SHIFT 0 -#define I40E_GLPES_VFIP4TXPKTSHI_IP4TXPKTSHI_MASK (0xFFFF << I40E_GLPES_VFIP4TXPKTSHI_IP4TXPKTSHI_SHIFT) -#define I40E_GLPES_VFIP4TXPKTSLO(_i) (0x00019C00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP4TXPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP4TXPKTSLO_IP4TXPKTSLO_SHIFT 0 -#define I40E_GLPES_VFIP4TXPKTSLO_IP4TXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP4TXPKTSLO_IP4TXPKTSLO_SHIFT) -#define I40E_GLPES_VFIP6RXDISCARD(_i) (0x00019200 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXDISCARD_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXDISCARD_IP6RXDISCARD_SHIFT 0 -#define I40E_GLPES_VFIP6RXDISCARD_IP6RXDISCARD_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6RXDISCARD_IP6RXDISCARD_SHIFT) -#define I40E_GLPES_VFIP6RXFRAGSHI(_i) (0x00019404 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXFRAGSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXFRAGSHI_IP6RXFRAGSHI_SHIFT 0 -#define I40E_GLPES_VFIP6RXFRAGSHI_IP6RXFRAGSHI_MASK (0xFFFF << I40E_GLPES_VFIP6RXFRAGSHI_IP6RXFRAGSHI_SHIFT) -#define I40E_GLPES_VFIP6RXFRAGSLO(_i) (0x00019400 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXFRAGSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXFRAGSLO_IP6RXFRAGSLO_SHIFT 0 -#define I40E_GLPES_VFIP6RXFRAGSLO_IP6RXFRAGSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6RXFRAGSLO_IP6RXFRAGSLO_SHIFT) -#define I40E_GLPES_VFIP6RXMCOCTSHI(_i) (0x00019604 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXMCOCTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXMCOCTSHI_IP6RXMCOCTSHI_SHIFT 0 -#define I40E_GLPES_VFIP6RXMCOCTSHI_IP6RXMCOCTSHI_MASK (0xFFFF << I40E_GLPES_VFIP6RXMCOCTSHI_IP6RXMCOCTSHI_SHIFT) -#define I40E_GLPES_VFIP6RXMCOCTSLO(_i) (0x00019600 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXMCOCTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXMCOCTSLO_IP6RXMCOCTSLO_SHIFT 0 -#define I40E_GLPES_VFIP6RXMCOCTSLO_IP6RXMCOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6RXMCOCTSLO_IP6RXMCOCTSLO_SHIFT) -#define I40E_GLPES_VFIP6RXMCPKTSHI(_i) (0x00019804 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXMCPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXMCPKTSHI_IP6RXMCPKTSHI_SHIFT 0 -#define I40E_GLPES_VFIP6RXMCPKTSHI_IP6RXMCPKTSHI_MASK (0xFFFF << I40E_GLPES_VFIP6RXMCPKTSHI_IP6RXMCPKTSHI_SHIFT) -#define I40E_GLPES_VFIP6RXMCPKTSLO(_i) (0x00019800 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXMCPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXMCPKTSLO_IP6RXMCPKTSLO_SHIFT 0 -#define I40E_GLPES_VFIP6RXMCPKTSLO_IP6RXMCPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6RXMCPKTSLO_IP6RXMCPKTSLO_SHIFT) -#define I40E_GLPES_VFIP6RXOCTSHI(_i) (0x00018E04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXOCTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXOCTSHI_IP6RXOCTSHI_SHIFT 0 -#define I40E_GLPES_VFIP6RXOCTSHI_IP6RXOCTSHI_MASK (0xFFFF << I40E_GLPES_VFIP6RXOCTSHI_IP6RXOCTSHI_SHIFT) -#define I40E_GLPES_VFIP6RXOCTSLO(_i) (0x00018E00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXOCTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXOCTSLO_IP6RXOCTSLO_SHIFT 0 -#define I40E_GLPES_VFIP6RXOCTSLO_IP6RXOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6RXOCTSLO_IP6RXOCTSLO_SHIFT) -#define I40E_GLPES_VFIP6RXPKTSHI(_i) (0x00019004 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXPKTSHI_IP6RXPKTSHI_SHIFT 0 -#define I40E_GLPES_VFIP6RXPKTSHI_IP6RXPKTSHI_MASK (0xFFFF << I40E_GLPES_VFIP6RXPKTSHI_IP6RXPKTSHI_SHIFT) -#define I40E_GLPES_VFIP6RXPKTSLO(_i) (0x00019000 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXPKTSLO_IP6RXPKTSLO_SHIFT 0 -#define I40E_GLPES_VFIP6RXPKTSLO_IP6RXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6RXPKTSLO_IP6RXPKTSLO_SHIFT) -#define I40E_GLPES_VFIP6RXTRUNC(_i) (0x00019300 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6RXTRUNC_MAX_INDEX 31 -#define I40E_GLPES_VFIP6RXTRUNC_IP6RXTRUNC_SHIFT 0 -#define I40E_GLPES_VFIP6RXTRUNC_IP6RXTRUNC_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6RXTRUNC_IP6RXTRUNC_SHIFT) -#define I40E_GLPES_VFIP6TXFRAGSHI(_i) (0x0001A804 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXFRAGSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXFRAGSHI_IP6TXFRAGSHI_SHIFT 0 -#define I40E_GLPES_VFIP6TXFRAGSHI_IP6TXFRAGSHI_MASK (0xFFFF << I40E_GLPES_VFIP6TXFRAGSHI_IP6TXFRAGSHI_SHIFT) -#define I40E_GLPES_VFIP6TXFRAGSLO(_i) (0x0001A800 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXFRAGSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXFRAGSLO_IP6TXFRAGSLO_SHIFT 0 -#define I40E_GLPES_VFIP6TXFRAGSLO_IP6TXFRAGSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6TXFRAGSLO_IP6TXFRAGSLO_SHIFT) -#define I40E_GLPES_VFIP6TXMCOCTSHI(_i) (0x0001AA04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXMCOCTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXMCOCTSHI_IP6TXMCOCTSHI_SHIFT 0 -#define I40E_GLPES_VFIP6TXMCOCTSHI_IP6TXMCOCTSHI_MASK (0xFFFF << I40E_GLPES_VFIP6TXMCOCTSHI_IP6TXMCOCTSHI_SHIFT) -#define I40E_GLPES_VFIP6TXMCOCTSLO(_i) (0x0001AA00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXMCOCTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXMCOCTSLO_IP6TXMCOCTSLO_SHIFT 0 -#define I40E_GLPES_VFIP6TXMCOCTSLO_IP6TXMCOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6TXMCOCTSLO_IP6TXMCOCTSLO_SHIFT) -#define I40E_GLPES_VFIP6TXMCPKTSHI(_i) (0x0001AC04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXMCPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXMCPKTSHI_IP6TXMCPKTSHI_SHIFT 0 -#define I40E_GLPES_VFIP6TXMCPKTSHI_IP6TXMCPKTSHI_MASK (0xFFFF << I40E_GLPES_VFIP6TXMCPKTSHI_IP6TXMCPKTSHI_SHIFT) -#define I40E_GLPES_VFIP6TXMCPKTSLO(_i) (0x0001AC00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXMCPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXMCPKTSLO_IP6TXMCPKTSLO_SHIFT 0 -#define I40E_GLPES_VFIP6TXMCPKTSLO_IP6TXMCPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6TXMCPKTSLO_IP6TXMCPKTSLO_SHIFT) -#define I40E_GLPES_VFIP6TXNOROUTE(_i) (0x0001AF00 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXNOROUTE_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXNOROUTE_IP6TXNOROUTE_SHIFT 0 -#define I40E_GLPES_VFIP6TXNOROUTE_IP6TXNOROUTE_MASK (0xFFFFFF << I40E_GLPES_VFIP6TXNOROUTE_IP6TXNOROUTE_SHIFT) -#define I40E_GLPES_VFIP6TXOCTSHI(_i) (0x0001A404 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXOCTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXOCTSHI_IP6TXOCTSHI_SHIFT 0 -#define I40E_GLPES_VFIP6TXOCTSHI_IP6TXOCTSHI_MASK (0xFFFF << I40E_GLPES_VFIP6TXOCTSHI_IP6TXOCTSHI_SHIFT) -#define I40E_GLPES_VFIP6TXOCTSLO(_i) (0x0001A400 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXOCTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXOCTSLO_IP6TXOCTSLO_SHIFT 0 -#define I40E_GLPES_VFIP6TXOCTSLO_IP6TXOCTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6TXOCTSLO_IP6TXOCTSLO_SHIFT) -#define I40E_GLPES_VFIP6TXPKTSHI(_i) (0x0001A604 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXPKTSHI_IP6TXPKTSHI_SHIFT 0 -#define I40E_GLPES_VFIP6TXPKTSHI_IP6TXPKTSHI_MASK (0xFFFF << I40E_GLPES_VFIP6TXPKTSHI_IP6TXPKTSHI_SHIFT) -#define I40E_GLPES_VFIP6TXPKTSLO(_i) (0x0001A600 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFIP6TXPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFIP6TXPKTSLO_IP6TXPKTSLO_SHIFT 0 -#define I40E_GLPES_VFIP6TXPKTSLO_IP6TXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFIP6TXPKTSLO_IP6TXPKTSLO_SHIFT) -#define I40E_GLPES_VFRDMARXRDSHI(_i) (0x0001BE04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMARXRDSHI_MAX_INDEX 31 -#define I40E_GLPES_VFRDMARXRDSHI_RDMARXRDSHI_SHIFT 0 -#define I40E_GLPES_VFRDMARXRDSHI_RDMARXRDSHI_MASK (0xFFFF << I40E_GLPES_VFRDMARXRDSHI_RDMARXRDSHI_SHIFT) -#define I40E_GLPES_VFRDMARXRDSLO(_i) (0x0001BE00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMARXRDSLO_MAX_INDEX 31 -#define I40E_GLPES_VFRDMARXRDSLO_RDMARXRDSLO_SHIFT 0 -#define I40E_GLPES_VFRDMARXRDSLO_RDMARXRDSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMARXRDSLO_RDMARXRDSLO_SHIFT) -#define I40E_GLPES_VFRDMARXSNDSHI(_i) (0x0001C004 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMARXSNDSHI_MAX_INDEX 31 -#define I40E_GLPES_VFRDMARXSNDSHI_RDMARXSNDSHI_SHIFT 0 -#define I40E_GLPES_VFRDMARXSNDSHI_RDMARXSNDSHI_MASK (0xFFFF << I40E_GLPES_VFRDMARXSNDSHI_RDMARXSNDSHI_SHIFT) -#define I40E_GLPES_VFRDMARXSNDSLO(_i) (0x0001C000 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMARXSNDSLO_MAX_INDEX 31 -#define I40E_GLPES_VFRDMARXSNDSLO_RDMARXSNDSLO_SHIFT 0 -#define I40E_GLPES_VFRDMARXSNDSLO_RDMARXSNDSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMARXSNDSLO_RDMARXSNDSLO_SHIFT) -#define I40E_GLPES_VFRDMARXWRSHI(_i) (0x0001BC04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMARXWRSHI_MAX_INDEX 31 -#define I40E_GLPES_VFRDMARXWRSHI_RDMARXWRSHI_SHIFT 0 -#define I40E_GLPES_VFRDMARXWRSHI_RDMARXWRSHI_MASK (0xFFFF << I40E_GLPES_VFRDMARXWRSHI_RDMARXWRSHI_SHIFT) -#define I40E_GLPES_VFRDMARXWRSLO(_i) (0x0001BC00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMARXWRSLO_MAX_INDEX 31 -#define I40E_GLPES_VFRDMARXWRSLO_RDMARXWRSLO_SHIFT 0 -#define I40E_GLPES_VFRDMARXWRSLO_RDMARXWRSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMARXWRSLO_RDMARXWRSLO_SHIFT) -#define I40E_GLPES_VFRDMATXRDSHI(_i) (0x0001C404 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMATXRDSHI_MAX_INDEX 31 -#define I40E_GLPES_VFRDMATXRDSHI_RDMARXRDSHI_SHIFT 0 -#define I40E_GLPES_VFRDMATXRDSHI_RDMARXRDSHI_MASK (0xFFFF << I40E_GLPES_VFRDMATXRDSHI_RDMARXRDSHI_SHIFT) -#define I40E_GLPES_VFRDMATXRDSLO(_i) (0x0001C400 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMATXRDSLO_MAX_INDEX 31 -#define I40E_GLPES_VFRDMATXRDSLO_RDMARXRDSLO_SHIFT 0 -#define I40E_GLPES_VFRDMATXRDSLO_RDMARXRDSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMATXRDSLO_RDMARXRDSLO_SHIFT) -#define I40E_GLPES_VFRDMATXSNDSHI(_i) (0x0001C604 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMATXSNDSHI_MAX_INDEX 31 -#define I40E_GLPES_VFRDMATXSNDSHI_RDMARXSNDSHI_SHIFT 0 -#define I40E_GLPES_VFRDMATXSNDSHI_RDMARXSNDSHI_MASK (0xFFFF << I40E_GLPES_VFRDMATXSNDSHI_RDMARXSNDSHI_SHIFT) -#define I40E_GLPES_VFRDMATXSNDSLO(_i) (0x0001C600 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMATXSNDSLO_MAX_INDEX 31 -#define I40E_GLPES_VFRDMATXSNDSLO_RDMARXSNDSLO_SHIFT 0 -#define I40E_GLPES_VFRDMATXSNDSLO_RDMARXSNDSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMATXSNDSLO_RDMARXSNDSLO_SHIFT) -#define I40E_GLPES_VFRDMATXWRSHI(_i) (0x0001C204 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMATXWRSHI_MAX_INDEX 31 -#define I40E_GLPES_VFRDMATXWRSHI_RDMARXWRSHI_SHIFT 0 -#define I40E_GLPES_VFRDMATXWRSHI_RDMARXWRSHI_MASK (0xFFFF << I40E_GLPES_VFRDMATXWRSHI_RDMARXWRSHI_SHIFT) -#define I40E_GLPES_VFRDMATXWRSLO(_i) (0x0001C200 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMATXWRSLO_MAX_INDEX 31 -#define I40E_GLPES_VFRDMATXWRSLO_RDMARXWRSLO_SHIFT 0 -#define I40E_GLPES_VFRDMATXWRSLO_RDMARXWRSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMATXWRSLO_RDMARXWRSLO_SHIFT) -#define I40E_GLPES_VFRDMAVBNDHI(_i) (0x0001C804 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMAVBNDHI_MAX_INDEX 31 -#define I40E_GLPES_VFRDMAVBNDHI_RDMAVBNDHI_SHIFT 0 -#define I40E_GLPES_VFRDMAVBNDHI_RDMAVBNDHI_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMAVBNDHI_RDMAVBNDHI_SHIFT) -#define I40E_GLPES_VFRDMAVBNDLO(_i) (0x0001C800 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMAVBNDLO_MAX_INDEX 31 -#define I40E_GLPES_VFRDMAVBNDLO_RDMAVBNDLO_SHIFT 0 -#define I40E_GLPES_VFRDMAVBNDLO_RDMAVBNDLO_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMAVBNDLO_RDMAVBNDLO_SHIFT) -#define I40E_GLPES_VFRDMAVINVHI(_i) (0x0001CA04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMAVINVHI_MAX_INDEX 31 -#define I40E_GLPES_VFRDMAVINVHI_RDMAVINVHI_SHIFT 0 -#define I40E_GLPES_VFRDMAVINVHI_RDMAVINVHI_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMAVINVHI_RDMAVINVHI_SHIFT) -#define I40E_GLPES_VFRDMAVINVLO(_i) (0x0001CA00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRDMAVINVLO_MAX_INDEX 31 -#define I40E_GLPES_VFRDMAVINVLO_RDMAVINVLO_SHIFT 0 -#define I40E_GLPES_VFRDMAVINVLO_RDMAVINVLO_MASK (0xFFFFFFFF << I40E_GLPES_VFRDMAVINVLO_RDMAVINVLO_SHIFT) -#define I40E_GLPES_VFRXVLANERR(_i) (0x00018000 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFRXVLANERR_MAX_INDEX 31 -#define I40E_GLPES_VFRXVLANERR_RXVLANERR_SHIFT 0 -#define I40E_GLPES_VFRXVLANERR_RXVLANERR_MASK (0xFFFFFF << I40E_GLPES_VFRXVLANERR_RXVLANERR_SHIFT) -#define I40E_GLPES_VFTCPRTXSEG(_i) (0x0001B600 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFTCPRTXSEG_MAX_INDEX 31 -#define I40E_GLPES_VFTCPRTXSEG_TCPRTXSEG_SHIFT 0 -#define I40E_GLPES_VFTCPRTXSEG_TCPRTXSEG_MASK (0xFFFFFFFF << I40E_GLPES_VFTCPRTXSEG_TCPRTXSEG_SHIFT) -#define I40E_GLPES_VFTCPRXOPTERR(_i) (0x0001B200 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFTCPRXOPTERR_MAX_INDEX 31 -#define I40E_GLPES_VFTCPRXOPTERR_TCPRXOPTERR_SHIFT 0 -#define I40E_GLPES_VFTCPRXOPTERR_TCPRXOPTERR_MASK (0xFFFFFF << I40E_GLPES_VFTCPRXOPTERR_TCPRXOPTERR_SHIFT) -#define I40E_GLPES_VFTCPRXPROTOERR(_i) (0x0001B300 + ((_i) * 4)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFTCPRXPROTOERR_MAX_INDEX 31 -#define I40E_GLPES_VFTCPRXPROTOERR_TCPRXPROTOERR_SHIFT 0 -#define I40E_GLPES_VFTCPRXPROTOERR_TCPRXPROTOERR_MASK (0xFFFFFF << I40E_GLPES_VFTCPRXPROTOERR_TCPRXPROTOERR_SHIFT) -#define I40E_GLPES_VFTCPRXSEGSHI(_i) (0x0001B004 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFTCPRXSEGSHI_MAX_INDEX 31 -#define I40E_GLPES_VFTCPRXSEGSHI_TCPRXSEGSHI_SHIFT 0 -#define I40E_GLPES_VFTCPRXSEGSHI_TCPRXSEGSHI_MASK (0xFFFF << I40E_GLPES_VFTCPRXSEGSHI_TCPRXSEGSHI_SHIFT) -#define I40E_GLPES_VFTCPRXSEGSLO(_i) (0x0001B000 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFTCPRXSEGSLO_MAX_INDEX 31 -#define I40E_GLPES_VFTCPRXSEGSLO_TCPRXSEGSLO_SHIFT 0 -#define I40E_GLPES_VFTCPRXSEGSLO_TCPRXSEGSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFTCPRXSEGSLO_TCPRXSEGSLO_SHIFT) -#define I40E_GLPES_VFTCPTXSEGHI(_i) (0x0001B404 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFTCPTXSEGHI_MAX_INDEX 31 -#define I40E_GLPES_VFTCPTXSEGHI_TCPTXSEGHI_SHIFT 0 -#define I40E_GLPES_VFTCPTXSEGHI_TCPTXSEGHI_MASK (0xFFFF << I40E_GLPES_VFTCPTXSEGHI_TCPTXSEGHI_SHIFT) -#define I40E_GLPES_VFTCPTXSEGLO(_i) (0x0001B400 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFTCPTXSEGLO_MAX_INDEX 31 -#define I40E_GLPES_VFTCPTXSEGLO_TCPTXSEGLO_SHIFT 0 -#define I40E_GLPES_VFTCPTXSEGLO_TCPTXSEGLO_MASK (0xFFFFFFFF << I40E_GLPES_VFTCPTXSEGLO_TCPTXSEGLO_SHIFT) -#define I40E_GLPES_VFUDPRXPKTSHI(_i) (0x0001B804 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFUDPRXPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFUDPRXPKTSHI_UDPRXPKTSHI_SHIFT 0 -#define I40E_GLPES_VFUDPRXPKTSHI_UDPRXPKTSHI_MASK (0xFFFF << I40E_GLPES_VFUDPRXPKTSHI_UDPRXPKTSHI_SHIFT) -#define I40E_GLPES_VFUDPRXPKTSLO(_i) (0x0001B800 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFUDPRXPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFUDPRXPKTSLO_UDPRXPKTSLO_SHIFT 0 -#define I40E_GLPES_VFUDPRXPKTSLO_UDPRXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFUDPRXPKTSLO_UDPRXPKTSLO_SHIFT) -#define I40E_GLPES_VFUDPTXPKTSHI(_i) (0x0001BA04 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFUDPTXPKTSHI_MAX_INDEX 31 -#define I40E_GLPES_VFUDPTXPKTSHI_UDPTXPKTSHI_SHIFT 0 -#define I40E_GLPES_VFUDPTXPKTSHI_UDPTXPKTSHI_MASK (0xFFFF << I40E_GLPES_VFUDPTXPKTSHI_UDPTXPKTSHI_SHIFT) -#define I40E_GLPES_VFUDPTXPKTSLO(_i) (0x0001BA00 + ((_i) * 8)) /* _i=0...31 */ /* Reset: PE_CORER */ -#define I40E_GLPES_VFUDPTXPKTSLO_MAX_INDEX 31 -#define I40E_GLPES_VFUDPTXPKTSLO_UDPTXPKTSLO_SHIFT 0 -#define I40E_GLPES_VFUDPTXPKTSLO_UDPTXPKTSLO_MASK (0xFFFFFFFF << I40E_GLPES_VFUDPTXPKTSLO_UDPTXPKTSLO_SHIFT) - -#define I40E_VFPE_AEQALLOC1 0x0000A400 /* Reset: VFR */ -#define I40E_VFPE_AEQALLOC1_AECOUNT_SHIFT 0 -#define I40E_VFPE_AEQALLOC1_AECOUNT_MASK (0xFFFFFFFF << I40E_VFPE_AEQALLOC1_AECOUNT_SHIFT) -#define I40E_VFPE_CCQPHIGH1 0x00009800 /* Reset: VFR */ -#define I40E_VFPE_CCQPHIGH1_PECCQPHIGH_SHIFT 0 -#define I40E_VFPE_CCQPHIGH1_PECCQPHIGH_MASK (0xFFFFFFFF << I40E_VFPE_CCQPHIGH1_PECCQPHIGH_SHIFT) -#define I40E_VFPE_CCQPLOW1 0x0000AC00 /* Reset: VFR */ -#define I40E_VFPE_CCQPLOW1_PECCQPLOW_SHIFT 0 -#define I40E_VFPE_CCQPLOW1_PECCQPLOW_MASK (0xFFFFFFFF << I40E_VFPE_CCQPLOW1_PECCQPLOW_SHIFT) -#define I40E_VFPE_CCQPSTATUS1 0x0000B800 /* Reset: VFR */ -#define I40E_VFPE_CCQPSTATUS1_CCQP_DONE_SHIFT 0 -#define I40E_VFPE_CCQPSTATUS1_CCQP_DONE_MASK (0x1 << I40E_VFPE_CCQPSTATUS1_CCQP_DONE_SHIFT) -#define I40E_VFPE_CCQPSTATUS1_HMC_PROFILE_SHIFT 4 -#define I40E_VFPE_CCQPSTATUS1_HMC_PROFILE_MASK (0x7 << I40E_VFPE_CCQPSTATUS1_HMC_PROFILE_SHIFT) -#define I40E_VFPE_CCQPSTATUS1_RDMA_EN_VFS_SHIFT 16 -#define I40E_VFPE_CCQPSTATUS1_RDMA_EN_VFS_MASK (0x3F << I40E_VFPE_CCQPSTATUS1_RDMA_EN_VFS_SHIFT) -#define I40E_VFPE_CCQPSTATUS1_CCQP_ERR_SHIFT 31 -#define I40E_VFPE_CCQPSTATUS1_CCQP_ERR_MASK (0x1 << I40E_VFPE_CCQPSTATUS1_CCQP_ERR_SHIFT) -#define I40E_VFPE_CQACK1 0x0000B000 /* Reset: VFR */ -#define I40E_VFPE_CQACK1_PECQID_SHIFT 0 -#define I40E_VFPE_CQACK1_PECQID_MASK (0x1FFFF << I40E_VFPE_CQACK1_PECQID_SHIFT) -#define I40E_VFPE_CQARM1 0x0000B400 /* Reset: VFR */ -#define I40E_VFPE_CQARM1_PECQID_SHIFT 0 -#define I40E_VFPE_CQARM1_PECQID_MASK (0x1FFFF << I40E_VFPE_CQARM1_PECQID_SHIFT) -#define I40E_VFPE_CQPDB1 0x0000BC00 /* Reset: VFR */ -#define I40E_VFPE_CQPDB1_WQHEAD_SHIFT 0 -#define I40E_VFPE_CQPDB1_WQHEAD_MASK (0x7FF << I40E_VFPE_CQPDB1_WQHEAD_SHIFT) -#define I40E_VFPE_CQPERRCODES1 0x00009C00 /* Reset: VFR */ -#define I40E_VFPE_CQPERRCODES1_CQP_MINOR_CODE_SHIFT 0 -#define I40E_VFPE_CQPERRCODES1_CQP_MINOR_CODE_MASK (0xFFFF << I40E_VFPE_CQPERRCODES1_CQP_MINOR_CODE_SHIFT) -#define I40E_VFPE_CQPERRCODES1_CQP_MAJOR_CODE_SHIFT 16 -#define I40E_VFPE_CQPERRCODES1_CQP_MAJOR_CODE_MASK (0xFFFF << I40E_VFPE_CQPERRCODES1_CQP_MAJOR_CODE_SHIFT) -#define I40E_VFPE_CQPTAIL1 0x0000A000 /* Reset: VFR */ -#define I40E_VFPE_CQPTAIL1_WQTAIL_SHIFT 0 -#define I40E_VFPE_CQPTAIL1_WQTAIL_MASK (0x7FF << I40E_VFPE_CQPTAIL1_WQTAIL_SHIFT) -#define I40E_VFPE_CQPTAIL1_CQP_OP_ERR_SHIFT 31 -#define I40E_VFPE_CQPTAIL1_CQP_OP_ERR_MASK (0x1 << I40E_VFPE_CQPTAIL1_CQP_OP_ERR_SHIFT) -#define I40E_VFPE_IPCONFIG01 0x00008C00 /* Reset: VFR */ -#define I40E_VFPE_IPCONFIG01_PEIPID_SHIFT 0 -#define I40E_VFPE_IPCONFIG01_PEIPID_MASK (0xFFFF << I40E_VFPE_IPCONFIG01_PEIPID_SHIFT) -#define I40E_VFPE_IPCONFIG01_USEENTIREIDRANGE_SHIFT 16 -#define I40E_VFPE_IPCONFIG01_USEENTIREIDRANGE_MASK (0x1 << I40E_VFPE_IPCONFIG01_USEENTIREIDRANGE_SHIFT) -#define I40E_VFPE_MRTEIDXMASK1 0x00009000 /* Reset: VFR */ -#define I40E_VFPE_MRTEIDXMASK1_MRTEIDXMASKBITS_SHIFT 0 -#define I40E_VFPE_MRTEIDXMASK1_MRTEIDXMASKBITS_MASK (0x1F << I40E_VFPE_MRTEIDXMASK1_MRTEIDXMASKBITS_SHIFT) -#define I40E_VFPE_RCVUNEXPECTEDERROR1 0x00009400 /* Reset: VFR */ -#define I40E_VFPE_RCVUNEXPECTEDERROR1_TCP_RX_UNEXP_ERR_SHIFT 0 -#define I40E_VFPE_RCVUNEXPECTEDERROR1_TCP_RX_UNEXP_ERR_MASK (0xFFFFFF << I40E_VFPE_RCVUNEXPECTEDERROR1_TCP_RX_UNEXP_ERR_SHIFT) -#define I40E_VFPE_TCPNOWTIMER1 0x0000A800 /* Reset: VFR */ -#define I40E_VFPE_TCPNOWTIMER1_TCP_NOW_SHIFT 0 -#define I40E_VFPE_TCPNOWTIMER1_TCP_NOW_MASK (0xFFFFFFFF << I40E_VFPE_TCPNOWTIMER1_TCP_NOW_SHIFT) -#define I40E_VFPE_WQEALLOC1 0x0000C000 /* Reset: VFR */ -#define I40E_VFPE_WQEALLOC1_PEQPID_SHIFT 0 -#define I40E_VFPE_WQEALLOC1_PEQPID_MASK (0x3FFFF << I40E_VFPE_WQEALLOC1_PEQPID_SHIFT) -#define I40E_VFPE_WQEALLOC1_WQE_DESC_INDEX_SHIFT 20 -#define I40E_VFPE_WQEALLOC1_WQE_DESC_INDEX_MASK (0xFFF << I40E_VFPE_WQEALLOC1_WQE_DESC_INDEX_SHIFT) -#endif /* I40IW_REGISTER_H */ diff --git a/usr/rdma-core/providers/i40iw/i40iw_status.h b/usr/rdma-core/providers/i40iw/i40iw_status.h deleted file mode 100644 index c64ce5466..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_status.h +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#ifndef I40IW_STATUS_H -#define I40IW_STATUS_H - -/* Error Codes */ -enum i40iw_status_code { - I40IW_SUCCESS = 0, - I40IW_ERR_NVM = -1, - I40IW_ERR_NVM_CHECKSUM = -2, - I40IW_ERR_CONFIG = -4, - I40IW_ERR_PARAM = -5, - I40IW_ERR_DEVICE_NOT_SUPPORTED = -6, - I40IW_ERR_RESET_FAILED = -7, - I40IW_ERR_SWFW_SYNC = -8, - I40IW_ERR_NO_MEMORY = -9, - I40IW_ERR_BAD_PTR = -10, - I40IW_ERR_INVALID_PD_ID = -11, - I40IW_ERR_INVALID_QP_ID = -12, - I40IW_ERR_INVALID_CQ_ID = -13, - I40IW_ERR_INVALID_CEQ_ID = -14, - I40IW_ERR_INVALID_AEQ_ID = -15, - I40IW_ERR_INVALID_SIZE = -16, - I40IW_ERR_INVALID_ARP_INDEX = -17, - I40IW_ERR_INVALID_FPM_FUNC_ID = -18, - I40IW_ERR_QP_INVALID_MSG_SIZE = -19, - I40IW_ERR_QP_TOOMANY_WRS_POSTED = -20, - I40IW_ERR_INVALID_FRAG_COUNT = -21, - I40IW_ERR_QUEUE_EMPTY = -22, - I40IW_ERR_INVALID_ALIGNMENT = -23, - I40IW_ERR_FLUSHED_QUEUE = -24, - I40IW_ERR_INVALID_PUSH_PAGE_INDEX = -25, - I40IW_ERR_INVALID_IMM_DATA_SIZE = -26, - I40IW_ERR_TIMEOUT = -27, - I40IW_ERR_OPCODE_MISMATCH = -28, - I40IW_ERR_CQP_COMPL_ERROR = -29, - I40IW_ERR_INVALID_VF_ID = -30, - I40IW_ERR_INVALID_HMCFN_ID = -31, - I40IW_ERR_BACKING_PAGE_ERROR = -32, - I40IW_ERR_NO_PBLCHUNKS_AVAILABLE = -33, - I40IW_ERR_INVALID_PBLE_INDEX = -34, - I40IW_ERR_INVALID_SD_INDEX = -35, - I40IW_ERR_INVALID_PAGE_DESC_INDEX = -36, - I40IW_ERR_INVALID_SD_TYPE = -37, - I40IW_ERR_MEMCPY_FAILED = -38, - I40IW_ERR_INVALID_HMC_OBJ_INDEX = -39, - I40IW_ERR_INVALID_HMC_OBJ_COUNT = -40, - I40IW_ERR_INVALID_SRQ_ARM_LIMIT = -41, - I40IW_ERR_SRQ_ENABLED = -42, - I40IW_ERR_BUF_TOO_SHORT = -43, - I40IW_ERR_BAD_IWARP_CQE = -44, - I40IW_ERR_NVM_BLANK_MODE = -45, - I40IW_ERR_NOT_IMPLEMENTED = -46, - I40IW_ERR_PE_DOORBELL_NOT_ENABLED = -47, - I40IW_ERR_NOT_READY = -48, - I40IW_NOT_SUPPORTED = -49, - I40IW_ERR_FIRMWARE_API_VERSION = -50, - I40IW_ERR_RING_FULL = -51, - I40IW_ERR_MPA_CRC = -61, - I40IW_ERR_NO_TXBUFS = -62, - I40IW_ERR_SEQ_NUM = -63, - I40IW_ERR_LIST_EMPTY = -64, - I40IW_ERR_INVALID_MAC_ADDR = -65, - I40IW_ERR_BAD_STAG = -66, - I40IW_ERR_CQ_COMPL_ERROR = -67, - I40IW_ERR_QUEUE_DESTROYED = -68 - -}; -#endif diff --git a/usr/rdma-core/providers/i40iw/i40iw_uk.c b/usr/rdma-core/providers/i40iw/i40iw_uk.c deleted file mode 100644 index cdc370aed..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_uk.c +++ /dev/null @@ -1,1220 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#include -#include - -#include "i40iw_osdep.h" -#include "i40iw_status.h" -#include "i40iw_d.h" -#include "i40iw_user.h" -#include "i40iw_register.h" - -static u32 nop_signature = 0x55550000; - -/** - * i40iw_nop_1 - insert a nop wqe and move head. no post work - * @qp: hw qp ptr - */ -static enum i40iw_status_code i40iw_nop_1(struct i40iw_qp_uk *qp) -{ - u64 header, *wqe; - u64 *wqe_0 = NULL; - u32 wqe_idx, peek_head; - bool signaled = false; - - if (!qp->sq_ring.head) - return I40IW_ERR_PARAM; - - wqe_idx = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring); - wqe = qp->sq_base[wqe_idx].elem; - - qp->sq_wrtrk_array[wqe_idx].wqe_size = I40IW_QP_WQE_MIN_SIZE; - - peek_head = (qp->sq_ring.head + 1) % qp->sq_ring.size; - wqe_0 = qp->sq_base[peek_head].elem; - if (peek_head) - wqe_0[3] = LS_64(!qp->swqe_polarity, I40IWQPSQ_VALID); - else - wqe_0[3] = LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - set_64bit_val(wqe, I40IW_BYTE_0, 0); - set_64bit_val(wqe, I40IW_BYTE_8, 0); - set_64bit_val(wqe, I40IW_BYTE_16, 0); - - header = LS_64(I40IWQP_OP_NOP, I40IWQPSQ_OPCODE) | - LS_64(signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID) | nop_signature++; - - udma_to_device_barrier(); /* Memory barrier to ensure data is written before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - return 0; -} - -/** - * i40iw_qp_post_wr - post wr to hrdware - * @qp: hw qp ptr - */ -void i40iw_qp_post_wr(struct i40iw_qp_uk *qp) -{ - u64 temp; - u32 hw_sq_tail; - u32 sw_sq_head; - - /* valid bit is written and loads completed before reading shadow - * - * Whatever is happening here does not match our common macros for - * producer/consumer DMA and may not be portable, however on x86-64 - * the required barrier is MFENCE, get a 'portable' version via C11 - * atomic. - */ - atomic_thread_fence(memory_order_seq_cst); - - /* read the doorbell shadow area */ - get_64bit_val(qp->shadow_area, I40IW_BYTE_0, &temp); - - hw_sq_tail = (u32)RS_64(temp, I40IW_QP_DBSA_HW_SQ_TAIL); - sw_sq_head = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring); - if (sw_sq_head != hw_sq_tail) { - if (sw_sq_head > qp->initial_ring.head) { - if ((hw_sq_tail >= qp->initial_ring.head) && - (hw_sq_tail < sw_sq_head)) { - db_wr32(qp->qp_id, qp->wqe_alloc_reg); - } - } else if (sw_sq_head != qp->initial_ring.head) { - if ((hw_sq_tail >= qp->initial_ring.head) || - (hw_sq_tail < sw_sq_head)) { - db_wr32(qp->qp_id, qp->wqe_alloc_reg); - } - } - } - - qp->initial_ring.head = qp->sq_ring.head; -} - -/** - * i40iw_qp_ring_push_db - ring qp doorbell - * @qp: hw qp ptr - * @wqe_idx: wqe index - */ -static void i40iw_qp_ring_push_db(struct i40iw_qp_uk *qp, u32 wqe_idx) -{ - set_32bit_val(qp->push_db, 0, LS_32((wqe_idx >> 2), I40E_PFPE_WQEALLOC_WQE_DESC_INDEX) | qp->qp_id); - qp->initial_ring.head = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring); -} - -/** - * i40iw_qp_get_next_send_wqe - return next wqe ptr - * @qp: hw qp ptr - * @wqe_idx: return wqe index - * @wqe_size: size of sq wqe - */ -u64 *i40iw_qp_get_next_send_wqe(struct i40iw_qp_uk *qp, - u32 *wqe_idx, - u8 wqe_size, - u32 total_size, - u64 wr_id - ) -{ - u64 *wqe = NULL; - u64 wqe_ptr; - u32 peek_head = 0; - u16 offset; - enum i40iw_status_code ret_code = 0; - u8 nop_wqe_cnt = 0, i; - u64 *wqe_0 = NULL; - - *wqe_idx = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring); - - if (!*wqe_idx) - qp->swqe_polarity = !qp->swqe_polarity; - wqe_ptr = (uintptr_t)qp->sq_base[*wqe_idx].elem; - offset = (u16)(wqe_ptr) & 0x7F; - if ((offset + wqe_size) > I40IW_QP_WQE_MAX_SIZE) { - nop_wqe_cnt = (u8)(I40IW_QP_WQE_MAX_SIZE - offset) / I40IW_QP_WQE_MIN_SIZE; - for (i = 0; i < nop_wqe_cnt; i++) { - i40iw_nop_1(qp); - I40IW_RING_MOVE_HEAD(qp->sq_ring, ret_code); - if (ret_code) - return NULL; - } - - *wqe_idx = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring); - if (!*wqe_idx) - qp->swqe_polarity = !qp->swqe_polarity; - } - - if (((*wqe_idx & 3) == 1) && (wqe_size == I40IW_WQE_SIZE_64)) { - i40iw_nop_1(qp); - I40IW_RING_MOVE_HEAD(qp->sq_ring, ret_code); - if (ret_code) - return NULL; - *wqe_idx = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring); - if (!*wqe_idx) - qp->swqe_polarity = !qp->swqe_polarity; - } - - I40IW_RING_MOVE_HEAD_BY_COUNT(qp->sq_ring, - (wqe_size / I40IW_QP_WQE_MIN_SIZE), ret_code); - if (ret_code) - return NULL; - - wqe = qp->sq_base[*wqe_idx].elem; - - peek_head = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring); - wqe_0 = qp->sq_base[peek_head].elem; - - if (((peek_head & 3) == 1) || ((peek_head & 3) == 3)) { - if (RS_64(wqe_0[3], I40IWQPSQ_VALID) != !qp->swqe_polarity) - wqe_0[3] = LS_64(!qp->swqe_polarity, I40IWQPSQ_VALID); - } - - qp->sq_wrtrk_array[*wqe_idx].wrid = wr_id; - qp->sq_wrtrk_array[*wqe_idx].wr_len = total_size; - qp->sq_wrtrk_array[*wqe_idx].wqe_size = wqe_size; - return wqe; -} - -/** - * i40iw_set_fragment - set fragment in wqe - * @wqe: wqe for setting fragment - * @offset: offset value - * @sge: sge length and stag - */ -static void i40iw_set_fragment(u64 *wqe, u32 offset, struct i40iw_sge *sge) -{ - if (sge) { - set_64bit_val(wqe, offset, LS_64(sge->tag_off, I40IWQPSQ_FRAG_TO)); - set_64bit_val(wqe, (offset + I40IW_BYTE_8), - (LS_64(sge->len, I40IWQPSQ_FRAG_LEN) | - LS_64(sge->stag, I40IWQPSQ_FRAG_STAG))); - } -} - -/** - * i40iw_qp_get_next_recv_wqe - get next qp's rcv wqe - * @qp: hw qp ptr - * @wqe_idx: return wqe index - */ -u64 *i40iw_qp_get_next_recv_wqe(struct i40iw_qp_uk *qp, u32 *wqe_idx) -{ - u64 *wqe = NULL; - enum i40iw_status_code ret_code; - - if (I40IW_RING_FULL_ERR(qp->rq_ring)) - return NULL; - - I40IW_ATOMIC_RING_MOVE_HEAD(qp->rq_ring, *wqe_idx, ret_code); - if (ret_code) - return NULL; - if (!*wqe_idx) - qp->rwqe_polarity = !qp->rwqe_polarity; - /* rq_wqe_size_multiplier is no of qwords in one rq wqe */ - wqe = qp->rq_base[*wqe_idx * (qp->rq_wqe_size_multiplier >> 2)].elem; - - return wqe; -} - -/** - * i40iw_rdma_write - rdma write operation - * @qp: hw qp ptr - * @info: post sq information - * @post_sq: flag to post sq - */ -static enum i40iw_status_code i40iw_rdma_write(struct i40iw_qp_uk *qp, - struct i40iw_post_sq_info *info, - bool post_sq) -{ - u64 header; - u64 *wqe; - struct i40iw_rdma_write *op_info; - u32 i, wqe_idx; - u32 total_size = 0, byte_off; - enum i40iw_status_code ret_code; - bool read_fence = false; - u8 wqe_size; - - op_info = &info->op.rdma_write; - if (op_info->num_lo_sges > qp->max_sq_frag_cnt) - return I40IW_ERR_INVALID_FRAG_COUNT; - - for (i = 0; i < op_info->num_lo_sges; i++) - total_size += op_info->lo_sg_list[i].len; - - if (total_size > I40IW_MAX_OUTBOUND_MESSAGE_SIZE) - return I40IW_ERR_QP_INVALID_MSG_SIZE; - - read_fence |= info->read_fence; - - ret_code = i40iw_fragcnt_to_wqesize_sq(op_info->num_lo_sges, &wqe_size); - if (ret_code) - return ret_code; - - wqe = i40iw_qp_get_next_send_wqe(qp, &wqe_idx, wqe_size, - total_size,info->wr_id); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - set_64bit_val(wqe, I40IW_BYTE_16, - LS_64(op_info->rem_addr.tag_off, I40IWQPSQ_FRAG_TO)); - if (!op_info->rem_addr.stag) - return I40IW_ERR_BAD_STAG; - - header = LS_64(op_info->rem_addr.stag, I40IWQPSQ_REMSTAG) | - LS_64(I40IWQP_OP_RDMA_WRITE, I40IWQPSQ_OPCODE) | - LS_64((op_info->num_lo_sges > 1 ? (op_info->num_lo_sges - 1) : 0), I40IWQPSQ_ADDFRAGCNT) | - LS_64(read_fence, I40IWQPSQ_READFENCE) | - LS_64(info->local_fence, I40IWQPSQ_LOCALFENCE) | - LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - - i40iw_set_fragment(wqe, I40IW_BYTE_0, op_info->lo_sg_list); - - for (i = 1, byte_off = I40IW_BYTE_32; i < op_info->num_lo_sges; i++) { - i40iw_set_fragment(wqe, byte_off, &op_info->lo_sg_list[i]); - byte_off += 16; - } - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - - if (post_sq) - i40iw_qp_post_wr(qp); - - return 0; -} - -/** - * i40iw_rdma_read - rdma read command - * @qp: hw qp ptr - * @info: post sq information - * @inv_stag: flag for inv_stag - * @post_sq: flag to post sq - */ -static enum i40iw_status_code i40iw_rdma_read(struct i40iw_qp_uk *qp, - struct i40iw_post_sq_info *info, - bool inv_stag, - bool post_sq) -{ - u64 *wqe; - struct i40iw_rdma_read *op_info; - u64 header; - u32 wqe_idx; - enum i40iw_status_code ret_code; - u8 wqe_size; - bool local_fence = false; - - op_info = &info->op.rdma_read; - ret_code = i40iw_fragcnt_to_wqesize_sq(1, &wqe_size); - if (ret_code) - return ret_code; - wqe = i40iw_qp_get_next_send_wqe(qp, &wqe_idx, wqe_size, - op_info->lo_addr.len,info->wr_id); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - local_fence |= info->local_fence; - - set_64bit_val(wqe, I40IW_BYTE_16, LS_64(op_info->rem_addr.tag_off, I40IWQPSQ_FRAG_TO)); - header = LS_64(op_info->rem_addr.stag, I40IWQPSQ_REMSTAG) | - LS_64((inv_stag ? I40IWQP_OP_RDMA_READ_LOC_INV : I40IWQP_OP_RDMA_READ), I40IWQPSQ_OPCODE) | - LS_64(info->read_fence, I40IWQPSQ_READFENCE) | - LS_64(local_fence, I40IWQPSQ_LOCALFENCE) | - LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - - i40iw_set_fragment(wqe, I40IW_BYTE_0, &op_info->lo_addr); - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - if (post_sq) - i40iw_qp_post_wr(qp); - - return 0; -} - -/** - * i40iw_send - rdma send command - * @qp: hw qp ptr - * @info: post sq information - * @stag_to_inv: stag_to_inv value - * @post_sq: flag to post sq - */ -static enum i40iw_status_code i40iw_send(struct i40iw_qp_uk *qp, - struct i40iw_post_sq_info *info, - u32 stag_to_inv, - bool post_sq) -{ - u64 *wqe; - struct i40iw_post_send *op_info; - u64 header; - u32 i, wqe_idx, total_size = 0, byte_off; - enum i40iw_status_code ret_code; - bool read_fence = false; - u8 wqe_size; - - op_info = &info->op.send; - if (qp->max_sq_frag_cnt < op_info->num_sges) - return I40IW_ERR_INVALID_FRAG_COUNT; - - for (i = 0; i < op_info->num_sges; i++) - total_size += op_info->sg_list[i].len; - ret_code = i40iw_fragcnt_to_wqesize_sq(op_info->num_sges, &wqe_size); - if (ret_code) - return ret_code; - - wqe = i40iw_qp_get_next_send_wqe(qp, &wqe_idx, wqe_size, - total_size,info->wr_id); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - - read_fence |= info->read_fence; - - set_64bit_val(wqe, I40IW_BYTE_16, 0); - header = LS_64(stag_to_inv, I40IWQPSQ_REMSTAG) | - LS_64(info->op_type, I40IWQPSQ_OPCODE) | - LS_64((op_info->num_sges > 1 ? (op_info->num_sges - 1) : 0), - I40IWQPSQ_ADDFRAGCNT) | - LS_64(read_fence, I40IWQPSQ_READFENCE) | - LS_64(info->local_fence, I40IWQPSQ_LOCALFENCE) | - LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - - i40iw_set_fragment(wqe, I40IW_BYTE_0, op_info->sg_list); - - for (i = 1, byte_off = I40IW_BYTE_32; i < op_info->num_sges; i++) { - i40iw_set_fragment(wqe, byte_off, &op_info->sg_list[i]); - byte_off += 16; - } - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - if (post_sq) - i40iw_qp_post_wr(qp); - - return 0; -} - -/** - * i40iw_inline_rdma_write - inline rdma write operation - * @qp: hw qp ptr - * @info: post sq information - * @post_sq: flag to post sq - */ -static enum i40iw_status_code i40iw_inline_rdma_write(struct i40iw_qp_uk *qp, - struct i40iw_post_sq_info *info, - bool post_sq) -{ - u64 *wqe; - u8 *dest, *src; - struct i40iw_inline_rdma_write *op_info; - u64 *push; - u64 header = 0; - u32 wqe_idx; - enum i40iw_status_code ret_code; - bool read_fence = false; - u8 wqe_size; - - op_info = &info->op.inline_rdma_write; - if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE) - return I40IW_ERR_INVALID_IMM_DATA_SIZE; - - ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size); - if (ret_code) - return ret_code; - - wqe = i40iw_qp_get_next_send_wqe(qp, &wqe_idx, wqe_size, - op_info->len,info->wr_id); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - - read_fence |= info->read_fence; - set_64bit_val(wqe, I40IW_BYTE_16, - LS_64(op_info->rem_addr.tag_off, I40IWQPSQ_FRAG_TO)); - - header = LS_64(op_info->rem_addr.stag, I40IWQPSQ_REMSTAG) | - LS_64(I40IWQP_OP_RDMA_WRITE, I40IWQPSQ_OPCODE) | - LS_64(op_info->len, I40IWQPSQ_INLINEDATALEN) | - LS_64(1, I40IWQPSQ_INLINEDATAFLAG) | - LS_64((qp->push_db ? 1 : 0), I40IWQPSQ_PUSHWQE) | - LS_64(read_fence, I40IWQPSQ_READFENCE) | - LS_64(info->local_fence, I40IWQPSQ_LOCALFENCE) | - LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - - dest = (u8 *)wqe; - src = (u8 *)(op_info->data); - - if (op_info->len <= I40IW_BYTE_16) { - memcpy(dest, src, op_info->len); - } else { - memcpy(dest, src, I40IW_BYTE_16); - src += I40IW_BYTE_16; - dest = (u8 *)wqe + I40IW_BYTE_32; - memcpy(dest, src, op_info->len - I40IW_BYTE_16); - } - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - - if (qp->push_db) { - push = (u64 *)((uintptr_t)qp->push_wqe + (wqe_idx & 0x3) * 0x20); - memcpy(push, wqe, (op_info->len > 16) ? op_info->len + 16 : 32); - i40iw_qp_ring_push_db(qp, wqe_idx); - } else { - if (post_sq) - i40iw_qp_post_wr(qp); - } - - return 0; -} - -/** - * i40iw_inline_send - inline send operation - * @qp: hw qp ptr - * @info: post sq information - * @stag_to_inv: remote stag - * @post_sq: flag to post sq - */ -static enum i40iw_status_code i40iw_inline_send(struct i40iw_qp_uk *qp, - struct i40iw_post_sq_info *info, - u32 stag_to_inv, - bool post_sq) -{ - u64 *wqe; - u8 *dest, *src; - struct i40iw_post_inline_send *op_info; - u64 header; - u32 wqe_idx; - enum i40iw_status_code ret_code; - bool read_fence = false; - u8 wqe_size; - u64 *push; - - op_info = &info->op.inline_send; - if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE) - return I40IW_ERR_INVALID_IMM_DATA_SIZE; - - ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size); - if (ret_code) - return ret_code; - - wqe = i40iw_qp_get_next_send_wqe(qp, &wqe_idx, wqe_size, - op_info->len,info->wr_id); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - - read_fence |= info->read_fence; - header = LS_64(stag_to_inv, I40IWQPSQ_REMSTAG) | - LS_64(info->op_type, I40IWQPSQ_OPCODE) | - LS_64(op_info->len, I40IWQPSQ_INLINEDATALEN) | - LS_64(1, I40IWQPSQ_INLINEDATAFLAG) | - LS_64((qp->push_db ? 1 : 0), I40IWQPSQ_PUSHWQE) | - LS_64(read_fence, I40IWQPSQ_READFENCE) | - LS_64(info->local_fence, I40IWQPSQ_LOCALFENCE) | - LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - - dest = (u8 *)wqe; - src = (u8 *)(op_info->data); - - if (op_info->len <= I40IW_BYTE_16) { - memcpy(dest, src, op_info->len); - } else { - memcpy(dest, src, I40IW_BYTE_16); - src += I40IW_BYTE_16; - dest = (u8 *)wqe + I40IW_BYTE_32; - memcpy(dest, src, op_info->len - I40IW_BYTE_16); - } - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - - if (qp->push_db) { - push = (u64 *)((uintptr_t)qp->push_wqe + (wqe_idx & 0x3) * 0x20); - memcpy(push, wqe, (op_info->len > 16) ? op_info->len + 16 : 32); - i40iw_qp_ring_push_db(qp, wqe_idx); - } else { - if (post_sq) - i40iw_qp_post_wr(qp); - } - - return 0; -} - -/** - * i40iw_stag_local_invalidate - stag invalidate operation - * @qp: hw qp ptr - * @info: post sq information - * @post_sq: flag to post sq - */ -static enum i40iw_status_code i40iw_stag_local_invalidate(struct i40iw_qp_uk *qp, - struct i40iw_post_sq_info *info, - bool post_sq) -{ - u64 *wqe; - struct i40iw_inv_local_stag *op_info; - u64 header; - u32 wqe_idx; - bool local_fence = false; - - op_info = &info->op.inv_local_stag; - local_fence = info->local_fence; - - wqe = i40iw_qp_get_next_send_wqe(qp, &wqe_idx, I40IW_QP_WQE_MIN_SIZE, - 0,info->wr_id); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - set_64bit_val(wqe, I40IW_BYTE_0, 0); - set_64bit_val(wqe, I40IW_BYTE_8, - LS_64(op_info->target_stag, I40IWQPSQ_LOCSTAG)); - set_64bit_val(wqe, I40IW_BYTE_16, 0); - header = LS_64(I40IW_OP_TYPE_INV_STAG, I40IWQPSQ_OPCODE) | - LS_64(info->read_fence, I40IWQPSQ_READFENCE) | - LS_64(local_fence, I40IWQPSQ_LOCALFENCE) | - LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - - if (post_sq) - i40iw_qp_post_wr(qp); - - return 0; -} - -/** - * i40iw_mw_bind - Memory Window bind operation - * @qp: hw qp ptr - * @info: post sq information - * @post_sq: flag to post sq - */ -static enum i40iw_status_code i40iw_mw_bind(struct i40iw_qp_uk *qp, - struct i40iw_post_sq_info *info, - bool post_sq) -{ - u64 *wqe; - struct i40iw_bind_window *op_info; - u64 header; - u32 wqe_idx; - bool local_fence = false; - - op_info = &info->op.bind_window; - - local_fence |= info->local_fence; - wqe = i40iw_qp_get_next_send_wqe(qp, &wqe_idx, I40IW_QP_WQE_MIN_SIZE, - 0,info->wr_id); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - set_64bit_val(wqe, I40IW_BYTE_0, (uintptr_t)op_info->va); - set_64bit_val(wqe, I40IW_BYTE_8, - LS_64(op_info->mr_stag, I40IWQPSQ_PARENTMRSTAG) | - LS_64(op_info->mw_stag, I40IWQPSQ_MWSTAG)); - set_64bit_val(wqe, I40IW_BYTE_16, op_info->bind_length); - header = LS_64(I40IW_OP_TYPE_BIND_MW, I40IWQPSQ_OPCODE) | - LS_64(((op_info->enable_reads << 2) | - (op_info->enable_writes << 3)), - I40IWQPSQ_STAGRIGHTS) | - LS_64((op_info->addressing_type == I40IW_ADDR_TYPE_VA_BASED ? 1 : 0), - I40IWQPSQ_VABASEDTO) | - LS_64(info->read_fence, I40IWQPSQ_READFENCE) | - LS_64(local_fence, I40IWQPSQ_LOCALFENCE) | - LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - - if (post_sq) - i40iw_qp_post_wr(qp); - - return 0; -} - -/** - * i40iw_post_receive - post receive wqe - * @qp: hw qp ptr - * @info: post rq information - */ -static enum i40iw_status_code i40iw_post_receive(struct i40iw_qp_uk *qp, - struct i40iw_post_rq_info *info) -{ - u64 *wqe; - u64 header; - u32 total_size = 0, wqe_idx, i, byte_off; - - if (qp->max_rq_frag_cnt < info->num_sges) - return I40IW_ERR_INVALID_FRAG_COUNT; - for (i = 0; i < info->num_sges; i++) - total_size += info->sg_list[i].len; - wqe = i40iw_qp_get_next_recv_wqe(qp, &wqe_idx); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - - qp->rq_wrid_array[wqe_idx] = info->wr_id; - set_64bit_val(wqe, I40IW_BYTE_16, 0); - - header = LS_64((info->num_sges > 1 ? (info->num_sges - 1) : 0), - I40IWQPSQ_ADDFRAGCNT) | - LS_64(qp->rwqe_polarity, I40IWQPSQ_VALID); - - i40iw_set_fragment(wqe, I40IW_BYTE_0, info->sg_list); - - for (i = 1, byte_off = I40IW_BYTE_32; i < info->num_sges; i++) { - i40iw_set_fragment(wqe, byte_off, &info->sg_list[i]); - byte_off += 16; - } - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - - return 0; -} - -/** - * i40iw_cq_request_notification - cq notification request (door bell) - * @cq: hw cq - * @cq_notify: notification type - */ -static void i40iw_cq_request_notification(struct i40iw_cq_uk *cq, - enum i40iw_completion_notify cq_notify) -{ - u64 temp_val; - u16 sw_cq_sel; - u8 arm_next_se = 0; - u8 arm_next = 0; - u8 arm_seq_num; - - get_64bit_val(cq->shadow_area, I40IW_BYTE_32, &temp_val); - arm_seq_num = (u8)RS_64(temp_val, I40IW_CQ_DBSA_ARM_SEQ_NUM); - arm_seq_num++; - - sw_cq_sel = (u16)RS_64(temp_val, I40IW_CQ_DBSA_SW_CQ_SELECT); - arm_next_se = (u8)RS_64(temp_val, I40IW_CQ_DBSA_ARM_NEXT_SE); - arm_next_se |= 1; - if (cq_notify == IW_CQ_COMPL_EVENT) - arm_next = 1; - temp_val = LS_64(arm_seq_num, I40IW_CQ_DBSA_ARM_SEQ_NUM) | - LS_64(sw_cq_sel, I40IW_CQ_DBSA_SW_CQ_SELECT) | - LS_64(arm_next_se, I40IW_CQ_DBSA_ARM_NEXT_SE) | - LS_64(arm_next, I40IW_CQ_DBSA_ARM_NEXT); - - set_64bit_val(cq->shadow_area, I40IW_BYTE_32, temp_val); - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - db_wr32(cq->cq_id, cq->cqe_alloc_reg); -} - -/** - * i40iw_cq_post_entries - update tail in shadow memory - * @cq: hw cq - * @count: # of entries processed - */ -static enum i40iw_status_code i40iw_cq_post_entries(struct i40iw_cq_uk *cq, - u8 count) -{ - I40IW_RING_MOVE_TAIL_BY_COUNT(cq->cq_ring, count); - set_64bit_val(cq->shadow_area, I40IW_BYTE_0, - I40IW_RING_GETCURRENT_HEAD(cq->cq_ring)); - return 0; -} - -/** - * i40iw_cq_poll_completion - get cq completion info - * @cq: hw cq - * @info: cq poll information returned - * @post_cq: update cq tail - */ -static enum i40iw_status_code i40iw_cq_poll_completion(struct i40iw_cq_uk *cq, - struct i40iw_cq_poll_info *info) -{ - u64 comp_ctx, qword0, qword2, qword3, wqe_qword; - u64 *cqe, *sw_wqe; - struct i40iw_qp_uk *qp; - struct i40iw_ring *pring = NULL; - u32 wqe_idx, q_type, array_idx = 0; - enum i40iw_status_code ret_code = 0; - bool move_cq_head = true; - u8 polarity; - u8 addl_wqes = 0; - - if (cq->avoid_mem_cflct) - cqe = (u64 *)I40IW_GET_CURRENT_EXTENDED_CQ_ELEMENT(cq); - else - cqe = (u64 *)I40IW_GET_CURRENT_CQ_ELEMENT(cq); - - get_64bit_val(cqe, I40IW_BYTE_24, &qword3); - polarity = (u8)RS_64(qword3, I40IW_CQ_VALID); - - if (polarity != cq->polarity) - return I40IW_ERR_QUEUE_EMPTY; - - udma_from_device_barrier(); - - q_type = (u8)RS_64(qword3, I40IW_CQ_SQ); - info->error = (bool)RS_64(qword3, I40IW_CQ_ERROR); - info->push_dropped = (bool)RS_64(qword3, I40IWCQ_PSHDROP); - if (info->error) { - info->comp_status = I40IW_COMPL_STATUS_FLUSHED; - info->major_err = (bool)RS_64(qword3, I40IW_CQ_MAJERR); - info->minor_err = (bool)RS_64(qword3, I40IW_CQ_MINERR); - } else { - info->comp_status = I40IW_COMPL_STATUS_SUCCESS; - } - - get_64bit_val(cqe, I40IW_BYTE_0, &qword0); - get_64bit_val(cqe, I40IW_BYTE_16, &qword2); - - info->tcp_seq_num = (u8)RS_64(qword0, I40IWCQ_TCPSEQNUM); - - info->qp_id = (u32)RS_64(qword2, I40IWCQ_QPID); - - get_64bit_val(cqe, I40IW_BYTE_8, &comp_ctx); - - info->solicited_event = (bool)RS_64(qword3, I40IWCQ_SOEVENT); - info->is_srq = (bool)RS_64(qword3, I40IWCQ_SRQ); - - qp = (struct i40iw_qp_uk *)(i40iw_uintptr)comp_ctx; - if (!qp) { - ret_code = I40IW_ERR_QUEUE_DESTROYED; - goto exit; - } - wqe_idx = (u32)RS_64(qword3, I40IW_CQ_WQEIDX); - info->qp_handle = (i40iw_qp_handle)(i40iw_uintptr)qp; - - if (q_type == I40IW_CQE_QTYPE_RQ) { - array_idx = (wqe_idx * 4) / qp->rq_wqe_size_multiplier; - if (info->comp_status == I40IW_COMPL_STATUS_FLUSHED) { - info->wr_id = qp->rq_wrid_array[qp->rq_ring.tail]; - array_idx = qp->rq_ring.tail; - } else { - info->wr_id = qp->rq_wrid_array[array_idx]; - } - - info->op_type = I40IW_OP_TYPE_REC; - if (qword3 & I40IWCQ_STAG_MASK) { - info->stag_invalid_set = true; - info->inv_stag = (u32)RS_64(qword2, I40IWCQ_INVSTAG); - } else { - info->stag_invalid_set = false; - } - info->bytes_xfered = (u32)RS_64(qword0, I40IWCQ_PAYLDLEN); - I40IW_RING_SET_TAIL(qp->rq_ring, array_idx + 1); - pring = &qp->rq_ring; - } else { - - if (info->comp_status != I40IW_COMPL_STATUS_FLUSHED) { - info->wr_id = qp->sq_wrtrk_array[wqe_idx].wrid; - info->bytes_xfered = qp->sq_wrtrk_array[wqe_idx].wr_len; - - info->op_type = (u8)RS_64(qword3, I40IWCQ_OP); - sw_wqe = qp->sq_base[wqe_idx].elem; - get_64bit_val(sw_wqe, I40IW_BYTE_24, &wqe_qword); - addl_wqes = qp->sq_wrtrk_array[wqe_idx].wqe_size/I40IW_QP_WQE_MIN_SIZE; - I40IW_RING_SET_TAIL(qp->sq_ring, (wqe_idx + addl_wqes)); - } else { - do { - u8 op_type; - u32 tail; - - tail = qp->sq_ring.tail; - sw_wqe = qp->sq_base[tail].elem; - get_64bit_val(sw_wqe, I40IW_BYTE_24, &wqe_qword); - op_type = (u8)RS_64(wqe_qword, I40IWQPSQ_OPCODE); - info->op_type = op_type; - addl_wqes = qp->sq_wrtrk_array[tail].wqe_size/I40IW_QP_WQE_MIN_SIZE; - I40IW_RING_SET_TAIL(qp->sq_ring, (tail + addl_wqes)); - if (op_type != I40IWQP_OP_NOP) { - info->wr_id = qp->sq_wrtrk_array[tail].wrid; - info->bytes_xfered = qp->sq_wrtrk_array[tail].wr_len; - break; - } - } while (1); - } - pring = &qp->sq_ring; - } - - ret_code = 0; - -exit: - if (!ret_code && - (info->comp_status == I40IW_COMPL_STATUS_FLUSHED)) - if (pring && (I40IW_RING_MORE_WORK(*pring))) - move_cq_head = false; - - if (move_cq_head) { - I40IW_RING_MOVE_HEAD_NOCHECK(cq->cq_ring); - - if (I40IW_RING_GETCURRENT_HEAD(cq->cq_ring) == 0) - cq->polarity ^= 1; - - I40IW_RING_MOVE_TAIL(cq->cq_ring); - set_64bit_val(cq->shadow_area, I40IW_BYTE_0, - I40IW_RING_GETCURRENT_HEAD(cq->cq_ring)); - } else { - if (info->is_srq) - return ret_code; - qword3 &= ~I40IW_CQ_WQEIDX_MASK; - qword3 |= LS_64(pring->tail, I40IW_CQ_WQEIDX); - set_64bit_val(cqe, I40IW_BYTE_24, qword3); - } - - return ret_code; -} - -/** - * i40iw_get_wqe_shift - get shift count for maximum wqe size - * @wqdepth: depth of wq required. - * @sge: Maximum Scatter Gather Elements wqe - * @inline_data: Maximum inline data size - * @shift: Returns the shift needed based on sge - * - * Shift can be used to left shift the wqe size based on number of SGEs and inlind data size. - * For 1 SGE or inline data <= 16, shift = 0 (wqe size of 32 bytes). - * For 2 or 3 SGEs or inline data <= 48, shift = 1 (wqe size of 64 bytes). - * Shift of 2 otherwise (wqe size of 128 bytes). - */ -enum i40iw_status_code i40iw_get_wqe_shift(u32 wqdepth, u32 sge, u32 inline_data, u8 *shift) -{ - u32 size; - - *shift = 0; - if (sge > 1 || inline_data > 16) - *shift = (sge < 4 && inline_data <= 48) ? 1 : 2; - - /* check if wqdepth is multiple of 2 or not */ - - if ((wqdepth < I40IWQP_SW_MIN_WQSIZE) || (wqdepth & (wqdepth - 1))) - return I40IW_ERR_INVALID_SIZE; - - size = wqdepth << *shift; /* multiple of 32 bytes count */ - if (size > I40IWQP_SW_MAX_WQSIZE) - return I40IW_ERR_INVALID_SIZE; - return 0; -} - -static struct i40iw_qp_uk_ops iw_qp_uk_ops = { - i40iw_qp_post_wr, - i40iw_qp_ring_push_db, - i40iw_rdma_write, - i40iw_rdma_read, - i40iw_send, - i40iw_inline_rdma_write, - i40iw_inline_send, - i40iw_stag_local_invalidate, - i40iw_mw_bind, - i40iw_post_receive, - i40iw_nop -}; - -static struct i40iw_cq_ops iw_cq_ops = { - i40iw_cq_request_notification, - i40iw_cq_poll_completion, - i40iw_cq_post_entries, - i40iw_clean_cq -}; - -static struct i40iw_device_uk_ops iw_device_uk_ops = { - i40iw_cq_uk_init, - i40iw_qp_uk_init, -}; - -/** - * i40iw_qp_uk_init - initialize shared qp - * @qp: hw qp (user and kernel) - * @info: qp initialization info - * - * initializes the vars used in both user and kernel mode. - * size of the wqe depends on numbers of max. fragements - * allowed. Then size of wqe * the number of wqes should be the - * amount of memory allocated for sq and rq. If srq is used, - * then rq_base will point to one rq wqe only (not the whole - * array of wqes) - */ -enum i40iw_status_code i40iw_qp_uk_init(struct i40iw_qp_uk *qp, - struct i40iw_qp_uk_init_info *info) -{ - enum i40iw_status_code ret_code = 0; - u32 sq_ring_size; - u8 sqshift, rqshift; - - if (info->max_sq_frag_cnt > I40IW_MAX_WQ_FRAGMENT_COUNT) - return I40IW_ERR_INVALID_FRAG_COUNT; - - if (info->max_rq_frag_cnt > I40IW_MAX_WQ_FRAGMENT_COUNT) - return I40IW_ERR_INVALID_FRAG_COUNT; - - ret_code = i40iw_get_wqe_shift(info->sq_size, info->max_sq_frag_cnt, info->max_inline_data, &sqshift); - if (ret_code) - return ret_code; - - qp->sq_base = info->sq; - qp->rq_base = info->rq; - qp->shadow_area = info->shadow_area; - qp->sq_wrtrk_array = info->sq_wrtrk_array; - qp->rq_wrid_array = info->rq_wrid_array; - - qp->wqe_alloc_reg = info->wqe_alloc_reg; - qp->qp_id = info->qp_id; - - qp->sq_size = info->sq_size; - qp->push_db = info->push_db; - qp->push_wqe = info->push_wqe; - - qp->max_sq_frag_cnt = info->max_sq_frag_cnt; - sq_ring_size = qp->sq_size << sqshift; - - I40IW_RING_INIT(qp->sq_ring, sq_ring_size); - I40IW_RING_INIT(qp->initial_ring, sq_ring_size); - I40IW_RING_MOVE_HEAD(qp->sq_ring, ret_code); - I40IW_RING_MOVE_TAIL(qp->sq_ring); - I40IW_RING_MOVE_HEAD(qp->initial_ring, ret_code); - qp->swqe_polarity = 1; - qp->swqe_polarity_deferred = 1; - qp->rwqe_polarity = 0; - - if (!qp->use_srq) { - qp->rq_size = info->rq_size; - qp->max_rq_frag_cnt = info->max_rq_frag_cnt; - I40IW_RING_INIT(qp->rq_ring, qp->rq_size); - switch (info->abi_ver) { - case 4: - ret_code = i40iw_get_wqe_shift(info->rq_size, info->max_rq_frag_cnt, 0, &rqshift); - if (ret_code) - return ret_code; - break; - case 5: /* fallthrough until next ABI version */ - default: - rqshift = I40IW_MAX_RQ_WQE_SHIFT; - break; - } - qp->rq_wqe_size = rqshift; - qp->rq_wqe_size_multiplier = 4 << rqshift; - } - qp->ops = iw_qp_uk_ops; - - return ret_code; -} - -/** - * i40iw_cq_uk_init - initialize shared cq (user and kernel) - * @cq: hw cq - * @info: hw cq initialization info - */ -enum i40iw_status_code i40iw_cq_uk_init(struct i40iw_cq_uk *cq, - struct i40iw_cq_uk_init_info *info) -{ - if ((info->cq_size < I40IW_MIN_CQ_SIZE) || - (info->cq_size > I40IW_MAX_CQ_SIZE)) - return I40IW_ERR_INVALID_SIZE; - cq->cq_base = (struct i40iw_cqe *)info->cq_base; - cq->cq_id = info->cq_id; - cq->cq_size = info->cq_size; - cq->cqe_alloc_reg = info->cqe_alloc_reg; - cq->shadow_area = info->shadow_area; - cq->avoid_mem_cflct = info->avoid_mem_cflct; - - I40IW_RING_INIT(cq->cq_ring, cq->cq_size); - cq->polarity = 1; - cq->ops = iw_cq_ops; - - return 0; -} - -/** - * i40iw_device_init_uk - setup routines for iwarp shared device - * @dev: iwarp shared (user and kernel) - */ -void i40iw_device_init_uk(struct i40iw_dev_uk *dev) -{ - dev->ops_uk = iw_device_uk_ops; -} - -/** - * i40iw_clean_cq - clean cq entries - * @ queue completion context - * @cq: cq to clean - */ -void i40iw_clean_cq(void *queue, struct i40iw_cq_uk *cq) -{ - u64 *cqe; - u64 qword3, comp_ctx; - u32 cq_head; - u8 polarity, temp; - - cq_head = cq->cq_ring.head; - temp = cq->polarity; - do { - if (cq->avoid_mem_cflct) - cqe = (u64 *)&(((struct i40iw_extended_cqe *)cq->cq_base)[cq_head]); - else - cqe = (u64 *)&cq->cq_base[cq_head]; - get_64bit_val(cqe, I40IW_BYTE_24, &qword3); - polarity = (u8)RS_64(qword3, I40IW_CQ_VALID); - - if (polarity != temp) - break; - - get_64bit_val(cqe, I40IW_BYTE_8, &comp_ctx); - if ((void *)(i40iw_uintptr)comp_ctx == queue) - set_64bit_val(cqe, I40IW_BYTE_8, 0); - - cq_head = (cq_head + 1) % cq->cq_ring.size; - if (!cq_head) - temp ^= 1; - } while (true); -} - -/** - * i40iw_nop - send a nop - * @qp: hw qp ptr - * @wr_id: work request id - * @signaled: flag if signaled for completion - * @post_sq: flag to post sq - */ -enum i40iw_status_code i40iw_nop(struct i40iw_qp_uk *qp, - u64 wr_id, - bool signaled, - bool post_sq) -{ - u64 header, *wqe; - u32 wqe_idx; - - wqe = i40iw_qp_get_next_send_wqe(qp, &wqe_idx, I40IW_QP_WQE_MIN_SIZE, - 0,wr_id); - if (!wqe) - return I40IW_ERR_QP_TOOMANY_WRS_POSTED; - set_64bit_val(wqe, I40IW_BYTE_0, 0); - set_64bit_val(wqe, I40IW_BYTE_8, 0); - set_64bit_val(wqe, I40IW_BYTE_16, 0); - - header = LS_64(I40IWQP_OP_NOP, I40IWQPSQ_OPCODE) | - LS_64(signaled, I40IWQPSQ_SIGCOMPL) | - LS_64(qp->swqe_polarity, I40IWQPSQ_VALID); - - udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - - set_64bit_val(wqe, I40IW_BYTE_24, header); - if (post_sq) - i40iw_qp_post_wr(qp); - - return 0; -} - -/** - * i40iw_fragcnt_to_wqesize_sq - calculate wqe size based on fragment count for SQ - * @frag_cnt: number of fragments - * @wqe_size: size of sq wqe returned - */ -enum i40iw_status_code i40iw_fragcnt_to_wqesize_sq(u32 frag_cnt, u8 *wqe_size) -{ - switch (frag_cnt) { - case 0: - case 1: - *wqe_size = I40IW_QP_WQE_MIN_SIZE; - break; - case 2: - case 3: - *wqe_size = 64; - break; - case 4: - case 5: - *wqe_size = 96; - break; - case 6: - case 7: - *wqe_size = 128; - break; - default: - return I40IW_ERR_INVALID_FRAG_COUNT; - } - - return 0; -} - -/** - * i40iw_fragcnt_to_wqesize_rq - calculate wqe size based on fragment count for RQ - * @frag_cnt: number of fragments - * @wqe_size: size of rq wqe returned - */ -enum i40iw_status_code i40iw_fragcnt_to_wqesize_rq(u32 frag_cnt, u8 *wqe_size) -{ - switch (frag_cnt) { - case 0: - case 1: - *wqe_size = 32; - break; - case 2: - case 3: - *wqe_size = 64; - break; - case 4: - case 5: - case 6: - case 7: - *wqe_size = 128; - break; - default: - return I40IW_ERR_INVALID_FRAG_COUNT; - } - - return 0; -} - -/** - * i40iw_inline_data_size_to_wqesize - based on inline data, wqe size - * @data_size: data size for inline - * @wqe_size: size of sq wqe returned - */ -enum i40iw_status_code i40iw_inline_data_size_to_wqesize(u32 data_size, - u8 *wqe_size) -{ - if (data_size > I40IW_MAX_INLINE_DATA_SIZE) - return I40IW_ERR_INVALID_IMM_DATA_SIZE; - - if (data_size <= 16) - *wqe_size = I40IW_QP_WQE_MIN_SIZE; - else - *wqe_size = 64; - - return 0; -} diff --git a/usr/rdma-core/providers/i40iw/i40iw_umain.c b/usr/rdma-core/providers/i40iw/i40iw_umain.c deleted file mode 100644 index 61c2a92dd..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_umain.c +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "i40e_devids.h" -#include "i40iw_umain.h" -#include "i40iw-abi.h" - -#include -#include -#include - -#define INTEL_HCA(v, d, t) VERBS_PCI_MATCH(v, d, (void *)(INTEL_##t)) -static const struct verbs_match_ent hca_table[] = { -#ifdef I40E_DEV_ID_X722_A0 - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_X722_A0, i40iw), -#endif -#ifdef I40E_DEV_ID_X722_A0_VF - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_X722_A0_VF, i40iw), -#endif -#ifdef I40E_DEV_ID_KX_X722 - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_KX_X722, i40iw), -#endif -#ifdef I40E_DEV_ID_QSFP_X722 - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_QSFP_X722, i40iw), -#endif -#ifdef I40E_DEV_ID_SFP_X722 - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_SFP_X722, i40iw), -#endif -#ifdef I40E_DEV_ID_1G_BASE_T_X722 - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_1G_BASE_T_X722, i40iw), -#endif -#ifdef I40E_DEV_ID_10G_BASE_T_X722 - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_10G_BASE_T_X722, i40iw), -#endif -#ifdef I40E_DEV_ID_SFP_I_X722 - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_SFP_I_X722, i40iw), -#endif -#ifdef I40E_DEV_ID_X722_VF - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_X722_VF, i40iw), -#endif -#ifdef I40E_DEV_ID_X722_VF_HV - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_X722_VF_HV, i40iw), -#endif -#ifdef I40E_DEV_ID_X722_FPGA - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_X722_FPGA, i40iw), -#endif -#ifdef I40E_DEV_ID_X722_FPGA_VF - INTEL_HCA(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_X722_FPGA_VF, i40iw), -#endif - {} -}; - -static struct ibv_context *i40iw_ualloc_context(struct ibv_device *, int); -static void i40iw_ufree_context(struct ibv_context *); - -static struct ibv_context_ops i40iw_uctx_ops = { - .query_device = i40iw_uquery_device, - .query_port = i40iw_uquery_port, - .alloc_pd = i40iw_ualloc_pd, - .dealloc_pd = i40iw_ufree_pd, - .reg_mr = i40iw_ureg_mr, - .dereg_mr = i40iw_udereg_mr, - .create_cq = i40iw_ucreate_cq, - .poll_cq = i40iw_upoll_cq, - .req_notify_cq = i40iw_uarm_cq, - .cq_event = i40iw_cq_event, - .resize_cq = i40iw_uresize_cq, - .destroy_cq = i40iw_udestroy_cq, - .create_srq = NULL, - .modify_srq = NULL, - .query_srq = NULL, - .destroy_srq = NULL, - .post_srq_recv = NULL, - .create_qp = i40iw_ucreate_qp, - .query_qp = i40iw_uquery_qp, - .modify_qp = i40iw_umodify_qp, - .destroy_qp = i40iw_udestroy_qp, - .post_send = i40iw_upost_send, - .post_recv = i40iw_upost_recv, - .create_ah = i40iw_ucreate_ah, - .destroy_ah = i40iw_udestroy_ah, - .attach_mcast = i40iw_uattach_mcast, - .detach_mcast = i40iw_udetach_mcast, - .async_event = i40iw_async_event -}; - -/** - * i40iw_ualloc_context - allocate context for user app - * @ibdev: pointer to device created during i40iw_driver_init - * @cmd_fd: save fd for the device - * - * Returns callback routines table and calls driver for allocating - * context and getting back resource information to return as ibv_context. - */ - -static struct ibv_context *i40iw_ualloc_context(struct ibv_device *ibdev, int cmd_fd) -{ - struct ibv_pd *ibv_pd; - struct i40iw_uvcontext *iwvctx; - struct i40iw_get_context cmd; - struct i40iw_ualloc_ucontext_resp resp; - - iwvctx = malloc(sizeof(*iwvctx)); - if (!iwvctx) - return NULL; - - memset(iwvctx, 0, sizeof(*iwvctx)); - iwvctx->ibv_ctx.cmd_fd = cmd_fd; - cmd.userspace_ver = I40IW_ABI_VER; - memset(&resp, 0, sizeof(resp)); - if (ibv_cmd_get_context(&iwvctx->ibv_ctx, (struct ibv_get_context *)&cmd, - sizeof(cmd), &resp.ibv_resp, sizeof(resp))) { - - cmd.userspace_ver = 4; - if (ibv_cmd_get_context(&iwvctx->ibv_ctx, (struct ibv_get_context *)&cmd, - sizeof(cmd), &resp.ibv_resp, sizeof(resp))) - goto err_free; - - } - - if (resp.kernel_ver > I40IW_ABI_VER) { - fprintf(stderr, PFX "%s: incompatible kernel driver version: %d. Need version %d\n", - __func__, resp.kernel_ver, I40IW_ABI_VER); - goto err_free; - } - - iwvctx->ibv_ctx.device = ibdev; - iwvctx->ibv_ctx.ops = i40iw_uctx_ops; - iwvctx->max_pds = resp.max_pds; - iwvctx->max_qps = resp.max_qps; - iwvctx->wq_size = resp.wq_size; - iwvctx->abi_ver = resp.kernel_ver; - - i40iw_device_init_uk(&iwvctx->dev); - ibv_pd = i40iw_ualloc_pd(&iwvctx->ibv_ctx); - if (!ibv_pd) - goto err_free; - ibv_pd->context = &iwvctx->ibv_ctx; - iwvctx->iwupd = to_i40iw_upd(ibv_pd); - - return &iwvctx->ibv_ctx; - -err_free: - fprintf(stderr, PFX "%s: failed to allocate context for device.\n", __func__); - free(iwvctx); - - return NULL; -} - -/** - * i40iw_ufree_context - free context that was allocated - * @ibctx: context allocated ptr - */ -static void i40iw_ufree_context(struct ibv_context *ibctx) -{ - struct i40iw_uvcontext *iwvctx = to_i40iw_uctx(ibctx); - - i40iw_ufree_pd(&iwvctx->iwupd->ibv_pd); - - free(iwvctx); -} - -static void i40iw_uninit_device(struct verbs_device *verbs_device) -{ - struct i40iw_udevice *dev = to_i40iw_udev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device * -i40iw_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct i40iw_udevice *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->hca_type = (uintptr_t)sysfs_dev->match->driver_data; - dev->page_size = I40IW_HW_PAGE_SIZE; - return &dev->ibv_dev; -} - -static const struct verbs_device_ops i40iw_udev_ops = { - .name = "i40iw", - .match_min_abi_version = 0, - .match_max_abi_version = INT_MAX, - .match_table = hca_table, - .alloc_device = i40iw_device_alloc, - .uninit_device = i40iw_uninit_device, - .alloc_context = i40iw_ualloc_context, - .free_context = i40iw_ufree_context, -}; -PROVIDER_DRIVER(i40iw_udev_ops); diff --git a/usr/rdma-core/providers/i40iw/i40iw_umain.h b/usr/rdma-core/providers/i40iw/i40iw_umain.h deleted file mode 100644 index bfca09bbc..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_umain.h +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#ifndef I40IW_UMAIN_H -#define I40IW_UMAIN_H - -#include -#include -#include -#include - -#include -#include - -#include "i40iw_osdep.h" -#include "i40iw_d.h" -#include "i40iw_status.h" -#include "i40iw_user.h" - -#define PFX "libi40iw-" - -#define I40IW_BASE_PUSH_PAGE 1 -#define I40IW_U_MINCQ_SIZE 4 - -#define I40IW_WC_WITH_VLAN (1 << 3) -#define I40IW_UD_RX_BATCH_SZ 64 -#define I40IW_UD_MAX_SG_LIST_SZ 1 -#define I40IW_CQ_BUF_OV_ERR 0x3 - -#define MAX_WQ_DEPTH 16384 -#define MIN_WQ_DEPTH 4 - -#define I40E_DB_SHADOW_AREA_SIZE 64 -#define I40E_DB_CQ_OFFSET 0x40 - -enum i40iw_uhca_type { - INTEL_i40iw -}; - -struct i40iw_udevice { - struct verbs_device ibv_dev; - enum i40iw_uhca_type hca_type; - int page_size; -}; - -struct i40iw_upd { - struct ibv_pd ibv_pd; - void volatile *db; - void volatile *arm_cq_page; - void volatile *arm_cq; - uint32_t pd_id; -}; - -struct i40iw_uvcontext { - struct ibv_context ibv_ctx; - struct i40iw_upd *iwupd; - uint32_t max_pds; /* maximum pds allowed for this user process */ - uint32_t max_qps; /* maximum qps allowed for this user process */ - uint32_t wq_size; /* size of the WQs (sq+rq) + shadow allocated to the mmaped area */ - struct i40iw_dev_uk dev; - int abi_ver; -}; - -struct i40iw_uqp; - -struct i40iw_ucq { - struct ibv_cq ibv_cq; - struct ibv_mr mr; - struct ibv_mr mr_shadow_area; - pthread_spinlock_t lock; - uint8_t is_armed; - uint8_t skip_arm; - int arm_sol; - int skip_sol; - int comp_vector; - struct i40iw_uqp *udqp; - struct i40iw_cq_uk cq; -}; - -struct i40iw_uqp { - struct ibv_qp ibv_qp; - struct i40iw_ucq *send_cq; - struct i40iw_ucq *recv_cq; - struct ibv_mr mr; - uint32_t i40iw_drv_opt; - pthread_spinlock_t lock; - u32 *push_db; /* mapped as uncached memory*/ - u64 *push_wqe; /* mapped as write combined memory*/ - uint16_t sq_sig_all; - uint16_t qperr; - uint16_t rsvd; - uint32_t pending_rcvs; - uint32_t wq_size; - struct ibv_recv_wr *pend_rx_wr; - struct i40iw_qp_uk qp; - -}; - -#define to_i40iw_uxxx(xxx, type) \ - ((struct i40iw_u ## type *) \ - ((void *)ib ## xxx - offsetof(struct i40iw_u ## type, ibv_ ## xxx))) - -static inline struct i40iw_udevice *to_i40iw_udev(struct ibv_device *ibdev) -{ - return to_i40iw_uxxx(dev, device); -} - -static inline struct i40iw_uvcontext *to_i40iw_uctx(struct ibv_context *ibctx) -{ - return to_i40iw_uxxx(ctx, vcontext); -} - -static inline struct i40iw_upd *to_i40iw_upd(struct ibv_pd *ibpd) -{ - return to_i40iw_uxxx(pd, pd); -} - -static inline struct i40iw_ucq *to_i40iw_ucq(struct ibv_cq *ibcq) -{ - return to_i40iw_uxxx(cq, cq); -} - -static inline struct i40iw_uqp *to_i40iw_uqp(struct ibv_qp *ibqp) -{ - return to_i40iw_uxxx(qp, qp); -} - -/* i40iw_uverbs.c */ -int i40iw_uquery_device(struct ibv_context *, struct ibv_device_attr *); -int i40iw_uquery_port(struct ibv_context *, uint8_t, struct ibv_port_attr *); -struct ibv_pd *i40iw_ualloc_pd(struct ibv_context *); -int i40iw_ufree_pd(struct ibv_pd *); -struct ibv_mr *i40iw_ureg_mr(struct ibv_pd *, void *, size_t, int); -int i40iw_udereg_mr(struct ibv_mr *); -struct ibv_cq *i40iw_ucreate_cq(struct ibv_context *, int, struct ibv_comp_channel *, int); -int i40iw_uresize_cq(struct ibv_cq *, int); -int i40iw_udestroy_cq(struct ibv_cq *); -int i40iw_upoll_cq(struct ibv_cq *, int, struct ibv_wc *); -int i40iw_uarm_cq(struct ibv_cq *, int); -void i40iw_cq_event(struct ibv_cq *); -struct ibv_srq *i40iw_ucreate_srq(struct ibv_pd *, struct ibv_srq_init_attr *); -int i40iw_umodify_srq(struct ibv_srq *, struct ibv_srq_attr *, int); -int i40iw_udestroy_srq(struct ibv_srq *); -int i40iw_upost_srq_recv(struct ibv_srq *, struct ibv_recv_wr *, struct ibv_recv_wr **); -struct ibv_qp *i40iw_ucreate_qp(struct ibv_pd *, struct ibv_qp_init_attr *); -int i40iw_uquery_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int, struct ibv_qp_init_attr *init_attr); -int i40iw_umodify_qp(struct ibv_qp *, struct ibv_qp_attr *, int); -int i40iw_udestroy_qp(struct ibv_qp *); -int i40iw_upost_send(struct ibv_qp *, struct ibv_send_wr *, struct ibv_send_wr **); -int i40iw_upost_recv(struct ibv_qp *, struct ibv_recv_wr *, struct ibv_recv_wr **); -struct ibv_ah *i40iw_ucreate_ah(struct ibv_pd *, struct ibv_ah_attr *); -int i40iw_udestroy_ah(struct ibv_ah *); -int i40iw_uattach_mcast(struct ibv_qp *, const union ibv_gid *, uint16_t); -int i40iw_udetach_mcast(struct ibv_qp *, const union ibv_gid *, uint16_t); -void i40iw_async_event(struct ibv_async_event *event); - -#endif /* i40iw_umain_H */ diff --git a/usr/rdma-core/providers/i40iw/i40iw_user.h b/usr/rdma-core/providers/i40iw/i40iw_user.h deleted file mode 100644 index 1e95c23ad..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_user.h +++ /dev/null @@ -1,453 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#ifndef I40IW_USER_H -#define I40IW_USER_H - -enum i40iw_device_capabilities_const { - I40IW_WQE_SIZE = 4, - I40IW_CQP_WQE_SIZE = 8, - I40IW_CQE_SIZE = 4, - I40IW_EXTENDED_CQE_SIZE = 8, - I40IW_AEQE_SIZE = 2, - I40IW_CEQE_SIZE = 1, - I40IW_CQP_CTX_SIZE = 8, - I40IW_SHADOW_AREA_SIZE = 8, - I40IW_CEQ_MAX_COUNT = 256, - I40IW_QUERY_FPM_BUF_SIZE = 128, - I40IW_COMMIT_FPM_BUF_SIZE = 128, - I40IW_MIN_IW_QP_ID = 1, - I40IW_MAX_IW_QP_ID = 262143, - I40IW_MIN_CEQID = 0, - I40IW_MAX_CEQID = 256, - I40IW_MIN_CQID = 0, - I40IW_MAX_CQID = 131071, - I40IW_MIN_AEQ_ENTRIES = 1, - I40IW_MAX_AEQ_ENTRIES = 524287, - I40IW_MIN_CEQ_ENTRIES = 1, - I40IW_MAX_CEQ_ENTRIES = 131071, - I40IW_MIN_CQ_SIZE = 1, - I40IW_MAX_CQ_SIZE = 1048575, - I40IW_MAX_AEQ_ALLOCATE_COUNT = 255, - I40IW_DB_ID_ZERO = 0, - I40IW_MAX_WQ_FRAGMENT_COUNT = 3, - I40IW_MAX_SGE_RD = 1, - I40IW_MAX_OUTBOUND_MESSAGE_SIZE = 2147483647, - I40IW_MAX_INBOUND_MESSAGE_SIZE = 2147483647, - I40IW_MAX_PUSH_PAGE_COUNT = 4096, - I40IW_MAX_PE_ENABLED_VF_COUNT = 32, - I40IW_MAX_VF_FPM_ID = 47, - I40IW_MAX_VF_PER_PF = 127, - I40IW_MAX_SQ_PAYLOAD_SIZE = 2145386496, - I40IW_MAX_INLINE_DATA_SIZE = 48, - I40IW_MAX_PUSHMODE_INLINE_DATA_SIZE = 48, - I40IW_MAX_IRD_SIZE = 32, - I40IW_QPCTX_ENCD_MAXIRD = 3, - I40IW_MAX_WQ_ENTRIES = 2048, - I40IW_MAX_ORD_SIZE = 32, - I40IW_Q2_BUFFER_SIZE = (248 + 100), - I40IW_MAX_WQE_SIZE_RQ = 128, - I40IW_QP_CTX_SIZE = 248 -}; - -#define i40iw_handle void * -#define i40iw_adapter_handle i40iw_handle -#define i40iw_qp_handle i40iw_handle -#define i40iw_cq_handle i40iw_handle -#define i40iw_srq_handle i40iw_handle -#define i40iw_pd_id i40iw_handle -#define i40iw_stag_handle i40iw_handle -#define i40iw_stag_index u32 -#define i40iw_stag u32 -#define i40iw_stag_key u8 - -#define i40iw_tagged_offset u64 -#define i40iw_access_privileges u32 -#define i40iw_physical_fragment u64 -#define i40iw_address_list u64 * - -#define I40IW_CREATE_STAG(index, key) (((index) << 8) + (key)) - -#define I40IW_STAG_KEY_FROM_STAG(stag) ((stag) && 0x000000FF) - -#define I40IW_STAG_INDEX_FROM_STAG(stag) (((stag) && 0xFFFFFF00) >> 8) - -#define I40IW_MAX_MR_SIZE 0x10000000000L -#define I40IW_MAX_RQ_WQE_SHIFT 2 - -struct i40iw_qp_uk; -struct i40iw_cq_uk; -struct i40iw_srq_uk; -struct i40iw_qp_uk_init_info; -struct i40iw_cq_uk_init_info; -struct i40iw_srq_uk_init_info; - -struct i40iw_sge { - i40iw_tagged_offset tag_off; - u32 len; - i40iw_stag stag; -}; - -#define i40iw_sgl struct i40iw_sge * - -struct i40iw_ring { - volatile u32 head; - volatile u32 tail; - u32 size; -}; - -struct i40iw_cqe { - u64 buf[I40IW_CQE_SIZE]; -}; - -struct i40iw_extended_cqe { - u64 buf[I40IW_EXTENDED_CQE_SIZE]; -}; - -struct i40iw_wqe { - u64 buf[I40IW_WQE_SIZE]; -}; - -struct i40iw_qp_uk_ops; - -enum i40iw_addressing_type { - I40IW_ADDR_TYPE_ZERO_BASED = 0, - I40IW_ADDR_TYPE_VA_BASED = 1, -}; - -#define I40IW_ACCESS_FLAGS_LOCALREAD 0x01 -#define I40IW_ACCESS_FLAGS_LOCALWRITE 0x02 -#define I40IW_ACCESS_FLAGS_REMOTEREAD_ONLY 0x04 -#define I40IW_ACCESS_FLAGS_REMOTEREAD 0x05 -#define I40IW_ACCESS_FLAGS_REMOTEWRITE_ONLY 0x08 -#define I40IW_ACCESS_FLAGS_REMOTEWRITE 0x0a -#define I40IW_ACCESS_FLAGS_BIND_WINDOW 0x10 -#define I40IW_ACCESS_FLAGS_ALL 0x1F - -#define I40IW_OP_TYPE_RDMA_WRITE 0 -#define I40IW_OP_TYPE_RDMA_READ 1 -#define I40IW_OP_TYPE_SEND 3 -#define I40IW_OP_TYPE_SEND_INV 4 -#define I40IW_OP_TYPE_SEND_SOL 5 -#define I40IW_OP_TYPE_SEND_SOL_INV 6 -#define I40IW_OP_TYPE_REC 7 -#define I40IW_OP_TYPE_BIND_MW 8 -#define I40IW_OP_TYPE_FAST_REG_NSMR 9 -#define I40IW_OP_TYPE_INV_STAG 10 -#define I40IW_OP_TYPE_RDMA_READ_INV_STAG 11 -#define I40IW_OP_TYPE_NOP 12 - -enum i40iw_completion_status { - I40IW_COMPL_STATUS_SUCCESS = 0, - I40IW_COMPL_STATUS_FLUSHED, - I40IW_COMPL_STATUS_INVALID_WQE, - I40IW_COMPL_STATUS_QP_CATASTROPHIC, - I40IW_COMPL_STATUS_REMOTE_TERMINATION, - I40IW_COMPL_STATUS_INVALID_STAG, - I40IW_COMPL_STATUS_BASE_BOUND_VIOLATION, - I40IW_COMPL_STATUS_ACCESS_VIOLATION, - I40IW_COMPL_STATUS_INVALID_PD_ID, - I40IW_COMPL_STATUS_WRAP_ERROR, - I40IW_COMPL_STATUS_STAG_INVALID_PDID, - I40IW_COMPL_STATUS_RDMA_READ_ZERO_ORD, - I40IW_COMPL_STATUS_QP_NOT_PRIVLEDGED, - I40IW_COMPL_STATUS_STAG_NOT_INVALID, - I40IW_COMPL_STATUS_INVALID_PHYS_BUFFER_SIZE, - I40IW_COMPL_STATUS_INVALID_PHYS_BUFFER_ENTRY, - I40IW_COMPL_STATUS_INVALID_FBO, - I40IW_COMPL_STATUS_INVALID_LENGTH, - I40IW_COMPL_STATUS_INVALID_ACCESS, - I40IW_COMPL_STATUS_PHYS_BUFFER_LIST_TOO_LONG, - I40IW_COMPL_STATUS_INVALID_VIRT_ADDRESS, - I40IW_COMPL_STATUS_INVALID_REGION, - I40IW_COMPL_STATUS_INVALID_WINDOW, - I40IW_COMPL_STATUS_INVALID_TOTAL_LENGTH -}; - -enum i40iw_completion_notify { - IW_CQ_COMPL_EVENT = 0, - IW_CQ_COMPL_SOLICITED = 1 -}; - -struct i40iw_post_send { - i40iw_sgl sg_list; - u32 num_sges; -}; - -struct i40iw_post_inline_send { - void *data; - u32 len; -}; - -struct i40iw_post_send_w_inv { - i40iw_sgl sg_list; - u32 num_sges; - i40iw_stag remote_stag_to_inv; -}; - -struct i40iw_post_inline_send_w_inv { - void *data; - u32 len; - i40iw_stag remote_stag_to_inv; -}; - -struct i40iw_rdma_write { - i40iw_sgl lo_sg_list; - u32 num_lo_sges; - struct i40iw_sge rem_addr; -}; - -struct i40iw_inline_rdma_write { - void *data; - u32 len; - struct i40iw_sge rem_addr; -}; - -struct i40iw_rdma_read { - struct i40iw_sge lo_addr; - struct i40iw_sge rem_addr; -}; - -struct i40iw_bind_window { - i40iw_stag mr_stag; - u64 bind_length; - void *va; - enum i40iw_addressing_type addressing_type; - bool enable_reads; - bool enable_writes; - i40iw_stag mw_stag; -}; - -struct i40iw_inv_local_stag { - i40iw_stag target_stag; -}; - -struct i40iw_post_sq_info { - u64 wr_id; - u8 op_type; - bool signaled; - bool read_fence; - bool local_fence; - bool inline_data; - bool defer_flag; - union { - struct i40iw_post_send send; - struct i40iw_post_send send_w_sol; - struct i40iw_post_send_w_inv send_w_inv; - struct i40iw_post_send_w_inv send_w_sol_inv; - struct i40iw_rdma_write rdma_write; - struct i40iw_rdma_read rdma_read; - struct i40iw_rdma_read rdma_read_inv; - struct i40iw_bind_window bind_window; - struct i40iw_inv_local_stag inv_local_stag; - struct i40iw_inline_rdma_write inline_rdma_write; - struct i40iw_post_inline_send inline_send; - struct i40iw_post_inline_send inline_send_w_sol; - struct i40iw_post_inline_send_w_inv inline_send_w_inv; - struct i40iw_post_inline_send_w_inv inline_send_w_sol_inv; - } op; -}; - -struct i40iw_post_rq_info { - u64 wr_id; - i40iw_sgl sg_list; - u32 num_sges; -}; - -struct i40iw_cq_poll_info { - u64 wr_id; - i40iw_qp_handle qp_handle; - u32 bytes_xfered; - u32 tcp_seq_num; - u32 qp_id; - i40iw_stag inv_stag; - enum i40iw_completion_status comp_status; - u16 major_err; - u16 minor_err; - u8 op_type; - bool stag_invalid_set; - bool push_dropped; - bool error; - bool is_srq; - bool solicited_event; -}; - -struct i40iw_qp_uk_ops { - void (*iw_qp_post_wr)(struct i40iw_qp_uk *); - void (*iw_qp_ring_push_db)(struct i40iw_qp_uk *, u32); - enum i40iw_status_code (*iw_rdma_write)(struct i40iw_qp_uk *, - struct i40iw_post_sq_info *, bool); - enum i40iw_status_code (*iw_rdma_read)(struct i40iw_qp_uk *, - struct i40iw_post_sq_info *, bool, bool); - enum i40iw_status_code (*iw_send)(struct i40iw_qp_uk *, - struct i40iw_post_sq_info *, u32, bool); - enum i40iw_status_code (*iw_inline_rdma_write)(struct i40iw_qp_uk *, - struct i40iw_post_sq_info *, bool); - enum i40iw_status_code (*iw_inline_send)(struct i40iw_qp_uk *, - struct i40iw_post_sq_info *, u32, bool); - enum i40iw_status_code (*iw_stag_local_invalidate)(struct i40iw_qp_uk *, - struct i40iw_post_sq_info *, bool); - enum i40iw_status_code (*iw_mw_bind)(struct i40iw_qp_uk *, - struct i40iw_post_sq_info *, bool); - enum i40iw_status_code (*iw_post_receive)(struct i40iw_qp_uk *, - struct i40iw_post_rq_info *); - enum i40iw_status_code (*iw_post_nop)(struct i40iw_qp_uk *, u64, bool, bool); -}; - -struct i40iw_cq_ops { - void (*iw_cq_request_notification)(struct i40iw_cq_uk *, - enum i40iw_completion_notify); - enum i40iw_status_code (*iw_cq_poll_completion)(struct i40iw_cq_uk *, - struct i40iw_cq_poll_info *); - enum i40iw_status_code (*iw_cq_post_entries)(struct i40iw_cq_uk *, u8 count); - void (*iw_cq_clean)(void *, struct i40iw_cq_uk *); -}; - -struct i40iw_dev_uk; - -struct i40iw_device_uk_ops { - enum i40iw_status_code (*iwarp_cq_uk_init)(struct i40iw_cq_uk *, - struct i40iw_cq_uk_init_info *); - enum i40iw_status_code (*iwarp_qp_uk_init)(struct i40iw_qp_uk *, - struct i40iw_qp_uk_init_info *); -}; - -struct i40iw_dev_uk { - struct i40iw_device_uk_ops ops_uk; -}; - -struct i40iw_sq_uk_wr_trk_info { - u64 wrid; - u32 wr_len; - u8 wqe_size; - u8 reserved[3]; -}; - -struct i40iw_qp_quanta { - u64 elem[I40IW_WQE_SIZE]; -}; - -struct i40iw_qp_uk { - struct i40iw_qp_quanta *sq_base; - struct i40iw_qp_quanta *rq_base; - u32 IOMEM *wqe_alloc_reg; - struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array; - u64 *rq_wrid_array; - u64 *shadow_area; - u32 *push_db; - u64 *push_wqe; - struct i40iw_ring sq_ring; - struct i40iw_ring rq_ring; - struct i40iw_ring initial_ring; - u32 qp_id; - u32 sq_size; - u32 rq_size; - u32 max_sq_frag_cnt; - u32 max_rq_frag_cnt; - struct i40iw_qp_uk_ops ops; - bool use_srq; - u8 swqe_polarity; - u8 swqe_polarity_deferred; - u8 rwqe_polarity; - u8 rq_wqe_size; - u8 rq_wqe_size_multiplier; - bool deferred_flag; -}; - -struct i40iw_cq_uk { - struct i40iw_cqe *cq_base; - u32 IOMEM *cqe_alloc_reg; - u64 *shadow_area; - u32 cq_id; - u32 cq_size; - struct i40iw_ring cq_ring; - u8 polarity; - bool avoid_mem_cflct; - - struct i40iw_cq_ops ops; -}; - -struct i40iw_qp_uk_init_info { - struct i40iw_qp_quanta *sq; - struct i40iw_qp_quanta *rq; - u32 IOMEM *wqe_alloc_reg; - u64 *shadow_area; - struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array; - u64 *rq_wrid_array; - u32 *push_db; - u64 *push_wqe; - u32 qp_id; - u32 sq_size; - u32 rq_size; - u32 max_sq_frag_cnt; - u32 max_rq_frag_cnt; - u32 max_inline_data; - int abi_ver; -}; - -struct i40iw_cq_uk_init_info { - u32 IOMEM *cqe_alloc_reg; - struct i40iw_cqe *cq_base; - u64 *shadow_area; - u32 cq_size; - u32 cq_id; - bool avoid_mem_cflct; -}; - -void i40iw_device_init_uk(struct i40iw_dev_uk *dev); - -void i40iw_qp_post_wr(struct i40iw_qp_uk *qp); -u64 *i40iw_qp_get_next_send_wqe(struct i40iw_qp_uk *qp, u32 *wqe_idx, - u8 wqe_size, - u32 total_size, - u64 wr_id - ); - -u64 *i40iw_qp_get_next_recv_wqe(struct i40iw_qp_uk *qp, u32 *wqe_idx); -u64 *i40iw_qp_get_next_srq_wqe(struct i40iw_srq_uk *srq, u32 *wqe_idx); - -enum i40iw_status_code i40iw_cq_uk_init(struct i40iw_cq_uk *cq, - struct i40iw_cq_uk_init_info *info); -enum i40iw_status_code i40iw_qp_uk_init(struct i40iw_qp_uk *qp, - struct i40iw_qp_uk_init_info *info); - -void i40iw_clean_cq(void *queue, struct i40iw_cq_uk *cq); -enum i40iw_status_code i40iw_nop(struct i40iw_qp_uk *qp, u64 wr_id, - bool signaled, bool post_sq); -enum i40iw_status_code i40iw_fragcnt_to_wqesize_sq(u32 frag_cnt, u8 *wqe_size); -enum i40iw_status_code i40iw_fragcnt_to_wqesize_rq(u32 frag_cnt, u8 *wqe_size); -enum i40iw_status_code i40iw_inline_data_size_to_wqesize(u32 data_size, - u8 *wqe_size); -enum i40iw_status_code i40iw_get_wqe_shift(u32 wqdepth, u32 sge, u32 inline_data, u8 *shift); -#endif diff --git a/usr/rdma-core/providers/i40iw/i40iw_uverbs.c b/usr/rdma-core/providers/i40iw/i40iw_uverbs.c deleted file mode 100644 index c21d895fa..000000000 --- a/usr/rdma-core/providers/i40iw/i40iw_uverbs.c +++ /dev/null @@ -1,1055 +0,0 @@ -/******************************************************************************* -* -* Copyright (c) 2015-2016 Intel Corporation. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenFabrics.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -* -*******************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "i40iw_umain.h" -#include "i40iw-abi.h" - -/** - * i40iw_uquery_device - call driver to query device for max resources - * @context: user context for the device - * @attr: where to save all the mx resources from the driver - **/ -int i40iw_uquery_device(struct ibv_context *context, struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t i40iw_fw_ver; - int ret; - unsigned int minor, major; - - ret = ibv_cmd_query_device(context, attr, &i40iw_fw_ver, &cmd, sizeof(cmd)); - if (ret) { - fprintf(stderr, PFX "%s: query device failed and returned status code: %d\n", __func__, ret); - return ret; - } - - major = (i40iw_fw_ver >> 16) & 0xffff; - minor = i40iw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof(attr->fw_ver), "%d.%d", major, minor); - - return 0; -} - -/** - * i40iw_uquery_port - get port attributes (msg size, lnk, mtu...) - * @context: user context of the device - * @port: port for the attributes - * @attr: to return port attributes - **/ -int i40iw_uquery_port(struct ibv_context *context, uint8_t port, struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof(cmd)); -} - -/** - * i40iw_ualloc_pd - allocates protection domain and return pd ptr - * @context: user context of the device - **/ -struct ibv_pd *i40iw_ualloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct i40iw_ualloc_pd_resp resp; - struct i40iw_upd *iwupd; - void *map; - - iwupd = malloc(sizeof(*iwupd)); - if (!iwupd) - return NULL; - memset(&resp, 0, sizeof(resp)); - if (ibv_cmd_alloc_pd(context, &iwupd->ibv_pd, &cmd, sizeof(cmd), &resp.ibv_resp, sizeof(resp))) - goto err_free; - - iwupd->pd_id = resp.pd_id; - map = mmap(NULL, I40IW_HW_PAGE_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, context->cmd_fd, 0); - if (map == MAP_FAILED) { - ibv_cmd_dealloc_pd(&iwupd->ibv_pd); - goto err_free; - } - iwupd->db = map; - - return &iwupd->ibv_pd; - -err_free: - free(iwupd); - return NULL; -} - -/** - * i40iw_ufree_pd - free pd resources - * @pd: pd to free resources - */ -int i40iw_ufree_pd(struct ibv_pd *pd) -{ - int ret; - struct i40iw_upd *iwupd; - - iwupd = to_i40iw_upd(pd); - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - munmap((void *)iwupd->db, I40IW_HW_PAGE_SIZE); - free(iwupd); - - return 0; -} - -/** - * i40iw_ureg_mr - register user memory region - * @pd: pd for the mr - * @addr: user address of the memory region - * @length: length of the memory - * @access: access allowed on this mr - */ -struct ibv_mr *i40iw_ureg_mr(struct ibv_pd *pd, void *addr, size_t length, int access) -{ - struct ibv_mr *mr; - struct i40iw_ureg_mr cmd; - struct ibv_reg_mr_resp resp; - - mr = malloc(sizeof(*mr)); - if (!mr) - return NULL; - - cmd.reg_type = I40IW_UMEMREG_TYPE_MEM; - - if (ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, - access, mr, &cmd.ibv_cmd, sizeof(cmd), - &resp, sizeof(resp))) { - fprintf(stderr, PFX "%s: Failed to register memory\n", __func__); - free(mr); - return NULL; - } - return mr; -} - -/** - * i40iw_udereg_mr - re-register memory region - * @mr: mr that was allocated - */ -int i40iw_udereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - free(mr); - return 0; -} - -/** - * i40iw_num_of_pages - number of pages needed - * @size: size for number of pages - */ -static inline u32 i40iw_num_of_pages(u32 size) -{ - return (size + 4095) >> 12; -} - -/** - * i40iw_ucreate_cq - create completion queue for user app - * @context: user context of the device - * @cqe: number of cq entries in the cq ring - * @channel: channel info (context, refcnt..) - * @comp_vector: save in ucq struct - */ -struct ibv_cq *i40iw_ucreate_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, int comp_vector) -{ - struct i40iw_ucq *iwucq; - struct i40iw_ucreate_cq cmd; - struct i40iw_ucreate_cq_resp resp; - struct i40iw_cq_uk_init_info info; - int ret; - struct i40iw_uvcontext *iwvctx = to_i40iw_uctx(context); - u32 cqe_struct_size; - u32 totalsize; - u32 cq_pages; - - struct i40iw_ureg_mr reg_mr_cmd; - - struct ibv_reg_mr_resp reg_mr_resp; - - if (cqe > I40IW_MAX_CQ_SIZE) - return NULL; - - cqe++; - memset(&cmd, 0, sizeof(cmd)); - memset(&resp, 0, sizeof(resp)); - memset(&info, 0, sizeof(info)); - memset(®_mr_cmd, 0, sizeof(reg_mr_cmd)); - - iwucq = malloc(sizeof(*iwucq)); - if (!iwucq) - return NULL; - memset(iwucq, 0, sizeof(*iwucq)); - - if (pthread_spin_init(&iwucq->lock, PTHREAD_PROCESS_PRIVATE)) { - free(iwucq); - return NULL; - } - if (cqe < I40IW_U_MINCQ_SIZE) - cqe = I40IW_U_MINCQ_SIZE; - - info.cq_size = cqe; - iwucq->comp_vector = comp_vector; - cqe_struct_size = sizeof(struct i40iw_cqe); - cq_pages = i40iw_num_of_pages(info.cq_size * cqe_struct_size); - totalsize = (cq_pages << 12) + I40E_DB_SHADOW_AREA_SIZE; - - info.cq_base = memalign(I40IW_HW_PAGE_SIZE, totalsize); - - if (!info.cq_base) - goto err; - - memset(info.cq_base, 0, totalsize); - info.shadow_area = (u64 *)((u8 *)info.cq_base + (cq_pages << 12)); - reg_mr_cmd.reg_type = I40IW_UMEMREG_TYPE_CQ; - - reg_mr_cmd.cq_pages = cq_pages; - - ret = ibv_cmd_reg_mr(&iwvctx->iwupd->ibv_pd, (void *)info.cq_base, totalsize, - (uintptr_t)info.cq_base, IBV_ACCESS_LOCAL_WRITE, - &iwucq->mr, ®_mr_cmd.ibv_cmd, sizeof(reg_mr_cmd), ®_mr_resp, - sizeof(reg_mr_resp)); - if (ret) { - fprintf(stderr, PFX "%s: failed to pin memory for CQ\n", __func__); - goto err; - } - - cmd.user_cq_buffer = (__u64)((uintptr_t)info.cq_base); - ret = ibv_cmd_create_cq(context, info.cq_size, channel, comp_vector, - &iwucq->ibv_cq, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (ret) { - ibv_cmd_dereg_mr(&iwucq->mr); - fprintf(stderr, PFX "%s: failed to create CQ\n", __func__); - goto err; - } - - info.cq_id = (uint16_t)resp.cq_id; - info.shadow_area = (u64 *)((u8 *)info.shadow_area + resp.reserved); - - info.cqe_alloc_reg = (u32 *)((u8 *)iwvctx->iwupd->db + I40E_DB_CQ_OFFSET); - ret = iwvctx->dev.ops_uk.iwarp_cq_uk_init(&iwucq->cq, &info); - if (!ret) - return &iwucq->ibv_cq; - else - fprintf(stderr, PFX "%s: failed to initialize CQ, status %d\n", __func__, ret); -err: - if (info.cq_base) - free(info.cq_base); - if (pthread_spin_destroy(&iwucq->lock)) - return NULL; - free(iwucq); - return NULL; -} - -/** - * i40iw_udestroy_cq - destroys cq - * @cq: ptr to cq to be destroyed - */ -int i40iw_udestroy_cq(struct ibv_cq *cq) -{ - struct i40iw_ucq *iwucq = to_i40iw_ucq(cq); - int ret; - - ret = pthread_spin_destroy(&iwucq->lock); - if (ret) - return ret; - - ret = ibv_cmd_destroy_cq(cq); - if (ret) - return ret; - - ibv_cmd_dereg_mr(&iwucq->mr); - - free(iwucq->cq.cq_base); - free(iwucq); - - return 0; -} - -/** - * i40iw_upoll_cq - user app to poll cq - * @cq: cq to poll - * @num_entries: max cq entries to poll - * @entry: for each completion complete entry - */ -int i40iw_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) -{ - struct i40iw_ucq *iwucq; - int cqe_count = 0; - struct i40iw_cq_poll_info cq_poll_info; - int ret; - - iwucq = to_i40iw_ucq(cq); - - ret = pthread_spin_lock(&iwucq->lock); - if (ret) - return ret; - while (cqe_count < num_entries) { - ret = iwucq->cq.ops.iw_cq_poll_completion(&iwucq->cq, &cq_poll_info); - if (ret == I40IW_ERR_QUEUE_EMPTY) { - break; - } else if (ret) { - fprintf(stderr, PFX "%s: Error polling CQ, status %d\n", __func__, ret); - if (!cqe_count) - /* Indicate error */ - cqe_count = -1; - break; - } - entry->wc_flags = 0; - entry->wr_id = cq_poll_info.wr_id; - - if (cq_poll_info.error) { - entry->status = IBV_WC_WR_FLUSH_ERR; - entry->vendor_err = cq_poll_info.major_err << 16 | cq_poll_info.minor_err; - } else { - entry->status = IBV_WC_SUCCESS; - } - - switch (cq_poll_info.op_type) { - case I40IW_OP_TYPE_RDMA_WRITE: - entry->opcode = IBV_WC_RDMA_WRITE; - break; - case I40IW_OP_TYPE_RDMA_READ_INV_STAG: - case I40IW_OP_TYPE_RDMA_READ: - entry->opcode = IBV_WC_RDMA_READ; - break; - case I40IW_OP_TYPE_SEND_SOL: - case I40IW_OP_TYPE_SEND_SOL_INV: - case I40IW_OP_TYPE_SEND_INV: - case I40IW_OP_TYPE_SEND: - entry->opcode = IBV_WC_SEND; - break; - case I40IW_OP_TYPE_REC: - entry->opcode = IBV_WC_RECV; - break; - default: - entry->opcode = IBV_WC_RECV; - break; - } - - entry->imm_data = 0; - entry->qp_num = cq_poll_info.qp_id; - entry->src_qp = cq_poll_info.qp_id; - entry->byte_len = cq_poll_info.bytes_xfered; - entry++; - cqe_count++; - } - pthread_spin_unlock(&iwucq->lock); - return cqe_count; -} - -/** - * i40iw_arm_cq - arm of cq - * @iwucq: cq to which arm - * @cq_notify: notification params - */ -static void i40iw_arm_cq(struct i40iw_ucq *iwucq, enum i40iw_completion_notify cq_notify) -{ - iwucq->is_armed = 1; - iwucq->arm_sol = 1; - iwucq->skip_arm = 0; - iwucq->skip_sol = 1; - - iwucq->cq.ops.iw_cq_request_notification(&iwucq->cq, cq_notify); -} - -/** - * i40iw_uarm_cq - callback for arm of cq - * @cq: cq to arm - * @solicited: to get notify params - */ -int i40iw_uarm_cq(struct ibv_cq *cq, int solicited) -{ - struct i40iw_ucq *iwucq; - enum i40iw_completion_notify cq_notify = IW_CQ_COMPL_EVENT; - int ret; - - iwucq = to_i40iw_ucq(cq); - if (solicited) - cq_notify = IW_CQ_COMPL_SOLICITED; - - ret = pthread_spin_lock(&iwucq->lock); - if (ret) - return ret; - - if (iwucq->is_armed) { - if ((iwucq->arm_sol) && (!solicited)) { - i40iw_arm_cq(iwucq, cq_notify); - } else { - iwucq->skip_arm = 1; - iwucq->skip_sol &= solicited; - } - } else { - i40iw_arm_cq(iwucq, cq_notify); - } - - pthread_spin_unlock(&iwucq->lock); - - return 0; -} - -/** - * i40iw_cq_event - cq to do completion event - * @cq: cq to arm - */ -void i40iw_cq_event(struct ibv_cq *cq) -{ - struct i40iw_ucq *iwucq; - - iwucq = to_i40iw_ucq(cq); - if (pthread_spin_lock(&iwucq->lock)) - return; - - if (iwucq->skip_arm) - i40iw_arm_cq(iwucq, IW_CQ_COMPL_EVENT); - else - iwucq->is_armed = 0; - - pthread_spin_unlock(&iwucq->lock); -} - -static int i40iw_destroy_vmapped_qp(struct i40iw_uqp *iwuqp, - struct i40iw_qp_quanta *sq_base) -{ - int ret; - - ret = ibv_cmd_destroy_qp(&iwuqp->ibv_qp); - if (ret) - return ret; - - if (iwuqp->push_db) - munmap(iwuqp->push_db, I40IW_HW_PAGE_SIZE); - if (iwuqp->push_wqe) - munmap(iwuqp->push_wqe, I40IW_HW_PAGE_SIZE); - - ibv_cmd_dereg_mr(&iwuqp->mr); - free((void *)sq_base); - - return 0; -} - -/** - * i40iw_vmapped_qp - create resources for qp - * @iwuqp: qp struct for resources - * @pd: pd for thes qp - * @attr: atributes of qp passed - * @resp: response back from create qp - * @sqdepth: depth of sq - * @rqdepth: depth of rq - * @info: info for initializing user level qp - */ -static int i40iw_vmapped_qp(struct i40iw_uqp *iwuqp, struct ibv_pd *pd, - struct ibv_qp_init_attr *attr, - struct i40iw_ucreate_qp_resp *resp, int sqdepth, - int rqdepth, struct i40iw_qp_uk_init_info *info) -{ - struct i40iw_ucreate_qp cmd; - int sqsize, rqsize, totalqpsize; - int ret; - struct i40iw_ureg_mr reg_mr_cmd; - u32 sq_pages, rq_pages; - struct ibv_reg_mr_resp reg_mr_resp; - - memset(®_mr_cmd, 0, sizeof(reg_mr_cmd)); - sqsize = sqdepth * I40IW_QP_WQE_MIN_SIZE; - rqsize = rqdepth * I40IW_QP_WQE_MIN_SIZE; - - sq_pages = i40iw_num_of_pages(sqsize); - rq_pages = i40iw_num_of_pages(rqsize); - sqsize = sq_pages << 12; - rqsize = rq_pages << 12; - totalqpsize = rqsize + sqsize + I40E_DB_SHADOW_AREA_SIZE; - info->sq = memalign(I40IW_HW_PAGE_SIZE, totalqpsize); - - if (!info->sq) { - fprintf(stderr, PFX "%s: failed to allocate memory for SQ\n", __func__); - return 0; - } - - memset(info->sq, 0, totalqpsize); - info->rq = &info->sq[sqsize / I40IW_QP_WQE_MIN_SIZE]; - info->shadow_area = info->rq[rqsize / I40IW_QP_WQE_MIN_SIZE].elem; - - reg_mr_cmd.reg_type = I40IW_UMEMREG_TYPE_QP; - reg_mr_cmd.sq_pages = sq_pages; - reg_mr_cmd.rq_pages = rq_pages; - - ret = ibv_cmd_reg_mr(pd, (void *)info->sq, totalqpsize, (uintptr_t)info->sq, - IBV_ACCESS_LOCAL_WRITE, &iwuqp->mr, ®_mr_cmd.ibv_cmd, - sizeof(reg_mr_cmd), ®_mr_resp, sizeof(reg_mr_resp)); - if (ret) { - fprintf(stderr, PFX "%s: failed to pin memory for SQ\n", __func__); - free(info->sq); - return 0; - } - cmd.user_wqe_buffers = (__u64)((uintptr_t)info->sq); - cmd.user_compl_ctx = (uintptr_t)&iwuqp->qp; - - ret = ibv_cmd_create_qp(pd, &iwuqp->ibv_qp, attr, &cmd.ibv_cmd, sizeof(cmd), - &resp->ibv_resp, sizeof(struct i40iw_ucreate_qp_resp)); - if (ret) { - fprintf(stderr, PFX "%s: failed to create QP, status %d\n", __func__, ret); - ibv_cmd_dereg_mr(&iwuqp->mr); - free(info->sq); - return 0; - } - - iwuqp->send_cq = to_i40iw_ucq(attr->send_cq); - iwuqp->recv_cq = to_i40iw_ucq(attr->recv_cq); - info->sq_size = resp->actual_sq_size; - info->rq_size = resp->actual_rq_size; - - if (resp->push_idx != I40IW_INVALID_PUSH_PAGE_INDEX) { - void *map; - u64 offset; - - offset = (resp->push_idx + I40IW_BASE_PUSH_PAGE) * I40IW_HW_PAGE_SIZE; - - map = mmap(NULL, I40IW_HW_PAGE_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, - pd->context->cmd_fd, offset); - if (map == MAP_FAILED) { - fprintf(stderr, PFX "%s: failed to map push page, errno %d\n", __func__, errno); - info->push_wqe = NULL; - info->push_db = NULL; - } else { - info->push_wqe = map; - - offset += I40IW_HW_PAGE_SIZE; - map = mmap(NULL, I40IW_HW_PAGE_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, - pd->context->cmd_fd, offset); - if (map == MAP_FAILED) { - fprintf(stderr, PFX "%s: failed to map push doorbell, errno %d\n", __func__, errno); - munmap(info->push_wqe, I40IW_HW_PAGE_SIZE); - info->push_wqe = NULL; - info->push_db = NULL; - } else { - info->push_db = map; - } - iwuqp->push_db = info->push_db; - iwuqp->push_wqe = info->push_wqe; - } - } - return 1; -} - -/** - * i40iw_qp_round_up - round up rq and sq ring sizes - * @wr_ring_size: size of the ring - */ -static int i40iw_qp_round_up(u32 wr_ring_size) -{ - int scount = 1; - - if (wr_ring_size <= MIN_WQ_DEPTH) - wr_ring_size = MIN_WQ_DEPTH; - - for (wr_ring_size--; scount <= 16; scount *= 2) - wr_ring_size |= wr_ring_size >> scount; - return ++wr_ring_size; -} - -/* - * i40iw_qp_get_qdepth of the ring depending of sge and qdepth - * @qdepth: queue depth - * @sge: max number of SGEs - * @inline_data: max QP inline data size - * - * returns depth of the ring - */ -static int i40iw_qp_get_qdepth(uint32_t qdepth, u32 sge, u32 inline_data) -{ - u8 shift = 0; - - if (i40iw_get_wqe_shift(qdepth, sge, inline_data, &shift)) - return 0; - - return (qdepth << shift); -} - -/** - * i40iw_ucreate_qp - create qp on user app - * @pd: pd for the qp - * @attr: attributes of the qp to be created (sizes, sge, cq) - */ -struct ibv_qp *i40iw_ucreate_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) -{ - struct i40iw_ucreate_qp_resp resp; - struct i40iw_uvcontext *iwvctx = to_i40iw_uctx(pd->context); - struct i40iw_uqp *iwuqp; - int sqdepth, rqdepth; - int status = 1; - struct i40iw_qp_uk_init_info info; - int sq_attr, rq_attr; - - if (attr->qp_type != IBV_QPT_RC) { - fprintf(stderr, PFX "%s: failed to create QP, unsupported QP type: 0x%x\n", __func__, attr->qp_type); - return NULL; - } - - if (attr->cap.max_send_sge > I40IW_MAX_WQ_FRAGMENT_COUNT) - attr->cap.max_send_sge = I40IW_MAX_WQ_FRAGMENT_COUNT; - - if (attr->cap.max_recv_sge > I40IW_MAX_WQ_FRAGMENT_COUNT) - attr->cap.max_recv_sge = I40IW_MAX_WQ_FRAGMENT_COUNT; - - if (attr->cap.max_inline_data > I40IW_MAX_INLINE_DATA_SIZE) - attr->cap.max_inline_data = I40IW_MAX_INLINE_DATA_SIZE; - - sq_attr = i40iw_qp_round_up(attr->cap.max_send_wr + 1); - rq_attr = i40iw_qp_round_up(attr->cap.max_recv_wr + 1); - - /* Sanity check QP size before proceeding */ - sqdepth = i40iw_qp_get_qdepth(sq_attr, attr->cap.max_send_sge, attr->cap.max_inline_data); - if (!sqdepth) { - fprintf(stderr, PFX "%s: invalid SQ attributes, max_send_wr=%d max_send_sge=%d\n", - __func__, attr->cap.max_send_wr, attr->cap.max_send_sge); - return NULL; - } - - switch (iwvctx->abi_ver) { - case 4: - rqdepth = i40iw_qp_get_qdepth(rq_attr, attr->cap.max_recv_sge, 0); - if (!rqdepth) { - fprintf(stderr, PFX "%s: invalid RQ attributes, max_recv_wr=%d max_recv_sge=%d\n", - __func__, attr->cap.max_recv_wr, attr->cap.max_recv_sge); - return NULL; - } - break; - case 5: /* fallthrough until next ABI version */ - default: - rqdepth = rq_attr << I40IW_MAX_RQ_WQE_SHIFT; - break; - } - - iwuqp = memalign(1024, sizeof(*iwuqp)); - if (!iwuqp) - return NULL; - memset(iwuqp, 0, sizeof(*iwuqp)); - - if (pthread_spin_init(&iwuqp->lock, PTHREAD_PROCESS_PRIVATE)) - goto err_free_qp; - - memset(&info, 0, sizeof(info)); - - info.sq_size = sq_attr; - info.rq_size = rq_attr; - attr->cap.max_send_wr = sq_attr; - attr->cap.max_recv_wr = rq_attr; - - info.max_sq_frag_cnt = attr->cap.max_send_sge; - info.max_rq_frag_cnt = attr->cap.max_recv_sge; - - info.wqe_alloc_reg = (u32 *)iwvctx->iwupd->db; - info.sq_wrtrk_array = calloc(sqdepth, sizeof(*info.sq_wrtrk_array)); - info.abi_ver = iwvctx->abi_ver; - - if (!info.sq_wrtrk_array) { - fprintf(stderr, PFX "%s: failed to allocate memory for SQ work array\n", __func__); - goto err_destroy_lock; - } - - info.rq_wrid_array = calloc(rqdepth, sizeof(*info.rq_wrid_array)); - if (!info.rq_wrid_array) { - fprintf(stderr, PFX "%s: failed to allocate memory for RQ work array\n", __func__); - goto err_free_sq_wrtrk; - } - - iwuqp->sq_sig_all = attr->sq_sig_all; - memset(&resp, 0, sizeof(resp)); - status = i40iw_vmapped_qp(iwuqp, pd, attr, &resp, sqdepth, rqdepth, &info); - - if (!status) { - fprintf(stderr, PFX "%s: failed to map QP\n", __func__); - goto err_free_rq_wrid; - } - info.qp_id = resp.qp_id; - iwuqp->i40iw_drv_opt = resp.i40iw_drv_opt; - iwuqp->ibv_qp.qp_num = resp.qp_id; - - info.max_sq_frag_cnt = attr->cap.max_send_sge; - info.max_rq_frag_cnt = attr->cap.max_recv_sge; - info.max_inline_data = attr->cap.max_inline_data; - - status = iwvctx->dev.ops_uk.iwarp_qp_uk_init(&iwuqp->qp, &info); - if (!status) - return &iwuqp->ibv_qp; - - i40iw_destroy_vmapped_qp(iwuqp, info.sq); -err_free_rq_wrid: - free(info.rq_wrid_array); -err_free_sq_wrtrk: - free(info.sq_wrtrk_array); -err_destroy_lock: - pthread_spin_destroy(&iwuqp->lock); -err_free_qp: - free(iwuqp); - return NULL; -} - -/** - * i40iw_uquery_qp - query qp for some attribute - * @qp: qp for the attributes query - * @attr: to return the attributes - * @attr_mask: mask of what is query for - * @init_attr: initial attributes during create_qp - */ -int i40iw_uquery_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask, - struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - - return ibv_cmd_query_qp(qp, attr, attr_mask, init_attr, &cmd, sizeof(cmd)); -} - -/** - * i40iw_umodify_qp - send qp modify to driver - * @qp: qp to modify - * @attr: attribute to modify - * @attr_mask: mask of the attribute - */ -int i40iw_umodify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - - return ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof(cmd)); -} - -/** - * i40iw_udestroy_qp - destroy qp - * @qp: qp to destroy - */ -int i40iw_udestroy_qp(struct ibv_qp *qp) -{ - struct i40iw_uqp *iwuqp = to_i40iw_uqp(qp); - int ret; - - ret = pthread_spin_destroy(&iwuqp->lock); - if (ret) - return ret; - - ret = i40iw_destroy_vmapped_qp(iwuqp, iwuqp->qp.sq_base); - if (ret) - return ret; - - if (iwuqp->qp.sq_wrtrk_array) - free(iwuqp->qp.sq_wrtrk_array); - if (iwuqp->qp.rq_wrid_array) - free(iwuqp->qp.rq_wrid_array); - /* Clean any pending completions from the cq(s) */ - if (iwuqp->send_cq) - i40iw_clean_cq((void *)&iwuqp->qp, &iwuqp->send_cq->cq); - - if ((iwuqp->recv_cq) && (iwuqp->recv_cq != iwuqp->send_cq)) - i40iw_clean_cq((void *)&iwuqp->qp, &iwuqp->recv_cq->cq); - - free(iwuqp); - - return 0; -} - -/** - * i40iw_copy_sg_list - copy sg list for qp - * @sg_list: copied into sg_list - * @sgl: copy from sgl - * @num_sges: count of sg entries - */ -static void i40iw_copy_sg_list(struct i40iw_sge *sg_list, struct ibv_sge *sgl, - int num_sges) -{ - unsigned int i; - - for (i = 0; (i < num_sges) && (i < I40IW_MAX_WQ_FRAGMENT_COUNT); i++) { - sg_list[i].tag_off = sgl[i].addr; - sg_list[i].len = sgl[i].length; - sg_list[i].stag = sgl[i].lkey; - } -} - -/** - * i40iw_post_send - post send wr for user application - * @ib_qp: qp ptr for wr - * @ib_wr: work request ptr - * @bad_wr: return of bad wr if err - */ -int i40iw_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, struct ibv_send_wr **bad_wr) -{ - struct i40iw_uqp *iwuqp; - struct i40iw_post_sq_info info; - enum i40iw_status_code ret = 0; - int err = 0; - - iwuqp = (struct i40iw_uqp *)ib_qp; - - err = pthread_spin_lock(&iwuqp->lock); - if (err) - return err; - while (ib_wr) { - memset(&info, 0, sizeof(info)); - info.wr_id = (u64)(ib_wr->wr_id); - if ((ib_wr->send_flags & IBV_SEND_SIGNALED) || iwuqp->sq_sig_all) - info.signaled = true; - if (ib_wr->send_flags & IBV_SEND_FENCE) - info.read_fence = true; - - switch (ib_wr->opcode) { - case IBV_WR_SEND: - if (ib_wr->send_flags & IBV_SEND_SOLICITED) - info.op_type = I40IW_OP_TYPE_SEND_SOL; - else - info.op_type = I40IW_OP_TYPE_SEND; - - if (ib_wr->send_flags & IBV_SEND_INLINE) { - info.op.inline_send.data = (void *)(uintptr_t)ib_wr->sg_list[0].addr; - info.op.inline_send.len = ib_wr->sg_list[0].length; - ret = iwuqp->qp.ops.iw_inline_send(&iwuqp->qp, &info, - ib_wr->wr.rdma.rkey, false); - } else { - info.op.send.num_sges = ib_wr->num_sge; - info.op.send.sg_list = (struct i40iw_sge *)ib_wr->sg_list; - ret = iwuqp->qp.ops.iw_send(&iwuqp->qp, &info, - ib_wr->wr.rdma.rkey, false); - } - - if (ret) { - if (ret == I40IW_ERR_QP_TOOMANY_WRS_POSTED) - err = -ENOMEM; - else - err = -EINVAL; - } - break; - - case IBV_WR_RDMA_WRITE: - info.op_type = I40IW_OP_TYPE_RDMA_WRITE; - - if (ib_wr->send_flags & IBV_SEND_INLINE) { - info.op.inline_rdma_write.data = (void *)(uintptr_t)ib_wr->sg_list[0].addr; - info.op.inline_rdma_write.len = ib_wr->sg_list[0].length; - info.op.inline_rdma_write.rem_addr.tag_off = ib_wr->wr.rdma.remote_addr; - info.op.inline_rdma_write.rem_addr.len = ib_wr->sg_list->length; - info.op.inline_rdma_write.rem_addr.stag = ib_wr->wr.rdma.rkey; - ret = iwuqp->qp.ops.iw_inline_rdma_write(&iwuqp->qp, &info, false); - } else { - info.op.rdma_write.lo_sg_list = (void *)ib_wr->sg_list; - info.op.rdma_write.num_lo_sges = ib_wr->num_sge; - info.op.rdma_write.rem_addr.tag_off = ib_wr->wr.rdma.remote_addr; - info.op.rdma_write.rem_addr.len = ib_wr->sg_list->length; - info.op.rdma_write.rem_addr.stag = ib_wr->wr.rdma.rkey; - ret = iwuqp->qp.ops.iw_rdma_write(&iwuqp->qp, &info, false); - } - - if (ret) { - if (ret == I40IW_ERR_QP_TOOMANY_WRS_POSTED) - err = -ENOMEM; - else - err = -EINVAL; - } - break; - - case IBV_WR_RDMA_READ: - if (ib_wr->num_sge > I40IW_MAX_SGE_RD) { - err = -EINVAL; - break; - } - info.op_type = I40IW_OP_TYPE_RDMA_READ; - info.op.rdma_read.rem_addr.tag_off = ib_wr->wr.rdma.remote_addr; - info.op.rdma_read.rem_addr.stag = ib_wr->wr.rdma.rkey; - info.op.rdma_read.rem_addr.len = ib_wr->sg_list->length; - info.op.rdma_read.lo_addr.tag_off = ib_wr->sg_list->addr; - info.op.rdma_read.lo_addr.stag = ib_wr->sg_list->lkey; - info.op.rdma_read.lo_addr.len = ib_wr->sg_list->length; - ret = iwuqp->qp.ops.iw_rdma_read(&iwuqp->qp, &info, false, false); - if (ret) { - if (ret == I40IW_ERR_QP_TOOMANY_WRS_POSTED) - err = -ENOMEM; - else - err = -EINVAL; - } - break; - - default: - /* error */ - err = -EINVAL; - fprintf(stderr, PFX "%s: post work request failed, invalid opcode: 0x%x\n", __func__, ib_wr->opcode); - break; - } - - if (err) - break; - - ib_wr = ib_wr->next; - } - - if (err) - *bad_wr = ib_wr; - else - iwuqp->qp.ops.iw_qp_post_wr(&iwuqp->qp); - - pthread_spin_unlock(&iwuqp->lock); - - return err; -} - -/** - * i40iw_post_recv - post receive wr for user application - * @ib_wr: work request for receive - * @bad_wr: bad wr caused an error - */ -int i40iw_upost_recv(struct ibv_qp *ib_qp, struct ibv_recv_wr *ib_wr, struct ibv_recv_wr **bad_wr) -{ - struct i40iw_uqp *iwuqp = to_i40iw_uqp(ib_qp); - enum i40iw_status_code ret = 0; - int err = 0; - struct i40iw_post_rq_info post_recv; - struct i40iw_sge sg_list[I40IW_MAX_WQ_FRAGMENT_COUNT]; - - memset(&post_recv, 0, sizeof(post_recv)); - err = pthread_spin_lock(&iwuqp->lock); - if (err) - return err; - while (ib_wr) { - post_recv.num_sges = ib_wr->num_sge; - post_recv.wr_id = ib_wr->wr_id; - i40iw_copy_sg_list(sg_list, ib_wr->sg_list, ib_wr->num_sge); - post_recv.sg_list = sg_list; - ret = iwuqp->qp.ops.iw_post_receive(&iwuqp->qp, &post_recv); - if (ret) { - fprintf(stderr, PFX "%s: failed to post receives, status %d\n", __func__, ret); - if (ret == I40IW_ERR_QP_TOOMANY_WRS_POSTED) - err = -ENOMEM; - else - err = -EINVAL; - *bad_wr = ib_wr; - goto error; - } - ib_wr = ib_wr->next; - } - -error: - pthread_spin_unlock(&iwuqp->lock); - return err; -} - -/** - * i40iw_async_event - handle async events from driver - * @event: event received - */ -void i40iw_async_event(struct ibv_async_event *event) -{ - struct i40iw_uqp *iwuqp; - - switch (event->event_type) { - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_ACCESS_ERR: - iwuqp = to_i40iw_uqp(event->element.qp); - iwuqp->qperr = 1; - break; - - default: - break; - } -} - -/** - * i40iw_ucreate_ah - Not implemented - * @pd: - * @attr: - */ -struct ibv_ah *i40iw_ucreate_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - return NULL; -} - -/** - * i40iw_udestroy_ah - Not implemented - * @ah: - */ -int i40iw_udestroy_ah(struct ibv_ah *ah) -{ - return -ENOSYS; -} - -/** - * i40iw_uattach_mcast - Not implemented - * @qp: - * @gid: - * @lid: - */ -int i40iw_uattach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - return -ENOSYS; -} - -/** - * i40iw_udetach_mcast - Not implemented - * @qp: - * @gid: - * @lid: - */ -int i40iw_udetach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - return -ENOSYS; -} - -/** - * i40iw_uresize_cq - Not implemented - * @cq: - * @cqe: - */ -int i40iw_uresize_cq(struct ibv_cq *cq, int cqe) -{ - return -ENOSYS; -} diff --git a/usr/rdma-core/providers/ipathverbs/CMakeLists.txt b/usr/rdma-core/providers/ipathverbs/CMakeLists.txt deleted file mode 100644 index 9031b86d0..000000000 --- a/usr/rdma-core/providers/ipathverbs/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -rdma_provider(ipathverbs - ipathverbs.c - verbs.c - ) - -rdma_subst_install(FILES "truescale.conf.in" - DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/modprobe.d/" - RENAME "truescale.conf") -install(FILES truescale-serdes.cmds - DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) diff --git a/usr/rdma-core/providers/ipathverbs/COPYING b/usr/rdma-core/providers/ipathverbs/COPYING deleted file mode 100644 index cf55023e8..000000000 --- a/usr/rdma-core/providers/ipathverbs/COPYING +++ /dev/null @@ -1,35 +0,0 @@ -Copyright (c) 2013. Intel Corporation. All rights reserved. -Copyright (c) 2007. QLogic Corp. All rights reserved. -Copyright (c) 2005. PathScale, Inc. All rights reserved. - -This software is available to you under a choice of one of two -licenses. You may choose to be licensed under the terms of the GNU -General Public License (GPL) Version 2, available from the file -COPYING in the main directory of this source tree, or the -OpenIB.org BSD license below: - - Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - - Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - - - Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -Patent licenses, if any, provided herein do not apply to -combinations of this program with other software, or any other -product whatsoever. diff --git a/usr/rdma-core/providers/ipathverbs/dracut_check b/usr/rdma-core/providers/ipathverbs/dracut_check deleted file mode 100644 index fbed81f80..000000000 --- a/usr/rdma-core/providers/ipathverbs/dracut_check +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -if [ -n "$hostonly" ]; then - lspci -n 2>/dev/null | grep -q -i "1077\|1fc1" - exit $? -fi - -exit 0 diff --git a/usr/rdma-core/providers/ipathverbs/dracut_install b/usr/rdma-core/providers/ipathverbs/dracut_install deleted file mode 100644 index a7ef490ea..000000000 --- a/usr/rdma-core/providers/ipathverbs/dracut_install +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -inst /etc/modprobe.d/truescale.conf -inst /usr/libexec/truescale-serdes.cmds - -# All files needed by truescale-serdes.cmds need to be present here -inst /sbin/lspci -inst /bin/grep -inst /bin/sed -inst /usr/bin/logger -inst /usr/sbin/dmidecode -inst /bin/readlink -inst /bin/echo diff --git a/usr/rdma-core/providers/ipathverbs/dracut_kmod b/usr/rdma-core/providers/ipathverbs/dracut_kmod deleted file mode 100644 index d76ae808b..000000000 --- a/usr/rdma-core/providers/ipathverbs/dracut_kmod +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -instmods ib_qib - diff --git a/usr/rdma-core/providers/ipathverbs/ipath-abi.h b/usr/rdma-core/providers/ipathverbs/ipath-abi.h deleted file mode 100644 index bd3cde23e..000000000 --- a/usr/rdma-core/providers/ipathverbs/ipath-abi.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2006 QLogic, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Patent licenses, if any, provided herein do not apply to - * combinations of this program with other software, or any other - * product whatsoever. - */ - -#ifndef IPATH_ABI_H -#define IPATH_ABI_H - -#include - -struct ipath_get_context_resp { - struct ibv_get_context_resp ibv_resp; - __u32 version; -}; - -struct ipath_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u64 offset; -}; - -struct ipath_resize_cq_resp { - struct ibv_resize_cq_resp ibv_resp; - __u64 offset; -}; - -struct ipath_create_qp_resp { - struct ibv_create_qp_resp ibv_resp; - __u64 offset; -}; - -struct ipath_create_srq_resp { - struct ibv_create_srq_resp ibv_resp; - __u64 offset; -}; - -struct ipath_modify_srq_cmd { - struct ibv_modify_srq ibv_cmd; - __u64 offset_addr; -}; - -#endif /* IPATH_ABI_H */ diff --git a/usr/rdma-core/providers/ipathverbs/ipathverbs.c b/usr/rdma-core/providers/ipathverbs/ipathverbs.c deleted file mode 100644 index 449abb048..000000000 --- a/usr/rdma-core/providers/ipathverbs/ipathverbs.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2006-2007 QLogic Corporation, All rights reserved. - * Copyright (c) 2005. PathScale, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Patent licenses, if any, provided herein do not apply to - * combinations of this program with other software, or any other - * product whatsoever. - */ - -#include - -#include -#include -#include -#include - -#include "ipathverbs.h" -#include "ipath-abi.h" - -#ifndef PCI_VENDOR_ID_PATHSCALE -#define PCI_VENDOR_ID_PATHSCALE 0x1fc1 -#endif - -#ifndef PCI_VENDOR_ID_QLOGIC -#define PCI_VENDOR_ID_QLOGIC 0x1077 -#endif - -#ifndef PCI_DEVICE_ID_INFINIPATH_HT -#define PCI_DEVICE_ID_INFINIPATH_HT 0x000d -#endif - -#ifndef PCI_DEVICE_ID_INFINIPATH_PE800 -#define PCI_DEVICE_ID_INFINIPATH_PE800 0x0010 -#endif - -#ifndef PCI_DEVICE_ID_INFINIPATH_6220 -#define PCI_DEVICE_ID_INFINIPATH_6220 0x6220 -#endif - -#ifndef PCI_DEVICE_ID_INFINIPATH_7220 -#define PCI_DEVICE_ID_INFINIPATH_7220 0x7220 -#endif - -#ifndef PCI_DEVICE_ID_INFINIPATH_7322 -#define PCI_DEVICE_ID_INFINIPATH_7322 0x7322 -#endif - -#define HCA(v, d) \ - VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, PCI_DEVICE_ID_INFINIPATH_##d, NULL) -static const struct verbs_match_ent hca_table[] = { - HCA(PATHSCALE, HT), - HCA(PATHSCALE, PE800), - HCA(QLOGIC, 6220), - HCA(QLOGIC, 7220), - HCA(QLOGIC, 7322), - {} -}; - -static struct ibv_context_ops ipath_ctx_ops = { - .query_device = ipath_query_device, - .query_port = ipath_query_port, - - .alloc_pd = ipath_alloc_pd, - .dealloc_pd = ipath_free_pd, - - .reg_mr = ipath_reg_mr, - .dereg_mr = ipath_dereg_mr, - - .create_cq = ipath_create_cq, - .poll_cq = ipath_poll_cq, - .req_notify_cq = ibv_cmd_req_notify_cq, - .cq_event = NULL, - .resize_cq = ipath_resize_cq, - .destroy_cq = ipath_destroy_cq, - - .create_srq = ipath_create_srq, - .modify_srq = ipath_modify_srq, - .query_srq = ipath_query_srq, - .destroy_srq = ipath_destroy_srq, - .post_srq_recv = ipath_post_srq_recv, - - .create_qp = ipath_create_qp, - .query_qp = ipath_query_qp, - .modify_qp = ipath_modify_qp, - .destroy_qp = ipath_destroy_qp, - - .post_send = ipath_post_send, - .post_recv = ipath_post_recv, - - .create_ah = ipath_create_ah, - .destroy_ah = ipath_destroy_ah, - - .attach_mcast = ibv_cmd_attach_mcast, - .detach_mcast = ibv_cmd_detach_mcast -}; - -static struct ibv_context *ipath_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - struct ipath_context *context; - struct ibv_get_context cmd; - struct ibv_get_context_resp resp; - struct ipath_device *dev; - - context = malloc(sizeof *context); - if (!context) - return NULL; - memset(context, 0, sizeof *context); - context->ibv_ctx.cmd_fd = cmd_fd; - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, - sizeof cmd, &resp, sizeof resp)) - goto err_free; - - context->ibv_ctx.ops = ipath_ctx_ops; - dev = to_idev(ibdev); - if (dev->abi_version == 1) { - context->ibv_ctx.ops.create_cq = ipath_create_cq_v1; - context->ibv_ctx.ops.poll_cq = ibv_cmd_poll_cq; - context->ibv_ctx.ops.resize_cq = ipath_resize_cq_v1; - context->ibv_ctx.ops.destroy_cq = ipath_destroy_cq_v1; - context->ibv_ctx.ops.create_srq = ipath_create_srq_v1; - context->ibv_ctx.ops.destroy_srq = ipath_destroy_srq_v1; - context->ibv_ctx.ops.modify_srq = ipath_modify_srq_v1; - context->ibv_ctx.ops.post_srq_recv = ibv_cmd_post_srq_recv; - context->ibv_ctx.ops.create_qp = ipath_create_qp_v1; - context->ibv_ctx.ops.destroy_qp = ipath_destroy_qp_v1; - context->ibv_ctx.ops.post_recv = ibv_cmd_post_recv; - } - return &context->ibv_ctx; - -err_free: - free(context); - return NULL; -} - -static void ipath_free_context(struct ibv_context *ibctx) -{ - struct ipath_context *context = to_ictx(ibctx); - - free(context); -} - -static void ipath_uninit_device(struct verbs_device *verbs_device) -{ - struct ipath_device *dev = to_idev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device * -ipath_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct ipath_device *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->abi_version = sysfs_dev->abi_ver; - - return &dev->ibv_dev; -} - -static const struct verbs_device_ops ipath_dev_ops = { - .name = "ipathverbs", - .match_min_abi_version = 0, - .match_max_abi_version = INT_MAX, - .match_table = hca_table, - .alloc_device = ipath_device_alloc, - .uninit_device = ipath_uninit_device, - .alloc_context = ipath_alloc_context, - .free_context = ipath_free_context, -}; -PROVIDER_DRIVER(ipath_dev_ops); diff --git a/usr/rdma-core/providers/ipathverbs/ipathverbs.h b/usr/rdma-core/providers/ipathverbs/ipathverbs.h deleted file mode 100644 index 13acec246..000000000 --- a/usr/rdma-core/providers/ipathverbs/ipathverbs.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2006-2009 QLogic Corp. All rights reserved. - * Copyright (c) 2005. PathScale, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Patent licenses, if any, provided herein do not apply to - * combinations of this program with other software, or any other - * product whatsoever. - */ - -#ifndef IPATH_H -#define IPATH_H - -#include -#include -#include -#include - -#include -#include - -#define PFX "ipath: " - -struct ipath_device { - struct verbs_device ibv_dev; - int abi_version; -}; - -struct ipath_context { - struct ibv_context ibv_ctx; -}; - -/* - * This structure needs to have the same size and offsets as - * the kernel's ib_wc structure since it is memory mapped. - */ -struct ipath_wc { - uint64_t wr_id; - enum ibv_wc_status status; - enum ibv_wc_opcode opcode; - uint32_t vendor_err; - uint32_t byte_len; - uint32_t imm_data; /* in network byte order */ - uint32_t qp_num; - uint32_t src_qp; - enum ibv_wc_flags wc_flags; - uint16_t pkey_index; - uint16_t slid; - uint8_t sl; - uint8_t dlid_path_bits; - uint8_t port_num; -}; - -struct ipath_cq_wc { - _Atomic(uint32_t) head; - _Atomic(uint32_t) tail; - struct ipath_wc queue[1]; -}; - -struct ipath_cq { - struct ibv_cq ibv_cq; - struct ipath_cq_wc *queue; - pthread_spinlock_t lock; -}; - -/* - * Receive work request queue entry. - * The size of the sg_list is determined when the QP is created and stored - * in qp->r_max_sge. - */ -struct ipath_rwqe { - uint64_t wr_id; - uint8_t num_sge; - uint8_t padding[7]; - struct ibv_sge sg_list[0]; -}; - -/* - * This struture is used to contain the head pointer, tail pointer, - * and receive work queue entries as a single memory allocation so - * it can be mmap'ed into user space. - * Note that the wq array elements are variable size so you can't - * just index into the array to get the N'th element; - * use get_rwqe_ptr() instead. - */ -struct ipath_rwq { - _Atomic(uint32_t) head; /* new requests posted to the head. */ - _Atomic(uint32_t) tail; /* receives pull requests from here. */ - struct ipath_rwqe wq[0]; -}; - -struct ipath_rq { - struct ipath_rwq *rwq; - pthread_spinlock_t lock; - uint32_t size; - uint32_t max_sge; -}; - -struct ipath_qp { - struct ibv_qp ibv_qp; - struct ipath_rq rq; -}; - -struct ipath_srq { - struct ibv_srq ibv_srq; - struct ipath_rq rq; -}; - -#define to_ixxx(xxx, type) \ - ((struct ipath_##type *) \ - ((void *) ib##xxx - offsetof(struct ipath_##type, ibv_##xxx))) - -static inline struct ipath_context *to_ictx(struct ibv_context *ibctx) -{ - return to_ixxx(ctx, context); -} - -static inline struct ipath_device *to_idev(struct ibv_device *ibdev) -{ - return to_ixxx(dev, device); -} - -static inline struct ipath_cq *to_icq(struct ibv_cq *ibcq) -{ - return to_ixxx(cq, cq); -} - -static inline struct ipath_qp *to_iqp(struct ibv_qp *ibqp) -{ - return to_ixxx(qp, qp); -} - -static inline struct ipath_srq *to_isrq(struct ibv_srq *ibsrq) -{ - return to_ixxx(srq, srq); -} - -/* - * Since struct ipath_rwqe is not a fixed size, we can't simply index into - * struct ipath_rq.wq. This function does the array index computation. - */ -static inline struct ipath_rwqe *get_rwqe_ptr(struct ipath_rq *rq, - unsigned n) -{ - return (struct ipath_rwqe *) - ((char *) rq->rwq->wq + - (sizeof(struct ipath_rwqe) + - rq->max_sge * sizeof(struct ibv_sge)) * n); -} - -extern int ipath_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); - -extern int ipath_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -struct ibv_pd *ipath_alloc_pd(struct ibv_context *pd); - -int ipath_free_pd(struct ibv_pd *pd); - -struct ibv_mr *ipath_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); - -int ipath_dereg_mr(struct ibv_mr *mr); - -struct ibv_cq *ipath_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); - -struct ibv_cq *ipath_create_cq_v1(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); - -int ipath_resize_cq(struct ibv_cq *cq, int cqe); - -int ipath_resize_cq_v1(struct ibv_cq *cq, int cqe); - -int ipath_destroy_cq(struct ibv_cq *cq); - -int ipath_destroy_cq_v1(struct ibv_cq *cq); - -int ipath_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); - -struct ibv_qp *ipath_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr); - -struct ibv_qp *ipath_create_qp_v1(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr); - -int ipath_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); - -int ipath_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); - -int ipath_destroy_qp(struct ibv_qp *qp); - -int ipath_destroy_qp_v1(struct ibv_qp *qp); - -int ipath_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); - -int ipath_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -struct ibv_srq *ipath_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); - -struct ibv_srq *ipath_create_srq_v1(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); - -int ipath_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int attr_mask); - -int ipath_modify_srq_v1(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int attr_mask); - -int ipath_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr); - -int ipath_destroy_srq(struct ibv_srq *srq); - -int ipath_destroy_srq_v1(struct ibv_srq *srq); - -int ipath_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -struct ibv_ah *ipath_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr); - -int ipath_destroy_ah(struct ibv_ah *ah); - -#endif /* IPATH_H */ diff --git a/usr/rdma-core/providers/ipathverbs/truescale-serdes.cmds b/usr/rdma-core/providers/ipathverbs/truescale-serdes.cmds deleted file mode 100755 index 0f8933765..000000000 --- a/usr/rdma-core/providers/ipathverbs/truescale-serdes.cmds +++ /dev/null @@ -1,257 +0,0 @@ -#!/bin/bash -# Copyright (c) 2013 Intel Corporation. All rights reserved. -# Copyright (c) 2010 QLogic Corporation. -# All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# OpenIB.org BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -# This script does truescale (qib) adapter-specific actions, and is -# sourced during boot after the ib_qib module is loaded. The stop -# operation is deprecated. It isn't intended for standalone use. - -# base name in /sys/class -PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH -export PATH -qb=/sys/class/infiniband/qib -serdes_parm=txselect - -if [ -r /etc/rdma/rdma.conf ]; then - IB_CONFIG=/etc/rdma/rdma.conf -else - IB_CONFIG=/etc/infiniband/openib.conf -fi -if [ -f $IB_CONFIG ]; then - . $IB_CONFIG -fi - -# If user specifies an override or the setting is ommitted from the config file -# then default to new back plane version. -if [ -z $QIB_QME_BPVER ]; then - QIB_QME_BPVER=1 -fi - -warn_and_log() -{ - echo "$0: $@" - logger -t infinipath "$@" -} - -setup_qmh() -{ - local -i nunit=0 bay bl2xB=0 full=0 - local parmf sysinfo bayinfo mez1bus mez2bus mez3bus=0 tbay - local -a parm bay_h1 - for parm in parameters/${serdes_parm} ${serdes_parm}; do - if [ -e /sys/module/ib_qib/$parm ]; then - parmf=/sys/module/ib_qib/$parm - break; - fi - done - if [ ! "$parmf" ]; then - warn_and_log Unable to find ${serdes_parm} parameter - return - fi - sysinfo="$(PATH=/sbin:/usr/sbin:$PATH; dmidecode -t system | \ - sed -e '/^Handle/d' -e '/^[ \t]*$/d' -e 's/[ \t]*$//' )" - if [ ! "$sysinfo" ]; then - warn_and_log Unable to determine system type - return - fi - bayinfo="$(PATH=/sbin:/usr/sbin:$PATH; dmidecode -t 204)" - if [ ! "$bayinfo" ]; then - warn_and_log Unable to determine bay - return - fi - case "${bayinfo}" in - *Server*Bay:*) tbay=$(PATH=/sbin:/usr/sbin:$PATH; dmidecode -t 204 | \ - sed -n -e 's/[ \t]*$//' -e 's/[ \t]*Server Bay:[ \t]*//p') ;; - *) tbay=$(PATH=/sbin:/usr/sbin:$PATH; dmidecode -t 204 | \ - sed -n -e '1,/BladeSystem/d' -e 's/ *$//' -e 's/^\t\t*//' \ - -e '/^[0-9][AB]*$/p' -e '/^[0-9][0-9][AB]*$/p') ;; - esac - - read pbase < $parmf - parm=($(echo ${qb}*)) - nunit=${#parm[*]} - - # [0] is a dummy in these arrays, bay #'ing starts at 1 - # H1 value, per bay (same for both ports) - m1_bay_h1=(0 8 7 7 7 7 6 6 6 8 7 7 7 7 6 6 7) - m2_bay_h1=(0 11 11 11 11 11 11 10 11 11 11 11 11 10 10 10 10) - m3_bay_h1=(0 11 11 11 11 10 10 10 10) - - # tx serdes index per bay for mez1 (either port) - mez1p1_idx=(0 2 2 17 17 17 1 1 1 2 1 17 17 16 2 18 16) - # tx serdes setting for mez1 p2 (only used on full-height blades) - mez1p2_idx=(0 4 4 3 3 3 2 4 4) - # tx serdes index per bay for mez2 port 1 - mez2p1_idx=(0 2 2 17 17 17 1 1 1 2 1 17 17 16 2 18 1) - # tx serdes index per bay for mez2 port 2 - mez2p2_idx=(0 2 2 19 1 1 1 1 1 2 1 18 17 1 19 1 1) - # tx serdes index per bay for mez3 port 1 (mez3 only on full-height blades) - mez3p1_idx=(0 2 1 18 17 1 19 1 1) - # tx serdes index per bay for mez3 port 2 (mez3 only on full-height blades) - mez3p2_idx=(0 2 1 17 17 16 2 18 1) - - case "${sysinfo}" in - *BL280[cC]*) mez1bus=3 mez2bus=6 bay=$tbay ;; - # both nodes on the 2x220 blade have bus 3, only one mez, but - # they connect to different switches through different paths - # so A and B have different parameters. They connect to - # the switch as if they were the mez2 on other blade types, - # with port 1 on mez2 for A node and port 2 on mez2 - # for the B node - *BL2x220[cC]*) - mez1bus=3 mez2bus=3 bay=${tbay%[AB]} - case "${tbay}" in - *A) bl2xB=${mez2p1_idx[$bay]} ;; - *B) bl2xB=${mez2p2_idx[$bay]} ;; - esac - ;; - *BL460[cC]*) mez1bus=6 mez2bus=9 bay=$tbay ;; - *BL465[cC]*) mez1bus=5 mez2bus=8 bay=$tbay ;; - *BL490[cC]*) mez1bus=6 mez2bus=7 bay=$tbay ;; - *BL685[cC]*) mez1bus=41 mez2bus=6 mez3bus=44 full=1 bay=$(($tbay % 9)) ;; - *) warn_and_log Unknown blade type "$sysinfo" - return ;; - esac - - # mez1 only has port1 connected, mez2, mez3 can have both ports - - # If only one card, and two mez possible, we have to figure out which - # mez we are plugged into. - # On RHEL4U8, we look in the driver subdir, all others - # in the device/driver subdir for the pcie bus. - pciprefix="[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]:" - if [ ${bl2xB} -ne 0 ]; then - pbase="${pbase} 0,1=${bl2xB},${m2_bay_h1[$bay]}" - else while [ $nunit -ne 0 ]; do - (( nunit-- )) - buspath=$(readlink -m ${qb}${nunit}/device) - if [ -n "$(echo ${buspath} | grep "${pciprefix}$(printf "%02d" ${mez1bus}):")" ]; then - pbase="${pbase} ${nunit},1=${mez1p1_idx[$bay]},${m1_bay_h1[$bay]}" - if [ ${full} -eq 1 ]; then - pbase="${pbase} ${nunit},2=${mez1p2_idx[$bay]},${m1_bay_h1[$bay]}" - fi - elif [ -n "$(echo ${buspath} | grep "${pciprefix}$(printf "%02d" ${mez2bus}):")" ]; then - pbase="${pbase} ${nunit},1=${mez2p1_idx[$bay]},${m2_bay_h1[$bay]}" - pbase="${pbase} ${nunit},2=${mez2p2_idx[$bay]},${m2_bay_h1[$bay]}" - elif [ -n "$(echo ${buspath} | grep "${pciprefix}$(printf "%02d" ${mez3bus}):")" ]; then - pbase="${pbase} ${nunit},1=${mez3p1_idx[$bay]},${m3_bay_h1[$bay]}" - pbase="${pbase} ${nunit},2=${mez3p2_idx[$bay]},${m3_bay_h1[$bay]}" - else - warn_and_log Mismatch on mezbus ${mez1_bus},${mez2_bus},${mez3_bus} \ - and unit ${nunit}, no serdes setup - fi - done - fi - echo -n ${pbase} > $parmf -} - - - -setup_qme() -{ - local parm parmf sn pbase - local -i nunit=0 bay idx bpver=${QIB_QME_BPVER:1} - local -a bp0_idx bp1_idx set - - # tx settings for Dell Backplane v1.0 - bp0_idx=( 0 22 23 24 25 26 24 27 28 22 23 24 25 26 24 27 28 ) - # tx settings for Dell Backplane v1.1 - bp1_idx=( 0 29 29 30 31 32 33 30 29 29 29 30 31 32 33 30 29 ) - - for parm in parameters/${serdes_parm} ${serdes_parm}; do - if [ -e /sys/module/ib_qib/$parm ]; then - parmf=/sys/module/ib_qib/$parm - break; - fi - done - if [ ! "$parmf" ]; then - warn_and_log Unable to find ${serdes_parm} parameter - return - fi - - read pbase < $parmf - parm=( $(echo ${qb}*) ) - nunit=${#parm[*]} - - if [ -e /sys/module/ib_qib/parameters/qme_bp ]; then - read bpver < /sys/module/ib_qib/parameters/qme_bp - if [ ${bpver} -ne 0 -a ${bpver} -ne 1 ]; then - warn_and_log "Invalid Dell backplane version (${bpver}). Defaulting to 1." - bpver=1 - fi - fi - eval 'set=( ${bp'${bpver}'_idx[@]} )' - - # we get two serial numbers normally, use 2nd if present, else first - sn="$(dmidecode -t 2 | grep -i serial | tail -1)" - case ${sn} in - *[sS]erial\ [nN]umber*) - bay="$(echo $sn | sed -e 's/\.$//' -e 's/.*\.0*//' -e 's/[abcd]$//')" - if [ ${bay} -gt ${#set[@]} ]; then - warn_and_log Unexpected QME7342 bay info: ${sn}, no Tx params - return - fi - idx=${set[bay]} - # H1 is same for all QME bays, so no need to specify. - while [ $nunit -ne 0 ]; do - (( nunit-- )) - pbase="${pbase} ${nunit},1=${idx} ${nunit},2=${idx}" - done - echo -n ${pbase} > $parmf - ;; - *) warn_and_log No QME7342 bay information, no Tx params - return;; - esac -} - -has_qib=$(lspci -n 2>/dev/null | grep -i "1077\|1fc1") -if [ ! "${has_qib}" ]; then - exit 0 -fi - -case "$1" in -start) - has_qmh7342=$(grep QMH7342 ${qb}*/hca_type 2>/dev/null) - if [ "${has_qmh7342}" ]; then - setup_qmh - else - has_qme7342=$(grep QME7342 ${qb}*/hca_type 2>/dev/null) - if [ "${has_qme7342}" ]; then - setup_qme - fi - fi - - ;; -stop) - warn_and_log stop operation deprecated - ;; -esac diff --git a/usr/rdma-core/providers/ipathverbs/truescale.conf.in b/usr/rdma-core/providers/ipathverbs/truescale.conf.in deleted file mode 100644 index e2827d956..000000000 --- a/usr/rdma-core/providers/ipathverbs/truescale.conf.in +++ /dev/null @@ -1 +0,0 @@ -install ib_qib modprobe -i ib_qib $CMDLINE_OPTS && @CMAKE_INSTALL_FULL_LIBEXECDIR@/truescale-serdes.cmds start diff --git a/usr/rdma-core/providers/ipathverbs/verbs.c b/usr/rdma-core/providers/ipathverbs/verbs.c deleted file mode 100644 index b81a98253..000000000 --- a/usr/rdma-core/providers/ipathverbs/verbs.c +++ /dev/null @@ -1,682 +0,0 @@ -/* - * Copyright (c) 2006-2009 QLogic Corp. All rights reserved. - * Copyright (c) 2005. PathScale, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Patent licenses, if any, provided herein do not apply to - * combinations of this program with other software, or any other - * product whatsoever. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "ipathverbs.h" -#include "ipath-abi.h" - -int ipath_query_device(struct ibv_context *context, - struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, - &cmd, sizeof cmd); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%d", major, minor, sub_minor); - - return 0; -} - -int ipath_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); -} - -struct ibv_pd *ipath_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct ibv_alloc_pd_resp resp; - struct ibv_pd *pd; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, pd, &cmd, sizeof cmd, - &resp, sizeof resp)) { - free(pd); - return NULL; - } - - return pd; -} - -int ipath_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - free(pd); - return 0; -} - -struct ibv_mr *ipath_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - struct ibv_mr *mr; - struct ibv_reg_mr cmd; - struct ibv_reg_mr_resp resp; - int ret; - - mr = malloc(sizeof *mr); - if (!mr) - return NULL; - - ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr, - &cmd, sizeof cmd, &resp, sizeof resp); - if (ret) { - free(mr); - return NULL; - } - - return mr; -} - -int ipath_dereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - free(mr); - return 0; -} - -struct ibv_cq *ipath_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct ipath_cq *cq; - struct ibv_create_cq cmd; - struct ipath_create_cq_resp resp; - int ret; - size_t size; - - cq = malloc(sizeof *cq); - if (!cq) - return NULL; - - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &cq->ibv_cq, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(cq); - return NULL; - } - - size = sizeof(struct ipath_cq_wc) + sizeof(struct ipath_wc) * cqe; - cq->queue = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - context->cmd_fd, resp.offset); - if ((void *) cq->queue == MAP_FAILED) { - ibv_cmd_destroy_cq(&cq->ibv_cq); - free(cq); - return NULL; - } - - pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE); - return &cq->ibv_cq; -} - -struct ibv_cq *ipath_create_cq_v1(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct ibv_cq *cq; - struct ibv_create_cq cmd; - struct ibv_create_cq_resp resp; - int ret; - - cq = malloc(sizeof *cq); - if (!cq) - return NULL; - - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - cq, &cmd, sizeof cmd, &resp, sizeof resp); - if (ret) { - free(cq); - return NULL; - } - - return cq; -} - -int ipath_resize_cq(struct ibv_cq *ibcq, int cqe) -{ - struct ipath_cq *cq = to_icq(ibcq); - struct ibv_resize_cq cmd; - struct ipath_resize_cq_resp resp; - size_t size; - int ret; - - pthread_spin_lock(&cq->lock); - /* Save the old size so we can unmmap the queue. */ - size = sizeof(struct ipath_cq_wc) + - (sizeof(struct ipath_wc) * cq->ibv_cq.cqe); - ret = ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - pthread_spin_unlock(&cq->lock); - return ret; - } - (void) munmap(cq->queue, size); - size = sizeof(struct ipath_cq_wc) + - (sizeof(struct ipath_wc) * cq->ibv_cq.cqe); - cq->queue = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - ibcq->context->cmd_fd, resp.offset); - ret = errno; - pthread_spin_unlock(&cq->lock); - if ((void *) cq->queue == MAP_FAILED) - return ret; - return 0; -} - -int ipath_resize_cq_v1(struct ibv_cq *ibcq, int cqe) -{ - struct ibv_resize_cq cmd; - struct ibv_resize_cq_resp resp; - - return ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd, - &resp, sizeof resp); -} - -int ipath_destroy_cq(struct ibv_cq *ibcq) -{ - struct ipath_cq *cq = to_icq(ibcq); - int ret; - - ret = ibv_cmd_destroy_cq(ibcq); - if (ret) - return ret; - - (void) munmap(cq->queue, sizeof(struct ipath_cq_wc) + - (sizeof(struct ipath_wc) * cq->ibv_cq.cqe)); - free(cq); - return 0; -} - -int ipath_destroy_cq_v1(struct ibv_cq *ibcq) -{ - int ret; - - ret = ibv_cmd_destroy_cq(ibcq); - if (!ret) - free(ibcq); - return ret; -} - -int ipath_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) -{ - struct ipath_cq *cq = to_icq(ibcq); - struct ipath_cq_wc *q; - int npolled; - uint32_t tail; - - pthread_spin_lock(&cq->lock); - q = cq->queue; - tail = atomic_load_explicit(&q->tail, memory_order_relaxed); - for (npolled = 0; npolled < ne; ++npolled, ++wc) { - if (tail == atomic_load(&q->head)) - break; - - /* Make sure entry is read after head index is read. */ - atomic_thread_fence(memory_order_acquire); - memcpy(wc, &q->queue[tail], sizeof(*wc)); - if (tail == cq->ibv_cq.cqe) - tail = 0; - else - tail++; - } - atomic_store(&q->tail, tail); - pthread_spin_unlock(&cq->lock); - - return npolled; -} - -struct ibv_qp *ipath_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) -{ - struct ibv_create_qp cmd; - struct ipath_create_qp_resp resp; - struct ipath_qp *qp; - int ret; - size_t size; - - qp = malloc(sizeof *qp); - if (!qp) - return NULL; - - ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(qp); - return NULL; - } - - if (attr->srq) { - qp->rq.size = 0; - qp->rq.max_sge = 0; - qp->rq.rwq = NULL; - } else { - qp->rq.size = attr->cap.max_recv_wr + 1; - qp->rq.max_sge = attr->cap.max_recv_sge; - size = sizeof(struct ipath_rwq) + - (sizeof(struct ipath_rwqe) + - (sizeof(struct ibv_sge) * qp->rq.max_sge)) * - qp->rq.size; - qp->rq.rwq = mmap(NULL, size, - PROT_READ | PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.offset); - if ((void *) qp->rq.rwq == MAP_FAILED) { - ibv_cmd_destroy_qp(&qp->ibv_qp); - free(qp); - return NULL; - } - } - - pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE); - return &qp->ibv_qp; -} - -struct ibv_qp *ipath_create_qp_v1(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - struct ibv_create_qp cmd; - struct ibv_create_qp_resp resp; - struct ibv_qp *qp; - int ret; - - qp = malloc(sizeof *qp); - if (!qp) - return NULL; - - ret = ibv_cmd_create_qp(pd, qp, attr, &cmd, sizeof cmd, - &resp, sizeof resp); - if (ret) { - free(qp); - return NULL; - } - - return qp; -} - -int ipath_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - - return ibv_cmd_query_qp(qp, attr, attr_mask, init_attr, - &cmd, sizeof cmd); -} - -int ipath_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - - return ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof cmd); -} - -int ipath_destroy_qp(struct ibv_qp *ibqp) -{ - struct ipath_qp *qp = to_iqp(ibqp); - int ret; - - ret = ibv_cmd_destroy_qp(ibqp); - if (ret) - return ret; - - if (qp->rq.rwq) { - size_t size; - - size = sizeof(struct ipath_rwq) + - (sizeof(struct ipath_rwqe) + - (sizeof(struct ibv_sge) * qp->rq.max_sge)) * - qp->rq.size; - (void) munmap(qp->rq.rwq, size); - } - free(qp); - return 0; -} - -int ipath_destroy_qp_v1(struct ibv_qp *ibqp) -{ - int ret; - - ret = ibv_cmd_destroy_qp(ibqp); - if (!ret) - free(ibqp); - return ret; -} - -int ipath_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - unsigned wr_count; - struct ibv_send_wr *i; - - /* Sanity check the number of WRs being posted */ - for (i = wr, wr_count = 0; i; i = i->next) - if (++wr_count > 10) - goto iter; - - return ibv_cmd_post_send(qp, wr, bad_wr); - -iter: - do { - struct ibv_send_wr *next; - int ret; - - next = i->next; - i->next = NULL; - ret = ibv_cmd_post_send(qp, wr, bad_wr); - i->next = next; - if (ret) - return ret; - if (next == NULL) - break; - wr = next; - for (i = wr, wr_count = 0; i->next; i = i->next) - if (++wr_count > 2) - break; - } while (1); - return 0; -} - -static int post_recv(struct ipath_rq *rq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct ibv_recv_wr *i; - struct ipath_rwq *rwq; - struct ipath_rwqe *wqe; - uint32_t head; - int n, ret; - - pthread_spin_lock(&rq->lock); - rwq = rq->rwq; - head = atomic_load_explicit(&rwq->head, memory_order_relaxed); - for (i = wr; i; i = i->next) { - if ((unsigned) i->num_sge > rq->max_sge) { - ret = EINVAL; - goto bad; - } - wqe = get_rwqe_ptr(rq, head); - if (++head >= rq->size) - head = 0; - if (head == atomic_load(&rwq->tail)) { - ret = ENOMEM; - goto bad; - } - wqe->wr_id = i->wr_id; - wqe->num_sge = i->num_sge; - for (n = 0; n < wqe->num_sge; n++) - wqe->sg_list[n] = i->sg_list[n]; - - /* Make sure queue entry is written before the head index. */ - atomic_thread_fence(memory_order_release); - atomic_store(&rwq->head, head); - } - ret = 0; - goto done; - -bad: - if (bad_wr) - *bad_wr = i; -done: - pthread_spin_unlock(&rq->lock); - return ret; -} - -int ipath_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct ipath_qp *qp = to_iqp(ibqp); - - return post_recv(&qp->rq, wr, bad_wr); -} - -struct ibv_srq *ipath_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct ipath_srq *srq; - struct ibv_create_srq cmd; - struct ipath_create_srq_resp resp; - int ret; - size_t size; - - srq = malloc(sizeof *srq); - if (srq == NULL) - return NULL; - - ret = ibv_cmd_create_srq(pd, &srq->ibv_srq, attr, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(srq); - return NULL; - } - - srq->rq.size = attr->attr.max_wr + 1; - srq->rq.max_sge = attr->attr.max_sge; - size = sizeof(struct ipath_rwq) + - (sizeof(struct ipath_rwqe) + - (sizeof(struct ibv_sge) * srq->rq.max_sge)) * srq->rq.size; - srq->rq.rwq = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.offset); - if ((void *) srq->rq.rwq == MAP_FAILED) { - ibv_cmd_destroy_srq(&srq->ibv_srq); - free(srq); - return NULL; - } - - pthread_spin_init(&srq->rq.lock, PTHREAD_PROCESS_PRIVATE); - return &srq->ibv_srq; -} - -struct ibv_srq *ipath_create_srq_v1(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct ibv_srq *srq; - struct ibv_create_srq cmd; - struct ibv_create_srq_resp resp; - int ret; - - srq = malloc(sizeof *srq); - if (srq == NULL) - return NULL; - - ret = ibv_cmd_create_srq(pd, srq, attr, &cmd, sizeof cmd, - &resp, sizeof resp); - if (ret) { - free(srq); - return NULL; - } - - return srq; -} - -int ipath_modify_srq(struct ibv_srq *ibsrq, - struct ibv_srq_attr *attr, - int attr_mask) -{ - struct ipath_srq *srq = to_isrq(ibsrq); - struct ipath_modify_srq_cmd cmd; - __u64 offset; - size_t size = 0; /* Shut up gcc */ - int ret; - - if (attr_mask & IBV_SRQ_MAX_WR) { - pthread_spin_lock(&srq->rq.lock); - /* Save the old size so we can unmmap the queue. */ - size = sizeof(struct ipath_rwq) + - (sizeof(struct ipath_rwqe) + - (sizeof(struct ibv_sge) * srq->rq.max_sge)) * - srq->rq.size; - } - cmd.offset_addr = (uintptr_t) &offset; - ret = ibv_cmd_modify_srq(ibsrq, attr, attr_mask, - &cmd.ibv_cmd, sizeof cmd); - if (ret) { - if (attr_mask & IBV_SRQ_MAX_WR) - pthread_spin_unlock(&srq->rq.lock); - return ret; - } - if (attr_mask & IBV_SRQ_MAX_WR) { - (void) munmap(srq->rq.rwq, size); - srq->rq.size = attr->max_wr + 1; - size = sizeof(struct ipath_rwq) + - (sizeof(struct ipath_rwqe) + - (sizeof(struct ibv_sge) * srq->rq.max_sge)) * - srq->rq.size; - srq->rq.rwq = mmap(NULL, size, - PROT_READ | PROT_WRITE, MAP_SHARED, - ibsrq->context->cmd_fd, offset); - pthread_spin_unlock(&srq->rq.lock); - /* XXX Now we have no receive queue. */ - if ((void *) srq->rq.rwq == MAP_FAILED) - return errno; - } - return 0; -} - -int ipath_modify_srq_v1(struct ibv_srq *ibsrq, - struct ibv_srq_attr *attr, - int attr_mask) -{ - struct ibv_modify_srq cmd; - - return ibv_cmd_modify_srq(ibsrq, attr, attr_mask, - &cmd, sizeof cmd); -} - -int ipath_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr) -{ - struct ibv_query_srq cmd; - - return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd); -} - -int ipath_destroy_srq(struct ibv_srq *ibsrq) -{ - struct ipath_srq *srq = to_isrq(ibsrq); - size_t size; - int ret; - - ret = ibv_cmd_destroy_srq(ibsrq); - if (ret) - return ret; - - size = sizeof(struct ipath_rwq) + - (sizeof(struct ipath_rwqe) + - (sizeof(struct ibv_sge) * srq->rq.max_sge)) * srq->rq.size; - (void) munmap(srq->rq.rwq, size); - free(srq); - return 0; -} - -int ipath_destroy_srq_v1(struct ibv_srq *ibsrq) -{ - int ret; - - ret = ibv_cmd_destroy_srq(ibsrq); - if (!ret) - free(ibsrq); - return ret; -} - -int ipath_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct ipath_srq *srq = to_isrq(ibsrq); - - return post_recv(&srq->rq, wr, bad_wr); -} - -struct ibv_ah *ipath_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - struct ibv_ah *ah; - struct ibv_create_ah_resp resp; - - ah = malloc(sizeof *ah); - if (ah == NULL) - return NULL; - - memset(&resp, 0, sizeof(resp)); - if (ibv_cmd_create_ah(pd, ah, attr, &resp, sizeof(resp))) { - free(ah); - return NULL; - } - - return ah; -} - -int ipath_destroy_ah(struct ibv_ah *ah) -{ - int ret; - - ret = ibv_cmd_destroy_ah(ah); - if (ret) - return ret; - - free(ah); - return 0; -} diff --git a/usr/rdma-core/providers/mlx4/CMakeLists.txt b/usr/rdma-core/providers/mlx4/CMakeLists.txt deleted file mode 100644 index 2cd668cbb..000000000 --- a/usr/rdma-core/providers/mlx4/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -rdma_shared_provider(mlx4 libmlx4.map - 1 1.0.${PACKAGE_VERSION} - buf.c - cq.c - dbrec.c - mlx4.c - qp.c - srq.c - verbs.c -) - -publish_headers(infiniband - mlx4dv.h -) - -install(FILES "mlx4.conf" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/modprobe.d/") diff --git a/usr/rdma-core/providers/mlx4/buf.c b/usr/rdma-core/providers/mlx4/buf.c deleted file mode 100644 index 9b41e7f62..000000000 --- a/usr/rdma-core/providers/mlx4/buf.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2006, 2007 Cisco, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include - -#include "mlx4.h" - -int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size) -{ - int ret; - - buf->length = align(size, page_size); - buf->buf = mmap(NULL, buf->length, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (buf->buf == MAP_FAILED) - return errno; - - ret = ibv_dontfork_range(buf->buf, size); - if (ret) - munmap(buf->buf, buf->length); - - return ret; -} - -void mlx4_free_buf(struct mlx4_buf *buf) -{ - if (buf->length) { - ibv_dofork_range(buf->buf, buf->length); - munmap(buf->buf, buf->length); - } -} diff --git a/usr/rdma-core/providers/mlx4/cq.c b/usr/rdma-core/providers/mlx4/cq.c deleted file mode 100644 index 8ced49e95..000000000 --- a/usr/rdma-core/providers/mlx4/cq.c +++ /dev/null @@ -1,785 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include "mlx4.h" - -enum { - CQ_OK = 0, - CQ_EMPTY = -1, - CQ_POLL_ERR = -2 -}; - -static struct mlx4_cqe *get_cqe(struct mlx4_cq *cq, int entry) -{ - return cq->buf.buf + entry * cq->cqe_size; -} - -static void *get_sw_cqe(struct mlx4_cq *cq, int n) -{ - struct mlx4_cqe *cqe = get_cqe(cq, n & cq->ibv_cq.cqe); - struct mlx4_cqe *tcqe = cq->cqe_size == 64 ? cqe + 1 : cqe; - - return (!!(tcqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^ - !!(n & (cq->ibv_cq.cqe + 1))) ? NULL : cqe; -} - -static struct mlx4_cqe *next_cqe_sw(struct mlx4_cq *cq) -{ - return get_sw_cqe(cq, cq->cons_index); -} - -static enum ibv_wc_status mlx4_handle_error_cqe(struct mlx4_err_cqe *cqe) -{ - if (cqe->syndrome == MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR) - printf(PFX "local QP operation err " - "(QPN %06x, WQE index %x, vendor syndrome %02x, " - "opcode = %02x)\n", - htobe32(cqe->vlan_my_qpn), htobe32(cqe->wqe_index), - cqe->vendor_err, - cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK); - - switch (cqe->syndrome) { - case MLX4_CQE_SYNDROME_LOCAL_LENGTH_ERR: - return IBV_WC_LOC_LEN_ERR; - case MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR: - return IBV_WC_LOC_QP_OP_ERR; - case MLX4_CQE_SYNDROME_LOCAL_PROT_ERR: - return IBV_WC_LOC_PROT_ERR; - case MLX4_CQE_SYNDROME_WR_FLUSH_ERR: - return IBV_WC_WR_FLUSH_ERR; - case MLX4_CQE_SYNDROME_MW_BIND_ERR: - return IBV_WC_MW_BIND_ERR; - case MLX4_CQE_SYNDROME_BAD_RESP_ERR: - return IBV_WC_BAD_RESP_ERR; - case MLX4_CQE_SYNDROME_LOCAL_ACCESS_ERR: - return IBV_WC_LOC_ACCESS_ERR; - case MLX4_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR: - return IBV_WC_REM_INV_REQ_ERR; - case MLX4_CQE_SYNDROME_REMOTE_ACCESS_ERR: - return IBV_WC_REM_ACCESS_ERR; - case MLX4_CQE_SYNDROME_REMOTE_OP_ERR: - return IBV_WC_REM_OP_ERR; - case MLX4_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR: - return IBV_WC_RETRY_EXC_ERR; - case MLX4_CQE_SYNDROME_RNR_RETRY_EXC_ERR: - return IBV_WC_RNR_RETRY_EXC_ERR; - case MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR: - return IBV_WC_REM_ABORT_ERR; - default: - return IBV_WC_GENERAL_ERR; - } -} - -static inline void handle_good_req(struct ibv_wc *wc, struct mlx4_cqe *cqe) -{ - wc->wc_flags = 0; - switch (mlx4dv_get_cqe_opcode(cqe)) { - case MLX4_OPCODE_RDMA_WRITE_IMM: - wc->wc_flags |= IBV_WC_WITH_IMM; - SWITCH_FALLTHROUGH; - case MLX4_OPCODE_RDMA_WRITE: - wc->opcode = IBV_WC_RDMA_WRITE; - break; - case MLX4_OPCODE_SEND_IMM: - wc->wc_flags |= IBV_WC_WITH_IMM; - SWITCH_FALLTHROUGH; - case MLX4_OPCODE_SEND: - case MLX4_OPCODE_SEND_INVAL: - wc->opcode = IBV_WC_SEND; - break; - case MLX4_OPCODE_RDMA_READ: - wc->opcode = IBV_WC_RDMA_READ; - wc->byte_len = be32toh(cqe->byte_cnt); - break; - case MLX4_OPCODE_ATOMIC_CS: - wc->opcode = IBV_WC_COMP_SWAP; - wc->byte_len = 8; - break; - case MLX4_OPCODE_ATOMIC_FA: - wc->opcode = IBV_WC_FETCH_ADD; - wc->byte_len = 8; - break; - case MLX4_OPCODE_LOCAL_INVAL: - wc->opcode = IBV_WC_LOCAL_INV; - break; - case MLX4_OPCODE_BIND_MW: - wc->opcode = IBV_WC_BIND_MW; - break; - default: - /* assume it's a send completion */ - wc->opcode = IBV_WC_SEND; - break; - } -} - -static inline int mlx4_get_next_cqe(struct mlx4_cq *cq, - struct mlx4_cqe **pcqe) - ALWAYS_INLINE; -static inline int mlx4_get_next_cqe(struct mlx4_cq *cq, - struct mlx4_cqe **pcqe) -{ - struct mlx4_cqe *cqe; - - cqe = next_cqe_sw(cq); - if (!cqe) - return CQ_EMPTY; - - if (cq->cqe_size == 64) - ++cqe; - - ++cq->cons_index; - - VALGRIND_MAKE_MEM_DEFINED(cqe, sizeof *cqe); - - /* - * Make sure we read CQ entry contents after we've checked the - * ownership bit. - */ - udma_from_device_barrier(); - - *pcqe = cqe; - - return CQ_OK; -} - -static inline int mlx4_parse_cqe(struct mlx4_cq *cq, - struct mlx4_cqe *cqe, - struct mlx4_qp **cur_qp, - struct ibv_wc *wc, int lazy) - ALWAYS_INLINE; -static inline int mlx4_parse_cqe(struct mlx4_cq *cq, - struct mlx4_cqe *cqe, - struct mlx4_qp **cur_qp, - struct ibv_wc *wc, int lazy) -{ - struct mlx4_wq *wq; - struct mlx4_srq *srq; - uint32_t qpn; - uint32_t g_mlpath_rqpn; - uint64_t *pwr_id; - uint16_t wqe_index; - struct mlx4_err_cqe *ecqe; - struct mlx4_context *mctx; - int is_error; - int is_send; - enum ibv_wc_status *pstatus; - - mctx = to_mctx(cq->ibv_cq.context); - qpn = be32toh(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK; - if (lazy) { - cq->cqe = cqe; - cq->flags &= (~MLX4_CQ_FLAGS_RX_CSUM_VALID); - } else - wc->qp_num = qpn; - - is_send = cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK; - is_error = (mlx4dv_get_cqe_opcode(cqe)) == - MLX4_CQE_OPCODE_ERROR; - - if ((qpn & MLX4_XRC_QPN_BIT) && !is_send) { - /* - * We do not have to take the XSRQ table lock here, - * because CQs will be locked while SRQs are removed - * from the table. - */ - srq = mlx4_find_xsrq(&mctx->xsrq_table, - be32toh(cqe->g_mlpath_rqpn) & MLX4_CQE_QPN_MASK); - if (!srq) - return CQ_POLL_ERR; - } else { - if (!*cur_qp || (qpn != (*cur_qp)->qpn_cache)) { - /* - * We do not have to take the QP table lock here, - * because CQs will be locked while QPs are removed - * from the table. - */ - *cur_qp = mlx4_find_qp(mctx, qpn); - if (!*cur_qp) - return CQ_POLL_ERR; - } - srq = ((*cur_qp)->type == MLX4_RSC_TYPE_SRQ) ? - to_msrq((*cur_qp)->verbs_qp.qp.srq) : NULL; - } - - pwr_id = lazy ? &cq->ibv_cq.wr_id : &wc->wr_id; - if (is_send) { - wq = &(*cur_qp)->sq; - wqe_index = be16toh(cqe->wqe_index); - wq->tail += (uint16_t) (wqe_index - (uint16_t) wq->tail); - *pwr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; - ++wq->tail; - } else if (srq) { - wqe_index = be16toh(cqe->wqe_index); - *pwr_id = srq->wrid[wqe_index]; - mlx4_free_srq_wqe(srq, wqe_index); - } else { - wq = &(*cur_qp)->rq; - *pwr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; - ++wq->tail; - } - - pstatus = lazy ? &cq->ibv_cq.status : &wc->status; - if (is_error) { - ecqe = (struct mlx4_err_cqe *)cqe; - *pstatus = mlx4_handle_error_cqe(ecqe); - if (!lazy) - wc->vendor_err = ecqe->vendor_err; - return CQ_OK; - } - - *pstatus = IBV_WC_SUCCESS; - if (lazy) { - if (!is_send) - if ((*cur_qp) && ((*cur_qp)->qp_cap_cache & MLX4_RX_CSUM_VALID)) - cq->flags |= MLX4_CQ_FLAGS_RX_CSUM_VALID; - } else if (is_send) { - handle_good_req(wc, cqe); - } else { - wc->byte_len = be32toh(cqe->byte_cnt); - - switch (mlx4dv_get_cqe_opcode(cqe)) { - case MLX4_RECV_OPCODE_RDMA_WRITE_IMM: - wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM; - wc->wc_flags = IBV_WC_WITH_IMM; - wc->imm_data = cqe->immed_rss_invalid; - break; - case MLX4_RECV_OPCODE_SEND_INVAL: - wc->opcode = IBV_WC_RECV; - wc->wc_flags |= IBV_WC_WITH_INV; - wc->invalidated_rkey = be32toh(cqe->immed_rss_invalid); - break; - case MLX4_RECV_OPCODE_SEND: - wc->opcode = IBV_WC_RECV; - wc->wc_flags = 0; - break; - case MLX4_RECV_OPCODE_SEND_IMM: - wc->opcode = IBV_WC_RECV; - wc->wc_flags = IBV_WC_WITH_IMM; - wc->imm_data = cqe->immed_rss_invalid; - break; - } - - wc->slid = be16toh(cqe->rlid); - g_mlpath_rqpn = be32toh(cqe->g_mlpath_rqpn); - wc->src_qp = g_mlpath_rqpn & 0xffffff; - wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f; - wc->wc_flags |= g_mlpath_rqpn & 0x80000000 ? IBV_WC_GRH : 0; - wc->pkey_index = be32toh(cqe->immed_rss_invalid) & 0x7f; - /* When working with xrc srqs, don't have qp to check link layer. - * Using IB SL, should consider Roce. (TBD) - */ - if ((*cur_qp) && (*cur_qp)->link_layer == IBV_LINK_LAYER_ETHERNET) - wc->sl = be16toh(cqe->sl_vid) >> 13; - else - wc->sl = be16toh(cqe->sl_vid) >> 12; - - if ((*cur_qp) && ((*cur_qp)->qp_cap_cache & MLX4_RX_CSUM_VALID)) { - wc->wc_flags |= ((cqe->status & htobe32(MLX4_CQE_STATUS_IPV4_CSUM_OK)) == - htobe32(MLX4_CQE_STATUS_IPV4_CSUM_OK)) << - IBV_WC_IP_CSUM_OK_SHIFT; - } - } - - return CQ_OK; -} - -static inline int mlx4_parse_lazy_cqe(struct mlx4_cq *cq, - struct mlx4_cqe *cqe) - ALWAYS_INLINE; -static inline int mlx4_parse_lazy_cqe(struct mlx4_cq *cq, - struct mlx4_cqe *cqe) -{ - return mlx4_parse_cqe(cq, cqe, &cq->cur_qp, NULL, 1); -} - -static inline int mlx4_poll_one(struct mlx4_cq *cq, - struct mlx4_qp **cur_qp, - struct ibv_wc *wc) - ALWAYS_INLINE; -static inline int mlx4_poll_one(struct mlx4_cq *cq, - struct mlx4_qp **cur_qp, - struct ibv_wc *wc) -{ - struct mlx4_cqe *cqe; - int err; - - err = mlx4_get_next_cqe(cq, &cqe); - if (err == CQ_EMPTY) - return err; - - return mlx4_parse_cqe(cq, cqe, cur_qp, wc, 0); -} - -int mlx4_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) -{ - struct mlx4_cq *cq = to_mcq(ibcq); - struct mlx4_qp *qp = NULL; - int npolled; - int err = CQ_OK; - - pthread_spin_lock(&cq->lock); - - for (npolled = 0; npolled < ne; ++npolled) { - err = mlx4_poll_one(cq, &qp, wc + npolled); - if (err != CQ_OK) - break; - } - - if (npolled || err == CQ_POLL_ERR) - mlx4_update_cons_index(cq); - - pthread_spin_unlock(&cq->lock); - - return err == CQ_POLL_ERR ? err : npolled; -} - -static inline void _mlx4_end_poll(struct ibv_cq_ex *ibcq, int lock) - ALWAYS_INLINE; -static inline void _mlx4_end_poll(struct ibv_cq_ex *ibcq, int lock) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - mlx4_update_cons_index(cq); - - if (lock) - pthread_spin_unlock(&cq->lock); -} - -static inline int _mlx4_start_poll(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr, - int lock) - ALWAYS_INLINE; -static inline int _mlx4_start_poll(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr, - int lock) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - struct mlx4_cqe *cqe; - int err; - - if (unlikely(attr->comp_mask)) - return EINVAL; - - if (lock) - pthread_spin_lock(&cq->lock); - - cq->cur_qp = NULL; - - err = mlx4_get_next_cqe(cq, &cqe); - if (err == CQ_EMPTY) { - if (lock) - pthread_spin_unlock(&cq->lock); - return ENOENT; - } - - err = mlx4_parse_lazy_cqe(cq, cqe); - if (lock && err) - pthread_spin_unlock(&cq->lock); - - return err; -} - -static int mlx4_next_poll(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - struct mlx4_cqe *cqe; - int err; - - err = mlx4_get_next_cqe(cq, &cqe); - if (err == CQ_EMPTY) - return ENOENT; - - return mlx4_parse_lazy_cqe(cq, cqe); -} - -static void mlx4_end_poll(struct ibv_cq_ex *ibcq) -{ - _mlx4_end_poll(ibcq, 0); -} - -static void mlx4_end_poll_lock(struct ibv_cq_ex *ibcq) -{ - _mlx4_end_poll(ibcq, 1); -} - -static int mlx4_start_poll(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return _mlx4_start_poll(ibcq, attr, 0); -} - -static int mlx4_start_poll_lock(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return _mlx4_start_poll(ibcq, attr, 1); -} - -static enum ibv_wc_opcode mlx4_cq_read_wc_opcode(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - if (cq->cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK) { - switch (mlx4dv_get_cqe_opcode(cq->cqe)) { - case MLX4_OPCODE_RDMA_WRITE_IMM: - case MLX4_OPCODE_RDMA_WRITE: - return IBV_WC_RDMA_WRITE; - case MLX4_OPCODE_SEND_INVAL: - case MLX4_OPCODE_SEND_IMM: - case MLX4_OPCODE_SEND: - return IBV_WC_SEND; - case MLX4_OPCODE_RDMA_READ: - return IBV_WC_RDMA_READ; - case MLX4_OPCODE_ATOMIC_CS: - return IBV_WC_COMP_SWAP; - case MLX4_OPCODE_ATOMIC_FA: - return IBV_WC_FETCH_ADD; - case MLX4_OPCODE_LOCAL_INVAL: - return IBV_WC_LOCAL_INV; - case MLX4_OPCODE_BIND_MW: - return IBV_WC_BIND_MW; - } - } else { - switch (mlx4dv_get_cqe_opcode(cq->cqe)) { - case MLX4_RECV_OPCODE_RDMA_WRITE_IMM: - return IBV_WC_RECV_RDMA_WITH_IMM; - case MLX4_RECV_OPCODE_SEND_INVAL: - case MLX4_RECV_OPCODE_SEND_IMM: - case MLX4_RECV_OPCODE_SEND: - return IBV_WC_RECV; - } - } - - return 0; -} - -static uint32_t mlx4_cq_read_wc_qp_num(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be32toh(cq->cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK; -} - -static int mlx4_cq_read_wc_flags(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - int is_send = cq->cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK; - int wc_flags = 0; - - if (is_send) { - switch (mlx4dv_get_cqe_opcode(cq->cqe)) { - case MLX4_OPCODE_RDMA_WRITE_IMM: - case MLX4_OPCODE_SEND_IMM: - wc_flags |= IBV_WC_WITH_IMM; - break; - } - } else { - if (cq->flags & MLX4_CQ_FLAGS_RX_CSUM_VALID) - wc_flags |= ((cq->cqe->status & - htobe32(MLX4_CQE_STATUS_IPV4_CSUM_OK)) == - htobe32(MLX4_CQE_STATUS_IPV4_CSUM_OK)) << - IBV_WC_IP_CSUM_OK_SHIFT; - - switch (mlx4dv_get_cqe_opcode(cq->cqe)) { - case MLX4_RECV_OPCODE_RDMA_WRITE_IMM: - case MLX4_RECV_OPCODE_SEND_IMM: - wc_flags |= IBV_WC_WITH_IMM; - break; - case MLX4_RECV_OPCODE_SEND_INVAL: - wc_flags |= IBV_WC_WITH_INV; - break; - } - wc_flags |= (be32toh(cq->cqe->g_mlpath_rqpn) & 0x80000000) ? IBV_WC_GRH : 0; - } - - return wc_flags; -} - -static uint32_t mlx4_cq_read_wc_byte_len(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be32toh(cq->cqe->byte_cnt); -} - -static uint32_t mlx4_cq_read_wc_vendor_err(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - struct mlx4_err_cqe *ecqe = (struct mlx4_err_cqe *)cq->cqe; - - return ecqe->vendor_err; -} - -static __be32 mlx4_cq_read_wc_imm_data(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - switch (mlx4dv_get_cqe_opcode(cq->cqe)) { - case MLX4_RECV_OPCODE_SEND_INVAL: - /* This is returning invalidate_rkey which is in host order, see - * ibv_wc_read_invalidated_rkey - */ - return (__force __be32)be32toh(cq->cqe->immed_rss_invalid); - default: - return cq->cqe->immed_rss_invalid; - } -} - -static uint32_t mlx4_cq_read_wc_slid(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return (uint32_t)be16toh(cq->cqe->rlid); -} - -static uint8_t mlx4_cq_read_wc_sl(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - if ((cq->cur_qp) && (cq->cur_qp->link_layer == IBV_LINK_LAYER_ETHERNET)) - return be16toh(cq->cqe->sl_vid) >> 13; - else - return be16toh(cq->cqe->sl_vid) >> 12; -} - -static uint32_t mlx4_cq_read_wc_src_qp(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be32toh(cq->cqe->g_mlpath_rqpn) & 0xffffff; -} - -static uint8_t mlx4_cq_read_wc_dlid_path_bits(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return (be32toh(cq->cqe->g_mlpath_rqpn) >> 24) & 0x7f; -} - -static uint64_t mlx4_cq_read_wc_completion_ts(struct ibv_cq_ex *ibcq) -{ - struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return ((uint64_t)be32toh(cq->cqe->ts_47_16) << 16) | - (cq->cqe->ts_15_8 << 8) | - (cq->cqe->ts_7_0); -} - -void mlx4_cq_fill_pfns(struct mlx4_cq *cq, const struct ibv_cq_init_attr_ex *cq_attr) -{ - - if (cq->flags & MLX4_CQ_FLAGS_SINGLE_THREADED) { - cq->ibv_cq.start_poll = mlx4_start_poll; - cq->ibv_cq.end_poll = mlx4_end_poll; - } else { - cq->ibv_cq.start_poll = mlx4_start_poll_lock; - cq->ibv_cq.end_poll = mlx4_end_poll_lock; - } - cq->ibv_cq.next_poll = mlx4_next_poll; - - cq->ibv_cq.read_opcode = mlx4_cq_read_wc_opcode; - cq->ibv_cq.read_vendor_err = mlx4_cq_read_wc_vendor_err; - cq->ibv_cq.read_wc_flags = mlx4_cq_read_wc_flags; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_BYTE_LEN) - cq->ibv_cq.read_byte_len = mlx4_cq_read_wc_byte_len; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_IMM) - cq->ibv_cq.read_imm_data = mlx4_cq_read_wc_imm_data; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_QP_NUM) - cq->ibv_cq.read_qp_num = mlx4_cq_read_wc_qp_num; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_SRC_QP) - cq->ibv_cq.read_src_qp = mlx4_cq_read_wc_src_qp; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_SLID) - cq->ibv_cq.read_slid = mlx4_cq_read_wc_slid; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_SL) - cq->ibv_cq.read_sl = mlx4_cq_read_wc_sl; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_DLID_PATH_BITS) - cq->ibv_cq.read_dlid_path_bits = mlx4_cq_read_wc_dlid_path_bits; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP) - cq->ibv_cq.read_completion_ts = mlx4_cq_read_wc_completion_ts; -} - -int mlx4_arm_cq(struct ibv_cq *ibvcq, int solicited) -{ - struct mlx4_cq *cq = to_mcq(ibvcq); - uint64_t doorbell; - uint32_t sn; - uint32_t ci; - uint32_t cmd; - - sn = cq->arm_sn & 3; - ci = cq->cons_index & 0xffffff; - cmd = solicited ? MLX4_CQ_DB_REQ_NOT_SOL : MLX4_CQ_DB_REQ_NOT; - - doorbell = sn << 28 | cmd | cq->cqn; - doorbell <<= 32; - doorbell |= ci; - - *cq->arm_db = htobe32(sn << 28 | cmd | ci); - - /* - * Make sure that the doorbell record in host memory is - * written before ringing the doorbell via PCI MMIO. - */ - udma_to_device_barrier(); - - mmio_write64_be(to_mctx(ibvcq->context)->uar + MLX4_CQ_DOORBELL, - htobe64(doorbell)); - - return 0; -} - -void mlx4_cq_event(struct ibv_cq *cq) -{ - to_mcq(cq)->arm_sn++; -} - -void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq) -{ - struct mlx4_cqe *cqe, *dest; - uint32_t prod_index; - uint8_t owner_bit; - int nfreed = 0; - int cqe_inc = cq->cqe_size == 64 ? 1 : 0; - - if (!cq || cq->flags & MLX4_CQ_FLAGS_DV_OWNED) - return; - - /* - * First we need to find the current producer index, so we - * know where to start cleaning from. It doesn't matter if HW - * adds new entries after this loop -- the QP we're worried - * about is already in RESET, so the new entries won't come - * from our QP and therefore don't need to be checked. - */ - for (prod_index = cq->cons_index; get_sw_cqe(cq, prod_index); ++prod_index) - if (prod_index == cq->cons_index + cq->ibv_cq.cqe) - break; - - /* - * Now sweep backwards through the CQ, removing CQ entries - * that match our QP by copying older entries on top of them. - */ - while ((int) --prod_index - (int) cq->cons_index >= 0) { - cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe); - cqe += cqe_inc; - if (srq && srq->ext_srq && - (be32toh(cqe->g_mlpath_rqpn) & MLX4_CQE_QPN_MASK) == srq->verbs_srq.srq_num && - !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK)) { - mlx4_free_srq_wqe(srq, be16toh(cqe->wqe_index)); - ++nfreed; - } else if ((be32toh(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK) == qpn) { - if (srq && !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK)) - mlx4_free_srq_wqe(srq, be16toh(cqe->wqe_index)); - ++nfreed; - } else if (nfreed) { - dest = get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe); - dest += cqe_inc; - owner_bit = dest->owner_sr_opcode & MLX4_CQE_OWNER_MASK; - memcpy(dest, cqe, sizeof *cqe); - dest->owner_sr_opcode = owner_bit | - (dest->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK); - } - } - - if (nfreed) { - cq->cons_index += nfreed; - /* - * Make sure update of buffer contents is done before - * updating consumer index. - */ - udma_to_device_barrier(); - mlx4_update_cons_index(cq); - } -} - -void mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq) -{ - pthread_spin_lock(&cq->lock); - __mlx4_cq_clean(cq, qpn, srq); - pthread_spin_unlock(&cq->lock); -} - -int mlx4_get_outstanding_cqes(struct mlx4_cq *cq) -{ - uint32_t i; - - for (i = cq->cons_index; get_sw_cqe(cq, i); ++i) - ; - - return i - cq->cons_index; -} - -void mlx4_cq_resize_copy_cqes(struct mlx4_cq *cq, void *buf, int old_cqe) -{ - struct mlx4_cqe *cqe; - int i; - int cqe_inc = cq->cqe_size == 64 ? 1 : 0; - - i = cq->cons_index; - cqe = get_cqe(cq, (i & old_cqe)); - cqe += cqe_inc; - - while ((mlx4dv_get_cqe_opcode(cqe)) != MLX4_CQE_OPCODE_RESIZE) { - cqe->owner_sr_opcode = (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK) | - (((i + 1) & (cq->ibv_cq.cqe + 1)) ? MLX4_CQE_OWNER_MASK : 0); - memcpy(buf + ((i + 1) & cq->ibv_cq.cqe) * cq->cqe_size, - cqe - cqe_inc, cq->cqe_size); - ++i; - cqe = get_cqe(cq, (i & old_cqe)); - cqe += cqe_inc; - } - - ++cq->cons_index; -} - -int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent, - int entry_size) -{ - if (mlx4_alloc_buf(buf, align(nent * entry_size, dev->page_size), - dev->page_size)) - return -1; - memset(buf->buf, 0, nent * entry_size); - - return 0; -} diff --git a/usr/rdma-core/providers/mlx4/dbrec.c b/usr/rdma-core/providers/mlx4/dbrec.c deleted file mode 100644 index e6d45fcff..000000000 --- a/usr/rdma-core/providers/mlx4/dbrec.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include - -#include "mlx4.h" - -struct mlx4_db_page { - struct mlx4_db_page *prev, *next; - struct mlx4_buf buf; - int num_db; - int use_cnt; - unsigned long free[0]; -}; - -static const int db_size[] = { - [MLX4_DB_TYPE_CQ] = 8, - [MLX4_DB_TYPE_RQ] = 4, -}; - -static struct mlx4_db_page *__add_page(struct mlx4_context *context, - enum mlx4_db_type type) -{ - struct mlx4_db_page *page; - int ps = to_mdev(context->ibv_ctx.device)->page_size; - int pp; - int i; - - pp = ps / db_size[type]; - - page = malloc(sizeof *page + pp / 8); - if (!page) - return NULL; - - if (mlx4_alloc_buf(&page->buf, ps, ps)) { - free(page); - return NULL; - } - - page->num_db = pp; - page->use_cnt = 0; - for (i = 0; i < pp / (sizeof (long) * 8); ++i) - page->free[i] = ~0; - - page->prev = NULL; - page->next = context->db_list[type]; - context->db_list[type] = page; - if (page->next) - page->next->prev = page; - - return page; -} - -__be32 *mlx4_alloc_db(struct mlx4_context *context, enum mlx4_db_type type) -{ - struct mlx4_db_page *page; - __be32 *db = NULL; - int i, j; - - pthread_mutex_lock(&context->db_list_mutex); - - for (page = context->db_list[type]; page; page = page->next) - if (page->use_cnt < page->num_db) - goto found; - - page = __add_page(context, type); - if (!page) - goto out; - -found: - ++page->use_cnt; - - for (i = 0; !page->free[i]; ++i) - /* nothing */; - - j = ffsl(page->free[i]); - page->free[i] &= ~(1UL << (j - 1)); - db = page->buf.buf + (i * 8 * sizeof (long) + (j - 1)) * db_size[type]; - -out: - pthread_mutex_unlock(&context->db_list_mutex); - - return db; -} - -void mlx4_free_db(struct mlx4_context *context, enum mlx4_db_type type, - __be32 *db) -{ - struct mlx4_db_page *page; - uintptr_t ps = to_mdev(context->ibv_ctx.device)->page_size; - int i; - - pthread_mutex_lock(&context->db_list_mutex); - - for (page = context->db_list[type]; page; page = page->next) - if (((uintptr_t) db & ~(ps - 1)) == (uintptr_t) page->buf.buf) - break; - - if (!page) - goto out; - - i = ((void *) db - page->buf.buf) / db_size[type]; - page->free[i / (8 * sizeof (long))] |= 1UL << (i % (8 * sizeof (long))); - - if (!--page->use_cnt) { - if (page->prev) - page->prev->next = page->next; - else - context->db_list[type] = page->next; - if (page->next) - page->next->prev = page->prev; - - mlx4_free_buf(&page->buf); - free(page); - } - -out: - pthread_mutex_unlock(&context->db_list_mutex); -} diff --git a/usr/rdma-core/providers/mlx4/libmlx4.map b/usr/rdma-core/providers/mlx4/libmlx4.map deleted file mode 100644 index ac2c77209..000000000 --- a/usr/rdma-core/providers/mlx4/libmlx4.map +++ /dev/null @@ -1,10 +0,0 @@ -/* Export symbols should be added below according to - Documentation/versioning.md document. */ -MLX4_1.0 { - global: - mlx4dv_init_obj; - mlx4dv_query_device; - mlx4dv_create_qp; - mlx4dv_set_context_attr; - local: *; -}; diff --git a/usr/rdma-core/providers/mlx4/man/CMakeLists.txt b/usr/rdma-core/providers/mlx4/man/CMakeLists.txt deleted file mode 100644 index 99a751015..000000000 --- a/usr/rdma-core/providers/mlx4/man/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -rdma_man_pages( - mlx4dv_init_obj.3 - mlx4dv_query_device.3 - mlx4dv.7 -) diff --git a/usr/rdma-core/providers/mlx4/man/mlx4dv.7 b/usr/rdma-core/providers/mlx4/man/mlx4dv.7 deleted file mode 100644 index e3e4cdce3..000000000 --- a/usr/rdma-core/providers/mlx4/man/mlx4dv.7 +++ /dev/null @@ -1,40 +0,0 @@ -.\" -*- nroff -*- -.\" Copyright (c) 2017 Mellanox Technologies, Inc. -.\" Licensed under the OpenIB.org (MIT) - See COPYING.md -.\" -.TH MLX4DV 7 2017-04-19 1.0.0 -.SH "NAME" -mlx4dv \- Direct verbs for mlx4 devices -.br -This is low level access to mlx4 devices to perform data path operations, -without general branching performed by \fBibv_post_send\fR(3). - -.SH "DESCRIPTION" -The libibverbs API is an abstract one. It is agnostic to any underlying -provider specific implementation. While this abstraction has the advantage -of user applications portability it has a performance penalty. For some -applications optimizing performance is more important than portability. - -The mlx4 direct verbs API is intended for such applications. -It exposes mlx4 specific low level data path (send/receive/completion) -operations, allowing the application to bypass the libibverbs data path API. - -This interface consists from one hardware specific header file -with relevant inline functions and conversion logic from ibverbs structures -to mlx4 specific structures. - -The direct include of mlx4dv.h together with linkage to mlx4 library will -allow usage of this new interface. - -Once an application uses the direct flow the locking scheme is fully managed -by itself. There is an expectation that no mixed flows in the data path for both -direct/non-direct access will be by same application. - -.SH "NOTES" -.SH "SEE ALSO" -.BR ibv_post_send (3), -.BR verbs (7) - -.SH "AUTHORS" -.TP -Maor Gottlieb diff --git a/usr/rdma-core/providers/mlx4/man/mlx4dv_init_obj.3 b/usr/rdma-core/providers/mlx4/man/mlx4dv_init_obj.3 deleted file mode 100644 index d2a2bb051..000000000 --- a/usr/rdma-core/providers/mlx4/man/mlx4dv_init_obj.3 +++ /dev/null @@ -1,139 +0,0 @@ -.\" -*- nroff -*- -.\" Copyright (c) 2017 Mellanox Technologies, Inc. -.\" Licensed under the OpenIB.org (MIT) - See COPYING.md -.\" -.TH MLX4DV_INIT_OBJ 3 2017-02-02 1.0.0 -.SH "NAME" -mlx4dv_init_obj \- Initialize mlx4 direct verbs object from ibv_xxx structures -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int mlx4dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type); -.fi -.SH "DESCRIPTION" -.B mlx4dv_init_obj() -This function will initialize mlx4dv_xxx structs based on supplied type. The information -for initialization is taken from ibv_xx structs supplied as part of input. - -Request information of CQ marks its owned by direct verbs for all consumer index -related actions. The initialization type can be combination of several types together. -.PP -.nf -struct mlx4dv_qp { -.in +8 -uint32_t *rdb; -uint32_t *sdb; -struct { -.in +8 -uint32_t wqe_cnt; -int wqe_shift; -int offset; -.in -8 -} sq; -struct { -.in +8 -uint32_t wqe_cnt; -int wqe_shift; -int offset; -.in -8 -} rq; -struct { -.in +8 -void *buf; -size_t length; -.in -8 -} buf; -uint64_t comp_mask; -.in -8 -}; - -struct mlx4dv_cq { -.in +8 -struct { -.in +8 -void *buf; -size_t length; -.in -8 -} buf; -uint32_t cqe_cnt; -uint32_t cqn; -uint32_t *set_ci_db; -uint32_t *arm_db; -int arm_sn; -int cqe_size; -uint64_t comp_mask; /* Use enum mlx4dv_cq_comp_mask */ -void *cq_uar; -.in -8 -}; - -struct mlx4dv_srq { -.in +8 -struct { -.in +8 -void *buf; -size_t length; -.in -8 -} buf; -int wqe_shift; -int head; -int tail; -uint32_t *db; -uint64_t comp_mask; -.in -8 -}; - -struct mlx4dv_rwq { -.in +8 -__be32 *rdb; -struct { -.in +8 -uint32_t wqe_cnt; -int wqe_shift; -int offset; -.in -8 -} rq; -struct { -.in +8 -void *buf; -size_t length; -.in -8 -} buf; -uint64_t comp_mask; -.in -8 -}; - -struct mlx4dv_obj { -.in +8 -struct { -.in +8 -struct ibv_qp *in; -struct mlx4dv_qp *out; -.in -8 -} qp; -struct { -.in +8 -struct ibv_cq *in; -struct mlx4dv_cq *out; -.in -8 -} cq; -.in -8 -}; - -enum mlx4dv_obj_type { -.in +8 -MLX4DV_OBJ_QP = 1 << 0, -MLX4DV_OBJ_CQ = 1 << 1, -MLX4DV_OBJ_SRQ = 1 << 2, -.in -8 -}; -.fi -.SH "RETURN VALUE" -0 on success or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" - * Compatibility masks (comp_mask) are in/out fields. -.SH "SEE ALSO" -.BR mlx4dv (7) -.SH "AUTHORS" -.TP -Maor Gottlieb diff --git a/usr/rdma-core/providers/mlx4/man/mlx4dv_query_device.3 b/usr/rdma-core/providers/mlx4/man/mlx4dv_query_device.3 deleted file mode 100644 index c5ec8811b..000000000 --- a/usr/rdma-core/providers/mlx4/man/mlx4dv_query_device.3 +++ /dev/null @@ -1,42 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org (MIT) - See COPYING.md -.\" -.TH MLX4DV_QUERY_DEVICE 3 2017-06-27 1.0.0 -.SH "NAME" -mlx4dv_query_device \- Query device capabilities specific to mlx4 -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int mlx4dv_query_device(struct ibv_context *ctx_in, -.BI " struct mlx4dv_context *attrs_out); -.fi -.SH "DESCRIPTION" -.B mlx4dv_query_device() -Query mlx4 specific device information that is usable via the direct verbs interface. -.PP -This function returns a version and compatibility mask. The version represents -the format of the internal hardware structures that mlx4dv.h exposes. -Future additions of new fields to the existing structures are handled by -the comp_mask field. -.PP -.nf -struct mlx4dv_context { -.in +8 -uint8_t version; -uint32_t max_inl_recv_sz; /* Maximum supported size of inline receive */ -uint64_t comp_mask; -.in -8 -}; - -.fi -.SH "RETURN VALUE" -0 on success or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" - * Compatibility mask (comp_mask) is an in/out field. -.SH "SEE ALSO" -.BR mlx4dv (7), -.BR ibv_query_device (3) -.SH "AUTHORS" -.TP -Maor Gottlieb diff --git a/usr/rdma-core/providers/mlx4/mlx4-abi.h b/usr/rdma-core/providers/mlx4/mlx4-abi.h deleted file mode 100644 index 4f2132c2e..000000000 --- a/usr/rdma-core/providers/mlx4/mlx4-abi.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2007 Cisco, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef MLX4_ABI_H -#define MLX4_ABI_H - -#include - -#define MLX4_UVERBS_MIN_ABI_VERSION 2 -#define MLX4_UVERBS_MAX_ABI_VERSION 4 - -#define MLX4_UVERBS_NO_DEV_CAPS_ABI_VERSION 3 - -enum { - MLX4_USER_DEV_CAP_64B_CQE = 1L << 0 -}; - -struct mlx4_alloc_ucontext_resp_v3 { - struct ibv_get_context_resp ibv_resp; - __u32 qp_tab_size; - __u16 bf_reg_size; - __u16 bf_regs_per_page; -}; - -enum mlx4_query_dev_ex_resp_mask { - MLX4_QUERY_DEV_RESP_MASK_CORE_CLOCK_OFFSET = 1UL << 0, -}; - -struct mlx4_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - __u32 dev_caps; - __u32 qp_tab_size; - __u16 bf_reg_size; - __u16 bf_regs_per_page; - __u32 cqe_size; -}; - -struct mlx4_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - __u32 pdn; - __u32 reserved; -}; - -struct mlx4_create_cq { - struct ibv_create_cq ibv_cmd; - __u64 buf_addr; - __u64 db_addr; -}; - -struct mlx4_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u32 cqn; - __u32 reserved; -}; - -struct mlx4_create_cq_ex { - struct ibv_create_cq_ex ibv_cmd; - __u64 buf_addr; - __u64 db_addr; -}; - -struct mlx4_create_cq_resp_ex { - struct ibv_create_cq_resp_ex ibv_resp; - __u32 cqn; - __u32 reserved; -}; - -struct mlx4_resize_cq { - struct ibv_resize_cq ibv_cmd; - __u64 buf_addr; -}; - -struct mlx4_query_device_ex_resp { - struct ibv_query_device_resp_ex ibv_resp; - __u32 comp_mask; - __u32 response_length; - __u64 hca_core_clock_offset; - __u32 max_inl_recv_sz; - __u32 reserved; -}; - -struct mlx4_query_device_ex { - struct ibv_query_device_ex ibv_cmd; -}; - -struct mlx4_create_srq { - struct ibv_create_srq ibv_cmd; - __u64 buf_addr; - __u64 db_addr; -}; - -struct mlx4_create_xsrq { - struct ibv_create_xsrq ibv_cmd; - __u64 buf_addr; - __u64 db_addr; -}; - -struct mlx4_create_srq_resp { - struct ibv_create_srq_resp ibv_resp; - __u32 srqn; - __u32 reserved; -}; - -struct mlx4_create_qp { - struct ibv_create_qp ibv_cmd; - __u64 buf_addr; - __u64 db_addr; - __u8 log_sq_bb_count; - __u8 log_sq_stride; - __u8 sq_no_prefetch; /* was reserved in ABI 2 */ - __u8 reserved; - __u32 inl_recv_sz; -}; - -struct mlx4_create_qp_drv_ex_rss { - __u64 hash_fields_mask; /* enum ibv_rx_hash_fields */ - __u8 hash_function; /* enum ibv_rx_hash_function_flags */ - __u8 reserved[7]; - __u8 hash_key[40]; - __u32 comp_mask; - __u32 reserved1; -}; - -struct mlx4_create_qp_ex_rss { - struct ibv_create_qp_ex ibv_cmd; - struct mlx4_create_qp_drv_ex_rss drv_ex; -}; - -struct mlx4_create_qp_drv_ex { - __u64 buf_addr; - __u64 db_addr; - __u8 log_sq_bb_count; - __u8 log_sq_stride; - __u8 sq_no_prefetch; /* was reserved in ABI 2 */ - __u8 reserved[5]; -}; - -struct mlx4_create_qp_ex { - struct ibv_create_qp_ex ibv_cmd; - struct mlx4_create_qp_drv_ex drv_ex; -}; - -struct mlx4_create_qp_resp_ex { - struct ibv_create_qp_resp_ex ibv_resp; -}; - -struct mlx4_drv_create_wq { - __u64 buf_addr; - __u64 db_addr; - __u8 log_range_size; - __u8 reserved[3]; - __u32 comp_mask; -}; - -struct mlx4_create_wq { - struct ibv_create_wq ibv_cmd; - struct mlx4_drv_create_wq drv; -}; - -struct mlx4_modify_wq { - struct ibv_modify_wq ibv_cmd; - __u32 comp_mask; - __u32 reserved; -}; - -#endif /* MLX4_ABI_H */ diff --git a/usr/rdma-core/providers/mlx4/mlx4.c b/usr/rdma-core/providers/mlx4/mlx4.c deleted file mode 100644 index 6de0bee55..000000000 --- a/usr/rdma-core/providers/mlx4/mlx4.c +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright (c) 2007 Cisco, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "mlx4.h" -#include "mlx4-abi.h" - -int mlx4_cleanup_upon_device_fatal = 0; - -#ifndef PCI_VENDOR_ID_MELLANOX -#define PCI_VENDOR_ID_MELLANOX 0x15b3 -#endif - -#define HCA(v, d) VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, d, NULL) -static const struct verbs_match_ent hca_table[] = { - HCA(MELLANOX, 0x6340), /* MT25408 "Hermon" SDR */ - HCA(MELLANOX, 0x634a), /* MT25408 "Hermon" DDR */ - HCA(MELLANOX, 0x6354), /* MT25408 "Hermon" QDR */ - HCA(MELLANOX, 0x6732), /* MT25408 "Hermon" DDR PCIe gen2 */ - HCA(MELLANOX, 0x673c), /* MT25408 "Hermon" QDR PCIe gen2 */ - HCA(MELLANOX, 0x6368), /* MT25408 "Hermon" EN 10GigE */ - HCA(MELLANOX, 0x6750), /* MT25408 "Hermon" EN 10GigE PCIe gen2 */ - HCA(MELLANOX, 0x6372), /* MT25458 ConnectX EN 10GBASE-T 10GigE */ - HCA(MELLANOX, 0x675a), /* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */ - HCA(MELLANOX, 0x6764), /* MT26468 ConnectX EN 10GigE PCIe gen2*/ - HCA(MELLANOX, 0x6746), /* MT26438 ConnectX EN 40GigE PCIe gen2 5GT/s */ - HCA(MELLANOX, 0x676e), /* MT26478 ConnectX2 40GigE PCIe gen2 */ - HCA(MELLANOX, 0x1002), /* MT25400 Family [ConnectX-2 Virtual Function] */ - HCA(MELLANOX, 0x1003), /* MT27500 Family [ConnectX-3] */ - HCA(MELLANOX, 0x1004), /* MT27500 Family [ConnectX-3 Virtual Function] */ - HCA(MELLANOX, 0x1005), /* MT27510 Family */ - HCA(MELLANOX, 0x1006), /* MT27511 Family */ - HCA(MELLANOX, 0x1007), /* MT27520 Family */ - HCA(MELLANOX, 0x1008), /* MT27521 Family */ - HCA(MELLANOX, 0x1009), /* MT27530 Family */ - HCA(MELLANOX, 0x100a), /* MT27531 Family */ - HCA(MELLANOX, 0x100b), /* MT27540 Family */ - HCA(MELLANOX, 0x100c), /* MT27541 Family */ - HCA(MELLANOX, 0x100d), /* MT27550 Family */ - HCA(MELLANOX, 0x100e), /* MT27551 Family */ - HCA(MELLANOX, 0x100f), /* MT27560 Family */ - HCA(MELLANOX, 0x1010), /* MT27561 Family */ - {} -}; - -static struct ibv_context_ops mlx4_ctx_ops = { - .query_device = mlx4_query_device, - .query_port = mlx4_query_port, - .alloc_pd = mlx4_alloc_pd, - .dealloc_pd = mlx4_free_pd, - .reg_mr = mlx4_reg_mr, - .rereg_mr = mlx4_rereg_mr, - .dereg_mr = mlx4_dereg_mr, - .alloc_mw = mlx4_alloc_mw, - .dealloc_mw = mlx4_dealloc_mw, - .bind_mw = mlx4_bind_mw, - .create_cq = mlx4_create_cq, - .poll_cq = mlx4_poll_cq, - .req_notify_cq = mlx4_arm_cq, - .cq_event = mlx4_cq_event, - .resize_cq = mlx4_resize_cq, - .destroy_cq = mlx4_destroy_cq, - .create_srq = mlx4_create_srq, - .modify_srq = mlx4_modify_srq, - .query_srq = mlx4_query_srq, - .destroy_srq = mlx4_destroy_srq, - .post_srq_recv = mlx4_post_srq_recv, - .create_qp = mlx4_create_qp, - .query_qp = mlx4_query_qp, - .modify_qp = mlx4_modify_qp, - .destroy_qp = mlx4_destroy_qp, - .post_send = mlx4_post_send, - .post_recv = mlx4_post_recv, - .create_ah = mlx4_create_ah, - .destroy_ah = mlx4_destroy_ah, - .attach_mcast = ibv_cmd_attach_mcast, - .detach_mcast = ibv_cmd_detach_mcast -}; - -static void mlx4_read_env(void) -{ - char *env_value; - - env_value = getenv("MLX4_DEVICE_FATAL_CLEANUP"); - if (env_value) - mlx4_cleanup_upon_device_fatal = (strcmp(env_value, "0")) ? 1 : 0; -} - -static int mlx4_map_internal_clock(struct mlx4_device *mdev, - struct ibv_context *ibv_ctx) -{ - struct mlx4_context *context = to_mctx(ibv_ctx); - void *hca_clock_page; - - hca_clock_page = mmap(NULL, mdev->page_size, - PROT_READ, MAP_SHARED, ibv_ctx->cmd_fd, - mdev->page_size * 3); - - if (hca_clock_page == MAP_FAILED) { - fprintf(stderr, PFX - "Warning: Timestamp available,\n" - "but failed to mmap() hca core clock page.\n"); - return -1; - } - - context->hca_core_clock = hca_clock_page + - (context->core_clock.offset & (mdev->page_size - 1)); - return 0; -} - -static int mlx4_init_context(struct verbs_device *v_device, - struct ibv_context *ibv_ctx, int cmd_fd) -{ - struct mlx4_context *context; - struct ibv_get_context cmd; - struct mlx4_alloc_ucontext_resp resp; - int i; - struct mlx4_alloc_ucontext_resp_v3 resp_v3; - __u16 bf_reg_size; - struct mlx4_device *dev = to_mdev(&v_device->device); - struct verbs_context *verbs_ctx = verbs_get_ctx(ibv_ctx); - struct ibv_device_attr_ex dev_attrs; - - /* memory footprint of mlx4_context and verbs_context share - * struct ibv_context. - */ - context = to_mctx(ibv_ctx); - ibv_ctx->cmd_fd = cmd_fd; - - mlx4_read_env(); - if (dev->abi_version <= MLX4_UVERBS_NO_DEV_CAPS_ABI_VERSION) { - if (ibv_cmd_get_context(ibv_ctx, &cmd, sizeof cmd, - &resp_v3.ibv_resp, sizeof resp_v3)) - return errno; - - context->num_qps = resp_v3.qp_tab_size; - bf_reg_size = resp_v3.bf_reg_size; - context->cqe_size = sizeof (struct mlx4_cqe); - } else { - if (ibv_cmd_get_context(ibv_ctx, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) - return errno; - - context->num_qps = resp.qp_tab_size; - bf_reg_size = resp.bf_reg_size; - if (resp.dev_caps & MLX4_USER_DEV_CAP_64B_CQE) - context->cqe_size = resp.cqe_size; - else - context->cqe_size = sizeof (struct mlx4_cqe); - } - - context->qp_table_shift = ffs(context->num_qps) - 1 - MLX4_QP_TABLE_BITS; - context->qp_table_mask = (1 << context->qp_table_shift) - 1; - for (i = 0; i < MLX4_PORTS_NUM; ++i) - context->port_query_cache[i].valid = 0; - - pthread_mutex_init(&context->qp_table_mutex, NULL); - for (i = 0; i < MLX4_QP_TABLE_SIZE; ++i) - context->qp_table[i].refcnt = 0; - - for (i = 0; i < MLX4_NUM_DB_TYPE; ++i) - context->db_list[i] = NULL; - - mlx4_init_xsrq_table(&context->xsrq_table, context->num_qps); - pthread_mutex_init(&context->db_list_mutex, NULL); - - context->uar = mmap(NULL, dev->page_size, PROT_WRITE, - MAP_SHARED, cmd_fd, 0); - if (context->uar == MAP_FAILED) - return errno; - - if (bf_reg_size) { - context->bf_page = mmap(NULL, dev->page_size, - PROT_WRITE, MAP_SHARED, cmd_fd, - dev->page_size); - if (context->bf_page == MAP_FAILED) { - fprintf(stderr, PFX "Warning: BlueFlame available, " - "but failed to mmap() BlueFlame page.\n"); - context->bf_page = NULL; - context->bf_buf_size = 0; - } else { - context->bf_buf_size = bf_reg_size / 2; - context->bf_offset = 0; - pthread_spin_init(&context->bf_lock, PTHREAD_PROCESS_PRIVATE); - } - } else { - context->bf_page = NULL; - context->bf_buf_size = 0; - } - - ibv_ctx->ops = mlx4_ctx_ops; - - context->hca_core_clock = NULL; - memset(&dev_attrs, 0, sizeof(dev_attrs)); - if (!mlx4_query_device_ex(ibv_ctx, NULL, &dev_attrs, - sizeof(struct ibv_device_attr_ex))) { - context->max_qp_wr = dev_attrs.orig_attr.max_qp_wr; - context->max_sge = dev_attrs.orig_attr.max_sge; - if (context->core_clock.offset_valid) - mlx4_map_internal_clock(dev, ibv_ctx); - } - - verbs_ctx->has_comp_mask = VERBS_CONTEXT_XRCD | VERBS_CONTEXT_SRQ | - VERBS_CONTEXT_QP; - verbs_set_ctx_op(verbs_ctx, close_xrcd, mlx4_close_xrcd); - verbs_set_ctx_op(verbs_ctx, open_xrcd, mlx4_open_xrcd); - verbs_set_ctx_op(verbs_ctx, create_srq_ex, mlx4_create_srq_ex); - verbs_set_ctx_op(verbs_ctx, get_srq_num, verbs_get_srq_num); - verbs_set_ctx_op(verbs_ctx, create_qp_ex, mlx4_create_qp_ex); - verbs_set_ctx_op(verbs_ctx, open_qp, mlx4_open_qp); - verbs_set_ctx_op(verbs_ctx, ibv_create_flow, ibv_cmd_create_flow); - verbs_set_ctx_op(verbs_ctx, ibv_destroy_flow, ibv_cmd_destroy_flow); - verbs_set_ctx_op(verbs_ctx, create_cq_ex, mlx4_create_cq_ex); - verbs_set_ctx_op(verbs_ctx, query_device_ex, mlx4_query_device_ex); - verbs_set_ctx_op(verbs_ctx, query_rt_values, mlx4_query_rt_values); - verbs_set_ctx_op(verbs_ctx, create_wq, mlx4_create_wq); - verbs_set_ctx_op(verbs_ctx, modify_wq, mlx4_modify_wq); - verbs_set_ctx_op(verbs_ctx, destroy_wq, mlx4_destroy_wq); - verbs_set_ctx_op(verbs_ctx, create_rwq_ind_table, mlx4_create_rwq_ind_table); - verbs_set_ctx_op(verbs_ctx, destroy_rwq_ind_table, mlx4_destroy_rwq_ind_table); - - return 0; - -} - -static void mlx4_uninit_context(struct verbs_device *v_device, - struct ibv_context *ibv_ctx) -{ - struct mlx4_context *context = to_mctx(ibv_ctx); - - munmap(context->uar, to_mdev(&v_device->device)->page_size); - if (context->bf_page) - munmap(context->bf_page, to_mdev(&v_device->device)->page_size); - if (context->hca_core_clock) - munmap(context->hca_core_clock - context->core_clock.offset, - to_mdev(&v_device->device)->page_size); -} - -static void mlx4_uninit_device(struct verbs_device *verbs_device) -{ - struct mlx4_device *dev = to_mdev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device *mlx4_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct mlx4_device *dev; - - dev = calloc(1, sizeof *dev); - if (!dev) - return NULL; - - dev->page_size = sysconf(_SC_PAGESIZE); - dev->abi_version = sysfs_dev->abi_ver; - - dev->verbs_dev.sz = sizeof(*dev); - dev->verbs_dev.size_of_context = - sizeof(struct mlx4_context) - sizeof(struct ibv_context); - - return &dev->verbs_dev; -} - -static const struct verbs_device_ops mlx4_dev_ops = { - .name = "mlx4", - .match_min_abi_version = MLX4_UVERBS_MIN_ABI_VERSION, - .match_max_abi_version = MLX4_UVERBS_MAX_ABI_VERSION, - .match_table = hca_table, - .alloc_device = mlx4_device_alloc, - .uninit_device = mlx4_uninit_device, - .init_context = mlx4_init_context, - .uninit_context = mlx4_uninit_context, -}; -PROVIDER_DRIVER(mlx4_dev_ops); - -static int mlx4dv_get_qp(struct ibv_qp *qp_in, - struct mlx4dv_qp *qp_out) -{ - struct mlx4_qp *mqp = to_mqp(qp_in); - struct mlx4_context *ctx = to_mctx(qp_in->context); - - qp_out->comp_mask = 0; - - qp_out->buf.buf = mqp->buf.buf; - qp_out->buf.length = mqp->buf.length; - - qp_out->rdb = mqp->db; - qp_out->sdb = (uint32_t *) (ctx->uar + MLX4_SEND_DOORBELL); - qp_out->doorbell_qpn = mqp->doorbell_qpn; - - qp_out->sq.wqe_cnt = mqp->sq.wqe_cnt; - qp_out->sq.wqe_shift = mqp->sq.wqe_shift; - qp_out->sq.offset = mqp->sq.offset; - - qp_out->rq.wqe_cnt = mqp->rq.wqe_cnt; - qp_out->rq.wqe_shift = mqp->rq.wqe_shift; - qp_out->rq.offset = mqp->rq.offset; - - return 0; -} - -static int mlx4dv_get_cq(struct ibv_cq *cq_in, - struct mlx4dv_cq *cq_out) -{ - struct mlx4_cq *mcq = to_mcq(cq_in); - struct mlx4_context *mctx = to_mctx(cq_in->context); - uint64_t mask_out = 0; - - cq_out->buf.buf = mcq->buf.buf; - cq_out->buf.length = mcq->buf.length; - cq_out->cqn = mcq->cqn; - cq_out->set_ci_db = mcq->set_ci_db; - cq_out->arm_db = mcq->arm_db; - cq_out->arm_sn = mcq->arm_sn; - cq_out->cqe_size = mcq->cqe_size; - cq_out->cqe_cnt = mcq->ibv_cq.cqe + 1; - - mcq->flags |= MLX4_CQ_FLAGS_DV_OWNED; - - if (cq_out->comp_mask & MLX4DV_CQ_MASK_UAR) { - cq_out->cq_uar = mctx->uar; - mask_out |= MLX4DV_CQ_MASK_UAR; - } - - cq_out->comp_mask = mask_out; - return 0; -} - -static int mlx4dv_get_srq(struct ibv_srq *srq_in, - struct mlx4dv_srq *srq_out) -{ - struct mlx4_srq *msrq = to_msrq(srq_in); - - srq_out->comp_mask = 0; - srq_out->buf.buf = msrq->buf.buf; - srq_out->buf.length = msrq->buf.length; - srq_out->wqe_shift = msrq->wqe_shift; - srq_out->head = msrq->head; - srq_out->tail = msrq->tail; - srq_out->db = msrq->db; - - return 0; -} - -static int mlx4dv_get_rwq(struct ibv_wq *wq_in, struct mlx4dv_rwq *wq_out) -{ - struct mlx4_qp *mqp = wq_to_mqp(wq_in); - - wq_out->comp_mask = 0; - - wq_out->buf.buf = mqp->buf.buf; - wq_out->buf.length = mqp->buf.length; - - wq_out->rdb = mqp->db; - - wq_out->rq.wqe_cnt = mqp->rq.wqe_cnt; - wq_out->rq.wqe_shift = mqp->rq.wqe_shift; - wq_out->rq.offset = mqp->rq.offset; - - return 0; -} - -int mlx4dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type) -{ - int ret = 0; - - if (obj_type & MLX4DV_OBJ_QP) - ret = mlx4dv_get_qp(obj->qp.in, obj->qp.out); - if (!ret && (obj_type & MLX4DV_OBJ_CQ)) - ret = mlx4dv_get_cq(obj->cq.in, obj->cq.out); - if (!ret && (obj_type & MLX4DV_OBJ_SRQ)) - ret = mlx4dv_get_srq(obj->srq.in, obj->srq.out); - if (!ret && (obj_type & MLX4DV_OBJ_RWQ)) - ret = mlx4dv_get_rwq(obj->rwq.in, obj->rwq.out); - - return ret; -} - -int mlx4dv_query_device(struct ibv_context *ctx_in, - struct mlx4dv_context *attrs_out) -{ - struct mlx4_context *mctx = to_mctx(ctx_in); - - attrs_out->version = 0; - attrs_out->comp_mask = 0; - - attrs_out->max_inl_recv_sz = mctx->max_inl_recv_sz; - - return 0; -} - -int mlx4dv_set_context_attr(struct ibv_context *context, - enum mlx4dv_set_ctx_attr_type attr_type, - void *attr) -{ - struct mlx4_context *ctx = to_mctx(context); - - switch (attr_type) { - case MLX4DV_SET_CTX_ATTR_LOG_WQS_RANGE_SZ: - ctx->log_wqs_range_sz = *((uint8_t *)attr); - break; - default: - return ENOTSUP; - } - - return 0; -} diff --git a/usr/rdma-core/providers/mlx4/mlx4.conf b/usr/rdma-core/providers/mlx4/mlx4.conf deleted file mode 100644 index c8b4cce6e..000000000 --- a/usr/rdma-core/providers/mlx4/mlx4.conf +++ /dev/null @@ -1,21 +0,0 @@ -# This file is intended for users to select the various module options -# they need for the mlx4 driver. On upgrade of the rdma package, -# any user made changes to this file are preserved. Any changes made -# to the libmlx4.conf file in this directory are overwritten on -# pacakge upgrade. -# -# Some sample options and what they would do -# Enable debugging output, device managed flow control, and disable SRIOV -#options mlx4_core debug_level=1 log_num_mgm_entry_size=-1 probe_vf=0 num_vfs=0 -# -# Enable debugging output and create SRIOV devices, but don't attach any of -# the child devices to the host, only the parent device -#options mlx4_core debug_level=1 probe_vf=0 num_vfs=7 -# -# Enable debugging output, SRIOV, and attach one of the SRIOV child devices -# in addition to the parent device to the host -#options mlx4_core debug_level=1 probe_vf=1 num_vfs=7 -# -# Enable per priority flow control for send and receive, setting both priority -# 1 and 2 as no drop priorities -#options mlx4_en pfctx=3 pfcrx=3 diff --git a/usr/rdma-core/providers/mlx4/mlx4.h b/usr/rdma-core/providers/mlx4/mlx4.h deleted file mode 100644 index 14f272018..000000000 --- a/usr/rdma-core/providers/mlx4/mlx4.h +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef MLX4_H -#define MLX4_H - -#include -#include -#include - -#include -#include -#include - -#include "mlx4dv.h" - -#define MLX4_PORTS_NUM 2 - -#include - -#define PFX "mlx4: " - -enum { - MLX4_STAT_RATE_OFFSET = 5 -}; - -enum { - MLX4_QP_TABLE_BITS = 8, - MLX4_QP_TABLE_SIZE = 1 << MLX4_QP_TABLE_BITS, - MLX4_QP_TABLE_MASK = MLX4_QP_TABLE_SIZE - 1 -}; - -#define MLX4_REMOTE_SRQN_FLAGS(wr) htobe32(wr->qp_type.xrc.remote_srqn << 8) - -enum { - MLX4_XSRQ_TABLE_BITS = 8, - MLX4_XSRQ_TABLE_SIZE = 1 << MLX4_XSRQ_TABLE_BITS, - MLX4_XSRQ_TABLE_MASK = MLX4_XSRQ_TABLE_SIZE - 1 -}; - -struct mlx4_xsrq_table { - struct { - struct mlx4_srq **table; - int refcnt; - } xsrq_table[MLX4_XSRQ_TABLE_SIZE]; - - pthread_mutex_t mutex; - int num_xsrq; - int shift; - int mask; -}; - -enum { - MLX4_XRC_QPN_BIT = (1 << 23) -}; - -enum mlx4_db_type { - MLX4_DB_TYPE_CQ, - MLX4_DB_TYPE_RQ, - MLX4_NUM_DB_TYPE -}; - -struct mlx4_device { - struct verbs_device verbs_dev; - int page_size; - int abi_version; -}; - -struct mlx4_db_page; - -struct mlx4_context { - struct ibv_context ibv_ctx; - - void *uar; - - void *bf_page; - int bf_buf_size; - int bf_offset; - pthread_spinlock_t bf_lock; - - struct { - struct mlx4_qp **table; - int refcnt; - } qp_table[MLX4_QP_TABLE_SIZE]; - pthread_mutex_t qp_table_mutex; - int num_qps; - int qp_table_shift; - int qp_table_mask; - int max_qp_wr; - int max_sge; - - struct mlx4_db_page *db_list[MLX4_NUM_DB_TYPE]; - pthread_mutex_t db_list_mutex; - int cqe_size; - struct mlx4_xsrq_table xsrq_table; - struct { - uint8_t valid; - uint8_t link_layer; - enum ibv_port_cap_flags caps; - } port_query_cache[MLX4_PORTS_NUM]; - struct { - uint64_t offset; - uint8_t offset_valid; - } core_clock; - void *hca_core_clock; - uint32_t max_inl_recv_sz; - uint8_t log_wqs_range_sz; -}; - -struct mlx4_buf { - void *buf; - size_t length; -}; - -struct mlx4_pd { - struct ibv_pd ibv_pd; - uint32_t pdn; -}; - -enum { - MLX4_CQ_FLAGS_RX_CSUM_VALID = 1 << 0, - MLX4_CQ_FLAGS_EXTENDED = 1 << 1, - MLX4_CQ_FLAGS_SINGLE_THREADED = 1 << 2, - MLX4_CQ_FLAGS_DV_OWNED = 1 << 3, -}; - -struct mlx4_cq { - struct ibv_cq_ex ibv_cq; - struct mlx4_buf buf; - struct mlx4_buf resize_buf; - pthread_spinlock_t lock; - uint32_t cqn; - uint32_t cons_index; - __be32 *set_ci_db; - __be32 *arm_db; - int arm_sn; - int cqe_size; - struct mlx4_qp *cur_qp; - struct mlx4_cqe *cqe; - uint32_t flags; -}; - -struct mlx4_srq { - struct verbs_srq verbs_srq; - struct mlx4_buf buf; - pthread_spinlock_t lock; - uint64_t *wrid; - uint32_t srqn; - int max; - int max_gs; - int wqe_shift; - int head; - int tail; - __be32 *db; - uint16_t counter; - uint8_t ext_srq; -}; - -struct mlx4_wq { - uint64_t *wrid; - pthread_spinlock_t lock; - int wqe_cnt; - int max_post; - unsigned head; - unsigned tail; - int max_gs; - int wqe_shift; - int offset; -}; - -enum mlx4_rsc_type { - MLX4_RSC_TYPE_QP = 0, - MLX4_RSC_TYPE_RSS_QP = 1, - MLX4_RSC_TYPE_SRQ = 2, -}; - -struct mlx4_qp { - union { - struct verbs_qp verbs_qp; - struct ibv_wq wq; - }; - struct mlx4_buf buf; - int max_inline_data; - int buf_size; - - __be32 doorbell_qpn; - __be32 sq_signal_bits; - int sq_spare_wqes; - struct mlx4_wq sq; - - __be32 *db; - struct mlx4_wq rq; - - uint8_t link_layer; - uint8_t type; /* enum mlx4_rsc_type */ - uint32_t qp_cap_cache; - uint32_t qpn_cache; -}; - -struct mlx4_ah { - struct ibv_ah ibv_ah; - struct mlx4_av av; - uint16_t vlan; - uint8_t mac[6]; -}; - -enum { - MLX4_CSUM_SUPPORT_UD_OVER_IB = (1 << 0), - MLX4_CSUM_SUPPORT_RAW_OVER_ETH = (1 << 1), - /* Only report rx checksum when the validation is valid */ - MLX4_RX_CSUM_VALID = (1 << 16), -}; - -static inline unsigned long align(unsigned long val, unsigned long align) -{ - return (val + align - 1) & ~(align - 1); -} -int align_queue_size(int req); - -#define to_mxxx(xxx, type) \ - ((struct mlx4_##type *) \ - ((void *) ib##xxx - offsetof(struct mlx4_##type, ibv_##xxx))) - -static inline struct mlx4_device *to_mdev(struct ibv_device *ibdev) -{ - /* ibv_device is first field of verbs_device - * see try_driver() in libibverbs. - */ - return container_of(ibdev, struct mlx4_device, verbs_dev); -} - -static inline struct mlx4_context *to_mctx(struct ibv_context *ibctx) -{ - return to_mxxx(ctx, context); -} - -static inline struct mlx4_pd *to_mpd(struct ibv_pd *ibpd) -{ - return to_mxxx(pd, pd); -} - -static inline struct mlx4_cq *to_mcq(struct ibv_cq *ibcq) -{ - return to_mxxx(cq, cq); -} - -static inline struct mlx4_srq *to_msrq(struct ibv_srq *ibsrq) -{ - return container_of(container_of(ibsrq, struct verbs_srq, srq), - struct mlx4_srq, verbs_srq); -} - -static inline struct mlx4_qp *to_mqp(struct ibv_qp *ibqp) -{ - return container_of(container_of(ibqp, struct verbs_qp, qp), - struct mlx4_qp, verbs_qp); -} - -static inline struct mlx4_qp *wq_to_mqp(struct ibv_wq *ibwq) -{ - return container_of(ibwq, struct mlx4_qp, wq); -} - -static inline struct mlx4_ah *to_mah(struct ibv_ah *ibah) -{ - return to_mxxx(ah, ah); -} - -static inline void mlx4_update_cons_index(struct mlx4_cq *cq) -{ - *cq->set_ci_db = htobe32(cq->cons_index & 0xffffff); -} - -extern int mlx4_cleanup_upon_device_fatal; -static inline int cleanup_on_fatal(int ret) -{ - return (ret == EIO && mlx4_cleanup_upon_device_fatal); -} - -int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size); -void mlx4_free_buf(struct mlx4_buf *buf); - -__be32 *mlx4_alloc_db(struct mlx4_context *context, enum mlx4_db_type type); -void mlx4_free_db(struct mlx4_context *context, enum mlx4_db_type type, - __be32 *db); - -int mlx4_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); -int mlx4_query_device_ex(struct ibv_context *context, - const struct ibv_query_device_ex_input *input, - struct ibv_device_attr_ex *attr, - size_t attr_size); -int mlx4_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); -int mlx4_query_rt_values(struct ibv_context *context, - struct ibv_values_ex *values); -struct ibv_pd *mlx4_alloc_pd(struct ibv_context *context); -int mlx4_free_pd(struct ibv_pd *pd); -struct ibv_xrcd *mlx4_open_xrcd(struct ibv_context *context, - struct ibv_xrcd_init_attr *attr); -int mlx4_close_xrcd(struct ibv_xrcd *xrcd); - -struct ibv_mr *mlx4_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); -int mlx4_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd, - void *addr, size_t length, int access); -int mlx4_dereg_mr(struct ibv_mr *mr); - -struct ibv_mw *mlx4_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type); -int mlx4_dealloc_mw(struct ibv_mw *mw); -int mlx4_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw, - struct ibv_mw_bind *mw_bind); - -struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); -struct ibv_cq_ex *mlx4_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr); -void mlx4_cq_fill_pfns(struct mlx4_cq *cq, const struct ibv_cq_init_attr_ex *cq_attr); -int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent, - int entry_size); -int mlx4_resize_cq(struct ibv_cq *cq, int cqe); -int mlx4_destroy_cq(struct ibv_cq *cq); -int mlx4_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -int mlx4_arm_cq(struct ibv_cq *cq, int solicited); -void mlx4_cq_event(struct ibv_cq *cq); -void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq); -void mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq); -int mlx4_get_outstanding_cqes(struct mlx4_cq *cq); -void mlx4_cq_resize_copy_cqes(struct mlx4_cq *cq, void *buf, int new_cqe); - -struct ibv_srq *mlx4_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); -struct ibv_srq *mlx4_create_srq_ex(struct ibv_context *context, - struct ibv_srq_init_attr_ex *attr_ex); -struct ibv_srq *mlx4_create_xrc_srq(struct ibv_context *context, - struct ibv_srq_init_attr_ex *attr_ex); -int mlx4_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int mask); -int mlx4_query_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr); -int mlx4_destroy_srq(struct ibv_srq *srq); -int mlx4_destroy_xrc_srq(struct ibv_srq *srq); -int mlx4_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr, - struct mlx4_srq *srq); -void mlx4_init_xsrq_table(struct mlx4_xsrq_table *xsrq_table, int size); -struct mlx4_srq *mlx4_find_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn); -int mlx4_store_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn, - struct mlx4_srq *srq); -void mlx4_clear_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn); -void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind); -int mlx4_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr); -struct ibv_qp *mlx4_create_qp_ex(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr); -struct ibv_qp *mlx4_open_qp(struct ibv_context *context, struct ibv_qp_open_attr *attr); -int mlx4_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); -int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); -int mlx4_destroy_qp(struct ibv_qp *qp); -void mlx4_init_qp_indices(struct mlx4_qp *qp); -void mlx4_qp_init_sq_ownership(struct mlx4_qp *qp); -int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type, - struct mlx4_qp *qp); -int mlx4_alloc_qp_buf(struct ibv_context *context, uint32_t max_recv_sge, - enum ibv_qp_type type, struct mlx4_qp *qp, - struct mlx4dv_qp_init_attr *mlx4qp_attr); -void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap, - enum ibv_qp_type type); -struct mlx4_qp *mlx4_find_qp(struct mlx4_context *ctx, uint32_t qpn); -int mlx4_store_qp(struct mlx4_context *ctx, uint32_t qpn, struct mlx4_qp *qp); -void mlx4_clear_qp(struct mlx4_context *ctx, uint32_t qpn); -struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr); -int mlx4_destroy_ah(struct ibv_ah *ah); -int mlx4_alloc_av(struct mlx4_pd *pd, struct ibv_ah_attr *attr, - struct mlx4_ah *ah); -void mlx4_free_av(struct mlx4_ah *ah); -struct ibv_wq *mlx4_create_wq(struct ibv_context *context, - struct ibv_wq_init_attr *attr); -int mlx4_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr); -int mlx4_destroy_wq(struct ibv_wq *wq); -struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context, - struct ibv_rwq_ind_table_init_attr *init_attr); -int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table); -int mlx4_post_wq_recv(struct ibv_wq *ibwq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -#endif /* MLX4_H */ diff --git a/usr/rdma-core/providers/mlx4/mlx4dv.h b/usr/rdma-core/providers/mlx4/mlx4dv.h deleted file mode 100644 index d47d3cd2e..000000000 --- a/usr/rdma-core/providers/mlx4/mlx4dv.h +++ /dev/null @@ -1,532 +0,0 @@ -/* - * Copyright (c) 2017 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _MLX4DV_H_ -#define _MLX4DV_H_ - -#include -#include -#include - -/* Always inline the functions */ -#ifdef __GNUC__ -#define MLX4DV_ALWAYS_INLINE inline __attribute__((always_inline)) -#else -#define MLX4DV_ALWAYS_INLINE inline -#endif - -enum { - MLX4_OPCODE_NOP = 0x00, - MLX4_OPCODE_SEND_INVAL = 0x01, - MLX4_OPCODE_RDMA_WRITE = 0x08, - MLX4_OPCODE_RDMA_WRITE_IMM = 0x09, - MLX4_OPCODE_SEND = 0x0a, - MLX4_OPCODE_SEND_IMM = 0x0b, - MLX4_OPCODE_LSO = 0x0e, - MLX4_OPCODE_RDMA_READ = 0x10, - MLX4_OPCODE_ATOMIC_CS = 0x11, - MLX4_OPCODE_ATOMIC_FA = 0x12, - MLX4_OPCODE_MASKED_ATOMIC_CS = 0x14, - MLX4_OPCODE_MASKED_ATOMIC_FA = 0x15, - MLX4_OPCODE_BIND_MW = 0x18, - MLX4_OPCODE_FMR = 0x19, - MLX4_OPCODE_LOCAL_INVAL = 0x1b, - MLX4_OPCODE_CONFIG_CMD = 0x1f, - - MLX4_RECV_OPCODE_RDMA_WRITE_IMM = 0x00, - MLX4_RECV_OPCODE_SEND = 0x01, - MLX4_RECV_OPCODE_SEND_IMM = 0x02, - MLX4_RECV_OPCODE_SEND_INVAL = 0x03, - - MLX4_CQE_OPCODE_ERROR = 0x1e, - MLX4_CQE_OPCODE_RESIZE = 0x16, -}; - -enum { - MLX4_CQ_DOORBELL = 0x20 -}; - -#define MLX4_CQ_DB_REQ_NOT_SOL (1 << 24) -#define MLX4_CQ_DB_REQ_NOT (2 << 24) - -enum { - MLX4_CQE_VLAN_PRESENT_MASK = 1 << 29, - MLX4_CQE_QPN_MASK = 0xffffff, -}; - -enum { - MLX4_CQE_OWNER_MASK = 0x80, - MLX4_CQE_IS_SEND_MASK = 0x40, - MLX4_CQE_OPCODE_MASK = 0x1f -}; - -enum { - MLX4_CQE_SYNDROME_LOCAL_LENGTH_ERR = 0x01, - MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR = 0x02, - MLX4_CQE_SYNDROME_LOCAL_PROT_ERR = 0x04, - MLX4_CQE_SYNDROME_WR_FLUSH_ERR = 0x05, - MLX4_CQE_SYNDROME_MW_BIND_ERR = 0x06, - MLX4_CQE_SYNDROME_BAD_RESP_ERR = 0x10, - MLX4_CQE_SYNDROME_LOCAL_ACCESS_ERR = 0x11, - MLX4_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12, - MLX4_CQE_SYNDROME_REMOTE_ACCESS_ERR = 0x13, - MLX4_CQE_SYNDROME_REMOTE_OP_ERR = 0x14, - MLX4_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR = 0x15, - MLX4_CQE_SYNDROME_RNR_RETRY_EXC_ERR = 0x16, - MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR = 0x22, -}; - -struct mlx4_err_cqe { - uint32_t vlan_my_qpn; - uint32_t reserved1[5]; - uint16_t wqe_index; - uint8_t vendor_err; - uint8_t syndrome; - uint8_t reserved2[3]; - uint8_t owner_sr_opcode; -}; - -enum mlx4_cqe_status { - MLX4_CQE_STATUS_TCP_UDP_CSUM_OK = (1 << 2), - MLX4_CQE_STATUS_IPV4_PKT = (1 << 22), - MLX4_CQE_STATUS_IP_HDR_CSUM_OK = (1 << 28), - MLX4_CQE_STATUS_IPV4_CSUM_OK = MLX4_CQE_STATUS_IPV4_PKT | - MLX4_CQE_STATUS_IP_HDR_CSUM_OK | - MLX4_CQE_STATUS_TCP_UDP_CSUM_OK -}; - -struct mlx4_cqe { - __be32 vlan_my_qpn; - __be32 immed_rss_invalid; - __be32 g_mlpath_rqpn; - union { - struct { - __be16 sl_vid; - __be16 rlid; - }; - __be32 ts_47_16; - }; - __be32 status; - __be32 byte_cnt; - __be16 wqe_index; - __be16 checksum; - uint8_t reserved3; - uint8_t ts_15_8; - uint8_t ts_7_0; - uint8_t owner_sr_opcode; -}; - -struct mlx4dv_qp { - __be32 *rdb; - uint32_t *sdb; - __be32 doorbell_qpn; - struct { - uint32_t wqe_cnt; - int wqe_shift; - int offset; - } sq; - struct { - uint32_t wqe_cnt; - int wqe_shift; - int offset; - } rq; - struct { - void *buf; - size_t length; - } buf; - uint64_t comp_mask; -}; - -enum mlx4dv_cq_comp_mask { - MLX4DV_CQ_MASK_UAR = 1 << 0, -}; - -struct mlx4dv_cq { - struct { - void *buf; - size_t length; - } buf; - uint32_t cqe_cnt; - uint32_t cqn; - __be32 *set_ci_db; - __be32 *arm_db; - int arm_sn; - int cqe_size; - uint64_t comp_mask; - void *cq_uar; -}; - -struct mlx4dv_srq { - struct { - void *buf; - size_t length; - } buf; - int wqe_shift; - int head; - int tail; - __be32 *db; - uint64_t comp_mask; -}; - -struct mlx4dv_rwq { - __be32 *rdb; - struct { - uint32_t wqe_cnt; - int wqe_shift; - int offset; - } rq; - struct { - void *buf; - size_t length; - } buf; - uint64_t comp_mask; -}; - -struct mlx4dv_obj { - struct { - struct ibv_qp *in; - struct mlx4dv_qp *out; - } qp; - struct { - struct ibv_cq *in; - struct mlx4dv_cq *out; - } cq; - struct { - struct ibv_srq *in; - struct mlx4dv_srq *out; - } srq; - struct { - struct ibv_wq *in; - struct mlx4dv_rwq *out; - } rwq; -}; - -enum mlx4dv_obj_type { - MLX4DV_OBJ_QP = 1 << 0, - MLX4DV_OBJ_CQ = 1 << 1, - MLX4DV_OBJ_SRQ = 1 << 2, - MLX4DV_OBJ_RWQ = 1 << 3, -}; - -/* - * This function will initialize mlx4dv_xxx structs based on supplied type. - * The information for initialization is taken from ibv_xx structs supplied - * as part of input. - * - * Request information of CQ marks its owned by DV for all consumer index - * related actions. - * - * The initialization type can be combination of several types together. - * - * Return: 0 in case of success. - */ -int mlx4dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type); - -static MLX4DV_ALWAYS_INLINE -uint8_t mlx4dv_get_cqe_owner(struct mlx4_cqe *cqe) -{ - return cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK; -} - -static MLX4DV_ALWAYS_INLINE -void mlx4dv_set_cqe_owner(struct mlx4_cqe *cqe, uint8_t val) -{ - cqe->owner_sr_opcode = (val & MLX4_CQE_OWNER_MASK) | - (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK); -} - -static MLX4DV_ALWAYS_INLINE -uint8_t mlx4dv_get_cqe_opcode(struct mlx4_cqe *cqe) -{ - return cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK; -} - -/* - * WQE related part - */ - -enum { - MLX4_SEND_DOORBELL = 0x14, -}; - -enum { - MLX4_WQE_CTRL_SOLICIT = 1 << 1, - MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2, - MLX4_WQE_CTRL_IP_HDR_CSUM = 1 << 4, - MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5, - MLX4_WQE_CTRL_FENCE = 1 << 6, - MLX4_WQE_CTRL_STRONG_ORDER = 1 << 7 -}; - -enum { - MLX4_WQE_BIND_TYPE_2 = (1<<31), - MLX4_WQE_BIND_ZERO_BASED = (1<<30), -}; - -enum { - MLX4_INLINE_SEG = 1 << 31, - MLX4_INLINE_ALIGN = 64, -}; - -enum { - MLX4_INVALID_LKEY = 0x100, -}; - -enum { - MLX4_WQE_MW_REMOTE_READ = 1 << 29, - MLX4_WQE_MW_REMOTE_WRITE = 1 << 30, - MLX4_WQE_MW_ATOMIC = 1 << 31 -}; - -struct mlx4_wqe_local_inval_seg { - uint64_t reserved1; - __be32 mem_key; - uint32_t reserved2; - uint64_t reserved3[2]; -}; - -struct mlx4_wqe_bind_seg { - __be32 flags1; - __be32 flags2; - __be32 new_rkey; - __be32 lkey; - __be64 addr; - __be64 length; -}; - -struct mlx4_wqe_ctrl_seg { - __be32 owner_opcode; - union { - struct { - uint8_t reserved[3]; - uint8_t fence_size; - }; - __be32 bf_qpn; - }; - /* - * High 24 bits are SRC remote buffer; low 8 bits are flags: - * [7] SO (strong ordering) - * [5] TCP/UDP checksum - * [4] IP checksum - * [3:2] C (generate completion queue entry) - * [1] SE (solicited event) - * [0] FL (force loopback) - */ - __be32 srcrb_flags; - /* - * imm is immediate data for send/RDMA write w/ immediate; - * also invalidation key for send with invalidate; input - * modifier for WQEs on CCQs. - */ - __be32 imm; -}; - -struct mlx4_av { - __be32 port_pd; - uint8_t reserved1; - uint8_t g_slid; - __be16 dlid; - uint8_t reserved2; - uint8_t gid_index; - uint8_t stat_rate; - uint8_t hop_limit; - __be32 sl_tclass_flowlabel; - uint8_t dgid[16]; -}; - -struct mlx4_wqe_datagram_seg { - struct mlx4_av av; - __be32 dqpn; - __be32 qkey; - __be16 vlan; - uint8_t mac[6]; -}; - -struct mlx4_wqe_data_seg { - __be32 byte_count; - __be32 lkey; - __be64 addr; -}; - -struct mlx4_wqe_inline_seg { - __be32 byte_count; -}; - -struct mlx4_wqe_srq_next_seg { - uint16_t reserved1; - __be16 next_wqe_index; - uint32_t reserved2[3]; -}; - -struct mlx4_wqe_raddr_seg { - __be64 raddr; - __be32 rkey; - __be32 reserved; -}; - -struct mlx4_wqe_atomic_seg { - __be64 swap_add; - __be64 compare; -}; - -enum mlx4dv_qp_init_attr_mask { - MLX4DV_QP_INIT_ATTR_MASK_INL_RECV = 1 << 0, - MLX4DV_QP_INIT_ATTR_MASK_RESERVED = 1 << 1, -}; - -struct mlx4dv_qp_init_attr { - uint64_t comp_mask; /* Use enum mlx4dv_qp_init_attr_mask */ - uint32_t inl_recv_sz; -}; - -struct ibv_qp *mlx4dv_create_qp(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr, - struct mlx4dv_qp_init_attr *mlx4_qp_attr); - -/* - * Direct verbs device-specific attributes - */ -struct mlx4dv_context { - uint8_t version; - uint32_t max_inl_recv_sz; - uint64_t comp_mask; -}; - -/* - * Control segment - contains some control information for the current WQE. - * - * Output: - * seg - control segment to be filled - * Input: - * owner_opcode - Opcode of this WQE (Encodes the type of operation - * to be executed on the QP) and owner bit. - * wqe_cnt - Number of queue entries. - * ind - WQEBB number of the first block of this WQE. - * fence_size - Fence bit and WQE size in octowords. - * srcrb_flags - High 24 bits are SRC remote buffer; low 8 bits are - * flags which described in mlx4_wqe_ctrl_seg struct. - * imm - Immediate data/Invalidation key. - */ -static MLX4DV_ALWAYS_INLINE -void mlx4dv_set_ctrl_seg(struct mlx4_wqe_ctrl_seg *seg, uint32_t owner_opcode, - uint8_t fence_size, uint32_t srcrb_flags, uint32_t imm) -{ - seg->owner_opcode = htobe32(owner_opcode); - seg->fence_size = fence_size; - seg->srcrb_flags = htobe32(srcrb_flags); - /* - * The caller should prepare "imm" in advance based on WR opcode. - * For IBV_WR_SEND_WITH_IMM and IBV_WR_RDMA_WRITE_WITH_IMM, - * the "imm" should be assigned as is. - * For the IBV_WR_SEND_WITH_INV, it should be htobe32(imm). - */ - seg->imm = imm; -} - -/* - * Datagram Segment - contains address information required in order - * to form a datagram message. - * - * Output: - * seg - datagram segment to be filled. - * Input: - * port_pd - Port number and protection domain. - * g_slid - GRH and source LID for IB port only. - * dlid - Remote LID. - * gid_index - Index to port GID table. - * state_rate - Maximum static rate control. - * hop_limit - IPv6 hop limit. - * sl_tclass_flowlabel - Service Level, IPv6 TClass and flow table. - * dgid - Remote GID for IB port only. - * dqpn - Destination QP. - * qkey - QKey. - * vlan - VLAN for RAW ETHERNET QP only. - * mac - Destination MAC for RAW ETHERNET QP only. - */ -static MLX4DV_ALWAYS_INLINE -void mlx4dv_set_dgram_seg(struct mlx4_wqe_datagram_seg *seg, uint32_t port_pd, - uint8_t g_slid, uint16_t dlid, uint8_t gid_index, - uint8_t stat_rate, uint8_t hop_limit, uint32_t - sl_tclass_flowlabel, uint8_t *dgid, uint32_t dqpn, - uint32_t qkey, uint16_t vlan, uint8_t *mac) -{ - seg->av.port_pd = htobe32(port_pd); - seg->av.g_slid = g_slid; - seg->av.dlid = htobe16(dlid); - seg->av.gid_index = gid_index; - seg->av.stat_rate = stat_rate; - seg->av.hop_limit = hop_limit; - seg->av.sl_tclass_flowlabel = htobe32(sl_tclass_flowlabel); - memcpy(seg->av.dgid, dgid, 16); - seg->dqpn = htobe32(dqpn); - seg->qkey = htobe32(qkey); - seg->vlan = htobe16(vlan); - memcpy(seg->mac, mac, 6); -} - -/* - * Data Segments - contain pointers and a byte count for the scatter/gather list. - * They can optionally contain data, which will save a memory read access for - * gather Work Requests. - */ -static MLX4DV_ALWAYS_INLINE -void mlx4dv_set_data_seg(struct mlx4_wqe_data_seg *seg, - uint32_t length, uint32_t lkey, - uintptr_t address) -{ - seg->byte_count = htobe32(length); - seg->lkey = htobe32(lkey); - seg->addr = htobe64(address); -} - -/* Most device capabilities are exported by ibv_query_device(...), - * but there is HW device-specific information which is important - * for data-path, but isn't provided. - * - * Return 0 on success. - */ -int mlx4dv_query_device(struct ibv_context *ctx_in, - struct mlx4dv_context *attrs_out); - -enum mlx4dv_set_ctx_attr_type { - /* Attribute type uint8_t */ - MLX4DV_SET_CTX_ATTR_LOG_WQS_RANGE_SZ = 0, -}; - -/* - * Returns 0 on success, or the value of errno on failure - * (which indicates the failure reason). - */ -int mlx4dv_set_context_attr(struct ibv_context *context, - enum mlx4dv_set_ctx_attr_type attr_type, - void *attr); -#endif /* _MLX4DV_H_ */ diff --git a/usr/rdma-core/providers/mlx4/qp.c b/usr/rdma-core/providers/mlx4/qp.c deleted file mode 100644 index 61f69ee58..000000000 --- a/usr/rdma-core/providers/mlx4/qp.c +++ /dev/null @@ -1,808 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2007 Cisco, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "mlx4.h" - -static const uint32_t mlx4_ib_opcode[] = { - [IBV_WR_SEND] = MLX4_OPCODE_SEND, - [IBV_WR_SEND_WITH_IMM] = MLX4_OPCODE_SEND_IMM, - [IBV_WR_RDMA_WRITE] = MLX4_OPCODE_RDMA_WRITE, - [IBV_WR_RDMA_WRITE_WITH_IMM] = MLX4_OPCODE_RDMA_WRITE_IMM, - [IBV_WR_RDMA_READ] = MLX4_OPCODE_RDMA_READ, - [IBV_WR_ATOMIC_CMP_AND_SWP] = MLX4_OPCODE_ATOMIC_CS, - [IBV_WR_ATOMIC_FETCH_AND_ADD] = MLX4_OPCODE_ATOMIC_FA, - [IBV_WR_LOCAL_INV] = MLX4_OPCODE_LOCAL_INVAL, - [IBV_WR_BIND_MW] = MLX4_OPCODE_BIND_MW, - [IBV_WR_SEND_WITH_INV] = MLX4_OPCODE_SEND_INVAL, -}; - -static void *get_recv_wqe(struct mlx4_qp *qp, int n) -{ - return qp->buf.buf + qp->rq.offset + (n << qp->rq.wqe_shift); -} - -static void *get_send_wqe(struct mlx4_qp *qp, int n) -{ - return qp->buf.buf + qp->sq.offset + (n << qp->sq.wqe_shift); -} - -/* - * Stamp a SQ WQE so that it is invalid if prefetched by marking the - * first four bytes of every 64 byte chunk with 0xffffffff, except for - * the very first chunk of the WQE. - */ -static void stamp_send_wqe(struct mlx4_qp *qp, int n) -{ - uint32_t *wqe = get_send_wqe(qp, n); - int i; - int ds = (((struct mlx4_wqe_ctrl_seg *)wqe)->fence_size & 0x3f) << 2; - - for (i = 16; i < ds; i += 16) - wqe[i] = 0xffffffff; -} - -void mlx4_init_qp_indices(struct mlx4_qp *qp) -{ - qp->sq.head = 0; - qp->sq.tail = 0; - qp->rq.head = 0; - qp->rq.tail = 0; -} - -void mlx4_qp_init_sq_ownership(struct mlx4_qp *qp) -{ - struct mlx4_wqe_ctrl_seg *ctrl; - int i; - - for (i = 0; i < qp->sq.wqe_cnt; ++i) { - ctrl = get_send_wqe(qp, i); - ctrl->owner_opcode = htobe32(1 << 31); - ctrl->fence_size = 1 << (qp->sq.wqe_shift - 4); - - stamp_send_wqe(qp, i); - } -} - -static int wq_overflow(struct mlx4_wq *wq, int nreq, struct mlx4_cq *cq) -{ - unsigned cur; - - cur = wq->head - wq->tail; - if (cur + nreq < wq->max_post) - return 0; - - pthread_spin_lock(&cq->lock); - cur = wq->head - wq->tail; - pthread_spin_unlock(&cq->lock); - - return cur + nreq >= wq->max_post; -} - -static void set_bind_seg(struct mlx4_wqe_bind_seg *bseg, struct ibv_send_wr *wr) -{ - int acc = wr->bind_mw.bind_info.mw_access_flags; - bseg->flags1 = 0; - if (acc & IBV_ACCESS_REMOTE_ATOMIC) - bseg->flags1 |= htobe32(MLX4_WQE_MW_ATOMIC); - if (acc & IBV_ACCESS_REMOTE_WRITE) - bseg->flags1 |= htobe32(MLX4_WQE_MW_REMOTE_WRITE); - if (acc & IBV_ACCESS_REMOTE_READ) - bseg->flags1 |= htobe32(MLX4_WQE_MW_REMOTE_READ); - - bseg->flags2 = 0; - if (((struct ibv_mw *)(wr->bind_mw.mw))->type == IBV_MW_TYPE_2) - bseg->flags2 |= htobe32(MLX4_WQE_BIND_TYPE_2); - if (acc & IBV_ACCESS_ZERO_BASED) - bseg->flags2 |= htobe32(MLX4_WQE_BIND_ZERO_BASED); - - bseg->new_rkey = htobe32(wr->bind_mw.rkey); - bseg->lkey = htobe32(wr->bind_mw.bind_info.mr->lkey); - bseg->addr = htobe64((uint64_t) wr->bind_mw.bind_info.addr); - bseg->length = htobe64(wr->bind_mw.bind_info.length); -} - -static inline void set_local_inv_seg(struct mlx4_wqe_local_inval_seg *iseg, - uint32_t rkey) -{ - iseg->mem_key = htobe32(rkey); - - iseg->reserved1 = 0; - iseg->reserved2 = 0; - iseg->reserved3[0] = 0; - iseg->reserved3[1] = 0; -} - -static inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg, - uint64_t remote_addr, uint32_t rkey) -{ - rseg->raddr = htobe64(remote_addr); - rseg->rkey = htobe32(rkey); - rseg->reserved = 0; -} - -static void set_atomic_seg(struct mlx4_wqe_atomic_seg *aseg, struct ibv_send_wr *wr) -{ - if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) { - aseg->swap_add = htobe64(wr->wr.atomic.swap); - aseg->compare = htobe64(wr->wr.atomic.compare_add); - } else { - aseg->swap_add = htobe64(wr->wr.atomic.compare_add); - aseg->compare = 0; - } - -} - -static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg, - struct ibv_send_wr *wr) -{ - memcpy(&dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof (struct mlx4_av)); - dseg->dqpn = htobe32(wr->wr.ud.remote_qpn); - dseg->qkey = htobe32(wr->wr.ud.remote_qkey); - dseg->vlan = htobe16(to_mah(wr->wr.ud.ah)->vlan); - memcpy(dseg->mac, to_mah(wr->wr.ud.ah)->mac, 6); -} - -static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ibv_sge *sg) -{ - dseg->byte_count = htobe32(sg->length); - dseg->lkey = htobe32(sg->lkey); - dseg->addr = htobe64(sg->addr); -} - -static void set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ibv_sge *sg) -{ - dseg->lkey = htobe32(sg->lkey); - dseg->addr = htobe64(sg->addr); - - /* - * Need a barrier here before writing the byte_count field to - * make sure that all the data is visible before the - * byte_count field is set. Otherwise, if the segment begins - * a new cacheline, the HCA prefetcher could grab the 64-byte - * chunk and get a valid (!= * 0xffffffff) byte count but - * stale data, and end up sending the wrong data. - */ - udma_to_device_barrier(); - - if (likely(sg->length)) - dseg->byte_count = htobe32(sg->length); - else - dseg->byte_count = htobe32(0x80000000); -} - -int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - struct mlx4_context *ctx; - struct mlx4_qp *qp = to_mqp(ibqp); - void *wqe; - struct mlx4_wqe_ctrl_seg *uninitialized_var(ctrl); - int ind; - int nreq; - int inl = 0; - int ret = 0; - int size = 0; - int i; - - pthread_spin_lock(&qp->sq.lock); - - /* XXX check that state is OK to post send */ - - ind = qp->sq.head; - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (wq_overflow(&qp->sq, nreq, to_mcq(ibqp->send_cq))) { - ret = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (wr->num_sge > qp->sq.max_gs) { - ret = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (wr->opcode >= sizeof mlx4_ib_opcode / sizeof mlx4_ib_opcode[0]) { - ret = EINVAL; - *bad_wr = wr; - goto out; - } - - ctrl = wqe = get_send_wqe(qp, ind & (qp->sq.wqe_cnt - 1)); - qp->sq.wrid[ind & (qp->sq.wqe_cnt - 1)] = wr->wr_id; - - ctrl->srcrb_flags = - (wr->send_flags & IBV_SEND_SIGNALED ? - htobe32(MLX4_WQE_CTRL_CQ_UPDATE) : 0) | - (wr->send_flags & IBV_SEND_SOLICITED ? - htobe32(MLX4_WQE_CTRL_SOLICIT) : 0) | - qp->sq_signal_bits; - - if (wr->opcode == IBV_WR_SEND_WITH_IMM || - wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM) - ctrl->imm = wr->imm_data; - else - ctrl->imm = 0; - - wqe += sizeof *ctrl; - size = sizeof *ctrl / 16; - - switch (ibqp->qp_type) { - case IBV_QPT_XRC_SEND: - ctrl->srcrb_flags |= MLX4_REMOTE_SRQN_FLAGS(wr); - /* fall through */ - case IBV_QPT_RC: - case IBV_QPT_UC: - switch (wr->opcode) { - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - set_raddr_seg(wqe, wr->wr.atomic.remote_addr, - wr->wr.atomic.rkey); - wqe += sizeof (struct mlx4_wqe_raddr_seg); - - set_atomic_seg(wqe, wr); - wqe += sizeof (struct mlx4_wqe_atomic_seg); - size += (sizeof (struct mlx4_wqe_raddr_seg) + - sizeof (struct mlx4_wqe_atomic_seg)) / 16; - - break; - - case IBV_WR_RDMA_READ: - inl = 1; - /* fall through */ - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - if (!wr->num_sge) - inl = 1; - set_raddr_seg(wqe, wr->wr.rdma.remote_addr, - wr->wr.rdma.rkey); - wqe += sizeof (struct mlx4_wqe_raddr_seg); - size += sizeof (struct mlx4_wqe_raddr_seg) / 16; - - break; - case IBV_WR_LOCAL_INV: - ctrl->srcrb_flags |= - htobe32(MLX4_WQE_CTRL_STRONG_ORDER); - set_local_inv_seg(wqe, wr->invalidate_rkey); - wqe += sizeof - (struct mlx4_wqe_local_inval_seg); - size += sizeof - (struct mlx4_wqe_local_inval_seg) / 16; - break; - case IBV_WR_BIND_MW: - ctrl->srcrb_flags |= - htobe32(MLX4_WQE_CTRL_STRONG_ORDER); - set_bind_seg(wqe, wr); - wqe += sizeof - (struct mlx4_wqe_bind_seg); - size += sizeof - (struct mlx4_wqe_bind_seg) / 16; - break; - case IBV_WR_SEND_WITH_INV: - ctrl->imm = htobe32(wr->invalidate_rkey); - break; - - default: - /* No extra segments required for sends */ - break; - } - break; - - case IBV_QPT_UD: - set_datagram_seg(wqe, wr); - wqe += sizeof (struct mlx4_wqe_datagram_seg); - size += sizeof (struct mlx4_wqe_datagram_seg) / 16; - - if (wr->send_flags & IBV_SEND_IP_CSUM) { - if (!(qp->qp_cap_cache & MLX4_CSUM_SUPPORT_UD_OVER_IB)) { - ret = EINVAL; - *bad_wr = wr; - goto out; - } - ctrl->srcrb_flags |= htobe32(MLX4_WQE_CTRL_IP_HDR_CSUM | - MLX4_WQE_CTRL_TCP_UDP_CSUM); - } - break; - - case IBV_QPT_RAW_PACKET: - /* For raw eth, the MLX4_WQE_CTRL_SOLICIT flag is used - * to indicate that no icrc should be calculated */ - ctrl->srcrb_flags |= htobe32(MLX4_WQE_CTRL_SOLICIT); - if (wr->send_flags & IBV_SEND_IP_CSUM) { - if (!(qp->qp_cap_cache & MLX4_CSUM_SUPPORT_RAW_OVER_ETH)) { - ret = EINVAL; - *bad_wr = wr; - goto out; - } - ctrl->srcrb_flags |= htobe32(MLX4_WQE_CTRL_IP_HDR_CSUM | - MLX4_WQE_CTRL_TCP_UDP_CSUM); - } - break; - - default: - break; - } - - if (wr->send_flags & IBV_SEND_INLINE && wr->num_sge) { - struct mlx4_wqe_inline_seg *seg; - void *addr; - int len, seg_len; - int num_seg; - int off, to_copy; - - inl = 0; - - seg = wqe; - wqe += sizeof *seg; - off = ((uintptr_t) wqe) & (MLX4_INLINE_ALIGN - 1); - num_seg = 0; - seg_len = 0; - - for (i = 0; i < wr->num_sge; ++i) { - addr = (void *) (uintptr_t) wr->sg_list[i].addr; - len = wr->sg_list[i].length; - inl += len; - - if (inl > qp->max_inline_data) { - inl = 0; - ret = ENOMEM; - *bad_wr = wr; - goto out; - } - - while (len >= MLX4_INLINE_ALIGN - off) { - to_copy = MLX4_INLINE_ALIGN - off; - memcpy(wqe, addr, to_copy); - len -= to_copy; - wqe += to_copy; - addr += to_copy; - seg_len += to_copy; - udma_to_device_barrier(); /* see comment below */ - seg->byte_count = htobe32(MLX4_INLINE_SEG | seg_len); - seg_len = 0; - seg = wqe; - wqe += sizeof *seg; - off = sizeof *seg; - ++num_seg; - } - - memcpy(wqe, addr, len); - wqe += len; - seg_len += len; - off += len; - } - - if (seg_len) { - ++num_seg; - /* - * Need a barrier here to make sure - * all the data is visible before the - * byte_count field is set. Otherwise - * the HCA prefetcher could grab the - * 64-byte chunk with this inline - * segment and get a valid (!= - * 0xffffffff) byte count but stale - * data, and end up sending the wrong - * data. - */ - udma_to_device_barrier(); - seg->byte_count = htobe32(MLX4_INLINE_SEG | seg_len); - } - - size += (inl + num_seg * sizeof * seg + 15) / 16; - } else { - struct mlx4_wqe_data_seg *seg = wqe; - - for (i = wr->num_sge - 1; i >= 0 ; --i) - set_data_seg(seg + i, wr->sg_list + i); - - size += wr->num_sge * (sizeof *seg / 16); - } - - ctrl->fence_size = (wr->send_flags & IBV_SEND_FENCE ? - MLX4_WQE_CTRL_FENCE : 0) | size; - - /* - * Make sure descriptor is fully written before - * setting ownership bit (because HW can start - * executing as soon as we do). - */ - udma_to_device_barrier(); - - ctrl->owner_opcode = htobe32(mlx4_ib_opcode[wr->opcode]) | - (ind & qp->sq.wqe_cnt ? htobe32(1 << 31) : 0); - - /* - * We can improve latency by not stamping the last - * send queue WQE until after ringing the doorbell, so - * only stamp here if there are still more WQEs to post. - */ - if (wr->next) - stamp_send_wqe(qp, (ind + qp->sq_spare_wqes) & - (qp->sq.wqe_cnt - 1)); - - ++ind; - } - -out: - ctx = to_mctx(ibqp->context); - - if (nreq == 1 && inl && size > 1 && size <= ctx->bf_buf_size / 16) { - ctrl->owner_opcode |= htobe32((qp->sq.head & 0xffff) << 8); - - ctrl->bf_qpn |= qp->doorbell_qpn; - ++qp->sq.head; - /* - * Make sure that descriptor is written to memory - * before writing to BlueFlame page. - */ - mmio_wc_spinlock(&ctx->bf_lock); - - mmio_memcpy_x64(ctx->bf_page + ctx->bf_offset, ctrl, - align(size * 16, 64)); - /* Flush before toggling bf_offset to be latency oriented */ - mmio_flush_writes(); - - ctx->bf_offset ^= ctx->bf_buf_size; - - pthread_spin_unlock(&ctx->bf_lock); - } else if (nreq) { - qp->sq.head += nreq; - - /* - * Make sure that descriptors are written before - * doorbell record. - */ - udma_to_device_barrier(); - - mmio_write32_be(ctx->uar + MLX4_SEND_DOORBELL, - qp->doorbell_qpn); - } - - if (nreq) - stamp_send_wqe(qp, (ind + qp->sq_spare_wqes - 1) & - (qp->sq.wqe_cnt - 1)); - - pthread_spin_unlock(&qp->sq.lock); - - return ret; -} - -static inline int _mlx4_post_recv(struct mlx4_qp *qp, struct mlx4_cq *cq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) - ALWAYS_INLINE; -static inline int _mlx4_post_recv(struct mlx4_qp *qp, struct mlx4_cq *cq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mlx4_wqe_data_seg *scat; - int ret = 0; - int nreq; - int ind; - int i; - - pthread_spin_lock(&qp->rq.lock); - - /* XXX check that state is OK to post receive */ - - ind = qp->rq.head & (qp->rq.wqe_cnt - 1); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (wq_overflow(&qp->rq, nreq, cq)) { - ret = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (wr->num_sge > qp->rq.max_gs) { - ret = ENOMEM; - *bad_wr = wr; - goto out; - } - - scat = get_recv_wqe(qp, ind); - - for (i = 0; i < wr->num_sge; ++i) - __set_data_seg(scat + i, wr->sg_list + i); - - if (i < qp->rq.max_gs) { - scat[i].byte_count = 0; - scat[i].lkey = htobe32(MLX4_INVALID_LKEY); - scat[i].addr = 0; - } - - qp->rq.wrid[ind] = wr->wr_id; - - ind = (ind + 1) & (qp->rq.wqe_cnt - 1); - } - -out: - if (nreq) { - qp->rq.head += nreq; - - /* - * Make sure that descriptors are written before - * doorbell record. - */ - udma_to_device_barrier(); - - *qp->db = htobe32(qp->rq.head & 0xffff); - } - - pthread_spin_unlock(&qp->rq.lock); - - return ret; -} - -int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mlx4_qp *qp = to_mqp(ibqp); - struct mlx4_cq *cq = to_mcq(ibqp->recv_cq); - - return _mlx4_post_recv(qp, cq, wr, bad_wr); -} - -int mlx4_post_wq_recv(struct ibv_wq *ibwq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mlx4_qp *qp = wq_to_mqp(ibwq); - struct mlx4_cq *cq = to_mcq(ibwq->cq); - - return _mlx4_post_recv(qp, cq, wr, bad_wr); -} - -static int num_inline_segs(int data, enum ibv_qp_type type) -{ - /* - * Inline data segments are not allowed to cross 64 byte - * boundaries. For UD QPs, the data segments always start - * aligned to 64 bytes (16 byte control segment + 48 byte - * datagram segment); for other QPs, there will be a 16 byte - * control segment and possibly a 16 byte remote address - * segment, so in the worst case there will be only 32 bytes - * available for the first data segment. - */ - if (type == IBV_QPT_UD) - data += (sizeof (struct mlx4_wqe_ctrl_seg) + - sizeof (struct mlx4_wqe_datagram_seg)) % - MLX4_INLINE_ALIGN; - else - data += (sizeof (struct mlx4_wqe_ctrl_seg) + - sizeof (struct mlx4_wqe_raddr_seg)) % - MLX4_INLINE_ALIGN; - - return (data + MLX4_INLINE_ALIGN - sizeof (struct mlx4_wqe_inline_seg) - 1) / - (MLX4_INLINE_ALIGN - sizeof (struct mlx4_wqe_inline_seg)); -} - -void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type, - struct mlx4_qp *qp) -{ - int size; - int max_sq_sge; - - max_sq_sge = align(cap->max_inline_data + - num_inline_segs(cap->max_inline_data, type) * - sizeof (struct mlx4_wqe_inline_seg), - sizeof (struct mlx4_wqe_data_seg)) / - sizeof (struct mlx4_wqe_data_seg); - if (max_sq_sge < cap->max_send_sge) - max_sq_sge = cap->max_send_sge; - - size = max_sq_sge * sizeof (struct mlx4_wqe_data_seg); - switch (type) { - case IBV_QPT_UD: - size += sizeof (struct mlx4_wqe_datagram_seg); - break; - - case IBV_QPT_UC: - size += sizeof (struct mlx4_wqe_raddr_seg); - break; - - case IBV_QPT_XRC_SEND: - case IBV_QPT_RC: - size += sizeof (struct mlx4_wqe_raddr_seg); - /* - * An atomic op will require an atomic segment, a - * remote address segment and one scatter entry. - */ - if (size < (sizeof (struct mlx4_wqe_atomic_seg) + - sizeof (struct mlx4_wqe_raddr_seg) + - sizeof (struct mlx4_wqe_data_seg))) - size = (sizeof (struct mlx4_wqe_atomic_seg) + - sizeof (struct mlx4_wqe_raddr_seg) + - sizeof (struct mlx4_wqe_data_seg)); - break; - - default: - break; - } - - /* Make sure that we have enough space for a bind request */ - if (size < sizeof (struct mlx4_wqe_bind_seg)) - size = sizeof (struct mlx4_wqe_bind_seg); - - size += sizeof (struct mlx4_wqe_ctrl_seg); - - for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size; - qp->sq.wqe_shift++) - ; /* nothing */ -} - -int mlx4_alloc_qp_buf(struct ibv_context *context, uint32_t max_recv_sge, - enum ibv_qp_type type, struct mlx4_qp *qp, - struct mlx4dv_qp_init_attr *mlx4qp_attr) -{ - int wqe_size; - - qp->rq.max_gs = max_recv_sge; - wqe_size = qp->rq.max_gs * sizeof(struct mlx4_wqe_data_seg); - if (mlx4qp_attr && - mlx4qp_attr->comp_mask & MLX4DV_QP_INIT_ATTR_MASK_INL_RECV && - mlx4qp_attr->inl_recv_sz > wqe_size) - wqe_size = mlx4qp_attr->inl_recv_sz; - - if (qp->sq.wqe_cnt) { - qp->sq.wrid = malloc(qp->sq.wqe_cnt * sizeof (uint64_t)); - if (!qp->sq.wrid) - return -1; - } - - if (qp->rq.wqe_cnt) { - qp->rq.wrid = malloc(qp->rq.wqe_cnt * sizeof (uint64_t)); - if (!qp->rq.wrid) { - free(qp->sq.wrid); - return -1; - } - } - - for (qp->rq.wqe_shift = 4; - 1 << qp->rq.wqe_shift < wqe_size; - qp->rq.wqe_shift++) - ; /* nothing */ - if (mlx4qp_attr) - mlx4qp_attr->inl_recv_sz = 1 << qp->rq.wqe_shift; - - qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) + - (qp->sq.wqe_cnt << qp->sq.wqe_shift); - if (qp->rq.wqe_shift > qp->sq.wqe_shift) { - qp->rq.offset = 0; - qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift; - } else { - qp->rq.offset = qp->sq.wqe_cnt << qp->sq.wqe_shift; - qp->sq.offset = 0; - } - - if (qp->buf_size) { - if (mlx4_alloc_buf(&qp->buf, - align(qp->buf_size, to_mdev(context->device)->page_size), - to_mdev(context->device)->page_size)) { - free(qp->sq.wrid); - free(qp->rq.wrid); - return -1; - } - - memset(qp->buf.buf, 0, qp->buf_size); - } else { - qp->buf.buf = NULL; - } - - return 0; -} - -void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap, - enum ibv_qp_type type) -{ - int wqe_size; - - wqe_size = (1 << qp->sq.wqe_shift) - sizeof (struct mlx4_wqe_ctrl_seg); - switch (type) { - case IBV_QPT_UD: - wqe_size -= sizeof (struct mlx4_wqe_datagram_seg); - break; - - case IBV_QPT_XRC_SEND: - case IBV_QPT_UC: - case IBV_QPT_RC: - wqe_size -= sizeof (struct mlx4_wqe_raddr_seg); - break; - - default: - break; - } - - qp->sq.max_gs = wqe_size / sizeof (struct mlx4_wqe_data_seg); - cap->max_send_sge = qp->sq.max_gs; - qp->sq.max_post = qp->sq.wqe_cnt - qp->sq_spare_wqes; - cap->max_send_wr = qp->sq.max_post; - - /* - * Inline data segments can't cross a 64 byte boundary. So - * subtract off one segment header for each 64-byte chunk, - * taking into account the fact that wqe_size will be 32 mod - * 64 for non-UD QPs. - */ - qp->max_inline_data = wqe_size - - sizeof (struct mlx4_wqe_inline_seg) * - (align(wqe_size, MLX4_INLINE_ALIGN) / MLX4_INLINE_ALIGN); - cap->max_inline_data = qp->max_inline_data; -} - -struct mlx4_qp *mlx4_find_qp(struct mlx4_context *ctx, uint32_t qpn) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (ctx->qp_table[tind].refcnt) - return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask]; - else - return NULL; -} - -int mlx4_store_qp(struct mlx4_context *ctx, uint32_t qpn, struct mlx4_qp *qp) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (!ctx->qp_table[tind].refcnt) { - ctx->qp_table[tind].table = calloc(ctx->qp_table_mask + 1, - sizeof (struct mlx4_qp *)); - if (!ctx->qp_table[tind].table) - return -1; - } - - ++ctx->qp_table[tind].refcnt; - ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = qp; - return 0; -} - -void mlx4_clear_qp(struct mlx4_context *ctx, uint32_t qpn) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (!--ctx->qp_table[tind].refcnt) - free(ctx->qp_table[tind].table); - else - ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = NULL; -} diff --git a/usr/rdma-core/providers/mlx4/srq.c b/usr/rdma-core/providers/mlx4/srq.c deleted file mode 100644 index f9cb0dd4f..000000000 --- a/usr/rdma-core/providers/mlx4/srq.c +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (c) 2007 Cisco, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include - -#include "mlx4.h" -#include "mlx4-abi.h" - -static void *get_wqe(struct mlx4_srq *srq, int n) -{ - return srq->buf.buf + (n << srq->wqe_shift); -} - -void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind) -{ - struct mlx4_wqe_srq_next_seg *next; - - pthread_spin_lock(&srq->lock); - - next = get_wqe(srq, srq->tail); - next->next_wqe_index = htobe16(ind); - srq->tail = ind; - - pthread_spin_unlock(&srq->lock); -} - -int mlx4_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mlx4_srq *srq = to_msrq(ibsrq); - struct mlx4_wqe_srq_next_seg *next; - struct mlx4_wqe_data_seg *scat; - int err = 0; - int nreq; - int i; - - pthread_spin_lock(&srq->lock); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (wr->num_sge > srq->max_gs) { - err = -1; - *bad_wr = wr; - break; - } - - if (srq->head == srq->tail) { - /* SRQ is full*/ - err = -1; - *bad_wr = wr; - break; - } - - srq->wrid[srq->head] = wr->wr_id; - - next = get_wqe(srq, srq->head); - srq->head = be16toh(next->next_wqe_index); - scat = (struct mlx4_wqe_data_seg *) (next + 1); - - for (i = 0; i < wr->num_sge; ++i) { - scat[i].byte_count = htobe32(wr->sg_list[i].length); - scat[i].lkey = htobe32(wr->sg_list[i].lkey); - scat[i].addr = htobe64(wr->sg_list[i].addr); - } - - if (i < srq->max_gs) { - scat[i].byte_count = 0; - scat[i].lkey = htobe32(MLX4_INVALID_LKEY); - scat[i].addr = 0; - } - } - - if (nreq) { - srq->counter += nreq; - - /* - * Make sure that descriptors are written before - * we write doorbell record. - */ - udma_to_device_barrier(); - - *srq->db = htobe32(srq->counter); - } - - pthread_spin_unlock(&srq->lock); - - return err; -} - -int mlx4_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr, - struct mlx4_srq *srq) -{ - struct mlx4_wqe_srq_next_seg *next; - struct mlx4_wqe_data_seg *scatter; - int size; - int buf_size; - int i; - - srq->wrid = malloc(srq->max * sizeof (uint64_t)); - if (!srq->wrid) - return -1; - - size = sizeof (struct mlx4_wqe_srq_next_seg) + - srq->max_gs * sizeof (struct mlx4_wqe_data_seg); - - for (srq->wqe_shift = 5; 1 << srq->wqe_shift < size; ++srq->wqe_shift) - ; /* nothing */ - - buf_size = srq->max << srq->wqe_shift; - - if (mlx4_alloc_buf(&srq->buf, buf_size, - to_mdev(pd->context->device)->page_size)) { - free(srq->wrid); - return -1; - } - - memset(srq->buf.buf, 0, buf_size); - - /* - * Now initialize the SRQ buffer so that all of the WQEs are - * linked into the list of free WQEs. - */ - - for (i = 0; i < srq->max; ++i) { - next = get_wqe(srq, i); - next->next_wqe_index = htobe16((i + 1) & (srq->max - 1)); - - for (scatter = (void *) (next + 1); - (void *) scatter < (void *) next + (1 << srq->wqe_shift); - ++scatter) - scatter->lkey = htobe32(MLX4_INVALID_LKEY); - } - - srq->head = 0; - srq->tail = srq->max - 1; - - return 0; -} - -void mlx4_init_xsrq_table(struct mlx4_xsrq_table *xsrq_table, int size) -{ - memset(xsrq_table, 0, sizeof *xsrq_table); - xsrq_table->num_xsrq = size; - xsrq_table->shift = ffs(size) - 1 - MLX4_XSRQ_TABLE_BITS; - xsrq_table->mask = (1 << xsrq_table->shift) - 1; - - pthread_mutex_init(&xsrq_table->mutex, NULL); -} - -struct mlx4_srq *mlx4_find_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn) -{ - int index; - - index = (srqn & (xsrq_table->num_xsrq - 1)) >> xsrq_table->shift; - if (xsrq_table->xsrq_table[index].refcnt) - return xsrq_table->xsrq_table[index].table[srqn & xsrq_table->mask]; - - return NULL; -} - -int mlx4_store_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn, - struct mlx4_srq *srq) -{ - int index, ret = 0; - - index = (srqn & (xsrq_table->num_xsrq - 1)) >> xsrq_table->shift; - pthread_mutex_lock(&xsrq_table->mutex); - if (!xsrq_table->xsrq_table[index].refcnt) { - xsrq_table->xsrq_table[index].table = calloc(xsrq_table->mask + 1, - sizeof(struct mlx4_srq *)); - if (!xsrq_table->xsrq_table[index].table) { - ret = -1; - goto out; - } - } - - xsrq_table->xsrq_table[index].refcnt++; - xsrq_table->xsrq_table[index].table[srqn & xsrq_table->mask] = srq; - -out: - pthread_mutex_unlock(&xsrq_table->mutex); - return ret; -} - -void mlx4_clear_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn) -{ - int index; - - index = (srqn & (xsrq_table->num_xsrq - 1)) >> xsrq_table->shift; - pthread_mutex_lock(&xsrq_table->mutex); - - if (--xsrq_table->xsrq_table[index].refcnt) - xsrq_table->xsrq_table[index].table[srqn & xsrq_table->mask] = NULL; - else - free(xsrq_table->xsrq_table[index].table); - - pthread_mutex_unlock(&xsrq_table->mutex); -} - -struct ibv_srq *mlx4_create_xrc_srq(struct ibv_context *context, - struct ibv_srq_init_attr_ex *attr_ex) -{ - struct mlx4_create_xsrq cmd; - struct mlx4_create_srq_resp resp; - struct mlx4_srq *srq; - int ret; - - /* Sanity check SRQ size before proceeding */ - if (attr_ex->attr.max_wr > 1 << 16 || attr_ex->attr.max_sge > 64) - return NULL; - - srq = calloc(1, sizeof *srq); - if (!srq) - return NULL; - - if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE)) - goto err; - - srq->max = align_queue_size(attr_ex->attr.max_wr + 1); - srq->max_gs = attr_ex->attr.max_sge; - srq->counter = 0; - srq->ext_srq = 1; - - if (mlx4_alloc_srq_buf(attr_ex->pd, &attr_ex->attr, srq)) - goto err; - - srq->db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_RQ); - if (!srq->db) - goto err_free; - - *srq->db = 0; - - cmd.buf_addr = (uintptr_t) srq->buf.buf; - cmd.db_addr = (uintptr_t) srq->db; - - ret = ibv_cmd_create_srq_ex(context, &srq->verbs_srq, - sizeof(srq->verbs_srq), - attr_ex, - &cmd.ibv_cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) - goto err_db; - - ret = mlx4_store_xsrq(&to_mctx(context)->xsrq_table, - srq->verbs_srq.srq_num, srq); - if (ret) - goto err_destroy; - - return &srq->verbs_srq.srq; - -err_destroy: - ibv_cmd_destroy_srq(&srq->verbs_srq.srq); -err_db: - mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_RQ, srq->db); -err_free: - free(srq->wrid); - mlx4_free_buf(&srq->buf); -err: - free(srq); - return NULL; -} - -int mlx4_destroy_xrc_srq(struct ibv_srq *srq) -{ - struct mlx4_context *mctx = to_mctx(srq->context); - struct mlx4_srq *msrq = to_msrq(srq); - struct mlx4_cq *mcq; - int ret; - - mcq = to_mcq(msrq->verbs_srq.cq); - mlx4_cq_clean(mcq, 0, msrq); - pthread_spin_lock(&mcq->lock); - mlx4_clear_xsrq(&mctx->xsrq_table, msrq->verbs_srq.srq_num); - pthread_spin_unlock(&mcq->lock); - - ret = ibv_cmd_destroy_srq(srq); - if (ret && !cleanup_on_fatal(ret)) { - pthread_spin_lock(&mcq->lock); - mlx4_store_xsrq(&mctx->xsrq_table, msrq->verbs_srq.srq_num, msrq); - pthread_spin_unlock(&mcq->lock); - return ret; - } - - mlx4_free_db(mctx, MLX4_DB_TYPE_RQ, msrq->db); - mlx4_free_buf(&msrq->buf); - free(msrq->wrid); - free(msrq); - - return 0; -} diff --git a/usr/rdma-core/providers/mlx4/verbs.c b/usr/rdma-core/providers/mlx4/verbs.c deleted file mode 100644 index b966ef2c2..000000000 --- a/usr/rdma-core/providers/mlx4/verbs.c +++ /dev/null @@ -1,1611 +0,0 @@ -/* - * Copyright (c) 2007 Cisco, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include "mlx4.h" -#include "mlx4-abi.h" - -int mlx4_query_device(struct ibv_context *context, struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, sizeof cmd); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%03d", major, minor, sub_minor); - - return 0; -} - -int mlx4_query_device_ex(struct ibv_context *context, - const struct ibv_query_device_ex_input *input, - struct ibv_device_attr_ex *attr, - size_t attr_size) -{ - struct mlx4_context *mctx = to_mctx(context); - struct mlx4_query_device_ex_resp resp = {}; - struct mlx4_query_device_ex cmd = {}; - uint64_t raw_fw_ver; - unsigned sub_minor; - unsigned major; - unsigned minor; - int err; - - err = ibv_cmd_query_device_ex(context, input, attr, attr_size, - &raw_fw_ver, - &cmd.ibv_cmd, sizeof(cmd.ibv_cmd), sizeof(cmd), - &resp.ibv_resp, sizeof(resp.ibv_resp), - sizeof(resp)); - if (err) - return err; - - if (resp.comp_mask & MLX4_QUERY_DEV_RESP_MASK_CORE_CLOCK_OFFSET) { - mctx->core_clock.offset = resp.hca_core_clock_offset; - mctx->core_clock.offset_valid = 1; - } - mctx->max_inl_recv_sz = resp.max_inl_recv_sz; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->orig_attr.fw_ver, sizeof attr->orig_attr.fw_ver, - "%d.%d.%03d", major, minor, sub_minor); - - return 0; -} - -static int mlx4_read_clock(struct ibv_context *context, uint64_t *cycles) -{ - uint32_t clockhi, clocklo, clockhi1; - int i; - struct mlx4_context *ctx = to_mctx(context); - - if (!ctx->hca_core_clock) - return -EOPNOTSUPP; - - /* Handle wraparound */ - for (i = 0; i < 2; i++) { - clockhi = be32toh(mmio_read32_be(ctx->hca_core_clock)); - clocklo = be32toh(mmio_read32_be(ctx->hca_core_clock + 4)); - clockhi1 = be32toh(mmio_read32_be(ctx->hca_core_clock)); - if (clockhi == clockhi1) - break; - } - - *cycles = (uint64_t)clockhi << 32 | (uint64_t)clocklo; - - return 0; -} - -int mlx4_query_rt_values(struct ibv_context *context, - struct ibv_values_ex *values) -{ - uint32_t comp_mask = 0; - int err = 0; - - if (values->comp_mask & IBV_VALUES_MASK_RAW_CLOCK) { - uint64_t cycles; - - err = mlx4_read_clock(context, &cycles); - if (!err) { - values->raw_clock.tv_sec = 0; - values->raw_clock.tv_nsec = cycles; - comp_mask |= IBV_VALUES_MASK_RAW_CLOCK; - } - } - - values->comp_mask = comp_mask; - - return err; -} - -int mlx4_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - int err; - - err = ibv_cmd_query_port(context, port, attr, &cmd, sizeof(cmd)); - if (!err && port <= MLX4_PORTS_NUM && port > 0) { - struct mlx4_context *mctx = to_mctx(context); - if (!mctx->port_query_cache[port - 1].valid) { - mctx->port_query_cache[port - 1].link_layer = - attr->link_layer; - mctx->port_query_cache[port - 1].caps = - attr->port_cap_flags; - mctx->port_query_cache[port - 1].valid = 1; - } - } - - return err; -} - -/* Only the fields in the port cache will be valid */ -static int query_port_cache(struct ibv_context *context, uint8_t port_num, - struct ibv_port_attr *port_attr) -{ - struct mlx4_context *mctx = to_mctx(context); - if (port_num <= 0 || port_num > MLX4_PORTS_NUM) - return -EINVAL; - if (mctx->port_query_cache[port_num - 1].valid) { - port_attr->link_layer = - mctx-> - port_query_cache[port_num - 1]. - link_layer; - port_attr->port_cap_flags = - mctx-> - port_query_cache[port_num - 1]. - caps; - return 0; - } - return mlx4_query_port(context, port_num, - (struct ibv_port_attr *)port_attr); - -} - -struct ibv_pd *mlx4_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct mlx4_alloc_pd_resp resp; - struct mlx4_pd *pd; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(pd); - return NULL; - } - - pd->pdn = resp.pdn; - - return &pd->ibv_pd; -} - -int mlx4_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret && !cleanup_on_fatal(ret)) - return ret; - - free(to_mpd(pd)); - return 0; -} - -struct ibv_xrcd *mlx4_open_xrcd(struct ibv_context *context, - struct ibv_xrcd_init_attr *attr) -{ - struct ibv_open_xrcd cmd; - struct ibv_open_xrcd_resp resp; - struct verbs_xrcd *xrcd; - int ret; - - xrcd = calloc(1, sizeof *xrcd); - if (!xrcd) - return NULL; - - ret = ibv_cmd_open_xrcd(context, xrcd, sizeof(*xrcd), attr, - &cmd, sizeof cmd, &resp, sizeof resp); - if (ret) - goto err; - - return &xrcd->xrcd; - -err: - free(xrcd); - return NULL; -} - -int mlx4_close_xrcd(struct ibv_xrcd *ib_xrcd) -{ - struct verbs_xrcd *xrcd = container_of(ib_xrcd, struct verbs_xrcd, xrcd); - int ret; - - ret = ibv_cmd_close_xrcd(xrcd); - if (ret && !cleanup_on_fatal(ret)) - return ret; - - free(xrcd); - return 0; -} - -struct ibv_mr *mlx4_reg_mr(struct ibv_pd *pd, void *addr, size_t length, - int access) -{ - struct ibv_mr *mr; - struct ibv_reg_mr cmd; - struct ibv_reg_mr_resp resp; - int ret; - - mr = malloc(sizeof *mr); - if (!mr) - return NULL; - - ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, - access, mr, &cmd, sizeof cmd, - &resp, sizeof resp); - if (ret) { - free(mr); - return NULL; - } - - return mr; -} - -int mlx4_rereg_mr(struct ibv_mr *mr, - int flags, - struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - struct ibv_rereg_mr cmd; - struct ibv_rereg_mr_resp resp; - - if (flags & IBV_REREG_MR_KEEP_VALID) - return ENOTSUP; - - return ibv_cmd_rereg_mr(mr, flags, addr, length, - (uintptr_t)addr, - access, pd, - &cmd, sizeof(cmd), - &resp, sizeof(resp)); -} - -int mlx4_dereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret && !cleanup_on_fatal(ret)) - return ret; - - free(mr); - return 0; -} - -struct ibv_mw *mlx4_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type) -{ - struct ibv_mw *mw; - struct ibv_alloc_mw cmd; - struct ibv_alloc_mw_resp resp; - int ret; - - mw = calloc(1, sizeof(*mw)); - if (!mw) - return NULL; - - ret = ibv_cmd_alloc_mw(pd, type, mw, &cmd, sizeof(cmd), - &resp, sizeof(resp)); - - if (ret) { - free(mw); - return NULL; - } - - return mw; -} - -int mlx4_dealloc_mw(struct ibv_mw *mw) -{ - int ret; - struct ibv_dealloc_mw cmd; - - ret = ibv_cmd_dealloc_mw(mw, &cmd, sizeof(cmd)); - if (ret && !cleanup_on_fatal(ret)) - return ret; - - free(mw); - return 0; -} - -int mlx4_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw, - struct ibv_mw_bind *mw_bind) -{ - struct ibv_send_wr *bad_wr = NULL; - struct ibv_send_wr wr = { }; - int ret; - - - wr.opcode = IBV_WR_BIND_MW; - wr.next = NULL; - - wr.wr_id = mw_bind->wr_id; - wr.send_flags = mw_bind->send_flags; - - wr.bind_mw.mw = mw; - wr.bind_mw.rkey = ibv_inc_rkey(mw->rkey); - wr.bind_mw.bind_info = mw_bind->bind_info; - - ret = mlx4_post_send(qp, &wr, &bad_wr); - - if (ret) - return ret; - - /* updating the mw with the latest rkey. */ - mw->rkey = wr.bind_mw.rkey; - - return 0; -} - -int align_queue_size(int req) -{ - int nent; - - for (nent = 1; nent < req; nent <<= 1) - ; /* nothing */ - - return nent; -} - -enum { - CREATE_CQ_SUPPORTED_WC_FLAGS = IBV_WC_STANDARD_FLAGS | - IBV_WC_EX_WITH_COMPLETION_TIMESTAMP -}; - -enum { - CREATE_CQ_SUPPORTED_COMP_MASK = IBV_CQ_INIT_ATTR_MASK_FLAGS -}; - -enum { - CREATE_CQ_SUPPORTED_FLAGS = IBV_CREATE_CQ_ATTR_SINGLE_THREADED -}; - - -static int mlx4_cmd_create_cq(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr, - struct mlx4_cq *cq) -{ - struct mlx4_create_cq cmd = {}; - struct mlx4_create_cq_resp resp = {}; - int ret; - - cmd.buf_addr = (uintptr_t) cq->buf.buf; - cmd.db_addr = (uintptr_t) cq->set_ci_db; - - ret = ibv_cmd_create_cq(context, cq_attr->cqe, cq_attr->channel, - cq_attr->comp_vector, - ibv_cq_ex_to_cq(&cq->ibv_cq), - &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (!ret) - cq->cqn = resp.cqn; - - return ret; - -} - -static int mlx4_cmd_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr, - struct mlx4_cq *cq) -{ - struct mlx4_create_cq_ex cmd = {}; - struct mlx4_create_cq_resp_ex resp = {}; - int ret; - - cmd.buf_addr = (uintptr_t) cq->buf.buf; - cmd.db_addr = (uintptr_t) cq->set_ci_db; - - ret = ibv_cmd_create_cq_ex(context, cq_attr, - &cq->ibv_cq, &cmd.ibv_cmd, - sizeof(cmd.ibv_cmd), - sizeof(cmd), - &resp.ibv_resp, - sizeof(resp.ibv_resp), - sizeof(resp)); - if (!ret) - cq->cqn = resp.cqn; - - return ret; -} - -static struct ibv_cq_ex *create_cq(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr, - int cq_alloc_flags) -{ - struct mlx4_cq *cq; - int ret; - struct mlx4_context *mctx = to_mctx(context); - - /* Sanity check CQ size before proceeding */ - if (cq_attr->cqe > 0x3fffff) { - errno = EINVAL; - return NULL; - } - - if (cq_attr->comp_mask & ~CREATE_CQ_SUPPORTED_COMP_MASK) { - errno = ENOTSUP; - return NULL; - } - - if (cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS && - cq_attr->flags & ~CREATE_CQ_SUPPORTED_FLAGS) { - errno = ENOTSUP; - return NULL; - } - - if (cq_attr->wc_flags & ~CREATE_CQ_SUPPORTED_WC_FLAGS) - return NULL; - - /* mlx4 devices don't support slid and sl in cqe when completion - * timestamp is enabled in the CQ - */ - if ((cq_attr->wc_flags & (IBV_WC_EX_WITH_SLID | IBV_WC_EX_WITH_SL)) && - (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP)) { - errno = ENOTSUP; - return NULL; - } - - cq = malloc(sizeof *cq); - if (!cq) - return NULL; - - cq->cons_index = 0; - - if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE)) - goto err; - - cq_attr->cqe = align_queue_size(cq_attr->cqe + 1); - - if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cq_attr->cqe, mctx->cqe_size)) - goto err; - - cq->cqe_size = mctx->cqe_size; - cq->set_ci_db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_CQ); - if (!cq->set_ci_db) - goto err_buf; - - cq->arm_db = cq->set_ci_db + 1; - *cq->arm_db = 0; - cq->arm_sn = 1; - *cq->set_ci_db = 0; - cq->flags = cq_alloc_flags; - - if (cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS && - cq_attr->flags & IBV_CREATE_CQ_ATTR_SINGLE_THREADED) - cq->flags |= MLX4_CQ_FLAGS_SINGLE_THREADED; - - --cq_attr->cqe; - if (cq_alloc_flags & MLX4_CQ_FLAGS_EXTENDED) - ret = mlx4_cmd_create_cq_ex(context, cq_attr, cq); - else - ret = mlx4_cmd_create_cq(context, cq_attr, cq); - - if (ret) - goto err_db; - - - if (cq_alloc_flags & MLX4_CQ_FLAGS_EXTENDED) - mlx4_cq_fill_pfns(cq, cq_attr); - - return &cq->ibv_cq; - -err_db: - mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_CQ, cq->set_ci_db); - -err_buf: - mlx4_free_buf(&cq->buf); - -err: - free(cq); - - return NULL; -} - -struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct ibv_cq_ex *cq; - struct ibv_cq_init_attr_ex cq_attr = {.cqe = cqe, .channel = channel, - .comp_vector = comp_vector, - .wc_flags = IBV_WC_STANDARD_FLAGS}; - - cq = create_cq(context, &cq_attr, 0); - return cq ? ibv_cq_ex_to_cq(cq) : NULL; -} - -struct ibv_cq_ex *mlx4_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr) -{ - /* - * Make local copy since some attributes might be adjusted - * for internal use. - */ - struct ibv_cq_init_attr_ex cq_attr_c = {.cqe = cq_attr->cqe, - .channel = cq_attr->channel, - .comp_vector = cq_attr->comp_vector, - .wc_flags = cq_attr->wc_flags, - .comp_mask = cq_attr->comp_mask, - .flags = cq_attr->flags}; - - return create_cq(context, &cq_attr_c, MLX4_CQ_FLAGS_EXTENDED); -} - -int mlx4_resize_cq(struct ibv_cq *ibcq, int cqe) -{ - struct mlx4_cq *cq = to_mcq(ibcq); - struct mlx4_resize_cq cmd; - struct ibv_resize_cq_resp resp; - struct mlx4_buf buf; - int old_cqe, outst_cqe, ret; - - /* Sanity check CQ size before proceeding */ - if (cqe > 0x3fffff) - return EINVAL; - - pthread_spin_lock(&cq->lock); - - cqe = align_queue_size(cqe + 1); - if (cqe == ibcq->cqe + 1) { - ret = 0; - goto out; - } - - /* Can't be smaller then the number of outstanding CQEs */ - outst_cqe = mlx4_get_outstanding_cqes(cq); - if (cqe < outst_cqe + 1) { - ret = EINVAL; - goto out; - } - - ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe, cq->cqe_size); - if (ret) - goto out; - - old_cqe = ibcq->cqe; - cmd.buf_addr = (uintptr_t) buf.buf; - - ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd, - &resp, sizeof resp); - if (ret) { - mlx4_free_buf(&buf); - goto out; - } - - mlx4_cq_resize_copy_cqes(cq, buf.buf, old_cqe); - - mlx4_free_buf(&cq->buf); - cq->buf = buf; - mlx4_update_cons_index(cq); - -out: - pthread_spin_unlock(&cq->lock); - return ret; -} - -int mlx4_destroy_cq(struct ibv_cq *cq) -{ - int ret; - - ret = ibv_cmd_destroy_cq(cq); - if (ret && !cleanup_on_fatal(ret)) - return ret; - - mlx4_free_db(to_mctx(cq->context), MLX4_DB_TYPE_CQ, to_mcq(cq)->set_ci_db); - mlx4_free_buf(&to_mcq(cq)->buf); - free(to_mcq(cq)); - - return 0; -} - -struct ibv_srq *mlx4_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct mlx4_create_srq cmd; - struct mlx4_create_srq_resp resp; - struct mlx4_srq *srq; - int ret; - - /* Sanity check SRQ size before proceeding */ - if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64) - return NULL; - - srq = malloc(sizeof *srq); - if (!srq) - return NULL; - - if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE)) - goto err; - - srq->max = align_queue_size(attr->attr.max_wr + 1); - srq->max_gs = attr->attr.max_sge; - srq->counter = 0; - srq->ext_srq = 0; - - if (mlx4_alloc_srq_buf(pd, &attr->attr, srq)) - goto err; - - srq->db = mlx4_alloc_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ); - if (!srq->db) - goto err_free; - - *srq->db = 0; - - cmd.buf_addr = (uintptr_t) srq->buf.buf; - cmd.db_addr = (uintptr_t) srq->db; - - ret = ibv_cmd_create_srq(pd, &srq->verbs_srq.srq, attr, - &cmd.ibv_cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) - goto err_db; - - return &srq->verbs_srq.srq; - -err_db: - mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, srq->db); - -err_free: - free(srq->wrid); - mlx4_free_buf(&srq->buf); - -err: - free(srq); - - return NULL; -} - -struct ibv_srq *mlx4_create_srq_ex(struct ibv_context *context, - struct ibv_srq_init_attr_ex *attr_ex) -{ - if (!(attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) || - (attr_ex->srq_type == IBV_SRQT_BASIC)) - return mlx4_create_srq(attr_ex->pd, (struct ibv_srq_init_attr *) attr_ex); - else if (attr_ex->srq_type == IBV_SRQT_XRC) - return mlx4_create_xrc_srq(context, attr_ex); - - return NULL; -} - -int mlx4_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int attr_mask) -{ - struct ibv_modify_srq cmd; - - return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd); -} - -int mlx4_query_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr) -{ - struct ibv_query_srq cmd; - - return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd); -} - -int mlx4_destroy_srq(struct ibv_srq *srq) -{ - int ret; - - if (to_msrq(srq)->ext_srq) - return mlx4_destroy_xrc_srq(srq); - - ret = ibv_cmd_destroy_srq(srq); - if (ret && !cleanup_on_fatal(ret)) - return ret; - - mlx4_free_db(to_mctx(srq->context), MLX4_DB_TYPE_RQ, to_msrq(srq)->db); - mlx4_free_buf(&to_msrq(srq)->buf); - free(to_msrq(srq)->wrid); - free(to_msrq(srq)); - - return 0; -} - -static int mlx4_cmd_create_qp_ex_rss(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr, - struct mlx4_create_qp *cmd, - struct mlx4_qp *qp) -{ - struct mlx4_create_qp_ex_rss cmd_ex = {}; - struct mlx4_create_qp_resp_ex resp; - int ret; - - if (attr->rx_hash_conf.rx_hash_key_len != - sizeof(cmd_ex.drv_ex.hash_key)) { - errno = ENOTSUP; - return errno; - } - - cmd_ex.drv_ex.hash_fields_mask = - attr->rx_hash_conf.rx_hash_fields_mask; - cmd_ex.drv_ex.hash_function = - attr->rx_hash_conf.rx_hash_function; - memcpy(cmd_ex.drv_ex.hash_key, attr->rx_hash_conf.rx_hash_key, - sizeof(cmd_ex.drv_ex.hash_key)); - - ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp, - sizeof(qp->verbs_qp), attr, - &cmd_ex.ibv_cmd, sizeof(cmd_ex.ibv_cmd), - sizeof(cmd_ex), &resp.ibv_resp, - sizeof(resp.ibv_resp), sizeof(resp)); - return ret; -} - -static struct ibv_qp *_mlx4_create_qp_ex_rss(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr) -{ - struct mlx4_create_qp cmd = {}; - struct mlx4_qp *qp; - int ret; - - if (!(attr->comp_mask & IBV_QP_INIT_ATTR_RX_HASH) || - !(attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE)) - return NULL; - - if (attr->qp_type != IBV_QPT_RAW_PACKET) - return NULL; - - qp = calloc(1, sizeof(*qp)); - if (!qp) - return NULL; - - if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) || - pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE)) - goto err; - - ret = mlx4_cmd_create_qp_ex_rss(context, attr, &cmd, qp); - if (ret) - goto err; - - qp->type = MLX4_RSC_TYPE_RSS_QP; - - return &qp->verbs_qp.qp; -err: - free(qp); - return NULL; -} - -static int mlx4_cmd_create_qp_ex(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr, - struct mlx4_create_qp *cmd, - struct mlx4_qp *qp) -{ - struct mlx4_create_qp_ex cmd_ex; - struct mlx4_create_qp_resp_ex resp; - int ret; - - memset(&cmd_ex, 0, sizeof(cmd_ex)); - memcpy(&cmd_ex.ibv_cmd.base, &cmd->ibv_cmd.user_handle, - offsetof(typeof(cmd->ibv_cmd), is_srq) + - sizeof(cmd->ibv_cmd.is_srq) - - offsetof(typeof(cmd->ibv_cmd), user_handle)); - - memcpy(&cmd_ex.drv_ex, &cmd->buf_addr, - offsetof(typeof(*cmd), sq_no_prefetch) + - sizeof(cmd->sq_no_prefetch) - sizeof(cmd->ibv_cmd)); - - ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp, - sizeof(qp->verbs_qp), attr, - &cmd_ex.ibv_cmd, sizeof(cmd_ex.ibv_cmd), - sizeof(cmd_ex), &resp.ibv_resp, - sizeof(resp.ibv_resp), sizeof(resp)); - return ret; -} - -enum { - MLX4_CREATE_QP_SUP_COMP_MASK = (IBV_QP_INIT_ATTR_PD | - IBV_QP_INIT_ATTR_XRCD | - IBV_QP_INIT_ATTR_CREATE_FLAGS), -}; - -enum { - MLX4_CREATE_QP_EX2_COMP_MASK = (IBV_QP_INIT_ATTR_CREATE_FLAGS), -}; - -static struct ibv_qp *create_qp_ex(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr, - struct mlx4dv_qp_init_attr *mlx4qp_attr) -{ - struct mlx4_context *ctx = to_mctx(context); - struct mlx4_create_qp cmd = {}; - struct ibv_create_qp_resp resp = {}; - struct mlx4_qp *qp; - int ret; - - if (attr->comp_mask & (IBV_QP_INIT_ATTR_RX_HASH | - IBV_QP_INIT_ATTR_IND_TABLE)) { - return _mlx4_create_qp_ex_rss(context, attr); - } - - /* Sanity check QP size before proceeding */ - if (ctx->max_qp_wr) { /* mlx4_query_device succeeded */ - if (attr->cap.max_send_wr > ctx->max_qp_wr || - attr->cap.max_recv_wr > ctx->max_qp_wr || - attr->cap.max_send_sge > ctx->max_sge || - attr->cap.max_recv_sge > ctx->max_sge) - return NULL; - } else { - if (attr->cap.max_send_wr > 65536 || - attr->cap.max_recv_wr > 65536 || - attr->cap.max_send_sge > 64 || - attr->cap.max_recv_sge > 64) - return NULL; - } - if (attr->cap.max_inline_data > 1024) - return NULL; - - if (attr->comp_mask & ~MLX4_CREATE_QP_SUP_COMP_MASK) - return NULL; - - qp = calloc(1, sizeof *qp); - if (!qp) - return NULL; - - if (attr->qp_type == IBV_QPT_XRC_RECV) { - attr->cap.max_send_wr = qp->sq.wqe_cnt = 0; - } else { - mlx4_calc_sq_wqe_size(&attr->cap, attr->qp_type, qp); - /* - * We need to leave 2 KB + 1 WQE of headroom in the SQ to - * allow HW to prefetch. - */ - qp->sq_spare_wqes = (2048 >> qp->sq.wqe_shift) + 1; - qp->sq.wqe_cnt = align_queue_size(attr->cap.max_send_wr + qp->sq_spare_wqes); - } - - if (attr->srq || attr->qp_type == IBV_QPT_XRC_SEND || - attr->qp_type == IBV_QPT_XRC_RECV) { - attr->cap.max_recv_wr = qp->rq.wqe_cnt = attr->cap.max_recv_sge = 0; - } else { - qp->rq.wqe_cnt = align_queue_size(attr->cap.max_recv_wr); - if (attr->cap.max_recv_sge < 1) - attr->cap.max_recv_sge = 1; - if (attr->cap.max_recv_wr < 1) - attr->cap.max_recv_wr = 1; - } - - if (mlx4_alloc_qp_buf(context, attr->cap.max_recv_sge, attr->qp_type, qp, - mlx4qp_attr)) - goto err; - - mlx4_init_qp_indices(qp); - - if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) || - pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE)) - goto err_free; - - if (mlx4qp_attr) { - if (mlx4qp_attr->comp_mask & - ~(MLX4DV_QP_INIT_ATTR_MASK_RESERVED - 1)) { - errno = EINVAL; - goto err_free; - } - if (mlx4qp_attr->comp_mask & MLX4DV_QP_INIT_ATTR_MASK_INL_RECV) - cmd.inl_recv_sz = mlx4qp_attr->inl_recv_sz; - } - if (attr->cap.max_recv_sge) { - qp->db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_RQ); - if (!qp->db) - goto err_free; - - *qp->db = 0; - cmd.db_addr = (uintptr_t) qp->db; - } else { - cmd.db_addr = 0; - } - - cmd.buf_addr = (uintptr_t) qp->buf.buf; - cmd.log_sq_stride = qp->sq.wqe_shift; - for (cmd.log_sq_bb_count = 0; - qp->sq.wqe_cnt > 1 << cmd.log_sq_bb_count; - ++cmd.log_sq_bb_count) - ; /* nothing */ - cmd.sq_no_prefetch = 0; /* OK for ABI 2: just a reserved field */ - pthread_mutex_lock(&to_mctx(context)->qp_table_mutex); - - - if (attr->comp_mask & MLX4_CREATE_QP_EX2_COMP_MASK) - ret = mlx4_cmd_create_qp_ex(context, attr, &cmd, qp); - else - ret = ibv_cmd_create_qp_ex(context, &qp->verbs_qp, - sizeof(qp->verbs_qp), attr, - &cmd.ibv_cmd, sizeof(cmd), &resp, - sizeof(resp)); - if (ret) - goto err_rq_db; - - if (qp->sq.wqe_cnt || qp->rq.wqe_cnt) { - ret = mlx4_store_qp(to_mctx(context), qp->verbs_qp.qp.qp_num, qp); - if (ret) - goto err_destroy; - } - pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex); - - qp->rq.wqe_cnt = qp->rq.max_post = attr->cap.max_recv_wr; - qp->rq.max_gs = attr->cap.max_recv_sge; - if (attr->qp_type != IBV_QPT_XRC_RECV) - mlx4_set_sq_sizes(qp, &attr->cap, attr->qp_type); - - qp->doorbell_qpn = htobe32(qp->verbs_qp.qp.qp_num << 8); - if (attr->sq_sig_all) - qp->sq_signal_bits = htobe32(MLX4_WQE_CTRL_CQ_UPDATE); - else - qp->sq_signal_bits = 0; - - qp->qpn_cache = qp->verbs_qp.qp.qp_num; - qp->type = attr->srq ? MLX4_RSC_TYPE_SRQ : MLX4_RSC_TYPE_QP; - - return &qp->verbs_qp.qp; - -err_destroy: - ibv_cmd_destroy_qp(&qp->verbs_qp.qp); - -err_rq_db: - pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex); - if (attr->cap.max_recv_sge) - mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_RQ, qp->db); - -err_free: - free(qp->sq.wrid); - if (qp->rq.wqe_cnt) - free(qp->rq.wrid); - mlx4_free_buf(&qp->buf); - -err: - free(qp); - - return NULL; -} - -struct ibv_qp *mlx4_create_qp_ex(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr) -{ - return create_qp_ex(context, attr, NULL); -} - -struct ibv_qp *mlx4dv_create_qp(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr, - struct mlx4dv_qp_init_attr *mlx4_qp_attr) -{ - return create_qp_ex(context, attr, mlx4_qp_attr); -} - -struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) -{ - struct ibv_qp_init_attr_ex attr_ex; - struct ibv_qp *qp; - - memcpy(&attr_ex, attr, sizeof *attr); - attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD; - attr_ex.pd = pd; - qp = mlx4_create_qp_ex(pd->context, &attr_ex); - if (qp) - memcpy(attr, &attr_ex, sizeof *attr); - return qp; -} - -struct ibv_qp *mlx4_open_qp(struct ibv_context *context, struct ibv_qp_open_attr *attr) -{ - struct ibv_open_qp cmd; - struct ibv_create_qp_resp resp; - struct mlx4_qp *qp; - int ret; - - qp = calloc(1, sizeof *qp); - if (!qp) - return NULL; - - ret = ibv_cmd_open_qp(context, &qp->verbs_qp, sizeof(qp->verbs_qp), attr, - &cmd, sizeof cmd, &resp, sizeof resp); - if (ret) - goto err; - - return &qp->verbs_qp.qp; - -err: - free(qp); - return NULL; -} - -int mlx4_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - struct mlx4_qp *qp = to_mqp(ibqp); - int ret; - - if (qp->type == MLX4_RSC_TYPE_RSS_QP) - return ENOTSUP; - - ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof cmd); - if (ret) - return ret; - - init_attr->cap.max_send_wr = qp->sq.max_post; - init_attr->cap.max_send_sge = qp->sq.max_gs; - init_attr->cap.max_inline_data = qp->max_inline_data; - - attr->cap = init_attr->cap; - - return 0; -} - -static int _mlx4_modify_qp_rss(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - - if (attr_mask & ~(IBV_QP_STATE | IBV_QP_PORT)) - return ENOTSUP; - - if (attr->qp_state > IBV_QPS_RTR) - return ENOTSUP; - - return ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof(cmd)); -} - -int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - struct ibv_port_attr port_attr; - struct mlx4_qp *mqp = to_mqp(qp); - struct ibv_device_attr device_attr; - int ret; - - if (mqp->type == MLX4_RSC_TYPE_RSS_QP) - return _mlx4_modify_qp_rss(qp, attr, attr_mask); - - memset(&device_attr, 0, sizeof(device_attr)); - if (attr_mask & IBV_QP_PORT) { - ret = ibv_query_port(qp->context, attr->port_num, - &port_attr); - if (ret) - return ret; - mqp->link_layer = port_attr.link_layer; - - ret = ibv_query_device(qp->context, &device_attr); - if (ret) - return ret; - - switch(qp->qp_type) { - case IBV_QPT_UD: - if ((mqp->link_layer == IBV_LINK_LAYER_INFINIBAND) && - (device_attr.device_cap_flags & IBV_DEVICE_UD_IP_CSUM)) - mqp->qp_cap_cache |= MLX4_CSUM_SUPPORT_UD_OVER_IB | - MLX4_RX_CSUM_VALID; - break; - case IBV_QPT_RAW_PACKET: - if ((mqp->link_layer == IBV_LINK_LAYER_ETHERNET) && - (device_attr.device_cap_flags & IBV_DEVICE_RAW_IP_CSUM)) - mqp->qp_cap_cache |= MLX4_CSUM_SUPPORT_RAW_OVER_ETH | - MLX4_RX_CSUM_VALID; - break; - default: - break; - } - - } - - if (qp->state == IBV_QPS_RESET && - attr_mask & IBV_QP_STATE && - attr->qp_state == IBV_QPS_INIT) { - mlx4_qp_init_sq_ownership(to_mqp(qp)); - } - - ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof cmd); - - if (!ret && - (attr_mask & IBV_QP_STATE) && - attr->qp_state == IBV_QPS_RESET) { - if (qp->recv_cq) - mlx4_cq_clean(to_mcq(qp->recv_cq), qp->qp_num, - qp->srq ? to_msrq(qp->srq) : NULL); - if (qp->send_cq && qp->send_cq != qp->recv_cq) - mlx4_cq_clean(to_mcq(qp->send_cq), qp->qp_num, NULL); - - mlx4_init_qp_indices(to_mqp(qp)); - if (to_mqp(qp)->rq.wqe_cnt) - *to_mqp(qp)->db = 0; - } - - return ret; -} - -static void mlx4_lock_cqs(struct ibv_qp *qp) -{ - struct mlx4_cq *send_cq = to_mcq(qp->send_cq); - struct mlx4_cq *recv_cq = to_mcq(qp->recv_cq); - - if (!qp->send_cq || !qp->recv_cq) { - if (qp->send_cq) - pthread_spin_lock(&send_cq->lock); - else if (qp->recv_cq) - pthread_spin_lock(&recv_cq->lock); - } else if (send_cq == recv_cq) { - pthread_spin_lock(&send_cq->lock); - } else if (send_cq->cqn < recv_cq->cqn) { - pthread_spin_lock(&send_cq->lock); - pthread_spin_lock(&recv_cq->lock); - } else { - pthread_spin_lock(&recv_cq->lock); - pthread_spin_lock(&send_cq->lock); - } -} - -static void mlx4_unlock_cqs(struct ibv_qp *qp) -{ - struct mlx4_cq *send_cq = to_mcq(qp->send_cq); - struct mlx4_cq *recv_cq = to_mcq(qp->recv_cq); - - - if (!qp->send_cq || !qp->recv_cq) { - if (qp->send_cq) - pthread_spin_unlock(&send_cq->lock); - else if (qp->recv_cq) - pthread_spin_unlock(&recv_cq->lock); - } else if (send_cq == recv_cq) { - pthread_spin_unlock(&send_cq->lock); - } else if (send_cq->cqn < recv_cq->cqn) { - pthread_spin_unlock(&recv_cq->lock); - pthread_spin_unlock(&send_cq->lock); - } else { - pthread_spin_unlock(&send_cq->lock); - pthread_spin_unlock(&recv_cq->lock); - } -} - -static int _mlx4_destroy_qp_rss(struct ibv_qp *ibqp) -{ - struct mlx4_qp *qp = to_mqp(ibqp); - int ret; - - ret = ibv_cmd_destroy_qp(ibqp); - if (ret && !cleanup_on_fatal(ret)) - return ret; - - free(qp); - - return 0; -} - -int mlx4_destroy_qp(struct ibv_qp *ibqp) -{ - struct mlx4_qp *qp = to_mqp(ibqp); - int ret; - - if (qp->type == MLX4_RSC_TYPE_RSS_QP) - return _mlx4_destroy_qp_rss(ibqp); - - pthread_mutex_lock(&to_mctx(ibqp->context)->qp_table_mutex); - ret = ibv_cmd_destroy_qp(ibqp); - if (ret && !cleanup_on_fatal(ret)) { - pthread_mutex_unlock(&to_mctx(ibqp->context)->qp_table_mutex); - return ret; - } - - mlx4_lock_cqs(ibqp); - - if (ibqp->recv_cq) - __mlx4_cq_clean(to_mcq(ibqp->recv_cq), ibqp->qp_num, - ibqp->srq ? to_msrq(ibqp->srq) : NULL); - if (ibqp->send_cq && ibqp->send_cq != ibqp->recv_cq) - __mlx4_cq_clean(to_mcq(ibqp->send_cq), ibqp->qp_num, NULL); - - if (qp->sq.wqe_cnt || qp->rq.wqe_cnt) - mlx4_clear_qp(to_mctx(ibqp->context), ibqp->qp_num); - - mlx4_unlock_cqs(ibqp); - pthread_mutex_unlock(&to_mctx(ibqp->context)->qp_table_mutex); - - if (qp->rq.wqe_cnt) { - mlx4_free_db(to_mctx(ibqp->context), MLX4_DB_TYPE_RQ, qp->db); - free(qp->rq.wrid); - } - if (qp->sq.wqe_cnt) - free(qp->sq.wrid); - mlx4_free_buf(&qp->buf); - free(qp); - - return 0; -} - -static int link_local_gid(const union ibv_gid *gid) -{ - return gid->global.subnet_prefix == htobe64(0xfe80000000000000ULL); -} - -static int is_multicast_gid(const union ibv_gid *gid) -{ - return gid->raw[0] == 0xff; -} - -static uint16_t get_vlan_id(union ibv_gid *gid) -{ - uint16_t vid; - vid = gid->raw[11] << 8 | gid->raw[12]; - return vid < 0x1000 ? vid : 0xffff; -} - -static int mlx4_resolve_grh_to_l2(struct ibv_pd *pd, struct mlx4_ah *ah, - struct ibv_ah_attr *attr) -{ - int err, i; - uint16_t vid; - union ibv_gid sgid; - - if (link_local_gid(&attr->grh.dgid)) { - memcpy(ah->mac, &attr->grh.dgid.raw[8], 3); - memcpy(ah->mac + 3, &attr->grh.dgid.raw[13], 3); - ah->mac[0] ^= 2; - - vid = get_vlan_id(&attr->grh.dgid); - } else if (is_multicast_gid(&attr->grh.dgid)) { - ah->mac[0] = 0x33; - ah->mac[1] = 0x33; - for (i = 2; i < 6; ++i) - ah->mac[i] = attr->grh.dgid.raw[i + 10]; - - err = ibv_query_gid(pd->context, attr->port_num, - attr->grh.sgid_index, &sgid); - if (err) - return err; - - ah->av.dlid = htobe16(0xc000); - ah->av.port_pd |= htobe32(1 << 31); - - vid = get_vlan_id(&sgid); - } else - return 1; - - if (vid != 0xffff) { - ah->av.port_pd |= htobe32(1 << 29); - ah->vlan = vid | ((attr->sl & 7) << 13); - } - - return 0; -} - -struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - struct mlx4_ah *ah; - struct ibv_port_attr port_attr; - - if (query_port_cache(pd->context, attr->port_num, &port_attr)) - return NULL; - - ah = malloc(sizeof *ah); - if (!ah) - return NULL; - - memset(&ah->av, 0, sizeof ah->av); - - ah->av.port_pd = htobe32(to_mpd(pd)->pdn | (attr->port_num << 24)); - - if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { - ah->av.g_slid = attr->src_path_bits; - ah->av.dlid = htobe16(attr->dlid); - ah->av.sl_tclass_flowlabel = htobe32(attr->sl << 28); - } else - ah->av.sl_tclass_flowlabel = htobe32(attr->sl << 29); - - if (attr->static_rate) { - ah->av.stat_rate = attr->static_rate + MLX4_STAT_RATE_OFFSET; - /* XXX check rate cap? */ - } - if (attr->is_global) { - ah->av.g_slid |= 0x80; - ah->av.gid_index = attr->grh.sgid_index; - ah->av.hop_limit = attr->grh.hop_limit; - ah->av.sl_tclass_flowlabel |= - htobe32((attr->grh.traffic_class << 20) | - attr->grh.flow_label); - memcpy(ah->av.dgid, attr->grh.dgid.raw, 16); - } - - if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) { - if (port_attr.port_cap_flags & IBV_PORT_IP_BASED_GIDS) { - uint16_t vid; - - if (ibv_resolve_eth_l2_from_gid(pd->context, attr, - ah->mac, &vid)) { - free(ah); - return NULL; - } - - if (vid <= 0xfff) { - ah->av.port_pd |= htobe32(1 << 29); - ah->vlan = vid | - ((attr->sl & 7) << 13); - } - - } else { - if (mlx4_resolve_grh_to_l2(pd, ah, attr)) { - free(ah); - return NULL; - } - } - } - - return &ah->ibv_ah; -} - -int mlx4_destroy_ah(struct ibv_ah *ah) -{ - free(to_mah(ah)); - - return 0; -} - -struct ibv_wq *mlx4_create_wq(struct ibv_context *context, - struct ibv_wq_init_attr *attr) -{ - struct mlx4_context *ctx = to_mctx(context); - struct mlx4_create_wq cmd = {}; - struct ibv_create_wq_resp resp = {}; - struct mlx4_qp *qp; - int ret; - - if (attr->wq_type != IBV_WQT_RQ) { - errno = ENOTSUP; - return NULL; - } - - /* Sanity check QP size before proceeding */ - if (ctx->max_qp_wr) { /* mlx4_query_device succeeded */ - if (attr->max_wr > ctx->max_qp_wr || - attr->max_sge > ctx->max_sge) { - errno = EINVAL; - return NULL; - } - } else { - if (attr->max_wr > 65536 || - attr->max_sge > 64) { - errno = EINVAL; - return NULL; - } - } - - if (attr->comp_mask) { - errno = ENOTSUP; - return NULL; - } - - qp = calloc(1, sizeof(*qp)); - if (!qp) - return NULL; - - if (attr->max_sge < 1) - attr->max_sge = 1; - - if (attr->max_wr < 1) - attr->max_wr = 1; - - /* Kernel driver requires a dummy SQ with minimum properties */ - qp->sq.wqe_shift = 6; - qp->sq.wqe_cnt = 1; - - qp->rq.wqe_cnt = align_queue_size(attr->max_wr); - - if (mlx4_alloc_qp_buf(context, attr->max_sge, IBV_QPT_RAW_PACKET, qp, NULL)) - goto err; - - mlx4_init_qp_indices(qp); - mlx4_qp_init_sq_ownership(qp); /* For dummy SQ */ - - if (pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE)) - goto err_free; - - qp->db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_RQ); - if (!qp->db) - goto err_free; - - *qp->db = 0; - cmd.drv.db_addr = (uintptr_t)qp->db; - - cmd.drv.buf_addr = (uintptr_t)qp->buf.buf; - - cmd.drv.log_range_size = ctx->log_wqs_range_sz; - - pthread_mutex_lock(&to_mctx(context)->qp_table_mutex); - - ret = ibv_cmd_create_wq(context, attr, &qp->wq, &cmd.ibv_cmd, - sizeof(cmd.ibv_cmd), - sizeof(cmd), - &resp, sizeof(resp), - sizeof(resp)); - if (ret) - goto err_rq_db; - - ret = mlx4_store_qp(to_mctx(context), qp->wq.wq_num, qp); - if (ret) - goto err_destroy; - - pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex); - - ctx->log_wqs_range_sz = 0; - - qp->rq.max_post = attr->max_wr; - qp->rq.wqe_cnt = attr->max_wr; - qp->rq.max_gs = attr->max_sge; - - qp->wq.state = IBV_WQS_RESET; - - qp->wq.post_recv = mlx4_post_wq_recv; - - qp->qpn_cache = qp->wq.wq_num; - - return &qp->wq; - -err_destroy: - ibv_cmd_destroy_wq(&qp->wq); - -err_rq_db: - pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex); - mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_RQ, qp->db); - -err_free: - free(qp->rq.wrid); - mlx4_free_buf(&qp->buf); - -err: - free(qp); - - return NULL; -} - -int mlx4_modify_wq(struct ibv_wq *ibwq, struct ibv_wq_attr *attr) -{ - struct mlx4_qp *qp = wq_to_mqp(ibwq); - struct mlx4_modify_wq cmd = {}; - int ret; - - ret = ibv_cmd_modify_wq(ibwq, attr, &cmd.ibv_cmd, sizeof(cmd.ibv_cmd), - sizeof(cmd)); - - if (!ret && (attr->attr_mask & IBV_WQ_ATTR_STATE) && - (ibwq->state == IBV_WQS_RESET)) { - mlx4_cq_clean(to_mcq(ibwq->cq), ibwq->wq_num, NULL); - - mlx4_init_qp_indices(qp); - *qp->db = 0; - } - - return ret; -} - -int mlx4_destroy_wq(struct ibv_wq *ibwq) -{ - struct mlx4_context *mcontext = to_mctx(ibwq->context); - struct mlx4_qp *qp = wq_to_mqp(ibwq); - struct mlx4_cq *cq = NULL; - int ret; - - pthread_mutex_lock(&mcontext->qp_table_mutex); - - ret = ibv_cmd_destroy_wq(ibwq); - if (ret && !cleanup_on_fatal(ret)) { - pthread_mutex_unlock(&mcontext->qp_table_mutex); - return ret; - } - - cq = to_mcq(ibwq->cq); - pthread_spin_lock(&cq->lock); - __mlx4_cq_clean(cq, ibwq->wq_num, NULL); - - mlx4_clear_qp(mcontext, ibwq->wq_num); - - pthread_spin_unlock(&cq->lock); - - pthread_mutex_unlock(&mcontext->qp_table_mutex); - - mlx4_free_db(mcontext, MLX4_DB_TYPE_RQ, qp->db); - free(qp->rq.wrid); - free(qp->sq.wrid); - - mlx4_free_buf(&qp->buf); - - free(qp); - - return 0; -} - -struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context, - struct ibv_rwq_ind_table_init_attr *init_attr) -{ - struct ibv_create_rwq_ind_table *cmd; - struct ibv_create_rwq_ind_table_resp resp = {}; - struct ibv_rwq_ind_table *ind_table; - uint32_t required_tbl_size; - unsigned int num_tbl_entries; - int cmd_size; - int err; - - num_tbl_entries = 1 << init_attr->log_ind_tbl_size; - /* Data must be u64 aligned */ - required_tbl_size = - (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ? - sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t)); - - cmd_size = required_tbl_size + sizeof(*cmd); - cmd = calloc(1, cmd_size); - if (!cmd) - return NULL; - - ind_table = calloc(1, sizeof(*ind_table)); - if (!ind_table) - goto free_cmd; - - err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, cmd, - cmd_size, cmd_size, &resp, - sizeof(resp), sizeof(resp)); - if (err) - goto err; - - free(cmd); - return ind_table; - -err: - free(ind_table); -free_cmd: - free(cmd); - return NULL; -} - -int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table) -{ - int ret; - - ret = ibv_cmd_destroy_rwq_ind_table(rwq_ind_table); - - if (ret && !cleanup_on_fatal(ret)) - return ret; - - free(rwq_ind_table); - return 0; -} diff --git a/usr/rdma-core/providers/mlx5/CMakeLists.txt b/usr/rdma-core/providers/mlx5/CMakeLists.txt deleted file mode 100644 index ab6a42d89..000000000 --- a/usr/rdma-core/providers/mlx5/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -set(MLX5_DEBUG "FALSE" CACHE BOOL - "Enable expensive runtime logging options for the mlx5 verbs provider") -if (MLX5_DEBUG) - add_definitions("-DMLX5_DEBUG") -endif() - -set(MLX5_MW_DEBUG "FALSE" CACHE BOOL - "Enable extra validation of memory windows for the mlx5 verbs provider") -if (MLX5_MW_DEBUG) - add_definitions("-DMW_DEBUG") -endif() - -rdma_shared_provider(mlx5 libmlx5.map - 1 1.2.${PACKAGE_VERSION} - buf.c - cq.c - dbrec.c - mlx5.c - qp.c - srq.c - verbs.c -) - -publish_headers(infiniband - mlx5dv.h -) diff --git a/usr/rdma-core/providers/mlx5/bitmap.h b/usr/rdma-core/providers/mlx5/bitmap.h deleted file mode 100644 index c0cee3c59..000000000 --- a/usr/rdma-core/providers/mlx5/bitmap.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2000, 2011 Mellanox Technology Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef BITMAP_H -#define BITMAP_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mlx5.h" - -/* Only ia64 requires this */ -#ifdef __ia64__ -#define MLX5_SHM_ADDR ((void *)0x8000000000000000UL) -#define MLX5_SHMAT_FLAGS (SHM_RND) -#else -#define MLX5_SHM_ADDR NULL -#define MLX5_SHMAT_FLAGS 0 -#endif - -#define BITS_PER_LONG (8 * sizeof(long)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) - -#ifndef HPAGE_SIZE -#define HPAGE_SIZE (2UL * 1024 * 1024) -#endif - -#define MLX5_SHM_LENGTH HPAGE_SIZE -#define MLX5_Q_CHUNK_SIZE 32768 -#define MLX5_SHM_NUM_REGION 64 - -static inline unsigned long mlx5_ffz(uint32_t word) -{ - return __builtin_ffs(~word) - 1; -} - -static inline uint32_t mlx5_find_first_zero_bit(const unsigned long *addr, - uint32_t size) -{ - const unsigned long *p = addr; - uint32_t result = 0; - unsigned long tmp; - - while (size & ~(BITS_PER_LONG - 1)) { - tmp = *(p++); - if (~tmp) - goto found; - result += BITS_PER_LONG; - size -= BITS_PER_LONG; - } - if (!size) - return result; - - tmp = (*p) | (~0UL << size); - if (tmp == (uint32_t)~0UL) /* Are any bits zero? */ - return result + size; /* Nope. */ -found: - return result + mlx5_ffz(tmp); -} - -static inline void mlx5_set_bit(unsigned int nr, unsigned long *addr) -{ - addr[(nr / BITS_PER_LONG)] |= (1 << (nr % BITS_PER_LONG)); -} - -static inline void mlx5_clear_bit(unsigned int nr, unsigned long *addr) -{ - addr[(nr / BITS_PER_LONG)] &= ~(1 << (nr % BITS_PER_LONG)); -} - -static inline int mlx5_test_bit(unsigned int nr, const unsigned long *addr) -{ - return !!(addr[(nr / BITS_PER_LONG)] & (1 << (nr % BITS_PER_LONG))); -} - -#endif diff --git a/usr/rdma-core/providers/mlx5/buf.c b/usr/rdma-core/providers/mlx5/buf.c deleted file mode 100644 index 8196db695..000000000 --- a/usr/rdma-core/providers/mlx5/buf.c +++ /dev/null @@ -1,620 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "mlx5.h" -#include "bitmap.h" - -static int mlx5_bitmap_init(struct mlx5_bitmap *bitmap, uint32_t num, - uint32_t mask) -{ - bitmap->last = 0; - bitmap->top = 0; - bitmap->max = num; - bitmap->avail = num; - bitmap->mask = mask; - bitmap->avail = bitmap->max; - bitmap->table = calloc(BITS_TO_LONGS(bitmap->max), sizeof(uint32_t)); - if (!bitmap->table) - return -ENOMEM; - - return 0; -} - -static void bitmap_free_range(struct mlx5_bitmap *bitmap, uint32_t obj, - int cnt) -{ - int i; - - obj &= bitmap->max - 1; - - for (i = 0; i < cnt; i++) - mlx5_clear_bit(obj + i, bitmap->table); - bitmap->last = min(bitmap->last, obj); - bitmap->top = (bitmap->top + bitmap->max) & bitmap->mask; - bitmap->avail += cnt; -} - -static int bitmap_empty(struct mlx5_bitmap *bitmap) -{ - return (bitmap->avail == bitmap->max) ? 1 : 0; -} - -static int bitmap_avail(struct mlx5_bitmap *bitmap) -{ - return bitmap->avail; -} - -static void mlx5_bitmap_cleanup(struct mlx5_bitmap *bitmap) -{ - if (bitmap->table) - free(bitmap->table); -} - -static void free_huge_mem(struct mlx5_hugetlb_mem *hmem) -{ - mlx5_bitmap_cleanup(&hmem->bitmap); - if (shmdt(hmem->shmaddr) == -1) - mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno)); - shmctl(hmem->shmid, IPC_RMID, NULL); - free(hmem); -} - -static int mlx5_bitmap_alloc(struct mlx5_bitmap *bitmap) -{ - uint32_t obj; - int ret; - - obj = mlx5_find_first_zero_bit(bitmap->table, bitmap->max); - if (obj < bitmap->max) { - mlx5_set_bit(obj, bitmap->table); - bitmap->last = (obj + 1); - if (bitmap->last == bitmap->max) - bitmap->last = 0; - obj |= bitmap->top; - ret = obj; - } else - ret = -1; - - if (ret != -1) - --bitmap->avail; - - return ret; -} - -static uint32_t find_aligned_range(unsigned long *bitmap, - uint32_t start, uint32_t nbits, - int len, int alignment) -{ - uint32_t end, i; - -again: - start = align(start, alignment); - - while ((start < nbits) && mlx5_test_bit(start, bitmap)) - start += alignment; - - if (start >= nbits) - return -1; - - end = start + len; - if (end > nbits) - return -1; - - for (i = start + 1; i < end; i++) { - if (mlx5_test_bit(i, bitmap)) { - start = i + 1; - goto again; - } - } - - return start; -} - -static int bitmap_alloc_range(struct mlx5_bitmap *bitmap, int cnt, - int align) -{ - uint32_t obj; - int ret, i; - - if (cnt == 1 && align == 1) - return mlx5_bitmap_alloc(bitmap); - - if (cnt > bitmap->max) - return -1; - - obj = find_aligned_range(bitmap->table, bitmap->last, - bitmap->max, cnt, align); - if (obj >= bitmap->max) { - bitmap->top = (bitmap->top + bitmap->max) & bitmap->mask; - obj = find_aligned_range(bitmap->table, 0, bitmap->max, - cnt, align); - } - - if (obj < bitmap->max) { - for (i = 0; i < cnt; i++) - mlx5_set_bit(obj + i, bitmap->table); - if (obj == bitmap->last) { - bitmap->last = (obj + cnt); - if (bitmap->last >= bitmap->max) - bitmap->last = 0; - } - obj |= bitmap->top; - ret = obj; - } else - ret = -1; - - if (ret != -1) - bitmap->avail -= cnt; - - return obj; -} - -static struct mlx5_hugetlb_mem *alloc_huge_mem(size_t size) -{ - struct mlx5_hugetlb_mem *hmem; - size_t shm_len; - - hmem = malloc(sizeof(*hmem)); - if (!hmem) - return NULL; - - shm_len = align(size, MLX5_SHM_LENGTH); - hmem->shmid = shmget(IPC_PRIVATE, shm_len, SHM_HUGETLB | SHM_R | SHM_W); - if (hmem->shmid == -1) { - mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno)); - goto out_free; - } - - hmem->shmaddr = shmat(hmem->shmid, MLX5_SHM_ADDR, MLX5_SHMAT_FLAGS); - if (hmem->shmaddr == (void *)-1) { - mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno)); - goto out_rmid; - } - - if (mlx5_bitmap_init(&hmem->bitmap, shm_len / MLX5_Q_CHUNK_SIZE, - shm_len / MLX5_Q_CHUNK_SIZE - 1)) { - mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno)); - goto out_shmdt; - } - - /* - * Marked to be destroyed when process detaches from shmget segment - */ - shmctl(hmem->shmid, IPC_RMID, NULL); - - return hmem; - -out_shmdt: - if (shmdt(hmem->shmaddr) == -1) - mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno)); - -out_rmid: - shmctl(hmem->shmid, IPC_RMID, NULL); - -out_free: - free(hmem); - return NULL; -} - -static int alloc_huge_buf(struct mlx5_context *mctx, struct mlx5_buf *buf, - size_t size, int page_size) -{ - int found = 0; - int nchunk; - struct mlx5_hugetlb_mem *hmem; - int ret; - - buf->length = align(size, MLX5_Q_CHUNK_SIZE); - nchunk = buf->length / MLX5_Q_CHUNK_SIZE; - - mlx5_spin_lock(&mctx->hugetlb_lock); - list_for_each(&mctx->hugetlb_list, hmem, entry) { - if (bitmap_avail(&hmem->bitmap)) { - buf->base = bitmap_alloc_range(&hmem->bitmap, nchunk, 1); - if (buf->base != -1) { - buf->hmem = hmem; - found = 1; - break; - } - } - } - mlx5_spin_unlock(&mctx->hugetlb_lock); - - if (!found) { - hmem = alloc_huge_mem(buf->length); - if (!hmem) - return -1; - - buf->base = bitmap_alloc_range(&hmem->bitmap, nchunk, 1); - if (buf->base == -1) { - free_huge_mem(hmem); - /* TBD: remove after proven stability */ - fprintf(stderr, "BUG: huge allocation\n"); - return -1; - } - - buf->hmem = hmem; - - mlx5_spin_lock(&mctx->hugetlb_lock); - if (bitmap_avail(&hmem->bitmap)) - list_add(&mctx->hugetlb_list, &hmem->entry); - else - list_add_tail(&mctx->hugetlb_list, &hmem->entry); - mlx5_spin_unlock(&mctx->hugetlb_lock); - } - - buf->buf = hmem->shmaddr + buf->base * MLX5_Q_CHUNK_SIZE; - - ret = ibv_dontfork_range(buf->buf, buf->length); - if (ret) { - mlx5_dbg(stderr, MLX5_DBG_CONTIG, "\n"); - goto out_fork; - } - buf->type = MLX5_ALLOC_TYPE_HUGE; - - return 0; - -out_fork: - mlx5_spin_lock(&mctx->hugetlb_lock); - bitmap_free_range(&hmem->bitmap, buf->base, nchunk); - if (bitmap_empty(&hmem->bitmap)) { - list_del(&hmem->entry); - mlx5_spin_unlock(&mctx->hugetlb_lock); - free_huge_mem(hmem); - } else - mlx5_spin_unlock(&mctx->hugetlb_lock); - - return -1; -} - -static void free_huge_buf(struct mlx5_context *ctx, struct mlx5_buf *buf) -{ - int nchunk; - - nchunk = buf->length / MLX5_Q_CHUNK_SIZE; - mlx5_spin_lock(&ctx->hugetlb_lock); - bitmap_free_range(&buf->hmem->bitmap, buf->base, nchunk); - if (bitmap_empty(&buf->hmem->bitmap)) { - list_del(&buf->hmem->entry); - mlx5_spin_unlock(&ctx->hugetlb_lock); - free_huge_mem(buf->hmem); - } else - mlx5_spin_unlock(&ctx->hugetlb_lock); -} - -void mlx5_free_buf_extern(struct mlx5_context *ctx, struct mlx5_buf *buf) -{ - ibv_dofork_range(buf->buf, buf->length); - ctx->extern_alloc.free(buf->buf, ctx->extern_alloc.data); -} - -int mlx5_alloc_buf_extern(struct mlx5_context *ctx, struct mlx5_buf *buf, - size_t size) -{ - void *addr; - - addr = ctx->extern_alloc.alloc(size, ctx->extern_alloc.data); - if (addr || size == 0) { - if (ibv_dontfork_range(addr, size)) { - mlx5_dbg(stderr, MLX5_DBG_CONTIG, - "External mode dontfork_range failed\n"); - ctx->extern_alloc.free(addr, - ctx->extern_alloc.data); - return -1; - } - buf->buf = addr; - buf->length = size; - buf->type = MLX5_ALLOC_TYPE_EXTERNAL; - return 0; - } - - mlx5_dbg(stderr, MLX5_DBG_CONTIG, "External alloc failed\n"); - return -1; -} - -int mlx5_alloc_prefered_buf(struct mlx5_context *mctx, - struct mlx5_buf *buf, - size_t size, int page_size, - enum mlx5_alloc_type type, - const char *component) -{ - int ret; - - /* - * Fallback mechanism priority: - * huge pages - * contig pages - * default - */ - if (type == MLX5_ALLOC_TYPE_HUGE || - type == MLX5_ALLOC_TYPE_PREFER_HUGE || - type == MLX5_ALLOC_TYPE_ALL) { - ret = alloc_huge_buf(mctx, buf, size, page_size); - if (!ret) - return 0; - - if (type == MLX5_ALLOC_TYPE_HUGE) - return -1; - - mlx5_dbg(stderr, MLX5_DBG_CONTIG, - "Huge mode allocation failed, fallback to %s mode\n", - MLX5_ALLOC_TYPE_ALL ? "contig" : "default"); - } - - if (type == MLX5_ALLOC_TYPE_CONTIG || - type == MLX5_ALLOC_TYPE_PREFER_CONTIG || - type == MLX5_ALLOC_TYPE_ALL) { - ret = mlx5_alloc_buf_contig(mctx, buf, size, page_size, component); - if (!ret) - return 0; - - if (type == MLX5_ALLOC_TYPE_CONTIG) - return -1; - mlx5_dbg(stderr, MLX5_DBG_CONTIG, - "Contig allocation failed, fallback to default mode\n"); - } - - if (type == MLX5_ALLOC_TYPE_EXTERNAL) - return mlx5_alloc_buf_extern(mctx, buf, size); - - return mlx5_alloc_buf(buf, size, page_size); - -} - -int mlx5_free_actual_buf(struct mlx5_context *ctx, struct mlx5_buf *buf) -{ - int err = 0; - - switch (buf->type) { - case MLX5_ALLOC_TYPE_ANON: - mlx5_free_buf(buf); - break; - - case MLX5_ALLOC_TYPE_HUGE: - free_huge_buf(ctx, buf); - break; - - case MLX5_ALLOC_TYPE_CONTIG: - mlx5_free_buf_contig(ctx, buf); - break; - - case MLX5_ALLOC_TYPE_EXTERNAL: - mlx5_free_buf_extern(ctx, buf); - break; - - default: - fprintf(stderr, "Bad allocation type\n"); - } - - return err; -} - -/* This function computes log2(v) rounded up. - We don't want to have a dependency to libm which exposes ceil & log2 APIs. - Code was written based on public domain code: - URL: http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog. -*/ -static uint32_t mlx5_get_block_order(uint32_t v) -{ - static const uint32_t bits_arr[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; - static const uint32_t shift_arr[] = {1, 2, 4, 8, 16}; - int i; - uint32_t input_val = v; - - register uint32_t r = 0;/* result of log2(v) will go here */ - for (i = 4; i >= 0; i--) { - if (v & bits_arr[i]) { - v >>= shift_arr[i]; - r |= shift_arr[i]; - } - } - /* Rounding up if required */ - r += !!(input_val & ((1 << r) - 1)); - - return r; -} - -bool mlx5_is_extern_alloc(struct mlx5_context *context) -{ - return context->extern_alloc.alloc && context->extern_alloc.free; -} - -void mlx5_get_alloc_type(struct mlx5_context *context, - const char *component, - enum mlx5_alloc_type *alloc_type, - enum mlx5_alloc_type default_type) - -{ - char *env_value; - char name[128]; - - if (mlx5_is_extern_alloc(context)) { - *alloc_type = MLX5_ALLOC_TYPE_EXTERNAL; - return; - } - - snprintf(name, sizeof(name), "%s_ALLOC_TYPE", component); - - *alloc_type = default_type; - - env_value = getenv(name); - if (env_value) { - if (!strcasecmp(env_value, "ANON")) - *alloc_type = MLX5_ALLOC_TYPE_ANON; - else if (!strcasecmp(env_value, "HUGE")) - *alloc_type = MLX5_ALLOC_TYPE_HUGE; - else if (!strcasecmp(env_value, "CONTIG")) - *alloc_type = MLX5_ALLOC_TYPE_CONTIG; - else if (!strcasecmp(env_value, "PREFER_CONTIG")) - *alloc_type = MLX5_ALLOC_TYPE_PREFER_CONTIG; - else if (!strcasecmp(env_value, "PREFER_HUGE")) - *alloc_type = MLX5_ALLOC_TYPE_PREFER_HUGE; - else if (!strcasecmp(env_value, "ALL")) - *alloc_type = MLX5_ALLOC_TYPE_ALL; - } -} - -static void mlx5_alloc_get_env_info(int *max_block_log, - int *min_block_log, - const char *component) - -{ - char *env; - int value; - char name[128]; - - /* First set defaults */ - *max_block_log = MLX5_MAX_LOG2_CONTIG_BLOCK_SIZE; - *min_block_log = MLX5_MIN_LOG2_CONTIG_BLOCK_SIZE; - - snprintf(name, sizeof(name), "%s_MAX_LOG2_CONTIG_BSIZE", component); - env = getenv(name); - if (env) { - value = atoi(env); - if (value <= MLX5_MAX_LOG2_CONTIG_BLOCK_SIZE && - value >= MLX5_MIN_LOG2_CONTIG_BLOCK_SIZE) - *max_block_log = value; - else - fprintf(stderr, "Invalid value %d for %s\n", - value, name); - } - sprintf(name, "%s_MIN_LOG2_CONTIG_BSIZE", component); - env = getenv(name); - if (env) { - value = atoi(env); - if (value >= MLX5_MIN_LOG2_CONTIG_BLOCK_SIZE && - value <= *max_block_log) - *min_block_log = value; - else - fprintf(stderr, "Invalid value %d for %s\n", - value, name); - } -} - -int mlx5_alloc_buf_contig(struct mlx5_context *mctx, - struct mlx5_buf *buf, size_t size, - int page_size, - const char *component) -{ - void *addr = MAP_FAILED; - int block_size_exp; - int max_block_log; - int min_block_log; - struct ibv_context *context = &mctx->ibv_ctx; - off_t offset; - - mlx5_alloc_get_env_info(&max_block_log, - &min_block_log, - component); - - block_size_exp = mlx5_get_block_order(size); - - if (block_size_exp > max_block_log) - block_size_exp = max_block_log; - - do { - offset = 0; - set_command(MLX5_MMAP_GET_CONTIGUOUS_PAGES_CMD, &offset); - set_order(block_size_exp, &offset); - addr = mmap(NULL , size, PROT_WRITE | PROT_READ, MAP_SHARED, - context->cmd_fd, page_size * offset); - if (addr != MAP_FAILED) - break; - - /* - * The kernel returns EINVAL if not supported - */ - if (errno == EINVAL) - return -1; - - block_size_exp -= 1; - } while (block_size_exp >= min_block_log); - mlx5_dbg(mctx->dbg_fp, MLX5_DBG_CONTIG, "block order %d, addr %p\n", - block_size_exp, addr); - - if (addr == MAP_FAILED) - return -1; - - if (ibv_dontfork_range(addr, size)) { - munmap(addr, size); - return -1; - } - - buf->buf = addr; - buf->length = size; - buf->type = MLX5_ALLOC_TYPE_CONTIG; - - return 0; -} - -void mlx5_free_buf_contig(struct mlx5_context *mctx, struct mlx5_buf *buf) -{ - ibv_dofork_range(buf->buf, buf->length); - munmap(buf->buf, buf->length); -} - -int mlx5_alloc_buf(struct mlx5_buf *buf, size_t size, int page_size) -{ - int ret; - int al_size; - - al_size = align(size, page_size); - ret = posix_memalign(&buf->buf, page_size, al_size); - if (ret) - return ret; - - ret = ibv_dontfork_range(buf->buf, al_size); - if (ret) - free(buf->buf); - - if (!ret) { - buf->length = al_size; - buf->type = MLX5_ALLOC_TYPE_ANON; - } - - return ret; -} - -void mlx5_free_buf(struct mlx5_buf *buf) -{ - ibv_dofork_range(buf->buf, buf->length); - free(buf->buf); -} diff --git a/usr/rdma-core/providers/mlx5/cq.c b/usr/rdma-core/providers/mlx5/cq.c deleted file mode 100644 index de261dda9..000000000 --- a/usr/rdma-core/providers/mlx5/cq.c +++ /dev/null @@ -1,1525 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "mlx5.h" -#include "wqe.h" - -enum { - CQ_OK = 0, - CQ_EMPTY = -1, - CQ_POLL_ERR = -2 -}; - -enum { - MLX5_CQ_MODIFY_RESEIZE = 0, - MLX5_CQ_MODIFY_MODER = 1, - MLX5_CQ_MODIFY_MAPPING = 2, -}; - -int mlx5_stall_num_loop = 60; -int mlx5_stall_cq_poll_min = 60; -int mlx5_stall_cq_poll_max = 100000; -int mlx5_stall_cq_inc_step = 100; -int mlx5_stall_cq_dec_step = 10; - -static inline uint8_t get_cqe_l3_hdr_type(struct mlx5_cqe64 *cqe) -{ - return (cqe->l4_hdr_type_etc >> 2) & 0x3; -} - -static void *get_buf_cqe(struct mlx5_buf *buf, int n, int cqe_sz) -{ - return buf->buf + n * cqe_sz; -} - -static void *get_cqe(struct mlx5_cq *cq, int n) -{ - return cq->active_buf->buf + n * cq->cqe_sz; -} - -static void *get_sw_cqe(struct mlx5_cq *cq, int n) -{ - void *cqe = get_cqe(cq, n & cq->ibv_cq.cqe); - struct mlx5_cqe64 *cqe64; - - cqe64 = (cq->cqe_sz == 64) ? cqe : cqe + 64; - - if (likely(mlx5dv_get_cqe_opcode(cqe64) != MLX5_CQE_INVALID) && - !((cqe64->op_own & MLX5_CQE_OWNER_MASK) ^ !!(n & (cq->ibv_cq.cqe + 1)))) { - return cqe; - } else { - return NULL; - } -} - -static void *next_cqe_sw(struct mlx5_cq *cq) -{ - return get_sw_cqe(cq, cq->cons_index); -} - -static void update_cons_index(struct mlx5_cq *cq) -{ - cq->dbrec[MLX5_CQ_SET_CI] = htobe32(cq->cons_index & 0xffffff); -} - -static inline void handle_good_req(struct ibv_wc *wc, struct mlx5_cqe64 *cqe, struct mlx5_wq *wq, int idx) -{ - switch (be32toh(cqe->sop_drop_qpn) >> 24) { - case MLX5_OPCODE_RDMA_WRITE_IMM: - wc->wc_flags |= IBV_WC_WITH_IMM; - SWITCH_FALLTHROUGH; - case MLX5_OPCODE_RDMA_WRITE: - wc->opcode = IBV_WC_RDMA_WRITE; - break; - case MLX5_OPCODE_SEND_IMM: - wc->wc_flags |= IBV_WC_WITH_IMM; - SWITCH_FALLTHROUGH; - case MLX5_OPCODE_SEND: - case MLX5_OPCODE_SEND_INVAL: - wc->opcode = IBV_WC_SEND; - break; - case MLX5_OPCODE_RDMA_READ: - wc->opcode = IBV_WC_RDMA_READ; - wc->byte_len = be32toh(cqe->byte_cnt); - break; - case MLX5_OPCODE_ATOMIC_CS: - wc->opcode = IBV_WC_COMP_SWAP; - wc->byte_len = 8; - break; - case MLX5_OPCODE_ATOMIC_FA: - wc->opcode = IBV_WC_FETCH_ADD; - wc->byte_len = 8; - break; - case MLX5_OPCODE_UMR: - wc->opcode = wq->wr_data[idx]; - break; - case MLX5_OPCODE_TSO: - wc->opcode = IBV_WC_TSO; - break; - } -} - -static inline int handle_responder_lazy(struct mlx5_cq *cq, struct mlx5_cqe64 *cqe, - struct mlx5_resource *cur_rsc, struct mlx5_srq *srq) -{ - uint16_t wqe_ctr; - struct mlx5_wq *wq; - struct mlx5_qp *qp = rsc_to_mqp(cur_rsc); - int err = IBV_WC_SUCCESS; - - if (srq) { - wqe_ctr = be16toh(cqe->wqe_counter); - cq->ibv_cq.wr_id = srq->wrid[wqe_ctr]; - mlx5_free_srq_wqe(srq, wqe_ctr); - if (cqe->op_own & MLX5_INLINE_SCATTER_32) - err = mlx5_copy_to_recv_srq(srq, wqe_ctr, cqe, - be32toh(cqe->byte_cnt)); - else if (cqe->op_own & MLX5_INLINE_SCATTER_64) - err = mlx5_copy_to_recv_srq(srq, wqe_ctr, cqe - 1, - be32toh(cqe->byte_cnt)); - } else { - if (likely(cur_rsc->type == MLX5_RSC_TYPE_QP)) { - wq = &qp->rq; - if (qp->qp_cap_cache & MLX5_RX_CSUM_VALID) - cq->flags |= MLX5_CQ_FLAGS_RX_CSUM_VALID; - } else { - wq = &(rsc_to_mrwq(cur_rsc)->rq); - } - - wqe_ctr = wq->tail & (wq->wqe_cnt - 1); - cq->ibv_cq.wr_id = wq->wrid[wqe_ctr]; - ++wq->tail; - if (cqe->op_own & MLX5_INLINE_SCATTER_32) - err = mlx5_copy_to_recv_wqe(qp, wqe_ctr, cqe, - be32toh(cqe->byte_cnt)); - else if (cqe->op_own & MLX5_INLINE_SCATTER_64) - err = mlx5_copy_to_recv_wqe(qp, wqe_ctr, cqe - 1, - be32toh(cqe->byte_cnt)); - } - - return err; -} - -/* Returns IBV_WC_IP_CSUM_OK or 0 */ -static inline int get_csum_ok(struct mlx5_cqe64 *cqe) -{ - return (((cqe->hds_ip_ext & (MLX5_CQE_L4_OK | MLX5_CQE_L3_OK)) == - (MLX5_CQE_L4_OK | MLX5_CQE_L3_OK)) & - (get_cqe_l3_hdr_type(cqe) == MLX5_CQE_L3_HDR_TYPE_IPV4)) - << IBV_WC_IP_CSUM_OK_SHIFT; -} - -static inline int handle_responder(struct ibv_wc *wc, struct mlx5_cqe64 *cqe, - struct mlx5_resource *cur_rsc, struct mlx5_srq *srq) -{ - uint16_t wqe_ctr; - struct mlx5_wq *wq; - struct mlx5_qp *qp = rsc_to_mqp(cur_rsc); - uint8_t g; - int err = 0; - - wc->byte_len = be32toh(cqe->byte_cnt); - if (srq) { - wqe_ctr = be16toh(cqe->wqe_counter); - wc->wr_id = srq->wrid[wqe_ctr]; - mlx5_free_srq_wqe(srq, wqe_ctr); - if (cqe->op_own & MLX5_INLINE_SCATTER_32) - err = mlx5_copy_to_recv_srq(srq, wqe_ctr, cqe, - wc->byte_len); - else if (cqe->op_own & MLX5_INLINE_SCATTER_64) - err = mlx5_copy_to_recv_srq(srq, wqe_ctr, cqe - 1, - wc->byte_len); - } else { - if (likely(cur_rsc->type == MLX5_RSC_TYPE_QP)) { - wq = &qp->rq; - if (qp->qp_cap_cache & MLX5_RX_CSUM_VALID) - wc->wc_flags |= get_csum_ok(cqe); - } else { - wq = &(rsc_to_mrwq(cur_rsc)->rq); - } - - wqe_ctr = wq->tail & (wq->wqe_cnt - 1); - wc->wr_id = wq->wrid[wqe_ctr]; - ++wq->tail; - if (cqe->op_own & MLX5_INLINE_SCATTER_32) - err = mlx5_copy_to_recv_wqe(qp, wqe_ctr, cqe, - wc->byte_len); - else if (cqe->op_own & MLX5_INLINE_SCATTER_64) - err = mlx5_copy_to_recv_wqe(qp, wqe_ctr, cqe - 1, - wc->byte_len); - } - if (err) - return err; - - switch (cqe->op_own >> 4) { - case MLX5_CQE_RESP_WR_IMM: - wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM; - wc->wc_flags |= IBV_WC_WITH_IMM; - wc->imm_data = cqe->imm_inval_pkey; - break; - case MLX5_CQE_RESP_SEND: - wc->opcode = IBV_WC_RECV; - break; - case MLX5_CQE_RESP_SEND_IMM: - wc->opcode = IBV_WC_RECV; - wc->wc_flags |= IBV_WC_WITH_IMM; - wc->imm_data = cqe->imm_inval_pkey; - break; - case MLX5_CQE_RESP_SEND_INV: - wc->opcode = IBV_WC_RECV; - wc->wc_flags |= IBV_WC_WITH_INV; - wc->invalidated_rkey = be32toh(cqe->imm_inval_pkey); - break; - } - wc->slid = be16toh(cqe->slid); - wc->sl = (be32toh(cqe->flags_rqpn) >> 24) & 0xf; - wc->src_qp = be32toh(cqe->flags_rqpn) & 0xffffff; - wc->dlid_path_bits = cqe->ml_path & 0x7f; - g = (be32toh(cqe->flags_rqpn) >> 28) & 3; - wc->wc_flags |= g ? IBV_WC_GRH : 0; - wc->pkey_index = be32toh(cqe->imm_inval_pkey) & 0xffff; - - return IBV_WC_SUCCESS; -} - -static void dump_cqe(FILE *fp, void *buf) -{ - __be32 *p = buf; - int i; - - for (i = 0; i < 16; i += 4) - fprintf(fp, "%08x %08x %08x %08x\n", be32toh(p[i]), be32toh(p[i + 1]), - be32toh(p[i + 2]), be32toh(p[i + 3])); -} - -static enum ibv_wc_status mlx5_handle_error_cqe(struct mlx5_err_cqe *cqe) -{ - switch (cqe->syndrome) { - case MLX5_CQE_SYNDROME_LOCAL_LENGTH_ERR: - return IBV_WC_LOC_LEN_ERR; - case MLX5_CQE_SYNDROME_LOCAL_QP_OP_ERR: - return IBV_WC_LOC_QP_OP_ERR; - case MLX5_CQE_SYNDROME_LOCAL_PROT_ERR: - return IBV_WC_LOC_PROT_ERR; - case MLX5_CQE_SYNDROME_WR_FLUSH_ERR: - return IBV_WC_WR_FLUSH_ERR; - case MLX5_CQE_SYNDROME_MW_BIND_ERR: - return IBV_WC_MW_BIND_ERR; - case MLX5_CQE_SYNDROME_BAD_RESP_ERR: - return IBV_WC_BAD_RESP_ERR; - case MLX5_CQE_SYNDROME_LOCAL_ACCESS_ERR: - return IBV_WC_LOC_ACCESS_ERR; - case MLX5_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR: - return IBV_WC_REM_INV_REQ_ERR; - case MLX5_CQE_SYNDROME_REMOTE_ACCESS_ERR: - return IBV_WC_REM_ACCESS_ERR; - case MLX5_CQE_SYNDROME_REMOTE_OP_ERR: - return IBV_WC_REM_OP_ERR; - case MLX5_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR: - return IBV_WC_RETRY_EXC_ERR; - case MLX5_CQE_SYNDROME_RNR_RETRY_EXC_ERR: - return IBV_WC_RNR_RETRY_EXC_ERR; - case MLX5_CQE_SYNDROME_REMOTE_ABORTED_ERR: - return IBV_WC_REM_ABORT_ERR; - default: - return IBV_WC_GENERAL_ERR; - } -} - -#if defined(__x86_64__) || defined (__i386__) -static inline unsigned long get_cycles(void) -{ - uint32_t low, high; - uint64_t val; - asm volatile ("rdtsc" : "=a" (low), "=d" (high)); - val = high; - val = (val << 32) | low; - return val; -} - -static void mlx5_stall_poll_cq(void) -{ - int i; - - for (i = 0; i < mlx5_stall_num_loop; i++) - (void)get_cycles(); -} -static void mlx5_stall_cycles_poll_cq(uint64_t cycles) -{ - while (get_cycles() < cycles) - ; /* Nothing */ -} -static void mlx5_get_cycles(uint64_t *cycles) -{ - *cycles = get_cycles(); -} -#else -static void mlx5_stall_poll_cq(void) -{ -} -static void mlx5_stall_cycles_poll_cq(uint64_t cycles) -{ -} -static void mlx5_get_cycles(uint64_t *cycles) -{ -} -#endif - -static inline struct mlx5_qp *get_req_context(struct mlx5_context *mctx, - struct mlx5_resource **cur_rsc, - uint32_t rsn, int cqe_ver) - ALWAYS_INLINE; -static inline struct mlx5_qp *get_req_context(struct mlx5_context *mctx, - struct mlx5_resource **cur_rsc, - uint32_t rsn, int cqe_ver) -{ - if (!*cur_rsc || (rsn != (*cur_rsc)->rsn)) - *cur_rsc = cqe_ver ? mlx5_find_uidx(mctx, rsn) : - (struct mlx5_resource *)mlx5_find_qp(mctx, rsn); - - return rsc_to_mqp(*cur_rsc); -} - -static inline int get_resp_ctx_v1(struct mlx5_context *mctx, - struct mlx5_resource **cur_rsc, - struct mlx5_srq **cur_srq, - uint32_t uidx, uint8_t *is_srq) - ALWAYS_INLINE; -static inline int get_resp_ctx_v1(struct mlx5_context *mctx, - struct mlx5_resource **cur_rsc, - struct mlx5_srq **cur_srq, - uint32_t uidx, uint8_t *is_srq) -{ - struct mlx5_qp *mqp; - - if (!*cur_rsc || (uidx != (*cur_rsc)->rsn)) { - *cur_rsc = mlx5_find_uidx(mctx, uidx); - if (unlikely(!*cur_rsc)) - return CQ_POLL_ERR; - } - - switch ((*cur_rsc)->type) { - case MLX5_RSC_TYPE_QP: - mqp = rsc_to_mqp(*cur_rsc); - if (mqp->verbs_qp.qp.srq) { - *cur_srq = to_msrq(mqp->verbs_qp.qp.srq); - *is_srq = 1; - } - break; - case MLX5_RSC_TYPE_XSRQ: - *cur_srq = rsc_to_msrq(*cur_rsc); - *is_srq = 1; - break; - case MLX5_RSC_TYPE_RWQ: - break; - default: - return CQ_POLL_ERR; - } - - return CQ_OK; -} - -static inline int get_qp_ctx(struct mlx5_context *mctx, - struct mlx5_resource **cur_rsc, - uint32_t qpn) - ALWAYS_INLINE; -static inline int get_qp_ctx(struct mlx5_context *mctx, - struct mlx5_resource **cur_rsc, - uint32_t qpn) -{ - if (!*cur_rsc || (qpn != (*cur_rsc)->rsn)) { - /* - * We do not have to take the QP table lock here, - * because CQs will be locked while QPs are removed - * from the table. - */ - *cur_rsc = (struct mlx5_resource *)mlx5_find_qp(mctx, qpn); - if (unlikely(!*cur_rsc)) - return CQ_POLL_ERR; - } - - return CQ_OK; -} - -static inline int get_srq_ctx(struct mlx5_context *mctx, - struct mlx5_srq **cur_srq, - uint32_t srqn_uidx) - ALWAYS_INLINE; -static inline int get_srq_ctx(struct mlx5_context *mctx, - struct mlx5_srq **cur_srq, - uint32_t srqn) -{ - if (!*cur_srq || (srqn != (*cur_srq)->srqn)) { - *cur_srq = mlx5_find_srq(mctx, srqn); - if (unlikely(!*cur_srq)) - return CQ_POLL_ERR; - } - - return CQ_OK; -} - -static inline int get_cur_rsc(struct mlx5_context *mctx, - int cqe_ver, - uint32_t qpn, - uint32_t srqn_uidx, - struct mlx5_resource **cur_rsc, - struct mlx5_srq **cur_srq, - uint8_t *is_srq) -{ - int err; - - if (cqe_ver) { - err = get_resp_ctx_v1(mctx, cur_rsc, cur_srq, srqn_uidx, - is_srq); - } else { - if (srqn_uidx) { - *is_srq = 1; - err = get_srq_ctx(mctx, cur_srq, srqn_uidx); - } else { - err = get_qp_ctx(mctx, cur_rsc, qpn); - } - } - - return err; - -} - -static inline int mlx5_get_next_cqe(struct mlx5_cq *cq, - struct mlx5_cqe64 **pcqe64, - void **pcqe) - ALWAYS_INLINE; -static inline int mlx5_get_next_cqe(struct mlx5_cq *cq, - struct mlx5_cqe64 **pcqe64, - void **pcqe) -{ - void *cqe; - struct mlx5_cqe64 *cqe64; - - cqe = next_cqe_sw(cq); - if (!cqe) - return CQ_EMPTY; - - cqe64 = (cq->cqe_sz == 64) ? cqe : cqe + 64; - - ++cq->cons_index; - - VALGRIND_MAKE_MEM_DEFINED(cqe64, sizeof *cqe64); - - /* - * Make sure we read CQ entry contents after we've checked the - * ownership bit. - */ - udma_from_device_barrier(); - -#ifdef MLX5_DEBUG - { - struct mlx5_context *mctx = to_mctx(cq->ibv_cq.context); - - if (mlx5_debug_mask & MLX5_DBG_CQ_CQE) { - FILE *fp = mctx->dbg_fp; - - mlx5_dbg(fp, MLX5_DBG_CQ_CQE, "dump cqe for cqn 0x%x:\n", cq->cqn); - dump_cqe(fp, cqe64); - } - } -#endif - *pcqe64 = cqe64; - *pcqe = cqe; - - return CQ_OK; -} - -static inline int mlx5_parse_cqe(struct mlx5_cq *cq, - struct mlx5_cqe64 *cqe64, - void *cqe, - struct mlx5_resource **cur_rsc, - struct mlx5_srq **cur_srq, - struct ibv_wc *wc, - int cqe_ver, int lazy) - ALWAYS_INLINE; -static inline int mlx5_parse_cqe(struct mlx5_cq *cq, - struct mlx5_cqe64 *cqe64, - void *cqe, - struct mlx5_resource **cur_rsc, - struct mlx5_srq **cur_srq, - struct ibv_wc *wc, - int cqe_ver, int lazy) -{ - struct mlx5_wq *wq; - uint16_t wqe_ctr; - uint32_t qpn; - uint32_t srqn_uidx; - int idx; - uint8_t opcode; - struct mlx5_err_cqe *ecqe; - int err = 0; - struct mlx5_qp *mqp; - struct mlx5_context *mctx; - uint8_t is_srq = 0; - - mctx = to_mctx(ibv_cq_ex_to_cq(&cq->ibv_cq)->context); - qpn = be32toh(cqe64->sop_drop_qpn) & 0xffffff; - if (lazy) { - cq->cqe64 = cqe64; - cq->flags &= (~MLX5_CQ_FLAGS_RX_CSUM_VALID); - } else { - wc->wc_flags = 0; - wc->qp_num = qpn; - } - - opcode = mlx5dv_get_cqe_opcode(cqe64); - switch (opcode) { - case MLX5_CQE_REQ: - { - mqp = get_req_context(mctx, cur_rsc, - (cqe_ver ? (be32toh(cqe64->srqn_uidx) & 0xffffff) : qpn), - cqe_ver); - if (unlikely(!mqp)) - return CQ_POLL_ERR; - wq = &mqp->sq; - wqe_ctr = be16toh(cqe64->wqe_counter); - idx = wqe_ctr & (wq->wqe_cnt - 1); - if (lazy) { - uint32_t wc_byte_len; - - switch (be32toh(cqe64->sop_drop_qpn) >> 24) { - case MLX5_OPCODE_UMR: - cq->umr_opcode = wq->wr_data[idx]; - break; - - case MLX5_OPCODE_RDMA_READ: - wc_byte_len = be32toh(cqe64->byte_cnt); - goto scatter_out; - case MLX5_OPCODE_ATOMIC_CS: - case MLX5_OPCODE_ATOMIC_FA: - wc_byte_len = 8; - - scatter_out: - if (cqe64->op_own & MLX5_INLINE_SCATTER_32) - err = mlx5_copy_to_send_wqe( - mqp, wqe_ctr, cqe, wc_byte_len); - else if (cqe64->op_own & MLX5_INLINE_SCATTER_64) - err = mlx5_copy_to_send_wqe( - mqp, wqe_ctr, cqe - 1, wc_byte_len); - break; - } - - cq->ibv_cq.wr_id = wq->wrid[idx]; - cq->ibv_cq.status = err; - } else { - handle_good_req(wc, cqe64, wq, idx); - - if (cqe64->op_own & MLX5_INLINE_SCATTER_32) - err = mlx5_copy_to_send_wqe(mqp, wqe_ctr, cqe, - wc->byte_len); - else if (cqe64->op_own & MLX5_INLINE_SCATTER_64) - err = mlx5_copy_to_send_wqe( - mqp, wqe_ctr, cqe - 1, wc->byte_len); - - wc->wr_id = wq->wrid[idx]; - wc->status = err; - } - - wq->tail = wq->wqe_head[idx] + 1; - break; - } - case MLX5_CQE_RESP_WR_IMM: - case MLX5_CQE_RESP_SEND: - case MLX5_CQE_RESP_SEND_IMM: - case MLX5_CQE_RESP_SEND_INV: - srqn_uidx = be32toh(cqe64->srqn_uidx) & 0xffffff; - err = get_cur_rsc(mctx, cqe_ver, qpn, srqn_uidx, cur_rsc, - cur_srq, &is_srq); - if (unlikely(err)) - return CQ_POLL_ERR; - - if (lazy) - cq->ibv_cq.status = handle_responder_lazy(cq, cqe64, - *cur_rsc, - is_srq ? *cur_srq : NULL); - else - wc->status = handle_responder(wc, cqe64, *cur_rsc, - is_srq ? *cur_srq : NULL); - break; - case MLX5_CQE_RESIZE_CQ: - break; - case MLX5_CQE_REQ_ERR: - case MLX5_CQE_RESP_ERR: - srqn_uidx = be32toh(cqe64->srqn_uidx) & 0xffffff; - ecqe = (struct mlx5_err_cqe *)cqe64; - { - enum ibv_wc_status *pstatus = lazy ? &cq->ibv_cq.status : &wc->status; - - *pstatus = mlx5_handle_error_cqe(ecqe); - } - - if (!lazy) - wc->vendor_err = ecqe->vendor_err_synd; - - if (unlikely(ecqe->syndrome != MLX5_CQE_SYNDROME_WR_FLUSH_ERR && - ecqe->syndrome != MLX5_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR)) { - FILE *fp = mctx->dbg_fp; - fprintf(fp, PFX "%s: got completion with error:\n", - mctx->hostname); - dump_cqe(fp, ecqe); - if (mlx5_freeze_on_error_cqe) { - fprintf(fp, PFX "freezing at poll cq..."); - while (1) - sleep(10); - } - } - - if (opcode == MLX5_CQE_REQ_ERR) { - mqp = get_req_context(mctx, cur_rsc, - (cqe_ver ? srqn_uidx : qpn), cqe_ver); - if (unlikely(!mqp)) - return CQ_POLL_ERR; - wq = &mqp->sq; - wqe_ctr = be16toh(cqe64->wqe_counter); - idx = wqe_ctr & (wq->wqe_cnt - 1); - if (lazy) - cq->ibv_cq.wr_id = wq->wrid[idx]; - else - wc->wr_id = wq->wrid[idx]; - wq->tail = wq->wqe_head[idx] + 1; - } else { - err = get_cur_rsc(mctx, cqe_ver, qpn, srqn_uidx, - cur_rsc, cur_srq, &is_srq); - if (unlikely(err)) - return CQ_POLL_ERR; - - if (is_srq) { - wqe_ctr = be16toh(cqe64->wqe_counter); - if (lazy) - cq->ibv_cq.wr_id = (*cur_srq)->wrid[wqe_ctr]; - else - wc->wr_id = (*cur_srq)->wrid[wqe_ctr]; - mlx5_free_srq_wqe(*cur_srq, wqe_ctr); - } else { - switch ((*cur_rsc)->type) { - case MLX5_RSC_TYPE_RWQ: - wq = &(rsc_to_mrwq(*cur_rsc)->rq); - break; - default: - wq = &(rsc_to_mqp(*cur_rsc)->rq); - break; - } - - if (lazy) - cq->ibv_cq.wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; - else - wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; - ++wq->tail; - } - } - break; - } - - return CQ_OK; -} - -static inline int mlx5_parse_lazy_cqe(struct mlx5_cq *cq, - struct mlx5_cqe64 *cqe64, - void *cqe, int cqe_ver) - ALWAYS_INLINE; -static inline int mlx5_parse_lazy_cqe(struct mlx5_cq *cq, - struct mlx5_cqe64 *cqe64, - void *cqe, int cqe_ver) -{ - return mlx5_parse_cqe(cq, cqe64, cqe, &cq->cur_rsc, &cq->cur_srq, NULL, cqe_ver, 1); -} - -static inline int mlx5_poll_one(struct mlx5_cq *cq, - struct mlx5_resource **cur_rsc, - struct mlx5_srq **cur_srq, - struct ibv_wc *wc, int cqe_ver) - ALWAYS_INLINE; -static inline int mlx5_poll_one(struct mlx5_cq *cq, - struct mlx5_resource **cur_rsc, - struct mlx5_srq **cur_srq, - struct ibv_wc *wc, int cqe_ver) -{ - struct mlx5_cqe64 *cqe64; - void *cqe; - int err; - - err = mlx5_get_next_cqe(cq, &cqe64, &cqe); - if (err == CQ_EMPTY) - return err; - - return mlx5_parse_cqe(cq, cqe64, cqe, cur_rsc, cur_srq, wc, cqe_ver, 0); -} - -static inline int poll_cq(struct ibv_cq *ibcq, int ne, - struct ibv_wc *wc, int cqe_ver) - ALWAYS_INLINE; -static inline int poll_cq(struct ibv_cq *ibcq, int ne, - struct ibv_wc *wc, int cqe_ver) -{ - struct mlx5_cq *cq = to_mcq(ibcq); - struct mlx5_resource *rsc = NULL; - struct mlx5_srq *srq = NULL; - int npolled; - int err = CQ_OK; - - if (cq->stall_enable) { - if (cq->stall_adaptive_enable) { - if (cq->stall_last_count) - mlx5_stall_cycles_poll_cq(cq->stall_last_count + cq->stall_cycles); - } else if (cq->stall_next_poll) { - cq->stall_next_poll = 0; - mlx5_stall_poll_cq(); - } - } - - mlx5_spin_lock(&cq->lock); - - for (npolled = 0; npolled < ne; ++npolled) { - err = mlx5_poll_one(cq, &rsc, &srq, wc + npolled, cqe_ver); - if (err != CQ_OK) - break; - } - - update_cons_index(cq); - - mlx5_spin_unlock(&cq->lock); - - if (cq->stall_enable) { - if (cq->stall_adaptive_enable) { - if (npolled == 0) { - cq->stall_cycles = max(cq->stall_cycles-mlx5_stall_cq_dec_step, - mlx5_stall_cq_poll_min); - mlx5_get_cycles(&cq->stall_last_count); - } else if (npolled < ne) { - cq->stall_cycles = min(cq->stall_cycles+mlx5_stall_cq_inc_step, - mlx5_stall_cq_poll_max); - mlx5_get_cycles(&cq->stall_last_count); - } else { - cq->stall_cycles = max(cq->stall_cycles-mlx5_stall_cq_dec_step, - mlx5_stall_cq_poll_min); - cq->stall_last_count = 0; - } - } else if (err == CQ_EMPTY) { - cq->stall_next_poll = 1; - } - } - - return err == CQ_POLL_ERR ? err : npolled; -} - -enum polling_mode { - POLLING_MODE_NO_STALL, - POLLING_MODE_STALL, - POLLING_MODE_STALL_ADAPTIVE -}; - -static inline void _mlx5_end_poll(struct ibv_cq_ex *ibcq, - int lock, enum polling_mode stall) - ALWAYS_INLINE; -static inline void _mlx5_end_poll(struct ibv_cq_ex *ibcq, - int lock, enum polling_mode stall) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - update_cons_index(cq); - - if (lock) - mlx5_spin_unlock(&cq->lock); - - if (stall) { - if (stall == POLLING_MODE_STALL_ADAPTIVE) { - if (!(cq->flags & MLX5_CQ_FLAGS_FOUND_CQES)) { - cq->stall_cycles = max(cq->stall_cycles - mlx5_stall_cq_dec_step, - mlx5_stall_cq_poll_min); - mlx5_get_cycles(&cq->stall_last_count); - } else if (cq->flags & MLX5_CQ_FLAGS_EMPTY_DURING_POLL) { - cq->stall_cycles = min(cq->stall_cycles + mlx5_stall_cq_inc_step, - mlx5_stall_cq_poll_max); - mlx5_get_cycles(&cq->stall_last_count); - } else { - cq->stall_cycles = max(cq->stall_cycles - mlx5_stall_cq_dec_step, - mlx5_stall_cq_poll_min); - cq->stall_last_count = 0; - } - } else if (!(cq->flags & MLX5_CQ_FLAGS_FOUND_CQES)) { - cq->stall_next_poll = 1; - } - - cq->flags &= ~(MLX5_CQ_FLAGS_FOUND_CQES | MLX5_CQ_FLAGS_EMPTY_DURING_POLL); - } -} - -static inline int mlx5_start_poll(struct ibv_cq_ex *ibcq, struct ibv_poll_cq_attr *attr, - int lock, enum polling_mode stall, int cqe_version) - ALWAYS_INLINE; -static inline int mlx5_start_poll(struct ibv_cq_ex *ibcq, struct ibv_poll_cq_attr *attr, - int lock, enum polling_mode stall, int cqe_version) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - struct mlx5_cqe64 *cqe64; - void *cqe; - int err; - - if (unlikely(attr->comp_mask)) - return EINVAL; - - if (stall) { - if (stall == POLLING_MODE_STALL_ADAPTIVE) { - if (cq->stall_last_count) - mlx5_stall_cycles_poll_cq(cq->stall_last_count + cq->stall_cycles); - } else if (cq->stall_next_poll) { - cq->stall_next_poll = 0; - mlx5_stall_poll_cq(); - } - } - - if (lock) - mlx5_spin_lock(&cq->lock); - - cq->cur_rsc = NULL; - cq->cur_srq = NULL; - - err = mlx5_get_next_cqe(cq, &cqe64, &cqe); - if (err == CQ_EMPTY) { - if (lock) - mlx5_spin_unlock(&cq->lock); - - if (stall) { - if (stall == POLLING_MODE_STALL_ADAPTIVE) { - cq->stall_cycles = max(cq->stall_cycles - mlx5_stall_cq_dec_step, - mlx5_stall_cq_poll_min); - mlx5_get_cycles(&cq->stall_last_count); - } else { - cq->stall_next_poll = 1; - } - } - - return ENOENT; - } - - if (stall) - cq->flags |= MLX5_CQ_FLAGS_FOUND_CQES; - - err = mlx5_parse_lazy_cqe(cq, cqe64, cqe, cqe_version); - if (lock && err) - mlx5_spin_unlock(&cq->lock); - - if (stall && err) { - if (stall == POLLING_MODE_STALL_ADAPTIVE) { - cq->stall_cycles = max(cq->stall_cycles - mlx5_stall_cq_dec_step, - mlx5_stall_cq_poll_min); - cq->stall_last_count = 0; - } - - cq->flags &= ~(MLX5_CQ_FLAGS_FOUND_CQES); - } - - return err; -} - -static inline int mlx5_next_poll(struct ibv_cq_ex *ibcq, - enum polling_mode stall, int cqe_version) - ALWAYS_INLINE; -static inline int mlx5_next_poll(struct ibv_cq_ex *ibcq, - enum polling_mode stall, - int cqe_version) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - struct mlx5_cqe64 *cqe64; - void *cqe; - int err; - - err = mlx5_get_next_cqe(cq, &cqe64, &cqe); - if (err == CQ_EMPTY) { - if (stall == POLLING_MODE_STALL_ADAPTIVE) - cq->flags |= MLX5_CQ_FLAGS_EMPTY_DURING_POLL; - - return ENOENT; - } - - return mlx5_parse_lazy_cqe(cq, cqe64, cqe, cqe_version); -} - -static inline int mlx5_next_poll_adaptive_v0(struct ibv_cq_ex *ibcq) -{ - return mlx5_next_poll(ibcq, POLLING_MODE_STALL_ADAPTIVE, 0); -} - -static inline int mlx5_next_poll_adaptive_v1(struct ibv_cq_ex *ibcq) -{ - return mlx5_next_poll(ibcq, POLLING_MODE_STALL_ADAPTIVE, 1); -} - -static inline int mlx5_next_poll_v0(struct ibv_cq_ex *ibcq) -{ - return mlx5_next_poll(ibcq, 0, 0); -} - -static inline int mlx5_next_poll_v1(struct ibv_cq_ex *ibcq) -{ - return mlx5_next_poll(ibcq, 0, 1); -} - -static inline int mlx5_start_poll_v0(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 0, 0, 0); -} - -static inline int mlx5_start_poll_v1(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 0, 0, 1); -} - -static inline int mlx5_start_poll_v0_lock(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 1, 0, 0); -} - -static inline int mlx5_start_poll_v1_lock(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 1, 0, 1); -} - -static inline int mlx5_start_poll_adaptive_stall_v0_lock(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 1, POLLING_MODE_STALL_ADAPTIVE, 0); -} - -static inline int mlx5_start_poll_stall_v0_lock(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 1, POLLING_MODE_STALL, 0); -} - -static inline int mlx5_start_poll_adaptive_stall_v1_lock(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 1, POLLING_MODE_STALL_ADAPTIVE, 1); -} - -static inline int mlx5_start_poll_stall_v1_lock(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 1, POLLING_MODE_STALL, 1); -} - -static inline int mlx5_start_poll_stall_v0(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 0, POLLING_MODE_STALL, 0); -} - -static inline int mlx5_start_poll_adaptive_stall_v0(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 0, POLLING_MODE_STALL_ADAPTIVE, 0); -} - -static inline int mlx5_start_poll_adaptive_stall_v1(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 0, POLLING_MODE_STALL_ADAPTIVE, 1); -} - -static inline int mlx5_start_poll_stall_v1(struct ibv_cq_ex *ibcq, - struct ibv_poll_cq_attr *attr) -{ - return mlx5_start_poll(ibcq, attr, 0, POLLING_MODE_STALL, 1); -} - -static inline void mlx5_end_poll_adaptive_stall_lock(struct ibv_cq_ex *ibcq) -{ - _mlx5_end_poll(ibcq, 1, POLLING_MODE_STALL_ADAPTIVE); -} - -static inline void mlx5_end_poll_stall_lock(struct ibv_cq_ex *ibcq) -{ - _mlx5_end_poll(ibcq, 1, POLLING_MODE_STALL); -} - -static inline void mlx5_end_poll_adaptive_stall(struct ibv_cq_ex *ibcq) -{ - _mlx5_end_poll(ibcq, 0, POLLING_MODE_STALL_ADAPTIVE); -} - -static inline void mlx5_end_poll_stall(struct ibv_cq_ex *ibcq) -{ - _mlx5_end_poll(ibcq, 0, POLLING_MODE_STALL); -} - -static inline void mlx5_end_poll(struct ibv_cq_ex *ibcq) -{ - _mlx5_end_poll(ibcq, 0, 0); -} - -static inline void mlx5_end_poll_lock(struct ibv_cq_ex *ibcq) -{ - _mlx5_end_poll(ibcq, 1, 0); -} - -int mlx5_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) -{ - return poll_cq(ibcq, ne, wc, 0); -} - -int mlx5_poll_cq_v1(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) -{ - return poll_cq(ibcq, ne, wc, 1); -} - -static inline enum ibv_wc_opcode mlx5_cq_read_wc_opcode(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - switch (mlx5dv_get_cqe_opcode(cq->cqe64)) { - case MLX5_CQE_RESP_WR_IMM: - return IBV_WC_RECV_RDMA_WITH_IMM; - case MLX5_CQE_RESP_SEND: - case MLX5_CQE_RESP_SEND_IMM: - case MLX5_CQE_RESP_SEND_INV: - return IBV_WC_RECV; - case MLX5_CQE_REQ: - switch (be32toh(cq->cqe64->sop_drop_qpn) >> 24) { - case MLX5_OPCODE_RDMA_WRITE_IMM: - case MLX5_OPCODE_RDMA_WRITE: - return IBV_WC_RDMA_WRITE; - case MLX5_OPCODE_SEND_IMM: - case MLX5_OPCODE_SEND: - case MLX5_OPCODE_SEND_INVAL: - return IBV_WC_SEND; - case MLX5_OPCODE_RDMA_READ: - return IBV_WC_RDMA_READ; - case MLX5_OPCODE_ATOMIC_CS: - return IBV_WC_COMP_SWAP; - case MLX5_OPCODE_ATOMIC_FA: - return IBV_WC_FETCH_ADD; - case MLX5_OPCODE_UMR: - return cq->umr_opcode; - case MLX5_OPCODE_TSO: - return IBV_WC_TSO; - } - } - -#ifdef MLX5_DEBUG -{ - struct mlx5_context *ctx = to_mctx(ibcq->context); - - mlx5_dbg(ctx->dbg_fp, MLX5_DBG_CQ_CQE, "un-expected opcode in cqe\n"); -} -#endif - return 0; -} - -static inline uint32_t mlx5_cq_read_wc_qp_num(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be32toh(cq->cqe64->sop_drop_qpn) & 0xffffff; -} - -static inline int mlx5_cq_read_wc_flags(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - int wc_flags = 0; - - if (cq->flags & MLX5_CQ_FLAGS_RX_CSUM_VALID) - wc_flags = get_csum_ok(cq->cqe64); - - switch (mlx5dv_get_cqe_opcode(cq->cqe64)) { - case MLX5_CQE_RESP_WR_IMM: - case MLX5_CQE_RESP_SEND_IMM: - wc_flags |= IBV_WC_WITH_IMM; - break; - case MLX5_CQE_RESP_SEND_INV: - wc_flags |= IBV_WC_WITH_INV; - break; - } - - wc_flags |= ((be32toh(cq->cqe64->flags_rqpn) >> 28) & 3) ? IBV_WC_GRH : 0; - return wc_flags; -} - -static inline uint32_t mlx5_cq_read_wc_byte_len(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be32toh(cq->cqe64->byte_cnt); -} - -static inline uint32_t mlx5_cq_read_wc_vendor_err(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - struct mlx5_err_cqe *ecqe = (struct mlx5_err_cqe *)cq->cqe64; - - return ecqe->vendor_err_synd; -} - -static inline __be32 mlx5_cq_read_wc_imm_data(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - switch (mlx5dv_get_cqe_opcode(cq->cqe64)) { - case MLX5_CQE_RESP_SEND_INV: - /* This is returning invalidate_rkey which is in host order, see - * ibv_wc_read_invalidated_rkey - */ - return (__force __be32)be32toh(cq->cqe64->imm_inval_pkey); - default: - return cq->cqe64->imm_inval_pkey; - } -} - -static inline uint32_t mlx5_cq_read_wc_slid(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return (uint32_t)be16toh(cq->cqe64->slid); -} - -static inline uint8_t mlx5_cq_read_wc_sl(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return (be32toh(cq->cqe64->flags_rqpn) >> 24) & 0xf; -} - -static inline uint32_t mlx5_cq_read_wc_src_qp(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be32toh(cq->cqe64->flags_rqpn) & 0xffffff; -} - -static inline uint8_t mlx5_cq_read_wc_dlid_path_bits(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return cq->cqe64->ml_path & 0x7f; -} - -static inline uint64_t mlx5_cq_read_wc_completion_ts(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be64toh(cq->cqe64->timestamp); -} - -static inline uint16_t mlx5_cq_read_wc_cvlan(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be16toh(cq->cqe64->vlan_info); -} - -static inline uint32_t mlx5_cq_read_flow_tag(struct ibv_cq_ex *ibcq) -{ - struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq)); - - return be32toh(cq->cqe64->sop_drop_qpn) & MLX5_FLOW_TAG_MASK; -} - -#define BIT(i) (1UL << (i)) - -#define SINGLE_THREADED BIT(0) -#define STALL BIT(1) -#define V1 BIT(2) -#define ADAPTIVE BIT(3) - -#define mlx5_start_poll_name(cqe_ver, lock, stall, adaptive) \ - mlx5_start_poll##adaptive##stall##cqe_ver##lock -#define mlx5_next_poll_name(cqe_ver, adaptive) \ - mlx5_next_poll##adaptive##cqe_ver -#define mlx5_end_poll_name(lock, stall, adaptive) \ - mlx5_end_poll##adaptive##stall##lock - -#define POLL_FN_ENTRY(cqe_ver, lock, stall, adaptive) { \ - .start_poll = &mlx5_start_poll_name(cqe_ver, lock, stall, adaptive), \ - .next_poll = &mlx5_next_poll_name(cqe_ver, adaptive), \ - .end_poll = &mlx5_end_poll_name(lock, stall, adaptive), \ - } - -static const struct op -{ - int (*start_poll)(struct ibv_cq_ex *ibcq, struct ibv_poll_cq_attr *attr); - int (*next_poll)(struct ibv_cq_ex *ibcq); - void (*end_poll)(struct ibv_cq_ex *ibcq); -} ops[ADAPTIVE + V1 + STALL + SINGLE_THREADED + 1] = { - [V1] = POLL_FN_ENTRY(_v1, _lock, , ), - [0] = POLL_FN_ENTRY(_v0, _lock, , ), - [V1 | SINGLE_THREADED] = POLL_FN_ENTRY(_v1, , , ), - [SINGLE_THREADED] = POLL_FN_ENTRY(_v0, , , ), - [V1 | STALL] = POLL_FN_ENTRY(_v1, _lock, _stall, ), - [STALL] = POLL_FN_ENTRY(_v0, _lock, _stall, ), - [V1 | SINGLE_THREADED | STALL] = POLL_FN_ENTRY(_v1, , _stall, ), - [SINGLE_THREADED | STALL] = POLL_FN_ENTRY(_v0, , _stall, ), - [V1 | STALL | ADAPTIVE] = POLL_FN_ENTRY(_v1, _lock, _stall, _adaptive), - [STALL | ADAPTIVE] = POLL_FN_ENTRY(_v0, _lock, _stall, _adaptive), - [V1 | SINGLE_THREADED | STALL | ADAPTIVE] = POLL_FN_ENTRY(_v1, , _stall, _adaptive), - [SINGLE_THREADED | STALL | ADAPTIVE] = POLL_FN_ENTRY(_v0, , _stall, _adaptive), -}; - -void mlx5_cq_fill_pfns(struct mlx5_cq *cq, const struct ibv_cq_init_attr_ex *cq_attr) -{ - struct mlx5_context *mctx = to_mctx(ibv_cq_ex_to_cq(&cq->ibv_cq)->context); - const struct op *poll_ops = &ops[((cq->stall_enable && cq->stall_adaptive_enable) ? ADAPTIVE : 0) | - (mctx->cqe_version ? V1 : 0) | - (cq->flags & MLX5_CQ_FLAGS_SINGLE_THREADED ? - SINGLE_THREADED : 0) | - (cq->stall_enable ? STALL : 0)]; - - cq->ibv_cq.start_poll = poll_ops->start_poll; - cq->ibv_cq.next_poll = poll_ops->next_poll; - cq->ibv_cq.end_poll = poll_ops->end_poll; - - cq->ibv_cq.read_opcode = mlx5_cq_read_wc_opcode; - cq->ibv_cq.read_vendor_err = mlx5_cq_read_wc_vendor_err; - cq->ibv_cq.read_wc_flags = mlx5_cq_read_wc_flags; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_BYTE_LEN) - cq->ibv_cq.read_byte_len = mlx5_cq_read_wc_byte_len; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_IMM) - cq->ibv_cq.read_imm_data = mlx5_cq_read_wc_imm_data; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_QP_NUM) - cq->ibv_cq.read_qp_num = mlx5_cq_read_wc_qp_num; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_SRC_QP) - cq->ibv_cq.read_src_qp = mlx5_cq_read_wc_src_qp; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_SLID) - cq->ibv_cq.read_slid = mlx5_cq_read_wc_slid; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_SL) - cq->ibv_cq.read_sl = mlx5_cq_read_wc_sl; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_DLID_PATH_BITS) - cq->ibv_cq.read_dlid_path_bits = mlx5_cq_read_wc_dlid_path_bits; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP) - cq->ibv_cq.read_completion_ts = mlx5_cq_read_wc_completion_ts; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_CVLAN) - cq->ibv_cq.read_cvlan = mlx5_cq_read_wc_cvlan; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_FLOW_TAG) - cq->ibv_cq.read_flow_tag = mlx5_cq_read_flow_tag; -} - -int mlx5_arm_cq(struct ibv_cq *ibvcq, int solicited) -{ - struct mlx5_cq *cq = to_mcq(ibvcq); - struct mlx5_context *ctx = to_mctx(ibvcq->context); - uint64_t doorbell; - uint32_t sn; - uint32_t ci; - uint32_t cmd; - - sn = cq->arm_sn & 3; - ci = cq->cons_index & 0xffffff; - cmd = solicited ? MLX5_CQ_DB_REQ_NOT_SOL : MLX5_CQ_DB_REQ_NOT; - - doorbell = sn << 28 | cmd | ci; - doorbell <<= 32; - doorbell |= cq->cqn; - - cq->dbrec[MLX5_CQ_ARM_DB] = htobe32(sn << 28 | cmd | ci); - - /* - * Make sure that the doorbell record in host memory is - * written before ringing the doorbell via PCI WC MMIO. - */ - mmio_wc_start(); - - mmio_write64_be(ctx->uar[0] + MLX5_CQ_DOORBELL, htobe64(doorbell)); - - mmio_flush_writes(); - - return 0; -} - -void mlx5_cq_event(struct ibv_cq *cq) -{ - to_mcq(cq)->arm_sn++; -} - -static int is_equal_rsn(struct mlx5_cqe64 *cqe64, uint32_t rsn) -{ - return rsn == (be32toh(cqe64->sop_drop_qpn) & 0xffffff); -} - -static inline int is_equal_uidx(struct mlx5_cqe64 *cqe64, uint32_t uidx) -{ - return uidx == (be32toh(cqe64->srqn_uidx) & 0xffffff); -} - -static inline int is_responder(uint8_t opcode) -{ - switch (opcode) { - case MLX5_CQE_RESP_WR_IMM: - case MLX5_CQE_RESP_SEND: - case MLX5_CQE_RESP_SEND_IMM: - case MLX5_CQE_RESP_SEND_INV: - case MLX5_CQE_RESP_ERR: - return 1; - } - - return 0; -} - -static inline int free_res_cqe(struct mlx5_cqe64 *cqe64, uint32_t rsn, - struct mlx5_srq *srq, int cqe_version) -{ - if (cqe_version) { - if (is_equal_uidx(cqe64, rsn)) { - if (srq && is_responder(mlx5dv_get_cqe_opcode(cqe64))) - mlx5_free_srq_wqe(srq, - be16toh(cqe64->wqe_counter)); - return 1; - } - } else { - if (is_equal_rsn(cqe64, rsn)) { - if (srq && (be32toh(cqe64->srqn_uidx) & 0xffffff)) - mlx5_free_srq_wqe(srq, - be16toh(cqe64->wqe_counter)); - return 1; - } - } - - return 0; -} - -void __mlx5_cq_clean(struct mlx5_cq *cq, uint32_t rsn, struct mlx5_srq *srq) -{ - uint32_t prod_index; - int nfreed = 0; - struct mlx5_cqe64 *cqe64, *dest64; - void *cqe, *dest; - uint8_t owner_bit; - int cqe_version; - - if (!cq || cq->flags & MLX5_CQ_FLAGS_DV_OWNED) - return; - - /* - * First we need to find the current producer index, so we - * know where to start cleaning from. It doesn't matter if HW - * adds new entries after this loop -- the QP we're worried - * about is already in RESET, so the new entries won't come - * from our QP and therefore don't need to be checked. - */ - for (prod_index = cq->cons_index; get_sw_cqe(cq, prod_index); ++prod_index) - if (prod_index == cq->cons_index + cq->ibv_cq.cqe) - break; - - /* - * Now sweep backwards through the CQ, removing CQ entries - * that match our QP by copying older entries on top of them. - */ - cqe_version = (to_mctx(cq->ibv_cq.context))->cqe_version; - while ((int) --prod_index - (int) cq->cons_index >= 0) { - cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe); - cqe64 = (cq->cqe_sz == 64) ? cqe : cqe + 64; - if (free_res_cqe(cqe64, rsn, srq, cqe_version)) { - ++nfreed; - } else if (nfreed) { - dest = get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe); - dest64 = (cq->cqe_sz == 64) ? dest : dest + 64; - owner_bit = dest64->op_own & MLX5_CQE_OWNER_MASK; - memcpy(dest, cqe, cq->cqe_sz); - dest64->op_own = owner_bit | - (dest64->op_own & ~MLX5_CQE_OWNER_MASK); - } - } - - if (nfreed) { - cq->cons_index += nfreed; - /* - * Make sure update of buffer contents is done before - * updating consumer index. - */ - udma_to_device_barrier(); - update_cons_index(cq); - } -} - -void mlx5_cq_clean(struct mlx5_cq *cq, uint32_t qpn, struct mlx5_srq *srq) -{ - mlx5_spin_lock(&cq->lock); - __mlx5_cq_clean(cq, qpn, srq); - mlx5_spin_unlock(&cq->lock); -} - -static uint8_t sw_ownership_bit(int n, int nent) -{ - return (n & nent) ? 1 : 0; -} - -static int is_hw(uint8_t own, int n, int mask) -{ - return (own & MLX5_CQE_OWNER_MASK) ^ !!(n & (mask + 1)); -} - -void mlx5_cq_resize_copy_cqes(struct mlx5_cq *cq) -{ - struct mlx5_cqe64 *scqe64; - struct mlx5_cqe64 *dcqe64; - void *start_cqe; - void *scqe; - void *dcqe; - int ssize; - int dsize; - int i; - uint8_t sw_own; - - ssize = cq->cqe_sz; - dsize = cq->resize_cqe_sz; - - i = cq->cons_index; - scqe = get_buf_cqe(cq->active_buf, i & cq->active_cqes, ssize); - scqe64 = ssize == 64 ? scqe : scqe + 64; - start_cqe = scqe; - if (is_hw(scqe64->op_own, i, cq->active_cqes)) { - fprintf(stderr, "expected cqe in sw ownership\n"); - return; - } - - while ((scqe64->op_own >> 4) != MLX5_CQE_RESIZE_CQ) { - dcqe = get_buf_cqe(cq->resize_buf, (i + 1) & (cq->resize_cqes - 1), dsize); - dcqe64 = dsize == 64 ? dcqe : dcqe + 64; - sw_own = sw_ownership_bit(i + 1, cq->resize_cqes); - memcpy(dcqe, scqe, ssize); - dcqe64->op_own = (dcqe64->op_own & ~MLX5_CQE_OWNER_MASK) | sw_own; - - ++i; - scqe = get_buf_cqe(cq->active_buf, i & cq->active_cqes, ssize); - scqe64 = ssize == 64 ? scqe : scqe + 64; - if (is_hw(scqe64->op_own, i, cq->active_cqes)) { - fprintf(stderr, "expected cqe in sw ownership\n"); - return; - } - - if (scqe == start_cqe) { - fprintf(stderr, "resize CQ failed to get resize CQE\n"); - return; - } - } - ++cq->cons_index; -} - -int mlx5_alloc_cq_buf(struct mlx5_context *mctx, struct mlx5_cq *cq, - struct mlx5_buf *buf, int nent, int cqe_sz) -{ - struct mlx5_cqe64 *cqe; - int i; - struct mlx5_device *dev = to_mdev(mctx->ibv_ctx.device); - int ret; - enum mlx5_alloc_type type; - enum mlx5_alloc_type default_type = MLX5_ALLOC_TYPE_ANON; - - if (mlx5_use_huge("HUGE_CQ")) - default_type = MLX5_ALLOC_TYPE_HUGE; - - mlx5_get_alloc_type(mctx, MLX5_CQ_PREFIX, &type, default_type); - - ret = mlx5_alloc_prefered_buf(mctx, buf, - align(nent * cqe_sz, dev->page_size), - dev->page_size, - type, - MLX5_CQ_PREFIX); - - if (ret) - return -1; - - memset(buf->buf, 0, nent * cqe_sz); - - for (i = 0; i < nent; ++i) { - cqe = buf->buf + i * cqe_sz; - cqe += cqe_sz == 128 ? 1 : 0; - cqe->op_own = MLX5_CQE_INVALID << 4; - } - - return 0; -} - -int mlx5_free_cq_buf(struct mlx5_context *ctx, struct mlx5_buf *buf) -{ - return mlx5_free_actual_buf(ctx, buf); -} diff --git a/usr/rdma-core/providers/mlx5/dbrec.c b/usr/rdma-core/providers/mlx5/dbrec.c deleted file mode 100644 index 17aee0ba2..000000000 --- a/usr/rdma-core/providers/mlx5/dbrec.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include - -#include "mlx5.h" - -struct mlx5_db_page { - struct mlx5_db_page *prev, *next; - struct mlx5_buf buf; - int num_db; - int use_cnt; - unsigned long free[0]; -}; - -static struct mlx5_db_page *__add_page(struct mlx5_context *context) -{ - struct mlx5_db_page *page; - int ps = to_mdev(context->ibv_ctx.device)->page_size; - int pp; - int i; - int nlong; - int ret; - - pp = ps / context->cache_line_size; - nlong = (pp + 8 * sizeof(long) - 1) / (8 * sizeof(long)); - - page = malloc(sizeof *page + nlong * sizeof(long)); - if (!page) - return NULL; - - if (mlx5_is_extern_alloc(context)) - ret = mlx5_alloc_buf_extern(context, &page->buf, ps); - else - ret = mlx5_alloc_buf(&page->buf, ps, ps); - if (ret) { - free(page); - return NULL; - } - - page->num_db = pp; - page->use_cnt = 0; - for (i = 0; i < nlong; ++i) - page->free[i] = ~0; - - page->prev = NULL; - page->next = context->db_list; - context->db_list = page; - if (page->next) - page->next->prev = page; - - return page; -} - -__be32 *mlx5_alloc_dbrec(struct mlx5_context *context) -{ - struct mlx5_db_page *page; - __be32 *db = NULL; - int i, j; - - pthread_mutex_lock(&context->db_list_mutex); - - for (page = context->db_list; page; page = page->next) - if (page->use_cnt < page->num_db) - goto found; - - page = __add_page(context); - if (!page) - goto out; - -found: - ++page->use_cnt; - - for (i = 0; !page->free[i]; ++i) - /* nothing */; - - j = ffsl(page->free[i]); - --j; - page->free[i] &= ~(1UL << j); - db = page->buf.buf + (i * 8 * sizeof(long) + j) * context->cache_line_size; - -out: - pthread_mutex_unlock(&context->db_list_mutex); - - return db; -} - -void mlx5_free_db(struct mlx5_context *context, __be32 *db) -{ - struct mlx5_db_page *page; - uintptr_t ps = to_mdev(context->ibv_ctx.device)->page_size; - int i; - - pthread_mutex_lock(&context->db_list_mutex); - - for (page = context->db_list; page; page = page->next) - if (((uintptr_t) db & ~(ps - 1)) == (uintptr_t) page->buf.buf) - break; - - if (!page) - goto out; - - i = ((void *) db - page->buf.buf) / context->cache_line_size; - page->free[i / (8 * sizeof(long))] |= 1UL << (i % (8 * sizeof(long))); - - if (!--page->use_cnt) { - if (page->prev) - page->prev->next = page->next; - else - context->db_list = page->next; - if (page->next) - page->next->prev = page->prev; - - if (page->buf.type == MLX5_ALLOC_TYPE_EXTERNAL) - mlx5_free_buf_extern(context, &page->buf); - else - mlx5_free_buf(&page->buf); - - free(page); - } - -out: - pthread_mutex_unlock(&context->db_list_mutex); -} diff --git a/usr/rdma-core/providers/mlx5/libmlx5.map b/usr/rdma-core/providers/mlx5/libmlx5.map deleted file mode 100644 index 09d886d14..000000000 --- a/usr/rdma-core/providers/mlx5/libmlx5.map +++ /dev/null @@ -1,19 +0,0 @@ -/* Export symbols should be added below according to - Documentation/versioning.md document. */ -MLX5_1.0 { - global: - mlx5dv_query_device; - mlx5dv_init_obj; - local: *; -}; - -MLX5_1.1 { - global: - mlx5dv_create_cq; -} MLX5_1.0; - -MLX5_1.2 { - global: - mlx5dv_init_obj; - mlx5dv_set_context_attr; -} MLX5_1.1; diff --git a/usr/rdma-core/providers/mlx5/man/CMakeLists.txt b/usr/rdma-core/providers/mlx5/man/CMakeLists.txt deleted file mode 100644 index bb1610bb8..000000000 --- a/usr/rdma-core/providers/mlx5/man/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -rdma_man_pages( - mlx5dv_init_obj.3 - mlx5dv_query_device.3 - mlx5dv.7 -) diff --git a/usr/rdma-core/providers/mlx5/man/mlx5dv.7 b/usr/rdma-core/providers/mlx5/man/mlx5dv.7 deleted file mode 100644 index c02c9670f..000000000 --- a/usr/rdma-core/providers/mlx5/man/mlx5dv.7 +++ /dev/null @@ -1,44 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org (MIT) - See COPYING.md -.\" -.TH MLX5DV 7 2017-02-02 1.0.0 -.SH "NAME" -mlx5dv \- Direct verbs for mlx5 devices -.br -This is low level access to mlx5 devices to perform data path operations, -without general branching performed by \fBibv_post_send\fR(3). - -.SH "DESCRIPTION" -The libibverbs API is an abstract one. It is agnostic to any underlying -provider specific implementation. While this abstraction has the advantage -of user applications portability it has a performance penalty. For some -applications optimizing performance is more important than portability. - -The mlx5 direct verbs API is intended for such applications. -It exposes mlx5 specific low level data path (send/receive/completion) -operations, allowing the application to bypass the libibverbs data path API. - -This interface consists from one hardware specific header file -with relevant inline functions and conversion logic from ibverbs structures -to mlx5 specific structures. - -The direct include of mlx5dv.h together with linkage to mlx5 library will -allow usage of this new interface. - -Once an application uses the direct flow the locking scheme is fully managed -by itself. There is an expectation that no mixed flows in the data path for both -direct/non-direct access will be by same application. - -.SH "NOTES" -All Mellanox NIC devices starting from Connect-IB (Connect-IB, -ConnectX-4, ConnectX-4Lx, ConnectX-5, ...) implement the mlx5 API, -thus using the mlx5 direct verbs does not limit the applications -to a single NIC HW device thus keeping some level of portability. - -.SH "SEE ALSO" -.BR ibv_post_send (3), -.BR verbs (7) - -.SH "AUTHORS" -.TP -Leon Romanovsky diff --git a/usr/rdma-core/providers/mlx5/man/mlx5dv_init_obj.3 b/usr/rdma-core/providers/mlx5/man/mlx5dv_init_obj.3 deleted file mode 100644 index 60d224aaf..000000000 --- a/usr/rdma-core/providers/mlx5/man/mlx5dv_init_obj.3 +++ /dev/null @@ -1,130 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org (MIT) - See COPYING.md -.\" -.TH MLX5DV_INIT_OBJ 3 2017-02-02 1.0.0 -.SH "NAME" -mlx5dv_init_obj \- Initialize mlx5 direct verbs object from ibv_xxx structures -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int mlx5dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type); -.fi -.SH "DESCRIPTION" -.B mlx5dv_init_obj() -This function will initialize mlx5dv_xxx structs based on supplied type. The information -for initialization is taken from ibv_xx structs supplied as part of input. - -Request information of CQ marks its owned by direct verbs for all consumer index -related actions. The initialization type can be combination of several types together. -.PP -.nf -struct mlx5dv_qp { -.in +8 -uint32_t *dbrec; -struct { -.in +8 -void *buf; -uint32_t wqe_cnt; -uint32_t stride; -.in -8 -} sq; -struct { -.in +8 -void *buf; -uint32_t wqe_cnt; -uint32_t stride; -.in -8 -} rq; -struct { -.in +8 -void *reg; -uint32_t size; -.in -8 -} bf; -uint64_t comp_mask; -.in -8 -}; - -struct mlx5dv_cq { -.in +8 -void *buf; -uint32_t *dbrec; -uint32_t cqe_cnt; -uint32_t cqe_size; -void *cq_uar; -uint32_t cqn; -uint64_t comp_mask; -.in -8 -}; - -struct mlx5dv_srq { -.in +8 -void *buf; -uint32_t *dbrec; -uint32_t stride; -uint32_t head; -uint32_t tail; -uint64_t comp_mask; -.in -8 -}; - -struct mlx5dv_rwq { -.in +8 -void *buf; -uint32_t *dbrec; -uint32_t wqe_cnt; -uint32_t stride; -uint64_t comp_mask; -.in -8 -}; - -struct mlx5dv_obj { -.in +8 -struct { -.in +8 -struct ibv_qp *in; -struct mlx5dv_qp *out; -.in -8 -} qp; -struct { -.in +8 -struct ibv_cq *in; -struct mlx5dv_cq *out; -.in -8 -} cq; -struct { -.in +8 -struct ibv_srq *in; -struct mlx5dv_srq *out; -.in -8 -} srq; -struct { -.in +8 -struct ibv_wq *in; -struct mlx5dv_rwq *out; -.in -8 -} rwq; -.in -8 -}; - -enum mlx5dv_obj_type { -.in +8 -MLX5DV_OBJ_QP = 1 << 0, -MLX5DV_OBJ_CQ = 1 << 1, -MLX5DV_OBJ_SRQ = 1 << 2, -MLX5DV_OBJ_RWQ = 1 << 3, -.in -8 -}; -.fi -.SH "RETURN VALUE" -0 on success or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" - * The information if doorbell is blueflame is based on mlx5dv_qp->bf->size, -in case of 0 it's not a BF. - * Compatibility masks (comp_mask) are in/out fields. -.SH "SEE ALSO" -.BR mlx5dv (7) -.SH "AUTHORS" -.TP -Leon Romanovsky diff --git a/usr/rdma-core/providers/mlx5/man/mlx5dv_query_device.3 b/usr/rdma-core/providers/mlx5/man/mlx5dv_query_device.3 deleted file mode 100644 index c2fe9a3ea..000000000 --- a/usr/rdma-core/providers/mlx5/man/mlx5dv_query_device.3 +++ /dev/null @@ -1,53 +0,0 @@ -.\" -*- nroff -*- -.\" Licensed under the OpenIB.org (MIT) - See COPYING.md -.\" -.TH MLX5DV_QUERY_DEVICE 3 2017-02-02 1.0.0 -.SH "NAME" -mlx5dv_query_device \- Query device capabilities specific to mlx5 -.SH "SYNOPSIS" -.nf -.B #include -.sp -.BI "int mlx5dv_query_device(struct ibv_context *ctx_in, -.BI " struct mlx5dv_context *attrs_out); -.fi -.SH "DESCRIPTION" -.B mlx5dv_query_device() -Query HW device-specific information which is important for data-path, but isn't provided by -\fBibv_query_device\fR(3). -.PP -This function returns version, flags and compatibility mask. The version represents the format -of the internal hardware structures that mlx5dv.h represents. Additions of new fields to the existed -structures are handled by comp_mask field. -.PP -.nf -struct mlx5dv_context { -.in +8 -uint8_t version; -uint64_t flags; -uint64_t comp_mask; -.in -8 -}; - -enum mlx5dv_context_flags { -.in +8 -/* - * This flag indicates if CQE version 0 or 1 is needed. - */ - MLX5DV_CONTEXT_FLAGS_CQE_V1 = (1 << 0), - MLX5DV_CONTEXT_FLAGS_OBSOLETE = (1 << 1), /* Obsoleted, don't use */ - MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED = (1 << 2), /* Multi packet WQE is allowed */ - MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW = (1 << 3), /* Enhanced multi packet WQE is supported or not */ -.in -8 -}; -.fi -.SH "RETURN VALUE" -0 on success or the value of errno on failure (which indicates the failure reason). -.SH "NOTES" - * Compatibility mask (comp_mask) is in/out field. -.SH "SEE ALSO" -.BR mlx5dv (7), -.BR ibv_query_device (3) -.SH "AUTHORS" -.TP -Leon Romanovsky diff --git a/usr/rdma-core/providers/mlx5/mlx5-abi.h b/usr/rdma-core/providers/mlx5/mlx5-abi.h deleted file mode 100644 index bce9e5593..000000000 --- a/usr/rdma-core/providers/mlx5/mlx5-abi.h +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef MLX5_ABI_H -#define MLX5_ABI_H - -#include -#include -#include "mlx5dv.h" - -#define MLX5_UVERBS_MIN_ABI_VERSION 1 -#define MLX5_UVERBS_MAX_ABI_VERSION 1 - -enum { - MLX5_QP_FLAG_SIGNATURE = 1 << 0, - MLX5_QP_FLAG_SCATTER_CQE = 1 << 1, -}; - -enum { - MLX5_RWQ_FLAG_SIGNATURE = 1 << 0, -}; - -enum { - MLX5_NUM_NON_FP_BFREGS_PER_UAR = 2, - NUM_BFREGS_PER_UAR = 4, - MLX5_MAX_UARS = 1 << 8, - MLX5_MAX_BFREGS = MLX5_MAX_UARS * MLX5_NUM_NON_FP_BFREGS_PER_UAR, - MLX5_DEF_TOT_UUARS = 8 * MLX5_NUM_NON_FP_BFREGS_PER_UAR, - MLX5_MED_BFREGS_TSHOLD = 12, -}; - -enum mlx5_lib_caps { - MLX5_LIB_CAP_4K_UAR = 1 << 0, -}; - -struct mlx5_alloc_ucontext { - struct ibv_get_context ibv_req; - __u32 total_num_uuars; - __u32 num_low_latency_uuars; - __u32 flags; - __u32 comp_mask; - __u8 cqe_version; - __u8 reserved0; - __u16 reserved1; - __u32 reserved2; - __u64 lib_caps; -}; - -enum mlx5_ib_alloc_ucontext_resp_mask { - MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET = 1UL << 0, -}; - -struct mlx5_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - __u32 qp_tab_size; - __u32 bf_reg_size; - __u32 tot_uuars; - __u32 cache_line_size; - __u16 max_sq_desc_sz; - __u16 max_rq_desc_sz; - __u32 max_send_wqebb; - __u32 max_recv_wr; - __u32 max_srq_recv_wr; - __u16 num_ports; - __u16 reserved1; - __u32 comp_mask; - __u32 response_length; - __u8 cqe_version; - __u8 cmds_supp_uhw; - __u16 reserved2; - __u64 hca_core_clock_offset; - __u32 log_uar_size; - __u32 num_uars_per_page; -}; - -struct mlx5_create_ah_resp { - struct ibv_create_ah_resp ibv_resp; - __u32 response_length; - __u8 dmac[ETHERNET_LL_SIZE]; - __u8 reserved[6]; -}; - -struct mlx5_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - __u32 pdn; -}; - -struct mlx5_create_cq { - struct ibv_create_cq ibv_cmd; - __u64 buf_addr; - __u64 db_addr; - __u32 cqe_size; - __u8 cqe_comp_en; - __u8 cqe_comp_res_format; - __u16 reserved; -}; - -struct mlx5_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u32 cqn; -}; - -struct mlx5_create_srq { - struct ibv_create_srq ibv_cmd; - __u64 buf_addr; - __u64 db_addr; - __u32 flags; -}; - -struct mlx5_create_srq_resp { - struct ibv_create_srq_resp ibv_resp; - __u32 srqn; - __u32 reserved; -}; - -struct mlx5_create_srq_ex { - struct ibv_create_xsrq ibv_cmd; - __u64 buf_addr; - __u64 db_addr; - __u32 flags; - __u32 reserved; - __u32 uidx; - __u32 reserved1; -}; - -struct mlx5_create_qp_drv_ex { - __u64 buf_addr; - __u64 db_addr; - __u32 sq_wqe_count; - __u32 rq_wqe_count; - __u32 rq_wqe_shift; - __u32 flags; - __u32 uidx; - __u32 reserved; - /* SQ buffer address - used for Raw Packet QP */ - __u64 sq_buf_addr; -}; - -struct mlx5_create_qp_ex { - struct ibv_create_qp_ex ibv_cmd; - struct mlx5_create_qp_drv_ex drv_ex; -}; - -struct mlx5_create_qp_ex_rss { - struct ibv_create_qp_ex ibv_cmd; - __u64 rx_hash_fields_mask; /* enum ibv_rx_hash_fields */ - __u8 rx_hash_function; /* enum ibv_rx_hash_function_flags */ - __u8 rx_key_len; - __u8 reserved[6]; - __u8 rx_hash_key[128]; - __u32 comp_mask; - __u32 reserved1; -}; - -struct mlx5_create_qp_resp_ex { - struct ibv_create_qp_resp_ex ibv_resp; - __u32 uuar_index; - __u32 reserved; -}; - -struct mlx5_create_qp { - struct ibv_create_qp ibv_cmd; - __u64 buf_addr; - __u64 db_addr; - __u32 sq_wqe_count; - __u32 rq_wqe_count; - __u32 rq_wqe_shift; - __u32 flags; - __u32 uidx; - __u32 reserved; - /* SQ buffer address - used for Raw Packet QP */ - __u64 sq_buf_addr; -}; - -struct mlx5_create_qp_resp { - struct ibv_create_qp_resp ibv_resp; - __u32 uuar_index; -}; - -struct mlx5_drv_create_wq { - __u64 buf_addr; - __u64 db_addr; - __u32 rq_wqe_count; - __u32 rq_wqe_shift; - __u32 user_index; - __u32 flags; - __u32 comp_mask; - __u32 reserved; -}; - -struct mlx5_create_wq { - struct ibv_create_wq ibv_cmd; - struct mlx5_drv_create_wq drv; -}; - -struct mlx5_create_wq_resp { - struct ibv_create_wq_resp ibv_resp; - __u32 response_length; - __u32 reserved; -}; - -struct mlx5_modify_wq { - struct ibv_modify_wq ibv_cmd; - __u32 comp_mask; - __u32 reserved; -}; - -struct mlx5_create_rwq_ind_table_resp { - struct ibv_create_rwq_ind_table_resp ibv_resp; -}; - -struct mlx5_destroy_rwq_ind_table { - struct ibv_destroy_rwq_ind_table ibv_cmd; -}; - -struct mlx5_resize_cq { - struct ibv_resize_cq ibv_cmd; - __u64 buf_addr; - __u16 cqe_size; - __u16 reserved0; - __u32 reserved1; -}; - -struct mlx5_resize_cq_resp { - struct ibv_resize_cq_resp ibv_resp; -}; - -struct mlx5_query_device_ex { - struct ibv_query_device_ex ibv_cmd; -}; - -struct mlx5_reserved_tso_caps { - __u64 reserved; -}; - -struct mlx5_rss_caps { - __u64 rx_hash_fields_mask; /* enum ibv_rx_hash_fields */ - __u8 rx_hash_function; /* enum ibv_rx_hash_function_flags */ - __u8 reserved[7]; -}; - -struct mlx5_packet_pacing_caps { - struct ibv_packet_pacing_caps caps; - __u32 reserved; -}; - -enum mlx5_mpw_caps { - MLX5_MPW_OBSOLETE = 1 << 0, /* Obsoleted, don't use */ - MLX5_ALLOW_MPW = 1 << 1, - MLX5_SUPPORT_EMPW = 1 << 2, -}; - -struct mlx5_query_device_ex_resp { - struct ibv_query_device_resp_ex ibv_resp; - __u32 comp_mask; - __u32 response_length; - struct ibv_tso_caps tso_caps; - struct mlx5_rss_caps rss_caps; /* vendor data channel */ - struct mlx5dv_cqe_comp_caps cqe_comp_caps; - struct mlx5_packet_pacing_caps packet_pacing_caps; - __u32 support_multi_pkt_send_wqe; - __u32 reserved; -}; - -#endif /* MLX5_ABI_H */ diff --git a/usr/rdma-core/providers/mlx5/mlx5.c b/usr/rdma-core/providers/mlx5/mlx5.c deleted file mode 100644 index 15f258dfc..000000000 --- a/usr/rdma-core/providers/mlx5/mlx5.c +++ /dev/null @@ -1,1051 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "mlx5.h" -#include "mlx5-abi.h" - -#ifndef PCI_VENDOR_ID_MELLANOX -#define PCI_VENDOR_ID_MELLANOX 0x15b3 -#endif - -#ifndef CPU_OR -#define CPU_OR(x, y, z) do {} while (0) -#endif - -#ifndef CPU_EQUAL -#define CPU_EQUAL(x, y) 1 -#endif - -#define HCA(v, d) VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, d, NULL) -static const struct verbs_match_ent hca_table[] = { - HCA(MELLANOX, 0x1011), /* MT4113 Connect-IB */ - HCA(MELLANOX, 0x1012), /* Connect-IB Virtual Function */ - HCA(MELLANOX, 0x1013), /* ConnectX-4 */ - HCA(MELLANOX, 0x1014), /* ConnectX-4 Virtual Function */ - HCA(MELLANOX, 0x1015), /* ConnectX-4LX */ - HCA(MELLANOX, 0x1016), /* ConnectX-4LX Virtual Function */ - HCA(MELLANOX, 0x1017), /* ConnectX-5, PCIe 3.0 */ - HCA(MELLANOX, 0x1018), /* ConnectX-5 Virtual Function */ - HCA(MELLANOX, 0x1019), /* ConnectX-5 Ex */ - HCA(MELLANOX, 0x101a), /* ConnectX-5 Ex VF */ - HCA(MELLANOX, 0x101b), /* ConnectX-6 */ - HCA(MELLANOX, 0x101c), /* ConnectX-6 VF */ - HCA(MELLANOX, 0xa2d2), /* BlueField integrated ConnectX-5 network controller */ - HCA(MELLANOX, 0xa2d3), /* BlueField integrated ConnectX-5 network controller VF */ - {} -}; - -uint32_t mlx5_debug_mask = 0; -int mlx5_freeze_on_error_cqe; - -static struct ibv_context_ops mlx5_ctx_ops = { - .query_device = mlx5_query_device, - .query_port = mlx5_query_port, - .alloc_pd = mlx5_alloc_pd, - .dealloc_pd = mlx5_free_pd, - .reg_mr = mlx5_reg_mr, - .rereg_mr = mlx5_rereg_mr, - .dereg_mr = mlx5_dereg_mr, - .alloc_mw = mlx5_alloc_mw, - .dealloc_mw = mlx5_dealloc_mw, - .bind_mw = mlx5_bind_mw, - .create_cq = mlx5_create_cq, - .poll_cq = mlx5_poll_cq, - .req_notify_cq = mlx5_arm_cq, - .cq_event = mlx5_cq_event, - .resize_cq = mlx5_resize_cq, - .destroy_cq = mlx5_destroy_cq, - .create_srq = mlx5_create_srq, - .modify_srq = mlx5_modify_srq, - .query_srq = mlx5_query_srq, - .destroy_srq = mlx5_destroy_srq, - .post_srq_recv = mlx5_post_srq_recv, - .create_qp = mlx5_create_qp, - .query_qp = mlx5_query_qp, - .modify_qp = mlx5_modify_qp, - .destroy_qp = mlx5_destroy_qp, - .post_send = mlx5_post_send, - .post_recv = mlx5_post_recv, - .create_ah = mlx5_create_ah, - .destroy_ah = mlx5_destroy_ah, - .attach_mcast = mlx5_attach_mcast, - .detach_mcast = mlx5_detach_mcast -}; - -static int read_number_from_line(const char *line, int *value) -{ - const char *ptr; - - ptr = strchr(line, ':'); - if (!ptr) - return 1; - - ++ptr; - - *value = atoi(ptr); - return 0; -} -/** - * The function looks for the first free user-index in all the - * user-index tables. If all are used, returns -1, otherwise - * a valid user-index. - * In case the reference count of the table is zero, it means the - * table is not in use and wasn't allocated yet, therefore the - * mlx5_store_uidx allocates the table, and increment the reference - * count on the table. - */ -static int32_t get_free_uidx(struct mlx5_context *ctx) -{ - int32_t tind; - int32_t i; - - for (tind = 0; tind < MLX5_UIDX_TABLE_SIZE; tind++) { - if (ctx->uidx_table[tind].refcnt < MLX5_UIDX_TABLE_MASK) - break; - } - - if (tind == MLX5_UIDX_TABLE_SIZE) - return -1; - - if (!ctx->uidx_table[tind].refcnt) - return tind << MLX5_UIDX_TABLE_SHIFT; - - for (i = 0; i < MLX5_UIDX_TABLE_MASK + 1; i++) { - if (!ctx->uidx_table[tind].table[i]) - break; - } - - return (tind << MLX5_UIDX_TABLE_SHIFT) | i; -} - -int32_t mlx5_store_uidx(struct mlx5_context *ctx, void *rsc) -{ - int32_t tind; - int32_t ret = -1; - int32_t uidx; - - pthread_mutex_lock(&ctx->uidx_table_mutex); - uidx = get_free_uidx(ctx); - if (uidx < 0) - goto out; - - tind = uidx >> MLX5_UIDX_TABLE_SHIFT; - - if (!ctx->uidx_table[tind].refcnt) { - ctx->uidx_table[tind].table = calloc(MLX5_UIDX_TABLE_MASK + 1, - sizeof(struct mlx5_resource *)); - if (!ctx->uidx_table[tind].table) - goto out; - } - - ++ctx->uidx_table[tind].refcnt; - ctx->uidx_table[tind].table[uidx & MLX5_UIDX_TABLE_MASK] = rsc; - ret = uidx; - -out: - pthread_mutex_unlock(&ctx->uidx_table_mutex); - return ret; -} - -void mlx5_clear_uidx(struct mlx5_context *ctx, uint32_t uidx) -{ - int tind = uidx >> MLX5_UIDX_TABLE_SHIFT; - - pthread_mutex_lock(&ctx->uidx_table_mutex); - - if (!--ctx->uidx_table[tind].refcnt) - free(ctx->uidx_table[tind].table); - else - ctx->uidx_table[tind].table[uidx & MLX5_UIDX_TABLE_MASK] = NULL; - - pthread_mutex_unlock(&ctx->uidx_table_mutex); -} - -static int mlx5_is_sandy_bridge(int *num_cores) -{ - char line[128]; - FILE *fd; - int rc = 0; - int cur_cpu_family = -1; - int cur_cpu_model = -1; - - fd = fopen("/proc/cpuinfo", "r"); - if (!fd) - return 0; - - *num_cores = 0; - - while (fgets(line, 128, fd)) { - int value; - - /* if this is information on new processor */ - if (!strncmp(line, "processor", 9)) { - ++*num_cores; - - cur_cpu_family = -1; - cur_cpu_model = -1; - } else if (!strncmp(line, "cpu family", 10)) { - if ((cur_cpu_family < 0) && (!read_number_from_line(line, &value))) - cur_cpu_family = value; - } else if (!strncmp(line, "model", 5)) { - if ((cur_cpu_model < 0) && (!read_number_from_line(line, &value))) - cur_cpu_model = value; - } - - /* if this is a Sandy Bridge CPU */ - if ((cur_cpu_family == 6) && - (cur_cpu_model == 0x2A || (cur_cpu_model == 0x2D) )) - rc = 1; - } - - fclose(fd); - return rc; -} - -/* -man cpuset - - This format displays each 32-bit word in hexadecimal (using ASCII characters "0" - "9" and "a" - "f"); words - are filled with leading zeros, if required. For masks longer than one word, a comma separator is used between - words. Words are displayed in big-endian order, which has the most significant bit first. The hex digits - within a word are also in big-endian order. - - The number of 32-bit words displayed is the minimum number needed to display all bits of the bitmask, based on - the size of the bitmask. - - Examples of the Mask Format: - - 00000001 # just bit 0 set - 40000000,00000000,00000000 # just bit 94 set - 000000ff,00000000 # bits 32-39 set - 00000000,000E3862 # 1,5,6,11-13,17-19 set - - A mask with bits 0, 1, 2, 4, 8, 16, 32, and 64 set displays as: - - 00000001,00000001,00010117 - - The first "1" is for bit 64, the second for bit 32, the third for bit 16, the fourth for bit 8, the fifth for - bit 4, and the "7" is for bits 2, 1, and 0. -*/ -static void mlx5_local_cpu_set(struct ibv_device *ibdev, cpu_set_t *cpu_set) -{ - char *p, buf[1024]; - char *env_value; - uint32_t word; - int i, k; - - env_value = getenv("MLX5_LOCAL_CPUS"); - if (env_value) - strncpy(buf, env_value, sizeof(buf)); - else { - char fname[MAXPATHLEN]; - FILE *fp; - - snprintf(fname, MAXPATHLEN, "/sys/class/infiniband/%s/device/local_cpus", - ibv_get_device_name(ibdev)); - - fp = fopen(fname, "r"); - if (!fp) { - fprintf(stderr, PFX "Warning: can not get local cpu set: failed to open %s\n", fname); - return; - } - if (!fgets(buf, sizeof(buf), fp)) { - fprintf(stderr, PFX "Warning: can not get local cpu set: failed to read cpu mask\n"); - fclose(fp); - return; - } - fclose(fp); - } - - p = strrchr(buf, ','); - if (!p) - p = buf; - - i = 0; - do { - if (*p == ',') { - *p = 0; - p ++; - } - - word = strtoul(p, NULL, 16); - - for (k = 0; word; ++k, word >>= 1) - if (word & 1) - CPU_SET(k+i, cpu_set); - - if (p == buf) - break; - - p = strrchr(buf, ','); - if (!p) - p = buf; - - i += 32; - } while (i < CPU_SETSIZE); -} - -static int mlx5_enable_sandy_bridge_fix(struct ibv_device *ibdev) -{ - cpu_set_t my_cpus, dev_local_cpus, result_set; - int stall_enable; - int ret; - int num_cores; - - if (!mlx5_is_sandy_bridge(&num_cores)) - return 0; - - /* by default enable stall on sandy bridge arch */ - stall_enable = 1; - - /* - * check if app is bound to cpu set that is inside - * of device local cpu set. Disable stalling if true - */ - - /* use static cpu set - up to CPU_SETSIZE (1024) cpus/node */ - CPU_ZERO(&my_cpus); - CPU_ZERO(&dev_local_cpus); - CPU_ZERO(&result_set); - ret = sched_getaffinity(0, sizeof(my_cpus), &my_cpus); - if (ret == -1) { - if (errno == EINVAL) - fprintf(stderr, PFX "Warning: my cpu set is too small\n"); - else - fprintf(stderr, PFX "Warning: failed to get my cpu set\n"); - goto out; - } - - /* get device local cpu set */ - mlx5_local_cpu_set(ibdev, &dev_local_cpus); - - /* check if my cpu set is in dev cpu */ - CPU_OR(&result_set, &my_cpus, &dev_local_cpus); - stall_enable = CPU_EQUAL(&result_set, &dev_local_cpus) ? 0 : 1; - -out: - return stall_enable; -} - -static void mlx5_read_env(struct ibv_device *ibdev, struct mlx5_context *ctx) -{ - char *env_value; - - env_value = getenv("MLX5_STALL_CQ_POLL"); - if (env_value) - /* check if cq stall is enforced by user */ - ctx->stall_enable = (strcmp(env_value, "0")) ? 1 : 0; - else - /* autodetect if we need to do cq polling */ - ctx->stall_enable = mlx5_enable_sandy_bridge_fix(ibdev); - - env_value = getenv("MLX5_STALL_NUM_LOOP"); - if (env_value) - mlx5_stall_num_loop = atoi(env_value); - - env_value = getenv("MLX5_STALL_CQ_POLL_MIN"); - if (env_value) - mlx5_stall_cq_poll_min = atoi(env_value); - - env_value = getenv("MLX5_STALL_CQ_POLL_MAX"); - if (env_value) - mlx5_stall_cq_poll_max = atoi(env_value); - - env_value = getenv("MLX5_STALL_CQ_INC_STEP"); - if (env_value) - mlx5_stall_cq_inc_step = atoi(env_value); - - env_value = getenv("MLX5_STALL_CQ_DEC_STEP"); - if (env_value) - mlx5_stall_cq_dec_step = atoi(env_value); - - ctx->stall_adaptive_enable = 0; - ctx->stall_cycles = 0; - - if (mlx5_stall_num_loop < 0) { - ctx->stall_adaptive_enable = 1; - ctx->stall_cycles = mlx5_stall_cq_poll_min; - } - -} - -static int get_total_uuars(int page_size) -{ - int size = MLX5_DEF_TOT_UUARS; - int uuars_in_page; - char *env; - - env = getenv("MLX5_TOTAL_UUARS"); - if (env) - size = atoi(env); - - if (size < 1) - return -EINVAL; - - uuars_in_page = page_size / MLX5_ADAPTER_PAGE_SIZE * MLX5_NUM_NON_FP_BFREGS_PER_UAR; - size = max(uuars_in_page, size); - size = align(size, MLX5_NUM_NON_FP_BFREGS_PER_UAR); - if (size > MLX5_MAX_BFREGS) - return -ENOMEM; - - return size; -} - -static void open_debug_file(struct mlx5_context *ctx) -{ - char *env; - - env = getenv("MLX5_DEBUG_FILE"); - if (!env) { - ctx->dbg_fp = stderr; - return; - } - - ctx->dbg_fp = fopen(env, "aw+"); - if (!ctx->dbg_fp) { - fprintf(stderr, "Failed opening debug file %s, using stderr\n", env); - ctx->dbg_fp = stderr; - return; - } -} - -static void close_debug_file(struct mlx5_context *ctx) -{ - if (ctx->dbg_fp && ctx->dbg_fp != stderr) - fclose(ctx->dbg_fp); -} - -static void set_debug_mask(void) -{ - char *env; - - env = getenv("MLX5_DEBUG_MASK"); - if (env) - mlx5_debug_mask = strtol(env, NULL, 0); -} - -static void set_freeze_on_error(void) -{ - char *env; - - env = getenv("MLX5_FREEZE_ON_ERROR_CQE"); - if (env) - mlx5_freeze_on_error_cqe = strtol(env, NULL, 0); -} - -static int get_always_bf(void) -{ - char *env; - - env = getenv("MLX5_POST_SEND_PREFER_BF"); - if (!env) - return 1; - - return strcmp(env, "0") ? 1 : 0; -} - -static int get_shut_up_bf(void) -{ - char *env; - - env = getenv("MLX5_SHUT_UP_BF"); - if (!env) - return 0; - - return strcmp(env, "0") ? 1 : 0; -} - -static int get_num_low_lat_uuars(int tot_uuars) -{ - char *env; - int num = 4; - - env = getenv("MLX5_NUM_LOW_LAT_UUARS"); - if (env) - num = atoi(env); - - if (num < 0) - return -EINVAL; - - num = max(num, tot_uuars - MLX5_MED_BFREGS_TSHOLD); - return num; -} - -/* The library allocates an array of uuar contexts. The one in index zero does - * not to execersize odd/even policy so it can avoid a lock but it may not use - * blue flame. The upper ones, low_lat_uuars can use blue flame with no lock - * since they are assigned to one QP only. The rest can use blue flame but since - * they are shared they need a lock - */ -static int need_uuar_lock(struct mlx5_context *ctx, int uuarn) -{ - if (uuarn == 0 || mlx5_single_threaded) - return 0; - - if (uuarn >= (ctx->tot_uuars - ctx->low_lat_uuars) * 2) - return 0; - - return 1; -} - -static int single_threaded_app(void) -{ - - char *env; - - env = getenv("MLX5_SINGLE_THREADED"); - if (env) - return strcmp(env, "1") ? 0 : 1; - - return 0; -} - -static int mlx5_cmd_get_context(struct mlx5_context *context, - struct mlx5_alloc_ucontext *req, - size_t req_len, - struct mlx5_alloc_ucontext_resp *resp, - size_t resp_len) -{ - if (!ibv_cmd_get_context(&context->ibv_ctx, &req->ibv_req, - req_len, &resp->ibv_resp, resp_len)) - return 0; - - /* The ibv_cmd_get_context fails in older kernels when passing - * a request length that the kernel doesn't know. - * To avoid breaking compatibility of new libmlx5 and older - * kernels, when ibv_cmd_get_context fails with the full - * request length, we try once again with the legacy length. - * We repeat this process while reducing requested size based - * on the feature input size. To avoid this in the future, we - * will remove the check in kernel that requires fields unknown - * to the kernel to be cleared. This will require that any new - * feature that involves extending struct mlx5_alloc_ucontext - * will be accompanied by an indication in the form of one or - * more fields in struct mlx5_alloc_ucontext_resp. If the - * response value can be interpreted as feature not supported - * when the returned value is zero, this will suffice to - * indicate to the library that the request was ignored by the - * kernel, either because it is unaware or because it decided - * to do so. If zero is a valid response, we will add a new - * field that indicates whether the request was handled. - */ - if (!ibv_cmd_get_context(&context->ibv_ctx, &req->ibv_req, - offsetof(struct mlx5_alloc_ucontext, lib_caps), - &resp->ibv_resp, resp_len)) - return 0; - - return ibv_cmd_get_context(&context->ibv_ctx, &req->ibv_req, - offsetof(struct mlx5_alloc_ucontext, - cqe_version), - &resp->ibv_resp, resp_len); -} - -static int mlx5_map_internal_clock(struct mlx5_device *mdev, - struct ibv_context *ibv_ctx) -{ - struct mlx5_context *context = to_mctx(ibv_ctx); - void *hca_clock_page; - off_t offset = 0; - - set_command(MLX5_MMAP_GET_CORE_CLOCK_CMD, &offset); - hca_clock_page = mmap(NULL, mdev->page_size, - PROT_READ, MAP_SHARED, ibv_ctx->cmd_fd, - mdev->page_size * offset); - - if (hca_clock_page == MAP_FAILED) { - fprintf(stderr, PFX - "Warning: Timestamp available,\n" - "but failed to mmap() hca core clock page.\n"); - return -1; - } - - context->hca_core_clock = hca_clock_page + - (context->core_clock.offset & (mdev->page_size - 1)); - return 0; -} - -int mlx5dv_query_device(struct ibv_context *ctx_in, - struct mlx5dv_context *attrs_out) -{ - struct mlx5_context *mctx = to_mctx(ctx_in); - uint64_t comp_mask_out = 0; - - attrs_out->version = 0; - attrs_out->flags = 0; - - if (mctx->cqe_version == MLX5_CQE_VERSION_V1) - attrs_out->flags |= MLX5DV_CONTEXT_FLAGS_CQE_V1; - - if (mctx->vendor_cap_flags & MLX5_VENDOR_CAP_FLAGS_MPW_ALLOWED) - attrs_out->flags |= MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED; - - if (attrs_out->comp_mask & MLX5DV_CONTEXT_MASK_CQE_COMPRESION) { - attrs_out->cqe_comp_caps = mctx->cqe_comp_caps; - comp_mask_out |= MLX5DV_CONTEXT_MASK_CQE_COMPRESION; - } - - if (mctx->vendor_cap_flags & MLX5_VENDOR_CAP_FLAGS_ENHANCED_MPW) - attrs_out->flags |= MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW; - - attrs_out->comp_mask = comp_mask_out; - - return 0; -} - -static int mlx5dv_get_qp(struct ibv_qp *qp_in, - struct mlx5dv_qp *qp_out) -{ - struct mlx5_qp *mqp = to_mqp(qp_in); - uint64_t mask_out = 0; - - qp_out->dbrec = mqp->db; - - if (mqp->sq_buf_size) - /* IBV_QPT_RAW_PACKET */ - qp_out->sq.buf = (void *)((uintptr_t)mqp->sq_buf.buf); - else - qp_out->sq.buf = (void *)((uintptr_t)mqp->buf.buf + mqp->sq.offset); - qp_out->sq.wqe_cnt = mqp->sq.wqe_cnt; - qp_out->sq.stride = 1 << mqp->sq.wqe_shift; - - qp_out->rq.buf = (void *)((uintptr_t)mqp->buf.buf + mqp->rq.offset); - qp_out->rq.wqe_cnt = mqp->rq.wqe_cnt; - qp_out->rq.stride = 1 << mqp->rq.wqe_shift; - - qp_out->bf.reg = mqp->bf->reg; - - if (qp_out->comp_mask & MLX5DV_QP_MASK_UAR_MMAP_OFFSET) { - qp_out->uar_mmap_offset = mqp->bf->uar_mmap_offset; - mask_out |= MLX5DV_QP_MASK_UAR_MMAP_OFFSET; - } - - if (mqp->bf->uuarn > 0) - qp_out->bf.size = mqp->bf->buf_size; - else - qp_out->bf.size = 0; - - qp_out->comp_mask = mask_out; - - return 0; -} - -static int mlx5dv_get_cq(struct ibv_cq *cq_in, - struct mlx5dv_cq *cq_out) -{ - struct mlx5_cq *mcq = to_mcq(cq_in); - struct mlx5_context *mctx = to_mctx(cq_in->context); - - cq_out->comp_mask = 0; - cq_out->cqn = mcq->cqn; - cq_out->cqe_cnt = mcq->ibv_cq.cqe + 1; - cq_out->cqe_size = mcq->cqe_sz; - cq_out->buf = mcq->active_buf->buf; - cq_out->dbrec = mcq->dbrec; - cq_out->cq_uar = mctx->uar[0]; - - mcq->flags |= MLX5_CQ_FLAGS_DV_OWNED; - - return 0; -} - -static int mlx5dv_get_rwq(struct ibv_wq *wq_in, - struct mlx5dv_rwq *rwq_out) -{ - struct mlx5_rwq *mrwq = to_mrwq(wq_in); - - rwq_out->comp_mask = 0; - rwq_out->buf = mrwq->pbuff; - rwq_out->dbrec = mrwq->recv_db; - rwq_out->wqe_cnt = mrwq->rq.wqe_cnt; - rwq_out->stride = 1 << mrwq->rq.wqe_shift; - - return 0; -} - -static int mlx5dv_get_srq(struct ibv_srq *srq_in, - struct mlx5dv_srq *srq_out) -{ - struct mlx5_srq *msrq; - - msrq = container_of(srq_in, struct mlx5_srq, vsrq.srq); - - srq_out->comp_mask = 0; - srq_out->buf = msrq->buf.buf; - srq_out->dbrec = msrq->db; - srq_out->stride = 1 << msrq->wqe_shift; - srq_out->head = msrq->head; - srq_out->tail = msrq->tail; - - return 0; -} - -LATEST_SYMVER_FUNC(mlx5dv_init_obj, 1_2, "MLX5_1.2", - int, - struct mlx5dv_obj *obj, uint64_t obj_type) -{ - int ret = 0; - - if (obj_type & MLX5DV_OBJ_QP) - ret = mlx5dv_get_qp(obj->qp.in, obj->qp.out); - if (!ret && (obj_type & MLX5DV_OBJ_CQ)) - ret = mlx5dv_get_cq(obj->cq.in, obj->cq.out); - if (!ret && (obj_type & MLX5DV_OBJ_SRQ)) - ret = mlx5dv_get_srq(obj->srq.in, obj->srq.out); - if (!ret && (obj_type & MLX5DV_OBJ_RWQ)) - ret = mlx5dv_get_rwq(obj->rwq.in, obj->rwq.out); - - return ret; -} - -COMPAT_SYMVER_FUNC(mlx5dv_init_obj, 1_0, "MLX5_1.0", - int, - struct mlx5dv_obj *obj, uint64_t obj_type) -{ - int ret = 0; - - ret = __mlx5dv_init_obj_1_2(obj, obj_type); - if (!ret && (obj_type & MLX5DV_OBJ_CQ)) { - /* ABI version 1.0 returns the void ** in this memory - * location - */ - obj->cq.out->cq_uar = to_mctx(obj->cq.in->context)->uar; - } - return ret; -} - -static off_t get_uar_mmap_offset(int idx, int page_size) -{ - off_t offset = 0; - - set_command(MLX5_MMAP_GET_REGULAR_PAGES_CMD, &offset); - set_index(idx, &offset); - return offset * page_size; -} - -int mlx5dv_set_context_attr(struct ibv_context *ibv_ctx, - enum mlx5dv_set_ctx_attr_type type, void *attr) -{ - struct mlx5_context *ctx = to_mctx(ibv_ctx); - - switch (type) { - case MLX5DV_CTX_ATTR_BUF_ALLOCATORS: - ctx->extern_alloc = *((struct mlx5dv_ctx_allocators *)attr); - break; - default: - return ENOTSUP; - } - - return 0; -} - -static void adjust_uar_info(struct mlx5_device *mdev, - struct mlx5_context *context, - struct mlx5_alloc_ucontext_resp resp) -{ - if (!resp.log_uar_size && !resp.num_uars_per_page) { - /* old kernel */ - context->uar_size = mdev->page_size; - context->num_uars_per_page = 1; - return; - } - - context->uar_size = 1 << resp.log_uar_size; - context->num_uars_per_page = resp.num_uars_per_page; -} - -static int mlx5_init_context(struct verbs_device *vdev, - struct ibv_context *ctx, int cmd_fd) -{ - struct mlx5_context *context; - struct mlx5_alloc_ucontext req; - struct mlx5_alloc_ucontext_resp resp; - int i; - int page_size; - int tot_uuars; - int low_lat_uuars; - int gross_uuars; - int j; - off_t offset; - struct mlx5_device *mdev; - struct verbs_context *v_ctx; - struct ibv_port_attr port_attr; - struct ibv_device_attr_ex device_attr; - int k; - int bfi; - int num_sys_page_map; - - mdev = to_mdev(&vdev->device); - v_ctx = verbs_get_ctx(ctx); - page_size = mdev->page_size; - mlx5_single_threaded = single_threaded_app(); - - context = to_mctx(ctx); - context->ibv_ctx.cmd_fd = cmd_fd; - - open_debug_file(context); - set_debug_mask(); - set_freeze_on_error(); - if (gethostname(context->hostname, sizeof(context->hostname))) - strcpy(context->hostname, "host_unknown"); - - tot_uuars = get_total_uuars(page_size); - if (tot_uuars < 0) { - errno = -tot_uuars; - goto err_free; - } - - low_lat_uuars = get_num_low_lat_uuars(tot_uuars); - if (low_lat_uuars < 0) { - errno = -low_lat_uuars; - goto err_free; - } - - if (low_lat_uuars > tot_uuars - 1) { - errno = ENOMEM; - goto err_free; - } - - memset(&req, 0, sizeof(req)); - memset(&resp, 0, sizeof(resp)); - - req.total_num_uuars = tot_uuars; - req.num_low_latency_uuars = low_lat_uuars; - req.cqe_version = MLX5_CQE_VERSION_V1; - req.lib_caps |= MLX5_LIB_CAP_4K_UAR; - - if (mlx5_cmd_get_context(context, &req, sizeof(req), &resp, - sizeof(resp))) - goto err_free; - - context->max_num_qps = resp.qp_tab_size; - context->bf_reg_size = resp.bf_reg_size; - context->tot_uuars = resp.tot_uuars; - context->low_lat_uuars = low_lat_uuars; - context->cache_line_size = resp.cache_line_size; - context->max_sq_desc_sz = resp.max_sq_desc_sz; - context->max_rq_desc_sz = resp.max_rq_desc_sz; - context->max_send_wqebb = resp.max_send_wqebb; - context->num_ports = resp.num_ports; - context->max_recv_wr = resp.max_recv_wr; - context->max_srq_recv_wr = resp.max_srq_recv_wr; - - context->cqe_version = resp.cqe_version; - if (context->cqe_version) { - if (context->cqe_version == MLX5_CQE_VERSION_V1) - mlx5_ctx_ops.poll_cq = mlx5_poll_cq_v1; - else - goto err_free; - } - - adjust_uar_info(mdev, context, resp); - - gross_uuars = context->tot_uuars / MLX5_NUM_NON_FP_BFREGS_PER_UAR * NUM_BFREGS_PER_UAR; - context->bfs = calloc(gross_uuars, sizeof(*context->bfs)); - if (!context->bfs) { - errno = ENOMEM; - goto err_free; - } - - context->cmds_supp_uhw = resp.cmds_supp_uhw; - context->vendor_cap_flags = 0; - - pthread_mutex_init(&context->qp_table_mutex, NULL); - pthread_mutex_init(&context->srq_table_mutex, NULL); - pthread_mutex_init(&context->uidx_table_mutex, NULL); - for (i = 0; i < MLX5_QP_TABLE_SIZE; ++i) - context->qp_table[i].refcnt = 0; - - for (i = 0; i < MLX5_QP_TABLE_SIZE; ++i) - context->uidx_table[i].refcnt = 0; - - context->db_list = NULL; - - pthread_mutex_init(&context->db_list_mutex, NULL); - - num_sys_page_map = context->tot_uuars / (context->num_uars_per_page * MLX5_NUM_NON_FP_BFREGS_PER_UAR); - for (i = 0; i < num_sys_page_map; ++i) { - offset = get_uar_mmap_offset(i, page_size); - context->uar[i] = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, - cmd_fd, offset); - if (context->uar[i] == MAP_FAILED) { - context->uar[i] = NULL; - goto err_free_bf; - } - } - - for (i = 0; i < num_sys_page_map; i++) { - for (j = 0; j < context->num_uars_per_page; j++) { - for (k = 0; k < NUM_BFREGS_PER_UAR; k++) { - bfi = (i * context->num_uars_per_page + j) * NUM_BFREGS_PER_UAR + k; - context->bfs[bfi].reg = context->uar[i] + MLX5_ADAPTER_PAGE_SIZE * j + - MLX5_BF_OFFSET + k * context->bf_reg_size; - context->bfs[bfi].need_lock = need_uuar_lock(context, bfi); - mlx5_spinlock_init(&context->bfs[bfi].lock); - context->bfs[bfi].offset = 0; - if (bfi) - context->bfs[bfi].buf_size = context->bf_reg_size / 2; - context->bfs[bfi].uuarn = bfi; - context->bfs[bfi].uar_mmap_offset = get_uar_mmap_offset(i, page_size); - } - } - } - context->hca_core_clock = NULL; - if (resp.response_length + sizeof(resp.ibv_resp) >= - offsetof(struct mlx5_alloc_ucontext_resp, hca_core_clock_offset) + - sizeof(resp.hca_core_clock_offset) && - resp.comp_mask & MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET) { - context->core_clock.offset = resp.hca_core_clock_offset; - mlx5_map_internal_clock(mdev, ctx); - } - - context->prefer_bf = get_always_bf(); - context->shut_up_bf = get_shut_up_bf(); - mlx5_read_env(&vdev->device, context); - - mlx5_spinlock_init(&context->hugetlb_lock); - list_head_init(&context->hugetlb_list); - - context->ibv_ctx.ops = mlx5_ctx_ops; - - verbs_set_ctx_op(v_ctx, create_qp_ex, mlx5_create_qp_ex); - verbs_set_ctx_op(v_ctx, open_xrcd, mlx5_open_xrcd); - verbs_set_ctx_op(v_ctx, close_xrcd, mlx5_close_xrcd); - verbs_set_ctx_op(v_ctx, create_srq_ex, mlx5_create_srq_ex); - verbs_set_ctx_op(v_ctx, get_srq_num, mlx5_get_srq_num); - verbs_set_ctx_op(v_ctx, query_device_ex, mlx5_query_device_ex); - verbs_set_ctx_op(v_ctx, query_rt_values, mlx5_query_rt_values); - verbs_set_ctx_op(v_ctx, ibv_create_flow, ibv_cmd_create_flow); - verbs_set_ctx_op(v_ctx, ibv_destroy_flow, ibv_cmd_destroy_flow); - verbs_set_ctx_op(v_ctx, create_cq_ex, mlx5_create_cq_ex); - verbs_set_ctx_op(v_ctx, create_wq, mlx5_create_wq); - verbs_set_ctx_op(v_ctx, modify_wq, mlx5_modify_wq); - verbs_set_ctx_op(v_ctx, destroy_wq, mlx5_destroy_wq); - verbs_set_ctx_op(v_ctx, create_rwq_ind_table, mlx5_create_rwq_ind_table); - verbs_set_ctx_op(v_ctx, destroy_rwq_ind_table, mlx5_destroy_rwq_ind_table); - - memset(&device_attr, 0, sizeof(device_attr)); - if (!mlx5_query_device_ex(ctx, NULL, &device_attr, - sizeof(struct ibv_device_attr_ex))) { - context->cached_device_cap_flags = - device_attr.orig_attr.device_cap_flags; - context->atomic_cap = device_attr.orig_attr.atomic_cap; - context->cached_tso_caps = device_attr.tso_caps; - } - - for (j = 0; j < min(MLX5_MAX_PORTS_NUM, context->num_ports); ++j) { - memset(&port_attr, 0, sizeof(port_attr)); - if (!mlx5_query_port(ctx, j + 1, &port_attr)) - context->cached_link_layer[j] = port_attr.link_layer; - } - - return 0; - -err_free_bf: - free(context->bfs); - -err_free: - for (i = 0; i < MLX5_MAX_UARS; ++i) { - if (context->uar[i]) - munmap(context->uar[i], page_size); - } - close_debug_file(context); - return errno; -} - -static void mlx5_cleanup_context(struct verbs_device *device, - struct ibv_context *ibctx) -{ - struct mlx5_context *context = to_mctx(ibctx); - int page_size = to_mdev(ibctx->device)->page_size; - int i; - - free(context->bfs); - for (i = 0; i < MLX5_MAX_UARS; ++i) { - if (context->uar[i]) - munmap(context->uar[i], page_size); - } - if (context->hca_core_clock) - munmap(context->hca_core_clock - context->core_clock.offset, - page_size); - close_debug_file(context); -} - -static void mlx5_uninit_device(struct verbs_device *verbs_device) -{ - struct mlx5_device *dev = to_mdev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device *mlx5_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct mlx5_device *dev; - - dev = calloc(1, sizeof *dev); - if (!dev) - return NULL; - - dev->page_size = sysconf(_SC_PAGESIZE); - dev->driver_abi_ver = sysfs_dev->abi_ver; - - dev->verbs_dev.sz = sizeof(*dev); - dev->verbs_dev.size_of_context = sizeof(struct mlx5_context) - - sizeof(struct ibv_context); - - return &dev->verbs_dev; -} - -static const struct verbs_device_ops mlx5_dev_ops = { - .name = "mlx5", - .match_min_abi_version = MLX5_UVERBS_MIN_ABI_VERSION, - .match_max_abi_version = MLX5_UVERBS_MAX_ABI_VERSION, - .match_table = hca_table, - .alloc_device = mlx5_device_alloc, - .uninit_device = mlx5_uninit_device, - .init_context = mlx5_init_context, - .uninit_context = mlx5_cleanup_context, -}; -PROVIDER_DRIVER(mlx5_dev_ops); diff --git a/usr/rdma-core/providers/mlx5/mlx5.h b/usr/rdma-core/providers/mlx5/mlx5.h deleted file mode 100644 index 46fce282b..000000000 --- a/usr/rdma-core/providers/mlx5/mlx5.h +++ /dev/null @@ -1,781 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef MLX5_H -#define MLX5_H - -#include -#include -#include -#include - -#include -#include -#include "mlx5-abi.h" -#include -#include "bitmap.h" -#include -#include "mlx5dv.h" - -#include - -#define PFX "mlx5: " - - -enum { - MLX5_IB_MMAP_CMD_SHIFT = 8, - MLX5_IB_MMAP_CMD_MASK = 0xff, -}; - -enum { - MLX5_MMAP_GET_REGULAR_PAGES_CMD = 0, - MLX5_MMAP_GET_CONTIGUOUS_PAGES_CMD = 1, - MLX5_MMAP_GET_CORE_CLOCK_CMD = 5 -}; - -enum { - MLX5_CQE_VERSION_V0 = 0, - MLX5_CQE_VERSION_V1 = 1, -}; - -enum { - MLX5_ADAPTER_PAGE_SIZE = 4096, -}; - -#define MLX5_CQ_PREFIX "MLX_CQ" -#define MLX5_QP_PREFIX "MLX_QP" -#define MLX5_MR_PREFIX "MLX_MR" -#define MLX5_RWQ_PREFIX "MLX_RWQ" -#define MLX5_MAX_LOG2_CONTIG_BLOCK_SIZE 23 -#define MLX5_MIN_LOG2_CONTIG_BLOCK_SIZE 12 - -enum { - MLX5_DBG_QP = 1 << 0, - MLX5_DBG_CQ = 1 << 1, - MLX5_DBG_QP_SEND = 1 << 2, - MLX5_DBG_QP_SEND_ERR = 1 << 3, - MLX5_DBG_CQ_CQE = 1 << 4, - MLX5_DBG_CONTIG = 1 << 5, -}; - -extern uint32_t mlx5_debug_mask; -extern int mlx5_freeze_on_error_cqe; - -#ifdef MLX5_DEBUG -#define mlx5_dbg(fp, mask, format, arg...) \ -do { \ - if (mask & mlx5_debug_mask) \ - fprintf(fp, "%s:%d: " format, __func__, __LINE__, ##arg); \ -} while (0) - -#else -static inline void mlx5_dbg(FILE *fp, uint32_t mask, const char *fmt, ...) - __attribute__((format(printf, 3, 4))); -static inline void mlx5_dbg(FILE *fp, uint32_t mask, const char *fmt, ...) -{ -} -#endif - -enum { - MLX5_STAT_RATE_OFFSET = 5 -}; - -enum { - MLX5_QP_TABLE_SHIFT = 12, - MLX5_QP_TABLE_MASK = (1 << MLX5_QP_TABLE_SHIFT) - 1, - MLX5_QP_TABLE_SIZE = 1 << (24 - MLX5_QP_TABLE_SHIFT), -}; - -enum { - MLX5_UIDX_TABLE_SHIFT = 12, - MLX5_UIDX_TABLE_MASK = (1 << MLX5_UIDX_TABLE_SHIFT) - 1, - MLX5_UIDX_TABLE_SIZE = 1 << (24 - MLX5_UIDX_TABLE_SHIFT), -}; - -enum { - MLX5_SRQ_TABLE_SHIFT = 12, - MLX5_SRQ_TABLE_MASK = (1 << MLX5_SRQ_TABLE_SHIFT) - 1, - MLX5_SRQ_TABLE_SIZE = 1 << (24 - MLX5_SRQ_TABLE_SHIFT), -}; - -enum { - MLX5_BF_OFFSET = 0x800 -}; - -enum { - MLX5_RECV_OPCODE_RDMA_WRITE_IMM = 0x00, - MLX5_RECV_OPCODE_SEND = 0x01, - MLX5_RECV_OPCODE_SEND_IMM = 0x02, - MLX5_RECV_OPCODE_SEND_INVAL = 0x03, - - MLX5_CQE_OPCODE_ERROR = 0x1e, - MLX5_CQE_OPCODE_RESIZE = 0x16, -}; - -enum { - MLX5_SRQ_FLAG_SIGNATURE = 1 << 0, -}; - -enum { - MLX5_MAX_PORTS_NUM = 2, -}; - -enum { - MLX5_CSUM_SUPPORT_RAW_OVER_ETH = (1 << 0), - MLX5_CSUM_SUPPORT_UNDERLAY_UD = (1 << 1), - /* - * Only report rx checksum when the validation - * is valid. - */ - MLX5_RX_CSUM_VALID = (1 << 16), -}; - -enum mlx5_alloc_type { - MLX5_ALLOC_TYPE_ANON, - MLX5_ALLOC_TYPE_HUGE, - MLX5_ALLOC_TYPE_CONTIG, - MLX5_ALLOC_TYPE_PREFER_HUGE, - MLX5_ALLOC_TYPE_PREFER_CONTIG, - MLX5_ALLOC_TYPE_EXTERNAL, - MLX5_ALLOC_TYPE_ALL -}; - -enum mlx5_rsc_type { - MLX5_RSC_TYPE_QP, - MLX5_RSC_TYPE_XSRQ, - MLX5_RSC_TYPE_SRQ, - MLX5_RSC_TYPE_RWQ, - MLX5_RSC_TYPE_INVAL, -}; - -enum { - MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE = 1 << 0, - MLX5_USER_CMDS_SUPP_UHW_CREATE_AH = 1 << 1, -}; - -enum mlx5_vendor_cap_flags { - MLX5_VENDOR_CAP_FLAGS_MPW = 1 << 0, /* Obsoleted */ - MLX5_VENDOR_CAP_FLAGS_MPW_ALLOWED = 1 << 1, - MLX5_VENDOR_CAP_FLAGS_ENHANCED_MPW = 1 << 2, -}; - -enum { - MLX5_FLOW_TAG_MASK = 0x000fffff, -}; - -struct mlx5_resource { - enum mlx5_rsc_type type; - uint32_t rsn; -}; - -struct mlx5_device { - struct verbs_device verbs_dev; - int page_size; - int driver_abi_ver; -}; - -struct mlx5_db_page; - -struct mlx5_spinlock { - pthread_spinlock_t lock; - int in_use; -}; - -struct mlx5_context { - struct ibv_context ibv_ctx; - int max_num_qps; - int bf_reg_size; - int tot_uuars; - int low_lat_uuars; - int num_uars_per_page; - int bf_regs_per_page; - int num_bf_regs; - int prefer_bf; - int shut_up_bf; - struct { - struct mlx5_qp **table; - int refcnt; - } qp_table[MLX5_QP_TABLE_SIZE]; - pthread_mutex_t qp_table_mutex; - - struct { - struct mlx5_srq **table; - int refcnt; - } srq_table[MLX5_SRQ_TABLE_SIZE]; - pthread_mutex_t srq_table_mutex; - - struct { - struct mlx5_resource **table; - int refcnt; - } uidx_table[MLX5_UIDX_TABLE_SIZE]; - pthread_mutex_t uidx_table_mutex; - - void *uar[MLX5_MAX_UARS]; - struct mlx5_db_page *db_list; - pthread_mutex_t db_list_mutex; - int cache_line_size; - int max_sq_desc_sz; - int max_rq_desc_sz; - int max_send_wqebb; - int max_recv_wr; - unsigned max_srq_recv_wr; - int num_ports; - int stall_enable; - int stall_adaptive_enable; - int stall_cycles; - struct mlx5_bf *bfs; - FILE *dbg_fp; - char hostname[40]; - struct mlx5_spinlock hugetlb_lock; - struct list_head hugetlb_list; - int cqe_version; - uint8_t cached_link_layer[MLX5_MAX_PORTS_NUM]; - int cached_device_cap_flags; - enum ibv_atomic_cap atomic_cap; - struct { - uint64_t offset; - uint64_t mask; - } core_clock; - void *hca_core_clock; - struct ibv_tso_caps cached_tso_caps; - int cmds_supp_uhw; - uint32_t uar_size; - uint64_t vendor_cap_flags; /* Use enum mlx5_vendor_cap_flags */ - struct mlx5dv_cqe_comp_caps cqe_comp_caps; - struct mlx5dv_ctx_allocators extern_alloc; -}; - -struct mlx5_bitmap { - uint32_t last; - uint32_t top; - uint32_t max; - uint32_t avail; - uint32_t mask; - unsigned long *table; -}; - -struct mlx5_hugetlb_mem { - int shmid; - void *shmaddr; - struct mlx5_bitmap bitmap; - struct list_node entry; -}; - -struct mlx5_buf { - void *buf; - size_t length; - int base; - struct mlx5_hugetlb_mem *hmem; - enum mlx5_alloc_type type; -}; - -struct mlx5_pd { - struct ibv_pd ibv_pd; - uint32_t pdn; -}; - -enum { - MLX5_CQ_SET_CI = 0, - MLX5_CQ_ARM_DB = 1, -}; - -enum { - MLX5_CQ_FLAGS_RX_CSUM_VALID = 1 << 0, - MLX5_CQ_FLAGS_EMPTY_DURING_POLL = 1 << 1, - MLX5_CQ_FLAGS_FOUND_CQES = 1 << 2, - MLX5_CQ_FLAGS_EXTENDED = 1 << 3, - MLX5_CQ_FLAGS_SINGLE_THREADED = 1 << 4, - MLX5_CQ_FLAGS_DV_OWNED = 1 << 5, -}; - -struct mlx5_cq { - /* ibv_cq should always be subset of ibv_cq_ex */ - struct ibv_cq_ex ibv_cq; - struct mlx5_buf buf_a; - struct mlx5_buf buf_b; - struct mlx5_buf *active_buf; - struct mlx5_buf *resize_buf; - int resize_cqes; - int active_cqes; - struct mlx5_spinlock lock; - uint32_t cqn; - uint32_t cons_index; - __be32 *dbrec; - int arm_sn; - int cqe_sz; - int resize_cqe_sz; - int stall_next_poll; - int stall_enable; - uint64_t stall_last_count; - int stall_adaptive_enable; - int stall_cycles; - struct mlx5_resource *cur_rsc; - struct mlx5_srq *cur_srq; - struct mlx5_cqe64 *cqe64; - uint32_t flags; - int umr_opcode; -}; - -struct mlx5_srq { - struct mlx5_resource rsc; /* This struct must be first */ - struct verbs_srq vsrq; - struct mlx5_buf buf; - struct mlx5_spinlock lock; - uint64_t *wrid; - uint32_t srqn; - int max; - int max_gs; - int wqe_shift; - int head; - int tail; - __be32 *db; - uint16_t counter; - int wq_sig; -}; - -struct wr_list { - uint16_t opcode; - uint16_t next; -}; - -struct mlx5_wq { - uint64_t *wrid; - unsigned *wqe_head; - struct mlx5_spinlock lock; - unsigned wqe_cnt; - unsigned max_post; - unsigned head; - unsigned tail; - unsigned cur_post; - int max_gs; - int wqe_shift; - int offset; - void *qend; - uint32_t *wr_data; -}; - -struct mlx5_bf { - void *reg; - int need_lock; - struct mlx5_spinlock lock; - unsigned offset; - unsigned buf_size; - unsigned uuarn; - off_t uar_mmap_offset; -}; - -struct mlx5_mr { - struct ibv_mr ibv_mr; - struct mlx5_buf buf; - uint32_t alloc_flags; -}; - -enum mlx5_qp_flags { - MLX5_QP_FLAGS_USE_UNDERLAY = 0x01, -}; - -struct mlx5_qp { - struct mlx5_resource rsc; /* This struct must be first */ - struct verbs_qp verbs_qp; - struct ibv_qp *ibv_qp; - struct mlx5_buf buf; - void *sq_start; - int max_inline_data; - int buf_size; - /* For Raw Packet QP, use different buffers for the SQ and RQ */ - struct mlx5_buf sq_buf; - int sq_buf_size; - struct mlx5_bf *bf; - - uint8_t fm_cache; - uint8_t sq_signal_bits; - struct mlx5_wq sq; - - __be32 *db; - struct mlx5_wq rq; - int wq_sig; - uint32_t qp_cap_cache; - int atomics_enabled; - uint32_t max_tso; - uint16_t max_tso_header; - int rss_qp; - uint32_t flags; /* Use enum mlx5_qp_flags */ -}; - -struct mlx5_ah { - struct ibv_ah ibv_ah; - struct mlx5_wqe_av av; - bool kern_ah; -}; - -struct mlx5_rwq { - struct mlx5_resource rsc; - struct ibv_wq wq; - struct mlx5_buf buf; - int buf_size; - struct mlx5_wq rq; - __be32 *db; - void *pbuff; - __be32 *recv_db; - int wq_sig; -}; - -static inline int mlx5_ilog2(int n) -{ - int t; - - if (n <= 0) - return -1; - - t = 0; - while ((1 << t) < n) - ++t; - - return t; -} - -extern int mlx5_stall_num_loop; -extern int mlx5_stall_cq_poll_min; -extern int mlx5_stall_cq_poll_max; -extern int mlx5_stall_cq_inc_step; -extern int mlx5_stall_cq_dec_step; -extern int mlx5_single_threaded; - -static inline unsigned DIV_ROUND_UP(unsigned n, unsigned d) -{ - return (n + d - 1u) / d; -} - -static inline unsigned long align(unsigned long val, unsigned long align) -{ - return (val + align - 1) & ~(align - 1); -} - -#define to_mxxx(xxx, type) \ - ((struct mlx5_##type *) \ - ((void *) ib##xxx - offsetof(struct mlx5_##type, ibv_##xxx))) - -static inline struct mlx5_device *to_mdev(struct ibv_device *ibdev) -{ - struct mlx5_device *ret; - - ret = (void *)ibdev - offsetof(struct mlx5_device, verbs_dev); - return ret; -} - -static inline struct mlx5_context *to_mctx(struct ibv_context *ibctx) -{ - return to_mxxx(ctx, context); -} - -static inline struct mlx5_pd *to_mpd(struct ibv_pd *ibpd) -{ - return to_mxxx(pd, pd); -} - -static inline struct mlx5_cq *to_mcq(struct ibv_cq *ibcq) -{ - return to_mxxx(cq, cq); -} - -static inline struct mlx5_srq *to_msrq(struct ibv_srq *ibsrq) -{ - struct verbs_srq *vsrq = (struct verbs_srq *)ibsrq; - - return container_of(vsrq, struct mlx5_srq, vsrq); -} - -static inline struct mlx5_qp *to_mqp(struct ibv_qp *ibqp) -{ - struct verbs_qp *vqp = (struct verbs_qp *)ibqp; - - return container_of(vqp, struct mlx5_qp, verbs_qp); -} - -static inline struct mlx5_rwq *to_mrwq(struct ibv_wq *ibwq) -{ - return container_of(ibwq, struct mlx5_rwq, wq); -} - -static inline struct mlx5_mr *to_mmr(struct ibv_mr *ibmr) -{ - return to_mxxx(mr, mr); -} - -static inline struct mlx5_ah *to_mah(struct ibv_ah *ibah) -{ - return to_mxxx(ah, ah); -} - -static inline int max_int(int a, int b) -{ - return a > b ? a : b; -} - -static inline struct mlx5_qp *rsc_to_mqp(struct mlx5_resource *rsc) -{ - return (struct mlx5_qp *)rsc; -} - -static inline struct mlx5_srq *rsc_to_msrq(struct mlx5_resource *rsc) -{ - return (struct mlx5_srq *)rsc; -} - -static inline struct mlx5_rwq *rsc_to_mrwq(struct mlx5_resource *rsc) -{ - return (struct mlx5_rwq *)rsc; -} - -int mlx5_alloc_buf(struct mlx5_buf *buf, size_t size, int page_size); -void mlx5_free_buf(struct mlx5_buf *buf); -int mlx5_alloc_buf_contig(struct mlx5_context *mctx, struct mlx5_buf *buf, - size_t size, int page_size, const char *component); -void mlx5_free_buf_contig(struct mlx5_context *mctx, struct mlx5_buf *buf); -int mlx5_alloc_prefered_buf(struct mlx5_context *mctx, - struct mlx5_buf *buf, - size_t size, int page_size, - enum mlx5_alloc_type alloc_type, - const char *component); -int mlx5_free_actual_buf(struct mlx5_context *ctx, struct mlx5_buf *buf); -void mlx5_get_alloc_type(struct mlx5_context *context, - const char *component, - enum mlx5_alloc_type *alloc_type, - enum mlx5_alloc_type default_alloc_type); -int mlx5_use_huge(const char *key); -bool mlx5_is_extern_alloc(struct mlx5_context *context); -int mlx5_alloc_buf_extern(struct mlx5_context *ctx, struct mlx5_buf *buf, - size_t size); -void mlx5_free_buf_extern(struct mlx5_context *ctx, struct mlx5_buf *buf); - -__be32 *mlx5_alloc_dbrec(struct mlx5_context *context); -void mlx5_free_db(struct mlx5_context *context, __be32 *db); - -int mlx5_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); -int mlx5_query_device_ex(struct ibv_context *context, - const struct ibv_query_device_ex_input *input, - struct ibv_device_attr_ex *attr, - size_t attr_size); -int mlx5_query_rt_values(struct ibv_context *context, - struct ibv_values_ex *values); -struct ibv_qp *mlx5_create_qp_ex(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr); -int mlx5_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -struct ibv_pd *mlx5_alloc_pd(struct ibv_context *context); -int mlx5_free_pd(struct ibv_pd *pd); - -struct ibv_mr *mlx5_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); -int mlx5_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd, void *addr, - size_t length, int access); -int mlx5_dereg_mr(struct ibv_mr *mr); -struct ibv_mw *mlx5_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type); -int mlx5_dealloc_mw(struct ibv_mw *mw); -int mlx5_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw, - struct ibv_mw_bind *mw_bind); - -struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); -struct ibv_cq_ex *mlx5_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr); -void mlx5_cq_fill_pfns(struct mlx5_cq *cq, const struct ibv_cq_init_attr_ex *cq_attr); -int mlx5_alloc_cq_buf(struct mlx5_context *mctx, struct mlx5_cq *cq, - struct mlx5_buf *buf, int nent, int cqe_sz); -int mlx5_free_cq_buf(struct mlx5_context *ctx, struct mlx5_buf *buf); -int mlx5_resize_cq(struct ibv_cq *cq, int cqe); -int mlx5_destroy_cq(struct ibv_cq *cq); -int mlx5_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -int mlx5_poll_cq_v1(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -int mlx5_arm_cq(struct ibv_cq *cq, int solicited); -void mlx5_cq_event(struct ibv_cq *cq); -void __mlx5_cq_clean(struct mlx5_cq *cq, uint32_t qpn, struct mlx5_srq *srq); -void mlx5_cq_clean(struct mlx5_cq *cq, uint32_t qpn, struct mlx5_srq *srq); -void mlx5_cq_resize_copy_cqes(struct mlx5_cq *cq); - -struct ibv_srq *mlx5_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); -int mlx5_modify_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr, - int mask); -int mlx5_query_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr); -int mlx5_destroy_srq(struct ibv_srq *srq); -int mlx5_alloc_srq_buf(struct ibv_context *context, struct mlx5_srq *srq); -void mlx5_free_srq_wqe(struct mlx5_srq *srq, int ind); -int mlx5_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -struct ibv_qp *mlx5_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr); -int mlx5_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); -int mlx5_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); -int mlx5_destroy_qp(struct ibv_qp *qp); -void mlx5_init_qp_indices(struct mlx5_qp *qp); -void mlx5_init_rwq_indices(struct mlx5_rwq *rwq); -int mlx5_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -int mlx5_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -int mlx5_post_wq_recv(struct ibv_wq *ibwq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -void mlx5_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type, - struct mlx5_qp *qp); -void mlx5_set_sq_sizes(struct mlx5_qp *qp, struct ibv_qp_cap *cap, - enum ibv_qp_type type); -struct mlx5_qp *mlx5_find_qp(struct mlx5_context *ctx, uint32_t qpn); -int mlx5_store_qp(struct mlx5_context *ctx, uint32_t qpn, struct mlx5_qp *qp); -void mlx5_clear_qp(struct mlx5_context *ctx, uint32_t qpn); -int32_t mlx5_store_uidx(struct mlx5_context *ctx, void *rsc); -void mlx5_clear_uidx(struct mlx5_context *ctx, uint32_t uidx); -struct mlx5_srq *mlx5_find_srq(struct mlx5_context *ctx, uint32_t srqn); -int mlx5_store_srq(struct mlx5_context *ctx, uint32_t srqn, - struct mlx5_srq *srq); -void mlx5_clear_srq(struct mlx5_context *ctx, uint32_t srqn); -struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr); -int mlx5_destroy_ah(struct ibv_ah *ah); -int mlx5_alloc_av(struct mlx5_pd *pd, struct ibv_ah_attr *attr, - struct mlx5_ah *ah); -void mlx5_free_av(struct mlx5_ah *ah); -int mlx5_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); -int mlx5_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); -int mlx5_round_up_power_of_two(long long sz); -void *mlx5_get_atomic_laddr(struct mlx5_qp *qp, uint16_t idx, int *byte_count); -void *mlx5_get_send_wqe(struct mlx5_qp *qp, int n); -int mlx5_copy_to_recv_wqe(struct mlx5_qp *qp, int idx, void *buf, int size); -int mlx5_copy_to_send_wqe(struct mlx5_qp *qp, int idx, void *buf, int size); -int mlx5_copy_to_recv_srq(struct mlx5_srq *srq, int idx, void *buf, int size); -struct ibv_xrcd *mlx5_open_xrcd(struct ibv_context *context, - struct ibv_xrcd_init_attr *xrcd_init_attr); -int mlx5_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num); -int mlx5_close_xrcd(struct ibv_xrcd *ib_xrcd); -struct ibv_wq *mlx5_create_wq(struct ibv_context *context, - struct ibv_wq_init_attr *attr); -int mlx5_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr); -int mlx5_destroy_wq(struct ibv_wq *wq); -struct ibv_rwq_ind_table *mlx5_create_rwq_ind_table(struct ibv_context *context, - struct ibv_rwq_ind_table_init_attr *init_attr); -int mlx5_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table); -struct ibv_srq *mlx5_create_srq_ex(struct ibv_context *context, - struct ibv_srq_init_attr_ex *attr); - -static inline void *mlx5_find_uidx(struct mlx5_context *ctx, uint32_t uidx) -{ - int tind = uidx >> MLX5_UIDX_TABLE_SHIFT; - - if (likely(ctx->uidx_table[tind].refcnt)) - return ctx->uidx_table[tind].table[uidx & MLX5_UIDX_TABLE_MASK]; - - return NULL; -} - -static inline int mlx5_spin_lock(struct mlx5_spinlock *lock) -{ - if (!mlx5_single_threaded) - return pthread_spin_lock(&lock->lock); - - if (unlikely(lock->in_use)) { - fprintf(stderr, "*** ERROR: multithreading vilation ***\n" - "You are running a multithreaded application but\n" - "you set MLX5_SINGLE_THREADED=1. Please unset it.\n"); - abort(); - } else { - lock->in_use = 1; - /* - * This fence is not at all correct, but it increases the - * chance that in_use is detected by another thread without - * much runtime cost. */ - atomic_thread_fence(memory_order_acq_rel); - } - - return 0; -} - -static inline int mlx5_spin_unlock(struct mlx5_spinlock *lock) -{ - if (!mlx5_single_threaded) - return pthread_spin_unlock(&lock->lock); - - lock->in_use = 0; - - return 0; -} - -static inline int mlx5_spinlock_init(struct mlx5_spinlock *lock) -{ - lock->in_use = 0; - return pthread_spin_init(&lock->lock, PTHREAD_PROCESS_PRIVATE); -} - -static inline int mlx5_spinlock_destroy(struct mlx5_spinlock *lock) -{ - return pthread_spin_destroy(&lock->lock); -} - -static inline void set_command(int command, off_t *offset) -{ - *offset |= (command << MLX5_IB_MMAP_CMD_SHIFT); -} - -static inline void set_arg(int arg, off_t *offset) -{ - *offset |= arg; -} - -static inline void set_order(int order, off_t *offset) -{ - set_arg(order, offset); -} - -static inline void set_index(int index, off_t *offset) -{ - set_arg(index, offset); -} - -static inline uint8_t calc_sig(void *wqe, int size) -{ - int i; - uint8_t *p = wqe; - uint8_t res = 0; - - for (i = 0; i < size; ++i) - res ^= p[i]; - - return ~res; -} - -#endif /* MLX5_H */ diff --git a/usr/rdma-core/providers/mlx5/mlx5dv.h b/usr/rdma-core/providers/mlx5/mlx5dv.h deleted file mode 100644 index ffe2c555a..000000000 --- a/usr/rdma-core/providers/mlx5/mlx5dv.h +++ /dev/null @@ -1,650 +0,0 @@ -/* - * Copyright (c) 2017 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _MLX5DV_H_ -#define _MLX5DV_H_ - -#include -#include /* For the __be64 type */ -#include -#if defined(__SSE3__) -#include -#include -#include -#endif /* defined(__SSE3__) */ - -#include - -/* Always inline the functions */ -#ifdef __GNUC__ -#define MLX5DV_ALWAYS_INLINE inline __attribute__((always_inline)) -#else -#define MLX5DV_ALWAYS_INLINE inline -#endif - -enum { - MLX5_RCV_DBR = 0, - MLX5_SND_DBR = 1, -}; - -enum mlx5dv_context_comp_mask { - MLX5DV_CONTEXT_MASK_CQE_COMPRESION = 1 << 0, - MLX5DV_CONTEXT_MASK_RESERVED = 1 << 1, -}; - -struct mlx5dv_cqe_comp_caps { - uint32_t max_num; - uint32_t supported_format; /* enum mlx5dv_cqe_comp_res_format */ -}; - -/* - * Direct verbs device-specific attributes - */ -struct mlx5dv_context { - uint8_t version; - uint64_t flags; - uint64_t comp_mask; - struct mlx5dv_cqe_comp_caps cqe_comp_caps; -}; - -enum mlx5dv_context_flags { - /* - * This flag indicates if CQE version 0 or 1 is needed. - */ - MLX5DV_CONTEXT_FLAGS_CQE_V1 = (1 << 0), - MLX5DV_CONTEXT_FLAGS_OBSOLETE = (1 << 1), /* Obsoleted, don't use */ - MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED = (1 << 2), - MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW = (1 << 3), -}; - -enum mlx5dv_cq_init_attr_mask { - MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE = 1 << 0, - MLX5DV_CQ_INIT_ATTR_MASK_RESERVED = 1 << 1, -}; - -struct mlx5dv_cq_init_attr { - uint64_t comp_mask; /* Use enum mlx5dv_cq_init_attr_mask */ - uint8_t cqe_comp_res_format; /* Use enum mlx5dv_cqe_comp_res_format */ -}; - -struct ibv_cq_ex *mlx5dv_create_cq(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr, - struct mlx5dv_cq_init_attr *mlx5_cq_attr); -/* - * Most device capabilities are exported by ibv_query_device(...), - * but there is HW device-specific information which is important - * for data-path, but isn't provided. - * - * Return 0 on success. - */ -int mlx5dv_query_device(struct ibv_context *ctx_in, - struct mlx5dv_context *attrs_out); - -enum mlx5dv_qp_comp_mask { - MLX5DV_QP_MASK_UAR_MMAP_OFFSET = 1 << 0, -}; - -struct mlx5dv_qp { - __be32 *dbrec; - struct { - void *buf; - uint32_t wqe_cnt; - uint32_t stride; - } sq; - struct { - void *buf; - uint32_t wqe_cnt; - uint32_t stride; - } rq; - struct { - void *reg; - uint32_t size; - } bf; - uint64_t comp_mask; - off_t uar_mmap_offset; -}; - -struct mlx5dv_cq { - void *buf; - __be32 *dbrec; - uint32_t cqe_cnt; - uint32_t cqe_size; - void *cq_uar; - uint32_t cqn; - uint64_t comp_mask; -}; - -struct mlx5dv_srq { - void *buf; - __be32 *dbrec; - uint32_t stride; - uint32_t head; - uint32_t tail; - uint64_t comp_mask; -}; - -struct mlx5dv_rwq { - void *buf; - __be32 *dbrec; - uint32_t wqe_cnt; - uint32_t stride; - uint64_t comp_mask; -}; - -struct mlx5dv_obj { - struct { - struct ibv_qp *in; - struct mlx5dv_qp *out; - } qp; - struct { - struct ibv_cq *in; - struct mlx5dv_cq *out; - } cq; - struct { - struct ibv_srq *in; - struct mlx5dv_srq *out; - } srq; - struct { - struct ibv_wq *in; - struct mlx5dv_rwq *out; - } rwq; -}; - -enum mlx5dv_obj_type { - MLX5DV_OBJ_QP = 1 << 0, - MLX5DV_OBJ_CQ = 1 << 1, - MLX5DV_OBJ_SRQ = 1 << 2, - MLX5DV_OBJ_RWQ = 1 << 3, -}; - -/* - * This function will initialize mlx5dv_xxx structs based on supplied type. - * The information for initialization is taken from ibv_xx structs supplied - * as part of input. - * - * Request information of CQ marks its owned by DV for all consumer index - * related actions. - * - * The initialization type can be combination of several types together. - * - * Return: 0 in case of success. - */ -int mlx5dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type); - -enum { - MLX5_OPCODE_NOP = 0x00, - MLX5_OPCODE_SEND_INVAL = 0x01, - MLX5_OPCODE_RDMA_WRITE = 0x08, - MLX5_OPCODE_RDMA_WRITE_IMM = 0x09, - MLX5_OPCODE_SEND = 0x0a, - MLX5_OPCODE_SEND_IMM = 0x0b, - MLX5_OPCODE_TSO = 0x0e, - MLX5_OPCODE_RDMA_READ = 0x10, - MLX5_OPCODE_ATOMIC_CS = 0x11, - MLX5_OPCODE_ATOMIC_FA = 0x12, - MLX5_OPCODE_ATOMIC_MASKED_CS = 0x14, - MLX5_OPCODE_ATOMIC_MASKED_FA = 0x15, - MLX5_OPCODE_FMR = 0x19, - MLX5_OPCODE_LOCAL_INVAL = 0x1b, - MLX5_OPCODE_CONFIG_CMD = 0x1f, - MLX5_OPCODE_UMR = 0x25, -}; - -/* - * CQE related part - */ - -enum { - MLX5_INLINE_SCATTER_32 = 0x4, - MLX5_INLINE_SCATTER_64 = 0x8, -}; - -enum { - MLX5_CQE_SYNDROME_LOCAL_LENGTH_ERR = 0x01, - MLX5_CQE_SYNDROME_LOCAL_QP_OP_ERR = 0x02, - MLX5_CQE_SYNDROME_LOCAL_PROT_ERR = 0x04, - MLX5_CQE_SYNDROME_WR_FLUSH_ERR = 0x05, - MLX5_CQE_SYNDROME_MW_BIND_ERR = 0x06, - MLX5_CQE_SYNDROME_BAD_RESP_ERR = 0x10, - MLX5_CQE_SYNDROME_LOCAL_ACCESS_ERR = 0x11, - MLX5_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12, - MLX5_CQE_SYNDROME_REMOTE_ACCESS_ERR = 0x13, - MLX5_CQE_SYNDROME_REMOTE_OP_ERR = 0x14, - MLX5_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR = 0x15, - MLX5_CQE_SYNDROME_RNR_RETRY_EXC_ERR = 0x16, - MLX5_CQE_SYNDROME_REMOTE_ABORTED_ERR = 0x22, -}; - -enum { - MLX5_CQE_L2_OK = 1 << 0, - MLX5_CQE_L3_OK = 1 << 1, - MLX5_CQE_L4_OK = 1 << 2, -}; - -enum { - MLX5_CQE_L3_HDR_TYPE_NONE = 0x0, - MLX5_CQE_L3_HDR_TYPE_IPV6 = 0x1, - MLX5_CQE_L3_HDR_TYPE_IPV4 = 0x2, -}; - -enum { - MLX5_CQE_OWNER_MASK = 1, - MLX5_CQE_REQ = 0, - MLX5_CQE_RESP_WR_IMM = 1, - MLX5_CQE_RESP_SEND = 2, - MLX5_CQE_RESP_SEND_IMM = 3, - MLX5_CQE_RESP_SEND_INV = 4, - MLX5_CQE_RESIZE_CQ = 5, - MLX5_CQE_REQ_ERR = 13, - MLX5_CQE_RESP_ERR = 14, - MLX5_CQE_INVALID = 15, -}; - -enum { - MLX5_CQ_DOORBELL = 0x20 -}; - -enum { - MLX5_CQ_DB_REQ_NOT_SOL = 1 << 24, - MLX5_CQ_DB_REQ_NOT = 0 << 24, -}; - -struct mlx5_err_cqe { - uint8_t rsvd0[32]; - uint32_t srqn; - uint8_t rsvd1[18]; - uint8_t vendor_err_synd; - uint8_t syndrome; - uint32_t s_wqe_opcode_qpn; - uint16_t wqe_counter; - uint8_t signature; - uint8_t op_own; -}; - -struct mlx5_cqe64 { - uint8_t rsvd0[17]; - uint8_t ml_path; - uint8_t rsvd20[4]; - __be16 slid; - __be32 flags_rqpn; - uint8_t hds_ip_ext; - uint8_t l4_hdr_type_etc; - __be16 vlan_info; - __be32 srqn_uidx; - __be32 imm_inval_pkey; - uint8_t rsvd40[4]; - __be32 byte_cnt; - __be64 timestamp; - __be32 sop_drop_qpn; - __be16 wqe_counter; - uint8_t signature; - uint8_t op_own; -}; - -enum mlx5dv_cqe_comp_res_format { - MLX5DV_CQE_RES_FORMAT_HASH = 1 << 0, - MLX5DV_CQE_RES_FORMAT_CSUM = 1 << 1, - MLX5DV_CQE_RES_FORMAT_RESERVED = 1 << 2, -}; - -static MLX5DV_ALWAYS_INLINE -uint8_t mlx5dv_get_cqe_owner(struct mlx5_cqe64 *cqe) -{ - return cqe->op_own & 0x1; -} - -static MLX5DV_ALWAYS_INLINE -void mlx5dv_set_cqe_owner(struct mlx5_cqe64 *cqe, uint8_t val) -{ - cqe->op_own = (val & 0x1) | (cqe->op_own & ~0x1); -} - -/* Solicited event */ -static MLX5DV_ALWAYS_INLINE -uint8_t mlx5dv_get_cqe_se(struct mlx5_cqe64 *cqe) -{ - return (cqe->op_own >> 1) & 0x1; -} - -static MLX5DV_ALWAYS_INLINE -uint8_t mlx5dv_get_cqe_format(struct mlx5_cqe64 *cqe) -{ - return (cqe->op_own >> 2) & 0x3; -} - -static MLX5DV_ALWAYS_INLINE -uint8_t mlx5dv_get_cqe_opcode(struct mlx5_cqe64 *cqe) -{ - return cqe->op_own >> 4; -} - -/* - * WQE related part - */ -enum { - MLX5_INVALID_LKEY = 0x100, -}; - -enum { - MLX5_EXTENDED_UD_AV = 0x80000000, -}; - -enum { - MLX5_WQE_CTRL_CQ_UPDATE = 2 << 2, - MLX5_WQE_CTRL_SOLICITED = 1 << 1, - MLX5_WQE_CTRL_FENCE = 4 << 5, - MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE = 1 << 5, -}; - -enum { - MLX5_SEND_WQE_BB = 64, - MLX5_SEND_WQE_SHIFT = 6, -}; - -enum { - MLX5_INLINE_SEG = 0x80000000, -}; - -enum { - MLX5_ETH_WQE_L3_CSUM = (1 << 6), - MLX5_ETH_WQE_L4_CSUM = (1 << 7), -}; - -struct mlx5_wqe_srq_next_seg { - uint8_t rsvd0[2]; - __be16 next_wqe_index; - uint8_t signature; - uint8_t rsvd1[11]; -}; - -struct mlx5_wqe_data_seg { - __be32 byte_count; - __be32 lkey; - __be64 addr; -}; - -struct mlx5_wqe_ctrl_seg { - __be32 opmod_idx_opcode; - __be32 qpn_ds; - uint8_t signature; - uint8_t rsvd[2]; - uint8_t fm_ce_se; - __be32 imm; -}; - -struct mlx5_wqe_av { - union { - struct { - __be32 qkey; - __be32 reserved; - } qkey; - __be64 dc_key; - } key; - __be32 dqp_dct; - uint8_t stat_rate_sl; - uint8_t fl_mlid; - __be16 rlid; - uint8_t reserved0[4]; - uint8_t rmac[6]; - uint8_t tclass; - uint8_t hop_limit; - __be32 grh_gid_fl; - uint8_t rgid[16]; -}; - -struct mlx5_wqe_datagram_seg { - struct mlx5_wqe_av av; -}; - -struct mlx5_wqe_raddr_seg { - __be64 raddr; - __be32 rkey; - __be32 reserved; -}; - -struct mlx5_wqe_atomic_seg { - __be64 swap_add; - __be64 compare; -}; - -struct mlx5_wqe_inl_data_seg { - uint32_t byte_count; -}; - -struct mlx5_wqe_eth_seg { - __be32 rsvd0; - uint8_t cs_flags; - uint8_t rsvd1; - __be16 mss; - __be32 rsvd2; - __be16 inline_hdr_sz; - uint8_t inline_hdr_start[2]; - uint8_t inline_hdr[16]; -}; - -/* - * Control segment - contains some control information for the current WQE. - * - * Output: - * seg - control segment to be filled - * Input: - * pi - WQEBB number of the first block of this WQE. - * This number should wrap at 0xffff, regardless of - * size of the WQ. - * opcode - Opcode of this WQE. Encodes the type of operation - * to be executed on the QP. - * opmod - Opcode modifier. - * qp_num - QP/SQ number this WQE is posted to. - * fm_ce_se - FM (fence mode), CE (completion and event mode) - * and SE (solicited event). - * ds - WQE size in octowords (16-byte units). DS accounts for all - * the segments in the WQE as summarized in WQE construction. - * signature - WQE signature. - * imm - Immediate data/Invalidation key/UMR mkey. - */ -static MLX5DV_ALWAYS_INLINE -void mlx5dv_set_ctrl_seg(struct mlx5_wqe_ctrl_seg *seg, uint16_t pi, - uint8_t opcode, uint8_t opmod, uint32_t qp_num, - uint8_t fm_ce_se, uint8_t ds, - uint8_t signature, uint32_t imm) -{ - seg->opmod_idx_opcode = htobe32(((uint32_t)opmod << 24) | ((uint32_t)pi << 8) | opcode); - seg->qpn_ds = htobe32((qp_num << 8) | ds); - seg->fm_ce_se = fm_ce_se; - seg->signature = signature; - /* - * The caller should prepare "imm" in advance based on WR opcode. - * For IBV_WR_SEND_WITH_IMM and IBV_WR_RDMA_WRITE_WITH_IMM, - * the "imm" should be assigned as is. - * For the IBV_WR_SEND_WITH_INV, it should be htobe32(imm). - */ - seg->imm = imm; -} - -/* x86 optimized version of mlx5dv_set_ctrl_seg() - * - * This is useful when doing calculations on large data sets - * for parallel calculations. - * - * It doesn't suit for serialized algorithms. - */ -#if defined(__SSE3__) -static MLX5DV_ALWAYS_INLINE -void mlx5dv_x86_set_ctrl_seg(struct mlx5_wqe_ctrl_seg *seg, uint16_t pi, - uint8_t opcode, uint8_t opmod, uint32_t qp_num, - uint8_t fm_ce_se, uint8_t ds, - uint8_t signature, uint32_t imm) -{ - __m128i val = _mm_set_epi32(imm, qp_num, (ds << 16) | pi, - (signature << 24) | (opcode << 16) | (opmod << 8) | fm_ce_se); - __m128i mask = _mm_set_epi8(15, 14, 13, 12, /* immediate */ - 0, /* signal/fence_mode */ -#if CHAR_MIN - -128, -128, /* reserved */ -#else - 0x80, 0x80, /* reserved */ -#endif - 3, /* signature */ - 6, /* data size */ - 8, 9, 10, /* QP num */ - 2, /* opcode */ - 4, 5, /* sw_pi in BE */ - 1 /* opmod */ - ); - *(__m128i *) seg = _mm_shuffle_epi8(val, mask); -} -#endif /* defined(__SSE3__) */ - -/* - * Datagram Segment - contains address information required in order - * to form a datagram message. - * - * Output: - * seg - datagram segment to be filled. - * Input: - * key - Q_key/access key. - * dqp_dct - Destination QP number for UD and DCT for DC. - * ext - Address vector extension. - * stat_rate_sl - Maximum static rate control, SL/ethernet priority. - * fl_mlid - Force loopback and source LID for IB. - * rlid - Remote LID - * rmac - Remote MAC - * tclass - GRH tclass/IPv6 tclass/IPv4 ToS - * hop_limit - GRH hop limit/IPv6 hop limit/IPv4 TTL - * grh_gid_fi - GRH, source GID address and IPv6 flow label. - * rgid - Remote GID/IP address. - */ -static MLX5DV_ALWAYS_INLINE -void mlx5dv_set_dgram_seg(struct mlx5_wqe_datagram_seg *seg, - uint64_t key, uint32_t dqp_dct, - uint8_t ext, uint8_t stat_rate_sl, - uint8_t fl_mlid, uint16_t rlid, - uint8_t *rmac, uint8_t tclass, - uint8_t hop_limit, uint32_t grh_gid_fi, - uint8_t *rgid) -{ - - /* Always put 64 bits, in q_key, the reserved part will be 0 */ - seg->av.key.dc_key = htobe64(key); - seg->av.dqp_dct = htobe32(((uint32_t)ext << 31) | dqp_dct); - seg->av.stat_rate_sl = stat_rate_sl; - seg->av.fl_mlid = fl_mlid; - seg->av.rlid = htobe16(rlid); - memcpy(seg->av.rmac, rmac, 6); - seg->av.tclass = tclass; - seg->av.hop_limit = hop_limit; - seg->av.grh_gid_fl = htobe32(grh_gid_fi); - memcpy(seg->av.rgid, rgid, 16); -} - -/* - * Data Segments - contain pointers and a byte count for the scatter/gather list. - * They can optionally contain data, which will save a memory read access for - * gather Work Requests. - */ -static MLX5DV_ALWAYS_INLINE -void mlx5dv_set_data_seg(struct mlx5_wqe_data_seg *seg, - uint32_t length, uint32_t lkey, - uintptr_t address) -{ - seg->byte_count = htobe32(length); - seg->lkey = htobe32(lkey); - seg->addr = htobe64(address); -} -/* - * x86 optimized version of mlx5dv_set_data_seg() - * - * This is useful when doing calculations on large data sets - * for parallel calculations. - * - * It doesn't suit for serialized algorithms. - */ -#if defined(__SSE3__) -static MLX5DV_ALWAYS_INLINE -void mlx5dv_x86_set_data_seg(struct mlx5_wqe_data_seg *seg, - uint32_t length, uint32_t lkey, - uintptr_t address) -{ - __m128i val = _mm_set_epi32((uint32_t)address, (uint32_t)(address >> 32), lkey, length); - __m128i mask = _mm_set_epi8(12, 13, 14, 15, /* local address low */ - 8, 9, 10, 11, /* local address high */ - 4, 5, 6, 7, /* l_key */ - 0, 1, 2, 3 /* byte count */ - ); - *(__m128i *) seg = _mm_shuffle_epi8(val, mask); -} -#endif /* defined(__SSE3__) */ - -/* - * Eth Segment - contains packet headers and information for stateless L2, L3, L4 offloading. - * - * Output: - * seg - Eth segment to be filled. - * Input: - * cs_flags - l3cs/l3cs_inner/l4cs/l4cs_inner. - * mss - Maximum segment size. For TSO WQEs, the number of bytes - * in the TCP payload to be transmitted in each packet. Must - * be 0 on non TSO WQEs. - * inline_hdr_sz - Length of the inlined packet headers. - * inline_hdr_start - Inlined packet header. - */ -static MLX5DV_ALWAYS_INLINE -void mlx5dv_set_eth_seg(struct mlx5_wqe_eth_seg *seg, uint8_t cs_flags, - uint16_t mss, uint16_t inline_hdr_sz, - uint8_t *inline_hdr_start) -{ - seg->cs_flags = cs_flags; - seg->mss = htobe16(mss); - seg->inline_hdr_sz = htobe16(inline_hdr_sz); - memcpy(seg->inline_hdr_start, inline_hdr_start, inline_hdr_sz); -} - -enum mlx5dv_set_ctx_attr_type { - MLX5DV_CTX_ATTR_BUF_ALLOCATORS = 1, -}; - -struct mlx5dv_ctx_allocators { - void *(*alloc)(size_t size, void *priv_data); - void (*free)(void *ptr, void *priv_data); - void *data; -}; - -/* - * Generic context attributes set API - * - * Returns 0 on success, or the value of errno on failure - * (which indicates the failure reason). - */ -int mlx5dv_set_context_attr(struct ibv_context *context, - enum mlx5dv_set_ctx_attr_type type, void *attr); - -#endif /* _MLX5DV_H_ */ diff --git a/usr/rdma-core/providers/mlx5/qp.c b/usr/rdma-core/providers/mlx5/qp.c deleted file mode 100644 index d5e677f2a..000000000 --- a/usr/rdma-core/providers/mlx5/qp.c +++ /dev/null @@ -1,1322 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "mlx5.h" -#include "wqe.h" - -#define MLX5_ATOMIC_SIZE 8 - -static const uint32_t mlx5_ib_opcode[] = { - [IBV_WR_SEND] = MLX5_OPCODE_SEND, - [IBV_WR_SEND_WITH_INV] = MLX5_OPCODE_SEND_INVAL, - [IBV_WR_SEND_WITH_IMM] = MLX5_OPCODE_SEND_IMM, - [IBV_WR_RDMA_WRITE] = MLX5_OPCODE_RDMA_WRITE, - [IBV_WR_RDMA_WRITE_WITH_IMM] = MLX5_OPCODE_RDMA_WRITE_IMM, - [IBV_WR_RDMA_READ] = MLX5_OPCODE_RDMA_READ, - [IBV_WR_ATOMIC_CMP_AND_SWP] = MLX5_OPCODE_ATOMIC_CS, - [IBV_WR_ATOMIC_FETCH_AND_ADD] = MLX5_OPCODE_ATOMIC_FA, - [IBV_WR_BIND_MW] = MLX5_OPCODE_UMR, - [IBV_WR_LOCAL_INV] = MLX5_OPCODE_UMR, - [IBV_WR_TSO] = MLX5_OPCODE_TSO, -}; - -static void *get_recv_wqe(struct mlx5_qp *qp, int n) -{ - return qp->buf.buf + qp->rq.offset + (n << qp->rq.wqe_shift); -} - -static void *get_wq_recv_wqe(struct mlx5_rwq *rwq, int n) -{ - return rwq->pbuff + (n << rwq->rq.wqe_shift); -} - -static int copy_to_scat(struct mlx5_wqe_data_seg *scat, void *buf, int *size, - int max) -{ - int copy; - int i; - - if (unlikely(!(*size))) - return IBV_WC_SUCCESS; - - for (i = 0; i < max; ++i) { - copy = min_t(long, *size, be32toh(scat->byte_count)); - memcpy((void *)(unsigned long)be64toh(scat->addr), buf, copy); - *size -= copy; - if (*size == 0) - return IBV_WC_SUCCESS; - - buf += copy; - ++scat; - } - return IBV_WC_LOC_LEN_ERR; -} - -int mlx5_copy_to_recv_wqe(struct mlx5_qp *qp, int idx, void *buf, int size) -{ - struct mlx5_wqe_data_seg *scat; - int max = 1 << (qp->rq.wqe_shift - 4); - - scat = get_recv_wqe(qp, idx); - if (unlikely(qp->wq_sig)) - ++scat; - - return copy_to_scat(scat, buf, &size, max); -} - -int mlx5_copy_to_send_wqe(struct mlx5_qp *qp, int idx, void *buf, int size) -{ - struct mlx5_wqe_ctrl_seg *ctrl; - struct mlx5_wqe_data_seg *scat; - void *p; - int max; - - idx &= (qp->sq.wqe_cnt - 1); - ctrl = mlx5_get_send_wqe(qp, idx); - if (qp->ibv_qp->qp_type != IBV_QPT_RC) { - fprintf(stderr, "scatter to CQE is supported only for RC QPs\n"); - return IBV_WC_GENERAL_ERR; - } - p = ctrl + 1; - - switch (be32toh(ctrl->opmod_idx_opcode) & 0xff) { - case MLX5_OPCODE_RDMA_READ: - p = p + sizeof(struct mlx5_wqe_raddr_seg); - break; - - case MLX5_OPCODE_ATOMIC_CS: - case MLX5_OPCODE_ATOMIC_FA: - p = p + sizeof(struct mlx5_wqe_raddr_seg) + - sizeof(struct mlx5_wqe_atomic_seg); - break; - - default: - fprintf(stderr, "scatter to CQE for opcode %d\n", - be32toh(ctrl->opmod_idx_opcode) & 0xff); - return IBV_WC_REM_INV_REQ_ERR; - } - - scat = p; - max = (be32toh(ctrl->qpn_ds) & 0x3F) - (((void *)scat - (void *)ctrl) >> 4); - if (unlikely((void *)(scat + max) > qp->sq.qend)) { - int tmp = ((void *)qp->sq.qend - (void *)scat) >> 4; - int orig_size = size; - - if (copy_to_scat(scat, buf, &size, tmp) == IBV_WC_SUCCESS) - return IBV_WC_SUCCESS; - max = max - tmp; - buf += orig_size - size; - scat = mlx5_get_send_wqe(qp, 0); - } - - return copy_to_scat(scat, buf, &size, max); -} - -void *mlx5_get_send_wqe(struct mlx5_qp *qp, int n) -{ - return qp->sq_start + (n << MLX5_SEND_WQE_SHIFT); -} - -void mlx5_init_rwq_indices(struct mlx5_rwq *rwq) -{ - rwq->rq.head = 0; - rwq->rq.tail = 0; -} - -void mlx5_init_qp_indices(struct mlx5_qp *qp) -{ - qp->sq.head = 0; - qp->sq.tail = 0; - qp->rq.head = 0; - qp->rq.tail = 0; - qp->sq.cur_post = 0; -} - -static int mlx5_wq_overflow(struct mlx5_wq *wq, int nreq, struct mlx5_cq *cq) -{ - unsigned cur; - - cur = wq->head - wq->tail; - if (cur + nreq < wq->max_post) - return 0; - - mlx5_spin_lock(&cq->lock); - cur = wq->head - wq->tail; - mlx5_spin_unlock(&cq->lock); - - return cur + nreq >= wq->max_post; -} - -static inline void set_raddr_seg(struct mlx5_wqe_raddr_seg *rseg, - uint64_t remote_addr, uint32_t rkey) -{ - rseg->raddr = htobe64(remote_addr); - rseg->rkey = htobe32(rkey); - rseg->reserved = 0; -} - -static void set_atomic_seg(struct mlx5_wqe_atomic_seg *aseg, - enum ibv_wr_opcode opcode, - uint64_t swap, - uint64_t compare_add) -{ - if (opcode == IBV_WR_ATOMIC_CMP_AND_SWP) { - aseg->swap_add = htobe64(swap); - aseg->compare = htobe64(compare_add); - } else { - aseg->swap_add = htobe64(compare_add); - } -} - -static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg, - struct ibv_send_wr *wr) -{ - memcpy(&dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof dseg->av); - dseg->av.dqp_dct = htobe32(wr->wr.ud.remote_qpn | MLX5_EXTENDED_UD_AV); - dseg->av.key.qkey.qkey = htobe32(wr->wr.ud.remote_qkey); -} - -static void set_data_ptr_seg(struct mlx5_wqe_data_seg *dseg, struct ibv_sge *sg, - int offset) -{ - dseg->byte_count = htobe32(sg->length - offset); - dseg->lkey = htobe32(sg->lkey); - dseg->addr = htobe64(sg->addr + offset); -} - -static void set_data_ptr_seg_atomic(struct mlx5_wqe_data_seg *dseg, - struct ibv_sge *sg) -{ - dseg->byte_count = htobe32(MLX5_ATOMIC_SIZE); - dseg->lkey = htobe32(sg->lkey); - dseg->addr = htobe64(sg->addr); -} - -/* - * Avoid using memcpy() to copy to BlueFlame page, since memcpy() - * implementations may use move-string-buffer assembler instructions, - * which do not guarantee order of copying. - */ -static void mlx5_bf_copy(uint64_t *dst, const uint64_t *src, unsigned bytecnt, - struct mlx5_qp *qp) -{ - do { - mmio_memcpy_x64(dst, src, 64); - bytecnt -= 64; - dst += 8; - src += 8; - if (unlikely(src == qp->sq.qend)) - src = qp->sq_start; - } while (bytecnt > 0); -} - -static __be32 send_ieth(struct ibv_send_wr *wr) -{ - switch (wr->opcode) { - case IBV_WR_SEND_WITH_IMM: - case IBV_WR_RDMA_WRITE_WITH_IMM: - return wr->imm_data; - case IBV_WR_SEND_WITH_INV: - return htobe32(wr->invalidate_rkey); - default: - return 0; - } -} - -static int set_data_inl_seg(struct mlx5_qp *qp, struct ibv_send_wr *wr, - void *wqe, int *sz, - struct mlx5_sg_copy_ptr *sg_copy_ptr) -{ - struct mlx5_wqe_inline_seg *seg; - void *addr; - int len; - int i; - int inl = 0; - void *qend = qp->sq.qend; - int copy; - int offset = sg_copy_ptr->offset; - - seg = wqe; - wqe += sizeof *seg; - for (i = sg_copy_ptr->index; i < wr->num_sge; ++i) { - addr = (void *) (unsigned long)(wr->sg_list[i].addr + offset); - len = wr->sg_list[i].length - offset; - inl += len; - offset = 0; - - if (unlikely(inl > qp->max_inline_data)) - return ENOMEM; - - if (unlikely(wqe + len > qend)) { - copy = qend - wqe; - memcpy(wqe, addr, copy); - addr += copy; - len -= copy; - wqe = mlx5_get_send_wqe(qp, 0); - } - memcpy(wqe, addr, len); - wqe += len; - } - - if (likely(inl)) { - seg->byte_count = htobe32(inl | MLX5_INLINE_SEG); - *sz = align(inl + sizeof seg->byte_count, 16) / 16; - } else - *sz = 0; - - return 0; -} - -static uint8_t wq_sig(struct mlx5_wqe_ctrl_seg *ctrl) -{ - return calc_sig(ctrl, be32toh(ctrl->qpn_ds)); -} - -#ifdef MLX5_DEBUG -static void dump_wqe(FILE *fp, int idx, int size_16, struct mlx5_qp *qp) -{ - uint32_t *uninitialized_var(p); - int i, j; - int tidx = idx; - - fprintf(fp, "dump wqe at %p\n", mlx5_get_send_wqe(qp, tidx)); - for (i = 0, j = 0; i < size_16 * 4; i += 4, j += 4) { - if ((i & 0xf) == 0) { - void *buf = mlx5_get_send_wqe(qp, tidx); - tidx = (tidx + 1) & (qp->sq.wqe_cnt - 1); - p = buf; - j = 0; - } - fprintf(fp, "%08x %08x %08x %08x\n", be32toh(p[j]), be32toh(p[j + 1]), - be32toh(p[j + 2]), be32toh(p[j + 3])); - } -} -#endif /* MLX5_DEBUG */ - - -void *mlx5_get_atomic_laddr(struct mlx5_qp *qp, uint16_t idx, int *byte_count) -{ - struct mlx5_wqe_data_seg *dpseg; - void *addr; - - dpseg = mlx5_get_send_wqe(qp, idx) + sizeof(struct mlx5_wqe_ctrl_seg) + - sizeof(struct mlx5_wqe_raddr_seg) + - sizeof(struct mlx5_wqe_atomic_seg); - addr = (void *)(unsigned long)be64toh(dpseg->addr); - - /* - * Currently byte count is always 8 bytes. Fix this when - * we support variable size of atomics - */ - *byte_count = 8; - return addr; -} - -static inline int copy_eth_inline_headers(struct ibv_qp *ibqp, - struct ibv_send_wr *wr, - struct mlx5_wqe_eth_seg *eseg, - struct mlx5_sg_copy_ptr *sg_copy_ptr) -{ - uint32_t inl_hdr_size = MLX5_ETH_L2_INLINE_HEADER_SIZE; - int inl_hdr_copy_size = 0; - int j = 0; - FILE *fp = to_mctx(ibqp->context)->dbg_fp; - - if (unlikely(wr->num_sge < 1)) { - mlx5_dbg(fp, MLX5_DBG_QP_SEND, "illegal num_sge: %d, minimum is 1\n", - wr->num_sge); - return EINVAL; - } - - if (likely(wr->sg_list[0].length >= MLX5_ETH_L2_INLINE_HEADER_SIZE)) { - inl_hdr_copy_size = MLX5_ETH_L2_INLINE_HEADER_SIZE; - memcpy(eseg->inline_hdr_start, - (void *)(uintptr_t)wr->sg_list[0].addr, - inl_hdr_copy_size); - } else { - for (j = 0; j < wr->num_sge && inl_hdr_size > 0; ++j) { - inl_hdr_copy_size = min(wr->sg_list[j].length, - inl_hdr_size); - memcpy(eseg->inline_hdr_start + - (MLX5_ETH_L2_INLINE_HEADER_SIZE - inl_hdr_size), - (void *)(uintptr_t)wr->sg_list[j].addr, - inl_hdr_copy_size); - inl_hdr_size -= inl_hdr_copy_size; - } - if (unlikely(inl_hdr_size)) { - mlx5_dbg(fp, MLX5_DBG_QP_SEND, "Ethernet headers < 16 bytes\n"); - return EINVAL; - } - --j; - } - - - eseg->inline_hdr_sz = htobe16(MLX5_ETH_L2_INLINE_HEADER_SIZE); - - /* If we copied all the sge into the inline-headers, then we need to - * start copying from the next sge into the data-segment. - */ - if (unlikely(wr->sg_list[j].length == inl_hdr_copy_size)) { - ++j; - inl_hdr_copy_size = 0; - } - - sg_copy_ptr->index = j; - sg_copy_ptr->offset = inl_hdr_copy_size; - - return 0; -} - -#define ALIGN(x, log_a) ((((x) + (1 << (log_a)) - 1)) & ~((1 << (log_a)) - 1)) - -static inline __be16 get_klm_octo(int nentries) -{ - return htobe16(ALIGN(nentries, 3) / 2); -} - -static void set_umr_data_seg(struct mlx5_qp *qp, enum ibv_mw_type type, - int32_t rkey, struct ibv_mw_bind_info *bind_info, - uint32_t qpn, void **seg, int *size) -{ - union { - struct mlx5_wqe_umr_klm_seg klm; - uint8_t reserved[64]; - } *data = *seg; - - data->klm.byte_count = htobe32(bind_info->length); - data->klm.mkey = htobe32(bind_info->mr->lkey); - data->klm.address = htobe64(bind_info->addr); - - memset(&data->klm + 1, 0, sizeof(data->reserved) - - sizeof(data->klm)); - - *seg += sizeof(*data); - *size += (sizeof(*data) / 16); -} - -static void set_umr_mkey_seg(struct mlx5_qp *qp, enum ibv_mw_type type, - int32_t rkey, struct ibv_mw_bind_info *bind_info, - uint32_t qpn, void **seg, int *size) -{ - struct mlx5_wqe_mkey_context_seg *mkey = *seg; - - mkey->qpn_mkey = htobe32((rkey & 0xFF) | - ((type == IBV_MW_TYPE_1 || !bind_info->length) ? - 0xFFFFFF00 : qpn << 8)); - if (bind_info->length) { - /* Local read is set in kernel */ - mkey->access_flags = 0; - mkey->free = 0; - if (bind_info->mw_access_flags & IBV_ACCESS_LOCAL_WRITE) - mkey->access_flags |= - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_LOCAL_WRITE; - if (bind_info->mw_access_flags & IBV_ACCESS_REMOTE_WRITE) - mkey->access_flags |= - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_REMOTE_WRITE; - if (bind_info->mw_access_flags & IBV_ACCESS_REMOTE_READ) - mkey->access_flags |= - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_REMOTE_READ; - if (bind_info->mw_access_flags & IBV_ACCESS_REMOTE_ATOMIC) - mkey->access_flags |= - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_ATOMIC; - if (bind_info->mw_access_flags & IBV_ACCESS_ZERO_BASED) - mkey->start_addr = 0; - else - mkey->start_addr = htobe64(bind_info->addr); - mkey->len = htobe64(bind_info->length); - } else { - mkey->free = MLX5_WQE_MKEY_CONTEXT_FREE; - } - - *seg += sizeof(struct mlx5_wqe_mkey_context_seg); - *size += (sizeof(struct mlx5_wqe_mkey_context_seg) / 16); -} - -static inline void set_umr_control_seg(struct mlx5_qp *qp, enum ibv_mw_type type, - int32_t rkey, struct ibv_mw_bind_info *bind_info, - uint32_t qpn, void **seg, int *size) -{ - struct mlx5_wqe_umr_ctrl_seg *ctrl = *seg; - - ctrl->flags = MLX5_WQE_UMR_CTRL_FLAG_TRNSLATION_OFFSET | - MLX5_WQE_UMR_CTRL_FLAG_INLINE; - ctrl->mkey_mask = htobe64(MLX5_WQE_UMR_CTRL_MKEY_MASK_FREE | - MLX5_WQE_UMR_CTRL_MKEY_MASK_MKEY); - ctrl->translation_offset = 0; - memset(ctrl->rsvd0, 0, sizeof(ctrl->rsvd0)); - memset(ctrl->rsvd1, 0, sizeof(ctrl->rsvd1)); - - if (type == IBV_MW_TYPE_2) - ctrl->mkey_mask |= htobe64(MLX5_WQE_UMR_CTRL_MKEY_MASK_QPN); - - if (bind_info->length) { - ctrl->klm_octowords = get_klm_octo(1); - if (type == IBV_MW_TYPE_2) - ctrl->flags |= MLX5_WQE_UMR_CTRL_FLAG_CHECK_FREE; - ctrl->mkey_mask |= htobe64(MLX5_WQE_UMR_CTRL_MKEY_MASK_LEN | - MLX5_WQE_UMR_CTRL_MKEY_MASK_START_ADDR | - MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_LOCAL_WRITE | - MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_REMOTE_READ | - MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_REMOTE_WRITE | - MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_ATOMIC); - } else { - ctrl->klm_octowords = get_klm_octo(0); - if (type == IBV_MW_TYPE_2) - ctrl->flags |= MLX5_WQE_UMR_CTRL_FLAG_CHECK_QPN; - } - - *seg += sizeof(struct mlx5_wqe_umr_ctrl_seg); - *size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16; -} - -static inline int set_bind_wr(struct mlx5_qp *qp, enum ibv_mw_type type, - int32_t rkey, struct ibv_mw_bind_info *bind_info, - uint32_t qpn, void **seg, int *size) -{ - void *qend = qp->sq.qend; - -#ifdef MW_DEBUG - if (bind_info->mw_access_flags & - ~(IBV_ACCESS_REMOTE_ATOMIC | IBV_ACCESS_REMOTE_READ | - IBV_ACCESS_REMOTE_WRITE)) - return EINVAL; - - if (bind_info->mr && - (bind_info->mr->addr > (void *)bind_info->addr || - bind_info->mr->addr + bind_info->mr->length < - (void *)bind_info->addr + bind_info->length || - !(to_mmr(bind_info->mr)->alloc_flags & IBV_ACCESS_MW_BIND) || - (bind_info->mw_access_flags & - (IBV_ACCESS_REMOTE_ATOMIC | IBV_ACCESS_REMOTE_WRITE) && - !(to_mmr(bind_info->mr)->alloc_flags & IBV_ACCESS_LOCAL_WRITE)))) - return EINVAL; - -#endif - - /* check that len > 2GB because KLM support only 2GB */ - if (bind_info->length > 1UL << 31) - return EOPNOTSUPP; - - set_umr_control_seg(qp, type, rkey, bind_info, qpn, seg, size); - if (unlikely((*seg == qend))) - *seg = mlx5_get_send_wqe(qp, 0); - - set_umr_mkey_seg(qp, type, rkey, bind_info, qpn, seg, size); - if (!bind_info->length) - return 0; - - if (unlikely((seg == qend))) - *seg = mlx5_get_send_wqe(qp, 0); - - set_umr_data_seg(qp, type, rkey, bind_info, qpn, seg, size); - return 0; -} - -/* Copy tso header to eth segment with considering padding and WQE - * wrap around in WQ buffer. - */ -static inline int set_tso_eth_seg(void **seg, struct ibv_send_wr *wr, - void *qend, struct mlx5_qp *qp, int *size) -{ - struct mlx5_wqe_eth_seg *eseg = *seg; - int size_of_inl_hdr_start = sizeof(eseg->inline_hdr_start); - uint64_t left, left_len, copy_sz; - void *pdata = wr->tso.hdr; - FILE *fp = to_mctx(qp->ibv_qp->context)->dbg_fp; - - if (unlikely(wr->tso.hdr_sz < MLX5_ETH_L2_MIN_HEADER_SIZE || - wr->tso.hdr_sz > qp->max_tso_header)) { - mlx5_dbg(fp, MLX5_DBG_QP_SEND, - "TSO header size should be at least %d and at most %d\n", - MLX5_ETH_L2_MIN_HEADER_SIZE, - qp->max_tso_header); - return EINVAL; - } - - left = wr->tso.hdr_sz; - eseg->mss = htobe16(wr->tso.mss); - eseg->inline_hdr_sz = htobe16(wr->tso.hdr_sz); - - /* Check if there is space till the end of queue, if yes, - * copy all in one shot, otherwise copy till the end of queue, - * rollback and then copy the left - */ - left_len = qend - (void *)eseg->inline_hdr_start; - copy_sz = min(left_len, left); - - memcpy(eseg->inline_hdr_start, pdata, copy_sz); - - /* The -1 is because there are already 16 bytes included in - * eseg->inline_hdr[16] - */ - *seg += align(copy_sz - size_of_inl_hdr_start, 16) - 16; - *size += align(copy_sz - size_of_inl_hdr_start, 16) / 16 - 1; - - /* The last wqe in the queue */ - if (unlikely(copy_sz < left)) { - *seg = mlx5_get_send_wqe(qp, 0); - left -= copy_sz; - pdata += copy_sz; - memcpy(*seg, pdata, left); - *seg += align(left, 16); - *size += align(left, 16) / 16; - } - - return 0; -} - -static inline int mlx5_post_send_underlay(struct mlx5_qp *qp, struct ibv_send_wr *wr, - void **pseg, int *total_size, - struct mlx5_sg_copy_ptr *sg_copy_ptr) -{ - struct mlx5_wqe_eth_seg *eseg; - int inl_hdr_copy_size; - void *seg = *pseg; - int size = 0; - - if (unlikely(wr->opcode == IBV_WR_SEND_WITH_IMM)) - return EINVAL; - - memset(seg, 0, sizeof(struct mlx5_wqe_eth_pad)); - size += sizeof(struct mlx5_wqe_eth_pad); - seg += sizeof(struct mlx5_wqe_eth_pad); - eseg = seg; - *((uint64_t *)eseg) = 0; - eseg->rsvd2 = 0; - - if (wr->send_flags & IBV_SEND_IP_CSUM) { - if (!(qp->qp_cap_cache & MLX5_CSUM_SUPPORT_UNDERLAY_UD)) - return EINVAL; - - eseg->cs_flags |= MLX5_ETH_WQE_L3_CSUM | MLX5_ETH_WQE_L4_CSUM; - } - - if (likely(wr->sg_list[0].length >= MLX5_SOURCE_QPN_INLINE_MAX_HEADER_SIZE)) - /* Copying the minimum required data unless inline mode is set */ - inl_hdr_copy_size = (wr->send_flags & IBV_SEND_INLINE) ? - MLX5_SOURCE_QPN_INLINE_MAX_HEADER_SIZE : - MLX5_IPOIB_INLINE_MIN_HEADER_SIZE; - else { - inl_hdr_copy_size = MLX5_IPOIB_INLINE_MIN_HEADER_SIZE; - /* We expect at least 4 bytes as part of first entry to hold the IPoIB header */ - if (unlikely(wr->sg_list[0].length < inl_hdr_copy_size)) - return EINVAL; - } - - memcpy(eseg->inline_hdr_start, (void *)(uintptr_t)wr->sg_list[0].addr, - inl_hdr_copy_size); - eseg->inline_hdr_sz = htobe16(inl_hdr_copy_size); - size += sizeof(struct mlx5_wqe_eth_seg); - seg += sizeof(struct mlx5_wqe_eth_seg); - - /* If we copied all the sge into the inline-headers, then we need to - * start copying from the next sge into the data-segment. - */ - if (unlikely(wr->sg_list[0].length == inl_hdr_copy_size)) - sg_copy_ptr->index++; - else - sg_copy_ptr->offset = inl_hdr_copy_size; - - *pseg = seg; - *total_size += (size / 16); - return 0; -} - -static inline int _mlx5_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - struct mlx5_context *ctx; - struct mlx5_qp *qp = to_mqp(ibqp); - void *seg; - struct mlx5_wqe_eth_seg *eseg; - struct mlx5_wqe_ctrl_seg *ctrl = NULL; - struct mlx5_wqe_data_seg *dpseg; - struct mlx5_sg_copy_ptr sg_copy_ptr = {.index = 0, .offset = 0}; - int nreq; - int inl = 0; - int err = 0; - int size = 0; - int i; - unsigned idx; - uint8_t opmod = 0; - struct mlx5_bf *bf = qp->bf; - void *qend = qp->sq.qend; - uint32_t mlx5_opcode; - struct mlx5_wqe_xrc_seg *xrc; - uint8_t fence; - uint8_t next_fence; - uint32_t max_tso = 0; - FILE *fp = to_mctx(ibqp->context)->dbg_fp; /* The compiler ignores in non-debug mode */ - - mlx5_spin_lock(&qp->sq.lock); - - next_fence = qp->fm_cache; - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (unlikely(wr->opcode < 0 || - wr->opcode >= sizeof mlx5_ib_opcode / sizeof mlx5_ib_opcode[0])) { - mlx5_dbg(fp, MLX5_DBG_QP_SEND, "bad opcode %d\n", wr->opcode); - err = EINVAL; - *bad_wr = wr; - goto out; - } - - if (unlikely(mlx5_wq_overflow(&qp->sq, nreq, - to_mcq(qp->ibv_qp->send_cq)))) { - mlx5_dbg(fp, MLX5_DBG_QP_SEND, "work queue overflow\n"); - err = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (unlikely(wr->num_sge > qp->sq.max_gs)) { - mlx5_dbg(fp, MLX5_DBG_QP_SEND, "max gs exceeded %d (max = %d)\n", - wr->num_sge, qp->sq.max_gs); - err = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (wr->send_flags & IBV_SEND_FENCE) - fence = MLX5_WQE_CTRL_FENCE; - else - fence = next_fence; - next_fence = 0; - idx = qp->sq.cur_post & (qp->sq.wqe_cnt - 1); - ctrl = seg = mlx5_get_send_wqe(qp, idx); - *(uint32_t *)(seg + 8) = 0; - ctrl->imm = send_ieth(wr); - ctrl->fm_ce_se = qp->sq_signal_bits | fence | - (wr->send_flags & IBV_SEND_SIGNALED ? - MLX5_WQE_CTRL_CQ_UPDATE : 0) | - (wr->send_flags & IBV_SEND_SOLICITED ? - MLX5_WQE_CTRL_SOLICITED : 0); - - seg += sizeof *ctrl; - size = sizeof *ctrl / 16; - - switch (ibqp->qp_type) { - case IBV_QPT_XRC_SEND: - if (unlikely(wr->opcode != IBV_WR_BIND_MW && - wr->opcode != IBV_WR_LOCAL_INV)) { - xrc = seg; - xrc->xrc_srqn = htobe32(wr->qp_type.xrc.remote_srqn); - seg += sizeof(*xrc); - size += sizeof(*xrc) / 16; - } - /* fall through */ - case IBV_QPT_RC: - switch (wr->opcode) { - case IBV_WR_RDMA_READ: - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - set_raddr_seg(seg, wr->wr.rdma.remote_addr, - wr->wr.rdma.rkey); - seg += sizeof(struct mlx5_wqe_raddr_seg); - size += sizeof(struct mlx5_wqe_raddr_seg) / 16; - break; - - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - if (unlikely(!qp->atomics_enabled)) { - mlx5_dbg(fp, MLX5_DBG_QP_SEND, "atomic operations are not supported\n"); - err = ENOSYS; - *bad_wr = wr; - goto out; - } - set_raddr_seg(seg, wr->wr.atomic.remote_addr, - wr->wr.atomic.rkey); - seg += sizeof(struct mlx5_wqe_raddr_seg); - - set_atomic_seg(seg, wr->opcode, - wr->wr.atomic.swap, - wr->wr.atomic.compare_add); - seg += sizeof(struct mlx5_wqe_atomic_seg); - - size += (sizeof(struct mlx5_wqe_raddr_seg) + - sizeof(struct mlx5_wqe_atomic_seg)) / 16; - break; - - case IBV_WR_BIND_MW: - next_fence = MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE; - ctrl->imm = htobe32(wr->bind_mw.mw->rkey); - err = set_bind_wr(qp, wr->bind_mw.mw->type, - wr->bind_mw.rkey, - &wr->bind_mw.bind_info, - ibqp->qp_num, &seg, &size); - if (err) { - *bad_wr = wr; - goto out; - } - - qp->sq.wr_data[idx] = IBV_WC_BIND_MW; - break; - case IBV_WR_LOCAL_INV: { - struct ibv_mw_bind_info bind_info = {}; - - next_fence = MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE; - ctrl->imm = htobe32(wr->invalidate_rkey); - err = set_bind_wr(qp, IBV_MW_TYPE_2, 0, - &bind_info, ibqp->qp_num, - &seg, &size); - if (err) { - *bad_wr = wr; - goto out; - } - - qp->sq.wr_data[idx] = IBV_WC_LOCAL_INV; - break; - } - - default: - break; - } - break; - - case IBV_QPT_UC: - switch (wr->opcode) { - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - set_raddr_seg(seg, wr->wr.rdma.remote_addr, - wr->wr.rdma.rkey); - seg += sizeof(struct mlx5_wqe_raddr_seg); - size += sizeof(struct mlx5_wqe_raddr_seg) / 16; - break; - case IBV_WR_BIND_MW: - next_fence = MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE; - ctrl->imm = htobe32(wr->bind_mw.mw->rkey); - err = set_bind_wr(qp, wr->bind_mw.mw->type, - wr->bind_mw.rkey, - &wr->bind_mw.bind_info, - ibqp->qp_num, &seg, &size); - if (err) { - *bad_wr = wr; - goto out; - } - - qp->sq.wr_data[idx] = IBV_WC_BIND_MW; - break; - case IBV_WR_LOCAL_INV: { - struct ibv_mw_bind_info bind_info = {}; - - next_fence = MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE; - ctrl->imm = htobe32(wr->invalidate_rkey); - err = set_bind_wr(qp, IBV_MW_TYPE_2, 0, - &bind_info, ibqp->qp_num, - &seg, &size); - if (err) { - *bad_wr = wr; - goto out; - } - - qp->sq.wr_data[idx] = IBV_WC_LOCAL_INV; - break; - } - - default: - break; - } - break; - - case IBV_QPT_UD: - set_datagram_seg(seg, wr); - seg += sizeof(struct mlx5_wqe_datagram_seg); - size += sizeof(struct mlx5_wqe_datagram_seg) / 16; - if (unlikely((seg == qend))) - seg = mlx5_get_send_wqe(qp, 0); - - if (unlikely(qp->flags & MLX5_QP_FLAGS_USE_UNDERLAY)) { - err = mlx5_post_send_underlay(qp, wr, &seg, &size, &sg_copy_ptr); - if (unlikely(err)) { - *bad_wr = wr; - goto out; - } - } - break; - - case IBV_QPT_RAW_PACKET: - memset(seg, 0, sizeof(struct mlx5_wqe_eth_seg)); - eseg = seg; - - if (wr->send_flags & IBV_SEND_IP_CSUM) { - if (!(qp->qp_cap_cache & MLX5_CSUM_SUPPORT_RAW_OVER_ETH)) { - err = EINVAL; - *bad_wr = wr; - goto out; - } - - eseg->cs_flags |= MLX5_ETH_WQE_L3_CSUM | MLX5_ETH_WQE_L4_CSUM; - } - - if (wr->opcode == IBV_WR_TSO) { - max_tso = qp->max_tso; - err = set_tso_eth_seg(&seg, wr, qend, qp, &size); - if (unlikely(err)) { - *bad_wr = wr; - goto out; - } - } else { - err = copy_eth_inline_headers(ibqp, wr, seg, &sg_copy_ptr); - if (unlikely(err)) { - *bad_wr = wr; - mlx5_dbg(fp, MLX5_DBG_QP_SEND, - "copy_eth_inline_headers failed, err: %d\n", - err); - goto out; - } - } - - seg += sizeof(struct mlx5_wqe_eth_seg); - size += sizeof(struct mlx5_wqe_eth_seg) / 16; - break; - - default: - break; - } - - if (wr->send_flags & IBV_SEND_INLINE && wr->num_sge) { - int uninitialized_var(sz); - - err = set_data_inl_seg(qp, wr, seg, &sz, &sg_copy_ptr); - if (unlikely(err)) { - *bad_wr = wr; - mlx5_dbg(fp, MLX5_DBG_QP_SEND, - "inline layout failed, err %d\n", err); - goto out; - } - inl = 1; - size += sz; - } else { - dpseg = seg; - for (i = sg_copy_ptr.index; i < wr->num_sge; ++i) { - if (unlikely(dpseg == qend)) { - seg = mlx5_get_send_wqe(qp, 0); - dpseg = seg; - } - if (likely(wr->sg_list[i].length)) { - if (unlikely(wr->opcode == - IBV_WR_ATOMIC_CMP_AND_SWP || - wr->opcode == - IBV_WR_ATOMIC_FETCH_AND_ADD)) - set_data_ptr_seg_atomic(dpseg, wr->sg_list + i); - else { - if (unlikely(wr->opcode == IBV_WR_TSO)) { - if (max_tso < wr->sg_list[i].length) { - err = EINVAL; - *bad_wr = wr; - goto out; - } - max_tso -= wr->sg_list[i].length; - } - set_data_ptr_seg(dpseg, wr->sg_list + i, - sg_copy_ptr.offset); - } - sg_copy_ptr.offset = 0; - ++dpseg; - size += sizeof(struct mlx5_wqe_data_seg) / 16; - } - } - } - - mlx5_opcode = mlx5_ib_opcode[wr->opcode]; - ctrl->opmod_idx_opcode = htobe32(((qp->sq.cur_post & 0xffff) << 8) | - mlx5_opcode | - (opmod << 24)); - ctrl->qpn_ds = htobe32(size | (ibqp->qp_num << 8)); - - if (unlikely(qp->wq_sig)) - ctrl->signature = wq_sig(ctrl); - - qp->sq.wrid[idx] = wr->wr_id; - qp->sq.wqe_head[idx] = qp->sq.head + nreq; - qp->sq.cur_post += DIV_ROUND_UP(size * 16, MLX5_SEND_WQE_BB); - -#ifdef MLX5_DEBUG - if (mlx5_debug_mask & MLX5_DBG_QP_SEND) - dump_wqe(to_mctx(ibqp->context)->dbg_fp, idx, size, qp); -#endif - } - -out: - if (likely(nreq)) { - qp->sq.head += nreq; - qp->fm_cache = next_fence; - - /* - * Make sure that descriptors are written before - * updating doorbell record and ringing the doorbell - */ - udma_to_device_barrier(); - qp->db[MLX5_SND_DBR] = htobe32(qp->sq.cur_post & 0xffff); - - /* Make sure that the doorbell write happens before the memcpy - * to WC memory below */ - ctx = to_mctx(ibqp->context); - if (bf->need_lock) - mmio_wc_spinlock(&bf->lock.lock); - else - mmio_wc_start(); - - if (!ctx->shut_up_bf && nreq == 1 && bf->uuarn && - (inl || ctx->prefer_bf) && size > 1 && - size <= bf->buf_size / 16) - mlx5_bf_copy(bf->reg + bf->offset, (uint64_t *)ctrl, - align(size * 16, 64), qp); - else - mmio_write64_be(bf->reg + bf->offset, *(__be64 *)ctrl); - - /* - * use mmio_flush_writes() to ensure write combining buffers are flushed out - * of the running CPU. This must be carried inside the spinlock. - * Otherwise, there is a potential race. In the race, CPU A - * writes doorbell 1, which is waiting in the WC buffer. CPU B - * writes doorbell 2, and it's write is flushed earlier. Since - * the mmio_flush_writes is CPU local, this will result in the HCA seeing - * doorbell 2, followed by doorbell 1. - * Flush before toggling bf_offset to be latency oriented. - */ - mmio_flush_writes(); - bf->offset ^= bf->buf_size; - if (bf->need_lock) - mlx5_spin_unlock(&bf->lock); - } - - mlx5_spin_unlock(&qp->sq.lock); - - return err; -} - -int mlx5_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ -#ifdef MW_DEBUG - if (wr->opcode == IBV_WR_BIND_MW) { - if (wr->bind_mw.mw->type == IBV_MW_TYPE_1) - return EINVAL; - - if (!wr->bind_mw.bind_info.mr || - !wr->bind_mw.bind_info.addr || - !wr->bind_mw.bind_info.length) - return EINVAL; - - if (wr->bind_mw.bind_info.mr->pd != wr->bind_mw.mw->pd) - return EINVAL; - } -#endif - - return _mlx5_post_send(ibqp, wr, bad_wr); -} - -int mlx5_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw, - struct ibv_mw_bind *mw_bind) -{ - struct ibv_mw_bind_info *bind_info = &mw_bind->bind_info; - struct ibv_send_wr wr = {}; - struct ibv_send_wr *bad_wr = NULL; - int ret; - - if (!bind_info->mr && (bind_info->addr || bind_info->length)) { - errno = EINVAL; - return errno; - } - - if (bind_info->mw_access_flags & IBV_ACCESS_ZERO_BASED) { - errno = EINVAL; - return errno; - } - - if (bind_info->mr) { - if (to_mmr(bind_info->mr)->alloc_flags & IBV_ACCESS_ZERO_BASED) { - errno = EINVAL; - return errno; - } - - if (mw->pd != bind_info->mr->pd) { - errno = EPERM; - return errno; - } - } - - wr.opcode = IBV_WR_BIND_MW; - wr.next = NULL; - wr.wr_id = mw_bind->wr_id; - wr.send_flags = mw_bind->send_flags; - wr.bind_mw.bind_info = mw_bind->bind_info; - wr.bind_mw.mw = mw; - wr.bind_mw.rkey = ibv_inc_rkey(mw->rkey); - - ret = _mlx5_post_send(qp, &wr, &bad_wr); - if (ret) - return ret; - - mw->rkey = wr.bind_mw.rkey; - - return 0; -} - -static void set_sig_seg(struct mlx5_qp *qp, struct mlx5_rwqe_sig *sig, - int size, uint16_t idx) -{ - uint8_t sign; - uint32_t qpn = qp->ibv_qp->qp_num; - - sign = calc_sig(sig, size); - sign ^= calc_sig(&qpn, 4); - sign ^= calc_sig(&idx, 2); - sig->signature = sign; -} - -static void set_wq_sig_seg(struct mlx5_rwq *rwq, struct mlx5_rwqe_sig *sig, - int size, uint16_t idx) -{ - uint8_t sign; - uint32_t qpn = rwq->wq.wq_num; - - sign = calc_sig(sig, size); - sign ^= calc_sig(&qpn, 4); - sign ^= calc_sig(&idx, 2); - sig->signature = sign; -} - -int mlx5_post_wq_recv(struct ibv_wq *ibwq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mlx5_rwq *rwq = to_mrwq(ibwq); - struct mlx5_wqe_data_seg *scat; - int err = 0; - int nreq; - int ind; - int i, j; - struct mlx5_rwqe_sig *sig; - - mlx5_spin_lock(&rwq->rq.lock); - - ind = rwq->rq.head & (rwq->rq.wqe_cnt - 1); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (unlikely(mlx5_wq_overflow(&rwq->rq, nreq, - to_mcq(rwq->wq.cq)))) { - err = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (unlikely(wr->num_sge > rwq->rq.max_gs)) { - err = EINVAL; - *bad_wr = wr; - goto out; - } - - scat = get_wq_recv_wqe(rwq, ind); - sig = (struct mlx5_rwqe_sig *)scat; - if (unlikely(rwq->wq_sig)) { - memset(sig, 0, 1 << rwq->rq.wqe_shift); - ++scat; - } - - for (i = 0, j = 0; i < wr->num_sge; ++i) { - if (unlikely(!wr->sg_list[i].length)) - continue; - set_data_ptr_seg(scat + j++, wr->sg_list + i, 0); - } - - if (j < rwq->rq.max_gs) { - scat[j].byte_count = 0; - scat[j].lkey = htobe32(MLX5_INVALID_LKEY); - scat[j].addr = 0; - } - - if (unlikely(rwq->wq_sig)) - set_wq_sig_seg(rwq, sig, (wr->num_sge + 1) << 4, - rwq->rq.head & 0xffff); - - rwq->rq.wrid[ind] = wr->wr_id; - - ind = (ind + 1) & (rwq->rq.wqe_cnt - 1); - } - -out: - if (likely(nreq)) { - rwq->rq.head += nreq; - /* - * Make sure that descriptors are written before - * doorbell record. - */ - udma_to_device_barrier(); - *(rwq->recv_db) = htobe32(rwq->rq.head & 0xffff); - } - - mlx5_spin_unlock(&rwq->rq.lock); - - return err; -} - -int mlx5_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mlx5_qp *qp = to_mqp(ibqp); - struct mlx5_wqe_data_seg *scat; - int err = 0; - int nreq; - int ind; - int i, j; - struct mlx5_rwqe_sig *sig; - - mlx5_spin_lock(&qp->rq.lock); - - ind = qp->rq.head & (qp->rq.wqe_cnt - 1); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (unlikely(mlx5_wq_overflow(&qp->rq, nreq, - to_mcq(qp->ibv_qp->recv_cq)))) { - err = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (unlikely(wr->num_sge > qp->rq.max_gs)) { - err = EINVAL; - *bad_wr = wr; - goto out; - } - - scat = get_recv_wqe(qp, ind); - sig = (struct mlx5_rwqe_sig *)scat; - if (unlikely(qp->wq_sig)) { - memset(sig, 0, 1 << qp->rq.wqe_shift); - ++scat; - } - - for (i = 0, j = 0; i < wr->num_sge; ++i) { - if (unlikely(!wr->sg_list[i].length)) - continue; - set_data_ptr_seg(scat + j++, wr->sg_list + i, 0); - } - - if (j < qp->rq.max_gs) { - scat[j].byte_count = 0; - scat[j].lkey = htobe32(MLX5_INVALID_LKEY); - scat[j].addr = 0; - } - - if (unlikely(qp->wq_sig)) - set_sig_seg(qp, sig, (wr->num_sge + 1) << 4, - qp->rq.head & 0xffff); - - qp->rq.wrid[ind] = wr->wr_id; - - ind = (ind + 1) & (qp->rq.wqe_cnt - 1); - } - -out: - if (likely(nreq)) { - qp->rq.head += nreq; - - /* - * Make sure that descriptors are written before - * doorbell record. - */ - udma_to_device_barrier(); - - /* - * For Raw Packet QP, avoid updating the doorbell record - * as long as the QP isn't in RTR state, to avoid receiving - * packets in illegal states. - * This is only for Raw Packet QPs since they are represented - * differently in the hardware. - */ - if (likely(!((ibqp->qp_type == IBV_QPT_RAW_PACKET || - qp->flags & MLX5_QP_FLAGS_USE_UNDERLAY) && - ibqp->state < IBV_QPS_RTR))) - qp->db[MLX5_RCV_DBR] = htobe32(qp->rq.head & 0xffff); - } - - mlx5_spin_unlock(&qp->rq.lock); - - return err; -} - -int mlx5_use_huge(const char *key) -{ - char *e; - e = getenv(key); - if (e && !strcmp(e, "y")) - return 1; - - return 0; -} - -struct mlx5_qp *mlx5_find_qp(struct mlx5_context *ctx, uint32_t qpn) -{ - int tind = qpn >> MLX5_QP_TABLE_SHIFT; - - if (ctx->qp_table[tind].refcnt) - return ctx->qp_table[tind].table[qpn & MLX5_QP_TABLE_MASK]; - else - return NULL; -} - -int mlx5_store_qp(struct mlx5_context *ctx, uint32_t qpn, struct mlx5_qp *qp) -{ - int tind = qpn >> MLX5_QP_TABLE_SHIFT; - - if (!ctx->qp_table[tind].refcnt) { - ctx->qp_table[tind].table = calloc(MLX5_QP_TABLE_MASK + 1, - sizeof(struct mlx5_qp *)); - if (!ctx->qp_table[tind].table) - return -1; - } - - ++ctx->qp_table[tind].refcnt; - ctx->qp_table[tind].table[qpn & MLX5_QP_TABLE_MASK] = qp; - return 0; -} - -void mlx5_clear_qp(struct mlx5_context *ctx, uint32_t qpn) -{ - int tind = qpn >> MLX5_QP_TABLE_SHIFT; - - if (!--ctx->qp_table[tind].refcnt) - free(ctx->qp_table[tind].table); - else - ctx->qp_table[tind].table[qpn & MLX5_QP_TABLE_MASK] = NULL; -} diff --git a/usr/rdma-core/providers/mlx5/srq.c b/usr/rdma-core/providers/mlx5/srq.c deleted file mode 100644 index 94528bba9..000000000 --- a/usr/rdma-core/providers/mlx5/srq.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include - -#include "mlx5.h" -#include "wqe.h" - -static void *get_wqe(struct mlx5_srq *srq, int n) -{ - return srq->buf.buf + (n << srq->wqe_shift); -} - -int mlx5_copy_to_recv_srq(struct mlx5_srq *srq, int idx, void *buf, int size) -{ - struct mlx5_wqe_srq_next_seg *next; - struct mlx5_wqe_data_seg *scat; - int copy; - int i; - int max = 1 << (srq->wqe_shift - 4); - - next = get_wqe(srq, idx); - scat = (struct mlx5_wqe_data_seg *) (next + 1); - - for (i = 0; i < max; ++i) { - copy = min_t(long, size, be32toh(scat->byte_count)); - memcpy((void *)(unsigned long)be64toh(scat->addr), buf, copy); - size -= copy; - if (size <= 0) - return IBV_WC_SUCCESS; - - buf += copy; - ++scat; - } - return IBV_WC_LOC_LEN_ERR; -} - -void mlx5_free_srq_wqe(struct mlx5_srq *srq, int ind) -{ - struct mlx5_wqe_srq_next_seg *next; - - mlx5_spin_lock(&srq->lock); - - next = get_wqe(srq, srq->tail); - next->next_wqe_index = htobe16(ind); - srq->tail = ind; - - mlx5_spin_unlock(&srq->lock); -} - -int mlx5_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mlx5_srq *srq = to_msrq(ibsrq); - struct mlx5_wqe_srq_next_seg *next; - struct mlx5_wqe_data_seg *scat; - int err = 0; - int nreq; - int i; - - mlx5_spin_lock(&srq->lock); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (wr->num_sge > srq->max_gs) { - err = EINVAL; - *bad_wr = wr; - break; - } - - if (srq->head == srq->tail) { - /* SRQ is full*/ - err = ENOMEM; - *bad_wr = wr; - break; - } - - srq->wrid[srq->head] = wr->wr_id; - - next = get_wqe(srq, srq->head); - srq->head = be16toh(next->next_wqe_index); - scat = (struct mlx5_wqe_data_seg *) (next + 1); - - for (i = 0; i < wr->num_sge; ++i) { - scat[i].byte_count = htobe32(wr->sg_list[i].length); - scat[i].lkey = htobe32(wr->sg_list[i].lkey); - scat[i].addr = htobe64(wr->sg_list[i].addr); - } - - if (i < srq->max_gs) { - scat[i].byte_count = 0; - scat[i].lkey = htobe32(MLX5_INVALID_LKEY); - scat[i].addr = 0; - } - } - - if (nreq) { - srq->counter += nreq; - - /* - * Make sure that descriptors are written before - * we write doorbell record. - */ - udma_to_device_barrier(); - - *srq->db = htobe32(srq->counter); - } - - mlx5_spin_unlock(&srq->lock); - - return err; -} - -int mlx5_alloc_srq_buf(struct ibv_context *context, struct mlx5_srq *srq) -{ - struct mlx5_wqe_srq_next_seg *next; - int size; - int buf_size; - int i; - struct mlx5_context *ctx; - - ctx = to_mctx(context); - - if (srq->max_gs < 0) { - errno = EINVAL; - return -1; - } - - srq->wrid = malloc(srq->max * sizeof *srq->wrid); - if (!srq->wrid) - return -1; - - size = sizeof(struct mlx5_wqe_srq_next_seg) + - srq->max_gs * sizeof(struct mlx5_wqe_data_seg); - size = max(32, size); - - size = mlx5_round_up_power_of_two(size); - - if (size > ctx->max_recv_wr) { - errno = EINVAL; - return -1; - } - srq->max_gs = (size - sizeof(struct mlx5_wqe_srq_next_seg)) / - sizeof(struct mlx5_wqe_data_seg); - - srq->wqe_shift = mlx5_ilog2(size); - - buf_size = srq->max * size; - - if (mlx5_alloc_buf(&srq->buf, buf_size, - to_mdev(context->device)->page_size)) { - free(srq->wrid); - return -1; - } - - memset(srq->buf.buf, 0, buf_size); - - /* - * Now initialize the SRQ buffer so that all of the WQEs are - * linked into the list of free WQEs. - */ - - for (i = 0; i < srq->max; ++i) { - next = get_wqe(srq, i); - next->next_wqe_index = htobe16((i + 1) & (srq->max - 1)); - } - - srq->head = 0; - srq->tail = srq->max - 1; - - return 0; -} - -struct mlx5_srq *mlx5_find_srq(struct mlx5_context *ctx, uint32_t srqn) -{ - int tind = srqn >> MLX5_SRQ_TABLE_SHIFT; - - if (ctx->srq_table[tind].refcnt) - return ctx->srq_table[tind].table[srqn & MLX5_SRQ_TABLE_MASK]; - else - return NULL; -} - -int mlx5_store_srq(struct mlx5_context *ctx, uint32_t srqn, - struct mlx5_srq *srq) -{ - int tind = srqn >> MLX5_SRQ_TABLE_SHIFT; - - if (!ctx->srq_table[tind].refcnt) { - ctx->srq_table[tind].table = calloc(MLX5_QP_TABLE_MASK + 1, - sizeof(struct mlx5_qp *)); - if (!ctx->srq_table[tind].table) - return -1; - } - - ++ctx->srq_table[tind].refcnt; - ctx->srq_table[tind].table[srqn & MLX5_QP_TABLE_MASK] = srq; - return 0; -} - -void mlx5_clear_srq(struct mlx5_context *ctx, uint32_t srqn) -{ - int tind = srqn >> MLX5_QP_TABLE_SHIFT; - - if (!--ctx->srq_table[tind].refcnt) - free(ctx->srq_table[tind].table); - else - ctx->srq_table[tind].table[srqn & MLX5_SRQ_TABLE_MASK] = NULL; -} diff --git a/usr/rdma-core/providers/mlx5/verbs.c b/usr/rdma-core/providers/mlx5/verbs.c deleted file mode 100644 index 2315a0d96..000000000 --- a/usr/rdma-core/providers/mlx5/verbs.c +++ /dev/null @@ -1,2250 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "mlx5.h" -#include "mlx5-abi.h" -#include "wqe.h" - -int mlx5_single_threaded = 0; - -static inline int is_xrc_tgt(int type) -{ - return type == IBV_QPT_XRC_RECV; -} - -int mlx5_query_device(struct ibv_context *context, struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, sizeof cmd); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%04d", major, minor, sub_minor); - - return 0; -} - -static int mlx5_read_clock(struct ibv_context *context, uint64_t *cycles) -{ - unsigned int clockhi, clocklo, clockhi1; - int i; - struct mlx5_context *ctx = to_mctx(context); - - if (!ctx->hca_core_clock) - return -EOPNOTSUPP; - - /* Handle wraparound */ - for (i = 0; i < 2; i++) { - clockhi = be32toh(mmio_read32_be(ctx->hca_core_clock)); - clocklo = be32toh(mmio_read32_be(ctx->hca_core_clock + 4)); - clockhi1 = be32toh(mmio_read32_be(ctx->hca_core_clock)); - if (clockhi == clockhi1) - break; - } - - *cycles = (uint64_t)clockhi << 32 | (uint64_t)clocklo; - - return 0; -} - -int mlx5_query_rt_values(struct ibv_context *context, - struct ibv_values_ex *values) -{ - uint32_t comp_mask = 0; - int err = 0; - - if (values->comp_mask & IBV_VALUES_MASK_RAW_CLOCK) { - uint64_t cycles; - - err = mlx5_read_clock(context, &cycles); - if (!err) { - values->raw_clock.tv_sec = 0; - values->raw_clock.tv_nsec = cycles; - comp_mask |= IBV_VALUES_MASK_RAW_CLOCK; - } - } - - values->comp_mask = comp_mask; - - return err; -} - -int mlx5_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); -} - -struct ibv_pd *mlx5_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct mlx5_alloc_pd_resp resp; - struct mlx5_pd *pd; - - pd = calloc(1, sizeof *pd); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(pd); - return NULL; - } - - pd->pdn = resp.pdn; - - return &pd->ibv_pd; -} - -int mlx5_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - free(to_mpd(pd)); - return 0; -} - -struct ibv_mr *mlx5_reg_mr(struct ibv_pd *pd, void *addr, size_t length, - int acc) -{ - struct mlx5_mr *mr; - struct ibv_reg_mr cmd; - int ret; - enum ibv_access_flags access = (enum ibv_access_flags)acc; - struct ibv_reg_mr_resp resp; - - mr = calloc(1, sizeof(*mr)); - if (!mr) - return NULL; - - ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, - &(mr->ibv_mr), &cmd, sizeof(cmd), &resp, - sizeof resp); - if (ret) { - mlx5_free_buf(&(mr->buf)); - free(mr); - return NULL; - } - mr->alloc_flags = acc; - - return &mr->ibv_mr; -} - -int mlx5_rereg_mr(struct ibv_mr *ibmr, int flags, struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - struct ibv_rereg_mr cmd; - struct ibv_rereg_mr_resp resp; - - if (flags & IBV_REREG_MR_KEEP_VALID) - return ENOTSUP; - - return ibv_cmd_rereg_mr(ibmr, flags, addr, length, (uintptr_t)addr, - access, pd, &cmd, sizeof(cmd), &resp, - sizeof(resp)); -} - -int mlx5_dereg_mr(struct ibv_mr *ibmr) -{ - int ret; - struct mlx5_mr *mr = to_mmr(ibmr); - - ret = ibv_cmd_dereg_mr(ibmr); - if (ret) - return ret; - - free(mr); - return 0; -} - -struct ibv_mw *mlx5_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type) -{ - struct ibv_mw *mw; - struct ibv_alloc_mw cmd; - struct ibv_alloc_mw_resp resp; - int ret; - - mw = malloc(sizeof(*mw)); - if (!mw) - return NULL; - - memset(mw, 0, sizeof(*mw)); - - ret = ibv_cmd_alloc_mw(pd, type, mw, &cmd, sizeof(cmd), &resp, - sizeof(resp)); - if (ret) { - free(mw); - return NULL; - } - - return mw; -} - -int mlx5_dealloc_mw(struct ibv_mw *mw) -{ - int ret; - struct ibv_dealloc_mw cmd; - - ret = ibv_cmd_dealloc_mw(mw, &cmd, sizeof(cmd)); - if (ret) - return ret; - - free(mw); - return 0; -} - -int mlx5_round_up_power_of_two(long long sz) -{ - long long ret; - - for (ret = 1; ret < sz; ret <<= 1) - ; /* nothing */ - - if (ret > INT_MAX) { - fprintf(stderr, "%s: roundup overflow\n", __func__); - return -ENOMEM; - } - - return (int)ret; -} - -static int align_queue_size(long long req) -{ - return mlx5_round_up_power_of_two(req); -} - -static int get_cqe_size(void) -{ - char *env; - int size = 64; - - env = getenv("MLX5_CQE_SIZE"); - if (env) - size = atoi(env); - - switch (size) { - case 64: - case 128: - return size; - - default: - return -EINVAL; - } -} - -static int use_scatter_to_cqe(void) -{ - char *env; - - env = getenv("MLX5_SCATTER_TO_CQE"); - if (env && !strcmp(env, "0")) - return 0; - - return 1; -} - -static int srq_sig_enabled(void) -{ - char *env; - - env = getenv("MLX5_SRQ_SIGNATURE"); - if (env) - return 1; - - return 0; -} - -static int qp_sig_enabled(void) -{ - char *env; - - env = getenv("MLX5_QP_SIGNATURE"); - if (env) - return 1; - - return 0; -} - -enum { - CREATE_CQ_SUPPORTED_WC_FLAGS = IBV_WC_STANDARD_FLAGS | - IBV_WC_EX_WITH_COMPLETION_TIMESTAMP | - IBV_WC_EX_WITH_CVLAN | - IBV_WC_EX_WITH_FLOW_TAG -}; - -enum { - CREATE_CQ_SUPPORTED_COMP_MASK = IBV_CQ_INIT_ATTR_MASK_FLAGS -}; - -enum { - CREATE_CQ_SUPPORTED_FLAGS = IBV_CREATE_CQ_ATTR_SINGLE_THREADED -}; - -static struct ibv_cq_ex *create_cq(struct ibv_context *context, - const struct ibv_cq_init_attr_ex *cq_attr, - int cq_alloc_flags, - struct mlx5dv_cq_init_attr *mlx5cq_attr) -{ - struct mlx5_create_cq cmd; - struct mlx5_create_cq_resp resp; - struct mlx5_cq *cq; - int cqe_sz; - int ret; - int ncqe; - struct mlx5_context *mctx = to_mctx(context); - FILE *fp = to_mctx(context)->dbg_fp; - - if (!cq_attr->cqe) { - mlx5_dbg(fp, MLX5_DBG_CQ, "CQE invalid\n"); - errno = EINVAL; - return NULL; - } - - if (cq_attr->comp_mask & ~CREATE_CQ_SUPPORTED_COMP_MASK) { - mlx5_dbg(fp, MLX5_DBG_CQ, - "Unsupported comp_mask for create_cq\n"); - errno = EINVAL; - return NULL; - } - - if (cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS && - cq_attr->flags & ~CREATE_CQ_SUPPORTED_FLAGS) { - mlx5_dbg(fp, MLX5_DBG_CQ, - "Unsupported creation flags requested for create_cq\n"); - errno = EINVAL; - return NULL; - } - - if (cq_attr->wc_flags & ~CREATE_CQ_SUPPORTED_WC_FLAGS) { - mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); - errno = ENOTSUP; - return NULL; - } - - cq = calloc(1, sizeof *cq); - if (!cq) { - mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); - return NULL; - } - - memset(&cmd, 0, sizeof cmd); - cq->cons_index = 0; - - if (mlx5_spinlock_init(&cq->lock)) - goto err; - - ncqe = align_queue_size(cq_attr->cqe + 1); - if ((ncqe > (1 << 24)) || (ncqe < (cq_attr->cqe + 1))) { - mlx5_dbg(fp, MLX5_DBG_CQ, "ncqe %d\n", ncqe); - errno = EINVAL; - goto err_spl; - } - - cqe_sz = get_cqe_size(); - if (cqe_sz < 0) { - mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); - errno = -cqe_sz; - goto err_spl; - } - - if (mlx5_alloc_cq_buf(to_mctx(context), cq, &cq->buf_a, ncqe, cqe_sz)) { - mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); - goto err_spl; - } - - cq->dbrec = mlx5_alloc_dbrec(to_mctx(context)); - if (!cq->dbrec) { - mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); - goto err_buf; - } - - cq->dbrec[MLX5_CQ_SET_CI] = 0; - cq->dbrec[MLX5_CQ_ARM_DB] = 0; - cq->arm_sn = 0; - cq->cqe_sz = cqe_sz; - cq->flags = cq_alloc_flags; - - if (cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS && - cq_attr->flags & IBV_CREATE_CQ_ATTR_SINGLE_THREADED) - cq->flags |= MLX5_CQ_FLAGS_SINGLE_THREADED; - cmd.buf_addr = (uintptr_t) cq->buf_a.buf; - cmd.db_addr = (uintptr_t) cq->dbrec; - cmd.cqe_size = cqe_sz; - - if (mlx5cq_attr) { - if (mlx5cq_attr->comp_mask & ~(MLX5DV_CQ_INIT_ATTR_MASK_RESERVED - 1)) { - mlx5_dbg(fp, MLX5_DBG_CQ, - "Unsupported vendor comp_mask for create_cq\n"); - errno = EINVAL; - goto err_db; - } - - if (mlx5cq_attr->comp_mask & MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE) { - if (mctx->cqe_comp_caps.max_num && - (mlx5cq_attr->cqe_comp_res_format & - mctx->cqe_comp_caps.supported_format)) { - cmd.cqe_comp_en = 1; - cmd.cqe_comp_res_format = mlx5cq_attr->cqe_comp_res_format; - } else { - mlx5_dbg(fp, MLX5_DBG_CQ, "CQE Compression is not supported\n"); - errno = EINVAL; - goto err_db; - } - } - } - - ret = ibv_cmd_create_cq(context, ncqe - 1, cq_attr->channel, - cq_attr->comp_vector, - ibv_cq_ex_to_cq(&cq->ibv_cq), &cmd.ibv_cmd, - sizeof(cmd), &resp.ibv_resp, sizeof(resp)); - if (ret) { - mlx5_dbg(fp, MLX5_DBG_CQ, "ret %d\n", ret); - goto err_db; - } - - cq->active_buf = &cq->buf_a; - cq->resize_buf = NULL; - cq->cqn = resp.cqn; - cq->stall_enable = to_mctx(context)->stall_enable; - cq->stall_adaptive_enable = to_mctx(context)->stall_adaptive_enable; - cq->stall_cycles = to_mctx(context)->stall_cycles; - - if (cq_alloc_flags & MLX5_CQ_FLAGS_EXTENDED) - mlx5_cq_fill_pfns(cq, cq_attr); - - return &cq->ibv_cq; - -err_db: - mlx5_free_db(to_mctx(context), cq->dbrec); - -err_buf: - mlx5_free_cq_buf(to_mctx(context), &cq->buf_a); - -err_spl: - mlx5_spinlock_destroy(&cq->lock); - -err: - free(cq); - - return NULL; -} - -struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct ibv_cq_ex *cq; - struct ibv_cq_init_attr_ex cq_attr = {.cqe = cqe, .channel = channel, - .comp_vector = comp_vector, - .wc_flags = IBV_WC_STANDARD_FLAGS}; - - if (cqe <= 0) { - errno = EINVAL; - return NULL; - } - - cq = create_cq(context, &cq_attr, 0, NULL); - return cq ? ibv_cq_ex_to_cq(cq) : NULL; -} - -struct ibv_cq_ex *mlx5_create_cq_ex(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr) -{ - return create_cq(context, cq_attr, MLX5_CQ_FLAGS_EXTENDED, NULL); -} - -struct ibv_cq_ex *mlx5dv_create_cq(struct ibv_context *context, - struct ibv_cq_init_attr_ex *cq_attr, - struct mlx5dv_cq_init_attr *mlx5_cq_attr) -{ - struct ibv_cq_ex *cq; - - cq = create_cq(context, cq_attr, MLX5_CQ_FLAGS_EXTENDED, mlx5_cq_attr); - if (!cq) - return NULL; - - verbs_init_cq(ibv_cq_ex_to_cq(cq), context, - cq_attr->channel, cq_attr->cq_context); - return cq; -} - -int mlx5_resize_cq(struct ibv_cq *ibcq, int cqe) -{ - struct mlx5_cq *cq = to_mcq(ibcq); - struct mlx5_resize_cq_resp resp; - struct mlx5_resize_cq cmd; - struct mlx5_context *mctx = to_mctx(ibcq->context); - int err; - - if (cqe < 0) { - errno = EINVAL; - return errno; - } - - memset(&cmd, 0, sizeof(cmd)); - memset(&resp, 0, sizeof(resp)); - - if (((long long)cqe * 64) > INT_MAX) - return EINVAL; - - mlx5_spin_lock(&cq->lock); - cq->active_cqes = cq->ibv_cq.cqe; - if (cq->active_buf == &cq->buf_a) - cq->resize_buf = &cq->buf_b; - else - cq->resize_buf = &cq->buf_a; - - cqe = align_queue_size(cqe + 1); - if (cqe == ibcq->cqe + 1) { - cq->resize_buf = NULL; - err = 0; - goto out; - } - - /* currently we don't change cqe size */ - cq->resize_cqe_sz = cq->cqe_sz; - cq->resize_cqes = cqe; - err = mlx5_alloc_cq_buf(mctx, cq, cq->resize_buf, cq->resize_cqes, cq->resize_cqe_sz); - if (err) { - cq->resize_buf = NULL; - errno = ENOMEM; - goto out; - } - - cmd.buf_addr = (uintptr_t)cq->resize_buf->buf; - cmd.cqe_size = cq->resize_cqe_sz; - - err = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (err) - goto out_buf; - - mlx5_cq_resize_copy_cqes(cq); - mlx5_free_cq_buf(mctx, cq->active_buf); - cq->active_buf = cq->resize_buf; - cq->ibv_cq.cqe = cqe - 1; - mlx5_spin_unlock(&cq->lock); - cq->resize_buf = NULL; - return 0; - -out_buf: - mlx5_free_cq_buf(mctx, cq->resize_buf); - cq->resize_buf = NULL; - -out: - mlx5_spin_unlock(&cq->lock); - return err; -} - -int mlx5_destroy_cq(struct ibv_cq *cq) -{ - int ret; - - ret = ibv_cmd_destroy_cq(cq); - if (ret) - return ret; - - mlx5_free_db(to_mctx(cq->context), to_mcq(cq)->dbrec); - mlx5_free_cq_buf(to_mctx(cq->context), to_mcq(cq)->active_buf); - free(to_mcq(cq)); - - return 0; -} - -struct ibv_srq *mlx5_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct mlx5_create_srq cmd; - struct mlx5_create_srq_resp resp; - struct mlx5_srq *srq; - int ret; - struct mlx5_context *ctx; - int max_sge; - struct ibv_srq *ibsrq; - - ctx = to_mctx(pd->context); - srq = calloc(1, sizeof *srq); - if (!srq) { - fprintf(stderr, "%s-%d:\n", __func__, __LINE__); - return NULL; - } - ibsrq = &srq->vsrq.srq; - - memset(&cmd, 0, sizeof cmd); - if (mlx5_spinlock_init(&srq->lock)) { - fprintf(stderr, "%s-%d:\n", __func__, __LINE__); - goto err; - } - - if (attr->attr.max_wr > ctx->max_srq_recv_wr) { - fprintf(stderr, "%s-%d:max_wr %d, max_srq_recv_wr %d\n", __func__, __LINE__, - attr->attr.max_wr, ctx->max_srq_recv_wr); - errno = EINVAL; - goto err; - } - - /* - * this calculation does not consider required control segments. The - * final calculation is done again later. This is done so to avoid - * overflows of variables - */ - max_sge = ctx->max_rq_desc_sz / sizeof(struct mlx5_wqe_data_seg); - if (attr->attr.max_sge > max_sge) { - fprintf(stderr, "%s-%d:max_wr %d, max_srq_recv_wr %d\n", __func__, __LINE__, - attr->attr.max_wr, ctx->max_srq_recv_wr); - errno = EINVAL; - goto err; - } - - srq->max = align_queue_size(attr->attr.max_wr + 1); - srq->max_gs = attr->attr.max_sge; - srq->counter = 0; - - if (mlx5_alloc_srq_buf(pd->context, srq)) { - fprintf(stderr, "%s-%d:\n", __func__, __LINE__); - goto err; - } - - srq->db = mlx5_alloc_dbrec(to_mctx(pd->context)); - if (!srq->db) { - fprintf(stderr, "%s-%d:\n", __func__, __LINE__); - goto err_free; - } - - *srq->db = 0; - - cmd.buf_addr = (uintptr_t) srq->buf.buf; - cmd.db_addr = (uintptr_t) srq->db; - srq->wq_sig = srq_sig_enabled(); - if (srq->wq_sig) - cmd.flags = MLX5_SRQ_FLAG_SIGNATURE; - - attr->attr.max_sge = srq->max_gs; - pthread_mutex_lock(&ctx->srq_table_mutex); - ret = ibv_cmd_create_srq(pd, ibsrq, attr, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (ret) - goto err_db; - - ret = mlx5_store_srq(ctx, resp.srqn, srq); - if (ret) - goto err_destroy; - - pthread_mutex_unlock(&ctx->srq_table_mutex); - - srq->srqn = resp.srqn; - srq->rsc.rsn = resp.srqn; - srq->rsc.type = MLX5_RSC_TYPE_SRQ; - - return ibsrq; - -err_destroy: - ibv_cmd_destroy_srq(ibsrq); - -err_db: - pthread_mutex_unlock(&ctx->srq_table_mutex); - mlx5_free_db(to_mctx(pd->context), srq->db); - -err_free: - free(srq->wrid); - mlx5_free_buf(&srq->buf); - -err: - free(srq); - - return NULL; -} - -int mlx5_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int attr_mask) -{ - struct ibv_modify_srq cmd; - - return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd); -} - -int mlx5_query_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr) -{ - struct ibv_query_srq cmd; - - return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd); -} - -int mlx5_destroy_srq(struct ibv_srq *srq) -{ - int ret; - struct mlx5_srq *msrq = to_msrq(srq); - struct mlx5_context *ctx = to_mctx(srq->context); - - ret = ibv_cmd_destroy_srq(srq); - if (ret) - return ret; - - if (ctx->cqe_version && msrq->rsc.type == MLX5_RSC_TYPE_XSRQ) - mlx5_clear_uidx(ctx, msrq->rsc.rsn); - else - mlx5_clear_srq(ctx, msrq->srqn); - - mlx5_free_db(ctx, msrq->db); - mlx5_free_buf(&msrq->buf); - free(msrq->wrid); - free(msrq); - - return 0; -} - -static int sq_overhead(struct mlx5_qp *qp, enum ibv_qp_type qp_type) -{ - size_t size = 0; - size_t mw_bind_size = - sizeof(struct mlx5_wqe_umr_ctrl_seg) + - sizeof(struct mlx5_wqe_mkey_context_seg) + - max_t(size_t, sizeof(struct mlx5_wqe_umr_klm_seg), 64); - - switch (qp_type) { - case IBV_QPT_RC: - size += sizeof(struct mlx5_wqe_ctrl_seg) + - max(sizeof(struct mlx5_wqe_atomic_seg) + - sizeof(struct mlx5_wqe_raddr_seg), - mw_bind_size); - break; - - case IBV_QPT_UC: - size = sizeof(struct mlx5_wqe_ctrl_seg) + - max(sizeof(struct mlx5_wqe_raddr_seg), - mw_bind_size); - break; - - case IBV_QPT_UD: - size = sizeof(struct mlx5_wqe_ctrl_seg) + - sizeof(struct mlx5_wqe_datagram_seg); - - if (qp->flags & MLX5_QP_FLAGS_USE_UNDERLAY) - size += (sizeof(struct mlx5_wqe_eth_seg) + sizeof(struct mlx5_wqe_eth_pad)); - - break; - - case IBV_QPT_XRC_SEND: - size = sizeof(struct mlx5_wqe_ctrl_seg) + mw_bind_size; - SWITCH_FALLTHROUGH; - - case IBV_QPT_XRC_RECV: - size = max(size, sizeof(struct mlx5_wqe_ctrl_seg) + - sizeof(struct mlx5_wqe_xrc_seg) + - sizeof(struct mlx5_wqe_raddr_seg)); - break; - - case IBV_QPT_RAW_PACKET: - size = sizeof(struct mlx5_wqe_ctrl_seg) + - sizeof(struct mlx5_wqe_eth_seg); - break; - - default: - return -EINVAL; - } - - return size; -} - -static int mlx5_calc_send_wqe(struct mlx5_context *ctx, - struct ibv_qp_init_attr_ex *attr, - struct mlx5_qp *qp) -{ - int size; - int inl_size = 0; - int max_gather; - int tot_size; - - size = sq_overhead(qp, attr->qp_type); - if (size < 0) - return size; - - if (attr->cap.max_inline_data) { - inl_size = size + align(sizeof(struct mlx5_wqe_inl_data_seg) + - attr->cap.max_inline_data, 16); - } - - if (attr->comp_mask & IBV_QP_INIT_ATTR_MAX_TSO_HEADER) { - size += align(attr->max_tso_header, 16); - qp->max_tso_header = attr->max_tso_header; - } - - max_gather = (ctx->max_sq_desc_sz - size) / - sizeof(struct mlx5_wqe_data_seg); - if (attr->cap.max_send_sge > max_gather) - return -EINVAL; - - size += attr->cap.max_send_sge * sizeof(struct mlx5_wqe_data_seg); - tot_size = max_int(size, inl_size); - - if (tot_size > ctx->max_sq_desc_sz) - return -EINVAL; - - return align(tot_size, MLX5_SEND_WQE_BB); -} - -static int mlx5_calc_rcv_wqe(struct mlx5_context *ctx, - struct ibv_qp_init_attr_ex *attr, - struct mlx5_qp *qp) -{ - uint32_t size; - int num_scatter; - - if (attr->srq) - return 0; - - num_scatter = max_t(uint32_t, attr->cap.max_recv_sge, 1); - size = sizeof(struct mlx5_wqe_data_seg) * num_scatter; - if (qp->wq_sig) - size += sizeof(struct mlx5_rwqe_sig); - - if (size > ctx->max_rq_desc_sz) - return -EINVAL; - - size = mlx5_round_up_power_of_two(size); - - return size; -} - -static int mlx5_calc_sq_size(struct mlx5_context *ctx, - struct ibv_qp_init_attr_ex *attr, - struct mlx5_qp *qp) -{ - int wqe_size; - int wq_size; - FILE *fp = ctx->dbg_fp; - - if (!attr->cap.max_send_wr) - return 0; - - wqe_size = mlx5_calc_send_wqe(ctx, attr, qp); - if (wqe_size < 0) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - return wqe_size; - } - - if (wqe_size > ctx->max_sq_desc_sz) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - return -EINVAL; - } - - qp->max_inline_data = wqe_size - sq_overhead(qp, attr->qp_type) - - sizeof(struct mlx5_wqe_inl_data_seg); - attr->cap.max_inline_data = qp->max_inline_data; - - /* - * to avoid overflow, we limit max_send_wr so - * that the multiplication will fit in int - */ - if (attr->cap.max_send_wr > 0x7fffffff / ctx->max_sq_desc_sz) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - return -EINVAL; - } - - wq_size = mlx5_round_up_power_of_two(attr->cap.max_send_wr * wqe_size); - qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB; - if (qp->sq.wqe_cnt > ctx->max_send_wqebb) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - return -EINVAL; - } - - qp->sq.wqe_shift = mlx5_ilog2(MLX5_SEND_WQE_BB); - qp->sq.max_gs = attr->cap.max_send_sge; - qp->sq.max_post = wq_size / wqe_size; - - return wq_size; -} - -static int mlx5_calc_rwq_size(struct mlx5_context *ctx, - struct mlx5_rwq *rwq, - struct ibv_wq_init_attr *attr) -{ - size_t wqe_size; - int wq_size; - uint32_t num_scatter; - int scat_spc; - - if (!attr->max_wr) - return -EINVAL; - - /* TBD: check caps for RQ */ - num_scatter = max_t(uint32_t, attr->max_sge, 1); - wqe_size = sizeof(struct mlx5_wqe_data_seg) * num_scatter; - - if (rwq->wq_sig) - wqe_size += sizeof(struct mlx5_rwqe_sig); - - if (wqe_size <= 0 || wqe_size > ctx->max_rq_desc_sz) - return -EINVAL; - - wqe_size = mlx5_round_up_power_of_two(wqe_size); - wq_size = mlx5_round_up_power_of_two(attr->max_wr) * wqe_size; - wq_size = max(wq_size, MLX5_SEND_WQE_BB); - rwq->rq.wqe_cnt = wq_size / wqe_size; - rwq->rq.wqe_shift = mlx5_ilog2(wqe_size); - rwq->rq.max_post = 1 << mlx5_ilog2(wq_size / wqe_size); - scat_spc = wqe_size - - ((rwq->wq_sig) ? sizeof(struct mlx5_rwqe_sig) : 0); - rwq->rq.max_gs = scat_spc / sizeof(struct mlx5_wqe_data_seg); - return wq_size; -} - -static int mlx5_calc_rq_size(struct mlx5_context *ctx, - struct ibv_qp_init_attr_ex *attr, - struct mlx5_qp *qp) -{ - int wqe_size; - int wq_size; - int scat_spc; - FILE *fp = ctx->dbg_fp; - - if (!attr->cap.max_recv_wr) - return 0; - - if (attr->cap.max_recv_wr > ctx->max_recv_wr) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - return -EINVAL; - } - - wqe_size = mlx5_calc_rcv_wqe(ctx, attr, qp); - if (wqe_size < 0 || wqe_size > ctx->max_rq_desc_sz) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - return -EINVAL; - } - - wq_size = mlx5_round_up_power_of_two(attr->cap.max_recv_wr) * wqe_size; - if (wqe_size) { - wq_size = max(wq_size, MLX5_SEND_WQE_BB); - qp->rq.wqe_cnt = wq_size / wqe_size; - qp->rq.wqe_shift = mlx5_ilog2(wqe_size); - qp->rq.max_post = 1 << mlx5_ilog2(wq_size / wqe_size); - scat_spc = wqe_size - - (qp->wq_sig ? sizeof(struct mlx5_rwqe_sig) : 0); - qp->rq.max_gs = scat_spc / sizeof(struct mlx5_wqe_data_seg); - } else { - qp->rq.wqe_cnt = 0; - qp->rq.wqe_shift = 0; - qp->rq.max_post = 0; - qp->rq.max_gs = 0; - } - return wq_size; -} - -static int mlx5_calc_wq_size(struct mlx5_context *ctx, - struct ibv_qp_init_attr_ex *attr, - struct mlx5_qp *qp) -{ - int ret; - int result; - - ret = mlx5_calc_sq_size(ctx, attr, qp); - if (ret < 0) - return ret; - - result = ret; - ret = mlx5_calc_rq_size(ctx, attr, qp); - if (ret < 0) - return ret; - - result += ret; - - qp->sq.offset = ret; - qp->rq.offset = 0; - - return result; -} - -static void map_uuar(struct ibv_context *context, struct mlx5_qp *qp, - int uuar_index) -{ - struct mlx5_context *ctx = to_mctx(context); - - qp->bf = &ctx->bfs[uuar_index]; -} - -static const char *qptype2key(enum ibv_qp_type type) -{ - switch (type) { - case IBV_QPT_RC: return "HUGE_RC"; - case IBV_QPT_UC: return "HUGE_UC"; - case IBV_QPT_UD: return "HUGE_UD"; - case IBV_QPT_RAW_PACKET: return "HUGE_RAW_ETH"; - default: return "HUGE_NA"; - } -} - -static int mlx5_alloc_qp_buf(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr, - struct mlx5_qp *qp, - int size) -{ - int err; - enum mlx5_alloc_type alloc_type; - enum mlx5_alloc_type default_alloc_type = MLX5_ALLOC_TYPE_ANON; - const char *qp_huge_key; - - if (qp->sq.wqe_cnt) { - qp->sq.wrid = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid)); - if (!qp->sq.wrid) { - errno = ENOMEM; - err = -1; - return err; - } - - qp->sq.wr_data = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data)); - if (!qp->sq.wr_data) { - errno = ENOMEM; - err = -1; - goto ex_wrid; - } - } - - qp->sq.wqe_head = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head)); - if (!qp->sq.wqe_head) { - errno = ENOMEM; - err = -1; - goto ex_wrid; - } - - if (qp->rq.wqe_cnt) { - qp->rq.wrid = malloc(qp->rq.wqe_cnt * sizeof(uint64_t)); - if (!qp->rq.wrid) { - errno = ENOMEM; - err = -1; - goto ex_wrid; - } - } - - /* compatibility support */ - qp_huge_key = qptype2key(qp->ibv_qp->qp_type); - if (mlx5_use_huge(qp_huge_key)) - default_alloc_type = MLX5_ALLOC_TYPE_HUGE; - - mlx5_get_alloc_type(to_mctx(context), MLX5_QP_PREFIX, &alloc_type, - default_alloc_type); - - err = mlx5_alloc_prefered_buf(to_mctx(context), &qp->buf, - align(qp->buf_size, to_mdev - (context->device)->page_size), - to_mdev(context->device)->page_size, - alloc_type, - MLX5_QP_PREFIX); - - if (err) { - err = -ENOMEM; - goto ex_wrid; - } - - memset(qp->buf.buf, 0, qp->buf_size); - - if (attr->qp_type == IBV_QPT_RAW_PACKET || - qp->flags & MLX5_QP_FLAGS_USE_UNDERLAY) { - size_t aligned_sq_buf_size = align(qp->sq_buf_size, - to_mdev(context->device)->page_size); - /* For Raw Packet QP, allocate a separate buffer for the SQ */ - err = mlx5_alloc_prefered_buf(to_mctx(context), &qp->sq_buf, - aligned_sq_buf_size, - to_mdev(context->device)->page_size, - alloc_type, - MLX5_QP_PREFIX); - if (err) { - err = -ENOMEM; - goto rq_buf; - } - - memset(qp->sq_buf.buf, 0, aligned_sq_buf_size); - } - - return 0; -rq_buf: - mlx5_free_actual_buf(to_mctx(qp->verbs_qp.qp.context), &qp->buf); -ex_wrid: - if (qp->rq.wrid) - free(qp->rq.wrid); - - if (qp->sq.wqe_head) - free(qp->sq.wqe_head); - - if (qp->sq.wr_data) - free(qp->sq.wr_data); - if (qp->sq.wrid) - free(qp->sq.wrid); - - return err; -} - -static void mlx5_free_qp_buf(struct mlx5_qp *qp) -{ - struct mlx5_context *ctx = to_mctx(qp->ibv_qp->context); - - mlx5_free_actual_buf(ctx, &qp->buf); - - if (qp->sq_buf.buf) - mlx5_free_actual_buf(ctx, &qp->sq_buf); - - if (qp->rq.wrid) - free(qp->rq.wrid); - - if (qp->sq.wqe_head) - free(qp->sq.wqe_head); - - if (qp->sq.wrid) - free(qp->sq.wrid); - - if (qp->sq.wr_data) - free(qp->sq.wr_data); -} - -static int mlx5_cmd_create_rss_qp(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr, - struct mlx5_qp *qp) -{ - struct mlx5_create_qp_ex_rss cmd_ex_rss = {}; - struct mlx5_create_qp_resp_ex resp = {}; - int ret; - - if (attr->rx_hash_conf.rx_hash_key_len > sizeof(cmd_ex_rss.rx_hash_key)) { - errno = EINVAL; - return errno; - } - - cmd_ex_rss.rx_hash_fields_mask = attr->rx_hash_conf.rx_hash_fields_mask; - cmd_ex_rss.rx_hash_function = attr->rx_hash_conf.rx_hash_function; - cmd_ex_rss.rx_key_len = attr->rx_hash_conf.rx_hash_key_len; - memcpy(cmd_ex_rss.rx_hash_key, attr->rx_hash_conf.rx_hash_key, - attr->rx_hash_conf.rx_hash_key_len); - - ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp, - sizeof(qp->verbs_qp), attr, - &cmd_ex_rss.ibv_cmd, sizeof(cmd_ex_rss.ibv_cmd), - sizeof(cmd_ex_rss), &resp.ibv_resp, - sizeof(resp.ibv_resp), sizeof(resp)); - if (ret) - return ret; - - qp->rss_qp = 1; - return 0; -} - -static int mlx5_cmd_create_qp_ex(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr, - struct mlx5_create_qp *cmd, - struct mlx5_qp *qp, - struct mlx5_create_qp_resp_ex *resp) -{ - struct mlx5_create_qp_ex cmd_ex; - int ret; - - memset(&cmd_ex, 0, sizeof(cmd_ex)); - memcpy(&cmd_ex.ibv_cmd.base, &cmd->ibv_cmd.user_handle, - offsetof(typeof(cmd->ibv_cmd), is_srq) + - sizeof(cmd->ibv_cmd.is_srq) - - offsetof(typeof(cmd->ibv_cmd), user_handle)); - - memcpy(&cmd_ex.drv_ex, &cmd->buf_addr, - offsetof(typeof(*cmd), sq_buf_addr) + - sizeof(cmd->sq_buf_addr) - sizeof(cmd->ibv_cmd)); - - ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp, - sizeof(qp->verbs_qp), attr, - &cmd_ex.ibv_cmd, sizeof(cmd_ex.ibv_cmd), - sizeof(cmd_ex), &resp->ibv_resp, - sizeof(resp->ibv_resp), sizeof(*resp)); - - return ret; -} - -enum { - MLX5_CREATE_QP_SUP_COMP_MASK = (IBV_QP_INIT_ATTR_PD | - IBV_QP_INIT_ATTR_XRCD | - IBV_QP_INIT_ATTR_CREATE_FLAGS | - IBV_QP_INIT_ATTR_MAX_TSO_HEADER | - IBV_QP_INIT_ATTR_IND_TABLE | - IBV_QP_INIT_ATTR_RX_HASH), -}; - -enum { - MLX5_CREATE_QP_EX2_COMP_MASK = (IBV_QP_INIT_ATTR_CREATE_FLAGS | - IBV_QP_INIT_ATTR_MAX_TSO_HEADER | - IBV_QP_INIT_ATTR_IND_TABLE | - IBV_QP_INIT_ATTR_RX_HASH), -}; - -static struct ibv_qp *create_qp(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr) -{ - struct mlx5_create_qp cmd; - struct mlx5_create_qp_resp resp; - struct mlx5_create_qp_resp_ex resp_ex; - struct mlx5_qp *qp; - int ret; - struct mlx5_context *ctx = to_mctx(context); - struct ibv_qp *ibqp; - int32_t usr_idx = 0; - uint32_t uuar_index; - FILE *fp = ctx->dbg_fp; - - if (attr->comp_mask & ~MLX5_CREATE_QP_SUP_COMP_MASK) - return NULL; - - if ((attr->comp_mask & IBV_QP_INIT_ATTR_MAX_TSO_HEADER) && - (attr->qp_type != IBV_QPT_RAW_PACKET)) - return NULL; - - qp = calloc(1, sizeof(*qp)); - if (!qp) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - return NULL; - } - ibqp = (struct ibv_qp *)&qp->verbs_qp; - qp->ibv_qp = ibqp; - - if ((attr->comp_mask & IBV_QP_INIT_ATTR_CREATE_FLAGS) && - (attr->create_flags & IBV_QP_CREATE_SOURCE_QPN)) { - - if (attr->qp_type != IBV_QPT_UD) { - errno = EINVAL; - goto err; - } - - qp->flags |= MLX5_QP_FLAGS_USE_UNDERLAY; - } - - memset(&cmd, 0, sizeof(cmd)); - memset(&resp, 0, sizeof(resp)); - memset(&resp_ex, 0, sizeof(resp_ex)); - - if (attr->comp_mask & IBV_QP_INIT_ATTR_RX_HASH) { - ret = mlx5_cmd_create_rss_qp(context, attr, qp); - if (ret) - goto err; - - return ibqp; - } - - qp->wq_sig = qp_sig_enabled(); - if (qp->wq_sig) - cmd.flags |= MLX5_QP_FLAG_SIGNATURE; - - if (use_scatter_to_cqe()) - cmd.flags |= MLX5_QP_FLAG_SCATTER_CQE; - - ret = mlx5_calc_wq_size(ctx, attr, qp); - if (ret < 0) { - errno = -ret; - goto err; - } - - if (attr->qp_type == IBV_QPT_RAW_PACKET || - qp->flags & MLX5_QP_FLAGS_USE_UNDERLAY) { - qp->buf_size = qp->sq.offset; - qp->sq_buf_size = ret - qp->buf_size; - qp->sq.offset = 0; - } else { - qp->buf_size = ret; - qp->sq_buf_size = 0; - } - - if (mlx5_alloc_qp_buf(context, attr, qp, ret)) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - goto err; - } - - if (attr->qp_type == IBV_QPT_RAW_PACKET || - qp->flags & MLX5_QP_FLAGS_USE_UNDERLAY) { - qp->sq_start = qp->sq_buf.buf; - qp->sq.qend = qp->sq_buf.buf + - (qp->sq.wqe_cnt << qp->sq.wqe_shift); - } else { - qp->sq_start = qp->buf.buf + qp->sq.offset; - qp->sq.qend = qp->buf.buf + qp->sq.offset + - (qp->sq.wqe_cnt << qp->sq.wqe_shift); - } - - mlx5_init_qp_indices(qp); - - if (mlx5_spinlock_init(&qp->sq.lock) || - mlx5_spinlock_init(&qp->rq.lock)) - goto err_free_qp_buf; - - qp->db = mlx5_alloc_dbrec(ctx); - if (!qp->db) { - mlx5_dbg(fp, MLX5_DBG_QP, "\n"); - goto err_free_qp_buf; - } - - qp->db[MLX5_RCV_DBR] = 0; - qp->db[MLX5_SND_DBR] = 0; - - cmd.buf_addr = (uintptr_t) qp->buf.buf; - cmd.sq_buf_addr = (attr->qp_type == IBV_QPT_RAW_PACKET || - qp->flags & MLX5_QP_FLAGS_USE_UNDERLAY) ? - (uintptr_t) qp->sq_buf.buf : 0; - cmd.db_addr = (uintptr_t) qp->db; - cmd.sq_wqe_count = qp->sq.wqe_cnt; - cmd.rq_wqe_count = qp->rq.wqe_cnt; - cmd.rq_wqe_shift = qp->rq.wqe_shift; - - if (ctx->atomic_cap == IBV_ATOMIC_HCA) - qp->atomics_enabled = 1; - - if (!ctx->cqe_version) { - cmd.uidx = 0xffffff; - pthread_mutex_lock(&ctx->qp_table_mutex); - } else if (!is_xrc_tgt(attr->qp_type)) { - usr_idx = mlx5_store_uidx(ctx, qp); - if (usr_idx < 0) { - mlx5_dbg(fp, MLX5_DBG_QP, "Couldn't find free user index\n"); - goto err_rq_db; - } - - cmd.uidx = usr_idx; - } - - if (attr->comp_mask & MLX5_CREATE_QP_EX2_COMP_MASK) - ret = mlx5_cmd_create_qp_ex(context, attr, &cmd, qp, &resp_ex); - else - ret = ibv_cmd_create_qp_ex(context, &qp->verbs_qp, sizeof(qp->verbs_qp), - attr, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (ret) { - mlx5_dbg(fp, MLX5_DBG_QP, "ret %d\n", ret); - goto err_free_uidx; - } - - uuar_index = (attr->comp_mask & MLX5_CREATE_QP_EX2_COMP_MASK) ? - resp_ex.uuar_index : resp.uuar_index; - if (!ctx->cqe_version) { - if (qp->sq.wqe_cnt || qp->rq.wqe_cnt) { - ret = mlx5_store_qp(ctx, ibqp->qp_num, qp); - if (ret) { - mlx5_dbg(fp, MLX5_DBG_QP, "ret %d\n", ret); - goto err_destroy; - } - } - - pthread_mutex_unlock(&ctx->qp_table_mutex); - } - - map_uuar(context, qp, uuar_index); - - qp->rq.max_post = qp->rq.wqe_cnt; - if (attr->sq_sig_all) - qp->sq_signal_bits = MLX5_WQE_CTRL_CQ_UPDATE; - else - qp->sq_signal_bits = 0; - - attr->cap.max_send_wr = qp->sq.max_post; - attr->cap.max_recv_wr = qp->rq.max_post; - attr->cap.max_recv_sge = qp->rq.max_gs; - - qp->rsc.type = MLX5_RSC_TYPE_QP; - qp->rsc.rsn = (ctx->cqe_version && !is_xrc_tgt(attr->qp_type)) ? - usr_idx : ibqp->qp_num; - - return ibqp; - -err_destroy: - ibv_cmd_destroy_qp(ibqp); - -err_free_uidx: - if (!ctx->cqe_version) - pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex); - else if (!is_xrc_tgt(attr->qp_type)) - mlx5_clear_uidx(ctx, usr_idx); - -err_rq_db: - mlx5_free_db(to_mctx(context), qp->db); - -err_free_qp_buf: - mlx5_free_qp_buf(qp); - -err: - free(qp); - - return NULL; -} - -struct ibv_qp *mlx5_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - struct ibv_qp *qp; - struct ibv_qp_init_attr_ex attrx; - - memset(&attrx, 0, sizeof(attrx)); - memcpy(&attrx, attr, sizeof(*attr)); - attrx.comp_mask = IBV_QP_INIT_ATTR_PD; - attrx.pd = pd; - qp = create_qp(pd->context, &attrx); - if (qp) - memcpy(attr, &attrx, sizeof(*attr)); - - return qp; -} - -static void mlx5_lock_cqs(struct ibv_qp *qp) -{ - struct mlx5_cq *send_cq = to_mcq(qp->send_cq); - struct mlx5_cq *recv_cq = to_mcq(qp->recv_cq); - - if (send_cq && recv_cq) { - if (send_cq == recv_cq) { - mlx5_spin_lock(&send_cq->lock); - } else if (send_cq->cqn < recv_cq->cqn) { - mlx5_spin_lock(&send_cq->lock); - mlx5_spin_lock(&recv_cq->lock); - } else { - mlx5_spin_lock(&recv_cq->lock); - mlx5_spin_lock(&send_cq->lock); - } - } else if (send_cq) { - mlx5_spin_lock(&send_cq->lock); - } else if (recv_cq) { - mlx5_spin_lock(&recv_cq->lock); - } -} - -static void mlx5_unlock_cqs(struct ibv_qp *qp) -{ - struct mlx5_cq *send_cq = to_mcq(qp->send_cq); - struct mlx5_cq *recv_cq = to_mcq(qp->recv_cq); - - if (send_cq && recv_cq) { - if (send_cq == recv_cq) { - mlx5_spin_unlock(&send_cq->lock); - } else if (send_cq->cqn < recv_cq->cqn) { - mlx5_spin_unlock(&recv_cq->lock); - mlx5_spin_unlock(&send_cq->lock); - } else { - mlx5_spin_unlock(&send_cq->lock); - mlx5_spin_unlock(&recv_cq->lock); - } - } else if (send_cq) { - mlx5_spin_unlock(&send_cq->lock); - } else if (recv_cq) { - mlx5_spin_unlock(&recv_cq->lock); - } -} - -int mlx5_destroy_qp(struct ibv_qp *ibqp) -{ - struct mlx5_qp *qp = to_mqp(ibqp); - struct mlx5_context *ctx = to_mctx(ibqp->context); - int ret; - - if (qp->rss_qp) { - ret = ibv_cmd_destroy_qp(ibqp); - if (ret) - return ret; - goto free; - } - - if (!ctx->cqe_version) - pthread_mutex_lock(&ctx->qp_table_mutex); - - ret = ibv_cmd_destroy_qp(ibqp); - if (ret) { - if (!ctx->cqe_version) - pthread_mutex_unlock(&ctx->qp_table_mutex); - return ret; - } - - mlx5_lock_cqs(ibqp); - - __mlx5_cq_clean(to_mcq(ibqp->recv_cq), qp->rsc.rsn, - ibqp->srq ? to_msrq(ibqp->srq) : NULL); - if (ibqp->send_cq != ibqp->recv_cq) - __mlx5_cq_clean(to_mcq(ibqp->send_cq), qp->rsc.rsn, NULL); - - if (!ctx->cqe_version) { - if (qp->sq.wqe_cnt || qp->rq.wqe_cnt) - mlx5_clear_qp(ctx, ibqp->qp_num); - } - - mlx5_unlock_cqs(ibqp); - if (!ctx->cqe_version) - pthread_mutex_unlock(&ctx->qp_table_mutex); - else if (!is_xrc_tgt(ibqp->qp_type)) - mlx5_clear_uidx(ctx, qp->rsc.rsn); - - mlx5_free_db(ctx, qp->db); - mlx5_free_qp_buf(qp); -free: - free(qp); - - return 0; -} - -int mlx5_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - struct mlx5_qp *qp = to_mqp(ibqp); - int ret; - - if (qp->rss_qp) - return ENOSYS; - - ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof(cmd)); - if (ret) - return ret; - - init_attr->cap.max_send_wr = qp->sq.max_post; - init_attr->cap.max_send_sge = qp->sq.max_gs; - init_attr->cap.max_inline_data = qp->max_inline_data; - - attr->cap = init_attr->cap; - - return 0; -} - -enum { - MLX5_MODIFY_QP_EX_ATTR_MASK = IBV_QP_RATE_LIMIT, -}; - -int mlx5_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - struct ibv_modify_qp_ex cmd_ex = {}; - struct ibv_modify_qp_resp_ex resp = {}; - struct mlx5_qp *mqp = to_mqp(qp); - struct mlx5_context *context = to_mctx(qp->context); - int ret; - __be32 *db; - - if (mqp->rss_qp) - return ENOSYS; - - if (mqp->flags & MLX5_QP_FLAGS_USE_UNDERLAY) { - if (attr_mask & ~(IBV_QP_STATE | IBV_QP_CUR_STATE)) - return EINVAL; - - /* Underlay QP is UD over infiniband */ - if (context->cached_device_cap_flags & IBV_DEVICE_UD_IP_CSUM) - mqp->qp_cap_cache |= MLX5_CSUM_SUPPORT_UNDERLAY_UD | - MLX5_RX_CSUM_VALID; - } - - if (attr_mask & IBV_QP_PORT) { - switch (qp->qp_type) { - case IBV_QPT_RAW_PACKET: - if (context->cached_link_layer[attr->port_num - 1] == - IBV_LINK_LAYER_ETHERNET) { - if (context->cached_device_cap_flags & - IBV_DEVICE_RAW_IP_CSUM) - mqp->qp_cap_cache |= - MLX5_CSUM_SUPPORT_RAW_OVER_ETH | - MLX5_RX_CSUM_VALID; - - if (ibv_is_qpt_supported( - context->cached_tso_caps.supported_qpts, - IBV_QPT_RAW_PACKET)) - mqp->max_tso = - context->cached_tso_caps.max_tso; - } - break; - default: - break; - } - } - - if (attr_mask & MLX5_MODIFY_QP_EX_ATTR_MASK) - ret = ibv_cmd_modify_qp_ex(qp, attr, attr_mask, - &cmd_ex, - sizeof(cmd_ex), sizeof(cmd_ex), - &resp, - sizeof(resp), sizeof(resp)); - else - ret = ibv_cmd_modify_qp(qp, attr, attr_mask, - &cmd, sizeof(cmd)); - - if (!ret && - (attr_mask & IBV_QP_STATE) && - attr->qp_state == IBV_QPS_RESET) { - if (qp->recv_cq) { - mlx5_cq_clean(to_mcq(qp->recv_cq), mqp->rsc.rsn, - qp->srq ? to_msrq(qp->srq) : NULL); - } - if (qp->send_cq != qp->recv_cq && qp->send_cq) - mlx5_cq_clean(to_mcq(qp->send_cq), - to_mqp(qp)->rsc.rsn, NULL); - - mlx5_init_qp_indices(mqp); - db = mqp->db; - db[MLX5_RCV_DBR] = 0; - db[MLX5_SND_DBR] = 0; - } - - /* - * When the Raw Packet QP is in INIT state, its RQ - * underneath is already in RDY, which means it can - * receive packets. According to the IB spec, a QP can't - * receive packets until moved to RTR state. To achieve this, - * for Raw Packet QPs, we update the doorbell record - * once the QP is moved to RTR. - */ - if (!ret && - (attr_mask & IBV_QP_STATE) && - attr->qp_state == IBV_QPS_RTR && - (qp->qp_type == IBV_QPT_RAW_PACKET || - mqp->flags & MLX5_QP_FLAGS_USE_UNDERLAY)) { - mlx5_spin_lock(&mqp->rq.lock); - mqp->db[MLX5_RCV_DBR] = htobe32(mqp->rq.head & 0xffff); - mlx5_spin_unlock(&mqp->rq.lock); - } - - return ret; -} - -#define RROCE_UDP_SPORT_MIN 0xC000 -#define RROCE_UDP_SPORT_MAX 0xFFFF -struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - struct mlx5_context *ctx = to_mctx(pd->context); - struct ibv_port_attr port_attr; - struct mlx5_ah *ah; - uint32_t gid_type; - __be32 tmp; - uint8_t grh; - int is_eth; - - if (attr->port_num < 1 || attr->port_num > ctx->num_ports) - return NULL; - - if (ctx->cached_link_layer[attr->port_num - 1]) { - is_eth = ctx->cached_link_layer[attr->port_num - 1] == - IBV_LINK_LAYER_ETHERNET; - } else { - if (ibv_query_port(pd->context, attr->port_num, &port_attr)) - return NULL; - - is_eth = (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET); - } - - if (unlikely((!attr->is_global) && is_eth)) { - errno = EINVAL; - return NULL; - } - - ah = calloc(1, sizeof *ah); - if (!ah) - return NULL; - - if (is_eth) { - if (ibv_query_gid_type(pd->context, attr->port_num, - attr->grh.sgid_index, &gid_type)) - goto err; - - if (gid_type == IBV_GID_TYPE_ROCE_V2) - ah->av.rlid = htobe16(rand() % (RROCE_UDP_SPORT_MAX + 1 - - RROCE_UDP_SPORT_MIN) - + RROCE_UDP_SPORT_MIN); - /* Since RoCE packets must contain GRH, this bit is reserved - * for RoCE and shouldn't be set. - */ - grh = 0; - } else { - ah->av.fl_mlid = attr->src_path_bits & 0x7f; - ah->av.rlid = htobe16(attr->dlid); - grh = 1; - } - ah->av.stat_rate_sl = (attr->static_rate << 4) | attr->sl; - if (attr->is_global) { - ah->av.tclass = attr->grh.traffic_class; - ah->av.hop_limit = attr->grh.hop_limit; - tmp = htobe32((grh << 30) | - ((attr->grh.sgid_index & 0xff) << 20) | - (attr->grh.flow_label & 0xfffff)); - ah->av.grh_gid_fl = tmp; - memcpy(ah->av.rgid, attr->grh.dgid.raw, 16); - } - - if (is_eth) { - if (ctx->cmds_supp_uhw & MLX5_USER_CMDS_SUPP_UHW_CREATE_AH) { - struct mlx5_create_ah_resp resp = {}; - - if (ibv_cmd_create_ah(pd, &ah->ibv_ah, attr, &resp.ibv_resp, sizeof(resp))) - goto err; - - ah->kern_ah = true; - memcpy(ah->av.rmac, resp.dmac, ETHERNET_LL_SIZE); - } else { - uint16_t vid; - - if (ibv_resolve_eth_l2_from_gid(pd->context, attr, - ah->av.rmac, &vid)) - goto err; - } - } - - return &ah->ibv_ah; -err: - free(ah); - return NULL; -} - -int mlx5_destroy_ah(struct ibv_ah *ah) -{ - struct mlx5_ah *mah = to_mah(ah); - int err; - - if (mah->kern_ah) { - err = ibv_cmd_destroy_ah(ah); - if (err) - return err; - } - - free(mah); - return 0; -} - -int mlx5_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - return ibv_cmd_attach_mcast(qp, gid, lid); -} - -int mlx5_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - return ibv_cmd_detach_mcast(qp, gid, lid); -} - -struct ibv_qp *mlx5_create_qp_ex(struct ibv_context *context, - struct ibv_qp_init_attr_ex *attr) -{ - return create_qp(context, attr); -} - -int mlx5_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num) -{ - struct mlx5_srq *msrq = to_msrq(srq); - - *srq_num = msrq->srqn; - - return 0; -} - -struct ibv_xrcd * -mlx5_open_xrcd(struct ibv_context *context, - struct ibv_xrcd_init_attr *xrcd_init_attr) -{ - int err; - struct verbs_xrcd *xrcd; - struct ibv_open_xrcd cmd = {}; - struct ibv_open_xrcd_resp resp = {}; - - xrcd = calloc(1, sizeof(*xrcd)); - if (!xrcd) - return NULL; - - err = ibv_cmd_open_xrcd(context, xrcd, sizeof(*xrcd), xrcd_init_attr, - &cmd, sizeof(cmd), &resp, sizeof(resp)); - if (err) { - free(xrcd); - return NULL; - } - - return &xrcd->xrcd; -} - -int mlx5_close_xrcd(struct ibv_xrcd *ib_xrcd) -{ - struct verbs_xrcd *xrcd = container_of(ib_xrcd, struct verbs_xrcd, xrcd); - int ret; - - ret = ibv_cmd_close_xrcd(xrcd); - if (!ret) - free(xrcd); - - return ret; -} - -static struct ibv_srq * -mlx5_create_xrc_srq(struct ibv_context *context, - struct ibv_srq_init_attr_ex *attr) -{ - int err; - struct mlx5_create_srq_ex cmd; - struct mlx5_create_srq_resp resp; - struct mlx5_srq *msrq; - struct mlx5_context *ctx = to_mctx(context); - int max_sge; - struct ibv_srq *ibsrq; - int uidx; - FILE *fp = ctx->dbg_fp; - - msrq = calloc(1, sizeof(*msrq)); - if (!msrq) - return NULL; - - ibsrq = (struct ibv_srq *)&msrq->vsrq; - - memset(&cmd, 0, sizeof(cmd)); - memset(&resp, 0, sizeof(resp)); - - if (mlx5_spinlock_init(&msrq->lock)) { - fprintf(stderr, "%s-%d:\n", __func__, __LINE__); - goto err; - } - - if (attr->attr.max_wr > ctx->max_srq_recv_wr) { - fprintf(stderr, "%s-%d:max_wr %d, max_srq_recv_wr %d\n", - __func__, __LINE__, attr->attr.max_wr, - ctx->max_srq_recv_wr); - errno = EINVAL; - goto err; - } - - /* - * this calculation does not consider required control segments. The - * final calculation is done again later. This is done so to avoid - * overflows of variables - */ - max_sge = ctx->max_recv_wr / sizeof(struct mlx5_wqe_data_seg); - if (attr->attr.max_sge > max_sge) { - fprintf(stderr, "%s-%d:max_wr %d, max_srq_recv_wr %d\n", - __func__, __LINE__, attr->attr.max_wr, - ctx->max_srq_recv_wr); - errno = EINVAL; - goto err; - } - - msrq->max = align_queue_size(attr->attr.max_wr + 1); - msrq->max_gs = attr->attr.max_sge; - msrq->counter = 0; - - if (mlx5_alloc_srq_buf(context, msrq)) { - fprintf(stderr, "%s-%d:\n", __func__, __LINE__); - goto err; - } - - msrq->db = mlx5_alloc_dbrec(ctx); - if (!msrq->db) { - fprintf(stderr, "%s-%d:\n", __func__, __LINE__); - goto err_free; - } - - *msrq->db = 0; - - cmd.buf_addr = (uintptr_t)msrq->buf.buf; - cmd.db_addr = (uintptr_t)msrq->db; - msrq->wq_sig = srq_sig_enabled(); - if (msrq->wq_sig) - cmd.flags = MLX5_SRQ_FLAG_SIGNATURE; - - attr->attr.max_sge = msrq->max_gs; - if (ctx->cqe_version) { - uidx = mlx5_store_uidx(ctx, msrq); - if (uidx < 0) { - mlx5_dbg(fp, MLX5_DBG_QP, "Couldn't find free user index\n"); - goto err_free_db; - } - cmd.uidx = uidx; - } else { - cmd.uidx = 0xffffff; - pthread_mutex_lock(&ctx->srq_table_mutex); - } - - err = ibv_cmd_create_srq_ex(context, &msrq->vsrq, sizeof(msrq->vsrq), - attr, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (err) - goto err_free_uidx; - - if (!ctx->cqe_version) { - err = mlx5_store_srq(to_mctx(context), resp.srqn, msrq); - if (err) - goto err_destroy; - - pthread_mutex_unlock(&ctx->srq_table_mutex); - } - - msrq->srqn = resp.srqn; - msrq->rsc.type = MLX5_RSC_TYPE_XSRQ; - msrq->rsc.rsn = ctx->cqe_version ? cmd.uidx : resp.srqn; - - return ibsrq; - -err_destroy: - ibv_cmd_destroy_srq(ibsrq); - -err_free_uidx: - if (ctx->cqe_version) - mlx5_clear_uidx(ctx, cmd.uidx); - else - pthread_mutex_unlock(&ctx->srq_table_mutex); - -err_free_db: - mlx5_free_db(ctx, msrq->db); - -err_free: - free(msrq->wrid); - mlx5_free_buf(&msrq->buf); - -err: - free(msrq); - - return NULL; -} - -struct ibv_srq *mlx5_create_srq_ex(struct ibv_context *context, - struct ibv_srq_init_attr_ex *attr) -{ - if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) || - (attr->srq_type == IBV_SRQT_BASIC)) - return mlx5_create_srq(attr->pd, - (struct ibv_srq_init_attr *)attr); - else if (attr->srq_type == IBV_SRQT_XRC) - return mlx5_create_xrc_srq(context, attr); - - return NULL; -} - -int mlx5_query_device_ex(struct ibv_context *context, - const struct ibv_query_device_ex_input *input, - struct ibv_device_attr_ex *attr, - size_t attr_size) -{ - struct mlx5_context *mctx = to_mctx(context); - struct mlx5_query_device_ex_resp resp; - struct mlx5_query_device_ex cmd; - struct ibv_device_attr *a; - uint64_t raw_fw_ver; - unsigned sub_minor; - unsigned major; - unsigned minor; - int err; - int cmd_supp_uhw = mctx->cmds_supp_uhw & - MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE; - - memset(&cmd, 0, sizeof(cmd)); - memset(&resp, 0, sizeof(resp)); - err = ibv_cmd_query_device_ex(context, input, attr, attr_size, - &raw_fw_ver, - &cmd.ibv_cmd, sizeof(cmd.ibv_cmd), sizeof(cmd), - &resp.ibv_resp, sizeof(resp.ibv_resp), - cmd_supp_uhw ? sizeof(resp) : sizeof(resp.ibv_resp)); - if (err) - return err; - - attr->tso_caps = resp.tso_caps; - attr->rss_caps.rx_hash_fields_mask = resp.rss_caps.rx_hash_fields_mask; - attr->rss_caps.rx_hash_function = resp.rss_caps.rx_hash_function; - attr->packet_pacing_caps = resp.packet_pacing_caps.caps; - - if (resp.support_multi_pkt_send_wqe & MLX5_ALLOW_MPW) - mctx->vendor_cap_flags |= MLX5_VENDOR_CAP_FLAGS_MPW_ALLOWED; - - if (resp.support_multi_pkt_send_wqe & MLX5_SUPPORT_EMPW) - mctx->vendor_cap_flags |= MLX5_VENDOR_CAP_FLAGS_ENHANCED_MPW; - - mctx->cqe_comp_caps = resp.cqe_comp_caps; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - a = &attr->orig_attr; - snprintf(a->fw_ver, sizeof(a->fw_ver), "%d.%d.%04d", - major, minor, sub_minor); - - return 0; -} - -static int rwq_sig_enabled(struct ibv_context *context) -{ - char *env; - - env = getenv("MLX5_RWQ_SIGNATURE"); - if (env) - return 1; - - return 0; -} - -static void mlx5_free_rwq_buf(struct mlx5_rwq *rwq, struct ibv_context *context) -{ - struct mlx5_context *ctx = to_mctx(context); - - mlx5_free_actual_buf(ctx, &rwq->buf); - free(rwq->rq.wrid); -} - -static int mlx5_alloc_rwq_buf(struct ibv_context *context, - struct mlx5_rwq *rwq, - int size) -{ - int err; - enum mlx5_alloc_type alloc_type; - - mlx5_get_alloc_type(to_mctx(context), MLX5_RWQ_PREFIX, - &alloc_type, MLX5_ALLOC_TYPE_ANON); - - rwq->rq.wrid = malloc(rwq->rq.wqe_cnt * sizeof(uint64_t)); - if (!rwq->rq.wrid) { - errno = ENOMEM; - return -1; - } - - err = mlx5_alloc_prefered_buf(to_mctx(context), &rwq->buf, - align(rwq->buf_size, to_mdev - (context->device)->page_size), - to_mdev(context->device)->page_size, - alloc_type, - MLX5_RWQ_PREFIX); - - if (err) { - free(rwq->rq.wrid); - errno = ENOMEM; - return -1; - } - - return 0; -} - -struct ibv_wq *mlx5_create_wq(struct ibv_context *context, - struct ibv_wq_init_attr *attr) -{ - struct mlx5_create_wq cmd; - struct mlx5_create_wq_resp resp; - int err; - struct mlx5_rwq *rwq; - struct mlx5_context *ctx = to_mctx(context); - int ret; - int32_t usr_idx = 0; - FILE *fp = ctx->dbg_fp; - - if (attr->wq_type != IBV_WQT_RQ) - return NULL; - - memset(&cmd, 0, sizeof(cmd)); - memset(&resp, 0, sizeof(resp)); - - rwq = calloc(1, sizeof(*rwq)); - if (!rwq) - return NULL; - - rwq->wq_sig = rwq_sig_enabled(context); - if (rwq->wq_sig) - cmd.drv.flags = MLX5_RWQ_FLAG_SIGNATURE; - - ret = mlx5_calc_rwq_size(ctx, rwq, attr); - if (ret < 0) { - errno = -ret; - goto err; - } - - rwq->buf_size = ret; - if (mlx5_alloc_rwq_buf(context, rwq, ret)) - goto err; - - mlx5_init_rwq_indices(rwq); - - if (mlx5_spinlock_init(&rwq->rq.lock)) - goto err_free_rwq_buf; - - rwq->db = mlx5_alloc_dbrec(ctx); - if (!rwq->db) - goto err_free_rwq_buf; - - rwq->db[MLX5_RCV_DBR] = 0; - rwq->db[MLX5_SND_DBR] = 0; - rwq->pbuff = rwq->buf.buf + rwq->rq.offset; - rwq->recv_db = &rwq->db[MLX5_RCV_DBR]; - cmd.drv.buf_addr = (uintptr_t)rwq->buf.buf; - cmd.drv.db_addr = (uintptr_t)rwq->db; - cmd.drv.rq_wqe_count = rwq->rq.wqe_cnt; - cmd.drv.rq_wqe_shift = rwq->rq.wqe_shift; - usr_idx = mlx5_store_uidx(ctx, rwq); - if (usr_idx < 0) { - mlx5_dbg(fp, MLX5_DBG_QP, "Couldn't find free user index\n"); - goto err_free_db_rec; - } - - cmd.drv.user_index = usr_idx; - err = ibv_cmd_create_wq(context, attr, &rwq->wq, &cmd.ibv_cmd, - sizeof(cmd.ibv_cmd), - sizeof(cmd), - &resp.ibv_resp, sizeof(resp.ibv_resp), - sizeof(resp)); - if (err) - goto err_create; - - rwq->rsc.type = MLX5_RSC_TYPE_RWQ; - rwq->rsc.rsn = cmd.drv.user_index; - - rwq->wq.post_recv = mlx5_post_wq_recv; - return &rwq->wq; - -err_create: - mlx5_clear_uidx(ctx, cmd.drv.user_index); -err_free_db_rec: - mlx5_free_db(to_mctx(context), rwq->db); -err_free_rwq_buf: - mlx5_free_rwq_buf(rwq, context); -err: - free(rwq); - return NULL; -} - -int mlx5_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr) -{ - struct mlx5_modify_wq cmd = {}; - struct mlx5_rwq *rwq = to_mrwq(wq); - - if ((attr->attr_mask & IBV_WQ_ATTR_STATE) && - attr->wq_state == IBV_WQS_RDY) { - if ((attr->attr_mask & IBV_WQ_ATTR_CURR_STATE) && - attr->curr_wq_state != wq->state) - return -EINVAL; - - if (wq->state == IBV_WQS_RESET) { - mlx5_spin_lock(&to_mcq(wq->cq)->lock); - __mlx5_cq_clean(to_mcq(wq->cq), - rwq->rsc.rsn, NULL); - mlx5_spin_unlock(&to_mcq(wq->cq)->lock); - mlx5_init_rwq_indices(rwq); - rwq->db[MLX5_RCV_DBR] = 0; - rwq->db[MLX5_SND_DBR] = 0; - } - } - - return ibv_cmd_modify_wq(wq, attr, &cmd.ibv_cmd, sizeof(cmd.ibv_cmd), sizeof(cmd)); -} - -int mlx5_destroy_wq(struct ibv_wq *wq) -{ - struct mlx5_rwq *rwq = to_mrwq(wq); - int ret; - - ret = ibv_cmd_destroy_wq(wq); - if (ret) - return ret; - - mlx5_spin_lock(&to_mcq(wq->cq)->lock); - __mlx5_cq_clean(to_mcq(wq->cq), rwq->rsc.rsn, NULL); - mlx5_spin_unlock(&to_mcq(wq->cq)->lock); - mlx5_clear_uidx(to_mctx(wq->context), rwq->rsc.rsn); - mlx5_free_db(to_mctx(wq->context), rwq->db); - mlx5_free_rwq_buf(rwq, wq->context); - free(rwq); - - return 0; -} - -struct ibv_rwq_ind_table *mlx5_create_rwq_ind_table(struct ibv_context *context, - struct ibv_rwq_ind_table_init_attr *init_attr) -{ - struct ibv_create_rwq_ind_table *cmd; - struct mlx5_create_rwq_ind_table_resp resp; - struct ibv_rwq_ind_table *ind_table; - uint32_t required_tbl_size; - int num_tbl_entries; - int cmd_size; - int err; - - num_tbl_entries = 1 << init_attr->log_ind_tbl_size; - /* Data must be u64 aligned */ - required_tbl_size = (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ? - sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t)); - - cmd_size = required_tbl_size + sizeof(*cmd); - cmd = calloc(1, cmd_size); - if (!cmd) - return NULL; - - memset(&resp, 0, sizeof(resp)); - ind_table = calloc(1, sizeof(*ind_table)); - if (!ind_table) - goto free_cmd; - - err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, cmd, - cmd_size, cmd_size, &resp.ibv_resp, sizeof(resp.ibv_resp), - sizeof(resp)); - if (err) - goto err; - - free(cmd); - return ind_table; - -err: - free(ind_table); -free_cmd: - free(cmd); - return NULL; -} - -int mlx5_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table) -{ - int ret; - - ret = ibv_cmd_destroy_rwq_ind_table(rwq_ind_table); - - if (ret) - return ret; - - free(rwq_ind_table); - return 0; -} diff --git a/usr/rdma-core/providers/mlx5/wqe.h b/usr/rdma-core/providers/mlx5/wqe.h deleted file mode 100644 index 5bf536cab..000000000 --- a/usr/rdma-core/providers/mlx5/wqe.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef WQE_H -#define WQE_H - -#include - -struct mlx5_sg_copy_ptr { - int index; - int offset; -}; - -struct mlx5_eqe_comp { - uint32_t reserved[6]; - uint32_t cqn; -}; - -struct mlx5_eqe_qp_srq { - uint32_t reserved[6]; - uint32_t qp_srq_n; -}; - -struct mlx5_wqe_eth_pad { - uint8_t rsvd0[16]; -}; - -struct mlx5_wqe_xrc_seg { - __be32 xrc_srqn; - uint8_t rsvd[12]; -}; - -struct mlx5_wqe_masked_atomic_seg { - uint64_t swap_add; - uint64_t compare; - uint64_t swap_add_mask; - uint64_t compare_mask; -}; - -enum { - MLX5_IPOIB_INLINE_MIN_HEADER_SIZE = 4, - MLX5_SOURCE_QPN_INLINE_MAX_HEADER_SIZE = 18, - MLX5_ETH_L2_INLINE_HEADER_SIZE = 18, - MLX5_ETH_L2_MIN_HEADER_SIZE = 14, -}; - -enum { - MLX5_WQE_UMR_CTRL_FLAG_INLINE = 1 << 7, - MLX5_WQE_UMR_CTRL_FLAG_CHECK_FREE = 1 << 5, - MLX5_WQE_UMR_CTRL_FLAG_TRNSLATION_OFFSET = 1 << 4, - MLX5_WQE_UMR_CTRL_FLAG_CHECK_QPN = 1 << 3, -}; - -enum { - MLX5_WQE_UMR_CTRL_MKEY_MASK_LEN = 1 << 0, - MLX5_WQE_UMR_CTRL_MKEY_MASK_START_ADDR = 1 << 6, - MLX5_WQE_UMR_CTRL_MKEY_MASK_MKEY = 1 << 13, - MLX5_WQE_UMR_CTRL_MKEY_MASK_QPN = 1 << 14, - MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_LOCAL_WRITE = 1 << 18, - MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_REMOTE_READ = 1 << 19, - MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_REMOTE_WRITE = 1 << 20, - MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_ATOMIC = 1 << 21, - MLX5_WQE_UMR_CTRL_MKEY_MASK_FREE = 1 << 29, -}; - -struct mlx5_wqe_umr_ctrl_seg { - uint8_t flags; - uint8_t rsvd0[3]; - __be16 klm_octowords; - __be16 translation_offset; - __be64 mkey_mask; - uint8_t rsvd1[32]; -}; - -struct mlx5_wqe_umr_klm_seg { - /* up to 2GB */ - __be32 byte_count; - __be32 mkey; - __be64 address; -}; - -union mlx5_wqe_umr_inline_seg { - struct mlx5_wqe_umr_klm_seg klm; -}; - -enum { - MLX5_WQE_MKEY_CONTEXT_FREE = 1 << 6 -}; - -enum { - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_ATOMIC = 1 << 6, - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_REMOTE_WRITE = 1 << 5, - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_REMOTE_READ = 1 << 4, - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_LOCAL_WRITE = 1 << 3, - MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_LOCAL_READ = 1 << 2 -}; - -struct mlx5_wqe_mkey_context_seg { - uint8_t free; - uint8_t reserved1; - uint8_t access_flags; - uint8_t sf; - __be32 qpn_mkey; - __be32 reserved2; - __be32 flags_pd; - __be64 start_addr; - __be64 len; - __be32 bsf_octword_size; - __be32 reserved3[4]; - __be32 translations_octword_size; - uint8_t reserved4[3]; - uint8_t log_page_size; - __be32 reserved; - union mlx5_wqe_umr_inline_seg inseg[0]; -}; - -struct mlx5_seg_set_psv { - uint8_t rsvd[4]; - uint16_t syndrome; - uint16_t status; - uint16_t block_guard; - uint16_t app_tag; - uint32_t ref_tag; - uint32_t mkey; - uint64_t va; -}; - -struct mlx5_seg_get_psv { - uint8_t rsvd[19]; - uint8_t num_psv; - uint32_t l_key; - uint64_t va; - uint32_t psv_index[4]; -}; - -struct mlx5_seg_check_psv { - uint8_t rsvd0[2]; - uint16_t err_coalescing_op; - uint8_t rsvd1[2]; - uint16_t xport_err_op; - uint8_t rsvd2[2]; - uint16_t xport_err_mask; - uint8_t rsvd3[7]; - uint8_t num_psv; - uint32_t l_key; - uint64_t va; - uint32_t psv_index[4]; -}; - -struct mlx5_rwqe_sig { - uint8_t rsvd0[4]; - uint8_t signature; - uint8_t rsvd1[11]; -}; - -struct mlx5_wqe_signature_seg { - uint8_t rsvd0[4]; - uint8_t signature; - uint8_t rsvd1[11]; -}; - -struct mlx5_wqe_inline_seg { - __be32 byte_count; -}; - - -#endif /* WQE_H */ diff --git a/usr/rdma-core/providers/mthca/CMakeLists.txt b/usr/rdma-core/providers/mthca/CMakeLists.txt deleted file mode 100644 index 63d714704..000000000 --- a/usr/rdma-core/providers/mthca/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -rdma_provider(mthca - ah.c - buf.c - cq.c - memfree.c - mthca.c - qp.c - srq.c - verbs.c -) diff --git a/usr/rdma-core/providers/mthca/ah.c b/usr/rdma-core/providers/mthca/ah.c deleted file mode 100644 index 625e3b8a9..000000000 --- a/usr/rdma-core/providers/mthca/ah.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include - -#include "mthca.h" - -struct mthca_ah_page { - struct mthca_ah_page *prev, *next; - struct mthca_buf buf; - struct ibv_mr *mr; - int use_cnt; - unsigned free[0]; -}; - -static struct mthca_ah_page *__add_page(struct mthca_pd *pd, int page_size, int per_page) -{ - struct mthca_ah_page *page; - int i; - - page = malloc(sizeof *page + per_page * sizeof (int)); - if (!page) - return NULL; - - if (mthca_alloc_buf(&page->buf, page_size, page_size)) { - free(page); - return NULL; - } - - page->mr = mthca_reg_mr(&pd->ibv_pd, page->buf.buf, page_size, 0); - if (!page->mr) { - mthca_free_buf(&page->buf); - free(page); - return NULL; - } - - page->mr->context = pd->ibv_pd.context; - - page->use_cnt = 0; - for (i = 0; i < per_page; ++i) - page->free[i] = ~0; - - page->prev = NULL; - page->next = pd->ah_list; - pd->ah_list = page; - if (page->next) - page->next->prev = page; - - return page; -} - -int mthca_alloc_av(struct mthca_pd *pd, struct ibv_ah_attr *attr, - struct mthca_ah *ah) -{ - if (mthca_is_memfree(pd->ibv_pd.context)) { - ah->av = malloc(sizeof *ah->av); - if (!ah->av) - return -1; - } else { - struct mthca_ah_page *page; - int ps; - int pp; - int i, j; - - ps = to_mdev(pd->ibv_pd.context->device)->page_size; - pp = ps / (sizeof *ah->av * 8 * sizeof (int)); - - pthread_mutex_lock(&pd->ah_mutex); - for (page = pd->ah_list; page; page = page->next) - if (page->use_cnt < ps / sizeof *ah->av) - for (i = 0; i < pp; ++i) - if (page->free[i]) - goto found; - - page = __add_page(pd, ps, pp); - if (!page) { - pthread_mutex_unlock(&pd->ah_mutex); - return -1; - } - - found: - ++page->use_cnt; - - for (i = 0, j = -1; i < pp; ++i) - if (page->free[i]) { - j = ffs(page->free[i]); - page->free[i] &= ~(1 << (j - 1)); - ah->av = page->buf.buf + - (i * 8 * sizeof (int) + (j - 1)) * sizeof *ah->av; - break; - } - - ah->key = page->mr->lkey; - ah->page = page; - - pthread_mutex_unlock(&pd->ah_mutex); - } - - memset(ah->av, 0, sizeof *ah->av); - - ah->av->port_pd = htobe32(pd->pdn | (attr->port_num << 24)); - ah->av->g_slid = attr->src_path_bits; - ah->av->dlid = htobe16(attr->dlid); - ah->av->msg_sr = (3 << 4) | /* 2K message */ - attr->static_rate; - ah->av->sl_tclass_flowlabel = htobe32(attr->sl << 28); - if (attr->is_global) { - ah->av->g_slid |= 0x80; - /* XXX get gid_table length */ - ah->av->gid_index = (attr->port_num - 1) * 32 + - attr->grh.sgid_index; - ah->av->hop_limit = attr->grh.hop_limit; - ah->av->sl_tclass_flowlabel |= - htobe32((attr->grh.traffic_class << 20) | - attr->grh.flow_label); - memcpy(ah->av->dgid, attr->grh.dgid.raw, 16); - } else { - /* Arbel workaround -- low byte of GID must be 2 */ - ah->av->dgid[3] = htobe32(2); - } - - return 0; -} - -void mthca_free_av(struct mthca_ah *ah) -{ - if (mthca_is_memfree(ah->ibv_ah.context)) { - free(ah->av); - } else { - struct mthca_pd *pd = to_mpd(ah->ibv_ah.pd); - struct mthca_ah_page *page; - int i; - - pthread_mutex_lock(&pd->ah_mutex); - - page = ah->page; - i = ((void *) ah->av - page->buf.buf) / sizeof *ah->av; - page->free[i / (8 * sizeof (int))] |= 1 << (i % (8 * sizeof (int))); - - if (!--page->use_cnt) { - if (page->prev) - page->prev->next = page->next; - else - pd->ah_list = page->next; - if (page->next) - page->next->prev = page->prev; - - mthca_dereg_mr(page->mr); - mthca_free_buf(&page->buf); - free(page); - } - - pthread_mutex_unlock(&pd->ah_mutex); - } -} diff --git a/usr/rdma-core/providers/mthca/buf.c b/usr/rdma-core/providers/mthca/buf.c deleted file mode 100644 index c03ee1f9a..000000000 --- a/usr/rdma-core/providers/mthca/buf.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include - -#include "mthca.h" - -int mthca_alloc_buf(struct mthca_buf *buf, size_t size, int page_size) -{ - int ret; - - buf->length = align(size, page_size); - buf->buf = mmap(NULL, buf->length, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (buf->buf == MAP_FAILED) - return errno; - - ret = ibv_dontfork_range(buf->buf, size); - if (ret) - munmap(buf->buf, buf->length); - - return ret; -} - -void mthca_free_buf(struct mthca_buf *buf) -{ - ibv_dofork_range(buf->buf, buf->length); - munmap(buf->buf, buf->length); -} diff --git a/usr/rdma-core/providers/mthca/cq.c b/usr/rdma-core/providers/mthca/cq.c deleted file mode 100644 index dd8baca19..000000000 --- a/usr/rdma-core/providers/mthca/cq.c +++ /dev/null @@ -1,627 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2006 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include - -#include - -#include "mthca.h" -#include "doorbell.h" - -enum { - MTHCA_CQ_DOORBELL = 0x20 -}; - -enum { - CQ_OK = 0, - CQ_EMPTY = -1, - CQ_POLL_ERR = -2 -}; - -#define MTHCA_TAVOR_CQ_DB_INC_CI (1 << 24) -#define MTHCA_TAVOR_CQ_DB_REQ_NOT (2 << 24) -#define MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL (3 << 24) -#define MTHCA_TAVOR_CQ_DB_SET_CI (4 << 24) -#define MTHCA_TAVOR_CQ_DB_REQ_NOT_MULT (5 << 24) - -#define MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL (1 << 24) -#define MTHCA_ARBEL_CQ_DB_REQ_NOT (2 << 24) -#define MTHCA_ARBEL_CQ_DB_REQ_NOT_MULT (3 << 24) - -enum { - MTHCA_CQ_ENTRY_OWNER_SW = 0x00, - MTHCA_CQ_ENTRY_OWNER_HW = 0x80, - MTHCA_ERROR_CQE_OPCODE_MASK = 0xfe -}; - -enum { - SYNDROME_LOCAL_LENGTH_ERR = 0x01, - SYNDROME_LOCAL_QP_OP_ERR = 0x02, - SYNDROME_LOCAL_EEC_OP_ERR = 0x03, - SYNDROME_LOCAL_PROT_ERR = 0x04, - SYNDROME_WR_FLUSH_ERR = 0x05, - SYNDROME_MW_BIND_ERR = 0x06, - SYNDROME_BAD_RESP_ERR = 0x10, - SYNDROME_LOCAL_ACCESS_ERR = 0x11, - SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12, - SYNDROME_REMOTE_ACCESS_ERR = 0x13, - SYNDROME_REMOTE_OP_ERR = 0x14, - SYNDROME_RETRY_EXC_ERR = 0x15, - SYNDROME_RNR_RETRY_EXC_ERR = 0x16, - SYNDROME_LOCAL_RDD_VIOL_ERR = 0x20, - SYNDROME_REMOTE_INVAL_RD_REQ_ERR = 0x21, - SYNDROME_REMOTE_ABORTED_ERR = 0x22, - SYNDROME_INVAL_EECN_ERR = 0x23, - SYNDROME_INVAL_EEC_STATE_ERR = 0x24 -}; - -struct mthca_cqe { - __be32 my_qpn; - __be32 my_ee; - __be32 rqpn; - __be16 sl_g_mlpath; - __be16 rlid; - __be32 imm_etype_pkey_eec; - __be32 byte_cnt; - __be32 wqe; - uint8_t opcode; - uint8_t is_send; - uint8_t reserved; - uint8_t owner; -}; - -struct mthca_err_cqe { - __be32 my_qpn; - __be32 reserved1[3]; - uint8_t syndrome; - uint8_t vendor_err; - __be16 db_cnt; - __be32 reserved2; - __be32 wqe; - uint8_t opcode; - uint8_t reserved3[2]; - uint8_t owner; -}; - -static inline struct mthca_cqe *get_cqe(struct mthca_cq *cq, int entry) -{ - return cq->buf.buf + entry * MTHCA_CQ_ENTRY_SIZE; -} - -static inline struct mthca_cqe *cqe_sw(struct mthca_cq *cq, int i) -{ - struct mthca_cqe *cqe = get_cqe(cq, i); - return MTHCA_CQ_ENTRY_OWNER_HW & cqe->owner ? NULL : cqe; -} - -static inline struct mthca_cqe *next_cqe_sw(struct mthca_cq *cq) -{ - return cqe_sw(cq, cq->cons_index & cq->ibv_cq.cqe); -} - -static inline void set_cqe_hw(struct mthca_cqe *cqe) -{ - VALGRIND_MAKE_MEM_UNDEFINED(cqe, sizeof *cqe); - cqe->owner = MTHCA_CQ_ENTRY_OWNER_HW; -} - -/* - * incr is ignored in native Arbel (mem-free) mode, so cq->cons_index - * should be correct before calling update_cons_index(). - */ -static inline void update_cons_index(struct mthca_cq *cq, int incr) -{ - uint32_t doorbell[2]; - - if (mthca_is_memfree(cq->ibv_cq.context)) { - *cq->set_ci_db = htobe32(cq->cons_index); - mmio_ordered_writes_hack(); - } else { - doorbell[0] = MTHCA_TAVOR_CQ_DB_INC_CI | cq->cqn; - doorbell[1] = incr - 1; - - mthca_write64(doorbell, to_mctx(cq->ibv_cq.context)->uar + MTHCA_CQ_DOORBELL); - } -} - -static void dump_cqe(void *cqe_ptr) -{ - __be32 *cqe = cqe_ptr; - int i; - - for (i = 0; i < 8; ++i) - printf(" [%2x] %08x\n", i * 4, be32toh(cqe[i])); -} - -static int handle_error_cqe(struct mthca_cq *cq, - struct mthca_qp *qp, int wqe_index, int is_send, - struct mthca_err_cqe *cqe, - struct ibv_wc *wc, int *free_cqe) -{ - int err; - int dbd; - __be32 new_wqe; - - if (cqe->syndrome == SYNDROME_LOCAL_QP_OP_ERR) { - printf("local QP operation err " - "(QPN %06x, WQE @ %08x, CQN %06x, index %d)\n", - be32toh(cqe->my_qpn), be32toh(cqe->wqe), - cq->cqn, cq->cons_index); - dump_cqe(cqe); - } - - /* - * For completions in error, only work request ID, status, vendor error - * (and freed resource count for RD) have to be set. - */ - switch (cqe->syndrome) { - case SYNDROME_LOCAL_LENGTH_ERR: - wc->status = IBV_WC_LOC_LEN_ERR; - break; - case SYNDROME_LOCAL_QP_OP_ERR: - wc->status = IBV_WC_LOC_QP_OP_ERR; - break; - case SYNDROME_LOCAL_EEC_OP_ERR: - wc->status = IBV_WC_LOC_EEC_OP_ERR; - break; - case SYNDROME_LOCAL_PROT_ERR: - wc->status = IBV_WC_LOC_PROT_ERR; - break; - case SYNDROME_WR_FLUSH_ERR: - wc->status = IBV_WC_WR_FLUSH_ERR; - break; - case SYNDROME_MW_BIND_ERR: - wc->status = IBV_WC_MW_BIND_ERR; - break; - case SYNDROME_BAD_RESP_ERR: - wc->status = IBV_WC_BAD_RESP_ERR; - break; - case SYNDROME_LOCAL_ACCESS_ERR: - wc->status = IBV_WC_LOC_ACCESS_ERR; - break; - case SYNDROME_REMOTE_INVAL_REQ_ERR: - wc->status = IBV_WC_REM_INV_REQ_ERR; - break; - case SYNDROME_REMOTE_ACCESS_ERR: - wc->status = IBV_WC_REM_ACCESS_ERR; - break; - case SYNDROME_REMOTE_OP_ERR: - wc->status = IBV_WC_REM_OP_ERR; - break; - case SYNDROME_RETRY_EXC_ERR: - wc->status = IBV_WC_RETRY_EXC_ERR; - break; - case SYNDROME_RNR_RETRY_EXC_ERR: - wc->status = IBV_WC_RNR_RETRY_EXC_ERR; - break; - case SYNDROME_LOCAL_RDD_VIOL_ERR: - wc->status = IBV_WC_LOC_RDD_VIOL_ERR; - break; - case SYNDROME_REMOTE_INVAL_RD_REQ_ERR: - wc->status = IBV_WC_REM_INV_RD_REQ_ERR; - break; - case SYNDROME_REMOTE_ABORTED_ERR: - wc->status = IBV_WC_REM_ABORT_ERR; - break; - case SYNDROME_INVAL_EECN_ERR: - wc->status = IBV_WC_INV_EECN_ERR; - break; - case SYNDROME_INVAL_EEC_STATE_ERR: - wc->status = IBV_WC_INV_EEC_STATE_ERR; - break; - default: - wc->status = IBV_WC_GENERAL_ERR; - break; - } - - wc->vendor_err = cqe->vendor_err; - - /* - * Mem-free HCAs always generate one CQE per WQE, even in the - * error case, so we don't have to check the doorbell count, etc. - */ - if (mthca_is_memfree(cq->ibv_cq.context)) - return 0; - - err = mthca_free_err_wqe(qp, is_send, wqe_index, &dbd, &new_wqe); - if (err) - return err; - - /* - * If we're at the end of the WQE chain, or we've used up our - * doorbell count, free the CQE. Otherwise just update it for - * the next poll operation. - * - * This doesn't apply to mem-free HCAs, which never use the - * doorbell count field. In that case we always free the CQE. - */ - if (mthca_is_memfree(cq->ibv_cq.context) || - !(new_wqe & htobe32(0x3f)) || (!cqe->db_cnt && dbd)) - return 0; - - cqe->db_cnt = htobe16(be16toh(cqe->db_cnt) - dbd); - cqe->wqe = new_wqe; - cqe->syndrome = SYNDROME_WR_FLUSH_ERR; - - *free_cqe = 0; - - return 0; -} - -static inline int mthca_poll_one(struct mthca_cq *cq, - struct mthca_qp **cur_qp, - int *freed, - struct ibv_wc *wc) -{ - struct mthca_wq *wq; - struct mthca_cqe *cqe; - struct mthca_srq *srq; - uint32_t qpn; - int wqe_index; - int is_error; - int is_send; - int free_cqe = 1; - int err = 0; - - cqe = next_cqe_sw(cq); - if (!cqe) - return CQ_EMPTY; - - VALGRIND_MAKE_MEM_DEFINED(cqe, sizeof *cqe); - - /* - * Make sure we read CQ entry contents after we've checked the - * ownership bit. - */ - udma_from_device_barrier(); - - qpn = be32toh(cqe->my_qpn); - - is_error = (cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) == - MTHCA_ERROR_CQE_OPCODE_MASK; - is_send = is_error ? cqe->opcode & 0x01 : cqe->is_send & 0x80; - - if (!*cur_qp || qpn != (*cur_qp)->ibv_qp.qp_num) { - /* - * We do not have to take the QP table lock here, - * because CQs will be locked while QPs are removed - * from the table. - */ - *cur_qp = mthca_find_qp(to_mctx(cq->ibv_cq.context), qpn); - if (!*cur_qp) { - err = CQ_POLL_ERR; - goto out; - } - } - - wc->qp_num = (*cur_qp)->ibv_qp.qp_num; - - if (is_send) { - wq = &(*cur_qp)->sq; - wqe_index = ((be32toh(cqe->wqe) - (*cur_qp)->send_wqe_offset) >> wq->wqe_shift); - wc->wr_id = (*cur_qp)->wrid[wqe_index + (*cur_qp)->rq.max]; - } else if ((*cur_qp)->ibv_qp.srq) { - uint32_t wqe; - srq = to_msrq((*cur_qp)->ibv_qp.srq); - wqe = be32toh(cqe->wqe); - wq = NULL; - wqe_index = wqe >> srq->wqe_shift; - wc->wr_id = srq->wrid[wqe_index]; - mthca_free_srq_wqe(srq, wqe_index); - } else { - int32_t wqe; - wq = &(*cur_qp)->rq; - wqe = be32toh(cqe->wqe); - wqe_index = wqe >> wq->wqe_shift; - /* - * WQE addr == base - 1 might be reported by Sinai FW - * 1.0.800 and Arbel FW 5.1.400 in receive completion - * with error instead of (rq size - 1). This bug - * should be fixed in later FW revisions. - */ - if (wqe_index < 0) - wqe_index = wq->max - 1; - wc->wr_id = (*cur_qp)->wrid[wqe_index]; - } - - if (wq) { - if (wq->last_comp < wqe_index) - wq->tail += wqe_index - wq->last_comp; - else - wq->tail += wqe_index + wq->max - wq->last_comp; - - wq->last_comp = wqe_index; - } - - if (is_error) { - err = handle_error_cqe(cq, *cur_qp, wqe_index, is_send, - (struct mthca_err_cqe *) cqe, - wc, &free_cqe); - goto out; - } - - if (is_send) { - wc->wc_flags = 0; - switch (cqe->opcode) { - case MTHCA_OPCODE_RDMA_WRITE: - wc->opcode = IBV_WC_RDMA_WRITE; - break; - case MTHCA_OPCODE_RDMA_WRITE_IMM: - wc->opcode = IBV_WC_RDMA_WRITE; - wc->wc_flags |= IBV_WC_WITH_IMM; - break; - case MTHCA_OPCODE_SEND: - wc->opcode = IBV_WC_SEND; - break; - case MTHCA_OPCODE_SEND_IMM: - wc->opcode = IBV_WC_SEND; - wc->wc_flags |= IBV_WC_WITH_IMM; - break; - case MTHCA_OPCODE_RDMA_READ: - wc->opcode = IBV_WC_RDMA_READ; - wc->byte_len = be32toh(cqe->byte_cnt); - break; - case MTHCA_OPCODE_ATOMIC_CS: - wc->opcode = IBV_WC_COMP_SWAP; - wc->byte_len = be32toh(cqe->byte_cnt); - break; - case MTHCA_OPCODE_ATOMIC_FA: - wc->opcode = IBV_WC_FETCH_ADD; - wc->byte_len = be32toh(cqe->byte_cnt); - break; - case MTHCA_OPCODE_BIND_MW: - wc->opcode = IBV_WC_BIND_MW; - break; - default: - /* assume it's a send completion */ - wc->opcode = IBV_WC_SEND; - break; - } - } else { - wc->byte_len = be32toh(cqe->byte_cnt); - switch (cqe->opcode & 0x1f) { - case IBV_OPCODE_SEND_LAST_WITH_IMMEDIATE: - case IBV_OPCODE_SEND_ONLY_WITH_IMMEDIATE: - wc->wc_flags = IBV_WC_WITH_IMM; - wc->imm_data = cqe->imm_etype_pkey_eec; - wc->opcode = IBV_WC_RECV; - break; - case IBV_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE: - case IBV_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE: - wc->wc_flags = IBV_WC_WITH_IMM; - wc->imm_data = cqe->imm_etype_pkey_eec; - wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM; - break; - default: - wc->wc_flags = 0; - wc->opcode = IBV_WC_RECV; - break; - } - wc->slid = be16toh(cqe->rlid); - wc->sl = be16toh(cqe->sl_g_mlpath) >> 12; - wc->src_qp = be32toh(cqe->rqpn) & 0xffffff; - wc->dlid_path_bits = be16toh(cqe->sl_g_mlpath) & 0x7f; - wc->pkey_index = be32toh(cqe->imm_etype_pkey_eec) >> 16; - wc->wc_flags |= be16toh(cqe->sl_g_mlpath) & 0x80 ? - IBV_WC_GRH : 0; - } - - wc->status = IBV_WC_SUCCESS; - -out: - if (free_cqe) { - set_cqe_hw(cqe); - ++(*freed); - ++cq->cons_index; - } - - return err; -} - -int mthca_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) -{ - struct mthca_cq *cq = to_mcq(ibcq); - struct mthca_qp *qp = NULL; - int npolled; - int err = CQ_OK; - int freed = 0; - - pthread_spin_lock(&cq->lock); - - for (npolled = 0; npolled < ne; ++npolled) { - err = mthca_poll_one(cq, &qp, &freed, wc + npolled); - if (err != CQ_OK) - break; - } - - if (freed) { - udma_to_device_barrier(); - update_cons_index(cq, freed); - } - - pthread_spin_unlock(&cq->lock); - - return err == CQ_POLL_ERR ? err : npolled; -} - -int mthca_tavor_arm_cq(struct ibv_cq *cq, int solicited) -{ - uint32_t doorbell[2]; - - doorbell[0] = (solicited ? MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL - : MTHCA_TAVOR_CQ_DB_REQ_NOT) | - to_mcq(cq)->cqn; - doorbell[1] = 0xffffffff; - - mthca_write64(doorbell, to_mctx(cq->context)->uar + MTHCA_CQ_DOORBELL); - - return 0; -} - -int mthca_arbel_arm_cq(struct ibv_cq *ibvcq, int solicited) -{ - struct mthca_cq *cq = to_mcq(ibvcq); - uint32_t doorbell[2]; - uint32_t sn; - - sn = cq->arm_sn & 3; - - doorbell[0] = cq->cons_index; - doorbell[1] = - (cq->cqn << 8) | (2 << 5) | (sn << 3) | (solicited ? 1 : 2); - - mthca_write64(doorbell, cq->arm_db); - - /* - * Make sure that the doorbell record in host memory is - * written before ringing the doorbell via PCI MMIO. - */ - udma_to_device_barrier(); - - doorbell[0] = (sn << 28) | (solicited ? MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL - : MTHCA_ARBEL_CQ_DB_REQ_NOT) | - cq->cqn; - doorbell[1] = cq->cons_index; - - mthca_write64(doorbell, - to_mctx(ibvcq->context)->uar + MTHCA_CQ_DOORBELL); - - return 0; -} - -void mthca_arbel_cq_event(struct ibv_cq *cq) -{ - to_mcq(cq)->arm_sn++; -} - -static inline int is_recv_cqe(struct mthca_cqe *cqe) -{ - if ((cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) == - MTHCA_ERROR_CQE_OPCODE_MASK) - return !(cqe->opcode & 0x01); - else - return !(cqe->is_send & 0x80); -} - -void __mthca_cq_clean(struct mthca_cq *cq, uint32_t qpn, struct mthca_srq *srq) -{ - struct mthca_cqe *cqe; - uint32_t prod_index; - int i, nfreed = 0; - - /* - * First we need to find the current producer index, so we - * know where to start cleaning from. It doesn't matter if HW - * adds new entries after this loop -- the QP we're worried - * about is already in RESET, so the new entries won't come - * from our QP and therefore don't need to be checked. - */ - for (prod_index = cq->cons_index; - cqe_sw(cq, prod_index & cq->ibv_cq.cqe); - ++prod_index) - if (prod_index == cq->cons_index + cq->ibv_cq.cqe) - break; - - /* - * Now sweep backwards through the CQ, removing CQ entries - * that match our QP by copying older entries on top of them. - */ - while ((int) --prod_index - (int) cq->cons_index >= 0) { - cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe); - if (cqe->my_qpn == htobe32(qpn)) { - if (srq && is_recv_cqe(cqe)) - mthca_free_srq_wqe(srq, - be32toh(cqe->wqe) >> srq->wqe_shift); - ++nfreed; - } else if (nfreed) - memcpy(get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe), - cqe, MTHCA_CQ_ENTRY_SIZE); - } - - if (nfreed) { - for (i = 0; i < nfreed; ++i) - set_cqe_hw(get_cqe(cq, (cq->cons_index + i) & cq->ibv_cq.cqe)); - udma_to_device_barrier(); - cq->cons_index += nfreed; - update_cons_index(cq, nfreed); - } -} - -void mthca_cq_clean(struct mthca_cq *cq, uint32_t qpn, struct mthca_srq *srq) -{ - pthread_spin_lock(&cq->lock); - __mthca_cq_clean(cq, qpn, srq); - pthread_spin_unlock(&cq->lock); -} - -void mthca_cq_resize_copy_cqes(struct mthca_cq *cq, void *buf, int old_cqe) -{ - int i; - - /* - * In Tavor mode, the hardware keeps the consumer and producer - * indices mod the CQ size. Since we might be making the CQ - * bigger, we need to deal with the case where the producer - * index wrapped around before the CQ was resized. - */ - if (!mthca_is_memfree(cq->ibv_cq.context) && old_cqe < cq->ibv_cq.cqe) { - cq->cons_index &= old_cqe; - if (cqe_sw(cq, old_cqe)) - cq->cons_index -= old_cqe + 1; - } - - for (i = cq->cons_index; cqe_sw(cq, i & old_cqe); ++i) - memcpy(buf + (i & cq->ibv_cq.cqe) * MTHCA_CQ_ENTRY_SIZE, - get_cqe(cq, i & old_cqe), MTHCA_CQ_ENTRY_SIZE); -} - -int mthca_alloc_cq_buf(struct mthca_device *dev, struct mthca_buf *buf, int nent) -{ - int i; - - if (mthca_alloc_buf(buf, align(nent * MTHCA_CQ_ENTRY_SIZE, dev->page_size), - dev->page_size)) - return -1; - - for (i = 0; i < nent; ++i) - ((struct mthca_cqe *) buf->buf)[i].owner = MTHCA_CQ_ENTRY_OWNER_HW; - - return 0; -} diff --git a/usr/rdma-core/providers/mthca/doorbell.h b/usr/rdma-core/providers/mthca/doorbell.h deleted file mode 100644 index d2411ea04..000000000 --- a/usr/rdma-core/providers/mthca/doorbell.h +++ /dev/null @@ -1,14 +0,0 @@ -/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file */ -#ifndef DOORBELL_H -#define DOORBELL_H - -#include -#include "mthca.h" - -static inline void mthca_write64(uint32_t val[2], void *reg) -{ - uint64_t doorbell = (((uint64_t)val[0]) << 32) | val[1]; - mmio_write64_be(reg, htobe64(doorbell)); -} - -#endif diff --git a/usr/rdma-core/providers/mthca/memfree.c b/usr/rdma-core/providers/mthca/memfree.c deleted file mode 100644 index 14edb00af..000000000 --- a/usr/rdma-core/providers/mthca/memfree.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define _GNU_SOURCE -#include - -#include -#include -#include -#include -#include - -#include "mthca.h" - -#define MTHCA_FREE_MAP_SIZE (MTHCA_DB_REC_PER_PAGE / (SIZEOF_LONG * 8)) - -struct mthca_db_page { - unsigned long free[MTHCA_FREE_MAP_SIZE]; - struct mthca_buf db_rec; -}; - -struct mthca_db_table { - int npages; - int max_group1; - int min_group2; - pthread_mutex_t mutex; - struct mthca_db_page page[]; -}; - -int mthca_alloc_db(struct mthca_db_table *db_tab, enum mthca_db_type type, - __be32 **db) -{ - int i, j, k; - int group, start, end, dir; - int ret = 0; - - pthread_mutex_lock(&db_tab->mutex); - - switch (type) { - case MTHCA_DB_TYPE_CQ_ARM: - case MTHCA_DB_TYPE_SQ: - group = 0; - start = 0; - end = db_tab->max_group1; - dir = 1; - break; - - case MTHCA_DB_TYPE_CQ_SET_CI: - case MTHCA_DB_TYPE_RQ: - case MTHCA_DB_TYPE_SRQ: - group = 1; - start = db_tab->npages - 1; - end = db_tab->min_group2; - dir = -1; - break; - - default: - ret = -1; - goto out; - } - - for (i = start; i != end; i += dir) - if (db_tab->page[i].db_rec.buf) - for (j = 0; j < MTHCA_FREE_MAP_SIZE; ++j) - if (db_tab->page[i].free[j]) - goto found; - - if (db_tab->max_group1 >= db_tab->min_group2 - 1) { - ret = -1; - goto out; - } - - if (mthca_alloc_buf(&db_tab->page[i].db_rec, - MTHCA_DB_REC_PAGE_SIZE, - MTHCA_DB_REC_PAGE_SIZE)) { - ret = -1; - goto out; - } - - memset(db_tab->page[i].db_rec.buf, 0, MTHCA_DB_REC_PAGE_SIZE); - memset(db_tab->page[i].free, 0xff, sizeof db_tab->page[i].free); - - if (group == 0) - ++db_tab->max_group1; - else - --db_tab->min_group2; - -found: - for (j = 0; j < MTHCA_FREE_MAP_SIZE; ++j) { - k = ffsl(db_tab->page[i].free[j]); - if (k) - break; - } - - if (!k) { - ret = -1; - goto out; - } - - --k; - db_tab->page[i].free[j] &= ~(1UL << k); - - j = j * SIZEOF_LONG * 8 + k; - if (group == 1) - j = MTHCA_DB_REC_PER_PAGE - 1 - j; - - ret = i * MTHCA_DB_REC_PER_PAGE + j; - *db = db_tab->page[i].db_rec.buf + j * 8; - -out: - pthread_mutex_unlock(&db_tab->mutex); - return ret; -} - -void mthca_set_db_qn(__be32 *db, enum mthca_db_type type, uint32_t qn) -{ - db[1] = htobe32((qn << 8) | (type << 5)); -} - -void mthca_free_db(struct mthca_db_table *db_tab, enum mthca_db_type type, int db_index) -{ - int i, j; - struct mthca_db_page *page; - - i = db_index / MTHCA_DB_REC_PER_PAGE; - j = db_index % MTHCA_DB_REC_PER_PAGE; - - page = db_tab->page + i; - - pthread_mutex_lock(&db_tab->mutex); - *(uint64_t *) (page->db_rec.buf + j * 8) = 0; - - if (i >= db_tab->min_group2) - j = MTHCA_DB_REC_PER_PAGE - 1 - j; - - page->free[j / (SIZEOF_LONG * 8)] |= 1UL << (j % (SIZEOF_LONG * 8)); - - pthread_mutex_unlock(&db_tab->mutex); -} - -struct mthca_db_table *mthca_alloc_db_tab(int uarc_size) -{ - struct mthca_db_table *db_tab; - int npages; - int i; - - npages = uarc_size / MTHCA_DB_REC_PAGE_SIZE; - db_tab = malloc(sizeof (struct mthca_db_table) + - npages * sizeof (struct mthca_db_page)); - - pthread_mutex_init(&db_tab->mutex, NULL); - - db_tab->npages = npages; - db_tab->max_group1 = 0; - db_tab->min_group2 = npages - 1; - - for (i = 0; i < npages; ++i) - db_tab->page[i].db_rec.buf = NULL; - - return db_tab; -} - -void mthca_free_db_tab(struct mthca_db_table *db_tab) -{ - int i; - - if (!db_tab) - return; - - for (i = 0; i < db_tab->npages; ++i) - if (db_tab->page[i].db_rec.buf) - mthca_free_buf(&db_tab->page[i].db_rec); - - free(db_tab); -} diff --git a/usr/rdma-core/providers/mthca/mthca-abi.h b/usr/rdma-core/providers/mthca/mthca-abi.h deleted file mode 100644 index 4fbd98bc0..000000000 --- a/usr/rdma-core/providers/mthca/mthca-abi.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef MTHCA_ABI_H -#define MTHCA_ABI_H - -#include - -#define MTHCA_UVERBS_ABI_VERSION 1 - -struct mthca_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - __u32 qp_tab_size; - __u32 uarc_size; -}; - -struct mthca_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - __u32 pdn; - __u32 reserved; -}; - -struct mthca_reg_mr { - struct ibv_reg_mr ibv_cmd; -/* - * Mark the memory region with a DMA attribute that causes - * in-flight DMA to be flushed when the region is written to: - */ -#define MTHCA_MR_DMASYNC 0x1 - __u32 mr_attrs; - __u32 reserved; -}; - -struct mthca_create_cq { - struct ibv_create_cq ibv_cmd; - __u32 lkey; - __u32 pdn; - __u64 arm_db_page; - __u64 set_db_page; - __u32 arm_db_index; - __u32 set_db_index; -}; - -struct mthca_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u32 cqn; - __u32 reserved; -}; - -struct mthca_resize_cq { - struct ibv_resize_cq ibv_cmd; - __u32 lkey; - __u32 reserved; -}; - -struct mthca_create_srq { - struct ibv_create_srq ibv_cmd; - __u32 lkey; - __u32 db_index; - __u64 db_page; -}; - -struct mthca_create_srq_resp { - struct ibv_create_srq_resp ibv_resp; - __u32 srqn; - __u32 reserved; -}; - -struct mthca_create_qp { - struct ibv_create_qp ibv_cmd; - __u32 lkey; - __u32 reserved; - __u64 sq_db_page; - __u64 rq_db_page; - __u32 sq_db_index; - __u32 rq_db_index; -}; - -#endif /* MTHCA_ABI_H */ diff --git a/usr/rdma-core/providers/mthca/mthca.c b/usr/rdma-core/providers/mthca/mthca.c deleted file mode 100644 index 511b8d513..000000000 --- a/usr/rdma-core/providers/mthca/mthca.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "mthca.h" -#include "mthca-abi.h" - -#ifndef PCI_VENDOR_ID_MELLANOX -#define PCI_VENDOR_ID_MELLANOX 0x15b3 -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_TAVOR -#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44 -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT -#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278 -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL -#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282 -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_SINAI_OLD -#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_SINAI -#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274 -#endif - -#ifndef PCI_VENDOR_ID_TOPSPIN -#define PCI_VENDOR_ID_TOPSPIN 0x1867 -#endif - -#define HCA(v, d, t) \ - VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, PCI_DEVICE_ID_MELLANOX_##d, \ - (void *)(MTHCA_##t)) -static const struct verbs_match_ent hca_table[] = { - HCA(MELLANOX, TAVOR, TAVOR), - HCA(MELLANOX, ARBEL_COMPAT, TAVOR), - HCA(MELLANOX, ARBEL, ARBEL), - HCA(MELLANOX, SINAI_OLD, ARBEL), - HCA(MELLANOX, SINAI, ARBEL), - HCA(TOPSPIN, TAVOR, TAVOR), - HCA(TOPSPIN, ARBEL_COMPAT, TAVOR), - HCA(TOPSPIN, ARBEL, ARBEL), - HCA(TOPSPIN, SINAI_OLD, ARBEL), - HCA(TOPSPIN, SINAI, ARBEL), - {} -}; - -static struct ibv_context_ops mthca_ctx_ops = { - .query_device = mthca_query_device, - .query_port = mthca_query_port, - .alloc_pd = mthca_alloc_pd, - .dealloc_pd = mthca_free_pd, - .reg_mr = mthca_reg_mr, - .dereg_mr = mthca_dereg_mr, - .create_cq = mthca_create_cq, - .poll_cq = mthca_poll_cq, - .resize_cq = mthca_resize_cq, - .destroy_cq = mthca_destroy_cq, - .create_srq = mthca_create_srq, - .modify_srq = mthca_modify_srq, - .query_srq = mthca_query_srq, - .destroy_srq = mthca_destroy_srq, - .create_qp = mthca_create_qp, - .query_qp = mthca_query_qp, - .modify_qp = mthca_modify_qp, - .destroy_qp = mthca_destroy_qp, - .create_ah = mthca_create_ah, - .destroy_ah = mthca_destroy_ah, - .attach_mcast = ibv_cmd_attach_mcast, - .detach_mcast = ibv_cmd_detach_mcast -}; - -static struct ibv_context *mthca_alloc_context(struct ibv_device *ibdev, int cmd_fd) -{ - struct mthca_context *context; - struct ibv_get_context cmd; - struct mthca_alloc_ucontext_resp resp; - int i; - - context = calloc(1, sizeof *context); - if (!context) - return NULL; - - context->ibv_ctx.cmd_fd = cmd_fd; - - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) - goto err_free; - - context->num_qps = resp.qp_tab_size; - context->qp_table_shift = ffs(context->num_qps) - 1 - MTHCA_QP_TABLE_BITS; - context->qp_table_mask = (1 << context->qp_table_shift) - 1; - - /* - * Need to set ibv_ctx.device because mthca_is_memfree() will - * look at it to figure out the HCA type. - */ - context->ibv_ctx.device = ibdev; - - if (mthca_is_memfree(&context->ibv_ctx)) { - context->db_tab = mthca_alloc_db_tab(resp.uarc_size); - if (!context->db_tab) - goto err_free; - } else - context->db_tab = NULL; - - pthread_mutex_init(&context->qp_table_mutex, NULL); - for (i = 0; i < MTHCA_QP_TABLE_SIZE; ++i) - context->qp_table[i].refcnt = 0; - - context->uar = mmap(NULL, to_mdev(ibdev)->page_size, PROT_WRITE, - MAP_SHARED, cmd_fd, 0); - if (context->uar == MAP_FAILED) - goto err_db_tab; - - pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE); - - context->pd = mthca_alloc_pd(&context->ibv_ctx); - if (!context->pd) - goto err_unmap; - - context->pd->context = &context->ibv_ctx; - - context->ibv_ctx.ops = mthca_ctx_ops; - - if (mthca_is_memfree(&context->ibv_ctx)) { - context->ibv_ctx.ops.req_notify_cq = mthca_arbel_arm_cq; - context->ibv_ctx.ops.cq_event = mthca_arbel_cq_event; - context->ibv_ctx.ops.post_send = mthca_arbel_post_send; - context->ibv_ctx.ops.post_recv = mthca_arbel_post_recv; - context->ibv_ctx.ops.post_srq_recv = mthca_arbel_post_srq_recv; - } else { - context->ibv_ctx.ops.req_notify_cq = mthca_tavor_arm_cq; - context->ibv_ctx.ops.cq_event = NULL; - context->ibv_ctx.ops.post_send = mthca_tavor_post_send; - context->ibv_ctx.ops.post_recv = mthca_tavor_post_recv; - context->ibv_ctx.ops.post_srq_recv = mthca_tavor_post_srq_recv; - } - - return &context->ibv_ctx; - -err_unmap: - munmap(context->uar, to_mdev(ibdev)->page_size); - -err_db_tab: - mthca_free_db_tab(context->db_tab); - -err_free: - free(context); - return NULL; -} - -static void mthca_free_context(struct ibv_context *ibctx) -{ - struct mthca_context *context = to_mctx(ibctx); - - mthca_free_pd(context->pd); - munmap(context->uar, to_mdev(ibctx->device)->page_size); - mthca_free_db_tab(context->db_tab); - free(context); -} - -static void mthca_uninit_device(struct verbs_device *verbs_device) -{ - struct mthca_device *dev = to_mdev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device * -mthca_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct mthca_device *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->hca_type = (uintptr_t)sysfs_dev->match->driver_data; - dev->page_size = sysconf(_SC_PAGESIZE); - - return &dev->ibv_dev; -} - -static const struct verbs_device_ops mthca_dev_ops = { - .name = "mthca", - .match_min_abi_version = 0, - .match_max_abi_version = MTHCA_UVERBS_ABI_VERSION, - .match_table = hca_table, - .alloc_device = mthca_device_alloc, - .uninit_device = mthca_uninit_device, - .alloc_context = mthca_alloc_context, - .free_context = mthca_free_context, -}; -PROVIDER_DRIVER(mthca_dev_ops); diff --git a/usr/rdma-core/providers/mthca/mthca.h b/usr/rdma-core/providers/mthca/mthca.h deleted file mode 100644 index 68bc5ad73..000000000 --- a/usr/rdma-core/providers/mthca/mthca.h +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef MTHCA_H -#define MTHCA_H - -#include - -#include -#include - -#include - -#define PFX "mthca: " - -enum mthca_hca_type { - MTHCA_TAVOR, - MTHCA_ARBEL -}; - -enum { - MTHCA_CQ_ENTRY_SIZE = 0x20 -}; - -enum { - MTHCA_QP_TABLE_BITS = 8, - MTHCA_QP_TABLE_SIZE = 1 << MTHCA_QP_TABLE_BITS, - MTHCA_QP_TABLE_MASK = MTHCA_QP_TABLE_SIZE - 1 -}; - -enum { - MTHCA_DB_REC_PAGE_SIZE = 4096, - MTHCA_DB_REC_PER_PAGE = MTHCA_DB_REC_PAGE_SIZE / 8 -}; - -enum mthca_db_type { - MTHCA_DB_TYPE_INVALID = 0x0, - MTHCA_DB_TYPE_CQ_SET_CI = 0x1, - MTHCA_DB_TYPE_CQ_ARM = 0x2, - MTHCA_DB_TYPE_SQ = 0x3, - MTHCA_DB_TYPE_RQ = 0x4, - MTHCA_DB_TYPE_SRQ = 0x5, - MTHCA_DB_TYPE_GROUP_SEP = 0x7 -}; - -enum { - MTHCA_OPCODE_NOP = 0x00, - MTHCA_OPCODE_RDMA_WRITE = 0x08, - MTHCA_OPCODE_RDMA_WRITE_IMM = 0x09, - MTHCA_OPCODE_SEND = 0x0a, - MTHCA_OPCODE_SEND_IMM = 0x0b, - MTHCA_OPCODE_RDMA_READ = 0x10, - MTHCA_OPCODE_ATOMIC_CS = 0x11, - MTHCA_OPCODE_ATOMIC_FA = 0x12, - MTHCA_OPCODE_BIND_MW = 0x18, - MTHCA_OPCODE_INVALID = 0xff -}; - -struct mthca_ah_page; - -struct mthca_device { - struct verbs_device ibv_dev; - enum mthca_hca_type hca_type; - int page_size; -}; - -struct mthca_db_table; - -struct mthca_context { - struct ibv_context ibv_ctx; - void *uar; - pthread_spinlock_t uar_lock; - struct mthca_db_table *db_tab; - struct ibv_pd *pd; - struct { - struct mthca_qp **table; - int refcnt; - } qp_table[MTHCA_QP_TABLE_SIZE]; - pthread_mutex_t qp_table_mutex; - int num_qps; - int qp_table_shift; - int qp_table_mask; -}; - -struct mthca_buf { - void *buf; - size_t length; -}; - -struct mthca_pd { - struct ibv_pd ibv_pd; - struct mthca_ah_page *ah_list; - pthread_mutex_t ah_mutex; - uint32_t pdn; -}; - -struct mthca_cq { - struct ibv_cq ibv_cq; - struct mthca_buf buf; - pthread_spinlock_t lock; - struct ibv_mr *mr; - uint32_t cqn; - uint32_t cons_index; - - /* Next fields are mem-free only */ - int set_ci_db_index; - __be32 *set_ci_db; - int arm_db_index; - __be32 *arm_db; - int arm_sn; -}; - -struct mthca_srq { - struct ibv_srq ibv_srq; - struct mthca_buf buf; - void *last; - pthread_spinlock_t lock; - struct ibv_mr *mr; - uint64_t *wrid; - uint32_t srqn; - int max; - int max_gs; - int wqe_shift; - int first_free; - int last_free; - int buf_size; - - /* Next fields are mem-free only */ - int db_index; - __be32 *db; - uint16_t counter; -}; - -struct mthca_wq { - pthread_spinlock_t lock; - int max; - unsigned next_ind; - unsigned last_comp; - unsigned head; - unsigned tail; - void *last; - int max_gs; - int wqe_shift; - - /* Next fields are mem-free only */ - int db_index; - __be32 *db; -}; - -struct mthca_qp { - struct ibv_qp ibv_qp; - struct mthca_buf buf; - uint64_t *wrid; - int send_wqe_offset; - int max_inline_data; - int buf_size; - struct mthca_wq sq; - struct mthca_wq rq; - struct ibv_mr *mr; - int sq_sig_all; -}; - -struct mthca_av { - __be32 port_pd; - uint8_t reserved1; - uint8_t g_slid; - __be16 dlid; - uint8_t reserved2; - uint8_t gid_index; - uint8_t msg_sr; - uint8_t hop_limit; - __be32 sl_tclass_flowlabel; - __be32 dgid[4]; -}; - -struct mthca_ah { - struct ibv_ah ibv_ah; - struct mthca_av *av; - struct mthca_ah_page *page; - uint32_t key; -}; - -static inline unsigned long align(unsigned long val, unsigned long align) -{ - return (val + align - 1) & ~(align - 1); -} - -static inline uintptr_t db_align(__be32 *db) -{ - return (uintptr_t) db & ~((uintptr_t) MTHCA_DB_REC_PAGE_SIZE - 1); -} - -#define to_mxxx(xxx, type) \ - ((struct mthca_##type *) \ - ((void *) ib##xxx - offsetof(struct mthca_##type, ibv_##xxx))) - -static inline struct mthca_device *to_mdev(struct ibv_device *ibdev) -{ - return to_mxxx(dev, device); -} - -static inline struct mthca_context *to_mctx(struct ibv_context *ibctx) -{ - return to_mxxx(ctx, context); -} - -static inline struct mthca_pd *to_mpd(struct ibv_pd *ibpd) -{ - return to_mxxx(pd, pd); -} - -static inline struct mthca_cq *to_mcq(struct ibv_cq *ibcq) -{ - return to_mxxx(cq, cq); -} - -static inline struct mthca_srq *to_msrq(struct ibv_srq *ibsrq) -{ - return to_mxxx(srq, srq); -} - -static inline struct mthca_qp *to_mqp(struct ibv_qp *ibqp) -{ - return to_mxxx(qp, qp); -} - -static inline struct mthca_ah *to_mah(struct ibv_ah *ibah) -{ - return to_mxxx(ah, ah); -} - -static inline int mthca_is_memfree(struct ibv_context *ibctx) -{ - return to_mdev(ibctx->device)->hca_type == MTHCA_ARBEL; -} - -int mthca_alloc_buf(struct mthca_buf *buf, size_t size, int page_size); -void mthca_free_buf(struct mthca_buf *buf); - -int mthca_alloc_db(struct mthca_db_table *db_tab, enum mthca_db_type type, - __be32 **db); -void mthca_set_db_qn(__be32 *db, enum mthca_db_type type, uint32_t qn); -void mthca_free_db(struct mthca_db_table *db_tab, enum mthca_db_type type, int db_index); -struct mthca_db_table *mthca_alloc_db_tab(int uarc_size); -void mthca_free_db_tab(struct mthca_db_table *db_tab); - -int mthca_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); -int mthca_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -struct ibv_pd *mthca_alloc_pd(struct ibv_context *context); -int mthca_free_pd(struct ibv_pd *pd); - -struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); -int mthca_dereg_mr(struct ibv_mr *mr); - -struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); -int mthca_resize_cq(struct ibv_cq *cq, int cqe); -int mthca_destroy_cq(struct ibv_cq *cq); -int mthca_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -int mthca_tavor_arm_cq(struct ibv_cq *cq, int solicited); -int mthca_arbel_arm_cq(struct ibv_cq *cq, int solicited); -void mthca_arbel_cq_event(struct ibv_cq *cq); -void __mthca_cq_clean(struct mthca_cq *cq, uint32_t qpn, struct mthca_srq *srq); -void mthca_cq_clean(struct mthca_cq *cq, uint32_t qpn, struct mthca_srq *srq); -void mthca_cq_resize_copy_cqes(struct mthca_cq *cq, void *buf, int new_cqe); -int mthca_alloc_cq_buf(struct mthca_device *dev, struct mthca_buf *buf, int nent); - -struct ibv_srq *mthca_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr); -int mthca_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int mask); -int mthca_query_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr); -int mthca_destroy_srq(struct ibv_srq *srq); -int mthca_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr, - struct mthca_srq *srq); -void mthca_free_srq_wqe(struct mthca_srq *srq, int ind); -int mthca_tavor_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -int mthca_arbel_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -struct ibv_qp *mthca_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr); -int mthca_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr); -int mthca_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); -int mthca_destroy_qp(struct ibv_qp *qp); -void mthca_init_qp_indices(struct mthca_qp *qp); -int mthca_tavor_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -int mthca_tavor_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -int mthca_arbel_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -int mthca_arbel_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -int mthca_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap, - enum ibv_qp_type type, struct mthca_qp *qp); -struct mthca_qp *mthca_find_qp(struct mthca_context *ctx, uint32_t qpn); -int mthca_store_qp(struct mthca_context *ctx, uint32_t qpn, struct mthca_qp *qp); -void mthca_clear_qp(struct mthca_context *ctx, uint32_t qpn); -int mthca_free_err_wqe(struct mthca_qp *qp, int is_send, - int index, int *dbd, __be32 *new_wqe); -struct ibv_ah *mthca_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr); -int mthca_destroy_ah(struct ibv_ah *ah); -int mthca_alloc_av(struct mthca_pd *pd, struct ibv_ah_attr *attr, - struct mthca_ah *ah); -void mthca_free_av(struct mthca_ah *ah); - -#endif /* MTHCA_H */ diff --git a/usr/rdma-core/providers/mthca/qp.c b/usr/rdma-core/providers/mthca/qp.c deleted file mode 100644 index f4289032a..000000000 --- a/usr/rdma-core/providers/mthca/qp.c +++ /dev/null @@ -1,956 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include - -#include "mthca.h" -#include "doorbell.h" -#include "wqe.h" - -enum { - MTHCA_SEND_DOORBELL_FENCE = 1 << 5 -}; - -static const uint8_t mthca_opcode[] = { - [IBV_WR_SEND] = MTHCA_OPCODE_SEND, - [IBV_WR_SEND_WITH_IMM] = MTHCA_OPCODE_SEND_IMM, - [IBV_WR_RDMA_WRITE] = MTHCA_OPCODE_RDMA_WRITE, - [IBV_WR_RDMA_WRITE_WITH_IMM] = MTHCA_OPCODE_RDMA_WRITE_IMM, - [IBV_WR_RDMA_READ] = MTHCA_OPCODE_RDMA_READ, - [IBV_WR_ATOMIC_CMP_AND_SWP] = MTHCA_OPCODE_ATOMIC_CS, - [IBV_WR_ATOMIC_FETCH_AND_ADD] = MTHCA_OPCODE_ATOMIC_FA, -}; - -static void *get_recv_wqe(struct mthca_qp *qp, int n) -{ - return qp->buf.buf + (n << qp->rq.wqe_shift); -} - -static void *get_send_wqe(struct mthca_qp *qp, int n) -{ - return qp->buf.buf + qp->send_wqe_offset + (n << qp->sq.wqe_shift); -} - -void mthca_init_qp_indices(struct mthca_qp *qp) -{ - qp->sq.next_ind = 0; - qp->sq.last_comp = qp->sq.max - 1; - qp->sq.head = 0; - qp->sq.tail = 0; - qp->sq.last = get_send_wqe(qp, qp->sq.max - 1); - - qp->rq.next_ind = 0; - qp->rq.last_comp = qp->rq.max - 1; - qp->rq.head = 0; - qp->rq.tail = 0; - qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1); -} - -static inline int wq_overflow(struct mthca_wq *wq, int nreq, struct mthca_cq *cq) -{ - unsigned cur; - - cur = wq->head - wq->tail; - if (cur + nreq < wq->max) - return 0; - - pthread_spin_lock(&cq->lock); - cur = wq->head - wq->tail; - pthread_spin_unlock(&cq->lock); - - return cur + nreq >= wq->max; -} - -int mthca_tavor_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - struct mthca_qp *qp = to_mqp(ibqp); - void *wqe, *prev_wqe; - int ind; - int nreq; - int ret = 0; - int size; - int size0 = 0; - int i; - uint32_t uninitialized_var(f0); - uint32_t uninitialized_var(op0); - - pthread_spin_lock(&qp->sq.lock); - udma_to_device_barrier(); - - ind = qp->sq.next_ind; - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (wq_overflow(&qp->sq, nreq, to_mcq(qp->ibv_qp.send_cq))) { - ret = -1; - *bad_wr = wr; - goto out; - } - - wqe = get_send_wqe(qp, ind); - prev_wqe = qp->sq.last; - qp->sq.last = wqe; - - ((struct mthca_next_seg *) wqe)->nda_op = 0; - ((struct mthca_next_seg *) wqe)->ee_nds = 0; - ((struct mthca_next_seg *) wqe)->flags = - ((wr->send_flags & IBV_SEND_SIGNALED) ? - htobe32(MTHCA_NEXT_CQ_UPDATE) : 0) | - ((wr->send_flags & IBV_SEND_SOLICITED) ? - htobe32(MTHCA_NEXT_SOLICIT) : 0) | - htobe32(1); - if (wr->opcode == IBV_WR_SEND_WITH_IMM || - wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM) - ((struct mthca_next_seg *) wqe)->imm = wr->imm_data; - - wqe += sizeof (struct mthca_next_seg); - size = sizeof (struct mthca_next_seg) / 16; - - switch (ibqp->qp_type) { - case IBV_QPT_RC: - switch (wr->opcode) { - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - ((struct mthca_raddr_seg *) wqe)->raddr = - htobe64(wr->wr.atomic.remote_addr); - ((struct mthca_raddr_seg *) wqe)->rkey = - htobe32(wr->wr.atomic.rkey); - ((struct mthca_raddr_seg *) wqe)->reserved = 0; - - wqe += sizeof (struct mthca_raddr_seg); - - if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) { - ((struct mthca_atomic_seg *) wqe)->swap_add = - htobe64(wr->wr.atomic.swap); - ((struct mthca_atomic_seg *) wqe)->compare = - htobe64(wr->wr.atomic.compare_add); - } else { - ((struct mthca_atomic_seg *) wqe)->swap_add = - htobe64(wr->wr.atomic.compare_add); - ((struct mthca_atomic_seg *) wqe)->compare = 0; - } - - wqe += sizeof (struct mthca_atomic_seg); - size += (sizeof (struct mthca_raddr_seg) + - sizeof (struct mthca_atomic_seg)) / 16; - break; - - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - case IBV_WR_RDMA_READ: - ((struct mthca_raddr_seg *) wqe)->raddr = - htobe64(wr->wr.rdma.remote_addr); - ((struct mthca_raddr_seg *) wqe)->rkey = - htobe32(wr->wr.rdma.rkey); - ((struct mthca_raddr_seg *) wqe)->reserved = 0; - wqe += sizeof (struct mthca_raddr_seg); - size += sizeof (struct mthca_raddr_seg) / 16; - break; - - default: - /* No extra segments required for sends */ - break; - } - - break; - - case IBV_QPT_UC: - switch (wr->opcode) { - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - ((struct mthca_raddr_seg *) wqe)->raddr = - htobe64(wr->wr.rdma.remote_addr); - ((struct mthca_raddr_seg *) wqe)->rkey = - htobe32(wr->wr.rdma.rkey); - ((struct mthca_raddr_seg *) wqe)->reserved = 0; - wqe += sizeof (struct mthca_raddr_seg); - size += sizeof (struct mthca_raddr_seg) / 16; - break; - - default: - /* No extra segments required for sends */ - break; - } - - break; - - case IBV_QPT_UD: - ((struct mthca_tavor_ud_seg *) wqe)->lkey = - htobe32(to_mah(wr->wr.ud.ah)->key); - ((struct mthca_tavor_ud_seg *) wqe)->av_addr = - htobe64((uintptr_t) to_mah(wr->wr.ud.ah)->av); - ((struct mthca_tavor_ud_seg *) wqe)->dqpn = - htobe32(wr->wr.ud.remote_qpn); - ((struct mthca_tavor_ud_seg *) wqe)->qkey = - htobe32(wr->wr.ud.remote_qkey); - - wqe += sizeof (struct mthca_tavor_ud_seg); - size += sizeof (struct mthca_tavor_ud_seg) / 16; - break; - - default: - break; - } - - if (wr->num_sge > qp->sq.max_gs) { - ret = -1; - *bad_wr = wr; - goto out; - } - - if (wr->send_flags & IBV_SEND_INLINE) { - if (wr->num_sge) { - struct mthca_inline_seg *seg = wqe; - int s = 0; - - wqe += sizeof *seg; - for (i = 0; i < wr->num_sge; ++i) { - struct ibv_sge *sge = &wr->sg_list[i]; - - s += sge->length; - - if (s > qp->max_inline_data) { - ret = -1; - *bad_wr = wr; - goto out; - } - - memcpy(wqe, (void *) (intptr_t) sge->addr, - sge->length); - wqe += sge->length; - } - - seg->byte_count = htobe32(MTHCA_INLINE_SEG | s); - size += align(s + sizeof *seg, 16) / 16; - } - } else { - struct mthca_data_seg *seg; - - for (i = 0; i < wr->num_sge; ++i) { - seg = wqe; - seg->byte_count = htobe32(wr->sg_list[i].length); - seg->lkey = htobe32(wr->sg_list[i].lkey); - seg->addr = htobe64(wr->sg_list[i].addr); - wqe += sizeof *seg; - } - - size += wr->num_sge * (sizeof *seg / 16); - } - - qp->wrid[ind + qp->rq.max] = wr->wr_id; - - if (wr->opcode >= sizeof mthca_opcode / sizeof mthca_opcode[0]) { - ret = -1; - *bad_wr = wr; - goto out; - } - - ((struct mthca_next_seg *) prev_wqe)->nda_op = - htobe32(((ind << qp->sq.wqe_shift) + - qp->send_wqe_offset) | - mthca_opcode[wr->opcode]); - /* - * Make sure that nda_op is written before setting ee_nds. - */ - udma_ordering_write_barrier(); - ((struct mthca_next_seg *) prev_wqe)->ee_nds = - htobe32((size0 ? 0 : MTHCA_NEXT_DBD) | size | - ((wr->send_flags & IBV_SEND_FENCE) ? - MTHCA_NEXT_FENCE : 0)); - - if (!size0) { - size0 = size; - op0 = mthca_opcode[wr->opcode]; - f0 = wr->send_flags & IBV_SEND_FENCE ? - MTHCA_SEND_DOORBELL_FENCE : 0; - } - - ++ind; - if (ind >= qp->sq.max) - ind -= qp->sq.max; - } - -out: - if (nreq) { - uint32_t doorbell[2]; - - doorbell[0] = ((qp->sq.next_ind << qp->sq.wqe_shift) + - qp->send_wqe_offset) | - f0 | op0; - doorbell[1] = (ibqp->qp_num << 8) | size0; - - udma_to_device_barrier(); - mthca_write64(doorbell, to_mctx(ibqp->context)->uar + - MTHCA_SEND_DOORBELL); - } - - qp->sq.next_ind = ind; - qp->sq.head += nreq; - - pthread_spin_unlock(&qp->sq.lock); - return ret; -} - -int mthca_tavor_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mthca_qp *qp = to_mqp(ibqp); - uint32_t doorbell[2]; - int ret = 0; - int nreq; - int i; - int size; - int size0 = 0; - int ind; - void *wqe; - void *prev_wqe; - - pthread_spin_lock(&qp->rq.lock); - - ind = qp->rq.next_ind; - - for (nreq = 0; wr; wr = wr->next) { - if (wq_overflow(&qp->rq, nreq, to_mcq(qp->ibv_qp.recv_cq))) { - ret = -1; - *bad_wr = wr; - goto out; - } - - wqe = get_recv_wqe(qp, ind); - prev_wqe = qp->rq.last; - qp->rq.last = wqe; - - ((struct mthca_next_seg *) wqe)->ee_nds = - htobe32(MTHCA_NEXT_DBD); - ((struct mthca_next_seg *) wqe)->flags = - htobe32(MTHCA_NEXT_CQ_UPDATE); - - wqe += sizeof (struct mthca_next_seg); - size = sizeof (struct mthca_next_seg) / 16; - - if (wr->num_sge > qp->rq.max_gs) { - ret = -1; - *bad_wr = wr; - goto out; - } - - for (i = 0; i < wr->num_sge; ++i) { - ((struct mthca_data_seg *) wqe)->byte_count = - htobe32(wr->sg_list[i].length); - ((struct mthca_data_seg *) wqe)->lkey = - htobe32(wr->sg_list[i].lkey); - ((struct mthca_data_seg *) wqe)->addr = - htobe64(wr->sg_list[i].addr); - wqe += sizeof (struct mthca_data_seg); - size += sizeof (struct mthca_data_seg) / 16; - } - - qp->wrid[ind] = wr->wr_id; - - ((struct mthca_next_seg *) prev_wqe)->ee_nds = - htobe32(MTHCA_NEXT_DBD | size); - - if (!size0) - size0 = size; - - ++ind; - if (ind >= qp->rq.max) - ind -= qp->rq.max; - - ++nreq; - if (nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB) { - nreq = 0; - - doorbell[0] = - (qp->rq.next_ind << qp->rq.wqe_shift) | size0; - doorbell[1] = ibqp->qp_num << 8; - - /* - * Make sure that descriptors are written - * before doorbell is rung. - */ - udma_to_device_barrier(); - - mthca_write64(doorbell, to_mctx(ibqp->context)->uar + - MTHCA_RECV_DOORBELL); - - qp->rq.next_ind = ind; - qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB; - size0 = 0; - } - } - -out: - if (nreq) { - doorbell[0] = (qp->rq.next_ind << qp->rq.wqe_shift) | size0; - doorbell[1] = (ibqp->qp_num << 8) | nreq; - - /* - * Make sure that descriptors are written before - * doorbell is rung. - */ - udma_to_device_barrier(); - - mthca_write64(doorbell, to_mctx(ibqp->context)->uar + - MTHCA_RECV_DOORBELL); - } - - qp->rq.next_ind = ind; - qp->rq.head += nreq; - - pthread_spin_unlock(&qp->rq.lock); - return ret; -} - -int mthca_arbel_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - struct mthca_qp *qp = to_mqp(ibqp); - uint32_t doorbell[2]; - void *wqe, *prev_wqe; - int ind; - int nreq; - int ret = 0; - int size; - int size0 = 0; - int i; - uint32_t uninitialized_var(f0); - uint32_t uninitialized_var(op0); - - pthread_spin_lock(&qp->sq.lock); - - /* XXX check that state is OK to post send */ - - ind = qp->sq.head & (qp->sq.max - 1); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB) { - nreq = 0; - - doorbell[0] = (MTHCA_ARBEL_MAX_WQES_PER_SEND_DB << 24) | - ((qp->sq.head & 0xffff) << 8) | f0 | op0; - doorbell[1] = (ibqp->qp_num << 8) | size0; - - qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB; - - /* - * Make sure that descriptors are written before - * doorbell record. - */ - udma_to_device_barrier(); - *qp->sq.db = htobe32(qp->sq.head & 0xffff); - - /* - * Make sure doorbell record is written before we - * write MMIO send doorbell. - */ - mmio_ordered_writes_hack(); - mthca_write64(doorbell, to_mctx(ibqp->context)->uar + - MTHCA_SEND_DOORBELL); - - size0 = 0; - } - - if (wq_overflow(&qp->sq, nreq, to_mcq(qp->ibv_qp.send_cq))) { - ret = -1; - *bad_wr = wr; - goto out; - } - - wqe = get_send_wqe(qp, ind); - prev_wqe = qp->sq.last; - qp->sq.last = wqe; - - ((struct mthca_next_seg *) wqe)->flags = - ((wr->send_flags & IBV_SEND_SIGNALED) ? - htobe32(MTHCA_NEXT_CQ_UPDATE) : 0) | - ((wr->send_flags & IBV_SEND_SOLICITED) ? - htobe32(MTHCA_NEXT_SOLICIT) : 0) | - htobe32(1); - if (wr->opcode == IBV_WR_SEND_WITH_IMM || - wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM) - ((struct mthca_next_seg *) wqe)->imm = wr->imm_data; - - wqe += sizeof (struct mthca_next_seg); - size = sizeof (struct mthca_next_seg) / 16; - - switch (ibqp->qp_type) { - case IBV_QPT_RC: - switch (wr->opcode) { - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - ((struct mthca_raddr_seg *) wqe)->raddr = - htobe64(wr->wr.atomic.remote_addr); - ((struct mthca_raddr_seg *) wqe)->rkey = - htobe32(wr->wr.atomic.rkey); - ((struct mthca_raddr_seg *) wqe)->reserved = 0; - - wqe += sizeof (struct mthca_raddr_seg); - - if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) { - ((struct mthca_atomic_seg *) wqe)->swap_add = - htobe64(wr->wr.atomic.swap); - ((struct mthca_atomic_seg *) wqe)->compare = - htobe64(wr->wr.atomic.compare_add); - } else { - ((struct mthca_atomic_seg *) wqe)->swap_add = - htobe64(wr->wr.atomic.compare_add); - ((struct mthca_atomic_seg *) wqe)->compare = 0; - } - - wqe += sizeof (struct mthca_atomic_seg); - size += (sizeof (struct mthca_raddr_seg) + - sizeof (struct mthca_atomic_seg)) / 16; - break; - - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - case IBV_WR_RDMA_READ: - ((struct mthca_raddr_seg *) wqe)->raddr = - htobe64(wr->wr.rdma.remote_addr); - ((struct mthca_raddr_seg *) wqe)->rkey = - htobe32(wr->wr.rdma.rkey); - ((struct mthca_raddr_seg *) wqe)->reserved = 0; - wqe += sizeof (struct mthca_raddr_seg); - size += sizeof (struct mthca_raddr_seg) / 16; - break; - - default: - /* No extra segments required for sends */ - break; - } - - break; - - case IBV_QPT_UC: - switch (wr->opcode) { - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - ((struct mthca_raddr_seg *) wqe)->raddr = - htobe64(wr->wr.rdma.remote_addr); - ((struct mthca_raddr_seg *) wqe)->rkey = - htobe32(wr->wr.rdma.rkey); - ((struct mthca_raddr_seg *) wqe)->reserved = 0; - wqe += sizeof (struct mthca_raddr_seg); - size += sizeof (struct mthca_raddr_seg) / 16; - break; - - default: - /* No extra segments required for sends */ - break; - } - - break; - - case IBV_QPT_UD: - memcpy(((struct mthca_arbel_ud_seg *) wqe)->av, - to_mah(wr->wr.ud.ah)->av, sizeof (struct mthca_av)); - ((struct mthca_arbel_ud_seg *) wqe)->dqpn = - htobe32(wr->wr.ud.remote_qpn); - ((struct mthca_arbel_ud_seg *) wqe)->qkey = - htobe32(wr->wr.ud.remote_qkey); - - wqe += sizeof (struct mthca_arbel_ud_seg); - size += sizeof (struct mthca_arbel_ud_seg) / 16; - break; - - default: - break; - } - - if (wr->num_sge > qp->sq.max_gs) { - ret = -1; - *bad_wr = wr; - goto out; - } - - if (wr->send_flags & IBV_SEND_INLINE) { - if (wr->num_sge) { - struct mthca_inline_seg *seg = wqe; - int s = 0; - - wqe += sizeof *seg; - for (i = 0; i < wr->num_sge; ++i) { - struct ibv_sge *sge = &wr->sg_list[i]; - - s += sge->length; - - if (s > qp->max_inline_data) { - ret = -1; - *bad_wr = wr; - goto out; - } - - memcpy(wqe, (void *) (uintptr_t) sge->addr, - sge->length); - wqe += sge->length; - } - - seg->byte_count = htobe32(MTHCA_INLINE_SEG | s); - size += align(s + sizeof *seg, 16) / 16; - } - } else { - struct mthca_data_seg *seg; - - for (i = 0; i < wr->num_sge; ++i) { - seg = wqe; - seg->byte_count = htobe32(wr->sg_list[i].length); - seg->lkey = htobe32(wr->sg_list[i].lkey); - seg->addr = htobe64(wr->sg_list[i].addr); - wqe += sizeof *seg; - } - - size += wr->num_sge * (sizeof *seg / 16); - } - - qp->wrid[ind + qp->rq.max] = wr->wr_id; - - if (wr->opcode >= sizeof mthca_opcode / sizeof mthca_opcode[0]) { - ret = -1; - *bad_wr = wr; - goto out; - } - - ((struct mthca_next_seg *) prev_wqe)->nda_op = - htobe32(((ind << qp->sq.wqe_shift) + - qp->send_wqe_offset) | - mthca_opcode[wr->opcode]); - udma_ordering_write_barrier(); - ((struct mthca_next_seg *) prev_wqe)->ee_nds = - htobe32(MTHCA_NEXT_DBD | size | - ((wr->send_flags & IBV_SEND_FENCE) ? - MTHCA_NEXT_FENCE : 0)); - - if (!size0) { - size0 = size; - op0 = mthca_opcode[wr->opcode]; - f0 = wr->send_flags & IBV_SEND_FENCE ? - MTHCA_SEND_DOORBELL_FENCE : 0; - } - - ++ind; - if (ind >= qp->sq.max) - ind -= qp->sq.max; - } - -out: - if (nreq) { - doorbell[0] = - (nreq << 24) | ((qp->sq.head & 0xffff) << 8) | f0 | op0; - doorbell[1] = (ibqp->qp_num << 8) | size0; - - qp->sq.head += nreq; - - /* - * Make sure that descriptors are written before - * doorbell record. - */ - udma_to_device_barrier(); - *qp->sq.db = htobe32(qp->sq.head & 0xffff); - - /* - * Make sure doorbell record is written before we - * write MMIO send doorbell. - */ - mmio_ordered_writes_hack(); - mthca_write64(doorbell, to_mctx(ibqp->context)->uar + - MTHCA_SEND_DOORBELL); - } - - pthread_spin_unlock(&qp->sq.lock); - return ret; -} - -int mthca_arbel_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mthca_qp *qp = to_mqp(ibqp); - int ret = 0; - int nreq; - int ind; - int i; - void *wqe; - - pthread_spin_lock(&qp->rq.lock); - - /* XXX check that state is OK to post receive */ - - ind = qp->rq.head & (qp->rq.max - 1); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - if (wq_overflow(&qp->rq, nreq, to_mcq(qp->ibv_qp.recv_cq))) { - ret = -1; - *bad_wr = wr; - goto out; - } - - wqe = get_recv_wqe(qp, ind); - - ((struct mthca_next_seg *) wqe)->flags = 0; - - wqe += sizeof (struct mthca_next_seg); - - if (wr->num_sge > qp->rq.max_gs) { - ret = -1; - *bad_wr = wr; - goto out; - } - - for (i = 0; i < wr->num_sge; ++i) { - ((struct mthca_data_seg *) wqe)->byte_count = - htobe32(wr->sg_list[i].length); - ((struct mthca_data_seg *) wqe)->lkey = - htobe32(wr->sg_list[i].lkey); - ((struct mthca_data_seg *) wqe)->addr = - htobe64(wr->sg_list[i].addr); - wqe += sizeof (struct mthca_data_seg); - } - - if (i < qp->rq.max_gs) { - ((struct mthca_data_seg *) wqe)->byte_count = 0; - ((struct mthca_data_seg *) wqe)->lkey = htobe32(MTHCA_INVAL_LKEY); - ((struct mthca_data_seg *) wqe)->addr = 0; - } - - qp->wrid[ind] = wr->wr_id; - - ++ind; - if (ind >= qp->rq.max) - ind -= qp->rq.max; - } -out: - if (nreq) { - qp->rq.head += nreq; - - /* - * Make sure that descriptors are written before - * doorbell record. - */ - udma_to_device_barrier(); - *qp->rq.db = htobe32(qp->rq.head & 0xffff); - } - - pthread_spin_unlock(&qp->rq.lock); - return ret; -} - -int mthca_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap, - enum ibv_qp_type type, struct mthca_qp *qp) -{ - int size; - int max_sq_sge; - struct mthca_next_seg *next; - int i; - - qp->rq.max_gs = cap->max_recv_sge; - qp->sq.max_gs = cap->max_send_sge; - max_sq_sge = align(cap->max_inline_data + sizeof (struct mthca_inline_seg), - sizeof (struct mthca_data_seg)) / sizeof (struct mthca_data_seg); - if (max_sq_sge < cap->max_send_sge) - max_sq_sge = cap->max_send_sge; - - qp->wrid = malloc((qp->rq.max + qp->sq.max) * sizeof (uint64_t)); - if (!qp->wrid) - return -1; - - size = sizeof (struct mthca_next_seg) + - qp->rq.max_gs * sizeof (struct mthca_data_seg); - - for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size; - qp->rq.wqe_shift++) - ; /* nothing */ - - size = max_sq_sge * sizeof (struct mthca_data_seg); - switch (type) { - case IBV_QPT_UD: - size += mthca_is_memfree(pd->context) ? - sizeof (struct mthca_arbel_ud_seg) : - sizeof (struct mthca_tavor_ud_seg); - break; - - case IBV_QPT_UC: - size += sizeof (struct mthca_raddr_seg); - break; - - case IBV_QPT_RC: - size += sizeof (struct mthca_raddr_seg); - /* - * An atomic op will require an atomic segment, a - * remote address segment and one scatter entry. - */ - if (size < (sizeof (struct mthca_atomic_seg) + - sizeof (struct mthca_raddr_seg) + - sizeof (struct mthca_data_seg))) - size = (sizeof (struct mthca_atomic_seg) + - sizeof (struct mthca_raddr_seg) + - sizeof (struct mthca_data_seg)); - break; - - default: - break; - } - - /* Make sure that we have enough space for a bind request */ - if (size < sizeof (struct mthca_bind_seg)) - size = sizeof (struct mthca_bind_seg); - - size += sizeof (struct mthca_next_seg); - - for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size; - qp->sq.wqe_shift++) - ; /* nothing */ - - qp->send_wqe_offset = align(qp->rq.max << qp->rq.wqe_shift, - 1 << qp->sq.wqe_shift); - - qp->buf_size = qp->send_wqe_offset + (qp->sq.max << qp->sq.wqe_shift); - - if (mthca_alloc_buf(&qp->buf, - align(qp->buf_size, to_mdev(pd->context->device)->page_size), - to_mdev(pd->context->device)->page_size)) { - free(qp->wrid); - return -1; - } - - memset(qp->buf.buf, 0, qp->buf_size); - - if (mthca_is_memfree(pd->context)) { - struct mthca_data_seg *scatter; - __be32 sz; - - sz = htobe32((sizeof (struct mthca_next_seg) + - qp->rq.max_gs * sizeof (struct mthca_data_seg)) / 16); - - for (i = 0; i < qp->rq.max; ++i) { - next = get_recv_wqe(qp, i); - next->nda_op = htobe32(((i + 1) & (qp->rq.max - 1)) << - qp->rq.wqe_shift); - next->ee_nds = sz; - - for (scatter = (void *) (next + 1); - (void *) scatter < (void *) next + (1 << qp->rq.wqe_shift); - ++scatter) - scatter->lkey = htobe32(MTHCA_INVAL_LKEY); - } - - for (i = 0; i < qp->sq.max; ++i) { - next = get_send_wqe(qp, i); - next->nda_op = htobe32((((i + 1) & (qp->sq.max - 1)) << - qp->sq.wqe_shift) + - qp->send_wqe_offset); - } - } else { - for (i = 0; i < qp->rq.max; ++i) { - next = get_recv_wqe(qp, i); - next->nda_op = htobe32((((i + 1) % qp->rq.max) << - qp->rq.wqe_shift) | 1); - } - } - - qp->sq.last = get_send_wqe(qp, qp->sq.max - 1); - qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1); - - return 0; -} - -struct mthca_qp *mthca_find_qp(struct mthca_context *ctx, uint32_t qpn) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (ctx->qp_table[tind].refcnt) - return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask]; - else - return NULL; -} - -int mthca_store_qp(struct mthca_context *ctx, uint32_t qpn, struct mthca_qp *qp) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (!ctx->qp_table[tind].refcnt) { - ctx->qp_table[tind].table = calloc(ctx->qp_table_mask + 1, - sizeof (struct mthca_qp *)); - if (!ctx->qp_table[tind].table) - return -1; - } - - ++ctx->qp_table[tind].refcnt; - ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = qp; - return 0; -} - -void mthca_clear_qp(struct mthca_context *ctx, uint32_t qpn) -{ - int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; - - if (!--ctx->qp_table[tind].refcnt) - free(ctx->qp_table[tind].table); - else - ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = NULL; -} - -int mthca_free_err_wqe(struct mthca_qp *qp, int is_send, - int index, int *dbd, __be32 *new_wqe) -{ - struct mthca_next_seg *next; - - /* - * For SRQs, all receive WQEs generate a CQE, so we're always - * at the end of the doorbell chain. - */ - if (qp->ibv_qp.srq && !is_send) { - *new_wqe = 0; - return 0; - } - - if (is_send) - next = get_send_wqe(qp, index); - else - next = get_recv_wqe(qp, index); - - *dbd = !!(next->ee_nds & htobe32(MTHCA_NEXT_DBD)); - if (next->ee_nds & htobe32(0x3f)) - *new_wqe = (next->nda_op & htobe32(~0x3f)) | - (next->ee_nds & htobe32(0x3f)); - else - *new_wqe = 0; - - return 0; -} - diff --git a/usr/rdma-core/providers/mthca/srq.c b/usr/rdma-core/providers/mthca/srq.c deleted file mode 100644 index ad6896134..000000000 --- a/usr/rdma-core/providers/mthca/srq.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2005 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include - -#include "mthca.h" -#include "doorbell.h" -#include "wqe.h" - -static void *get_wqe(struct mthca_srq *srq, int n) -{ - return srq->buf.buf + (n << srq->wqe_shift); -} - -/* - * Return a pointer to the location within a WQE that we're using as a - * link when the WQE is in the free list. We use the imm field at an - * offset of 12 bytes because in the Tavor case, posting a WQE may - * overwrite the next segment of the previous WQE, but a receive WQE - * will never touch the imm field. This avoids corrupting our free - * list if the previous WQE has already completed and been put on the - * free list when we post the next WQE. - */ -static inline int *wqe_to_link(void *wqe) -{ - return (int *) (wqe + 12); -} - -void mthca_free_srq_wqe(struct mthca_srq *srq, int ind) -{ - struct mthca_next_seg *last_free; - - pthread_spin_lock(&srq->lock); - - last_free = get_wqe(srq, srq->last_free); - *wqe_to_link(last_free) = ind; - last_free->nda_op = htobe32((ind << srq->wqe_shift) | 1); - *wqe_to_link(get_wqe(srq, ind)) = -1; - srq->last_free = ind; - - pthread_spin_unlock(&srq->lock); -} - -int mthca_tavor_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mthca_srq *srq = to_msrq(ibsrq); - uint32_t doorbell[2]; - int err = 0; - int first_ind; - int ind; - int next_ind; - int nreq; - int i; - void *wqe; - void *prev_wqe; - - pthread_spin_lock(&srq->lock); - - first_ind = srq->first_free; - - for (nreq = 0; wr; wr = wr->next) { - ind = srq->first_free; - wqe = get_wqe(srq, ind); - next_ind = *wqe_to_link(wqe); - - if (next_ind < 0) { - err = -1; - *bad_wr = wr; - break; - } - - prev_wqe = srq->last; - srq->last = wqe; - - ((struct mthca_next_seg *) wqe)->ee_nds = 0; - /* flags field will always remain 0 */ - - wqe += sizeof (struct mthca_next_seg); - - if (wr->num_sge > srq->max_gs) { - err = -1; - *bad_wr = wr; - srq->last = prev_wqe; - break; - } - - for (i = 0; i < wr->num_sge; ++i) { - ((struct mthca_data_seg *) wqe)->byte_count = - htobe32(wr->sg_list[i].length); - ((struct mthca_data_seg *) wqe)->lkey = - htobe32(wr->sg_list[i].lkey); - ((struct mthca_data_seg *) wqe)->addr = - htobe64(wr->sg_list[i].addr); - wqe += sizeof (struct mthca_data_seg); - } - - if (i < srq->max_gs) { - ((struct mthca_data_seg *) wqe)->byte_count = 0; - ((struct mthca_data_seg *) wqe)->lkey = htobe32(MTHCA_INVAL_LKEY); - ((struct mthca_data_seg *) wqe)->addr = 0; - } - - ((struct mthca_next_seg *) prev_wqe)->ee_nds = - htobe32(MTHCA_NEXT_DBD); - - srq->wrid[ind] = wr->wr_id; - srq->first_free = next_ind; - - if (++nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB) { - nreq = 0; - - doorbell[0] = first_ind << srq->wqe_shift; - doorbell[1] = srq->srqn << 8; - - /* - * Make sure that descriptors are written - * before doorbell is rung. - */ - udma_to_device_barrier(); - - mthca_write64(doorbell, to_mctx(ibsrq->context)->uar + - MTHCA_RECV_DOORBELL); - - first_ind = srq->first_free; - } - } - - if (nreq) { - doorbell[0] = first_ind << srq->wqe_shift; - doorbell[1] = (srq->srqn << 8) | nreq; - - /* - * Make sure that descriptors are written before - * doorbell is rung. - */ - udma_to_device_barrier(); - - mthca_write64(doorbell, to_mctx(ibsrq->context)->uar + - MTHCA_RECV_DOORBELL); - } - - pthread_spin_unlock(&srq->lock); - return err; -} - -int mthca_arbel_post_srq_recv(struct ibv_srq *ibsrq, - struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct mthca_srq *srq = to_msrq(ibsrq); - int err = 0; - int ind; - int next_ind; - int nreq; - int i; - void *wqe; - - pthread_spin_lock(&srq->lock); - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - ind = srq->first_free; - wqe = get_wqe(srq, ind); - next_ind = *wqe_to_link(wqe); - - if (next_ind < 0) { - err = -1; - *bad_wr = wr; - break; - } - - ((struct mthca_next_seg *) wqe)->ee_nds = 0; - /* flags field will always remain 0 */ - - wqe += sizeof (struct mthca_next_seg); - - if (wr->num_sge > srq->max_gs) { - err = -1; - *bad_wr = wr; - break; - } - - for (i = 0; i < wr->num_sge; ++i) { - ((struct mthca_data_seg *) wqe)->byte_count = - htobe32(wr->sg_list[i].length); - ((struct mthca_data_seg *) wqe)->lkey = - htobe32(wr->sg_list[i].lkey); - ((struct mthca_data_seg *) wqe)->addr = - htobe64(wr->sg_list[i].addr); - wqe += sizeof (struct mthca_data_seg); - } - - if (i < srq->max_gs) { - ((struct mthca_data_seg *) wqe)->byte_count = 0; - ((struct mthca_data_seg *) wqe)->lkey = htobe32(MTHCA_INVAL_LKEY); - ((struct mthca_data_seg *) wqe)->addr = 0; - } - - srq->wrid[ind] = wr->wr_id; - srq->first_free = next_ind; - } - - if (nreq) { - srq->counter += nreq; - - /* - * Make sure that descriptors are written before - * we write doorbell record. - */ - udma_ordering_write_barrier(); - *srq->db = htobe32(srq->counter); - } - - pthread_spin_unlock(&srq->lock); - return err; -} - -int mthca_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr, - struct mthca_srq *srq) -{ - struct mthca_data_seg *scatter; - void *wqe; - int size; - int i; - - srq->wrid = malloc(srq->max * sizeof (uint64_t)); - if (!srq->wrid) - return -1; - - size = sizeof (struct mthca_next_seg) + - srq->max_gs * sizeof (struct mthca_data_seg); - - for (srq->wqe_shift = 6; 1 << srq->wqe_shift < size; ++srq->wqe_shift) - ; /* nothing */ - - srq->buf_size = srq->max << srq->wqe_shift; - - if (mthca_alloc_buf(&srq->buf, - align(srq->buf_size, to_mdev(pd->context->device)->page_size), - to_mdev(pd->context->device)->page_size)) { - free(srq->wrid); - return -1; - } - - memset(srq->buf.buf, 0, srq->buf_size); - - /* - * Now initialize the SRQ buffer so that all of the WQEs are - * linked into the list of free WQEs. In addition, set the - * scatter list L_Keys to the sentry value of 0x100. - */ - - for (i = 0; i < srq->max; ++i) { - struct mthca_next_seg *next; - - next = wqe = get_wqe(srq, i); - - if (i < srq->max - 1) { - *wqe_to_link(wqe) = i + 1; - next->nda_op = htobe32(((i + 1) << srq->wqe_shift) | 1); - } else { - *wqe_to_link(wqe) = -1; - next->nda_op = 0; - } - - for (scatter = wqe + sizeof (struct mthca_next_seg); - (void *) scatter < wqe + (1 << srq->wqe_shift); - ++scatter) - scatter->lkey = htobe32(MTHCA_INVAL_LKEY); - } - - srq->first_free = 0; - srq->last_free = srq->max - 1; - srq->last = get_wqe(srq, srq->max - 1); - - return 0; -} diff --git a/usr/rdma-core/providers/mthca/verbs.c b/usr/rdma-core/providers/mthca/verbs.c deleted file mode 100644 index 33024be2e..000000000 --- a/usr/rdma-core/providers/mthca/verbs.c +++ /dev/null @@ -1,731 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include - -#include "mthca.h" -#include "mthca-abi.h" - -int mthca_query_device(struct ibv_context *context, struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, sizeof cmd); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%d", major, minor, sub_minor); - - return 0; -} - -int mthca_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); -} - -struct ibv_pd *mthca_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct mthca_alloc_pd_resp resp; - struct mthca_pd *pd; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - - if (!mthca_is_memfree(context)) { - pd->ah_list = NULL; - if (pthread_mutex_init(&pd->ah_mutex, NULL)) { - free(pd); - return NULL; - } - } - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(pd); - return NULL; - } - - pd->pdn = resp.pdn; - - return &pd->ibv_pd; -} - -int mthca_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - free(to_mpd(pd)); - return 0; -} - -static struct ibv_mr *__mthca_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, uint64_t hca_va, - int access, - int dma_sync) -{ - struct ibv_mr *mr; - struct mthca_reg_mr cmd; - struct ibv_reg_mr_resp resp; - int ret; - - /* - * Old kernels just ignore the extra data we pass in with the - * reg_mr command structure, so there's no need to add an ABI - * version check here (and indeed the kernel ABI was not - * incremented due to this change). - */ - cmd.mr_attrs = dma_sync ? MTHCA_MR_DMASYNC : 0; - cmd.reserved = 0; - - mr = malloc(sizeof *mr); - if (!mr) - return NULL; - - ret = ibv_cmd_reg_mr(pd, addr, length, hca_va, access, mr, &cmd.ibv_cmd, - sizeof cmd, &resp, sizeof resp); - if (ret) { - free(mr); - return NULL; - } - - return mr; -} - -struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - return __mthca_reg_mr(pd, addr, length, (uintptr_t) addr, access, 0); -} - -int mthca_dereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - free(mr); - return 0; -} - -static int align_cq_size(int cqe) -{ - int nent; - - for (nent = 1; nent <= cqe; nent <<= 1) - ; /* nothing */ - - return nent; -} - -struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct mthca_create_cq cmd; - struct mthca_create_cq_resp resp; - struct mthca_cq *cq; - int ret; - - /* Sanity check CQ size before proceeding */ - if (cqe > 131072) - return NULL; - - cq = malloc(sizeof *cq); - if (!cq) - return NULL; - - cq->cons_index = 0; - - if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE)) - goto err; - - cqe = align_cq_size(cqe); - if (mthca_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe)) - goto err; - - cq->mr = __mthca_reg_mr(to_mctx(context)->pd, cq->buf.buf, - cqe * MTHCA_CQ_ENTRY_SIZE, - 0, IBV_ACCESS_LOCAL_WRITE, 1); - if (!cq->mr) - goto err_buf; - - cq->mr->context = context; - - if (mthca_is_memfree(context)) { - cq->arm_sn = 1; - cq->set_ci_db_index = mthca_alloc_db(to_mctx(context)->db_tab, - MTHCA_DB_TYPE_CQ_SET_CI, - &cq->set_ci_db); - if (cq->set_ci_db_index < 0) - goto err_unreg; - - cq->arm_db_index = mthca_alloc_db(to_mctx(context)->db_tab, - MTHCA_DB_TYPE_CQ_ARM, - &cq->arm_db); - if (cq->arm_db_index < 0) - goto err_set_db; - - cmd.arm_db_page = db_align(cq->arm_db); - cmd.set_db_page = db_align(cq->set_ci_db); - cmd.arm_db_index = cq->arm_db_index; - cmd.set_db_index = cq->set_ci_db_index; - } else { - cmd.arm_db_page = cmd.set_db_page = - cmd.arm_db_index = cmd.set_db_index = 0; - } - - cmd.lkey = cq->mr->lkey; - cmd.pdn = to_mpd(to_mctx(context)->pd)->pdn; - ret = ibv_cmd_create_cq(context, cqe - 1, channel, comp_vector, - &cq->ibv_cq, &cmd.ibv_cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) - goto err_arm_db; - - cq->cqn = resp.cqn; - - if (mthca_is_memfree(context)) { - mthca_set_db_qn(cq->set_ci_db, MTHCA_DB_TYPE_CQ_SET_CI, cq->cqn); - mthca_set_db_qn(cq->arm_db, MTHCA_DB_TYPE_CQ_ARM, cq->cqn); - } - - return &cq->ibv_cq; - -err_arm_db: - if (mthca_is_memfree(context)) - mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_ARM, - cq->arm_db_index); - -err_set_db: - if (mthca_is_memfree(context)) - mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_SET_CI, - cq->set_ci_db_index); - -err_unreg: - mthca_dereg_mr(cq->mr); - -err_buf: - mthca_free_buf(&cq->buf); - -err: - free(cq); - - return NULL; -} - -int mthca_resize_cq(struct ibv_cq *ibcq, int cqe) -{ - struct mthca_cq *cq = to_mcq(ibcq); - struct mthca_resize_cq cmd; - struct ibv_mr *mr; - struct mthca_buf buf; - struct ibv_resize_cq_resp resp; - int old_cqe; - int ret; - - /* Sanity check CQ size before proceeding */ - if (cqe > 131072) - return EINVAL; - - pthread_spin_lock(&cq->lock); - - cqe = align_cq_size(cqe); - if (cqe == ibcq->cqe + 1) { - ret = 0; - goto out; - } - - ret = mthca_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe); - if (ret) - goto out; - - mr = __mthca_reg_mr(to_mctx(ibcq->context)->pd, buf.buf, - cqe * MTHCA_CQ_ENTRY_SIZE, - 0, IBV_ACCESS_LOCAL_WRITE, 1); - if (!mr) { - mthca_free_buf(&buf); - ret = ENOMEM; - goto out; - } - - mr->context = ibcq->context; - - old_cqe = ibcq->cqe; - - cmd.lkey = mr->lkey; - ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd, &resp, - sizeof resp); - if (ret) { - mthca_dereg_mr(mr); - mthca_free_buf(&buf); - goto out; - } - - mthca_cq_resize_copy_cqes(cq, buf.buf, old_cqe); - - mthca_dereg_mr(cq->mr); - mthca_free_buf(&cq->buf); - - cq->buf = buf; - cq->mr = mr; - -out: - pthread_spin_unlock(&cq->lock); - return ret; -} - -int mthca_destroy_cq(struct ibv_cq *cq) -{ - int ret; - - ret = ibv_cmd_destroy_cq(cq); - if (ret) - return ret; - - if (mthca_is_memfree(cq->context)) { - mthca_free_db(to_mctx(cq->context)->db_tab, MTHCA_DB_TYPE_CQ_SET_CI, - to_mcq(cq)->set_ci_db_index); - mthca_free_db(to_mctx(cq->context)->db_tab, MTHCA_DB_TYPE_CQ_ARM, - to_mcq(cq)->arm_db_index); - } - - mthca_dereg_mr(to_mcq(cq)->mr); - mthca_free_buf(&to_mcq(cq)->buf); - free(to_mcq(cq)); - - return 0; -} - -static int align_queue_size(struct ibv_context *context, int size, int spare) -{ - int ret; - - /* - * If someone asks for a 0-sized queue, presumably they're not - * going to use it. So don't mess with their size. - */ - if (!size) - return 0; - - if (mthca_is_memfree(context)) { - for (ret = 1; ret < size + spare; ret <<= 1) - ; /* nothing */ - - return ret; - } else - return size + spare; -} - -struct ibv_srq *mthca_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct mthca_create_srq cmd; - struct mthca_create_srq_resp resp; - struct mthca_srq *srq; - int ret; - - /* Sanity check SRQ size before proceeding */ - if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64) - return NULL; - - srq = malloc(sizeof *srq); - if (!srq) - return NULL; - - if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE)) - goto err; - - srq->max = align_queue_size(pd->context, attr->attr.max_wr, 1); - srq->max_gs = attr->attr.max_sge; - srq->counter = 0; - - if (mthca_alloc_srq_buf(pd, &attr->attr, srq)) - goto err; - - srq->mr = __mthca_reg_mr(pd, srq->buf.buf, srq->buf_size, 0, 0, 0); - if (!srq->mr) - goto err_free; - - srq->mr->context = pd->context; - - if (mthca_is_memfree(pd->context)) { - srq->db_index = mthca_alloc_db(to_mctx(pd->context)->db_tab, - MTHCA_DB_TYPE_SRQ, &srq->db); - if (srq->db_index < 0) - goto err_unreg; - - cmd.db_page = db_align(srq->db); - cmd.db_index = srq->db_index; - } else { - cmd.db_page = cmd.db_index = 0; - } - - cmd.lkey = srq->mr->lkey; - - ret = ibv_cmd_create_srq(pd, &srq->ibv_srq, attr, - &cmd.ibv_cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) - goto err_db; - - srq->srqn = resp.srqn; - - if (mthca_is_memfree(pd->context)) - mthca_set_db_qn(srq->db, MTHCA_DB_TYPE_SRQ, srq->srqn); - - return &srq->ibv_srq; - -err_db: - if (mthca_is_memfree(pd->context)) - mthca_free_db(to_mctx(pd->context)->db_tab, MTHCA_DB_TYPE_SRQ, - srq->db_index); - -err_unreg: - mthca_dereg_mr(srq->mr); - -err_free: - free(srq->wrid); - mthca_free_buf(&srq->buf); - -err: - free(srq); - - return NULL; -} - -int mthca_modify_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr, - int attr_mask) -{ - struct ibv_modify_srq cmd; - - return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd); -} - -int mthca_query_srq(struct ibv_srq *srq, - struct ibv_srq_attr *attr) -{ - struct ibv_query_srq cmd; - - return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd); -} - -int mthca_destroy_srq(struct ibv_srq *srq) -{ - int ret; - - ret = ibv_cmd_destroy_srq(srq); - if (ret) - return ret; - - if (mthca_is_memfree(srq->context)) - mthca_free_db(to_mctx(srq->context)->db_tab, MTHCA_DB_TYPE_SRQ, - to_msrq(srq)->db_index); - - mthca_dereg_mr(to_msrq(srq)->mr); - - mthca_free_buf(&to_msrq(srq)->buf); - free(to_msrq(srq)->wrid); - free(to_msrq(srq)); - - return 0; -} - -struct ibv_qp *mthca_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) -{ - struct mthca_create_qp cmd; - struct ibv_create_qp_resp resp; - struct mthca_qp *qp; - int ret; - - /* Sanity check QP size before proceeding */ - if (attr->cap.max_send_wr > 65536 || - attr->cap.max_recv_wr > 65536 || - attr->cap.max_send_sge > 64 || - attr->cap.max_recv_sge > 64 || - attr->cap.max_inline_data > 1024) - return NULL; - - qp = malloc(sizeof *qp); - if (!qp) - return NULL; - - qp->sq.max = align_queue_size(pd->context, attr->cap.max_send_wr, 0); - qp->rq.max = align_queue_size(pd->context, attr->cap.max_recv_wr, 0); - - if (mthca_alloc_qp_buf(pd, &attr->cap, attr->qp_type, qp)) - goto err; - - mthca_init_qp_indices(qp); - - if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) || - pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE)) - goto err_free; - - qp->mr = __mthca_reg_mr(pd, qp->buf.buf, qp->buf_size, 0, 0, 0); - if (!qp->mr) - goto err_free; - - qp->mr->context = pd->context; - - cmd.lkey = qp->mr->lkey; - cmd.reserved = 0; - - if (mthca_is_memfree(pd->context)) { - qp->sq.db_index = mthca_alloc_db(to_mctx(pd->context)->db_tab, - MTHCA_DB_TYPE_SQ, - &qp->sq.db); - if (qp->sq.db_index < 0) - goto err_unreg; - - qp->rq.db_index = mthca_alloc_db(to_mctx(pd->context)->db_tab, - MTHCA_DB_TYPE_RQ, - &qp->rq.db); - if (qp->rq.db_index < 0) - goto err_sq_db; - - cmd.sq_db_page = db_align(qp->sq.db); - cmd.rq_db_page = db_align(qp->rq.db); - cmd.sq_db_index = qp->sq.db_index; - cmd.rq_db_index = qp->rq.db_index; - } else { - cmd.sq_db_page = cmd.rq_db_page = - cmd.sq_db_index = cmd.rq_db_index = 0; - } - - pthread_mutex_lock(&to_mctx(pd->context)->qp_table_mutex); - ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd, - &resp, sizeof resp); - if (ret) - goto err_rq_db; - - if (mthca_is_memfree(pd->context)) { - mthca_set_db_qn(qp->sq.db, MTHCA_DB_TYPE_SQ, qp->ibv_qp.qp_num); - mthca_set_db_qn(qp->rq.db, MTHCA_DB_TYPE_RQ, qp->ibv_qp.qp_num); - } - - ret = mthca_store_qp(to_mctx(pd->context), qp->ibv_qp.qp_num, qp); - if (ret) - goto err_destroy; - pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex); - - qp->sq.max = attr->cap.max_send_wr; - qp->rq.max = attr->cap.max_recv_wr; - qp->sq.max_gs = attr->cap.max_send_sge; - qp->rq.max_gs = attr->cap.max_recv_sge; - qp->max_inline_data = attr->cap.max_inline_data; - - return &qp->ibv_qp; - -err_destroy: - ibv_cmd_destroy_qp(&qp->ibv_qp); - -err_rq_db: - pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex); - if (mthca_is_memfree(pd->context)) - mthca_free_db(to_mctx(pd->context)->db_tab, MTHCA_DB_TYPE_RQ, - qp->rq.db_index); - -err_sq_db: - if (mthca_is_memfree(pd->context)) - mthca_free_db(to_mctx(pd->context)->db_tab, MTHCA_DB_TYPE_SQ, - qp->sq.db_index); - -err_unreg: - mthca_dereg_mr(qp->mr); - -err_free: - free(qp->wrid); - mthca_free_buf(&qp->buf); - -err: - free(qp); - - return NULL; -} - -int mthca_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - - return ibv_cmd_query_qp(qp, attr, attr_mask, init_attr, &cmd, sizeof cmd); -} - -int mthca_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - int ret; - - ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof cmd); - - if (!ret && - (attr_mask & IBV_QP_STATE) && - attr->qp_state == IBV_QPS_RESET) { - mthca_cq_clean(to_mcq(qp->recv_cq), qp->qp_num, - qp->srq ? to_msrq(qp->srq) : NULL); - if (qp->send_cq != qp->recv_cq) - mthca_cq_clean(to_mcq(qp->send_cq), qp->qp_num, NULL); - - mthca_init_qp_indices(to_mqp(qp)); - - if (mthca_is_memfree(qp->context)) { - *to_mqp(qp)->sq.db = 0; - *to_mqp(qp)->rq.db = 0; - } - } - - return ret; -} - -static void mthca_lock_cqs(struct ibv_qp *qp) -{ - struct mthca_cq *send_cq = to_mcq(qp->send_cq); - struct mthca_cq *recv_cq = to_mcq(qp->recv_cq); - - if (send_cq == recv_cq) - pthread_spin_lock(&send_cq->lock); - else if (send_cq->cqn < recv_cq->cqn) { - pthread_spin_lock(&send_cq->lock); - pthread_spin_lock(&recv_cq->lock); - } else { - pthread_spin_lock(&recv_cq->lock); - pthread_spin_lock(&send_cq->lock); - } -} - -static void mthca_unlock_cqs(struct ibv_qp *qp) -{ - struct mthca_cq *send_cq = to_mcq(qp->send_cq); - struct mthca_cq *recv_cq = to_mcq(qp->recv_cq); - - if (send_cq == recv_cq) - pthread_spin_unlock(&send_cq->lock); - else if (send_cq->cqn < recv_cq->cqn) { - pthread_spin_unlock(&recv_cq->lock); - pthread_spin_unlock(&send_cq->lock); - } else { - pthread_spin_unlock(&send_cq->lock); - pthread_spin_unlock(&recv_cq->lock); - } -} - -int mthca_destroy_qp(struct ibv_qp *qp) -{ - int ret; - - pthread_mutex_lock(&to_mctx(qp->context)->qp_table_mutex); - ret = ibv_cmd_destroy_qp(qp); - if (ret) { - pthread_mutex_unlock(&to_mctx(qp->context)->qp_table_mutex); - return ret; - } - - mthca_lock_cqs(qp); - - __mthca_cq_clean(to_mcq(qp->recv_cq), qp->qp_num, - qp->srq ? to_msrq(qp->srq) : NULL); - if (qp->send_cq != qp->recv_cq) - __mthca_cq_clean(to_mcq(qp->send_cq), qp->qp_num, NULL); - - mthca_clear_qp(to_mctx(qp->context), qp->qp_num); - - mthca_unlock_cqs(qp); - pthread_mutex_unlock(&to_mctx(qp->context)->qp_table_mutex); - - if (mthca_is_memfree(qp->context)) { - mthca_free_db(to_mctx(qp->context)->db_tab, MTHCA_DB_TYPE_RQ, - to_mqp(qp)->rq.db_index); - mthca_free_db(to_mctx(qp->context)->db_tab, MTHCA_DB_TYPE_SQ, - to_mqp(qp)->sq.db_index); - } - - mthca_dereg_mr(to_mqp(qp)->mr); - mthca_free_buf(&to_mqp(qp)->buf); - free(to_mqp(qp)->wrid); - free(to_mqp(qp)); - - return 0; -} - -struct ibv_ah *mthca_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - struct mthca_ah *ah; - - ah = malloc(sizeof *ah); - if (!ah) - return NULL; - - if (mthca_alloc_av(to_mpd(pd), attr, ah)) { - free(ah); - return NULL; - } - - return &ah->ibv_ah; -} - -int mthca_destroy_ah(struct ibv_ah *ah) -{ - mthca_free_av(to_mah(ah)); - free(to_mah(ah)); - - return 0; -} diff --git a/usr/rdma-core/providers/mthca/wqe.h b/usr/rdma-core/providers/mthca/wqe.h deleted file mode 100644 index e56ed9c26..000000000 --- a/usr/rdma-core/providers/mthca/wqe.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Cisco Systems. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef WQE_H -#define WQE_H - -#include - -enum { - MTHCA_SEND_DOORBELL = 0x10, - MTHCA_RECV_DOORBELL = 0x18 -}; - -enum { - MTHCA_NEXT_DBD = 1 << 7, - MTHCA_NEXT_FENCE = 1 << 6, - MTHCA_NEXT_CQ_UPDATE = 1 << 3, - MTHCA_NEXT_EVENT_GEN = 1 << 2, - MTHCA_NEXT_SOLICIT = 1 << 1, -}; - -enum { - MTHCA_INLINE_SEG = 1 << 31 -}; - -enum { - MTHCA_INVAL_LKEY = 0x100, - MTHCA_TAVOR_MAX_WQES_PER_RECV_DB = 256, - MTHCA_ARBEL_MAX_WQES_PER_SEND_DB = 255 -}; - -struct mthca_next_seg { - __be32 nda_op; /* [31:6] next WQE [4:0] next opcode */ - __be32 ee_nds; /* [31:8] next EE [7] DBD [6] F [5:0] next WQE size */ - __be32 flags; /* [3] CQ [2] Event [1] Solicit */ - __be32 imm; /* immediate data */ -}; - -struct mthca_tavor_ud_seg { - __be32 reserved1; - __be32 lkey; - __be64 av_addr; - __be32 reserved2[4]; - __be32 dqpn; - __be32 qkey; - __be32 reserved3[2]; -}; - -struct mthca_arbel_ud_seg { - __be32 av[8]; - __be32 dqpn; - __be32 qkey; - __be32 reserved[2]; -}; - -struct mthca_bind_seg { - __be32 flags; /* [31] Atomic [30] rem write [29] rem read */ - __be32 reserved; - __be32 new_rkey; - __be32 lkey; - __be64 addr; - __be64 length; -}; - -struct mthca_raddr_seg { - __be64 raddr; - __be32 rkey; - __be32 reserved; -}; - -struct mthca_atomic_seg { - __be64 swap_add; - __be64 compare; -}; - -struct mthca_data_seg { - __be32 byte_count; - __be32 lkey; - __be64 addr; -}; - -struct mthca_inline_seg { - __be32 byte_count; -}; - -#endif /* WQE_H */ diff --git a/usr/rdma-core/providers/nes/CMakeLists.txt b/usr/rdma-core/providers/nes/CMakeLists.txt deleted file mode 100644 index 0c7fa8fad..000000000 --- a/usr/rdma-core/providers/nes/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -rdma_provider(nes - nes_umain.c - nes_uverbs.c -) diff --git a/usr/rdma-core/providers/nes/nes-abi.h b/usr/rdma-core/providers/nes/nes-abi.h deleted file mode 100644 index f363f95e8..000000000 --- a/usr/rdma-core/providers/nes/nes-abi.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2006 - 2010 Intel Corporation. All rights reserved. - * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * gpl-2.0.txt in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef nes_ABI_H -#define nes_ABI_H - -#include - -#define NES_ABI_USERSPACE_VER 2 -#define NES_ABI_KERNEL_VER 2 - -struct nes_get_context { - struct ibv_get_context cmd; - __u32 reserved32; - __u8 userspace_ver; - __u8 reserved8[3]; -}; - - -struct nes_ualloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - __u32 max_pds; /* maximum pds allowed for this user process */ - __u32 max_qps; /* maximum qps allowed for this user process */ - __u32 wq_size; /* defines the size of the WQs (sq+rq) allocated to the mmaped area */ - __u8 virtwq; - __u8 kernel_ver; - __u8 reserved[2]; -}; - -struct nes_ualloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - __u32 pd_id; - __u32 db_index; -}; - -struct nes_ucreate_cq { - struct ibv_create_cq ibv_cmd; - __u64 user_cq_buffer; - __u32 mcrqf; - __u8 reserved[4]; -}; - -struct nes_ucreate_cq_resp { - struct ibv_create_cq_resp ibv_resp; - __u32 cq_id; - __u32 cq_size; - __u32 mmap_db_index; - __u32 reserved; -}; - -enum nes_umemreg_type { - NES_UMEMREG_TYPE_MEM = 0x0000, - NES_UMEMREG_TYPE_QP = 0x0001, - NES_UMEMREG_TYPE_CQ = 0x0002, -}; - -struct nes_ureg_mr { - struct ibv_reg_mr ibv_cmd; - __u32 reg_type; /* indicates if id is memory, QP or CQ */ - __u32 reserved; -}; - -struct nes_ucreate_qp { - struct ibv_create_qp ibv_cmd; - __u64 user_sq_buffer; - __u64 user_qp_buffer; -}; - -struct nes_ucreate_qp_resp { - struct ibv_create_qp_resp ibv_resp; - __u32 qp_id; - __u32 actual_sq_size; - __u32 actual_rq_size; - __u32 mmap_sq_db_index; - __u32 mmap_rq_db_index; - __u32 nes_drv_opt; -}; - -struct nes_cqe { - __u32 header; - __u32 len; - __u32 wrid_hi_stag; - __u32 wrid_low_msn; -}; - -#endif /* nes_ABI_H */ diff --git a/usr/rdma-core/providers/nes/nes_umain.c b/usr/rdma-core/providers/nes/nes_umain.c deleted file mode 100644 index fd3d19def..000000000 --- a/usr/rdma-core/providers/nes/nes_umain.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2006 - 2010 Intel Corporation. All rights reserved. - * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * gpl-2.0.txt in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "nes_umain.h" -#include "nes-abi.h" - -unsigned int nes_debug_level = 0; -long int page_size; - -#include -#include -#include - -#ifndef PCI_VENDOR_ID_NETEFFECT -#define PCI_VENDOR_ID_NETEFFECT 0x1678 -#endif - -#define HCA(v, d, t) \ - VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, d, (void *)(NETEFFECT_##t)) -static const struct verbs_match_ent hca_table[] = { - HCA(NETEFFECT, 0x0100, nes), - HCA(NETEFFECT, 0x0110, nes), - {}, -}; - -static struct ibv_context *nes_ualloc_context(struct ibv_device *, int); -static void nes_ufree_context(struct ibv_context *); - -static struct ibv_context_ops nes_uctx_ops = { - .query_device = nes_uquery_device, - .query_port = nes_uquery_port, - .alloc_pd = nes_ualloc_pd, - .dealloc_pd = nes_ufree_pd, - .reg_mr = nes_ureg_mr, - .dereg_mr = nes_udereg_mr, - .create_cq = nes_ucreate_cq, - .poll_cq = nes_upoll_cq, - .req_notify_cq = nes_uarm_cq, - .cq_event = nes_cq_event, - .resize_cq = nes_uresize_cq, - .destroy_cq = nes_udestroy_cq, - .create_srq = NULL, - .modify_srq = NULL, - .query_srq = NULL, - .destroy_srq = NULL, - .post_srq_recv = NULL, - .create_qp = nes_ucreate_qp, - .query_qp = nes_uquery_qp, - .modify_qp = nes_umodify_qp, - .destroy_qp = nes_udestroy_qp, - .post_send = nes_upost_send, - .post_recv = nes_upost_recv, - .create_ah = nes_ucreate_ah, - .destroy_ah = nes_udestroy_ah, - .attach_mcast = nes_uattach_mcast, - .detach_mcast = nes_udetach_mcast, - .async_event = nes_async_event -}; - - -/** - * nes_ualloc_context - */ -static struct ibv_context *nes_ualloc_context(struct ibv_device *ibdev, int cmd_fd) -{ - struct ibv_pd *ibv_pd; - struct nes_uvcontext *nesvctx; - struct nes_get_context cmd; - struct nes_ualloc_ucontext_resp resp; - char value[16]; - uint32_t nes_drv_opt = 0; - - page_size = sysconf(_SC_PAGESIZE); - - nesvctx = malloc(sizeof *nesvctx); - if (!nesvctx) - return NULL; - - memset(nesvctx, 0, sizeof *nesvctx); - nesvctx->ibv_ctx.cmd_fd = cmd_fd; - cmd.userspace_ver = NES_ABI_USERSPACE_VER; - - if (ibv_cmd_get_context(&nesvctx->ibv_ctx, (struct ibv_get_context *)&cmd, sizeof cmd, - &resp.ibv_resp, sizeof(resp))) - goto err_free; - - if (resp.kernel_ver != NES_ABI_KERNEL_VER) { - fprintf(stderr, PFX "%s: Invalid kernel driver version detected. Detected %d, should be %d\n", - __FUNCTION__, resp.kernel_ver, NES_ABI_KERNEL_VER); - goto err_free; - } - - if (ibv_read_sysfs_file("/sys/module/iw_nes", "parameters/nes_drv_opt", - value, sizeof(value)) > 0) { - sscanf(value, "%d", &nes_drv_opt); - } else if (ibv_read_sysfs_file("/sys/module/iw_nes", "nes_drv_opt", - value, sizeof(value)) > 0) { - sscanf(value, "%d", &nes_drv_opt); - } - - nesvctx->ibv_ctx.device = ibdev; - - if (nes_drv_opt & NES_DRV_OPT_NO_DB_READ) - nes_uctx_ops.poll_cq = nes_upoll_cq_no_db_read; - - nesvctx->ibv_ctx.ops = nes_uctx_ops; - nesvctx->max_pds = resp.max_pds; - nesvctx->max_qps = resp.max_qps; - nesvctx->wq_size = resp.wq_size; - nesvctx->virtwq = resp.virtwq; - nesvctx->mcrqf = 0; - - /* Get a doorbell region for the CQs */ - ibv_pd = nes_ualloc_pd(&nesvctx->ibv_ctx); - if (!ibv_pd) - goto err_free; - ibv_pd->context = &nesvctx->ibv_ctx; - nesvctx->nesupd = to_nes_upd(ibv_pd); - - return &nesvctx->ibv_ctx; - -err_free: - fprintf(stderr, PFX "%s: Failed to allocate context for device.\n", __FUNCTION__); - free(nesvctx); - - return NULL; -} - - -/** - * nes_ufree_context - */ -static void nes_ufree_context(struct ibv_context *ibctx) -{ - struct nes_uvcontext *nesvctx = to_nes_uctx(ibctx); - nes_ufree_pd(&nesvctx->nesupd->ibv_pd); - - free(nesvctx); -} - -static void nes_uninit_device(struct verbs_device *verbs_device) -{ - struct nes_udevice *dev = to_nes_udev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device * -nes_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct nes_udevice *dev; - char value[16]; - - if (ibv_read_sysfs_file("/sys/module/iw_nes", "parameters/debug_level", - value, sizeof(value)) > 0) { - sscanf(value, "%u", &nes_debug_level); - } else if (ibv_read_sysfs_file("/sys/module/iw_nes", "debug_level", - value, sizeof(value)) > 0) { - sscanf(value, "%u", &nes_debug_level); - } - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->hca_type = (uintptr_t)sysfs_dev->match->driver_data; - dev->page_size = sysconf(_SC_PAGESIZE); - - nes_debug(NES_DBG_INIT, "libnes initialized\n"); - - return &dev->ibv_dev; -} - -static const struct verbs_device_ops nes_udev_ops = { - .name = "nes", - .match_min_abi_version = 0, - .match_max_abi_version = INT_MAX, - .match_table = hca_table, - .alloc_device = nes_device_alloc, - .uninit_device = nes_uninit_device, - .alloc_context = nes_ualloc_context, - .free_context = nes_ufree_context, -}; -PROVIDER_DRIVER(nes_udev_ops); diff --git a/usr/rdma-core/providers/nes/nes_umain.h b/usr/rdma-core/providers/nes/nes_umain.h deleted file mode 100644 index 94c81c2fa..000000000 --- a/usr/rdma-core/providers/nes/nes_umain.h +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (c) 2006 - 2010 Intel Corporation. All rights reserved. - * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * gpl-2.0.txt in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef nes_umain_H -#define nes_umain_H - -#include -#include -#include -#include - -#include -#include - -#define PFX "libnes: " - -#define NES_QP_MMAP 1 -#define NES_QP_VMAP 2 - -#define NES_DRV_OPT_NO_INLINE_DATA 0x00000080 -#define NES_DRV_OPT_NO_DB_READ 0x00001000 - -#define NES_DEBUG -/* debug levels */ -/* must match kernel */ -#define NES_DBG_HW 0x00000001 -#define NES_DBG_INIT 0x00000002 -#define NES_DBG_ISR 0x00000004 -#define NES_DBG_PHY 0x00000008 -#define NES_DBG_NETDEV 0x00000010 -#define NES_DBG_CM 0x00000020 -#define NES_DBG_CM1 0x00000040 -#define NES_DBG_NIC_RX 0x00000080 -#define NES_DBG_NIC_TX 0x00000100 -#define NES_DBG_CQP 0x00000200 -#define NES_DBG_MMAP 0x00000400 -#define NES_DBG_MR 0x00000800 -#define NES_DBG_PD 0x00001000 -#define NES_DBG_CQ 0x00002000 -#define NES_DBG_QP 0x00004000 -#define NES_DBG_MOD_QP 0x00008000 -#define NES_DBG_AEQ 0x00010000 -#define NES_DBG_IW_RX 0x00020000 -#define NES_DBG_IW_TX 0x00040000 -#define NES_DBG_SHUTDOWN 0x00080000 -#define NES_DBG_UD 0x00100000 -#define NES_DBG_RSVD1 0x10000000 -#define NES_DBG_RSVD2 0x20000000 -#define NES_DBG_RSVD3 0x40000000 -#define NES_DBG_RSVD4 0x80000000 -#define NES_DBG_ALL 0xffffffff - -extern unsigned int nes_debug_level; -#ifdef NES_DEBUG -#define nes_debug(level, fmt, args...) \ - if (level & nes_debug_level) \ - fprintf(stderr, PFX "%s[%u]: " fmt, __FUNCTION__, __LINE__, ##args) -#else -#define nes_debug(level, fmt, args...) -#endif - -enum nes_cqe_opcode_bits { - NES_CQE_STAG_VALID = (1<<6), - NES_CQE_ERROR = (1<<7), - NES_CQE_SQ = (1<<8), - NES_CQE_SE = (1<<9), - NES_CQE_PSH = (1<<29), - NES_CQE_FIN = (1<<30), - NES_CQE_VALID = (1<<31), -}; - -enum nes_cqe_word_idx { - NES_CQE_PAYLOAD_LENGTH_IDX = 0, - NES_CQE_COMP_COMP_CTX_LOW_IDX = 2, - NES_CQE_COMP_COMP_CTX_HIGH_IDX = 3, - NES_CQE_INV_STAG_IDX = 4, - NES_CQE_QP_ID_IDX = 5, - NES_CQE_ERROR_CODE_IDX = 6, - NES_CQE_OPCODE_IDX = 7, -}; - -enum nes_cqe_allocate_bits { - NES_CQE_ALLOC_INC_SELECT = (1<<28), - NES_CQE_ALLOC_NOTIFY_NEXT = (1<<29), - NES_CQE_ALLOC_NOTIFY_SE = (1<<30), - NES_CQE_ALLOC_RESET = (1<<31), -}; - -enum nes_iwarp_sq_wqe_word_idx { - NES_IWARP_SQ_WQE_MISC_IDX = 0, - NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX = 1, - NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX = 2, - NES_IWARP_SQ_WQE_COMP_CTX_HIGH_IDX = 3, - NES_IWARP_SQ_WQE_COMP_SCRATCH_LOW_IDX = 4, - NES_IWARP_SQ_WQE_COMP_SCRATCH_HIGH_IDX = 5, - NES_IWARP_SQ_WQE_INV_STAG_LOW_IDX = 7, - NES_IWARP_SQ_WQE_RDMA_TO_LOW_IDX = 8, - NES_IWARP_SQ_WQE_RDMA_TO_HIGH_IDX = 9, - NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX = 10, - NES_IWARP_SQ_WQE_RDMA_STAG_IDX = 11, - NES_IWARP_SQ_WQE_IMM_DATA_START_IDX = 12, - NES_IWARP_SQ_WQE_FRAG0_LOW_IDX = 16, - NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX = 17, - NES_IWARP_SQ_WQE_LENGTH0_IDX = 18, - NES_IWARP_SQ_WQE_STAG0_IDX = 19, - NES_IWARP_SQ_WQE_FRAG1_LOW_IDX = 20, - NES_IWARP_SQ_WQE_FRAG1_HIGH_IDX = 21, - NES_IWARP_SQ_WQE_LENGTH1_IDX = 22, - NES_IWARP_SQ_WQE_STAG1_IDX = 23, - NES_IWARP_SQ_WQE_FRAG2_LOW_IDX = 24, - NES_IWARP_SQ_WQE_FRAG2_HIGH_IDX = 25, - NES_IWARP_SQ_WQE_LENGTH2_IDX = 26, - NES_IWARP_SQ_WQE_STAG2_IDX = 27, - NES_IWARP_SQ_WQE_FRAG3_LOW_IDX = 28, - NES_IWARP_SQ_WQE_FRAG3_HIGH_IDX = 29, - NES_IWARP_SQ_WQE_LENGTH3_IDX = 30, - NES_IWARP_SQ_WQE_STAG3_IDX = 31, -}; - -enum nes_iwarp_rq_wqe_word_idx { - NES_IWARP_RQ_WQE_TOTAL_PAYLOAD_IDX = 1, - NES_IWARP_RQ_WQE_COMP_CTX_LOW_IDX = 2, - NES_IWARP_RQ_WQE_COMP_CTX_HIGH_IDX = 3, - NES_IWARP_RQ_WQE_COMP_SCRATCH_LOW_IDX = 4, - NES_IWARP_RQ_WQE_COMP_SCRATCH_HIGH_IDX = 5, - NES_IWARP_RQ_WQE_FRAG0_LOW_IDX = 8, - NES_IWARP_RQ_WQE_FRAG0_HIGH_IDX = 9, - NES_IWARP_RQ_WQE_LENGTH0_IDX = 10, - NES_IWARP_RQ_WQE_STAG0_IDX = 11, - NES_IWARP_RQ_WQE_FRAG1_LOW_IDX = 12, - NES_IWARP_RQ_WQE_FRAG1_HIGH_IDX = 13, - NES_IWARP_RQ_WQE_LENGTH1_IDX = 14, - NES_IWARP_RQ_WQE_STAG1_IDX = 15, - NES_IWARP_RQ_WQE_FRAG2_LOW_IDX = 16, - NES_IWARP_RQ_WQE_FRAG2_HIGH_IDX = 17, - NES_IWARP_RQ_WQE_LENGTH2_IDX = 18, - NES_IWARP_RQ_WQE_STAG2_IDX = 19, - NES_IWARP_RQ_WQE_FRAG3_LOW_IDX = 20, - NES_IWARP_RQ_WQE_FRAG3_HIGH_IDX = 21, - NES_IWARP_RQ_WQE_LENGTH3_IDX = 22, - NES_IWARP_RQ_WQE_STAG3_IDX = 23, -}; - -enum nes_iwarp_sq_opcodes { - NES_IWARP_SQ_WQE_STREAMING = (1<<23), - NES_IWARP_SQ_WQE_IMM_DATA = (1<<28), - NES_IWARP_SQ_WQE_READ_FENCE = (1<<29), - NES_IWARP_SQ_WQE_LOCAL_FENCE = (1<<30), - NES_IWARP_SQ_WQE_SIGNALED_COMPL = (1<<31), -}; - -enum nes_iwarp_sq_wqe_bits { - NES_IWARP_SQ_OP_RDMAW = 0, - NES_IWARP_SQ_OP_RDMAR = 1, - NES_IWARP_SQ_OP_SEND = 3, - NES_IWARP_SQ_OP_SENDINV = 4, - NES_IWARP_SQ_OP_SENDSE = 5, - NES_IWARP_SQ_OP_SENDSEINV = 6, - NES_IWARP_SQ_OP_BIND = 8, - NES_IWARP_SQ_OP_FAST_REG = 9, - NES_IWARP_SQ_OP_LOCINV = 10, - NES_IWARP_SQ_OP_RDMAR_LOCINV = 11, - NES_IWARP_SQ_OP_NOP = 12, -}; - -enum nes_nic_cqe_word_idx { - NES_NIC_CQE_ACCQP_ID_IDX = 0, - NES_NIC_CQE_TAG_PKT_TYPE_IDX = 2, - NES_NIC_CQE_MISC_IDX = 3, -}; - -#define NES_NIC_CQE_ERRV_SHIFT 16 -enum nes_nic_ev_bits { - NES_NIC_ERRV_BITS_MODE = (1<<0), - NES_NIC_ERRV_BITS_IPV4_CSUM_ERR = (1<<1), - NES_NIC_ERRV_BITS_TCPUDP_CSUM_ERR = (1<<2), - NES_NIC_ERRV_BITS_WQE_OVERRUN = (1<<3), - NES_NIC_ERRV_BITS_IPH_ERR = (1<<4), -}; - -enum nes_nic_cqe_bits { - NES_NIC_CQE_ERRV_MASK = (0xff< - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nes_umain.h" -#include "nes-abi.h" - -#define STATIC static -#define INLINE inline - -#define NES_WC_WITH_VLAN 1 << 3 -#define NES_UD_RX_BATCH_SZ 64 -#define NES_UD_MAX_SG_LIST_SZ 1 - -struct nes_ud_send_wr { - uint32_t wr_cnt; - uint32_t qpn; - uint32_t flags; - uint32_t resv[1]; - struct ibv_sge sg_list[64]; -}; - -struct nes_ud_recv_wr { - uint32_t wr_cnt; - uint32_t qpn; - uint32_t resv[2]; - struct ibv_sge sg_list[64]; -}; - -/** - * nes_uquery_device - */ -int nes_uquery_device(struct ibv_context *context, struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t nes_fw_ver; - int ret; - unsigned int minor, major; - - ret = ibv_cmd_query_device(context, attr, &nes_fw_ver, - &cmd, sizeof cmd); - if (ret) - return ret; - - major = (nes_fw_ver >> 16) & 0xffff; - minor = nes_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d", major, minor); - - return 0; -} - - -/** - * nes_uquery_port - */ -int nes_uquery_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); -} - - -/** - * nes_ualloc_pd - */ -struct ibv_pd *nes_ualloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct nes_ualloc_pd_resp resp; - struct nes_upd *nesupd; - - nesupd = malloc(sizeof *nesupd); - if (!nesupd) - return NULL; - - if (ibv_cmd_alloc_pd(context, &nesupd->ibv_pd, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(nesupd); - return NULL; - } - nesupd->pd_id = resp.pd_id; - nesupd->db_index = resp.db_index; - - nesupd->udoorbell = mmap(NULL, page_size, PROT_WRITE | PROT_READ, MAP_SHARED, - context->cmd_fd, nesupd->db_index * page_size); - - if (nesupd->udoorbell == MAP_FAILED) { - free(nesupd); - return NULL; - } - - return &nesupd->ibv_pd; -} - - -/** - * nes_ufree_pd - */ -int nes_ufree_pd(struct ibv_pd *pd) -{ - int ret; - struct nes_upd *nesupd; - - nesupd = to_nes_upd(pd); - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - munmap((void *)nesupd->udoorbell, page_size); - free(nesupd); - - return 0; -} - - -/** - * nes_ureg_mr - */ -struct ibv_mr *nes_ureg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access) -{ - struct ibv_mr *mr; - struct nes_ureg_mr cmd; - struct ibv_reg_mr_resp resp; - - mr = malloc(sizeof *mr); - if (!mr) - return NULL; - - cmd.reg_type = NES_UMEMREG_TYPE_MEM; - if (ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, - access, mr, &cmd.ibv_cmd, sizeof cmd, - &resp, sizeof resp)) { - free(mr); - - return NULL; - } - - return mr; -} - - -/** - * nes_udereg_mr - */ -int nes_udereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - free(mr); - return 0; -} - -/** - * nes_ucreate_cq - */ -struct ibv_cq *nes_ucreate_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, int comp_vector) -{ - struct nes_ucq *nesucq; - struct nes_ureg_mr reg_mr_cmd; - struct ibv_reg_mr_resp reg_mr_resp; - struct nes_ucreate_cq cmd; - struct nes_ucreate_cq_resp resp; - int ret; - struct nes_uvcontext *nesvctx = to_nes_uctx(context); - - nesucq = malloc(sizeof *nesucq); - if (!nesucq) { - return NULL; - } - memset(nesucq, 0, sizeof(*nesucq)); - - if (pthread_spin_init(&nesucq->lock, PTHREAD_PROCESS_PRIVATE)) { - free(nesucq); - return NULL; - } - - if (cqe < 4) /* a reasonable minimum */ - cqe = 4; - nesucq->size = cqe + 1; - nesucq->comp_vector = comp_vector; - - nesucq->cqes = memalign(page_size, nesucq->size*sizeof(struct nes_hw_cqe)); - if (!nesucq->cqes) - goto err; - - /* Register the memory for the CQ */ - reg_mr_cmd.reg_type = NES_UMEMREG_TYPE_CQ; - - ret = ibv_cmd_reg_mr(&nesvctx->nesupd->ibv_pd, (void *)nesucq->cqes, - (nesucq->size*sizeof(struct nes_hw_cqe)), - (uintptr_t)nesucq->cqes, IBV_ACCESS_LOCAL_WRITE, &nesucq->mr, - ®_mr_cmd.ibv_cmd, sizeof reg_mr_cmd, - ®_mr_resp, sizeof reg_mr_resp); - if (ret) { - /* fprintf(stderr, "ibv_cmd_reg_mr failed (ret = %d).\n", ret); */ - free((struct nes_hw_cqe *)nesucq->cqes); - goto err; - } - - /* Create the CQ */ - memset(&cmd, 0, sizeof(cmd)); - cmd.user_cq_buffer = (__u64)((uintptr_t)nesucq->cqes); - cmd.mcrqf = nesvctx->mcrqf; - - ret = ibv_cmd_create_cq(context, nesucq->size-1, channel, comp_vector, - &nesucq->ibv_cq, &cmd.ibv_cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) - goto err; - - nesucq->cq_id = (uint16_t)resp.cq_id; - - /* Zero out the CQ */ - memset((struct nes_hw_cqe *)nesucq->cqes, 0, nesucq->size*sizeof(struct nes_hw_cqe)); - - return &nesucq->ibv_cq; - -err: - /* fprintf(stderr, PFX "%s: Error Creating CQ.\n", __FUNCTION__); */ - pthread_spin_destroy(&nesucq->lock); - free(nesucq); - - return NULL; -} - - -/** - * nes_uresize_cq - */ -int nes_uresize_cq(struct ibv_cq *cq, int cqe) -{ - /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ - return -ENOSYS; -} - -/** - * nes_udestroy_cq - */ -int nes_udestroy_cq(struct ibv_cq *cq) -{ - struct nes_ucq *nesucq = to_nes_ucq(cq); - int ret; - - ret = ibv_cmd_destroy_cq(cq); - if (ret) - return ret; - - ret = ibv_cmd_dereg_mr(&nesucq->mr); - if (ret) - fprintf(stderr, PFX "%s: Failed to deregister CQ Memory Region.\n", __FUNCTION__); - - /* Free CQ the memory */ - free((struct nes_hw_cqe *)nesucq->cqes); - pthread_spin_destroy(&nesucq->lock); - free(nesucq); - - return 0; -} - -#define NES_CQ_BUF_OV_ERR 0x3 - -static inline -int nes_ima_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) -{ - struct nes_ucq *nesucq = to_nes_ucq(cq); - struct nes_uvcontext *nesvctx = to_nes_uctx(cq->context); - uint32_t cqe_misc; - int cqe_count = 0; - uint32_t head; - uint32_t cq_size; - - volatile struct nes_hw_nic_cqe *cqe = NULL; - volatile struct nes_hw_nic_cqe *cqes; - - struct nes_uqp *nesuqp = nesucq->udqp; - uint32_t vlan_tag = 0; - - cqes = (volatile struct nes_hw_nic_cqe *)nesucq->cqes; - head = nesucq->head; - cq_size = nesucq->size; - - if (!nesuqp || !nesvctx) - exit(0); - if (nesuqp->ibv_qp.state == IBV_QPS_ERR) { - while (cqe_count < num_entries) { - memset(entry, 0, sizeof *entry); - - if (nesuqp->recv_cq == nesucq) { - if (nesuqp->rq_tail != nesuqp->rq_head) { - /* Working on a RQ Completion*/ - entry->wr_id = - nesuqp->recv_wr_id[nesuqp->rq_tail]; - if (++nesuqp->rq_tail >= nesuqp->rq_size) - nesuqp->rq_tail = 0; - } else - return cqe_count; - } else - if (nesuqp->send_cq == nesucq) { - if (nesuqp->sq_tail != nesuqp->sq_head) { - entry->wr_id = - nesuqp->send_wr_id[nesuqp->sq_tail]; - /* Working on a SQ Completion*/ - if (++nesuqp->sq_tail >= nesuqp->sq_size) - nesuqp->sq_tail = 0; - } else - return cqe_count; - } - entry->status = IBV_WC_WR_FLUSH_ERR; - entry++; - cqe_count++; - } - return cqe_count; - } - - while (cqe_count < num_entries) { - const enum ibv_wc_opcode INVAL_OP = -1; - - entry->opcode = INVAL_OP; - cqe = &cqes[head]; - cqe_misc = - le32toh(cqe->cqe_words[NES_NIC_CQE_MISC_IDX]); - if (cqe_misc & NES_NIC_CQE_VALID) { - memset(entry, 0, sizeof *entry); - entry->opcode = INVAL_OP; - cqe->cqe_words[NES_NIC_CQE_MISC_IDX] = 0; - entry->status = (cqe_misc & NES_NIC_CQE_ERRV_MASK) >> - NES_NIC_CQE_ERRV_SHIFT; - entry->qp_num = nesuqp->qp_id; - entry->src_qp = nesuqp->qp_id; - if (cqe_misc & NES_NIC_CQE_SQ) { - entry->opcode = IBV_WC_SEND; - - entry->wr_id = - nesuqp->send_wr_id[nesuqp->sq_tail]; - - /* Working on a SQ Completion*/ - if (++nesuqp->sq_tail >= nesuqp->sq_size) - nesuqp->sq_tail = 0; - } else { - /* no CRC counting at all - all packets - go to higher layer as they are received - - the fastest path */ - - entry->byte_len = cqe_misc & 0xffff; - entry->opcode = IBV_WC_RECV; - - entry->wr_id = - nesuqp->recv_wr_id[nesuqp->rq_tail]; - if (cqe_misc & NES_NIC_CQE_TAG_VALID) { - vlan_tag = le32toh( - cqe->cqe_words[NES_NIC_CQE_TAG_PKT_TYPE_IDX]) - >> 16; - entry->sl = (vlan_tag >> 12) & 0x0f; - entry->pkey_index = vlan_tag & 0x0fff; - entry->wc_flags |= NES_WC_WITH_VLAN; - } - - - /* Working on a RQ Completion*/ - if (++nesuqp->rq_tail >= nesuqp->rq_size) - nesuqp->rq_tail = 0; - if (entry->status == NES_CQ_BUF_OV_ERR) - entry->status = IBV_WC_LOC_LEN_ERR; - } - - if (++head >= cq_size) - head = 0; - - if (entry->opcode != INVAL_OP) { - /* it is possible that no entry will be - available */ - cqe_count++; - entry++; - } - - nesvctx->nesupd->udoorbell->cqe_alloc = - htole32(nesucq->cq_id | (1 << 16)); - } else { - break; - } - } - nesucq->head = head; - return cqe_count; -} - -/** - * nes_upoll_cq - */ -int nes_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) -{ - uint64_t wrid; - struct nes_ucq *nesucq; - struct nes_uvcontext *nesvctx = NULL; - struct nes_uqp *nesuqp; - int cqe_count=0; - uint32_t head; - uint32_t cq_size; - uint32_t wqe_index; - uint32_t wq_tail = 0; - struct nes_hw_cqe cqe; - uint64_t u64temp; - int move_cq_head = 1; - uint32_t err_code; - - nesucq = to_nes_ucq(cq); - nesvctx = to_nes_uctx(cq->context); - - if (nesucq->cq_id < 64) - return nes_ima_upoll_cq(cq, num_entries, entry); - - pthread_spin_lock(&nesucq->lock); - - head = nesucq->head; - cq_size = nesucq->size; - - while (cqe_countcqes[head].cqe_words[NES_CQE_OPCODE_IDX]) & NES_CQE_VALID) == 0) - break; - - /* Make sure we read CQ entry contents *after* we've checked the valid bit. */ - udma_from_device_barrier(); - - cqe = (volatile struct nes_hw_cqe)nesucq->cqes[head]; - - /* parse CQE, get completion context from WQE (either rq or sq */ - wqe_index = le32toh(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]) & 511; - u64temp = ((uint64_t) (le32toh(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]))) | - (((uint64_t) (le32toh(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_HIGH_IDX])))<<32); - - if (likely(u64temp)) { - nesuqp = (struct nes_uqp *)(uintptr_t)(u64temp & (~1023)); - memset(entry, 0, sizeof *entry); - if (likely(le32toh(cqe.cqe_words[NES_CQE_ERROR_CODE_IDX]) == 0)) { - entry->status = IBV_WC_SUCCESS; - } else { - err_code = le32toh(cqe.cqe_words[NES_CQE_ERROR_CODE_IDX]); - if (NES_IWARP_CQE_MAJOR_DRV == (err_code >> 16)) { - entry->status = err_code & 0x0000ffff; - } else { - entry->status = IBV_WC_WR_FLUSH_ERR; - if (le32toh(cqe.cqe_words[NES_CQE_OPCODE_IDX]) & NES_CQE_SQ) { - if (wqe_index == 0 && nesuqp->rdma0_msg) { - nesuqp->sq_tail = (wqe_index+1)&(nesuqp->sq_size - 1); - move_cq_head = 0; - wq_tail = nesuqp->sq_tail; - nesuqp->rdma0_msg = 0; - goto nes_upoll_cq_update; - } - } - } - } - entry->qp_num = nesuqp->qp_id; - entry->src_qp = nesuqp->qp_id; - nesuqp->rdma0_msg = 0; - - if (le32toh(cqe.cqe_words[NES_CQE_OPCODE_IDX]) & NES_CQE_SQ) { - /* Working on a SQ Completion*/ - wrid = ((uint64_t) le32toh(nesuqp->sq_vbase[wqe_index].wqe_words[NES_IWARP_SQ_WQE_COMP_SCRATCH_LOW_IDX])) | - (((uint64_t) le32toh(nesuqp->sq_vbase[wqe_index].wqe_words[NES_IWARP_SQ_WQE_COMP_SCRATCH_HIGH_IDX]))<<32); - entry->byte_len = le32toh(nesuqp->sq_vbase[wqe_index].wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX]); - - switch (le32toh(nesuqp->sq_vbase[wqe_index]. - wqe_words[NES_IWARP_SQ_WQE_MISC_IDX]) & 0x3f) { - case NES_IWARP_SQ_OP_RDMAW: - /* fprintf(stderr, PFX "%s: Operation = RDMA WRITE.\n", - __FUNCTION__ ); */ - entry->opcode = IBV_WC_RDMA_WRITE; - break; - case NES_IWARP_SQ_OP_RDMAR: - /* fprintf(stderr, PFX "%s: Operation = RDMA READ.\n", - __FUNCTION__ ); */ - entry->opcode = IBV_WC_RDMA_READ; - entry->byte_len = le32toh(nesuqp->sq_vbase[wqe_index]. - wqe_words[NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX]); - break; - case NES_IWARP_SQ_OP_SENDINV: - case NES_IWARP_SQ_OP_SENDSEINV: - case NES_IWARP_SQ_OP_SEND: - case NES_IWARP_SQ_OP_SENDSE: - /* fprintf(stderr, PFX "%s: Operation = Send.\n", - __FUNCTION__ ); */ - entry->opcode = IBV_WC_SEND; - break; - } - - nesuqp->sq_tail = (wqe_index+1)&(nesuqp->sq_size - 1); - if ((entry->status != IBV_WC_SUCCESS) && (nesuqp->sq_tail != nesuqp->sq_head)) { - move_cq_head = 0; - wq_tail = nesuqp->sq_tail; - } - } else { - /* Working on a RQ Completion*/ - entry->byte_len = le32toh(cqe.cqe_words[NES_CQE_PAYLOAD_LENGTH_IDX]); - wrid = ((uint64_t) le32toh(nesuqp->rq_vbase[wqe_index].wqe_words[NES_IWARP_RQ_WQE_COMP_SCRATCH_LOW_IDX])) | - (((uint64_t) le32toh(nesuqp->rq_vbase[wqe_index].wqe_words[NES_IWARP_RQ_WQE_COMP_SCRATCH_HIGH_IDX]))<<32); - entry->opcode = IBV_WC_RECV; - - nesuqp->rq_tail = (wqe_index+1)&(nesuqp->rq_size - 1); - if ((entry->status != IBV_WC_SUCCESS) && (nesuqp->rq_tail != nesuqp->rq_head)) { - move_cq_head = 0; - wq_tail = nesuqp->rq_tail; - } - } - - entry->wr_id = wrid; - entry++; - cqe_count++; - } -nes_upoll_cq_update: - if (move_cq_head) { - nesucq->cqes[head].cqe_words[NES_CQE_OPCODE_IDX] = 0; - if (++head >= cq_size) - head = 0; - nesucq->polled_completions++; - - if ((nesucq->polled_completions > (cq_size/2)) || - (nesucq->polled_completions == 255)) { - if (nesvctx == NULL) - nesvctx = to_nes_uctx(cq->context); - nesvctx->nesupd->udoorbell->cqe_alloc = htole32(nesucq->cq_id | - (nesucq->polled_completions << 16)); - nesucq->polled_completions = 0; - } - } else { - /* Update the wqe index and set status to flush */ - wqe_index = le32toh(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]); - wqe_index = (wqe_index & (~511)) | wq_tail; - nesucq->cqes[head].cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX] = - htole32(wqe_index); - nesucq->cqes[head].cqe_words[NES_CQE_ERROR_CODE_IDX] = - htole32((NES_IWARP_CQE_MAJOR_FLUSH << 16) | NES_IWARP_CQE_MINOR_FLUSH); - move_cq_head = 1; /* ready for next pass */ - } - } - - if (nesucq->polled_completions) { - if (nesvctx == NULL) - nesvctx = to_nes_uctx(cq->context); - nesvctx->nesupd->udoorbell->cqe_alloc = htole32(nesucq->cq_id | - (nesucq->polled_completions << 16)); - nesucq->polled_completions = 0; - } - nesucq->head = head; - - pthread_spin_unlock(&nesucq->lock); - - return cqe_count; -} - - -/** - * nes_upoll_cq_no_db_read - */ -int nes_upoll_cq_no_db_read(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) -{ - uint64_t wrid; - struct nes_ucq *nesucq; - struct nes_uvcontext *nesvctx = NULL; - struct nes_uqp *nesuqp; - int cqe_count=0; - uint32_t head; - uint32_t cq_size; - uint32_t wqe_index; - uint32_t wq_tail = 0; - struct nes_hw_cqe cqe; - uint64_t u64temp; - int move_cq_head = 1; - uint32_t err_code; - - nesucq = to_nes_ucq(cq); - nesvctx = to_nes_uctx(cq->context); - - if (nesucq->cq_id < 64) - return nes_ima_upoll_cq(cq, num_entries, entry); - - pthread_spin_lock(&nesucq->lock); - - head = nesucq->head; - cq_size = nesucq->size; - - while (cqe_countcqes[head].cqe_words[NES_CQE_OPCODE_IDX]) & NES_CQE_VALID) == 0) - break; - - /* Make sure we read CQ entry contents *after* we've checked the valid bit. */ - udma_from_device_barrier(); - - cqe = (volatile struct nes_hw_cqe)nesucq->cqes[head]; - - /* parse CQE, get completion context from WQE (either rq or sq */ - wqe_index = le32toh(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]) & 511; - u64temp = ((uint64_t) (le32toh(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]))) | - (((uint64_t) (le32toh(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_HIGH_IDX])))<<32); - - if (likely(u64temp)) { - nesuqp = (struct nes_uqp *)(uintptr_t)(u64temp & (~1023)); - memset(entry, 0, sizeof *entry); - if (likely(le32toh(cqe.cqe_words[NES_CQE_ERROR_CODE_IDX]) == 0)) { - entry->status = IBV_WC_SUCCESS; - } else { - err_code = le32toh(cqe.cqe_words[NES_CQE_ERROR_CODE_IDX]); - if (NES_IWARP_CQE_MAJOR_DRV == (err_code >> 16)) - entry->status = err_code & 0x0000ffff; - else - entry->status = IBV_WC_WR_FLUSH_ERR; - } - entry->qp_num = nesuqp->qp_id; - entry->src_qp = nesuqp->qp_id; - - if (le32toh(cqe.cqe_words[NES_CQE_OPCODE_IDX]) & NES_CQE_SQ) { - /* Working on a SQ Completion*/ - wrid = ((uint64_t) le32toh(nesuqp->sq_vbase[wqe_index].wqe_words[NES_IWARP_SQ_WQE_COMP_SCRATCH_LOW_IDX])) | - (((uint64_t) le32toh(nesuqp->sq_vbase[wqe_index].wqe_words[NES_IWARP_SQ_WQE_COMP_SCRATCH_HIGH_IDX]))<<32); - entry->byte_len = le32toh(nesuqp->sq_vbase[wqe_index].wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX]); - - switch (le32toh(nesuqp->sq_vbase[wqe_index]. - wqe_words[NES_IWARP_SQ_WQE_MISC_IDX]) & 0x3f) { - case NES_IWARP_SQ_OP_RDMAW: - /* fprintf(stderr, PFX "%s: Operation = RDMA WRITE.\n", - __FUNCTION__ ); */ - entry->opcode = IBV_WC_RDMA_WRITE; - break; - case NES_IWARP_SQ_OP_RDMAR: - /* fprintf(stderr, PFX "%s: Operation = RDMA READ.\n", - __FUNCTION__ ); */ - entry->opcode = IBV_WC_RDMA_READ; - entry->byte_len = le32toh(nesuqp->sq_vbase[wqe_index]. - wqe_words[NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX]); - break; - case NES_IWARP_SQ_OP_SENDINV: - case NES_IWARP_SQ_OP_SENDSEINV: - case NES_IWARP_SQ_OP_SEND: - case NES_IWARP_SQ_OP_SENDSE: - /* fprintf(stderr, PFX "%s: Operation = Send.\n", - __FUNCTION__ ); */ - entry->opcode = IBV_WC_SEND; - break; - } - - nesuqp->sq_tail = (wqe_index+1)&(nesuqp->sq_size - 1); - if ((entry->status != IBV_WC_SUCCESS) && (nesuqp->sq_tail != nesuqp->sq_head)) { - move_cq_head = 0; - wq_tail = nesuqp->sq_tail; - } - } else { - /* Working on a RQ Completion*/ - entry->byte_len = le32toh(cqe.cqe_words[NES_CQE_PAYLOAD_LENGTH_IDX]); - wrid = ((uint64_t) le32toh(nesuqp->rq_vbase[wqe_index].wqe_words[NES_IWARP_RQ_WQE_COMP_SCRATCH_LOW_IDX])) | - (((uint64_t) le32toh(nesuqp->rq_vbase[wqe_index].wqe_words[NES_IWARP_RQ_WQE_COMP_SCRATCH_HIGH_IDX]))<<32); - entry->opcode = IBV_WC_RECV; - - nesuqp->rq_tail = (wqe_index+1)&(nesuqp->rq_size - 1); - if ((entry->status != IBV_WC_SUCCESS) && (nesuqp->rq_tail != nesuqp->rq_head)) { - move_cq_head = 0; - wq_tail = nesuqp->rq_tail; - } - } - - entry->wr_id = wrid; - entry++; - cqe_count++; - } - - if (move_cq_head) { - nesucq->cqes[head].cqe_words[NES_CQE_OPCODE_IDX] = 0; - if (++head >= cq_size) - head = 0; - nesucq->polled_completions++; - - if ((nesucq->polled_completions > (cq_size/2)) || - (nesucq->polled_completions == 255)) { - if (nesvctx == NULL) - nesvctx = to_nes_uctx(cq->context); - nesvctx->nesupd->udoorbell->cqe_alloc = htole32(nesucq->cq_id | - (nesucq->polled_completions << 16)); - nesucq->polled_completions = 0; - } - } else { - /* Update the wqe index and set status to flush */ - wqe_index = le32toh(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]); - wqe_index = (wqe_index & (~511)) | wq_tail; - nesucq->cqes[head].cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX] = - htole32(wqe_index); - nesucq->cqes[head].cqe_words[NES_CQE_ERROR_CODE_IDX] = - htole32((NES_IWARP_CQE_MAJOR_FLUSH << 16) | NES_IWARP_CQE_MINOR_FLUSH); - move_cq_head = 1; /* ready for next pass */ - } - } - - if (nesucq->polled_completions) { - if (nesvctx == NULL) - nesvctx = to_nes_uctx(cq->context); - nesvctx->nesupd->udoorbell->cqe_alloc = htole32(nesucq->cq_id | - (nesucq->polled_completions << 16)); - nesucq->polled_completions = 0; - } - nesucq->head = head; - - pthread_spin_unlock(&nesucq->lock); - - return cqe_count; -} - -/** - * nes_arm_cq - */ -static void nes_arm_cq(struct nes_ucq *nesucq, struct nes_uvcontext *nesvctx, int sol) -{ - uint32_t cq_arm; - - cq_arm = nesucq->cq_id; - - if (sol) - cq_arm |= NES_CQE_ALLOC_NOTIFY_SE; - else - cq_arm |= NES_CQE_ALLOC_NOTIFY_NEXT; - - nesvctx->nesupd->udoorbell->cqe_alloc = htole32(cq_arm); - nesucq->is_armed = 1; - nesucq->arm_sol = sol; - nesucq->skip_arm = 0; - nesucq->skip_sol = 1; -} - -/** - * nes_uarm_cq - */ -int nes_uarm_cq(struct ibv_cq *cq, int solicited) -{ - struct nes_ucq *nesucq; - struct nes_uvcontext *nesvctx; - - nesucq = to_nes_ucq(cq); - nesvctx = to_nes_uctx(cq->context); - - pthread_spin_lock(&nesucq->lock); - - if (nesucq->is_armed) { - /* don't arm again unless... */ - if ((nesucq->arm_sol) && (!solicited)) { - /* solicited changed from notify SE to notify next */ - nes_arm_cq(nesucq, nesvctx, solicited); - } else { - nesucq->skip_arm = 1; - nesucq->skip_sol &= solicited; - } - } else { - nes_arm_cq(nesucq, nesvctx, solicited); - } - - pthread_spin_unlock(&nesucq->lock); - - return 0; -} - - -/** - * nes_cq_event - */ -void nes_cq_event(struct ibv_cq *cq) -{ - struct nes_ucq *nesucq; - - nesucq = to_nes_ucq(cq); - - pthread_spin_lock(&nesucq->lock); - - if (nesucq->skip_arm) { - struct nes_uvcontext *nesvctx; - nesvctx = to_nes_uctx(cq->context); - nes_arm_cq(nesucq, nesvctx, nesucq->skip_sol); - } else { - nesucq->is_armed = 0; - } - - pthread_spin_unlock(&nesucq->lock); -} - - -/** - * nes_ucreate_srq - */ -struct ibv_srq *nes_ucreate_srq(struct ibv_pd *pd, struct ibv_srq_init_attr *attr) -{ - /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ - return (void *)-ENOSYS; -} - - -/** - * nes_umodify_srq - */ -int nes_umodify_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr, int attr_mask) -{ - /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ - return -ENOSYS; -} - - -/** - * nes_udestroy_srq - */ -int nes_udestroy_srq(struct ibv_srq *srq) -{ - /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ - return -ENOSYS; -} - - -/** - * nes_upost_srq_recv - */ -int nes_upost_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ - return -ENOSYS; -} - - -/** - * nes_mmapped_qp - * will not invoke registration of memory reqion and will allow - * the kernel module to allocate big chunk of contigous memory - * for sq and rq... returns 1 if succeeds, 0 if fails.. - */ -static int nes_mmapped_qp(struct nes_uqp *nesuqp, struct ibv_pd *pd, struct ibv_qp_init_attr *attr, - struct nes_ucreate_qp_resp *resp) -{ - - unsigned long mmap_offset; - struct nes_ucreate_qp cmd; - struct nes_uvcontext *nesvctx = to_nes_uctx(pd->context); - int ret; - - memset (&cmd, 0, sizeof(cmd) ); - cmd.user_qp_buffer = (__u64) ((uintptr_t) nesuqp); - - /* fprintf(stderr, PFX "%s entering==>\n",__FUNCTION__); */ - ret = ibv_cmd_create_qp(pd, &nesuqp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd, - &resp->ibv_resp, sizeof (struct nes_ucreate_qp_resp) ); - if (ret) - return 0; - nesuqp->send_cq = to_nes_ucq(attr->send_cq); - nesuqp->recv_cq = to_nes_ucq(attr->recv_cq); - nesuqp->sq_db_index = resp->mmap_sq_db_index; - nesuqp->rq_db_index = resp->mmap_rq_db_index; - nesuqp->sq_size = resp->actual_sq_size; - nesuqp->rq_size = resp->actual_rq_size; - - /* Map the SQ/RQ buffers */ - mmap_offset = nesvctx->max_pds*page_size; - mmap_offset += (((sizeof(struct nes_hw_qp_wqe) * nesvctx->wq_size) + page_size-1) & - (~(page_size-1)))*nesuqp->sq_db_index; - - nesuqp->sq_vbase = mmap(NULL, (nesuqp->sq_size+nesuqp->rq_size) * - sizeof(struct nes_hw_qp_wqe), PROT_WRITE | PROT_READ, - MAP_SHARED, pd->context->cmd_fd, mmap_offset); - - - if (nesuqp->sq_vbase == MAP_FAILED) { - return 0; - } - nesuqp->rq_vbase = (struct nes_hw_qp_wqe *)(((char *)nesuqp->sq_vbase) + - (nesuqp->sq_size*sizeof(struct nes_hw_qp_wqe))); - *((unsigned int *)nesuqp->sq_vbase) = 0; - nesuqp->mapping = NES_QP_MMAP; - - return 1; -} - - -/** - * nes_vmapped_qp - * invoke registration of memory reqion. This method is used - * when kernel can not allocate qp memory (contigous physical). - * - * returns 1 if succeeds, 0 if fails.. - */ -static int nes_vmapped_qp(struct nes_uqp *nesuqp, struct ibv_pd *pd, struct ibv_qp_init_attr *attr, - struct nes_ucreate_qp_resp *resp, int sqdepth, int rqdepth) -{ - struct nes_ucreate_qp cmd; - struct nes_ureg_mr reg_mr_cmd; - struct ibv_reg_mr_resp reg_mr_resp; - int totalqpsize; - int ret; - - // fprintf(stderr, PFX "%s\n", __FUNCTION__); - totalqpsize = (sqdepth + rqdepth) * sizeof (struct nes_hw_qp_wqe) ; - nesuqp->sq_vbase = memalign(page_size, totalqpsize); - if (!nesuqp->sq_vbase) { - // fprintf(stderr, PFX "CREATE_QP could not allocate mem of size %d\n", totalqpsize); - return 0; - } - nesuqp->rq_vbase = (struct nes_hw_qp_wqe *) (((char *) nesuqp->sq_vbase) + - (nesuqp->sq_size * sizeof(struct nes_hw_qp_wqe))); - - reg_mr_cmd.reg_type = NES_UMEMREG_TYPE_QP; - - //fprintf(stderr, PFX "qp_rq_vbase = %p qp_sq_vbase=%p reg_mr = %p\n", - // nesuqp->rq_vbase, nesuqp->sq_vbase, &nesuqp->mr); - - ret = ibv_cmd_reg_mr(pd, (void *)nesuqp->sq_vbase,totalqpsize, - (uintptr_t) nesuqp->sq_vbase, IBV_ACCESS_LOCAL_WRITE, - &nesuqp->mr, ®_mr_cmd.ibv_cmd, sizeof reg_mr_cmd, - ®_mr_resp, sizeof reg_mr_resp); - if (ret) { - // fprintf(stderr, PFX "%s ibv_cmd_reg_mr failed (ret = %d).\n", __FUNCTION__, ret); - free((void *) nesuqp->sq_vbase); - return 0; - } - // So now the memory has been registered.. - memset (&cmd, 0, sizeof(cmd) ); - cmd.user_sq_buffer = (__u64) ((uintptr_t) nesuqp->sq_vbase); - cmd.user_qp_buffer = (__u64) ((uintptr_t) nesuqp); - ret = ibv_cmd_create_qp(pd, &nesuqp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd, - &resp->ibv_resp, sizeof (struct nes_ucreate_qp_resp) ); - if (ret) { - ibv_cmd_dereg_mr(&nesuqp->mr); - free((void *)nesuqp->sq_vbase); - return 0; - } - *((unsigned int *)nesuqp->rq_vbase) = 0; - nesuqp->send_cq = to_nes_ucq(attr->send_cq); - nesuqp->recv_cq = to_nes_ucq(attr->recv_cq); - nesuqp->sq_db_index = resp->mmap_sq_db_index; - nesuqp->rq_db_index = resp->mmap_rq_db_index; - nesuqp->sq_size = resp->actual_sq_size; - nesuqp->rq_size = resp->actual_rq_size; - nesuqp->mapping = NES_QP_VMAP; - return 1; -} - - -/** - * nes_qp_get_qdepth - * This routine will return the size of qdepth to be set for one - * of the qp (sq or rq) - */ -static int nes_qp_get_qdepth(uint32_t qdepth, uint32_t maxsges) -{ - int retdepth; - - /* Do sanity check on the parameters */ - /* Should the following be 510 or 511 */ - if ((qdepth > 510) || (maxsges > 4) ) - return 0; - - /* Do we need to do the following of */ - /* we can just return the actual value.. needed for alignment */ - if (qdepth < 32) - retdepth = 32; - else if (qdepth < 128) - retdepth = 128; - else retdepth = 512; - - return retdepth; -} - - -/** - * nes_ucreate_qp - */ -struct ibv_qp *nes_ucreate_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) -{ - struct nes_ucreate_qp_resp resp; - struct nes_uvcontext *nesvctx = to_nes_uctx(pd->context); - struct nes_uqp *nesuqp; - int sqdepth, rqdepth; - int status = 1; - - /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ - - /* Sanity check QP size before proceeding */ - sqdepth = nes_qp_get_qdepth(attr->cap.max_send_wr, attr->cap.max_send_sge); - if (!sqdepth) { - fprintf(stderr, PFX "%s Bad sq attr parameters max_send_wr=%d max_send_sge=%d\n", - __FUNCTION__, attr->cap.max_send_wr,attr->cap.max_send_sge); - return NULL; - } - - rqdepth = nes_qp_get_qdepth(attr->cap.max_recv_wr, attr->cap.max_recv_sge); - if (!rqdepth) { - fprintf(stderr, PFX "%s Bad rq attr parameters max_recv_wr=%d max_recv_sge=%d\n", - __FUNCTION__, attr->cap.max_recv_wr,attr->cap.max_recv_sge); - return NULL; - } - - nesuqp = memalign(1024, sizeof(*nesuqp)); - if (!nesuqp) - return NULL; - memset(nesuqp, 0, sizeof(*nesuqp)); - - if (pthread_spin_init(&nesuqp->lock, PTHREAD_PROCESS_PRIVATE)) { - free(nesuqp); - return NULL; - } - - /* Initially setting it up so we will know how much memory to allocate for mapping */ - /* also setting it up in attr.. If we do not want to modify the attr struct, we */ - /* can save the original values and restore them before return. */ - nesuqp->sq_size = attr->cap.max_send_wr = sqdepth; - nesuqp->rq_size = attr->cap.max_recv_wr = rqdepth; - - nesuqp->sq_sig_all = attr->sq_sig_all; - if (nesvctx->virtwq) { - status = nes_vmapped_qp(nesuqp,pd, attr,&resp,sqdepth,rqdepth); - }else { - status = nes_mmapped_qp(nesuqp,pd,attr, &resp); - } - - if (!status) { - pthread_spin_destroy(&nesuqp->lock); - free(nesuqp); - return NULL; - } - - - /* The following are the common parameters no matter how the */ - /* sq and rq memory was mapped.. */ - - /* Account for LSMM, in theory, could get overrun if app preposts to SQ */ - nesuqp->sq_head = 1; - nesuqp->sq_tail = 1; - nesuqp->qp_id = resp.qp_id; - nesuqp->nes_drv_opt = resp.nes_drv_opt; - nesuqp->ibv_qp.qp_num = resp.qp_id; - nesuqp->rdma0_msg = 1; - - return &nesuqp->ibv_qp; -} - - -/** - * nes_uquery_qp - */ -int nes_uquery_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - - /* fprintf(stderr, PFX "nes_uquery_qp: calling ibv_cmd_query_qp\n"); */ - - return ibv_cmd_query_qp(qp, attr, attr_mask, init_attr, &cmd, sizeof(cmd)); -} - - -/** - * nes_umodify_qp - */ -int nes_umodify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - return ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof cmd); -} - - -/** - * nes_clean_cq - */ -static void nes_clean_cq(struct nes_uqp *nesuqp, struct nes_ucq *nesucq) -{ - uint32_t cq_head; - uint32_t lo; - uint32_t hi; - uint64_t u64temp; - - pthread_spin_lock(&nesucq->lock); - - cq_head = nesucq->head; - while (le32toh(nesucq->cqes[cq_head].cqe_words[NES_CQE_OPCODE_IDX]) & NES_CQE_VALID) { - udma_from_device_barrier(); - lo = le32toh(nesucq->cqes[cq_head].cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]); - hi = le32toh(nesucq->cqes[cq_head].cqe_words[NES_CQE_COMP_COMP_CTX_HIGH_IDX]); - u64temp = (((uint64_t)hi) << 32) | ((uint64_t)lo); - u64temp &= (~1023); - if (u64temp == (uint64_t)(uintptr_t)nesuqp) { - /* Zero the context value so cqe will be ignored */ - nesucq->cqes[cq_head].cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX] = 0; - nesucq->cqes[cq_head].cqe_words[NES_CQE_COMP_COMP_CTX_HIGH_IDX] = 0; - } - - if (++cq_head >= nesucq->size) - cq_head = 0; - } - - pthread_spin_unlock(&nesucq->lock); -} - - -/** - * nes_udestroy_qp - */ -int nes_udestroy_qp(struct ibv_qp *qp) -{ - struct nes_uqp *nesuqp = to_nes_uqp(qp); - int ret = 0; - - // fprintf(stderr, PFX "%s addr&mr= %p \n", __FUNCTION__, &nesuqp->mr ); - - if (nesuqp->mapping == NES_QP_VMAP) { - ret = ibv_cmd_dereg_mr(&nesuqp->mr); - if (ret) - fprintf(stderr, PFX "%s dereg_mr FAILED\n", __FUNCTION__); - free((void *)nesuqp->sq_vbase); - } - - if (nesuqp->mapping == NES_QP_MMAP) { - munmap((void *)nesuqp->sq_vbase, (nesuqp->sq_size+nesuqp->rq_size) * - sizeof(struct nes_hw_qp_wqe)); - } - - ret = ibv_cmd_destroy_qp(qp); - if (ret) { - fprintf(stderr, PFX "%s FAILED\n", __FUNCTION__); - return ret; - } - - pthread_spin_destroy(&nesuqp->lock); - - /* Clean any pending completions from the cq(s) */ - if (nesuqp->send_cq) - nes_clean_cq(nesuqp, nesuqp->send_cq); - - if ((nesuqp->recv_cq) && (nesuqp->recv_cq != nesuqp->send_cq)) - nes_clean_cq(nesuqp, nesuqp->recv_cq); - free(nesuqp); - - return 0; -} - -/** - * nes_upost_send - */ -int nes_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, - struct ibv_send_wr **bad_wr) -{ - uint64_t u64temp; - struct nes_uqp *nesuqp = to_nes_uqp(ib_qp); - struct nes_upd *nesupd = to_nes_upd(ib_qp->pd); - struct nes_hw_qp_wqe volatile *wqe; - uint32_t head; - uint32_t qsize = nesuqp->sq_size; - uint32_t counter; - uint32_t err = 0; - uint32_t wqe_count = 0; - uint32_t outstanding_wqes; - uint32_t total_payload_length = 0; - int sge_index; - - pthread_spin_lock(&nesuqp->lock); - udma_to_device_barrier(); - - head = nesuqp->sq_head; - while (ib_wr) { - if (unlikely(nesuqp->qperr)) { - err = -EINVAL; - break; - } - - /* Check for SQ overflow */ - outstanding_wqes = head + (2 * qsize) - nesuqp->sq_tail; - outstanding_wqes &= qsize - 1; - if (unlikely(outstanding_wqes == (qsize - 1))) { - err = -EINVAL; - break; - } - if (unlikely(ib_wr->num_sge > 4)) { - err = -EINVAL; - break; - } - - wqe = (struct nes_hw_qp_wqe *)&nesuqp->sq_vbase[head]; - /* fprintf(stderr, PFX "%s: QP%u: processing sq wqe at %p, head = %u.\n", - __FUNCTION__, nesuqp->qp_id, wqe, head); */ - u64temp = (uint64_t) ib_wr->wr_id; - wqe->wqe_words[NES_IWARP_SQ_WQE_COMP_SCRATCH_LOW_IDX] = htole32((uint32_t)u64temp); - wqe->wqe_words[NES_IWARP_SQ_WQE_COMP_SCRATCH_HIGH_IDX] = htole32((uint32_t)(u64temp>>32)); - u64temp = (uint64_t)((uintptr_t)nesuqp); - wqe->wqe_words[NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX] = htole32((uint32_t)u64temp); - wqe->wqe_words[NES_IWARP_SQ_WQE_COMP_CTX_HIGH_IDX] = htole32((uint32_t)(u64temp>>32)); - udma_ordering_write_barrier(); - wqe->wqe_words[NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX] |= htole32(head); - - switch (ib_wr->opcode) { - case IBV_WR_SEND: - case IBV_WR_SEND_WITH_IMM: - /* fprintf(stderr, PFX "%s: QP%u: processing sq wqe%u. Opcode = %s\n", - __FUNCTION__, nesuqp->qp_id, head, "Send"); */ - if (ib_wr->send_flags & IBV_SEND_SOLICITED) { - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = htole32(NES_IWARP_SQ_OP_SENDSE); - } else { - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = htole32(NES_IWARP_SQ_OP_SEND); - } - - if (ib_wr->send_flags & IBV_SEND_FENCE) { - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] |= htole32(NES_IWARP_SQ_WQE_READ_FENCE); - } - - /* if (ib_wr->send_flags & IBV_SEND_INLINE) { - fprintf(stderr, PFX "%s: Send SEND_INLINE, length=%d\n", - __FUNCTION__, ib_wr->sg_list[0].length); - } */ - if ((ib_wr->send_flags & IBV_SEND_INLINE) && (ib_wr->sg_list[0].length <= 64) && - ((nesuqp->nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) == 0) && - (ib_wr->num_sge == 1)) { - memcpy((void *)&wqe->wqe_words[NES_IWARP_SQ_WQE_IMM_DATA_START_IDX], - (void *)(intptr_t)ib_wr->sg_list[0].addr, ib_wr->sg_list[0].length); - wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = htole32(ib_wr->sg_list[0].length); - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] |= htole32(NES_IWARP_SQ_WQE_IMM_DATA); - } else { - total_payload_length = 0; - for (sge_index=0; sge_index < ib_wr->num_sge; sge_index++) { - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX+(sge_index*4)] = - htole32((uint32_t)ib_wr->sg_list[sge_index].addr); - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX+(sge_index*4)] = - htole32((uint32_t)(ib_wr->sg_list[sge_index].addr>>32)); - wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX+(sge_index*4)] = - htole32(ib_wr->sg_list[sge_index].length); - wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX+(sge_index*4)] = - htole32(ib_wr->sg_list[sge_index].lkey); - total_payload_length += ib_wr->sg_list[sge_index].length; - } - wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = - htole32(total_payload_length); - } - - break; - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - /* fprintf(stderr, PFX "%s:QP%u: processing sq wqe%u. Opcode = %s\n", - __FUNCTION__, nesuqp->qp_id, head, "Write"); */ - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = htole32(NES_IWARP_SQ_OP_RDMAW); - - if (ib_wr->send_flags & IBV_SEND_FENCE) { - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] |= htole32(NES_IWARP_SQ_WQE_READ_FENCE); - } - wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_STAG_IDX] = htole32(ib_wr->wr.rdma.rkey); - wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_TO_LOW_IDX] = htole32( - (uint32_t)ib_wr->wr.rdma.remote_addr); - wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_TO_HIGH_IDX] = htole32( - (uint32_t)(ib_wr->wr.rdma.remote_addr>>32)); - - /* if (ib_wr->send_flags & IBV_SEND_INLINE) { - fprintf(stderr, PFX "%s: Write SEND_INLINE, length=%d\n", - __FUNCTION__, ib_wr->sg_list[0].length); - } */ - if ((ib_wr->send_flags & IBV_SEND_INLINE) && (ib_wr->sg_list[0].length <= 64) && - ((nesuqp->nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) == 0) && - (ib_wr->num_sge == 1)) { - memcpy((void *)&wqe->wqe_words[NES_IWARP_SQ_WQE_IMM_DATA_START_IDX], - (void *)(intptr_t)ib_wr->sg_list[0].addr, ib_wr->sg_list[0].length); - wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = htole32(ib_wr->sg_list[0].length); - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] |= htole32(NES_IWARP_SQ_WQE_IMM_DATA); - } else { - total_payload_length = 0; - for (sge_index=0; sge_index < ib_wr->num_sge; sge_index++) { - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX+(sge_index*4)] = htole32( - (uint32_t)ib_wr->sg_list[sge_index].addr); - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX+(sge_index*4)] = htole32( - (uint32_t)(ib_wr->sg_list[sge_index].addr>>32)); - wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX+(sge_index*4)] = htole32( - ib_wr->sg_list[sge_index].length); - wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX+(sge_index*4)] = htole32( - ib_wr->sg_list[sge_index].lkey); - total_payload_length += ib_wr->sg_list[sge_index].length; - } - wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = htole32(total_payload_length); - } - wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX] = - wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX]; - break; - case IBV_WR_RDMA_READ: - /* fprintf(stderr, PFX "%s:QP%u:processing sq wqe%u. Opcode = %s\n", - __FUNCTION__, nesuqp->qp_id, head, "Read"); */ - /* IWarp only supports 1 sge for RDMA reads */ - if (ib_wr->num_sge > 1) { - err = -EINVAL; - break; - } - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = htole32(NES_IWARP_SQ_OP_RDMAR); - wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_TO_LOW_IDX] = htole32((uint32_t)ib_wr->wr.rdma.remote_addr); - wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_TO_HIGH_IDX] = htole32((uint32_t)(ib_wr->wr.rdma.remote_addr>>32)); - wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_STAG_IDX] = htole32(ib_wr->wr.rdma.rkey); - wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX] = htole32(ib_wr->sg_list->length); - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = htole32((uint32_t)ib_wr->sg_list->addr); - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = htole32((uint32_t)(ib_wr->sg_list->addr>>32)); - wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = htole32(ib_wr->sg_list->lkey); - break; - default: - /* error */ - err = -EINVAL; - break; - } - - if ((ib_wr->send_flags & IBV_SEND_SIGNALED) || nesuqp->sq_sig_all) { - /* fprintf(stderr, PFX "%s:sq wqe%u is signalled\n", __FUNCTION__, head); */ - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] |= htole32(NES_IWARP_SQ_WQE_SIGNALED_COMPL); - } - ib_wr = ib_wr->next; - head++; - wqe_count++; - if (head >= qsize) - head = 0; - } - - nesuqp->sq_head = head; - udma_to_device_barrier(); - while (wqe_count) { - counter = (wqe_count<(uint32_t)255) ? wqe_count : 255; - wqe_count -= counter; - nesupd->udoorbell->wqe_alloc = htole32((counter<<24) | 0x00800000 | nesuqp->qp_id); - } - - if (err) - *bad_wr = ib_wr; - - pthread_spin_unlock(&nesuqp->lock); - - return err; -} - -/** - * nes_upost_recv - */ -int nes_upost_recv(struct ibv_qp *ib_qp, struct ibv_recv_wr *ib_wr, - struct ibv_recv_wr **bad_wr) -{ - uint64_t u64temp; - struct nes_uqp *nesuqp = to_nes_uqp(ib_qp); - struct nes_upd *nesupd = to_nes_upd(ib_qp->pd); - struct nes_hw_qp_wqe *wqe; - uint32_t head; - uint32_t qsize = nesuqp->rq_size; - uint32_t counter; - uint32_t err = 0; - uint32_t wqe_count = 0; - uint32_t outstanding_wqes; - uint32_t total_payload_length; - int sge_index; - - if (unlikely(ib_wr->num_sge > 4)) { - *bad_wr = ib_wr; - return -EINVAL; - } - - pthread_spin_lock(&nesuqp->lock); - udma_to_device_barrier(); - - head = nesuqp->rq_head; - while (ib_wr) { - if (unlikely(nesuqp->qperr)) { - err = -EINVAL; - break; - } - - /* Check for RQ overflow */ - outstanding_wqes = head + (2 * qsize) - nesuqp->rq_tail; - outstanding_wqes &= qsize - 1; - if (unlikely(outstanding_wqes == (qsize - 1))) { - err = -EINVAL; - break; - } - - wqe = (struct nes_hw_qp_wqe *)&nesuqp->rq_vbase[head]; - u64temp = ib_wr->wr_id; - wqe->wqe_words[NES_IWARP_RQ_WQE_COMP_SCRATCH_LOW_IDX] = - htole32((uint32_t)u64temp); - wqe->wqe_words[NES_IWARP_RQ_WQE_COMP_SCRATCH_HIGH_IDX] = - htole32((uint32_t)(u64temp >> 32)); - u64temp = (uint64_t)((uintptr_t)nesuqp); - wqe->wqe_words[NES_IWARP_RQ_WQE_COMP_CTX_LOW_IDX] = - htole32((uint32_t)u64temp); - wqe->wqe_words[NES_IWARP_RQ_WQE_COMP_CTX_HIGH_IDX] = - htole32((uint32_t)(u64temp >> 32)); - udma_ordering_write_barrier(); - wqe->wqe_words[NES_IWARP_RQ_WQE_COMP_CTX_LOW_IDX] |= htole32(head); - - total_payload_length = 0; - for (sge_index=0; sge_index < ib_wr->num_sge; sge_index++) { - wqe->wqe_words[NES_IWARP_RQ_WQE_FRAG0_LOW_IDX+(sge_index*4)] = - htole32((uint32_t)ib_wr->sg_list[sge_index].addr); - wqe->wqe_words[NES_IWARP_RQ_WQE_FRAG0_HIGH_IDX+(sge_index*4)] = - htole32((uint32_t)(ib_wr->sg_list[sge_index].addr>>32)); - wqe->wqe_words[NES_IWARP_RQ_WQE_LENGTH0_IDX+(sge_index*4)] = - htole32(ib_wr->sg_list[sge_index].length); - wqe->wqe_words[NES_IWARP_RQ_WQE_STAG0_IDX+(sge_index*4)] = - htole32(ib_wr->sg_list[sge_index].lkey); - total_payload_length += ib_wr->sg_list[sge_index].length; - } - wqe->wqe_words[NES_IWARP_RQ_WQE_TOTAL_PAYLOAD_IDX] = htole32(total_payload_length); - - ib_wr = ib_wr->next; - head++; - wqe_count++; - if (head >= qsize) - head = 0; - } - - nesuqp->rq_head = head; - udma_to_device_barrier(); - while (wqe_count) { - counter = (wqe_count<(uint32_t)255) ? wqe_count : 255; - wqe_count -= counter; - nesupd->udoorbell->wqe_alloc = htole32((counter << 24) | nesuqp->qp_id); - } - - if (err) - *bad_wr = ib_wr; - - pthread_spin_unlock(&nesuqp->lock); - - return err; -} - - -/** - * nes_ucreate_ah - */ -struct ibv_ah *nes_ucreate_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ - return (void *)-ENOSYS; -} - - -/** - * nes_udestroy_ah - */ -int nes_udestroy_ah(struct ibv_ah *ah) -{ - /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ - return -ENOSYS; -} - - -/** - * nes_uattach_mcast - */ -int nes_uattach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - int ret = 0; - ret = ibv_cmd_attach_mcast(qp, gid, lid); - nes_debug(NES_DBG_UD, "%s ret=%d\n", __func__, ret); - return ret; -} - - -/** - * nes_udetach_mcast - */ -int nes_udetach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) -{ - int ret = 0; - ret = ibv_cmd_detach_mcast(qp, gid, lid); - nes_debug(NES_DBG_UD, "%s ret=%d\n", __func__, ret); - return ret; -} - -/** - * nes_async_event - */ -void nes_async_event(struct ibv_async_event *event) -{ - struct nes_uqp *nesuqp; - - switch (event->event_type) { - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_ACCESS_ERR: - /* Do not let application queue anything else to the qp */ - nesuqp = to_nes_uqp(event->element.qp); - nesuqp->qperr = 1; - break; - - default: - break; - } -} diff --git a/usr/rdma-core/providers/ocrdma/CMakeLists.txt b/usr/rdma-core/providers/ocrdma/CMakeLists.txt deleted file mode 100644 index 08623adb4..000000000 --- a/usr/rdma-core/providers/ocrdma/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -rdma_provider(ocrdma - ocrdma_main.c - ocrdma_verbs.c - ) diff --git a/usr/rdma-core/providers/ocrdma/Changelog b/usr/rdma-core/providers/ocrdma/Changelog deleted file mode 100644 index e69de29bb..000000000 diff --git a/usr/rdma-core/providers/ocrdma/ocrdma_abi.h b/usr/rdma-core/providers/ocrdma/ocrdma_abi.h deleted file mode 100644 index e43e30aa7..000000000 --- a/usr/rdma-core/providers/ocrdma/ocrdma_abi.h +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (C) 2008-2013 Emulex. All rights reserved. - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __OCRDMA_ABI_H__ -#define __OCRDMA_ABI_H__ - -#include -#include - -#define OCRDMA_ABI_VERSION 2 - -#define Bit(_b) (1 << (_b)) - -#define OCRDMA_MAX_QP 2048 - -enum { - OCRDMA_DB_RQ_OFFSET = 0xE0, - OCRDMA_DB_SQ_OFFSET = 0x60, - OCRDMA_DB_SRQ_OFFSET = OCRDMA_DB_RQ_OFFSET, - OCRDMA_DB_CQ_OFFSET = 0x120 -}; - -#define OCRDMA_DB_CQ_RING_ID_MASK 0x3FF /* bits 0 - 9 */ -#define OCRDMA_DB_CQ_RING_ID_EXT_MASK 0x0C00 /* bits 10-11 of qid placing at 12-11 */ -#define OCRDMA_DB_CQ_RING_ID_EXT_MASK_SHIFT 0x1 /* qid #2 msbits placing at 12-11 */ -#define OCRDMA_DB_CQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */ -/* Rearm bit */ -#define OCRDMA_DB_CQ_REARM_SHIFT (29) /* bit 29 */ - -/* solicited bit */ -#define OCRDMA_DB_CQ_SOLICIT_SHIFT (31) /* bit 31 */ - -struct ocrdma_get_context { - struct ibv_get_context cmd; -}; - -struct ocrdma_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - uint32_t dev_id; - uint32_t wqe_size; - uint32_t max_inline_data; - uint32_t dpp_wqe_size; - uint64_t ah_tbl_page; - uint32_t ah_tbl_len; - uint32_t rqe_size; - uint8_t fw_ver[32]; - uint64_t rsvd1; - uint64_t rsvd2; -}; - -struct ocrdma_alloc_pd_req { - struct ibv_alloc_pd cmd; - uint64_t rsvd; -}; - -struct ocrdma_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - uint32_t id; - uint32_t dpp_enabled; - uint32_t dpp_page_addr_hi; - uint32_t dpp_page_addr_lo; - uint64_t rsvd; -}; - -struct ocrdma_create_cq_req { - struct ibv_create_cq ibv_cmd; - uint32_t dpp_cq; - uint32_t rsvd; -}; - -#define MAX_CQ_PAGES 8 -struct ocrdma_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - uint32_t cq_id; - uint32_t size; - uint32_t num_pages; - uint32_t max_hw_cqe; - uint64_t page_addr[MAX_CQ_PAGES]; - uint64_t db_page_addr; - uint32_t db_page_size; - uint32_t phase_change; - uint64_t rsvd1; - uint64_t rsvd2; -}; - -struct ocrdma_reg_mr { - struct ibv_reg_mr ibv_cmd; -}; - -struct ocrdma_reg_mr_resp { - struct ibv_reg_mr_resp ibv_resp; -}; - -struct ocrdma_create_qp_cmd { - struct ibv_create_qp ibv_cmd; - uint8_t enable_dpp_cq; - uint8_t rsvd; - uint16_t dpp_cq_id; - uint32_t rsvd1; /* pad */ -}; - -#define MAX_QP_PAGES 8 -#define MAX_UD_HDR_PAGES 8 - -struct ocrdma_create_qp_uresp { - struct ibv_create_qp_resp ibv_resp; - uint16_t qp_id; - uint16_t sq_dbid; - uint16_t rq_dbid; - uint16_t resv0; /* pad */ - uint32_t sq_page_size; - uint32_t rq_page_size; - uint32_t num_sq_pages; - uint32_t num_rq_pages; - uint64_t sq_page_addr[MAX_QP_PAGES]; - uint64_t rq_page_addr[MAX_QP_PAGES]; - uint64_t db_page_addr; - uint32_t db_page_size; - uint32_t dpp_credit; - uint32_t dpp_offset; - uint32_t num_wqe_allocated; - uint32_t num_rqe_allocated; - uint32_t db_sq_offset; - uint32_t db_rq_offset; - uint32_t db_shift; - uint64_t rsvd[11]; /* 8*8 + 4*4 + 8 */ -}; - -struct ocrdma_create_srq_cmd { - struct ibv_create_srq ibv_cmd; -}; - -struct ocrdma_create_srq_resp { - struct ibv_create_srq_resp ibv_resp; - uint16_t rq_dbid; - uint16_t resv0; - uint32_t resv1; - - uint32_t rq_page_size; - uint32_t num_rq_pages; - - uint64_t rq_page_addr[MAX_QP_PAGES]; - uint64_t db_page_addr; - - uint32_t db_page_size; - uint32_t num_rqe_allocated; - uint32_t db_rq_offset; - uint32_t db_shift; - uint64_t rsvd2; - uint64_t rsvd3; -}; - -enum OCRDMA_CQE_STATUS { - OCRDMA_CQE_SUCCESS = 0, - OCRDMA_CQE_LOC_LEN_ERR = 1, - OCRDMA_CQE_LOC_QP_OP_ERR = 2, - OCRDMA_CQE_LOC_EEC_OP_ERR = 3, - OCRDMA_CQE_LOC_PROT_ERR = 4, - OCRDMA_CQE_WR_FLUSH_ERR = 5, - OCRDMA_CQE_MW_BIND_ERR = 6, - OCRDMA_CQE_BAD_RESP_ERR = 7, - OCRDMA_CQE_LOC_ACCESS_ERR = 8, - OCRDMA_CQE_REM_INV_REQ_ERR = 9, - OCRDMA_CQE_REM_ACCESS_ERR = 0xa, - OCRDMA_CQE_REM_OP_ERR = 0xb, - OCRDMA_CQE_RETRY_EXC_ERR = 0xc, - OCRDMA_CQE_RNR_RETRY_EXC_ERR = 0xd, - OCRDMA_CQE_LOC_RDD_VIOL_ERR = 0xe, - OCRDMA_CQE_REM_INV_RD_REQ_ERR = 0xf, - OCRDMA_CQE_REM_ABORT_ERR = 0x10, - OCRDMA_CQE_INV_EECN_ERR = 0x11, - OCRDMA_CQE_INV_EEC_STATE_ERR = 0x12, - OCRDMA_CQE_FATAL_ERR = 0x13, - OCRDMA_CQE_RESP_TIMEOUT_ERR = 0x14, - OCRDMA_CQE_GENERAL_ERR -}; - -enum { - /* w0 */ - OCRDMA_CQE_WQEIDX_SHIFT = 0, - OCRDMA_CQE_WQEIDX_MASK = 0xFFFF, - - /* w1 */ - OCRDMA_CQE_UD_XFER_LEN_SHIFT = 16, - OCRDMA_CQE_PKEY_SHIFT = 0, - OCRDMA_CQE_PKEY_MASK = 0xFFFF, - - /* w2 */ - OCRDMA_CQE_QPN_SHIFT = 0, - OCRDMA_CQE_QPN_MASK = 0x0000FFFF, - - OCRDMA_CQE_BUFTAG_SHIFT = 16, - OCRDMA_CQE_BUFTAG_MASK = 0xFFFF << OCRDMA_CQE_BUFTAG_SHIFT, - - /* w3 */ - OCRDMA_CQE_UD_STATUS_SHIFT = 24, - OCRDMA_CQE_UD_STATUS_MASK = 0x7 << OCRDMA_CQE_UD_STATUS_SHIFT, - OCRDMA_CQE_STATUS_SHIFT = 16, - OCRDMA_CQE_STATUS_MASK = (0xFF << OCRDMA_CQE_STATUS_SHIFT), - OCRDMA_CQE_VALID = Bit(31), - OCRDMA_CQE_INVALIDATE = Bit(30), - OCRDMA_CQE_QTYPE = Bit(29), - OCRDMA_CQE_IMM = Bit(28), - OCRDMA_CQE_WRITE_IMM = Bit(27), - OCRDMA_CQE_QTYPE_SQ = 0, - OCRDMA_CQE_QTYPE_RQ = 1, - OCRDMA_CQE_SRCQP_MASK = 0xFFFFFF -}; - -struct ocrdma_cqe { - union { - /* w0 to w2 */ - struct { - __le32 wqeidx; - __le32 bytes_xfered; - __le32 qpn; - } wq; - struct { - __le32 lkey_immdt; - __le32 rxlen; - __le32 buftag_qpn; - } rq; - struct { - __le32 lkey_immdt; - __le32 rxlen_pkey; - __le32 buftag_qpn; - } ud; - struct { - __le32 word_0; - __le32 word_1; - __le32 qpn; - } cmn; - }; - __le32 flags_status_srcqpn; /* w3 */ -} __attribute__ ((packed)); - -struct ocrdma_sge { - uint32_t addr_hi; - uint32_t addr_lo; - uint32_t lrkey; - uint32_t len; -} __attribute__ ((packed)); - -enum { - OCRDMA_WQE_OPCODE_SHIFT = 0, - OCRDMA_WQE_OPCODE_MASK = 0x0000001F, - OCRDMA_WQE_FLAGS_SHIFT = 5, - OCRDMA_WQE_TYPE_SHIFT = 16, - OCRDMA_WQE_TYPE_MASK = 0x00030000, - OCRDMA_WQE_SIZE_SHIFT = 18, - OCRDMA_WQE_SIZE_MASK = 0xFF, - OCRDMA_WQE_NXT_WQE_SIZE_SHIFT = 25, - OCRDMA_WQE_LKEY_FLAGS_SHIFT = 0, - OCRDMA_WQE_LKEY_FLAGS_MASK = 0xF -}; - -enum { - OCRDMA_FLAG_SIG = 0x1, - OCRDMA_FLAG_INV = 0x2, - OCRDMA_FLAG_FENCE_L = 0x4, - OCRDMA_FLAG_FENCE_R = 0x8, - OCRDMA_FLAG_SOLICIT = 0x10, - OCRDMA_FLAG_IMM = 0x20, - OCRDMA_FLAG_AH_VLAN_PR = 0x40, - - /* Stag flags */ - OCRDMA_LKEY_FLAG_LOCAL_WR = 0x1, - OCRDMA_LKEY_FLAG_REMOTE_RD = 0x2, - OCRDMA_LKEY_FLAG_REMOTE_WR = 0x4, - OCRDMA_LKEY_FLAG_VATO = 0x8 -}; - -enum { - OCRDMA_TYPE_INLINE = 0x0, - OCRDMA_TYPE_LKEY = 0x1 -}; - -#define OCRDMA_CQE_QTYPE_RQ 1 -#define OCRDMA_CQE_QTYPE_SQ 0 - -enum OCRDMA_WQE_OPCODE { - OCRDMA_WRITE = 0x06, - OCRDMA_READ = 0x0C, - OCRDMA_RESV0 = 0x02, - OCRDMA_SEND = 0x00, - OCRDMA_BIND_MW = 0x08, - OCRDMA_RESV1 = 0x0A, - OCRDMA_LKEY_INV = 0x15, -}; - -#define OCRDMA_WQE_STRIDE 8 -#define OCRDMA_WQE_ALIGN_BYTES 16 -/* header WQE for all the SQ and RQ operations */ -struct ocrdma_hdr_wqe { - uint32_t cw; - union { - uint32_t rsvd_tag; - uint32_t rsvd_stag_flags; - }; - union { - uint32_t immdt; - uint32_t lkey; - }; - uint32_t total_len; -} __attribute__ ((packed)); - -struct ocrdma_hdr_wqe_le { - __le32 cw; - union { - __le32 rsvd_tag; - __le32 rsvd_stag_flags; - }; - union { - __le32 immdt; - __le32 lkey; - }; - __le32 total_len; -} __attribute__ ((packed)); - -struct ocrdma_ewqe_atomic { - uint32_t ra_hi; - uint32_t ra_lo; - uint32_t rkey; - uint32_t rlen; - uint32_t swap_add_hi; - uint32_t swap_add_lo; - uint32_t compare_hi; - uint32_t compare_lo; - struct ocrdma_sge sge; -} __attribute__ ((packed)); - -struct ocrdma_ewqe_ud_hdr { - uint32_t rsvd_dest_qpn; - uint32_t qkey; - uint32_t rsvd_ahid; - uint32_t hdr_type; -} __attribute__ ((packed)); - -#endif /* __OCRDMA_ABI_H__ */ diff --git a/usr/rdma-core/providers/ocrdma/ocrdma_main.c b/usr/rdma-core/providers/ocrdma/ocrdma_main.c deleted file mode 100644 index 92a5b8a5d..000000000 --- a/usr/rdma-core/providers/ocrdma/ocrdma_main.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2008-2013 Emulex. All rights reserved. - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "ocrdma_main.h" -#include "ocrdma_abi.h" -#include - -#include -#include -#include - -#define PCI_VENDOR_ID_EMULEX 0x10DF -#define PCI_DEVICE_ID_EMULEX_GEN1 0xe220 -#define PCI_DEVICE_ID_EMULEX_GEN2 0x720 -#define PCI_DEVICE_ID_EMULEX_GEN2_VF 0x728 - -#define UCNA(v, d) \ - VERBS_PCI_MATCH(PCI_VENDOR_ID_##v, PCI_DEVICE_ID_EMULEX_##d, NULL) -static const struct verbs_match_ent ucna_table[] = { - UCNA(EMULEX, GEN1), - UCNA(EMULEX, GEN2), - UCNA(EMULEX, GEN2_VF), - {} -}; - -static struct ibv_context *ocrdma_alloc_context(struct ibv_device *, int); -static void ocrdma_free_context(struct ibv_context *); - -static struct ibv_context_ops ocrdma_ctx_ops = { - .query_device = ocrdma_query_device, - .query_port = ocrdma_query_port, - .alloc_pd = ocrdma_alloc_pd, - .dealloc_pd = ocrdma_free_pd, - .reg_mr = ocrdma_reg_mr, - .dereg_mr = ocrdma_dereg_mr, - .create_cq = ocrdma_create_cq, - .poll_cq = ocrdma_poll_cq, - .req_notify_cq = ocrdma_arm_cq, - .resize_cq = ocrdma_resize_cq, - .destroy_cq = ocrdma_destroy_cq, - - .create_qp = ocrdma_create_qp, - .query_qp = ocrdma_query_qp, - .modify_qp = ocrdma_modify_qp, - .destroy_qp = ocrdma_destroy_qp, - .post_send = ocrdma_post_send, - .post_recv = ocrdma_post_recv, - .create_ah = ocrdma_create_ah, - .destroy_ah = ocrdma_destroy_ah, - - .create_srq = ocrdma_create_srq, - .modify_srq = ocrdma_modify_srq, - .query_srq = ocrdma_query_srq, - .destroy_srq = ocrdma_destroy_srq, - .post_srq_recv = ocrdma_post_srq_recv, - .attach_mcast = ocrdma_attach_mcast, - .detach_mcast = ocrdma_detach_mcast -}; - -static void ocrdma_uninit_device(struct verbs_device *verbs_device) -{ - struct ocrdma_device *dev = get_ocrdma_dev(&verbs_device->device); - - free(dev); -} - -/* - * ocrdma_alloc_context - */ -static struct ibv_context *ocrdma_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - struct ocrdma_devctx *ctx; - struct ocrdma_get_context cmd; - struct ocrdma_alloc_ucontext_resp resp; - - ctx = calloc(1, sizeof(struct ocrdma_devctx)); - if (!ctx) - return NULL; - memset(&resp, 0, sizeof(resp)); - - ctx->ibv_ctx.cmd_fd = cmd_fd; - - if (ibv_cmd_get_context(&ctx->ibv_ctx, - (struct ibv_get_context *)&cmd, sizeof cmd, - &resp.ibv_resp, sizeof(resp))) - goto cmd_err; - - ctx->ibv_ctx.device = ibdev; - ctx->ibv_ctx.ops = ocrdma_ctx_ops; - get_ocrdma_dev(ibdev)->id = resp.dev_id; - get_ocrdma_dev(ibdev)->max_inline_data = resp.max_inline_data; - get_ocrdma_dev(ibdev)->wqe_size = resp.wqe_size; - get_ocrdma_dev(ibdev)->rqe_size = resp.rqe_size; - memcpy(get_ocrdma_dev(ibdev)->fw_ver, resp.fw_ver, sizeof(resp.fw_ver)); - get_ocrdma_dev(ibdev)->dpp_wqe_size = resp.dpp_wqe_size; - - ctx->ah_tbl = - mmap(NULL, resp.ah_tbl_len, PROT_READ | PROT_WRITE, MAP_SHARED, - cmd_fd, resp.ah_tbl_page); - - if (ctx->ah_tbl == MAP_FAILED) - goto cmd_err; - ctx->ah_tbl_len = resp.ah_tbl_len; - ocrdma_init_ahid_tbl(ctx); - - return &ctx->ibv_ctx; - -cmd_err: - ocrdma_err("%s: Failed to allocate context for device.\n", __func__); - free(ctx); - return NULL; -} - -/* - * ocrdma_free_context - */ -static void ocrdma_free_context(struct ibv_context *ibctx) -{ - struct ocrdma_devctx *ctx = get_ocrdma_ctx(ibctx); - - if (ctx->ah_tbl) - munmap((void *)ctx->ah_tbl, ctx->ah_tbl_len); - - free(ctx); -} - -static struct verbs_device * -ocrdma_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct ocrdma_device *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->qp_tbl = malloc(OCRDMA_MAX_QP * sizeof(struct ocrdma_qp *)); - if (!dev->qp_tbl) - goto qp_err; - bzero(dev->qp_tbl, OCRDMA_MAX_QP * sizeof(struct ocrdma_qp *)); - pthread_mutex_init(&dev->dev_lock, NULL); - pthread_spin_init(&dev->flush_q_lock, PTHREAD_PROCESS_PRIVATE); - return &dev->ibv_dev; -qp_err: - free(dev); - return NULL; -} - -static const struct verbs_device_ops ocrdma_dev_ops = { - .name = "ocrdma", - .match_min_abi_version = OCRDMA_ABI_VERSION, - .match_max_abi_version = OCRDMA_ABI_VERSION, - .match_table = ucna_table, - .alloc_device = ocrdma_device_alloc, - .uninit_device = ocrdma_uninit_device, - .alloc_context = ocrdma_alloc_context, - .free_context = ocrdma_free_context, -}; -PROVIDER_DRIVER(ocrdma_dev_ops); diff --git a/usr/rdma-core/providers/ocrdma/ocrdma_main.h b/usr/rdma-core/providers/ocrdma/ocrdma_main.h deleted file mode 100644 index 05bb12435..000000000 --- a/usr/rdma-core/providers/ocrdma/ocrdma_main.h +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright (C) 2008-2013 Emulex. All rights reserved. - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __OCRDMA_MAIN_H__ -#define __OCRDMA_MAIN_H__ - -#include -#include -#include - -#include -#include - -#include - -#define ocrdma_err(format, arg...) printf(format, ##arg) - -#define OCRDMA_DPP_PAGE_SIZE (4096) - -#define ROUND_UP_X(_val, _x) \ - (((unsigned long)(_val) + ((_x)-1)) & (long)~((_x)-1)) - -struct ocrdma_qp; - -struct ocrdma_device { - struct verbs_device ibv_dev; - struct ocrdma_qp **qp_tbl; - pthread_mutex_t dev_lock; - pthread_spinlock_t flush_q_lock; - int id; - int gen; - uint32_t wqe_size; - uint32_t rqe_size; - uint32_t dpp_wqe_size; - uint32_t max_inline_data; - uint8_t fw_ver[32]; -}; - -struct ocrdma_devctx { - struct ibv_context ibv_ctx; - uint32_t *ah_tbl; - uint32_t ah_tbl_len; - pthread_mutex_t tbl_lock; -}; - -struct ocrdma_pd { - struct ibv_pd ibv_pd; - struct ocrdma_device *dev; - struct ocrdma_devctx *uctx; - void *dpp_va; -}; - -struct ocrdma_mr { - struct ibv_mr ibv_mr; -}; - -struct ocrdma_cq { - struct ibv_cq ibv_cq; - struct ocrdma_device *dev; - uint16_t cq_id; - uint16_t cq_dbid; - uint16_t getp; - pthread_spinlock_t cq_lock; - uint32_t max_hw_cqe; - uint32_t cq_mem_size; - struct ocrdma_cqe *va; - void *db_va; - - uint32_t db_size; - - uint32_t phase; - int phase_change; - - uint8_t deferred_arm; - uint8_t deferred_sol; - uint8_t first_arm; - struct list_head sq_head; - struct list_head rq_head; -}; - -enum { - OCRDMA_DPP_WQE_INDEX_MASK = 0xFFFF, - OCRDMA_DPP_CQE_VALID_BIT_SHIFT = 31, - OCRDMA_DPP_CQE_VALID_BIT_MASK = 1 << 31 -}; - -struct ocrdma_dpp_cqe { - uint32_t wqe_idx_valid; -}; - -enum { - OCRDMA_PD_MAX_DPP_ENABLED_QP = 16 -}; - -struct ocrdma_qp_hwq_info { - uint8_t *va; /* virtual address */ - uint32_t max_sges; - uint32_t free_cnt; - - uint32_t head, tail; - uint32_t entry_size; - uint32_t max_cnt; - uint32_t max_wqe_idx; - uint32_t len; - uint16_t dbid; /* qid, where to ring the doorbell. */ -}; - -struct ocrdma_srq { - struct ibv_srq ibv_srq; - struct ocrdma_device *dev; - void *db_va; - uint32_t db_size; - pthread_spinlock_t q_lock; - - struct ocrdma_qp_hwq_info rq; - uint32_t max_rq_sges; - uint32_t id; - uint64_t *rqe_wr_id_tbl; - uint32_t *idx_bit_fields; - uint32_t bit_fields_len; - uint32_t db_shift; -}; - -enum { - OCRDMA_CREATE_QP_REQ_DPP_CREDIT_LIMIT = 1 -}; - -enum ocrdma_qp_state { - OCRDMA_QPS_RST = 0, - OCRDMA_QPS_INIT = 1, - OCRDMA_QPS_RTR = 2, - OCRDMA_QPS_RTS = 3, - OCRDMA_QPS_SQE = 4, - OCRDMA_QPS_SQ_DRAINING = 5, - OCRDMA_QPS_ERR = 6, - OCRDMA_QPS_SQD = 7 -}; - -struct ocrdma_qp { - struct ibv_qp ibv_qp; - struct ocrdma_device *dev; - pthread_spinlock_t q_lock; - - struct ocrdma_qp_hwq_info sq; - struct ocrdma_cq *sq_cq; - struct { - uint64_t wrid; - uint16_t dpp_wqe_idx; - uint16_t dpp_wqe; - uint8_t signaled; - uint8_t rsvd[3]; - } *wqe_wr_id_tbl; - struct ocrdma_qp_hwq_info dpp_q; - int dpp_enabled; - - struct ocrdma_qp_hwq_info rq; - struct ocrdma_cq *rq_cq; - uint64_t *rqe_wr_id_tbl; - void *db_va; - void *db_sq_va; - void *db_rq_va; - uint32_t max_inline_data; - - struct ocrdma_srq *srq; - struct ocrdma_cq *dpp_cq; - - uint32_t db_size; - uint32_t max_ord; - uint32_t max_ird; - uint32_t dpp_prev_indx; - - enum ibv_qp_type qp_type; - enum ocrdma_qp_state state; - struct list_node sq_entry; - struct list_node rq_entry; - uint16_t id; - uint16_t rsvd; - uint32_t db_shift; - int signaled; /* signaled QP */ -}; - -enum { - OCRDMA_AH_ID_MASK = 0x3FF, - OCRDMA_AH_VLAN_VALID_MASK = 0x01, - OCRDMA_AH_VLAN_VALID_SHIFT = 0x1F, - OCRDMA_AH_L3_TYPE_MASK = 0x03, - OCRDMA_AH_L3_TYPE_SHIFT = 0x1D -}; - -struct ocrdma_ah { - struct ibv_ah ibv_ah; - struct ocrdma_pd *pd; - uint16_t id; - uint8_t isvlan; - uint8_t hdr_type; -}; - -#define get_ocrdma_xxx(xxx, type) \ - ((struct ocrdma_##type *) \ - ((void *) ib##xxx - offsetof(struct ocrdma_##type, ibv_##xxx))) - -static inline struct ocrdma_devctx *get_ocrdma_ctx(struct ibv_context *ibctx) -{ - return get_ocrdma_xxx(ctx, devctx); -} - -static inline struct ocrdma_device *get_ocrdma_dev(struct ibv_device *ibdev) -{ - return get_ocrdma_xxx(dev, device); -} - -static inline struct ocrdma_qp *get_ocrdma_qp(struct ibv_qp *ibqp) -{ - return get_ocrdma_xxx(qp, qp); -} - -static inline struct ocrdma_srq *get_ocrdma_srq(struct ibv_srq *ibsrq) -{ - return get_ocrdma_xxx(srq, srq); -} - -static inline struct ocrdma_pd *get_ocrdma_pd(struct ibv_pd *ibpd) -{ - return get_ocrdma_xxx(pd, pd); -} - -static inline struct ocrdma_cq *get_ocrdma_cq(struct ibv_cq *ibcq) -{ - return get_ocrdma_xxx(cq, cq); -} - -static inline struct ocrdma_ah *get_ocrdma_ah(struct ibv_ah *ibah) -{ - return get_ocrdma_xxx(ah, ah); -} - -void ocrdma_init_ahid_tbl(struct ocrdma_devctx *ctx); -int ocrdma_query_device(struct ibv_context *, struct ibv_device_attr *); -int ocrdma_query_port(struct ibv_context *, uint8_t, struct ibv_port_attr *); -struct ibv_pd *ocrdma_alloc_pd(struct ibv_context *); -int ocrdma_free_pd(struct ibv_pd *); -struct ibv_mr *ocrdma_reg_mr(struct ibv_pd *, void *, size_t, - int ibv_access_flags); -int ocrdma_dereg_mr(struct ibv_mr *); - -struct ibv_cq *ocrdma_create_cq(struct ibv_context *, int, - struct ibv_comp_channel *, int); -int ocrdma_resize_cq(struct ibv_cq *, int); -int ocrdma_destroy_cq(struct ibv_cq *); -int ocrdma_poll_cq(struct ibv_cq *, int, struct ibv_wc *); -int ocrdma_arm_cq(struct ibv_cq *, int); - -struct ibv_qp *ocrdma_create_qp(struct ibv_pd *, struct ibv_qp_init_attr *); -int ocrdma_modify_qp(struct ibv_qp *, struct ibv_qp_attr *, - int ibv_qp_attr_mask); -int ocrdma_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask, - struct ibv_qp_init_attr *init_attr); -int ocrdma_destroy_qp(struct ibv_qp *); -int ocrdma_post_send(struct ibv_qp *, struct ibv_send_wr *, - struct ibv_send_wr **); -int ocrdma_post_recv(struct ibv_qp *, struct ibv_recv_wr *, - struct ibv_recv_wr **); - -struct ibv_srq *ocrdma_create_srq(struct ibv_pd *, struct ibv_srq_init_attr *); -int ocrdma_modify_srq(struct ibv_srq *, struct ibv_srq_attr *, int); -int ocrdma_destroy_srq(struct ibv_srq *); -int ocrdma_query_srq(struct ibv_srq *ibsrq, struct ibv_srq_attr *attr); -int ocrdma_post_srq_recv(struct ibv_srq *, struct ibv_recv_wr *, - struct ibv_recv_wr **); -struct ibv_ah *ocrdma_create_ah(struct ibv_pd *, struct ibv_ah_attr *); -int ocrdma_destroy_ah(struct ibv_ah *); -int ocrdma_attach_mcast(struct ibv_qp *, const union ibv_gid *, uint16_t); -int ocrdma_detach_mcast(struct ibv_qp *, const union ibv_gid *, uint16_t); -void ocrdma_async_event(struct ibv_async_event *event); - -#endif /* __OCRDMA_MAIN_H__ */ diff --git a/usr/rdma-core/providers/ocrdma/ocrdma_verbs.c b/usr/rdma-core/providers/ocrdma/ocrdma_verbs.c deleted file mode 100644 index 6f140c33d..000000000 --- a/usr/rdma-core/providers/ocrdma/ocrdma_verbs.c +++ /dev/null @@ -1,2166 +0,0 @@ -/* - * Copyright (C) 2008-2013 Emulex. All rights reserved. - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ocrdma_main.h" -#include "ocrdma_abi.h" -#include -#include - -static void ocrdma_ring_cq_db(struct ocrdma_cq *cq, uint32_t armed, - int solicited, uint32_t num_cqe); - -static inline void ocrdma_swap_cpu_to_le(void *dst, uint32_t len) -{ - int i = 0; - __le32 *src_ptr = dst; - uint32_t *dst_ptr = dst; - for (; i < (len / 4); i++) - *dst_ptr++ = le32toh(*src_ptr++); -} - -/* - * ocrdma_query_device - */ -int ocrdma_query_device(struct ibv_context *context, - struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t fw_ver; - struct ocrdma_device *dev = get_ocrdma_dev(context->device); - int status; - - bzero(attr, sizeof *attr); - status = ibv_cmd_query_device(context, attr, &fw_ver, &cmd, sizeof cmd); - memcpy(attr->fw_ver, dev->fw_ver, sizeof(dev->fw_ver)); - return status; -} - -/* - * ocrdma_query_port - */ -int ocrdma_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - int status; - status = ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); - return status; -} - -#define OCRDMA_INVALID_AH_IDX 0xffffffff -void ocrdma_init_ahid_tbl(struct ocrdma_devctx *ctx) -{ - int i; - - pthread_mutex_init(&ctx->tbl_lock, NULL); - for (i = 0; i < (ctx->ah_tbl_len / sizeof(uint32_t)); i++) - ctx->ah_tbl[i] = OCRDMA_INVALID_AH_IDX; -} - -static int ocrdma_alloc_ah_tbl_id(struct ocrdma_devctx *ctx) -{ - int i; - int status = -EINVAL; - pthread_mutex_lock(&ctx->tbl_lock); - - for (i = 0; i < (ctx->ah_tbl_len / sizeof(uint32_t)); i++) { - if (ctx->ah_tbl[i] == OCRDMA_INVALID_AH_IDX) { - ctx->ah_tbl[i] = ctx->ah_tbl_len; - status = i; - break; - } - } - pthread_mutex_unlock(&ctx->tbl_lock); - return status; -} - -static void ocrdma_free_ah_tbl_id(struct ocrdma_devctx *ctx, int idx) -{ - pthread_mutex_lock(&ctx->tbl_lock); - ctx->ah_tbl[idx] = OCRDMA_INVALID_AH_IDX; - pthread_mutex_unlock(&ctx->tbl_lock); -} - -/* - * ocrdma_alloc_pd - */ -struct ibv_pd *ocrdma_alloc_pd(struct ibv_context *context) -{ - struct ocrdma_alloc_pd_req cmd; - struct ocrdma_alloc_pd_resp resp; - struct ocrdma_pd *pd; - uint64_t map_address = 0; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - bzero(pd, sizeof *pd); - memset(&cmd, 0, sizeof(cmd)); - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd.cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(pd); - return NULL; - } - pd->dev = get_ocrdma_dev(context->device); - pd->uctx = get_ocrdma_ctx(context); - - if (resp.dpp_enabled) { - map_address = ((uint64_t) resp.dpp_page_addr_hi << 32) | - resp.dpp_page_addr_lo; - pd->dpp_va = mmap(NULL, OCRDMA_DPP_PAGE_SIZE, PROT_WRITE, - MAP_SHARED, context->cmd_fd, map_address); - if (pd->dpp_va == MAP_FAILED) { - ocrdma_free_pd(&pd->ibv_pd); - return NULL; - } - } - return &pd->ibv_pd; -} - -/* - * ocrdma_free_pd - */ -int ocrdma_free_pd(struct ibv_pd *ibpd) -{ - int status; - struct ocrdma_pd *pd = get_ocrdma_pd(ibpd); - - status = ibv_cmd_dealloc_pd(ibpd); - if (status) - return status; - - if (pd->dpp_va) - munmap((void *)pd->dpp_va, OCRDMA_DPP_PAGE_SIZE); - free(pd); - return 0; -} - -/* - * ocrdma_reg_mr - */ -struct ibv_mr *ocrdma_reg_mr(struct ibv_pd *pd, void *addr, - size_t len, int access) -{ - struct ocrdma_mr *mr; - struct ibv_reg_mr cmd; - struct ocrdma_reg_mr_resp resp; - uint64_t hca_va = (uintptr_t) addr; - - mr = malloc(sizeof *mr); - if (!mr) - return NULL; - bzero(mr, sizeof *mr); - - if (ibv_cmd_reg_mr(pd, addr, len, hca_va, - access, &mr->ibv_mr, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) { - free(mr); - return NULL; - } - return &mr->ibv_mr; -} - -/* - * ocrdma_dereg_mr - */ -int ocrdma_dereg_mr(struct ibv_mr *mr) -{ - int status; - status = ibv_cmd_dereg_mr(mr); - if (status) - return status; - free(mr); - return 0; -} - -/* - * ocrdma_create_cq - */ -static struct ibv_cq *ocrdma_create_cq_common(struct ibv_context *context, - int cqe, - struct ibv_comp_channel *channel, - int comp_vector, int dpp_cq) -{ - int status; - struct ocrdma_create_cq_req cmd; - struct ocrdma_create_cq_resp resp; - struct ocrdma_cq *cq; - struct ocrdma_device *dev = get_ocrdma_dev(context->device); - void *map_addr; - - cq = malloc(sizeof *cq); - if (!cq) - return NULL; - - bzero(cq, sizeof *cq); - cmd.dpp_cq = dpp_cq; - status = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &cq->ibv_cq, &cmd.ibv_cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (status) - goto cq_err1; - - pthread_spin_init(&cq->cq_lock, PTHREAD_PROCESS_PRIVATE); - cq->dev = dev; - cq->cq_id = resp.cq_id; - cq->cq_dbid = resp.cq_id; - cq->cq_mem_size = resp.size; - cq->max_hw_cqe = resp.max_hw_cqe; - cq->phase_change = resp.phase_change; - cq->va = mmap(NULL, resp.size, PROT_READ | PROT_WRITE, - MAP_SHARED, context->cmd_fd, resp.page_addr[0]); - if (cq->va == MAP_FAILED) - goto cq_err2; - - map_addr = mmap(NULL, resp.db_page_size, PROT_WRITE, - MAP_SHARED, context->cmd_fd, resp.db_page_addr); - if (map_addr == MAP_FAILED) - goto cq_err2; - cq->db_va = map_addr; - cq->db_size = resp.db_page_size; - cq->phase = OCRDMA_CQE_VALID; - cq->first_arm = 1; - if (!dpp_cq) { - ocrdma_ring_cq_db(cq, 0, 0, 0); - } - cq->ibv_cq.cqe = cqe; - list_head_init(&cq->sq_head); - list_head_init(&cq->rq_head); - return &cq->ibv_cq; -cq_err2: - (void)ibv_cmd_destroy_cq(&cq->ibv_cq); -cq_err1: - free(cq); - return NULL; -} - -struct ibv_cq *ocrdma_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - return ocrdma_create_cq_common(context, cqe, channel, comp_vector, 0); -} - -#ifdef DPP_CQ_SUPPORT -static struct ocrdma_cq *ocrdma_create_dpp_cq(struct ibv_context *context, - int cqe) -{ - struct ibv_cq *ibcq; - ibcq = ocrdma_create_cq_common(context, cqe, 0, 0, 1); - if (ibcq) - return get_ocrdma_cq(ibcq); - return NULL; -} -#endif - -/* - * ocrdma_resize_cq - */ -int ocrdma_resize_cq(struct ibv_cq *ibcq, int new_entries) -{ - int status; - struct ibv_resize_cq cmd; - struct ibv_resize_cq_resp resp; - status = ibv_cmd_resize_cq(ibcq, new_entries, - &cmd, sizeof cmd, &resp, sizeof resp); - if (status == 0) - ibcq->cqe = new_entries; - return status; -} - -/* - * ocrdma_destroy_cq - */ -int ocrdma_destroy_cq(struct ibv_cq *ibv_cq) -{ - struct ocrdma_cq *cq = get_ocrdma_cq(ibv_cq); - int status; - - status = ibv_cmd_destroy_cq(ibv_cq); - if (status) - return status; - - if (cq->db_va) - munmap((void *)cq->db_va, cq->db_size); - if (cq->va) - munmap((void*)cq->va, cq->cq_mem_size); - - free(cq); - return 0; -} - -static void ocrdma_add_qpn_map(struct ocrdma_device *dev, struct ocrdma_qp *qp) -{ - pthread_mutex_lock(&dev->dev_lock); - dev->qp_tbl[qp->id] = qp; - pthread_mutex_unlock(&dev->dev_lock); -} - -static void _ocrdma_del_qpn_map(struct ocrdma_device *dev, struct ocrdma_qp *qp) -{ - dev->qp_tbl[qp->id] = NULL; -} - -struct ibv_srq *ocrdma_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *init_attr) -{ - int status = 0; - struct ocrdma_srq *srq; - struct ocrdma_create_srq_cmd cmd; - struct ocrdma_create_srq_resp resp; - void *map_addr; - - srq = calloc(1, sizeof *srq); - if (!srq) - return NULL; - - pthread_spin_init(&srq->q_lock, PTHREAD_PROCESS_PRIVATE); - status = ibv_cmd_create_srq(pd, &srq->ibv_srq, init_attr, &cmd.ibv_cmd, - sizeof cmd, &resp.ibv_resp, sizeof resp); - if (status) - goto cmd_err; - - srq->dev = get_ocrdma_pd(pd)->dev; - srq->rq.dbid = resp.rq_dbid; - srq->rq.max_sges = init_attr->attr.max_sge; - srq->rq.max_cnt = resp.num_rqe_allocated; - srq->rq.max_wqe_idx = resp.num_rqe_allocated - 1; - srq->rq.entry_size = srq->dev->rqe_size; - srq->rqe_wr_id_tbl = calloc(srq->rq.max_cnt, sizeof(uint64_t)); - if (srq->rqe_wr_id_tbl == NULL) - goto map_err; - - srq->bit_fields_len = - (srq->rq.max_cnt / 32) + (srq->rq.max_cnt % 32 ? 1 : 0); - srq->idx_bit_fields = malloc(srq->bit_fields_len * sizeof(uint32_t)); - if (srq->idx_bit_fields == NULL) - goto map_err; - memset(srq->idx_bit_fields, 0xff, - srq->bit_fields_len * sizeof(uint32_t)); - - if (resp.num_rq_pages > 1) - goto map_err; - - map_addr = mmap(NULL, resp.rq_page_size, PROT_READ | PROT_WRITE, - MAP_SHARED, pd->context->cmd_fd, resp.rq_page_addr[0]); - if (map_addr == MAP_FAILED) - goto map_err; - srq->rq.len = resp.rq_page_size; - srq->rq.va = map_addr; - - map_addr = mmap(NULL, resp.db_page_size, PROT_WRITE, - MAP_SHARED, pd->context->cmd_fd, resp.db_page_addr); - if (map_addr == MAP_FAILED) - goto map_err; - srq->db_va = (uint8_t *) map_addr + resp.db_rq_offset; - srq->db_shift = resp.db_shift; - srq->db_size = resp.db_page_size; - return &srq->ibv_srq; - -map_err: - ocrdma_destroy_srq(&srq->ibv_srq); - return NULL; - -cmd_err: - pthread_spin_destroy(&srq->q_lock); - free(srq); - return NULL; -} - -int ocrdma_modify_srq(struct ibv_srq *ibsrq, - struct ibv_srq_attr *attr, int attr_mask) -{ - struct ibv_modify_srq cmd; - - return ibv_cmd_modify_srq(ibsrq, attr, attr_mask, &cmd, sizeof cmd); -} - -int ocrdma_query_srq(struct ibv_srq *ibsrq, struct ibv_srq_attr *attr) -{ - struct ibv_query_srq cmd; - - return ibv_cmd_query_srq(ibsrq, attr, &cmd, sizeof cmd); -} - -int ocrdma_destroy_srq(struct ibv_srq *ibsrq) -{ - int status; - struct ocrdma_srq *srq; - srq = get_ocrdma_srq(ibsrq); - - status = ibv_cmd_destroy_srq(ibsrq); - if (status) - return status; - - if (srq->idx_bit_fields) - free(srq->idx_bit_fields); - if (srq->rqe_wr_id_tbl) - free(srq->rqe_wr_id_tbl); - if (srq->db_va) { - munmap((void *)srq->db_va, srq->db_size); - srq->db_va = NULL; - } - if (srq->rq.va) { - munmap(srq->rq.va, srq->rq.len); - srq->rq.va = NULL; - } - pthread_spin_destroy(&srq->q_lock); - free(srq); - return status; -} - -/* - * ocrdma_create_qp - */ -struct ibv_qp *ocrdma_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attrs) -{ - int status = 0; - struct ocrdma_create_qp_cmd cmd; - struct ocrdma_create_qp_uresp resp; - struct ocrdma_qp *qp; - void *map_addr; -#ifdef DPP_CQ_SUPPORT - struct ocrdma_dpp_cqe *dpp_cqe = NULL; -#endif - - qp = calloc(1, sizeof *qp); - if (!qp) - return NULL; - memset(&cmd, 0, sizeof(cmd)); - - qp->qp_type = attrs->qp_type; - pthread_spin_init(&qp->q_lock, PTHREAD_PROCESS_PRIVATE); - -#ifdef DPP_CQ_SUPPORT - if (attrs->cap.max_inline_data) { - qp->dpp_cq = ocrdma_create_dpp_cq(pd->context, - OCRDMA_CREATE_QP_REQ_DPP_CREDIT_LIMIT); - if (qp->dpp_cq) { - cmd.enable_dpp_cq = 1; - cmd.dpp_cq_id = qp->dpp_cq->cq_id; - /* Write invalid index for the first entry */ - dpp_cqe = (struct ocrdma_dpp_cqe *)qp->dpp_cq->va; - dpp_cqe->wqe_idx_valid = 0xFFFF; - qp->dpp_prev_indx = 0xFFFF; - } - } -#endif - status = ibv_cmd_create_qp(pd, &qp->ibv_qp, attrs, &cmd.ibv_cmd, - sizeof cmd, &resp.ibv_resp, sizeof resp); - if (status) - goto mbx_err; - - qp->dev = get_ocrdma_dev(pd->context->device); - qp->id = resp.qp_id; - - ocrdma_add_qpn_map(qp->dev, qp); - - qp->sq.dbid = resp.sq_dbid; - - qp->sq.max_sges = attrs->cap.max_send_sge; - qp->max_inline_data = attrs->cap.max_inline_data; - - qp->signaled = attrs->sq_sig_all; - - qp->sq.max_cnt = resp.num_wqe_allocated; - qp->sq.max_wqe_idx = resp.num_wqe_allocated - 1; - qp->sq.entry_size = qp->dev->wqe_size; - if (attrs->srq) - qp->srq = get_ocrdma_srq(attrs->srq); - else { - qp->rq.dbid = resp.rq_dbid; - qp->rq.max_sges = attrs->cap.max_recv_sge; - qp->rq.max_cnt = resp.num_rqe_allocated; - qp->rq.max_wqe_idx = resp.num_rqe_allocated - 1; - qp->rq.entry_size = qp->dev->rqe_size; - qp->rqe_wr_id_tbl = calloc(qp->rq.max_cnt, sizeof(uint64_t)); - if (qp->rqe_wr_id_tbl == NULL) - goto map_err; - } - - qp->sq_cq = get_ocrdma_cq(attrs->send_cq); - qp->rq_cq = get_ocrdma_cq(attrs->recv_cq); - - qp->wqe_wr_id_tbl = calloc(qp->sq.max_cnt, sizeof(*qp->wqe_wr_id_tbl)); - if (qp->wqe_wr_id_tbl == NULL) - goto map_err; - - /* currently we support only one virtual page */ - if ((resp.num_sq_pages > 1) || (!attrs->srq && resp.num_rq_pages > 1)) - goto map_err; - - map_addr = mmap(NULL, resp.sq_page_size, PROT_READ | PROT_WRITE, - MAP_SHARED, pd->context->cmd_fd, resp.sq_page_addr[0]); - if (map_addr == MAP_FAILED) - goto map_err; - qp->sq.va = map_addr; - qp->sq.len = resp.sq_page_size; - qp->db_shift = resp.db_shift; - - if (!attrs->srq) { - map_addr = mmap(NULL, resp.rq_page_size, PROT_READ | PROT_WRITE, - MAP_SHARED, pd->context->cmd_fd, - resp.rq_page_addr[0]); - if (map_addr == MAP_FAILED) - goto map_err; - - qp->rq.len = resp.rq_page_size; - qp->rq.va = map_addr; - } - - map_addr = mmap(NULL, resp.db_page_size, PROT_WRITE, - MAP_SHARED, pd->context->cmd_fd, resp.db_page_addr); - if (map_addr == MAP_FAILED) - goto map_err; - - qp->db_va = map_addr; - qp->db_sq_va = (uint8_t *) map_addr + resp.db_sq_offset; - qp->db_rq_va = (uint8_t *) map_addr + resp.db_rq_offset; - - qp->db_size = resp.db_page_size; - - if (resp.dpp_credit) { - struct ocrdma_pd *opd = get_ocrdma_pd(pd); - map_addr = (uint8_t *) opd->dpp_va + - (resp.dpp_offset * qp->dev->wqe_size); - qp->dpp_q.max_cnt = 1; /* DPP is posted at the same offset */ - qp->dpp_q.free_cnt = resp.dpp_credit; - qp->dpp_q.va = map_addr; - qp->dpp_q.head = qp->dpp_q.tail = 0; - qp->dpp_q.entry_size = qp->dev->dpp_wqe_size; - qp->dpp_q.len = resp.dpp_credit * qp->dev->dpp_wqe_size; - qp->dpp_enabled = 1; - } else { - if (qp->dpp_cq) { - ocrdma_destroy_cq(&qp->dpp_cq->ibv_cq); - qp->dpp_cq = NULL; - } - } - qp->state = OCRDMA_QPS_RST; - list_node_init(&qp->sq_entry); - list_node_init(&qp->rq_entry); - return &qp->ibv_qp; - -map_err: - ocrdma_destroy_qp(&qp->ibv_qp); - return NULL; -mbx_err: - pthread_spin_destroy(&qp->q_lock); - free(qp); - return NULL; -} - -static enum ocrdma_qp_state get_ocrdma_qp_state(enum ibv_qp_state qps) -{ - switch (qps) { - case IBV_QPS_RESET: - return OCRDMA_QPS_RST; - case IBV_QPS_INIT: - return OCRDMA_QPS_INIT; - case IBV_QPS_RTR: - return OCRDMA_QPS_RTR; - case IBV_QPS_RTS: - return OCRDMA_QPS_RTS; - case IBV_QPS_SQD: - return OCRDMA_QPS_SQD; - case IBV_QPS_SQE: - return OCRDMA_QPS_SQE; - case IBV_QPS_ERR: - return OCRDMA_QPS_ERR; - case IBV_QPS_UNKNOWN: - break; - default: - break; - }; - return OCRDMA_QPS_ERR; -} - -static int ocrdma_is_qp_in_sq_flushlist(struct ocrdma_cq *cq, - struct ocrdma_qp *qp) -{ - struct ocrdma_qp *list_qp; - struct ocrdma_qp *list_qp_tmp; - int found = 0; - list_for_each_safe(&cq->sq_head, list_qp, list_qp_tmp, sq_entry) { - if (qp == list_qp) { - found = 1; - break; - } - } - return found; -} - -static int ocrdma_is_qp_in_rq_flushlist(struct ocrdma_cq *cq, - struct ocrdma_qp *qp) -{ - struct ocrdma_qp *list_qp; - struct ocrdma_qp *list_qp_tmp; - int found = 0; - list_for_each_safe(&cq->rq_head, list_qp, list_qp_tmp, rq_entry) { - if (qp == list_qp) { - found = 1; - break; - } - } - return found; -} - -static void ocrdma_init_hwq_ptr(struct ocrdma_qp *qp) -{ - qp->sq.head = qp->sq.tail = 0; - qp->rq.head = qp->rq.tail = 0; - qp->dpp_q.head = qp->dpp_q.tail = 0; - qp->dpp_q.free_cnt = qp->dpp_q.max_cnt; -} - -static void ocrdma_del_flush_qp(struct ocrdma_qp *qp) -{ - int found = 0; - struct ocrdma_device *dev = qp->dev; - /* sync with any active CQ poll */ - - pthread_spin_lock(&dev->flush_q_lock); - found = ocrdma_is_qp_in_sq_flushlist(qp->sq_cq, qp); - if (found) - list_del(&qp->sq_entry); - if (!qp->srq) { - found = ocrdma_is_qp_in_rq_flushlist(qp->rq_cq, qp); - if (found) - list_del(&qp->rq_entry); - } - pthread_spin_unlock(&dev->flush_q_lock); -} - -static void ocrdma_flush_qp(struct ocrdma_qp *qp) -{ - int found; - - pthread_spin_lock(&qp->dev->flush_q_lock); - found = ocrdma_is_qp_in_sq_flushlist(qp->sq_cq, qp); - if (!found) - list_add_tail(&qp->sq_cq->sq_head, &qp->sq_entry); - if (!qp->srq) { - found = ocrdma_is_qp_in_rq_flushlist(qp->rq_cq, qp); - if (!found) - list_add_tail(&qp->rq_cq->rq_head, &qp->rq_entry); - } - pthread_spin_unlock(&qp->dev->flush_q_lock); -} - -static int ocrdma_qp_state_machine(struct ocrdma_qp *qp, - enum ibv_qp_state new_ib_state) -{ - int status = 0; - enum ocrdma_qp_state new_state; - new_state = get_ocrdma_qp_state(new_ib_state); - - pthread_spin_lock(&qp->q_lock); - - if (new_state == qp->state) { - pthread_spin_unlock(&qp->q_lock); - return 1; - } - - switch (qp->state) { - case OCRDMA_QPS_RST: - switch (new_state) { - case OCRDMA_QPS_RST: - break; - case OCRDMA_QPS_INIT: - /* init pointers to place wqe/rqe at start of hw q */ - ocrdma_init_hwq_ptr(qp); - /* detach qp from the CQ flush list */ - ocrdma_del_flush_qp(qp); - break; - default: - status = EINVAL; - break; - }; - break; - case OCRDMA_QPS_INIT: - /* qps: INIT->XXX */ - switch (new_state) { - case OCRDMA_QPS_INIT: - break; - case OCRDMA_QPS_RTR: - break; - case OCRDMA_QPS_ERR: - ocrdma_flush_qp(qp); - break; - default: - /* invalid state change. */ - status = EINVAL; - break; - }; - break; - case OCRDMA_QPS_RTR: - /* qps: RTS->XXX */ - switch (new_state) { - case OCRDMA_QPS_RTS: - break; - case OCRDMA_QPS_ERR: - ocrdma_flush_qp(qp); - break; - default: - /* invalid state change. */ - status = EINVAL; - break; - }; - break; - case OCRDMA_QPS_RTS: - /* qps: RTS->XXX */ - switch (new_state) { - case OCRDMA_QPS_SQD: - case OCRDMA_QPS_SQE: - break; - case OCRDMA_QPS_ERR: - ocrdma_flush_qp(qp); - break; - default: - /* invalid state change. */ - status = EINVAL; - break; - }; - break; - case OCRDMA_QPS_SQD: - /* qps: SQD->XXX */ - switch (new_state) { - case OCRDMA_QPS_RTS: - case OCRDMA_QPS_SQE: - case OCRDMA_QPS_ERR: - break; - default: - /* invalid state change. */ - status = EINVAL; - break; - }; - break; - case OCRDMA_QPS_SQE: - switch (new_state) { - case OCRDMA_QPS_RTS: - case OCRDMA_QPS_ERR: - break; - default: - /* invalid state change. */ - status = EINVAL; - break; - }; - break; - case OCRDMA_QPS_ERR: - /* qps: ERR->XXX */ - switch (new_state) { - case OCRDMA_QPS_RST: - break; - default: - status = EINVAL; - break; - }; - break; - default: - status = EINVAL; - break; - }; - if (!status) - qp->state = new_state; - - pthread_spin_unlock(&qp->q_lock); - return status; -} - -/* - * ocrdma_modify_qp - */ -int ocrdma_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - struct ocrdma_qp *qp = get_ocrdma_qp(ibqp); - int status; - - status = ibv_cmd_modify_qp(ibqp, attr, attr_mask, &cmd, sizeof cmd); - if ((!status) && (attr_mask & IBV_QP_STATE)) - ocrdma_qp_state_machine(qp, attr->qp_state); - return status; -} - -/* - * ocrdma_query_qp - */ -int ocrdma_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - struct ocrdma_qp *qp = get_ocrdma_qp(ibqp); - int status; - - status = ibv_cmd_query_qp(ibqp, attr, attr_mask, - init_attr, &cmd, sizeof(cmd)); - - if (!status) - ocrdma_qp_state_machine(qp, attr->qp_state); - - return status; -} - -static void ocrdma_srq_toggle_bit(struct ocrdma_srq *srq, int idx) -{ - int i = idx / 32; - unsigned int mask = (1 << (idx % 32)); - - if (srq->idx_bit_fields[i] & mask) { - srq->idx_bit_fields[i] &= ~mask; - } else { - srq->idx_bit_fields[i] |= mask; - } -} - -static int ocrdma_srq_get_idx(struct ocrdma_srq *srq) -{ - int row = 0; - int indx = 0; - - for (row = 0; row < srq->bit_fields_len; row++) { - if (srq->idx_bit_fields[row]) { - indx = ffs(srq->idx_bit_fields[row]); - indx = (row * 32) + (indx - 1); - if (indx >= srq->rq.max_cnt) - assert(0); - ocrdma_srq_toggle_bit(srq, indx); - break; - } - } - if (row == srq->bit_fields_len) - assert(0); - return indx + 1; /* Use the index from 1 */ -} - -static int ocrdma_dppq_credits(struct ocrdma_qp_hwq_info *q) -{ - return ((q->max_wqe_idx - q->head) + q->tail) % q->free_cnt; -} - -static int ocrdma_hwq_free_cnt(struct ocrdma_qp_hwq_info *q) -{ - return ((q->max_wqe_idx - q->head) + q->tail) % q->max_cnt; -} - -static int is_hw_sq_empty(struct ocrdma_qp *qp) -{ - return ((qp->sq.tail == qp->sq.head) ? 1 : 0); -} - -static inline int is_hw_rq_empty(struct ocrdma_qp *qp) -{ - return ((qp->rq.head == qp->rq.tail) ? 1 : 0); -} - -static inline void *ocrdma_hwq_head(struct ocrdma_qp_hwq_info *q) -{ - return q->va + (q->head * q->entry_size); -} - -/*static inline void *ocrdma_wq_tail(struct ocrdma_qp_hwq_info *q) -{ - return q->va + (q->tail * q->entry_size); -} -*/ - -static inline void *ocrdma_hwq_head_from_idx(struct ocrdma_qp_hwq_info *q, - uint32_t idx) -{ - return q->va + (idx * q->entry_size); -} - -static void ocrdma_hwq_inc_head(struct ocrdma_qp_hwq_info *q) -{ - q->head = (q->head + 1) & q->max_wqe_idx; -} - -static void ocrdma_hwq_inc_tail(struct ocrdma_qp_hwq_info *q) -{ - q->tail = (q->tail + 1) & q->max_wqe_idx; -} - -static inline void ocrdma_hwq_inc_tail_by_idx(struct ocrdma_qp_hwq_info *q, - int idx) -{ - q->tail = (idx + 1) & q->max_wqe_idx; -} - -static int is_cqe_valid(struct ocrdma_cq *cq, struct ocrdma_cqe *cqe) -{ - int cqe_valid; - cqe_valid = le32toh(cqe->flags_status_srcqpn) & OCRDMA_CQE_VALID; - return (cqe_valid == cq->phase); -} - -static int is_cqe_for_sq(struct ocrdma_cqe *cqe) -{ - return (le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_QTYPE) ? 0 : 1; -} - -static int is_cqe_imm(struct ocrdma_cqe *cqe) -{ - return (le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_IMM) ? 1 : 0; -} - -static int is_cqe_wr_imm(struct ocrdma_cqe *cqe) -{ - return (le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_WRITE_IMM) ? 1 : 0; -} - -static inline void ocrdma_srq_inc_tail(struct ocrdma_qp *qp, - struct ocrdma_cqe *cqe) -{ - int wqe_idx; - - wqe_idx = (le32toh(cqe->rq.buftag_qpn) >> - OCRDMA_CQE_BUFTAG_SHIFT) & qp->srq->rq.max_wqe_idx; - - if (wqe_idx < 1) - assert(0); - - pthread_spin_lock(&qp->srq->q_lock); - ocrdma_hwq_inc_tail(&qp->srq->rq); - ocrdma_srq_toggle_bit(qp->srq, wqe_idx - 1); - pthread_spin_unlock(&qp->srq->q_lock); -} - -static void ocrdma_discard_cqes(struct ocrdma_qp *qp, struct ocrdma_cq *cq) -{ - int discard_cnt = 0; - uint32_t cur_getp, stop_getp; - struct ocrdma_cqe *cqe; - uint32_t qpn = 0; - int wqe_idx; - - pthread_spin_lock(&cq->cq_lock); - - /* traverse through the CQEs in the hw CQ, - * find the matching CQE for a given qp, - * mark the matching one discarded=1. - * discard the cqe. - * ring the doorbell in the poll_cq() as - * we don't complete out of order cqe. - */ - cur_getp = cq->getp; - /* find upto when do we reap the cq.*/ - stop_getp = cur_getp; - do { - if (is_hw_sq_empty(qp) && (!qp->srq && is_hw_rq_empty(qp))) - break; - - cqe = cq->va + cur_getp; - /* if (a) no valid cqe, or (b) done reading full hw cq, or - * (c) qp_xq becomes empty. - * then exit - */ - qpn = le32toh(cqe->cmn.qpn) & OCRDMA_CQE_QPN_MASK; - /* if previously discarded cqe found, skip that too. - * check for matching qp - */ - if ((qpn == 0) || (qpn != qp->id)) - goto skip_cqe; - - /* mark cqe discarded so that it is not picked up later - * in the poll_cq(). - */ - if (is_cqe_for_sq(cqe)) { - wqe_idx = (le32toh(cqe->wq.wqeidx) & - OCRDMA_CQE_WQEIDX_MASK) & qp->sq.max_wqe_idx; - ocrdma_hwq_inc_tail_by_idx(&qp->sq, wqe_idx); - } else { - if (qp->srq) - ocrdma_srq_inc_tail(qp, cqe); - else - ocrdma_hwq_inc_tail(&qp->rq); - } - - discard_cnt += 1; - /* discard by marking qp_id = 0 */ - cqe->cmn.qpn = 0; -skip_cqe: - cur_getp = (cur_getp + 1) % cq->max_hw_cqe; - - } while (cur_getp != stop_getp); - pthread_spin_unlock(&cq->cq_lock); -} - -/* - * ocrdma_destroy_qp - */ -int ocrdma_destroy_qp(struct ibv_qp *ibqp) -{ - int status = 0; - struct ocrdma_qp *qp; - struct ocrdma_device *dev; - - qp = get_ocrdma_qp(ibqp); - dev = qp->dev; - /* - * acquire CQ lock while destroy is in progress, in order to - * protect against proessing in-flight CQEs for this QP. - */ - pthread_spin_lock(&qp->sq_cq->cq_lock); - - if (qp->rq_cq && (qp->rq_cq != qp->sq_cq)) - pthread_spin_lock(&qp->rq_cq->cq_lock); - - _ocrdma_del_qpn_map(qp->dev, qp); - - if (qp->rq_cq && (qp->rq_cq != qp->sq_cq)) - pthread_spin_unlock(&qp->rq_cq->cq_lock); - - pthread_spin_unlock(&qp->sq_cq->cq_lock); - - if (qp->db_va) - munmap((void *)qp->db_va, qp->db_size); - if (qp->rq.va) - munmap(qp->rq.va, qp->rq.len); - if (qp->sq.va) - munmap(qp->sq.va, qp->sq.len); - - /* ensure that CQEs for newly created QP (whose id may be same with - * one which just getting destroyed are same), don't get - * discarded until the old CQEs are discarded. - */ - pthread_mutex_lock(&dev->dev_lock); - status = ibv_cmd_destroy_qp(ibqp); - - ocrdma_discard_cqes(qp, qp->sq_cq); - ocrdma_discard_cqes(qp, qp->rq_cq); - pthread_mutex_unlock(&dev->dev_lock); - - ocrdma_del_flush_qp(qp); - - pthread_spin_destroy(&qp->q_lock); - if (qp->rqe_wr_id_tbl) - free(qp->rqe_wr_id_tbl); - if (qp->wqe_wr_id_tbl) - free(qp->wqe_wr_id_tbl); - if (qp->dpp_cq) - ocrdma_destroy_cq(&qp->dpp_cq->ibv_cq); - free(qp); - - return status; -} - -static void ocrdma_ring_sq_db(struct ocrdma_qp *qp) -{ - __le32 db_val = htole32((qp->sq.dbid | (1 << 16))); - - udma_to_device_barrier(); - *(__le32 *) (((uint8_t *) qp->db_sq_va)) = db_val; -} - -static void ocrdma_ring_rq_db(struct ocrdma_qp *qp) -{ - __le32 db_val = htole32((qp->rq.dbid | (1 << qp->db_shift))); - - udma_to_device_barrier(); - *(__le32 *) ((uint8_t *) qp->db_rq_va) = db_val; -} - -static void ocrdma_ring_srq_db(struct ocrdma_srq *srq) -{ - __le32 db_val = htole32(srq->rq.dbid | (1 << srq->db_shift)); - - udma_to_device_barrier(); - *(__le32 *) (srq->db_va) = db_val; -} - -static void ocrdma_ring_cq_db(struct ocrdma_cq *cq, uint32_t armed, - int solicited, uint32_t num_cqe) -{ - uint32_t val; - - val = cq->cq_dbid & OCRDMA_DB_CQ_RING_ID_MASK; - val |= ((cq->cq_dbid & OCRDMA_DB_CQ_RING_ID_EXT_MASK) << - OCRDMA_DB_CQ_RING_ID_EXT_MASK_SHIFT); - - if (armed) - val |= (1 << OCRDMA_DB_CQ_REARM_SHIFT); - if (solicited) - val |= (1 << OCRDMA_DB_CQ_SOLICIT_SHIFT); - val |= (num_cqe << OCRDMA_DB_CQ_NUM_POPPED_SHIFT); - - udma_to_device_barrier(); - *(__le32 *) ((uint8_t *) (cq->db_va) + OCRDMA_DB_CQ_OFFSET) = - htole32(val); -} - -static void ocrdma_build_ud_hdr(struct ocrdma_qp *qp, - struct ocrdma_hdr_wqe *hdr, - struct ibv_send_wr *wr) -{ - struct ocrdma_ewqe_ud_hdr *ud_hdr = - (struct ocrdma_ewqe_ud_hdr *)(hdr + 1); - struct ocrdma_ah *ah = get_ocrdma_ah(wr->wr.ud.ah); - - ud_hdr->rsvd_dest_qpn = wr->wr.ud.remote_qpn; - ud_hdr->qkey = wr->wr.ud.remote_qkey; - ud_hdr->rsvd_ahid = ah->id; - if (ah->isvlan) - hdr->cw |= (OCRDMA_FLAG_AH_VLAN_PR << - OCRDMA_WQE_FLAGS_SHIFT); - ud_hdr->hdr_type = ah->hdr_type; -} - -static void ocrdma_build_sges(struct ocrdma_hdr_wqe *hdr, - struct ocrdma_sge *sge, int num_sge, - struct ibv_sge *sg_list) -{ - int i; - for (i = 0; i < num_sge; i++) { - sge[i].lrkey = sg_list[i].lkey; - sge[i].addr_lo = sg_list[i].addr; - sge[i].addr_hi = sg_list[i].addr >> 32; - sge[i].len = sg_list[i].length; - hdr->total_len += sg_list[i].length; - } - if (num_sge == 0) - memset(sge, 0, sizeof(*sge)); -} - - -static inline uint32_t ocrdma_sglist_len(struct ibv_sge *sg_list, int num_sge) -{ - uint32_t total_len = 0, i; - - for (i = 0; i < num_sge; i++) - total_len += sg_list[i].length; - return total_len; -} - -static inline int ocrdma_build_inline_sges(struct ocrdma_qp *qp, - struct ocrdma_hdr_wqe *hdr, - struct ocrdma_sge *sge, - struct ibv_send_wr *wr, - uint32_t wqe_size) -{ - int i; - char *dpp_addr; - - if (wr->send_flags & IBV_SEND_INLINE && qp->qp_type != IBV_QPT_UD) { - hdr->total_len = ocrdma_sglist_len(wr->sg_list, wr->num_sge); - if (hdr->total_len > qp->max_inline_data) { - ocrdma_err - ("%s() supported_len=0x%x, unsupported len req=0x%x\n", - __func__, qp->max_inline_data, hdr->total_len); - return EINVAL; - } - - dpp_addr = (char *)sge; - for (i = 0; i < wr->num_sge; i++) { - memcpy(dpp_addr, - (void *)(unsigned long)wr->sg_list[i].addr, - wr->sg_list[i].length); - dpp_addr += wr->sg_list[i].length; - } - - wqe_size += ROUND_UP_X(hdr->total_len, OCRDMA_WQE_ALIGN_BYTES); - if (0 == hdr->total_len) - wqe_size += sizeof(struct ocrdma_sge); - hdr->cw |= (OCRDMA_TYPE_INLINE << OCRDMA_WQE_TYPE_SHIFT); - } else { - ocrdma_build_sges(hdr, sge, wr->num_sge, wr->sg_list); - if (wr->num_sge) - wqe_size += (wr->num_sge * sizeof(struct ocrdma_sge)); - else - wqe_size += sizeof(struct ocrdma_sge); - hdr->cw |= (OCRDMA_TYPE_LKEY << OCRDMA_WQE_TYPE_SHIFT); - } - hdr->cw |= ((wqe_size / OCRDMA_WQE_STRIDE) << OCRDMA_WQE_SIZE_SHIFT); - return 0; -} - -static int ocrdma_build_send(struct ocrdma_qp *qp, struct ocrdma_hdr_wqe *hdr, - struct ibv_send_wr *wr) -{ - int status; - struct ocrdma_sge *sge; - uint32_t wqe_size = sizeof(*hdr); - - if (qp->qp_type == IBV_QPT_UD) { - wqe_size += sizeof(struct ocrdma_ewqe_ud_hdr); - ocrdma_build_ud_hdr(qp, hdr, wr); - sge = (struct ocrdma_sge *)(hdr + 2); - } else - sge = (struct ocrdma_sge *)(hdr + 1); - - status = ocrdma_build_inline_sges(qp, hdr, sge, wr, wqe_size); - - return status; -} - -static int ocrdma_build_write(struct ocrdma_qp *qp, struct ocrdma_hdr_wqe *hdr, - struct ibv_send_wr *wr) -{ - int status; - struct ocrdma_sge *ext_rw = (struct ocrdma_sge *)(hdr + 1); - struct ocrdma_sge *sge = ext_rw + 1; - uint32_t wqe_size = sizeof(*hdr) + sizeof(*ext_rw); - - status = ocrdma_build_inline_sges(qp, hdr, sge, wr, wqe_size); - if (status) - return status; - - ext_rw->addr_lo = wr->wr.rdma.remote_addr; - ext_rw->addr_hi = (wr->wr.rdma.remote_addr >> 32); - ext_rw->lrkey = wr->wr.rdma.rkey; - ext_rw->len = hdr->total_len; - - return 0; -} - -static void ocrdma_build_read(struct ocrdma_qp *qp, struct ocrdma_hdr_wqe *hdr, - struct ibv_send_wr *wr) -{ - struct ocrdma_sge *ext_rw = (struct ocrdma_sge *)(hdr + 1); - struct ocrdma_sge *sge = ext_rw + 1; - uint32_t wqe_size = ((wr->num_sge + 1) * sizeof(*sge)) + sizeof(*hdr); - - hdr->cw |= (OCRDMA_TYPE_LKEY << OCRDMA_WQE_TYPE_SHIFT); - hdr->cw |= ((wqe_size / OCRDMA_WQE_STRIDE) << OCRDMA_WQE_SIZE_SHIFT); - hdr->cw |= (OCRDMA_READ << OCRDMA_WQE_OPCODE_SHIFT); - - ocrdma_build_sges(hdr, sge, wr->num_sge, wr->sg_list); - - ext_rw->addr_lo = wr->wr.rdma.remote_addr; - ext_rw->addr_hi = (wr->wr.rdma.remote_addr >> 32); - ext_rw->lrkey = wr->wr.rdma.rkey; - ext_rw->len = hdr->total_len; - -} - -/* Dpp cq is single entry cq, we just need to read - * wqe index from first 16 bits at 0th cqe index. - */ -static void ocrdma_poll_dpp_cq(struct ocrdma_qp *qp) -{ - struct ocrdma_cq *cq = qp->dpp_cq; - struct ocrdma_dpp_cqe *cqe; - int idx = 0; - cqe = ((struct ocrdma_dpp_cqe *)cq->va); - idx = cqe->wqe_idx_valid & OCRDMA_DPP_WQE_INDEX_MASK; - - if (idx != qp->dpp_prev_indx) { - ocrdma_hwq_inc_tail_by_idx(&qp->dpp_q, idx); - qp->dpp_prev_indx = idx; - } -} - -static uint32_t ocrdma_get_hdr_len(struct ocrdma_qp *qp, - struct ocrdma_hdr_wqe *hdr) -{ - uint32_t hdr_sz = sizeof(*hdr); - if (qp->qp_type == IBV_QPT_UD) - hdr_sz += sizeof(struct ocrdma_ewqe_ud_hdr); - if (hdr->cw & (OCRDMA_WRITE << OCRDMA_WQE_OPCODE_SHIFT)) - hdr_sz += sizeof(struct ocrdma_sge); - return hdr_sz / sizeof(uint32_t); -} - -static void ocrdma_build_dpp_wqe(void *va, struct ocrdma_hdr_wqe *wqe, - uint32_t hdr_len) -{ - uint32_t pyld_len = (wqe->cw >> OCRDMA_WQE_SIZE_SHIFT) * 2; - uint32_t i = 0; - - mmio_wc_start(); - - /* convert WQE header to LE format */ - for (; i < hdr_len; i++) - *((__le32 *) va + i) = - htole32(*((uint32_t *) wqe + i)); - /* Convertion of data is done in HW */ - for (; i < pyld_len; i++) - *((uint32_t *) va + i) = (*((uint32_t *) wqe + i)); - - mmio_flush_writes(); -} - -static void ocrdma_post_dpp_wqe(struct ocrdma_qp *qp, - struct ocrdma_hdr_wqe *hdr) -{ - if (qp->dpp_cq && ocrdma_dppq_credits(&qp->dpp_q) == 0) - ocrdma_poll_dpp_cq(qp); - if (!qp->dpp_cq || ocrdma_dppq_credits(&qp->dpp_q)) { - ocrdma_build_dpp_wqe(qp->dpp_q.va, hdr, - ocrdma_get_hdr_len(qp, hdr)); - qp->wqe_wr_id_tbl[qp->sq.head].dpp_wqe = 1; - qp->wqe_wr_id_tbl[qp->sq.head].dpp_wqe_idx = qp->dpp_q.head; - /* if dpp cq is not enabled, we can post - * wqe as soon as we receive and adapter - * takes care of flow control. - */ - if (qp->dpp_cq) - ocrdma_hwq_inc_head(&qp->dpp_q); - } else - qp->wqe_wr_id_tbl[qp->sq.head].dpp_wqe = 0; -} - -/* - * ocrdma_post_send - */ -int ocrdma_post_send(struct ibv_qp *ib_qp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - int status = 0; - struct ocrdma_qp *qp; - struct ocrdma_hdr_wqe *hdr; - - qp = get_ocrdma_qp(ib_qp); - - pthread_spin_lock(&qp->q_lock); - if (qp->state != OCRDMA_QPS_RTS && qp->state != OCRDMA_QPS_SQD) { - pthread_spin_unlock(&qp->q_lock); - *bad_wr = wr; - return EINVAL; - } - - while (wr) { - - if (qp->qp_type == IBV_QPT_UD && (wr->opcode != IBV_WR_SEND && - wr->opcode != IBV_WR_SEND_WITH_IMM)) { - *bad_wr = wr; - status = EINVAL; - break; - } - - if (ocrdma_hwq_free_cnt(&qp->sq) == 0 || - wr->num_sge > qp->sq.max_sges) { - *bad_wr = wr; - status = ENOMEM; - break; - } - hdr = ocrdma_hwq_head(&qp->sq); - hdr->cw = 0; - hdr->total_len = 0; - if (wr->send_flags & IBV_SEND_SIGNALED || qp->signaled) - hdr->cw = (OCRDMA_FLAG_SIG << OCRDMA_WQE_FLAGS_SHIFT); - if (wr->send_flags & IBV_SEND_FENCE) - hdr->cw |= - (OCRDMA_FLAG_FENCE_L << OCRDMA_WQE_FLAGS_SHIFT); - if (wr->send_flags & IBV_SEND_SOLICITED) - hdr->cw |= - (OCRDMA_FLAG_SOLICIT << OCRDMA_WQE_FLAGS_SHIFT); - - qp->wqe_wr_id_tbl[qp->sq.head].wrid = wr->wr_id; - switch (wr->opcode) { - case IBV_WR_SEND_WITH_IMM: - hdr->cw |= (OCRDMA_FLAG_IMM << OCRDMA_WQE_FLAGS_SHIFT); - hdr->immdt = be32toh(wr->imm_data); - SWITCH_FALLTHROUGH; - case IBV_WR_SEND: - hdr->cw |= (OCRDMA_SEND << OCRDMA_WQE_OPCODE_SHIFT); - status = ocrdma_build_send(qp, hdr, wr); - break; - case IBV_WR_RDMA_WRITE_WITH_IMM: - hdr->cw |= (OCRDMA_FLAG_IMM << OCRDMA_WQE_FLAGS_SHIFT); - hdr->immdt = be32toh(wr->imm_data); - SWITCH_FALLTHROUGH; - case IBV_WR_RDMA_WRITE: - hdr->cw |= (OCRDMA_WRITE << OCRDMA_WQE_OPCODE_SHIFT); - status = ocrdma_build_write(qp, hdr, wr); - break; - case IBV_WR_RDMA_READ: - ocrdma_build_read(qp, hdr, wr); - break; - default: - status = EINVAL; - break; - } - if (status) { - *bad_wr = wr; - break; - } - if (wr->send_flags & IBV_SEND_SIGNALED || qp->signaled) - qp->wqe_wr_id_tbl[qp->sq.head].signaled = 1; - else - qp->wqe_wr_id_tbl[qp->sq.head].signaled = 0; - - if (qp->dpp_enabled && (wr->send_flags & IBV_SEND_INLINE)) - ocrdma_post_dpp_wqe(qp, hdr); - - ocrdma_swap_cpu_to_le(hdr, ((hdr->cw >> OCRDMA_WQE_SIZE_SHIFT) & - OCRDMA_WQE_SIZE_MASK) * - OCRDMA_WQE_STRIDE); - - ocrdma_ring_sq_db(qp); - - /* update pointer, counter for next wr */ - ocrdma_hwq_inc_head(&qp->sq); - wr = wr->next; - } - pthread_spin_unlock(&qp->q_lock); - - return status; -} - -static void ocrdma_build_rqe(struct ocrdma_hdr_wqe *rqe, struct ibv_recv_wr *wr, - uint16_t tag) -{ - struct ocrdma_sge *sge; - uint32_t wqe_size; - - if (wr->num_sge) - wqe_size = (wr->num_sge * sizeof(*sge)) + sizeof(*rqe); - else - wqe_size = sizeof(*sge) + sizeof(*rqe); - - rqe->cw = ((wqe_size / OCRDMA_WQE_STRIDE) << OCRDMA_WQE_SIZE_SHIFT); - rqe->cw |= (OCRDMA_FLAG_SIG << OCRDMA_WQE_FLAGS_SHIFT); - rqe->cw |= (OCRDMA_TYPE_LKEY << OCRDMA_WQE_TYPE_SHIFT); - rqe->total_len = 0; - rqe->rsvd_tag = tag; - sge = (struct ocrdma_sge *)(rqe + 1); - ocrdma_build_sges(rqe, sge, wr->num_sge, wr->sg_list); - ocrdma_swap_cpu_to_le(rqe, wqe_size); -} - -/* - * ocrdma_post_recv - */ -int ocrdma_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - int status = 0; - struct ocrdma_qp *qp; - struct ocrdma_hdr_wqe *rqe; - - qp = get_ocrdma_qp(ibqp); - - pthread_spin_lock(&qp->q_lock); - if (qp->state == OCRDMA_QPS_RST || qp->state == OCRDMA_QPS_ERR) { - pthread_spin_unlock(&qp->q_lock); - *bad_wr = wr; - return EINVAL; - } - - while (wr) { - if (ocrdma_hwq_free_cnt(&qp->rq) == 0 || - wr->num_sge > qp->rq.max_sges) { - status = ENOMEM; - *bad_wr = wr; - break; - } - rqe = ocrdma_hwq_head(&qp->rq); - ocrdma_build_rqe(rqe, wr, 0); - qp->rqe_wr_id_tbl[qp->rq.head] = wr->wr_id; - ocrdma_ring_rq_db(qp); - - /* update pointer, counter for next wr */ - ocrdma_hwq_inc_head(&qp->rq); - wr = wr->next; - } - pthread_spin_unlock(&qp->q_lock); - - return status; -} - -static enum ibv_wc_status ocrdma_to_ibwc_err(uint16_t status) -{ - enum ibv_wc_status ibwc_status = IBV_WC_GENERAL_ERR; - switch (status) { - case OCRDMA_CQE_GENERAL_ERR: - ibwc_status = IBV_WC_GENERAL_ERR; - break; - case OCRDMA_CQE_LOC_LEN_ERR: - ibwc_status = IBV_WC_LOC_LEN_ERR; - break; - case OCRDMA_CQE_LOC_QP_OP_ERR: - ibwc_status = IBV_WC_LOC_QP_OP_ERR; - break; - case OCRDMA_CQE_LOC_EEC_OP_ERR: - ibwc_status = IBV_WC_LOC_EEC_OP_ERR; - break; - case OCRDMA_CQE_LOC_PROT_ERR: - ibwc_status = IBV_WC_LOC_PROT_ERR; - break; - case OCRDMA_CQE_WR_FLUSH_ERR: - ibwc_status = IBV_WC_WR_FLUSH_ERR; - break; - case OCRDMA_CQE_BAD_RESP_ERR: - ibwc_status = IBV_WC_BAD_RESP_ERR; - break; - case OCRDMA_CQE_LOC_ACCESS_ERR: - ibwc_status = IBV_WC_LOC_ACCESS_ERR; - break; - case OCRDMA_CQE_REM_INV_REQ_ERR: - ibwc_status = IBV_WC_REM_INV_REQ_ERR; - break; - case OCRDMA_CQE_REM_ACCESS_ERR: - ibwc_status = IBV_WC_REM_ACCESS_ERR; - break; - case OCRDMA_CQE_REM_OP_ERR: - ibwc_status = IBV_WC_REM_OP_ERR; - break; - case OCRDMA_CQE_RETRY_EXC_ERR: - ibwc_status = IBV_WC_RETRY_EXC_ERR; - break; - case OCRDMA_CQE_RNR_RETRY_EXC_ERR: - ibwc_status = IBV_WC_RNR_RETRY_EXC_ERR; - break; - case OCRDMA_CQE_LOC_RDD_VIOL_ERR: - ibwc_status = IBV_WC_LOC_RDD_VIOL_ERR; - break; - case OCRDMA_CQE_REM_INV_RD_REQ_ERR: - ibwc_status = IBV_WC_REM_INV_RD_REQ_ERR; - break; - case OCRDMA_CQE_REM_ABORT_ERR: - ibwc_status = IBV_WC_REM_ABORT_ERR; - break; - case OCRDMA_CQE_INV_EECN_ERR: - ibwc_status = IBV_WC_INV_EECN_ERR; - break; - case OCRDMA_CQE_INV_EEC_STATE_ERR: - ibwc_status = IBV_WC_INV_EEC_STATE_ERR; - break; - case OCRDMA_CQE_FATAL_ERR: - ibwc_status = IBV_WC_FATAL_ERR; - break; - case OCRDMA_CQE_RESP_TIMEOUT_ERR: - ibwc_status = IBV_WC_RESP_TIMEOUT_ERR; - break; - default: - ibwc_status = IBV_WC_GENERAL_ERR; - break; - }; - return ibwc_status; -} - -static void ocrdma_update_wc(struct ocrdma_qp *qp, struct ibv_wc *ibwc, - uint32_t wqe_idx) -{ - struct ocrdma_hdr_wqe_le *hdr; - struct ocrdma_sge *rw; - int opcode; - - hdr = ocrdma_hwq_head_from_idx(&qp->sq, wqe_idx); - - ibwc->wr_id = qp->wqe_wr_id_tbl[wqe_idx].wrid; - - /* Undo the hdr->cw swap */ - opcode = le32toh(hdr->cw) & OCRDMA_WQE_OPCODE_MASK; - switch (opcode) { - case OCRDMA_WRITE: - ibwc->opcode = IBV_WC_RDMA_WRITE; - break; - case OCRDMA_READ: - rw = (struct ocrdma_sge *)(hdr + 1); - ibwc->opcode = IBV_WC_RDMA_READ; - ibwc->byte_len = rw->len; - break; - case OCRDMA_SEND: - ibwc->opcode = IBV_WC_SEND; - break; - default: - ibwc->status = IBV_WC_GENERAL_ERR; - ocrdma_err("%s() invalid opcode received = 0x%x\n", - __func__, le32toh(hdr->cw) & OCRDMA_WQE_OPCODE_MASK); - break; - }; -} - -static void ocrdma_set_cqe_status_flushed(struct ocrdma_qp *qp, - struct ocrdma_cqe *cqe) -{ - if (is_cqe_for_sq(cqe)) { - cqe->flags_status_srcqpn = - htole32(le32toh(cqe->flags_status_srcqpn) - & ~OCRDMA_CQE_STATUS_MASK); - cqe->flags_status_srcqpn = - htole32(le32toh(cqe->flags_status_srcqpn) - | (OCRDMA_CQE_WR_FLUSH_ERR << - OCRDMA_CQE_STATUS_SHIFT)); - } else { - if (qp->qp_type == IBV_QPT_UD) { - cqe->flags_status_srcqpn = - htole32(le32toh - (cqe->flags_status_srcqpn) & - ~OCRDMA_CQE_UD_STATUS_MASK); - cqe->flags_status_srcqpn = - htole32(le32toh - (cqe->flags_status_srcqpn) | - (OCRDMA_CQE_WR_FLUSH_ERR << - OCRDMA_CQE_UD_STATUS_SHIFT)); - } else { - cqe->flags_status_srcqpn = - htole32(le32toh - (cqe->flags_status_srcqpn) & - ~OCRDMA_CQE_STATUS_MASK); - cqe->flags_status_srcqpn = - htole32(le32toh - (cqe->flags_status_srcqpn) | - (OCRDMA_CQE_WR_FLUSH_ERR << - OCRDMA_CQE_STATUS_SHIFT)); - } - } -} - -static int ocrdma_update_err_cqe(struct ibv_wc *ibwc, struct ocrdma_cqe *cqe, - struct ocrdma_qp *qp, int status) -{ - int expand = 0; - - ibwc->byte_len = 0; - ibwc->qp_num = qp->id; - ibwc->status = ocrdma_to_ibwc_err(status); - - ocrdma_flush_qp(qp); - ocrdma_qp_state_machine(qp, IBV_QPS_ERR); - - /* if wqe/rqe pending for which cqe needs to be returned, - * trigger inflating it. - */ - if (!is_hw_rq_empty(qp) || !is_hw_sq_empty(qp)) { - expand = 1; - ocrdma_set_cqe_status_flushed(qp, cqe); - } - return expand; -} - -static int ocrdma_update_err_rcqe(struct ibv_wc *ibwc, struct ocrdma_cqe *cqe, - struct ocrdma_qp *qp, int status) -{ - ibwc->opcode = IBV_WC_RECV; - ibwc->wr_id = qp->rqe_wr_id_tbl[qp->rq.tail]; - ocrdma_hwq_inc_tail(&qp->rq); - - return ocrdma_update_err_cqe(ibwc, cqe, qp, status); -} - -static int ocrdma_update_err_scqe(struct ibv_wc *ibwc, struct ocrdma_cqe *cqe, - struct ocrdma_qp *qp, int status) -{ - ocrdma_update_wc(qp, ibwc, qp->sq.tail); - ocrdma_hwq_inc_tail(&qp->sq); - - return ocrdma_update_err_cqe(ibwc, cqe, qp, status); -} - -static int ocrdma_poll_err_scqe(struct ocrdma_qp *qp, - struct ocrdma_cqe *cqe, struct ibv_wc *ibwc, - int *polled, int *stop) -{ - int expand; - int status = (le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_STATUS_MASK) >> OCRDMA_CQE_STATUS_SHIFT; - - /* when hw sq is empty, but rq is not empty, so we continue - * to keep the cqe in order to get the cq event again. - */ - if (is_hw_sq_empty(qp) && !is_hw_rq_empty(qp)) { - /* when cq for rq and sq is same, it is safe to return - * flush cqe for RQEs. - */ - if (!qp->srq && (qp->sq_cq == qp->rq_cq)) { - *polled = 1; - status = OCRDMA_CQE_WR_FLUSH_ERR; - expand = ocrdma_update_err_rcqe(ibwc, cqe, qp, status); - } else { - *polled = 0; - *stop = 1; - expand = 0; - } - } else if (is_hw_sq_empty(qp)) { - /* Do nothing */ - expand = 0; - *polled = 0; - *stop = 0; - } else { - *polled = 1; - expand = ocrdma_update_err_scqe(ibwc, cqe, qp, status); - } - return expand; -} - -static int ocrdma_poll_success_scqe(struct ocrdma_qp *qp, - struct ocrdma_cqe *cqe, - struct ibv_wc *ibwc, int *polled) -{ - int expand = 0; - int tail = qp->sq.tail; - uint32_t wqe_idx; - - if (!qp->wqe_wr_id_tbl[tail].signaled) { - *polled = 0; /* WC cannot be consumed yet */ - } else { - ibwc->status = IBV_WC_SUCCESS; - ibwc->wc_flags = 0; - ibwc->qp_num = qp->id; - ocrdma_update_wc(qp, ibwc, tail); - *polled = 1; - } - - wqe_idx = (le32toh(cqe->wq.wqeidx) & - OCRDMA_CQE_WQEIDX_MASK) & qp->sq.max_wqe_idx; - if (tail != wqe_idx) /* CQE cannot be consumed yet */ - expand = 1; /* Coallesced CQE */ - - ocrdma_hwq_inc_tail(&qp->sq); - return expand; -} - -static int ocrdma_poll_scqe(struct ocrdma_qp *qp, struct ocrdma_cqe *cqe, - struct ibv_wc *ibwc, int *polled, int *stop) -{ - int status, expand; - - status = (le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_STATUS_MASK) >> OCRDMA_CQE_STATUS_SHIFT; - - if (status == OCRDMA_CQE_SUCCESS) - expand = ocrdma_poll_success_scqe(qp, cqe, ibwc, polled); - else - expand = ocrdma_poll_err_scqe(qp, cqe, ibwc, polled, stop); - return expand; -} - -static int ocrdma_update_ud_rcqe(struct ibv_wc *ibwc, struct ocrdma_cqe *cqe) -{ - int status; - - status = (le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_UD_STATUS_MASK) >> OCRDMA_CQE_UD_STATUS_SHIFT; - ibwc->src_qp = le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_SRCQP_MASK; - ibwc->pkey_index = le32toh(cqe->ud.rxlen_pkey) & - OCRDMA_CQE_PKEY_MASK; - ibwc->wc_flags = IBV_WC_GRH; - ibwc->byte_len = (le32toh(cqe->ud.rxlen_pkey) >> - OCRDMA_CQE_UD_XFER_LEN_SHIFT); - return status; -} - -static void ocrdma_update_free_srq_cqe(struct ibv_wc *ibwc, - struct ocrdma_cqe *cqe, - struct ocrdma_qp *qp) -{ - struct ocrdma_srq *srq = NULL; - uint32_t wqe_idx; - - srq = get_ocrdma_srq(qp->ibv_qp.srq); -#if !defined(SKH_A0_WORKAROUND) /* BUG 113416 */ - wqe_idx = (le32toh(cqe->rq.buftag_qpn) >> - OCRDMA_CQE_BUFTAG_SHIFT) & srq->rq.max_wqe_idx; -#else - wqe_idx = (le32toh(cqe->flags_status_srcqpn)) & 0xFFFF; -#endif - if (wqe_idx < 1) - assert(0); - ibwc->wr_id = srq->rqe_wr_id_tbl[wqe_idx]; - - pthread_spin_lock(&srq->q_lock); - ocrdma_srq_toggle_bit(srq, wqe_idx - 1); - pthread_spin_unlock(&srq->q_lock); - - ocrdma_hwq_inc_tail(&srq->rq); -} - -static int ocrdma_poll_err_rcqe(struct ocrdma_qp *qp, struct ocrdma_cqe *cqe, - struct ibv_wc *ibwc, int *polled, int *stop, - int status) -{ - int expand; - - /* when hw_rq is empty, but wq is not empty, so continue - * to keep the cqe to get the cq event again. - */ - if (is_hw_rq_empty(qp) && !is_hw_sq_empty(qp)) { - if (!qp->srq && (qp->sq_cq == qp->rq_cq)) { - *polled = 1; - status = OCRDMA_CQE_WR_FLUSH_ERR; - expand = ocrdma_update_err_scqe(ibwc, cqe, qp, status); - } else { - *polled = 0; - *stop = 1; - expand = 0; - } - } else if (is_hw_rq_empty(qp)) { - /* Do nothing */ - expand = 0; - *polled = 0; - *stop = 0; - } else { - *polled = 1; - expand = ocrdma_update_err_rcqe(ibwc, cqe, qp, status); - } - return expand; -} - -static void ocrdma_poll_success_rcqe(struct ocrdma_qp *qp, - struct ocrdma_cqe *cqe, - struct ibv_wc *ibwc) -{ - ibwc->opcode = IBV_WC_RECV; - ibwc->qp_num = qp->id; - ibwc->status = IBV_WC_SUCCESS; - - if (qp->qp_type == IBV_QPT_UD) - ocrdma_update_ud_rcqe(ibwc, cqe); - else - ibwc->byte_len = le32toh(cqe->rq.rxlen); - - if (is_cqe_imm(cqe)) { - ibwc->imm_data = htobe32(le32toh(cqe->rq.lkey_immdt)); - ibwc->wc_flags |= IBV_WC_WITH_IMM; - } else if (is_cqe_wr_imm(cqe)) { - ibwc->opcode = IBV_WC_RECV_RDMA_WITH_IMM; - ibwc->imm_data = htobe32(le32toh(cqe->rq.lkey_immdt)); - ibwc->wc_flags |= IBV_WC_WITH_IMM; - } - if (qp->ibv_qp.srq) - ocrdma_update_free_srq_cqe(ibwc, cqe, qp); - else { - ibwc->wr_id = qp->rqe_wr_id_tbl[qp->rq.tail]; - ocrdma_hwq_inc_tail(&qp->rq); - } -} - -static int ocrdma_poll_rcqe(struct ocrdma_qp *qp, struct ocrdma_cqe *cqe, - struct ibv_wc *ibwc, int *polled, int *stop) -{ - int status; - int expand = 0; - - ibwc->wc_flags = 0; - if (qp->qp_type == IBV_QPT_UD) - status = (le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_UD_STATUS_MASK) >> - OCRDMA_CQE_UD_STATUS_SHIFT; - else - status = (le32toh(cqe->flags_status_srcqpn) & - OCRDMA_CQE_STATUS_MASK) >> OCRDMA_CQE_STATUS_SHIFT; - - if (status == OCRDMA_CQE_SUCCESS) { - *polled = 1; - ocrdma_poll_success_rcqe(qp, cqe, ibwc); - } else { - expand = ocrdma_poll_err_rcqe(qp, cqe, ibwc, polled, stop, - status); - } - return expand; -} - -static void ocrdma_change_cq_phase(struct ocrdma_cq *cq, - struct ocrdma_cqe *cqe, uint16_t cur_getp) -{ - if (cq->phase_change) { - if (cur_getp == 0) - cq->phase = (~cq->phase & OCRDMA_CQE_VALID); - } else - cqe->flags_status_srcqpn = 0; /* clear valid bit */ -} - -static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries, - struct ibv_wc *ibwc) -{ - uint16_t qpn = 0; - int i = 0; - int expand = 0; - int polled_hw_cqes = 0; - struct ocrdma_qp *qp = NULL; - struct ocrdma_device *dev = cq->dev; - struct ocrdma_cqe *cqe; - uint16_t cur_getp; - int polled = 0; - int stop = 0; - - cur_getp = cq->getp; - while (num_entries) { - cqe = cq->va + cur_getp; - /* check whether valid cqe or not */ - if (!is_cqe_valid(cq, cqe)) - break; - qpn = (le32toh(cqe->cmn.qpn) & OCRDMA_CQE_QPN_MASK); - /* ignore discarded cqe */ - if (qpn == 0) - goto skip_cqe; - qp = dev->qp_tbl[qpn]; - if (qp == NULL) { - ocrdma_err("%s() cqe for invalid qpn= 0x%x received.\n", - __func__, qpn); - goto skip_cqe; - } - - if (is_cqe_for_sq(cqe)) { - expand = ocrdma_poll_scqe(qp, cqe, ibwc, &polled, - &stop); - } else { - expand = ocrdma_poll_rcqe(qp, cqe, ibwc, &polled, - &stop); - } - if (expand) - goto expand_cqe; - if (stop) - goto stop_cqe; - /* clear qpn to avoid duplicate processing by discard_cqe() */ - cqe->cmn.qpn = 0; -skip_cqe: - polled_hw_cqes += 1; - cur_getp = (cur_getp + 1) % cq->max_hw_cqe; - ocrdma_change_cq_phase(cq, cqe, cur_getp); -expand_cqe: - if (polled) { - num_entries -= 1; - i += 1; - ibwc = ibwc + 1; - polled = 0; - } - } -stop_cqe: - cq->getp = cur_getp; - if (cq->deferred_arm || polled_hw_cqes) { - ocrdma_ring_cq_db(cq, cq->deferred_arm, - cq->deferred_sol, polled_hw_cqes); - cq->deferred_arm = 0; - cq->deferred_sol = 0; - } - - return i; -} - -static int ocrdma_add_err_cqe(struct ocrdma_cq *cq, int num_entries, - struct ocrdma_qp *qp, struct ibv_wc *ibwc) -{ - int err_cqes = 0; - - while (num_entries) { - if (is_hw_sq_empty(qp) && is_hw_rq_empty(qp)) - break; - if (!is_hw_sq_empty(qp) && qp->sq_cq == cq) { - ocrdma_update_wc(qp, ibwc, qp->sq.tail); - ocrdma_hwq_inc_tail(&qp->sq); - } else if (!is_hw_rq_empty(qp) && qp->rq_cq == cq) { - ibwc->wr_id = qp->rqe_wr_id_tbl[qp->rq.tail]; - ocrdma_hwq_inc_tail(&qp->rq); - } else - return err_cqes; - ibwc->byte_len = 0; - ibwc->status = IBV_WC_WR_FLUSH_ERR; - ibwc = ibwc + 1; - err_cqes += 1; - num_entries -= 1; - } - return err_cqes; -} - -/* - * ocrdma_poll_cq - */ -int ocrdma_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc) -{ - struct ocrdma_cq *cq; - int cqes_to_poll = num_entries; - int num_os_cqe = 0, err_cqes = 0; - struct ocrdma_qp *qp; - struct ocrdma_qp *qp_tmp; - - cq = get_ocrdma_cq(ibcq); - pthread_spin_lock(&cq->cq_lock); - num_os_cqe = ocrdma_poll_hwcq(cq, num_entries, wc); - pthread_spin_unlock(&cq->cq_lock); - cqes_to_poll -= num_os_cqe; - - if (cqes_to_poll) { - wc = wc + num_os_cqe; - pthread_spin_lock(&cq->dev->flush_q_lock); - list_for_each_safe(&cq->sq_head, qp, qp_tmp, sq_entry) { - if (cqes_to_poll == 0) - break; - err_cqes = ocrdma_add_err_cqe(cq, cqes_to_poll, qp, wc); - cqes_to_poll -= err_cqes; - num_os_cqe += err_cqes; - wc = wc + err_cqes; - } - pthread_spin_unlock(&cq->dev->flush_q_lock); - } - return num_os_cqe; -} - -/* - * ocrdma_arm_cq - */ -int ocrdma_arm_cq(struct ibv_cq *ibcq, int solicited) -{ - struct ocrdma_cq *cq; - - cq = get_ocrdma_cq(ibcq); - pthread_spin_lock(&cq->cq_lock); - - if (cq->first_arm) { - ocrdma_ring_cq_db(cq, 1, solicited, 0); - cq->first_arm = 0; - } - - cq->deferred_arm = 1; - cq->deferred_sol = solicited; - - pthread_spin_unlock(&cq->cq_lock); - - return 0; -} - -/* - * ocrdma_post_srq_recv - */ -int ocrdma_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - int status = 0; - uint16_t tag; - struct ocrdma_srq *srq; - struct ocrdma_hdr_wqe *rqe; - - srq = get_ocrdma_srq(ibsrq); - pthread_spin_lock(&srq->q_lock); - while (wr) { - if (ocrdma_hwq_free_cnt(&srq->rq) == 0 || - wr->num_sge > srq->rq.max_sges) { - status = ENOMEM; - *bad_wr = wr; - break; - } - rqe = ocrdma_hwq_head(&srq->rq); - tag = ocrdma_srq_get_idx(srq); - ocrdma_build_rqe(rqe, wr, tag); - srq->rqe_wr_id_tbl[tag] = wr->wr_id; - - ocrdma_ring_srq_db(srq); - - /* update pointer, counter for next wr */ - ocrdma_hwq_inc_head(&srq->rq); - wr = wr->next; - } - pthread_spin_unlock(&srq->q_lock); - return status; -} - -/* - * ocrdma_create_ah - */ -struct ibv_ah *ocrdma_create_ah(struct ibv_pd *ibpd, struct ibv_ah_attr *attr) -{ - int status; - int ahtbl_idx; - struct ocrdma_pd *pd; - struct ocrdma_ah *ah; - struct ibv_create_ah_resp resp; - - pd = get_ocrdma_pd(ibpd); - ah = malloc(sizeof *ah); - if (!ah) - return NULL; - bzero(ah, sizeof *ah); - ah->pd = pd; - - ahtbl_idx = ocrdma_alloc_ah_tbl_id(pd->uctx); - if (ahtbl_idx < 0) - goto tbl_err; - attr->dlid = ahtbl_idx; - memset(&resp, 0, sizeof(resp)); - status = ibv_cmd_create_ah(ibpd, &ah->ibv_ah, attr, &resp, sizeof(resp)); - if (status) - goto cmd_err; - - ah->id = pd->uctx->ah_tbl[ahtbl_idx] & OCRDMA_AH_ID_MASK; - ah->isvlan = (pd->uctx->ah_tbl[ahtbl_idx] >> - OCRDMA_AH_VLAN_VALID_SHIFT); - ah->hdr_type = ((pd->uctx->ah_tbl[ahtbl_idx] >> OCRDMA_AH_L3_TYPE_SHIFT) - & OCRDMA_AH_L3_TYPE_MASK); - - return &ah->ibv_ah; -cmd_err: - ocrdma_free_ah_tbl_id(pd->uctx, ahtbl_idx); -tbl_err: - free(ah); - return NULL; -} - -/* - * ocrdma_destroy_ah - */ -int ocrdma_destroy_ah(struct ibv_ah *ibah) -{ - int status; - struct ocrdma_ah *ah; - - ah = get_ocrdma_ah(ibah); - - status = ibv_cmd_destroy_ah(ibah); - ocrdma_free_ah_tbl_id(ah->pd->uctx, ah->id); - free(ah); - return status; -} - -/* - * ocrdma_attach_mcast - */ -int ocrdma_attach_mcast(struct ibv_qp *ibqp, const union ibv_gid *gid, - uint16_t lid) -{ - return ibv_cmd_attach_mcast(ibqp, gid, lid); -} - -/* - * ocrdma_detach_mcast - */ -int ocrdma_detach_mcast(struct ibv_qp *ibqp, const union ibv_gid *gid, - uint16_t lid) -{ - return ibv_cmd_detach_mcast(ibqp, gid, lid); -} diff --git a/usr/rdma-core/providers/qedr/CMakeLists.txt b/usr/rdma-core/providers/qedr/CMakeLists.txt deleted file mode 100644 index 8d4f3cee6..000000000 --- a/usr/rdma-core/providers/qedr/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -rdma_provider(qedr - qelr_main.c - qelr_verbs.c - qelr_chain.c - ) diff --git a/usr/rdma-core/providers/qedr/common_hsi.h b/usr/rdma-core/providers/qedr/common_hsi.h deleted file mode 100644 index 791006b0e..000000000 --- a/usr/rdma-core/providers/qedr/common_hsi.h +++ /dev/null @@ -1,1506 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __COMMON_HSI__ -#define __COMMON_HSI__ - -#include -#include - -/********************************/ -/* PROTOCOL COMMON FW CONSTANTS */ -/********************************/ - -/* Temporarily here should be added to HSI automatically by resource allocation tool.*/ -#define T_TEST_AGG_INT_TEMP 6 -#define M_TEST_AGG_INT_TEMP 8 -#define U_TEST_AGG_INT_TEMP 6 -#define X_TEST_AGG_INT_TEMP 14 -#define Y_TEST_AGG_INT_TEMP 4 -#define P_TEST_AGG_INT_TEMP 4 - -#define X_FINAL_CLEANUP_AGG_INT 1 - -#define EVENT_RING_PAGE_SIZE_BYTES 4096 - -#define NUM_OF_GLOBAL_QUEUES 128 -#define COMMON_QUEUE_ENTRY_MAX_BYTE_SIZE 64 - -#define ISCSI_CDU_TASK_SEG_TYPE 0 -#define FCOE_CDU_TASK_SEG_TYPE 0 -#define RDMA_CDU_TASK_SEG_TYPE 1 - -#define FW_ASSERT_GENERAL_ATTN_IDX 32 - -#define MAX_PINNED_CCFC 32 - -#define EAGLE_ENG1_WORKAROUND_NIG_FLOWCTRL_MODE 3 - -/* Queue Zone sizes in bytes */ -#define TSTORM_QZONE_SIZE 8 /*tstorm_scsi_queue_zone*/ -#define MSTORM_QZONE_SIZE 16 /*mstorm_eth_queue_zone. Used only for RX producer of VFs in backward compatibility mode.*/ -#define USTORM_QZONE_SIZE 8 /*ustorm_eth_queue_zone*/ -#define XSTORM_QZONE_SIZE 8 /*xstorm_eth_queue_zone*/ -#define YSTORM_QZONE_SIZE 0 -#define PSTORM_QZONE_SIZE 0 - -#define MSTORM_VF_ZONE_DEFAULT_SIZE_LOG 7 /*Log of mstorm default VF zone size.*/ -#define ETH_MAX_NUM_RX_QUEUES_PER_VF_DEFAULT 16 /*Maximum number of RX queues that can be allocated to VF by default*/ -#define ETH_MAX_NUM_RX_QUEUES_PER_VF_DOUBLE 48 /*Maximum number of RX queues that can be allocated to VF with doubled VF zone size. Up to 96 VF supported in this mode*/ -#define ETH_MAX_NUM_RX_QUEUES_PER_VF_QUAD 112 /*Maximum number of RX queues that can be allocated to VF with 4 VF zone size. Up to 48 VF supported in this mode*/ - - -/********************************/ -/* CORE (LIGHT L2) FW CONSTANTS */ -/********************************/ - -#define CORE_LL2_MAX_RAMROD_PER_CON 8 -#define CORE_LL2_TX_BD_PAGE_SIZE_BYTES 4096 -#define CORE_LL2_RX_BD_PAGE_SIZE_BYTES 4096 -#define CORE_LL2_RX_CQE_PAGE_SIZE_BYTES 4096 -#define CORE_LL2_RX_NUM_NEXT_PAGE_BDS 1 - -#define CORE_LL2_TX_MAX_BDS_PER_PACKET 12 - -#define CORE_SPQE_PAGE_SIZE_BYTES 4096 - -#define MAX_NUM_LL2_RX_QUEUES 32 -#define MAX_NUM_LL2_TX_STATS_COUNTERS 32 - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Include firmware verison number only- do not add constants here to avoid redundunt compilations -/////////////////////////////////////////////////////////////////////////////////////////////////// - - -#define FW_MAJOR_VERSION 8 -#define FW_MINOR_VERSION 10 -#define FW_REVISION_VERSION 9 -#define FW_ENGINEERING_VERSION 0 - -/***********************/ -/* COMMON HW CONSTANTS */ -/***********************/ - -/* PCI functions */ -#define MAX_NUM_PORTS_K2 (4) -#define MAX_NUM_PORTS_BB (2) -#define MAX_NUM_PORTS (MAX_NUM_PORTS_K2) - -#define MAX_NUM_PFS_K2 (16) -#define MAX_NUM_PFS_BB (8) -#define MAX_NUM_PFS (MAX_NUM_PFS_K2) -#define MAX_NUM_OF_PFS_IN_CHIP (16) /* On both engines */ - -#define MAX_NUM_VFS_K2 (192) -#define MAX_NUM_VFS_BB (120) -#define MAX_NUM_VFS (MAX_NUM_VFS_K2) - -#define MAX_NUM_FUNCTIONS_BB (MAX_NUM_PFS_BB + MAX_NUM_VFS_BB) -#define MAX_NUM_FUNCTIONS_K2 (MAX_NUM_PFS_K2 + MAX_NUM_VFS_K2) -#define MAX_NUM_FUNCTIONS (MAX_NUM_PFS + MAX_NUM_VFS) - -/* in both BB and K2, the VF number starts from 16. so for arrays containing all */ -/* possible PFs and VFs - we need a constant for this size */ -#define MAX_FUNCTION_NUMBER_BB (MAX_NUM_PFS + MAX_NUM_VFS_BB) -#define MAX_FUNCTION_NUMBER_K2 (MAX_NUM_PFS + MAX_NUM_VFS_K2) -#define MAX_FUNCTION_NUMBER (MAX_NUM_PFS + MAX_NUM_VFS) - -#define MAX_NUM_VPORTS_K2 (208) -#define MAX_NUM_VPORTS_BB (160) -#define MAX_NUM_VPORTS (MAX_NUM_VPORTS_K2) - -#define MAX_NUM_L2_QUEUES_K2 (320) -#define MAX_NUM_L2_QUEUES_BB (256) -#define MAX_NUM_L2_QUEUES (MAX_NUM_L2_QUEUES_K2) - -/* Traffic classes in network-facing blocks (PBF, BTB, NIG, BRB, PRS and QM) */ -// 4-Port K2. -#define NUM_PHYS_TCS_4PORT_K2 (4) -#define NUM_OF_PHYS_TCS (8) - -#define NUM_TCS_4PORT_K2 (NUM_PHYS_TCS_4PORT_K2 + 1) -#define NUM_OF_TCS (NUM_OF_PHYS_TCS + 1) - -#define LB_TC (NUM_OF_PHYS_TCS) - -/* Num of possible traffic priority values */ -#define NUM_OF_PRIO (8) - -#define MAX_NUM_VOQS_K2 (NUM_TCS_4PORT_K2 * MAX_NUM_PORTS_K2) -#define MAX_NUM_VOQS_BB (NUM_OF_TCS * MAX_NUM_PORTS_BB) -#define MAX_NUM_VOQS (MAX_NUM_VOQS_K2) -#define MAX_PHYS_VOQS (NUM_OF_PHYS_TCS * MAX_NUM_PORTS_BB) - -/* CIDs */ -#define NUM_OF_CONNECTION_TYPES (8) -#define NUM_OF_LCIDS (320) -#define NUM_OF_LTIDS (320) - -/* Clock values */ -#define MASTER_CLK_FREQ_E4 (375e6) -#define STORM_CLK_FREQ_E4 (1000e6) -#define CLK25M_CLK_FREQ_E4 (25e6) - -/* Global PXP windows (GTT) */ -#define NUM_OF_GTT 19 -#define GTT_DWORD_SIZE_BITS 10 -#define GTT_BYTE_SIZE_BITS (GTT_DWORD_SIZE_BITS + 2) -#define GTT_DWORD_SIZE (1 << GTT_DWORD_SIZE_BITS) - -/* Tools Version */ -#define TOOLS_VERSION 10 -/*****************/ -/* CDU CONSTANTS */ -/*****************/ - -#define CDU_SEG_TYPE_OFFSET_REG_TYPE_SHIFT (17) -#define CDU_SEG_TYPE_OFFSET_REG_OFFSET_MASK (0x1ffff) - -#define CDU_VF_FL_SEG_TYPE_OFFSET_REG_TYPE_SHIFT (12) -#define CDU_VF_FL_SEG_TYPE_OFFSET_REG_OFFSET_MASK (0xfff) - - -/*****************/ -/* DQ CONSTANTS */ -/*****************/ - -/* DEMS */ -#define DQ_DEMS_LEGACY 0 -#define DQ_DEMS_TOE_MORE_TO_SEND 3 -#define DQ_DEMS_TOE_LOCAL_ADV_WND 4 -#define DQ_DEMS_ROCE_CQ_CONS 7 - -/* XCM agg val selection (HW) */ -#define DQ_XCM_AGG_VAL_SEL_WORD2 0 -#define DQ_XCM_AGG_VAL_SEL_WORD3 1 -#define DQ_XCM_AGG_VAL_SEL_WORD4 2 -#define DQ_XCM_AGG_VAL_SEL_WORD5 3 -#define DQ_XCM_AGG_VAL_SEL_REG3 4 -#define DQ_XCM_AGG_VAL_SEL_REG4 5 -#define DQ_XCM_AGG_VAL_SEL_REG5 6 -#define DQ_XCM_AGG_VAL_SEL_REG6 7 - -/* XCM agg val selection (FW) */ -#define DQ_XCM_CORE_TX_BD_CONS_CMD DQ_XCM_AGG_VAL_SEL_WORD3 -#define DQ_XCM_CORE_TX_BD_PROD_CMD DQ_XCM_AGG_VAL_SEL_WORD4 -#define DQ_XCM_CORE_SPQ_PROD_CMD DQ_XCM_AGG_VAL_SEL_WORD4 -#define DQ_XCM_ETH_EDPM_NUM_BDS_CMD DQ_XCM_AGG_VAL_SEL_WORD2 -#define DQ_XCM_ETH_TX_BD_CONS_CMD DQ_XCM_AGG_VAL_SEL_WORD3 -#define DQ_XCM_ETH_TX_BD_PROD_CMD DQ_XCM_AGG_VAL_SEL_WORD4 -#define DQ_XCM_ETH_GO_TO_BD_CONS_CMD DQ_XCM_AGG_VAL_SEL_WORD5 -#define DQ_XCM_FCOE_SQ_CONS_CMD DQ_XCM_AGG_VAL_SEL_WORD3 -#define DQ_XCM_FCOE_SQ_PROD_CMD DQ_XCM_AGG_VAL_SEL_WORD4 -#define DQ_XCM_FCOE_X_FERQ_PROD_CMD DQ_XCM_AGG_VAL_SEL_WORD5 -#define DQ_XCM_ISCSI_SQ_CONS_CMD DQ_XCM_AGG_VAL_SEL_WORD3 -#define DQ_XCM_ISCSI_SQ_PROD_CMD DQ_XCM_AGG_VAL_SEL_WORD4 -#define DQ_XCM_ISCSI_MORE_TO_SEND_SEQ_CMD DQ_XCM_AGG_VAL_SEL_REG3 -#define DQ_XCM_ISCSI_EXP_STAT_SN_CMD DQ_XCM_AGG_VAL_SEL_REG6 -#define DQ_XCM_ROCE_SQ_PROD_CMD DQ_XCM_AGG_VAL_SEL_WORD4 -#define DQ_XCM_TOE_TX_BD_PROD_CMD DQ_XCM_AGG_VAL_SEL_WORD4 -#define DQ_XCM_TOE_MORE_TO_SEND_SEQ_CMD DQ_XCM_AGG_VAL_SEL_REG3 -#define DQ_XCM_TOE_LOCAL_ADV_WND_SEQ_CMD DQ_XCM_AGG_VAL_SEL_REG4 - -/* UCM agg val selection (HW) */ -#define DQ_UCM_AGG_VAL_SEL_WORD0 0 -#define DQ_UCM_AGG_VAL_SEL_WORD1 1 -#define DQ_UCM_AGG_VAL_SEL_WORD2 2 -#define DQ_UCM_AGG_VAL_SEL_WORD3 3 -#define DQ_UCM_AGG_VAL_SEL_REG0 4 -#define DQ_UCM_AGG_VAL_SEL_REG1 5 -#define DQ_UCM_AGG_VAL_SEL_REG2 6 -#define DQ_UCM_AGG_VAL_SEL_REG3 7 - -/* UCM agg val selection (FW) */ -#define DQ_UCM_ETH_PMD_TX_CONS_CMD DQ_UCM_AGG_VAL_SEL_WORD2 -#define DQ_UCM_ETH_PMD_RX_CONS_CMD DQ_UCM_AGG_VAL_SEL_WORD3 -#define DQ_UCM_ROCE_CQ_CONS_CMD DQ_UCM_AGG_VAL_SEL_REG0 -#define DQ_UCM_ROCE_CQ_PROD_CMD DQ_UCM_AGG_VAL_SEL_REG2 - -/* TCM agg val selection (HW) */ -#define DQ_TCM_AGG_VAL_SEL_WORD0 0 -#define DQ_TCM_AGG_VAL_SEL_WORD1 1 -#define DQ_TCM_AGG_VAL_SEL_WORD2 2 -#define DQ_TCM_AGG_VAL_SEL_WORD3 3 -#define DQ_TCM_AGG_VAL_SEL_REG1 4 -#define DQ_TCM_AGG_VAL_SEL_REG2 5 -#define DQ_TCM_AGG_VAL_SEL_REG6 6 -#define DQ_TCM_AGG_VAL_SEL_REG9 7 - -/* TCM agg val selection (FW) */ -#define DQ_TCM_L2B_BD_PROD_CMD DQ_TCM_AGG_VAL_SEL_WORD1 -#define DQ_TCM_ROCE_RQ_PROD_CMD DQ_TCM_AGG_VAL_SEL_WORD0 - -/* XCM agg counter flag selection (HW) */ -#define DQ_XCM_AGG_FLG_SHIFT_BIT14 0 -#define DQ_XCM_AGG_FLG_SHIFT_BIT15 1 -#define DQ_XCM_AGG_FLG_SHIFT_CF12 2 -#define DQ_XCM_AGG_FLG_SHIFT_CF13 3 -#define DQ_XCM_AGG_FLG_SHIFT_CF18 4 -#define DQ_XCM_AGG_FLG_SHIFT_CF19 5 -#define DQ_XCM_AGG_FLG_SHIFT_CF22 6 -#define DQ_XCM_AGG_FLG_SHIFT_CF23 7 - -/* XCM agg counter flag selection (FW) */ -#define DQ_XCM_CORE_DQ_CF_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF18) -#define DQ_XCM_CORE_TERMINATE_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF19) -#define DQ_XCM_CORE_SLOW_PATH_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF22) -#define DQ_XCM_ETH_DQ_CF_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF18) -#define DQ_XCM_ETH_TERMINATE_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF19) -#define DQ_XCM_ETH_SLOW_PATH_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF22) -#define DQ_XCM_ETH_TPH_EN_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF23) -#define DQ_XCM_FCOE_SLOW_PATH_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF22) -#define DQ_XCM_ISCSI_DQ_FLUSH_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF19) -#define DQ_XCM_ISCSI_SLOW_PATH_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF22) -#define DQ_XCM_ISCSI_PROC_ONLY_CLEANUP_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF23) -#define DQ_XCM_TOE_DQ_FLUSH_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF19) -#define DQ_XCM_TOE_SLOW_PATH_CMD (1 << DQ_XCM_AGG_FLG_SHIFT_CF22) - -/* UCM agg counter flag selection (HW) */ -#define DQ_UCM_AGG_FLG_SHIFT_CF0 0 -#define DQ_UCM_AGG_FLG_SHIFT_CF1 1 -#define DQ_UCM_AGG_FLG_SHIFT_CF3 2 -#define DQ_UCM_AGG_FLG_SHIFT_CF4 3 -#define DQ_UCM_AGG_FLG_SHIFT_CF5 4 -#define DQ_UCM_AGG_FLG_SHIFT_CF6 5 -#define DQ_UCM_AGG_FLG_SHIFT_RULE0EN 6 -#define DQ_UCM_AGG_FLG_SHIFT_RULE1EN 7 - -/* UCM agg counter flag selection (FW) */ -#define DQ_UCM_ETH_PMD_TX_ARM_CMD (1 << DQ_UCM_AGG_FLG_SHIFT_CF4) -#define DQ_UCM_ETH_PMD_RX_ARM_CMD (1 << DQ_UCM_AGG_FLG_SHIFT_CF5) -#define DQ_UCM_ROCE_CQ_ARM_SE_CF_CMD (1 << DQ_UCM_AGG_FLG_SHIFT_CF4) -#define DQ_UCM_ROCE_CQ_ARM_CF_CMD (1 << DQ_UCM_AGG_FLG_SHIFT_CF5) -#define DQ_UCM_TOE_TIMER_STOP_ALL_CMD (1 << DQ_UCM_AGG_FLG_SHIFT_CF3) -#define DQ_UCM_TOE_SLOW_PATH_CF_CMD (1 << DQ_UCM_AGG_FLG_SHIFT_CF4) -#define DQ_UCM_TOE_DQ_CF_CMD (1 << DQ_UCM_AGG_FLG_SHIFT_CF5) - -/* TCM agg counter flag selection (HW) */ -#define DQ_TCM_AGG_FLG_SHIFT_CF0 0 -#define DQ_TCM_AGG_FLG_SHIFT_CF1 1 -#define DQ_TCM_AGG_FLG_SHIFT_CF2 2 -#define DQ_TCM_AGG_FLG_SHIFT_CF3 3 -#define DQ_TCM_AGG_FLG_SHIFT_CF4 4 -#define DQ_TCM_AGG_FLG_SHIFT_CF5 5 -#define DQ_TCM_AGG_FLG_SHIFT_CF6 6 -#define DQ_TCM_AGG_FLG_SHIFT_CF7 7 - -/* TCM agg counter flag selection (FW) */ -#define DQ_TCM_FCOE_FLUSH_Q0_CMD (1 << DQ_TCM_AGG_FLG_SHIFT_CF1) -#define DQ_TCM_FCOE_DUMMY_TIMER_CMD (1 << DQ_TCM_AGG_FLG_SHIFT_CF2) -#define DQ_TCM_FCOE_TIMER_STOP_ALL_CMD (1 << DQ_TCM_AGG_FLG_SHIFT_CF3) -#define DQ_TCM_ISCSI_FLUSH_Q0_CMD (1 << DQ_TCM_AGG_FLG_SHIFT_CF1) -#define DQ_TCM_ISCSI_TIMER_STOP_ALL_CMD (1 << DQ_TCM_AGG_FLG_SHIFT_CF3) -#define DQ_TCM_TOE_FLUSH_Q0_CMD (1 << DQ_TCM_AGG_FLG_SHIFT_CF1) -#define DQ_TCM_TOE_TIMER_STOP_ALL_CMD (1 << DQ_TCM_AGG_FLG_SHIFT_CF3) -#define DQ_TCM_IWARP_POST_RQ_CF_CMD (1 << DQ_TCM_AGG_FLG_SHIFT_CF1) - -/* PWM address mapping */ -#define DQ_PWM_OFFSET_DPM_BASE 0x0 -#define DQ_PWM_OFFSET_DPM_END 0x27 -#define DQ_PWM_OFFSET_XCM16_BASE 0x40 -#define DQ_PWM_OFFSET_XCM32_BASE 0x44 -#define DQ_PWM_OFFSET_UCM16_BASE 0x48 -#define DQ_PWM_OFFSET_UCM32_BASE 0x4C -#define DQ_PWM_OFFSET_UCM16_4 0x50 -#define DQ_PWM_OFFSET_TCM16_BASE 0x58 -#define DQ_PWM_OFFSET_TCM32_BASE 0x5C -#define DQ_PWM_OFFSET_XCM_FLAGS 0x68 -#define DQ_PWM_OFFSET_UCM_FLAGS 0x69 -#define DQ_PWM_OFFSET_TCM_FLAGS 0x6B - -#define DQ_PWM_OFFSET_XCM_RDMA_SQ_PROD (DQ_PWM_OFFSET_XCM16_BASE + 2) -#define DQ_PWM_OFFSET_UCM_RDMA_CQ_CONS_32BIT (DQ_PWM_OFFSET_UCM32_BASE) -#define DQ_PWM_OFFSET_UCM_RDMA_CQ_CONS_16BIT (DQ_PWM_OFFSET_UCM16_4) -#define DQ_PWM_OFFSET_UCM_RDMA_INT_TIMEOUT (DQ_PWM_OFFSET_UCM16_BASE + 2) -#define DQ_PWM_OFFSET_UCM_RDMA_ARM_FLAGS (DQ_PWM_OFFSET_UCM_FLAGS) -#define DQ_PWM_OFFSET_TCM_ROCE_RQ_PROD (DQ_PWM_OFFSET_TCM16_BASE + 1) -#define DQ_PWM_OFFSET_TCM_IWARP_RQ_PROD (DQ_PWM_OFFSET_TCM16_BASE + 3) - -#define DQ_REGION_SHIFT (12) - -/* DPM */ -#define DQ_DPM_WQE_BUFF_SIZE (320) - -// Conn type ranges -#define DQ_CONN_TYPE_RANGE_SHIFT (4) - -/*****************/ -/* QM CONSTANTS */ -/*****************/ - -/* number of TX queues in the QM */ -#define MAX_QM_TX_QUEUES_K2 512 -#define MAX_QM_TX_QUEUES_BB 448 -#define MAX_QM_TX_QUEUES MAX_QM_TX_QUEUES_K2 - -/* number of Other queues in the QM */ -#define MAX_QM_OTHER_QUEUES_BB 64 -#define MAX_QM_OTHER_QUEUES_K2 128 -#define MAX_QM_OTHER_QUEUES MAX_QM_OTHER_QUEUES_K2 - -/* number of queues in a PF queue group */ -#define QM_PF_QUEUE_GROUP_SIZE 8 - -/* the size of a single queue element in bytes */ -#define QM_PQ_ELEMENT_SIZE 4 - -/* base number of Tx PQs in the CM PQ representation. - should be used when storing PQ IDs in CM PQ registers and context */ -#define CM_TX_PQ_BASE 0x200 - -/* number of global Vport/QCN rate limiters */ -#define MAX_QM_GLOBAL_RLS 256 - -/* QM registers data */ -#define QM_LINE_CRD_REG_WIDTH 16 -#define QM_LINE_CRD_REG_SIGN_BIT (1 << (QM_LINE_CRD_REG_WIDTH - 1)) -#define QM_BYTE_CRD_REG_WIDTH 24 -#define QM_BYTE_CRD_REG_SIGN_BIT (1 << (QM_BYTE_CRD_REG_WIDTH - 1)) -#define QM_WFQ_CRD_REG_WIDTH 32 -#define QM_WFQ_CRD_REG_SIGN_BIT (1 << (QM_WFQ_CRD_REG_WIDTH - 1)) -#define QM_RL_CRD_REG_WIDTH 32 -#define QM_RL_CRD_REG_SIGN_BIT (1 << (QM_RL_CRD_REG_WIDTH - 1)) - -/*****************/ -/* CAU CONSTANTS */ -/*****************/ - -#define CAU_FSM_ETH_RX 0 -#define CAU_FSM_ETH_TX 1 - -/* Number of Protocol Indices per Status Block */ -#define PIS_PER_SB 12 - - -#define CAU_HC_STOPPED_STATE 3 /* fsm is stopped or not valid for this sb */ -#define CAU_HC_DISABLE_STATE 4 /* fsm is working without interrupt coalescing for this sb*/ -#define CAU_HC_ENABLE_STATE 0 /* fsm is working with interrupt coalescing for this sb*/ - - -/*****************/ -/* IGU CONSTANTS */ -/*****************/ - -#define MAX_SB_PER_PATH_K2 (368) -#define MAX_SB_PER_PATH_BB (288) -#define MAX_TOT_SB_PER_PATH MAX_SB_PER_PATH_K2 - -#define MAX_SB_PER_PF_MIMD 129 -#define MAX_SB_PER_PF_SIMD 64 -#define MAX_SB_PER_VF 64 - -/* Memory addresses on the BAR for the IGU Sub Block */ -#define IGU_MEM_BASE 0x0000 - -#define IGU_MEM_MSIX_BASE 0x0000 -#define IGU_MEM_MSIX_UPPER 0x0101 -#define IGU_MEM_MSIX_RESERVED_UPPER 0x01ff - -#define IGU_MEM_PBA_MSIX_BASE 0x0200 -#define IGU_MEM_PBA_MSIX_UPPER 0x0202 -#define IGU_MEM_PBA_MSIX_RESERVED_UPPER 0x03ff - -#define IGU_CMD_INT_ACK_BASE 0x0400 -#define IGU_CMD_INT_ACK_UPPER (IGU_CMD_INT_ACK_BASE + MAX_TOT_SB_PER_PATH - 1) -#define IGU_CMD_INT_ACK_RESERVED_UPPER 0x05ff - -#define IGU_CMD_ATTN_BIT_UPD_UPPER 0x05f0 -#define IGU_CMD_ATTN_BIT_SET_UPPER 0x05f1 -#define IGU_CMD_ATTN_BIT_CLR_UPPER 0x05f2 - -#define IGU_REG_SISR_MDPC_WMASK_UPPER 0x05f3 -#define IGU_REG_SISR_MDPC_WMASK_LSB_UPPER 0x05f4 -#define IGU_REG_SISR_MDPC_WMASK_MSB_UPPER 0x05f5 -#define IGU_REG_SISR_MDPC_WOMASK_UPPER 0x05f6 - -#define IGU_CMD_PROD_UPD_BASE 0x0600 -#define IGU_CMD_PROD_UPD_UPPER (IGU_CMD_PROD_UPD_BASE + MAX_TOT_SB_PER_PATH - 1) -#define IGU_CMD_PROD_UPD_RESERVED_UPPER 0x07ff - -/*****************/ -/* PXP CONSTANTS */ -/*****************/ - -/* Bars for Blocks */ -#define PXP_BAR_GRC 0 -#define PXP_BAR_TSDM 0 -#define PXP_BAR_USDM 0 -#define PXP_BAR_XSDM 0 -#define PXP_BAR_MSDM 0 -#define PXP_BAR_YSDM 0 -#define PXP_BAR_PSDM 0 -#define PXP_BAR_IGU 0 -#define PXP_BAR_DQ 1 - -/* PTT and GTT */ -#define PXP_NUM_PF_WINDOWS 12 -#define PXP_PER_PF_ENTRY_SIZE 8 -#define PXP_NUM_GLOBAL_WINDOWS 243 -#define PXP_GLOBAL_ENTRY_SIZE 4 -#define PXP_ADMIN_WINDOW_ALLOWED_LENGTH 4 -#define PXP_PF_WINDOW_ADMIN_START 0 -#define PXP_PF_WINDOW_ADMIN_LENGTH 0x1000 -#define PXP_PF_WINDOW_ADMIN_END (PXP_PF_WINDOW_ADMIN_START + PXP_PF_WINDOW_ADMIN_LENGTH - 1) -#define PXP_PF_WINDOW_ADMIN_PER_PF_START 0 -#define PXP_PF_WINDOW_ADMIN_PER_PF_LENGTH (PXP_NUM_PF_WINDOWS * PXP_PER_PF_ENTRY_SIZE) -#define PXP_PF_WINDOW_ADMIN_PER_PF_END (PXP_PF_WINDOW_ADMIN_PER_PF_START + PXP_PF_WINDOW_ADMIN_PER_PF_LENGTH - 1) -#define PXP_PF_WINDOW_ADMIN_GLOBAL_START 0x200 -#define PXP_PF_WINDOW_ADMIN_GLOBAL_LENGTH (PXP_NUM_GLOBAL_WINDOWS * PXP_GLOBAL_ENTRY_SIZE) -#define PXP_PF_WINDOW_ADMIN_GLOBAL_END (PXP_PF_WINDOW_ADMIN_GLOBAL_START + PXP_PF_WINDOW_ADMIN_GLOBAL_LENGTH - 1) -#define PXP_PF_GLOBAL_PRETEND_ADDR 0x1f0 -#define PXP_PF_ME_OPAQUE_MASK_ADDR 0xf4 -#define PXP_PF_ME_OPAQUE_ADDR 0x1f8 -#define PXP_PF_ME_CONCRETE_ADDR 0x1fc - -#define PXP_EXTERNAL_BAR_PF_WINDOW_START 0x1000 -#define PXP_EXTERNAL_BAR_PF_WINDOW_NUM PXP_NUM_PF_WINDOWS -#define PXP_EXTERNAL_BAR_PF_WINDOW_SINGLE_SIZE 0x1000 -#define PXP_EXTERNAL_BAR_PF_WINDOW_LENGTH (PXP_EXTERNAL_BAR_PF_WINDOW_NUM * PXP_EXTERNAL_BAR_PF_WINDOW_SINGLE_SIZE) -#define PXP_EXTERNAL_BAR_PF_WINDOW_END (PXP_EXTERNAL_BAR_PF_WINDOW_START + PXP_EXTERNAL_BAR_PF_WINDOW_LENGTH - 1) - -#define PXP_EXTERNAL_BAR_GLOBAL_WINDOW_START (PXP_EXTERNAL_BAR_PF_WINDOW_END + 1) -#define PXP_EXTERNAL_BAR_GLOBAL_WINDOW_NUM PXP_NUM_GLOBAL_WINDOWS -#define PXP_EXTERNAL_BAR_GLOBAL_WINDOW_SINGLE_SIZE 0x1000 -#define PXP_EXTERNAL_BAR_GLOBAL_WINDOW_LENGTH (PXP_EXTERNAL_BAR_GLOBAL_WINDOW_NUM * PXP_EXTERNAL_BAR_GLOBAL_WINDOW_SINGLE_SIZE) -#define PXP_EXTERNAL_BAR_GLOBAL_WINDOW_END (PXP_EXTERNAL_BAR_GLOBAL_WINDOW_START + PXP_EXTERNAL_BAR_GLOBAL_WINDOW_LENGTH - 1) - -/* PF BAR */ -//#define PXP_BAR0_START_GRC 0x1000 -//#define PXP_BAR0_GRC_LENGTH 0xBFF000 -#define PXP_BAR0_START_GRC 0x0000 -#define PXP_BAR0_GRC_LENGTH 0x1C00000 -#define PXP_BAR0_END_GRC (PXP_BAR0_START_GRC + PXP_BAR0_GRC_LENGTH - 1) - -#define PXP_BAR0_START_IGU 0x1C00000 -#define PXP_BAR0_IGU_LENGTH 0x10000 -#define PXP_BAR0_END_IGU (PXP_BAR0_START_IGU + PXP_BAR0_IGU_LENGTH - 1) - -#define PXP_BAR0_START_TSDM 0x1C80000 -#define PXP_BAR0_SDM_LENGTH 0x40000 -#define PXP_BAR0_SDM_RESERVED_LENGTH 0x40000 -#define PXP_BAR0_END_TSDM (PXP_BAR0_START_TSDM + PXP_BAR0_SDM_LENGTH - 1) - -#define PXP_BAR0_START_MSDM 0x1D00000 -#define PXP_BAR0_END_MSDM (PXP_BAR0_START_MSDM + PXP_BAR0_SDM_LENGTH - 1) - -#define PXP_BAR0_START_USDM 0x1D80000 -#define PXP_BAR0_END_USDM (PXP_BAR0_START_USDM + PXP_BAR0_SDM_LENGTH - 1) - -#define PXP_BAR0_START_XSDM 0x1E00000 -#define PXP_BAR0_END_XSDM (PXP_BAR0_START_XSDM + PXP_BAR0_SDM_LENGTH - 1) - -#define PXP_BAR0_START_YSDM 0x1E80000 -#define PXP_BAR0_END_YSDM (PXP_BAR0_START_YSDM + PXP_BAR0_SDM_LENGTH - 1) - -#define PXP_BAR0_START_PSDM 0x1F00000 -#define PXP_BAR0_END_PSDM (PXP_BAR0_START_PSDM + PXP_BAR0_SDM_LENGTH - 1) - -#define PXP_BAR0_FIRST_INVALID_ADDRESS (PXP_BAR0_END_PSDM + 1) - -/* VF BAR */ -#define PXP_VF_BAR0 0 - -#define PXP_VF_BAR0_START_GRC 0x3E00 -#define PXP_VF_BAR0_GRC_LENGTH 0x200 -#define PXP_VF_BAR0_END_GRC (PXP_VF_BAR0_START_GRC + PXP_VF_BAR0_GRC_LENGTH - 1) - -#define PXP_VF_BAR0_START_IGU 0 -#define PXP_VF_BAR0_IGU_LENGTH 0x3000 -#define PXP_VF_BAR0_END_IGU (PXP_VF_BAR0_START_IGU + PXP_VF_BAR0_IGU_LENGTH - 1) - -#define PXP_VF_BAR0_START_DQ 0x3000 -#define PXP_VF_BAR0_DQ_LENGTH 0x200 -#define PXP_VF_BAR0_DQ_OPAQUE_OFFSET 0 -#define PXP_VF_BAR0_ME_OPAQUE_ADDRESS (PXP_VF_BAR0_START_DQ + PXP_VF_BAR0_DQ_OPAQUE_OFFSET) -#define PXP_VF_BAR0_ME_CONCRETE_ADDRESS (PXP_VF_BAR0_ME_OPAQUE_ADDRESS + 4) -#define PXP_VF_BAR0_END_DQ (PXP_VF_BAR0_START_DQ + PXP_VF_BAR0_DQ_LENGTH - 1) - -#define PXP_VF_BAR0_START_TSDM_ZONE_B 0x3200 -#define PXP_VF_BAR0_SDM_LENGTH_ZONE_B 0x200 -#define PXP_VF_BAR0_END_TSDM_ZONE_B (PXP_VF_BAR0_START_TSDM_ZONE_B + PXP_VF_BAR0_SDM_LENGTH_ZONE_B - 1) - -#define PXP_VF_BAR0_START_MSDM_ZONE_B 0x3400 -#define PXP_VF_BAR0_END_MSDM_ZONE_B (PXP_VF_BAR0_START_MSDM_ZONE_B + PXP_VF_BAR0_SDM_LENGTH_ZONE_B - 1) - -#define PXP_VF_BAR0_START_USDM_ZONE_B 0x3600 -#define PXP_VF_BAR0_END_USDM_ZONE_B (PXP_VF_BAR0_START_USDM_ZONE_B + PXP_VF_BAR0_SDM_LENGTH_ZONE_B - 1) - -#define PXP_VF_BAR0_START_XSDM_ZONE_B 0x3800 -#define PXP_VF_BAR0_END_XSDM_ZONE_B (PXP_VF_BAR0_START_XSDM_ZONE_B + PXP_VF_BAR0_SDM_LENGTH_ZONE_B - 1) - -#define PXP_VF_BAR0_START_YSDM_ZONE_B 0x3a00 -#define PXP_VF_BAR0_END_YSDM_ZONE_B (PXP_VF_BAR0_START_YSDM_ZONE_B + PXP_VF_BAR0_SDM_LENGTH_ZONE_B - 1) - -#define PXP_VF_BAR0_START_PSDM_ZONE_B 0x3c00 -#define PXP_VF_BAR0_END_PSDM_ZONE_B (PXP_VF_BAR0_START_PSDM_ZONE_B + PXP_VF_BAR0_SDM_LENGTH_ZONE_B - 1) - -#define PXP_VF_BAR0_START_SDM_ZONE_A 0x4000 -#define PXP_VF_BAR0_END_SDM_ZONE_A 0x10000 - -#define PXP_VF_BAR0_GRC_WINDOW_LENGTH 32 - -#define PXP_ILT_PAGE_SIZE_NUM_BITS_MIN 12 -#define PXP_ILT_BLOCK_FACTOR_MULTIPLIER 1024 - -// ILT Records -#define PXP_NUM_ILT_RECORDS_BB 7600 -#define PXP_NUM_ILT_RECORDS_K2 11000 -#define MAX_NUM_ILT_RECORDS MAX(PXP_NUM_ILT_RECORDS_BB,PXP_NUM_ILT_RECORDS_K2) - - -// Host Interface -#define PXP_QUEUES_ZONE_MAX_NUM 320 - - - - -/*****************/ -/* PRM CONSTANTS */ -/*****************/ -#define PRM_DMA_PAD_BYTES_NUM 2 -/*****************/ -/* SDMs CONSTANTS */ -/*****************/ - - -#define SDM_OP_GEN_TRIG_NONE 0 -#define SDM_OP_GEN_TRIG_WAKE_THREAD 1 -#define SDM_OP_GEN_TRIG_AGG_INT 2 -#define SDM_OP_GEN_TRIG_LOADER 4 -#define SDM_OP_GEN_TRIG_INDICATE_ERROR 6 -#define SDM_OP_GEN_TRIG_RELEASE_THREAD 7 - -///////////////////////////////////////////////////////////// -// Completion types -///////////////////////////////////////////////////////////// - -#define SDM_COMP_TYPE_NONE 0 -#define SDM_COMP_TYPE_WAKE_THREAD 1 -#define SDM_COMP_TYPE_AGG_INT 2 -#define SDM_COMP_TYPE_CM 3 // Send direct message to local CM and/or remote CMs. Destinations are defined by vector in CompParams. -#define SDM_COMP_TYPE_LOADER 4 -#define SDM_COMP_TYPE_PXP 5 // Send direct message to PXP (like "internal write" command) to write to remote Storm RAM via remote SDM -#define SDM_COMP_TYPE_INDICATE_ERROR 6 // Indicate error per thread -#define SDM_COMP_TYPE_RELEASE_THREAD 7 -#define SDM_COMP_TYPE_RAM 8 // Write to local RAM as a completion - - -/******************/ -/* PBF CONSTANTS */ -/******************/ - -/* Number of PBF command queue lines. Each line is 32B. */ -#define PBF_MAX_CMD_LINES 3328 - -/* Number of BTB blocks. Each block is 256B. */ -#define BTB_MAX_BLOCKS 1440 - -/*****************/ -/* PRS CONSTANTS */ -/*****************/ - -#define PRS_GFT_CAM_LINES_NO_MATCH 31 - -/* - * Async data KCQ CQE - */ -struct async_data -{ - __le32 cid /* Context ID of the connection */; - __le16 itid /* Task Id of the task (for error that happened on a a task) */; - uint8_t error_code /* error code - relevant only if the opcode indicates its an error */; - uint8_t fw_debug_param /* internal fw debug parameter */; -}; - - -/* - * Interrupt coalescing TimeSet - */ -struct coalescing_timeset -{ - uint8_t value; -#define COALESCING_TIMESET_TIMESET_MASK 0x7F /* Interrupt coalescing TimeSet (timeout_ticks = TimeSet shl (TimerRes+1)) */ -#define COALESCING_TIMESET_TIMESET_SHIFT 0 -#define COALESCING_TIMESET_VALID_MASK 0x1 /* Only if this flag is set, timeset will take effect */ -#define COALESCING_TIMESET_VALID_SHIFT 7 -}; - - -struct common_queue_zone -{ - __le16 ring_drv_data_consumer; - __le16 reserved; -}; - - -/* - * ETH Rx producers data - */ -struct eth_rx_prod_data -{ - __le16 bd_prod /* BD producer. */; - __le16 cqe_prod /* CQE producer. */; -}; - - -struct regpair -{ - __le32 lo /* low word for reg-pair */; - __le32 hi /* high word for reg-pair */; -}; - -/* - * Event Ring VF-PF Channel data - */ -struct vf_pf_channel_eqe_data -{ - struct regpair msg_addr /* VF-PF message address */; -}; - -struct iscsi_eqe_data -{ - __le32 cid /* Context ID of the connection */; - __le16 conn_id /* Task Id of the task (for error that happened on a a task) */; - uint8_t error_code /* error code - relevant only if the opcode indicates its an error */; - uint8_t error_pdu_opcode_reserved; -#define ISCSI_EQE_DATA_ERROR_PDU_OPCODE_MASK 0x3F /* The processed PDUs opcode on which happened the error - updated for specific error codes, by defualt=0xFF */ -#define ISCSI_EQE_DATA_ERROR_PDU_OPCODE_SHIFT 0 -#define ISCSI_EQE_DATA_ERROR_PDU_OPCODE_VALID_MASK 0x1 /* Indication for driver is the error_pdu_opcode field has valid value */ -#define ISCSI_EQE_DATA_ERROR_PDU_OPCODE_VALID_SHIFT 6 -#define ISCSI_EQE_DATA_RESERVED0_MASK 0x1 -#define ISCSI_EQE_DATA_RESERVED0_SHIFT 7 -}; - -/* - * Event Ring malicious VF data - */ -struct malicious_vf_eqe_data -{ - uint8_t vfId /* Malicious VF ID */; - uint8_t errId /* Malicious VF error */; - __le16 reserved[3]; -}; - -/* - * Event Ring initial cleanup data - */ -struct initial_cleanup_eqe_data -{ - uint8_t vfId /* VF ID */; - uint8_t reserved[7]; -}; - -/* - * Event Data Union - */ -union event_ring_data -{ - uint8_t bytes[8] /* Byte Array */; - struct vf_pf_channel_eqe_data vf_pf_channel /* VF-PF Channel data */; - struct iscsi_eqe_data iscsi_info /* Dedicated fields to iscsi data */; - struct regpair roceHandle /* Dedicated field for RoCE affiliated asynchronous error */; - struct malicious_vf_eqe_data malicious_vf /* Malicious VF data */; - struct initial_cleanup_eqe_data vf_init_cleanup /* VF Initial Cleanup data */; - struct regpair iwarp_handle /* Host handle for the Async Completions */; -}; - - -/* - * Event Ring Entry - */ -struct event_ring_entry -{ - uint8_t protocol_id /* Event Protocol ID */; - uint8_t opcode /* Event Opcode */; - __le16 reserved0 /* Reserved */; - __le16 echo /* Echo value from ramrod data on the host */; - uint8_t fw_return_code /* FW return code for SP ramrods */; - uint8_t flags; -#define EVENT_RING_ENTRY_ASYNC_MASK 0x1 /* 0: synchronous EQE - a completion of SP message. 1: asynchronous EQE */ -#define EVENT_RING_ENTRY_ASYNC_SHIFT 0 -#define EVENT_RING_ENTRY_RESERVED1_MASK 0x7F -#define EVENT_RING_ENTRY_RESERVED1_SHIFT 1 - union event_ring_data data; -}; - - - - - -/* - * Multi function mode - */ -enum mf_mode -{ - ERROR_MODE /* Unsupported mode */, - MF_OVLAN /* Multi function based on outer VLAN */, - MF_NPAR /* Multi function based on MAC address (NIC partitioning) */, - MAX_MF_MODE -}; - - -/* - * Per-protocol connection types - */ -enum protocol_type -{ - PROTOCOLID_ISCSI /* iSCSI */, - PROTOCOLID_FCOE /* FCoE */, - PROTOCOLID_ROCE /* RoCE */, - PROTOCOLID_CORE /* Core (light L2, slow path core) */, - PROTOCOLID_ETH /* Ethernet */, - PROTOCOLID_IWARP /* iWARP */, - PROTOCOLID_TOE /* TOE */, - PROTOCOLID_PREROCE /* Pre (tapeout) RoCE */, - PROTOCOLID_COMMON /* ProtocolCommon */, - PROTOCOLID_TCP /* TCP */, - MAX_PROTOCOL_TYPE -}; - - -/* - * Ustorm Queue Zone - */ -struct ustorm_eth_queue_zone -{ - struct coalescing_timeset int_coalescing_timeset /* Rx interrupt coalescing TimeSet */; - uint8_t reserved[3]; -}; - - -struct ustorm_queue_zone -{ - struct ustorm_eth_queue_zone eth; - struct common_queue_zone common; -}; - - - -/* - * status block structure - */ -struct cau_pi_entry -{ - __le32 prod; -#define CAU_PI_ENTRY_PROD_VAL_MASK 0xFFFF /* A per protocol indexPROD value. */ -#define CAU_PI_ENTRY_PROD_VAL_SHIFT 0 -#define CAU_PI_ENTRY_PI_TIMESET_MASK 0x7F /* This value determines the TimeSet that the PI is associated with */ -#define CAU_PI_ENTRY_PI_TIMESET_SHIFT 16 -#define CAU_PI_ENTRY_FSM_SEL_MASK 0x1 /* Select the FSM within the SB */ -#define CAU_PI_ENTRY_FSM_SEL_SHIFT 23 -#define CAU_PI_ENTRY_RESERVED_MASK 0xFF /* Select the FSM within the SB */ -#define CAU_PI_ENTRY_RESERVED_SHIFT 24 -}; - - -/* - * status block structure - */ -struct cau_sb_entry -{ - __le32 data; -#define CAU_SB_ENTRY_SB_PROD_MASK 0xFFFFFF /* The SB PROD index which is sent to the IGU. */ -#define CAU_SB_ENTRY_SB_PROD_SHIFT 0 -#define CAU_SB_ENTRY_STATE0_MASK 0xF /* RX state */ -#define CAU_SB_ENTRY_STATE0_SHIFT 24 -#define CAU_SB_ENTRY_STATE1_MASK 0xF /* TX state */ -#define CAU_SB_ENTRY_STATE1_SHIFT 28 - __le32 params; -#define CAU_SB_ENTRY_SB_TIMESET0_MASK 0x7F /* Indicates the RX TimeSet that this SB is associated with. */ -#define CAU_SB_ENTRY_SB_TIMESET0_SHIFT 0 -#define CAU_SB_ENTRY_SB_TIMESET1_MASK 0x7F /* Indicates the TX TimeSet that this SB is associated with. */ -#define CAU_SB_ENTRY_SB_TIMESET1_SHIFT 7 -#define CAU_SB_ENTRY_TIMER_RES0_MASK 0x3 /* This value will determine the RX FSM timer resolution in ticks */ -#define CAU_SB_ENTRY_TIMER_RES0_SHIFT 14 -#define CAU_SB_ENTRY_TIMER_RES1_MASK 0x3 /* This value will determine the TX FSM timer resolution in ticks */ -#define CAU_SB_ENTRY_TIMER_RES1_SHIFT 16 -#define CAU_SB_ENTRY_VF_NUMBER_MASK 0xFF -#define CAU_SB_ENTRY_VF_NUMBER_SHIFT 18 -#define CAU_SB_ENTRY_VF_VALID_MASK 0x1 -#define CAU_SB_ENTRY_VF_VALID_SHIFT 26 -#define CAU_SB_ENTRY_PF_NUMBER_MASK 0xF -#define CAU_SB_ENTRY_PF_NUMBER_SHIFT 27 -#define CAU_SB_ENTRY_TPH_MASK 0x1 /* If set then indicates that the TPH STAG is equal to the SB number. Otherwise the STAG will be equal to all ones. */ -#define CAU_SB_ENTRY_TPH_SHIFT 31 -}; - - -/* - * core doorbell data - */ -struct core_db_data -{ - uint8_t params; -#define CORE_DB_DATA_DEST_MASK 0x3 /* destination of doorbell (use enum db_dest) */ -#define CORE_DB_DATA_DEST_SHIFT 0 -#define CORE_DB_DATA_AGG_CMD_MASK 0x3 /* aggregative command to CM (use enum db_agg_cmd_sel) */ -#define CORE_DB_DATA_AGG_CMD_SHIFT 2 -#define CORE_DB_DATA_BYPASS_EN_MASK 0x1 /* enable QM bypass */ -#define CORE_DB_DATA_BYPASS_EN_SHIFT 4 -#define CORE_DB_DATA_RESERVED_MASK 0x1 -#define CORE_DB_DATA_RESERVED_SHIFT 5 -#define CORE_DB_DATA_AGG_VAL_SEL_MASK 0x3 /* aggregative value selection */ -#define CORE_DB_DATA_AGG_VAL_SEL_SHIFT 6 - uint8_t agg_flags /* bit for every DQ counter flags in CM context that DQ can increment */; - __le16 spq_prod; -}; - - -/* - * Enum of doorbell aggregative command selection - */ -enum db_agg_cmd_sel -{ - DB_AGG_CMD_NOP /* No operation */, - DB_AGG_CMD_SET /* Set the value */, - DB_AGG_CMD_ADD /* Add the value */, - DB_AGG_CMD_MAX /* Set max of current and new value */, - MAX_DB_AGG_CMD_SEL -}; - - -/* - * Enum of doorbell destination - */ -enum db_dest -{ - DB_DEST_XCM /* TX doorbell to XCM */, - DB_DEST_UCM /* RX doorbell to UCM */, - DB_DEST_TCM /* RX doorbell to TCM */, - DB_NUM_DESTINATIONS, - MAX_DB_DEST -}; - - -/* - * Enum of doorbell DPM types - */ -enum db_dpm_type -{ - DPM_LEGACY /* Legacy DPM- to Xstorm RAM */, - DPM_ROCE /* RoCE DPM- to NIG */, - DPM_L2_INLINE /* L2 DPM inline- to PBF, with packet data on doorbell */, - DPM_L2_BD /* L2 DPM with BD- to PBF, with TX BD data on doorbell */, - MAX_DB_DPM_TYPE -}; - - -/* - * Structure for doorbell data, in L2 DPM mode, for the first doorbell in a DPM burst - */ -struct db_l2_dpm_data -{ - __le16 icid /* internal CID */; - __le16 bd_prod /* bd producer value to update */; - __le32 params; -#define DB_L2_DPM_DATA_SIZE_MASK 0x3F /* Size in QWORD-s of the DPM burst */ -#define DB_L2_DPM_DATA_SIZE_SHIFT 0 -#define DB_L2_DPM_DATA_DPM_TYPE_MASK 0x3 /* Type of DPM transaction (DPM_L2_INLINE or DPM_L2_BD) (use enum db_dpm_type) */ -#define DB_L2_DPM_DATA_DPM_TYPE_SHIFT 6 -#define DB_L2_DPM_DATA_NUM_BDS_MASK 0xFF /* number of BD-s */ -#define DB_L2_DPM_DATA_NUM_BDS_SHIFT 8 -#define DB_L2_DPM_DATA_PKT_SIZE_MASK 0x7FF /* size of the packet to be transmitted in bytes */ -#define DB_L2_DPM_DATA_PKT_SIZE_SHIFT 16 -#define DB_L2_DPM_DATA_RESERVED0_MASK 0x1 -#define DB_L2_DPM_DATA_RESERVED0_SHIFT 27 -#define DB_L2_DPM_DATA_SGE_NUM_MASK 0x7 /* In DPM_L2_BD mode: the number of SGE-s */ -#define DB_L2_DPM_DATA_SGE_NUM_SHIFT 28 -#define DB_L2_DPM_DATA_RESERVED1_MASK 0x1 -#define DB_L2_DPM_DATA_RESERVED1_SHIFT 31 -}; - - -/* - * Structure for SGE in a DPM doorbell of type DPM_L2_BD - */ -struct db_l2_dpm_sge -{ - struct regpair addr /* Single continuous buffer */; - __le16 nbytes /* Number of bytes in this BD. */; - __le16 bitfields; -#define DB_L2_DPM_SGE_TPH_ST_INDEX_MASK 0x1FF /* The TPH STAG index value */ -#define DB_L2_DPM_SGE_TPH_ST_INDEX_SHIFT 0 -#define DB_L2_DPM_SGE_RESERVED0_MASK 0x3 -#define DB_L2_DPM_SGE_RESERVED0_SHIFT 9 -#define DB_L2_DPM_SGE_ST_VALID_MASK 0x1 /* Indicate if ST hint is requested or not */ -#define DB_L2_DPM_SGE_ST_VALID_SHIFT 11 -#define DB_L2_DPM_SGE_RESERVED1_MASK 0xF -#define DB_L2_DPM_SGE_RESERVED1_SHIFT 12 - __le32 reserved2; -}; - - -/* - * Structure for doorbell address, in legacy mode - */ -struct db_legacy_addr -{ - __le32 addr; -#define DB_LEGACY_ADDR_RESERVED0_MASK 0x3 -#define DB_LEGACY_ADDR_RESERVED0_SHIFT 0 -#define DB_LEGACY_ADDR_DEMS_MASK 0x7 /* doorbell extraction mode specifier- 0 if not used */ -#define DB_LEGACY_ADDR_DEMS_SHIFT 2 -#define DB_LEGACY_ADDR_ICID_MASK 0x7FFFFFF /* internal CID */ -#define DB_LEGACY_ADDR_ICID_SHIFT 5 -}; - - -/* - * Structure for doorbell address, in PWM mode - */ -struct db_pwm_addr -{ - __le32 addr; -#define DB_PWM_ADDR_RESERVED0_MASK 0x7 -#define DB_PWM_ADDR_RESERVED0_SHIFT 0 -#define DB_PWM_ADDR_OFFSET_MASK 0x7F /* Offset in PWM address space */ -#define DB_PWM_ADDR_OFFSET_SHIFT 3 -#define DB_PWM_ADDR_WID_MASK 0x3 /* Window ID */ -#define DB_PWM_ADDR_WID_SHIFT 10 -#define DB_PWM_ADDR_DPI_MASK 0xFFFF /* Doorbell page ID */ -#define DB_PWM_ADDR_DPI_SHIFT 12 -#define DB_PWM_ADDR_RESERVED1_MASK 0xF -#define DB_PWM_ADDR_RESERVED1_SHIFT 28 -}; - - -/* - * Parameters to RoCE firmware, passed in EDPM doorbell - */ -struct db_roce_dpm_params -{ - __le32 params; -#define DB_ROCE_DPM_PARAMS_SIZE_MASK 0x3F /* Size in QWORD-s of the DPM burst */ -#define DB_ROCE_DPM_PARAMS_SIZE_SHIFT 0 -#define DB_ROCE_DPM_PARAMS_DPM_TYPE_MASK 0x3 /* Type of DPM transacation (DPM_ROCE) (use enum db_dpm_type) */ -#define DB_ROCE_DPM_PARAMS_DPM_TYPE_SHIFT 6 -#define DB_ROCE_DPM_PARAMS_OPCODE_MASK 0xFF /* opcode for ROCE operation */ -#define DB_ROCE_DPM_PARAMS_OPCODE_SHIFT 8 -#define DB_ROCE_DPM_PARAMS_WQE_SIZE_MASK 0x7FF /* the size of the WQE payload in bytes */ -#define DB_ROCE_DPM_PARAMS_WQE_SIZE_SHIFT 16 -#define DB_ROCE_DPM_PARAMS_RESERVED0_MASK 0x1 -#define DB_ROCE_DPM_PARAMS_RESERVED0_SHIFT 27 -#define DB_ROCE_DPM_PARAMS_COMPLETION_FLG_MASK 0x1 /* RoCE completion flag */ -#define DB_ROCE_DPM_PARAMS_COMPLETION_FLG_SHIFT 28 -#define DB_ROCE_DPM_PARAMS_S_FLG_MASK 0x1 /* RoCE S flag */ -#define DB_ROCE_DPM_PARAMS_S_FLG_SHIFT 29 -#define DB_ROCE_DPM_PARAMS_RESERVED1_MASK 0x3 -#define DB_ROCE_DPM_PARAMS_RESERVED1_SHIFT 30 -}; - -/* - * Structure for doorbell data, in ROCE DPM mode, for the first doorbell in a DPM burst - */ -struct db_roce_dpm_data -{ - __le16 icid /* internal CID */; - __le16 prod_val /* aggregated value to update */; - struct db_roce_dpm_params params /* parametes passed to RoCE firmware */; -}; - - - -/* - * Igu interrupt command - */ -enum igu_int_cmd -{ - IGU_INT_ENABLE=0, - IGU_INT_DISABLE=1, - IGU_INT_NOP=2, - IGU_INT_NOP2=3, - MAX_IGU_INT_CMD -}; - - -/* - * IGU producer or consumer update command - */ -struct igu_prod_cons_update -{ - __le32 sb_id_and_flags; -#define IGU_PROD_CONS_UPDATE_SB_INDEX_MASK 0xFFFFFF -#define IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT 0 -#define IGU_PROD_CONS_UPDATE_UPDATE_FLAG_MASK 0x1 -#define IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT 24 -#define IGU_PROD_CONS_UPDATE_ENABLE_INT_MASK 0x3 /* interrupt enable/disable/nop (use enum igu_int_cmd) */ -#define IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT 25 -#define IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_MASK 0x1 /* (use enum igu_seg_access) */ -#define IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT 27 -#define IGU_PROD_CONS_UPDATE_TIMER_MASK_MASK 0x1 -#define IGU_PROD_CONS_UPDATE_TIMER_MASK_SHIFT 28 -#define IGU_PROD_CONS_UPDATE_RESERVED0_MASK 0x3 -#define IGU_PROD_CONS_UPDATE_RESERVED0_SHIFT 29 -#define IGU_PROD_CONS_UPDATE_COMMAND_TYPE_MASK 0x1 /* must always be set cleared (use enum command_type_bit) */ -#define IGU_PROD_CONS_UPDATE_COMMAND_TYPE_SHIFT 31 - __le32 reserved1; -}; - - -/* - * Igu segments access for default status block only - */ -enum igu_seg_access -{ - IGU_SEG_ACCESS_REG=0, - IGU_SEG_ACCESS_ATTN=1, - MAX_IGU_SEG_ACCESS -}; - - -/* - * Enumeration for L3 type field of parsing_and_err_flags_union. L3Type: 0 - unknown (not ip) ,1 - Ipv4, 2 - Ipv6 (this field can be filled according to the last-ethertype) - */ -enum l3_type -{ - e_l3Type_unknown, - e_l3Type_ipv4, - e_l3Type_ipv6, - MAX_L3_TYPE -}; - - -/* - * Enumeration for l4Protocol field of parsing_and_err_flags_union. L4-protocol 0 - none, 1 - TCP, 2- UDP. if the packet is IPv4 fragment, and its not the first fragment, the protocol-type should be set to none. - */ -enum l4_protocol -{ - e_l4Protocol_none, - e_l4Protocol_tcp, - e_l4Protocol_udp, - MAX_L4_PROTOCOL -}; - - -/* - * Parsing and error flags field. - */ -struct parsing_and_err_flags -{ - __le16 flags; -#define PARSING_AND_ERR_FLAGS_L3TYPE_MASK 0x3 /* L3Type: 0 - unknown (not ip) ,1 - Ipv4, 2 - Ipv6 (this field can be filled according to the last-ethertype) (use enum l3_type) */ -#define PARSING_AND_ERR_FLAGS_L3TYPE_SHIFT 0 -#define PARSING_AND_ERR_FLAGS_L4PROTOCOL_MASK 0x3 /* L4-protocol 0 - none, 1 - TCP, 2- UDP. if the packet is IPv4 fragment, and its not the first fragment, the protocol-type should be set to none. (use enum l4_protocol) */ -#define PARSING_AND_ERR_FLAGS_L4PROTOCOL_SHIFT 2 -#define PARSING_AND_ERR_FLAGS_IPV4FRAG_MASK 0x1 /* Set if the packet is IPv4 fragment. */ -#define PARSING_AND_ERR_FLAGS_IPV4FRAG_SHIFT 4 -#define PARSING_AND_ERR_FLAGS_TAG8021QEXIST_MASK 0x1 /* Set if VLAN tag exists. Invalid if tunnel type are IP GRE or IP GENEVE. */ -#define PARSING_AND_ERR_FLAGS_TAG8021QEXIST_SHIFT 5 -#define PARSING_AND_ERR_FLAGS_L4CHKSMWASCALCULATED_MASK 0x1 /* Set if L4 checksum was calculated. */ -#define PARSING_AND_ERR_FLAGS_L4CHKSMWASCALCULATED_SHIFT 6 -#define PARSING_AND_ERR_FLAGS_TIMESYNCPKT_MASK 0x1 /* Set for PTP packet. */ -#define PARSING_AND_ERR_FLAGS_TIMESYNCPKT_SHIFT 7 -#define PARSING_AND_ERR_FLAGS_TIMESTAMPRECORDED_MASK 0x1 /* Set if PTP timestamp recorded. */ -#define PARSING_AND_ERR_FLAGS_TIMESTAMPRECORDED_SHIFT 8 -#define PARSING_AND_ERR_FLAGS_IPHDRERROR_MASK 0x1 /* Set if either version-mismatch or hdr-len-error or ipv4-cksm is set or ipv6 ver mismatch */ -#define PARSING_AND_ERR_FLAGS_IPHDRERROR_SHIFT 9 -#define PARSING_AND_ERR_FLAGS_L4CHKSMERROR_MASK 0x1 /* Set if L4 checksum validation failed. Valid only if L4 checksum was calculated. */ -#define PARSING_AND_ERR_FLAGS_L4CHKSMERROR_SHIFT 10 -#define PARSING_AND_ERR_FLAGS_TUNNELEXIST_MASK 0x1 /* Set if GRE/VXLAN/GENEVE tunnel detected. */ -#define PARSING_AND_ERR_FLAGS_TUNNELEXIST_SHIFT 11 -#define PARSING_AND_ERR_FLAGS_TUNNEL8021QTAGEXIST_MASK 0x1 /* Set if VLAN tag exists in tunnel header. */ -#define PARSING_AND_ERR_FLAGS_TUNNEL8021QTAGEXIST_SHIFT 12 -#define PARSING_AND_ERR_FLAGS_TUNNELIPHDRERROR_MASK 0x1 /* Set if either tunnel-ipv4-version-mismatch or tunnel-ipv4-hdr-len-error or tunnel-ipv4-cksm is set or tunneling ipv6 ver mismatch */ -#define PARSING_AND_ERR_FLAGS_TUNNELIPHDRERROR_SHIFT 13 -#define PARSING_AND_ERR_FLAGS_TUNNELL4CHKSMWASCALCULATED_MASK 0x1 /* Set if GRE or VXLAN/GENEVE UDP checksum was calculated. */ -#define PARSING_AND_ERR_FLAGS_TUNNELL4CHKSMWASCALCULATED_SHIFT 14 -#define PARSING_AND_ERR_FLAGS_TUNNELL4CHKSMERROR_MASK 0x1 /* Set if tunnel L4 checksum validation failed. Valid only if tunnel L4 checksum was calculated. */ -#define PARSING_AND_ERR_FLAGS_TUNNELL4CHKSMERROR_SHIFT 15 -}; - - -/* - * Pb context - */ -struct pb_context -{ - __le32 crc[4]; -}; - - -/* - * Concrete Function ID. - */ -struct pxp_concrete_fid -{ - __le16 fid; -#define PXP_CONCRETE_FID_PFID_MASK 0xF /* Parent PFID */ -#define PXP_CONCRETE_FID_PFID_SHIFT 0 -#define PXP_CONCRETE_FID_PORT_MASK 0x3 /* port number */ -#define PXP_CONCRETE_FID_PORT_SHIFT 4 -#define PXP_CONCRETE_FID_PATH_MASK 0x1 /* path number */ -#define PXP_CONCRETE_FID_PATH_SHIFT 6 -#define PXP_CONCRETE_FID_VFVALID_MASK 0x1 -#define PXP_CONCRETE_FID_VFVALID_SHIFT 7 -#define PXP_CONCRETE_FID_VFID_MASK 0xFF -#define PXP_CONCRETE_FID_VFID_SHIFT 8 -}; - - -/* - * Concrete Function ID. - */ -struct pxp_pretend_concrete_fid -{ - __le16 fid; -#define PXP_PRETEND_CONCRETE_FID_PFID_MASK 0xF /* Parent PFID */ -#define PXP_PRETEND_CONCRETE_FID_PFID_SHIFT 0 -#define PXP_PRETEND_CONCRETE_FID_RESERVED_MASK 0x7 /* port number. Only when part of ME register. */ -#define PXP_PRETEND_CONCRETE_FID_RESERVED_SHIFT 4 -#define PXP_PRETEND_CONCRETE_FID_VFVALID_MASK 0x1 -#define PXP_PRETEND_CONCRETE_FID_VFVALID_SHIFT 7 -#define PXP_PRETEND_CONCRETE_FID_VFID_MASK 0xFF -#define PXP_PRETEND_CONCRETE_FID_VFID_SHIFT 8 -}; - -/* - * Function ID. - */ -union pxp_pretend_fid -{ - struct pxp_pretend_concrete_fid concrete_fid; - __le16 opaque_fid; -}; - -/* - * Pxp Pretend Command Register. - */ -struct pxp_pretend_cmd -{ - union pxp_pretend_fid fid; - __le16 control; -#define PXP_PRETEND_CMD_PATH_MASK 0x1 -#define PXP_PRETEND_CMD_PATH_SHIFT 0 -#define PXP_PRETEND_CMD_USE_PORT_MASK 0x1 -#define PXP_PRETEND_CMD_USE_PORT_SHIFT 1 -#define PXP_PRETEND_CMD_PORT_MASK 0x3 -#define PXP_PRETEND_CMD_PORT_SHIFT 2 -#define PXP_PRETEND_CMD_RESERVED0_MASK 0xF -#define PXP_PRETEND_CMD_RESERVED0_SHIFT 4 -#define PXP_PRETEND_CMD_RESERVED1_MASK 0xF -#define PXP_PRETEND_CMD_RESERVED1_SHIFT 8 -#define PXP_PRETEND_CMD_PRETEND_PATH_MASK 0x1 /* is pretend mode? */ -#define PXP_PRETEND_CMD_PRETEND_PATH_SHIFT 12 -#define PXP_PRETEND_CMD_PRETEND_PORT_MASK 0x1 /* is pretend mode? */ -#define PXP_PRETEND_CMD_PRETEND_PORT_SHIFT 13 -#define PXP_PRETEND_CMD_PRETEND_FUNCTION_MASK 0x1 /* is pretend mode? */ -#define PXP_PRETEND_CMD_PRETEND_FUNCTION_SHIFT 14 -#define PXP_PRETEND_CMD_IS_CONCRETE_MASK 0x1 /* is fid concrete? */ -#define PXP_PRETEND_CMD_IS_CONCRETE_SHIFT 15 -}; - - - - -/* - * PTT Record in PXP Admin Window. - */ -struct pxp_ptt_entry -{ - __le32 offset; -#define PXP_PTT_ENTRY_OFFSET_MASK 0x7FFFFF -#define PXP_PTT_ENTRY_OFFSET_SHIFT 0 -#define PXP_PTT_ENTRY_RESERVED0_MASK 0x1FF -#define PXP_PTT_ENTRY_RESERVED0_SHIFT 23 - struct pxp_pretend_cmd pretend; -}; - - -/* - * VF Zone A Permission Register. - */ -struct pxp_vf_zone_a_permission -{ - __le32 control; -#define PXP_VF_ZONE_A_PERMISSION_VFID_MASK 0xFF -#define PXP_VF_ZONE_A_PERMISSION_VFID_SHIFT 0 -#define PXP_VF_ZONE_A_PERMISSION_VALID_MASK 0x1 -#define PXP_VF_ZONE_A_PERMISSION_VALID_SHIFT 8 -#define PXP_VF_ZONE_A_PERMISSION_RESERVED0_MASK 0x7F -#define PXP_VF_ZONE_A_PERMISSION_RESERVED0_SHIFT 9 -#define PXP_VF_ZONE_A_PERMISSION_RESERVED1_MASK 0xFFFF -#define PXP_VF_ZONE_A_PERMISSION_RESERVED1_SHIFT 16 -}; - - -/* - * Rdif context - */ -struct rdif_task_context -{ - __le32 initialRefTag; - __le16 appTagValue; - __le16 appTagMask; - uint8_t flags0; -#define RDIF_TASK_CONTEXT_IGNOREAPPTAG_MASK 0x1 -#define RDIF_TASK_CONTEXT_IGNOREAPPTAG_SHIFT 0 -#define RDIF_TASK_CONTEXT_INITIALREFTAGVALID_MASK 0x1 -#define RDIF_TASK_CONTEXT_INITIALREFTAGVALID_SHIFT 1 -#define RDIF_TASK_CONTEXT_HOSTGUARDTYPE_MASK 0x1 /* 0 = IP checksum, 1 = CRC */ -#define RDIF_TASK_CONTEXT_HOSTGUARDTYPE_SHIFT 2 -#define RDIF_TASK_CONTEXT_SETERRORWITHEOP_MASK 0x1 -#define RDIF_TASK_CONTEXT_SETERRORWITHEOP_SHIFT 3 -#define RDIF_TASK_CONTEXT_PROTECTIONTYPE_MASK 0x3 /* 1/2/3 - Protection Type */ -#define RDIF_TASK_CONTEXT_PROTECTIONTYPE_SHIFT 4 -#define RDIF_TASK_CONTEXT_CRC_SEED_MASK 0x1 /* 0=0x0000, 1=0xffff */ -#define RDIF_TASK_CONTEXT_CRC_SEED_SHIFT 6 -#define RDIF_TASK_CONTEXT_KEEPREFTAGCONST_MASK 0x1 /* Keep reference tag constant */ -#define RDIF_TASK_CONTEXT_KEEPREFTAGCONST_SHIFT 7 - uint8_t partialDifData[7]; - __le16 partialCrcValue; - __le16 partialChecksumValue; - __le32 offsetInIO; - __le16 flags1; -#define RDIF_TASK_CONTEXT_VALIDATEGUARD_MASK 0x1 -#define RDIF_TASK_CONTEXT_VALIDATEGUARD_SHIFT 0 -#define RDIF_TASK_CONTEXT_VALIDATEAPPTAG_MASK 0x1 -#define RDIF_TASK_CONTEXT_VALIDATEAPPTAG_SHIFT 1 -#define RDIF_TASK_CONTEXT_VALIDATEREFTAG_MASK 0x1 -#define RDIF_TASK_CONTEXT_VALIDATEREFTAG_SHIFT 2 -#define RDIF_TASK_CONTEXT_FORWARDGUARD_MASK 0x1 -#define RDIF_TASK_CONTEXT_FORWARDGUARD_SHIFT 3 -#define RDIF_TASK_CONTEXT_FORWARDAPPTAG_MASK 0x1 -#define RDIF_TASK_CONTEXT_FORWARDAPPTAG_SHIFT 4 -#define RDIF_TASK_CONTEXT_FORWARDREFTAG_MASK 0x1 -#define RDIF_TASK_CONTEXT_FORWARDREFTAG_SHIFT 5 -#define RDIF_TASK_CONTEXT_INTERVALSIZE_MASK 0x7 /* 0=512B, 1=1KB, 2=2KB, 3=4KB, 4=8KB */ -#define RDIF_TASK_CONTEXT_INTERVALSIZE_SHIFT 6 -#define RDIF_TASK_CONTEXT_HOSTINTERFACE_MASK 0x3 /* 0=None, 1=DIF, 2=DIX */ -#define RDIF_TASK_CONTEXT_HOSTINTERFACE_SHIFT 9 -#define RDIF_TASK_CONTEXT_DIFBEFOREDATA_MASK 0x1 /* DIF tag right at the beginning of DIF interval */ -#define RDIF_TASK_CONTEXT_DIFBEFOREDATA_SHIFT 11 -#define RDIF_TASK_CONTEXT_RESERVED0_MASK 0x1 -#define RDIF_TASK_CONTEXT_RESERVED0_SHIFT 12 -#define RDIF_TASK_CONTEXT_NETWORKINTERFACE_MASK 0x1 /* 0=None, 1=DIF */ -#define RDIF_TASK_CONTEXT_NETWORKINTERFACE_SHIFT 13 -#define RDIF_TASK_CONTEXT_FORWARDAPPTAGWITHMASK_MASK 0x1 /* Forward application tag with mask */ -#define RDIF_TASK_CONTEXT_FORWARDAPPTAGWITHMASK_SHIFT 14 -#define RDIF_TASK_CONTEXT_FORWARDREFTAGWITHMASK_MASK 0x1 /* Forward reference tag with mask */ -#define RDIF_TASK_CONTEXT_FORWARDREFTAGWITHMASK_SHIFT 15 - __le16 state; -#define RDIF_TASK_CONTEXT_RECEIVEDDIFBYTESLEFT_MASK 0xF -#define RDIF_TASK_CONTEXT_RECEIVEDDIFBYTESLEFT_SHIFT 0 -#define RDIF_TASK_CONTEXT_TRANSMITEDDIFBYTESLEFT_MASK 0xF -#define RDIF_TASK_CONTEXT_TRANSMITEDDIFBYTESLEFT_SHIFT 4 -#define RDIF_TASK_CONTEXT_ERRORINIO_MASK 0x1 -#define RDIF_TASK_CONTEXT_ERRORINIO_SHIFT 8 -#define RDIF_TASK_CONTEXT_CHECKSUMOVERFLOW_MASK 0x1 -#define RDIF_TASK_CONTEXT_CHECKSUMOVERFLOW_SHIFT 9 -#define RDIF_TASK_CONTEXT_REFTAGMASK_MASK 0xF /* mask for refernce tag handling */ -#define RDIF_TASK_CONTEXT_REFTAGMASK_SHIFT 10 -#define RDIF_TASK_CONTEXT_RESERVED1_MASK 0x3 -#define RDIF_TASK_CONTEXT_RESERVED1_SHIFT 14 - __le32 reserved2; -}; - - - -/* - * RSS hash type - */ -enum rss_hash_type -{ - RSS_HASH_TYPE_DEFAULT=0, - RSS_HASH_TYPE_IPV4=1, - RSS_HASH_TYPE_TCP_IPV4=2, - RSS_HASH_TYPE_IPV6=3, - RSS_HASH_TYPE_TCP_IPV6=4, - RSS_HASH_TYPE_UDP_IPV4=5, - RSS_HASH_TYPE_UDP_IPV6=6, - MAX_RSS_HASH_TYPE -}; - - -/* - * status block structure - */ -struct status_block -{ - __le16 pi_array[PIS_PER_SB]; - __le32 sb_num; -#define STATUS_BLOCK_SB_NUM_MASK 0x1FF -#define STATUS_BLOCK_SB_NUM_SHIFT 0 -#define STATUS_BLOCK_ZERO_PAD_MASK 0x7F -#define STATUS_BLOCK_ZERO_PAD_SHIFT 9 -#define STATUS_BLOCK_ZERO_PAD2_MASK 0xFFFF -#define STATUS_BLOCK_ZERO_PAD2_SHIFT 16 - __le32 prod_index; -#define STATUS_BLOCK_PROD_INDEX_MASK 0xFFFFFF -#define STATUS_BLOCK_PROD_INDEX_SHIFT 0 -#define STATUS_BLOCK_ZERO_PAD3_MASK 0xFF -#define STATUS_BLOCK_ZERO_PAD3_SHIFT 24 -}; - - -/* - * Tdif context - */ -struct tdif_task_context -{ - __le32 initialRefTag; - __le16 appTagValue; - __le16 appTagMask; - __le16 partialCrcValueB; - __le16 partialChecksumValueB; - __le16 stateB; -#define TDIF_TASK_CONTEXT_RECEIVEDDIFBYTESLEFTB_MASK 0xF -#define TDIF_TASK_CONTEXT_RECEIVEDDIFBYTESLEFTB_SHIFT 0 -#define TDIF_TASK_CONTEXT_TRANSMITEDDIFBYTESLEFTB_MASK 0xF -#define TDIF_TASK_CONTEXT_TRANSMITEDDIFBYTESLEFTB_SHIFT 4 -#define TDIF_TASK_CONTEXT_ERRORINIOB_MASK 0x1 -#define TDIF_TASK_CONTEXT_ERRORINIOB_SHIFT 8 -#define TDIF_TASK_CONTEXT_CHECKSUMOVERFLOW_MASK 0x1 -#define TDIF_TASK_CONTEXT_CHECKSUMOVERFLOW_SHIFT 9 -#define TDIF_TASK_CONTEXT_RESERVED0_MASK 0x3F -#define TDIF_TASK_CONTEXT_RESERVED0_SHIFT 10 - uint8_t reserved1; - uint8_t flags0; -#define TDIF_TASK_CONTEXT_IGNOREAPPTAG_MASK 0x1 -#define TDIF_TASK_CONTEXT_IGNOREAPPTAG_SHIFT 0 -#define TDIF_TASK_CONTEXT_INITIALREFTAGVALID_MASK 0x1 -#define TDIF_TASK_CONTEXT_INITIALREFTAGVALID_SHIFT 1 -#define TDIF_TASK_CONTEXT_HOSTGUARDTYPE_MASK 0x1 /* 0 = IP checksum, 1 = CRC */ -#define TDIF_TASK_CONTEXT_HOSTGUARDTYPE_SHIFT 2 -#define TDIF_TASK_CONTEXT_SETERRORWITHEOP_MASK 0x1 -#define TDIF_TASK_CONTEXT_SETERRORWITHEOP_SHIFT 3 -#define TDIF_TASK_CONTEXT_PROTECTIONTYPE_MASK 0x3 /* 1/2/3 - Protection Type */ -#define TDIF_TASK_CONTEXT_PROTECTIONTYPE_SHIFT 4 -#define TDIF_TASK_CONTEXT_CRC_SEED_MASK 0x1 /* 0=0x0000, 1=0xffff */ -#define TDIF_TASK_CONTEXT_CRC_SEED_SHIFT 6 -#define TDIF_TASK_CONTEXT_RESERVED2_MASK 0x1 -#define TDIF_TASK_CONTEXT_RESERVED2_SHIFT 7 - __le32 flags1; -#define TDIF_TASK_CONTEXT_VALIDATEGUARD_MASK 0x1 -#define TDIF_TASK_CONTEXT_VALIDATEGUARD_SHIFT 0 -#define TDIF_TASK_CONTEXT_VALIDATEAPPTAG_MASK 0x1 -#define TDIF_TASK_CONTEXT_VALIDATEAPPTAG_SHIFT 1 -#define TDIF_TASK_CONTEXT_VALIDATEREFTAG_MASK 0x1 -#define TDIF_TASK_CONTEXT_VALIDATEREFTAG_SHIFT 2 -#define TDIF_TASK_CONTEXT_FORWARDGUARD_MASK 0x1 -#define TDIF_TASK_CONTEXT_FORWARDGUARD_SHIFT 3 -#define TDIF_TASK_CONTEXT_FORWARDAPPTAG_MASK 0x1 -#define TDIF_TASK_CONTEXT_FORWARDAPPTAG_SHIFT 4 -#define TDIF_TASK_CONTEXT_FORWARDREFTAG_MASK 0x1 -#define TDIF_TASK_CONTEXT_FORWARDREFTAG_SHIFT 5 -#define TDIF_TASK_CONTEXT_INTERVALSIZE_MASK 0x7 /* 0=512B, 1=1KB, 2=2KB, 3=4KB, 4=8KB */ -#define TDIF_TASK_CONTEXT_INTERVALSIZE_SHIFT 6 -#define TDIF_TASK_CONTEXT_HOSTINTERFACE_MASK 0x3 /* 0=None, 1=DIF, 2=DIX */ -#define TDIF_TASK_CONTEXT_HOSTINTERFACE_SHIFT 9 -#define TDIF_TASK_CONTEXT_DIFBEFOREDATA_MASK 0x1 /* DIF tag right at the beginning of DIF interval */ -#define TDIF_TASK_CONTEXT_DIFBEFOREDATA_SHIFT 11 -#define TDIF_TASK_CONTEXT_RESERVED3_MASK 0x1 /* reserved */ -#define TDIF_TASK_CONTEXT_RESERVED3_SHIFT 12 -#define TDIF_TASK_CONTEXT_NETWORKINTERFACE_MASK 0x1 /* 0=None, 1=DIF */ -#define TDIF_TASK_CONTEXT_NETWORKINTERFACE_SHIFT 13 -#define TDIF_TASK_CONTEXT_RECEIVEDDIFBYTESLEFTA_MASK 0xF -#define TDIF_TASK_CONTEXT_RECEIVEDDIFBYTESLEFTA_SHIFT 14 -#define TDIF_TASK_CONTEXT_TRANSMITEDDIFBYTESLEFTA_MASK 0xF -#define TDIF_TASK_CONTEXT_TRANSMITEDDIFBYTESLEFTA_SHIFT 18 -#define TDIF_TASK_CONTEXT_ERRORINIOA_MASK 0x1 -#define TDIF_TASK_CONTEXT_ERRORINIOA_SHIFT 22 -#define TDIF_TASK_CONTEXT_CHECKSUMOVERFLOWA_MASK 0x1 -#define TDIF_TASK_CONTEXT_CHECKSUMOVERFLOWA_SHIFT 23 -#define TDIF_TASK_CONTEXT_REFTAGMASK_MASK 0xF /* mask for refernce tag handling */ -#define TDIF_TASK_CONTEXT_REFTAGMASK_SHIFT 24 -#define TDIF_TASK_CONTEXT_FORWARDAPPTAGWITHMASK_MASK 0x1 /* Forward application tag with mask */ -#define TDIF_TASK_CONTEXT_FORWARDAPPTAGWITHMASK_SHIFT 28 -#define TDIF_TASK_CONTEXT_FORWARDREFTAGWITHMASK_MASK 0x1 /* Forward reference tag with mask */ -#define TDIF_TASK_CONTEXT_FORWARDREFTAGWITHMASK_SHIFT 29 -#define TDIF_TASK_CONTEXT_KEEPREFTAGCONST_MASK 0x1 /* Keep reference tag constant */ -#define TDIF_TASK_CONTEXT_KEEPREFTAGCONST_SHIFT 30 -#define TDIF_TASK_CONTEXT_RESERVED4_MASK 0x1 -#define TDIF_TASK_CONTEXT_RESERVED4_SHIFT 31 - __le32 offsetInIOB; - __le16 partialCrcValueA; - __le16 partialChecksumValueA; - __le32 offsetInIOA; - uint8_t partialDifDataA[8]; - uint8_t partialDifDataB[8]; -}; - - -/* - * Timers context - */ -struct timers_context -{ - __le32 logical_client_0; -#define TIMERS_CONTEXT_EXPIRATIONTIMELC0_MASK 0xFFFFFFF /* Expiration time of logical client 0 */ -#define TIMERS_CONTEXT_EXPIRATIONTIMELC0_SHIFT 0 -#define TIMERS_CONTEXT_VALIDLC0_MASK 0x1 /* Valid bit of logical client 0 */ -#define TIMERS_CONTEXT_VALIDLC0_SHIFT 28 -#define TIMERS_CONTEXT_ACTIVELC0_MASK 0x1 /* Active bit of logical client 0 */ -#define TIMERS_CONTEXT_ACTIVELC0_SHIFT 29 -#define TIMERS_CONTEXT_RESERVED0_MASK 0x3 -#define TIMERS_CONTEXT_RESERVED0_SHIFT 30 - __le32 logical_client_1; -#define TIMERS_CONTEXT_EXPIRATIONTIMELC1_MASK 0xFFFFFFF /* Expiration time of logical client 1 */ -#define TIMERS_CONTEXT_EXPIRATIONTIMELC1_SHIFT 0 -#define TIMERS_CONTEXT_VALIDLC1_MASK 0x1 /* Valid bit of logical client 1 */ -#define TIMERS_CONTEXT_VALIDLC1_SHIFT 28 -#define TIMERS_CONTEXT_ACTIVELC1_MASK 0x1 /* Active bit of logical client 1 */ -#define TIMERS_CONTEXT_ACTIVELC1_SHIFT 29 -#define TIMERS_CONTEXT_RESERVED1_MASK 0x3 -#define TIMERS_CONTEXT_RESERVED1_SHIFT 30 - __le32 logical_client_2; -#define TIMERS_CONTEXT_EXPIRATIONTIMELC2_MASK 0xFFFFFFF /* Expiration time of logical client 2 */ -#define TIMERS_CONTEXT_EXPIRATIONTIMELC2_SHIFT 0 -#define TIMERS_CONTEXT_VALIDLC2_MASK 0x1 /* Valid bit of logical client 2 */ -#define TIMERS_CONTEXT_VALIDLC2_SHIFT 28 -#define TIMERS_CONTEXT_ACTIVELC2_MASK 0x1 /* Active bit of logical client 2 */ -#define TIMERS_CONTEXT_ACTIVELC2_SHIFT 29 -#define TIMERS_CONTEXT_RESERVED2_MASK 0x3 -#define TIMERS_CONTEXT_RESERVED2_SHIFT 30 - __le32 host_expiration_fields; -#define TIMERS_CONTEXT_HOSTEXPRIRATIONVALUE_MASK 0xFFFFFFF /* Expiration time on host (closest one) */ -#define TIMERS_CONTEXT_HOSTEXPRIRATIONVALUE_SHIFT 0 -#define TIMERS_CONTEXT_HOSTEXPRIRATIONVALID_MASK 0x1 /* Valid bit of host expiration */ -#define TIMERS_CONTEXT_HOSTEXPRIRATIONVALID_SHIFT 28 -#define TIMERS_CONTEXT_RESERVED3_MASK 0x7 -#define TIMERS_CONTEXT_RESERVED3_SHIFT 29 -}; - - -/* - * Enum for next_protocol field of tunnel_parsing_flags - */ -enum tunnel_next_protocol -{ - e_unknown=0, - e_l2=1, - e_ipv4=2, - e_ipv6=3, - MAX_TUNNEL_NEXT_PROTOCOL -}; - -#endif /* __COMMON_HSI__ */ diff --git a/usr/rdma-core/providers/qedr/qelr.h b/usr/rdma-core/providers/qedr/qelr.h deleted file mode 100644 index 1a5920c66..000000000 --- a/usr/rdma-core/providers/qedr/qelr.h +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __QELR_H__ -#define __QELR_H__ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#define writel(b, p) (*(uint32_t *)(p) = (b)) -#define writeq(b, p) (*(uint64_t *)(p) = (b)) - -#include "qelr_hsi.h" -#include "qelr_chain.h" - -#define qelr_err(format, arg...) printf(format, ##arg) - -extern uint32_t qelr_dp_level; -extern uint32_t qelr_dp_module; - -enum DP_MODULE { - QELR_MSG_CQ = 0x10000, - QELR_MSG_RQ = 0x20000, - QELR_MSG_SQ = 0x40000, - QELR_MSG_QP = (QELR_MSG_SQ | QELR_MSG_RQ), - QELR_MSG_MR = 0x80000, - QELR_MSG_INIT = 0x100000, - /* to be added...up to 0x8000000 */ -}; - -enum DP_LEVEL { - QELR_LEVEL_VERBOSE = 0x0, - QELR_LEVEL_INFO = 0x1, - QELR_LEVEL_NOTICE = 0x2, - QELR_LEVEL_ERR = 0x3, -}; - -#define DP_ERR(fd, fmt, ...) \ -do { \ - fprintf(fd, "[%s:%d]" fmt, \ - __func__, __LINE__, \ - ##__VA_ARGS__); \ - fflush(fd); \ -} while (0) - -#define DP_NOTICE(fd, fmt, ...) \ -do { \ - if (qelr_dp_level <= QELR_LEVEL_NOTICE) {\ - fprintf(fd, "[%s:%d]" fmt, \ - __func__, __LINE__, \ - ##__VA_ARGS__); \ - fflush(fd); } \ -} while (0) - -#define DP_INFO(fd, fmt, ...) \ -do { \ - if (qelr_dp_level <= QELR_LEVEL_INFO) { \ - fprintf(fd, "[%s:%d]" fmt, \ - __func__, __LINE__, \ - ##__VA_ARGS__); fflush(fd); \ - } \ -} while (0) - -#define DP_VERBOSE(fd, module, fmt, ...) \ -do { \ - if ((qelr_dp_level <= QELR_LEVEL_VERBOSE) && \ - (qelr_dp_module & (module))) { \ - fprintf(fd, "[%s:%d]" fmt, \ - __func__, __LINE__, \ - ##__VA_ARGS__); fflush(fd); } \ -} while (0) - -struct qelr_buf { - void *addr; - size_t len; /* a 64 uint is used as s preparation - * for double layer pbl. - */ -}; - -struct qelr_device { - struct verbs_device ibv_dev; -}; - -struct qelr_devctx { - struct ibv_context ibv_ctx; - FILE *dbg_fp; - void *db_addr; - uint64_t db_pa; - uint32_t db_size; - uint8_t disable_edpm; - uint32_t kernel_page_size; - - uint32_t max_send_wr; - uint32_t max_recv_wr; - uint32_t sges_per_send_wr; - uint32_t sges_per_recv_wr; - int max_cqes; -}; - -struct qelr_pd { - struct ibv_pd ibv_pd; - uint32_t pd_id; -}; - -struct qelr_mr { - struct ibv_mr ibv_mr; -}; - -union db_prod64 { - struct rdma_pwm_val32_data data; - uint64_t raw; -}; - -struct qelr_cq { - struct ibv_cq ibv_cq; /* must be first */ - - struct qelr_chain chain; - - void *db_addr; - union db_prod64 db; - - uint8_t chain_toggle; - union rdma_cqe *latest_cqe; - union rdma_cqe *toggle_cqe; - - uint8_t arm_flags; -}; - -enum qelr_qp_state { - QELR_QPS_RST, - QELR_QPS_INIT, - QELR_QPS_RTR, - QELR_QPS_RTS, - QELR_QPS_SQD, - QELR_QPS_ERR, - QELR_QPS_SQE -}; - -union db_prod32 { - struct rdma_pwm_val16_data data; - uint32_t raw; -}; - -struct qelr_qp_hwq_info { - /* WQE */ - struct qelr_chain chain; - uint8_t max_sges; - - /* WQ */ - uint16_t prod; - uint16_t wqe_cons; - uint16_t cons; - uint16_t max_wr; - - /* DB */ - void *db; /* Doorbell address */ - void *edpm_db; - union db_prod32 db_data; /* Doorbell data */ - void *iwarp_db2; - union db_prod32 iwarp_db2_data; - - uint16_t icid; -}; - -struct qelr_rdma_ext { - __be64 remote_va; - __be32 remote_key; - __be32 dma_length; -}; - -/* rdma extension, invalidate / immediate data + padding, inline data... */ -#define QELR_MAX_DPM_PAYLOAD (sizeof(struct qelr_rdma_ext) + sizeof(uint64_t) +\ - ROCE_REQ_MAX_INLINE_DATA_SIZE) -struct qelr_dpm { - uint8_t is_edpm; - union { - struct db_roce_dpm_data data; - uint64_t raw; - } msg; - - uint8_t payload[QELR_MAX_DPM_PAYLOAD]; - uint32_t payload_size; - uint32_t payload_offset; - - struct qelr_rdma_ext *rdma_ext; -}; - -struct qelr_qp { - struct ibv_qp ibv_qp; - pthread_spinlock_t q_lock; - enum qelr_qp_state state; /* QP state */ - - struct qelr_qp_hwq_info sq; - struct qelr_qp_hwq_info rq; - struct { - uint64_t wr_id; - enum ibv_wc_opcode opcode; - uint32_t bytes_len; - uint8_t wqe_size; - uint8_t signaled; - } *wqe_wr_id; - - struct { - uint64_t wr_id; - uint8_t wqe_size; - } *rqe_wr_id; - - uint8_t prev_wqe_size; - uint32_t max_inline_data; - uint32_t qp_id; - int sq_sig_all; - int atomic_supported; - uint8_t edpm_disabled; -}; - -static inline struct qelr_devctx *get_qelr_ctx(struct ibv_context *ibctx) -{ - return container_of(ibctx, struct qelr_devctx, ibv_ctx); -} - -static inline struct qelr_device *get_qelr_dev(struct ibv_device *ibdev) -{ - return container_of(ibdev, struct qelr_device, ibv_dev); -} - -static inline struct qelr_qp *get_qelr_qp(struct ibv_qp *ibqp) -{ - return container_of(ibqp, struct qelr_qp, ibv_qp); -} - -static inline struct qelr_pd *get_qelr_pd(struct ibv_pd *ibpd) -{ - return container_of(ibpd, struct qelr_pd, ibv_pd); -} - -static inline struct qelr_cq *get_qelr_cq(struct ibv_cq *ibcq) -{ - return container_of(ibcq, struct qelr_cq, ibv_cq); -} - -#define SET_FIELD(value, name, flag) \ - do { \ - (value) &= ~(name ## _MASK << name ## _SHIFT); \ - (value) |= ((flag) << (name ## _SHIFT)); \ - } while (0) - -#define SET_FIELD2(value, name, flag) \ - ((value) |= ((flag) << (name ## _SHIFT))) - -#define GET_FIELD(value, name) \ - (((value) >> (name ## _SHIFT)) & name ## _MASK) - -#define ROCE_WQE_ELEM_SIZE sizeof(struct rdma_sq_sge) -#define RDMA_WQE_BYTES (16) - -#define QELR_RESP_IMM (RDMA_CQE_RESPONDER_IMM_FLG_MASK << \ - RDMA_CQE_RESPONDER_IMM_FLG_SHIFT) -#define QELR_RESP_RDMA (RDMA_CQE_RESPONDER_RDMA_FLG_MASK << \ - RDMA_CQE_RESPONDER_RDMA_FLG_SHIFT) -#define QELR_RESP_RDMA_IMM (QELR_RESP_IMM | QELR_RESP_RDMA) - -#define TYPEPTR_ADDR_SET(type_ptr, field, vaddr) \ - do { \ - (type_ptr)->field.hi = htole32(U64_HI(vaddr)); \ - (type_ptr)->field.lo = htole32(U64_LO(vaddr)); \ - } while (0) - -#define RQ_SGE_SET(sge, vaddr, vlength, vflags) \ - do { \ - TYPEPTR_ADDR_SET(sge, addr, vaddr); \ - (sge)->length = htole32(vlength); \ - (sge)->flags = htole32(vflags); \ - } while (0) - -#define U64_HI(val) ((uint32_t)(((uint64_t)(uintptr_t)(val)) >> 32)) -#define U64_LO(val) ((uint32_t)(((uint64_t)(uintptr_t)(val)) & 0xffffffff)) -#define HILO_U64(hi, lo) ((uintptr_t)((((uint64_t)(hi)) << 32) + (lo))) - -#define QELR_MAX_RQ_WQE_SIZE (RDMA_MAX_SGE_PER_RQ_WQE) -#define QELR_MAX_SQ_WQE_SIZE (ROCE_REQ_MAX_SINGLE_SQ_WQE_SIZE / \ - ROCE_WQE_ELEM_SIZE) - -#endif /* __QELR_H__ */ diff --git a/usr/rdma-core/providers/qedr/qelr_abi.h b/usr/rdma-core/providers/qedr/qelr_abi.h deleted file mode 100644 index a7a0638e9..000000000 --- a/usr/rdma-core/providers/qedr/qelr_abi.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __QELR_ABI_H__ -#define __QELR_ABI_H__ - -#include - -#define QELR_ABI_VERSION (8) - -struct qelr_get_context { - struct ibv_get_context cmd; /* must be first */ -}; - -struct qelr_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; /* must be first */ - __u64 db_pa; - __u32 db_size; - - __u32 max_send_wr; - __u32 max_recv_wr; - __u32 max_srq_wr; - __u32 sges_per_send_wr; - __u32 sges_per_recv_wr; - __u32 sges_per_srq_wr; - __u32 max_cqes; -}; - -struct qelr_alloc_pd_req { - struct ibv_alloc_pd cmd; /* must be first */ -}; - -struct qelr_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; /* must be first */ - __u32 pd_id; -}; - -struct qelr_create_cq_req { - struct ibv_create_cq ibv_cmd; /* must be first */ - - __u64 addr; /* user space virtual address of CQ buffer */ - __u64 len; /* size of CQ buffer */ -}; - -struct qelr_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; /* must be first */ - __u32 db_offset; - __u16 icid; -}; - -struct qelr_reg_mr { - struct ibv_reg_mr ibv_cmd; /* must be first */ -}; - -struct qelr_reg_mr_resp { - struct ibv_reg_mr_resp ibv_resp; /* must be first */ -}; - -struct qelr_create_qp_req { - struct ibv_create_qp ibv_qp; /* must be first */ - - __u32 qp_handle_hi; - __u32 qp_handle_lo; - - /* SQ */ - __u64 sq_addr; /* user space virtual address of SQ buffer */ - __u64 sq_len; /* length of SQ buffer */ - - /* RQ */ - __u64 rq_addr; /* user space virtual address of RQ buffer */ - __u64 rq_len; /* length of RQ buffer */ -}; - -struct qelr_create_qp_resp { - struct ibv_create_qp_resp ibv_resp; /* must be first */ - - __u32 qp_id; - __u32 atomic_supported; - - /* SQ */ - __u32 sq_db_offset; - __u16 sq_icid; - - /* RQ */ - __u32 rq_db_offset; - __u16 rq_icid; - - __u32 rq_db2_offset; -}; - -#endif /* __QELR_ABI_H__ */ diff --git a/usr/rdma-core/providers/qedr/qelr_chain.c b/usr/rdma-core/providers/qedr/qelr_chain.c deleted file mode 100644 index 26d0d0aa4..000000000 --- a/usr/rdma-core/providers/qedr/qelr_chain.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -#include "qelr.h" - -void *qelr_chain_get_last_elem(struct qelr_chain *p_chain) -{ - void *p_virt_addr = NULL; - uint32_t size; - - if (!p_chain->first_addr) - goto out; - - size = p_chain->elem_size * (p_chain->n_elems - 1); - p_virt_addr = ((uint8_t *)p_chain->first_addr + size); -out: - return p_virt_addr; -} - -void qelr_chain_reset(struct qelr_chain *p_chain) -{ - p_chain->prod_idx = 0; - p_chain->cons_idx = 0; - - p_chain->p_cons_elem = p_chain->first_addr; - p_chain->p_prod_elem = p_chain->first_addr; -} - -#define QELR_ANON_FD (-1) /* MAP_ANONYMOUS => file desc.= -1 */ -#define QELR_ANON_OFFSET (0) /* MAP_ANONYMOUS => offset = d/c */ - -int qelr_chain_alloc(struct qelr_chain *chain, int chain_size, int page_size, - uint16_t elem_size) -{ - int ret, a_chain_size; - void *addr; - - /* alloc aligned page aligned chain */ - a_chain_size = (chain_size + page_size - 1) & ~(page_size - 1); - addr = mmap(NULL, a_chain_size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, QELR_ANON_FD, - QELR_ANON_OFFSET); - if (addr == MAP_FAILED) - return errno; - - ret = ibv_dontfork_range(addr, a_chain_size); - if (ret) { - munmap(addr, a_chain_size); - return ret; - } - - /* init chain */ - memset(chain, 0, sizeof(*chain)); - chain->first_addr = addr; - chain->size = a_chain_size; - chain->p_cons_elem = chain->first_addr; - chain->p_prod_elem = chain->first_addr; - chain->elem_size = elem_size; - chain->n_elems = chain->size / elem_size; - chain->last_addr = (void *) - ((uint8_t *)addr + (elem_size * (chain->n_elems -1))); - - /* Note: since we are using MAP_ANONYMOUS the chain is zeroed for us */ - - return 0; -} - -void qelr_chain_free(struct qelr_chain *chain) -{ - if (chain->size) { - ibv_dofork_range(chain->first_addr, chain->size); - munmap(chain->first_addr, chain->size); - } -} diff --git a/usr/rdma-core/providers/qedr/qelr_chain.h b/usr/rdma-core/providers/qedr/qelr_chain.h deleted file mode 100644 index 5b6e324eb..000000000 --- a/usr/rdma-core/providers/qedr/qelr_chain.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __QELR_CHAIN_H__ -#define __QELR_CHAIN_H__ - -#include -#include - -struct qelr_chain { - void *first_addr; /* Address of first element in chain */ - void *last_addr; /* Address of last element in chain */ - - /* Point to next element to produce/consume */ - void *p_prod_elem; - void *p_cons_elem; - - uint32_t prod_idx; - uint32_t cons_idx; - - uint32_t n_elems; - uint32_t size; - uint16_t elem_size; -}; - -/* fast path functions are inline */ - -static inline uint32_t qelr_chain_get_cons_idx_u32(struct qelr_chain *p_chain) -{ - return p_chain->cons_idx; -} - -static inline void *qelr_chain_produce(struct qelr_chain *p_chain) -{ - void *p_ret = NULL; - - p_chain->prod_idx++; - - p_ret = p_chain->p_prod_elem; - - if (p_chain->p_prod_elem == p_chain->last_addr) - p_chain->p_prod_elem = p_chain->first_addr; - else - p_chain->p_prod_elem = (void *)(((uint8_t *)p_chain->p_prod_elem) + - p_chain->elem_size); - - return p_ret; -} - -static inline void *qelr_chain_produce_n(struct qelr_chain *p_chain, int n) -{ - void *p_ret = NULL; - int n_wrap; - - p_chain->prod_idx++; - p_ret = p_chain->p_prod_elem; - - n_wrap = p_chain->prod_idx % p_chain->n_elems; - if (n_wrap < n) - p_chain->p_prod_elem = (void *) - (((uint8_t *)p_chain->first_addr) + - (p_chain->elem_size * n_wrap)); - else - p_chain->p_prod_elem = (void *)(((uint8_t *)p_chain->p_prod_elem) + - (p_chain->elem_size * n)); - - return p_ret; -} - -static inline void *qelr_chain_consume(struct qelr_chain *p_chain) -{ - void *p_ret = NULL; - - p_chain->cons_idx++; - - p_ret = p_chain->p_cons_elem; - - if (p_chain->p_cons_elem == p_chain->last_addr) - p_chain->p_cons_elem = p_chain->first_addr; - else - p_chain->p_cons_elem = (void *) - (((uint8_t *)p_chain->p_cons_elem) + - p_chain->elem_size); - - return p_ret; -} - -static inline void *qelr_chain_consume_n(struct qelr_chain *p_chain, int n) -{ - void *p_ret = NULL; - int n_wrap; - - p_chain->cons_idx += n; - p_ret = p_chain->p_cons_elem; - - n_wrap = p_chain->cons_idx % p_chain->n_elems; - if (n_wrap < n) - p_chain->p_cons_elem = (void *) - (((uint8_t *)p_chain->first_addr) + - (p_chain->elem_size * n_wrap)); - else - p_chain->p_cons_elem = (void *)(((uint8_t *)p_chain->p_cons_elem) + - (p_chain->elem_size * n)); - - return p_ret; -} - -static inline uint32_t qelr_chain_get_elem_left_u32(struct qelr_chain *p_chain) -{ - uint32_t used; - - used = (uint32_t)(((uint64_t)((uint64_t) ~0U) + 1 + - (uint64_t)(p_chain->prod_idx)) - - (uint64_t)p_chain->cons_idx); - - return p_chain->n_elems - used; -} - -static inline uint8_t qelr_chain_is_full(struct qelr_chain *p_chain) -{ - return qelr_chain_get_elem_left_u32(p_chain) == p_chain->n_elems; -} - -static inline void qelr_chain_set_prod( - struct qelr_chain *p_chain, - uint32_t prod_idx, - void *p_prod_elem) -{ - p_chain->prod_idx = prod_idx; - p_chain->p_prod_elem = p_prod_elem; -} - -void *qelr_chain_get_last_elem(struct qelr_chain *p_chain); -void qelr_chain_reset(struct qelr_chain *p_chain); -int qelr_chain_alloc(struct qelr_chain *chain, int chain_size, int page_size, - uint16_t elem_size); -void qelr_chain_free(struct qelr_chain *buf); - -#endif /* __QELR_CHAIN_H__ */ diff --git a/usr/rdma-core/providers/qedr/qelr_hsi.h b/usr/rdma-core/providers/qedr/qelr_hsi.h deleted file mode 100644 index 8eaf18313..000000000 --- a/usr/rdma-core/providers/qedr/qelr_hsi.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __QED_HSI_ROCE__ -#define __QED_HSI_ROCE__ -/********************************/ -/* Add include to common target */ -/********************************/ -#include "common_hsi.h" - -/************************************************************************/ -/* Add include to common roce target for both eCore and protocol roce driver */ -/************************************************************************/ -#include "roce_common.h" -/************************************************************************/ -/* Add include to qed hsi rdma target for both roce and iwarp qed driver */ -/************************************************************************/ -#include "qelr_hsi_rdma.h" - -/* Affiliated asynchronous events / errors enumeration */ -enum roce_async_events_type -{ - ROCE_ASYNC_EVENT_NONE, - ROCE_ASYNC_EVENT_COMM_EST, - ROCE_ASYNC_EVENT_SQ_DRAINED, - ROCE_ASYNC_EVENT_SRQ_LIMIT, - ROCE_ASYNC_EVENT_LAST_WQE_REACHED, - ROCE_ASYNC_EVENT_CQ_ERR, - ROCE_ASYNC_EVENT_LOCAL_INVALID_REQUEST_ERR, - ROCE_ASYNC_EVENT_LOCAL_CATASTROPHIC_ERR, - ROCE_ASYNC_EVENT_LOCAL_ACCESS_ERR, - ROCE_ASYNC_EVENT_QP_CATASTROPHIC_ERR, - ROCE_ASYNC_EVENT_CQ_OVERFLOW_ERR, - ROCE_ASYNC_EVENT_SRQ_EMPTY, - MAX_ROCE_ASYNC_EVENTS_TYPE -}; - -#endif /* __QED_HSI_ROCE__ */ diff --git a/usr/rdma-core/providers/qedr/qelr_hsi_rdma.h b/usr/rdma-core/providers/qedr/qelr_hsi_rdma.h deleted file mode 100644 index ced75d47c..000000000 --- a/usr/rdma-core/providers/qedr/qelr_hsi_rdma.h +++ /dev/null @@ -1,913 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __QED_HSI_RDMA__ -#define __QED_HSI_RDMA__ - -#include "common_hsi.h" -#include "rdma_common.h" - -/* - * rdma completion notification queue element - */ -struct rdma_cnqe -{ - struct regpair cq_handle; -}; - - -struct rdma_cqe_responder -{ - struct regpair srq_wr_id; - struct regpair qp_handle; - __le32 imm_data_or_inv_r_Key /* immediate data in case imm_flg is set, or invalidated r_key in case inv_flg is set */; - __le32 length; - __le32 imm_data_hi /* High bytes of immediate data in case imm_flg is set in iWARP only */; - __le16 rq_cons /* Valid only when status is WORK_REQUEST_FLUSHED_ERR. Indicates an aggregative flush on all posted RQ WQEs until the reported rq_cons. */; - uint8_t flags; -#define RDMA_CQE_RESPONDER_TOGGLE_BIT_MASK 0x1 /* indicates a valid completion written by FW. FW toggle this bit each time it finishes producing all PBL entries */ -#define RDMA_CQE_RESPONDER_TOGGLE_BIT_SHIFT 0 -#define RDMA_CQE_RESPONDER_TYPE_MASK 0x3 /* (use enum rdma_cqe_type) */ -#define RDMA_CQE_RESPONDER_TYPE_SHIFT 1 -#define RDMA_CQE_RESPONDER_INV_FLG_MASK 0x1 /* r_key invalidated indicator */ -#define RDMA_CQE_RESPONDER_INV_FLG_SHIFT 3 -#define RDMA_CQE_RESPONDER_IMM_FLG_MASK 0x1 /* immediate data indicator */ -#define RDMA_CQE_RESPONDER_IMM_FLG_SHIFT 4 -#define RDMA_CQE_RESPONDER_RDMA_FLG_MASK 0x1 /* 1=this CQE relates to an RDMA Write. 0=Send. */ -#define RDMA_CQE_RESPONDER_RDMA_FLG_SHIFT 5 -#define RDMA_CQE_RESPONDER_RESERVED2_MASK 0x3 -#define RDMA_CQE_RESPONDER_RESERVED2_SHIFT 6 - uint8_t status; -}; - -struct rdma_cqe_requester -{ - __le16 sq_cons; - __le16 reserved0; - __le32 reserved1; - struct regpair qp_handle; - struct regpair reserved2; - __le32 reserved3; - __le16 reserved4; - uint8_t flags; -#define RDMA_CQE_REQUESTER_TOGGLE_BIT_MASK 0x1 /* indicates a valid completion written by FW. FW toggle this bit each time it finishes producing all PBL entries */ -#define RDMA_CQE_REQUESTER_TOGGLE_BIT_SHIFT 0 -#define RDMA_CQE_REQUESTER_TYPE_MASK 0x3 /* (use enum rdma_cqe_type) */ -#define RDMA_CQE_REQUESTER_TYPE_SHIFT 1 -#define RDMA_CQE_REQUESTER_RESERVED5_MASK 0x1F -#define RDMA_CQE_REQUESTER_RESERVED5_SHIFT 3 - uint8_t status; -}; - -struct rdma_cqe_common -{ - struct regpair reserved0; - struct regpair qp_handle; - __le16 reserved1[7]; - uint8_t flags; -#define RDMA_CQE_COMMON_TOGGLE_BIT_MASK 0x1 /* indicates a valid completion written by FW. FW toggle this bit each time it finishes producing all PBL entries */ -#define RDMA_CQE_COMMON_TOGGLE_BIT_SHIFT 0 -#define RDMA_CQE_COMMON_TYPE_MASK 0x3 /* (use enum rdma_cqe_type) */ -#define RDMA_CQE_COMMON_TYPE_SHIFT 1 -#define RDMA_CQE_COMMON_RESERVED2_MASK 0x1F -#define RDMA_CQE_COMMON_RESERVED2_SHIFT 3 - uint8_t status; -}; - -/* - * rdma completion queue element - */ -union rdma_cqe -{ - struct rdma_cqe_responder resp; - struct rdma_cqe_requester req; - struct rdma_cqe_common cmn; -}; - - - - -/* - * CQE requester status enumeration - */ -enum rdma_cqe_requester_status_enum -{ - RDMA_CQE_REQ_STS_OK, - RDMA_CQE_REQ_STS_BAD_RESPONSE_ERR, - RDMA_CQE_REQ_STS_LOCAL_LENGTH_ERR, - RDMA_CQE_REQ_STS_LOCAL_QP_OPERATION_ERR, - RDMA_CQE_REQ_STS_LOCAL_PROTECTION_ERR, - RDMA_CQE_REQ_STS_MEMORY_MGT_OPERATION_ERR, - RDMA_CQE_REQ_STS_REMOTE_INVALID_REQUEST_ERR, - RDMA_CQE_REQ_STS_REMOTE_ACCESS_ERR, - RDMA_CQE_REQ_STS_REMOTE_OPERATION_ERR, - RDMA_CQE_REQ_STS_RNR_NAK_RETRY_CNT_ERR, - RDMA_CQE_REQ_STS_TRANSPORT_RETRY_CNT_ERR, - RDMA_CQE_REQ_STS_WORK_REQUEST_FLUSHED_ERR, - MAX_RDMA_CQE_REQUESTER_STATUS_ENUM -}; - - - -/* - * CQE responder status enumeration - */ -enum rdma_cqe_responder_status_enum -{ - RDMA_CQE_RESP_STS_OK, - RDMA_CQE_RESP_STS_LOCAL_ACCESS_ERR, - RDMA_CQE_RESP_STS_LOCAL_LENGTH_ERR, - RDMA_CQE_RESP_STS_LOCAL_QP_OPERATION_ERR, - RDMA_CQE_RESP_STS_LOCAL_PROTECTION_ERR, - RDMA_CQE_RESP_STS_MEMORY_MGT_OPERATION_ERR, - RDMA_CQE_RESP_STS_REMOTE_INVALID_REQUEST_ERR, - RDMA_CQE_RESP_STS_WORK_REQUEST_FLUSHED_ERR, - MAX_RDMA_CQE_RESPONDER_STATUS_ENUM -}; - - -/* - * CQE type enumeration - */ -enum rdma_cqe_type -{ - RDMA_CQE_TYPE_REQUESTER, - RDMA_CQE_TYPE_RESPONDER_RQ, - RDMA_CQE_TYPE_RESPONDER_SRQ, - RDMA_CQE_TYPE_INVALID, - MAX_RDMA_CQE_TYPE -}; - - -/* - * DIF Block size options - */ -enum rdma_dif_block_size -{ - RDMA_DIF_BLOCK_512=0, - RDMA_DIF_BLOCK_4096=1, - MAX_RDMA_DIF_BLOCK_SIZE -}; - - -/* - * DIF CRC initial value - */ -enum rdma_dif_crc_seed -{ - RDMA_DIF_CRC_SEED_0000=0, - RDMA_DIF_CRC_SEED_FFFF=1, - MAX_RDMA_DIF_CRC_SEED -}; - - -/* - * RDMA DIF Error Result Structure - */ -struct rdma_dif_error_result -{ - __le32 error_intervals /* Total number of error intervals in the IO. */; - __le32 dif_error_1st_interval /* Number of the first interval that contained error. Set to 0xFFFFFFFF if error occurred in the Runt Block. */; - uint8_t flags; -#define RDMA_DIF_ERROR_RESULT_DIF_ERROR_TYPE_CRC_MASK 0x1 /* CRC error occurred. */ -#define RDMA_DIF_ERROR_RESULT_DIF_ERROR_TYPE_CRC_SHIFT 0 -#define RDMA_DIF_ERROR_RESULT_DIF_ERROR_TYPE_APP_TAG_MASK 0x1 /* App Tag error occurred. */ -#define RDMA_DIF_ERROR_RESULT_DIF_ERROR_TYPE_APP_TAG_SHIFT 1 -#define RDMA_DIF_ERROR_RESULT_DIF_ERROR_TYPE_REF_TAG_MASK 0x1 /* Ref Tag error occurred. */ -#define RDMA_DIF_ERROR_RESULT_DIF_ERROR_TYPE_REF_TAG_SHIFT 2 -#define RDMA_DIF_ERROR_RESULT_RESERVED0_MASK 0xF -#define RDMA_DIF_ERROR_RESULT_RESERVED0_SHIFT 3 -#define RDMA_DIF_ERROR_RESULT_TOGGLE_BIT_MASK 0x1 /* Used to indicate the structure is valid. Toggles each time an invalidate region is performed. */ -#define RDMA_DIF_ERROR_RESULT_TOGGLE_BIT_SHIFT 7 - uint8_t reserved1[55] /* Pad to 64 bytes to ensure efficient word line writing. */; -}; - - -/* - * DIF IO direction - */ -enum rdma_dif_io_direction_flg -{ - RDMA_DIF_DIR_RX=0, - RDMA_DIF_DIR_TX=1, - MAX_RDMA_DIF_IO_DIRECTION_FLG -}; - - -/* - * RDMA DIF Runt Result Structure - */ -struct rdma_dif_runt_result -{ - __le16 guard_tag /* CRC result of received IO. */; - __le16 reserved[3]; -}; - - -/* - * memory window type enumeration - */ -enum rdma_mw_type -{ - RDMA_MW_TYPE_1, - RDMA_MW_TYPE_2A, - MAX_RDMA_MW_TYPE -}; - - -struct rdma_rq_sge -{ - struct regpair addr; - __le32 length; - __le32 flags; -#define RDMA_RQ_SGE_L_KEY_MASK 0x3FFFFFF /* key of memory relating to this RQ */ -#define RDMA_RQ_SGE_L_KEY_SHIFT 0 -#define RDMA_RQ_SGE_NUM_SGES_MASK 0x7 /* first SGE - number of SGEs in this RQ WQE. Other SGEs - should be set to 0 */ -#define RDMA_RQ_SGE_NUM_SGES_SHIFT 26 -#define RDMA_RQ_SGE_RESERVED0_MASK 0x7 -#define RDMA_RQ_SGE_RESERVED0_SHIFT 29 -}; - - -struct rdma_sq_atomic_wqe -{ - __le32 reserved1; - __le32 length /* Total data length (8 bytes for Atomic) */; - __le32 xrc_srq /* Valid only when XRC is set for the QP */; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_ATOMIC_WQE_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_ATOMIC_WQE_COMP_FLG_SHIFT 0 -#define RDMA_SQ_ATOMIC_WQE_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_ATOMIC_WQE_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_ATOMIC_WQE_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_ATOMIC_WQE_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_ATOMIC_WQE_SE_FLG_MASK 0x1 /* Don't care for atomic wqe */ -#define RDMA_SQ_ATOMIC_WQE_SE_FLG_SHIFT 3 -#define RDMA_SQ_ATOMIC_WQE_INLINE_FLG_MASK 0x1 /* Should be 0 for atomic wqe */ -#define RDMA_SQ_ATOMIC_WQE_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_ATOMIC_WQE_DIF_ON_HOST_FLG_MASK 0x1 /* Should be 0 for atomic wqe */ -#define RDMA_SQ_ATOMIC_WQE_DIF_ON_HOST_FLG_SHIFT 5 -#define RDMA_SQ_ATOMIC_WQE_RESERVED0_MASK 0x3 -#define RDMA_SQ_ATOMIC_WQE_RESERVED0_SHIFT 6 - uint8_t wqe_size /* Size of WQE in 16B chunks including SGE */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; - struct regpair remote_va /* remote virtual address */; - __le32 r_key /* Remote key */; - __le32 reserved2; - struct regpair cmp_data /* Data to compare in case of ATOMIC_CMP_AND_SWAP */; - struct regpair swap_data /* Swap or add data */; -}; - - -/* - * First element (16 bytes) of atomic wqe - */ -struct rdma_sq_atomic_wqe_1st -{ - __le32 reserved1; - __le32 length /* Total data length (8 bytes for Atomic) */; - __le32 xrc_srq /* Valid only when XRC is set for the QP */; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_ATOMIC_WQE_1ST_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_ATOMIC_WQE_1ST_COMP_FLG_SHIFT 0 -#define RDMA_SQ_ATOMIC_WQE_1ST_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_ATOMIC_WQE_1ST_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_ATOMIC_WQE_1ST_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_ATOMIC_WQE_1ST_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_ATOMIC_WQE_1ST_SE_FLG_MASK 0x1 /* Don't care for atomic wqe */ -#define RDMA_SQ_ATOMIC_WQE_1ST_SE_FLG_SHIFT 3 -#define RDMA_SQ_ATOMIC_WQE_1ST_INLINE_FLG_MASK 0x1 /* Should be 0 for atomic wqe */ -#define RDMA_SQ_ATOMIC_WQE_1ST_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_ATOMIC_WQE_1ST_RESERVED0_MASK 0x7 -#define RDMA_SQ_ATOMIC_WQE_1ST_RESERVED0_SHIFT 5 - uint8_t wqe_size /* Size of WQE in 16B chunks including all SGEs. Set to number of SGEs + 1. */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; -}; - - -/* - * Second element (16 bytes) of atomic wqe - */ -struct rdma_sq_atomic_wqe_2nd -{ - struct regpair remote_va /* remote virtual address */; - __le32 r_key /* Remote key */; - __le32 reserved2; -}; - - -/* - * Third element (16 bytes) of atomic wqe - */ -struct rdma_sq_atomic_wqe_3rd -{ - struct regpair cmp_data /* Data to compare in case of ATOMIC_CMP_AND_SWAP */; - struct regpair swap_data /* Swap or add data */; -}; - - -struct rdma_sq_bind_wqe -{ - struct regpair addr; - __le32 l_key; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_BIND_WQE_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_BIND_WQE_COMP_FLG_SHIFT 0 -#define RDMA_SQ_BIND_WQE_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_BIND_WQE_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_BIND_WQE_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_BIND_WQE_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_BIND_WQE_SE_FLG_MASK 0x1 /* Don't care for bind wqe */ -#define RDMA_SQ_BIND_WQE_SE_FLG_SHIFT 3 -#define RDMA_SQ_BIND_WQE_INLINE_FLG_MASK 0x1 /* Should be 0 for bind wqe */ -#define RDMA_SQ_BIND_WQE_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_BIND_WQE_RESERVED0_MASK 0x7 -#define RDMA_SQ_BIND_WQE_RESERVED0_SHIFT 5 - uint8_t wqe_size /* Size of WQE in 16B chunks */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; - uint8_t bind_ctrl; -#define RDMA_SQ_BIND_WQE_ZERO_BASED_MASK 0x1 /* zero based indication */ -#define RDMA_SQ_BIND_WQE_ZERO_BASED_SHIFT 0 -#define RDMA_SQ_BIND_WQE_MW_TYPE_MASK 0x1 /* (use enum rdma_mw_type) */ -#define RDMA_SQ_BIND_WQE_MW_TYPE_SHIFT 1 -#define RDMA_SQ_BIND_WQE_RESERVED1_MASK 0x3F -#define RDMA_SQ_BIND_WQE_RESERVED1_SHIFT 2 - uint8_t access_ctrl; -#define RDMA_SQ_BIND_WQE_REMOTE_READ_MASK 0x1 -#define RDMA_SQ_BIND_WQE_REMOTE_READ_SHIFT 0 -#define RDMA_SQ_BIND_WQE_REMOTE_WRITE_MASK 0x1 -#define RDMA_SQ_BIND_WQE_REMOTE_WRITE_SHIFT 1 -#define RDMA_SQ_BIND_WQE_ENABLE_ATOMIC_MASK 0x1 -#define RDMA_SQ_BIND_WQE_ENABLE_ATOMIC_SHIFT 2 -#define RDMA_SQ_BIND_WQE_LOCAL_READ_MASK 0x1 -#define RDMA_SQ_BIND_WQE_LOCAL_READ_SHIFT 3 -#define RDMA_SQ_BIND_WQE_LOCAL_WRITE_MASK 0x1 -#define RDMA_SQ_BIND_WQE_LOCAL_WRITE_SHIFT 4 -#define RDMA_SQ_BIND_WQE_RESERVED2_MASK 0x7 -#define RDMA_SQ_BIND_WQE_RESERVED2_SHIFT 5 - uint8_t reserved3; - uint8_t length_hi /* upper 8 bits of the registered MW length */; - __le32 length_lo /* lower 32 bits of the registered MW length */; - __le32 parent_l_key /* l_key of the parent MR */; - __le32 reserved4; -}; - - -/* - * First element (16 bytes) of bind wqe - */ -struct rdma_sq_bind_wqe_1st -{ - struct regpair addr; - __le32 l_key; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_BIND_WQE_1ST_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_BIND_WQE_1ST_COMP_FLG_SHIFT 0 -#define RDMA_SQ_BIND_WQE_1ST_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_BIND_WQE_1ST_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_BIND_WQE_1ST_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_BIND_WQE_1ST_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_BIND_WQE_1ST_SE_FLG_MASK 0x1 /* Don't care for bind wqe */ -#define RDMA_SQ_BIND_WQE_1ST_SE_FLG_SHIFT 3 -#define RDMA_SQ_BIND_WQE_1ST_INLINE_FLG_MASK 0x1 /* Should be 0 for bind wqe */ -#define RDMA_SQ_BIND_WQE_1ST_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_BIND_WQE_1ST_RESERVED0_MASK 0x7 -#define RDMA_SQ_BIND_WQE_1ST_RESERVED0_SHIFT 5 - uint8_t wqe_size /* Size of WQE in 16B chunks */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; -}; - - -/* - * Second element (16 bytes) of bind wqe - */ -struct rdma_sq_bind_wqe_2nd -{ - uint8_t bind_ctrl; -#define RDMA_SQ_BIND_WQE_2ND_ZERO_BASED_MASK 0x1 /* zero based indication */ -#define RDMA_SQ_BIND_WQE_2ND_ZERO_BASED_SHIFT 0 -#define RDMA_SQ_BIND_WQE_2ND_MW_TYPE_MASK 0x1 /* (use enum rdma_mw_type) */ -#define RDMA_SQ_BIND_WQE_2ND_MW_TYPE_SHIFT 1 -#define RDMA_SQ_BIND_WQE_2ND_RESERVED1_MASK 0x3F -#define RDMA_SQ_BIND_WQE_2ND_RESERVED1_SHIFT 2 - uint8_t access_ctrl; -#define RDMA_SQ_BIND_WQE_2ND_REMOTE_READ_MASK 0x1 -#define RDMA_SQ_BIND_WQE_2ND_REMOTE_READ_SHIFT 0 -#define RDMA_SQ_BIND_WQE_2ND_REMOTE_WRITE_MASK 0x1 -#define RDMA_SQ_BIND_WQE_2ND_REMOTE_WRITE_SHIFT 1 -#define RDMA_SQ_BIND_WQE_2ND_ENABLE_ATOMIC_MASK 0x1 -#define RDMA_SQ_BIND_WQE_2ND_ENABLE_ATOMIC_SHIFT 2 -#define RDMA_SQ_BIND_WQE_2ND_LOCAL_READ_MASK 0x1 -#define RDMA_SQ_BIND_WQE_2ND_LOCAL_READ_SHIFT 3 -#define RDMA_SQ_BIND_WQE_2ND_LOCAL_WRITE_MASK 0x1 -#define RDMA_SQ_BIND_WQE_2ND_LOCAL_WRITE_SHIFT 4 -#define RDMA_SQ_BIND_WQE_2ND_RESERVED2_MASK 0x7 -#define RDMA_SQ_BIND_WQE_2ND_RESERVED2_SHIFT 5 - uint8_t reserved3; - uint8_t length_hi /* upper 8 bits of the registered MW length */; - __le32 length_lo /* lower 32 bits of the registered MW length */; - __le32 parent_l_key /* l_key of the parent MR */; - __le32 reserved4; -}; - - -/* - * Structure with only the SQ WQE common fields. Size is of one SQ element (16B) - */ -struct rdma_sq_common_wqe -{ - __le32 reserved1[3]; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_COMMON_WQE_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_COMMON_WQE_COMP_FLG_SHIFT 0 -#define RDMA_SQ_COMMON_WQE_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_COMMON_WQE_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_COMMON_WQE_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_COMMON_WQE_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_COMMON_WQE_SE_FLG_MASK 0x1 /* If set, signal the responder to generate a solicited event on this WQE (only relevant in SENDs and RDMA write with Imm) */ -#define RDMA_SQ_COMMON_WQE_SE_FLG_SHIFT 3 -#define RDMA_SQ_COMMON_WQE_INLINE_FLG_MASK 0x1 /* if set, indicates inline data is following this WQE instead of SGEs (only relevant in SENDs and RDMA writes) */ -#define RDMA_SQ_COMMON_WQE_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_COMMON_WQE_RESERVED0_MASK 0x7 -#define RDMA_SQ_COMMON_WQE_RESERVED0_SHIFT 5 - uint8_t wqe_size /* Size of WQE in 16B chunks including all SGEs or inline data. In case there are SGEs: set to number of SGEs + 1. In case of inline data: set to the whole number of 16B which contain the inline data + 1. */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; -}; - - -struct rdma_sq_fmr_wqe -{ - struct regpair addr; - __le32 l_key; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_FMR_WQE_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_FMR_WQE_COMP_FLG_SHIFT 0 -#define RDMA_SQ_FMR_WQE_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_FMR_WQE_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_FMR_WQE_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_FMR_WQE_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_FMR_WQE_SE_FLG_MASK 0x1 /* Don't care for FMR wqe */ -#define RDMA_SQ_FMR_WQE_SE_FLG_SHIFT 3 -#define RDMA_SQ_FMR_WQE_INLINE_FLG_MASK 0x1 /* Should be 0 for FMR wqe */ -#define RDMA_SQ_FMR_WQE_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_FMR_WQE_DIF_ON_HOST_FLG_MASK 0x1 /* If set, indicated host memory of this WQE is DIF protected. */ -#define RDMA_SQ_FMR_WQE_DIF_ON_HOST_FLG_SHIFT 5 -#define RDMA_SQ_FMR_WQE_RESERVED0_MASK 0x3 -#define RDMA_SQ_FMR_WQE_RESERVED0_SHIFT 6 - uint8_t wqe_size /* Size of WQE in 16B chunks */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; - uint8_t fmr_ctrl; -#define RDMA_SQ_FMR_WQE_PAGE_SIZE_LOG_MASK 0x1F /* 0 is 4k, 1 is 8k... */ -#define RDMA_SQ_FMR_WQE_PAGE_SIZE_LOG_SHIFT 0 -#define RDMA_SQ_FMR_WQE_ZERO_BASED_MASK 0x1 /* zero based indication */ -#define RDMA_SQ_FMR_WQE_ZERO_BASED_SHIFT 5 -#define RDMA_SQ_FMR_WQE_BIND_EN_MASK 0x1 /* indication whether bind is enabled for this MR */ -#define RDMA_SQ_FMR_WQE_BIND_EN_SHIFT 6 -#define RDMA_SQ_FMR_WQE_RESERVED1_MASK 0x1 -#define RDMA_SQ_FMR_WQE_RESERVED1_SHIFT 7 - uint8_t access_ctrl; -#define RDMA_SQ_FMR_WQE_REMOTE_READ_MASK 0x1 -#define RDMA_SQ_FMR_WQE_REMOTE_READ_SHIFT 0 -#define RDMA_SQ_FMR_WQE_REMOTE_WRITE_MASK 0x1 -#define RDMA_SQ_FMR_WQE_REMOTE_WRITE_SHIFT 1 -#define RDMA_SQ_FMR_WQE_ENABLE_ATOMIC_MASK 0x1 -#define RDMA_SQ_FMR_WQE_ENABLE_ATOMIC_SHIFT 2 -#define RDMA_SQ_FMR_WQE_LOCAL_READ_MASK 0x1 -#define RDMA_SQ_FMR_WQE_LOCAL_READ_SHIFT 3 -#define RDMA_SQ_FMR_WQE_LOCAL_WRITE_MASK 0x1 -#define RDMA_SQ_FMR_WQE_LOCAL_WRITE_SHIFT 4 -#define RDMA_SQ_FMR_WQE_RESERVED2_MASK 0x7 -#define RDMA_SQ_FMR_WQE_RESERVED2_SHIFT 5 - uint8_t reserved3; - uint8_t length_hi /* upper 8 bits of the registered MR length */; - __le32 length_lo /* lower 32 bits of the registered MR length. In case of DIF the length is specified including the DIF guards. */; - struct regpair pbl_addr /* Address of PBL */; - __le32 dif_base_ref_tag /* Ref tag of the first DIF Block. */; - __le16 dif_app_tag /* App tag of all DIF Blocks. */; - __le16 dif_app_tag_mask /* Bitmask for verifying dif_app_tag. */; - __le16 dif_runt_crc_value /* In TX IO, in case the runt_valid_flg is set, this value is used to validate the last Block in the IO. */; - __le16 dif_flags; -#define RDMA_SQ_FMR_WQE_DIF_IO_DIRECTION_FLG_MASK 0x1 /* 0=RX, 1=TX (use enum rdma_dif_io_direction_flg) */ -#define RDMA_SQ_FMR_WQE_DIF_IO_DIRECTION_FLG_SHIFT 0 -#define RDMA_SQ_FMR_WQE_DIF_BLOCK_SIZE_MASK 0x1 /* DIF block size. 0=512B 1=4096B (use enum rdma_dif_block_size) */ -#define RDMA_SQ_FMR_WQE_DIF_BLOCK_SIZE_SHIFT 1 -#define RDMA_SQ_FMR_WQE_DIF_RUNT_VALID_FLG_MASK 0x1 /* In TX IO, indicates the runt_value field is valid. In RX IO, indicates the calculated runt value is to be placed on host buffer. */ -#define RDMA_SQ_FMR_WQE_DIF_RUNT_VALID_FLG_SHIFT 2 -#define RDMA_SQ_FMR_WQE_DIF_VALIDATE_CRC_GUARD_MASK 0x1 /* In TX IO, indicates CRC of each DIF guard tag is checked. */ -#define RDMA_SQ_FMR_WQE_DIF_VALIDATE_CRC_GUARD_SHIFT 3 -#define RDMA_SQ_FMR_WQE_DIF_VALIDATE_REF_TAG_MASK 0x1 /* In TX IO, indicates Ref tag of each DIF guard tag is checked. */ -#define RDMA_SQ_FMR_WQE_DIF_VALIDATE_REF_TAG_SHIFT 4 -#define RDMA_SQ_FMR_WQE_DIF_VALIDATE_APP_TAG_MASK 0x1 /* In TX IO, indicates App tag of each DIF guard tag is checked. */ -#define RDMA_SQ_FMR_WQE_DIF_VALIDATE_APP_TAG_SHIFT 5 -#define RDMA_SQ_FMR_WQE_DIF_CRC_SEED_MASK 0x1 /* DIF CRC Seed to use. 0=0x000 1=0xFFFF (use enum rdma_dif_crc_seed) */ -#define RDMA_SQ_FMR_WQE_DIF_CRC_SEED_SHIFT 6 -#define RDMA_SQ_FMR_WQE_RESERVED4_MASK 0x1FF -#define RDMA_SQ_FMR_WQE_RESERVED4_SHIFT 7 - __le32 Reserved5; -}; - - -/* - * First element (16 bytes) of fmr wqe - */ -struct rdma_sq_fmr_wqe_1st -{ - struct regpair addr; - __le32 l_key; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_FMR_WQE_1ST_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_FMR_WQE_1ST_COMP_FLG_SHIFT 0 -#define RDMA_SQ_FMR_WQE_1ST_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_FMR_WQE_1ST_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_FMR_WQE_1ST_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_FMR_WQE_1ST_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_FMR_WQE_1ST_SE_FLG_MASK 0x1 /* Don't care for FMR wqe */ -#define RDMA_SQ_FMR_WQE_1ST_SE_FLG_SHIFT 3 -#define RDMA_SQ_FMR_WQE_1ST_INLINE_FLG_MASK 0x1 /* Should be 0 for FMR wqe */ -#define RDMA_SQ_FMR_WQE_1ST_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_FMR_WQE_1ST_DIF_ON_HOST_FLG_MASK 0x1 /* If set, indicated host memory of this WQE is DIF protected. */ -#define RDMA_SQ_FMR_WQE_1ST_DIF_ON_HOST_FLG_SHIFT 5 -#define RDMA_SQ_FMR_WQE_1ST_RESERVED0_MASK 0x3 -#define RDMA_SQ_FMR_WQE_1ST_RESERVED0_SHIFT 6 - uint8_t wqe_size /* Size of WQE in 16B chunks */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; -}; - - -/* - * Second element (16 bytes) of fmr wqe - */ -struct rdma_sq_fmr_wqe_2nd -{ - uint8_t fmr_ctrl; -#define RDMA_SQ_FMR_WQE_2ND_PAGE_SIZE_LOG_MASK 0x1F /* 0 is 4k, 1 is 8k... */ -#define RDMA_SQ_FMR_WQE_2ND_PAGE_SIZE_LOG_SHIFT 0 -#define RDMA_SQ_FMR_WQE_2ND_ZERO_BASED_MASK 0x1 /* zero based indication */ -#define RDMA_SQ_FMR_WQE_2ND_ZERO_BASED_SHIFT 5 -#define RDMA_SQ_FMR_WQE_2ND_BIND_EN_MASK 0x1 /* indication whether bind is enabled for this MR */ -#define RDMA_SQ_FMR_WQE_2ND_BIND_EN_SHIFT 6 -#define RDMA_SQ_FMR_WQE_2ND_RESERVED1_MASK 0x1 -#define RDMA_SQ_FMR_WQE_2ND_RESERVED1_SHIFT 7 - uint8_t access_ctrl; -#define RDMA_SQ_FMR_WQE_2ND_REMOTE_READ_MASK 0x1 -#define RDMA_SQ_FMR_WQE_2ND_REMOTE_READ_SHIFT 0 -#define RDMA_SQ_FMR_WQE_2ND_REMOTE_WRITE_MASK 0x1 -#define RDMA_SQ_FMR_WQE_2ND_REMOTE_WRITE_SHIFT 1 -#define RDMA_SQ_FMR_WQE_2ND_ENABLE_ATOMIC_MASK 0x1 -#define RDMA_SQ_FMR_WQE_2ND_ENABLE_ATOMIC_SHIFT 2 -#define RDMA_SQ_FMR_WQE_2ND_LOCAL_READ_MASK 0x1 -#define RDMA_SQ_FMR_WQE_2ND_LOCAL_READ_SHIFT 3 -#define RDMA_SQ_FMR_WQE_2ND_LOCAL_WRITE_MASK 0x1 -#define RDMA_SQ_FMR_WQE_2ND_LOCAL_WRITE_SHIFT 4 -#define RDMA_SQ_FMR_WQE_2ND_RESERVED2_MASK 0x7 -#define RDMA_SQ_FMR_WQE_2ND_RESERVED2_SHIFT 5 - uint8_t reserved3; - uint8_t length_hi /* upper 8 bits of the registered MR length */; - __le32 length_lo /* lower 32 bits of the registered MR length. In case of zero based MR, will hold FBO */; - struct regpair pbl_addr /* Address of PBL */; -}; - - -/* - * Third element (16 bytes) of fmr wqe - */ -struct rdma_sq_fmr_wqe_3rd -{ - __le32 dif_base_ref_tag /* Ref tag of the first DIF Block. */; - __le16 dif_app_tag /* App tag of all DIF Blocks. */; - __le16 dif_app_tag_mask /* Bitmask for verifying dif_app_tag. */; - __le16 dif_runt_crc_value /* In TX IO, in case the runt_valid_flg is set, this value is used to validate the last Block in the IO. */; - __le16 dif_flags; -#define RDMA_SQ_FMR_WQE_3RD_DIF_IO_DIRECTION_FLG_MASK 0x1 /* 0=RX, 1=TX (use enum rdma_dif_io_direction_flg) */ -#define RDMA_SQ_FMR_WQE_3RD_DIF_IO_DIRECTION_FLG_SHIFT 0 -#define RDMA_SQ_FMR_WQE_3RD_DIF_BLOCK_SIZE_MASK 0x1 /* DIF block size. 0=512B 1=4096B (use enum rdma_dif_block_size) */ -#define RDMA_SQ_FMR_WQE_3RD_DIF_BLOCK_SIZE_SHIFT 1 -#define RDMA_SQ_FMR_WQE_3RD_DIF_RUNT_VALID_FLG_MASK 0x1 /* In TX IO, indicates the runt_value field is valid. In RX IO, indicates the calculated runt value is to be placed on host buffer. */ -#define RDMA_SQ_FMR_WQE_3RD_DIF_RUNT_VALID_FLG_SHIFT 2 -#define RDMA_SQ_FMR_WQE_3RD_DIF_VALIDATE_CRC_GUARD_MASK 0x1 /* In TX IO, indicates CRC of each DIF guard tag is checked. */ -#define RDMA_SQ_FMR_WQE_3RD_DIF_VALIDATE_CRC_GUARD_SHIFT 3 -#define RDMA_SQ_FMR_WQE_3RD_DIF_VALIDATE_REF_TAG_MASK 0x1 /* In TX IO, indicates Ref tag of each DIF guard tag is checked. */ -#define RDMA_SQ_FMR_WQE_3RD_DIF_VALIDATE_REF_TAG_SHIFT 4 -#define RDMA_SQ_FMR_WQE_3RD_DIF_VALIDATE_APP_TAG_MASK 0x1 /* In TX IO, indicates App tag of each DIF guard tag is checked. */ -#define RDMA_SQ_FMR_WQE_3RD_DIF_VALIDATE_APP_TAG_SHIFT 5 -#define RDMA_SQ_FMR_WQE_3RD_DIF_CRC_SEED_MASK 0x1 /* DIF CRC Seed to use. 0=0x000 1=0xFFFF (use enum rdma_dif_crc_seed) */ -#define RDMA_SQ_FMR_WQE_3RD_DIF_CRC_SEED_SHIFT 6 -#define RDMA_SQ_FMR_WQE_3RD_RESERVED4_MASK 0x1FF -#define RDMA_SQ_FMR_WQE_3RD_RESERVED4_SHIFT 7 - __le32 Reserved5; -}; - - -struct rdma_sq_local_inv_wqe -{ - struct regpair reserved; - __le32 inv_l_key /* The invalidate local key */; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_LOCAL_INV_WQE_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_LOCAL_INV_WQE_COMP_FLG_SHIFT 0 -#define RDMA_SQ_LOCAL_INV_WQE_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_LOCAL_INV_WQE_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_LOCAL_INV_WQE_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_LOCAL_INV_WQE_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_LOCAL_INV_WQE_SE_FLG_MASK 0x1 /* Don't care for local invalidate wqe */ -#define RDMA_SQ_LOCAL_INV_WQE_SE_FLG_SHIFT 3 -#define RDMA_SQ_LOCAL_INV_WQE_INLINE_FLG_MASK 0x1 /* Should be 0 for local invalidate wqe */ -#define RDMA_SQ_LOCAL_INV_WQE_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_LOCAL_INV_WQE_DIF_ON_HOST_FLG_MASK 0x1 /* If set, indicated host memory of this WQE is DIF protected. */ -#define RDMA_SQ_LOCAL_INV_WQE_DIF_ON_HOST_FLG_SHIFT 5 -#define RDMA_SQ_LOCAL_INV_WQE_RESERVED0_MASK 0x3 -#define RDMA_SQ_LOCAL_INV_WQE_RESERVED0_SHIFT 6 - uint8_t wqe_size /* Size of WQE in 16B chunks */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; -}; - - -struct rdma_sq_rdma_wqe -{ - __le32 imm_data /* The immediate data in case of RDMA_WITH_IMM */; - __le32 length /* Total data length. If DIF on host is enabled, length does NOT include DIF guards. */; - __le32 xrc_srq /* Valid only when XRC is set for the QP */; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_RDMA_WQE_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_RDMA_WQE_COMP_FLG_SHIFT 0 -#define RDMA_SQ_RDMA_WQE_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_RDMA_WQE_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_RDMA_WQE_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_RDMA_WQE_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_RDMA_WQE_SE_FLG_MASK 0x1 /* If set, signal the responder to generate a solicited event on this WQE */ -#define RDMA_SQ_RDMA_WQE_SE_FLG_SHIFT 3 -#define RDMA_SQ_RDMA_WQE_INLINE_FLG_MASK 0x1 /* if set, indicates inline data is following this WQE instead of SGEs. Applicable for RDMA_WR or RDMA_WR_WITH_IMM. Should be 0 for RDMA_RD */ -#define RDMA_SQ_RDMA_WQE_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_RDMA_WQE_DIF_ON_HOST_FLG_MASK 0x1 /* If set, indicated host memory of this WQE is DIF protected. */ -#define RDMA_SQ_RDMA_WQE_DIF_ON_HOST_FLG_SHIFT 5 -#define RDMA_SQ_RDMA_WQE_RESERVED0_MASK 0x3 -#define RDMA_SQ_RDMA_WQE_RESERVED0_SHIFT 6 - uint8_t wqe_size /* Size of WQE in 16B chunks including all SGEs or inline data. In case there are SGEs: set to number of SGEs + 1. In case of inline data: set to the whole number of 16B which contain the inline data + 1. */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; - struct regpair remote_va /* Remote virtual address */; - __le32 r_key /* Remote key */; - uint8_t dif_flags; -#define RDMA_SQ_RDMA_WQE_DIF_BLOCK_SIZE_MASK 0x1 /* if dif_on_host_flg set: DIF block size. 0=512B 1=4096B (use enum rdma_dif_block_size) */ -#define RDMA_SQ_RDMA_WQE_DIF_BLOCK_SIZE_SHIFT 0 -#define RDMA_SQ_RDMA_WQE_DIF_FIRST_RDMA_IN_IO_FLG_MASK 0x1 /* if dif_on_host_flg set: WQE executes first RDMA on related IO. */ -#define RDMA_SQ_RDMA_WQE_DIF_FIRST_RDMA_IN_IO_FLG_SHIFT 1 -#define RDMA_SQ_RDMA_WQE_DIF_LAST_RDMA_IN_IO_FLG_MASK 0x1 /* if dif_on_host_flg set: WQE executes last RDMA on related IO. */ -#define RDMA_SQ_RDMA_WQE_DIF_LAST_RDMA_IN_IO_FLG_SHIFT 2 -#define RDMA_SQ_RDMA_WQE_RESERVED1_MASK 0x1F -#define RDMA_SQ_RDMA_WQE_RESERVED1_SHIFT 3 - uint8_t reserved2[3]; -}; - - -/* - * First element (16 bytes) of rdma wqe - */ -struct rdma_sq_rdma_wqe_1st -{ - __le32 imm_data /* The immediate data in case of RDMA_WITH_IMM */; - __le32 length /* Total data length */; - __le32 xrc_srq /* Valid only when XRC is set for the QP */; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_RDMA_WQE_1ST_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_RDMA_WQE_1ST_COMP_FLG_SHIFT 0 -#define RDMA_SQ_RDMA_WQE_1ST_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_RDMA_WQE_1ST_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_RDMA_WQE_1ST_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_RDMA_WQE_1ST_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_RDMA_WQE_1ST_SE_FLG_MASK 0x1 /* If set, signal the responder to generate a solicited event on this WQE */ -#define RDMA_SQ_RDMA_WQE_1ST_SE_FLG_SHIFT 3 -#define RDMA_SQ_RDMA_WQE_1ST_INLINE_FLG_MASK 0x1 /* if set, indicates inline data is following this WQE instead of SGEs. Applicable for RDMA_WR or RDMA_WR_WITH_IMM. Should be 0 for RDMA_RD */ -#define RDMA_SQ_RDMA_WQE_1ST_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_RDMA_WQE_1ST_DIF_ON_HOST_FLG_MASK 0x1 /* If set, indicated host memory of this WQE is DIF protected. */ -#define RDMA_SQ_RDMA_WQE_1ST_DIF_ON_HOST_FLG_SHIFT 5 -#define RDMA_SQ_RDMA_WQE_1ST_RESERVED0_MASK 0x3 -#define RDMA_SQ_RDMA_WQE_1ST_RESERVED0_SHIFT 6 - uint8_t wqe_size /* Size of WQE in 16B chunks including all SGEs or inline data. In case there are SGEs: set to number of SGEs + 1. In case of inline data: set to the whole number of 16B which contain the inline data + 1. */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; -}; - - -/* - * Second element (16 bytes) of rdma wqe - */ -struct rdma_sq_rdma_wqe_2nd -{ - struct regpair remote_va /* Remote virtual address */; - __le32 r_key /* Remote key */; - uint8_t dif_flags; -#define RDMA_SQ_RDMA_WQE_2ND_DIF_BLOCK_SIZE_MASK 0x1 /* if dif_on_host_flg set: DIF block size. 0=512B 1=4096B (use enum rdma_dif_block_size) */ -#define RDMA_SQ_RDMA_WQE_2ND_DIF_BLOCK_SIZE_SHIFT 0 -#define RDMA_SQ_RDMA_WQE_2ND_DIF_FIRST_SEGMENT_FLG_MASK 0x1 /* if dif_on_host_flg set: WQE executes first DIF on related MR. */ -#define RDMA_SQ_RDMA_WQE_2ND_DIF_FIRST_SEGMENT_FLG_SHIFT 1 -#define RDMA_SQ_RDMA_WQE_2ND_DIF_LAST_SEGMENT_FLG_MASK 0x1 /* if dif_on_host_flg set: WQE executes last DIF on related MR. */ -#define RDMA_SQ_RDMA_WQE_2ND_DIF_LAST_SEGMENT_FLG_SHIFT 2 -#define RDMA_SQ_RDMA_WQE_2ND_RESERVED1_MASK 0x1F -#define RDMA_SQ_RDMA_WQE_2ND_RESERVED1_SHIFT 3 - uint8_t reserved2[3]; -}; - - -/* - * SQ WQE req type enumeration - */ -enum rdma_sq_req_type -{ - RDMA_SQ_REQ_TYPE_SEND, - RDMA_SQ_REQ_TYPE_SEND_WITH_IMM, - RDMA_SQ_REQ_TYPE_SEND_WITH_INVALIDATE, - RDMA_SQ_REQ_TYPE_RDMA_WR, - RDMA_SQ_REQ_TYPE_RDMA_WR_WITH_IMM, - RDMA_SQ_REQ_TYPE_RDMA_RD, - RDMA_SQ_REQ_TYPE_ATOMIC_CMP_AND_SWAP, - RDMA_SQ_REQ_TYPE_ATOMIC_ADD, - RDMA_SQ_REQ_TYPE_LOCAL_INVALIDATE, - RDMA_SQ_REQ_TYPE_FAST_MR, - RDMA_SQ_REQ_TYPE_BIND, - RDMA_SQ_REQ_TYPE_INVALID, - MAX_RDMA_SQ_REQ_TYPE -}; - - -struct rdma_sq_send_wqe -{ - __le32 inv_key_or_imm_data /* the r_key to invalidate in case of SEND_WITH_INVALIDATE, or the immediate data in case of SEND_WITH_IMM */; - __le32 length /* Total data length */; - __le32 xrc_srq /* Valid only when XRC is set for the QP */; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_SEND_WQE_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_SEND_WQE_COMP_FLG_SHIFT 0 -#define RDMA_SQ_SEND_WQE_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_SEND_WQE_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_SEND_WQE_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_SEND_WQE_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_SEND_WQE_SE_FLG_MASK 0x1 /* If set, signal the responder to generate a solicited event on this WQE */ -#define RDMA_SQ_SEND_WQE_SE_FLG_SHIFT 3 -#define RDMA_SQ_SEND_WQE_INLINE_FLG_MASK 0x1 /* if set, indicates inline data is following this WQE instead of SGEs */ -#define RDMA_SQ_SEND_WQE_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_SEND_WQE_DIF_ON_HOST_FLG_MASK 0x1 /* Should be 0 for send wqe */ -#define RDMA_SQ_SEND_WQE_DIF_ON_HOST_FLG_SHIFT 5 -#define RDMA_SQ_SEND_WQE_RESERVED0_MASK 0x3 -#define RDMA_SQ_SEND_WQE_RESERVED0_SHIFT 6 - uint8_t wqe_size /* Size of WQE in 16B chunks including all SGEs or inline data. In case there are SGEs: set to number of SGEs + 1. In case of inline data: set to the whole number of 16B which contain the inline data + 1. */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; - __le32 reserved1[4]; -}; - - -struct rdma_sq_send_wqe_1st -{ - __le32 inv_key_or_imm_data /* the r_key to invalidate in case of SEND_WITH_INVALIDATE, or the immediate data in case of SEND_WITH_IMM */; - __le32 length /* Total data length */; - __le32 xrc_srq /* Valid only when XRC is set for the QP */; - uint8_t req_type /* Type of WQE */; - uint8_t flags; -#define RDMA_SQ_SEND_WQE_1ST_COMP_FLG_MASK 0x1 /* If set, completion will be generated when the WQE is completed */ -#define RDMA_SQ_SEND_WQE_1ST_COMP_FLG_SHIFT 0 -#define RDMA_SQ_SEND_WQE_1ST_RD_FENCE_FLG_MASK 0x1 /* If set, all pending RDMA read or Atomic operations will be completed before start processing this WQE */ -#define RDMA_SQ_SEND_WQE_1ST_RD_FENCE_FLG_SHIFT 1 -#define RDMA_SQ_SEND_WQE_1ST_INV_FENCE_FLG_MASK 0x1 /* If set, all pending operations will be completed before start processing this WQE */ -#define RDMA_SQ_SEND_WQE_1ST_INV_FENCE_FLG_SHIFT 2 -#define RDMA_SQ_SEND_WQE_1ST_SE_FLG_MASK 0x1 /* If set, signal the responder to generate a solicited event on this WQE */ -#define RDMA_SQ_SEND_WQE_1ST_SE_FLG_SHIFT 3 -#define RDMA_SQ_SEND_WQE_1ST_INLINE_FLG_MASK 0x1 /* if set, indicates inline data is following this WQE instead of SGEs */ -#define RDMA_SQ_SEND_WQE_1ST_INLINE_FLG_SHIFT 4 -#define RDMA_SQ_SEND_WQE_1ST_RESERVED0_MASK 0x7 -#define RDMA_SQ_SEND_WQE_1ST_RESERVED0_SHIFT 5 - uint8_t wqe_size /* Size of WQE in 16B chunks including all SGEs or inline data. In case there are SGEs: set to number of SGEs + 1. In case of inline data: set to the whole number of 16B which contain the inline data + 1. */; - uint8_t prev_wqe_size /* Previous WQE size in 16B chunks */; -}; - - -struct rdma_sq_send_wqe_2st -{ - __le32 reserved1[4]; -}; - - -struct rdma_sq_sge -{ - __le32 length /* Total length of the send. If DIF on host is enabled, SGE length includes the DIF guards. */; - struct regpair addr; - __le32 l_key; -}; - - -struct rdma_srq_wqe_header -{ - struct regpair wr_id; - uint8_t num_sges /* number of SGEs in WQE */; - uint8_t reserved2[7]; -}; - -struct rdma_srq_sge -{ - struct regpair addr; - __le32 length; - __le32 l_key; -}; - -/* - * rdma srq sge - */ -union rdma_srq_elm -{ - struct rdma_srq_wqe_header header; - struct rdma_srq_sge sge; -}; - - - - -/* - * Rdma doorbell data for flags update - */ -struct rdma_pwm_flags_data -{ - __le16 icid /* internal CID */; - uint8_t agg_flags /* aggregative flags */; - uint8_t reserved; -}; - - -/* - * Rdma doorbell data for SQ and RQ - */ -struct rdma_pwm_val16_data -{ - __le16 icid /* internal CID */; - __le16 value /* aggregated value to update */; -}; - - -union rdma_pwm_val16_data_union -{ - struct rdma_pwm_val16_data as_struct /* Parameters field */; - __le32 as_dword; -}; - - -/* - * Rdma doorbell data for CQ - */ -struct rdma_pwm_val32_data -{ - __le16 icid /* internal CID */; - uint8_t agg_flags /* bit for every DQ counter flags in CM context that DQ can increment */; - uint8_t params; -#define RDMA_PWM_VAL32_DATA_AGG_CMD_MASK 0x3 /* aggregative command to CM (use enum db_agg_cmd_sel) */ -#define RDMA_PWM_VAL32_DATA_AGG_CMD_SHIFT 0 -#define RDMA_PWM_VAL32_DATA_BYPASS_EN_MASK 0x1 /* enable QM bypass */ -#define RDMA_PWM_VAL32_DATA_BYPASS_EN_SHIFT 2 -#define RDMA_PWM_VAL32_DATA_RESERVED_MASK 0x1F -#define RDMA_PWM_VAL32_DATA_RESERVED_SHIFT 3 - __le32 value /* aggregated value to update */; -}; - - -union rdma_pwm_val32_data_union -{ - struct rdma_pwm_val32_data as_struct /* Parameters field */; - struct regpair as_repair; -}; - -#endif /* __QED_HSI_RDMA__ */ diff --git a/usr/rdma-core/providers/qedr/qelr_main.c b/usr/rdma-core/providers/qedr/qelr_main.c deleted file mode 100644 index fa2be455e..000000000 --- a/usr/rdma-core/providers/qedr/qelr_main.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "qelr.h" -#include "qelr_main.h" -#include "qelr_abi.h" -#include "qelr_chain.h" - -#include -#include -#include - -#define PCI_VENDOR_ID_QLOGIC (0x1077) -#define PCI_DEVICE_ID_QLOGIC_57980S (0x1629) -#define PCI_DEVICE_ID_QLOGIC_57980S_40 (0x1634) -#define PCI_DEVICE_ID_QLOGIC_57980S_10 (0x1666) -#define PCI_DEVICE_ID_QLOGIC_57980S_MF (0x1636) -#define PCI_DEVICE_ID_QLOGIC_57980S_100 (0x1644) -#define PCI_DEVICE_ID_QLOGIC_57980S_50 (0x1654) -#define PCI_DEVICE_ID_QLOGIC_57980S_25 (0x1656) -#define PCI_DEVICE_ID_QLOGIC_57980S_IOV (0x1664) -#define PCI_DEVICE_ID_QLOGIC_AH (0x8070) -#define PCI_DEVICE_ID_QLOGIC_AH_IOV (0x8090) - -uint32_t qelr_dp_level; -uint32_t qelr_dp_module; - -#define QHCA(d) \ - VERBS_PCI_MATCH(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_##d, NULL) -static const struct verbs_match_ent hca_table[] = { - QHCA(57980S), - QHCA(57980S_40), - QHCA(57980S_10), - QHCA(57980S_MF), - QHCA(57980S_100), - QHCA(57980S_50), - QHCA(57980S_25), - QHCA(57980S_IOV), - QHCA(AH), - QHCA(AH_IOV), - {} -}; - -static struct ibv_context *qelr_alloc_context(struct ibv_device *, int); -static void qelr_free_context(struct ibv_context *); - -static struct ibv_context_ops qelr_ctx_ops = { - .query_device = qelr_query_device, - .query_port = qelr_query_port, - .alloc_pd = qelr_alloc_pd, - .dealloc_pd = qelr_dealloc_pd, - .reg_mr = qelr_reg_mr, - .dereg_mr = qelr_dereg_mr, - .create_cq = qelr_create_cq, - .poll_cq = qelr_poll_cq, - .req_notify_cq = qelr_arm_cq, - .cq_event = qelr_cq_event, - .destroy_cq = qelr_destroy_cq, - .create_qp = qelr_create_qp, - .query_qp = qelr_query_qp, - .modify_qp = qelr_modify_qp, - .destroy_qp = qelr_destroy_qp, - .post_send = qelr_post_send, - .post_recv = qelr_post_recv, - .async_event = qelr_async_event, -}; - -static void qelr_uninit_device(struct verbs_device *verbs_device) -{ - struct qelr_device *dev = get_qelr_dev(&verbs_device->device); - - free(dev); -} - -static void qelr_open_debug_file(struct qelr_devctx *ctx) -{ - char *env; - - env = getenv("QELR_DEBUG_FILE"); - if (!env) { - ctx->dbg_fp = stderr; - DP_VERBOSE(ctx->dbg_fp, QELR_MSG_INIT, - "Debug file opened: stderr\n"); - return; - } - - ctx->dbg_fp = fopen(env, "aw+"); - if (!ctx->dbg_fp) { - fprintf(stderr, "Failed opening debug file %s, using stderr\n", - env); - ctx->dbg_fp = stderr; - DP_VERBOSE(ctx->dbg_fp, QELR_MSG_INIT, - "Debug file opened: stderr\n"); - return; - } - - DP_VERBOSE(ctx->dbg_fp, QELR_MSG_INIT, "Debug file opened: %s\n", env); -} - -static void qelr_close_debug_file(struct qelr_devctx *ctx) -{ - if (ctx->dbg_fp && ctx->dbg_fp != stderr) - fclose(ctx->dbg_fp); -} - -static void qelr_set_debug_mask(void) -{ - char *env; - - qelr_dp_level = QELR_LEVEL_NOTICE; - qelr_dp_module = 0; - - env = getenv("QELR_DP_LEVEL"); - if (env) - qelr_dp_level = atoi(env); - - env = getenv("QELR_DP_MODULE"); - if (env) - qelr_dp_module = atoi(env); -} - -static struct ibv_context *qelr_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - struct qelr_devctx *ctx; - struct qelr_get_context cmd; - struct qelr_alloc_ucontext_resp resp; - - ctx = calloc(1, sizeof(struct qelr_devctx)); - if (!ctx) - return NULL; - memset(&resp, 0, sizeof(resp)); - - ctx->ibv_ctx.cmd_fd = cmd_fd; - - qelr_open_debug_file(ctx); - qelr_set_debug_mask(); - - if (ibv_cmd_get_context(&ctx->ibv_ctx, - (struct ibv_get_context *)&cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp))) - goto cmd_err; - - ctx->kernel_page_size = sysconf(_SC_PAGESIZE); - ctx->ibv_ctx.device = ibdev; - ctx->ibv_ctx.ops = qelr_ctx_ops; - ctx->db_pa = resp.db_pa; - ctx->db_size = resp.db_size; - ctx->max_send_wr = resp.max_send_wr; - ctx->max_recv_wr = resp.max_recv_wr; - ctx->sges_per_send_wr = resp.sges_per_send_wr; - ctx->sges_per_recv_wr = resp.sges_per_recv_wr; - ctx->max_cqes = resp.max_cqes; - - ctx->db_addr = mmap(NULL, ctx->db_size, PROT_WRITE, MAP_SHARED, - cmd_fd, ctx->db_pa); - - if (ctx->db_addr == MAP_FAILED) { - int errsv = errno; - - DP_ERR(ctx->dbg_fp, - "alloc context: doorbell mapping failed resp.db_pa = %llx resp.db_size=%d context->cmd_fd=%d errno=%d\n", - resp.db_pa, resp.db_size, cmd_fd, errsv); - goto cmd_err; - } - - return &ctx->ibv_ctx; - -cmd_err: - qelr_err("%s: Failed to allocate context for device.\n", __func__); - qelr_close_debug_file(ctx); - free(ctx); - return NULL; -} - -static void qelr_free_context(struct ibv_context *ibctx) -{ - struct qelr_devctx *ctx = get_qelr_ctx(ibctx); - - if (ctx->db_addr) - munmap(ctx->db_addr, ctx->db_size); - - qelr_close_debug_file(ctx); - free(ctx); -} - -static struct verbs_device *qelr_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct qelr_device *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - return &dev->ibv_dev; -} - -static const struct verbs_device_ops qelr_dev_ops = { - .name = "qedr", - .match_min_abi_version = QELR_ABI_VERSION, - .match_max_abi_version = QELR_ABI_VERSION, - .match_table = hca_table, - .alloc_device = qelr_device_alloc, - .uninit_device = qelr_uninit_device, - .alloc_context = qelr_alloc_context, - .free_context = qelr_free_context, -}; -PROVIDER_DRIVER(qelr_dev_ops); diff --git a/usr/rdma-core/providers/qedr/qelr_main.h b/usr/rdma-core/providers/qedr/qelr_main.h deleted file mode 100644 index f0b16d980..000000000 --- a/usr/rdma-core/providers/qedr/qelr_main.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __QELR_MAIN_H__ -#define __QELR_MAIN_H__ - -#include -#include -#include - -#include -#include - -int qelr_query_device(struct ibv_context *, struct ibv_device_attr *); -int qelr_query_port(struct ibv_context *, uint8_t, struct ibv_port_attr *); - -struct ibv_pd *qelr_alloc_pd(struct ibv_context *); -int qelr_dealloc_pd(struct ibv_pd *); - -struct ibv_mr *qelr_reg_mr(struct ibv_pd *, void *, size_t, - int ibv_access_flags); -int qelr_dereg_mr(struct ibv_mr *); - -struct ibv_cq *qelr_create_cq(struct ibv_context *, int, - struct ibv_comp_channel *, int); -int qelr_destroy_cq(struct ibv_cq *); -int qelr_poll_cq(struct ibv_cq *, int, struct ibv_wc *); -void qelr_cq_event(struct ibv_cq *); -int qelr_arm_cq(struct ibv_cq *, int); - -int qelr_query_srq(struct ibv_srq *ibv_srq, struct ibv_srq_attr *attr); -int qelr_modify_srq(struct ibv_srq *ibv_srq, struct ibv_srq_attr *attr, - int attr_mask); -struct ibv_srq *qelr_create_srq(struct ibv_pd *, struct ibv_srq_init_attr *); -int qelr_destroy_srq(struct ibv_srq *ibv_srq); -int qelr_post_srq_recv(struct ibv_srq *, struct ibv_recv_wr *, - struct ibv_recv_wr **bad_wr); - -struct ibv_qp *qelr_create_qp(struct ibv_pd *, struct ibv_qp_init_attr *); -int qelr_modify_qp(struct ibv_qp *, struct ibv_qp_attr *, - int ibv_qp_attr_mask); -int qelr_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask, - struct ibv_qp_init_attr *init_attr); -int qelr_destroy_qp(struct ibv_qp *); - -int qelr_post_send(struct ibv_qp *, struct ibv_send_wr *, - struct ibv_send_wr **); -int qelr_post_recv(struct ibv_qp *, struct ibv_recv_wr *, - struct ibv_recv_wr **); - -void qelr_async_event(struct ibv_async_event *event); -#endif /* __QELR_MAIN_H__ */ diff --git a/usr/rdma-core/providers/qedr/qelr_verbs.c b/usr/rdma-core/providers/qedr/qelr_verbs.c deleted file mode 100644 index 4a74c50e2..000000000 --- a/usr/rdma-core/providers/qedr/qelr_verbs.c +++ /dev/null @@ -1,2031 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qelr.h" -#include "qelr_abi.h" -#include "qelr_chain.h" -#include "qelr_verbs.h" -#include - -#include -#include -#include - -#define QELR_SQE_ELEMENT_SIZE (sizeof(struct rdma_sq_sge)) -#define QELR_RQE_ELEMENT_SIZE (sizeof(struct rdma_rq_sge)) -#define QELR_CQE_SIZE (sizeof(union rdma_cqe)) - -#define IS_IWARP(_dev) (_dev->node_type == IBV_NODE_RNIC) -#define IS_ROCE(_dev) (_dev->node_type == IBV_NODE_CA) - -static void qelr_inc_sw_cons_u16(struct qelr_qp_hwq_info *info) -{ - info->cons = (info->cons + 1) % info->max_wr; - info->wqe_cons++; -} - -static void qelr_inc_sw_prod_u16(struct qelr_qp_hwq_info *info) -{ - info->prod = (info->prod + 1) % info->max_wr; -} - -static inline int qelr_wq_is_full(struct qelr_qp_hwq_info *info) -{ - return (((info->prod + 1) % info->max_wr) == info->cons); -} - -int qelr_query_device(struct ibv_context *context, - struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t fw_ver; - unsigned int major, minor, revision, eng; - int status; - - bzero(attr, sizeof(*attr)); - status = ibv_cmd_query_device(context, attr, &fw_ver, &cmd, - sizeof(cmd)); - - major = (fw_ver >> 24) & 0xff; - minor = (fw_ver >> 16) & 0xff; - revision = (fw_ver >> 8) & 0xff; - eng = fw_ver & 0xff; - - snprintf(attr->fw_ver, sizeof(attr->fw_ver), - "%d.%d.%d.%d", major, minor, revision, eng); - - return status; -} - -int qelr_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - int status; - - status = ibv_cmd_query_port(context, port, attr, &cmd, sizeof(cmd)); - return status; -} - -struct ibv_pd *qelr_alloc_pd(struct ibv_context *context) -{ - struct qelr_alloc_pd_req cmd; - struct qelr_alloc_pd_resp resp; - struct qelr_pd *pd; - struct qelr_devctx *cxt = get_qelr_ctx(context); - - pd = malloc(sizeof(*pd)); - if (!pd) - return NULL; - - bzero(pd, sizeof(*pd)); - memset(&cmd, 0, sizeof(cmd)); - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd.cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp))) { - free(pd); - return NULL; - } - - pd->pd_id = resp.pd_id; - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_INIT, "Allocated pd: %d\n", pd->pd_id); - - return &pd->ibv_pd; -} - -int qelr_dealloc_pd(struct ibv_pd *ibpd) -{ - int rc = 0; - struct qelr_pd *pd = get_qelr_pd(ibpd); - struct qelr_devctx *cxt = get_qelr_ctx(ibpd->context); - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_INIT, "Deallocated pd: %d\n", - pd->pd_id); - - rc = ibv_cmd_dealloc_pd(ibpd); - - if (rc) - return rc; - - free(pd); - - return rc; -} - -struct ibv_mr *qelr_reg_mr(struct ibv_pd *ibpd, void *addr, - size_t len, int access) -{ - struct qelr_mr *mr; - struct ibv_reg_mr cmd; - struct qelr_reg_mr_resp resp; - struct qelr_pd *pd = get_qelr_pd(ibpd); - struct qelr_devctx *cxt = get_qelr_ctx(ibpd->context); - - uint64_t hca_va = (uintptr_t) addr; - - mr = malloc(sizeof(*mr)); - if (!mr) - return NULL; - - bzero(mr, sizeof(*mr)); - - if (ibv_cmd_reg_mr(ibpd, addr, len, hca_va, - access, &mr->ibv_mr, &cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp))) { - free(mr); - return NULL; - } - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_MR, - "MR Register %p completed successfully pd_id=%d addr=%p len=%zu access=%d lkey=%x rkey=%x\n", - mr, pd->pd_id, addr, len, access, mr->ibv_mr.lkey, - mr->ibv_mr.rkey); - - return &mr->ibv_mr; -} - -int qelr_dereg_mr(struct ibv_mr *mr) -{ - struct qelr_devctx *cxt = get_qelr_ctx(mr->context); - int rc; - - rc = ibv_cmd_dereg_mr(mr); - if (rc) - return rc; - - free(mr); - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_MR, - "MR DERegister %p completed successfully\n", mr); - return 0; -} - -static void consume_cqe(struct qelr_cq *cq) -{ - if (cq->latest_cqe == cq->toggle_cqe) - cq->chain_toggle ^= RDMA_CQE_REQUESTER_TOGGLE_BIT_MASK; - - cq->latest_cqe = qelr_chain_consume(&cq->chain); -} - -static inline int qelr_cq_entries(int entries) -{ - /* FW requires an extra entry */ - return entries + 1; -} - -struct ibv_cq *qelr_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct qelr_devctx *cxt = get_qelr_ctx(context); - struct qelr_create_cq_resp resp; - struct qelr_create_cq_req cmd; - struct qelr_cq *cq; - int chain_size; - int rc; - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_CQ, - "create cq: context=%p, cqe=%d, channel=%p, comp_vector=%d\n", - context, cqe, channel, comp_vector); - - if (!cqe || cqe > cxt->max_cqes) { - DP_ERR(cxt->dbg_fp, - "create cq: failed. attempted to allocate %d cqes but valid range is 1...%d\n", - cqe, cqe > cxt->max_cqes); - return NULL; - } - - /* allocate CQ structure */ - cq = calloc(1, sizeof(*cq)); - if (!cq) - return NULL; - - /* allocate CQ buffer */ - chain_size = qelr_cq_entries(cqe) * QELR_CQE_SIZE; - rc = qelr_chain_alloc(&cq->chain, chain_size, cxt->kernel_page_size, - QELR_CQE_SIZE); - if (rc) - goto err_0; - - cmd.addr = (uintptr_t) cq->chain.first_addr; - cmd.len = cq->chain.size; - rc = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &cq->ibv_cq, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (rc) { - DP_ERR(cxt->dbg_fp, "create cq: failed with rc = %d\n", rc); - goto err_1; - } - - /* map the doorbell and prepare its data */ - cq->db.data.icid = htole16(resp.icid); - cq->db.data.params = DB_AGG_CMD_SET << - RDMA_PWM_VAL32_DATA_AGG_CMD_SHIFT; - cq->db_addr = cxt->db_addr + resp.db_offset; - - /* point to the very last element, passing this we will toggle */ - cq->toggle_cqe = qelr_chain_get_last_elem(&cq->chain); - cq->chain_toggle = RDMA_CQE_REQUESTER_TOGGLE_BIT_MASK; - cq->latest_cqe = NULL; /* must be different from chain_toggle */ - consume_cqe(cq); - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_CQ, - "create cq: successfully created %p\n", cq); - - return &cq->ibv_cq; - -err_1: - qelr_chain_free(&cq->chain); -err_0: - free(cq); - - return NULL; -} - -int qelr_destroy_cq(struct ibv_cq *ibv_cq) -{ - struct qelr_devctx *cxt = get_qelr_ctx(ibv_cq->context); - struct qelr_cq *cq = get_qelr_cq(ibv_cq); - int rc; - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_CQ, "destroy cq: %p\n", cq); - - rc = ibv_cmd_destroy_cq(ibv_cq); - if (rc) { - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_CQ, - "destroy cq: failed to destroy %p, got %d.\n", cq, - rc); - return rc; - } - - qelr_chain_free(&cq->chain); - free(cq); - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_CQ, - "destroy cq: successfully destroyed %p\n", cq); - - return 0; -} - -static void qelr_free_rq(struct qelr_qp *qp) -{ - free(qp->rqe_wr_id); -} - -static void qelr_free_sq(struct qelr_qp *qp) -{ - free(qp->wqe_wr_id); -} - -static void qelr_chain_free_sq(struct qelr_qp *qp) -{ - qelr_chain_free(&qp->sq.chain); -} - -static void qelr_chain_free_rq(struct qelr_qp *qp) -{ - qelr_chain_free(&qp->rq.chain); -} - -static inline int qelr_create_qp_buffers_sq(struct qelr_devctx *cxt, - struct qelr_qp *qp, - struct ibv_qp_init_attr *attrs) -{ - uint32_t max_send_wr, max_send_sges, max_send_buf; - int chain_size; - int rc; - - /* SQ */ - max_send_wr = attrs->cap.max_send_wr; - max_send_wr = max_t(uint32_t, max_send_wr, 1); - max_send_wr = min_t(uint32_t, max_send_wr, cxt->max_send_wr); - max_send_sges = max_send_wr * cxt->sges_per_send_wr; - max_send_buf = max_send_sges * QELR_SQE_ELEMENT_SIZE; - - chain_size = max_send_buf; - rc = qelr_chain_alloc(&qp->sq.chain, chain_size, cxt->kernel_page_size, - QELR_SQE_ELEMENT_SIZE); - if (rc) - DP_ERR(cxt->dbg_fp, "create qp: failed to map SQ chain, got %d", rc); - - qp->sq.max_wr = max_send_wr; - qp->sq.max_sges = cxt->sges_per_send_wr; - - return rc; -} - -static inline int qelr_create_qp_buffers_rq(struct qelr_devctx *cxt, - struct qelr_qp *qp, - struct ibv_qp_init_attr *attrs) -{ - uint32_t max_recv_wr, max_recv_sges, max_recv_buf; - int chain_size; - int rc; - - /* RQ */ - max_recv_wr = attrs->cap.max_recv_wr; - max_recv_wr = max_t(uint32_t, max_recv_wr, 1); - max_recv_wr = min_t(uint32_t, max_recv_wr, cxt->max_recv_wr); - max_recv_sges = max_recv_wr * cxt->sges_per_recv_wr; - max_recv_buf = max_recv_sges * QELR_RQE_ELEMENT_SIZE; - - chain_size = max_recv_buf; - rc = qelr_chain_alloc(&qp->rq.chain, chain_size, cxt->kernel_page_size, - QELR_RQE_ELEMENT_SIZE); - if (rc) - DP_ERR(cxt->dbg_fp, "create qp: failed to map RQ chain, got %d", rc); - - qp->rq.max_wr = max_recv_wr; - qp->rq.max_sges = cxt->sges_per_recv_wr; - - return rc; -} - -static inline int qelr_create_qp_buffers(struct qelr_devctx *cxt, - struct qelr_qp *qp, - struct ibv_qp_init_attr *attrs) -{ - int rc; - - rc = qelr_create_qp_buffers_sq(cxt, qp, attrs); - if (rc) - return rc; - - rc = qelr_create_qp_buffers_rq(cxt, qp, attrs); - if (rc) { - qelr_chain_free_sq(qp); - return rc; - } - - return 0; -} - -static inline int qelr_configure_qp_sq(struct qelr_devctx *cxt, - struct qelr_qp *qp, - struct ibv_qp_init_attr *attrs, - struct qelr_create_qp_resp *resp) -{ - qp->sq.icid = resp->sq_icid; - qp->sq.db_data.data.icid = htole16(resp->sq_icid); - qp->sq.prod = 0; - qp->sq.db = cxt->db_addr + resp->sq_db_offset; - qp->sq.edpm_db = cxt->db_addr; - - /* shadow SQ */ - qp->sq.max_wr++; /* prod/cons method requires N+1 elements */ - qp->wqe_wr_id = calloc(qp->sq.max_wr, sizeof(*qp->wqe_wr_id)); - if (!qp->wqe_wr_id) { - DP_ERR(cxt->dbg_fp, - "create qp: failed shadow SQ memory allocation\n"); - return -ENOMEM; - } - return 0; -} - -static inline int qelr_configure_qp_rq(struct qelr_devctx *cxt, - struct qelr_qp *qp, - struct ibv_qp_init_attr *attrs, - struct qelr_create_qp_resp *resp) -{ - /* RQ */ - qp->rq.icid = resp->rq_icid; - qp->rq.db_data.data.icid = htole16(resp->rq_icid); - qp->rq.db = cxt->db_addr + resp->rq_db_offset; - qp->rq.iwarp_db2 = cxt->db_addr + resp->rq_db2_offset; - qp->rq.iwarp_db2_data.data.icid = htole16(qp->rq.icid); - qp->rq.iwarp_db2_data.data.value = htole16(DQ_TCM_IWARP_POST_RQ_CF_CMD); - qp->rq.prod = 0; - - /* shadow RQ */ - qp->rq.max_wr++; /* prod/cons method requires N+1 elements */ - qp->rqe_wr_id = calloc(qp->rq.max_wr, sizeof(*qp->rqe_wr_id)); - if (!qp->rqe_wr_id) { - DP_ERR(cxt->dbg_fp, - "create qp: failed shadow RQ memory allocation\n"); - return -ENOMEM; - } - - return 0; -} - -static inline int qelr_configure_qp(struct qelr_devctx *cxt, struct qelr_qp *qp, - struct ibv_qp_init_attr *attrs, - struct qelr_create_qp_resp *resp) -{ - int rc; - - /* general */ - pthread_spin_init(&qp->q_lock, PTHREAD_PROCESS_PRIVATE); - qp->qp_id = resp->qp_id; - qp->state = QELR_QPS_RST; - qp->sq_sig_all = attrs->sq_sig_all; - qp->atomic_supported = resp->atomic_supported; - - rc = qelr_configure_qp_sq(cxt, qp, attrs, resp); - if (rc) - return rc; - rc = qelr_configure_qp_rq(cxt, qp, attrs, resp); - if (rc) - qelr_free_sq(qp); - - return rc; -} - -static inline void qelr_print_qp_init_attr( - struct qelr_devctx *cxt, - struct ibv_qp_init_attr *attr) -{ - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, - "create qp: send_cq=%p, recv_cq=%p, srq=%p, max_inline_data=%d, max_recv_sge=%d, max_recv_wr=%d, max_send_sge=%d, max_send_wr=%d, qp_type=%d, sq_sig_all=%d\n", - attr->send_cq, attr->recv_cq, attr->srq, - attr->cap.max_inline_data, attr->cap.max_recv_sge, - attr->cap.max_recv_wr, attr->cap.max_send_sge, - attr->cap.max_send_wr, attr->qp_type, attr->sq_sig_all); -} - -static inline void -qelr_create_qp_configure_sq_req(struct qelr_qp *qp, - struct qelr_create_qp_req *req) -{ - req->sq_addr = (uintptr_t)qp->sq.chain.first_addr; - req->sq_len = qp->sq.chain.size; -} - -static inline void -qelr_create_qp_configure_rq_req(struct qelr_qp *qp, - struct qelr_create_qp_req *req) -{ - req->rq_addr = (uintptr_t)qp->rq.chain.first_addr; - req->rq_len = qp->rq.chain.size; -} - -static inline void -qelr_create_qp_configure_req(struct qelr_qp *qp, - struct qelr_create_qp_req *req) -{ - memset(req, 0, sizeof(*req)); - req->qp_handle_hi = U64_HI(qp); - req->qp_handle_lo = U64_LO(qp); - qelr_create_qp_configure_sq_req(qp, req); - qelr_create_qp_configure_rq_req(qp, req); -} - -struct ibv_qp *qelr_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attrs) -{ - struct qelr_devctx *cxt = get_qelr_ctx(pd->context); - struct qelr_create_qp_resp resp; - struct qelr_create_qp_req req; - struct qelr_qp *qp; - int rc; - - qelr_print_qp_init_attr(cxt, attrs); - - qp = calloc(1, sizeof(*qp)); - if (!qp) - return NULL; - - rc = qelr_create_qp_buffers(cxt, qp, attrs); - if (rc) - goto err0; - - qelr_create_qp_configure_req(qp, &req); - - rc = ibv_cmd_create_qp(pd, &qp->ibv_qp, attrs, &req.ibv_qp, sizeof(req), - &resp.ibv_resp, sizeof(resp)); - if (rc) { - DP_ERR(cxt->dbg_fp, - "create qp: failed on ibv_cmd_create_qp with %d\n", rc); - goto err1; - } - - rc = qelr_configure_qp(cxt, qp, attrs, &resp); - if (rc) - goto err2; - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, - "create qp: successfully created %p. handle_hi=%x handle_lo=%x\n", - qp, req.qp_handle_hi, req.qp_handle_lo); - - return &qp->ibv_qp; - -err2: - rc = ibv_cmd_destroy_qp(&qp->ibv_qp); - if (rc) - DP_ERR(cxt->dbg_fp, "create qp: fatal fault. rc=%d\n", rc); -err1: - qelr_chain_free_sq(qp); - qelr_chain_free_rq(qp); -err0: - free(qp); - - return NULL; -} - -static void qelr_print_ah_attr(struct qelr_devctx *cxt, struct ibv_ah_attr *attr) -{ - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, - "grh.dgid=[%#" PRIx64 ":%#" PRIx64 "], grh.flow_label=%d, grh.sgid_index=%d, grh.hop_limit=%d, grh.traffic_class=%d, dlid=%d, sl=%d, src_path_bits=%d, static_rate = %d, port_num=%d\n", - be64toh(attr->grh.dgid.global.interface_id), - be64toh(attr->grh.dgid.global.subnet_prefix), - attr->grh.flow_label, attr->grh.hop_limit, - attr->grh.sgid_index, attr->grh.traffic_class, attr->dlid, - attr->sl, attr->src_path_bits, - attr->static_rate, attr->port_num); -} - -static void qelr_print_qp_attr(struct qelr_devctx *cxt, struct ibv_qp_attr *attr) -{ - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, - "\tqp_state=%d\tcur_qp_state=%d\tpath_mtu=%d\tpath_mig_state=%d\tqkey=%d\trq_psn=%d\tsq_psn=%d\tdest_qp_num=%d\tqp_access_flags=%d\tmax_inline_data=%d\tmax_recv_sge=%d\tmax_recv_wr=%d\tmax_send_sge=%d\tmax_send_wr=%d\tpkey_index=%d\talt_pkey_index=%d\ten_sqd_async_notify=%d\tsq_draining=%d\tmax_rd_atomic=%d\tmax_dest_rd_atomic=%d\tmin_rnr_timer=%d\tport_num=%d\ttimeout=%d\tretry_cnt=%d\trnr_retry=%d\talt_port_num=%d\talt_timeout=%d\n", - attr->qp_state, attr->cur_qp_state, attr->path_mtu, - attr->path_mig_state, attr->qkey, attr->rq_psn, attr->sq_psn, - attr->dest_qp_num, attr->qp_access_flags, - attr->cap.max_inline_data, attr->cap.max_recv_sge, - attr->cap.max_recv_wr, attr->cap.max_send_sge, - attr->cap.max_send_wr, attr->pkey_index, - attr->alt_pkey_index, attr->en_sqd_async_notify, - attr->sq_draining, attr->max_rd_atomic, - attr->max_dest_rd_atomic, attr->min_rnr_timer, - attr->port_num, attr->timeout, attr->retry_cnt, - attr->rnr_retry, attr->alt_port_num, attr->alt_timeout); - - qelr_print_ah_attr(cxt, &attr->ah_attr); - qelr_print_ah_attr(cxt, &attr->alt_ah_attr); -} - -int qelr_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - struct qelr_devctx *cxt = get_qelr_ctx(qp->context); - int rc; - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, "QP Query %p, attr_mask=0x%x\n", - get_qelr_qp(qp), attr_mask); - - rc = ibv_cmd_query_qp(qp, attr, attr_mask, - init_attr, &cmd, sizeof(cmd)); - - qelr_print_qp_attr(cxt, attr); - - return rc; -} - -static enum qelr_qp_state get_qelr_qp_state(enum ibv_qp_state qps) -{ - switch (qps) { - case IBV_QPS_RESET: - return QELR_QPS_RST; - case IBV_QPS_INIT: - return QELR_QPS_INIT; - case IBV_QPS_RTR: - return QELR_QPS_RTR; - case IBV_QPS_RTS: - return QELR_QPS_RTS; - case IBV_QPS_SQD: - return QELR_QPS_SQD; - case IBV_QPS_SQE: - return QELR_QPS_SQE; - case IBV_QPS_ERR: - default: - return QELR_QPS_ERR; - }; -} - -static void qelr_reset_qp_hwq_info(struct qelr_qp_hwq_info *q) -{ - qelr_chain_reset(&q->chain); - q->prod = 0; - q->cons = 0; - q->wqe_cons = 0; - q->db_data.data.value = 0; -} - -static int qelr_update_qp_state(struct qelr_qp *qp, - enum ibv_qp_state new_ib_state) -{ - int status = 0; - enum qelr_qp_state new_state; - - /* iWARP states are updated implicitely by driver and don't have a - * real purpose in user-lib. - */ - if (IS_IWARP(qp->ibv_qp.context->device)) - return 0; - - new_state = get_qelr_qp_state(new_ib_state); - - pthread_spin_lock(&qp->q_lock); - - if (new_state == qp->state) { - pthread_spin_unlock(&qp->q_lock); - return 0; - } - - switch (qp->state) { - case QELR_QPS_RST: - switch (new_state) { - case QELR_QPS_INIT: - qp->prev_wqe_size = 0; - qelr_reset_qp_hwq_info(&qp->sq); - qelr_reset_qp_hwq_info(&qp->rq); - break; - default: - status = -EINVAL; - break; - }; - break; - case QELR_QPS_INIT: - /* INIT->XXX */ - switch (new_state) { - case QELR_QPS_RTR: - /* Update doorbell (in case post_recv was done before - * move to RTR) - */ - if (IS_ROCE(qp->ibv_qp.context->device)) { - mmio_wc_start(); - writel(qp->rq.db_data.raw, qp->rq.db); - mmio_flush_writes(); - } - break; - case QELR_QPS_ERR: - break; - default: - /* invalid state change. */ - status = -EINVAL; - break; - }; - break; - case QELR_QPS_RTR: - /* RTR->XXX */ - switch (new_state) { - case QELR_QPS_RTS: - break; - case QELR_QPS_ERR: - break; - default: - /* invalid state change. */ - status = -EINVAL; - break; - }; - break; - case QELR_QPS_RTS: - /* RTS->XXX */ - switch (new_state) { - case QELR_QPS_SQD: - case QELR_QPS_SQE: - break; - case QELR_QPS_ERR: - break; - default: - /* invalid state change. */ - status = -EINVAL; - break; - }; - break; - case QELR_QPS_SQD: - /* SQD->XXX */ - switch (new_state) { - case QELR_QPS_RTS: - case QELR_QPS_SQE: - case QELR_QPS_ERR: - break; - default: - /* invalid state change. */ - status = -EINVAL; - break; - }; - break; - case QELR_QPS_SQE: - switch (new_state) { - case QELR_QPS_RTS: - case QELR_QPS_ERR: - break; - default: - /* invalid state change. */ - status = -EINVAL; - break; - }; - break; - case QELR_QPS_ERR: - /* ERR->XXX */ - switch (new_state) { - case QELR_QPS_RST: - break; - default: - status = -EINVAL; - break; - }; - break; - default: - status = -EINVAL; - break; - }; - if (!status) - qp->state = new_state; - - pthread_spin_unlock(&qp->q_lock); - - return status; -} - -int qelr_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - struct qelr_qp *qp = get_qelr_qp(ibqp); - struct qelr_devctx *cxt = get_qelr_ctx(ibqp->context); - union ibv_gid sgid, *p_dgid; - int rc; - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, "QP Modify %p, attr_mask=0x%x\n", - qp, attr_mask); - - qelr_print_qp_attr(cxt, attr); - - rc = ibv_cmd_modify_qp(ibqp, attr, attr_mask, &cmd, sizeof(cmd)); - if (rc) { - DP_ERR(cxt->dbg_fp, "QP Modify: Failed command. rc=%d\n", rc); - return rc; - } - - if (attr_mask & IBV_QP_STATE) { - rc = qelr_update_qp_state(qp, attr->qp_state); - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, - "QP Modify state %d->%d, rc=%d\n", qp->state, - attr->qp_state, rc); - if (rc) { - DP_ERR(cxt->dbg_fp, - "QP Modify: Failed to update state. rc=%d\n", - rc); - - return rc; - } - } - - /* EDPM must be disabled if GIDs match */ - if (attr_mask & IBV_QP_AV) { - rc = ibv_query_gid(ibqp->context, attr->ah_attr.port_num, - attr->ah_attr.grh.sgid_index, &sgid); - - if (!rc) { - p_dgid = &attr->ah_attr.grh.dgid; - qp->edpm_disabled = !memcmp(&sgid, p_dgid, - sizeof(sgid)); - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, - "QP Modify: %p, edpm_disabled=%d\n", qp, - qp->edpm_disabled); - } else { - DP_ERR(cxt->dbg_fp, - "QP Modify: Failed querying GID. rc=%d\n", - rc); - } - } - - return 0; -} - -int qelr_destroy_qp(struct ibv_qp *ibqp) -{ - struct qelr_devctx *cxt = get_qelr_ctx(ibqp->context); - struct qelr_qp *qp = get_qelr_qp(ibqp); - int rc = 0; - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, "destroy qp: %p\n", qp); - - rc = ibv_cmd_destroy_qp(ibqp); - if (rc) { - DP_ERR(cxt->dbg_fp, - "destroy qp: failed to destroy %p, got %d.\n", qp, rc); - return rc; - } - - qelr_free_sq(qp); - qelr_free_rq(qp); - qelr_chain_free_sq(qp); - qelr_chain_free_rq(qp); - free(qp); - - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, - "destroy cq: successfully destroyed %p\n", qp); - - return 0; -} - -static int sge_data_len(struct ibv_sge *sg_list, int num_sge) -{ - int i, len = 0; - - for (i = 0; i < num_sge; i++) - len += sg_list[i].length; - return len; -} - -static void swap_wqe_data64(uint64_t *p) -{ - __be64 *bep=(__be64 *)p; - int i; - - for (i = 0; i < ROCE_WQE_ELEM_SIZE / sizeof(uint64_t); i++, p++) - *bep = htobe64(*p); -} - -static inline void qelr_init_dpm_info(struct qelr_devctx *cxt, - struct qelr_qp *qp, - struct ibv_send_wr *wr, - struct qelr_dpm *dpm, - int data_size) -{ - dpm->is_edpm = 0; - - /* Currently dpm is not supported for iWARP */ - if (IS_IWARP(cxt->ibv_ctx.device)) - return; - - if (qelr_chain_is_full(&qp->sq.chain) && - wr->send_flags & IBV_SEND_INLINE && !qp->edpm_disabled) { - memset(dpm, 0, sizeof(*dpm)); - dpm->rdma_ext = (struct qelr_rdma_ext *)&dpm->payload; - dpm->is_edpm = 1; - } -} - -#define QELR_IB_OPCODE_SEND_ONLY 0x04 -#define QELR_IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE 0x05 -#define QELR_IB_OPCODE_RDMA_WRITE_ONLY 0x0a -#define QELR_IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE 0x0b -#define QELR_IS_IMM(opcode) \ - ((opcode == QELR_IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE) || \ - (opcode == QELR_IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE)) - -static inline void qelr_edpm_set_msg_data(struct qelr_qp *qp, - struct qelr_dpm *dpm, - uint8_t opcode, - uint16_t length, - uint8_t se, - uint8_t comp) -{ - uint32_t wqe_size, dpm_size, params; - - params = 0; - wqe_size = length + (QELR_IS_IMM(opcode)? sizeof(uint32_t) : 0); - dpm_size = wqe_size + sizeof(struct db_roce_dpm_data); - - SET_FIELD(params, DB_ROCE_DPM_PARAMS_DPM_TYPE, DPM_ROCE); - SET_FIELD(params, DB_ROCE_DPM_PARAMS_OPCODE, opcode); - SET_FIELD(params, DB_ROCE_DPM_PARAMS_WQE_SIZE, wqe_size); - SET_FIELD(params, DB_ROCE_DPM_PARAMS_COMPLETION_FLG, comp ? 1 : 0); - SET_FIELD(params, DB_ROCE_DPM_PARAMS_S_FLG, se ? 1 : 0); - SET_FIELD(params, DB_ROCE_DPM_PARAMS_SIZE, - (dpm_size + sizeof(uint64_t) - 1) / sizeof(uint64_t)); - - dpm->msg.data.params.params = htole32(params); -} - -static inline void qelr_edpm_set_inv_imm(struct qelr_qp *qp, - struct qelr_dpm *dpm, - __be32 data) -{ - memcpy(&dpm->payload[dpm->payload_offset], &data, sizeof(data)); - - dpm->payload_offset += sizeof(data); - dpm->payload_size += sizeof(data); -} - -static inline void qelr_edpm_set_rdma_ext(struct qelr_qp *qp, - struct qelr_dpm *dpm, - uint64_t remote_addr, - uint32_t rkey) -{ - dpm->rdma_ext->remote_va = htobe64(remote_addr); - dpm->rdma_ext->remote_key = htobe32(rkey); - dpm->payload_offset += sizeof(*dpm->rdma_ext); - dpm->payload_size += sizeof(*dpm->rdma_ext); -} - -static inline void qelr_edpm_set_payload(struct qelr_qp *qp, - struct qelr_dpm *dpm, char *buf, - uint32_t length) -{ - memcpy(&dpm->payload[dpm->payload_offset], buf, length); - - dpm->payload_offset += length; -} - -static void qelr_prepare_sq_inline_data(struct qelr_qp *qp, - struct qelr_dpm *dpm, - int data_size, - uint8_t *wqe_size, - struct ibv_send_wr *wr, - uint8_t *bits, uint8_t bit) -{ - int i; - uint32_t seg_siz; - char *seg_prt, *wqe; - - if (!data_size) - return; - - /* set the bit */ - *bits |= bit; - - seg_prt = NULL; - wqe = NULL; - seg_siz = 0; - - /* copy data inline */ - for (i = 0; i < wr->num_sge; i++) { - uint32_t len = wr->sg_list[i].length; - void *src = (void *)(uintptr_t)wr->sg_list[i].addr; - - if (dpm->is_edpm) - qelr_edpm_set_payload(qp, dpm, src, len); - - while (len > 0) { - uint32_t cur; - - /* new segment required */ - if (!seg_siz) { - wqe = (char *)qelr_chain_produce(&qp->sq.chain); - seg_prt = wqe; - seg_siz = sizeof(struct rdma_sq_common_wqe); - (*wqe_size)++; - } - - /* calculate currently allowed length */ - cur = min(len, seg_siz); - - memcpy(seg_prt, src, cur); - - /* update segment variables */ - seg_prt += cur; - seg_siz -= cur; - /* update sge variables */ - src += cur; - len -= cur; - - /* swap fully-completed segments */ - if (!seg_siz) - swap_wqe_data64((uint64_t *)wqe); - } - } - - /* swap last not completed segment */ - if (seg_siz) - swap_wqe_data64((uint64_t *)wqe); - - if (dpm->is_edpm) { - dpm->payload_size += data_size; - - if (wr->opcode == IBV_WR_RDMA_WRITE || - wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM) - dpm->rdma_ext->dma_length = htobe32(data_size); - } -} - -static void qelr_prepare_sq_sges(struct qelr_qp *qp, - struct qelr_dpm *dpm, - uint8_t *wqe_size, - struct ibv_send_wr *wr) -{ - int i; - - for (i = 0; i < wr->num_sge; i++) { - struct rdma_sq_sge *sge = qelr_chain_produce(&qp->sq.chain); - - TYPEPTR_ADDR_SET(sge, addr, wr->sg_list[i].addr); - sge->l_key = htole32(wr->sg_list[i].lkey); - sge->length = htole32(wr->sg_list[i].length); - } - - if (wqe_size) - *wqe_size += wr->num_sge; -} - -static uint32_t qelr_prepare_sq_rdma_data(struct qelr_qp *qp, - struct qelr_dpm *dpm, - int data_size, - uint8_t *p_wqe_size, - struct rdma_sq_rdma_wqe_1st *rwqe, - struct rdma_sq_rdma_wqe_2nd *rwqe2, - struct ibv_send_wr *wr, - bool is_imm) -{ - memset(rwqe2, 0, sizeof(*rwqe2)); - rwqe2->r_key = htole32(wr->wr.rdma.rkey); - TYPEPTR_ADDR_SET(rwqe2, remote_va, wr->wr.rdma.remote_addr); - rwqe->length = htole32(data_size); - - if (is_imm) - rwqe->imm_data = htole32(be32toh(wr->imm_data)); - - if (wr->send_flags & IBV_SEND_INLINE && - (wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM || - wr->opcode == IBV_WR_RDMA_WRITE)) { - uint8_t flags = 0; - - SET_FIELD2(flags, RDMA_SQ_RDMA_WQE_1ST_INLINE_FLG, 1); - qelr_prepare_sq_inline_data(qp, dpm, data_size, - p_wqe_size, wr, - &rwqe->flags, flags); - rwqe->wqe_size = *p_wqe_size; - } else { - qelr_prepare_sq_sges(qp, dpm, p_wqe_size, wr); - rwqe->wqe_size = *p_wqe_size; - } - - return data_size; -} - -static uint32_t qelr_prepare_sq_send_data(struct qelr_qp *qp, - struct qelr_dpm *dpm, - int data_size, - uint8_t *p_wqe_size, - struct rdma_sq_send_wqe_1st *swqe, - struct rdma_sq_send_wqe_2st *swqe2, - struct ibv_send_wr *wr, - bool is_imm) -{ - memset(swqe2, 0, sizeof(*swqe2)); - swqe->length = htole32(data_size); - - if (is_imm) - swqe->inv_key_or_imm_data = htole32(be32toh(wr->imm_data)); - - if (wr->send_flags & IBV_SEND_INLINE) { - uint8_t flags = 0; - - SET_FIELD2(flags, RDMA_SQ_SEND_WQE_INLINE_FLG, 1); - qelr_prepare_sq_inline_data(qp, dpm, data_size, - p_wqe_size, wr, - &swqe->flags, flags); - swqe->wqe_size = *p_wqe_size; - } else { - qelr_prepare_sq_sges(qp, dpm, p_wqe_size, wr); - swqe->wqe_size = *p_wqe_size; - } - - return data_size; -} - -static enum ibv_wc_opcode qelr_ibv_to_wc_opcode(enum ibv_wr_opcode opcode) -{ - switch (opcode) { - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - return IBV_WC_RDMA_WRITE; - case IBV_WR_SEND_WITH_IMM: - case IBV_WR_SEND: - return IBV_WC_SEND; - case IBV_WR_RDMA_READ: - return IBV_WC_RDMA_READ; - case IBV_WR_ATOMIC_CMP_AND_SWP: - return IBV_WC_COMP_SWAP; - case IBV_WR_ATOMIC_FETCH_AND_ADD: - return IBV_WC_FETCH_ADD; - default: - return IBV_WC_SEND; - } -} - -static inline void doorbell_qp(struct qelr_qp *qp) -{ - mmio_wc_start(); - writel(qp->sq.db_data.raw, qp->sq.db); - mmio_flush_writes(); -} - -static inline void doorbell_dpm_qp(struct qelr_devctx *cxt, struct qelr_qp *qp, - struct qelr_dpm *dpm) -{ - uint32_t offset = 0; - uint64_t data; - uint64_t *payload = (uint64_t *)dpm->payload; - uint32_t num_dwords; - int bytes = 0; - void *db_addr; - - mmio_wc_start(); - - /* Write message header */ - dpm->msg.data.icid = qp->sq.db_data.data.icid; - dpm->msg.data.prod_val = qp->sq.db_data.data.value; - db_addr = qp->sq.edpm_db; - writeq(dpm->msg.raw, db_addr); - - - /* Write mesage body */ - bytes += sizeof(uint64_t); - num_dwords = (dpm->payload_size + sizeof(uint64_t) - 1) / - sizeof(uint64_t); - db_addr += sizeof(dpm->msg.data); - - while (offset < num_dwords) { - data = payload[offset]; - writeq(data, db_addr); - - bytes += sizeof(uint64_t); - db_addr += sizeof(uint64_t); - - /* Since we rewrite the buffer every 64 bytes we need to flush - * it here, otherwise the CPU could optimize away the - * duplicate stores. - */ - if (bytes == 64) { - mmio_flush_writes(); - bytes = 0; - } - offset++; - } - - mmio_flush_writes(); -} - -static inline int qelr_can_post_send(struct qelr_devctx *cxt, - struct qelr_qp *qp, - struct ibv_send_wr *wr, - int data_size) -{ - /* Invalid WR */ - if (wr->num_sge > qp->sq.max_sges) { - DP_ERR(cxt->dbg_fp, - "error: WR is bad. Post send on QP %p failed\n", - qp); - return -EINVAL; - } - - /* WR overflow */ - if (qelr_wq_is_full(&qp->sq)) { - DP_ERR(cxt->dbg_fp, - "error: WQ is full. Post send on QP %p failed (this error appears only once)\n", - qp); - return -ENOMEM; - } - - /* WQE overflow */ - if (qelr_chain_get_elem_left_u32(&qp->sq.chain) < - QELR_MAX_SQ_WQE_SIZE) { - DP_ERR(cxt->dbg_fp, - "error: WQ PBL is full. Post send on QP %p failed (this error appears only once)\n", - qp); - return -ENOMEM; - } - - if ((wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP || - wr->opcode == IBV_WR_ATOMIC_FETCH_AND_ADD) && - !qp->atomic_supported) { - DP_ERR(cxt->dbg_fp, "Atomic not supported on this machine\n"); - return -EINVAL; - } - - if ((wr->send_flags & IBV_SEND_INLINE) && - (data_size > ROCE_REQ_MAX_INLINE_DATA_SIZE)) { - DP_ERR(cxt->dbg_fp, "Too much inline data in WR: %d\n", data_size); - return -EINVAL; - } - - - return 0; -} - -static int __qelr_post_send(struct qelr_devctx *cxt, struct qelr_qp *qp, - struct ibv_send_wr *wr, int data_size, - int *normal_db_required) -{ - uint8_t se, comp, fence; - struct rdma_sq_common_wqe *wqe; - struct rdma_sq_send_wqe_1st *swqe; - struct rdma_sq_send_wqe_2st *swqe2; - struct rdma_sq_rdma_wqe_1st *rwqe; - struct rdma_sq_rdma_wqe_2nd *rwqe2; - struct rdma_sq_atomic_wqe_1st *awqe1; - struct rdma_sq_atomic_wqe_2nd *awqe2; - struct rdma_sq_atomic_wqe_3rd *awqe3; - struct qelr_dpm dpm; - uint32_t wqe_length; - uint8_t wqe_size; - uint16_t db_val; - int rc = 0; - - qelr_init_dpm_info(cxt, qp, wr, &dpm, data_size); - - wqe = qelr_chain_produce(&qp->sq.chain); - - comp = (!!(wr->send_flags & IBV_SEND_SIGNALED)) || - (!!qp->sq_sig_all); - qp->wqe_wr_id[qp->sq.prod].signaled = comp; - - /* common fields */ - wqe->flags = 0; - se = !!(wr->send_flags & IBV_SEND_SOLICITED); - fence = !!(wr->send_flags & IBV_SEND_FENCE); - SET_FIELD2(wqe->flags, RDMA_SQ_COMMON_WQE_SE_FLG, se); - SET_FIELD2(wqe->flags, RDMA_SQ_COMMON_WQE_COMP_FLG, comp); - SET_FIELD2(wqe->flags, RDMA_SQ_COMMON_WQE_RD_FENCE_FLG, fence); - wqe->prev_wqe_size = qp->prev_wqe_size; - - qp->wqe_wr_id[qp->sq.prod].opcode = qelr_ibv_to_wc_opcode(wr->opcode); - - switch (wr->opcode) { - case IBV_WR_SEND_WITH_IMM: - wqe->req_type = RDMA_SQ_REQ_TYPE_SEND_WITH_IMM; - swqe = (struct rdma_sq_send_wqe_1st *)wqe; - - wqe_size = sizeof(struct rdma_sq_send_wqe) / RDMA_WQE_BYTES; - swqe2 = (struct rdma_sq_send_wqe_2st *)qelr_chain_produce(&qp->sq.chain); - - if (dpm.is_edpm) - qelr_edpm_set_inv_imm(qp, &dpm, wr->imm_data); - - wqe_length = qelr_prepare_sq_send_data(qp, &dpm, data_size, - &wqe_size, swqe, swqe2, - wr, 1 /* Imm */); - - if (dpm.is_edpm) - qelr_edpm_set_msg_data(qp, &dpm, - QELR_IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE, - wqe_length, se, comp); - - qp->wqe_wr_id[qp->sq.prod].wqe_size = wqe_size; - qp->prev_wqe_size = wqe_size; - qp->wqe_wr_id[qp->sq.prod].bytes_len = wqe_length; - break; - - case IBV_WR_SEND: - wqe->req_type = RDMA_SQ_REQ_TYPE_SEND; - swqe = (struct rdma_sq_send_wqe_1st *)wqe; - - wqe_size = sizeof(struct rdma_sq_send_wqe) / RDMA_WQE_BYTES; - swqe2 = (struct rdma_sq_send_wqe_2st *)qelr_chain_produce(&qp->sq.chain); - wqe_length = qelr_prepare_sq_send_data(qp, &dpm, data_size, - &wqe_size, swqe, swqe2, - wr, 0); - - if (dpm.is_edpm) - qelr_edpm_set_msg_data(qp, &dpm, - QELR_IB_OPCODE_SEND_ONLY, - wqe_length, se, comp); - - qp->wqe_wr_id[qp->sq.prod].wqe_size = wqe_size; - qp->prev_wqe_size = wqe_size; - qp->wqe_wr_id[qp->sq.prod].bytes_len = wqe_length; - break; - - case IBV_WR_RDMA_WRITE_WITH_IMM: - wqe->req_type = RDMA_SQ_REQ_TYPE_RDMA_WR_WITH_IMM; - rwqe = (struct rdma_sq_rdma_wqe_1st *)wqe; - - wqe_size = sizeof(struct rdma_sq_rdma_wqe) / RDMA_WQE_BYTES; - rwqe2 = (struct rdma_sq_rdma_wqe_2nd *)qelr_chain_produce(&qp->sq.chain); - if (dpm.is_edpm) { - qelr_edpm_set_rdma_ext(qp, &dpm, wr->wr.rdma.remote_addr, - wr->wr.rdma.rkey); - qelr_edpm_set_inv_imm(qp, &dpm, wr->imm_data); - } - - wqe_length = qelr_prepare_sq_rdma_data(qp, &dpm, data_size, &wqe_size, - rwqe, rwqe2, wr, 1 /* Imm */); - if (dpm.is_edpm) - qelr_edpm_set_msg_data(qp, &dpm, - QELR_IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE, - wqe_length + sizeof(*dpm.rdma_ext), - se, comp); - qp->wqe_wr_id[qp->sq.prod].wqe_size = wqe_size; - qp->prev_wqe_size = wqe_size; - qp->wqe_wr_id[qp->sq.prod].bytes_len = wqe_length; - break; - - case IBV_WR_RDMA_WRITE: - wqe->req_type = RDMA_SQ_REQ_TYPE_RDMA_WR; - rwqe = (struct rdma_sq_rdma_wqe_1st *)wqe; - - wqe_size = sizeof(struct rdma_sq_rdma_wqe) / RDMA_WQE_BYTES; - rwqe2 = (struct rdma_sq_rdma_wqe_2nd *)qelr_chain_produce(&qp->sq.chain); - if (dpm.is_edpm) - qelr_edpm_set_rdma_ext(qp, &dpm, - wr->wr.rdma.remote_addr, - wr->wr.rdma.rkey); - - wqe_length = qelr_prepare_sq_rdma_data(qp, &dpm, data_size, &wqe_size, - rwqe, rwqe2, wr, 0); - if (dpm.is_edpm) - qelr_edpm_set_msg_data(qp, &dpm, - QELR_IB_OPCODE_RDMA_WRITE_ONLY, - wqe_length + - sizeof(*dpm.rdma_ext), - se, comp); - qp->wqe_wr_id[qp->sq.prod].wqe_size = wqe_size; - qp->prev_wqe_size = wqe_size; - qp->wqe_wr_id[qp->sq.prod].bytes_len = wqe_length; - break; - - case IBV_WR_RDMA_READ: - wqe->req_type = RDMA_SQ_REQ_TYPE_RDMA_RD; - rwqe = (struct rdma_sq_rdma_wqe_1st *)wqe; - - wqe_size = sizeof(struct rdma_sq_rdma_wqe) / RDMA_WQE_BYTES; - rwqe2 = (struct rdma_sq_rdma_wqe_2nd *)qelr_chain_produce(&qp->sq.chain); - wqe_length = qelr_prepare_sq_rdma_data(qp, &dpm, data_size, &wqe_size, - rwqe, rwqe2, wr, 0); - qp->wqe_wr_id[qp->sq.prod].wqe_size = wqe_size; - qp->prev_wqe_size = wqe_size; - qp->wqe_wr_id[qp->sq.prod].bytes_len = wqe_length; - break; - - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - awqe1 = (struct rdma_sq_atomic_wqe_1st *)wqe; - awqe1->wqe_size = 4; - - awqe2 = (struct rdma_sq_atomic_wqe_2nd *)qelr_chain_produce(&qp->sq.chain); - TYPEPTR_ADDR_SET(awqe2, remote_va, wr->wr.atomic.remote_addr); - awqe2->r_key = htole32(wr->wr.atomic.rkey); - - awqe3 = (struct rdma_sq_atomic_wqe_3rd *)qelr_chain_produce(&qp->sq.chain); - - if (wr->opcode == IBV_WR_ATOMIC_FETCH_AND_ADD) { - wqe->req_type = RDMA_SQ_REQ_TYPE_ATOMIC_ADD; - TYPEPTR_ADDR_SET(awqe3, swap_data, wr->wr.atomic.compare_add); - } else { - wqe->req_type = RDMA_SQ_REQ_TYPE_ATOMIC_CMP_AND_SWAP; - TYPEPTR_ADDR_SET(awqe3, swap_data, wr->wr.atomic.swap); - TYPEPTR_ADDR_SET(awqe3, cmp_data, wr->wr.atomic.compare_add); - } - - qelr_prepare_sq_sges(qp, &dpm, NULL, wr); - - qp->wqe_wr_id[qp->sq.prod].wqe_size = awqe1->wqe_size; - qp->prev_wqe_size = awqe1->wqe_size; - - break; - - default: - /* restore prod to its position before this WR was processed */ - qelr_chain_set_prod(&qp->sq.chain, - le16toh(qp->sq.db_data.data.value), - wqe); - - /* restore prev_wqe_size */ - qp->prev_wqe_size = wqe->prev_wqe_size; - - rc = -EINVAL; - DP_ERR(cxt->dbg_fp, - "Invalid opcode %d in work request on QP %p\n", - wr->opcode, qp); - break; - } - - if (rc) - return rc; - - qp->wqe_wr_id[qp->sq.prod].wr_id = wr->wr_id; - qelr_inc_sw_prod_u16(&qp->sq); - db_val = le16toh(qp->sq.db_data.data.value) + 1; - qp->sq.db_data.data.value = htole16(db_val); - - if (dpm.is_edpm) { - doorbell_dpm_qp(cxt, qp, &dpm); - *normal_db_required = 0; - } else { - *normal_db_required = 1; - } - - return 0; -} - -int qelr_post_send(struct ibv_qp *ib_qp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - struct qelr_devctx *cxt = get_qelr_ctx(ib_qp->context); - struct qelr_qp *qp = get_qelr_qp(ib_qp); - int doorbell_required = 0; - *bad_wr = NULL; - int rc = 0; - - pthread_spin_lock(&qp->q_lock); - - if (IS_ROCE(ib_qp->context->device) && - (qp->state != QELR_QPS_RTS && qp->state != QELR_QPS_ERR && - qp->state != QELR_QPS_SQD)) { - pthread_spin_unlock(&qp->q_lock); - *bad_wr = wr; - return -EINVAL; - } - - while (wr) { - int data_size = sge_data_len(wr->sg_list, wr->num_sge); - - rc = qelr_can_post_send(cxt, qp, wr, data_size); - if (rc) { - *bad_wr = wr; - break; - } - - rc = __qelr_post_send(cxt, qp, wr, data_size, &doorbell_required); - if (rc) { - *bad_wr = wr; - break; - } - - wr = wr->next; - } - - if (doorbell_required) - doorbell_qp(qp); - - pthread_spin_unlock(&qp->q_lock); - - return rc; -} - -int qelr_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - int status = 0; - struct qelr_qp *qp = get_qelr_qp(ibqp); - struct qelr_devctx *cxt = get_qelr_ctx(ibqp->context); - uint16_t db_val; - uint8_t iwarp = IS_IWARP(ibqp->context->device); - - pthread_spin_lock(&qp->q_lock); - - if (!iwarp && qp->state == QELR_QPS_RST) { - pthread_spin_unlock(&qp->q_lock); - *bad_wr = wr; - return -EINVAL; - } - - while (wr) { - int i; - - if (qelr_chain_get_elem_left_u32(&qp->rq.chain) < - QELR_MAX_RQ_WQE_SIZE || wr->num_sge > qp->rq.max_sges) { - DP_ERR(cxt->dbg_fp, - "Can't post WR (%d < %d) || (%d > %d)\n", - qelr_chain_get_elem_left_u32(&qp->rq.chain), - QELR_MAX_RQ_WQE_SIZE, wr->num_sge, - qp->rq.max_sges); - status = -ENOMEM; - *bad_wr = wr; - break; - } - for (i = 0; i < wr->num_sge; i++) { - uint32_t flags = 0; - struct rdma_rq_sge *rqe; - - /* first one must include the number of SGE in the - * list - */ - if (!i) - SET_FIELD(flags, RDMA_RQ_SGE_NUM_SGES, - wr->num_sge); - - SET_FIELD(flags, RDMA_RQ_SGE_L_KEY, - wr->sg_list[i].lkey); - rqe = qelr_chain_produce(&qp->rq.chain); - RQ_SGE_SET(rqe, wr->sg_list[i].addr, - wr->sg_list[i].length, flags); - } - /* Special case of no sges. FW requires between 1-4 sges... - * in this case we need to post 1 sge with length zero. this is - * because rdma write with immediate consumes an RQ. - */ - if (!wr->num_sge) { - uint32_t flags = 0; - struct rdma_rq_sge *rqe; - - /* first one must include the number of SGE in the - * list - */ - SET_FIELD(flags, RDMA_RQ_SGE_L_KEY, 0); - SET_FIELD(flags, RDMA_RQ_SGE_NUM_SGES, 1); - - rqe = qelr_chain_produce(&qp->rq.chain); - RQ_SGE_SET(rqe, 0, 0, flags); - i = 1; - } - - qp->rqe_wr_id[qp->rq.prod].wr_id = wr->wr_id; - qp->rqe_wr_id[qp->rq.prod].wqe_size = i; - - qelr_inc_sw_prod_u16(&qp->rq); - - mmio_wc_start(); - - db_val = le16toh(qp->rq.db_data.data.value) + 1; - qp->rq.db_data.data.value = htole16(db_val); - - writel(qp->rq.db_data.raw, qp->rq.db); - mmio_flush_writes(); - - if (iwarp) { - writel(qp->rq.iwarp_db2_data.raw, qp->rq.iwarp_db2); - mmio_flush_writes(); - } - wr = wr->next; - } - - pthread_spin_unlock(&qp->q_lock); - - return status; -} - -static int is_valid_cqe(struct qelr_cq *cq, union rdma_cqe *cqe) -{ - struct rdma_cqe_requester *resp_cqe = &cqe->req; - - return (resp_cqe->flags & RDMA_CQE_REQUESTER_TOGGLE_BIT_MASK) == - cq->chain_toggle; -} - -static enum rdma_cqe_type cqe_get_type(union rdma_cqe *cqe) -{ - struct rdma_cqe_requester *resp_cqe = &cqe->req; - - return GET_FIELD(resp_cqe->flags, RDMA_CQE_REQUESTER_TYPE); -} - -static struct qelr_qp *cqe_get_qp(union rdma_cqe *cqe) -{ - struct regpair *qph = &cqe->req.qp_handle; - - return (struct qelr_qp *)HILO_U64(le32toh(qph->hi), le32toh(qph->lo)); -} - -static int process_req(struct qelr_qp *qp, struct qelr_cq *cq, int num_entries, - struct ibv_wc *wc, uint16_t hw_cons, - enum ibv_wc_status status, int force) -{ - struct qelr_devctx *cxt = get_qelr_ctx(qp->ibv_qp.context); - uint16_t cnt = 0; - - while (num_entries && qp->sq.wqe_cons != hw_cons) { - if (!qp->wqe_wr_id[qp->sq.cons].signaled && !force) { - /* skip WC */ - goto next_cqe; - } - - /* fill WC */ - wc->status = status; - wc->wc_flags = 0; - wc->qp_num = qp->qp_id; - - /* common section */ - wc->wr_id = qp->wqe_wr_id[qp->sq.cons].wr_id; - wc->opcode = qp->wqe_wr_id[qp->sq.cons].opcode; - - switch (wc->opcode) { - case IBV_WC_RDMA_WRITE: - wc->byte_len = qp->wqe_wr_id[qp->sq.cons].bytes_len; - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_CQ, - "POLL REQ CQ: IBV_WC_RDMA_WRITE byte_len=%d\n", - qp->wqe_wr_id[qp->sq.cons].bytes_len); - break; - case IBV_WC_COMP_SWAP: - case IBV_WC_FETCH_ADD: - wc->byte_len = 8; - break; - case IBV_WC_RDMA_READ: - case IBV_WC_SEND: - case IBV_WC_BIND_MW: - wc->byte_len = qp->wqe_wr_id[qp->sq.cons].bytes_len; - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_CQ, - "POLL REQ CQ: IBV_WC_RDMA_READ / IBV_WC_SEND\n"); - break; - default: - break; - } - - num_entries--; - wc++; - cnt++; -next_cqe: - while (qp->wqe_wr_id[qp->sq.cons].wqe_size--) - qelr_chain_consume(&qp->sq.chain); - qelr_inc_sw_cons_u16(&qp->sq); - } - - return cnt; -} - -static int qelr_poll_cq_req(struct qelr_qp *qp, struct qelr_cq *cq, - int num_entries, struct ibv_wc *wc, - struct rdma_cqe_requester *req) -{ - struct qelr_devctx *cxt = get_qelr_ctx(qp->ibv_qp.context); - uint16_t sq_cons = le16toh(req->sq_cons); - int cnt = 0; - - switch (req->status) { - case RDMA_CQE_REQ_STS_OK: - cnt = process_req(qp, cq, num_entries, wc, sq_cons, - IBV_WC_SUCCESS, 0); - break; - case RDMA_CQE_REQ_STS_WORK_REQUEST_FLUSHED_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with ROCE_CQE_REQ_STS_WORK_REQUEST_FLUSHED_ERR. QP icid=0x%x\n", - qp->sq.icid); - cnt = process_req(qp, cq, num_entries, wc, sq_cons, - IBV_WC_WR_FLUSH_ERR, 0); - break; - default: /* other errors case */ - /* process all WQE before the consumer */ - qp->state = QELR_QPS_ERR; - cnt = process_req(qp, cq, num_entries, wc, sq_cons - 1, - IBV_WC_SUCCESS, 0); - wc += cnt; - /* if we have extra WC fill it with actual error info */ - if (cnt < num_entries) { - enum ibv_wc_status wc_status; - - switch (req->status) { - case RDMA_CQE_REQ_STS_BAD_RESPONSE_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_BAD_RESPONSE_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_BAD_RESP_ERR; - break; - case RDMA_CQE_REQ_STS_LOCAL_LENGTH_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_LOCAL_LENGTH_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_LOC_LEN_ERR; - break; - case RDMA_CQE_REQ_STS_LOCAL_QP_OPERATION_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_LOCAL_QP_OPERATION_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_LOC_QP_OP_ERR; - break; - case RDMA_CQE_REQ_STS_LOCAL_PROTECTION_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_LOCAL_PROTECTION_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_LOC_PROT_ERR; - break; - case RDMA_CQE_REQ_STS_MEMORY_MGT_OPERATION_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_MEMORY_MGT_OPERATION_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_MW_BIND_ERR; - break; - case RDMA_CQE_REQ_STS_REMOTE_INVALID_REQUEST_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_REMOTE_INVALID_REQUEST_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_REM_INV_REQ_ERR; - break; - case RDMA_CQE_REQ_STS_REMOTE_ACCESS_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_REMOTE_ACCESS_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_REM_ACCESS_ERR; - break; - case RDMA_CQE_REQ_STS_REMOTE_OPERATION_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_REMOTE_OPERATION_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_REM_OP_ERR; - break; - case RDMA_CQE_REQ_STS_RNR_NAK_RETRY_CNT_ERR: - DP_ERR(cxt->dbg_fp, - "Error: POLL CQ with RDMA_CQE_REQ_STS_RNR_NAK_RETRY_CNT_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_RNR_RETRY_EXC_ERR; - break; - case RDMA_CQE_REQ_STS_TRANSPORT_RETRY_CNT_ERR: - DP_ERR(cxt->dbg_fp, - "RDMA_CQE_REQ_STS_TRANSPORT_RETRY_CNT_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_RETRY_EXC_ERR; - break; - default: - DP_ERR(cxt->dbg_fp, - "IBV_WC_GENERAL_ERR. QP icid=0x%x\n", - qp->sq.icid); - wc_status = IBV_WC_GENERAL_ERR; - } - - cnt += process_req(qp, cq, 1, wc, sq_cons, wc_status, - 1 /* force use of WC */); - } - } - - return cnt; -} - -static void __process_resp_one(struct qelr_qp *qp, struct qelr_cq *cq, - struct ibv_wc *wc, - struct rdma_cqe_responder *resp, uint64_t wr_id) -{ - struct qelr_devctx *cxt = get_qelr_ctx(qp->ibv_qp.context); - enum ibv_wc_status wc_status = IBV_WC_SUCCESS; - uint8_t flags; - - wc->opcode = IBV_WC_RECV; - wc->wc_flags = 0; - - switch (resp->status) { - case RDMA_CQE_RESP_STS_LOCAL_ACCESS_ERR: - wc_status = IBV_WC_LOC_ACCESS_ERR; - break; - case RDMA_CQE_RESP_STS_LOCAL_LENGTH_ERR: - wc_status = IBV_WC_LOC_LEN_ERR; - break; - case RDMA_CQE_RESP_STS_LOCAL_QP_OPERATION_ERR: - wc_status = IBV_WC_LOC_QP_OP_ERR; - break; - case RDMA_CQE_RESP_STS_LOCAL_PROTECTION_ERR: - wc_status = IBV_WC_LOC_PROT_ERR; - break; - case RDMA_CQE_RESP_STS_MEMORY_MGT_OPERATION_ERR: - wc_status = IBV_WC_MW_BIND_ERR; - break; - case RDMA_CQE_RESP_STS_REMOTE_INVALID_REQUEST_ERR: - wc_status = IBV_WC_REM_INV_RD_REQ_ERR; - break; - case RDMA_CQE_RESP_STS_OK: - wc_status = IBV_WC_SUCCESS; - wc->byte_len = le32toh(resp->length); - - flags = resp->flags & QELR_RESP_RDMA_IMM; - - switch (flags) { - case QELR_RESP_RDMA_IMM: - /* update opcode */ - wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM; - SWITCH_FALLTHROUGH; - case QELR_RESP_IMM: - wc->imm_data = htobe32(le32toh(resp->imm_data_or_inv_r_Key)); - wc->wc_flags |= IBV_WC_WITH_IMM; - break; - case QELR_RESP_RDMA: - DP_ERR(cxt->dbg_fp, "Invalid flags detected\n"); - break; - default: - /* valid configuration, but nothing to do here */ - break; - } - - wc->wr_id = wr_id; - break; - default: - wc->status = IBV_WC_GENERAL_ERR; - DP_ERR(cxt->dbg_fp, "Invalid CQE status detected\n"); - } - - /* fill WC */ - wc->status = wc_status; - wc->qp_num = qp->qp_id; -} - -static int process_resp_one(struct qelr_qp *qp, struct qelr_cq *cq, - struct ibv_wc *wc, struct rdma_cqe_responder *resp) -{ - uint64_t wr_id = qp->rqe_wr_id[qp->rq.cons].wr_id; - - __process_resp_one(qp, cq, wc, resp, wr_id); - - while (qp->rqe_wr_id[qp->rq.cons].wqe_size--) - qelr_chain_consume(&qp->rq.chain); - - qelr_inc_sw_cons_u16(&qp->rq); - - return 1; -} - -static int process_resp_flush(struct qelr_qp *qp, struct qelr_cq *cq, - int num_entries, struct ibv_wc *wc, - uint16_t hw_cons) -{ - uint16_t cnt = 0; - - while (num_entries && qp->rq.wqe_cons != hw_cons) { - /* fill WC */ - wc->status = IBV_WC_WR_FLUSH_ERR; - wc->qp_num = qp->qp_id; - wc->byte_len = 0; - wc->wr_id = qp->rqe_wr_id[qp->rq.cons].wr_id; - num_entries--; - wc++; - cnt++; - while (qp->rqe_wr_id[qp->rq.cons].wqe_size--) - qelr_chain_consume(&qp->rq.chain); - qelr_inc_sw_cons_u16(&qp->rq); - } - - return cnt; -} - -/* return latest CQE (needs processing) */ -static union rdma_cqe *get_cqe(struct qelr_cq *cq) -{ - return cq->latest_cqe; -} - -static void try_consume_req_cqe(struct qelr_cq *cq, struct qelr_qp *qp, - struct rdma_cqe_requester *req, int *update) -{ - uint16_t sq_cons = le16toh(req->sq_cons); - - if (sq_cons == qp->sq.wqe_cons) { - consume_cqe(cq); - *update |= 1; - } -} - -/* used with flush only, when resp->rq_cons is valid */ -static void try_consume_resp_cqe(struct qelr_cq *cq, struct qelr_qp *qp, - uint16_t rq_cons, int *update) -{ - if (rq_cons == qp->rq.wqe_cons) { - consume_cqe(cq); - *update |= 1; - } -} - -static int qelr_poll_cq_resp(struct qelr_qp *qp, struct qelr_cq *cq, - int num_entries, struct ibv_wc *wc, - struct rdma_cqe_responder *resp, int *update) -{ - uint16_t rq_cons = le16toh(resp->rq_cons); - int cnt; - - if (resp->status == RDMA_CQE_RESP_STS_WORK_REQUEST_FLUSHED_ERR) { - cnt = process_resp_flush(qp, cq, num_entries, wc, rq_cons); - try_consume_resp_cqe(cq, qp, rq_cons, update); - } else { - cnt = process_resp_one(qp, cq, wc, resp); - consume_cqe(cq); - *update |= 1; - } - - return cnt; -} - -static void doorbell_cq(struct qelr_cq *cq, uint32_t cons, uint8_t flags) -{ - mmio_wc_start(); - cq->db.data.agg_flags = flags; - cq->db.data.value = htole32(cons); - - writeq(cq->db.raw, cq->db_addr); - mmio_flush_writes(); -} - -int qelr_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc) -{ - struct qelr_cq *cq = get_qelr_cq(ibcq); - int done = 0; - union rdma_cqe *cqe = get_cqe(cq); - int update = 0; - uint32_t db_cons; - - while (num_entries && is_valid_cqe(cq, cqe)) { - int cnt = 0; - struct qelr_qp *qp; - - /* prevent speculative reads of any field of CQE */ - udma_from_device_barrier(); - - qp = cqe_get_qp(cqe); - if (!qp) { - DP_ERR(stderr, - "Error: CQE QP pointer is NULL. CQE=%p\n", cqe); - break; - } - - switch (cqe_get_type(cqe)) { - case RDMA_CQE_TYPE_REQUESTER: - cnt = qelr_poll_cq_req(qp, cq, num_entries, wc, - &cqe->req); - try_consume_req_cqe(cq, qp, &cqe->req, &update); - break; - case RDMA_CQE_TYPE_RESPONDER_RQ: - cnt = qelr_poll_cq_resp(qp, cq, num_entries, wc, - &cqe->resp, &update); - break; - case RDMA_CQE_TYPE_INVALID: - default: - printf("Error: invalid CQE type = %d\n", - cqe_get_type(cqe)); - } - num_entries -= cnt; - wc += cnt; - done += cnt; - - cqe = get_cqe(cq); - } - - db_cons = qelr_chain_get_cons_idx_u32(&cq->chain) - 1; - if (update) { - /* doorbell notifies about latest VALID entry, - * but chain already point to the next INVALID one - */ - doorbell_cq(cq, db_cons, cq->arm_flags); - } - - return done; -} - -void qelr_cq_event(struct ibv_cq *ibcq) -{ - /* Trigger received, can reset arm flags */ - struct qelr_cq *cq = get_qelr_cq(ibcq); - - cq->arm_flags = 0; -} - -int qelr_arm_cq(struct ibv_cq *ibcq, int solicited) -{ - struct qelr_cq *cq = get_qelr_cq(ibcq); - uint32_t db_cons; - - db_cons = qelr_chain_get_cons_idx_u32(&cq->chain) - 1; - cq->arm_flags = solicited ? DQ_UCM_ROCE_CQ_ARM_SE_CF_CMD : - DQ_UCM_ROCE_CQ_ARM_CF_CMD; - - doorbell_cq(cq, db_cons, cq->arm_flags); - - return 0; -} - -void qelr_async_event(struct ibv_async_event *event) -{ - struct qelr_cq *cq = NULL; - struct qelr_qp *qp = NULL; - - switch (event->event_type) { - case IBV_EVENT_CQ_ERR: - cq = get_qelr_cq(event->element.cq); - break; - case IBV_EVENT_QP_FATAL: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_PATH_MIG_ERR:{ - qp = get_qelr_qp(event->element.qp); - break; - } - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_QP_LAST_WQE_REACHED: - break; - case IBV_EVENT_PORT_ACTIVE: - case IBV_EVENT_PORT_ERR: - break; - default: - break; - } - - fprintf(stderr, "qelr_async_event not implemented yet cq=%p qp=%p\n", - cq, qp); -} diff --git a/usr/rdma-core/providers/qedr/qelr_verbs.h b/usr/rdma-core/providers/qedr/qelr_verbs.h deleted file mode 100644 index 28ad18c88..000000000 --- a/usr/rdma-core/providers/qedr/qelr_verbs.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __QELR_VERBS_H__ -#define __QELR_VERBS_H__ - -#include -#include -#include - -#include -#include - -int qelr_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); -int qelr_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -struct ibv_pd *qelr_alloc_pd(struct ibv_context *context); -int qelr_dealloc_pd(struct ibv_pd *ibpd); - -struct ibv_mr *qelr_reg_mr(struct ibv_pd *ibpd, void *addr, - size_t len, int access); -int qelr_dereg_mr(struct ibv_mr *mr); - -struct ibv_cq *qelr_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); -int qelr_arm_cq(struct ibv_cq *ibcq, int solicited); -int qelr_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc); -void qelr_cq_event(struct ibv_cq *ibcq); -int qelr_destroy_cq(struct ibv_cq *); - -struct ibv_qp *qelr_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attrs); -int qelr_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask); -int qelr_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr); -int qelr_destroy_qp(struct ibv_qp *ibqp); - -int qelr_post_send(struct ibv_qp *ib_qp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -int qelr_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); - -void qelr_async_event(struct ibv_async_event *event); -#endif /* __QELR_VERBS_H__ */ diff --git a/usr/rdma-core/providers/qedr/rdma_common.h b/usr/rdma-core/providers/qedr/rdma_common.h deleted file mode 100644 index 0707e17a1..000000000 --- a/usr/rdma-core/providers/qedr/rdma_common.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __RDMA_COMMON__ -#define __RDMA_COMMON__ - -#include - -/************************/ -/* RDMA FW CONSTANTS */ -/************************/ - -#define RDMA_RESERVED_LKEY (0) //Reserved lkey -#define RDMA_RING_PAGE_SIZE (0x1000) //4KB pages - -#define RDMA_MAX_SGE_PER_SQ_WQE (4) //max number of SGEs in a single request -#define RDMA_MAX_SGE_PER_RQ_WQE (4) //max number of SGEs in a single request - -#define RDMA_MAX_DATA_SIZE_IN_WQE (0x7FFFFFFF) //max size of data in single request - -#define RDMA_REQ_RD_ATOMIC_ELM_SIZE (0x50) -#define RDMA_RESP_RD_ATOMIC_ELM_SIZE (0x20) - -#define RDMA_MAX_CQS (64*1024) -#define RDMA_MAX_TIDS (128*1024-1) -#define RDMA_MAX_PDS (64*1024) - -#define RDMA_NUM_STATISTIC_COUNTERS MAX_NUM_VPORTS -#define RDMA_NUM_STATISTIC_COUNTERS_K2 MAX_NUM_VPORTS_K2 -#define RDMA_NUM_STATISTIC_COUNTERS_BB MAX_NUM_VPORTS_BB - -#define RDMA_TASK_TYPE (PROTOCOLID_ROCE) - - -struct rdma_srq_id -{ - __le16 srq_idx /* SRQ index */; - __le16 opaque_fid; -}; - - -struct rdma_srq_producers -{ - __le32 sge_prod /* Current produced sge in SRQ */; - __le32 wqe_prod /* Current produced WQE to SRQ */; -}; - -#endif /* __RDMA_COMMON__ */ diff --git a/usr/rdma-core/providers/qedr/roce_common.h b/usr/rdma-core/providers/qedr/roce_common.h deleted file mode 100644 index b01c2adef..000000000 --- a/usr/rdma-core/providers/qedr/roce_common.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015-2016 QLogic Corporation - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and /or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __ROCE_COMMON__ -#define __ROCE_COMMON__ -/************************************************************************/ -/* Add include to common rdma target for both eCore and protocol rdma driver */ -/************************************************************************/ -#include "rdma_common.h" -/************************/ -/* ROCE FW CONSTANTS */ -/************************/ - -#define ROCE_REQ_MAX_INLINE_DATA_SIZE (256) //max size of inline data in single request -#define ROCE_REQ_MAX_SINGLE_SQ_WQE_SIZE (288) //Maximum size of single SQ WQE (rdma wqe and inline data) - -#define ROCE_MAX_QPS (32*1024) -#define ROCE_DCQCN_NP_MAX_QPS (64) /* notification point max QPs*/ -#define ROCE_DCQCN_RP_MAX_QPS (64) /* reaction point max QPs*/ - -#endif /* __ROCE_COMMON__ */ diff --git a/usr/rdma-core/providers/rxe/CMakeLists.txt b/usr/rdma-core/providers/rxe/CMakeLists.txt deleted file mode 100644 index 15dc627e4..000000000 --- a/usr/rdma-core/providers/rxe/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -rdma_provider(rxe - rxe.c - ) -rdma_subst_install(FILES "rxe_cfg.in" - RENAME "rxe_cfg" - DESTINATION "${CMAKE_INSTALL_BINDIR}" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE - ) diff --git a/usr/rdma-core/providers/rxe/man/CMakeLists.txt b/usr/rdma-core/providers/rxe/man/CMakeLists.txt deleted file mode 100644 index 69e8bd8cf..000000000 --- a/usr/rdma-core/providers/rxe/man/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -rdma_man_pages( - rxe.7 - rxe_cfg.8 -) diff --git a/usr/rdma-core/providers/rxe/man/rxe.7 b/usr/rdma-core/providers/rxe/man/rxe.7 deleted file mode 100644 index 79349e9d3..000000000 --- a/usr/rdma-core/providers/rxe/man/rxe.7 +++ /dev/null @@ -1,105 +0,0 @@ -.\" -*- nroff -*- -.\" -.TH RXE 7 2011-06-29 1.0.0 -.SH "NAME" -rxe \- Software RDMA over Ethernet -.SH "SYNOPSIS" -\fBmodprobe rdma_rxe\fR -.br -This is usually performed by a configuration utility (see \fBrxe_cfg\fR(8).) - -.SH "DESCRIPTION" -The rdma_rxe kernel module provides a software implementation of the RoCEv2 -protocol. The RoCEv2 protocol is an RDMA transport protocol that exists on -top of UDP/IPv4 or UDP/IPv6. The InfiniBand (IB) Base Transport Header (BTH) -is encapsulated in the UDP packet. - -Once a RXE instance has been created, communicating via RXE is the same as communicating via any OFED compatible Infiniband HCA, albeit in some cases with addressing implications. - -In particular, while the use of a GRH header is optional within IB subnets, it is mandatory with RoCE. Verbs applications written over IB verbs should work seamlessly, but they require provisioning of GRH information when creating address vectors. The library and driver are modified to provide for mapping from GID to MAC addresses required by the hardware. - -.SH "FILES" -.TP -\fB/sys/class/infiniband/rxe[0,1,...]\fR -Directory that holds RDMA device information. The format is the same as other RDMA devices. - -.TP -\fB/sys/module/rdma_rxe_net/parameters/add\fR -Write only file used by \fBrxe_cfg(8)\fR to add new RXE devices to existing Ethernet devices. - -.TP -\fB/sys/module/rdma_rxe_net/parameters/remove\fR -Write only file used by \fBrxe_cfg(8)\fR to remove RXE devices. - -.TP -\fB/sys/module/rdma_rxe_net/parameters/mtu\fR -Write only file used by \fBrxe_cfg(8)\fR to configure RoCE and Ethernet MTU values. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_ucontext\fR -Read/Write file that sets a limit on the number of UCs allowed per RXE device. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_qp\fR -Read/Write file that sets a limit on the number of QPs allowed per RXE device. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_qp_wr\fR -Read/Write file that sets a limit on the number of WRs per QP allowed per RXE device. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_mr\fR -Read/Write file that sets a limit on the number of MRs allowed per RXE device. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_fmr\fR -Read/Write file that sets a limit on the number of FMRs allowed per RXE device. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_cq\fR -Read/Write file that sets a limit on the number of CQs allowed per RXE device. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_log_cqe\fR -Read/Write file that sets a limit on the log base 2 of the number of CQEs per CQ allowed per RXE device. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_inline_data\fR -Read/Write file that sets a limit on the maximum amount of inline data per WR allowed per RXE device. - -The above configuration parameters only affect a new RXE instance when it is created not afterwards. - -.TP -\fB/sys/module/rdma_rxe/parameters/crc_disable\fR -Read/Write file that controls the disabling of ICRC computation. Set to a nonzero value for TRUE. Zero for FALSE. - -.TP -\fB/sys/module/rdma_rxe/parameters/fast_comp|req|resp|arb\fR -Read/Write file that enables calling kernel tasklets as subroutines to reduce latency. - -.TP -\fB/sys/module/rdma_rxe/parameters/nsec_per_packet|kbyte\fR -Read/Write file that controls static rate pacing for output packets. If set to nonzero values the minimum delay to the next packet is set to nsec_per_kbyte * sizeof(current packet in KBytes) or nsec_per_packet which ever is less. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_packet_per_ack\fR -Read/Write file that controls the issuing of acks by the responder during a long message. If set additional acks will be generated every max_pkt_per_ack packets. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_skb_per_qp\fR -Read/Write file that controls the number of skbs (packets) that a requester can queue for sending internally. - -.TP -\fB/sys/module/rdma_rxe/parameters/max_req_comp_gap\fR -Read/Write file that controls the maximum gap between the PSN of request packets send and ack packets received. - -.TP -\fB/sys/module/rdma_rxe/parameters/default_mtu\fR -Read/Write file that controls the default mtu used for UD packets. - -.SH "SEE ALSO" -.BR rxe_cfg (8), -.BR verbs (7), - -.SH "AUTHORS" -Written by John Groves, Frank Zago and Bob Pearson at System Fabric Works. diff --git a/usr/rdma-core/providers/rxe/man/rxe_cfg.8 b/usr/rdma-core/providers/rxe/man/rxe_cfg.8 deleted file mode 100644 index 30e0d4cc7..000000000 --- a/usr/rdma-core/providers/rxe/man/rxe_cfg.8 +++ /dev/null @@ -1,96 +0,0 @@ -.\" -*- nroff -*- -.\" -.TH RXE_CFG 8 2011-06-29 1.0.0 -.SH "NAME" -rxe_cfg \- rxe configuration tool for RXE (Soft RoCE) -.SH "SYNOPSIS" -\fBrxe_cfg [status]\fR -.br -\fBrxe_cfg start\fR [\fB\-p\fR \fIproto\fR] -.br -\fBrxe_cfg stop\fR -.br -\fBrxe_cfg persistent\fR -.br -\fBrxe_cfg add\fR [\fB\-n\fR] \fIethN\fR -.br -\fBrxe_cfg remove\fR [\fB\-n\fR] \fIethN\fR|\fIrxeN\fR -.br -\fBrxe_cfg crc enable\fR|\fBdisable\fR -.br -\fBrxe_cfg\fR \fBmtu\fR [\fB\-f\fR] [\fIrxeN\fR] \fImtu_size\fR -.br -.SH "DESCRIPTION" -rxe_cfg is the configuration tool for the RXE software implementation of the RoCE protocol. - -The RXE kernel modules are loaded, configured, reconfigured and unloaded via the various rxe_cfg command options, documented below. - -.SH "PARAMETERS" -.TP -\fIproto\fR -Ethertype field. Default value is 0x8915. This value must be changed to use RXE on Mellanox ConnectX adapters. - -.TP -\fIethN\fR -Network device name as listed in /sys/class/net. Only Ethernet devices are supported; ie. eth0 or eth0.1234 for VLANs. - -.TP -\fIrxeN\fR -RXE device name as listed in /sys/class/infiniband/. Examples are rxe0 or rxe1. - -.TP -\fImtu_size\fR -RoCE mtu. For RoCE the mtu represents the payload excluding headers and has the possible values: 256, 512, 1024, 2048 and 4096. - -.SH "COMMANDS" -.TP -[\fBstatus\fR] -The \fBstatus\fR command prints a table of information on available Ethernet devices and configured RXE instances. The status display is the default if no options are provided. - -.TP -\fBstart\fR [\fB\-p\fR \fIproto\fR] -The \fBstart\fR command loads the RXE modules and configures any persistent instances. If the \fB-p\fR \fIproto\fR option is included, the RXE modules will be configured to use Ethertype = \fIproto\fR. (This allows testing RXE on devices, like Mellanox ConnectX, that already support the default RoCE Ethertype in hardware.) - -.TP -\fBstop\fR -The \fBstop\fR command unconfigures all RXE instances and attempts to unload the kernel modules. - -.TP -\fBpersistent\fR -The \fBpersistent\fR command prints the list of Ethernet devices for which a RXE instance is persistently configured. - -.TP -\fBadd\fR [\fB\-n\fR] \fIethN\fR -The \fBadd\fR command will configure a RXE instance on Ethernet device \fIethN\fR (e.g. eth0). The RXE modules must have already been loaded via \fBrxe_cfg start\fR. - -The default behavior is to add \fIethN\fR to a file of persistent configurations and the same RXE device will be configured the next time that \fBrxe_cfg start\fR is run. If the \fB-n\fR option is included the device is not added to the persistence file. - -.TP -\fBremove\fR [\fB\-n\fR] \fIethN\fR|\fIrxeN\fR -The \fBremove\fR command will remove the specified RXE instance. The parameter must match a currently active ethN or rxeN name. - -If the \fB-n\fR option is included the RXE device will be removed but not removed from the persistent state. So it will be recreated the next time that \fBrxe_cfg start\fR is run. - -.TP -\fBmtu\fR [\fB\-f\fR] [\fIrxeN\fR] \fImtu_size\fR -The \fBmtu\fR command will set the RoCE MTU of all RXE devices to \fImtu_size\fR, provided that the underlying Ethernet MTU is sufficiently large. If the Ethernet MTU is not large enough, RXE will use the largest MTU that fits; the driver remembers the requested RoCE MTU and will increase the currently active MTU if the Ethernet MTU is later changed up to the requested MTU. - -If the \fB-f\fR option is included the underlying Ethernet MTUs will be increased if necessary to the minimum size to accommodate a RoCE MTU of \fIsize\fR. - -If a \fIrxeN\fR instance is specified then only that instance will be affected by the command. - -.TP -\fBcrc\fR \fBenable\fR|\fBdisable\fR -The \fBcrc\fR command will enable or disable RoCE ICRC calculation. Valid ICRCs are be required to communicate hardware RoCE NICs, but when a RXE instance is communicating with another RXE instance the performance will be better with the CRC disabled. - -This option is global to all RXE instances. - -.SH "FILES" -.TP -\fB[PREFIX]/etc/rxe.conf\fR -RXE configuration file. Contains the list of persistent RXE instances. All persistent RXE instances can be removed by deleting this file (note this will take effect on the next "rxe_cfg start" -- to remove actively configured instances, you must "rxe_cfg stop"). - -.SH "SEE ALSO" -.BR rxe (7), -.SH "AUTHORS" -Written by John Groves, Frank Zago and Bob Pearson at System Fabric Works. diff --git a/usr/rdma-core/providers/rxe/rxe-abi.h b/usr/rdma-core/providers/rxe/rxe-abi.h deleted file mode 100644 index 18e45a383..000000000 --- a/usr/rdma-core/providers/rxe/rxe-abi.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2009 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2009 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#ifndef RXE_ABI_H -#define RXE_ABI_H - -#include - -struct mmap_info { - __u64 offset; - __u32 size; - __u32 pad; -}; - -struct rxe_get_context_resp { - struct ibv_get_context_resp ibv_resp; - __u32 version; -}; - -struct rxe_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - struct mmap_info mi; -}; - -struct rxe_resize_cq_resp { - struct ibv_resize_cq_resp ibv_resp; - struct mmap_info mi; -}; - -struct rxe_create_qp_resp { - struct ibv_create_qp_resp ibv_resp; - struct mmap_info rq_mi; - struct mmap_info sq_mi; -}; - -struct rxe_create_srq_resp { - struct ibv_create_srq_resp ibv_resp; - struct mmap_info mi; - __u32 srq_num; -}; - -struct rxe_modify_srq_cmd { - struct ibv_modify_srq ibv_cmd; - __u64 mmap_info_addr; -}; - -#endif /* RXE_ABI_H */ diff --git a/usr/rdma-core/providers/rxe/rxe.c b/usr/rdma-core/providers/rxe/rxe.c deleted file mode 100644 index 683ffaa2a..000000000 --- a/usr/rdma-core/providers/rxe/rxe.c +++ /dev/null @@ -1,924 +0,0 @@ -/* - * Copyright (c) 2009 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2009 System Fabric Works, Inc. All rights reserved. - * Copyright (C) 2006-2007 QLogic Corporation, All rights reserved. - * Copyright (c) 2005. PathScale, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "rxe_queue.h" -#include "rxe-abi.h" -#include "rxe.h" - -static const struct verbs_match_ent hca_table[] = { - /* FIXME: rxe needs a more reliable way to detect the rxe device */ - VERBS_NAME_MATCH("rxe", NULL), - {}, -}; - -static int rxe_query_device(struct ibv_context *context, - struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, - &cmd, sizeof cmd); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%d", major, minor, sub_minor); - - return 0; -} - -static int rxe_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd); -} - -static struct ibv_pd *rxe_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct ibv_alloc_pd_resp resp; - struct ibv_pd *pd; - - pd = malloc(sizeof *pd); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, pd, &cmd, sizeof cmd, &resp, sizeof resp)) { - free(pd); - return NULL; - } - - return pd; -} - -static int rxe_dealloc_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (!ret) - free(pd); - - return ret; -} - -static struct ibv_mr *rxe_reg_mr(struct ibv_pd *pd, void *addr, size_t length, - int access) -{ - struct ibv_mr *mr; - struct ibv_reg_mr cmd; - struct ibv_reg_mr_resp resp; - int ret; - - mr = malloc(sizeof *mr); - if (!mr) { - return NULL; - } - - ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr, - &cmd, sizeof cmd, &resp, sizeof resp); - if (ret) { - free(mr); - return NULL; - } - - return mr; -} - -static int rxe_dereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - free(mr); - return 0; -} - -static struct ibv_cq *rxe_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct rxe_cq *cq; - struct ibv_create_cq cmd; - struct rxe_create_cq_resp resp; - int ret; - - cq = malloc(sizeof *cq); - if (!cq) { - return NULL; - } - - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &cq->ibv_cq, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(cq); - return NULL; - } - - cq->queue = mmap(NULL, resp.mi.size, PROT_READ | PROT_WRITE, MAP_SHARED, - context->cmd_fd, resp.mi.offset); - if ((void *)cq->queue == MAP_FAILED) { - ibv_cmd_destroy_cq(&cq->ibv_cq); - free(cq); - return NULL; - } - - cq->mmap_info = resp.mi; - pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE); - - return &cq->ibv_cq; -} - -static int rxe_resize_cq(struct ibv_cq *ibcq, int cqe) -{ - struct rxe_cq *cq = to_rcq(ibcq); - struct ibv_resize_cq cmd; - struct rxe_resize_cq_resp resp; - int ret; - - pthread_spin_lock(&cq->lock); - - ret = ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - pthread_spin_unlock(&cq->lock); - return ret; - } - - munmap(cq->queue, cq->mmap_info.size); - - cq->queue = mmap(NULL, resp.mi.size, - PROT_READ | PROT_WRITE, MAP_SHARED, - ibcq->context->cmd_fd, resp.mi.offset); - - ret = errno; - pthread_spin_unlock(&cq->lock); - - if ((void *)cq->queue == MAP_FAILED) { - cq->queue = NULL; - cq->mmap_info.size = 0; - return ret; - } - - cq->mmap_info = resp.mi; - - return 0; -} - -static int rxe_destroy_cq(struct ibv_cq *ibcq) -{ - struct rxe_cq *cq = to_rcq(ibcq); - int ret; - - ret = ibv_cmd_destroy_cq(ibcq); - if (ret) - return ret; - - if (cq->mmap_info.size) - munmap(cq->queue, cq->mmap_info.size); - free(cq); - - return 0; -} - -static int rxe_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) -{ - struct rxe_cq *cq = to_rcq(ibcq); - struct rxe_queue *q; - int npolled; - uint8_t *src; - - pthread_spin_lock(&cq->lock); - q = cq->queue; - - for (npolled = 0; npolled < ne; ++npolled, ++wc) { - if (queue_empty(q)) - break; - - atomic_thread_fence(memory_order_acquire); - src = consumer_addr(q); - memcpy(wc, src, sizeof(*wc)); - advance_consumer(q); - } - - pthread_spin_unlock(&cq->lock); - return npolled; -} - -static struct ibv_srq *rxe_create_srq(struct ibv_pd *pd, - struct ibv_srq_init_attr *attr) -{ - struct rxe_srq *srq; - struct ibv_create_srq cmd; - struct rxe_create_srq_resp resp; - int ret; - - srq = malloc(sizeof *srq); - if (srq == NULL) { - return NULL; - } - - ret = ibv_cmd_create_srq(pd, &srq->ibv_srq, attr, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(srq); - return NULL; - } - - srq->rq.queue = mmap(NULL, resp.mi.size, - PROT_READ | PROT_WRITE, MAP_SHARED, - pd->context->cmd_fd, resp.mi.offset); - if ((void *)srq->rq.queue == MAP_FAILED) { - ibv_cmd_destroy_srq(&srq->ibv_srq); - free(srq); - return NULL; - } - - srq->mmap_info = resp.mi; - srq->rq.max_sge = attr->attr.max_sge; - pthread_spin_init(&srq->rq.lock, PTHREAD_PROCESS_PRIVATE); - - return &srq->ibv_srq; -} - -static int rxe_modify_srq(struct ibv_srq *ibsrq, - struct ibv_srq_attr *attr, int attr_mask) -{ - struct rxe_srq *srq = to_rsrq(ibsrq); - struct rxe_modify_srq_cmd cmd; - int rc = 0; - struct mmap_info mi; - - mi.offset = 0; - mi.size = 0; - - if (attr_mask & IBV_SRQ_MAX_WR) - pthread_spin_lock(&srq->rq.lock); - - cmd.mmap_info_addr = (__u64)(uintptr_t) & mi; - rc = ibv_cmd_modify_srq(ibsrq, attr, attr_mask, - &cmd.ibv_cmd, sizeof cmd); - if (rc) - goto out; - - if (attr_mask & IBV_SRQ_MAX_WR) { - (void)munmap(srq->rq.queue, srq->mmap_info.size); - srq->rq.queue = mmap(NULL, mi.size, - PROT_READ | PROT_WRITE, MAP_SHARED, - ibsrq->context->cmd_fd, mi.offset); - - if ((void *)srq->rq.queue == MAP_FAILED) { - rc = errno; - srq->rq.queue = NULL; - srq->mmap_info.size = 0; - goto out; - } - - srq->mmap_info = mi; - } - -out: - if (attr_mask & IBV_SRQ_MAX_WR) - pthread_spin_unlock(&srq->rq.lock); - return rc; -} - -static int rxe_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr) -{ - struct ibv_query_srq cmd; - - return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd); -} - -static int rxe_destroy_srq(struct ibv_srq *ibvsrq) -{ - int ret; - struct rxe_srq *srq = to_rsrq(ibvsrq); - struct rxe_queue *q = srq->rq.queue; - - ret = ibv_cmd_destroy_srq(ibvsrq); - if (!ret) { - if (srq->mmap_info.size) - munmap(q, srq->mmap_info.size); - free(srq); - } - - return ret; -} - -static int rxe_post_one_recv(struct rxe_wq *rq, struct ibv_recv_wr *recv_wr) -{ - int i; - struct rxe_recv_wqe *wqe; - struct rxe_queue *q = rq->queue; - int length = 0; - int rc = 0; - - if (queue_full(q)) { - rc = -ENOMEM; - goto out; - } - - if (recv_wr->num_sge > rq->max_sge) { - rc = -EINVAL; - goto out; - } - - wqe = (struct rxe_recv_wqe *)producer_addr(q); - - wqe->wr_id = recv_wr->wr_id; - wqe->num_sge = recv_wr->num_sge; - - memcpy(wqe->dma.sge, recv_wr->sg_list, - wqe->num_sge*sizeof(*wqe->dma.sge)); - - for (i = 0; i < wqe->num_sge; i++) { - length += wqe->dma.sge[i].length; - } - - wqe->dma.length = length; - wqe->dma.resid = length; - wqe->dma.cur_sge = 0; - wqe->dma.num_sge = wqe->num_sge; - wqe->dma.sge_offset = 0; - - advance_producer(q); - -out: - return rc; -} - -static int rxe_post_srq_recv(struct ibv_srq *ibvsrq, - struct ibv_recv_wr *recv_wr, - struct ibv_recv_wr **bad_recv_wr) -{ - struct rxe_srq *srq = to_rsrq(ibvsrq); - int rc = 0; - - pthread_spin_lock(&srq->rq.lock); - - while (recv_wr) { - rc = rxe_post_one_recv(&srq->rq, recv_wr); - if (rc) { - *bad_recv_wr = recv_wr; - break; - } - - recv_wr = recv_wr->next; - } - - pthread_spin_unlock(&srq->rq.lock); - - return rc; -} - -static struct ibv_qp *rxe_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - struct ibv_create_qp cmd; - struct rxe_create_qp_resp resp; - struct rxe_qp *qp; - int ret; - - qp = malloc(sizeof *qp); - if (!qp) { - return NULL; - } - - ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp); - if (ret) { - free(qp); - return NULL; - } - - if (attr->srq) { - qp->rq.max_sge = 0; - qp->rq.queue = NULL; - qp->rq_mmap_info.size = 0; - } else { - qp->rq.max_sge = attr->cap.max_recv_sge; - qp->rq.queue = mmap(NULL, resp.rq_mi.size, PROT_READ | PROT_WRITE, - MAP_SHARED, - pd->context->cmd_fd, resp.rq_mi.offset); - if ((void *)qp->rq.queue == MAP_FAILED) { - ibv_cmd_destroy_qp(&qp->ibv_qp); - free(qp); - return NULL; - } - - qp->rq_mmap_info = resp.rq_mi; - pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE); - } - - qp->sq.max_sge = attr->cap.max_send_sge; - qp->sq.max_inline = attr->cap.max_inline_data; - qp->sq.queue = mmap(NULL, resp.sq_mi.size, PROT_READ | PROT_WRITE, - MAP_SHARED, - pd->context->cmd_fd, resp.sq_mi.offset); - if ((void *)qp->sq.queue == MAP_FAILED) { - if (qp->rq_mmap_info.size) - munmap(qp->rq.queue, qp->rq_mmap_info.size); - ibv_cmd_destroy_qp(&qp->ibv_qp); - free(qp); - return NULL; - } - - qp->sq_mmap_info = resp.sq_mi; - pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE); - - return &qp->ibv_qp; -} - -static int rxe_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - - return ibv_cmd_query_qp(qp, attr, attr_mask, init_attr, - &cmd, sizeof cmd); -} - -static int rxe_modify_qp(struct ibv_qp *ibvqp, - struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd = {}; - - return ibv_cmd_modify_qp(ibvqp, attr, attr_mask, &cmd, sizeof cmd); -} - -static int rxe_destroy_qp(struct ibv_qp *ibv_qp) -{ - int ret; - struct rxe_qp *qp = to_rqp(ibv_qp); - - ret = ibv_cmd_destroy_qp(ibv_qp); - if (!ret) { - if (qp->rq_mmap_info.size) - munmap(qp->rq.queue, qp->rq_mmap_info.size); - if (qp->sq_mmap_info.size) - munmap(qp->sq.queue, qp->sq_mmap_info.size); - - free(qp); - } - - return ret; -} - -/* basic sanity checks for send work request */ -static int validate_send_wr(struct rxe_wq *sq, struct ibv_send_wr *ibwr, - unsigned int length) -{ - enum ibv_wr_opcode opcode = ibwr->opcode; - - if (ibwr->num_sge > sq->max_sge) - return -EINVAL; - - if ((opcode == IBV_WR_ATOMIC_CMP_AND_SWP) - || (opcode == IBV_WR_ATOMIC_FETCH_AND_ADD)) - if (length < 8 || ibwr->wr.atomic.remote_addr & 0x7) - return -EINVAL; - - if ((ibwr->send_flags & IBV_SEND_INLINE) && (length > sq->max_inline)) - return -EINVAL; - - return 0; -} - -static void convert_send_wr(struct rxe_send_wr *kwr, struct ibv_send_wr *uwr) -{ - memset(kwr, 0, sizeof(*kwr)); - - kwr->wr_id = uwr->wr_id; - kwr->num_sge = uwr->num_sge; - kwr->opcode = uwr->opcode; - kwr->send_flags = uwr->send_flags; - kwr->ex.imm_data = uwr->imm_data; - - switch(uwr->opcode) { - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - case IBV_WR_RDMA_READ: - kwr->wr.rdma.remote_addr = uwr->wr.rdma.remote_addr; - kwr->wr.rdma.rkey = uwr->wr.rdma.rkey; - break; - - case IBV_WR_SEND: - case IBV_WR_SEND_WITH_IMM: - kwr->wr.ud.remote_qpn = uwr->wr.ud.remote_qpn; - kwr->wr.ud.remote_qkey = uwr->wr.ud.remote_qkey; - break; - - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - kwr->wr.atomic.remote_addr = uwr->wr.atomic.remote_addr; - kwr->wr.atomic.compare_add = uwr->wr.atomic.compare_add; - kwr->wr.atomic.swap = uwr->wr.atomic.swap; - kwr->wr.atomic.rkey = uwr->wr.atomic.rkey; - break; - - case IBV_WR_LOCAL_INV: - case IBV_WR_BIND_MW: - case IBV_WR_SEND_WITH_INV: - case IBV_WR_TSO: - break; - } -} - -static int init_send_wqe(struct rxe_qp *qp, struct rxe_wq *sq, - struct ibv_send_wr *ibwr, unsigned int length, - struct rxe_send_wqe *wqe) -{ - int num_sge = ibwr->num_sge; - int i; - unsigned int opcode = ibwr->opcode; - - convert_send_wr(&wqe->wr, ibwr); - - if (qp_type(qp) == IBV_QPT_UD) - memcpy(&wqe->av, &to_rah(ibwr->wr.ud.ah)->av, - sizeof(struct rxe_av)); - - if (ibwr->send_flags & IBV_SEND_INLINE) { - uint8_t *inline_data = wqe->dma.inline_data; - - for (i = 0; i < num_sge; i++) { - memcpy(inline_data, - (uint8_t *)(long)ibwr->sg_list[i].addr, - ibwr->sg_list[i].length); - inline_data += ibwr->sg_list[i].length; - } - } else - memcpy(wqe->dma.sge, ibwr->sg_list, - num_sge*sizeof(struct ibv_sge)); - - if ((opcode == IBV_WR_ATOMIC_CMP_AND_SWP) - || (opcode == IBV_WR_ATOMIC_FETCH_AND_ADD)) - wqe->iova = ibwr->wr.atomic.remote_addr; - else - wqe->iova = ibwr->wr.rdma.remote_addr; - wqe->dma.length = length; - wqe->dma.resid = length; - wqe->dma.num_sge = num_sge; - wqe->dma.cur_sge = 0; - wqe->dma.sge_offset = 0; - wqe->state = 0; - wqe->ssn = qp->ssn++; - - return 0; -} - -static int post_one_send(struct rxe_qp *qp, struct rxe_wq *sq, - struct ibv_send_wr *ibwr) -{ - int err; - struct rxe_send_wqe *wqe; - unsigned int length = 0; - int i; - - for (i = 0; i < ibwr->num_sge; i++) - length += ibwr->sg_list[i].length; - - err = validate_send_wr(sq, ibwr, length); - if (err) { - printf("validate send failed\n"); - return err; - } - - wqe = (struct rxe_send_wqe *)producer_addr(sq->queue); - - err = init_send_wqe(qp, sq, ibwr, length, wqe); - if (err) - return err; - - if (queue_full(sq->queue)) - return -ENOMEM; - - advance_producer(sq->queue); - - return 0; -} - -/* send a null post send as a doorbell */ -static int post_send_db(struct ibv_qp *ibqp) -{ - struct ibv_post_send cmd; - struct ibv_post_send_resp resp; - - cmd.command = IB_USER_VERBS_CMD_POST_SEND; - cmd.in_words = sizeof(cmd)/4; - cmd.out_words = sizeof(resp)/4; - cmd.response = (uintptr_t)&resp; - cmd.qp_handle = ibqp->handle; - cmd.wr_count = 0; - cmd.sge_count = 0; - cmd.wqe_size = sizeof(struct ibv_send_wr); - - if (write(ibqp->context->cmd_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) - return errno; - - return 0; -} - -/* this API does not make a distinction between - restartable and non-restartable errors */ -static int rxe_post_send(struct ibv_qp *ibqp, - struct ibv_send_wr *wr_list, - struct ibv_send_wr **bad_wr) -{ - int rc = 0; - int err; - struct rxe_qp *qp = to_rqp(ibqp); - struct rxe_wq *sq = &qp->sq; - - if (!bad_wr) - return EINVAL; - - *bad_wr = NULL; - - if (!sq || !wr_list || !sq->queue) - return EINVAL; - - pthread_spin_lock(&sq->lock); - - while (wr_list) { - rc = post_one_send(qp, sq, wr_list); - if (rc) { - *bad_wr = wr_list; - break; - } - - wr_list = wr_list->next; - } - - pthread_spin_unlock(&sq->lock); - - err = post_send_db(ibqp); - return err ? err : rc; -} - -static int rxe_post_recv(struct ibv_qp *ibqp, - struct ibv_recv_wr *recv_wr, - struct ibv_recv_wr **bad_wr) -{ - int rc = 0; - struct rxe_qp *qp = to_rqp(ibqp); - struct rxe_wq *rq = &qp->rq; - - if (!bad_wr) - return EINVAL; - - *bad_wr = NULL; - - if (!rq || !recv_wr || !rq->queue) - return EINVAL; - - pthread_spin_lock(&rq->lock); - - while (recv_wr) { - rc = rxe_post_one_recv(rq, recv_wr); - if (rc) { - *bad_wr = recv_wr; - break; - } - - recv_wr = recv_wr->next; - } - - pthread_spin_unlock(&rq->lock); - - return rc; -} - -static inline int ipv6_addr_v4mapped(const struct in6_addr *a) -{ - return IN6_IS_ADDR_V4MAPPED(a); -} - -static inline int rdma_gid2ip(struct sockaddr *out, union ibv_gid *gid) -{ - if (ipv6_addr_v4mapped((struct in6_addr *)gid)) { - struct sockaddr_in *out_in = (struct sockaddr_in *)out; - memset(out_in, 0, sizeof(*out_in)); - memcpy(&out_in->sin_addr.s_addr, gid->raw + 12, 4); - } else { - struct sockaddr_in6 *out_in = (struct sockaddr_in6 *)out; - memset(out_in, 0, sizeof(*out_in)); - out_in->sin6_family = AF_INET6; - memcpy(&out_in->sin6_addr.s6_addr, gid->raw, 16); - } - return 0; -} - -static struct ibv_ah *rxe_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) -{ - int err; - struct rxe_ah *ah; - struct rxe_av *av; - union ibv_gid sgid; - struct ibv_create_ah_resp resp; - - err = ibv_query_gid(pd->context, attr->port_num, attr->grh.sgid_index, - &sgid); - if (err) { - fprintf(stderr, "rxe: Failed to query sgid.\n"); - return NULL; - } - - ah = malloc(sizeof *ah); - if (ah == NULL) - return NULL; - - av = &ah->av; - av->port_num = attr->port_num; - memcpy(&av->grh, &attr->grh, sizeof(attr->grh)); - av->network_type = - ipv6_addr_v4mapped((struct in6_addr *)attr->grh.dgid.raw) ? - RDMA_NETWORK_IPV4 : RDMA_NETWORK_IPV6; - - rdma_gid2ip(&av->sgid_addr._sockaddr, &sgid); - rdma_gid2ip(&av->dgid_addr._sockaddr, &attr->grh.dgid); - - memset(&resp, 0, sizeof(resp)); - if (ibv_cmd_create_ah(pd, &ah->ibv_ah, attr, &resp, sizeof(resp))) { - free(ah); - return NULL; - } - - return &ah->ibv_ah; -} - -static int rxe_destroy_ah(struct ibv_ah *ibah) -{ - int ret; - struct rxe_ah *ah = to_rah(ibah); - - ret = ibv_cmd_destroy_ah(&ah->ibv_ah); - if (ret) - return ret; - - free(ah); - return 0; -} - -static struct ibv_context_ops rxe_ctx_ops = { - .query_device = rxe_query_device, - .query_port = rxe_query_port, - .alloc_pd = rxe_alloc_pd, - .dealloc_pd = rxe_dealloc_pd, - .reg_mr = rxe_reg_mr, - .dereg_mr = rxe_dereg_mr, - .create_cq = rxe_create_cq, - .poll_cq = rxe_poll_cq, - .req_notify_cq = ibv_cmd_req_notify_cq, - .cq_event = NULL, - .resize_cq = rxe_resize_cq, - .destroy_cq = rxe_destroy_cq, - .create_srq = rxe_create_srq, - .modify_srq = rxe_modify_srq, - .query_srq = rxe_query_srq, - .destroy_srq = rxe_destroy_srq, - .post_srq_recv = rxe_post_srq_recv, - .create_qp = rxe_create_qp, - .query_qp = rxe_query_qp, - .modify_qp = rxe_modify_qp, - .destroy_qp = rxe_destroy_qp, - .post_send = rxe_post_send, - .post_recv = rxe_post_recv, - .create_ah = rxe_create_ah, - .destroy_ah = rxe_destroy_ah, - .attach_mcast = ibv_cmd_attach_mcast, - .detach_mcast = ibv_cmd_detach_mcast -}; - -static struct ibv_context *rxe_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - struct rxe_context *context; - struct ibv_get_context cmd; - struct ibv_get_context_resp resp; - - context = malloc(sizeof *context); - if (!context) - return NULL; - - memset(context, 0, sizeof *context); - context->ibv_ctx.cmd_fd = cmd_fd; - - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, - sizeof cmd, &resp, sizeof resp)) - goto out; - - context->ibv_ctx.ops = rxe_ctx_ops; - - return &context->ibv_ctx; - -out: - free(context); - return NULL; -} - -static void rxe_free_context(struct ibv_context *ibctx) -{ - struct rxe_context *context = to_rctx(ibctx); - - free(context); -} - -static void rxe_uninit_device(struct verbs_device *verbs_device) -{ - struct rxe_device *dev = to_rdev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device *rxe_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct rxe_device *dev; - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->abi_version = sysfs_dev->abi_ver; - - return &dev->ibv_dev; -} - -static const struct verbs_device_ops rxe_dev_ops = { - .name = "rxe", - .match_min_abi_version = 0, - .match_max_abi_version = INT_MAX, - .match_table = hca_table, - .alloc_device = rxe_device_alloc, - .uninit_device = rxe_uninit_device, - .alloc_context = rxe_alloc_context, - .free_context = rxe_free_context, -}; -PROVIDER_DRIVER(rxe_dev_ops); diff --git a/usr/rdma-core/providers/rxe/rxe.h b/usr/rdma-core/providers/rxe/rxe.h deleted file mode 100644 index 8a25e82af..000000000 --- a/usr/rdma-core/providers/rxe/rxe.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2009 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2009 System Fabric Works, Inc. All rights reserved. - * Copyright (c) 2006-2007 QLogic Corp. All rights reserved. - * Copyright (c) 2005. PathScale, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef RXE_H -#define RXE_H - -#include -#include -#include -#include /* struct rxe_av */ -#include "rxe-abi.h" - -enum rdma_network_type { - RDMA_NETWORK_IB, - RDMA_NETWORK_IPV4, - RDMA_NETWORK_IPV6 -}; - -struct rxe_device { - struct verbs_device ibv_dev; - int abi_version; -}; - -struct rxe_context { - struct ibv_context ibv_ctx; -}; - -struct rxe_cq { - struct ibv_cq ibv_cq; - struct mmap_info mmap_info; - struct rxe_queue *queue; - pthread_spinlock_t lock; -}; - -struct rxe_ah { - struct ibv_ah ibv_ah; - struct rxe_av av; -}; - -struct rxe_wq { - struct rxe_queue *queue; - pthread_spinlock_t lock; - unsigned int max_sge; - unsigned int max_inline; -}; - -struct rxe_qp { - struct ibv_qp ibv_qp; - struct mmap_info rq_mmap_info; - struct rxe_wq rq; - struct mmap_info sq_mmap_info; - struct rxe_wq sq; - unsigned int ssn; -}; - -#define qp_type(qp) ((qp)->ibv_qp.qp_type) - -struct rxe_srq { - struct ibv_srq ibv_srq; - struct mmap_info mmap_info; - struct rxe_wq rq; - uint32_t srq_num; -}; - -#define to_rxxx(xxx, type) \ - ((struct rxe_##type *) \ - ((void *) ib##xxx - offsetof(struct rxe_##type, ibv_##xxx))) - -static inline struct rxe_context *to_rctx(struct ibv_context *ibctx) -{ - return to_rxxx(ctx, context); -} - -static inline struct rxe_device *to_rdev(struct ibv_device *ibdev) -{ - return to_rxxx(dev, device); -} - -static inline struct rxe_cq *to_rcq(struct ibv_cq *ibcq) -{ - return to_rxxx(cq, cq); -} - -static inline struct rxe_qp *to_rqp(struct ibv_qp *ibqp) -{ - return to_rxxx(qp, qp); -} - -static inline struct rxe_srq *to_rsrq(struct ibv_srq *ibsrq) -{ - return to_rxxx(srq, srq); -} - -static inline struct rxe_ah *to_rah(struct ibv_ah *ibah) -{ - return to_rxxx(ah, ah); -} - -#endif /* RXE_H */ diff --git a/usr/rdma-core/providers/rxe/rxe_cfg.in b/usr/rdma-core/providers/rxe/rxe_cfg.in deleted file mode 100755 index 0a8583da1..000000000 --- a/usr/rdma-core/providers/rxe/rxe_cfg.in +++ /dev/null @@ -1,674 +0,0 @@ -#!/usr/bin/perl - -# * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved. -# * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved. -# * -# * This software is available to you under a choice of one of two -# * licenses. You may choose to be licensed under the terms of the GNU -# * General Public License (GPL) Version 2, available from the file -# * COPYING in the main directory of this source tree, or the -# * OpenIB.org BSD license below: -# * -# * Redistribution and use in source and binary forms, with or -# * without modification, are permitted provided that the following -# * conditions are met: -# * -# * - Redistributions of source code must retain the above -# * copyright notice, this list of conditions and the following -# * disclaimer. -# * -# * - Redistributions in binary form must reproduce the above -# * copyright notice, this list of conditions and the following -# * disclaimer in the documentation and/or other materials -# * provided with the distribution. -# * -# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# * SOFTWARE. -# - -use warnings; -use strict; - -use File::Basename; -use File::Path qw(make_path); -use Getopt::Long; - -my $help = 0; -my $no_persist = 0; -my $debug = 0; -my $force = 0; -my $linkonly = 0; -my $parms = "/sys/module/rdma_rxe/parameters"; -my $modprobe_opt = ""; -my $modprobe_checked = "0"; -my $persistence_path = "@CMAKE_INSTALL_FULL_SHAREDSTATEDIR@/rxe"; -my $persistence_file = "${persistence_path}/rxe"; -my $num_persistent = 0; -my $sys = "/sys/module/rdma_rxe/parameters"; -my %rxe_names; -my @rxe_array; -my %eth_names; -my @eth_list; -my %eth_driver; -my %link_state; -my %link_speed; -my %eth_mtu; -my %ipv4_addr; -my %rxe_mtu; -my @persistence_array; -my %persistence_hash; -my @mlx4_port; -my @mlx4_ether; -my @roce_list; - -# Read a file and return its contents as a string. -sub read_file { - my $filename = shift; - my $result = ""; - - if (open(FILE, $filename)) { - $result = ; - close FILE; - } - return $result; -} - -#get mapping between rxe and eth devices -sub get_names { - my $i = 0; - - foreach my $rxe (glob("/sys/class/infiniband/rxe*")) { - $rxe = basename($rxe); - my $eth = read_file("/sys/class/infiniband/$rxe/parent"); - chomp($eth); - - if (($eth =~ /[\w]+[\d]/) - && ($rxe =~ /rxe[0123456789]/)) { - - # hash ethername to rxename - $rxe_names{$eth} = $rxe; - $rxe_array[$i++] = $rxe; - - # hash rxename to ethername - $eth_names{$rxe} = $eth; - } - } -} - -# get list of Mellanox RoCE ports -sub get_mlx4_list { - my $i = 0; - - foreach my $mlx4 (glob("/sys/class/infiniband/mlx4_*")) { - $mlx4 = basename($mlx4); - foreach my $port (glob("/sys/class/infiniband/$mlx4/ports/*")) { - $port = basename($port); - my $link = read_file("$port/link_layer"); - chomp($link); - - if ($link =~ "Ethernet") { - $roce_list[$i++] = "$mlx4:$port"; - } - } - } -} - -#collect per device information -sub get_dev_info { - my @list; - my @fields; - my @lines; - my $line; - my $eth; - my $drv; - my $np; - my $i = 0; - my $j = 0; - - get_mlx4_list(); - - my @my_eth_list = (); - foreach my $my_eth_dev (glob("/sys/class/net/*")) { - $my_eth_dev = basename($my_eth_dev); - my $my_dev_type = read_file("/sys/class/net/${my_eth_dev}/type"); - chomp($my_dev_type); - if ($my_dev_type == "1") { - push(@my_eth_list, "$my_eth_dev"); - } - } - - @list = @my_eth_list; - foreach $eth (@list) { - chomp($eth); - - $eth_list[$i++] = $eth; - - @lines = `ethtool -i $eth`; - foreach $line (@lines) { - chomp($line); - - @fields = split(/\s+/, $line); - chomp($fields[0]); - - if ($fields[0] =~ /driver:/) { - $drv = $fields[1]; - $eth_driver{$eth} = $drv; - - if ($drv =~ /mlx4_en/ && scalar(@roce_list) > 0 ) { - $eth_names{$roce_list[$j++]} = $eth; - } - } - } - - # get link status - $link_state{$eth} = ""; - $link_speed{$eth} = ""; - - @lines = `ethtool $eth`; - foreach $line (@lines) { - chomp($line); - - @fields = split(/:/, $line); - if (defined($fields[1])) { - $fields[1] =~ s/^\s+//g; - if ($fields[0] =~ "Link detected") { - $link_state{$eth} = $fields[1]; - } - } - elsif ($line =~ "10000baseT") { - $link_speed{$eth} = "10GigE"; - } - } - - $ipv4_addr{$eth} = " "; - $eth_mtu{$eth} = ""; - - @lines = `ifconfig $eth`; - foreach $line (@lines) { - # get IP address - if ($line =~ /inet addr/) { - $line =~ s/^\s+inet addr://g; - @fields = split(/\s+/, $line); - $ipv4_addr{$eth} = $fields[0]; - } - - # get ethernet mtu - if ($line =~ /MTU:/) { - $line =~ s/^.*MTU://g; - @fields = split(/\s+/, $line); - $eth_mtu{$eth} = $fields[0]; - } - } - } - - # get rxe mtu - foreach my $rxe (@rxe_array) { - - @lines = `ibv_devinfo -d $rxe`; - foreach $line (@lines) { - if ($line =~ "active_mtu") { - $line =~ s/^\s+active_mtu:\s+//g; - chomp($line); - - $rxe_mtu{$rxe} = $line; - } - } - $rxe_mtu{$rxe} = "(?)" if (!$rxe_mtu{$rxe}); - } -} - -# return string or the string "###" if string is all whitespace -sub set_field { - my $fld = $_[0]; - - if (defined($fld) && $fld =~ /\S/) { - return $fld; - } else { - return "###"; - } -} - -# format status output into fixed width columns -sub status_print { - my @fields; - my $field; - my @flen = (); - my $num_fields = 0; - my $i; - my $pad; - my $line; - - # one pass to size the columns - foreach $line (@_) { - @fields = split(/\s+/, $line); - $i = 0; - foreach $field (@fields) { - if (!defined($flen[$i])) { - $flen[$i] = length($field); - } - else { - $flen[$i] = max($flen[$i], length($field)); - } - $i++; - } - - if ($i > $num_fields) { - $num_fields = $i; - } - } - - # one pass to print - foreach $line (@_) { - print " "; - @fields = split(/\s+/, $line); - for ($i = 0; $i < $num_fields; $i++) { - if (defined($fields[$i])) { - $pad = $flen[$i] - length($fields[$i]) + 2; - } - else { - $pad = $flen[$i] + 2; - } - if (defined($fields[$i]) && ($fields[$i] ne "###")) { - print "$fields[$i]"; - } - else { - print " "; - } - printf("%*s", $pad, ""); - } - print "\n"; - } -} - -# check driver load status -sub check_module_status { - if (-e $sys) { - return 0; - } else { - return 1; - } -} - -# print driver load status and ethertype for rdma_rxe and rdma_rxe_net -sub show_module_status { - print "rdma_rxe module not loaded\n" if (!(-e $sys)); -} - -# print rxe status -sub do_status { - my $instance = $_[0]; - my $ln = 0; - my @outp; - my $rxe; - my $rmtu; - - get_names(); - get_dev_info(); - show_module_status(); - - $outp[$ln++] = "Name\tLink\tDriver\t\tSpeed\tNMTU\tIPv4_addr\tRDEV\tRMTU"; - - foreach my $eth (@eth_list) { - - # handle case where rxe_drivers are not loaded - if (defined($rxe_names{$eth})) { - $rxe = $rxe_names{$eth}; - $rmtu = $rxe_mtu{$rxe}; - } - else { - $rxe = ""; - $rmtu = ""; - } - - if ((!defined($instance) - && (($linkonly == 0) || ($link_state{$eth} =~ "yes"))) - || (defined($instance) && ($rxe =~ "$instance"))) { - $outp[$ln] = set_field("$eth"); - $outp[$ln] .= "\t"; - $outp[$ln] .= set_field("$link_state{$eth}"); - $outp[$ln] .= "\t"; - $outp[$ln] .= set_field(exists($eth_driver{$eth}) ? $eth_driver{$eth} : ""); - $outp[$ln] .= "\t"; - $outp[$ln] .= set_field("$link_speed{$eth}"); - $outp[$ln] .= "\t"; - $outp[$ln] .= set_field("$eth_mtu{$eth}"); - $outp[$ln] .= "\t"; - $outp[$ln] .= set_field("$ipv4_addr{$eth}"); - $outp[$ln] .= "\t"; - $outp[$ln] .= set_field("$rxe"); - $outp[$ln] .= "\t"; - $outp[$ln] .= set_field("$rmtu"); - $ln++; - } - } - - status_print(@outp); -} - -# read file containing list of ethernet devices into a list -sub populate_persistence { - my $i = 0; - - open FILE, $persistence_file; - while() { - my $line = $_; - chomp($line); - $line =~ s/^\s+//g; - if ($line =~ /[\w]+[\d]/) { - # in case we add fields later - my ($eth, $cruft) = split(/\s+/, $line, 2); - if ($eth =~ /^[\w]+[\d]/) { - $persistence_array[$i] = $eth; - $persistence_hash{$eth} = $i++; - } - } - } - close FILE; - - $num_persistent = $i; -} - -# print out list of ethernet devices to file -sub commit_persistent { - my $i; - my $eth; - - open(PF, ">$persistence_file"); - - for ($i = 0; $i < $num_persistent; $i++) { - $eth = $persistence_array[$i]; - if ($eth =~ /[\w]+[\d]/) { - print(PF "$persistence_array[$i]\n"); - } - } - - close(PF); -} - -sub delete_persistent { - my $eth = $_[0]; - - if (defined($persistence_hash{$eth})) { - $persistence_array[$persistence_hash{$eth}] = ""; - } -} - -sub add_persistent { - my $eth = $_[0]; - - # Is this one already in the persistence list? - if (!defined($persistence_hash{$eth})) { - $persistence_array[$num_persistent] = $eth; - $persistence_hash{$eth} = $num_persistent; - $num_persistent++; - } -} - -# add new rxe device to eth if not already up -sub rxe_add { - my $eth = $_[0]; - - if (!($eth =~ /[\w]+[\d]/)) { - print "eth_name ($eth) looks bogus\n"; - return; - } - - if (!defined($rxe_names{$eth})) { - system("echo '$eth' > $parms/add"); - } - if (!$no_persist) { - add_persistent($eth); - commit_persistent(); - } -} - -sub rxe_remove { - my $arg2 = $_[0]; - my $rxe; - my $eth; - - print "remove $arg2\n" if ($debug > 0); - - if ($arg2 =~ /[\w]+[\d]/) { - $eth = $arg2; - $rxe = $rxe_names{$eth}; - } - elsif ($arg2 =~ /rxe[0123456789]/) { - $rxe = $arg2; - $eth = $eth_names{$rxe}; - } - elsif ($arg2 eq "all") { - $rxe = "all"; - } - - if (($rxe eq "all") || ($rxe =~ /^rxe[0123456789]/)) { - my $cmd = "echo '$rxe' > $parms/remove"; - #print "$cmd\n"; - system($cmd); - if (!$no_persist) { - if ($rxe eq "all") { - unlink($persistence_file); - } - elsif ($eth =~/[\w]+[\d]/) { - delete_persistent($eth); - commit_persistent(); - } - else { - print "Warning: Unable to resolve ethname; " - . "instance may persist on restart\n"; - } - } - } - else { - print "rxe instance $rxe not found\n"; - } -} - -sub get_devinfo { - my $rxe = $_[0]; - - my $cmd = "ibv_devinfo -d $rxe"; - return `$cmd`; -} - -# allow unsupported modules to load in SLES11 if allowed -sub modprobe { - my $module = $_[0]; - my $opts = $_[1]; - my @lines; - my $line; - - if ($modprobe_checked == "0") { - @lines = `modprobe -c`; - foreach $line (@lines) { - if ($line =~ /^allow_unsupported_modules *0/) { - $modprobe_opt = " --allow-unsupported-modules "; - last; - } - } - $modprobe_checked = "1"; - } - - if (!defined($opts)) { - $opts = ""; - } - - system("modprobe $modprobe_opt $module $opts"); -} - -# bring up rxe -sub do_start { - my $proto_str = ""; - - system("mkdir -p $persistence_path"); - system("touch $persistence_file"); - - modprobe("ib_core"); - modprobe("ib_uverbs"); - modprobe("rdma_ucm"); - modprobe("rdma_rxe"); - - populate_persistence(); - - foreach my $eth (@persistence_array) { - rxe_add($eth); - } - - get_names(); - - foreach my $rxe (@rxe_array) { - my $stat = get_devinfo($rxe); - if ($stat =~ "PORT_DOWN") { - my $cmd = "ifconfig $eth_names{$rxe} up"; - system($cmd); - } - } - -} - -# check if argument is an integer -sub is_integer { - defined $_[0] && $_[0] =~ /^[+-]?\d+$/; -} - -# remove all rxe devices and unload drivers -sub do_stop { - my $rxe; - - foreach $rxe (@rxe_array) { - system("echo '$rxe' > $sys/remove"); - } - - if (-e $sys) { - system("rmmod rdma_rxe"); - } - - if (-e $sys) { - print "unable to unload drivers, reboot required\n"; - } -} - -sub do_debug { - my $arg2 = $_[0]; - my $debugfile = "$parms/debug"; - chomp($arg2); - - if (!(-e "$debugfile")) { - print "Error: debug is compiled out of this rxe driver\n"; - return; - } - - if ($arg2 eq "on") { system("echo '31' > $debugfile"); } - elsif ($arg2 eq "off") { system("echo '0' > $debugfile"); } - elsif ($arg2 eq "0") { system("echo '0' > $debugfile"); } - elsif ($arg2 eq "") { } - elsif ($arg2 ge "0" && $arg2 le "31") { - system("echo '$arg2' > $debugfile"); - } - else { - print "unrecognized debug cmd ($arg2)\n"; - } - - my $current = read_file($debugfile); - chomp($current); - if ($current > 0) { - print "Debug is ON ($current)\n"; - } - elsif ($current == 0) { - print "Debug is OFF\n"; - } - else { - print "Unrecognized debug value\n"; - } -} - -sub max { - my $a = $_[0]; - my $b = $_[1]; - return $a if ($a > $b); - return $b; -} - -# show usage for rxe_cfg -sub usage { - print " Usage:\n"; - print " rxe_cfg [options] start|stop|status|persistent\n"; - print " rxe_cfg debug on|off|\n"; - print " rxe_cfg [-n] add \n"; - print " rxe_cfg [-n] remove |\n"; - print "\n"; - print " = network device e.g. eth3\n"; - print " = rdma device e.g. rxe1\n"; - print "\n"; - print " Options:\n"; - print " -h: print this usage information\n"; - print " -n: do not make the configuration action persistent\n"; - print " -v: print additional debug output\n"; - print " -l: show status for interfaces with link up\n"; - print " -p : (start command only) - set ethertype\n"; -} - -sub main { - GetOptions( - "-h" => \$help, - "--help" => \$help, - "-n" => \$no_persist, - "-v:+" => \$debug, - "-f" => \$force, - "-l" => \$linkonly, - ); - - my $arg1 = $ARGV[0]; - my $arg2 = $ARGV[1]; - my $arg3 = $ARGV[2]; - - # status is the default - if (!defined($arg1) || ($arg1 =~ /status/)) { - do_status($arg2); - exit; - } - - if ($help) { - usage(); - exit; - } - - # stuff that does not require modules to be loaded - if ($arg1 eq "help") { usage(); exit; } - elsif ($arg1 eq "start") { do_start(); do_status(); exit; } - elsif ($arg1 eq "persistent") { system("cat $persistence_file"); exit; } - - - # can't do much else, bail if modules aren't loaded - if (check_module_status()) { - exit; - } - - # create persistence file if necessary - make_path($persistence_path); - if (!(-e $persistence_file)) { - `touch $persistence_file`; - } - - # Get full context of the configuration - populate_persistence(); - get_names(); - get_dev_info(); - - # Stuff that requires the rdma_rxe module to be loaded - if ($arg1 eq "stop") { do_stop(); exit; } - elsif ($arg1 eq "debug") { do_debug($arg2); exit; } - elsif ($arg1 eq "add") { rxe_add($arg2); exit; } - elsif ($arg1 eq "remove") { rxe_remove($arg2); exit; } - elsif ($arg1 eq "help") { usage(); exit; } -} - -main(); - -exit; diff --git a/usr/rdma-core/providers/rxe/rxe_queue.h b/usr/rdma-core/providers/rxe/rxe_queue.h deleted file mode 100644 index 5c57b3e38..000000000 --- a/usr/rdma-core/providers/rxe/rxe_queue.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2009 Mellanox Technologies Ltd. All rights reserved. - * Copyright (c) 2009 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the fileA - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -/* implements a simple circular buffer with sizes a power of 2 */ - -#ifndef H_RXE_PCQ -#define H_RXE_PCQ - -#include -#include - -/* MUST MATCH kernel struct rxe_pqc in rxe_queue.h */ -struct rxe_queue { - uint32_t log2_elem_size; - uint32_t index_mask; - uint32_t pad_1[30]; - _Atomic(uint32_t) producer_index; - uint32_t pad_2[31]; - _Atomic(uint32_t) consumer_index; - uint32_t pad_3[31]; - uint8_t data[0]; -}; - -static inline int next_index(struct rxe_queue *q, int index) -{ - return (index + 1) & q->index_mask; -} - -static inline int queue_empty(struct rxe_queue *q) -{ - /* Must hold consumer_index lock */ - return ((atomic_load(&q->producer_index) - - atomic_load_explicit(&q->consumer_index, - memory_order_relaxed)) & - q->index_mask) == 0; -} - -static inline int queue_full(struct rxe_queue *q) -{ - /* Must hold producer_index lock */ - return ((atomic_load_explicit(&q->producer_index, - memory_order_relaxed) + - 1 - atomic_load(&q->consumer_index)) & - q->index_mask) == 0; -} - -static inline void advance_producer(struct rxe_queue *q) -{ - /* Must hold producer_index lock */ - atomic_thread_fence(memory_order_release); - atomic_store( - &q->producer_index, - (atomic_load_explicit(&q->producer_index, memory_order_relaxed) + - 1) & - q->index_mask); -} - -static inline void advance_consumer(struct rxe_queue *q) -{ - /* Must hold consumer_index lock */ - atomic_store( - &q->consumer_index, - (atomic_load_explicit(&q->consumer_index, memory_order_relaxed) + - 1) & - q->index_mask); -} - -static inline void *producer_addr(struct rxe_queue *q) -{ - /* Must hold producer_index lock */ - return q->data + ((atomic_load_explicit(&q->producer_index, - memory_order_relaxed) & - q->index_mask) - << q->log2_elem_size); -} - -static inline void *consumer_addr(struct rxe_queue *q) -{ - /* Must hold consumer_index lock */ - return q->data + ((atomic_load_explicit(&q->consumer_index, - memory_order_relaxed) & - q->index_mask) - << q->log2_elem_size); -} - -static inline void *addr_from_index(struct rxe_queue *q, unsigned int index) -{ - return q->data + ((index & q->index_mask) - << q->log2_elem_size); -} - -static inline unsigned int index_from_addr(const struct rxe_queue *q, const void *addr) -{ - return (((uint8_t *)addr - q->data) >> q->log2_elem_size) & q->index_mask; -} - -#endif /* H_RXE_PCQ */ diff --git a/usr/rdma-core/providers/vmw_pvrdma/CMakeLists.txt b/usr/rdma-core/providers/vmw_pvrdma/CMakeLists.txt deleted file mode 100644 index f14629508..000000000 --- a/usr/rdma-core/providers/vmw_pvrdma/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -rdma_provider(vmw_pvrdma - cq.c - pvrdma_main.c - qp.c - verbs.c -) diff --git a/usr/rdma-core/providers/vmw_pvrdma/cq.c b/usr/rdma-core/providers/vmw_pvrdma/cq.c deleted file mode 100644 index 701f0522f..000000000 --- a/usr/rdma-core/providers/vmw_pvrdma/cq.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. 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 version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program available in the file COPYING in the main - * directory of this source tree. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "pvrdma.h" - -enum { - CQ_OK = 0, - CQ_EMPTY = -1, - CQ_POLL_ERR = -2, -}; - -enum { - PVRDMA_CQE_IS_SEND_MASK = 0x40, - PVRDMA_CQE_OPCODE_MASK = 0x1f, -}; - -int pvrdma_alloc_cq_buf(struct pvrdma_device *dev, struct pvrdma_cq *cq, - struct pvrdma_buf *buf, int entries) -{ - if (pvrdma_alloc_buf(buf, cq->offset + - entries * (sizeof(struct pvrdma_cqe)), - dev->page_size)) - return -1; - memset(buf->buf, 0, buf->length); - - return 0; -} - -static struct pvrdma_cqe *get_cqe(struct pvrdma_cq *cq, int entry) -{ - return cq->buf.buf + cq->offset + - entry * (sizeof(struct pvrdma_cqe)); -} - -static int pvrdma_poll_one(struct pvrdma_cq *cq, - struct pvrdma_qp **cur_qp, - struct ibv_wc *wc) -{ - struct pvrdma_context *ctx = to_vctx(cq->ibv_cq.context); - int has_data; - unsigned int head; - int tried = 0; - struct pvrdma_cqe *cqe; - -retry: - has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx, - cq->cqe_cnt, &head); - if (has_data == 0) { - unsigned int val; - - if (tried) - return CQ_EMPTY; - - /* Pass down POLL to give physical HCA a chance to poll. */ - val = cq->cqn | PVRDMA_UAR_CQ_POLL; - pvrdma_write_uar_cq(ctx->uar, val); - - tried = 1; - goto retry; - } else if (has_data == -1) { - return CQ_POLL_ERR; - } - - cqe = get_cqe(cq, head); - if (!cqe) - return CQ_EMPTY; - - udma_from_device_barrier(); - - if (ctx->qp_tbl[cqe->qp & 0xFFFF]) - *cur_qp = (struct pvrdma_qp *)ctx->qp_tbl[cqe->qp & 0xFFFF]; - else - return CQ_POLL_ERR; - - wc->opcode = pvrdma_wc_opcode_to_ibv(cqe->opcode); - wc->status = pvrdma_wc_status_to_ibv(cqe->status); - wc->wr_id = cqe->wr_id; - wc->qp_num = (*cur_qp)->ibv_qp.qp_num; - wc->byte_len = cqe->byte_len; - wc->imm_data = cqe->imm_data; - wc->src_qp = cqe->src_qp; - wc->wc_flags = cqe->wc_flags; - wc->pkey_index = cqe->pkey_index; - wc->slid = cqe->slid; - wc->sl = cqe->sl; - wc->dlid_path_bits = cqe->dlid_path_bits; - wc->vendor_err = 0; - - /* Update shared ring state. */ - pvrdma_idx_ring_inc(&(cq->ring_state->rx.cons_head), cq->cqe_cnt); - - return CQ_OK; -} - -int pvrdma_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc) -{ - struct pvrdma_cq *cq = to_vcq(ibcq); - struct pvrdma_qp *qp; - int npolled = 0; - - if (num_entries < 1 || wc == NULL) - return 0; - - pthread_spin_lock(&cq->lock); - - for (npolled = 0; npolled < num_entries; ++npolled) { - if (pvrdma_poll_one(cq, &qp, wc + npolled) != CQ_OK) - break; - } - - pthread_spin_unlock(&cq->lock); - - return npolled; -} - -void pvrdma_cq_clean_int(struct pvrdma_cq *cq, uint32_t qpn) -{ - /* Flush CQEs from specified QP */ - int has_data; - unsigned int head; - - /* Lock held */ - has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx, - cq->cqe_cnt, &head); - - if (unlikely(has_data > 0)) { - int items; - int curr; - int tail = pvrdma_idx(&cq->ring_state->rx.prod_tail, - cq->cqe_cnt); - struct pvrdma_cqe *cqe; - struct pvrdma_cqe *curr_cqe; - - items = (tail > head) ? (tail - head) : - (cq->cqe_cnt - head + tail); - curr = --tail; - while (items-- > 0) { - if (curr < 0) - curr = cq->cqe_cnt - 1; - if (tail < 0) - tail = cq->cqe_cnt - 1; - curr_cqe = get_cqe(cq, curr); - udma_from_device_barrier(); - if ((curr_cqe->qp & 0xFFFF) != qpn) { - if (curr != tail) { - cqe = get_cqe(cq, tail); - udma_from_device_barrier(); - *cqe = *curr_cqe; - } - tail--; - } else { - pvrdma_idx_ring_inc( - &cq->ring_state->rx.cons_head, - cq->cqe_cnt); - } - curr--; - } - } -} - -void pvrdma_cq_clean(struct pvrdma_cq *cq, uint32_t qpn) -{ - pthread_spin_lock(&cq->lock); - pvrdma_cq_clean_int(cq, qpn); - pthread_spin_unlock(&cq->lock); -} - -struct ibv_cq *pvrdma_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) -{ - struct pvrdma_device *dev = to_vdev(context->device); - struct user_pvrdma_create_cq cmd; - struct user_pvrdma_create_cq_resp resp; - struct pvrdma_cq *cq; - int ret; - - if (cqe < 1) - return NULL; - - cq = malloc(sizeof(*cq)); - if (!cq) - return NULL; - - /* Extra page for shared ring state */ - cq->offset = dev->page_size; - - if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE)) - goto err; - - cqe = align_next_power2(cqe); - - if (pvrdma_alloc_cq_buf(dev, cq, &cq->buf, cqe)) - goto err; - - cq->ring_state = cq->buf.buf; - - cmd.udata.buf_addr = (uintptr_t) cq->buf.buf; - cmd.udata.buf_size = cq->buf.length; - ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, - &cq->ibv_cq, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp)); - if (ret) - goto err_buf; - - cq->cqn = resp.udata.cqn; - cq->cqe_cnt = cq->ibv_cq.cqe; - - return &cq->ibv_cq; - -err_buf: - pvrdma_free_buf(&cq->buf); -err: - free(cq); - - return NULL; -} - -int pvrdma_destroy_cq(struct ibv_cq *cq) -{ - int ret; - - ret = ibv_cmd_destroy_cq(cq); - if (ret) - return ret; - - pvrdma_free_buf(&to_vcq(cq)->buf); - free(to_vcq(cq)); - - return 0; -} - -int pvrdma_req_notify_cq(struct ibv_cq *ibcq, int solicited) -{ - struct pvrdma_context *ctx = to_vctx(ibcq->context); - struct pvrdma_cq *cq = to_vcq(ibcq); - unsigned int val = cq->cqn; - - val |= solicited ? PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM; - pvrdma_write_uar_cq(ctx->uar, val); - - return 0; -} diff --git a/usr/rdma-core/providers/vmw_pvrdma/pvrdma-abi-fix.h b/usr/rdma-core/providers/vmw_pvrdma/pvrdma-abi-fix.h deleted file mode 100644 index 83916dbfc..000000000 --- a/usr/rdma-core/providers/vmw_pvrdma/pvrdma-abi-fix.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. 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 version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program available in the file COPYING in the main - * directory of this source tree. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PVRDMA_ABI_FIX_H__ -#define __PVRDMA_ABI_FIX_H__ - -#include -#include - -struct user_pvrdma_alloc_ucontext_resp { - struct ibv_get_context_resp ibv_resp; - struct pvrdma_alloc_ucontext_resp udata; -}; - -struct user_pvrdma_alloc_pd_resp { - struct ibv_alloc_pd_resp ibv_resp; - struct pvrdma_alloc_pd_resp udata; -}; - -struct user_pvrdma_create_cq { - struct ibv_create_cq ibv_cmd; - struct pvrdma_create_cq udata; -}; - -struct user_pvrdma_create_cq_resp { - struct ibv_create_cq_resp ibv_resp; - struct pvrdma_create_cq_resp udata; -}; - -struct user_pvrdma_create_qp { - struct ibv_create_qp ibv_cmd; - struct pvrdma_create_qp udata; -}; - -#endif /* __PVRDMA_ABI_FIX_H__ */ diff --git a/usr/rdma-core/providers/vmw_pvrdma/pvrdma.h b/usr/rdma-core/providers/vmw_pvrdma/pvrdma.h deleted file mode 100644 index 7840e11ee..000000000 --- a/usr/rdma-core/providers/vmw_pvrdma/pvrdma.h +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. 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 version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program available in the file COPYING in the main - * directory of this source tree. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PVRDMA_H__ -#define __PVRDMA_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BIT(nr) (1UL << (nr)) - -#include "pvrdma-abi-fix.h" -#include "pvrdma_ring.h" - -#define PFX "pvrdma: " - -enum { - PVRDMA_OPCODE_NOP = 0x00, - PVRDMA_OPCODE_SEND_INVAL = 0x01, - PVRDMA_OPCODE_RDMA_WRITE = 0x08, - PVRDMA_OPCODE_RDMA_WRITE_IMM = 0x09, - PVRDMA_OPCODE_SEND = 0x0a, - PVRDMA_OPCODE_SEND_IMM = 0x0b, - PVRDMA_OPCODE_LSO = 0x0e, - PVRDMA_OPCODE_RDMA_READ = 0x10, - PVRDMA_OPCODE_ATOMIC_CS = 0x11, - PVRDMA_OPCODE_ATOMIC_FA = 0x12, - PVRDMA_OPCODE_ATOMIC_MASK_CS = 0x14, - PVRDMA_OPCODE_ATOMIC_MASK_FA = 0x15, - PVRDMA_OPCODE_BIND_MW = 0x18, - PVRDMA_OPCODE_FMR = 0x19, - PVRDMA_OPCODE_LOCAL_INVAL = 0x1b, - PVRDMA_OPCODE_CONFIG_CMD = 0x1f, - - PVRDMA_RECV_OPCODE_RDMA_WRITE_IMM = 0x00, - PVRDMA_RECV_OPCODE_SEND = 0x01, - PVRDMA_RECV_OPCODE_SEND_IMM = 0x02, - PVRDMA_RECV_OPCODE_SEND_INVAL = 0x03, - - PVRDMA_CQE_OPCODE_ERROR = 0x1e, - PVRDMA_CQE_OPCODE_RESIZE = 0x16, -}; - -enum { - PVRDMA_WQE_CTRL_FENCE = 1 << 6, - PVRDMA_WQE_CTRL_CQ_UPDATE = 3 << 2, - PVRDMA_WQE_CTRL_SOLICIT = 1 << 1, -}; - -struct pvrdma_device { - struct verbs_device ibv_dev; - int page_size; - int abi_version; -}; - -struct pvrdma_context { - struct ibv_context ibv_ctx; - void *uar; - pthread_spinlock_t uar_lock; - int max_qp_wr; - int max_sge; - int max_cqe; - struct pvrdma_qp **qp_tbl; -}; - -struct pvrdma_buf { - void *buf; - size_t length; -}; - -struct pvrdma_pd { - struct ibv_pd ibv_pd; - uint32_t pdn; -}; - -struct pvrdma_cq { - struct ibv_cq ibv_cq; - struct pvrdma_buf buf; - struct pvrdma_buf resize_buf; - pthread_spinlock_t lock; - struct pvrdma_ring_state *ring_state; - uint32_t cqe_cnt; - uint32_t offset; - uint32_t cqn; -}; - -struct pvrdma_wq { - uint64_t *wrid; - pthread_spinlock_t lock; - int wqe_cnt; - int wqe_size; - struct pvrdma_ring *ring_state; - int max_gs; - int wqe_shift; - int offset; -}; - -struct pvrdma_qp { - struct ibv_qp ibv_qp; - struct pvrdma_buf rbuf; - struct pvrdma_buf sbuf; - int max_inline_data; - int buf_size; - __be32 sq_signal_bits; - int sq_spare_wqes; - struct pvrdma_wq sq; - struct pvrdma_wq rq; -}; - -struct pvrdma_ah { - struct ibv_ah ibv_ah; - struct pvrdma_av av; -}; - -static inline unsigned long align(unsigned long val, unsigned long align) -{ - return (val + align - 1) & ~(align - 1); -} - -static inline int align_next_power2(int size) -{ - int val = 1; - - while (val < size) - val <<= 1; - - return val; -} - -static inline struct pvrdma_device *to_vdev(struct ibv_device *ibdev) -{ - return container_of(ibdev, struct pvrdma_device, ibv_dev); -} - -static inline struct pvrdma_context *to_vctx(struct ibv_context *ibctx) -{ - return container_of(ibctx, struct pvrdma_context, ibv_ctx); -} - -static inline struct pvrdma_pd *to_vpd(struct ibv_pd *ibpd) -{ - return container_of(ibpd, struct pvrdma_pd, ibv_pd); -} - -static inline struct pvrdma_cq *to_vcq(struct ibv_cq *ibcq) -{ - return container_of(ibcq, struct pvrdma_cq, ibv_cq); -} - -static inline struct pvrdma_qp *to_vqp(struct ibv_qp *ibqp) -{ - return container_of(ibqp, struct pvrdma_qp, ibv_qp); -} - -static inline struct pvrdma_ah *to_vah(struct ibv_ah *ibah) -{ - return container_of(ibah, struct pvrdma_ah, ibv_ah); -} - -static inline void pvrdma_write_uar_qp(void *uar, unsigned value) -{ - *(__le32 *)(uar + PVRDMA_UAR_QP_OFFSET) = htole32(value); -} - -static inline void pvrdma_write_uar_cq(void *uar, unsigned value) -{ - *(__le32 *)(uar + PVRDMA_UAR_CQ_OFFSET) = htole32(value); -} - -static inline int ibv_send_flags_to_pvrdma(int flags) -{ - return flags; -} - -static inline enum pvrdma_wr_opcode ibv_wr_opcode_to_pvrdma( - enum ibv_wr_opcode op) -{ - return (enum pvrdma_wr_opcode)op; -} - -static inline enum ibv_wc_status pvrdma_wc_status_to_ibv( - enum pvrdma_wc_status status) -{ - return (enum ibv_wc_status)status; -} - -static inline enum ibv_wc_opcode pvrdma_wc_opcode_to_ibv( - enum pvrdma_wc_opcode op) -{ - return (enum ibv_wc_opcode)op; -} - -static inline int pvrdma_wc_flags_to_ibv(int flags) -{ - return flags; -} - -int pvrdma_alloc_buf(struct pvrdma_buf *buf, size_t size, int page_size); -void pvrdma_free_buf(struct pvrdma_buf *buf); - -int pvrdma_query_device(struct ibv_context *context, - struct ibv_device_attr *attr); -int pvrdma_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr); - -struct ibv_pd *pvrdma_alloc_pd(struct ibv_context *context); -int pvrdma_free_pd(struct ibv_pd *pd); - -struct ibv_mr *pvrdma_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, int access); -int pvrdma_dereg_mr(struct ibv_mr *mr); - -struct ibv_cq *pvrdma_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector); -int pvrdma_alloc_cq_buf(struct pvrdma_device *dev, struct pvrdma_cq *cq, - struct pvrdma_buf *buf, int nent); -int pvrdma_destroy_cq(struct ibv_cq *cq); -int pvrdma_req_notify_cq(struct ibv_cq *cq, int solicited); -int pvrdma_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); -void pvrdma_cq_event(struct ibv_cq *cq); -void pvrdma_cq_clean_int(struct pvrdma_cq *cq, uint32_t qpn); -void pvrdma_cq_clean(struct pvrdma_cq *cq, uint32_t qpn); -int pvrdma_get_outstanding_cqes(struct pvrdma_cq *cq); -void pvrdma_cq_resize_copy_cqes(struct pvrdma_cq *cq, void *buf, - int new_cqe); - -struct ibv_qp *pvrdma_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr); -int pvrdma_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask, struct ibv_qp_init_attr *init_attr); -int pvrdma_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask); -int pvrdma_destroy_qp(struct ibv_qp *qp); -void pvrdma_init_qp_indices(struct pvrdma_qp *qp); -void pvrdma_qp_init_sq_ownership(struct pvrdma_qp *qp); -int pvrdma_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr); -int pvrdma_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr); -void pvrdma_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type, - struct pvrdma_qp *qp); -int pvrdma_alloc_qp_buf(struct pvrdma_device *dev, struct ibv_qp_cap *cap, - enum ibv_qp_type type, struct pvrdma_qp *qp); -void pvrdma_set_sq_sizes(struct pvrdma_qp *qp, struct ibv_qp_cap *cap, - enum ibv_qp_type type); -struct pvrdma_qp *pvrdma_find_qp(struct pvrdma_context *ctx, - uint32_t qpn); -int pvrdma_store_qp(struct pvrdma_context *ctx, uint32_t qpn, - struct pvrdma_qp *qp); -void pvrdma_clear_qp(struct pvrdma_context *ctx, uint32_t qpn); - -struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr); -int pvrdma_destroy_ah(struct ibv_ah *ah); - -int pvrdma_alloc_av(struct pvrdma_pd *pd, struct ibv_ah_attr *attr, - struct pvrdma_ah *ah); -void pvrdma_free_av(struct pvrdma_ah *ah); - -#endif /* __PVRDMA_H__ */ diff --git a/usr/rdma-core/providers/vmw_pvrdma/pvrdma_main.c b/usr/rdma-core/providers/vmw_pvrdma/pvrdma_main.c deleted file mode 100644 index 0826629c0..000000000 --- a/usr/rdma-core/providers/vmw_pvrdma/pvrdma_main.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. 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 version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program available in the file COPYING in the main - * directory of this source tree. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "pvrdma.h" - -/* - * VMware PVRDMA vendor id and PCI device id. - */ -#define PCI_VENDOR_ID_VMWARE 0x15AD -#define PCI_DEVICE_ID_VMWARE_PVRDMA 0x0820 - -static struct ibv_context_ops pvrdma_ctx_ops = { - .query_device = pvrdma_query_device, - .query_port = pvrdma_query_port, - .alloc_pd = pvrdma_alloc_pd, - .dealloc_pd = pvrdma_free_pd, - - .reg_mr = pvrdma_reg_mr, - .dereg_mr = pvrdma_dereg_mr, - .create_cq = pvrdma_create_cq, - .poll_cq = pvrdma_poll_cq, - .req_notify_cq = pvrdma_req_notify_cq, - .destroy_cq = pvrdma_destroy_cq, - - .create_qp = pvrdma_create_qp, - .query_qp = pvrdma_query_qp, - .modify_qp = pvrdma_modify_qp, - .destroy_qp = pvrdma_destroy_qp, - - .post_send = pvrdma_post_send, - .post_recv = pvrdma_post_recv, - .create_ah = pvrdma_create_ah, - .destroy_ah = pvrdma_destroy_ah, -}; - -int pvrdma_alloc_buf(struct pvrdma_buf *buf, size_t size, int page_size) -{ - int ret; - - buf->length = align(size, page_size); - buf->buf = mmap(NULL, buf->length, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (buf->buf == MAP_FAILED) - return errno; - - ret = ibv_dontfork_range(buf->buf, size); - if (ret) - munmap(buf->buf, buf->length); - - return ret; -} - -void pvrdma_free_buf(struct pvrdma_buf *buf) -{ - ibv_dofork_range(buf->buf, buf->length); - munmap(buf->buf, buf->length); -} - -static int pvrdma_init_context_shared(struct pvrdma_context *context, - struct ibv_device *ibdev, - int cmd_fd) -{ - struct ibv_get_context cmd; - struct user_pvrdma_alloc_ucontext_resp resp; - - context->ibv_ctx.cmd_fd = cmd_fd; - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp))) - return errno; - - context->qp_tbl = calloc(resp.udata.qp_tab_size & 0xFFFF, - sizeof(struct pvrdma_qp *)); - if (!context->qp_tbl) - return -ENOMEM; - - context->uar = mmap(NULL, to_vdev(ibdev)->page_size, PROT_WRITE, - MAP_SHARED, cmd_fd, 0); - if (context->uar == MAP_FAILED) { - free(context->qp_tbl); - return errno; - } - - pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE); - context->ibv_ctx.ops = pvrdma_ctx_ops; - - return 0; -} - -static void pvrdma_free_context_shared(struct pvrdma_context *context, - struct pvrdma_device *dev) -{ - munmap(context->uar, dev->page_size); - free(context->qp_tbl); -} - -static struct ibv_context *pvrdma_alloc_context(struct ibv_device *ibdev, - int cmd_fd) -{ - struct pvrdma_context *context; - - context = malloc(sizeof(*context)); - if (!context) - return NULL; - - memset(context, 0, sizeof(*context)); - - if (pvrdma_init_context_shared(context, ibdev, cmd_fd)) { - free(context); - return NULL; - } - - return &context->ibv_ctx; -} - -static void pvrdma_free_context(struct ibv_context *ibctx) -{ - struct pvrdma_context *context = to_vctx(ibctx); - - pvrdma_free_context_shared(context, to_vdev(ibctx->device)); - free(context); -} - -static void pvrdma_uninit_device(struct verbs_device *verbs_device) -{ - struct pvrdma_device *dev = to_vdev(&verbs_device->device); - - free(dev); -} - -static struct verbs_device * -pvrdma_device_alloc(struct verbs_sysfs_dev *sysfs_dev) -{ - struct pvrdma_device *dev; - - dev = calloc(1, sizeof(*dev)); - if (!dev) - return NULL; - - dev->abi_version = sysfs_dev->abi_ver; - dev->page_size = sysconf(_SC_PAGESIZE); - - return &dev->ibv_dev; -} - -static const struct verbs_match_ent hca_table[] = { - VERBS_PCI_MATCH(PCI_VENDOR_ID_VMWARE, PCI_DEVICE_ID_VMWARE_PVRDMA, - NULL), - {} -}; - -static const struct verbs_device_ops pvrdma_dev_ops = { - .name = "pvrdma", - .match_min_abi_version = PVRDMA_UVERBS_ABI_VERSION, - .match_max_abi_version = PVRDMA_UVERBS_ABI_VERSION, - .match_table = hca_table, - .alloc_device = pvrdma_device_alloc, - .uninit_device = pvrdma_uninit_device, - .alloc_context = pvrdma_alloc_context, - .free_context = pvrdma_free_context, -}; -PROVIDER_DRIVER(pvrdma_dev_ops); diff --git a/usr/rdma-core/providers/vmw_pvrdma/pvrdma_ring.h b/usr/rdma-core/providers/vmw_pvrdma/pvrdma_ring.h deleted file mode 100644 index e2472312c..000000000 --- a/usr/rdma-core/providers/vmw_pvrdma/pvrdma_ring.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. 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 version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program in the file COPYING. If not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PVRDMA_RING_H__ -#define __PVRDMA_RING_H__ - -#include -#include - -#define PVRDMA_INVALID_IDX -1 /* Invalid index. */ - -/* - * Rings are shared with the device, so read/write access must be atomic. - * PVRDMA is x86 only, and since 32-bit access is atomic on x86, using - * regular uint32_t is safe. - */ - -struct pvrdma_ring { - uint32_t prod_tail; /* Producer tail. */ - uint32_t cons_head; /* Consumer head. */ -}; - -struct pvrdma_ring_state { - struct pvrdma_ring tx; /* Tx ring. */ - struct pvrdma_ring rx; /* Rx ring. */ -}; - -static inline int pvrdma_idx_valid(uint32_t idx, uint32_t max_elems) -{ - /* Generates fewer instructions than a less-than. */ - return (idx & ~((max_elems << 1) - 1)) == 0; -} - -static inline int32_t pvrdma_idx(uint32_t *var, uint32_t max_elems) -{ - const uint32_t idx = *var; - - if (pvrdma_idx_valid(idx, max_elems)) - return idx & (max_elems - 1); - return PVRDMA_INVALID_IDX; -} - -static inline void pvrdma_idx_ring_inc(uint32_t *var, uint32_t max_elems) -{ - uint32_t idx = (*var) + 1; /* Increment. */ - - idx &= (max_elems << 1) - 1; /* Modulo size, flip gen. */ - *var = idx; -} - -static inline int32_t pvrdma_idx_ring_has_space(const struct pvrdma_ring *r, - uint32_t max_elems, - uint32_t *out_tail) -{ - const uint32_t tail = r->prod_tail; - const uint32_t head = r->cons_head; - - if (pvrdma_idx_valid(tail, max_elems) && - pvrdma_idx_valid(head, max_elems)) { - *out_tail = tail & (max_elems - 1); - return tail != (head ^ max_elems); - } - return PVRDMA_INVALID_IDX; -} - -static inline int32_t pvrdma_idx_ring_has_data(const struct pvrdma_ring *r, - uint32_t max_elems, - uint32_t *out_head) -{ - const uint32_t tail = r->prod_tail; - const uint32_t head = r->cons_head; - - if (pvrdma_idx_valid(tail, max_elems) && - pvrdma_idx_valid(head, max_elems)) { - *out_head = head & (max_elems - 1); - return tail != head; - } - return PVRDMA_INVALID_IDX; -} - -static inline int32_t pvrdma_idx_ring_is_valid_idx(const struct pvrdma_ring *r, - uint32_t max_elems, - uint32_t *idx) -{ - const uint32_t tail = r->prod_tail; - const uint32_t head = r->cons_head; - - if (pvrdma_idx_valid(tail, max_elems) && - pvrdma_idx_valid(head, max_elems) && - pvrdma_idx_valid(*idx, max_elems)) { - if (tail > head && (*idx < tail && *idx >= head)) - return 1; - else if (head > tail && (*idx >= head || *idx < tail)) - return 1; - } - return 0; -} - -#endif /* __PVRDMA_RING_H__ */ diff --git a/usr/rdma-core/providers/vmw_pvrdma/qp.c b/usr/rdma-core/providers/vmw_pvrdma/qp.c deleted file mode 100644 index f5e24860b..000000000 --- a/usr/rdma-core/providers/vmw_pvrdma/qp.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. 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 version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program available in the file COPYING in the main - * directory of this source tree. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "pvrdma.h" - -int pvrdma_alloc_qp_buf(struct pvrdma_device *dev, struct ibv_qp_cap *cap, - enum ibv_qp_type type, struct pvrdma_qp *qp) -{ - qp->sq.wrid = calloc(qp->sq.wqe_cnt, sizeof(uint64_t)); - if (!qp->sq.wrid) - return -1; - - qp->rq.wrid = calloc(qp->rq.wqe_cnt, sizeof(uint64_t)); - if (!qp->rq.wrid) { - free(qp->sq.wrid); - return -1; - } - - /* Align page size for [rq][sq] */ - qp->rbuf.length = align(qp->rq.offset + - qp->rq.wqe_cnt * qp->rq.wqe_size, - dev->page_size); - qp->sbuf.length = align(qp->sq.offset + - qp->sq.wqe_cnt * qp->sq.wqe_size, - dev->page_size); - qp->buf_size = qp->rbuf.length + qp->sbuf.length; - - if (pvrdma_alloc_buf(&qp->rbuf, qp->rbuf.length, dev->page_size)) { - free(qp->sq.wrid); - free(qp->rq.wrid); - return -1; - } - - if (pvrdma_alloc_buf(&qp->sbuf, qp->sbuf.length, dev->page_size)) { - free(qp->sq.wrid); - free(qp->rq.wrid); - pvrdma_free_buf(&qp->rbuf); - return -1; - } - - memset(qp->rbuf.buf, 0, qp->rbuf.length); - memset(qp->sbuf.buf, 0, qp->sbuf.length); - - return 0; -} - -static void pvrdma_init_qp_queue(struct pvrdma_qp *qp) -{ - qp->sq.ring_state->cons_head = 0; - qp->sq.ring_state->prod_tail = 0; - qp->rq.ring_state->cons_head = 0; - qp->rq.ring_state->prod_tail = 0; -} - -struct ibv_qp *pvrdma_create_qp(struct ibv_pd *pd, - struct ibv_qp_init_attr *attr) -{ - struct pvrdma_device *dev = to_vdev(pd->context->device); - struct user_pvrdma_create_qp cmd; - struct ibv_create_qp_resp resp; - struct pvrdma_qp *qp; - int ret; - - attr->cap.max_recv_sge = - align_next_power2(max_t(uint32_t, 1U, attr->cap.max_recv_sge)); - attr->cap.max_recv_wr = - align_next_power2(max_t(uint32_t, 1U, attr->cap.max_recv_wr)); - attr->cap.max_send_sge = - align_next_power2(max_t(uint32_t, 1U, attr->cap.max_send_sge)); - attr->cap.max_send_wr = - align_next_power2(max_t(uint32_t, 1U, attr->cap.max_send_wr)); - - qp = calloc(1, sizeof(*qp)); - if (!qp) - return NULL; - - qp->rq.max_gs = attr->cap.max_recv_sge; - qp->rq.wqe_cnt = attr->cap.max_recv_wr; - qp->rq.offset = 0; - qp->rq.wqe_size = align_next_power2(sizeof(struct pvrdma_rq_wqe_hdr) + - sizeof(struct ibv_sge) * - qp->rq.max_gs); - - qp->sq.max_gs = attr->cap.max_send_sge; - qp->sq.wqe_cnt = attr->cap.max_send_wr; - /* Extra page for shared ring state */ - qp->sq.offset = dev->page_size; - qp->sq.wqe_size = align_next_power2(sizeof(struct pvrdma_sq_wqe_hdr) + - sizeof(struct ibv_sge) * - qp->sq.max_gs); - - /* Reset attr.cap, no srq for now */ - if (attr->srq) { - attr->cap.max_recv_wr = 0; - qp->rq.wqe_cnt = 0; - } - - /* Allocate [rq][sq] memory */ - if (pvrdma_alloc_qp_buf(dev, &attr->cap, attr->qp_type, qp)) - goto err; - - qp->sq.ring_state = qp->sbuf.buf; - qp->rq.ring_state = (struct pvrdma_ring *)&qp->sq.ring_state[1]; - pvrdma_init_qp_queue(qp); - - if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) || - pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE)) - goto err_free; - - memset(&cmd, 0, sizeof(cmd)); - cmd.udata.rbuf_addr = (uintptr_t)qp->rbuf.buf; - cmd.udata.rbuf_size = qp->rbuf.length; - cmd.udata.sbuf_addr = (uintptr_t)qp->sbuf.buf; - cmd.udata.sbuf_size = qp->sbuf.length; - cmd.udata.qp_addr = (uintptr_t) qp; - - ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, - &cmd.ibv_cmd, sizeof(cmd), - &resp, sizeof(resp)); - - if (ret) - goto err_free; - - to_vctx(pd->context)->qp_tbl[qp->ibv_qp.qp_num & 0xFFFF] = qp; - - /* If set, each WR submitted to the SQ generate a completion entry */ - if (attr->sq_sig_all) - qp->sq_signal_bits = htobe32(PVRDMA_WQE_CTRL_CQ_UPDATE); - else - qp->sq_signal_bits = 0; - - return &qp->ibv_qp; - -err_free: - if (qp->sq.wqe_cnt) - free(qp->sq.wrid); - if (qp->rq.wqe_cnt) - free(qp->rq.wrid); - pvrdma_free_buf(&qp->rbuf); - pvrdma_free_buf(&qp->sbuf); -err: - free(qp); - - return NULL; -} - -int pvrdma_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, - int attr_mask, - struct ibv_qp_init_attr *init_attr) -{ - struct ibv_query_qp cmd; - struct pvrdma_qp *qp = to_vqp(ibqp); - int ret; - - ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, - &cmd, sizeof(cmd)); - if (ret) - return ret; - - /* Passing back */ - init_attr->cap.max_send_wr = qp->sq.wqe_cnt; - init_attr->cap.max_send_sge = qp->sq.max_gs; - init_attr->cap.max_inline_data = qp->max_inline_data; - - attr->cap = init_attr->cap; - - return 0; -} - -int pvrdma_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, - int attr_mask) -{ - struct ibv_modify_qp cmd; - int ret; - - /* Sanity check */ - if (!attr_mask) - return 0; - - ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof(cmd)); - - if (!ret && - (attr_mask & IBV_QP_STATE) && - attr->qp_state == IBV_QPS_RESET) { - pvrdma_cq_clean(to_vcq(qp->recv_cq), qp->qp_num); - if (qp->send_cq != qp->recv_cq) - pvrdma_cq_clean(to_vcq(qp->send_cq), qp->qp_num); - pvrdma_init_qp_queue(to_vqp(qp)); - } - - return ret; -} - -static void pvrdma_lock_cqs(struct ibv_qp *qp) -{ - struct pvrdma_cq *send_cq = to_vcq(qp->send_cq); - struct pvrdma_cq *recv_cq = to_vcq(qp->recv_cq); - - if (send_cq == recv_cq) - pthread_spin_lock(&send_cq->lock); - else if (send_cq->cqn < recv_cq->cqn) { - pthread_spin_lock(&send_cq->lock); - pthread_spin_lock(&recv_cq->lock); - } else { - pthread_spin_lock(&recv_cq->lock); - pthread_spin_lock(&send_cq->lock); - } -} - -static void pvrdma_unlock_cqs(struct ibv_qp *qp) -{ - struct pvrdma_cq *send_cq = to_vcq(qp->send_cq); - struct pvrdma_cq *recv_cq = to_vcq(qp->recv_cq); - - if (send_cq == recv_cq) - pthread_spin_unlock(&send_cq->lock); - else if (send_cq->cqn < recv_cq->cqn) { - pthread_spin_unlock(&recv_cq->lock); - pthread_spin_unlock(&send_cq->lock); - } else { - pthread_spin_unlock(&send_cq->lock); - pthread_spin_unlock(&recv_cq->lock); - } -} - -int pvrdma_destroy_qp(struct ibv_qp *ibqp) -{ - struct pvrdma_context *ctx = to_vctx(ibqp->context); - struct pvrdma_qp *qp = to_vqp(ibqp); - int ret; - - ret = ibv_cmd_destroy_qp(ibqp); - if (ret) { - return ret; - } - - pvrdma_lock_cqs(ibqp); - /* Dump cqs */ - pvrdma_cq_clean_int(to_vcq(ibqp->recv_cq), ibqp->qp_num); - - if (ibqp->send_cq != ibqp->recv_cq) - pvrdma_cq_clean_int(to_vcq(ibqp->send_cq), ibqp->qp_num); - pvrdma_unlock_cqs(ibqp); - - free(qp->sq.wrid); - free(qp->rq.wrid); - pvrdma_free_buf(&qp->rbuf); - pvrdma_free_buf(&qp->sbuf); - ctx->qp_tbl[ibqp->qp_num & 0xFFFF] = NULL; - free(qp); - - return 0; -} - -static void *get_rq_wqe(struct pvrdma_qp *qp, int n) -{ - return qp->rbuf.buf + qp->rq.offset + (n * qp->rq.wqe_size); -} - -static void *get_sq_wqe(struct pvrdma_qp *qp, int n) -{ - return qp->sbuf.buf + qp->sq.offset + (n * qp->sq.wqe_size); -} - -int pvrdma_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, - struct ibv_send_wr **bad_wr) -{ - struct pvrdma_context *ctx = to_vctx(ibqp->context); - struct pvrdma_qp *qp = to_vqp(ibqp); - int ind; - int nreq = 0; - struct pvrdma_sq_wqe_hdr *wqe_hdr; - struct ibv_sge *sge; - int ret = 0; - int i; - - /* - * In states lower than RTS, we can fail immediately. In other states, - * just post and let the device figure it out. - */ - if (ibqp->state < IBV_QPS_RTS) { - *bad_wr = wr; - return EINVAL; - } - - pthread_spin_lock(&qp->sq.lock); - ind = pvrdma_idx(&(qp->sq.ring_state->prod_tail), qp->sq.wqe_cnt); - if (ind < 0) { - pthread_spin_unlock(&qp->sq.lock); - ret = EINVAL; - goto out; - } - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - unsigned int tail; - - if (pvrdma_idx_ring_has_space(qp->sq.ring_state, - qp->sq.wqe_cnt, &tail) <= 0) { - ret = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (wr->num_sge > qp->sq.max_gs) { - ret = EINVAL; - *bad_wr = wr; - goto out; - } - - wqe_hdr = (struct pvrdma_sq_wqe_hdr *)get_sq_wqe(qp, ind); - wqe_hdr->wr_id = wr->wr_id; - wqe_hdr->num_sge = wr->num_sge; - wqe_hdr->opcode = ibv_wr_opcode_to_pvrdma(wr->opcode); - wqe_hdr->send_flags = ibv_send_flags_to_pvrdma(wr->send_flags); - if (wr->opcode == IBV_WR_SEND_WITH_IMM || - wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM) - wqe_hdr->ex.imm_data = wr->imm_data; - - switch (ibqp->qp_type) { - case IBV_QPT_UD: - wqe_hdr->wr.ud.remote_qpn = wr->wr.ud.remote_qpn; - wqe_hdr->wr.ud.remote_qkey = wr->wr.ud.remote_qkey; - wqe_hdr->wr.ud.av = to_vah(wr->wr.ud.ah)->av; - break; - case IBV_QPT_RC: - switch (wr->opcode) { - case IBV_WR_RDMA_READ: - case IBV_WR_RDMA_WRITE: - case IBV_WR_RDMA_WRITE_WITH_IMM: - wqe_hdr->wr.rdma.remote_addr = - wr->wr.rdma.remote_addr; - wqe_hdr->wr.rdma.rkey = wr->wr.rdma.rkey; - break; - case IBV_WR_ATOMIC_CMP_AND_SWP: - case IBV_WR_ATOMIC_FETCH_AND_ADD: - wqe_hdr->wr.atomic.remote_addr = wr->wr.atomic.remote_addr; - wqe_hdr->wr.atomic.rkey = wr->wr.atomic.rkey; - wqe_hdr->wr.atomic.compare_add = wr->wr.atomic.compare_add; - if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) - wqe_hdr->wr.atomic.swap = wr->wr.atomic.swap; - break; - default: - /* No extra segments required for sends */ - break; - } - break; - default: - fprintf(stderr, PFX "invalid post send opcode\n"); - ret = EINVAL; - *bad_wr = wr; - goto out; - } - - /* Write each segment */ - sge = (struct ibv_sge *)&wqe_hdr[1]; - for (i = 0; i < wr->num_sge; i++) { - sge->addr = wr->sg_list[i].addr; - sge->length = wr->sg_list[i].length; - sge->lkey = wr->sg_list[i].lkey; - sge++; - } - - udma_to_device_barrier(); - pvrdma_idx_ring_inc(&(qp->sq.ring_state->prod_tail), - qp->sq.wqe_cnt); - - qp->sq.wrid[ind] = wr->wr_id; - ++ind; - if (ind >= qp->sq.wqe_cnt) - ind = 0; - } - -out: - if (nreq) { - udma_to_device_barrier(); - pvrdma_write_uar_qp(ctx->uar, - PVRDMA_UAR_QP_SEND | ibqp->qp_num); - } - - pthread_spin_unlock(&qp->sq.lock); - - return ret; -} - -int pvrdma_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, - struct ibv_recv_wr **bad_wr) -{ - struct pvrdma_context *ctx = to_vctx(ibqp->context); - struct pvrdma_qp *qp = to_vqp(ibqp); - struct pvrdma_rq_wqe_hdr *wqe_hdr; - struct ibv_sge *sge; - int nreq; - int ind; - int i; - int ret = 0; - - if (!wr || !bad_wr) - return EINVAL; - - /* - * In the RESET state, we can fail immediately. For other states, - * just post and let the device figure it out. - */ - if (ibqp->state == IBV_QPS_RESET) { - *bad_wr = wr; - return EINVAL; - } - - pthread_spin_lock(&qp->rq.lock); - - ind = pvrdma_idx(&(qp->rq.ring_state->prod_tail), qp->rq.wqe_cnt); - if (ind < 0) { - pthread_spin_unlock(&qp->rq.lock); - *bad_wr = wr; - return EINVAL; - } - - for (nreq = 0; wr; ++nreq, wr = wr->next) { - unsigned int tail; - - if (pvrdma_idx_ring_has_space(qp->rq.ring_state, - qp->rq.wqe_cnt, &tail) <= 0) { - ret = ENOMEM; - *bad_wr = wr; - goto out; - } - - if (wr->num_sge > qp->rq.max_gs) { - ret = EINVAL; - *bad_wr = wr; - goto out; - } - - /* Fetch wqe */ - wqe_hdr = (struct pvrdma_rq_wqe_hdr *)get_rq_wqe(qp, ind); - wqe_hdr->wr_id = wr->wr_id; - wqe_hdr->num_sge = wr->num_sge; - - sge = (struct ibv_sge *)(wqe_hdr + 1); - for (i = 0; i < wr->num_sge; ++i) { - sge->addr = (uint64_t)wr->sg_list[i].addr; - sge->length = wr->sg_list[i].length; - sge->lkey = wr->sg_list[i].lkey; - sge++; - } - - pvrdma_idx_ring_inc(&qp->rq.ring_state->prod_tail, - qp->rq.wqe_cnt); - - qp->rq.wrid[ind] = wr->wr_id; - ind = (ind + 1) & (qp->rq.wqe_cnt - 1); - } - -out: - if (nreq) - pvrdma_write_uar_qp(ctx->uar, - PVRDMA_UAR_QP_RECV | ibqp->qp_num); - - pthread_spin_unlock(&qp->rq.lock); - return ret; -} diff --git a/usr/rdma-core/providers/vmw_pvrdma/verbs.c b/usr/rdma-core/providers/vmw_pvrdma/verbs.c deleted file mode 100644 index a32046b5c..000000000 --- a/usr/rdma-core/providers/vmw_pvrdma/verbs.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. 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 version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program available in the file COPYING in the main - * directory of this source tree. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "pvrdma.h" - -int pvrdma_query_device(struct ibv_context *context, - struct ibv_device_attr *attr) -{ - struct ibv_query_device cmd; - uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; - int ret; - - ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, - &cmd, sizeof(cmd)); - if (ret) - return ret; - - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; - - snprintf(attr->fw_ver, sizeof(attr->fw_ver), - "%d.%d.%03d", major, minor, sub_minor); - - return 0; -} - -int pvrdma_query_port(struct ibv_context *context, uint8_t port, - struct ibv_port_attr *attr) -{ - struct ibv_query_port cmd; - - return ibv_cmd_query_port(context, port, attr, &cmd, sizeof(cmd)); -} - -struct ibv_pd *pvrdma_alloc_pd(struct ibv_context *context) -{ - struct ibv_alloc_pd cmd; - struct user_pvrdma_alloc_pd_resp resp; - struct pvrdma_pd *pd; - - pd = malloc(sizeof(*pd)); - if (!pd) - return NULL; - - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp))) { - free(pd); - return NULL; - } - - pd->pdn = resp.udata.pdn; - - return &pd->ibv_pd; -} - -int pvrdma_free_pd(struct ibv_pd *pd) -{ - int ret; - - ret = ibv_cmd_dealloc_pd(pd); - if (ret) - return ret; - - free(to_vpd(pd)); - - return 0; -} - -struct ibv_mr *pvrdma_reg_mr(struct ibv_pd *pd, void *addr, size_t length, - int access) -{ - struct ibv_mr *mr; - struct ibv_reg_mr cmd; - struct ibv_reg_mr_resp resp; - int ret; - - mr = malloc(sizeof(*mr)); - if (!mr) - return NULL; - - ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, - access, mr, &cmd, sizeof(cmd), - &resp, sizeof(resp)); - if (ret) { - free(mr); - return NULL; - } - - return mr; -} - -int pvrdma_dereg_mr(struct ibv_mr *mr) -{ - int ret; - - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; - - free(mr); - - return 0; -} - -static int is_multicast_gid(const union ibv_gid *gid) -{ - return gid->raw[0] == 0xff; -} - -static int is_link_local_gid(const union ibv_gid *gid) -{ - return gid->global.subnet_prefix == htobe64(0xfe80000000000000ULL); -} - -static int is_ipv6_addr_v4mapped(const struct in6_addr *a) -{ - return IN6_IS_ADDR_V4MAPPED(&a->s6_addr32) || - /* IPv4 encoded multicast addresses */ - (a->s6_addr32[0] == htobe32(0xff0e0000) && - ((a->s6_addr32[1] | - (a->s6_addr32[2] ^ htobe32(0x0000ffff))) == 0UL)); -} - -static int set_mac_from_gid(const union ibv_gid *gid, - __u8 mac[6]) -{ - if (is_link_local_gid(gid)) { - /* - * The MAC is embedded in GID[8-10,13-15] with the - * 7th most significant bit inverted. - */ - memcpy(mac, gid->raw + 8, 3); - memcpy(mac + 3, gid->raw + 13, 3); - mac[0] ^= 2; - - return 0; - } - - return 1; -} - -struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, - struct ibv_ah_attr *attr) -{ - struct pvrdma_ah *ah; - struct pvrdma_av *av; - struct ibv_port_attr port_attr; - uint16_t vlan_id; - - if (!attr->is_global) - return NULL; - - if (ibv_query_port(pd->context, attr->port_num, &port_attr)) - return NULL; - - if (port_attr.link_layer == IBV_LINK_LAYER_UNSPECIFIED || - port_attr.link_layer == IBV_LINK_LAYER_INFINIBAND) - return NULL; - - if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET && - (!is_link_local_gid(&attr->grh.dgid) && - !is_multicast_gid(&attr->grh.dgid) && - !is_ipv6_addr_v4mapped((struct in6_addr *)attr->grh.dgid.raw))) - return NULL; - - ah = calloc(1, sizeof(*ah)); - if (!ah) - return NULL; - - av = &ah->av; - av->port_pd = to_vpd(pd)->pdn | (attr->port_num << 24); - av->src_path_bits = attr->src_path_bits; - av->src_path_bits |= 0x80; - av->gid_index = attr->grh.sgid_index; - av->hop_limit = attr->grh.hop_limit; - av->sl_tclass_flowlabel = (attr->grh.traffic_class << 20) | - attr->grh.flow_label; - memcpy(av->dgid, attr->grh.dgid.raw, 16); - - if (port_attr.port_cap_flags & IBV_PORT_IP_BASED_GIDS) { - if (!ibv_resolve_eth_l2_from_gid(pd->context, attr, - av->dmac, &vlan_id)) - return &ah->ibv_ah; - } else { - if (!set_mac_from_gid(&attr->grh.dgid, av->dmac)) - return &ah->ibv_ah; - } - - free(ah); - return NULL; -} - -int pvrdma_destroy_ah(struct ibv_ah *ah) -{ - free(to_vah(ah)); - - return 0; -} diff --git a/usr/rdma-core/rdma-ndd/CMakeLists.txt b/usr/rdma-core/rdma-ndd/CMakeLists.txt deleted file mode 100644 index e8419a6c9..000000000 --- a/usr/rdma-core/rdma-ndd/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# COPYRIGHT (c) 2016 Intel Corporation. -# Licensed under BSD (MIT variant) or GPLv2. See COPYING. - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - -rdma_sbin_executable(rdma-ndd - rdma-ndd.c - ) - -target_link_libraries(rdma-ndd LINK_PRIVATE - ${SYSTEMD_LIBRARIES} - ${UDEV_LIBRARIES} - ) - -# FIXME Autogenerate from the .rst -rdma_man_pages( - rdma-ndd.8.in - ) - -install(FILES "rdma-ndd.rules" - RENAME "60-rdma-ndd.rules" - DESTINATION "${CMAKE_INSTALL_UDEV_RULESDIR}") - -rdma_subst_install(FILES "rdma-ndd.service.in" - DESTINATION "${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}" - RENAME "rdma-ndd.service") - diff --git a/usr/rdma-core/rdma-ndd/rdma-ndd.8.in b/usr/rdma-core/rdma-ndd/rdma-ndd.8.in deleted file mode 100644 index d6c75d325..000000000 --- a/usr/rdma-core/rdma-ndd/rdma-ndd.8.in +++ /dev/null @@ -1,91 +0,0 @@ -.\" Man page generated from reStructuredText. -. -.TH RDMA-NDD 8 "@BUILD_DATE@" "" "OpenIB Diagnostics" -.SH NAME -RDMA-NDD \- RDMA device Node Description update daemon -. -.nr rst2man-indent-level 0 -. -.de1 rstReportMargin -\\$1 \\n[an-margin] -level \\n[rst2man-indent-level] -level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] -- -\\n[rst2man-indent0] -\\n[rst2man-indent1] -\\n[rst2man-indent2] -.. -.de1 INDENT -.\" .rstReportMargin pre: -. RS \\$1 -. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] -. nr rst2man-indent-level +1 -.\" .rstReportMargin post: -.. -.de UNINDENT -. RE -.\" indent \\n[an-margin] -.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] -.nr rst2man-indent-level -1 -.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] -.in \\n[rst2man-indent\\n[rst2man-indent-level]]u -.. -.SH SYNOPSIS -.sp -rdma\-ndd -.SH DESCRIPTION -.sp -rdma\-ndd is a system daemon which watches for rdma device changes and/or -hostname changes and updates the Node Description of the rdma devices based on -those changes. -.SH DETAILS -.sp -Full operation of this daemon requires kernels which support polling of the -procfs hostname file as well as libudev. -.sp -If your system does not support either of these features, the daemon will set -the Node Descriptions at start up and then sleep forever. -.SS Node Description configuration -.sp -The daemon uses the environment variable RDMA_NDD_ND_FORMAT to set the node -description. The following wild cards can be specified for more dynamic -control. -.sp -%h \-\- replace with the current hostname (not including domain) -.sp -%d \-\- replace with the device name (for example mlx4_0, qib0, etc.) -.sp -If not specified the default is "%h %d". -.sp -NOTE: At startup, and on new device detection, the Node Description is always -written to ensure the SM and rdma\-ndd are in sync. Subsequent events will only -write the Node Description on a device if it has changed. -.SS Using systemd -.sp -Setting the environment variable for the daemon is normally be done via a -systemd drop in unit. For example the following could be added to a file named -/etc/systemd/system/rdma\-ndd.service.d/nd\-format.conf to use only the -hostname as your node description. -.sp -[Service] -Environment="RDMA_NDD_ND_FORMAT=%%h" -.sp -NOTE: Systemd requires an extra \(aq%\(aq. -.SH OPTIONS -.sp -\fB\-f, \-\-foreground\fP -Run in the foreground instead of as a daemon -.sp -\fB\-d, \-\-debugging\fP -Log additional debugging information to syslog -.sp -\fB\-\-systemd\fP -Enable systemd integration. -.SH AUTHOR -.INDENT 0.0 -.TP -.B Ira Weiny -< \fI\%ira.weiny@intel.com\fP > -.UNINDENT -.\" Generated by docutils manpage writer. -. diff --git a/usr/rdma-core/rdma-ndd/rdma-ndd.8.in.rst b/usr/rdma-core/rdma-ndd/rdma-ndd.8.in.rst deleted file mode 100644 index 767f388e9..000000000 --- a/usr/rdma-core/rdma-ndd/rdma-ndd.8.in.rst +++ /dev/null @@ -1,85 +0,0 @@ -======== -RDMA-NDD -======== - ------------------------------------------- -RDMA device Node Description update daemon ------------------------------------------- - -:Date: @BUILD_DATE@ -:Manual section: 8 -:Manual group: OpenIB Diagnostics - - -SYNOPSIS -======== - -rdma-ndd - -DESCRIPTION -=========== - -rdma-ndd is a system daemon which watches for rdma device changes and/or -hostname changes and updates the Node Description of the rdma devices based on -those changes. - - -DETAILS -======= - -Full operation of this daemon requires kernels which support polling of the -procfs hostname file as well as libudev. - -If your system does not support either of these features, the daemon will set -the Node Descriptions at start up and then sleep forever. - - -Node Description configuration ------------------------------- - -The daemon uses the environment variable RDMA_NDD_ND_FORMAT to set the node -description. The following wild cards can be specified for more dynamic -control. - -%h -- replace with the current hostname (not including domain) - -%d -- replace with the device name (for example mlx4_0, qib0, etc.) - -If not specified the default is "%h %d". - -NOTE: At startup, and on new device detection, the Node Description is always -written to ensure the SM and rdma-ndd are in sync. Subsequent events will only -write the Node Description on a device if it has changed. - -Using systemd -------------- - -Setting the environment variable for the daemon is normally be done via a -systemd drop in unit. For example the following could be added to a file named -/etc/systemd/system/rdma-ndd.service.d/nd-format.conf to use only the -hostname as your node description. - -[Service] -Environment="RDMA_NDD_ND_FORMAT=%%h" - -NOTE: Systemd requires an extra '%'. - - -OPTIONS -======= - -**-f, --foreground** -Run in the foreground instead of as a daemon - -**-d, --debugging** -Log additional debugging information to syslog - -**--systemd** -Enable systemd integration. - - -AUTHOR -====== - -Ira Weiny - < ira.weiny@intel.com > diff --git a/usr/rdma-core/rdma-ndd/rdma-ndd.c b/usr/rdma-core/rdma-ndd/rdma-ndd.c deleted file mode 100644 index 418d1de94..000000000 --- a/usr/rdma-core/rdma-ndd/rdma-ndd.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright (c) 2014,2016 Intel Corporation. All Rights Reserved - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -static struct udev *g_udev; -static struct udev_monitor *g_mon; - -#define SYS_HOSTNAME "/proc/sys/kernel/hostname" -#define SYS_INFINIBAND "/sys/class/infiniband" -#define DEFAULT_ND_FORMAT "%h %d" - -static char *g_nd_format = NULL; -static bool debugging; - -static void newline_to_null(char *str) -{ - char *term = index(str, '\n'); - if (term) - *term = '\0'; -} - -static void strip_domain(char *str) -{ - char *term = index(str, '.'); - if (term) - *term = '\0'; -} - -static __attribute__((format(printf, 1, 2))) void dbg_log(const char *fmt, ...) -{ - va_list ap; - - if (!debugging) - return; - - va_start(ap, fmt); - vsyslog(LOG_DEBUG, fmt, ap); - va_end(ap); -} - -static void build_node_desc(char *dest, size_t len, - const char *device, const char *hostname) -{ - char *end = dest + len-1; - const char *field; - char *src = g_nd_format; - - while (*src && (dest < end)) { - if (*src != '%') { - *dest++ = *src++; - } else { - src++; - switch (*src) { - case 'h': - field = hostname; - while (*field && (*field != '.') && (dest < end)) - *dest++ = *field++; - break; - case 'd': - field = device; - while (*field && (dest < end)) - *dest++ = *field++; - break; - } - src++; - } - } - *dest = 0; -} - -static int update_node_desc(const char *device, const char *hostname, int force) -{ - int rc; - char nd[128]; - char new_nd[64]; - char nd_file[PATH_MAX]; - FILE *f; - - snprintf(nd_file, sizeof(nd_file), SYS_INFINIBAND "/%s/node_desc", - device); - nd_file[sizeof(nd_file)-1] = '\0'; - - f = fopen(nd_file, "r+"); - if (!f) { - syslog(LOG_ERR, "Failed to open %s\n", nd_file); - return -EIO; - } - - if (!fgets(nd, sizeof(nd), f)) { - syslog(LOG_ERR, "Failed to read %s\n", nd_file); - rc = -EIO; - goto error; - } - newline_to_null(nd); - - build_node_desc(new_nd, sizeof(new_nd), device, hostname); - - if (!force && strncmp(new_nd, nd, sizeof(new_nd)) == 0) { - dbg_log("%s: no change (%s)\n", device, new_nd); - } else { - dbg_log("%s: change (%s) -> (%s)\n", device, nd, new_nd); - rewind(f); - fprintf(f, "%s", new_nd); - } - - rc = 0; -error: - fclose(f); - return rc; -} - -static void set_rdma_node_desc(const char *hostname, int force) -{ - DIR *class_dir; - struct dirent *dent; - - class_dir = opendir(SYS_INFINIBAND); - if (!class_dir) { - syslog(LOG_ERR, "Failed to open " SYS_INFINIBAND); - return; - } - - while ((dent = readdir(class_dir))) { - if (dent->d_name[0] == '.') - continue; - - if (update_node_desc(dent->d_name, hostname, force)) - syslog(LOG_ERR, "set Node Description failed on %s\n", - dent->d_name); - } - - closedir(class_dir); -} - -static void read_hostname(int fd, char *name, size_t len) -{ - memset(name, 0, len); - if (read(fd, name, len-1) >= 0) { - newline_to_null(name); - strip_domain(name); - } else { - syslog(LOG_ERR, "Read %s Failed\n", SYS_HOSTNAME); - } - lseek(fd, 0, SEEK_SET); -} - -static void setup_udev(void) -{ - g_udev = udev_new(); - if (!g_udev) { - syslog(LOG_ERR, "udev_new failed\n"); - return; - } -} - -static int get_udev_fd(void) -{ - g_mon = udev_monitor_new_from_netlink(g_udev, "udev"); - if (!g_mon) { - syslog(LOG_ERR, "udev monitoring failed\n"); - return -1; - } - - udev_monitor_filter_add_match_subsystem_devtype(g_mon, "infiniband", NULL); - udev_monitor_enable_receiving(g_mon); - return udev_monitor_get_fd(g_mon); -} - -static void process_udev_event(int ud_fd, const char *hostname) -{ - struct udev_device *dev; - - dev = udev_monitor_receive_device(g_mon); - if (dev) { - const char *device = udev_device_get_sysname(dev); - const char *action = udev_device_get_action(dev); - - dbg_log("Device event: %s, %s, %s\n", - udev_device_get_subsystem(dev), device, action); - - if (device && action - && strncmp(action, "add", sizeof("add")) == 0) - if (update_node_desc(device, hostname, 1)) - syslog(LOG_ERR, "set Node Description failed on %s\n", - device); - - udev_device_unref(dev); - } -} - -static void monitor(bool systemd) -{ - char hostname[128]; - int hn_fd; - struct pollfd fds[2]; - int numfds = 1; - int ud_fd; - - hn_fd = open(SYS_HOSTNAME, O_RDONLY); - if (hn_fd < 0) { - syslog(LOG_ERR, "Open %s Failed exiting\n", - SYS_HOSTNAME); - exit(EXIT_FAILURE); - } - - read_hostname(hn_fd, hostname, sizeof(hostname)); - set_rdma_node_desc((const char *)hostname, 1); - - fds[0].fd = hn_fd; - fds[0].events = 0; - - ud_fd = get_udev_fd(); - if (ud_fd >= 0) - numfds = 2; - - fds[1].fd = ud_fd; - fds[1].events = POLLIN; - - if (systemd) - sd_notify(0, "READY=1"); - - while (1) { - if (poll(fds, numfds, -1) <= 0) { - syslog(LOG_ERR, "Poll %s failed; exiting\n", SYS_HOSTNAME); - exit(EXIT_FAILURE); - } - - if (fds[0].revents != 0) { - read_hostname(hn_fd, hostname, sizeof(hostname)); - dbg_log("Hostname event: %s\n", hostname); - set_rdma_node_desc((const char *)hostname, 0); - } - - if (fds[1].revents != 0) - process_udev_event(ud_fd, hostname); - } -} - -int main(int argc, char *argv[]) -{ - bool foreground = false; - bool systemd = false; - - openlog(NULL, LOG_NDELAY | LOG_CONS | LOG_PID, LOG_DAEMON); - - while (1) { - static const struct option long_opts[] = { - { "foreground", 0, NULL, 'f' }, - { "systemd", 0, NULL, 's' }, - { "help", 0, NULL, 'h' }, - { "debug", 0, NULL, 'd' }, - { } - }; - - int c = getopt_long(argc, argv, "fh", long_opts, NULL); - if (c == -1) - break; - - switch (c) { - case 'f': - foreground = true; - break; - case 's': - systemd = true; - break; - case 'd': - debugging = true; - break; - case 'h': - printf("rdma-ndd [options]\n"); - printf(" See 'man rdma-ndd' for details\n"); - return 0; - default: - break; - - } - } - - if (!foreground && !systemd) { - if (daemon(0, 0) != 0) { - syslog(LOG_ERR, "Failed to daemonize\n"); - return EXIT_FAILURE; - } - } - - setup_udev(); - - g_nd_format = getenv("RDMA_NDD_ND_FORMAT"); - if (g_nd_format && strncmp("", g_nd_format, strlen(g_nd_format)) != 0) - g_nd_format = strdup(g_nd_format); - else - g_nd_format = strdup(DEFAULT_ND_FORMAT); - - dbg_log("Node Descriptor format (%s)\n", g_nd_format); - - monitor(systemd); - - return 0; -} diff --git a/usr/rdma-core/rdma-ndd/rdma-ndd.rules b/usr/rdma-core/rdma-ndd/rdma-ndd.rules deleted file mode 100644 index ef7768e06..000000000 --- a/usr/rdma-core/rdma-ndd/rdma-ndd.rules +++ /dev/null @@ -1,3 +0,0 @@ -# If an InfiniBand/RDMA device is installed with a writable node_description -# sysfs then start rdma-ndd to keep it up to date -SUBSYSTEM=="infiniband", TAG+="systemd", ATTRS{node_desc}=="*", ENV{SYSTEMD_WANTS}+="rdma-ndd.service" diff --git a/usr/rdma-core/rdma-ndd/rdma-ndd.service.in b/usr/rdma-core/rdma-ndd/rdma-ndd.service.in deleted file mode 100644 index a63399a5f..000000000 --- a/usr/rdma-core/rdma-ndd/rdma-ndd.service.in +++ /dev/null @@ -1,24 +0,0 @@ -[Unit] -Description=RDMA Node Description Daemon -Documentation=man:rdma-ndd -StopWhenUnneeded=yes -# rdma-ndd is a kernel support program and needs to run as early as possible, -# before the network link is brought up, and before an external manager tries -# to read the local node description. -DefaultDependencies=no -Before=sysinit.target -# Do not execute concurrently with an ongoing shutdown (required for DefaultDependencies=no) -Conflicts=shutdown.target -Before=shutdown.target -# Networking, particularly link up, should not happen until ndd is ready -Wants=network-pre.target -Before=network-pre.target -# rdma-hw is not ready until ndd is running -Before=rdma-hw.target - -[Service] -Type=notify -Restart=always -ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/rdma-ndd --systemd - -# rdma-ndd is automatically wanted by udev when an RDMA device with a node description is present diff --git a/usr/rdma-core/redhat/rdma-core.spec b/usr/rdma-core/redhat/rdma-core.spec deleted file mode 100644 index 48b7d30ac..000000000 --- a/usr/rdma-core/redhat/rdma-core.spec +++ /dev/null @@ -1,467 +0,0 @@ -Name: rdma-core -Version: 16 -Release: 1%{?dist} -Summary: RDMA core userspace libraries and daemons - -# Almost everything is licensed under the OFA dual GPLv2, 2 Clause BSD license -# providers/ipathverbs/ Dual licensed using a BSD license with an extra patent clause -# providers/rxe/ Incorporates code from ipathverbs and contains the patent clause -# providers/hfi1verbs Uses the 3 Clause BSD license -License: GPLv2 or BSD -Url: https://github.com/linux-rdma/rdma-core -Source: rdma-core-%{version}.tgz - -BuildRequires: binutils -BuildRequires: cmake >= 2.8.11 -BuildRequires: gcc -BuildRequires: libudev-devel -BuildRequires: pkgconfig -BuildRequires: pkgconfig(libnl-3.0) -BuildRequires: pkgconfig(libnl-route-3.0) -BuildRequires: valgrind-devel -BuildRequires: systemd -BuildRequires: systemd-devel -BuildRequires: python - -Requires: dracut, kmod, systemd -# Red Hat/Fedora previously shipped redhat/ as a stand-alone -# package called 'rdma', which we're supplanting here. -Provides: rdma = %{version}-%{release} -Obsoletes: rdma < %{version}-%{release} -Conflicts: infiniband-diags <= 1.6.7 - -# Since we recommend developers use Ninja, so should packagers, for consistency. -%define CMAKE_FLAGS %{nil} -%if 0%{?fedora} >= 23 -# Ninja was introduced in FC23 -BuildRequires: ninja-build -%define CMAKE_FLAGS -GNinja -%define make_jobs ninja-build -v %{?_smp_mflags} -%define cmake_install DESTDIR=%{buildroot} ninja-build install -%else -# Fallback to make otherwise -BuildRequires: make -%define make_jobs make -v %{?_smp_mflags} -%define cmake_install DESTDIR=%{buildroot} make install -%endif - -%description -RDMA core userspace infrastructure and documentation, including initialization -scripts, kernel driver-specific modprobe override configs, IPoIB network -scripts, dracut rules, and the rdma-ndd utility. - -%package devel -Summary: RDMA core development libraries and headers -Requires: %{name}%{?_isa} = %{version}-%{release} -Requires: libibverbs = %{version}-%{release} -Provides: libibverbs-devel = %{version}-%{release} -Obsoletes: libibverbs-devel < %{version}-%{release} -Requires: libibcm = %{version}-%{release} -Provides: libibcm-devel = %{version}-%{release} -Obsoletes: libibcm-devel < %{version}-%{release} -Requires: libibumad = %{version}-%{release} -Provides: libibumad-devel = %{version}-%{release} -Obsoletes: libibumad-devel < %{version}-%{release} -Requires: librdmacm = %{version}-%{release} -Provides: librdmacm-devel = %{version}-%{release} -Obsoletes: librdmacm-devel < %{version}-%{release} -Requires: ibacm = %{version}-%{release} -Provides: ibacm-devel = %{version}-%{release} -Obsoletes: ibacm-devel < %{version}-%{release} - -%description devel -RDMA core development libraries and headers. - -%package -n libibverbs -Summary: A library and drivers for direct userspace use of RDMA (InfiniBand/iWARP/RoCE) hardware -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig -Requires: %{name}%{?_isa} = %{version}-%{release} -Provides: libcxgb3 = %{version}-%{release} -Obsoletes: libcxgb3 < %{version}-%{release} -Provides: libcxgb4 = %{version}-%{release} -Obsoletes: libcxgb4 < %{version}-%{release} -Provides: libhfi1 = %{version}-%{release} -Obsoletes: libhfi1 < %{version}-%{release} -Provides: libi40iw = %{version}-%{release} -Obsoletes: libi40iw < %{version}-%{release} -Provides: libipathverbs = %{version}-%{release} -Obsoletes: libipathverbs < %{version}-%{release} -Provides: libmlx4 = %{version}-%{release} -Obsoletes: libmlx4 < %{version}-%{release} -Provides: libmlx5 = %{version}-%{release} -Obsoletes: libmlx5 < %{version}-%{release} -Provides: libmthca = %{version}-%{release} -Obsoletes: libmthca < %{version}-%{release} -Provides: libnes = %{version}-%{release} -Obsoletes: libnes < %{version}-%{release} -Provides: libocrdma = %{version}-%{release} -Obsoletes: libocrdma < %{version}-%{release} -Provides: librxe = %{version}-%{release} -Obsoletes: librxe < %{version}-%{release} - -%description -n libibverbs -libibverbs is a library that allows userspace processes to use RDMA -"verbs" as described in the InfiniBand Architecture Specification and -the RDMA Protocol Verbs Specification. This includes direct hardware -access from userspace to InfiniBand/iWARP adapters (kernel bypass) for -fast path operations. - -Device-specific plug-in ibverbs userspace drivers are included: - -- libcxgb3: Chelsio T3 iWARP HCA -- libcxgb4: Chelsio T4 iWARP HCA -- libhfi1: Intel Omni-Path HFI -- libhns: HiSilicon Hip06 SoC -- libi40iw: Intel Ethernet Connection X722 RDMA -- libipathverbs: QLogic InfiniPath HCA -- libmlx4: Mellanox ConnectX-3 InfiniBand HCA -- libmlx5: Mellanox Connect-IB/X-4+ InfiniBand HCA -- libmthca: Mellanox InfiniBand HCA -- libnes: NetEffect RNIC -- libocrdma: Emulex OneConnect RDMA/RoCE Device -- libqedr: QLogic QL4xxx RoCE HCA -- librxe: A software implementation of the RoCE protocol -- libvmw_pvrdma: VMware paravirtual RDMA device - -%package -n libibverbs-utils -Summary: Examples for the libibverbs library -Requires: libibverbs%{?_isa} = %{version}-%{release} - -%description -n libibverbs-utils -Useful libibverbs example programs such as ibv_devinfo, which -displays information about RDMA devices. - -%package -n ibacm -Summary: InfiniBand Communication Manager Assistant -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units -Requires: %{name}%{?_isa} = %{version}-%{release} - -%description -n ibacm -The ibacm daemon helps reduce the load of managing path record lookups on -large InfiniBand fabrics by providing a user space implementation of what -is functionally similar to an ARP cache. The use of ibacm, when properly -configured, can reduce the SA packet load of a large IB cluster from O(n^2) -to O(n). The ibacm daemon is started and normally runs in the background, -user applications need not know about this daemon as long as their app -uses librdmacm to handle connection bring up/tear down. The librdmacm -library knows how to talk directly to the ibacm daemon to retrieve data. - -%package -n iwpmd -Summary: iWarp Port Mapper userspace daemon -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units -Requires: %{name}%{?_isa} = %{version}-%{release} - -%description -n iwpmd -iwpmd provides a userspace service for iWarp drivers to claim -tcp ports through the standard socket interface. - -%package -n libibcm -Summary: Userspace InfiniBand Connection Manager -ExcludeArch: s390 s390x -Requires: %{name}%{?_isa} = %{version}-%{release} - -%description -n libibcm -libibcm provides a userspace library that handles the majority of the low -level work required to open an RDMA connection between two machines. - -%package -n libibumad -Summary: OpenFabrics Alliance InfiniBand umad (userspace management datagram) library -Requires: %{name}%{?_isa} = %{version}-%{release} - -%description -n libibumad -libibumad provides the userspace management datagram (umad) library -functions, which sit on top of the umad modules in the kernel. These -are used by the IB diagnostic and management tools, including OpenSM. - -%package -n librdmacm -Summary: Userspace RDMA Connection Manager -Requires: %{name}%{?_isa} = %{version}-%{release} - -%description -n librdmacm -librdmacm provides a userspace RDMA Communication Management API. - -%package -n librdmacm-utils -Summary: Examples for the librdmacm library -Requires: librdmacm%{?_isa} = %{version}-%{release} - -%description -n librdmacm-utils -Example test programs for the librdmacm library. - -%package -n srp_daemon -Summary: Tools for using the InfiniBand SRP protocol devices -Obsoletes: srptools <= 1.0.3 -Provides: srptools = %{version}-%{release} -Obsoletes: openib-srptools <= 0.0.6 -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units -Requires: %{name}%{?_isa} = %{version}-%{release} - -%description -n srp_daemon -In conjunction with the kernel ib_srp driver, srp_daemon allows you to -discover and use SCSI devices via the SCSI RDMA Protocol over InfiniBand. - -%prep -%setup - -%build - -# New RPM defines _rundir, usually as /run -%if 0%{?_rundir:1} -%else -%define _rundir /var/run -%endif - -# Pass all of the rpm paths directly to GNUInstallDirs and our other defines. -%cmake %{CMAKE_FLAGS} \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_BINDIR:PATH=%{_bindir} \ - -DCMAKE_INSTALL_SBINDIR:PATH=%{_sbindir} \ - -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=%{_libexecdir} \ - -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=%{_localstatedir} \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=%{_sharedstatedir} \ - -DCMAKE_INSTALL_INCLUDEDIR:PATH=%{_includedir} \ - -DCMAKE_INSTALL_INFODIR:PATH=%{_infodir} \ - -DCMAKE_INSTALL_MANDIR:PATH=%{_mandir} \ - -DCMAKE_INSTALL_SYSCONFDIR:PATH=%{_sysconfdir} \ - -DCMAKE_INSTALL_SYSTEMD_SERVICEDIR:PATH=%{_unitdir} \ - -DCMAKE_INSTALL_INITDDIR:PATH=%{_initrddir} \ - -DCMAKE_INSTALL_RUNDIR:PATH=%{_rundir} \ - -DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{name}-%{version} \ - -DCMAKE_INSTALL_UDEV_RULESDIR:PATH=%{_udevrulesdir} -%make_jobs - -%install -%cmake_install - -mkdir -p %{buildroot}/%{_sysconfdir}/rdma - -# Red Hat specific glue -%global dracutlibdir %{_prefix}/lib/dracut -%global sysmodprobedir %{_prefix}/lib/modprobe.d -mkdir -p %{buildroot}/%{_sysconfdir}/sysconfig/network-scripts -mkdir -p %{buildroot}%{_sysconfdir}/udev/rules.d -mkdir -p %{buildroot}%{_libexecdir} -mkdir -p %{buildroot}%{_udevrulesdir} -mkdir -p %{buildroot}%{dracutlibdir}/modules.d/05rdma -mkdir -p %{buildroot}%{sysmodprobedir} -install -D -m0644 redhat/rdma.conf %{buildroot}/%{_sysconfdir}/rdma/rdma.conf -install -D -m0644 redhat/rdma.sriov-vfs %{buildroot}/%{_sysconfdir}/rdma/sriov-vfs -install -D -m0644 redhat/rdma.mlx4.conf %{buildroot}/%{_sysconfdir}/rdma/mlx4.conf -install -D -m0755 redhat/rdma.ifup-ib %{buildroot}/%{_sysconfdir}/sysconfig/network-scripts/ifup-ib -install -D -m0755 redhat/rdma.ifdown-ib %{buildroot}/%{_sysconfdir}/sysconfig/network-scripts/ifdown-ib -install -D -m0644 redhat/rdma.service %{buildroot}%{_unitdir}/rdma.service -install -D -m0755 redhat/rdma.modules-setup.sh %{buildroot}%{dracutlibdir}/modules.d/05rdma/module-setup.sh -install -D -m0644 redhat/rdma.udev-rules %{buildroot}%{_udevrulesdir}/98-rdma.rules -install -D -m0644 redhat/rdma.mlx4.sys.modprobe %{buildroot}%{sysmodprobedir}/libmlx4.conf -install -D -m0755 redhat/rdma.kernel-init %{buildroot}%{_libexecdir}/rdma-init-kernel -install -D -m0755 redhat/rdma.sriov-init %{buildroot}%{_libexecdir}/rdma-set-sriov-vf -install -D -m0755 redhat/rdma.mlx4-setup.sh %{buildroot}%{_libexecdir}/mlx4-setup.sh - -# ibacm -bin/ib_acme -D . -O -install -D -m0644 ibacm_opts.cfg %{buildroot}%{_sysconfdir}/rdma/ - -# Delete the package's init.d scripts -rm -rf %{buildroot}/%{_initrddir}/ -rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh - -# libibverbs -%post -n libibverbs -p /sbin/ldconfig -%postun -n libibverbs -p /sbin/ldconfig - -# libibcm -%post -n libibcm -p /sbin/ldconfig -%postun -n libibcm -p /sbin/ldconfig - -# libibumad -%post -n libibumad -p /sbin/ldconfig -%postun -n libibumad -p /sbin/ldconfig - -# librdmacm -%post -n librdmacm -p /sbin/ldconfig -%postun -n librdmacm -p /sbin/ldconfig - -# ibacm -%post -n ibacm -%systemd_post ibacm.service -%preun -n ibacm -%systemd_preun ibacm.service -%postun -n ibacm -%systemd_postun_with_restart ibacm.service - -# srp_daemon -%post -n srp_daemon -%systemd_post srp_daemon.service -%preun -n srp_daemon -%systemd_preun srp_daemon.service -%postun -n srp_daemon -%systemd_postun_with_restart srp_daemon.service - -# iwpmd -%post -n iwpmd -%systemd_post iwpmd.service -%preun -n iwpmd -%systemd_preun iwpmd.service -%postun -n iwpmd -%systemd_postun_with_restart iwpmd.service - -%files -%dir %{_sysconfdir}/rdma -%dir %{_docdir}/%{name}-%{version} -%doc %{_docdir}/%{name}-%{version}/README.md -%doc %{_docdir}/%{name}-%{version}/rxe.md -%doc %{_docdir}/%{name}-%{version}/udev.md -%config(noreplace) %{_sysconfdir}/rdma/mlx4.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/infiniband.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/iwarp.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/opa.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/rdma.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/roce.conf -%config(noreplace) %{_sysconfdir}/rdma/rdma.conf -%config(noreplace) %{_sysconfdir}/rdma/sriov-vfs -%config(noreplace) %{_sysconfdir}/udev/rules.d/* -%config(noreplace) %{_sysconfdir}/modprobe.d/mlx4.conf -%config(noreplace) %{_sysconfdir}/modprobe.d/truescale.conf -%{_sysconfdir}/sysconfig/network-scripts/* -%{_unitdir}/rdma-hw.target -%{_unitdir}/rdma-load-modules@.service -%{_unitdir}/rdma.service -%dir %{dracutlibdir}/modules.d/05rdma -%{dracutlibdir}/modules.d/05rdma/module-setup.sh -%{_udevrulesdir}/60-rdma-ndd.rules -%{_udevrulesdir}/75-rdma-description.rules -%{_udevrulesdir}/90-rdma-hw-modules.rules -%{_udevrulesdir}/90-rdma-ulp-modules.rules -%{_udevrulesdir}/90-rdma-umad.rules -%{_udevrulesdir}/98-rdma.rules -%{sysmodprobedir}/libmlx4.conf -%{_libexecdir}/rdma-init-kernel -%{_libexecdir}/rdma-set-sriov-vf -%{_libexecdir}/mlx4-setup.sh -%{_libexecdir}/truescale-serdes.cmds -%{_bindir}/rxe_cfg -%{_sbindir}/rdma-ndd -%{_unitdir}/rdma-ndd.service -%{_mandir}/man7/rxe* -%{_mandir}/man8/rdma-ndd.* -%{_mandir}/man8/rxe* -%license COPYING.* - -%files devel -%doc %{_docdir}/%{name}-%{version}/MAINTAINERS -%dir %{_includedir}/infiniband -%dir %{_includedir}/rdma -%{_includedir}/infiniband/* -%{_includedir}/rdma/* -%{_libdir}/lib*.so -%{_mandir}/man3/ibv_* -%{_mandir}/man3/rdma* -%{_mandir}/man3/umad* -%{_mandir}/man3/*_to_ibv_rate.* -%{_mandir}/man7/rdma_cm.* -%{_mandir}/man3/mlx5dv* -%{_mandir}/man3/mlx4dv* -%{_mandir}/man7/mlx5dv* -%{_mandir}/man7/mlx4dv* - -%files -n libibverbs -%dir %{_sysconfdir}/libibverbs.d -%dir %{_libdir}/libibverbs -%{_libdir}/libibverbs*.so.* -%{_libdir}/libibverbs/*.so -%{_libdir}/libmlx5.so.* -%{_libdir}/libmlx4.so.* -%config(noreplace) %{_sysconfdir}/libibverbs.d/*.driver -%doc %{_docdir}/%{name}-%{version}/libibverbs.md - -%files -n libibverbs-utils -%{_bindir}/ibv_* -%{_mandir}/man1/ibv_* - -%files -n ibacm -%config(noreplace) %{_sysconfdir}/rdma/ibacm_opts.cfg -%{_bindir}/ib_acme -%{_sbindir}/ibacm -%{_mandir}/man1/ibacm.* -%{_mandir}/man1/ib_acme.* -%{_mandir}/man7/ibacm.* -%{_mandir}/man7/ibacm_prov.* -%{_unitdir}/ibacm.service -%{_unitdir}/ibacm.socket -%dir %{_libdir}/ibacm -%{_libdir}/ibacm/* -%doc %{_docdir}/%{name}-%{version}/ibacm.md - -%files -n iwpmd -%{_sbindir}/iwpmd -%{_unitdir}/iwpmd.service -%config(noreplace) %{_sysconfdir}/rdma/modules/iwpmd.conf -%config(noreplace) %{_sysconfdir}/iwpmd.conf -%{_udevrulesdir}/90-iwpmd.rules -%{_mandir}/man8/iwpmd.* -%{_mandir}/man5/iwpmd.* - -%files -n libibcm -%{_libdir}/libibcm*.so.* -%doc %{_docdir}/%{name}-%{version}/libibcm.md - -%files -n libibumad -%{_libdir}/libibumad*.so.* - -%files -n librdmacm -%{_libdir}/librdmacm*.so.* -%dir %{_libdir}/rsocket -%{_libdir}/rsocket/*.so* -%doc %{_docdir}/%{name}-%{version}/librdmacm.md -%{_mandir}/man7/rsocket.* - -%files -n librdmacm-utils -%{_bindir}/cmtime -%{_bindir}/mckey -%{_bindir}/rcopy -%{_bindir}/rdma_client -%{_bindir}/rdma_server -%{_bindir}/rdma_xclient -%{_bindir}/rdma_xserver -%{_bindir}/riostream -%{_bindir}/rping -%{_bindir}/rstream -%{_bindir}/ucmatose -%{_bindir}/udaddy -%{_bindir}/udpong -%{_mandir}/man1/cmtime.* -%{_mandir}/man1/mckey.* -%{_mandir}/man1/rcopy.* -%{_mandir}/man1/rdma_client.* -%{_mandir}/man1/rdma_server.* -%{_mandir}/man1/rdma_xclient.* -%{_mandir}/man1/rdma_xserver.* -%{_mandir}/man1/riostream.* -%{_mandir}/man1/rping.* -%{_mandir}/man1/rstream.* -%{_mandir}/man1/ucmatose.* -%{_mandir}/man1/udaddy.* -%{_mandir}/man1/udpong.* - -%files -n srp_daemon -%config(noreplace) %{_sysconfdir}/srp_daemon.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/srp_daemon.conf -%{_libexecdir}/srp_daemon/start_on_all_ports -%{_unitdir}/srp_daemon.service -%{_unitdir}/srp_daemon_port@.service -%{_sbindir}/ibsrpdm -%{_sbindir}/srp_daemon -%{_sbindir}/run_srp_daemon -%{_udevrulesdir}/60-srp_daemon.rules -%{_mandir}/man1/ibsrpdm.1* -%{_mandir}/man1/srp_daemon.1* -%{_mandir}/man5/srp_daemon.service.5* -%{_mandir}/man5/srp_daemon_port@.service.5* -%doc %{_docdir}/%{name}-%{version}/ibsrpdm.md diff --git a/usr/rdma-core/redhat/rdma.conf b/usr/rdma-core/redhat/rdma.conf deleted file mode 100644 index f5b74b248..000000000 --- a/usr/rdma-core/redhat/rdma.conf +++ /dev/null @@ -1,18 +0,0 @@ -# Load IPoIB -IPOIB_LOAD=yes -# Load SRP (SCSI Remote Protocol initiator support) module -SRP_LOAD=yes -# Load SRPT (SCSI Remote Protocol target support) module -SRPT_LOAD=yes -# Load iSER (iSCSI over RDMA initiator support) module -ISER_LOAD=yes -# Load iSERT (iSCSI over RDMA target support) module -ISERT_LOAD=yes -# Load RDS (Reliable Datagram Service) network protocol -RDS_LOAD=no -# Load NFSoRDMA client transport module -XPRTRDMA_LOAD=yes -# Load NFSoRDMA server transport module -SVCRDMA_LOAD=no -# Load Tech Preview device driver modules -TECH_PREVIEW_LOAD=no diff --git a/usr/rdma-core/redhat/rdma.ifdown-ib b/usr/rdma-core/redhat/rdma.ifdown-ib deleted file mode 100644 index 1cb284dc2..000000000 --- a/usr/rdma-core/redhat/rdma.ifdown-ib +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/bash -# Network Interface Configuration System -# Copyright (c) 1996-2013 Red Hat, Inc. all rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License, version 2, -# as published by the Free Software Foundation. -# -# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -. /etc/init.d/functions - -cd /etc/sysconfig/network-scripts -. ./network-functions - -[ -f ../network ] && . ../network - -CONFIG=${1} - -source_config - -# Allow the user to override the detection of our physical device by passing -# it in. No checking is done, if the user gives us a bogus dev, it's -# their problem. -[ -n "${PHYSDEV}" ] && REALDEVICE="$PHYSDEV" - -. /etc/sysconfig/network - -# Check to make sure the device is actually up -check_device_down ${DEVICE} && exit 0 - -# If we are a P_Key device, we need to munge a few things -if [ "${PKEY}" = yes ]; then - [ -z "${PKEY_ID}" ] && { - net_log $"InfiniBand IPoIB device: PKEY=yes requires a PKEY_ID" - exit 1 - } - [ -z "${PHYSDEV}" ] && { - net_log $"InfiniBand IPoIB device: PKEY=yes requires a PHYSDEV" - exit 1 - } - # Normalize our PKEY_ID to have the high bit set - NEW_PKEY_ID=`printf "0x%04x" $(( 0x8000 | ${PKEY_ID} ))` - NEW_PKEY_NAME=`printf "%04x" ${NEW_PKEY_ID}` - [ "${DEVICE}" != "${PHYSDEV}.${NEW_PKEY_NAME}" ] && { - net_log $"Configured DEVICE name does not match what new device name would be. This -is most likely because once the PKEY_ID was normalized, it no longer -resulted in the expected device naming, and so the DEVICE entry in the -config file needs to be updated to match. This can also be caused by -giving PKEY_ID as a hex number but without using the mandatory 0x prefix. - Configured DEVICE=$DEVICE - Configured PHYSDEV=$PHYSDEV - Configured PKEY_ID=$PKEY_ID - Calculated PKEY_ID=$NEW_PKEY_ID - Calculated name=${PHYSDEV}.${NEW_PKEY_NAME}" - exit 1 - } - [ -d "/sys/class/net/${DEVICE}" ] || exit 0 - # When we get to downing the IP address, we need REALDEVICE to - # point to our PKEY device - REALDEVICE="${DEVICE}" -fi - - -if [ "${SLAVE}" != "yes" -o -z "${MASTER}" ]; then -if [ -n "${HWADDR}" -a -z "${MACADDR}" ]; then - HWADDR=$(echo $HWADDR | tail -c 24) - FOUNDMACADDR=$(get_hwaddr ${REALDEVICE} | tail -c 24) - if [ -n "${FOUNDMACADDR}" -a "${FOUNDMACADDR}" != "${HWADDR}" ]; then - NEWCONFIG=$(get_config_by_hwaddr ${FOUNDMACADDR}) - if [ -n "${NEWCONFIG}" ]; then - eval $(LANG=C grep -F "DEVICE=" $NEWCONFIG) - else - net_log $"Device ${DEVICE} has MAC address ${FOUNDMACADDR}, instead of configured address ${HWADDR}. Ignoring." - exit 1 - fi - if [ -n "${NEWCONFIG}" -a "${NEWCONFIG##*/}" != "${CONFIG##*/}" -a "${DEVICE}" = "${REALDEVICE}" ]; then - exec /sbin/ifdown ${NEWCONFIG} - else - net_log $"Device ${DEVICE} has MAC address ${FOUNDMACADDR}, instead of configured address ${HWADDR}. Ignoring." - exit 1 - fi - fi -fi -fi - -if is_bonding_device ${DEVICE} ; then - for device in $(LANG=C grep -l "^[[:space:]]*MASTER=\"\?${DEVICE}\"\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-*) ; do - is_ignored_file "$device" && continue - /sbin/ifdown ${device##*/} - done - for arg in $BONDING_OPTS ; do - key=${arg%%=*}; - [[ "${key}" != "arp_ip_target" ]] && continue - value=${arg##*=}; - if [ "${value:0:1}" != "" ]; then - OLDIFS=$IFS; - IFS=','; - for arp_ip in $value; do - if grep -q $arp_ip /sys/class/net/${DEVICE}/bonding/arp_ip_target; then - echo "-$arp_ip" > /sys/class/net/${DEVICE}/bonding/arp_ip_target - fi - done - IFS=$OLDIFS; - else - value=${value#+}; - if grep -q $value /sys/class/net/${DEVICE}/bonding/arp_ip_target; then - echo "-$value" > /sys/class/net/${DEVICE}/bonding/arp_ip_target - fi - fi - done -fi - -/etc/sysconfig/network-scripts/ifdown-ipv6 ${CONFIG} - -retcode=0 -[ -n "$(pidof -x dhclient)" ] && { - for VER in "" 6 ; do - if [ -f "/var/run/dhclient$VER-${DEVICE}.pid" ]; then - dhcpid=$(cat /var/run/dhclient$VER-${DEVICE}.pid) - generate_lease_file_name $VER - if [[ "$DHCPRELEASE" = [yY1]* ]]; then - /sbin/dhclient -r -lf ${LEASEFILE} -pf /var/run/dhclient$VER-${DEVICE}.pid ${DEVICE} >/dev/null 2>&1 - retcode=$? - else - kill $dhcpid >/dev/null 2>&1 - retcode=$? - reason=STOP$VER interface=${DEVICE} /sbin/dhclient-script - fi - if [ -f "/var/run/dhclient$VER-${DEVICE}.pid" ]; then - rm -f /var/run/dhclient$VER-${DEVICE}.pid - kill $dhcpid >/dev/null 2>&1 - fi - fi - done -} -# we can't just delete the configured address because that address -# may have been changed in the config file since the device was -# brought up. Flush all addresses associated with this -# instance instead. -if [ -d "/sys/class/net/${REALDEVICE}" ]; then - if [ "${REALDEVICE}" = "${DEVICE}" ]; then - ip addr flush dev ${REALDEVICE} scope global 2>/dev/null - else - ip addr flush dev ${REALDEVICE} label ${DEVICE} scope global 2>/dev/null - fi - - if [ "${SLAVE}" = "yes" -a -n "${MASTER}" ]; then - echo "-${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null - fi - - if [ "${REALDEVICE}" = "${DEVICE}" ]; then - ip link set dev ${DEVICE} down 2>/dev/null - fi -fi -[ "$retcode" = "0" ] && retcode=$? - -# wait up to 5 seconds for device to actually come down... -waited=0 -while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do - usleep 10000 - waited=$(($waited+1)) -done - -if [ "$retcode" = 0 ] ; then - /etc/sysconfig/network-scripts/ifdown-post $CONFIG - # do NOT use $? because ifdown should return whether or not - # the interface went down. -fi - -if [ -n "$PKEY" ]; then - # PKey PKEY - echo "$NEW_PKEY_ID" > /sys/class/net/${PHYSDEV}/delete_child -fi - -exit $retcode diff --git a/usr/rdma-core/redhat/rdma.ifup-ib b/usr/rdma-core/redhat/rdma.ifup-ib deleted file mode 100644 index bb4d4f71f..000000000 --- a/usr/rdma-core/redhat/rdma.ifup-ib +++ /dev/null @@ -1,308 +0,0 @@ -#!/bin/bash -# Network Interface Configuration System -# Copyright (c) 1996-2013 Red Hat, Inc. all rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License, version 2, -# as published by the Free Software Foundation. -# -# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -. /etc/init.d/functions - -cd /etc/sysconfig/network-scripts -. ./network-functions - -[ -f ../network ] && . ../network - -CONFIG="${1}" - -need_config "${CONFIG}" - -source_config - -# Allow the user to override the detection of our physical device by passing -# it in. No checking is done, if the user gives us a bogus dev, it's -# their problem. -[ -n "${PHYSDEV}" ] && REALDEVICE="$PHYSDEV" - -if [ "${BOOTPROTO}" = "dhcp" ]; then - DYNCONFIG=true -fi - -# load the module associated with that device -# /sbin/modprobe ${REALDEVICE} -is_available_wait ${REALDEVICE} ${DEVTIMEOUT} - -# bail out, if the MAC does not fit -if [ -n "${HWADDR}" ]; then - FOUNDMACADDR=$(get_hwaddr ${REALDEVICE} | tail -c 24) - HWADDR=$(echo $HWADDR | tail -c 24) - if [ "${FOUNDMACADDR}" != "${HWADDR}" ]; then - net_log $"Device ${DEVICE} has different MAC address than expected, ignoring." - exit 1 - fi -fi - -# now check the real state -is_available ${REALDEVICE} || { - if [ -n "$alias" ]; then - net_log $"$alias device ${DEVICE} does not seem to be present, delaying initialization." - else - net_log $"Device ${DEVICE} does not seem to be present, delaying initialization." - fi - exit 1 -} - -# if we are a P_Key device, create the device if needed -if [ "${PKEY}" = yes ]; then - [ -z "${PKEY_ID}" ] && { - net_log $"InfiniBand IPoIB device: PKEY=yes requires a PKEY_ID" - exit 1 - } - [ -z "${PHYSDEV}" ] && { - net_log $"InfiniBand IPoIB device: PKEY=yes requires a PHYSDEV" - exit 1 - } - # Normalize our PKEY_ID to have the high bit set - NEW_PKEY_ID=`printf "0x%04x" $(( 0x8000 | ${PKEY_ID} ))` - NEW_PKEY_NAME=`printf "%04x" ${NEW_PKEY_ID}` - [ "${DEVICE}" != "${PHYSDEV}.${NEW_PKEY_NAME}" ] && { - net_log $"Configured DEVICE name does not match what new device name would be. This -is most likely because once the PKEY_ID was normalized, it no longer -resulted in the expected device naming, and so the DEVICE entry in the -config file needs to be updated to match. This can also be caused by -giving PKEY_ID as a hex number but without using the mandatory 0x prefix. - Configured DEVICE=$DEVICE - Configured PHYSDEV=$PHYSDEV - Configured PKEY_ID=$PKEY_ID - Calculated PKEY_ID=$NEW_PKEY_ID - Calculated name=${PHYSDEV}.${NEW_PKEY_NAME}" - exit 1 - } - [ -d "/sys/class/net/${DEVICE}" ] || - echo "${NEW_PKEY_ID}" > "/sys/class/net/${PHYSDEV}/create_child" - [ -d "/sys/class/net/${DEVICE}" ] || { - echo "Failed to create child device $NEW_PKEY_ID of $PHYSDEV" - exit 1 - } - # When we get to setting up the IP address, we need REALDEVICE to - # point to our new PKEY device - REALDEVICE="${DEVICE}" -fi - - -if [ -n "${MACADDR}" ]; then - net_log $"IPoIB devices do not support setting the MAC address of the interface" - # ip link set dev ${DEVICE} address ${MACADDR} -fi - -# First, do we even support setting connected mode? -if [ -e /sys/class/net/${DEVICE}/mode ]; then - # OK, set the mode in all cases, that way it gets reset on a down/up - # cycle, allowing people to change the mode without rebooting - if [ "${CONNECTED_MODE}" = yes ]; then - echo connected > /sys/class/net/${DEVICE}/mode - # cap the MTU where we should based upon mode - [ -z "$MTU" ] && MTU=65520 - [ "$MTU" -gt 65520 ] && MTU=65520 - else - echo datagram > /sys/class/net/${DEVICE}/mode - # cap the MTU where we should based upon mode - [ -z "$MTU" ] && MTU=2044 - [ "$MTU" -gt 2044 ] && MTU=2044 - fi -fi - -if [ -n "${MTU}" ]; then - ip link set dev ${DEVICE} mtu ${MTU} -fi - -# slave device? -if [ "${SLAVE}" = yes -a "${ISALIAS}" = no -a "${MASTER}" != "" ]; then - install_bonding_driver ${MASTER} - grep -wq "${DEVICE}" /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null || { - /sbin/ip link set dev ${DEVICE} down - echo "+${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null - } - ethtool_set - - exit 0 -fi - -# Bonding initialization. For DHCP, we need to enslave the devices early, -# so it can actually get an IP. -if [ "$ISALIAS" = no ] && is_bonding_device ${DEVICE} ; then - install_bonding_driver ${DEVICE} - /sbin/ip link set dev ${DEVICE} up - for device in $(LANG=C grep -l "^[[:space:]]*MASTER=\"\?${DEVICE}\"\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-*) ; do - is_ignored_file "$device" && continue - /sbin/ifup ${device##*/} - done - - [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY} - - # add the bits to setup the needed post enslavement parameters - for arg in $BONDING_OPTS ; do - key=${arg%%=*}; - value=${arg##*=}; - if [ "${key}" = "primary" ]; then - echo $value > /sys/class/net/${DEVICE}/bonding/$key - fi - done -fi - - -if [ -n "${DYNCONFIG}" ] && [ -x /sbin/dhclient ]; then - if [[ "${PERSISTENT_DHCLIENT}" = [yY1]* ]]; then - ONESHOT=""; - else - ONESHOT="-1"; - fi; - generate_config_file_name - generate_lease_file_name - DHCLIENTARGS="${DHCLIENTARGS} -H ${DHCP_HOSTNAME:-${HOSTNAME%%.*}} ${ONESHOT} -q ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient-${DEVICE}.pid" - echo - echo -n $"Determining IP information for ${DEVICE}..." - if [[ "${PERSISTENT_DHCLIENT}" != [yY1]* ]] && check_link_down ${DEVICE}; then - echo $" failed; no link present. Check cable?" - exit 1 - fi - - ethtool_set - - if /sbin/dhclient ${DHCLIENTARGS} ${DEVICE} ; then - echo $" done." - dhcpipv4="good" - else - echo $" failed." - if [[ "${IPV4_FAILURE_FATAL}" = [Yy1]* ]] ; then - exit 1 - fi - if [[ "$IPV6INIT" != [yY1]* && "$DHCPV6C" != [yY1]* ]] ; then - exit 1 - fi - net_log "Unable to obtain IPv4 DHCP address ${DEVICE}." warning - fi -# end dynamic device configuration -else - if [ -z "${IPADDR}" -a -z "${IPADDR0}" -a -z "${IPADDR1}" -a -z "${IPADDR2}" ]; then - # enable device without IP, useful for e.g. PPPoE - ip link set dev ${REALDEVICE} up - ethtool_set - [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY} - else - - expand_config - - [ -n "${ARP}" ] && \ - ip link set dev ${REALDEVICE} $(toggle_value arp $ARP) - - if ! ip link set dev ${REALDEVICE} up ; then - net_log $"Failed to bring up ${DEVICE}." - exit 1 - fi - - ethtool_set - - [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY} - - if [ "${DEVICE}" = "lo" ]; then - SCOPE="scope host" - else - SCOPE=${SCOPE:-} - fi - - if [ -n "$SRCADDR" ]; then - SRC="src $SRCADDR" - else - SRC= - fi - - # set IP address(es) - for idx in {0..256} ; do - if [ -z "${ipaddr[$idx]}" ]; then - break - fi - - if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${ipaddr[$idx]}/${prefix[$idx]}" ; then - [ "${REALDEVICE}" != "lo" ] && [ "${arpcheck[$idx]}" != "no" ] && \ - /sbin/arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${ipaddr[$idx]} - if [ $? = 1 ]; then - net_log $"Error, some other host already uses address ${ipaddr[$idx]}." - exit 1 - fi - - if ! ip addr add ${ipaddr[$idx]}/${prefix[$idx]} \ - brd ${broadcast[$idx]:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then - net_log $"Error adding address ${ipaddr[$idx]} for ${DEVICE}." - fi - fi - - if [ -n "$SRCADDR" ]; then - sysctl -w "net.ipv4.conf.${REALDEVICE}.arp_filter=1" >/dev/null 2>&1 - fi - - # update ARP cache of neighboring computers - if [ "${REALDEVICE}" != "lo" ]; then - /sbin/arping -q -A -c 1 -I ${REALDEVICE} ${ipaddr[$idx]} - ( sleep 2; - /sbin/arping -q -U -c 1 -I ${REALDEVICE} ${ipaddr[$idx]} ) > /dev/null 2>&1 < /dev/null & - fi - done - - # Set a default route. - if [ "${DEFROUTE}" != "no" ] && [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then - # set up default gateway. replace if one already exists - if [ -n "${GATEWAY}" ] && [ "$(ipcalc --network ${GATEWAY} ${netmask[0]} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then - ip route replace default ${METRIC:+metric $METRIC} \ - via ${GATEWAY} ${WINDOW:+window $WINDOW} ${SRC} \ - ${GATEWAYDEV:+dev $GATEWAYDEV} || - net_log $"Error adding default gateway ${GATEWAY} for ${DEVICE}." - elif [ "${GATEWAYDEV}" = "${DEVICE}" ]; then - ip route replace default ${METRIC:+metric $METRIC} \ - ${SRC} ${WINDOW:+window $WINDOW} dev ${REALDEVICE} || - net_log $"Erorr adding default gateway for ${REALDEVICE}." - fi - fi - fi -fi - -# Add Zeroconf route. -if [ -z "${NOZEROCONF}" -a "${ISALIAS}" = "no" -a "${REALDEVICE}" != "lo" ]; then - ip route add 169.254.0.0/16 dev ${REALDEVICE} metric $((1000 + $(cat /sys/class/net/${REALDEVICE}/ifindex))) scope link -fi - -# Inform firewall which network zone (empty means default) this interface belongs to -if [ -x /usr/bin/firewall-cmd -a "${REALDEVICE}" != "lo" ]; then - /usr/bin/firewall-cmd --zone="${ZONE}" --change-interface="${DEVICE}" > /dev/null 2>&1 -fi - -# IPv6 initialisation? -/etc/sysconfig/network-scripts/ifup-ipv6 ${CONFIG} -if [[ "${DHCPV6C}" = [Yy1]* ]] && [ -x /sbin/dhclient ]; then - generate_config_file_name 6 - generate_lease_file_name 6 - echo - echo -n $"Determining IPv6 information for ${DEVICE}..." - if /sbin/dhclient -6 -1 ${DHCPV6C_OPTIONS} ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient6-${DEVICE}.pid -H ${DHCP_HOSTNAME:-${HOSTNAME%%.*}} ${DEVICE} ; then - echo $" done." - else - echo $" failed." - if [ "${dhcpipv4}" = "good" -o -n "${IPADDR}" ]; then - net_log "Unable to obtain IPv6 DHCP address ${DEVICE}." warning - else - exit 1 - fi - fi -fi - -exec /etc/sysconfig/network-scripts/ifup-post ${CONFIG} ${2} - diff --git a/usr/rdma-core/redhat/rdma.kernel-init b/usr/rdma-core/redhat/rdma.kernel-init deleted file mode 100644 index 6f50e72fc..000000000 --- a/usr/rdma-core/redhat/rdma.kernel-init +++ /dev/null @@ -1,233 +0,0 @@ -#!/bin/bash -# -# Bring up the kernel RDMA stack -# -# This is usually run automatically by systemd after a hardware activation -# event in udev has triggered a start of the rdma.service unit -# - -shopt -s nullglob - -CONFIG=/etc/rdma/rdma.conf - -LOAD_ULP_MODULES="" -LOAD_CORE_USER_MODULES="ib_umad ib_uverbs ib_ucm rdma_ucm" -LOAD_CORE_CM_MODULES="iw_cm ib_cm rdma_cm" -LOAD_CORE_MODULES="ib_core" -LOAD_TECH_PREVIEW_DRIVERS="no" - -if [ -f $CONFIG ]; then - . $CONFIG - - if [ "${RDS_LOAD}" == "yes" ]; then - IPOIB_LOAD=yes - fi - - if [ "${IPOIB_LOAD}" == "yes" ]; then - LOAD_ULP_MODULES="ib_ipoib" - fi - - if [ "${RDS_LOAD}" == "yes" -a -f /lib/modules/`uname -r`/kernel/net/rds/rds.ko ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES rds" - if [ -f /lib/modules/`uname -r`/kernel/net/rds/rds_tcp.ko ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES rds_tcp" - fi - if [ -f /lib/modules/`uname -r`/kernel/net/rds/rds_rdma.ko ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES rds_rdma" - fi - fi - - if [ "${SRP_LOAD}" == "yes" ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES ib_srp" - fi - - if [ "${SRPT_LOAD}" == "yes" ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES ib_srpt" - fi - - if [ "${ISER_LOAD}" == "yes" ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES ib_iser" - fi - - if [ "${ISERT_LOAD}" == "yes" ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES ib_isert" - fi - - if [ "${XPRTRDMA_LOAD}" == "yes" ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES xprtrdma" - fi - - if [ "${SVCRDMA_LOAD}" == "yes" ]; then - LOAD_ULP_MODULES="$LOAD_ULP_MODULES svcrdma" - fi - if [ "${TECH_PREVIEW_LOAD}" == "yes" ]; then - LOAD_TECH_PREVIEW_DRIVERS="$TECH_PREVIEW_LOAD" - fi -else - LOAD_ULP_MODULES="ib_ipoib" -fi - -# If module $1 is loaded return - 0 else - 1 -is_loaded() -{ - /sbin/lsmod | grep -w "$1" > /dev/null 2>&1 - return $? -} - -load_modules() -{ - local RC=0 - - for module in $*; do - if ! /sbin/modinfo $module > /dev/null 2>&1; then - # do not attempt to load modules which do not exist - continue - fi - if ! is_loaded $module; then - /sbin/modprobe $module - res=$? - RC=$[ $RC + $res ] - if [ $res -ne 0 ]; then - echo - echo "Failed to load module $module" - fi - fi - done - return $RC -} - -load_hardware_modules() -{ - local -i RC=0 - - # We match both class NETWORK and class INFINIBAND devices since our - # iWARP hardware is listed under class NETWORK. The side effect of - # this is that we might cause a non-iWARP network driver to be loaded. - udevadm trigger --subsystem-match=pci --attr-nomatch=driver --attr-match=class=0x020000 --attr-match=class=0x0c0600 - udevadm settle - if [ -r /proc/device-tree ]; then - if [ -n "`ls /proc/device-tree | grep lhca`" ]; then - if ! is_loaded ib_ehca; then - load_modules ib_ehca - RC+=$? - fi - fi - fi - if is_loaded mlx4_core -a ! is_loaded mlx4_ib; then - load_modules mlx4_ib - RC+=$? - fi - if is_loaded mlx4_core -a ! is_loaded mlx4_en; then - load_modules mlx4_en - RC+=$? - fi - if is_loaded mlx5_core -a ! is_loaded mlx5_ib; then - load_modules mlx5_ib - RC+=$? - fi - if is_loaded cxgb3 -a ! is_loaded iw_cxgb3; then - load_modules iw_cxgb3 - RC+=$? - fi - if is_loaded cxgb4 -a ! is_loaded iw_cxgb4; then - load_modules iw_cxgb4 - RC+=$? - fi - if is_loaded be2net -a ! is_loaded ocrdma; then - load_modules ocrdma - RC+=$? - fi - if is_loaded enic -a ! is_loaded usnic_verbs; then - load_modules usnic_verbs - RC+=$? - fi - if [ "${LOAD_TECH_PREVIEW_DRIVERS}" == "yes" ]; then - if is_loaded i40e -a ! is_loaded i40iw; then - load_modules i40iw - RC+=$? - fi - fi - return $RC -} - -errata_58() -{ - # Check AMD chipset issue Errata #58 - if test -x /sbin/lspci && test -x /sbin/setpci; then - if ( /sbin/lspci -nd 1022:1100 | grep "1100" > /dev/null ) && - ( /sbin/lspci -nd 1022:7450 | grep "7450" > /dev/null ) && - ( /sbin/lspci -nd 15b3:5a46 | grep "5a46" > /dev/null ); then - CURVAL=`/sbin/setpci -d 1022:1100 69` - for val in $CURVAL - do - if [ "${val}" != "c0" ]; then - /sbin/setpci -d 1022:1100 69=c0 - if [ $? -eq 0 ]; then - break - else - echo "Failed to apply AMD-8131 Errata #58 workaround" - fi - fi - done - fi - fi -} - -errata_56() -{ - # Check AMD chipset issue Errata #56 - if test -x /sbin/lspci && test -x /sbin/setpci; then - if ( /sbin/lspci -nd 1022:1100 | grep "1100" > /dev/null ) && - ( /sbin/lspci -nd 1022:7450 | grep "7450" > /dev/null ) && - ( /sbin/lspci -nd 15b3:5a46 | grep "5a46" > /dev/null ); then - bus="" - # Look for devices AMD-8131 - for dev in `/sbin/setpci -v -f -d 1022:7450 19 | cut -d':' -f1,2` - do - bus=`/sbin/setpci -s $dev 19` - rev=`/sbin/setpci -s $dev 8` - # Look for Tavor attach to secondary bus of this devices - for device in `/sbin/setpci -f -s $bus: -d 15b3:5a46 19` - do - if [ $rev -lt 13 ]; then - /sbin/setpci -d 15b3:5a44 72=14 - if [ $? -eq 0 ]; then - break - else - echo - echo "Failed to apply AMD-8131 Errata #56 workaround" - fi - else - continue - fi - # If more than one device is on the bus the issue a - # warning - num=`/sbin/setpci -f -s $bus: 0 | wc -l | sed 's/\ *//g'` - if [ $num -gt 1 ]; then - echo "Warning: your current PCI-X configuration might be incorrect." - echo "see AMD-8131 Errata 56 for more details." - fi - done - done - fi - fi -} - - -load_hardware_modules -RC=$[ $RC + $? ] -load_modules $LOAD_CORE_MODULES -RC=$[ $RC + $? ] -load_modules $LOAD_CORE_CM_MODULES -RC=$[ $RC + $? ] -load_modules $LOAD_CORE_USER_MODULES -RC=$[ $RC + $? ] -load_modules $LOAD_ULP_MODULES -RC=$[ $RC + $? ] - -errata_58 -errata_56 - -/usr/libexec/rdma-set-sriov-vf - -exit $RC diff --git a/usr/rdma-core/redhat/rdma.mlx4-setup.sh b/usr/rdma-core/redhat/rdma.mlx4-setup.sh deleted file mode 100644 index ff8caf53a..000000000 --- a/usr/rdma-core/redhat/rdma.mlx4-setup.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -dir="/sys/bus/pci/drivers/mlx4_core" -[ ! -d $dir ] && exit 1 -pushd $dir >/dev/null - -function set_dual_port() { - device=$1 - port1=$2 - port2=$3 - pushd $device >/dev/null - cur_p1=`cat mlx4_port1` - cur_p2=`cat mlx4_port2` - - # special case the "eth eth" mode as we need port2 to - # actually switch to eth before the driver will let us - # switch port1 to eth as well - if [ "$port1" == "eth" ]; then - if [ "$port2" != "eth" ]; then - echo "In order for port1 to be eth, port2 to must also be eth" - popd >/dev/null - return - fi - if [ "$cur_p2" != "eth" -a "$cur_p2" != "auto (eth)" ]; then - tries=0 - echo "$port2" > mlx4_port2 2>/dev/null - sleep .25 - cur_p2=`cat mlx4_port2` - while [ "$cur_p2" != "eth" -a "$cur_p2" != "auto (eth)" -a $tries -lt 10 ]; do - sleep .25 - let tries++ - cur_p2=`cat mlx4_port2` - done - if [ "$cur_p2" != "eth" -a "$cur_p2" != "auto (eth)" ]; then - echo "Failed to set port2 to eth mode" - popd >/dev/null - return - fi - fi - if [ "$cur_p1" != "eth" -a "$cur_p1" != "auto (eth)" ]; then - tries=0 - echo "$port1" > mlx4_port1 2>/dev/null - sleep .25 - cur_p1=`cat mlx4_port1` - while [ "$cur_p1" != "eth" -a "$cur_p1" != "auto (eth)" -a $tries -lt 10 ]; do - sleep .25 - let tries++ - cur_p1=`cat mlx4_port1` - done - if [ "$cur_p1" != "eth" -a "$cur_p1" != "auto (eth)" ]; then - echo "Failed to set port1 to eth mode" - fi - fi - popd >/dev/null - return - fi - - # our mode is not eth as that is covered above - # so we should be able to successfully set the ports in - # port1 then port2 order - if [ "$cur_p1" != "$port1" -o "$cur_p2" != "$port2" ]; then - # Try setting the ports in order first - echo "$port1" > mlx4_port1 2>/dev/null ; sleep .1 - echo "$port2" > mlx4_port2 2>/dev/null ; sleep .1 - cur_p1=`cat mlx4_port1` - cur_p2=`cat mlx4_port2` - fi - - if [ "$cur_p1" != "$port1" -o "$cur_p2" != "$port2" ]; then - # Try reverse order this time - echo "$port2" > mlx4_port2 2>/dev/null ; sleep .1 - echo "$port1" > mlx4_port1 2>/dev/null ; sleep .1 - cur_p1=`cat mlx4_port1` - cur_p2=`cat mlx4_port2` - fi - - if [ "$cur_p1" != "$port1" -o "$cur_p2" != "$port2" ]; then - echo "Error setting port type on mlx4 device $device" - fi - - popd >/dev/null - return -} - - -while read device port1 port2 ; do - [ -d "$device" ] || continue - [ -z "$port1" ] && continue - [ -f "$device/mlx4_port2" -a -z "$port2" ] && continue - [ -f "$device/mlx4_port2" ] && set_dual_port $device $port1 $port2 || echo "$port1" > "$device/mlx4_port1" -done -popd 2&>/dev/null diff --git a/usr/rdma-core/redhat/rdma.mlx4.conf b/usr/rdma-core/redhat/rdma.mlx4.conf deleted file mode 100644 index 71207cc54..000000000 --- a/usr/rdma-core/redhat/rdma.mlx4.conf +++ /dev/null @@ -1,27 +0,0 @@ -# Config file for mlx4 hardware port settings -# This file is read when the mlx4_core module is loaded and used to -# set the port types for any hardware found. If a card is not listed -# in this file, then its port types are left alone. -# -# Format: -# [port2_type] -# -# @port1 and @port2: -# One of auto, ib, or eth. No checking is performed to make sure that -# combinations are valid. Invalid inputs will result in the driver -# not setting the port to the type requested. port1 is required at -# all times, port2 is required for dual port cards. -# -# Example: -# 0000:0b:00.0 eth eth -# -# You can find the right pci device to use for any given card by loading -# the mlx4_core module, then going to /sys/bus/pci/drivers/mlx4_core and -# seeing what possible PCI devices are listed there. The possible values -# for ports are: ib, eth, and auto. However, not all cards support all -# types, so if you get messages from the kernel that your selected port -# type isn't supported, there's nothing this script can do about it. Also, -# some cards don't support using different types on the two ports (aka, -# both ports must be either eth or ib). Again, we can't set what the kernel -# or hardware won't support. -# diff --git a/usr/rdma-core/redhat/rdma.mlx4.sys.modprobe b/usr/rdma-core/redhat/rdma.mlx4.sys.modprobe deleted file mode 100644 index 781562cd8..000000000 --- a/usr/rdma-core/redhat/rdma.mlx4.sys.modprobe +++ /dev/null @@ -1,5 +0,0 @@ -# WARNING! - This file is overwritten any time the rdma rpm package is -# updated. Please do not make any changes to this file. Instead, make -# changes to the mlx4.conf file. It's contents are preserved if they -# have been changed from the default values. -install mlx4_core /sbin/modprobe --ignore-install mlx4_core $CMDLINE_OPTS && (if [ -f /usr/libexec/mlx4-setup.sh -a -f /etc/rdma/mlx4.conf ]; then /usr/libexec/mlx4-setup.sh < /etc/rdma/mlx4.conf; fi; /sbin/modprobe mlx4_en; if /sbin/modinfo mlx4_ib > /dev/null 2>&1; then /sbin/modprobe mlx4_ib; fi) diff --git a/usr/rdma-core/redhat/rdma.modules-setup.sh b/usr/rdma-core/redhat/rdma.modules-setup.sh deleted file mode 100644 index 803fc60f4..000000000 --- a/usr/rdma-core/redhat/rdma.modules-setup.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -check() { - [ -n "$hostonly" -a -c /sys/class/infiniband_verbs/uverbs0 ] && return 0 - [ -n "$hostonly" ] && return 255 - return 0 -} - -depends() { - return 0 -} - -install() { - inst /etc/rdma/rdma.conf - inst /etc/rdma/mlx4.conf - inst /etc/rdma/sriov-vfs - inst /usr/libexec/rdma-init-kernel - inst /usr/libexec/mlx4-setup.sh - inst /usr/libexec/rdma-set-sriov-vf - inst /usr/lib/modprobe.d/libmlx4.conf - inst_multiple lspci setpci awk sleep - inst_multiple -o /etc/modprobe.d/mlx4.conf - inst_rules 98-rdma.rules 70-persistent-ipoib.rules -} - -installkernel() { - hostonly='' instmods =drivers/infiniband =drivers/net/ethernet/mellanox =drivers/net/ethernet/chelsio =drivers/net/ethernet/cisco =drivers/net/ethernet/emulex =drivers/target - hostonly='' instmods crc-t10dif crct10dif_common -} diff --git a/usr/rdma-core/redhat/rdma.service b/usr/rdma-core/redhat/rdma.service deleted file mode 100644 index 514ef58b9..000000000 --- a/usr/rdma-core/redhat/rdma.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Initialize the iWARP/InfiniBand/RDMA stack in the kernel -Documentation=file:/etc/rdma/rdma.conf -RefuseManualStop=true -DefaultDependencies=false -Conflicts=emergency.target emergency.service -Before=network.target remote-fs-pre.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/libexec/rdma-init-kernel - -[Install] -WantedBy=sysinit.target diff --git a/usr/rdma-core/redhat/rdma.sriov-init b/usr/rdma-core/redhat/rdma.sriov-init deleted file mode 100644 index 0d7cbc67e..000000000 --- a/usr/rdma-core/redhat/rdma.sriov-init +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash -# -# Initialize SRIOV virtual devices -# -# This is usually run automatically by systemd after a hardware activation -# event in udev has triggered a start of the rdma.service unit -port=1 - -function __get_parent_pci_dev() -{ - pushd /sys/bus/pci/devices/$pci_dev >/dev/null 2>&1 - ppci_dev=`ls -l physfn | cut -f 2 -d '/'` - popd >/dev/null 2>&1 -} - -function __get_parent_ib_dev() -{ - ib_dev=`ls -l | awk '/'$ppci_dev'/ { print $9 }'` -} - -function __get_parent_net_dev() -{ - for netdev in /sys/bus/pci/devices/$ppci_dev/net/* ; do - if [ "$port" -eq `cat $netdev/dev_port` ]; then - netdev=`basename $netdev` - break - fi - done -} - -function __get_vf_num() -{ - pushd /sys/bus/pci/devices/$ppci_dev >/dev/null 2>&1 - vf=`ls -l virtfn* | awk '/'$pci_dev'/ { print $9 }' | sed -e 's/virtfn//'` - popd >/dev/null 2>&1 -} - -function __en_sriov_set_vf() -{ - pci_dev=$1 - shift - [ "$1" = "port" ] && port=$2 && shift 2 - # We find our parent device by the netdev registered port number, - # however, the netdev port numbers start at 0 while the port - # numbers on the card start at 1, so we subtract 1 from our - # configured port number to get the netdev number - let port-- - # Now we need to fill in the necessary information to pass to the ip - # command - __get_parent_pci_dev - __get_parent_net_dev - __get_vf_num - # The rest is easy. Either the user passed valid arguments as options - # or they didn't - ip link set dev $netdev vf $vf $* -} - -function __ib_sriov_set_vf() -{ - pci_dev=$1 - shift - [ "$1" = "port" ] && port=$2 && shift 2 - guid="" - __get_parent_pci_dev - __get_parent_ib_dev - [ -f $ib_dev/iov/$pci_dev/ports/$port/gid_idx/0 ] || return - while [ -n "$1" ]; do - case $1 in - guid) - guid=$2 - shift 2 - ;; - pkey) - shift 1 - break - ;; - *) - echo "Unknown option in $src" - shift - ;; - esac - done - if [ -n "$guid" ]; then - guid_idx=`cat "$ib_dev/iov/$pci_dev/ports/$port/gid_idx/0"` - echo "$guid" > "$ib_dev/iov/ports/$port/admin_guids/$guid_idx" - fi - i=0 - while [ -n "$1" ]; do - for pkey in $ib_dev/iov/ports/$port/pkeys/*; do - if [ `cat $pkey` = "$1" ]; then - echo `basename $pkey` > $ib_dev/iov/$pci_dev/ports/$port/pkey_idx/$i - let i++ - break - fi - done - shift - done -} - -[ -d /sys/class/infiniband ] || return -pushd /sys/class/infiniband >/dev/null 2>&1 - -if [ -z "$*" ]; then - src=/etc/rdma/sriov-vfs - [ -f "$src" ] || return - grep -v "^#" $src | while read -a args; do - # When we use read -a to read into an array, the index starts at - # 0, unlike below where the arg count starts at 1 - port=1 - next_arg=1 - [ "${args[$next_arg]}" = "port" ] && next_arg=3 - case ${args[$next_arg]} in - guid|pkey) - __ib_sriov_set_vf ${args[*]} - ;; - mac|vlan|rate|spoofchk|enable) - __en_sriov_set_vf ${args[*]} - ;; - *) - ;; - esac - done -else - [ "$2" = "port" ] && next_arg=$4 || next_arg=$2 - case $next_arg in - guid|pkey) - __ib_sriov_set_vf $* - ;; - mac|vlan|rate|spoofchk|enable) - __en_sriov_set_vf $* - ;; - *) - ;; - esac -fi - -popd >/dev/null 2>&1 diff --git a/usr/rdma-core/redhat/rdma.sriov-vfs b/usr/rdma-core/redhat/rdma.sriov-vfs deleted file mode 100644 index ef3e6c090..000000000 --- a/usr/rdma-core/redhat/rdma.sriov-vfs +++ /dev/null @@ -1,41 +0,0 @@ -# All lines in this file that start with a # are comments, -# all other lines will be processed without argument checks -# Format of this file is one sriov vf setting per line with -# arguments as follows: -# vf [port #] [ethernet settings | infiniband settings] -# -# @vf - PCI address of device to configure as found in -# /sys/bus/pci/devices/ -# -# [port @port] - Optional: the port number we are setting on -# the device. We always assume port 1 unless told -# otherwise. -# -# Ethernet settings: -# mac [additional options] -# @mac - mac address to assign to vf...this is currently required by -# the ip program if you wish to be able to set any of the other -# settings. If you don't set anything on a vf, it will get a -# random mac address and you may use static IP addressing to -# have a consistent IP address in spite of the random mac -# @* - additional arguments are passed to ip link without any -# further processing/checking, additional options that could -# be passed as of the time of writing this are: -# [ vlan VLANID [ qos VLAN-QOS ] ] -# [ rate TXRATE ] -# [ spoofchk { on | off} ] -# [ state { auto | enable | disable} ] -# -# InfiniBand settings: -# [guid ] [pkey ] -# @guid - 64bit GUID value to assign to vf. Omit this option to -# use a subnet manager assigned GUID. -# @pkey - one or more pkeys to assign to this guest, must be last -# item on line -# -# Examples: -# -# 0000:44:00.1 guid 05011403007bcba1 pkey 0xffff 0x8002 -# 0000:44:00.1 port 2 mac aa:bb:cc:dd:ee:f0 spoofchk on -# 0000:44:00.2 port 1 pkey 0x7fff 0x0002 -# 0000:44:00.2 port 2 mac aa:bb:cc:dd:ee:f1 vlan 10 spoofchk on state enable diff --git a/usr/rdma-core/redhat/rdma.udev-rules b/usr/rdma-core/redhat/rdma.udev-rules deleted file mode 100644 index 7f44fe30d..000000000 --- a/usr/rdma-core/redhat/rdma.udev-rules +++ /dev/null @@ -1,12 +0,0 @@ -# We list all the various kernel modules that drive hardware in the -# InfiniBand stack (and a few in the network stack that might not actually -# be RDMA capable, but we don't know that at this time and it's safe to -# enable the IB stack, so do so unilaterally) and on load of any of that -# hardware, we trigger the rdma.service load in systemd - -SUBSYSTEM=="module", KERNEL=="cxgb*", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service" -SUBSYSTEM=="module", KERNEL=="ib_*", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service" -SUBSYSTEM=="module", KERNEL=="mlx*", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service" -SUBSYSTEM=="module", KERNEL=="iw_*", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service" -SUBSYSTEM=="module", KERNEL=="be2net", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service" -SUBSYSTEM=="module", KERNEL=="enic", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service" diff --git a/usr/rdma-core/srp_daemon/CMakeLists.txt b/usr/rdma-core/srp_daemon/CMakeLists.txt deleted file mode 100644 index 0e7de9594..000000000 --- a/usr/rdma-core/srp_daemon/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NO_STRICT_ALIASING_FLAGS}") - -rdma_man_pages( - ibsrpdm.1 - srp_daemon.1.in - srp_daemon.service.5 - srp_daemon_port@.service.5 - ) - -rdma_sbin_executable(srp_daemon - srp_daemon.c - srp_handle_traps.c - srp_sync.c - ) -target_link_libraries(srp_daemon LINK_PRIVATE - ibverbs - ibumad - ${RT_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ) - -rdma_install_symlink(srp_daemon "${CMAKE_INSTALL_SBINDIR}/ibsrpdm") -# FIXME: Why? -rdma_install_symlink(srp_daemon "${CMAKE_INSTALL_SBINDIR}/run_srp_daemon") -rdma_subst_install(FILES "srp_daemon.sh.in" - DESTINATION "${CMAKE_INSTALL_SBINDIR}" - RENAME "srp_daemon.sh" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) - -install(FILES start_on_all_ports - DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/srp_daemon" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) - -rdma_subst_install(FILES srp_daemon.service.in - DESTINATION "${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}" - RENAME srp_daemon.service - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) - -rdma_subst_install(FILES srp_daemon_port@.service.in - DESTINATION "${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}" - RENAME srp_daemon_port@.service - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) - -install(FILES srp_daemon.conf DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}") - -install(FILES "srp_daemon.rules" - RENAME "60-srp_daemon.rules" - DESTINATION "${CMAKE_INSTALL_UDEV_RULESDIR}") - -install(FILES modules-srp_daemon.conf - RENAME "srp_daemon.conf" - DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/rdma/modules") - -# FIXME: The ib init.d file should really be included in rdma-core as well. -set(RDMA_SERVICE "openibd" CACHE STRING "init.d file service name to order srpd after") -# NOTE: These defaults are for CentOS, packagers should override. -set(SRP_DEFAULT_START "2 3 4 5" CACHE STRING "Default-Start service data for srpd") -set(SRP_DEFAULT_STOP "0 1 6" CACHE STRING "Default-Stop service data for srpd") -configure_file(srpd.in "${CMAKE_CURRENT_BINARY_DIR}/srpd") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/srpd" - DESTINATION "${CMAKE_INSTALL_INITDDIR}" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) diff --git a/usr/rdma-core/srp_daemon/ibsrpdm.1 b/usr/rdma-core/srp_daemon/ibsrpdm.1 deleted file mode 100644 index 6e7fc0d6e..000000000 --- a/usr/rdma-core/srp_daemon/ibsrpdm.1 +++ /dev/null @@ -1,38 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH IBSRPDM 1 "August 30, 2005" "OpenFabrics" "USER COMMANDS" - -.SH NAME -ibsrpdm \- Discover SRP targets on an InfiniBand Fabric - -.SH SYNOPSIS -.B ibsrpdm [\fIOPTIONS\fB] - -.SH DESCRIPTION -.PP -List InfiniBand SCSI RDMA Protocol (SRP) targets on an IB fabric. - -.SH OPTIONS - -.PP -.TP -\fB\-c\fR -Generate output suitable for piping directly to a -/sys/class/infiniband_srp/srp\-\-/add_target file -.TP -\fB\-d\fR \fIDEVICE\fR -Use device file \fIDEVICE\fR (default /dev/infiniband/umad0) -.TP -\fB\-k\fR \fIP_KEY\fR -Use InfiniBand partition key \fIP_KEY\fR (default 0xffff) -.TP -\fB\-v\fR -Print more verbose output - -.SH SEE ALSO -.BR srp_daemon (1) - -.SH AUTHORS -.TP -Roland Dreier -.RI < roland@kernel.org > - diff --git a/usr/rdma-core/srp_daemon/modules-srp_daemon.conf b/usr/rdma-core/srp_daemon/modules-srp_daemon.conf deleted file mode 100644 index dbe434362..000000000 --- a/usr/rdma-core/srp_daemon/modules-srp_daemon.conf +++ /dev/null @@ -1,2 +0,0 @@ -# These modules are loaded by the system if srp_daemon is to be run -ib_srp diff --git a/usr/rdma-core/srp_daemon/srp_daemon.1.in b/usr/rdma-core/srp_daemon/srp_daemon.1.in deleted file mode 100644 index 0534cf430..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon.1.in +++ /dev/null @@ -1,137 +0,0 @@ -.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -.TH SRP_DAEMON 1 "September 5, 2006" "OpenFabrics" "USER COMMANDS" - -.SH NAME -srp_daemon \- Discovers SRP targets in an InfiniBand Fabric - -.SH SYNOPSIS -.B srp_daemon\fR [\fB-vVcaeon\fR] [\fB-d \fIumad-device\fR | \fB-i \fIinfiniband-device\fR [\fB-p \fIport-num\fR] | \fB-j \fIdev:port\fR] [\fB-t \fItimeout(ms)\fR] [\fB-r \fIretries\fR] [\fB-R \fIrescan-time\fR] [\fB-f \fIrules-file\fR] - - -.SH DESCRIPTION -.PP -Discovers and connects to InfiniBand SCSI RDMA Protocol (SRP) targets in an IB fabric. - -Each srp_daemon instance operates on one local port. Upon boot it performs a -full rescan of the fabric and then waits for an srp_daemon event. An -srp_daemon event can be a join of a new machine to the fabric, a change in the -capabilities of a machine, an SA change, or an expiration of a predefined -timeout. - -When a new machine joins the fabric, srp_daemon checks if it is an SRP -target. When there is a change of capabilities, srp_daemon checks if the -machine has turned into an SRP target. When there is an SA change or a timeout -expiration, srp_daemon performs a full rescan of the fabric. - -For each target srp_daemon finds, it checks if it should connect to this -target according to its rules (the default rules file is -@CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf) and if it is already -connected to the local port. If it should connect to this target and if it is -not connected yet, srp_daemon can either print the target details or connect -to it. - -.SH OPTIONS - -.PP -.TP -\fB\-v\fR -Print more verbose output -.TP -\fB\-V\fR -Print even more verbose output (debug mode) -.TP -\fB\-i\fR \fIinfiniband-device\fR -Work on \fIinfiniband-device\fR. This option should not be used with -d nor -with -j. -.TP -\fB\-p\fR \fIport-num\fR -Work on port \fIport-num\fR (default 1). This option must be used with -i and -should not be used with -d nor with -j. -.TP -\fB\-j\fR \fIdev:port\fR -Work on port number \fIport\fR of InfiniBand device \fIdev\fR. This option -should not be used with -d, -i nor with -p. -.TP -\fB\-d\fR \fIumad-device\fR -Use device file \fIumad-device\fR (default /dev/infiniband/umad0) This option -should not be used with -i, -p nor with -j. -.TP -\fB\-c\fR -Generate output suitable for piping directly to a -/sys/class/infiniband_srp/srp\-\-/add_target file. -.TP -\fB\-a\fR -Prints all the targets in the fabric, not only targets that are not connected -through the local port. This is the same behavior as that of ibsrpdm. -.TP -\fB\-e\fR -Execute the connection command, i.e., make the connection to the target. -.TP -\fB\-o\fR -Perform only one rescan and exit just like ibsrpdm. -.TP -\fB\-R\fR \fIrescan-time\fR -Force a complete rescan every \fIrescan-time\fR seconds. If -R is not specified, no timeout rescans will be performed. -.TP -\fB\-T\fR \fIretry-timeout\fR -Retries to connect to existing target after \fIretry-timeout\fR seconds. If -R is not specified, uses 5 Seconds timeout. if retry-timeout is 0, will not try to reconnect. The reason srp_daemon retries to connect to the target is because there may be a rare scnerio in which srp_daemon will try to connect to add a target when the target is about to be removed, but is not removed yet. -.TP -\fB\-f\fR \fIrules-file\fR -Decide to which targets to connect according to the rules in \fIrules-file\fR. -If \fB\-f\fR is not specified, uses the default rules file @CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf. -Each line in the \fIrules-file\fR is a rule which can be either an allow connection or a disallow connection according to -the first character in the line (a or d accordingly). The rest of the line is values for id_ext, ioc_guid, dgid, -service_id. Please take a look at the example section for an example of the file. srp_daemon decide whether to allow or disallow each target according to first rule that match the target. If no rule matches the target, the target is allowed and will be connected. In an allow rule it is possible to set attributes for the connection to the target. Supported attributes are max_cmd_per_lun and max_sect. -.TP -\fB\-t\fR \fItimeout\fR -Use timeout of \fItimeout\fR msec for MAD responses (default: 5 sec). -.TP -\fB\-r\fR \fIretries\fR -Perform \fIretries\fR retries on each send to MAD (default: 3 retries). -.TP -\fB\-n\fR -New format - use also initiator_ext in the connection command. -.TP -\fB\--systemd\fR -Enable systemd integration. - -.SH FILES -@CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf - -Default rules configuration file that indicates to which targets to connect. Can be overridden using the \fB\-f\fR \fIrules-file\fR option. -Each line in this file is a rule which can be either an allow connection or a disallow connection according to -the first character in the line (a or d accordingly). The rest of the line is values for id_ext, ioc_guid, dgid, -service_id. Please take a look at the example section for an example of the file. srp_daemon decide whether to allow or disallow each target according to first rule that match the target. If no rule matches the target, the target is allowed and will be connected. In an allow rule it is possible to set attributes for the connection to the target. Supported attributes are max_cmd_per_lun and max_sect. - -.SH EXAMPLES -srp_daemon -e -i mthca0 -p 1 -R 60 (Connects to the targets accessible through port 1 of mthca0. Performs a complete rescan every minute) - -srp_daemon -o -c -a (Prints the connection commands for the targets in the fabric and exits - similar to ibsrpdm) - -srp_daemon -e -f rules.txt (Connects to the targets allowed in the rules file rules.txt) - -.nf -An example for a rules configuration file (such as @CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf) ------------------------------------------------------------------------- -# Rules file example -# This is a comment -# disallow the following dgid -d dgid=fe800000000000000002c90200402bd5 -# allow target with the following ioc_guid -a ioc_guid=00a0b80200402bd7 -# allow target with the following id_ext and ioc_guid. And setting max_cmd_per_lun to 31. -a id_ext=200500A0B81146A1,ioc_guid=00a0b80200402bef,max_cmd_per_lun=31 -# disallow all the rest -d -.fi - - -.SH SEE ALSO -.BR ibsrpdm (1) - -.SH AUTHORS -.TP -Roland Dreier -.RI < rolandd@cisco.com > -.TP -Ishai Rabinovitz -.RI < ishai@mellanox.co.il > diff --git a/usr/rdma-core/srp_daemon/srp_daemon.c b/usr/rdma-core/srp_daemon/srp_daemon.c deleted file mode 100644 index 2465ccd9e..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon.c +++ /dev/null @@ -1,2395 +0,0 @@ -/* - * srp_daemon - discover SRP targets over IB - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2006 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Author: ishai Rabinovitz [ishai@mellanox.co.il]$ - * Based on Roland Dreier's initial code [rdreier@cisco.com] - * - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "srp_ib_types.h" - -#include "srp_daemon.h" - -#define IBDEV_STR_SIZE 16 -#define IBPORT_STR_SIZE 16 -#define IGNORE(value) do { if (value) { } } while (0) -#define max_t(type, x, y) ({ \ - type __max1 = (x); \ - type __max2 = (y); \ - __max1 > __max2 ? __max1: __max2; }) - -#define get_data_ptr(mad) ((void *) ((mad).hdr.data)) - -enum log_dest { log_to_syslog, log_to_stderr }; - -static int get_lid(struct umad_resources *umad_res, union umad_gid *gid, - uint16_t *lid); - -static const int node_table_response_size = 1 << 18; -static const char *sysfs_path = "/sys"; -static enum log_dest s_log_dest = log_to_syslog; -static int wakeup_pipe[2] = { -1, -1 }; - - -void wake_up_main_loop(char ch) -{ - int res; - - assert(wakeup_pipe[1] >= 0); - res = write(wakeup_pipe[1], &ch, 1); - IGNORE(res); -} - -static void signal_handler(int signo) -{ - wake_up_main_loop(signo); -} - -/* - * Return either the received signal (SIGINT, SIGTERM, ...) or 0 if no signal - * has been received before the timeout has expired. - */ -static int get_received_signal(time_t tv_sec, suseconds_t tv_usec) -{ - int fd, ret, received_signal = 0; - fd_set rset; - struct timeval timeout; - char buf[16]; - - fd = wakeup_pipe[0]; - FD_ZERO(&rset); - FD_SET(fd, &rset); - timeout.tv_sec = tv_sec; - timeout.tv_usec = tv_usec; - ret = select(fd + 1, &rset, NULL, NULL, &timeout); - if (ret < 0) - assert(errno == EINTR); - while ((ret = read(fd, buf, sizeof(buf))) > 0) - received_signal = buf[ret - 1]; - - return received_signal; -} - -static int check_process_uniqueness(struct config_t *conf) -{ - char path[256]; - int fd; - - snprintf(path, sizeof(path), SRP_DEAMON_LOCK_PREFIX "_%s_%d", - conf->dev_name, conf->port_num); - - if ((fd = open(path, O_CREAT|O_RDWR, - S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR)) < 0) { - pr_err("cannot open file \"%s\" (errno: %d).\n", path, errno); - return -1; - } - - fchmod(fd, S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH); - if (0 != lockf(fd, F_TLOCK, 0)) { - pr_err("failed to lock %s (errno: %d). possibly another " - "srp_daemon is locking it\n", path, errno); - close(fd); - fd = -1; - } - - return fd; -} - -static int srpd_sys_read_string(const char *dir_name, const char *file_name, - char *str, int max_len) -{ - char path[256], *s; - int fd, r; - - snprintf(path, sizeof(path), "%s/%s", dir_name, file_name); - - if ((fd = open(path, O_RDONLY)) < 0) - return (errno > 0) ? -errno : errno; - - if ((r = read(fd, str, max_len)) < 0) { - int e = errno; - close(fd); - return (e > 0) ? -e : e; - } - - str[(r < max_len) ? r : max_len - 1] = 0; - - if ((s = strrchr(str, '\n'))) - *s = 0; - - close(fd); - return 0; -} - -static int srpd_sys_read_gid(const char *dir_name, const char *file_name, - uint8_t *gid) -{ - char buf[64], *str, *s; - __be16 *ugid = (__be16 *)gid; - int r, i; - - if ((r = srpd_sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0) - return r; - - for (s = buf, i = 0 ; i < 8; i++) { - if (!(str = strsep(&s, ": \t\n"))) - return -EINVAL; - ugid[i] = htobe16(strtoul(str, NULL, 16) & 0xffff); - } - - return 0; -} - -static int srpd_sys_read_uint64(const char *dir_name, const char *file_name, - uint64_t *u) -{ - char buf[32]; - int r; - - if ((r = srpd_sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0) - return r; - - *u = strtoull(buf, NULL, 0); - - return 0; -} - - - - -static void usage(const char *argv0) -{ - fprintf(stderr, "Usage: %s [-vVcaeon] [-d | -i [-p ]] [-t ] [-r ] [-R ] [-f \n", argv0); - fprintf(stderr, "-v Verbose\n"); - fprintf(stderr, "-V debug Verbose\n"); - fprintf(stderr, "-c prints connection Commands\n"); - fprintf(stderr, "-a show All - prints also targets that are already connected\n"); - fprintf(stderr, "-e Executes connection commands\n"); - fprintf(stderr, "-o runs only Once and stop\n"); - fprintf(stderr, "-d use umad Device \n"); - fprintf(stderr, "-i use InfiniBand device \n"); - fprintf(stderr, "-p use Port num \n"); - fprintf(stderr, "-j : use the IB dev / port_num combination \n"); - fprintf(stderr, "-R perform complete Rescan every seconds\n"); - fprintf(stderr, "-T Retries to connect to existing target after Timeout of seconds\n"); - fprintf(stderr, "-l Transport retry count before failing IO. should be in range [2..7], (default 2)\n"); - fprintf(stderr, "-f use rules File to set to which target(s) to connect (default: " SRP_DEAMON_CONFIG_FILE ")\n"); - fprintf(stderr, "-t Timeout for mad response in milliseconds\n"); - fprintf(stderr, "-r number of send Retries for each mad\n"); - fprintf(stderr, "-n New connection command format - use also initiator extension\n"); - fprintf(stderr, "--systemd Enable systemd integration.\n"); - fprintf(stderr, "\nExample: srp_daemon -e -n -i mthca0 -p 1 -R 60\n"); -} - -static int -check_equal_uint64(char *dir_name, const char *attr, uint64_t val) -{ - uint64_t attr_value; - - if (srpd_sys_read_uint64(dir_name, attr, &attr_value)) - return 0; - - return attr_value == val; -} - -static int -check_equal_uint16(char *dir_name, const char *attr, uint16_t val) -{ - uint64_t attr_value; - - if (srpd_sys_read_uint64(dir_name, attr, &attr_value)) - return 0; - - return val == (attr_value & 0xffff); -} - -static int recalc(struct resources *res); - -static void pr_cmd(char *target_str, int not_connected) -{ - int ret; - - if (config->cmd) - printf("%s\n", target_str); - - if (config->execute && not_connected) { - int fd = open(config->add_target_file, O_WRONLY); - if (fd < 0) { - pr_err("unable to open %s, maybe ib_srp is not loaded\n", config->add_target_file); - return; - } - ret = write(fd, target_str, strlen(target_str)); - pr_debug("Adding target returned %d\n", ret); - close(fd); - } -} - -void pr_debug(const char *fmt, ...) -{ - va_list args; - - if (!config->debug_verbose) - return; - - va_start(args, fmt); - vprintf(fmt, args); - va_end(args); -} - -void pr_err(const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - switch (s_log_dest) { - case log_to_syslog: - vsyslog(LOG_DAEMON | LOG_ERR, fmt, args); - break; - case log_to_stderr: - vfprintf(stderr, fmt, args); - break; - } - va_end(args); -} - -static int check_not_equal_str(const char *dir_name, const char *attr, - const char *value) -{ - char attr_value[64]; - int len = strlen(value); - - if (len > sizeof(attr_value)) { - pr_err("string %s is too long\n", value); - return 1; - } - - if (srpd_sys_read_string(dir_name, attr, attr_value, - sizeof(attr_value))) - return 0; - if (strncmp(attr_value, value, len)) - return 1; - - return 0; -} - -static int check_not_equal_int(const char *dir_name, const char *attr, - int value) -{ - char attr_value[64]; - - if (srpd_sys_read_string(dir_name, attr, attr_value, - sizeof(attr_value))) - return 0; - if (value != atoi(attr_value)) - return 1; - - return 0; -} - -static int is_enabled_by_rules_file(struct target_details *target) -{ - int rule; - struct config_t *conf = config; - - if (NULL == conf->rules) - return 1; - - pr_debug("Found an SRP target with id_ext %s - check if it allowed by rules file\n", target->id_ext); - rule = -1; - do { - rule++; - if (conf->rules[rule].id_ext[0] != '\0' && - strtoull(target->id_ext, NULL, 16) != - strtoull(conf->rules[rule].id_ext, NULL, 16)) - continue; - - if (conf->rules[rule].ioc_guid[0] != '\0' && - be64toh(target->ioc_prof.guid) != - strtoull(conf->rules[rule].ioc_guid, NULL, 16)) - continue; - - if (conf->rules[rule].dgid[0] != '\0') { - char tmp = conf->rules[rule].dgid[16]; - conf->rules[rule].dgid[16] = '\0'; - if (strtoull(conf->rules[rule].dgid, NULL, 16) != - target->subnet_prefix) { - conf->rules[rule].dgid[16] = tmp; - continue; - } - conf->rules[rule].dgid[16] = tmp; - if (strtoull(&conf->rules[rule].dgid[16], NULL, 16) != - target->h_guid) - continue; - } - - if (conf->rules[rule].service_id[0] != '\0' && - strtoull(conf->rules[rule].service_id, NULL, 16) != - target->h_service_id) - continue; - - if (conf->rules[rule].pkey[0] != '\0' && - (uint16_t)strtoul(conf->rules[rule].pkey, NULL, 16) != - target->pkey) - continue; - - target->options = conf->rules[rule].options; - - return conf->rules[rule].allow; - - } while (1); -} - - - -static int add_non_exist_target(struct target_details *target) -{ - char scsi_host_dir[50]; - DIR *dir; - struct dirent *subdir; - char *subdir_name_ptr; - int prefix_len; - union umad_gid dgid_val; - char target_config_str[255]; - int len; - int not_connected = 1; - - pr_debug("Found an SRP target with id_ext %s - check if it is already connected\n", target->id_ext); - - strcpy(scsi_host_dir, "/sys/class/scsi_host/"); - dir=opendir(scsi_host_dir); - if (!dir) { - perror("opendir - /sys/class/scsi_host/"); - return -1; - } - prefix_len = strlen(scsi_host_dir); - subdir_name_ptr = scsi_host_dir + prefix_len; - - subdir = (void *) 1; /* Dummy value to enter the loop */ - while (subdir) { - subdir = readdir(dir); - - if (!subdir) - continue; - - if (subdir->d_name[0] == '.') - continue; - - strncpy(subdir_name_ptr, subdir->d_name, - sizeof(scsi_host_dir) - prefix_len); - if (!check_equal_uint64(scsi_host_dir, "id_ext", - strtoull(target->id_ext, NULL, 16))) - continue; - if (!check_equal_uint16(scsi_host_dir, "pkey", target->pkey) && - !config->execute) - continue; - - if (!check_equal_uint64(scsi_host_dir, "service_id", - target->h_service_id)) - continue; - if (!check_equal_uint64(scsi_host_dir, "ioc_guid", - be64toh(target->ioc_prof.guid))) - continue; - if (srpd_sys_read_gid(scsi_host_dir, "orig_dgid", - dgid_val.raw)) { - /* - * In case this is an old kernel that does not have - * orig_dgid in sysfs, use dgid instead (this is - * problematic when there is a dgid redirection - * by the CM) - */ - if (srpd_sys_read_gid(scsi_host_dir, "dgid", - dgid_val.raw)) - continue; - } - if (htobe64(target->subnet_prefix) != - dgid_val.global.subnet_prefix) - continue; - if (htobe64(target->h_guid) != dgid_val.global.interface_id) - continue; - - /* If there is no local_ib_device in the scsi host dir (old kernel module), assumes it is equal */ - if (check_not_equal_str(scsi_host_dir, "local_ib_device", config->dev_name)) - continue; - - /* If there is no local_ib_port in the scsi host dir (old kernel module), assumes it is equal */ - if (check_not_equal_int(scsi_host_dir, "local_ib_port", config->port_num)) - continue; - - /* there is a match - this target is already connected */ - - /* There is a rare possibility of a race in the following - scenario: - a. A link goes down, - b. ib_srp decide to remove the corresponding scsi_host. - c. Before removing it, the link returns - d. srp_daemon gets trap 64. - e. srp_daemon thinks that this target is still - connected (ib_srp has not removed it yet) so it - does not connect to it. - f. ib_srp continue to remove the scsi_host. - As a result there is no connection to a target in the fabric - and there will not be a new trap. - - To solve this race we schedule here another call to check - if this target exist in the near future. - */ - - - - /* If there is a need to print all we will continue to pr_cmd. - not_connected is set to zero to make sure that this target - will be printed but not connected. - */ - if (config->all) { - not_connected = 0; - break; - } - - pr_debug("This target is already connected - skip\n"); - closedir(dir); - - return 0; - - } - - len = snprintf(target_config_str, sizeof(target_config_str), "id_ext=%s," - "ioc_guid=%016llx," - "dgid=%016llx%016llx," - "pkey=%04x," - "service_id=%016llx", - target->id_ext, - (unsigned long long) be64toh(target->ioc_prof.guid), - (unsigned long long) target->subnet_prefix, - (unsigned long long) target->h_guid, - target->pkey, - (unsigned long long) target->h_service_id); - if (len >= sizeof(target_config_str)) { - pr_err("Target config string is too long, ignoring target\n"); - closedir(dir); - return -1; - } - - if (target->ioc_prof.io_class != htobe16(SRP_REV16A_IB_IO_CLASS)) { - len += snprintf(target_config_str+len, - sizeof(target_config_str) - len, - ",io_class=%04hx", be16toh(target->ioc_prof.io_class)); - - if (len >= sizeof(target_config_str)) { - pr_err("Target config string is too long, ignoring target\n"); - closedir(dir); - return -1; - } - } - - if (config->print_initiator_ext) { - len += snprintf(target_config_str+len, - sizeof(target_config_str) - len, - ",initiator_ext=%016llx", - (unsigned long long) target->h_guid); - - if (len >= sizeof(target_config_str)) { - pr_err("Target config string is too long, ignoring target\n"); - closedir(dir); - return -1; - } - } - - if (config->execute && config->tl_retry_count) { - len += snprintf(target_config_str + len, - sizeof(target_config_str) - len, - ",tl_retry_count=%d", config->tl_retry_count); - - if (len >= sizeof(target_config_str)) { - pr_err("Target config string is too long, ignoring target\n"); - closedir(dir); - return -1; - } - } - - if (target->options) { - len += snprintf(target_config_str+len, - sizeof(target_config_str) - len, - "%s", - target->options); - - if (len >= sizeof(target_config_str)) { - pr_err("Target config string is too long, ignoring target\n"); - closedir(dir); - return -1; - } - } - - target_config_str[len] = '\0'; - - pr_cmd(target_config_str, not_connected); - - closedir(dir); - - return 1; -} - -static int send_and_get(int portid, int agent, struct srp_ib_user_mad *out_mad, - struct srp_ib_user_mad *in_mad, int in_mad_size) -{ - struct umad_dm_packet *out_dm_mad = (void *) out_mad->hdr.data; - struct umad_dm_packet *in_dm_mad = (void *) in_mad->hdr.data; - int i, len; - int in_agent; - int ret; - static uint32_t tid; - uint32_t received_tid; - - for (i = 0; i < config->mad_retries; ++i) { - /* Skip tid 0 because OpenSM ignores it. */ - if (++tid == 0) - ++tid; - out_dm_mad->mad_hdr.tid = htobe64(tid); - - ret = umad_send(portid, agent, out_mad, MAD_BLOCK_SIZE, - config->timeout, 0); - if (ret < 0) { - pr_err("umad_send to %u failed\n", - (uint16_t) be16toh(out_mad->hdr.addr.lid)); - return ret; - } - - do { -recv: - len = in_mad_size ? in_mad_size : MAD_BLOCK_SIZE; - in_agent = umad_recv(portid, (struct ib_user_mad *) in_mad, - &len, config->timeout); - if (in_agent < 0) { - pr_err("umad_recv from %u failed - %d\n", - (uint16_t) be16toh(out_mad->hdr.addr.lid), - in_agent); - return in_agent; - } - if (in_agent != agent) { - pr_debug("umad_recv returned different agent\n"); - goto recv; - } - - ret = umad_status(in_mad); - if (ret) { - pr_err( - "bad MAD status (%u) from lid %#x\n", - ret, be16toh(out_mad->hdr.addr.lid)); - return -ret; - } - - received_tid = be64toh(in_dm_mad->mad_hdr.tid); - if (tid != received_tid) - pr_debug("umad_recv returned different transaction id sent %d got %d\n", - tid, received_tid); - - } while ((int32_t)(tid - received_tid) > 0); - - if (len > 0) - return len; - } - - return -1; -} - -static void initialize_sysfs(void) -{ - char *env; - - env = getenv("SYSFS_PATH"); - if (env) { - int len; - char *dup; - - sysfs_path = dup = strndup(env, 256); - len = strlen(dup); - while (len > 0 && dup[len - 1] == '/') { - --len; - dup[len] = '\0'; - } - } -} - -static int translate_umad_to_ibdev_and_port(char *umad_dev, char **ibdev, - char **ibport) -{ - char *class_dev_path; - char *umad_dev_name; - int ret; - - *ibdev = NULL; - *ibport = NULL; - - umad_dev_name = rindex(umad_dev, '/'); - if (!umad_dev_name) { - pr_err("Couldn't find device name in '%s'\n", - umad_dev_name); - return -1; - } - - ret = asprintf(&class_dev_path, "%s/class/infiniband_mad/%s", sysfs_path, - umad_dev_name); - - if (ret < 0) { - pr_err("out of memory\n"); - return -ENOMEM; - } - - *ibdev = malloc(IBDEV_STR_SIZE); - if (!*ibdev) { - pr_err("out of memory\n"); - ret = -ENOMEM; - goto end; - } - - if (srpd_sys_read_string(class_dev_path, "ibdev", *ibdev, - IBDEV_STR_SIZE) < 0) { - pr_err("Couldn't read ibdev attribute\n"); - ret = -1; - goto end; - } - - *ibport = malloc(IBPORT_STR_SIZE); - if (!*ibport) { - pr_err("out of memory\n"); - ret = -ENOMEM; - goto end; - } - if (srpd_sys_read_string(class_dev_path, "port", *ibport, IBPORT_STR_SIZE) < 0) { - pr_err("Couldn't read port attribute\n"); - ret = -1; - goto end; - } - - ret = 0; - -end: - if (ret) { - free(*ibport); - free(*ibdev); - } - free(class_dev_path); - - return ret; -} - -static void init_srp_mad(struct srp_ib_user_mad *out_umad, int agent, - uint16_t h_dlid, uint16_t h_attr_id, uint32_t h_attr_mod) -{ - struct umad_dm_packet *out_mad; - - memset(out_umad, 0, sizeof *out_umad); - - out_umad->hdr.agent_id = agent; - out_umad->hdr.addr.qpn = htobe32(1); - out_umad->hdr.addr.qkey = htobe32(UMAD_QKEY); - out_umad->hdr.addr.lid = htobe16(h_dlid); - - out_mad = (void *) out_umad->hdr.data; - - out_mad->mad_hdr.base_version = UMAD_BASE_VERSION; - out_mad->mad_hdr.method = UMAD_METHOD_GET; - out_mad->mad_hdr.attr_id = htobe16(h_attr_id); - out_mad->mad_hdr.attr_mod = htobe32(h_attr_mod); -} - -static void init_srp_dm_mad(struct srp_ib_user_mad *out_mad, int agent, uint16_t h_dlid, - uint16_t h_attr_id, uint32_t h_attr_mod) -{ - struct umad_sa_packet *out_dm_mad = get_data_ptr(*out_mad); - - init_srp_mad(out_mad, agent, h_dlid, h_attr_id, h_attr_mod); - out_dm_mad->mad_hdr.mgmt_class = UMAD_CLASS_DEVICE_MGMT; - out_dm_mad->mad_hdr.class_version = 1; -} - -static void init_srp_sa_mad(struct srp_ib_user_mad *out_mad, int agent, uint16_t h_dlid, - uint16_t h_attr_id, uint32_t h_attr_mod) -{ - struct umad_sa_packet *out_sa_mad = get_data_ptr(*out_mad); - - init_srp_mad(out_mad, agent, h_dlid, h_attr_id, h_attr_mod); - out_sa_mad->mad_hdr.mgmt_class = UMAD_CLASS_SUBN_ADM; - out_sa_mad->mad_hdr.class_version = UMAD_SA_CLASS_VERSION; -} - -static int check_sm_cap(struct umad_resources *umad_res, int *mask_match) -{ - struct srp_ib_user_mad out_mad, in_mad; - struct umad_sa_packet *in_sa_mad; - struct umad_class_port_info *cpi; - int ret; - - in_sa_mad = get_data_ptr(in_mad); - - init_srp_sa_mad(&out_mad, umad_res->agent, umad_res->sm_lid, - UMAD_ATTR_CLASS_PORT_INFO, 0); - - ret = send_and_get(umad_res->portid, umad_res->agent, &out_mad, &in_mad, 0); - if (ret < 0) - return ret; - - cpi = (void *) in_sa_mad->data; - - *mask_match = !!(be16toh(cpi->cap_mask) & SRP_SM_SUPPORTS_MASK_MATCH); - - return 0; -} - -static int set_class_port_info(struct umad_resources *umad_res, uint16_t dlid) -{ - struct srp_ib_user_mad in_mad, out_mad; - struct umad_dm_packet *out_dm_mad, *in_dm_mad; - struct umad_class_port_info *cpi; - char val[64]; - int i; - - init_srp_dm_mad(&out_mad, umad_res->agent, dlid, UMAD_ATTR_CLASS_PORT_INFO, 0); - - out_dm_mad = get_data_ptr(out_mad); - out_dm_mad->mad_hdr.method = UMAD_METHOD_SET; - - cpi = (void *) out_dm_mad->data; - - if (srpd_sys_read_string(umad_res->port_sysfs_path, "lid", val, sizeof val) < 0) { - pr_err("Couldn't read LID\n"); - return -1; - } - - cpi->trap_lid = htobe16(strtol(val, NULL, 0)); - - if (srpd_sys_read_string(umad_res->port_sysfs_path, "gids/0", val, sizeof val) < 0) { - pr_err("Couldn't read GID[0]\n"); - return -1; - } - - for (i = 0; i < 8; ++i) - cpi->trapgid.raw_be16[i] = htobe16(strtol(val + i * 5, NULL, 16)); - - if (send_and_get(umad_res->portid, umad_res->agent, &out_mad, &in_mad, 0) < 0) - return -1; - - in_dm_mad = get_data_ptr(in_mad); - if (in_dm_mad->mad_hdr.status) { - pr_err("Class Port Info set returned status 0x%04x\n", - be16toh(in_dm_mad->mad_hdr.status)); - return -1; - } - - return 0; -} - -static int get_iou_info(struct umad_resources *umad_res, uint16_t dlid, - struct srp_dm_iou_info *iou_info) -{ - struct srp_ib_user_mad in_mad, out_mad; - struct umad_dm_packet *in_dm_mad; - - init_srp_dm_mad(&out_mad, umad_res->agent, dlid, SRP_DM_ATTR_IO_UNIT_INFO, 0); - - if (send_and_get(umad_res->portid, umad_res->agent, &out_mad, &in_mad, 0) < 0) - return -1; - - in_dm_mad = get_data_ptr(in_mad); - if (in_dm_mad->mad_hdr.status) { - pr_err("IO Unit Info query returned status 0x%04x\n", - be16toh(in_dm_mad->mad_hdr.status)); - return -1; - } - - memcpy(iou_info, in_dm_mad->data, sizeof *iou_info); -/* - pr_debug("iou_info->max_controllers is %d\n", iou_info->max_controllers); -*/ - return 0; -} - -static int get_ioc_prof(struct umad_resources *umad_res, uint16_t h_dlid, int ioc, - struct srp_dm_ioc_prof *ioc_prof) -{ - struct srp_ib_user_mad in_mad, out_mad; - struct umad_dm_packet *in_dm_mad; - - init_srp_dm_mad(&out_mad, umad_res->agent, h_dlid, SRP_DM_ATTR_IO_CONTROLLER_PROFILE, ioc); - - if (send_and_get(umad_res->portid, umad_res->agent, &out_mad, &in_mad, 0) < 0) - return -1; - - in_dm_mad = get_data_ptr(in_mad); - if (in_dm_mad->mad_hdr.status) { - pr_err("IO Controller Profile query returned status 0x%04x for %d\n", - be16toh(in_dm_mad->mad_hdr.status), ioc); - return -1; - } - - memcpy(ioc_prof, in_dm_mad->data, sizeof *ioc_prof); - - return 0; -} - -static int get_svc_entries(struct umad_resources *umad_res, uint16_t dlid, int ioc, - int start, int end, struct srp_dm_svc_entries *svc_entries) -{ - struct srp_ib_user_mad in_mad, out_mad; - struct umad_dm_packet *in_dm_mad; - - init_srp_dm_mad(&out_mad, umad_res->agent, dlid, SRP_DM_ATTR_SERVICE_ENTRIES, - (ioc << 16) | (end << 8) | start); - - if (send_and_get(umad_res->portid, umad_res->agent, &out_mad, &in_mad, 0) < 0) - return -1; - - in_dm_mad = get_data_ptr(in_mad); - if (in_dm_mad->mad_hdr.status) { - pr_err("Service Entries query returned status 0x%04x\n", - be16toh(in_dm_mad->mad_hdr.status)); - return -1; - } - - memcpy(svc_entries, in_dm_mad->data, sizeof *svc_entries); - - return 0; -} - -static int do_port(struct resources *res, uint16_t pkey, uint16_t dlid, - uint64_t subnet_prefix, uint64_t h_guid) -{ - struct umad_resources *umad_res = res->umad_res; - struct srp_dm_iou_info iou_info; - struct srp_dm_svc_entries svc_entries; - int i, j, k, ret; - - static const uint64_t topspin_oui = 0x0005ad0000000000ull; - static const uint64_t oui_mask = 0xffffff0000000000ull; - - struct target_details *target = (struct target_details *) - malloc(sizeof(struct target_details)); - - target->subnet_prefix = subnet_prefix; - target->h_guid = h_guid; - target->options = NULL; - - pr_debug("enter do_port\n"); - if ((target->h_guid & oui_mask) == topspin_oui && - set_class_port_info(umad_res, dlid)) - pr_err("Warning: set of ClassPortInfo failed\n"); - - ret = get_iou_info(umad_res, dlid, &iou_info); - if (ret < 0) { - pr_err("failed to get iou info for dlid %#x\n", dlid); - goto out; - } - - pr_human("IO Unit Info:\n"); - pr_human(" port LID: %04x\n", dlid); - pr_human(" port GID: %016llx%016llx\n", - (unsigned long long) target->subnet_prefix, - (unsigned long long) target->h_guid); - pr_human(" change ID: %04x\n", be16toh(iou_info.change_id)); - pr_human(" max controllers: 0x%02x\n", iou_info.max_controllers); - - if (config->verbose > 0) - for (i = 0; i < iou_info.max_controllers; ++i) { - pr_human(" controller[%3d]: ", i + 1); - switch ((iou_info.controller_list[i / 2] >> - (4 * (1 - i % 2))) & 0xf) { - case SRP_DM_NO_IOC: pr_human("not installed\n"); break; - case SRP_DM_IOC_PRESENT: pr_human("present\n"); break; - case SRP_DM_NO_SLOT: pr_human("no slot\n"); break; - default: pr_human("\n"); break; - } - } - - for (i = 0; i < iou_info.max_controllers; ++i) { - if (((iou_info.controller_list[i / 2] >> (4 * (1 - i % 2))) & 0xf) == - SRP_DM_IOC_PRESENT) { - pr_human("\n"); - - if (get_ioc_prof(umad_res, dlid, i + 1, &target->ioc_prof)) - continue; - - pr_human(" controller[%3d]\n", i + 1); - - pr_human(" GUID: %016llx\n", - (unsigned long long) be64toh(target->ioc_prof.guid)); - pr_human(" vendor ID: %06x\n", be32toh(target->ioc_prof.vendor_id) >> 8); - pr_human(" device ID: %06x\n", be32toh(target->ioc_prof.device_id)); - pr_human(" IO class : %04hx\n", be16toh(target->ioc_prof.io_class)); - pr_human(" ID: %s\n", target->ioc_prof.id); - pr_human(" service entries: %d\n", target->ioc_prof.service_entries); - - for (j = 0; j < target->ioc_prof.service_entries; j += 4) { - int n; - - n = j + 3; - if (n >= target->ioc_prof.service_entries) - n = target->ioc_prof.service_entries - 1; - - if (get_svc_entries(umad_res, dlid, i + 1, - j, n, &svc_entries)) - continue; - - for (k = 0; k <= n - j; ++k) { - - if (sscanf(svc_entries.service[k].name, - "SRP.T10:%16s", - target->id_ext) != 1) - continue; - - pr_human(" service[%3d]: %016llx / %s\n", - j + k, - (unsigned long long) be64toh(svc_entries.service[k].id), - svc_entries.service[k].name); - - target->h_service_id = be64toh(svc_entries.service[k].id); - target->pkey = pkey; - if (is_enabled_by_rules_file(target)) { - if (!add_non_exist_target(target) && !config->once) { - target->retry_time = - time(NULL) + config->retry_timeout; - push_to_retry_list(res->sync_res, target); - } - } - } - } - } - } - - pr_human("\n"); - -out: - free(target); - return ret; -} - -int get_node(struct umad_resources *umad_res, uint16_t dlid, uint64_t *guid) -{ - struct srp_ib_user_mad out_mad, in_mad; - struct umad_sa_packet *out_sa_mad, *in_sa_mad; - struct srp_sa_node_rec *node; - - in_sa_mad = get_data_ptr(in_mad); - out_sa_mad = get_data_ptr(out_mad); - - init_srp_sa_mad(&out_mad, umad_res->agent, umad_res->sm_lid, - UMAD_SA_ATTR_NODE_REC, 0); - - out_sa_mad->comp_mask = htobe64(1); /* LID */ - node = (void *) out_sa_mad->data; - node->lid = htobe16(dlid); - - if (send_and_get(umad_res->portid, umad_res->agent, &out_mad, &in_mad, 0) < 0) - return -1; - - node = (void *) in_sa_mad->data; - *guid = be64toh(node->port_guid); - - return 0; -} - -static int get_port_info(struct umad_resources *umad_res, uint16_t dlid, - uint64_t *subnet_prefix, int *isdm) -{ - struct srp_ib_user_mad out_mad, in_mad; - struct umad_sa_packet *out_sa_mad, *in_sa_mad; - struct srp_sa_port_info_rec *port_info; - - in_sa_mad = get_data_ptr(in_mad); - out_sa_mad = get_data_ptr(out_mad); - - init_srp_sa_mad(&out_mad, umad_res->agent, umad_res->sm_lid, - UMAD_SA_ATTR_PORT_INFO_REC, 0); - - out_sa_mad->comp_mask = htobe64(1); /* LID */ - port_info = (void *) out_sa_mad->data; - port_info->endport_lid = htobe16(dlid); - - if (send_and_get(umad_res->portid, umad_res->agent, &out_mad, &in_mad, 0) < 0) - return -1; - - port_info = (void *) in_sa_mad->data; - *subnet_prefix = be64toh(port_info->subnet_prefix); - *isdm = !!(be32toh(port_info->capability_mask) & SRP_IS_DM); - - return 0; -} - -int pkey_index_to_pkey(struct umad_resources *umad_res, int pkey_index, - uint16_t *pkey) -{ - char pkey_file[16], pkey_str[16]; - - /* Read pkey */ - snprintf(pkey_file, sizeof(pkey_file), "pkeys/%d", pkey_index); - if (srpd_sys_read_string(umad_res->port_sysfs_path, pkey_file, - pkey_str, sizeof(pkey_str)) < 0) - return -1; - - *pkey = strtoul(pkey_str, NULL, 0); - if (*pkey) - pr_debug("discover Targets for P_key %04x (index %d)\n", - *pkey, pkey_index); - return 0; -} - -static int get_shared_pkeys(struct resources *res, - uint16_t dest_port_lid, - uint16_t *pkeys) -{ - struct umad_resources *umad_res = res->umad_res; - uint8_t *in_mad_buf; - struct srp_ib_user_mad out_mad; - struct ib_user_mad *in_mad; - struct umad_sa_packet *out_sa_mad, *in_sa_mad; - struct ib_path_rec *path_rec; - ssize_t len; - int i, num_pkeys = 0; - uint16_t pkey; - uint16_t local_port_lid = get_port_lid(res->ud_res->ib_ctx, - config->port_num); - - in_mad_buf = malloc(sizeof(struct ib_user_mad) + - node_table_response_size); - if (!in_mad_buf) - return -ENOMEM; - - in_mad = (void *)in_mad_buf; - in_sa_mad = (void *)in_mad->data; - out_sa_mad = get_data_ptr(out_mad); - - init_srp_sa_mad(&out_mad, umad_res->agent, umad_res->sm_lid, - UMAD_SA_ATTR_PATH_REC, 0); - - /** - * Due to OpenSM bug (issue #335016) SM won't return - * table of all shared P_Keys, it will return only the first - * shared P_Key, So we send path_rec over each P_Key in the P_Key - * table. SM will return path record if P_Key is shared or else None. - * Once SM bug will be fixed, this loop should be removed. - **/ - for (i = 0; ; i++) { - if (pkey_index_to_pkey(umad_res, i, &pkey)) - break; - if (!pkey) - continue; - - /* Mark components: DLID, SLID, PKEY */ - out_sa_mad->comp_mask = htobe64(1 << 4 | 1 << 5 | 1 << 13); - path_rec = (struct ib_path_rec *)out_sa_mad->data; - path_rec->slid = htobe16(local_port_lid); - path_rec->dlid = htobe16(dest_port_lid); - path_rec->pkey = htobe16(pkey); - - len = send_and_get(umad_res->portid, umad_res->agent, &out_mad, - (struct srp_ib_user_mad *)in_mad, - node_table_response_size); - if (len < 0) - goto err; - - path_rec = (struct ib_path_rec *)in_sa_mad->data; - pkeys[num_pkeys++] = be16toh(path_rec->pkey); - } - - free(in_mad_buf); - return num_pkeys; -err: - free(in_mad_buf); - return -1; -} - -static int do_dm_port_list(struct resources *res) -{ - struct umad_resources *umad_res = res->umad_res; - uint8_t *in_mad_buf; - struct srp_ib_user_mad out_mad; - struct ib_user_mad *in_mad; - struct umad_sa_packet *out_sa_mad, *in_sa_mad; - struct srp_sa_port_info_rec *port_info; - ssize_t len; - int size; - int i, j,num_pkeys; - uint16_t pkeys[SRP_MAX_SHARED_PKEYS]; - uint64_t guid; - - in_mad_buf = malloc(sizeof(struct ib_user_mad) + - node_table_response_size); - if (!in_mad_buf) - return -ENOMEM; - - in_mad = (void *) in_mad_buf; - in_sa_mad = (void *) in_mad->data; - out_sa_mad = get_data_ptr(out_mad); - - init_srp_sa_mad(&out_mad, umad_res->agent, umad_res->sm_lid, - UMAD_SA_ATTR_PORT_INFO_REC, SRP_SM_CAP_MASK_MATCH_ATTR_MOD); - - out_sa_mad->mad_hdr.method = UMAD_SA_METHOD_GET_TABLE; - out_sa_mad->comp_mask = htobe64(1 << 7); /* Capability mask */ - out_sa_mad->rmpp_hdr.rmpp_version = UMAD_RMPP_VERSION; - out_sa_mad->rmpp_hdr.rmpp_type = 1; - port_info = (void *) out_sa_mad->data; - port_info->capability_mask = htobe32(SRP_IS_DM); /* IsDM */ - - len = send_and_get(umad_res->portid, umad_res->agent, &out_mad, - (struct srp_ib_user_mad *) in_mad, - node_table_response_size); - if (len < 0) { - free(in_mad_buf); - return len; - } - - size = ib_get_attr_size(in_sa_mad->attr_offset); - if (!size) { - if (config->verbose) { - printf("Query did not find any targets\n"); - } - free(in_mad_buf); - return 0; - } - - for (i = 0; (i + 1) * size <= len - MAD_RMPP_HDR_SIZE; ++i) { - port_info = (void *) in_sa_mad->data + i * size; - if (get_node(umad_res, be16toh(port_info->endport_lid), &guid)) - continue; - - num_pkeys = get_shared_pkeys(res, be16toh(port_info->endport_lid), - pkeys); - if (num_pkeys < 0) { - pr_err("failed to get shared P_Keys with LID %#x\n", - be16toh(port_info->endport_lid)); - free(in_mad_buf); - return num_pkeys; - } - - for (j = 0; j < num_pkeys; ++j) - do_port(res, pkeys[j], be16toh(port_info->endport_lid), - be64toh(port_info->subnet_prefix), guid); - } - - free(in_mad_buf); - return 0; -} - -void handle_port(struct resources *res, uint16_t pkey, uint16_t lid, uint64_t h_guid) -{ - struct umad_resources *umad_res = res->umad_res; - uint64_t subnet_prefix; - int isdm; - - pr_debug("enter handle_port for lid %#x\n", lid); - if (get_port_info(umad_res, lid, &subnet_prefix, &isdm)) - return; - - if (!isdm) - return; - - do_port(res, pkey, lid, subnet_prefix, h_guid); -} - - -static int do_full_port_list(struct resources *res) -{ - struct umad_resources *umad_res = res->umad_res; - uint8_t *in_mad_buf; - struct srp_ib_user_mad out_mad; - struct ib_user_mad *in_mad; - struct umad_sa_packet *out_sa_mad, *in_sa_mad; - struct srp_sa_node_rec *node; - ssize_t len; - int size; - int i, j, num_pkeys; - uint16_t pkeys[SRP_MAX_SHARED_PKEYS]; - - in_mad_buf = malloc(sizeof(struct ib_user_mad) + - node_table_response_size); - if (!in_mad_buf) - return -ENOMEM; - - in_mad = (void *) in_mad_buf; - in_sa_mad = (void *) in_mad->data; - out_sa_mad = get_data_ptr(out_mad); - - init_srp_sa_mad(&out_mad, umad_res->agent, umad_res->sm_lid, - UMAD_SA_ATTR_NODE_REC, 0); - - out_sa_mad->mad_hdr.method = UMAD_SA_METHOD_GET_TABLE; - out_sa_mad->comp_mask = 0; /* Get all end ports */ - out_sa_mad->rmpp_hdr.rmpp_version = UMAD_RMPP_VERSION; - out_sa_mad->rmpp_hdr.rmpp_type = 1; - - len = send_and_get(umad_res->portid, umad_res->agent, &out_mad, - (struct srp_ib_user_mad *) in_mad, - node_table_response_size); - if (len < 0) { - free(in_mad_buf); - return len; - } - - size = be16toh(in_sa_mad->attr_offset) * 8; - - for (i = 0; (i + 1) * size <= len - MAD_RMPP_HDR_SIZE; ++i) { - node = (void *) in_sa_mad->data + i * size; - - num_pkeys = get_shared_pkeys(res, be16toh(node->lid), - pkeys); - if (num_pkeys < 0) { - pr_err("failed to get shared P_Keys with LID %#x\n", - be16toh(node->lid)); - free(in_mad_buf); - return num_pkeys; - } - - for (j = 0; j < num_pkeys; ++j) - (void) handle_port(res, pkeys[j], be16toh(node->lid), - be64toh(node->port_guid)); - } - - free(in_mad_buf); - return 0; -} - -struct config_t *config; - -static void print_config(struct config_t *conf) -{ - printf(" configuration report\n"); - printf(" ------------------------------------------------\n"); - printf(" Current pid : %u\n", getpid()); - printf(" Device name : \"%s\"\n", conf->dev_name); - printf(" IB port : %u\n", conf->port_num); - printf(" Mad Retries : %d\n", conf->mad_retries); - printf(" Number of outstanding WR : %u\n", conf->num_of_oust); - printf(" Mad timeout (msec) : %u\n", conf->timeout); - printf(" Prints add target command : %d\n", conf->cmd); - printf(" Executes add target command : %d\n", conf->execute); - printf(" Print also connected targets : %d\n", conf->all); - printf(" Report current targets and stop : %d\n", conf->once); - if (conf->rules_file) - printf(" Reads rules from : %s\n", conf->rules_file); - if (conf->print_initiator_ext) - printf(" Print initiator_ext\n"); - else - printf(" Do not print initiator_ext\n"); - if (conf->recalc_time) - printf(" Performs full target rescan every %d seconds\n", conf->recalc_time); - else - printf(" No full target rescan\n"); - if (conf->retry_timeout) - printf(" Retries to connect to existing target after %d seconds\n", conf->retry_timeout); - else - printf(" Do not retry to connect to existing targets\n"); - printf(" ------------------------------------------------\n"); -} - -static char *copy_till_comma(char *d, char *s, int len, int base) -{ - int i=0; - - while (strchr(", \t\n", *s) == NULL) { - if (i == len) - return NULL; - if ((base == 16 && isxdigit(*s)) || (base == 10 && isdigit(*s))) { - *d=*s; - ++d; - ++s; - ++i; - } else - return NULL; - } - *d='\0'; - - if (*s == '\n') - return s; - - ++s; - return s; -} - -static char *parse_main_option(struct rule *rule, char *ptr) -{ - struct option_info { - const char *name; - size_t offset; - size_t len; - int base; - }; -#define OPTION_INFO(n, base) { #n "=", offsetof(struct rule, n), \ - sizeof(((struct rule *)NULL)->n), base} - static const struct option_info opt_info[] = { - OPTION_INFO(id_ext, 16), - OPTION_INFO(ioc_guid, 16), - OPTION_INFO(dgid, 16), - OPTION_INFO(service_id, 16), - OPTION_INFO(pkey, 16), - }; - int i, optnamelen; - char *ptr2 = NULL; - - for (i = 0; i < sizeof(opt_info) / sizeof(opt_info[0]); i++) { - optnamelen = strlen(opt_info[i].name); - if (strncmp(ptr, opt_info[i].name, optnamelen) == 0) { - ptr2 = copy_till_comma((char *)rule - + opt_info[i].offset, - ptr + optnamelen, - opt_info[i].len - 1, - opt_info[i].base); - break; - } - } - - return ptr2; -} - -/* - * Return values: - * -1 if the output buffer is not large enough. - * 0 if an unsupported option has been encountered. - * > 0 if parsing succeeded. - */ -static int parse_other_option(struct rule *rule, char *ptr) -{ - static const char *const opt[] = { - "allow_ext_sg=", - "cmd_sg_entries=", - "comp_vector=", - "max_cmd_per_lun=", - "max_sect=", - "queue_size=", - "sg_tablesize=", - "tl_retry_count=", - }; - - char *ptr2 = NULL, *optr, option[17]; - int i, optnamelen, len, left; - - optr = rule->options; - left = sizeof(rule->options); - len = strlen(optr); - optr += len; - left -= len; - for (i = 0; i < sizeof(opt)/sizeof(opt[0]); ++i) { - optnamelen = strlen(opt[i]); - if (strncmp(ptr, opt[i], optnamelen) != 0) - continue; - ptr2 = copy_till_comma(option, ptr + optnamelen, - sizeof(option) - 1, 10); - if (!ptr2) - return -1; - len = snprintf(optr, left, ",%s%s", opt[i], option); - optr += len; - left -= len; - if (left <= 0) - return -1; - break; - } - return ptr2 ? ptr2 - ptr : 0; -} - -static int get_rules_file(struct config_t *conf) -{ - int line_number = 1, len, line_number_for_output, ret = -1; - char line[255]; - char *ptr, *ptr2; - struct rule *rule; - FILE *infile = fopen(conf->rules_file, "r"); - - if (infile == NULL) { - pr_debug("Could not find rules file %s, going with default\n", - conf->rules_file); - return 0; - } - - while (fgets(line, sizeof(line), infile) != NULL) { - if (line[0] != '#' && line[0] != '\n') - line_number++; - } - - if (fseek(infile, 0L, SEEK_SET) != 0) { - pr_err("internal error while seeking %s\n", conf->rules_file); - goto out; - } - - conf->rules = malloc(sizeof(struct rule) * line_number); - - rule = &conf->rules[0] - 1; - line_number_for_output = 0; - while (fgets(line, sizeof(line), infile) != NULL) { - line_number_for_output++; - if (line[0] == '#' || line[0] == '\n') - continue; - - rule++; - switch (line[0]) { - case 'a': - case 'A': - rule->allow = 1; - break; - case 'd': - case 'D': - rule->allow = 0; - break; - default: - pr_err("Bad syntax in rules file %s line %d:" - " line should start with 'a' or 'd'\n", - conf->rules_file, line_number_for_output); - goto out; - } - - rule->id_ext[0] = '\0'; - rule->ioc_guid[0] = '\0'; - rule->dgid[0] = '\0'; - rule->service_id[0] = '\0'; - rule->pkey[0] = '\0'; - rule->options[0] = '\0'; - - ptr = &line[1]; - while (*ptr == ' ' || *ptr == '\t') - ptr++; - - while (*ptr != '\n') { - ptr2 = parse_main_option(rule, ptr); - if (!ptr2 && rule->allow) { - len = parse_other_option(rule, ptr); - if (len < 0) { - pr_err("Buffer overflow triggered by" - " rules file %s line %d\n", - conf->rules_file, - line_number_for_output); - goto out; - } - ptr2 = len ? ptr + len : NULL; - } - - if (ptr2 == NULL) { - pr_err("Bad syntax in rules file %s line %d\n", - conf->rules_file, line_number_for_output); - goto out; - } - ptr = ptr2; - - while (*ptr == ' ' || *ptr == '\t') - ptr++; - } - } - rule++; - rule->id_ext[0] = '\0'; - rule->ioc_guid[0] = '\0'; - rule->dgid[0] = '\0'; - rule->service_id[0] = '\0'; - rule->pkey[0] = '\0'; - rule->options[0] = '\0'; - rule->allow = 1; - ret = 0; - -out: - fclose(infile); - - return ret; -} - -static int set_conf_dev_and_port(char *umad_dev, struct config_t *conf) -{ - int ret; - - if (umad_dev) { - char *ibport; - - ret = translate_umad_to_ibdev_and_port(umad_dev, - &conf->dev_name, - &ibport); - if (ret) { - pr_err("Fail to translate umad to ibdev and port\n"); - goto out; - } - conf->port_num = atoi(ibport); - if (conf->port_num == 0) { - pr_err("Bad port number %s\n", ibport); - ret = -1; - } - free(ibport); - } else { - umad_ca_t ca; - umad_port_t port; - - ret = umad_get_ca(NULL, &ca); - if (ret) { - pr_err("Failed to get default CA\n"); - goto out; - } - - ret = umad_get_port(ca.ca_name, 0, &port); - if (ret) { - pr_err("Failed to get default port for CA %s\n", - ca.ca_name); - umad_release_ca(&ca); - goto out; - } - conf->dev_name = strdup(ca.ca_name); - conf->port_num = port.portnum; - umad_release_port(&port); - umad_release_ca(&ca); - pr_debug("Using device %s port %d\n", conf->dev_name, - conf->port_num); - } -out: - return ret; -} - -static const struct option long_opts[] = { - { "systemd", 0, NULL, 'S' }, - {} -}; -static const char short_opts[] = "caveod:i:j:p:t:r:R:T:l:Vhnf:"; - -/* Check if the --systemd options was passed in very early so we can setup - * logging properly. - */ -static bool is_systemd(int argc, char *argv[]) -{ - while (1) { - int c; - - c = getopt_long(argc, argv, short_opts, long_opts, NULL); - if (c == -1) - break; - if (c == 'S') - return true; - - } - return false; -} - -static int get_config(struct config_t *conf, int argc, char *argv[]) -{ - /* set defaults */ - char* umad_dev = NULL; - int ret; - - conf->port_num = 1; - conf->num_of_oust = 10; - conf->dev_name = NULL; - conf->cmd = 0; - conf->once = 0; - conf->execute = 0; - conf->all = 0; - conf->verbose = 0; - conf->debug_verbose = 0; - conf->timeout = 5000; - conf->mad_retries = 3; - conf->recalc_time = 0; - conf->retry_timeout = 20; - conf->add_target_file = NULL; - conf->print_initiator_ext = 0; - conf->rules_file = SRP_DEAMON_CONFIG_FILE; - conf->rules = NULL; - conf->tl_retry_count = 0; - - optind = 1; - while (1) { - int c; - - c = getopt_long(argc, argv, short_opts, long_opts, NULL); - if (c == -1) - break; - - switch (c) { - case 'd': - umad_dev = optarg; - break; - case 'i': - conf->dev_name = strdup(optarg); - if (!conf->dev_name) { - pr_err("Fail to alloc space for dev_name\n"); - return -ENOMEM; - } - break; - case 'p': - conf->port_num = atoi(optarg); - if (conf->port_num == 0) { - pr_err("Bad port number %s\n", optarg); - return -1; - } - break; - case 'j': { - char dev[32]; - int port_num; - - if (sscanf(optarg, "%31[^:]:%d", dev, &port_num) != 2) { - pr_err("Bad dev:port specification %s\n", - optarg); - return -1; - } - conf->dev_name = strdup(dev); - conf->port_num = port_num; - } - break; - case 'c': - ++conf->cmd; - break; - case 'o': - ++conf->once; - break; - case 'a': - ++conf->all; - break; - case 'e': - ++conf->execute; - break; - case 'v': - ++conf->verbose; - break; - case 'V': - ++conf->debug_verbose; - break; - case 'n': - ++conf->print_initiator_ext; - break; - case 't': - conf->timeout = atoi(optarg); - if (conf->timeout == 0) { - pr_err("Bad timeout - %s\n", optarg); - return -1; - } - break; - case 'r': - conf->mad_retries = atoi(optarg); - if (conf->mad_retries == 0) { - pr_err("Bad number of retries - %s\n", optarg); - return -1; - } - break; - case 'R': - conf->recalc_time = atoi(optarg); - if (conf->recalc_time == 0) { - pr_err("Bad Rescan time window - %s\n", optarg); - return -1; - } - break; - case 'T': - conf->retry_timeout = atoi(optarg); - if (conf->retry_timeout == 0 && strcmp(optarg, "0")) { - pr_err("Bad retry Timeout value- %s.\n", optarg); - return -1; - } - break; - case 'f': - conf->rules_file = optarg; - break; - case 'l': - conf->tl_retry_count = atoi(optarg); - if (conf->tl_retry_count < 2 || - conf->tl_retry_count > 7) { - pr_err("Bad tl_retry_count argument (%d), " - "must be 2 <= tl_retry_count <= 7\n", - conf->tl_retry_count); - return -1; - } - break; - case 'S': - break; - case 'h': - default: - usage(argv[0]); - return -1; - } - } - - initialize_sysfs(); - - if (conf->dev_name == NULL) { - ret = set_conf_dev_and_port(umad_dev, conf); - if (ret) { - pr_err("Failed to build config\n"); - return ret; - } - } - ret = asprintf(&conf->add_target_file, - "%s/class/infiniband_srp/srp-%s-%d/add_target", sysfs_path, - conf->dev_name, conf->port_num); - if (ret < 0) { - pr_err("error while allocating add_target\n"); - return ret; - } - - if (get_rules_file(conf)) - return -1; - - return 0; -} - -static void free_config(struct config_t *conf) -{ - free(conf->dev_name); - free(conf->add_target_file); - free(conf->rules); - free(conf); -} - -static void umad_resources_init(struct umad_resources *umad_res) -{ - umad_res->portid = -1; - umad_res->agent = -1; - umad_res->agent = -1; - umad_res->port_sysfs_path = NULL; -} - -static void umad_resources_destroy(struct umad_resources *umad_res) -{ - if (umad_res->port_sysfs_path) - free(umad_res->port_sysfs_path); - - if (umad_res->portid >= 0) { - if (umad_res->agent >= 0) - umad_unregister(umad_res->portid, umad_res->agent); - umad_close_port(umad_res->portid); - } - - umad_done(); -} - -static int umad_resources_create(struct umad_resources *umad_res) -{ - - int ret; - - ret = asprintf(&umad_res->port_sysfs_path, "%s/class/infiniband/%s/ports/%d", - sysfs_path, config->dev_name, config->port_num); - - if (ret < 0) { - umad_res->port_sysfs_path = NULL; - return -ENOMEM; - } - - umad_res->portid = umad_open_port(config->dev_name, config->port_num); - if (umad_res->portid < 0) { - pr_err("umad_open_port failed for device %s port %d\n", - config->dev_name, config->port_num); - return -ENXIO; - } - - umad_res->agent = umad_register(umad_res->portid, UMAD_CLASS_SUBN_ADM, - UMAD_SA_CLASS_VERSION, - UMAD_RMPP_VERSION, NULL); - if (umad_res->agent < 0) { - pr_err("umad_register failed\n"); - return umad_res->agent; - } - - return 0; -} - -static void *run_thread_retry_to_connect(void *res_in) -{ - struct resources *res = (struct resources *)res_in; - struct target_details *target; - time_t sleep_time; - - pthread_mutex_lock(&res->sync_res->retry_mutex); - while (!res->sync_res->stop_threads) { - if (retry_list_is_empty(res->sync_res)) - pthread_cond_wait(&res->sync_res->retry_cond, - &res->sync_res->retry_mutex); - while (!res->sync_res->stop_threads && - (target = pop_from_retry_list(res->sync_res)) != NULL) { - pthread_mutex_unlock(&res->sync_res->retry_mutex); - sleep_time = target->retry_time - time(NULL); - - if (sleep_time > 0) - srp_sleep(sleep_time, 0); - - add_non_exist_target(target); - free(target); - pthread_mutex_lock(&res->sync_res->retry_mutex); - } - } - /* empty retry_list */ - while ((target = pop_from_retry_list(res->sync_res))) - free(target); - pthread_mutex_unlock(&res->sync_res->retry_mutex); - - pr_debug("retry_to_connect thread ended\n"); - - pthread_exit(NULL); -} - -static void free_res(struct resources *res) -{ - void *status; - - if (!res) - return; - - if (res->sync_res) { - pthread_mutex_lock(&res->sync_res->retry_mutex); - res->sync_res->stop_threads = 1; - pthread_cond_signal(&res->sync_res->retry_cond); - pthread_mutex_unlock(&res->sync_res->retry_mutex); - } - - if (res->ud_res) - modify_qp_to_err(res->ud_res->qp); - - if (res->reconnect_thread) { - pthread_kill(res->reconnect_thread, SIGINT); - pthread_join(res->reconnect_thread, &status); - } - if (res->async_ev_thread) { - pthread_kill(res->async_ev_thread, SIGINT); - pthread_join(res->async_ev_thread, &status); - } - if (res->trap_thread) { - pthread_kill(res->trap_thread, SIGINT); - pthread_join(res->trap_thread, &status); - } - if (res->sync_res) - sync_resources_cleanup(res->sync_res); - if (res->ud_res) - ud_resources_destroy(res->ud_res); - if (res->umad_res) - umad_resources_destroy(res->umad_res); - free(res); -} - -static struct resources *alloc_res(void) -{ - struct all_resources { - struct resources res; - struct ud_resources ud_res; - struct umad_resources umad_res; - struct sync_resources sync_res; - }; - - struct all_resources *res; - int ret; - - res = calloc(1, sizeof(*res)); - if (!res) - goto err; - - umad_resources_init(&res->umad_res); - ret = umad_resources_create(&res->umad_res); - if (ret) - goto err; - res->res.umad_res = &res->umad_res; - - ud_resources_init(&res->ud_res); - ret = ud_resources_create(&res->ud_res); - if (ret) - goto err; - res->res.ud_res = &res->ud_res; - - ret = sync_resources_init(&res->sync_res); - if (ret) - goto err; - res->res.sync_res = &res->sync_res; - - if (!config->once) { - ret = pthread_create(&res->res.trap_thread, NULL, - run_thread_get_trap_notices, &res->res); - if (ret) - goto err; - } - - ret = pthread_create(&res->res.async_ev_thread, NULL, - run_thread_listen_to_events, &res->res); - if (ret) - goto err; - - if (config->retry_timeout && !config->once) { - ret = pthread_create(&res->res.reconnect_thread, NULL, - run_thread_retry_to_connect, &res->res); - if (ret) - goto err; - } - - return &res->res; -err: - if (res) - free_res(&res->res); - return NULL; -} - -/* *c = *a - *b. See also the BSD macro timersub(). */ -static void ts_sub(const struct timespec *a, const struct timespec *b, - struct timespec *res) -{ - res->tv_sec = a->tv_sec - b->tv_sec; - res->tv_nsec = a->tv_nsec - b->tv_nsec; - if (res->tv_nsec < 0) { - res->tv_sec--; - res->tv_nsec += 1000 * 1000 * 1000; - } -} - -static void cleanup_wakeup_fd(void) -{ - struct sigaction sa = {}; - - sigemptyset(&sa.sa_mask); - sa.sa_handler = SIG_DFL; - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - sigaction(SRP_CATAS_ERR, &sa, NULL); - - close(wakeup_pipe[1]); - close(wakeup_pipe[0]); - wakeup_pipe[0] = -1; - wakeup_pipe[1] = -1; -} - -static int setup_wakeup_fd(void) -{ - struct sigaction sa = {}; - int ret; - - ret = pipe2(wakeup_pipe, O_NONBLOCK | O_CLOEXEC); - if (ret < 0) { - pr_err("could not create pipe\n"); - return -1; - } - - sigemptyset(&sa.sa_mask); - sa.sa_handler = signal_handler; - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - sigaction(SRP_CATAS_ERR, &sa, NULL); - return 0; -} - -static int ibsrpdm(int argc, char *argv[]) -{ - char* umad_dev = NULL; - struct resources *res; - int ret; - - s_log_dest = log_to_stderr; - - config = calloc(1, sizeof(*config)); - config->num_of_oust = 10; - config->timeout = 5000; - config->mad_retries = 3; - config->all = 1; - config->once = 1; - - while (1) { - int c; - - c = getopt(argc, argv, "cd:h:v"); - if (c == -1) - break; - - switch (c) { - case 'c': - ++config->cmd; - break; - case 'd': - umad_dev = optarg; - break; - case 'v': - ++config->debug_verbose; - break; - case 'h': - default: - fprintf(stderr, - "Usage: %s [-vc] [-d ]\n", - argv[0]); - return 1; - } - } - - initialize_sysfs(); - - ret = set_conf_dev_and_port(umad_dev, config); - if (ret) { - pr_err("Failed to build config\n"); - goto out; - } - - umad_init(); - res = alloc_res(); - if (!res) { - ret = 1; - pr_err("Resource allocation failed\n"); - goto umad_done; - } - ret = recalc(res); - if (ret) - pr_err("Querying SRP targets failed\n"); - - assert(res->sync_res); - pthread_mutex_lock(&res->sync_res->retry_mutex); - res->sync_res->stop_threads = 1; - pthread_cond_signal(&res->sync_res->retry_cond); - pthread_mutex_unlock(&res->sync_res->retry_mutex); - - free_res(res); -umad_done: - umad_done(); -out: - free_config(config); - - return ret; -} - -int main(int argc, char *argv[]) -{ - int ret; - struct resources *res; - uint16_t lid; - uint16_t pkey; - union umad_gid gid; - struct target_details *target; - int subscribed; - int lockfd = -1; - int received_signal = 0; - bool systemd; - -#ifndef __CHECKER__ - /* - * Hide these checks for sparse because these checks fail with - * older versions of sparse. - */ - BUILD_ASSERT(sizeof(struct ib_path_rec) == 64); - BUILD_ASSERT(sizeof(struct ib_inform_info) == 36); - BUILD_ASSERT(sizeof(struct ib_mad_notice_attr) == 80); - BUILD_ASSERT(offsetof(struct ib_mad_notice_attr, - data_details.ntc_64_67.gid) == 16); -#endif - BUILD_ASSERT(sizeof(struct srp_sa_node_rec) == 108); - BUILD_ASSERT(sizeof(struct srp_sa_port_info_rec) == 58); - BUILD_ASSERT(sizeof(struct srp_dm_iou_info) == 132); - BUILD_ASSERT(sizeof(struct srp_dm_ioc_prof) == 128); - - if (strcmp(argv[0] + max_t(int, 0, strlen(argv[0]) - strlen("ibsrpdm")), - "ibsrpdm") == 0) { - ret = ibsrpdm(argc, argv); - goto out; - } - - systemd = is_systemd(argc, argv); - - if (systemd) - openlog(NULL, LOG_NDELAY | LOG_CONS | LOG_PID, LOG_DAEMON); - else - openlog("srp_daemon", LOG_PID, LOG_DAEMON); - - config = calloc(1, sizeof(*config)); - if (!config) { - pr_err("out of memory\n"); - ret = ENOMEM; - goto close_log; - } - - if (get_config(config, argc, argv)) { - ret = EINVAL; - goto free_config; - } - - if (config->verbose) - print_config(config); - - if (!config->once) { - lockfd = check_process_uniqueness(config); - if (lockfd < 0) { - ret = EPERM; - goto free_config; - } - } - - ret = setup_wakeup_fd(); - if (ret) - goto cleanup_wakeup; - -catas_start: - subscribed = 0; - - ret = umad_init(); - if (ret < 0) { - pr_err("umad_init failed\n"); - goto close_lockfd; - } - - res = alloc_res(); - if (!res && received_signal == SRP_CATAS_ERR) - pr_err("Device has not yet recovered from catas error\n"); - if (!res) - goto clean_umad; - - /* - * alloc_res() fails while the HCA is recovering from a catastrophic - * error. Clear 'received_signal' after alloc_res() has succeeded to - * finish the alloc_res() retry loop. - */ - if (received_signal == SRP_CATAS_ERR) { - pr_err("Device recovered from catastrophic error\n"); - received_signal = 0; - } - - if (config->once) { - ret = recalc(res); - goto free_res; - } - - while (received_signal == 0) { - pthread_mutex_lock(&res->sync_res->mutex); - if (__rescan_scheduled(res->sync_res)) { - uint16_t port_lid; - - pthread_mutex_unlock(&res->sync_res->mutex); - - pr_debug("Starting a recalculation\n"); - port_lid = get_port_lid(res->ud_res->ib_ctx, - config->port_num); - if (port_lid != res->ud_res->port_attr.lid) { - if (res->ud_res->ah) { - ibv_destroy_ah(res->ud_res->ah); - res->ud_res->ah = NULL; - } - ret = create_ah(res->ud_res); - if (ret) { - received_signal = get_received_signal(10, 0); - goto kill_threads; - } - } - - if (res->ud_res->ah) { - if (register_to_traps(res, 1)) - pr_err("Fail to register to traps, maybe there " - "is no opensm running on fabric or IB port is down\n"); - else - subscribed = 1; - } - - clear_traps_list(res->sync_res); - schedule_rescan(res->sync_res, config->recalc_time ? - config->recalc_time : -1); - - /* empty retry_list */ - pthread_mutex_lock(&res->sync_res->retry_mutex); - while ((target = pop_from_retry_list(res->sync_res))) - free(target); - pthread_mutex_unlock(&res->sync_res->retry_mutex); - - recalc(res); - } else if (pop_from_list(res->sync_res, &lid, &gid, &pkey)) { - pthread_mutex_unlock(&res->sync_res->mutex); - if (lid) { - uint64_t guid; - ret = get_node(res->umad_res, lid, &guid); - if (ret) - /* unexpected error - do a full rescan */ - schedule_rescan(res->sync_res, 0); - else - handle_port(res, pkey, lid, guid); - } else { - ret = get_lid(res->umad_res, &gid, &lid); - if (ret < 0) - /* unexpected error - do a full rescan */ - schedule_rescan(res->sync_res, 0); - else { - pr_debug("lid is %#x\n", lid); - - srp_sleep(0, 100); - handle_port(res, pkey, lid, - be64toh(ib_gid_get_guid(&gid))); - } - } - } else { - static const struct timespec zero; - struct timespec now, delta; - struct timespec recalc = { - .tv_sec = config->recalc_time - }; - struct timeval timeout; - - clock_gettime(CLOCK_MONOTONIC, &now); - ts_sub(&res->sync_res->next_recalc_time, &now, &delta); - pthread_mutex_unlock(&res->sync_res->mutex); - - if (ts_cmp(&zero, &delta, <=) && - ts_cmp(&delta, &recalc, <)) - recalc = delta; - timeout.tv_sec = recalc.tv_sec; - timeout.tv_usec = recalc.tv_nsec / 1000 + 1; - - received_signal = get_received_signal(timeout.tv_sec, - timeout.tv_usec) ? : - received_signal; - } - } - - ret = 0; - -kill_threads: - switch (received_signal) { - case SIGINT: - pr_err("Got SIGINT\n"); - break; - case SIGTERM: - pr_err("Got SIGTERM\n"); - break; - case SRP_CATAS_ERR: - pr_err("Got SIG SRP_CATAS_ERR\n"); - break; - case 0: - break; - default: - pr_err("Got SIG???\n"); - break; - } - - if (subscribed && received_signal != SRP_CATAS_ERR) { - pr_err("Deregistering traps ...\n"); - register_to_traps(res, 0); - pr_err("Finished trap deregistration.\n"); - } -free_res: - free_res(res); - /* Discard the SIGINT triggered by the free_res() implementation. */ - get_received_signal(0, 0); -clean_umad: - umad_done(); - if (received_signal == SRP_CATAS_ERR) { - /* - * Device got a catastrophic error. Let's wait a grace - * period and try to probe the device by attempting to - * allocate IB resources. Once it recovers, we will - * start all over again. - */ - received_signal = get_received_signal(10, 0) ? : - received_signal; - if (received_signal == SRP_CATAS_ERR) - goto catas_start; - } -close_lockfd: - if (lockfd >= 0) - close(lockfd); -cleanup_wakeup: - cleanup_wakeup_fd(); -free_config: - free_config(config); -close_log: - closelog(); -out: - exit(ret ? 1 : 0); -} - -static int recalc(struct resources *res) -{ - struct umad_resources *umad_res = res->umad_res; - int mask_match; - char val[7]; - int ret; - - ret = srpd_sys_read_string(umad_res->port_sysfs_path, "sm_lid", val, sizeof val); - if (ret < 0) { - pr_err("Couldn't read SM LID\n"); - return ret; - } - - umad_res->sm_lid = strtol(val, NULL, 0); - if (umad_res->sm_lid == 0) { - pr_err("SM LID is 0, maybe no opensm is running\n"); - return -1; - } - - ret = check_sm_cap(umad_res, &mask_match); - if (ret < 0) - return ret; - - if (mask_match) { - pr_debug("Advanced SM, performing a capability query\n"); - ret = do_dm_port_list(res); - } else { - pr_debug("Old SM, performing a full node query\n"); - ret = do_full_port_list(res); - } - - return ret; -} - -static int get_lid(struct umad_resources *umad_res, union umad_gid *gid, - uint16_t *lid) -{ - struct srp_ib_user_mad out_mad, in_mad; - struct umad_sa_packet *in_sa_mad = get_data_ptr(in_mad); - struct umad_sa_packet *out_sa_mad = get_data_ptr(out_mad); - struct ib_path_rec *path_rec = (struct ib_path_rec *) out_sa_mad->data; - - memset(&in_mad, 0, sizeof(in_mad)); - init_srp_sa_mad(&out_mad, umad_res->agent, umad_res->sm_lid, - UMAD_SA_ATTR_PATH_REC, 0); - - out_sa_mad->comp_mask = htobe64( 4 | 8 | 64 | 512 | 4096 ); - - path_rec->sgid = *gid; - path_rec->dgid = *gid; - path_rec->num_path = 1; - path_rec->hop_flow_raw = htobe32(1 << 31); /* rawtraffic=1 hoplimit = 0 */ - - if (send_and_get(umad_res->portid, umad_res->agent, &out_mad, &in_mad, 0) < 0) - return -1; - - path_rec = (struct ib_path_rec *) in_sa_mad->data; - - *lid = be16toh(path_rec->dlid); - - return 0; -} diff --git a/usr/rdma-core/srp_daemon/srp_daemon.conf b/usr/rdma-core/srp_daemon/srp_daemon.conf deleted file mode 100644 index 8a3abe536..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon.conf +++ /dev/null @@ -1,19 +0,0 @@ -## This is an example rules configuration file for srp_daemon. -## -#This is a comment -## disallow the following dgid -#d dgid=fe800000000000000002c90200402bd5 -## allow target with the following ioc_guid -#a ioc_guid=00a0b80200402bd7 -## allow target with the following pkey -#a pkey=ffff -## allow target with the following id_ext and ioc_guid -#a id_ext=200500A0B81146A1,ioc_guid=00a0b80200402bef -## disallow all the rest -#d -## -## Here is another example: -## -## Allow all targets and set queue size to 128. -# a queue_size=128,max_cmd_per_lun=128 - diff --git a/usr/rdma-core/srp_daemon/srp_daemon.h b/usr/rdma-core/srp_daemon/srp_daemon.h deleted file mode 100644 index 5d268ed39..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon.h +++ /dev/null @@ -1,324 +0,0 @@ -/* - * srp_daemon - discover SRP targets over IB - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2006 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef SRP_DM_H -#define SRP_DM_H - -#include -#include -#include -#include -#include -#include -#include /* __be16, __be32 and __be64 */ -#include - -#include "config.h" -#include "srp_ib_types.h" - -#define SRP_CATAS_ERR SIGUSR1 - -enum { - SRP_DM_ATTR_IO_UNIT_INFO = 0x0010, - SRP_DM_ATTR_IO_CONTROLLER_PROFILE = 0x0011, - SRP_DM_ATTR_SERVICE_ENTRIES = 0x0012 -}; - -enum { - SRP_DM_NO_IOC = 0x0, - SRP_DM_IOC_PRESENT = 0x1, - SRP_DM_NO_SLOT = 0xf -}; - -enum { - SRP_SM_SUPPORTS_MASK_MATCH = 1 << 13, - SRP_IS_DM = 1 << 19, - SRP_SM_CAP_MASK_MATCH_ATTR_MOD = 1 << 31, -}; - -enum { - SRP_REV10_IB_IO_CLASS = 0xff00, - SRP_REV16A_IB_IO_CLASS = 0x0100 -}; - -struct srp_sa_node_rec { - __be16 lid; - __be16 reserved; - uint8_t base_version; - uint8_t class_version; - uint8_t type; - uint8_t num_ports; - __be64 sys_guid __attribute__((packed)); - __be64 node_guid __attribute__((packed)); - __be64 port_guid __attribute__((packed)); - __be16 partition_cap; - __be16 device_id; - __be32 revision; - __be32 port_num_vendor_id; - uint8_t desc[64]; -}; - -struct srp_sa_port_info_rec { - __be16 endport_lid; - uint8_t port_num; - uint8_t reserved; - __be64 m_key __attribute__((packed)); - __be64 subnet_prefix __attribute__((packed)); - __be16 base_lid; - __be16 master_sm_base_lid; - __be32 capability_mask __attribute__((packed)); - __be16 diag_code; - __be16 m_key_lease_period; - uint8_t local_port_num; - uint8_t link_width_enabled; - uint8_t link_width_supported; - uint8_t link_width_active; - uint8_t state_info1; - uint8_t state_info2; - uint8_t mkey_lmc; - uint8_t link_speed; - uint8_t mtu_smsl; - uint8_t vl_cap; - uint8_t vl_high_limit; - uint8_t vl_arb_high_cap; - uint8_t vl_arb_low_cap; - uint8_t mtu_cap; - uint8_t vl_stall_life; - uint8_t vl_enforce; - __be16 m_key_violations; - __be16 p_key_violations; - __be16 q_key_violations; - uint8_t guid_cap; - uint8_t subnet_timeout; - uint8_t resp_time_value; - uint8_t error_threshold; -}; - -struct srp_dm_iou_info { - __be16 change_id; - uint8_t max_controllers; - uint8_t diagid_optionrom; - uint8_t controller_list[128]; -}; - -struct srp_dm_ioc_prof { - __be64 guid; - __be32 vendor_id; - __be32 device_id; - __be16 device_version; - __be16 reserved1; - __be32 subsys_vendor_id; - __be32 subsys_device_id; - __be16 io_class; - __be16 io_subclass; - __be16 protocol; - __be16 protocol_version; - __be32 reserved2; - __be16 send_queue_depth; - uint8_t reserved3; - uint8_t rdma_read_depth; - __be32 send_size; - __be32 rdma_size; - uint8_t cap_mask; - uint8_t reserved4; - uint8_t service_entries; - uint8_t reserved5[9]; - char id[64]; -}; - -struct srp_dm_svc_entries { - struct { - char name[40]; - __be64 id; - } service[4]; -}; - -enum { - SEND_SIZE = 256, - GRH_SIZE = 40, - RECV_BUF_SIZE = SEND_SIZE + GRH_SIZE, -}; - -struct rule { - int allow; - char id_ext[17], ioc_guid[17], dgid[33], service_id[17], pkey[10], options[128]; -}; - -#define SRP_MAX_SHARED_PKEYS 127 -#define MAX_ID_EXT_STRING_LENGTH 17 - -struct target_details { - uint16_t pkey; - char id_ext[MAX_ID_EXT_STRING_LENGTH]; - struct srp_dm_ioc_prof ioc_prof; - uint64_t subnet_prefix; - uint64_t h_guid; - uint64_t h_service_id; - time_t retry_time; - char *options; - struct target_details *next; -}; - -struct config_t { - char *dev_name; - int port_num; - char *add_target_file; - int mad_retries; - int num_of_oust; - int cmd; - int once; - int execute; - int all; - int verbose; - int debug_verbose; - int timeout; - int recalc_time; - int print_initiator_ext; - const char *rules_file; - struct rule *rules; - int retry_timeout; - int tl_retry_count; -}; - -extern struct config_t *config; - -struct ud_resources { - struct ibv_device **dev_list; - struct ibv_context *ib_ctx; - struct ibv_pd *pd; - struct ibv_cq *send_cq; - struct ibv_cq *recv_cq; - struct ibv_qp *qp; - struct ibv_mr *mr; - struct ibv_ah *ah; - char *recv_buf; - char *send_buf; - struct ibv_device_attr device_attr; - struct ibv_port_attr port_attr; - int cq_size; - struct ibv_comp_channel *channel; - pthread_mutex_t *mad_buffer_mutex; - struct umad_sa_packet *mad_buffer; -}; - -struct umad_resources { - int portid; - int agent; - char *port_sysfs_path; - uint16_t sm_lid; -}; - -enum { - SIZE_OF_TASKS_LIST = 5, -}; - -struct sync_resources { - int stop_threads; - int next_task; - struct timespec next_recalc_time; - struct { - uint16_t lid; - uint16_t pkey; - union umad_gid gid; - } tasks[SIZE_OF_TASKS_LIST]; - pthread_mutex_t mutex; - struct target_details *retry_tasks_head; - struct target_details *retry_tasks_tail; - pthread_mutex_t retry_mutex; - pthread_cond_t retry_cond; -}; - -struct resources { - struct ud_resources *ud_res; - struct umad_resources *umad_res; - struct sync_resources *sync_res; - pthread_t trap_thread; - pthread_t async_ev_thread; - pthread_t reconnect_thread; - pthread_t timer_thread; -}; - -struct srp_ib_user_mad { - struct ib_user_mad hdr; - char filler[MAD_BLOCK_SIZE]; -}; - -#include - -#define pr_human(arg...) \ - do { \ - if (!config->cmd && !config->execute) \ - printf(arg); \ - } while (0) - -void pr_debug(const char *fmt, ...) __attribute__((format(printf, 1, 2))); -void pr_err(const char *fmt, ...) __attribute__((format(printf, 1, 2))); - -int pkey_index_to_pkey(struct umad_resources *umad_res, int pkey_index, - uint16_t *pkey); -void handle_port(struct resources *res, uint16_t pkey, uint16_t lid, uint64_t h_guid); -void ud_resources_init(struct ud_resources *res); -int ud_resources_create(struct ud_resources *res); -int ud_resources_destroy(struct ud_resources *res); -int wait_for_recalc(struct resources *res_in); -int trap_main(struct resources *res); -void *run_thread_get_trap_notices(void *res_in); -void *run_thread_listen_to_events(void *res_in); -int get_node(struct umad_resources *umad_res, uint16_t dlid, uint64_t *guid); -int create_trap_resources(struct ud_resources *ud_res); -int register_to_traps(struct resources *res, int subscribe); -uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num); -int create_ah(struct ud_resources *ud_res); -void push_gid_to_list(struct sync_resources *res, union umad_gid *gid, - uint16_t pkey); -void push_lid_to_list(struct sync_resources *res, uint16_t lid, uint16_t pkey); -struct target_details *pop_from_retry_list(struct sync_resources *res); -void push_to_retry_list(struct sync_resources *res, - struct target_details *target); -int retry_list_is_empty(struct sync_resources *res); -void clear_traps_list(struct sync_resources *res); -int pop_from_list(struct sync_resources *res, uint16_t *lid, - union umad_gid *gid, uint16_t *pkey); -int sync_resources_init(struct sync_resources *res); -void sync_resources_cleanup(struct sync_resources *res); -int modify_qp_to_err(struct ibv_qp *qp); -void srp_sleep(time_t sec, time_t usec); -void wake_up_main_loop(char ch); -void __schedule_rescan(struct sync_resources *res, int when); -void schedule_rescan(struct sync_resources *res, int when); -int __rescan_scheduled(struct sync_resources *res); -int rescan_scheduled(struct sync_resources *res); - -#endif /* SRP_DM_H */ diff --git a/usr/rdma-core/srp_daemon/srp_daemon.rules b/usr/rdma-core/srp_daemon/srp_daemon.rules deleted file mode 100644 index b6411dcec..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon.rules +++ /dev/null @@ -1 +0,0 @@ -SUBSYSTEM=="infiniband_mad", KERNEL=="*umad*", PROGRAM=="/bin/systemctl show srp_daemon -p ActiveState", RESULT=="ActiveState=active", ENV{SYSTEMD_WANTS}+="srp_daemon_port@$attr{ibdev}:$attr{port}.service" diff --git a/usr/rdma-core/srp_daemon/srp_daemon.service.5 b/usr/rdma-core/srp_daemon/srp_daemon.service.5 deleted file mode 100644 index a6b25d6a2..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon.service.5 +++ /dev/null @@ -1,30 +0,0 @@ -'\" t -.TH "SRP_DAEMON\&.SERVICE" "5" "" "srp_daemon" "srp_daemon.service" -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- -.SH "NAME" -srp_daemon.service \- srp_daemon systemd service that controls all ports -.SH "SYNOPSIS" -.PP -srp_daemon\&.service -.SH "DESCRIPTION" -.PP -The srp_daemon\&.service controls whether or not any srp_daemon processes are -running. Although no srp_daemon processes are controlled directly by the -srp_daemon\&.service, this service controls whether or not any -srp_daemon_port@\&.service are allowed to be active. Each -srp_daemon_port@\&.service controls one srp_daemon process. - -.SH "SEE ALSO" -.PP -\fBsrp_daemon\fR(1), -\fBsrp_daemon_port@.service\fR(5), -\fBsystemctl\fR(1) diff --git a/usr/rdma-core/srp_daemon/srp_daemon.service.in b/usr/rdma-core/srp_daemon/srp_daemon.service.in deleted file mode 100644 index 188b7e1a3..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon.service.in +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=Daemon that discovers and logs in to SRP target systems -Documentation=man:srp_daemon file:/etc/srp_daemon.conf -DefaultDependencies=false -Conflicts=emergency.target emergency.service -Before=remote-fs-pre.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=@CMAKE_INSTALL_FULL_LIBEXECDIR@/srp_daemon/start_on_all_ports -MemoryDenyWriteExecute=yes -PrivateTmp=yes -ProtectHome=yes -ProtectKernelModules=yes -RestrictRealtime=yes - -[Install] -WantedBy=remote-fs-pre.target diff --git a/usr/rdma-core/srp_daemon/srp_daemon.sh.in b/usr/rdma-core/srp_daemon/srp_daemon.sh.in deleted file mode 100755 index 75e8a31b9..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon.sh.in +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2006 Mellanox Technologies. All rights reserved. -# -# This Software is licensed under one of the following licenses: -# -# 1) under the terms of the "Common Public License 1.0" a copy of which is -# available from the Open Source Initiative, see -# http://www.opensource.org/licenses/cpl.php. -# -# 2) under the terms of the "The BSD License" a copy of which is -# available from the Open Source Initiative, see -# http://www.opensource.org/licenses/bsd-license.php. -# -# 3) under the terms of the "GNU General Public License (GPL) Version 2" a -# copy of which is available from the Open Source Initiative, see -# http://www.opensource.org/licenses/gpl-license.php. -# -# Licensee has the right to choose one of the above licenses. -# -# Redistributions of source code must retain the above copyright -# notice and one of the license notices. -# -# Redistributions in binary form must reproduce both the above copyright -# notice, one of the license notices in the documentation -# and/or other materials provided with the distribution. -# -# $Id$ -# - -shopt -s nullglob - -prog=@CMAKE_INSTALL_FULL_SBINDIR@/srp_daemon -params=("$@") -ibdir="/sys/class/infiniband" -rescan_interval=60 -pids=() -pidfile="@CMAKE_INSTALL_FULL_RUNDIR@/srp_daemon.sh.pid" -mypid=$$ - -trap_handler() -{ - if [ "${#pids[@]}" ]; then - kill -15 "${pids[@]}" > /dev/null 2>&1 - wait "${pids[@]}" - fi - logger -i -t "$(basename "$0")" "killing $prog." - /bin/rm -f "$pidfile" - exit 0 -} - -# Check if there is another copy running of srp_daemon.sh -if [ -f "$pidfile" ]; then - if [ -e "/proc/$(cat "$pidfile" 2>/dev/null)/status" ]; then - echo "$(basename "$0") is already running. Exiting." - exit 1 - else - /bin/rm -f "$pidfile" - fi -fi - -if ! echo $mypid > "$pidfile"; then - echo "Creating $pidfile for pid $mypid failed" - exit 1 -fi - -trap 'trap_handler' 2 15 - -while [ ! -d ${ibdir} ] -do - sleep 30 -done - -for d in ${ibdir}_mad/umad*; do - hca_id="$(<"$d/ibdev")" - port="$(<"$d/port")" - add_target="${ibdir}_srp/srp-${hca_id}-${port}/add_target" - if [ -e "${add_target}" ]; then - ${prog} -e -c -n -i "${hca_id}" -p "${port}" -R "${rescan_interval}" "${params[@]}" >/dev/null 2>&1 & - pids+=($!) - fi -done - -wait diff --git a/usr/rdma-core/srp_daemon/srp_daemon_port@.service.5 b/usr/rdma-core/srp_daemon/srp_daemon_port@.service.5 deleted file mode 100644 index 9136f1a30..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon_port@.service.5 +++ /dev/null @@ -1,49 +0,0 @@ -'\" t -.TH "SRP_DAEMON_PORT@\&.SERVICE" "5" "" "srp_daemon" "srp_daemon_port@.service" -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- -.SH "NAME" -srp_daemon_port@.service \- srp_daemon_port@ systemd service that controls a -single port -.SH "SYNOPSIS" -.PP -srp_daemon_port@\&.service -.SH "DESCRIPTION" -.PP -The srp_daemon_port@\&.service controls whether or not an srp_daemon process -is monitoring the RDMA port specified as template argument. The format for the -RDMA port name is \fIdev:port\fR where \fIdev\fR is the name of an RDMA device -and \fIport\fR is an port number starting from one. Starting an instance of -this template will start an srp_daemon process. Stopping an instance of this -template will stop the srp_daemon process for the specified port. It can be -prevented that srp_daemon is started for a certain port by masking the -corresponding systemd service, e.g. \fBsystemctl mask -srp_daemon_port@mlx4_0:1\fR. - -A list of all RDMA device and port number pairs can be obtained e.g. as follows: -.PP -.nf -.RS -$ (cd /sys/class/infiniband >&/dev/null && for p in */ports/*; do - [ -e "$p" ] && echo "${p/\\/ports\\//:}"; done) -mlx4_0:1 -mlx4_0:2 -mlx4_1:1 -mlx4_1:2 -.RE -.fi -.PP - -.SH "SEE ALSO" -.PP -\fBsrp_daemon\fR(1), -\fBsrp_daemon.service\fR(5), -\fBsystemctl\fR(1) diff --git a/usr/rdma-core/srp_daemon/srp_daemon_port@.service.in b/usr/rdma-core/srp_daemon/srp_daemon_port@.service.in deleted file mode 100644 index 3d5a11e86..000000000 --- a/usr/rdma-core/srp_daemon/srp_daemon_port@.service.in +++ /dev/null @@ -1,42 +0,0 @@ -[Unit] -Description=SRP daemon that monitors port %i -Documentation=man:srp_daemon file:/etc/rdma/rdma.conf file:/etc/srp_daemon.conf -# srp_daemon is required to mount filesystems, and could run before sysinit.target -DefaultDependencies=false -Before=remote-fs-pre.target -# Do not execute concurrently with an ongoing shutdown (required for DefaultDependencies=no) -Conflicts=shutdown.target -Before=shutdown.target -# Ensure required kernel modules are loaded before starting -Requires=rdma-load-modules@srp_daemon.service -After=rdma-load-modules@srp_daemon.service -# Complete setting up low level RDMA hardware -After=rdma-hw.target -# Only run while the RDMA udev device is in an active state, and shutdown if -# it becomes unplugged. -After=sys-subsystem-rdma-devices-%i-umad.device -BindsTo=sys-subsystem-rdma-devices-%i-umad.device -# Allow srp_daemon to act as a leader for all of the port services for -# stop/start/reset -After=srp_daemon.service -BindsTo=srp_daemon.service - -[Service] -Type=simple -ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/srp_daemon --systemd -e -c -n -j %I -R 60 -MemoryDenyWriteExecute=yes -PrivateNetwork=yes -PrivateTmp=yes -ProtectControlGroups=yes -ProtectHome=yes -ProtectKernelModules=yes -ProtectSystem=full -RestrictRealtime=yes -SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io - -[Install] -# Instances of this template unit file is started automatically by udev or by -# srp_daemon.service as devices are discovered. However, if the user manually -# enables a template unit then it will be installed with remote-fs-pre. Note -# that systemd will defer starting the unit until the rdma .device appears. -WantedBy=remote-fs-pre.target diff --git a/usr/rdma-core/srp_daemon/srp_handle_traps.c b/usr/rdma-core/srp_daemon/srp_handle_traps.c deleted file mode 100644 index 6d94634ef..000000000 --- a/usr/rdma-core/srp_daemon/srp_handle_traps.c +++ /dev/null @@ -1,857 +0,0 @@ -/* - * Copyright (c) 2006 Mellanox Technologies. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Author: ishai Rabinovitz [ishai@mellanox.co.il]$ - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "srp_ib_types.h" - -#include "srp_daemon.h" - -void srp_sleep(time_t sec, time_t usec) -{ - struct timespec req, rem; - - if (usec > 1000) { - sec += usec / 1000; - usec = usec % 1000; - } - req.tv_sec = sec; - req.tv_nsec = usec * 1000000; - - nanosleep(&req, &rem); -} - -/***************************************************************************** -* Function: ud_resources_init -*****************************************************************************/ -void -ud_resources_init(struct ud_resources *res) -{ - res->dev_list = NULL; - res->ib_ctx = NULL; - res->send_cq = NULL; - res->recv_cq = NULL; - res->channel = NULL; - res->qp = NULL; - res->pd = NULL; - res->mr = NULL; - res->ah = NULL; - res->send_buf = NULL; - res->recv_buf = NULL; -} - - -/***************************************************************************** -* Function: modify_qp_to_rts -*****************************************************************************/ -static int modify_qp_to_rts(struct ibv_qp *qp) -{ - struct ibv_qp_attr attr; - int flags; - int rc; - - /* RESET -> INIT */ - memset(&attr, 0, sizeof(struct ibv_qp_attr)); - - attr.qp_state = IBV_QPS_INIT; - attr.port_num = config->port_num; - attr.pkey_index = 0; - attr.qkey = UMAD_QKEY; - - flags = IBV_QP_STATE | IBV_QP_PKEY_INDEX | IBV_QP_PORT | IBV_QP_QKEY; - - rc = ibv_modify_qp(qp, &attr, flags); - if (rc) { - pr_err("failed to modify QP state to INIT\n"); - return rc; - } - - /* INIT -> RTR */ - memset(&attr, 0, sizeof(attr)); - - attr.qp_state = IBV_QPS_RTR; - - flags = IBV_QP_STATE; - - rc = ibv_modify_qp(qp, &attr, flags); - if (rc) { - pr_err("failed to modify QP state to RTR\n"); - return rc; - } - - /* RTR -> RTS */ - /* memset(&attr, 0, sizeof(attr)); */ - - attr.qp_state = IBV_QPS_RTS; - attr.sq_psn = 0; - - flags = IBV_QP_STATE | IBV_QP_SQ_PSN; - - rc = ibv_modify_qp(qp, &attr, flags); - if (rc) { - pr_err("failed to modify QP state to RTS\n"); - return rc; - } - - return 0; -} - -int modify_qp_to_err(struct ibv_qp *qp) -{ - static struct ibv_qp_attr attr = { - .qp_state = IBV_QPS_ERR, - }; - - return ibv_modify_qp(qp, &attr, IBV_QP_STATE); -} - -/***************************************************************************** -* Function: fill_rq_entry -*****************************************************************************/ -static int fill_rq_entry(struct ud_resources *res, int cur_receive) -{ - struct ibv_recv_wr rr; - struct ibv_sge sg; - struct ibv_recv_wr *_bad_wr = NULL; - struct ibv_recv_wr **bad_wr = &_bad_wr; - int ret; - - memset(&rr, 0, sizeof(rr)); - - sg.length = RECV_BUF_SIZE; - sg.lkey = res->mr->lkey; - - rr.next = NULL; - rr.sg_list = &sg; - rr.num_sge = 1; - - sg.addr = (((unsigned long)res->recv_buf) + RECV_BUF_SIZE * cur_receive); - rr.wr_id = cur_receive; - - ret = ibv_post_recv(res->qp, &rr, bad_wr); - if (ret < 0) { - pr_err("failed to post RR\n"); - return ret; - } - return 0; -} - -/***************************************************************************** -* Function: fill_rq -*****************************************************************************/ -static int fill_rq(struct ud_resources *res) -{ - int cur_receive; - int ret; - - for (cur_receive=0; cur_receivenum_of_oust; ++cur_receive) { - ret = fill_rq_entry(res, cur_receive); - if (ret < 0) { - pr_err("failed to fill_rq_entry\n"); - return ret; - } - } - - return 0; -} - -/***************************************************************************** -* Function: ud_resources_create -*****************************************************************************/ -int ud_resources_create(struct ud_resources *res) -{ - struct ibv_device *ib_dev = NULL; - size_t size; - int i; - int cq_size; - int num_devices; - - /* get device names in the system */ - res->dev_list = ibv_get_device_list(&num_devices); - if (!res->dev_list) { - pr_err("failed to get IB devices list\n"); - return -1; - } - - for (i = 0; i < num_devices; i ++) { - if (!strcmp(ibv_get_device_name(res->dev_list[i]), config->dev_name)) { - ib_dev = res->dev_list[i]; - break; - } - } - - if (!ib_dev) { - pr_err("IB device %s wasn't found\n", config->dev_name); - return -ENXIO; - } - - pr_debug("Device %s was found\n", config->dev_name); - - /* get device handle */ - res->ib_ctx = ibv_open_device(ib_dev); - if (!res->ib_ctx) { - pr_err("failed to open device %s\n", config->dev_name); - return -ENXIO; - } - - res->channel = ibv_create_comp_channel(res->ib_ctx); - if (!res->channel) { - pr_err("failed to create completion channel \n"); - return -ENXIO; - } - - res->pd = ibv_alloc_pd(res->ib_ctx); - if (!res->pd) { - pr_err("ibv_alloc_pd failed\n"); - return -1; - } - - cq_size = config->num_of_oust; - res->recv_cq = ibv_create_cq(res->ib_ctx, cq_size, NULL, res->channel, 0); - if (!res->recv_cq) { - pr_err("failed to create CQ with %u entries\n", cq_size); - return -1; - } - pr_debug("CQ was created with %u CQEs\n", cq_size); - - if (ibv_req_notify_cq(res->recv_cq, 0)) { - pr_err("Couldn't request CQ notification\n"); - return -1; - } - - - res->send_cq = ibv_create_cq(res->ib_ctx, 1, NULL, NULL, 0); - if (!res->send_cq) { - pr_err("failed to create CQ with %u entries\n", 1); - return -1; - } - pr_debug("CQ was created with %u CQEs\n", 1); - - size = cq_size * RECV_BUF_SIZE + SEND_SIZE; - res->recv_buf = malloc(size); - if (!res->recv_buf) { - pr_err("failed to malloc %zu bytes to memory buffer\n", size); - return -ENOMEM; - } - - memset(res->recv_buf, 0, size); - - res->send_buf = res->recv_buf + cq_size * RECV_BUF_SIZE; - - res->mr = ibv_reg_mr(res->pd, res->recv_buf, size, IBV_ACCESS_LOCAL_WRITE); - if (!res->mr) { - pr_err("ibv_reg_mr failed\n"); - return -1; - } - pr_debug("MR was created with addr=%p, lkey=0x%x,\n", res->recv_buf, res->mr->lkey); - - { - struct ibv_qp_init_attr attr = { - .send_cq = res->send_cq, - .recv_cq = res->recv_cq, - .cap = { - .max_send_wr = 1, - .max_recv_wr = config->num_of_oust, - .max_send_sge = 1, - .max_recv_sge = 1 - }, - .qp_type = IBV_QPT_UD, - .sq_sig_all = 1, - }; - - res->qp = ibv_create_qp(res->pd, &attr); - if (!res->qp) { - pr_err("failed to create QP\n"); - return -1; - } - pr_debug("QP was created, QP number=0x%x\n", res->qp->qp_num); - } - - /* modify the QP to RTS (connect the QPs) */ - if (modify_qp_to_rts(res->qp)) { - pr_err("failed to modify QP state from RESET to RTS\n"); - return -1; - } - - pr_debug("QPs were modified to RTS\n"); - - if (fill_rq(res)) - return -1; - - res->mad_buffer = malloc(sizeof(struct umad_sa_packet)); - if (!res->mad_buffer) { - pr_err("Could not alloc mad_buffer, abort\n"); - return -1; - } - - res->mad_buffer_mutex = malloc(sizeof(pthread_mutex_t)); - if (!res->mad_buffer_mutex) { - pr_err("Could not alloc mad_buffer_mutex, abort\n"); - return -1; - } - - if (pthread_mutex_init(res->mad_buffer_mutex, NULL)) { - pr_err("Could not init mad_buffer_mutex, abort\n"); - return -1; - } - - return 0; -} - -uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num) -{ - struct ibv_port_attr port_attr; - - return ibv_query_port(ib_ctx, port_num, &port_attr) == 0 ? - port_attr.lid : 0; -} - -int create_ah(struct ud_resources *ud_res) -{ - struct ibv_ah_attr ah_attr; - - assert(!ud_res->ah); - - /* create the UD AV */ - memset(&ah_attr, 0, sizeof(ah_attr)); - - if (ibv_query_port(ud_res->ib_ctx, config->port_num, &ud_res->port_attr)) { - pr_err("ibv_query_port on port %u failed\n", config->port_num); - return -1; - } - - ah_attr.dlid = ud_res->port_attr.sm_lid; - ah_attr.port_num = config->port_num; - - ud_res->ah = ibv_create_ah(ud_res->pd, &ah_attr); - if (!ud_res->ah) { - pr_err("failed to create UD AV\n"); - return -1; - } - - return 0; -} - -/***************************************************************************** -* Function: ud_resources_destroy -*****************************************************************************/ -int ud_resources_destroy(struct ud_resources *res) -{ - int test_result = 0; - - if (res->qp) { - if (ibv_destroy_qp(res->qp)) { - pr_err("failed to destroy QP\n"); - test_result = 1; - } - } - - if (res->mr) { - if (ibv_dereg_mr(res->mr)) { - pr_err("ibv_dereg_mr failed\n"); - test_result = 1; - } - } - - if (res->send_cq) { - if (ibv_destroy_cq(res->send_cq)) { - pr_err("ibv_destroy_cq of CQ failed\n"); - test_result = 1; - } - } - - if (res->recv_cq) { - if (ibv_destroy_cq(res->recv_cq)) { - pr_err("ibv_destroy_cq of CQ failed\n"); - test_result = 1; - } - } - - if (res->channel) { - if (ibv_destroy_comp_channel(res->channel)) { - pr_err("ibv_destroy_comp_channel failed\n"); - test_result = 1; - } - } - - if (res->ah) { - if (ibv_destroy_ah(res->ah)) { - pr_err("ibv_destroy_ah failed\n"); - test_result = 1; - } - } - - if (res->pd) { - if (ibv_dealloc_pd(res->pd)) { - pr_err("ibv_dealloc_pd failed\n"); - test_result = 1; - } - } - - if (res->ib_ctx) { - if (ibv_close_device(res->ib_ctx)) { - pr_err("ibv_close_device failed\n"); - test_result = 1; - } - } - - if (res->dev_list) - ibv_free_device_list(res->dev_list); - - if (res->recv_buf) - free(res->recv_buf); - - if (res->mad_buffer) - free(res->mad_buffer); - - if (res->mad_buffer_mutex) - free(res->mad_buffer_mutex); - - return test_result; -} - -static void fill_send_request(struct ud_resources *res, struct ibv_send_wr *psr, - struct ibv_sge *psg, struct umad_hdr *mad_hdr) -{ - static int wr_id=0; - - assert(res->ah); - - memset(psr, 0, sizeof(*psr)); - - psr->next = NULL; - psr->wr_id = wr_id++; - psr->sg_list = psg; - psr->num_sge = 1; - psr->opcode = IBV_WR_SEND; -// psr->send_flags = IBV_SEND_SIGNALED | IBV_SEND_INLINE; - psr->send_flags = IBV_SEND_SIGNALED; - psr->wr.ud.ah = res->ah; - psr->wr.ud.remote_qpn = 1; - psr->wr.ud.remote_qkey = UMAD_QKEY; - - psg->addr = (uintptr_t) mad_hdr; - psg->length = SEND_SIZE; - psg->lkey = res->mr->lkey; -} - -static int stop_threads(struct sync_resources *sync_res) -{ - int result; - - pthread_mutex_lock(&sync_res->retry_mutex); - result = sync_res->stop_threads; - pthread_mutex_unlock(&sync_res->retry_mutex); - - return result; -} - -static int poll_cq(struct sync_resources *sync_res, struct ibv_cq *cq, - struct ibv_wc *wc, struct ibv_comp_channel *channel) -{ - int ret; - struct ibv_cq *ev_cq; - void *ev_ctx; - - if (channel) { - if (ibv_get_cq_event(channel, &ev_cq, &ev_ctx)) { - pr_err("Failed to get cq_event\n"); - return -1; - } - - ibv_ack_cq_events(ev_cq, 1); - - if (ev_cq != cq) { - pr_debug("CQ event for unknown CQ %p\n", ev_cq); - return -1; - } - - if (ibv_req_notify_cq(cq, 0)) { - pr_err("Couldn't request CQ notification\n"); - return -1; - } - - } - - do { - ret = ibv_poll_cq(cq, 1, wc); - if (ret < 0) { - pr_err("poll CQ failed\n"); - return ret; - } - - if (ret > 0 && wc->status != IBV_WC_SUCCESS) { - if (!stop_threads(sync_res)) - pr_err("got bad completion with status: 0x%x\n", - wc->status); - return -ret; - } - - if (ret == 0 && channel) { - pr_err("Weird poll returned no cqe after CQ event\n"); - return -1; - } - } while (ret == 0); - - return 0; -} - -/***************************************************************************** -* Function: register_to_trap -*****************************************************************************/ -static int register_to_trap(struct sync_resources *sync_res, - struct ud_resources *res, int dest_lid, - int trap_num, int subscribe) -{ - struct ibv_send_wr sr; - struct ibv_wc wc; - struct ibv_sge sg; - struct ibv_send_wr *_bad_wr = NULL; - struct ibv_send_wr **bad_wr = &_bad_wr; - int counter = 0; - int rc = 0; - int ret; - long long unsigned comp_mask = 0; - - struct umad_hdr *mad_hdr = (struct umad_hdr *) (res->send_buf); - struct umad_sa_packet *p_sa_mad = (struct umad_sa_packet *) (res->send_buf); - struct ib_inform_info *data = (struct ib_inform_info *) (p_sa_mad->data); - static uint64_t trans_id = 0x0000FFFF; - - if (subscribe) - pr_debug("Registering to trap:%d (sm in %#x)\n", trap_num, dest_lid); - else - pr_debug("Deregistering from trap:%d (sm in %#x)\n", trap_num, dest_lid); - - memset(res->send_buf, 0, SEND_SIZE); - - fill_send_request(res, &sr, &sg, mad_hdr); - - umad_init_new(mad_hdr, /* Mad Header */ - UMAD_CLASS_SUBN_ADM, /* Management Class */ - UMAD_SA_CLASS_VERSION, /* Class Version */ - UMAD_METHOD_SET, /* Method */ - 0, /* Transaction ID - will be set before the send in the loop*/ - htobe16(UMAD_ATTR_INFORM_INFO), /* Attribute ID */ - 0 ); /* Attribute Modifier */ - - - data->lid_range_begin = htobe16(0xFFFF); - data->is_generic = 1; - data->subscribe = subscribe; - if (trap_num == UMAD_SM_GID_IN_SERVICE_TRAP) - data->trap_type = htobe16(3); /* SM */ - else if (trap_num == UMAD_SM_LOCAL_CHANGES_TRAP) - data->trap_type = htobe16(4); /* Informational */ - data->g_or_v.generic.trap_num = htobe16(trap_num); - data->g_or_v.generic.node_type_msb = 0; - if (trap_num == UMAD_SM_GID_IN_SERVICE_TRAP) - /* Class Manager */ - data->g_or_v.generic.node_type_lsb = htobe16(4); - else if (trap_num == UMAD_SM_LOCAL_CHANGES_TRAP) - /* Channel Adapter */ - data->g_or_v.generic.node_type_lsb = htobe16(1); - - comp_mask |= SRP_INFORMINFO_LID_COMP | - SRP_INFORMINFO_ISGENERIC_COMP | - SRP_INFORMINFO_SUBSCRIBE_COMP | - SRP_INFORMINFO_TRAPTYPE_COMP | - SRP_INFORMINFO_TRAPNUM_COMP | - SRP_INFORMINFO_PRODUCER_COMP; - - if (!data->subscribe) { - data->g_or_v.generic.qpn_resp_time_val = htobe32(res->qp->qp_num << 8); - comp_mask |= SRP_INFORMINFO_QPN_COMP; - } - - p_sa_mad->comp_mask = htobe64(comp_mask); - pr_debug("comp_mask: %llx\n", comp_mask); - - do { - pthread_mutex_lock(res->mad_buffer_mutex); - res->mad_buffer->mad_hdr.base_version = 0; // flag that the buffer is empty - pthread_mutex_unlock(res->mad_buffer_mutex); - mad_hdr->tid = htobe64(trans_id); - trans_id++; - - ret = ibv_post_send(res->qp, &sr, bad_wr); - if (ret) { - pr_err("failed to post SR\n"); - return ret; - } - - ret = poll_cq(sync_res, res->send_cq, &wc, NULL); - if (ret < 0) - return ret; - - /* sleep and check for response from SA */ - do { - srp_sleep(1, 0); - pthread_mutex_lock(res->mad_buffer_mutex); - if (res->mad_buffer->mad_hdr.base_version == 0) - rc = 0; - else if (res->mad_buffer->mad_hdr.tid == mad_hdr->tid) - rc = 1; - else { - res->mad_buffer->mad_hdr.base_version = 0; - rc = 2; - } - pthread_mutex_unlock(res->mad_buffer_mutex); - } while (rc == 2); // while old response. - - } while (rc == 0 && ++counter < 3); - - if (counter==3) { - pr_err("No response to inform info registration\n"); - return -EAGAIN; - } - - return 0; -} - - -/***************************************************************************** -* Function: response_to_trap -*****************************************************************************/ -static int response_to_trap(struct sync_resources *sync_res, - struct ud_resources *res, - struct umad_sa_packet *mad_buffer) -{ - struct ibv_send_wr sr; - struct ibv_sge sg; - struct ibv_send_wr *_bad_wr = NULL; - struct ibv_send_wr **bad_wr = &_bad_wr; - int ret; - struct ibv_wc wc; - - struct umad_sa_packet *response_buffer = (struct umad_sa_packet *) (res->send_buf); - - memcpy(response_buffer, mad_buffer, sizeof(struct umad_sa_packet)); - response_buffer->mad_hdr.method = UMAD_METHOD_REPORT_RESP; - - fill_send_request(res, &sr, &sg, (struct umad_hdr *) response_buffer); - ret = ibv_post_send(res->qp, &sr, bad_wr); - if (ret < 0) { - pr_err("failed to post response\n"); - return ret; - } - ret = poll_cq(sync_res, res->send_cq, &wc, NULL); - - return ret; -} - - -/***************************************************************************** -* Function: get_trap_notices -*****************************************************************************/ -static int get_trap_notices(struct resources *res) -{ - struct ibv_wc wc; - int cur_receive = 0; - int ret = 0; - int pkey_index; - uint16_t pkey; - char *buffer; - struct umad_sa_packet *mad_buffer; - struct ib_mad_notice_attr *notice_buffer; - int trap_num; - - while (!stop_threads(res->sync_res)) { - - ret = poll_cq(res->sync_res, res->ud_res->recv_cq, &wc, - res->ud_res->channel); - if (ret < 0) - continue; - - pr_debug("get_trap_notices: Got CQE wc.wr_id=%lld\n", (long long int) wc.wr_id); - cur_receive = wc.wr_id; - buffer = res->ud_res->recv_buf + RECV_BUF_SIZE * cur_receive; - mad_buffer = (struct umad_sa_packet *) (buffer + GRH_SIZE); - - if ((mad_buffer->mad_hdr.mgmt_class == UMAD_CLASS_SUBN_ADM) && - (mad_buffer->mad_hdr.method == UMAD_METHOD_GET_RESP) && - (be16toh(mad_buffer->mad_hdr.attr_id) == UMAD_ATTR_INFORM_INFO)) { - /* this is probably a response to register to trap */ - pthread_mutex_lock(res->ud_res->mad_buffer_mutex); - *res->ud_res->mad_buffer = *mad_buffer; - pthread_mutex_unlock(res->ud_res->mad_buffer_mutex); - } else if ((mad_buffer->mad_hdr.mgmt_class == UMAD_CLASS_SUBN_ADM) && - (mad_buffer->mad_hdr.method == UMAD_METHOD_REPORT) && - (be16toh(mad_buffer->mad_hdr.attr_id) == UMAD_ATTR_NOTICE)) - { /* this is a trap notice */ - pkey_index = wc.pkey_index; - ret = pkey_index_to_pkey(res->umad_res, pkey_index, &pkey); - if (ret) { - pr_err("get_trap_notices: Got Bad pkey_index (%d)\n", - pkey_index); - wake_up_main_loop(0); - break; - } - - notice_buffer = (struct ib_mad_notice_attr *) (mad_buffer->data); - trap_num = be16toh(notice_buffer->g_or_v.generic.trap_num); - response_to_trap(res->sync_res, res->ud_res, mad_buffer); - if (trap_num == UMAD_SM_GID_IN_SERVICE_TRAP) - push_gid_to_list(res->sync_res, - ¬ice_buffer->data_details.ntc_64_67.gid, - pkey); - else if (trap_num == UMAD_SM_LOCAL_CHANGES_TRAP) { - if (be32toh(notice_buffer->data_details.ntc_144.new_cap_mask) & SRP_IS_DM) - push_lid_to_list(res->sync_res, - be16toh(notice_buffer->data_details.ntc_144.lid), - pkey); - } else { - pr_err("Unhandled trap_num %d\n", trap_num); - } - } - - ret = fill_rq_entry(res->ud_res, cur_receive); - if (ret < 0) { - wake_up_main_loop(0); - break; - } - } - return ret; -} - -void *run_thread_get_trap_notices(void *res_in) -{ - int ret; - - ret = get_trap_notices((struct resources *)res_in); - - pr_debug("get_trap_notices thread ended\n"); - - pthread_exit((void *)(long)ret); -} - - -/***************************************************************************** -* Function: register_to_traps -*****************************************************************************/ -int register_to_traps(struct resources *res, int subscribe) -{ - int rc; - int trap_numbers[] = {UMAD_SM_GID_IN_SERVICE_TRAP, UMAD_SM_LOCAL_CHANGES_TRAP}; - int i; - - for (i=0; i < sizeof(trap_numbers) / sizeof(*trap_numbers); ++i) { - rc = register_to_trap(res->sync_res, res->ud_res, - res->ud_res->port_attr.sm_lid, - trap_numbers[i], subscribe); - if (rc != 0) - return rc; - } - - return 0; - -} - -void *run_thread_listen_to_events(void *res_in) -{ - struct resources *res = (struct resources *)res_in; - struct ibv_async_event event; - - while (!stop_threads(res->sync_res)) { - if (ibv_get_async_event(res->ud_res->ib_ctx, &event)) { - if (errno != EINTR) - pr_err("ibv_get_async_event failed (errno = %d)\n", - errno); - break; - } - - pr_debug("event_type %d, port %d\n", - event.event_type, event.element.port_num); - - switch (event.event_type) { - case IBV_EVENT_PORT_ACTIVE: - case IBV_EVENT_SM_CHANGE: - case IBV_EVENT_LID_CHANGE: - case IBV_EVENT_CLIENT_REREGISTER: - case IBV_EVENT_PKEY_CHANGE: - if (event.element.port_num == config->port_num) { - pthread_mutex_lock(&res->sync_res->mutex); - __schedule_rescan(res->sync_res, 0); - wake_up_main_loop(0); - pthread_mutex_unlock(&res->sync_res->mutex); - } - break; - - case IBV_EVENT_DEVICE_FATAL: - case IBV_EVENT_CQ_ERR: - case IBV_EVENT_QP_FATAL: - /* clean and restart */ - pr_err("Critical event %d, raising catastrophic " - "error signal\n", event.event_type); - raise(SRP_CATAS_ERR); - break; - - /* - - case IBV_EVENT_PORT_ERR: - case IBV_EVENT_QP_REQ_ERR: - case IBV_EVENT_QP_ACCESS_ERR: - case IBV_EVENT_COMM_EST: - case IBV_EVENT_SQ_DRAINED: - case IBV_EVENT_PATH_MIG: - case IBV_EVENT_PATH_MIG_ERR: - case IBV_EVENT_SRQ_ERR: - case IBV_EVENT_SRQ_LIMIT_REACHED: - case IBV_EVENT_QP_LAST_WQE_REACHED: - - */ - - - default: - break; - } - - ibv_ack_async_event(&event); - - } - - return NULL; -} - diff --git a/usr/rdma-core/srp_daemon/srp_ib_types.h b/usr/rdma-core/srp_daemon/srp_ib_types.h deleted file mode 100644 index 8fa19a762..000000000 --- a/usr/rdma-core/srp_daemon/srp_ib_types.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * srp-ib_types - discover SRP targets over IB - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2006 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef SRP_IB_TYPES_H -#define SRP_IB_TYPES_H - -#include -#include -#include /* __be16, __be32 and __be64 */ -#include /* union umad_gid */ -#include - -#define SRP_INFORMINFO_LID_COMP (1 << 1) -#define SRP_INFORMINFO_ISGENERIC_COMP (1 << 4) -#define SRP_INFORMINFO_SUBSCRIBE_COMP (1 << 5) -#define SRP_INFORMINFO_TRAPTYPE_COMP (1 << 6) -#define SRP_INFORMINFO_TRAPNUM_COMP (1 << 7) -#define SRP_INFORMINFO_QPN_COMP (1 << 8) -#define SRP_INFORMINFO_PRODUCER_COMP (1 << 12) - -#define PACK_SUFFIX4 __attribute__((aligned(4))) __attribute__((packed)) -#define PACK_SUFFIX __attribute__((packed)) - -/****d* IBA Base: Constants/MAD_BLOCK_SIZE -* NAME -* MAD_BLOCK_SIZE -* -* DESCRIPTION -* Size of a non-RMPP MAD datagram. -* -* SOURCE -*/ -#define MAD_BLOCK_SIZE 256 - -static inline uint32_t ib_get_attr_size(const __be16 attr_offset) -{ - return( ((uint32_t)be16toh( attr_offset )) << 3 ); -} - -/************************************************************ -* NAME -* MAD_RMPP_HDR_SIZE -* -* DESCRIPTION -* Size of an RMPP header, including the common MAD header. -* -* SOURCE -*/ -enum { - MAD_RMPP_HDR_SIZE = 36, -}; - -/****s* IBA Base: Types/struct ib_path_rec -* NAME -* struct ib_path_rec -* -* DESCRIPTION -* Path records encapsulate the properties of a given -* route between two end-points on a subnet. -* -* SYNOPSIS -*/ -struct ib_path_rec -{ - uint8_t resv0[8]; - union umad_gid dgid; - union umad_gid sgid; - __be16 dlid; - __be16 slid; - __be32 hop_flow_raw; - uint8_t tclass; - uint8_t num_path; - __be16 pkey; - __be16 sl; - uint8_t mtu; - uint8_t rate; - uint8_t pkt_life; - uint8_t preference; - uint8_t resv2[6]; - -} PACK_SUFFIX4; - - -/****f* IBA Base: Types/umad_init_new -* NAME -* umad_init_new -* -* DESCRIPTION -* Initialize UMAD common header. -* -* SYNOPSIS -*/ -static inline void -umad_init_new(struct umad_hdr* const p_mad, - const uint8_t mgmt_class, - const uint8_t class_ver, - const uint8_t method, - const __be64 trans_id, - const __be16 attr_id, - const __be32 attr_mod) -{ - p_mad->base_version = 1; - p_mad->mgmt_class = mgmt_class; - p_mad->class_version = class_ver; - p_mad->method = method; - p_mad->status = 0; - p_mad->class_specific = 0; - p_mad->tid = trans_id; - p_mad->attr_id = attr_id; - p_mad->resv = 0; - p_mad->attr_mod = attr_mod; -} - - -struct ib_inform_info -{ - union umad_gid gid; - __be16 lid_range_begin; - __be16 lid_range_end; - __be16 reserved1; - uint8_t is_generic; - uint8_t subscribe; - __be16 trap_type; - union _inform_g_or_v - { - struct _inform_generic - { - __be16 trap_num; - __be32 qpn_resp_time_val; - uint8_t reserved2; - uint8_t node_type_msb; - __be16 node_type_lsb; - } PACK_SUFFIX generic; - - struct _inform_vend - { - __be16 dev_id; - __be32 qpn_resp_time_val; - uint8_t reserved2; - uint8_t vendor_id_msb; - __be16 vendor_id_lsb; - } PACK_SUFFIX vend; - - } PACK_SUFFIX g_or_v; - -} PACK_SUFFIX4; - -struct ib_mad_notice_attr // Total Size calc Accumulated -{ - uint8_t generic_type; // 1 1 - - union _notice_g_or_v - { - struct _notice_generic // 5 6 - { - uint8_t prod_type_msb; - __be16 prod_type_lsb; - __be16 trap_num; - } PACK_SUFFIX generic; - - struct _notice_vend - { - uint8_t vend_id_msb; - __be16 vend_id_lsb; - __be16 dev_id; - } PACK_SUFFIX vend; - } g_or_v; - - __be16 issuer_lid; // 2 8 - __be16 toggle_count; // 2 10 - - union _data_details // 54 64 - { - struct _raw_data - { - uint8_t details[54]; - } raw_data; - - struct _ntc_64_67 - { - uint8_t res[6]; - union umad_gid gid; // the Node or Multicast Group that came in/out - } PACK_SUFFIX ntc_64_67; - - struct _ntc_144 { - __be16 pad1; - __be16 lid; // lid where capability mask changed - __be16 pad2; - __be32 new_cap_mask; // new capability mask - } PACK_SUFFIX ntc_144; - - } data_details; - - union umad_gid issuer_gid; // 16 80 - -} PACK_SUFFIX4; - -/****f* IBA Base: Types/ib_gid_get_guid -* NAME -* ib_gid_get_guid -* -* DESCRIPTION -* Gets the guid from a GID. -* -* SYNOPSIS -*/ -static inline __be64 ib_gid_get_guid(const union umad_gid *const p_gid) -{ - return p_gid->global.interface_id; -} - -#endif diff --git a/usr/rdma-core/srp_daemon/srp_sync.c b/usr/rdma-core/srp_daemon/srp_sync.c deleted file mode 100644 index 036fbe54b..000000000 --- a/usr/rdma-core/srp_daemon/srp_sync.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * srp_sync - discover SRP targets over IB - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2006 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Author: ishai Rabinovitz [ishai@mellanox.co.il]$ - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "srp_daemon.h" - -/* - * Schedule a rescan at now + when if when >= 0 or disable rescanning if - * when < 0. - */ -void __schedule_rescan(struct sync_resources *res, int when) -{ - struct timespec *ts = &res->next_recalc_time; - - clock_gettime(CLOCK_MONOTONIC, ts); - ts->tv_sec = when >= 0 ? ts->tv_sec + when : LONG_MAX; -} - -void schedule_rescan(struct sync_resources *res, int when) -{ - pthread_mutex_lock(&res->mutex); - __schedule_rescan(res, when); - pthread_mutex_unlock(&res->mutex); -} - -int __rescan_scheduled(struct sync_resources *res) -{ - struct timespec now; - - clock_gettime(CLOCK_MONOTONIC, &now); - return ts_cmp(&res->next_recalc_time, &now, <=); -} - -int rescan_scheduled(struct sync_resources *res) -{ - int ret; - - pthread_mutex_lock(&res->mutex); - ret = __rescan_scheduled(res); - pthread_mutex_unlock(&res->mutex); - - return ret; -} - -int sync_resources_init(struct sync_resources *res) -{ - int ret; - - res->stop_threads = 0; - __schedule_rescan(res, 0); - res->next_task = 0; - ret = pthread_mutex_init(&res->mutex, NULL); - if (ret < 0) { - pr_err("could not initialize mutex\n"); - return ret; - } - - res->retry_tasks_head = NULL; - ret = pthread_mutex_init(&res->retry_mutex, NULL); - if (ret < 0) { - pr_err("could not initialize mutex\n"); - return ret; - } - ret = pthread_cond_init(&res->retry_cond, NULL); - if (ret < 0) - pr_err("could not initialize cond\n"); - - return ret; -} - -void sync_resources_cleanup(struct sync_resources *res) -{ - pthread_cond_destroy(&res->retry_cond); - pthread_mutex_destroy(&res->retry_mutex); - pthread_mutex_destroy(&res->mutex); -} - -void push_gid_to_list(struct sync_resources *res, union umad_gid *gid, - uint16_t pkey) -{ - int i; - - /* If there is going to be a recalc soon - do nothing */ - if (rescan_scheduled(res)) - return; - - pthread_mutex_lock(&res->mutex); - - /* check if the gid is already in the list */ - - for (i=0; i < res->next_task; ++i) - if (!memcmp(&res->tasks[i].gid, gid, 16) && - res->tasks[i].pkey == pkey) { - pr_debug("gid is already in task list\n"); - pthread_mutex_unlock(&res->mutex); - return; - } - - if (res->next_task == SIZE_OF_TASKS_LIST) { - /* if the list is full, lets do a full rescan */ - - __schedule_rescan(res, 0); - res->next_task = 0; - } else { - /* otherwise enter to the next entry */ - - res->tasks[res->next_task].gid = *gid; - res->tasks[res->next_task].lid = 0; - res->tasks[res->next_task].pkey = pkey; - ++res->next_task; - } - - wake_up_main_loop(0); - pthread_mutex_unlock(&res->mutex); -} - -void push_lid_to_list(struct sync_resources *res, uint16_t lid, uint16_t pkey) -{ - int i; - - /* If there is going to be a recalc soon - do nothing */ - if (rescan_scheduled(res)) - return; - - pthread_mutex_lock(&res->mutex); - - - /* check if the lid is already in the list */ - - for (i=0; i < res->next_task; ++i) - if (res->tasks[i].lid == lid && res->tasks[i].pkey == pkey) { - pr_debug("lid %#x is already in task list\n", lid); - pthread_mutex_unlock(&res->mutex); - return; - } - - if (res->next_task == SIZE_OF_TASKS_LIST) { - /* if the list is full, lets do a full rescan */ - - __schedule_rescan(res, 0); - res->next_task = 0; - } else { - /* otherwise enter to the next entry */ - - res->tasks[res->next_task].lid = lid; - res->tasks[res->next_task].pkey = pkey; - memset(&res->tasks[res->next_task].gid, 0, 16); - ++res->next_task; - } - - wake_up_main_loop(0); - pthread_mutex_unlock(&res->mutex); -} - -void clear_traps_list(struct sync_resources *res) -{ - pthread_mutex_lock(&res->mutex); - res->next_task = 0; - pthread_mutex_unlock(&res->mutex); -} - - -/* assumes that res->mutex is locked !!! */ -int pop_from_list(struct sync_resources *res, uint16_t *lid, - union umad_gid *gid, uint16_t *pkey) -{ - int ret=0; - int i; - - if (res->next_task) { - *lid = res->tasks[0].lid; - *pkey = res->tasks[0].pkey; - *gid = res->tasks[0].gid; - /* push the rest down */ - for (i=1; i < res->next_task; ++i) - res->tasks[i-1] = res->tasks[i]; - ret = 1; - --res->next_task; - } - - return ret; -} - - -/* assumes that res->retry_mutex is locked !!! */ -struct target_details *pop_from_retry_list(struct sync_resources *res) -{ - struct target_details *ret = res->retry_tasks_head; - - if (ret) - res->retry_tasks_head = ret->next; - else - res->retry_tasks_tail = NULL; - - return ret; -} - -void push_to_retry_list(struct sync_resources *res, - struct target_details *orig_target) -{ - struct target_details *target; - - /* If there is going to be a recalc soon - do nothing */ - if (rescan_scheduled(res)) - return; - - target = malloc(sizeof(struct target_details)); - memcpy(target, orig_target, sizeof(struct target_details)); - - pthread_mutex_lock(&res->retry_mutex); - - if (!res->retry_tasks_head) - res->retry_tasks_head = target; - - if (res->retry_tasks_tail) - res->retry_tasks_tail->next = target; - - res->retry_tasks_tail = target; - - target->next = NULL; - - pthread_cond_signal(&res->retry_cond); - pthread_mutex_unlock(&res->retry_mutex); -} - -/* assumes that res->retry_mutex is locked !!! */ -int retry_list_is_empty(struct sync_resources *res) -{ - return res->retry_tasks_head == NULL; -} diff --git a/usr/rdma-core/srp_daemon/srpd.in b/usr/rdma-core/srp_daemon/srpd.in deleted file mode 100755 index 7e2316f6f..000000000 --- a/usr/rdma-core/srp_daemon/srpd.in +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/bash -# Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md -# -# Manage the SRP client daemon (srp_daemon) -# -# chkconfig: - 25 75 -# description: Starts/Stops InfiniBand SRP client service -# config: @CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf -# -### BEGIN INIT INFO -# Provides: srpd -# Required-Start: $syslog @RDMA_SERVICE@ -# Required-Stop: $syslog @RDMA_SERVICE@ -# Default-Start: @SRP_DEFAULT_START@ -# Default-Stop: @SRP_DEFAULT_STOP@ -# Should-Start: -# Should-Stop: -# Short-Description: Starts and stops the InfiniBand SRP client service -# Description: The InfiniBand SRP client service attaches to SRP devices -# on the InfiniBand fabric and makes them appear as local disks to -# to the system. This service starts the client daemon that's -# responsible for initiating and maintaining the connections to -# remote devices. -### END INIT INFO - -if [ -e /etc/rdma/rdma.conf ]; then - # RHEL / Fedora. - RDMA_CONFIG=/etc/rdma/rdma.conf -else - # OFED - RDMA_CONFIG=/etc/infiniband/openib.conf -fi -if [ -f $RDMA_CONFIG ]; then - . $RDMA_CONFIG -fi -pidfile=@CMAKE_INSTALL_FULL_RUNDIR@/srp_daemon.sh.pid -prog=@CMAKE_INSTALL_FULL_SBINDIR@/srp_daemon.sh - -checkpid() { - [ -e "/proc/$1" ] -} - -stop_srp_daemon() { - if ! running; then - return 1 - fi - - local pid=`cat $pidfile` - kill $pid - # timeout 30 seconds for termination - for i in `seq 300`; do - if ! checkpid $pid; then - return 0 - fi - sleep 0.1 - done - kill -9 $pid - # If srp_daemon executables didn't finish by now - # force kill - pkill -9 srp_daemon - - return 0 -} - -# if the ib_srp module is loaded or built into the kernel return 0 otherwise -# return 1. -is_srp_mod_loaded() { - [ -e /sys/module/ib_srp ] -} - -running() { - [ -f $pidfile ] && checkpid "$(cat $pidfile)" -} - -start() { - if ! is_srp_mod_loaded; then - echo "SRP kernel module is not loaded, unable to start SRP daemon" - return 6 - fi - if running; then - echo "Already started" - return 0 - fi - - echo -n "Starting SRP daemon service" - - if [ "$SRP_DEFAULT_TL_RETRY_COUNT" ]; then - params=$params"-l $SRP_DEFAULT_TL_RETRY_COUNT " - fi - - setsid $prog $params &/dev/null & - RC=$? - [ $RC -eq 0 ] && echo || echo " ...failed" - return $RC -} - -stop() { - echo -n "Stopping SRP daemon service" - - stop_srp_daemon - RC=$? - for ((i=0;i<5;i++)); do - if ! running; then - rm -f $pidfile - break - fi - sleep 1 - done - [ $RC -eq 0 ] && echo || echo " ...failed" - return $RC -} - -status() { - local ret - - if [ ! -f $pidfile ]; then - ret=3 # program not running - else - checkpid "$(cat $pidfile)" - ret=$? # 1: pid file exists and not running / 0: running - fi - if [ $ret -eq 0 ] ; then - echo "$prog is running... pid=$(cat $pidfile)" - else - echo "$prog is not running." - fi - return $ret -} - -restart() { - stop - start -} - -condrestart() { - [ -f $pidfile ] && restart || return 0 -} - -usage() { - echo - echo "Usage: `basename $0` {start|stop|restart|condrestart|try-restart|force-reload|status}" - echo - return 2 -} - -case $1 in - start|stop|restart|condrestart|try-restart|force-reload) - [ `id -u` != "0" ] && exit 4 ;; -esac - -case $1 in - start) start; RC=$? ;; - stop) stop; RC=$? ;; - restart) restart; RC=$? ;; - reload) RC=3 ;; - condrestart) condrestart; RC=$? ;; - try-restart) condrestart; RC=$? ;; - force-reload) condrestart; RC=$? ;; - status) status; RC=$? ;; - *) usage; RC=$? ;; -esac - -exit $RC diff --git a/usr/rdma-core/srp_daemon/start_on_all_ports b/usr/rdma-core/srp_daemon/start_on_all_ports deleted file mode 100644 index 0a7e72e26..000000000 --- a/usr/rdma-core/srp_daemon/start_on_all_ports +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -for p in /sys/class/infiniband/*/ports/*; do - [ -e "$p" ] || continue - p=${p#/sys/class/infiniband/} - nohup /bin/systemctl start "srp_daemon_port@${p/\/ports\//:}" &/dev/null & -done diff --git a/usr/rdma-core/suse/rdma-core.spec b/usr/rdma-core/suse/rdma-core.spec deleted file mode 100644 index defe3b425..000000000 --- a/usr/rdma-core/suse/rdma-core.spec +++ /dev/null @@ -1,677 +0,0 @@ -# -# spec file for package rdma-core -# -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. -# -# All modifications and additions to the file contributed by third parties -# remain the property of their copyright owners, unless otherwise agreed -# upon. The license for this file, and modifications and additions to the -# file, is the same license as for the pristine package itself (unless the -# license for the pristine package is not an Open Source License, in which -# case the license is the MIT License). An "Open Source License" is a -# license that conforms to the Open Source Definition (Version 1.9) -# published by the Open Source Initiative. - -# Please submit bugfixes or comments via http://bugs.opensuse.org/ -# - - -%bcond_without systemd -%define git_ver %{nil} -Name: rdma-core -Version: 16 -Release: 0 -Summary: RDMA core userspace libraries and daemons -License: GPL-2.0 or BSD-2-Clause -Group: Productivity/Networking/Other - -%define verbs_so_major 1 -%define ibcm_so_major 1 -%define rdmacm_so_major 1 -%define umad_so_major 3 -%define mlx4_so_major 1 -%define mlx5_so_major 1 - -%define verbs_lname libibverbs%{verbs_so_major} -%define ibcm_lname libibcm%{ibcm_so_major} -%define rdmacm_lname librdmacm%{rdmacm_so_major} -%define umad_lname libibumad%{umad_so_major} -%define mlx4_lname libmlx4-%{mlx4_so_major} -%define mlx5_lname libmlx5-%{mlx5_so_major} - -%ifnarch s390 %arm -%define dma_coherent 1 -%endif - -# Almost everything is licensed under the OFA dual GPLv2, 2 Clause BSD license -# providers/ipathverbs/ Dual licensed using a BSD license with an extra patent clause -# providers/rxe/ Incorporates code from ipathverbs and contains the patent clause -# providers/hfi1verbs Uses the 3 Clause BSD license -Url: https://github.com/linux-rdma/rdma-core -Source: rdma-core-%{version}%{git_ver}.tar.gz -Source1: baselibs.conf -BuildRequires: binutils -BuildRequires: cmake >= 2.8.11 -BuildRequires: gcc -BuildRequires: pkgconfig -BuildRequires: pkgconfig(libsystemd) -BuildRequires: pkgconfig(libudev) -BuildRequires: pkgconfig(systemd) -BuildRequires: pkgconfig(udev) -%ifnarch s390 s390x -BuildRequires: valgrind-devel -%endif -BuildRequires: systemd-rpm-macros -BuildRequires: pkgconfig(libnl-3.0) -BuildRequires: pkgconfig(libnl-route-3.0) -BuildRequires: pkgconfig(systemd) -Requires: kmod -Requires: systemd -Requires: udev - -# SUSE previously shipped rdma as a stand-alone -# package which we're supplanting here. - -Provides: rdma = %{version} -Obsoletes: rdma < %{version} -Provides: ofed = %{version} -Obsoletes: ofed < %{version} - -%if 0%{?suse_version} >= 1330 -BuildRequires: curl-mini -%endif - -# Tumbleweed's cmake RPM macro adds -Wl,--no-undefined to the module flags -# which is totally inappropriate and breaks building 'ENABLE_EXPORTS' style -# module libraries (eg ibacmp). -#%%define CMAKE_FLAGS -DCMAKE_MODULE_LINKER_FLAGS="" - -# Since we recommend developers use Ninja, so should packagers, for consistency. -%define CMAKE_FLAGS %{nil} -%if 0%{?suse_version} >= 1300 -BuildRequires: ninja -%define CMAKE_FLAGS -GNinja -%define make_jobs ninja -v %{?_smp_mflags} -%define cmake_install DESTDIR=%{buildroot} ninja install -%else -# Fallback to make otherwise -BuildRequires: make -%define make_jobs make -v %{?_smp_mflags} -%define cmake_install DESTDIR=%{buildroot} make install -%endif - -%description -RDMA core userspace infrastructure and documentation, including initialization -scripts, kernel driver-specific modprobe override configs, IPoIB network -scripts, dracut rules, and the rdma-ndd utility. - -%package devel -Summary: RDMA core development libraries and headers -Group: Development/Libraries/C and C++ -Requires: %{name}%{?_isa} = %{version}-%{release} - -Requires: %{ibcm_lname} = %{version}-%{release} -Requires: %{rdmacm_lname} = %{version}-%{release} -Requires: %{umad_lname} = %{version}-%{release} -Requires: %{verbs_lname} = %{version}-%{release} -%%if 0%{?dma_coherent} -Requires: %{mlx4_lname} = %{version}-%{release} -Requires: %{mlx5_lname} = %{version}-%{release} -%endif -Requires: rsocket = %{version}-%{release} - -Provides: libibverbs-devel = %{version}-%{release} -Obsoletes: libibverbs-devel < %{version}-%{release} - -Provides: libibcm-devel = %{version}-%{release} -Obsoletes: libibcm-devel < %{version}-%{release} - -Provides: libibumad-devel = %{version}-%{release} -Obsoletes: libibumad-devel < %{version}-%{release} -Provides: librdmacm-devel = %{version}-%{release} - -Obsoletes: librdmacm-devel < %{version}-%{release} -#Requires: ibacm = %%{version}-%%{release} -Provides: ibacm-devel = %{version}-%{release} -Obsoletes: ibacm-devel < %{version}-%{release} - -%description devel -RDMA core development libraries and headers. - -%package -n libibverbs -Summary: Library & drivers for direct userspace use of InfiniBand/iWARP/RoCE hardware -Group: System/Libraries -Requires: %{name}%{?_isa} = %{version}-%{release} -Obsoletes: libcxgb3-rdmav2 < %{version}-%{release} -Obsoletes: libcxgb4-rdmav2 < %{version}-%{release} -Obsoletes: libhfi1verbs-rdmav2 < %{version}-%{release} -Obsoletes: libi40iw-rdmav2 < %{version}-%{release} -Obsoletes: libipathverbs-rdmav2 < %{version}-%{release} -Obsoletes: libmlx4-rdmav2 < %{version}-%{release} -Obsoletes: libmlx5-rdmav2 < %{version}-%{release} -Obsoletes: libmthca-rdmav2 < %{version}-%{release} -Obsoletes: libnes-rdmav2 < %{version}-%{release} -Obsoletes: libocrdma-rdmav2 < %{version}-%{release} -Obsoletes: librxe-rdmav2 < %{version}-%{release} -%if 0%{?dma_coherent} -Requires: %{mlx4_lname} = %{version}-%{release} -Requires: %{mlx5_lname} = %{version}-%{release} -%endif - -%description -n libibverbs -libibverbs is a library that allows userspace processes to use RDMA -"verbs" as described in the InfiniBand Architecture Specification and -the RDMA Protocol Verbs Specification. This includes direct hardware -access from userspace to InfiniBand/iWARP adapters (kernel bypass) for -fast path operations. - -Device-specific plug-in ibverbs userspace drivers are included: - -- libcxgb3: Chelsio T3 iWARP HCA -- libcxgb4: Chelsio T4 iWARP HCA -- libhfi1: Intel Omni-Path HFI -- libhns: HiSilicon Hip06 SoC -- libi40iw: Intel Ethernet Connection X722 RDMA -- libipathverbs: QLogic InfiniPath HCA -- libmlx4: Mellanox ConnectX-3 InfiniBand HCA -- libmlx5: Mellanox Connect-IB/X-4+ InfiniBand HCA -- libmthca: Mellanox InfiniBand HCA -- libnes: NetEffect RNIC -- libocrdma: Emulex OneConnect RDMA/RoCE Device -- libqedr: QLogic QL4xxx RoCE HCA -- librxe: A software implementation of the RoCE protocol -- libvmw_pvrdma: VMware paravirtual RDMA device - -%package -n %verbs_lname -Summary: Ibverbs runtime library -Group: System/Libraries -Requires: libibverbs = %{version} - -%description -n %verbs_lname -This package contains the ibverbs runtime library. - -%if 0%{?dma_coherent} -%package -n %mlx4_lname -Summary: MLX4 runtime library -Group: System/Libraries - -%description -n %mlx4_lname -This package contains the mlx4 runtime library. - -%package -n %mlx5_lname -Summary: MLX5 runtime library -Group: System/Libraries - -%description -n %mlx5_lname -This package contains the mlx5 runtime library. -%endif - -%package -n libibverbs-utils -Summary: Examples for the libibverbs library -Group: Productivity/Networking/Other -Requires: libibverbs%{?_isa} = %{version} - -%description -n libibverbs-utils -Useful libibverbs example programs such as ibv_devinfo, which -displays information about RDMA devices. - -%package -n ibacm -Summary: InfiniBand Communication Manager Assistant -Group: Productivity/Networking/Other -%{?systemd_requires} -Requires: %{name}%{?_isa} = %{version} -Obsoletes: libibacmp1 < %{version} -Provides: libibacmp1 = %{version} - -%description -n ibacm -The ibacm daemon helps reduce the load of managing path record lookups on -large InfiniBand fabrics by providing a user space implementation of what -is functionally similar to an ARP cache. The use of ibacm, when properly -configured, can reduce the SA packet load of a large IB cluster from O(n^2) -to O(n). The ibacm daemon is started and normally runs in the background, -user applications need not know about this daemon as long as their app -uses librdmacm to handle connection bring up/tear down. The librdmacm -library knows how to talk directly to the ibacm daemon to retrieve data. - -%package -n iwpmd -Summary: Userspace iWarp Port Mapper daemon -Group: Development/Libraries/C and C++ -Requires: %{name}%{?_isa} = %{version} -%{?systemd_requires} - -%description -n iwpmd -iwpmd provides a userspace service for iWarp drivers to claim -tcp ports through the standard socket interface. - -%package -n %ibcm_lname -Summary: Userspace InfiniBand Connection Manager -Group: System/Libraries - -%description -n %ibcm_lname -libibcm provides a userspace library that handles the majority of the low -level work required to open an RDMA connection between two machines. - -%package -n %umad_lname -Summary: OpenFabrics Alliance InfiniBand Userspace Management Datagram library -Group: System/Libraries - -%description -n %umad_lname -libibumad provides the userspace management datagram (umad) library -functions, which sit on top of the umad modules in the kernel. These -are used by the IB diagnostic and management tools, including OpenSM. - -%package -n %rdmacm_lname -Summary: Userspace RDMA Connection Manager -Group: System/Libraries -Requires: %{name} = %{version} - -%description -n %rdmacm_lname -librdmacm provides a userspace RDMA Communication Management API. - -%package -n rsocket -Summary: Preloadable library to turn the socket API RDMA-aware -Group: System/Libraries - -%description -n rsocket -Existing applications can make use of rsockets through the use this -preloadable library. See the documentation in the packaged rsocket(7) -manpage for details. - -%package -n librdmacm-utils -Summary: Examples for the librdmacm library -Group: Productivity/Networking/Other - -%description -n librdmacm-utils -Example test programs for the librdmacm library. - -%package -n srp_daemon -Summary: Tools for using the InfiniBand SRP protocol devices -Group: Development/Libraries/C and C++ -Requires: %{name} = %{version} -Obsoletes: srptools <= 1.0.3 -Provides: srptools = %{version} -%{?systemd_requires} - -%description -n srp_daemon -In conjunction with the kernel ib_srp driver, srp_daemon allows you to -discover and use SCSI devices via the SCSI RDMA Protocol over InfiniBand. - -%package -n rdma-ndd -Summary: Daemon to manage RDMA Node Description -Group: System/Daemons -Requires: %{name} = %{version} -# The udev rules in rdma need to be aware of rdma-ndd: -Conflicts: rdma < 2.1 -%{?systemd_requires} - -%description -n rdma-ndd -rdma-ndd is a system daemon which watches for rdma device changes and/or -hostname changes and updates the Node Description of the rdma devices based -on those changes. - -%prep -%setup -q -n %{name}-%{version}%{git_ver} - -%build - -# New RPM defines _rundir, usually as /run -%if 0%{?_rundir:1} -%else -%define _rundir /var/run -%endif - -# Pass all of the rpm paths directly to GNUInstallDirs and our other defines. -%cmake %{CMAKE_FLAGS} \ - -DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed -Wl,-z,now" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_BINDIR:PATH=%{_bindir} \ - -DCMAKE_INSTALL_SBINDIR:PATH=%{_sbindir} \ - -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=%{_libexecdir} \ - -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=%{_localstatedir} \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=%{_sharedstatedir} \ - -DCMAKE_INSTALL_INCLUDEDIR:PATH=%{_includedir} \ - -DCMAKE_INSTALL_INFODIR:PATH=%{_infodir} \ - -DCMAKE_INSTALL_MANDIR:PATH=%{_mandir} \ - -DCMAKE_INSTALL_SYSCONFDIR:PATH=%{_sysconfdir} \ - -DCMAKE_INSTALL_SYSTEMD_SERVICEDIR:PATH=%{_unitdir} \ - -DCMAKE_INSTALL_SYSTEMD_BINDIR:PATH=%{_libexecdir}/systemd \ - -DCMAKE_INSTALL_INITDDIR:PATH=%{_initddir} \ - -DCMAKE_INSTALL_RUNDIR:PATH=%{_rundir} \ - -DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{name}-%{version} \ - -DCMAKE_INSTALL_UDEV_RULESDIR:PATH=%{_udevrulesdir} -%make_jobs - -%install -cd build -%cmake_install -cd .. -mkdir -p %{buildroot}/%{_sysconfdir}/rdma - -%global dracutlibdir %%{_sysconfdir}/dracut.conf.d -%global sysmodprobedir %%{_sysconfdir}/modprobe.d - -mkdir -p %{buildroot}%{_libexecdir}/udev/rules.d -mkdir -p %{buildroot}%{_udevrulesdir} -mkdir -p %{buildroot}%{dracutlibdir}/modules.d/05rdma -mkdir -p %{buildroot}%{sysmodprobedir} -mkdir -p %{buildroot}%{_unitdir} - -# SRIOV service -install -D -m0644 redhat/rdma.sriov-vfs %{buildroot}/%{_sysconfdir}/rdma/sriov-vfs -install -D -m0755 redhat/rdma.sriov-init %{buildroot}%{_libexecdir}/rdma-set-sriov-vf -install -D -m0644 suse/rdma.sriov-rules %{buildroot}%{_udevrulesdir}/98-rdma-sriov.rules -install -D -m0644 suse/rdma.sriov-service %{buildroot}%{_unitdir}/rdma-sriov.service - -# Port type setup for mlx4 dual port cards -install -D -m0644 redhat/rdma.mlx4.conf %{buildroot}/%{_sysconfdir}/rdma/mlx4.conf -sed 's%/usr/libexec%/usr/lib%g' redhat/rdma.mlx4.sys.modprobe > %{buildroot}%{sysmodprobedir}/50-libmlx4.conf -chmod 0644 %{buildroot}%{sysmodprobedir}/50-libmlx4.conf -install -D -m0755 redhat/rdma.mlx4-setup.sh %{buildroot}%{_libexecdir}/mlx4-setup.sh - -# Dracut file for IB support during boot -sed 's%/usr/libexec%/usr/lib%g' redhat/rdma.modules-setup.sh > %{buildroot}%{dracutlibdir}/modules.d/05rdma/module-setup.sh -chmod 0755 %{buildroot}%{dracutlibdir}/modules.d/05rdma/module-setup.sh - -# ibacm -cd build -LD_LIBRARY_PATH=./lib bin/ib_acme -D . -O -install -D -m0644 ibacm_opts.cfg %{buildroot}%{_sysconfdir}/rdma/ - -for service in rdma rdma-ndd ibacm iwpmd srp_daemon; do ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc${service}; done - -# Delete the package's init.d scripts -rm -rf %{buildroot}/%{_initddir}/ -rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh - -%post -n %verbs_lname -p /sbin/ldconfig -%postun -n %verbs_lname -p /sbin/ldconfig - -%if 0%{?dma_coherent} -%post -n %mlx4_lname -p /sbin/ldconfig -%postun -n %mlx4_lname -p /sbin/ldconfig - -%post -n %mlx5_lname -p /sbin/ldconfig -%postun -n %mlx5_lname -p /sbin/ldconfig -%endif - -%post -n %ibcm_lname -p /sbin/ldconfig -%postun -n %ibcm_lname -p /sbin/ldconfig - -%post -n %umad_lname -p /sbin/ldconfig -%postun -n %umad_lname -p /sbin/ldconfig - -%post -n %rdmacm_lname -p /sbin/ldconfig -%postun -n %rdmacm_lname -p /sbin/ldconfig - -%post -# we ship udev rules, so trigger an update. -/sbin/udevadm trigger --subsystem-match=infiniband --action=change || true -/sbin/udevadm trigger --subsystem-match=infiniband_mad --action=change || true - -# -# ibacm -# -%pre -n ibacm -%service_add_pre ibacm.service ibacm.socket - -%post -n ibacm -%service_add_post ibacm.service ibacm.socket - -%preun -n ibacm -%service_del_preun ibacm.service ibacm.socket - -%postun -n ibacm -%service_del_postun ibacm.service ibacm.socket - -# -# srp daemon -# -%pre -n srp_daemon -%service_add_pre srp_daemon.service srp_daemon_port@.service - -%post -n srp_daemon -%service_add_post srp_daemon.service srp_daemon_port@.service -# we ship udev rules, so trigger an update. -/sbin/udevadm trigger --subsystem-match=infiniband_mad --action=change - -%preun -n srp_daemon -%service_del_preun srp_daemon.service -%service_del_postun -n srp_daemon_port@.service - -%postun -n srp_daemon -%service_del_postun srp_daemon.service -%service_del_postun -n srp_daemon_port@.service - -# -# iwpmd -# -%pre -n iwpmd -%service_add_pre ibiwpmd.service - -%post -n iwpmd -%service_add_post iwpmd.service - -%preun -n iwpmd -%service_del_preun iwpmd.service - -%postun -n iwpmd -%service_del_postun iwpmd.service - -# -# rdma-ndd -# -%pre -n rdma-ndd -%service_add_pre rdma-ndd.service - -%preun -n rdma-ndd -%service_del_preun rdma-ndd.service - -%post -n rdma-ndd -%service_add_post rdma-ndd.service - -%postun -n rdma-ndd -%service_del_postun rdma-ndd.service - -%files -%defattr(-,root,root) -%dir %{_sysconfdir}/rdma -%dir %{_sysconfdir}/rdma/modules -%dir %{_docdir}/%{name}-%{version} -%dir %{_libexecdir}/udev -%dir %{_libexecdir}/udev/rules.d -%dir %{_sysconfdir}/udev -%dir %{_sysconfdir}/udev/rules.d -%dir %{_sysconfdir}/modprobe.d -%doc %{_docdir}/%{name}-%{version}/README.md -%config(noreplace) %{_sysconfdir}/rdma/mlx4.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/infiniband.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/iwarp.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/opa.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/rdma.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/roce.conf -%config(noreplace) %{_sysconfdir}/rdma/sriov-vfs -%if 0%{?dma_coherent} -%config(noreplace) %{_sysconfdir}/modprobe.d/mlx4.conf -%endif -%config(noreplace) %{_sysconfdir}/modprobe.d/truescale.conf -%config(noreplace) %{_sysconfdir}/udev/rules.d/70-persistent-ipoib.rules -%{_unitdir}/rdma-hw.target -%{_unitdir}/rdma-load-modules@.service -%{_unitdir}/rdma-sriov.service -%dir %{dracutlibdir} -%dir %{dracutlibdir}/modules.d -%dir %{dracutlibdir}/modules.d/05rdma -%{dracutlibdir}/modules.d/05rdma/module-setup.sh -%{_udevrulesdir}/75-rdma-description.rules -%{_udevrulesdir}/90-rdma-hw-modules.rules -%{_udevrulesdir}/90-rdma-ulp-modules.rules -%{_udevrulesdir}/90-rdma-umad.rules -%{_udevrulesdir}/98-rdma-sriov.rules -%{sysmodprobedir}/50-libmlx4.conf -%{_libexecdir}/rdma-set-sriov-vf -%{_libexecdir}/mlx4-setup.sh -%{_libexecdir}/truescale-serdes.cmds -%license COPYING.* -%{_sbindir}/rcrdma - -%files devel -%defattr(-,root,root) -%doc %{_docdir}/%{name}-%{version}/MAINTAINERS -%dir %{_includedir}/infiniband -%dir %{_includedir}/rdma -%{_includedir}/infiniband/* -%{_includedir}/rdma/* -%{_libdir}/lib*.so -%{_mandir}/man3/ibv_* -%{_mandir}/man3/rdma* -%{_mandir}/man3/umad* -%{_mandir}/man3/*_to_ibv_rate.* -%{_mandir}/man7/rdma_cm.* -%if 0%{?dma_coherent} -%{_mandir}/man3/mlx5dv* -%{_mandir}/man3/mlx4dv* -%{_mandir}/man7/mlx5dv* -%{_mandir}/man7/mlx4dv* -%endif - -%files -n libibverbs -%defattr(-,root,root) -%dir %{_sysconfdir}/libibverbs.d -%dir %{_libdir}/libibverbs -%{_libdir}/libibverbs/*.so -%config(noreplace) %{_sysconfdir}/libibverbs.d/*.driver -%doc %{_docdir}/%{name}-%{version}/libibverbs.md -%doc %{_docdir}/%{name}-%{version}/rxe.md -%doc %{_docdir}/%{name}-%{version}/udev.md -%{_bindir}/rxe_cfg -%{_mandir}/man7/rxe* -%{_mandir}/man8/rxe* - -%files -n %verbs_lname -%defattr(-,root,root) -%{_libdir}/libibverbs*.so.* - -%if 0%{?dma_coherent} -%files -n %mlx4_lname -%defattr(-,root,root) -%{_libdir}/libmlx4*.so.* - -%files -n %mlx5_lname -%defattr(-,root,root) -%{_libdir}/libmlx5*.so.* -%endif - -%files -n libibverbs-utils -%defattr(-,root,root) -%{_bindir}/ibv_* -%{_mandir}/man1/ibv_* - -%files -n ibacm -%defattr(-,root,root) -%config(noreplace) %{_sysconfdir}/rdma/ibacm_opts.cfg -%{_bindir}/ib_acme -%{_sbindir}/ibacm -%{_mandir}/man1/ibacm.* -%{_mandir}/man1/ib_acme.* -%{_mandir}/man7/ibacm.* -%{_mandir}/man7/ibacm_prov.* -%{_unitdir}/ibacm.service -%{_unitdir}/ibacm.socket -%dir %{_libdir}/ibacm -%{_libdir}/ibacm/* -%{_sbindir}/rcibacm -%doc %{_docdir}/%{name}-%{version}/ibacm.md - -%files -n iwpmd -%defattr(-,root,root) -%dir %{_sysconfdir}/rdma -%dir %{_sysconfdir}/rdma/modules -%{_sbindir}/iwpmd -%{_sbindir}/rciwpmd -%{_unitdir}/iwpmd.service -%config(noreplace) %{_sysconfdir}/rdma/modules/iwpmd.conf -%config(noreplace) %{_sysconfdir}/iwpmd.conf -%{_udevrulesdir}/90-iwpmd.rules -%{_mandir}/man8/iwpmd.* -%{_mandir}/man5/iwpmd.* - -%files -n %ibcm_lname -%defattr(-,root,root) -%{_libdir}/libibcm*.so.* -%doc %{_docdir}/%{name}-%{version}/libibcm.md - -%files -n %umad_lname -%defattr(-,root,root) -%{_libdir}/libibumad*.so.* - -%files -n %rdmacm_lname -%defattr(-,root,root) -%{_libdir}/librdmacm*.so.* -%doc %{_docdir}/%{name}-%{version}/librdmacm.md - -%files -n rsocket -%defattr(-,root,root) -%dir %{_libdir}/rsocket -%{_libdir}/rsocket/*.so* -%{_mandir}/man7/rsocket.* - -%files -n librdmacm-utils -%defattr(-,root,root) -%{_bindir}/cmtime -%{_bindir}/mckey -%{_bindir}/rcopy -%{_bindir}/rdma_client -%{_bindir}/rdma_server -%{_bindir}/rdma_xclient -%{_bindir}/rdma_xserver -%{_bindir}/riostream -%{_bindir}/rping -%{_bindir}/rstream -%{_bindir}/ucmatose -%{_bindir}/udaddy -%{_bindir}/udpong -%{_mandir}/man1/cmtime.* -%{_mandir}/man1/mckey.* -%{_mandir}/man1/rcopy.* -%{_mandir}/man1/rdma_client.* -%{_mandir}/man1/rdma_server.* -%{_mandir}/man1/rdma_xclient.* -%{_mandir}/man1/rdma_xserver.* -%{_mandir}/man1/riostream.* -%{_mandir}/man1/rping.* -%{_mandir}/man1/rstream.* -%{_mandir}/man1/ucmatose.* -%{_mandir}/man1/udaddy.* -%{_mandir}/man1/udpong.* - -%files -n srp_daemon -%defattr(-,root,root) -%dir %{_libexecdir}/srp_daemon -%dir %{_sysconfdir}/rdma -%dir %{_sysconfdir}/rdma/modules -%config(noreplace) %{_sysconfdir}/srp_daemon.conf -%config(noreplace) %{_sysconfdir}/rdma/modules/srp_daemon.conf -%{_libexecdir}/udev/rules.d/60-srp_daemon.rules -%{_libexecdir}/srp_daemon/start_on_all_ports -%{_unitdir}/srp_daemon.service -%{_unitdir}/srp_daemon_port@.service -%{_sbindir}/ibsrpdm -%{_sbindir}/srp_daemon -%{_sbindir}/run_srp_daemon -%{_sbindir}/rcsrp_daemon -%{_mandir}/man1/ibsrpdm.1* -%{_mandir}/man1/srp_daemon.1* -%{_mandir}/man5/srp_daemon.service.5* -%{_mandir}/man5/srp_daemon_port@.service.5* -%doc %{_docdir}/%{name}-%{version}/ibsrpdm.md - -%files -n rdma-ndd -%defattr(-, root, root) -%{_sbindir}/rdma-ndd -%{_sbindir}/rcrdma-ndd -%{_unitdir}/rdma-ndd.service -%{_mandir}/man8/rdma-ndd.8* -%{_libexecdir}/udev/rules.d/60-rdma-ndd.rules - -%changelog diff --git a/usr/rdma-core/suse/rdma.modules-setup.sh b/usr/rdma-core/suse/rdma.modules-setup.sh deleted file mode 100644 index 5a5407d7e..000000000 --- a/usr/rdma-core/suse/rdma.modules-setup.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -check() { - [ -n "$hostonly" -a -c /sys/class/infiniband_verbs/uverbs0 ] && return 0 - [ -n "$hostonly" ] && return 255 - return 0 -} - -depends() { - return 0 -} - -install() { - inst /etc/rdma/mlx4.conf - inst /etc/rdma/sriov-vfs - inst /usr/lib/mlx4-setup.sh - inst /usr/lib/rdma-set-sriov-vf - inst /usr/lib/modprobe.d/50-libmlx4.conf - inst_multiple lspci setpci sleep - inst_multiple -o /etc/modprobe.d/mlx4.conf - inst_rules 98-rdma-sriov.rules 70-persistent-ipoib.rules -} - -installkernel() { - hostonly='' instmods =drivers/infiniband =drivers/net/ethernet/mellanox =drivers/net/ethernet/chelsio =drivers/net/ethernet/cisco =drivers/net/ethernet/emulex =drivers/target - hostonly='' instmods crc-t10dif crct10dif_common -} diff --git a/usr/rdma-core/suse/rdma.sriov-rules b/usr/rdma-core/suse/rdma.sriov-rules deleted file mode 100644 index 722ffced4..000000000 --- a/usr/rdma-core/suse/rdma.sriov-rules +++ /dev/null @@ -1,7 +0,0 @@ -ACTION=="remove", GOTO="rdma_sriov_end" -SUBSYSTEM!="infiniband", GOTO="rdma_sriov_end" - -# Automatically load general RDMA ULP modules when RDMA hardware is installed -TAG+="systemd", ENV{ID_RDMA_INFINIBAND}=="1", ENV{SYSTEMD_WANTS}+="rdma-sriov.service" - -LABEL="rdma_sriov_end" diff --git a/usr/rdma-core/suse/rdma.sriov-service b/usr/rdma-core/suse/rdma.sriov-service deleted file mode 100644 index 2b701b80a..000000000 --- a/usr/rdma-core/suse/rdma.sriov-service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Initialize SRIOV for RDMA devices -RefuseManualStop=true -DefaultDependencies=false -Conflicts=emergency.target emergency.service -# Partially support distro network setup scripts that try to run after hardware is configured. -# Run them after any SRIOV devices have been created -Wants=network-pre.target -Before=network-pre.target -# RDMA is not ready until all SRIOV devices are created -Before=rdma-hw.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/lib/rdma-set-sriov-vf diff --git a/usr/rdma-core/util/CMakeLists.txt b/usr/rdma-core/util/CMakeLists.txt deleted file mode 100644 index 57d910965..000000000 --- a/usr/rdma-core/util/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -publish_internal_headers(util - compiler.h - symver.h - util.h - ) - -set(C_FILES - util.c) - -if (HAVE_COHERENT_DMA) - publish_internal_headers(util - mmio.h - udma_barrier.h - ) - - set(C_FILES ${C_FILES} - mmio.c - ) -endif() - -add_library(rdma_util STATIC ${C_FILES}) -add_library(rdma_util_pic STATIC ${C_FILES}) -set_property(TARGET rdma_util_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE) diff --git a/usr/rdma-core/util/compiler.h b/usr/rdma-core/util/compiler.h deleted file mode 100644 index 16f5ee14b..000000000 --- a/usr/rdma-core/util/compiler.h +++ /dev/null @@ -1,53 +0,0 @@ -/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file */ -#ifndef UTIL_COMPILER_H -#define UTIL_COMPILER_H - -/* Use to tag a variable that causes compiler warnings. Use as: - int uninitialized_var(sz) - - This is only enabled for old compilers. gcc 6.x and beyond have excellent - static flow analysis. If code solicits a warning from 6.x it is almost - certainly too complex for a human to understand. -*/ -#if __GNUC__ >= 6 || defined(__clang__) -#define uninitialized_var(x) x -#else -#define uninitialized_var(x) x = x -#endif - -#ifndef likely -#ifdef __GNUC__ -#define likely(x) __builtin_expect(!!(x), 1) -#else -#define likely(x) (x) -#endif -#endif - -#ifndef unlikely -#ifdef __GNUC__ -#define unlikely(x) __builtin_expect(!!(x), 0) -#else -#define unlikely(x) (x) -#endif -#endif - -#ifdef HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE -#define ALWAYS_INLINE __attribute__((always_inline)) -#else -#define ALWAYS_INLINE -#endif - -/* Use to mark fall through on switch statements as desired. */ -#if __GNUC__ >= 7 -#define SWITCH_FALLTHROUGH __attribute__ ((fallthrough)) -#else -#define SWITCH_FALLTHROUGH -#endif - -#ifdef __CHECKER__ -# define __force __attribute__((force)) -#else -# define __force -#endif - -#endif diff --git a/usr/rdma-core/util/mmio.c b/usr/rdma-core/util/mmio.c deleted file mode 100644 index b362a65e8..000000000 --- a/usr/rdma-core/util/mmio.c +++ /dev/null @@ -1,83 +0,0 @@ -/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file */ -#include -#include -#include - -#include -#include - -#if SIZEOF_LONG != 8 - -static pthread_spinlock_t mmio_spinlock; - -static __attribute__((constructor)) void lock_constructor(void) -{ - pthread_spin_init(&mmio_spinlock, PTHREAD_PROCESS_PRIVATE); -} - -/* When the arch does not have a 64 bit store we provide an emulation that - does two stores in address ascending order while holding a global - spinlock. */ -static void pthread_mmio_write64_be(void *addr, __be64 val) -{ - __be32 first_dword = htobe32(be64toh(val) >> 32); - __be32 second_dword = htobe32(be64toh(val)); - - /* The WC spinlock, by definition, provides global ordering for all UC - and WC stores within the critical region. */ - mmio_wc_spinlock(&mmio_spinlock); - - mmio_write32_be(addr, first_dword); - mmio_write32_be(addr + 4, second_dword); - - mmio_wc_spinunlock(&mmio_spinlock); -} - -#if defined(__i386__) -#include -#include - -/* For ia32 we have historically emitted movlps SSE instructions to do the 64 - bit operations. */ -static void __attribute__((target("sse"))) -sse_mmio_write64_be(void *addr, __be64 val) -{ - __m128 tmp = {}; - tmp = _mm_loadl_pi(tmp, (__force __m64 *)&val); - _mm_storel_pi((__m64 *)addr,tmp); -} - -static bool have_sse(void) -{ - unsigned int ax,bx,cx,dx; - - if (!__get_cpuid(1,&ax,&bx,&cx,&dx)) - return false; - return dx & bit_SSE; -} - -#endif /* defined(__i386__) */ - -typedef void (*write64_fn_t)(void *, __be64); - -/* This uses the STT_GNU_IFUNC extension to have the dynamic linker select the - best above implementations at runtime. */ -#if HAVE_FUNC_ATTRIBUTE_IFUNC -void mmio_write64_be(void *addr, __be64 val) - __attribute__((ifunc("resolve_mmio_write64_be"))); -static write64_fn_t resolve_mmio_write64_be(void); -#else -__asm__(".type mmio_write64_be, %gnu_indirect_function"); -write64_fn_t resolve_mmio_write64_be(void) __asm__("mmio_write64_be"); -#endif - -write64_fn_t resolve_mmio_write64_be(void) -{ -#if defined(__i386__) - if (have_sse()) - return &sse_mmio_write64_be; -#endif - return &pthread_mmio_write64_be; -} - -#endif /* SIZEOF_LONG != 8 */ diff --git a/usr/rdma-core/util/mmio.h b/usr/rdma-core/util/mmio.h deleted file mode 100644 index 101af9dd3..000000000 --- a/usr/rdma-core/util/mmio.h +++ /dev/null @@ -1,267 +0,0 @@ -/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file - - These accessors always map to PCI-E TLPs in predictable ways. Translation - to other buses should follow similar definitions. - - write32(mem, 1) - Produce a 4 byte MemWr TLP with bit 0 of DW byte offset 0 set - write32_be(mem, htobe32(1)) - Produce a 4 byte MemWr TLP with bit 0 of DW byte offset 3 set - write32_le(mem, htole32(1)) - Produce a 4 byte MemWr TLP with bit 0 of DW byte offset 0 set - - For ordering these accessors are similar to the Kernel's concept of - writel_relaxed(). When working with UC memory the following hold: - - 1) Strong ordering is required when talking to the same device (eg BAR), - and combining is not permitted: - - write32(mem, 1); - write32(mem + 4, 1); - write32(mem, 1); - - Must produce three TLPs, in order. - - 2) Ordering ignores all pthread locking: - - pthread_spin_lock(&lock); - write32(mem, global++); - pthread_spin_unlock(&lock); - - When run concurrently on all CPUs the device must observe all stores, - but the data value will not be strictly increasing. - - 3) Interaction with DMA is not ordered. Explicit use of a barrier from - udma_barriers is required: - - *dma_mem = 1; - udma_to_device_barrier(); - write32(mem, GO_DMA); - - 4) Access out of program order (eg speculation), either by the CPU or - compiler is not permitted: - - if (cond) - read32(); - - Must not issue a read TLP if cond is false. - - If these are used with WC memory then #1 and #4 do not apply, and all WC - accesses must be bracketed with mmio_wc_start() // mmio_flush_writes() -*/ - -#ifndef __UTIL_MMIO_H -#define __UTIL_MMIO_H - -#include -#include -#include -#include -#include - -#include -#include - -/* The first step is to define the 'raw' accessors. To make this very safe - with sparse we define two versions of each, a le and a be - however the - code is always identical. -*/ -#ifdef __s390x__ -#include -#include - -/* s390 requires a privileged instruction to access IO memory, these syscalls - perform that instruction using a memory buffer copy semantic. -*/ -static inline void s390_mmio_write(void *mmio_addr, const void *val, - size_t length) -{ - // FIXME: Check for error and call abort? - syscall(__NR_s390_pci_mmio_write, mmio_addr, val, length); -} - -static inline void s390_mmio_read(const void *mmio_addr, void *val, - size_t length) -{ - // FIXME: Check for error and call abort? - syscall(__NR_s390_pci_mmio_read, mmio_addr, val, length); -} - -#define MAKE_WRITE(_NAME_, _SZ_) \ - static inline void _NAME_##_be(void *addr, __be##_SZ_ value) \ - { \ - s390_mmio_write(addr, &value, sizeof(value)); \ - } \ - static inline void _NAME_##_le(void *addr, __le##_SZ_ value) \ - { \ - s390_mmio_write(addr, &value, sizeof(value)); \ - } -#define MAKE_READ(_NAME_, _SZ_) \ - static inline __be##_SZ_ _NAME_##_be(const void *addr) \ - { \ - __be##_SZ_ res; \ - s390_mmio_read(addr, &res, sizeof(res)); \ - return res; \ - } \ - static inline __le##_SZ_ _NAME_##_le(const void *addr) \ - { \ - __le##_SZ_ res; \ - s390_mmio_read(addr, &res, sizeof(res)); \ - return res; \ - } - -static inline void mmio_write8(void *addr, uint8_t value) -{ - s390_mmio_write(addr, &value, sizeof(value)); -} - -static inline uint8_t mmio_read8(const void *addr) -{ - uint8_t res; - s390_mmio_read(addr, &res, sizeof(res)); - return res; -} - -#else /* __s390x__ */ - -#define MAKE_WRITE(_NAME_, _SZ_) \ - static inline void _NAME_##_be(void *addr, __be##_SZ_ value) \ - { \ - atomic_store_explicit((_Atomic(uint##_SZ_##_t) *)addr, \ - (__force uint##_SZ_##_t)value, \ - memory_order_relaxed); \ - } \ - static inline void _NAME_##_le(void *addr, __le##_SZ_ value) \ - { \ - atomic_store_explicit((_Atomic(uint##_SZ_##_t) *)addr, \ - (__force uint##_SZ_##_t)value, \ - memory_order_relaxed); \ - } -#define MAKE_READ(_NAME_, _SZ_) \ - static inline __be##_SZ_ _NAME_##_be(const void *addr) \ - { \ - return (__force __be##_SZ_)atomic_load_explicit( \ - (_Atomic(uint##_SZ_##_t) *)addr, memory_order_relaxed); \ - } \ - static inline __le##_SZ_ _NAME_##_le(const void *addr) \ - { \ - return (__force __le##_SZ_)atomic_load_explicit( \ - (_Atomic(uint##_SZ_##_t) *)addr, memory_order_relaxed); \ - } - -static inline void mmio_write8(void *addr, uint8_t value) -{ - atomic_store_explicit((_Atomic(uint8_t) *)addr, value, - memory_order_relaxed); -} -static inline uint8_t mmio_read8(const void *addr) -{ - return atomic_load_explicit((_Atomic(uint32_t) *)addr, - memory_order_relaxed); -} -#endif /* __s390x__ */ - -MAKE_WRITE(mmio_write16, 16) -MAKE_WRITE(mmio_write32, 32) - -MAKE_READ(mmio_read16, 16) -MAKE_READ(mmio_read32, 32) - -#if SIZEOF_LONG == 8 -MAKE_WRITE(mmio_write64, 64) -MAKE_READ(mmio_read64, 64) -#else -void mmio_write64_be(void *addr, __be64 val); -static inline void mmio_write64_le(void *addr, __le64 val) -{ - mmio_write64_be(addr, (__be64 __force)val); -} - -/* There is no way to do read64 atomically, rather than provide some sketchy - implementation we leave these functions undefined, users should not call - them if SIZEOF_LONG != 8, but instead implement an appropriate version. -*/ -__be64 mmio_read64_be(const void *addr); -__le64 mmio_read64_le(const void *addr); -#endif /* SIZEOF_LONG == 8 */ - -#undef MAKE_WRITE -#undef MAKE_READ - -/* Now we can define the host endian versions of the operator, this just includes - a call to htole. -*/ -#define MAKE_WRITE(_NAME_, _SZ_) \ - static inline void _NAME_(void *addr, uint##_SZ_##_t value) \ - { \ - _NAME_##_le(addr, htole##_SZ_(value)); \ - } -#define MAKE_READ(_NAME_, _SZ_) \ - static inline uint##_SZ_##_t _NAME_(const void *addr) \ - { \ - return le##_SZ_##toh(_NAME_##_le(addr)); \ - } - -/* This strictly guarantees the order of TLP generation for the memory copy to - be in ascending address order. -*/ -#ifdef __s390x__ -static inline void mmio_memcpy_x64(void *dest, const void *src, size_t bytecnt) -{ - s390_mmio_write(dest, src, bytecnt); -} -#else - -/* Transfer is some multiple of 64 bytes */ -static inline void mmio_memcpy_x64(void *dest, const void *src, size_t bytecnt) -{ - uintptr_t *dst_p = dest; - - /* Caller must guarantee: - assert(bytecnt != 0); - assert((bytecnt % 64) == 0); - assert(((uintptr_t)dest) % __alignof__(*dst) == 0); - assert(((uintptr_t)src) % __alignof__(*dst) == 0); - */ - - /* Use the native word size for the copy */ - if (sizeof(*dst_p) == 8) { - const __be64 *src_p = src; - - do { - /* Do 64 bytes at a time */ - mmio_write64_be(dst_p++, *src_p++); - mmio_write64_be(dst_p++, *src_p++); - mmio_write64_be(dst_p++, *src_p++); - mmio_write64_be(dst_p++, *src_p++); - mmio_write64_be(dst_p++, *src_p++); - mmio_write64_be(dst_p++, *src_p++); - mmio_write64_be(dst_p++, *src_p++); - mmio_write64_be(dst_p++, *src_p++); - - bytecnt -= 8 * sizeof(*dst_p); - } while (bytecnt > 0); - } else if (sizeof(*dst_p) == 4) { - const __be32 *src_p = src; - - do { - mmio_write32_be(dst_p++, *src_p++); - mmio_write32_be(dst_p++, *src_p++); - bytecnt -= 2 * sizeof(*dst_p); - } while (bytecnt > 0); - } -} -#endif - -MAKE_WRITE(mmio_write16, 16) -MAKE_WRITE(mmio_write32, 32) -MAKE_WRITE(mmio_write64, 64) - -MAKE_READ(mmio_read16, 16) -MAKE_READ(mmio_read32, 32) -MAKE_READ(mmio_read64, 64) - -#undef MAKE_WRITE -#undef MAKE_READ - -#endif diff --git a/usr/rdma-core/util/symver.h b/usr/rdma-core/util/symver.h deleted file mode 100644 index e739b5a11..000000000 --- a/usr/rdma-core/util/symver.h +++ /dev/null @@ -1,100 +0,0 @@ -/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file - - These definitions help using the ELF symbol version feature, and must be - used in conjunction with the library's map file. - */ - -#ifndef __UTIL_SYMVER_H -#define __UTIL_SYMVER_H - -#include -#include - -/* - These macros should only be used if the library is defining compatibility - symbols, eg: - - 213: 000000000000a650 315 FUNC GLOBAL DEFAULT 13 ibv_get_device_list@IBVERBS_1.0 - 214: 000000000000b020 304 FUNC GLOBAL DEFAULT 13 ibv_get_device_list@@IBVERBS_1.1 - - Symbols which have only a single implementation should use a normal extern - function and be placed in the correct stanza in the linker map file. - - Follow this pattern to use this feature: - public.h: - struct ibv_device **ibv_get_device_list(int *num_devices); - foo.c: - // Implement the latest version - LATEST_SYMVER_FUNC(ibv_get_device_list, 1_1, "IBVERBS_1.1", - struct ibv_device **, - int *num_devices) - { - ... - } - - // Implement the compat version - COMPAT_SYMVER_FUNC(ibv_get_device_list, 1_0, "IBVERBS_1.0", - struct ibv_device_1_0 **, - int *num_devices) - { - ... - } - - As well as matching information in the map file. - - These macros deal with the various uglyness in gcc surrounding symbol - versions - - - The internal name __public_1_x is synthesized by the macro - - A prototype for the internal name is created by the macro - - If statically linking the latest symbol expands into a normal function - definition - - If statically linking the compat symbols expand into unused static - functions are are discarded by the compiler. - - The prototype of the latest symbol is checked against the public - prototype (only when compiling statically) - - The extra prototypes are included only to avoid -Wmissing-prototypes - warnings. See also Documentation/versioning.md -*/ - -#define _MAKE_SYMVER(_local_sym, _public_sym, _ver_str) \ - asm(".symver " #_local_sym "," #_public_sym "@" _ver_str) -#define _MAKE_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, ...) \ - _ret __##_public_sym##_##_uniq(__VA_ARGS__); \ - _MAKE_SYMVER(__##_public_sym##_##_uniq, _public_sym, _ver_str); \ - _ret __##_public_sym##_##_uniq(__VA_ARGS__) - -#if defined(HAVE_FULL_SYMBOL_VERSIONS) && !defined(_STATIC_LIBRARY_BUILD_) - - // Produce all symbol versions for dynamic linking - -# define COMPAT_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, ...) \ - _MAKE_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, __VA_ARGS__) -# define LATEST_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, ...) \ - _MAKE_SYMVER_FUNC(_public_sym, _uniq, "@" _ver_str, _ret, __VA_ARGS__) - -#elif defined(HAVE_LIMITED_SYMBOL_VERSIONS) && !defined(_STATIC_LIBRARY_BUILD_) - - /* Produce only implemenations for the latest symbol and tag it with the - * correct symbol versions. This supports dynamic linkers that do not - * understand symbol versions - */ -# define COMPAT_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, ...) \ - static inline _ret __##_public_sym##_##_uniq(__VA_ARGS__) -# define LATEST_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, ...) \ - _MAKE_SYMVER_FUNC(_public_sym, _uniq, "@" _ver_str, _ret, __VA_ARGS__) - -#else - - // Static linking, or linker does not support symbol versions -# define COMPAT_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, ...) \ - static inline _ret __##_public_sym##_##_uniq(__VA_ARGS__) -# define LATEST_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, ...) \ - static _ret __##_public_sym##_##_uniq(__VA_ARGS__) \ - __attribute__((alias(stringify(_public_sym)))); \ - extern _ret _public_sym(__VA_ARGS__) - -#endif - -#endif diff --git a/usr/rdma-core/util/udma_barrier.h b/usr/rdma-core/util/udma_barrier.h deleted file mode 100644 index 23acf233d..000000000 --- a/usr/rdma-core/util/udma_barrier.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef __UTIL_UDMA_BARRIER_H -#define __UTIL_UDMA_BARRIER_H - -#include - -/* Barriers for DMA. - - These barriers are expliclty only for use with user DMA operations. If you - are looking for barriers to use with cache-coherent multi-threaded - consitency then look in stdatomic.h. If you need both kinds of synchronicity - for the same address then use an atomic operation followed by one - of these barriers. - - When reasoning about these barriers there are two objects: - - CPU attached address space (the CPU memory could be a range of things: - cached/uncached/non-temporal CPU DRAM, uncached MMIO space in another - device, pMEM). Generally speaking the ordering is only relative - to the local CPU's view of the system. Eg if the local CPU - is not guaranteed to see a write from another CPU then it is also - OK for the DMA device to also not see the write after the barrier. - - A DMA initiator on a bus. For instance a PCI-E device issuing - MemRd/MemWr TLPs. - - The ordering guarantee is always stated between those two streams. Eg what - happens if a MemRd TLP is sent in via PCI-E relative to a CPU WRITE to the - same memory location. - - The providers have a very regular and predictable use of these barriers, - to make things very clear each narrow use is given a name and the proper - name should be used in the provider as a form of documentation. -*/ - -/* Ensure that the device's view of memory matches the CPU's view of memory. - This should be placed before any MMIO store that could trigger the device - to begin doing DMA, such as a device doorbell ring. - - eg - *dma_buf = 1; - udma_to_device_barrier(); - mmio_write(DO_DMA_REG, dma_buf); - Must ensure that the device sees the '1'. - - This is required to fence writes created by the libibverbs user. Those - writes could be to any CPU mapped memory object with any cachability mode. - - NOTE: x86 has historically used a weaker semantic for this barrier, and - only fenced normal stores to normal memory. libibverbs users using other - memory types or non-temporal stores are required to use SFENCE in their own - code prior to calling verbs to start a DMA. -*/ -#if defined(__i386__) -#define udma_to_device_barrier() asm volatile("" ::: "memory") -#elif defined(__x86_64__) -#define udma_to_device_barrier() asm volatile("" ::: "memory") -#elif defined(__PPC64__) -#define udma_to_device_barrier() asm volatile("sync" ::: "memory") -#elif defined(__PPC__) -#define udma_to_device_barrier() asm volatile("sync" ::: "memory") -#elif defined(__ia64__) -#define udma_to_device_barrier() asm volatile("mf" ::: "memory") -#elif defined(__sparc_v9__) -#define udma_to_device_barrier() asm volatile("membar #StoreStore" ::: "memory") -#elif defined(__aarch64__) -#define udma_to_device_barrier() asm volatile("dsb st" ::: "memory"); -#elif defined(__sparc__) || defined(__s390x__) -#define udma_to_device_barrier() asm volatile("" ::: "memory") -#else -#error No architecture specific memory barrier defines found! -#endif - -/* Ensure that all ordered stores from the device are observable from the - CPU. This only makes sense after something that observes an ordered store - from the device - eg by reading a MMIO register or seeing that CPU memory is - updated. - - This guarantees that all reads that follow the barrier see the ordered - stores that preceded the observation. - - For instance, this would be used after testing a valid bit in a memory - that is a DMA target, to ensure that the following reads see the - data written before the MemWr TLP that set the valid bit. -*/ -#if defined(__i386__) -#define udma_from_device_barrier() asm volatile("lock; addl $0,0(%%esp) " ::: "memory") -#elif defined(__x86_64__) -#define udma_from_device_barrier() asm volatile("lfence" ::: "memory") -#elif defined(__PPC64__) -#define udma_from_device_barrier() asm volatile("lwsync" ::: "memory") -#elif defined(__PPC__) -#define udma_from_device_barrier() asm volatile("sync" ::: "memory") -#elif defined(__ia64__) -#define udma_from_device_barrier() asm volatile("mf" ::: "memory") -#elif defined(__sparc_v9__) -#define udma_from_device_barrier() asm volatile("membar #LoadLoad" ::: "memory") -#elif defined(__aarch64__) -#define udma_from_device_barrier() asm volatile("dsb ld" ::: "memory"); -#elif defined(__sparc__) || defined(__s390x__) -#define udma_from_device_barrier() asm volatile("" ::: "memory") -#else -#error No architecture specific memory barrier defines found! -#endif - -/* Order writes to CPU memory so that a DMA device cannot view writes after - the barrier without also seeing all writes before the barrier. This does - not guarantee any writes are visible to DMA. - - This would be used in cases where a DMA buffer might have a valid bit and - data, this barrier is placed after writing the data but before writing the - valid bit to ensure the DMA device cannot observe a set valid bit with - unwritten data. - - Compared to udma_to_device_barrier() this barrier is not required to fence - anything but normal stores to normal malloc memory. Usage should be: - - write_wqe - udma_to_device_barrier(); // Get user memory ready for DMA - wqe->addr = ...; - wqe->flags = ...; - udma_ordering_write_barrier(); // Guarantee WQE written in order - wqe->valid = 1; -*/ -#define udma_ordering_write_barrier() udma_to_device_barrier() - -/* Promptly flush writes to MMIO Write Cominbing memory. - This should be used after a write to WC memory. This is both a barrier - and a hint to the CPU to flush any buffers to reduce latency to TLP - generation. - - This is not required to have any effect on CPU memory. - - If done while holding a lock then the ordering of MMIO writes across CPUs - must be guaranteed to follow the natural ordering implied by the lock. - - This must also act as a barrier that prevents write combining, eg - *wc_mem = 1; - mmio_flush_writes(); - *wc_mem = 2; - Must always produce two MemWr TLPs, '1' and '2'. Without the barrier - the CPU is allowed to produce a single TLP '2'. - - Note that there is no order guarantee for writes to WC memory without - barriers. - - This is intended to be used in conjunction with WC memory to generate large - PCI-E MemWr TLPs from the CPU. -*/ -#if defined(__i386__) -#define mmio_flush_writes() asm volatile("lock; addl $0,0(%%esp) " ::: "memory") -#elif defined(__x86_64__) -#define mmio_flush_writes() asm volatile("sfence" ::: "memory") -#elif defined(__PPC64__) -#define mmio_flush_writes() asm volatile("sync" ::: "memory") -#elif defined(__PPC__) -#define mmio_flush_writes() asm volatile("sync" ::: "memory") -#elif defined(__ia64__) -#define mmio_flush_writes() asm volatile("fwb" ::: "memory") -#elif defined(__sparc_v9__) -#define mmio_flush_writes() asm volatile("membar #StoreStore" ::: "memory") -#elif defined(__aarch64__) -#define mmio_flush_writes() asm volatile("dsb st" ::: "memory"); -#elif defined(__sparc__) || defined(__s390x__) -#define mmio_flush_writes() asm volatile("" ::: "memory") -#else -#error No architecture specific memory barrier defines found! -#endif - -/* Prevent WC writes from being re-ordered relative to other MMIO - writes. This should be used before a write to WC memory. - - This must act as a barrier to prevent write re-ordering from different - memory types: - *mmio_mem = 1; - mmio_flush_writes(); - *wc_mem = 2; - Must always produce a TLP '1' followed by '2'. - - This barrier implies udma_to_device_barrier() - - This is intended to be used in conjunction with WC memory to generate large - PCI-E MemWr TLPs from the CPU. -*/ -#define mmio_wc_start() mmio_flush_writes() - -/* Keep MMIO writes in order. - Currently we lack writel macros that universally guarantee MMIO - writes happen in order, like the kernel does. Even worse many - providers haphazardly open code writes to MMIO memory omitting even - volatile. - - Until this can be fixed with a proper writel macro, this barrier - is a stand in to indicate places where MMIO writes should be switched - to some future writel. -*/ -#define mmio_ordered_writes_hack() mmio_flush_writes() - -/* Write Combining Spinlock primitive - - Any access to a multi-value WC region must ensure that multiple cpus do not - write to the same values concurrently, these macros make that - straightforward and efficient if the choosen exclusion is a spinlock. - - The spinlock guarantees that the WC writes issued within the critical - section are made visible as TLP to the device. The TLP must be seen by the - device strictly in the order that the spinlocks are acquired, and combining - WC writes between different sections is not permitted. - - Use of these macros allow the fencing inside the spinlock to be combined - with the fencing required for DMA. - */ -static inline void mmio_wc_spinlock(pthread_spinlock_t *lock) -{ - pthread_spin_lock(lock); -#if !defined(__i386__) && !defined(__x86_64__) - /* For x86 the serialization within the spin lock is enough to - * strongly order WC and other memory types. */ - mmio_wc_start(); -#endif -} - -static inline void mmio_wc_spinunlock(pthread_spinlock_t *lock) -{ - /* It is possible that on x86 the atomic in the lock is strong enough - * to force-flush the WC buffers quickly, and this SFENCE can be - * omitted too. */ - mmio_flush_writes(); - pthread_spin_unlock(lock); -} - -#endif diff --git a/usr/rdma-core/util/util.c b/usr/rdma-core/util/util.c deleted file mode 100644 index 8c5f8f1ae..000000000 --- a/usr/rdma-core/util/util.c +++ /dev/null @@ -1,22 +0,0 @@ -/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file */ -#include -#include -#include - -int set_fd_nonblock(int fd, bool nonblock) -{ - int val; - - val = fcntl(fd, F_GETFL); - if (val == -1) - return -1; - - if (nonblock) - val |= O_NONBLOCK; - else - val &= ~(unsigned int)(O_NONBLOCK); - - if (fcntl(fd, F_SETFL, val) == -1) - return -1; - return 0; -} diff --git a/usr/rdma-core/util/util.h b/usr/rdma-core/util/util.h deleted file mode 100644 index bc708db95..000000000 --- a/usr/rdma-core/util/util.h +++ /dev/null @@ -1,26 +0,0 @@ -/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file */ -#ifndef UTIL_UTIL_H -#define UTIL_UTIL_H - -#include -#include - -/* Return true if the snprintf succeeded, false if there was truncation or - * error */ -static inline bool __good_snprintf(size_t len, int rc) -{ - return (rc < len && rc >= 0); -} - -#define check_snprintf(buf, len, fmt, ...) \ - __good_snprintf(len, snprintf(buf, len, fmt, ##__VA_ARGS__)) - -/* a CMP b. See also the BSD macro timercmp(). */ -#define ts_cmp(a, b, CMP) \ - (((a)->tv_sec == (b)->tv_sec) ? \ - ((a)->tv_nsec CMP (b)->tv_nsec) : \ - ((a)->tv_sec CMP (b)->tv_sec)) - -int set_fd_nonblock(int fd, bool nonblock); - -#endif diff --git a/usr/tests/CMakeLists.txt b/usr/tests/CMakeLists.txt index dfdce0013..0789e72cc 100644 --- a/usr/tests/CMakeLists.txt +++ b/usr/tests/CMakeLists.txt @@ -10,7 +10,7 @@ add_executable(hellof hellof.f90) add_executable(pi pi.go) add_executable(ib-test ib_test.c) -target_link_libraries(ib-test ibverbs) +#target_link_libraries(ib-test ibverbs) add_executable(test-malloc test-malloc.c) add_executable(test-malloc-mt test-malloc-mt.c) diff --git a/usr/tests/ib_test.c b/usr/tests/ib_test.c index d0d9d6278..f01226720 100644 --- a/usr/tests/ib_test.c +++ b/usr/tests/ib_test.c @@ -32,7 +32,7 @@ #include #include -#include // GEHT, brauche ich aber nicht? +/*#include // GEHT, brauche ich aber nicht?*/ #include // Geht per cmake copy workaround