[openib-general] [RFC] new ibv_get_devices() API -- avoid dlists

2005-11-10 Thread Roland Dreier
Michael Maybe its a naming thing? We can call the list
Michael iterator, does this make it less ugly?

I thought about this, but it feels like overkill for something pretty
simple.  So how about just doing

/* put list of devices in list and return length of list */
extern int ibv_get_device_list(struct ibv_device * const **list);

/* free a list of devices from ibv_get_device_list */
extern void ibv_free_device_list(struct ibv_device * const *list);

which could be used as:

struct ibv_device * const *list;
int list_len;

list_len = ibv_get_device_list(list);

/* ... */

ibv_free_device_list(list);

Or are the consts too confusing?  Should we be a little less safe but
make it nice and simple and just do

extern int ibv_get_device_list(struct ibv_device ***list);

and so on?

 - R.
___
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


Re: (SPAM?) [openib-general] [RFC] new ibv_get_devices() API -- avoid dlists

2005-11-10 Thread Sean Hefty

Roland Dreier wrote:

Or are the consts too confusing?  Should we be a little less safe but
make it nice and simple and just do


The const confuses me somewhat.


extern int ibv_get_device_list(struct ibv_device ***list);


Is ***list really what we want here?  Can we just get away with **list?

Would something like:

struct ibv_device * ibv_get_device(index);

work as well?

- Sean
___
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


Re: [openib-general] [RFC] new ibv_get_devices() API -- avoid dlists

2005-11-10 Thread Johann George
 So how about just doing
 
 /* put list of devices in list and return length of list */
 extern int ibv_get_device_list(struct ibv_device * const **list);
 
 /* free a list of devices from ibv_get_device_list */
 extern void ibv_free_device_list(struct ibv_device * const *list);

I like it much better than what we have now.  Clean, simple and easy to
understand.

 Or are the consts too confusing?  Should we be a little less safe but
 make it nice and simple and just do

I often find consts a bit of a nuisance for what they give me; but am fine
either way.  Both are simple enough.

Johann
___
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


Re: (SPAM?) [openib-general] [RFC] new ibv_get_devices() API -- avoid dlists

2005-11-10 Thread Johann George
 Is ***list really what we want here?  Can we just get away with **list?
 
 Would something like:
 
 struct ibv_device * ibv_get_device(index);

I would prefer one call to get the entire structure.  Another option might
be:

struct ibv_device ** ibv_get_device()

where it returns a list which is null terminated so you do not need to
return the length.

Johann
___
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


Re: (SPAM?) Re: (SPAM?) [openib-general] [RFC] new ibv_get_devices() API -- avoid dlists

2005-11-10 Thread Sean Hefty

Roland Dreier wrote:

  Is ***list really what we want here?  Can we just get away with **list?

Yes -- a single device is represented by a struct ibv_device *.
So an array of devices is represented by a struct ibv_device **.
And a pointer to such an array is struct ibv_device ***.


I understand.  This is just API that I've seen that used '***'.  Why not just 
return a copy of the array?



  Would something like:
  
  struct ibv_device * ibv_get_device(index);
  
  work as well?


That could work as well.  But it doesn't handle hotplug quite as well.
By returning a snapshot of all the known devices at a given moment, we
at least have a chance at doing something sensible with devices
appearing or disappearing.


This doesn't seem any worse to me.  The user can reference device_array[i] or 
call ibv_get_device(i).


I need to spend more time understanding how userspace hotplug will work.

- Sean
___
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


Re: [openib-general] [RFC] new ibv_get_devices() API -- avoid dlists

2005-11-10 Thread Johann George
 It seemed faintly preferable to tell the caller how big the array was
 rather than forcing the caller to count for itself.

If you really wanted that, I would be more inclined towards:

struct ibv_device ** ibv_get_device(*length_ptr)

and if you do not want length, you could pass a null length_ptr.  But since
I also cannot think of a strong case for it, I prefer the cleaner interface
of leaving it out.

Johann
___
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