Commit Graph

81 Commits

Author SHA1 Message Date
John Baldwin
53e938e408 hyperv storvsc: Don't abuse struct sglist to hold virtual addresses.
struct sglist is intended for holding S/G lists of physical address
ranges, not virtual address ranges.  GCC 9.x issues several warnings
due to casts between pointers and integers of different sizes as a
result (vm_paddr_t is 64-bits on i386).  Instead, add a local 'struct
hv_sglist' which uses an array of 'struct iovec' to hold the S/G list
of virtual address ranges.

Differential Revision:	https://reviews.freebsd.org/D31933
2022-01-31 17:11:27 -08:00
Cy Schubert
db0ac6ded6 Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816"
This reverts commit 266f97b5e9, reversing
changes made to a10253cffe.

A mismerge of a merge to catch up to main resulted in files being
committed which should not have been.
2021-12-02 14:45:04 -08:00
Cy Schubert
266f97b5e9 wpa: Import wpa_supplicant/hostapd commit 14ab4a816
This is the November update to vendor/wpa committed upstream 2021-11-26.

MFC after:      1 month
2021-12-02 13:35:14 -08:00
Don Morris
8f82dc8dd3 hyperv: Flag hn and storvsc statistics with CTLFLAG_STATS.
Reviewed by:    vangyzen, whu, bdrewery
Sponsored by:	Dell EMC
Differential Revision: https://reviews.freebsd.org/D30060
2021-12-02 10:46:36 -08:00
Andriy Gapon
8afecefd57 storvsc: fix auto-sense reporting
I saw a situation where the driver set CAM_AUTOSNS_VALID on a failed ccb
even though SRB_STATUS_AUTOSENSE_VALID was not set in the status.
The actual sense data remained all zeros.
The problem seems to be that create_storvsc_request() always sets
hv_storvsc_request::sense_info_len, so checking for sense_info_len != 0
is not enough to determine if any auto-sense data is actually available.

Reviewed by:	whu, imp
MFC after:	2 weeks
Sponsored by:	CyberSecure
Differential Revision:	https://reviews.freebsd.org/D30124
2021-05-07 10:17:57 +03:00
Wei Hu
2a0ce39d08 Hyper-V: storvsc: Enhance srb_status code handling.
In hv_storvsc_io_request() when coring, prevent changing of the send channel
from the base channel to another one. storvsc_poll always probes on the base
channel.

Based upon conversations with Microsoft, changed the handling of srb_status
codes. Most we should never get, others yes. All are treated as retry-able
except for two. We should not get these statuses, but if we ever do, the I/O
state is not known.

Submitted by:	Alexander Sideropoulos <Alexander.Sideropoulos@netapp.com>
Reviewed by:	trasz, allanjude, whu
MFC after:	1 week
Sponsored by:	Netapp Inc
Differential Revision:	https://reviews.freebsd.org/D25756
2020-08-31 09:05:45 +00:00
Andriy Gapon
efdba95d62 storvsc: port a Linux patch, properly set residual data length on errors
This change is based on Linux commit 40630f462824ee.  csio.resid should
account for transfer_len only for success and SRB_STATUS_DATA_OVERRUN
condition.

I am not sure how exactly this change works, but I have a report from a
user that they see lots of checksum errors when running a pool scrub
concurrently with iozone -l 1 -s 100G.  After applying this patch the
problem cannot be reproduced.

Reviewed by:	nobody
Sponsored by:	CyberSecure
Differential Revision: https://reviews.freebsd.org/D22312
2020-01-14 13:20:16 +00:00
Andriy Gapon
97d8f008af hyperv/storvsc: stash a pointer to hv_storvsc_request in ccb
A SIM-private field is used for that.
The pointer can be useful when examining a state of a queued ccb.
E.g., a ccb on a da_softc.pending_ccbs.

MFC after:	2 weeks
2019-11-19 07:20:59 +00:00
Dexuan Cui
0d880ef422 hyperv/storvsc: storvsc_io_done(): do not use CAM_SEL_TIMEOUT
CAM_SEL_TIMEOUT was introduced in
https://reviews.freebsd.org/D7521 (r304251), which claimed:

"VM shall response to CAM layer with CAM_SEL_TIMEOUT to filter those
invalid LUNs. Never use CAM_DEV_NOT_THERE which will block LUN scan
for LUN number higher than 7."

But it turns out this is not correct:

I think what really filters the invalid LUNs in r304251 is that:
before r304251, we could set the CAM_REQ_CMP without checking
vm_srb->srb_status at all:
ccb->ccb_h.status |= CAM_REQ_CMP.

r304251 checks vm_srb->srb_status and sets ccb->ccb_h.status properly,
so the invalid LUNs are filtered.

I changed my code version to r304251 but replaced the CAM_SEL_TIMEOUT
with CAM_DEV_NOT_THERE, and I confirmed the invalid LUNs can also be
filtered, and I successfully hot-added and hot-removed 8 disks to/from
the VM without any issue.

CAM_SEL_TIMEOUT has an unwanted side effect -- see cam_periph_error():
For a selection timeout, we consider all of the LUNs on
the target to be gone. If the status is CAM_DEV_NOT_THERE,
then we only get rid of the device(s) specified by the
path in the original CCB.

This means: for a VM with a valid LUN on 3:0:0:0, when the VM inquires
3:0:0:1 and the host reports 3:0:0:1 doesn't exist and storvsc returns
CAM_SEL_TIMEOUT to the CAM layer, CAM will detech 3:0:0:0 as well: this
is the bug I reported recently:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226583

PR:	226583
Reviewed by:	mav
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D14690
2018-04-10 18:05:02 +00:00
Warner Losh
762a7f4f5f Define xpt_path_inq.
This provides a nice wrarpper around the XPT_PATH_INQ ccb creation and
calling.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13387
2017-12-06 23:05:22 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Sepherosa Ziehau
93b4e111bb hyperv: Update copyright for the files changed in 2017
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D11982
2017-08-14 06:00:50 +00:00
Sepherosa Ziehau
6478f3180c hyperv/storvsc: Force SPC3 for CDROM attached.
This unbreaks the CDROM attaching on GEN2 VMs.  On GEN1 VMs, CDROM is
attached to emulated ATA controller.

PR:		220790
Submitted by:	Hongjiang Zhang <honzhan microsoft com>
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D11634
2017-07-20 07:13:26 +00:00
Jason A. Harmening
eb36b1d0bc Clean up MD pollution of bus_dma.h:
--Remove special-case handling of sparc64 bus_dmamap* functions.
  Replace with a more generic mechanism that allows MD busdma
  implementations to generate inline mapping functions by
  defining WANT_INLINE_DMAMAP in <machine/bus_dma.h>.  This
  is currently useful for sparc64, x86, and arm64, which all
  implement non-load dmamap operations as simple wrappers
  around map objects which may be bus- or device-specific.

--Remove NULL-checked bus_dmamap macros.  Implement the
  equivalent NULL checks in the inlined x86 implementation.
  For non-x86 platforms, these checks are a minor pessimization
  as those platforms do not currently allow NULL maps.  NULL
  maps were originally allowed on arm64, which appears to have
  been the motivation behind adding arm[64]-specific barriers
  to bus_dma.h, but that support was removed in r299463.

--Simplify the internal interface used by the bus_dmamap_load*
  variants and move it to bus_dma_internal.h

--Fix some drivers that directly include sys/bus_dma.h
  despite the recommendations of bus_dma(9)

Reviewed by:	kib (previous revision), marius
Differential Revision:	https://reviews.freebsd.org/D10729
2017-07-01 05:35:29 +00:00
Sepherosa Ziehau
cdb5402c4c hyperv/storvsc: Reduce log verbosity
On some windows hosts TEST_UNIT_READY command will return
SRB_STATUS_ERROR and sense data "NOT READY asc:3a,1 (Medium
not present - tray closed)", this occurs periodically, and
not hurt anything else.  So, we prefer to ignore this kind
of errors.

PR:		219973
Submitted by:	Hongjiang Zhang <hongzhan microsoft com>
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D11271
2017-06-21 06:44:56 +00:00
Sepherosa Ziehau
e25942b0eb hyperv/storvsc: Use ULL for 64bits value shift.
Reported by:	PVS
MFC after:	3 days
Sponsored by:	Microsoft
2017-04-14 05:25:21 +00:00
Sepherosa Ziehau
498ef762ec hyperv/storvsc: Fixup SRB status.
This unbreaks GEN2 Hyper-V cd support.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
Reviewed by:	dexuan@
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D10212
2017-04-05 08:15:47 +00:00
Alan Somers
4195c7de24 Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)
The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are
fixed-length strings. AFAICT the only place they're read is in
sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated.
However, the kernel doesn't null-terminate them. A bunch of copy-pasted code
uses strncpy to write them, and doesn't guarantee null-termination. For at
least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually
overflows. You can see the result by doing "camcontrol negotiate da0 -v".

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

PR:		215474
Reported by:	Coverity
CID:		1009997 1010000 1010001 1010002 1010003 1010004 1010005
CID:		1331519 1010006 1215097 1010007 1288967 1010008 1306000
CID:		1211924 1010009 1010010 1010011 1010012 1010013 1010014
CID:		1147190 1010017 1010016 1010018 1216435 1010020 1010021
CID:		1010022 1009666 1018185 1010023 1010025 1010026 1010027
CID:		1010028 1010029 1010030 1010031 1010033 1018186 1018187
CID:		1010035 1010036 1010042 1010041 1010040 1010039
Reviewed by:	imp, sephe, slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9037
Differential Revision:	https://reviews.freebsd.org/D9038
2017-01-04 20:26:42 +00:00
Sepherosa Ziehau
39f0182303 hyperv/storvsc: The max channel in PDU actually means the max sub-chans.
Use proper name for local variables. PDU fields' name was not changed yet.
While I'm here, make # of usable channels tunable. This eases further
testing.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8851
2016-12-21 03:09:07 +00:00
Sepherosa Ziehau
4b167c2b4d hyperv/storvsc: Minor style changes; no functional changes.
Reported by:	rpokala
MFC after:	1 week
Sponsored by:	Microsoft
2016-12-09 06:18:12 +00:00
Sepherosa Ziehau
692cb24f10 hyperv/storvsc: Fix the SCSI disk attachment issue.
On pre-WS2016 Hyper-V, if the only LUNs > 7 are used, then all disks
fails to attach.  Mainly because those versions of Hyper-V do not set
SRB_STATUS properly and deliver junky INQUERY responses.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
Reported by:	Hongxiong Xian <v-hoxian microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8724
2016-12-09 03:16:36 +00:00
Sepherosa Ziehau
14c85e527e hyperv/storvsc: Don't use timedwait.
The timeout is unnecessary.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8656
2016-11-30 08:21:15 +00:00
Sepherosa Ziehau
e52a79e5c1 hyperv/stor: Fix off-by-one bug; this brings back TRIM support.
Submitted by:	Hongjiang Zhang <honzhan microsoft com>
Reported by:	Lili Deng <v-lide microsoft com>
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8238
2016-10-14 05:32:47 +00:00
Sepherosa Ziehau
cdf2c7a5da hyperv/storvsc: Fix the blkvsc disk attachment issues.
- The original 'disengage' ATA controller model does not work properly
  for all possible disk configurations.  Use the newly added ATA disk
  veto eventhandler to fit into all possible disk configuration.
- If the 'invalid LUN' happens on blkvsc controllers, return
  CAM_DEV_NOT_THERE so that CAM will not destroy attached disks under
  the blkvsc controllers.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
Discussed with:	mav
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7693
2016-09-29 01:41:52 +00:00
Sepherosa Ziehau
fa8c981396 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
MFC after:	3 days
Sponsored by:	Microsoft
2016-09-20 08:52:45 +00:00
Sepherosa Ziehau
9db7c2c6b5 hyperv/storvsc: Increase queue depth and rework channel selection.
- Increasing queue depth gives ~100% performance improvement for
  randwrite fio test in Azure.
- New channel selection, which takes LUN id and the current cpuid
  into consideration, gives additional ~20% performance improvement
  for ranwrite fio test in Azure.

Submitted by:   Hongzhang Jiang <honzhan microsoft com>
Modified by:    sephe
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7622
2016-08-25 05:50:19 +00:00
Sepherosa Ziehau
86afc9b625 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>
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7521
2016-08-17 05:02:18 +00:00
Sepherosa Ziehau
8d17f17043 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>
MFC after:	3 days
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7405
2016-08-04 05:05:35 +00:00
Sepherosa Ziehau
05f7a8a69c hyperv/storvsc: Stringent PRP list assertions
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7361
2016-08-01 05:09:11 +00:00
Sepherosa Ziehau
88cb8d7812 hyperv/storvsc: Set maxio to 128KB.
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7360
2016-08-01 04:51:31 +00:00
Sepherosa Ziehau
9d6016a773 hyperv/vmbus: Remove the artificial entry limit of SG and PRP list.
Just make sure that the total channel packet size does not exceed 1/2
data size of the TX bufring.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7359
2016-08-01 04:26:24 +00:00
Sepherosa Ziehau
cf6890fbdc hyperv/storvsc: Use busdma(9) and enable PIM_UNMAPPED by default.
The UNMAPPED I/O greatly improves userland direct disk I/O performance
by 35% ~ 135%.

Submitted by:	Hongjiang Zhang <honzhan microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7195
2016-07-29 06:22:11 +00:00
Sepherosa Ziehau
7d8ee480c4 hyperv/vmbus: Inclusion cleanup
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7334
2016-07-28 06:46:10 +00:00
Sepherosa Ziehau
82b8a87964 hyperv: hv_vmbus_channel -> vmbus_channel
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7260
2016-07-21 06:09:47 +00:00
Sepherosa Ziehau
6254947245 hyperv/vmbus: Hide channel struct definition.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7245
2016-07-20 06:00:27 +00:00
Sepherosa Ziehau
ca871fb75c hyperv/vmbus: Pass channel as the first argument for channel callback
The prepares to kill device private fields in channel struct, which
are not flexible and extensible.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7243
2016-07-20 05:34:28 +00:00
Sepherosa Ziehau
9129ad2d70 hyperv/vmbus: Channel struct field rename
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7242
2016-07-20 05:26:04 +00:00
Sepherosa Ziehau
e93854c495 hyperv/vmbus: Function rename
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7230
2016-07-19 05:57:19 +00:00
Sepherosa Ziehau
742fb4f669 hyperv/vmbus: Cleanup cpu based channel selection.
And create cpu to channel map at device attach time for storvsc(4).

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7229
2016-07-19 05:46:15 +00:00
Sepherosa Ziehau
d0856980e4 hyperv/vmbus: Function rename
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7212
2016-07-15 08:23:33 +00:00
Sepherosa Ziehau
a91e5fd55f hyperv/vmbus: Back out r302888 temporarily
Committed by accident w/ duplicated commit log

MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-07-15 08:13:44 +00:00
Sepherosa Ziehau
047affd165 hyperv/hn: Busdma-fy rxbuf and chimney sending buffer
Nuke unused channel GPADL API.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7211
2016-07-15 08:08:13 +00:00
Sepherosa Ziehau
7c55724859 hyperv/vmbus: Cleanup channel receiving.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7202
2016-07-15 07:45:30 +00:00
Sepherosa Ziehau
12140675e8 hyperv/vmbus: Function rename
And reorder the error prone parameters list.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7191
2016-07-15 07:16:46 +00:00
Sepherosa Ziehau
03055a2cea hyperv/vmbus: Move channel packet types definition to vmbus.h
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7177
2016-07-15 06:58:21 +00:00
Sepherosa Ziehau
1680fb300c hyperv/vmbus: Move channel packet flags definition to vmbus.h
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7176
2016-07-15 06:49:45 +00:00
Sepherosa Ziehau
66e132bd0f hyeprv/vmbus: Rework prplist sending.
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7175
2016-07-15 06:40:59 +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
d2c2a2ef36 hyperv/stor: Avoid the hv_device and nuke the broken get_stor_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/D7027
2016-07-13 05:28:07 +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