libsas.h 19 KB

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