aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/isp/isp.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r321622, r321623:Kenneth D. Merry2017-08-021-21/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ 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 ------------------------------------------------------------------------ Notes: svn path=/stable/10/; revision=321945
* MFC r317740:Kenneth D. Merry2017-05-101-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/stable/10/; revision=318149
* MFC r317356: Switch isp_reset to scratchpad not requiring ISP_MBOXDMASETUP.Alexander Motin2017-05-011-2/+2
| | | | Notes: svn path=/stable/10/; revision=317636
* MFC r315708: Cleanup response queue processing.Alexander Motin2017-04-241-288/+141
| | | | Notes: svn path=/stable/10/; revision=317363
* MFC r316652: Fix few minor issues found by Clang Analyzer.Alexander Motin2017-04-231-1/+2
| | | | Notes: svn path=/stable/10/; revision=317322
* MFC r315681: Improve command timeout handling.Alexander Motin2017-04-021-5/+1
| | | | | | | | | | 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. Notes: svn path=/stable/10/; revision=316407
* MFC r315678: Remove questionable reqp->req_time access.Alexander Motin2017-04-021-4/+5
| | | | Notes: svn path=/stable/10/; revision=316405
* MFC r315587, r315652: Remove some dead/useless code.Alexander Motin2017-04-021-11/+0
| | | | Notes: svn path=/stable/10/; revision=316401
* MFC r315579, r315670: Add initial support for multiple MSI-X vectors.Alexander Motin2017-04-021-1/+7
| | | | | | | | | | 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. Notes: svn path=/stable/10/; revision=316399
* MFC r315545: Remove hackish code delaying ATIOs to unknown virtual port.Alexander Motin2017-03-291-6/+0
| | | | | | | | 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. Notes: svn path=/stable/10/; revision=316169
* MFC r315485: Remove dead remnants of SPI target.Alexander Motin2017-03-291-2/+0
| | | | Notes: svn path=/stable/10/; revision=316155
* MFC r315307: Refactor interrupt handling.Alexander Motin2017-03-291-185/+76
| | | | | | | | | | | | | 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. Notes: svn path=/stable/10/; revision=316146
* MFC r315279: Remove some dead/broken code paths around async handlingAlexander Motin2017-03-281-45/+21
| | | | Notes: svn path=/stable/10/; revision=316093
* MFC r315273: Remove tangled isp_mbox_continue() mechanism.Alexander Motin2017-03-281-225/+39
| | | | | | | | | | 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. Notes: svn path=/stable/10/; revision=316091
* MFC r315236: Remove dangerous and questionable isp_mboxcmd_qnw() call.Alexander Motin2017-03-281-17/+4
| | | | Notes: svn path=/stable/10/; revision=316089
* MFC r315234: Improvements around attach, reset and detach.Alexander Motin2017-03-281-103/+89
| | | | | | | | | | 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. Notes: svn path=/stable/10/; revision=316087
* MFC r315161: Try to slight untangle I/O and loop status handling.Alexander Motin2017-03-261-10/+10
| | | | Notes: svn path=/stable/10/; revision=315980
* MFC r315160: Remove code for unsupported FreeBSD versions.Alexander Motin2017-03-261-16/+0
| | | | Notes: svn path=/stable/10/; revision=315978
* MFC r314326: Send TERMINATE to firmware when aborting active ATIO.Alexander Motin2017-03-061-1/+1
| | | | Notes: svn path=/stable/10/; revision=314765
* MFC r314302: Return better error code in case of too long CDB.Alexander Motin2017-03-061-4/+5
| | | | | | | | 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. Notes: svn path=/stable/10/; revision=314759
* MFC r313568:Kenneth D. Merry2017-02-131-13/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ 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 ------------------------------------------------------------------------ Notes: svn path=/stable/10/; revision=313700
* MFC r300222: Fix delaying requests to unknown virtual ports 2s after init.Alexander Motin2016-08-181-0/+5
| | | | | | | | | | | | 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. Notes: svn path=/stable/10/; revision=304416
* MFC r300217: Add IOCB debugging for ISPCTL_RESET_DEV and ISPCTL_ABORT_CMD.Alexander Motin2016-05-241-0/+8
| | | | Notes: svn path=/stable/10/; revision=300583
* MFC r300058: Make RQCS_PORT_LOGGED_OUT for ZOMBIE ports retriable.Alexander Motin2016-05-241-4/+18
| | | | | | | | It is normal for ZOMBIE ports to be logged out. This status is not really an error until Gone Device Timeout expires, so make CAM retry after delay. Notes: svn path=/stable/10/; revision=300581
* MFC r300052: Completely remove broken now autologin port flag.Alexander Motin2016-05-241-2/+1
| | | | | | | | Firmware automatically logs in only to local loop ports, and those ports can be easily identified without extra flag by zero domain and area IDs. Notes: svn path=/stable/10/; revision=300580
* MFC r299955: No need to check login status for ZOMBIE ports.Alexander Motin2016-05-241-0/+3
| | | | | | | ZOMBIE ports are always logged out, and so initiator may try to relogin. Notes: svn path=/stable/10/; revision=300578
* MFC r298103: Simplify memory allocation for NS requests.Alexander Motin2016-05-031-33/+28
| | | | | | | | | Since we no longer need additional buffers for request and response IOCBs, we can increase receive space by 192 bytes, that is enough for fetching 48 more ports. The new limit is 1020 fabric ports per virtual port. Notes: svn path=/stable/10/; revision=298975
* MFC r297991: Extract virtual port address from RQSTYPE_RPT_ID_ACQ.Alexander Motin2016-05-031-4/+12
| | | | | | | | | This should close the race between request arriving on new target mode virtual port and its scanner thread finally fetch its address for request routing. Notes: svn path=/stable/10/; revision=298972
* MFC r297915: Filter Port Database Changed notifications.Alexander Motin2016-05-031-2/+9
| | | | | | | | | | For some reason firmware sends Port Database Changed notifications in case of explicit login requests from the driver when target port is unavailabe. Those notifications don't give driver any new information, but only cause infinite scan loop. Notes: svn path=/stable/10/; revision=298970
* MFC r297912: Respect NVRAM topology settings on 24xx and above chips.Alexander Motin2016-05-031-16/+31
| | | | Notes: svn path=/stable/10/; revision=298969
* MFC r297867: Make all CT Pass-Through (name server requests) asynchronous.Alexander Motin2016-05-031-57/+78
| | | | | | | | | | | Previously we had to do it synchronously because we could not drop the lock due to potential scratch memory use conflicts. Previous commits fixed that collision, so here it goes -- slower and less reliable external requests are executed asynchronously without spinning in tight loop and with more safe timeout handling. Notes: svn path=/stable/10/; revision=298968
* MFC r297859: Switch isp_getpdb() to synchronous IOCB DMA area.Alexander Motin2016-05-031-18/+11
| | | | | | | | While technically it is not IOCB, it is synchronous and can be called from different places, so calling FC_SCRATCH_ACQUIRE() here is inconvenient. Notes: svn path=/stable/10/; revision=298967
* MFC r297858: Allocate separate DMA area for synchronous IOCB execution.Alexander Motin2016-05-031-37/+23
| | | | | | | | | | | Usually IOCBs should be put on queue for asynchronous processing and should not require additional DMA memory. But there are some cases like aborts and resets that for external reasons has to be synchronous. Give those cases separate 2*64 byte DMA area to decouple them from other DMA scratch area users, using it for asynchronous requests. Notes: svn path=/stable/10/; revision=298966
* MFC r297854: Add couple missing memory barriers.Alexander Motin2016-05-031-1/+3
| | | | Notes: svn path=/stable/10/; revision=298964
* MFC r297817: Polish debugging IOCB dumping.Alexander Motin2016-05-031-27/+36
| | | | | | | Add few more missing cases, unify byte order. Notes: svn path=/stable/10/; revision=298963
* MFC r297751: Register symbolic port/node names in FC name server.Alexander Motin2016-05-031-6/+128
| | | | | | | | | | This is cosmetics that simplifies identification of new ports on FC switch. It would be good to use target name from CTL here instead of hostname, but it is not passed here through CAM now. Notes: svn path=/stable/10/; revision=298962
* MFC r297741: Reduce code duplication when executing Passthrough IOCB.Alexander Motin2016-05-031-187/+80
| | | | Notes: svn path=/stable/10/; revision=298961
* MFC r292765: Allocate separate scratch space for scanner purposes.Alexander Motin2015-12-301-113/+92
| | | | | | | | | | | This space does not require DMA syncing. It reduces lock scope of the DMA scratch space. It allows whole DMA scratch space to be used to I/O, so now we can fetch up to ~1000 ports from SNS. Due to the last fact, increase maximal number of ports from 256 to 1024. Notes: svn path=/stable/10/; revision=292931
* MFC r292741: Make port logins asynchronous, following r292739 logic.Alexander Motin2015-12-301-66/+55
| | | | | | | | This is even more important since it involves more network operations and more prone to delays and timeouts. Notes: svn path=/stable/10/; revision=292924
* MFC r292739: Make virtual ports control asynchronous.Alexander Motin2015-12-301-82/+96
| | | | | | | | | | | | | | | Before this change virtual ports control IOCBs were executed synchronously via Execute IOCB mailbox command. It required exclusive use of scratch space of driver and mailbox registers of the hardware. Because of that shared resources use this code could not really sleep, having to spin for completion, blocking any other operation. This change introduces new asynchronous design, sending the IOCBs directly on request queue and gracefully waiting for their return on response queue. Returned IOCBs are identified with unified handle space from r292725. Notes: svn path=/stable/10/; revision=292922
* MFC r292725: Unify handles allocation for initiator and target IOCBs.Alexander Motin2015-12-301-11/+5
| | | | | | | | | I am not sure why this was split long ago, but I see no reason for it. At this point this unification just slightly reduces memory usage, but as next step I plan to reuse shared handle space for other IOCB types. Notes: svn path=/stable/10/; revision=292921
* MFC r292715: Clear virtual port's port database when disabling it.Alexander Motin2015-12-301-0/+153
| | | | | | | | Previously it was done only on full chip reinit, that caused old ports resurrect in case of virtual port reenabling. Notes: svn path=/stable/10/; revision=292919
* MFC r292690: Some polishing for command timeouts handling.Alexander Motin2015-12-301-15/+17
| | | | Notes: svn path=/stable/10/; revision=292918
* MFC r292610: Fix speed setting by NVRAM for 24xx and above chips.Alexander Motin2015-12-301-2/+26
| | | | Notes: svn path=/stable/10/; revision=292916
* MFC r291654, r291727, r291821, r291872, r292034, r292041, r292249, r292042:Alexander Motin2015-12-221-23/+46
| | | | | | | Add initial support for 16Gbps FC QLogic chips. Notes: svn path=/stable/10/; revision=292598
* MFC r291365, r291369: One more round of port scanner rewrite.Alexander Motin2015-11-301-40/+63
| | | | | | | | | | - Make scan aborted by event restart immediately and infinitely. - Improve handling of some loop events from firmware. - Remove loop down timer, adding its functionality to scanner thread. - Some more unification and simplification. Notes: svn path=/stable/10/; revision=291532
* MFC r291265: Rename ASYNC_LIP_F8 to ASYNC_LIP_NOS_OLS_RECV.Alexander Motin2015-11-301-1/+1
| | | | | | | New name better repsents its meaning for modern chips. Notes: svn path=/stable/10/; revision=291531
* MFC r291209: Fix target mode support for Qlogic 2200 FC adapters.Alexander Motin2015-11-301-5/+9
| | | | | | | | Now target mode works for all supported FC adapters except ancient 2100, which is not tested. Notes: svn path=/stable/10/; revision=291529
* MFC r291188: Rip off target mode support for parallel SCSI QLogic adapters.Alexander Motin2015-11-301-34/+15
| | | | | | | | | | Hacks to enable target mode there complicated code, while didn't really work. And for outdated hardware fixing it is not really interesting. Initiator mode tested with Qlogic 1080 adapter is still working fine. Notes: svn path=/stable/10/; revision=291528
* MFC r291163:Alexander Motin2015-11-301-3/+18
| | | | | | | | | | | Explicitly call SEND CHANGE REQUEST for pre-24xx chips in target mode. While later firmware always registers for RSCN requests, older one does it only in initiator mode. But in target mode there RSCN can be the only way to detect gone intiator. Notes: svn path=/stable/10/; revision=291523