libsas.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  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 bool dev_parent_is_expander(struct domain_device *dev)
  161. {
  162. if (!dev->parent)
  163. return false;
  164. return dev_is_expander(dev->parent->dev_type);
  165. }
  166. static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *))
  167. {
  168. INIT_WORK(&sw->work, fn);
  169. INIT_LIST_HEAD(&sw->drain_node);
  170. }
  171. struct sas_discovery_event {
  172. struct sas_work work;
  173. struct asd_sas_port *port;
  174. };
  175. static inline struct sas_discovery_event *to_sas_discovery_event(struct work_struct *work)
  176. {
  177. struct sas_discovery_event *ev = container_of(work, typeof(*ev), work.work);
  178. return ev;
  179. }
  180. struct sas_discovery {
  181. struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
  182. unsigned long pending;
  183. u8 fanout_sas_addr[SAS_ADDR_SIZE];
  184. u8 eeds_a[SAS_ADDR_SIZE];
  185. u8 eeds_b[SAS_ADDR_SIZE];
  186. int max_level;
  187. };
  188. /* The port struct is Class:RW, driver:RO */
  189. struct asd_sas_port {
  190. /* private: */
  191. struct sas_discovery disc;
  192. struct domain_device *port_dev;
  193. spinlock_t dev_list_lock;
  194. struct list_head dev_list;
  195. struct list_head disco_list;
  196. struct list_head destroy_list;
  197. struct list_head sas_port_del_list;
  198. enum sas_linkrate linkrate;
  199. struct sas_work work;
  200. int suspended;
  201. /* public: */
  202. int id;
  203. u8 sas_addr[SAS_ADDR_SIZE];
  204. u8 attached_sas_addr[SAS_ADDR_SIZE];
  205. enum sas_protocol iproto;
  206. enum sas_protocol tproto;
  207. enum sas_oob_mode oob_mode;
  208. spinlock_t phy_list_lock;
  209. struct list_head phy_list;
  210. int num_phys;
  211. u32 phy_mask;
  212. struct sas_ha_struct *ha;
  213. struct sas_port *port;
  214. void *lldd_port; /* not touched by the sas class code */
  215. };
  216. struct asd_sas_event {
  217. struct sas_work work;
  218. struct asd_sas_phy *phy;
  219. int event;
  220. };
  221. static inline struct asd_sas_event *to_asd_sas_event(struct work_struct *work)
  222. {
  223. struct asd_sas_event *ev = container_of(work, typeof(*ev), work.work);
  224. return ev;
  225. }
  226. static inline void INIT_SAS_EVENT(struct asd_sas_event *ev,
  227. void (*fn)(struct work_struct *),
  228. struct asd_sas_phy *phy, int event)
  229. {
  230. INIT_SAS_WORK(&ev->work, fn);
  231. ev->phy = phy;
  232. ev->event = event;
  233. }
  234. #define SAS_PHY_SHUTDOWN_THRES 1024
  235. /* The phy pretty much is controlled by the LLDD.
  236. * The class only reads those fields.
  237. */
  238. struct asd_sas_phy {
  239. /* private: */
  240. atomic_t event_nr;
  241. int in_shutdown;
  242. int error;
  243. int suspended;
  244. struct sas_phy *phy;
  245. /* public: */
  246. /* The following are class:RO, driver:R/W */
  247. int enabled; /* must be set */
  248. int id; /* must be set */
  249. enum sas_protocol iproto;
  250. enum sas_protocol tproto;
  251. enum sas_phy_role role;
  252. enum sas_oob_mode oob_mode;
  253. enum sas_linkrate linkrate;
  254. u8 *sas_addr; /* must be set */
  255. u8 attached_sas_addr[SAS_ADDR_SIZE]; /* class:RO, driver: R/W */
  256. spinlock_t frame_rcvd_lock;
  257. u8 *frame_rcvd; /* must be set */
  258. int frame_rcvd_size;
  259. spinlock_t sas_prim_lock;
  260. u32 sas_prim;
  261. struct list_head port_phy_el; /* driver:RO */
  262. struct asd_sas_port *port; /* Class:RW, driver: RO */
  263. struct sas_ha_struct *ha; /* may be set; the class sets it anyway */
  264. void *lldd_phy; /* not touched by the sas_class_code */
  265. };
  266. enum sas_ha_state {
  267. SAS_HA_REGISTERED,
  268. SAS_HA_DRAINING,
  269. SAS_HA_ATA_EH_ACTIVE,
  270. SAS_HA_FROZEN,
  271. SAS_HA_RESUMING,
  272. };
  273. struct sas_ha_struct {
  274. /* private: */
  275. struct list_head defer_q; /* work queued while draining */
  276. struct mutex drain_mutex;
  277. unsigned long state;
  278. spinlock_t lock;
  279. int eh_active;
  280. wait_queue_head_t eh_wait_q;
  281. struct list_head eh_dev_q;
  282. struct mutex disco_mutex;
  283. struct Scsi_Host *shost;
  284. /* public: */
  285. char *sas_ha_name;
  286. struct device *dev; /* should be set */
  287. struct workqueue_struct *event_q;
  288. struct workqueue_struct *disco_q;
  289. u8 *sas_addr; /* must be set */
  290. u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE];
  291. spinlock_t phy_port_lock;
  292. struct asd_sas_phy **sas_phy; /* array of valid pointers, must be set */
  293. struct asd_sas_port **sas_port; /* array of valid pointers, must be set */
  294. int num_phys; /* must be set, gt 0, static */
  295. int strict_wide_ports; /* both sas_addr and attached_sas_addr must match
  296. * their siblings when forming wide ports */
  297. void *lldd_ha; /* not touched by sas class code */
  298. struct list_head eh_done_q; /* complete via scsi_eh_flush_done_q */
  299. struct list_head eh_ata_q; /* scmds to promote from sas to ata eh */
  300. int event_thres;
  301. };
  302. #define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata)
  303. static inline struct domain_device *
  304. starget_to_domain_dev(struct scsi_target *starget) {
  305. return starget->hostdata;
  306. }
  307. static inline struct domain_device *
  308. sdev_to_domain_dev(struct scsi_device *sdev) {
  309. return starget_to_domain_dev(sdev->sdev_target);
  310. }
  311. static inline struct ata_device *sas_to_ata_dev(struct domain_device *dev)
  312. {
  313. return &dev->sata_dev.ap->link.device[0];
  314. }
  315. static inline struct domain_device *
  316. cmd_to_domain_dev(struct scsi_cmnd *cmd)
  317. {
  318. return sdev_to_domain_dev(cmd->device);
  319. }
  320. /* Before calling a notify event, LLDD should use this function
  321. * when the link is severed (possibly from its tasklet).
  322. * The idea is that the Class only reads those, while the LLDD,
  323. * can R/W these (thus avoiding a race).
  324. */
  325. static inline void sas_phy_disconnected(struct asd_sas_phy *phy)
  326. {
  327. phy->oob_mode = OOB_NOT_CONNECTED;
  328. phy->linkrate = SAS_LINK_RATE_UNKNOWN;
  329. }
  330. static inline unsigned int to_sas_gpio_od(int device, int bit)
  331. {
  332. return 3 * device + bit;
  333. }
  334. static inline void sas_put_local_phy(struct sas_phy *phy)
  335. {
  336. put_device(&phy->dev);
  337. }
  338. #ifdef CONFIG_SCSI_SAS_HOST_SMP
  339. int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count);
  340. #else
  341. static inline int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count)
  342. {
  343. return -1;
  344. }
  345. #endif
  346. /* ---------- Tasks ---------- */
  347. /*
  348. service_response | SAS_TASK_COMPLETE | SAS_TASK_UNDELIVERED |
  349. exec_status | | |
  350. ---------------------+---------------------+-----------------------+
  351. SAM_... | X | |
  352. DEV_NO_RESPONSE | X | X |
  353. INTERRUPTED | X | |
  354. QUEUE_FULL | | X |
  355. DEVICE_UNKNOWN | | X |
  356. SG_ERR | | X |
  357. ---------------------+---------------------+-----------------------+
  358. */
  359. enum service_response {
  360. SAS_TASK_COMPLETE,
  361. SAS_TASK_UNDELIVERED = -1,
  362. };
  363. enum exec_status {
  364. /*
  365. * Values 0..0x7f are used to return the SAM_STAT_* codes. To avoid
  366. * 'case value not in enumerated type' compiler warnings every value
  367. * returned through the exec_status enum needs an alias with the SAS_
  368. * prefix here.
  369. */
  370. SAS_SAM_STAT_GOOD = SAM_STAT_GOOD,
  371. SAS_SAM_STAT_BUSY = SAM_STAT_BUSY,
  372. SAS_SAM_STAT_TASK_ABORTED = SAM_STAT_TASK_ABORTED,
  373. SAS_SAM_STAT_CHECK_CONDITION = SAM_STAT_CHECK_CONDITION,
  374. SAS_DEV_NO_RESPONSE = 0x80,
  375. SAS_DATA_UNDERRUN,
  376. SAS_DATA_OVERRUN,
  377. SAS_INTERRUPTED,
  378. SAS_QUEUE_FULL,
  379. SAS_DEVICE_UNKNOWN,
  380. SAS_OPEN_REJECT,
  381. SAS_OPEN_TO,
  382. SAS_PROTO_RESPONSE,
  383. SAS_PHY_DOWN,
  384. SAS_NAK_R_ERR,
  385. SAS_PENDING,
  386. SAS_ABORTED_TASK,
  387. };
  388. /* When a task finishes with a response, the LLDD examines the
  389. * response:
  390. * - For an ATA task task_status_struct::stat is set to
  391. * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the
  392. * contents of struct ata_task_resp.
  393. * - For SSP tasks, if no data is present or status/TMF response
  394. * is valid, task_status_struct::stat is set. If data is present
  395. * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets
  396. * task_status_struct::buf_valid_size, and task_status_struct::stat is
  397. * set to SAM_CHECK_COND.
  398. *
  399. * "buf" has format SCSI Sense for SSP task, or struct ata_task_resp
  400. * for ATA task.
  401. *
  402. * "frame_len" is the total frame length, which could be more or less
  403. * than actually copied.
  404. *
  405. * Tasks ending with response, always set the residual field.
  406. */
  407. struct ata_task_resp {
  408. u16 frame_len;
  409. u8 ending_fis[ATA_RESP_FIS_SIZE]; /* dev to host or data-in */
  410. };
  411. #define SAS_STATUS_BUF_SIZE 96
  412. struct task_status_struct {
  413. enum service_response resp;
  414. enum exec_status stat;
  415. int buf_valid_size;
  416. u8 buf[SAS_STATUS_BUF_SIZE];
  417. u32 residual;
  418. enum sas_open_rej_reason open_rej_reason;
  419. };
  420. /* ATA and ATAPI task queuable to a SAS LLDD.
  421. */
  422. struct sas_ata_task {
  423. struct host_to_dev_fis fis;
  424. u8 atapi_packet[16]; /* 0 if not ATAPI task */
  425. u8 dma_xfer:1; /* PIO:0 or DMA:1 */
  426. u8 use_ncq:1;
  427. u8 return_fis_on_success:1;
  428. u8 device_control_reg_update:1;
  429. bool force_phy;
  430. int force_phy_id;
  431. };
  432. /* LLDDs rely on these values */
  433. enum sas_internal_abort {
  434. SAS_INTERNAL_ABORT_SINGLE = 0,
  435. SAS_INTERNAL_ABORT_DEV = 1,
  436. };
  437. struct sas_internal_abort_task {
  438. enum sas_internal_abort type;
  439. unsigned int qid;
  440. u16 tag;
  441. };
  442. struct sas_smp_task {
  443. struct scatterlist smp_req;
  444. struct scatterlist smp_resp;
  445. };
  446. enum task_attribute {
  447. TASK_ATTR_SIMPLE = 0,
  448. TASK_ATTR_HOQ = 1,
  449. TASK_ATTR_ORDERED= 2,
  450. TASK_ATTR_ACA = 4,
  451. };
  452. struct sas_ssp_task {
  453. u8 LUN[8];
  454. enum task_attribute task_attr;
  455. struct scsi_cmnd *cmd;
  456. };
  457. struct sas_tmf_task {
  458. u8 tmf;
  459. u16 tag_of_task_to_be_managed;
  460. };
  461. struct sas_task {
  462. struct domain_device *dev;
  463. spinlock_t task_state_lock;
  464. unsigned task_state_flags;
  465. enum sas_protocol task_proto;
  466. union {
  467. struct sas_ata_task ata_task;
  468. struct sas_smp_task smp_task;
  469. struct sas_ssp_task ssp_task;
  470. struct sas_internal_abort_task abort_task;
  471. };
  472. struct scatterlist *scatter;
  473. int num_scatter;
  474. u32 total_xfer_len;
  475. u8 data_dir:2; /* Use PCI_DMA_... */
  476. struct task_status_struct task_status;
  477. void (*task_done)(struct sas_task *);
  478. void *lldd_task; /* for use by LLDDs */
  479. void *uldd_task;
  480. struct sas_task_slow *slow_task;
  481. struct sas_tmf_task *tmf;
  482. };
  483. struct sas_task_slow {
  484. /* standard/extra infrastructure for slow path commands (SMP and
  485. * internal lldd commands
  486. */
  487. struct timer_list timer;
  488. struct completion completion;
  489. struct sas_task *task;
  490. };
  491. #define SAS_TASK_STATE_PENDING 1
  492. #define SAS_TASK_STATE_DONE 2
  493. #define SAS_TASK_STATE_ABORTED 4
  494. #define SAS_TASK_NEED_DEV_RESET 8
  495. static inline bool sas_is_internal_abort(struct sas_task *task)
  496. {
  497. return task->task_proto == SAS_PROTOCOL_INTERNAL_ABORT;
  498. }
  499. static inline struct request *sas_task_find_rq(struct sas_task *task)
  500. {
  501. struct scsi_cmnd *scmd;
  502. if (task->task_proto & SAS_PROTOCOL_STP_ALL) {
  503. struct ata_queued_cmd *qc = task->uldd_task;
  504. scmd = qc ? qc->scsicmd : NULL;
  505. } else {
  506. scmd = task->uldd_task;
  507. }
  508. if (!scmd)
  509. return NULL;
  510. return scsi_cmd_to_rq(scmd);
  511. }
  512. struct sas_domain_function_template {
  513. /* The class calls these to notify the LLDD of an event. */
  514. void (*lldd_port_formed)(struct asd_sas_phy *);
  515. void (*lldd_port_deformed)(struct asd_sas_phy *);
  516. /* The class calls these when a device is found or gone. */
  517. int (*lldd_dev_found)(struct domain_device *);
  518. void (*lldd_dev_gone)(struct domain_device *);
  519. int (*lldd_execute_task)(struct sas_task *, gfp_t gfp_flags);
  520. /* Task Management Functions. Must be called from process context. */
  521. int (*lldd_abort_task)(struct sas_task *);
  522. int (*lldd_abort_task_set)(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. /* Special TMF callbacks */
  530. void (*lldd_tmf_exec_complete)(struct domain_device *dev);
  531. void (*lldd_tmf_aborted)(struct sas_task *task);
  532. bool (*lldd_abort_timeout)(struct sas_task *task, void *data);
  533. /* Port and Adapter management */
  534. int (*lldd_clear_nexus_port)(struct asd_sas_port *);
  535. int (*lldd_clear_nexus_ha)(struct sas_ha_struct *);
  536. /* Phy management */
  537. int (*lldd_control_phy)(struct asd_sas_phy *, enum phy_func, void *);
  538. /* GPIO support */
  539. int (*lldd_write_gpio)(struct sas_ha_struct *, u8 reg_type,
  540. u8 reg_index, u8 reg_count, u8 *write_data);
  541. };
  542. extern int sas_register_ha(struct sas_ha_struct *);
  543. extern int sas_unregister_ha(struct sas_ha_struct *);
  544. extern void sas_prep_resume_ha(struct sas_ha_struct *sas_ha);
  545. extern void sas_resume_ha(struct sas_ha_struct *sas_ha);
  546. extern void sas_resume_ha_no_sync(struct sas_ha_struct *sas_ha);
  547. extern void sas_suspend_ha(struct sas_ha_struct *sas_ha);
  548. int sas_phy_reset(struct sas_phy *phy, int hard_reset);
  549. int sas_phy_enable(struct sas_phy *phy, int enable);
  550. extern enum scsi_qc_status sas_queuecommand(struct Scsi_Host *host,
  551. struct scsi_cmnd *cmd);
  552. extern int sas_target_alloc(struct scsi_target *);
  553. int sas_sdev_configure(struct scsi_device *dev, struct queue_limits *lim);
  554. extern int sas_change_queue_depth(struct scsi_device *, int new_depth);
  555. extern int sas_bios_param(struct scsi_device *, struct gendisk *,
  556. sector_t capacity, int *hsc);
  557. int sas_execute_internal_abort_single(struct domain_device *device,
  558. u16 tag, unsigned int qid,
  559. void *data);
  560. int sas_execute_internal_abort_dev(struct domain_device *device,
  561. unsigned int qid, void *data);
  562. extern struct scsi_transport_template *
  563. sas_domain_attach_transport(struct sas_domain_function_template *);
  564. extern struct device_attribute dev_attr_phy_event_threshold;
  565. void sas_task_abort(struct sas_task *);
  566. int sas_eh_abort_handler(struct scsi_cmnd *cmd);
  567. int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
  568. int sas_eh_target_reset_handler(struct scsi_cmnd *cmd);
  569. extern void sas_target_destroy(struct scsi_target *);
  570. extern int sas_sdev_init(struct scsi_device *);
  571. extern int sas_ioctl(struct scsi_device *sdev, unsigned int cmd,
  572. void __user *arg);
  573. extern int sas_drain_work(struct sas_ha_struct *ha);
  574. extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
  575. struct ssp_response_iu *iu);
  576. struct sas_phy *sas_get_local_phy(struct domain_device *dev);
  577. int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
  578. int sas_abort_task_set(struct domain_device *dev, u8 *lun);
  579. int sas_clear_task_set(struct domain_device *dev, u8 *lun);
  580. int sas_lu_reset(struct domain_device *dev, u8 *lun);
  581. int sas_query_task(struct sas_task *task, u16 tag);
  582. int sas_abort_task(struct sas_task *task, u16 tag);
  583. int sas_find_attached_phy_id(struct expander_device *ex_dev,
  584. struct domain_device *dev);
  585. void sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event,
  586. gfp_t gfp_flags);
  587. void sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event,
  588. gfp_t gfp_flags);
  589. #define __LIBSAS_SHT_BASE \
  590. .module = THIS_MODULE, \
  591. .name = DRV_NAME, \
  592. .proc_name = DRV_NAME, \
  593. .queuecommand = sas_queuecommand, \
  594. .dma_need_drain = ata_scsi_dma_need_drain, \
  595. .target_alloc = sas_target_alloc, \
  596. .change_queue_depth = sas_change_queue_depth, \
  597. .bios_param = sas_bios_param, \
  598. .this_id = -1, \
  599. .eh_device_reset_handler = sas_eh_device_reset_handler, \
  600. .eh_target_reset_handler = sas_eh_target_reset_handler, \
  601. .target_destroy = sas_target_destroy, \
  602. .ioctl = sas_ioctl, \
  603. #ifdef CONFIG_COMPAT
  604. #define _LIBSAS_SHT_BASE __LIBSAS_SHT_BASE \
  605. .compat_ioctl = sas_ioctl,
  606. #else
  607. #define _LIBSAS_SHT_BASE __LIBSAS_SHT_BASE
  608. #endif
  609. #define LIBSAS_SHT_BASE _LIBSAS_SHT_BASE \
  610. .sdev_configure = sas_sdev_configure, \
  611. .sdev_init = sas_sdev_init, \
  612. #define LIBSAS_SHT_BASE_NO_SLAVE_INIT _LIBSAS_SHT_BASE
  613. #endif /* _SASLIB_H_ */