scsi_priv.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #ifndef _SCSI_PRIV_H
  2. #define _SCSI_PRIV_H
  3. #include <linux/device.h>
  4. #include <linux/async.h>
  5. #include <scsi/scsi_device.h>
  6. struct request_queue;
  7. struct request;
  8. struct scsi_cmnd;
  9. struct scsi_device;
  10. struct scsi_target;
  11. struct scsi_host_template;
  12. struct Scsi_Host;
  13. struct scsi_nl_hdr;
  14. /*
  15. * Scsi Error Handler Flags
  16. */
  17. #define SCSI_EH_CANCEL_CMD 0x0001 /* Cancel this cmd */
  18. #define SCSI_EH_ABORT_SCHEDULED 0x0002 /* Abort has been scheduled */
  19. #define SCSI_SENSE_VALID(scmd) \
  20. (((scmd)->sense_buffer[0] & 0x70) == 0x70)
  21. /* hosts.c */
  22. extern int scsi_init_hosts(void);
  23. extern void scsi_exit_hosts(void);
  24. /* scsi.c */
  25. extern bool scsi_use_blk_mq;
  26. extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
  27. extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
  28. #ifdef CONFIG_SCSI_LOGGING
  29. void scsi_log_send(struct scsi_cmnd *cmd);
  30. void scsi_log_completion(struct scsi_cmnd *cmd, int disposition);
  31. #else
  32. static inline void scsi_log_send(struct scsi_cmnd *cmd)
  33. { };
  34. static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
  35. { };
  36. #endif
  37. /* scsi_devinfo.c */
  38. /* list of keys for the lists */
  39. enum {
  40. SCSI_DEVINFO_GLOBAL = 0,
  41. SCSI_DEVINFO_SPI,
  42. };
  43. extern int scsi_get_device_flags(struct scsi_device *sdev,
  44. const unsigned char *vendor,
  45. const unsigned char *model);
  46. extern int scsi_get_device_flags_keyed(struct scsi_device *sdev,
  47. const unsigned char *vendor,
  48. const unsigned char *model, int key);
  49. extern int scsi_dev_info_list_add_keyed(int compatible, char *vendor,
  50. char *model, char *strflags,
  51. int flags, int key);
  52. extern int scsi_dev_info_list_del_keyed(char *vendor, char *model, int key);
  53. extern int scsi_dev_info_add_list(int key, const char *name);
  54. extern int scsi_dev_info_remove_list(int key);
  55. extern int __init scsi_init_devinfo(void);
  56. extern void scsi_exit_devinfo(void);
  57. /* scsi_error.c */
  58. extern void scmd_eh_abort_handler(struct work_struct *work);
  59. extern enum blk_eh_timer_return scsi_times_out(struct request *req);
  60. extern int scsi_error_handler(void *host);
  61. extern int scsi_decide_disposition(struct scsi_cmnd *cmd);
  62. extern void scsi_eh_wakeup(struct Scsi_Host *shost);
  63. extern int scsi_eh_scmd_add(struct scsi_cmnd *, int);
  64. void scsi_eh_ready_devs(struct Scsi_Host *shost,
  65. struct list_head *work_q,
  66. struct list_head *done_q);
  67. int scsi_eh_get_sense(struct list_head *work_q,
  68. struct list_head *done_q);
  69. int scsi_noretry_cmd(struct scsi_cmnd *scmd);
  70. /* scsi_lib.c */
  71. extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
  72. extern void scsi_device_unbusy(struct scsi_device *sdev);
  73. extern void scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
  74. extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
  75. extern void scsi_run_host_queues(struct Scsi_Host *shost);
  76. extern void scsi_requeue_run_queue(struct work_struct *work);
  77. extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
  78. extern struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev);
  79. extern int scsi_mq_setup_tags(struct Scsi_Host *shost);
  80. extern void scsi_mq_destroy_tags(struct Scsi_Host *shost);
  81. extern int scsi_init_queue(void);
  82. extern void scsi_exit_queue(void);
  83. extern void scsi_evt_thread(struct work_struct *work);
  84. struct request_queue;
  85. struct request;
  86. extern struct kmem_cache *scsi_sdb_cache;
  87. /* scsi_proc.c */
  88. #ifdef CONFIG_SCSI_PROC_FS
  89. extern void scsi_proc_hostdir_add(struct scsi_host_template *);
  90. extern void scsi_proc_hostdir_rm(struct scsi_host_template *);
  91. extern void scsi_proc_host_add(struct Scsi_Host *);
  92. extern void scsi_proc_host_rm(struct Scsi_Host *);
  93. extern int scsi_init_procfs(void);
  94. extern void scsi_exit_procfs(void);
  95. #else
  96. # define scsi_proc_hostdir_add(sht) do { } while (0)
  97. # define scsi_proc_hostdir_rm(sht) do { } while (0)
  98. # define scsi_proc_host_add(shost) do { } while (0)
  99. # define scsi_proc_host_rm(shost) do { } while (0)
  100. # define scsi_init_procfs() (0)
  101. # define scsi_exit_procfs() do { } while (0)
  102. #endif /* CONFIG_PROC_FS */
  103. /* scsi_scan.c */
  104. extern char scsi_scan_type[];
  105. extern int scsi_complete_async_scans(void);
  106. extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
  107. unsigned int, u64, enum scsi_scan_mode);
  108. extern void scsi_forget_host(struct Scsi_Host *);
  109. extern void scsi_rescan_device(struct device *);
  110. /* scsi_sysctl.c */
  111. #ifdef CONFIG_SYSCTL
  112. extern int scsi_init_sysctl(void);
  113. extern void scsi_exit_sysctl(void);
  114. #else
  115. # define scsi_init_sysctl() (0)
  116. # define scsi_exit_sysctl() do { } while (0)
  117. #endif /* CONFIG_SYSCTL */
  118. /* scsi_sysfs.c */
  119. extern int scsi_sysfs_add_sdev(struct scsi_device *);
  120. extern int scsi_sysfs_add_host(struct Scsi_Host *);
  121. extern int scsi_sysfs_register(void);
  122. extern void scsi_sysfs_unregister(void);
  123. extern void scsi_sysfs_device_initialize(struct scsi_device *);
  124. extern int scsi_sysfs_target_initialize(struct scsi_device *);
  125. extern struct scsi_transport_template blank_transport_template;
  126. extern void __scsi_remove_device(struct scsi_device *);
  127. extern struct bus_type scsi_bus_type;
  128. extern const struct attribute_group *scsi_sysfs_shost_attr_groups[];
  129. /* scsi_netlink.c */
  130. #ifdef CONFIG_SCSI_NETLINK
  131. extern void scsi_netlink_init(void);
  132. extern void scsi_netlink_exit(void);
  133. extern struct sock *scsi_nl_sock;
  134. #else
  135. static inline void scsi_netlink_init(void) {}
  136. static inline void scsi_netlink_exit(void) {}
  137. #endif
  138. /* scsi_pm.c */
  139. #ifdef CONFIG_PM
  140. extern const struct dev_pm_ops scsi_bus_pm_ops;
  141. extern void scsi_autopm_get_target(struct scsi_target *);
  142. extern void scsi_autopm_put_target(struct scsi_target *);
  143. extern int scsi_autopm_get_host(struct Scsi_Host *);
  144. extern void scsi_autopm_put_host(struct Scsi_Host *);
  145. #else
  146. static inline void scsi_autopm_get_target(struct scsi_target *t) {}
  147. static inline void scsi_autopm_put_target(struct scsi_target *t) {}
  148. static inline int scsi_autopm_get_host(struct Scsi_Host *h) { return 0; }
  149. static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
  150. #endif /* CONFIG_PM */
  151. extern struct async_domain scsi_sd_pm_domain;
  152. extern struct async_domain scsi_sd_probe_domain;
  153. /* scsi_dh.c */
  154. #ifdef CONFIG_SCSI_DH
  155. int scsi_dh_add_device(struct scsi_device *sdev);
  156. void scsi_dh_release_device(struct scsi_device *sdev);
  157. #else
  158. static inline int scsi_dh_add_device(struct scsi_device *sdev) { return 0; }
  159. static inline void scsi_dh_release_device(struct scsi_device *sdev) { }
  160. #endif
  161. static inline void scsi_dh_remove_device(struct scsi_device *sdev) { }
  162. /*
  163. * internal scsi timeout functions: for use by mid-layer and transport
  164. * classes.
  165. */
  166. #define SCSI_DEVICE_BLOCK_MAX_TIMEOUT 600 /* units in seconds */
  167. extern int scsi_internal_device_block(struct scsi_device *sdev);
  168. extern int scsi_internal_device_unblock(struct scsi_device *sdev,
  169. enum scsi_device_state new_state);
  170. #endif /* _SCSI_PRIV_H */