Commit Graph
901 Commits
Author SHA1 Message Date
Alexander Motin 4f8f08e874 MFC r315709: Switch from using periph_links to sim_links.
periph_links field belongs to periph drivers and must not be used here.
2017-04-02 11:00:47 +00:00
Alexander Motin 6fc54ae8f3 MFC r315682, r315683: Remove some dead code left after r246713. 2017-04-02 10:58:55 +00:00
Alexander Motin 5d5a6f0f33 MFC r315681: 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.
2017-04-02 10:57:19 +00:00
Alexander Motin f026d90848 MFC r315678: Remove questionable reqp->req_time access. 2017-04-02 10:55:40 +00:00
Alexander Motin 8b0e4d76f3 MFC r315677: Clean/unify some macro usage. 2017-04-02 10:54:28 +00:00
Alexander Motin 0ca78ba453 MFC r315587, r315652: Remove some dead/useless code. 2017-04-02 10:53:03 +00:00
Alexander Motin 2ca41beb6e MFC r315579, r315670: 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.
2017-04-02 10:50:49 +00:00
Alexander Motin e5467230e0 MFC r315545: 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.
2017-03-29 16:16:39 +00:00
Alexander Motin 55a5429093 MFC r315536: Move <= 23xx PDB workaround to generic code.
It is chip-specific and has nothing to do with platform.
2017-03-29 16:15:18 +00:00
Alexander Motin 7c778cdeda MFC r315534: Remove some dead stuff. 2017-03-29 16:14:04 +00:00
Alexander Motin 8028d755cd MFC r315533: Move 24xx RQSTYPE_NOTIFY handling to generic code.
This code has nothing to do with specific platform.
2017-03-29 16:12:41 +00:00
Alexander Motin c8d0547a3b MFC r315507: 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.
2017-03-29 16:10:34 +00:00
Alexander Motin 82820cf18b MFC r315489: Move RQSTYPE_ABTS_RCVD parsing into generic code. 2017-03-29 16:03:33 +00:00
Alexander Motin f3b7a5048f MFC r315488: Extend nt_lun to full 8 byte. 2017-03-29 16:02:19 +00:00
Alexander Motin e52abb371c MFC r315485: Remove dead remnants of SPI target. 2017-03-29 15:57:50 +00:00
Alexander Motin 82db7656ad MFC r315482: Use isp_target_put_entry() in places where it can be.
This unifies the code and removes some duplication.
2017-03-29 15:56:25 +00:00
Alexander Motin 72f1bd9a4f MFC r315478: Do some notify acks cleanup.
ISPASYNC_TARGET_NOTIFY_ACK makes no sense without argument.
2017-03-29 15:45:04 +00:00
Alexander Motin 49ca97b06e MFC r315327: Remove not very useful ATIO/INOT stats.
While there polish respective debug logging.
2017-03-29 15:43:51 +00:00
Alexander Motin f021fd0ee4 MFC r315307: 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.
2017-03-29 15:42:35 +00:00
Alexander Motin beb6f7fe8c MFC r315303: Fix panic when SIM dereferenced before allocation. 2017-03-29 15:40:45 +00:00
Alexander Motin 416c8e9162 MFC r315298: Fix ancient bug from r84597, which broke 23xx after r315234. 2017-03-29 15:39:13 +00:00
Alexander Motin 46a0d647d6 MFC r315279: Remove some dead/broken code paths around async handling 2017-03-28 10:25:56 +00:00
Alexander Motin 07e0f619ea MFC r315273: 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.
2017-03-28 10:24:41 +00:00
Alexander Motin 398e3b6633 MFC r315236: Remove dangerous and questionable isp_mboxcmd_qnw() call. 2017-03-28 10:23:32 +00:00
Alexander Motin fe5b8d4638 MFC r315234: 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.
2017-03-28 10:11:00 +00:00
Alexander Motin 5b953f4d50 MFC 315229: Remove remnant of r315163. 2017-03-27 08:29:02 +00:00
Alexander Motin efaf556562 MFC r315161: Try to slight untangle I/O and loop status handling. 2017-03-26 08:53:29 +00:00
Alexander Motin 19a4674194 MFC r315160: Remove code for unsupported FreeBSD versions. 2017-03-26 08:52:14 +00:00
Alexander Motin c127e688bf MFC r315163: 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.
2017-03-26 08:50:50 +00:00
Alexander Motin 6352900b3d MFC r311305 (by asomers):
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
2017-03-23 06:40:20 +00:00
Pedro F. Giffuni bd0faecc93 MFC r313982, r314068:
sys: Replace zero with NULL for pointers.

Found with:	devel/coccinelle
2017-03-14 02:06:03 +00:00
Alexander Motin 12082578a8 MFC r314326: Send TERMINATE to firmware when aborting active ATIO. 2017-03-06 06:45:00 +00:00
Alexander Motin 1d84cc89fa MFC r314302: 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.
2017-03-06 06:39:10 +00:00
Alexander Motin 71c10e9b69 MFC r314299, r314300: 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.
2017-03-06 06:37:44 +00:00
Alexander Motin 4910b1059f MFC r314208: Respecting r314204 tighten ATIO cleanup requirements.
Every ATIO must complete with either successfully sent status or XPT_ABORT.
2017-03-06 06:30:27 +00:00
Alexander Motin f5574d6f14 MFC r314203: Fix missing xpt_done() for ATIO/INOT on missing LUN. 2017-03-06 06:27:59 +00:00
Alexander Motin 789011827a MFC r314088: Slightly polish isp_dump_atpd(). 2017-03-06 06:23:17 +00:00
Alexander Motin baf470423f MFC r314086: 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.
2017-03-06 06:22:07 +00:00
Alexander Motin bf03a329b0 MFC r314045: 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.
2017-03-06 06:20:58 +00:00
Alexander Motin 9478de621e MFC r314038: Remove ancient __FreeBSD_version checks. 2017-03-06 06:19:42 +00:00
Alexander Motin 4612c24e8b MFC r313936, r313937: Move CTIO waitq from per-LUN to per-channel.
All resources lack of which may put CTIO into the queue are either
per-channel or potentially per-queue, but none of them are per-LUN.

This is a first step to fix live LUN disabling.  Before this change
any CTIOs held in a queue in time of disabling were just leaked.
2017-03-05 05:17:02 +00:00
Alexander Motin a3c801dc84 MFC r313945: Remove broken remnants of obsolete INOT API. 2017-03-05 05:15:02 +00:00
Kenneth D. Merry 532dd80e55 MFC r313568:
------------------------------------------------------------------------
  r313568 | ken | 2017-02-10 15:02:45 -0700 (Fri, 10 Feb 2017) | 68 lines

  Change the isp(4) driver to not adjust the tag type for REQUEST SENSE.

  The isp(4) driver was changing the tag type for REQUEST SENSE
  commands to Head of Queue, when the CAM CCB flag
  CAM_TAG_ACTION_VALID was NOT set.  CAM_TAG_ACTION_VALID is set
  when the tag action in the XPT_SCSI_IO is not CAM_TAG_ACTION_NONE
  and when the target has tagged queueing turned on.

  In most cases when CAM_TAG_ACTION_VALID is not set, it is because
  the target is not doing tagged queueing.  In those cases, trying to
  send a Head of Queue tag may cause problems.  Instead, default to
  sending a simple tag.

  IBM tape drives claim to support tagged queueing in their standard
  Inquiry data, but have the DQue bit set in the control mode page
  (mode page 10).  CAM correctly detects that these drives do not
  support tagged queueing, and clears the CAM_TAG_ACTION_VALID flag
  on CCBs sent down to the drives.

  This caused the isp(4) driver to go down the path of setting the
  tag action to a default value, and for Request Sense commands only,
  set the tag action to Head of Queue.

  If an IBM tape drive does get a Head of Queue tag, it rejects it with
  Invalid Message Error (0x49,0x00).  (The Qlogic firmware translates that
  to a Transport Error, which the driver translates to an Unrecoverable
  HBA Error, or CAM_UNREC_HBA_ERROR.) So, by default, it wasn't possible
  to get a good response from a REQUEST SENSE to an FC-attached IBM
  tape drive with the isp(4) driver.

  IBM tape drives (tested on an LTO-5 with G9N1 firmware and a TS1150
  with 4470 firmware) also have a bug in that sending a command with a
  non-simple tag attribute breaks the tape drive's Command Reference
  Number (CRN) accounting and causes it to ignore all subsequent
  commands because it and the initiator disagree about the next
  expected CRN.  The drives do reject the initial command with a head
  of queue tag with an Invalid Message Error (0x49,0x00), but after that
  they ignore any subsequent commands.  IBM confirmed that it is a bug,
  and sent me test firmware that fixes the bug.  However tape drives in
  the field will still exhibit the bug until they are upgraded.

  Request Sense is not often sent to targets because most errors are
  reported automatically through autosense in Fibre Channel and other
  modern transports.  ("Modern" meaning post SCSI-2.)  So this is not
  an error that would crop up frequently.  But Request Sense is useful on
  tape devices to report status information, aside from error reporting.

  This problem is less serious without FC-Tape features turned on,
  specifically precise delivery of commands (which enables Command
  Reference Numbers), enabled on the target and initiator.  Without
  FC-Tape features turned on, the target would return an error and
  things would continue on.

  And it also does not cause problems for targets that do tagged
  queueing, because in those cases the isp(4) driver just uses the
  tag type that is specified in the CCB, assuming the
  CAM_TAG_ACTION_VALID flag is set, and defaults to sending a Simple
  tag action if it isn't an ordered or head of queue tag.

  sys/dev/isp/isp.c:
  	In isp_start(), don't try to send Request Sense commands
  	with the Head of Queue tag attribute if the CCB doesn't
  	have a valid tag action.  The tag action likely isn't valid
  	because the target doesn't support tagged queueing.

  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
2017-02-13 16:06:38 +00:00
Kenneth D. Merry e4be6df155 MFC, r310338:
------------------------------------------------------------------------
  r310338 | ken | 2016-12-20 14:17:07 -0700 (Tue, 20 Dec 2016) | 37 lines

  Turn on FC-Tape by default in the isp(4) driver.

  FC-Tape provides additional link level error recovery, and is
  highly recommended for tape devices.  It will only be turned on for
  a given target if the target supports it.

  Without this setting, we default to whatever FC-Tape setting is in
  NVRAM on the card.

  This can be overridden by setting the following loader tunable, for
  example for isp0:

  hint.isp.0.nofctape=1

  sys/conf/options:
  	Add a new kernel config option, ISP_FCTAPE_OFF, that
  	defaults the FC-Tape configuration to off.

  sys/dev/isp/isp_pci.c:
  	If ISP_FCTAPE_OFF is defined, turn off FC-Tape.  Otherwise,
  	turn it on if the card supports it.

  share/man/man4/isp.4:
  	Add a description of FC-Tape to the isp(4) man page.

  	Add descriptions of the fctape and nofctape options, as well as the
  	ISP_FCTAPE_OFF kernel configuration option.

  	Add the ispfw module and kernel drivers to the suggested
  	configurations at the top of the man page so that users are less
  	likely to leave it out.  The driver works well with the included
  	firmware, but may not work at all with whatever firmware the user
  	has flashed on their card.

  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
Sponsored by:	Spectra Logic
2016-12-23 18:25:43 +00:00
Alexander Motin 873b0260d4 Pass proper for 23xx arguments to isp_endcmd(). 2016-05-20 11:56:16 +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
Alexander Motin 514a71eba7 Fix delaying requests to unknown virtual ports 2s after init.
This code was originally implemented 7 years ago, but never really worked
due to trivial error.  I think this functionality may be not required.
Initiators supporting optional periodic command status checks detected
those terminated commands and retried them 3 seconds later.  But thinking
about less featured initiators and the fact that it is our race makes
virtual ports "unknown" it may be good to have this feature.
2016-05-19 17:48:56 +00:00
Alexander Motin 352427b341 Add proper reporting for early task management errors.
This covers unknown requests and requests to unknown virtual ports.
Previously it "worked" only because of timeout handling on initiator.
2016-05-19 17:02:33 +00:00
Alexander Motin 0bd83292ef Add IOCB debugging for ISPCTL_RESET_DEV and ISPCTL_ABORT_CMD. 2016-05-19 16:53:53 +00:00
Alexander Motin 93d07b9a26 Unify Multi ID target code by reusing isp_find_chan_by_did(). 2016-05-18 16:15:09 +00:00