So I think I've got this working now (with a driver that exposes two
ethernet ports on a single PCI function -- i.e. dev_info_t.)
I've posted a webrev of the changes at
http://cr.opensolaris.org/~gdamore/ppa/
What this does is allow NIC drivers to have more than one mac instance
(i.e. network port) on a given dev_info_t (i.e. PCI function, etc.)
More details:
A few notes about what I've done:
1) In order for this to work, a mac provider that wants to do this has
to supply their own getinfo(9e) implementation. This is required
because Nemo won't know how to map from dev_t to dev_info_t otherwise.
To facilitate this for device drivers, I've had to add some additional
exports to the mac_provider.h header:
MAC_MAX_MINOR -- this is just as before, but now its available so
provider's know what the maximum instance number they can support is.
MAC_MINOR_TO_INSTANCE() -- this allows a mac provider to decode
GLDv3's encoding of the minor number to obtain the PPA (mac instance
number)
MAC_INSTANCE_TO_MINOR() -- the inverse, for completeness, although so
far I've not had a need for it
mac_getinfo() -- this function is used so that a driver can rely on
GLDv3 to perform its magic for "open" dev_t's (i.e. do the
dld_finddevinfo() lookup, etc.) The MAC driver calls this for any dev_t
where the minor number is > MAC_MAX_MINOR, and < MAC_PRIVATE_MINOR. (It
can just tail-call this function.)
This also allows drivers that need to have their own minor_t's (e.g. for
device control or convergence scenarios) to supply their own getinfo(9e)
as well, and still allow GLDv3 to do its magic for the typical ones.
(Note that a driver that uses this feature, but still only uses one MAC
instance with PPA == ddi_get_instance(), can just call mac_getinfo(9e)
for any dev_t < MAC_PRIVATE_MINOR.)
2) This support is only available for GLDv3 devices. Non-GLDv3 devices
still are limited.
3) No changes to boot device support. In particular, there is still
some low-level code surrounding boot that assumes ddi_get_instance() ==
PPA. Fixing this particular code is probably rather problematic. It
would be a lot easier if we could ditch the boot code's use of style 2
and just let it do a Style 1 open! For my driver, it just means that
you can only use the first port of the card for networking booting...
livable if unfortunate.
4) In softmac, I have changed the code to just skip over GLDv3 style 1
nodes. Softmac doesn't appear to need them, and it significantly
complicated the code, since it becomes harder to match the inbound
device node for such a case to a softmac.
5) I use the dev_to_instance() to lookup dev_info_t instance from a
dev_t -- this calls the driver's getinfo(9e) implementation (see above
comments), instead of using a fixed calculation. This is used to
attach the underlying dev_info_t. See softmac_main.c line 1512 for this.
6) The kstat names were created incorrectly using ddi_get_instance().
That's fixed now too. :-) Actually the code is now simpler, for that,
since it doesn't need to check for GLDv3 anymore.
5) I fixed some bogus comments in softmac about GLDv3 VLAN handling,
which don't apply anymore after Crossbow.
The other thing is that once this fix is integrated, we'll need to be a
*lot* more careful about understanding that assumptions that
mac->mi_instance == ddi_get_instance() are inherently bogus.
Thanks in advance for any feedback you can provide!
- Garrett
_______________________________________________
networking-discuss mailing list
[email protected]