aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/isp/isp_library.c
Commit message (Collapse)AuthorAgeFilesLines
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-1/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* isp: Remove unused variable.John Baldwin2022-04-121-2/+0
|
* Some code reorganization.Alexander Motin2020-11-271-1/+152
| | | | | | | | | | | | | | | | - 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
* Some minor FCoE bits I had lying around.Alexander Motin2020-11-261-2/+2
| | | | Notes: svn path=/head/; revision=368044
* Remove some more dead code from pre-24xx.Alexander Motin2020-11-261-76/+0
| | | | Notes: svn path=/head/; revision=368043
* Implement request queue overflow protection.Alexander Motin2020-11-241-31/+8
| | | | | | | | | | | | | | | | 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-2/+2
| | | | | | | | | | | - 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
* Cleanup DMA handling.Alexander Motin2020-11-201-23/+11
| | | | | | | | | | | | - 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-1269/+72
| | | | | | | | | | | | | | | | | | | | | 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
* 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-46/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Unify initiator and target DMA setup and command sending.Alexander Motin2017-03-241-186/+65
| | | | | | | | | The code is so alike that it is pointless to keep it separate. MFC after: 2 weeks Notes: svn path=/head/; revision=315908
* Remove dead remnants of SPI target.Alexander Motin2017-03-181-72/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315485
* Improvements around attach, reset and detach.Alexander Motin2017-03-141-22/+0
| | | | | | | | | | | | 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
* Completely remove broken now autologin port flag.Alexander Motin2016-05-171-2/+2
| | | | | | | | | | 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
* Extract virtual port address from RQSTYPE_RPT_ID_ACQ.Alexander Motin2016-04-141-2/+3
| | | | | | | | | 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
* Polish debugging IOCB dumping.Alexander Motin2016-04-111-4/+6
| | | | | | | | | Add few more missing cases, unify byte order. MFC after: 1 month Notes: svn path=/head/; revision=297817
* Register symbolic port/node names in FC name server.Alexander Motin2016-04-091-0/+23
| | | | | | | | | | | | 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. MFC after: 2 weeks Notes: svn path=/head/; revision=297751
* Make virtual ports control asynchronous.Alexander Motin2015-12-261-4/+12
| | | | | | | | | | | | | | | 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-121/+40
| | | | | | | | | 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
* Clear virtual port's port database when disabling it.Alexander Motin2015-12-251-162/+0
| | | | | | | | Previously it was done only on full chip reinit, that caused old ports resurrect in case of virtual port reenabling. Notes: svn path=/head/; revision=292715
* Update isp_put_icb_2400() for new structure fields.Alexander Motin2015-12-041-3/+10
| | | | Notes: svn path=/head/; revision=291730
* One more round of port scanner rewrite.Alexander Motin2015-11-261-25/+24
| | | | | | | | | | - 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
* Fix target mode support for Qlogic 2200 FC adapters.Alexander Motin2015-11-231-2/+4
| | | | | | | | Now target mode works for all supported FC adapters except ancient 2100, which is not tested. Notes: svn path=/head/; revision=291209
* Rip off target mode support for parallel SCSI QLogic adapters.Alexander Motin2015-11-231-281/+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-5/+5
| | | | | | | | | | 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-30/+37
| | | | | | | | | 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
* Remove some confusions between loopid and nphdl.Alexander Motin2015-11-181-1/+1
| | | | | | | | | | | Modern cards in most cases operate abstract port handles, that have no any relation to real loop IDs. Leave loopid used only where it really goes about local loop IDs. While there, fix few more cases where LUNs were still printed in decimal. Notes: svn path=/head/; revision=291013
* Register our FC4 Features in SNS.Alexander Motin2015-11-171-0/+14
| | | | Notes: svn path=/head/; revision=291000
* Unify and cleanup FC ports scan.Alexander Motin2015-11-171-22/+16
| | | | Notes: svn path=/head/; revision=290993
* Make firmware handle virtual ports SNS logins for us.Alexander Motin2015-11-171-1/+2
| | | | Notes: svn path=/head/; revision=290980
* Add real initial support for RQSTYPE_RPT_ID_ACQ.Alexander Motin2015-11-171-11/+4
| | | | Notes: svn path=/head/; revision=290978
* Improve/fix loop scanning routine.Alexander Motin2015-10-281-0/+38
| | | | | | | | | | | | | | | For the most of chips (except anscient ones) port handlers have no relation to port IDs. In such situation old code scanning first 125 handlers was quite naive. Instead of doing that, send to chip single request to get full list of port handlers available on specific virtual port and scan only them. Old code had problems with case of several virtual ports enabled, when port handlers allocated from global address space could easily go above 125. This change was successfully tested on 23xx, 24xx and 25xx chips in loop mode with 4 virtual initiator ports, each seing 50 virtual target ports. Notes: svn path=/head/; revision=290104
* Reimplement enable and implement disable of virtual ports.Alexander Motin2015-10-261-62/+148
| | | | | | | | | | | | | Now on 24xx and above chips it is really possible to simulate several virtual FC ports with single physical one. For example, it allows to configure several targets in ctl.conf, assign each of them to separate virtual port, and let user to control access to them with switch zoning. I still doubt that all problems are solved there, but at now it passes at least basic tests. Notes: svn path=/head/; revision=290018
* Add new field to Abort IOCB.Alexander Motin2015-10-241-0/+2
| | | | Notes: svn path=/head/; revision=289886
* Minor additions to Status Type 0 IOCB.Alexander Motin2015-10-231-1/+1
| | | | Notes: svn path=/head/; revision=289855
* Improve INOTs handling for 24xx and above chips.Alexander Motin2015-10-231-20/+40
| | | | Notes: svn path=/head/; revision=289838
* Unify port database use for target and initiator roles.Alexander Motin2015-07-131-164/+106
| | | | | | | | | | 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
* Drop discovered targets when initiator role is disabled.Alexander Motin2015-07-041-11/+0
| | | | Notes: svn path=/head/; revision=285146
* Rewrite port database handling for target mode.Alexander Motin2015-06-211-111/+127
| | | | | | | | | | | | | | Previous implementation was too fragile to initiator parameters changes. In case of port role change it could not survive different handle assigned to the same initiator by firmware, even though initiator was logged out. The new implementation should be more resillient to this kind of problems, trying to work in any situation and only warn user about suspisious events. MFC after: 1 week Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=284681
* Make isp_find_pdb_by_*() search for targets in portdb in reverse order.Alexander Motin2014-11-261-3/+3
| | | | | | | | | | Records with target_mode == 1 are allocated from the end of portdb, so it seems logical to start search from the end not traverse whole array. MFC after: 1 month Notes: svn path=/head/; revision=275112
* Fix r272936 build with old GCC.Alexander Motin2014-10-111-1/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=272937
* Update isp_tgt_map and send new arrival notification if target that departedAlexander Motin2014-10-111-0/+5
| | | | | | | | | earlier has returned. Previously that code worked only once, confusing CTL. MFC after: 1 month Notes: svn path=/head/; revision=272936
* Fix I/O freezes in some cases, caused by r257916.Alexander Motin2014-02-051-2/+6
| | | | | | | | | | | Delaying isp_reqodx update, we should be ready to update it every time we read it. Otherwise requests using several indexes may be requeued ndefinitely without ever updating the variable. MFC after: 3 days Notes: svn path=/head/; revision=261515
* Save one more register read per command by not reading rqstoutrp registerAlexander Motin2013-11-101-3/+7
| | | | | | | | | | | | every time. The purpose of that register is unlikely output queue overflow detection, so read it only when its last known (and probably stale now) value signals overflow. This reduces CPU load and lock congestion and rises bottleneck in CTL while doing target mode via two 8Gbps ports from 100K to 120K IOPS. Notes: svn path=/head/; revision=257916
* -----------Matt Jacob2012-07-281-161/+236
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MISC CHANGES Add a new async event- ISP_TARGET_NOTIFY_ACK, that will guarantee eventual delivery of a NOTIFY ACK. This is tons better than just ignoring the return from isp_notify_ack and hoping for the best. Clean up the lower level lun enable code to be a bit more sensible. Fix a botch in isp_endcmd which was messing up the sense data. Fix notify ack for SRR to use a sensible error code in the case of a reject. Clean up and make clear what kind of firmware we've loaded and what capabilities it has. ----------- FULL (252 byte) SENSE DATA In CTIOs for the ISP, there's only a limimted amount of space to load SENSE DATA for associated CHECK CONDITIONS (24 or 26 bytes). This makes it difficult to send full SENSE DATA that can be up to 252 bytes. Implement MODE 2 responses which have us build the FCP Response in system memory which the ISP will put onto the wire directly. On the initiator side, the same problem occurs in that a command status response only has a limited amount of space for SENSE DATA. This data is supplemented by status continuation responses that the ISP pushes onto the response queue after the status response. We now pull them all together so that full sense data can be returned to the periph driver. This is supported on 23XX, 24XX and 25XX cards. This is also preparation for doing >16 byte CDBs. ----------- FC TAPE Implement full FC-TAPE on both initiator and target mode side. This capability is driven by firmware loaded, board type, board NVRAM settings, or hint configuration options to enable or disable. This is supported for 23XX, 24XX and 25XX cards. On the initiator side, we pretty much just have to generate a command reference number for each command we send out. This is FCP-4 compliant in that we do this per ITL nexus to generate the allowed 1 thru 255 CRN. In order to support the target side of FC-TAPE, we now pay attention to more of the PRLI word 3 parameters which will tell us whether an initiator wants confirmed responses. While we're at it, we'll pay attention to the initiator view too and report it. On sending back CTIOs, we will notice whether the initiator wants confirmed responses and we'll set up flags to do so. If a response or data frame is lost the initiator sends us an SRR (Sequence Retransmit Request) ELS which shows up as an SRR notify and all outstanding CTIOs are nuked with SRR Received status. The SRR notify contains the offset that the initiator wants us to restart the data transfer from or to retransmit the response frame. If the ISP driver still has the CCB around for which the data segment or response applies, it will retransmit. However, we typically don't know about a lost data frame until we send the FCP Response and the initiator totes up counters for data moved and notices missing segments. In this case we've already completed the data CCBs already and sent themn back up to the periph driver. Because there's no really clean mechanism yet in CAM to handle this, a hack has been put into place to complete the CTIO CCB with the CAM_MESSAGE_RECV status which will have a MODIFY DATA POINTER extended message in it. The internal ISP target groks this and ctl(8) will be modified to deal with this as well. At any rate, the data is retransmitted and an an FCP response is sent. The whole point here is to successfully complete a command so that you don't have to depend on ULP (SCSI) to have to recover, which in the case of tape is not really possible (hence the name FC-TAPE). Sponsored by: Spectralogic MFC after: 1 month Notes: svn path=/head/; revision=238869
* - Use the correct DMA tag/map pair for synchronize the FC scratch area.Marius Strobl2011-02-141-2/+2
| | | | | | | | | | | | | | - Allocate coherent DMA memory for the request/response queue area and and the FC scratch area. These changes allow isp(4) to work properly on sparc64 with usage of the IOMMU streaming buffers enabled. Approved by: mjacob MFC after: 2 weeks Notes: svn path=/head/; revision=218691
* Don't pass a buffer directly as a printflike format string.Matt Jacob2010-06-101-1/+1
| | | | | | | | Found by: clang MFC after: 1 month Notes: svn path=/head/; revision=208997
* Various minor and not so minor fixes suggested by Coverity.Matt Jacob2010-06-021-1/+1
| | | | | | | | | | In at least one case, it's amazing that target mode worked at all. Found by: Coverity. MFC after: 2 weeks Notes: svn path=/head/; revision=208761