[openib-general] Re: device classes

Greg KH greg at kroah.com
Tue Aug 10 14:39:06 PDT 2004


On Wed, Aug 04, 2004 at 05:30:25PM -0700, Roland Dreier wrote:
>     Greg> A class?  Look at the struct class_interface code,
>     Greg> specifically class_interface_register() and
>     Greg> class_interface_unregister() functions.  If you call them,
>     Greg> then the function pointers you pass in for the add and
>     Greg> remove functions in the struct class_interface will get
>     Greg> called for every struct class_device that is added or
>     Greg> removed for that struct class.
> 
> Hmm, that could work, if the core creates "infiniband_device" and
> "infiniband_port" classes.  But is it kosher to use the
> class_device.dev pointer to go back up to the actual device (and then
> create a new class_device)?

I don't see why not.

>     Greg> No, that sounds about right.  IPoIB would be a struct class.
>     Greg> Hm, but then you want that class code to be called whenever
>     Greg> a struct device (really a ib_device) is added to the system.
>     Greg> That's not built in anywhere, you'll have to either add some
>     Greg> custom code, or I need to get off my butt and create a
>     Greg> struct bus_interface chunk of code that will work like
>     Greg> struct class_interface.  Would that help out here?
> 
> Not sure -- it seems like bus_interface would be per bus (not per "bus
> type"), so it's not quite what we want.  IPoIB wants to get notified
> whenever a device is added to any of the "virtual infiniband" buses we
> talked about.

Then you might just want to stick with an internal notifier that you
have full control over.

> At a high level here are the things I think we want to happen (exact
> function names below aren't important, I'm just trying to come up with
> placeholders):
> 
>  - when a low-level driver (eg mthca) finds an HCA, it calls
>    ib_register_device(), which creates a virtual bus rooted at the PCI
>    device and adds new virtual devices for the HCA and each of its
>    ports (in part to be able to put both global HCA attributes and
>    also per-port attributes in sysfs)

Sounds good.

>  - when an ULP (IPoIB, SDP, etc) is loaded, it calls ib_register_ulp()
>    This will trigger callbacks for all of the HCA devices that already
>    exist (if the ULP is loaded after the LLD) and also when new HCA
>    devices are added.

Also sounds reasonable.  You might have to do this in ib specific code
however.

>  - when a low-level driver is unloaded or an HCA is hot-removed, it
>    calls ib_unregister_device(), which calls every ULP's remove() method.
>  - when a ULP is unloaded, it calls ib_unregister_ulp(), which calls
>    the ULP's remove() method for every HCA in the system.
> 
> The question is how to make this happen within the device model.  One
> way would be to use (abuse?) the class_interface stuff by having
> ib_register_device() create virtual devices and then create
> class_devices for each virtual device.

That might work.

> Then the ULPs would get called back by the class_interface stuff, and
> then follow the dev pointer back to the original struct device and
> create their own class_devices.  There may be a better way...

I think you need to start out slow and work into it.  Don't try to
design it all ahead of time.  Try getting the struct device stuff and
the bus working first :)

thanks,

greg k-h

(p.s. please cc me on any questions you want me to answer, as I'm not on
the openib mailing lists anymore.)



More information about the general mailing list