Commit Graph

914 Commits

Author SHA1 Message Date
Kenneth D. Merry
57b6261f94 Correct loop mode CRN resets to adhere to FCP-4 section 4.10
Prior to this change, the CRN (Command Reference Number) is reset on any
firmware LIP, LOOP DOWN, or LOOP RESET event in violation of FCP-4 which
specifies that the CRN should only be reset in response to a LIP Reset
(LIPyx) primitive. FCP-4 also indicates PLOGI/LOGO and PRLI/PRLO ELS
actions as conditions for resetting the CRN for the associated initiator
port.

These violations manifest themselves when the HBA is removed from the
loop, or a target device is removed (especially during an outstanding
command) without power cycling. If the HBA and and the target device
determine upon re-establishing the loop that no PLOGI or PRLI is
required, and the target does not issue a LIPxy to the initiator, the
CRN for the target will have been improperly reset by the isp driver. As
a result, the target port will silently ignore all FCP commands issued
during the device probe (which will time out) preventing the device from
attaching.

This change corrects thie CRN reset behavior in response to loop state
changes, also introduces CRN resets for the above mentioned ELS actions
as encountered through async PDB change events.

This change also adds cleanup of outstanding commands in isp_loop_dead()
that was previously missing.

sys/dev/isp/isp.c
	Add the last login state to debug output when syncing the pdb

sys/dev/isp/isp_freebsd.c
	Replace binary statement setting aborted ccb status in
	isp_watchdog() with the XS_SETERR macro used elsewhere

	In isp_loop_dead(), abort or complete pending commands as done
	in isp_watchdog()

	In isp_async(), segregate the ISPASYNC_LOOP_RESET action from
	ISPASYNC_LIP, ISPASYNC_LOOP_DOWN, and ISPASYNC_LOOP_UP
	fallthroughs, and only reset the CRN in the RESET case. Also add
	checks to handle false LOOP RESET actions that do not have a
	proper associated LIP primitive, and log the primitive in the
	debug messages

	In isp_async(), remove the goto from ISP_ASYNC_DEV_STAYED, and
	only reset the CRN in the DEV_CHANGED action

	In isp_async(), when processing an ISPASYNC_CHANGE_PDB status,
	reset CRN(s) for the associated nphdl (or all ports) if the
	change reason is some form of ELS login/logout. Also remove
	assignment to fc since it is not used in the scope

sys/dev/isp/ispmbox.h
	Add macro definition for the global N-Port handle, and correct a
	macro typo 'PDB24XX_AE_PRLI_DONJE'

sys/dev/isp/ispvar.h
	Add macros FCP_AL_DA_ALL, FCP_AL_PA, and FCP_IS_DEST_ALPD for
	more legible code when determining if an AL_PD port matches the
	portid for a given struct fcparam* by value or by virtue of the
	AL_PD port being 0xFF

Submitted by:	Reid Linnemann
Sponsored by:	Spectra Logic
MFC after:	1 week
2017-05-03 13:17:01 +00:00
Alexander Motin
1c779b2849 Switch isp_reset to scratchpad not requiring ISP_MBOXDMASETUP.
MFC after:	1 week
2017-04-24 10:16:12 +00:00
Alexander Motin
e9da70a35e Fix few minor issues found by Clang Analyzer.
MFC after:	2 weeks
2017-04-09 07:53:31 +00:00
Alexander Motin
00be964c08 Add brackets to fix incorrect macro expansion.
Reported by:	Andreas Hollmann / PVS-Studio
MFC after:	2 weeks
2017-03-24 16:26:11 +00:00
Alexander Motin
7e31684ea4 Unify initiator and target DMA setup and command sending.
The code is so alike that it is pointless to keep it separate.

MFC after:	2 weeks
2017-03-24 14:44:03 +00:00
Alexander Motin
961da6389a isp field in struct isp_pcmd is also unused.
MFC after:	2 weeks
2017-03-23 21:18:10 +00:00
Alexander Motin
96ae113f37 Remove write-only crn field from struct isp_pcmd.
MFC after:	2 weeks
2017-03-23 21:11:55 +00:00
Alexander Motin
ea8e769e42 Switch from using periph_links to sim_links.
periph_links field belongs to periph drivers and must not be used here.

MFC after:	2 weeks
2017-03-22 11:06:33 +00:00
Alexander Motin
2d24b6af63 Cleanup response queue processing.
MFC after:	2 weeks
2017-03-22 08:56:03 +00:00
Alexander Motin
cf8242898d Remove another remnants left after r246713.
MFC after:	2 weeks
2017-03-21 14:14:11 +00:00
Alexander Motin
97dfdd4efa Remove some dead code left after r246713.
MFC after:	2 weeks
2017-03-21 13:49:43 +00:00
Alexander Motin
31c161a615 Improve command timeout handling.
Let firmware do its best first, and if it can't, try software recovery.
I would remove software timeout handler completely, but found bunch of
complains on command timeout on sparc64 mailing list few years ago, so
better be safe in case of interrupt loss.

MFC after:	2 weeks
2017-03-21 13:10:37 +00:00
Alexander Motin
01728721bf Remove questionable reqp->req_time access.
MFC after:	2 weeks
2017-03-21 11:26:31 +00:00
Alexander Motin
13d9c92192 Clean/unify some macro usage.
MFC after:	2 weeks
2017-03-21 10:34:34 +00:00
Alexander Motin
abdc2e314b Addition to r315579: drop the lock while allocating IRQs.
MFC after:	12 days
2017-03-21 08:56:13 +00:00
Alexander Motin
98339da12a Remove some more dead code.
MFC after:	2 weeks
2017-03-20 20:44:14 +00:00
Alexander Motin
9abc1e2b0c Remove some useless code.
MFC after:	2 weeks
2017-03-19 21:25:13 +00:00
Alexander Motin
08826086fe Add initial support for multiple MSI-X vectors.
For 24xx and above use 2 vectors (default and response queue).
For 26xx and above use 3 vectors (default, response and ATIO queues).
Due to global lock interrupt hardlers never run simultaneously now, but
at least this allows to save one regitster read per interrupt.

MFC after:	2 weeks
2017-03-19 19:11:40 +00:00
Alexander Motin
9c81a61ee1 Remove hackish code delaying ATIOs to unknown virtual port.
Since we support RQSTYPE_RPT_ID_ACQ, that functionality is only useful
in loop mode, which probably doesn't worth having this hack in 2017.

MFC after:	2 weeks
2017-03-19 13:46:11 +00:00
Alexander Motin
e2a658cb0c Move <= 23xx PDB workaround to generic code.
It is chip-specific and has nothing to do with platform.

MFC after:	2 weeks
2017-03-19 10:28:04 +00:00
Alexander Motin
a41dd87f61 Remove some dead stuff.
MFC after:	2 weeks
2017-03-19 09:36:43 +00:00
Alexander Motin
5a5632c2de Move 24xx RQSTYPE_NOTIFY handling to generic code.
This code has nothing to do with specific platform.

MFC after:	2 weeks
2017-03-19 09:30:03 +00:00
Alexander Motin
87b04de6cb Reorganize RQSTYPE_NOTIFY handling for chips <= 23xx.
There were two copies of the code: one in generic code was half-broken, and
another in platform code was never called.  Leave only one in generic code
and working.

MFC after:	2 weeks
2017-03-18 19:27:16 +00:00
Alexander Motin
981ffc4e21 Move RQSTYPE_ABTS_RCVD parsing into generic code.
MFC after:	2 weeks
2017-03-18 17:01:11 +00:00
Alexander Motin
15c62456d1 Extend nt_lun to full 8 byte.
MFC after:	2 weeks
2017-03-18 16:09:36 +00:00
Alexander Motin
98b08fbea5 Remove dead remnants of SPI target.
MFC after:	2 weeks
2017-03-18 15:42:22 +00:00
Alexander Motin
782a8e7ca3 Use isp_target_put_entry() in places where it can be.
This unifies the code and removes some duplication.

MFC after:	2 weeks
2017-03-18 13:42:08 +00:00
Alexander Motin
44a2a27af5 Do some notify acks cleanup.
ISPASYNC_TARGET_NOTIFY_ACK makes no sense without argument.

MFC after:	2 weeks
2017-03-18 10:34:29 +00:00
Alexander Motin
d10e4cd0c0 Remove not very useful ATIO/INOT stats.
While there polish respective debug logging.

MFC after:	2 weeks
2017-03-15 19:49:45 +00:00
Alexander Motin
0e6bc811e4 Refactor interrupt handling.
Instead of single isp_intr() function doing all possible magic, introduce
four different functions to handle mailbox operation completions, async
events, response and ATIO queues.  The goal is to isolate different code
paths to make code more readable, and to make easier support for multiple
interrupt vectors.  Even oldest hardware in many cases can identify what
code path it should run on interrupt.  Contemporary hardware can assign
them to different interrupt vectors.

MFC after:	2 weeks
2017-03-15 14:58:29 +00:00
Alexander Motin
ce9f323727 Fix panic when SIM dereferenced before allocation.
MFC after:	2 weeks
2017-03-15 11:16:26 +00:00
Alexander Motin
b0a66d29b8 Fix ancient bug from r84597, which broke 23xx after r315234.
MFC after:	13 days
2017-03-15 10:33:44 +00:00
Alexander Motin
9c2e9bcfbe Remove some dead/broken code paths around async handling
MFC after:	2 weeks
2017-03-14 18:42:33 +00:00
Alexander Motin
6327b0d287 Remove tangled isp_mbox_continue() mechanism.
It was implemented to reduce context switches when uploading firmware to
card's RAM.  But this mechanism is not used last 10 years since all mbox
operations are now polled, and it was never used for cards produced in
last 15 years.  Newer cards can use DMA to upload firmware.

MFC after:	2 weeks
2017-03-14 17:34:44 +00:00
Alexander Motin
0cbfd9bb18 Remove dangerous and questionable isp_mboxcmd_qnw() call.
MFC after:	2 weeks
2017-03-14 08:45:33 +00:00
Alexander Motin
a1fa02673a Improvements around attach, reset and detach.
This change fixes DMA resource leak on driver unload.  Also it removes
DMA resources allocation for hardcoded number of requests before fetching
the real number from firmware.  Also it prepares ground for more flexible
IRQs allocation according to firmware capabilities.

MFC after:	2 weeks
2017-03-14 08:03:56 +00:00
Alexander Motin
4599b54219 Remove remnant of r315163.
MFC after:	13 days
2017-03-14 06:57:55 +00:00
Alexander Motin
c44f58fce9 Remove strange config_intrhook_establish() magic.
Interrupts are enabled as part of chip reset just during driver attach.
Later "enabling" of already enabled interrupts is useless.

MFC after:	2 weeks
2017-03-12 16:55:18 +00:00
Alexander Motin
ab23521a49 Try to slight untangle I/O and loop status handling.
MFC after:	2 weeks
2017-03-12 15:36:07 +00:00
Alexander Motin
229203af68 Remove code for unsupported FreeBSD versions.
MFC after:	2 weeks
2017-03-12 14:17:57 +00:00
Alexander Motin
3f072d6948 Send TERMINATE to firmware when aborting active ATIO.
MFC after:	2 weeks
2017-02-27 08:20:28 +00:00
Alexander Motin
2d4a5bcccb Return better error code in case of too long CDB.
Its more important for SPI HBAs, as they don't support CDBs above 12 bytes.
The new error code makes CAM to fall back to alternative commands.

MFC after:	2 weeks
2017-02-26 14:29:09 +00:00
Alexander Motin
a6036a44fd Fix residual length reporting in target mode.
This allows to properly handle cases when target wants to receive or send
more data then initiator wants to send or receive.  Previously in such
cases isp(4) returned CAM_DATA_RUN_ERR, while now it returns resid > 0.

MFC after:	2 weeks
2017-02-26 12:52:44 +00:00
Alexander Motin
87de303c4a Respecting r314204 tighten ATIO cleanup requirements.
Every ATIO must complete with either successfully sent status or XPT_ABORT.

MFC after:	2 weeks
2017-02-24 14:48:17 +00:00
Alexander Motin
5c0b756a9a Fix missing xpt_done() for ATIO/INOT on missing LUN.
MFC after:	2 weeks
2017-02-24 12:11:17 +00:00
Alexander Motin
cfbeb41ccf Slightly polish isp_dump_atpd().
MFC after:	2 weeks
2017-02-22 07:12:20 +00:00
Alexander Motin
8290ea90be Fix multiple problems around LUN disable under load.
- Move private data about ATIOs/INOTs from per-LUN to per-channel data.
This allows active commands to continue operation after LUN destruction.
This also simplifies lookup of the data by tag in some situations.
 - Unify three restart_queue processing implementations.
 - Complete all ATIOs from restart_queue on LUN disable.
 - Delete ATIO private data when command completed or aborted, not depending
on the ATIO being requeued, that was ugly hack and could never happen.  CAM
should always call ether XPT_CONT_TARGET_IO with status or XPT_ABORT.
 - Implement XPT_ABORT for queued ATIOs/INOTs to allow CAM do graceful
shutdown, not depending on LUN disable, as it is done in ahd(4)/targ(4).
 - Unify isp_endcmd() arguments to make it more usable in generic code.
 - Remove never really used LUN state reference counter.

MFC after:	2 weeks
2017-02-22 06:43:49 +00:00
Alexander Motin
26719198a7 Remove duplicate INOT allocation.
For some reason isp_handle_platform_notify_fc() allocated INOT just
before calling isp_handle_platform_target_tmf(), which also allocates
INOT.  It seems to be a braino introduced in r196008.

MFC after:	2 weeks
2017-02-21 14:31:58 +00:00
Alexander Motin
069f5ef977 Remove ancient __FreeBSD_version checks.
MFC after:	2 weeks
2017-02-21 12:29:07 +00:00
Pedro F. Giffuni
4d24901ac9 sys/dev: Replace zero with NULL for pointers.
Makes things easier to read, plus architectures may set NULL to something
different than zero.

Found with:	devel/coccinelle
MFC after:	3 weeks
2017-02-20 03:43:12 +00:00