summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ibmvscsi/ibmvfc.h
Commit message (Collapse)AuthorAgeFilesLines
* scsi: ibmvfc: Use 'unsigned int' for single-bit bitfields in 'struct ↵Nathan Chancellor2023-10-131-9/+9
| | | | | | | | | | | | | | | | | | | | | | | ibmvfc_host' Clang warns (or errors with CONFIG_WERROR=y) several times along the lines of: drivers/scsi/ibmvscsi/ibmvfc.c:650:17: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 650 | vhost->reinit = 1; | ^ ~ A single-bit signed integer bitfield only has possible values of -1 and 0, not 0 and 1 like an unsigned one would. No context appears to check the actual value of these bitfields, just whether or not it is zero. However, it is easy enough to change the type of the fields to 'unsigned int', which keeps the same size in memory and resolves the warning. Fixes: 5144905884e2 ("scsi: ibmvfc: Use a bitfield for boolean flags") Signed-off-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20231010-ibmvfc-fix-bitfields-type-v1-1-37e95b5a60e5@kernel.org Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Add protocol field to target structureTyrel Datwyler2023-09-211-5/+6
| | | | | | | | | | | Add a per target protocol field so target code can determine correct protocol specific actions as well as identify the correct channel group target list. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://lore.kernel.org/r/20230921225435.3537728-12-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Make discovery buffer per protocol channel groupTyrel Datwyler2023-09-211-3/+3
| | | | | | | | | | | | | The target discovery buffer that the VIOS populates with targets is currently a host adapter field. To facilitate the discovery of NVMe targets as well as SCSI another discovery buffer is required. Move the discovery buffer out of the host struct and into the ibmvfc_channels struct so that each channels instance for a given protocol has its own discovery buffer. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://lore.kernel.org/r/20230921225435.3537728-11-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Add protocol field to ibmvfc_channelsTyrel Datwyler2023-09-211-0/+7
| | | | | | | | | | | There are cases in the generic code where protocol specific configuration or actions may need to be taken. Add a protocol field to struct ibmvfc_channels and initial IBMVFC_PROTO_[SCSI/NVME] definitions. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://lore.kernel.org/r/20230921225435.3537728-10-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Track max and desired queue size in ibmvfc_channelsTyrel Datwyler2023-09-211-2/+3
| | | | | | | | | | | | Add fields for desired and max number of queues to ibmvfc_channels. With support for NVMeoF protocol coming these sorts of values should be tracked in the protocol specific channel struct instead of the overarching host adapter. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://lore.kernel.org/r/20230921225435.3537728-8-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Rename ibmvfc_scsi_channels to ibmvfc_channelsTyrel Datwyler2023-09-211-2/+2
| | | | | | | | | | | | There is nothing scsi specific about the ibmvfc_scsi_channels struct. It is meant to encapsulate a set of channels regardless of protocol. Remove _scsi from the struct name to reflect this genric nature. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://lore.kernel.org/r/20230921225435.3537728-7-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Use a bitfield for boolean flagsTyrel Datwyler2023-09-211-10/+10
| | | | | | | | | | | There are currently 9 binary flag fields in the ibmvfc host structure. Converting each of these to a single bitfield reduces the foot print of the structure by 32 bytes. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://lore.kernel.org/r/20230921225435.3537728-6-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Implement channel queue depth and event buffer accountingTyrel Datwyler2023-09-211-0/+9
| | | | | | | | | | | | | | | | | Extend ibmvfc_queue, ibmvfc_event, and ibmvfc_event_pool to provide queue depths for general I/O commands and reserved commands as well as proper accounting of the free events of each type from the general event pool. Further, calculate the negotiated max command limit with the VIOS at NPIV login time as a function of the number of queues times their total queue depth (general and reserved depths combined). This does away with the legacy max_request value, and allows the driver to better manage and track it resources. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://lore.kernel.org/r/20230921225435.3537728-3-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Store vhost pointer during subcrq allocationTyrel Datwyler2022-06-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the back pointer from a queue to the vhost adapter isn't set until after subcrq interrupt registration. The value is available when a queue is first allocated and can/should be also set for primary and async queues as well as subcrqs. This fixes a crash observed during kexec/kdump on Power 9 with legacy XICS interrupt controller where a pending subcrq interrupt from the previous kernel can be replayed immediately upon IRQ registration resulting in dereference of a garbage backpointer in ibmvfc_interrupt_scsi(). Kernel attempted to read user page (58) - exploit attempt? (uid: 0) BUG: Kernel NULL pointer dereference on read at 0x00000058 Faulting instruction address: 0xc008000003216a08 Oops: Kernel access of bad area, sig: 11 [#1] ... NIP [c008000003216a08] ibmvfc_interrupt_scsi+0x40/0xb0 [ibmvfc] LR [c0000000082079e8] __handle_irq_event_percpu+0x98/0x270 Call Trace: [c000000047fa3d80] [c0000000123e6180] 0xc0000000123e6180 (unreliable) [c000000047fa3df0] [c0000000082079e8] __handle_irq_event_percpu+0x98/0x270 [c000000047fa3ea0] [c000000008207d18] handle_irq_event+0x98/0x188 [c000000047fa3ef0] [c00000000820f564] handle_fasteoi_irq+0xc4/0x310 [c000000047fa3f40] [c000000008205c60] generic_handle_irq+0x50/0x80 [c000000047fa3f60] [c000000008015c40] __do_irq+0x70/0x1a0 [c000000047fa3f90] [c000000008016d7c] __do_IRQ+0x9c/0x130 [c000000014622f60] [0000000020000000] 0x20000000 [c000000014622ff0] [c000000008016e50] do_IRQ+0x40/0xa0 [c000000014623020] [c000000008017044] replay_soft_interrupts+0x194/0x2f0 [c000000014623210] [c0000000080172a8] arch_local_irq_restore+0x108/0x170 [c000000014623240] [c000000008eb1008] _raw_spin_unlock_irqrestore+0x58/0xb0 [c000000014623270] [c00000000820b12c] __setup_irq+0x49c/0x9f0 [c000000014623310] [c00000000820b7c0] request_threaded_irq+0x140/0x230 [c000000014623380] [c008000003212a50] ibmvfc_register_scsi_channel+0x1e8/0x2f0 [ibmvfc] [c000000014623450] [c008000003213d1c] ibmvfc_init_sub_crqs+0xc4/0x1f0 [ibmvfc] [c0000000146234d0] [c0080000032145a8] ibmvfc_reset_crq+0x150/0x210 [ibmvfc] [c000000014623550] [c0080000032147c8] ibmvfc_init_crq+0x160/0x280 [ibmvfc] [c0000000146235f0] [c00800000321a9cc] ibmvfc_probe+0x2a4/0x530 [ibmvfc] Link: https://lore.kernel.org/r/20220616191126.1281259-2-tyreld@linux.ibm.com Fixes: 3034ebe26389 ("scsi: ibmvfc: Add alloc/dealloc routines for SCSI Sub-CRQ Channels") Cc: stable@vger.kernel.org Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Do not wait for initial device scanHannes Reinecke2021-08-171-0/+1
| | | | | | | | | | | | The initial device scan might take some time, and there really is no need to wait for it during probe(). So return immediately from scsi_scan_host() during probe() and avoid any udev stalls during booting. Link: https://lore.kernel.org/r/20210817075306.11315-1-mwilck@suse.com Acked-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Fix command state accounting and stale response detectionTyrel Datwyler2021-07-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to commit 1f4a4a19508d ("scsi: ibmvfc: Complete commands outside the host/queue lock") responses to commands were completed sequentially with the host lock held such that a command had a basic binary state of active or free. It was therefore a simple affair of ensuring the assocaiated ibmvfc_event to a VIOS response was valid by testing that it was not already free. The lock relexation work to complete commands outside the lock inadverdently made it a trinary command state such that a command is either in flight, received and being completed, or completed and now free. This breaks the stale command detection logic as a command may be still marked active and been placed on the delayed completion list when a second stale response for the same command arrives. This can lead to double completions and list corruption. This issue was exposed by a recent VIOS regression were a missing memory barrier could occasionally result in the ibmvfc client receiving a duplicate response for the same command. Fix the issue by introducing the atomic ibmvfc_event.active to track the trinary state of a command. The state is explicitly set to 1 when a command is successfully sent. The CRQ response handlers use atomic_dec_if_positive() to test for stale responses and correctly transition to the completion state when a active command is received. Finally, atomic_dec_and_test() is used to sanity check transistions when commands are freed as a result of a completion, or moved to the purge list as a result of error handling or adapter reset. Link: https://lore.kernel.org/r/20210716205220.1101150-1-tyreld@linux.ibm.com Fixes: 1f4a4a19508d ("scsi: ibmvfc: Complete commands outside the host/queue lock") Cc: stable@vger.kernel.org Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Avoid move login if fast fail is enabledBrian King2021-05-141-0/+1
| | | | | | | | | | | | | | | | | | If fast fail is enabled and we encounter a WWPN moving from one port id to another port id with I/O outstanding, if we use the move login MAD, although it will work, it will leave any outstanding I/O still outstanding to the old port id. Eventually, the SCSI command timers will fire and we will abort these commands, however, this is generally much longer than the fast fail timeout, which can lead to I/O operations being outstanding for a long time. This patch changes the behavior to avoid the move login if fast fail is enabled. Once terminate_rport_io cleans up the rport, then we force the target back through the delete process, which re-drives the implicit logout, then kicks us back into discovery where we will discover the WWPN at the new location and do a PLOGI to it. Link: https://lore.kernel.org/r/1620756740-7045-3-git-send-email-brking@linux.vnet.ibm.com Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Handle move login failureBrian King2021-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | When service is being performed on an SVC with NPIV enabled, the WWPN of the canister / node being serviced fails over to the another canister / node. This looks to the ibmvfc driver as a WWPN moving from one SCSI ID to another. The driver will first attempt to do an implicit logout of the old SCSI ID. If this works, we simply delete the rport at the old location and add an rport at the new location and the FC transport class handles everything. However, if there is I/O outstanding, this implicit logout will fail, in which case we will send a "move login" request to the VIOS. This will cancel any outstanding I/O to that port, logout the port, and PLOGI the new port. Recently we've encountered a scenario where the move login fails. This was resulting in an attempted plogi to the new scsi id, without the old scsi id getting logged out, which is a VIOS protocol violation. To solve this, we want to keep tracking the old scsi id as the current scsi id. That way, once terminate_rport_io cancels the outstanding i/o, it will send us back through to do an implicit logout of the old scsi id, rather than the new scsi id, and then we can plogi the new scsi id. Link: https://lore.kernel.org/r/1620756740-7045-2-git-send-email-brking@linux.vnet.ibm.com Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Provide modules parameters for MQ settingsTyrel Datwyler2021-01-141-0/+1
| | | | | | | | | | | Add the various module parameter toggles for adjusting the MQ characteristics at boot/load time as well as a device attribute for changing the client scsi channel request amount. Link: https://lore.kernel.org/r/20210114203148.246656-22-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Enable MQ and set reasonable defaultsTyrel Datwyler2021-01-141-3/+3
| | | | | | | | | | | Turn on MQ by default and set sane values for the upper limit on hw queues for the SCSI host, and number of hw SCSI channels to request from the partner VIOS. Link: https://lore.kernel.org/r/20210114203148.246656-21-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Send Cancel MAD down each hw SCSI channelTyrel Datwyler2021-01-141-0/+3
| | | | | | | | | | | | | | | | | | | In general the client needs to send Cancel MADs and task management commands down the same channel as the command(s) intended to cancel or abort. The client assigns cancel keys per LUN and thus must send a Cancel down each channel commands were submitted for that LUN. Further, the client then must wait for those cancel completions prior to submitting a LUN RESET or ABORT TASK SET. Add a cancel rsp iu syncronization field to the ibmvfc_queue struct such that the cancel routine can sync the cancel response to each queue that requires a cancel command. Build a list of each cancel event sent and wait for the completion of each submitted cancel. Link: https://lore.kernel.org/r/20210114203148.246656-19-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Set and track hw queue in ibmvfc_event structTyrel Datwyler2021-01-141-0/+1
| | | | | | | | | | | Extract the hwq id from a SCSI command and store it in the ibmvfc_event structure to identify which Sub-CRQ to send the command down when channels are being utilized. Link: https://lore.kernel.org/r/20210114203148.246656-15-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Implement channel enquiry and setup commandsTyrel Datwyler2021-01-141-0/+3
| | | | | | | | | | | | | | | | | | | | New NPIV_ENQUIRY_CHANNEL and NPIV_SETUP_CHANNEL management datagrams (MADs) were defined in a previous patchset. If the client advertises a desire to use channels and the partner VIOS is channel capable then the client must proceed with channel enquiry to determine the maximum number of channels the VIOS is capable of providing, and registering SubCRQs via channel setup with the VIOS immediately following NPIV Login. This handshaking should not be performed for subsequent NPIV Logins unless the CRQ connection has been reset. Implement these two new MADs and issue them following a successful NPIV login where the VIOS has set the SUPPORT_CHANNELS capability bit in the NPIV Login response. Link: https://lore.kernel.org/r/20210114203148.246656-13-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Add alloc/dealloc routines for SCSI Sub-CRQ ChannelsTyrel Datwyler2021-01-141-0/+1
| | | | | | | | | | | | | | | Allocate a set of Sub-CRQs in advance. During channel setup the client and VIOS negotiate the number of queues the VIOS supports and the number that the client desires to request. Its possible that the final channel resources allocated is less than requested, but the client is still responsible for sending handles for every queue it is hoping for. Also, provide deallocation cleanup routines. Link: https://lore.kernel.org/r/20210114203148.246656-8-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Add Subordinate CRQ definitionsTyrel Datwyler2021-01-141-0/+21
| | | | | | | | | | | | | | | | | | | | Subordinate Command Response Queues (Sub CRQ) are used in conjunction with the primary CRQ when more than one queue is needed by the virtual I/O adapter. Recent phyp firmware versions support Sub CRQ's with ibmvfc adapters. This feature is a prerequisite for supporting multiple hardware backed submission queues in the vfc adapter. The Sub CRQ command element differs from the standard CRQ in that it is 32bytes long as opposed to 16bytes for the latter. Despite this extra 16bytes the ibmvfc protocol will use the original CRQ command element mapped to the first 16bytes of the Sub CRQ element initially. Add definitions for the Sub CRQ command element and queue. Link: https://lore.kernel.org/r/20210114203148.246656-7-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Add vhost fields and defaults for MQ enablementTyrel Datwyler2021-01-141-0/+9
| | | | | | | | | | Introduce several new vhost fields for managing MQ state of the adapter as well as initial defaults for MQ enablement. Link: https://lore.kernel.org/r/20210114203148.246656-2-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Complete commands outside the host/queue lockTyrel Datwyler2021-01-071-1/+2
| | | | | | | | | | | Drain the command queue and place all commands on a completion list. Perform command completion on that list outside the host/queue locks. Further, move purged command compeletions outside the host_lock as well. Link: https://lore.kernel.org/r/20210106201835.1053593-5-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Define per-queue state/list locksTyrel Datwyler2021-01-071-1/+6
| | | | | | | | | | | | Define per-queue locks for protecting queue state and event pool sent/free lists. The evt list lock is initially redundant but it allows the driver to be modified in the follow-up patches to relax the queue locking around submissions and completions. Link: https://lore.kernel.org/r/20210106201835.1053593-4-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Make command event pool queue specificTyrel Datwyler2021-01-071-4/+6
| | | | | | | | | | | | There is currently a single command event pool per host. In anticipation of providing multiple queues add a per-queue event pool definition and reimplement the existing CRQ to use its queue defined event pool for command submission and completion. Link: https://lore.kernel.org/r/20210106201835.1053593-3-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Define generic queue structure for CRQsTyrel Datwyler2021-01-071-14/+20
| | | | | | | | | | | | | | | | The primary and async CRQs are nearly identical outside of the format and length of each message entry in the dma mapped page that represents the queue data. These queues can be represented with a generic queue structure that uses a union to differentiate between message format of the mapped page. This structure will further be leveraged in a followup patcheset that introduces Sub-CRQs. Link: https://lore.kernel.org/r/20210106201835.1053593-2-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Add new fields for version 2 of several MADsTyrel Datwyler2020-11-191-4/+24
| | | | | | | | | | | | | | | Introduce a target_wwpn field to several MADs. Its possible that a SCSI ID of a target can change due to some fabric changes. The WWPN of the SCSI target provides a better way to identify the target. Also, add flags for receiving MAD versioning information and advertising client support for targetWWPN with the VIOS. This latter capability flag will be required for future clients capable of requesting multiple hardware queues from the host adapter. Link: https://lore.kernel.org/r/20201118011104.296999-3-tyreld@linux.ibm.com Acked-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Avoid link down on FS9100 canister rebootBrian King2020-09-151-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a canister on a FS9100, or similar storage, running in NPIV mode, is rebooted, its WWPNs will fail over to another canister. When this occurs, we see a WWPN going away from the fabric at one N-Port ID, and, a short time later, the same WWPN appears at a different N-Port ID. When the canister is fully operational again, the WWPNs fail back to the original canister. If there is any I/O outstanding to the target when this occurs, it will result in the implicit logout the ibmvfc driver issues before removing the rport to fail. When the WWPN then shows up at a different N-Port ID, and we issue a PLOGI to it, the VIOS will see that it still has a login for this WWPN at the old N-Port ID, which results in the VIOS simulating a link down / link up sequence to the client, in order to get the VIOS and client LPAR in sync. The patch below improves the way we handle this scenario so as to avoid the link bounce, which affects all targets under the virtual host adapter. The change is to utilize the Move Login MAD, which will work even when I/O is outstanding to the target. The change only alters the target state machine for the case where the implicit logout fails prior to deleting the rport. If this implicit logout fails, we defer deleting the ibmvfc_target object after calling fc_remote_port_delete. This enables us to later retry the implicit logout after terminate_rport_io occurs, or to issue the Move Login request if a WWPN shows up at a new N-Port ID prior to this occurring. This has been tested by IBM's storage interoperability team on a FS9100, forcing the failover to occur. With debug tracing enabled in the ibmvfc driver, we confirmed the move login was sent in this scenario and confirmed the link bounce no longer occurred. [mkp: fix checkpatch warnings] Link: https://lore.kernel.org/r/1599859706-8505-1-git-send-email-brking@linux.vnet.ibm.com Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Interface updates for future FPIN and MQ supportTyrel Datwyler2020-09-081-1/+65
| | | | | | | | | | | | | | | | | | | | | | VIOS partitions with SLI-4 enabled Emulex adapters will be capable of driving I/O in parallel through mulitple work queues or channels, and with new hypervisor firmware that supports multiple interrupt sources an ibmvfc NPIV single initiator can be modified to exploit end-to-end channelization in a PowerVM environment. VIOS hosts will also be able to expose fabric perfromance impact notifications (FPIN) via a new asynchronous event to ibmvfc clients that advertise support via IBMVFC_CAN_HANDLE_FPIN in their capabilities flag during NPIV_LOGIN. This patch introduces three new Management Datagrams (MADs) for channelization support negotiation as well as the FPIN asynchronous event and FPIN status flags. Follow up work is required to plumb the ibmvfc client driver to use these new interfaces. Link: https://lore.kernel.org/r/20200904232936.840193-2-tyreld@linux.ibm.com Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Use compiler attribute defines instead of __attribute__()Tyrel Datwyler2020-09-081-28/+28
| | | | | | | | | | Update ibmvfc.h structs to use the preferred __packed and __aligned() attribute macros defined in include/linux/compiler_attributes.h in place of __attribute__(). Link: https://lore.kernel.org/r/20200904232936.840193-1-tyreld@linux.ibm.com Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: Avoid loss of all paths during SVC node rebootBrian King2020-03-111-1/+2
| | | | | | | | | | | | | | | | When an SVC node goes down as part of a node reboot, its WWPNs are moved to the remaining node. When the node is back online, its WWPNs are moved back. The result is that the WWPN moves from one NPort_ID to another, then back again. The ibmvfc driver was forcing the old port to be removed, but not sending an implicit logout. When the WWPN showed up at the new location, the PLOGI failed as there was already a login established for the old scsi id. The patch below fixes this by ensuring we always send an implicit logout for any scsi id associated with an rport prior to calling fc_remote_port_delete. Link: https://lore.kernel.org/r/1582767943-16611-1-git-send-email-brking@linux.vnet.ibm.com Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156Thomas Gleixner2019-05-301-15/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 59 temple place suite 330 boston ma 02111 1307 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1334 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* scsi: ibmvfc: Clean up transport eventsTyrel Datwyler2019-03-271-1/+6
| | | | | | | | | | | No change to functionality. Simply make transport event messages a little clearer, and rework CRQ format enums such that we have separate enums for INIT messages and XPORT events. [mkp: typo] Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: fix misdefined reserved field in ibmvfc_fcp_rsp_infoTyrel Datwyler2018-01-301-1/+1
| | | | | | | | | | | | | | | | | | | The fcp_rsp_info structure as defined in the FC spec has an initial 3 bytes reserved field. The ibmvfc driver mistakenly defined this field as 4 bytes resulting in the rsp_code field being defined in what should be the start of the second reserved field and thus always being reported as zero by the driver. Ideally, we should wire ibmvfc up with libfc for the sake of code deduplication, and ease of maintaining standardized structures in a single place. However, for now simply fixup the definition in ibmvfc for backporting to distros on older kernels. Wiring up with libfc will be done in a followup patch. Cc: <stable@vger.kernel.org> Reported-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* scsi: ibmvfc: add FC Class 3 Error Recovery supportTyrel Datwyler2016-08-251-0/+1
| | | | | | | | | | | | | | The ibmvfc driver currently doesn't support FC Class 3 Error Recovery. However, it is simply a matter of informing the VIOS that the payload expects to use sequence level error recovery via a bit flag in the ibmvfc_cmd structure. This patch adds a module parameter to enable error recovery support at boot time. When enabled the RETRY service parameter bit is set during PRLI, and ibmvfc_cmd->flags includes the IBMVFC_CLASS_3_ERR bit. Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
* ibmvscsis: Initial commit of IBM VSCSI Tgt DriverBryant G. Ly2016-07-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This driver is a pick up of the old IBM VIO scsi Target Driver that was started by Nick and Fujita 2-4 years ago. http://comments.gmane.org/gmane.linux.scsi/90119 The driver provides a virtual SCSI device on IBM Power Servers. This patch contains the fifth version for an initial merge of the tcm ibmvscsis driver. More information on this driver and config can be found: https://github.com/powervm/ibmvscsis/wiki/Configuration http://www.linux-iscsi.org/wiki/IBM_vSCSI (Drop extra libsrp review breakage + Fix kconfig typo - nab) Signed-off-by: Steven Royer <seroyer@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> Signed-off-by: Michael Cyr <mikecyr@linux.vnet.ibm.com> Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com> Cc: FUJITA Tomonori <tomof@acm.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* ibmvfc: fix little endian issuesTyrel Datwyler2014-07-251-134/+134
| | | | | | | | | Added big endian annotations to relevant data structure fields, and necessary byte swappings to support little endian builds. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
* [SCSI] ibmvfc: Driver version 1.0.11Brian King2013-05-021-2/+2
| | | | | | Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Acked-by: Robert Jennings <rcj@linux.vnet.ibm.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
* [SCSI] ibmvfc: Suppress ABTS if target goneBrian King2013-05-021-1/+2
| | | | | | | | | | | Adds support for a new VIOS feature that allows ibmvfc to optimize terminate_rport_io by telling the VIOS the target is no longer accessible on the fabric and that it should not send an ABTS out on the fabric to the device. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Acked-by: Robert Jennings <rcj@linux.vnet.ibm.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
* [SCSI] ibmvfc: Driver version 1.0.10Brian King2012-09-241-2/+2
| | | | | | | Bump driver version. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
* [SCSI] ibmvfc: Improve ibmvfc_async_desc memory layoutRobert Jennings2010-12-211-1/+1
| | | | | | | | | By changing field ordering we can avoid a couple of memory holes in the tables that use the ibmvfc_async_desc structure. Signed-off-by: Robert Jennings <rcj@linux.vnet.ibm.com> Acked-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Log link up/down eventsBrian King2010-09-161-0/+6
| | | | | | | | | | | By default, ibmvfc does not log any async events in order to avoid flooding the log with them. Improve on this by logging by default events that are not likely to flood the log, such as link up/down. Having these events in the log will improve the ability to debug issues with ibmvfc. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Driver version 1.0.9Brian King2010-08-061-2/+2
| | | | | | | Bump driver version. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Fix terminate_rport_ioBrian King2010-08-061-0/+1
| | | | | | | | | | | | The ibmvfc driver was incorrectly obtaining a scsi_target pointer from an fc_rport. The way it is coded ensures that ibmvfc's terminate_rport_io handler does absolutely nothing. Fix this up to iterate through affected devices differently, sending cancel and abort task set as appropriate. Without this patch, fast_io_fail_tmo is broken for ibmvfc. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Fix rport add/delete race resulting in oopsBrian King2010-08-061-0/+1
| | | | | | | | | | | | | Commit 43c8da907ccc656935d1085701f4db83385d8a59 introduced a race condition which can occur when adding/deleting rports. There are two possible threads now that can be deleting rports in the ibmvfc driver, which can result in list_del being called twice, resulting in an oops. This patch adds a new state to the ibmvfc_target struct to indicate the target has been removed from the list and is in the process of being deleted. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Driver version 1.0.8Brian King2010-07-271-2/+2
| | | | | | | Bump driver version. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Fix soft lockup on resumeBrian King2010-07-271-0/+2
| | | | | | | | | | | | | | | This fixes a softlockup seen on resume. During resume, the CRQ must be reenabled. However, the H_ENABLE_CRQ hcall used to do this may return H_BUSY or H_LONG_BUSY. When this happens, the caller is expected to retry later. Normally the H_ENABLE_CRQ succeeds relatively soon. However, we have seen cases where this can take long enough to see softlockup warnings. This patch changes a simple loop, which was causing the softlockup, to a loop at task level which sleeps between retries rather than simply spinning. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Reduce error recovery timeoutBrian King2010-05-021-0/+1
| | | | | | | | | | If a command times out resulting in EH getting invoked, we wait for the aborted commands to come back after sending the abort. Shorten the amount of time we wait for these responses, to ensure we don't get stuck in EH for several minutes. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Driver version 1.0.7Brian King2009-12-041-2/+2
| | | | | | | Bump driver version to 1.0.7. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* [SCSI] ibmvfc: Add FC Passthru supportBrian King2009-12-041-1/+7
| | | | | | | Adds support for FC passthru via BSG. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
* ibmvfc: Fix endless PRLI loop in discoveryBrian King2009-06-211-0/+1
| | | | | | | | | | | | Fixes a problem seen where sending a PRLI to a target resulted in it sending a LOGO. This caused the ibmvfc driver to go back through discovery again, which caused another PRLI attempt, which caused another LOGO. Fix this behavior by ignoring LOGO if we haven't even logged into the target yet. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>