Date: Fri, 21 Jan 2000 00:56:51 +0900 From: Tatsumi Hosokawa <hosokawa@itc.keio.ac.jp> To: imp@village.org Cc: mobile@FreeBSD.ORG Subject: Re: One more serious problem with -current PCCARD support Message-ID: <864sc820u4.wl@ringo.FromTo.Cc> In-Reply-To: In your message of "Tue, 18 Jan 2000 00:42:30 -0700" <200001180742.AAA15379@harmony.village.org> References: <86r9fisfe2.wl@ringo.FromTo.Cc> <86u2kesizg.wl@ringo.FromTo.Cc> <200001180742.AAA15379@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
At Tue, 18 Jan 2000 00:42:30 -0700,
Warner Losh <imp@village.org> wrote:
> Right now the ethernet information is passed between the kernel and
> pccardd in the misc field of the dev attach. I've likely broken the
> association between it and the MAC address in current's oldcard.
>
> Likely the fastest way to deal with this would be to add the misc
> field to the pccard ivars that get stuck on the device and have an
> accessor function to grab it from there. This should solve the
> problem of needing to pass down the ethernet addresses. I can try to
> find some time to code this up... I'd have done it if I had one of
> the bad ethernet cards :-).
>
> Actually, that reminds me that I do need to fix if_sn_pccard.c in a
> similar way...
Thank you and Watanabe-san for the discussion about this problem.
Following patch is the result of it. I tested it with IBM Creditcard
Ethernet card.
Comments?
Index: dev/pccard/pccardvar.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/pccard/pccardvar.h,v
retrieving revision 1.5
diff -u -r1.5 pccardvar.h
--- dev/pccard/pccardvar.h 2000/01/10 06:58:17 1.5
+++ dev/pccard/pccardvar.h 2000/01/20 15:50:28
@@ -269,3 +269,16 @@
#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);
+}
Index: dev/ed/if_ed_pccard.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ed/if_ed_pccard.c,v
retrieving revision 1.8
diff -u -r1.8 if_ed_pccard.c
--- dev/ed/if_ed_pccard.c 1999/12/10 07:22:53 1.8
+++ dev/ed/if_ed_pccard.c 2000/01/20 15:50:28
@@ -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 @@
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);
@@ -146,6 +150,12 @@
ed_release_resources(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);
Index: pccard/pccard_nbk.c
===================================================================
RCS file: /home/ncvs/src/sys/pccard/pccard_nbk.c,v
retrieving revision 1.12
diff -u -r1.12 pccard_nbk.c
--- pccard/pccard_nbk.c 1999/12/08 07:55:19 1.12
+++ pccard/pccard_nbk.c 2000/01/20 15:50:33
@@ -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 @@
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 @@
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 }
};
--
---------------------------
Tatsumi Hosokawa
hosokawa@itc.keio.ac.jp
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?864sc820u4.wl>
