Propagate MAC address in CIS tupple to dev/ed/ driver.

Many ed-based Ethernet PC-cards can't get correct MAC address without
this patch.

Submitted by: Takanori Watanabe <takawata@shidahara1.planet.sci.kobe-u.ac.jp>
Reviewed by: Warner Losh <imp@village.org>
This commit is contained in:
Tatsumi Hosokawa 2000-01-21 03:08:46 +00:00
parent bd9079fa6c
commit 87ef0a0afb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56361
3 changed files with 40 additions and 0 deletions

View File

@ -42,6 +42,7 @@
#include <net/if_mib.h>
#include <dev/ed/if_edvar.h>
#include <dev/pccard/pccardvar.h>
/*
* PC-Card (PCMCIA) specific code.
@ -132,6 +133,9 @@ ed_pccard_attach(device_t dev)
struct ed_softc *sc = device_get_softc(dev);
int flags = device_get_flags(dev);
int error;
int i;
u_char sum;
u_char ether_addr[ETHER_ADDR_LEN];
if (sc->port_used > 0)
ed_alloc_port(dev, sc->port_rid, sc->port_used);
@ -147,6 +151,12 @@ ed_pccard_attach(device_t dev)
return (error);
}
pccard_get_ether(dev, ether_addr);
for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
sum |= ether_addr[i];
if (sum)
bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
error = ed_attach(sc, device_get_unit(dev), flags);
return (error);
}

View File

@ -269,3 +269,16 @@ void pccard_io_unmap(struct pccard_function *, int);
#define pccard_mem_unmap(pf, window) \
(pccard_chip_mem_unmap((pf)->sc->pct, (pf)->sc->pch, (window)))
/* ivar interface */
enum {
PCCARD_IVAR_ETHADDR, /* read ethernet address from CIS tupple */
};
/* read ethernet address from CIS tupple */
__inline static int
pccard_get_ether(device_t dev, u_char *enaddr)
{
return BUS_READ_IVAR(device_get_parent(dev), dev,
PCCARD_IVAR_ETHADDR, (uintptr_t *)enaddr);
}

View File

@ -70,6 +70,9 @@
#include <pccard/slot.h>
#include <pccard/pccard_nbk.h>
#include <dev/pccard/pccardvar.h>
#include <net/ethernet.h>
devclass_t pccard_devclass;
#define PCCARD_NPORT 2
@ -252,6 +255,19 @@ pccard_release_resource(device_t bus, device_t child, int type, int rid,
return resource_list_release(rl, bus, child, type, rid, r);
}
static int
pccard_read_ivar(device_t bus, device_t child, int which, u_char *result)
{
struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
switch (which) {
case PCCARD_IVAR_ETHADDR:
bcopy(devi->misc, result, ETHER_ADDR_LEN);
return 0;
}
return ENOENT;
}
static device_method_t pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccard_probe),
@ -272,6 +288,7 @@ static device_method_t pccard_methods[] = {
DEVMETHOD(bus_set_resource, pccard_set_resource),
DEVMETHOD(bus_get_resource, pccard_get_resource),
DEVMETHOD(bus_delete_resource, pccard_delete_resource),
DEVMETHOD(bus_read_ivar, pccard_read_ivar),
{ 0, 0 }
};