aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_frontend_iscsi.c
Commit message (Collapse)AuthorAgeFilesLines
* Exclude reserved iSCSI Target Transfer Tag.Alexander Motin2021-01-241-0/+4
| | | | | | | | | RFC 7143 (11.7.4): The Target Transfer Tag values are not specified by this protocol, except that the value 0xffffffff is reserved and means that the Target Transfer Tag is not supplied. MFC after: 1 month
* Drop "All rights reserved" from all my stuff. This includesEdward Tomasz Napierala2020-10-281-1/+0
| | | | | | | | | | | | Foundation copyrights, approved by emaste@. It does not include files which carry other people's copyrights; if you're one of those people, feel free to make similar change. Reviewed by: emaste, imp, gbe (manpages) Differential Revision: https://reviews.freebsd.org/D26980 Notes: svn path=/head/; revision=367105
* Introduce support of SCSI Command Priority.Alexander Motin2020-10-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+0
| | | | Notes: svn path=/head/; revision=365225
* Implement zero-copy iSCSI target transmission/read.Alexander Motin2020-06-081-3/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add ICL_NOCOPY flag to icl_pdu_append_data(), specifying that the method can just reference the data buffer instead of immediately copying it. Extend the offload KPI with optional PDU queue method, allowing to specify completion callback, called when all the data referenced by above has been transferred and won't be accessed any more (the buffers can be freed). Implement the above functionality in software iSCSI driver using mbufs with external storage and reference counter. Note that some NICs (ixl(4)) may keep the mbuf in TX queue for a long time, so CTL has to be ready. Add optional method to struct ctl_scsiio for buffer reference counting. Implement it for CTL block backend, allowing to delay free of the struct ctl_be_block_io and memory it references as needed. In first reincarnation of the patch I tried to delay whole I/O as it is done for FibreChannel, that was cleaner, but due to the above callback delays I had to rewrite it this way to not leave LUN referenced potentially for hours or more. All together on sequential read from ZFS ARC this saves about 30% of CPU time and memory bandwidth by avoiding one of 3 memory copies (the other two are from ZFS ARC to DMU cache and then from DMU cache to CTL buffers). On tests with 2x Xeon Silver 4114 this allows to reach full line rate of 100GigE NIC. Tests with Gold CPUs and two 100GigE NICs are stil TBD, but expectations to saturate them are pretty high. ;) Discussed with: Chelsio Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=361939
* Remove session locking from cfiscsi_pdu_update_cmdsn().Alexander Motin2020-05-291-57/+45
| | | | | | | | | | | | cs_cmdsn can be incremented with single atomic. expcmdsn/maxcmdsn set in cfiscsi_pdu_prepare() based on cs_cmdsn are not required to be updated synchronously, only monotonically, that is achieved with lock there. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=361630
* Move EXPDATASN/R2TSN from PDU to CTL_PRIV_FRONTEND.Alexander Motin2020-05-291-16/+23
| | | | | | | | | | | | We any way have per-I/O space in CTL_PRIV_FRONTEND, while for PDU private fields I have better use ideas. Plus to me such use of PDU fields looked a layering violation. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=361616
* Remove PDU_TOTAL_TRANSFER_LEN() macro.Alexander Motin2020-05-281-23/+8
| | | | | | | | | | | | I don't see a point to copy io->scsiio.kern_total_len into the request PDU private field. The io is going to stay with us till the end, and kern_total_len field is not changed after being first initialized. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=361609
* Add session locking in cfiscsi_ioctl_handoff().Alexander Motin2020-05-031-2/+4
| | | | | | | | | | | | | While there, remove ifdef around cs_target check in cfiscsi_ioctl_list(). I am not sure why this ifdef was added, but without this check code will crash below on NULL dereference. Submitted by: Aleksandr Fedorov <aleksandr.fedorov@itglobal.com> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24587 Notes: svn path=/head/; revision=360610
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+1
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Make the wait in cfiscsi_offline() interruptible. This is the second halfEdward Tomasz Napierala2018-09-111-3/+9
| | | | | | | | | | | | | | of the fix/workaround for the "ctld hanging on reload" problem. PR: 220175 Reported by: Eugene M. Zheganin <emz at norma.perm.ru> Tested by: Eugene M. Zheganin <emz at norma.perm.ru> Approved by: re (kib) MFC after: 2 weeks Sponsored by: playkey.net Notes: svn path=/head/; revision=338586
* Try harder in cfiscsi_offline(). This is believed to be the workaroundEdward Tomasz Napierala2018-09-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | for the "ctld hanging on reload" problem observed in same cases under high load. I'm not 100% sure it's _the_ fix, as the issue is rather hard to reproduce, but it was tested as part of a larger path and the problem disappeared. It certainly shouldn't break anything. Now, technically, it shouldn't be needed. Quoting mav@, "After ct->ct_online == 0 there should be no new sessions attached to the target. And if you see some problems abbout it, it may either mean that there are some races where single cfiscsi_session_terminate(cs) call may be lost, or as a guess while this thread was sleeping target was reenabbled and redisabled again". Should such race be discovered and properly fixed in the future, than this and the followup two commits can be backed out. PR: 220175 Reported by: Eugene M. Zheganin <emz at norma.perm.ru> Tested by: Eugene M. Zheganin <emz at norma.perm.ru> Discussed with: mav Approved by: re (gjb) MFC after: 2 weeks Sponsored by: playkey.net Notes: svn path=/head/; revision=338426
* Remove unneccessary code, which also introduced a (very minor)Edward Tomasz Napierala2018-08-211-6/+0
| | | | | | | | | | | | race condition, due to a missing call to cfiscsi_target_release(). Discussed with: mav@ Tested by: Eugene M. Zheganin <emz at norma.perm.ru> (earlier version) MFC after: 2 weeks Sponsored by: playkey.net Notes: svn path=/head/; revision=338139
* Rework CTL frontend & backend options to use nv(3), allow creating multipleMarcelo Araujo2018-05-101-29/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ioctl frontend ports. This revision introduces two changes to CTL: - Changes the way options are passed to CTL_LUN_REQ and CTL_PORT_REQ ioctls. Removes ctl_be_arg structure and associated logic and replaces it with nv(3)-based logic for passing in and out arguments. - Allows creating multiple ioctl frontend ports using either ctladm(8) or ctld(8). New frontend ports are represented by /dev/cam/ctl<pp>.<vp> nodes, eg /dev/cam/ctl5.3. Those device nodes respond only to CTL_IO ioctl. New command-line options for ctladm: # creates new ioctl frontend port with using free pp and vp=0 ctladm port -c # creates new ioctl frontend port with pp=10 and vp=0 ctladm port -c -O pp=10 # creates new ioctl frontend port with pp=11 and vp=12 ctladm port -c -O pp=11 -O vp=12 # removes port with number 4 (it's a "targ_port" number, not pp number) ctladm port -r -p 4 New syntax for ctl.conf: target ... { port ioctl/<pp> ... } target ... { port ioctl/<pp>/<vp> ... Note: Most of this work was made by jceel@, thank you. Submitted by: jceel Reworked by: myself Reviewed by: mav (earlier versions and recently during the rework) Obtained from: FreeNAS and TrueOS Relnotes: Yes Sponsored by: iXsystems Inc. Differential Revision: https://reviews.freebsd.org/D9299 Notes: svn path=/head/; revision=333446
* Fix iSCSI target crash on session reinstation.Edward Tomasz Napierala2018-03-151-7/+31
| | | | | | | | | | | | | | | | | | | The crash scenario goes like this: there's a thread waiting on "reinstate"; because it doesn't update the timeout counter it gets terminated by the callout; at this point the maintenance thread starts the termination routine. The first thread finishes waiting, proceeds to icl_conn_handoff(), and drops the refcount, which allows the maintenance thread to free its resources. At this point another thread receives a PDU. Boom. PR: 222898, 219866 Reported by: Eugene M. Zheganin <emz at norma.perm.ru> Tested by: Eugene M. Zheganin <emz at norma.perm.ru> Reviewed by: mav@ (earlier version) MFC after: 2 weeks Sponsored by: playkey.net Notes: svn path=/head/; revision=331013
* 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
* Fix iSCSI target panics on concurrent session teardown and displayEdward Tomasz Napierala2017-10-041-6/+5
| | | | | | | | | | | | (eg removing a target and doing "ctladm islist -v" at the same time). Reviewed by: manu Tested by: manu MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=324261
* Fix few minor issues found by Clang Analyzer.Alexander Motin2017-04-091-3/+9
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=316653
* Split iscsi(4) ctl frontend off of ctl(4) as cfiscsi(4)Enji Cooper2017-03-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this work is to remove the explicit dependency for ctl(4) on iscsi(4), so end-users without iscsi(4) support in the kernel can use ctl(4) for its other functions. This allows those without iscsi(4) support built into the kernel to use ctl(4) as a test mechanism. As a sidenote, this was possible around the 10.0-RELEASE period, but made impossible for end-users without iscsi(4) between 10.0-RELEASE and 11.0-RELEASE. Automatically load cfiscsi(4) from ctladm(8) and ctld(8) for backwards compatibility with previously releases. The automatic loading feature is compiled into the beforementioned tools if MK_ISCSI == yes when building world. Add a manpage for cfiscsi(4) and refer to it in ctl(4). Differential Revision: D10099 MFC after: 2 months Relnotes: yes Reviewed by: mav, trasz Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316212
* Change the way MaxCmdSN is used.Alexander Motin2017-02-171-6/+6
| | | | | | | | | | | | | | | | | Before this change MaxCmdSN was reported as CmdSN + delta, that made it limit number of requests in transmission from the initiator to target, that was pretty useless. After this change MaxCmdSN limits number of requests queued to CTL, i.e. maximal queue depth for the initiator. The default limit is 256 outstanding requests per initiator at a time. This code uses existing cs_outstanding_ctl_pdus counter to track queue depth. It's semantics doen't perfectly match, but close enough to not add another counter. Just don't set the maxtags below 2. MFC after: 2 weeks Notes: svn path=/head/; revision=313854
* Fix overrun handling issue in r312291.Alexander Motin2017-01-231-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=312669
* Remove max_targets and max_target_id CTL port variables; they were unused.Edward Tomasz Napierala2017-01-221-5/+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-2/+21
| | | | | | | | | | | 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
* Improve error message on duplicate iSCSI port.Alexander Motin2017-01-171-1/+2
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=312343
* Make CTL frontends report kern_data_resid for under-/overruns.Alexander Motin2017-01-161-9/+10
| | | | | | | | | | | | | | | | | 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
* Don't release the cfiscsi session refcount too early. It wasn'tEdward Tomasz Napierala2017-01-041-1/+2
| | | | | | | | | | | observed to fix any actual error, but it's the right thing to do from the correctness point of view. Tested by: Eugene M. Zheganin <emz at norma.perm.ru> MFC after: 1 month Notes: svn path=/head/; revision=311283
* Make the iSCSI parameter negotiation more flexible.Navdeep Parhar2016-08-251-13/+23
| | | | | | | | | | | | | | | | | | | | | | Decouple the send and receive limits on the amount of data in a single iSCSI PDU. MaxRecvDataSegmentLength is declarative, not negotiated, and is direction-specific so there is no reason for both ends to limit themselves to the same min(initiator, target) value in both directions. Allow iSCSI drivers to report their send, receive, first burst, and max burst limits explicitly instead of using hardcoded values or trying to derive all of them from the receive limit (which was the only limit reported by the drivers prior to this change). Display the send and receive limits separately in the userspace iSCSI utilities. Reviewed by: jpaetzel@ (earlier version), trasz@ Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D7279 Notes: svn path=/head/; revision=304787
* Report negotiated MaxBurstLength and FirstBurstLength in "iscsictl -v"Edward Tomasz Napierala2016-06-051-0/+5
| | | | | | | | | and "ctladm islist -v" outputs. MFC after: 1 month Notes: svn path=/head/; revision=301437
* Add mechanism for choosing iSER-capable ICL modules.Edward Tomasz Napierala2016-05-241-2/+3
| | | | | | | | MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=300592
* Add icl_conn_connect() ICL method, required for iSER.Edward Tomasz Napierala2016-05-171-0/+1
| | | | | | | | | Obtained from: Mellanox Technologies (earlier version) MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=300044
* Set bhsdi_target_transfer_tag to reserved value, which is 0xffffffff.Alexander Motin2016-03-041-0/+1
| | | | | | | This should be a purely cosmetic change. Notes: svn path=/head/; revision=296392
* Give CTL support for PIM_EXTLUNS when talking to CAM.Alexander Motin2015-10-241-58/+3
| | | | | | | | 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
* Remove some dead code found by Clang analyzer.Alexander Motin2015-09-251-2/+1
| | | | Notes: svn path=/head/; revision=288221
* Remove some control_softc references.Alexander Motin2015-09-251-1/+0
| | | | Notes: svn path=/head/; revision=288211
* Log iSCSI session reinstatements.Alexander Motin2015-09-211-0/+10
| | | | | | | | False session reinstatements can be result of misconfiguration, when several initiators use the same initiator name and ISID. Notes: svn path=/head/; revision=288067
* Mark with DMA flag I/Os waiting for iSCSI write data after R2T.Alexander Motin2015-09-201-0/+5
| | | | | | | Reads and immediate writes are not blocking, so don't bother. Notes: svn path=/head/; revision=288021
* Implement QUERY TASK, QUERY TASK SET and QUERY ASYNC EVENT.Alexander Motin2015-09-141-10/+34
| | | | | | | Now we support most of SAM-5 task management. Notes: svn path=/head/; revision=287774
* Map CLEAR TASK SET and I_T NEXUS RESET for iSCSI.Alexander Motin2015-09-131-0/+12
| | | | | | | The last should not be called without iSCSIProtocolLevel negotiation. Notes: svn path=/head/; revision=287765
* Implement iSCSI TARGET COLD RESET task management function.Alexander Motin2015-09-131-1/+23
| | | | | | | Implement it as CTL_TASK_TARGET_RESET plus termination of all sessions. Notes: svn path=/head/; revision=287764
* 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-6/+3
| | | | Notes: svn path=/head/; revision=287620
* Make most of port methods optional and remove bunch of dummies.Alexander Motin2015-09-011-19/+0
| | | | Notes: svn path=/head/; revision=287372
* Drop "internal" CTL frontend.Alexander Motin2015-08-151-1/+0
| | | | | | | | | Its idea was to be a simple initiator and execute several commands from kernel level, but FreeBSD never had consumer for that functionality, while its implementation polluted many unrelated places.. Notes: svn path=/head/; revision=286806
* Bring per-port LUN enable/disable code up to date:Alexander Motin2015-06-201-6/+4
| | | | | | | | | | | | | - 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
* Fix ordering of "*logout" and "*terminate"; no functional changes.Edward Tomasz Napierala2015-02-081-40/+40
| | | | | | | | MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=278398
* Extend ICL to add receive offload methods. For software ICL backendEdward Tomasz Napierala2015-02-081-11/+57
| | | | | | | | | | they are no-ops. MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=278397
* Make it possible to set (via ctl.conf(5)) and query (via ctladm islist -v)Edward Tomasz Napierala2015-02-061-5/+34
| | | | | | | | | | | | target iSCSI offload. Add mechanism to query maximum receive data segment size supported by chosen hardware offload module, and use it in ctld(8) to determine the value to advertise to the other side. MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=278331
* Bring some more order into iSCSI portal group tags support.Alexander Motin2015-02-031-19/+29
| | | | | | | | | | | While ctld(8) still does not allow multiple portal groups per target to be configured, kernel should now be able to handle it. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=278161
* CTL LUN mapping rewrite.Alexander Motin2015-02-011-98/+1
| | | | | | | | | | | | | | | | | | | | | | | | Replace iSCSI-specific LUN mapping mechanism with new one, working for any ports. By default all ports are created without LUN mapping, exposing all CTL LUNs as before. But, if needed, LUN mapping can be manually set on per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2). The next step will be to teach ctld to work with FibreChannel ports also. Respecting additional flexibility of the new mechanism, ctl.conf now allows alternative syntax for LUN definition. LUNs can now be defined in global context, and then referenced from targets by unique name, as needed. It allows same LUN to be exposed several times via multiple targets. While there, increase limit for LUNs per target in ctld from 256 to 1024. Some initiators do not support LUNs above 255, but that is not our problem. Discussed with: trasz MFC after: 2 weeks Relnotes: yes Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=278037
* Add kobj interface between ICL and the rest of the iSCSI stack.Edward Tomasz Napierala2015-01-311-1/+3
| | | | | | | | | | Review note - icl.c was moved to icl_soft.c. MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=277963