scsi_dh.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Header file for SCSI device handler infrastruture.
  4. *
  5. * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu>
  6. *
  7. * Copyright IBM Corporation, 2007
  8. * Authors:
  9. * Chandra Seetharaman <sekharan@us.ibm.com>
  10. * Mike Anderson <andmike@linux.vnet.ibm.com>
  11. */
  12. #include <scsi/scsi_device.h>
  13. enum {
  14. SCSI_DH_OK = 0,
  15. /*
  16. * device errors
  17. */
  18. SCSI_DH_DEV_FAILED, /* generic device error */
  19. SCSI_DH_DEV_TEMP_BUSY,
  20. SCSI_DH_DEV_UNSUPP, /* device handler not supported */
  21. SCSI_DH_DEVICE_MAX, /* max device blkerr definition */
  22. /*
  23. * transport errors
  24. */
  25. SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1,
  26. SCSI_DH_CONN_FAILURE,
  27. SCSI_DH_TRANSPORT_MAX, /* max transport blkerr definition */
  28. /*
  29. * driver and generic errors
  30. */
  31. SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1, /* generic error */
  32. SCSI_DH_INVALID_IO,
  33. SCSI_DH_RETRY, /* retry the req, but not immediately */
  34. SCSI_DH_IMM_RETRY, /* immediately retry the req */
  35. SCSI_DH_TIMED_OUT,
  36. SCSI_DH_RES_TEMP_UNAVAIL,
  37. SCSI_DH_DEV_OFFLINED,
  38. SCSI_DH_NOMEM,
  39. SCSI_DH_NOSYS,
  40. SCSI_DH_DRIVER_MAX,
  41. };
  42. typedef void (*activate_complete)(void *, int);
  43. struct scsi_device_handler {
  44. /* Used by the infrastructure */
  45. struct list_head list; /* list of scsi_device_handlers */
  46. /* Filled by the hardware handler */
  47. struct module *module;
  48. const char *name;
  49. int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
  50. int (*attach)(struct scsi_device *);
  51. void (*detach)(struct scsi_device *);
  52. int (*activate)(struct scsi_device *, activate_complete, void *);
  53. blk_status_t (*prep_fn)(struct scsi_device *, struct request *);
  54. int (*set_params)(struct scsi_device *, const char *);
  55. void (*rescan)(struct scsi_device *);
  56. };
  57. #ifdef CONFIG_SCSI_DH
  58. extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
  59. extern int scsi_dh_attach(struct request_queue *, const char *);
  60. extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
  61. extern int scsi_dh_set_params(struct request_queue *, const char *);
  62. #else
  63. static inline int scsi_dh_activate(struct request_queue *req,
  64. activate_complete fn, void *data)
  65. {
  66. fn(data, 0);
  67. return 0;
  68. }
  69. static inline int scsi_dh_attach(struct request_queue *req, const char *name)
  70. {
  71. return SCSI_DH_NOSYS;
  72. }
  73. static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
  74. gfp_t gfp)
  75. {
  76. return NULL;
  77. }
  78. static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
  79. {
  80. return -SCSI_DH_NOSYS;
  81. }
  82. #endif