blob: 85d731746834d258e002c51db293457fc0a52ece [file] [log] [blame]
Chandra Seetharamana6a8d9f2008-05-01 14:49:46 -07001/*
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
26#include <scsi/scsi_device.h>
27
28enum {
29 SCSI_DH_OK = 0,
30 /*
31 * device errors
32 */
33 SCSI_DH_DEV_FAILED, /* generic device error */
34 SCSI_DH_DEV_TEMP_BUSY,
Hannes Reineckeb6ff1b12008-07-17 16:53:03 -070035 SCSI_DH_DEV_UNSUPP, /* device handler not supported */
Chandra Seetharamana6a8d9f2008-05-01 14:49:46 -070036 SCSI_DH_DEVICE_MAX, /* max device blkerr definition */
37
38 /*
39 * transport errors
40 */
41 SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1,
42 SCSI_DH_CONN_FAILURE,
43 SCSI_DH_TRANSPORT_MAX, /* max transport blkerr definition */
44
45 /*
46 * driver and generic errors
47 */
48 SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1, /* generic error */
49 SCSI_DH_INVALID_IO,
50 SCSI_DH_RETRY, /* retry the req, but not immediately */
51 SCSI_DH_IMM_RETRY, /* immediately retry the req */
52 SCSI_DH_TIMED_OUT,
53 SCSI_DH_RES_TEMP_UNAVAIL,
54 SCSI_DH_DEV_OFFLINED,
55 SCSI_DH_NOSYS,
56 SCSI_DH_DRIVER_MAX,
57};
Christoph Hellwigee14c672015-08-27 14:16:59 +020058
59typedef void (*activate_complete)(void *, int);
60struct scsi_device_handler {
61 /* Used by the infrastructure */
62 struct list_head list; /* list of scsi_device_handlers */
63
64 /* Filled by the hardware handler */
65 struct module *module;
66 const char *name;
67 int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
68 int (*attach)(struct scsi_device *);
69 void (*detach)(struct scsi_device *);
70 int (*activate)(struct scsi_device *, activate_complete, void *);
71 int (*prep_fn)(struct scsi_device *, struct request *);
72 int (*set_params)(struct scsi_device *, const char *);
73};
74
Christoph Hellwig086b91d2015-08-27 14:16:57 +020075#ifdef CONFIG_SCSI_DH
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070076extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
Hannes Reineckeae11b1b2008-07-17 17:49:02 -070077extern int scsi_dh_attach(struct request_queue *, const char *);
Mike Snitzer7e8a74b2012-06-26 14:32:03 -040078extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
Chandra Seetharaman18ee70c2009-08-03 12:42:33 -070079extern int scsi_dh_set_params(struct request_queue *, const char *);
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070080#else
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070081static inline int scsi_dh_activate(struct request_queue *req,
82 activate_complete fn, void *data)
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070083{
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070084 fn(data, 0);
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070085 return 0;
86}
Hannes Reineckeae11b1b2008-07-17 17:49:02 -070087static inline int scsi_dh_attach(struct request_queue *req, const char *name)
88{
89 return SCSI_DH_NOSYS;
90}
Mike Snitzer7e8a74b2012-06-26 14:32:03 -040091static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
92 gfp_t gfp)
93{
94 return NULL;
95}
Chandra Seetharaman18ee70c2009-08-03 12:42:33 -070096static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
97{
98 return -SCSI_DH_NOSYS;
99}
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -0700100#endif