Deleted Added
full compact
if_wi.c (116898) if_wi.c (116951)
1/* $NetBSD: wi.c,v 1.109 2003/01/09 08:52:19 dyoung Exp $ */
2
3/*
4 * Copyright (c) 1997, 1998, 1999
5 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 48 unchanged lines hidden (view full) ---

57 * from the HCF Light code and corresponding documentation.
58 *
59 * This driver supports the ISA, PCMCIA and PCI versions of the Lucent
60 * WaveLan cards (based on the Hermes chipset), as well as the newer
61 * Prism 2 chipsets with firmware from Intersil and Symbol.
62 */
63
64#include <sys/cdefs.h>
1/* $NetBSD: wi.c,v 1.109 2003/01/09 08:52:19 dyoung Exp $ */
2
3/*
4 * Copyright (c) 1997, 1998, 1999
5 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 48 unchanged lines hidden (view full) ---

57 * from the HCF Light code and corresponding documentation.
58 *
59 * This driver supports the ISA, PCMCIA and PCI versions of the Lucent
60 * WaveLan cards (based on the Hermes chipset), as well as the newer
61 * Prism 2 chipsets with firmware from Intersil and Symbol.
62 */
63
64#include <sys/cdefs.h>
65__FBSDID("$FreeBSD: head/sys/dev/wi/if_wi.c 116898 2003-06-27 00:49:04Z sam $");
65__FBSDID("$FreeBSD: head/sys/dev/wi/if_wi.c 116951 2003-06-28 06:17:26Z sam $");
66
67#define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */
68#define WI_HERMES_STATS_WAR /* Work around stats counter bug. */
69
70#define NBPFILTER 1
71
72#include <sys/param.h>
73#include <sys/systm.h>

--- 9 unchanged lines hidden (view full) ---

83#include <sys/bus.h>
84#include <sys/random.h>
85#include <sys/syslog.h>
86#include <sys/sysctl.h>
87
88#include <machine/bus.h>
89#include <machine/resource.h>
90#include <machine/clock.h>
66
67#define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */
68#define WI_HERMES_STATS_WAR /* Work around stats counter bug. */
69
70#define NBPFILTER 1
71
72#include <sys/param.h>
73#include <sys/systm.h>

--- 9 unchanged lines hidden (view full) ---

83#include <sys/bus.h>
84#include <sys/random.h>
85#include <sys/syslog.h>
86#include <sys/sysctl.h>
87
88#include <machine/bus.h>
89#include <machine/resource.h>
90#include <machine/clock.h>
91#include <machine/atomic.h>
91#include <sys/rman.h>
92
93#include <net/if.h>
94#include <net/if_arp.h>
95#include <net/ethernet.h>
96#include <net/if_dl.h>
97#include <net/if_media.h>
98#include <net/if_types.h>
92#include <sys/rman.h>
93
94#include <net/if.h>
95#include <net/if_arp.h>
96#include <net/ethernet.h>
97#include <net/if_dl.h>
98#include <net/if_media.h>
99#include <net/if_types.h>
99#include <net/if_ieee80211.h>
100
100
101#include <net80211/ieee80211_var.h>
102#include <net80211/ieee80211_ioctl.h>
103
101#include <netinet/in.h>
102#include <netinet/in_systm.h>
103#include <netinet/in_var.h>
104#include <netinet/ip.h>
105#include <netinet/if_ether.h>
106
107#include <net/bpf.h>
108

--- 125 unchanged lines hidden (view full) ---

234devclass_t wi_devclass;
235
236int
237wi_attach(device_t dev)
238{
239 struct wi_softc *sc = device_get_softc(dev);
240 struct ieee80211com *ic = &sc->sc_ic;
241 struct ifnet *ifp = &ic->ic_if;
104#include <netinet/in.h>
105#include <netinet/in_systm.h>
106#include <netinet/in_var.h>
107#include <netinet/ip.h>
108#include <netinet/if_ether.h>
109
110#include <net/bpf.h>
111

--- 125 unchanged lines hidden (view full) ---

237devclass_t wi_devclass;
238
239int
240wi_attach(device_t dev)
241{
242 struct wi_softc *sc = device_get_softc(dev);
243 struct ieee80211com *ic = &sc->sc_ic;
244 struct ifnet *ifp = &ic->ic_if;
242 int i, nrate, mword, buflen;
243 u_int8_t r;
245 int i, nrates, buflen;
244 u_int16_t val;
245 u_int8_t ratebuf[2 + IEEE80211_RATE_SIZE];
246 u_int16_t val;
247 u_int8_t ratebuf[2 + IEEE80211_RATE_SIZE];
248 struct ieee80211_rateset *rs;
246 static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
248 };
249 int error;
250
251 /*
252 * NB: no locking is needed here; don't put it here
253 * unless you can prove it!

--- 48 unchanged lines hidden (view full) ---

302 ifp->if_ioctl = wi_ioctl;
303 ifp->if_start = wi_start;
304 ifp->if_watchdog = wi_watchdog;
305 ifp->if_init = wi_init;
306 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
307
308 ic->ic_phytype = IEEE80211_T_DS;
309 ic->ic_opmode = IEEE80211_M_STA;
249 static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
251 };
252 int error;
253
254 /*
255 * NB: no locking is needed here; don't put it here
256 * unless you can prove it!

--- 48 unchanged lines hidden (view full) ---

305 ifp->if_ioctl = wi_ioctl;
306 ifp->if_start = wi_start;
307 ifp->if_watchdog = wi_watchdog;
308 ifp->if_init = wi_init;
309 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
310
311 ic->ic_phytype = IEEE80211_T_DS;
312 ic->ic_opmode = IEEE80211_M_STA;
310 ic->ic_flags = IEEE80211_F_HASPMGT | IEEE80211_F_HASAHDEMO;
313 ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_AHDEMO;
311 ic->ic_state = IEEE80211_S_INIT;
312 ic->ic_newstate = wi_newstate;
314 ic->ic_state = IEEE80211_S_INIT;
315 ic->ic_newstate = wi_newstate;
313 ic->ic_fixed_rate = -1; /* Auto */
314
316
315 /* Find available channels */
317 /*
318 * Query the card for available channels and setup the
319 * channel table. We assume these are all 11b channels.
320 */
316 buflen = sizeof(val);
317 if (wi_read_rid(sc, WI_RID_CHANNEL_LIST, &val, &buflen) != 0)
318 val = htole16(0x1fff); /* assume 1-11 */
321 buflen = sizeof(val);
322 if (wi_read_rid(sc, WI_RID_CHANNEL_LIST, &val, &buflen) != 0)
323 val = htole16(0x1fff); /* assume 1-11 */
319 for (i = 0; i < 16; i++) {
320 if (isset((u_int8_t*)&val, i))
321 setbit(ic->ic_chan_avail, i + 1);
324 KASSERT(val != 0, ("wi_attach: no available channels listed!"));
325
326 val <<= 1; /* shift for base 1 indices */
327 for (i = 1; i < 16; i++) {
328 if (isset((u_int8_t*)&val, i)) {
329 ic->ic_channels[i].ic_freq =
330 ieee80211_ieee2mhz(i, IEEE80211_CHAN_B);
331 ic->ic_channels[i].ic_flags = IEEE80211_CHAN_B;
332 }
322 }
333 }
323 KASSERT(ic->ic_chan_avail != 0,
324 ("wi_attach: no available channels listed!"));
325
326 /*
327 * Read the default channel from the NIC. This may vary
328 * depending on the country where the NIC was purchased, so
329 * we can't hard-code a default and expect it to work for
330 * everyone.
334
335 /*
336 * Read the default channel from the NIC. This may vary
337 * depending on the country where the NIC was purchased, so
338 * we can't hard-code a default and expect it to work for
339 * everyone.
340 *
341 * If no channel is specified, let the 802.11 code select.
331 */
332 buflen = sizeof(val);
342 */
343 buflen = sizeof(val);
333 if (wi_read_rid(sc, WI_RID_OWN_CHNL, &val, &buflen) == 0)
334 ic->ic_ibss_chan = le16toh(val);
335 else {
336 /* use lowest available channel */
337 for (i = 0; i < 16 && !isset(ic->ic_chan_avail, i); i++)
338 ;
339 ic->ic_ibss_chan = i;
344 if (wi_read_rid(sc, WI_RID_OWN_CHNL, &val, &buflen) == 0) {
345 val = le16toh(val);
346 KASSERT(val < IEEE80211_CHAN_MAX &&
347 ic->ic_channels[val].ic_flags != 0,
348 ("wi_attach: invalid own channel %u!", val));
349 ic->ic_ibss_chan = &ic->ic_channels[val];
340 }
341
342 /*
343 * Set flags based on firmware version.
344 */
345 switch (sc->sc_firmware_type) {
346 case WI_LUCENT:
347 sc->sc_ntxbuf = 1;
348 sc->sc_flags |= WI_FLAGS_HAS_SYSSCALE;
349#ifdef WI_HERMES_AUTOINC_WAR
350 /* XXX: not confirmed, but never seen for recent firmware */
351 if (sc->sc_sta_firmware_ver < 40000) {
352 sc->sc_flags |= WI_FLAGS_BUG_AUTOINC;
353 }
354#endif
355 if (sc->sc_sta_firmware_ver >= 60000)
356 sc->sc_flags |= WI_FLAGS_HAS_MOR;
357 if (sc->sc_sta_firmware_ver >= 60006)
350 }
351
352 /*
353 * Set flags based on firmware version.
354 */
355 switch (sc->sc_firmware_type) {
356 case WI_LUCENT:
357 sc->sc_ntxbuf = 1;
358 sc->sc_flags |= WI_FLAGS_HAS_SYSSCALE;
359#ifdef WI_HERMES_AUTOINC_WAR
360 /* XXX: not confirmed, but never seen for recent firmware */
361 if (sc->sc_sta_firmware_ver < 40000) {
362 sc->sc_flags |= WI_FLAGS_BUG_AUTOINC;
363 }
364#endif
365 if (sc->sc_sta_firmware_ver >= 60000)
366 sc->sc_flags |= WI_FLAGS_HAS_MOR;
367 if (sc->sc_sta_firmware_ver >= 60006)
358 ic->ic_flags |= IEEE80211_F_HASIBSS;
368 ic->ic_caps |= IEEE80211_C_IBSS;
359 sc->sc_ibss_port = htole16(1);
360 break;
361
362 case WI_INTERSIL:
363 sc->sc_ntxbuf = WI_NTXBUF;
364 sc->sc_flags |= WI_FLAGS_HAS_FRAGTHR;
365 sc->sc_flags |= WI_FLAGS_HAS_ROAMING;
366 sc->sc_flags |= WI_FLAGS_HAS_SYSSCALE;
367 if (sc->sc_sta_firmware_ver > 10101)
368 sc->sc_flags |= WI_FLAGS_HAS_DBMADJUST;
369 if (sc->sc_sta_firmware_ver >= 800)
369 sc->sc_ibss_port = htole16(1);
370 break;
371
372 case WI_INTERSIL:
373 sc->sc_ntxbuf = WI_NTXBUF;
374 sc->sc_flags |= WI_FLAGS_HAS_FRAGTHR;
375 sc->sc_flags |= WI_FLAGS_HAS_ROAMING;
376 sc->sc_flags |= WI_FLAGS_HAS_SYSSCALE;
377 if (sc->sc_sta_firmware_ver > 10101)
378 sc->sc_flags |= WI_FLAGS_HAS_DBMADJUST;
379 if (sc->sc_sta_firmware_ver >= 800)
370 ic->ic_flags |= IEEE80211_F_HASIBSS;
380 ic->ic_caps |= IEEE80211_C_IBSS;
371 /*
372 * version 0.8.3 and newer are the only ones that are known
373 * to currently work. Earlier versions can be made to work,
374 * at least according to the Linux driver.
375 */
376 if (sc->sc_sta_firmware_ver >= 803)
381 /*
382 * version 0.8.3 and newer are the only ones that are known
383 * to currently work. Earlier versions can be made to work,
384 * at least according to the Linux driver.
385 */
386 if (sc->sc_sta_firmware_ver >= 803)
377 ic->ic_flags |= IEEE80211_F_HASHOSTAP;
387 ic->ic_caps |= IEEE80211_C_HOSTAP;
378 sc->sc_ibss_port = htole16(0);
379 break;
380
381 case WI_SYMBOL:
382 sc->sc_ntxbuf = 1;
383 sc->sc_flags |= WI_FLAGS_HAS_DIVERSITY;
384 if (sc->sc_sta_firmware_ver >= 25000)
388 sc->sc_ibss_port = htole16(0);
389 break;
390
391 case WI_SYMBOL:
392 sc->sc_ntxbuf = 1;
393 sc->sc_flags |= WI_FLAGS_HAS_DIVERSITY;
394 if (sc->sc_sta_firmware_ver >= 25000)
385 ic->ic_flags |= IEEE80211_F_HASIBSS;
395 ic->ic_caps |= IEEE80211_C_IBSS;
386 sc->sc_ibss_port = htole16(4);
387 break;
388 }
389
390 /*
391 * Find out if we support WEP on this card.
392 */
393 buflen = sizeof(val);
394 if (wi_read_rid(sc, WI_RID_WEP_AVAIL, &val, &buflen) == 0 &&
395 val != htole16(0))
396 sc->sc_ibss_port = htole16(4);
397 break;
398 }
399
400 /*
401 * Find out if we support WEP on this card.
402 */
403 buflen = sizeof(val);
404 if (wi_read_rid(sc, WI_RID_WEP_AVAIL, &val, &buflen) == 0 &&
405 val != htole16(0))
396 ic->ic_flags |= IEEE80211_F_HASWEP;
406 ic->ic_caps |= IEEE80211_C_WEP;
397
398 /* Find supported rates. */
399 buflen = sizeof(ratebuf);
407
408 /* Find supported rates. */
409 buflen = sizeof(ratebuf);
410 rs = &ic->ic_sup_rates[IEEE80211_MODE_11B];
400 if (wi_read_rid(sc, WI_RID_DATA_RATES, ratebuf, &buflen) == 0) {
411 if (wi_read_rid(sc, WI_RID_DATA_RATES, ratebuf, &buflen) == 0) {
401 nrate = le16toh(*(u_int16_t *)ratebuf);
402 if (nrate > IEEE80211_RATE_SIZE)
403 nrate = IEEE80211_RATE_SIZE;
404 memcpy(ic->ic_sup_rates, ratebuf + 2, nrate);
412 nrates = le16toh(*(u_int16_t *)ratebuf);
413 if (nrates > IEEE80211_RATE_MAXSIZE)
414 nrates = IEEE80211_RATE_MAXSIZE;
415 rs->rs_nrates = 0;
416 for (i = 0; i < nrates; i++)
417 if (ratebuf[2+i])
418 rs->rs_rates[rs->rs_nrates++] = ratebuf[2+i];
405 } else {
406 /* XXX fallback on error? */
419 } else {
420 /* XXX fallback on error? */
407 nrate = 0;
421 rs->rs_nrates = 0;
408 }
409
410 buflen = sizeof(val);
411 if ((sc->sc_flags & WI_FLAGS_HAS_DBMADJUST) &&
412 wi_read_rid(sc, WI_RID_DBM_ADJUST, &val, &buflen) == 0) {
413 sc->sc_dbm_adjust = le16toh(val);
414 } else
415 sc->sc_dbm_adjust = 100; /* default */
416
417 sc->sc_max_datalen = 2304;
422 }
423
424 buflen = sizeof(val);
425 if ((sc->sc_flags & WI_FLAGS_HAS_DBMADJUST) &&
426 wi_read_rid(sc, WI_RID_DBM_ADJUST, &val, &buflen) == 0) {
427 sc->sc_dbm_adjust = le16toh(val);
428 } else
429 sc->sc_dbm_adjust = 100; /* default */
430
431 sc->sc_max_datalen = 2304;
418 sc->sc_rts_thresh = 2347;
419 sc->sc_frag_thresh = 2346;
420 sc->sc_system_scale = 1;
421 sc->sc_cnfauthmode = IEEE80211_AUTH_OPEN;
422 sc->sc_roaming_mode = 1;
423
424 sc->sc_portnum = WI_DEFAULT_PORT;
425 sc->sc_authtype = WI_DEFAULT_AUTHTYPE;
426
427 bzero(sc->sc_nodename, sizeof(sc->sc_nodename));
428 sc->sc_nodelen = sizeof(WI_DEFAULT_NODENAME) - 1;
429 bcopy(WI_DEFAULT_NODENAME, sc->sc_nodename, sc->sc_nodelen);
430
431 bzero(sc->sc_net_name, sizeof(sc->sc_net_name));
432 bcopy(WI_DEFAULT_NETNAME, sc->sc_net_name,
433 sizeof(WI_DEFAULT_NETNAME) - 1);
434
432 sc->sc_system_scale = 1;
433 sc->sc_cnfauthmode = IEEE80211_AUTH_OPEN;
434 sc->sc_roaming_mode = 1;
435
436 sc->sc_portnum = WI_DEFAULT_PORT;
437 sc->sc_authtype = WI_DEFAULT_AUTHTYPE;
438
439 bzero(sc->sc_nodename, sizeof(sc->sc_nodename));
440 sc->sc_nodelen = sizeof(WI_DEFAULT_NODENAME) - 1;
441 bcopy(WI_DEFAULT_NODENAME, sc->sc_nodename, sc->sc_nodelen);
442
443 bzero(sc->sc_net_name, sizeof(sc->sc_net_name));
444 bcopy(WI_DEFAULT_NETNAME, sc->sc_net_name,
445 sizeof(WI_DEFAULT_NETNAME) - 1);
446
435 ifmedia_init(&sc->sc_media, 0, wi_media_change, wi_media_status);
436 if_printf(ifp, "supported rates: ");
437#define ADD(s, o) ifmedia_add(&sc->sc_media, \
438 IFM_MAKEWORD(IFM_IEEE80211, (s), (o), 0), 0, NULL)
439 ADD(IFM_AUTO, 0);
440 if (ic->ic_flags & IEEE80211_F_HASHOSTAP)
441 ADD(IFM_AUTO, IFM_IEEE80211_HOSTAP);
442 if (ic->ic_flags & IEEE80211_F_HASIBSS)
443 ADD(IFM_AUTO, IFM_IEEE80211_ADHOC);
444 ADD(IFM_AUTO, IFM_IEEE80211_ADHOC | IFM_FLAG0);
445 for (i = 0; i < nrate; i++) {
446 r = ic->ic_sup_rates[i];
447 mword = ieee80211_rate2media(r, IEEE80211_T_DS);
448 if (mword == 0)
449 continue;
450 printf("%s%d%sMbps", (i != 0 ? " " : ""),
451 (r & IEEE80211_RATE_VAL) / 2, ((r & 0x1) != 0 ? ".5" : ""));
452 ADD(mword, 0);
453 if (ic->ic_flags & IEEE80211_F_HASHOSTAP)
454 ADD(mword, IFM_IEEE80211_HOSTAP);
455 if (ic->ic_flags & IEEE80211_F_HASIBSS)
456 ADD(mword, IFM_IEEE80211_ADHOC);
457 ADD(mword, IFM_IEEE80211_ADHOC | IFM_FLAG0);
458 }
459 printf("\n");
460 ifmedia_set(&sc->sc_media, IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0));
461#undef ADD
462
463 /*
464 * Call MI attach routine.
465 */
466 ieee80211_ifattach(ifp);
447 /*
448 * Call MI attach routine.
449 */
450 ieee80211_ifattach(ifp);
451 ieee80211_media_init(ifp, wi_media_change, wi_media_status);
467
468 return (0);
469}
470
471int
472wi_detach(device_t dev)
473{
474 struct wi_softc *sc = device_get_softc(dev);
475 struct ifnet *ifp = &sc->sc_ic.ic_if;
476 WI_LOCK_DECL();
477
478 WI_LOCK(sc);
479
480 /* check if device was removed */
481 sc->wi_gone = !bus_child_present(dev);
482
483 wi_stop(ifp, 0);
484
452
453 return (0);
454}
455
456int
457wi_detach(device_t dev)
458{
459 struct wi_softc *sc = device_get_softc(dev);
460 struct ifnet *ifp = &sc->sc_ic.ic_if;
461 WI_LOCK_DECL();
462
463 WI_LOCK(sc);
464
465 /* check if device was removed */
466 sc->wi_gone = !bus_child_present(dev);
467
468 wi_stop(ifp, 0);
469
485 /* Delete all remaining media. */
486 ifmedia_removeall(&sc->sc_media);
487
488 ieee80211_ifdetach(ifp);
489 WI_UNLOCK(sc);
490 bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
491 wi_free(dev);
492#if __FreeBSD_version >= 500000
493 mtx_destroy(&sc->sc_mtx);
494#endif
495 return (0);

--- 144 unchanged lines hidden (view full) ---

640 if (sc->sc_firmware_type == WI_LUCENT &&
641 (ic->ic_flags & IEEE80211_F_IBSSON) && ic->ic_des_esslen > 0)
642 wi_write_val(sc, WI_RID_CREATE_IBSS, 1);
643 else
644 wi_write_val(sc, WI_RID_CREATE_IBSS, 0);
645 wi_write_val(sc, WI_RID_MAX_SLEEP, ic->ic_lintval);
646 wi_write_ssid(sc, WI_RID_DESIRED_SSID, ic->ic_des_essid,
647 ic->ic_des_esslen);
470 ieee80211_ifdetach(ifp);
471 WI_UNLOCK(sc);
472 bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
473 wi_free(dev);
474#if __FreeBSD_version >= 500000
475 mtx_destroy(&sc->sc_mtx);
476#endif
477 return (0);

--- 144 unchanged lines hidden (view full) ---

622 if (sc->sc_firmware_type == WI_LUCENT &&
623 (ic->ic_flags & IEEE80211_F_IBSSON) && ic->ic_des_esslen > 0)
624 wi_write_val(sc, WI_RID_CREATE_IBSS, 1);
625 else
626 wi_write_val(sc, WI_RID_CREATE_IBSS, 0);
627 wi_write_val(sc, WI_RID_MAX_SLEEP, ic->ic_lintval);
628 wi_write_ssid(sc, WI_RID_DESIRED_SSID, ic->ic_des_essid,
629 ic->ic_des_esslen);
648 wi_write_val(sc, WI_RID_OWN_CHNL, ic->ic_ibss_chan);
630 wi_write_val(sc, WI_RID_OWN_CHNL,
631 ieee80211_chan2ieee(ic, ic->ic_ibss_chan));
649 wi_write_ssid(sc, WI_RID_OWN_SSID, ic->ic_des_essid, ic->ic_des_esslen);
650
651 ifa = ifaddr_byindex(ifp->if_index);
652 sdl = (struct sockaddr_dl *) ifa->ifa_addr;
653 IEEE80211_ADDR_COPY(ic->ic_myaddr, LLADDR(sdl));
654 wi_write_rid(sc, WI_RID_MAC_NODE, ic->ic_myaddr, IEEE80211_ADDR_LEN);
655
656 wi_write_val(sc, WI_RID_PM_ENABLED,
657 (ic->ic_flags & IEEE80211_F_PMGTON) ? 1 : 0);
658
659 /* not yet common 802.11 configuration */
660 wi_write_val(sc, WI_RID_MAX_DATALEN, sc->sc_max_datalen);
632 wi_write_ssid(sc, WI_RID_OWN_SSID, ic->ic_des_essid, ic->ic_des_esslen);
633
634 ifa = ifaddr_byindex(ifp->if_index);
635 sdl = (struct sockaddr_dl *) ifa->ifa_addr;
636 IEEE80211_ADDR_COPY(ic->ic_myaddr, LLADDR(sdl));
637 wi_write_rid(sc, WI_RID_MAC_NODE, ic->ic_myaddr, IEEE80211_ADDR_LEN);
638
639 wi_write_val(sc, WI_RID_PM_ENABLED,
640 (ic->ic_flags & IEEE80211_F_PMGTON) ? 1 : 0);
641
642 /* not yet common 802.11 configuration */
643 wi_write_val(sc, WI_RID_MAX_DATALEN, sc->sc_max_datalen);
661 wi_write_val(sc, WI_RID_RTS_THRESH, sc->sc_rts_thresh);
644 wi_write_val(sc, WI_RID_RTS_THRESH, ic->ic_rtsthreshold);
662 if (sc->sc_flags & WI_FLAGS_HAS_FRAGTHR)
645 if (sc->sc_flags & WI_FLAGS_HAS_FRAGTHR)
663 wi_write_val(sc, WI_RID_FRAG_THRESH, sc->sc_frag_thresh);
646 wi_write_val(sc, WI_RID_FRAG_THRESH, ic->ic_fragthreshold);
664
665 /* driver specific 802.11 configuration */
666 if (sc->sc_flags & WI_FLAGS_HAS_SYSSCALE)
667 wi_write_val(sc, WI_RID_SYSTEM_SCALE, sc->sc_system_scale);
668 if (sc->sc_flags & WI_FLAGS_HAS_ROAMING)
669 wi_write_val(sc, WI_RID_ROAMING_MODE, sc->sc_roaming_mode);
670 if (sc->sc_flags & WI_FLAGS_HAS_MOR)
671 wi_write_val(sc, WI_RID_MICROWAVE_OVEN, sc->sc_microwave_oven);

--- 19 unchanged lines hidden (view full) ---

691 if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
692 (ifp->if_flags & IFF_PROMISC) != 0) {
693 wi_write_val(sc, WI_RID_PROMISC, 1);
694 } else {
695 wi_write_val(sc, WI_RID_PROMISC, 0);
696 }
697
698 /* Configure WEP. */
647
648 /* driver specific 802.11 configuration */
649 if (sc->sc_flags & WI_FLAGS_HAS_SYSSCALE)
650 wi_write_val(sc, WI_RID_SYSTEM_SCALE, sc->sc_system_scale);
651 if (sc->sc_flags & WI_FLAGS_HAS_ROAMING)
652 wi_write_val(sc, WI_RID_ROAMING_MODE, sc->sc_roaming_mode);
653 if (sc->sc_flags & WI_FLAGS_HAS_MOR)
654 wi_write_val(sc, WI_RID_MICROWAVE_OVEN, sc->sc_microwave_oven);

--- 19 unchanged lines hidden (view full) ---

674 if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
675 (ifp->if_flags & IFF_PROMISC) != 0) {
676 wi_write_val(sc, WI_RID_PROMISC, 1);
677 } else {
678 wi_write_val(sc, WI_RID_PROMISC, 0);
679 }
680
681 /* Configure WEP. */
699 if (ic->ic_flags & IEEE80211_F_HASWEP)
682 if (ic->ic_caps & IEEE80211_C_WEP)
700 wi_write_wep(sc);
701
702 /* Set multicast filter. */
703 wi_write_multi(sc);
704
705 /* Allocate fids for the card */
706 if (sc->sc_firmware_type != WI_SYMBOL || !wasenabled) {
707 sc->sc_buflen = IEEE80211_MAX_LEN + sizeof(struct wi_frame);

--- 31 unchanged lines hidden (view full) ---

739 sc->sc_firmware_type == WI_INTERSIL) {
740 /* XXX: some card need to be re-enabled for hostap */
741 wi_cmd(sc, WI_CMD_DISABLE | WI_PORT0, 0, 0, 0);
742 wi_cmd(sc, WI_CMD_ENABLE | WI_PORT0, 0, 0, 0);
743 }
744
745 if (ic->ic_opmode == IEEE80211_M_STA &&
746 ((ic->ic_flags & IEEE80211_F_DESBSSID) ||
683 wi_write_wep(sc);
684
685 /* Set multicast filter. */
686 wi_write_multi(sc);
687
688 /* Allocate fids for the card */
689 if (sc->sc_firmware_type != WI_SYMBOL || !wasenabled) {
690 sc->sc_buflen = IEEE80211_MAX_LEN + sizeof(struct wi_frame);

--- 31 unchanged lines hidden (view full) ---

722 sc->sc_firmware_type == WI_INTERSIL) {
723 /* XXX: some card need to be re-enabled for hostap */
724 wi_cmd(sc, WI_CMD_DISABLE | WI_PORT0, 0, 0, 0);
725 wi_cmd(sc, WI_CMD_ENABLE | WI_PORT0, 0, 0, 0);
726 }
727
728 if (ic->ic_opmode == IEEE80211_M_STA &&
729 ((ic->ic_flags & IEEE80211_F_DESBSSID) ||
747 ic->ic_des_chan != IEEE80211_CHAN_ANY)) {
730 ic->ic_des_chan != IEEE80211_CHAN_ANYC)) {
748 memset(&join, 0, sizeof(join));
749 if (ic->ic_flags & IEEE80211_F_DESBSSID)
750 IEEE80211_ADDR_COPY(&join.wi_bssid, ic->ic_des_bssid);
731 memset(&join, 0, sizeof(join));
732 if (ic->ic_flags & IEEE80211_F_DESBSSID)
733 IEEE80211_ADDR_COPY(&join.wi_bssid, ic->ic_des_bssid);
751 if (ic->ic_des_chan != IEEE80211_CHAN_ANY)
752 join.wi_chan = htole16(ic->ic_des_chan);
734 if (ic->ic_des_chan != IEEE80211_CHAN_ANYC)
735 join.wi_chan = htole16(
736 ieee80211_chan2ieee(ic, ic->ic_des_chan));
753 /* Lucent firmware does not support the JOIN RID. */
754 if (sc->sc_firmware_type != WI_LUCENT)
755 wi_write_rid(sc, WI_RID_JOIN_REQ, &join, sizeof(join));
756 }
757
758 WI_UNLOCK(sc);
759 return;
760out:

--- 18 unchanged lines hidden (view full) ---

779 if (sc->sc_enabled && !sc->wi_gone) {
780 CSR_WRITE_2(sc, WI_INT_EN, 0);
781 wi_cmd(sc, WI_CMD_DISABLE | sc->sc_portnum, 0, 0, 0);
782 if (disable) {
783#ifdef __NetBSD__
784 if (sc->sc_disable)
785 (*sc->sc_disable)(sc);
786#endif
737 /* Lucent firmware does not support the JOIN RID. */
738 if (sc->sc_firmware_type != WI_LUCENT)
739 wi_write_rid(sc, WI_RID_JOIN_REQ, &join, sizeof(join));
740 }
741
742 WI_UNLOCK(sc);
743 return;
744out:

--- 18 unchanged lines hidden (view full) ---

763 if (sc->sc_enabled && !sc->wi_gone) {
764 CSR_WRITE_2(sc, WI_INT_EN, 0);
765 wi_cmd(sc, WI_CMD_DISABLE | sc->sc_portnum, 0, 0, 0);
766 if (disable) {
767#ifdef __NetBSD__
768 if (sc->sc_disable)
769 (*sc->sc_disable)(sc);
770#endif
771 sc->sc_enabled = 0;
787 }
772 }
788 sc->sc_enabled = 0;
789 }
790
791 sc->sc_tx_timer = 0;
792 sc->sc_scan_timer = 0;
793 sc->sc_syn_timer = 0;
794 sc->sc_false_syns = 0;
795 sc->sc_naps = 0;
796 ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
797 ifp->if_timer = 0;
798
799 WI_UNLOCK(sc);
800}
801
802static void
803wi_start(struct ifnet *ifp)
804{
805 struct wi_softc *sc = ifp->if_softc;
806 struct ieee80211com *ic = &sc->sc_ic;
773 }
774
775 sc->sc_tx_timer = 0;
776 sc->sc_scan_timer = 0;
777 sc->sc_syn_timer = 0;
778 sc->sc_false_syns = 0;
779 sc->sc_naps = 0;
780 ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
781 ifp->if_timer = 0;
782
783 WI_UNLOCK(sc);
784}
785
786static void
787wi_start(struct ifnet *ifp)
788{
789 struct wi_softc *sc = ifp->if_softc;
790 struct ieee80211com *ic = &sc->sc_ic;
807 struct ieee80211_node *ni = NULL;
808 struct ieee80211_frame *wh;
809 struct mbuf *m0;
810 struct wi_frame frmhdr;
811 int cur, fid, off;
812 WI_LOCK_DECL();
813
814 WI_LOCK(sc);
815

--- 41 unchanged lines hidden (view full) ---

857 if ((m0 = ieee80211_encap(ifp, m0)) == NULL) {
858 ifp->if_oerrors++;
859 continue;
860 }
861 wh = mtod(m0, struct ieee80211_frame *);
862 if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
863 !IEEE80211_IS_MULTICAST(wh->i_addr1) &&
864 (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
791 struct ieee80211_frame *wh;
792 struct mbuf *m0;
793 struct wi_frame frmhdr;
794 int cur, fid, off;
795 WI_LOCK_DECL();
796
797 WI_LOCK(sc);
798

--- 41 unchanged lines hidden (view full) ---

840 if ((m0 = ieee80211_encap(ifp, m0)) == NULL) {
841 ifp->if_oerrors++;
842 continue;
843 }
844 wh = mtod(m0, struct ieee80211_frame *);
845 if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
846 !IEEE80211_IS_MULTICAST(wh->i_addr1) &&
847 (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
865 IEEE80211_FC0_TYPE_DATA &&
866 ((ni = ieee80211_find_node(ic, wh->i_addr1)) ==
867 NULL || ni->ni_associd == 0)) {
868 m_freem(m0);
869 ifp->if_oerrors++;
870 continue;
848 IEEE80211_FC0_TYPE_DATA) {
849 struct ieee80211_node *ni =
850 ieee80211_find_node(ic, wh->i_addr1);
851 int err = (ni == NULL || ni->ni_associd == 0);
852 if (ni != NULL)
853 ieee80211_unref_node(&ni);
854 if (err) {
855 m_freem(m0);
856 ifp->if_oerrors++;
857 continue;
858 }
871 }
872 if (ic->ic_flags & IEEE80211_F_WEPON)
873 wh->i_fc[1] |= IEEE80211_FC1_WEP;
874
875 }
876#if NBPFILTER > 0
877 if (ic->ic_rawbpf)
878 bpf_mtap(ic->ic_rawbpf, m0);

--- 23 unchanged lines hidden (view full) ---

902 mb->m_len = sizeof(frmhdr);
903 mb->m_pkthdr.len += mb->m_len;
904 bpf_mtap(sc->sc_drvbpf, mb);
905 m_free(mb);
906 }
907 }
908#endif
909 if (IFF_DUMPPKTS(ifp))
859 }
860 if (ic->ic_flags & IEEE80211_F_WEPON)
861 wh->i_fc[1] |= IEEE80211_FC1_WEP;
862
863 }
864#if NBPFILTER > 0
865 if (ic->ic_rawbpf)
866 bpf_mtap(ic->ic_rawbpf, m0);

--- 23 unchanged lines hidden (view full) ---

890 mb->m_len = sizeof(frmhdr);
891 mb->m_pkthdr.len += mb->m_len;
892 bpf_mtap(sc->sc_drvbpf, mb);
893 m_free(mb);
894 }
895 }
896#endif
897 if (IFF_DUMPPKTS(ifp))
910 wi_dump_pkt(&frmhdr, ni, -1);
898 wi_dump_pkt(&frmhdr, NULL, -1);
911 fid = sc->sc_txd[cur].d_fid;
912 off = sizeof(frmhdr);
913 if (wi_write_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr)) != 0 ||
914 wi_mwrite_bap(sc, fid, off, m0, m0->m_pkthdr.len) != 0) {
915 ifp->if_oerrors++;
916 m_freem(m0);
917 continue;
918 }

--- 147 unchanged lines hidden (view full) ---

1066 } else {
1067 if (ifp->if_flags & IFF_RUNNING) {
1068 wi_stop(ifp, 0);
1069 }
1070 }
1071 sc->sc_if_flags = ifp->if_flags;
1072 error = 0;
1073 break;
899 fid = sc->sc_txd[cur].d_fid;
900 off = sizeof(frmhdr);
901 if (wi_write_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr)) != 0 ||
902 wi_mwrite_bap(sc, fid, off, m0, m0->m_pkthdr.len) != 0) {
903 ifp->if_oerrors++;
904 m_freem(m0);
905 continue;
906 }

--- 147 unchanged lines hidden (view full) ---

1054 } else {
1055 if (ifp->if_flags & IFF_RUNNING) {
1056 wi_stop(ifp, 0);
1057 }
1058 }
1059 sc->sc_if_flags = ifp->if_flags;
1060 error = 0;
1061 break;
1074 case SIOCSIFMEDIA:
1075 case SIOCGIFMEDIA:
1076 error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
1077 break;
1078 case SIOCADDMULTI:
1079 case SIOCDELMULTI:
1080 error = wi_write_multi(sc);
1081 break;
1082 case SIOCGIFGENERIC:
1083 error = wi_get_cfg(ifp, cmd, data);
1084 break;
1085 case SIOCSIFGENERIC:

--- 67 unchanged lines hidden (view full) ---

1153 }
1154 break;
1155 default:
1156 error = ieee80211_ioctl(ifp, cmd, data);
1157 break;
1158 }
1159 if (error == ENETRESET) {
1160 if (sc->sc_enabled)
1062 case SIOCADDMULTI:
1063 case SIOCDELMULTI:
1064 error = wi_write_multi(sc);
1065 break;
1066 case SIOCGIFGENERIC:
1067 error = wi_get_cfg(ifp, cmd, data);
1068 break;
1069 case SIOCSIFGENERIC:

--- 67 unchanged lines hidden (view full) ---

1137 }
1138 break;
1139 default:
1140 error = ieee80211_ioctl(ifp, cmd, data);
1141 break;
1142 }
1143 if (error == ENETRESET) {
1144 if (sc->sc_enabled)
1161 wi_init(ifp->if_softc); /* XXX no error return */
1145 wi_init(sc); /* XXX no error return */
1162 error = 0;
1163 }
1164out:
1165 WI_UNLOCK(sc);
1166
1167 return (error);
1168}
1169
1170static int
1171wi_media_change(struct ifnet *ifp)
1172{
1173 struct wi_softc *sc = ifp->if_softc;
1146 error = 0;
1147 }
1148out:
1149 WI_UNLOCK(sc);
1150
1151 return (error);
1152}
1153
1154static int
1155wi_media_change(struct ifnet *ifp)
1156{
1157 struct wi_softc *sc = ifp->if_softc;
1174 struct ieee80211com *ic = &sc->sc_ic;
1175 struct ifmedia_entry *ime;
1176 enum ieee80211_opmode newmode;
1177 int i, rate, error = 0;
1158 int error;
1178
1159
1179 ime = sc->sc_media.ifm_cur;
1180 if (IFM_SUBTYPE(ime->ifm_media) == IFM_AUTO) {
1181 i = -1;
1182 } else {
1183 rate = ieee80211_media2rate(ime->ifm_media, IEEE80211_T_DS);
1184 if (rate == 0)
1185 return EINVAL;
1186 for (i = 0; i < IEEE80211_RATE_SIZE; i++) {
1187 if ((ic->ic_sup_rates[i] & IEEE80211_RATE_VAL) == rate)
1188 break;
1189 }
1190 if (i == IEEE80211_RATE_SIZE)
1191 return EINVAL;
1192 }
1193 if (ic->ic_fixed_rate != i) {
1194 ic->ic_fixed_rate = i;
1195 error = ENETRESET;
1196 }
1197
1198 if ((ime->ifm_media & IFM_IEEE80211_ADHOC) &&
1199 (ime->ifm_media & IFM_FLAG0))
1200 newmode = IEEE80211_M_AHDEMO;
1201 else if (ime->ifm_media & IFM_IEEE80211_ADHOC)
1202 newmode = IEEE80211_M_IBSS;
1203 else if (ime->ifm_media & IFM_IEEE80211_HOSTAP)
1204 newmode = IEEE80211_M_HOSTAP;
1205 else
1206 newmode = IEEE80211_M_STA;
1207 if (ic->ic_opmode != newmode) {
1208 ic->ic_opmode = newmode;
1209 error = ENETRESET;
1210 }
1160 error = ieee80211_media_change(ifp);
1211 if (error == ENETRESET) {
1212 if (sc->sc_enabled)
1161 if (error == ENETRESET) {
1162 if (sc->sc_enabled)
1213 wi_init(ifp->if_softc); /* XXX error code lost */
1163 wi_init(sc); /* XXX no error return */
1214 error = 0;
1215 }
1164 error = 0;
1165 }
1216#if 0
1217 ifp->if_baudrate = ifmedia_baudrate(sc->sc_media.ifm_cur->ifm_media);
1218#endif
1219 return error;
1220}
1221
1222static void
1223wi_media_status(struct ifnet *ifp, struct ifmediareq *imr)
1224{
1225 struct wi_softc *sc = ifp->if_softc;
1226 struct ieee80211com *ic = &sc->sc_ic;

--- 24 unchanged lines hidden (view full) ---

1251 rate = 22; /* 11Mbps */
1252 } else {
1253 if (rate == 4*2)
1254 rate = 11; /* 5.5Mbps */
1255 else if (rate == 8*2)
1256 rate = 22; /* 11Mbps */
1257 }
1258 }
1166 return error;
1167}
1168
1169static void
1170wi_media_status(struct ifnet *ifp, struct ifmediareq *imr)
1171{
1172 struct wi_softc *sc = ifp->if_softc;
1173 struct ieee80211com *ic = &sc->sc_ic;

--- 24 unchanged lines hidden (view full) ---

1198 rate = 22; /* 11Mbps */
1199 } else {
1200 if (rate == 4*2)
1201 rate = 11; /* 5.5Mbps */
1202 else if (rate == 8*2)
1203 rate = 22; /* 11Mbps */
1204 }
1205 }
1259 imr->ifm_active |= ieee80211_rate2media(rate, IEEE80211_T_DS);
1206 imr->ifm_active |= ieee80211_rate2media(ic, rate, IEEE80211_MODE_11B);
1260 switch (ic->ic_opmode) {
1261 case IEEE80211_M_STA:
1262 break;
1263 case IEEE80211_M_IBSS:
1264 imr->ifm_active |= IFM_IEEE80211_ADHOC;
1265 break;
1266 case IEEE80211_M_AHDEMO:
1267 imr->ifm_active |= IFM_IEEE80211_ADHOC | IFM_FLAG0;
1268 break;
1269 case IEEE80211_M_HOSTAP:
1270 imr->ifm_active |= IFM_IEEE80211_HOSTAP;
1271 break;
1272 }
1273}
1274
1275static void
1276wi_sync_bssid(struct wi_softc *sc, u_int8_t new_bssid[IEEE80211_ADDR_LEN])
1277{
1278 struct ieee80211com *ic = &sc->sc_ic;
1207 switch (ic->ic_opmode) {
1208 case IEEE80211_M_STA:
1209 break;
1210 case IEEE80211_M_IBSS:
1211 imr->ifm_active |= IFM_IEEE80211_ADHOC;
1212 break;
1213 case IEEE80211_M_AHDEMO:
1214 imr->ifm_active |= IFM_IEEE80211_ADHOC | IFM_FLAG0;
1215 break;
1216 case IEEE80211_M_HOSTAP:
1217 imr->ifm_active |= IFM_IEEE80211_HOSTAP;
1218 break;
1219 }
1220}
1221
1222static void
1223wi_sync_bssid(struct wi_softc *sc, u_int8_t new_bssid[IEEE80211_ADDR_LEN])
1224{
1225 struct ieee80211com *ic = &sc->sc_ic;
1279 struct ieee80211_node *ni = &ic->ic_bss;
1226 struct ieee80211_node *ni = ic->ic_bss;
1280 struct ifnet *ifp = &ic->ic_if;
1281
1282 if (IEEE80211_ADDR_EQ(new_bssid, ni->ni_bssid))
1283 return;
1284
1285 DPRINTF(("wi_sync_bssid: bssid %s -> ", ether_sprintf(ni->ni_bssid)));
1286 DPRINTF(("%s ?\n", ether_sprintf(new_bssid)));
1287

--- 196 unchanged lines hidden (view full) ---

1484 wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
1485 }
1486
1487 /* synchronize driver's BSSID with firmware's BSSID */
1488 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK;
1489 if (ic->ic_opmode == IEEE80211_M_IBSS && dir == IEEE80211_FC1_DIR_NODS)
1490 wi_sync_bssid(sc, wh->i_addr3);
1491
1227 struct ifnet *ifp = &ic->ic_if;
1228
1229 if (IEEE80211_ADDR_EQ(new_bssid, ni->ni_bssid))
1230 return;
1231
1232 DPRINTF(("wi_sync_bssid: bssid %s -> ", ether_sprintf(ni->ni_bssid)));
1233 DPRINTF(("%s ?\n", ether_sprintf(new_bssid)));
1234

--- 196 unchanged lines hidden (view full) ---

1431 wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
1432 }
1433
1434 /* synchronize driver's BSSID with firmware's BSSID */
1435 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK;
1436 if (ic->ic_opmode == IEEE80211_M_IBSS && dir == IEEE80211_FC1_DIR_NODS)
1437 wi_sync_bssid(sc, wh->i_addr3);
1438
1492 ieee80211_input(ifp, m, rssi, rstamp);
1439 ieee80211_input(ifp, m, rssi, rstamp, 0);
1493}
1494
1495static void
1496wi_tx_ex_intr(struct wi_softc *sc)
1497{
1498 struct ieee80211com *ic = &sc->sc_ic;
1499 struct ifnet *ifp = &ic->ic_if;
1500 struct wi_frame frmhdr;

--- 350 unchanged lines hidden (view full) ---

1851 break;
1852
1853 case WI_RID_FRAG_THRESH:
1854 if (sc->sc_enabled && (sc->sc_flags & WI_FLAGS_HAS_FRAGTHR)) {
1855 error = wi_read_rid(sc, wreq.wi_type, wreq.wi_val,
1856 &len);
1857 break;
1858 }
1440}
1441
1442static void
1443wi_tx_ex_intr(struct wi_softc *sc)
1444{
1445 struct ieee80211com *ic = &sc->sc_ic;
1446 struct ifnet *ifp = &ic->ic_if;
1447 struct wi_frame frmhdr;

--- 350 unchanged lines hidden (view full) ---

1798 break;
1799
1800 case WI_RID_FRAG_THRESH:
1801 if (sc->sc_enabled && (sc->sc_flags & WI_FLAGS_HAS_FRAGTHR)) {
1802 error = wi_read_rid(sc, wreq.wi_type, wreq.wi_val,
1803 &len);
1804 break;
1805 }
1859 wreq.wi_val[0] = htole16(sc->sc_frag_thresh);
1806 wreq.wi_val[0] = htole16(ic->ic_fragthreshold);
1860 len = sizeof(u_int16_t);
1861 break;
1862
1863 case WI_RID_READ_APS:
1864 if (ic->ic_opmode == IEEE80211_M_HOSTAP)
1865 return ieee80211_cfgget(ifp, cmd, data);
1866 if (sc->sc_scan_timer > 0) {
1867 error = EINPROGRESS;

--- 91 unchanged lines hidden (view full) ---

1959 break;
1960 }
1961 switch (wreq.wi_type) {
1962 case WI_RID_MAX_DATALEN:
1963 wreq.wi_val[0] = htole16(sc->sc_max_datalen);
1964 len = sizeof(u_int16_t);
1965 break;
1966 case WI_RID_RTS_THRESH:
1807 len = sizeof(u_int16_t);
1808 break;
1809
1810 case WI_RID_READ_APS:
1811 if (ic->ic_opmode == IEEE80211_M_HOSTAP)
1812 return ieee80211_cfgget(ifp, cmd, data);
1813 if (sc->sc_scan_timer > 0) {
1814 error = EINPROGRESS;

--- 91 unchanged lines hidden (view full) ---

1906 break;
1907 }
1908 switch (wreq.wi_type) {
1909 case WI_RID_MAX_DATALEN:
1910 wreq.wi_val[0] = htole16(sc->sc_max_datalen);
1911 len = sizeof(u_int16_t);
1912 break;
1913 case WI_RID_RTS_THRESH:
1967 wreq.wi_val[0] = htole16(sc->sc_rts_thresh);
1914 wreq.wi_val[0] = htole16(ic->ic_rtsthreshold);
1968 len = sizeof(u_int16_t);
1969 break;
1970 case WI_RID_CNFAUTHMODE:
1971 wreq.wi_val[0] = htole16(sc->sc_cnfauthmode);
1972 len = sizeof(u_int16_t);
1973 break;
1974 case WI_RID_NODENAME:
1975 if (len < sc->sc_nodelen + sizeof(u_int16_t)) {

--- 20 unchanged lines hidden (view full) ---

1996wi_set_cfg(struct ifnet *ifp, u_long cmd, caddr_t data)
1997{
1998 struct wi_softc *sc = ifp->if_softc;
1999 struct ieee80211com *ic = &sc->sc_ic;
2000 struct ifreq *ifr = (struct ifreq *)data;
2001 struct wi_req wreq;
2002 struct mbuf *m;
2003 int i, len, error, mif, val;
1915 len = sizeof(u_int16_t);
1916 break;
1917 case WI_RID_CNFAUTHMODE:
1918 wreq.wi_val[0] = htole16(sc->sc_cnfauthmode);
1919 len = sizeof(u_int16_t);
1920 break;
1921 case WI_RID_NODENAME:
1922 if (len < sc->sc_nodelen + sizeof(u_int16_t)) {

--- 20 unchanged lines hidden (view full) ---

1943wi_set_cfg(struct ifnet *ifp, u_long cmd, caddr_t data)
1944{
1945 struct wi_softc *sc = ifp->if_softc;
1946 struct ieee80211com *ic = &sc->sc_ic;
1947 struct ifreq *ifr = (struct ifreq *)data;
1948 struct wi_req wreq;
1949 struct mbuf *m;
1950 int i, len, error, mif, val;
1951 struct ieee80211_rateset *rs;
2004
2005 error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
2006 if (error)
2007 return error;
2008 len = wreq.wi_len ? (wreq.wi_len - 1) * 2 : 0;
2009 switch (wreq.wi_type) {
2010 case WI_RID_DBM_ADJUST:
2011 return ENODEV;

--- 37 unchanged lines hidden (view full) ---

2049 if (sc->sc_enabled) {
2050 error = wi_write_rid(sc, wreq.wi_type, wreq.wi_val,
2051 sizeof(u_int16_t));
2052 if (error)
2053 break;
2054 }
2055 switch (wreq.wi_type) {
2056 case WI_RID_FRAG_THRESH:
1952
1953 error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
1954 if (error)
1955 return error;
1956 len = wreq.wi_len ? (wreq.wi_len - 1) * 2 : 0;
1957 switch (wreq.wi_type) {
1958 case WI_RID_DBM_ADJUST:
1959 return ENODEV;

--- 37 unchanged lines hidden (view full) ---

1997 if (sc->sc_enabled) {
1998 error = wi_write_rid(sc, wreq.wi_type, wreq.wi_val,
1999 sizeof(u_int16_t));
2000 if (error)
2001 break;
2002 }
2003 switch (wreq.wi_type) {
2004 case WI_RID_FRAG_THRESH:
2057 sc->sc_frag_thresh = le16toh(wreq.wi_val[0]);
2005 ic->ic_fragthreshold = le16toh(wreq.wi_val[0]);
2058 break;
2059 case WI_RID_RTS_THRESH:
2006 break;
2007 case WI_RID_RTS_THRESH:
2060 sc->sc_rts_thresh = le16toh(wreq.wi_val[0]);
2008 ic->ic_rtsthreshold = le16toh(wreq.wi_val[0]);
2061 break;
2062 case WI_RID_MICROWAVE_OVEN:
2063 sc->sc_microwave_oven = le16toh(wreq.wi_val[0]);
2064 break;
2065 case WI_RID_ROAMING_MODE:
2066 sc->sc_roaming_mode = le16toh(wreq.wi_val[0]);
2067 break;
2068 case WI_RID_SYSTEM_SCALE:

--- 9 unchanged lines hidden (view full) ---

2078 break;
2079
2080 case WI_RID_TX_RATE:
2081 switch (le16toh(wreq.wi_val[0])) {
2082 case 3:
2083 ic->ic_fixed_rate = -1;
2084 break;
2085 default:
2009 break;
2010 case WI_RID_MICROWAVE_OVEN:
2011 sc->sc_microwave_oven = le16toh(wreq.wi_val[0]);
2012 break;
2013 case WI_RID_ROAMING_MODE:
2014 sc->sc_roaming_mode = le16toh(wreq.wi_val[0]);
2015 break;
2016 case WI_RID_SYSTEM_SCALE:

--- 9 unchanged lines hidden (view full) ---

2026 break;
2027
2028 case WI_RID_TX_RATE:
2029 switch (le16toh(wreq.wi_val[0])) {
2030 case 3:
2031 ic->ic_fixed_rate = -1;
2032 break;
2033 default:
2086 for (i = 0; i < IEEE80211_RATE_SIZE; i++) {
2087 if ((ic->ic_sup_rates[i] & IEEE80211_RATE_VAL)
2034 rs = &ic->ic_sup_rates[IEEE80211_MODE_11B];
2035 for (i = 0; i < rs->rs_nrates; i++) {
2036 if ((rs->rs_rates[i] & IEEE80211_RATE_VAL)
2088 / 2 == le16toh(wreq.wi_val[0]))
2089 break;
2090 }
2037 / 2 == le16toh(wreq.wi_val[0]))
2038 break;
2039 }
2091 if (i == IEEE80211_RATE_SIZE)
2040 if (i == rs->rs_nrates)
2092 return EINVAL;
2093 ic->ic_fixed_rate = i;
2094 }
2095 if (sc->sc_enabled)
2096 error = wi_write_txrate(sc);
2097 break;
2098
2099 case WI_RID_SCAN_APS:

--- 63 unchanged lines hidden (view full) ---

2163{
2164 struct ieee80211com *ic = &sc->sc_ic;
2165 int i;
2166 u_int16_t rate;
2167
2168 if (ic->ic_fixed_rate < 0)
2169 rate = 0; /* auto */
2170 else
2041 return EINVAL;
2042 ic->ic_fixed_rate = i;
2043 }
2044 if (sc->sc_enabled)
2045 error = wi_write_txrate(sc);
2046 break;
2047
2048 case WI_RID_SCAN_APS:

--- 63 unchanged lines hidden (view full) ---

2112{
2113 struct ieee80211com *ic = &sc->sc_ic;
2114 int i;
2115 u_int16_t rate;
2116
2117 if (ic->ic_fixed_rate < 0)
2118 rate = 0; /* auto */
2119 else
2171 rate = (ic->ic_sup_rates[ic->ic_fixed_rate] &
2120 rate = (ic->ic_sup_rates[IEEE80211_MODE_11B].rs_rates[ic->ic_fixed_rate] &
2172 IEEE80211_RATE_VAL) / 2;
2173
2174 /* rate: 0, 1, 2, 5, 11 */
2175
2176 switch (sc->sc_firmware_type) {
2177 case WI_LUCENT:
2178 switch (rate) {
2179 case 0: /* auto == 11mbps auto */

--- 385 unchanged lines hidden (view full) ---

2565 return wi_cmd(sc, WI_CMD_ACCESS | WI_ACCESS_WRITE, rid, 0, 0);
2566}
2567
2568static int
2569wi_newstate(void *arg, enum ieee80211_state nstate)
2570{
2571 struct wi_softc *sc = arg;
2572 struct ieee80211com *ic = &sc->sc_ic;
2121 IEEE80211_RATE_VAL) / 2;
2122
2123 /* rate: 0, 1, 2, 5, 11 */
2124
2125 switch (sc->sc_firmware_type) {
2126 case WI_LUCENT:
2127 switch (rate) {
2128 case 0: /* auto == 11mbps auto */

--- 385 unchanged lines hidden (view full) ---

2514 return wi_cmd(sc, WI_CMD_ACCESS | WI_ACCESS_WRITE, rid, 0, 0);
2515}
2516
2517static int
2518wi_newstate(void *arg, enum ieee80211_state nstate)
2519{
2520 struct wi_softc *sc = arg;
2521 struct ieee80211com *ic = &sc->sc_ic;
2573 struct ieee80211_node *ni = &ic->ic_bss;
2574 int i, buflen;
2522 struct ieee80211_node *ni = ic->ic_bss;
2523 int buflen;
2575 u_int16_t val;
2576 struct wi_ssid ssid;
2577 u_int8_t old_bssid[IEEE80211_ADDR_LEN];
2578 enum ieee80211_state ostate;
2579#ifdef WI_DEBUG
2580 static const char *stname[] =
2581 { "INIT", "SCAN", "AUTH", "ASSOC", "RUN" };
2582#endif /* WI_DEBUG */

--- 10 unchanged lines hidden (view full) ---

2593
2594 case IEEE80211_S_RUN:
2595 sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
2596 buflen = IEEE80211_ADDR_LEN;
2597 wi_read_rid(sc, WI_RID_CURRENT_BSSID, ni->ni_bssid, &buflen);
2598 IEEE80211_ADDR_COPY(ni->ni_macaddr, ni->ni_bssid);
2599 buflen = sizeof(val);
2600 wi_read_rid(sc, WI_RID_CURRENT_CHAN, &val, &buflen);
2524 u_int16_t val;
2525 struct wi_ssid ssid;
2526 u_int8_t old_bssid[IEEE80211_ADDR_LEN];
2527 enum ieee80211_state ostate;
2528#ifdef WI_DEBUG
2529 static const char *stname[] =
2530 { "INIT", "SCAN", "AUTH", "ASSOC", "RUN" };
2531#endif /* WI_DEBUG */

--- 10 unchanged lines hidden (view full) ---

2542
2543 case IEEE80211_S_RUN:
2544 sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
2545 buflen = IEEE80211_ADDR_LEN;
2546 wi_read_rid(sc, WI_RID_CURRENT_BSSID, ni->ni_bssid, &buflen);
2547 IEEE80211_ADDR_COPY(ni->ni_macaddr, ni->ni_bssid);
2548 buflen = sizeof(val);
2549 wi_read_rid(sc, WI_RID_CURRENT_CHAN, &val, &buflen);
2601 ni->ni_chan = le16toh(val);
2550 /* XXX validate channel */
2551 ni->ni_chan = &ic->ic_channels[le16toh(val)];
2602
2603 if (IEEE80211_ADDR_EQ(old_bssid, ni->ni_bssid))
2604 sc->sc_false_syns++;
2605 else
2606 sc->sc_false_syns = 0;
2607
2608 if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
2609 ni->ni_esslen = ic->ic_des_esslen;
2610 memcpy(ni->ni_essid, ic->ic_des_essid, ni->ni_esslen);
2552
2553 if (IEEE80211_ADDR_EQ(old_bssid, ni->ni_bssid))
2554 sc->sc_false_syns++;
2555 else
2556 sc->sc_false_syns = 0;
2557
2558 if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
2559 ni->ni_esslen = ic->ic_des_esslen;
2560 memcpy(ni->ni_essid, ic->ic_des_essid, ni->ni_esslen);
2611 ni->ni_nrate = 0;
2612 for (i = 0; i < IEEE80211_RATE_SIZE; i++) {
2613 if (ic->ic_sup_rates[i])
2614 ni->ni_rates[ni->ni_nrate++] =
2615 ic->ic_sup_rates[i];
2616 }
2561 ni->ni_rates = ic->ic_sup_rates[IEEE80211_MODE_11B];
2617 ni->ni_intval = ic->ic_lintval;
2618 ni->ni_capinfo = IEEE80211_CAPINFO_ESS;
2619 if (ic->ic_flags & IEEE80211_F_WEPON)
2620 ni->ni_capinfo |= IEEE80211_CAPINFO_PRIVACY;
2621 } else {
2622 /* XXX check return value */
2623 buflen = sizeof(ssid);
2624 wi_read_rid(sc, WI_RID_CURRENT_SSID, &ssid, &buflen);

--- 112 unchanged lines hidden (view full) ---

2737 DPRINTF(("wi_scan_result: scan complete: ap %d\n", naps));
2738#undef N
2739}
2740
2741static void
2742wi_dump_pkt(struct wi_frame *wh, struct ieee80211_node *ni, int rssi)
2743{
2744 ieee80211_dump_pkt((u_int8_t *) &wh->wi_whdr, sizeof(wh->wi_whdr),
2562 ni->ni_intval = ic->ic_lintval;
2563 ni->ni_capinfo = IEEE80211_CAPINFO_ESS;
2564 if (ic->ic_flags & IEEE80211_F_WEPON)
2565 ni->ni_capinfo |= IEEE80211_CAPINFO_PRIVACY;
2566 } else {
2567 /* XXX check return value */
2568 buflen = sizeof(ssid);
2569 wi_read_rid(sc, WI_RID_CURRENT_SSID, &ssid, &buflen);

--- 112 unchanged lines hidden (view full) ---

2682 DPRINTF(("wi_scan_result: scan complete: ap %d\n", naps));
2683#undef N
2684}
2685
2686static void
2687wi_dump_pkt(struct wi_frame *wh, struct ieee80211_node *ni, int rssi)
2688{
2689 ieee80211_dump_pkt((u_int8_t *) &wh->wi_whdr, sizeof(wh->wi_whdr),
2745 ni ? ni->ni_rates[ni->ni_txrate] & IEEE80211_RATE_VAL : -1, rssi);
2690 ni ? ni->ni_rates.rs_rates[ni->ni_txrate] & IEEE80211_RATE_VAL : -1, rssi);
2746 printf(" status 0x%x rx_tstamp1 %u rx_tstamp0 0x%u rx_silence %u\n",
2747 le16toh(wh->wi_status), le16toh(wh->wi_rx_tstamp1),
2748 le16toh(wh->wi_rx_tstamp0), wh->wi_rx_silence);
2749 printf(" rx_signal %u rx_rate %u rx_flow %u\n",
2750 wh->wi_rx_signal, wh->wi_rx_rate, wh->wi_rx_flow);
2751 printf(" tx_rtry %u tx_rate %u tx_ctl 0x%x dat_len %u\n",
2752 wh->wi_tx_rtry, wh->wi_tx_rate,
2753 le16toh(wh->wi_tx_ctl), le16toh(wh->wi_dat_len));

--- 353 unchanged lines hidden ---
2691 printf(" status 0x%x rx_tstamp1 %u rx_tstamp0 0x%u rx_silence %u\n",
2692 le16toh(wh->wi_status), le16toh(wh->wi_rx_tstamp1),
2693 le16toh(wh->wi_rx_tstamp0), wh->wi_rx_silence);
2694 printf(" rx_signal %u rx_rate %u rx_flow %u\n",
2695 wh->wi_rx_signal, wh->wi_rx_rate, wh->wi_rx_flow);
2696 printf(" tx_rtry %u tx_rate %u tx_ctl 0x%x dat_len %u\n",
2697 wh->wi_tx_rtry, wh->wi_tx_rate,
2698 le16toh(wh->wi_tx_ctl), le16toh(wh->wi_dat_len));

--- 353 unchanged lines hidden ---