^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * SAS host prototypes and structures header file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef _LIBSAS_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define _LIBSAS_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <scsi/sas.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/libata.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <scsi/scsi_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <scsi/scsi_cmnd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <scsi/scsi_transport_sas.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/scatterlist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct block_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) enum sas_class {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) SAS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) EXPANDER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) enum sas_phy_role {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) PHY_ROLE_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) PHY_ROLE_TARGET = 0x40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) PHY_ROLE_INITIATOR = 0x80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) enum sas_phy_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) PHY_TYPE_PHYSICAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) PHY_TYPE_VIRTUAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* The events are mnemonically described in sas_dump.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * so when updating/adding events here, please also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * update the other file too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) enum port_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) PORTE_BYTES_DMAED = 0U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) PORTE_BROADCAST_RCVD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) PORTE_LINK_RESET_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) PORTE_TIMER_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) PORTE_HARD_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) PORT_NUM_EVENTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) enum phy_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) PHYE_LOSS_OF_SIGNAL = 0U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) PHYE_OOB_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) PHYE_OOB_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) PHYE_SPINUP_HOLD, /* hot plug SATA, no COMWAKE sent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) PHYE_RESUME_TIMEOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) PHYE_SHUTDOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) PHY_NUM_EVENTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) enum discover_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) DISCE_DISCOVER_DOMAIN = 0U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) DISCE_REVALIDATE_DOMAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) DISCE_SUSPEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) DISCE_RESUME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) DISC_NUM_EVENTS,
^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) /* ---------- Expander Devices ---------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define to_dom_device(_obj) container_of(_obj, struct domain_device, dev_obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define to_dev_attr(_attr) container_of(_attr, struct domain_dev_attribute,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) enum routing_attribute {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) DIRECT_ROUTING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) SUBTRACTIVE_ROUTING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) TABLE_ROUTING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) enum ex_phy_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) PHY_EMPTY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) PHY_VACANT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) PHY_NOT_PRESENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) PHY_DEVICE_DISCOVERED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct ex_phy {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int phy_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) enum ex_phy_state phy_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) enum sas_device_type attached_dev_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) enum sas_linkrate linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) u8 attached_sata_host:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) u8 attached_sata_dev:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) u8 attached_sata_ps:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) enum sas_protocol attached_tproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) enum sas_protocol attached_iproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) u8 attached_sas_addr[SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) u8 attached_phy_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int phy_change_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) enum routing_attribute routing_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) u8 virtual:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int last_da_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct sas_phy *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct sas_port *port;
^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) struct expander_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct list_head children;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int ex_change_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) u16 max_route_indexes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) u8 num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) u8 t2t_supp:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u8 configuring:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) u8 conf_route_table:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) u8 enclosure_logical_id[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct ex_phy *ex_phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct sas_port *parent_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct mutex cmd_mutex;
^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) /* ---------- SATA device ---------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define ATA_RESP_FIS_SIZE 24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct sata_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) unsigned int class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) u8 port_no; /* port number, if this is a PM (Port) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct ata_port *ap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct ata_host *ata_host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct smp_resp rps_resp ____cacheline_aligned; /* report_phy_sata_resp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) u8 fis[ATA_RESP_FIS_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct ssp_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct list_head eh_list_node; /* pending a user requested eh action */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct scsi_lun reset_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) SAS_DEV_GONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) SAS_DEV_FOUND, /* device notified to lldd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) SAS_DEV_DESTROY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) SAS_DEV_EH_PENDING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) SAS_DEV_LU_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) SAS_DEV_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct domain_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) spinlock_t done_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) enum sas_device_type dev_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) enum sas_linkrate linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) enum sas_linkrate min_linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) enum sas_linkrate max_linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) int pathways;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct domain_device *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct list_head siblings; /* devices on the same level */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct asd_sas_port *port; /* shortcut to root of the tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct sas_phy *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct list_head dev_list_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct list_head disco_list_node; /* awaiting probe or destruct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) enum sas_protocol iproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) enum sas_protocol tproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) u8 sas_addr[SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) u8 frame_rcvd[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct expander_device ex_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct sata_device sata_dev; /* STP & directly attached */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct ssp_device ssp_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) void *lldd_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct kref kref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct sas_work {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct list_head drain_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static inline bool dev_is_expander(enum sas_device_type type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) return type == SAS_EDGE_EXPANDER_DEVICE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) type == SAS_FANOUT_EXPANDER_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) INIT_WORK(&sw->work, fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) INIT_LIST_HEAD(&sw->drain_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct sas_discovery_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct sas_work work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct asd_sas_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static inline struct sas_discovery_event *to_sas_discovery_event(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) struct sas_discovery_event *ev = container_of(work, typeof(*ev), work.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return ev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct sas_discovery {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) unsigned long pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) u8 fanout_sas_addr[SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) u8 eeds_a[SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) u8 eeds_b[SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) int max_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /* The port struct is Class:RW, driver:RO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) struct asd_sas_port {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /* private: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct sas_discovery disc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct domain_device *port_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) spinlock_t dev_list_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct list_head dev_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct list_head disco_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) struct list_head destroy_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct list_head sas_port_del_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) enum sas_linkrate linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) struct sas_work work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) int suspended;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* public: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) enum sas_class class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) u8 sas_addr[SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) u8 attached_sas_addr[SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) enum sas_protocol iproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) enum sas_protocol tproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) enum sas_oob_mode oob_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) spinlock_t phy_list_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct list_head phy_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) int num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) u32 phy_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct sas_ha_struct *ha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct sas_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) void *lldd_port; /* not touched by the sas class code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) struct asd_sas_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct sas_work work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) struct asd_sas_phy *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) int event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static inline struct asd_sas_event *to_asd_sas_event(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) struct asd_sas_event *ev = container_of(work, typeof(*ev), work.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) return ev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) static inline void INIT_SAS_EVENT(struct asd_sas_event *ev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) void (*fn)(struct work_struct *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) struct asd_sas_phy *phy, int event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) INIT_SAS_WORK(&ev->work, fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) ev->phy = phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ev->event = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) #define SAS_PHY_SHUTDOWN_THRES 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /* The phy pretty much is controlled by the LLDD.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * The class only reads those fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) struct asd_sas_phy {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) /* private: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) atomic_t event_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) int in_shutdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) int suspended;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) struct sas_phy *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) /* public: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) /* The following are class:RO, driver:R/W */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) int enabled; /* must be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) int id; /* must be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) enum sas_class class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) enum sas_protocol iproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) enum sas_protocol tproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) enum sas_phy_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) enum sas_phy_role role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) enum sas_oob_mode oob_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) enum sas_linkrate linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) u8 *sas_addr; /* must be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) u8 attached_sas_addr[SAS_ADDR_SIZE]; /* class:RO, driver: R/W */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) spinlock_t frame_rcvd_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) u8 *frame_rcvd; /* must be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) int frame_rcvd_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) spinlock_t sas_prim_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) u32 sas_prim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) struct list_head port_phy_el; /* driver:RO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) struct asd_sas_port *port; /* Class:RW, driver: RO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct sas_ha_struct *ha; /* may be set; the class sets it anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) void *lldd_phy; /* not touched by the sas_class_code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) struct scsi_core {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) enum sas_ha_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) SAS_HA_REGISTERED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) SAS_HA_DRAINING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) SAS_HA_ATA_EH_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) SAS_HA_FROZEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct sas_ha_struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) /* private: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) struct list_head defer_q; /* work queued while draining */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) struct mutex drain_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) int eh_active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) wait_queue_head_t eh_wait_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) struct list_head eh_dev_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) struct mutex disco_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) struct scsi_core core;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) /* public: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) char *sas_ha_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct device *dev; /* should be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) struct module *lldd_module; /* should be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct workqueue_struct *event_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) struct workqueue_struct *disco_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) u8 *sas_addr; /* must be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) spinlock_t phy_port_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) struct asd_sas_phy **sas_phy; /* array of valid pointers, must be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) struct asd_sas_port **sas_port; /* array of valid pointers, must be set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) int num_phys; /* must be set, gt 0, static */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) int strict_wide_ports; /* both sas_addr and attached_sas_addr must match
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * their siblings when forming wide ports */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) void *lldd_ha; /* not touched by sas class code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) struct list_head eh_done_q; /* complete via scsi_eh_flush_done_q */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) struct list_head eh_ata_q; /* scmds to promote from sas to ata eh */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) int event_thres;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) #define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) static inline struct domain_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) starget_to_domain_dev(struct scsi_target *starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) return starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) static inline struct domain_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) sdev_to_domain_dev(struct scsi_device *sdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) return starget_to_domain_dev(sdev->sdev_target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) static inline struct ata_device *sas_to_ata_dev(struct domain_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) return &dev->sata_dev.ap->link.device[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static inline struct domain_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) cmd_to_domain_dev(struct scsi_cmnd *cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) return sdev_to_domain_dev(cmd->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) void sas_hash_addr(u8 *hashed, const u8 *sas_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) /* Before calling a notify event, LLDD should use this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * when the link is severed (possibly from its tasklet).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * The idea is that the Class only reads those, while the LLDD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * can R/W these (thus avoiding a race).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) static inline void sas_phy_disconnected(struct asd_sas_phy *phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) phy->oob_mode = OOB_NOT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) phy->linkrate = SAS_LINK_RATE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) static inline unsigned int to_sas_gpio_od(int device, int bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) return 3 * device + bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static inline void sas_put_local_phy(struct sas_phy *phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) put_device(&phy->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) #ifdef CONFIG_SCSI_SAS_HOST_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) static inline int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) /* ---------- Tasks ---------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) service_response | SAS_TASK_COMPLETE | SAS_TASK_UNDELIVERED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) exec_status | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) ---------------------+---------------------+-----------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) SAM_... | X | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) DEV_NO_RESPONSE | X | X |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) INTERRUPTED | X | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) QUEUE_FULL | | X |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) DEVICE_UNKNOWN | | X |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) SG_ERR | | X |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) ---------------------+---------------------+-----------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) enum service_response {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) SAS_TASK_COMPLETE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) SAS_TASK_UNDELIVERED = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) enum exec_status {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) /* The SAM_STAT_.. codes fit in the lower 6 bits, alias some of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * them here to silence 'case value not in enumerated type' warnings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) __SAM_STAT_CHECK_CONDITION = SAM_STAT_CHECK_CONDITION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) SAS_DEV_NO_RESPONSE = 0x80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) SAS_DATA_UNDERRUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) SAS_DATA_OVERRUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) SAS_INTERRUPTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) SAS_QUEUE_FULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) SAS_DEVICE_UNKNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) SAS_SG_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) SAS_OPEN_REJECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) SAS_OPEN_TO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) SAS_PROTO_RESPONSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) SAS_PHY_DOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) SAS_NAK_R_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) SAS_PENDING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) SAS_ABORTED_TASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) /* When a task finishes with a response, the LLDD examines the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * response:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * - For an ATA task task_status_struct::stat is set to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * contents of struct ata_task_resp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) * - For SSP tasks, if no data is present or status/TMF response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) * is valid, task_status_struct::stat is set. If data is present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * task_status_struct::buf_valid_size, and task_status_struct::stat is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * set to SAM_CHECK_COND.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * "buf" has format SCSI Sense for SSP task, or struct ata_task_resp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) * for ATA task.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * "frame_len" is the total frame length, which could be more or less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * than actually copied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) * Tasks ending with response, always set the residual field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) struct ata_task_resp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) u16 frame_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) u8 ending_fis[ATA_RESP_FIS_SIZE]; /* dev to host or data-in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) #define SAS_STATUS_BUF_SIZE 96
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) struct task_status_struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) enum service_response resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) enum exec_status stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) int buf_valid_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) u8 buf[SAS_STATUS_BUF_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) u32 residual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) enum sas_open_rej_reason open_rej_reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) /* ATA and ATAPI task queuable to a SAS LLDD.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) struct sas_ata_task {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) struct host_to_dev_fis fis;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) u8 atapi_packet[16]; /* 0 if not ATAPI task */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) u8 retry_count; /* hardware retry, should be > 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) u8 dma_xfer:1; /* PIO:0 or DMA:1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) u8 use_ncq:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) u8 set_affil_pol:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) u8 stp_affil_pol:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) u8 device_control_reg_update:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) struct sas_smp_task {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) struct scatterlist smp_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) struct scatterlist smp_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) enum task_attribute {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) TASK_ATTR_SIMPLE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) TASK_ATTR_HOQ = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) TASK_ATTR_ORDERED= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) TASK_ATTR_ACA = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) struct sas_ssp_task {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) u8 retry_count; /* hardware retry, should be > 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) u8 LUN[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) u8 enable_first_burst:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) enum task_attribute task_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) u8 task_prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) struct scsi_cmnd *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) struct sas_task {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) struct domain_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) spinlock_t task_state_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) unsigned task_state_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) enum sas_protocol task_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) struct sas_ata_task ata_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) struct sas_smp_task smp_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) struct sas_ssp_task ssp_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) struct scatterlist *scatter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) int num_scatter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) u32 total_xfer_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) u8 data_dir:2; /* Use PCI_DMA_... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) struct task_status_struct task_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) void (*task_done)(struct sas_task *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) void *lldd_task; /* for use by LLDDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) void *uldd_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) struct sas_task_slow *slow_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) struct sas_task_slow {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) /* standard/extra infrastructure for slow path commands (SMP and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * internal lldd commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) struct completion completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) struct sas_task *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) #define SAS_TASK_STATE_PENDING 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) #define SAS_TASK_STATE_DONE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) #define SAS_TASK_STATE_ABORTED 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) #define SAS_TASK_NEED_DEV_RESET 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) #define SAS_TASK_AT_INITIATOR 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) extern struct sas_task *sas_alloc_task(gfp_t flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) extern struct sas_task *sas_alloc_slow_task(gfp_t flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) extern void sas_free_task(struct sas_task *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) struct sas_domain_function_template {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) /* The class calls these to notify the LLDD of an event. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) void (*lldd_port_formed)(struct asd_sas_phy *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) void (*lldd_port_deformed)(struct asd_sas_phy *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) /* The class calls these when a device is found or gone. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) int (*lldd_dev_found)(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) void (*lldd_dev_gone)(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) int (*lldd_execute_task)(struct sas_task *, gfp_t gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) /* Task Management Functions. Must be called from process context. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) int (*lldd_abort_task)(struct sas_task *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) int (*lldd_abort_task_set)(struct domain_device *, u8 *lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) int (*lldd_clear_aca)(struct domain_device *, u8 *lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) int (*lldd_clear_task_set)(struct domain_device *, u8 *lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) int (*lldd_I_T_nexus_reset)(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) int (*lldd_ata_check_ready)(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) void (*lldd_ata_set_dmamode)(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) int (*lldd_lu_reset)(struct domain_device *, u8 *lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) int (*lldd_query_task)(struct sas_task *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) /* Port and Adapter management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) int (*lldd_clear_nexus_port)(struct asd_sas_port *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) int (*lldd_clear_nexus_ha)(struct sas_ha_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) /* Phy management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) int (*lldd_control_phy)(struct asd_sas_phy *, enum phy_func, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) /* GPIO support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) int (*lldd_write_gpio)(struct sas_ha_struct *, u8 reg_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) u8 reg_index, u8 reg_count, u8 *write_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) extern int sas_register_ha(struct sas_ha_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) extern int sas_unregister_ha(struct sas_ha_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) extern void sas_prep_resume_ha(struct sas_ha_struct *sas_ha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) extern void sas_resume_ha(struct sas_ha_struct *sas_ha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) extern void sas_suspend_ha(struct sas_ha_struct *sas_ha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) int sas_phy_reset(struct sas_phy *phy, int hard_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) extern int sas_target_alloc(struct scsi_target *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) extern int sas_slave_configure(struct scsi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) extern int sas_change_queue_depth(struct scsi_device *, int new_depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) extern int sas_bios_param(struct scsi_device *, struct block_device *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) sector_t capacity, int *hsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) extern struct scsi_transport_template *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) sas_domain_attach_transport(struct sas_domain_function_template *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) extern struct device_attribute dev_attr_phy_event_threshold;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) int sas_discover_root_expander(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) void sas_init_ex_attr(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) int sas_ex_revalidate_domain(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) void sas_unregister_domain_devices(struct asd_sas_port *port, int gone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) int sas_discover_event(struct asd_sas_port *, enum discover_event ev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) int sas_discover_sata(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) int sas_discover_end_dev(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) void sas_init_dev(struct domain_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) void sas_task_abort(struct sas_task *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) int sas_eh_abort_handler(struct scsi_cmnd *cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) int sas_eh_target_reset_handler(struct scsi_cmnd *cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) extern void sas_target_destroy(struct scsi_target *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) extern int sas_slave_alloc(struct scsi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) extern int sas_ioctl(struct scsi_device *sdev, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) void __user *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) extern int sas_drain_work(struct sas_ha_struct *ha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) struct ssp_response_iu *iu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) struct sas_phy *sas_get_local_phy(struct domain_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) int sas_notify_port_event_gfp(struct asd_sas_phy *phy, enum port_event event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) gfp_t gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) int sas_notify_phy_event_gfp(struct asd_sas_phy *phy, enum phy_event event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) gfp_t gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) #endif /* _SASLIB_H_ */