Commit Graph

110351 Commits

Author SHA1 Message Date
Svatopluk Kraus
aa0d25b7a1 INTRNG - update gpio pin capabilities according to r299166.
Note that the updated comment is valid only for INTRNG. This should not
be a problem as not INTRNG code is left in place for debugging reasons
only and should not be used anymore. It's anticipated that this old
code will be removed soon.
2016-05-08 08:57:50 +00:00
Mateusz Guzik
0cfe1a1fec fd: assert dropped filedesc lock in fdcloseexec 2016-05-08 03:26:12 +00:00
Rick Macklem
de2413b95e Don't increment srvrpccnt[] for the NFSv4.1 operations.
When support for NFSv4.1 was added to the NFS server, it broke
the server rpc count stats, since newnfsstats.srvrpccnt[] doesn't
have entries for the new NFSv4.1 operations.
Without this patch, the code was incrementing bogus entries in
newnfsstats for the new NFSv4.1 operations.
This patch is an interim fix. The nfsstats structure needs to be
updated and that will come in a future commit.

Reported by:	cem
MFC after:	2 weeks
2016-05-07 22:45:08 +00:00
Mark Johnston
20b5f02214 Clean up callers of nd6_prelist_add().
nd6_prelist_add() sets *newp if and only if it is successful, so there's no
need for code that handles the case where the return value is 0 and
*newp == NULL. Fix some style bugs in nd6_prelist_add() while here.

MFC after:	1 week
2016-05-07 03:41:29 +00:00
Mark Johnston
83631b16a7 Remove two useless local variables from prelist_update().
MFC after:	1 week
2016-05-07 03:32:29 +00:00
John Baldwin
dc9643853d Use DDP to implement zerocopy TCP receive with aio_read().
Chelsio's TCP offload engine supports direct DMA of received TCP payload
into wired user buffers.  This feature is known as Direct-Data Placement.
However, to scale well the adapter needs to prepare buffers for DDP
before data arrives.  aio_read() is more amenable to this requirement than
read() as applications often call read() only after data is available in
the socket buffer.

When DDP is enabled, TOE sockets use the recently added pru_aio_queue
protocol hook to claim aio_read(2) requests instead of letting them use
the default AIO socket logic.  The DDP feature supports scheduling DMA
to two buffers at a time so that the second buffer is ready for use
after the first buffer is filled.  The aio/DDP code optimizes the case
of an application ping-ponging between two buffers (similar to the
zero-copy bpf(4) code) by keeping the two most recently used AIO buffers
wired.  If a buffer is reused, the aio/DDP code is able to reuse the
vm_page_t array as well as page pod mappings (a kind of MMU mapping the
Chelsio NIC uses to describe user buffers).  The generation of the
vmspace of the calling process is used in conjunction with the user
buffer's address and length to determine if a user buffer matches a
previously used buffer.  If an application queues a buffer for AIO that
does not match a previously used buffer then the least recently used
buffer is unwired before the new buffer is wired.  This ensures that no
more than two user buffers per socket are ever wired.

Note that this feature is best suited to applications sending a steady
stream of data vs short bursts of traffic.

Discussed with:	np
Relnotes:	yes
Sponsored by:	Chelsio Communications
2016-05-07 00:33:35 +00:00
John Baldwin
826c2372c5 Set the correct vnet in TOE event handlers.
Differential Revision:	https://reviews.freebsd.org/D6152
2016-05-06 23:49:10 +00:00
John Baldwin
1963070cd3 Restore name=value format of PCI location strings.
When devctl was added, the location string for PCI devices was changed to
use the PCI "selector" that pciconf and devctl accept.  However, devd
assumes that location strings are formatted as a list of name=value pairs.
As a result, devd is no longer parsing any of the values out of PCI
device events.  Restore the previous format of the PCI location strings
to restore the location and slot keywords in case any devd scripts are
using this.  Add the "selector" as a new 'dbsf' location variable.

Reviewed by:	imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D6253
2016-05-06 23:46:35 +00:00
Pedro F. Giffuni
ee58b56452 nfsserver: minor spelling fix in comment.
No functional change.
2016-05-06 23:40:37 +00:00
Pedro F. Giffuni
1762773d79 sys/opencrypto: minor spelling fixes.
No functional change.

Reviewed by:	jmg
2016-05-06 23:37:19 +00:00
Rick Macklem
8eabbbe24b Give mountd -S priority over outstanding RPC requests when suspending the nfsd.
It was reported via email that under certain heavy RPC loads
long delays before the exports would be updated was observed
when using "mountd -S". This patch reverses the priority between
the exclusive lock request to suspend the nfsd threads and the
shared lock request for performing RPCs.
As such, when mountd attempts to suspend the nfsd threads, it
gets priority over outstanding RPC requests to do this.
I suspect that the case reported was an artificial test load,
but this patch did fix the problem for the reporter.

Reported and Tested by:	josephlai@qnap.com
MFC after:	2 weeks
2016-05-06 23:26:17 +00:00
Pedro F. Giffuni
363089d89e dev/e1000,ixgbe: minor spelling fixes.
No functional change.

Differential Revision:	https://reviews.freebsd.org/D6177
2016-05-06 22:54:56 +00:00
Ed Maste
8edac6eee6 Add nid_namelen bounds check to nfssvc system call
This is only allowed by root and only used by the nfs daemon, which
should not provide an incorrect value. However, it's still good
practice to validate data provided by userland.

PR:		206626
Reported by:	CTurt <cturt@hardenedbsd.org>
Reviewed by:	rmacklem
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D6201
2016-05-06 21:19:28 +00:00
Svatopluk Kraus
6247277a02 INTRNG - support new interrupt mapping type INTR_MAP_DATA_GPIO
introduced in r298738.
2016-05-06 20:57:41 +00:00
Svatopluk Kraus
c28b681c3e INTRNG - use gpio interrupt modes definitions added in r298738 and
implement also GPIO_INTR_EDGE_BOTH mode. All reasonable interrupt
modes are supported now.
2016-05-06 20:55:14 +00:00
Maxim Sobolev
e3d7ead7df Add missing include "opt_geom.h" to make GEOM_UZIP_DEBUG option working,
also rename enum member so it does not conflict with GEOM_UZIP option
name.

Submitted by:	mizhka@gmail.com
Differential Revision:	https://reviews.freebsd.org/D6207
2016-05-06 20:32:39 +00:00
Pedro F. Giffuni
8c6a0d07a6 Revert r298938: Change x/a to work similar to gdb.
This badly breaks x/ia: ddb and gdb syntax are quite different and it is
unclear if they can be reconciled.
2016-05-06 20:28:28 +00:00
Andriy Voskoboinyk
bec488d17d iwn: fix comments for iwn_read_eeprom_channels().
It's used for all channels (20MHz and 40MHz).
2016-05-06 17:39:12 +00:00
Sean Bruno
40b6008fc5 Since igb_detach() cleans up all the data structures that will be
free'd by the functions following its call, we can simply return instead
of crashing and burning in the event of igb_detach() failing.

PR:		197139
Submitted by:	rupavath@juniper.net
MFC after:	2 weeks
2016-05-06 17:00:45 +00:00
Pedro F. Giffuni
bc5ade0d10 sys/security: minor spelling fixes.
No functional change.
2016-05-06 16:59:04 +00:00
Pedro F. Giffuni
ea0ccffc39 cam/scsi: Remove mostly unused scsi_quirk_table_size.
It was only being used only once and it can be directly replaced
instead.
2016-05-06 16:51:56 +00:00
Roger Pau Monné
288b2385b8 xen/privcmd: fix integer truncation in IOCTL_PRIVCMD_MMAPBATCH
The size field in the XENMEM_add_to_physmap_range is an uint16_t, and the
privcmd driver was doing an implicit truncation of an int into an uint16_t
when filling the hypercall parameters.

Fix this by adding a loop and making sure privcmd splits ioctl request into
2^16 chunks when issuing the hypercalls.

Reported and tested by:	Marcin Cieslak <saper@saper.info>
Sponsored by:		Citrix Systems R&D
2016-05-06 16:44:46 +00:00
Roger Pau Monné
03f5b58d56 bitset: introduce helpers to allocate a bitset at runtime
Introduce some new helpers to declare and allocate a dynamic bitset, whose
size is not a constant.

Sponsored by:		Citrix Systems R&D
Reviewed by:		kib jhb
Differential revision:	https://reviews.freebsd.org/D6226
2016-05-06 16:41:23 +00:00
Sean Bruno
eb9f04ddd9 If ALTQ is defined in the kern conf, switch to Legacy Mode.
PR:		208409
Submitted by:	freebsd@mcwest.org
MFC after:	2 weeks
2016-05-06 15:41:38 +00:00
Pedro F. Giffuni
a5a274d0d4 sys/ofed: minor spelling fix.
No functional change.

Reviewed by:	hselasky
2016-05-06 15:37:06 +00:00
Pedro F. Giffuni
c1f403238a sys/cam/scsi: unsigned some loop indexes.
Although usually small, values produced by nitems() are unsigned.
One more case where unsgining the index may be useful.
2016-05-06 15:36:25 +00:00
Pedro F. Giffuni
bf5cba36db ofed/drivers: minor spelling fixes.
No functional change.

Reviewed by:	hselasky
2016-05-06 15:16:13 +00:00
Pedro F. Giffuni
2a392dd62b sys/cam/scsi: unsigned some loop indexes.
Although usually small, values produced by nitems() are unsigned.
By unsigning the corresponding indexes we avoid signed vs unsigned
comparisons. This may have some effect on performance, although given the
small sizes the effect will not be perceivable and it makes the code
clearer.
2016-05-06 15:13:44 +00:00
Pedro F. Giffuni
25cd047538 dev/usb: unsigned some loop indexes.
Although usually small, values produced by nitems() are unsigned.
By unsigning the corresponding indexes we avoid signed vs unsigned
comparisons. This may have some effect on performance, although given the
small sizes the effect will not be perceivable, and it makes the code
clearer.

Respect the style of the changed files: one uses u_int while the other
uses "unsigned int".

Reviewed by:	hselasky
2016-05-06 15:09:21 +00:00
Andriy Voskoboinyk
82731f79a3 net80211: restore 'iflladdr_event' event handler.
Now 'ether' argument to ifconfig can be used as an alias to 'wlanaddr'.

PR:		208933
2016-05-06 11:41:49 +00:00
Svatopluk Kraus
1a251c538f INTRNG - support new interrupt mapping type INTR_MAP_DATA_GPIO
introduced in r298738.
2016-05-06 08:59:25 +00:00
Svatopluk Kraus
2202c37926 INTRNG - use gpio interrupt modes definitions added in r298738 and
implement also GPIO_INTR_EDGE_BOTH mode. All reasonable interrupt
modes are supported now.
2016-05-06 08:56:46 +00:00
Svatopluk Kraus
a100280e59 Set correct size to the size member of struct intr_map_data when
initialized. As the size member is not used at the present,
it did not break anything.
2016-05-06 08:54:00 +00:00
Stanislav Galabov
8173c81630 mtk_spi cleanup commented printfs
Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6223
2016-05-06 05:24:10 +00:00
Stanislav Galabov
025f79a5cd mtk_gpio fixes
Allow output pins to be read and input pins to be set.
Fix bugs where we were trying to access the gpio softc before doing
device_get_softc.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6222
2016-05-06 05:22:25 +00:00
Andrey V. Elsukov
b309f085e0 Change the type of objhash_cb_t callback function to be able return an
error code. Use it to interrupt the loop in ipfw_objhash_foreach().

Obtained from:	Yandex LLC
Sponsored by:	Yandex LLC
2016-05-06 03:18:51 +00:00
Pedro F. Giffuni
6244c6e7db sys/rpc: minor spelling fixes.
No functional change.
2016-05-06 01:49:46 +00:00
John Baldwin
82cb5c3b5b Native PCI-express HotPlug support.
PCI-express HotPlug support is implemented via bits in the slot
registers of the PCI-express capability of the downstream port along
with an interrupt that triggers when bits in the slot status register
change.

This is implemented for FreeBSD by adding HotPlug support to the
PCI-PCI bridge driver which attaches to the virtual PCI-PCI bridges
representing downstream ports on HotPlug slots. The PCI-PCI bridge
driver registers an interrupt handler to receive HotPlug events. It
also uses the slot registers to determine the current HotPlug state
and drive an internal HotPlug state machine. For simplicty of
implementation, the PCI-PCI bridge device detaches and deletes the
child PCI device when a card is removed from a slot and creates and
attaches a PCI child device when a card is inserted into the slot.

The PCI-PCI bridge driver provides a bus_child_present which claims
that child devices are present on HotPlug-capable slots only when a
card is inserted. Rather than requiring a timeout in the RC for
config accesses to not-present children, the pcib_read/write_config
methods fail all requests when a card is not present (or not yet
ready).

These changes include support for various optional HotPlug
capabilities such as a power controller, mechanical latch,
electro-mechanical interlock, indicators, and an attention button.
It also includes support for devices which require waiting for
command completion events before initiating a subsequent HotPlug
command. However, it has only been tested on ExpressCard systems
which support surprise removal and have none of these optional
capabilities.

PCI-express HotPlug support is conditional on the PCI_HP option
which is enabled by default on arm64, x86, and powerpc.

Reviewed by:	adrian, imp, vangyzen (older versions)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D6136
2016-05-05 22:26:23 +00:00
Adrian Chadd
eb98afc8b0 .. delete this; I don't know why this was here. oops! 2016-05-05 20:16:58 +00:00
Andrey V. Elsukov
2df1a11ffa Rename find_name_tlv_type() to ipfw_find_name_tlv_type() and make it
global. Use it in ip_fw_table.c instead of find_name_tlv() to reduce
duplicated code.

Obtained from:	Yandex LLC
Sponsored by:	Yandex LLC
2016-05-05 20:15:46 +00:00
Adrian Chadd
426a80d44d [bhnd] don't use anonymous unions.
Found by: gcc-4.2
2016-05-05 19:56:18 +00:00
Adrian Chadd
054ae23156 [bhnd] default to BUS_PROBE_DEFAULT for unknown BHND classes.
Found by: gcc-4.2
2016-05-05 19:55:16 +00:00
Adrian Chadd
0aba90e3bc [bhnd] handle unknown bhnd port type. 2016-05-05 19:54:17 +00:00
Adrian Chadd
3b0750141a [bwn] fix signed-ness of the rssi parameter.
It's a uint8_t from the hardware.

Found by: gcc
2016-05-05 19:40:26 +00:00
Adrian Chadd
10cb4427d5 [bhnd] quieten gcc warning. 2016-05-05 19:38:53 +00:00
Adrian Chadd
988fa8d078 [bhnd] handle unknown port type.
Reported by: emaste
2016-05-05 19:30:14 +00:00
Jung-uk Kim
c19e9bb3b0 Fix intmax_t to uintptr_t casting on 32-bit platforms. Found by GCC.
Submitted by:	bde
2016-05-05 18:43:31 +00:00
Niclas Zeising
b7f227d86d Fix kernel build with parallel make.
Approved by:	jhb
2016-05-05 17:55:10 +00:00
Zbigniew Bodek
42638f9c5a Fix GICv3 build after r299090
Obtained from:	Semihalf
Sponsored by:	Cavium
2016-05-05 17:51:14 +00:00
Ed Maste
c009c4021c bhnd: another build fix for GCC-using architectures
Further to r299119. GCC architectures failed with
bcma_subr.c:138: warning: control reaches end of non-void function

Sponsored by:	The FreeBSD Foundation
2016-05-05 17:47:03 +00:00
John Baldwin
f8e81aa50e Fix <sys/_bitset.h> and <sys/_cpuset.h> to not require <sys/param.h>.
- Hardcode '8' instead of NBBY in _BITSET_BITS.
- Define a private version of 'howmany' for use in __bitset_words().
- While here, move a few more things out of _bitset.h and _cpuset.h to
  bitset.h and cpuset.h, respectively.  The only things left in
  _bitset.h and _cpuset.h are the bits needed to define a bitset
  structure.

Reviewed by:	bde, kib (ish)
2016-05-05 15:43:26 +00:00
Alan Somers
6adfa7edf0 mpr(4) and mps(4) shouldn't indefinitely retry for "terminated ioc" errors
Submitted by:	ken
Reviewed by:	slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6210
2016-05-05 15:32:47 +00:00
Ed Maste
b4f6936599 Add explicit cast to fix mips and powerpc build after r299090
Sponsored by:	The FreeBSD Foundation
2016-05-05 15:21:33 +00:00
Ed Maste
c2ec037ff5 bhnd: fix build on gcc architectures
"make tinderbox" fails on sparc64 GENERIC-NODEBUG with:
bhnd_subr.c:188: warning: control reaches end of non-void function

Sponsored by:	The FreeBSD Foundation
2016-05-05 15:07:40 +00:00
Ruslan Bukin
d7dc6bae03 Implement FBT provider (MD part) for DTrace on MIPS.
Tested on MIPS64.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-05-05 13:54:50 +00:00
Svatopluk Kraus
cd642c88a1 INTRNG - redefine struct intr_map_data to avoid headers pollution. Each
struct associated with some type defined in enum intr_map_data_type
must have struct intr_map_data on the top of its own definition now.
When such structs are used, correct type and size must be filled in.

There are three such structs defined in sys/intr.h now. Their
definitions should be moved to corresponding headers by follow-up
commits.

While this change was propagated to all INTRNG like PICs,
pic_map_intr() method implementations were corrected on some places.
For this specific method, it's ensured by a caller that the 'data'
argument passed to this method is never NULL. Also, the return error
values were standardized there.
2016-05-05 13:31:19 +00:00
Svatopluk Kraus
15adccc687 Remove superfluous check. The pic_dev member of struct pic
is never NULL on PIC found by pic_lookup().
2016-05-05 13:23:38 +00:00
Jared McNeill
8a0fd1a7cd Add support for the Allwinner A83T (sun8iw6p1) SoC.
Clocks, GPIO, UART, SD card / eMMC, USB, watchdog, and ethernet are
supported. Note that the A83T contains two clusters of four Cortex-A7
CPUs, and only CPUs in first cluster are started for now.

Tested on a Sinovoip Banana Pi BPI-M3.
2016-05-05 09:41:57 +00:00
Adrian Chadd
af4ae173e4 [bwn] implement firmware tx/rx versioning and fix RSSI calculation.
Different versions of firmware have different requirments for TX/RX
packet layouts (and other things, of course.)  Currently the driver
checks between 3xx and 4xx firmware by using the BWN_ISOLDFMT() macro,
which doesn't take into account the 5xx firmware (which I think I need
for the HT and N series PHY chips.  I'll know when I do the port.)
BWN_HDRSIZE() also needs to learn about the 5xx series firmware
as well.

So:

* add a firmware version enum
* populate it based on the firmware version we read at load time
* don't finish loading if the firmware is the 5xx firmware; any
  code using BWN_ISOLDFMT or BWN_HDRSIZE needs updating (most notably
  the TX and RX bits.)

Then, for RX RSSI:

* write down and reimplement the b43 rssi calculation method;
* use it for the correct PHYs (which are all the ones we support);
* do the RSSI calculation before radiotap, not after.

Tested:

* Broadcom BCM4312, STA mode

Obtained from:	Linux b43 (careful writing and reimplementing; lots of integer math..)
2016-05-05 07:04:38 +00:00
Adrian Chadd
fb45992d1b [bhnd] add missing bus file. 2016-05-05 06:58:30 +00:00
Enji Cooper
7c6f639b60 Revert r299096
The change broke buildworld when building lib/libkvm

This change likely needs to be run through a ports -exp run as a sanity
check, as it might break downstream consumers.

Pointyhat to: adrian
Reported by: kargl (confirmed on $work workstation)
Sponsored by: EMC / Isilon Storage Division
2016-05-05 02:51:31 +00:00
Conrad Meyer
3d5b6ffbf8 efipart: Support an arbitrary number of partitions
Don't crash if the user has more than 31 of them.  A follow-up to
r298230.

Reviewed by:	allanjude
Relnotes:	maybe
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D6212
2016-05-05 00:07:08 +00:00
Adrian Chadd
148ed57165 [bwn] [bhnd] initial support for using bhnd for if_bwn devices.
This is an initial work in progress to use the replacement bhnd
bus code for devices which support it.

* Add manpage updates for bhnd, bhndb, siba
* Add kernel options for bhnd, bhndbus, etc
* Add initial support in if_bwn_pci / if_bwn_mac for using bhnd
  as the bus transport for suppoted NICs
* if_bwn_pci will eventually be the PCI bus glue to interface to bwn,
  which will use the right backend bus to attach to, versus direct
  nexus/bhnd attachments (as found in embedded broadcom devices.)

The PCI glue defaults to probing at a lower level than the bwn glue,
so bwn should still attach as per normal without a boot time tunable set.

It's also not fully fleshed out - the bwn probe/attach code needs to be
broken out into platform and bus specific things (just like ath, ath_pci,
ath_ahb) before we can shift the driver over to using this.

Tested:

* BCM4311, STA mode
* BCM4312, STA mode

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6191
2016-05-04 23:38:27 +00:00
Adrian Chadd
1b34262b0b s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 23:32:57 +00:00
Adrian Chadd
d17f808fab s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 23:31:52 +00:00
Enji Cooper
430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
John Baldwin
e45163b216 Fix the acpi attachment to always start the worker thread.
The previous change to split the worker thread start out of fdc_attach()
did not start the worker thread if the fdc device in the ACPI namespace
did not have an _FDE method.  This fixes hangs when booting with a
floppy controller enabled on certain machines with ACPI.

Tested by:	joel
2016-05-04 23:00:57 +00:00
Alan Somers
8907f744ff Improve performance and functionality of the bitstring(3) api
Two new functions are provided, bit_ffs_at() and bit_ffc_at(), which allow
for efficient searching of set or cleared bits starting from any bit offset
within the bit string.

Performance is improved by operating on longs instead of bytes and using
ffsl() for searches within a long. ffsl() is a compiler builtin in both
clang and gcc for most architectures, converting what was a brute force
while loop search into a couple of instructions.

All of the bitstring(3) API continues to be contained in the header file.
Some of the functions are large enough that perhaps they should be uninlined
and moved to a library, but that is beyond the scope of this commit.

sys/sys/bitstring.h:
        Convert the majority of the existing bit string implementation from
        macros to inline functions.

        Properly protect the implementation from inadvertant macro expansion
        when included in a user's program by prefixing all private
        macros/functions and local variables with '_'.

        Add bit_ffs_at() and bit_ffc_at(). Implement bit_ffs() and
        bit_ffc() in terms of their "at" counterparts.

        Provide a kernel implementation of bit_alloc(), making the full API
        usable in the kernel.

        Improve code documenation.

share/man/man3/bitstring.3:
        Add pre-exisiting API bit_ffc() to the synopsis.

        Document new APIs.

        Document the initialization state of the bit strings
        allocated/declared by bit_alloc() and bit_decl().

        Correct documentation for bitstr_size(). The original code comments
        indicate the size is in bytes, not "elements of bitstr_t". The new
        implementation follows this lead. Only hastd assumed "elements"
        rather than bytes and it has been corrected.

etc/mtree/BSD.tests.dist:
tests/sys/Makefile:
tests/sys/sys/Makefile:
tests/sys/sys/bitstring.c:
        Add tests for all existing and new functionality.

include/bitstring.h
	Include all headers needed by sys/bitstring.h

lib/libbluetooth/bluetooth.h:
usr.sbin/bluetooth/hccontrol/le.c:
        Include bitstring.h instead of sys/bitstring.h.

sbin/hastd/activemap.c:
        Correct usage of bitstr_size().

sys/dev/xen/blkback/blkback.c
        Use new bit_alloc.

sys/kern/subr_unit.c:
        Remove hard-coded assumption that sizeof(bitstr_t) is 1.  Get rid of
        unrb.busy, which caches the number of bits set in unrb.map.  When
        INVARIANTS are disabled, nothing needs to know that information.
        callapse_unr can be adapted to use bit_ffs and bit_ffc instead.
        Eliminating unrb.busy saves memory, simplifies the code, and
        provides a slight speedup when INVARIANTS are disabled.

sys/net/flowtable.c:
        Use the new kernel implementation of bit-alloc, instead of hacking
        the old libc-dependent macro.

sys/sys/param.h
        Update __FreeBSD_version to indicate availability of new API

Submitted by:   gibbs, asomers
Reviewed by:    gibbs, ngie
MFC after:      4 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D6004
2016-05-04 22:34:11 +00:00
Jared McNeill
d3810ff91c Add driver for Allwinner A83T/H3/A64 Gigabit Ethernet.
The datasheets refer to this controller as EMAC, not to be confused with
the fast ethernet controller (also named EMAC) found in A10/A20 SoCs.

Tested on a BananaPi M3 (A83T), which uses an external RGMII PHY (RTL8211E).

Reviewed by:		adrian
Differential Revision:	https://reviews.freebsd.org/D6169
2016-05-04 20:06:20 +00:00
Andriy Voskoboinyk
4772b8701c wi: fix a comment (0x1fff has 13 bits set). 2016-05-04 18:08:38 +00:00
Alan Cox
cdbf6d8a05 Explain why pmap_copy(), pmap_enter_pde(), and pmap_enter_quick_locked()
call pmap_invalidate_page() even though they are not destroying a leaf-
level page table entry.

Eliminate some bogus white-space characters in a comment.

Reviewed by:	kib
2016-05-04 17:54:13 +00:00
Pedro F. Giffuni
4a00a65162 dev/pms: minor spelling fixes for the FreeBSD-specific part. 2016-05-04 17:52:53 +00:00
Andriy Voskoboinyk
b134c5824b net80211: do not hardcode size of ic_modecaps field. 2016-05-04 17:22:35 +00:00
Adrian Chadd
ced0a8950a [net80211] add extra debugging around negotiated A-MPDU parameters. 2016-05-04 16:42:53 +00:00
Bjoern A. Zeeb
e94f204a32 While gem5 is not qemu, we treat it as "simulators" or "virtual environments".
Add the needed hardcoded gem5 attachments for the UART there, re-using all
the other bits.

In collaboration with:	andrew
Sponsored by:		DARPA/AFRL
Reviewed by:		andrew
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D6204
2016-05-04 16:24:12 +00:00
Bjoern A. Zeeb
ab257e40e6 The virtual timer is optional on ARM64. Properly handle that condition. [1]
In case we do not have an interrupt assignment for the virtual timer,
force the physical timer.
Also skip resource allocation for any timer we do not have an interrupt
assignment for.

In collaboration with:	andrew
Submitted by:		br ([1] from his gem5 arm64 work)
Sponsored by:		DARPA/AFRL
Reviewed by:		andrew
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D6203
2016-05-04 16:15:39 +00:00
Bjoern A. Zeeb
83655449f5 The ARM generic timer keeps ticking even if disabled or it expired.
In case of updating it with a very low value it might expire again
after writing the tval but before updating ctrl. In that case we do
lose the status bit saying that the timer expired and we will consequently
not get an interrupt for it, leaving the timer in a "dead" state.

In order to solve this increase the minimum period with what the timer
can be loaded to something higher.

Found & analysed with:	gem5
Debugged with:		andrew
Sponsored by:		DARPA/AFRL
Reviewed by:		andrew
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D6202
2016-05-04 16:09:51 +00:00
Pedro F. Giffuni
730ba5a1aa sys/sparc64: minor spelling fixes.
Only affects comments: no functional change.
2016-05-04 15:52:40 +00:00
Pedro F. Giffuni
255eff3b0d sys/arm: Minor spelling fixes.
Only affects comments: no functional change.
2016-05-04 15:48:59 +00:00
Roger Pau Monné
2ed46a6f7d xen/pvclock: set the correct resolution for the Xen PV clock
The Xen PV clock has a resolution of 1ns, so set the resolution to the
highest one that FreeBSD supports, which is 1us.

MFC after:	2 weeks
Sponsored by:	Citrix Systems R&D
2016-05-04 13:49:59 +00:00
Roger Pau Monné
731c90b713 rtc: fix inverted resolution check
The current code in clock_register checks if the newly added clock has a
resolution value higher than the current one in order to make it the
default, which is wrong. Clocks with a lower resolution value should be
better than ones with a higher resolution value, in fact with the current
code FreeBSD is always selecting the worse clock.

Reviewed by:		kib jhb jkim
Sponsored by:		Citrix Systems R&D
MFC after:		2 weeks
Differential revision:	https://reviews.freebsd.org/D6185
2016-05-04 13:48:59 +00:00
Andriy Voskoboinyk
a7d1e7a9ec iwn: fix device reset after watchdog timeout.
Simple device reset (stop/start) is not enough here;
post-init state changes must be applied too.
2016-05-04 12:51:27 +00:00
Hans Petter Selasky
869df73304 Extend the UQ_NO_STRINGS quirk to also cover the USB language string
descriptor. This fixes enumeration of some older Samsung Galaxy S3
phones.

MFC after:	1 week
2016-05-04 08:57:40 +00:00
Adrian Chadd
a8cd039341 s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:26:27 +00:00
Adrian Chadd
cde57cac55 s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:25:12 +00:00
Adrian Chadd
ade965c38b s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:24:51 +00:00
Adrian Chadd
d19677ddd7 s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:24:10 +00:00
Adrian Chadd
748cd4c30d s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:23:49 +00:00
Jung-uk Kim
12b204a61b Fix build without "options PCI_IOV". 2016-05-04 06:22:41 +00:00
Sepherosa Ziehau
d5f0ea7ca2 kern: Factor out function to convert hash flags to malloc(9) flags
Suggested by:	jhb
Reviewed by:	jhb, kib
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6184
2016-05-04 03:07:52 +00:00
Adrian Chadd
d191ae19a2 [bwn] fix rate control feedback.
* Add a debug print for the xmit completion status fields.
  Yes, I like staring at a stream of DWORDS.

* Set the retrycnt to the number of full frame retries for now;
  I'll figure out how to factor rts/cts failures into it when
  I figure out what the difference is.

  It's -1 because it's not "retries", it's "tries".

It now passes the youtube test.

Tested:

* BCM4312, STA mode
2016-05-04 02:11:45 +00:00
Alexander Kabaev
cdd2592ffd Fix nvram2env after bus_space_fdt removal.
The generic bus space does the mapping now, no need to pre-translate
phys addresses to KSEG1 anymore.

Submitted by: Hiroki Mori
2016-05-04 01:56:37 +00:00
Marcelo Araujo
b3956646bf Use imin() macro from sys/libkern.h.
MFC after:	2 weeks.
2016-05-04 01:43:07 +00:00
Adrian Chadd
e1e8b05256 [bwn] accurately(ish) account transmit/recieve failures for rate control.
I noticed that it'd associate fine, but it'd quickly stop exchanging traffic.
Receive was okay, but transmit just failed.

Then I went "wlandebug +rate".  I discovered it started at 36M OFDM, and then
quickly rose to 54M, which then showed 0% transmit success.

Then, I dug into how the completion path works.  We are reading 'ack=0'
in the TX status side, so .. then I discovered we were only processing the
TX completion status /if/ ack=1.  So, we'd only ever count successes;
we'd never count failures, and thus the rate control code thought
everything was a-ok.

We also have to set retrycnt to something non-zero so it indeed does
bring the rate down upon failure.

So:

* Delete the rate control completion code from the tx completion
  routine, it's just duplicate and never worked.  Putting it behind
  'if (status->ack) was pointless.

* Move it to the PIO and DMA completion routines which actually
  do free the node reference and mbuf.  We know at that point
  what the status is, so do it there.

* Fake a retrycnt of 1 for now, so we at least count failures.

Also:

* Start adding comments about weird stuff I find with rate selection.
  In this instance, we shouldn't be selecting a fallback rate that
  doesn't match the currently configured mode (11a, 11b, 11g, etc.)

This isn't perfect - AMRR does try 54mbit and takes a few packets
before it figures out it's a bad idea - but it's better than nothing.

This makes the bwn(4) driver actually useful for the first time since
I've tried using it - and that dates back to 2011.  I've resisted
successfully until now.

Tested:

* Broadcom BCM4312 802.11b/g Wireless, STA mode
  WLAN (chipid 0x4312 rev 15) PHY (analog 6 type 5 rev 1) RADIO (manuf 0x17f ver 0x2062 rev 2)

TODO:

* See if the fallback rate actually /is/ working
* Question my own sanity over touching this driver in the first place.
2016-05-04 01:36:19 +00:00
Adrian Chadd
b0436c3acf [bwn] ensure the fallback rate stays in the same PHY mode.
Falling back from 6MB OFDM to 5MB CCK (a) may not work well in the
11bg PHYs, (b) won't work at all if you're 11g only, and (c) plainly
won't work for the 11a PHY.

So, don't do that!

Tested:

* BCM4312 802.11b/g Wireless, STA mode
  WLAN (chipid 0x4312 rev 15) PHY (analog 6 type 5 rev 1) RADIO (manuf 0x17f ver 0x2062 rev 2)
2016-05-04 01:29:00 +00:00
Enji Cooper
aa853cb461 Use DEVMETHOD_END ({ NULL, NULL }) instead of hardcoding { 0, 0 }
Sponsored by: EMC / Isilon Storage Division
2016-05-03 23:56:52 +00:00
Pedro F. Giffuni
edafb5a327 sys/amd64: Small spelling fixes.
No functional change.
2016-05-03 22:13:04 +00:00
Pedro F. Giffuni
500eb14ae8 vmm(4): Small spelling fixes.
Reviewed by:	grehan
2016-05-03 22:07:18 +00:00
Pedro F. Giffuni
696efc839c kgssapi: insignificant spelling fix.
No functional change.
2016-05-03 22:05:03 +00:00
Pedro F. Giffuni
a1ff7af013 Misc. build: minor spelling fixes.
No functional change.
2016-05-03 22:01:48 +00:00
Pedro F. Giffuni
55b0545890 sys/isa: minor spelling fixes.
No functional change.
2016-05-03 21:51:52 +00:00
Eric van Gyzen
2db0699d88 Work around (ignore) broken SRAT tables
Instead of panicking when parsing an invalid ACPI SRAT table,
just ignore it, effectively disabling NUMA.

https://lists.freebsd.org/pipermail/freebsd-current/2016-May/060984.html

Reported and tested by:	 Bill O'Hanlon (bill.ohanlon at gmail.com)
Reviewed by:	jhb
MFC after:	1 week
Relnotes:	If dmesg shows "SRAT: Duplicate local APIC ID",
                try updating your BIOS to fix NUMA support.
Sponsored by:	Dell Inc.
2016-05-03 20:14:04 +00:00
John Baldwin
e402d55c84 Save and restore SRIOV-related config registers.
Save the value of the IOV control and page size registers and restore
them (along with the VF count) in pci_cfg_save/pci_cfg_restore.  This
ensures ARI remains enabled if a PF driver resets itself during the
PCI_IOV_INIT callback.  This might also properly restore SRIOV state
across suspend/resume.

Reviewed by:	rstone, vangyzen
Differential Revision:	https://reviews.freebsd.org/D6192
2016-05-03 19:45:24 +00:00
John Baldwin
b83c5d07c1 Use the correct location of the SRIOV capability when enabling ARI.
While here, check if ARI was enabled by re-reading the config register
after writing it and return an error if the write fails.

Reviewed by:	rstone, vangyzen
2016-05-03 19:37:25 +00:00
Pedro F. Giffuni
a4641f4eaa sys/net*: minor spelling fixes.
No functional change.
2016-05-03 18:05:43 +00:00
Adrian Chadd
31ae3b070d [asmc] Add support for MacBookPro5,1
Tested by:	Johannes Lundberg <johannes@brilliantservice.co.jp>
PR:		kern/209179
Submitted by:	Thomas Brierley <tomxor@gmail.com>
2016-05-03 17:11:33 +00:00
Conrad Meyer
bec7ff798a ioat(4): Implement CRC and MOVECRC APIs
And document them in ioat.4.

Sponsored by:	EMC / Isilon Storage Division
2016-05-03 17:07:18 +00:00
Conrad Meyer
be3cbf60a5 ioat(4): Add CRC descriptor structure
Add CRC/MOVECRC operations, as well as the TEST and STORE variants.

With these operations, a CRC32C can be computed over one or more
descriptors' source data.  When the STORE operation is encountered, the
accumulated CRC32C is emitted to memory.  A TEST operations triggers an
IOAT channel error if the accumulated CRC32C does not match one in
memory.

These operations are not exposed through any API yet.

Sponsored by:	EMC / Isilon Storage Division
2016-05-03 17:06:33 +00:00
Conrad Meyer
519e8baab7 ioat(4): Limit descriptor allocation to low 40 bits
The IOAT engine can only address the low 40 bits (1 TB) of physmem via
the 'next descriptor' pointer.  Restrict acceptable range given to
bus_dma_tag_create to match.

Sponsored by:	EMC / Isilon Storage Division
2016-05-03 17:05:58 +00:00
Pedro F. Giffuni
ca4aaf2359 sys/sys: missed in r298981.
I am sure I've missed others as well, but at least it should
be more readable now.

No functional change.
2016-05-03 16:37:09 +00:00
Bjoern A. Zeeb
46b0539ca4 Remove the most useful INET || INET6 check leftover from whenever,
doing nothing.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2016-05-03 16:01:53 +00:00
Alexander Motin
71733a504f Add some device IDs from Intel Sunrise Point chipsets.
MFC after:	2 weeks
2016-05-03 15:27:47 +00:00
Konstantin Belousov
c89e1b8739 Add EVFILT_VNODE open, read and close notifications.
While there, order EVFILT_VNODE notes descriptions alphabetically.

Based on submission, and tested by:	Vladimir Kondratyev <wulf@cicgroup.ru>
MFC after:	2 weeks
2016-05-03 15:17:43 +00:00
Pedro F. Giffuni
7f417bfac1 sys/sys: minor spelling fixes.
While the changes are minor, these headers are very visible.

MFC after:	2 weeks
2016-05-03 15:14:17 +00:00
Pedro F. Giffuni
266078c6db dev/iscsi: minor spelling fixes.
No functional change.

Reviewed by:	trasz
2016-05-03 14:49:49 +00:00
Scott Long
de482e7bbb Fix a memory leak in the devctl notify code.
Submitted by:	markj
MFC after:	asap
2016-05-03 14:30:26 +00:00
Pedro F. Giffuni
612226d756 Revert r298955 for the cxgbe firmware.
These files have checksums that are none of my business.

Requested by:	np
2016-05-03 11:49:29 +00:00
Sepherosa Ziehau
51e3c20d36 tcp/lro: Refactor the active list operation.
Ease more work concerning active list, e.g. hash table etc.

Reviewed by:	gallatin, rrs (earlier version)
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6137
2016-05-03 08:13:25 +00:00
Roger Pau Monné
71718d3c73 xen/i386: enable the platform hypercall for i386
Not sure why the platform hypercall was disabled on i386, just enable it in
order to fix compilation of the PV timer on i386.

Sponsored by: Citrix Systems R&D
2016-05-03 08:05:14 +00:00
Sepherosa Ziehau
f8ce3dfaf1 kern: Add phashinit_flags(), which allows malloc(M_NOWAIT)
It will be used for the upcoming LRO hash table initialization.
And probably will be useful in other cases, when M_WAITOK can't
be used.

Reviewed by:	jhb, kib
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6138
2016-05-03 07:17:13 +00:00
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Adrian Chadd
7860c0c384 [bwn] update bwn_dummy_transmission().
This is based on the b43 code.  It'll be used by the upcoming 11n phy.

Obtained from:	Linux b43 (concept)
2016-05-03 03:31:16 +00:00
Adrian Chadd
988afd2163 [bwn] add PHY types for later PHYs.
Obtained from:	Linux b43
2016-05-03 03:27:11 +00:00
Adrian Chadd
6dbb9b3cca [bwn] migrate bwn_dummy_transmission() back to main, as it'll be used by other PHYs.
The Linux b43 driver uses this in other PHYs besides the g PHY.
2016-05-03 03:24:27 +00:00
John Baldwin
8a08b7d36b Revert bus_get_cpus() for now.
I really thought I had run this through the tinderbox before committing,
but many places need <sys/types.h> -> <sys/param.h> for <sys/bus.h> now.
2016-05-03 01:17:40 +00:00
John Baldwin
a38f0dafb5 Fix an off by one error when remapping MSI-X vectors.
pci_remap_msix() can be used to alter the mapping of allocated
MSI-X vectors to the MSI-X table.  The code had an off by one error
when adding the IRQ resources after performing a remap.  This was
fatal for any vectors in the table that used the "last" valid IRQ as
those vectors were assigned a garbage IRQ value.

MFC after:	3 days
2016-05-03 00:35:11 +00:00
Peter Wemm
d8818fce69 Change a rounding operation that had missing braces into a roundup2()
macro.  Adjust the buffer clipping code to work as expected.

This prevented a number of machines in the FreeBSD.org cluster from
booting due to "ZFS: i/o error - all block copies unavailable"
after an unclean shutdown.
2016-05-03 00:09:13 +00:00
Adrian Chadd
d546e47aa0 [bwn] break out the 'g' phy code into a separate source file.
* Break out the 'g' phy code;
* Break out the debugging bits into a separate source file, since
  some debugging prints are done in the phy code;
* Make some more chip methods in if_bwn.c public.

This brings the size of if_bwn.c down to 6,805 lines which is now
approaching managable.
2016-05-02 22:58:11 +00:00
Adrian Chadd
eaddb80745 [bhnd] fix more module dependencies.
Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6180
2016-05-02 22:30:46 +00:00
Michael Tuexen
afd6748258 Undo a spell fix introduced in r298942, which breaks compilation. 2016-05-02 21:23:05 +00:00
Adrian Chadd
b976830308 [bwn] break out the LP PHY code into a separate file.
This (and eventually migrating the other PHY code out) is in preparation
for adding the 11n PHY.  No, the 11ac PHY (for the BCM4260 softmac part) isn't
yet open source, so we can't grow that.  Yet.

This trims ~3,700 lines of code from if_bwn.c, bringing it down to a slightly
less crazy sounding 10,446 lines of code.
2016-05-02 21:06:02 +00:00
Adrian Chadd
96546b75e7 [bhnd] add module dependencies.
Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6179
2016-05-02 21:01:08 +00:00
Pedro F. Giffuni
cd0a4ff6a5 netinet/sctp*: minor spelling fixes in comments.
No functional change.

Reviewed by:	tuexen
2016-05-02 20:56:11 +00:00
Andriy Voskoboinyk
c6a35ee46c net80211: fix MAC address change via SIOCSIFLLADDR ioctl.
Recheck MAC address on SIOCSIFFLAGS; as a result,
'ifconfig wlan0 ether <addr>' can be used after interface startup.

PR:		208933
2016-05-02 20:46:05 +00:00
Pedro F. Giffuni
763df3ec55 sys/vm: minor spelling fixes in comments.
No functional change.
2016-05-02 20:16:29 +00:00
Pedro F. Giffuni
f6b6084b8e dev/ath: minor spelling fixes in comments.
No functional change.

Reviewed by:	adrian
2016-05-02 19:56:48 +00:00
Pedro F. Giffuni
dd40d6d5e0 Enhance the ddb examine (x) command.
* Change x/a to work similar to gdb.  The content of the memory is
  treated as an address, printed symbolically and the address is advanced.
  This way you can x/a <stack_address> and then just hit return a bunch
  of times to locate useful data on the stack.

* Add x/p.  The content of the memory is treated as an address and
  printed as hex.

This is based on the similar commit from DragonFlyBSD without the
cosmetic changes.

Relnotes:	yes
Obtained from:	DragonflyBSD (Matthew Dillon)
Reference:	0624d20e86affcd708609cbf9014207537537a72
2016-05-02 19:32:06 +00:00
Adrian Chadd
108e307680 [asmc] add support for more models and restore keyboard backlight after resume.
This patch adds support for restoring backlight after resume and adds models
Macbook3,1
MacbookAir5,1
MacbookAir5,2

It also incorporates fixes for bug #175260, bug #203610 and bug #203512
so those can be closed if this patch is applied.

PR:		kern/209156
PR: kern/175260
PR: kern/203610
PR: kern/203512
Submitted by:	Johannes Lundberg <johannes@brilliantservice.co.jp>
2016-05-02 19:15:16 +00:00
Andriy Voskoboinyk
d35192e513 iwm: fix parameters for iwm_add_channel_band()
It accepts <first index, max index + 1>, not
<first index, number of entries>.

Reported by:	adrian
2016-05-02 19:07:44 +00:00
Adrian Chadd
7bc47ad999 [bhnd] add missing bus interface SRC bits, required after the last source import. 2016-05-02 18:48:37 +00:00
Roger Pau Monné
6e2a4a5f48 xen/control: improve suspend/resume
Implement several small improvements to the suspend/resume Xen sequence:

 - Call the power_suspend_early event before stopping all processes.
 - Stop all processes. This was done implicitly previously by putting all
   the CPUs in a known IPI handler.
 - Warm up the timecounter.
 - Re-initialize the time of day register.

Sponsored by: Citrix Systems R&D
2016-05-02 18:23:48 +00:00
John Baldwin
bc153c692f Add a new bus method to fetch device-specific CPU sets.
bus_get_cpus() returns a specified set of CPUs for a device.  It accepts
an enum for the second parameter that indicates the type of cpuset to
request.  Currently two valus are supported:

 - LOCAL_CPUS (on x86 this returns all the CPUs in the package closest to
   the device when DEVICE_NUMA is enabled)
 - INTR_CPUS (like LOCAL_CPUS but only returns 1 SMT thread for each core)

For systems that do not support NUMA (or if it is not enabled in the kernel
config), LOCAL_CPUS fails with EINVAL.  INTR_CPUS is mapped to 'all_cpus'
by default.  The idea is that INTR_CPUS should always return a valid set.

Device drivers which want to use per-CPU interrupts should start using
INTR_CPUS instead of simply assigning interrupts to all available CPUs.
In the future we may wish to add tunables to control the policy of
INTR_CPUS (e.g. should it be local-only or global, should it ignore
SMT threads or not).

The x86 nexus driver exposes the internal set of interrupt CPUs from the
the x86 interrupt code via INTR_CPUS.

The ACPI bus driver and PCI bridge drivers use _PXM to return a suitable
LOCAL_CPUS set when _PXM exists and DEVICE_NUMA is enabled.  They also and
the global INTR_CPUS set from the nexus driver with the per-domain set from
_PXM to generate a local INTR_CPUS set for child devices.

Reviewed by:	wblock (manpage)
Differential Revision:	https://reviews.freebsd.org/D5519
2016-05-02 18:00:38 +00:00
Pedro F. Giffuni
207332450e dev/usb: minor spelling fixes in comments.
No functional change.

Reviewed by:	hselasky
2016-05-02 17:44:03 +00:00
Pedro F. Giffuni
b790c1938d etc: minor spelling fixes.
Mostly comments but also some user-visible strings.

MFC after:	2 weeks
2016-05-02 16:47:28 +00:00
Roger Pau Monné
f8af716b04 xen/time: fix PV clock resolution
The current resolution of the Xen PV clock is too high, which causes an
adjustment of 5s to be applied to it. Reduce the resolution to be the same
as the RTC plus one, so it's always selected as the best source when
available on x86.

Also don't reset the clock on resume, it's pointless and discards any
previous adjustments.

Sponsoted by: Citrix Systems R&D
2016-05-02 16:16:08 +00:00
Roger Pau Monné
eac636b0ce xen/time: allow Dom0 to set the host time
Dom0 should be able to set the host time. This is implemented by first
writing to the RTC (as would be done on bare metal), and then using the
XENPF_settime64 hypercall in order to force Xen to update the wallclock
shared page of all domains.

Sponsored by: Citrix Systems R&D
2016-05-02 16:15:28 +00:00
Roger Pau Monné
f65466eb3a atrtc: export function to set RTC
This is going to be used by the Xen clock on Dom0 in order to set the RTC of
the host. The current logic in atrtc_settime is moved to atrtc_set and the
unused device_t parameter is removed from the atrtc_set function call so it
can be safely used by other callers.

Sponsored by:		Citrix Systems R&D
Reviewed by:		kib, jhb
Differential revision:	https://reviews.freebsd.org/D6067
2016-05-02 16:14:55 +00:00
Roger Pau Monné
af5bb69c5a xen/timer: remove the timer setup loop
With the removal of the usage of the VCPU_SSHOTTMR_future flag, now
all errors from xentimer_vcpu_start_timer should be considered fatal, and
the loop is no longer needed since in case of setting the timer in the past
we will get an event interrupt right away (instead of returning ETIME).

Sponsored by:	Citrix Systems R&D
MFC after :	2 weeks
2016-05-02 16:13:55 +00:00
Roger Pau Monné
04423b622a xen/x86: don't lose event interrupts
On slow platforms with unreliable TSC, such as QEMU emulated machines,
it is possible for the FreeBSD kernel to request the next event in the
past. In that case, in the current implementation of
xentimer_vcpu_start_timer, we simply return -ETIME. To be precise Xen
returns -ETIME and we pass it on. As a consequence we need to loop
around to function to make sure that the timer is properly set.

Instead it is better to always ask the hypervisor for a timer event,
even if the timeout is past. To do that, remove the VCPU_SSHOTTMR_future
flag.

Submitted by:	Stefano Stabellini <sstabellini@kernel.org>
Reviewed by:	royger
MFC after:	2 weeks
2016-05-02 16:13:11 +00:00
Andriy Voskoboinyk
b8ad211534 iwn: do not buffer frames for non-passive channels (it's not needed). 2016-05-02 15:14:16 +00:00
Pedro F. Giffuni
32a71a72e1 dev/random: minor spelling fixes in comments.
No functional change.

Reviewed by:	markm
Approved by:	so
2016-05-02 14:35:57 +00:00
Konstantin Belousov
f7b71c8a5b Issue NOTE_EXTEND when a directory entry is added to or removed from
the monitored directory as the result of rename(2) operation.  The
renames staying in the directory are not reported.

Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>
MFC after:	2 weeks
2016-05-02 13:18:17 +00:00
Konstantin Belousov
bd2ead6b2e Fix reporting of NOTE_LINK when directory link count changes due to
rename removing or adding subdirectory entry.

Discussed with and tested by:	Vladimir Kondratyev <wulf@cicgroup.ru>
NetBSD PR:	48958 (http://gnats.netbsd.org/48958)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2016-05-02 13:13:32 +00:00
Adrian Chadd
b35978d0da [otus] implement monitor mode.
* break out the operating mode and rx filter into new functions, rather
  than them being hard-coded
* if we're in sniffer mode or not associated, set the BSS MAC to all zero,
  rather than relying on a chip reset to do it for us
* add comments about .. how interestingly buggy the chip is.

Tested:

* AR9170 + AR9102, STA+monitor mode

Obtained from:	linux carl9170 (general chip workings, constant definitions)
2016-05-02 05:43:46 +00:00
Adrian Chadd
afce6f3b0b s/struct device */device_t/
Submitted by:	kmacy
2016-05-02 05:37:25 +00:00
Adrian Chadd
dd8a5c3593 [mwl] s/struct device/device_t/
Submitted by:	kmacy
2016-05-02 04:15:15 +00:00
Andriy Voskoboinyk
f5c911273a iwn: switch to ieee80211_add_channel*()
Switch to add_channel / add_channel_ht40 + pass channel's TX power
for the last.

Tested by:	dhw
Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D6141
2016-05-01 22:00:40 +00:00
Michael Tuexen
ec70917ffa When a client uses UDP encapsulation and lists IP addresses in the INIT
chunk, enable UDP encapsulation for all those addresses.
This helps clients using a userland stack to support multihoming if
they are not behind a NAT.

MFC after: 1 week
2016-05-01 21:48:55 +00:00
Allan Jude
ffd50bca7e bcache read ahead may attempt to read past end of disk
The new bcache code does not know the size of the disk, and therefore may attempt to read past the end of the disk while trying to fill its read-ahead cache.

This is usually not an issue, it fails gracefully on all of my machines, but some BIOSes seem to retry the reads for up to 30 seconds each, resulting in a long stall during boot

Submitted by:	Toomas Soome <tsoome@me.com>
Reviewed by:	jhb, np
Differential Revision:	https://reviews.freebsd.org/D6109
2016-05-01 21:06:59 +00:00
Andriy Voskoboinyk
88a755106d net80211: calculate IEEE80211_MODE_BYTES / IEEE80211_CHAN_BYTES
instead of hardcoding it.

Suggested by:	adrian
2016-05-01 20:57:10 +00:00
Andriy Voskoboinyk
7b45c9dfe1 rum: switch to ieee80211_add_channel_list_*()
- Use device's channel list instead of default one
(from ieee80211_init_channels()).
- Add ic_getradiocaps() method.

Added channels:
2GHz band: 12, 13 and 14.
5Ghz band: 34, 38, 42, 46 and 165.

Tested with WUSB54GC, STA / MONITOR modes.

Differential Revision:	https://reviews.freebsd.org/D6125
2016-05-01 18:53:12 +00:00
Andriy Voskoboinyk
7f145aba97 otus: switch to ieee80211_add_channel_list_*()
- Use device's channel list instead of default one
(from ieee80211_init_channels()).
- Sort channels (ieee80211_add_channel_list_* requirement).
- Add ic_getradiocaps() method.

Added channels:
2GHz band: 12, 13 and 14.
5GHz band: 34, 38, 42, 46 and 165.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D6145
2016-05-01 18:15:40 +00:00
Konstantin Belousov
e9d37c9f8d Avoid duplicated calls to pmap_page_get_memattr().
Avoid logging inconsistency for the /dev/mem device at all. The driver
leaves memattr intact, and the corrective action in the device pager
handles it right.

In the logged warning, name the driver we blame, and show memory
attributes values.

Reported and tested by:	pho
Reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D6149
2016-05-01 17:48:43 +00:00
Konstantin Belousov
e1da986b54 Make it explicit that D_MEM cdevsw d_flag is to signify that the
driver is (or behaves identically to) /dev/mem.  Remove the D_MEM flag
from random drivers.

Note that currently the D_MEM flag does not affect any behaviour, but
this going to change in the next commit.

Noted and reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
X-Differential revision:	https://reviews.freebsd.org/D6149
2016-05-01 17:46:56 +00:00
Andriy Voskoboinyk
5c1f6e21a5 iwm: switch to ieee80211_add_channel()
- Switch to ieee80211_add_channel().
- Parse/set more channel flags (DFS, NOADHOC).
- Add ic_getradiocaps() method.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D6150
2016-05-01 14:27:27 +00:00
Adrian Chadd
82f860283c [iwn] fill in the TX command rate info flags consistently.
The Linux driver sets the rate_n_flags regardless of whether it's being
sent using firmware rate control or local rate control.  This includes
the antenna configuration.

Thanks to Kyle Evans <kevans91@ksu.edu> for pointing this out to me
and doing some investigation/testing on his end.

Tested:

* Intel 7260 STA, 2G and 5G networks
2016-05-01 05:01:10 +00:00
Pedro F. Giffuni
20d7fee404 powerpc: Replace rounddown() from r298856 with roundup().
Both are equivalent but roundup is more logical for this case.
Catch another case while here.

Pointed out by:	jhibbits
2016-04-30 19:50:59 +00:00
Robert Watson
a75a7d90e9 When attempting to satisfy mmap() requests for superpage alignment on
64-bit MIPS, use superpage rather than physical-segment constants, or
we may improperly fail to apply suitable alignment -- yet still allow
mmap() to appear to succeed.

Reviewed by:	sson
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2016-04-30 19:29:03 +00:00
Pedro F. Giffuni
a1118f872e powerpc: Make use of our rounddown() macro when sys/param.h is available.
No functional change.
2016-04-30 18:56:35 +00:00
Emmanuel Vadot
22d6365976 ACK the interrupt after disabling it, this avoid an interrupt storm.
Approved by:	andrew (mentor)
2016-04-30 18:07:13 +00:00
Andrew Turner
cca48a59de Add a MULTIDELAY option to allow the ARM kernel to have multiple DELAY
implementations. Early in the boot the kernel will use an approximate,
however after the timer has been probed it will switch to a more accurate
implementation.

Reviewed by:	manu
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5762
2016-04-30 17:27:33 +00:00
Ed Maste
58fef175e4 Rationalize license numbering in fdescfs(5) 2016-04-30 16:01:37 +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
Michael Tuexen
7154bf4a41 Add the UDP encaps port as a parameter to sctp_add_remote_addr().
This is currently only a code change without any functional
change. But this allows to set the remote encapsulation port
in a more detailed way, which will be provided in a follow-up
commit.

MFC after: 1 week
2016-04-30 14:25:00 +00:00
Ed Maste
799e4e488f ANSIfy fdescfs(5) 2016-04-30 12:44:03 +00:00
Jung-uk Kim
4cf287c011 Revert AccessWidth/BitOffset support for AcpiHwWrite() and AcpiHwRead() for
now.  The following upstream commits are reverted from hwregs.c:

https://github.com/acpica/acpica/commit/96ece05
https://github.com/acpica/acpica/commit/3d8583a
https://github.com/acpica/acpica/commit/48eea5e
https://github.com/acpica/acpica/commit/0a212c3
https://github.com/acpica/acpica/commit/41f6aef
https://github.com/acpica/acpica/commit/26434b9
https://github.com/acpica/acpica/commit/c23034a
https://github.com/acpica/acpica/commit/c49a751

Note this commit will be reverted when the upstream fixes the code properly.
2016-04-30 06:48:48 +00:00
Pedro F. Giffuni
88ebc8558f boot/forth: spelling fixes.
Reviewed by: dteske
MFC after: 2 weeks
2016-04-30 02:47:41 +00:00
Pedro F. Giffuni
1ce4275dd2 sys/compat/linux*: spelling fixes.
Mostly on comments but there are some user-visible messages as well.

MFC after: 2 weeks
2016-04-30 00:53:10 +00:00
Pedro F. Giffuni
72ffecf147 ndis: spelling fixes in comments.
No functional change.
2016-04-30 00:35:46 +00:00
Pedro F. Giffuni
2bede1b82a x86bios: spelling fix in a comment.
No functional change.
2016-04-30 00:34:04 +00:00
Pedro F. Giffuni
5d708ee940 sys/boot: spelling fixes in comments.
No functional change.
2016-04-30 00:26:38 +00:00
John Baldwin
c41df40133 Add PCI_IOV to NOTES. 2016-04-29 23:55:22 +00:00
John Baldwin
e131ba36e8 Move 'device pci' for the PCI bus driver to the MI NOTES file.
The PCI bus was already listed in all of the MD NOTES files and the
driver should at least compile on all platforms.
2016-04-29 23:53:55 +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
Oleksandr Tymoshenko
26f47fdd8f Add FDT overlays support to ubldr
FDT overlays is de-facto standard for describing expansion boards like
Beaglebone capes or Raspberry Pi shields. The ides is to have basic
DTB for base board and overlays DTB for shields/capes and to construct
final DTB either using human-readable configuration or some
self-discovery mechanism. I believe this approach can also be expanded
to support dynamically loadable FPGA bitstreams on systems like
Zedboard/Zybo.

Overlaying process is simmilar to executable link process for
binaries: each DTB has "exported" symbols and "undefined" symbols, the
latter are resolved using information for the former obtained from
base DTB or one of the overlays applied earlier (more rare case).

This symbols information is not generated by standard dtc that FreeBSD
has in base system, patched[1] version required to produces
overlay-compatible blobs. So although DTB files generated by
buildkernel do not support overlays there are enough
vendor/community-provided DTB blobs ciruclating around to justify
committing this change to ubldr.

This commit introduces handler for "fdt_overlays" variable that can be
defined either as a loader env variable or U-Boot env variable.
fdt_overlays is comma-separated list of .dtbo files located in
/boot/dtb/ directory along with base .dtb. ubldr loads files and
applies them one-by-one to base .dtb and then passes result blob to
the kernel.

[1] dd6a0533e8

Differential Revision:	https://reviews.freebsd.org/D3180
2016-04-29 22:42:59 +00:00
John Baldwin
9f7f2d8f89 Remove vestiges of IEEE-488/GPIB drivers removed in r276214. 2016-04-29 22:29:33 +00:00
Pedro F. Giffuni
e3043798aa sys/kern: spelling fixes in comments.
No functional change.
2016-04-29 22:15:33 +00:00
Andriy Voskoboinyk
a061fea6ee net80211 + drivers: hide size of 'bands' array behind a macro.
Auto-replace 'howmany(IEEE80211_MODE_MAX, 8)' with 'IEEE80211_MODE_BYTES'.
No functional changes.
2016-04-29 22:14:11 +00:00
Pedro F. Giffuni
31b6732008 sys/kern: spelling fixes.
Mostly on comments but affects some debug messages.

MFC after: 2 weeks
2016-04-29 21:54:28 +00:00
Jared McNeill
e7502187c2 Set txbuf_map array size to TX_DESC_COUNT instead of RX_DESC_COUNT. 2016-04-29 21:46:43 +00:00
Andriy Voskoboinyk
bc502553a6 wpi: remove unused variable. 2016-04-29 21:38:36 +00:00
Alan Somers
c9a807447d Fix a use-after-free when "zpool import" fails
clear vd->vdev_tsd in vdev_geom_close_locked instead of vdev_geom_detach.
In the latter function, it would fail to happen in certain circumstances
where cp->private was unset.  Ideally, the latter should never happen, but
it can happen when vdev open fails, or where spares are involved.

MFC after:	4 weeks
X-MFC-With:	298786
Sponsored by:	Spectra Logic Corp
2016-04-29 21:29:37 +00:00
Pedro F. Giffuni
053359b7f4 sys/netgraph: spelling fixes in comments.
No functional change.
2016-04-29 21:25:05 +00:00
Andriy Voskoboinyk
355fec4842 net80211: provide a set of ieee80211_add_channel*() functions
This change adds few methods for net80211 channel table setup:

- ieee80211_add_channel()
- ieee80211_add_channel_ht40()
(primarily for drivers, that parse EEPROM to get channel list -
they will allow to hide implementation details).

- ieee80211_add_channel_list_2ghz()
- ieee80211_add_channel_list_5ghz()
(mostly as a replacement for ieee80211_init_channels() - they will allow
to specify non-default channel list; may be used in ic_getradiocaps()).

Tested with wpi(4) (add_channel) and rum(4) (add_channel_list_2ghz).

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D6124
2016-04-29 21:18:14 +00:00
Alan Somers
794277da54 Automate the subr_unit test.
Build and install the subr_unit test program originally written by phk, and
run it with the other ATF tests.

tests/sys/kern/Makefile
	* Build and install the subr_unit test as a plain test

sys/kern/subr_unit.c
	* Reduce the default number of repetitions from 100 to 1, and add a
	  command-line parser to override it.
	* Don't be so noisy by default
	* Fix an include problem for the test build

Reviewed by:	ngie
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6038
2016-04-29 21:11:31 +00:00
Pedro F. Giffuni
1ffe58516c sys/cam: spelling fixes in comments.
No functional change.
2016-04-29 21:05:48 +00:00
Pedro F. Giffuni
d63978e2b6 sys/cam: spelling fixes.
Affects a debug message.

MFC after: 2 weeks
2016-04-29 21:04:06 +00:00
Pedro F. Giffuni
e8d5712284 sys/geom: spelling fixes in comments.
No functional change.
2016-04-29 20:56:58 +00:00
Pedro F. Giffuni
ad29e12e0c sys/ddb: spelling fixes in comments.
No functional change.
2016-04-29 20:53:39 +00:00
Pedro F. Giffuni
b3a15ddd5b sys/fs: spelling fixes in comments.
No functional change.
2016-04-29 20:51:24 +00:00