65
65
66
66
static struct svcxprt_rdma * svc_rdma_create_xprt (struct svc_serv * serv ,
67
67
struct net * net , int node );
68
+ static int svc_rdma_listen_handler (struct rdma_cm_id * cma_id ,
69
+ struct rdma_cm_event * event );
68
70
static struct svc_xprt * svc_rdma_create (struct svc_serv * serv ,
69
71
struct net * net ,
70
72
struct sockaddr * sa , int salen ,
@@ -122,6 +124,41 @@ static void qp_event_handler(struct ib_event *event, void *context)
122
124
}
123
125
}
124
126
127
+ static struct rdma_cm_id *
128
+ svc_rdma_create_listen_id (struct net * net , struct sockaddr * sap ,
129
+ void * context )
130
+ {
131
+ struct rdma_cm_id * listen_id ;
132
+ int ret ;
133
+
134
+ listen_id = rdma_create_id (net , svc_rdma_listen_handler , context ,
135
+ RDMA_PS_TCP , IB_QPT_RC );
136
+ if (IS_ERR (listen_id ))
137
+ return listen_id ;
138
+
139
+ /* Allow both IPv4 and IPv6 sockets to bind a single port
140
+ * at the same time.
141
+ */
142
+ #if IS_ENABLED (CONFIG_IPV6 )
143
+ ret = rdma_set_afonly (listen_id , 1 );
144
+ if (ret )
145
+ goto out_destroy ;
146
+ #endif
147
+ ret = rdma_bind_addr (listen_id , sap );
148
+ if (ret )
149
+ goto out_destroy ;
150
+
151
+ ret = rdma_listen (listen_id , RPCRDMA_LISTEN_BACKLOG );
152
+ if (ret )
153
+ goto out_destroy ;
154
+
155
+ return listen_id ;
156
+
157
+ out_destroy :
158
+ rdma_destroy_id (listen_id );
159
+ return ERR_PTR (ret );
160
+ }
161
+
125
162
static struct svcxprt_rdma * svc_rdma_create_xprt (struct svc_serv * serv ,
126
163
struct net * net , int node )
127
164
{
@@ -307,7 +344,6 @@ static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
307
344
{
308
345
struct rdma_cm_id * listen_id ;
309
346
struct svcxprt_rdma * cma_xprt ;
310
- int ret ;
311
347
312
348
if (sa -> sa_family != AF_INET && sa -> sa_family != AF_INET6 )
313
349
return ERR_PTR (- EAFNOSUPPORT );
@@ -317,30 +353,13 @@ static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
317
353
set_bit (XPT_LISTENER , & cma_xprt -> sc_xprt .xpt_flags );
318
354
strcpy (cma_xprt -> sc_xprt .xpt_remotebuf , "listener" );
319
355
320
- listen_id = rdma_create_id (net , svc_rdma_listen_handler , cma_xprt ,
321
- RDMA_PS_TCP , IB_QPT_RC );
356
+ listen_id = svc_rdma_create_listen_id (net , sa , cma_xprt );
322
357
if (IS_ERR (listen_id )) {
323
- ret = PTR_ERR ( listen_id );
324
- goto err0 ;
358
+ kfree ( cma_xprt );
359
+ return ( struct svc_xprt * ) listen_id ;
325
360
}
326
-
327
- /* Allow both IPv4 and IPv6 sockets to bind a single port
328
- * at the same time.
329
- */
330
- #if IS_ENABLED (CONFIG_IPV6 )
331
- ret = rdma_set_afonly (listen_id , 1 );
332
- if (ret )
333
- goto err1 ;
334
- #endif
335
- ret = rdma_bind_addr (listen_id , sa );
336
- if (ret )
337
- goto err1 ;
338
361
cma_xprt -> sc_cm_id = listen_id ;
339
362
340
- ret = rdma_listen (listen_id , RPCRDMA_LISTEN_BACKLOG );
341
- if (ret )
342
- goto err1 ;
343
-
344
363
/*
345
364
* We need to use the address from the cm_id in case the
346
365
* caller specified 0 for the port number.
@@ -349,12 +368,6 @@ static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
349
368
svc_xprt_set_local (& cma_xprt -> sc_xprt , sa , salen );
350
369
351
370
return & cma_xprt -> sc_xprt ;
352
-
353
- err1 :
354
- rdma_destroy_id (listen_id );
355
- err0 :
356
- kfree (cma_xprt );
357
- return ERR_PTR (ret );
358
371
}
359
372
360
373
/*
0 commit comments