libsas.h 19 KB

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