the NIC decryptes & decapsulates WEP frames before passing them to
the host. "Remember" the state of IEEE80211_F_DROPUNENC in
sc_ic_flags, though, and try our best to honor it as we setup the
hardware state.
This is the second patch of this kind. The previous patch was
badly broken because wi_mend_flags was basing its decision to clear
IEEE80211_F_DROPUNENC based on the operating state we were
transitioning FROM instead of the state we were transitioning TO.
This fixes a bug that Simon Burge reported, where dhclient wi0
would not get a lease unless and until you ran 'ifconfig wi0'
concurrently (which would frob the IEEE80211_F_DROPUNENC bit in
the right way). This patch was tested by Simon with his Toshiba
Lucent-clone.
back out my change to ieee80211_crypto_encap that made it free its
mbuf argument on error. I had thought it was a bug. It was not.
It's the drivers that are broken. Make an(4), atw(4), ipw(4),
iwi(4), ral(4), rtw(4), ural(4), and wi(4) free the mbuf when
ieee80211_crypto_encap returns NULL. Also, return ath(4) to the
way it was---i.e., free the mbuf.
Thanks to Sam Leffler to pointing out my mistake.
net80211. It was especially important to zero the IEEE80211_F_DROPUNENC
(discard unencrypted packets) flag in operating modes where the
firmware decrypts for us. Otherwise, the 802.11 layer discarded
all received frames. See wi_mend_flags. From FreeBSD, with
improvements by me.
For better compliance with the "net80211 way":
set sc_cnfauthmode from ic->ic_bss->ni_authmode. Enter
the RUN state through ieee80211_create_ibss instead of
ieee80211_new_state(IEEE80211_S_RUN). To sync BSSID in ad hoc
mode, use ieee80211_sta_join() instead of
ieee80211_new_state(IEEE80211_S_RUN). From FreeBSD.
Configure the firmware to obey IEEE80211_F_DROPUNENC.
As we change to state RUN in STA mode, generate a link-status
message on the routing socket with a call to ieee80211_notify_node_join()
instead of calling rt_ifmsg directly.
Run normal net80211 processing (ieee80211_newstate) on the ->RUN
transition.
CIS MAC only on error.
(NetBSD these days tries to read the MAC address from the PCMCIA
CIS. Prism cards made by Senao set the MAC in every PCMCIA CIS to
00:02:6f:00:02:15. In a network of Senao cards, this causes MAC
duplication.)
subroutine wi_txcmd_wait from wi_cmd and wi_stop.
This stops wi from griping, "wi0: command timed out, cmd=0x10b,
arg=0x0", when we down/up the interface. Thanks to Pavel Cahyna
for reporting this bug.
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.
wi_read_rid(sc, rid, &val, &buflen) == 0 && buflen == sizeof(val),
become wi_read_xrid calls
wi_read_xrid(sc, rid, &val, sizeof(val)) == 0.
If the actual RID length is different from the expected RID length,
wi_read_rid prints to the log.
are at the end of the node queue. Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver. Every node in the table with ni_refcnt=0
is eligible to be garbage-collected. The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now. A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.
While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
* 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.
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.
* 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.