Commit Graph

53 Commits

Author SHA1 Message Date
dyoung 4a2df5a4d4 Bug fix: synchronize Transmit commands with all other commands.
Following Charles Hannum's wi(4) optimizations, there could be a
Transmit command outstanding after wi_tx_intr or wi_start returns.
The driver would blithely issue a second command [*] before the
first command was finished, taking the first command's WI_EV_CMD
indication to mean the second command had finished.  The driver
would be dreadfully confused when the second command's results did
not meet its expectations (e.g., a RID mismatch error would occur).
The packet transmit section of the code would never read the
WI_EV_CMD it expected, so transmissions would cease.

This patch counts the outstanding transmit commands (there can be
only one) and, if a transmit command is outstanding at the top of
wi_cmd(), wi_cmd waits for the command to complete.  If there was
a transmit command outstanding when wi_cmd begins, it calls
wi_cmd_intr() on its way out.

I have tested this on an Orinoco card.  Previously, the card would
stop transmitting or the kernel would panic as desynchronization
occurred.  Now it works beautifully.

[*] A second command could be issued by wi_ioctl or else by
    wi_intr->wi_info_intr->wi_newstate->wi_read_xrid->wi_read_rid.
2004-12-13 17:55:28 +00:00
dyoung 1b319e72be Simplify the BSSID synchronization code. 2004-09-28 00:42:11 +00:00
mycroft 1afe1f83af Be much more robust with RID values during attach:
* If the device returns a length too short to even contain the RID number,
  flag it as not supported and return EOPNOTSUPP, rather than returning a
  length of -2 and trying to use the value anyway.
* Check the returned lengths to see if we actually got anything.
* If we get no rate list, fail the attach, so we don't just blow up later.
Allow the frontend to pass in a MAC address.
2004-08-07 17:12:44 +00:00
mycroft ddc97f59ca Put unadulterated dB values in the radiotap header, not the converted dBm
values.
2004-08-05 22:57:32 +00:00
mycroft 8f64992310 Add sc_txstart and sc_txstarted, to keep track of the current FID we want to
start and the number we've started that have not been alloced yet.  Currently
sc_txstarted is constained to 0 or 1 because of the way we start the next
packet, but this will change.
2004-07-22 21:56:58 +00:00
mycroft a1b8647f1e Non-functional changes: add comments, remove a structure name. 2004-07-22 20:39:15 +00:00
mycroft 1854f1b055 Keep a count of packets written to the chip but not yet initiated. This
simplifies some logic, and is needed for later changes.
2004-07-22 20:30:43 +00:00
mycroft 04cd0b261d Change some names.
sc_txnext -> sc_txalloc
sc_txcur -> sc_txqueue
2004-07-22 20:25:23 +00:00
mycroft 9df2197095 Keep a count of FIDs allocated, rather than storing a packet length in the
ring.
2004-07-22 20:23:31 +00:00
mycroft 94e3bc2cef Rework the rate-lowering hack:
* Update sc_txpending[] when a packet is written, even before we issue the TX
  command, since it may be active when we issue the TX command for the
  following packet.
* Do not lower the rate in ni_txrate or id_rateidx, because these are used to
  keep track of sc_txpending[], and could cause us to get "stuck" at the lower
  rate.
2004-07-22 20:06:05 +00:00
dyoung 9f147300d1 Disable rate-adaptation for Lucent firmware version 8.42.1, per a
bug report from Simon Burge: the firmware seems to lock up.

If rate-adaptation is disabled on a Lucent card, then do all the
rate-adaptation work *except* for writing the new transmit rate,
since I suspect that is what locks-up the firmware.
2004-02-10 00:59:38 +00:00
dyoung d32ed08a80 Factor out the initialization/reset of RSS descriptors, making
wi_rssdescs_init, wi_rssdescs_reset, which I will use to receover
when the firmware botches up the RSS descriptor index.
2004-02-10 00:47:41 +00:00
dyoung 609617af90 Enable RSSI-based rate-adaptation for wi(4). This enables wi(4)-based
APs to run at "full speed" where before they ran at just 1 or 2Mb/s.
The AP will adapt the data rate for each client based on packet
losses and the received signal strength.

I have also enabled rate adaptation for STA mode and for IBSS mode,
but the hardware gives us less control over the data rate in those
modes.
2003-12-07 05:44:49 +00:00
dyoung 9270de9dc4 Updates to 802.11 radiotap. The _DB_ flags were used everywhere to
denote a signed dBm Rx power, so rename them to _DBM_ and change
the signedness.  Add new _DB_ flags for unsigned Rx power measured
from an arbitrary reference.

Try to synchronize net80211/ieee80211_radiotap.h with my tcpdump
sources (which public tcpdump has not seen, yet) and with FreeBSD.
2003-12-07 04:49:17 +00:00
dyoung 23d8f48692 Add data-link type DLT_IEEE802_11_RADIO to wi and atw. DLT_IEEE802_11_RADIO
lets you monitor radio stats like received signal strength, which
diversity antenna was used, channel/frequency, modulation, and data
rate.
2003-11-16 09:02:42 +00:00
dyoung 50daf0a217 The upper & lower bounds on wi RSSI are completely bogus, AFAICT. 2003-10-16 10:38:07 +00:00
dyoung ef743c64b6 Switch wi(4) to the new 802.11 layer. 2003-10-13 08:07:21 +00:00
dyoung 6e3daf0a07 Still more consolidation of 802.11 media-handling, moving moving
common code from awi and wi into the 802.11 framework. Inspired by
Sam Leffler's patches to FreeBSD.
2003-07-06 20:01:17 +00:00
dyoung 2c1f7efe46 Improved RSSI->dBm conversion, especially for Lucent cards, for
which I borrowed some conversion constants from the Linux orinoco_cs
driver.
2003-07-06 07:15:55 +00:00
dyoung ba845eeeb3 Stop wi panics on card ejection in Powerbook in both the enabled
and disabled states. This should fix an x86 panic somebody reported
on icb.
2003-05-20 01:29:35 +00:00
dyoung 045ad0db5e IEEE80211_LOCK and WI_LOCK conceal enormous differences in locking
semantics on FreeBSD and NetBSD, so I am backing them out until
the macro set is enriched.
2003-05-16 01:26:17 +00:00
dyoung 850a6ef1e6 Begin synchronization with FreeBSD:
1 Add channel mask, transmit rate-mask arguments to wi_scan_ap.
2 Adopt the macros WI_LOCK/WI_UNLOCK for synchronization. FreeBSD
  uses a different synchronization mechanism.
3 In wi_cmd, adopt constants WI_DELAY/WI_TIMEOUT for timing.
4 Pull debug messages from into wi_read_nicid from FreeBSD.
5 Bug fix: if IFF_ALLMULTI, don't filter any multicasts.
6 Count and report TX exceptions, but don't generate any additional
  interrupts.
2003-05-13 08:35:58 +00:00
dyoung a090735114 Misc changes to wi_stop. First, block interrupts in wi_stop. (From
FreeBSD.)

Fix a bug in wi_stop where ejecting from the Powerbook crashes the
system. Essentially, the patch makes sure we write *no* registers
when we are no longer attached.

Also, for consistency w/ FreeBSD, use sc_portnum throughout wi,
instead of hard-coding WI_PORT0 .
2003-05-13 06:33:40 +00:00
dyoung 913d1b877a Cosmetic: move sc_reset closer to its siblings sc_disable and sc_enable. 2003-03-27 04:53:52 +00:00
dyoung 404d2ac6e8 Introduced sc_reset to wi_softc. The bus-specific front-end gets
to fill this.
2003-03-27 04:34:16 +00:00
dyoung c4780f2706 wi_start: write an mbuf chain to the driver using wi_mwrite_bap,
which is safer than the loop there used to be here.

wi_mwrite_bap: if wi_write_bap fails, don't keep on going: this
  way you avoid writing garbage to the radio. First time you see
  an odd-length mbuf, copy the remainder of the chain to sc_txbuf
  and from there to the MAC. This way, you do not read an mbuf past
  the end of its data (occasionally you will cross a page doing
  that!) and you avoid expensive, excess seeks in the radio's own
  buffer chain.

wi_rx_intr: clamp the frame length told to us by the driver to the
  most bytes we can fit in our mbuf cluster.

I am still getting e-mails from my testers telling me how much
better this makes things.
2003-01-09 08:49:39 +00:00
dyoung 18d05b8362 A Prism firmware participating in an IBSS network will not send a
LINK_STAT notification for every change of BSSID, so the firmware's
BSSID and the driver's BSSID will get out of sync. This has two
bad affects. First, because the 802.11 framework filters received
packets based on BSSID, many packets can be dropped before the
driver adopts the firmware's BSSID.  Second, ifconfig's tells a
misleading BSSID to the operator.

This problem is most apparent in networks where every station does
not hear every other. I reproduce these conditions in an office by
removing/replacing the antennas on my 802.11 cards.

As a solution, in IBSS mode, the driver will ask the firmware for
the BSSID every five seconds. Also, whenever the driver receives
a frame carrying a different BSSID than the driver's BSSID, then
the driver asks the firmware for the BSSID before handing the frame
to ieee80211_input.
2003-01-01 02:06:47 +00:00
dyoung fb22424264 The RID for the RSSI->dBm adjustment is not supported by Prism
station firmware version <= 1.1.1.
2002-12-27 07:54:35 +00:00
dyoung 1b3451a594 Only Prism is known to support WI_RID_FRAG_THRESH. 2002-11-18 15:10:22 +00:00
dyoung f675f5f8b5 Support two new RIDs.
WI_RID_DBM_ADJUST: In preparation for capturing Prism packets
  containing received signal strength indications (RSSI), read the
  constant for conversion from RSSI to dBm (decibels relative to
  a milliwatt).

  WI_RID_FRAG_THRESH: Get/set the packet fragmentation threshold
  on Lucent/Prism.
2002-11-16 06:02:53 +00:00
onoe d131e2b1a8 Handle of AP_IN_RANGE/AP_OUT_RANGE, to fix a problem once the station
is out of ragen, it never comes up again.
For HostAP, prohibit sending DATA frame to an unassociated but authenticated
station.
2002-10-04 04:23:20 +00:00
onoe 9fadcea372 old lucent adhoc-demo mode (adhoc,flag0 or wiconfig -p 3) wasn't handled
correctly.  To avoid massive extra code in each driver, now if_iee80211subr.c
also handles non-standard old lucent adhoc-demo mode.
This also fixes PR 14227.
2002-09-30 15:48:41 +00:00
onoe efe919010c Jumbo commit for wi driver.
- Eliminate wi_hostap.c since most of the code are duplicated with
  net/if_ieee80211subr.c
- Station for Infrastructure network and IBSS also use service functions
  as much as possible to be consistent with other wireless drivers.
Now WEP works for station/ibss/hostap.
2002-09-30 06:50:35 +00:00
onoe 2f8340c369 Nuke unneeded member sc_ifp and use #define sc_if instead,
to prepare jumbo commit for wi.c
2002-09-30 06:29:29 +00:00
thorpej 4f4dc45bbb Jumbo patch, from David Young <dyoung@ojctech.com>, with small tweaks
by me:
* Speed up reading/writing buffers from the hardware by avoiding
  slow forward seeks.  In preparation to use the optimization, do
  not read overlapping bytes.  This is currently disabled, but can
  be enabled with OPTIMIZE_RW_DATA.
* Hand 802.11 and Prism-specific frames to BPF.  User can watch these
  frames by specifying an alternate DLT to e.g. tcpdump(8).
* Add support for SIOC[SG]80211BSSID and SIOC[SG]80211CHANNEL.
* Issue join requests and track join/create state through link-status
  notifications.
* Split wi_rxeof into separate routines for receiving Ethernet II,
  802.11 data, and 802.11 management frames.
* Bug fix: Account for aligning m_data to a word boundary in the Rx
  buffer size check.
* Bug fix: Check for LLC/SNAP even if the firmware tells us the frame
  is Ethernet II, as the firmware sometimes gets this wrong.
* Process as many events as possible when we get an interrupt, using
  a simple heuristic to avoid reprocessing an event (which can have
  bad side-effects).  Clamp the time spent in the interrupt handler
  to 4ms.
* Redo the timeout loops to be consistent and less prone to error.
* Add delays to timeout loops which were missing them, so that a
  fast CPU won't win the race.
* Borrow some timeout loop values from the linux-wlan-ng driver,
  which seems to reflect a high level of clue (due to direct support
  from Intersil).
* Get rid of silly wi_read_data(..., len + 2) idiom; simply round up
  in wi_read_data() and wi_write_data().  Also, protect against a
  length of 0.
* Name some frequently-used constants.  Correct spelling.  Other style nits.
* Bug fix: On Prism, set Create IBSS register to 0 *always*.  The meaning
  of Create IBSS == 1 is join an IBSS or *ESS*, and we do not want to
  join an ESS, because that would put us in an inconsistent state.  0
  is the right value for Prism.
* Bug fix: Clean up state at the top of wi_init(), in the event that
  we don't reach the bottom.
* Simplify wi_start() by always providing an RFC1042-encoded 802.11
  frame to the firmware.
* Larval powersave support for HostAP mode, enabled by WI_HOSTAP_POWERSAVE.
* Bug fix: Call wi_stop() from wi_shutdown().
* Bug fix: sync media options with HostAP mode in wi_sync_media().
* In wi_media_status(), inquire firmware for current media state if
  media == auto.  From FreeBSD.
* Clean up the way buffer lengths are computed by using pointer
  arithmetic rather than magic constants.
* Swap the order of comparisons in addr_cmp() for speed.
* Bug fix: Send ReAssoc Response instead of Assoc Response to a
  ReAssoc Request.
* Bug fix: Copy SSID using the correct size.
* Give more meaningful names to offsets in a wi_frame.
* Bug fix: Assign the right values to the named constants for
  Rx frame encoding.
* Get rid of useless SNAP constants.
2002-09-23 14:31:27 +00:00
thorpej 3ebfddbcca Remove an unused member from the softc. 2002-08-11 21:50:06 +00:00
thorpej 22c90da7f0 Snapshot of work-in-progress: Add AP support for Prism2-based boards.
WEP for APs is not yet implemented, but without WEP, this works well
enough for my laptop to associate with an AP running this code.

Adapted from OpenBSD.
2002-08-11 06:13:53 +00:00
thorpej bb718bd6e3 * Add "wi_flags" to the softc to indicate capabilities of the card. Fill
in this info based on firmware type and version.  Replace "wi_has_wep"
  with a flag.
* For cards which support IBSS, add "ibss" has a media option.
* For cards which support CREATE_IBSS, add "ibss-master" as a media
  option.
* Use the "ibss" and "ibss-master" media options to determine if
  we should go into IBSS mode and/or create the IBSS.
* Internally convert between the generic WI_PORTTYPE_IBSS and the
  value the firmware wants to use for IBSS.
* When setting the IBSS name, if a desired-SSID is set, and we're
  an ibss-master, write the desired-SSID into the own-SSID slot.
  This ensures that "ifconfig wi0 nwid FOO" will do the expected
  thing.
* Only set the roaming mode if the card supports roaming.

From OpenBSD.
2002-08-11 01:30:28 +00:00
thorpej 375eb183ff Read supported rates from the card and report them. Only add
media types if that rate is supported.

Adapted from OpenBSD.
2002-08-11 00:00:41 +00:00
ichiro 7d1236beff fix minor bugs for lucent cards. (point out from Warner Losh) 2002-04-05 00:54:51 +00:00
jdolecek 46d335a320 move wi_pci_reset() from ic/wi.c to pci/if_wi_pci.c, where is belongs 2002-04-04 17:43:31 +00:00
ichiro 7fadd48a2f using table driven for Prism2 family IDs/Names. 2002-04-04 07:06:16 +00:00
ichiro 7cd9648d72 added sc_pri_firmware_ver, and print Primary/Station firmware versions.
cosmetic change.
2002-03-30 16:44:59 +00:00
onoe 45a8f0749c Fix to work Symbol firmware card, which cannot be initialized more than once.
Tested with 3Com 3CRWE737A and Intel Pro/Wireless 2011.
2002-03-27 08:01:22 +00:00
dbj ea44522489 changes from Warner Losh to read firmware version for non prism2 cards 2002-03-25 09:10:54 +00:00
ichiro e08ec84292 "Association Faild" was added to "Link Stat" messages.
;
Implement wi_scan into wi.c.
forces if_wi to initiate one round of access point scan.
This code was written by jrb@cs.pdx.edu, modified and bug-fixed by ichiro@netbsd.org
2002-01-21 11:28:18 +00:00
explorer a40b01901f revert changes I made a long time ago. This should undo the changes which are causing problems on some non-x86 platforms. I'll probsably redo some of these changes, but after the next release branch. 2002-01-05 20:10:53 +00:00
ichiro cbcfff63ec Add Intersil Prism2.5 Mini-PCI wavelan. 2001-10-13 15:00:23 +00:00
explorer 56b9583089 Implement two major items:
(1) Add an IOCTL to tell the Lucent based cards how often to
	    do an access point scan.  These results are returned by
	    calling another IOCTL to get the most recent scan data.

	    This function works with prism2 cards as well, but the
	    data is returned in a different format, or perhaps it is
	    data only for the closest access point.

	(2) For prism2 cards, add the ability to put it into LAN monitor
	    mode, where (via BPF) all packets can be received.  This
	    mode works best with "wiconfig wi0 -p 3 -f ?" to put the
	    card into pseudo-IBSS mode (to keep it from channel-hopping
	    and scanning for access points) and to set the frequency of
	    the AP you wish to monitor.

	    The returned data has a partial wi_frame header (down to the
	    wi_dat_len field) followed by the raw data of the packet.
	    I have and will put up on http://www.flame.org/NetBSD/wireless/
	    some simple utilities which do some perhaps interesting things,
	    like scan for access points, capture packets, etc.
2001-09-22 17:22:25 +00:00
ichiro 4afb07bd12 getting prism2 firm ver routine to wi_get_id().
if firm ver is more than 0.8c3, promiscuous mode is off.

typo WI_RID_STA_IDENEITY -> WI_RID_STA_IDENTITY
2001-05-15 09:01:27 +00:00