Commit Graph

768 Commits

Author SHA1 Message Date
Sepherosa Ziehau
9ba5e29c5c hyperv: Use kmem_malloc for hypercall memory due to NX bit change.
Reported by:	dexuan@
MFC after:	now
Sponsored by:	Microsoft
2017-04-19 02:39:48 +00:00
Sepherosa Ziehau
1e85137841 hyperv/kvp: Remove always false condition.
Reported by:	PVS
MFC after:	3 days
Sponsored by:	Microsoft
2017-04-14 05:29:27 +00:00
Sepherosa Ziehau
e25942b0eb hyperv/storvsc: Use ULL for 64bits value shift.
Reported by:	PVS
MFC after:	3 days
Sponsored by:	Microsoft
2017-04-14 05:25:21 +00:00
Sepherosa Ziehau
7737abe4f2 hyperv/kbd: Remove unnecessary assignment.
Reported by:	PVS
MFC after:	3 days
Sponsored by:	Microsoft
2017-04-14 05:18:42 +00:00
Sepherosa Ziehau
b3b75d9c84 hyperv/hn: Fixat RNDIS rxfilter after the successful RNDIS init.
Under certain conditions on certain versions of Hyper-V, the RNDIS
rxfilter is _not_ zero on the hypervisor side after the successful
RNDIS initialization, which breaks the assumption of any following
code (well, it breaks the RNDIS API contract actually).  Clear the
RNDIS rxfilter explicitly, drain packets sneaking through, and drain
the interrupt taskqueues scheduled due to the stealth packets.

Reported by:	dexuan@
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D10230
2017-04-05 08:25:22 +00:00
Sepherosa Ziehau
498ef762ec hyperv/storvsc: Fixup SRB status.
This unbreaks GEN2 Hyper-V cd support.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
Reviewed by:	dexuan@
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D10212
2017-04-05 08:15:47 +00:00
Sepherosa Ziehau
3f1b91c58d hyperv/kbd: Add support for synthetic keyboard.
Synthetic keyboard is the only supported keyboard on GEN2 Hyper-V.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D10196
2017-04-05 05:01:23 +00:00
Sepherosa Ziehau
920adec330 hyperv/hn: Misaligned chimney sending buffers should not be used
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D9714
2017-03-01 09:05:12 +00:00
Sepherosa Ziehau
7675868a04 hyperv/hn: Make sure that RNDIS packet message is at least 4B aligned.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D9713
2017-03-01 08:50:41 +00:00
Sepherosa Ziehau
8fe90f73ae hyperv/hn: Simplify RNDIS packet total length calculation.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D9712
2017-03-01 08:24:17 +00:00
Sepherosa Ziehau
9130c4f75b hyperv/hn: Simplify RNDIS packet data offset calculation.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D9699
2017-02-28 09:50:34 +00:00
Warner Losh
28586889c2 Convert PCIe Hot Plug to using pci_request_feature
Convert PCIe hot plug support over to asking the firmware, if any, for
permission to use the HotPlug hardware. Implement pci_request_feature
for ACPI. All other host pci connections to allowing all valid feature
requests.

Sponsored by: Netflix
2017-02-25 06:11:59 +00:00
Dexuan Cui
33408a34c4 hyperv/hn: add devctl_notify for VF_UP/DOWN events
Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	2 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D9102
2017-01-24 09:27:13 +00:00
Dexuan Cui
40d60d6ee1 hyperv/hn: add a sysctl name for the VF interface
This makes it easier for the userland script to find the releated
VF interface.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	2 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D9101
2017-01-24 09:25:42 +00:00
Dexuan Cui
5bdfd3fd36 hyperv/hn: add the support for VF drivers (SR-IOV)
Hyper-V's NIC SR-IOV implementation needs a Hyper-V synthetic NIC and
a VF NIC to work together (both NICs have the same MAC address), mainly to
support seamless live migration.

When the VF device becomes UP (or DOWN), the synthetic NIC driver needs
to switch the data path from the synthetic NIC to the VF (or the opposite).

Note: multicast/broadcast packets are still received through the synthetic
NIC and we need to inject the packets through the VF interface (if the VF is
UP), even if the synthetic NIC is DOWN (so we need to force the rxfilter
to be NDIS_PACKET_TYPE_PROMISCUOUS, when the VF is UP).

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	2 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8964
2017-01-24 09:24:14 +00:00
Dexuan Cui
c927d68136 hyperv/hn: remove the MTU and IFF_DRV_RUNNING checking in hn_rxpkt()
It's unnecessary because the upper nework stack does the same checking.

In the case of Hyper-V SR-IOV, we need to remove the checking because
1) multicast/broadcast packets are still received through the synthetic
NIC and we need to inject the packets through the VF interface;
2) we must inject the packets even if the synthetic NIC is down, or has
a different MTU from the VF device.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	2 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8962
2017-01-24 09:15:36 +00:00
Dexuan Cui
3ab0fea134 hyperv/hn: remember the channel pointer in struct hn_rx_ring
This will be used by the coming NIC SR-IOV patch.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	2 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8909
2017-01-24 09:09:53 +00:00
Sepherosa Ziehau
227bb849d3 hyperv: Add method to read 64bit Hyper-V specific time value.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D9057
2017-01-09 03:38:41 +00:00
Alan Somers
4195c7de24 Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)
The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are
fixed-length strings. AFAICT the only place they're read is in
sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated.
However, the kernel doesn't null-terminate them. A bunch of copy-pasted code
uses strncpy to write them, and doesn't guarantee null-termination. For at
least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually
overflows. You can see the result by doing "camcontrol negotiate da0 -v".

This change null-terminates those fields everywhere they're set in the
kernel. It also shortens a few strings to ensure they'll fit within the
16-character field.

PR:		215474
Reported by:	Coverity
CID:		1009997 1010000 1010001 1010002 1010003 1010004 1010005
CID:		1331519 1010006 1215097 1010007 1288967 1010008 1306000
CID:		1211924 1010009 1010010 1010011 1010012 1010013 1010014
CID:		1147190 1010017 1010016 1010018 1216435 1010020 1010021
CID:		1010022 1009666 1018185 1010023 1010025 1010026 1010027
CID:		1010028 1010029 1010030 1010031 1010033 1018186 1018187
CID:		1010035 1010036 1010042 1010041 1010040 1010039
Reviewed by:	imp, sephe, slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9037
Differential Revision:	https://reviews.freebsd.org/D9038
2017-01-04 20:26:42 +00:00
Sepherosa Ziehau
f1b0a43ff6 hyperv/hn: Factor out function to set rxfilter.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8928
2016-12-28 04:47:17 +00:00
Sepherosa Ziehau
c08f7b2c28 hyperv/hn: Function renaming; no functional changes.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8908
2016-12-28 04:35:52 +00:00
Sepherosa Ziehau
87f8129d28 hyperv/hn: Consolidate hn_{suspend,resume}
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8907
2016-12-28 03:19:59 +00:00
Sepherosa Ziehau
69d2eb82d7 hyperv/vmbus: Nuke unnecessary critical sections.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8906
2016-12-28 03:07:58 +00:00
Sepherosa Ziehau
92c1ba2828 hyperv/ic: Allow applying the samples from hypervisor unconditionally.
MFC after:	1 week
Sponsored by:	Microsoft
2016-12-23 08:52:10 +00:00
Sepherosa Ziehau
69b12e53db hyperv/ic: Fix version4 timesync message format.
It is not compat w/ the old timesync message format, which the message
type stays the same as the old timesync message.

MFC after:	1 week
Sponsored by:	Microsoft
2016-12-23 08:41:28 +00:00
Sepherosa Ziehau
be53a2fa1b hyperv: Unbreak EARLY_AP_STARUP Hyper-V bootstrap by using intrhook
Properly working pause and friends are required.

MFC after:	3 days
Sponsored by:	Microsoft
2016-12-21 03:23:35 +00:00
Sepherosa Ziehau
39f0182303 hyperv/storvsc: The max channel in PDU actually means the max sub-chans.
Use proper name for local variables. PDU fields' name was not changed yet.
While I'm here, make # of usable channels tunable. This eases further
testing.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8851
2016-12-21 03:09:07 +00:00
Sepherosa Ziehau
5c072c8e98 hyperv/ic: Rename cleaned up files.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8850
2016-12-20 09:46:14 +00:00
Sepherosa Ziehau
f1d33c25fa hyperv/ic: Cleanup driver glue.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8849
2016-12-20 07:34:44 +00:00
Sepherosa Ziehau
9ff086544d hyperv/ic: Rname cleaned up file.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8848
2016-12-20 07:14:24 +00:00
Sepherosa Ziehau
8e10e18f02 hyperv/ic: Inclusion cleanup
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8847
2016-12-20 05:39:00 +00:00
Sepherosa Ziehau
ed8107d131 hyperv/ic: Rename cleaned up header file.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8846
2016-12-20 05:26:38 +00:00
Sepherosa Ziehau
1eb6d71178 hyperv/ic: Cleanup common struct and functions.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8845
2016-12-20 05:07:12 +00:00
Sepherosa Ziehau
2438ba4ed4 hyperv/ic: Factor out function to send IC response
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8844
2016-12-20 04:51:14 +00:00
Sepherosa Ziehau
fff5be0be3 hyperv: Implement userspace gettimeofday(2) with Hyper-V reference TSC
This 6 times gettimeofday performance, as measured by
tools/tools/syscall_timing

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8789
2016-12-19 07:40:45 +00:00
Sepherosa Ziehau
9622c93ae8 hyperv: Allow userland to ro-mmap reference TSC page
This paves way to implement VDSO for the enlightened time counter.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8768
2016-12-15 03:32:24 +00:00
Sepherosa Ziehau
de69dfbbbc hyperv: Implement "enlightened" time counter, which is rdtsc based.
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8763
2016-12-14 03:20:57 +00:00
Sepherosa Ziehau
6c1204df36 hyperv/hn: Add polling support
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8739
2016-12-12 05:18:03 +00:00
Sepherosa Ziehau
b99113a1c1 hyperv/vmbus: Add channel polling support.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8738
2016-12-12 05:04:55 +00:00
Sepherosa Ziehau
4b167c2b4d hyperv/storvsc: Minor style changes; no functional changes.
Reported by:	rpokala
MFC after:	1 week
Sponsored by:	Microsoft
2016-12-09 06:18:12 +00:00
Sepherosa Ziehau
692cb24f10 hyperv/storvsc: Fix the SCSI disk attachment issue.
On pre-WS2016 Hyper-V, if the only LUNs > 7 are used, then all disks
fails to attach.  Mainly because those versions of Hyper-V do not set
SRB_STATUS properly and deliver junky INQUERY responses.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
Reported by:	Hongxiong Xian <v-hoxian microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8724
2016-12-09 03:16:36 +00:00
Sepherosa Ziehau
096d83feb9 hyperv/timesync: Support "sent TC" to improve accuracy.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8723
2016-12-08 05:37:39 +00:00
Sepherosa Ziehau
98cb13b6cc hyperv/vmbus: Utilize vmbus_chan_run_task()
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8686
2016-12-08 05:15:00 +00:00
Sepherosa Ziehau
6dbe58e249 hyperv/vmbus: Use pause if possible.
This makes booting on Hyper-V w/ small # of vCPUs work properly.

Reported by:	Hongxiong Xian <v-hoxian microsoft com>, Hongjiang Zhang <honzhan microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft
2016-12-07 08:12:02 +00:00
Sepherosa Ziehau
34d68912be hyperv/hn: Add 'options RSS' support.
Reviewed by:	adrian
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8676
2016-12-01 05:37:29 +00:00
Sepherosa Ziehau
8e7d313625 hyperv/hn: Don't hold txdesc, if no BPFs are attached.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8675
2016-12-01 03:39:34 +00:00
Sepherosa Ziehau
85e4ae1e13 hyperv/hn: Add HN_DEBUG kernel option.
If bufring is used for per-TX ring descs, don't update "available"
counter, which is only used to help debugging.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8674
2016-12-01 03:27:16 +00:00
Sepherosa Ziehau
14c85e527e hyperv/storvsc: Don't use timedwait.
The timeout is unnecessary.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8656
2016-11-30 08:21:15 +00:00
Sepherosa Ziehau
ca567dee01 hypver/vmbus: Remove extra assertion.
It is asserted by vmbus_chan_gpadl_connect() now.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8660
2016-11-30 08:10:49 +00:00
Sepherosa Ziehau
0e11868dfa hyperv/hn: Allow TX to share event taskqueues.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8659
2016-11-30 07:54:28 +00:00
Sepherosa Ziehau
b5c7e2415e hyperv/vmbus: Add DEVMETHOD to map cpu to event taskq.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8658
2016-11-30 07:45:05 +00:00
Sepherosa Ziehau
fdd0222a04 hyperv/hn: Allow multiple TX taskqueues.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8655
2016-11-30 05:28:39 +00:00
Sepherosa Ziehau
52d8123421 hyperv/hn: Nuke the unused TX taskqueue CPU binding tunable.
It was an experimental tunable, and is now deemed to be road blocker
for further changes.  Time to retire it.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8654
2016-11-30 05:11:59 +00:00
Sepherosa Ziehau
5e61edf60e hyperv/vmbus: Use poll/cancel APIs to wait for the CHOPEN response.
Since hypervisor does not respond CHOPEN to a revoked channel.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8636
2016-11-28 07:56:03 +00:00
Sepherosa Ziehau
2ee4e46fe6 hyperv/vmbus: Add exec cancel support for message Hypercall API.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8635
2016-11-28 07:44:50 +00:00
Sepherosa Ziehau
2fb45c54a1 hyperv/vmbus: Add result polling support for message Hypercall API.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8634
2016-11-28 07:36:51 +00:00
Sepherosa Ziehau
1b34e69534 hyperv/vmbus: Add result polling support for xact API.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8633
2016-11-28 07:27:08 +00:00
Sepherosa Ziehau
6555f01eec hyperv/vmbus: Stringent GPADL parameter assertion.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8632
2016-11-28 07:04:32 +00:00
Sepherosa Ziehau
fa643a5d0a hyperv/vmbus: Make sure that the allocated GPADL is not zero.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8631
2016-11-28 06:53:00 +00:00
Sepherosa Ziehau
afd4971b7b hyperv/hn: Simplify RSS indirect table fixup API
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8630
2016-11-28 06:40:26 +00:00
Sepherosa Ziehau
aa1a2adc92 hyperv/hn: Fix vmbus_chan_subidx usage.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8629
2016-11-28 06:10:41 +00:00
Sepherosa Ziehau
fa915c4d20 hyperv/hn: Enable multi-packet RNDIS message support by default.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8621
2016-11-28 05:54:20 +00:00
Sepherosa Ziehau
71e8ac5696 hyperv/hn: Fix attach error handling
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8620
2016-11-28 05:46:00 +00:00
Sepherosa Ziehau
a4364cfea9 hyperv/hn: Fix multi-packet RNDIS message aggregation size setting.
Just in case that no chimney sending buffer can be used.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8619
2016-11-28 05:31:36 +00:00
Sepherosa Ziehau
2494d735e2 hyperv/hn: Fix detach error handling.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8613
2016-11-28 05:23:57 +00:00
Sepherosa Ziehau
f6f2e0ce38 hyperv/hn: Utilize vmbus_chan_xact_wait
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8612
2016-11-28 05:15:28 +00:00
Sepherosa Ziehau
a54152eaa5 hyperv/vmbus: Add supportive transaction wait function.
This function supports channel revocation properly.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8611
2016-11-28 05:07:48 +00:00
Sepherosa Ziehau
faaba341e5 hyperv/vmbus: Zero out GPADL if error happens.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8601
2016-11-28 04:53:36 +00:00
Sepherosa Ziehau
2641e75742 hyperv/vmbus: Add a simplified version of channel close.
So that the caller can know the channel close error and react accordingly.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8600
2016-11-25 09:13:10 +00:00
Sepherosa Ziehau
892b35bc36 hyperv/vmbus: Propagate close error.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8599
2016-11-25 08:57:52 +00:00
Sepherosa Ziehau
0743140a63 hyperv/vmbus: Always try disconnect/free bufring memory upon channel close
While I'm here, minor wording and style changes.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8598
2016-11-25 08:31:13 +00:00
Sepherosa Ziehau
f2aeeaff6f hyperv/vmbus: Don't free the bufring if its GPADL can't be disconnected.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8570
2016-11-25 07:41:42 +00:00
Sepherosa Ziehau
32ab625a61 hyperv/vmbus: Return EISCONN if the bufring GPADL can't be disconnected.
So that the callers of vmbus_chan_open_br() could handle the passed in
bufring memory properly.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8569
2016-11-25 07:24:11 +00:00
Sepherosa Ziehau
12fbfdab73 hyperv/vmbus: No stranded bufring GPADL is allowed.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8568
2016-11-25 07:03:45 +00:00
Sepherosa Ziehau
11629f1cd6 hyperv/vmbus: GPADL disconnect error on a revoked channel is benign.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8567
2016-11-25 06:48:53 +00:00
Sepherosa Ziehau
fd2b520f2f hyperv/vmbus: Don't close unopened channels.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8566
2016-11-25 06:12:18 +00:00
Sepherosa Ziehau
ba9238f89f hyperv/vmbus: Fix sysctl tree leakage, if channel open fails.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8565
2016-11-25 06:01:45 +00:00
Sepherosa Ziehau
6d147fc18b hyperv/vmbus: Minor style changes.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8564
2016-11-25 05:46:15 +00:00
Sepherosa Ziehau
eb812ea9ab hyperv/vmbus: Commit the GPADL id only after the connection succeeds.
Minor style change.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8563
2016-11-25 05:35:29 +00:00
Dexuan Cui
cdb316ee87 hyperv/vmbus,pcib: unbreak build in case NEW_PCIB is undefined
vmbus_pcib requires NEW_PCIB, but in case that's not defined, we at
least shouldn't break build.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	3 days
Sponsored by:	Microsoft
2016-11-25 04:35:40 +00:00
Sepherosa Ziehau
25641fc705 hyperv/hn: Fix primary channel revocation
Since hypervisor will not drain the TX bufring, once the channels are
revoked:
- Setup vmbus orphan handler properly.
- Make sure that suspension will not wait the TX bufring draining
  forever.
- GC the pending TX descs on detach path, before freeing the busdma
  stuffs.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8559
2016-11-24 07:35:16 +00:00
Sepherosa Ziehau
91955558f5 hyperv/vmbus: Fix the multi-channel revoking on vmbus side.
- Reference count the sub-channel when channel offer message is
  processed, so that immediate rescind message on the same channel
  will not race sub-channel open on driver side.
- Drop the above reference when sub-channel is closed, this closely
  mimics the hypervisor's reaction when primary channel is closed
  on the VM side.  No drivers use sub-channel after primary channel
  is closed.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8546
2016-11-24 06:01:29 +00:00
Sepherosa Ziehau
5ab84aaf2f hyperv/vmbus: Fix the primary channel revoking on vmbus side.
Drivers can now use vmbus_chan_{is_revoked,set_orphan,unset_orphan}() and
vmbus_xact_ctx_orphan() to fix their attach/detach DEVMETHODs for revoked
primary channels.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8545
2016-11-24 05:18:45 +00:00
Sepherosa Ziehau
494ec41ae2 hyperv/vmbus: Implement orphan support for transaction API
It will be used to fix the primary channel revocation support.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8525
2016-11-24 04:58:13 +00:00
Sepherosa Ziehau
713ff628ac hyperv/vmbus: Merge free/active locks.
These functions are only used by management stuffs, so there are
no needs to introduce extra complexity.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8524
2016-11-23 08:30:02 +00:00
Sepherosa Ziehau
fb6216bd43 hyperv/vmbus: Set a mark on the revoked channel.
This will be used to fix device detach DEVMETHOD for revoked primary
channel.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8522
2016-11-23 05:03:44 +00:00
Sepherosa Ziehau
a7ba764844 hyperv/hn: Don't abuse hn_{tx,rx}_ring_inuse.
Just in case, the # of TX/RX rings is changed upon synthetic parts
re-attach.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8520
2016-11-21 05:54:31 +00:00
Sepherosa Ziehau
7960e6ba99 hyperv/hn: Allow enabling IPv6 TX checksum offloading and IPv6 TSO.
They are still disabled by default.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8490
2016-11-21 05:41:08 +00:00
Sepherosa Ziehau
fdc4f478ed hyperv/hn: Fix WITNESS warnings
And re-enable SIOCADDMULTI/SIOCDELMULTI, after WITNESS warning is fixed.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8489
2016-11-21 05:21:15 +00:00
Sepherosa Ziehau
8f3bf5f97b hyperv/vmbus: Support transction result busy-wait.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8488
2016-11-21 05:09:43 +00:00
Sepherosa Ziehau
dc13fee60c hyperv/hn: Implement RNDIS multi-packet message support.
Currently, it is only applied to packet sent through chimney sending
buffers.  Not enabled by default yet.

This one gives 20%~30% performance boost for non-TSO usage in both
bit/packet rate tests and nginx performance test.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8560
2016-11-21 05:00:51 +00:00
Dexuan Cui
8c582c7c58 hyperv/pcib: change the file name: pcib.c -> vmbus_pcib.c
This makes the file name and the variable naming in the file consistent.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	1 week
Sponsored by:	Microsoft
2016-11-18 06:44:18 +00:00
Dexuan Cui
50182f1312 hyperv/vmbus,pcib: Add MODULE_DEPEND on pci
We'd better add this dependency explicitly, though usually the pci
driver is built into the kernel by default.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	1 week
Sponsored by:	Microsoft
2016-11-18 06:24:22 +00:00
Dexuan Cui
871c968b3a hyperv/pcib: enable PCIe pass-through (a.k.a. Discrete Device Assignment)
The feature enables us to pass through physical PCIe devices to FreeBSD VM
running on Hyper-V (Windows Server 2016) to get near-native performance with
low CPU utilization.

The patch implements a PCI bridge driver to support the feature:

1) The pcib driver talks to the host to discover device(s) and presents
the device(s) to FreeBSD's pci driver via PCI configuration space (note:
to access the configuration space, we don't use the standard I/O port
0xCF8/CFC method; instead, we use an MMIO-based method supplied by Hyper-V,
which is very similar to the 0xCF8/CFC method).

2) The pcib driver allocates resources for the device(s) and initialize
the related BARs, when the device driver's attach method is invoked;

3) The pcib driver talks to the host to create MSI/MSI-X interrupt
remapping between the guest and the host;

4) The pcib driver supports device hot add/remove.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8332
2016-11-16 09:25:00 +00:00
Dexuan Cui
522c192d38 hyperv/vmbus: add new vmbus methods to support PCIe pass-through
The new methods will be used by the coming pcib driver.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8409
2016-11-16 09:08:32 +00:00
Dexuan Cui
c8b32f717d hyperv/vmbus: add a new method to get vcpu_id
vcpu_id is host's representation of guest CPU.
We get the mapping between vcpu_id and FreeBSD kernel's cpu id when VMBus
driver is loaded. Later, when a driver, like the coming pcib driver, talks
to the host and needs to refer to a guest CPU, the driver must use the
vcpu_id.

Reviewed by:	jhb, sephe
Approved by:	sephe (mentor)
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8410
2016-11-16 09:02:17 +00:00
Sepherosa Ziehau
168fce73b5 hyperv/vss: Add driver and tools for VSS
VSS stands for "Volume Shadow Copy Service".  Unlike virtual machine
snapshot, it only takes snapshot for the virtual disks, so both
filesystem and applications have to aware of it, and cooperate the
whole VSS process.

This driver exposes two device files to the userland:

    /dev/hv_fsvss_dev

    Normally userland programs should _not_ mess with this device file.
    It is currently used by the hv_vss_daemon(8), which freezes and
    thaws the filesystem.  NOTE: currently only UFS is supported, if
    the system mounts _any_ other filesystems, the hv_vss_daemon(8)
    will veto the VSS process.

    If hv_vss_daemon(8) was disabled, then this device file must be
    opened, and proper ioctls must be issued to keep the VSS working.

    /dev/hv_appvss_dev

    Userland application can opened this device file to receive the
    VSS freeze notification, hold the VSS for a while (mainly to flush
    application data to filesystem), release the VSS process, and
    receive the VSS thaw notification i.e. applications can run again.

    The VSS will still work, even if this device file is not opened.
    However, only filesystem consistency is promised, if this device
    file is not opened or is not operated properly.

hv_vss_daemon(8) is started by devd(8) by default.  It can be disabled
by editting /etc/devd/hyperv.conf.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
Reviewed by:	kib, mckusick
MFC after:	3 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8224
2016-11-15 02:36:12 +00:00
Sepherosa Ziehau
afe30aa97f hyperv/vmbus: Reset ch_dev, once the child is deleted.
So it will not be mis-used later on, e.g. in vmbus_chan_printf().

Submitted by:	dexuan
Reported by:	dexuan
MFC after:	1 week
Sponsored by:	Microsoft
2016-11-04 01:14:41 +00:00
Sepherosa Ziehau
30c90f019f hyperv/kvp: Don't mix message status codes and function return values.
While I'm here, move message status codes to hv_utilreg.h, since they
will be used by the upcoming VSS stuffs.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8391
2016-11-02 07:18:27 +00:00
Sepherosa Ziehau
2a5a7ca81d hyperv: GC unused functions.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8406
2016-11-02 05:41:23 +00:00