Subject: kern/30018: Sun QFE support in non-sparc hardware
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <peter@boku.net>
List: netbsd-bugs
Date: 04/20/2005 18:00:00
>Number:         30018
>Category:       kern
>Synopsis:       Sun QFE support in non-sparc hardware
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 20 18:00:00 +0000 2005
>Originator:     Peter Eisch
>Release:        3.99.3
>Organization:
>Environment:
NetBSD emach 3.99.3 NetBSD 3.99.3 (PETER-FW) #12: Wed Apr 20 12:43:45 CDT 2005  peter@emach:/builds/current/i386/obj/builds/current/src/sys/arch/i386/compile/PETER-FW i386

>Description:
Below is a diff for what it took to get the MAC addrs for each of the four network interfaces on a QFE (sun or non-sun barcode) PCI cards.

I cribbed a couple lines of this from the FreeBSD if_hme_pci.c and took a liberty with the 'slot' variable.  Slot is a way of figuring out which interface on the card is being initialized using a pci_get_slot(dev) call.  I don't know what the equiavlent call would be, so I worked around it with a local variable.

The changes for lines 250,251 could probably be done cleaner, though I'm fairly confident that this will retain support for the HME cards.

This has not been tested with:
- multiple QFE cards
- any combination of QFE and HME
- multiple HME cards

>How-To-Repeat:
Install a QFE card in non-sparc hardware.
>Fix:
Index: if_hme_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_hme_pci.c,v
retrieving revision 1.16
diff -r1.16 if_hme_pci.c
80a81
> int     slot = 0; /* XXX will this work if there are multiple cards? prolly not */
119c120
<       u_int8_t                buf[32];
---
>       u_int8_t                buf[64];
138a140,146
>       static const u_int8_t promdat2qfe[] = {
>               0x18, 0x00,                     /* structure length */
>               0x00,                           /* structure revision */
>               0x80,                           /* interface revision */
>               PCI_SUBCLASS_NETWORK_ETHERNET,  /* subclass code */
>               PCI_CLASS_NETWORK               /* class code */
>       };
245d252
< 
250,251c257,260
<                           memcmp(buf + PROMDATA_DATA2, promdat2,
<                               sizeof promdat2) == 0 &&
---
>                           (memcmp(buf + PROMDATA_DATA2, promdat2,
>                                   sizeof promdat2) == 0 || 
>                           memcmp(buf + PROMDATA_DATA2, promdat2qfe,
>                                  sizeof promdat2) == 0) &&
262a272,279
>                         if (bus_space_read_1(romt, romh,
>                                              vpdoff + 3 + sizeof(struct pci_vpd) + ETHER_ADDR_LEN) != 0x79 &&
>                             bus_space_read_1(romt, romh,
>                                              vpdoff + 4 * (3 + sizeof(struct pci_vpd) + ETHER_ADDR_LEN)) == 0x79)
>                           /* Use the Nth NA for the Nth HME on this SUNW,qfe. */
>                           vpdoff += slot++ * (3 + sizeof(struct pci_vpd) + ETHER_ADDR_LEN);
> 
>                         slot = (slot % 4);