diff options
Diffstat (limited to 'include/scsi/osd_initiator.h')
-rw-r--r-- | include/scsi/osd_initiator.h | 81 |
1 files changed, 69 insertions, 12 deletions
diff --git a/include/scsi/osd_initiator.h b/include/scsi/osd_initiator.h index 02bd9f716357..39d6d1097153 100644 --- a/include/scsi/osd_initiator.h +++ b/include/scsi/osd_initiator.h | |||
@@ -48,7 +48,6 @@ enum osd_std_version { | |||
48 | */ | 48 | */ |
49 | struct osd_dev { | 49 | struct osd_dev { |
50 | struct scsi_device *scsi_device; | 50 | struct scsi_device *scsi_device; |
51 | struct file *file; | ||
52 | unsigned def_timeout; | 51 | unsigned def_timeout; |
53 | 52 | ||
54 | #ifdef OSD_VER1_SUPPORT | 53 | #ifdef OSD_VER1_SUPPORT |
@@ -56,10 +55,24 @@ struct osd_dev { | |||
56 | #endif | 55 | #endif |
57 | }; | 56 | }; |
58 | 57 | ||
59 | /* Retrieve/return osd_dev(s) for use by Kernel clients */ | 58 | /* Unique Identification of an OSD device */ |
60 | struct osd_dev *osduld_path_lookup(const char *dev_name); /*Use IS_ERR/ERR_PTR*/ | 59 | struct osd_dev_info { |
60 | unsigned systemid_len; | ||
61 | u8 systemid[OSD_SYSTEMID_LEN]; | ||
62 | unsigned osdname_len; | ||
63 | u8 *osdname; | ||
64 | }; | ||
65 | |||
66 | /* Retrieve/return osd_dev(s) for use by Kernel clients | ||
67 | * Use IS_ERR/ERR_PTR on returned "osd_dev *". | ||
68 | */ | ||
69 | struct osd_dev *osduld_path_lookup(const char *dev_name); | ||
70 | struct osd_dev *osduld_info_lookup(const struct osd_dev_info *odi); | ||
61 | void osduld_put_device(struct osd_dev *od); | 71 | void osduld_put_device(struct osd_dev *od); |
62 | 72 | ||
73 | const struct osd_dev_info *osduld_device_info(struct osd_dev *od); | ||
74 | bool osduld_device_same(struct osd_dev *od, const struct osd_dev_info *odi); | ||
75 | |||
63 | /* Add/remove test ioctls from external modules */ | 76 | /* Add/remove test ioctls from external modules */ |
64 | typedef int (do_test_fn)(struct osd_dev *od, unsigned cmd, unsigned long arg); | 77 | typedef int (do_test_fn)(struct osd_dev *od, unsigned cmd, unsigned long arg); |
65 | int osduld_register_test(unsigned ioctl, do_test_fn *do_test); | 78 | int osduld_register_test(unsigned ioctl, do_test_fn *do_test); |
@@ -69,8 +82,24 @@ void osduld_unregister_test(unsigned ioctl); | |||
69 | void osd_dev_init(struct osd_dev *od, struct scsi_device *scsi_device); | 82 | void osd_dev_init(struct osd_dev *od, struct scsi_device *scsi_device); |
70 | void osd_dev_fini(struct osd_dev *od); | 83 | void osd_dev_fini(struct osd_dev *od); |
71 | 84 | ||
72 | /* some hi level device operations */ | 85 | /** |
73 | int osd_auto_detect_ver(struct osd_dev *od, void *caps); /* GFP_KERNEL */ | 86 | * osd_auto_detect_ver - Detect the OSD version, return Unique Identification |
87 | * | ||
88 | * @od: OSD target lun handle | ||
89 | * @caps: Capabilities authorizing OSD root read attributes access | ||
90 | * @odi: Retrieved information uniquely identifying the osd target lun | ||
91 | * Note: odi->osdname must be kfreed by caller. | ||
92 | * | ||
93 | * Auto detects the OSD version of the OSD target and sets the @od | ||
94 | * accordingly. Meanwhile also returns the "system id" and "osd name" root | ||
95 | * attributes which uniquely identify the OSD target. This member is usually | ||
96 | * called by the ULD. ULD users should call osduld_device_info(). | ||
97 | * This rutine allocates osd requests and memory at GFP_KERNEL level and might | ||
98 | * sleep. | ||
99 | */ | ||
100 | int osd_auto_detect_ver(struct osd_dev *od, | ||
101 | void *caps, struct osd_dev_info *odi); | ||
102 | |||
74 | static inline struct request_queue *osd_request_queue(struct osd_dev *od) | 103 | static inline struct request_queue *osd_request_queue(struct osd_dev *od) |
75 | { | 104 | { |
76 | return od->scsi_device->request_queue; | 105 | return od->scsi_device->request_queue; |
@@ -84,6 +113,15 @@ static inline void osd_dev_set_ver(struct osd_dev *od, enum osd_std_version v) | |||
84 | #endif | 113 | #endif |
85 | } | 114 | } |
86 | 115 | ||
116 | static inline bool osd_dev_is_ver1(struct osd_dev *od) | ||
117 | { | ||
118 | #ifdef OSD_VER1_SUPPORT | ||
119 | return od->version == OSD_VER1; | ||
120 | #else | ||
121 | return false; | ||
122 | #endif | ||
123 | } | ||
124 | |||
87 | struct osd_request; | 125 | struct osd_request; |
88 | typedef void (osd_req_done_fn)(struct osd_request *or, void *private); | 126 | typedef void (osd_req_done_fn)(struct osd_request *or, void *private); |
89 | 127 | ||
@@ -120,14 +158,9 @@ struct osd_request { | |||
120 | int async_error; | 158 | int async_error; |
121 | }; | 159 | }; |
122 | 160 | ||
123 | /* OSD Version control */ | ||
124 | static inline bool osd_req_is_ver1(struct osd_request *or) | 161 | static inline bool osd_req_is_ver1(struct osd_request *or) |
125 | { | 162 | { |
126 | #ifdef OSD_VER1_SUPPORT | 163 | return osd_dev_is_ver1(or->osd_dev); |
127 | return or->osd_dev->version == OSD_VER1; | ||
128 | #else | ||
129 | return false; | ||
130 | #endif | ||
131 | } | 164 | } |
132 | 165 | ||
133 | /* | 166 | /* |
@@ -234,7 +267,7 @@ int osd_execute_request_async(struct osd_request *or, | |||
234 | * @bad_attr_list - List of failing attributes (optional) | 267 | * @bad_attr_list - List of failing attributes (optional) |
235 | * @max_attr - Size of @bad_attr_list. | 268 | * @max_attr - Size of @bad_attr_list. |
236 | * | 269 | * |
237 | * After execution, sense + return code can be analyzed using this function. The | 270 | * After execution, osd_request results are analyzed using this function. The |
238 | * return code is the final disposition on the error. So it is possible that a | 271 | * return code is the final disposition on the error. So it is possible that a |
239 | * CHECK_CONDITION was returned from target but this will return NO_ERROR, for | 272 | * CHECK_CONDITION was returned from target but this will return NO_ERROR, for |
240 | * example on recovered errors. All parameters are optional if caller does | 273 | * example on recovered errors. All parameters are optional if caller does |
@@ -243,7 +276,31 @@ int osd_execute_request_async(struct osd_request *or, | |||
243 | * of the SCSI_OSD_DPRINT_SENSE Kconfig value. Set @silent if you know the | 276 | * of the SCSI_OSD_DPRINT_SENSE Kconfig value. Set @silent if you know the |
244 | * command would routinely fail, to not spam the dmsg file. | 277 | * command would routinely fail, to not spam the dmsg file. |
245 | */ | 278 | */ |
279 | |||
280 | /** | ||
281 | * osd_err_priority - osd categorized return codes in ascending severity. | ||
282 | * | ||
283 | * The categories are borrowed from the pnfs_osd_errno enum. | ||
284 | * See comments for translated Linux codes returned by osd_req_decode_sense. | ||
285 | */ | ||
286 | enum osd_err_priority { | ||
287 | OSD_ERR_PRI_NO_ERROR = 0, | ||
288 | /* Recoverable, caller should clear_highpage() all pages */ | ||
289 | OSD_ERR_PRI_CLEAR_PAGES = 1, /* -EFAULT */ | ||
290 | OSD_ERR_PRI_RESOURCE = 2, /* -ENOMEM */ | ||
291 | OSD_ERR_PRI_BAD_CRED = 3, /* -EINVAL */ | ||
292 | OSD_ERR_PRI_NO_ACCESS = 4, /* -EACCES */ | ||
293 | OSD_ERR_PRI_UNREACHABLE = 5, /* any other */ | ||
294 | OSD_ERR_PRI_NOT_FOUND = 6, /* -ENOENT */ | ||
295 | OSD_ERR_PRI_NO_SPACE = 7, /* -ENOSPC */ | ||
296 | OSD_ERR_PRI_EIO = 8, /* -EIO */ | ||
297 | }; | ||
298 | |||
246 | struct osd_sense_info { | 299 | struct osd_sense_info { |
300 | u64 out_resid; /* Zero on success otherwise out residual */ | ||
301 | u64 in_resid; /* Zero on success otherwise in residual */ | ||
302 | enum osd_err_priority osd_err_pri; | ||
303 | |||
247 | int key; /* one of enum scsi_sense_keys */ | 304 | int key; /* one of enum scsi_sense_keys */ |
248 | int additional_code ; /* enum osd_additional_sense_codes */ | 305 | int additional_code ; /* enum osd_additional_sense_codes */ |
249 | union { /* Sense specific information */ | 306 | union { /* Sense specific information */ |