[openib-general] Re: device classes
Roland Dreier
roland at topspin.com
Wed Aug 4 17:30:25 PDT 2004
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)?
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.
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)
- 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.
- 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. 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...
- R.
- R.
More information about the general
mailing list