Commit Graph

215 Commits

Author SHA1 Message Date
Alexander Motin
171e3d1a1f Remove unneeded pmap_change_attr() calls.
Reported by:	kib
MFC after:	13 days
2017-08-31 17:02:06 +00:00
Alexander Motin
0faf59149c Add/polish some defines.
MFC after:	13 days
2017-08-31 16:32:11 +00:00
Alexander Motin
b6c46372af Fix port control for PEX 8749.
That chip has three Station Ports, so previous address math was incorrect.

MFC after:	13 days
Sponsored by:	iXsystems, Inc.
2017-08-31 13:41:44 +00:00
Alexander Motin
c7dabb6563 Make ntb_set_ctx() always generate fake link event.
It allows application driver get initial link state without racing with
hardware interrupts, thanks to the context rmlock held here.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2017-08-31 10:59:39 +00:00
Alexander Motin
ba4b25cbba Make ntb_transport(4) ready receive early link events.
Those events may be reported as soon as callback is registered, if the link
is enabled by hardware or some other application.

While there, clean link_is_up variable on link down event.

MFC after:	1 week
2017-08-31 10:53:10 +00:00
Alexander Motin
ed9652da5f Add NTB driver for PLX/Avago/Broadcom PCIe switches.
This driver supports both NTB-to-NTB and NTB-to-Root Port modes (though
the second with predictable complications on hot-plug and reboot events).
I tested it with PEX 8717 and PEX 8733 chips, but expect it should work
with many other compatible ones too.  It supports up to two NT bridges
per chip, each of which can have up to 2 64-bit or 4 32-bit memory windows,
6 or 12 scratchpad registers and 16 doorbells.  There are also 4 DMA engines
in those chips, but they are not yet supported.

While there, rename Intel NTB driver from generic ntb_hw(4) to more specific
ntb_hw_intel(4), so now it is on par with this new ntb_hw_plx(4) driver and
alike to Linux naming.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2017-08-30 21:16:32 +00:00
Alexander Motin
546ec4e544 Mask doorbells while processing them.
This fixes interrupt storms on hardware using legacy level-triggered
interrupts, since doorbell processing could take time after interrupt
handler completion, that triggered extra interrupts in a loop.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2017-08-28 20:00:21 +00:00
Alexander Motin
e6f000753e Fix fake interrupt when set doorbell is unmasked.
Since the doorbell bit is already set when interrupt handler is called,
the event was not propagated to upper layer.  It was working normally
because present code was not using masking actively, but that is going
to change.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2017-08-28 19:52:57 +00:00
Alexander Motin
48c4767756 Report NTB link speed to console and interface.
MFC after:	2 weeks
2017-04-23 14:25:51 +00:00
Alexander Motin
47967ab741 Pretend we support some IOCTLs to not scary upper layers.
MFC after:	2 weeks
2017-01-11 20:23:45 +00:00
Alexander Motin
7e58465356 Wrap previous MSIX workaround into #ifndef EARLY_AP_STARTUP.
With EARLY_AP_STARTUP we can successfully negotiate MSIX earlier.

Requested by:	jhb@
2016-07-30 21:06:59 +00:00
Alexander Motin
a8ec75016f Block MSIX negotiation until SMP started and IRQ reshuffled. 2016-07-30 15:56:36 +00:00
Alexander Motin
8260941c76 Make MAC address generation more random.
'ticks' approach does not work at boot time.
2016-07-30 15:51:16 +00:00
Alexander Motin
cf2e151f65 Fix infinite loops introduced at r303429. 2016-07-30 10:32:28 +00:00
Alexander Motin
718e8abba9 Fix NTBT_QP_LINKS negotiation.
I believe it never worked correctly for more the one queue even in Linux.
This fixes case when one of consumer drivers is not loaded on one side,
but its queues still announced as ready if something else brought link up.

While there, remove some pointless NULL checks.
2016-07-29 21:03:30 +00:00
Alexander Motin
75b94efd08 Clear scratchpad after MSIX negotiation to not leak garbage. 2016-07-29 20:52:18 +00:00
Alexander Motin
6bd57d14ed Once more refactor KPI between ntb_transport(4) and if_ntb(4)..
New design allows to attach multiple consumers to ntb_transport(4) instance.
Previous design obtained from Linux theoretically allowed that, but was not
practically usable (Linux also has only one consumer driver now).
2016-07-29 17:15:41 +00:00
Alexander Motin
8709930cfc Fix r303429 build with invariants. 2016-07-28 12:25:58 +00:00
Alexander Motin
4490696b3e Once more refactor KPI between NTB hardware and consumers.
New design allows hardware resources to be split between several consumers.
For example, one BAR can be dedicated for remote memory access, while other
resources can be used for packet transport for virtual Ethernet interface.
And even without resource split, this code allows to specify which consumer
driver should attach the hardware.

From some points this makes the code even closer to Linux one, even though
Linux does not provide the described flexibility.
2016-07-28 10:48:20 +00:00
Alexander Motin
c072301617 Postpone ntb_get_msix_info() till we need to negotiate MSIX.
Calling it earlier increases the window when MSIX info may change.
This change does not solve the problem completely, but seems logical.
Complete solution should probably include link reset in case of MSIX
remap to trigger new negotiation, but we have no way to get notified
about that now.
2016-07-24 14:42:11 +00:00
Sepherosa Ziehau
02888b1e1b ntb: Fix LINT
Sponsored by:	Microsoft OSTC
2016-07-12 05:41:34 +00:00
Alexander Motin
ce35eeb771 Revert odd change, setting limit registers before base.
I don't know what errata is mentioned there, I was unable to find it, but
setting limit before the base simply does not work at all.  According to
specification attempt to set limit out of the present window range resets
it to zero, effectively disabling it.  And that is what I see in practice.

Fixing this properly disables access for remote side to our memory until
respective xlat is negotiated and set.  As I see, Linux does the same.
2016-07-10 20:22:04 +00:00
Alexander Motin
9c85a81906 Fix wrong copy/paste in r302510. 2016-07-10 19:52:26 +00:00
Alexander Motin
d2de6786c1 Remove callout_reset(link_work) from ntb_transport_attach().
At that point link is quite likely not established yet, so messing with
scratch registers is premature there.  Original commit message mentioned
code diff reduction from Linux, but this line is not present in Linux now.
2016-07-10 19:15:29 +00:00
Alexander Motin
a8916479cc Simplify MSIX MW BAR xlat setup, and don't forget to unlock its limit.
The last fixes SB01BASE_LOCKUP workaround after driver reload.
2016-07-10 01:09:16 +00:00
Alexander Motin
eeed92a759 Disable SB01BASE_LOCKUP workaround when split BARs disabled.
For some reason hack with sending MSI-X interrupts by writing to remote
LAPIC memory works only for 32-bit BARs, that are available only if split
BARs mode is enabled in BIOS.  If it is not, complain loudly and fall back
to less efficient workaround.
2016-07-09 23:22:44 +00:00
Alexander Motin
c266ab3830 Improve checksum "offload" support.
For compatibility reasons make driver not report any checksum offload by
default, since there is indeed none.  But if administrator knows that
interface is used only for local traffic, he can enable fake checksum
offload manually on both sides to save some CPU cycles, since the data
are already protected by CRC32 of PCIe link.

Sponsored by:	iXsystems, Inc.
2016-07-09 14:59:16 +00:00
Alexander Motin
8795de77ce Rewrite if_ntb to use modern interface KPIs and features.
It includes: link state, if_transmit, buf_ring, multiple queues, bpf, etc.

Sponsored by:	iXsystems, Inc.
2016-07-09 12:10:08 +00:00
Alexander Motin
b42e3ec60b Improve memory allocation errors handling on receive. 2016-07-09 12:00:04 +00:00
Alexander Motin
a7e0f01a3d Synchronize MTU code with Linux.
It is mandatory for transport compatibility.
2016-07-09 11:58:59 +00:00
Alexander Motin
59850913b2 Reimplement doorbell register emulation for NTB_SB01BASE_LOCKUP.
This allows at least first three doorbells to work very close to normal
hardware, properly signaling events to upper layers without spurious or
lost events.  Doorbells above the first three may still report spurious
events due to lack of reliable information, but they are rarely used.
2016-07-09 11:57:21 +00:00
Alexander Motin
f31eea5c49 Bring some more order into link and qp state handling.
Do not touch scratchpad registers until link is reported up.
Mask and do not handle doorbell events until respective qp is up.
2016-07-09 11:48:57 +00:00
Alexander Motin
ef48f66349 Switch ctx_lock from mutex to rmlock.
It is odd idea to serialize different MSI-X vectors.  Use of rmlocks
here allows them to execute in parallel, but still protects ctx.
If upper layers require any additional serialization -- they can
do it by themselves.
2016-07-09 11:47:52 +00:00
Alexander Motin
1be8a2635c Create separate RX taskqueue for each qp. 2016-07-09 11:46:32 +00:00
Alexander Motin
784ec7043b Remove rx_completion_task taskqueue.
It is not needed after RX lock removed in previous commit.
2016-07-09 11:45:18 +00:00
Alexander Motin
0a42578f0d Remove unneeded RX lock, and make TX lock per-qp. 2016-07-09 11:43:51 +00:00
Alexander Motin
0c84bc33cf Reduce code divergence from Linux, preparing for DMA support. 2016-07-09 11:40:59 +00:00
Alexander Motin
f7be35856a Fix operation with multiple qps. 2016-07-09 11:36:09 +00:00
Alexander Motin
9a5325c205 NewBus'ify NTB subsystem.
This follows NTB subsystem modularization in Linux, tuning it to FreeBSD
native NewBus interfaces.  This change allows to support different types
of hardware with different drivers, support multiple NTB instances in a
system, ntb_transport module use for needs other then if_ntb, etc.

Sponsored by:	iXsystems, Inc.
2016-07-09 11:20:42 +00:00
Alexander Motin
12738808e7 Remove some dead code found by Clang static analyzer. 2016-07-09 09:47:11 +00:00
Alexander Motin
b56203ac03 Fix NTB_SDOORBELL_LOCKUP workaround.
Since SBARxSZ register can be write-once, it can be unusable for disabling
the SBAR.  For such case also set SBARxBASE to zero to not intersect with
config BAR.
2016-07-09 09:34:24 +00:00
Eric van Gyzen
ee61689fdf Fix if_ntb interface setup to include IFF_MULTICAST.
This allows IPv6 link local addresses (and other IPv6 functionality) to work.

PR:		210355
Submitted by:	Steve Wahl and David Bright (both at Dell Inc.)
Reviewed by:	cem, mav
Tested by:	mav (on Intel hardware)
Approved by:	re (kib)
MFC after:	5 days
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D6885
2016-06-18 23:18:04 +00:00
Alexander Motin
32727d3b6d When negotiating NTB_SB01BASE_LOCKUP workaround, don't try to limit the
BAR size to 1MB.  According to Xeon v3 specifications and my tests, that
size register is write-once and so not writeable after BIOS written it.

Instead of that, make the code work with BAR of any sufficient size,
properly calculating offset within its base.  It also simplifies the code.

Discussed with:	cem
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2016-06-04 00:18:59 +00:00
Alexander Motin
c096696f31 When negotiating MSIX parameters, give other head time to see our
NTB_MSIX_RECEIVED status, before making upper layers overwrite it.

This is not completely perfect, but now it works better then before.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2016-06-04 00:08:37 +00:00
Alexander Motin
b72a6f8a8f Re-enable write combining, disabled by default at r295486.
if_ntb(4) strongly benefits from WC, improving throughput from 350Mbit/s
to 8-10Gbit/s on my tests.

MFC after:	1 week
2016-05-24 12:40:03 +00:00
Conrad Meyer
ab7c85b4b9 ntb_hw(4): Only record the first three MSIX vectors
Don't overrun the msix_data array by reading the (unused) link state
interrupt information.

Reported by:	mav (earlier version)
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D6489
2016-05-23 19:46:58 +00:00
Conrad Meyer
2d3192783d ntb_hw(4): Add sysctls for administrative/test link config, state
dev.ntb_hw.0.admin_up=0/1: Like ifconfig UP/DOWN.
dev.ntb_hw.0.active=0/1:   Like ifconfig 'status'

Reviewed by:	ngie
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D6429
2016-05-18 02:10:05 +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
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
Conrad Meyer
f98d21e561 NTB: workaround for high traffic hardware hang
This patch comes from Dave Jiang's Linux tree, davejiang/ntb.  It hasn't
been accepted into Linus' tree, so I do not have an authoritative SHA1
to point at.  Original commit log:

=====================================================================
A hardware errata causes the NTB to hang when heavy bi-directional
traffic in addition to the usage of BAR0/1 (where the registers reside,
including the doorbell registers to trigger interrupts).

This workaround is only available on Haswell and Broadwell platform.
The workaround is to enable split BAR in the BIOS to allow the 64bit
BAR4 to be split into two 32bit BAR4 and BAR5. The BAR4 shall be pointed
to LAPIC region of the remote host. We will bypass the db mechanism and
directly trigger the MSIX interrupts. The offsets and vectors are
exchanged during transport scratch pad negotiation. The scratch pads are
now overloaded in order to allow the exchange of the information. This
gets around using the doorbell and prevents the lockup with additional
pcode changes in BIOS.

Signed-off-by:	Dave Jiang <dave.jiang@intel.com>
=====================================================================

Notable changes in the FreeBSD version of this patch:
* The MSIX BAR is configurable, like hw.ntb.b2b_mw_idx (msix_mw_idx).
  The Linux version of the patch only uses BAR4.
* MSIX negotiation aborts if the link goes down.

Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2016-02-14 22:37:28 +00:00
Conrad Meyer
6ea028df50 ntb_hw(4): Print correct PAT name for non-WC/WB types mapped at load
Sponsored by:	EMC / Isilon Storage Division
2016-02-10 20:49:22 +00:00
Conrad Meyer
b1d46e7cb0 ntb_hw(4): Allow any x86 PAT caching flags for MW defaults
Replace the hw.ntb.enable_writecombine tunable with
hw.ntb.default_mw_pat.  It can be set with several specific numerical
values to select a caching type.  Any bogus value is treated as
Uncacheable (UC).

The ntb_mw_set_wc() KPI has removed the restriction that the selected
mode must be one of UC, WC, or WB.

Sponsored by:	EMC / Isilon Storage Division
2016-02-10 20:28:28 +00:00
Conrad Meyer
b23896a221 if_ntb: Don't roundup MW size to full BAR size unnecessarily
Note that the MW allocation still must be BAR *aligned*.  So, this only
loosens the constraints on MW allocation slightly.  BAR-aligned does not
play well with large (GB+) BAR sizes.

Going forward, if anyone cares about if_ntb on very large BARs, I
suggest they add functionality to allocate a smaller window than the BAR
size, and set the BAR range to cover a window much larger than the
allocated window.  This will require negotiating a window offset and
limit for protocol traffic.  None of this is implemented in this
revision.

Sponsored by:	EMC / Isilon Storage Division
2015-12-03 17:22:55 +00:00
Conrad Meyer
64448a2a50 if_ntb: Log error *before* zeroing relevant variables
Sponsored by:	EMC / Isilon Storage Division
2015-12-03 17:22:45 +00:00
Conrad Meyer
c4492f4758 NTB: WC/WB isn't enough; set MMR region as UC
And expose vm_memattr_t of current mapping to consumers (as well as the
ability to change it to one of UC, WB, WC).

After short discussion with:	jhb (but no review)
Sponsored by:	EMC / Isilon Storage Division
2015-11-25 01:59:08 +00:00
Conrad Meyer
e7f64f2e33 ntb: Add MW tunable for MMR Xeon errata workaround
Adds a new tunable, ntb.hw.b2b_mw_idx, which specifies the offset (from the
total number of memory windows) to use for register access on hardware with
the SDOORBELL_LOCKUP errata.  The default is -1, i.e., the last memory
window.

We map BARs before the b2b_mw_idx is selected, so map them all as memory
windows initially.  The register memory window should not be write-combined,
so we explicitly disable WC on the selected MW later.

This introduces a layer of abstraction between consumer memory window
indices, which exclude any exclusive errata-workaround BARs, and internal
memory window indices, which include such BARs.  An internal routine,
ntb_user_mw_to_idx(), converts the former to the latter.  Public APIs have
been updated to use this instead of assuming the exclusive workaround BAR is
the last available MW.

Sponsored by:	EMC / Isilon Storage Division
2015-11-24 18:51:17 +00:00
Conrad Meyer
70bca634d0 if_ntb: Initialize if_mtu to the correct MTU
Lower the payload data (IP) portion of the MTU from 0x10000 to
IP_MAXPACKET (0xFFFF) to avoid panicing the IP stack.

Sponsored by:	EMC / Isilon Storage Division
2015-11-19 19:53:19 +00:00
Conrad Meyer
f51a1fe048 if_ntb: Add Xeon link watchdog register writes
This feature is disabled by default.  To enable it, tune
hw.if_ntb.enable_xeon_watchdog to non-zero.

If enabled, writes an unused NTB register every second to demonstrate to
a hardware watchdog that the NTB device is still alive.  Most machines
with NTB will not need this -- you know who you are.

Sponsored by:	EMC / Isilon Storage Division
2015-11-19 19:53:09 +00:00
Conrad Meyer
e90df06388 if_ntb: Reuse receive buffers correctly
Discard the unused rx_free_q.  Instead, reuse inputed packets by putting
them back on the *pend* queue after reinitialization.

If tx or rx handlers are unavailable, free mbufs rather than leaking
them.

With this change, if_ntb can receive more than 100
(NTB_QP_DEF_NUM_ENTRIES) packets.

Sponsored by:	EMC / Isilon Storage Division
2015-11-18 22:20:49 +00:00
Conrad Meyer
c95b032ec6 NTB: Expose 32-bit BAR limits to consumers
32-bit BARs can only address memory mapped in the low 32 bits of
physical RAM.  Expose this as a 'plimit' out parameter from
ntb_mw_get_range().

Fix if_ntb to allocate memory within this limit.

Sponsored by:	EMC / Isilon Storage Division
2015-11-18 22:20:40 +00:00
Conrad Meyer
4e1eea459a NTB: Mask off the low 12 bits of address/range registers
Sometimes they'll read spurious values (observed: 0xc on Broadwell-DE),
failing link negotiation.

Discussed with:	Dave Jiang, Allen Hubbe
Sponsored by:	EMC / Isilon Storage Division
2015-11-18 22:20:31 +00:00
Conrad Meyer
57ba792a67 ntb_hw: Add programmatic interface to enable/disable WC
Enable users to enable/disable WC on memory windows programmatically.

Sponsored by:	EMC / Isilon Storage Division
2015-11-18 22:20:21 +00:00
Conrad Meyer
3062870897 ntb_hw: Add tunable to disable write-combining
The tunable 'hw.ntb.enable_writecombine' may be set to zero to
administratively disable write combining the mapped NTB region.

Sponsored by:	EMC / Isilon Storage Division
2015-11-18 22:20:13 +00:00
Conrad Meyer
552573e11c NTB: Fix 32-bit BAR size validation
Sponsored by:	EMC / Isilon Storage Division
2015-11-18 22:20:04 +00:00
Conrad Meyer
30994d9192 if_ntb: Diff reduce with Linux
Use bus_space_write instead of (non-volatile) C pointer writes via an
iowrite32() shim in the same places as the Dual BSD/GPL Linux driver.

Update some types to fixed 32-bit sizes.

Sponsored by:	EMC / Isilon Storage Division
2015-11-18 22:19:55 +00:00
Conrad Meyer
efd5acf04b if_ntb: Clear the right QP in the free bitmap
Now it can ping back and forth.

Sponsored by:	EMC / Isilon Storage Division
2015-11-14 01:23:13 +00:00
Conrad Meyer
dc8579df1c NTB: MFV 8b782fab: unify translation addresses
There is no need for the upstream and downstream addresses to be
different for the NTB configs.  Go to using a single set of address. It
is still possible to configure them differently using module parameter
override however (CEM: tunable).

Authored by:	Dave Jiang <dave.jiang@intel.com>
Reviewed by:	Allen Hubbe <Allen.Hubbe@emc.com>
Reviewed by:	Jon Mason <jdmason@kudzu.us>
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-11-12 19:07:03 +00:00
Conrad Meyer
28a0666622 if_ntb: MFV c92ba3c5: invalid buf pointer in multi-MW setups
Order of operations issue with the QP Num and MW count, which would
result in the receive buffer pointer being invalid if there are more
than 1 MW.  Corrected with parenthesis to enforce the proper order of
operations.

Reported by:	John I. Kading <John.Kading@gd-ms.com>
Reported by:	Conrad Meyer <cem@FreeBSD.org>
Authored by:	Jon Mason <jdmason@kudzu.us>
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:56:21 +00:00
Conrad Meyer
13e751cf1a NTB: Add more HW registers to device sysctl tree
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:56:11 +00:00
Conrad Meyer
fe92caaf23 ntb: volatile some members set by interrupt routines
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:56:02 +00:00
Conrad Meyer
bce32f9268 ntb_hw: Similarly, add a debug-leveled macro for ntb_hw
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:55:53 +00:00
Conrad Meyer
98bdb1ce51 if_ntb: Add module-specific log level
Rather than relying on the quite accurately named 'bootverbose'.

Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:55:44 +00:00
Conrad Meyer
b22ecf1ff8 if_ntb: Transport link cleanup needs to be on a taskqueue
Because it can sleep drainking link work callout(s).  Linux (dual
BSD/GPL driver) does something very similar.

At the same time, switch the NTB CTX lock to a non-spin mutex, because
the taskqueue_swi lock can't be taken after a spin mutex.

Suggested by:	Witness
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:55:34 +00:00
Conrad Meyer
9cf310367f NTB: Diff reduce with Linux
No functional change.

Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:55:25 +00:00
Conrad Meyer
e4a818a922 ntb_hw: Correctly detect DSD/USD
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:55:16 +00:00
Conrad Meyer
2219047bc1 ntb_hw: In INTx fallback, correct db shift from 15 to 16
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:55:07 +00:00
Conrad Meyer
6fde27ecee ntb: Use caddr_t to simplify pointer arithmetic
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:54:58 +00:00
Conrad Meyer
1a60b0c88e NTB: Skip db_valid validation writing DB link bit
In ntb_poll_link, we are intentionally writing the link bit, which is
absent from db_valid_mask.  Don't panic on a kassert when we do so.

The Linux version of this (dual BSD/GPL) driver has the db_valid_mask
assertions in callers of db_iowrite() rather than db_iowrite() itself;
it skips the assertions in the equivalent of ntb_poll_link().  Rather
than duplicating the assertions in every caller, add a db_iowrite_raw()
that doesn't check and use it from ntb_poll_link().

Suggested by:	kassert_panic
Sponsored by:	EMC / Isilon Storage Division
2015-11-11 18:54:49 +00:00
Conrad Meyer
217b098a1e ntb: Revert r290130 now that r290156 has landed
Nagged by:	vangyzen
Sponsored by:	EMC / Isilon Storage Division
2015-10-29 19:35:01 +00:00
Conrad Meyer
79c1a0199f ntb: Do not attempt to set write-combining on MWs
AMD64 pmap assumes ranges will be in the DMAP, which isn't necessarily
true for NTB memory windows (especially 64-bit BARs).

Suggested by:	pmap_change_attr_locked -> kassert_panic
Sponsored by:	EMC / Isilon Storage Division
2015-10-29 04:16:28 +00:00
Conrad Meyer
f09b75d4b5 if_ntb: Use ffsll() now that it is broadly available
Sponsored by:	EMC / Isilon Storage Division
2015-10-22 23:03:24 +00:00
Conrad Meyer
0a7663c2c0 NTB: Add device introspection sysctl hierarchy
This should export all of the same information as the Linux ntb_hw_intel
debugfs info file, but with a bit more structure, in the sysctl tree
rooted at 'dev.ntb_hw.<N>.debug_info'.

Raw registers are marked as OPAQUE because reading them on some hardware
revisions may cause a hard lockup (NTB errata).  They can be read with
'sysctl -x dev.ntb_hw.<N>.debug_info.registers'.  On Xeon platforms,
some additional registers are available under 'registers.xeon_stats' and
'registers.xeon_hw_err'.  They are exported as big-endian values so that
the 'sysctl -x' output is legible.

Shrink the feature mask to 32 bits so we can use the %b formatter in
'debug_info.features'.

Sponsored by:	EMC / Isilon Storage Division
2015-10-22 23:03:15 +00:00
Conrad Meyer
a69ff5b1ee NTB: Revert r289645
Per Benno, this is a Linuxism we do not need in FreeBSD.

Suggested by:	benno
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:32:16 +00:00
Conrad Meyer
d9503a7fcd if_ntb: Diff-reduce with Linux; add queue index type
Add ntb_q_idx_t so it is more clear which struct members are of the same
type (some bogus uint64_ts snuck in that should have been unsigned int).

Add tx_err_no_buf and s/ENOMEM/EBUSY/ in tx_enqueue to match Linux.

Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:21:01 +00:00
Conrad Meyer
2d6501b281 NTB: MFV 8c9edf63: Fix zero size or integer overflow in ntb_set_mw
A plain 32 bit integer will overflow for values over 4GiB.

Change the plain integer size to the appropriate size type in
ntb_set_mw.  Change the type of the size parameter and two local
variables used for size.

Even if there is no overflow, a size of zero is invalid here.

Authored by:	Allen Hubbe
Reported by:	Juyoung Jung
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:20:52 +00:00
Conrad Meyer
4994fe1295 NTB: MFV da2e5ae5: Fix ntb_transport out-of-order RX update
It was possible for a synchronous update of the RX index in the error
case to get ahead of the asynchronous RX index update in the normal
case.  Change the RX processing to preserve an RX completion order.

There were two error cases.  First, if a buffer is not present to
receive data, there would be no queue entry to preserve the RX
completion order.  Instead of dropping the RX frame, leave the RX frame
in the ring.  Schedule RX processing when RX entries are enqueued, in
case there are RX frames waiting in the ring to be received.

Second, if a buffer is too small to receive data, drop the frame in the
ring, mark the RX entry as done, and indicate the error in the RX entry
length.  Check for a negative length in the receive callback in
ntb_netdev, and count occurrences as rx_length_errors.

Authored by:	Allen Hubbe
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:20:42 +00:00
Conrad Meyer
8a26cf17c6 if_ntb: Correct over-long lines, use qmin()
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:20:33 +00:00
Conrad Meyer
bbea13c586 if_ntb: Use if_printf instead of device_printf
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:20:24 +00:00
Conrad Meyer
eccd1f0a14 NTB: MFV 2f887b9a: Rename Intel code names to platform names
Mechanically replace "SOC" with "ATOM" to match Linux.  No functional
change.  Original Linux commit log follows:

Instead of using the platform code names, use the correct platform names
to identify the respective Intel NTB hardware.

Authored by:	Dave Jiang
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:20:15 +00:00
Conrad Meyer
3a8a0a9dfa NTB: Don't abort if setting a MW write-combine fails
Also log BAR mapping results more verbosely.

Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:20:06 +00:00
Conrad Meyer
217453caed NTB: Fix typo in bar5 tunables
Typo introduced in r289614.

Pointy-hat:	cem
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:19:57 +00:00
Conrad Meyer
43a191ed78 NTB: MFV 7eb38781: Print driver name in module init
Prints driver name to indicate what is being loaded.

Authored by:	Dave Jiang
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 19:19:48 +00:00
Conrad Meyer
5165422dff NTB: Clean up safely if attach fails early
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 01:54:52 +00:00
Conrad Meyer
98580c064c NTB: MFV 9891417d: Increase transport MTU to 64k from 16k
Benchmarking showed a significant performance increase with the MTU size
to 64k instead of 16k.  Change the driver default to 64k.

Authored by:	Dave Jiang
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 01:54:43 +00:00
Conrad Meyer
6a88fb3ef8 if_ntb: Fix typo in qp_link_work to match Linux
Throw away the result of the peer SPAD read.  The peer will write our
local SPAD and we need to keep the locally read SPAD value to check if
the remote side is up.

Sponsored by:	EMC / Isilon Storage Division
2015-10-20 01:54:34 +00:00
Conrad Meyer
d5bd08b091 NTB: MFV 42fefc86: Add parameters for Intel SNB B2B addresses
Add module parameters for the addresses to be used in B2B topology.

Authored by:	Allen Hubbe
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 01:54:25 +00:00
Conrad Meyer
25ff5df7c4 if_ntb: MFV 2849b5d7: Reset transport QP link stats on down
Reset the link stats when the link goes down.  In particular, the TX and
RX index and count must be reset, or else the TX side will be sending
packets to the RX side where the RX side is not expecting them.  Reset
all the stats, to be consistent.

Authored by:	Allen Hubbe
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 01:54:16 +00:00
Conrad Meyer
0326e4d6b5 NTB: Change Atom (BWD/SoC) pci_id name to match others
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 01:54:08 +00:00
Conrad Meyer
fb6531b056 NTB: MFV 5ae0beb6: Enable link for Intel root port mode in probe
We skip actually bringing up Rootport/Transparent configurations, so
most of this doesn't apply.  Original Linux commit log:

Link training should be enabled in the driver probe for root port mode.
We should not have to wait for transport to be loaded for this to
happen.  Otherwise the ntb device will not show up on the transparent
bridge side of the link.

Authored by:	Dave Jiang
Obtained from:	Linux (Dual BSD/GPL driver)
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 01:46:14 +00:00
Conrad Meyer
6849146f9d NTB: enum-ify some HW constants
Sponsored by:	EMC / Isilon Storage Division
2015-10-20 01:46:05 +00:00