Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * SAS host prototypes and structures header file
0004  *
0005  * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
0006  * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
0007  */
0008 
0009 #ifndef _LIBSAS_H_
0010 #define _LIBSAS_H_
0011 
0012 
0013 #include <linux/timer.h>
0014 #include <linux/pci.h>
0015 #include <scsi/sas.h>
0016 #include <linux/libata.h>
0017 #include <linux/list.h>
0018 #include <scsi/scsi_device.h>
0019 #include <scsi/scsi_cmnd.h>
0020 #include <scsi/scsi_transport_sas.h>
0021 #include <linux/scatterlist.h>
0022 #include <linux/slab.h>
0023 
0024 struct block_device;
0025 
0026 enum sas_class {
0027     SAS,
0028     EXPANDER
0029 };
0030 
0031 enum sas_phy_role {
0032     PHY_ROLE_NONE = 0,
0033     PHY_ROLE_TARGET = 0x40,
0034     PHY_ROLE_INITIATOR = 0x80,
0035 };
0036 
0037 enum sas_phy_type {
0038     PHY_TYPE_PHYSICAL,
0039     PHY_TYPE_VIRTUAL
0040 };
0041 
0042 /* The events are mnemonically described in sas_dump.c
0043  * so when updating/adding events here, please also
0044  * update the other file too.
0045  */
0046 enum port_event {
0047     PORTE_BYTES_DMAED     = 0U,
0048     PORTE_BROADCAST_RCVD,
0049     PORTE_LINK_RESET_ERR,
0050     PORTE_TIMER_EVENT,
0051     PORTE_HARD_RESET,
0052     PORT_NUM_EVENTS,
0053 };
0054 
0055 enum phy_event {
0056     PHYE_LOSS_OF_SIGNAL   = 0U,
0057     PHYE_OOB_DONE,
0058     PHYE_OOB_ERROR,
0059     PHYE_SPINUP_HOLD,             /* hot plug SATA, no COMWAKE sent */
0060     PHYE_RESUME_TIMEOUT,
0061     PHYE_SHUTDOWN,
0062     PHY_NUM_EVENTS,
0063 };
0064 
0065 enum discover_event {
0066     DISCE_DISCOVER_DOMAIN   = 0U,
0067     DISCE_REVALIDATE_DOMAIN,
0068     DISCE_SUSPEND,
0069     DISCE_RESUME,
0070     DISC_NUM_EVENTS,
0071 };
0072 
0073 /* ---------- Expander Devices ---------- */
0074 
0075 #define to_dom_device(_obj) container_of(_obj, struct domain_device, dev_obj)
0076 #define to_dev_attr(_attr)  container_of(_attr, struct domain_dev_attribute,\
0077                      attr)
0078 
0079 enum routing_attribute {
0080     DIRECT_ROUTING,
0081     SUBTRACTIVE_ROUTING,
0082     TABLE_ROUTING,
0083 };
0084 
0085 enum ex_phy_state {
0086     PHY_EMPTY,
0087     PHY_VACANT,
0088     PHY_NOT_PRESENT,
0089     PHY_DEVICE_DISCOVERED
0090 };
0091 
0092 struct ex_phy {
0093     int    phy_id;
0094 
0095     enum ex_phy_state phy_state;
0096 
0097     enum sas_device_type attached_dev_type;
0098     enum sas_linkrate linkrate;
0099 
0100     u8   attached_sata_host:1;
0101     u8   attached_sata_dev:1;
0102     u8   attached_sata_ps:1;
0103 
0104     enum sas_protocol attached_tproto;
0105     enum sas_protocol attached_iproto;
0106 
0107     u8   attached_sas_addr[SAS_ADDR_SIZE];
0108     u8   attached_phy_id;
0109 
0110     int phy_change_count;
0111     enum routing_attribute routing_attr;
0112     u8   virtual:1;
0113 
0114     int  last_da_index;
0115 
0116     struct sas_phy *phy;
0117     struct sas_port *port;
0118 };
0119 
0120 struct expander_device {
0121     struct list_head children;
0122 
0123     int    ex_change_count;
0124     u16    max_route_indexes;
0125     u8     num_phys;
0126 
0127     u8     t2t_supp:1;
0128     u8     configuring:1;
0129     u8     conf_route_table:1;
0130 
0131     u8     enclosure_logical_id[8];
0132 
0133     struct ex_phy *ex_phy;
0134     struct sas_port *parent_port;
0135 
0136     struct mutex cmd_mutex;
0137 };
0138 
0139 /* ---------- SATA device ---------- */
0140 #define ATA_RESP_FIS_SIZE 24
0141 
0142 struct sata_device {
0143     unsigned int class;
0144     u8     port_no;        /* port number, if this is a PM (Port) */
0145 
0146     struct ata_port *ap;
0147     struct ata_host *ata_host;
0148     struct smp_rps_resp rps_resp ____cacheline_aligned; /* report_phy_sata_resp */
0149     u8     fis[ATA_RESP_FIS_SIZE];
0150 };
0151 
0152 struct ssp_device {
0153     struct list_head eh_list_node; /* pending a user requested eh action */
0154     struct scsi_lun reset_lun;
0155 };
0156 
0157 enum {
0158     SAS_DEV_GONE,
0159     SAS_DEV_FOUND, /* device notified to lldd */
0160     SAS_DEV_DESTROY,
0161     SAS_DEV_EH_PENDING,
0162     SAS_DEV_LU_RESET,
0163     SAS_DEV_RESET,
0164 };
0165 
0166 struct domain_device {
0167     spinlock_t done_lock;
0168     enum sas_device_type dev_type;
0169 
0170     enum sas_linkrate linkrate;
0171     enum sas_linkrate min_linkrate;
0172     enum sas_linkrate max_linkrate;
0173 
0174     int  pathways;
0175 
0176     struct domain_device *parent;
0177     struct list_head siblings; /* devices on the same level */
0178     struct asd_sas_port *port;        /* shortcut to root of the tree */
0179     struct sas_phy *phy;
0180 
0181     struct list_head dev_list_node;
0182     struct list_head disco_list_node; /* awaiting probe or destruct */
0183 
0184     enum sas_protocol    iproto;
0185     enum sas_protocol    tproto;
0186 
0187     struct sas_rphy *rphy;
0188 
0189     u8  sas_addr[SAS_ADDR_SIZE];
0190     u8  hashed_sas_addr[HASHED_SAS_ADDR_SIZE];
0191 
0192     u8  frame_rcvd[32];
0193 
0194     union {
0195         struct expander_device ex_dev;
0196         struct sata_device     sata_dev; /* STP & directly attached */
0197         struct ssp_device      ssp_dev;
0198     };
0199 
0200     void *lldd_dev;
0201     unsigned long state;
0202     struct kref kref;
0203 };
0204 
0205 struct sas_work {
0206     struct list_head drain_node;
0207     struct work_struct work;
0208 };
0209 
0210 static inline bool dev_is_expander(enum sas_device_type type)
0211 {
0212     return type == SAS_EDGE_EXPANDER_DEVICE ||
0213            type == SAS_FANOUT_EXPANDER_DEVICE;
0214 }
0215 
0216 static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *))
0217 {
0218     INIT_WORK(&sw->work, fn);
0219     INIT_LIST_HEAD(&sw->drain_node);
0220 }
0221 
0222 struct sas_discovery_event {
0223     struct sas_work work;
0224     struct asd_sas_port *port;
0225 };
0226 
0227 static inline struct sas_discovery_event *to_sas_discovery_event(struct work_struct *work)
0228 {
0229     struct sas_discovery_event *ev = container_of(work, typeof(*ev), work.work);
0230 
0231     return ev;
0232 }
0233 
0234 struct sas_discovery {
0235     struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
0236     unsigned long    pending;
0237     u8     fanout_sas_addr[SAS_ADDR_SIZE];
0238     u8     eeds_a[SAS_ADDR_SIZE];
0239     u8     eeds_b[SAS_ADDR_SIZE];
0240     int    max_level;
0241 };
0242 
0243 /* The port struct is Class:RW, driver:RO */
0244 struct asd_sas_port {
0245 /* private: */
0246     struct sas_discovery disc;
0247     struct domain_device *port_dev;
0248     spinlock_t dev_list_lock;
0249     struct list_head dev_list;
0250     struct list_head disco_list;
0251     struct list_head destroy_list;
0252     struct list_head sas_port_del_list;
0253     enum   sas_linkrate linkrate;
0254 
0255     struct sas_work work;
0256     int suspended;
0257 
0258 /* public: */
0259     int id;
0260 
0261     enum sas_class   class;
0262     u8               sas_addr[SAS_ADDR_SIZE];
0263     u8               attached_sas_addr[SAS_ADDR_SIZE];
0264     enum sas_protocol   iproto;
0265     enum sas_protocol   tproto;
0266 
0267     enum sas_oob_mode oob_mode;
0268 
0269     spinlock_t       phy_list_lock;
0270     struct list_head phy_list;
0271     int              num_phys;
0272     u32              phy_mask;
0273 
0274     struct sas_ha_struct *ha;
0275 
0276     struct sas_port *port;
0277 
0278     void *lldd_port;      /* not touched by the sas class code */
0279 };
0280 
0281 struct asd_sas_event {
0282     struct sas_work work;
0283     struct asd_sas_phy *phy;
0284     int event;
0285 };
0286 
0287 static inline struct asd_sas_event *to_asd_sas_event(struct work_struct *work)
0288 {
0289     struct asd_sas_event *ev = container_of(work, typeof(*ev), work.work);
0290 
0291     return ev;
0292 }
0293 
0294 static inline void INIT_SAS_EVENT(struct asd_sas_event *ev,
0295         void (*fn)(struct work_struct *),
0296         struct asd_sas_phy *phy, int event)
0297 {
0298     INIT_SAS_WORK(&ev->work, fn);
0299     ev->phy = phy;
0300     ev->event = event;
0301 }
0302 
0303 #define SAS_PHY_SHUTDOWN_THRES   1024
0304 
0305 /* The phy pretty much is controlled by the LLDD.
0306  * The class only reads those fields.
0307  */
0308 struct asd_sas_phy {
0309 /* private: */
0310     atomic_t event_nr;
0311     int in_shutdown;
0312     int error;
0313     int suspended;
0314 
0315     struct sas_phy *phy;
0316 
0317 /* public: */
0318     /* The following are class:RO, driver:R/W */
0319     int            enabled;   /* must be set */
0320 
0321     int            id;    /* must be set */
0322     enum sas_class class;
0323     enum sas_protocol iproto;
0324     enum sas_protocol tproto;
0325 
0326     enum sas_phy_type  type;
0327     enum sas_phy_role  role;
0328     enum sas_oob_mode  oob_mode;
0329     enum sas_linkrate linkrate;
0330 
0331     u8   *sas_addr;       /* must be set */
0332     u8   attached_sas_addr[SAS_ADDR_SIZE]; /* class:RO, driver: R/W */
0333 
0334     spinlock_t     frame_rcvd_lock;
0335     u8             *frame_rcvd; /* must be set */
0336     int            frame_rcvd_size;
0337 
0338     spinlock_t     sas_prim_lock;
0339     u32            sas_prim;
0340 
0341     struct list_head port_phy_el; /* driver:RO */
0342     struct asd_sas_port      *port; /* Class:RW, driver: RO */
0343 
0344     struct sas_ha_struct *ha; /* may be set; the class sets it anyway */
0345 
0346     void *lldd_phy;       /* not touched by the sas_class_code */
0347 };
0348 
0349 struct scsi_core {
0350     struct Scsi_Host *shost;
0351 
0352 };
0353 
0354 enum sas_ha_state {
0355     SAS_HA_REGISTERED,
0356     SAS_HA_DRAINING,
0357     SAS_HA_ATA_EH_ACTIVE,
0358     SAS_HA_FROZEN,
0359     SAS_HA_RESUMING,
0360 };
0361 
0362 struct sas_ha_struct {
0363 /* private: */
0364     struct list_head  defer_q; /* work queued while draining */
0365     struct mutex      drain_mutex;
0366     unsigned long     state;
0367     spinlock_t    lock;
0368     int       eh_active;
0369     wait_queue_head_t eh_wait_q;
0370     struct list_head  eh_dev_q;
0371 
0372     struct mutex disco_mutex;
0373 
0374     struct scsi_core core;
0375 
0376 /* public: */
0377     char *sas_ha_name;
0378     struct device *dev;   /* should be set */
0379     struct module *lldd_module; /* should be set */
0380 
0381     struct workqueue_struct *event_q;
0382     struct workqueue_struct *disco_q;
0383 
0384     u8 *sas_addr;         /* must be set */
0385     u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE];
0386 
0387     spinlock_t      phy_port_lock;
0388     struct asd_sas_phy  **sas_phy; /* array of valid pointers, must be set */
0389     struct asd_sas_port **sas_port; /* array of valid pointers, must be set */
0390     int             num_phys; /* must be set, gt 0, static */
0391 
0392     int strict_wide_ports; /* both sas_addr and attached_sas_addr must match
0393                 * their siblings when forming wide ports */
0394 
0395     void *lldd_ha;        /* not touched by sas class code */
0396 
0397     struct list_head eh_done_q;  /* complete via scsi_eh_flush_done_q */
0398     struct list_head eh_ata_q; /* scmds to promote from sas to ata eh */
0399 
0400     int event_thres;
0401 };
0402 
0403 #define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata)
0404 
0405 static inline struct domain_device *
0406 starget_to_domain_dev(struct scsi_target *starget) {
0407     return starget->hostdata;
0408 }
0409 
0410 static inline struct domain_device *
0411 sdev_to_domain_dev(struct scsi_device *sdev) {
0412     return starget_to_domain_dev(sdev->sdev_target);
0413 }
0414 
0415 static inline struct ata_device *sas_to_ata_dev(struct domain_device *dev)
0416 {
0417     return &dev->sata_dev.ap->link.device[0];
0418 }
0419 
0420 static inline struct domain_device *
0421 cmd_to_domain_dev(struct scsi_cmnd *cmd)
0422 {
0423     return sdev_to_domain_dev(cmd->device);
0424 }
0425 
0426 void sas_hash_addr(u8 *hashed, const u8 *sas_addr);
0427 
0428 /* Before calling a notify event, LLDD should use this function
0429  * when the link is severed (possibly from its tasklet).
0430  * The idea is that the Class only reads those, while the LLDD,
0431  * can R/W these (thus avoiding a race).
0432  */
0433 static inline void sas_phy_disconnected(struct asd_sas_phy *phy)
0434 {
0435     phy->oob_mode = OOB_NOT_CONNECTED;
0436     phy->linkrate = SAS_LINK_RATE_UNKNOWN;
0437 }
0438 
0439 static inline unsigned int to_sas_gpio_od(int device, int bit)
0440 {
0441     return 3 * device + bit;
0442 }
0443 
0444 static inline void sas_put_local_phy(struct sas_phy *phy)
0445 {
0446     put_device(&phy->dev);
0447 }
0448 
0449 #ifdef CONFIG_SCSI_SAS_HOST_SMP
0450 int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count);
0451 #else
0452 static inline int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count)
0453 {
0454     return -1;
0455 }
0456 #endif
0457 
0458 /* ---------- Tasks ---------- */
0459 /*
0460       service_response |  SAS_TASK_COMPLETE  |  SAS_TASK_UNDELIVERED |
0461   exec_status          |                     |                       |
0462   ---------------------+---------------------+-----------------------+
0463        SAM_...         |         X           |                       |
0464        DEV_NO_RESPONSE |         X           |           X           |
0465        INTERRUPTED     |         X           |                       |
0466        QUEUE_FULL      |                     |           X           |
0467        DEVICE_UNKNOWN  |                     |           X           |
0468        SG_ERR          |                     |           X           |
0469   ---------------------+---------------------+-----------------------+
0470  */
0471 
0472 enum service_response {
0473     SAS_TASK_COMPLETE,
0474     SAS_TASK_UNDELIVERED = -1,
0475 };
0476 
0477 enum exec_status {
0478     /*
0479      * Values 0..0x7f are used to return the SAM_STAT_* codes.  To avoid
0480      * 'case value not in enumerated type' compiler warnings every value
0481      * returned through the exec_status enum needs an alias with the SAS_
0482      * prefix here.
0483      */
0484     SAS_SAM_STAT_GOOD = SAM_STAT_GOOD,
0485     SAS_SAM_STAT_BUSY = SAM_STAT_BUSY,
0486     SAS_SAM_STAT_TASK_ABORTED = SAM_STAT_TASK_ABORTED,
0487     SAS_SAM_STAT_CHECK_CONDITION = SAM_STAT_CHECK_CONDITION,
0488 
0489     SAS_DEV_NO_RESPONSE = 0x80,
0490     SAS_DATA_UNDERRUN,
0491     SAS_DATA_OVERRUN,
0492     SAS_INTERRUPTED,
0493     SAS_QUEUE_FULL,
0494     SAS_DEVICE_UNKNOWN,
0495     SAS_OPEN_REJECT,
0496     SAS_OPEN_TO,
0497     SAS_PROTO_RESPONSE,
0498     SAS_PHY_DOWN,
0499     SAS_NAK_R_ERR,
0500     SAS_PENDING,
0501     SAS_ABORTED_TASK,
0502 };
0503 
0504 /* When a task finishes with a response, the LLDD examines the
0505  * response:
0506  *  - For an ATA task task_status_struct::stat is set to
0507  * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the
0508  * contents of struct ata_task_resp.
0509  *  - For SSP tasks, if no data is present or status/TMF response
0510  * is valid, task_status_struct::stat is set.  If data is present
0511  * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets
0512  * task_status_struct::buf_valid_size, and task_status_struct::stat is
0513  * set to SAM_CHECK_COND.
0514  *
0515  * "buf" has format SCSI Sense for SSP task, or struct ata_task_resp
0516  * for ATA task.
0517  *
0518  * "frame_len" is the total frame length, which could be more or less
0519  * than actually copied.
0520  *
0521  * Tasks ending with response, always set the residual field.
0522  */
0523 struct ata_task_resp {
0524     u16  frame_len;
0525     u8   ending_fis[ATA_RESP_FIS_SIZE];   /* dev to host or data-in */
0526 };
0527 
0528 #define SAS_STATUS_BUF_SIZE 96
0529 
0530 struct task_status_struct {
0531     enum service_response resp;
0532     enum exec_status      stat;
0533     int  buf_valid_size;
0534 
0535     u8   buf[SAS_STATUS_BUF_SIZE];
0536 
0537     u32  residual;
0538     enum sas_open_rej_reason open_rej_reason;
0539 };
0540 
0541 /* ATA and ATAPI task queuable to a SAS LLDD.
0542  */
0543 struct sas_ata_task {
0544     struct host_to_dev_fis fis;
0545     u8     atapi_packet[16];  /* 0 if not ATAPI task */
0546 
0547     u8     retry_count;   /* hardware retry, should be > 0 */
0548 
0549     u8     dma_xfer:1;    /* PIO:0 or DMA:1 */
0550     u8     use_ncq:1;
0551     u8     set_affil_pol:1;
0552     u8     stp_affil_pol:1;
0553 
0554     u8     device_control_reg_update:1;
0555 
0556     bool   force_phy;
0557     int    force_phy_id;
0558 };
0559 
0560 /* LLDDs rely on these values */
0561 enum sas_internal_abort {
0562     SAS_INTERNAL_ABORT_SINGLE   = 0,
0563     SAS_INTERNAL_ABORT_DEV      = 1,
0564 };
0565 
0566 struct sas_internal_abort_task {
0567     enum sas_internal_abort type;
0568     unsigned int qid;
0569     u16 tag;
0570 };
0571 
0572 struct sas_smp_task {
0573     struct scatterlist smp_req;
0574     struct scatterlist smp_resp;
0575 };
0576 
0577 enum task_attribute {
0578     TASK_ATTR_SIMPLE = 0,
0579     TASK_ATTR_HOQ    = 1,
0580     TASK_ATTR_ORDERED= 2,
0581     TASK_ATTR_ACA    = 4,
0582 };
0583 
0584 struct sas_ssp_task {
0585     u8     retry_count;   /* hardware retry, should be > 0 */
0586 
0587     u8     LUN[8];
0588     u8     enable_first_burst:1;
0589     enum   task_attribute task_attr;
0590     u8     task_prio;
0591     struct scsi_cmnd *cmd;
0592 };
0593 
0594 struct sas_tmf_task {
0595     u8 tmf;
0596     u16 tag_of_task_to_be_managed;
0597 };
0598 
0599 struct sas_task {
0600     struct domain_device *dev;
0601 
0602     spinlock_t   task_state_lock;
0603     unsigned     task_state_flags;
0604 
0605     enum   sas_protocol      task_proto;
0606 
0607     union {
0608         struct sas_ata_task ata_task;
0609         struct sas_smp_task smp_task;
0610         struct sas_ssp_task ssp_task;
0611         struct sas_internal_abort_task abort_task;
0612     };
0613 
0614     struct scatterlist *scatter;
0615     int    num_scatter;
0616     u32    total_xfer_len;
0617     u8     data_dir:2;    /* Use PCI_DMA_... */
0618 
0619     struct task_status_struct task_status;
0620     void   (*task_done)(struct sas_task *);
0621 
0622     void   *lldd_task;    /* for use by LLDDs */
0623     void   *uldd_task;
0624     struct sas_task_slow *slow_task;
0625     struct sas_tmf_task *tmf;
0626 };
0627 
0628 struct sas_task_slow {
0629     /* standard/extra infrastructure for slow path commands (SMP and
0630      * internal lldd commands
0631      */
0632     struct timer_list     timer;
0633     struct completion     completion;
0634     struct sas_task       *task;
0635 };
0636 
0637 #define SAS_TASK_STATE_PENDING      1
0638 #define SAS_TASK_STATE_DONE         2
0639 #define SAS_TASK_STATE_ABORTED      4
0640 #define SAS_TASK_NEED_DEV_RESET     8
0641 
0642 extern struct sas_task *sas_alloc_task(gfp_t flags);
0643 extern struct sas_task *sas_alloc_slow_task(gfp_t flags);
0644 extern void sas_free_task(struct sas_task *task);
0645 
0646 static inline bool sas_is_internal_abort(struct sas_task *task)
0647 {
0648     return task->task_proto == SAS_PROTOCOL_INTERNAL_ABORT;
0649 }
0650 
0651 struct sas_domain_function_template {
0652     /* The class calls these to notify the LLDD of an event. */
0653     void (*lldd_port_formed)(struct asd_sas_phy *);
0654     void (*lldd_port_deformed)(struct asd_sas_phy *);
0655 
0656     /* The class calls these when a device is found or gone. */
0657     int  (*lldd_dev_found)(struct domain_device *);
0658     void (*lldd_dev_gone)(struct domain_device *);
0659 
0660     int (*lldd_execute_task)(struct sas_task *, gfp_t gfp_flags);
0661 
0662     /* Task Management Functions. Must be called from process context. */
0663     int (*lldd_abort_task)(struct sas_task *);
0664     int (*lldd_abort_task_set)(struct domain_device *, u8 *lun);
0665     int (*lldd_clear_task_set)(struct domain_device *, u8 *lun);
0666     int (*lldd_I_T_nexus_reset)(struct domain_device *);
0667     int (*lldd_ata_check_ready)(struct domain_device *);
0668     void (*lldd_ata_set_dmamode)(struct domain_device *);
0669     int (*lldd_lu_reset)(struct domain_device *, u8 *lun);
0670     int (*lldd_query_task)(struct sas_task *);
0671 
0672     /* Special TMF callbacks */
0673     void (*lldd_tmf_exec_complete)(struct domain_device *dev);
0674     void (*lldd_tmf_aborted)(struct sas_task *task);
0675     bool (*lldd_abort_timeout)(struct sas_task *task, void *data);
0676 
0677     /* Port and Adapter management */
0678     int (*lldd_clear_nexus_port)(struct asd_sas_port *);
0679     int (*lldd_clear_nexus_ha)(struct sas_ha_struct *);
0680 
0681     /* Phy management */
0682     int (*lldd_control_phy)(struct asd_sas_phy *, enum phy_func, void *);
0683 
0684     /* GPIO support */
0685     int (*lldd_write_gpio)(struct sas_ha_struct *, u8 reg_type,
0686                    u8 reg_index, u8 reg_count, u8 *write_data);
0687 };
0688 
0689 extern int sas_register_ha(struct sas_ha_struct *);
0690 extern int sas_unregister_ha(struct sas_ha_struct *);
0691 extern void sas_prep_resume_ha(struct sas_ha_struct *sas_ha);
0692 extern void sas_resume_ha(struct sas_ha_struct *sas_ha);
0693 extern void sas_resume_ha_no_sync(struct sas_ha_struct *sas_ha);
0694 extern void sas_suspend_ha(struct sas_ha_struct *sas_ha);
0695 
0696 int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates);
0697 int sas_phy_reset(struct sas_phy *phy, int hard_reset);
0698 int sas_phy_enable(struct sas_phy *phy, int enable);
0699 extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
0700 extern int sas_target_alloc(struct scsi_target *);
0701 extern int sas_slave_configure(struct scsi_device *);
0702 extern int sas_change_queue_depth(struct scsi_device *, int new_depth);
0703 extern int sas_bios_param(struct scsi_device *, struct block_device *,
0704               sector_t capacity, int *hsc);
0705 int sas_execute_internal_abort_single(struct domain_device *device,
0706                       u16 tag, unsigned int qid,
0707                       void *data);
0708 int sas_execute_internal_abort_dev(struct domain_device *device,
0709                    unsigned int qid, void *data);
0710 extern struct scsi_transport_template *
0711 sas_domain_attach_transport(struct sas_domain_function_template *);
0712 extern struct device_attribute dev_attr_phy_event_threshold;
0713 
0714 int  sas_discover_root_expander(struct domain_device *);
0715 
0716 void sas_init_ex_attr(void);
0717 
0718 int  sas_ex_revalidate_domain(struct domain_device *);
0719 
0720 void sas_unregister_domain_devices(struct asd_sas_port *port, int gone);
0721 void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *);
0722 void sas_discover_event(struct asd_sas_port *, enum discover_event ev);
0723 
0724 int  sas_discover_sata(struct domain_device *);
0725 int  sas_discover_end_dev(struct domain_device *);
0726 
0727 void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *);
0728 
0729 void sas_init_dev(struct domain_device *);
0730 
0731 void sas_task_abort(struct sas_task *);
0732 int sas_eh_abort_handler(struct scsi_cmnd *cmd);
0733 int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
0734 int sas_eh_target_reset_handler(struct scsi_cmnd *cmd);
0735 
0736 extern void sas_target_destroy(struct scsi_target *);
0737 extern int sas_slave_alloc(struct scsi_device *);
0738 extern int sas_ioctl(struct scsi_device *sdev, unsigned int cmd,
0739              void __user *arg);
0740 extern int sas_drain_work(struct sas_ha_struct *ha);
0741 
0742 extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
0743                   struct ssp_response_iu *iu);
0744 struct sas_phy *sas_get_local_phy(struct domain_device *dev);
0745 
0746 int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
0747 
0748 int sas_abort_task_set(struct domain_device *dev, u8 *lun);
0749 int sas_clear_task_set(struct domain_device *dev, u8 *lun);
0750 int sas_lu_reset(struct domain_device *dev, u8 *lun);
0751 int sas_query_task(struct sas_task *task, u16 tag);
0752 int sas_abort_task(struct sas_task *task, u16 tag);
0753 
0754 void sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event,
0755                gfp_t gfp_flags);
0756 void sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event,
0757                gfp_t gfp_flags);
0758 
0759 #endif /* _SASLIB_H_ */