Commit Graph

109 Commits

Author SHA1 Message Date
Sepherosa Ziehau
0e38830eec MFC 306015
hyperv/storvsc: Fix SRB length setting.

    This fixes disk discovery issue on WS2008R2 Hyper-V, which plagued
    us since 10.2-release.

    Reported by:    many
    Sponsored by:   Microsoft
2016-09-23 04:53:47 +00:00
Sepherosa Ziehau
bc6adc2ca0 MFC 304251
hyperv/storvsc: Deliver CAM_SEL_TIMEOUT upon SRB status error.

    SRB status is set to 0x20 by the hypervisor, if the specified LUN is
    unaccessible, and even worse the INQUIRY response will not be set by
    the hypervisor at all under this situation.  Additionally, SRB status
    is 0x20 too, for TUR on an unaccessible LUN.

    Deliver CAM_SEL_TIMEOUT to CAM upon SRB status errors as suggested by
    Scott Long, other values seems improper.

    This commit fixes the Hyper-V disk hotplug support.

    Submitted by:   Hongjiang Zhang <honzhan microsoft com>
    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D7521
2016-08-22 02:11:30 +00:00
Sepherosa Ziehau
96c62bcea9 MFC 303737
hyperv/storvsc: Claim SPC-3 conformance, thus enable UNMAP support

    The Hyper-V on pre-win10 systems will only report SPC-2 conformance,
    but it actually conforms to SPC-3.  The INQUIRY response is adjusted
    to propagate the SPC-3 version information to CAM.

    Submitted by:   Hongjiang Zhang <honzhan microsoft com>
    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D7405
2016-08-08 06:33:59 +00:00
Sepherosa Ziehau
c44421a4dc MFC 302541,302605
302541
    hyperv/stor: Fix the INQUIRY checks

    Don't check the area that the host has not filled.

    PR:         https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209443
    PR:         https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210425
    Submitted by:       Hongjiang Zhang <honzhan microsoft com>
    Reviewed by:        sephe, Dexuan Cui <decui microsoft com>
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6955

302605
    hyperv/stor: Save the response status and xfer length properly.

    The current command response handling discards status and xfer
    length unconditionally, so that all of the commands would be
    considered successful, even if errors happened.  When errors
    really happens, this causes all kinds of wiredness, since the
    buffer will not be filled on the host side and sense data will
    be ignored.

    Most of the time, errors do not happen, however, error does
    happen for the request sent immediately after the disk resizing.
    Discarding the SCSI status (SCSI_STATUS_CHECK_COND) and sense
    data (capacity changes) prevents the disk resizing from working
    properly.

    This commit saves the response status and xfer length properly
    for later use.

    Submitted by:       Dexuan Cui <decui microsoft com>
    Noticed by: sephe
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D7181
2016-07-15 02:29:10 +00:00
Sepherosa Ziehau
5119948815 hyperv/vmbus: Fix mismerge of r301015
Submitted by:	Oliver Pinter <oliver.pinter hardenedbsd org>
Sponsored by:	Microsoft OSTC
2016-06-27 01:17:00 +00:00
Sepherosa Ziehau
ff4b64f078 MFC 301483,301484,301487,301488,301583,301588
301483
    hyperv: Move machine dependent bits into machine dependent files.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6701

301484
    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

301487
    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

301488
    hyperv/vmbus: Constify channel message

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6708

301583
    hyperv/vmbus: Busdma-fy MNF and event flags.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6744

301588
    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-24 02:30:14 +00:00
Sepherosa Ziehau
fb7399770b MFC 301113
hyperv: Rename some cleaned up/almost cleaned up files

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-24 02:06:13 +00:00
Sepherosa Ziehau
14c9deb6f9 MFC 301017,301018,301019,301020,301021,301022,301106
301017
    hyperv/vmbus: Indentation cleanup

    No functional changes.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6602

301018
    hyperv/vmbus: Move global vmbus id array to stack.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6603

301019
    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

301020
    hyperv/vmbus: White space cleanup

    No functional changes

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6637

301021
    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

301022
    hyperv/kvp: Use if_xname.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6641

301106
    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-24 01:49:59 +00:00
Sepherosa Ziehau
b2e69e76fc MFC 301015
hyperv/vmbus: Rename ISR functions

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6601
2016-06-24 01:20:33 +00:00
Sepherosa Ziehau
6b397b5585 MFC 300987,300988,300989,300992,300993,300994,301009
300987
    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

300988
    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

300989
    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

300992
    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

300993
    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

300994
    hyperv/et: Allow Hyper-V event timer be disabled

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6599

301009
    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-06-23 09:03:52 +00:00
Sepherosa Ziehau
bd1f69776b MFC 300825,300827,300830,300831,300832,300834
300825
    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

300827
    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

300830
    hyperv/vmbus: Move MSR EOM to hyperv_reg.h

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6567

300831
    hyperv: GC unneeded bits

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6568

300832
    hyperv: Clean up Hyper-V timecounter a bit.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6569

300834
    hyperv: Test features before enabling optional functionalities

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6571
2016-06-23 08:26:07 +00:00
Sepherosa Ziehau
fdcca00bff MFC 300654,300655,300708
300654
    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

300655
    hyperv: Preserve required bits when disable Hypercall

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6530

300708
    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-06-23 08:09:44 +00:00
Sepherosa Ziehau
555199507c MFC 300647,300650,300651,300652,300653
300647
    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

300650
    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

300651
    hyperv/vmbus: Minor style and white space cleanup

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6523

300652
    hyperv/vmbus: Pass vmbus softc to vmbus_synic_setup

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6527

300653
    hyperv/vmbus: Nuke unnecessary MSR read

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6528
2016-06-23 07:53:58 +00:00
Sepherosa Ziehau
c3f99f50f8 MFC 300646
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-06-23 07:36:03 +00:00
Sepherosa Ziehau
ad4fd71dcd MFC 300645
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-06-23 07:09:44 +00:00
Sepherosa Ziehau
2a3e12641c MFC 300576,300644
300576
    hyperv/vmbus: Free message taskqueue during interrupt teardown

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6506

300644
    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-06-23 06:27:41 +00:00
Sepherosa Ziehau
4b8d076eb1 MFC 300574
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-06-23 06:18:32 +00:00
Sepherosa Ziehau
adea738d4b MFC 300573
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-06-23 05:56:04 +00:00
Sepherosa Ziehau
64c8cdaeb7 MFC 300572
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-06-23 05:51:57 +00:00
Sepherosa Ziehau
38600b09c0 MFC 300565,300567,300568,300570,300571
300565
    hyperv/vmbus: Move vmbus interrupt counter into vmbus softc

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6497

300567
    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

300568
    hyperv/busdma: Take BUS_DMA_ZERO into account

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6499

300570
    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

300571
    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-06-23 05:35:08 +00:00
Sepherosa Ziehau
ccf8c766c0 MFC 300487
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-06-23 05:08:17 +00:00
Sepherosa Ziehau
97e2e0cfbd MFC 300480,300481,300486
300480
    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

300481
    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

300486
    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-06-23 04:40:13 +00:00
Sepherosa Ziehau
828508fc3a MFC 300478,300479
300478
    hyperv: Add helpers for busdma(9) operation

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6443

300479
    hyperv/hn: Use hyperv busdma(9) helper.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6444
2016-06-23 03:25:18 +00:00
Sepherosa Ziehau
10dde1d3a0 MFC 300122,300123,300124,300126,300127,300129,300455
300122
    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

300123
    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

300124
    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

300126
    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

300127
    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

300129
    hyperv/vmbus: Use consistent device description as other devices

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6418

300455
    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-06-23 03:14:09 +00:00
Sepherosa Ziehau
54dac9be77 MFC 300108,300111,300112,300120,300121
300108
    hyperv/vmbus: Minor white space and style cleanup

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6407

300111
    hyperv/vmbus: Utilize curcpu

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6408

300112
    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

300120
    hyperv/vmbus: Remove useless modevent handler

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6410

300121
    hyperv/vmbus: Nuke unnecessary function indirection

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6411
2016-06-23 02:53:24 +00:00
Sepherosa Ziehau
cf8cfdc147 MFC 299927,300101,300102,300105,300107
299927
    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

300101
    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

300102
    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

300105
    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

300107
    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-06-23 02:37:24 +00:00
Sepherosa Ziehau
e1a98e6255 MFC 299889,299890,299892
299889
    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

299890
    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

299892
    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-06-23 01:47:30 +00:00
Sepherosa Ziehau
7fdc68f70e MFC 299401,299888
299401
    hyperv/hn: Extract RSS hash value and type.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6287

299888
    hyperv/hn: Combine per-packet-information parsing.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-21 07:05:49 +00:00
Sepherosa Ziehau
8584c47dc9 MFC 298690,298693,298694
298690
    hyperv/hn: Mark sysctls MPSAFE

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298693
    hyperv/vmbus: Mark sysctls MPSAFE

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298694
    hyperv/hn: Add stat for # of chimney sending tries

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-21 06:45:29 +00:00
Sepherosa Ziehau
b5ed9d0bfa MFC 298618,298620,298688,298689
298618
    hyperv/stor: Set description properly in probe devmethod

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298620
    hyperv/hn: Change description to "Hyper-V Network Interface"

    This is consistent w/ other Hyper-V devices.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298688
    hyperv/hn: Restart sending earlier once we gathered some free TX descs

    This greatly reduces the oqdrops under heavy workload.

    For TCP send/recv test (10K concurrent connections):
    oqdrops is reduced by 17% on sending side, and 57% on receiving side.

    For nginx-1.8/wrk-4 1KB object test (10K concurrent connections,
    4 requests/connection):
    oqdrops is reduced by 44% on nginx side, and 10% on wrk side.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298689
    hyperv/hn: Remove unapplied comment.

    Chimney sending buffers are shared across channels.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-21 06:37:38 +00:00
Sepherosa Ziehau
198337673c MFC 298569,298570,298571,298572,298574,298575,298613,298614,298615,298616,298617
298569
    hyperv/channel: Remove the unnecessary 'new' flag

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298570
    hyperv/channel: Minor style changes; no functional changes.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298571
    hyperv/channel: Remove unapplied comment

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298572
    hyperv/channel: Log a warning about duplicated primary channel offer

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298574
    hyperv/channel: Add functions to synchronize sub-channel offers

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298575
    hyperv/hn: Synchronize sub-channel offers

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298613
    hyperv/stor: Remove the useless hs_open_multi_channel

    This fixes the sub-channel offer race after Hyper-V device probe/attach
    is moved to vmbus SYSINIT/attach.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298614
    hyperv/stor: Synchronize sub-channel offers

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298615
    hyperv/hn: Avoid sub-channel creation callback.

    Since the sub-channel offers are synchronized, we can do our own
    channel setup without using the sub-channel creation callback.

    This paves the way to whack the sub-channel creation callback.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298616
    hyperv/stor: Avoid sub-channel creation callback.

    Since the sub-channel offers are synchronized, we can do our own
    channel setup without using the sub-channel creation callback.

    This paves the way to whack the sub-channel creation callback.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298617
    hyperv/channel: Git rid of the sub-channel creation callback

    It is no longer used.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-21 06:18:41 +00:00
Sepherosa Ziehau
774b160d01 MFC 298561,298563
298561
    hn: Increase odrops for if_transmit method if drbr_enqueue fails.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298563
    hyperv/hn: Allow users to configure ifq or bufring depth.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-21 05:49:07 +00:00
Sepherosa Ziehau
cfd6f88f77 MFC 298449,298568
298449
    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

298568
    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-06-21 05:33:26 +00:00
Sepherosa Ziehau
4a26ada395 MFC 298446
hyperv: Update copyright to 2016 for the files Microsoft changed in 2016

    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D6039
2016-06-21 05:20:41 +00:00
Sepherosa Ziehau
0c2b22a10a MFC 298260
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-06-21 05:16:21 +00:00
Sepherosa Ziehau
00f06038e0 MFC 298041,298259
298041
    hyperv: No need to zero out softc

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298259
    hyperv: Remove two assign-only local variables

    Submitted by:       Jun Su <junsu microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-21 05:11:19 +00:00
Sepherosa Ziehau
aee1765014 MFC 298040
hyperv/stor: Use xpt_done_direct() upon I/O completion

    Reviewed by:        mav
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5955
2016-06-21 05:02:03 +00:00
Sepherosa Ziehau
95188920f6 MFC 297931,298022
297931
    Expose doreti as a global symbol on amd64 and i386.

    doreti provides the common code path for returning from interrupt
    andlers on x86.  Exposing doreti as a global symbol allows kernel
    modules to include low-level interrupt handlers instead of requiring
    all low-level handlers to be statically compiled into the kernel.

    Submitted by:       Howard Su <howard0su@gmail.com>
    Reviewed by:        kib

298022
    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-06-21 04:51:55 +00:00
Sepherosa Ziehau
1b107df2d5 MFC 297815,297841,297908,297913
297815
    hyperv: Typo

    Noticed by: kib
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

297841
    hyperv: Replace 0 w/ NULL

    Submitted by:       pfg
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

297908
    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

297913
    hyperv: device_get_softc does not return NULL

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-21 02:36:03 +00:00
Sepherosa Ziehau
820bf01998 MFC 298039,298042
298039
    hyperv/vmbus: Put multi-channel offer logging under bootverbose

    Suggested by:       Dexuan Cui <decui microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

298042
    hyperv/hn: Hide ring to channel linkage message under bootverbose

    Suggested by:       Dexuan Cui <decui microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-16 06:34:12 +00:00
Sepherosa Ziehau
02d799777f hyperv/hn: ifnet TSO configuration is available on 10-stable.
Sponsored by:	Microsoft OSTC
2016-06-16 06:26:09 +00:00
Sepherosa Ziehau
bd2db18dd8 MFC 297809,297810,297811
297809
    hyperv/hn: Cap default # of rings to 8.

    8 gives the best performance in both Azure and local Hyper-V on both
    10Ge and 40Ge. More rings are still allowed by manual configuration.

    Reviewed by:        Dexuan Cui <decui microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5879

297810
    hyperv/hn: By default enable multiple TX/RX rings, aka vRSS.

    Reviewed by:        Dexuan Cui <decui microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5880

297811
    hyperv/hn: Remove unnecessary NULL checks

    Submitted by:       Jun Su <junsu microsoft com>
    Reviewed by:        sephe
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5905
2016-06-16 05:24:00 +00:00
Sepherosa Ziehau
9621352981 MFC 297636,297800,297801,297805,297807,297808
297636
    hyperv: Typo in r297634

    Noticed by: hiren
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

297800
    hyperv/vmbus: Nuke unused function

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

297801
    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

297805
    hyperv: Break long line

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

297807
    hyperv: Print more features

    And add comment about the MSR features.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

297808
    hyperv: Define macro for Hyper-V interface

    Suggested by:       rpokala
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-16 05:12:28 +00:00
Sepherosa Ziehau
b774f5de06 MFC 297220
hyperv/utils: Allow hint to disable individual utility

    Reviewed by:        kib, Dexuan Cui <decui microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5714
2016-06-16 03:25:26 +00:00
Sepherosa Ziehau
24b803de77 MFC 297180,297181,297182
297180
    hyperv/hn: Reduce TCP segment aggregation limit for multiple RX rings

    This mainly used to improve ACK timeliness when multiple RX rings
    are enabled.

    This value gives the best performance in both Azure and Hyper-V
    environment, w/ both 10Ge and 40Ge using non-{INVARIANTS,WITNESS}
    kernel.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5691

297181
    hyperv/hn: Factor out hn_set_lro_lenlim()

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5692

297182
    hyperv/hn: When short of mbufs on the RX path, don't spam the console.

    Instead, increase the IQDROPS counter.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5693
2016-06-16 03:16:43 +00:00
Sepherosa Ziehau
9b2d0feeca MFC 297142,297143,297176,297177,297178,297221
297142
    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

297143
    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

297176
    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

297177
    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

297178
    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

297221
    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-06-16 03:04:16 +00:00
Sepherosa Ziehau
d8cfae94f0 MFC 296379,296380,296381,296593,296594,296595
296379
    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

296380
    hyperv/hn: Pass channel to send done callbacks.

    Mainly to strigent the data packet send done check.

    MFC after:  2 weeks
    Sponsored by:       Microsoft OSTC

296381
    hyperv/hn: Add per-TX ring stats for # of transmitted packets

    MFC after:  2 weeks
    Sponsored by:       Microsoft OSTC

296593
    hyperv/hn: Move if_initname to an earlier place

    So that functions shared w/ attach path could use if_printf().

    While I'm here, remove unnecessary if_dunit and if_dname assignment.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5576

296594
    hyperv/hn: Factor out hn_channel_attach

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5577

296595
    hyperv/hn: Make the # of TX rings configurable.

    Rename the tunables to avoid confusion.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5578
2016-06-16 02:48:18 +00:00
Sepherosa Ziehau
88ac3302e3 MFC 297802,297803(297481),297804
297802
    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

279803(297481)
    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

    =================

    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

297804
    hyperv: Declare hyperv_{features,recommends} properly

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
2016-06-16 01:57:16 +00:00
Sepherosa Ziehau
ba79f83ecc MFC 297635
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-06-15 09:52:01 +00:00
Sepherosa Ziehau
9d23ba86fb MFC 297219
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-06-15 09:39:41 +00:00