208 list_remove_node(&i_ipaddr->list);
209 kmem_free(i_ipaddr, sizeof (*i_ipaddr));
210 }
211
212 rdsv3_ib_destroy_conns(rds_ibdev);
213
214 if (rds_ibdev->fmr_soft_cq)
215 rdsv3_af_thr_destroy(rds_ibdev->fmr_soft_cq);
216 if (rds_ibdev->inc_soft_cq)
217 rdsv3_af_thr_destroy(rds_ibdev->inc_soft_cq);
218
219 rdsv3_ib_destroy_mr_pool(rds_ibdev);
220 rdsv3_ib_destroy_inc_pool(rds_ibdev);
221
222 kmem_cache_destroy(rds_ibdev->ib_frag_slab);
223
224 rdsv3_af_grp_destroy(rds_ibdev->aft_hcagp);
225
226 #if 0
227 while (ib_dealloc_pd(rds_ibdev->pd)) {
228 #ifndef __lock_lint
229 RDSV3_DPRINTF5("rdsv3_ib_remove_one",
230 "%s-%d Failed to dealloc pd %p",
231 __func__, __LINE__, rds_ibdev->pd);
232 #endif
233 delay(drv_usectohz(1000));
234 }
235 #else
236 if (ib_dealloc_pd(rds_ibdev->pd)) {
237 #ifndef __lock_lint
238 RDSV3_DPRINTF2("rdsv3_ib_remove_one",
239 "Failed to dealloc pd %p\n", rds_ibdev->pd);
240 #endif
241 }
242 #endif
243
244 list_destroy(&rds_ibdev->ipaddr_list);
245 list_destroy(&rds_ibdev->conn_list);
246 list_remove_node(&rds_ibdev->list);
247 mutex_destroy(&rds_ibdev->spinlock);
248 rw_destroy(&rds_ibdev->rwlock);
249 kmem_free(rds_ibdev, sizeof (*rds_ibdev));
250
251 RDSV3_DPRINTF2("rdsv3_ib_remove_one", "Return: device: %p", device);
252 }
253
254 #ifndef __lock_lint
255 struct ib_client rdsv3_ib_client = {
256 .name = "rdsv3_ib",
257 .add = rdsv3_ib_add_one,
258 .remove = rdsv3_ib_remove_one,
259 .clnt_hdl = NULL,
260 .state = IB_CLNT_UNINITIALIZED
261 };
262 #else
263 struct ib_client rdsv3_ib_client = {
264 "rdsv3_ib",
265 rdsv3_ib_add_one,
266 rdsv3_ib_remove_one,
267 NULL,
268 NULL,
269 IB_CLNT_UNINITIALIZED
270 };
271 #endif
272
273 static int
274 rds_ib_conn_info_visitor(struct rdsv3_connection *conn,
275 void *buffer)
276 {
277 struct rds_info_rdma_connection *iinfo = buffer;
278 struct rdsv3_ib_connection *ic;
279
280 RDSV3_DPRINTF4("rds_ib_conn_info_visitor", "conn: %p buffer: %p",
281 conn, buffer);
282
283 /* We will only ever look at IB transports */
284 if (conn->c_trans != &rdsv3_ib_transport)
285 return (0);
286
287 iinfo->src_addr = conn->c_laddr;
288 iinfo->dst_addr = conn->c_faddr;
289
290 (void) memset(&iinfo->src_gid, 0, sizeof (iinfo->src_gid));
291 (void) memset(&iinfo->dst_gid, 0, sizeof (iinfo->dst_gid));
377 void
378 rdsv3_ib_exit(void)
379 {
380 RDSV3_DPRINTF4("rds_ib_exit", "Enter");
381
382 rdsv3_info_deregister_func(RDS_INFO_IB_CONNECTIONS, rds_ib_ic_info);
383 rdsv3_ib_destroy_nodev_conns();
384 ib_unregister_client(&rdsv3_ib_client);
385 rdsv3_ib_sysctl_exit();
386 rdsv3_ib_recv_exit();
387 rdsv3_trans_unregister(&rdsv3_ib_transport);
388 kmem_free(rdsv3_ib_stats,
389 nr_cpus * sizeof (struct rdsv3_ib_statistics));
390 mutex_destroy(&ib_nodev_conns_lock);
391 list_destroy(&ib_nodev_conns);
392 list_destroy(&rdsv3_ib_devices);
393
394 RDSV3_DPRINTF4("rds_ib_exit", "Return");
395 }
396
397 #ifndef __lock_lint
398 struct rdsv3_transport rdsv3_ib_transport = {
399 .laddr_check = rds_ib_laddr_check,
400 .xmit_complete = rdsv3_ib_xmit_complete,
401 .xmit = rdsv3_ib_xmit,
402 .xmit_cong_map = NULL,
403 .xmit_rdma = rdsv3_ib_xmit_rdma,
404 .recv = rdsv3_ib_recv,
405 .conn_alloc = rdsv3_ib_conn_alloc,
406 .conn_free = rdsv3_ib_conn_free,
407 .conn_connect = rdsv3_ib_conn_connect,
408 .conn_shutdown = rdsv3_ib_conn_shutdown,
409 .inc_copy_to_user = rdsv3_ib_inc_copy_to_user,
410 .inc_free = rdsv3_ib_inc_free,
411 .cm_initiate_connect = rdsv3_ib_cm_initiate_connect,
412 .cm_handle_connect = rdsv3_ib_cm_handle_connect,
413 .cm_connect_complete = rdsv3_ib_cm_connect_complete,
414 .stats_info_copy = rdsv3_ib_stats_info_copy,
415 .exit = rdsv3_ib_exit,
416 .get_mr = rdsv3_ib_get_mr,
417 .sync_mr = rdsv3_ib_sync_mr,
418 .free_mr = rdsv3_ib_free_mr,
419 .flush_mrs = rdsv3_ib_flush_mrs,
420 .t_name = "infiniband",
421 .t_type = RDS_TRANS_IB
422 };
423 #else
424 struct rdsv3_transport rdsv3_ib_transport;
425 #endif
426
427 int
428 rdsv3_ib_init(void)
429 {
430 int ret;
431
432 RDSV3_DPRINTF4("rds_ib_init", "Enter");
433
434 list_create(&rdsv3_ib_devices, sizeof (struct rdsv3_ib_device),
435 offsetof(struct rdsv3_ib_device, list));
436 list_create(&ib_nodev_conns, sizeof (struct rdsv3_ib_connection),
437 offsetof(struct rdsv3_ib_connection, ib_node));
438 mutex_init(&ib_nodev_conns_lock, NULL, MUTEX_DRIVER, NULL);
439
440 /* allocate space for ib statistics */
441 ASSERT(rdsv3_ib_stats == NULL);
442 rdsv3_ib_stats = kmem_zalloc(nr_cpus *
443 sizeof (struct rdsv3_ib_statistics), KM_SLEEP);
444
445 rdsv3_ib_client.dip = rdsv3_dev_info;
|
208 list_remove_node(&i_ipaddr->list);
209 kmem_free(i_ipaddr, sizeof (*i_ipaddr));
210 }
211
212 rdsv3_ib_destroy_conns(rds_ibdev);
213
214 if (rds_ibdev->fmr_soft_cq)
215 rdsv3_af_thr_destroy(rds_ibdev->fmr_soft_cq);
216 if (rds_ibdev->inc_soft_cq)
217 rdsv3_af_thr_destroy(rds_ibdev->inc_soft_cq);
218
219 rdsv3_ib_destroy_mr_pool(rds_ibdev);
220 rdsv3_ib_destroy_inc_pool(rds_ibdev);
221
222 kmem_cache_destroy(rds_ibdev->ib_frag_slab);
223
224 rdsv3_af_grp_destroy(rds_ibdev->aft_hcagp);
225
226 #if 0
227 while (ib_dealloc_pd(rds_ibdev->pd)) {
228 RDSV3_DPRINTF5("rdsv3_ib_remove_one",
229 "%s-%d Failed to dealloc pd %p",
230 __func__, __LINE__, rds_ibdev->pd);
231 delay(drv_usectohz(1000));
232 }
233 #else
234 if (ib_dealloc_pd(rds_ibdev->pd)) {
235 RDSV3_DPRINTF2("rdsv3_ib_remove_one",
236 "Failed to dealloc pd %p\n", rds_ibdev->pd);
237 }
238 #endif
239
240 list_destroy(&rds_ibdev->ipaddr_list);
241 list_destroy(&rds_ibdev->conn_list);
242 list_remove_node(&rds_ibdev->list);
243 mutex_destroy(&rds_ibdev->spinlock);
244 rw_destroy(&rds_ibdev->rwlock);
245 kmem_free(rds_ibdev, sizeof (*rds_ibdev));
246
247 RDSV3_DPRINTF2("rdsv3_ib_remove_one", "Return: device: %p", device);
248 }
249
250 struct ib_client rdsv3_ib_client = {
251 .name = "rdsv3_ib",
252 .add = rdsv3_ib_add_one,
253 .remove = rdsv3_ib_remove_one,
254 .clnt_hdl = NULL,
255 .state = IB_CLNT_UNINITIALIZED
256 };
257
258 static int
259 rds_ib_conn_info_visitor(struct rdsv3_connection *conn,
260 void *buffer)
261 {
262 struct rds_info_rdma_connection *iinfo = buffer;
263 struct rdsv3_ib_connection *ic;
264
265 RDSV3_DPRINTF4("rds_ib_conn_info_visitor", "conn: %p buffer: %p",
266 conn, buffer);
267
268 /* We will only ever look at IB transports */
269 if (conn->c_trans != &rdsv3_ib_transport)
270 return (0);
271
272 iinfo->src_addr = conn->c_laddr;
273 iinfo->dst_addr = conn->c_faddr;
274
275 (void) memset(&iinfo->src_gid, 0, sizeof (iinfo->src_gid));
276 (void) memset(&iinfo->dst_gid, 0, sizeof (iinfo->dst_gid));
362 void
363 rdsv3_ib_exit(void)
364 {
365 RDSV3_DPRINTF4("rds_ib_exit", "Enter");
366
367 rdsv3_info_deregister_func(RDS_INFO_IB_CONNECTIONS, rds_ib_ic_info);
368 rdsv3_ib_destroy_nodev_conns();
369 ib_unregister_client(&rdsv3_ib_client);
370 rdsv3_ib_sysctl_exit();
371 rdsv3_ib_recv_exit();
372 rdsv3_trans_unregister(&rdsv3_ib_transport);
373 kmem_free(rdsv3_ib_stats,
374 nr_cpus * sizeof (struct rdsv3_ib_statistics));
375 mutex_destroy(&ib_nodev_conns_lock);
376 list_destroy(&ib_nodev_conns);
377 list_destroy(&rdsv3_ib_devices);
378
379 RDSV3_DPRINTF4("rds_ib_exit", "Return");
380 }
381
382 struct rdsv3_transport rdsv3_ib_transport = {
383 .laddr_check = rds_ib_laddr_check,
384 .xmit_complete = rdsv3_ib_xmit_complete,
385 .xmit = rdsv3_ib_xmit,
386 .xmit_cong_map = NULL,
387 .xmit_rdma = rdsv3_ib_xmit_rdma,
388 .recv = rdsv3_ib_recv,
389 .conn_alloc = rdsv3_ib_conn_alloc,
390 .conn_free = rdsv3_ib_conn_free,
391 .conn_connect = rdsv3_ib_conn_connect,
392 .conn_shutdown = rdsv3_ib_conn_shutdown,
393 .inc_copy_to_user = rdsv3_ib_inc_copy_to_user,
394 .inc_free = rdsv3_ib_inc_free,
395 .cm_initiate_connect = rdsv3_ib_cm_initiate_connect,
396 .cm_handle_connect = rdsv3_ib_cm_handle_connect,
397 .cm_connect_complete = rdsv3_ib_cm_connect_complete,
398 .stats_info_copy = rdsv3_ib_stats_info_copy,
399 .exit = rdsv3_ib_exit,
400 .get_mr = rdsv3_ib_get_mr,
401 .sync_mr = rdsv3_ib_sync_mr,
402 .free_mr = rdsv3_ib_free_mr,
403 .flush_mrs = rdsv3_ib_flush_mrs,
404 .t_name = "infiniband",
405 .t_type = RDS_TRANS_IB
406 };
407
408 int
409 rdsv3_ib_init(void)
410 {
411 int ret;
412
413 RDSV3_DPRINTF4("rds_ib_init", "Enter");
414
415 list_create(&rdsv3_ib_devices, sizeof (struct rdsv3_ib_device),
416 offsetof(struct rdsv3_ib_device, list));
417 list_create(&ib_nodev_conns, sizeof (struct rdsv3_ib_connection),
418 offsetof(struct rdsv3_ib_connection, ib_node));
419 mutex_init(&ib_nodev_conns_lock, NULL, MUTEX_DRIVER, NULL);
420
421 /* allocate space for ib statistics */
422 ASSERT(rdsv3_ib_stats == NULL);
423 rdsv3_ib_stats = kmem_zalloc(nr_cpus *
424 sizeof (struct rdsv3_ib_statistics), KM_SLEEP);
425
426 rdsv3_ib_client.dip = rdsv3_dev_info;
|