Commit Graph

310 Commits

Author SHA1 Message Date
Gordon Bergling
c17b2a79bd camcontrol(8): Fix some warnings spotted by mandoc
- skipping paragraph macro: Pp before Bl
2020-11-20 11:45:08 +00:00
Ilya Bakulin
3f3878075e Add help messages for camcontrol(8) MMCCAM functionality
This adds the help messages for camcontrol(8) in-binary help.
Man page will follow in the separate change.

Reviewed by:	bz
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D25963
2020-10-30 18:55:08 +00:00
Gordon Bergling
6444039275 camcontrol(8): Bugfixes for some issues reported by mandoc
- new sentence, new line

MFC after:	1 week
2020-10-03 18:40:02 +00:00
Ilya Bakulin
badc50c270 Make it possible to get/set MMC frequency from camcontrol
Enhance camcontrol(8) so that it's possible to manually set frequency for SD/MMC cards.
While here, display more information about the current controller, such as
supported operating modes and VCCQ voltages, as well as current VCCQ voltage.

Reviewed by:	manu
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D25795
2020-07-24 21:14:59 +00:00
Ryan Libby
36947e1f4d Declare packed struct ata_params as 2-byte-aligned
This avoids gcc9 warning about unaligned access to the structure when
casting to uint16_t pointer type.

Submitted by:	imp
Reviewed by:	imp
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D22888
2019-12-21 02:44:00 +00:00
Alexander Motin
5233eb9dc6 Properly detect ATA sanitize errors.
It seems I read specifications not careful enough.  There are devices not
setting successful completion bit, causing previous code report false error.

MFC after:	1 week
2019-12-15 23:28:53 +00:00
Alexander Motin
f97cf1a168 Fix off-by-one error in HPA/AMA maximum reporting.
Before my refactoring the code reported value as maximum number of sectors,
adding one to the maximum sector number returned by respective command.
While this difference is somewhat confusing, restore previous behavior.

MFC after:	3 days
2019-11-22 15:41:47 +00:00
Alexander Motin
34454e9a6e Remove Tagged Command Queuing feature reporting.
I never saw those devices myself, FreeBSD never supported them, and it is
officially obsolete since ACS-2 specification.

MFC after:	3 days
2019-09-12 17:42:37 +00:00
Alexander Motin
43e22acce2 Report Trusted Computing feature set support.
It practically means the device is SED.

MFC after:	3 days
2019-09-12 17:20:51 +00:00
Alexander Motin
5b7145c6d4 Remove struct ata_res_pass16, unneeded after r352082.
MFC after:	4 days
2019-09-10 23:51:46 +00:00
Alexander Motin
576649b30a Initialize page/subpage in case of modepage -d.
Previously without -m parameter it worked mostly by concodence.

While there, make page/subpage values validation more strict.

MFC after:	5 days
Sponsored by:	iXsystems, Inc.
2019-09-09 22:08:22 +00:00
Alexander Motin
2090029769 Add one more error message to r352082.
MFC after:	5 days
Sponsored by:	iXsystems, Inc.
2019-09-09 19:00:37 +00:00
Alexander Motin
ca847845e3 Fix number of problems found while testing on SAT devices.
- Remove incomplete and dangerous ata_res decoding from ata_do_cmd().
Instead switch all functions that need the result to use get_ata_status(),
doing the same, but more careful, also reducing code duplication.
 - Made get_ata_status() to also decode fixed format sense.  In many cases
it is still not enough to make it useful, since it can only report results
of 28-bit command, but it is slightly better then nothing.
 - Organize error reporting in ata_do_cmd(), so that if caller specified
AP_FLAG_CHK_COND, it is responsible for command errors (non-ioctl ones).
 - Make HPA/AMA errors not fatal for `identify` subcommand.
 - Fix reprobe() not being called on HPA/AMA when in quiet mode.
 - Remove not very useful messages from `format` and `sanitize` commands
with -y flag.  Once they started, they often can't be stopped any way.

MFC after:	5 days
Sponsored by:	iXsystems, Inc.
2019-09-09 17:36:29 +00:00
Alexander Motin
268c280675 Unify cam_send_ccb() error reporting.
Error there mean that command was not even executed, and all information
we have about it is errno, and cam_error_print() call is not very useful.
Plus it is most likely a programmatic error, that shoud not happen.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2019-09-07 16:52:40 +00:00
Alexander Motin
16614d3518 Supply SAT layer with valid transfer sizes.
This is a rework of r344701, that noticed that number of bytes passes to
8 bit sector count field gets truncated.  First decision was to not pass
anything, since ATA specs define the field as N/A.  But it appeared to be a
problem for some SAT devices, that require information about data transfer
to operate properly.  Some additional investigation shown that it is quite
a common practice to set unused fields of ATA commands (fortunately ATA
specs formally allow it) to supply the information to SAT layer.  I have
found SAS-SATA interposer that does not allow pass-through without it.

As side effect, reduce code duplication by removing ata_do_28bit_cmd()
function, replacing it with more universal ata_do_cmd().

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2019-09-07 15:56:00 +00:00
Alexander Motin
b7e08f9305 Make GCC happy about math in r350676.
MFC after:	1 week
2019-08-07 15:05:08 +00:00
Alexander Motin
0912877616 Make camcontrol modepage support block descriptors.
It allows to read and write block descriptors alike to mode page parameters.
It allows to change block size or short-stroke HDDs or overprovision SSDs.
Depenting on -P parameter the change can be either persistent or till reset.
In case of block size change device may need reformat after the setting.
In case of SSD overprovisioning format or sanitize may be needed to really
free the flash.

During implementation appeared that csio_encode_visit() can not handle
integers of more then 4 bytes, that makes 8-byte LBA handling awkward.
I had to split it into two 4-byte halves now.

MFC after:	1 week
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2019-08-07 14:45:10 +00:00
Alexander Motin
e341cfd279 Make camcontrol modepage to use 10 byte commands.
While old devices may not support 10 byte MODE SENSE/MODE SELECT commands,
new ones may not be able to report all mode pages with 6 byte commands.

This patch makes camcontrol by default start with 10 byte commands and
fall back to 6 byte on ILLEGAL REQUEST error, or 6 byte can be forced.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-07-30 20:58:56 +00:00
Alexander Motin
df8aa95b31 Use present now scsi_mode_sense_subpage().
MFC after:	2 weeks
2019-07-29 20:41:11 +00:00
Alexander Motin
d7c1da6153 Decode some more IDENTIFY DEVICE bits.
MFC after:	2 weeks
2019-07-28 20:17:40 +00:00
Alexander Motin
c15a591cbd Make camcontrol sanitize support also ATA devices.
ATA sanitize is functionally identical to SCSI, just uses different
initiation commands and status reporting mechanism.

While there, make kernel better handle sanitize commands and statuses.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-07-25 18:48:31 +00:00
Alexander Motin
0642bc1cbb Make camcontrol hpa and camcontrol ama trigger reprobe.
This makes OS automatically see the disk's new disk size.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-07-23 19:42:03 +00:00
Alexander Motin
512efccf6d Unify BTL parsing for camcontrol debug and reset.
This makes `camcontrol debug` also allow peripheral device specification.

While there, make BTL parser more strict and switch from strtok() to
strsep().

MFC after:	2 weeks
2019-07-22 17:08:18 +00:00
Alexander Motin
c1264e76cd Properly report ACS revisions alike to kernel.
MFC after:	2 weeks
2019-07-19 20:02:01 +00:00
Alexander Motin
89b35a5274 Add Accessible Max Address Configuration support to camcontrol.
AMA replaced HPA in ACS-3 specification.  It allows to limit size of the
disk alike to HPA, but declares inaccessible data as indeterminate.  One
of its practical use cases is to under-provision SATA SSDs for better
reliability and performance.

While there, fix HPA Security detection/reporting.

MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2019-07-19 19:15:08 +00:00
Warner Losh
237024606a Use a different approach to range check.
gcc hates dt < CC_DT_NONE since it can never be true when dt is an unsigned
type. Since that's a compiler choice and may be affected by weird stuff, instead
use (unsigned)dt > CC_DT_UNKNOWN to test for bounds error since that will work
regardless of the signedness of dt.
2019-07-15 23:43:38 +00:00
Warner Losh
d455c0d04a Implement a devtype command.
List the device's protocol. The returned value is one of the following:
	ata	direct attach ATA or SATA device
	satl	a SATA device attached via SAS
	scsi	A parallel SCSI or SAS
	nvme	A direct attached NVMe device
	mmcsd	A MMC or SD attached device

Reviewed by: scottl@, rpokala@
Differential Revision: https://reviews.freebsd.org/D20950
2019-07-15 22:33:37 +00:00
Warner Losh
40152db5d3 Use the more proper term of SATL instead of ATA_BEHIND_SCSI.
Most people know SAS attached SATA devices by the name SAT or SATL
(with the latter being a little more common). Change the device type
ATA_BEHIND_SCSI to SATL since it's more specific and meaningful.

Suggested by: scottl@
2019-07-15 20:25:41 +00:00
Warner Losh
a5a8266af1 Add device type NVME and device type MMCSD to get_device_type
For completeness, add nvme and mmc/sd devices to the list of device
types we know.
2019-07-13 03:22:28 +00:00
Warner Losh
c99e4e6b8b Retire support for -DMINIMALISTIC
We've not used this in years since we retired sysinstall, and it
hasn't compiled in at least a year. A full camcontrol is only 180k, so
making it smaller is not as important as it once was.

OK'd by: ken@, scottl@
2019-07-12 05:35:45 +00:00
Warner Losh
91211c46ac Replay r349341 by imp accidentally reverted by r349352
Use ata_param_fixup instead of a custom copy here
2019-06-25 06:14:26 +00:00
Warner Losh
f5a95d9a07 Remove NAND and NANDFS support
NANDFS has been broken for years. Remove it. The NAND drivers that
remain are for ancient parts that are no longer relevant. They are
polled, have terrible performance and just for ancient arm
hardware. NAND parts have evolved significantly from this early work
and little to none of it would be relevant should someone need to
update to support raw nand. This code has been off by default for
years and has violated the vnode protocol leading to panics since it
was committed.

Numerous posts to arch@ and other locations have found no actual users
for this software.

Relnotes:	Yes
No Objection From: arch@
Differential Revision: https://reviews.freebsd.org/D20745
2019-06-25 04:50:09 +00:00
Warner Losh
6506ca91d2 Use ata_param_fixup instead of a custom copy here 2019-06-24 20:19:03 +00:00
Warner Losh
07810343ee Increase the timeout for READ NATIVE MAX
READ NATIVE MAX can take longer than a second if the queued NCQ I/Os
take longer than a second to drain.
2019-06-13 05:19:36 +00:00
Steven Hartland
3bed0179ee Add ATA power mode support to camcontrol
Add the ability to report ATA device power mode with the cmmand 'powermode'
to compliment the existing ability to set it using idle, standby and sleep
commands.

MFC after:	2 weeks
Sponsored by:	Multiplay
2019-04-23 07:46:38 +00:00
Ilya Bakulin
0660cfa0c4 Add new fields to mmc_data in preparation to SDIO CMD53 block mode support
SDIO command CMD53 (IO_RW_EXTENDED) allows data transfers using blocks of 1-2048 bytes,
with a maximum of 511 blocks per request.
Extend mmc_data structure to properly describe such requests,
and initialize the new fields in kernel and userland consumers.

No actual driver changes happen yet, these will follow in the separate changes.

Reviewed by:	bz
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D19779
2019-04-10 19:49:35 +00:00
Warner Losh
3ace9199b4 Make WD and WDC aliases for HGST.
HGST was bought by WDC. Over the years, it has sold different drives
branded as HGST, WD or WDC. All of them need the HGST workaround of
sending 4k-sized packets (or multiples of 4k). And the ones that don't
really need this aren't broken by this change. Submitter is the vendor
who has tested these changes on a number of drives. I've simplified it
slightly, since we don't need additional vendors for this at this
time.

Submitted by: JacobBurley via github on behalf of WDC
Pull Request: https://github.com/freebsd/freebsd/pull/391
2019-03-21 06:27:58 +00:00
Mateusz Piotrowski
bf43c6d1fc camcontrol.8: Bump date after r345051
Reviewed by:	bcr
Approved by:	bcr (doc)
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D19555
2019-03-12 09:43:11 +00:00
Warner Losh
b9dd559a32 Add -l to camcontrol readcap.
The -l flag sends only the READ CAPACITY (16) sevice action. Normally
we send the READ CAPACITY (10) command, and only send RC16 when the
capacity is larger than 2TB (since that's the max RC10 can
report). However, some badly programmed drives report different
numbers for RC10 and RC16. This can be hard to diagnose, but generally
there's a "Logical block address out of range" error when RC16 reports
a larger number than RC10 and the RC10 number is the correct one. By
comparing the output of readcap with and without the -l argmuent, one
can determine if there's a mismatch and if the DA_Q_NO_RC16 quirk is
needed.

Reviewed by: ken@
Differential Revision: https://reviews.freebsd.org/D19536
2019-03-12 04:57:05 +00:00
Steven Hartland
c092a1dbc3 Fix incorrect / unused sector_count for identify requests
Fix incorrect / unused sector_count for identify requests from camcontrol.

Submitted by:	Alexey Dokuchaev
Reported by:	Alexey Dokuchaev
MFC after:	1 week
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D19408
2019-03-01 14:39:15 +00:00
Warner Losh
f0f8a1af01 NVME support is only for x86 and powerpc64.
Implement MK_NVME now that the expression for where NVMe is
complicated. Default it to "yes" for x86 and powerpc64 and
no everywhere else. Use it in camcontrol to define WITH_NVME
for those platforms where we support nvme.

This should fix the newly introduced nvme files to camcontrol
which were building everywhere.

Pointy Hat To: imp
Sponsored by: Netflix
2018-06-14 01:15:19 +00:00
Warner Losh
6ee13c54da Make camcontrol identify work with nda devices
Both ATA and NVME have an identify command. They are completely
different, but to the user they are the same. Leverage nvmecontrol's
print_controller code to provide that functionality to camcontrol
identify. Query the path to see what kind of protocol it supports, and
send the most appropriate command down. Refactor nvme_print_dev a
little to make it easy to get the nvme cdata.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D15371
2018-06-13 22:00:08 +00:00
Warner Losh
0272270a8d nda protocol rate reporting
Report the NVMe spec, number of lanes (and max) as well as the PCIe
generation we're negotiated at (and max) for the camcontrol rate
command.

Reviewed by: scottl (the output, not the code)
Sponsored by: Netflix
2018-05-09 18:41:04 +00:00
Edward Tomasz Napierala
f0bbdd70ad Strip trailing whitespace.
MFC after:	2 weeks
2018-04-10 08:13:59 +00:00
Scott Long
19641ce893 Revert ABI breakage to CAM that came in with MMC/SD support in r320844.
Make it possible to retrieve mmc parameters via the XPT_GET_ADVINFO
call instead.  Convert camcontrol to the new scheme.

Reviewed by:	imp. kibab
Sponsored by:	Netflix
Differential Revision:	D13868
2018-01-19 15:32:27 +00:00
Scott Long
f2592b12e9 Refactor code related to 'camcontrol devlist'
Obtained from:	Netflix
2018-01-10 05:52:24 +00:00
Scott Long
c371df4f47 Implement the ability to query NVME for its controller data so that it will
be shown when issueing the 'camcontrol devlist' command.

Obtained from:	Netflix
2018-01-10 05:29:02 +00:00
Pedro F. Giffuni
1de7b4b805 various: general 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.

No functional change intended.
2017-11-27 15:37:16 +00:00
Alan Somers
8d68f9d430 Print ZAC device type in "camcontrol identify" output
ZAC (Zoned-device ATA Command set) is the standard for addressing SMR
(shingled magnetic recording) devices over SATA.  Drives indicate their
support for ZAC in their IDENTIFY block. Print whether and how a drive
supports ZAC in the output of "camcontrol identify".

Reviewed by:	ken, imp
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D13171
2017-11-20 21:56:25 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00