summaryrefslogtreecommitdiffstats
path: root/include/rdma
diff options
context:
space:
mode:
authorTatyana Nikolova <Tatyana.E.Nikolova@intel.com>2014-03-26 18:07:35 -0400
committerRoland Dreier <roland@purestorage.com>2014-06-10 13:11:45 -0400
commit30dc5e63d6a5ad24894b5512d10b228d73645a44 (patch)
treecbb54ab8d06b165dbbd83a243cf743c8b6ad64da /include/rdma
parentd6d211db37e75de2ddc3a4f979038c40df7cc79c (diff)
RDMA/core: Add support for iWARP Port Mapper user space service
This patch adds iWARP Port Mapper (IWPM) Version 2 support. The iWARP Port Mapper implementation is based on the port mapper specification section in the Sockets Direct Protocol paper - http://www.rdmaconsortium.org/home/draft-pinkerton-iwarp-sdp-v1.0.pdf 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. The iWARP Port Mapper solution doesn't contain any changes to the existing network stack in the kernel space. All the changes are contained with the infiniband tree and also in user space. The iWARP Port Mapper service is implemented as a user space daemon process. Source for the IWPM service is located at http://git.openfabrics.org/git?p=~tnikolova/libiwpm-1.0.0/.git;a=summary The iWARP driver (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. The message exchange between the IWPM service and the iWARP drivers (between user space and kernel space) is implemented using netlink sockets. 1) Netlink interface functions are added: ibnl_unicast() and ibnl_mulitcast() for sending netlink messages to user space 2) The signature of the existing ibnl_put_msg() is changed to be more generic 3) Two netlink clients are added: RDMA_NL_NES, RDMA_NL_C4IW corresponding to the two iWarp drivers - nes and cxgb4 which use the IWPM service 4) Enums are added to enumerate the attributes in the netlink messages, which are exchanged between the user space IWPM service and the iWARP drivers Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com> Signed-off-by: Steve Wise <swise@opengridcomputing.com> Reviewed-by: PJ Waskiewicz <pj.waskiewicz@solidfire.com> [ Fold in range checking fixes and nlh_next removal as suggested by Dan Carpenter and Steve Wise. Fix sparse endianness in hash. - Roland ] Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/iw_portmap.h199
-rw-r--r--include/rdma/rdma_netlink.h23
2 files changed, 221 insertions, 1 deletions
diff --git a/include/rdma/iw_portmap.h b/include/rdma/iw_portmap.h
new file mode 100644
index 000000000000..928b2775e992
--- /dev/null
+++ b/include/rdma/iw_portmap.h
@@ -0,0 +1,199 @@
1/*
2 * Copyright (c) 2014 Intel Corporation. All rights reserved.
3 * Copyright (c) 2014 Chelsio, Inc. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 */
33#ifndef _IW_PORTMAP_H
34#define _IW_PORTMAP_H
35
36#define IWPM_ULIBNAME_SIZE 32
37#define IWPM_DEVNAME_SIZE 32
38#define IWPM_IFNAME_SIZE 16
39#define IWPM_IPADDR_SIZE 16
40
41enum {
42 IWPM_INVALID_NLMSG_ERR = 10,
43 IWPM_CREATE_MAPPING_ERR,
44 IWPM_DUPLICATE_MAPPING_ERR,
45 IWPM_UNKNOWN_MAPPING_ERR,
46 IWPM_CLIENT_DEV_INFO_ERR,
47 IWPM_USER_LIB_INFO_ERR,
48 IWPM_REMOTE_QUERY_REJECT
49};
50
51struct iwpm_dev_data {
52 char dev_name[IWPM_DEVNAME_SIZE];
53 char if_name[IWPM_IFNAME_SIZE];
54};
55
56struct iwpm_sa_data {
57 struct sockaddr_storage loc_addr;
58 struct sockaddr_storage mapped_loc_addr;
59 struct sockaddr_storage rem_addr;
60 struct sockaddr_storage mapped_rem_addr;
61};
62
63/**
64 * iwpm_init - Allocate resources for the iwarp port mapper
65 *
66 * Should be called when network interface goes up.
67 */
68int iwpm_init(u8);
69
70/**
71 * iwpm_exit - Deallocate resources for the iwarp port mapper
72 *
73 * Should be called when network interface goes down.
74 */
75int iwpm_exit(u8);
76
77/**
78 * iwpm_valid_pid - Check if the userspace iwarp port mapper pid is valid
79 *
80 * Returns true if the pid is greater than zero, otherwise returns false
81 */
82int iwpm_valid_pid(void);
83
84/**
85 * iwpm_register_pid - Send a netlink query to userspace
86 * to get the iwarp port mapper pid
87 * @pm_msg: Contains driver info to send to the userspace port mapper
88 * @nl_client: The index of the netlink client
89 */
90int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 nl_client);
91
92/**
93 * iwpm_add_mapping - Send a netlink add mapping request to
94 * the userspace port mapper
95 * @pm_msg: Contains the local ip/tcp address info to send
96 * @nl_client: The index of the netlink client
97 *
98 * If the request is successful, the pm_msg stores
99 * the port mapper response (mapped address info)
100 */
101int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client);
102
103/**
104 * iwpm_add_and_query_mapping - Send a netlink add and query mapping request
105 * to the userspace port mapper
106 * @pm_msg: Contains the local and remote ip/tcp address info to send
107 * @nl_client: The index of the netlink client
108 *
109 * If the request is successful, the pm_msg stores the
110 * port mapper response (mapped local and remote address info)
111 */
112int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client);
113
114/**
115 * iwpm_remove_mapping - Send a netlink remove mapping request
116 * to the userspace port mapper
117 *
118 * @local_addr: Local ip/tcp address to remove
119 * @nl_client: The index of the netlink client
120 */
121int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client);
122
123/**
124 * iwpm_register_pid_cb - Process the port mapper response to
125 * iwpm_register_pid query
126 * @skb:
127 * @cb: Contains the received message (payload and netlink header)
128 *
129 * If successful, the function receives the userspace port mapper pid
130 * which is used in future communication with the port mapper
131 */
132int iwpm_register_pid_cb(struct sk_buff *, struct netlink_callback *);
133
134/**
135 * iwpm_add_mapping_cb - Process the port mapper response to
136 * iwpm_add_mapping request
137 * @skb:
138 * @cb: Contains the received message (payload and netlink header)
139 */
140int iwpm_add_mapping_cb(struct sk_buff *, struct netlink_callback *);
141
142/**
143 * iwpm_add_and_query_mapping_cb - Process the port mapper response to
144 * iwpm_add_and_query_mapping request
145 * @skb:
146 * @cb: Contains the received message (payload and netlink header)
147 */
148int iwpm_add_and_query_mapping_cb(struct sk_buff *, struct netlink_callback *);
149
150/**
151 * iwpm_mapping_error_cb - Process port mapper notification for error
152 *
153 * @skb:
154 * @cb: Contains the received message (payload and netlink header)
155 */
156int iwpm_mapping_error_cb(struct sk_buff *, struct netlink_callback *);
157
158/**
159 * iwpm_mapping_info_cb - Process a notification that the userspace
160 * port mapper daemon is started
161 * @skb:
162 * @cb: Contains the received message (payload and netlink header)
163 *
164 * Using the received port mapper pid, send all the local mapping
165 * info records to the userspace port mapper
166 */
167int iwpm_mapping_info_cb(struct sk_buff *, struct netlink_callback *);
168
169/**
170 * iwpm_ack_mapping_info_cb - Process the port mapper ack for
171 * the provided local mapping info records
172 * @skb:
173 * @cb: Contains the received message (payload and netlink header)
174 */
175int iwpm_ack_mapping_info_cb(struct sk_buff *, struct netlink_callback *);
176
177/**
178 * iwpm_create_mapinfo - Store local and mapped IPv4/IPv6 address
179 * info in a hash table
180 * @local_addr: Local ip/tcp address
181 * @mapped_addr: Mapped local ip/tcp address
182 * @nl_client: The index of the netlink client
183 */
184int iwpm_create_mapinfo(struct sockaddr_storage *local_addr,
185 struct sockaddr_storage *mapped_addr, u8 nl_client);
186
187/**
188 * iwpm_remove_mapinfo - Remove local and mapped IPv4/IPv6 address
189 * info from the hash table
190 * @local_addr: Local ip/tcp address
191 * @mapped_addr: Mapped local ip/tcp address
192 *
193 * Returns err code if mapping info is not found in the hash table,
194 * otherwise returns 0
195 */
196int iwpm_remove_mapinfo(struct sockaddr_storage *local_addr,
197 struct sockaddr_storage *mapped_addr);
198
199#endif /* _IW_PORTMAP_H */
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index e38de79eeb48..0790882e0c9b 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -43,7 +43,7 @@ int ibnl_remove_client(int index);
43 * Returns the allocated buffer on success and NULL on failure. 43 * Returns the allocated buffer on success and NULL on failure.
44 */ 44 */
45void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq, 45void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
46 int len, int client, int op); 46 int len, int client, int op, int flags);
47/** 47/**
48 * Put a new attribute in a supplied skb. 48 * Put a new attribute in a supplied skb.
49 * @skb: The netlink skb. 49 * @skb: The netlink skb.
@@ -56,4 +56,25 @@ void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
56int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh, 56int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
57 int len, void *data, int type); 57 int len, void *data, int type);
58 58
59/**
60 * Send the supplied skb to a specific userspace PID.
61 * @skb: The netlink skb
62 * @nlh: Header of the netlink message to send
63 * @pid: Userspace netlink process ID
64 * Returns 0 on success or a negative error code.
65 */
66int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
67 __u32 pid);
68
69/**
70 * Send the supplied skb to a netlink group.
71 * @skb: The netlink skb
72 * @nlh: Header of the netlink message to send
73 * @group: Netlink group ID
74 * @flags: allocation flags
75 * Returns 0 on success or a negative error code.
76 */
77int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
78 unsigned int group, gfp_t flags);
79
59#endif /* _RDMA_NETLINK_H */ 80#endif /* _RDMA_NETLINK_H */