Commit Graph

32372 Commits

Author SHA1 Message Date
Sepherosa Ziehau
c8fca9324a hyperv/hn: Pull vmbus channel open up.
While I'm here, pull up the channel callback related code too.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7805
2016-09-08 05:27:43 +00:00
John Baldwin
6af45170c1 Chelsio T4/T5 VF driver.
The cxgbev/cxlv driver supports Virtual Function devices for Chelsio
T4 and T4 adapters.  The VF devices share most of their code with the
existing PF4 driver (cxgbe/cxl) and as such the VF device driver
currently depends on the PF4 driver.

Similar to the cxgbe/cxl drivers, the VF driver includes a t4vf/t5vf
PCI device driver that attaches to the VF device.  It then creates
child cxgbev/cxlv devices representing ports assigned to the VF.
By default, the PF driver assigns a single port to each VF.

t4vf_hw.c contains VF-specific routines from the shared code used to
fetch VF-specific parameters from the firmware.

t4_vf.c contains the VF-specific PCI device driver and includes its
own attach routine.

VF devices are required to use a different firmware request when
transmitting packets (which in turn requires a different CPL message
to encapsulate messages).  This alternate firmware request does not
permit chaining multiple packets in a single message, so each packet
results in a firmware request.  In addition, the different CPL message
requires more detailed information when enabling hardware checksums,
so parse_pkt() on VF devices must examine L2 and L3 headers for all
packets (not just TSO packets) for VF devices.  Finally, L2 checksums
on non-UDP/non-TCP packets do not work reliably (the firmware trashes
the IPv4 fragment field), so IPv4 checksums for such packets are
calculated in software.

Most of the other changes in the non-VF-specific code are to expose
various variables and functions private to the PF driver so that they
can be used by the VF driver.

Note that a limited subset of cxgbetool functions are supported on VF
devices including register dumps, scheduler classes, and clearing of
statistics.  In addition, TOE is not supported on VF devices, only for
the PF interfaces.

Reviewed by:	np
MFC after:	2 months
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7599
2016-09-07 18:13:57 +00:00
John Baldwin
e06ab612d2 Don't break out of the m_advance() loop if len drops to zero.
If a packet contains the Ethernet header (14 bytes) in the first mbuf
and the payload (IP + UDP + data) in the second mbuf, then the attempt
to fetch the l3hdr will return a NULL pointer.  The first loop iteration
will drop len to zero and exit the loop without setting 'p'.  However,
the desired data is at the start of the second mbuf, so the correct
behavior is to loop around and let the conditional set 'p' to m_data of
the next mbuf (and leave offset as 0).

Reviewed by:	np
Sponsored by:	Chelsio Communications
2016-09-07 18:08:43 +00:00
Andriy Voskoboinyk
d204cea9f8 rum: fix possible panic on device detach (similar to r302034).
Tested with WUSB54GC, STA/AP modes.
2016-09-07 16:19:20 +00:00
Alexander Motin
07c3504304 Fix channel initialization in FBS mode.
Due to reading initialized variable, FIS receive area was always allocated
as 256 bytes, suitable for command-based switching, instead of 4096 bytes,
required for FIS-based switching.  This caused memory corruption in case of
port multipliers used on FBS-capable HBAs (Marvell).

MFC after:	1 week
2016-09-07 13:51:34 +00:00
Andriy Gapon
9626ccde7f amdsbwd: add support for FCH in family 16h models 30h-3Fh processors
Requested by:	Mike Tancsa <mike@sentex.net>
Tested by:	Mike Tancsa <mike@sentex.net>
MFC after:	1 week
2016-09-07 13:45:35 +00:00
Andriy Voskoboinyk
4c90f11b3c rum: use mgmt frame rate for EAPOL frames. 2016-09-07 12:07:02 +00:00
Sepherosa Ziehau
b67f3d2873 hyperv/hn: Nuke unused bits
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7795
2016-09-07 09:20:58 +00:00
Sepherosa Ziehau
b44fb279e8 hyperv/hn: Simplify per-packet-info construction.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7794
2016-09-07 06:02:29 +00:00
Sepherosa Ziehau
61ac564fd0 hyperv/hn: Cleanup RNDIS packet message encapsulation.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7793
2016-09-07 05:41:01 +00:00
Sepherosa Ziehau
5761f5dfdd hyperv/hn: Avoid bit fields for TXCSUM setup.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7792
2016-09-07 05:27:43 +00:00
John Baldwin
da0fc9250c Reset PCI pass through devices via PCI-e FLR during VM start and end.
Add routines to trigger a function level reset (FLR) of a PCI-express
device via the PCI-express device control register.  This also includes
support routines to wait for pending transactions to complete as well
as calculating the maximum completion timeout permitted by a device.

Change the ppt(4) driver to reset pass through devices before attaching
to a VM during startup and before detaching from a VM during shutdown.

Reviewed by:	imp, wblock (earlier version)
MFC after:	1 month
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7751
2016-09-06 21:15:35 +00:00
Jared McNeill
319336a943 Add generic device-tree cpufreq driver.
This driver supports two bindings:
 - cpufreq-dt: systems which share clock and voltage across all CPUs
 - arm_big_little_dt: systems which share clock and voltage across all
   CPUs in a single cluster

Reviewed by:		andrew, imp
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D7741
2016-09-06 20:43:26 +00:00
John Baldwin
64414cc00f Update the I/O MMU in bhyve when PCI devices are added and removed.
When the I/O MMU is active in bhyve, all PCI devices need valid entries
in the DMAR context tables. The I/O MMU code does a single enumeration
of the available PCI devices during initialization to add all existing
devices to a domain representing the host. The ppt(4) driver then moves
pass through devices in and out of domains for virtual machines as needed.
However, when new PCI devices were added at runtime either via SR-IOV or
HotPlug, the I/O MMU tables were not updated.

This change adds a new set of EVENTHANDLERS that are invoked when PCI
devices are added and deleted. The I/O MMU driver in bhyve installs
handlers for these events which it uses to add and remove devices to
the "host" domain.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7667
2016-09-06 20:17:54 +00:00
Wojciech Macek
aab9fdaf6f Import missing enum declaration in pci_host_generic header file
Other files including pci_host_generic.h failed to compile
due to missing declaration of enum pci_id_type.

Obtained from:         Semihalf
Submitted by:          Michal Stanek <mst@semihalf.com>
Sponsored by:          Annapurna Labs
Reviewed by:           wma
Differential Revision: https://reviews.freebsd.org/D7561
2016-09-06 15:11:37 +00:00
Wojciech Macek
d8f1c69cc2 Remove check for 64-bit FDT ranges in pci-host-generic
This allows 32-bit platforms to use pci-host-generic.

Obtained from:         Semihalf
Submitted by:          Michal Stanek <mst@semihalf.com>
Sponsored by:          Annapurna Labs
Reviewed by:           wma
Differential Revision: https://reviews.freebsd.org/D7560
2016-09-06 15:06:08 +00:00
Ed Maste
68c6ae00ad bhnd: remove redundant ;s at the end of functions or switch statements 2016-09-06 13:34:10 +00:00
Andriy Voskoboinyk
93ae47478c rum: use m_get2() in Rx path. 2016-09-06 12:00:16 +00:00
Andriy Voskoboinyk
b7c8904780 rtwn: fix firmware readiness check in rtwn_load_firmware(). 2016-09-06 11:08:32 +00:00
Andriy Voskoboinyk
9afea60f98 iwm: fix scanning for hidden SSIDs.
Setup SSIDs in scan command so firmware will send direct probe request(s)
while scanning.

Tested by:	dbkirk@gmail.com

PR:		211519
MFC after:	1 week
2016-09-06 10:08:32 +00:00
Andriy Voskoboinyk
c84bb70268 rum: fix frame length checks in Rx path.
Split usbd_xfer_status() check:
- Check xfer length: must be longer, than Rx descriptor size.
- Check frame size: must be shorter than xfer length.
- Discard too short frames.

Tested with WUSB54GC, STA/MONITOR modes.
2016-09-06 06:40:59 +00:00
Sepherosa Ziehau
50002d3dfa hyperv/hn: Avoid bit fields for LSOv2 setup.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7786
2016-09-06 04:37:53 +00:00
Sepherosa Ziehau
14ee29ba93 hyperv/hn: Fix VLAN tag setup for outgoing VLAN packets.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7785
2016-09-06 03:31:31 +00:00
Sepherosa Ziehau
b349357819 hyperv/hn: Stringent RNDIS packet message length/offset check.
While I'm here, use definition in net/rndis.h

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7782
2016-09-06 03:20:06 +00:00
Navdeep Parhar
48214203c4 Fix send/recv limit mixup. 2016-09-05 23:12:24 +00:00
Landon J. Fuller
824b48eff3 bhnd(4): Implement backplane interrupt handling.
This adds bhnd(4) bus-level support for querying backplane interrupt vector
routing, and delegating machine/bridge-specific interrupt handling to the
concrete bhnd(4) driver implementation.

On bhndb(4) bridged PCI devices, we provide the PCI/MSI interrupt directly
to attached cores.

On MIPS devices, we report a backplane interrupt count of 0, effectively
disabling the bus-level interrupt assignment. This allows mips/broadcom
to temporarily continue using hard-coded MIPS IRQs until bhnd_mips PIC
support is implemented.

Reviewed by:	mizhka
Approved by:	adrian (mentor, implicit)
2016-09-05 22:11:46 +00:00
Landon J. Fuller
7d6162806b bwn(4): ignore BCM4321's unpopulated USB11 host controller core.
Broadcom Intensi-fi chipsets provided a common set of IP cores; on PCI/PCIe
devices, the USB11 host controller is left floating.

Approved by:	adrian (mentor, implicit)
2016-09-05 21:55:27 +00:00
Landon J. Fuller
fb88110c09 bhnd(4): Add device classes for USB host/dev/dual-mode controller cores.
Approved by:	adrian (mentor, implicit)
2016-09-05 21:48:16 +00:00
Andriy Voskoboinyk
c57ee45ba9 rum: do not restart device when protmode / rtsthreshold is changed. 2016-09-05 19:42:35 +00:00
Navdeep Parhar
5aaa3bc3b9 cxgbe/t4_tom: toepcb should be all-zero on allocation because the code
that cleans up on failure assumes that non-NULL values indicate
initialized items.

Sponsored by:	Chelsio Communications
2016-09-05 19:37:47 +00:00
Michael Zhilin
29d492ace1 [BHND/USB] Port of EHCI/OHCI support from ZRouter
This patch adds driver implementation for BHND USB core. Driver has been
imported from ZRouter project with small adaptions for FreeBSD 11.

Also it's enabled for BroadCom MIPS74k boards by default. It's fully tested
on Asus boards (RT-N16: external USB, RT-N53: USB bus between SoC and WiFi
chips).

Reviewed by:    adrian (mentor), ray
Approved by:	adrian (mentor)
Obtained from:	ZRouter
Differential Revision:  https://reviews.freebsd.org/D7781
2016-09-05 16:06:52 +00:00
Hans Petter Selasky
64cb5e2a26 Resolve deadlock between device_detach() and usbd_do_request_flags()
by reviving the SX control request lock and refining which lock
protects the common scratch area in "struct usb_device".

The SX control request lock was removed by r246759 because it caused a
lock order reversal with the USB enumeration lock inside
usbd_transfer_setup() as a function of r246616. It was thought that
reducing the number of locks would resolve the LOR, but because some
USB device drivers use usbd_do_request_flags() inside callback
functions, like in taskqueues, a deadlock may occur when these are
drained from device_detach(). By restoring the SX control request
lock usbd_do_request_flags() is allowed to complete its execution
when a USB device driver is detaching. By using the SX control request
lock to protect the scratch area, the LOR introduced by r246616 is
also resolved.

Bump the FreeBSD version while at it to force recompilation of all USB
kernel modules.

Found by:	avos@
MFC after:	1 week
2016-09-05 15:35:58 +00:00
Jared McNeill
8dd48c60a0 Add driver for Silergy Corp. SY8106A buck regulator. 2016-09-05 13:39:54 +00:00
Sepherosa Ziehau
0bbb7d483b hyperv/hn: Stringent RNDIS control message length check.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7758
2016-09-05 05:07:40 +00:00
Sepherosa Ziehau
7a466137f0 hyperv/hn: Stringent NVS RNDIS packets length checks.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7755
2016-09-05 04:47:31 +00:00
Sepherosa Ziehau
dc65be7a3d hyperv/hn: Stringent NVS notification length check.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7753
2016-09-05 03:39:04 +00:00
Sepherosa Ziehau
19c8ea1086 hyperv/vmbus: Stringent header length and total length check.
While I'm here, minor style changes.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7752
2016-09-05 03:21:31 +00:00
Dimitry Andric
02d4a225db With clang 3.9.0, compiling uplcom results in the following warnings:
sys/dev/usb/serial/uplcom.c:543:29: error: implicit conversion from 'int' to 'int8_t' (aka 'signed char') changes value from 192 to -64 [-Werror,-Wconstant-conversion]
        if (uplcom_pl2303_do(udev, UT_READ_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x8484, 0, 1)
            ~~~~~~~~~~~~~~~~       ^~~~~~~~~~~~~~~~~~~~~
sys/dev/usb/usb.h:179:53: note: expanded from macro 'UT_READ_VENDOR_DEVICE'
#define UT_READ_VENDOR_DEVICE   (UT_READ  | UT_VENDOR | UT_DEVICE)
                                 ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~

This is because UT_READ is 0x80, so the int8_t argument is wrapped to a
negative value.  Fix this by using uint8_t instead.

Reviewed by:	imp, hselasky
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D7776
2016-09-04 16:59:35 +00:00
Landon J. Fuller
eb83f2e1ea bhndb(4): Fix probing of bhndb-attached bhnd_nvram devices.
This fixes bhnd(4) nvram handling on devices that map SPROM CSRs via PCI
configuration space.

The probe method previously required that a bhnd(4) device be attached to the
parent bridge; now that the bhnd_nvram device is always attached first, this
unnecessary sanity check always failed.

Approved by:	adrian (mentor, implicit)
2016-09-04 01:47:21 +00:00
Landon J. Fuller
63fb0e8236 bhndb(4): Skip disabled cores when performing bridge configuration probing.
On BCM4321 chipsets, both PCI and PCIe cores are included, with one of
the cores potentially left floating.

Since the PCI core appears first in the device table, and the PCI
profiles appear first in the resource configuration tables, this resulted in
incorrectly matching and using the PCI/v1 resource configuration on PCIe
devices, rather than the correct PCIe/v1 profile.

Approved by:	adrian (mentor, implicit)
2016-09-04 01:43:54 +00:00
Landon J. Fuller
f32befd1a2 siba(4): Add missing bhnd_device/bhnd_device_quirk table terminator entries.
This resulted in an over-read on siba chipsets that failed to match the
existing entries.

Approved by:	adrian (mentor, implicit)
2016-09-04 01:25:46 +00:00
Landon J. Fuller
111d7cb2e3 Migrate bhndb(4) to the new bhnd_erom API.
Adds support for probing and initializing bhndb(4) bridge state using
the bhnd_erom API, ensuring that full bridge configuration is available
*prior* to actually attaching and enumerating the bhnd(4) child device,
allowing us to safely allocate bus-level agent/device resources during
bhnd(4) bus enumeration.

- Add a bhnd_erom_probe() method usable by bhndb(4). This is an analogue
  to the existing bhnd_erom_probe_static() method, and allows the bhndb
  bridge to discover the best available erom parser class prior to newbus
  probing of its children.
- Add support for supplying identification hints when probing erom
  devices. This is required on early EXTIF-only chipsets, where chip
  identification registers are not available.
- Migrate bhndb over to the new bhnd_erom API, using bhnd_core_info
  records rather than bridged bhnd(4) device_t references to determine
  the bridged chipsets' capability/bridge configuration.
- The bhndb parent (e.g. if_bwn) is now required to supply a hardware
  priority table to the bridge. The default table is currently sufficient
  for our supported devices.
- Drop the two-pass attach approach we used for compatibility with bhndb(4) in
  the bhnd(4) bus drivers, and instead perform bus enumeration immediately,
  and allocate bridged per-child bus-level resources during that enumeration.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7768
2016-09-04 00:58:19 +00:00
Landon J. Fuller
664a749708 Implement a generic bhnd(4) device enumeration table API.
This defines a new bhnd_erom_if API, providing a common interface to device
enumeration on siba(4) and bcma(4) devices, for use both in the bhndb bridge
and SoC early boot contexts, and migrates mips/broadcom over to the new API.

This also replaces the previous adhoc device enumeration support implemented
for mips/broadcom.

Migration of bhndb to the new API will be implemented in a follow-up commit.


- Defined new bhnd_erom_if interface for bhnd(4) device enumeration, along
  with bcma(4) and siba(4)-specific implementations.
- Fixed a minor bug in bhndb that logged an error when we attempted to map the
  full siba(4) bus space (18000000-17FFFFFF) in the siba EROM parser.
- Reverted use of the resource's start address as the ChipCommon enum_addr in
  bhnd_read_chipid(). When called from bhndb, this address is found within the
  host address space, resulting in an invalid bridged enum_addr.
- Added support for falling back on standard bus_activate_resource() in
  bhnd_bus_generic_activate_resource(), enabling allocation of the bhnd_erom's
  bhnd_resource directly from a nexus-attached bhnd(4) device.
- Removed BHND_BUS_GET_CORE_TABLE(); it has been replaced by the erom API.
- Added support for statically initializing bhnd_erom instances, for use prior
  to malloc availability. The statically allocated buffer size is verified both
  at runtime, and via a compile-time assertion (see BHND_EROM_STATIC_BYTES).
- bhnd_erom classes are registered within a module via a linker set, allowing
  mips/broadcom to probe available EROM parser instances without creating a
  strong reference to bcma/siba-specific symbols.
- Migrated mips/broadcom to bhnd_erom_if, replacing the previous MIPS-specific
  device enumeration implementation.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7748
2016-09-03 23:57:17 +00:00
Dimitry Andric
2db7b9f259 With clang 3.9.0, compiling cxgb results in the following warning:
sys/dev/cxgb/cxgb_sge.c:2873:44: error: implicit conversion from 'int'
to 'char' changes value from 128 to -128 [-Werror,-Wconstant-conversion]
                        *mtod(m, char *) = CPL_ASYNC_NOTIF;
                                         ~ ^~~~~~~~~~~~~~~

This is because CPL_ASYNC_NOTIF is 0x80, so the plain char argument is
wrapped to a negative value.  Fix this by using uint8_t instead.

Reviewed by:	np
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D7772
2016-09-03 19:01:11 +00:00
Navdeep Parhar
5a63431265 Use correct CTR<n> variant. 2016-09-03 18:54:26 +00:00
Dimitry Andric
3128fa9a5a With clang 3.9.0, compiling ppbus(4) results in the following warnings:
sys/dev/ppbus/ppb_1284.c:296:46: error: implicit conversion from 'int'
to 'char' changes value from 144 to -112 [-Werror,-Wconstant-conversion]
        if ((error = do_peripheral_wait(bus, SELECT | nBUSY, 0))) {
                     ~~~~~~~~~~~~~~~~~~      ~~~~~~~^~~~~~~
sys/dev/ppbus/ppb_1284.c:785:48: error: implicit conversion from 'int'
to 'char' changes value from 240 to -16 [-Werror,-Wconstant-conversion]
                if (do_1284_wait(bus, nACK | SELECT | PERROR | nBUSY,
                    ~~~~~~~~~~~~      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
sys/dev/ppbus/ppb_1284.c:786:29: error: implicit conversion from 'int'
to 'char' changes value from 240 to -16 [-Werror,-Wconstant-conversion]
                                        nACK | SELECT | PERROR | nBUSY)) {
                                        ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~

This is because nBUSY is 0x80, so the plain char argument is wrapped to
a negative value.  Fix this in a minimal fashion, by using uint8_t in a
few places.

Reviewed by:	emaste
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D7771
2016-09-03 13:48:44 +00:00
Dimitry Andric
402e32a8af Define drmP.h's __OS_HAS_AGP and __OS_HAS_MTRR macros in a defined and
portable way.

Reviewed by:	dumbbell
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D7770
2016-09-03 13:33:28 +00:00
Sepherosa Ziehau
225c6e916e hyperv/ic: Cleanup timesync channel callback.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7745
2016-09-02 06:23:28 +00:00
Sepherosa Ziehau
1feb13270d hyperv/ic: Cleanup shutdown channel callback.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7744
2016-09-02 06:15:30 +00:00
Sepherosa Ziehau
9c040f41df hyperv/ic: Minor style fix.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7743
2016-09-02 06:08:08 +00:00
Sepherosa Ziehau
2a469fff98 hyperv/hn: Use the per-packet-info types defined by net/rndis.h
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7737
2016-09-02 05:30:38 +00:00
Sepherosa Ziehau
4e835450fd hyperv/hn: Simplify RX hash related bits.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7736
2016-09-02 03:19:55 +00:00
Sepherosa Ziehau
a191051577 hyperv/hn: Rework RXCSUM related bits
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7735
2016-09-02 03:10:30 +00:00
Navdeep Parhar
af4251f3a1 cxgbe/cxgbei: Provide a knob to set the DDP threshold for iSCSI
transfers.

The Initiator and Target both perform zero copy receive for transfers
greater than or equal to this threshold.

Sponsored by:	Chelsio Communications
2016-09-02 00:21:24 +00:00
Navdeep Parhar
22536e1556 cxgbe/cxgbei: Count various events related to iSCSI operation and make
these counters available in the sysctl MIB.

Sponsored by:	Chelsio Communications
2016-09-01 23:58:36 +00:00
Conrad Meyer
985efa77cc ioat(4): Despam relatively common hardware reset messages
Reported by:	ngie@
2016-09-01 23:56:02 +00:00
Navdeep Parhar
fec7f83342 cxgbe/cxgbei: Minor changes in the iSCSI CPL handlers.
- Use m_copydata instead of bcopy.
- Add new assertions.
- Log some more information.

Sponsored by:	Chelsio Communications
2016-09-01 22:40:55 +00:00
Navdeep Parhar
7cba15b16e cxgbe/cxgbei: Retire all DDP related code from cxgbei and switch to
routines available in t4_tom to manage the iSCSI DDP page pod region.

This adds the ability to use multiple DDP page sizes to the iSCSI
driver, among other improvements.

Sponsored by:	Chelsio Communications
2016-09-01 20:43:01 +00:00
Bruce Evans
90adad104b The log message for the previous commit didn't mention the most the
important detail that sc_cngetc() now opens and closes the keyboard
on every call again.  This was moved from sc_cngetc() to scn_cngrab/
ungrab() in r228644, but the change wasn't quite complete.  After
fixes for nesting in kbdd_poll() in ukbd and kbdmux, these opens
and closes should have no significant effect if done while grabbed.
They fix unusual cases when cngetc() is called while not grabbed.

This commit is the main fix for screen locking in sc_cnputc():
detect deadlock or likely-deadlock and handle it by buffering the
output atomically and printing it later if the deadlock condition
clears (and sc_cnputc() is called).

The most common deadlock is when the screen lock is held by ourself.
Then it would be safe to acquire the lock recursively if the console
driver is calling printf() in a safe context, but we don't know when
that is.  It is not safe to ignore the lock even in kdb or panic mode.
But ignore it in panic mode.  The only other known case of deadlock
is when another thread holds the lock but is running on a stopped CPU.
Detect that case approximately by using trylock and retrying for 1000
usec.  On a 4 GHz CPU, 100 usec is almost long enough -- screen switches
take slightly longer than that.  Not retrying at all is good enough
except for stress tests, and planned future versions will extend the
timeout so that the stress tests work better.

To see the behaviour when deadlock is detected, single step through
sctty_outwakeup() (or sc_puts() to start with deadlock).  Another
(serial) console is needed to the buffered-only output, but the
keyboard works in this context to continue or step out of the
deadlocked region.  The buffer is not large enough to hold all the
output for this.
2016-09-01 19:18:26 +00:00
Michael Zhilin
d5f271dde9 [BHND/PMU] Correct shift of bits in BHND_PMU_SET_BITS macro
The purpose of BHND_PMU_{GET,SET}_BITS macro is to transform values from/into
register format. SET macro shifts value to left and applies filter mask.
GET macro applies filter mask and then shifts value to right.

Reviewed by:    landonf, adrian (mentor)
Approved by:    adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D7721
2016-09-01 13:38:46 +00:00
Sepherosa Ziehau
b34d3ad6cc hyperv/hn: Fix VLAN tag construction.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7716
2016-09-01 07:04:47 +00:00
Sepherosa Ziehau
fc4a9fc4c0 hyperv/hn: Stringent per-packet-info verification.
While I'm here, minor style changes.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7709
2016-09-01 06:05:08 +00:00
Sepherosa Ziehau
2c2e52605f hyperv/hn: Remove unused function
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7706
2016-09-01 05:29:58 +00:00
Eric Joyner
ff9b61ca07 Fix linker warnings (errors on gcc) that resulted from r304510.
The variables that are extern in the netmap header file should be
defined in ixl_txrx.c (the file that is included in both ixl(4)/ixlv(4),
not in the main driver source files.

Reported by:	ed@, dim@, ngie@
2016-09-01 01:08:18 +00:00
Navdeep Parhar
a9feb2cdbb cxgbe/t4_tom: Two new routines to allocate and write page pods for a
buffer in the kernel's address space.
2016-09-01 00:51:59 +00:00
Navdeep Parhar
968267fdb8 cxgbe/t4_tom: Add general purpose routines to deal with page pod regions
and allocations within them.  Switch to these routines to manage the TOE
DDP region.

Sponsored by:	Chelsio Communications
2016-08-31 23:23:46 +00:00
Bruce Evans
a95582c6fd Add some locking to sc_cngetc().
Keyboard input needs Giant locking, and that is not possible to do
correctly here.  Use mtx_trylock() and proceed unlocked as before if
we can't acquire Giant (non-recursively), except in kdb mode don't
even try to acquire Giant.  Everything here is a hack, but it often
works.  Even if mtx_trylock() succeeds, this might be a LOR.

Keyboard input also needs screen locking, to handle screen updates
and switches.  Add this, using the same simplistic screen locking
as for sc_cnputc().

Giant must be acquired before the screen lock, and the screen lock
must be dropped when calling the keyboard driver (else it would get a
harmless LOR if it tries to acquire Giant).  It was intended that sc
cn open/close hide the locking calls, and they do for i/o functions
functions except for this complication.

Non-console keyboard input is still only Giant-locked, with screen
locking in some called functions.  This is correct for the keyboard
parts only.

When Giant cannot be acquired properly, atkbd and kbdmux tend to race
and work (they assume that the caller acquired Giant properly and don't
try to acquire it again or check that it has been acquired, and the
races rarely matter), while ukbd tends to deadlock or panic (since it
does the opposite, and has other usb threads to deadlock with).

The keyboard (Giant) locking here does very little, but the screen
locking completes screen locking for console mode except for not
detecting or handling deadlock.
2016-08-31 11:10:39 +00:00
Sepherosa Ziehau
4bddf0c813 hyperv/timesync: Rework time adjustment policy
- By default, adjust time upon SYNC request.  It can be disabled
  through hw.hvtimesync.ignore_sync_req.  SYNC request will be
  sent by hypervisor the host is resumed, rebooted, etc.
- By default, adjust time upon SAMPLE request, if there is 100ms
  difference between VM time and hypervisor time.  This can be
  disabled through hw.hvtimesync.sample_drift.

And nuke the unnecessary task, since channel callback is running
in a Hyper-V taskqueue nowadays.

Submitted by:	YanZhe Chen <t-yachen microsoft com>
Discussed with:	Dexuan Cui <decui microsoft com>, Hongjiang Zhang <honzhan microsoft com>, sephe
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7707
2016-08-31 06:00:20 +00:00
Sepherosa Ziehau
cf38cf1b7a hyperv/hn: Consolidate NVS transaction execution.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7704
2016-08-31 05:27:30 +00:00
Ed Maste
718d07c040 iscsi_initiator: make logout_req::reason unsigned char
Previously this reported an error from Clang 3.9.0: implict conversion
from 'int' to 'char' changes value from 128 to -128.

Discussed with:	dim, trasz
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7699
2016-08-30 19:20:26 +00:00
Bruce Evans
cc43fd1ab5 Fix keyboard polling "on/off" to support recursion. vt depends on
this, and sc will soon depend on it again.

The on/off request is passed without modification to lower layers,
so the bug was smaller in this layer than in in lower layers (the
sequence on;on;off left polling off when it should be on, but the
sequence on;on;off;on;off...  doesn't allow the interrupt handler
to eat the input after an "off" that should't turn off polled mode,
provided lower layers don't have the bug, since this layer is virtual.

The bug was small in lower layers too.  Normally everything is Giant
locked for keyboards, and this locks out the interrupt handler in
on;on;off;on;off... sequences.  However, PR 211884 says that fixing
this bug in ukbd in r303765 apparently causes the eating-by-interrupt
behaviour that the fix is to prevent.

Discussed with: emax
2016-08-30 12:36:14 +00:00
Bruce Evans
81306e463e Start adding locking to sc_cngetc().
Restore an splx() lost in r228644.  We aren't nearly ready to remove
spl's.  They give hints about missing locking.  This lost one was
misplaced.  Dropping it early for convenience gave race windows for
accesses to the fkey buffer.  Giant locking accidentally fixed this
for non-console cases.

Put the spl's around the whole function.  Since there are many returns
that would need splx() just before them for a direct fix, split the
function into a wrapper that does the spl's and a "locked" function
that does the work.

Return earlier when no keyboard is attached to match the ordering in a
planned version.  This breaks the dubious feature of returning keys
from the fkey buffer after the keyboard has gone away.  Losing the keys
wouldn't matter, but we keep them too long now.
2016-08-30 10:57:19 +00:00
Sepherosa Ziehau
96376f14a9 hyperv/hn: Remove unnecessary NULL check.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7690
2016-08-30 05:47:58 +00:00
Sepherosa Ziehau
fa021050df hyperv/hn: Log packet message alignment.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7689
2016-08-30 05:35:19 +00:00
Sepherosa Ziehau
ecb735a3ac hyperv/hn: Remove the useless rndis_device and related bits
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7687
2016-08-30 05:21:34 +00:00
Sepherosa Ziehau
1eeba644f0 hyperv/hn: Switch to new RNDIS transaction execution for halt.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7686
2016-08-30 05:09:26 +00:00
Sepherosa Ziehau
63d98d54aa hyperv/hn: Factor out func to exec RNDIS transaction w/o checking result
It will be used by RNDIS HALT and RESET.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7685
2016-08-30 04:04:29 +00:00
Sepherosa Ziehau
c7359ebb0c hyperv/hn: Remove unused function
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7684
2016-08-30 03:55:43 +00:00
Sepherosa Ziehau
05bbfc3062 hyperv/hn: Switch to new RNDIS set for RX filters.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7683
2016-08-30 03:40:22 +00:00
Sepherosa Ziehau
1010113dad net/rndis: Packet types are defined by NDIS; not RNDIS specific.
Reviewed by:	hps
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7681
2016-08-30 03:11:07 +00:00
Sepherosa Ziehau
77a48d6159 hyperv/hn: Indentation and field comment fixup for ndis.h.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7680
2016-08-30 03:03:19 +00:00
Sepherosa Ziehau
8bb1a21b56 hyperv/hn: Move OIDs to net/rndis.h; they are standard NDIS OIDs.
Actually all OIDs defined in net/rndis.h are standard NDIS OIDs.
While I'm here, use the verbose macro name as in NDIS spec.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7679
2016-08-30 02:55:07 +00:00
Justin Hibbits
e150821a8c Add support for NXP/Freescale etsec2 ethernet controller
Adding the compatible property check isn't enough.  Device trees for eTSEC2
devices are missing a 'reg' property on the eTSEC node itself, relegating it to
the queue group child nodes.

Still left to do: add Multigroup mode support (see QorIQ reference manuals s for
SoCs with eTSEC2).

MFC after:	2 weeks
Relnotes:	Yes
2016-08-30 01:58:49 +00:00
John Baldwin
bc32f05443 Use device_verbose() to undo device_quiet() when detaching from t[45]iovX.
The device quiet flag is not automatically reset on detach, so it is
inherited by other device drivers (e.g. when switching a device driver
over to ppt for PCI pass through).  Cope with this behavior by explicitly
marking the device verbose during detach so that the next driver can make
its own decision.

Sponsored by:	Chelsio Communications
2016-08-29 22:47:14 +00:00
Conrad Meyer
ee5642bb35 ioat(4): Add additional CTR tracing during reset 2016-08-29 20:51:34 +00:00
Conrad Meyer
1bbc06b85b ioat(4): Don't "complete" DMA descriptors prematurely
In r304602, I mistakenly removed the ioat_process_events check that we weren't
processing events before the hardware had completed the descriptor
("last_seen").  Reinstate that logic.

Keep the defensive loop condition and additionally make sure we've actually
completed a descriptor before blindly chasing the ring around.

In reset, queue and finish the startup command before allowing any event
processing or submission to occur.  Avoid potential missed callouts by
requeueing the poll later.
2016-08-29 20:46:33 +00:00
Bruce Evans
b430634b31 Add screen locking calls to sc cn grab and ungrab. The locking functions
just use the same mutex locking as sc cn putc so they have the same
defects.

The locking calls to acquire the lock are actually in sc cn open and close.
Ungrab has to unlock, although this opens a race window.

Change the direct mutex lock calls in sc cn putc to the new locking
functions via the open and close functions.  Putc also has to unlock, but
doesn't keep the screen open like grab.  Screen open and close reduce to
locking, except screen open for grab also attempts to switch the screen.

Keyboard locking is more difficult and still null, even when keyboard
input calls screen functions, except some of the functions have locks
too deep to work right.

This organization gives a single place to fix some of the locking.
2016-08-29 18:41:06 +00:00
Sepherosa Ziehau
fdda77284f hyperv/hn: Switch to new RNDIS set for RSS parameters.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7658
2016-08-29 05:35:35 +00:00
Sepherosa Ziehau
7681d6725a hyperv/hn: Fix # of channels setting, if RSS is not available.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7657
2016-08-29 05:08:53 +00:00
Sepherosa Ziehau
e4e0ef792c hyperv/hn: Switch to new RNDIS query for RSS capabilities extraction.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7656
2016-08-29 04:54:13 +00:00
Sepherosa Ziehau
c204be533c hyperv/hn: Switch to new RNDIS query for link status extraction.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7654
2016-08-29 04:44:24 +00:00
Sepherosa Ziehau
3dc33a77d7 hyperv/hn: Add definition for NDIS media state.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7652
2016-08-29 03:22:56 +00:00
John Baldwin
27dc50b0f0 Add missing array subscript.
This fixes a tautological pointer comparison warning, but would also a
real bug for a platform where bus_dmamap_unload of a static allocation
is not a no-op.
2016-08-29 01:59:18 +00:00
Justin Hibbits
24f4202df8 Check all compatible strings on uart devices in powerpc
Summary:
Some device trees put "fsl,ns16650" first in the compatible list.  This causes
the probe code to choke, even though the device is compatible with ns16650, and
has it listed later in the tree.

Reviewed by:	nwhitehorn
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D7676
2016-08-28 21:31:21 +00:00
Landon J. Fuller
d851916ef2 bhnd(4): Apply the siba chipid ncore fixup in bhnd_read_chipid(), ensuring
that bhndb et al are always operating on a valid core count.

Approved by:	adrian (mentor, implicit)
2016-08-28 20:39:53 +00:00
Landon J. Fuller
203788adf0 bhnd(4): Add a bhnd bus method for fetching the device's core table.
This will allow us to perform bhndb(4) bridge configuration based on
the identified hardware, prior to performing full enumeration of the
child bhnd bus.

Approved by:	adrian (mentor, implicit)
2016-08-28 19:34:22 +00:00
Justin Hibbits
7bd8311dec Fix UART PPS capture mode printing
* Add breaks to prevent fallthrough and printing of multiple modes.
* Only check the mode, mask out all other bits.
2016-08-28 04:40:27 +00:00
Andriy Voskoboinyk
e796f68455 iwm: fix few comment typos. 2016-08-27 10:04:48 +00:00
Andriy Voskoboinyk
d845f44fb1 iwm: add 'command accepted' debug notification (copied from wpi(4)).
Now it should be easier to find out which command causes firmware
panics when few commands are sent in a short period of time.
2016-08-27 08:34:20 +00:00
Landon J. Fuller
b24852c2b3 Implement siba(4) support for bhnd_(read|write)_config.
This provides access to the siba(4) bus-mapped per-core cfg0 register
block.

Approved by:	adrian (mentor, implicit)
2016-08-27 00:58:21 +00:00
Navdeep Parhar
e25621e5ea cxgbe(4): Provide more details about the card in the sysctl MIB.
dev.t5nex.0.%desc: Chelsio T580-CR
dev.t5nex.0.hw_revision: 1
dev.t5nex.0.sn: PT13140042
dev.t5nex.0.pn: 110117150A0
dev.t5nex.0.ec: 0000000000000000
dev.t5nex.0.na: 0007432AF490
dev.t5nex.0.vpd_version: 3
dev.t5nex.0.scfg_version: 53255
dev.t5nex.0.bs_version: 1.1.0.0
dev.t5nex.0.er_version: 1.0.0.68
dev.t5nex.0.tp_version: 0.1.4.9
dev.t5nex.0.firmware_version: 1.16.2.0

Sponsored by:	Chelsio Communications
2016-08-27 00:13:41 +00:00
Landon J. Fuller
9bb959068a bhnd(4): Include the chip model (e.g. BCM4xxx) in bhnd(4) bus's device
descriptions.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7570
2016-08-27 00:07:48 +00:00
Landon J. Fuller
eb175e8bfb [mips/broadcom]: Replace static frequency table with generic PMU clock
handling.


- Extended PWRCTL/PMU APIs to support querying clock frequency during very
  early boot, prior to bus attach.
- Implement generic PMU-based calculation of UART rclk values.
- Replaced use of static frequency tables (bcm_socinfo) with
  runtime-determined values.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7552
2016-08-27 00:06:20 +00:00
Landon J. Fuller
f90f4b6532 bhnd(4): Initial PMU/PWRCTL power and clock management support.
- Added bhnd_pmu driver implementations for PMU and PWRCTL chipsets,
  derived from Broadcom's ISC-licensed HND code.
- Added bhnd bus-level support for routing per-core clock and resource
  power requests to the PMU device.
- Lift ChipCommon support out into the bhnd module, dropping
  bhnd_chipc.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7492
2016-08-27 00:03:02 +00:00
Landon J. Fuller
cb4abe62ba [mips/broadcom] Generic platform_reset() support.
This adds support for performing platform_reset() on all supported
devices, using early boot enumeration of chipc capabilities and
available cores.


- Added Broadcom-specific MIPS CP0 register definitions used by
  BCM4785-specific reset handling.
- Added a bcm_platform structure for tracking chipc/pmu/cfe platform
  data.
- Extended the BCMA EROM API to support early boot lookup of core info
  (including port/region mappings).
- Extended platform_reset() to support PMU, PMU+AOB, and non-PMU
  devices.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7539
2016-08-26 20:16:02 +00:00
Navdeep Parhar
7df135c055 cxgbe/iw_cxgbe: Various fixes to the iWARP driver.
- Return appropriate error code instead of ENOMEM when sosend() fails in
  send_mpa_req.
- Fix for problematic race during destroy_qp.
- Abortive close in the failure of send_mpa_reject() instead of normal close.
- Remove the unnecessary doorbell flowcontrol logic.

Submitted by:	Krishnamraju Eraparaju at Chelsio
MFC after:	1 month
Sponsored by:	Chelsio communications
2016-08-26 17:38:13 +00:00
Sepherosa Ziehau
77c4f5aa9d hyperv/hn: Use vmbus xact for RNDIS set.
And use new RNDIS set to configure NDIS offloading parameters.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7641
2016-08-26 05:18:27 +00:00
Sepherosa Ziehau
467da5ad48 hyperv/hn: Save the adopted NDIS version for RNDIS to use later.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7640
2016-08-26 05:15:08 +00:00
Sepherosa Ziehau
cc3d96db55 hyperv/hn: Use vmbus xact for RNDIS query.
And switch MAC address query to use new RNDIS query function.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7639
2016-08-26 05:12:09 +00:00
Navdeep Parhar
c149da1661 cxgbe/cxgbei: There is no need for multiple modules in the KLD.
Sponsored by:	Chelsio Communications
2016-08-26 01:28:31 +00:00
Navdeep Parhar
a95e0bfb6c cxgbe/cxgbei: Convert the driver-private PDU flags to enums and replace
pdu_ prefix with icp_ in struct icl_cxgbei_pdu.

Sponsored by:	Chelsio Communications
2016-08-25 23:06:12 +00:00
Navdeep Parhar
5d83392ac5 cxgbe/cxgbei: Read the chip's configuration to determine the actual
hardware send and receive PDU limits.  Report these limits to ICL and
take them into account when setting the socket's send and receive buffer
sizes.  The driver used a single hardcoded limit everywhere prior to
this change.

Sponsored by:	Chelsio Communications
2016-08-25 21:55:17 +00:00
Bruce Evans
d350ce61cf Less-quick fix for locking fixes in r172250. r172250 added a second
syscons spinlock for the output routine alone.  It is better to extend
the coverage of the first syscons spinlock added in r162285.  2 locks
might work with complicated juggling, but no juggling was done.  What
the 2 locks actually did was to cover some of the missing locking in
each other and deadlock less often against each other than a single
lock with larger coverage would against itself.  Races are preferable
to deadlocks here, but 2 locks are still worse since they are harder
to understand and fix.

Prefer deadlocks to races and merge the second lock into the first one.

Extend the scope of the spinlocking to all of sc_cnputc() instead of
just the sc_puts() part.  This further prefers deadlocks to races.

Extend the kdb_active hack from sc_puts() internals for the second lock
to all spinlocking.  This reduces deadlocks much more than the other
changes increases them.  The s/p,10* test in ddb gets much further now.
Hide this detail in the SC_VIDEO_LOCK() macro.  Add namespace pollution
in 1 nested #include and reduce namespace pollution in other nested
#includes to pay for this.

Move the first lock higher in the witness order.  The second lock was
unnaturally low and the first lock was unnaturally high.  The second
lock had to be above "sleepq chain" and/or "callout" to avoid spurious
LORs for visual bells in sc_puts().  Other console driver locks are
already even higher (but not adjacent like they should be) except when
they are missing from the table.  Audio bells also benefit from the
syscons lock being high so that audio mutexes have chance of being
lower.  Otherwise, console drviver locks should be as low as possible.
Non-spurious LORs now occur if the bell code calls printf() or is
interrupted (perhaps by an NMI) and the interrupt handler calls
printf().  Previous commits turned off many bells in console i/o but
missed ones done by the teken layer.
2016-08-25 13:46:52 +00:00
Bruce Evans
9f25943b82 Fix logic errors in bounds checks in previous commit. The 2-entry stack
was overrun for grab levels larger than 2.

Reported by:	pluknet
2016-08-25 12:04:57 +00:00
Sepherosa Ziehau
9db7c2c6b5 hyperv/storvsc: Increase queue depth and rework channel selection.
- Increasing queue depth gives ~100% performance improvement for
  randwrite fio test in Azure.
- New channel selection, which takes LUN id and the current cpuid
  into consideration, gives additional ~20% performance improvement
  for ranwrite fio test in Azure.

Submitted by:   Hongzhang Jiang <honzhan microsoft com>
Modified by:    sephe
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7622
2016-08-25 05:50:19 +00:00
Sepherosa Ziehau
dd9af4103b hyperv/vmbus: Add function to calculate max # of elements in a bufring.
MFC after:	1 week
Sponsored by:	Microsoft
2016-08-25 05:35:51 +00:00
Sepherosa Ziehau
c72fc9d2b9 hyperv/ic: Update total message size if negotiate message size grows.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7627
2016-08-25 05:24:57 +00:00
Navdeep Parhar
97b84d344d Make the iSCSI parameter negotiation more flexible.
Decouple the send and receive limits on the amount of data in a single
iSCSI PDU.  MaxRecvDataSegmentLength is declarative, not negotiated, and
is direction-specific so there is no reason for both ends to limit
themselves to the same min(initiator, target) value in both directions.

Allow iSCSI drivers to report their send, receive, first burst, and max
burst limits explicitly instead of using hardcoded values or trying to
derive all of them from the receive limit (which was the only limit
reported by the drivers prior to this change).

Display the send and receive limits separately in the userspace iSCSI
utilities.

Reviewed by:	jpaetzel@ (earlier version), trasz@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7279
2016-08-25 05:22:53 +00:00
Sepherosa Ziehau
02d9926559 hyperv/ic: Cleanup heartbeat channel callback.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7626
2016-08-25 05:11:04 +00:00
Sepherosa Ziehau
550bbdbd27 hyperv/hn: Use vmbus xact for RNDIS initialize.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7624
2016-08-25 05:00:41 +00:00
Sepherosa Ziehau
fec38279d8 hyperv/hn: Add compat code for RNDIS reorganization phase.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7621
2016-08-25 04:52:50 +00:00
Sepherosa Ziehau
6cc86f82b7 hyperv/hn: Use definition in net/rndis.h for message type and status code.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7620
2016-08-25 04:40:51 +00:00
Bruce Evans
e866ca565f Flesh out the state and flags args to sccnopen(). Set state flags to
indicate (potentially partial) success of the open.  Use these to
decide what to close in sccnclose().  Only grab/ungrab use open/close
so far.

Add a per-sc variable to count successful keyboard opens and use
this instead of the grab count to decide if the keyboad state has
been switched.

Start fixing the locking by using atomic ops for the most important
counter -- the grab level one.  Other racy counting will eventually
be fixed by normal mutex or kdb locking in most cases.

Use a 2-entry per-sc stack of states for grabbing.  2 is just enough
to debug grabbing, e.g., for gets().  gets() grabs once and might not
be able to do a full (or any) state switch.  ddb grabs again and has
a better chance of doing a full state switch and needs a place to
stack the previous state.  For more than 3 levels, grabbing just
changes the count.  Console drivers should try to switch on every i/o
in case lower levels of nesting failed to switch but the current level
succeeds, but then the switch (back) must be completed on every i/o
and this flaps the state unless the switch is null.  The main point
of grabbing is to make it null quite often.  Syscons grabbing also
does a carefully chosen screen focus that is not done on every i/o.

Add a large comment about grabbing.

Restore some small lost comments.
2016-08-24 18:59:24 +00:00
Bruce Evans
2078bf6ef0 Reorganise a little to prepare for locking fixes:
- in sccnopen(), open the keyboard before the screen.  The keyboard
  currently requires Giant (although it must be spinlocked to work
  correctly as a console), so the previous order would be a LOR if
  it has any semblance of locking.
- add a (currently dummy) state arg to scgetc().
2016-08-24 17:26:11 +00:00
Bruce Evans
1a58327bc3 Fix key delay and repeat, part 2.
Use sbintime_t timeouts with precision control to get very accurate
timing.  It costs little to always ask for about 1% accuracy, and the
not so new event timer implementation usual delivers that, and when
it can't it gets much closer than our previous coarse timeouts and
buggy simple countdown.

The 2 fastest atkbd repeat rates have periods 34 and 38 msec, and ukbd
pretended to support rates in between these.  This requires
sub-microsecond precision and accuracy even to handle the 4 msec
difference very well, but ukbd asked the timeout subsystem for timeouts
of 25 msec and the buggy simple countdown of this gave a a wide range
of precisions and accuracies depending on HZ and other timer
configuration (sometimes better than 25 msec but usually more like 50
msec).  We now ask for and usually get precision and accuracy of about
1% for each repeat and much better on average.

The 1% accuracy is overkill.  Rounding of 30 cps to 34 msec instead of
33 already gives an error of +2% instead of -1%, and ut AT keyboards on
PS/2 interfaces have similar errors.

A timeout is now scheduled for every keypress and release.  This allows
some simplifications that are not done.  It allows removing the timeout
scheduling for exiting polled mode where it was unsafe in ddb mode.  This
is done.  Exiting polled mode had some problems with extra repeats.  Now
exiting polled mode lets an extra timeout fire and the state is fudged
so that the timeout handler does very little.

The sc->time_ms variable is unsigned to avoid overflow.  Differences of
it need to be signed.  Signed comparisons were emulated by testing an
emulated sign bits.  This only works easily for '<' comparisonss, but
we now need a '<=' comparison.  Change the difference variable to
signed and use a signed comparison.  Using unsigned types here didn't
prevent overflow bugs but just reduced them.  Overflow occurs with
n repeats at the silly repeat period of [U]INT_MAX / n.  The old countdown
had an off by 1 error, and the simplifications would simply count down
1 to 0 and not need to accumulate possibly-large repeat repeats.
2016-08-24 05:54:11 +00:00
Sepherosa Ziehau
8f555c7d0a hyperv/ic: Redefine IC version negotiate message.
And stringent input IC version negotiate message checks.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7614
2016-08-24 04:36:04 +00:00
Sepherosa Ziehau
aa4a62df05 hyperv/hn: Log a warning for RESET_CMPLT.
RESET is not used by the hn(4) at all, and RESET_CMPLT does not even
have a rid to match with the pending requests.  So, let's put it
onto an independent switch branch and log a warning about it.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7602
2016-08-24 04:21:15 +00:00
Kevin Lo
e626c40eb5 Bring datasheet URL up to date. 2016-08-24 03:44:16 +00:00
Sepherosa Ziehau
d51ce2d164 hyperv/hn: Remove the redundant rid setting for RNDIS HALT.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7595
2016-08-24 03:28:58 +00:00
Sepherosa Ziehau
48ef7b17f0 net/rndis: Add canonical RNDIS major/minor version as of today.
Reviewed by:	hps
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7593
2016-08-24 03:08:13 +00:00
Bruce Evans
e99472e0d6 Fix key delay and repeat, part 1.
kbdcontrol -r fast is documented to give a non-emulated atkbd's fastest
rate of 250.34, but is misimplemented to request this as 0.0.  ukbd
supports many nonstandard rates, although it is currently too inaccurate
by a factor of several hundred for non-huge nonstandard rates to be
useful.  It mapped 0.0 to 200.0.  A repeat delay of 0 means a rate of
infinity which is quite fast, but physical constraints limit this to
a few MHz and the inaccuracies made it almost usable.

Convert 0.0 to the documented 250.34.

Also convert negative args and small args to the 250.34 minimal ones,
like atkbd does.  This is for KDSETREPEAT -- the 2 versions of the
deprecated KDSETRAD have bounds checking.  Keep not doing any bounds
checking or conversions for upper limits since nonstandard large
delays are useful for testing.

The inaccuracies are dependent on HZ and the timeout implementation.
With the old timeout implementation and HZ = 1000, 200.0 probably
worked better to emulate 250.34 than 250.34 itself.  HZ = 100 gives
roundoff errors that accidentally reduce the inaaccuracies, and
event timers reduce the inaccuracies even more, so 200.0 was giving
more like itself (perhaps 215.15 on average but sometimes close to
10 msec repeat which is noticebly too fast).  This commit makes 0.0
noticeably too slow, like 250.34 always was.
2016-08-23 19:50:16 +00:00
Landon J. Fuller
7ba0628f07 bhndb(4): Fix unsigned integer underflow in dynamic register window
handling. This resulted in the window target being left uninitialized
when an underflow occured.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7617
2016-08-23 19:03:11 +00:00
Andriy Gapon
a48ec78e96 intpm: add support for SB800
This code should be able to support later AMD chipsets as well, but that
hasn't been tested.

SB800 supports accessing several different SMBus buses using the same
set of constrol registeirs plus special PMIO registers that control which
bus is selected.  This could be exposed to consumers as several smb devices
each talking to its bus.  This feature is not implemented yet.

MFC after:	2 weeks
2016-08-23 10:40:53 +00:00
Sepherosa Ziehau
1ba241d223 net: Split RNDIS protocol structs/macros out of dev/usb/net/if_urndisreg.h
So that Hyper-V can leverage them instead of rolling its own definition.

Discussed with:	hps
Reviewed by:	hps
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7592
2016-08-23 02:54:06 +00:00
Hans Petter Selasky
f81d0b43f1 Don't separate the status stage of the XHCI USB control transfers into
its own job because this breaks the simplified QEMU XHCI TRB parser,
which expects the complete USB control transfer as a series of back to
back TRBs. The old behaviour is kept under #ifdef in case this change
breaks enumeration of any USB devices.

PR:		212021
MFC after:	1 week
2016-08-22 19:32:50 +00:00
Bruce Evans
ded67349a3 Further fixes for translation of PrintScreen/SysRq.
The previous fix was tested mainly on 3 AT keyboards with USB adaptors where
it works.  1 USB keyboard doesn't translate Alt-PrintScreen, so the software
has to do it.

Reorganize a little to share some code and to not translate the unusual usb
scan code0x8a unless an Alt modified is set.  Remove redundant check of Alt
modifiers.  Translation now more clearly filters out Alt-PrintScreen before
the check.

The table of errors fixed in the previous commit had many bugs.  Correct
table:

K_RAW  Ctl-PrintScreen:                                 E0-2A-E0-37 -> E0-37
K_RAW  Alt-PrintScreen (with 4 comb. of Ctl/Shift):     79 -> 54
K_RAW  Pause/Break (with 4 comb. of Alt/Shift):         E0-46 -> E1-1D-45
K_CODE PrintScreen (with 4 comb. of Ctl/Shift):         54 -> 5c
K_CODE Alt-PrintScreen (with 4 comb. of Ctl/Shift):     7e -> 54
K_CODE Pause/Break (with 8 comb. of Ctl/Alt/Shift):     6c -> 68

That is 25 of 32 shift combinations for 2 keys fixed.  All 16 combinations
were broken for K_CODE and thus also for K_XLATE.
2016-08-22 16:39:51 +00:00
Conrad Meyer
c114e74120 ioat(4): Allow callouts to be scheduled after hw reset
is_completion_pending governs whether or not a callout will be scheduled
when new work is queued on the IOAT device.  If true, a callout is
already scheduled, so we do not need a new one.  If false, we schedule
one and set it true.  Because resetting the hardware completed all
outstanding work but failed to clear is_completion_pending, no new
callout could be scheduled after a reset with pending work.

This resulted in a driver hang for polled-only work.
2016-08-22 14:51:09 +00:00
Conrad Meyer
0283c0f581 ioat(4): Don't process events past queue head
Fix a race where the completion routine could overrun the active ring
area in some situations.
2016-08-22 14:51:07 +00:00
Hans Petter Selasky
351a9c7c0b Increase the maximum RX/TX queue size. This allows for a RX/TX queue
size of 16384 mbufs. Previously the limit was 8192.

Sponsored by:	Mellanox Technologies
MFC after:	1 week
2016-08-22 13:43:25 +00:00
Hans Petter Selasky
7816434a4f Fix for invalid use of bits in input context. Basically split
configuring of EP0 and non-EP0 into xhci_cmd_evaluate_ctx() and
xhci_cmd_configure_ep() respectivly. This resolves some errors when
using XHCI under QEMU and gets is more in line with the XHCI
specification.

PR:		212021
MFC after:	1 week
2016-08-22 10:21:25 +00:00
Sepherosa Ziehau
2e5573e6de hyperv/hn: Factor out function to simplify NVS request sending
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7578
2016-08-22 08:00:14 +00:00
Sepherosa Ziehau
8f556f2598 hyperv/hn: Factor out function to execute NVS transactions.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7577
2016-08-22 07:51:46 +00:00
Sepherosa Ziehau
ef56e63fb3 hyperv/hn: Get rid of netvsc_dev
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7575
2016-08-22 07:44:11 +00:00
Sepherosa Ziehau
fdd6031b04 hyperv/hn: Move chimney sending buffer to hn_softc
And don't recreate chimney sending buffer for each primary channel
open, it is now created in device_attach DEVMETHOD and destroyed
in device_detach DEVMETHOD.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7574
2016-08-22 07:34:39 +00:00
Pyun YongHyeon
bb7e9b3046 Add a missing change in r304575.
Noticed by:	jhb
2016-08-22 03:28:06 +00:00
Pyun YongHyeon
477cba21d2 Add Killer E2400 Gigabit Ethernet support.
It seems Killer E2200/E2400 has a BIOS misconfiguration or silicon
bug which triggers DMA write errors when driver uses advertised
maximum payload size.  Force the maximum payload size to 128 bytes
in DMA configuration.
This change should fix occasional DMA write errors reported on
Killer E2200.

Tested by:	<psy0nic@sys-tek.org>
2016-08-22 01:19:05 +00:00
Pyun YongHyeon
03b4253bb8 Correct DMA channel number selection on AR816x family of
controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
except L1D controller, use vendor recommended ASPM parameters.
While here, increase alc_dma_burst array size.  Broken H/W can
return bogus value in theory.
2016-08-22 01:06:54 +00:00
Hans Petter Selasky
a6ae9251b4 Make the UKBD USB transfers double buffered and set them up one by one,
so they are memory independent which allows for handling panics
triggered by the keyboard driver itself, typically via CTRL+ALT+ESC
sequences. Or if the USB keyboard driver was processing a key at the
moment of panic. Allow UKBD to be attached while keyboard polling is active.

Tested by:	Bruce Evans <bde@freebsd.org>
MFC after:	1 week
2016-08-21 18:37:21 +00:00
Bruce Evans
3f7880e23a Fix translation of the PrintScreen/SysRq and Pause/Break keys. Almost
everything was broken.  The cases that I noticed were Ctrl-PrintScreen
not being mapped to the virtual scancode 0x5c (debug) and Pause not being
mapped to the physical/virtual scancode 0x46 (slock).

These keys are the most complicated ones due to kludges to give some
compatibility back to before AT keyboards.

Alt-PrintScreen must pretend to be a separate key from PrintScreen
even at the "raw" level.  The (unique) usb code for it is 0x8a and we
just have to map this to our unique virtual scancode 0x54, but we
mapped it first to the internal code 0x7e and then to 0x79 which is a
key on the Japanese 106/109 keyboard.  This fix is under the
UKBD_EMULATE_ATASCANCODE option which shouldn't be used for non-AT
keyboards.  If it is, then the syscons Japanese keymaps have nothing
of importance for code 0x79 and can easily be changed.  0x54 is also
unimportant in Japanese and US keymaps.

NonAlt-PrintScreen and NonCtl-Pause/Break had many much larger bugs with
smaller compatibility problems from fixing them.  The details are too
ugly to give here.  Summary of the changed (hex) codes:

K_RAW  PrintScreen (Ctl, Shift, Ctl-Shift):             E0-2A-E0-37 -> E0-37
K_RAW  Alt-PrintScreen (all shift states):              79 -> 54
K_RAW  Pause/Break (unshifted, Shift, Alt, Alt-Shift)): E0-46 -> E1-1D-45
K_CODE ALT-PrintScreen (all shift states):              79 -> 54

That is 15 of 32 shift combinations for 2 keys fixed, with 8 easy cases
from the 79 -> 54 remapping.

The difference is only large and with no workaround using a keymap for
for K_RAW, but this affects other modes when ukbd is layered under kbmux
because kbmux keeps all subdevices in K_RAW mode and translates.  Oops.
I used kbdmux to generate the above table of changes.
2016-08-21 16:06:00 +00:00
Andriy Gapon
6975a721d1 JMicron JMB361 has only a single SATA port
Discussed with:	mav
MFC after:	3 days
2016-08-20 09:13:14 +00:00