]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
a6a8d9f8 CS |
2 | /* |
3 | * Header file for SCSI device handler infrastruture. | |
4 | * | |
5 | * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu> | |
6 | * | |
a6a8d9f8 CS |
7 | * 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 | ||
15 | enum { | |
16 | SCSI_DH_OK = 0, | |
17 | /* | |
18 | * device errors | |
19 | */ | |
20 | SCSI_DH_DEV_FAILED, /* generic device error */ | |
21 | SCSI_DH_DEV_TEMP_BUSY, | |
b6ff1b14 | 22 | SCSI_DH_DEV_UNSUPP, /* device handler not supported */ |
a6a8d9f8 CS |
23 | 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, | |
43394c67 | 42 | SCSI_DH_NOMEM, |
a6a8d9f8 CS |
43 | SCSI_DH_NOSYS, |
44 | SCSI_DH_DRIVER_MAX, | |
45 | }; | |
ee14c674 CH |
46 | |
47 | typedef void (*activate_complete)(void *, int); | |
48 | struct 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 *); | |
4c1cb67c | 59 | blk_status_t (*prep_fn)(struct scsi_device *, struct request *); |
ee14c674 | 60 | int (*set_params)(struct scsi_device *, const char *); |
d3d32891 | 61 | void (*rescan)(struct scsi_device *); |
ee14c674 CH |
62 | }; |
63 | ||
086b91d0 | 64 | #ifdef CONFIG_SCSI_DH |
3ae31f6a | 65 | extern int scsi_dh_activate(struct request_queue *, activate_complete, void *); |
ae11b1b3 | 66 | extern int scsi_dh_attach(struct request_queue *, const char *); |
7e8a74b1 | 67 | extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t); |
18ee70c9 | 68 | extern int scsi_dh_set_params(struct request_queue *, const char *); |
fe9233fb | 69 | #else |
3ae31f6a CS |
70 | static inline int scsi_dh_activate(struct request_queue *req, |
71 | activate_complete fn, void *data) | |
fe9233fb | 72 | { |
3ae31f6a | 73 | fn(data, 0); |
fe9233fb CS |
74 | return 0; |
75 | } | |
ae11b1b3 HR |
76 | static inline int scsi_dh_attach(struct request_queue *req, const char *name) |
77 | { | |
78 | return SCSI_DH_NOSYS; | |
79 | } | |
7e8a74b1 MS |
80 | static inline const char *scsi_dh_attached_handler_name(struct request_queue *q, |
81 | gfp_t gfp) | |
82 | { | |
83 | return NULL; | |
84 | } | |
18ee70c9 CS |
85 | static inline int scsi_dh_set_params(struct request_queue *req, const char *params) |
86 | { | |
87 | return -SCSI_DH_NOSYS; | |
88 | } | |
fe9233fb | 89 | #endif |