Commit Graph

155 Commits

Author SHA1 Message Date
Hans Petter Selasky
12af734d32 Add more LinuxKPI PCI definitions.
Obtained from:	kmacy @
Sponsored by:	Mellanox Technologies
MFC after:	1 week
2016-12-09 15:05:09 +00:00
Hans Petter Selasky
1724ded49c Prefer function macros over regular macros in the LinuxKPI.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-12-09 15:01:37 +00:00
Hans Petter Selasky
be48ab92ac Avoid malloc() warnings when using the LinuxKPI by zero-checking
the allocation flags.

Obtained from:		kmacy @
Sponsored by:           Mellanox Technologies
MFC after:		1 week
2016-12-09 14:06:22 +00:00
Hans Petter Selasky
0a61267a99 MSIX can support more than 256 IRQs. Make sure the invalid IRQ number
set in the LinuxKPI is big enough.

Sponsored by:           Mellanox Technologies
MFC after:		1 week
2016-12-09 13:53:31 +00:00
Hans Petter Selasky
e996b07c72 Prefix some _pci_xxx() functions in the Linux KPI with linux_ and make
sure the IRQ number used by these functions is unsigned.

Sponsored by:           Mellanox Technologies
MFC after:		1 week
2016-12-09 13:47:50 +00:00
Hans Petter Selasky
7fdce5c42b Prefix the Linux KPI's kmem_xxx() functions with linux_ to avoid
conflict with the opensolaris kernel module.

This patch solves a problem where the kernel linker will incorrectly
resolve opensolaris kmem_xxx() functions as linuxkpi ones, which leads
to a panic when these functions are used.

Submitted by:		gallatin @
Sponsored by:           Mellanox Technologies
MFC after:		1 week
2016-12-09 13:41:26 +00:00
Sepherosa Ziehau
6faefea03b linuxkpi: Fix PCI BAR lazy allocation support.
FreeBSD supports lazy allocation of PCI BAR, that is, when a device
driver's attach method is invoked, even if the device's PCI BAR
address wasn't initialized, the invocation of bus_alloc_resource_any()
(the call chain: pci_alloc_resource() -> pci_alloc_multi_resource() ->
pci_reserve_map() -> pci_write_bar()) would allocate a proper address
for the PCI BAR and write this 'lazy allocated' address into the PCI
BAR.

This model works fine for native FreeBSD device drivers, but _not_ for
device drivers shared with Linux (e.g. dev/mlx5/mlx5_core/mlx5_main.c
and ofed/drivers/net/mlx4/main.c.  Both of them use
pci_request_regions(), which doesn't work properly with the PCI BAR
lazy allocation, because pci_resource_type() -> _pci_get_rle() always
returns NULL, so pci_request_regions() doesn't have the opportunity to
invoke bus_alloc_resource_any().  We now use pci_find_bar() in
pci_resource_type(), which is able to locate all available PCI BARs
even if some of them will be lazy allocated.

Submitted by:	Dexuan Cui <decui microsoft com>
Reviewed by:	hps
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8071
2016-09-30 05:51:11 +00:00
Hans Petter Selasky
bdff61f849 The IORESOURCE_XXX defines should resemble a bitmask while SYS_RES_XXX
are not bitmasks. Fix return value of pci_resource_flags() to reflect
this change.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-09-29 14:35:32 +00:00
Mark Johnston
8de3effe5e Add a missing error check for a malloc() call in idr_get().
Submitted by:	Matt Joras <mjoras@isilon.com>
Approved by:	re (gjb)
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-06-14 03:57:00 +00:00
Hans Petter Selasky
d8571d3ea3 Fallback to arc4rand() in the LinuxKPI when read_random() returns
zero. This can happen for virtual machines.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-06-07 13:10:13 +00:00
Hans Petter Selasky
8eeb3e1773 The SCHEDULER_STOPPED() macro already contains a predict false statement.
Remove superfluous unlikely() wrapper.

Suggested by:	glebius
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-27 07:33:49 +00:00
Hans Petter Selasky
2bb46d5516 Define ATOMIC_LONG_INIT() in the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-26 10:03:22 +00:00
Hans Petter Selasky
06ca64ecf3 Add support for runtime modifiable module parameters in the LinuxKPI.
Linux module parameters have a permissions value. If any write bits
are set we are allowed to modify the module parameter runtime. Reflect
this when creating the static SYSCTL nodes.

Sponsored by:	Mellanox Technologies
MFC after:	1 week
2016-05-26 09:04:14 +00:00
Hans Petter Selasky
707324edee Add more module parameter macros to the LinuxKPI.
Obtained from:	kmacy @
Sponsored by:	Mellanox Technologies
2016-05-26 08:47:06 +00:00
Hans Petter Selasky
0bb3dd300b Add support for boolean module parameters in the LinuxKPI.
Requested by:	kmacy @
Sponsored by:	Mellanox Technologies
2016-05-26 08:44:11 +00:00
Hans Petter Selasky
1d9b99e5e3 Implement Linux module parameters as read-only tunable SYSCTLs.
Bool module parameters are no longer supported, because there is no
equivalent in FreeBSD.

There are two macros available which control the behaviour of the
LinuxKPI module parameters:

- LINUXKPI_PARAM_PARENT allows the consumer to set the SYSCTL parent
where the modules parameters will be created.

- LINUXKPI_PARAM_PREFIX defines a parameter name prefix, which is
  added to all created module parameters.

Sponsored by:	Mellanox Technologies
MFC after:	1 week
2016-05-25 12:12:14 +00:00
Hans Petter Selasky
8571421886 Add checks for SCHEDULER_STOPPED() so that code using the LinuxKPI can
run after a panic(). This for example allows a LinuxKPI based graphics
stack to receive prints during a panic.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-25 09:04:06 +00:00
Kevin Lo
8636496407 Add __iowrite32_copy() to the Linux kernel compatibility layer.
Reviewed by:	hselasky
2016-05-24 09:23:04 +00:00
Hans Petter Selasky
9183a497e7 Use the DROP_GIANT() and PICKUP_GIANT() macros instead of making
assumptions about how the Giant mutex is locked.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-24 07:52:53 +00:00
Hans Petter Selasky
3ce1263063 Set "current" for all PCI enumeration callbacks.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-24 07:46:20 +00:00
Hans Petter Selasky
5a6748b2cf Use make_dev_s() instead of make_dev() to avoid race setting
"si_drv1". Convert panic() into regular error while at it.

Suggested by:	jhb @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-24 07:06:04 +00:00
Hans Petter Selasky
44701cf732 Implement "atomic_long_add_unless()" in the LinuxKPI and fix the
implementation of "atomic_long_inc_not_zero()".

Found by:	ngie @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 16:19:51 +00:00
Hans Petter Selasky
8b68f2509f A missing definition needed by ktime_to_ms().
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 13:19:20 +00:00
Hans Petter Selasky
425da8eb61 Fix some data types and add "inline" keyword for __reg_op() function.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 13:18:15 +00:00
Hans Petter Selasky
83cfd83419 Implement ror32() in the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 12:53:17 +00:00
Hans Petter Selasky
fb2faed84e Define more copy to/from userspace functions in the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 12:52:22 +00:00
Hans Petter Selasky
aef2a67b83 Add more printf() related functions to the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 12:35:07 +00:00
Hans Petter Selasky
3092e0c54c Set an invalid IRQ number when no PCI IRQ is available in the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 12:13:16 +00:00
Hans Petter Selasky
7dfa8b2c4e Add more ktime related functions to the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 12:10:28 +00:00
Hans Petter Selasky
08a5e6ec7f Implement "kref_put_mutex()" for the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 12:06:34 +00:00
Hans Petter Selasky
aad02fb444 Add more list_xxx() functions to the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 12:03:40 +00:00
Hans Petter Selasky
0f8f7f554b Make header file standalone by including definitions for needed
linux_wait_xxx() functions.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 11:57:23 +00:00
Hans Petter Selasky
94a201be43 Implement "_outb()" to the LinuxKPI for i386 and amd64 only.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 11:53:00 +00:00
Hans Petter Selasky
ed5f781270 Add support for "cdev_add_ext()" to the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 11:50:05 +00:00
Hans Petter Selasky
299f29203a Add more GFP related defines to the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 11:47:54 +00:00
Hans Petter Selasky
4a0f827906 Add support for atomic_long_inc_not_zero() to the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 11:44:46 +00:00
Hans Petter Selasky
b5c541821a Add support for atomic_long_inc_not_zero() to the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 11:41:35 +00:00
Hans Petter Selasky
0f9f74597d Only lock Giant when needed in the LinuxKPI.
Suggested by:	ngie @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-16 17:41:25 +00:00
Hans Petter Selasky
b334cdea9b Implement more Linux device related functions in the LinuxKPI. While
at it use NULL for some pointer checks.

Bump the FreeBSD version to force recompilation of all kernel modules
due to a structure size change.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-16 09:56:48 +00:00
Hans Petter Selasky
88fa0d734c Don't dereference parent pointer when it is NULL.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-16 09:25:56 +00:00
Hans Petter Selasky
03219fba43 Properly implement "cpu_has_clflush" macro.
Suggested by:	kib, jhb
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-16 09:16:15 +00:00
Hans Petter Selasky
fdddd267d7 Handle case of class being set, but not parent when calling
device_register() in the LinuxKPI.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-13 13:01:02 +00:00
Hans Petter Selasky
83d5d45ea2 Add more PAGE related defines to the LinuxKPI. Move the definition of
"pgprot_t" to "linux/page.h" similar to what Linux does.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-13 12:41:21 +00:00
Hans Petter Selasky
854e1d4e6c Implement "old_encode_dev()" for the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-13 11:51:43 +00:00
Hans Petter Selasky
374377ce91 Define _IOC_SIZE() in the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-13 11:42:36 +00:00
Hans Petter Selasky
677a229c76 Add unlikely() statement to optimise the IS_ERR_VALUE() macro.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-13 11:30:56 +00:00
Hans Petter Selasky
e320ac1958 Implement nsecs_to_jiffies() in the LinuxKPI and while at it
streamline the rest of the xxx_to_jiffies() functions to have a
constant 64-bit argument and use identical range checks for the
result.

Specifically preserve msecs_to_jiffies(0) returning 0. See r282743 for
further details.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-13 11:02:02 +00:00
Hans Petter Selasky
abb14a540f Add more Linux defines. Improve some existing ones.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-13 10:10:43 +00:00
Hans Petter Selasky
04a471587e The Linux error defines should all be positive, else frequently used
error code checks might fail. ERESTART is in the BSD world defined as
-1. While at it add more Linux error codes.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-13 09:21:22 +00:00
Hans Petter Selasky
3a8bec33ef Fix handling of IOCTLs in the LinuxKPI.
Linux requires that all IOCTL data resides in userspace. FreeBSD
always moves the main IOCTL structure into a kernel buffer before
invoking the IOCTL handler and then copies it back into userspace,
before returning. Hide this difference in the "linux_copyin()" and
"linux_copyout()" functions by remapping userspace addresses in the
range from 0x10000 to 0x20000, to the kernel IOCTL data buffer.

It is assumed that the userspace code, data and stack segments starts
no lower than memory address 0x400000, which is also stated by "man 1
ld", which means any valid userspace pointer can be passed to regular
LinuxKPI handled IOCTLs.

Bump the FreeBSD version to force recompilation of all kernel modules.

Discussed with:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-12 11:38:28 +00:00
Hans Petter Selasky
15c98ff2f1 Remove redundant "task_struct_set()".
This is done by the "linux_kthread_fn()".

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-12 09:11:18 +00:00
Hans Petter Selasky
464d20bcc8 Create a dummy "task_struct" on the stack which is returned by
"current" inside all LinuxKPI file operation callbacks. The "current"
is frequently used for various debug prints, printing the thread name
and thread ID for example.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-12 09:06:54 +00:00
Hans Petter Selasky
dacb734ea8 Match Linux behaviour and iterate the IDR tree unlocked. The caller is
responsible the IDR tree stays unmodified while iterating.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-11 17:20:20 +00:00
Hans Petter Selasky
b3c89b5ad9 Return a proper error code instead of panicing when an I/O vector
having the wrong number of entries is detected.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-11 10:50:59 +00:00
Hans Petter Selasky
fd42d62378 Add more IDR and IDA related functions to the LinuxKPI.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-11 10:40:04 +00:00
Hans Petter Selasky
f8221002a5 Factor out common code into "idr_find_layer_locked()" and fix inverted
bitmap test for free entry in "idr_replace()".

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-11 10:35:15 +00:00
Hans Petter Selasky
5d35d77707 Add missing destruction of mutex.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-11 10:06:58 +00:00
Hans Petter Selasky
8457719578 Add more atomic LinuxKPI functions.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-11 07:58:43 +00:00
Hans Petter Selasky
f2dbb750f4 Implement ioremap_wt() and use that in the MEMREMAP_WT case for i386
and amd64.

Suggested by:	cem @
Discussed with:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-10 17:51:17 +00:00
Hans Petter Selasky
684a5fef01 Add more LinuxKPI I/O functions.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-10 12:04:57 +00:00
Hans Petter Selasky
7652bc32f7 Use function macros when possible to avoid stray substitutions.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-10 11:39:36 +00:00
Hans Petter Selasky
f2f5b1337e Add missing semicolon and properly wrap macro argument.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-10 11:34:22 +00:00
Hans Petter Selasky
c7d81c66df Allow the argument for the cpu_to_xxxp() and xxx_to_cpup() macros to
point to a constant.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-10 11:31:00 +00:00
Hans Petter Selasky
0754e66c54 Fix file polling bug.
Ensure the actual poll result is returned by the "linux_file_poll()"
function instead of zero which means no data is available.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
2016-05-09 11:52:57 +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
Sepherosa Ziehau
1ea448225c tcp/lro: Change SLIST to LIST, so that removing an entry is O(1)
This is kinda critical to the performance when the CPU is slow and
network bandwidth is high, e.g. in the hypervisor.

Reviewed by:	rrs, gallatin, Dexuan Cui <decui microsoft com>
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5765
2016-04-01 06:43:05 +00:00
Navdeep Parhar
b03384114d Add wait_event_interruptible_timeout to linuxkpi.
Submitted by:	Krishnamraju Eraparaju @ Chelsio
Reviewed by:	hselasky@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D5776
2016-03-31 17:11:58 +00:00
Hans Petter Selasky
9ad5ce9d01 Fix bugs in currently unused bit searching loop.
MFC after:	3 days
Sponsored by:	Mellanox Technologies
2016-03-31 06:19:15 +00:00
Hans Petter Selasky
cb19abd277 Run the LinuxKPI PCI shutdown handler free of the Giant mutex.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-03-07 14:35:31 +00:00
Hans Petter Selasky
510ebed7be Add more functions to the LinuxKPI.
Define strnicmp as a function macro instead of a regular macro while
at it.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-03-03 09:56:04 +00:00
Svatopluk Kraus
a1e1814d76 As <machine/pmap.h> is included from <vm/pmap.h>, there is no need to
include it explicitly when <vm/pmap.h> is already included.

Reviewed by:	alc, kib
Differential Revision:	https://reviews.freebsd.org/D5373
2016-02-22 09:02:20 +00:00
Hans Petter Selasky
fe68f570d4 Update and add various macros to the LinuxKPI and resolve a macro
redefinition issue in the cxgb driver.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
Reviewed by:	np @
2016-01-26 15:26:35 +00:00
Hans Petter Selasky
c7c96d1093 LinuxKPI list updates:
- Add some new hlist macros.
- Update existing hlist macros removing the need for a temporary
  iteration variable.
- Properly define the RCU hlist macros to be SMP safe with regard
  to RCU.
- Safe list macro arguments by adding a pair of parentheses.
- Prefix the _list_add() and _list_splice() functions with "linux"
  to reflect they are LinuxKPI internal functions.

Obtained from:	Linux
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-26 15:12:31 +00:00
Hans Petter Selasky
e6ef991e5e Implement ether_addr_equal(), ether_addr_equal_64bits() and
random_ether_addr() for the LinuxKPI.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-26 14:36:16 +00:00
Hans Petter Selasky
f15ffb5e63 Implement is_vlan_dev() and vlan_dev_vlan_id() for the LinuxKPI.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-26 14:33:20 +00:00
Hans Petter Selasky
e28297940b Implement bitmap_weight() and bitmap_equal() for the LinuxKPI.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-26 14:31:20 +00:00
Hans Petter Selasky
d211177315 Add more network related macros and functions to the LinuxKPI.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-26 14:29:50 +00:00
Hans Petter Selasky
4a19cc98b3 Add definition for the NETDEV_CHANGE event and tidy up the LinuxKPI
notifier header file a bit while at it.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-26 14:27:00 +00:00
Hans Petter Selasky
9f34efb9f4 Define __get_user() and __put_user() for the LinuxKPI.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-26 14:21:30 +00:00
Hans Petter Selasky
a65ef21558 Add more LinuxKPI PCI related functions and defines.
Removed comments deriving from Linux.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-26 14:20:25 +00:00
Hans Petter Selasky
f919b7a664 Implement 64-bit atomic operations for the LinuxKPI.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-21 17:56:23 +00:00
Hans Petter Selasky
29cbb3bef2 LinuxKPI atomic fixes:
- Fix implementation of atomic_add_unless(). The atomic_cmpset_int()
  function returns a boolean and not the previous value of the atomic
  variable.
- The atomic counters should be signed according to Linux.
- Some minor cosmetics and styling while at it.

Reviewed by:	alfred @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-21 17:52:55 +00:00
Hans Petter Selasky
1f6112d50a Use function macro instead of non-function macro to reduce chance of
incorrect expansion.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-21 17:36:06 +00:00
Hans Petter Selasky
2d1bee654a Implement idr_preload(), idr_preload_end(), idr_alloc() and
idr_alloc_cyclic() in the LinuxKPI. Bump the FreeBSD version to
force recompilation of all KLDs due to IDR structure size change.

MFC after:	2 weeks
Sponsored by:	Mellanox Technologies
2016-01-21 14:57:45 +00:00
John Baldwin
e23cd1b923 Initialize vm_page_prot to VM_MEMATTR_DEFAULT instead of 0.
If a driver's Linux mmap callback passed vm_page_prot through unchanged,
then linux_dev_mmap_single() would try to apply whatever VM_MEMATTR_xxx
value 0 is to the mapping.  On x86, VM_MEMATTR_DEFAULT is the PAT value
for write-back (WB) which is 6, while 0 maps to the PAT value for
uncacheable (UC).  Thus, any mmap request that did not explicitly set
page_prot was tried to map memory as UC triggering the warning in
sg_pager_getpages().

Tested by:	np
Reported by:	Krishnamraju Eraparaju @ Chelsio
MFC after:	3 days
Sponsored by:	Chelsio Communications
2016-01-20 00:14:34 +00:00
Hans Petter Selasky
7d1333938f Implement support for PCI suspend, resume and shutdown events in the
LinuxKPI. Fix a few spaces to tabs. Bump the FreeBSD version to force
recompilation of existing KMODs.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-15 11:18:58 +00:00
Hans Petter Selasky
0c510167fb LinuxKPI style changes:
- Properly prefix internal functions with "linux_" instead of only a
  single underscore to avoid future namespace collisions.
- Make some functions global instead of inline to ease debugging and
  to avoid unnecessary code duplication.
- Remove no longer existing kthread_create() function's prototype.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-08 10:04:19 +00:00
Hans Petter Selasky
e10c4cc0a4 Implement RCU mechanism using shared exclusive locks.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-01-05 12:22:45 +00:00
Hans Petter Selasky
b648035313 Handle when filedescriptors are closed before initialized. An early
fdclose() call can cause fget_unlocked() to fail.

Found by:	mjg @
MFC after:	1 week
Reviewed by:	Mark Block <markb@mellanox.com>
Sponsored by:	Mellanox Technologies
Differential Revision:	https://reviews.freebsd.org/D4351
2015-12-31 14:47:45 +00:00
Hans Petter Selasky
06204f8e25 Minor LinuxKPI code cleanup:
- Declare some static functions in linux_compat.c instead if inside
  various header files.
- Prefix FreeBSD local functions in the LinuxKPI with "linux_" to
  avoid symbol name conflicts in the future and to make debugging
  easier.
- Make the "struct kobj_ktype" declaractions constant to shave off a
  few bytes from the data segment.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-31 12:30:19 +00:00
Hans Petter Selasky
337cb9f04c Make the kobject refcounting compliant with Linux. Refcounting on the
parent kobject cannot be factored out and must be done by the kobject
consumers.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-31 11:27:36 +00:00
Hans Petter Selasky
260194052e Reduce memory consumption when allocating kobject strings in the
LinuxKPI. Compute string length before allocating memory instead of
using fixed size allocations. Make kobject_set_name_vargs() global
instead of inline to save some bytes when compiling.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-28 18:20:05 +00:00
Hans Petter Selasky
c4e58b4efe Implement drain_workqueue() function.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-21 12:20:02 +00:00
Hans Petter Selasky
9782763db2 In the zero delay case in queue_delayed_work() use the return value
from taskqueue_enqueue() instead of reading "ta_pending" unlocked and
also ensure the callout is stopped before proceeding.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-21 12:13:03 +00:00
Hans Petter Selasky
55d445d317 Minor workqueue cleanup:
- Make some functions global instead of inline to ease debugging.
- Fix some minor style issues.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-21 11:58:59 +00:00
Hans Petter Selasky
c094330345 Implement sleepable RCU mechanism using shared exclusive locks.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-21 11:03:12 +00:00
Hans Petter Selasky
cee21041cf Implement ACCESS_ONCE(), WRITE_ONCE() and READ_ONCE().
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-21 10:56:38 +00:00
Hans Petter Selasky
f837e46d16 Add some structures and defines which will be used when decoding small
form factor, SFF, standards compliant ethernet EEPROMs.

MFC after:	1 week
Obtained from:	Linux
Sponsored by:	Mellanox Technologies
2015-12-03 12:51:54 +00:00
Hans Petter Selasky
9ce5ab9ce6 Remove incorrect defines. The proper version of these macros is
defined in linux/etherdevice.h.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-12-03 11:45:12 +00:00
Hans Petter Selasky
52ba05767f Add more functions and types to the LinuxKPI.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2015-11-30 09:24:12 +00:00