Commit Graph

2050 Commits

Author SHA1 Message Date
Scott Long
bf1a889535 Squash a couple of uses of xpt_print_path()
Sponsored by:	Netflix
2017-01-27 21:55:47 +00:00
Warner Losh
e831795b8a Remove nested #ifdef that can't possibly be false. 2017-01-27 08:30:43 +00:00
Jung-uk Kim
a196ef645a Fix libcam build. It was broken with r312827. 2017-01-27 00:17:07 +00:00
Scott Long
a136ca542c Fix a development mis-merge from r312827
Sponsored by:	Netflix
2017-01-26 20:18:03 +00:00
Scott Long
ab3e89f1ab Refactor xpt_print_path, xpt_print, and xpt_path_string. Implement
all of them in terms of an sbuf-based back-end, xpt_path_sbuf.  This
unifies the implementation, but more importantly it stops the output
fropm being split between 4 or more invocations of printf.  The
multiple invocations cause interleaving of the messages on the
console during boot, making the output of disk discovery often
unintelligible.  This change helps a lot, but more work is needed.

Reviewed by:	ken, mav
Sponsored by:	Netflix
2017-01-26 20:08:58 +00:00
Edward Tomasz Napierala
5ab1cf33f7 Bring the ctl headers a bit closer to style(9). No functional changes. 2017-01-25 22:52:57 +00:00
Warner Losh
b20c0a07fb Preening pass to fix up trailing white space and other minor style(9)
nits (though I'm sure others remain).

MFC After: 3 days
2017-01-25 02:05:08 +00:00
Alexander Motin
e7037673ca Make CTL ramdisk backend a real RAM disk.
If "capacity" LU option is set, ramdisk backend now implements featured
thin provisioned disk, storing data in malloc(9) allocated memory blocks
of pblocksize bytes (default PAGE_SIZE or 4KB).  Additionally ~0.2% of LU
size is used for indirection tree (bigger pblocksize reduce the overhead).
Backend supports all unmap and anchor operations.  If configured capacity
is overflowed, proper error conditions are reported.

If "capacity" LU option is not set, the backend operates mostly the same
as before without allocating real storage: writes go to nowhere, reads
return zeroes, reporting that all LBAs are unmapped.

This backend is still mostly oriented on testing and benchmarking (it is
still a volatile RAM disk), but now it should allow to run real FS tests,
not only simple dumb dd.

MFC after:	2 weeks
2017-01-24 12:13:41 +00:00
Alexander Motin
b96d9778eb Fix overrun handling issue in r312291.
MFC after:	1 week
2017-01-23 17:44:33 +00:00
Edward Tomasz Napierala
f308ab7043 Remove max_targets and max_target_id CTL port variables; they were unused.
This changes the CTL frontend ABI and thus shouldn't be MFC-ed.

Reviewed by:	mav@
2017-01-22 20:06:15 +00:00
Edward Tomasz Napierala
c6646787ab Add SCSI descriptors for USB Mass Storage.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2017-01-22 15:32:17 +00:00
Alexander Motin
0c629e2884 Add initial support for CTL module unloading.
It is only a first step and not perfect, but better then nothing.
The main blocker is CAM target frontend, that can not be unloaded,
since CAM does not have mechanism to unregister periph driver now.

MFC after:	2 weeks
2017-01-21 19:38:26 +00:00
Alan Somers
c9bd03d87f Fix "camcontrol timestamp -s" with LTO-7 drives
The length of the scsi_set_timestamp_parameters struct was incorrect.  LTO-5
drives don't care, but LTO-7 drives do.

Reviewed by:	Sam Klopsch
MFC after:	2 weeks
Sponsored by:	Spectra Logic Corp
2017-01-20 17:54:24 +00:00
Alexander Motin
640603fbf6 Remove writing 'residual' field of struct ctl_scsiio.
This field has no practical use and never readed.  Initiators already
receive respective residual size from frontends.  Removed field had
different semantics, which looks useless, and was never passed through
by any frontend.

While there, fix kern_data_resid field support in case of HA, missed in
r312291.

MFC after:	13 days
2017-01-17 18:32:47 +00:00
Sean Bruno
23030355c6 Add 4k quirk for Micron 5100 and Intel S3610 SSDs
Submitted by:	Jason Wolfe <j@nitrology.com>
MFH:		1 week
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D9209
2017-01-17 14:52:48 +00:00
Alexander Motin
a8d32bff70 Improve error message on duplicate iSCSI port.
MFC after:	2 weeks
2017-01-17 14:13:14 +00:00
Alexander Motin
eb6ac6f9db Make CTL frontends report kern_data_resid for under-/overruns.
It seems like kern_data_resid was never really implemented.  This change
finally does it.  Now frontends update this field while transferring data,
while CTL/backends getting it can more flexibly handle the result.
At this point behavior should not change significantly, still reporting
errors on write overrun, but that may be changed later, if we decide so.

CAM target frontend still does not properly handle overruns due to CAM API
limitations.  We may need to add some fields to struct ccb_accept_tio to
pass information about initiator requested transfer size(s).

MFC after:	2 weeks
2017-01-16 16:19:55 +00:00
Conrad Meyer
1d64db52f3 Fix a variety of cosmetic typos and misspellings
No functional change.

PR:		216096, 216097, 216098, 216101, 216102, 216106, 216109, 216110
Reported by:	Bulat <bltsrc at mail.ru>
Sponsored by:	Dell EMC Isilon
2017-01-15 18:00:45 +00:00
Conrad Meyer
db4fcadf52 "Buses" is the preferred plural of "bus"
Replace archaic "busses" with modern form "buses."

Intentionally excluded:
* Old/random drivers I didn't recognize
  * Old hardware in general
* Use of "busses" in code as identifiers

No functional change.

http://grammarist.com/spelling/buses-busses/

PR:		216099
Reported by:	bltsrc at mail.ru
Sponsored by:	Dell EMC Isilon
2017-01-15 17:54:01 +00:00
Alexander Motin
953f538e0e Add under-/overrun support to IOCTL and CAM SIM frontends.
MFC after:	1 week
2017-01-15 13:57:42 +00:00
Alexander Motin
f319059631 When in kernel, map ctl_scsi_zero_io() to ctl_zero_io().
MFC after:	1 week
2017-01-15 13:51:44 +00:00
Alexander Motin
4902e14dc8 Improve CAM_CDB_POINTER support.
MFC after:	2 weeks
2017-01-13 08:31:55 +00:00
Alexander Motin
17160457b4 Report random flash storage as non-rotating to GEOM_DISK.
While doing it, introduce respective constants in geom_disk.h.

MFC after:	1 week
2017-01-12 08:53:10 +00:00
Alexander Motin
4982dca18d Do not wait for HA thread shutdown if scheduler is stopped.
This wait loop made system hang on panic instead of reboot.

MFC after:	1 week
2017-01-10 20:16:16 +00:00
Alexander Motin
7c07ea9aa2 Fix malloc(M_WAITOK) under mutex, introduced at r311787.
MFC after:	13 days
2017-01-10 10:33:36 +00:00
Alexander Motin
bb8f9017b3 Rewrite CTL statistics in more simple and scalable way.
Instead of collecting statistics for each combination of ports and logical
units, that consumed ~45KB per LU with present number of ports, collect
separate statistics for every port and every logical unit separately, that
consume only 176 bytes per each single LU/port.  This reduces struct
ctl_lun size down to just 6KB.

Also new IOCTL API/ABI does not hardcode number of LUs/ports, and should
allow handling of very large quantities.

MFC after:	2 weeks (probably keeping old API enabled for some time)
2017-01-09 18:18:15 +00:00
Alexander Motin
0e2d6474ca Allocate memory for prevent flags only for removable LUs.
This array takes 64KB of RAM now, that was more then half of struct ctl_lun
size.  If at some point we support more ports, this may need another tune.

MFC after:	2 weeks
2017-01-09 16:21:06 +00:00
Alexander Motin
81241f2828 Make CTL_GETSTATS ioctl return partial data if buffer is small.
MFC after:	2 weeks
2017-01-08 13:26:34 +00:00
Alexander Motin
54644e21e8 Make 'camcontrol modepage' support subpages.
MFC after:	2 weeks
2017-01-07 09:56:12 +00:00
Alexander Motin
f9b66e4c7d Fix bootverbose affecting code logic in r294558.
Reported by:	Jilles Tjoelker <jilles@stack.nl>
2017-01-05 16:30:13 +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
Edward Tomasz Napierala
3a408ce90d Don't release the cfiscsi session refcount too early. It wasn't
observed to fix any actual error, but it's the right thing to do
from the correctness point of view.

Tested by:	Eugene M. Zheganin <emz at norma.perm.ru>
MFC after:	1 month
2017-01-04 12:50:44 +00:00
Alexander Motin
49fe3b378b Fix build with enabled debug after r310778.
MFC after:	2 weeks
2016-12-29 18:08:04 +00:00
Alexander Motin
9cbbfd2f5c Improve use of I/O's private area.
- Since I/Os are allocates from per-port pools, make allocations store
pointer to CTL softc there, and use it where needed instead of global.
 - Created bunch of helper macros to access LUN, port and CTL softc.

MFC after:	 2 weeks
2016-12-29 15:09:34 +00:00
Alexander Motin
e67ac203a6 Allow more efficient use of private area.
There are 16 bytes of space, so we may store two pointers in one.

MFC after:	2 weeks
2016-12-27 23:56:46 +00:00
Alexander Motin
ca734d8a13 Do not update "saved" mode page on every MODE SELECT.
We do not have non-volatile memory to really save those values, so we
neither report nor support this capability.  Also saved mode pages are
not replicated between HA peers now.

MFC after:	2 weeks
2016-12-27 22:38:44 +00:00
Alexander Motin
2e0a1f828e Fix/synchronize field types in struct ctl_modepage_header.
MFC after:	2 weeks
2016-12-27 22:31:06 +00:00
Alexander Motin
2c966e8500 Missed piece of r310640.
MFC after:	2 weeks
2016-12-27 22:28:14 +00:00
Alexander Motin
3722787c8a Add support for revert to defaults (RTD) bit in MODE SELECT.
MFC after:	2 weeks
2016-12-27 21:11:54 +00:00
Alexander Motin
ee5e44e076 Decouple limits on number of LUNs per port and LUs per CTL.
Those two values are not directly related, so make them independent.
This does not change any limits immediately, but makes number of LUNs
per port controllable via tunable/sysctl kern.cam.ctl.lun_map_size.
After this change increasing CTL_MAX_LUNS should be pretty cheap,
and even making it tunable should be easy.

MFC after:	2 weeks
2016-12-27 18:23:16 +00:00
Alexander Motin
92efdd4305 Fix improperly used nexus.targ_lun.
MFC after:	2 weeks
2016-12-26 08:47:35 +00:00
Alexander Motin
a16253002c Some random code cleaning.
- Reduce indentation.
 - Remove extra braces.
 - Add few missing savety checks.

MFC after:	2 weeks
2016-12-25 20:17:15 +00:00
Alexander Motin
4124315924 Remove CTL_MAX_LUNS from places where it is not required.
MFC after:	2 weeks
2016-12-25 13:34:02 +00:00
Alexander Motin
a3dd837892 Improve third-party copy error reporting.
For EXTENDED COPY:
 - improve parameters checking to report some errors before copy start;
 - forward sense data from copy target as descriptor in case of error;
 - report which CSCD reported error in sense key specific information.
For WRITE USING TOKEN:
 - pass through real sense data from copy target instead of reporting
our copy error, since for initiator its a "simple" write, not a copy.

MFC after:	2 weeks
2016-12-25 09:40:44 +00:00
Alexander Motin
4fc0d1d757 Improve length handling when writing sense data.
- Allow maximal sense size limitation via Control Extension mode page.
 - When sense size limited, include descriptors atomically: whole or none.
 - Set new SDAT_OVFL bit if some descriptors don't fit the limit.
 - Report real written sense length instead of static maximal 252 bytes.

MFC after:	2 weeks
2016-12-24 17:42:34 +00:00
Alexander Motin
5bb5027e27 Implement printing forwarded sense data.
MFC after:	2 weeks
2016-12-23 21:56:08 +00:00
Alexander Motin
368cbc2c67 Add place-holders for TAPE STREAM MIRRORING subcommands of XCOPY.
We do not support tapes, so this is only a comments.

MFC after:	2 weeks
2016-12-23 14:54:40 +00:00
Alexander Motin
2be7cd9bdb Add support for REPD bit in RSTMF command.
We have no real timeout values to report there, but its better then error.

MFC after:	2 weeks
2016-12-22 12:18:40 +00:00
Alexander Motin
8202971892 Fix REPORT SUPPORTED OPERATION CODES for READ/WRITE BUFFER commands.
Specifications require MODE parameter of those commands to be treated
the same as SERVICE ACTION parameter of other commands.

MFC after:	2 weeks
2016-12-22 11:10:11 +00:00
Alexander Motin
20549bf66f Add support for REPORTING OPTIONS == 3 in REPORT SUPPORTED OPERATION CODES.
MFC after:	2 weeks
2016-12-21 20:19:12 +00:00
Alexander Motin
33e7ba9cf9 Add support for SITUA bit in Logical Block Provisioning mode page.
VMware tries to enable this bit to avoid multiple threshold notifications
in case of multiple initiators connected to the same LUN.  Unfortunately
their code sends MODE SELECT(6) request with parameter length hardcoded
for the page without any thresholds.  Since we have four threshold and our
page is bigger, this attempt fails, that is correct in my understanding.
So all we can do about this now is to report proper error code and hope
VMware fix their code one day.

MFC after:	2 weeks
2016-12-21 15:17:47 +00:00
Alexander Motin
3157c36886 Fix UUID formatting added in r310360. Oops!
MFC after:	2 weeks
2016-12-21 09:49:16 +00:00
Alexander Motin
00d72d5714 Report UUID and MD5 LUN IDs.
MFC after:	2 weeks
2016-12-21 09:36:23 +00:00
Alexander Motin
f383d6efd5 Add support for locally assigned RFC 4122 UUID LUN identifiers.
MFC after:	2 weeks
2016-12-21 09:05:30 +00:00
Alexander Motin
171e4b68b3 Bump specifications support to SAM-6/SPC-5. 2016-12-20 21:58:43 +00:00
Alexander Motin
1f0694a680 Improve error handling when I/O split between several BIOs.
If we get several error codes, handle one with lowest offset.

MFC after:	2 weeks
2016-12-19 21:27:18 +00:00
Alexander Motin
32920cbfa3 When reporting "Logical block address out of range" error, report the LBA
in sense data INFORMATION field.

MFC after:	2 weeks
2016-12-19 19:00:03 +00:00
Alexander Motin
b9985489dd When writing fixed format sense data, set VALID bit only if provided value
for INFORMATION field fit into available 4 bytes (has no non-zero bytes
except last 4), as explicitly required by SPC-5 specification.

MFC after:	2 weeks
2016-12-19 18:55:10 +00:00
Alexander Motin
c329b295dc Fix typo in function name. 2016-12-19 15:49:59 +00:00
Alexander Motin
f60639b79e Add new bits into Extended Inquiry VPD page.
MFC after:	2 weeks
2016-12-19 15:18:31 +00:00
Alexander Motin
7f900be181 Add support for NUAR bit in Control mode page.
MFC after:	2 weeks
2016-12-19 14:19:52 +00:00
Alexander Motin
1188787581 Add set of macros to simplify code access to mode pages fields.
MFC after:	2 weeks
2016-12-19 13:25:53 +00:00
Alexander Motin
f3ee47571e Following SPC-5, make REQUEST SENSE report "Logical unit not supported"
in returned parameter data for not accessible LUNs.

MFC after:	2 weeks
2016-12-19 11:44:41 +00:00
Alexander Motin
d9ba4eefdc Improve support for informational exceptions.
While CTL still has no real events to report in this way (like SMART),
it is possible to trigger false event by manually setting TEST bit in
Informational Exceptions Control mode page, that can be useful for
initiator testing.  This code supports all flavours of IE reporting:
UNIT ATTENTION, RECOVERED ERROR and NO SENSE sense keys, REQUEST SENSE
command and Informational Exceptions log page.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2016-12-19 10:25:47 +00:00
Alexander Motin
b7599b7205 Don't treat informational exceptions (warnings and impending failures)
a.k.a. SCSI SMART events as errors.  Log them to console and continue.

MFC after:	2 weeks
2016-12-18 15:02:50 +00:00
Ed Schouten
4c484fd216 Add label annotations to CAM sysctls.
Under kern.cam we have certain sysctls that are per-device, such as the
ones under kern.cam.ada.[0-9]+.*. Add a "device_index" label annotation
to such sysctls, so that the Prometheus metrics exporter will give all
of those metrics the same name. The device number will be added to the
metric name as the "device_index" label.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D8775
2016-12-14 12:53:33 +00:00
Kenneth D. Merry
28db0a5e74 Add SCSI REPORT TIMESTAMP and SET TIMESTAMP support.
This adds support to camcontrol(8) and libcam(3) for getting and setting
the time on SCSI protocol drives.  This is more commonly found on tape
drives, but is a SPC (SCSI Primary Commands) command, and may be found
on any device that speaks SCSI.

The new camcontrol timestamp subcommand allows getting the current device
time or setting the time to the current system time or any arbitrary time.

sbin/camcontrol/Makefile:
	Add timestamp.c.

sbin/camcontrol/camcontrol.8:
	Document the new timestamp subcommand.

sbin/camcontrol/camcontrol.c:
	Add the timestamp subcommand to camcontrol.

sbin/camcontrol/camcontrol.h:
	Add the timestamp() function prototype.

sbin/camcontrol/timestamp.c:
	Timestamp setting and reporting functionality.

sys/cam/scsi/scsi_all.c:
	Add two new CCB building functions, scsi_set_timestamp() and
	scsi_report_timestamp().  Also, add a new helper function,
	scsi_create_timestamp().

sys/cam/scsi/scsi_all.h:
	Add CDB and parameter data for the the set and report timestamp
	commands.

	Add function declarations for the new CCB building and helper
	functions.

Submitted by:	Sam Klopsch
Sponsored by:	Spectra Logic
MFC After:	2 weeks
2016-12-01 22:20:27 +00:00
Alexander Motin
7027c01c56 Make SES status updates more aggressive.
- On control request update all status pages, since they may also be
affected if user enables/disables enclosure slots.
 - Periodically update element descriptors too, since there is some
hardware where they are changed dynamically.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2016-11-29 13:48:36 +00:00
Alexander Motin
ab4327bb3f Explicitly initialize cdai.flags.
In SES driver uninitialized value caused unreliable physpath reporting.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2016-11-29 11:13:43 +00:00
Alan Somers
2edc027cf0 Fix "camcontrol rescan" with SATA drives behind a SAS controller
A bug in CAM's serial number hash logic resulted in SATA drives behind a SAS
controller getting removed and readded anytime the drive was rescanned for
any reason.

PR:		212914
Submitted by:	kadesai
Reported by:	kadesai
Reviewed by:	asomers, ken
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2016-11-17 20:42:56 +00:00
Bryan Drewery
28323add09 Fix improper use of "its".
Sponsored by:	Dell EMC Isilon
2016-11-08 23:59:41 +00:00
Conrad Meyer
8fc77fff81 cam: Zero bio pointer in user-supplied SCSI CCBs
The BUF_TRACKING bio pointer only makes sense for kernel consumers of
CCBs.

PR:		214250
Reported by:	trasz@
Reviewed by:	imp@, markj@
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8477
2016-11-08 21:17:24 +00:00
Alexander Motin
bceff6e30a Add support for EIIOE flag in Additional Element Status.
It was added in SES-3 spec, and its support required to properly link
the Additional Element Status page data to the original elements.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2016-11-07 18:21:53 +00:00
Scott Long
34cc1bf804 If the da periph probe state machine gets an asc=0x44 error, the periph
is not going to recover until the system is reset.  Treat it as a special
case and don't allow it to fall through to quasi-success.

Reviewed by:	ken, imp
Obtained from:	Netflix
MFC after:	3 days
2016-11-04 17:08:52 +00:00
Scott Long
b575f33f67 asc/ascq 44/0 is typically a non-transient, permanent error (at least until
the components are reset).  Therefore retries are pointless.  This is very
visible in SATL systems, for example an LSI SAS controller and a SATA HDD/SSD.

Reviewed by:	ken
Obtained from:	Netflix
MFC after:	3 days
2016-11-04 16:56:36 +00:00
Edward Tomasz Napierala
a851d1fbfd Check for lengths being <= 0. Note that this interface can only
be accessed by root.  It uses unsigned ints instead of size_t
to preserve the ABI.

PR:		207627
Submitted by:	ryan@ryanday.net (with slight tweaks)
MFC after:	1 month
2016-11-03 10:11:59 +00:00
Conrad Meyer
8532d381a9 Add BUF_TRACKING and FULL_BUF_TRACKING buffer debugging
Upstream the BUF_TRACKING and FULL_BUF_TRACKING buffer debugging code.
This can be handy in tracking down what code touched hung bios and bufs
last. The full history is especially useful, but adds enough bloat that
it shouldn't be enabled in release builds.

Function names (or arbitrary string constants) are tracked in a
fixed-size ring in bufs. Bios gain a pointer to the upper buf for
tracking. SCSI CCBs gain a pointer to the upper bio for tracking.

Reviewed by:	markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8366
2016-10-31 23:09:52 +00:00
Alexander Motin
a1a604ca90 Make pass driver better support CAM_CDB_POINTER flag.
Previously pass driver just ignored the flag, making random kernel code
access user-space pointer, sometime causing crashes even for correctly
written applications if user-level context was switched or swapped out.
This patch tries to copyin the CDB into kernel space to avoid it.

MFC after:	2 weeks
2016-10-17 15:02:17 +00:00
Alexander Motin
bc9d8bd59e Revert timeout part of r307507.
I misread 5 minutes as 5 seconds.  Timeout of 5 minutes may have sense.

MFC after:	2 weeks
2016-10-17 09:16:44 +00:00
Alexander Motin
55a1720717 Replicate r307507 for ATA disks.
MFC after:	2 weeks
2016-10-17 08:38:24 +00:00
Alexander Motin
3d946e4f5e Consider device as clean even if SYNCHRONIZE CACHE failed.
If device reservation was preempted by other initiator, our sync request
will always fail.  Without this change CAM tried to sync cache on every
following device close, including numerous GEOM tasting opens/closes,
causing lots of useless noise in logs.

While there, increase SYNCHRONIZE CACHE timeout to default value.

MFC after:	2 weeks
2016-10-17 08:35:56 +00:00
Alexander Motin
4928a0c224 Add LU option to control reported provisioning type.
MFC after:	2 weeks
2016-10-15 14:40:34 +00:00
Alexander Motin
15fd2e2412 Add LUN options to limit UNMAP and WRITE SAME sizes.
CTL itself has no limits on on UNMAP and WRITE SAME sizes.  But depending
on backends large requests may take too much time.  To avoid that new
configuration options allow to hint initiator maximal sizes it should not
exceed.

MFC after:	2 weeks
2016-10-15 10:29:33 +00:00
Alexander Motin
25ee4c0429 Use copyout() instead of pointing sbuf to user-space buffer.
MFC after:	2 weeks
2016-10-12 08:25:13 +00:00
Alexander Motin
7061250472 Fix copy/paste bug in r306747.
Submitted by:	emaste, pfg
MFC after:	3 days
2016-10-11 15:27:39 +00:00
Alexander Motin
d3c5b1fea9 Fix ABI compat shims, broken by adding NVMe support.
MFC after:	1 week
2016-10-06 01:14:10 +00:00
Mark Johnston
f30cad3355 CAM ccbq sanity: checks on insert and remove
KASSERT in cam_ccbq_insert_ccb that only XPT_FC_QUEUED ops are queued,
and XPT_FC_USER_CCB ops are not. Otherwise cam_ccbq_ccb_done may be
skipped.

Bounds check the index used for camq_remove in order to panic instead
of scribble on removal of an out-of-bounds index (e.g. consider the
effect of camq_remove of CAM_UNQUEUED_INDEX).

KASSERT in cam_ccbq_remove_ccb that the ccb removed by index was the
one sought.

Submitted by:	Ryan Libby <rlibby@gmail.com>
Reviewed by:	imp, mav
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8151
2016-10-05 17:18:24 +00:00
Alexander Motin
769cbdb7a3 Do not retry on some security sense codes.
MFC after:	1 week
2016-10-05 00:45:58 +00:00
Mark Johnston
991b5d2630 cam_periph_ccbwait could return while ccb in progress
In cam_periph_runccb, cam_periph_ccbwait was using the value of the ccb
pinfo.index and status fields to determine whether the ccb was done,
but these fields are updated without a contending lock and could glitch
into states that would be erroneously interpreted as done.  Instead,
have cam_periph_ccbwait look for the explicit result of the function
cam_periph_done.

Submitted by:	Ryan Libby <rlibby@gmail.com>
Reviewed by:	mav
MFC after:	3 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8020
2016-09-30 21:00:09 +00:00
Warner Losh
cf3ec15167 Compute two new metrics. Disk load, the average number of transactions
we have queued up normaliazed to the queue size. Also compute buckets
of latency to help compute, in userland, estimates of Median, P90, P95
and P99 values.

Sponsored by: Netflix, Inc
2016-09-30 17:49:04 +00:00
Sepherosa Ziehau
a11463fd84 cam/ata: Allow drivers to veto ATA disk attachment.
This eventhandler is mainly used by VMs, e.g. Hyper-V, whose disk
controllers share the disks with the simulated ATA 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-28 08:35:05 +00:00
Mark Johnston
dda945f50a Protect ccbq access with devq->send_mtx in the XPT_ABORT handler.
Submitted by:	Ryan Libby <rlibby@gmail.com>
Reviewed by:	mav
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7985
2016-09-21 00:08:42 +00:00
Alexander Motin
cd3752643c Don't report to devd statuses that CAM doesn't consider errors.
Some statuses, such as "ATA pass through information available", are part
part of absolutely normal operation and do not worth reporting.

MFC after:	2 weeks
2016-09-08 13:33:33 +00:00
Alexander Motin
5d18110a7f "Extended copy information available" is not an error either.
MFC after:	2 weeks
2016-09-08 13:03:49 +00:00
Alexander Motin
6867747328 "ATA pass through information available" is not an error.
MFC after:	2 weeks
2016-09-08 12:58:33 +00:00
Alexander Motin
d4a08767ba Decode ATA Status Return descriptor.
MFC after:	2 weeks
2016-09-08 12:00:02 +00:00
Alexander Motin
1e3d53e2c4 Decode some new ATA commands found in ACS-3.
MFC after:	1 week
2016-08-27 19:51:37 +00:00
Navdeep Parhar
97b84d344d Make the iSCSI parameter negotiation more flexible.
Decouple the send and receive limits on the amount of data in a single
iSCSI PDU.  MaxRecvDataSegmentLength is declarative, not negotiated, and
is direction-specific so there is no reason for both ends to limit
themselves to the same min(initiator, target) value in both directions.

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

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

Reviewed by:	jpaetzel@ (earlier version), trasz@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7279
2016-08-25 05:22:53 +00:00
Warner Losh
3f04cc100f Improve the pattern matching so that internal *'s work, as well as
[set] notation. This fixes pattern matching for recently added drives
that would set the NCQ Trim being broken incorrectly.

PR: 210686
Tested-by: Tomoaki AOKI
MFC After: 3 days
2016-08-19 04:30:29 +00:00
Sepherosa Ziehau
0ea702cd46 cam/da: Add quirk for I-O Data USB Flash Disk
PR:		211716
Submitted by:	Jun Su <junsu microsoft com>
Reported by:	Jun Su <junsu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft
2016-08-11 03:12:56 +00:00
Pedro F. Giffuni
a061aa46fe sys: replace comma with semicolon when pertinent.
Uses of commas instead of a semicolons can easily go undetected. The comma
can serve as a statement separator but this shouldn't be abused when
statements are meant to be standalone.

Detected with devel/coccinelle following a hint from DragonFlyBSD.

MFC after:	1 month
2016-08-09 19:42:20 +00:00
Warner Losh
08f1387933 Move protocol specific stuff into a linker set object that's
per-protocol. This reduces the number scsi symbols references by
cam_xpt significantly, and eliminates all ata / nvme symbols. There's
still some NVME / ATA specific code for dealing with XPT_NVME_IO and
XPT_ATA_IO respectively, and a bunch of scsi-specific code, but this
is progress.

Differential Revision: https://reviews.freebsd.org/D7289
2016-07-28 22:55:21 +00:00
Warner Losh
ded2b70617 Switch to linker sets to find the xport callback object. This
eliminates the need to special case everything in cam_xpt for new
transports. It is now a failure to not have a transport object when
registering the bus as well. You can still, however, create a
transport that's unspecified (XPT_)

Differential Revision: https://reviews.freebsd.org/D7289
2016-07-28 22:55:14 +00:00
Warner Losh
964fee41a3 Remove some extraneous printfs. 2016-07-25 19:16:30 +00:00
Warner Losh
e0ce51cb80 Remove some bogus comments and printfs. Also, we can't
cam_periph_releaes_locked() at the end of nvme_probe_start because we
hit an assertion which may be bogus. Instead, leak a periph until we
sort it out. Since these devices don't arrive and depart often, so
this is the lessor of two evils.

MFC after: 1 week
2016-07-21 03:11:37 +00:00
Warner Losh
336b7b6665 Fix mismerge and add NVME xport support to devstat (or rather, exclude
it from SCSI).

MFC after: 1 week
2016-07-21 03:11:36 +00:00
Warner Losh
b24ced67d0 Fix mismerge and include the nvme support.
Also, print out the name of any CCB's functions that's not supported.

MFC after: 1 week
2016-07-21 03:11:35 +00:00
Alexander Motin
db8e94bb3b Restore PIM_ATA_EXT flag handling, lost at r300207.
This re-enables NCQ TRIM usage on capable hardware (bhyve).
2016-07-17 14:17:58 +00:00
Warner Losh
035ec48e55 Tidy up loose ends from Netflix I/O sched rename to dynamic I/O sched.
Rename kern.cam.do_netflix_iosched sysctl to
kern.cam.do_dynamic_iosched.

Approved by: re (kib@)
2016-07-07 20:31:35 +00:00
Sean Bruno
3f7606d5a3 Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length.
PR:	202625
Submitted by:	niakrisn@gmail.com
Reviewed by:	scottl kenm
Approved by:	re (gjb)
MFC after:	2 weeks
2016-06-29 16:41:37 +00:00
Sean Bruno
795b21ec94 Revert svn r302253 at the request/review of Ken M. This commit is
incorrect.

PR:		202625
Approved by:	re (implicit)
2016-06-28 18:32:15 +00:00
Sean Bruno
9df32773f3 Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length.
PR:		202625
Submitted by:	niakrisn@gmail.com
Reviewed by:	scottl
Approved by:	re (hrs)
MFC after:	2 weeks
2016-06-28 18:08:47 +00:00
Warner Losh
df2362478e Rename CAM_NETFLIX_IOSCHED to CAM_IOSCHED_DYNAMIC to better reflect
its nature.

Approved by: re
Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D6811
2016-06-23 23:20:58 +00:00
Warner Losh
f24c011beb Commit the bits of nda that were missed. This should fix the build.
Approved by: re@
2016-06-10 06:04:53 +00:00
Warner Losh
baabaca31b New NVMe front end (nda). 2016-06-09 22:39:02 +00:00
Warner Losh
bbb19fc720 Add place holder for SDIO CAM stuff for CCB XPT type.
Sponsored by: Netflix
2016-06-09 16:05:56 +00:00
Warner Losh
7b05c3e3c1 Add NVME IO type. 2016-06-09 16:05:49 +00:00
Warner Losh
69be012ff2 Improve debugging of xpt.
Sponsored by: Netflix
2016-06-09 16:05:40 +00:00
Conrad Meyer
75548271a9 Fix memory leaks in (a|)daregister introduced in r298002
In the case where cam_iosched_init() fails, the ada and da softcs were leaked.
Instead, free them.

Reported by:	Coverity
CID:		1356039
Sponsored by:	EMC / Isilon Storage Division
2016-06-07 20:33:55 +00:00
Edward Tomasz Napierala
4e5408f10c Report negotiated MaxBurstLength and FirstBurstLength in "iscsictl -v"
and "ctladm islist -v" outputs.

MFC after:	1 month
2016-06-05 08:48:37 +00:00
Alan Somers
583febf416 Strip leading spaces off of a SCSI disk's serial number
sys/cam/scsi/scsi_xpt.c
	Strip leading spaces off of a SCSI disk's reported serial number
	when populating the CAM serial number. This affects the output of
	"diskinfo -v" and the names of /dev/diskid/DISK-* device nodes,
	among other things.

	SPC5r05 says that the Product Serial Number field from the Unit
	Serial Number VPD page is right-aligned. So any leading spaces are
	not part of the actual serial number. Most devices don't left-pad
	their serial numbers, but some do. In particular, the SN VPD page
	that an LSI HBA emulates for a SATA drive contains enough
	left-padding to fill a 20-byte field.

UPDATING
	Add a note to UPDATING, because some users may have to update
	/etc/fstab or geom labels.

Reviewed by:	ken, mav
MFC after:	Never
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6516
2016-05-27 22:26:43 +00:00
Kenneth D. Merry
600fd98ff3 Fix a few ada(4) driver issues:
o Some Samsung drives do not support the ATA READ LOG EXT or READ
   LOG DMA EXT commands, despite indicating that they do in their
   IDENTIFY data.  So, fix this in two ways:
	1. Only start the log directory probe (ADA_STATE_LOGDIR) if
	   the drive claims to be an SMR drive in the first place.
	   We don't need to do the extra probing for other devices.
	   This will also serve to prevent problems with other
	   drives that have the same issue.
	2. Add quirks for the two Samsung drives that have been
	   reported so far (thanks to Oleg Nauman and Alex Petrov).
	   If there is a reason to do a Read Log later on, we will
	   know that it doesn't work on these drives.

 o Add a quirk entry to mark Seagate Lamarr Drive Managed drives as
   drive managed.  They don't report this in their Identify data.

sys/cam/ata/ata_da.c:
	Add two new quirks:
	1. ADA_Q_LOG_BROKEN, for drives that claim to support Read
	   Log but don't really.
	2. ADA_Q_SMR_DM, for drives that are Drive Managed SMR, but
	   don't report it.  This can matter for software that
	   wants to know when it should make an extra effort to
	   write sequentially.

	Record two Samsung drives that don't support Read Log, and
	one Seagate drive that doesn't report that it is a SMR drive.
	The Seagate drive is already recorded in the da(4) driver.

	We may have to come up with a similar solution in the da(4)
	driver for SATA drives that don't properly support Read Log.

	In adasetflags(), Dont' set the ADA_FLAG_CAN_LOG bit if the
	device has the LOG_BROKEN quirk set.  Also, look at the
	SMR_DM quirk and set the device type accordingly if it is
	actually a drive managed drive.

	When deciding whether to go into the LOGDIR probe state,
	look to see whether the device claims to be an SMR device.
	If not, don't bother with the LOGDIR probe state.

Sponsored by:	Spectra Logic
2016-05-25 01:37:39 +00:00
Edward Tomasz Napierala
b891159418 Add mechanism for choosing iSER-capable ICL modules.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-24 08:44:45 +00:00
Don Lewis
95320acebc Fix multiple Coverity Out-of-bounds access false postive issues in CAM
The currently used idiom for clearing the part of a ccb after its
header generates one or two Coverity errors for each time it is
used.  All instances generate an Out-of-bounds access (ARRAY_VS_SINGLETON)
error because of the treatment of the header as a two element array,
with a pointer to the non-existent second element being passed as
the starting address to bzero().  Some instances also alsp generate
Out-of-bounds access (OVERRUN) errors, probably because the space
being cleared is larger than the sizeofstruct ccb_hdr).

In addition, this idiom is difficult for humans to understand and
it is error prone.  The user has to chose the proper struct ccb_*
type (which does not appear in the surrounding code) for the sizeof()
in the length calculation.  I found several instances where the
length was incorrect, which could cause either an actual out of
bounds write, or incompletely clear the ccb.

A better way is to write the code to clear the ccb itself starting
at sizeof(ccb_hdr) bytes from the start of the ccb, and calculate
the length based on the specific type of struct ccb_* being cleared
as specified by the union ccb member being used.  The latter can
normally be seen in the nearby code.  This is friendlier for Coverity
and other static analysis tools because they will see that the
intent is to clear the trailing part of the ccb.

Wrap all of the boilerplate code in a convenient macro that only
requires a pointer to the desired union ccb member (or a pointer
to the union ccb itself) as an argument.

Reported by:	Coverity
CID:		1007578, 1008684, 1009724, 1009773, 1011304, 1011306
CID:		1011307, 1011308, 1011309, 1011310, 1011311, 1011312
CID:		1011313, 1011314, 1011315, 1011316, 1011317, 1011318
CID:		1011319, 1011320, 1011321, 1011322, 1011324, 1011325
CID:		1011326, 1011327, 1011328, 1011329, 1011330, 1011374
CID:		1011390, 1011391, 1011392, 1011393, 1011394, 1011395
CID:		1011396, 1011397, 1011398, 1011399, 1011400, 1011401
CID:		1011402, 1011403, 1011404, 1011405, 1011406, 1011408
CID:		1011409, 1011410, 1011411, 1011412, 1011413, 1011414
CID:		1017461, 1018387, 1086860, 1086874, 1194257, 1229897
CID:		1229968, 1306229, 1306234, 1331282, 1331283, 1331294
CID:		1331295, 1331535, 1331536, 1331539, 1331540, 1341623
CID:		1341624, 1341637, 1341638, 1355264, 1355324
Reviewed by:	scottl, ken, delphij, imp
MFH:		1 month
Differential Revision:	https://reviews.freebsd.org/D6496
2016-05-24 00:57:11 +00:00
Kenneth D. Merry
3f54ec85e8 Fix ada(4) trim support quirk setting.
I broke broke the quirk in the ada(4) driver disabling NCQ trim support
in revision 300207.  The support flags were set before the quirks were
loaded.

sys/cam/ata/ata_da.c:
	Call adasetflags() after loading quirks, so that we'll set the
	flags accurately.

Sponsored by:	Spectra Logic
2016-05-23 19:52:08 +00:00
Alexander Motin
96b5475b7a Pass task management response information from CTL through CAM to isp(4),
utilizing previously unused arg field of struct ccb_notify_acknowledge.

This makes new QUERY TASK, QUERY TASK SET and QUERY ASYNC EVENT requests
really functional for CAM target mode drivers.
2016-05-20 10:26:12 +00:00
Kenneth D. Merry
9a6844d55f Add support for managing Shingled Magnetic Recording (SMR) drives.
This change includes support for SCSI SMR drives (which conform to the
Zoned Block Commands or ZBC spec) and ATA SMR drives (which conform to
the Zoned ATA Command Set or ZAC spec) behind SAS expanders.

This includes full management support through the GEOM BIO interface, and
through a new userland utility, zonectl(8), and through camcontrol(8).

This is now ready for filesystems to use to detect and manage zoned drives.
(There is no work in progress that I know of to use this for ZFS or UFS, if
anyone is interested, let me know and I may have some suggestions.)

Also, improve ATA command passthrough and dispatch support, both via ATA
and ATA passthrough over SCSI.

Also, add support to camcontrol(8) for the ATA Extended Power Conditions
feature set.  You can now manage ATA device power states, and set various
idle time thresholds for a drive to enter lower power states.

Note that this change cannot be MFCed in full, because it depends on
changes to the struct bio API that break compatilibity.  In order to
avoid breaking the stable API, only changes that don't touch or depend on
the struct bio changes can be merged.  For example, the camcontrol(8)
changes don't depend on the new bio API, but zonectl(8) and the probe
changes to the da(4) and ada(4) drivers do depend on it.

Also note that the SMR changes have not yet been tested with an actual
SCSI ZBC device, or a SCSI to ATA translation layer (SAT) that supports
ZBC to ZAC translation.  I have not yet gotten a suitable drive or SAT
layer, so any testing help would be appreciated.  These changes have been
tested with Seagate Host Aware SATA drives attached to both SAS and SATA
controllers.  Also, I do not have any SATA Host Managed devices, and I
suspect that it may take additional (hopefully minor) changes to support
them.

Thanks to Seagate for supplying the test hardware and answering questions.

sbin/camcontrol/Makefile:
	Add epc.c and zone.c.

sbin/camcontrol/camcontrol.8:
	Document the zone and epc subcommands.

sbin/camcontrol/camcontrol.c:
	Add the zone and epc subcommands.

	Add auxiliary register support to build_ata_cmd().  Make sure to
	set the CAM_ATAIO_NEEDRESULT, CAM_ATAIO_DMA, and CAM_ATAIO_FPDMA
	flags as appropriate for ATA commands.

	Add a new get_ata_status() function to parse ATA result from SCSI
	sense descriptors (for ATA passthrough over SCSI) and ATA I/O
	requests.

sbin/camcontrol/camcontrol.h:
	Update the build_ata_cmd() prototype

	Add get_ata_status(), zone(), and epc().

sbin/camcontrol/epc.c:
	Support for ATA Extended Power Conditions features.  This includes
	support for all features documented in the ACS-4 Revision 12
	specification from t13.org (dated February 18, 2016).

	The EPC feature set allows putting a drive into a power power mode
	immediately, or setting timeouts so that the drive will
	automatically enter progressively lower power states after various
	idle times.

sbin/camcontrol/fwdownload.c:
	Update the firmware download code for the new build_ata_cmd()
	arguments.

sbin/camcontrol/zone.c:
	Implement support for Shingled Magnetic Recording (SMR) drives
	via SCSI Zoned Block Commands (ZBC) and ATA Zoned Device ATA
	Command Set (ZAC).

	These specs were developed in concert, and are functionally
	identical.  The primary differences are due to SCSI and ATA
	differences.  (SCSI is big endian, ATA is little endian, for
	example.)

	This includes support for all commands defined in the ZBC and
	ZAC specs.

sys/cam/ata/ata_all.c:
	Decode a number of additional ATA command names in ata_op_string().

	Add a new CCB building function, ata_read_log().

	Add ata_zac_mgmt_in() and ata_zac_mgmt_out() CCB building
	functions.  These support both DMA and NCQ encapsulation.

sys/cam/ata/ata_all.h:
	Add prototypes for ata_read_log(), ata_zac_mgmt_out(), and
	ata_zac_mgmt_in().

sys/cam/ata/ata_da.c:
	Revamp the ada(4) driver to support zoned devices.

	Add four new probe states to gather information needed for zone
	support.

	Add a new adasetflags() function to avoid duplication of large
	blocks of flag setting between the async handler and register
	functions.

	Add new sysctl variables that describe zone support and paramters.

	Add support for the new BIO_ZONE bio, and all of its subcommands:
	DISK_ZONE_OPEN, DISK_ZONE_CLOSE, DISK_ZONE_FINISH, DISK_ZONE_RWP,
	DISK_ZONE_REPORT_ZONES, and DISK_ZONE_GET_PARAMS.

sys/cam/scsi/scsi_all.c:
	Add command descriptions for the ZBC IN/OUT commands.

	Add descriptions for ZBC Host Managed devices.

	Add a new function, scsi_ata_pass() to do ATA passthrough over
	SCSI.  This will eventually replace scsi_ata_pass_16() -- it
	can create the 12, 16, and 32-byte variants of the ATA
	PASS-THROUGH command, and supports setting all of the
	registers defined as of SAT-4, Revision 5 (March 11, 2016).

	Change scsi_ata_identify() to use scsi_ata_pass() instead of
	scsi_ata_pass_16().

	Add a new scsi_ata_read_log() function to facilitate reading
	ATA logs via SCSI.

sys/cam/scsi/scsi_all.h:
	Add the new ATA PASS-THROUGH(32) command CDB.  Add extended and
	variable CDB opcodes.

	Add Zoned Block Device Characteristics VPD page.

	Add ATA Return SCSI sense descriptor.

	Add prototypes for scsi_ata_read_log() and scsi_ata_pass().

sys/cam/scsi/scsi_da.c:
	Revamp the da(4) driver to support zoned devices.

	Add five new probe states, four of which are needed for ATA
	devices.

	Add five new sysctl variables that describe zone support and
	parameters.

	The da(4) driver supports SCSI ZBC devices, as well as ATA ZAC
	devices when they are attached via a SCSI to ATA Translation (SAT)
	layer.  Since ZBC -> ZAC translation is a new feature in the T10
	SAT-4 spec, most SATA drives will be supported via ATA commands
	sent via the SCSI ATA PASS-THROUGH command.  The da(4) driver will
	prefer the ZBC interface, if it is available, for performance
	reasons, but will use the ATA PASS-THROUGH interface to the ZAC
	command set if the SAT layer doesn't support translation yet.
	As I mentioned above, ZBC command support is untested.

	Add support for the new BIO_ZONE bio, and all of its subcommands:
	DISK_ZONE_OPEN, DISK_ZONE_CLOSE, DISK_ZONE_FINISH, DISK_ZONE_RWP,
	DISK_ZONE_REPORT_ZONES, and DISK_ZONE_GET_PARAMS.

	Add scsi_zbc_in() and scsi_zbc_out() CCB building functions.

	Add scsi_ata_zac_mgmt_out() and scsi_ata_zac_mgmt_in() CCB/CDB
	building functions.  Note that these have return values, unlike
	almost all other CCB building functions in CAM.  The reason is
	that they can fail, depending upon the particular combination
	of input parameters.  The primary failure case is if the user
	wants NCQ, but fails to specify additional CDB storage.  NCQ
	requires using the 32-byte version of the SCSI ATA PASS-THROUGH
	command, and the current CAM CDB size is 16 bytes.

sys/cam/scsi/scsi_da.h:
	Add ZBC IN and ZBC OUT CDBs and opcodes.

	Add SCSI Report Zones data structures.

	Add scsi_zbc_in(), scsi_zbc_out(), scsi_ata_zac_mgmt_out(), and
	scsi_ata_zac_mgmt_in() prototypes.

sys/dev/ahci/ahci.c:
	Fix SEND / RECEIVE FPDMA QUEUED in the ahci(4) driver.

	ahci_setup_fis() previously set the top bits of the sector count
	register in the FIS to 0 for FPDMA commands.  This is okay for
	read and write, because the PRIO field is in the only thing in
	those bits, and we don't implement that further up the stack.

	But, for SEND and RECEIVE FPDMA QUEUED, the subcommand is in that
	byte, so it needs to be transmitted to the drive.

	In ahci_setup_fis(), always set the the top 8 bits of the
	sector count register.  We need it in both the standard
	and NCQ / FPDMA cases.

sys/geom/eli/g_eli.c:
	Pass BIO_ZONE commands through the GELI class.

sys/geom/geom.h:
	Add g_io_zonecmd() prototype.

sys/geom/geom_dev.c:
	Add new DIOCZONECMD ioctl, which allows sending zone commands to
	disks.

sys/geom/geom_disk.c:
	Add support for BIO_ZONE commands.

sys/geom/geom_disk.h:
	Add a new flag, DISKFLAG_CANZONE, that indicates that a given
	GEOM disk client can handle BIO_ZONE commands.

sys/geom/geom_io.c:
	Add a new function, g_io_zonecmd(), that handles execution of
	BIO_ZONE commands.

	Add permissions check for BIO_ZONE commands.

	Add command decoding for BIO_ZONE commands.

sys/geom/geom_subr.c:
	Add DDB command decoding for BIO_ZONE commands.

sys/kern/subr_devstat.c:
	Record statistics for REPORT ZONES commands.  Note that the
	number of bytes transferred for REPORT ZONES won't quite match
	what is received from the harware.  This is because we're
	necessarily counting bytes coming from the da(4) / ada(4) drivers,
	which are using the disk_zone.h interface to communicate up
	the stack.  The structure sizes it uses are slightly different
	than the SCSI and ATA structure sizes.

sys/sys/ata.h:
	Add many bit and structure definitions for ZAC, NCQ, and EPC
	command support.

sys/sys/bio.h:
	Convert the bio_cmd field to a straight enumeration.  This will
	yield more space for additional commands in the future.  After
	change r297955 and other related changes, this is now possible.
	Converting to an enumeration will also prevent use as a bitmask
	in the future.

sys/sys/disk.h:
	Define the DIOCZONECMD ioctl.

sys/sys/disk_zone.h:
	Add a new API for managing zoned disks.  This is very close to
	the SCSI ZBC and ATA ZAC standards, but uses integers in native
	byte order instead of big endian (SCSI) or little endian (ATA)
	byte arrays.

	This is intended to offer to the complete feature set of the ZBC
	and ZAC disk management without requiring the application developer
	to include SCSI or ATA headers.  We also use one set of headers
	for ioctl consumers and kernel bio-level consumers.

sys/sys/param.h:
	Bump __FreeBSD_version for sys/bio.h command changes, and inclusion
	of SMR support.

usr.sbin/Makefile:
	Add the zonectl utility.

usr.sbin/diskinfo/diskinfo.c
	Add disk zoning capability to the 'diskinfo -v' output.

usr.sbin/zonectl/Makefile:
	Add zonectl makefile.

usr.sbin/zonectl/zonectl.8
	zonectl(8) man page.

usr.sbin/zonectl/zonectl.c
	The zonectl(8) utility.  This allows managing SCSI or ATA zoned
	disks via the disk_zone.h API.  You can report zones, reset write
	pointers, get parameters, etc.

Sponsored by:	Spectra Logic
Differential Revision:	https://reviews.freebsd.org/D6147
Reviewed by:	wblock (documentation)
2016-05-19 14:08:36 +00:00
Eitan Adler
cef367e6a1 Don't repeat the the word 'the'
(one manual change to fix grammar)

Confirmed With: db
Approved by: secteam (not really, but this is a comment typo fix)
2016-05-17 12:52:31 +00:00
Edward Tomasz Napierala
f41492b00f Add icl_conn_connect() ICL method, required for iSER.
Obtained from:	Mellanox Technologies (earlier version)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-17 11:10:44 +00:00
Mark Johnston
565e7fd3bc opt_kdtrace.h is not needed for SDT probes as of r258541. 2016-05-15 20:04:43 +00:00
Alexander Motin
ed246e8260 Allow sleepable allocations in enclosure daemon threads.
There were at least two places where M_NOWAIT was used without NULL check.
This change should fix NULL-dereference panic there and possibly improve
operation in other ways under memory pressure.

MFC after:	2 weeks
2016-05-10 16:20:36 +00:00
Edward Tomasz Napierala
d68fae5849 Add "camcontrol reprobe" subcommand, and implement it for da(4).
This makes it possible to manually force updating capacity data
after the disk got resized. Without it it might be neccessary to
reboot before FreeBSD notices updated disk size under eg VMWare.

Discussed with:	imp@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6108
2016-05-10 15:46:33 +00:00
Alexander Motin
8fadf66094 Fix previous commit to report proper error code.
MFC after:	2 weeks
2016-05-10 08:37:41 +00:00
Alexander Motin
38618bf430 Validate XCOPY range offsets and lengths.
MFC after:	2 weeks
2016-05-10 08:28:16 +00:00
Alexander Motin
e13f4248db More XCOPY parameters validation.
MFC after:	2 weeks
2016-05-10 08:08:39 +00:00
Alexander Motin
3eb7651aad Improve validation of some POPULATE TOKEN parameters.
MFC after:	2 weeks
2016-05-10 07:14:49 +00:00
Pedro F. Giffuni
ea0ccffc39 cam/scsi: Remove mostly unused scsi_quirk_table_size.
It was only being used only once and it can be directly replaced
instead.
2016-05-06 16:51:56 +00:00
Pedro F. Giffuni
c1f403238a sys/cam/scsi: unsigned some loop indexes.
Although usually small, values produced by nitems() are unsigned.
One more case where unsgining the index may be useful.
2016-05-06 15:36:25 +00:00
Pedro F. Giffuni
2a392dd62b sys/cam/scsi: unsigned some loop indexes.
Although usually small, values produced by nitems() are unsigned.
By unsigning the corresponding indexes we avoid signed vs unsigned
comparisons. This may have some effect on performance, although given the
small sizes the effect will not be perceivable and it makes the code
clearer.
2016-05-06 15:13:44 +00:00
Scott Long
de482e7bbb Fix a memory leak in the devctl notify code.
Submitted by:	markj
MFC after:	asap
2016-05-03 14:30:26 +00:00
Pedro F. Giffuni
1ffe58516c sys/cam: spelling fixes in comments.
No functional change.
2016-04-29 21:05:48 +00:00
Pedro F. Giffuni
d63978e2b6 sys/cam: spelling fixes.
Affects a debug message.

MFC after: 2 weeks
2016-04-29 21:04:06 +00:00
Pedro F. Giffuni
e45a63ee67 Small typos. 2016-04-28 15:18:28 +00:00
Pedro F. Giffuni
167e63e394 cam: unsign some types to match their definitions and avoid overflows.
numpatterns is u_int.

ctl:
CTL_NUM_MODE_PAGES comes from sizeof().
In struct:ctl_scsiio, kern_sg_entries is uint32_t.

MFC after:	2 weeks
2016-04-27 15:35:05 +00:00
Pedro F. Giffuni
55e0987aea sys: extend use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 15:38:17 +00:00
Pedro F. Giffuni
a380994fff Yet more redundant parenthesis from r298431.
Mea culpa.
2016-04-21 20:30:38 +00:00
Pedro F. Giffuni
323b076e9c sys: use our nitems() macro when param.h is available.
This should cover all the remaining cases in the kernel.

Discussed in:	freebsd-current
2016-04-21 19:40:10 +00:00
Pedro F. Giffuni
8dfea46460 Remove slightly used const values that can be replaced with nitems().
Suggested by:	jhb
2016-04-21 15:38:28 +00:00
Sean Bruno
bbea316cc8 Plug memory leak in ctl(4) when ctl_copyin_args() is called with a non-
null terminated ASCII string.

PR:		207626
Submitted by:	cturt@hardenedbsd.org
MFC after:	2 days
2016-04-19 16:48:14 +00:00
Alan Somers
f94033f407 Add the ability to read a SAS device's Target Port NAA designator
sys/cam/scsi/scsi_all.h
sys/cam/scsi/scsi_all.c
	Add the scsi_devid_is_port_naa helper function

Reviewed by:	ken
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D5975
2016-04-18 15:01:59 +00:00