Commit Graph
915 Commits
Author SHA1 Message Date
Alexander Motin 2ae92170f2 MFC r322821: Add missing restart_queue initialization. 2017-08-30 06:28:09 +00:00
Kenneth D. Merry 00359659e3 MFC r321622, r321623:
------------------------------------------------------------------------
  r321622 | ken | 2017-07-27 09:33:57 -0600 (Thu, 27 Jul 2017) | 44 lines

  Fix probing FC targets with hard addressing turned on.

  This largely reverts FreeBSD SVN change 289937 from October 25th, 2015.

  The intent of that change was to keep loop IDs persistent across
  chip reinits.

  The problem is that the change turned on the PREVLOOP /
  PREV_ADDRESS bit (bit 7 in Firmware Options 2), which tells the
  Qlogic chip to not participate in the loop if it can't get the
  requested loop address.  It also turned off soft addressing on 2400
  (4Gb) and newer controllers.

  The isp(4) driver defaults to loop address 0, and the tape drives
  I have tested default to loop address 0 if hard addressing is turned
  on.  So when hard loop addressing is turned on on the drive, the isp(4)
  driver just refuses to participate in the loop.

  The solution is to largely revert that change.  I left some elements
  in place that are related to virtual ports, since they were new.

  This does work with IBM tape drives with hard and soft addressing
  turned on.  I have tested it with 4Gb, 8Gb, and 16Gb controllers.

  sys/dev/isp.c:
  	Largely revert FreeBSD SVN change 289937.  I left the
  	ispmbox.h changes in place.

  	Don't use the PREV_ADDRESS bit on initialization.  It tells
  	the chip to not participate if it can't get the requested
  	loop ID.

  	Do use soft addressing on 2400 and newer chips.

  	Use hard addressing when the user has requested a specific
  	initiator ID.  (hint.isp.X.iid=N in /boot/loader.conf)

  	Leave some of the virtual port options from that change in
  	place, but don't turn on the PREV_ADDRESS bit.

  Reviewed by:	mav
  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
  r321623 | ken | 2017-07-27 09:51:56 -0600 (Thu, 27 Jul 2017) | 6 lines

  Remove duplicate assignments from r321622.

  Submitted by:	mav
  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
2017-08-02 20:24:26 +00:00
Alexander Motin dbce1d6f1e MFC r320604, r320865:
Switch fabric scans from GID_FT to GID_PT+GFF_ID/GFT_ID.

Instead of using GID_FT SNS request to get list of registered FCP ports,
use GID_PT to get list of all Nx_Ports, and then use GFF_ID and/or GFT_ID
requests to find whether they are FCP and target capable.

The problem with old approach is that GID_FT does not report ports without
FC-4 type registered.  In particular it was impossible to boot OS from
FreeBSD FC target using QLogic FC BIOS, since one does not register FC-4
type even on new cards and so ignored by old code as incompatible.

As a side bonus this allows initiator to skip pointless logins to other
initiators by fetching that information from SNS instead.

In case some switches do not implement GFF_ID/GFT_ID correctly, add sysctls
to disable that functionality.  I handled broken GFF_ID of my Brocade 200E,
but there may be other switches with different bugs.

Linux also uses GID_PT, but GFF_ID is disabled by default there, and GFT_ID
is not supported.

Sponsored by:	iXsystems, Inc.
2017-08-01 13:03:06 +00:00
Alexander Motin c5146e1140 MFC r320575: Move comment respecting previous commit. 2017-08-01 13:00:13 +00:00
Alexander Motin 3dc607428a MFC r320574: Slightly unify SNS requests for post- and pre-24xx. 2017-08-01 12:59:37 +00:00
Alexander Motin c8f9ee4864 MFC r320492: Polish target_id/target_lun setting for ATIOs/INOTs.
For ATIOs it is pointless to report isp_loopid to CAM, since in other
places it operates with port database record IDs, not with loop IDs.

For INOTs target_id/target_lun seems were never set, so wildcard INOTs
probably were not working correctly when LUN IDs were important.
2017-08-01 12:58:48 +00:00
Kenneth D. Merry a46d8510b6 MFC r317740:
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
2017-05-10 18:59:18 +00:00
Alexander Motin a4cac0db9a MFC r317356: Switch isp_reset to scratchpad not requiring ISP_MBOXDMASETUP. 2017-05-01 06:04:34 +00:00
Alexander Motin 302634478a MFC r315913: Add brackets to fix incorrect macro expansion. 2017-04-24 11:12:03 +00:00
Alexander Motin 5f1be74b8c MFC r315908: Unify initiator and target DMA setup and command sending.
The code is so alike that it is pointless to keep it separate.
2017-04-24 10:21:13 +00:00
Alexander Motin 86d27d4fe7 MFC r315870: isp field in struct isp_pcmd is also unused. 2017-04-24 10:20:36 +00:00
Alexander Motin 3a81e654d7 MFC r315869: Remove write-only crn field from struct isp_pcmd. 2017-04-24 10:19:59 +00:00
Alexander Motin a290bb1a6d MFC r315708: Cleanup response queue processing. 2017-04-24 10:19:26 +00:00
Alexander Motin 8ab1460801 MFC r316652: Fix few minor issues found by Clang Analyzer. 2017-04-23 07:36:44 +00:00
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