Commit Graph

91 Commits

Author SHA1 Message Date
Scott Long
c11c484f15 Rework the debug print API. Event printing no longer gets special handling.
All of the printing from the tables file now has wrappers so that the
handling is cleaner and it's possible to print something out (say, during
development) without having to fight the global debug flags. This re-org
will also make it easier to have the tables be compiled out at build time
if desired.

Other than fixing some minor bugs, there are no user-visible changes from
this change

Sponsored by:	Netflix, Inc.
Differential Revision:	D9238
2017-01-19 21:47:50 +00:00
Scott Long
94e4e732af Print out the number of queues/MSIx vectors.
Sponsored by:	Netflix
2017-01-12 01:13:05 +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
Alan Somers
fa699bb23e misc minor fixes in mpr(4)
sys/dev/mpr/mpr_sas.c
	* Fix a potential null pointer dereference (CID 1305731)
	* Check for overrun of the ccb_scsiio.cdb_io.cdb_bytes buffer (CID
	  1211934)

sys/dev/mpr/mpr_sas_lsi.c
	* Nullify a dangling pointer in mprsas_get_sata_identify
	* Fix a memory leak in mprsas_SSU_to_SATA_devices (CID 1211935)

Reported by:	Coverity (partially)
CID:		1305731 1211934 1211935
Reviewed by:	slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D8880
2017-01-03 17:35:16 +00:00
Scott Long
694cb8b815 Record the LogInfo field when reporting the IOCStatus. Helps in
debugging errors.

Submitted by:	slm
Obtained from:	Netflix
MFC after:	3 days
2016-11-04 17:25:47 +00:00
Scott Long
4ab1cdc5ad Add a fallback to the device mapper logic. We've seen systems in the field
that are apparently misconfigured by the manufacturer and cause the mapping
logic to fail.  The fallback allows drive numbers to be assigned based on the
PHY number that they're attached to.  Add sysctls and tunables to overrid
this new behavior, but they should be considered only necessary for debugging.

Reviewed by:	 imp, smh
Obtained from:	Netflix
MFC after:	3 days
Sponsored by:	D8403
2016-11-02 15:13:25 +00:00
Stephen McConnell
32b0a21e43 Use real values to calculate Max I/O size instead of guessing.
Reviewed by:	ken, scottl
Approved by:	ken, scottl, ambrisko (mentors)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D7043
2016-07-12 19:34:10 +00:00
Edward Tomasz Napierala
13a8942827 Remove NULL checks after M_WAITOK allocations from mpr(4).
Reviewed by:	asomers@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6297
2016-05-10 15:04:24 +00:00
Stephen McConnell
e769dfac49 Bump version of mpr driver to 13.00.00.00-fbsd
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
2016-05-09 16:38:51 +00:00
Stephen McConnell
58581c1363 Disks can go missing until a reboot is done in some cases.
This is due to the DevHandle not being released, which causes the Firmware to
not allow that disk to be re-added.

Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6102
2016-05-09 16:36:40 +00:00
Stephen McConnell
5d21655f67 done_ccb pointer can be used if it is NULL.
To prevent this, move check for done_ccb == NULL to before done_ccb is used in
mprsas_stop_unit_done().

Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6099
2016-05-09 16:34:06 +00:00
Stephen McConnell
407073a044 Use callout_reset_sbt() instead of callout_reset() if FreeBSD ver is >= 1000029
Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6101
2016-05-09 16:31:43 +00:00
Stephen McConnell
dd9f4a95b2 No need to set the MPRSAS_SHUTDOWN flag because it's never used.
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
2016-05-09 16:29:25 +00:00
Stephen McConnell
8861939221 Fix possible use of invalid pointer.
It was possible to use an invalid pointer to get the target ID value. To fix
this, initialize a local Target ID variable to an invalid value and change that
variable to a valid value only if the pointer to the Target ID is not NULL.

Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6100
2016-05-09 16:26:34 +00:00
Stephen McConnell
b41c6ff97a Change logging level for a debug string to use MPR_LOG instead of MPR_INFO.
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
2016-05-09 16:24:16 +00:00
Stephen McConnell
d3f6eabf13 No log bit in IOCStatus and endian-safe changes.
Use MPI2_IOCSTATUS_MASK when checking IOCStatus to mask off the log bit, and
make a few more things endian-safe.

Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6097
2016-05-09 16:21:14 +00:00
Stephen McConnell
2bbc5fcb4b Add support for the Broadcom (Avago/LSI) 9305 16 and 24 port HBA's.
Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Relnotes:       yes
Differential Revision: https://reviews.freebsd.org/D6098
2016-05-09 16:19:13 +00:00
Stephen McConnell
7a2a6a1a6f Several style changes and add copyrights for 2016.
Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6103
2016-05-09 16:16:00 +00:00
Stephen McConnell
28ae62b066 Update MPI headers to version 42.
Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6096
2016-05-09 16:12:32 +00:00
Alan Somers
6adfa7edf0 mpr(4) and mps(4) shouldn't indefinitely retry for "terminated ioc" errors
Submitted by:	ken
Reviewed by:	slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6210
2016-05-05 15:32:47 +00:00
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Pedro F. Giffuni
d9c9c81c08 sys: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code
and when the code has a high indentation level it was not really
advantageous to do the replacement.

This tries to strike a balance between readability using the macros
and flexibility of having the expressions, so not everything is
converted.
2016-04-21 19:57:40 +00:00
Alan Somers
a92fe02768 Don't retry SAS commands in response to protocol errors
sys/dev/mpr/mpr_sas_lsi.c
sys/dev/mps/mps_sas_lsi.c
	When mp[rs]sas_get_sata_identify returns
	MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR, don't bother retrying. Protocol
	errors aren't likely to be fixed by sleeping.

	Without this change, a system that generated may protocol errors due
	to signal integrity issues was taking more than an hour to boot, due
	to all the retries.

Reviewed by:	slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D4553
2015-12-14 19:40:47 +00:00
Scott Long
d0be3479d5 Remove _FreeBSD_version check for something that was only an issue with
9-CURRENT.

Obtained from:  Netlfix, Inc
MFC after:      3 days
2015-10-16 17:56:43 +00:00
Stephen McConnell
a2c1487946 The wrong commit message was given with r283632. This is the correct message.
- Updated all files with 2015 Avago copyright, and updated LSI's copyright
  dates.

- Changed all of the PCI device strings from LSI to Avago Technologies (LSI).

- Added a sysctl variable to control how StartStopUnit behavior works. User can
  select to spin down disks based on if disk is SSD or HDD.

- Inquiry data is required to tell if a disk will support SSU at shutdown or
  not. Due to the addition of mpssas_async, which gets Advanced Info but not
  Inquiry data, the setting of supports_SSU was moved to the
  mpssas_scsiio_complete function, which snoops for any Inquiry commands. And,
  since disks are shutdown as a target and not a LUN, this process was
  simplified by basing it on targets and not LUNs.

- Added a sysctl variable that sets the amount of time to retry after sending a
  failed SATA ID command. This helps with some bad disks and large disks that
  require a lot of time to spin up. Part of this change was to add a callout to
  handle timeouts with the SATA ID command. The callout function is called
  mpssas_ata_id_timeout(). (Fixes PR 191348)

- Changed the way resets work by allowing I/O to continue to devices that are
  not currently under a reset condition. This uses devq's instead of simq's and
  makes use of the MPSSAS_TARGET_INRESET flag. This change also adds a function
  called mpssas_prepare_tm().

- Some changes were made to reduce code duplication when getting a SAS address
  for a SATA disk.

- Fixed some formatting and whitespace.

- Bump version of mps driver to 9.255.01.00-fbsd

PR:		191348
Reviewed by:	ken, scottl
Approved by:	ken, scottl
MFC after:	1 week
2015-05-28 18:24:22 +00:00
Stephen McConnell
c91d307f52 The wrong commit message was given with r283632. To get the correct commit
message synced to the changes in r283632, those changes are now backed out.
Another commit will be done that is exactly the same as r283632 except it will
have to correct commit message.

Approved by:	ken, scottl, asomers, gibbs
2015-05-28 18:14:55 +00:00
Stephen McConnell
2ca937d2ad This setting of stop_at_shutdown should have been removed with r279253
Approved by:	ken
MFC after:	1 week
2015-05-27 20:37:34 +00:00
Kenneth D. Merry
6c0541fa8e Add FreeBSD stable/10 version checks for the availability of the
CDAI_FLAG_NONE advanced information CCB flag.

Support for the flag was merged to stable/10 in r279329, and the
__FreeBSD_version in stable/10 was bumped to 1001510.

Check for that version in the mps(4) and mpr(4) drivers when determining
whether to use the flag.

Sponsored by:	Spectra Logic
MFC after:	3 days
2015-02-26 22:22:06 +00:00
Kenneth D. Merry
e8577fb489 Make sure that the flags for the XPT_DEV_ADVINFO CCB are initialized
properly.

If there is garbage in the flags field, it can sometimes include a
set CDAI_FLAG_STORE flag, which may cause either an error or
perhaps result in overwriting the field that was intended to be
read.

sys/cam/cam_ccb.h:
	Add a new flag to the XPT_DEV_ADVINFO CCB, CDAI_FLAG_NONE,
	that callers can use to set the flags field when no store
	is desired.

sys/cam/scsi/scsi_enc_ses.c:
	In ses_setphyspath_callback(), explicitly set the
	XPT_DEV_ADVINFO flags to CDAI_FLAG_NONE when fetching the
	physical path information.  Instead of ORing in the
	CDAI_FLAG_STORE flag when storing the physical path, set
	the flags field to CDAI_FLAG_STORE.

sys/cam/scsi/scsi_sa.c:
	Set the XPT_DEV_ADVINFO flags field to CDAI_FLAG_NONE when
	fetching extended inquiry information.

sys/cam/scsi/scsi_da.c:
	When storing extended READ CAPACITY information, set the
	XPT_DEV_ADVINFO flags field to CDAI_FLAG_STORE instead of
	ORing it into a field that isn't initialized.

sys/dev/mpr/mpr_sas.c,
sys/dev/mps/mps_sas.c:
	When fetching extended READ CAPACITY information, set the
	XPT_DEV_ADVINFO flags field to CDAI_FLAG_NONE instead of
	setting it to 0.

sbin/camcontrol/camcontrol.c:
	When fetching a device ID, set the XPT_DEV_ADVINFO flags
	field to CDAI_FLAG_NONE instead of 0.

sys/sys/param.h:
	Bump __FreeBSD_version to 1100061 for the new XPT_DEV_ADVINFO
	CCB flag, CDAI_FLAG_NONE.

Sponsored by:	Spectra Logic
MFC after:	1 week
2015-02-18 18:30:19 +00:00
Steven Hartland
85c9dd9d89 Prevent overflow issues in timeout processing
Previously, any timeout value for which (timeout * hz) will overflow the
signed integer, will give weird results, since callout(9) routines will
convert negative values of ticks to '1'. For unsigned integer overflow we
will get sufficiently smaller timeout values than expected.

Switch from callout_reset, which requires conversion to int based ticks
to callout_reset_sbt to avoid this.

Also correct isci to correctly resolve ccb timeout.

This was based on the original work done by Eygene Ryabinkin
<rea@freebsd.org> back in 5 Aug 2011 which used a macro to help avoid
the overlow.

Differential Revision:	https://reviews.freebsd.org/D1157
Reviewed by:	mav, davide
MFC after:	1 month
Sponsored by:	Multiplay
2014-11-21 21:01:24 +00:00
Hans Petter Selasky
f0188618f2 Fix multiple incorrect SYSCTL arguments in the kernel:
- Wrong integer type was specified.

- Wrong or missing "access" specifier. The "access" specifier
sometimes included the SYSCTL type, which it should not, except for
procedural SYSCTL nodes.

- Logical OR where binary OR was expected.

- Properly assert the "access" argument passed to all SYSCTL macros,
using the CTASSERT macro. This applies to both static- and dynamically
created SYSCTLs.

- Properly assert the the data type for both static and dynamic
SYSCTLs. In the case of static SYSCTLs we only assert that the data
pointed to by the SYSCTL data pointer has the correct size, hence
there is no easy way to assert types in the C language outside a
C-function.

- Rewrote some code which doesn't pass a constant "access" specifier
when creating dynamic SYSCTL nodes, which is now a requirement.

- Updated "EXAMPLES" section in SYSCTL manual page.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
2014-10-21 07:31:21 +00:00
Alexander Motin
82315915e0 Properly report 12Gbps connection rate.
Reviewed by:	kadesai, slm
MFC after:	1 week
2014-10-08 16:22:26 +00:00
Alexander Motin
c2a0f07a10 Increase taskqueue thread priority from idle to PRIBIO.
Idle priority is not even time-share, so if system is busy in any way,
those events may never be executed.  Since in some cases system waits
for events processed by that thread, that may cause deadlocks.
2014-05-24 13:00:49 +00:00
Kenneth D. Merry
a371d6f964 Add #ifdefs in the mpr(4) driver so that versions of stable/9 that
have implemented the PIM_NOSCAN rescan functionality will have it
enabled.

This is a no-op for head.

Reviewed by:	slm
Sponsored by:	Spectra Logic Corporation
MFC after:	3 days
2014-05-08 20:46:46 +00:00
Kenneth D. Merry
d2b4e18b21 Fix TLR (Transport Layer Retry) support in the mps(4) and mpr(4) drivers.
TLR is necessary for reliable communication with SAS tape drives.

This was broken by change 246713 in the mps(4) driver.  It changed the
cm_data field for SCSI I/O requests to point to the CCB instead of the data
buffer.  So, instead, look at the CCB's data pointer to determine whether
or not we're talking to a tape drive.

Also, take the residual into account to make sure that we don't go off the
end of the request.

MFC after:	3 days
Sponsored by:	Spectra Logic Corporation
2014-05-08 20:28:22 +00:00
Kenneth D. Merry
63941e9834 Hold the SIM lock when calling xpt_create_path() and xpt_action() in
mprsas_SSU_to_SATA_devices().

This fixes an assertion on shutdown with INVARIANTS enabled with SATA
drives present on an IR firmware controller.

Reviewed by:	Steve McConnell <stephen.mcconnell@avagotech.com>.
MFC after:	3 days
2014-05-07 05:14:48 +00:00
Kenneth D. Merry
09e25c0e8a Remove some debugging code.
Submitted by:	Steve McConnell <stephen.mcconnell@avagotech.com>
MFC after:	3 days
2014-05-07 05:11:16 +00:00
Kenneth D. Merry
c0ba1535a4 Change the device name for mpr(4) from /dev/mpr_N to /dev/mprN.
This is more consistent with the existing mps(4) behavior.

Reviewed by:	Steve McConnell <stephen.mcconnell@avagotech.com>
MFC after:	3 days
2014-05-06 22:13:38 +00:00
Kenneth D. Merry
07aa4de131 Fix a problem with async notifications in the mpr(4) driver.
This problem only occurs on versions of FreeBSD prior to the recent CAM
locking changes.  (i.e. stable/9 and older versions of stable/10)  This
change should be a no-op for head and stable/10.

If a path isn't specified, xpt_register_async() will create a fully
wildcarded path and acquire a lock (the XPT lock in older versions,
and via xpt_path_lock() in newer versions) to call xpt_action() for the
XPT_SASYNC_CB CCB.  It will then drop the lock and if the requested event
includes AC_FOUND_DEVICE or AC_PATH_REGISTERED, it will get the caller up
to date with any device arrivals or path registrations.

The issue is that before the locking changes, each SIM lock would get
acquired in turn during the EDT tree traversal process.  If a path is
specified for xpt_register_async(), it won't acquire and drop its own lock,
but instead expects the caller to hold its own SIM lock.  That works for
the first part of xpt_register_async(), but causes a recursive lock
acquisition once the EDT traversal happens and it comes to the SIM in
question.  And it isn't possible to call xpt_action() without holding a SIM
lock.

The locking changes fix this by using the XPT topology lock for EDT
traversal, so it is no longer an issue to hold the SIM lock while calling
xpt_register_async().

The solution for FreeBSD versions before the locking changes is to request
notification of all device arrivals (so we pass a NULL path into
xpt_register_async()) and then filter out the arrivals that are not ours.

MFC After:	3 days
Sponsored by:	Spectra Logic Corporation
2014-05-06 06:18:43 +00:00
Kenneth D. Merry
c503306dc6 Adjust #if statements inside mprsas_send_smpcmd() to more accurately
reflect when unmapped I/O support was added.

For FreeBSD 10, it arrived just prior to __FreeBSD_version 1000028.
For FreeBSD 9, it arrived just prior to __FreeBSD_version 902001.

Also, fix compiler warnings in mprsas_send_smpcmd() that happen in the
i386 PAE build for non-unmapped I/O builds.  These were fixed in mps(4)
in revision 241145, but didn't make it into the mpr(4) driver.  This
change should only affect FreeBSD versions outside the above revisions,
and thus doesn't affect head.

MFC after:	3 days
Sponsored by:	Spectra Logic Corporation
2014-05-05 19:53:03 +00:00
Kenneth D. Merry
991554f2c4 Bring in the mpr(4) driver for LSI's MPT3 12Gb SAS controllers.
This is derived from the mps(4) driver, but it supports only the 12Gb
IT and IR hardware including the SAS 3004, SAS 3008 and SAS 3108.

Some notes about this driver:
 o The 12Gb hardware can do "FastPath" I/O, and that capability is included in
   this driver.

 o WarpDrive functionality has been removed, since it isn't supported in
   the 12Gb driver interface.

 o The Scatter/Gather list handling code is significantly different between
   the 6Gb and 12Gb hardware.  The 12Gb boards support IEEE Scatter/Gather
   lists.

Thanks to LSI for developing and testing this driver for FreeBSD.

share/man/man4/mpr.4:
	mpr(4) man page.

sys/dev/mpr/*:
	mpr(4) driver files.

sys/modules/Makefile,
sys/modules/mpr/Makefile:
	Add a module Makefile for the mpr(4) driver.

sys/conf/files:
	Add the mpr(4) driver.

sys/amd64/conf/GENERIC,
sys/i386/conf/GENERIC,
sys/mips/conf/OCTEON1,
sys/sparc64/conf/GENERIC:
	Add the mpr(4) driver to all config files that currently
	have the mps(4) driver.

sys/ia64/conf/GENERIC:
	Add the mps(4) and mpr(4) drivers to the ia64 GENERIC
	config file.

sys/i386/conf/XEN:
	Exclude the mpr module from building here.

Submitted by:	Steve McConnell <Stephen.McConnell@lsi.com>
MFC after:	3 days
Tested by:	Chris Reeves <chrisr@spectralogic.com>
Sponsored by:	LSI, Spectra Logic
Relnotes:	LSI 12Gb SAS driver mpr(4) added
2014-05-02 20:25:09 +00:00