Commit Graph

503 Commits

Author SHA1 Message Date
Konstantin Belousov
48ce5d4cac Provide yet another KPI for cdev creation, make_dev_s(9).
Immediate problem fixed by the new KPI is the long-standing race
between device creation and assignments to cdev->si_drv1 and
cdev->si_drv2, which allows the window where cdevsw methods might be
called with si_drv1,2 fields not yet set.  Devices typically checked
for NULL and returned spurious errors to usermode, and often left some
methods unchecked.

The new function interface is designed to be extensible, which should
allow to add more features to make_dev_s(9) without inventing yet
another name for function to create devices, while maintaining KPI and
even KBI backward-compatibility.

Reviewed by:	hps, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D4746
2016-01-07 20:08:02 +00:00
John Baldwin
ce204e1bd8 Add accessor methods to fetch the BAR holding the MSI-X table and PBA.
While here, explicitly note the requirement that the BAR(s) must be
allocated prior to calling pci_alloc_msix().

Reviewed by:	andrew, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D4688
2015-12-23 21:51:10 +00:00
Jonathan T. Looney
54503a13d8 Add a safety net to reclaim mbufs when one of the mbuf zones become
exhausted.

It is possible for a bug in the code (or, theoretically, even unusual
network conditions) to exhaust all possible mbufs or mbuf clusters.
When this occurs, things can grind to a halt fairly quickly. However,
we currently do not call mb_reclaim() unless the entire system is
experiencing a low-memory condition.

While it is best to try to prevent exhaustion of one of the mbuf zones,
it would also be useful to have a mechanism to attempt to recover from
these situations by freeing "expendable" mbufs.

This patch makes two changes:

a) The patch adds a generic API to the UMA zone allocator to set a
function that should be called when an allocation fails because the
zone limit has been reached. Because of the way this function can be
called, it really should do minimal work.

b) The patch uses this API to try to free mbufs when an allocation
fails from one of the mbuf zones because the zone limit has been
reached. The function schedules a callout to run mb_reclaim().

Differential Revision:	https://reviews.freebsd.org/D3864
Reviewed by:	gnn
Comments by:	rrs, glebius
MFC after:	2 weeks
Sponsored by:	Juniper Networks
2015-12-20 02:05:33 +00:00
Mark Johnston
711fbd17ec Add helper functions proc_readmem() and proc_writemem().
These helper functions can be used to read in or write a buffer from or to
an arbitrary process' address space. Without them, this can only be done
using proc_rwmem(), which requires the caller to fill out a uio. This is
onerous and results in code duplication; the new functions provide a simpler
interface which is sufficient for most existing callers of proc_rwmem().

This change also adds a manual page for proc_rwmem() and the new functions.

Reviewed by:	jhb, kib
Differential Revision:	https://reviews.freebsd.org/D4245
2015-12-07 21:33:15 +00:00
Christian Brueffer
a8b75f756d Add an MLINK for m_collapse.
PR:		204205
Submitted by:	avos
MFC after:	1 week
2015-12-07 19:08:33 +00:00
Randall Stewart
f5206d3f71 Some basic documentation (a man page) on kern_testfrwk 2015-11-12 11:42:01 +00:00
Randall Stewart
96eacdfdc2 Add the MLINK for async_drain Thanks Edward for the pointer.
MFC after:	1 month
2015-11-11 23:10:09 +00:00
Mark Johnston
635458bc06 Add a manual page for PHOLD() and friends.
MFC after:	1 week
2015-11-08 01:41:44 +00:00
Conrad Meyer
be87839e56 Round out SYSCTL macros to the full set of fixed-width types
Add S8, S16, S32, and U32 types;  add SYSCTL*() macros for them, as well
as for the existing 64-bit types.  (While SYSCTL*QUAD and UQUAD macros
already exist, they do not take the same sort of 'val' parameter that
the other macros do.)

Clean up the documented "types" in the sysctl.9 document.  (These are
macros and thus not real types, but the manual page documents intent.)

The sysctl_add_oid(9) arg2 has been bumped from intptr_t to intmax_t to
accommodate 64-bit types on 32-bit pointer architectures.

This is just the kernel support piece; the userspace sysctl(1) support
will follow in a later patch.

Submitted by:	Ravi Pokala <rpokala@panasas.com>
Reviewed by:	cem
Relnotes:	no
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D4091
2015-11-07 01:43:01 +00:00
Adrian Chadd
791b3571a2 remove \, it confuses things. 2015-11-05 22:50:21 +00:00
John Baldwin
87dd2f95d2 Add a new helper function for PCI devices to locate the upstream
PCI-express root port of a given PCI device.

Reviewed by:	kib, imp
MFC after:	1 week
Sponsored by:	Chelsio
Differential Revision:	https://reviews.freebsd.org/D4089
2015-11-05 21:27:25 +00:00
John Baldwin
ec603c7297 Add helper routines for PCI device drivers to read, write, and modify
PCI-Express capability registers (that is, PCI config registers in the
standard PCI config space belonging to the PCI-Express capability
register set).

Note that all of the current PCI-e registers are either 16 or 32-bits,
so only widths of 2 or 4 bytes are supported.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Chelsio
Differential Revision:	https://reviews.freebsd.org/D4088
2015-11-05 21:26:06 +00:00
Conrad Meyer
fb61390c99 sysctl(9): Document U8/U16 types from r289773
Suggested by:	ngie
Sponsored by:	EMC / Isilon Storage Division
2015-10-23 15:08:16 +00:00
Conrad Meyer
5546be25d6 Document cpuset(9)
A follow-up to r289467.

Coerced by:	jhb
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 23:48:14 +00:00
Conrad Meyer
7ebf41220c Document bitset(9) 2015-10-17 19:55:58 +00:00
Enji Cooper
f2e3428854 Remove MLINKS to more non-existent mbuf(9) macros
X-MFC with: r288295
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2015-09-27 04:55:43 +00:00
Enji Cooper
c91afdd4d0 Posthumously remove all references to MFREE(9)
The macro was removed in r90227

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2015-09-27 04:40:54 +00:00
Conrad Meyer
0d27967e31 Document bus_get_resource(9).
Suggested by:	Francois Tigeot
Obtained from:	DragonFlyBSD 09301a2b29f3ae5edd39a858f909f8770372f71e
Sponsored by:	EMC / Isilon Storage Division
2015-09-26 14:52:47 +00:00
Hans Petter Selasky
c55f4c9445 Revert r287780 until more developers have their say.
Differential Revision:	https://reviews.freebsd.org/D3521
Requested by:		gnn
2015-09-22 06:51:55 +00:00
Hans Petter Selasky
9acc0eafd7 Implement callout_drain_async(), inspired by the projects/hps_head
branch.

This function is used to drain a callout via a callback instead of
blocking the caller until the drain is complete. Refer to the
callout_drain_async() manual page for a detailed description.

Limitation: If a lock is used with the callout, the callout can only
be drained asynchronously one time unless the callout_init_mtx()
function is called again. This limitation is not present in
projects/hps_head and will require more invasive changes to the
timeout code, which was not in the scope of this patch.

Differential Revision:	https://reviews.freebsd.org/D3521
Reviewed by:		wblock
MFC after:		1 month
2015-09-14 10:52:26 +00:00
Warner Losh
ae1f3df434 New 1-Wire bus implementation. 1-Wire controller is abstracted, though
only gpiobus configured via FDT is supported. Bus enumeration is
supported. Devices are created for each device found. 1-Wire
temperature controllers are supported, but other drivers could be
written. Temperatures are polled and reported via a sysctl.  Errors
are reported via sysctl counters. Mis-wired bus detection is included
for more trouble shooting. See ow(4), owc(4) and ow_temp(4) for
details of what's supported and known issues.

This has been tested on Raspberry Pi-B, Pi2 and Beagle Bone Black
with up to 7 devices.

Differential Revision: https://reviews.freebsd.org/D2956
Relnotes: yes
MFC after: 2 weeks
Reviewed by: loos@ (with many insightful comments)
2015-08-27 23:33:38 +00:00
Bryan Drewery
7ec1b6b672 Add link for rw_unlock(9) to rwlock(9).
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2015-08-20 18:22:06 +00:00
Jason A. Harmening
cbaa6a0e0c Create man page for pmap_quick_enter_page(9) and pmap_quick_remove_page(9)
Reviewed by:	kib, brueffer, wblock
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D3312
2015-08-07 12:13:15 +00:00
Edward Tomasz Napierala
cdc3449233 Revert r286236; vgonel() is a static function.
Sponsored by:	The FreeBSD Foundation
2015-08-04 08:16:18 +00:00
Edward Tomasz Napierala
6a968be547 Document vgonel(9).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-08-03 16:30:47 +00:00
Ed Schouten
707d98fe2f Implement the CloudABI random_get() system call.
The random_get() system call works similar to getentropy()/getrandom()
on OpenBSD/Linux. It fills a buffer with random data.

This change introduces a new function, read_random_uio(), that is used
to implement read() on the random devices. We can call into this
function from within the CloudABI compatibility layer.

Approved by:	secteam
Reviewed by:	jmg, markm, wblock
Obtained from:	https://github.com/NuxiNL/freebsd
Differential Revision:	https://reviews.freebsd.org/D3053
2015-07-14 18:45:15 +00:00
Mariusz Zaborski
58c86148dd Move nvlist documentation to the FreeBSD Kernel Developer's sections.
Approved by:	pjd (mentor)
2015-07-04 10:27:30 +00:00
John Baldwin
f3bb925153 Create a separate kobj interface for leaf-driver PCI IOV methods.
Leaf drivers should not import the PCI bus interface to add IOV handling.
Instead, move the IOV client methods to a separate kobj interface.

Differential Revision:	https://reviews.freebsd.org/D2584
Reviewed by:	rstone
2015-05-28 22:01:50 +00:00
Bryan Drewery
6b46b078b7 Remove references to Giant in namei(9). This was removed in r241896.
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2015-05-07 01:55:39 +00:00
Mark Johnston
da10a60340 Make vpanic() externally visible so that it can be called as part of the
DTrace panic() action.

Differential Revision:	https://reviews.freebsd.org/D2349
Reviewed by:	avg
MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-04-24 03:17:21 +00:00
Ryan Stone
1fe9f6f6a7 Document the interface for defining a configuration schema
Differential Revision:	https://reviews.freebsd.org/D89
Reviewed by:		wblock, emaste, allanjude
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:59:21 +00:00
Ryan Stone
e1de57232c Add manpages for SR-IOV enable/disable driver interface
Differential Revision:	https://reviews.freebsd.org/D75
Reviewed by:		wblock
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:01 +00:00
Ryan Stone
7d971e363e Document pci_iov_attach/detach in pci.9
Differential Revision:	https://reviews.freebsd.org/D74
Reviewed by:		bcr, wblock, emaste
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:39:55 +00:00
Enji Cooper
b6f503dde0 Clean up more usb related files when MK_USB == no when dealing with
manpages, libraries, and binaries

MFC after: 1 week
X-MFC with: r278135
Sponsored by: EMC / Isilon Storage Division
2015-02-04 11:43:19 +00:00
Warner Losh
5a63bdd39b spl man page hasn't been relevant for a while, retire it. 2015-01-25 04:58:41 +00:00
Hans Petter Selasky
a115fb62ed Revert for r277213:
FreeBSD developers need more time to review patches in the surrounding
areas like the TCP stack which are using MPSAFE callouts to restore
distribution of callouts on multiple CPUs.

Bump the __FreeBSD_version instead of reverting it.

Suggested by:		kmacy, adrian, glebius and kib
Differential Revision:	https://reviews.freebsd.org/D1438
2015-01-22 11:12:42 +00:00
Hans Petter Selasky
1a26c3c047 Major callout subsystem cleanup and rewrite:
- Close a migration race where callout_reset() failed to set the
  CALLOUT_ACTIVE flag.
- Callout callback functions are now allowed to be protected by
  spinlocks.
- Switching the callout CPU number cannot always be done on a
  per-callout basis. See the updated timeout(9) manual page for more
  information.
- The timeout(9) manual page has been updated to reflect how all the
  functions inside the callout API are working. The manual page has
  been made function oriented to make it easier to deduce how each of
  the functions making up the callout API are working without having
  to first read the whole manual page. Group all functions into a
  handful of sections which should give a quick top-level overview
  when the different functions should be used.
- The CALLOUT_SHAREDLOCK flag and its functionality has been removed
  to reduce the complexity in the callout code and to avoid problems
  about atomically stopping callouts via callout_stop(). If someone
  needs it, it can be re-added. From my quick grep there are no
  CALLOUT_SHAREDLOCK clients in the kernel.
- A new callout API function named "callout_drain_async()" has been
  added. See the updated timeout(9) manual page for a complete
  description.
- Update the callout clients in the "kern/" folder to use the callout
  API properly, like cv_timedwait(). Previously there was some custom
  sleepqueue code in the callout subsystem, which has been removed,
  because we now allow callouts to be protected by spinlocks. This
  allows us to tear down the callout like done with regular mutexes,
  and a "td_slpmutex" has been added to "struct thread" to atomically
  teardown the "td_slpcallout". Further the "TDF_TIMOFAIL" and
  "SWT_SLEEPQTIMO" states can now be completely removed. Currently
  they are marked as available and will be cleaned up in a follow up
  commit.
- Bump the __FreeBSD_version to indicate kernel modules need
  recompilation.
- There has been several reports that this patch "seems to squash a
  serious bug leading to a callout timeout and panic".

Kernel build testing:	all architectures were built
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D1438
Sponsored by:		Mellanox Technologies
Reviewed by:		jhb, adrian, sbruno and emaste
2015-01-15 15:32:30 +00:00
Kevin Lo
2433b5f10f Replace CC_VAR with CCV, since the CC_VAR macro doesn't exist.
While here, add MLINK for CCV.9 and DECLARE_CC_MODULE.9.
2014-12-25 15:17:57 +00:00
Enji Cooper
0341ccf227 Clean up more usb related files when MK_USB == no when dealing with
manpages, libraries, and binaries
2014-11-26 21:18:52 +00:00
Andriy Gapon
088b124ba7 callout(9): add sbt flavors of callout_schedule
Differential Revision:	https://reviews.freebsd.org/D1161 (partial)
Reviewed by:	jhb, markj
MFC after:	1 week
2014-11-25 15:21:21 +00:00
Craig Rodrigues
abf832a879 Create a vimage.9 link to vnet.9
Requested by: glebius
2014-11-21 17:57:37 +00:00
Craig Rodrigues
9ca24f65c5 MFp4: @179066
Add page which describes VNET network stack virtualization infrastructure.

Submitted by: bz
Sponsored by: The FreeBSD Foundation
Sponsored by: CK Software GmbH
2014-11-20 09:56:34 +00:00
Jung-uk Kim
1561b87885 Actually install casuword(9) to fix build. 2014-10-28 16:19:02 +00:00
Konstantin Belousov
4f3dc90023 Add fueword(9) and casueword(9) functions. They are like fuword(9)
and casuword(9), but do not mix value read and indication of fault.

I know (or remember) enough assembly to handle x86 and powerpc.  For
arm, mips and sparc64, implement fueword() and casueword() as wrappers
around fuword() and casuword(), which means that the functions cannot
distinguish between -1 and fault.

On architectures where fueword() and casueword() are native, implement
fuword() and casuword() using fueword() and casuword(), to reduce
assembly code duplication.

Sponsored by:	The FreeBSD Foundation
Tested by:	pho
MFC after:	2 weeks (ia64 needs treating)
2014-10-28 15:22:13 +00:00
Hans Petter Selasky
f0188618f2 Fix multiple incorrect SYSCTL arguments in the kernel:
- Wrong integer type was specified.

- Wrong or missing "access" specifier. The "access" specifier
sometimes included the SYSCTL type, which it should not, except for
procedural SYSCTL nodes.

- Logical OR where binary OR was expected.

- Properly assert the "access" argument passed to all SYSCTL macros,
using the CTASSERT macro. This applies to both static- and dynamically
created SYSCTLs.

- Properly assert the the data type for both static and dynamic
SYSCTLs. In the case of static SYSCTLs we only assert that the data
pointed to by the SYSCTL data pointer has the correct size, hence
there is no easy way to assert types in the C language outside a
C-function.

- Rewrote some code which doesn't pass a constant "access" specifier
when creating dynamic SYSCTL nodes, which is now a requirement.

- Updated "EXAMPLES" section in SYSCTL manual page.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
2014-10-21 07:31:21 +00:00
Li-Wen Hsu
e444e04b67 Reflect the chanages in sleepqueue.h and subr_sleepqueue.c
- Priority argument is introduced to sleepq_*wait* in r177085
- sleepq_calc_signal_retval is removed from implementation
- sleepq_catch_signals is internal now

Differential Revision:	https://reviews.freebsd.org/D794
Reviewed by:	jhb
Approved by:	jhb
2014-09-22 19:14:27 +00:00
Edward Tomasz Napierala
a5b1f2ab54 Add missing mlinks for section 9.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-09-22 13:04:49 +00:00
Edward Tomasz Napierala
40972ae5b9 Add missing link to TIMEOUT_TASK_INIT(9).
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-09-18 13:56:32 +00:00
Edward Tomasz Napierala
3fc12d241c Add missing links to taskqueue(9).
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-09-18 13:39:47 +00:00
Hans Petter Selasky
b5177e001b Add description of "sysctl_remove_name()" function. 2014-08-28 04:35:38 +00:00