scsi_priv.h 6.1 KB

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