Commit Graph

29 Commits

Author SHA1 Message Date
dyoung
7153b68a4a Make rtwvar.h, rtw.c agree whether rtw_host_rfio and rtw_debug are
static or extern.  Problem noted by Tom Spindler.
2006-05-14 04:08:09 +00:00
perry
fbae48b901 Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
2006-02-16 20:17:12 +00:00
dyoung
92e2a6beb6 Add support for the GCT Semiconductor GRF5101 transceiver/synthesizer.
From OpenBSD.

GCT will not provide any documentation, so there are many magic
numbers in this code.
2005-12-29 22:27:17 +00:00
perry
93124077ae Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:27:29 +00:00
dyoung
63d8fb2cb6 Miscellaneous Realtek RTL8180L driver improvements:
1 Added new sysctl controls for debugging.

2 Improve detection & support for hardware WEP.

3 Revamp handling of transmit descriptor rings.

4 Reliably IFF_OACTIVE when transmit descriptors are available, to
  stop the transmit section of the driver from freezing up.

5 Fix beacon transmission in adhoc and hostap modes.  XXX There is
  a wart in hostap mode, where beacons are transmitted at 1/2 the
  correct rate.  Load beacon descriptors when the RTW_INTR_BINT
  interrupt arrives; schedule RTW_INTR_BINT 1ms ahead of the target
  beacon time.

6 Recover more gracefully from tx/rx errors: avoid
  transmitter/receiver/chip resets.  Try to re-synchronize software
  state with hardware state---e.g., load next descriptor pointer
  from hardware.

7 Activate the transmit watchdog timer for beacons as well as other
  packets.

8 Introduce rtw_idle() that waits for transmit DMA to finish; call
  it before resetting the transmitter.
2005-11-23 04:12:33 +00:00
dyoung
c0a74e44c8 rtw: Try to get hardware WEP to work. It seems to work in
the RX direction, but not in the TX direction.  The
	  net80211 crypto framework doesn't seem to cope very well
	  with the assymetry (I'm probably missing something), so
	  I will use software WEP for now.

net80211: In ieee80211_compute_duration, figure out whether to add
	  the WEP header to the packet overhead by checking the
	  WEP bit in the Frame Control field of the 802.11 header,
	  instead of checking the IEEE80211_F_PRIVACY flag.

	  Also, if the WEP bit is present, assume that the frame
	  described by (wh, len) has already already been WEP
	  encapsulated, and adjust the payload length accordingly.
	  XXX that's a grotty hack that I will have to revisit,
	  later.
2005-06-27 05:49:13 +00:00
dyoung
9063402978 Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD.  Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]).  Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
2005-06-22 06:14:51 +00:00
dyoung
8125cd1769 Misc. changes to improve ad hoc mode and to enable hostap mode:
Fix the work-around for the NIC bug where it skips to rx
  descriptor 0.  The driver used to skip to rx descriptor 1.
  Hopefully this stops the out-of-order packet reception that
  Charles Hannum saw.
                                                                                  When debugging is enabled, print rx-descriptor status flags
  before printing the rx bit rate.

  Add a debug message for when a beacon tx buffer reclamation.

  Reset IFF_OACTIVE when we reset the transmitter.

  Pass the consolidated LED state, a struct rtw_led_state,
  to rtw_led_attach.

  Choose the bit-rate for management frames (1Mb/s) at the
  same place we choose for all other frames.

  Do not use the NIC's short preamble or RTS options for
  management frames.  Label beacons for the NIC.

  Following a Linux driver, take care not to zero arbitrary
  bits in the TPPOLL register.

  Use the new idiom for IBSS merges: disable transmitter,
  kick the state machine.
                                                                                  Add a second descriptor to the beacon ring.  The NIC seems
  to like this much better.
2005-03-02 05:20:43 +00:00
perry
f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
perry
18db93c7f6 de-__P 2005-02-04 02:10:35 +00:00
dyoung
55940f7c4e Move the register access mode into struct rtw_regs. Change
rtw_set_access, rtw_set_access1 to match.

Add a subroutine for setting WEP keys.  WEP isn't quite finished,
because I have to add the WEP header to Tx packets.  Implement the
SIOCS80211NWKEY ioctl for setting WEP keys.

Program the LEDs based on operating state and packet activity.

 * On a Revision F RTL8180, blink LED1 at 1Hz to indicate
   scan/authenticate/associate states.  In the run state, turn LED1
   on.  In every state, blink LED1 at 5Hz to indicate non-beacon
   tx/rx activity.  I would like to use two LEDs, but in all my
   Rev. F instances, LED0 is not wired to an LED; instead, the
   first LED is wired to indicate that the card's power is on.

 * On a Revision D RTL8180, program the LEDs so that LED0 indicates
   Tx, and LED1 indicates Rx.  The Rx LED will blink annoyingly if
   there are beacons in the air, but at least the Tx LED is useful.

 * Store the hardware revision in the softc to support my futile
   attempt at programming LEDs for both Rev. D and Rev. F parts;
   I never did get Rev. D LEDs to work right.

 * Add a debug flag RTW_DEBUG_LED for the LED transitions.

Add RTW_TPPOLL_ALL, RTW_TPPOLL_SALL to start and stop, respectively,
all of the transmit rings.

In ad hoc mode, allocate a beacon and load it into the beacon ring.
Start the ring.  In one trial, the card re-transmitted the beacon
ring's contents several times before stopping.  More programming
and testing for ad hoc mode is necessary.  I'm not setting the
beacon flag in the transmit descriptor.

Revamp the transmit section to make better use of all the transmit
rings:  beacon queue, high-, low-, and medium-priority rings.  Put
beacon frames on the beacon ring.  All other management frames,
and data frames, go on the medium-priority ring.  Power-save data
frames go on the high-priority ring.  (Note that powersaving is
not implemented!)  This is a work in progress.

Send all 802.11 Management frames at 1Mbps.

After we put a packet on a transmit ring, tickle the right bit in
the TPPOLL to tell RTL8180.  Stop all rings on error and in rtw_stop.

Use the RF chip type, not the RTL8180 revision, to choose between
host- and MAC-controlled RF serial I/O.  Now the Netgear MA521
works.

Remove bogus definition of bit RTW_TPPOLL_FSWINT.
2005-01-16 11:50:43 +00:00
dyoung
66e0c6fbb9 sys/dev/ic/rtw.c:
Cosmetic: remove two short ladders from rtw_init.  Fit the
        NIC registers print-out onto one line using the RTW_PRINT_REGS
        macro.

sys/dev/ic/rtwvar.h:

        Add RTW_PRINT_REGS wrapper macro for rtw_print_regs.  It
        is a null op unless defined(RTW_DEBUG).
2005-01-03 03:25:06 +00:00
dyoung
37420795ec Cosmetic: change u_int{8,16,32,64}_t to C99-style uint{8,16,32,64}_t,
which is preferred.
2005-01-02 04:23:03 +00:00
dyoung
9bd9e3df21 Remove unused rtw_softc variables and some other dead code. 2004-12-29 01:11:24 +00:00
dyoung
c3b84ef737 I like the tlp/atw-style names for software descriptors, txsoft,
better than txctl.  Change from rtw_txctl/rtw_rxctl to
rtw_txsoft/rtw_rxsoft.  Change the descriptor blocks' names to
match: rtw_txctl_blk becomes rtw_txsoft_blk.  Change the member-name
prefixes for both software and hardware descriptors.
2004-12-29 01:06:52 +00:00
dyoung
d07caa7269 Consolidate variables related to the rx ring in sc_rxdesc_blk,
which is a struct rtw_rxdesc_blk.

Put a copy of the DMA tag and the DMA map into the rx- and tx-ring
blocks so that I don't have to pass them to subroutines all of the
time.
2004-12-29 00:21:37 +00:00
dyoung
f1fa0e7819 Add bpf(4) packet taps to rtw(4). Now you can tap DLT_EN10MB
(Ethernet II), DLT_IEEE802_11 (802.11), and DLT_IEEE802_11_RADIO
(radiotap + 802.11).
2004-12-28 22:30:07 +00:00
dyoung
05372fb8f4 Group receiver-related variables together: move sc_rxctl nearer to
sc_rxnext.

Add sc_nrxdesc, the number of receive descriptors that we are
actually able to use.  sc_nrxdesc will ordinarily equal RTW_RXQLEN.
If buffers are exhausted, sc_nrxdesc < RTW_RXQLEN.  My next commit
will change dev/ic/rtw.c to deal with buffer exhaustion.
2004-12-28 22:07:04 +00:00
dyoung
e336b06e3b Remove useless debug sysctls.
For AP scanning, change the channel dwell time from 1 second to
1/5 second.
2004-12-27 06:12:28 +00:00
mycroft
1083cfb1dd Fix a compile error if no RTW_DEBUG. 2004-12-26 22:37:57 +00:00
dyoung
1b319bfabc The rx descriptor ring bug happens quite often, so printf'ing
occurrences is annoying.  Only printf about it when rtw_debug
contains RTW_DEBUG_BUG.
2004-12-25 07:45:53 +00:00
dyoung
d2b4873c41 Change rtw_debug from a debug level to a debug mask. Add a lot of
debug flags.

From Linux: handle an RTL8180 bug.  Sometimes the NIC skips from
the middle of the ring to the 0th rx descriptor.  Now the driver
resynchronizes.

Handle a receive descriptor underrun or Rx FIFO overflow condition
in the way that the Linux driver does.  This kind of seems like
overkill, but whatever.

Protect rtw_ioctl with splnet().

Do not load a tx descriptor with a buffer shorter than 4 bytes.

Handle a transmit timeout less disruptively.
2004-12-25 06:58:37 +00:00
dyoung
b24dd60cd6 Round up the number of h/w Rx descriptors to the number of h/w,
not s/w, descriptors in 256 bytes (the descriptor ring alignment).
2004-12-23 08:27:38 +00:00
dyoung
aecae5f227 Realtek sample sources are not consistent about the "Digital PHY"
bit in the SROM.  It seems as if it is set to 1 when the PHY is
*analog*, not *digital*.  Fix my sources.

In rtw_intr_rx, use units of 500kb/s instead of 100kb/s for rate,
to be consistent with net80211's expectations.  Polish up some
debugging ugly messages.  Dump raw 802.11 packets if IFF_DEBUG|IFF_LINK2
and RTW_DEBUG is defined.

Polish power-state (on/sleep/off) handling.  Especially improve
support for RFMD (totally untested) and Maxim.  For Philips, take
the Digital PHY property into account.

Call the net80211 watchdog function from rtw_watchdog, so that we
scan again if auth/assoc fails.

Be a little more cautious about writing register[RTW_TPPOLL], since
other drivers are....  Don't frob the high/low-priority queues
right now, since I don't use them.

Add rtw_join_bss which programs the card with the BSSID and other
properties of a BSS.  Use it on state transitions.  Factor out
rtw_set_nettype.

Make rtw_recv_beacon call ieee80211_recv_mgmt instead of dropping
beacons on the floor!  TBD IBSS merges.

Change some rtw_debug=2 printfs to rtw_debug=3 (RTW_DPRINTF3)
printfs so the console doesn't get spammed so badly at rtw_debug=2.
Change some debugging printfs to RTW_DPRINTFs.  E.g., print the
"RF programming method" only if debugging is enabled.
2004-12-20 23:05:41 +00:00
dyoung
38e3126fe5 Add the transmit section of rtw(4): build up and tear down transmit
descriptor rings, move packets from the transmit queues to the
transmit rings, handle transmission-completed interrupts.  My
Linksys WPC11 ver. 4 with Maxim RF, generates interrupts like it
is successfully transmitting packets.  Clearly there are bugs: my
G4 Powerbook locks up hard.  I will debug tomorrow.
2004-12-19 08:19:25 +00:00
dyoung
0842199905 Fix a typo, s/high/low/. 2004-12-13 01:15:07 +00:00
dyoung
87f615f34e At last, I have rtw w/ Philips RF receiving packets.
I added some sysctls to aid debugging:

  * hw.rtw.debug -- enable debugging

  * hw.rtw.flush_rfio -- Linux voodoo: possibly makes the MAC
    "flush" bits down the serial bus to the RF

  * hw.rtw.host_rfio: force the host to bang bits to the RF, instead
    of the MAC banging bits

  * hw.rtw.rfio_delay: after telling the MAC to bang bits to the
    RF front-end, delay rfio_delay microseconds.

  * hw.rtw.rfprog_fallback: there is this notion of the "RF
    programming method."  I believe the choice influences the
    polarity/timing of the serial bus used to program the RF
    front-end.  I know the correct choice for Intersil/RFMD/Philips
    front-ends, only.  For all other front-ends, I "fallback" to
    rfprog_fallback.

Make rtw_txdac_enable take an rtw_softc argument.  I will probably
revert this change.

Add some Linux voodoo to rtw_continuous_tx_enable.  I will probably
revert this change.

Important: add rtw_set_rfprog, which sets the correct RF programming
method.  This change and the following change are probably responsible
for making the Philips RF work.

Important: RTW_CONFIG1 is an 8-bit register, treat it that way!

Important: RTW_BRSR is 16-bit, RTW_CRCOUNT, RTW_PHYDELAY, and
RTW_MSR are 8-bit: treat them that way!

Vastly simplify rtw_resume_ticks.

Note to self: set the LED state to match the power state.

Hedge against the possibility that RTW_MSR is protected as
RTW_CONFIG[0123] are, meanwhile reworking that section of rtw_init
a little.

Add sc_anaparm, which isn't used, yet....
2004-12-13 00:48:02 +00:00
dyoung
a534631ee7 Miscellaneous changes. Details below. Important changes flagged
with [].  Using the driver with my Linksys WPC11 ver. 4, it seems
to be receiving packets for a change.  The WPC11 ver. 4 has a Maxim
RF section.  My no-name rtw with Philips RF section still does not
receive any packets.

Keep access-level (analog params > config[0123] registers > none)
in sc_access.  Add rtw_set_access for changing the access level.

Make rtw_continuous_tx_enable and other subroutines use rtw_set_access
instead of rtw_config0123_enable and rtw_anaparm_enable.

Factor part of the chip-reset code into rtw_chip_reset1.

Change the 'struct foo (*bar)[N]'-style arguments to
'struct foo *bar'-style arguments.

Consolidate software/hardware Tx/Rx ring setup in rtw_hwring_setup,
rtw_swring_setup.

Add a new constant, SA2400_OPMODE_DEFAULTS, for the bits that we
*always* set in the SA2400 OPMODE register.

Factor some code out into rtw_sa2400_calibrate.  (Inspired by the
Linux driver.)

[] When the receiver goes into underrun/overflow state, call a new
   subroutine, rtw_kick() that stops the Rx/Tx processes, resets
   the chip, reinitializes the Tx/Rx rings, and restarts Rx/Tx
   processes.  (Inspired by the Linux driver.)

[] In rtw_intr_rx, check for too-short packets before calling
   ieee80211_find_rxnode.  I believe this will prevent a repeat of
   the MCHK exception I saw once on macppc.

[] Use seconds-elapased as well as microseconds-elapsed to set the
   next "due date" for the timeout interrupt.  This keeps the driver
   from programming the timeout to expire too early.

[] In rtw_intr, read RTW_ISR at most 10 times, then get out.  If
   the interface is not enabled (RTW_F_ENABLED), then get out.

[] In rtw_stop, get out if the interface is not enabled (RTW_F_ENABLED).
   Block IPL_NET interrupts.  Don't read/write any registers if
   the interface is invalid (RTW_F_INVALID).

[] Call rtw_stop in rtw_detach.
2004-12-12 06:37:59 +00:00
dyoung
3e9bdb9662 Add work-in-progress driver rtw(4) for Realtek RTL8180 MAC/baseband.
Add register definitions for Maxim MAX2820 and Philips SA2400 radio
front-ends.
2004-09-26 02:29:15 +00:00