aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/isp/ispvar.h
Commit message (Collapse)AuthorAgeFilesLines
* Some code reorganization.Alexander Motin2020-11-271-5/+3
| | | | | | | | | | | | | | | | - Remove code duplication by adding two new functions to execute prepared queue entry via either mbox or request queue and wait for result. - Since the new function executing via request queue sleeps any way, make it sleep also in case of overflows or handle shortages. It should make it more reliable and less affecting other less flexible request queue users. - Turn isp_target_put_entry() into not target-specific isp_send_entry(). - Make handling of responses with control handles more universal. - Move RQSTYPE_RPT_ID_ACQ handling into new function. - Inline isp_handle_other_response(), becoming trivial after above. - Clean the list of IOCBs from pre-24xx ones. Notes: svn path=/head/; revision=368105
* More cleanup in response queue and reset code.Alexander Motin2020-11-261-3/+0
| | | | Notes: svn path=/head/; revision=368079
* Remove some more dead code from pre-24xx.Alexander Motin2020-11-261-1/+0
| | | | Notes: svn path=/head/; revision=368043
* Remove more legacy of parallel SCSI.Alexander Motin2020-11-241-11/+6
| | | | Notes: svn path=/head/; revision=368001
* Remove concept of mbox_sleep_ok.Alexander Motin2020-11-241-5/+0
| | | | | | | | | | | | | It was broken by design and unused for years due to conflicts between different threads, fighting for the same set of mailbox registers, not designed for multiple requests at a time. So either request has to be synchronous and spin under the lock, or it should be sent asynchronously through the queues as Mailbox Command IOCB or some other way. This removes any OS specifics from the wait code, so it can be inlined. Notes: svn path=/head/; revision=367986
* Implement request queue overflow protection.Alexander Motin2020-11-241-5/+6
| | | | | | | | | | | | | | | | Before this change in case of request queue overflow driver just froze the device queue for 100ms to retry after. It was pretty bad for performance. This change introduces SIM queue freezing when free space on the request queue drops below 255 entries (worst case of maximum I/O size S/G list), checking for a chance to release it on I/O completion. If the queue still get overflowed somehow, the old mechanism is still in place, just with delay reduced to 10ms. With the earlier queue length increase overflows should not happen often, but it is still easily reachable on synthetic tests. Notes: svn path=/head/; revision=367979
* Make handlers and atpds overflows unlikely.Alexander Motin2020-11-221-7/+9
| | | | | | | | | | | - Allocate 256 handlers more than payload commands for management purposes. - Increase maximum number of handlers from 8K to 16K by tuning the format. - Just to be safe limit the number of payload commands to 16K - 256. - Limit number of target exchanges in mixed mode to the number of atpds. - If we still somehow get out of atpds -- return BUSY, since we really are. Notes: svn path=/head/; revision=367926
* Remove remnants of execthrottle and maxalloc parameters.Alexander Motin2020-11-221-3/+0
| | | | | | | | The first was obsolete since 26xx, not used on 25xx and not needed on 24xx. The second seems never worked on 24xx and up. Notes: svn path=/head/; revision=367924
* Increase queue depths from 1024/256 to 8192/1024 IOCBs.Alexander Motin2020-11-201-12/+7
| | | | | | | | | | | | | | Qlogic chips store S/G lists in the same queue as requests themselves. In the worst case 1MB I/O may require up to 52 IOCBs, that means queue of 1024 IOCBs can store only 19 of such requests. The increase reduces chances of overflow, while we should be able to afford additional 512KB of RAM per HBA. The Linux driver uses comparable numbers. While there, decouple ATIO queue size from response queue size. There is no reason for them to be equal. Notes: svn path=/head/; revision=367909
* Cleanup DMA handling.Alexander Motin2020-11-201-10/+6
| | | | | | | | | | | | - Make isp_start() to set all the IOCB fields aside of S/G list, removing extra information from isp_send_cmd(), now only doing S/G lists and sending. - Turn DMA setup/free from being card and PCI-specific into OS-specific, instead add new card-specific method for isp_send_cmd(). Previously this function was a monster handling all the cards. - Remove double error code translation. Notes: svn path=/head/; revision=367906
* Remove parallel SCSI and 1/2Gb FC support from isp(4).Alexander Motin2020-11-201-176/+10
| | | | | | | | | | | | | | | | | | | | | This removes 288KB (36%) of the driver code and zillions of hacks and workarounds, making single driver uniformly support several different generations of hardware interfaces, not counting minor card variations. After years of the hopeless fight, I don't think it worth to continue support for hardware obsolete for 15-20 years. Instead much cleaner now code should allow to move forward toward better locking, multiple queues and other cool features. All the remaining Qlogic cards starting from 4Gb 24xx to 32Gb 27xx use the same hardware/firmware interface with minor incremental improvements, so it seems to be a good new starting point. Except one PCI-X model all all of them are PCIe and so still usable in modern systems. Discussed with: ken, scottl, jpaetzel, imp Relnotes: yes Notes: svn path=/head/; revision=367857
* Introduce support of SCSI Command Priority.Alexander Motin2020-10-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SAM-3 specification introduced concept of Task Priority, that was renamed to Command Priority in SAM-4, and supported by all modern SCSI transports. It provides 15 levels of relative priorities: 1 - highest, 15 - lowest and 0 - default. SAT specification for SATA devices translates priorities 1-3 into NCQ high priority. This change adds new "priority" field into empty spots of struct ccb_scsiio and struct ccb_accept_tio of CAM and struct ctl_scsiio of CTL. Respective support is added into iscsi(4), isp(4), mpr(4), mps(4) and ocs_fc(4) drivers for both initiator and where applicable target roles. Minimal support was added to CTL to receive the priority value from different frontends, pass it between HA controllers and report in few places. This patch does not add consumers of this functionality, so nothing should really change yet, since the field is still set to 0 (default) on initiator and not actively used on target. Those are to be implemented separately. I've confirmed priority working on WD Red SATA disks connected via mpr(4) and properly transferred to CTL target via iscsi(4), isp(4) and ocs_fc(4). While there, added missing tag_action support to ocs_fc(4) initiator role. MFC after: 1 month Relnotes: yes Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=367044
* Fix CRN resets in the isp(4) driver in certain situations.Kenneth D. Merry2019-03-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. MFC after: 1 week Sponsored by: Spectra Logic Differential Revision: https://reviews.freebsd.org/D19472 Notes: svn path=/head/; revision=345008
* Add support for Enhanced Gen 5 (16Gb) and Gen 6 (32Gb) QLogic FC HBAs.Alexander Motin2018-02-281-6/+9
| | | | | | | | 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-271-0/+2
| | | | | | | | | | | | | | | 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
* Switch fabric scans from GID_FT to GID_PT+GFF_ID/GFT_ID.Alexander Motin2017-07-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Correct loop mode CRN resets to adhere to FCP-4 section 4.10Kenneth D. Merry2017-05-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Unify initiator and target DMA setup and command sending.Alexander Motin2017-03-241-0/+1
| | | | | | | | | The code is so alike that it is pointless to keep it separate. MFC after: 2 weeks Notes: svn path=/head/; revision=315908
* Cleanup response queue processing.Alexander Motin2017-03-221-7/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315708
* Improve command timeout handling.Alexander Motin2017-03-211-1/+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. MFC after: 2 weeks Notes: svn path=/head/; revision=315681
* Remove some more dead code.Alexander Motin2017-03-201-2/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315652
* Remove some useless code.Alexander Motin2017-03-191-1/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315587
* Add initial support for multiple MSI-X vectors.Alexander Motin2017-03-191-0/+2
| | | | | | | | | | | | 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-191-1/+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. MFC after: 2 weeks Notes: svn path=/head/; revision=315545
* Refactor interrupt handling.Alexander Motin2017-03-151-20/+9
| | | | | | | | | | | | | | | 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
* Remove some dead/broken code paths around async handlingAlexander Motin2017-03-141-3/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315279
* Remove tangled isp_mbox_continue() mechanism.Alexander Motin2017-03-141-5/+0
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315273
* Improvements around attach, reset and detach.Alexander Motin2017-03-141-13/+11
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315234
* Add proper reporting for early task management errors.Alexander Motin2016-05-191-1/+2
| | | | | | | | This covers unknown requests and requests to unknown virtual ports. Previously it "worked" only because of timeout handling on initiator. Notes: svn path=/head/; revision=300218
* Completely remove broken now autologin port flag.Alexander Motin2016-05-171-5/+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. MFC after: 1 week Notes: svn path=/head/; revision=300052
* sys/dev: minor spelling fixes.Pedro F. Giffuni2016-05-031-3/+3
| | | | | | | Most affect comments, very few have user-visible effects. Notes: svn path=/head/; revision=298955
* Extract virtual port address from RQSTYPE_RPT_ID_ACQ.Alexander Motin2016-04-141-8/+9
| | | | | | | | | 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=/head/; revision=297991
* Filter Port Database Changed notifications.Alexander Motin2016-04-131-0/+1
| | | | | | | | | | 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=/head/; revision=297915
* Respect NVRAM topology settings on 24xx and above chips.Alexander Motin2016-04-131-5/+6
| | | | Notes: svn path=/head/; revision=297912
* Allocate separate DMA area for synchronous IOCB execution.Alexander Motin2016-04-121-0/+8
| | | | | | | | | | | 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=/head/; revision=297858
* Allocate separate scratch space for scanner purposes.Alexander Motin2015-12-271-1/+3
| | | | | | | | | | | 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=/head/; revision=292765
* Make virtual ports control asynchronous.Alexander Motin2015-12-261-1/+3
| | | | | | | | | | | | | | | 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=/head/; revision=292739
* Unify handles allocation for initiator and target IOCBs.Alexander Motin2015-12-251-19/+4
| | | | | | | | | 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=/head/; revision=292725
* Add initial support for 16Gbps FC QLogic chips.Alexander Motin2015-12-021-5/+7
| | | | | | | | I still don't know how to read NVRAM there, so WWNs and other parameters are incorrect, but other then that driver seems like attaching normally. Notes: svn path=/head/; revision=291654
* One more round of port scanner rewrite.Alexander Motin2015-11-261-10/+10
| | | | | | | | | | - 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=/head/; revision=291365
* Rip off target mode support for parallel SCSI QLogic adapters.Alexander Motin2015-11-231-11/+1
| | | | | | | | | | 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=/head/; revision=291188
* Fix target mode with fabric for pre-24xx chips.Alexander Motin2015-11-211-0/+1
| | | | | | | | | | For those chips we are not receiving login events, adding initiators based on ATIO requests. But there is no port ID in that structure, so in fabric mode we have to explicitly fetch it from firmware to be able to do normal scan after that. Notes: svn path=/head/; revision=291144
* Another round of port scanner rewrite.Alexander Motin2015-11-191-9/+10
| | | | | | | | | This change simplifies and unifies port adding/updating for loop and fabric scanners. It also fixes problems with scanning restarts due to concurrent port databases changes. It also fixes many cosmetic issues. Notes: svn path=/head/; revision=291080
* Unify and cleanup FC ports scan.Alexander Motin2015-11-171-8/+7
| | | | Notes: svn path=/head/; revision=290993
* Reimplement next port handle generation.Alexander Motin2015-10-271-3/+0
| | | | | | | | For some reason port handles should be allocated from HBA-global space, while old code was not very specific, mixing per-HBA and per-VP logic. Notes: svn path=/head/; revision=290054
* Skip reserved IP Broadcast handle from using.Alexander Motin2015-10-241-1/+1
| | | | Notes: svn path=/head/; revision=289890
* Some polishing and unification in ISR code.Alexander Motin2015-10-231-4/+4
| | | | Notes: svn path=/head/; revision=289812
* Export bunch of state variables as sysctls.Alexander Motin2015-10-131-10/+8
| | | | Notes: svn path=/head/; revision=289219
* Unify port database use for target and initiator roles.Alexander Motin2015-07-131-30/+12
| | | | | | | | | | Aside from cleaner and more consistent code, this allows ports to be both target and initiator same time, and easily switch from any role to any. Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=285459
* Remove extra level of target ID indirection (isp_dev_map).Alexander Motin2015-07-051-16/+1
| | | | | | | | | | FreeBSD never had limitation on number of target IDs, and there is no any other requirement to allocate them densely. Since slots of port database already populated just sequentially, there is no much need for another indirection to allocate sequentially too. Notes: svn path=/head/; revision=285154