1321936Shselasky/*
2321936Shselasky * Copyright (c) 2011-2012 Intel Corporation.  All rights reserved.
3321936Shselasky *
4321936Shselasky * This software is available to you under a choice of one of two
5321936Shselasky * licenses.  You may choose to be licensed under the terms of the GNU
6321936Shselasky * General Public License (GPL) Version 2, available from the file
7321936Shselasky * COPYING in the main directory of this source tree, or the
8321936Shselasky * OpenIB.org BSD license below:
9321936Shselasky *
10321936Shselasky *     Redistribution and use in source and binary forms, with or
11321936Shselasky *     without modification, are permitted provided that the following
12321936Shselasky *     conditions are met:
13321936Shselasky *
14321936Shselasky *      - Redistributions of source code must retain the above
15321936Shselasky *        copyright notice, this list of conditions and the following
16321936Shselasky *        disclaimer.
17321936Shselasky *
18321936Shselasky *      - Redistributions in binary form must reproduce the above
19321936Shselasky *        copyright notice, this list of conditions and the following
20321936Shselasky *        disclaimer in the documentation and/or other materials
21321936Shselasky *        provided with the distribution.
22321936Shselasky *
23321936Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24321936Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25321936Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26321936Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27321936Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28321936Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29321936Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30321936Shselasky * SOFTWARE.
31321936Shselasky */
32321936Shselasky
33321936Shselasky#if !defined(RSOCKET_H)
34321936Shselasky#define RSOCKET_H
35321936Shselasky
36321936Shselasky#include <infiniband/verbs.h>
37321936Shselasky#include <rdma/rdma_cma.h>
38321936Shselasky#include <sys/socket.h>
39321936Shselasky#include <errno.h>
40321936Shselasky#include <poll.h>
41321936Shselasky#include <sys/select.h>
42321936Shselasky#include <sys/mman.h>
43321936Shselasky
44321936Shselasky#ifdef __cplusplus
45321936Shselaskyextern "C" {
46321936Shselasky#endif
47321936Shselasky
48321936Shselaskyint rsocket(int domain, int type, int protocol);
49321936Shselaskyint rbind(int socket, const struct sockaddr *addr, socklen_t addrlen);
50321936Shselaskyint rlisten(int socket, int backlog);
51321936Shselaskyint raccept(int socket, struct sockaddr *addr, socklen_t *addrlen);
52321936Shselaskyint rconnect(int socket, const struct sockaddr *addr, socklen_t addrlen);
53321936Shselaskyint rshutdown(int socket, int how);
54321936Shselaskyint rclose(int socket);
55321936Shselasky
56321936Shselaskyssize_t rrecv(int socket, void *buf, size_t len, int flags);
57321936Shselaskyssize_t rrecvfrom(int socket, void *buf, size_t len, int flags,
58321936Shselasky		  struct sockaddr *src_addr, socklen_t *addrlen);
59321936Shselaskyssize_t rrecvmsg(int socket, struct msghdr *msg, int flags);
60321936Shselaskyssize_t rsend(int socket, const void *buf, size_t len, int flags);
61321936Shselaskyssize_t rsendto(int socket, const void *buf, size_t len, int flags,
62321936Shselasky		const struct sockaddr *dest_addr, socklen_t addrlen);
63321936Shselaskyssize_t rsendmsg(int socket, const struct msghdr *msg, int flags);
64321936Shselaskyssize_t rread(int socket, void *buf, size_t count);
65321936Shselaskyssize_t rreadv(int socket, const struct iovec *iov, int iovcnt);
66321936Shselaskyssize_t rwrite(int socket, const void *buf, size_t count);
67321936Shselaskyssize_t rwritev(int socket, const struct iovec *iov, int iovcnt);
68321936Shselasky
69321936Shselaskyint rpoll(struct pollfd *fds, nfds_t nfds, int timeout);
70321936Shselaskyint rselect(int nfds, fd_set *readfds, fd_set *writefds,
71321936Shselasky	    fd_set *exceptfds, struct timeval *timeout);
72321936Shselasky
73321936Shselaskyint rgetpeername(int socket, struct sockaddr *addr, socklen_t *addrlen);
74321936Shselaskyint rgetsockname(int socket, struct sockaddr *addr, socklen_t *addrlen);
75321936Shselasky
76321936Shselasky#define SOL_RDMA 0x10000
77321936Shselaskyenum {
78321936Shselasky	RDMA_SQSIZE,
79321936Shselasky	RDMA_RQSIZE,
80321936Shselasky	RDMA_INLINE,
81321936Shselasky	RDMA_IOMAPSIZE,
82321936Shselasky	RDMA_ROUTE
83321936Shselasky};
84321936Shselasky
85321936Shselaskyint rsetsockopt(int socket, int level, int optname,
86321936Shselasky		const void *optval, socklen_t optlen);
87321936Shselaskyint rgetsockopt(int socket, int level, int optname,
88321936Shselasky		void *optval, socklen_t *optlen);
89321936Shselaskyint rfcntl(int socket, int cmd, ... /* arg */ );
90321936Shselasky
91321936Shselaskyoff_t riomap(int socket, void *buf, size_t len, int prot, int flags, off_t offset);
92321936Shselaskyint riounmap(int socket, void *buf, size_t len);
93321936Shselaskysize_t riowrite(int socket, const void *buf, size_t count, off_t offset, int flags);
94321936Shselasky
95321936Shselasky#ifdef __cplusplus
96321936Shselasky}
97321936Shselasky#endif
98321936Shselasky
99321936Shselasky#endif /* RSOCKET_H */
100