scsi_dh.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Header file for SCSI device handler infrastruture.
  3. *
  4. * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. *
  20. * Copyright IBM Corporation, 2007
  21. * Authors:
  22. * Chandra Seetharaman <sekharan@us.ibm.com>
  23. * Mike Anderson <andmike@linux.vnet.ibm.com>
  24. */
  25. #include <scsi/scsi_device.h>
  26. enum {
  27. SCSI_DH_OK = 0,
  28. /*
  29. * device errors
  30. */
  31. SCSI_DH_DEV_FAILED, /* generic device error */
  32. SCSI_DH_DEV_TEMP_BUSY,
  33. SCSI_DH_DEV_UNSUPP, /* device handler not supported */
  34. SCSI_DH_DEVICE_MAX, /* max device blkerr definition */
  35. /*
  36. * transport errors
  37. */
  38. SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1,
  39. SCSI_DH_CONN_FAILURE,
  40. SCSI_DH_TRANSPORT_MAX, /* max transport blkerr definition */
  41. /*
  42. * driver and generic errors
  43. */
  44. SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1, /* generic error */
  45. SCSI_DH_INVALID_IO,
  46. SCSI_DH_RETRY, /* retry the req, but not immediately */
  47. SCSI_DH_IMM_RETRY, /* immediately retry the req */
  48. SCSI_DH_TIMED_OUT,
  49. SCSI_DH_RES_TEMP_UNAVAIL,
  50. SCSI_DH_DEV_OFFLINED,
  51. SCSI_DH_NOMEM,
  52. SCSI_DH_NOSYS,
  53. SCSI_DH_DRIVER_MAX,
  54. };
  55. typedef void (*activate_complete)(void *, int);
  56. struct scsi_device_handler {
  57. /* Used by the infrastructure */
  58. struct list_head list; /* list of scsi_device_handlers */
  59. /* Filled by the hardware handler */
  60. struct module *module;
  61. const char *name;
  62. int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
  63. int (*attach)(struct scsi_device *);
  64. void (*detach)(struct scsi_device *);
  65. int (*activate)(struct scsi_device *, activate_complete, void *);
  66. int (*prep_fn)(struct scsi_device *, struct request *);
  67. int (*set_params)(struct scsi_device *, const char *);
  68. void (*rescan)(struct scsi_device *);
  69. };
  70. #ifdef CONFIG_SCSI_DH
  71. extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
  72. extern int scsi_dh_attach(struct request_queue *, const char *);
  73. extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
  74. extern int scsi_dh_set_params(struct request_queue *, const char *);
  75. #else
  76. static inline int scsi_dh_activate(struct request_queue *req,
  77. activate_complete fn, void *data)
  78. {
  79. fn(data, 0);
  80. return 0;
  81. }
  82. static inline int scsi_dh_attach(struct request_queue *req, const char *name)
  83. {
  84. return SCSI_DH_NOSYS;
  85. }
  86. static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
  87. gfp_t gfp)
  88. {
  89. return NULL;
  90. }
  91. static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
  92. {
  93. return -SCSI_DH_NOSYS;
  94. }
  95. #endif