Commit Graph

211945 Commits

Author SHA1 Message Date
Enji Cooper
d208c8fa3f Replace QUADFMT with %ju and QUADXFMT with %jx and cast values with uintmax_t
This will cure some -Wformat warnings

MFC after: 1 week
Reported by: clang, gcc
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:10:37 +00:00
Enji Cooper
70e366f272 Bump WARNS to 6
MFC after: 1 month
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:08:09 +00:00
Enji Cooper
92f7f8fb62 Fix up r299769
Similar to r299802, it was noted that using nitems on scalar pointers is
invalid.

Use strdup instead of malloc + strlcpy (which is what the old code was doing
anyhow).

MFC after: 1 week
Pointyhat to: ngie
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:05:28 +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
Enji Cooper
4e312050f0 Replace malloc + memset(.., 0, ..) with calloc calls
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:02:55 +00:00
Enji Cooper
2501437203 Fix up both r299764 and r299770
nitems was wrong too, as it was being tested against a pointer instead of a buffer on
the stack.

Since the old code was just doing malloc, then strlcpy'ing the contents of the source
buffer into the destination buffer, replace it all with a call to strdup..

Reported by: bde
MFC after: 1 week
X-MFC with: r299764, r299770
Supersized Duncecap to: ngie
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:01:23 +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
Jared McNeill
292e26ba55 Add pmic (AXP813) child node to r_rsb for Sinovoip BananaPi BPI-M3. 2016-05-14 23:36:00 +00:00
Konstantin Belousov
56e61f57b0 Eliminate pvh_global_lock from the amd64 pmap.
The only current purpose of the pvh lock was explained there
On Wed, Jan 09, 2013 at 11:46:13PM -0600, Alan Cox wrote:
> Let me lay out one example for you in detail.  Suppose that we have
> three processors and two of these processors are actively using the same
> pmap.  Now, one of the two processors sharing the pmap performs a
> pmap_remove().  Suppose that one of the removed mappings is to a
> physical page P.  Moreover, suppose that the other processor sharing
> that pmap has this mapping cached with write access in its TLB.  Here's
> where the trouble might begin.  As you might expect, the processor
> performing the pmap_remove() will acquire the fine-grained lock on the
> PV list for page P before destroying the mapping to page P.  Moreover,
> this processor will ensure that the vm_page's dirty field is updated
> before releasing that PV list lock.  However, the TLB shootdown for this
> mapping may not be initiated until after the PV list lock is released.
> The processor performing the pmap_remove() is not problematic, because
> the code being executed by that processor won't presume that the mapping
> is destroyed until the TLB shootdown has completed and pmap_remove() has
> returned.  However, the other processor sharing the pmap could be
> problematic.  Specifically, suppose that the third processor is
> executing the page daemon and concurrently trying to reclaim page P.
> This processor performs a pmap_remove_all() on page P in preparation for
> reclaiming the page.  At this instant, the PV list for page P may
> already be empty but our second processor still has a stale TLB entry
> mapping page P.  So, changes might still occur to the page after the
> page daemon believes that all mappings have been destroyed.  (If the PV
> entry had still existed, then the pmap lock would have ensured that the
> TLB shootdown completed before the pmap_remove_all() finished.)  Note,
> however, the page daemon will know that the page is dirty.  It can't
> possibly mistake a dirty page for a clean one.  However, without the
> current pvh global locking, I don't think anything is stopping the page
> daemon from starting the laundering process before the TLB shootdown has
> completed.
>
> I believe that a similar example could be constructed with a clean page
> P' and a stale read-only TLB entry.  In this case, the page P' could be
> "cached" in the cache/free queues and recycled before the stale TLB
> entry is flushed.

TLBs for addresses with updated PTEs are always flushed before pmap
lock is unlocked.  On the other hand, amd64 pmap code does not always
flushes TLBs before PV list locks are unlocked, if previously PTEs
were cleared and PV entries removed.

To handle the situations where a thread might notice empty PV list but
third thread still having access to the page due to TLB invalidation
not finished yet, introduce delayed invalidation.  Comparing with the
pvh_global_lock, DI does not block entered thread when
pmap_remove_all() or pmap_remove_write() (callers of
pmap_delayed_invl_wait()) are executed in parallel.  But _invl_wait()
callers are blocked until all previously noted DI blocks are leaved,
thus ensuring that neccessary TLB invalidations were performed before
returning from pmap_remove_all() or pmap_remove_write().

See comments for detailed description of the mechanism, and also for
the explanations why several pmap methods, most important
pmap_enter(), do not need DI protection.

Reviewed by:	alc, jhb (turnstile KPI usage)
Tested by:	pho (previous version)
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D5747
2016-05-14 23:35:11 +00:00
Jared McNeill
eceba010ba Add and enable Allwinner RSB and AXP81x power management IC drivers. 2016-05-14 23:34:57 +00:00
Jared McNeill
ceba82fdf5 Add a basic driver for X-Powers AXP813 and AXP818 power management ICs.
This driver simply installs a shutdown event handler for handling
RB_POWEROFF at shutdown. Tested on a Sinovoip BananaPi BPI-M3.
2016-05-14 23:33:57 +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
Pedro F. Giffuni
5728318b35 Avoid NULL de-references.
CID:		271079
Obtained from:	NetBSD
MFC after:	2 weeks.
2016-05-14 23:32:03 +00:00
Enji Cooper
4a2b63d5bb Convert tok from enum tok to int32_t in function calls
get_token(..) returns int32_t, not enum tok, and in many cases tests for items
not in enum tok (e.g. '('). Make the typing consistent with get_token, which
includes a domino effect of changing enum tok to int32_t.

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-14 23:29:41 +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
Jared McNeill
4b9a54a9fc Add a driver for the Allwinner Reduced Serial Bus (RSB).
The RSB controller speaks a simplified two wire protocol at speeds up to
20MHz. It is used on sun8i and sun9i family SoCs to communicate with
power management ICs.

RSB isn't really I2C or SMBus, but the driver exposes an iicbus interface
to simplify power management IC drivers (which may need to support both
RSB and I2C connectivity).
2016-05-14 23:27:54 +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
Jared McNeill
472c6f0685 Add node for A83T NMI interrupt controller. 2016-05-14 23:22:52 +00:00
Enji Cooper
5413861b16 Use a consistent errno save/restore pattern before running strtoul
- Save errno
- Set errno to 0
- Call strtoul
- Test errno (optional, but many calls to strtoul did this afterwards)

Some of the code was setting errno = 0 after calling strtoul, not setting
errno = 0, or setting errno to saved_errno after the call, but before the
test. These all have unwanted behavioral side-effects, depending on the
initial value of errno and whether or not the input to strtoul was correct
or incorrect.

MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-14 23:22:38 +00:00
Pedro F. Giffuni
365cb451d3 routed(8): Use arc4random.
CID:		1305962
Obtained from:	NetBSD (CVS Rev. 1.34, Itojun)
2016-05-14 23:22:19 +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
Enji Cooper
2c0046434b Do minimal work necessary to cure a -Wunused-but-set-variable warning from gcc
How errno is saved before and restored after strtoul calls needs a rethink

MFC after: 1 week
Reported by: gcc 5.x
Sponsored by: EMC / Isilon Storage Division
2016-05-14 23:13:23 +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
c41639c2b7 [bwn] add in the new phy common and utils files.
They're not yet used by included code; that'll come next.
2016-05-14 23:08:34 +00:00
Pedro F. Giffuni
0b279f8c94 routed: Fix use after free.
For the multihomed case, ifp be used after being freed. NULL the value
after freeing it and avoid getting into the branch without reassigning
a new value.

CID:		272671
Obtained from:	NetBSD
MFC after:	2 weeks
2016-05-14 23:07:26 +00:00
Enji Cooper
54811dda50 Fix up r299764
I meant to use nitems, not sizeof(..) with the destination buffer. Using sizeof(..)
on a pointer will always truncate the output in the destination buffer incorrectly

Pointyhat to: ngie
MFC after: 1 week
X-MFC with: r299764
Sponsored by: EMC / Isilon Storage Division
2016-05-14 22:43:07 +00:00
Enji Cooper
896f12fec1 Use the size of the destination buffer instead of the malloc size, repeated, in order
to mute a -Wstrlcpy-strlcat-size warning

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-14 22:40:35 +00:00
Pedro F. Giffuni
562c5a82cb routed(8): use NULL instead of zero for pointers. 2016-05-14 22:40:08 +00:00
Enji Cooper
19ffd5ecda Mute sign compare warning by casting rc to u_int to match nbindings' type
rc cannot be negative -- that was already tested for earlier on in
the function

MFC after: 1 week
Reported by: clang, gcc
Sponsored by: EMC / Isilon Storage Division
2016-05-14 22:29:11 +00:00
Enji Cooper
715e3b39a6 Fix logically dead code pointed out by clang/Coverity
parse_context, parse_user_security: test for validity of results from
parse_ascii(..) with by casting to int32_t and comparing to -1; comparing
unsigned types to negative values will always be false.

Reported by: clang, Coverity
CID: 1011432, 1011433
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-14 22:04:44 +00:00
Enji Cooper
81910adfc4 Fix theoretical buffer overflow issues in snmp_oid2asn_oid
Increase the size of `string` by 1 to account for the '\0' terminator. In the event
that `str` doesn't contain any non-alpha chars, i would be set to MAXSTR, and
the subsequent strlcpy call would overflow by a character.

Remove unnecessary `string[i] = '\0'` -- this is already handled by strlcpy.

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-14 21:32:52 +00:00
Enji Cooper
78a780e3e5 Use the size of the destination buffer, not the source buffer.
Technically this is a no-op, but mute the clang warning in case the malloc call
above for fstring ever changes in the future

Reported by: clang
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 21:27:33 +00:00
Enji Cooper
6e229b2973 Mute -Wstrlcpy-strlcat-size warning by using nitems with the size of the buffer
This is a no-op as the malloc above set the size of the buffer to the size used
below, but this keeps things consistent in case the malloc call changes somehow.

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:58:34 +00:00
Enji Cooper
444991f1e6 Mark snmptoolctx unused in parse_authentication(..), parse_privacy(..),
parse_context(..), and parse_user_security(..).

MFC after: 1 week
Reported by: clang, gcc
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:33:42 +00:00
Enji Cooper
4a8c12cd34 parse_ascii: make count size_t to mute a -Wsign-compare issue
count is always unsigned.

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:31:12 +00:00
Enji Cooper
9a3ebeefc0 Sort variables in parse_ascii(..) per style(9)
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:28:23 +00:00
Enji Cooper
031987d916 Use calloc instead of memset(.., 0, ..) + malloc
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:25:14 +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