2 * Copyright (c) 2005-2012 Intel Corporation. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 #include <sys/types.h>
37 #include <infiniband/endian.h>
40 #include <rdma/rdma_cma.h>
41 #include <rdma/rsocket.h>
42 #include <infiniband/ib.h>
46 #define rs_socket(f,t,p) use_rs ? rsocket(f,t,p) : socket(f,t,p)
47 #define rs_bind(s,a,l) use_rs ? rbind(s,a,l) : bind(s,a,l)
48 #define rs_listen(s,b) use_rs ? rlisten(s,b) : listen(s,b)
49 #define rs_connect(s,a,l) use_rs ? rconnect(s,a,l) : connect(s,a,l)
50 #define rs_accept(s,a,l) use_rs ? raccept(s,a,l) : accept(s,a,l)
51 #define rs_shutdown(s,h) use_rs ? rshutdown(s,h) : shutdown(s,h)
52 #define rs_close(s) use_rs ? rclose(s) : close(s)
53 #define rs_recv(s,b,l,f) use_rs ? rrecv(s,b,l,f) : recv(s,b,l,f)
54 #define rs_send(s,b,l,f) use_rs ? rsend(s,b,l,f) : send(s,b,l,f)
55 #define rs_recvfrom(s,b,l,f,a,al) \
56 use_rs ? rrecvfrom(s,b,l,f,a,al) : recvfrom(s,b,l,f,a,al)
57 #define rs_sendto(s,b,l,f,a,al) \
58 use_rs ? rsendto(s,b,l,f,a,al) : sendto(s,b,l,f,a,al)
59 #define rs_poll(f,n,t) use_rs ? rpoll(f,n,t) : poll(f,n,t)
60 #define rs_fcntl(s,c,p) use_rs ? rfcntl(s,c,p) : fcntl(s,c,p)
61 #define rs_setsockopt(s,l,n,v,ol) \
62 use_rs ? rsetsockopt(s,l,n,v,ol) : setsockopt(s,l,n,v,ol)
63 #define rs_getsockopt(s,l,n,v,ol) \
64 use_rs ? rgetsockopt(s,l,n,v,ol) : getsockopt(s,l,n,v,ol)
68 struct sockaddr_in sin;
69 struct sockaddr_in6 sin6;
72 enum rs_optimization {
78 int get_rdma_addr(const char *src, const char *dst, const char *port,
79 struct rdma_addrinfo *hints, struct rdma_addrinfo **rai);
81 void size_str(char *str, size_t ssize, long long size);
82 void cnt_str(char *str, size_t ssize, long long cnt);
83 int size_to_count(int size);
84 void format_buf(void *buf, int size);
85 int verify_buf(void *buf, int size);
86 int do_poll(struct pollfd *fds, int timeout);