Commit Graph

125 Commits

Author SHA1 Message Date
Landon J. Fuller
1728aef23d bhnd(4): Implement NVRAM support required for PMU bring-up.
- Added a generic bhnd_nvram_parser API, with support for the TLV format
  used on WGT634U devices, the standard BCM NVRAM format used on most
  modern devices, and the "board text file" format used on some hardware
  to supply external NVRAM data at runtime (e.g. via an EFI variable).

- Extended the bhnd_bus_if and bhnd_nvram_if interfaces to support both
  string-based and primitive data type variable access, required for
  common behavior across both SPROM and NVRAM data sources.
- Extended the existing SPROM implementation to support the new
  string-based NVRAM APIs.

- Added an abstract bhnd_nvram driver, implementing the bhnd_nvram_if
  atop the bhnd_nvram_parser API.
- Added a CFE-based bhnd_nvram driver to provide read-only access to
  NVRAM data on MIPS SoCs, pending implementation of a flash-aware
  bhnd_nvram driver.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7489
2016-08-16 21:32:05 +00:00
Adrian Chadd
4594925d80 [bwn] don't use a 1MB CCK RTS frame for 11a OFDM transmissions. 2016-06-06 07:09:02 +00:00
Adrian Chadd
14b258b806 [bwn] Add missing firmware release calls.
This trips me up whenever I'm fooling around with partially supported
NICs that fail to fully attach or initialise - the firmware gets loaded
and references, but something fails - and the firmware references
aren't cleaned up.
2016-06-05 07:56:28 +00:00
Adrian Chadd
4bfbed7264 [bwn] Enable PHY-LP 5GHz support for the one NIC I have tested it on so far.
After perusing the PHY-LP code (don't ask why; honest) I discovered that
it /has/ 5GHz support - but it's not ever used.  I found one NIC - a
BCM4312 w/ pci id 0x4315 - which advertised dual-band PHY-LP support.

Turns out it works.

Whilst here, move up the support bit logging code so I can use it
to debug this.

Tested:

* BCM4312 (pci id 0x4315); 5GHz STA operation
2016-06-05 07:55:21 +00:00
Adrian Chadd
59f341f8bc [bwn] complain usefully if a PHY-N PHY is detected with no support is compiled in.
Log something other than "error 6" if the attach fails because the
GPL PHY-N code isn't included.
2016-06-05 07:51:36 +00:00
Adrian Chadd
40dcddfcca [bwn] begin separating out the attach path from the SIBA specific bits.
* convert phy_getinfo() to take a "gmode" flag, rather than the siba
  TGSHIGH flags and then check for 2GHz.  This should ensure that
  gmode is set correctly even on DUALPHY NICs.
* move the siba_powerup() call and the TGSHIGH decoding into a
  call to bwn_is_bus_siba(), and return an error if it's called
  on anything else.  We don't yet do anything else, but when we do..

Tested:

* BCM4322, 11a STA
2016-05-24 04:58:58 +00:00
Adrian Chadd
972459a6ca [bwn] add BCM43225 to the BHND device list.
This is all for the bhnd(4) work in progress.  It's enough to probe/attach
all the bhnd internals, but we're missing OTP support and some cleanup
code.  And, well, all the rest of the bhnd(4) migration.

So no, this won't give you BCM43225 support.  Sorry!
2016-05-24 04:55:00 +00:00
Adrian Chadd
a7978cf36d [bwn] add extra debugging for non-SIBA devices.
This is a no-op at the present moment, but will eventually remind me
where the SIBA specific demons lie.

Tested:

* BCM4322, STA mode
2016-05-24 01:20:30 +00:00
Andriy Voskoboinyk
4328ca5a21 wi: fix a typo.
The max size of bitmask is IEEE80211_MODE_BYTES, not IEEE80211_MODE_MAX.

Reuse it in bwn(4) while I'm here.

Noticed by:	kevlo
2016-05-20 08:58:06 +00:00
Adrian Chadd
0550ee2477 [bwn] quieten the "invalid firmware state".
That pops up in the rev 5xx / 6xx microcode on the later cores
(4312, 4322.) I'm not sure why this is happening yet and I'll
dig into it, but Linux b43 does the same thing.
2016-05-19 05:09:20 +00:00
Adrian Chadd
4afc7f78aa [bwn] program in the MAC capabilities somewhere where later microcode
expects it.

Obtained from:	Linux b43
2016-05-19 05:06:48 +00:00
Adrian Chadd
a5d89c93cc [bwn] add extra debugging. 2016-05-19 04:29:25 +00:00
Adrian Chadd
fefdffc6a5 [bwn] toggle the PHY clock during chip reset.
Tested:

* BCM4311, STA mode
* BCM4312, STA mode
* BCM4321, STA mode
* BCM4322, STA mde
2016-05-19 04:28:49 +00:00
Adrian Chadd
867d6884dd [bwn] enable dual-phy on BCM4322MC.
Tested (with later commits):

* BCM4322MC, STA mode, 2G + 5G
2016-05-19 04:23:54 +00:00
Adrian Chadd
923840c646 [bwn] rename TGS low registers to be consistent with naming scheme. 2016-05-19 04:22:58 +00:00
Adrian Chadd
a74bf02069 [bwn] add initial 5xx firmware API support
* Add the new TX/RX frame formats;
* Use the right TX/RX format based on the frame info;
* Disable the 5xx firmware check, since now it should
  somewhat work (but note, we don't yet use it unless
  you manually add ucode11/initvals11 from the 5.x driver
  to bwn-kmod-firmware;

* Misc: update some comments/debugging now I know what's
  actually going on.

Tested:

* BCM4321MC, STA mode, both 4xx and 666 firmware, DMA mode

TODO:

* The newer firmware ends up logging "warn: firmware state (0)";
  not sure yet what's going on there.  But, yes, it still works.
  I'm committing this via a BCM4321MC, 11a station, firmware
  rev 666.

Obtained from:	Linux b43 (TX/RX descriptor format for 5xx)
2016-05-18 05:56:25 +00:00
Adrian Chadd
3095d9fbc6 [bwn] correctly calculate RSSI level.
Tested:

* BCM4311, PHY-G, STA mode
* BCM4312, PHY-LP, STA mode
* BCM4321, PHY-N, STA moe
2016-05-17 21:24:10 +00:00
Adrian Chadd
0a27537893 [bwn] print out a very obvious notice that GPLv2 code is compiled in if it is. 2016-05-17 20:21:39 +00:00
Adrian Chadd
f629a23855 [bwn] always allocate maximum size txhdr entries; prepare for fw 598
* always allocate maximum size txhdr entries
* set the right rx header offset/framesize based on firmware

This still isn't what's completely required for fw 598 support; there's
more to come.

Tested:

* Apple BCM94321MC 11abgn NIC, 11a STA mode, firmware version 4xx.

Obtained from:	DragonflyBSD (txhdr entry sizing), fw 598 RX header size (linux b43)
2016-05-17 20:18:23 +00:00
Adrian Chadd
ac31839dd2 [bwn] Add PHY-N call hooks. 2016-05-17 07:12:00 +00:00
Adrian Chadd
98d0edeff0 [bwn] add PHY-N glue.
It defaults to stubbing out PHY-N bindings, but it can be flipped to
call into the b43 PHY-N port.
2016-05-17 07:11:12 +00:00
Adrian Chadd
a971082444 [bwn] add opt_wlan.h / opt_bwn.h for build-time control
This is a separate commit as I have local changes to bwn for now and
this needs a manual merge/commit.

Sponsored by:	Palm Springs
2016-05-16 22:57:36 +00:00
Adrian Chadd
5025b8d583 [bwn] add opt_wlan.h and opt_bwn.h so we can enable bwn debugging as appropriate.
Tested:

* BCM4322, STA mode (11a)

Sponsored by:	Palm Springs
2016-05-16 22:56:45 +00:00
Adrian Chadd
5217d1308f [bwn] switch to ieee80211_add_channel()
This is an updated version of D6140.

Tested:

* BCM4321 11abgn, STA mode (11a)

Submitted by:	avos
Differential Revision:	https://reviews.freebsd.org/D6140
2016-05-16 22:39:17 +00:00
Adrian Chadd
f52cfd7fdf [bwn] check DUALPHY; add BCM4322 to the don't-override list.
* DUALPHY in TGSHIGH tells us there's a phy that is dualband, rather than
  two separate PHYs/MACs (which we almost but don't quite yet support.)
  Use it.

* Add the BCM4322 PCI ID to the list of devices we don't override.
  This means the 2g/5g flags are preserved, and thus we get 5GHz
  operation (with N-PHY, of course.)

Tested:

* BCM4311, STA mode (11bg)
* BCM4312, STA mode (11bg)
* BCM4321, STA mode (11abg)

Sponsored by:	Palm Springs
2016-05-16 20:26:30 +00:00
Adrian Chadd
16ff0ae77f [bwn] use contigmalloc to allocate descriptors.
We can't assume malloc() returns physically contiguous memory.

Submitted by:	Imre Vadasz <imre@vdsz.com>
Obtained from:	DragonflyBSD
2016-05-16 04:03:43 +00:00
Adrian Chadd
1e383b4bca [bwn] remove N-PHY registers for now.
I've submitted an alternative proposal to -core about just importing
the (converted) GPL PHY code in an alternate directory under sys/gnu/
so I don't have to rewrite it all to be BSD licenced.
2016-05-15 14:39:41 +00:00
Adrian Chadd
e542607041 [bwn] add DUALPHY; this may be useful for PHY-N and later dual-phy probing.
Obtained from:	Landon Fuller <landonf@landonf.org>
2016-05-15 07:02:34 +00:00
Adrian Chadd
882abba02f [bwn] commit the N-PHY register set.
Obtained from:	Linux b43 (register definitions.)
2016-05-15 06:11:40 +00:00
Adrian Chadd
b327475b51 [bwn] add the full suite of SPROM flags
Obtained from:	Linux b43
2016-05-15 00:03:14 +00:00
Adrian Chadd
2ad2bda1a1 [bwn] handle core rev 12, we can mostly do that new. 2016-05-14 23:50:44 +00:00
Adrian Chadd
c3d021a603 [bwn] disable 11na channel setup for now, since we definitely, positively
don't do 11na yet.
2016-05-14 23:50:15 +00:00
Adrian Chadd
45606ae1d5 [bwn] fill out phyctl_1 fields for N-PHY (and later, eventually.)
N-PHY and later require a lot more plcp specific setup for the PHY
to know what to transmit.  I've been spoilt by the atheros, intel
and realtek parts where you don't have to hand-assemble the PLCP
but .. well, apparently Broadcom require a lot more work.

This, and PHY-N itself, was the last major missing bit to get 11a
OFDM transmit to work.  Without this, CCK transmit worked but
OFDM transmit would always fail (with stat.phy_err set to 0x80.)

I have no idea what 0x80 is, and I went mad reading the broadcom
vendor driver to try and figure it out.

Tested:

* BCM4312 (PHY-LP)
* BCM4321 (PHY-N), 11a, 11bg.
2016-05-14 23:48:26 +00:00
Adrian Chadd
80c3f55282 [bwn] set the 5ghz transmit flag for 5ghz transmit.
Turns out trying to do 11a transmit without this set works poorly.
2016-05-14 23:45:47 +00:00
Adrian Chadd
e9e6f47e20 [bwn] disable writing slottime timing out to improve performance.
this is from b43 linux, there's a comment in there which notes
one nic family suffers performance degredation with this being set.
2016-05-14 23:45:16 +00:00
Adrian Chadd
7fb49b1e66 [bwn] make rf-kill work for PHY-N. 2016-05-14 23:44:30 +00:00
Adrian Chadd
d54c38a3e9 [bwn] decode the RX RSSI for PHY-N.
I'm still figuring this out, but it at least works somewhat.
2016-05-14 23:43:43 +00:00
Adrian Chadd
6553a04cad [bwn] use the new enum type. 2016-05-14 23:43:05 +00:00
Adrian Chadd
1fb1f6f918 [bwn] debugging changes.
Now that I have 5g working on PHY-N, that "changing band" message
happens quite a bit.  Make it a debug log, not an explicit printf.
2016-05-14 23:42:37 +00:00
Adrian Chadd
53a9eeb782 [bwn] Explicitly only work for SIBA parts; add some placeholder debugging.
Set phy-full-init always to 1 for now; PHY-N supports being able to do
partial init for things like fast channel changes but I'm going to
ignore it all.
2016-05-14 23:41:28 +00:00
Adrian Chadd
cd39b27e70 [bwn] missed commit! 2016-05-14 23:38:51 +00:00
Adrian Chadd
1ea968180f [bwn] add new types, prepare for PHY-N; prepare for rev 5xx firmware.
This is a big commit with a whole lot of little changes, all in
preparation for PHY-N and rev 5xx firmware.

* add in a write method that does an explicit flush
* change the txpwr recalc type to return an enum, versus just an int.
* add in PHY-N RX frame format bits, for decoding RX RSSI and such
* add in the header space calculation for rev 5xx firmware.
* add in a whole bunch of new types that the newer and 5g phy code
  needs.  Notably, broadcom has a split 5GHz band concept -
  5G-Low, 5G(-Mid) and 5G-High.  I kept encountering this at my
  day job and wondered whether it was just some marketing thing.
  Nope, turns out it isn't; it's an actual PHY thing.

* Add a "am I a siba bus device" method, that returns true.
  The aim is to convert all the siba/bhnd specific bits in if_bwn
  over to be wrapped in this check, so when landon does a BHND
  drive through he knows which bits need updating.

Now, this the /complete/ set of changes for rev 5xx firmware.
Notably, the TX descriptor handling isn't at all done yet and the
format has changed.  So don' try blindly flipping this on just yet!
2016-05-14 23:38:21 +00:00
Adrian Chadd
36fcc18d80 [bwn] add an implementation of "cordic" and imaginary math.
This is used by the PHY-N code.

Obtained from:	http://bcm-v4.sipsolutions.net/802.11/PHY/Cordic
2016-05-14 23:33:13 +00:00
Adrian Chadd
9193516e94 [bwn] TX logging / completion fixes
* Log the per-completion status out if requested
* If we get a PHY failure, the retrycnt is set to 0 and ack=0, so
  the logic was incorrect.  So, for ack=0, ensure we don't log
  a retrycnt of 0 (or rate control breaks) or a negative retrycnt
  (or rate control also breaks.)

Tested:

* BCM4321 (11abgn N-PHY), BCM4312 (LP-PHY)
2016-05-14 23:27:55 +00:00
Adrian Chadd
0cfd65ecdc [bwn] add in new microcode and phy initval information.
This is required for PHY-N and later hardware.

Tested:

* BCN4321 (11abgn), PHY-N
2016-05-14 23:23:50 +00:00
Adrian Chadd
52bef765d7 [bwn] implement reset improvements in preparation for PHY-N support
* Ensure we set 20MHz wide channels (hard-coded) for PHY-N.
* Change the core rese tto take a flag saying "gmode" vesus uint32_t
  flags.  This is important for BCMA support where the "gmode" bit
  is different.
* Refactor out the mac-phy clock reset routine (usde by PHY-N).

Tested:

* BCM4321 (PHY-N), BCM4312 (PHY-LP)

TODO:

* Checkpoint test on PHY-G hardware, just to check.
2016-05-14 23:20:46 +00:00
Adrian Chadd
dc94ad18cd [bwn] use the shared bwn_sqrt() routine. 2016-05-14 23:13:44 +00:00
Adrian Chadd
baed0627b7 [bwn] disable bgscan for now.
I'll re-enable this when I've verified all of the locking / concurrency
access to the hardware is "right".

Tested:

* BCM4321 (PHY-N), BCM4312 (PHY-LP)
2016-05-14 23:10:47 +00:00
Adrian Chadd
c68e865e8f [bwn] begin migrating PHY common routines into if_bwn_phy_common.[ch].
This isn't compiled in yet; so some code here duplicates what
is in the existing code.  I'll migrate it all out in subsequent
commits.

Obtained from:	b43 (definitions), bcm-v4 specifications website
2016-05-14 20:11:48 +00:00
Adrian Chadd
020cb2200b [bwn] add Q52 macros.
The PHY-N code uses a different format for gain values, so these macros
are used for converting to/from and print out values.
2016-05-14 20:09:37 +00:00