aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/scsi_ctl.c
Commit message (Collapse)AuthorAgeFilesLines
* Move XPT_IMMEDIATE_NOTIFY handling out of periph lock.Alexander Motin2021-02-181-1/+2
| | | | | | It is a rare, but still better to not have lock dependencies. MFC after: 1 month
* 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
* cam: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-3/+1
| | | | Notes: svn path=/head/; revision=365225
* Return a C errno for cam_periph_acquire().Scott Long2018-02-061-5/+5
| | | | | | | | | | | | | | There's no compelling reason to return a cam_status type for this function and doing so only creates confusion with normal C coding practices. It's technically an API change, but the periph API isn't widely used. No efffective change to operation. Reviewed by: imp, mav, ken Sponsored by: Netflix Differential Revision: D14063 Notes: svn path=/head/; revision=328918
* Minimum changes for ctl to build on architectures with non-matching physical andJustin Hibbits2018-01-261-1/+1
| | | | | | | | | | | | | | | | virtual address sizes Summary: Some architectures use physical addresses larger than virtual. This is the minimal changeset needed to get CAM/CTL to build on these targets. No functional changes. More changes would likely be needed for this to be fully functional on said platforms, but they can be made when needed. Reviewed By: mav, chuck Differential Revision: https://reviews.freebsd.org/D14041 Notes: svn path=/head/; revision=328425
* sys/cam: 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=326265
* Do not loose CCB flags after r320493.Alexander Motin2017-08-091-1/+2
| | | | | | | | | There is at least CAM_UNLOCKED that should be kept. MFC after: 3 days Notes: svn path=/head/; revision=322302
* Unify INOT/ATIO setup.Alexander Motin2017-06-301-6/+3
| | | | Notes: svn path=/head/; revision=320493
* Increase device openings to tagged maximum.Alexander Motin2017-03-111-5/+25
| | | | | | | | | | | | | | | | Some SIMs report much less untagged device openings then tagged ones. Target mode devices are not handled by regular probing routines, and so there is nothing to increase queue size for them to the SIM's maximum. To fix that resize the queue explicitly on ctl periph registration. This radically improves performance of mpt(4) in target mode. Also fetch and report device queue statistics in `ctladm dumpstructs`, since regular way of `camcontrol tags` is not usable in target mode. MFC after: 2 weeks Notes: svn path=/head/; revision=315084
* Abort all ATIOs and INOTs queued to SIM on LUN disable.Alexander Motin2017-03-101-22/+45
| | | | | | | | | | | | Some SIMs may not abort them implicitly, that either fail the LUN disable request or just make us wait for those CCBs forever. With this change I can successfully disable LUNs on mpt(4). For isp(4), which aborts them implicitly, this change should be irrelevant. MFC after: 2 weeks Notes: svn path=/head/; revision=315030
* Switch work_queue from TAILQ to STAILQ.Alexander Motin2017-03-101-14/+13
| | | | | | | | | It is mostly FIFO and we don't need random removal there. MFC after: 2 weeks Notes: svn path=/head/; revision=315025
* Request change of SIM target role only when it is different.Alexander Motin2017-03-101-51/+51
| | | | | | | | | Separate WWNs change into separate request to know what actually failed. MFC after: 2 weeks Notes: svn path=/head/; revision=315022
* Add mechanism to unload CAM periph drivers.Alexander Motin2017-03-071-8/+25
| | | | | | | | For now it allows to unload CTL kernel module if there are no target-capable SIMs in CAM. As next step full teardown of CAM targets can be implemented. Notes: svn path=/head/; revision=314870
* Add support for SIMs without autosense.Alexander Motin2017-02-261-0/+14
| | | | | | | | | | | | If we asked to send sense data by setting CAM_SEND_SENSE, but SIM didn't confirm transmission by setting CAM_SENT_SENSE, assume it was not sent. Queue the I/O back to CTL for later REQUEST SENSE with ctl_queue_sense(). This is needed for error reporting on SPI HBAs like ahc(4)/ahd(4). MFC after: 2 weeks Notes: svn path=/head/; revision=314307
* Use resid field of CTIO to detect under/overruns.Alexander Motin2017-02-261-3/+4
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=314300
* Axe out some forever disabled questionable functionality.Alexander Motin2017-02-251-116/+6
| | | | | | | | | This code is complicated enough even in its base shape. MFC after: 2 weeks Notes: svn path=/head/; revision=314247
* Improve CAM target frontend reference counting.Alexander Motin2017-02-251-54/+52
| | | | | | | | | | Before this change it was possible to trigger some use-after-free panics by disabling LUNs/ports under heavy load. MFC after: 2 weeks Notes: svn path=/head/; revision=314246
* Explicitly abort ATIO if CTIO sending status has failed.Alexander Motin2017-02-241-0/+8
| | | | | | | | | This helps SIM to free related resources in questionable cases. MFC after: 2 weeks Notes: svn path=/head/; revision=314204
* We can't access periph after ctlfe_free_ccb().Alexander Motin2017-02-241-1/+3
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=314200
* Unify ATIO/INOT CCBs requeuing.Alexander Motin2017-02-241-58/+48
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=314196
* Some code cleanup.Alexander Motin2017-02-241-38/+15
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=314193
* Do not blindly free completed ATIOs/INOTs on invalidation.Alexander Motin2017-02-211-59/+19
| | | | | | | | | | | | | | When LUN is disabled, SIM starts returning queued ATIOs/INOTs. But at the same time there can be some ATIOs/INOTs still carrying real new requests. If we free those, SIM may leak some resources, forever expecting for any response from us. So try to be careful, separating ATIOs/INOTs carrying requests which still must be processed, from ATIOs/INOTs completed with errors which can be freed. MFC after: 2 weeks Notes: svn path=/head/; revision=314027
* Remove max_targets and max_target_id CTL port variables; they were unused.Edward Tomasz Napierala2017-01-221-6/+0
| | | | | | | | | This changes the CTL frontend ABI and thus shouldn't be MFC-ed. Reviewed by: mav@ Notes: svn path=/head/; revision=312651
* Add initial support for CTL module unloading.Alexander Motin2017-01-211-6/+8
| | | | | | | | | | | It is only a first step and not perfect, but better then nothing. The main blocker is CAM target frontend, that can not be unloaded, since CAM does not have mechanism to unregister periph driver now. MFC after: 2 weeks Notes: svn path=/head/; revision=312603
* Make CTL frontends report kern_data_resid for under-/overruns.Alexander Motin2017-01-161-53/+51
| | | | | | | | | | | | | | | | | It seems like kern_data_resid was never really implemented. This change finally does it. Now frontends update this field while transferring data, while CTL/backends getting it can more flexibly handle the result. At this point behavior should not change significantly, still reporting errors on write overrun, but that may be changed later, if we decide so. CAM target frontend still does not properly handle overruns due to CAM API limitations. We may need to add some fields to struct ccb_accept_tio to pass information about initiator requested transfer size(s). MFC after: 2 weeks Notes: svn path=/head/; revision=312291
* Improve CAM_CDB_POINTER support.Alexander Motin2017-01-131-6/+4
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=312026
* Allow more efficient use of private area.Alexander Motin2016-12-271-11/+14
| | | | | | | | | There are 16 bytes of space, so we may store two pointers in one. MFC after: 2 weeks Notes: svn path=/head/; revision=310649
* Pass task management response information from CTL through CAM to isp(4),Alexander Motin2016-05-201-0/+23
| | | | | | | | | | utilizing previously unused arg field of struct ccb_notify_acknowledge. This makes new QUERY TASK, QUERY TASK SET and QUERY ASYNC EVENT requests really functional for CAM target mode drivers. Notes: svn path=/head/; revision=300293
* Move to new value for XPT_GET_SIM_KNOB to avoid clash with XPT_ATA_IO.Warner Losh2016-03-101-0/+1
| | | | Notes: svn path=/head/; revision=296604
* Give CTL support for PIM_EXTLUNS when talking to CAM.Alexander Motin2015-10-241-9/+26
| | | | | | | | CTL itself still lives in flat LUN space, but it can generate extended numbers if CAM SIM reports such capability. Notes: svn path=/head/; revision=289881
* Add partial support for QUERY TMF to CAM and isp(4).Alexander Motin2015-10-231-8/+15
| | | | | | | | | | | This change allows to decode respective functions in isp(4) in target mode and pass them through CAM to CTL. Unfortunately neither CAM nor isp(4) support returning response info for those task management functions now. On the other side I just have no initiator to test this functionality. Notes: svn path=/head/; revision=289843
* Fix LUN disable in CAM broken at r285155.Alexander Motin2015-10-231-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=289819
* Update WRITE ATOMIC(16) support to sbc4r8 draft.Alexander Motin2015-09-241-1/+0
| | | | | | | | This is only a cosmetic change. We still don't support atomic boundary field in the CDB, but at least now we do it formally. Notes: svn path=/head/; revision=288166
* Reimplement CTL High Availability.Alexander Motin2015-09-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | CTL HA functionality was originally implemented by Copan many years ago, but large part of the sources was never published. This change includes clean room implementation of the missing code and fixes for many bugs. This code supports dual-node HA with ALUA in four modes: - Active/Unavailable without interlink between nodes; - Active/Standby with second node handling only basic LUN discovery and reservation, synchronizing with the first node through the interlink; - Active/Active with both nodes processing commands and accessing the backing storage, synchronizing with the first node through the interlink; - Active/Active with second node working as proxy, transfering all commands to the first node for execution through the interlink. Unlike original Copan's implementation, depending on specific hardware, this code uses simple custom TCP-based protocol for interlink. It has no authentication, so it should never be enabled on public interfaces. The code may still need some polishing, but generally it is functional. Relnotes: yes Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=287621
* Remove unused target and initiator IDs.Alexander Motin2015-09-101-7/+4
| | | | Notes: svn path=/head/; revision=287620
* Remove 600 bytes of port_priv from struct ctl_io_hdr.Alexander Motin2015-08-291-14/+27
| | | | | | | | This field used only for camtgt frontend, and once it any way preallocates all requests, let it preallocate this memory too, not bothering core code. Notes: svn path=/head/; revision=287293
* Make first step toward supporting target and initiator roles same time.Alexander Motin2015-07-051-11/+7
| | | | | | | | | | | | | | | | | | | | | | To avoid conflicts between target and initiator devices in CAM, make CTL use target ID reported by HBA as its initiator_id in XPT_PATH_INQ. That target ID is known to never be used for initiator role, so it won't conflict. For Fibre Channel and FireWire HBAs this specific ID choice is irrelevant since all target IDs there are virtual. Same time for SPI HBAs it seems could be even requirement to use same target ID for both initiator and target roles. While there are some more things to polish in isp(4) driver, first tests of using both roles same time on the same port appeared successfull: # camcontrol devlist -v scbus0 on isp0 bus 0: <FREEBSD CTLDISK 0001> at scbus0 target 1 lun 0 (da20,pass21) <> at scbus0 target 256 lun 0 (ctl0) <> at scbus0 target -1 lun ffffffff (ctl1) Notes: svn path=/head/; revision=285155
* Bring per-port LUN enable/disable code up to date:Alexander Motin2015-06-201-11/+7
| | | | | | | | | | | | | - remove last remnants of never implemented multiple targets support; - implement missing support for LUN mapping in this area. Due to existing locking constraints LUN mapping code is practically unlocked at this point. Hopefully it is not racy enough to live until somebody get idea how to call sleeping fronend methods under lock also taken by the same frontend in non-sleepable context. :( Notes: svn path=/head/; revision=284640
* Remove device queue freeze handling and replace it with dummy.Alexander Motin2015-06-201-30/+14
| | | | | | | | | | | | At this point CTL has no known use case for device queue freezes. Same time existing (considered to be broken) code was found to cause modify-after-free issues. Discussed with: ken MFC after: 1 week Notes: svn path=/head/; revision=284622
* Change ATIO/INOT counting to prevent periph destruction while requestsAlexander Motin2015-06-181-33/+28
| | | | | | | | | are still running inside CTL. MFC after: 1 week Notes: svn path=/head/; revision=284541
* Allow setting only WWNN or only WWPN.Alexander Motin2015-06-051-5/+13
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=284013
* Don't count status as sent until CTIO completes successfully.Alexander Motin2015-01-161-1/+4
| | | | | | | | | | | If we aggregated status sending with data move and got error, allow status to be updated and resent again separately. Without this command may stuck without status sent at all. MFC after: 2 weeks Notes: svn path=/head/; revision=277247
* Reduce number of places where global control_softc is used.Alexander Motin2014-12-191-2/+0
| | | | | | | | | | At some point we may want to have several CTL instances, and that is not really impossible. MFC after: 2 weeks Notes: svn path=/head/; revision=275942
* Move ctlfe_onoffline() out of lock to let it sleep when needed.Alexander Motin2014-12-011-32/+9
| | | | | | | | | Do some more other polishing while there. MFC after: 2 weeks Notes: svn path=/head/; revision=275365
* Coalesce last data move and command status for read commands.Alexander Motin2014-11-251-7/+27
| | | | | | | | | | | | | | | | | | Make CTL core and block backend set success status before initiating last data move for read commands. Make CAM target and iSCSI frontends detect such condition and send command status together with data. New I/O flag allows to skip duplicate status sending on later fe_done() call. For Fibre Channel this change saves one of three interrupts per read command, increasing performance from 126K to 160K IOPS. For iSCSI this change saves one of three PDUs per read command, increasing performance from 1M to 1.2M IOPS. MFC after: 1 month Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=275058
* Decouple datamove/done logic from CTL status set.Alexander Motin2014-11-251-330/+210
| | | | Notes: svn path=/head/; revision=275032
* Replace home-grown CTL IO allocator with UMA.Alexander Motin2014-11-241-132/+107
| | | | | | | | | | | | | | | | | | | | | Old allocator created significant lock congestion protecting its lists of preallocated I/Os, while UMA provides much better SMP scalability. The downside of UMA is lack of reliable preallocation, that could guarantee successful allocation in non-sleepable environments. But careful code review shown, that only CAM target frontend really has that requirement. Fix that making that frontend preallocate and statically bind CTL I/O for every ATIO/INOT it preallocates any way. That allows to avoid allocations in hot I/O path. Other frontends either may sleep in allocation context or can properly handle allocation errors. On 40-core server with 6 ZVOL-backed LUNs and 7 iSCSI client connections this change increases peak performance from ~700K to >1M IOPS! Yay! :) MFC after: 1 month Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=274962
* Partially reconstruct Active/Standby clusting.Alexander Motin2014-11-211-1/+1
| | | | | | | | | | | | In this mode one head is in Active state, supporting all commands, while another is in Standby state, supporting only minimal LUN discovery subset. It is still incomplete since Standby state requires reservation support, which is impossible to do right without having interlink between heads. But it allows to run some basic experiments. Notes: svn path=/head/; revision=274785
* Fix residual copy/paste in r274080.Alexander Motin2014-11-041-1/+0
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=274081
* Improve error handling around duplicate lun and port enable.Alexander Motin2014-11-041-11/+30
| | | | | | | | | This fixes kernel panic if port enabled twice and then disabled. MFC after: 1 week Notes: svn path=/head/; revision=274080