diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-10-10 20:27:47 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-10-10 20:27:47 +0000 |
commit | d6bab5cdbe6466c848f46b52777ed2ef9fcd17ac (patch) | |
tree | d673b0fbd98930082b52196f4fb8c75ac360c8ee | |
parent | 9ca2315087f2a6c35c0af2749c2e6882addb645c (diff) |
Make wi_get_id() table driven, similar to NetBSD and FreeBSD but
make the table itself a #define so we can reuse it in wicontrol.
Also add a bunch of chip IDs from NetBSD/FreeBSD.
mickey@ OK
-rw-r--r-- | sbin/wicontrol/wicontrol.c | 71 | ||||
-rw-r--r-- | sys/dev/ic/if_wi.c | 80 | ||||
-rw-r--r-- | sys/dev/ic/if_wi_ieee.h | 201 | ||||
-rw-r--r-- | sys/dev/ic/if_wireg.h | 16 | ||||
-rw-r--r-- | sys/dev/ic/if_wivar.h | 7 |
5 files changed, 247 insertions, 128 deletions
diff --git a/sbin/wicontrol/wicontrol.c b/sbin/wicontrol/wicontrol.c index 24b6d20ae6f..9f41c22ad74 100644 --- a/sbin/wicontrol/wicontrol.c +++ b/sbin/wicontrol/wicontrol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wicontrol.c,v 1.40 2002/07/25 22:27:50 deraadt Exp $ */ +/* $OpenBSD: wicontrol.c,v 1.41 2002/10/10 20:27:46 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -69,7 +69,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997, 1998, 1999\ Bill Paul. All rights reserved."; static const char rcsid[] = - "@(#) $OpenBSD: wicontrol.c,v 1.40 2002/07/25 22:27:50 deraadt Exp $"; + "@(#) $OpenBSD: wicontrol.c,v 1.41 2002/10/10 20:27:46 millert Exp $"; #endif void wi_getval(char *, struct wi_req *); @@ -86,7 +86,7 @@ void wi_printaplist(char *); void wi_dumpinfo(char *); void wi_setkeys(char *, int, char *); void wi_printkeys(struct wi_req *); -void wi_printcardid(struct wi_req *, int); +void wi_printcardid(struct wi_req *, u_int16_t); void wi_dumpstats(char *); void wi_dumpstations(char *); void printb(char *, unsigned short, char *); @@ -95,6 +95,10 @@ char *portid(char *); int get_if_flags(int, const char *); int set_if_flags(int, const char *, int); +const struct wi_card_ident wi_card_ident[] = { + WI_CARD_IDS +}; + void wi_getval(iface, wreq) char *iface; @@ -373,58 +377,29 @@ wi_printkeys(wreq) void wi_printcardid(wreq, chip_id) struct wi_req *wreq; - int chip_id; + u_int16_t chip_id; { - char *chip_name; + const char *chip_name; + const struct wi_card_ident *id; if (wreq->wi_len < 4) return; - /* Copied from wi_get_id() in if_wi.c */ - switch (chip_id) { - case WI_NIC_EVB2: - chip_name = "PRISM I HFA3841(EVB2)"; - break; - case WI_NIC_HWB3763: - chip_name = "PRISM II HWB3763 rev.B"; - break; - case WI_NIC_HWB3163: - chip_name = "PRISM II HWB3163 rev.A"; - break; - case WI_NIC_HWB3163B: - chip_name = "PRISM II HWB3163 rev.B"; - break; - case WI_NIC_EVB3: - chip_name = "PRISM II HFA3842(EVB3)"; - break; - case WI_NIC_HWB1153: - chip_name = "PRISM I HFA1153"; - break; - case WI_NIC_P2_SST: - chip_name = "PRISM II HWB3163 SST-flash"; - break; - case WI_NIC_PRISM2_5: - chip_name = "PRISM 2.5 ISL3873"; - break; - case WI_NIC_37300P: - chip_name = "PRISM 2.5 ISL37300P"; - break; - case WI_NIC_LUCENT: - chip_name = "Lucent"; - break; - case WI_NIC_SONY: - chip_name = "Sony"; - break; - case WI_NIC_LUCENT_EM: - chip_name = "Lucent (embedded)"; - break; - default: - if (chip_id & 0x8000) - chip_name = "Unknown PRISM II chip"; + for (id = wi_card_ident; id->firm_type != WI_NOTYPE; id++) { + if (chip_id == id->card_id) + break; + } + if (id->firm_type != WI_NOTYPE) + chip_name = id->card_name; + else { + if (chip_id & htole16(0x8000)) + chip_name = "Unknown PRISM chip"; else chip_name = "Unknown Lucent chip"; } - if (chip_id & 0x8000) + + /* XXX - doesn't decode Symbol firmware */ + if (chip_id & htole16(0x8000)) printf("[ %s, Firmware %d.%d.%d ]", chip_name, letoh16(wreq->wi_val[2]), letoh16(wreq->wi_val[3]), letoh16(wreq->wi_val[1])); @@ -660,7 +635,7 @@ wi_dumpinfo(iface) wreq.wi_type = WI_RID_CARD_ID; wreq.wi_len = 5; wi_getval(iface, &wreq); - chip_id = letoh16(wreq.wi_val[0]); + chip_id = wreq.wi_val[0]; /* Check for WEP support. */ bzero((char *)&wreq, sizeof(wreq)); diff --git a/sys/dev/ic/if_wi.c b/sys/dev/ic/if_wi.c index 9ed7ee1d4ef..fd863db2acd 100644 --- a/sys/dev/ic/if_wi.c +++ b/sys/dev/ic/if_wi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi.c,v 1.80 2002/10/04 02:29:36 millert Exp $ */ +/* $OpenBSD: if_wi.c,v 1.81 2002/10/10 20:27:46 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -124,7 +124,7 @@ u_int32_t widebug = WIDEBUG; #if !defined(lint) && !defined(__OpenBSD__) static const char rcsid[] = - "$OpenBSD: if_wi.c,v 1.80 2002/10/04 02:29:36 millert Exp $"; + "$OpenBSD: if_wi.c,v 1.81 2002/10/10 20:27:46 millert Exp $"; #endif /* lint */ #ifdef foo @@ -172,6 +172,10 @@ struct cfdriver wi_cd = { NULL, "wi", DV_IFNET }; +const struct wi_card_ident wi_card_ident[] = { + WI_CARD_IDS +}; + int wi_attach(sc) struct wi_softc *sc; @@ -2231,65 +2235,29 @@ STATIC void wi_get_id(sc) struct wi_softc *sc; { - struct wi_ltv_ver ver; - u_int16_t pri_fw_ver[3]; - const char *p; + struct wi_ltv_ver ver; + const struct wi_card_ident *id; + u_int16_t pri_fw_ver[3]; + const char *chip_id; /* get chip identity */ bzero(&ver, sizeof(ver)); ver.wi_type = WI_RID_CARD_ID; ver.wi_len = 5; wi_read_record(sc, (struct wi_ltv_gen *)&ver); - switch (letoh16(ver.wi_ver[0])) { - case WI_NIC_EVB2: - p = "PRISM I HFA3841(EVB2)"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_HWB3763: - p = "PRISM II HWB3763 rev.B"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_HWB3163: - p = "PRISM II HWB3163 rev.A"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_HWB3163B: - p = "PRISM II HWB3163 rev.B"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_EVB3: - p = "PRISM II HFA3842(EVB3)"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_HWB1153: - p = "PRISM I HFA1153"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_P2_SST: - p = "PRISM II HWB3163 SST-flash"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_PRISM2_5: - p = "PRISM 2.5 ISL3873"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_3874A: - p = "PRISM 2.5 ISL3874A(PCI)"; - sc->sc_firmware_type = WI_INTERSIL; - break; - case WI_NIC_37300P: - p = "PRISM 2.5 ISL37300P"; - sc->sc_firmware_type = WI_INTERSIL; - break; - default: - if (ver.wi_ver[0] & htole16(0x8000)) { - p = "Unknown PRISM2 chip"; - sc->sc_firmware_type = WI_INTERSIL; - } else { - sc->sc_firmware_type = WI_LUCENT; - } + for (id = wi_card_ident; id->firm_type != WI_NOTYPE; id++) { + if (ver.wi_ver[0] == id->card_id) break; } + if (id->firm_type != WI_NOTYPE) { + sc->sc_firmware_type = id->firm_type; + chip_id = id->card_name; + } else if (ver.wi_ver[0] & htole16(0x8000)) { + sc->sc_firmware_type = WI_INTERSIL; + chip_id = "Unknown PRISM2 chip"; + } else { + sc->sc_firmware_type = WI_LUCENT; + } /* get primary firmware version (XXX - how to do Lucent?) */ if (sc->sc_firmware_type != WI_LUCENT) { @@ -2338,14 +2306,12 @@ wi_get_id(sc) } else { printf("\n%s: %s%s, Firmware %d.%d.%d (primary), %d.%d.%d (station), ", WI_PRT_ARG(sc), - sc->sc_firmware_type == WI_SYMBOL ? "Symbol " : "", p, - pri_fw_ver[0], pri_fw_ver[1], pri_fw_ver[2], + sc->sc_firmware_type == WI_SYMBOL ? "Symbol " : "", + chip_id, pri_fw_ver[0], pri_fw_ver[1], pri_fw_ver[2], sc->sc_sta_firmware_ver / 10000, (sc->sc_sta_firmware_ver % 10000) / 100, sc->sc_sta_firmware_ver % 100); } - - return; } STATIC int diff --git a/sys/dev/ic/if_wi_ieee.h b/sys/dev/ic/if_wi_ieee.h index 4301b8921a9..0ed4d38e2a6 100644 --- a/sys/dev/ic/if_wi_ieee.h +++ b/sys/dev/ic/if_wi_ieee.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_ieee.h,v 1.12 2002/10/04 02:29:36 millert Exp $ */ +/* $OpenBSD: if_wi_ieee.h,v 1.13 2002/10/10 20:27:46 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -709,4 +709,201 @@ struct wi_scan_p2_hdr { #define WI_RID_MAC_PROC_DELAY 0xFDC5 /* MAC processing delay time */ #define WI_RID_DATA_RATES 0xFDC6 /* supported data rates */ -#endif +/* Firmware types */ +#define WI_NOTYPE 0 +#define WI_LUCENT 1 +#define WI_INTERSIL 2 +#define WI_SYMBOL 3 + +/* Card identities */ +#define WI_NIC_LUCENT 0x0001 + +#define WI_NIC_SONY 0x0002 + +#define WI_NIC_LUCENT_EMB 0x0005 + +#define WI_NIC_EVB2 0x8000 + +#define WI_NIC_HWB3763 0x8001 + +#define WI_NIC_HWB3163 0x8002 + +#define WI_NIC_HWB3163B 0x8003 + +#define WI_NIC_EVB3 0x8004 + +#define WI_NIC_HWB1153 0x8007 + +#define WI_NIC_P2_SST 0x8008 /* Prism2 with SST flush */ + +#define WI_NIC_EVB2_SST 0x8009 + +#define WI_NIC_3842_EVA 0x800A /* 3842 Evaluation Board */ + +#define WI_NIC_3842_PCMCIA_AMD 0x800B /* Prism2.5 PCMCIA */ +#define WI_NIC_3842_PCMCIA_SST 0x800C +#define WI_NIC_3842_PCMCIA_ATL 0x800D +#define WI_NIC_3842_PCMCIA_ATS 0x800E + +#define WI_NIC_3842_MINI_AMD 0x8012 /* Prism2.5 Mini-PCI */ +#define WI_NIC_3842_MINI_SST 0x8013 +#define WI_NIC_3842_MINI_ATL 0x8014 +#define WI_NIC_3842_MINI_ATS 0x8015 + +#define WI_NIC_3842_PCI_AMD 0x8016 /* Prism2.5 PCI-bridge */ +#define WI_NIC_3842_PCI_SST 0x8017 +#define WI_NIC_3842_PCI_ATL 0x8018 +#define WI_NIC_3842_PCI_ATS 0x8019 + +#define WI_NIC_P3_PCMCIA_AMD 0x801A /* Prism3 PCMCIA */ +#define WI_NIC_P3_PCMCIA_SST 0x801B +#define WI_NIC_P3_PCMCIA_ATL 0x801C +#define WI_NIC_P3_PCMCIA_ATS 0x801D + +#define WI_NIC_P3_MINI_AMD 0x8021 /* Prism3 Mini-PCI */ +#define WI_NIC_P3_MINI_SST 0x8022 +#define WI_NIC_P3_MINI_ATL 0x8023 +#define WI_NIC_P3_MINI_ATS 0x8024 + +struct wi_card_ident { + const u_int16_t card_id; + const char *card_name; + const u_int8_t firm_type; +}; + +#define WI_CARD_IDS \ + { \ + htole16(WI_NIC_LUCENT), \ + "Lucent WaveLAN/IEEE", \ + WI_LUCENT \ + }, { \ + htole16(WI_NIC_SONY), \ + "Sony WaveLAN/IEEE", \ + WI_LUCENT \ + }, { \ + htole16(WI_NIC_LUCENT_EMB), \ + "Lucent Embedded WaveLAN/IEEE", \ + WI_LUCENT \ + }, { \ + htole16(WI_NIC_EVB2), \ + "PRISM2 HFA3841(EVB2)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_HWB3763), \ + "PRISM2 HWB3763 rev.B", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_HWB3163), \ + "PRISM2 HWB3163 rev.A", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_HWB3163B), \ + "PRISM2 HWB3163 rev.B", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_EVB3), \ + "PRISM2 HFA3842(EVB3)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_HWB1153), \ + "PRISM1 HWB1153", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P2_SST), \ + "PRISM2 HWB3163 SST-flash", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_EVB2_SST), \ + "PRISM2 HWB3163(EVB2) SST-flash", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_EVA), \ + "PRISM2 HFA3842(EVAL)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_PCMCIA_AMD), \ + "PRISM2.5 ISL3873", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_PCMCIA_SST), \ + "PRISM2.5 ISL3873", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_PCMCIA_ATL), \ + "PRISM2.5 ISL3873", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_PCMCIA_ATS), \ + "PRISM2.5 ISL3873", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_MINI_AMD), \ + "PRISM2.5 ISL3874A(Mini-PCI)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_MINI_SST), \ + "PRISM2.5 ISL3874A(Mini-PCI)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_MINI_ATL), \ + "PRISM2.5 ISL3874A(Mini-PCI)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_MINI_ATS), \ + "PRISM2.5 ISL3874A(Mini-PCI)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_PCI_AMD), \ + "PRISM2.5 ISL3874A(PCI-bridge)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_PCI_SST), \ + "PRISM2.5 ISL3874A(PCI-bridge)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_PCI_ATS), \ + "PRISM2.5 ISL3874A(PCI-bridge)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_3842_PCI_ATL), \ + "PRISM2.5 ISL3874A(PCI-bridge)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P3_PCMCIA_AMD), \ + "PRISM3 ISL37300P", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P3_PCMCIA_SST), \ + "PRISM3 ISL37300P", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P3_PCMCIA_ATL), \ + "PRISM3 ISL37300P", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P3_PCMCIA_ATS), \ + "PRISM3 ISL37300P", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P3_MINI_AMD), \ + "PRISM3 ISL37300P(PCI)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P3_MINI_SST), \ + "PRISM3 ISL37300P(PCI)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P3_MINI_ATL), \ + "PRISM3 ISL37300P(PCI)", \ + WI_INTERSIL \ + }, { \ + htole16(WI_NIC_P3_MINI_ATS), \ + "PRISM3 ISL37300P(PCI)", \ + WI_INTERSIL \ + }, { \ + 0, \ + NULL, \ + WI_NOTYPE \ + } + +#endif /* _IF_WI_IEEE_H */ diff --git a/sys/dev/ic/if_wireg.h b/sys/dev/ic/if_wireg.h index 792ac998097..b96f7307f3c 100644 --- a/sys/dev/ic/if_wireg.h +++ b/sys/dev/ic/if_wireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wireg.h,v 1.28 2002/09/12 03:48:31 millert Exp $ */ +/* $OpenBSD: if_wireg.h,v 1.29 2002/10/10 20:27:46 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -402,19 +402,6 @@ 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 -#define WI_NIC_SONY 0x0002 -#define WI_NIC_LUCENT_EM 0x0005 -#define WI_NIC_EVB2 0x8000 -#define WI_NIC_HWB3763 0x8001 -#define WI_NIC_HWB3163 0x8002 -#define WI_NIC_HWB3163B 0x8003 -#define WI_NIC_EVB3 0x8004 -#define WI_NIC_HWB1153 0x8007 -#define WI_NIC_P2_SST 0x8008 /* Prism2 with SST flush */ -#define WI_NIC_PRISM2_5 0x800C -#define WI_NIC_3874A 0x8013 /* Prism2.5 Mini-PCI */ -#define WI_NIC_37300P 0x801a }; /* @@ -611,4 +598,3 @@ struct wi_frame { #define WI_SNAP_WORD1 (WI_SNAP_K2 | (WI_SNAP_CONTROL << 8)) #define WI_SNAPHDR_LEN 0x6 #define WI_FCS_LEN 0x4 - diff --git a/sys/dev/ic/if_wivar.h b/sys/dev/ic/if_wivar.h index 25062908825..d9bbe6778ef 100644 --- a/sys/dev/ic/if_wivar.h +++ b/sys/dev/ic/if_wivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wivar.h,v 1.18 2002/07/09 11:00:27 fgsch Exp $ */ +/* $OpenBSD: if_wivar.h,v 1.19 2002/10/10 20:27:46 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -121,11 +121,6 @@ struct wi_softc { #define WI_FLAGS_HAS_HOSTAP 0x0100 #define WI_FLAGS_BUS_PCMCIA 0x0200 -/* Firmware types */ -#define WI_LUCENT 0 -#define WI_INTERSIL 1 -#define WI_SYMBOL 2 - #define WI_PRT_FMT "%s" #define WI_PRT_ARG(sc) (sc)->sc_dev.dv_xname |