Sean Hefty wrote:
> The following patch adds calls to the userspace RDMA CM to return its list
> of RDMA devices.  The calls are similar to ibv_get_device_list() /
> ibv_free_device_list().
Thanks Sean for adding this functionality. This was needed.

Thanks,
Pradipta Kumar.
> 
> Currently, RDMA device contexts are handed to the user only after they
> create an rdma_cm_id and bind it to a local device.  By exposing the device
> list to the user, it makes it easier for the user to allocate device
> specific resources (such as PDs, CQs, etc.) that are shared among multiple
> rdma_cm_id's.
> 
> Signed-off-by: Sean Hefty <[EMAIL PROTECTED]>
> ---
> Index: include/rdma/rdma_cma.h
> ===================================================================
> --- include/rdma/rdma_cma.h   (revision 8215)
> +++ include/rdma/rdma_cma.h   (working copy)
> @@ -332,4 +332,20 @@ static inline uint16_t rdma_get_dst_port
>               ((struct sockaddr_in *) &id->route.addr.dst_addr)->sin_port;
>  }
>  
> +/**
> + * rdma_get_devices - Get list of RDMA devices currently available.
> + * @num_devices: If non-NULL, set to the number of devices returned.
> + *
> + * Return a NULL-terminated array of opened RDMA devices.  Callers can use 
> this
> + * routine to allocate resources on specific RDMA devices that will be shared
> + * across multiple rdma_cm_id's.
> + * The array must be released by calling rdma_free_devices().
> + */
> +struct ibv_context **rdma_get_devices(int *num_devices);
> +
> +/**
> + * rdma_free_devices - Frees the list of devices returned by 
> rdma_get_devices().
> + */
> +void rdma_free_devices(struct ibv_context **list);
> +
>  #endif /* RDMA_CMA_H */
> Index: src/cma.c
> ===================================================================
> --- src/cma.c (revision 8517)
> +++ src/cma.c (working copy)
> @@ -216,6 +216,32 @@ err:
>       return ret;
>  }
>  
> +struct ibv_context **rdma_get_devices(int *num_devices)
> +{
> +     struct ibv_context **devs = NULL;
> +     int i;
> +
> +     if (!cma_dev_cnt && ucma_init())
> +             goto out;
> +
> +     devs = malloc(sizeof *devs * (cma_dev_cnt + 1));
> +     if (!devs)
> +             goto out;
> +
> +     for (i = 0; i < cma_dev_cnt; i++)
> +             devs[i] = cma_dev_array[i].verbs;
> +     devs[i] = NULL;
> +out:
> +     if (num_devices)
> +             *num_devices = devs ? cma_dev_cnt : 0;
> +     return devs;
> +}
> +
> +void rdma_free_devices(struct ibv_context **list)
> +{
> +     free(list);
> +}
> +
>  static void __attribute__((destructor)) rdma_cma_fini(void)
>  {
>       ucma_cleanup();
> Index: src/librdmacm.map
> ===================================================================
> --- src/librdmacm.map (revision 8215)
> +++ src/librdmacm.map (working copy)
> @@ -21,5 +21,7 @@ RDMACM_1.0 {
>               rdma_get_dst_attr;
>               rdma_join_multicast;
>               rdma_leave_multicast;
> +             rdma_get_devices;
> +             rdma_free_devices;
>       local: *;
>  };
> 
> 
> _______________________________________________
> openib-general mailing list
> openib-general@openib.org
> http://openib.org/mailman/listinfo/openib-general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
> 
> 


_______________________________________________
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to