Commit Graph

353 Commits

Author SHA1 Message Date
Sepherosa Ziehau
d805de567f hyperv/vmbus: Get rid of rel{_id,id}, use channel id consistently.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7100
2016-07-14 06:10:00 +00:00
Sepherosa Ziehau
5ef8204d4b hyperv/vmbus: Remove unused bits
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7095
2016-07-14 06:00:40 +00:00
Sepherosa Ziehau
f15c787ae7 hyperv/vmbus: Switch to vmbus channel message macros
Prepare for more cleanup.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7094
2016-07-14 05:49:14 +00:00
Sepherosa Ziehau
e979461031 hyperv/vmbus: Move channel offer message definition to vmbus_reg.h
- Avoid bit fields.
- Avoid unnecessary indirection.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7093
2016-07-14 05:33:33 +00:00
Sepherosa Ziehau
71ac1309f0 hyperv: hv_guid -> struct hyperv_guid.
This paves way for the further cleanup/disentangle.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7092
2016-07-14 05:25:31 +00:00
Sepherosa Ziehau
e2d8dbe438 hyperv/vmbus: Cleanup channel rescind
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7090
2016-07-13 09:44:24 +00:00
Sepherosa Ziehau
37a911a59b hyperv/vmbus: Remove unused code
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7089
2016-07-13 09:36:46 +00:00
Sepherosa Ziehau
8c8cf3f2e2 hyperv/vmbus: Reorganize MNF event sending.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7088
2016-07-13 09:28:46 +00:00
Sepherosa Ziehau
562d480b7d hyperv: Signal event input parameter is shared w/ MNF
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7087
2016-07-13 09:19:33 +00:00
Sepherosa Ziehau
a570251d00 hyperv: All Hypercall parameters have same alignment requirement.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7086
2016-07-13 09:11:03 +00:00
Sepherosa Ziehau
782b0df476 hyperv/vmbus: Install different task function for batch/non-batch channels
This avoids bunch of unnecessary checks on hot path and simplifies the
channel processing.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7085
2016-07-13 08:30:14 +00:00
Sepherosa Ziehau
817c040c3f hyperv/vmbus: Remove unnecessary callback check.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7046
2016-07-13 06:55:21 +00:00
Sepherosa Ziehau
df1021e7bf hyperv/vmbus: Pack bool field into flags field
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7038
2016-07-13 06:46:29 +00:00
Sepherosa Ziehau
7c2abef176 hyperv/bufring: Remove unused fields
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7037
2016-07-13 06:39:04 +00:00
Sepherosa Ziehau
6de616d3a0 hyperv/vmbus: Nuke unused field from hv_vmbus_channel.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7036
2016-07-13 06:30:33 +00:00
Sepherosa Ziehau
3b50b13baa hyperv: Get rid of hv_device, which is unnecessary indirection.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7034
2016-07-13 06:17:15 +00:00
Sepherosa Ziehau
47575345ba hyperv/vmbus: Deprecate the usage of hv_device.
This paves way to nuke the hv_device, which is actually an unncessary
indirection.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7032
2016-07-13 05:47:09 +00:00
Sepherosa Ziehau
edd0c2c7c7 hyperv/vmbus: Add channel ivar accessor.
This makes life easier during the transition period to nuke the hv_device.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7026
2016-07-13 05:19:45 +00:00
Sepherosa Ziehau
93637258fd hyperv/vmbus: All ivars are read-only; nuke unnecessary write_ivar
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7025
2016-07-13 05:11:45 +00:00
Sepherosa Ziehau
884d26c84c hyperv/vmbus: Add vmbus method for GUID base device probing.
Reduce the exposure of hv_device.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7024
2016-07-13 05:01:12 +00:00
Sepherosa Ziehau
abe9fa4996 hyperv/vmbus: Remove the embedded offer message from hv_vmbus_channel
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7021
2016-07-13 04:51:37 +00:00
Sepherosa Ziehau
5c604feb67 hyperv/vmbus: Add type/instance guid fields into hv_vmbus_channel
This prepares to remove the unnecessary offer message embedding in
hv_vmbus_channel.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7020
2016-07-13 04:39:16 +00:00
Sepherosa Ziehau
d74e22ed4a hyperv/vmbus: Add flags field into hv_vmbus_channel for MNF indication
This prepares to remove the unnecessary offer message embedding in
hv_vmbus_channel.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7019
2016-07-13 04:31:08 +00:00
Sepherosa Ziehau
4ac0a9bf1e hyperv/vmbus: Make subchan index a field of hv_vmbus_channel.
This prepares to remove the unnecessary offer message embedding in
hv_vmbus_channel.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7015
2016-07-13 03:35:22 +00:00
Sepherosa Ziehau
2c4888c75b hyperv/vmbus: Make channel id a field of hv_vmbus_channel.
This prepares to remove the unnecessary offer message embedding in
hv_vmbus_channel.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7014
2016-07-13 03:24:29 +00:00
Sepherosa Ziehau
e71d17193d hyperv/vmbus: Merge hv_connection.c into hv_channel.c
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7004
2016-07-13 03:14:29 +00:00
Sepherosa Ziehau
283ec9df45 hyperv/vmbus: Destroy channel list lock upon attach failure and detach.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7003
2016-07-12 09:06:25 +00:00
Sepherosa Ziehau
250ca4ca3b hyperv/vmbus: Remove needed bits
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7002
2016-07-12 08:55:08 +00:00
Sepherosa Ziehau
af3be0bfa5 hyperv/vmbus: Move channel map to vmbus_softc
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6982
2016-07-12 08:47:04 +00:00
Sepherosa Ziehau
99e315276a hyperv/vmbus: Fix sub-channel re-open support.
For multi-channel devices, once the primary channel is closed,
a set of 'rescind' messages for sub-channels will be delivered
by Hypervisor.  Sub-channel MUST be freed according to these
'rescind' messages; directly re-openning sub-channels in the
same fashion as the primary channel's re-opening does NOT work
at all.

After the primary channel is re-opened, requested # of sub-
channels will be delivered though 'channel offer' messages, and
this set of newly offered channels can be opened along side with
the primary channel.

This unbreaks the MTU setting for hn(4), which requires re-
openning all existsing channels upon MTU change.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6978
2016-07-12 08:38:03 +00:00
Sepherosa Ziehau
81e1f05268 hyperv/vmbus: Free sysctl properly upon channel close.
Prepare for sub-channel re-open.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6977
2016-07-12 08:28:51 +00:00
Sepherosa Ziehau
3dee05577d hyperv/vmbus: More verbose for GPADL_connect/chan_{rescind,offer}
Reviewed by:	Dexuan Cui <decui microsoft com>, Hongjiang Zhang <honzhan microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6976
2016-07-12 08:21:28 +00:00
Sepherosa Ziehau
7fbf073008 hyperv/vmbus: Move channel list to vmbus_softc
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6956
2016-07-12 08:11:16 +00:00
Sepherosa Ziehau
ee7e313f03 hyperv/vmbus: Move GPADL index into vmbus_softc
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6954
2016-07-12 07:49:38 +00:00
Sepherosa Ziehau
38d19df6ff hyperv/vmbus: Rework vmbus version accessing.
Instead of global variable, vmbus version is accessed through
a vmbus DEVMETHOD now.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6953
2016-07-12 07:33:39 +00:00
Sepherosa Ziehau
f24517f037 hyperv/vmbus: Minor renaming
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6919
2016-07-12 05:55:11 +00:00
Sepherosa Ziehau
9e6efea698 hyperv/vmbus: Don't be oversmart in default cpu selection.
Pin the channel to cpu0 by default.  Drivers having special channel-cpu
mapping requirement should call vmbus_channel_cpu_{set,rr}() themselves.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6918
2016-07-12 05:31:33 +00:00
Sepherosa Ziehau
fc7ddc1e23 hyperv: Nuke unused stuffs
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6917
2016-07-12 05:23:14 +00:00
Sepherosa Ziehau
e44bdd84c9 hyperv/vmbus: Busdma-fy Hypercall signal event input parameter.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6916
2016-07-12 05:09:07 +00:00
Sepherosa Ziehau
44d03f9a5f hyperv/vmbus: Avoid tx_evtflags setting code duplication.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6915
2016-07-12 04:58:21 +00:00
Sepherosa Ziehau
88d2677299 hyperv/vmbus: Flatten channel message response processing.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6914
2016-07-12 04:35:32 +00:00
Sepherosa Ziehau
1f175550a0 hyperv: Nuke unused stuffs
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6913
2016-07-12 03:38:29 +00:00
Sepherosa Ziehau
e90ec741f9 hyperv/vmbus: Use post message Hypercall APIs for GPA disconnect
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6912
2016-07-12 03:32:07 +00:00
Sepherosa Ziehau
e9bd7c4417 hyperv/vmbus: Use post message Hypercall APIs for channel close
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6906
2016-07-12 03:25:36 +00:00
Sepherosa Ziehau
2bf62f9a89 hyperv/vmbus: Use post message Hypercall APIs for GPADL connect.
This also fixes memory leakge if sub-connect messages are needed.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6878
2016-07-12 03:19:40 +00:00
Sepherosa Ziehau
df9f40d810 hyperv/vmbus: Remove unnecessary check and unapplied comment
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6877
2016-07-12 03:14:35 +00:00
Sepherosa Ziehau
fc1208d658 hyperv/vmbus: Use post message Hypercall APIs for channel open
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6876
2016-07-12 03:09:10 +00:00
Sepherosa Ziehau
796a90bf5d hyperv/vmbus: Reorganize vmbus scan process.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6875
2016-07-12 03:03:17 +00:00
Sepherosa Ziehau
60169cb210 hyperv/vmbus: Embed channel detach task in channel itself.
GC work queue stuffs.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6864
2016-07-11 08:12:04 +00:00
Sepherosa Ziehau
3e1c325e63 hyperv/vmbus: Save vmbus softc to channels.
So that we don't need to access the global vmbus softc.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6863
2016-07-11 07:54:58 +00:00
Sepherosa Ziehau
fd5831c624 hyperv/vmbus: Create channel synchronously.
The device probe/attach has been move to a different thread, so the
reasons to create the channel asynchronously are no longer valid.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6862
2016-07-11 07:45:31 +00:00
Sepherosa Ziehau
1ecb24660f hyperv/vmbus: Use post message Hypercall APIs for unload
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6861
2016-07-11 07:28:15 +00:00
Sepherosa Ziehau
47a3ee5c60 hyperv/vmbus: Add sysctl to expose vmbus version.
Requested by:	Hongxiong Xian <v-hoxian microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6860
2016-07-11 06:55:02 +00:00
Sepherosa Ziehau
833cfa5fcb hyperv/vmbus: Explicitly assign channel message process array.
While I'm here, remove the useless message type from message process
array, which is not used and serves no purposes at all.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6858
2016-07-11 06:37:04 +00:00
Sepherosa Ziehau
dd012a57a7 hyperv/vmbus: Function renaming.
And pass vmbus_softc to vmbus_doattach()

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6842
2016-07-11 06:29:56 +00:00
Sepherosa Ziehau
c1cc5bdfe8 hyperv/vmbus: Use post message Hypercall APIs for channel request
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6831
2016-07-11 06:11:24 +00:00
Sepherosa Ziehau
236764b1c2 hyperv/vmbus: Implement a new set of APIs for post message Hypercall
And use this new APIs for Initial Contact post message Hypercall.
More post message Hypercalls will be converted.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6830
2016-07-11 04:52:11 +00:00
Sepherosa Ziehau
51a9a000ee hyperv/vmbus: Change tx_evtflags type to u_long to match vmbus_evtflags
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6745
2016-06-08 07:47:21 +00:00
Sepherosa Ziehau
6523ab7e00 hyperv/vmbus: Busdma-fy MNF and event flags.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6744
2016-06-08 05:34:22 +00:00
Sepherosa Ziehau
43926ba13f hyperv/vmbus: Constify channel message
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6708
2016-06-06 07:39:44 +00:00
Sepherosa Ziehau
12ea25ae4f hyperv/vmbus: Factor out channel message processing
This paves the way for further cleanup.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6707
2016-06-06 07:27:57 +00:00
Sepherosa Ziehau
fa4828b0ab hyperv/vmbus: Define type for channel messages.
And fix message processing; only channel messages are supported.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6706
2016-06-06 06:18:18 +00:00
Sepherosa Ziehau
d8bf51683d hyperv: Move machine dependent bits into machine dependent files.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6701
2016-06-06 05:55:37 +00:00
Sepherosa Ziehau
b7bb4816a0 hyperv: Rename some cleaned up/almost cleaned up files
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-06-01 09:20:52 +00:00
Sepherosa Ziehau
5d8fdc7fe4 hyperv/channel: Only cpu0 is supported as channel target cpu on WIN7
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-06-01 07:11:54 +00:00
Sepherosa Ziehau
417afb00cb hyperv/vmbus: Redefine event flags.
- Nuke unnecessary union.
- Avoid convoluted macro indirection.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6671
2016-06-01 06:51:44 +00:00
Sepherosa Ziehau
7df850a759 hyperv: Move guid2str from vmbus file to hyperv file
- Use uint8_t for GUID byte array.
- Define GUID string length.
- Break long lines.
- Nuke unnecessary stack variable.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6640
2016-05-31 05:43:59 +00:00
Sepherosa Ziehau
b8ec7cd1e0 hyperv/vmbus: White space cleanup
No functional changes

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6637
2016-05-31 05:34:46 +00:00
Sepherosa Ziehau
3ae6d31281 hyperv/vmbus: Redefine SynIC message.
- Avoid unnecessary indirection.
- Avoid bit fields.
- Use __packed.

Reviewed by:	Jun Su <junsu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6636
2016-05-31 05:18:55 +00:00
Sepherosa Ziehau
3b2f526463 hyperv/vmbus: Move global vmbus id array to stack.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6603
2016-05-31 05:10:20 +00:00
Sepherosa Ziehau
e4a8553128 hyperv/vmbus: Indentation cleanup
No functional changes.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6602
2016-05-31 05:01:43 +00:00
Sepherosa Ziehau
98a68947d4 hyperv/vmbus: Rename ISR functions
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6601
2016-05-31 04:47:53 +00:00
Sepherosa Ziehau
387d355588 hyperv/vmbus: Process event timer before checking events
And update comment.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6600
2016-05-31 04:10:15 +00:00
Sepherosa Ziehau
496d023db3 hyperv/et: Allow Hyper-V event timer be disabled
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6599
2016-05-30 09:44:17 +00:00
Sepherosa Ziehau
6072b2511c hyperv/et: Device renaming; consistent w/ other Hyper-V utils
While I'm here, prefix function names w/ vmbus, since unlike Hyper-V
timecounter, Hyper-V event timer will not work w/o vmbus.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6598
2016-05-30 09:35:36 +00:00
Sepherosa Ziehau
3f07976a64 hyperv: Move timer frequency definition to common place.
And cleanup event timer period settings.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6597
2016-05-30 09:20:08 +00:00
Sepherosa Ziehau
efe8791a64 hyperv/et: Make sure only one event timer will be registered
This nullifies the need to use softc.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6591
2016-05-30 08:50:33 +00:00
Sepherosa Ziehau
430d28dbb3 hyperv/vmbus: Move SINT settings to vmbus_var.h
While I'm here remove the event timer's dependency on hv_vmbus_priv.h

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6574
2016-05-30 08:42:35 +00:00
Sepherosa Ziehau
d7bc16443e hyperv/et: Fix STIMER0 operations.
- Make sure that STIMER0 is disabled before writting to it, since
  writing to an enabled STIMER will result in undefined behaviour.
- It is unnecessary to reconfigure STIMER0 upon each et_start().
- Make sure that MSR_HV_REF_TIME_COUNT will not return 0, since
  writing 0 to STIMER_COUNT will disable the target STIMER.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6573
2016-05-30 08:25:09 +00:00
Sepherosa Ziehau
5cb904dc2f hyperv: Test features before enabling optional functionalities
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6571
2016-05-27 07:29:31 +00:00
Sepherosa Ziehau
7da9c32e83 hyperv: Clean up Hyper-V timecounter a bit.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6569
2016-05-27 07:05:30 +00:00
Sepherosa Ziehau
62eb6e21b6 hyperv: GC unneeded bits
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6568
2016-05-27 06:55:05 +00:00
Sepherosa Ziehau
e3ebe93016 hyperv/vmbus: Move MSR EOM to hyperv_reg.h
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6567
2016-05-27 06:47:04 +00:00
Sepherosa Ziehau
a4574fd680 hyperv: Move timer related MSRs into hyperv_reg.h
And avoid bit fields for event timer.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6566
2016-05-27 06:12:43 +00:00
Sepherosa Ziehau
a8362fc737 hyperv: Move CPUID related bits to hyperv_reg.h and give them clean name
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6565
2016-05-27 05:58:53 +00:00
Sepherosa Ziehau
2b0bce640b hyperv: Rework guest id settings according to Hyper-V spec
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6553
2016-05-26 03:50:52 +00:00
Sepherosa Ziehau
dade2a02e3 hyperv: Preserve required bits when disable Hypercall
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6530
2016-05-25 06:01:47 +00:00
Sepherosa Ziehau
6d6baea80d hyperv/vmbus: Rework SynIC setup and teardown
- Avoid bit fields.
- Fix SINT setup (preserve required bits).

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6529
2016-05-25 05:53:12 +00:00
Sepherosa Ziehau
c1d5ebc5a4 hyperv/vmbus: Nuke unnecessary MSR read
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6528
2016-05-25 05:45:43 +00:00
Sepherosa Ziehau
8239b2f287 hyperv/vmbus: Pass vmbus softc to vmbus_synic_setup
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6527
2016-05-25 05:37:42 +00:00
Sepherosa Ziehau
c4592280be hyperv/vmbus: Minor style and white space cleanup
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6523
2016-05-25 05:30:48 +00:00
Sepherosa Ziehau
20bce8fa9f hyperv/vmbus: Move two global flags into vmbus softc
And pack them into one flag field.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6522
2016-05-25 05:22:35 +00:00
Sepherosa Ziehau
14aa3e8097 hyperv/vmbus: Move vcpuid into vmbus softc per-cpu data
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6521
2016-05-25 05:06:15 +00:00
Sepherosa Ziehau
95a45414a0 hyperv/vmbus: Move event/message taskqueue/task to vmbus softc
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6520
2016-05-25 04:59:20 +00:00
Sepherosa Ziehau
bd5465a441 hyperv/vmbus: Allocate/setup IDT vector after all ISR resources are ready
And release IDT vector before releasing ISR resources on interrupt
teardown path.  We still have some work to do on the interrupt tearing
down path.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6519
2016-05-25 03:39:42 +00:00
Sepherosa Ziehau
01ac237df2 hyperv/vmbus: Check hyperv_dmamem_alloc return value
Though it is highly unlikely this function would fail w/ BUS_DMA_WAITOK,
we had better to check its return value; better safe then sorry here.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6518
2016-05-25 03:30:56 +00:00
Sepherosa Ziehau
8982969f05 hyperv/vmbus: Free message taskqueue during interrupt teardown
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6506
2016-05-24 07:07:11 +00:00
Sepherosa Ziehau
b28956a456 hyperv/vmbus: Factor out functions for vmbus interrupt set/teardown
This paves way for further cleanup and fix.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6505
2016-05-24 06:42:14 +00:00
Sepherosa Ziehau
bcc9e3e995 hyperv/vmbus: Git rid of sc version of pcpu data extraction macro
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6503
2016-05-24 06:10:21 +00:00
Sepherosa Ziehau
0408d8b80a hyperv/vmbus: Use busdma(9) for messages and event flags
And
- Move message and event flags to vmbus_softc per-cpu data.
- Get rid of hv_setup_arg, which serves no purpose now.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6502
2016-05-24 06:01:39 +00:00
Sepherosa Ziehau
fc2d20095c hyperv/vmbus: Move SynIC setup/teardown from hyperv file to vmbus file
Avoid unnecessary exposure.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6501
2016-05-24 05:51:51 +00:00
Sepherosa Ziehau
5c8e70d86c hyperv/vmbus: Rename local variable and break long lines
No functional changes.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6500
2016-05-24 05:43:55 +00:00
Sepherosa Ziehau
d8313c45a6 hyperv/busdma: Take BUS_DMA_ZERO into account
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6499
2016-05-24 05:26:52 +00:00
Sepherosa Ziehau
86931e66f6 hyperv/vmbus: Pass vmbus_softc and curcpu to hv_vmbus_isr()
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6498
2016-05-24 05:18:26 +00:00
Sepherosa Ziehau
a995872175 hyperv/vmbus: Move vmbus interrupt counter into vmbus softc
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6497
2016-05-24 05:06:01 +00:00
Sepherosa Ziehau
fc4d679fd7 hyperv/vmbus: Move IDT vector to vmbus_softc
Prepare to get rid of the hv_setup_arg.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6449
2016-05-23 07:32:34 +00:00
Sepherosa Ziehau
e2468dfeff hyperv/vmbus: Get rid of vmbus_devp
While I'm here, nuke useless print in vmbus_attach().

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6447
2016-05-23 07:23:19 +00:00
Sepherosa Ziehau
c4b78721e3 hyperv/vmbus: Declare Synic message and event w/ proper types
Avoid ugly casts.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6446
2016-05-23 07:14:04 +00:00
Sepherosa Ziehau
ae39ebd8df hyperv: Move Hypercall setup to an early place.
It does not belong to the vmbus.

While I'm here rework the Hypercall setup, e.g. use busdma(9)
and avoid bit fields.

Discussed with:	Jun Su <junsu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6445
2016-05-23 07:06:53 +00:00
Sepherosa Ziehau
7e118515ca hyperv: Add helpers for busdma(9) operation
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6443
2016-05-23 06:35:11 +00:00
Sepherosa Ziehau
b9f1312664 hyperv: Move guest id setup to early place
And
- Rework the guest id composition.
- Nuke useless saved guest_id.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6430
2016-05-23 05:11:38 +00:00
Sepherosa Ziehau
a2dc39b5e6 hyperv/vmbus: Use consistent device description as other devices
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6418
2016-05-18 07:18:11 +00:00
Sepherosa Ziehau
4910efc98e hyperv/vmbus: Minor function definition style fixup
Reviewed by:	Jun Su <junsu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6417
2016-05-18 07:09:44 +00:00
Sepherosa Ziehau
50b2a96140 hyperv/vmbus: Fix SYSINIT function prototype and usage.
Reviewed by:	Jun Su <junsu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6416
2016-05-18 07:01:32 +00:00
Sepherosa Ziehau
6279cdb1fb hyperv/vmbus: Reindent and cleanup devmethods.
While I'm here, use DEVMETHOD_END.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6415
2016-05-18 06:52:20 +00:00
Sepherosa Ziehau
1c21090e08 hyperv/vmbus: Staticize vmbus_devclass
Reviewed by:	Jun Su <junsu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6414
2016-05-18 06:43:15 +00:00
Sepherosa Ziehau
27ba130d14 hyperv: Set vm_guest to VM_GUEST_VM, if hypervisor is not Hyper-V
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6412
2016-05-18 06:36:28 +00:00
Sepherosa Ziehau
9627a270d2 hyperv/vmbus: Nuke unnecessary function indirection
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6411
2016-05-18 06:29:03 +00:00
Sepherosa Ziehau
fee8b5f96d hyperv/vmbus: Remove useless modevent handler
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6410
2016-05-18 06:19:22 +00:00
Sepherosa Ziehau
679afe0d78 hyperv/vmbus: Function renaming vmbus_msg_swintr -> vmbus_msg_task
It is not an SWI handler for a long time.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6409
2016-05-18 04:04:14 +00:00
Sepherosa Ziehau
a5dcd30f69 hyperv/vmbus: Utilize curcpu
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6408
2016-05-18 03:58:04 +00:00
Sepherosa Ziehau
f9ce274675 hyperv/vmbus: Minor white space and style cleanup
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6407
2016-05-18 03:50:18 +00:00
Sepherosa Ziehau
646995bdda hyperv/vmbus: Avoid two unnecessary protocol checks on isr handling path
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6405
2016-05-18 03:41:37 +00:00
Sepherosa Ziehau
632da4eb89 hyperv/vmbus: Use atomic swap and flsl to process event flags
Greatly reduce the locked instructions and reduce number of inner loops.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6404
2016-05-18 03:28:51 +00:00
Sepherosa Ziehau
008024f2b8 hyperv/vmbus: Reduce the # of event loops by recording event flag count
Use vmbus softc to save vmbus per-cpu data.  More stuffs will be moved
into vmbus softc.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6403
2016-05-18 03:19:53 +00:00
Sepherosa Ziehau
8080722aee hyperv/vmbus: Use unsigned long for event bits.
And move base channel id calculation out of inner loop.  This prepares
for more event processing optimization.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6384
2016-05-18 02:59:46 +00:00
Sepherosa Ziehau
81ccfbbc2e hyperv/vmbus: Use atomic_testandclear
Prepare to use unsigned long for event channel bit array.

Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6382
2016-05-16 08:50:32 +00:00
Sepherosa Ziehau
b3e348206c hyperv/vmbus: Fix event processing loop indentation.
No functional changes.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6334
2016-05-16 04:03:52 +00:00
Sepherosa Ziehau
2a616fdcda hyperv/vmbus: Simplify event processing
For channel0, it will never be processed on event handling path,
so there is no need to install it.  After skipping in the channel0
installation, we could discard the channel0 check on event
handling hot code path.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6333
2016-05-16 03:56:24 +00:00
Sepherosa Ziehau
2afc04024e hyperv/vmbus: Simplify event processing
While I'm here, remove useless comment and unnecessary return.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6332
2016-05-16 03:48:00 +00:00
John Baldwin
fdce57a042 Add an EARLY_AP_STARTUP option to start APs earlier during boot.
Currently, Application Processors (non-boot CPUs) are started by
MD code at SI_SUB_CPU, but they are kept waiting in a "pen" until
SI_SUB_SMP at which point they are released to run kernel threads.
SI_SUB_SMP is one of the last SYSINIT levels, so APs don't enter
the scheduler and start running threads until fairly late in the
boot.

This change moves SI_SUB_SMP up to just before software interrupt
threads are created allowing the APs to start executing kernel
threads much sooner (before any devices are probed).  This allows
several initialization routines that need to perform initialization
on all CPUs to now perform that initialization in one step rather
than having to defer the AP initialization to a second SYSINIT run
at SI_SUB_SMP.  It also permits all CPUs to be available for
handling interrupts before any devices are probed.

This last feature fixes a problem on with interrupt vector exhaustion.
Specifically, in the old model all device interrupts were routed
onto the boot CPU during boot.  Later after the APs were released at
SI_SUB_SMP, interrupts were redistributed across all CPUs.

However, several drivers for multiqueue hardware allocate N interrupts
per CPU in the system.  In a system with many CPUs, just a few drivers
doing this could exhaust the available pool of interrupt vectors on
the boot CPU as each driver was allocating N * mp_ncpu vectors on the
boot CPU.  Now, drivers will allocate interrupts on their desired CPUs
during boot meaning that only N interrupts are allocated from the boot
CPU instead of N * mp_ncpu.

Some other bits of code can also be simplified as smp_started is
now true much earlier and will now always be true for these bits of
code.  This removes the need to treat the single-CPU boot environment
as a special case.

As a transition aid, the new behavior is available under a new kernel
option (EARLY_AP_STARTUP).  This will allow the option to be turned off
if need be during initial testing.  I plan to enable this on x86 by
default in a followup commit in the next few days and to have all
platforms moved over before 11.0.  Once the transition is complete,
the option will be removed along with the !EARLY_AP_STARTUP code.

These changes have only been tested on x86.  Other platform maintainers
are encouraged to port their architectures over as well.  The main
things to check for are any uses of smp_started in MD code that can be
simplified and SI_SUB_SMP SYSINITs in MD code that can be removed in
the EARLY_AP_STARTUP case (e.g. the interrupt shuffling).

PR:		kern/199321
Reviewed by:	markj, gnn, kib
Sponsored by:	Netflix
2016-05-14 18:22:52 +00:00
Sepherosa Ziehau
677d0d5076 hyperv/vmbus: Mark sysctls MPSAFE
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-27 05:45:14 +00:00
Sepherosa Ziehau
96a8c456f1 hyperv/channel: Git rid of the sub-channel creation callback
It is no longer used.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-26 05:21:27 +00:00
Sepherosa Ziehau
480805ab13 hyperv/channel: Add functions to synchronize sub-channel offers
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-25 09:00:06 +00:00
Sepherosa Ziehau
b9dfafffcd hyperv/channel: Log a warning about duplicated primary channel offer
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-25 05:58:32 +00:00
Sepherosa Ziehau
d4135e865c hyperv/channel: Remove unapplied comment
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-25 05:46:44 +00:00
Sepherosa Ziehau
a37ec104c5 hyperv/channel: Minor style changes; no functional changes.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-25 05:30:42 +00:00
Sepherosa Ziehau
84e83c0abd hyperv/channel: Remove the unnecessary 'new' flag
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-25 05:22:35 +00:00
Sepherosa Ziehau
625dc68a9e hyperv/et: Strip extra white space in function name
Reported by:	Sascha Wildner <saw online de>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-25 04:58:14 +00:00
Sepherosa Ziehau
d1c801bbf1 hyperv/et: Make Hyper-V event timer a device.
Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	sephe, Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5957
2016-04-22 05:15:59 +00:00
Sepherosa Ziehau
7cd9b96b7a hyperv: Update copyright to 2016 for the files Microsoft changed in 2016
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6039
2016-04-22 05:01:43 +00:00
Sepherosa Ziehau
adc9edf341 hyperv/vmbus: Make device probe/attach synchronous w/ vmbus attach/SYSINIT
Discussed with:	Jun Su <junsu microsoft com>, Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-19 09:42:48 +00:00
Sepherosa Ziehau
55a1cfa16b hyperv: Remove two assign-only local variables
Submitted by:	Jun Su <junsu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-19 09:25:56 +00:00
Sepherosa Ziehau
4a060c8407 hyperv/vmbus: Put multi-channel offer logging under bootverbose
Suggested by:	Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-15 07:48:41 +00:00
Sepherosa Ziehau
0c29fe6db8 hyperv: Deprecate HYPERV option by moving Hyper-V IDT vector into vmbus
Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	jhb, kib, sephe
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5910
2016-04-15 02:20:18 +00:00
Sepherosa Ziehau
1859e4178b hyperv/vmbus: Merge duplicated version check for events
Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	sephe
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5911
2016-04-13 03:45:39 +00:00
Sepherosa Ziehau
3d861d81b9 hyperv: Replace 0 w/ NULL
Submitted by:	pfg
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-12 02:01:16 +00:00
Sepherosa Ziehau
9859c43dfe hyperv: Typo
Noticed by:	kib
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 09:52:24 +00:00
Sepherosa Ziehau
083b2c353d hyperv: Define macro for Hyper-V interface
Suggested by:	rpokala
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 06:22:26 +00:00
Sepherosa Ziehau
29b7b56766 hyperv: Print more features
And add comment about the MSR features.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 06:15:40 +00:00
Sepherosa Ziehau
3f2b057e35 hyperv: Break long line
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 04:56:23 +00:00
Sepherosa Ziehau
e4276edca5 hyperv: Declare hyperv_{features,recommends} properly
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 04:49:21 +00:00
Sepherosa Ziehau
c8d7fb6a5c hyperv: Resurrect r297481
This time we make sure that the TIME_REF_COUNT MSR exists.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	sephe, Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 03:36:07 +00:00
Sepherosa Ziehau
68247c05c2 hyperv: Identify Hyper-V features and recommends properly
Features bits will be used to detect devices, e.g. timers, which
do not have corresponding event channels.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	sephe, Dexuan Cui <decui microsoft com>
Rearranged by:	sephe
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 03:28:17 +00:00
Sepherosa Ziehau
e69fbdcbdf hyperv/vmbus: Get rid of max_leaf detection; this is actually not used.
It will be replaced by a new one.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 03:14:28 +00:00
Sepherosa Ziehau
2924c4efeb hyperv/vmbus: Nuke unused function
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-11 03:07:35 +00:00
Sepherosa Ziehau
222c454d33 hyperv: Revert r297481
Use vm_guest == VM_GUEST_HV is not enough to determine whether FreeBSD
is running on Hyper-V or not.  What a mess.

Reported by:	smokehydration tutanota com
Sponsored by:	Microsoft OSTC
2016-04-08 09:20:46 +00:00
Sepherosa Ziehau
e43d20993a hyperv: Use lapic_{alloc,free}_ipi to allocate private interrupt vector
Suggested by:	jhb
Reviewed by:	Dexuan Cui <decui microsoft com>, Jun Su <junsu microsoft com>
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5850
2016-04-07 07:12:57 +00:00
Sepherosa Ziehau
a121087069 hyperv: Typo in r297634
Noticed by:	hiren
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-04-07 05:56:22 +00:00
Sepherosa Ziehau
aec810d4c5 hyperv/vmbus: Use default mtx for channel message queue
First of all sema_post() can't be called w/ spinlock, and the channel
message queue processing is not on hot code path, i.e. spinlock is not
necessary.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	sephe, Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5812
2016-04-07 05:45:49 +00:00
Sepherosa Ziehau
d8258c4498 hyperv: Use mb() instead of atomic_thread_fence_seq_cst()
Since atomic_thread_fence_seq_cst() will become compiler fence on UP kernel.

Reviewed by:	kib, Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5852
2016-04-07 05:31:22 +00:00
Sepherosa Ziehau
04c247a1d0 hyperv: Register Hyper-V timer early enough for TSC freq calibration
The i8254 simulation in Hyper-V is kinda broken and is not available
in Generation 2 Hyper-V VMs, so Hyper-V timer must be registered early
enough so that it can be used to do the TSC freq calibration.

This fixes the notorious warning like this:
calcru: runtime went backwards from 50 usec to 25 usec for pid 0 (kernel)

Submitted by:	Dexuan Cui <decui microsoft com>
Reviewed by:	kib, sephe
Tested by:	kib, sephe
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5778
2016-04-01 06:17:57 +00:00
Sepherosa Ziehau
4793a1da1c hyperv/vmbus: Create per-cpu fast taskqueue for msg handling
Using one taskqueue does not work, since the EOM MSR must be written
on the msg's owner CPU.

Noticed by:	Jun Su <junsu microsoft com>
Discussed with:	Jun Su <junsu microsoft com>, Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-03-24 02:15:23 +00:00
Sepherosa Ziehau
25a40f12b0 hyperv/vmbus: use a better retry method in hv_vmbus_post_message()
Most often, hv_vmbus_post_message() doesn't fail.  However, it fails
intermittently when GPADLs of large shared memory is to be established
with the host, e.g. on the hn(4) attach path: a GPADL of 15MB sendbuf
is created, for which lots of messages will be flooded to the host.
The host side tries to throttle the message rate by returning
HV_STATUS_INSUFFICIENT_BUFFERS.

Before this commit, we do several retries for failed messages, but the
delay between each retry is pretty/too low, which will cause sporadic
message posting failure.  We now use large delay (>=1ms) between each
retry to fix the message posting failure.

Submitted by:	Dexuan Cui <decui microsoft com>
Reviewed by:	sephe
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5715
2016-03-24 00:40:41 +00:00
Sepherosa Ziehau
1f0dfd9918 hyperv/vmbus: Remove NULL check for taskqueue_create_fast(M_WAITOK)
Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	Dexuan Cui <decui microsoft com>, sephe
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5215
2016-03-22 06:23:09 +00:00
Sepherosa Ziehau
595a21e69e hyperv/vmbus: Use taskqueue_fast for non-performance critical messages
This gets rid of the per-cpu SWIs.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	Dexuan Cui <decui microsoft com>, sephe
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5215
2016-03-22 06:13:27 +00:00
Sepherosa Ziehau
1948628a54 hyperv/evttimer: Use an independent message slot so that it can work
Using the same message slot as the other types of the messages has
the side effect that the event timer message could be deferred to
the swi threads to run (lacking of trapframe and the original code
didn't even handle that, so the event timer was actually broken).

As of this commit we use an independent message slot for event timer,
so that we could handle all of event timer messages in the interrupt
handler directly.  Note, the message slot for event timer is still
bind to the same interrupt vector as the other types of messages.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	sephe
Discussed with: Jun Su <junsu microsoft com>, Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5696
2016-03-22 05:48:51 +00:00
Sepherosa Ziehau
b6ba8b778a hyperv/vmbus: Implement bus_child_pnpinfo_str method
Submitted by:	Jun Su <junsu microsoft com>
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5669
2016-03-21 07:16:30 +00:00
Sepherosa Ziehau
57a339543d hyperv: Factor out snprinf_hv_guid()
Submitted by:	Ju Sun <junsu microsoft com>
Reviewed by:	Dexuan Cui <decui microsoft com>, sephe
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5651
2016-03-21 06:54:21 +00:00
Sepherosa Ziehau
21640df213 hyperv/hn: Add multiple channel support, a.k.a. vRSS
Each channel contains one RX ring and one TX ring.  And we
try to distribute the channels to different evenly.

Note: Currently we don't have enough information to extract
the RSS type and RSS hash value from the received packets.

This greatly improves the TX/RX performance for 8 virtual CPU
Hyper-V over 10Ge: it can max out 10Ge for TCP when multiple
RX/TX rings are enabled.

This almost doubles the TX/RX performance for locally connected
Hyper-Vs: was 6Gbps w/ 128 TCP streams, now 11Gbps w/ multiple
RX/TX rings enabled.

It is not enabled by default; it will be switched on after more
tests.

Collaborated with:	Hongjiang Zhang <honzhan microsoft com>
MFC after:	2 week
Sponsored by:	Microsoft OSTC
2016-03-04 06:52:11 +00:00
Sepherosa Ziehau
9e5c6042f9 hyperv/chan: Factor out the vcpu setting
And use it for cpu0 assignment; it does not sound right to assume that
cpu0 maps to vcpu0.  And this factored out function will be exposed to
drivers, if driver specific CPU binding is needed, e.g. hn(4).

Move default cpu select after saving channel offer message. This makes
sure that all useful information of the channel has been setup.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5504
2016-03-02 01:40:47 +00:00
Sepherosa Ziehau
990aae810b hyperv/chan: Function renaming; no functional change
The renamed function create a sysctl tree for channel, and many
non-statistics nodes exists, so don't claim it only adds sysctl
nodes for statistics.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5503
2016-03-02 01:33:30 +00:00
Sepherosa Ziehau
87d697796a hyperv/chan: Add sysctl node to check whether monitor is allocated or not
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5502
2016-03-02 01:26:05 +00:00
John Baldwin
cbc4d2db75 Remove taskqueue_enqueue_fast().
taskqueue_enqueue() was changed to support both fast and non-fast
taskqueues 10 years ago in r154167.  It has been a compat shim ever
since.  It's time for the compat shim to go.

Submitted by:	Howard Su <howard0su@gmail.com>
Reviewed by:	sephe
Differential Revision:	https://reviews.freebsd.org/D5131
2016-03-01 17:47:32 +00:00
Sepherosa Ziehau
b431335d25 hyperv/channel: Nuke useless stack variable
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5499
2016-03-01 05:15:26 +00:00
Sepherosa Ziehau
6512e69278 hyperv/channel: Add sysctl node for channel owner cpu
And add sysctl node for sub-channel's channel id.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5489
2016-02-29 09:14:55 +00:00
Sepherosa Ziehau
77394b18ab hyperv/channel: Add debug sysctl nodes for channel indices
It would serve as a debug tool, if the shared buffer ring's indices
stopped updating.

Submitted by:	HongJiang Zhang <honzhan microsoft com>
Reviewed by:	sephe, Jun Su <junsu microsoft com>
Modified by:	sephe
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5402
2016-02-29 05:24:29 +00:00
Sepherosa Ziehau
5fa2e9dd39 hyperv: Use proper fence function to keep store-load order for msgs
sfence only makes sure about the store-store order, which is not
sufficient here.  Use atomic_thread_fence_seq_cst() as suggested
jhb and kib (a locked op in the nutshell, which should have the

Reviewed by:	jhb, kib, Jun Su <junsu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5436
2016-02-29 04:58:40 +00:00
Sepherosa Ziehau
b96a7ad189 hyperv: Always set device for channels
And unregister hv_device only for primary channels, who own the hv_device.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5451
2016-02-26 09:23:17 +00:00
Sepherosa Ziehau
a14df6ad64 hyperv: Remove useless channel inbound_lock
It serves no purpose.

Reviewed by:	Hongjiang Zhang <honzhan microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5450
2016-02-26 09:17:31 +00:00
Sepherosa Ziehau
9021e53b29 hyperv: Use atomic_fetchadd_int to get GPADL id.
Reviewed by:	Hongjiang Zhang <honzhan microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5439
2016-02-26 02:26:19 +00:00
Sepherosa Ziehau
f7d33dfef2 hyperv: Wait 5 seconds for hyperv result, instead of 500ms
This addresses various devices (network, stoarge) attach failure.

Reported by:	Hongxiong Xian <v-hoxian microsoft com>
Tested by:	Hongxiong Xian <v-hoxian microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5435
2016-02-25 09:27:50 +00:00
Sepherosa Ziehau
600d84765f hyperv/vmbus: Use free(9) for interrupt page; it is allocated by malloc(9)
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5417
2016-02-24 08:54:50 +00:00
Sepherosa Ziehau
3fd8cd9ce4 hyperv: Use malloc for page allocation.
We will eventually convert them to use busdma.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	adrian, sephe, Dexuan Cui <decui microsoft com>
Approved by:	adrian (mentor)
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5087
2016-02-05 07:29:11 +00:00
Sepherosa Ziehau
27cc90ebb1 hyperv: Use WAITOK in the places where we can wait
And convert rndis non-hot path spinlock to mutex.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	adrian, sephe
Approved by:	adrian (mentor)
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5081
2016-02-05 07:20:31 +00:00
Sepherosa Ziehau
f11ef33f0d hyperv: Use standard taskqueue instead of hv_work_queue
HyperV code was ported from Linux.  There is an implementation of
work queue called hv_work_queue.  In FreeBSD, taskqueue could be
used for the same purpose.  Convert all the consumer of hv_work_queue
to use taskqueue, and remove work queue implementation.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	adrian, Hongjiang Zhang <honzhan microsoft com>
Approved by:	adrian (mentor)
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D4963
2016-02-05 07:09:58 +00:00
Sepherosa Ziehau
0eff2e2ea1 hyperv/vmbus: Event handling code refactor.
- Use taskqueue instead of swi for event handling.
- Scan the interrupt flags in filter
- Disable ringbuffer interrupt mask in filter to ensure no unnecessary
  interrupts.

Submitted by:		Jun Su <junsu microsoft com>
Reviewed by:		adrian, sephe, Dexuan <decui microsoft com>
Approved by:		adrian (mentor)
MFC after:		2 weeks
Sponsored by:		Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D4920
2016-01-27 03:53:30 +00:00
Sepherosa Ziehau
51f6f18c88 hyperv/vmbus: Avoid extra copy of page information.
The page information array could contain up to 32 elements (i.e. 512B).
And on network side w/ TSO, 11+ (176B+) elements, i.e. ~44K TSO packet,
in the page information array is quite common.

This saves us some cpu cycles.

Reviewed by:		adrian, delphij
Approved by:		adrian (mentor)
Sponsored by:		Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D4992
2016-01-25 05:33:18 +00:00
Sepherosa Ziehau
a601c86751 hyperv/vmbus: Lookup channel through id table
Vmbus event handler will need to find the channel by its relative
id, when software interrupt for event happens.  The original lookup
searches the channel list, which is not very efficient.  We now
create a table indexed by the channel relative id to speed up
the channel lookup.

Submitted by:		Hongjiang Zhang <honzhan microsoft com>
Reviewed by:		delphij, adrain, sephe, Dexuan Cui <decui microsoft com>
Approved by:		adrian (mentor)
Sponsored by:		Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D4802
2016-01-22 07:29:31 +00:00
Sepherosa Ziehau
1952924333 hyperv: add interrupt counters
Submitted by:		Howard Su <howard0su gmail com>
Reviewed by:		royger, Dexuan Cui <decui microsoft com>, adrian
Approved by:		adrian (mentor)
Sponsored by:		Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D4693
2016-01-14 03:11:35 +00:00
Sepherosa Ziehau
99781cb353 hyperv: implement an event timer
Submitted by:		Howard Su <howard0su@gmail.com>
Reviewed by:		delphij, royger, adrian
Approved by:		adrian (mentor)
Sponsored by:		Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D4676
2016-01-14 03:05:10 +00:00
Sepherosa Ziehau
69a53a7a3a hyperv: use x86 generic code to do the hypervisor detection
This is first step to move the generic part of HV code into kernel instead
of module, so that it is possible to use hypercall to implement some other
paravirtualization code in the kernel.

Submitted by:		Howard Su <howard0su@gmail.com>
Reviewed by:		royger, delphij, adrian
Approved by:		adrian (mentor)
Sponsored by:		Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D3072
2016-01-14 02:50:13 +00:00
Xin LI
fcf8d36c46 hyperv: vmbus: run non-blocking message handlers in vmbus_msg_swintr()
We'll remove the per-channel control_work_queue because it can't properly
do serialization of message handling, e.g., when there are 2 NIC devices,
vmbus_channel_on_offer() -> hv_queue_work_item() has a race condition:
for an SMP VM, vmbus_channel_process_offer() can run concurrently on
different CPUs and if the second NIC's
vmbus_channel_process_offer() -> hv_vmbus_child_device_register() runs
first, the second NIC's name will be hn0 and the first NIC's name will
be hn1!

We can fix the race condition by removing the per-channel control_work_queue
and run all the message handlers in the global
hv_vmbus_g_connection.work_queue -- we'll do this in the next patch.

With the coming next patch, we have to run the non-blocking handlers
directly in the kernel thread vmbus_msg_swintr(), because the special
handling of sub-channel: when a sub-channel (e.g., of the storvsc driver)
is received and being handled in vmbus_channel_on_offer() running on the
global hv_vmbus_g_connection.work_queue, vmbus_channel_process_offer()
invokes channel->sc_creation_callback, i.e., storvsc_handle_sc_creation,
and the callback will invoke hv_vmbus_channel_open() -> hv_vmbus_post_message
and expect a further reply from the host, but the handling of the further
messag can't be done because the current message's handling hasn't finished
yet; as result, hv_vmbus_channel_open() -> sema_timedwait() will time out
and th device can't work.

Also renamed the handler type from hv_pfn_channel_msg_handler to
vmbus_msg_handler: the 'pfn' and 'channel' in the old name make no sense.

Submitted by:	Dexuan Cui <decui microsoft com>
Reviewed by:	royger
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D4596
2015-12-29 08:19:43 +00:00
Xin LI
47f175b846 hyperv: vmbus: remove the per-channel control_work_queue
Now vmbus_channel_on_offer() -> vmbus_channel_process_offer() can
safely run on the global hv_vmbus_g_connection.work_queue now.

We remove the per-channel control_work_queue to achieve the proper
serialization of the message handling.

I removed the bogus TODO in vmbus_channel_on_offer(): a vmbus offer
can only come from the parent partition, i.e., the host.

PR:		kern/205156
Submitted by:	Dexuan Cui <decui microsoft com>
Reviewed by:	Howard Su <howard0su gmail com>, delphij
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D4597
2015-12-29 07:54:55 +00:00
Enji Cooper
05ff465524 Remove redundant vmbus_select_outgoing_channel declaration already handled
in include/hyperv.h

This unbreaks the gcc 4.2.1 kernel build of hyperv

Differential Revision: https://reviews.freebsd.org/D4684
MFC after: 3 days
Reviewed by: royger
Sponsored by: EMC / Isilon Storage Division
2015-12-23 17:37:30 +00:00
Wei Hu
da2f98a1cf Microsoft vmbus, storage and other related driver enhancements for HyperV.
- Vmbus multi channel support.
    - Vector interrupt support.
    - Signal optimization.
    - Storvsc driver performance improvement.
    - Scatter and gather support for storvsc driver.
    - Minor bug fix for KVP driver.
Thanks royger, jhb and delphij from FreeBSD community for the reviews
and comments. Also thanks Hovy Xu from NetApp for the contributions to
the storvsc driver.

PR:     195238
Submitted by:   whu
Reviewed by:    royger, jhb, delphij
Approved by:    royger
MFC after:      2 weeks
Relnotes:       yes
Sponsored by:   Microsoft OSTC
2015-04-29 10:12:34 +00:00
Nathan Whitehorn
feeec74df7 More BUS_PROBE_NOWILDCARD sweeping. Some devices here (if_ath_ahb and siba)
resist easy conversion since they implement a great deal of their attach
logic inside probe(). Some of this could be fixed by moving it to attach(),
but some requires something more subtle than BUS_PROBE_NOWILDCARD.
2013-10-29 14:19:42 +00:00
Justin T. Gibbs
352830e2fa Centralize the detection logic for the Hyper-V hypervisor.
Submitted by:	Roger Pau Monné
Sponsored by:	Citrix Systems R&D
Reviewed by:	gibbs, grehan
Approved by:	re (gjb)

sys/sys/systm.h:
 * Add a new VM_GUEST type, VM_GUEST_HV (HyperV guest).

sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c:
sys/dev/hyperv/vmbus/hv_hv.c:
sys/dev/hyperv/stordisengage/hv_ata_pci_disengage.c:
 * Set vm_guest to VM_GUEST_HV and use that on other HyperV related
   devices instead of cloning the cpuid hypervisor check.
 * Cleanup the vmbus_identify function.
2013-10-13 02:41:30 +00:00
Peter Grehan
ddc4c1e797 Fix vmbus channel memory leak where incorrect length parameter was
being passed to contigfree().

Submitted by:	Microsoft hyperv dev team
Approved by:	re@ (glebius)
2013-10-11 21:30:27 +00:00
Dimitry Andric
785e09b08f In sys/dev/hyperv, fix a number of gcc warnings about usage of anonymous
union members in strict C99, by giving them names.  While here, add some
FreeBSD keywords where they were missing.

Approved by:	re (gjb)
Reviewed by:	grehan
2013-10-10 16:25:53 +00:00