Commit Graph

212 Commits

Author SHA1 Message Date
Dimitry Andric
bab8274c09 Use bool for one-bit wide bit-fields
A signed one-bit wide bit-field can take only the values 0 and -1. Clang
16 introduced a warning that "implicit truncation from 'int' to a
one-bit wide bit-field changes value from 1 to -1". Fix the warnings by
using C99 bool.

Reported by:	Clang 16
Reviewed by:	emaste, jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D39705
2023-04-25 19:26:03 +02:00
John Baldwin
51776a92ca wpi: Remove unused devclass argument to DRIVER_MODULE. 2022-05-06 15:46:57 -07:00
Mark Johnston
6d042d7c86 wpi: Fix a lock leak in an error path in wpi_run()
PR:		258243
Reported by:	dinghao.liu@zju.edu.cn
MFC after:	1 week
2021-09-10 10:03:51 -04:00
Mateusz Guzik
391a27c41d wpi: clean up empty lines in .c and .h files 2020-09-01 21:46:27 +00:00
Hans Petter Selasky
b65f813c1a Widen EPOCH(9) usage in PCI WLAN drivers.
Make sure all occurrences of ieee80211_input_xxx() in sys/dev are
covered by a network epoch section. Do not depend on the interrupt
handler nor any taskqueues being in a network epoch section.

This patch should unbreak the PCI WLAN drivers after r357004.

Pointy hat:	glebius@
Sponsored by:	Mellanox Technologies
2020-01-30 10:28:01 +00:00
Andriy Voskoboinyk
786ac7035f Fix ieee80211_radiotap(9) usage in wireless drivers:
- Alignment issues:
 * Add missing __packed attributes + padding across all drivers; in
most places there was an assumption that padding will be always
minimally suitable; in few places - e.g., in urtw(4) / rtwn(4) -
padding was just missing.
 * Add __aligned(8) attribute for all Rx radiotap headers since they can
contain 64-bit TSF timestamp; it cannot appear in Tx radiotap headers, so
just drop the attribute here. Refresh ieee80211_radiotap(9) man page
accordingly.

- Since net80211 automatically updates channel frequency / flags in
ieee80211_radiotap_chan_change() drop duplicate setup for these fields
in drivers.

Tested with Netgear WG111 v3 (urtw(4)), STA mode.

MFC after:	2 weeks
2019-03-11 01:27:01 +00:00
Adrian Chadd
9fbe631a1a [net80211] convert all of the WME use over to a temporary copy of WME info.
This removes the direct WME info access in the ieee80211com struct and instead
provides a method of fetching the data.  Right now it's a no-op but eventually
it'll turn into a per-VAP method for drivers that support it (eg iwn, iwm,
upcoming ath10k work) as things like p2p support require this kind of behaviour.

Tested:

* ath(4), STA and AP mode

TODO:

* yes, this is slightly stack size-y, but it is an important first step
  to get drivers migrated over to a sensible WME API.  A lot of per-phy things
  need to be converted to per-VAP before P2P, 11ac firmware, etc stuff shows up.
2018-01-02 00:07:28 +00:00
Andriy Voskoboinyk
f631357540 net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters
directly from the node.

- Use ni_txparms directly instead of calculating them manually every time
- Move M_EAPOL flag check upper; otherwise it may be skipped due to
'ucastrate' / 'mcastrate' check
- Use 'mgtrate' for control frames too (see ifconfig(8), mgtrate parameter)
- Add few more M_EAPOL checks where it was missing (zyd(4), ural(4),
urtw(4))
- Few unrelated cleanups

Tested with:
 - Intel 6205 (iwn(4)), STA mode;
 - WUSB54GC (rum(4)), HOSTAP mode + RTL8188EU (rtwn(4)), STA mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D9811
2017-02-26 20:49:35 +00:00
Andriy Voskoboinyk
3f3d4d6100 wpi: restore frame header before submitting an mbuf to
ieee80211_tx_complete()

This change allows to pass packet length to rate control modules and
fixes IFCOUNTER_OBYTES calculation.

Tested with Intel 3945BG, STA mode.
2016-10-08 20:41:08 +00:00
Andriy Voskoboinyk
f6930bec33 net80211: ieee80211_ratectl*: switch to reusable KPI
Replace various void * / int argument combinations with common structures:
- ieee80211_ratectl_tx_status for *_tx_complete();
- ieee80211_ratectl_tx_stats for *_tx_update();

While here, improve amrr_tx_update() for a bit:
1. In case, if receiver is not known (typical for Ralink USB drivers),
refresh Tx rate for all nodes on the interface.
2. There was a misuse:
- otus(4) sends non-decreasing counters (as originally intended);
- but ural(4), rum(4) and run(4) are using 'read & clear' registers
to obtain statistics for some period of time (and those 'last period'
values are used as arguments for tx_update()). If arguments are not big
enough, they are just discarded after the next call.

Fix: move counting into *_tx_update()
(now otus(4) will zero out all node counters after every tx_update() call)

Tested with:
- Intel 3945BG (wpi(4)), STA mode.
- WUSB54GC (rum(4)), STA / HOSTAP mode.
- RTL8188EU (urtwn(4)), STA mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D8037
2016-10-02 20:35:55 +00:00
Pedro F. Giffuni
4ed3c0e713 sys: Make use of our rounddown() macro when sys/param.h is available.
No functional change.
2016-04-30 14:41:18 +00:00
Andriy Voskoboinyk
5763d9db58 wpi: convert to ieee80211_add_channel() (mostly noop).
Tested with Intel 3945BG, STA / HOSTAP modes.
2016-04-29 22:43:11 +00:00
Andriy Voskoboinyk
bc502553a6 wpi: remove unused variable. 2016-04-29 21:38:36 +00:00
Andriy Voskoboinyk
86d9f8fc65 wpi, iwn: fix check in find_eeprom_channel()
Return correct eeprom_chan structure pointer for 7, 8, 11 and 12 5Ghz
channels.
2016-04-03 14:38:26 +00:00
Andriy Voskoboinyk
abd89aa292 wpi: remove internal taskqueue
- Replace sc_reinittask() by ieee80211_restart_all() (mostly the same).
- Revert r282377 (seems to be unneeded now).

Tested with Intel 3945BG, STA mode.

Differential Revision:	https://reviews.freebsd.org/D5056
2016-03-21 23:25:41 +00:00
Andriy Voskoboinyk
1c6b43df0a wpi, iwn: implement ic_getradiocaps method
This will allow to restore channel list after switching interface
to more restrictive regdomain.

Tested with Intel 3945BG (wpi) only.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4863
2016-01-12 00:24:40 +00:00
Andriy Voskoboinyk
ce036b5148 wpi, rum and urtwn: update copyright headers
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4489
2015-12-13 22:08:27 +00:00
Andriy Voskoboinyk
54b27b3583 wpi: ignore ic_update_promisc() call when device is not running
This change will fix kernel panic with uninitialized (zeroed)
RXON structure.

Tested with Intel 3945BG, IBSS mode.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4304
2015-11-30 17:16:51 +00:00
Andriy Voskoboinyk
7c2e8d335d wpi(4): import r289674
Switch PCI register reads from using magic numbers to using the names
defined in pcireg.h

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4185
2015-11-16 21:55:11 +00:00
Kevin Lo
b020e15ebd Remove BUS_DMA_NOWAIT from bus_dma_tag_create() invocations as it's
no valid flag there.
2015-10-21 06:23:57 +00:00
Adrian Chadd
d957a93abe net80211: move ieee80211_free_node() call on error from ic_raw_xmit() to ieee80211_raw_output().
This doesn't free the mbuf upon error; the driver ic_raw_xmit method is still
doing that.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3774
2015-10-12 04:55:20 +00:00
Adrian Chadd
940aa8080c wpi(4): add support for TX fragmentation.
Tested:

* Tested with Intel 3945BG, HOSTAP and STA modes

Differential Revision:	https://reviews.freebsd.org/D3770
2015-10-12 04:05:12 +00:00
Adrian Chadd
f7cd3e189c wpi(4): do not count failures twice for ic_raw_xmit().
Tested:

* Tested with Intel 3945BG, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3768
2015-10-11 02:00:08 +00:00
Adrian Chadd
823e17dbe1 wpi(4): move error handling upper (wpi_tx_data()/wpi_cmd2() -> wpi_raw_xmit()/wpi_transmit()).
Tested:

* Tested with Intel 3945BG, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3767
2015-10-11 01:58:50 +00:00
Adrian Chadd
431ebc90bf wpi(4): fix possible race between TX/RX threads.
Tested:

* Tested with Intel 3945BG, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3766
2015-10-11 01:56:46 +00:00
Adrian Chadd
19053a5448 wpi(4): do not allocate space for unused rings.
Tested:

* Tested with Intel 3945BG, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3765
2015-10-11 01:53:51 +00:00
Adrian Chadd
57c61f5d05 wpi(4): do not override iv_recv_mgmt() in non-adhoc modes.
Tested:

* Tested with Intel 3945BG, IBSS and STA modes

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3764
2015-10-11 01:50:54 +00:00
Adrian Chadd
525a3d47d8 wpi(4): use more correct types.
This change fixes some amount of -Wsign-conversion and -Wconversion warnings
and sets correct sizes for some variables (as a result, some loop counters
were touched too).

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3763
2015-10-11 01:31:18 +00:00
Adrian Chadd
fbcf1662de wpi(4): check size before transmitting frames
In addition to https://bz-attachments.freebsd.org/attachment.cgi?id=156112;
fixes https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=144987.

Tested:

* Tested with Intel 3945BG, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3762
2015-10-08 07:22:40 +00:00
Adrian Chadd
4c09e592e6 wpi(4): fix some byteorder conversions
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3761
2015-10-08 07:21:36 +00:00
Adrian Chadd
19ea23a08d wpi(4): fix 'maybe uninitialized' warnings
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3760
2015-10-08 07:20:22 +00:00
Adrian Chadd
859f6ddcdc wpi(4): add some branch predictions.
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3759
2015-10-08 07:18:28 +00:00
Adrian Chadd
c34db4207c wpi(4): drop unnecessary locking in wpi_set_pslevel().
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3758
2015-10-08 07:17:11 +00:00
Adrian Chadd
753ca9ef4f wpi(4): remove software queues
Use direct dispatch into the destination hardware ring instead of using
a staging queue.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3757
2015-10-08 00:52:41 +00:00
Adrian Chadd
210ab3c258 net80211: drop ieee80211_beacon_offsets parameter from ieee80211_beacon_alloc() and ieee80211_beacon_update()
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3659
2015-10-03 22:12:25 +00:00
Adrian Chadd
bc813c40bf net80211: drop redundant 3rd parameter from iv_key_set().
The MAC can be fetched from the key struct.

I added the ndis updates to make it compile.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3657
2015-10-03 21:48:27 +00:00
Adrian Chadd
cc43c3e8a7 Don't duplicate checks; net80211 now does this for us.
Submitted by:	s3erios@gmail.com
2015-09-26 13:22:44 +00:00
Adrian Chadd
0cf00015be net80211: include one copy of struct ieee80211_beacon_offsets into ieee80211vap
Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3658
2015-09-22 06:34:07 +00:00
Gleb Smirnoff
7a79cebfba Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.

Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.

Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:

- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
  the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
  driver about any changes: number of wlan(4) interfaces, number of them
  in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
  driver experiences errors and can not attribute them to any specific
  interface, driver updates ic_oerrors or ic_ierrors counters.

Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
  now provided by net.wlan.devices sysctl.

Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.

Reviewed by:	adrian
Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2015-08-27 08:56:39 +00:00
Adrian Chadd
2cb71df183 Convert more ifp->if_softc -> ic->ic_softc.
These should be a big no-op.

Tested:

* make universe
2015-08-17 23:44:38 +00:00
Adrian Chadd
ba2c1fbc03 Revert the wifi ifnet changes until things are more baked and tested.
* 286410
* 286413
* 286416

The initial commit broke a variety of debug and features that aren't
in the GENERIC kernels but are enabled in other platforms.
2015-08-08 01:10:17 +00:00
Gleb Smirnoff
79d2c5e857 Change KPI of how device drivers that provide wireless connectivity interact
with the net80211 stack.

Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.

Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:

- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
  the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
  driver about any changes: number of wlan(4) interfaces, number of them
  in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
  driver experiences errors and can not attribute them to any specific
  interface, driver updates ic_oerrors or ic_ierrors counters.

Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
  now provided by net.wlan.devices sysctl.

Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to Olivier Cochard, gjb@, mmoll@,
op@ and lev@, who also participated in testing. Details here:

https://wiki.freebsd.org/projects/ifnet/net80211

Still, drivers: ndis, wtap, mwl, ipw, bwn, wi, upgt, uath were not
tested. Changes to mwl, ipw, bwn, wi, upgt are trivial and chances
of problems are low. The wtap wasn't compilable even before this change.
But the ndis driver is complex, and it is likely to be broken with this
commit. Help with testing and debugging it is appreciated.

Differential Revision:	D2655, D2740
Sponsored by:	Nginx, Inc.
Sponsored by:	Netflix
2015-08-07 11:43:14 +00:00
Gleb Smirnoff
272f6ade9b Change three methods in struct ieee80211com, namely ic_updateslot,
ic_update_mcast and ic_update_promisc, to pass pointer to the ieee80211com,
not to the ifnet.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2015-05-25 19:53:29 +00:00
Gleb Smirnoff
59686fe935 Set ic_softc in all 802.11 drivers. Not required right now, but will be
used quite soon.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2015-05-25 18:50:26 +00:00
Adrian Chadd
b66af287ad Update wpi(4) to use the new mgmt RX API. 2015-05-25 17:06:52 +00:00
Gleb Smirnoff
c8550c0278 Make net80211 drivers supply their device name to the net80211 layer, so
that the latter doesn't need to go through struct ifnet to get their name.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2015-05-25 13:51:13 +00:00
Adrian Chadd
3077c104f5 [iwn] Do not filter control frames in monitor mode.
PR:		kern/197143
Submitted by:	 Andriy Voskoboinyk <s3erios@gmail.com>
2015-05-03 23:40:12 +00:00
Adrian Chadd
a20c9aff42 Handle properly IBSS merges (works with patch from bug 199632).
PR:		kern/197143
Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
2015-05-03 23:39:44 +00:00
Adrian Chadd
5cacb17fa2 Fix various powersave races + optimize tx/rx pointer update when powersave is off.
PR:		kern/197143
Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
2015-05-03 23:39:02 +00:00
Adrian Chadd
9b7cc717ed [iwn?] Use correct sequence numbers with non-QoS STAs.
PR:		kern/197143
Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
2015-05-03 23:38:32 +00:00