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