aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/isp
Commit message (Collapse)AuthorAgeFilesLines
* MFC r348247:Kenneth D. Merry2019-05-312-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r348247 | ken | 2019-05-24 13:58:29 -0400 (Fri, 24 May 2019) | 57 lines Fix FC-Tape bugs caused in part by r345008. The point of r345008 was to reset the Command Reference Number (CRN) in some situations where a device stayed in the topology, but had changed somehow. This can include moving from a switch connection to a direct connection or vice versa, or a device that temporarily goes away and comes back. (e.g. moving to a different switch port) There were a couple of bugs in that change: - We were reporting that a device had not changed whenever the Establish Image Pair bit was not set. That is not quite correct. Instead, if the Establish Image Pair bit stays the same (set or not), the device hasn't changed in that way. - We weren't setting PRLI Word0 in the port database when a new device arrived, so comparisons with the old value for the Establish Image Pair bit weren't really possible. So, make sure PRLI Word0 is set in the port database for new devices. - We were resetting the CRN whenever the Establish Image Pair bit was set for a device, even when the device had stayed the same and the value of the bit hadn't changed. Now, only reset the CRN for devices that have changed, not devices that sayed the same. The result of all of this was that if we had a single FC device on an FC port and it went away and came back, we would wind up correctly resetting the CRN. But, if we had multiple devices connected via a switch, and there was any change in one or more of those devices, all of the devices that stayed the same would also have their CRN values reset. The result, from a user standpoint, is that the tape drives, etc. would all start to time out commands and the initiator would send aborts. sys/dev/isp/isp.c: In isp_pdb_add_update(), look at whether the Establish Image Pair bit has changed as part of the check to determine whether a device is still the same. This was causing erroneous change notifications. Also, when creating a new port database entry, initialize the PRLI Word 0 values. sys/dev/isp/isp_freebsd.c: In isp_async(), in the changed/stayed case, instead of looking at the Establish Image Pair bit to determine whether to reset the CRN, look at the command value. (Changed vs. Stayed.) Only reset the CRN for devices that have changed. ------------------------------------------------------------------------ Sponsored by: Spectra Logic Notes: svn path=/stable/12/; revision=348480
* MFC r345008:Kenneth D. Merry2019-05-175-3/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r345008 | ken | 2019-03-11 10:21:14 -0400 (Mon, 11 Mar 2019) | 59 lines Fix CRN resets in the isp(4) driver in certain situations. The Command Reference Number (CRN) is part of the FC-Tape features that we enable when talking to tape drives. It starts at 1, and goes to 255 and wraps around to 1. There are a number of reset type conditions that result in the CRN getting reset to 1. These are detailed in section 4.10 (table 8) of the FCP-4r02b specification. One of the conditions is when a PRLI (Process Login) is sent by the initiator, and the Establish Image Pair bit is set in Word 0 of the PRLI. Previously, the isp(4) driver core sent a notification via isp_async() that the target had changed or stayed in place, but there was no indication of whether a PRLI was sent and whether the Establish Image Pair bit was set. The result of this was that in some situations, notably switching back and forth between a direct connection and a switch connection to a tape drive, the isp(4) driver would fail to reset the CRN in situations that require it according to the spec. When the CRN isn't reset in a situation that requires it, the tape drive then rejects every subsequent command that is sent to the drive. It is assuming that the commands are being sent out of order. So, modify the isp(4) driver to include Word 0 of the PRLI command when it sends isp_async() notifications of target changes. Look at the Establish Image Pair bit, and reset the CRN if that bit is set. With this change, I am able to switch a tape drive back and forth between a direct connection and a switch connection, and the isp(4) driver resets the CRN when it should. sys/dev/isp_stds.h: Add bit definitions for PRLI Word 0. sys/dev/ispmbox.h: Add PRLI Word 0 to the port database type, isp_pdb_t. sys/dev/ispvar.h Add PRLI Word 0 to fcportdb_t. sys/dev/isp.c: Populate the new prli_word0 parameter in the port database. In isp_pdb_add_update(), add a check to see if the Establish Image Pair bit is set in PRLI Word 0. If it is, then that is an additional reason to create a change notification. sys/dev/isp_freebsd.c: In isp_async(), if the device changed or stayed, look at PRLI Word 0 to see if the Establish Image Pair bit is set. If it is, reset the CRN if we haven't already. Sponsored by: Spectra Logic ------------------------------------------------------------------------ Differential Revision: https://reviews.freebsd.org/D19472 Notes: svn path=/stable/12/; revision=347906
* MFC r344661, r344669: Limit 24xx adapters to only MSI interrupts by default.Alexander Motin2019-03-081-1/+1
| | | | | | | | | | This was actually the known good configuration we used before. Single MSI-X configuration doesn't even work there on my tests, just due to lack of documentation not sure whether by design or I am doing something wrong. Notes: svn path=/stable/12/; revision=344910
* MFC r344660: Add to isp(4) tunables to limit MSI/MSI-X usage.Alexander Motin2019-03-081-2/+9
| | | | | | | | | There are some problem reports possibly related to the new driver use of multiple interrupts on older cards. Hopefully this allow to workaround them. Notes: svn path=/stable/12/; revision=344908
* Make timespecadd(3) and friends publicAlan Somers2018-07-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | The timespecadd(3) family of macros were imported from NetBSD back in r35029. However, they were initially guarded by #ifdef _KERNEL. In the meantime, we have grown at least 28 syscalls that use timespecs in some way, leading many programs both inside and outside of the base system to redefine those macros. It's better just to make the definitions public. Our kernel currently defines two-argument versions of timespecadd and timespecsub. NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define three-argument versions. Solaris also defines a three-argument version, but only in its kernel. This revision changes our definition to match the common three-argument version. Bump _FreeBSD_version due to the breaking KPI change. Discussed with: cem, jilles, ian, bde Differential Revision: https://reviews.freebsd.org/D14725 Notes: svn path=/head/; revision=336914
* Increase ABOUT FIRMWARE command timeout to 5s.Alexander Motin2018-03-151-3/+7
| | | | | | | | | | | It seems default timeout of 100ms is not enough for my 2694L card, while it was perfectly fine for others, even for full-height 2694. MFC after: 1 week Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=330963
* Fix ISP_FC_LIP and ISP_RESCAN on big-endian 64-bit systems.Brooks Davis2018-03-131-2/+2
| | | | | | | | | | | | | | | | | | For _IO() ioctls, addr is a pointer to uap->data which is a caddr_t. When the caddr_t stores an int, dereferencing addr as an (int *) results in truncation on little-endian 64-bit systems and corruption (owing to extracting top bits) on big-endian 64-bit systems. In practice the value of chan was probably always zero on systems of the latter type as all such FreeBSD platforms use a register-based calling convention. Reviewed by: mav Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14673 Notes: svn path=/head/; revision=330876
* Add support for Enhanced Gen 5 (16Gb) and Gen 6 (32Gb) QLogic FC HBAs.Alexander Motin2018-02-284-88/+83
| | | | | | | | MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=330121
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2714-0/+28
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326255
* Update several more URLsEitan Adler2017-10-291-1/+1
| | | | | | | | - Primarily http -> https - Primarily FreeBSD project URLs Notes: svn path=/head/; revision=325096
* Add missing restart_queue initialization.Alexander Motin2017-08-231-0/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=322821
* Remove duplicate assignments from r321622.Kenneth D. Merry2017-07-271-2/+0
| | | | | | | | | Submitted by: mav MFC after: 3 days Sponsored by: Spectra Logic Notes: svn path=/head/; revision=321623
* Fix probing FC targets with hard addressing turned on.Kenneth D. Merry2017-07-271-21/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 MFC after: 3 days Sponsored by: Spectra Logic Notes: svn path=/head/; revision=321622
* "Port Type not registered" is not a real error for GIT_PT.Alexander Motin2017-07-101-1/+4
| | | | Notes: svn path=/head/; revision=320865
* Switch fabric scans from GID_FT to GID_PT+GFF_ID/GFT_ID.Alexander Motin2017-07-036-76/+281
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=320604
* Move comment respecting previous commit.Alexander Motin2017-07-021-13/+13
| | | | Notes: svn path=/head/; revision=320575
* Slightly unify SNS requests for post- and pre-24xx.Alexander Motin2017-07-022-133/+94
| | | | Notes: svn path=/head/; revision=320574
* Polish target_id/target_lun setting for ATIOs/INOTs.Alexander Motin2017-06-301-3/+5
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=320492
* Correct loop mode CRN resets to adhere to FCP-4 section 4.10Kenneth D. Merry2017-05-034-36/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=317740
* Switch isp_reset to scratchpad not requiring ISP_MBOXDMASETUP.Alexander Motin2017-04-241-2/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=317356
* Fix few minor issues found by Clang Analyzer.Alexander Motin2017-04-092-2/+2
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=316652
* Add brackets to fix incorrect macro expansion.Alexander Motin2017-03-241-1/+1
| | | | | | | | Reported by: Andreas Hollmann / PVS-Studio MFC after: 2 weeks Notes: svn path=/head/; revision=315913
* Unify initiator and target DMA setup and command sending.Alexander Motin2017-03-247-332/+114
| | | | | | | | | The code is so alike that it is pointless to keep it separate. MFC after: 2 weeks Notes: svn path=/head/; revision=315908
* isp field in struct isp_pcmd is also unused.Alexander Motin2017-03-231-1/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315870
* Remove write-only crn field from struct isp_pcmd.Alexander Motin2017-03-232-3/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315869
* Switch from using periph_links to sim_links.Alexander Motin2017-03-221-10/+10
| | | | | | | | | periph_links field belongs to periph drivers and must not be used here. MFC after: 2 weeks Notes: svn path=/head/; revision=315709
* Cleanup response queue processing.Alexander Motin2017-03-224-318/+153
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315708
* Remove another remnants left after r246713.Alexander Motin2017-03-212-4/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315683
* Remove some dead code left after r246713.Alexander Motin2017-03-212-38/+3
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315682
* Improve command timeout handling.Alexander Motin2017-03-214-36/+14
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315681
* Remove questionable reqp->req_time access.Alexander Motin2017-03-211-4/+5
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315678
* Clean/unify some macro usage.Alexander Motin2017-03-214-62/+51
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315677
* Addition to r315579: drop the lock while allocating IRQs.Alexander Motin2017-03-211-0/+2
| | | | | | | MFC after: 12 days Notes: svn path=/head/; revision=315670
* Remove some more dead code.Alexander Motin2017-03-203-38/+8
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315652
* Remove some useless code.Alexander Motin2017-03-193-16/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315587
* Add initial support for multiple MSI-X vectors.Alexander Motin2017-03-197-64/+119
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315579
* Remove hackish code delaying ATIOs to unknown virtual port.Alexander Motin2017-03-194-53/+28
| | | | | | | | | | 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 Notes: svn path=/head/; revision=315545
* Move <= 23xx PDB workaround to generic code.Alexander Motin2017-03-192-18/+29
| | | | | | | | | It is chip-specific and has nothing to do with platform. MFC after: 2 weeks Notes: svn path=/head/; revision=315536
* Remove some dead stuff.Alexander Motin2017-03-191-16/+5
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315534
* Move 24xx RQSTYPE_NOTIFY handling to generic code.Alexander Motin2017-03-193-181/+156
| | | | | | | | | This code has nothing to do with specific platform. MFC after: 2 weeks Notes: svn path=/head/; revision=315533
* Reorganize RQSTYPE_NOTIFY handling for chips <= 23xx.Alexander Motin2017-03-182-191/+87
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=315507
* Move RQSTYPE_ABTS_RCVD parsing into generic code.Alexander Motin2017-03-182-57/+51
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315489
* Extend nt_lun to full 8 byte.Alexander Motin2017-03-183-11/+11
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315488
* Remove dead remnants of SPI target.Alexander Motin2017-03-184-82/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315485
* Use isp_target_put_entry() in places where it can be.Alexander Motin2017-03-182-64/+35
| | | | | | | | | This unifies the code and removes some duplication. MFC after: 2 weeks Notes: svn path=/head/; revision=315482
* Do some notify acks cleanup.Alexander Motin2017-03-182-79/+74
| | | | | | | | | ISPASYNC_TARGET_NOTIFY_ACK makes no sense without argument. MFC after: 2 weeks Notes: svn path=/head/; revision=315478
* Remove not very useful ATIO/INOT stats.Alexander Motin2017-03-152-14/+9
| | | | | | | | | While there polish respective debug logging. MFC after: 2 weeks Notes: svn path=/head/; revision=315327
* Refactor interrupt handling.Alexander Motin2017-03-155-355/+198
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315307
* Fix panic when SIM dereferenced before allocation.Alexander Motin2017-03-151-24/+25
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315303
* Fix ancient bug from r84597, which broke 23xx after r315234.Alexander Motin2017-03-151-1/+1
| | | | | | | MFC after: 13 days Notes: svn path=/head/; revision=315298