From ca0f2a1b7aeea0f4454943a372377cb8329d4e1b Mon Sep 17 00:00:00 2001 From: imp Date: Sat, 16 Mar 2002 22:59:15 +0000 Subject: o Rework the identify routine a little, merging it with NetBSD's wi. o Add exerpimental support for identifying lucent cards. All of mine come back with ID of 1, but NetBSD committed code for 5. So accept both. o rename wi_prism2_ver to wi_firmware_ver so that we could, if necessary, do special things for lucent cards too. o Bring in a small part of the changes from airtools: The wi_cmd function now takes two additional arguments. I didn't bring in their ioctls yet. o eliminate the use of LE16TOH, and remove its define. o Print the firmware as if there were 100 versions instead of 10. This means that 6.1 and 6.10 aren't confusing to people. We now print 6.01 in the former case. # A good junior hacker project would be to merge the NetBSD, FreeBSD, and # OpenBSD drivers into one source base. --- sys/dev/wi/if_wavelan_ieee.h | 2 +- sys/dev/wi/if_wi.c | 87 ++++++++++++++++++++------------------------ sys/dev/wi/if_wireg.h | 6 ++- 3 files changed, 45 insertions(+), 50 deletions(-) diff --git a/sys/dev/wi/if_wavelan_ieee.h b/sys/dev/wi/if_wavelan_ieee.h index 0454898..334d724 100644 --- a/sys/dev/wi/if_wavelan_ieee.h +++ b/sys/dev/wi/if_wavelan_ieee.h @@ -275,7 +275,7 @@ struct wi_ltv_keys { #define WI_RID_REG_DOMAINS 0xFD11 /* list of intendted regulatory doms */ #define WI_RID_TEMP_TYPE 0xFD12 /* hw temp range code */ #define WI_RID_CIS 0xFD13 /* PC card info struct */ -#define WI_RID_STA_IDENEITY 0xFD20 /* station funcs firmware ident */ +#define WI_RID_STA_IDENTITY 0xFD20 /* station funcs firmware ident */ #define WI_RID_STA_SUP_RANGE 0xFD21 /* station supplier compat */ #define WI_RID_MFI_ACT_RANGE 0xFD22 #define WI_RID_CFI_ACT_RANGE 0xFD33 diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index ee2e54b..21ab969 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -124,11 +124,6 @@ static const char rcsid[] = static u_int8_t wi_mcast_addr[6] = { 0x01, 0x60, 0x1D, 0x00, 0x01, 0x00 }; #endif -/* - * The following is for compatibility with NetBSD. - */ -#define LE16TOH(a) ((a) = le16toh((a))) - static void wi_intr(void *); static void wi_reset(struct wi_softc *); static int wi_ioctl(struct ifnet *, u_long, caddr_t); @@ -141,7 +136,7 @@ static void wi_txeof(struct wi_softc *, int); static void wi_update_stats(struct wi_softc *); static void wi_setmulti(struct wi_softc *); -static int wi_cmd(struct wi_softc *, int, int); +static int wi_cmd(struct wi_softc *, int, int, int, int); static int wi_read_record(struct wi_softc *, struct wi_ltv_gen *); static int wi_write_record(struct wi_softc *, struct wi_ltv_gen *); static int wi_read_data(struct wi_softc *, int, int, caddr_t, int); @@ -654,63 +649,59 @@ wi_get_id(sc, dev) ver.wi_len = 5; wi_read_record(sc, (struct wi_ltv_gen *)&ver); device_printf(dev, "using "); - switch (le16toh(ver.wi_ver[0])) { + sc->wi_prism2 = 1; + sc->wi_nic_type = le16toh(ver.wi_ver[0]); + switch (sc->wi_nic_type) { case WI_NIC_EVB2: printf("RF:PRISM2 MAC:HFA3841"); - sc->wi_prism2 = 1; break; case WI_NIC_HWB3763: printf("RF:PRISM2 MAC:HFA3841 CARD:HWB3763 rev.B"); - sc->wi_prism2 = 1; break; case WI_NIC_HWB3163: printf("RF:PRISM2 MAC:HFA3841 CARD:HWB3163 rev.A"); - sc->wi_prism2 = 1; break; case WI_NIC_HWB3163B: printf("RF:PRISM2 MAC:HFA3841 CARD:HWB3163 rev.B"); - sc->wi_prism2 = 1; break; case WI_NIC_EVB3: printf("RF:PRISM2 MAC:HFA3842"); - sc->wi_prism2 = 1; break; case WI_NIC_HWB1153: printf("RF:PRISM1 MAC:HFA3841 CARD:HWB1153"); - sc->wi_prism2 = 1; break; case WI_NIC_P2_SST: printf("RF:PRISM2 MAC:HFA3841 CARD:HWB3163-SST-flash"); - sc->wi_prism2 = 1; break; case WI_NIC_PRISM2_5: printf("RF:PRISM2.5 MAC:ISL3873"); - sc->wi_prism2 = 1; break; case WI_NIC_3874A: printf("RF:PRISM2.5 MAC:ISL3874A(PCI)"); - sc->wi_prism2 = 1; + break; + case WI_NIC_LUCENT: + case WI_NIC_LUCENT_ALT: + printf("WaveLan/Lucent/Orinoco chip"); + sc->wi_prism2 = 0; break; default: - printf("Lucent chip or unknown chip\n"); + printf("Lucent chip or unknown chip %04x", ver.wi_ver[0]); sc->wi_prism2 = 0; break; } - if (sc->wi_prism2) { - /* try to get prism2 firm version */ - memset(&ver, 0, sizeof(ver)); - ver.wi_type = WI_RID_IDENT; - ver.wi_len = 5; - wi_read_record(sc, (struct wi_ltv_gen *)&ver); - LE16TOH(ver.wi_ver[1]); - LE16TOH(ver.wi_ver[2]); - LE16TOH(ver.wi_ver[3]); - printf(", Firmware: %d.%d variant %d\n", ver.wi_ver[2], - ver.wi_ver[3], ver.wi_ver[1]); - sc->wi_prism2_ver = ver.wi_ver[2] * 100 + - ver.wi_ver[3] * 10 + ver.wi_ver[1]; - } + /* get firmware version */ + memset(&ver, 0, sizeof(ver)); + ver.wi_type = WI_RID_STA_IDENTITY; + ver.wi_len = 5; + wi_read_record(sc, (struct wi_ltv_gen *)&ver); + ver.wi_ver[1] = le16toh(ver.wi_ver[1]); + ver.wi_ver[2] = le16toh(ver.wi_ver[2]); + ver.wi_ver[3] = le16toh(ver.wi_ver[3]); + sc->wi_firmware_ver = ver.wi_ver[2] * 100 + ver.wi_ver[3] * 10 + + ver.wi_ver[1]; + printf(", Firmware: %d.%02d variant %d\n", ver.wi_ver[2], + ver.wi_ver[3], ver.wi_ver[1]); return; } @@ -863,7 +854,7 @@ wi_inquire(xsc) if (ifp->if_flags & IFF_OACTIVE) return; - wi_cmd(sc, WI_CMD_INQUIRE, WI_INFO_COUNTERS); + wi_cmd(sc, WI_CMD_INQUIRE, WI_INFO_COUNTERS, 0, 0); return; } @@ -979,10 +970,12 @@ wi_intr(xsc) } static int -wi_cmd(sc, cmd, val) +wi_cmd(sc, cmd, val0, val1, val2) struct wi_softc *sc; int cmd; - int val; + int val0; + int val1; + int val2; { int i, s = 0; @@ -998,9 +991,9 @@ wi_cmd(sc, cmd, val) return(ETIMEDOUT); } - CSR_WRITE_2(sc, WI_PARAM0, val); - CSR_WRITE_2(sc, WI_PARAM1, 0); - CSR_WRITE_2(sc, WI_PARAM2, 0); + CSR_WRITE_2(sc, WI_PARAM0, val0); + CSR_WRITE_2(sc, WI_PARAM1, val1); + CSR_WRITE_2(sc, WI_PARAM2, val2); CSR_WRITE_2(sc, WI_COMMAND, cmd); for (i = 0; i < WI_TIMEOUT; i++) { @@ -1026,7 +1019,7 @@ wi_cmd(sc, cmd, val) if (i == WI_TIMEOUT) { device_printf(sc->dev, - "timeout in wi_cmd %x; event status %x\n", cmd, s); + "timeout in wi_cmd 0x%04x; event status 0x%04x\n", cmd, s); return(ETIMEDOUT); } @@ -1041,7 +1034,7 @@ wi_reset(sc) int i; for (i = 0; i < WI_INIT_TRIES; i++) { - if (wi_cmd(sc, WI_CMD_INI, 0) == 0) + if (wi_cmd(sc, WI_CMD_INI, 0, 0, 0) == 0) break; DELAY(WI_DELAY * 1000); } @@ -1086,7 +1079,7 @@ wi_read_record(sc, ltv) } /* Tell the NIC to enter record read mode. */ - if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_READ, ltv->wi_type)) + if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_READ, ltv->wi_type, 0, 0)) return(EIO); /* Seek to the record. */ @@ -1241,7 +1234,7 @@ wi_write_record(sc, ltv) for (i = 0; i < ltv->wi_len - 1; i++) CSR_WRITE_2(sc, WI_DATA1, ptr[i]); - if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_WRITE, ltv->wi_type)) + if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_WRITE, ltv->wi_type, 0, 0)) return(EIO); return(0); @@ -1375,7 +1368,7 @@ wi_alloc_nicmem(sc, len, id) { int i; - if (wi_cmd(sc, WI_CMD_ALLOC_MEM, len)) { + if (wi_cmd(sc, WI_CMD_ALLOC_MEM, len, 0, 0)) { device_printf(sc->dev, "failed to allocate %d bytes on NIC\n", len); return(ENOMEM); @@ -1941,7 +1934,7 @@ wi_init(xsc) * It is under investigation for details. * (ichiro@netbsd.org) */ - if (sc->wi_prism2_ver < 83 ) { + if (sc->wi_firmware_ver < 83 ) { /* firm ver < 0.8 variant 3 */ WI_SETVAL(WI_RID_PROMISC, 1); } @@ -1960,7 +1953,7 @@ wi_init(xsc) wi_setmulti(sc); /* Enable desired port */ - wi_cmd(sc, WI_CMD_ENABLE | sc->wi_portnum, 0); + wi_cmd(sc, WI_CMD_ENABLE | sc->wi_portnum, 0, 0, 0); if (wi_alloc_nicmem(sc, ETHER_MAX_LEN + sizeof(struct wi_frame) + 8, &id)) device_printf(sc->dev, "tx buffer allocation failed\n"); @@ -2065,7 +2058,7 @@ wi_start(ifp) m_freem(m0); - if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id)) + if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id, 0, 0)) device_printf(sc->dev, "xmit failed\n"); ifp->if_flags |= IFF_OACTIVE; @@ -2109,7 +2102,7 @@ wi_mgmt_xmit(sc, data, len) wi_write_data(sc, id, WI_802_11_OFFSET_RAW, dptr, (len - sizeof(struct wi_80211_hdr)) + 2); - if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id)) { + if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id, 0, 0)) { device_printf(sc->dev, "xmit failed\n"); return(EIO); } @@ -2139,7 +2132,7 @@ wi_stop(sc) */ if (CSR_READ_2(sc, WI_STATUS) != 0xffff) { CSR_WRITE_2(sc, WI_INT_EN, 0); - wi_cmd(sc, WI_CMD_DISABLE|sc->wi_portnum, 0); + wi_cmd(sc, WI_CMD_DISABLE|sc->wi_portnum, 0, 0, 0); } untimeout(wi_inquire, sc, sc->wi_stat_ch); diff --git a/sys/dev/wi/if_wireg.h b/sys/dev/wi/if_wireg.h index ff120e3..c7c5750 100644 --- a/sys/dev/wi/if_wireg.h +++ b/sys/dev/wi/if_wireg.h @@ -142,7 +142,8 @@ struct wi_softc { struct callout_handle wi_stat_ch; struct mtx wi_mtx; int wi_prism2; - int wi_prism2_ver; + int wi_firmware_ver; + int wi_nic_type; int wi_bus_type; /* Bus attachment type */ }; @@ -481,11 +482,12 @@ struct wi_ltv_memsz { * NIC Identification (0xFD0B) */ #define WI_RID_CARDID 0xFD0B -#define WI_RID_IDENT 0xFD20 struct wi_ltv_ver { u_int16_t wi_len; u_int16_t wi_type; u_int16_t wi_ver[4]; +#define WI_NIC_LUCENT 0x0001 /* Emperically derived */ +#define WI_NIC_LUCENT_ALT 0x0005 /* Emperically derived */ #define WI_NIC_EVB2 0x8000 #define WI_NIC_HWB3763 0x8001 #define WI_NIC_HWB3163 0x8002 -- cgit v1.1