[openib-general] Proposed device enumeration & async event APIs
Fab Tillier
ftillier at infiniconsys.com
Fri Sep 10 14:57:35 PDT 2004
> From: Roland Dreier [mailto:roland at topspin.com]
> Sent: Friday, September 10, 2004 2:29 PM
>
> Fab> This sounds sane. Are existing device notifications invoked
> Fab> from the thread context of the ib_register_client function?
> Fab> In other words, does the ib_register_client function return
> Fab> before or after the client has receive notifications of
> Fab> existing events? Does ib_unregister_client synchronize with
> Fab> callback delivery? Does ib_unregister_client send "pretend"
> Fab> removal events?
>
> Yes to all of these questions.
...
>
> So everything is synchronized by the lock and all fake events are
> generated.
Great! I didn't see a way for a client to associate a context or some such
thing with a device when the device is added. I would think this would be
beneficial in order to avoid requiring clients to search a list for a
matching device. I'm suggesting something like this:
struct ib_device_reg {
void (*remove)(struct ib_device_reg *);
struct list_head reg_list;
struct list_head dev_list;
};
struct ib_client {
struct ib_device_reg * (*add) (struct ib_device *);
struct list_head list;
struct list_head reg_list;
};
Adding a device does
lock device list
add device to device list
generate add callbacks for existing clients
insert returned value into device's reg_list
insert returned value into client's reg_list
unlock device list
and removing a device does
lock device list
for each entry in device's reg_list {
generate remove callback
remove device_reg.dev_list and device_reg.reg_list from
lists }
unlock device list
and unregister does
lock device list
remove client from client list
for each entry in client's reg_list {
generate remove callbacks
remove device_reg.dev_list and device_reg.reg_list from
lists }
unlock device list
This does two things: it provides a way for clients to get some sort of
context back for removal, allowing them to embed a struct ib_device_reg in
whatever they allocate for the device; it allows clients to suppress a
remove event for a device for which they failed to allocate stuff or don't
care about.
Thoughts?
- Fab
More information about the general
mailing list