📄 if_wlp_wavelan.c
字号:
#ifdef WLP_DEBUG printf("wlp%d: ENTRY wlpconfig()\n", sc->sc_unit);#endif /* * Reset the 82593. */ IOWrite1(0x00, P0_RESET); DELAY(DELAYCONST); status = IORead1(0x00); if (status != P0_S0_CHNL) { printf("wlp%d: Reset of the Intel 82593 failed (status = %x)\n", sc->sc_unit, status); goto bad; } /* * Configure the MMI (Modem Management Interface) Reference: * Interface Specification for WaveLAN Host Adapter TYPE IBM AT * Document No. 407-0024326, Rev. A */ val = read_modem_byte(sc, RF_MODEM_DSP_ID); /* DSP ID Register */ if (val != 0xAA) { printf("wlp%d: DSP ID Register returned invalid status (%x)\n", sc->sc_unit, val); goto bad; } write_modem_byte(sc, RF_DSP_LOOP, 0x00); /* Looptest Selection */ write_modem_byte(sc, RF_DSP_JAB_EN, 0x01); /* Jaber Timer Enable/Disable */ write_modem_byte(sc, RF_DSP_FREEZE, 0x00); /* Freeze Function */ write_modem_byte(sc, RF_DSP_RX_ANTENNA, 0x02); /* Antenna Selection */ write_modem_byte(sc, RF_INTER_FRAME_SPACE, 0x20); /* Inter Frame Space */ write_modem_byte(sc, RF_MODEM_DELAY, 0x04); /* Modem Delay */ write_modem_byte(sc, RF_JAM_TIME, 0x38); /* Jamming Time */ write_modem_byte(sc, RF_SIGNAL_LEVEL_THRESHOLD, sc->sc_sigthresh); /* Threshold Pre-set */ write_modem_byte(sc, RF_QUALITY_THRESHOLD, 0x03); /* Quality Threshold */ write_modem_byte(sc, RF_NWID_CODE_REGISTER_L, sc->sc_nwid[1]); /* Network Identification (low) */ write_modem_byte(sc, RF_NWID_CODE_REGISTER_H, sc->sc_nwid[0]); /* Network Identification (high) */ write_modem_byte(sc, RF_MODE_SELECT, 0x00); /* Mode Select */ sc->sc_nwidprom = 0;#define WAVELAN_PCMCIA_24#ifdef WAVELAN_PCMCIA_24 val = read_modem_byte(sc, RF_EECTRL); switch((val & RF_EECTRL_ID24)) { case RF_X24STAT_CHIPID_X24: case RF_X24STAT_CHIPID_ARIADNE: { u_int16_t freq = 0; if ((val & RF_EECTRL_ID24) == RF_X24STAT_CHIPID_X24) { printf("WaveLAN: X24 chip ID found"); } else { printf("WaveLAN: Ariadne Chip ID found\n"); } write_modem_byte(sc, RF_EEADDR, 0x00 + 0x0F); write_modem_byte(sc, RF_EECTRL,RF_EECTRL_DWLD + RF_EECTRL_PRREAD); wait_for_eeprom(sc); write_modem_byte(sc, RF_EEADDR, 0x60 + 0x01); write_modem_byte(sc, RF_EECTRL, RF_EECTRL_DWLD + RF_EECTRL_PRREAD); wait_for_eeprom(sc); wait_for_eeprom(sc); /* * Read the frequency offset from EEPROM Area 0 */ write_modem_byte(sc, RF_EEADDR, 0x00 + 0x00); write_modem_byte(sc, RF_EECTRL, RF_EECTRL_PRREAD); wait_for_eeprom(sc); val = read_modem_byte(sc, RF_EEDATAL); freq = val; val = read_modem_byte(sc, RF_EEDATAH); freq |= (val << 8); freq >>= 5; printf("WaveLAN: frequency band %d mHz (%x) \n", freq / 2 + 2400, freq);#if 0 /* * See if the modem was manufactured for use in Japan. */ write_modem_byte(sc, RF_EEADDR, 0x60 + 0x1B); write_modem_byte(sc, RF_EECTRL, RF_EECTRL_PRREAD); wait_for_eeprom(sc); val = read_modem_byte(sc, RF_EEDATAL); if (val == 0x01) { printf("WaveLAN: for use in Japanese market\n"); printf("WaveLAN: Should check call code regs...\n"); }#endif } break; default:#if 0 printf("WaveLAN: Invalid Chip ID 0x%x\n", val);#endif }#endif /* WAVELAN_PCMCIA_24 */ /* * Configure the 82593 Ethernet Controller * * (1) Load 82593 Configuration data into a temporary buffer * (2) Reset the TX DMA * (3) Point the IO Registers at the Transmit Buffer * (4) Load the configuration into the Transmit Buffer * (5) Issue the CONFIGURE Command to the 82593 * (6) Make sure that I get a CONFIGURE_DONE IRQ */ { struct i82593_conf cfg; i82593_wavelan_config(ifp, &cfg); WLP_ResetTXDMA(); WLP_PointTXBUF(WLP_TXBASE); IOWrite(0x04, (caddr_t) &cfg, sizeof(cfg)); IOWrite1(0x00, P0_CONFIGURE); if (I82593_wait(sc, P0_CONFIGURE) != (P0_CONFIGURE | P0_S0_INT | P0_S0_EXEC)) { printf("wlp%d: Configure of the Intel 82593 failed!\n", sc->sc_unit); goto bad; }#ifdef WLP_DEBUG else { /* Read Status 1-0 */ IOWrite1(0x00, P0_NOP | P0_STATUS1); printf("wlp%d: Intel 82593 configured successfully, Chip Signature: %x\n", sc->sc_unit, IORead1(0x00)); }#endif } /* * (1) Load the Ethernet address into the Transmit Buffer * (2) Reset the DMA * (3) Issue the IA-SETUP command to the 82593 * (4) Make sure that we get an IA-SETUP-DONE interrupt. */ { u_char ebuf[8]; ebuf[0] = ETHER_ADDR_LEN; ebuf[1] = 0x00; bcopy(sc->sc_ac.ac_enaddr, &ebuf[2], ETHER_ADDR_LEN); WLP_ResetTXDMA(); WLP_PointTXBUF(WLP_TXBASE); IOWrite(0x04, ebuf, ETHER_ADDR_LEN + 2); IOWrite1(0x00, P0_IA_SETUP); if (I82593_wait(sc, P0_IA_SETUP) != (P0_IA_SETUP | P0_S0_INT | P0_S0_EXEC)) { printf("wlp%d: IA-SETUP of the Intel 82593 failed!\n", sc->sc_unit); goto bad; }#ifdef WLP_DEBUG else { printf("wlp%d: IA-SETUP of the Intel 82593 successful\n", sc->sc_unit); }#endif } /* * (1) Load the multicast address list * (2) Reset the Receive DMA */ if (sc->sc_ac.ac_multiaddrs) { wlpsetrcr(sc); if (I82593_wait(sc, P0_MC_SETUP) != (P0_MC_SETUP | P0_S0_INT | P0_S0_EXEC)) { printf("wlp%d: MC_SETUP of the Intel 82593 failed!\n", sc->sc_unit); goto bad; } }#ifdef WLP_DEBUG printf("wlp%d: ENTRY wlpconfig() successful...\n", sc->sc_unit);#endif return 0;bad:#ifdef WLP_DEBUG printf("wlp%d: ENTRY wlpconfig() error...\n", sc->sc_unit);#endif return 1;}intwavelan_ioctl(ifp, cmd, data) struct ifnet *ifp; int cmd; caddr_t data;{ struct wlp_softc *sc = (struct wlp_softc *) ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int error = 0; switch (cmd) {#ifndef WAVELAN_ROAMING case SIOCSIFNWID: SetNWID(sc, (int) ifr->ifr_data, 0); break; case SIOCGIFNWID: (int) ifr->ifr_data = (sc->sc_nwid[0] << 8 | sc->sc_nwid[1]); break;#endif case SIOCSSIGTHRESH: { char t = (int) ifr->ifr_data & 0x3F; write_modem_byte(sc, RF_SIGNAL_LEVEL_THRESHOLD, t); DELAY(100000); t = read_modem_byte(sc, RF_SIGNAL_LEVEL_THRESHOLD); sc->sc_sigthresh = t; printf("wlp%d: Signal Level Threshold is 0x%02x\n", ifp->if_unit, t & 0x3F); } break;#if !defined(WAVELAN_ROAMING) case SIOCGIFSIGNAL: (int) ifr->ifr_data = sc->sc_sigstat; break;#endif default:#ifdef WAVELAN_ROAMING error = wavelan_roaming_ioctl(ifp, cmd, data);#else error = EINVAL;#endif } return error;}voidwavelan_stats(sc, ifs) struct wlp_softc *sc; struct ifstats *ifs;{ u_int8_t val;#ifdef WAVELAN_ROAMING ifs->ifs_wstats.nwid = ((sc->sc_nwid[0] << 8) | sc->sc_nwid[1]) ^ sc->sc_rs.rs_beaconkey; ifs->ifs_wstats.domid = sc->sc_rs.rs_domid; ifs->ifs_wstats.roam = sc->sc_rs.rs_roam_enable; ifs->ifs_wstats.mode = sc->sc_rs.rs_roam_mode; ifs->ifs_wstats.beaconkey = ntohs(sc->sc_rs.rs_beaconkey); ifs->ifs_wstats.soreq_cnt = sc->sc_rs.rs_SOReqCnt; ifs->ifs_wstats.soreq_failed = sc->sc_rs.rs_SOReqFailed; ifs->ifs_wstats.beacon_cnt = sc->sc_rs.rs_BeaconCount; ifs->ifs_wstats.beacon_kept = sc->sc_rs.rs_BeaconKept; if (sc->sc_rs.rs_ap) { strncpy(ifs->ifs_wstats.ap_name, sc->sc_rs.rs_ap->ap_beacon.apname, 32); ifs->ifs_wstats.ap_noise = sc->sc_rs.rs_ap->ap_beacon.rfnoise; ifs->ifs_wstats.ap_interval = *((u_int16_t *) & sc->sc_rs.rs_ap->ap_beacon.interval); ifs->ifs_wstats.ap_timeout = *((u_int16_t *) & sc->sc_rs.rs_ap->ap_beacon.timeout); ifs->ifs_wstats.ap_signal = (sc->sc_rs.rs_ap->ap_siglevel << SIGL_SHIFT) + (sc->sc_rs.rs_ap->ap_sillevel << SILL_SHIFT) + (sc->sc_rs.rs_ap->ap_sigqual << SIGQ_SHIFT); ifs->ifs_wstats.ap_thresh = (STOP_CELL(sc->sc_rs.rs_ap) << STOPC_SHIFT) + (REG_CELL(sc->sc_rs.rs_ap) << REGC_SHIFT) + (FAST_CELL(sc->sc_rs.rs_ap) << FASTC_SHIFT); } else { strncpy(ifs->ifs_wstats.ap_name, "NO AP", 5); ifs->ifs_wstats.ap_noise = 0; ifs->ifs_wstats.ap_interval = 0; ifs->ifs_wstats.ap_timeout = 0; ifs->ifs_wstats.ap_signal = sc->sc_sigstat; ifs->ifs_wstats.ap_thresh = 0; }#endif /* WAVELAN_ROAMING */ ifs->ifs_wstats.signal_stats = sc->sc_sigstat; val = read_modem_byte(sc, RF_SIGNAL_LEVEL_THRESHOLD); ifs->ifs_wstats.signal_threshold = val & 0x3F; /* 6 bits of info */ DELAY(10000); val = read_modem_byte(sc, RF_CORRECT_NWIDL); ifs->ifs_wstats.nwid_correct = val; DELAY(10000); val = read_modem_byte(sc, RF_CORRECT_NWIDH); ifs->ifs_wstats.nwid_correct |= (val << 8); DELAY(10000); val = read_modem_byte(sc, RF_INCORRECT_NWIDL); ifs->ifs_wstats.nwid_incorrect = val; DELAY(10000); val = read_modem_byte(sc, RF_INCORRECT_NWIDH); ifs->ifs_wstats.nwid_incorrect |= (val << 8);}voidSetNWID(sc, val, prom) struct wlp_softc *sc; int val; int prom;{#ifdef WLP_DEBUG printf("%s: val = 0x%04x, prom = %x\n", __FUNCTION__, val, prom);#endif if (prom && sc->sc_nwidprom == 0) { /* Enter Promisc Mode */ write_modem_byte(sc, 0x10, 0x40); sc->sc_nwidprom = 1; } else if (! prom && sc->sc_nwidprom != 0) { write_modem_byte(sc, 0x10, 0x00); sc->sc_nwidprom = 0; } if (val) { sc->sc_nwid[1] = (val & 0xFF); sc->sc_nwid[0] = ((val >> 8) & 0xFF); write_modem_byte(sc, 0x1C, sc->sc_nwid[1]); write_modem_byte(sc, 0x1D, sc->sc_nwid[0]); }#ifdef WLP_DEBUG printf("\tnwid: %x:%x, nwidprom: %x\n", sc->sc_nwid[0], sc->sc_nwid[1], sc->sc_nwidprom);#endif}#endif /* NCARD > 0 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -