[openib-general] Proposed device enumeration & async event APIs

Grant Grundler iod00d at hp.com
Mon Sep 13 08:42:06 PDT 2004


On Sun, Sep 12, 2004 at 09:05:14AM -0700, Roland Dreier wrote:
> OK, I thought about it some more and I decided that it's better to
> have the API from the beginning so that more efficient implementations
> can be added without changing the client code.  However, I implemented
> the following API:
> 
> 	void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
> 	int   ib_set_client_data(struct ib_device *device, struct ib_client *client,
> 				 void *data);

Can a client talk to multiple devices?
ie is the "data" more closely associated with the ib_device or
with the ib_client?
Someplace, there has to be a 1:1 mapping or ib_get_client_data() can't
work.


> I think this is equivalent to what you proposed but simpler to
> implement and use.  It also mimics the API in <linux/pci.h>:
> 
> 	void *pci_get_drvdata (struct pci_dev *pdev);
> 	void pci_set_drvdata (struct pci_dev *pdev, void *data);

pci set/get hides the mechanism of where/how this info is stored
so fewer details of the pci data structure are public. And in fact,
the implementation makes use of generic device support.
Everything is handed in and pci has a 1:1 - so life is simple.

To answer Fab's question: How do PCI functions avoid a malloc?
It's a 1:1 relationship and the PCI discovery sets up all
the main data structures.

> (my set function returns an int because it does an allocation, so it
> can fail)

This feels like it shouldn't be necessary.
PCI has dealt with the 1:N relationship well before a driver gets
associated with a device and might call pci_set_drvdata().

The 1:N relationship (ib_device:ib_client) needs to be dealt with at
a different level or earlier in the initialization sequence.
Is that not possible?

hth,
grant



More information about the general mailing list