Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Header file for SCSI device handler infrastructure.
0004  *
0005  * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu>
0006  *
0007  * Copyright IBM Corporation, 2007
0008  *      Authors:
0009  *               Chandra Seetharaman <sekharan@us.ibm.com>
0010  *               Mike Anderson <andmike@linux.vnet.ibm.com>
0011  */
0012 
0013 #include <scsi/scsi_device.h>
0014 
0015 enum {
0016     SCSI_DH_OK = 0,
0017     /*
0018      * device errors
0019      */
0020     SCSI_DH_DEV_FAILED, /* generic device error */
0021     SCSI_DH_DEV_TEMP_BUSY,
0022     SCSI_DH_DEV_UNSUPP, /* device handler not supported */
0023     SCSI_DH_DEVICE_MAX, /* max device blkerr definition */
0024 
0025     /*
0026      * transport errors
0027      */
0028     SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1,
0029     SCSI_DH_CONN_FAILURE,
0030     SCSI_DH_TRANSPORT_MAX,  /* max transport blkerr definition */
0031 
0032     /*
0033      * driver and generic errors
0034      */
0035     SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1, /* generic error */
0036     SCSI_DH_INVALID_IO,
0037     SCSI_DH_RETRY,      /* retry the req, but not immediately */
0038     SCSI_DH_IMM_RETRY,  /* immediately retry the req */
0039     SCSI_DH_TIMED_OUT,
0040     SCSI_DH_RES_TEMP_UNAVAIL,
0041     SCSI_DH_DEV_OFFLINED,
0042     SCSI_DH_NOMEM,
0043     SCSI_DH_NOSYS,
0044     SCSI_DH_DRIVER_MAX,
0045 };
0046 
0047 typedef void (*activate_complete)(void *, int);
0048 struct scsi_device_handler {
0049     /* Used by the infrastructure */
0050     struct list_head list; /* list of scsi_device_handlers */
0051 
0052     /* Filled by the hardware handler */
0053     struct module *module;
0054     const char *name;
0055     enum scsi_disposition (*check_sense)(struct scsi_device *,
0056                          struct scsi_sense_hdr *);
0057     int (*attach)(struct scsi_device *);
0058     void (*detach)(struct scsi_device *);
0059     int (*activate)(struct scsi_device *, activate_complete, void *);
0060     blk_status_t (*prep_fn)(struct scsi_device *, struct request *);
0061     int (*set_params)(struct scsi_device *, const char *);
0062     void (*rescan)(struct scsi_device *);
0063 };
0064 
0065 #ifdef CONFIG_SCSI_DH
0066 extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
0067 extern int scsi_dh_attach(struct request_queue *, const char *);
0068 extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
0069 extern int scsi_dh_set_params(struct request_queue *, const char *);
0070 #else
0071 static inline int scsi_dh_activate(struct request_queue *req,
0072                     activate_complete fn, void *data)
0073 {
0074     fn(data, 0);
0075     return 0;
0076 }
0077 static inline int scsi_dh_attach(struct request_queue *req, const char *name)
0078 {
0079     return SCSI_DH_NOSYS;
0080 }
0081 static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
0082                             gfp_t gfp)
0083 {
0084     return NULL;
0085 }
0086 static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
0087 {
0088     return -SCSI_DH_NOSYS;
0089 }
0090 #endif