^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * This file is provided under a dual BSD/GPLv2 license. When using or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * redistributing this file, you may do so under either license.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * GPL LICENSE SUMMARY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * it under the terms of version 2 of the GNU General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * The full GNU General Public License is included in this distribution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * in the file called LICENSE.GPL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * BSD LICENSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * * Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * * Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * notice, this list of conditions and the following disclaimer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * * Neither the name of Intel Corporation nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #ifndef _ISCI_REMOTE_DEVICE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define _ISCI_REMOTE_DEVICE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #include <scsi/libsas.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #include "scu_remote_node_context.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #include "remote_node_context.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #include "port.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) enum sci_remote_device_not_ready_reason_code {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * isci_remote_device - isci representation of a sas expander / end point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @device_port_width: hw setting for number of simultaneous connections
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * @connection_rate: per-taskcontext connection rate for this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * @working_request: SATA requests have no tag we for unaccelerated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * protocols we need a method to associate unsolicited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * frames with a pending request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct isci_remote_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define IDEV_START_PENDING 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define IDEV_STOP_PENDING 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define IDEV_ALLOCATED 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define IDEV_GONE 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define IDEV_IO_READY 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define IDEV_IO_NCQERROR 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define IDEV_RNC_LLHANG_ENABLED 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define IDEV_ABORT_PATH_ACTIVE 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define IDEV_ABORT_PATH_RESUME_PENDING 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct kref kref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct isci_port *isci_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct domain_device *domain_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct sci_base_state_machine sm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u32 device_port_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) enum sas_linkrate connection_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct isci_port *owning_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct sci_remote_node_context rnc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* XXX unify with device reference counting and delete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) u32 started_request_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct isci_request *working_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) u32 not_ready_reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) scics_sds_remote_node_context_callback abort_resume_cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) void *abort_resume_cbparam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /* device reference routines must be called under sci_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static inline struct isci_remote_device *isci_get_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct isci_remote_device *idev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (idev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) kref_get(&idev->kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return idev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static inline struct isci_remote_device *isci_lookup_device(struct domain_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct isci_remote_device *idev = dev->lldd_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (idev && !test_bit(IDEV_GONE, &idev->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) kref_get(&idev->kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return idev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) void isci_remote_device_release(struct kref *kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static inline void isci_put_device(struct isci_remote_device *idev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (idev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) kref_put(&idev->kref, isci_remote_device_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) enum sci_status isci_remote_device_stop(struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) void isci_remote_device_nuke_requests(struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) void isci_remote_device_gone(struct domain_device *domain_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int isci_remote_device_found(struct domain_device *domain_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * sci_remote_device_stop() - This method will stop both transmission and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * reception of link activity for the supplied remote device. This method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * disables normal IO requests from flowing through to the remote device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * @remote_device: This parameter specifies the device to be stopped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * @timeout: This parameter specifies the number of milliseconds in which the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * stop operation should complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * An indication of whether the device was successfully stopped. SCI_SUCCESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * This value is returned if the transmission and reception for the device was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * successfully stopped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) enum sci_status sci_remote_device_stop(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) u32 timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * sci_remote_device_reset() - This method will reset the device making it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * ready for operation. This method must be called anytime the device is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * reset either through a SMP phy control or a port hard reset request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * @remote_device: This parameter specifies the device to be reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * This method does not actually cause the device hardware to be reset. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * method resets the software object so that it will be operational after a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * device hardware reset completes. An indication of whether the device reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * was accepted. SCI_SUCCESS This value is returned if the device reset is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * started.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) enum sci_status sci_remote_device_reset(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * sci_remote_device_reset_complete() - This method informs the device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * that the reset operation is complete and the device can resume operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * @remote_device: This parameter specifies the device which is to be informed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * of the reset complete operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * An indication that the device is resuming operation. SCI_SUCCESS the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * is resuming operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) enum sci_status sci_remote_device_reset_complete(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * enum sci_remote_device_states - This enumeration depicts all the states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * for the common remote device state machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * @SCI_DEV_INITIAL: Simply the initial state for the base remote device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * state machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * @SCI_DEV_STOPPED: This state indicates that the remote device has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * successfully been stopped. In this state no new IO operations are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * permitted. This state is entered from the INITIAL state. This state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * is entered from the STOPPING state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * @SCI_DEV_STARTING: This state indicates the the remote device is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * the process of becoming ready (i.e. starting). In this state no new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * IO operations are permitted. This state is entered from the STOPPED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * @SCI_DEV_READY: This state indicates the remote device is now ready.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * Thus, the user is able to perform IO operations on the remote device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * This state is entered from the STARTING state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * @SCI_STP_DEV_IDLE: This is the idle substate for the stp remote
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * device. When there are no active IO for the device it is is in this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * @SCI_STP_DEV_CMD: This is the command state for for the STP remote
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * device. This state is entered when the device is processing a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * non-NCQ command. The device object will fail any new start IO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * requests until this command is complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * @SCI_STP_DEV_NCQ: This is the NCQ state for the STP remote device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * This state is entered when the device is processing an NCQ reuqest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * It will remain in this state so long as there is one or more NCQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * requests being processed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * @SCI_STP_DEV_NCQ_ERROR: This is the NCQ error state for the STP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * remote device. This state is entered when an SDB error FIS is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * received by the device object while in the NCQ state. The device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * object will only accept a READ LOG command while in this state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * @SCI_STP_DEV_ATAPI_ERROR: This is the ATAPI error state for the STP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * ATAPI remote device. This state is entered when ATAPI device sends
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * error status FIS without data while the device object is in CMD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * state. A suspension event is expected in this state. The device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * object will resume right away.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * @SCI_STP_DEV_AWAIT_RESET: This is the READY substate indicates the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * device is waiting for the RESET task coming to be recovered from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * certain hardware specific error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * @SCI_SMP_DEV_IDLE: This is the ready operational substate for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * remote device. This is the normal operational state for a remote
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * @SCI_SMP_DEV_CMD: This is the suspended state for the remote device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * This is the state that the device is placed in when a RNC suspend is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * received by the SCU hardware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * @SCI_DEV_STOPPING: This state indicates that the remote device is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * the process of stopping. In this state no new IO operations are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * permitted, but existing IO operations are allowed to complete. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * state is entered from the READY state. This state is entered from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * the FAILED state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * @SCI_DEV_FAILED: This state indicates that the remote device has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * failed. In this state no new IO operations are permitted. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * state is entered from the INITIALIZING state. This state is entered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * from the READY state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * @SCI_DEV_RESETTING: This state indicates the device is being reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * In this state no new IO operations are permitted. This state is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * entered from the READY state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * @SCI_DEV_FINAL: Simply the final state for the base remote device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * state machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #define REMOTE_DEV_STATES {\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) C(DEV_INITIAL),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) C(DEV_STOPPED),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) C(DEV_STARTING),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) C(DEV_READY),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) C(STP_DEV_IDLE),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) C(STP_DEV_CMD),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) C(STP_DEV_NCQ),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) C(STP_DEV_NCQ_ERROR),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) C(STP_DEV_ATAPI_ERROR),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) C(STP_DEV_AWAIT_RESET),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) C(SMP_DEV_IDLE),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) C(SMP_DEV_CMD),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) C(DEV_STOPPING),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) C(DEV_FAILED),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) C(DEV_RESETTING),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) C(DEV_FINAL),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #undef C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) #define C(a) SCI_##a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) enum sci_remote_device_states REMOTE_DEV_STATES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) #undef C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) const char *dev_state_name(enum sci_remote_device_states state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) static inline struct isci_remote_device *rnc_to_dev(struct sci_remote_node_context *rnc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct isci_remote_device *idev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) idev = container_of(rnc, typeof(*idev), rnc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) return idev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static inline void sci_remote_device_decrement_request_count(struct isci_remote_device *idev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) /* XXX delete this voodoo when converting to the top-level device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) if (WARN_ONCE(idev->started_request_count == 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) "%s: tried to decrement started_request_count past 0!?",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) __func__))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /* pass */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) idev->started_request_count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) void isci_dev_set_hang_detection_timeout(struct isci_remote_device *idev, u32 timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) enum sci_status sci_remote_device_frame_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) u32 frame_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) enum sci_status sci_remote_device_event_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) u32 event_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) enum sci_status sci_remote_device_start_io(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) enum sci_status sci_remote_device_start_task(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) enum sci_status sci_remote_device_complete_io(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) void sci_remote_device_post_request(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) u32 request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) enum sci_status sci_remote_device_terminate_requests(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) int isci_remote_device_is_safe_to_abort(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) enum sci_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) sci_remote_device_abort_requests_pending_abort(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) enum sci_status isci_remote_device_suspend(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) enum sci_status sci_remote_device_resume(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) scics_sds_remote_node_context_callback cb_fn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) void *cb_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) enum sci_status isci_remote_device_resume_from_abort(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) enum sci_status isci_remote_device_reset(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) enum sci_status isci_remote_device_reset_complete(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) struct isci_remote_device *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) enum sci_status isci_remote_device_suspend_terminate(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) enum sci_status isci_remote_device_terminate_requests(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) enum sci_status sci_remote_device_suspend(struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) enum sci_remote_node_suspension_reasons reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */