From aa5eb84d3cf44e0d4c6a2d63e8bafb0d166f2409 Mon Sep 17 00:00:00 2001 From: Duncan Barclay Date: Tue, 21 Mar 2000 14:27:46 +0000 Subject: [PATCH] Added user level updates and reading of parameters. --- sys/dev/ray/if_ray.c | 162 +++++++++++++++++++++++++++++++++------- sys/dev/ray/if_raymib.h | 140 +++++++++++++++++++++++++++++++--- 2 files changed, 266 insertions(+), 36 deletions(-) diff --git a/sys/dev/ray/if_ray.c b/sys/dev/ray/if_ray.c index d64b01927766..491c3151b33d 100644 --- a/sys/dev/ray/if_ray.c +++ b/sys/dev/ray/if_ray.c @@ -181,32 +181,31 @@ * reported via raycontrol * start_join_done needs a restart in download_done - done * now use netbsd style start up + * ioctls - done + * use raycontrol + * translation, BSS_ID, countrycode, changing mode * * shutdown * ifp->if_hdr length * _reset - check where needed * apm - * ioctls - translation, BSS_ID, countrycode, changing mode * faster TX routine * more translations * infrastructure mode - maybe need some of the old stuff for checking? * differeniate between parameters set in attach and init * spinning in ray_issue_cmd * fix the XXX code in start_join_done - * - * callout handles need rationalising. can probably remove timerh and - * use ccs_timerh for download and sj_timerh - * - * ray_update_params_done needs work - * * make RAY_DEBUG a knob somehow - either sysctl or IFF_DEBUG - * + * ray_update_params_done needs work + * do an rx level and antenna cache, the antenna can be used to set c_antenna + * for tx + * callout handles need rationalising. can probably remove timerh and + * use ccs_timerh for download and sj_timerh */ #define XXX 0 #define XXX_NETBSDTX 0 #define XXX_PROM 0 -#define XXX_IOCTL 0 /* * XXX build options - move to LINT @@ -237,8 +236,6 @@ #define RAY_NEED_CM_REMAPPING 1 /* Needed until pccard maps more than one memory area */ -#define RAY_DUMP_CM_ON_GIFMEDIA 1 /* Dump some common memory when the SIOCGIFMEDIA ioctl is issued - a nasty hack for debugging and will be placed by an ioctl and control program */ - #define RAY_RESET_TIMEOUT (5*hz) /* Timeout for resetting the card */ #define RAY_USE_CALLOUT_STOP 0 /* Set for kernels with callout_stop function - 3.3 and above */ @@ -1042,9 +1039,9 @@ ray_init (xsc) see the ray_attach section for stuff to move #endif sc->sc_d.np_upd_param = 0; - bzero(sc->sc_d.np_bss_id, sizeof(sc->sc_d.np_bss_id)); + bzero(sc->sc_d.np_bss_id, ETHER_ADDR_LEN); sc->sc_d.np_inited = 0; - sc->sc_d.np_def_txrate = RAY_MIB_BASIC_RATE_SET_2000K; + sc->sc_d.np_def_txrate = RAY_MIB_BASIC_RATE_SET_DEFAULT; sc->sc_d.np_encrypt = 0; sc->sc_d.np_ap_status = RAY_MIB_AP_STATUS_DEFAULT; @@ -1325,7 +1322,11 @@ ray_ioctl (ifp, command, data) case SIOCSRAYPARAM: RAY_DPRINTFN(30, ("ray%d: ioctl called for SRAYPARAM\n", sc->unit)); - error = EINVAL; + if ((error = copyin(ifr->ifr_data, &pr, sizeof(pr)))) + break; + error = ray_user_update_params(sc, &pr); + error2 = copyout(&pr, ifr->ifr_data, sizeof(pr)); + error = error2 ? error2 : error; break; case SIOCGRAYPARAM: @@ -1371,10 +1372,6 @@ ray_ioctl (ifp, command, data) case SIOCGIFMEDIA: RAY_DPRINTFN(30, ("ray%d: ioctl called for GIFMEDIA\n", sc->unit)); -#if RAY_DUMP_CM_ON_GIFMEDIA - RAY_DPRINTFN(10, ("ray%d: RAY_STATUS\n", sc->unit)); - RAY_DNET_DUMP(sc, "."); -#endif /* RAY_DUMP_CM_ON_GIFMEDIA */ error = EINVAL; break; @@ -1497,8 +1494,8 @@ ray_start_sc (sc) * Reserve and fill the ccs - must do the length later. * * Even though build 4 and build 5 have different fields all these - * are common apart from tx_rate. This will be overwritten later if - * needed. + * are common apart from tx_rate. Neither the NetBSD driver or Linux + * driver bother to overwrite this for build 4 cards. */ ccs = RAY_CCS_ADDRESS(i); bufp = RAY_TX_BASE + i * RAY_TX_BUF_SIZE; @@ -1508,8 +1505,8 @@ ray_start_sc (sc) SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_link, RAY_CCS_LINK_NULL); SRAM_WRITE_FIELD_2(sc, ccs, ray_cmd_tx, c_bufp, bufp); SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_tx_rate, sc->sc_c.np_def_txrate); - SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_apm_mode, 0); - SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_antenna, 0); + SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_apm_mode, 0); /* XXX */ + SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_antenna, 0); /* XXX */ bufp += sizeof(struct ray_tx_phy_header); /* @@ -1792,7 +1789,7 @@ ray_start_wrhdr (sc, eh, bufp) } /* - * recevice a packet from the card + * receive a packet from the card */ static void ray_rx (sc, rcs) @@ -2963,9 +2960,9 @@ PUT2(MIB5(mib_cw_min), RAY_MIB_CW_MIN_V5); MIB5(mib_test_min_chan) = RAY_MIB_TEST_MIN_CHAN_DEFAULT; MIB5(mib_test_max_chan) = RAY_MIB_TEST_MAX_CHAN_DEFAULT; MIB5(mib_allow_probe_resp) = RAY_MIB_ALLOW_PROBE_RESP_DEFAULT; - MIB5(mib_privacy_must_start) = RAY_MIB_PRIVACY_MUST_START_DEFAULT; - MIB5(mib_privacy_can_join) = sc->sc_d.np_priv_start; - MIB5(mib_basic_rate_set[0]) = sc->sc_d.np_priv_join; + MIB5(mib_privacy_must_start) = sc->sc_d.np_priv_start; + MIB5(mib_privacy_can_join) = sc->sc_d.np_priv_join; + MIB5(mib_basic_rate_set[0]) = sc->sc_d.np_def_txrate; if (!RAY_ECF_READY(sc)) { printf("ray%d: ray_download_params something is already happening\n", @@ -3376,6 +3373,48 @@ ray_user_update_params(struct ray_softc *sc, struct ray_param_req *pr) return (EIO); } + if (pr->r_paramid > RAY_MIB_MAX) { + return (EINVAL); + } + + /* + * Handle certain parameters specially + */ + switch (pr->r_paramid) { + case RAY_MIB_NET_TYPE: + if (sc->sc_c.np_net_type == *pr->r_data) + return (0); + sc->sc_d.np_net_type = *pr->r_data; + if (ifp->if_flags & IFF_RUNNING) + ray_start_join_net(sc); + return (0); + + case RAY_MIB_SSID: + if (!bcmp(sc->sc_c.np_ssid, pr->r_data, IEEE80211_NWID_LEN)) + return (0); + bcopy(pr->r_data, sc->sc_d.np_ssid, IEEE80211_NWID_LEN); + if (ifp->if_flags & IFF_RUNNING) + ray_start_join_net(sc); + return (0); + + case RAY_MIB_BASIC_RATE_SET: + sc->sc_d.np_def_txrate = *pr->r_data; + break; + + case RAY_MIB_AP_STATUS: /* Unsupported */ + case RAY_MIB_MAC_ADDR: /* XXX Need interface up */ + case RAY_MIB_PROMISC: /* BPF */ + return (EINVAL); + break; + + default: + break; + } + + if (pr->r_paramid > RAY_MIB_LASTUSER) { + return (EINVAL); + } + /* wait to be able to issue the command */ rv = 0; while (ray_cmd_is_running(sc, SCP_UPD_UPDATEPARAMS) || @@ -3410,6 +3449,7 @@ static int ray_user_report_params(struct ray_softc *sc, struct ray_param_req *pr) { struct ifnet *ifp; + int mib_sizes[] = RAY_MIB_SIZES; int rv; RAY_DPRINTFN(5, ("ray%d: ray_user_report_params\n", sc->unit)); @@ -3422,6 +3462,76 @@ ray_user_report_params(struct ray_softc *sc, struct ray_param_req *pr) return (EIO); } + /* test for illegal values or immediate responses */ + if (pr->r_paramid > RAY_MIB_LASTUSER) { + switch (pr->r_paramid) { + + case RAY_MIB_VERSION: + if (sc->sc_version == RAY_ECFS_BUILD_4) + *pr->r_data = 4; + else + *pr->r_data = 5; + break; + + case RAY_MIB_CUR_BSSID: + bcopy(sc->sc_c.np_bss_id, pr->r_data, ETHER_ADDR_LEN); + break; + case RAY_MIB_CUR_INITED: + *pr->r_data = sc->sc_c.np_inited; + break; + case RAY_MIB_CUR_DEF_TXRATE: + *pr->r_data = sc->sc_c.np_def_txrate; + break; + case RAY_MIB_CUR_ENCRYPT: + *pr->r_data = sc->sc_c.np_encrypt; + break; + case RAY_MIB_CUR_NET_TYPE: + *pr->r_data = sc->sc_c.np_net_type; + break; + case RAY_MIB_CUR_SSID: + bcopy(sc->sc_c.np_ssid, pr->r_data, IEEE80211_NWID_LEN); + break; + case RAY_MIB_CUR_PRIV_START: + *pr->r_data = sc->sc_c.np_priv_start; + break; + case RAY_MIB_CUR_PRIV_JOIN: + *pr->r_data = sc->sc_c.np_priv_join; + break; + + case RAY_MIB_DES_BSSID: + bcopy(sc->sc_d.np_bss_id, pr->r_data, ETHER_ADDR_LEN); + break; + case RAY_MIB_DES_INITED: + *pr->r_data = sc->sc_d.np_inited; + break; + case RAY_MIB_DES_DEF_TXRATE: + *pr->r_data = sc->sc_d.np_def_txrate; + break; + case RAY_MIB_DES_ENCRYPT: + *pr->r_data = sc->sc_d.np_encrypt; + break; + case RAY_MIB_DES_NET_TYPE: + *pr->r_data = sc->sc_d.np_net_type; + break; + case RAY_MIB_DES_SSID: + bcopy(sc->sc_d.np_ssid, pr->r_data, IEEE80211_NWID_LEN); + break; + case RAY_MIB_DES_PRIV_START: + *pr->r_data = sc->sc_d.np_priv_start; + break; + case RAY_MIB_DES_PRIV_JOIN: + *pr->r_data = sc->sc_d.np_priv_join; + break; + + default: + return (EINVAL); + break; + } + pr->r_failcause = 0; + pr->r_len = mib_sizes[pr->r_paramid]; + return (0); + } + /* wait to be able to issue the command */ rv = 0; while (ray_cmd_is_running(sc, SCP_REPORTPARAMS) diff --git a/sys/dev/ray/if_raymib.h b/sys/dev/ray/if_raymib.h index b7e5b8968293..8906181053b6 100644 --- a/sys/dev/ray/if_raymib.h +++ b/sys/dev/ray/if_raymib.h @@ -220,18 +220,37 @@ struct ray_stats_req { #define RAY_MIB_PRIVACY_MUST_START 43 #define RAY_MIB_PRIVACY_CAN_JOIN 44 #define RAY_MIB_BASIC_RATE_SET 45 -#define RAY_MIB_MAX 46 +#define RAY_MIB_VERSION 46 +#define RAY_MIB_CUR_BSSID 47 +#define RAY_MIB_CUR_INITED 48 +#define RAY_MIB_CUR_DEF_TXRATE 49 +#define RAY_MIB_CUR_ENCRYPT 50 +#define RAY_MIB_CUR_NET_TYPE 51 +#define RAY_MIB_CUR_SSID 52 +#define RAY_MIB_CUR_PRIV_START 53 +#define RAY_MIB_CUR_PRIV_JOIN 54 +#define RAY_MIB_DES_BSSID 55 +#define RAY_MIB_DES_INITED 56 +#define RAY_MIB_DES_DEF_TXRATE 57 +#define RAY_MIB_DES_ENCRYPT 58 +#define RAY_MIB_DES_NET_TYPE 59 +#define RAY_MIB_DES_SSID 60 +#define RAY_MIB_DES_PRIV_START 61 +#define RAY_MIB_DES_PRIV_JOIN 62 + +#define RAY_MIB_LASTUSER 45 +#define RAY_MIB_MAX 62 /* * Strings for the MIB */ #define RAY_MIB_STRINGS { \ - "NET_TYPE", \ - "AP_STATUS", \ + "Network type", \ + "AP status", \ "SSID", \ - "SCAN_MODE", \ - "APM_MODE", \ - "MAC_ADDR", \ + "Scan mode", \ + "APM mode", \ + "MAC address", \ "FRAG_THRESH", \ "DWELL_TIME", \ "BEACON_PERIOD", \ @@ -271,7 +290,90 @@ struct ray_stats_req { "ALLOW_PROBE_RESP", \ "PRIVACY_MUST_START", \ "PRIVACY_CAN_JOIN", \ - "BASIC_RATE_SET" \ + "BASIC_RATE_SET", \ + "Firmware version", \ + "Current BSS Id", \ + "Current INITED", \ + "Current DEF_TXRATE", \ + "Current ENCRYPT", \ + "Current NET_TYPE", \ + "Current SSID", \ + "Current PRIV_START", \ + "Current PRIV_JOIN", \ + "Desired BSSID", \ + "Desired INITED", \ + "Desired DEF_TXRATE", \ + "Desired ENCRYPT", \ + "Desired NET_TYPE", \ + "Desired SSID", \ + "Desired PRIV_START", \ + "Desired PRIV_JOIN" \ +} + +#define RAY_MIB_HELP_STRINGS { \ + "0 Ad hoc, 1 Infrastructure", \ + "0 Station, 1 Access Point", \ + "", \ + "0 Passive, 1 Active", \ + "0 Off, 1 On", \ + "", \ + "FRAG_THRESH", \ + "DWELL_TIME", \ + "BEACON_PERIOD", \ + "DTIM_INTERVAL", \ + "MAX_RETRY", \ + "ACK_TIMO", \ + "SIFS", \ + "DIFS", \ + "PIFS", \ + "RTS_THRESH", \ + "SCAN_DWELL", \ + "SCAN_MAX_DWELL", \ + "ASSOC_TIMO", \ + "ADHOC_SCAN_CYCLE", \ + "INFRA_SCAN_CYCLE", \ + "INFRA_SUPER_SCAN_CYCLE", \ + "PROMISC", \ + "UNIQ_WORD", \ + "SLOT_TIME", \ + "ROAM_LOW_SNR_THRESH", \ + "LOW_SNR_COUNT", \ + "INFRA_MISSED_BEACON_COUNT", \ + "ADHOC_MISSED_BEACON_COUNT", \ + "COUNTRY_CODE", \ + "HOP_SEQ", \ + "HOP_SEQ_LEN", \ + "CW_MAX", \ + "CW_MIN", \ + "NOISE_FILTER_GAIN", \ + "NOISE_LIMIT_OFFSET", \ + "RSSI_THRESH_OFFSET", \ + "BUSY_THRESH_OFFSET", \ + "SYNC_THRESH", \ + "TEST_MODE", \ + "TEST_MIN_CHAN", \ + "TEST_MAX_CHAN", \ + "ALLOW_PROBE_RESP", \ + "PRIVACY_MUST_START", \ + "PRIVACY_CAN_JOIN", \ + "BASIC_RATE_SET", \ + "", \ + "", \ + "0 Joined a net, 1 Created a net", \ + "Current DEF_TXRATE", \ + "Current ENCRYPT", \ + "Current NET_TYPE", \ + "", \ + "Current PRIV_START", \ + "Current PRIV_JOIN", \ + "N/A", \ + "N/A", \ + "Desired DEF_TXRATE", \ + "Desired ENCRYPT", \ + "Desired NET_TYPE", \ + "", \ + "Desired PRIV_START", \ + "Desired PRIV_JOIN" \ } /* @@ -323,7 +425,24 @@ struct ray_stats_req { 1, /* RAY_MIB_ALLOW_PROBE_RESP */ \ 1, /* RAY_MIB_PRIVACY_MUST_START */ \ 1, /* RAY_MIB_PRIVACY_CAN_JOIN */ \ - 8 /* RAY_MIB_BASIC_RATE_SET */ \ + 8, /* RAY_MIB_BASIC_RATE_SET */ \ + 1, /* RAY_MIB_VERSION */ \ + ETHER_ADDR_LEN, /* RAY_MIB_CUR_BSSID */ \ + 1, /* RAY_MIB_CUR_INITED */ \ + 1, /* RAY_MIB_CUR_DEF_TXRATE */ \ + 1, /* RAY_MIB_CUR_ENCRYPT */ \ + 1, /* RAY_MIB_CUR_NET_TYPE */ \ + IEEE80211_NWID_LEN, /* RAY_MIB_CUR_SSID */ \ + 1, /* RAY_MIB_CUR_PRIV_START */ \ + 1, /* RAY_MIB_CUR_PRIV_JOIN */ \ + ETHER_ADDR_LEN, /* RAY_MIB_DES_BSSID */ \ + 1, /* RAY_MIB_DES_INITED */ \ + 1, /* RAY_MIB_DES_DEF_TXRATE */ \ + 1, /* RAY_MIB_DES_ENCRYPT */ \ + 1, /* RAY_MIB_DES_NET_TYPE */ \ + IEEE80211_NWID_LEN, /* RAY_MIB_DES_SSID */ \ + 1, /* RAY_MIB_DES_PRIV_START */ \ + 1 /* RAY_MIB_DES_PRIV_JOIN */ \ } /* @@ -592,7 +711,7 @@ struct ray_stats_req { * Linux.c 0xff * NetBSD 0xff * Symb 0xXX - so what happens in adhoc if the beacon is missed? - * do we create our own beacon + * do we create our own beacon */ #define RAY_MIB_ADHOC_MISSED_BEACON_COUNT_DISABLED 0xff #define RAY_MIB_ADHOC_MISSED_BEACON_COUNT_DEFAULT RAY_MIB_ADHOC_MISSED_BEACON_COUNT_DISABLED @@ -670,4 +789,5 @@ struct ray_stats_req { #define RAY_MIB_BASIC_RATE_SET_1000K 2 #define RAY_MIB_BASIC_RATE_SET_1500K 3 #define RAY_MIB_BASIC_RATE_SET_2000K 4 -#define RAY_MIB_BASIC_RATE_SET_DEFAULT RAY_MIB_BASIC_RATE_SET_1000K +#define RAY_MIB_BASIC_RATE_SET_MAX 5 +#define RAY_MIB_BASIC_RATE_SET_DEFAULT RAY_MIB_BASIC_RATE_SET_2000K