blob: 2852e470a8edba3719e8758d2a0d3054b00cccae [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/*
3 * Header file for SCSI device handler infrastruture.
4 *
5 * Modified version of patches posted by Mike Christie <[email protected]>
6 *
Chandra Seetharamana6a8d9f2008-05-01 14:49:46 -07007 * Copyright IBM Corporation, 2007
8 * Authors:
9 * Chandra Seetharaman <[email protected]>
10 * Mike Anderson <[email protected]>
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;
55 int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
56 int (*attach)(struct scsi_device *);
57 void (*detach)(struct scsi_device *);
58 int (*activate)(struct scsi_device *, activate_complete, void *);
Christoph Hellwig4c1cb672018-11-09 14:42:40 +010059 blk_status_t (*prep_fn)(struct scsi_device *, struct request *);
Christoph Hellwigee14c672015-08-27 14:16:59 +020060 int (*set_params)(struct scsi_device *, const char *);
Hannes Reinecked3d32892016-02-19 09:17:16 +010061 void (*rescan)(struct scsi_device *);
Christoph Hellwigee14c672015-08-27 14:16:59 +020062};
63
Christoph Hellwig086b91d2015-08-27 14:16:57 +020064#ifdef CONFIG_SCSI_DH
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070065extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
Hannes Reineckeae11b1b2008-07-17 17:49:02 -070066extern int scsi_dh_attach(struct request_queue *, const char *);
Mike Snitzer7e8a74b2012-06-26 14:32:03 -040067extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
Chandra Seetharaman18ee70c2009-08-03 12:42:33 -070068extern int scsi_dh_set_params(struct request_queue *, const char *);
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070069#else
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070070static inline int scsi_dh_activate(struct request_queue *req,
71 activate_complete fn, void *data)
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070072{
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -070073 fn(data, 0);
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070074 return 0;
75}
Hannes Reineckeae11b1b2008-07-17 17:49:02 -070076static inline int scsi_dh_attach(struct request_queue *req, const char *name)
77{
78 return SCSI_DH_NOSYS;
79}
Mike Snitzer7e8a74b2012-06-26 14:32:03 -040080static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
81 gfp_t gfp)
82{
83 return NULL;
84}
Chandra Seetharaman18ee70c2009-08-03 12:42:33 -070085static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
86{
87 return -SCSI_DH_NOSYS;
88}
Chandra Seetharamanfe9233f2008-05-23 18:16:40 -070089#endif