blob: 4df943c1b90b333ebea77493706e5908fa3f745a [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Chandra Seetharamana6a8d9f2008-05-01 14:49:46 -07002/*
Bhaskar Chowdhuryae98ddf02021-03-22 12:17:24 +05303 * Header file for SCSI device handler infrastructure.
Chandra Seetharamana6a8d9f2008-05-01 14:49:46 -07004 *
5 * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu>
6 *
Chandra Seetharamana6a8d9f2008-05-01 14:49:46 -07007 * Copyright IBM Corporation, 2007
8 * Authors:
9 * Chandra Seetharaman <sekharan@us.ibm.com>
10 * Mike Anderson <andmike@linux.vnet.ibm.com>
11 */
12
13#include <scsi/scsi_device.h>
14
15enum {
16 SCSI_DH_OK = 0,
17 /*
18 * device errors
19 */
20 SCSI_DH_DEV_FAILED, /* generic device error */
21 SCSI_DH_DEV_TEMP_BUSY,
Hannes Reineckeb6ff1b12008-07-17 16:53:03 -070022 SCSI_DH_DEV_UNSUPP, /* device handler not supported */
Chandra Seetharamana6a8d9f2008-05-01 14:49:46 -070023 SCSI_DH_DEVICE_MAX, /* max device blkerr definition */
24
25 /*
26 * transport errors
27 */
28 SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1,
29 SCSI_DH_CONN_FAILURE,
30 SCSI_DH_TRANSPORT_MAX, /* max transport blkerr definition */
31
32 /*
33 * driver and generic errors
34 */
35 SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1, /* generic error */
36 SCSI_DH_INVALID_IO,
37 SCSI_DH_RETRY, /* retry the req, but not immediately */
38 SCSI_DH_IMM_RETRY, /* immediately retry the req */
39 SCSI_DH_TIMED_OUT,
40 SCSI_DH_RES_TEMP_UNAVAIL,
41 SCSI_DH_DEV_OFFLINED,
Hannes Reinecke43394c62016-02-19 09:17:04 +010042 SCSI_DH_NOMEM,
Chandra Seetharamana6a8d9f2008-05-01 14:49:46 -070043 SCSI_DH_NOSYS,
44 SCSI_DH_DRIVER_MAX,
45};
Christoph Hellwigee14c672015-08-27 14:16:59 +020046
47typedef void (*activate_complete)(void *, int);
48struct scsi_device_handler {
49 /* Used by the infrastructure */
50 struct list_head list; /* list of scsi_device_handlers */
51
52 /* Filled by the hardware handler */
53 struct module *module;
54 const char *name;
Bart Van Asscheb8e162f2021-04-15 15:08:11 -070055 enum scsi_disposition (*check_sense)(struct scsi_device *,
56 struct scsi_sense_hdr *);
Christoph Hellwigee14c672015-08-27 14:16:59 +020057 int (*attach)(struct scsi_device *);
58 void (*detach)(struct scsi_device *);
59 int (*activate)(struct scsi_device *, activate_complete, void *);
Christoph Hellwig4c1cb672018-11-09 14:42:40 +010060 blk_status_t (*prep_fn)(struct scsi_device *, struct request *);
Christoph Hellwigee14c672015-08-27 14:16:59 +020061 int (*set_params)(struct scsi_device *, const char *);
Hannes Reinecked3d32892016-02-19 09:17:16 +010062 void (*rescan)(struct scsi_device *);
Christoph Hellwigee14c672015-08-27 14:16:59 +020063};
64
Christoph Hellwig086b91d2015-08-27 14:16:57 +020065#ifdef CONFIG_SCSI_DH
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070066extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
Hannes Reineckeae11b1b2008-07-17 17:49:02 -070067extern int scsi_dh_attach(struct request_queue *, const char *);
Mike Snitzer7e8a74b2012-06-26 14:32:03 -040068extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
Chandra Seetharaman18ee70c2009-08-03 12:42:33 -070069extern int scsi_dh_set_params(struct request_queue *, const char *);
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070070#else
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070071static inline int scsi_dh_activate(struct request_queue *req,
72 activate_complete fn, void *data)
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070073{
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070074 fn(data, 0);
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070075 return 0;
76}
Hannes Reineckeae11b1b2008-07-17 17:49:02 -070077static inline int scsi_dh_attach(struct request_queue *req, const char *name)
78{
79 return SCSI_DH_NOSYS;
80}
Mike Snitzer7e8a74b2012-06-26 14:32:03 -040081static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
82 gfp_t gfp)
83{
84 return NULL;
85}
Chandra Seetharaman18ee70c2009-08-03 12:42:33 -070086static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
87{
88 return -SCSI_DH_NOSYS;
89}
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070090#endif